Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 5 additions & 114 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,6 @@
name: CI

on: ['push', 'pull_request']

name: ✅ test
on: [push, pull_request]
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: cache package-lock.json
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: create package-lock.json
run: npm i --package-lock-only --ignore-scripts

- name: hack for singe file
run: |
if [ ! -d "package-temp-dir" ]; then
mkdir package-temp-dir
fi
cp package-lock.json package-temp-dir

- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci

lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: lint
run: npm run lint

needs: setup

compile:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: compile
run: npm run compile

needs: setup

coverage:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: restore cache from package-lock.json
uses: actions/cache@v4
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: coverage
run: npm test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

needs: setup
test:
uses: react-component/rc-test/.github/workflows/test.yml@main
secrets: inherit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ coverage/

# dumi
.dumi/tmp
.dumi/tmp-production
.dumi/tmp-production

bun.lockb
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
peer = false
6 changes: 3 additions & 3 deletions docs/examples/cellRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default () => {
{...sharedProps}
locale={zhCN}
picker="time"
cellRender={(current, info) =>
cellRender={(current: number | string, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -173,13 +173,13 @@ export default () => {
allowClear
showTime
style={{ width: 580 }}
cellRender={(current: Moment, info) => {
cellRender={(current, info) => {
return (
<div
title={info.type}
style={{ background: info.type === 'time' ? 'green' : 'yellow' }}
>
{info.type === 'time' ? current : current.get('date')}
{info.type === 'time' ? (current as number) : (current as Moment).get('date')}
</div>
);
}}
Expand Down
1 change: 1 addition & 0 deletions docs/examples/customize.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import moment, { type Moment } from 'moment';
import * as React from 'react';
import '../../assets/index.less';
Expand Down
14 changes: 10 additions & 4 deletions docs/examples/rtl.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import moment, { type Moment } from 'moment';
import React from 'react';
import '../../assets/index.less';
import type { PickerRef } from '../../src/';
import { Picker, PickerPanel, RangePicker } from '../../src/';
import momentGenerateConfig from '../../src/generate/moment';
import enUS from '../../src/locale/en_US';
import jaJP from '../../src/locale/ja_JP';
import zhCN from '../../src/locale/zh_CN';
import type { RangePickerRef } from '@/interface';
import type { NoUndefinedRangeValueType } from '@/PickerInput/RangePicker';

const defaultValue = moment();

Expand All @@ -16,13 +19,16 @@ function formatDate(date: Moment | null) {
export default () => {
const [value, setValue] = React.useState<Moment | null>(defaultValue);

const weekRef = React.useRef<Picker<Moment>>(null);
const weekRef = React.useRef<PickerRef>(null);

const onSelect = (newValue: Moment) => {
console.log('Select:', newValue);
};

const onChange = (newValue: Moment | null, formatString?: string) => {
const onChange = (
newValue: NoUndefinedRangeValueType<Moment>,
formatString?: string | [string, string],
) => {
const lastValue = Array.isArray(newValue) ? newValue[1] : newValue;
console.log('Change:', lastValue, newValue, formatString);
setValue(lastValue);
Expand All @@ -33,10 +39,10 @@ export default () => {
value,
onSelect,
onChange,
direction: 'rtl',
direction: 'rtl' as const,
};

const rangePickerRef = React.useRef<RangePicker<Moment>>(null);
const rangePickerRef = React.useRef<RangePickerRef>(null);

return (
<div dir="rtl">
Expand Down
Loading