@douyinfe/semi-ui 2.10.2 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/anchor/link.tsx +2 -2
- package/autoComplete/index.tsx +3 -3
- package/avatar/interface.ts +2 -2
- package/badge/index.tsx +1 -1
- package/banner/index.tsx +4 -4
- package/breadcrumb/bread-context.tsx +1 -1
- package/card/cardGroup.tsx +1 -1
- package/card/index.tsx +1 -1
- package/cascader/index.tsx +4 -4
- package/checkbox/checkbox.tsx +16 -6
- package/collapse/index.tsx +1 -1
- package/collapse/item.tsx +1 -1
- package/collapsible/index.tsx +1 -1
- package/datePicker/_story/datePicker.stories.js +48 -1
- package/datePicker/_story/v2/AutoFillTime.jsx +37 -0
- package/datePicker/_story/v2/InputFormat.jsx +29 -0
- package/datePicker/_story/v2/InputFormatConfirm.jsx +44 -0
- package/datePicker/_story/v2/InputFormatDisabled.jsx +27 -0
- package/datePicker/_story/v2/index.js +4 -0
- package/datePicker/dateInput.tsx +7 -0
- package/datePicker/datePicker.tsx +7 -11
- package/datePicker/monthsGrid.tsx +2 -1
- package/descriptions/item.tsx +1 -1
- package/dist/umd/semi-ui.js +521 -197
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/empty/index.tsx +1 -1
- package/form/errorMessage.tsx +1 -1
- package/form/interface.ts +1 -1
- package/form/label.tsx +1 -1
- package/form/section.tsx +2 -2
- package/form/slot.tsx +1 -1
- package/layout/Sider.tsx +1 -1
- package/lib/cjs/anchor/link.d.ts +2 -2
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.js +1 -1
- package/lib/cjs/avatar/interface.d.ts +2 -2
- package/lib/cjs/badge/index.d.ts +1 -1
- package/lib/cjs/banner/index.d.ts +4 -4
- package/lib/cjs/breadcrumb/bread-context.d.ts +1 -1
- package/lib/cjs/card/cardGroup.d.ts +1 -1
- package/lib/cjs/card/index.d.ts +1 -1
- package/lib/cjs/cascader/index.d.ts +1 -1
- package/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +23 -11
- package/lib/cjs/collapse/index.d.ts +1 -1
- package/lib/cjs/collapse/item.d.ts +1 -1
- package/lib/cjs/collapsible/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -0
- package/lib/cjs/datePicker/dateInput.js +5 -3
- package/lib/cjs/datePicker/datePicker.js +9 -12
- package/lib/cjs/datePicker/monthsGrid.js +2 -1
- package/lib/cjs/descriptions/item.d.ts +1 -1
- package/lib/cjs/empty/index.d.ts +1 -1
- package/lib/cjs/form/errorMessage.d.ts +1 -1
- package/lib/cjs/form/interface.d.ts +1 -1
- package/lib/cjs/form/label.d.ts +1 -1
- package/lib/cjs/form/section.d.ts +2 -2
- package/lib/cjs/form/slot.d.ts +1 -1
- package/lib/cjs/layout/Sider.d.ts +1 -1
- package/lib/cjs/list/index.d.ts +1 -1
- package/lib/cjs/list/item.d.ts +1 -1
- package/lib/cjs/modal/Modal.d.ts +5 -5
- package/lib/cjs/modal/ModalContent.d.ts +1 -1
- package/lib/cjs/modal/confirm.d.ts +4 -2
- package/lib/cjs/modal/useModal/index.d.ts +16 -23
- package/lib/cjs/navigation/Footer.d.ts +1 -1
- package/lib/cjs/radio/radio.d.ts +4 -0
- package/lib/cjs/radio/radio.js +26 -12
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/sideSheet/SideSheetContent.d.ts +1 -1
- package/lib/cjs/table/interface.d.ts +1 -1
- package/lib/cjs/tag/group.d.ts +3 -3
- package/lib/cjs/timeline/index.d.ts +1 -1
- package/lib/cjs/timeline/item.d.ts +1 -1
- package/lib/cjs/tooltip/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.js +6 -1
- package/lib/es/anchor/link.d.ts +2 -2
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/autoComplete/index.js +1 -1
- package/lib/es/avatar/interface.d.ts +2 -2
- package/lib/es/badge/index.d.ts +1 -1
- package/lib/es/banner/index.d.ts +4 -4
- package/lib/es/breadcrumb/bread-context.d.ts +1 -1
- package/lib/es/card/cardGroup.d.ts +1 -1
- package/lib/es/card/index.d.ts +1 -1
- package/lib/es/cascader/index.d.ts +1 -1
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +23 -11
- package/lib/es/collapse/index.d.ts +1 -1
- package/lib/es/collapse/item.d.ts +1 -1
- package/lib/es/collapsible/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -0
- package/lib/es/datePicker/dateInput.js +5 -3
- package/lib/es/datePicker/datePicker.js +9 -12
- package/lib/es/datePicker/monthsGrid.js +2 -1
- package/lib/es/descriptions/item.d.ts +1 -1
- package/lib/es/empty/index.d.ts +1 -1
- package/lib/es/form/errorMessage.d.ts +1 -1
- package/lib/es/form/interface.d.ts +1 -1
- package/lib/es/form/label.d.ts +1 -1
- package/lib/es/form/section.d.ts +2 -2
- package/lib/es/form/slot.d.ts +1 -1
- package/lib/es/layout/Sider.d.ts +1 -1
- package/lib/es/list/index.d.ts +1 -1
- package/lib/es/list/item.d.ts +1 -1
- package/lib/es/modal/Modal.d.ts +5 -5
- package/lib/es/modal/ModalContent.d.ts +1 -1
- package/lib/es/modal/confirm.d.ts +4 -2
- package/lib/es/modal/confirm.js +1 -1
- package/lib/es/modal/useModal/index.d.ts +16 -23
- package/lib/es/navigation/Footer.d.ts +1 -1
- package/lib/es/radio/radio.d.ts +4 -0
- package/lib/es/radio/radio.js +26 -12
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/sideSheet/SideSheetContent.d.ts +1 -1
- package/lib/es/table/interface.d.ts +1 -1
- package/lib/es/tag/group.d.ts +3 -3
- package/lib/es/timeline/index.d.ts +1 -1
- package/lib/es/timeline/item.d.ts +1 -1
- package/lib/es/tooltip/index.d.ts +1 -0
- package/lib/es/tooltip/index.js +6 -1
- package/list/index.tsx +1 -1
- package/list/item.tsx +1 -1
- package/modal/Modal.tsx +7 -7
- package/modal/ModalContent.tsx +1 -1
- package/modal/confirm.tsx +10 -11
- package/modal/useModal/index.tsx +9 -1
- package/navigation/Footer.tsx +2 -2
- package/package.json +9 -9
- package/radio/radio.tsx +17 -7
- package/radio/radioGroup.tsx +1 -1
- package/select/index.tsx +8 -8
- package/sideSheet/SideSheetContent.tsx +1 -1
- package/table/interface.ts +1 -1
- package/tag/group.tsx +4 -4
- package/timeline/index.tsx +1 -1
- package/timeline/item.tsx +1 -1
- package/tooltip/index.tsx +5 -1
- package/treeSelect/index.tsx +1 -1
package/anchor/link.tsx
CHANGED
|
@@ -11,9 +11,9 @@ const prefixCls = cssClasses.PREFIX;
|
|
|
11
11
|
|
|
12
12
|
export interface LinkProps {
|
|
13
13
|
href?: string;
|
|
14
|
-
title?:
|
|
14
|
+
title?: ReactNode;
|
|
15
15
|
className?: string;
|
|
16
|
-
children?: ReactNode
|
|
16
|
+
children?: ReactNode;
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
disabled?: boolean;
|
|
19
19
|
}
|
package/autoComplete/index.tsx
CHANGED
|
@@ -57,7 +57,7 @@ export interface AutoCompleteProps<T extends AutoCompleteItems> {
|
|
|
57
57
|
dropdownMatchSelectWidth?: boolean;
|
|
58
58
|
dropdownClassName?: string;
|
|
59
59
|
dropdownStyle?: React.CSSProperties;
|
|
60
|
-
emptyContent?: React.ReactNode
|
|
60
|
+
emptyContent?: React.ReactNode;
|
|
61
61
|
getPopupContainer?: () => HTMLElement;
|
|
62
62
|
insetLabel?: React.ReactNode;
|
|
63
63
|
insetLabelId?: string;
|
|
@@ -218,8 +218,8 @@ class AutoComplete<T extends AutoCompleteItems> extends BaseComponent<AutoComple
|
|
|
218
218
|
|
|
219
219
|
warning(
|
|
220
220
|
'triggerRender' in this.props && typeof this.props.triggerRender === 'function',
|
|
221
|
-
`[Semi AutoComplete]
|
|
222
|
-
- If you are using the following props: 'suffix', 'prefix', 'showClear', 'validateStatus', and 'size',
|
|
221
|
+
`[Semi AutoComplete]
|
|
222
|
+
- If you are using the following props: 'suffix', 'prefix', 'showClear', 'validateStatus', and 'size',
|
|
223
223
|
please notice that they will be removed in the next major version.
|
|
224
224
|
Please use 'componentProps' to retrieve these props instead.
|
|
225
225
|
- If you are using 'onBlur', 'onFocus', please try to avoid using them and look for changes in the future.`
|
package/avatar/interface.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type AvatarColor =
|
|
|
22
22
|
| 'yellow';
|
|
23
23
|
|
|
24
24
|
export interface AvatarProps extends BaseProps {
|
|
25
|
-
children?: React.ReactNode
|
|
25
|
+
children?: React.ReactNode;
|
|
26
26
|
color?: AvatarColor;
|
|
27
27
|
shape?: AvatarShape;
|
|
28
28
|
size?: AvatarSize;
|
|
@@ -42,7 +42,7 @@ export type AvatarGroupSize = 'extra-extra-small' | 'extra-small' | 'small' | 'm
|
|
|
42
42
|
export type AvatarGroupOverlapFrom = 'start' | 'end';
|
|
43
43
|
|
|
44
44
|
export interface AvatarGroupProps {
|
|
45
|
-
children?: React.ReactNode
|
|
45
|
+
children?: React.ReactNode;
|
|
46
46
|
shape?: AvatarGroupShape;
|
|
47
47
|
size?: AvatarGroupSize;
|
|
48
48
|
overlapFrom?: AvatarGroupOverlapFrom;
|
package/badge/index.tsx
CHANGED
|
@@ -24,7 +24,7 @@ export interface BadgeProps {
|
|
|
24
24
|
onMouseEnter?: (e: React.MouseEvent) => any;
|
|
25
25
|
onMouseLeave?: (e: React.MouseEvent) => any;
|
|
26
26
|
onClick?: (e: React.MouseEvent) => any;
|
|
27
|
-
children?: React.ReactNode
|
|
27
|
+
children?: React.ReactNode;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export default class Badge extends PureComponent<BadgeProps> {
|
package/banner/index.tsx
CHANGED
|
@@ -20,15 +20,15 @@ export type Type = 'info' | 'danger' | 'warning' | 'success';
|
|
|
20
20
|
export interface BannerProps {
|
|
21
21
|
type?: Type;
|
|
22
22
|
className?: string;
|
|
23
|
-
children?: React.ReactNode
|
|
23
|
+
children?: React.ReactNode;
|
|
24
24
|
fullMode?: boolean;
|
|
25
25
|
title?: React.ReactNode;
|
|
26
26
|
description?: React.ReactNode;
|
|
27
|
-
icon?:
|
|
28
|
-
closeIcon?:
|
|
27
|
+
icon?: React.ReactNode;
|
|
28
|
+
closeIcon?: React.ReactNode;
|
|
29
29
|
style?: React.CSSProperties;
|
|
30
30
|
bordered?: boolean;
|
|
31
|
-
onClose
|
|
31
|
+
onClose?(e: React.MouseEvent):void;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface BannerState {
|
|
@@ -5,7 +5,7 @@ export interface BreadContextType {
|
|
|
5
5
|
onClick?: (info: BreadcrumbItemInfo, event: React.MouseEvent) => void;
|
|
6
6
|
showTooltip?: boolean | showToolTipProps;
|
|
7
7
|
compact?: boolean;
|
|
8
|
-
separator?:
|
|
8
|
+
separator?: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const BreadContext = React.createContext<BreadContextType>({});
|
package/card/cardGroup.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export type CardGroupType = 'grid';
|
|
|
11
11
|
export interface CardGroupProps {
|
|
12
12
|
/** Card group style class name */
|
|
13
13
|
className?: string;
|
|
14
|
-
children?: React.ReactNode
|
|
14
|
+
children?: React.ReactNode;
|
|
15
15
|
/** Card Spacing */
|
|
16
16
|
spacing?: number | number[];
|
|
17
17
|
/** Card group inline style */
|
package/card/index.tsx
CHANGED
|
@@ -26,7 +26,7 @@ export interface CardProps {
|
|
|
26
26
|
bordered?: boolean;
|
|
27
27
|
/** Style class name */
|
|
28
28
|
className?: string;
|
|
29
|
-
children?: React.ReactNode
|
|
29
|
+
children?: React.ReactNode;
|
|
30
30
|
/** Cover */
|
|
31
31
|
cover?: ReactNode;
|
|
32
32
|
/** Additional additions to the right of the title */
|
package/cascader/index.tsx
CHANGED
|
@@ -62,7 +62,7 @@ export interface CascaderProps extends BasicCascaderProps {
|
|
|
62
62
|
motion?: Motion;
|
|
63
63
|
treeData?: Array<CascaderData>;
|
|
64
64
|
restTagsPopoverProps?: PopoverProps;
|
|
65
|
-
children?: React.ReactNode
|
|
65
|
+
children?: React.ReactNode;
|
|
66
66
|
value?: Value;
|
|
67
67
|
prefix?: ReactNode;
|
|
68
68
|
suffix?: ReactNode;
|
|
@@ -843,11 +843,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
843
843
|
const allowClear = this.showClearBtn();
|
|
844
844
|
if (allowClear) {
|
|
845
845
|
return (
|
|
846
|
-
<div
|
|
846
|
+
<div
|
|
847
847
|
className={clearCls}
|
|
848
|
-
onClick={this.handleClear}
|
|
848
|
+
onClick={this.handleClear}
|
|
849
849
|
onKeyPress={this.handleClearEnterPress}
|
|
850
|
-
role='button'
|
|
850
|
+
role='button'
|
|
851
851
|
tabIndex={0}
|
|
852
852
|
>
|
|
853
853
|
<IconClear />
|
package/checkbox/checkbox.tsx
CHANGED
|
@@ -29,9 +29,13 @@ export interface CheckboxProps extends BaseCheckboxProps {
|
|
|
29
29
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
30
30
|
role?: React.HTMLAttributes<HTMLSpanElement>['role']; // a11y: wrapper role
|
|
31
31
|
tabIndex?: number; // a11y: wrapper tabIndex
|
|
32
|
+
addonId?: string;
|
|
33
|
+
extraId?: string;
|
|
32
34
|
}
|
|
33
35
|
interface CheckboxState {
|
|
34
36
|
checked: boolean;
|
|
37
|
+
addonId?: string;
|
|
38
|
+
extraId?: string;
|
|
35
39
|
}
|
|
36
40
|
class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
37
41
|
static contextType = Context;
|
|
@@ -89,7 +93,13 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
89
93
|
notifyGroupChange: cbContent => {
|
|
90
94
|
this.context.checkboxGroup.onChange(cbContent);
|
|
91
95
|
},
|
|
92
|
-
getGroupDisabled: () => (this.context && this.context.checkboxGroup.disabled)
|
|
96
|
+
getGroupDisabled: () => (this.context && this.context.checkboxGroup.disabled),
|
|
97
|
+
setAddonId: () => {
|
|
98
|
+
this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
|
|
99
|
+
},
|
|
100
|
+
setExtraId: () => {
|
|
101
|
+
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
102
|
+
}
|
|
93
103
|
};
|
|
94
104
|
}
|
|
95
105
|
|
|
@@ -103,11 +113,11 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
103
113
|
|
|
104
114
|
this.state = {
|
|
105
115
|
checked: props.checked || props.defaultChecked || checked,
|
|
116
|
+
addonId: props.addonId,
|
|
117
|
+
extraId: props.extraId,
|
|
106
118
|
};
|
|
107
119
|
|
|
108
120
|
this.checkboxEntity = null;
|
|
109
|
-
this.addonId = getUuidShort({ prefix: 'addon' });
|
|
110
|
-
this.extraId = getUuidShort({ prefix: 'extra' });
|
|
111
121
|
this.foundation = new CheckboxFoundation(this.adapter);
|
|
112
122
|
}
|
|
113
123
|
|
|
@@ -153,7 +163,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
153
163
|
tabIndex,
|
|
154
164
|
id
|
|
155
165
|
} = this.props;
|
|
156
|
-
const { checked } = this.state;
|
|
166
|
+
const { checked, addonId, extraId } = this.state;
|
|
157
167
|
const props: Record<string, any> = {
|
|
158
168
|
checked,
|
|
159
169
|
disabled,
|
|
@@ -195,8 +205,8 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
195
205
|
|
|
196
206
|
const renderContent = () => (
|
|
197
207
|
<>
|
|
198
|
-
{children ? <span id={
|
|
199
|
-
{extra ? <div id={
|
|
208
|
+
{children ? <span id={addonId} className={`${prefix}-addon`}>{children}</span> : null}
|
|
209
|
+
{extra ? <div id={extraId} className={extraCls}>{extra}</div> : null}
|
|
200
210
|
</>
|
|
201
211
|
);
|
|
202
212
|
return (
|
package/collapse/index.tsx
CHANGED
|
@@ -20,7 +20,7 @@ export { CollapsePanelProps } from './item';
|
|
|
20
20
|
export interface CollapseReactProps extends CollapseProps{
|
|
21
21
|
expandIcon?: React.ReactNode;
|
|
22
22
|
collapseIcon?: React.ReactNode;
|
|
23
|
-
children?: React.ReactNode
|
|
23
|
+
children?: React.ReactNode;
|
|
24
24
|
style?: CSSProperties;
|
|
25
25
|
onChange?: (activeKey: CollapseProps['activeKey'], e: React.MouseEvent) => void;
|
|
26
26
|
}
|
package/collapse/item.tsx
CHANGED
package/collapsible/index.tsx
CHANGED
|
@@ -849,5 +849,52 @@ export const A11yKeyboardDemo = () => {
|
|
|
849
849
|
);
|
|
850
850
|
};
|
|
851
851
|
|
|
852
|
-
A11yKeyboardDemo.storyName = "a11y keyboard demo"
|
|
852
|
+
A11yKeyboardDemo.storyName = "a11y keyboard demo";
|
|
853
853
|
|
|
854
|
+
/**
|
|
855
|
+
* test with cypress
|
|
856
|
+
*/
|
|
857
|
+
export const NeedConfirmDelete = () => {
|
|
858
|
+
return (
|
|
859
|
+
<div data-cy="dateTimeRange">
|
|
860
|
+
<DatePicker
|
|
861
|
+
value={[new Date('2022-08-08 00:00'), new Date('2022-08-09 12:00')]}
|
|
862
|
+
type="dateTimeRange"
|
|
863
|
+
needConfirm
|
|
864
|
+
/>
|
|
865
|
+
</div>
|
|
866
|
+
);
|
|
867
|
+
};
|
|
868
|
+
NeedConfirmDelete.storyName = "cashedSelectedValue return to last selected when needConfirm & input invalid";
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* test with cypress
|
|
872
|
+
*/
|
|
873
|
+
export const CashedSelectedValue = () => {
|
|
874
|
+
return (
|
|
875
|
+
<Space>
|
|
876
|
+
<div data-cy="date">
|
|
877
|
+
<DatePicker
|
|
878
|
+
defaultValue={new Date('2022-08-08')}
|
|
879
|
+
type="date"
|
|
880
|
+
motion={false}
|
|
881
|
+
/>
|
|
882
|
+
</div>
|
|
883
|
+
<div data-cy="dateTime">
|
|
884
|
+
<DatePicker
|
|
885
|
+
defaultValue={new Date('2022-08-08 19:11:00')}
|
|
886
|
+
type="dateTime"
|
|
887
|
+
motion={false}
|
|
888
|
+
/>
|
|
889
|
+
</div>
|
|
890
|
+
<div data-cy="dateRange">
|
|
891
|
+
<DatePicker
|
|
892
|
+
defaultValue={[new Date('2022-08-08'), new Date('2022-08-09')]}
|
|
893
|
+
type="dateRange"
|
|
894
|
+
motion={false}
|
|
895
|
+
/>
|
|
896
|
+
</div>
|
|
897
|
+
</Space>
|
|
898
|
+
);
|
|
899
|
+
};
|
|
900
|
+
CashedSelectedValue.storyName = "cashedSelectedValue";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Space, Button } from '../../../index';
|
|
3
|
+
|
|
4
|
+
AutoFillTime.storyName = '自动填充时间';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 输入开始日期后,自动填充一个时间
|
|
8
|
+
*/
|
|
9
|
+
export default function AutoFillTime() {
|
|
10
|
+
const format = 'yyyy-MM-dd HH:mm';
|
|
11
|
+
const defaultPickerValue = '2021-03-15 14:00';
|
|
12
|
+
const defaultPickerValue2 = ['2021-01-10 00:01', '2021-03-15 23:59'];
|
|
13
|
+
|
|
14
|
+
const handleChange = (...args) => {
|
|
15
|
+
console.log('change', ...args);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const props = {
|
|
19
|
+
format,
|
|
20
|
+
insetInput: true,
|
|
21
|
+
onChange: handleChange,
|
|
22
|
+
motion: false,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div data-cy="container">
|
|
27
|
+
<Space>
|
|
28
|
+
<div data-cy="dateTime">
|
|
29
|
+
<DatePicker {...props} type="dateTime" defaultPickerValue={defaultPickerValue} />
|
|
30
|
+
</div>
|
|
31
|
+
<div data-cy="dateTimeRange">
|
|
32
|
+
<DatePicker {...props} type="dateTimeRange" defaultPickerValue={defaultPickerValue2} />
|
|
33
|
+
</div>
|
|
34
|
+
</Space>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Space, Button } from '../../../index';
|
|
3
|
+
|
|
4
|
+
InputFormat.storyName = '输入部分日期,回显在面板上';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 优化 input format
|
|
8
|
+
*/
|
|
9
|
+
export default function InputFormat() {
|
|
10
|
+
const handleChange = (...args) => {
|
|
11
|
+
console.log('change', ...args);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div data-cy="container">
|
|
16
|
+
<Space>
|
|
17
|
+
<div data-cy="date">
|
|
18
|
+
<DatePicker onChange={handleChange} />
|
|
19
|
+
</div>
|
|
20
|
+
<div data-cy="dateRange">
|
|
21
|
+
<DatePicker onChange={handleChange} type="dateRange" />
|
|
22
|
+
</div>
|
|
23
|
+
<div data-cy="dateTime">
|
|
24
|
+
<DatePicker onChange={handleChange} type="dateTime" />
|
|
25
|
+
</div>
|
|
26
|
+
</Space>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Space, Button } from '../../../index';
|
|
3
|
+
|
|
4
|
+
InputFormatConfirm.storyName = '输入时间 + needConfirm';
|
|
5
|
+
|
|
6
|
+
export default function InputFormatConfirm() {
|
|
7
|
+
const [insetInput, setInputInput] = React.useState(false);
|
|
8
|
+
const format = 'yyyy-MM-dd HH:mm';
|
|
9
|
+
const defaultPickerValue = '2021-03-15 14:00';
|
|
10
|
+
const defaultPickerValue2 = ['2021-01-10 00:01', '2021-03-15 23:59'];
|
|
11
|
+
|
|
12
|
+
const handleChange = (...args) => {
|
|
13
|
+
console.log('change', ...args);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const handleConfirm = (...args) => {
|
|
17
|
+
console.log('confirm', ...args);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const props = {
|
|
21
|
+
format,
|
|
22
|
+
onChange: handleChange,
|
|
23
|
+
onConfirm: handleConfirm,
|
|
24
|
+
motion: false,
|
|
25
|
+
needConfirm: true,
|
|
26
|
+
insetInput
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div data-cy="container">
|
|
31
|
+
<Space>
|
|
32
|
+
<Button data-cy="inset-switch" onClick={() => setInputInput(!insetInput)}>{`insetInput=${insetInput}`}</Button>
|
|
33
|
+
<Space>
|
|
34
|
+
<div data-cy="dateTime">
|
|
35
|
+
<DatePicker {...props} type="dateTime" defaultPickerValue={defaultPickerValue} />
|
|
36
|
+
</div>
|
|
37
|
+
<div data-cy="dateTimeRange">
|
|
38
|
+
<DatePicker {...props} type="dateTimeRange" defaultPickerValue={defaultPickerValue2} />
|
|
39
|
+
</div>
|
|
40
|
+
</Space>
|
|
41
|
+
</Space>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Space, Button } from '../../../index';
|
|
3
|
+
|
|
4
|
+
InputFormatDisabled.storyName = '输入禁用日期,不回显在面板上';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 优化 input format
|
|
8
|
+
*/
|
|
9
|
+
export default function InputFormatDisabled() {
|
|
10
|
+
const handleChange = (...args) => {
|
|
11
|
+
console.log('change', ...args);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const disabledDate = (date) => {
|
|
15
|
+
return date.getDate() === 15;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div data-cy="container">
|
|
20
|
+
<Space>
|
|
21
|
+
<div data-cy="date">
|
|
22
|
+
<DatePicker disabledDate={disabledDate} onChange={handleChange} />
|
|
23
|
+
</div>
|
|
24
|
+
</Space>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -4,3 +4,7 @@ export { default as FixInputRangeFocus } from './FixInputRangeFocus';
|
|
|
4
4
|
export { default as InsetInput } from './InsetInput';
|
|
5
5
|
export { default as InsetInputE2E } from './InsetInputE2E';
|
|
6
6
|
export { default as FixDefaultPickerValue } from './FixDefaultPickerValue';
|
|
7
|
+
export { default as InputFormat } from './InputFormat';
|
|
8
|
+
export { default as InputFormatDisabled } from './InputFormatDisabled';
|
|
9
|
+
export { default as AutoFillTime } from './AutoFillTime';
|
|
10
|
+
export { default as InputFormatConfirm } from './InputFormatConfirm';
|
package/datePicker/dateInput.tsx
CHANGED
|
@@ -64,6 +64,12 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
64
64
|
rangeSeparator: PropTypes.string,
|
|
65
65
|
insetInput: PropTypes.bool,
|
|
66
66
|
insetInputValue: PropTypes.object,
|
|
67
|
+
defaultPickerValue: PropTypes.oneOfType([
|
|
68
|
+
PropTypes.string,
|
|
69
|
+
PropTypes.number,
|
|
70
|
+
PropTypes.object,
|
|
71
|
+
PropTypes.array,
|
|
72
|
+
]),
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
static defaultProps = {
|
|
@@ -392,6 +398,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
392
398
|
rangeSeparator,
|
|
393
399
|
insetInput,
|
|
394
400
|
insetInputValue,
|
|
401
|
+
defaultPickerValue,
|
|
395
402
|
...rest
|
|
396
403
|
} = this.props;
|
|
397
404
|
const dateIcon = <IconCalendar aria-hidden />;
|
|
@@ -184,7 +184,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
184
184
|
isRange: false,
|
|
185
185
|
inputValue: null, // Staging input values
|
|
186
186
|
value: [], // The currently selected date, each date is a Date object
|
|
187
|
-
cachedSelectedValue: null, // Save last selected date
|
|
187
|
+
cachedSelectedValue: null, // Save last selected date, maybe include null
|
|
188
188
|
prevTimeZone: null,
|
|
189
189
|
motionEnd: false, // Monitor if popover animation ends
|
|
190
190
|
rangeInputFocus: undefined, // Optional'rangeStart ',' rangeEnd ', false
|
|
@@ -415,16 +415,9 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
415
415
|
triggerRender,
|
|
416
416
|
insetInput
|
|
417
417
|
} = this.props;
|
|
418
|
-
const {
|
|
419
|
-
|
|
420
|
-
// const cachedSelectedValue = this.adapter.getCache('cachedSelectedValue');
|
|
421
|
-
|
|
422
|
-
let defaultValue = value;
|
|
423
|
-
|
|
424
|
-
if (this.adapter.needConfirm()) {
|
|
425
|
-
defaultValue = cachedSelectedValue;
|
|
426
|
-
}
|
|
418
|
+
const { cachedSelectedValue, motionEnd, rangeInputFocus } = this.state;
|
|
427
419
|
|
|
420
|
+
const defaultValue = cachedSelectedValue;
|
|
428
421
|
return (
|
|
429
422
|
<MonthsGrid
|
|
430
423
|
ref={this.monthGrid}
|
|
@@ -535,6 +528,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
535
528
|
inputReadOnly,
|
|
536
529
|
rangeSeparator,
|
|
537
530
|
insetInput,
|
|
531
|
+
defaultPickerValue
|
|
538
532
|
} = this.props;
|
|
539
533
|
const { value, inputValue, rangeInputFocus, triggerDisabled } = this.state;
|
|
540
534
|
// This class is not needed when triggerRender is function
|
|
@@ -555,6 +549,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
555
549
|
disabled: inputDisabled,
|
|
556
550
|
inputValue,
|
|
557
551
|
value: value as Date[],
|
|
552
|
+
defaultPickerValue,
|
|
558
553
|
onChange: this.handleInputChange,
|
|
559
554
|
onEnterPress: this.handleInputComplete,
|
|
560
555
|
// TODO: remove in next major version
|
|
@@ -629,7 +624,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
629
624
|
};
|
|
630
625
|
|
|
631
626
|
renderPanel = (locale: Locale['DatePicker'], localeCode: string, dateFnsLocale: Locale['dateFnsLocale']) => {
|
|
632
|
-
const { dropdownClassName, dropdownStyle, density, topSlot, bottomSlot, insetInput, type, format, rangeSeparator } = this.props;
|
|
627
|
+
const { dropdownClassName, dropdownStyle, density, topSlot, bottomSlot, insetInput, type, format, rangeSeparator, defaultPickerValue } = this.props;
|
|
633
628
|
const { insetInputValue, value } = this.state;
|
|
634
629
|
const wrapCls = classnames(
|
|
635
630
|
cssClasses.PREFIX,
|
|
@@ -653,6 +648,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
653
648
|
rangeInputStartRef: this.rangeInputStartRef,
|
|
654
649
|
rangeInputEndRef: this.rangeInputEndRef,
|
|
655
650
|
density,
|
|
651
|
+
defaultPickerValue
|
|
656
652
|
};
|
|
657
653
|
|
|
658
654
|
return (
|
|
@@ -168,7 +168,8 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
168
168
|
componentDidUpdate(prevProps: MonthsGridProps, prevState: MonthsGridState) {
|
|
169
169
|
const { defaultValue, defaultPickerValue, motionEnd } = this.props;
|
|
170
170
|
if (prevProps.defaultValue !== defaultValue) {
|
|
171
|
-
|
|
171
|
+
// we should always update panel state when value changes
|
|
172
|
+
this.foundation.updateSelectedFromProps(defaultValue);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
if (prevProps.defaultPickerValue !== defaultPickerValue) {
|
package/descriptions/item.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import DescriptionsContext, { DescriptionsContextValue } from './descriptions-co
|
|
|
7
7
|
export interface DescriptionsItemProps {
|
|
8
8
|
hidden?: boolean;
|
|
9
9
|
className?: string;
|
|
10
|
-
children?: React.ReactNode |
|
|
10
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
11
11
|
style?: React.CSSProperties;
|
|
12
12
|
itemKey?: React.ReactNode;
|
|
13
13
|
}
|