@movk/nuxt 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/.nuxt/movk-ui.css +3 -0
  2. package/README.md +74 -79
  3. package/dist/module.d.mts +57 -1
  4. package/dist/module.json +2 -2
  5. package/dist/module.mjs +120 -126
  6. package/dist/runtime/components/AutoForm.d.vue.ts +10 -30
  7. package/dist/runtime/components/AutoForm.vue +114 -125
  8. package/dist/runtime/components/AutoForm.vue.d.ts +10 -30
  9. package/dist/runtime/components/ColorChooser.d.vue.ts +21 -22
  10. package/dist/runtime/components/ColorChooser.vue +304 -27
  11. package/dist/runtime/components/ColorChooser.vue.d.ts +21 -22
  12. package/dist/runtime/components/DataTable.d.vue.ts +57 -0
  13. package/dist/runtime/components/DataTable.vue +584 -0
  14. package/dist/runtime/components/DataTable.vue.d.ts +57 -0
  15. package/dist/runtime/components/DatePicker.d.vue.ts +20 -33
  16. package/dist/runtime/components/DatePicker.vue +173 -65
  17. package/dist/runtime/components/DatePicker.vue.d.ts +20 -33
  18. package/dist/runtime/components/MessageBox.d.vue.ts +36 -0
  19. package/dist/runtime/components/MessageBox.vue +113 -0
  20. package/dist/runtime/components/MessageBox.vue.d.ts +36 -0
  21. package/dist/runtime/components/PillGroup.d.vue.ts +33 -0
  22. package/dist/runtime/components/PillGroup.vue +291 -0
  23. package/dist/runtime/components/PillGroup.vue.d.ts +33 -0
  24. package/dist/runtime/components/Popconfirm.d.vue.ts +30 -0
  25. package/dist/runtime/components/Popconfirm.vue +143 -0
  26. package/dist/runtime/components/Popconfirm.vue.d.ts +30 -0
  27. package/dist/runtime/components/SearchForm.d.vue.ts +21 -149
  28. package/dist/runtime/components/SearchForm.vue +211 -153
  29. package/dist/runtime/components/SearchForm.vue.d.ts +21 -149
  30. package/dist/runtime/components/SlideVerify.d.vue.ts +31 -70
  31. package/dist/runtime/components/SlideVerify.vue +117 -90
  32. package/dist/runtime/components/SlideVerify.vue.d.ts +31 -70
  33. package/dist/runtime/components/StarRating.d.vue.ts +38 -87
  34. package/dist/runtime/components/StarRating.vue +118 -74
  35. package/dist/runtime/components/StarRating.vue.d.ts +38 -87
  36. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +11 -15
  37. package/dist/runtime/components/input/AsPhoneNumberInput.vue +22 -9
  38. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +11 -15
  39. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -13
  40. package/dist/runtime/components/input/WithCharacterLimit.vue +23 -11
  41. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -13
  42. package/dist/runtime/components/input/WithClear.d.vue.ts +13 -11
  43. package/dist/runtime/components/input/WithClear.vue +27 -8
  44. package/dist/runtime/components/input/WithClear.vue.d.ts +13 -11
  45. package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -13
  46. package/dist/runtime/components/input/WithCopy.vue +25 -8
  47. package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -13
  48. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +13 -16
  49. package/dist/runtime/components/input/WithFloatingLabel.vue +35 -27
  50. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +13 -16
  51. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -7
  52. package/dist/runtime/components/input/WithPasswordToggle.vue +24 -7
  53. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -7
  54. package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
  55. package/dist/runtime/components/theme-picker/ThemePicker.vue +27 -12
  56. package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
  57. package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +9 -4
  58. package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
  59. package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +9 -4
  60. package/dist/runtime/composables/index.d.ts +9 -8
  61. package/dist/runtime/composables/index.js +1 -0
  62. package/dist/runtime/composables/useApiFetch.d.ts +10 -5
  63. package/dist/runtime/composables/useApiFetch.js +20 -2
  64. package/dist/runtime/composables/useAutoForm.d.ts +4 -4
  65. package/dist/runtime/composables/useAutoForm.js +23 -9
  66. package/dist/runtime/composables/useClientApiFetch.d.ts +3 -2
  67. package/dist/runtime/composables/useDateFormatter.d.ts +16 -3
  68. package/dist/runtime/composables/useDateFormatter.js +89 -30
  69. package/dist/runtime/composables/useDownloadWithProgress.d.ts +26 -27
  70. package/dist/runtime/composables/useDownloadWithProgress.js +142 -40
  71. package/dist/runtime/composables/useLazyApiFetch.d.ts +3 -2
  72. package/dist/runtime/composables/useMessageBox.d.ts +6 -0
  73. package/dist/runtime/composables/useMessageBox.js +16 -0
  74. package/dist/runtime/composables/useTheme.d.ts +26 -16
  75. package/dist/runtime/composables/useTheme.js +98 -71
  76. package/dist/runtime/composables/useUploadWithProgress.d.ts +23 -29
  77. package/dist/runtime/composables/useUploadWithProgress.js +78 -67
  78. package/dist/runtime/domains/api/auth.d.ts +2 -0
  79. package/dist/runtime/domains/api/auth.js +31 -0
  80. package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
  81. package/dist/runtime/domains/api/endpoint-config.js +17 -0
  82. package/dist/runtime/domains/api/errors.d.ts +2 -0
  83. package/dist/runtime/domains/api/errors.js +10 -0
  84. package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
  85. package/dist/runtime/domains/api/fetch-key.js +23 -0
  86. package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
  87. package/dist/runtime/domains/api/interceptors/error.js +49 -0
  88. package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
  89. package/dist/runtime/domains/api/interceptors/request.js +46 -0
  90. package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
  91. package/dist/runtime/domains/api/interceptors/response.js +27 -0
  92. package/dist/runtime/domains/api/response.d.ts +4 -0
  93. package/dist/runtime/domains/api/response.js +14 -0
  94. package/dist/runtime/domains/api/toast.d.ts +15 -0
  95. package/dist/runtime/domains/api/toast.js +46 -0
  96. package/dist/runtime/domains/api/transfer.d.ts +69 -0
  97. package/dist/runtime/domains/api/transfer.js +81 -0
  98. package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
  99. package/dist/runtime/domains/auto-form/actions.js +4 -0
  100. package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
  101. package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +25 -29
  102. package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
  103. package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
  104. package/dist/runtime/{components/auto-form-renderer/AutoFormRendererChildren.vue → domains/auto-form/components/Children.vue} +18 -18
  105. package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
  106. package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
  107. package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
  108. package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
  109. package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
  110. package/dist/runtime/{components/auto-form-renderer/AutoFormRendererLayout.vue → domains/auto-form/components/Layout.vue} +24 -25
  111. package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
  112. package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
  113. package/dist/runtime/{components/auto-form-renderer/AutoFormRendererNested.vue → domains/auto-form/components/Nested.vue} +17 -21
  114. package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
  115. package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
  116. package/dist/runtime/{auto-form → domains/auto-form}/controls.js +27 -24
  117. package/dist/runtime/{auto-form/field-utils.d.ts → domains/auto-form/fields.d.ts} +3 -1
  118. package/dist/runtime/{auto-form/field-utils.js → domains/auto-form/fields.js} +18 -2
  119. package/dist/runtime/{auto-form → domains/auto-form}/metadata.js +1 -1
  120. package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
  121. package/dist/runtime/{auto-form → domains/auto-form}/provider.js +6 -3
  122. package/dist/runtime/{auto-form/reactive-utils.d.ts → domains/auto-form/reactive.d.ts} +5 -5
  123. package/dist/runtime/{auto-form/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
  124. package/dist/runtime/{auto-form/schema-introspector.d.ts → domains/auto-form/schema.d.ts} +2 -2
  125. package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +1 -1
  126. package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
  127. package/dist/runtime/domains/data-table/columns/constants.js +19 -0
  128. package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
  129. package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
  130. package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
  131. package/dist/runtime/domains/data-table/columns/resolve-data-column.js +164 -0
  132. package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
  133. package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
  134. package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
  135. package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
  136. package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
  137. package/dist/runtime/domains/data-table/columns/style.js +67 -0
  138. package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
  139. package/dist/runtime/domains/data-table/columns/utils.js +16 -0
  140. package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
  141. package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
  142. package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
  143. package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
  144. package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
  145. package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
  146. package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
  147. package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
  148. package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
  149. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
  150. package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
  151. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
  152. package/dist/runtime/domains/data-table/indent.d.ts +8 -0
  153. package/dist/runtime/domains/data-table/indent.js +19 -0
  154. package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
  155. package/dist/runtime/domains/data-table/tree-selection.js +76 -0
  156. package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
  157. package/dist/runtime/index.css +1 -0
  158. package/dist/runtime/plugins/api.factory.js +17 -117
  159. package/dist/runtime/plugins/theme.js +49 -27
  160. package/dist/runtime/types/api/config.d.ts +127 -0
  161. package/dist/runtime/types/api/fetch.d.ts +50 -0
  162. package/dist/runtime/types/api/index.d.ts +5 -0
  163. package/dist/runtime/types/api/module.d.ts +94 -0
  164. package/dist/runtime/types/api/response.d.ts +62 -0
  165. package/dist/runtime/types/api/response.js +0 -0
  166. package/dist/runtime/types/api/transfer.d.ts +32 -0
  167. package/dist/runtime/types/api/transfer.js +0 -0
  168. package/dist/runtime/types/app.config.d.ts +6 -0
  169. package/dist/runtime/types/auto-form/base.d.ts +26 -0
  170. package/dist/runtime/types/auto-form/base.js +0 -0
  171. package/dist/runtime/types/auto-form/component.d.ts +28 -0
  172. package/dist/runtime/types/auto-form/component.js +0 -0
  173. package/dist/runtime/types/auto-form/controls.d.ts +45 -0
  174. package/dist/runtime/types/auto-form/controls.js +0 -0
  175. package/dist/runtime/types/auto-form/fields.d.ts +68 -0
  176. package/dist/runtime/types/auto-form/fields.js +0 -0
  177. package/dist/runtime/types/auto-form/index.d.ts +7 -0
  178. package/dist/runtime/types/auto-form/index.js +0 -0
  179. package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
  180. package/dist/runtime/types/auto-form/search-form.js +0 -0
  181. package/dist/runtime/types/auto-form/slots.d.ts +85 -0
  182. package/dist/runtime/types/auto-form/slots.js +0 -0
  183. package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
  184. package/dist/runtime/types/auto-form/zod-factory.js +0 -0
  185. package/dist/runtime/types/components/color-chooser.d.ts +109 -0
  186. package/dist/runtime/types/components/color-chooser.js +0 -0
  187. package/dist/runtime/types/components/date-picker.d.ts +41 -0
  188. package/dist/runtime/types/components/date-picker.js +0 -0
  189. package/dist/runtime/types/components/index.d.ts +8 -0
  190. package/dist/runtime/types/components/index.js +0 -0
  191. package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
  192. package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
  193. package/dist/runtime/types/components/input/index.d.ts +6 -0
  194. package/dist/runtime/types/components/input/index.js +0 -0
  195. package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
  196. package/dist/runtime/types/components/input/with-character-limit.js +0 -0
  197. package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
  198. package/dist/runtime/types/components/input/with-clear.js +0 -0
  199. package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
  200. package/dist/runtime/types/components/input/with-copy.js +0 -0
  201. package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
  202. package/dist/runtime/types/components/input/with-floating-label.js +0 -0
  203. package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
  204. package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
  205. package/dist/runtime/types/components/message-box.d.ts +69 -0
  206. package/dist/runtime/types/components/message-box.js +0 -0
  207. package/dist/runtime/types/components/pill-group.d.ts +103 -0
  208. package/dist/runtime/types/components/pill-group.js +0 -0
  209. package/dist/runtime/types/components/popconfirm.d.ts +74 -0
  210. package/dist/runtime/types/components/popconfirm.js +0 -0
  211. package/dist/runtime/types/components/slide-verify.d.ts +54 -0
  212. package/dist/runtime/types/components/slide-verify.js +0 -0
  213. package/dist/runtime/types/components/star-rating.d.ts +55 -0
  214. package/dist/runtime/types/components/star-rating.js +0 -0
  215. package/dist/runtime/types/data-table/columns.d.ts +236 -0
  216. package/dist/runtime/types/data-table/columns.js +6 -0
  217. package/dist/runtime/types/data-table/component.d.ts +190 -0
  218. package/dist/runtime/types/data-table/component.js +0 -0
  219. package/dist/runtime/types/data-table/contexts.d.ts +44 -0
  220. package/dist/runtime/types/data-table/contexts.js +0 -0
  221. package/dist/runtime/types/data-table/index.d.ts +6 -0
  222. package/dist/runtime/types/data-table/index.js +1 -0
  223. package/dist/runtime/types/data-table/pagination.d.ts +87 -0
  224. package/dist/runtime/types/data-table/pagination.js +0 -0
  225. package/dist/runtime/types/index.d.ts +6 -5
  226. package/dist/runtime/types/index.js +5 -5
  227. package/dist/runtime/types/shared.d.ts +5 -0
  228. package/dist/runtime/types/shared.js +0 -0
  229. package/dist/runtime/types/zod.d.ts +11 -10
  230. package/dist/runtime/utils/extend-theme.d.ts +19 -0
  231. package/dist/runtime/utils/extend-theme.js +44 -0
  232. package/dist/runtime/utils/form-control.d.ts +33 -0
  233. package/dist/runtime/utils/form-control.js +54 -0
  234. package/dist/runtime/utils/meta.d.ts +2 -5
  235. package/dist/runtime/utils/meta.js +1 -3
  236. package/dist/runtime/utils/theme-defaults.d.ts +27 -0
  237. package/dist/runtime/utils/theme-defaults.js +28 -0
  238. package/dist/runtime/utils/tv.d.ts +1 -0
  239. package/dist/runtime/utils/tv.js +4 -0
  240. package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
  241. package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
  242. package/dist/runtime/vue/plugins/theme.d.ts +6 -0
  243. package/dist/runtime/vue/plugins/theme.js +14 -0
  244. package/dist/runtime/vue/stubs/base.d.ts +2 -0
  245. package/dist/runtime/vue/stubs/base.js +2 -0
  246. package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
  247. package/dist/runtime/vue/stubs/inertia.js +2 -0
  248. package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
  249. package/dist/runtime/vue/stubs/movk-extra.js +2 -0
  250. package/dist/runtime/vue/stubs/none.d.ts +2 -0
  251. package/dist/runtime/vue/stubs/none.js +2 -0
  252. package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
  253. package/dist/runtime/vue/stubs/vue-router.js +2 -0
  254. package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
  255. package/dist/types.d.mts +2 -6
  256. package/dist/unplugin.d.mts +28 -0
  257. package/dist/unplugin.mjs +292 -0
  258. package/dist/vite.d.mts +12 -0
  259. package/dist/vite.mjs +20 -0
  260. package/package.json +75 -36
  261. package/vue-plugin.d.ts +5 -0
  262. package/dist/runtime/auto-form/controls.d.ts +0 -221
  263. package/dist/runtime/auto-form/provider.d.ts +0 -27
  264. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -28
  265. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -28
  266. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +0 -26
  267. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +0 -26
  268. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -26
  269. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
  270. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -26
  271. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -26
  272. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -26
  273. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -26
  274. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -26
  275. package/dist/runtime/constants/api-defaults.d.ts +0 -9
  276. package/dist/runtime/constants/api-defaults.js +0 -32
  277. package/dist/runtime/constants/grid-cols.d.ts +0 -7
  278. package/dist/runtime/constants/grid-cols.js +0 -44
  279. package/dist/runtime/style.css +0 -1
  280. package/dist/runtime/types/api.d.ts +0 -349
  281. package/dist/runtime/types/auto-form.d.ts +0 -259
  282. package/dist/runtime/types/module.d.ts +0 -96
  283. package/dist/runtime/types/theme.d.ts +0 -2
  284. package/dist/runtime/utils/api-utils.d.ts +0 -58
  285. package/dist/runtime/utils/api-utils.js +0 -98
  286. /package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -0
  287. /package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -0
  288. /package/dist/runtime/{auto-form → domains/auto-form}/metadata.d.ts +0 -0
  289. /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
  290. /package/dist/runtime/types/{api.js → api/config.js} +0 -0
  291. /package/dist/runtime/types/{auto-form.js → api/fetch.js} +0 -0
  292. /package/dist/runtime/types/{module.js → api/index.js} +0 -0
  293. /package/dist/runtime/types/{theme.js → api/module.js} +0 -0
@@ -1,32 +1,43 @@
1
1
  <script setup>
2
- import { computed, useAttrs } from "vue";
2
+ import { useAttrs } from "vue";
3
3
  import { UInput, UButton } from "#components";
4
4
  import { isEmpty } from "@movk/core";
5
+ import { useAppConfig } from "#imports";
6
+ import theme from "#build/movk-ui/with-floating-label";
7
+ import inputTheme from "#build/ui/input";
8
+ import { useExtendedTv } from "../../utils/extend-theme";
9
+ import { useFormFieldBridge, useForwardedProps } from "../../utils/form-control";
5
10
  const props = defineProps({
6
11
  label: { type: String, required: false },
7
- labelClass: { type: [Array, String, null, Number, Boolean], required: false, skipCheck: true },
8
- clearButtonProps: { type: Object, required: false }
12
+ size: { type: null, required: false },
13
+ clearButtonProps: { type: Object, required: false },
14
+ ui: { type: Object, required: false }
9
15
  });
10
- const emit = defineEmits(["update:modelValue", "blur", "change", "clear"]);
16
+ const emits = defineEmits(["update:modelValue", "blur", "change", "clear"]);
11
17
  const slots = defineSlots();
12
18
  defineOptions({ inheritAttrs: false });
13
19
  const attrs = useAttrs();
20
+ const appConfig = useAppConfig();
14
21
  const modelValue = defineModel({ type: null });
15
- const labelLeftClass = computed(() => {
16
- const hasLeading = !!(attrs["leading-icon"] || attrs.avatar || attrs.leadingIcon || slots.leading);
17
- if (!hasLeading) return "left-0";
18
- const offsetMap = {
19
- xs: "left-5",
20
- sm: "left-6",
21
- md: "left-7",
22
- lg: "left-8",
23
- xl: "left-9"
24
- };
25
- return offsetMap[attrs.size ?? "md"] ?? "left-7";
26
- });
22
+ const inputProps = useForwardedProps(props, ["ui", "label", "clearButtonProps", "placeholder", "defaultValue", "modelModifiers"]);
23
+ const { size: effectiveSize, emitFormChange, emitFormInput } = useFormFieldBridge(props);
24
+ const { baseUi, extraUi } = useExtendedTv(
25
+ inputTheme,
26
+ theme,
27
+ () => appConfig.movk?.withFloatingLabel,
28
+ () => ({
29
+ ui: props.ui,
30
+ variants: {
31
+ size: effectiveSize.value,
32
+ hasLeading: !!(attrs["leading-icon"] || attrs.avatar || attrs.leadingIcon || attrs.icon || slots.leading)
33
+ }
34
+ })
35
+ );
27
36
  function handleClear() {
28
37
  modelValue.value = void 0;
29
- emit("clear");
38
+ emitFormInput();
39
+ emitFormChange();
40
+ emits("clear");
30
41
  }
31
42
  </script>
32
43
 
@@ -34,21 +45,18 @@ function handleClear() {
34
45
  <UInput
35
46
  v-model="modelValue"
36
47
  :placeholder="props.placeholder ?? ''"
37
- :ui="{ base: 'peer', trailing: 'pe-1' }"
38
- v-bind="$attrs"
39
- @blur="emit('blur', $event)"
40
- @change="emit('change', $event)"
48
+ :ui="baseUi"
49
+ v-bind="{ ...inputProps, ...attrs }"
50
+ @blur="emits('blur', $event)"
51
+ @change="emits('change', $event)"
41
52
  >
42
53
  <template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
43
54
  <slot :name="slotName" v-bind="slotProps ?? {}" />
44
55
  </template>
45
56
 
46
57
  <template v-if="props.label" #default>
47
- <label
48
- class="pointer-events-none absolute -top-2.5 text-highlighted text-xs font-medium px-1.5 transition-all peer-focus:-top-2.5 peer-focus:text-highlighted peer-focus:text-xs peer-focus:font-medium peer-placeholder-shown:text-sm peer-placeholder-shown:text-dimmed peer-placeholder-shown:top-1.5 peer-placeholder-shown:font-normal"
49
- :class="[labelLeftClass, props.labelClass]"
50
- >
51
- <span class="inline-flex bg-default px-1">{{ props.label }}</span>
58
+ <label :class="extraUi.label">
59
+ <span :class="extraUi.labelText">{{ props.label }}</span>
52
60
  </label>
53
61
  </template>
54
62
 
@@ -56,7 +64,7 @@ function handleClear() {
56
64
  <UButton
57
65
  color="neutral"
58
66
  variant="link"
59
- size="sm"
67
+ :size="effectiveSize"
60
68
  icon="i-lucide-circle-x"
61
69
  aria-label="Clear input"
62
70
  v-bind="props.clearButtonProps"
@@ -1,29 +1,26 @@
1
- import { type OmitByKey } from '@movk/core';
2
- import type { ButtonProps, InputEmits, InputProps, InputSlots, InputValue } from '@nuxt/ui';
3
- import type { ClassNameValue } from '../../types/index.js';
4
- export interface WithFloatingLabelProps<T extends InputValue = InputValue> extends /** @vue-ignore */ OmitByKey<InputProps<T>, 'modelValue'> {
5
- /** 浮动标签文本 */
6
- label?: string;
7
- /** 浮动标签的自定义样式类 */
8
- labelClass?: ClassNameValue;
9
- /** 清除按钮的自定义属性 */
10
- clearButtonProps?: ButtonProps;
11
- }
12
- export type WithFloatingLabelEmits<T extends InputValue = InputValue> = InputEmits<T> & {
13
- clear: [];
14
- };
1
+ import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
2
+ import type { OmitByKey } from '@movk/core';
3
+ import theme from '#build/movk-ui/with-floating-label';
4
+ import inputTheme from '#build/ui/input';
5
+ import type { AppConfig } from 'nuxt/schema';
6
+ import type { WithFloatingLabelProps } from '../../types/components/input/with-floating-label';
15
7
  declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
16
8
  props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithFloatingLabelProps<T> & {
9
+ ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withFloatingLabel">["slots"];
10
+ } & {
17
11
  modelValue?: T;
18
12
  }) & {
19
- [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
13
+ onClear?: (() => any) | undefined;
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
15
+ onChange?: ((event: Event) => any) | undefined;
16
+ "onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
20
17
  }> & (typeof globalThis extends {
21
18
  __VLS_PROPS_FALLBACK: infer P;
22
19
  } ? P : {});
23
20
  expose: (exposed: {}) => void;
24
21
  attrs: any;
25
22
  slots: OmitByKey<InputSlots, "default" | "trailing">;
26
- emit: any & ((event: "update:modelValue", value: T | undefined) => void);
23
+ emit: (((evt: "clear") => void) & ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
27
24
  }>) => import("vue").VNode & {
28
25
  __ctx?: Awaited<typeof __VLS_setup>;
29
26
  };
@@ -1,21 +1,25 @@
1
+ import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
1
2
  import type { OmitByKey } from '@movk/core';
2
- import type { ButtonProps, InputProps, InputSlots, InputValue } from '@nuxt/ui';
3
- export interface WithPasswordToggleProps<T extends InputValue = InputValue> extends /** @vue-ignore */ OmitByKey<InputProps<T>, 'type' | 'modelValue'> {
4
- /** 切换按钮的自定义属性 */
5
- buttonProps?: ButtonProps;
6
- }
3
+ import theme from '#build/movk-ui/with-password-toggle';
4
+ import inputTheme from '#build/ui/input';
5
+ import type { AppConfig } from 'nuxt/schema';
6
+ import type { WithPasswordToggleProps } from '../../types/components/input/with-password-toggle';
7
7
  declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
8
8
  props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
9
+ ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
10
+ } & {
9
11
  modelValue?: T;
10
12
  }) & {
11
- [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
13
+ onBlur?: ((event: FocusEvent) => any) | undefined;
14
+ onChange?: ((event: Event) => any) | undefined;
15
+ "onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
12
16
  }> & (typeof globalThis extends {
13
17
  __VLS_PROPS_FALLBACK: infer P;
14
18
  } ? P : {});
15
19
  expose: (exposed: {}) => void;
16
20
  attrs: any;
17
21
  slots: OmitByKey<InputSlots, "trailing">;
18
- emit: any & ((event: "update:modelValue", value: T | undefined) => void);
22
+ emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
19
23
  }>) => import("vue").VNode & {
20
24
  __ctx?: Awaited<typeof __VLS_setup>;
21
25
  };
