@douyinfe/semi-foundation 2.2.2 → 2.4.0-beta.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.
Files changed (140) hide show
  1. package/breadcrumb/foundation.ts +10 -1
  2. package/checkbox/checkboxFoundation.ts +9 -0
  3. package/form/foundation.ts +20 -8
  4. package/form/utils.ts +2 -0
  5. package/input/foundation.ts +21 -2
  6. package/input/textarea.scss +11 -7
  7. package/input/textareaFoundation.ts +11 -1
  8. package/inputNumber/constants.ts +1 -0
  9. package/inputNumber/foundation.ts +15 -1
  10. package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
  11. package/lib/cjs/breadcrumb/foundation.js +12 -0
  12. package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
  13. package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
  14. package/lib/cjs/form/foundation.d.ts +13 -0
  15. package/lib/cjs/form/foundation.js +32 -8
  16. package/lib/cjs/form/utils.d.ts +1 -0
  17. package/lib/cjs/form/utils.js +5 -3
  18. package/lib/cjs/input/foundation.d.ts +8 -0
  19. package/lib/cjs/input/foundation.js +24 -2
  20. package/lib/cjs/input/textarea.css +12 -9
  21. package/lib/cjs/input/textarea.scss +11 -7
  22. package/lib/cjs/input/textareaFoundation.d.ts +5 -1
  23. package/lib/cjs/input/textareaFoundation.js +12 -0
  24. package/lib/cjs/inputNumber/constants.d.ts +1 -0
  25. package/lib/cjs/inputNumber/constants.js +2 -1
  26. package/lib/cjs/inputNumber/foundation.d.ts +5 -0
  27. package/lib/cjs/inputNumber/foundation.js +19 -0
  28. package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
  29. package/lib/cjs/modal/modalContentFoundation.js +14 -0
  30. package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
  31. package/lib/cjs/navigation/itemFoundation.js +12 -0
  32. package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
  33. package/lib/cjs/navigation/subNavFoundation.js +14 -0
  34. package/lib/cjs/notification/notificationListFoundation.js +1 -1
  35. package/lib/cjs/radio/radio.css +7 -1
  36. package/lib/cjs/radio/radio.scss +8 -1
  37. package/lib/cjs/select/foundation.d.ts +2 -0
  38. package/lib/cjs/select/foundation.js +40 -6
  39. package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
  40. package/lib/cjs/slider/foundation.d.ts +6 -1
  41. package/lib/cjs/slider/foundation.js +6 -12
  42. package/lib/cjs/slider/slider.css +1 -0
  43. package/lib/cjs/slider/slider.scss +1 -0
  44. package/lib/cjs/table/table.css +3 -0
  45. package/lib/cjs/table/table.scss +4 -0
  46. package/lib/cjs/table/utils.d.ts +7 -0
  47. package/lib/cjs/table/utils.js +26 -0
  48. package/lib/cjs/tagInput/foundation.d.ts +4 -0
  49. package/lib/cjs/tagInput/foundation.js +12 -0
  50. package/lib/cjs/timePicker/foundation.d.ts +2 -1
  51. package/lib/cjs/timePicker/foundation.js +7 -1
  52. package/lib/cjs/tooltip/foundation.js +7 -6
  53. package/lib/cjs/transfer/transfer.css +0 -2
  54. package/lib/cjs/transfer/transfer.scss +0 -2
  55. package/lib/cjs/tree/foundation.d.ts +1 -0
  56. package/lib/cjs/tree/foundation.js +1 -1
  57. package/lib/cjs/treeSelect/foundation.d.ts +9 -1
  58. package/lib/cjs/treeSelect/foundation.js +22 -0
  59. package/lib/cjs/utils/isEnterPress.d.ts +4 -0
  60. package/lib/cjs/utils/isEnterPress.js +22 -0
  61. package/lib/cjs/utils/keyCode.d.ts +2 -0
  62. package/lib/cjs/utils/keyCode.js +5 -1
  63. package/lib/cjs/utils/uuid.d.ts +16 -1
  64. package/lib/cjs/utils/uuid.js +32 -0
  65. package/lib/es/breadcrumb/foundation.d.ts +4 -0
  66. package/lib/es/breadcrumb/foundation.js +11 -0
  67. package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
  68. package/lib/es/checkbox/checkboxFoundation.js +7 -0
  69. package/lib/es/form/foundation.d.ts +13 -0
  70. package/lib/es/form/foundation.js +31 -8
  71. package/lib/es/form/utils.d.ts +1 -0
  72. package/lib/es/form/utils.js +5 -3
  73. package/lib/es/input/foundation.d.ts +8 -0
  74. package/lib/es/input/foundation.js +23 -2
  75. package/lib/es/input/textarea.css +12 -9
  76. package/lib/es/input/textarea.scss +11 -7
  77. package/lib/es/input/textareaFoundation.d.ts +5 -1
  78. package/lib/es/input/textareaFoundation.js +11 -0
  79. package/lib/es/inputNumber/constants.d.ts +1 -0
  80. package/lib/es/inputNumber/constants.js +2 -1
  81. package/lib/es/inputNumber/foundation.d.ts +5 -0
  82. package/lib/es/inputNumber/foundation.js +18 -0
  83. package/lib/es/modal/modalContentFoundation.d.ts +7 -0
  84. package/lib/es/modal/modalContentFoundation.js +14 -0
  85. package/lib/es/navigation/itemFoundation.d.ts +5 -0
  86. package/lib/es/navigation/itemFoundation.js +11 -0
  87. package/lib/es/navigation/subNavFoundation.d.ts +6 -0
  88. package/lib/es/navigation/subNavFoundation.js +13 -0
  89. package/lib/es/notification/notificationListFoundation.js +1 -1
  90. package/lib/es/radio/radio.css +7 -1
  91. package/lib/es/radio/radio.scss +8 -1
  92. package/lib/es/select/foundation.d.ts +2 -0
  93. package/lib/es/select/foundation.js +31 -6
  94. package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
  95. package/lib/es/slider/foundation.d.ts +6 -1
  96. package/lib/es/slider/foundation.js +6 -12
  97. package/lib/es/slider/slider.css +1 -0
  98. package/lib/es/slider/slider.scss +1 -0
  99. package/lib/es/table/table.css +3 -0
  100. package/lib/es/table/table.scss +4 -0
  101. package/lib/es/table/utils.d.ts +7 -0
  102. package/lib/es/table/utils.js +24 -0
  103. package/lib/es/tagInput/foundation.d.ts +4 -0
  104. package/lib/es/tagInput/foundation.js +11 -0
  105. package/lib/es/timePicker/foundation.d.ts +2 -1
  106. package/lib/es/timePicker/foundation.js +7 -1
  107. package/lib/es/tooltip/foundation.js +7 -6
  108. package/lib/es/transfer/transfer.css +0 -2
  109. package/lib/es/transfer/transfer.scss +0 -2
  110. package/lib/es/tree/foundation.d.ts +1 -0
  111. package/lib/es/tree/foundation.js +1 -1
  112. package/lib/es/treeSelect/foundation.d.ts +9 -1
  113. package/lib/es/treeSelect/foundation.js +22 -1
  114. package/lib/es/utils/isEnterPress.d.ts +4 -0
  115. package/lib/es/utils/isEnterPress.js +8 -0
  116. package/lib/es/utils/keyCode.d.ts +2 -0
  117. package/lib/es/utils/keyCode.js +2 -0
  118. package/lib/es/utils/uuid.d.ts +16 -1
  119. package/lib/es/utils/uuid.js +32 -1
  120. package/modal/modalContentFoundation.ts +18 -0
  121. package/navigation/itemFoundation.ts +11 -0
  122. package/navigation/subNavFoundation.ts +12 -0
  123. package/notification/notificationListFoundation.ts +4 -8
  124. package/package.json +3 -3
  125. package/radio/radio.scss +8 -1
  126. package/select/foundation.ts +26 -7
  127. package/sideSheet/sideSheetFoundation.ts +3 -5
  128. package/slider/foundation.ts +10 -13
  129. package/slider/slider.scss +1 -0
  130. package/table/table.scss +4 -0
  131. package/table/utils.ts +16 -0
  132. package/tagInput/foundation.ts +10 -0
  133. package/timePicker/foundation.ts +8 -3
  134. package/tooltip/foundation.ts +5 -5
  135. package/transfer/transfer.scss +0 -2
  136. package/tree/foundation.ts +2 -1
  137. package/treeSelect/foundation.ts +20 -0
  138. package/utils/isEnterPress.ts +8 -0
  139. package/utils/keyCode.ts +3 -0
  140. package/utils/uuid.ts +29 -1
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable prefer-const */
2
2
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
-
3
+ import isEnterPress from '../utils/isEnterPress';
4
4
  import { BreadcrumbItemInfo, Route } from './itemFoundation';
