@movk/nuxt 1.8.3 → 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 (274) 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 +15 -22
  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 +6 -7
  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 -14
  58. package/dist/runtime/domains/api/interceptors/response.js +34 -25
  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 +1 -1
  64. package/dist/runtime/domains/api/session.js +1 -1
  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.DfVF6ZZv.mjs → nuxt.CbmfnBRt.mjs} +82 -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 +39 -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 -26
  249. package/dist/runtime/domains/api/interceptors/unauthorized.d.ts +0 -12
  250. package/dist/runtime/domains/api/interceptors/unauthorized.js +0 -34
  251. package/dist/runtime/domains/api/transfer.d.ts +0 -69
  252. package/dist/runtime/domains/api/transfer.js +0 -87
  253. package/dist/runtime/types/components/color-chooser.d.ts +0 -109
  254. package/dist/runtime/types/components/input/as-phone-number-input.d.ts +0 -17
  255. package/dist/runtime/types/components/input/index.d.ts +0 -6
  256. package/dist/runtime/types/components/input/index.js +0 -0
  257. package/dist/runtime/types/components/input/with-character-limit.d.ts +0 -11
  258. package/dist/runtime/types/components/input/with-character-limit.js +0 -0
  259. package/dist/runtime/types/components/input/with-clear.d.ts +0 -10
  260. package/dist/runtime/types/components/input/with-clear.js +0 -0
  261. package/dist/runtime/types/components/input/with-copy.d.ts +0 -11
  262. package/dist/runtime/types/components/input/with-copy.js +0 -0
  263. package/dist/runtime/types/components/input/with-floating-label.d.ts +0 -12
  264. package/dist/runtime/types/components/input/with-floating-label.js +0 -0
  265. package/dist/runtime/types/components/input/with-password-toggle.d.ts +0 -7
  266. package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
  267. package/dist/runtime/types/components/pill-group.d.ts +0 -103
  268. package/dist/runtime/types/components/pill-group.js +0 -0
  269. package/dist/runtime/types/components/popconfirm.d.ts +0 -74
  270. package/dist/runtime/types/components/popconfirm.js +0 -0
  271. package/dist/runtime/types/components/slide-verify.d.ts +0 -54
  272. package/dist/runtime/types/components/slide-verify.js +0 -0
  273. /package/dist/runtime/types/{components/color-chooser.js → locale.js} +0 -0
  274. /package/dist/runtime/types/{components/input/as-phone-number-input.js → zod-config.js} +0 -0
@@ -1,52 +1,66 @@
1
1
  <script setup>
2
2
  import { UButton, UCollapsible, UForm } from "#components";
3
- import { computed, onMounted, ref, toRaw, unref, useAttrs, useTemplateRef, watch } from "vue";
4
- import { deepClone, isFunction } from "@movk/core";
5
- import { useAutoFormProvider } from "../domains/auto-form/provider";
6
- import { extractPureSchema, introspectSchema } from "../domains/auto-form/schema";
7
- import { applyFieldDefaults } from "../domains/auto-form/fields";
8
- import { DEFAULT_CONTROLS } from "../domains/auto-form/controls";
9
- import { DEFAULT_SEARCH_ACTIONS } from "../domains/auto-form/actions";
3
+ import { computed, ref, useAttrs, useTemplateRef, watch } from "vue";
4
+ import { useBreakpoints } from "@vueuse/core";
5
+ import { useAutoFormCore } from "../domains/auto-form/useAutoFormCore";
6
+ import { isLeafField } from "../domains/auto-form/fields";
7
+ import { AUTOFORM_META } from "../domains/auto-form/constants";
8
+ import { createDefaultSearchActions } from "../domains/auto-form/actions";
9
+ import { useMovkLocale } from "../composables/useMovkLocale";
10
10
  import AutoFormRendererField from "../domains/auto-form/components/Field.vue";
11
11
  import { useAppConfig } from "#imports";
12
+ import { cleanSearchPayload } from "../domains/auto-form/search-query";
13
+ import { useSearchQuerySync } from "../domains/auto-form/useSearchQuerySync";
12
14
  import theme from "#build/movk-ui/search-form";
13
15
  import { useExtendedTv } from "../utils/extend-theme";