@@ -1,13 +1,30 @@
1
1
  <script setup>
2
+ import { useAttrs } from "vue";
2
3
  import { UInput, UButton } from "#components";
3
4
  import { useToggle } from "@vueuse/core";
5
+ import { useAppConfig } from "#imports";
6
+ import theme from "#build/movk-ui/with-password-toggle";
7
+ import inputTheme from "#build/ui/input";
8
+ import { useExtendedTv } from "../../utils/extend-theme";
9
+ import { useFormFieldBridge, useForwardedProps } from "../../utils/form-control";
4
10
  const props = defineProps({
5
- buttonProps: { type: Object, required: false }
11
+ buttonProps: { type: Object, required: false },
12
+ ui: { type: Object, required: false }
6
13
  });
7
- const emit = defineEmits(["update:modelValue", "blur", "change"]);
14
+ const emits = defineEmits(["update:modelValue", "blur", "change"]);
8
15
  const slots = defineSlots();
9
16
  defineOptions({ inheritAttrs: false });
17
+ const attrs = useAttrs();
18
+ const appConfig = useAppConfig();
10
19
  const modelValue = defineModel({ type: null });
20
+ const inputProps = useForwardedProps(props, ["ui", "buttonProps", "defaultValue", "modelModifiers"]);
21
+ const { size: buttonSize } = useFormFieldBridge(props);
22
+ const { baseUi } = useExtendedTv(
23
+ inputTheme,
24
+ theme,
25
+ () => appConfig.movk?.withPasswordToggle,
26
+ () => ({ ui: props.ui })
27
+ );
11
28
  const [value, toggle] = useToggle(false);
