@sheinx/hooks 3.8.0-beta.8 → 3.8.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 (183) hide show
  1. package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
  2. package/cjs/common/use-filter/use-filter.js +4 -1
  3. package/cjs/common/use-position-style/check-border.d.ts +1 -0
  4. package/cjs/common/use-position-style/check-border.d.ts.map +1 -1
  5. package/cjs/common/use-position-style/check-border.js +2 -2
  6. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  7. package/cjs/common/use-position-style/index.js +10 -4
  8. package/cjs/components/use-check/use-check.d.ts.map +1 -1
  9. package/cjs/components/use-check/use-check.js +10 -2
  10. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  11. package/cjs/components/use-datepicker/use-datepicker-format.js +1 -0
  12. package/cjs/components/use-datepicker/use-time.d.ts +10 -8
  13. package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
  14. package/cjs/components/use-datepicker/use-time.js +19 -5
  15. package/cjs/components/use-datepicker/use-time.type.d.ts +5 -1
  16. package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
  17. package/cjs/components/use-datepicker/util.d.ts.map +1 -1
  18. package/cjs/components/use-datepicker/util.js +10 -1
  19. package/cjs/components/use-form/Provider.d.ts.map +1 -1
  20. package/cjs/components/use-form/Provider.js +7 -2
  21. package/cjs/components/use-form/form-schema-context.d.ts +6 -0
  22. package/cjs/components/use-form/form-schema-context.d.ts.map +1 -0
  23. package/cjs/components/use-form/form-schema-context.js +16 -0
  24. package/cjs/components/use-form/index.d.ts +2 -0
  25. package/cjs/components/use-form/index.d.ts.map +1 -1
  26. package/cjs/components/use-form/index.js +21 -1
  27. package/cjs/components/use-form/use-form-context.d.ts.map +1 -1
  28. package/cjs/components/use-form/use-form-context.js +11 -5
  29. package/cjs/components/use-form/use-form-context.type.d.ts +6 -0
  30. package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
  31. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  32. package/cjs/components/use-form/use-form-control/use-form-control.js +34 -4
  33. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
  34. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  35. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
  36. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  37. package/cjs/components/use-form/use-form-item/form-item-context.d.ts +1 -0
  38. package/cjs/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
  39. package/cjs/components/use-form/use-form-item/form-item-context.js +2 -1
  40. package/cjs/components/use-form/use-form-item/index.d.ts +1 -0
  41. package/cjs/components/use-form/use-form-item/index.d.ts.map +1 -1
  42. package/cjs/components/use-form/use-form-item/index.js +7 -0
  43. package/cjs/components/use-form/use-form-item/use-form-item.d.ts +1 -1
  44. package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
  45. package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
  46. package/cjs/components/use-form/use-form-schema/form-schema-builder.js +377 -0
  47. package/cjs/components/use-form/use-form-schema/index.d.ts +3 -0
  48. package/cjs/components/use-form/use-form-schema/index.d.ts.map +1 -0
  49. package/cjs/components/use-form/use-form-schema/index.js +13 -0
  50. package/cjs/components/use-form/use-form.d.ts +4 -0
  51. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  52. package/cjs/components/use-form/use-form.js +19 -9
  53. package/cjs/components/use-form/use-form.type.d.ts +46 -39
  54. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  55. package/cjs/components/use-input/use-input-number.d.ts.map +1 -1
  56. package/cjs/components/use-input/use-input-number.js +3 -1
  57. package/cjs/components/use-input/use-input-number.type.d.ts +1 -1
  58. package/cjs/components/use-input/use-input-number.type.d.ts.map +1 -1
  59. package/cjs/components/use-input/use-input.d.ts.map +1 -1
  60. package/cjs/components/use-input/use-input.js +4 -1
  61. package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
  62. package/cjs/components/use-pagination/use-pagination.js +2 -1
  63. package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
  64. package/cjs/components/use-popup/use-popup.js +12 -24
  65. package/cjs/components/use-select/use-select.type.d.ts +27 -18
  66. package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
  67. package/cjs/components/use-table/use-table-virtual.d.ts +6 -1
  68. package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
  69. package/cjs/components/use-table/use-table-virtual.js +5 -4
  70. package/cjs/components/use-table/use-table.type.d.ts +70 -92
  71. package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
  72. package/cjs/components/use-tree/use-tree-node.d.ts +7 -1
  73. package/cjs/components/use-tree/use-tree-node.d.ts.map +1 -1
  74. package/cjs/components/use-tree/use-tree-node.js +19 -1
  75. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  76. package/cjs/components/use-tree/use-tree.js +26 -19
  77. package/cjs/components/use-tree/use-tree.type.d.ts +7 -1
  78. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  79. package/cjs/utils/dom/document.d.ts +4 -0
  80. package/cjs/utils/dom/document.d.ts.map +1 -1
  81. package/cjs/utils/dom/document.js +19 -2
  82. package/cjs/utils/dom/element.d.ts +1 -0
  83. package/cjs/utils/dom/element.d.ts.map +1 -1
  84. package/cjs/utils/dom/element.js +5 -1
  85. package/cjs/utils/highlight.d.ts.map +1 -1
  86. package/cjs/utils/highlight.js +24 -11
  87. package/cjs/utils/lazyload.d.ts.map +1 -1
  88. package/cjs/utils/lazyload.js +33 -1
  89. package/cjs/utils/object.d.ts +6 -0
  90. package/cjs/utils/object.d.ts.map +1 -1
  91. package/cjs/utils/object.js +21 -1
  92. package/esm/common/use-filter/use-filter.d.ts.map +1 -1
  93. package/esm/common/use-filter/use-filter.js +4 -1
  94. package/esm/common/use-position-style/check-border.d.ts +1 -0
  95. package/esm/common/use-position-style/check-border.d.ts.map +1 -1
  96. package/esm/common/use-position-style/check-border.js +2 -2
  97. package/esm/common/use-position-style/index.d.ts.map +1 -1
  98. package/esm/common/use-position-style/index.js +11 -5
  99. package/esm/components/use-check/use-check.d.ts.map +1 -1
  100. package/esm/components/use-check/use-check.js +10 -2
  101. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  102. package/esm/components/use-datepicker/use-datepicker-format.js +1 -0
  103. package/esm/components/use-datepicker/use-time.d.ts +10 -8
  104. package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
  105. package/esm/components/use-datepicker/use-time.js +19 -5
  106. package/esm/components/use-datepicker/use-time.type.d.ts +5 -1
  107. package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
  108. package/esm/components/use-datepicker/util.d.ts.map +1 -1
  109. package/esm/components/use-datepicker/util.js +10 -1
  110. package/esm/components/use-form/Provider.d.ts.map +1 -1
  111. package/esm/components/use-form/Provider.js +7 -2
  112. package/esm/components/use-form/form-schema-context.d.ts +6 -0
  113. package/esm/components/use-form/form-schema-context.d.ts.map +1 -0
  114. package/esm/components/use-form/form-schema-context.js +8 -0
  115. package/esm/components/use-form/index.d.ts +2 -0
  116. package/esm/components/use-form/index.d.ts.map +1 -1
  117. package/esm/components/use-form/index.js +3 -1
  118. package/esm/components/use-form/use-form-context.d.ts.map +1 -1
  119. package/esm/components/use-form/use-form-context.js +11 -5
  120. package/esm/components/use-form/use-form-context.type.d.ts +6 -0
  121. package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
  122. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  123. package/esm/components/use-form/use-form-control/use-form-control.js +34 -4
  124. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
  125. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  126. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
  127. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  128. package/esm/components/use-form/use-form-item/form-item-context.d.ts +1 -0
  129. package/esm/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
  130. package/esm/components/use-form/use-form-item/form-item-context.js +2 -1
  131. package/esm/components/use-form/use-form-item/index.d.ts +1 -0
  132. package/esm/components/use-form/use-form-item/index.d.ts.map +1 -1
  133. package/esm/components/use-form/use-form-item/index.js +2 -1
  134. package/esm/components/use-form/use-form-item/use-form-item.d.ts +1 -1
  135. package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
  136. package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
  137. package/esm/components/use-form/use-form-schema/form-schema-builder.js +371 -0
  138. package/esm/components/use-form/use-form-schema/index.d.ts +3 -0
  139. package/esm/components/use-form/use-form-schema/index.d.ts.map +1 -0
  140. package/esm/components/use-form/use-form-schema/index.js +2 -0
  141. package/esm/components/use-form/use-form.d.ts +4 -0
  142. package/esm/components/use-form/use-form.d.ts.map +1 -1
  143. package/esm/components/use-form/use-form.js +19 -9
  144. package/esm/components/use-form/use-form.type.d.ts +46 -39
  145. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  146. package/esm/components/use-input/use-input-number.d.ts.map +1 -1
  147. package/esm/components/use-input/use-input-number.js +3 -1
  148. package/esm/components/use-input/use-input-number.type.d.ts +1 -1
  149. package/esm/components/use-input/use-input-number.type.d.ts.map +1 -1
  150. package/esm/components/use-input/use-input.d.ts.map +1 -1
  151. package/esm/components/use-input/use-input.js +4 -1
  152. package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
  153. package/esm/components/use-pagination/use-pagination.js +2 -1
  154. package/esm/components/use-popup/use-popup.d.ts.map +1 -1
  155. package/esm/components/use-popup/use-popup.js +12 -24
  156. package/esm/components/use-select/use-select.type.d.ts +27 -18
  157. package/esm/components/use-select/use-select.type.d.ts.map +1 -1
  158. package/esm/components/use-table/use-table-virtual.d.ts +6 -1
  159. package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
  160. package/esm/components/use-table/use-table-virtual.js +5 -4
  161. package/esm/components/use-table/use-table.type.d.ts +70 -92
  162. package/esm/components/use-table/use-table.type.d.ts.map +1 -1
  163. package/esm/components/use-tree/use-tree-node.d.ts +7 -1
  164. package/esm/components/use-tree/use-tree-node.d.ts.map +1 -1
  165. package/esm/components/use-tree/use-tree-node.js +19 -1
  166. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  167. package/esm/components/use-tree/use-tree.js +26 -19
  168. package/esm/components/use-tree/use-tree.type.d.ts +7 -1
  169. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  170. package/esm/utils/dom/document.d.ts +4 -0
  171. package/esm/utils/dom/document.d.ts.map +1 -1
  172. package/esm/utils/dom/document.js +18 -1
  173. package/esm/utils/dom/element.d.ts +1 -0
  174. package/esm/utils/dom/element.d.ts.map +1 -1
  175. package/esm/utils/dom/element.js +4 -0
  176. package/esm/utils/highlight.d.ts.map +1 -1
  177. package/esm/utils/highlight.js +24 -10
  178. package/esm/utils/lazyload.d.ts.map +1 -1
  179. package/esm/utils/lazyload.js +33 -1
  180. package/esm/utils/object.d.ts +6 -0
  181. package/esm/utils/object.d.ts.map +1 -1
  182. package/esm/utils/object.js +20 -0
  183. package/package.json +3 -3
