@movk/nuxt 1.8.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.en.md +16 -6
  2. package/README.md +16 -6
  3. package/dist/module.d.mts +6 -0
  4. package/dist/module.json +3 -3
  5. package/dist/module.mjs +21 -24
  6. package/dist/runtime/components/AutoForm.d.vue.ts +15 -1
  7. package/dist/runtime/components/AutoForm.vue +48 -50
  8. package/dist/runtime/components/AutoForm.vue.d.ts +15 -1
  9. package/dist/runtime/components/DataTable.d.vue.ts +4 -2
  10. package/dist/runtime/components/DataTable.vue +166 -174
  11. package/dist/runtime/components/DataTable.vue.d.ts +4 -2
  12. package/dist/runtime/components/DatePicker.d.vue.ts +6 -5
  13. package/dist/runtime/components/DatePicker.vue +96 -43
  14. package/dist/runtime/components/DatePicker.vue.d.ts +6 -5
  15. package/dist/runtime/components/MessageBox.d.vue.ts +1 -5
  16. package/dist/runtime/components/MessageBox.vue +9 -7
  17. package/dist/runtime/components/MessageBox.vue.d.ts +1 -5
  18. package/dist/runtime/components/SearchForm.d.vue.ts +12 -4
  19. package/dist/runtime/components/SearchForm.vue +130 -120
  20. package/dist/runtime/components/SearchForm.vue.d.ts +12 -4
  21. package/dist/runtime/components/Tree.d.vue.ts +3 -1
  22. package/dist/runtime/components/Tree.vue +102 -140
  23. package/dist/runtime/components/Tree.vue.d.ts +3 -1
  24. package/dist/runtime/components/theme-picker/ThemePicker.vue +5 -3
  25. package/dist/runtime/components/theme-picker/ThemePickerButton.vue +15 -6
  26. package/dist/runtime/composables/index.d.ts +1 -0
  27. package/dist/runtime/composables/index.js +1 -0
  28. package/dist/runtime/composables/useApiFetch.d.ts +7 -7
  29. package/dist/runtime/composables/useApiFetch.js +5 -23
  30. package/dist/runtime/composables/useAutoForm.js +2 -2
  31. package/dist/runtime/composables/useClientApiFetch.d.ts +5 -5
  32. package/dist/runtime/composables/useDateFormatter.d.ts +32 -34
  33. package/dist/runtime/composables/useDateFormatter.js +75 -232
  34. package/dist/runtime/composables/useDownloadWithProgress.d.ts +11 -8
  35. package/dist/runtime/composables/useDownloadWithProgress.js +49 -132
  36. package/dist/runtime/composables/useMessageBox.js +3 -2
  37. package/dist/runtime/composables/useMovkLocale.d.ts +16 -0
  38. package/dist/runtime/composables/useMovkLocale.js +20 -0
  39. package/dist/runtime/composables/useTheme.js +8 -18
  40. package/dist/runtime/composables/useUploadWithProgress.d.ts +9 -6
  41. package/dist/runtime/composables/useUploadWithProgress.js +50 -84
  42. package/dist/runtime/domains/ai/chat-transport.js +1 -0
  43. package/dist/runtime/domains/api/adapters/xhr.d.ts +17 -0
  44. package/dist/runtime/domains/api/adapters/xhr.js +55 -0
  45. package/dist/runtime/domains/api/auth.d.ts +4 -1
  46. package/dist/runtime/domains/api/auth.js +9 -13
  47. package/dist/runtime/domains/api/client.d.ts +13 -0
  48. package/dist/runtime/domains/api/client.js +35 -0
  49. package/dist/runtime/domains/api/download.d.ts +10 -0
  50. package/dist/runtime/domains/api/download.js +28 -0
  51. package/dist/runtime/domains/api/errors.d.ts +20 -2
  52. package/dist/runtime/domains/api/errors.js +61 -8
  53. package/dist/runtime/domains/api/fetch-key.d.ts +2 -2
  54. package/dist/runtime/domains/api/fetch-key.js +4 -4
  55. package/dist/runtime/domains/api/interceptors/request.d.ts +2 -6
  56. package/dist/runtime/domains/api/interceptors/request.js +3 -2
  57. package/dist/runtime/domains/api/interceptors/response.d.ts +8 -12
  58. package/dist/runtime/domains/api/interceptors/response.js +34 -20
  59. package/dist/runtime/domains/api/report.d.ts +25 -0
  60. package/dist/runtime/domains/api/report.js +51 -0
  61. package/dist/runtime/domains/api/response.d.ts +29 -4
  62. package/dist/runtime/domains/api/response.js +27 -6
  63. package/dist/runtime/domains/api/session.d.ts +12 -0
  64. package/dist/runtime/domains/api/session.js +9 -0
  65. package/dist/runtime/domains/api/stream.d.ts +2 -1
  66. package/dist/runtime/domains/api/stream.js +2 -1
  67. package/dist/runtime/domains/api/toast.d.ts +6 -3
  68. package/dist/runtime/domains/api/toast.js +7 -7
  69. package/dist/runtime/domains/auto-form/actions.d.ts +2 -1
  70. package/dist/runtime/domains/auto-form/actions.js +6 -4
  71. package/dist/runtime/domains/auto-form/array-ops.d.ts +3 -0
  72. package/dist/runtime/domains/auto-form/array-ops.js +9 -0
  73. package/dist/runtime/domains/auto-form/async-items.d.ts +10 -0
  74. package/dist/runtime/domains/auto-form/async-items.js +42 -0
  75. package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +0 -4
  76. package/dist/runtime/domains/auto-form/components/Array.vue +81 -73
  77. package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +0 -4
  78. package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +0 -2
  79. package/dist/runtime/domains/auto-form/components/Children.vue +0 -5
  80. package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +0 -2
  81. package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +0 -2
  82. package/dist/runtime/domains/auto-form/components/Field.vue +9 -2
  83. package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +0 -2
  84. package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +0 -2
  85. package/dist/runtime/domains/auto-form/components/Layout.vue +3 -6
  86. package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +0 -2
  87. package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +0 -2
  88. package/dist/runtime/domains/auto-form/components/Nested.vue +5 -9
  89. package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +0 -2
  90. package/dist/runtime/domains/auto-form/controls.d.ts +5 -572
  91. package/dist/runtime/domains/auto-form/controls.js +7 -20
  92. package/dist/runtime/domains/auto-form/fields.d.ts +21 -4
  93. package/dist/runtime/domains/auto-form/fields.js +52 -40
  94. package/dist/runtime/domains/auto-form/provider.d.ts +15 -6
  95. package/dist/runtime/domains/auto-form/provider.js +24 -10
  96. package/dist/runtime/domains/auto-form/schema.d.ts +9 -4
  97. package/dist/runtime/domains/auto-form/schema.js +91 -50
  98. package/dist/runtime/domains/auto-form/search-query.d.ts +10 -0
  99. package/dist/runtime/domains/auto-form/search-query.js +57 -0
  100. package/dist/runtime/domains/auto-form/useAutoFormCore.d.ts +62 -0
  101. package/dist/runtime/domains/auto-form/useAutoFormCore.js +108 -0
  102. package/dist/runtime/domains/auto-form/useSearchQuerySync.d.ts +11 -0
  103. package/dist/runtime/domains/auto-form/useSearchQuerySync.js +64 -0
  104. package/dist/runtime/domains/data-table/columns/constants.d.ts +2 -0
  105. package/dist/runtime/domains/data-table/columns/constants.js +1 -1
  106. package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +2 -1
  107. package/dist/runtime/domains/data-table/columns/resolve-columns.js +3 -2
  108. package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +7 -2
  109. package/dist/runtime/domains/data-table/columns/resolve-data-column.js +10 -5
  110. package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +14 -8
  111. package/dist/runtime/domains/data-table/components/ColumnSettings.d.vue.ts +20 -0
  112. package/dist/runtime/domains/data-table/components/ColumnSettings.vue +63 -0
  113. package/dist/runtime/domains/data-table/components/ColumnSettings.vue.d.ts +20 -0
  114. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +2 -8
  115. package/dist/runtime/domains/data-table/components/Pagination.vue +34 -36
  116. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +2 -8
  117. package/dist/runtime/domains/data-table/export.d.ts +23 -0
  118. package/dist/runtime/domains/data-table/export.js +43 -0
  119. package/dist/runtime/domains/data-table/load-more.d.ts +8 -0
  120. package/dist/runtime/domains/data-table/load-more.js +14 -0
  121. package/dist/runtime/domains/data-table/pagination.d.ts +29 -0
  122. package/dist/runtime/domains/data-table/pagination.js +42 -0
  123. package/dist/runtime/domains/data-table/persist.d.ts +12 -0
  124. package/dist/runtime/domains/data-table/persist.js +41 -0
  125. package/dist/runtime/domains/data-table/state/keys.d.ts +11 -0
  126. package/dist/runtime/domains/data-table/state/keys.js +44 -0
  127. package/dist/runtime/domains/data-table/state/models.d.ts +5 -0
  128. package/dist/runtime/domains/data-table/state/models.js +38 -0
  129. package/dist/runtime/domains/data-table/tree-layout.d.ts +13 -0
  130. package/dist/runtime/domains/data-table/tree-layout.js +30 -0
  131. package/dist/runtime/domains/theme/theme-color.d.ts +3 -0
  132. package/dist/runtime/domains/theme/theme-color.js +16 -0
  133. package/dist/runtime/domains/theme/theme-fouc.d.ts +5 -0
  134. package/dist/runtime/domains/theme/theme-fouc.js +43 -0
  135. package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +7 -5
  136. package/dist/runtime/domains/tree/components/TreeToolbar.vue +6 -4
  137. package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +7 -5
  138. package/dist/runtime/domains/tree/tree-disabled.d.ts +5 -0
  139. package/dist/runtime/domains/tree/tree-disabled.js +15 -0
  140. package/dist/runtime/domains/tree/tree-lazy.d.ts +8 -0
  141. package/dist/runtime/domains/tree/tree-lazy.js +19 -1
  142. package/dist/runtime/domains/tree/tree-search.d.ts +3 -1
  143. package/dist/runtime/domains/tree/tree-search.js +4 -0
  144. package/dist/runtime/domains/tree/useTreeLazy.d.ts +22 -0
  145. package/dist/runtime/domains/tree/useTreeLazy.js +57 -0
  146. package/dist/runtime/domains/tree/useTreeSearch.d.ts +27 -0
  147. package/dist/runtime/domains/tree/useTreeSearch.js +59 -0
  148. package/dist/runtime/domains/tree/useTreeSelection.d.ts +31 -0
  149. package/dist/runtime/domains/tree/useTreeSelection.js +89 -0
  150. package/dist/runtime/domains/zod/apply.d.ts +23 -0
  151. package/dist/runtime/domains/zod/apply.js +26 -0
  152. package/dist/runtime/domains/zod/error-map.d.ts +13 -0
  153. package/dist/runtime/domains/zod/error-map.js +19 -0
  154. package/dist/runtime/domains/zod/locale-map.d.ts +5 -0
  155. package/dist/runtime/domains/zod/locale-map.js +17 -0
  156. package/dist/runtime/domains/zod/sync.d.ts +12 -0
  157. package/dist/runtime/domains/zod/sync.js +30 -0
  158. package/dist/runtime/locale/en.d.ts +74 -0
  159. package/dist/runtime/locale/en.js +73 -0
  160. package/dist/runtime/locale/index.d.ts +8 -0
  161. package/dist/runtime/locale/index.js +15 -0
  162. package/dist/runtime/locale/zh_cn.d.ts +74 -0
  163. package/dist/runtime/locale/zh_cn.js +73 -0
  164. package/dist/runtime/plugins/api.factory.js +5 -22
  165. package/dist/runtime/plugins/theme.js +4 -42
  166. package/dist/runtime/plugins/zod.d.ts +2 -0
  167. package/dist/runtime/plugins/zod.js +16 -0
  168. package/dist/runtime/types/api/config.d.ts +12 -0
  169. package/dist/runtime/types/api/fetch.d.ts +3 -16
  170. package/dist/runtime/types/api/index.d.ts +1 -1
  171. package/dist/runtime/types/api/response.d.ts +33 -19
  172. package/dist/runtime/types/api/stream.d.ts +2 -3
  173. package/dist/runtime/types/api/transfer.d.ts +3 -7
  174. package/dist/runtime/types/auto-form/base.d.ts +9 -1
  175. package/dist/runtime/types/auto-form/component.d.ts +31 -3
  176. package/dist/runtime/types/auto-form/fields.d.ts +15 -1
  177. package/dist/runtime/types/auto-form/index.d.ts +3 -3
  178. package/dist/runtime/types/auto-form/search-form.d.ts +26 -12
  179. package/dist/runtime/types/auto-form/zod-factory.d.ts +2 -2
  180. package/dist/runtime/types/components/date-picker.d.ts +14 -3
  181. package/dist/runtime/types/components/index.d.ts +1 -6
  182. package/dist/runtime/types/components/message-box.d.ts +5 -18
  183. package/dist/runtime/types/components/tree.d.ts +17 -14
  184. package/dist/runtime/types/data-table/columns.d.ts +6 -14
  185. package/dist/runtime/types/data-table/component.d.ts +42 -1
  186. package/dist/runtime/types/data-table/index.d.ts +1 -1
  187. package/dist/runtime/types/data-table/pagination.d.ts +7 -8
  188. package/dist/runtime/types/index.d.ts +2 -0
  189. package/dist/runtime/types/locale.d.ts +82 -0
  190. package/dist/runtime/types/shared.d.ts +13 -0
  191. package/dist/runtime/types/zod-config.d.ts +38 -0
  192. package/dist/runtime/types/zod.d.ts +9 -1
  193. package/dist/runtime/utils/date/convert.d.ts +29 -0
  194. package/dist/runtime/utils/date/convert.js +93 -0
  195. package/dist/runtime/utils/date/guards.d.ts +10 -0
  196. package/dist/runtime/utils/date/guards.js +18 -0
  197. package/dist/runtime/utils/extend-theme.js +2 -1
  198. package/dist/runtime/utils/form-control.d.ts +0 -12
  199. package/dist/runtime/utils/form-control.js +3 -39
  200. package/dist/runtime/utils/interpolate.d.ts +2 -0
  201. package/dist/runtime/utils/interpolate.js +4 -0
  202. package/dist/runtime/utils/theme-defaults.d.ts +10 -0
  203. package/dist/runtime/utils/theme-defaults.js +9 -0
  204. package/dist/runtime/utils/tree-selection.d.ts +2 -15
  205. package/dist/runtime/utils/tv.d.ts +1 -1
  206. package/dist/runtime/vue/plugins/zod.d.ts +7 -0
  207. package/dist/runtime/vue/plugins/zod.js +12 -0
  208. package/dist/shared/{nuxt.C7xx2FPO.mjs → nuxt.CbmfnBRt.mjs} +92 -236
  209. package/dist/unplugin.d.mts +3 -2
  210. package/dist/unplugin.mjs +22 -22
  211. package/dist/vite.d.mts +1 -0
  212. package/dist/vite.mjs +2 -1
  213. package/package.json +40 -34
  214. package/vue-plugin.d.ts +7 -1
  215. package/dist/runtime/components/ColorChooser.d.vue.ts +0 -36
  216. package/dist/runtime/components/ColorChooser.vue +0 -328
  217. package/dist/runtime/components/ColorChooser.vue.d.ts +0 -36
  218. package/dist/runtime/components/PillGroup.d.vue.ts +0 -33
  219. package/dist/runtime/components/PillGroup.vue +0 -291
  220. package/dist/runtime/components/PillGroup.vue.d.ts +0 -33
  221. package/dist/runtime/components/Popconfirm.d.vue.ts +0 -30
  222. package/dist/runtime/components/Popconfirm.vue +0 -143
  223. package/dist/runtime/components/Popconfirm.vue.d.ts +0 -30
  224. package/dist/runtime/components/SlideVerify.d.vue.ts +0 -41
  225. package/dist/runtime/components/SlideVerify.vue +0 -174
  226. package/dist/runtime/components/SlideVerify.vue.d.ts +0 -41
  227. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +0 -32
  228. package/dist/runtime/components/input/AsPhoneNumberInput.vue +0 -48
  229. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +0 -32
  230. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +0 -32
  231. package/dist/runtime/components/input/WithCharacterLimit.vue +0 -54
  232. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +0 -32
  233. package/dist/runtime/components/input/WithClear.d.vue.ts +0 -33
  234. package/dist/runtime/components/input/WithClear.vue +0 -60
  235. package/dist/runtime/components/input/WithClear.vue.d.ts +0 -33
  236. package/dist/runtime/components/input/WithCopy.d.vue.ts +0 -33
  237. package/dist/runtime/components/input/WithCopy.vue +0 -66
  238. package/dist/runtime/components/input/WithCopy.vue.d.ts +0 -33
  239. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +0 -33
  240. package/dist/runtime/components/input/WithFloatingLabel.vue +0 -75
  241. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +0 -33
  242. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +0 -32
  243. package/dist/runtime/components/input/WithPasswordToggle.vue +0 -61
  244. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +0 -32
  245. package/dist/runtime/domains/api/interceptors/compose.d.ts +0 -24
  246. package/dist/runtime/domains/api/interceptors/compose.js +0 -18
  247. package/dist/runtime/domains/api/interceptors/error.d.ts +0 -13
  248. package/dist/runtime/domains/api/interceptors/error.js +0 -49
  249. package/dist/runtime/domains/api/transfer.d.ts +0 -69
  250. package/dist/runtime/domains/api/transfer.js +0 -82
  251. package/dist/runtime/types/components/color-chooser.d.ts +0 -109
  252. package/dist/runtime/types/components/input/as-phone-number-input.d.ts +0 -17
  253. package/dist/runtime/types/components/input/index.d.ts +0 -6
  254. package/dist/runtime/types/components/input/index.js +0 -0
  255. package/dist/runtime/types/components/input/with-character-limit.d.ts +0 -11
  256. package/dist/runtime/types/components/input/with-character-limit.js +0 -0
  257. package/dist/runtime/types/components/input/with-clear.d.ts +0 -10
  258. package/dist/runtime/types/components/input/with-clear.js +0 -0
  259. package/dist/runtime/types/components/input/with-copy.d.ts +0 -11
  260. package/dist/runtime/types/components/input/with-copy.js +0 -0
  261. package/dist/runtime/types/components/input/with-floating-label.d.ts +0 -12
  262. package/dist/runtime/types/components/input/with-floating-label.js +0 -0
  263. package/dist/runtime/types/components/input/with-password-toggle.d.ts +0 -7
  264. package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
  265. package/dist/runtime/types/components/pill-group.d.ts +0 -103
  266. package/dist/runtime/types/components/pill-group.js +0 -0
  267. package/dist/runtime/types/components/popconfirm.d.ts +0 -74
  268. package/dist/runtime/types/components/popconfirm.js +0 -0
  269. package/dist/runtime/types/components/slide-verify.d.ts +0 -54
  270. package/dist/runtime/types/components/slide-verify.js +0 -0
  271. /package/dist/runtime/types/{components/color-chooser.js → locale.js} +0 -0
  272. /package/dist/runtime/types/{components/input/as-phone-number-input.js → zod-config.js} +0 -0
