cnhis-design-vue 3.1.16-beta.1 → 3.1.16-beta.10

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 (104) hide show
  1. package/es/packages/big-table/index.d.ts +652 -430
  2. package/es/packages/big-table/src/BigTable.vue.d.ts +655 -457
  3. package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +106 -112
  4. package/es/packages/big-table/src/bigTableProps.d.ts +4 -0
  5. package/es/packages/big-table/src/bigTableProps.js +2 -1
  6. package/es/packages/big-table/src/bigTableState.d.ts +2 -0
  7. package/es/packages/big-table/src/bigTableState.js +3 -1
  8. package/es/packages/big-table/src/components/edit-form/edit-time.js +1 -1
  9. package/es/packages/big-table/src/hooks/index.d.ts +9 -0
  10. package/es/packages/big-table/src/hooks/index.js +9 -0
  11. package/es/packages/big-table/src/hooks/useAnchor.d.ts +7 -0
  12. package/es/packages/big-table/src/hooks/useAnchor.js +49 -0
  13. package/es/packages/big-table/src/hooks/useColumnConfigAdaptor.js +24 -8
  14. package/es/packages/big-table/src/hooks/useEdit.js +1 -1
  15. package/es/packages/big-table/src/hooks/useEvent.d.ts +1 -1
  16. package/es/packages/big-table/src/hooks/useEvent.js +3 -2
  17. package/es/packages/big-table/style/index.css +1 -2
  18. package/es/packages/button-print/index.d.ts +2 -2
  19. package/es/packages/button-print/src/ButtonPrint.vue.d.ts +2 -2
  20. package/es/packages/button-print/src/ButtonPrint.vue_vue_type_script_setup_true_lang.js +2 -1
  21. package/es/packages/button-print/src/components/IdentityVerification.vue.d.ts +2 -2
  22. package/es/packages/drag-layout/index.d.ts +2 -2
  23. package/es/packages/drag-layout/src/DragLayout.vue.d.ts +2 -2
  24. package/es/packages/fabric-chart/src/FabricChart.js +2 -1
  25. package/es/packages/fabric-chart/src/hooks/constant.js +4 -4
  26. package/es/packages/fabric-chart/src/hooks/useCenter.js +20 -23
  27. package/es/packages/fabric-chart/src/hooks/useDraw.js +11 -4
  28. package/es/packages/fabric-chart/src/hooks/useEvent.js +11 -3
  29. package/es/packages/fabric-chart/src/hooks/useLeft.js +8 -4
  30. package/es/packages/fabric-chart/src/hooks/useTop.js +5 -8
  31. package/es/packages/field-set/index.d.ts +1 -1
  32. package/es/packages/field-set/src/FieldSet.vue.d.ts +1 -1
  33. package/es/packages/form-config/index.d.ts +110 -3367
  34. package/es/packages/form-config/src/FormConfig.js +42 -34
  35. package/es/packages/form-config/src/FormConfig.vue.d.ts +147 -3404
  36. package/es/packages/form-config/src/components/FormConfigCreator.js +13 -11
  37. package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +23 -22
  38. package/es/packages/form-config/src/components/FormConfigEdit.js +2 -2
  39. package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +75 -49
  40. package/es/packages/form-config/src/constants/index.d.ts +58 -24
  41. package/es/packages/form-config/src/constants/index.js +52 -23
  42. package/es/packages/form-config/src/hooks/index.d.ts +1 -0
  43. package/es/packages/form-config/src/hooks/index.js +1 -0
  44. package/es/packages/form-config/src/hooks/useConfigurationField.d.ts +2 -1
  45. package/es/packages/form-config/src/hooks/useConfigurationField.js +29 -80
  46. package/es/packages/form-config/src/hooks/usePresetRenderer.d.ts +2 -3
  47. package/es/packages/form-config/src/hooks/usePresetRenderer.js +16 -19
  48. package/es/packages/form-config/src/hooks/useSortable.js +1 -1
  49. package/es/packages/form-config/src/types/index.d.ts +22 -4
  50. package/es/packages/form-config/src/utils/index.d.ts +2 -0
  51. package/es/packages/form-config/src/utils/index.js +15 -0
  52. package/es/packages/form-config/style/index.css +26 -2
  53. package/es/packages/form-render/index.d.ts +13 -15
  54. package/es/packages/form-render/src/FormRender.js +10 -7
  55. package/es/packages/form-render/src/FormRender.vue.d.ts +14 -16
  56. package/es/packages/form-render/src/components/renderer/cascader.d.ts +2 -14
  57. package/es/packages/form-render/src/components/renderer/cascader.js +3 -3
  58. package/es/packages/form-render/src/components/renderer/checkbox.js +1 -1
  59. package/es/packages/form-render/src/components/renderer/combination/index.js +2 -1
  60. package/es/packages/form-render/src/components/renderer/complex.js +1 -1
  61. package/es/packages/form-render/src/components/renderer/date.d.ts +20 -4
  62. package/es/packages/form-render/src/components/renderer/date.js +36 -20
  63. package/es/packages/form-render/src/components/renderer/input.js +2 -1
  64. package/es/packages/form-render/src/components/renderer/inputNumber.js +2 -1
  65. package/es/packages/form-render/src/components/renderer/linebar.js +1 -4
  66. package/es/packages/form-render/src/components/renderer/radio.js +1 -1
  67. package/es/packages/form-render/src/components/renderer/select.d.ts +1 -10
  68. package/es/packages/form-render/src/components/renderer/select.js +26 -17
  69. package/es/packages/form-render/src/components/renderer/slider.d.ts +8 -344
  70. package/es/packages/form-render/src/components/renderer/slider.js +24 -2
  71. package/es/packages/form-render/src/components/renderer/switch.js +1 -1
  72. package/es/packages/form-render/src/components/renderer/textarea.js +1 -1
  73. package/es/packages/form-render/src/hooks/useAnchor.js +7 -4
  74. package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +15 -9
  75. package/es/packages/form-render/src/hooks/useBusinessBinding.js +62 -58
  76. package/es/packages/form-render/src/hooks/useChangeContext.d.ts +4 -2
  77. package/es/packages/form-render/src/hooks/useChangeContext.js +4 -7
  78. package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +17 -7
  79. package/es/packages/form-render/src/hooks/useFormContext.d.ts +2 -1
  80. package/es/packages/form-render/src/hooks/useFormContext.js +2 -2
  81. package/es/packages/form-render/src/hooks/useFormValidator.js +13 -3
  82. package/es/packages/form-render/src/hooks/useInitialData.d.ts +1 -1
  83. package/es/packages/form-render/src/hooks/useInitialData.js +9 -4
  84. package/es/packages/form-render/src/hooks/useTypeNormalize.js +1 -1
  85. package/es/packages/form-render/src/types/fieldItem.d.ts +11 -12
  86. package/es/packages/form-render/src/types/index.d.ts +7 -8
  87. package/es/packages/form-render/src/utils/business.d.ts +12 -0
  88. package/es/packages/form-render/src/utils/business.js +78 -0
  89. package/es/packages/form-render/src/utils/dom.d.ts +6 -0
  90. package/es/packages/form-render/src/utils/dom.js +14 -0
  91. package/es/packages/form-render/src/utils/index.d.ts +6 -26
  92. package/es/packages/form-render/src/utils/index.js +9 -138
  93. package/es/packages/form-render/src/utils/schema.d.ts +16 -0
  94. package/es/packages/form-render/src/utils/schema.js +94 -0
  95. package/es/packages/index.css +27 -4
  96. package/es/packages/scale-view/src/hooks/use-component.d.ts +7 -7
  97. package/es/packages/select-label/index.d.ts +10 -10
  98. package/es/packages/select-label/src/LabelFormContent.vue.d.ts +3 -3
  99. package/es/packages/select-label/src/SelectLabel.vue.d.ts +7 -7
  100. package/es/packages/shortcut-setter/index.d.ts +18 -20
  101. package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +18 -20
  102. package/es/packages/time-line/index.d.ts +2 -2
  103. package/es/packages/time-line/src/TimeLine.vue.d.ts +2 -2
  104. package/package.json +1 -1