12
29
  </script>
13
30
 
@@ -15,10 +32,10 @@ const [value, toggle] = useToggle(false);
15
32
  <UInput
16
33
  v-model="modelValue"
17
34
  :type="value ? 'text' : 'password'"
18
- :ui="{ trailing: 'pe-1' }"
19
- v-bind="$attrs"
20
- @blur="emit('blur', $event)"
21
- @change="emit('change', $event)"
35
+ :ui="baseUi"
36
+ v-bind="{ ...inputProps, ...attrs }"
37
+ @blur="emits('blur', $event)"
38
+ @change="emits('change', $event)"
22
39
  >
23
40
  <template v-for="(_, slotName) in slots" :key="slotName" #[slotName]="slotProps">
24
41
  <slot :name="slotName" v-bind="slotProps ?? {}" />
@@ -28,7 +45,7 @@ const [value, toggle] = useToggle(false);
28
45
  <UButton
29
46
  color="neutral"
30
47
  variant="link"
31
- size="sm"
48
+ :size="buttonSize"
32
49
  :icon="value ? 'i-lucide-eye-off' : 'i-lucide-eye'"
33
50
  :aria-label="value ? 'Hide password' : 'Show password'"
34
51
  :aria-pressed="value"
@@ -1,21 +1,25 @@
1
+ import type { InputSlots, InputValue, ComponentConfig } from '@nuxt/ui';
1
2
  import type { OmitByKey } from '@movk/core';
