@movk/nuxt 1.1.1 → 1.2.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 (121) hide show
  1. package/README.md +5 -29
  2. package/dist/module.d.mts +3 -31
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +135 -77
  5. package/dist/runtime/auto-form/controls.d.ts +221 -0
  6. package/dist/runtime/auto-form/controls.js +70 -0
  7. package/dist/runtime/{utils → auto-form}/field-utils.d.ts +4 -20
  8. package/dist/runtime/{utils → auto-form}/field-utils.js +1 -2
  9. package/dist/runtime/auto-form/metadata.d.ts +22 -0
  10. package/dist/runtime/auto-form/metadata.js +53 -0
  11. package/dist/runtime/auto-form/provider.d.ts +27 -0
  12. package/dist/runtime/{internal/useAutoFormProvider.js → auto-form/provider.js} +1 -1
  13. package/dist/runtime/{utils → auto-form}/reactive-utils.d.ts +4 -22
  14. package/dist/runtime/{utils → auto-form}/schema-introspector.d.ts +3 -9
  15. package/dist/runtime/{utils → auto-form}/schema-introspector.js +11 -9
  16. package/dist/runtime/components/AutoForm.d.vue.ts +4 -5
  17. package/dist/runtime/components/AutoForm.vue +12 -35
  18. package/dist/runtime/components/AutoForm.vue.d.ts +4 -5
  19. package/dist/runtime/components/ColorChooser.d.vue.ts +10 -6
  20. package/dist/runtime/components/ColorChooser.vue +4 -7
  21. package/dist/runtime/components/ColorChooser.vue.d.ts +10 -6
  22. package/dist/runtime/components/DatePicker.d.vue.ts +16 -10
  23. package/dist/runtime/components/DatePicker.vue.d.ts +16 -10
  24. package/dist/runtime/components/SearchForm.d.vue.ts +171 -0
  25. package/dist/runtime/components/SearchForm.vue +216 -0
  26. package/dist/runtime/components/SearchForm.vue.d.ts +171 -0
  27. package/dist/runtime/components/SlideVerify.d.vue.ts +5 -32
  28. package/dist/runtime/components/SlideVerify.vue +4 -4
  29. package/dist/runtime/components/SlideVerify.vue.d.ts +5 -32
  30. package/dist/runtime/components/StarRating.d.vue.ts +8 -16
  31. package/dist/runtime/components/StarRating.vue +50 -65
  32. package/dist/runtime/components/StarRating.vue.d.ts +8 -16
  33. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +10 -2
  34. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue +16 -23
  35. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +10 -2
  36. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +26 -0
  37. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue +50 -0
  38. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +26 -0
  39. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +8 -2
  40. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +2 -2
  41. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +8 -2
  42. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +8 -2
  43. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +29 -64
  44. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +8 -2
  45. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +8 -2
  46. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +15 -69
  47. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +8 -2
  48. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +36 -0
  49. package/dist/runtime/components/input/AsPhoneNumberInput.vue +35 -0
  50. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +36 -0
  51. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +17 -9
  52. package/dist/runtime/components/input/WithCharacterLimit.vue +5 -5
  53. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +17 -9
  54. package/dist/runtime/components/input/WithClear.d.vue.ts +13 -9
  55. package/dist/runtime/components/input/WithClear.vue +2 -2
  56. package/dist/runtime/components/input/WithClear.vue.d.ts +13 -9
  57. package/dist/runtime/components/input/WithCopy.d.vue.ts +16 -10
  58. package/dist/runtime/components/input/WithCopy.vue +3 -3
  59. package/dist/runtime/components/input/WithCopy.vue.d.ts +16 -10
  60. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +36 -0
  61. package/dist/runtime/components/input/WithFloatingLabel.vue +67 -0
  62. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +36 -0
  63. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -9
  64. package/dist/runtime/components/input/WithPasswordToggle.vue +3 -3
  65. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -9
  66. package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +1 -1
  67. package/dist/runtime/components/theme-picker/ThemePicker.vue +19 -25
  68. package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +1 -1
  69. package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +1 -7
  70. package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +1 -7
  71. package/dist/runtime/composables/index.d.ts +8 -0
  72. package/dist/runtime/composables/index.js +8 -0
  73. package/dist/runtime/composables/useApiFetch.d.ts +17 -14
  74. package/dist/runtime/composables/useApiFetch.js +3 -28
  75. package/dist/runtime/composables/useAutoForm.d.ts +14 -98
  76. package/dist/runtime/composables/useAutoForm.js +37 -157
  77. package/dist/runtime/composables/useClientApiFetch.d.ts +5 -6
  78. package/dist/runtime/composables/useDownloadWithProgress.js +5 -6
  79. package/dist/runtime/composables/useLazyApiFetch.d.ts +18 -0
  80. package/dist/runtime/composables/useLazyApiFetch.js +4 -0
  81. package/dist/runtime/composables/useTheme.d.ts +17 -14
  82. package/dist/runtime/composables/useTheme.js +68 -72
  83. package/dist/runtime/composables/useUploadWithProgress.d.ts +2 -2
  84. package/dist/runtime/composables/useUploadWithProgress.js +7 -7
  85. package/dist/runtime/constants/api-defaults.d.ts +9 -0
  86. package/dist/runtime/constants/api-defaults.js +32 -0
  87. package/dist/runtime/constants/auto-form.d.ts +0 -2
  88. package/dist/runtime/constants/auto-form.js +0 -25
  89. package/dist/runtime/constants/grid-cols.d.ts +7 -0
  90. package/dist/runtime/constants/grid-cols.js +44 -0
  91. package/dist/runtime/plugins/api.factory.js +78 -121
  92. package/dist/runtime/plugins/theme.js +44 -64
  93. package/dist/runtime/style.css +1 -1
  94. package/dist/runtime/types/api.d.ts +277 -146
  95. package/dist/runtime/types/auto-form.d.ts +122 -411
  96. package/dist/runtime/types/index.d.ts +3 -2
  97. package/dist/runtime/types/index.js +3 -2
  98. package/dist/runtime/types/module.d.ts +96 -0
  99. package/dist/runtime/types/theme.d.ts +2 -0
  100. package/dist/runtime/types/zod.d.ts +11 -10
  101. package/dist/runtime/utils/api-utils.d.ts +27 -48
  102. package/dist/runtime/utils/api-utils.js +18 -47
  103. package/dist/runtime/utils/meta.d.ts +7 -0
  104. package/dist/runtime/utils/meta.js +16 -0
  105. package/dist/types.d.mts +6 -2
  106. package/package.json +68 -37
  107. package/dist/runtime/composables/useApiAuth.d.ts +0 -47
  108. package/dist/runtime/composables/useApiAuth.js +0 -66
  109. package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
  110. package/dist/runtime/schemas/api.d.ts +0 -590
  111. package/dist/runtime/schemas/api.js +0 -228
  112. package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
  113. package/dist/runtime/server/api/_movk/session.post.js +0 -18
  114. package/dist/runtime/types/auth.d.ts +0 -34
  115. package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
  116. package/dist/runtime/types/components.d.ts +0 -43
  117. package/dist/runtime/utils/auto-form.d.ts +0 -3
  118. package/dist/runtime/utils/auto-form.js +0 -18
  119. /package/dist/runtime/{utils → auto-form}/reactive-utils.js +0 -0
  120. /package/dist/runtime/types/{auto-form-renderer.js → module.js} +0 -0
  121. /package/dist/runtime/types/{components.js → theme.js} +0 -0