@@ -18,12 +18,14 @@ type __VLS_Props = {
18
18
  search?: string;
19
19
  };
20
20
  };
21
- declare var __VLS_1: {}, __VLS_39: {};
22
- type __VLS_Slots = {} & {
23
- leading?: (props: typeof __VLS_1) => any;
24
- } & {
25
- trailing?: (props: typeof __VLS_39) => any;
21
+ declare const __VLS_template: () => {
22
+ __VLS_Slots: {
23
+ leading?: (props: {}) => any;
24
+ } & {
25
+ trailing?: (props: {}) => any;
26
+ };
26
27
  };
28
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
27
29
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
30
  clear: () => any;
29
31
  "select-all": () => any;
@@ -1,3 +1,8 @@
1
1
  import type { AnyObject } from '@movk/core';
2
2
  /** 收集 disabled 子树的全部 key:节点自身 disabled 或祖先 disabled 即纳入 */
3
3
  export declare function collectDisabledKeys<T extends AnyObject>(items: T[], getKey: (node: T) => string): Set<string>;
4
+ /**
5
+ * 向 disabled 子树注入 `disabled`,交由 UTree 原生置灰整棵后代;无 disabled 时零拷贝,
6
+ * 有 disabled 时仅克隆受影响节点,保留其余节点引用,避免污染 v-model 节点 identity
7
+ */
8
+ export declare function applyDisabled<T extends AnyObject>(nodes: T[], disabledKeys: ReadonlySet<string>, getKey: (node: T) => string): T[];
@@ -10,3 +10,18 @@ export function collectDisabledKeys(items, getKey) {
10
10
  walk(items, false);
11
11
  return set;
12
12
  }
13
+ export function applyDisabled(nodes, disabledKeys, getKey) {
14
+ if (!disabledKeys.size) return nodes;
15
+ const inject = (list) => list.map((node) => {
16
+ const rawChildren = node.children;
17
+ const children = Array.isArray(rawChildren) ? inject(rawChildren) : rawChildren;
18
+ const disabled = disabledKeys.has(getKey(node));
19
+ if (!disabled && children === rawChildren) return node;
20
+ return {
21
+ ...node,
22
+ ...disabled ? { disabled: true } : null,
23
+ ...children !== rawChildren ? { children } : null
24
+ };
25
+ });
26
+ return inject(nodes);
27
+ }
@@ -8,6 +8,8 @@ export declare const PLACEHOLDER_FLAG = "__movkLazyPlaceholder";
8
8
  * 而 updateNode 仅支持按字段名匹配,写入此字段后无论 getKey 与 labelKey 是否一致都能命中。
9
9
  */
10
10
  export declare const LAZY_KEY_FIELD = "__movkKey";
11
+ /** 占位节点记录所属父节点 key,供加载失败时定位重试 */
12
+ export declare const PLACEHOLDER_PARENT_FIELD = "__movkParent";
11
13
  /** 判断节点是否为懒加载占位 */
12
14
  export declare function isPlaceholder(node: AnyObject): boolean;
13
15
  /**
@@ -17,3 +19,9 @@ export declare function isPlaceholder(node: AnyObject): boolean;
17
19
  * 注入一个占位子节点使其可展开。展开时再由 `Tree.updateNode` 用真实子节点替换。不修改入参。
18
20
  */
19
21
  export declare function markLazyPlaceholders<T extends AnyObject>(items: T[], getKey: (node: T) => string, labelKey?: string): T[];
22
+ /** 占位节点所属父节点的 key */
23
+ export declare function placeholderParentKey(node: AnyObject): string | undefined;
24
+ /**
25
+ * 把已加载的子节点回填到仍为占位的父节点上,使 `items` 引用变化后已展开的懒加载子树不丢失。不修改入参
26
+ */
27
+ export declare function restoreLoadedChildren<T extends AnyObject>(items: T[], loaded: ReadonlyMap<string, T[]>, getKey: (node: T) => string): T[];
@@ -1,5 +1,6 @@
1
1
  export const PLACEHOLDER_FLAG = "__movkLazyPlaceholder";
2
2
  export const LAZY_KEY_FIELD = "__movkKey";
3
+ export const PLACEHOLDER_PARENT_FIELD = "__movkParent";
3
4
  export function isPlaceholder(node) {
4
5
  return !!node[PLACEHOLDER_FLAG];
5
6
  }
@@ -12,8 +13,25 @@ export function markLazyPlaceholders(items, getKey, labelKey = "label") {
12
13
  if (node.isLeaf) return node;
13
14
  const placeholder = {
14
15
  [labelKey]: `${PLACEHOLDER_FLAG}:${getKey(node)}`,
15
- [PLACEHOLDER_FLAG]: true
16
+ [PLACEHOLDER_FLAG]: true,
17
+ [PLACEHOLDER_PARENT_FIELD]: getKey(node)
16
18
  };
17
19
  return { ...node, [LAZY_KEY_FIELD]: getKey(node), children: [placeholder] };
18
20
  });