2
- import type { ButtonProps, InputProps, InputSlots, InputValue } from '@nuxt/ui';
3
- export interface WithPasswordToggleProps<T extends InputValue = InputValue> extends /** @vue-ignore */ OmitByKey<InputProps<T>, 'type' | 'modelValue'> {
4
- /** 切换按钮的自定义属性 */
5
- buttonProps?: ButtonProps;
6
- }
3
+ import theme from '#build/movk-ui/with-password-toggle';
4
+ import inputTheme from '#build/ui/input';
5
+ import type { AppConfig } from 'nuxt/schema';
6
+ import type { WithPasswordToggleProps } from '../../types/components/input/with-password-toggle';
7
7
  declare const __VLS_export: <T extends InputValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
8
8
  props: import("vue").PublicProps & __VLS_PrettifyLocal<(WithPasswordToggleProps<T> & {
9
+ ui?: ComponentConfig<typeof inputTheme & typeof theme, AppConfig, "withPasswordToggle">["slots"];
10
+ } & {
9
11
  modelValue?: T;
10
12
  }) & {
11
- [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
13
+ onBlur?: ((event: FocusEvent) => any) | undefined;
14
+ onChange?: ((event: Event) => any) | undefined;
15
+ "onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
12
16
  }> & (typeof globalThis extends {
13
17
  __VLS_PROPS_FALLBACK: infer P;
14
18
  } ? P : {});
15
19
  expose: (exposed: {}) => void;
16
20
  attrs: any;
17
21
  slots: OmitByKey<InputSlots, "trailing">;
18
- emit: any & ((event: "update:modelValue", value: T | undefined) => void);
22
+ emit: (((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: T) => void)) & ((event: "update:modelValue", value: T | undefined) => void);
19
23
  }>) => import("vue").VNode & {
20
24
  __ctx?: Awaited<typeof __VLS_setup>;
21
25
  };