@@ -1,347 +1,11 @@
1
1
  export declare const SLIDER: import("vue").DefineComponent<{
2
- readonly to: {
3
- type: import("vue").PropType<string | boolean | HTMLElement>;
4
- default: undefined;
2
+ value: {
3
+ type: (NumberConstructor | StringConstructor)[];
5
4
  };
6
- readonly defaultValue: {
7
- readonly type: import("vue").PropType<number | number[]>;
8
- readonly default: 0;
5
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
6
+ value: {
7
+ type: (NumberConstructor | StringConstructor)[];
9
8
  };
10
- readonly marks: import("vue").PropType<Record<string, string>>;
11
- readonly disabled: {
12
- readonly type: import("vue").PropType<boolean | undefined>;
13
- readonly default: undefined;
14
- };
15
- readonly formatTooltip: import("vue").PropType<(value: number) => string | number>;
16
- readonly min: {
17
- readonly type: NumberConstructor;
18
- readonly default: 0;
19
- };
20
- readonly max: {
21
- readonly type: NumberConstructor;
22
- readonly default: 100;
23
- };
24
- readonly step: {
25
- readonly type: import("vue").PropType<number | "mark">;
26
- readonly default: 1;
27
- };
28
- readonly range: BooleanConstructor;
29
- readonly value: import("vue").PropType<number | number[]>;
30
- readonly placement: import("vue").PropType<import("naive-ui").PopoverPlacement>;
31
- readonly showTooltip: {
32
- readonly type: import("vue").PropType<boolean | undefined>;
33
- readonly default: undefined;
34
- };
35
- readonly tooltip: {
36
- readonly type: BooleanConstructor;
37
- readonly default: true;
38
- };
39
- readonly vertical: BooleanConstructor;
40
- readonly reverse: BooleanConstructor;
41
- readonly 'onUpdate:value': import("vue").PropType<import("naive-ui/es/_utils").MaybeArray<(value: number & number[]) => void>>;
42
- readonly onUpdateValue: import("vue").PropType<import("naive-ui/es/_utils").MaybeArray<(value: number & number[]) => void>>;
43
- readonly theme: import("vue").PropType<import("naive-ui/es/_mixins").Theme<"Slider", {
44
- fontSize: string;
45
- railColor: string;
46
- railColorHover: string;
47
- fillColor: string;
48
- fillColorHover: string;
49
- opacityDisabled: string;
50
- handleColor: string;
51
- dotColor: string;
52
- dotColorModal: string;
53
- dotColorPopover: string;
54
- handleBoxShadow: string;
55
- handleBoxShadowHover: string;
56
- handleBoxShadowActive: string;
57
- handleBoxShadowFocus: string;
58
- indicatorColor: string;
59
- indicatorBoxShadow: string;
60
- indicatorTextColor: string;
61
- indicatorBorderRadius: string;
62
- dotBorder: string;
63
- dotBorderActive: string;
64
- dotBoxShadow: string;
65
- railHeight: string;
66
- railWidthVertical: string;
67
- handleSize: string;
68
- dotHeight: string;
69
- dotWidth: string;
70
- dotBorderRadius: string;
71
- }, any>>;
72
- readonly themeOverrides: import("vue").PropType<import("naive-ui/es/_mixins/use-theme").ExtractThemeOverrides<import("naive-ui/es/_mixins").Theme<"Slider", {
73
- fontSize: string;
74
- railColor: string;
75
- railColorHover: string;
76
- fillColor: string;
77
- fillColorHover: string;
78
- opacityDisabled: string;
79
- handleColor: string;
80
- dotColor: string;
81
- dotColorModal: string;
82
- dotColorPopover: string;
83
- handleBoxShadow: string;
84
- handleBoxShadowHover: string;
85
- handleBoxShadowActive: string;
86
- handleBoxShadowFocus: string;
87
- indicatorColor: string;
88
- indicatorBoxShadow: string;
89
- indicatorTextColor: string;
90
- indicatorBorderRadius: string;
91
- dotBorder: string;
92
- dotBorderActive: string;
93
- dotBoxShadow: string;
94
- railHeight: string;
95
- railWidthVertical: string;
96
- handleSize: string;
97
- dotHeight: string;
98
- dotWidth: string;
99
- dotBorderRadius: string;
100
- }, any>>>;
101
- readonly builtinThemeOverrides: import("vue").PropType<import("naive-ui/es/_mixins/use-theme").ExtractThemeOverrides<import("naive-ui/es/_mixins").Theme<"Slider", {
102
- fontSize: string;
103
- railColor: string;
104
- railColorHover: string;
105
- fillColor: string;
106
- fillColorHover: string;
107
- opacityDisabled: string;
108
- handleColor: string;
109
- dotColor: string;
110
- dotColorModal: string;
111
- dotColorPopover: string;
112
- handleBoxShadow: string;
113
- handleBoxShadowHover: string;
114
- handleBoxShadowActive: string;
115
- handleBoxShadowFocus: string;
116
- indicatorColor: string;
117
- indicatorBoxShadow: string;
118
- indicatorTextColor: string;
119
- indicatorBorderRadius: string;
120
- dotBorder: string;
121
- dotBorderActive: string;
122
- dotBoxShadow: string;
123
- railHeight: string;
124
- railWidthVertical: string;
125
- handleSize: string;
126
- dotHeight: string;
127
- dotWidth: string;
128
- dotBorderRadius: string;
129
- }, any>>>;
130
- }, {
131
- mergedClsPrefix: import("vue").ComputedRef<string>;
132
- namespace: import("vue").ComputedRef<string | undefined>;
133
- uncontrolledValue: import("vue").Ref<number | number[]>;
134
- mergedValue: import("vue").ComputedRef<number | number[]>;
135
- mergedDisabled: import("vue").ComputedRef<boolean>;
136
- mergedPlacement: import("vue").ComputedRef<import("naive-ui").PopoverPlacement>;
137
- isMounted: Readonly<import("vue").Ref<boolean>>;
138
- adjustedTo: import("vue").ComputedRef<string | HTMLElement>;
139
- dotTransitionDisabled: import("vue").Ref<boolean>;
140
- markInfos: import("vue").ComputedRef<{
141
- active: boolean;
142
- label: string;
143
- style: import("vue").CSSProperties;
144
- }[]>;
145
- isShowTooltip: (index: number) => boolean;
146
- shouldKeepTooltipTransition: (index: number) => boolean;
147
- handleRailRef: import("vue").Ref<HTMLElement | null>;
148
- setHandleRefs: (key: number) => (el: any) => void;
149
- setFollowerRefs: (key: number) => (el: any) => void;
150
- fillStyle: import("vue").ComputedRef<{
151
- [x: string]: string;
152
- height: string;
153
- width?: undefined;
154
- } | {
155
- [x: string]: string;
156
- width: string;
157
- height?: undefined;
158
- } | undefined>;
159
- getHandleStyle: (value: number, index: number) => Record<string, any>;
160
- activeIndex: import("vue").Ref<number>;
161
- arrifiedValues: import("vue").ComputedRef<number[]>;
162
- followerEnabledIndexSet: import("vue").Ref<Set<number>>;
163
- handleRailMouseDown: (event: MouseEvent | TouchEvent) => void;
164
- handleHandleFocus: (index: number) => void;
165
- handleHandleBlur: (index: number) => void;
166
- handleHandleMouseEnter: (index: number) => void;
167
- handleHandleMouseLeave: (index: number) => void;
168
- handleRailKeyDown: (e: KeyboardEvent) => void;
169
- indicatorCssVars: import("vue").ComputedRef<{
170
- '--n-font-size': string;
171
- '--n-indicator-border-radius': string;
172
- '--n-indicator-box-shadow': string;
173
- '--n-indicator-color': string;
174
- '--n-indicator-text-color': string;
175
- }> | undefined;
176
- indicatorThemeClass: import("vue").Ref<string> | undefined;
177
- indicatorOnRender: (() => void) | undefined;
178
- cssVars: import("vue").ComputedRef<{
179
- '--n-bezier': string;
180
- '--n-dot-border': string;
181
- '--n-dot-border-active': string;
182
- '--n-dot-border-radius': string;
183
- '--n-dot-box-shadow': string;
184
- '--n-dot-color': string;
185
- '--n-dot-color-modal': string;
186
- '--n-dot-color-popover': string;
187
- '--n-dot-height': string;
188
- '--n-dot-width': string;
189
- '--n-fill-color': string;
190
- '--n-fill-color-hover': string;
191
- '--n-font-size': string;
192
- '--n-handle-box-shadow': string;
193
- '--n-handle-box-shadow-active': string;
194
- '--n-handle-box-shadow-focus': string;
195
- '--n-handle-box-shadow-hover': string;
196
- '--n-handle-color': string;
197
- '--n-handle-size': string;
198
- '--n-opacity-disabled': string;
199
- '--n-rail-color': string;
200
- '--n-rail-color-hover': string;
201
- '--n-rail-height': string;
202
- '--n-rail-width-vertical': string;
203
- }> | undefined;
204
- themeClass: import("vue").Ref<string> | undefined;
205
- onRender: (() => void) | undefined;
206
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
207
- readonly to: {
208
- type: import("vue").PropType<string | boolean | HTMLElement>;
209
- default: undefined;
210
- };
211
- readonly defaultValue: {
212
- readonly type: import("vue").PropType<number | number[]>;
213
- readonly default: 0;
214
- };
215
- readonly marks: import("vue").PropType<Record<string, string>>;
216
- readonly disabled: {
217
- readonly type: import("vue").PropType<boolean | undefined>;
218
- readonly default: undefined;
219
- };
220
- readonly formatTooltip: import("vue").PropType<(value: number) => string | number>;
221
- readonly min: {
222
- readonly type: NumberConstructor;
223
- readonly default: 0;
224
- };
225
- readonly max: {
226
- readonly type: NumberConstructor;
227
- readonly default: 100;
228
- };
229
- readonly step: {
230
- readonly type: import("vue").PropType<number | "mark">;
231
- readonly default: 1;
232
- };
233
- readonly range: BooleanConstructor;
234
- readonly value: import("vue").PropType<number | number[]>;
235
- readonly placement: import("vue").PropType<import("naive-ui").PopoverPlacement>;
236
- readonly showTooltip: {
237
- readonly type: import("vue").PropType<boolean | undefined>;
238
- readonly default: undefined;
239
- };
240
- readonly tooltip: {
241
- readonly type: BooleanConstructor;
242
- readonly default: true;
243
- };
244
- readonly vertical: BooleanConstructor;
245
- readonly reverse: BooleanConstructor;
246
- readonly 'onUpdate:value': import("vue").PropType<import("naive-ui/es/_utils").MaybeArray<(value: number & number[]) => void>>;
247
- readonly onUpdateValue: import("vue").PropType<import("naive-ui/es/_utils").MaybeArray<(value: number & number[]) => void>>;
248
- readonly theme: import("vue").PropType<import("naive-ui/es/_mixins").Theme<"Slider", {
249
- fontSize: string;
250
- railColor: string;
251
- railColorHover: string;
252
- fillColor: string;
253
- fillColorHover: string;
254
- opacityDisabled: string;
255
- handleColor: string;
256
- dotColor: string;
257
- dotColorModal: string;
258
- dotColorPopover: string;
259
- handleBoxShadow: string;
260
- handleBoxShadowHover: string;
261
- handleBoxShadowActive: string;
262
- handleBoxShadowFocus: string;
263
- indicatorColor: string;
264
- indicatorBoxShadow: string;
265
- indicatorTextColor: string;
266
- indicatorBorderRadius: string;
267
- dotBorder: string;
268
- dotBorderActive: string;
269
- dotBoxShadow: string;
270
- railHeight: string;
271
- railWidthVertical: string;
272
- handleSize: string;
273
- dotHeight: string;
274
- dotWidth: string;
275
- dotBorderRadius: string;
276
- }, any>>;
277
- readonly themeOverrides: import("vue").PropType<import("naive-ui/es/_mixins/use-theme").ExtractThemeOverrides<import("naive-ui/es/_mixins").Theme<"Slider", {
278
- fontSize: string;
279
- railColor: string;
280
- railColorHover: string;
281
- fillColor: string;
282
- fillColorHover: string;
283
- opacityDisabled: string;
284
- handleColor: string;
285
- dotColor: string;
286
- dotColorModal: string;
287
- dotColorPopover: string;
288
- handleBoxShadow: string;
289
- handleBoxShadowHover: string;
290
- handleBoxShadowActive: string;
291
- handleBoxShadowFocus: string;
292
- indicatorColor: string;
293
- indicatorBoxShadow: string;
294
- indicatorTextColor: string;
295
- indicatorBorderRadius: string;
296
- dotBorder: string;
297
- dotBorderActive: string;
298
- dotBoxShadow: string;
299
- railHeight: string;
300
- railWidthVertical: string;
301
- handleSize: string;
302
- dotHeight: string;
303
- dotWidth: string;
304
- dotBorderRadius: string;
305
- }, any>>>;
306
- readonly builtinThemeOverrides: import("vue").PropType<import("naive-ui/es/_mixins/use-theme").ExtractThemeOverrides<import("naive-ui/es/_mixins").Theme<"Slider", {
307
- fontSize: string;
308
- railColor: string;
309
- railColorHover: string;
310
- fillColor: string;
311
- fillColorHover: string;
312
- opacityDisabled: string;
313
- handleColor: string;
314
- dotColor: string;
315
- dotColorModal: string;
316
- dotColorPopover: string;
317
- handleBoxShadow: string;
318
- handleBoxShadowHover: string;
319
- handleBoxShadowActive: string;
320
- handleBoxShadowFocus: string;
321
- indicatorColor: string;
322
- indicatorBoxShadow: string;
323
- indicatorTextColor: string;
324
- indicatorBorderRadius: string;
325
- dotBorder: string;
326
- dotBorderActive: string;
327
- dotBoxShadow: string;
328
- railHeight: string;
329
- railWidthVertical: string;
330
- handleSize: string;
331
- dotHeight: string;
332
- dotWidth: string;
333
- dotBorderRadius: string;
334
- }, any>>>;
335
- }>>, {
336
- readonly range: boolean;
337
- readonly reverse: boolean;
338
- readonly vertical: boolean;
339
- readonly tooltip: boolean;
340
- readonly disabled: boolean | undefined;
341
- readonly step: number | "mark";
342
- readonly max: number;
343
- readonly min: number;
344
- readonly to: string | boolean | HTMLElement;
345
- readonly defaultValue: number | number[];
346
- readonly showTooltip: boolean | undefined;
347
- }>;
9
+ }>> & {
10
+ "onUpdate:value"?: ((...args: any[]) => any) | undefined;
11
+ }, {}>;
@@ -1,8 +1,30 @@
1
+ import { defineComponent, computed, createVNode } from 'vue';
1
2
  import { connect, mapProps } from '@formily/vue';
2
3
  import { NSlider } from 'naive-ui';
3
- import { assignUpdateValue } from '../../utils/index.js';
4
+ import { parseNumberFromMaybeString } from '../../utils/index.js';
5
+ import { assignUpdateValue } from '../../utils/schema.js';
4
6
 
5
- const SLIDER = connect(NSlider, mapProps((props, field) => {
7
+ const script = defineComponent({
8
+ props: {
9
+ value: {
10
+ type: [Number, String]
11
+ }
12
+ },
13
+ emits: ["update:value"],
14
+ setup(props, {
15
+ emit
16
+ }) {
17
+ const valueRef = computed({
18
+ get: () => parseNumberFromMaybeString(props.value),
19
+ set: (v) => emit("update:value", v)
20
+ });
21
+ return () => createVNode(NSlider, {
22
+ "value": valueRef.value,
23
+ "onUpdate:value": ($event) => valueRef.value = $event
24
+ }, null);
25
+ }
26
+ });
27
+ const SLIDER = connect(script, mapProps((props, field) => {
6
28
  const _props = assignUpdateValue(props, field);
7
29
  if (Array.isArray(_props.option)) {
8
30
  _props.marks = _props.option.reduce((fin, option) => {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, computed, createVNode, createTextVNode } from 'vue';
2
2
  import { NSwitch } from 'naive-ui';
3
- import { assignUpdateValue } from '../../utils/index.js';
4
3
  import { connect, mapProps } from '@formily/vue';
4
+ import { assignUpdateValue } from '../../utils/schema.js';
5
5
 
6
6
  const script = defineComponent({
7
7
  name: "FormSwitch",
@@ -1,6 +1,6 @@
1
- import { assignUpdateValue } from '../../utils/index.js';
2
1
  import { connect, mapProps } from '@formily/vue';
3
2
  import { NInput } from 'naive-ui';
3
+ import { assignUpdateValue } from '../../utils/schema.js';
4
4
 
5
5
  const TEXTAREA = connect(NInput, mapProps((props, field) => {
6
6
  const _props = assignUpdateValue(props, field);
@@ -37,7 +37,7 @@ function useAnchor(props, scrollbarRef, collector) {
37
37
  doAnimation(scrollbarRef.value.scrollTop, targetAnchor.offsetTop, 300, (top) => {
38
38
  var _a;
39
39
  (_a = scrollbarRef.value) == null ? void 0 : _a.scrollTo({ top });
40
- }, "easeInSine", resolve);
40
+ }, "easeInSine", () => setTimeout(resolve, 300));
41
41
  });
42
42
  } finally {
43
43
  scrollLock = false;
@@ -48,11 +48,14 @@ function useAnchor(props, scrollbarRef, collector) {
48
48
  if (scrollLock || !scrollbarRef.value)
49
49
  return;
50
50
  const { scrollTop, clientHeight } = scrollbarRef.value;
51
- const result = anchorIdList.value.find((anchor) => {
52
- const node = scrollbarRef.value.querySelector(`#${createLinebarId(anchor.name)}`);
51
+ const result = anchorIdList.value.find((anchor, idx, arr) => {
52
+ const nextAnchor = arr[idx + 1];
53
+ if (!nextAnchor)
54
+ return true;
55
+ const node = scrollbarRef.value.querySelector(`#${createLinebarId(nextAnchor.name)}`);
53
56
  if (!node)
54
57
  return;
55
- return node.offsetTop >= scrollTop || node.offsetTop < scrollTop && node.clientHeight + node.offsetTop > scrollTop + clientHeight;
58
+ return node.offsetTop > scrollTop + clientHeight / 2;
56
59
  }) || anchorIdList.value[anchorIdList.value.length - 1];
57
60
  __currentAnchor.value = (_a = result == null ? void 0 : result.name) != null ? _a : "";
58
61
  }, 300);
@@ -1,20 +1,26 @@
1
1
  import { Form } from '@formily/core';
2
- import { FormBusinessFilter } from '../../../../../es/packages/form-render';
2
+ import { FormBusinessFormatter } from '../../../../../es/packages/form-render';
3
3
  import { FIELD_BUSINESS_TYPE } from '../constants';
4
4
  export declare class BusinessCollector {
5
+ private formModel;
6
+ private businessFormatter?;
5
7
  private readonly typeCollector;
6
8
  private readonly fieldNameCollector;
7
- private readonly valueFilter;
8
- constructor(valueFilter?: FormBusinessFilter);
9
+ constructor(formModel: Form, businessFormatter?: FormBusinessFormatter | undefined);
10
+ private formatter;
9
11
  collect(type: FIELD_BUSINESS_TYPE, fieldName: string): void;
10
- getField(type: FIELD_BUSINESS_TYPE): string[];
11
- getType(fieldName: string): FIELD_BUSINESS_TYPE | undefined;
12
- private setAge;
12
+ private getField;
13
+ private getType;
14
+ private getValueByField;
15
+ private getValueByType;
16
+ private setValueByType;
13
17
  private handlerIdCardType;
14
18
  private handlerBirthdayType;
15
- handlerMap: Map<FIELD_BUSINESS_TYPE, (formModel: Form, value: unknown) => void>;
16
- trigger(formModel: Form, fieldName: string, value: unknown): void;
19
+ private handlerAgeType;
20
+ private handlerChangeMap;
21
+ private blurHandlerMap;
22
+ trigger(fieldName: string, triggerType?: 'change' | 'blur'): void;
17
23
  }
18
24
  export declare function useBusinessBinding(): {
19
- create: (valueFilter?: FormBusinessFilter) => BusinessCollector;
25
+ create: (formModel: Form, formatter?: FormBusinessFormatter) => BusinessCollector;
20
26
  };
@@ -1,87 +1,91 @@
1
+ import { isField } from '@formily/core';
1
2
  import { isString } from '@vueuse/core';
2
- import { FIELD_BUSINESS_TYPE, FIELD_AGE_UNIT } from '../constants/index.js';
3
- import { isIdCard, parseIdCard, parseBirthday } from '../utils/index.js';
3
+ import { isFunction, isNumber } from 'lodash-es';
4
+ import { FIELD_BUSINESS_TYPE } from '../constants/index.js';
5
+ import { isIdCard, parseIdCard, parseAge2FromContext, parseBirthday, parseAge2Birthday } from '../utils/business.js';
4
6
 
5
7
  class BusinessCollector {
6
- constructor(valueFilter = ({ value }) => value) {
8
+ constructor(formModel, businessFormatter) {
9
+ this.formModel = formModel;
10
+ this.businessFormatter = businessFormatter;
7
11
  this.typeCollector = /* @__PURE__ */ new Map();
8
12
  this.fieldNameCollector = /* @__PURE__ */ new Map();
9
- this.handlerMap = /* @__PURE__ */ new Map([
13
+ this.handlerChangeMap = /* @__PURE__ */ new Map([
10
14
  [FIELD_BUSINESS_TYPE.ID_CARD, this.handlerIdCardType.bind(this)],
11
- [FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)]
15
+ [FIELD_BUSINESS_TYPE.AGE_UNIT, this.handlerAgeType.bind(this)]
12
16
  ]);
13
- this.valueFilter = valueFilter;
17
+ this.blurHandlerMap = /* @__PURE__ */ new Map([
18
+ [FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)],
19
+ [FIELD_BUSINESS_TYPE.AGE, this.handlerAgeType.bind(this)]
20
+ ]);
21
+ }
22
+ formatter(...args) {
23
+ return isFunction(this.businessFormatter) ? this.businessFormatter(...args) : args[0].value;
14
24
  }
15
25
  collect(type, fieldName) {
16
- const set = this.typeCollector.get(type) || /* @__PURE__ */ new Set();
17
- set.add(fieldName);
18
- this.typeCollector.set(type, set);
26
+ this.typeCollector.set(type, fieldName);
19
27
  this.fieldNameCollector.set(fieldName, type);
20
28
  }
21
29
  getField(type) {
22
- return [...this.typeCollector.get(type) || /* @__PURE__ */ new Set()];
30
+ return this.typeCollector.get(type);
23
31
  }
24
32
  getType(fieldName) {
25
33
  return this.fieldNameCollector.get(fieldName);
26
34
  }
27
- setAge(formModel, context) {
28
- const value = context.day < 30 ? { ageUnit: FIELD_AGE_UNIT.DAY, age: context.day } : context.day < 365 ? { ageUnit: FIELD_AGE_UNIT.MONTH, age: context.month } : { ageUnit: FIELD_AGE_UNIT.YEAR, age: context.year };
29
- const ageUnitFields = this.getField(FIELD_BUSINESS_TYPE.AGE_UNIT);
30
- ageUnitFields.forEach((field) => {
31
- formModel.setFieldState(field, (state) => {
32
- state.value = this.valueFilter({
33
- fieldKey: field,
34
- value: value.ageUnit,
35
- context,
36
- type: FIELD_BUSINESS_TYPE.AGE_UNIT
37
- });
38
- });
39
- });
40
- const ageFields = this.getField(FIELD_BUSINESS_TYPE.AGE);
41
- ageFields.forEach((field) => {
42
- formModel.setFieldState(field, (state) => {
43
- state.value = this.valueFilter({
44
- fieldKey: field,
45
- value: ageUnitFields.length ? value.age : context.year,
46
- context,
47
- type: FIELD_BUSINESS_TYPE.AGE
48
- });
49
- });
35
+ getValueByField(fieldName) {
36
+ const _field = this.formModel.query(fieldName).take();
37
+ return isField(_field) ? _field.value : null;
38
+ }
39
+ getValueByType(type) {
40
+ const field = this.getField(type);
41
+ return field ? this.getValueByField(field) : null;
42
+ }
43
+ setValueByType(type, value, force = true) {
44
+ const field = this.getField(type);
45
+ field && this.formModel.setFieldState(field, (state) => {
46
+ if (!force && state.value)
47
+ return;
48
+ state.value = this.formatter({ value, type, fieldKey: field });
50
49
  });
51
50
  }
52
- handlerIdCardType(formModel, value) {
53
- if (!value || !isString(value) || !isIdCard(value))
51
+ handlerIdCardType() {
52
+ const idCard = this.getValueByType(FIELD_BUSINESS_TYPE.ID_CARD);
53
+ if (!idCard || !isString(idCard) || !isIdCard(idCard))
54
54
  return;
55
- const info = parseIdCard(value);
56
- this.setAge(formModel, info);
57
- const sexFields = this.getField(FIELD_BUSINESS_TYPE.SEX);
58
- sexFields.forEach((field) => {
59
- formModel.setFieldState(field, (state) => {
60
- state.value = this.valueFilter({ fieldKey: field, value: info.sex, type: FIELD_BUSINESS_TYPE.SEX });
61
- });
62
- });
63
- const birthdayFields = this.getField(FIELD_BUSINESS_TYPE.BIRTHDAY);
64
- birthdayFields.forEach((field) => {
65
- formModel.setFieldState(field, (state) => {
66
- state.value = this.valueFilter({ fieldKey: field, value: info.birthday, type: FIELD_BUSINESS_TYPE.BIRTHDAY });
67
- });
68
- });
55
+ const info = parseIdCard(idCard);
56
+ const { age, ageUnit } = parseAge2FromContext(info);
57
+ this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
58
+ this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
59
+ this.setValueByType(FIELD_BUSINESS_TYPE.SEX, info.sex);
60
+ this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, info.birthday);
69
61
  }
70
- handlerBirthdayType(formModel, value) {
71
- if (!isString(value))
62
+ handlerBirthdayType() {
63
+ const birthday = this.getValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY);
64
+ if (!isString(birthday))
72
65
  return;
73
- this.setAge(formModel, parseBirthday(value));
66
+ const { age, ageUnit } = parseAge2FromContext(parseBirthday(birthday));
67
+ this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
68
+ this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
74
69
  }
75
- trigger(formModel, fieldName, value) {
76
- const type = this.getType(fieldName);
77
- if (!type || !this.handlerMap.has(type))
70
+ handlerAgeType() {
71
+ const age = this.getValueByType(FIELD_BUSINESS_TYPE.AGE);
72
+ const ageUnit = this.getValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT);
73
+ if (!isString(age) && !isNumber(age) || age === "")
74
+ return;
75
+ if (!isString(ageUnit) || ageUnit === "")
78
76
  return;
79
- this.handlerMap.get(type)(formModel, value);
77
+ this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit), false);
78
+ }
79
+ trigger(fieldName, triggerType = "change") {
80
+ var _a;
81
+ const type = this.getType(fieldName);
82
+ const handler = triggerType === "change" ? this.handlerChangeMap : triggerType === "blur" ? this.blurHandlerMap : null;
83
+ type && ((_a = handler == null ? void 0 : handler.get(type)) == null ? void 0 : _a());
80
84
  }
81
85
  }
82
86
  function useBusinessBinding() {
83
- function create(valueFilter) {
84
- return new BusinessCollector(valueFilter);
87
+ function create(formModel, formatter) {
88
+ return new BusinessCollector(formModel, formatter);
85
89
  }
86
90
  return { create };
87
91
  }
@@ -1,10 +1,12 @@
1
1
  import { FormChangeContext } from '../types';
2
2
  export declare class ContextCollector {
3
3
  private readonly contextMap;
4
- setContext<T extends keyof FormChangeContext>(key: string, prop: T, value: FormChangeContext[T]): void;
4
+ setContext(key: string, value: () => Promise<FormChangeContext> | FormChangeContext): void;
5
5
  getContext(key: string): Partial<{
6
6
  currentOption: import("../../../../src/types").AnyObject;
7
- }>;
7
+ }> | Promise<Partial<{
8
+ currentOption: import("../../../../src/types").AnyObject;
9
+ }>> | undefined;
8
10
  }
9
11
  export declare function useChangeContext(): {
10
12
  create: () => ContextCollector;
@@ -2,15 +2,12 @@ class ContextCollector {
2
2
  constructor() {
3
3
  this.contextMap = /* @__PURE__ */ new Map();
4
4
  }
5
- setContext(key, prop, value) {
6
- const context = this.contextMap.get(key) || {};
7
- context[prop] = value;
8
- this.contextMap.set(key, context);
5
+ setContext(key, value) {
6
+ this.contextMap.set(key, value);
9
7
  }
10
8
  getContext(key) {
11
- const result = this.contextMap.get(key) || {};
12
- this.contextMap.delete(key);
13
- return result;
9
+ var _a;
10
+ return (_a = this.contextMap.get(key)) == null ? void 0 : _a();
14
11
  }
15
12
  }
16
13
  function useChangeContext() {