19
21
  }
22
+ export function placeholderParentKey(node) {
23
+ return isPlaceholder(node) ? node[PLACEHOLDER_PARENT_FIELD] : void 0;
24
+ }
25
+ export function restoreLoadedChildren(items, loaded, getKey) {
26
+ if (!loaded.size) return items;
27
+ return items.map((node) => {
28
+ const children = node.children;
29
+ if (!Array.isArray(children)) return node;
30
+ const key = getKey(node);
31
+ if (children.length === 1 && isPlaceholder(children[0]) && loaded.has(key)) {
32
+ const restored = loaded.get(key);
33
+ return { ...node, children: restoreLoadedChildren(restored, loaded, getKey) };
34
+ }
35
+ return { ...node, children: restoreLoadedChildren(children, loaded, getKey) };
36
+ });
37
+ }
@@ -5,5 +5,7 @@ import type { AnyObject } from '@movk/core';
5
5
  * 作为 `Tree.filter` 的默认匹配函数;高亮切分由 `@movk/core` 的 `splitHighlight` 承担。
6
6
  */
7
7
  export declare function matchLabel(label: unknown, term: string): boolean;
8
- /** 按 labelKey 取节点文本(点路径,与 nodeLabel / createGetKey 一致)后做默认匹配 */
8
+ /** 按 labelKey(点路径)取节点文本,缺失时为空串 */
9
+ export declare function labelOf(node: AnyObject, labelKey: string): string;
10
+ /** 按 labelKey 取节点文本后做默认匹配 */
9
11
  export declare function matchNode(node: AnyObject, labelKey: string, term: string): boolean;