16
+ const BREAKPOINTS = { sm: 640, md: 768, lg: 1024, xl: 1280 };
17
+ const BREAKPOINT_KEYS = Object.keys(BREAKPOINTS);
14
18
  const props = defineProps({
19
+ syncQuery: { type: [Boolean, Object], required: false, default: false },
20
+ transformPayload: { type: [Boolean, Function], required: false, default: true },
15
21
  cols: { type: [Number, Object], required: false, default: 3 },
16
22
  visibleRows: { type: Number, required: false, default: 1 },
17
23
  actions: { type: Array, required: false },
18
24
  loading: { type: Boolean, required: false },
19
25
  collapseButtonProps: { type: Object, required: false },
20
26
  icon: { type: null, required: false, default: "i-lucide-chevron-down" },
21
- expandText: { type: String, required: false, default: "\u5C55\u5F00" },
22
- collapseText: { type: String, required: false, default: "\u6536\u8D77" },
23
- expanded: { type: Boolean, required: false },
27
+ expandText: { type: String, required: false },
28
+ collapseText: { type: String, required: false },
24
29
  defaultExpanded: { type: Boolean, required: false, default: false },
25
30
  schema: { type: null, required: true },
26
31
  controls: { type: Object, required: false },
27
32
  globalMeta: { type: Object, required: false },
28
33
  loadingAuto: { type: Boolean, required: false, default: true },
29
34
  validateOn: { type: Array, required: false, default: () => [] },
35
+ hiddenValue: { type: String, required: false },
36
+ onSubmit: { type: Function, required: false },
30
37
  class: { type: [Array, String, null, Number, Boolean], required: false, skipCheck: true },
31
38
  ui: { type: Object, required: false }
32
39
  });
33
40
  const modelValue = defineModel({ type: Object, ...{ default: () => ({}) } });
34
- const expandedModel = defineModel("expanded", { type: Boolean });
35
- const emits = defineEmits(["reset", "clear", "expand", "update:expanded", "error"]);
41
+ const expandedModel = defineModel("expanded", { type: Boolean, skipCheck: true });
42
+ const emits = defineEmits(["reset", "clear", "expand", "query-restore", "error"]);
36
43
  const slots = defineSlots();
37
44
  defineOptions({ inheritAttrs: false });
38
45
  const attrs = useAttrs();
39
- let baseline = deepClone(toRaw(modelValue.value));
46
+ const { t } = useMovkLocale();
40
47
  const appConfig = useAppConfig();
41
48
  const formRef = useTemplateRef("formRef");
42
- const internalExpanded = ref(props.defaultExpanded ?? false);
49
+ const core = useAutoFormCore({
50
+ schema: () => props.schema,
51
+ controls: () => props.controls,
52
+ globalMeta: () => props.globalMeta,
53
+ hiddenValue: () => props.hiddenValue,
54
+ model: modelValue,
55
+ slots
56
+ });
57
+ const { validationSchema, resolvedButtonSize } = core;
58
+ const internalExpanded = ref(props.defaultExpanded);
43
59
  const expanded = computed({
44
60
  get: () => expandedModel.value ?? internalExpanded.value,
45
- set: (val) => {
46
- internalExpanded.value = val;
47
- if (expandedModel.value !== void 0) {
48
- expandedModel.value = val;
49
- }
61
+ set: (value) => {
62
+ internalExpanded.value = value;
63
+ expandedModel.value = value;
50
64
  }
51
65
  });
52
66
  const { baseUi, extraUi } = useExtendedTv(
@@ -60,99 +74,111 @@ const { baseUi, extraUi } = useExtendedTv(
60
74
  }
61
75
  })
62
76
  );