5
5
  export interface BreadcrumbAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
6
6
  notifyClick: (itemInfo: BreadcrumbItemInfo, event: any) => void;
@@ -21,6 +21,15 @@ export default class BreadcrumbFoundation<P = Record<string, any>, S = Record<st
21
21
  this._adapter.expandCollapsed(clickEvent);
22
22
  }
23
23
 
24
+ /**
25
+ * A11y: simulate clear button click
26
+ */
27
+ handleExpandEnterPress(keyboardEvent: any) {
28
+ if (isEnterPress(keyboardEvent)) {
29
+ this.handleExpand(keyboardEvent);
30
+ }
31
+ }
32
+
24
33
  genRoutes(routes: Array<Route>) {
25
34
  return routes.map(route => {
26
35
  if (typeof route !== 'object') {
@@ -1,4 +1,5 @@
1
1
  import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation';
2
+ import isEnterPress from '../utils/isEnterPress';
2
3
 
3
4
  export interface BasicTargetObject {
4
5
  [x: string]: any;
@@ -98,6 +99,12 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
98
99
  this._adapter.notifyGroupChange(event);
99
100
  }
100
101
 
102
+ handleEnterPress(e: any) {
103
+ if (isEnterPress(e)) {
104
+ this.handleChange(e);
105
+ }
106
+ }
107
+
101
108
  setChecked(checked: boolean) {
102
109
  this._adapter.setNativeControlChecked(checked);
103
110
  }
@@ -121,6 +128,8 @@ export interface BaseCheckboxProps {
121
128
  onMouseEnter?: (e: any) => void;
122
129
  onMouseLeave?: (e: any) => void;
123
130
  extra?: any;
131
+ addonId?: string;
132
+ extraId?: string;
124
133
  }
125
134
 
126
135
  export default CheckboxFoundation;
@@ -258,10 +258,19 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
258
258
  });
259
259
  }
260
260
 
261
- // All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
262
- // input => output:
263
- // a => a[0]、a[1]
264
- // b => b.type、b.name[3]、b.name[2]
261
+ /**
262
+ * Case A:
263
+ * All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
264
+ * input => output:
265
+ * a => a[0]、a[1]
266
+ * b => b.type、b.name[0]、b.name[2]
267
+ *
268
+ * Case B:
269
+ * All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
270
+ * input => output:
271
+ * activity.a => activity.a[0]、activity.a[1]
272
+ *
273
+ */
265
274
  _getNestedField(path: string): Map<string, FieldStaff> {
266
275
  const allRegisterField = this.fields;
267
276
  const allFieldPath = [...allRegisterField].map(item => item[0]);
@@ -269,7 +278,7 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
269
278
  allFieldPath.forEach(item => {
270
279
  let itemPath = toPath(item);
271
280
  let targetPath = toPath(path);
272
- if (itemPath[0] === targetPath[0]) {
281
+ if (targetPath.every((path, i) => (targetPath[i] === itemPath[i]))) {
273
282
  const realField = allRegisterField.get(item);
274
283
  nestedFieldPath.set(item, realField);
275
284
  }
@@ -503,7 +512,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
503
512
  nestedFields.forEach(fieldStaff => {
504
513
  let fieldPath = fieldStaff.field;
505
514
  let newFieldVal = ObjectUtil.get(this.data.values, fieldPath);
506
- fieldStaff.fieldApi.setValue(newFieldVal, opts);
515
+ let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
516
+ fieldStaff.fieldApi.setValue(newFieldVal, nestedBatchUpdateOpts);
507
517
  });
508
518
  }
509
519
  // If the reset happens to be, then update the updateKey corresponding to ArrayField to render it again
@@ -524,7 +534,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
524
534
  nestedFields.forEach(fieldStaff => {
525
535
  let fieldPath = fieldStaff.field;
526
536
  let newFieldError = ObjectUtil.get(this.data.errors, fieldPath);
527
- fieldStaff.fieldApi.setError(newFieldError, opts);
537
+ let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
538
+ fieldStaff.fieldApi.setError(newFieldError, nestedBatchUpdateOpts);
528
539
  });
529
540
  }
530
541
  if (this.getArrayField(field)) {
@@ -544,7 +555,8 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
544
555
  nestedFields.forEach(fieldStaff => {
545
556
  let fieldPath = fieldStaff.field;
546
557
  let newFieldTouch = ObjectUtil.get(this.data.touched, fieldPath);
547
- fieldStaff.fieldApi.setTouched(newFieldTouch, opts);
558
+ let nestedBatchUpdateOpts = { notNotify: true, notUpdate: true };
559
+ fieldStaff.fieldApi.setTouched(newFieldTouch, nestedBatchUpdateOpts);
548
560
  });
549
561
  }
550
562
  if (this.getArrayField(field)) {
package/form/utils.ts CHANGED
@@ -133,6 +133,7 @@ export function mergeProps(props: any) {
133
133
  extraText,
134
134
  extraTextPosition,
135
135
  pure,
136
+ id,
136
137
  ...rest
137
138
  }: any = { ...defaultProps, ...props };
138
139
  // Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
@@ -183,6 +184,7 @@ export function mergeProps(props: any) {
183
184
  extraTextPosition,
184
185
  pure,
185
186
  rest,
187
+ id
186
188
  };
187
189
  }
188
190
 
@@ -2,7 +2,8 @@ import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation
2
2
  import { strings } from './constants';
3
3
  import { noop, set, isNumber, isString, isFunction } from 'lodash';
4
4
 
5
- const ENTER_KEY_CODE = 'Enter';
5
+ import isEnterPress from '../utils/isEnterPress';
6
+ import { ENTER_KEY } from './../utils/keyCode';
6
7
 
7
8
  export interface InputDefaultAdapter {
8
9
  notifyChange: noopFunction;
@@ -261,7 +262,7 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
261
262
 
262
263
  handleKeyPress(e: any) {
263
264
  this._adapter.notifyKeyPress(e);
264
- if (e.key === ENTER_KEY_CODE) {
265
+ if (e.key === ENTER_KEY) {
265
266
  this._adapter.notifyEnterPress(e);
266
267
  }
267
268
  }
@@ -294,5 +295,23 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
294
295
  e.preventDefault();
295
296
  }
296
297
  }
298
+
299
+ /**
300
+ * A11y: simulate clear button click
301
+ */
302
+ handleClearEnterPress(e: any) {
303
+ if (isEnterPress(e)) {
304
+ this.handleClear(e);
305
+ }
306
+ }
307
+
308
+ /**
309
+ * A11y: simulate password button click
310
+ */
311
+ handleModeEnterPress(e: any) {
312
+ if (isEnterPress(e)) {
313
+ this.handleClickEye(e);
314
+ }
315
+ }
297
316
  }
298
317
  export default InputFoundation;
@@ -55,11 +55,7 @@ $module: #{$prefix}-input;
55
55
  }
56
56
  }
