@qsxy/element-plus-react 1.0.0-next.2 → 1.0.0-next.4

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 (144) hide show
  1. package/README.md +29 -0
  2. package/dist/Badge/Badge.js +1 -1
  3. package/dist/Badge/typings.d.ts +10 -0
  4. package/dist/Breadcrumb/typings.d.ts +4 -0
  5. package/dist/Button/typings.d.ts +28 -0
  6. package/dist/Calendar/CalendarContext.d.ts +10 -0
  7. package/dist/Calendar/ShortCuts.d.ts +2 -0
  8. package/dist/Calendar/typings.d.ts +18 -0
  9. package/dist/Card/typings.d.ts +4 -0
  10. package/dist/Cascader/CascaderDropdown.d.ts +1 -0
  11. package/dist/Cascader/CascaderMenu.d.ts +7 -0
  12. package/dist/Cascader/typings.d.ts +80 -0
  13. package/dist/Cascader/useCascader.d.ts +72 -0
  14. package/dist/Checkbox/typings.d.ts +11 -0
  15. package/dist/CheckboxGroup/CheckboxGroup.d.ts +4 -0
  16. package/dist/CheckboxGroup/CheckboxGroupContext.d.ts +1 -0
  17. package/dist/Col/typings.d.ts +10 -0
  18. package/dist/Collapse/CollapseContext.d.ts +3 -0
  19. package/dist/Collapse/CollapseItem.js +1 -1
  20. package/dist/Collapse/typings.d.ts +7 -0
  21. package/dist/ColorPicker/AlphaSlider.d.ts +7 -0
  22. package/dist/ColorPicker/HueSlider.d.ts +7 -0
  23. package/dist/ColorPicker/Predefine.d.ts +7 -0
  24. package/dist/ColorPicker/SvPanel.d.ts +7 -0
  25. package/dist/ColorPicker/typings.d.ts +9 -0
  26. package/dist/ConfigProvider/ConfigProvider.d.ts +5 -0
  27. package/dist/DatePicker/typings.d.ts +69 -0
  28. package/dist/DateTimePicker/DateTimePicker.d.ts +1 -1
  29. package/dist/DateTimePicker/DateTimePicker.js +3 -3
  30. package/dist/DateTimePicker/typings.d.ts +1 -0
  31. package/dist/Descriptions/DescriptionsContext.d.ts +2 -0
  32. package/dist/Descriptions/typings.d.ts +13 -0
  33. package/dist/Dialog/DialogContext.d.ts +8 -0
  34. package/dist/Dialog/typings.d.ts +38 -2
  35. package/dist/Divider/Divider.d.ts +4 -0
  36. package/dist/Drawer/Drawer.js +18 -9
  37. package/dist/Drawer/DrawerContext.d.ts +10 -0
  38. package/dist/Drawer/typings.d.ts +16 -0
  39. package/dist/Dropdown/Dropdown.js +1 -1
  40. package/dist/Dropdown/DropdownContext.d.ts +2 -0
  41. package/dist/Dropdown/typings.d.ts +16 -1
  42. package/dist/Form/FormItem.d.ts +12 -0
  43. package/dist/Form/typings.d.ts +55 -0
  44. package/dist/Form/useForm.d.ts +22 -0
  45. package/dist/Form/utils/NameMap.d.ts +3 -0
  46. package/dist/Form/utils/validateUtil.d.ts +4 -0
  47. package/dist/Form/utils/valueUtil.d.ts +17 -0
  48. package/dist/Icon/typings.d.ts +7 -0
  49. package/dist/Input/Input.js +2 -1
  50. package/dist/Input/typings.d.ts +61 -0
  51. package/dist/InputNumber/typings.d.ts +21 -0
  52. package/dist/Link/typings.d.ts +6 -1
  53. package/dist/Loading/typings.d.ts +5 -0
  54. package/dist/Message/Main.d.ts +7 -0
  55. package/dist/Message/index.d.ts +8 -0
  56. package/dist/Message/typings.d.ts +11 -0
  57. package/dist/MessageBox/index.d.ts +14 -0
  58. package/dist/MessageBox/typings.d.ts +50 -0
  59. package/dist/Notification/Main.d.ts +7 -0
  60. package/dist/Notification/index.d.ts +15 -0
  61. package/dist/Notification/typings.d.ts +13 -0
  62. package/dist/Pagination/typings.d.ts +28 -0
  63. package/dist/Popconfirm/Popconfirm.js +1 -1
  64. package/dist/Popconfirm/typings.d.ts +12 -1
  65. package/dist/Popover/Popover.js +1 -1
  66. package/dist/Popover/typings.d.ts +13 -1
  67. package/dist/Popper/typings.d.ts +7 -1
  68. package/dist/Progress/typings.d.ts +12 -0
  69. package/dist/Radio/typings.d.ts +7 -0
  70. package/dist/RadioGroup/typings.d.ts +1 -0
  71. package/dist/Row/RowContext.d.ts +1 -0
  72. package/dist/Row/typings.d.ts +4 -0
  73. package/dist/Scrollbar/typings.d.ts +20 -0
  74. package/dist/Select/typings.d.ts +33 -0
  75. package/dist/Skeleton/PlaceholderGraph.d.ts +4 -0
  76. package/dist/Skeleton/PlaceholderGrid.d.ts +4 -0
  77. package/dist/Skeleton/PlaceholderParagraph.d.ts +4 -0
  78. package/dist/Switch/typings.d.ts +15 -0
  79. package/dist/Table/Colgroup.d.ts +1 -0
  80. package/dist/Table/TableContext.d.ts +8 -0
  81. package/dist/Table/hooks/useSelection.d.ts +18 -1
  82. package/dist/Table/hooks/useTable.d.ts +7 -0
  83. package/dist/Table/treeUtil.d.ts +39 -0
  84. package/dist/Table/typings.d.ts +137 -1
  85. package/dist/Table/util.d.ts +10 -0
  86. package/dist/Table/util.js +1 -1
  87. package/dist/Tabs/Tabs.js +1 -1
  88. package/dist/Tabs/typings.d.ts +38 -0
  89. package/dist/Tag/Tag.d.ts +1 -1
  90. package/dist/Tag/Tag.js +18 -26
  91. package/dist/Tag/typings.d.ts +10 -0
  92. package/dist/TimeLine/typings.d.ts +9 -0
  93. package/dist/TimePicker/TimePicker.js +1 -0
  94. package/dist/TimePicker/TimeSpinnerPanel.js +2 -1
  95. package/dist/TimePicker/typings.d.ts +13 -0
  96. package/dist/TimePicker/useTimePicker.d.ts +7 -0
  97. package/dist/Tooltip/Tooltip.js +8 -19
  98. package/dist/Tooltip/TooltipContext.d.ts +1 -0
  99. package/dist/Tooltip/typings.d.ts +14 -1
  100. package/dist/Transfer/ListItem.d.ts +1 -0
  101. package/dist/Transfer/typings/index.d.ts +27 -0
  102. package/dist/Transfer/typings/list.d.ts +25 -0
  103. package/dist/Transfer/typings/listBody.d.ts +1 -0
  104. package/dist/Transition/Transition.d.ts +10 -0
  105. package/dist/Transition/TransitionGroup.d.ts +59 -0
  106. package/dist/Transition/childMapping.d.ts +23 -0
  107. package/dist/Tree/NodeList.d.ts +3 -0
  108. package/dist/Tree/RCTree.d.ts +15 -0
  109. package/dist/Tree/Tree.d.ts +15 -0
  110. package/dist/Tree/TreeNode.d.ts +7 -0
  111. package/dist/Tree/contextTypes.d.ts +4 -0
  112. package/dist/Tree/typings.d.ts +3 -0
  113. package/dist/Tree/util.d.ts +17 -0
  114. package/dist/Tree/utils/KeyCode.d.ts +326 -0
  115. package/dist/Tree/utils/conductUtil.d.ts +6 -0
  116. package/dist/Tree/utils/dictUtil.d.ts +1 -0
  117. package/dist/Tree/utils/pickAttrs.d.ts +5 -0
  118. package/dist/Tree/utils/treeUtil.d.ts +25 -1
  119. package/dist/TreeSelect/Utils.d.ts +1 -0
  120. package/dist/TreeSelect/typings.d.ts +19 -0
  121. package/dist/Upload/typings.d.ts +34 -0
  122. package/dist/Upload/use-handlers.d.ts +1 -0
  123. package/dist/Util/Math.d.ts +34 -0
  124. package/dist/Util/base.d.ts +21 -0
  125. package/dist/Util/shallowEqual.d.ts +11 -0
  126. package/dist/Util/treeUtils.d.ts +8 -0
  127. package/dist/VirtualList/Filler.d.ts +5 -0
  128. package/dist/VirtualList/VirtualList.d.ts +3 -0
  129. package/dist/VirtualList/hooks/useLayoutEffect.d.ts +3 -0
  130. package/dist/VirtualList/utils/algorithmUtil.d.ts +17 -0
  131. package/dist/VirtualList/utils/findDOMNode.d.ts +3 -0
  132. package/dist/hooks/animationPropsUtils.d.ts +12 -0
  133. package/dist/hooks/htmlPropsUtils.d.ts +8 -0
  134. package/dist/hooks/popperPropsUtils.d.ts +12 -0
  135. package/dist/hooks/treePropsUtils.d.ts +12 -0
  136. package/dist/hooks/useChildrenInstance.d.ts +11 -0
  137. package/dist/hooks/useClassNames.d.ts +78 -0
  138. package/dist/hooks/useControlled.d.ts +8 -0
  139. package/dist/hooks/useForceUpdate.d.ts +1 -0
  140. package/dist/index.d.ts +1 -0
  141. package/dist/theme-chalk/link/index.scss +0 -85
  142. package/dist/types/common.d.ts +24 -0
  143. package/dist/types/type.d.ts +5 -0
  144. package/package.json +1 -1
