@douyinfe/semi-ui 2.1.4 → 2.2.0-beta.1
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/_base/_story/a11y.jsx +1302 -0
- package/_base/_story/a11y.scss +49 -0
- package/_base/_story/index.stories.js +3 -1
- package/_utils/index.ts +9 -4
- package/button/Button.tsx +1 -0
- package/cascader/__test__/cascader.test.js +221 -0
- package/cascader/_story/cascader.stories.js +138 -0
- package/cascader/index.tsx +37 -21
- package/cascader/item.tsx +4 -2
- package/checkbox/checkbox.tsx +2 -0
- package/checkbox/checkboxGroup.tsx +3 -2
- package/datePicker/__test__/datePicker.test.js +85 -2
- package/datePicker/_story/datePicker.stories.js +29 -1
- package/datePicker/_story/v2/YearButton.jsx +17 -0
- package/datePicker/_story/v2/index.js +1 -0
- package/datePicker/monthsGrid.tsx +12 -1
- package/datePicker/navigation.tsx +55 -29
- package/descriptions/__test__/descriptions.test.js +27 -1
- package/descriptions/_story/descriptions.stories.js +52 -2
- package/descriptions/item.tsx +1 -1
- package/dist/css/semi.css +56 -32
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +854 -258
- 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 +2 -2
- package/form/_story/form.stories.js +0 -67
- package/form/hoc/withField.tsx +1 -1
- package/gulpfile.js +2 -1
- package/lib/cjs/_base/base.css +2 -2
- package/lib/cjs/_utils/index.d.ts +1 -0
- package/lib/cjs/_utils/index.js +12 -5
- package/lib/cjs/button/Button.d.ts +1 -0
- package/lib/cjs/cascader/index.d.ts +7 -0
- package/lib/cjs/cascader/index.js +35 -22
- package/lib/cjs/cascader/item.d.ts +2 -0
- package/lib/cjs/cascader/item.js +4 -2
- package/lib/cjs/checkbox/checkbox.js +3 -1
- package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/cjs/checkbox/checkboxGroup.js +3 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.js +6 -0
- package/lib/cjs/datePicker/navigation.js +47 -7
- package/lib/cjs/descriptions/item.js +1 -1
- package/lib/cjs/empty/index.d.ts +2 -2
- package/lib/cjs/empty/index.js +19 -18
- package/lib/cjs/form/baseForm.d.ts +6 -0
- package/lib/cjs/form/field.d.ts +6 -0
- package/lib/cjs/form/hoc/withField.js +3 -1
- package/lib/cjs/locale/source/es.d.ts +7 -0
- package/lib/cjs/locale/source/es.js +168 -0
- package/lib/cjs/modal/Modal.d.ts +2 -2
- package/lib/cjs/modal/Modal.js +2 -2
- package/lib/cjs/modal/confirm.d.ts +10 -10
- package/lib/cjs/navigation/index.d.ts +2 -2
- package/lib/cjs/pagination/index.js +9 -4
- package/lib/cjs/rating/item.js +1 -1
- package/lib/cjs/select/index.d.ts +10 -0
- package/lib/cjs/select/index.js +15 -9
- package/lib/cjs/timeline/item.d.ts +5 -2
- package/lib/cjs/timeline/item.js +13 -7
- package/lib/cjs/tree/treeNode.js +0 -2
- package/lib/cjs/upload/fileCard.d.ts +2 -0
- package/lib/cjs/upload/fileCard.js +70 -45
- package/lib/cjs/upload/index.d.ts +23 -2
- package/lib/cjs/upload/index.js +133 -25
- package/lib/cjs/upload/interface.d.ts +3 -0
- package/lib/es/_base/base.css +2 -2
- package/lib/es/_utils/index.d.ts +1 -0
- package/lib/es/_utils/index.js +12 -5
- package/lib/es/button/Button.d.ts +1 -0
- package/lib/es/cascader/index.d.ts +7 -0
- package/lib/es/cascader/index.js +34 -25
- package/lib/es/cascader/item.d.ts +2 -0
- package/lib/es/cascader/item.js +4 -2
- package/lib/es/checkbox/checkbox.js +3 -1
- package/lib/es/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/es/checkbox/checkboxGroup.js +3 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.js +6 -0
- package/lib/es/datePicker/navigation.js +48 -8
- package/lib/es/descriptions/item.js +1 -1
- package/lib/es/empty/index.d.ts +2 -2
- package/lib/es/empty/index.js +19 -18
- package/lib/es/form/baseForm.d.ts +6 -0
- package/lib/es/form/field.d.ts +6 -0
- package/lib/es/form/hoc/withField.js +3 -1
- package/lib/es/locale/source/es.d.ts +7 -0
- package/lib/es/locale/source/es.js +157 -0
- package/lib/es/modal/Modal.d.ts +2 -2
- package/lib/es/modal/Modal.js +2 -2
- package/lib/es/modal/confirm.d.ts +10 -10
- package/lib/es/navigation/index.d.ts +2 -2
- package/lib/es/pagination/index.js +8 -4
- package/lib/es/rating/item.js +1 -1
- package/lib/es/select/index.d.ts +10 -0
- package/lib/es/select/index.js +19 -9
- package/lib/es/timeline/item.d.ts +5 -2
- package/lib/es/timeline/item.js +12 -7
- package/lib/es/tree/treeNode.js +0 -2
- package/lib/es/upload/fileCard.d.ts +2 -0
- package/lib/es/upload/fileCard.js +69 -44
- package/lib/es/upload/index.d.ts +23 -2
- package/lib/es/upload/index.js +133 -24
- package/lib/es/upload/interface.d.ts +3 -0
- package/locale/source/es.ts +160 -0
- package/modal/Modal.tsx +4 -4
- package/navigation/__test__/navigation.test.js +4 -4
- package/navigation/_story/AutoOpen/index.js +1 -1
- package/navigation/_story/WithChildren/index.js +1 -1
- package/navigation/_story/navigation.stories.js +1 -1
- package/navigation/_story/navigation.stories.tsx +4 -4
- package/navigation/index.tsx +2 -2
- package/package.json +17 -9
- package/pagination/_story/pagination.stories.js +11 -0
- package/pagination/index.tsx +9 -4
- package/popover/Arrow.tsx +1 -1
- package/radio/_story/radio.stories.js +12 -1
- package/rating/item.tsx +1 -1
- package/select/_story/select.stories.js +39 -14
- package/select/index.tsx +21 -7
- package/table/_story/DynamicFilters/index.js +13 -16
- package/timeline/__test__/timeline.test.js +17 -1
- package/timeline/_story/timeline.stories.js +70 -6
- package/timeline/item.tsx +11 -6
- package/tooltip/_story/tooltip.stories.js +1 -1
- package/tree/_story/tree.stories.js +2 -2
- package/tree/treeNode.tsx +0 -2
- package/upload/__test__/upload.test.js +50 -1
- package/upload/fileCard.tsx +110 -95
- package/upload/index.tsx +147 -53
- package/upload/interface.ts +3 -0
package/lib/es/_utils/index.js
CHANGED
|
@@ -102,7 +102,7 @@ export const getHighLightTextHTML = _ref => {
|
|
|
102
102
|
const markEle = option.highlightTag || 'mark';
|
|
103
103
|
const highlightClassName = option.highlightClassName || '';
|
|
104
104
|
const highlightStyle = option.highlightStyle || {};
|
|
105
|
-
return _mapInstanceProperty(chunks).call(chunks, chunk => {
|
|
105
|
+
return _mapInstanceProperty(chunks).call(chunks, (chunk, index) => {
|
|
106
106
|
const {
|
|
107
107
|
end,
|
|
108
108
|
start,
|
|
@@ -113,7 +113,8 @@ export const getHighLightTextHTML = _ref => {
|
|
|
113
113
|
if (highlight) {
|
|
114
114
|
return /*#__PURE__*/React.createElement(markEle, {
|
|
115
115
|
style: highlightStyle,
|
|
116
|
-
className: highlightClassName
|
|
116
|
+
className: highlightClassName,
|
|
117
|
+
key: text + index
|
|
117
118
|
}, text);
|
|
118
119
|
} else {
|
|
119
120
|
return text;
|
|
@@ -146,11 +147,17 @@ export const registerMediaQuery = (media, _ref2) => {
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
callInInit && handlerMediaChange(mediaQueryList);
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
|
|
151
|
+
if (Object.prototype.hasOwnProperty.call(mediaQueryList, 'addEventListener')) {
|
|
152
|
+
mediaQueryList.addEventListener('change', handlerMediaChange);
|
|
153
|
+
return () => mediaQueryList.removeEventListener('change', handlerMediaChange);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
mediaQueryList.addListener(handlerMediaChange);
|
|
157
|
+
return () => mediaQueryList.removeListener(handlerMediaChange);
|
|
151
158
|
}
|
|
152
159
|
|
|
153
|
-
return
|
|
160
|
+
return () => undefined;
|
|
154
161
|
};
|
|
155
162
|
/**
|
|
156
163
|
* Determine whether the incoming element is a built-in icon
|
|
@@ -7,6 +7,7 @@ export declare type Size = 'default' | 'small' | 'large';
|
|
|
7
7
|
export declare type Theme = 'solid' | 'borderless' | 'light';
|
|
8
8
|
export declare type Type = 'primary' | 'secondary' | 'tertiary' | 'warning' | 'danger';
|
|
9
9
|
export interface ButtonProps {
|
|
10
|
+
id?: string;
|
|
10
11
|
block?: boolean;
|
|
11
12
|
circle?: boolean;
|
|
12
13
|
disabled?: boolean;
|
|
@@ -105,14 +105,18 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
105
105
|
showRestTagsPopover: PropTypes.Requireable<boolean>;
|
|
106
106
|
restTagsPopoverProps: PropTypes.Requireable<object>;
|
|
107
107
|
max: PropTypes.Requireable<number>;
|
|
108
|
+
separator: PropTypes.Requireable<string>;
|
|
108
109
|
onExceed: PropTypes.Requireable<(...args: any[]) => any>;
|
|
109
110
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
110
111
|
loadData: PropTypes.Requireable<(...args: any[]) => any>;
|
|
111
112
|
onLoad: PropTypes.Requireable<(...args: any[]) => any>;
|
|
112
113
|
loadedKeys: PropTypes.Requireable<any[]>;
|
|
113
114
|
disableStrictly: PropTypes.Requireable<boolean>;
|
|
115
|
+
leafOnly: PropTypes.Requireable<boolean>;
|
|
116
|
+
enableLeafClick: PropTypes.Requireable<boolean>;
|
|
114
117
|
};
|
|
115
118
|
static defaultProps: {
|
|
119
|
+
leafOnly: boolean;
|
|
116
120
|
arrowIcon: JSX.Element;
|
|
117
121
|
stopPropagation: boolean;
|
|
118
122
|
motion: boolean;
|
|
@@ -129,6 +133,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
129
133
|
filterLeafOnly: boolean;
|
|
130
134
|
showRestTagsPopover: boolean;
|
|
131
135
|
restTagsPopoverProps: {};
|
|
136
|
+
separator: string;
|
|
132
137
|
size: "default";
|
|
133
138
|
treeNodeFilterProp: "label";
|
|
134
139
|
displayProp: "label";
|
|
@@ -138,6 +143,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
138
143
|
onClear: (...args: any[]) => void;
|
|
139
144
|
onDropdownVisibleChange: (...args: any[]) => void;
|
|
140
145
|
onListScroll: (...args: any[]) => void;
|
|
146
|
+
enableLeafClick: boolean;
|
|
141
147
|
};
|
|
142
148
|
options: any;
|
|
143
149
|
isEmpty: boolean;
|
|
@@ -145,6 +151,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
145
151
|
triggerRef: React.RefObject<HTMLDivElement>;
|
|
146
152
|
optionsRef: React.RefObject<any>;
|
|
147
153
|
clickOutsideHandler: any;
|
|
154
|
+
mergeType: string;
|
|
148
155
|
constructor(props: CascaderProps);
|
|
149
156
|
get adapter(): CascaderAdapter;
|
|
150
157
|
static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState): Partial<CascaderState>;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _flatten from "lodash/flatten";
|
|
1
2
|
import _noop from "lodash/noop";
|
|
2
3
|
import _isNumber from "lodash/isNumber";
|
|
3
4
|
import _isFunction from "lodash/isFunction";
|
|
@@ -20,7 +21,7 @@ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/cascader/c
|
|
|
20
21
|
import { numbers as popoverNumbers } from '@douyinfe/semi-foundation/lib/es/popover/constants';
|
|
21
22
|
import '@douyinfe/semi-foundation/lib/es/cascader/cascader.css';
|
|
22
23
|
import { IconClear, IconChevronDown } from '@douyinfe/semi-icons';
|
|
23
|
-
import { findKeysForValues, convertDataToEntities } from '@douyinfe/semi-foundation/lib/es/cascader/util';
|
|
24
|
+
import { findKeysForValues, convertDataToEntities, calcMergeType } from '@douyinfe/semi-foundation/lib/es/cascader/util';
|
|
24
25
|
import { calcCheckedKeys, normalizeKeyList, calcDisabledKeys } from '@douyinfe/semi-foundation/lib/es/tree/treeUtil';
|
|
25
26
|
import ConfigContext from '../configProvider/context';
|
|
26
27
|
import BaseComponent from '../_base/baseComponent';
|
|
@@ -122,6 +123,7 @@ class Cascader extends BaseComponent {
|
|
|
122
123
|
dropdownStyle,
|
|
123
124
|
loadData,
|
|
124
125
|
emptyContent,
|
|
126
|
+
separator,
|
|
125
127
|
topSlot,
|
|
126
128
|
bottomSlot,
|
|
127
129
|
showNext,
|
|
@@ -137,6 +139,7 @@ class Cascader extends BaseComponent {
|
|
|
137
139
|
}, topSlot, /*#__PURE__*/React.createElement(Item, {
|
|
138
140
|
activeKeys: activeKeys,
|
|
139
141
|
selectedKeys: selectedKeys,
|
|
142
|
+
separator: separator,
|
|
140
143
|
loadedKeys: loadedKeys,
|
|
141
144
|
loadingKeys: loadingKeys,
|
|
142
145
|
onItemClick: this.handleItemClick,
|
|
@@ -186,9 +189,9 @@ class Cascader extends BaseComponent {
|
|
|
186
189
|
} = this.props;
|
|
187
190
|
const {
|
|
188
191
|
checkedKeys,
|
|
189
|
-
|
|
192
|
+
resolvedCheckedKeys
|
|
190
193
|
} = this.state;
|
|
191
|
-
const realKeys =
|
|
194
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
192
195
|
const displayTag = [];
|
|
193
196
|
const hiddenTag = [];
|
|
194
197
|
|
|
@@ -278,20 +281,23 @@ class Cascader extends BaseComponent {
|
|
|
278
281
|
const {
|
|
279
282
|
disabled,
|
|
280
283
|
triggerRender,
|
|
281
|
-
multiple
|
|
282
|
-
autoMergeValue
|
|
284
|
+
multiple
|
|
283
285
|
} = this.props;
|
|
284
286
|
const {
|
|
285
287
|
selectedKeys,
|
|
286
288
|
inputValue,
|
|
287
289
|
inputPlaceHolder,
|
|
288
|
-
|
|
290
|
+
resolvedCheckedKeys,
|
|
289
291
|
checkedKeys
|
|
290
292
|
} = this.state;
|
|
291
293
|
let realValue;
|
|
292
294
|
|
|
293
295
|
if (multiple) {
|
|
294
|
-
|
|
296
|
+
if (this.mergeType === strings.NONE_MERGE_TYPE) {
|
|
297
|
+
realValue = checkedKeys;
|
|
298
|
+
} else {
|
|
299
|
+
realValue = resolvedCheckedKeys;
|
|
300
|
+
}
|
|
295
301
|
} else {
|
|
296
302
|
realValue = [...selectedKeys][0];
|
|
297
303
|
}
|
|
@@ -471,8 +477,8 @@ class Cascader extends BaseComponent {
|
|
|
471
477
|
/* Key of half checked node, when multiple */
|
|
472
478
|
halfCheckedKeys: new _Set([]),
|
|
473
479
|
|
|
474
|
-
/* Auto merged checkedKeys, when multiple */
|
|
475
|
-
|
|
480
|
+
/* Auto merged checkedKeys or leaf checkedKeys, when multiple */
|
|
481
|
+
resolvedCheckedKeys: new _Set([]),
|
|
476
482
|
|
|
477
483
|
/* Keys of loaded item */
|
|
478
484
|
loadedKeys: new _Set(),
|
|
@@ -485,6 +491,7 @@ class Cascader extends BaseComponent {
|
|
|
485
491
|
};
|
|
486
492
|
this.options = {};
|
|
487
493
|
this.isEmpty = false;
|
|
494
|
+
this.mergeType = calcMergeType(props.autoMergeValue, props.leafOnly);
|
|
488
495
|
this.inputRef = /*#__PURE__*/React.createRef();
|
|
489
496
|
this.triggerRef = /*#__PURE__*/React.createRef();
|
|
490
497
|
this.optionsRef = /*#__PURE__*/React.createRef();
|
|
@@ -627,7 +634,9 @@ class Cascader extends BaseComponent {
|
|
|
627
634
|
multiple,
|
|
628
635
|
value,
|
|
629
636
|
defaultValue,
|
|
630
|
-
onChangeWithObject
|
|
637
|
+
onChangeWithObject,
|
|
638
|
+
leafOnly,
|
|
639
|
+
autoMergeValue
|
|
631
640
|
} = props;
|
|
632
641
|
const {
|
|
633
642
|
prevProps
|
|
@@ -692,24 +701,19 @@ class Cascader extends BaseComponent {
|
|
|
692
701
|
realKeys = formatKeys;
|
|
693
702
|
}
|
|
694
703
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
_forEachInstanceProperty(realKeys).call(realKeys, v => {
|
|
699
|
-
const calRes = calcCheckedKeys(v, keyEntities);
|
|
700
|
-
checkedKeys = new _Set([...checkedKeys, ...calRes.checkedKeys]);
|
|
701
|
-
halfCheckedKeys = new _Set([...halfCheckedKeys, ...calRes.halfCheckedKeys]);
|
|
702
|
-
}); // disableStrictly
|
|
703
|
-
|
|
704
|
+
const calRes = calcCheckedKeys(_flatten(realKeys), keyEntities);
|
|
705
|
+
const checkedKeys = new _Set(calRes.checkedKeys);
|
|
706
|
+
const halfCheckedKeys = new _Set(calRes.halfCheckedKeys); // disableStrictly
|
|
704
707
|
|
|
705
708
|
if (props.disableStrictly) {
|
|
706
709
|
newState.disabledKeys = calcDisabledKeys(keyEntities);
|
|
707
710
|
}
|
|
708
711
|
|
|
712
|
+
const isLeafOnlyMerge = calcMergeType(autoMergeValue, leafOnly) === strings.LEAF_ONLY_MERGE_TYPE;
|
|
709
713
|
newState.prevProps = props;
|
|
710
714
|
newState.checkedKeys = checkedKeys;
|
|
711
715
|
newState.halfCheckedKeys = halfCheckedKeys;
|
|
712
|
-
newState.
|
|
716
|
+
newState.resolvedCheckedKeys = new _Set(normalizeKeyList(checkedKeys, keyEntities, isLeafOnlyMerge));
|
|
713
717
|
}
|
|
714
718
|
}
|
|
715
719
|
|
|
@@ -743,7 +747,6 @@ class Cascader extends BaseComponent {
|
|
|
743
747
|
const {
|
|
744
748
|
size,
|
|
745
749
|
disabled,
|
|
746
|
-
autoMergeValue,
|
|
747
750
|
placeholder,
|
|
748
751
|
maxTagCount,
|
|
749
752
|
showRestTagsPopover,
|
|
@@ -753,11 +756,11 @@ class Cascader extends BaseComponent {
|
|
|
753
756
|
inputValue,
|
|
754
757
|
checkedKeys,
|
|
755
758
|
keyEntities,
|
|
756
|
-
|
|
759
|
+
resolvedCheckedKeys
|
|
757
760
|
} = this.state;
|
|
758
761
|
const tagInputcls = cls("".concat(prefixcls, "-tagInput-wrapper"));
|
|
759
762
|
const tagValue = [];
|
|
760
|
-
const realKeys =
|
|
763
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
761
764
|
|
|
762
765
|
_forEachInstanceProperty(_context3 = [...realKeys]).call(_context3, checkedKey => {
|
|
763
766
|
if (!_isEmpty(keyEntities[checkedKey])) {
|
|
@@ -907,14 +910,18 @@ Cascader.propTypes = {
|
|
|
907
910
|
showRestTagsPopover: PropTypes.bool,
|
|
908
911
|
restTagsPopoverProps: PropTypes.object,
|
|
909
912
|
max: PropTypes.number,
|
|
913
|
+
separator: PropTypes.string,
|
|
910
914
|
onExceed: PropTypes.func,
|
|
911
915
|
onClear: PropTypes.func,
|
|
912
916
|
loadData: PropTypes.func,
|
|
913
917
|
onLoad: PropTypes.func,
|
|
914
918
|
loadedKeys: PropTypes.array,
|
|
915
|
-
disableStrictly: PropTypes.bool
|
|
919
|
+
disableStrictly: PropTypes.bool,
|
|
920
|
+
leafOnly: PropTypes.bool,
|
|
921
|
+
enableLeafClick: PropTypes.bool
|
|
916
922
|
};
|
|
917
923
|
Cascader.defaultProps = {
|
|
924
|
+
leafOnly: false,
|
|
918
925
|
arrowIcon: /*#__PURE__*/React.createElement(IconChevronDown, null),
|
|
919
926
|
stopPropagation: true,
|
|
920
927
|
motion: true,
|
|
@@ -931,6 +938,7 @@ Cascader.defaultProps = {
|
|
|
931
938
|
filterLeafOnly: true,
|
|
932
939
|
showRestTagsPopover: false,
|
|
933
940
|
restTagsPopoverProps: {},
|
|
941
|
+
separator: ' / ',
|
|
934
942
|
size: 'default',
|
|
935
943
|
treeNodeFilterProp: 'label',
|
|
936
944
|
displayProp: 'label',
|
|
@@ -939,6 +947,7 @@ Cascader.defaultProps = {
|
|
|
939
947
|
onExceed: _noop,
|
|
940
948
|
onClear: _noop,
|
|
941
949
|
onDropdownVisibleChange: _noop,
|
|
942
|
-
onListScroll: _noop
|
|
950
|
+
onListScroll: _noop,
|
|
951
|
+
enableLeafClick: false
|
|
943
952
|
};
|
|
944
953
|
export default Cascader;
|
|
@@ -33,6 +33,7 @@ export interface CascaderItemProps {
|
|
|
33
33
|
emptyContent: React.ReactNode;
|
|
34
34
|
loadData: (selectOptions: CascaderData[]) => Promise<void>;
|
|
35
35
|
data: Array<Data | Entity>;
|
|
36
|
+
separator: string;
|
|
36
37
|
multiple: boolean;
|
|
37
38
|
checkedKeys: Set<string>;
|
|
38
39
|
halfCheckedKeys: Set<string>;
|
|
@@ -50,6 +51,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
50
51
|
checkedKeys: PropTypes.Requireable<object>;
|
|
51
52
|
halfCheckedKeys: PropTypes.Requireable<object>;
|
|
52
53
|
onItemCheckboxClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
|
+
separator: PropTypes.Requireable<string>;
|
|
53
55
|
keyword: PropTypes.Requireable<string>;
|
|
54
56
|
};
|
|
55
57
|
static defaultProps: {
|
package/lib/es/cascader/item.js
CHANGED
|
@@ -117,7 +117,8 @@ export default class Item extends PureComponent {
|
|
|
117
117
|
this.highlight = searchText => {
|
|
118
118
|
const content = [];
|
|
119
119
|
const {
|
|
120
|
-
keyword
|
|
120
|
+
keyword,
|
|
121
|
+
separator
|
|
121
122
|
} = this.props;
|
|
122
123
|
|
|
123
124
|
_forEachInstanceProperty(searchText).call(searchText, (item, idx) => {
|
|
@@ -141,7 +142,7 @@ export default class Item extends PureComponent {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
if (idx !== searchText.length - 1) {
|
|
144
|
-
content.push(
|
|
145
|
+
content.push(separator);
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
148
|
|
|
@@ -313,6 +314,7 @@ Item.propTypes = {
|
|
|
313
314
|
checkedKeys: PropTypes.object,
|
|
314
315
|
halfCheckedKeys: PropTypes.object,
|
|
315
316
|
onItemCheckboxClick: PropTypes.func,
|
|
317
|
+
separator: PropTypes.string,
|
|
316
318
|
keyword: PropTypes.string
|
|
317
319
|
};
|
|
318
320
|
Item.defaultProps = {
|
|
@@ -84,7 +84,8 @@ class Checkbox extends BaseComponent {
|
|
|
84
84
|
onMouseEnter,
|
|
85
85
|
onMouseLeave,
|
|
86
86
|
extra,
|
|
87
|
-
value
|
|
87
|
+
value,
|
|
88
|
+
id
|
|
88
89
|
} = this.props;
|
|
89
90
|
const {
|
|
90
91
|
checked
|
|
@@ -142,6 +143,7 @@ class Checkbox extends BaseComponent {
|
|
|
142
143
|
return /*#__PURE__*/React.createElement("span", {
|
|
143
144
|
style: style,
|
|
144
145
|
className: wrapper,
|
|
146
|
+
id: id,
|
|
145
147
|
onMouseEnter: onMouseEnter,
|
|
146
148
|
onMouseLeave: onMouseLeave,
|
|
147
149
|
onClick: this.handleChange
|
|
@@ -67,6 +67,7 @@ class CheckboxGroup extends BaseComponent {
|
|
|
67
67
|
prefixCls,
|
|
68
68
|
direction,
|
|
69
69
|
className,
|
|
70
|
+
id,
|
|
70
71
|
style,
|
|
71
72
|
type
|
|
72
73
|
} = this.props;
|
|
@@ -118,7 +119,8 @@ class CheckboxGroup extends BaseComponent {
|
|
|
118
119
|
|
|
119
120
|
return /*#__PURE__*/React.createElement("div", {
|
|
120
121
|
className: prefixClsDisplay,
|
|
121
|
-
style: style
|
|
122
|
+
style: style,
|
|
123
|
+
id: id
|
|
122
124
|
}, /*#__PURE__*/React.createElement(Context.Provider, {
|
|
123
125
|
value: {
|
|
124
126
|
checkboxGroup: {
|
|
@@ -81,6 +81,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
|
|
|
81
81
|
renderMonth(month: Date, panelType: PanelType): JSX.Element;
|
|
82
82
|
handleWeeksRowNumChange: (weeksRowNum: number, panelType: PanelType) => void;
|
|
83
83
|
reselect: () => void;
|
|
84
|
+
getYAMOpenType: () => "left" | "right" | "none" | "both";
|
|
84
85
|
renderTimePicker(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
|
|
85
86
|
renderYearAndMonth(panelType: PanelType, panelDetail: MonthInfo): JSX.Element;
|
|
86
87
|
renderSwitch(panelType: PanelType): JSX.Element;
|
|
@@ -124,6 +124,10 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
124
124
|
});
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
this.getYAMOpenType = () => {
|
|
128
|
+
return this.foundation.getYAMOpenType();
|
|
129
|
+
};
|
|
130
|
+
|
|
127
131
|
let nowDate = _Array$isArray(props.defaultPickerValue) ? props.defaultPickerValue[0] : props.defaultPickerValue;
|
|
128
132
|
const validFormat = props.format || getDefaultFormatTokenByType(props.type);
|
|
129
133
|
|
|
@@ -615,9 +619,11 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
615
619
|
content = 'year month';
|
|
616
620
|
}
|
|
617
621
|
|
|
622
|
+
const yearOpenType = this.getYAMOpenType();
|
|
618
623
|
return /*#__PURE__*/React.createElement("div", {
|
|
619
624
|
className: monthGridCls,
|
|
620
625
|
"x-type": type,
|
|
626
|
+
"x-panel-yearandmonth-open-type": yearOpenType,
|
|
621
627
|
ref: current => this.cacheRefCurrent('monthGrid', current)
|
|
622
628
|
}, content);
|
|
623
629
|
}
|
|
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import IconButton from '../iconButton';
|
|
6
6
|
import Button from '../button';
|
|
7
7
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
|
|
8
|
-
import { IconChevronLeft, IconChevronRight } from '@douyinfe/semi-icons';
|
|
8
|
+
import { IconChevronLeft, IconChevronRight, IconDoubleChevronLeft, IconDoubleChevronRight } from '@douyinfe/semi-icons';
|
|
9
9
|
const prefixCls = cssClasses.NAVIGATION;
|
|
10
10
|
export default class Navigation extends PureComponent {
|
|
11
11
|
constructor(props) {
|
|
@@ -20,6 +20,8 @@ export default class Navigation extends PureComponent {
|
|
|
20
20
|
onMonthClick,
|
|
21
21
|
onNextMonth,
|
|
22
22
|
onPrevMonth,
|
|
23
|
+
onPrevYear,
|
|
24
|
+
onNextYear,
|
|
23
25
|
density,
|
|
24
26
|
shouldBimonthSwitch,
|
|
25
27
|
panelType
|
|
@@ -27,37 +29,75 @@ export default class Navigation extends PureComponent {
|
|
|
27
29
|
const btnTheme = 'borderless';
|
|
28
30
|
const iconBtnSize = density === 'compact' ? 'default' : 'large';
|
|
29
31
|
const btnNoHorizontalPadding = true;
|
|
30
|
-
const buttonSize = density === 'compact' ? 'small' : 'default';
|
|
32
|
+
const buttonSize = density === 'compact' ? 'small' : 'default';
|
|
33
|
+
const isLeftPanel = panelType === strings.PANEL_TYPE_LEFT;
|
|
34
|
+
const isRightPanel = panelType === strings.PANEL_TYPE_RIGHT; // syncSwitchMonth and the current panel is the left
|
|
31
35
|
|
|
32
|
-
const
|
|
36
|
+
const hiddenLeftPanelRightButtons = shouldBimonthSwitch && isLeftPanel; // syncSwitchMonth and the current panel is the right
|
|
37
|
+
|
|
38
|
+
const hiddenRightPanelLeftButtons = shouldBimonthSwitch && isRightPanel; // `visibility: hidden` will keep the icon in position
|
|
39
|
+
|
|
40
|
+
const leftButtonStyle = {};
|
|
41
|
+
const rightButtonStyle = {};
|
|
42
|
+
|
|
43
|
+
if (hiddenRightPanelLeftButtons) {
|
|
44
|
+
leftButtonStyle.visibility = 'hidden';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (hiddenLeftPanelRightButtons) {
|
|
48
|
+
rightButtonStyle.visibility = 'hidden';
|
|
49
|
+
}
|
|
33
50
|
|
|
34
|
-
const bimonthSwitchWithRightPanel = shouldBimonthSwitch && panelType === strings.PANEL_TYPE_RIGHT;
|
|
35
51
|
const ref = forwardRef || this.navRef;
|
|
36
52
|
return /*#__PURE__*/React.createElement("div", {
|
|
37
53
|
className: prefixCls,
|
|
38
54
|
ref: ref
|
|
39
|
-
},
|
|
55
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
56
|
+
key: "double-chevron-left",
|
|
57
|
+
icon: /*#__PURE__*/React.createElement(IconDoubleChevronLeft, {
|
|
58
|
+
size: iconBtnSize
|
|
59
|
+
}),
|
|
60
|
+
size: buttonSize,
|
|
61
|
+
theme: btnTheme,
|
|
62
|
+
noHorizontalPadding: btnNoHorizontalPadding,
|
|
63
|
+
onClick: onPrevYear,
|
|
64
|
+
style: leftButtonStyle
|
|
65
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
66
|
+
key: "chevron-left",
|
|
40
67
|
icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
|
|
41
68
|
size: iconBtnSize
|
|
42
69
|
}),
|
|
43
70
|
size: buttonSize,
|
|
44
71
|
onClick: onPrevMonth,
|
|
45
72
|
theme: btnTheme,
|
|
46
|
-
noHorizontalPadding: btnNoHorizontalPadding
|
|
73
|
+
noHorizontalPadding: btnNoHorizontalPadding,
|
|
74
|
+
style: leftButtonStyle
|
|
47
75
|
}), /*#__PURE__*/React.createElement("div", {
|
|
48
76
|
className: "".concat(prefixCls, "-month")
|
|
49
77
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
50
78
|
onClick: onMonthClick,
|
|
51
79
|
theme: btnTheme,
|
|
52
80
|
size: buttonSize
|
|
53
|
-
}, /*#__PURE__*/React.createElement("span", null, monthText))),
|
|
81
|
+
}, /*#__PURE__*/React.createElement("span", null, monthText))), /*#__PURE__*/React.createElement(IconButton, {
|
|
82
|
+
key: "chevron-right",
|
|
54
83
|
icon: /*#__PURE__*/React.createElement(IconChevronRight, {
|
|
55
84
|
size: iconBtnSize
|
|
56
85
|
}),
|
|
57
86
|
size: buttonSize,
|
|
58
87
|
onClick: onNextMonth,
|
|
59
88
|
theme: btnTheme,
|
|
60
|
-
noHorizontalPadding: btnNoHorizontalPadding
|
|
89
|
+
noHorizontalPadding: btnNoHorizontalPadding,
|
|
90
|
+
style: rightButtonStyle
|
|
91
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
92
|
+
key: "double-chevron-right",
|
|
93
|
+
icon: /*#__PURE__*/React.createElement(IconDoubleChevronRight, {
|
|
94
|
+
size: iconBtnSize
|
|
95
|
+
}),
|
|
96
|
+
size: buttonSize,
|
|
97
|
+
theme: btnTheme,
|
|
98
|
+
noHorizontalPadding: btnNoHorizontalPadding,
|
|
99
|
+
onClick: onNextYear,
|
|
100
|
+
style: rightButtonStyle
|
|
61
101
|
}));
|
|
62
102
|
}
|
|
63
103
|
|
|
@@ -33,7 +33,7 @@ export default class Item extends PureComponent {
|
|
|
33
33
|
className: "".concat(prefixCls, "-item")
|
|
34
34
|
}, /*#__PURE__*/React.createElement("span", {
|
|
35
35
|
className: keyCls
|
|
36
|
-
},
|
|
36
|
+
}, itemKey, ":"), /*#__PURE__*/React.createElement("span", {
|
|
37
37
|
className: valCls
|
|
38
38
|
}, typeof children === 'function' ? children() : children))) : /*#__PURE__*/React.createElement("tr", {
|
|
39
39
|
className: className,
|
package/lib/es/empty/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export default class Empty extends BaseComponent<EmptyProps, EmptyState> {
|
|
|
31
31
|
constructor(props: EmptyProps);
|
|
32
32
|
componentDidMount(): void;
|
|
33
33
|
componentWillUnmount(): void;
|
|
34
|
-
observe(mutationsList: any)
|
|
35
|
-
updateMode()
|
|
34
|
+
observe: (mutationsList: any) => void;
|
|
35
|
+
updateMode: () => void;
|
|
36
36
|
render(): JSX.Element;
|
|
37
37
|
}
|
|
38
38
|
export {};
|
package/lib/es/empty/index.js
CHANGED
|
@@ -10,6 +10,25 @@ const prefixCls = cssClasses.PREFIX;
|
|
|
10
10
|
export default class Empty extends BaseComponent {
|
|
11
11
|
constructor(props) {
|
|
12
12
|
super(props);
|
|
13
|
+
|
|
14
|
+
this.observe = mutationsList => {
|
|
15
|
+
for (const mutation of mutationsList) {
|
|
16
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'theme-mode') {
|
|
17
|
+
this.updateMode();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
this.updateMode = () => {
|
|
23
|
+
const val = this.body.getAttribute('theme-mode');
|
|
24
|
+
|
|
25
|
+
if (val !== this.state.mode) {
|
|
26
|
+
this.setState({
|
|
27
|
+
mode: val
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
13
32
|
this.state = {
|
|
14
33
|
mode: null
|
|
15
34
|
};
|
|
@@ -33,24 +52,6 @@ export default class Empty extends BaseComponent {
|
|
|
33
52
|
this.observer && this.observer.disconnect();
|
|
34
53
|
}
|
|
35
54
|
|
|
36
|
-
observe(mutationsList) {
|
|
37
|
-
for (const mutation of mutationsList) {
|
|
38
|
-
if (mutation.type === 'attributes' && mutation.attributeName === 'theme-mode') {
|
|
39
|
-
this.updateMode();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
updateMode() {
|
|
45
|
-
const val = this.body.getAttribute('theme-mode');
|
|
46
|
-
|
|
47
|
-
if (val !== this.state.mode) {
|
|
48
|
-
this.setState({
|
|
49
|
-
mode: val
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
55
|
render() {
|
|
55
56
|
var _context;
|
|
56
57
|
|
|
@@ -53,6 +53,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
53
53
|
static TextArea: React.ComponentType<import("utility-types").Subtract<Omit<import("../input").TextAreaProps, "forwardRef"> & React.RefAttributes<HTMLTextAreaElement>, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
54
54
|
static InputNumber: React.ComponentType<import("utility-types").Subtract<import("../inputNumber").InputNumberProps & React.RefAttributes<HTMLInputElement>, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
55
55
|
static Select: React.ComponentType<import("utility-types").Subtract<{
|
|
56
|
+
id?: string;
|
|
56
57
|
autoFocus?: boolean;
|
|
57
58
|
arrowIcon?: React.ReactNode;
|
|
58
59
|
defaultValue?: string | number | any[] | Record<string, any>;
|
|
@@ -89,6 +90,11 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
89
90
|
suffix?: React.ReactNode;
|
|
90
91
|
prefix?: React.ReactNode;
|
|
91
92
|
insetLabel?: React.ReactNode;
|
|
93
|
+
inputProps?: import("utility-types").Subtract<import("../input").InputProps, {
|
|
94
|
+
value?: React.ReactText;
|
|
95
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
|
96
|
+
onChange?: (value: string, e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
97
|
+
}>;
|
|
92
98
|
showClear?: boolean;
|
|
93
99
|
showArrow?: boolean;
|
|
94
100
|
renderSelectedItem?: import("../select").RenderSelectedItemFn;
|
package/lib/es/form/field.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ declare const FormInput: import("react").ComponentType<import("utility-types").S
|
|
|
3
3
|
declare const FormInputNumber: import("react").ComponentType<import("utility-types").Subtract<import("../inputNumber/index").InputNumberProps & import("react").RefAttributes<HTMLInputElement>, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
4
4
|
declare const FormTextArea: import("react").ComponentType<import("utility-types").Subtract<Omit<import("../input/textarea").TextAreaProps, "forwardRef"> & import("react").RefAttributes<HTMLTextAreaElement>, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
|
|
5
5
|
declare const FormSelect: import("react").ComponentType<import("utility-types").Subtract<{
|
|
6
|
+
id?: string;
|
|
6
7
|
autoFocus?: boolean;
|
|
7
8
|
arrowIcon?: import("react").ReactNode;
|
|
8
9
|
defaultValue?: string | number | any[] | Record<string, any>;
|
|
@@ -39,6 +40,11 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
39
40
|
suffix?: import("react").ReactNode;
|
|
40
41
|
prefix?: import("react").ReactNode;
|
|
41
42
|
insetLabel?: import("react").ReactNode;
|
|
43
|
+
inputProps?: import("utility-types").Subtract<import("../input/index").InputProps, {
|
|
44
|
+
value?: import("react").ReactText;
|
|
45
|
+
onFocus?: (e: import("react").FocusEvent<HTMLInputElement, Element>) => void;
|
|
46
|
+
onChange?: (value: string, e: import("react").ChangeEvent<HTMLInputElement>) => void;
|
|
47
|
+
}>;
|
|
42
48
|
showClear?: boolean;
|
|
43
49
|
showArrow?: boolean;
|
|
44
50
|
renderSelectedItem?: import("../select/index").RenderSelectedItemFn;
|
|
@@ -70,7 +70,9 @@ function withField(Component, opts) {
|
|
|
70
70
|
// Return without injection, eg: <Checkbox> / <Radio> inside CheckboxGroup/RadioGroup
|
|
71
71
|
|
|
72
72
|
if (!shouldInject) {
|
|
73
|
-
return /*#__PURE__*/React.createElement(Component, _Object$assign({}, rest
|
|
73
|
+
return /*#__PURE__*/React.createElement(Component, _Object$assign({}, rest, {
|
|
74
|
+
ref: ref
|
|
75
|
+
}));
|
|
74
76
|
} // grab formState from context
|
|
75
77
|
|
|
76
78
|
|