@@ -1,3 +1,10 @@
1
- declare const __VLS_export: any;
1
+ import type { ComponentConfig } from '@nuxt/ui';
2
+ import type { AppConfig } from 'nuxt/schema';
3
+ import theme from '#build/movk-ui/theme-picker';
4
+ import popoverTheme from '#build/ui/popover';
5
+ interface ThemePickerProps {
6
+ ui?: ComponentConfig<typeof popoverTheme & typeof theme, AppConfig, 'themePicker'>['slots'];
7
+ }
8
+ declare const __VLS_export: import("vue").DefineComponent<ThemePickerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
9
  declare const _default: typeof __VLS_export;
3
10
  export default _default;
@@ -1,19 +1,33 @@
1
1
  <script setup>
2
- import { useColorMode } from "#imports";
2
+ import { useAppConfig, useColorMode } from "#imports";
3
3
  import { useClipboard } from "@vueuse/core";
4
4
  import { ref } from "vue";
5
- import { useTheme } from "../../composables";
5
+ import { useTheme } from "../../composables/useTheme";
6
6
  import ThemePickerButton from "./ThemePickerButton.vue";
7
+ import theme from "#build/movk-ui/theme-picker";
8
+ import popoverTheme from "#build/ui/popover";
9
+ import { useExtendedTv } from "../../utils/extend-theme";
10
+ const props = defineProps({
11
+ ui: { type: Object, required: false }
12
+ });
13
+ const appConfig = useAppConfig();
7
14
  const colorMode = useColorMode();