@@ -2,26 +2,41 @@ import React from 'react';
2
2
  import { PopperOptions } from '../Popper';
3
3
  import { TransitionProps } from '../Transition';
4
4
  import { AnimationEventProps, BaseProps, NativeProps } from '../types/common';
5
- export interface DropdownProps extends BaseProps, NativeProps, PopperOptions, AnimationEventProps, TransitionProps {
5
+ /** Dropdown 属性 */
6
+ export interface DropdownProps extends BaseProps<React.ReactElement>, NativeProps, PopperOptions, AnimationEventProps, Omit<TransitionProps, 'children'> {
6
7
  menu: React.ReactElement<DropdownMenuProps>;
8
+ /** 触发下拉的行为 */
7
9
  trigger?: 'hover' | 'click' | 'contextmenu';
10
+ /** 是否在点击菜单项后隐藏菜单 */
8
11
  hideOnClick?: boolean;
12
+ /** 展开下拉菜单的延时,仅在 trigger 为 hover 时有效 */
9
13
  showTimeout?: number;
14
+ /** 收起下拉菜单的延时(仅在 trigger 为 hover 时有效) */
10
15
  hideTimeout?: number;
16
+ /** 状态是否可见 */
11
17
  visible?: boolean;
18
+ /** 初始值 */
12
19
  defaultVisible?: boolean;
20
+ /** 是否禁用 */
13
21
  disabled?: boolean;
14
22
  onMouseEnter?: (e?: React.MouseEvent<any>) => void;
15
23
  onMouseLeave?: (e?: React.MouseEvent<any>) => void;
24
+ /** 点击菜单项触发的事件回调 */
16
25
  onClick?: (command: string | number | object) => void;
26
+ /** 下拉框出现/隐藏时触发: 出现则为 true,隐藏则为 false */
17
27
  visiblechange?: (visible: boolean) => void;
18
28
  }
19
29
  export interface DropdownMenuProps extends BaseProps, NativeProps {
20
30
  classPrefix?: string;
21
31
  }
32
+ /** Dropdown-Item 属性 */
22
33
  export interface DropdownItemProps extends BaseProps, NativeProps {
34
+ /** 派发到command回调函数的指令参数 */
23
35
  command?: string | number | object;
36
+ /** 是否禁用*/
24
37
  disabled?: boolean;
38
+ /** 是否显示分隔符 */
25
39
  divided?: boolean;
40
+ /** 是否为激活状态 */
26
41
  active?: boolean;
27
42
  }
@@ -9,14 +9,22 @@ interface ChildProps {
9
9
  }
10
10
  export interface InternalFieldProps<Values = any> extends Omit<FormItemProps<Values>, 'children'> {
11
11
  children?: ComponentChildren | ((control: ChildProps, meta: Meta, form: FormInstance<Values>) => React.ReactElement);
12
+ /**
13
+ * Set up `dependencies` field.
14
+ * When dependencies field update and current field is touched,
15
+ * will trigger validate rules and render.
16
+ */
12
17
  dependencies?: NamePath[];
13
18
  getValueFromEvent?: (...args: EventArgs) => StoreValue;
19
+ /** 字段名,支持数组 */
14
20
  name?: InternalNamePath;
15
21
  normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue;
22
+ /** 校验规则,设置字段的校验逻辑。点击此处查看示例 */
16
23
  rules?: Rule[];
17
24
  shouldUpdate?: ShouldUpdate<Values>;
18
25
  trigger?: string;
19
26
  validateTrigger?: string | string[] | false;
27
+ /** 当某一规则校验不通过时,是否停止剩下的规则的校验。设置 parallel 时会并行校验 */
20
28
  validateFirst?: boolean | 'parallel';
21
29
  valuePropName?: string;
22
30
  getValueProps?: (value: StoreValue) => Record<string, unknown>;
@@ -27,8 +35,12 @@ export interface InternalFieldProps<Values = any> extends Omit<FormItemProps<Val
27
35
  destroy?: boolean;
28
36
  }) => void;
