Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: New Picker interactive #691

Merged
merged 381 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
381 commits
Select commit Hold shift + click to select a range
82a3496
fix: preset should not trigger when invalidate
zombieJ Nov 15, 2023
20b6c1b
fix: block disabled
zombieJ Nov 15, 2023
5bd78fc
fix: picker logic
zombieJ Nov 15, 2023
f28a5ee
test: no clickable
zombieJ Nov 15, 2023
9d08d4f
test: more test case
zombieJ Nov 15, 2023
580619d
chore: init needConfirm prop def
zombieJ Nov 16, 2023
599df4c
refactor: needConfirm logic
zombieJ Nov 17, 2023
f9f99ce
fix: new test case
zombieJ Nov 17, 2023
9be9ac3
fix: lock logic
zombieJ Nov 17, 2023
176ec51
fix: active logic
zombieJ Nov 17, 2023
d185e00
fix: no need hover
zombieJ Nov 17, 2023
6856ec6
test: fix test case
zombieJ Nov 17, 2023
f47df51
chore: init logic desc
zombieJ Nov 20, 2023
f52d485
chore: new confirm logic
zombieJ Nov 20, 2023
f16a404
chore: renew flush logic
zombieJ Nov 20, 2023
e5ca270
chore: tmp of it
zombieJ Nov 20, 2023
e14d476
chore: sync flush
zombieJ Nov 20, 2023
137d0eb
chore: rm submit effect
zombieJ Nov 21, 2023
854650c
chore: off it
zombieJ Nov 21, 2023
4e693a8
chore: support switch on !needConfirm
zombieJ Nov 21, 2023
8102445
chore: open logic
zombieJ Nov 21, 2023
559e92b
fix: part logic
zombieJ Nov 21, 2023
ebf50cf
chore: fix validate logic
zombieJ Nov 21, 2023
2ad4a82
chore: clean up
zombieJ Nov 21, 2023
427f3b5
test: more test case
zombieJ Nov 22, 2023
dd12fad
chore: dbl click
zombieJ Nov 23, 2023
48a13f8
refactor: motion scroll
zombieJ Nov 23, 2023
0cceb07
chore: clean up
zombieJ Nov 23, 2023
623051d
test: dbl click
zombieJ Nov 23, 2023
f49a481
chore: all the logic
zombieJ Nov 23, 2023
a0cb25a
chore: open false also can submit
zombieJ Nov 23, 2023
5a35a04
chore: open false also can submit
zombieJ Nov 23, 2023
5dfb6e1
fix: scroll sync
zombieJ Nov 23, 2023
1eb43c4
fix: logic missing
zombieJ Nov 23, 2023
97f2f92
feat: input support render
zombieJ Nov 29, 2023
b71f94e
test: reset with onChange
zombieJ Nov 29, 2023
a29cdd1
chore: resize also realign the popup
zombieJ Nov 29, 2023
ad107fa
test: fix test case
zombieJ Nov 29, 2023
12634ba
chore: enter to submit
zombieJ Nov 29, 2023
79be686
test: coverage
zombieJ Nov 29, 2023
e7573ac
test: test driven
zombieJ Nov 29, 2023
ef43217
fix: onPickerValue change
zombieJ Nov 29, 2023
b8ce81a
feat: focus provider it
zombieJ Nov 30, 2023
a9e797e
chore: focus info
zombieJ Nov 30, 2023
b6b8b0c
chore: fix warning message
zombieJ Dec 1, 2023
ea935e7
chore: part ts
zombieJ Dec 1, 2023
744c062
chore: ability
zombieJ Dec 1, 2023
cccc1c0
chore: more ts
zombieJ Dec 1, 2023
2eddf2f
chore: tmp of it
zombieJ Dec 1, 2023
72091db
refactor: split calendarValue
zombieJ Dec 1, 2023
8c2f684
chore: clean up
zombieJ Dec 1, 2023
9eea205
chore: tmp of it
zombieJ Dec 1, 2023
a8a96f1
chore: tmp of it
zombieJ Dec 1, 2023
7e9f23f
chore: all disabled logic
zombieJ Dec 3, 2023
ae6119b
chore: tmp of it
zombieJ Dec 4, 2023
aebbe66
chore: pickerValue
zombieJ Dec 4, 2023
f8f5ce8
chore: new pickerValue logic
zombieJ Dec 4, 2023
a5a413e
chore: clean up
zombieJ Dec 4, 2023
4914dd0
test: 7 days
zombieJ Dec 4, 2023
ace680e
feat: auto limit
zombieJ Dec 4, 2023
83e5533
chore: comment it
zombieJ Dec 4, 2023
55e4a4e
chore: sync in range
zombieJ Dec 4, 2023
e766d2c
test: add test case
zombieJ Dec 4, 2023
9d7fd22
test: update test case
zombieJ Dec 4, 2023
47ab3e6
refactor: use changeOnBlur
zombieJ Dec 5, 2023
b923033
test: update test case
zombieJ Dec 5, 2023
f65ef7e
docs: update
zombieJ Dec 5, 2023
1a18513
chore: tmp of it
zombieJ Dec 5, 2023
645ffc0
chore: tmp of it
zombieJ Dec 5, 2023
3304389
chore: tmp of it
zombieJ Dec 5, 2023
7f6e8ba
chore: tmp of it
zombieJ Dec 5, 2023
b284261
chore: clean up
zombieJ Dec 5, 2023
9c187e1
chore: single selector
zombieJ Dec 5, 2023
6828a11
chore: tmp of it
zombieJ Dec 5, 2023
4ac3009
chore: tmp of it
zombieJ Dec 5, 2023
706040b
chore: tmp of it
zombieJ Dec 6, 2023
29ddd6e
chore: tmp of it
zombieJ Dec 6, 2023
3cb73c9
refactor: generic of useUtil
zombieJ Dec 6, 2023
d1f7651
refactor: generic of SinglePicker
zombieJ Dec 6, 2023
6425fbf
chore: tmp of it
zombieJ Dec 6, 2023
42e6fbe
chore: merge filled logic
zombieJ Dec 6, 2023
c0bc3e5
refactor: more hooks
zombieJ Dec 6, 2023
8365a39
chore: comment it
zombieJ Dec 6, 2023
7326a75
chore: move more
zombieJ Dec 6, 2023
d60c648
chore: more exclude
zombieJ Dec 6, 2023
c40f8b5
chore: ts update
zombieJ Dec 6, 2023
bf0fa88
chore: move more
zombieJ Dec 6, 2023
2e5ccb5
chore: fix type
zombieJ Dec 6, 2023
a71aed3
chore: merge code
zombieJ Dec 6, 2023
6c68505
chore: more info
zombieJ Dec 6, 2023
78a7a33
chore: clean up
zombieJ Dec 6, 2023
fe57078
chore: fix type
zombieJ Dec 6, 2023
a4c2bf7
fix: event
zombieJ Dec 6, 2023
c23740e
chore: unique
zombieJ Dec 7, 2023
6f0a729
chore: tmp of it
zombieJ Dec 7, 2023
bffb149
chore: merge more
zombieJ Dec 7, 2023
8a5805d
chore: tmp of it
zombieJ Dec 7, 2023
52dce60
chore: tmp of it
zombieJ Dec 7, 2023
deac496
chore: refix Range type
zombieJ Dec 7, 2023
a0ecd44
chore: fix type
zombieJ Dec 7, 2023
d673310
chore: move more
zombieJ Dec 7, 2023
65a1683
chore: fix type
zombieJ Dec 7, 2023
56efe0d
chore: fix type
zombieJ Dec 7, 2023
de22724
chore: more
zombieJ Dec 7, 2023
9f70922
chore: more ts
zombieJ Dec 7, 2023
8973dee
chore: more types
zombieJ Dec 7, 2023
77bd724
chore: more types
zombieJ Dec 7, 2023
edbdba1
chore: fix mode change
zombieJ Dec 7, 2023
8b676d0
chore: clean up
zombieJ Dec 7, 2023
1936a30
chore: more info
zombieJ Dec 8, 2023
1a9496b
chore: more info
zombieJ Dec 8, 2023
a7899be
chore: rename to onSelect
zombieJ Dec 8, 2023
af4707a
refactor: rename onCalendarChange to onSelect
zombieJ Dec 8, 2023
9d770e9
chore: ts support multiple
zombieJ Dec 8, 2023
39c55a2
chore: tmp of it
zombieJ Dec 8, 2023
44cb6c2
chore: split code
zombieJ Dec 8, 2023
4ccfdf5
refactor: type of it
zombieJ Dec 8, 2023
86e182c
chore: clean up
zombieJ Dec 8, 2023
610b134
refactor: pass type
zombieJ Dec 8, 2023
6a46dd5
chore: part of it
zombieJ Dec 8, 2023
76f8ea2
chore: tmp of selection
zombieJ Dec 11, 2023
e65bbec
refactor: toggle logic outside
zombieJ Dec 11, 2023
5a0d5f4
refactor: use unique panelType
zombieJ Dec 11, 2023
7bfe07d
refactor: logic adjust
zombieJ Dec 11, 2023
ce91cc0
chore: support panel multiple
zombieJ Dec 11, 2023
a7b0534
chore: tmp of def
zombieJ Dec 11, 2023
975c730
chore: more ts
zombieJ Dec 11, 2023
557b5cf
chore: fix ts logic
zombieJ Dec 11, 2023
9c61715
chore: refactor part of code
zombieJ Dec 11, 2023
a59794a
chore: fix SinglePicker warning
zombieJ Dec 11, 2023
a4d8dbc
chore: adjust useInput logic
zombieJ Dec 11, 2023
7c549cf
chore: fix crash
zombieJ Dec 11, 2023
6fcd8f2
fix: allowEmpty check
zombieJ Dec 11, 2023
3a7ab99
chore: merged values
zombieJ Dec 11, 2023
dce8902
chore: fix logic
zombieJ Dec 11, 2023
aa7c365
chore: part refactor of range values
zombieJ Dec 11, 2023
aabab2e
chore: unique disabled submit check
zombieJ Dec 11, 2023
e2bde21
chore: move order type to interface
zombieJ Dec 11, 2023
0d67f41
chore: change after close
zombieJ Dec 11, 2023
2977030
test: part of test
zombieJ Dec 11, 2023
e530ecb
fix: should not open when all disabled
zombieJ Dec 11, 2023
dd3498e
fix: go to emptys
zombieJ Dec 11, 2023
efa85e8
fix: change logic
zombieJ Dec 11, 2023
170cb15
chore: add missing picker reset
zombieJ Dec 11, 2023
c08c512
fix: invalidate logic
zombieJ Dec 11, 2023
9d9278d
chore: tmp of demo
zombieJ Dec 12, 2023
ffc4429
chore: onPickerValue change also provide the mode info
zombieJ Dec 12, 2023
67b6da5
chore: adjust logic
zombieJ Dec 12, 2023
a4697bc
refactor: rollback
zombieJ Dec 12, 2023
3c4c9fb
chore: add comment
zombieJ Dec 12, 2023
b4f5b04
chore: all trigger panelChange
zombieJ Dec 12, 2023
30accbd
chore: fix decade format
zombieJ Dec 12, 2023
e0e6ebd
chore: refactoring of OK logic
zombieJ Dec 12, 2023
886cc78
chore: add onNow btn
zombieJ Dec 12, 2023
03845ee
fix: now should block
zombieJ Dec 12, 2023
8133736
test: update snapshot
zombieJ Dec 12, 2023
1094139
chore: depecated inputRender
zombieJ Dec 12, 2023
451794e
test: fix test case
zombieJ Dec 12, 2023
9fecfb8
test: fix test case
zombieJ Dec 12, 2023
e4c8201
fix: showNow on time
zombieJ Dec 12, 2023
f2167f5
chore: support of it
zombieJ Dec 12, 2023
af2a6a3
refactor: support ts
zombieJ Dec 12, 2023
72adca1
chore: adjust align
zombieJ Dec 13, 2023
fa66ef5
chore: useHookContext
zombieJ Dec 13, 2023
bd548f3
refactor: move in hooks
zombieJ Dec 13, 2023
1196285
refactor: move in hooks
zombieJ Dec 13, 2023
a95635d
chore: clean up
zombieJ Dec 13, 2023
3051093
chore: support of content format
zombieJ Dec 13, 2023
d4991fb
chore: fix logic
zombieJ Dec 13, 2023
54445e8
test: fix test case
zombieJ Dec 13, 2023
4393087
chore: tmp of it
zombieJ Dec 13, 2023
913fbf4
test: update snapshot
zombieJ Dec 14, 2023
f3338df
chore: pick props
zombieJ Dec 14, 2023
4b8d952
chore: fix props
zombieJ Dec 14, 2023
272b599
fix: reset logic
zombieJ Dec 14, 2023
0049767
test: update snapshot
zombieJ Dec 14, 2023
e1b903c
chore: fix type
zombieJ Dec 14, 2023
c009edf
test: update test case
zombieJ Dec 14, 2023
67126da
fix: Enter should open picker
zombieJ Dec 14, 2023
872432e
fix: missing onKeyDown
zombieJ Dec 14, 2023
ffdf577
chore: move preventDefault to native event
zombieJ Dec 14, 2023
b8ffa39
test: all test
zombieJ Dec 15, 2023
cd0165e
test: update blur test
zombieJ Dec 15, 2023
0ead4fb
chore: preserveInvalidOnBlur
zombieJ Dec 15, 2023
bbe500d
chore: wrap info
zombieJ Dec 15, 2023
c2cddea
clean up
zombieJ Dec 15, 2023
5cd1296
fix: disabledTime range
zombieJ Dec 15, 2023
0790bec
fix: disabled logic
zombieJ Dec 15, 2023
62bd662
chore: fix type
zombieJ Dec 15, 2023
9abcc8b
refactor: part
zombieJ Dec 15, 2023
0f7ee6f
chore: fix selection
zombieJ Dec 15, 2023
9a7c601
chore: tmp of it
zombieJ Dec 15, 2023
5373c08
chore: add warning
zombieJ Dec 15, 2023
974dbdc
fix: panel switch
zombieJ Dec 15, 2023
2c422e0
fix: clear test
zombieJ Dec 15, 2023
3effdea
test: update snapshot
zombieJ Dec 15, 2023
854f925
test: update test case
zombieJ Dec 15, 2023
5991a09
chore: add rtl
zombieJ Dec 15, 2023
d9e2ba7
chore: back of warning
zombieJ Dec 15, 2023
2f77ee3
test: more test case
zombieJ Dec 15, 2023
28c9a1e
test: more test case
zombieJ Dec 15, 2023
056f09c
test: update snapshot
zombieJ Dec 15, 2023
bb59038
test: find
zombieJ Dec 15, 2023
ad3130f
chore: picker test
zombieJ Dec 15, 2023
5de6a07
chore: tmp of it
zombieJ Dec 18, 2023
3ab6af4
chore: selection
zombieJ Dec 18, 2023
09ce516
chore: multiple values
zombieJ Dec 18, 2023
458d82d
chore: multiple style
zombieJ Dec 18, 2023
d9ffa30
chore: not trigger change when opened
zombieJ Dec 18, 2023
4b9d693
test: add test case
zombieJ Dec 18, 2023
e5ad1b7
test: add test case
zombieJ Dec 18, 2023
5c9de42
chore: clean types
zombieJ Dec 18, 2023
4522864
chore: clean up
zombieJ Dec 18, 2023
e6ff34f
clean up
zombieJ Dec 18, 2023
f4c7890
clean up
zombieJ Dec 18, 2023
c41b2d6
chore: merge code
zombieJ Dec 18, 2023
ab77693
test: coverage
zombieJ Dec 18, 2023
2339f4b
chore: refactoring
zombieJ Dec 18, 2023
0692d60
chore: refactoring
zombieJ Dec 18, 2023
9afa1df
chore: fix more ts
zombieJ Dec 18, 2023
2b3d337
chore: ts part
zombieJ Dec 18, 2023
bd77974
refactor: move hooks
zombieJ Dec 18, 2023
f221272
refactor: move hooks
zombieJ Dec 18, 2023
c280323
refactor: move util
zombieJ Dec 19, 2023
c853785
refactor: move index
zombieJ Dec 19, 2023
ba7340d
refactor: move trigger
zombieJ Dec 19, 2023
c291701
refactor: move part panels
zombieJ Dec 19, 2023
c906129
refactor: move part panels
zombieJ Dec 19, 2023
88fadfb
fix: link code
zombieJ Dec 19, 2023
27a127d
refactor: clean up
zombieJ Dec 19, 2023
9d6e64b
refactor: move picker
zombieJ Dec 19, 2023
acf802a
refactor: move picker hooks
zombieJ Dec 19, 2023
cba9a0b
refactor: move picker popup
zombieJ Dec 19, 2023
10662a9
refactor: move picker seletor hooks
zombieJ Dec 19, 2023
9e93836
refactor: placement pass support
zombieJ Dec 19, 2023
5eb891b
test: coverage
zombieJ Dec 20, 2023
c2b3fe9
test: coverage
zombieJ Dec 20, 2023
f32d410
docs: fix demo
zombieJ Dec 20, 2023
b7e49aa
refactor: fix demo
zombieJ Dec 20, 2023
7ffa8a8
docs: more demo
zombieJ Dec 20, 2023
f1af539
chore: fix break
zombieJ Dec 21, 2023
775edde
fix: pickerProps logic
zombieJ Dec 21, 2023
349a1af
chore: clean up
zombieJ Dec 21, 2023
2b3153b
test: coverage
zombieJ Dec 25, 2023
78252b4
test: coverage
zombieJ Dec 25, 2023
8d08d41
refactor: hover values
zombieJ Dec 25, 2023
049d938
refactor: split hover
zombieJ Dec 25, 2023
a20e556
chore: support hover
zombieJ Dec 25, 2023
9d14434
chore: clean up
zombieJ Dec 25, 2023
38137eb
chore: coverage
zombieJ Dec 25, 2023
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
91 changes: 85 additions & 6 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