57
57
 
58
- &-readonly {
59
- cursor: default;
60
- }
61
-
62
- &-disabled {
58
+ &-disabled, &-readonly {
63
59
  cursor: not-allowed;
64
60
  // border: $border-thickness-control $color-input_disabled-border-default solid;
65
61
  color: $color-input_disabled-text-default;
@@ -74,6 +70,10 @@ $module: #{$prefix}-input;
74
70
  }
75
71
  }
76
72
 
73
+ &-readonly {
74
+ cursor: text;
75
+ }
76
+
77
77
  &-error {
78
78
  background-color: $color-input_danger-bg-default;
79
79
  border-color: $color-input_danger-border-default;
@@ -151,7 +151,7 @@ $module: #{$prefix}-input;
151
151
  padding-right: $spacing-textarea_withShowClear-paddingRight;
152
152
  }
153
153
 
154
- &-disabled {
154
+ &-disabled, &-readonly {
155
155
  cursor: not-allowed;
156
156
  color: $color-input_disabled-text-default;
157
157
  background-color: transparent;
@@ -165,10 +165,14 @@ $module: #{$prefix}-input;
165
165
  }
166
166
  }
167
167
 
168
+ &-readonly {
169
+ cursor: text;
170
+ }
171
+
168
172
  &-autosize {
169
173
  overflow: hidden;
170
174
  }