@@ -3,6 +3,7 @@ import { ReactNode } from 'react';
3
3
  import { AddNoProps, ObjectType } from '../../common/type';
4
4
  import { FormItemRule } from '../../utils/rule/rule.type';
5
5
  import { FormError } from '../../utils';
6
+ import { SchemaBuilder } from './use-form-schema';
6
7
  export type KeyType = string | number | symbol;
7
8
  export interface ValidationError<T> {
8
9
  values: T;
@@ -32,48 +33,49 @@ export interface ProviderProps {
32
33
  formConfig: FormCommonConfig;
33
34
  formValue: FormContextValueType;
34
35
  formFunc: FormFunc;
36
+ formSchema: SchemaBuilder | null;
35
37
  children?: ReactNode;
36
38
  }
37
39
  export interface FormLabelConfig {
38
40
  /**
39
- * @en The width of label. It is invalid when labelAlign is 'top'.
40
- * @cn 标签宽度,labelAlign 为 'top' 时无效。
41
+ * @en The width of label. It is invalid when labelAlign is 'top'. Uniformly sets the width of form item labels. Can be a specific pixel value (such as '140px') or percentage (such as '30%'). This configuration is invalid when labels are top-aligned. Used to maintain aligned visual effects of forms, ensuring all form item input areas are left-aligned
42
+ * @cn 标签宽度,labelAlign 为 'top' 时无效。统一设置表单项标签的宽度。可以是具体像素值(如 '140px')或百分比(如 '30%')。当标签顶部对齐时此配置无效。用于保持表单整齐的视觉效果,确保所有表单项的输入区域左对齐
41
43
  * @default 140px
42
44
  */
43
45
  labelWidth?: string | number;
44
46
  /**
45
- * @en The default is empty, follow the theme style.
46
- * @cn 默认为空,跟随主题样式。
47
+ * @en The default is empty, follow the theme style. Label alignment. 'left' for left alignment, 'right' for right alignment, 'top' for top alignment. Different alignment methods are suitable for different form layout needs: 'right' is suitable for traditional form layouts, 'top' is suitable for mobile or compact layouts, 'left' is suitable for special design requirements
48
+ * @cn 默认为空,跟随主题样式。标签的对齐方式。'left' 左对齐,'right' 右对齐,'top' 顶部对齐。不同的对齐方式适用于不同的表单布局需求:'right' 适合传统表单布局,'top' 适合移动端或紧凑布局,'left' 适合特殊设计需求
47
49
  */
48
50
  labelAlign?: 'left' | 'right' | 'top';
49
51
  /**
50
- * @en the default value is top.
51
- * @cn 默认顶部对齐
52
+ * @en The default value is top. Vertical alignment of labels. When labels and input boxes are on the same line (labelAlign is 'left' or 'right'), controls the vertical position of labels relative to input boxes. 'top' aligns with the top of the input box, 'middle' aligns center, 'bottom' aligns with the bottom of the input box
53
+ * @cn 默认顶部对齐。标签的垂直对齐方式。当标签和输入框在同一行时(labelAlign 为 'left' 或 'right'),控制标签相对于输入框的垂直位置。'top' 与输入框顶部对齐,'middle' 居中对齐,'bottom' 与输入框底部对齐
52
54
  * @default 'top'
53
55
  */
54
56
  labelVerticalAlign?: 'bottom' | 'top' | 'middle';
55
57
  /**
56
- * @en Single-line error prompt will not stretch the page height
57
- * @cn 单行错误提示不撑开页面高度
58
+ * @en Single-line error prompt will not stretch the page height. Keeps error prompt height fixed to avoid page jittering when error messages appear/disappear. When enabled, it reserves display space for error messages to ensure stable form height. Suitable for scenarios with high requirements for layout stability, such as long forms with many form items. Note: This configuration is invalid when keepErrorBelow is true
59
+ * @cn 单行错误提示不撑开页面高度。保持错误提示高度固定,避免错误信息出现/消失时页面抖动。开启后会预留错误信息的显示空间,确保表单高度稳定。适用于对布局稳定性要求较高的场景,如表单项较多的长表单。注意:当 keepErrorBelow 为 true 时,此配置会失效
58
60
  * @default false
59
61
  */
60
62
  keepErrorHeight?: boolean;
61
63
  /**
62
- * @en Whether to keep the error message below the form item, the default is false
63
- * @cn 是否保持错误信息在提示信息下方
64
+ * @en Whether to keep the error message below the form item, the default is false. Controls the display position of error messages. When enabled, error messages are always displayed below the tip property of the form item, maintaining layout consistency. When disabled, error messages may override tip information. Suitable for scenarios where both tip and error messages need to be displayed. Note: When enabled, keepErrorHeight becomes invalid
65
+ * @cn 是否保持错误信息在提示信息下方。控制错误信息的显示位置。开启后错误信息始终显示在表单项的 tip 属性下方,保持布局的一致性。关闭时错误信息可能会覆盖 tip 信息。适用于同时需要显示提示信息和错误信息的场景。注意:开启后会使 keepErrorHeight 失效
64
66
  * @default false
65
67
  * @version 3.7.0
66
68
  */
67
69
  keepErrorBelow?: boolean;
68
70
  /**
69
- * @en When inline is true, the form is horizontal layout
70
- * @cn 是否水平布局
71
+ * @en When inline is true, the form is horizontal layout. Arranges form items horizontally, suitable for simple single-line forms or filter forms. When enabled, form items will be displayed on the same line with automatic line wrapping. Usually used for search conditions, filters and other scenarios that need to save vertical space
72
+ * @cn 是否水平布局。将表单项横向排列,适用于简单的单行表单或筛选表单。开启后表单项会在同一行显示,自动换行。通常用于搜索条件、筛选器等需要节省垂直空间的场景
71
73
  * @default false
72
74
  */
73
75
  inline?: boolean;
74
76
  /**
75
- * @en Whether to append a colon after the label, the priority is less than the colon setting of Form.Item
76
- * @cn 标签后是否追加显示一个冒号,优先级小于Form.Itemcolon设置
77
+ * @en Uniformly controls whether to display a colon after all form item labels. Can be a boolean value (true displays default colon ':') or custom ReactNode (such as ':', '->', etc.). The colon property on Form.Item has higher priority and can override this global setting
78
+ * @cn 统一控制所有表单项标签后是否显示冒号。可以是布尔值(true 显示默认冒号 ':')或自定义的 ReactNode(如 ':'、'->'等)。Form.Item 上的 colon 属性优先级更高,可以覆盖此全局设置
77
79
  * @default false
78
80
  * @version 3.6.0
79
81
  */
@@ -81,20 +83,20 @@ export interface FormLabelConfig {
81
83
  }
82
84
  export interface FormCommonConfig extends FormLabelConfig {
83
85
  /**
84
- * @en When disabled is true, all the elements in the form are disabled.
85
- * @cn 是否禁用,为 true 时,表单内所有元素 disabled 都为 true
86
+ * @en When disabled is true, all the elements in the form are disabled. Global control of form disabled state. Suitable for scenarios where the entire form needs to be temporarily disabled, such as viewing details or during submission. All controlled components in the form (such as Input, Select, DatePicker, etc.) will inherit this property
87
+ * @cn 是否禁用,为 true 时,表单内所有元素 disabled 都为 true。全局控制表单的禁用状态。适用于查看详情、提交中等需要临时禁用整个表单的场景。表单内所有受控组件(如 Input、Select、DatePicker 等)都会继承此属性
86
88
  * @default false
87
89
  */
88
90
  disabled?: boolean;
89
91
  /**
90
- * @en Form element size
91
- * @cn 表单元素的尺寸
92
+ * @en Form element size. Uniformly sets the size of all components in the form. Supports three specifications: 'small', 'default', 'large', affecting input box height, font size, etc. Controlled components in the form will inherit this property, but can also be overridden individually on specific components
93
+ * @cn 表单元素的尺寸。统一设置表单内所有组件的尺寸。支持 'small'、'default'、'large' 三种规格,影响输入框高度、字体大小等。表单内的受控组件会继承此属性,也可以在具体组件上单独覆盖
92
94
  * @default 'default'
93
95
  */
94
96
  size?: 'small' | 'default' | 'large';
95
97
  /**
96
- * @en When set to true, the form items in Form will not automatically delete data after unmounting
97
- * @cn 设置为 true 时,表单内所有组件的reserveAble都为 true : 卸载后不自动删除数据
98
+ * @en When set to true, the form items in Form will not automatically delete data after unmounting. Controls whether to retain data when form items are unmounted. Suitable for scenarios such as tab switching and conditional rendering to avoid losing user-filled data. When enabled, even if form items are hidden or unmounted, their data will still be retained in the form. Can be overridden individually on Form.Field components or supported form components (such as Input, Select, DatePicker, etc.)
99
+ * @cn 设置为 true 时,表单内所有组件的 reserveAble 都为 true : 卸载后不自动删除数据。控制表单项卸载时是否保留数据。适用于标签页切换、条件渲染等场景,避免用户填写的数据丢失。开启后即使表单项被隐藏或卸载,其数据仍会保留在表单中。可在 Form.Field 组件或支持的表单组件(如 Input、Select、DatePicker 等)上单独设置覆盖此全局配置
98
100
  * @default false
99
101
  * @version 3.5.0
100
102
  */
@@ -131,54 +133,58 @@ export interface BaseFormProps<T> extends Omit<FormCommonConfig, 'formName'> {
131
133
  value?: T;
132
134
  onChange?: (value: T) => void;
133
135
  /**
134
- * @en default Value
135
- * @cn 默认值
136
+ * @en Initial value of the form in uncontrolled mode. Only effective when the component is first rendered, subsequent modifications will not affect the internal data of the form. Suitable for scenarios where form data is managed internally by the component, such as creating new forms, standalone forms, etc.
137
+ * @cn 非受控模式下的表单初始值。仅在组件首次渲染时生效,后续修改不会影响表单内部数据。适用于表单数据由组件内部管理的场景,如新建表单、独立表单等
136
138
  */
137
139
  defaultValue?: T;
138
140
  /**
139
- * @cn 设置 value 后是否自动校验
141
+ * @en When the form value changes, whether to automatically trigger validation. When enabled, validation results can be displayed in real time when data changes, suitable for scenarios that require immediate feedback. Note: Only effective in controlled mode
142
+ * @cn 当表单 value 发生变化时,是否自动触发校验。开启后可以在数据变化时实时显示校验结果,适用于需要即时反馈的场景。注意:仅在受控模式下有效
143
+ * @default false
140
144
  */
141
145
  initValidate?: boolean;
142
146
  /**
143
- * @en the function for Form Submission. When the internal validation fails, it will not be triggered.
144
- * @cn 表单提交函数。表单内部校验失败时不会触发。
147
+ * @en Callback function when the form is submitted. Only called when all fields pass validation, with the parameter being the complete form data. Usually used to handle form data submission logic, such as sending requests to the server. Can be triggered with Form.Submit button or formRef.submit() method
148
+ * @cn 表单提交时的回调函数。只有当所有字段校验通过后才会调用,参数为完整的表单数据。通常用于处理表单数据的提交逻辑,如发送请求到服务器。可配合 Form.Submit 按钮或 formRef.submit() 方法触发
145
149
  */
146
150
  onSubmit?: (value: T) => void;
147
151
  /**
148
- * @cn 表单重置函数
149
- * @en the function for Form Reset.
152
+ * @en Callback function when the form is reset. Triggered after the form is reset to initial value (defaultValue or empty value). Can be used to execute additional reset logic, such as clearing related states, resetting related components, etc. Used with Form.Reset button or formRef.reset() method
153
+ * @cn 表单重置时的回调函数。在表单被重置为初始值(defaultValue 或空值)后触发。可用于执行额外的重置逻辑,如清除关联状态、重置相关组件等。配合 Form.Reset 按钮或 formRef.reset() 方法使用
150
154
  */
151
155
  onReset?: () => void;
152
156
  /**
153
- * @en When the verification fails, whether to scroll to the first verification failure component, when the value is a number, it means the offset relative to the top
154
- * @cn 校验失败时是否滚动到第一个校验失败组件,该值为数字时,表示相对于顶部的偏移量
157
+ * @en When the form is long, automatically scrolling to the error position can help users quickly locate problems. Set to true to use default scrolling, set to a number to adjust the offset of the scroll position to avoid being blocked by fixed headers
158
+ * @cn 当表单较长时,自动滚动到错误位置可以帮助用户快速定位问题。设置为 true 时使用默认滚动,设置为数字时可以调整滚动位置的偏移量,避免被固定头部遮挡
155
159
  * @default false
156
160
  */
157
161
  scrollToError?: boolean | number;
158
162
  /**
159
- * @en rules validation callback
160
- * @cn rules 校验回调
163
+ * @en Error callback function when validation rules are triggered. Called when any field validation fails, with the parameter being the error object. Can be used to uniformly handle validation errors, such as logging, displaying global notifications, reporting errors, etc.
164
+ * @cn 校验规则触发时的错误回调函数。当任意字段校验失败时调用,参数为错误对象。可用于统一处理校验错误,如记录日志、显示全局通知、上报错误等
161
165
  */
162
166
  onError?: (error: Error) => void;
163
167
  /**
164
- * @cn 是否删除值为 undefined 的字段
168
+ * @en Whether to automatically remove fields with undefined values when submitting the form. When enabled, it can avoid submitting meaningless empty values and keep data clean. Especially suitable for interfacing with backend APIs to avoid passing unnecessary undefined values
169
+ * @cn 提交表单时是否自动移除值为 undefined 的字段。开启后可以避免提交无意义的空值,保持数据整洁。特别适用于与后端 API 对接时,避免传递不必要的 undefined 值
165
170
  * @default true
166
171
  */
167
172
  removeUndefined?: boolean;
168
173
  /**
169
- * @en Validation rules
170
- * @cn 校验规则
174
+ * @en Form-level validation rule configuration. Supports nested object rule definitions, and can set validation rules for any field in the form. The key of the rule object corresponds to the form field path (such as 'name', 'user.email', 'list[0].id'), and the value is the validation rule array (FormItemRule) for that field. These rules will be merged with the rules property set on the Form.Field component, with Form-level rules executing first. For rule types, please refer to the Rule component documentation
175
+ * @cn 表单级别的校验规则配置。支持嵌套对象的规则定义,可以为表单的任意字段设置校验规则。规则对象的 key 对应表单字段路径(如 'name'、'user.email'、'list[0].id'),value 为该字段的校验规则数组(FormItemRule)。这些规则会与 Form.Field 组件上设置的 rules 属性合并,Form 级别的规则会先执行。规则类型请参考 Rule 组件文档
171
176
  * @override RuleItem[]
172
177
  */
173
178
  rules?: FormRuleObject<any>;
174
179
  /**
175
- * @cn ms, 两次提交间隔时长(防止重复提交)
180
+ * @en Throttle time to prevent users from clicking the submit button frequently. Repeated clicks on submit within this time will be ignored, effectively avoiding duplicate submission issues. Suitable for scenarios with slow network requests or long processing times
181
+ * @cn 防止用户频繁点击提交按钮的节流时间。在此时间内重复点击提交将被忽略,有效避免重复提交问题。适用于网络请求较慢或处理时间较长的场景
176
182
  * @default 1000
177
183
  */
178
184
  throttle?: number;
179
185
  /**
180
- * @cn 滚动的父元素,用于滚动到错误位置增加偏移量
181
- * @en The parent element of the scroll, used to scroll to the error position to increase the offset
186
+ * @en Specify the scroll container element. When the form is not scrolling directly on document.body (such as in a modal or drawer), you need to specify the actual scroll container to ensure correct scrolling to the error position. Returns null to use default scrolling behavior
187
+ * @cn 指定滚动容器元素。当表单不在 document.body 直接滚动时(如在弹窗、抽屉中),需要指定实际的滚动容器以确保正确滚动到错误位置。返回 null 时使用默认滚动行为
182
188
  */
183
189
  scrollParent?: () => HTMLElement | null;
184
190
  /**
@@ -186,8 +192,8 @@ export interface BaseFormProps<T> extends Omit<FormCommonConfig, 'formName'> {
186
192
  */
187
193
  error?: ObjectType<string | Error>;
188
194
  /**
189
- * @en The name of the form, will be used as the prefix of the form field id, and can enable the <label for="id" /> function after setting
190
- * @cn 表单名称,会作为表单字段 id 的前缀,设置后可使用 formRef scrollToField 方法
195
+ * @en Unique identifier name of the form. After setting, it will be used as the prefix for all form field ids to ensure that ids do not conflict when multiple forms coexist. Also enables the formRef.scrollToField method to quickly locate specified fields by field name
196
+ * @cn 表单的唯一标识名称。设置后会作为所有表单字段 id 的前缀,确保多个表单共存时 id 不冲突。同时启用 formRef.scrollToField 方法,可以通过字段名称快速定位到指定字段
191
197
  * @version 3.5.3
192
198
  */
193
199
  name?: string;
@@ -216,6 +222,7 @@ export type FormContext = {
216
222
  unmounted: boolean;
217
223
  removeLock: boolean;
218
224
  ignoreValidateFields: string[];
225
+ schema: SchemaBuilder | null;
219
226
  };
220
227
  export type UseFormSlotOwnProps = {
221
228
  onSubmit: any;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC;IACV,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,EAAE,CAAC;CACL;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7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,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CACzE,mBAAmB,EACnB,MAAM,CACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;CAwJ/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-input-number.d.ts","sourceRoot":"","sources":["use-input-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,QAAA,MAAM,eAAe,UAAW,gBAAgB;;;;;;;;CA0J/C,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -37,7 +37,8 @@ var useNumberFormat = function useNumberFormat(props) {
37
37
  _props$step = props.step,
38
38
  step = _props$step === void 0 ? 1 : _props$step,
39
39
  cancelBlurChange = props.cancelBlurChange,
40
- disabled = props.disabled;
40
+ disabled = props.disabled,
41
+ coin = props.coin;
41
42
  var getStringValue = function getStringValue(value) {
42
43
  if (value === undefined) return value;
43
44
  if (typeof value === 'number') {
@@ -156,6 +157,7 @@ var useNumberFormat = function useNumberFormat(props) {
156
157
  numType: numType,
157
158
  integerLimit: integerLimit,
158
159
  digits: digits,
160
+ coin: coin,
159
161
  onChange: onNumberChange,
160
162
  onBlur: onNumberBlur,
161
163
  onFocus: props.onFocus,
@@ -1,6 +1,6 @@
1
1
  import { InputFormatProps } from './use-input-format.type';
2
2
  export type NumberValue = string | number | undefined | null;
3
- export interface InputNumberProps extends Omit<InputFormatProps, 'value' | 'onChange' | 'autoFix' | 'trim' | 'coin' | 'type'> {
3
+ export interface InputNumberProps extends Omit<InputFormatProps, 'value' | 'onChange' | 'autoFix' | 'trim' | 'type'> {
4
4
  value: NumberValue;
5
5
  onChange: (value: NumberValue) => void | undefined;
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"use-input-number.type.d.ts","sourceRoot":"","sources":["use-input-number.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAC7D,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC3F,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,SAAS,CAAC;IACnD;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"use-input-number.type.d.ts","sourceRoot":"","sources":["use-input-number.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAC7D,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IAClF,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,SAAS,CAAC;IACnD;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-input.d.ts","sourceRoot":"","sources":["use-input.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa5D,QAAA,MAAM,QAAQ,WAAY,cAAc;;;;;;;CAyIvC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-input.d.ts","sourceRoot":"","sources":["use-input.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa5D,QAAA,MAAM,QAAQ,WAAY,cAAc;;;;;;;CA4IvC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -97,7 +97,10 @@ var useInput = function useInput(params) {
97
97
  (_otherHandlers$onFocu = otherHandlers.onFocus) === null || _otherHandlers$onFocu === void 0 || _otherHandlers$onFocu.call(otherHandlers, event);
98
98
  setFocused(true);
99
99
  if (autoSelect) {
100
- event.target.select();
100
+ // why requestAnimationFrame: 当在文字身体上hover后立即点击,select()与浏览器的光标定位逻辑产生竞争,有可能导致只选中的部分文本,所以需要延迟一下
101
+ requestAnimationFrame(function () {
102
+ event.target.select();
103
+ });
101
104
  }
102
105
  };
103
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-pagination.d.ts","sourceRoot":"","sources":["use-pagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,aAAa,UAAW,mBAAmB;;;;kBAqBT,MAAM,SAAS,MAAM;;;;;;;CAiC5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"use-pagination.d.ts","sourceRoot":"","sources":["use-pagination.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,QAAA,MAAM,aAAa,UAAW,mBAAmB;;;;kBAqBT,MAAM,SAAS,MAAM;;;;;;;CAkC5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -61,7 +61,8 @@ var usePagination = function usePagination(props) {
61
61
  return _objectSpread({}, mergedEventHandlers);
62
62
  };
63
63
  return {
64
- current: current,
64
+ // current,
65
+ current: currentProp !== undefined ? currentProp : current,
65
66
  pageSize: pageSize,
66
67
  total: total,
67
68
  onChange: handleChange,
@@ -1 +1 @@
1
- {"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAkIK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAM9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBA5B7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;2BApFzC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;8BAOvC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;2BA2JxD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAMxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CA8BlE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4E,MAAM,OAAO,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BAqHK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAS9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBA/B7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAvEzC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;8BAOvC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;2BAiJxD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAMxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CA8BlE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -90,26 +90,11 @@ var usePopup = function usePopup(props) {
90
90
  }
91
91
  setOpenState(!!props.open);
92
92
  }, [props.open]);
93
-
94
- // const getPopUpHeight = () => {
95
- // let height = 0;
96
- // if (popupRef.current) {
97
- // const el = popupRef.current;
98
- // const parent = el?.parentElement;
99
- // let clone = el.cloneNode(true) as HTMLElement;
100
- // clone.style.opacity = '0';
101
- // clone.style.display = '';
102
- // clone.style.visibility = 'visible';
103
- // clone.style.pointerEvents = 'none';
104
- // parent?.appendChild(clone);
105
- // height = clone.offsetHeight;
106
- // parent?.removeChild(clone);
107
- // //@ts-ignore
108
- // clone = null;
109
- // }
110
- // return height;
111
- // };
112
-
93
+ (0, _react.useEffect)(function () {
94
+ if (props.open === undefined && defaultOpen) {
95
+ setOpenState(true);
96
+ }
97
+ }, []);
113
98
  var handleFocus = function handleFocus(delay) {
114
99
  if (props.open === undefined) {
115
100
  updatePosition();
@@ -142,17 +127,20 @@ var usePopup = function usePopup(props) {
142
127
  }
143
128
  };
144
129
  var handleMouseEnter = (0, _usePersistFn.default)(function (e) {
145
- var _targetEvents$onMouse;
130
+ var _targetEvents$onMouse, _targetRef$current, _popupRef$current2;
146
131
  targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse = targetEvents.onMouseEnter) === null || _targetEvents$onMouse === void 0 || _targetEvents$onMouse.call(targetEvents, e);
147
132
  if (trigger !== 'hover') return;
148
- handleHoverToggle(true);
133
+ var isParentContainsCurrent = (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(e.target);
134
+ if (isParentContainsCurrent || popupRef !== null && popupRef !== void 0 && (_popupRef$current2 = popupRef.current) !== null && _popupRef$current2 !== void 0 && _popupRef$current2.contains(e.target)) {
135
+ handleHoverToggle(true);
136
+ }
149
137
  });
150
138
  var handleMouseLeave = (0, _usePersistFn.default)(function (e) {
151
- var _targetEvents$onMouse2, _popupRef$current2;
139
+ var _targetEvents$onMouse2, _popupRef$current3;
152
140
  targetEvents === null || targetEvents === void 0 || (_targetEvents$onMouse2 = targetEvents.onMouseLeave) === null || _targetEvents$onMouse2 === void 0 || _targetEvents$onMouse2.call(targetEvents, e);
153
141
  if (trigger !== 'hover') return;
154
142
  // @ts-ignore
155
- if (e.relatedTarget instanceof HTMLElement && (_popupRef$current2 = popupRef.current) !== null && _popupRef$current2 !== void 0 && _popupRef$current2.contains(e.relatedTarget)) {
143
+ if (e.relatedTarget instanceof HTMLElement && (_popupRef$current3 = popupRef.current) !== null && _popupRef$current3 !== void 0 && _popupRef$current3.contains(e.relatedTarget)) {
156
144
  return;
157
145
  }
158
146
  handleHoverToggle(false);
@@ -4,56 +4,65 @@ export interface BaseSelectProps<DataItem, Value> {
4
4
  data?: DataItem[];
5
5
  treeData?: DataItem[];
6
6
  /**
7
- * @en Data cache, if data change asynchronously, better set true
8
- * @cn 是否开启数据缓存,如果数据存在动态更新的情况建议开启
7
+ * @en Whether to disable data caching. By default, shineout caches value-to-data mappings for performance. When data changes frequently (e.g., updated from API), enabling this prevents stale cache issues
8
+ * @cn 是否禁用数据缓存。出于性能考虑,shineout 默认会缓存 value 与 data 的映射关系。当 data 频繁变更时(如接口动态更新),开启此选项可避免缓存不一致问题
9
9
  * @default false
10
+ * @when 当列表数据会动态更新时使用,如通过接口实时获取数据或根据其他条件变化数据
10
11
  */
11
12
  noCache?: boolean;
12
13
  /**
13
- * @en Initial value
14
- * @cn 默认值 通过 Value 类型
14
+ * @en Initial value for uncontrolled component
15
+ * @cn 非受控组件的初始值
16
+ * @when 需要设置初始选中值但不需要外部控制时使用
15
17
  */
16
18
  defaultValue?: Value;
17
19
  control: boolean;
18
20
  separator?: string;
19
21
  /**
20
- * @en If it is true, it will be multiple selection
21
- * @cn 是否是多选
22
+ * @en Enable multiple selection mode
23
+ * @cn 是否开启多选模式
22
24
  * @default false
25
+ * @when 需要选择多个选项时使用
23
26
  */
24
27
  multiple?: boolean;
25
28
  childrenKey?: keyof DataItem;
26
29
  /**
27
- * @en When the value is true, disabled all checkboxes; When the value is function, disable the checkbox that this function returns true
28
- * @cn 如果 disabled 为 true,禁用全部选项,如果 disabled 为函数,根据函数反回结果禁用选项
30
+ * @en When true, disables all options; when function, disables options where function returns true
31
+ * @cn 为 true 时禁用全部选项;为函数时根据返回值禁用特定选项
29
32
  * @default false
33
+ * @when 需要禁用整个选择器或根据条件禁用特定选项时使用
30
34
  */
31
35
  disabled?: boolean | ((data: DataItem) => boolean);
32
36
  /**
33
- * @en By default, the result of the format function is used to compare whether it matches. In some cases (for example, whe an object that returns the original data is updated, an different option with the same value is generated), the prediction function needs to be used to determine whether match
34
- * @cn 默认使用 format 函数执行的结果来比较是否匹配,在某些情况下(例如返回原始数据的对象,更新数据时,生成了一个值相同,非同一个对象的选项),需要借助 prediction 函数来判断是否匹配
37
+ * @en Custom comparison function to determine if a value matches a data item. Solves JavaScript's reference equality (===) limitation where objects with identical content but different references are considered unequal
38
+ * @cn 自定义匹配函数,用于判断 value 是否与数据项匹配。解决 JavaScript 引用相等(===)的局限性,即内容相同但引用不同的对象会被判定为不相等的问题
35
39
  * @default (val, d) => val===format(d)
40
+ * @when 当选中值为对象类型且数据源会重新生成(如从接口获取)时使用,避免因引用变化导致的匹配失败
36
41
  */
37
42
  prediction?: (value: Value extends (infer U)[] ? U : Value, Data: DataItem) => boolean;
38
43
  /**
39
- * @en Format value. The defaule value is return the original data. When it is a string, the value is fetched from the original data as a key equivalent to (d) => d[format] When it is a function, use its return value
40
- * @cn 格式化 value, 默认值,返回原始数据。 为 string 时,会作为 key 从原始数据中获取值,相当于 (d) => d[format]; 为函数时,以函数返回结果作为 value
44
+ * @en Formats data item to value. String: extracts property (e.g., 'id' gets d.id). Function: returns custom value from data item
45
+ * @cn 格式化数据项为选中值。字符串:提取对应属性(如 'id' 获取 d.id)。函数:从数据项返回自定义值
41
46
  * @default d => d
47
+ * @when 当数据项为对象但只需要其中某个属性作为值时使用
42
48
  */
43
49
  format?: ((data: DataItem) => Value extends (infer U)[] ? U : Value) | ObjectKey<DataItem>;
44
50
  /**
45
- * @en The callback before the value is changed, when the return value is not empty, it will be used as the new value of the component
46
- * @cn 值改变前的回调,当返回值不为空时将作为组件的新值
51
+ * @en Intercepts value changes. Return new value to modify it, or undefined to prevent the change
52
+ * @cn 拦截值变更。返回新值以修改,返回 undefined 阻止变更
53
+ * @when 需要在值变更前进行验证或转换时使用
47
54
  */
48
55
  beforeChange?: (value: Value) => any;
49
56
  /**
50
- * @en Change callback
51
- * @cn 值改变回调
57
+ * @en Callback when value changes. Parameters: value (selected value), data (selected data item), checked (selection state)
58
+ * @cn 值变更回调。参数:value(选中值)、data(选中的数据项)、checked(选中状态)
59
+ * @when 需要响应选择变化时使用
52
60
  */
53
61
  onChange?: (value: Value, data?: DataItem, checked?: boolean) => void;
54
62
  /**
55
- * @en Group by
56
- * @cn 分组
63
+ * @en Groups options by returning group name for each item. Parameters: item (current data item to categorize), index (item's position in array), data (complete data array for context)
64
+ * @cn 通过返回分组名称对选项进行分组。参数:item(当前要分类的数据项)、index(数据项在数组中的索引位置)、data(完整的数据数组,提供上下文信息)
65
+ * @when 需要将选项按类别分组显示时使用,如按部门、类型或首字母等条件组织选项
57
66
  */
58
67
  groupBy?: (item: DataItem, index?: number, data?: DataItem[]) => string;
59
68
  filterSameChange?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-select.type.d.ts","sourceRoot":"","sources":["use-select.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,eAAe,CAAC,QAAQ,EAAE,KAAK;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,QAAQ,CAAC;IAE7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC;IAEnD;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI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,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,QAAQ,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;IAEvF;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE3F;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC;IAErC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAEtE;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,MAAM,CAAC;IACxE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACtC"}
@@ -11,7 +11,8 @@ interface UseTableVirtualProps {
11
11
  isRtl?: boolean;
12
12
  columns: TableFormatColumn<any>[];
13
13
  colgroup: (number | string | undefined)[];
14
- theadAndTfootHeight: number;
14
+ theadHeight: number;
15
+ tfootHeight: number;
15
16
  }
16
17
  declare const useTableVirtual: (props: UseTableVirtualProps) => {
17
18
  scrollHeight: number;
@@ -29,6 +30,10 @@ declare const useTableVirtual: (props: UseTableVirtualProps) => {
29
30
  scrollToIndex: (index: number, callback?: () => void) => void;
30
31
  scrollColumnByLeft: (targetLeft: number) => void;
31
32
  scrollColumnIntoView: (colKey: string | number) => void;
33
+ rowSpanInfo: {
34
+ rowSpanIndexArray: number[];
35
+ maxRowSpan: number;
36
+ } | null;
32
37
  };
33
38
  export default useTableVirtual;
34
39
  //# sourceMappingURL=use-table-virtual.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnGuB,MAAM,UAAU,MAAM;2BAsIrB,MAAM,aAAa,MAAM,IAAI;qCAoBnB,MAAM;mCAUR,MAAM,GAAG,MAAM;CA0GnE,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAnGuB,MAAM,UAAU,MAAM;2BAsIrB,MAAM,aAAa,MAAM,IAAI;qCAoBnB,MAAM;mCAUR,MAAM,GAAG,MAAM;;;;;CA2GnE,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -129,7 +129,7 @@ var useTableVirtual = function useTableVirtual(props) {
129
129
  for (var i = 0; i <= index; i++) {
130
130
  sum += context.cachedHeight[i] || props.rowHeight;
131
131
  }
132
- return sum + props.theadAndTfootHeight;
132
+ return sum + props.theadHeight + props.tfootHeight;
133
133
  };
134
134
  var setRowHeight = (0, _usePersistFn.usePersistFn)(function (index, height) {
135
135
  if (props.disabled) return;
@@ -272,7 +272,7 @@ var useTableVirtual = function useTableVirtual(props) {
272
272
  callback();
273
273
  }
274
274
  };
275
- props.scrollRef.current.scrollTop = beforeHeight;
275
+ props.scrollRef.current.scrollTop = beforeHeight - props.theadHeight;
276
276
  }
277
277
  });
278
278
  var scrollColumnByLeft = (0, _usePersistFn.usePersistFn)(function (targetLeft) {
@@ -349,7 +349,7 @@ var useTableVirtual = function useTableVirtual(props) {
349
349
  (0, _react.useEffect)(function () {
350
350
  if (props.disabled) return;
351
351
  setHeight(getContentHeight(props.data.length - 1));
352
- }, [props.data.length, props.theadAndTfootHeight]);
352
+ }, [props.data.length, props.theadHeight, props.tfootHeight]);
353
353
  (0, _react.useEffect)(function () {
354
354
  if (props.disabled) return;
355
355
  if (context.heightCallback) {
@@ -381,7 +381,8 @@ var useTableVirtual = function useTableVirtual(props) {
381
381
  setRowHeight: setRowHeight,
382
382
  scrollToIndex: scrollToIndex,
383
383
  scrollColumnByLeft: scrollColumnByLeft,
384
- scrollColumnIntoView: scrollColumnIntoView
384
+ scrollColumnIntoView: scrollColumnIntoView,
385
+ rowSpanInfo: rowSpanInfo
385
386
  };
386
387
  };
387
388
  var _default = exports.default = useTableVirtual;