@movk/nuxt 1.1.2 → 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 (301) hide show
  1. package/.nuxt/movk-ui.css +3 -0
  2. package/README.md +75 -104
  3. package/dist/module.d.mts +59 -1
  4. package/dist/module.json +2 -2
  5. package/dist/module.mjs +136 -56
  6. package/dist/runtime/components/AutoForm.d.vue.ts +10 -31
  7. package/dist/runtime/components/AutoForm.vue +114 -148
  8. package/dist/runtime/components/AutoForm.vue.d.ts +10 -31
  9. package/dist/runtime/components/ColorChooser.d.vue.ts +20 -17
  10. package/dist/runtime/components/ColorChooser.vue +305 -31
  11. package/dist/runtime/components/ColorChooser.vue.d.ts +20 -17
  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 +15 -22
  16. package/dist/runtime/components/DatePicker.vue +173 -65
  17. package/dist/runtime/components/DatePicker.vue.d.ts +15 -22
  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 +43 -0
  28. package/dist/runtime/components/SearchForm.vue +274 -0
  29. package/dist/runtime/components/SearchForm.vue.d.ts +43 -0
  30. package/dist/runtime/components/SlideVerify.d.vue.ts +13 -79
  31. package/dist/runtime/components/SlideVerify.vue +117 -90
  32. package/dist/runtime/components/SlideVerify.vue.d.ts +13 -79
  33. package/dist/runtime/components/StarRating.d.vue.ts +25 -82
  34. package/dist/runtime/components/StarRating.vue +128 -99
  35. package/dist/runtime/components/StarRating.vue.d.ts +25 -82
  36. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +32 -0
  37. package/dist/runtime/components/input/AsPhoneNumberInput.vue +48 -0
  38. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +32 -0
  39. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +13 -7
  40. package/dist/runtime/components/input/WithCharacterLimit.vue +27 -15
  41. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +13 -7
  42. package/dist/runtime/components/input/WithClear.d.vue.ts +11 -5
  43. package/dist/runtime/components/input/WithClear.vue +29 -10
  44. package/dist/runtime/components/input/WithClear.vue.d.ts +11 -5
  45. package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -7
  46. package/dist/runtime/components/input/WithCopy.vue +28 -11
  47. package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -7
  48. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +33 -0
  49. package/dist/runtime/components/input/WithFloatingLabel.vue +75 -0
  50. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +33 -0
  51. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +13 -7
  52. package/dist/runtime/components/input/WithPasswordToggle.vue +27 -10
  53. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +13 -7
  54. package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
  55. package/dist/runtime/components/theme-picker/ThemePicker.vue +37 -28
  56. package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
  57. package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +5 -6
  58. package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
  59. package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +5 -6
  60. package/dist/runtime/composables/index.d.ts +9 -8
  61. package/dist/runtime/composables/index.js +2 -1
  62. package/dist/runtime/composables/useApiFetch.d.ts +23 -15
  63. package/dist/runtime/composables/useApiFetch.js +21 -28
  64. package/dist/runtime/composables/useAutoForm.d.ts +14 -98
  65. package/dist/runtime/composables/useAutoForm.js +55 -161
  66. package/dist/runtime/composables/useClientApiFetch.d.ts +7 -7
  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 +143 -42
  71. package/dist/runtime/composables/useLazyApiFetch.d.ts +19 -0
  72. package/dist/runtime/composables/useLazyApiFetch.js +4 -0
  73. package/dist/runtime/composables/useMessageBox.d.ts +6 -0
  74. package/dist/runtime/composables/useMessageBox.js +16 -0
  75. package/dist/runtime/composables/useTheme.d.ts +21 -8
  76. package/dist/runtime/composables/useTheme.js +109 -86
  77. package/dist/runtime/composables/useUploadWithProgress.d.ts +22 -28
  78. package/dist/runtime/composables/useUploadWithProgress.js +79 -68
  79. package/dist/runtime/domains/api/auth.d.ts +2 -0
  80. package/dist/runtime/domains/api/auth.js +31 -0
  81. package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
  82. package/dist/runtime/domains/api/endpoint-config.js +17 -0
  83. package/dist/runtime/domains/api/errors.d.ts +2 -0
  84. package/dist/runtime/domains/api/errors.js +10 -0
  85. package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
  86. package/dist/runtime/domains/api/fetch-key.js +23 -0
  87. package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
  88. package/dist/runtime/domains/api/interceptors/error.js +49 -0
  89. package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
  90. package/dist/runtime/domains/api/interceptors/request.js +46 -0
  91. package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
  92. package/dist/runtime/domains/api/interceptors/response.js +27 -0
  93. package/dist/runtime/domains/api/response.d.ts +4 -0
  94. package/dist/runtime/domains/api/response.js +14 -0
  95. package/dist/runtime/domains/api/toast.d.ts +15 -0
  96. package/dist/runtime/domains/api/toast.js +46 -0
  97. package/dist/runtime/domains/api/transfer.d.ts +69 -0
  98. package/dist/runtime/domains/api/transfer.js +81 -0
  99. package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
  100. package/dist/runtime/domains/auto-form/actions.js +4 -0
  101. package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
  102. package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +37 -48
  103. package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
  104. package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
  105. package/dist/runtime/domains/auto-form/components/Children.vue +50 -0
  106. package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
  107. package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
  108. package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
  109. package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
  110. package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
  111. package/dist/runtime/domains/auto-form/components/Layout.vue +89 -0
  112. package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
  113. package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
  114. package/dist/runtime/domains/auto-form/components/Nested.vue +47 -0
  115. package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
  116. package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -2
  117. package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -25
  118. package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
  119. package/dist/runtime/domains/auto-form/controls.js +73 -0
  120. package/dist/runtime/{utils/field-utils.d.ts → domains/auto-form/fields.d.ts} +7 -21
  121. package/dist/runtime/{utils/field-utils.js → domains/auto-form/fields.js} +19 -4
  122. package/dist/runtime/domains/auto-form/metadata.d.ts +22 -0
  123. package/dist/runtime/domains/auto-form/metadata.js +53 -0
  124. package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
  125. package/dist/runtime/{internal/useAutoFormProvider.js → domains/auto-form/provider.js} +6 -3
  126. package/dist/runtime/domains/auto-form/reactive.d.ts +12 -0
  127. package/dist/runtime/{utils/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
  128. package/dist/runtime/domains/auto-form/schema.d.ts +7 -0
  129. package/dist/runtime/{utils/schema-introspector.js → domains/auto-form/schema.js} +12 -10
  130. package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
  131. package/dist/runtime/domains/data-table/columns/constants.js +19 -0
  132. package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
  133. package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
  134. package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
  135. package/dist/runtime/domains/data-table/columns/resolve-data-column.js +164 -0
  136. package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
  137. package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
  138. package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
  139. package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
  140. package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
  141. package/dist/runtime/domains/data-table/columns/style.js +67 -0
  142. package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
  143. package/dist/runtime/domains/data-table/columns/utils.js +16 -0
  144. package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
  145. package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
  146. package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
  147. package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
  148. package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
  149. package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
  150. package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
  151. package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
  152. package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
  153. package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
  154. package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
  155. package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
  156. package/dist/runtime/domains/data-table/indent.d.ts +8 -0
  157. package/dist/runtime/domains/data-table/indent.js +19 -0
  158. package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
  159. package/dist/runtime/domains/data-table/tree-selection.js +76 -0
  160. package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
  161. package/dist/runtime/index.css +1 -0
  162. package/dist/runtime/plugins/api.factory.js +28 -171
  163. package/dist/runtime/plugins/theme.js +72 -70
  164. package/dist/runtime/types/api/config.d.ts +127 -0
  165. package/dist/runtime/types/api/fetch.d.ts +50 -0
  166. package/dist/runtime/types/api/index.d.ts +5 -0
  167. package/dist/runtime/types/api/module.d.ts +94 -0
  168. package/dist/runtime/types/api/response.d.ts +62 -0
  169. package/dist/runtime/types/api/transfer.d.ts +32 -0
  170. package/dist/runtime/types/api/transfer.js +0 -0
  171. package/dist/runtime/types/app.config.d.ts +6 -0
  172. package/dist/runtime/types/auto-form/base.d.ts +26 -0
  173. package/dist/runtime/types/auto-form/base.js +0 -0
  174. package/dist/runtime/types/auto-form/component.d.ts +28 -0
  175. package/dist/runtime/types/auto-form/component.js +0 -0
  176. package/dist/runtime/types/auto-form/controls.d.ts +45 -0
  177. package/dist/runtime/types/auto-form/controls.js +0 -0
  178. package/dist/runtime/types/auto-form/fields.d.ts +68 -0
  179. package/dist/runtime/types/auto-form/fields.js +0 -0
  180. package/dist/runtime/types/auto-form/index.d.ts +7 -0
  181. package/dist/runtime/types/auto-form/index.js +0 -0
  182. package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
  183. package/dist/runtime/types/auto-form/search-form.js +0 -0
  184. package/dist/runtime/types/auto-form/slots.d.ts +85 -0
  185. package/dist/runtime/types/auto-form/slots.js +0 -0
  186. package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
  187. package/dist/runtime/types/auto-form/zod-factory.js +0 -0
  188. package/dist/runtime/types/components/color-chooser.d.ts +109 -0
  189. package/dist/runtime/types/components/color-chooser.js +0 -0
  190. package/dist/runtime/types/components/date-picker.d.ts +41 -0
  191. package/dist/runtime/types/components/date-picker.js +0 -0
  192. package/dist/runtime/types/components/index.d.ts +8 -0
  193. package/dist/runtime/types/components/index.js +0 -0
  194. package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
  195. package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
  196. package/dist/runtime/types/components/input/index.d.ts +6 -0
  197. package/dist/runtime/types/components/input/index.js +0 -0
  198. package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
  199. package/dist/runtime/types/components/input/with-character-limit.js +0 -0
  200. package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
  201. package/dist/runtime/types/components/input/with-clear.js +0 -0
  202. package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
  203. package/dist/runtime/types/components/input/with-copy.js +0 -0
  204. package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
  205. package/dist/runtime/types/components/input/with-floating-label.js +0 -0
  206. package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
  207. package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
  208. package/dist/runtime/types/components/message-box.d.ts +69 -0
  209. package/dist/runtime/types/components/message-box.js +0 -0
  210. package/dist/runtime/types/components/pill-group.d.ts +103 -0
  211. package/dist/runtime/types/components/pill-group.js +0 -0
  212. package/dist/runtime/types/components/popconfirm.d.ts +74 -0
  213. package/dist/runtime/types/components/popconfirm.js +0 -0
  214. package/dist/runtime/types/components/slide-verify.d.ts +54 -0
  215. package/dist/runtime/types/components/slide-verify.js +0 -0
  216. package/dist/runtime/types/components/star-rating.d.ts +55 -0
  217. package/dist/runtime/types/components/star-rating.js +0 -0
  218. package/dist/runtime/types/data-table/columns.d.ts +236 -0
  219. package/dist/runtime/types/data-table/columns.js +6 -0
  220. package/dist/runtime/types/data-table/component.d.ts +190 -0
  221. package/dist/runtime/types/data-table/component.js +0 -0
  222. package/dist/runtime/types/data-table/contexts.d.ts +44 -0
  223. package/dist/runtime/types/data-table/contexts.js +0 -0
  224. package/dist/runtime/types/data-table/index.d.ts +6 -0
  225. package/dist/runtime/types/data-table/index.js +1 -0
  226. package/dist/runtime/types/data-table/pagination.d.ts +87 -0
  227. package/dist/runtime/types/data-table/pagination.js +0 -0
  228. package/dist/runtime/types/index.d.ts +6 -5
  229. package/dist/runtime/types/index.js +5 -5
  230. package/dist/runtime/types/shared.d.ts +5 -0
  231. package/dist/runtime/types/shared.js +0 -0
  232. package/dist/runtime/types/zod.d.ts +19 -17
  233. package/dist/runtime/utils/extend-theme.d.ts +19 -0
  234. package/dist/runtime/utils/extend-theme.js +44 -0
  235. package/dist/runtime/utils/form-control.d.ts +33 -0
  236. package/dist/runtime/utils/form-control.js +54 -0
  237. package/dist/runtime/utils/meta.d.ts +4 -0
  238. package/dist/runtime/utils/meta.js +14 -0
  239. package/dist/runtime/utils/theme-defaults.d.ts +27 -0
  240. package/dist/runtime/utils/theme-defaults.js +28 -0
  241. package/dist/runtime/utils/tv.d.ts +1 -0
  242. package/dist/runtime/utils/tv.js +4 -0
  243. package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
  244. package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
  245. package/dist/runtime/vue/plugins/theme.d.ts +6 -0
  246. package/dist/runtime/vue/plugins/theme.js +14 -0
  247. package/dist/runtime/vue/stubs/base.d.ts +2 -0
  248. package/dist/runtime/vue/stubs/base.js +2 -0
  249. package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
  250. package/dist/runtime/vue/stubs/inertia.js +2 -0
  251. package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
  252. package/dist/runtime/vue/stubs/movk-extra.js +2 -0
  253. package/dist/runtime/vue/stubs/none.d.ts +2 -0
  254. package/dist/runtime/vue/stubs/none.js +2 -0
  255. package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
  256. package/dist/runtime/vue/stubs/vue-router.js +2 -0
  257. package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
  258. package/dist/types.d.mts +2 -6
  259. package/dist/unplugin.d.mts +28 -0
  260. package/dist/unplugin.mjs +292 -0
  261. package/dist/vite.d.mts +12 -0
  262. package/dist/vite.mjs +20 -0
  263. package/package.json +82 -42
  264. package/vue-plugin.d.ts +5 -0
  265. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -20
  266. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -20
  267. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -20
  268. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
  269. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -20
  270. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -20
  271. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +0 -125
  272. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -20
  273. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -20
  274. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +0 -105
  275. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -20
  276. package/dist/runtime/composables/useApiAuth.d.ts +0 -47
  277. package/dist/runtime/composables/useApiAuth.js +0 -66
  278. package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
  279. package/dist/runtime/schemas/api.d.ts +0 -590
  280. package/dist/runtime/schemas/api.js +0 -228
  281. package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
  282. package/dist/runtime/server/api/_movk/session.post.js +0 -18
  283. package/dist/runtime/style.css +0 -1
  284. package/dist/runtime/types/api.d.ts +0 -218
  285. package/dist/runtime/types/auth.d.ts +0 -34
  286. package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
  287. package/dist/runtime/types/auto-form.d.ts +0 -548
  288. package/dist/runtime/types/components.d.ts +0 -43
  289. package/dist/runtime/types/module.d.ts +0 -39
  290. package/dist/runtime/utils/api-utils.d.ts +0 -79
  291. package/dist/runtime/utils/api-utils.js +0 -127
  292. package/dist/runtime/utils/auto-form.d.ts +0 -3
  293. package/dist/runtime/utils/auto-form.js +0 -18
  294. package/dist/runtime/utils/reactive-utils.d.ts +0 -30
  295. package/dist/runtime/utils/schema-introspector.d.ts +0 -13
  296. /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
  297. /package/dist/runtime/types/{api.js → api/config.js} +0 -0
  298. /package/dist/runtime/types/{auto-form-renderer.js → api/fetch.js} +0 -0
  299. /package/dist/runtime/types/{auto-form.js → api/index.js} +0 -0
  300. /package/dist/runtime/types/{module.js → api/module.js} +0 -0
  301. /package/dist/runtime/types/{components.js → api/response.js} +0 -0
@@ -1,78 +1,10 @@
1
- import { z } from "zod/v4";
2
- import WithClear from "../components/input/WithClear.vue";
3
- import WithPasswordToggle from "../components/input/WithPasswordToggle.vue";
4
- import WithCopy from "../components/input/WithCopy.vue";
5
- import WithCharacterLimit from "../components/input/WithCharacterLimit.vue";
6
- import DatePicker from "../components/DatePicker.vue";
7
- import ColorChooser from "../components/ColorChooser.vue";
8
- import StarRating from "../components/StarRating.vue";
9
- import SlideVerify from "../components/SlideVerify.vue";
10
- import {
11
- UInput,
12
- UInputNumber,
13
- UCheckbox,
14
- USwitch,
15
- UTextarea,
16
- USlider,
17
- UPinInput,
18
- UInputTags,
19
- UFileUpload,
20
- USelect,
21
- USelectMenu,
22
- UInputMenu,
23
- UCheckboxGroup,
24
- URadioGroup,
25
- UInputDate,
26
- UInputTime
27
- } from "#components";
1
+ import { z } from "zod";
28
2
  import { isObject } from "@movk/core";
29
- import { AUTOFORM_META, CLONE_METHODS } from "../constants/auto-form.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";
30
6
  import { useDateFormatter } from "./useDateFormatter.js";
31
- import { extractEnumValuesFromItems } from "../utils/auto-form.js";
32
- function interceptCloneMethods(schema, customMeta) {
33
- for (const methodName of CLONE_METHODS) {
34
- const originalMethod = schema[methodName];
35
- if (typeof originalMethod !== "function")
36
- continue;
37
- schema[methodName] = function(...args) {
38
- const newSchema = originalMethod.apply(this, args);
39
- if (!newSchema?._def)
40
- return newSchema;
41
- const newMeta = methodName === "meta" && args[0] ? { ...customMeta || {}, ...args[0] || {} } : customMeta || {};
42
- newSchema[AUTOFORM_META.KEY] = newMeta;
43
- return interceptCloneMethods(newSchema, newMeta);
44
- };
45
- }
46
- return schema;
47
- }
48
- function applyMeta(schema, meta = {}) {
49
- schema[AUTOFORM_META.KEY] = meta;
50
- interceptCloneMethods(schema, meta);
51
- return schema;
52
- }
53
- function getAutoFormMetadata(schema) {
54
- const meta = schema[AUTOFORM_META.KEY];
55
- if (meta)
56
- return meta;
57
- if ("unwrap" in schema && typeof schema.unwrap === "function") {
58
- try {
59
- const unwrapped = schema.unwrap();
60
- return unwrapped?.[AUTOFORM_META.KEY] || {};
61
- } catch {
62
- }
63
- }
64
- return {};
65
- }
66
- function extractErrorAndMeta(controlMeta) {
67
- if (typeof controlMeta === "string") {
68
- return [controlMeta, void 0];
69
- }
70
- if (controlMeta && isObject(controlMeta) && "error" in controlMeta) {
71
- const { error, ...meta } = controlMeta;
72
- return [error, meta];
73
- }
74
- return [void 0, controlMeta];
75
- }
7
+ import { AUTOFORM_META } from "../domains/auto-form/constants.js";
76
8
  function createBasicFactory(zodFactory) {
77
9
  return (controlMeta) => {
78
10
  const [error, meta] = extractErrorAndMeta(controlMeta);
@@ -80,19 +12,33 @@ function createBasicFactory(zodFactory) {
80
12
  return applyMeta(schema, meta || {});
81
13
  };
82
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
+ }
83
27
  function createCalendarDateFactory(type = "calendarDate") {
84
- const { isDateValue, isDateRange } = useDateFormatter();
28
+ const { fromFormat, isDateRange } = useDateFormatter();
85
29
  return (controlMeta) => {
86
30
  const [error, meta] = extractErrorAndMeta(controlMeta);
31
+ const valueFormat = resolveStaticValueFormat(meta);
32
+ const isValidDateValue = (value) => fromFormat(value, valueFormat) !== null;
87
33
  const schema = z.custom().refine(
88
34
  (val) => {
89
- if (isDateValue(val)) return true;
35
+ if (isValidDateValue(val)) return true;
90
36
  if (isDateRange(val)) {
91
37
  const range = val;
92
- return isDateValue(range.start) && isDateValue(range.end);
38
+ return isValidDateValue(range.start) && isValidDateValue(range.end);
93
39
  }
94
40
  if (Array.isArray(val)) {
95
- return val.length > 0 && val.every((item) => isDateValue(item));
41
+ return val.length > 0 && val.every(isValidDateValue);
96
42
  }
97
43
  return false;
98
44
  },
@@ -102,17 +48,15 @@ function createCalendarDateFactory(type = "calendarDate") {
102
48
  return applyMeta(schema, { ...meta || {}, type: finalType });
103
49
  };
104
50
  }
105
- function createInputTimeFactory() {
106
- return (controlMeta) => {
107
- const [error, meta] = extractErrorAndMeta(controlMeta);
108
- const schema = z.custom().refine(
109
- (val) => {
110
- return val !== null && val !== void 0 && typeof val === "object" && "hour" in val && "minute" in val && typeof val.hour === "number" && typeof val.minute === "number";
111
- },
112
- { message: error || "\u65E0\u6548\u7684\u65F6\u95F4\u683C\u5F0F" }
113
- );
114
- return applyMeta(schema, { ...meta || {}, type: "inputTime" });
115
- };
51
+ function inputTimeFactory(controlMeta) {
52
+ const [error, meta] = extractErrorAndMeta(controlMeta);
53
+ const schema = z.custom().refine(
54
+ (val) => {
55
+ return val !== null && val !== void 0 && typeof val === "object" && "hour" in val && "minute" in val && typeof val.hour === "number" && typeof val.minute === "number";
56
+ },
57
+ { message: error || "\u65E0\u6548\u7684\u65F6\u95F4\u683C\u5F0F" }
58
+ );
59
+ return applyMeta(schema, { ...meta || {}, type: "inputTime" });
116
60
  }
117
61
  function createISOFactory(type) {
118
62
  return (controlMeta) => {
@@ -122,41 +66,35 @@ function createISOFactory(type) {
122
66
  };
123
67
  }
124
68
  function applyOverwrite(schema, overwrite) {
125
- return overwrite && isObject(overwrite) ? applyMeta(schema, { overwrite }) : applyMeta(schema, {});
69
+ return applyMeta(schema, overwrite && isObject(overwrite) ? { overwrite } : void 0);
126
70
  }
127
71
  function createObjectFactory(method) {
72
+ const createSchema = (shape) => z[method](shape);
128
73
  return (shapeOrNothing, meta) => {
129
74
  if (shapeOrNothing === void 0) {
130
- return (shape, innerMeta) => applyMeta(z[method](shape), innerMeta || {});
75
+ return (shape, innerMeta) => applyMeta(createSchema(shape), innerMeta);
131
76
  }
132
- return applyMeta(z[method](shapeOrNothing), meta || {});
77
+ return applyMeta(createSchema(shapeOrNothing), meta);
133
78
  };
134
79
  }
135
- function createLayoutFactory() {
136
- return (config) => {
137
- return applyMeta(z.custom(), {
138
- type: AUTOFORM_META.LAYOUT_KEY,
139
- layout: config
140
- });
141
- };
80
+ function layoutFactory(config) {
81
+ return applyMeta(z.custom(), {
82
+ type: AUTOFORM_META.LAYOUT_KEY,
83
+ layout: config
84
+ });
142
85
  }
143
- function createArrayFactory() {
144
- return (schema, overwrite) => applyOverwrite(z.array(schema), overwrite);
86
+ function arrayFactory(schema, overwrite) {
87
+ return applyOverwrite(z.array(schema), overwrite);
145
88
  }
146
- function createTupleFactory() {
147
- return (schemas, overwrite) => applyOverwrite(z.tuple(schemas), overwrite);
89
+ function tupleFactory(schemas, overwrite) {
90
+ return applyOverwrite(z.tuple(schemas), overwrite);
148
91
  }
149
92
  function createEnumFactory() {
150
93
  return (values, overwrite) => {
151
94
  let enumValues = values;
152
95
  if ((!values || Array.isArray(values) && values.length === 0) && overwrite?.controlProps?.items) {
153
96
  const valueKey = overwrite.controlProps.valueKey;
154
- const extractedValues = extractEnumValuesFromItems(overwrite.controlProps.items, valueKey);
155
- if (extractedValues.length > 0) {
156
- enumValues = extractedValues;
157
- } else {
158
- enumValues = [];
159
- }
97
+ enumValues = extractEnumValuesFromItems(overwrite.controlProps.items, valueKey);
160
98
  }
161
99
  if (!enumValues || Array.isArray(enumValues) && enumValues.length === 0) {
162
100
  return applyOverwrite(z.string(), overwrite);
@@ -164,83 +102,39 @@ function createEnumFactory() {
164
102
  return applyOverwrite(z.enum(enumValues), overwrite);
165
103
  };
166
104
  }
167
- const DEFAULT_CONTROL_PROPS = { class: "w-full" };
168
- function defineControl(e) {
169
- return e;
170
- }
171
- const DEFAULT_CONTROLS = {
172
- // 基础类型
173
- string: defineControl({ component: UInput, controlProps: DEFAULT_CONTROL_PROPS }),
174
- number: defineControl({ component: UInputNumber, controlProps: DEFAULT_CONTROL_PROPS }),
175
- boolean: defineControl({ component: UCheckbox, controlProps: DEFAULT_CONTROL_PROPS }),
176
- enum: defineControl({ component: USelect, controlProps: DEFAULT_CONTROL_PROPS }),
177
- file: defineControl({ component: UFileUpload, controlProps: DEFAULT_CONTROL_PROPS }),
178
- calendarDate: defineControl({ component: DatePicker, controlProps: DEFAULT_CONTROL_PROPS }),
179
- // 扩展类型
180
- switch: defineControl({ component: USwitch, controlProps: DEFAULT_CONTROL_PROPS }),
181
- textarea: defineControl({ component: UTextarea, controlProps: DEFAULT_CONTROL_PROPS }),
182
- slider: defineControl({ component: USlider, controlProps: DEFAULT_CONTROL_PROPS }),
183
- pinInput: defineControl({ component: UPinInput, controlProps: DEFAULT_CONTROL_PROPS }),
184
- inputTags: defineControl({ component: UInputTags, controlProps: DEFAULT_CONTROL_PROPS }),
185
- selectMenu: defineControl({ component: USelectMenu, controlProps: DEFAULT_CONTROL_PROPS }),
186
- inputMenu: defineControl({ component: UInputMenu, controlProps: DEFAULT_CONTROL_PROPS }),
187
- checkboxGroup: defineControl({ component: UCheckboxGroup, controlProps: DEFAULT_CONTROL_PROPS }),
188
- radioGroup: defineControl({ component: URadioGroup, controlProps: DEFAULT_CONTROL_PROPS }),
189
- inputDate: defineControl({ component: UInputDate, controlProps: DEFAULT_CONTROL_PROPS }),
190
- inputTime: defineControl({ component: UInputTime, controlProps: DEFAULT_CONTROL_PROPS }),
191
- // 自定义增强型组件
192
- withClear: defineControl({ component: WithClear, controlProps: DEFAULT_CONTROL_PROPS }),
193
- withPasswordToggle: defineControl({ component: WithPasswordToggle, controlProps: DEFAULT_CONTROL_PROPS }),
194
- withCopy: defineControl({ component: WithCopy, controlProps: DEFAULT_CONTROL_PROPS }),
195
- withCharacterLimit: defineControl({ component: WithCharacterLimit, controlProps: DEFAULT_CONTROL_PROPS }),
196
- colorChooser: defineControl({ component: ColorChooser, controlProps: DEFAULT_CONTROL_PROPS }),
197
- starRating: defineControl({ component: StarRating, controlProps: DEFAULT_CONTROL_PROPS }),
198
- slideVerify: defineControl({ component: SlideVerify, controlProps: DEFAULT_CONTROL_PROPS })
199
- };
200
105
  export function useAutoForm(controls) {
201
- function createZodFactory(_controls) {
106
+ function createZodFactory() {
202
107
  return {
203
- // 基础类型
204
108
  string: createBasicFactory(z.string),
205
109
  number: createBasicFactory(z.number),
206
110
  boolean: createBasicFactory(z.boolean),
207
111
  file: createBasicFactory(z.file),
208
- // 日期和时间类型
209
112
  calendarDate: createCalendarDateFactory(),
210
113
  inputDate: createCalendarDateFactory("inputDate"),
211
- inputTime: createInputTimeFactory(),
212
- // ISO 字符串类型
114
+ inputTime: inputTimeFactory,
213
115
  isoDatetime: createISOFactory("datetime"),
214
116
  isoDate: createISOFactory("date"),
215
117
  isoTime: createISOFactory("time"),
216
- // Zod v4 专用验证函数
217
118
  email: createBasicFactory(z.email),
218
119
  url: createBasicFactory(z.url),
219
120
  uuid: createBasicFactory(z.uuid),
220
- // 集合类型
221
- array: createArrayFactory(),
222
- tuple: createTupleFactory(),
121
+ array: arrayFactory,
122
+ tuple: tupleFactory,
223
123
  enum: createEnumFactory(),
224
- // 布局系统
225
- layout: createLayoutFactory(),
226
- // 对象类型
124
+ layout: layoutFactory,
227
125
  object: createObjectFactory("object"),
228
126
  looseObject: createObjectFactory("looseObject"),
229
127
  strictObject: createObjectFactory("strictObject")
230
128
  };
231
129
  }
232
- const builtControls = controls ? Object.fromEntries(
233
- Object.entries(controls).map(([key, control]) => [
234
- key,
235
- defineControl(control)
236
- ])
237
- ) : void 0;
238
- const afz = createZodFactory(builtControls);
130
+ const mergedControls = controls ? { ...DEFAULT_CONTROLS, ...controls } : DEFAULT_CONTROLS;
131
+ const afz = createZodFactory();
239
132
  return {
240
133
  defineControl,
241
134
  afz,
242
135
  DEFAULT_CONTROLS,
243
- controls,
136
+ controls: mergedControls,
244
137
  getAutoFormMetadata
245
138
  };
246
139
  }
140
+ export { defineControl, DEFAULT_CONTROLS, getAutoFormMetadata };
@@ -1,12 +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
  * 仅客户端执行的 useApiFetch
4
5
  *
5
6
  * 设置 `server: false, lazy: true`
6
7
  * 适合非 SEO 敏感数据,需手动调用 execute() 触发请求
7
8
  *
8
- * @typeParam ResT - API 响应 data 字段的原始类型
9
- * @typeParam DataT - transform 转换后的最终类型(默认等于 ResT)
9
+ * @typeParam T - 业务数据类型(已由 $api 自动解包)
10
10
  *
11
11
  * @example
12
12
  * ```ts
@@ -15,10 +15,10 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
15
15
  * // 在 onMounted 或用户操作时触发
16
16
  * onMounted(() => execute())
17
17
  *
18
- * // 使用 transform 转换数据(接收解包后的数据)
19
- * const { data } = useClientApiFetch<{ content: User[] }, User[]>('/users', {
20
- * transform: ({ content }) => content ?? []
18
+ * // 使用 transform 转换数据(接收已解包的业务数据)
19
+ * const { data } = useClientApiFetch<User[]>('/users', {
20
+ * transform: (users) => users.filter(u => u.active)
21
21
  * })
22
22
  * ```
23
23
  */
24
- export declare function useClientApiFetch<ResT = unknown, DataT = ResT>(url: string | (() => string), options?: UseApiFetchOptions<ResT, DataT>): UseApiFetchReturn<DataT>;
24
+ export declare function useClientApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
@@ -1,5 +1,7 @@
1
+ import { CalendarDate } from '@internationalized/date';
1
2
  import type { DateValue } from '@internationalized/date';
2
3
  import type { DateRange } from 'reka-ui';
4
+ export type ValueFormat = 'date-value' | 'iso' | 'timestamp' | 'unix' | 'date';
3
5
  /**
4
6
  * 日期格式化器配置选项
5
7
  */
@@ -55,9 +57,17 @@ export declare function useDateFormatter(options?: DateFormatterOptions): {
55
57
  toDate: (date: DateValue | undefined | null) => Date | null;
56
58
  toTimestamp: (date: DateValue | undefined | null) => number | null;
57
59
  toUnixTimestamp: (date: DateValue | undefined | null) => number | null;
58
- parse: (value: string) => import("@internationalized/date").CalendarDate | import("@internationalized/date").CalendarDateTime | import("@internationalized/date").ZonedDateTime | null;
60
+ toFormat: (date: DateValue | undefined | null, format: ValueFormat) => unknown;
61
+ fromISO: (value: string | undefined | null) => DateValue | null;
62
+ fromDate: (value: Date | undefined | null) => CalendarDate | null;
63
+ fromTimestamp: (value: number | undefined | null) => CalendarDate | null;
64
+ fromUnixTimestamp: (value: number | undefined | null) => CalendarDate | null;
65
+ fromFormat: (value: unknown, format: ValueFormat) => DateValue | null;
66
+ parse: (value: string) => CalendarDate | import("@internationalized/date").CalendarDateTime | import("@internationalized/date").ZonedDateTime | null;
59
67
  convertData: <T>(data: T, converter: (value: DateValue) => unknown) => T;
60
- getToday: () => import("@internationalized/date").CalendarDate;
68
+ convertToFormat: <T>(data: T, format: ValueFormat) => unknown;
69
+ convertFromFormat: <T>(data: T, format: ValueFormat) => unknown;
70
+ getToday: () => CalendarDate;
61
71
  getNow: () => import("@internationalized/date").ZonedDateTime;
62
72
  getStartOfWeek: (date: DateValue) => DateValue;
63
73
  getEndOfWeek: (date: DateValue) => DateValue;
@@ -82,4 +92,7 @@ export declare function useDateFormatter(options?: DateFormatterOptions): {
82
92
  locale: string;
83
93
  timeZone: string;
84
94
  };
85
- export {};
95
+ export { CalendarDate } from '@internationalized/date';
96
+ export type DateFormatter = ReturnType<typeof useDateFormatter>;
97
+ export type { AnyCalendarDate, Calendar, CalendarDateTime, DateDuration, DateFields, DateValue, Time, ZonedDateTime } from '@internationalized/date';
98
+ export type { DateRange } from 'reka-ui';
@@ -1,5 +1,6 @@
1
1
  import {
2
- DateFormatter,
2
+ CalendarDate,
3
+ DateFormatter as IntlDateFormatter,
3
4
  getLocalTimeZone,
4
5
  today,
5
6
  now,
@@ -23,6 +24,13 @@ import {
23
24
  } from "@internationalized/date";
24
25
  const DEFAULT_LOCALE = "zh-CN";
25
26
  const DEFAULT_FORMAT_OPTIONS = { dateStyle: "medium" };
27
+ function safe(fn, fallback) {
28
+ try {
29
+ return fn();
30
+ } catch {
31
+ return fallback;
32
+ }
33
+ }
26
34
  function isDateValue(value) {
27
35
  return value !== null && value !== void 0 && typeof value === "object" && "calendar" in value && "year" in value && "month" in value && "day" in value;
28
36
  }
@@ -33,14 +41,10 @@ export function useDateFormatter(options = {}) {
33
41
  const locale = options.locale ?? DEFAULT_LOCALE;
34
42
  const formatOptions = options.formatOptions ?? DEFAULT_FORMAT_OPTIONS;
35
43
  const timeZone = options.timeZone ?? getLocalTimeZone();
36
- const formatter = new DateFormatter(locale, { ...formatOptions, timeZone });
44
+ const formatter = new IntlDateFormatter(locale, { ...formatOptions, timeZone });
37
45
  function format(date) {
38
46
  if (!date) return "";
39
- try {
40
- return formatter.format(date.toDate(timeZone));
41
- } catch {
42
- return "";
43
- }
47
+ return safe(() => formatter.format(date.toDate(timeZone)), "");
44
48
  }
45
49
  function formatRange(start, end, separator = " - ") {
46
50
  if (!start || !end) return "";
@@ -52,19 +56,11 @@ export function useDateFormatter(options = {}) {
52
56
  }
53
57
  function toISO(date) {
54
58
  if (!date) return "";
55
- try {
56
- return date.toString();
57
- } catch {
58
- return "";
59
- }
59
+ return safe(() => date.toString(), "");
60
60
  }
61
61
  function toDate(date) {
62
62
  if (!date) return null;
63
- try {
64
- return new Date(Date.UTC(date.year, date.month - 1, date.day));
65
- } catch {
66
- return null;
67
- }
63
+ return safe(() => new Date(Date.UTC(date.year, date.month - 1, date.day)), null);
68
64
  }
69
65
  function toTimestamp(date) {
70
66
  const jsDate = toDate(date);
@@ -72,7 +68,67 @@ export function useDateFormatter(options = {}) {
72
68
  }
73
69
  function toUnixTimestamp(date) {
74
70
  const timestamp = toTimestamp(date);
75
- return timestamp ? Math.floor(timestamp / 1e3) : null;
71
+ return timestamp === null ? null : Math.floor(timestamp / 1e3);
72
+ }
73
+ function toFormat(date, format2) {
74
+ if (!date) return void 0;
75
+ switch (format2) {
76
+ case "date-value":
77
+ return date;
78
+ case "iso":
79
+ return toISO(date);
80
+ case "timestamp":
81
+ return toTimestamp(date);
82
+ case "unix":
83
+ return toUnixTimestamp(date);
84
+ case "date":
85
+ return toDate(date);
86
+ }
87
+ }
88
+ function convertToFormat(data, format2) {
89
+ if (format2 === "date-value") return data;
90
+ return convertData(data, (value) => toFormat(value, format2));
91
+ }
92
+ function fromDate(value) {
93
+ if (!value || Number.isNaN(value.getTime())) return null;
94
+ return safe(
95
+ () => new CalendarDate(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate()),
96
+ null
97
+ );
98
+ }
99
+ function fromTimestamp(value) {
100
+ if (value === null || value === void 0 || Number.isNaN(value)) return null;
101
+ return fromDate(new Date(value));
102
+ }
103
+ function fromUnixTimestamp(value) {
104
+ if (value === null || value === void 0 || Number.isNaN(value)) return null;
105
+ return fromTimestamp(value * 1e3);
106
+ }
107
+ function fromISO(value) {
108
+ if (!value) return null;
109
+ return parse(value);
110
+ }
111
+ function fromFormat(value, format2) {
112
+ if (value === null || value === void 0) return null;
113
+ if (format2 === "date-value") return isDateValue(value) ? value : null;
114
+ if (format2 === "iso") return typeof value === "string" ? fromISO(value) : null;
115
+ if (format2 === "timestamp") return typeof value === "number" ? fromTimestamp(value) : null;
116
+ if (format2 === "unix") return typeof value === "number" ? fromUnixTimestamp(value) : null;
117
+ if (format2 === "date") return value instanceof Date ? fromDate(value) : null;
118
+ return null;
119
+ }
120
+ function convertFromFormat(data, format2) {
121
+ if (data === null || data === void 0) return data;
122
+ if (format2 === "date-value") return data;
123
+ if (Array.isArray(data)) return data.map((item) => convertFromFormat(item, format2));
124
+ if (typeof data === "object" && "start" in data && "end" in data) {
125
+ const range = data;
126
+ return {
127
+ start: range.start === void 0 || range.start === null ? range.start : fromFormat(range.start, format2),
128
+ end: range.end === void 0 || range.end === null ? range.end : fromFormat(range.end, format2)
129
+ };
130
+ }
131
+ return fromFormat(data, format2);
76
132
  }
77
133
  function getToday() {
78
134
  return today(timeZone);
@@ -112,12 +168,10 @@ export function useDateFormatter(options = {}) {
112
168
  return getDayOfWeek(date, locale);
113
169
  }
114
170
  function getDayOfWeekName(date, style = "long") {
115
- try {
116
- const weekdayFormatter = new DateFormatter(locale, { weekday: style, timeZone });
171
+ return safe(() => {
172
+ const weekdayFormatter = new IntlDateFormatter(locale, { weekday: style, timeZone });
117
173
  return weekdayFormatter.format(date.toDate(timeZone));
118
- } catch {
119
- return "";
120
- }
174
+ }, "");
121
175
  }
122
176
  function getWeeksInMonthNumber(date) {
123
177
  return getWeeksInMonth(date, locale);
@@ -156,13 +210,9 @@ export function useDateFormatter(options = {}) {
156
210
  return data.map((item) => convertData(item, converter));
157
211
  }
158
212
  if (typeof data === "object") {
159
- const result = {};
160
- for (const key in data) {
161
- if (Object.prototype.hasOwnProperty.call(data, key)) {
162
- result[key] = convertData(data[key], converter);
163
- }
164
- }
165
- return result;
213
+ return Object.fromEntries(
214
+ Object.entries(data).map(([k, v]) => [k, convertData(v, converter)])
215
+ );
166
216
  }
167
217
  return data;
168
218
  }
@@ -183,8 +233,16 @@ export function useDateFormatter(options = {}) {
183
233
  toDate,
184
234
  toTimestamp,
185
235
  toUnixTimestamp,
236
+ toFormat,
237
+ fromISO,
238
+ fromDate,
239
+ fromTimestamp,
240
+ fromUnixTimestamp,
241
+ fromFormat,
186
242
  parse,
187
243
  convertData,
244
+ convertToFormat,
245
+ convertFromFormat,
188
246
  getToday,
189
247
  getNow,
190
248
  getStartOfWeek,
@@ -211,3 +269,4 @@ export function useDateFormatter(options = {}) {
211
269
  timeZone
212
270
  };
213
271
  }
272
+ export { CalendarDate } from "@internationalized/date";
@@ -1,48 +1,47 @@
1
- import type { RequestToastOptions } from '../types/api.js';
1
+ import type { NitroFetchRequest } from 'nitropack/types';
2
+ import type { ApiError, TransferRequestOptions, TransferResult } from '../types/api';
2
3
  /**
3
- * 下载选项(带进度监控)
4
+ * 下载选项(带进度监控)
4
5
  */
5
- export interface DownloadWithProgressOptions {
6
- /** 自定义文件名,不提供时从响应头提取 */
6
+ export interface DownloadWithProgressOptions extends TransferRequestOptions {
7
+ /** HTTP 方法 @defaultValue 'GET' */
8
+ method?: RequestInit['method'];
9
+ /** 请求体,非 GET 时若非 string 自动序列化为 JSON */
10
+ body?: RequestInit['body'] | Record<string, unknown>;
11
+ /** 自定义文件名,不提供时从响应头或 URL 提取 */
7
12
  filename?: string;
8
- /** 额外的请求头 */
9
- headers?: Record<string, string>;
10
- /** Toast 配置 */
11
- toast?: RequestToastOptions | false;
12
- /** 端点名称 */
13
- endpoint?: string;
14
- /** 下载成功回调 */
13
+ /** 下载成功回调(文件名) */
15
14
  onSuccess?: (filename: string) => void;
16
- /** 下载失败回调 */
17
- onError?: (error: Error) => void;
15
+ /** 下载失败回调;中止时不触发 */
16
+ onError?: (error: ApiError | Error) => void;
18
17
  }
19
18
  /**
20
- * 带进度监控的文件下载 composable
19
+ * 带进度监控的文件下载 composable(仅客户端)
21
20
  *
22
- * 基于原生 fetch + ReadableStream 实现,支持实时进度和取消下载
21
+ * @description 基于原生 fetch + ReadableStream 实现,复用 `@movk/nuxt` 的端点/认证/业务校验/toast/hook 体系。
22
+ * - 后端返回 JSON 时按业务码校验,错误不会触发文件下载
23
+ * - 后端无 content-length 时 progress 为 null,UI 据此切 indeterminate
23
24
  *
24
25
  * @example
25
26
  * ```ts
26
- * const { progress, downloading, download, abort } = useDownloadWithProgress()
27
+ * const { progress, status, error, download, abort } = useDownloadWithProgress()
27
28
  *
28
- * await download('/api/export', {
29
- * filename: 'report.pdf',
30
- * onSuccess: (name) => console.log('下载成功:', name)
29
+ * const { data, error: err, aborted } = await download('/api/export', {
30
+ * filename: 'report.pdf'
31
31
  * })
32
32
  * ```
33
33
  */
34
- export declare function useDownloadWithProgress(): {
35
- /** 下载进度 (0-100) */
34
+ export declare function useDownloadWithProgress<T = Blob>(): {
35
+ /** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
36
36
  progress: any;
37
- /** 是否正在下载 */
38
- downloading: any;
37
+ /** 传输状态 */
38
+ status: any;
39
+ /** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
40
+ data: any;
39
41
  /** 错误信息 */
40
42
  error: any;
41
43
  /** 执行下载 */
42
- download: (url: string, options?: DownloadWithProgressOptions) => Promise<{
43
- success: boolean;
44
- error: Error | null;
45
- }>;
44
+ download: (url: NitroFetchRequest, options?: DownloadWithProgressOptions) => Promise<TransferResult<T>>;
46
45
  /** 中止下载 */
47
46
  abort: () => void;
48
47
  };