29
37
  preserve?: boolean;
38
+ /** @private Passed by Form.List props. Do not use since it will break by path check. */
30
39
  isListField?: boolean;
40
+ /** @private Passed by Form.List props. Do not use since it will break by path check. */
31
41
  isList?: boolean;
42
+ /** @private Pass context as prop instead of context api
43
+ * since class component can not get context in constructor */
32
44
  fieldContext?: InternalFormInstance;
33
45
  }
34
46
  export interface FieldProps<Values = any> extends Omit<InternalFieldProps<Values>, 'name' | 'fieldContext'> {
@@ -5,12 +5,15 @@ type BaseFormProps = Omit<React.AllHTMLAttributes<HTMLFormElement>, 'onSubmit' |
5
5
  type RenderProps = (values: Store, form: FormInstance) => React.ReactElement;
6
6
  export type FormRules = Record<string, Rule[]>;
7
7
  export interface FormProps<Values = any> extends BaseFormProps {
8
+ /** 经 Form.useForm() 创建的 form 控制实例,不提供时会自动创建 */
8
9
  form?: FormInstance<Values>;
9
10
  children?: RenderProps | ComponentChildren;
10
11
  component?: false | string | FC<any> | ComponentClass<any, any>;
11
12
  fields?: FieldData[];
13
+ /** 表单验证规则 */
12
14
  rules?: FormRules;
13
15
  name?: string;
16
+ /** 验证提示模板 */
14
17
  validateMessages?: ValidateMessages;
15
18
  onValuesChange?: Callbacks<Values>['onValuesChange'];
16
19
  onFieldsChange?: Callbacks<Values>['onFieldsChange'];
@@ -18,31 +21,55 @@ export interface FormProps<Values = any> extends BaseFormProps {
18
21
  onFinishFailed?: Callbacks<Values>['onFinishFailed'];
19
22
  validateTrigger?: string | string[] | false;
20
23
  preserve?: boolean;
24
+ /** 配置 Form.Item 的 colon 的默认值。表示是否显示 label 后面的冒号 */
21
25
  colon?: boolean;
26
+ /** 表单默认值,只有初始化以及重置时生效 */
22
27
  initialValues?: Store;
28
+ /** 表单域标签的位置, 如果值为 left 或者 right 时,则需要设置 label-width */
23
29
  labelPosition?: 'left' | 'right' | 'top';
30
+ /** 表单域标签的宽度,例如 '50px'。 作为 Form 直接子元素的 form-item 会继承该值。 支持 auto。 */
24
31
  labelWidth?: string | number;
32
+ /** 行内表单模式 */
25
33
  inline?: boolean;
34
+ /** 是否宽度100% */
26
35
  flat?: boolean;
36
+ /** 每行列数 */
37
+ /** 是否只读 */
27
38
  disabled?: boolean;
39
+ /** 用于控制该表单内组件的尺寸 */
28
40
  size?: TypeAttributes.Size;
29
41
  onChange?: (model: any) => void;
30
42
  formStyle?: React.CSSProperties;
31
43
  className?: string;
32
44
  }
33
45
  export interface FormItemProps<T> extends BaseProps, NativeProps {
46
+ /**
47
+ * 配合 label 属性使用,表示是否显示 label 后面的冒号
48
+ */
34
49
  colon?: boolean;
50
+ /** label 标签的文本 */
35
51
  label?: boolean | string | React.ReactElement;
52
+ /** 用于控制该表单内组件的尺寸 */
36
53
  size?: TypeAttributes.Size;
54
+ /** 标签的长度,例如 '50px'。 作为 Form 直接子元素的 form-item 会继承该值。 可以使用 auto。 */
37
55
  labelWidth?: string | number;
56
+ /** 必填样式设置。如不设置,则会根据校验规则自动生成 */
38
57
  required?: boolean;
58
+ /** 为 true 时不带样式,作为纯字段控件使用 */
39
59
  noStyle?: boolean;
60
+ /** 校验状态,如不设置,则会根据校验规则自动生成,可选:'success' 'warning' 'error' 'validating' */
40
61
  validateStatus?: 'success' | 'warning' | 'error' | 'validating';
62
+ /** 配置提示信息 */
41
63
  help?: string | React.ReactElement;
64
+ /** 是否标签宽度为0,等用于`labelWidth={0}`,如果同时设置了labelWidth,则此配置无效 */
42
65
  pure?: boolean;
66
+ /** 是否居中 */
43
67
  center?: boolean;
68
+ /** 文本自定义内联样式 */
44
69
  labelStyle?: React.CSSProperties;
70
+ /** 校验失败文本自定义内联样式 */
45
71
  errorStyle?: React.CSSProperties;
72
+ /** 校验警告自定义内联样式 */
46
73
  warningStyle?: React.CSSProperties;
47
74
  }
48
75
  export interface FieldEntity {
@@ -91,6 +118,9 @@ export interface Meta {
91
118
  export interface InternalFieldData extends Meta {
92
119
  value: StoreValue;
93
120
  }
121
+ /**
122
+ * Used by `setFields` config
123
+ */
94
124
  export interface FieldData extends Partial<Omit<InternalFieldData, 'name'>> {
95
125
  name: NamePath;
96
126
  }
@@ -115,6 +145,7 @@ interface BaseRule {
115
145
  transform?: (value: StoreValue) => StoreValue;
116
146
  type?: RuleType;
117
147
  whitespace?: boolean;
148
+ /** Customize rule level `validateTrigger`. Must be subset of Field `validateTrigger` */
118
149
  validateTrigger?: string | string[];
119
150
  phone?: boolean;
120
151
  }
@@ -166,6 +197,10 @@ export interface ValidateOptions {
166
197
  label?: string | boolean | React.ReactElement<{}>;
167
198
  triggerName?: string;
168
199
  validateMessages?: ValidateMessages;
200
+ /**
201
+ * Recursive validate. It will validate all the name path that contains the provided one.
202
+ * e.g. ['a'] will validate ['a'] , ['a', 'b'] and ['a', 1].
203
+ */
169
204
  recursive?: boolean;
170
205
  }
171
206
  export type InternalValidateFields<Values = any> = (nameList?: NamePath[], options?: ValidateOptions) => Promise<Values>;
@@ -189,6 +224,11 @@ interface SetFieldInfo {
189
224
  }
190
225
  interface DependenciesUpdateInfo {
191
226
  type: 'dependenciesUpdate';
227
+ /**
228
+ * Contains all the related `InternalNamePath[]`.
229
+ * a <- b <- c : change `a`
230
+ * relatedFields=[a, b, c]
231
+ */
192
232
  relatedFields: InternalNamePath[];
193
233
  }
194
234
  export type NotifyInfo = ValueUpdateInfo | ValidateFinishInfo | ResetInfo | RemoveInfo | SetFieldInfo | DependenciesUpdateInfo;
@@ -216,6 +256,7 @@ export interface InternalHooks {
216
256
  setPreserve: (preserve?: boolean) => void;
217
257
  getInitialValue: (namePath: InternalNamePath) => StoreValue;
218
258
  }
259
+ /** Only return partial when type is not any */
219
260
  type RecursivePartial<T> = T extends object ? {
220
261
  [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
221
262
  } : any;
@@ -239,15 +280,29 @@ export interface FormInstance<Values = any> {
239
280
  }
240
281
  export type InternalFormInstance = Omit<FormInstance, 'validateFields'> & {
241
282
  validateFields: InternalValidateFields;
283
+ /**
284
+ * Passed by field context props
285
+ */
242
286
  prefixName?: InternalNamePath;
243
287
  validateTrigger?: string | string[] | false;
288
+ /**
289
+ * Form component should register some content into store.
290
+ * We pass the `HOOK_MARK` as key to avoid user call the function.
291
+ */
244
292
  getInternalHooks: (secret: string) => InternalHooks | null;
293
+ /** @private Internal usage. Do not use it in your production */
245
294
  _init?: boolean;
295
+ /** 配置 Form.Item 的 colon 的默认值。表示是否显示 label 后面的冒号 */
246
296
  colon?: boolean;
297
+ /** 是否禁用该表单内的所有组件。 如果设置为 true, 它将覆盖内部组件的 disabled 属性 */
247
298
  disabled?: boolean;
299
+ /** 表单域标签的位置, 如果值为 left 或者 right 时,则需要设置 label-width */
248
300
  labelPosition?: 'left' | 'right' | 'top';
301
+ /** 标签宽度,例如 '50px'。 可以使用 auto。 */
249
302
  labelWidth?: string | number;
303
+ /** 用于控制该表单域下组件的默认尺寸 */
250
304
  size?: TypeAttributes.Size;
305
+ /** 表单验证规则 */
251
306
  rules?: FormRules;
252
307
  };
253
308
  export type EventArgs = any[];
@@ -26,7 +26,14 @@ export declare class FormStore {
26
26
  private scrollToField;
27
27
  private getInternalHooks;
28
28
  private useSubscribe;
29
+ /**
30
+ * Record prev Form unmount fieldEntities which config preserve false.
31
+ * This need to be refill with initialValues instead of store value.
32
+ */
29
33
  private prevWithoutPreserves;
34
+ /**
35
+ * First time `setInitialValues` should update store with initial value
36
+ */
30
37
  private setInitialValues;
31
38
  private destroyForm;
32
39
  private getInitialValue;
@@ -39,6 +46,10 @@ export declare class FormStore {
39
46
  private timeoutId;
40
47
  private warningUnhooked;
41
48
  private updateStore;
49
+ /**
50
+ * Get registered field entities.
51
+ * @param pure Only return field which has a `name`. Default: false
52
+ */
42
53
  private getFieldEntities;
43
54
  private getFieldsMap;
44
55
  private getFieldEntitiesForNamePathList;
@@ -51,15 +62,26 @@ export declare class FormStore {
51
62
  private isFieldTouched;
52
63
  private isFieldsValidating;
53
64
  private isFieldValidating;
65
+ /**
66
+ * Reset Field with field `initialValue` prop.
67
+ * Can pass `entities` or `namePathList` or just nothing.
68
+ */
54
69
  private resetWithFieldInitialValue;
55
70
  private resetFields;
56
71
  private setFields;
57
72
  private getFields;
73
+ /**
74
+ * This only trigger when a field is on constructor to avoid we get initialValue too late
75
+ */
58
76
  private initEntityValue;
59
77
  private isMergedPreserve;
60
78
  private registerField;
61
79
  private dispatch;
62
80
  private notifyObservers;
81
+ /**
82
+ * Notify dependencies children with parent update
83
+ * We need delay to trigger validate in case Field is under render props
84
+ */
63
85
  private triggerDependenciesUpdate;
64
86
  private updateValue;
65
87
  private setFieldsValue;
@@ -3,6 +3,9 @@ interface KV<T> {
3
3
  key: InternalNamePath;
4
4
  value: T;
5
5
  }
6
+ /**
7
+ * NameMap like a `Map` but accepts `string[]` as key.
8
+ */
6
9
  declare class NameMap<T> {
7
10
  private kvs;
8
11
  set(key: InternalNamePath, value: T): void;
@@ -1,2 +1,6 @@
1
1
  import type { InternalNamePath, RuleError, RuleObject, StoreValue, ValidateOptions } from '../typings';
2
+ /**
3
+ * We use `async-validator` to validate the value.
4
+ * But only check one value in a time to avoid namePath validate issue.
5
+ */
2
6
  export declare function validateRules(namePath: InternalNamePath, value: StoreValue, rules: RuleObject[], options: ValidateOptions, validateFirst: boolean | 'parallel', messageVariables?: Record<string, string>): Promise<RuleError[]>;
@@ -1,4 +1,11 @@
1
1
  import type { EventArgs, InternalNamePath, NamePath, Store, StoreValue } from '../typings';
2
+ /**
3
+ * Convert name to internal supported format.
4
+ * This function should keep since we still thinking if need support like `a.b.c` format.
5
+ * 'a' => ['a']
6
+ * 123 => [123]
7
+ * ['a', 123] => ['a', 123]
8
+ */
2
9
  export declare function getNamePath(path: NamePath | null): InternalNamePath;
3
10
  export declare function getValue(store: Store, namePath: InternalNamePath): any;
4
11
  export declare function setValue(store: Store, namePath: InternalNamePath, value: StoreValue, removeIfUndefined?: boolean): Store;
@@ -9,6 +16,16 @@ export declare function matchNamePath(namePath: InternalNamePath, changedNamePat
9
16
  type SimilarObject = string | number | {};
10
17
  export declare function isSimilar(source: SimilarObject, target: SimilarObject): boolean;
11
18
  export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any;
19
+ /**
20
+ * Moves an array item from one position in an array to another.
21
+ *
22
+ * Note: This is a pure function so a new array will be returned, instead
23
+ * of altering the array argument.
24
+ *
25
+ * @param array Array in which to move an item. (required)
26
+ * @param moveIndex The index of the item to move. (required)
27
+ * @param toIndex The index to move item at moveIndex to. (required)
28
+ */
12
29
  export declare function move<T>(array: T[], moveIndex: number, toIndex: number): T[];
13
30
  export declare function toNamePathStr(name: NamePath): string;
14
31
  export {};
@@ -1,12 +1,19 @@
1
1
  import React from 'react';
2
2
  import { BaseProps, NativeProps } from '../types/common';
3
3
  export interface IconProps extends Omit<React.AllHTMLAttributes<HTMLElement>, 'size' | 'style' | 'className' | 'readOnly' | 'disabled' | 'children'>, BaseProps, NativeProps {
4
+ /** 图标前缀,定义图标字体粗细 */
4
5
  prefix?: IconPrefix;
6
+ /** 图标名称 */
5
7
  name: IconName;
8
+ /** 图标大小 */
6
9
  size?: IconSize;
10
+ /** 图标是否旋转 */
7
11
  rotate?: Rotate;
12
+ /** 图标是否翻转 */
8
13
  flip?: Flip;
14
+ /** 是否动画 */
9
15
  spin?: boolean;
16
+ /** 是否8方向旋转 */
10
17
  pulse?: boolean;
11
18
  }
12
19
  export type SvgIconProps = Omit<IconProps, 'name'>;
@@ -316,7 +316,7 @@ function InternalInput(props, ref) {
316
316
  }
317
317
  }
318
318
  ))),
319
- suffixSlot && /* @__PURE__ */ import_react.default.createElement("span", { ref: suffixRef, key: "suffixSlot", className: (0, import_classnames.default)(e`suffix`, { "r-click": suffixCanClick }), onClick: onClickSuffix }, /* @__PURE__ */ import_react.default.createElement("span", { className: e`suffix-inner` }, suffixSlot))
319
+ suffixSlot && /* @__PURE__ */ import_react.default.createElement("span", { ref: suffixRef, key: "suffixSlot", className: (0, import_classnames.default)(e`suffix`, { [b("click", false)]: suffixCanClick }), onClick: onClickSuffix }, /* @__PURE__ */ import_react.default.createElement("span", { className: e`suffix-inner` }, suffixSlot))
320
320
  );
321
321
  }, [
322
322
  type,
@@ -342,6 +342,7 @@ function InternalInput(props, ref) {
342
342
  maxLength,
343
343
  handelClear,
344
344
  suffixSlot,
345
+ b,
345
346
  suffixCanClick,
346
347
  onClickSuffix,
347
348
  showClear,
@@ -3,11 +3,16 @@ import { BaseProps, FormControlBaseProps, NativeProps, TypeAttributes } from '..
3
3
  export type LiteralUnion<T extends U, U> = T | (U & {});
4
4
  export type ValueType = React.AllHTMLAttributes<HTMLInputElement>['value'];
5
5
  export type BaseInputRef = {
6
+ /** 获取值 */
6
7
  getValue: () => ValueType;
8
+ /** 设置值 */
7
9
  setValue: (value: ValueType) => void;
8
10
  onClear: (event?: any) => void;
11
+ /** 重置值 */
9
12
  clear: (event?: any) => void;
13
+ /** 使 input 组件获得焦点 */
10
14
  focus: () => void;
15
+ /** 使 input 组件失去焦点 */
11
16
  blur: () => void;
12
17
  showClear?: (value: ValueType) => void;
13
18
  hideClear?: () => void;
@@ -21,67 +26,123 @@ export type TextareaRef = {
21
26
  } & BaseInputRef;
22
27
  export interface InputProps extends FormControlBaseProps<ValueType>, BaseProps, NativeProps, Omit<React.AllHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'size' | 'prefix' | 'type' | 'onInput' | 'onChange' | 'style' | 'children'> {
23
28
  size?: TypeAttributes.Size;
29
+ /** 初始值 */
24
30
  defaultValue?: ValueType;
31
+ /**
32
+ * text,textarea 和其他原生 input 的 type 值
33
+ * ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#%3Cinput%3E_types */
25
34
  type?: LiteralUnion<'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'number' | 'password' | 'range' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week', string>;
35
+ /** 输入框头部内容,只对 type="text" 有效 */
26
36
  prefix?: React.ReactElement<any> | string | number;
37
+ /** 输入框尾部内容,只对 type="text" 有效 */
27
38
  suffix?: React.ReactElement<any> | string | number;
39
+ /** 输入框前置内容,只对 type="text" 有效 */
28
40
  prepend?: React.ReactElement<any> | string | number;
41
+ /** 输入框后置内容,只对 type="text" 有效 */
29
42
  append?: React.ReactElement | string | number;
43
+ /** 是否可清空 */
30
44
  clearable?: boolean;
45
+ /** 是否显示切换密码图标 */
31
46
  showPassword?: boolean;
47
+ /** 是否纯文本模式,即无边框 */
32
48
  plain?: boolean;
49
+ /** 表单校验错误提示 */
33
50
  error?: boolean;
51
+ /** 表单校验警告提示 */
34
52
  warning?: boolean;
53
+ /** 输入是否防抖动 */
35
54
  debounceInput?: boolean;
55
+ /** 获取输入建议的防抖延时,单位为毫秒 */
36
56
  debounceTime?: number;
57
+ /** input自定义内联样式 */
37
58
  innerStyle?: React.CSSProperties;
59
+ /** 范围选择时开始输入框的占位内容 */
38
60
  startPlaceholder?: string;
61
+ /** 范围选择时结束输入框的占位内容 */
39
62
  endPlaceholder?: string;
63
+ /** 最大输入长度 */
40
64
  maxLength?: number;
65
+ /** 原生属性,最小输入长度 */
41
66
  minLength?: number;
67
+ /** 是否显示统计字数, 只在 type 为 'text' 或 'textarea' 的时候生效 */
42
68
  showWordLimit?: boolean;
69
+ /** 是否隐藏值 */
43
70
  hiddenValue?: boolean;
71
+ /** 在点击由 clearable 属性生成的清空按钮时触发 */
44
72
  onClear?: (e: MouseEvent) => void;
73
+ /** 在 Input 值改变时触发 */
45
74
  onChange?: (value: ValueType, event?: React.ChangeEvent) => void;
46
75
  }
47
76
  export interface InputGroupProps extends BaseProps, NativeProps {
77
+ /** 输入框前置内容,只对 type="text" 有效 */
48
78
  prepend?: React.ReactElement<any> | string | number;
79
+ /** 输入框后置内容,只对 type="text" 有效 */
49
80
  append?: React.ReactElement | string | number;
50
81
  }
51
82
  export interface TextareaProps extends Omit<React.AllHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'size' | 'prefix' | 'type' | 'onInput' | 'onChange' | 'style' | 'children'>, FormControlBaseProps<ValueType>, BaseProps, NativeProps {
83
+ /** 初始值 */
52
84
  defaultValue?: ValueType;
85
+ /** 表单校验错误提示 */
53
86
  error?: boolean;
87
+ /** 表单校验警告提示 */
54
88
  warning?: boolean;
89
+ /** 是否纯文本模式,即无边框 */
55
90
  plain?: boolean;
56
91
  rows?: number;
92
+ /** input自定义内联样式 */
57
93
  innerStyle?: React.CSSProperties;
94
+ /** 最大输入长度 */
58
95
  maxLength?: number;
96
+ /** 原生属性,最小输入长度 */
59
97
  minLength?: number;
98
+ /** 是否显示统计字数, 只在 type 为 'text' 或 'textarea' 的时候生效 */
60
99
  showWordLimit?: boolean;
100
+ /** 在 Input 值改变时触发 */
61
101
  onChange?: (value: ValueType, event?: React.ChangeEvent) => void;
62
102
  }
63
103
  export type InputRangeValueType = [string | null, string | null] | [number | null, number | null];
64
104
  export interface InputRangeProps<T = InputRangeValueType> extends Omit<FormControlBaseProps<T>, 'name' | 'onChange'>, BaseProps, NativeProps {
65
105
  name?: [string, string];
66
106
  size?: TypeAttributes.Size;
107
+ /** 只读 */
67
108
  readOnly?: boolean;
109
+ /** 是否激活状态 */
68
110
  active?: boolean;
69
111
  onClick?: React.MouseEventHandler<HTMLDivElement>;
112
+ /**
113
+ * text,textarea 和其他原生 input 的 type 值
114
+ * ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#%3Cinput%3E_types */
70
115
  type?: 'text' | 'hidden' | 'number';
116
+ /** 输入框头部内容,只对 type="text" 有效 */
71
117
  prefix?: React.ReactElement<any> | string | number;
118
+ /** 输入框尾部内容,只对 type="text" 有效 */
72
119
  suffix?: React.ReactElement<any> | string | number;
120
+ /** 输入框前置内容,只对 type="text" 有效 */
73
121
  prepend?: React.ReactElement<any> | string | number;
122
+ /** 输入框后置内容,只对 type="text" 有效 */
74
123
  append?: React.ReactElement | string | number;
124
+ /** 数值精度 */
75
125
  precision?: number;
126
+ /** 是否可清空 */
76
127
  clearable?: boolean;
128
+ /** 是否纯文本模式,即无边框 */
77
129
  plain?: boolean;
130
+ /** 表单校验失败 */
78
131
  error?: boolean;
132
+ /** 表单校验失败 */
79
133
  warning?: boolean;
134
+ /** 选择范围时的分隔符 */
80
135
  rangeSeparator?: string;
136
+ /** 输入是否防抖动 */
81
137
  debounceInput?: boolean;
138
+ /** input自定义内联样式 */
82
139
  innerStyle?: React.CSSProperties;
140
+ /** 范围选择时开始输入框的占位内容 */
83
141
  startPlaceholder?: string;
142
+ /** 范围选择时结束输入框的占位内容 */
84
143
  endPlaceholder?: string;
144
+ /** 在点击由 clearable 属性生成的清空按钮时触发 */
85
145
  onClear?: (e: MouseEvent) => void;
146
+ /** 选中值发生变化时触发 */
86
147
  onChange?: (value: InputRangeValueType | null, event?: Event) => void;
87
148
  }
@@ -4,28 +4,49 @@ import { BaseProps, FormControlBaseProps, NativeProps } from '../types/common';
4
4
  export type LiteralUnion<T extends U, U> = T | (U & {});
5
5
  export type ValueType = number | string;
6
6
  export interface InputNumberProps<V = ValueType> extends Omit<FormControlBaseProps<V>, 'onChange'>, BaseProps<HTMLDivElement>, NativeProps, Omit<React.AllHTMLAttributes<HTMLInputElement>, 'defaultValue' | 'size' | 'prefix' | 'type' | 'onInput' | 'onChange' | 'style' | 'value' | 'ref' | 'className' | 'readOnly' | 'disabled' | 'name' | 'children'> {
7
+ /** 设置计数器允许的最大值 */
7
8
  max?: number;
9
+ /** 设置计数器允许的最小值 */
8
10
  min?: number;
11
+ /** 计数器步长 */
9
12
  step?: number;
13
+ /** 是否只能输入 step 的倍数 */
10
14
  stepStrictly?: boolean;
15
+ /** 数值精度 */
11
16
  precision?: number;
17
+ /** 控制按钮位置 */
12
18
  controlsPositionRight?: boolean;
19
+ /** 占位符 */
13
20
  placeholder?: string;
21
+ /** 绑定值被改变时触发 */
14
22
  onChange?: (currentValue: number | string, oldValue?: number | string) => void;
23
+ /** 样式前缀 */
15
24
  prefixCls?: string;
25
+ /** 表单校验错误提示 */
16
26
  error?: boolean;
27
+ /** 表单校验警告提示 */
17
28
  warning?: boolean;
29
+ /** 输入框头部内容 */
18
30
  prefix?: React.ReactElement<any> | string | number;
31
+ /** 输入框尾部内容 */
19
32
  suffix?: React.ReactElement<any> | string | number;
33
+ /** 输入框前置内容 */
20
34
  prepend?: React.ReactElement<any> | string | number;
35
+ /** 输入框后置内容 */
21
36
  append?: React.ReactElement | string | number;
37
+ /** 最大输入长度 */
22
38
  maxLength?: number;
39
+ /** 原生属性,最小输入长度 */
23
40
  minLength?: number;
24
41
  }
25
42
  export interface InputNumberRef {
43
+ /** 顶级div */
26
44
  ref: Ref<HTMLDivElement>;
45
+ /** input */
27
46
  input: Ref<InputRef>;
28
47
  getValue: () => number;
48
+ /** 使 input 组件获得焦点 */
29
49
  focus: () => void;
50
+ /** 使 input 组件失去焦点 */
30
51
  blur: () => void;
31
52
  }
@@ -2,10 +2,15 @@ import React from 'react';
2
2
  import { IconName } from '../Icon';
3
3
  import { BaseProps, NativeProps, TypeAttributes } from '../types/common';
4
4
  export type LinkType = TypeAttributes.Appearance;
5
- export interface LinkProps extends BaseProps, NativeProps, Omit<React.AllHTMLAttributes<HTMLAnchorElement>, 'type' | 'style' | 'children'> {
5
+ export interface LinkProps extends BaseProps, NativeProps<'--el-link-font-size' | '--el-link-font-weight' | '--el-link-text-color' | '--el-link-hover-text-color' | '--el-link-disabled-text-color'>, Omit<React.AllHTMLAttributes<HTMLAnchorElement>, 'type' | 'style' | 'children'> {
6
+ /** 链接地址 */
6
7
  href?: string;
8
+ /** 链接类型 */
7
9
  type?: LinkType;
10
+ /** 是否下划线 */
8
11
  underline?: boolean;
12
+ /** 是否禁用状态 */
9
13
  disabled?: boolean;
14
+ /** 图标组件 */
10
15
  icon?: IconName;
11
16
  }
@@ -2,12 +2,17 @@ import { RefObject } from 'react';
2
2
  import { IconName } from '../Icon';
3
3
  import { BaseProps, NativeProps } from '../types/common';
4
4
  export interface LoadingProps extends BaseProps, NativeProps {
5
+ /** Loading 需要覆盖的 DOM 节点。 可传入一个 DOM 对象或字符串; 若传入字符串,则会将其作为参数传入 document.querySelector以获取到对应 DOM 节点 */
5
6
  target?: RefObject<HTMLElement>;
6
7
  visible?: boolean;
8
+ /** 是否让加载组件铺满整个屏幕 */
7
9
  fullscreen?: boolean;
8
10
  lock?: boolean;
11
+ /** 显示在加载图标下方的加载文案 */
9
12
  text?: string;
13
+ /** 自定义加载图标类名 */
10
14
  spinner?: IconName;
15
+ /** 遮罩背景色 */
11
16
  background?: string;
12
17
  }
13
18
  export type LoadingService = (props?: LoadingProps) => {
@@ -1,5 +1,12 @@
1
1
  import React from 'react';
2
2
  import { MessageProps, MessageRef } from './typings';
3
+ /**
4
+ * @author Parker
5
+ * @CreateTime 2022/5/2 21:15:44
6
+ * @LastEditor Parker
7
+ * @ModifyTime 2022/5/3 12:09:53
8
+ * @Description
9
+ */
3
10
  export declare class Main {
4
11
  ref: React.RefObject<MessageRef>;
5
12
  constructor(props: MessageProps);
@@ -1,6 +1,14 @@
1
1
  import { RefObject } from 'react';
2
2
  import { MessageMethod, MessageQueue } from './typings';
3
3
  export declare const instances: MessageQueue;
4
+ /**
5
+ * 消息提示组件
6
+ * @author Parker
7
+ * @CreateTime 2022/3/10 12:45:48
8
+ * @LastEditor Parker
9
+ * @ModifyTime 2022/5/3 12:10:04
10
+ * @Description Element Plus 消息提示组件魔改过来的,源代码见:https://github.com/element-plus/element-plus
11
+ */
4
12
  export declare const Message: MessageMethod;
5
13
  export declare function close(id: string, userOnClose?: (el?: RefObject<HTMLElement>) => void): void;
6
14
  export declare function closeAll(): void;
@@ -6,15 +6,25 @@ export interface MessageHandle {
6
6
  }
7
7
  export interface MessageProps extends BaseProps, NativeProps, AnimationEventProps {
8
8
  id?: string;
9
+ /** 文字是否居中 */
9
10
  center?: boolean;
11
+ /** 显示时间,单位为毫秒。 设为 0 则不会自动关闭 */
10
12
  duration?: number;
13
+ /** 自定义图标 */
11
14
  iconClass?: string;
15
+ /** 消息文字 */
12
16
  message?: string | React.ReactElement;
17
+ /** Message 距离窗口顶部的偏移量 */
13
18
  offset?: number;
19
+ /** 关闭时的回调函数, 参数为被关闭的 message 实例 */
14
20
  onClose?: (el?: RefObject<HTMLElement>) => void;
21
+ /** 是否显示关闭按钮 */
15
22
  showClose?: boolean;
23
+ /** 消息类型 */
16
24
  type?: 'success' | 'warning' | 'info' | 'error' | '';
25
+ /** 是否立即执行onClose方法 */
17
26
  immediate?: boolean;
27
+ /** 合并内容相同的消息,不支持 VNode 类型的消息 */
18
28
  grouping?: boolean;
19
29
  userOnClose?: (el?: RefObject<HTMLElement>) => void;
20
30
  }
@@ -37,6 +47,7 @@ export interface MessageRef {
37
47
  message: string | React.ReactElement;
38
48
  close: () => void;
39
49
  setOffset: (val: number) => void;
50
+ /** 设置重复数量 */
40
51
  setReapetNum: () => void;
41
52
  }
42
53
  export type MessageQueue = Array<RefObject<MessageRef>>;