171
-
175
+
172
176
  &-counter {
173
177
  @include font-size-small;
174
178
  display: flex;
@@ -7,6 +7,7 @@ import {
7
7
  } from 'lodash';
8
8
  import calculateNodeHeight from './util/calculateNodeHeight';
9
9
  import getSizingData from './util/getSizingData';
10
+ import isEnterPress from '../utils/isEnterPress';
10
11
 
11
12
  export interface TextAreaDefaultAdpter {
12
13
  notifyChange: noopFunction;
@@ -171,7 +172,7 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
171
172
  }
172
173
  }
173
174
 
174
- resizeTextarea = (cb: any) => {
175
+ resizeTextarea = (cb?: any) => {
175
176
  const { height } = this.getStates();
176
177
  const { rows } = this.getProps();
177
178
  const node = this._adapter.getRef().current;
@@ -232,4 +233,13 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdpter> {
232
233
  this._adapter.notifyClear(e);
233
234
  this.stopPropagation(e);
234
235
  }
236
+
237
+ /**
238
+ * A11y: simulate clear button click
239
+ */
240
+ handleClearEnterPress(e: any) {
241
+ if (isEnterPress(e)) {
242
+ this.handleClear(e);
243
+ }
244
+ }
235
245
  }
@@ -10,6 +10,7 @@ const numbers = {
10
10
  DEFAULT_SHIFT_STEP: 1,
11
11
  DEFAULT_PRESS_TIMEOUT: 250,
12
12
  DEFAULT_PRESS_INTERVAL: 0,
13
+ MOUSE_BUTTON_LEFT: 0, // left mouse button
13
14
  };
14
15
 
15
16
  const strings = {
@@ -4,7 +4,7 @@
4
4
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
5
5
  import keyCode from '../utils/keyCode';
6
6
  import { numbers } from './constants';
7
- import { toNumber, toString } from 'lodash';
7
+ import { toNumber, toString, get } from 'lodash';
8
8
  import { minus as numberMinus } from '../utils/number';
9
9
 
10
10
  export interface InputNumberAdapter extends DefaultAdapter {
@@ -286,6 +286,9 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
286
286
  }
287
287
 
288
288
  handleUpClick(event: any) {
289
+ if (!this._isMouseButtonLeft(event)) {
290
+ return;
291
+ }
289
292
  this._adapter.setClickUpOrDown(true);
290
293
  if (event) {
291
294
  event.persist();
@@ -303,6 +306,9 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
303
306
  }
304
307
 
305
308
  handleDownClick(event: any) {
309
+ if (!this._isMouseButtonLeft(event)) {
310
+ return;
311
+ }
306
312
  this._adapter.setClickUpOrDown(true);
307
313
  if (event) {
308
314
  event.persist();
@@ -317,6 +323,14 @@ class InputNumberFoundation extends BaseFoundation<InputNumberAdapter> {
317
323
  });
318
324
  }
319
325
 
326
+ /**
327
+ * Whether it is a left mouse button click
328
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
329
+ */
330
+ _isMouseButtonLeft(event: any) {
331
+ return get(event, 'button') === numbers.MOUSE_BUTTON_LEFT;
332
+ }
333
+
320
334
  _preventDefault(event: any) {
321
335
  const keepFocus = this._adapter.getProp('keepFocus');
322
336
  if (keepFocus) {
@@ -8,6 +8,10 @@ export default class BreadcrumbFoundation<P = Record<string, any>, S = Record<st
8
8
  constructor(adapter: BreadcrumbAdapter<P, S>);
9
9
  handleClick(info: BreadcrumbItemInfo, event: any): void;
10
10
  handleExpand(clickEvent: any): void;
11
+ /**
12
+ * A11y: simulate clear button click
13
+ */
14
+ handleExpandEnterPress(keyboardEvent: any): void;
11
15
  genRoutes(routes: Array<Route>): ({
12
16
  name: never;
13
17
  _origin: {
@@ -16,6 +16,8 @@ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable
16
16
 
17
17
  var _foundation = _interopRequireDefault(require("../base/foundation"));
18
18
 
19
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
20
+
19
21
  /* eslint-disable prefer-const */
20
22
  class BreadcrumbFoundation extends _foundation.default {
21
23
  constructor(adapter) {
@@ -29,6 +31,16 @@ class BreadcrumbFoundation extends _foundation.default {
29
31
  handleExpand(clickEvent) {
30
32
  this._adapter.expandCollapsed(clickEvent);
31
33
  }
34
+ /**
35
+ * A11y: simulate clear button click
36
+ */
37
+
38
+
39
+ handleExpandEnterPress(keyboardEvent) {
40
+ if ((0, _isEnterPress.default)(keyboardEvent)) {
41
+ this.handleExpand(keyboardEvent);
42
+ }
43
+ }
32
44
 
33
45
  genRoutes(routes) {
34
46
  return (0, _map.default)(routes).call(routes, route => {
@@ -34,6 +34,7 @@ declare class CheckboxFoundation<P = Record<string, any>, S = Record<string, any
34
34
  notifyChange(checked: boolean, e: any): void;
35
35
  handleChange(e: any): void;
36
36
  handleChangeInGroup(e: any): void;
37
+ handleEnterPress(e: any): void;
37
38
  setChecked(checked: boolean): void;
38
39
  destroy(): void;
39
40
  }
@@ -52,5 +53,7 @@ export interface BaseCheckboxProps {
52
53
  onMouseEnter?: (e: any) => void;
53
54
  onMouseLeave?: (e: any) => void;
54
55
  extra?: any;
56
+ addonId?: string;
57
+ extraId?: string;
55
58
  }
56
59
  export default CheckboxFoundation;
@@ -16,6 +16,8 @@ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-s
16
16
 
17
17
  var _foundation = _interopRequireDefault(require("../base/foundation"));
18
18
 
19
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
20
+
19
21
  class CheckboxFoundation extends _foundation.default {
20
22
  constructor(adapter) {
21
23
  super((0, _assign.default)({}, adapter));
@@ -99,6 +101,12 @@ class CheckboxFoundation extends _foundation.default {
99
101
  this._adapter.notifyGroupChange(event);
100
102
  }
101
103
 
104
+ handleEnterPress(e) {
105
+ if ((0, _isEnterPress.default)(e)) {
106
+ this.handleChange(e);
107
+ }
108
+ }
109
+
102
110
  setChecked(checked) {
103
111
  this._adapter.setNativeControlChecked(checked);
104
112
  } // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -19,6 +19,19 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
19
19
  _formValidate(): Promise<unknown>;
20
20
  _fieldsValidate(fieldPaths: Array<string>): Promise<unknown>;
21
21
  submit(): void;
22
+ /**
23
+ * Case A:
24
+ * All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
25
+ * input => output:
26
+ * a => a[0]、a[1]
27
+ * b => b.type、b.name[0]、b.name[2]
28
+ *
29
+ * Case B:
30
+ * All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
31
+ * input => output:
32
+ * activity.a => activity.a[0]、activity.a[1]
33
+ *
34
+ */
22
35
  _getNestedField(path: string): Map<string, FieldStaff>;
23
36
  _getOperateFieldMap(fieldPaths?: Array<string>): Map<string, FieldStaff>;
24
37
  reset(fieldPaths?: Array<string>): void;
@@ -28,6 +28,8 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
28
28
 
29
29
  var _map2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
30
30
 
31
+ var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
32
+
31
33
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
32
34
 
33
35
  var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
@@ -320,10 +322,20 @@ class FormFoundation extends _foundation.default {
320
322
 
321
323
  this._adapter.notifySubmitFail(_errors, _values);
322
324
  });
323
- } // All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
324
- // input => output:
325
- // a => a[0]、a[1]
326
- // b => b.type、b.name[3]、b.name[2]
325
+ }
326
+ /**
327
+ * Case A:
328
+ * All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
329
+ * input => output:
330
+ * a => a[0]、a[1]
331
+ * b => b.type、b.name[0]、b.name[2]
332
+ *
333
+ * Case B:
334
+ * All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
335
+ * input => output:
336
+ * activity.a => activity.a[0]、activity.a[1]
337
+ *
338
+ */
327
339
 
328
340
 
329
341
  _getNestedField(path) {
@@ -336,7 +348,7 @@ class FormFoundation extends _foundation.default {
336
348
  let itemPath = (0, _toPath2.default)(item);
337
349
  let targetPath = (0, _toPath2.default)(path);
338
350
 
339
- if (itemPath[0] === targetPath[0]) {
351
+ if ((0, _every.default)(targetPath).call(targetPath, (path, i) => targetPath[i] === itemPath[i])) {
340
352
  const realField = allRegisterField.get(item);
341
353
  nestedFieldPath.set(item, realField);
342
354
  }
@@ -610,7 +622,11 @@ class FormFoundation extends _foundation.default {
610
622
  (0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
611
623
  let fieldPath = fieldStaff.field;
612
624
  let newFieldVal = ObjectUtil.get((0, _values2.default)(this.data), fieldPath);
613
- fieldStaff.fieldApi.setValue(newFieldVal, opts);
625
+ let nestedBatchUpdateOpts = {
626
+ notNotify: true,
627
+ notUpdate: true
628
+ };
629
+ fieldStaff.fieldApi.setValue(newFieldVal, nestedBatchUpdateOpts);
614
630
  });
615
631
  } // If the reset happens to be, then update the updateKey corresponding to ArrayField to render it again
616
632
 
@@ -639,7 +655,11 @@ class FormFoundation extends _foundation.default {
639
655
  (0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
640
656
  let fieldPath = fieldStaff.field;
641
657
  let newFieldError = ObjectUtil.get(this.data.errors, fieldPath);
642
- fieldStaff.fieldApi.setError(newFieldError, opts);
658
+ let nestedBatchUpdateOpts = {
659
+ notNotify: true,
660
+ notUpdate: true
661
+ };
662
+ fieldStaff.fieldApi.setError(newFieldError, nestedBatchUpdateOpts);
643
663
  });
644
664
  }
645
665
 
@@ -665,7 +685,11 @@ class FormFoundation extends _foundation.default {
665
685
  (0, _forEach.default)(nestedFields).call(nestedFields, fieldStaff => {
666
686
  let fieldPath = fieldStaff.field;
667
687
  let newFieldTouch = ObjectUtil.get(this.data.touched, fieldPath);
668
- fieldStaff.fieldApi.setTouched(newFieldTouch, opts);
688
+ let nestedBatchUpdateOpts = {
689
+ notNotify: true,
690
+ notUpdate: true
691
+ };
692
+ fieldStaff.fieldApi.setTouched(newFieldTouch, nestedBatchUpdateOpts);
669
693
  });
670
694
  }
671
695
 
@@ -49,4 +49,5 @@ export declare function mergeProps(props: any): {
49
49
  extraTextPosition: any;
50
50
  pure: any;
51
51
  rest: any;
52
+ id: any;
52
53
  };
@@ -183,9 +183,10 @@ function mergeProps(props) {
183
183
  helpText,
184
184
  extraText,
185
185
  extraTextPosition,
186
- pure
186
+ pure,
187
+ id
187
188
  } = _a,
188
- rest = __rest(_a, ["field", "label", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "initValue", "validate", "validateStatus", "trigger", "allowEmptyString", "allowEmpty", "emptyValue", "rules", "onChange", "keepState", "transform", "name", "fieldClassName", "fieldStyle", "noLabel", "noErrorMessage", "isInInputGroup", "stopValidateWithError", "convert", "showValidateIcon", "helpText", "extraText", "extraTextPosition", "pure"]); // Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
189
+ rest = __rest(_a, ["field", "label", "labelPosition", "labelWidth", "labelAlign", "labelCol", "wrapperCol", "initValue", "validate", "validateStatus", "trigger", "allowEmptyString", "allowEmpty", "emptyValue", "rules", "onChange", "keepState", "transform", "name", "fieldClassName", "fieldStyle", "noLabel", "noErrorMessage", "isInInputGroup", "stopValidateWithError", "convert", "showValidateIcon", "helpText", "extraText", "extraTextPosition", "pure", "id"]); // Form中的任何类型组件,初始值都统一通过initValue字段来传入,同时将可能会导致组件行为错误的props抽取出来,防止透传到组件中
189
190
  // For any type of field component in Form, the initial value is uniformly passed in through the initValue field.
190
191
  // At the same time, the props that may cause component behavior errors are extracted to prevent transparent transmission to the component.
191
192
 
@@ -233,7 +234,8 @@ function mergeProps(props) {
233
234
  extraText,
234
235
  extraTextPosition,
235
236
  pure,
236
- rest
237
+ rest,
238
+ id
237
239
  };
238
240
  }
239
241
 
@@ -75,5 +75,13 @@ declare class InputFoundation extends BaseFoundation<InputAdapter> {
75
75
  * @param {Event} e
76
76
  */
77
77
  handlePreventMouseDown(e: any): void;
78
+ /**
79
+ * A11y: simulate clear button click
80
+ */
81
+ handleClearEnterPress(e: any): void;
82
+ /**
83
+ * A11y: simulate password button click
84
+ */
85
+ handleModeEnterPress(e: any): void;
78
86
  }
79
87
  export default InputFoundation;
@@ -28,7 +28,9 @@ var _foundation = _interopRequireDefault(require("../base/foundation"));
28
28
 
29
29
  var _constants = require("./constants");
30
30
 
31
- const ENTER_KEY_CODE = 'Enter';
31
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
32
+
33
+ var _keyCode = require("./../utils/keyCode");
32
34
 
33
35
  class InputFoundation extends _foundation.default {
34
36
  constructor(adapter) {
@@ -323,7 +325,7 @@ class InputFoundation extends _foundation.default {
323
325
  handleKeyPress(e) {
324
326
  this._adapter.notifyKeyPress(e);
325
327
 
326
- if (e.key === ENTER_KEY_CODE) {
328
+ if (e.key === _keyCode.ENTER_KEY) {
327
329
  this._adapter.notifyEnterPress(e);
328
330
  }
329
331
  }
@@ -372,6 +374,26 @@ class InputFoundation extends _foundation.default {
372
374
  e.preventDefault();
373
375
  }
374
376
  }
377
+ /**
378
+ * A11y: simulate clear button click
379
+ */
380
+
381
+
382
+ handleClearEnterPress(e) {
383
+ if ((0, _isEnterPress.default)(e)) {
384
+ this.handleClear(e);
385
+ }
386
+ }
387
+ /**
388
+ * A11y: simulate password button click
389
+ */
390
+
391
+
392
+ handleModeEnterPress(e) {
393
+ if ((0, _isEnterPress.default)(e)) {
394
+ this.handleClickEye(e);
395
+ }
396
+ }
375
397
 
376
398
  }
377
399
 
@@ -44,20 +44,20 @@
44
44
  .semi-input-textarea-wrapper .semi-input-clearbtn-hidden {
45
45
  visibility: hidden;
46
46
  }
47
- .semi-input-textarea-wrapper-readonly {
48
- cursor: default;
49
- }
50
- .semi-input-textarea-wrapper-disabled {
47
+ .semi-input-textarea-wrapper-disabled, .semi-input-textarea-wrapper-readonly {
51
48
  cursor: not-allowed;
52
49
  color: var(--semi-color-disabled-text);
53
50
  background-color: var(--semi-color-disabled-fill);
54
51
  }
55
- .semi-input-textarea-wrapper-disabled:hover {
52
+ .semi-input-textarea-wrapper-disabled:hover, .semi-input-textarea-wrapper-readonly:hover {
56
53
  background-color: var(--semi-color-disabled-fill);
57
54
  }
58
- .semi-input-textarea-wrapper-disabled::placeholder {
55
+ .semi-input-textarea-wrapper-disabled::placeholder, .semi-input-textarea-wrapper-readonly::placeholder {
59
56
  color: var(--semi-color-disabled-text);
60
57
  }
58
+ .semi-input-textarea-wrapper-readonly {
59
+ cursor: text;
60
+ }
61
61
  .semi-input-textarea-wrapper-error {
62
62
  background-color: var(--semi-color-danger-light-default);
63
63
  border-color: var(--semi-color-danger-light-default);
@@ -114,17 +114,20 @@
114
114
  .semi-input-textarea-showClear {
115
115
  padding-right: 36px;
116
116
  }
117
- .semi-input-textarea-disabled {
117
+ .semi-input-textarea-disabled, .semi-input-textarea-readonly {
118
118
  cursor: not-allowed;
119
119
  color: var(--semi-color-disabled-text);
120
120
  background-color: transparent;
121
121
  }
122
- .semi-input-textarea-disabled:hover {
122
+ .semi-input-textarea-disabled:hover, .semi-input-textarea-readonly:hover {
123
123
  background-color: transparent;
124
124
  }
125
- .semi-input-textarea-disabled::placeholder {
125
+ .semi-input-textarea-disabled::placeholder, .semi-input-textarea-readonly::placeholder {
126
126
  color: var(--semi-color-disabled-text);
127
127
  }
128
+ .semi-input-textarea-readonly {
129
+ cursor: text;
130
+ }
128
131
  .semi-input-textarea-autosize {
129
132
  overflow: hidden;
130
133
  }