@@ -4,6 +4,10 @@ export function matchLabel(label, term) {
4
4
  if (label == null) return false;
5
5
  return String(label).toLowerCase().includes(term.toLowerCase());
6
6
  }
7
+ export function labelOf(node, labelKey) {
8
+ const value = getPath(node, labelKey);
9
+ return value == null ? "" : String(value);
10
+ }
7
11
  export function matchNode(node, labelKey, term) {
8
12
  return matchLabel(getPath(node, labelKey), term);
9
13
  }
@@ -0,0 +1,22 @@
1
+ import type { Ref } from 'vue';
2
+ type WorkNode = Record<string, any>;
3
+ interface TreeLazyOptions {
4
+ baseItems: Ref<WorkNode[]>;
5
+ getKey: () => (node: WorkNode) => string;
6
+ /** 规范化与注入占位节点 */
7
+ buildBase: (items: WorkNode[]) => WorkNode[];
8
+ loadChildren: () => ((node: WorkNode) => Promise<WorkNode[]> | WorkNode[]) | undefined;
9
+ onError: (node: WorkNode, error: unknown) => void;
10
+ }
11
+ /** 懒加载子节点:去重并发、记录失败节点供重试,并在 items 重建后回填已加载的子树 */
12
+ export declare function useTreeLazy(options: TreeLazyOptions): {
13
+ loadingKeys: Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
14
+ errorKeys: Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
15
+ load: (key: string, { retry }?: {
16
+ retry?: boolean | undefined;
17
+ }) => Promise<void>;
18
+ reload: (key: string) => Promise<void>;
19
+ rebuild: (items: WorkNode[]) => WorkNode[];
20
+ clearLoaded: () => void;
21
+ };
22
+ export {};
@@ -0,0 +1,57 @@
1
+ import { ref } from "vue";
2
+ import { Tree } from "@movk/core";
3
+ import { isPlaceholder, LAZY_KEY_FIELD, markLazyPlaceholders, restoreLoadedChildren } from "./tree-lazy.js";
4
+ export function useTreeLazy(options) {
5
+ const { baseItems } = options;
6
+ const loadingKeys = ref(/* @__PURE__ */ new Set());
7
+ const errorKeys = ref(/* @__PURE__ */ new Set());
8
+ const loaded = /* @__PURE__ */ new Map();
9
+ const withKey = (set, key) => new Set(set).add(key);
10
+ const withoutKey = (set, key) => {
11
+ const next = new Set(set);
12
+ next.delete(key);
13
+ return next;
14
+ };
15
+ function findNode(key) {
16
+ const getKey = options.getKey();
17
+ return Tree.find(baseItems.value, ({ node }) => getKey(node) === key);
18
+ }
19
+ function replaceNode(key, update) {
20
+ baseItems.value = Tree.updateNode(baseItems.value, key, ({ node }) => update(node), { id: LAZY_KEY_FIELD });
21
+ }
22
+ async function load(key, { retry = false } = {}) {
23
+ const loadChildren = options.loadChildren();
24
+ const node = findNode(key);
25
+ const first = node?.children?.[0];
26
+ if (!loadChildren || !node || !first || !isPlaceholder(first) || loadingKeys.value.has(key)) return;
27
+ if (errorKeys.value.has(key) && !retry) return;
28
+ loadingKeys.value = withKey(loadingKeys.value, key);
29
+ errorKeys.value = withoutKey(errorKeys.value, key);
30
+ try {
31
+ const children = options.buildBase(await loadChildren(node));
32
+ loaded.set(key, children);
33
+ replaceNode(key, (current) => ({ ...current, children: children.length ? children : void 0, isLeaf: children.length === 0 }));
34
+ } catch (error) {
35
+ errorKeys.value = withKey(errorKeys.value, key);
36
+ options.onError(node, error);
37
+ } finally {
38
+ loadingKeys.value = withoutKey(loadingKeys.value, key);
39
+ }
40
+ }
41
+ async function reload(key) {
42
+ loaded.delete(key);
43
+ const node = findNode(key);
44
+ if (!node) return;
45
+ const [reset] = markLazyPlaceholders([{ ...node, children: void 0, isLeaf: void 0 }], options.getKey());
46
+ replaceNode(key, () => reset);
47
+ await load(key, { retry: true });
48
+ }
49
+ function rebuild(items) {
50
+ return restoreLoadedChildren(options.buildBase(items), loaded, options.getKey());
51
+ }
52
+ function clearLoaded() {
53
+ loaded.clear();
54
+ errorKeys.value = /* @__PURE__ */ new Set();
55
+ }
56
+ return { loadingKeys, errorKeys, load, reload, rebuild, clearLoaded };
57
+ }
@@ -0,0 +1,27 @@
1
+ import type { Ref } from 'vue';
2
+ type WorkNode = Record<string, any>;
3
+ interface TreeSearchOptions {
4
+ search: Ref<string>;
5
+ enabled: () => boolean;
6
+ baseItems: Ref<WorkNode[]>;
7
+ expanded: Ref<string[]>;
8
+ getKey: () => (node: WorkNode) => string;
9
+ labelKey: () => string;
10
+ filter: () => ((node: WorkNode, term: string) => boolean) | undefined;
11
+ searchMethod: () => ((term: string) => Promise<WorkNode[]>) | undefined;
12
+ searchDebounce: () => number;
13
+ buildBase: (items: WorkNode[]) => WorkNode[];
14
+ onError: (term: string, error: unknown) => void;
15
+ }
16
+ /** 本地过滤或远程搜索;搜索期间自动展开命中路径,结束后恢复搜索前的展开状态 */
17
+ export declare function useTreeSearch(options: TreeSearchOptions): {
18
+ term: import("vue").ComputedRef<string>;
19
+ searching: import("vue").ComputedRef<boolean>;
20
+ matchedItems: import("vue").ComputedRef<WorkNode[]>;
21
+ isEmpty: import("vue").ComputedRef<boolean>;
22
+ remote: import("vue").ComputedRef<boolean>;
23
+ remoteLoading: Ref<boolean, boolean>;
24
+ remoteError: Ref<boolean, boolean>;
25
+ retry: () => number;
26
+ };
27
+ export {};
@@ -0,0 +1,59 @@
1
+ import { computed, ref, shallowRef, watch } from "vue";
2
+ import { Tree } from "@movk/core";
3
+ import { isPlaceholder } from "./tree-lazy.js";
4
+ import { matchNode } from "./tree-search.js";
5
+ export function useTreeSearch(options) {
6
+ const term = computed(() => options.search.value.trim());
7
+ const searching = computed(() => options.enabled() && !!term.value);
8
+ const remoteItems = shallowRef([]);
9
+ const remoteLoading = ref(false);
10
+ const remoteError = ref(false);
11
+ const retryCount = ref(0);
12
+ const remote = computed(() => searching.value && !!options.searchMethod());
13
+ watch([term, options.searchMethod, searching, options.searchDebounce, retryCount], ([value, searchMethod, active, delay], _previous, onCleanup) => {
14
+ remoteItems.value = [];
15
+ remoteError.value = false;
16
+ remoteLoading.value = !!searchMethod && active;
17
+ if (!searchMethod || !active || import.meta.server) return;
18
+ let current = true;
19
+ const timer = setTimeout(async () => {
20
+ try {
21
+ const items = await searchMethod(value);
22
+ if (current) remoteItems.value = options.buildBase(items);
23
+ } catch (error) {
24
+ if (!current) return;
25
+ remoteError.value = true;
26
+ options.onError(value, error);
27
+ } finally {
28
+ if (current) remoteLoading.value = false;
29
+ }
30
+ }, delay);
31
+ onCleanup(() => {
32
+ current = false;
33
+ clearTimeout(timer);
34
+ });
35
+ }, { immediate: true });
36
+ const matchedItems = computed(() => {
37
+ if (!searching.value) return options.baseItems.value;
38
+ if (options.searchMethod()) return remoteItems.value;
39
+ const filter = options.filter();
40
+ const labelKey = options.labelKey();
41
+ return Tree.filter(options.baseItems.value, ({ node }) => !isPlaceholder(node) && (filter ? filter(node, term.value) : matchNode(node, labelKey, term.value)));
42
+ });
43
+ const isEmpty = computed(() => searching.value && !remoteLoading.value && !remoteError.value && matchedItems.value.length === 0);
44
+ let snapshot;
45
+ watch(searching, (active) => {
46
+ if (active) {
47
+ snapshot = options.expanded.value;
48
+ } else if (snapshot) {
49
+ options.expanded.value = snapshot;
50
+ snapshot = void 0;
51
+ }
52
+ }, { immediate: true });
53
+ watch(matchedItems, (items) => {
54
+ if (!searching.value) return;
55
+ const getKey = options.getKey();
56
+ options.expanded.value = Tree.findAll(items, ({ node }) => !!node.children?.length).map((node) => getKey(node));
57
+ });
58
+ return { term, searching, matchedItems, isEmpty, remote, remoteLoading, remoteError, retry: () => retryCount.value++ };
59
+ }
@@ -0,0 +1,31 @@
1
+ import type { Ref } from 'vue';
2
+ import type { TreeSelectionResult, TreeSelectionStrategy } from '../../types/shared';
3
+ type WorkNode = Record<string, any>;
4
+ type ModelValue = WorkNode | WorkNode[] | undefined;
5
+ interface TreeSelectionOptions {
6
+ baseItems: Ref<WorkNode[]>;
7
+ remoteItems: Ref<WorkNode[] | undefined>;
8
+ getKey: () => (node: WorkNode) => string;
9
+ disabledKeys: Ref<Set<string>>;
10
+ strategy: () => TreeSelectionStrategy;
11
+ multiple: () => boolean;
12
+ disabled: () => boolean;
13
+ modelValue: Ref<ModelValue>;
14
+ selectedKeys: Ref<string[] | undefined>;
15
+ onChange: (payload: {
16
+ value: ModelValue;
17
+ keys: string[];
18
+ selection: TreeSelectionResult<WorkNode>;
19
+ }) => void;
20
+ }
21
+ /** 节点对象 model 与 selectedKeys 双形态的选中状态、分类结果与工具栏摘要 */
22
+ export declare function useTreeSelection(options: TreeSelectionOptions): {
23
+ effectiveModel: import("vue").ComputedRef<ModelValue>;
24
+ treeSelection: import("vue").ComputedRef<TreeSelectionResult<WorkNode>>;
25
+ summary: import("vue").ComputedRef<import("../../types").TreeSelectionSummary>;
26
+ onModelUpdate: (value: ModelValue) => void;
27
+ selectAll: () => void;
28
+ clearSelection: () => void;
29
+ nodesByKey: import("vue").ComputedRef<Map<string, WorkNode>>;
30
+ };
31
+ export {};
@@ -0,0 +1,89 @@
1
+ import { computed, shallowRef, watch } from "vue";
2
+ import { Tree } from "@movk/core";
3
+ import { computeTreeSelection, selectionSummary } from "../../utils/tree-selection.js";
4
+ import { isPlaceholder } from "./tree-lazy.js";
5
+ export function useTreeSelection(options) {
6
+ const { baseItems, remoteItems, disabledKeys, modelValue, selectedKeys: selectedKeysState } = options;
7
+ const isSelectable = (node) => !isPlaceholder(node) && !disabledKeys.value.has(options.getKey()(node));
8
+ const activeItems = computed(() => remoteItems.value ?? baseItems.value);
9
+ const selectableNodes = computed(() => Tree.findAll(activeItems.value, ({ node }) => isSelectable(node)));
10
+ const activeNodes = computed(() => indexNodes(activeItems.value, options.getKey()));
11
+ const cachedSelection = shallowRef([]);
12
+ const selectionItems = computed(() => {
13
+ if (!remoteItems.value?.length && !cachedSelection.value.length) return baseItems.value;
14
+ return mergeTrees(baseItems.value, [...remoteItems.value ?? [], ...cachedSelection.value], options.getKey());
15
+ });
16
+ const nodesByKey = computed(() => indexNodes(selectionItems.value, options.getKey()));
17
+ function modelToKeys(value) {
18
+ const getKey = options.getKey();
19
+ if (Array.isArray(value)) return value.map(getKey);
20
+ return value ? [getKey(value)] : [];
21
+ }
22
+ function keysToModel(keys) {
23
+ const nodes = keys.map((key) => nodesByKey.value.get(key)).filter((node) => !!node);
24
+ return options.multiple() ? nodes : nodes[0];
25
+ }
26
+ const selectedKeys = computed(() => selectedKeysState.value ?? modelToKeys(modelValue.value));
27
+ watch([selectedKeys, remoteItems], ([keys, results]) => {
28
+ const getKey = options.getKey();
29
+ const prior = indexNodes(cachedSelection.value, getKey);
30
+ const found = results ? activeNodes.value : void 0;
31
+ cachedSelection.value = keys.flatMap((key) => {
32
+ const node = found?.get(key) ?? prior.get(key);
33
+ return node ? [node] : [];
34
+ });
35
+ }, { immediate: true, flush: "sync" });
36
+ const effectiveModel = computed(() => selectedKeysState.value !== void 0 ? keysToModel(selectedKeysState.value) : modelValue.value);
37
+ const classify = (keys) => computeTreeSelection(selectionItems.value, new Set(keys), { getKey: options.getKey(), strategy: options.strategy() });
38
+ const treeSelection = computed(() => classify(selectedKeys.value));
39
+ const selectableLeafCount = computed(() => selectableNodes.value.filter((node) => !(Array.isArray(node.children) && node.children.length > 0)).length);
40
+ const summary = computed(() => selectionSummary(
41
+ treeSelection.value.leaves.filter((node) => activeNodes.value.has(options.getKey()(node))).length,
42
+ selectableLeafCount.value
43
+ ));
44
+ function withSelectionOutsideResults(nodes) {
45
+ if (!remoteItems.value) return nodes;
46
+ const existing = selectedKeys.value.filter((key) => !activeNodes.value.has(key));
47
+ return [...existing.map((key) => nodesByKey.value.get(key)).filter((node) => node !== void 0), ...nodes];
48
+ }
49
+ function setModel(value) {
50
+ modelValue.value = value;
51
+ const keys = modelToKeys(value);
52
+ if (selectedKeysState.value !== void 0) selectedKeysState.value = keys;
53
+ options.onChange({ value, keys, selection: classify(keys) });
54
+ }
55
+ function onModelUpdate(value) {
56
+ if (options.disabled()) return;
57
+ if (Array.isArray(value)) {
58
+ setModel(withSelectionOutsideResults(value.filter((node) => !node.disabled && (!remoteItems.value || activeNodes.value.has(options.getKey()(node))))));
59
+ return;
60
+ }
61
+ if (value?.disabled) return;
62
+ setModel(value);
63
+ }
64
+ const selectAll = () => setModel(withSelectionOutsideResults(selectableNodes.value));
65
+ const clearSelection = () => setModel(options.multiple() ? [] : void 0);
66
+ return { effectiveModel, treeSelection, summary, onModelUpdate, selectAll, clearSelection, nodesByKey };
67
+ }
68
+ function indexNodes(items, getKey) {
69
+ const nodes = /* @__PURE__ */ new Map();
70
+ Tree.forEach(items, ({ node }) => {
71
+ if (!isPlaceholder(node)) nodes.set(getKey(node), node);
72
+ });
73
+ return nodes;
74
+ }
75
+ function mergeTrees(base, extra, getKey) {
76
+ const seen = new Set(indexNodes(base, getKey).keys());
77
+ function collect(nodes) {
78
+ return nodes.flatMap((node) => {
79
+ if (isPlaceholder(node)) return [];
80
+ const key = getKey(node);
81
+ const known = seen.has(key);
82
+ seen.add(key);
83
+ const children = Array.isArray(node.children) ? collect(node.children) : void 0;
84
+ if (known) return children ?? [];
85
+ return [children?.length === node.children?.length ? node : { ...node, children }];
86
+ });
87
+ }
88
+ return [...base, ...collect(extra)];
89
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import type { ZodRequiredInput } from '../../types/zod-config';
3
+ import type { MovkTranslator } from '../../locale';
4
+ type ZodErrorMap = z.core.$ZodErrorMap;
5
+ export type ZodLocaleFactory = () => {
6
+ localeError: ZodErrorMap;
7
+ };
8
+ /** 构建期归一化后的 `zod` 模块选项,经 `#build/movk-zod` 注入运行时 */
9
+ export interface ResolvedZodOptions {
10
+ locale: string;
11
+ fallback: string;
12
+ localeMap: Record<string, string>;
13
+ requiredInputs: ZodRequiredInput[] | false;
14
+ label: boolean;
15
+ jitless: boolean;
16
+ }
17
+ export declare function resolveLocaleError(code: string, options: ResolvedZodOptions, locales: Record<string, ZodLocaleFactory>): ZodErrorMap | undefined;
18
+ export declare function dictionaryTranslator(code: string): MovkTranslator;
19
+ /**
20
+ * 全局配置只包含构建期设置。每个应用的错误映射与界面语言由单次表单校验提供。
21
+ */
22
+ export declare function installZod(options: ResolvedZodOptions, locales: Record<string, ZodLocaleFactory>): void;
23
+ export {};
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import { createTranslator, en, movkLocales } from "../../locale/index.js";
3
+ import { createErrorMap } from "./error-map.js";
4
+ import { resolveZodLocale } from "./locale-map.js";
5
+ export function resolveLocaleError(code, options, locales) {
6
+ const names = Object.keys(locales);
7
+ const name = resolveZodLocale(code, names, options.localeMap) ?? resolveZodLocale(options.fallback, names, options.localeMap);
8
+ return name ? locales[name]?.().localeError : void 0;
9
+ }
10
+ export function dictionaryTranslator(code) {
11
+ const messages = movkLocales[code] ?? en;
12
+ return createTranslator(() => messages);
13
+ }
14
+ export function installZod(options, locales) {
15
+ const initial = options.locale === "auto" ? options.fallback : options.locale;
16
+ const t = dictionaryTranslator(initial);
17
+ z.config({
18
+ jitless: options.jitless,
19
+ localeError: resolveLocaleError(initial, options, locales),
20
+ customError: createErrorMap({
21
+ requiredInputs: options.requiredInputs,
22
+ label: options.label,
23
+ getT: () => t
24
+ })
25
+ });
26
+ }
@@ -0,0 +1,13 @@
1
+ import type { z } from 'zod';
2
+ import type { MovkTranslator } from '../../composables/useMovkLocale';
3
+ import type { ZodRequiredInput } from '../../types/zod-config';
4
+ type ZodErrorMap = z.core.$ZodErrorMap;
5
+ export interface ErrorMapOptions {
6
+ requiredInputs: ZodRequiredInput[] | false;
7
+ label: boolean;
8
+ getT: () => MovkTranslator;
9
+ customError?: ZodErrorMap;
10
+ }
11
+ /** 组合用户 `customError` 与必填文案;返回 `undefined` 时交给 zod 的 locale 文案 */
12
+ export declare function createErrorMap(options: ErrorMapOptions): ZodErrorMap;
13
+ export {};
@@ -0,0 +1,19 @@
1
+ import { getAutoFormMetadata } from "../auto-form/metadata.js";
2
+ function resolveLabel(issue) {
3
+ const schema = issue.schema ?? issue.inst;
4
+ if (!schema || !("_zod" in schema) || !("meta" in schema)) return;
5
+ const meta = getAutoFormMetadata(schema);
6
+ const label = meta.label ?? meta.title;
7
+ return typeof label === "string" && label ? label : void 0;
8
+ }
9
+ export function createErrorMap(options) {
10
+ const { requiredInputs, label, getT, customError } = options;
11
+ return (issue) => {
12
+ const custom = customError?.(issue);
13
+ if (custom != null) return custom;
14
+ if (!requiredInputs || !requiredInputs.includes(issue.input)) return;
15
+ const t = getT();
16
+ const name = label ? resolveLabel(issue) : void 0;
17
+ return name ? t("validation.requiredWithLabel", { label: name }) : t("validation.required");
18
+ };
19
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 把 Nuxt UI locale code(如 `zh-CN`、`en-US`)解析为 `zod/locales` 的导出名,
3
+ * 依次尝试 `localeMap`、内置映射、去连字符、主语言子标签。
4
+ */
5
+ export declare function resolveZodLocale(code: string, available: readonly string[], localeMap?: Record<string, string>): string | undefined;
@@ -0,0 +1,17 @@
1
+ const BUILTIN_ZOD_LOCALE_MAP = {
2
+ "zh": "zhCN",
3
+ "zh-Hans": "zhCN",
4
+ "zh-SG": "zhCN",
5
+ "zh-Hant": "zhTW",
6
+ "zh-HK": "zhTW",
7
+ "nb": "no"
8
+ };
9
+ export function resolveZodLocale(code, available, localeMap = {}) {
10
+ const candidates = [
11
+ localeMap[code],
12
+ BUILTIN_ZOD_LOCALE_MAP[code],
13
+ code.replace(/-/g, ""),
14
+ code.split("-")[0]
15
+ ];
16
+ return candidates.find((name) => !!name && available.includes(name));
17
+ }
@@ -0,0 +1,12 @@
1
+ import type { InjectionKey } from 'vue';
2
+ import type { z } from 'zod';
3
+ import type { MovkZodRuntimeConfig } from '../../types/zod-config';
4
+ import type { ResolvedZodOptions, ZodLocaleFactory } from './apply';
5
+ interface ZodFormContext {
6
+ options: ResolvedZodOptions;
7
+ locales: Record<string, ZodLocaleFactory>;
8
+ runtime: MovkZodRuntimeConfig;
9
+ }
10
+ export declare const ZOD_FORM_CONTEXT: InjectionKey<ZodFormContext>;
11
+ export declare function useZodFormSchema<S extends z.ZodType>(getSchema: () => S | undefined): import("vue").ComputedRef<S | undefined>;
12
+ export {};
@@ -0,0 +1,30 @@
1
+ import { computed, inject } from "vue";
2
+ import { useMovkLocale } from "../../composables/useMovkLocale.js";
3
+ import { dictionaryTranslator, resolveLocaleError } from "./apply.js";
4
+ import { createErrorMap } from "./error-map.js";
5
+ export const ZOD_FORM_CONTEXT = Symbol("movk-zod-form");
6
+ export function useZodFormSchema(getSchema) {
7
+ const context = inject(ZOD_FORM_CONTEXT, void 0);
8
+ const locale = context?.options.locale === "auto" && !import.meta.server ? useMovkLocale() : void 0;
9
+ return computed(() => {
10
+ const schema = getSchema();
11
+ if (!schema || !context) return schema;
12
+ const { options, locales, runtime } = context;
13
+ const code = locale?.code.value ?? (options.locale === "auto" ? options.fallback : options.locale);
14
+ const errorMap = createErrorMap({
15
+ requiredInputs: options.requiredInputs,
16
+ label: options.label,
17
+ getT: () => locale?.t ?? dictionaryTranslator(code),
18
+ customError: runtime.customError
19
+ });
20
+ const localeError = resolveLocaleError(code, options, locales);
21
+ const standard = {
22
+ ...schema["~standard"],
23
+ async validate(input) {
24
+ const result = await schema.safeParseAsync(input, { error: (issue) => errorMap(issue) ?? localeError?.(issue) });
25
+ return result.success ? { value: result.data } : { issues: result.error.issues };
26
+ }
27
+ };
28
+ return Object.defineProperty(schema.clone(), "~standard", { value: standard });
29
+ });
30
+ }
@@ -0,0 +1,74 @@
1
+ declare const _default: {
2
+ autoForm: {
3
+ submit: string;
4
+ add: string;
5
+ moveUp: string;
6
+ moveDown: string;
7
+ duplicate: string;
8
+ remove: string;
9
+ };
10
+ searchForm: {
11
+ search: string;
12
+ reset: string;
13
+ expand: string;
14
+ collapse: string;
15
+ };
16
+ dataTable: {
17
+ actions: string;
18
+ selectAll: string;
19
+ selectRow: string;
20
+ selectParentRow: string;
21
+ expandAll: string;
22
+ collapseAll: string;
23
+ pinRow: string;
24
+ unpinRow: string;
25
+ pinColumn: string;
26
+ unpinColumn: string;
27
+ columnSettings: string;
28
+ resetColumns: string;
29
+ };
30
+ pagination: {
31
+ empty: string;
32
+ total: string;
33
+ range: string;
34
+ rangeUnknown: string;
35
+ selected: string;
36
+ pageSize: string;
37
+ };
38
+ tree: {
39
+ empty: string;
40
+ loading: string;
41
+ selected: string;
42
+ selectAll: string;
43
+ expandAll: string;
44
+ collapseAll: string;
45
+ search: string;
46
+ clearSearch: string;
47
+ loadError: string;
48
+ searchError: string;
49
+ searchLoading: string;
50
+ retry: string;
51
+ };
52
+ datePicker: {
53
+ placeholder: string;
54
+ clear: string;
55
+ today: string;
56
+ yesterday: string;
57
+ tomorrow: string;
58
+ thisWeek: string;
59
+ thisMonth: string;
60
+ last7Days: string;
61
+ last30Days: string;
62
+ };
63
+ messageBox: {
64
+ title: string;
65
+ acknowledge: string;
66
+ confirm: string;
67
+ cancel: string;
68
+ };
69
+ validation: {
70
+ required: string;
71
+ requiredWithLabel: string;
72
+ };
73
+ };
74
+ export default _default;