15
+ const { extendUi } = useExtendedTv(
16
+ popoverTheme,
17
+ theme,
18
+ () => appConfig.movk?.themePicker,
19
+ () => ({ ui: props.ui })
20
+ );
8
21
  const open = ref(false);
9
22
  const { copy: copyCSS, copied: copiedCSS } = useClipboard();
10
- const { copy: copyAppConfig, copied: copiedAppConfig } = useClipboard();
23
+ const { copy: copyConfig, copied: copiedConfig } = useClipboard();
11
24
  const {
12
25
  neutralColors,
13
26
  neutral,
14
27
  primaryColors,
15
28
  primary,
16
29
  blackAsPrimary,
30
+ setBlackAsPrimary,
17
31
  radiuses,
18
32
  radius,
19
33
  fonts,
@@ -23,15 +37,16 @@ const {
23
37
  modes,
24
38
  mode,
25
39
  hasCSSChanges,
26
- hasAppConfigChanges,
40
+ hasConfigChanges,
41
+ configLabel,
27
42
  exportCSS,
28
- exportAppConfig,
43
+ exportConfig,
29
44
  resetTheme
30
45
  } = useTheme();
31
46
  </script>
32
47
 
33
48
  <template>
34
- <UPopover v-model:open="open" :ui="{ content: 'w-72 px-6 py-4 flex flex-col gap-4 overflow-y-auto max-h-[calc(100vh-5rem)]' }">
49
+ <UPopover v-model:open="open" :ui="extendUi">
35
50
  <template #default>
36
51
  <UButton
37
52
  icon="i-lucide-swatch-book"
@@ -63,7 +78,7 @@ const {
63
78
  <ThemePickerButton
64
79
  label="Black"
65
80
  :selected="blackAsPrimary"
66
- @click="blackAsPrimary = true"
81
+ @click="setBlackAsPrimary(true)"
67
82
  >
68
83
  <template #leading>
69
84
  <span class="inline-block size-2 rounded-full bg-black dark:bg-white" />
@@ -217,7 +232,7 @@ const {
217
232
  </div>
218
233
  </fieldset>
219
234
 
220
- <fieldset v-if="hasCSSChanges || hasAppConfigChanges">
235
+ <fieldset v-if="hasCSSChanges || hasConfigChanges">
221
236
  <legend class="text-[11px] leading-none font-semibold mb-2 select-none">
222
237
  Export
223
238
  </legend>
@@ -234,14 +249,14 @@ const {
234
249
  @click="copyCSS(exportCSS())"
235
250
  />
236
251
  <UButton
237
- v-if="hasAppConfigChanges"
252
+ v-if="hasConfigChanges"
238
253
  color="neutral"
239
254
  variant="soft"
240
255
  size="sm"
241
- label="app.config.ts"
242
- :icon="copiedAppConfig ? 'i-lucide-copy-check' : 'i-lucide-copy'"
256
+ :label="configLabel"
257
+ :icon="copiedConfig ? 'i-lucide-copy-check' : 'i-lucide-copy'"
243
258
  class="flex-1 text-[11px]"
244
- @click="copyAppConfig(exportAppConfig())"
259
+ @click="copyConfig(exportConfig())"
245
260
  />
246
261
  <UTooltip text="Reset theme">
247
262
  <UButton
@@ -1,3 +1,10 @@
1
- declare const __VLS_export: any;
1
+ import type { ComponentConfig } from '@nuxt/ui';
2
+ import type { AppConfig } from 'nuxt/schema';
3
+ import theme from '#build/movk-ui/theme-picker';
4
+ import popoverTheme from '#build/ui/popover';
5
+ interface ThemePickerProps {
6
+ ui?: ComponentConfig<typeof popoverTheme & typeof theme, AppConfig, 'themePicker'>['slots'];
7
+ }
8
+ declare const __VLS_export: import("vue").DefineComponent<ThemePickerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
9
  declare const _default: typeof __VLS_export;
3
10
  export default _default;
@@ -1,10 +1,15 @@
1
- type __VLS_Slots = {
1
+ interface ThemePickerButtonProps {
2
+ label: string;
3
+ icon?: string;
4
+ chip?: string;
5
+ selected?: boolean;
6
+ }
7
+ interface ThemePickerButtonSlots {
2
8
  leading: () => any;
3
- };
4
- declare const __VLS_base: any;
5
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ }
6
10
  declare const _default: typeof __VLS_export;
7
11
  export default _default;
12
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ThemePickerButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerButtonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ThemePickerButtonSlots>;
8
13
  type __VLS_WithSlots<T, S> = T & {
9
14
  new (): {
10
15
  $slots: S;
@@ -1,3 +1,7 @@
1
+ <script>
2
+
3
+ </script>
4
+
1
5
  <script setup>
2
6
  defineProps({
3
7
  label: { type: String, required: true },
@@ -1,10 +1,15 @@
1
- type __VLS_Slots = {
1
+ interface ThemePickerButtonProps {
2
+ label: string;
3
+ icon?: string;
4
+ chip?: string;
5
+ selected?: boolean;
6
+ }
7
+ interface ThemePickerButtonSlots {
2
8
  leading: () => any;
3
- };
4
- declare const __VLS_base: any;
5
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ }
6
10
  declare const _default: typeof __VLS_export;
7
11
  export default _default;
12
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ThemePickerButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ThemePickerButtonProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ThemePickerButtonSlots>;
8
13
  type __VLS_WithSlots<T, S> = T & {
9
14
  new (): {
10
15
  $slots: S;
@@ -1,8 +1,9 @@
1
- export * from './useApiFetch.js';
2
- export * from './useLazyApiFetch.js';
3
- export * from './useClientApiFetch.js';
4
- export * from './useDownloadWithProgress.js';
5
- export * from './useUploadWithProgress.js';
6
- export * from './useAutoForm.js';
7
- export * from './useTheme.js';
8
- export * from './useDateFormatter.js';
1
+ export * from './useApiFetch';
2
+ export * from './useLazyApiFetch';
3
+ export * from './useClientApiFetch';
4
+ export * from './useDownloadWithProgress';
5
+ export * from './useUploadWithProgress';
6
+ export * from './useAutoForm';
7
+ export * from './useTheme';
8
+ export * from './useDateFormatter';
9
+ export * from './useMessageBox';
@@ -6,3 +6,4 @@ export * from "./useUploadWithProgress.js";
6
6
  export * from "./useAutoForm.js";
7
7
  export * from "./useTheme.js";
8
8
  export * from "./useDateFormatter.js";
9
+ export * from "./useMessageBox.js";
@@ -1,11 +1,12 @@
1
- import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
1
+ import type { NitroFetchRequest } from 'nitropack/types';
2
+ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
2
3
  /**
3
4
  * API Fetch 组合式函数
4
5
  *
5
6
  * 基于 Nuxt useFetch 的薄封装,自动注入 $api 实例。
6
7
  * 所有核心能力(认证、业务检查、数据解包、Toast)由 $api interceptors 统一处理。
7
8
  *
8
- * @typeParam T - 业务数据类型(已由 $api 自动解包)
9
+ * @typeParam T - 业务数据类型(默认已由 $api 自动解包;skipUnwrap 时为原始响应类型)
9
10
  *
10
11
  * @example
11
12
  * ```ts
@@ -31,15 +32,19 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
31
32
  * toast: { successMessage: '加载成功' }
32
33
  * })
33
34
  *
34
- * // 跳过业务检查(直接返回原始响应)
35
- * const { data } = await useApiFetch('/external', { skipBusinessCheck: true })
35
+ * // 跳过业务状态码校验(仍按 dataKey 解包,适合 code 字段缺失的场景)
36
+ * const { data } = await useApiFetch('/legacy', { skipBusinessCheck: true })
37
+ *
38
+ * // 跳过解包,拿原始响应(与 skipBusinessCheck 正交)
39
+ * const { data } = await useApiFetch<ApiResponse>('/external', { skipUnwrap: true })
36
40
  *
37
41
  * // 用户自定义 hooks(通过 useFetch 原生选项透传)
38
42
  * const { data } = await useApiFetch('/users', {
39
43
  * onResponse({ response }) {
44
+ * // response._data 已是解包后的业务数据(除非传入 skipUnwrap: true)
40
45
  * console.log('自定义处理:', response._data)
41
46
  * }
42
47
  * })
43
48
  * ```
44
49
  */
45
- export declare function useApiFetch<T = unknown, DataT = T>(url: string | (() => string), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
50
+ export declare function useApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
@@ -1,16 +1,34 @@
1
- import { useNuxtApp, useFetch } from "#imports";
1
+ import { computed, toValue } from "vue";
2
+ import { useNuxtApp, useFetch } from "#app";
3
+ import { buildApiFetchKey } from "../domains/api/fetch-key.js";
2
4
  export function useApiFetch(url, options = {}) {
3
5
  const { $api } = useNuxtApp();
4
6
  const {
5
7
  endpoint,
6
8
  toast,
7
9
  skipBusinessCheck,
10
+ skipUnwrap,
8
11
  ...fetchOptions
9
12
  } = options;
10
13
  const apiInstance = endpoint ? $api.use(endpoint) : $api;
14
+ const fetchKey = computed(() => {
15
+ const userKey = toValue(fetchOptions.key);
16
+ if (userKey) return userKey;
17
+ return buildApiFetchKey({
18
+ endpoint,
19
+ skipUnwrap,
20
+ skipBusinessCheck,
21
+ toast,
22
+ method: toValue(fetchOptions.method),
23
+ url: typeof url === "function" ? url() : url,
24
+ query: toValue(fetchOptions.query),
25
+ body: toValue(fetchOptions.body)
26
+ });
27
+ });
11
28
  return useFetch(url, {
12
29
  ...fetchOptions,
30
+ key: fetchKey,
13
31
  $fetch: apiInstance,
14
- context: { toast, skipBusinessCheck }
32
+ context: { toast, skipBusinessCheck, skipUnwrap }
15
33
  });
16
34
  }
@@ -1,7 +1,6 @@
1
- import type { AutoFormControls, TypedZodFactory } from '../types/auto-form.js';
2
- import { getAutoFormMetadata } from '../auto-form/metadata.js';
3
- import { DEFAULT_CONTROLS, defineControl } from '../auto-form/controls.js';
4
- export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
1
+ import type { AutoFormControls, TypedZodFactory } from '../types/auto-form';
2
+ import { getAutoFormMetadata } from '../domains/auto-form/metadata';
3
+ import { DEFAULT_CONTROLS, defineControl } from '../domains/auto-form/controls';
5
4
  type UseAutoFormReturn<TControls extends AutoFormControls> = {
6
5
  defineControl: typeof defineControl;
7
6
  afz: TypedZodFactory<TControls>;
@@ -15,3 +14,4 @@ type UseAutoFormReturn<TControls extends AutoFormControls> = {
15
14
  */
16
15
  export declare function useAutoForm(): UseAutoFormReturn<typeof DEFAULT_CONTROLS>;
17
16
  export declare function useAutoForm<const TControls extends AutoFormControls>(controls: TControls): UseAutoFormReturn<typeof DEFAULT_CONTROLS & TControls>;
17
+ export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { isObject } from "@movk/core";
3
- import { AUTOFORM_META } from "../constants/auto-form.js";
4
- import { applyMeta, extractErrorAndMeta, getAutoFormMetadata } from "../auto-form/metadata.js";
5
- import { DEFAULT_CONTROLS, defineControl } from "../auto-form/controls.js";
6
- import { extractEnumValuesFromItems } from "../auto-form/field-utils.js";
3
+ import { applyMeta, extractErrorAndMeta, getAutoFormMetadata } from "../domains/auto-form/metadata.js";
4
+ import { DEFAULT_CONTROLS, defineControl } from "../domains/auto-form/controls.js";
5
+ import { extractEnumValuesFromItems } from "../domains/auto-form/fields.js";
7
6
  import { useDateFormatter } from "./useDateFormatter.js";
7
+ import { AUTOFORM_META } from "../domains/auto-form/constants.js";
8
8
  function createBasicFactory(zodFactory) {
9
9
  return (controlMeta) => {
10
10
  const [error, meta] = extractErrorAndMeta(controlMeta);
@@ -12,19 +12,33 @@ function createBasicFactory(zodFactory) {
12
12
  return applyMeta(schema, meta || {});
13
13
  };
14
14
  }
15
+ const DEFAULT_VALUE_FORMAT = "date-value";
16
+ const VALUE_FORMATS = ["date-value", "iso", "timestamp", "unix", "date"];
17
+ function isValueFormat(value) {
18
+ return typeof value === "string" && VALUE_FORMATS.includes(value);
19
+ }
20
+ function resolveStaticValueFormat(meta) {
21
+ if (!isObject(meta)) return DEFAULT_VALUE_FORMAT;
22
+ const controlProps = meta.controlProps;
23
+ if (!isObject(controlProps)) return DEFAULT_VALUE_FORMAT;
24
+ const valueFormat = controlProps.valueFormat;
25
+ return isValueFormat(valueFormat) ? valueFormat : DEFAULT_VALUE_FORMAT;
26
+ }
15
27
  function createCalendarDateFactory(type = "calendarDate") {
16
- const { isDateValue, isDateRange } = useDateFormatter();
28
+ const { fromFormat, isDateRange } = useDateFormatter();
17
29
  return (controlMeta) => {
18
30
  const [error, meta] = extractErrorAndMeta(controlMeta);
31
+ const valueFormat = resolveStaticValueFormat(meta);
32
+ const isValidDateValue = (value) => fromFormat(value, valueFormat) !== null;
19
33
  const schema = z.custom().refine(
20
34
  (val) => {
21
- if (isDateValue(val)) return true;
35
+ if (isValidDateValue(val)) return true;
22
36
  if (isDateRange(val)) {
23
37
  const range = val;
24
- return isDateValue(range.start) && isDateValue(range.end);
38
+ return isValidDateValue(range.start) && isValidDateValue(range.end);
25
39
  }
26
40
  if (Array.isArray(val)) {
27
- return val.length > 0 && val.every((item) => isDateValue(item));
41
+ return val.length > 0 && val.every(isValidDateValue);
28
42
  }
29
43
  return false;
30
44
  },
@@ -88,7 +102,6 @@ function createEnumFactory() {
88
102
  return applyOverwrite(z.enum(enumValues), overwrite);
89
103
  };
90
104
  }
91
- export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
92
105
  export function useAutoForm(controls) {
93
106
  function createZodFactory() {
94
107
  return {
@@ -124,3 +137,4 @@ export function useAutoForm(controls) {
124
137
  getAutoFormMetadata
125
138
  };
126
139
  }
140
+ export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
@@ -1,4 +1,5 @@
1
- import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
1
+ import type { NitroFetchRequest } from 'nitropack/types';
2
+ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
2
3
  /**
3
4
  * 仅客户端执行的 useApiFetch
4
5
  *
@@ -20,4 +21,4 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
20
21
  * })
21
22
  * ```
22
23
  */
23
- export declare function useClientApiFetch<T = unknown, DataT = T>(url: string | (() => string), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
24
+ export declare function useClientApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;