63
- function maxCols(cols) {
77
+ const activeBreakpoints = useBreakpoints(BREAKPOINTS, { ssrWidth: 0 }).current();
78
+ const currentCols = computed(() => {
79
+ const cols = props.cols;
64
80
  if (typeof cols === "number") return cols;
65
81
  if (!cols) return 1;
66
- return Math.max(cols.sm ?? 1, cols.md ?? 1, cols.lg ?? 1, cols.xl ?? 1);
67
- }
82
+ const base = cols.sm ?? cols.md ?? cols.lg ?? cols.xl ?? 1;
83
+ return activeBreakpoints.value.reduce((acc, key) => cols[key] ?? acc, base);
84
+ });
68
85
  const gridStyle = computed(() => {
69
- const c = props.cols;
70
- const vars = {};
71
- if (typeof c === "number") {
72
- vars["--m-search-cols"] = String(c);
73
- } else if (c) {
74
- const base = c.sm ?? c.md ?? c.lg ?? c.xl ?? 1;
75
- vars["--m-search-cols"] = String(base);
76
- if (c.sm !== void 0) vars["--m-search-cols-sm"] = String(c.sm);
77
- if (c.md !== void 0) vars["--m-search-cols-md"] = String(c.md);
78
- if (c.lg !== void 0) vars["--m-search-cols-lg"] = String(c.lg);
79
- if (c.xl !== void 0) vars["--m-search-cols-xl"] = String(c.xl);
86
+ const cols = props.cols;
87
+ if (typeof cols === "number") return { "--m-search-cols": String(cols) };
88
+ if (!cols) return {};
89
+ const vars = { "--m-search-cols": String(cols.sm ?? cols.md ?? cols.lg ?? cols.xl ?? 1) };
90
+ for (const key of BREAKPOINT_KEYS) {
91
+ if (cols[key] !== void 0) vars[`--m-search-cols-${key}`] = String(cols[key]);
80
92
  }
81
93
  return vars;
82
94
  });
83
- useAutoFormProvider(modelValue, slots);
84
- const resolvedButtonSize = computed(() => {
85
- const size = props.globalMeta?.size;
86
- if (size === void 0 || isFunction(size)) return void 0;
87
- return unref(size);
88
- });
89
- const pureSchema = computed(() => extractPureSchema(props.schema));
90
- const controlsMapping = computed(() => ({ ...DEFAULT_CONTROLS, ...props.controls }));
91
- const fields = computed(() => introspectSchema(props.schema, controlsMapping.value, "", props.globalMeta));
92
- const actionsBag = { toggle, search: submit, reset, clear };
93
- function buildSlotProps(errors, loading) {
94
- return {
95
- ...actionsBag,
96
- expanded: expanded.value,
97
- loading: props.loading || loading,
98
- state: modelValue.value,
99
- errors
100
- };
101
- }
102
- function resolveActions(slotCtx) {
103
- const list = props.actions ?? DEFAULT_SEARCH_ACTIONS;
104
- return list.filter((action) => {
105
- if (action.visible === void 0) return true;
106
- if (typeof action.visible === "function") {
107
- return action.visible(slotCtx);
108
- }
109
- return action.visible;
110
- });
95
+ function isSupportedField(field) {
96
+ return isLeafField(field) && field.meta?.type !== AUTOFORM_META.LAYOUT_KEY;
111
97
  }
112
- const showActionsCell = computed(() => {
113
- const list = props.actions ?? DEFAULT_SEARCH_ACTIONS;
114
- return list.length > 0 || !!slots.actions || !!slots.extraActions;
115
- });
98
+ watch(core.fields, (fields) => {
99
+ const unsupported = fields.filter((field) => !isSupportedField(field)).map((field) => field.path);
100
+ if (import.meta.dev && unsupported.length) {
101
+ console.warn(`[SearchForm] Object, array and layout fields are not supported and will be skipped: ${unsupported.join(", ")}`);
102
+ }
103
+ }, { immediate: true });
104
+ const renderFields = computed(() => core.visibleFields.value.filter(isSupportedField));
105
+ const actionList = computed(() => props.actions ?? createDefaultSearchActions(t));
106
+ const showActionsCell = computed(() => actionList.value.length > 0 || !!slots.actions || !!slots.extraActions);
116
107
  const visibleCount = computed(() => {
117
- const total = maxCols(props.cols) * props.visibleRows;
118
- if (!showActionsCell.value) return total;
119
- if (maxCols(props.cols) <= 1) return total;
120
- return Math.max(0, total - 1);
108
+ const total = currentCols.value * props.visibleRows;
109
+ return showActionsCell.value && currentCols.value > 1 ? Math.max(0, total - 1) : total;
121
110
  });
122
- const visibleFields = computed(() => fields.value.slice(0, visibleCount.value));
123
- const collapsedFields = computed(() => fields.value.slice(visibleCount.value));
111
+ const visibleFields = computed(() => renderFields.value.slice(0, visibleCount.value));
112
+ const collapsedFields = computed(() => renderFields.value.slice(visibleCount.value));
124
113
  const needsCollapse = computed(() => collapsedFields.value.length > 0);
125
114
  function toggle() {
126
- const next = !expanded.value;
127
- expanded.value = next;
128
- emits("expand", next);
129
- emits("update:expanded", next);
130
- }
131
- function submit() {
132
- formRef.value?.submit();
115
+ expanded.value = !expanded.value;
116
+ emits("expand", expanded.value);
133
117
  }
118
+ const submit = async () => formRef.value?.submit();
119
+ const validate = ((...args) => formRef.value?.validate(...args));
134
120
  function buildFieldPayload(state) {
135
- const keys = Object.keys(props.schema.shape);
136
- return keys.reduce((acc, key) => {
137
- acc[key] = state[key];
138
- return acc;
139
- }, {});
121
+ const keys = Object.keys(core.pureSchema.value?.shape ?? {});
122
+ return Object.fromEntries(keys.map((key) => [key, state[key]]));
140
123
  }
141
- function clear() {
142
- const next = {};
143
- modelValue.value = next;
144
- formRef.value?.clear();
145
- emits("clear", buildFieldPayload(next));
124
+ const syncQuery = useSearchQuerySync({
125
+ sync: () => props.syncQuery,
126
+ schema: () => core.pureSchema.value,
127
+ state: () => modelValue.value,
128
+ onRestore: (state) => {
129
+ formRef.value?.clear();
130
+ emits("query-restore", state);
131
+ }
132
+ });
133
+ function writeQuery(state) {
134
+ syncQuery(state).catch((error) => console.error("[SearchForm] Failed to update the URL query.", error));
146
135
  }
136
+ function applyTransform(data) {
137
+ const transform = props.transformPayload;
138
+ if (transform === false) return data;
139
+ return transform === true ? cleanSearchPayload(data) : transform(data);
140
+ }
141
+ const handleSubmit = ((event) => {
142
+ const data = applyTransform(event.data);
143
+ writeQuery(data);
144
+ return props.onSubmit?.({ ...event, data });
145
+ });
147
146
  function reset() {
148
- const next = deepClone(baseline);
149
- applyFieldDefaults(fields.value, next);
150
- modelValue.value = next;
147
+ const next = core.reset();
151
148
  formRef.value?.clear();
149
+ writeQuery(next);
152
150
  emits("reset", buildFieldPayload(next));
153
151
  }
154
- function setBaseline(value) {
155
- baseline = deepClone(toRaw(value ?? modelValue.value));
152
+ function clear() {
153
+ const next = core.clear();
154
+ formRef.value?.clear();
155
+ writeQuery(next);
156
+ emits("clear", buildFieldPayload(next));
157
+ }
158
+ function buildSlotProps(errors, loading) {
159
+ return {
160
+ toggle,
161
+ search: submit,
162
+ reset,
163
+ clear,
164
+ expanded: expanded.value,
165
+ loading: props.loading || loading,
166
+ state: modelValue.value,
167
+ errors
168
+ };
169
+ }
170
+ function resolveActions(ctx) {
171
+ return actionList.value.filter(({ visible }) => typeof visible === "function" ? visible(ctx) : visible !== false);
172
+ }
173
+ function actionButtonProps(action, ctx) {
174
+ const { key: _key, visible: _visible, onClick: _onClick, ...rest } = action;
175
+ const isSearch = action.key === "search" || action.type === "submit";
176
+ return {
177
+ size: resolvedButtonSize.value,
178
+ disabled: attrs.disabled,
179
+ ...rest,
180
+ loading: isSearch ? ctx.loading : rest.loading
181
+ };
156
182
  }
157
183
  function handleAction(action, ctx) {
158
184
  if (action.onClick) {
@@ -163,26 +189,18 @@ function handleAction(action, ctx) {
163
189
  if (action.key === "reset") reset();
164
190
  else if (action.key === "search") submit();
165
191
  }
166
- function actionLoading(action, ctx) {
167
- if (action.key === "search" || action.type === "submit") return ctx.loading;
168
- return false;
169
- }
170
- watch(() => fields.value, () => {
171
- applyFieldDefaults(fields.value, modelValue.value);
172
- }, { flush: "post" });
173
- watch(() => props.schema, () => {
174
- formRef.value?.clear();
175
- });
176
- onMounted(() => {
177
- applyFieldDefaults(fields.value, modelValue.value);
178
- setBaseline();
179
- });
192
+ watch(() => props.schema, () => formRef.value?.clear());
180
193
  defineExpose({
181
194
  formRef,
182
195
  submit,
196
+ validate,
183
197
  reset,
184
198
  clear,
185
- setBaseline,
199
+ setBaseline: core.setBaseline,
200
+ isDirty: core.isDirty,
201
+ dirtyFields: core.dirtyFields,
202
+ getFieldValue: core.getFieldValue,
203
+ setFieldValue: core.setFieldValue,
186
204
  expanded,
187
205
  toggle
188
206
  });
@@ -193,12 +211,13 @@ defineExpose({
193
211
  <UForm
194
212
  ref="formRef"
195
213
  :state="modelValue"
196
- :schema="pureSchema"
214
+ :schema="validationSchema"
197
215
  :loading-auto="props.loadingAuto"
198
216
  :validate-on="props.validateOn"
199
217
  :ui="baseUi"
200
218
  data-slot="form"
201
219
  v-bind="attrs"
220
+ :on-submit="handleSubmit"
202
221
  @error="emits('error', $event)"
203
222
  >
204
223
  <template #default="{ errors, loading }">
@@ -212,7 +231,6 @@ defineExpose({
212
231
  v-for="field in visibleFields"
213
232
  :key="field.path"
214
233
  :field="field"
215
- :schema="props.schema"
216
234
  :extra-props="{ errors, loading, state: modelValue }"
217
235
  />
218
236
 
@@ -224,14 +242,7 @@ defineExpose({
224
242
  <div :class="extraUi.actions" data-slot="actions">
225
243
  <template v-for="action in resolveActions(buildSlotProps(errors, loading))" :key="action.key">
226
244
  <UButton
227
- :label="action.label"
228
- :type="action.type"
229
- :icon="action.icon"
230
- :color="action.color"
231
- :variant="action.variant"
232
- :loading="actionLoading(action, buildSlotProps(errors, loading))"
233
- :size="resolvedButtonSize"
234
- v-bind="action"
245
+ v-bind="actionButtonProps(action, buildSlotProps(errors, loading))"
235
246
  @click="handleAction(action, buildSlotProps(errors, loading))"
236
247
  />
237
248
  </template>
@@ -248,7 +259,6 @@ defineExpose({
248
259
  v-for="field in collapsedFields"
249
260
  :key="field.path"
250
261
  :field="field"
251
- :schema="props.schema"
252
262
  :extra-props="{ errors, loading, state: modelValue }"
253
263
  />
254
264
  </div>
@@ -262,7 +272,7 @@ defineExpose({
262
272
  :size="resolvedButtonSize"
263
273
  variant="ghost"
264
274
  :data-state="expanded ? 'open' : 'closed'"
265
- :label="expanded ? collapseText : expandText"
275
+ :label="expanded ? collapseText ?? t('searchForm.collapse') : expandText ?? t('searchForm.expand')"
266
276
  tabindex="-1"
267
277
  :class="extraUi.toggle"
268
278
  v-bind="collapseButtonProps"
@@ -8,7 +8,7 @@ declare const __VLS_export: <S extends z.ZodObject>(__VLS_props: NonNullable<Awa
8
8
  ui?: ComponentConfig<typeof theme, AppConfig, "searchForm">["slots"];
9
9
  } & {
10
10
  modelValue?: Partial<InferInput<S>>;
11
- expanded?: boolean;
11
+ expanded?: boolean | undefined;
12
12
  }) & {
13
13
  onError?: ((event: import("@nuxt/ui").FormErrorEvent) => any) | undefined;
14
14
  onClear?: ((state: Partial<InferInput<S>>) => any) | undefined;
@@ -16,21 +16,29 @@ declare const __VLS_export: <S extends z.ZodObject>(__VLS_props: NonNullable<Awa
16
16
  "onUpdate:modelValue"?: ((value: Partial<InferInput<S>>) => any) | undefined;
17
17
  onExpand?: ((expanded: boolean) => any) | undefined;
18
18
  "onUpdate:expanded"?: ((value: boolean | undefined) => any) | undefined;
19
+ "onQuery-restore"?: ((state: Partial<InferInput<S>>) => any) | undefined;
19
20
  }> & (typeof globalThis extends {
20
21
  __VLS_PROPS_FALLBACK: infer P;
21
22
  } ? P : {});
22
23
  expose: (exposed: import("vue").ShallowUnwrapRef<{
23
24
  formRef: Readonly<import("vue").ShallowRef<any, any>>;
24
- submit: () => void;
25
+ submit: () => Promise<any>;
26
+ validate: any;
25
27
  reset: () => void;
26
28
  clear: () => void;
27
- setBaseline: (value?: Partial<InferInput<S>>) => void;
29
+ setBaseline: (value?: {
30
+ [x: string]: any;
31
+ }) => void;
32
+ isDirty: import("vue").ComputedRef<boolean>;
33
+ dirtyFields: import("vue").ComputedRef<string[]>;
34
+ getFieldValue: (path: string) => unknown;
35
+ setFieldValue: (path: string, value: unknown) => void;
28
36
  expanded: import("vue").WritableComputedRef<boolean, boolean>;
29
37
  toggle: () => void;
30
38
  }>) => void;
31
39
  attrs: any;
32
40
  slots: SearchFormSlots<S>;
33
- emit: (((evt: "error", event: import("@nuxt/ui").FormErrorEvent) => void) & ((evt: "clear", state: Partial<InferInput<S>>) => void) & ((evt: "reset", state: Partial<InferInput<S>>) => void) & ((evt: "expand", expanded: boolean) => void) & ((evt: "update:expanded", expanded: boolean) => void)) & (((event: "update:modelValue", value: Partial<InferInput<S>>) => void) & ((event: "update:expanded", value: boolean | undefined) => void));
41
+ emit: (((evt: "error", event: import("@nuxt/ui").FormErrorEvent) => void) & ((evt: "clear", state: Partial<InferInput<S>>) => void) & ((evt: "reset", state: Partial<InferInput<S>>) => void) & ((evt: "expand", expanded: boolean) => void) & ((evt: "query-restore", state: Partial<InferInput<S>>) => void)) & (((event: "update:modelValue", value: Partial<InferInput<S>>) => void) & ((event: "update:expanded", value: boolean | undefined) => void));
34
42
  }>) => import("vue").VNode & {
35
43
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
36
44
  };
@@ -18,6 +18,8 @@ declare const __VLS_export: <T extends TreeItem[] = TreeItem[], M extends boolea
18
18
  selection: import("../types").TreeSelectionResult<T[number]>;
19
19
  }) => any) | undefined;
20
20
  "onUpdate:modelValue"?: ((value: (M extends true ? T[number][] : T[number]) | undefined) => any) | undefined;
21
+ onLoadError?: ((node: T[number], error: unknown) => any) | undefined;
22
+ onSearchError?: ((term: string, error: unknown) => any) | undefined;
21
23
  "onUpdate:expanded"?: ((val: string[]) => any) | undefined;
22
24
  "onUpdate:search"?: ((value: string) => any) | undefined;
23
25
  "onUpdate:selectedKeys"?: ((value: string[] | undefined) => any) | undefined;
@@ -31,7 +33,7 @@ declare const __VLS_export: <T extends TreeItem[] = TreeItem[], M extends boolea
31
33
  value: (M extends true ? T[number][] : T[number]) | undefined;
32
34
  keys: string[];
33
35
  selection: import("../types").TreeSelectionResult<T[number]>;
34
- }) => void) & ((evt: "update:modelValue", val: M extends true ? T[number][] : T[number]) => void) & ((evt: "update:expanded", val: string[]) => void) & ((evt: "update:search", value: string) => void)) & (((event: "update:modelValue", value: (M extends true ? T[number][] : T[number]) | undefined) => void) & ((event: "update:expanded", value: string[]) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selectedKeys", value: string[] | undefined) => void));
36
+ }) => void) & ((evt: "update:modelValue", val: M extends true ? T[number][] : T[number]) => void) & ((evt: "loadError", node: T[number], error: unknown) => void) & ((evt: "searchError", term: string, error: unknown) => void) & ((evt: "update:expanded", val: string[]) => void) & ((evt: "update:search", value: string) => void)) & (((event: "update:modelValue", value: (M extends true ? T[number][] : T[number]) | undefined) => void) & ((event: "update:expanded", value: string[]) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selectedKeys", value: string[] | undefined) => void));
35
37
  }>) => import("vue").VNode & {
36
38
  __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
37
39
  };