@douyinfe/semi-foundation 2.43.0-beta.0 → 2.43.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.
@@ -9,7 +9,7 @@ const cssClasses = {
9
9
 
10
10
  const strings = {
11
11
  POSITION_SET: tooltipStrings.POSITION_SET,
12
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
12
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
13
13
  DEFAULT_LEAVE_DELAY: 100,
14
14
  ITEM_TYPE: ['primary', 'secondary', 'tertiary', 'warning', 'danger'],
15
15
  };
@@ -14,7 +14,7 @@ const cssClasses = {
14
14
  exports.cssClasses = cssClasses;
15
15
  const strings = {
16
16
  POSITION_SET: _constants.strings.POSITION_SET,
17
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
17
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
18
18
  DEFAULT_LEAVE_DELAY: 100,
19
19
  ITEM_TYPE: ['primary', 'secondary', 'tertiary', 'warning', 'danger']
20
20
  };
@@ -4,7 +4,7 @@ declare const cssClasses: {
4
4
  };
5
5
  declare const strings: {
6
6
  readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
7
- readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom"];
7
+ readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom", "contextMenu"];
8
8
  readonly DEFAULT_ARROW_STYLE: {
9
9
  readonly borderOpacity: "1";
10
10
  readonly backgroundColor: "var(--semi-color-bg-3)";
@@ -13,7 +13,7 @@ const cssClasses = {
13
13
  exports.cssClasses = cssClasses;
14
14
  const strings = {
15
15
  POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver'],
16
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
16
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
17
17
  DEFAULT_ARROW_STYLE: {
18
18
  borderOpacity: '1',
19
19
  backgroundColor: 'var(--semi-color-bg-3)',
@@ -41,10 +41,15 @@ class TagInputFoundation extends _foundation.default {
41
41
  }
42
42
  };
43
43
  this.handleInputCompositionStart = e => {
44
+ const {
45
+ maxLength
46
+ } = this.getProps();
47
+ if (!(0, _isNumber2.default)(maxLength)) {
48
+ return;
49
+ }
44
50
  this._adapter.setEntering(true);
45
51
  };
46
52
  this.handleInputCompositionEnd = e => {
47
- this._adapter.setEntering(false);
48
53
  const {
49
54
  value
50
55
  } = e.target;
@@ -53,27 +58,31 @@ class TagInputFoundation extends _foundation.default {
53
58
  onInputExceed,
54
59
  separator
55
60
  } = this.getProps();
61
+ if (!(0, _isNumber2.default)(maxLength)) {
62
+ return;
63
+ }
64
+ this._adapter.setEntering(false);
56
65
  let allowChange = true;
57
- const {
58
- inputValue
59
- } = this.getStates();
60
- if ((0, _isNumber2.default)(maxLength)) {
61
- const inputArr = (0, _getSplitedArray.default)(inputValue, separator);
62
- let index = 0;
63
- for (; index < inputArr.length; index++) {
64
- if (inputArr[index].length > maxLength) {
65
- allowChange = false;
66
- (0, _isFunction2.default)(onInputExceed) && onInputExceed(value);
67
- break;
68
- }
66
+ const inputArr = (0, _getSplitedArray.default)(value, separator);
67
+ let index = 0;
68
+ for (; index < inputArr.length; index++) {
69
+ if (inputArr[index].length > maxLength) {
70
+ allowChange = false;
71
+ (0, _isFunction2.default)(onInputExceed) && onInputExceed(value);
72
+ break;
69
73
  }
70
- if (!allowChange) {
71
- const newInputArr = inputArr.slice(0, index);
72
- if (index < inputArr.length) {
73
- newInputArr.push(inputArr[index].slice(0, maxLength));
74
- }
75
- this._adapter.setInputValue(newInputArr.join(separator));
74
+ }
75
+ if (!allowChange) {
76
+ const newInputArr = inputArr.slice(0, index);
77
+ if (index < inputArr.length) {
78
+ newInputArr.push(inputArr[index].slice(0, maxLength));
76
79
  }
80
+ this._adapter.setInputValue(newInputArr.join(separator));
81
+ } else {
82
+ // Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
83
+ // Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
84
+ // the composition input completes input.
85
+ this._adapter.setInputValue(value);
77
86
  }
78
87
  };
79
88
  /**
@@ -169,7 +169,7 @@ export interface BasicTreeProps {
169
169
  onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
170
170
  onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
171
171
  onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
172
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
172
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
173
173
  preventScroll?: boolean;
174
174
  renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
175
175
  renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
@@ -64,7 +64,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
64
64
  restTagsPopoverProps?: any;
65
65
  clickTriggerToHide?: boolean;
66
66
  loadData?: (data: BasicTreeNodeData) => Promise<void>;
67
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
67
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
68
68
  searchRender?: (inputProps: any) => any;
69
69
  renderSelectedItem?: BasicRenderSelectedItem;
70
70
  getPopupContainer?: () => HTMLElement;
@@ -89,7 +89,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
89
89
  unregisterClickOutsideHandler: () => void;
90
90
  rePositionDropdown: () => void;
91
91
  updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
92
- notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
92
+ notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
93
93
  notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
94
94
  cacheFlattenNodes: (bool: boolean) => void;
95
95
  openMenu: () => void;
@@ -7,7 +7,7 @@ const cssClasses = {
7
7
  };
8
8
  const strings = {
9
9
  POSITION_SET: tooltipStrings.POSITION_SET,
10
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
10
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
11
11
  DEFAULT_LEAVE_DELAY: 100,
12
12
  ITEM_TYPE: ['primary', 'secondary', 'tertiary', 'warning', 'danger']
13
13
  };
@@ -4,7 +4,7 @@ declare const cssClasses: {
4
4
  };
5
5
  declare const strings: {
6
6
  readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
7
- readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom"];
7
+ readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom", "contextMenu"];
8
8
  readonly DEFAULT_ARROW_STYLE: {
9
9
  readonly borderOpacity: "1";
10
10
  readonly backgroundColor: "var(--semi-color-bg-3)";
@@ -6,7 +6,7 @@ const cssClasses = {
6
6
  };
7
7
  const strings = {
8
8
  POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver'],
9
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
9
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
10
10
  DEFAULT_ARROW_STYLE: {
11
11
  borderOpacity: '1',
12
12
  backgroundColor: 'var(--semi-color-bg-3)',
@@ -34,10 +34,15 @@ class TagInputFoundation extends BaseFoundation {
34
34
  }
35
35
  };
36
36
  this.handleInputCompositionStart = e => {
37
+ const {
38
+ maxLength
39
+ } = this.getProps();
40
+ if (!_isNumber(maxLength)) {
41
+ return;
42
+ }
37
43
  this._adapter.setEntering(true);
38
44
  };
39
45
  this.handleInputCompositionEnd = e => {
40
- this._adapter.setEntering(false);
41
46
  const {
42
47
  value
43
48
  } = e.target;
@@ -46,27 +51,31 @@ class TagInputFoundation extends BaseFoundation {
46
51
  onInputExceed,
47
52
  separator
48
53
  } = this.getProps();
54
+ if (!_isNumber(maxLength)) {
55
+ return;
56
+ }
57
+ this._adapter.setEntering(false);
49
58
  let allowChange = true;
50
- const {
51
- inputValue
52
- } = this.getStates();
53
- if (_isNumber(maxLength)) {
54
- const inputArr = getSplitedArray(inputValue, separator);
55
- let index = 0;
56
- for (; index < inputArr.length; index++) {
57
- if (inputArr[index].length > maxLength) {
58
- allowChange = false;
59
- _isFunction(onInputExceed) && onInputExceed(value);
60
- break;
61
- }
59
+ const inputArr = getSplitedArray(value, separator);
60
+ let index = 0;
61
+ for (; index < inputArr.length; index++) {
62
+ if (inputArr[index].length > maxLength) {
63
+ allowChange = false;
64
+ _isFunction(onInputExceed) && onInputExceed(value);
65
+ break;
62
66
  }
63
- if (!allowChange) {
64
- const newInputArr = inputArr.slice(0, index);
65
- if (index < inputArr.length) {
66
- newInputArr.push(inputArr[index].slice(0, maxLength));
67
- }
68
- this._adapter.setInputValue(newInputArr.join(separator));
67
+ }
68
+ if (!allowChange) {
69
+ const newInputArr = inputArr.slice(0, index);
70
+ if (index < inputArr.length) {
71
+ newInputArr.push(inputArr[index].slice(0, maxLength));
69
72
  }
73
+ this._adapter.setInputValue(newInputArr.join(separator));
74
+ } else {
75
+ // Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
76
+ // Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
77
+ // the composition input completes input.
78
+ this._adapter.setInputValue(value);
70
79
  }
71
80
  };
72
81
  /**
@@ -169,7 +169,7 @@ export interface BasicTreeProps {
169
169
  onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
170
170
  onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
171
171
  onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
172
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
172
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
173
173
  preventScroll?: boolean;
174
174
  renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
175
175
  renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
@@ -64,7 +64,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
64
64
  restTagsPopoverProps?: any;
65
65
  clickTriggerToHide?: boolean;
66
66
  loadData?: (data: BasicTreeNodeData) => Promise<void>;
67
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
67
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
68
68
  searchRender?: (inputProps: any) => any;
69
69
  renderSelectedItem?: BasicRenderSelectedItem;
70
70
  getPopupContainer?: () => HTMLElement;
@@ -89,7 +89,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
89
89
  unregisterClickOutsideHandler: () => void;
90
90
  rePositionDropdown: () => void;
91
91
  updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
92
- notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
92
+ notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
93
93
  notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
94
94
  cacheFlattenNodes: (bool: boolean) => void;
95
95
  openMenu: () => void;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.43.0-beta.0",
3
+ "version": "2.43.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
7
7
  "prepublishOnly": "npm run build:lib"
8
8
  },
9
9
  "dependencies": {
10
- "@douyinfe/semi-animation": "2.43.0-beta.0",
10
+ "@douyinfe/semi-animation": "2.43.1",
11
11
  "async-validator": "^3.5.0",
12
12
  "classnames": "^2.2.6",
13
13
  "date-fns": "^2.29.3",
@@ -23,7 +23,7 @@
23
23
  "*.scss",
24
24
  "*.css"
25
25
  ],
26
- "gitHead": "48acb39a658ce8078194ef761a655f7c2215e2b2",
26
+ "gitHead": "84abaef26e42768a44ba5db31b9891bf508a314e",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -23,7 +23,7 @@ const strings = {
23
23
  'leftTopOver',
24
24
  'rightTopOver',
25
25
  ],
26
- TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
26
+ TRIGGER_SET: ['hover', 'focus', 'click', 'custom', 'contextMenu'],
27
27
  DEFAULT_ARROW_STYLE: {
28
28
  borderOpacity: '1',
29
29
  backgroundColor: 'var(--semi-color-bg-3)',
@@ -66,36 +66,45 @@ class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
66
66
  };
67
67
 
68
68
  handleInputCompositionStart = (e: any) => {
69
+ const { maxLength } = this.getProps();
70
+ if (!isNumber(maxLength)) {
71
+ return;
72
+ }
69
73
  this._adapter.setEntering(true);
70
74
  }
71
75
 
72
76
  handleInputCompositionEnd = (e: any) => {
73
- this._adapter.setEntering(false);
74
77
  const { value } = e.target;
75
78
  const {
76
79
  maxLength,
77
80
  onInputExceed,
78
81
  separator
79
82
  } = this.getProps();
83
+ if (!isNumber(maxLength)) {
84
+ return;
85
+ }
86
+ this._adapter.setEntering(false);
80
87
  let allowChange = true;
81
- const { inputValue } = this.getStates();
82
- if (isNumber(maxLength)) {
83
- const inputArr = getSplitedArray(inputValue, separator);
84
- let index = 0;
85
- for (; index < inputArr.length; index++) {
86
- if (inputArr[index].length > maxLength) {
87
- allowChange = false;
88
- isFunction(onInputExceed) && onInputExceed(value);
89
- break;
90
- }
88
+ const inputArr = getSplitedArray(value, separator);
89
+ let index = 0;
90
+ for (; index < inputArr.length; index++) {
91
+ if (inputArr[index].length > maxLength) {
92
+ allowChange = false;
93
+ isFunction(onInputExceed) && onInputExceed(value);
94
+ break;
91
95
  }
92
- if (!allowChange) {
93
- const newInputArr = inputArr.slice(0, index);
94
- if (index < inputArr.length) {
95
- newInputArr.push(inputArr[index].slice(0, maxLength));
96
- }
97
- this._adapter.setInputValue(newInputArr.join(separator));
96
+ }
97
+ if (!allowChange) {
98
+ const newInputArr = inputArr.slice(0, index);
99
+ if (index < inputArr.length) {
100
+ newInputArr.push(inputArr[index].slice(0, maxLength));
98
101
  }
102
+ this._adapter.setInputValue(newInputArr.join(separator));
103
+ } else {
104
+ // Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
105
+ // Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
106
+ // the composition input completes input.
107
+ this._adapter.setInputValue(value);
99
108
  }
100
109
  }
101
110
 
@@ -222,7 +222,7 @@ export interface BasicTreeProps {
222
222
  onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
223
223
  onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
224
224
  onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
225
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
225
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
226
226
  preventScroll?: boolean;
227
227
  renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
228
228
  renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
@@ -133,7 +133,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
133
133
  restTagsPopoverProps?: any;
134
134
  clickTriggerToHide?: boolean;
135
135
  loadData?: (data: BasicTreeNodeData) => Promise<void>;
136
- onSelect?: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
136
+ onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
137
137
  searchRender?: (inputProps: any) => any;
138
138
  renderSelectedItem?: BasicRenderSelectedItem;
139
139
  getPopupContainer?: () => HTMLElement;
@@ -181,7 +181,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
181
181
  unregisterClickOutsideHandler: () => void;
182
182
  rePositionDropdown: () => void;
183
183
  updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
184
- notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
184
+ notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
185
185
  notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
186
186
  cacheFlattenNodes: (bool: boolean) => void;
187
187
  openMenu: () => void;