@@ -1,66 +0,0 @@
1
- import { getPath } from "@movk/core";
2
- import { useNuxtApp, useRuntimeConfig, useUserSession } from "#imports";
3
- export function useApiAuth() {
4
- const { $api } = useNuxtApp();
5
- const userSession = useUserSession();
6
- const moduleConfig = useRuntimeConfig().public.movkApi;
7
- const buildAuthHeader = (token, authConfig = {}) => {
8
- const tokenType = authConfig.tokenType === "Custom" ? authConfig.customTokenType || "" : authConfig.tokenType || "Bearer";
9
- return tokenType ? `${tokenType} ${token}` : token;
10
- };
11
- const getHeaderName = (authConfig = {}) => {
12
- return authConfig.headerName || "Authorization";
13
- };
14
- const defaultTokenExtractor = (response) => {
15
- return getPath(response, "data.token") ?? getPath(response, "data.accessToken") ?? getPath(response, "token");
16
- };
17
- const defaultSessionBuilder = (user, token) => ({
18
- user,
19
- token,
20
- loggedInAt: (/* @__PURE__ */ new Date()).toISOString()
21
- });
22
- async function login(options) {
23
- const {
24
- loginPath,
25
- credentials,
26
- userInfoPath,
27
- tokenExtractor = defaultTokenExtractor,
28
- sessionBuilder = defaultSessionBuilder,
29
- endpoint
30
- } = options;
31
- const api = endpoint ? $api.use(endpoint) : $api;
32
- const loginResponse = await api.$fetch(loginPath, {
33
- method: "POST",
34
- body: credentials
35
- });
36
- const token = tokenExtractor(loginResponse);
37
- if (!token) {
38
- throw new Error("Login failed: token not found in response");
39
- }
40
- let userInfo;
41
- if (userInfoPath) {
42
- const endpointConfig = api.getConfig();
43
- const authConfig = endpointConfig.auth || moduleConfig.auth || {};
44
- const headerName = getHeaderName(authConfig);
45
- const headerValue = buildAuthHeader(token, authConfig);
46
- const userResponse = await api.$fetch(userInfoPath, {
47
- headers: { [headerName]: headerValue },
48
- context: { toast: false }
49
- });
50
- userInfo = getPath(userResponse, "data") ?? userResponse;
51
- } else {
52
- userInfo = getPath(loginResponse, "data") ?? loginResponse;
53
- }
54
- const sessionData = sessionBuilder(userInfo, token);
55
- await $fetch("/api/_movk/session", {
56
- method: "POST",
57
- body: sessionData
58
- });
59
- await userSession.fetch();
60
- return { user: userInfo, token };
61
- }
62
- return {
63
- login,
64
- ...userSession
65
- };
66
- }
@@ -1,50 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { AutoFormField, AutoFormFieldContext } from '../types/auto-form.js';
3
- export declare function useAutoFormProvider<T extends Record<string, any>>(state: Ref<T>, slots: Record<string, any>): {
4
- createFieldContext: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
5
- createSlotProps: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
6
- resolveFieldProp: <T_1 = any>(field: AutoFormField, prop: string, defaultValue?: T_1, extraProps?: Record<string, any>) => T_1 | undefined;
7
- renderFieldSlot: (fn?: (props?: any) => any, slotProps?: any) => any;
8
- getResolvedFieldSlots: (field: AutoFormField, extraProps?: Record<string, any>) => undefined;
9
- renderControl: (field: AutoFormField, extraProps?: Record<string, any>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
- [key: string]: any;
11
- }> | null;
12
- createSlotResolver: (field: AutoFormField, extraProps?: Record<string, any>) => {
13
- hasSlot(name: string): boolean;
14
- renderSlot(name: string, slotProps: any): any;
15
- };
16
- createFormFieldSlots: (field: AutoFormField, slotResolver: ReturnType<(field: AutoFormField, extraProps?: Record<string, any>) => {
17
- hasSlot(name: string): boolean;
18
- renderSlot(name: string, slotProps: any): any;
19
- }>, extraProps?: Record<string, any>) => Record<string, any>;
20
- createCollapsibleEnhancer: (field: AutoFormField, extraProps?: Record<string, any>) => {
21
- collapsibleConfig: import("vue").ComputedRef<undefined>;
22
- shouldShowCollapsible: import("vue").ComputedRef<boolean>;
23
- isHidden: import("vue").ComputedRef<undefined>;
24
- enhancedField: import("vue").ComputedRef<AutoFormField>;
25
- };
26
- };
27
- export declare function useAutoFormInjector(): {
28
- createFieldContext: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
29
- createSlotProps: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
30
- resolveFieldProp: <T = any>(field: AutoFormField, prop: string, defaultValue?: T | undefined, extraProps?: Record<string, any>) => T | undefined;
31
- renderFieldSlot: (fn?: ((props?: any) => any) | undefined, slotProps?: any) => any;
32
- getResolvedFieldSlots: (field: AutoFormField, extraProps?: Record<string, any>) => undefined;
33
- renderControl: (field: AutoFormField, extraProps?: Record<string, any>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
34
- [key: string]: any;
35
- }> | null;
36
- createSlotResolver: (field: AutoFormField, extraProps?: Record<string, any>) => {
37
- hasSlot(name: string): boolean;
38
- renderSlot(name: string, slotProps: any): any;
39
- };
40
- createFormFieldSlots: (field: AutoFormField, slotResolver: {
41
- hasSlot(name: string): boolean;
42
- renderSlot(name: string, slotProps: any): any;
43
- }, extraProps?: Record<string, any>) => Record<string, any>;
44
- createCollapsibleEnhancer: (field: AutoFormField, extraProps?: Record<string, any>) => {
45
- collapsibleConfig: import("vue").ComputedRef<undefined>;
46
- shouldShowCollapsible: import("vue").ComputedRef<boolean>;
47
- isHidden: import("vue").ComputedRef<undefined>;
48
- enhancedField: import("vue").ComputedRef<AutoFormField>;
49
- };
50
- };