@input-placeholder-color: hsv(0, 0, 75%);

@time-panel-padding-total: 180px;
// @time-panel-padding-top: 90px;
@time-panel-padding-top: 0;

.placeholder(@color: @input-placeholder-color) {
// Firefox
&::-moz-placeholder {
Expand All @@ -20,6 +24,7 @@
}

.@{prefix-cls} {
position: relative;
display: inline-flex;

&-rtl {
Expand All @@ -29,6 +34,9 @@
&-focused {
border: 1px solid blue;
}
&-invalid {
box-shadow: 0 0 2px red;
}
&-panel {
display: inline-block;
vertical-align: top;
Expand Down Expand Up @@ -115,6 +123,11 @@
&-in-range > &-inner {
background: fade(blue, 5%);
}

&-hover > &-inner {
background: orange;
}

&-range-hover-start,
&-range-hover-end,
&-range-hover {
Expand Down Expand Up @@ -249,15 +262,39 @@
width: auto;

.@{prefix-cls}-content {
position: relative;
display: flex;
max-height: 200px;

// &::after {
// position: absolute;
// top: @time-panel-padding-top;
// right: -5px;
// left: -5px;
// height: 20px;
// background: rgba(255, 0, 0, 0.05);
// content: '';
// pointer-events: none;
// }
}

&-column-holder {
display: flex;
flex-direction: column;
text-align: center;
}

&-column-title {
font-size: 14px;
line-height: 20px;
}

&-column {
flex: none;
flex: auto;
width: 50px;
margin: 0;
padding: 0 0 180px 0;
// padding: 0 0 180px 0;
padding: @time-panel-padding-top 0 (@time-panel-padding-total - @time-panel-padding-top);
overflow-x: hidden;
overflow-y: hidden;
font-size: 12px;
Expand All @@ -274,6 +311,7 @@
}

> li {
width: 50px;
margin: 0;
padding: 0;
cursor: pointer;
Expand All @@ -282,17 +320,21 @@
&-disabled {
opacity: 0.5;
}

&-selected {
background: rgba(0, 0, 255, 0.5);
}
}

.@{prefix-cls}-time-panel-cell-inner {
display: block;
width: 100%;
height: 20px;
margin: 0;
padding: 0 0 0 12px;
// padding: 0 0 0 12px;
color: #333;
line-height: 20px;
text-align: left;
text-align: center;

.@{prefix-cls}-panel-rtl & {
padding: 0 12px 0 0;
Expand Down Expand Up @@ -339,6 +381,12 @@
text-align: right;
}

&-active {
> input {
background: rgba(0, 0, 255, 0.05);
}
}

> input {
width: 100%;
.placeholder();
Expand Down Expand Up @@ -371,6 +419,7 @@
&-dropdown {
position: absolute;
box-shadow: 0 0 1px red;
pointer-events: none;

&-range {
padding: 10px 0;
Expand All @@ -393,7 +442,7 @@
&-placement-bottomLeft,
&-placement-bottomright {
.@{prefix-cls}-range-arrow {
top: @arrow-size / 2 + 1px;
top: (@arrow-size / 2 + 1px);
transform: rotate(-45deg);
}
}
Expand Down Expand Up @@ -433,7 +482,7 @@
&::before {
width: @arrow-size;
height: @arrow-size;
border: @arrow-size / 2 solid blue;
border: (@arrow-size / 2) solid blue;
border-color: blue blue transparent transparent;
}
&::after {
Expand Down Expand Up @@ -476,11 +525,41 @@
display: inline-block;
vertical-align: top;
transition: margin 0.3s;
pointer-events: all;
}

&-panel-layout {
display: flex;
flex-wrap: nowrap;
align-items: stretch;
}

// ========================================================
// = Overflow =
// ========================================================
&-selector {
width: 100%;
}

&-selection-overflow {
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
width: 100%;
border: 1px solid green;

&-item {
flex: none;
max-width: 100%;
}
}

&-selection-item {
border: 1px solid blue;
}

&-multiple-input {
width: 10px;
opacity: 0.1;
}
}
8 changes: 8 additions & 0 deletions docs/demo/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: debug
nav:
title: Demo
path: /demo
---

<code src="../examples/debug.tsx"></code>
12 changes: 6 additions & 6 deletions docs/examples/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import type { Moment } from 'moment';
import moment from 'moment';
import Picker from '../../src/Picker';
import React from 'react';
import '../../assets/index.less';
import { Picker, type PickerRef } from '../../src';
import momentGenerateConfig from '../../src/generate/moment';
import zhCN from '../../src/locale/zh_CN';
import enUS from '../../src/locale/en_US';
import '../../assets/index.less';
import zhCN from '../../src/locale/zh_CN';

// const defaultValue = moment('2019-09-03 05:02:03');
const defaultValue = moment('2019-11-28 01:02:03');

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);
Expand All @@ -36,7 +36,7 @@ export default () => {
{
label: 'Now',
value: () => moment(),
}
},
],
};

Expand Down
7 changes: 3 additions & 4 deletions docs/examples/calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Moment } from 'moment';
import React from 'react';
import { Moment } from 'moment';
import Picker from '../../src/Picker';
import PickerPanel from '../../src/PickerPanel';
import '../../assets/index.less';
import { Picker, PickerPanel } from '../../src';
import momentGenerateConfig from '../../src/generate/moment';
import zhCN from '../../src/locale/zh_CN';
import '../../assets/index.less';
import './calendar.less';

function dateRender(date: Moment, today: Moment) {
Expand Down
35 changes: 21 additions & 14 deletions docs/examples/cellRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import type { Moment } from 'moment';
import moment from 'moment';
import React from 'react';
import '../../assets/index.less';
import { Picker, RangePicker } from '../../src';
import momentGenerateConfig from '../../src/generate/moment';
import zhCN from '../../src/locale/zh_CN';
import Picker from '../../src/Picker';
import RangePicker from '../../src/RangePicker';

const defaultValue = moment('2019-11-28 01:02:03');

Expand All @@ -23,7 +22,6 @@ export default () => {
defaultEndValue,
]);


const onSelect = (newValue: Moment) => {
console.log('Select:', newValue);
};
Expand All @@ -46,7 +44,10 @@ export default () => {
],
};

const onRangeChange = (newValue: [Moment | null, Moment | null] | null, formatStrings?: string[]) => {
const onRangeChange = (
newValue: [Moment | null, Moment | null] | null,
formatStrings?: string[],
) => {
console.log('Change:', newValue, formatStrings);
setRangeValue(newValue);
};
Expand All @@ -66,7 +67,7 @@ export default () => {
<Picker<Moment>
{...sharedProps}
locale={zhCN}
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -79,7 +80,7 @@ export default () => {
<Picker<Moment>
{...sharedProps}
locale={zhCN}
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -93,7 +94,7 @@ export default () => {
{...sharedProps}
locale={zhCN}
picker="week"
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -107,7 +108,7 @@ export default () => {
{...sharedProps}
locale={zhCN}
picker="year"
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -121,7 +122,7 @@ export default () => {
{...sharedProps}
locale={zhCN}
picker="month"
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -135,7 +136,7 @@ export default () => {
{...sharedProps}
locale={zhCN}
picker="quarter"
cellRender={(current, info) =>
cellRender={(current: Moment, info) =>
React.cloneElement(
info.originNode,
{
Expand All @@ -162,17 +163,23 @@ export default () => {
</div>
<div style={{ margin: '0 8px' }}>
<h3>Range</h3>
<h4>RangeValue: {rangeValue ? `${formatDate(rangeValue[0])} ~ ${formatDate(rangeValue[1])}` : 'null'}</h4>
<h4>
RangeValue:{' '}
{rangeValue ? `${formatDate(rangeValue[0])} ~ ${formatDate(rangeValue[1])}` : 'null'}
</h4>
<RangePicker<Moment>
{...rangeSharedProps}
locale={zhCN}
allowClear
showTime
style={{ width: 580 }}
cellRender={(current, info) => {
cellRender={(current: Moment, info) => {
return (
<div title={info.type} style={{ background: info.type === 'time' ? 'green' : 'yellow' }}>
{info.type === "time" ? current : current.get('date')}
<div
title={info.type}
style={{ background: info.type === 'time' ? 'green' : 'yellow' }}
>
{info.type === 'time' ? current : current.get('date')}
</div>
);
}}
Expand Down
Loading
Loading