@nuxt/ui 0.4.1 → 2.8.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 (143) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +63 -50
  3. package/dist/module.cjs +5 -0
  4. package/dist/module.d.mts +1234 -0
  5. package/dist/module.d.ts +1234 -0
  6. package/dist/module.json +8 -0
  7. package/dist/module.mjs +407 -0
  8. package/dist/runtime/app.config.d.ts +1203 -0
  9. package/dist/runtime/app.config.mjs +1057 -0
  10. package/dist/runtime/components/data/Table.vue +251 -0
  11. package/dist/runtime/components/data/Table.vue.d.ts +215 -0
  12. package/dist/runtime/components/elements/Accordion.vue +138 -0
  13. package/dist/runtime/components/elements/Accordion.vue.d.ts +80 -0
  14. package/dist/runtime/components/elements/Alert.vue +120 -0
  15. package/dist/runtime/components/elements/Alert.vue.d.ts +107 -0
  16. package/dist/runtime/components/elements/Avatar.vue +149 -0
  17. package/dist/runtime/components/elements/Avatar.vue.d.ts +115 -0
  18. package/dist/runtime/components/elements/AvatarGroup.d.ts +37 -0
  19. package/dist/runtime/components/elements/AvatarGroup.mjs +53 -0
  20. package/dist/runtime/components/elements/Badge.vue +69 -0
  21. package/dist/runtime/components/elements/Badge.vue.d.ts +63 -0
  22. package/dist/runtime/components/elements/Button.vue +182 -0
  23. package/dist/runtime/components/elements/Button.vue.d.ts +187 -0
  24. package/dist/runtime/components/elements/ButtonGroup.d.ts +39 -0
  25. package/dist/runtime/components/elements/ButtonGroup.mjs +70 -0
  26. package/dist/runtime/components/elements/Dropdown.vue +172 -0
  27. package/dist/runtime/components/elements/Dropdown.vue.d.ts +96 -0
  28. package/dist/runtime/components/elements/Icon.vue +15 -0
  29. package/dist/runtime/components/elements/Icon.vue.d.ts +12 -0
  30. package/dist/runtime/components/elements/Kbd.vue +55 -0
  31. package/dist/runtime/components/elements/Kbd.vue.d.ts +42 -0
  32. package/dist/runtime/components/elements/Link.vue +80 -0
  33. package/dist/runtime/components/elements/Link.vue.d.ts +9 -0
  34. package/dist/runtime/components/forms/Checkbox.vue +136 -0
  35. package/dist/runtime/components/forms/Checkbox.vue.d.ts +129 -0
  36. package/dist/runtime/components/forms/Form.vue +186 -0
  37. package/dist/runtime/components/forms/Form.vue.d.ts +50 -0
  38. package/dist/runtime/components/forms/FormGroup.vue +97 -0
  39. package/dist/runtime/components/forms/FormGroup.vue.d.ts +98 -0
  40. package/dist/runtime/components/forms/Input.vue +250 -0
  41. package/dist/runtime/components/forms/Input.vue.d.ts +214 -0
  42. package/dist/runtime/components/forms/Radio.vue +122 -0
  43. package/dist/runtime/components/forms/Radio.vue.d.ts +109 -0
  44. package/dist/runtime/components/forms/Range.vue +163 -0
  45. package/dist/runtime/components/forms/Range.vue.d.ts +119 -0
  46. package/dist/runtime/components/forms/Select.vue +307 -0
  47. package/dist/runtime/components/forms/Select.vue.d.ts +229 -0
  48. package/dist/runtime/components/forms/SelectMenu.vue +429 -0
  49. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +330 -0
  50. package/dist/runtime/components/forms/Textarea.vue +184 -0
  51. package/dist/runtime/components/forms/Textarea.vue.d.ts +161 -0
  52. package/dist/runtime/components/forms/Toggle.vue +113 -0
  53. package/dist/runtime/components/forms/Toggle.vue.d.ts +83 -0
  54. package/dist/runtime/components/layout/Card.vue +58 -0
  55. package/dist/runtime/components/layout/Card.vue.d.ts +31 -0
  56. package/dist/runtime/components/layout/Container.vue +43 -0
  57. package/dist/runtime/components/layout/Container.vue.d.ts +31 -0
  58. package/dist/runtime/components/layout/Skeleton.vue +37 -0
  59. package/dist/runtime/components/layout/Skeleton.vue.d.ts +22 -0
  60. package/dist/runtime/components/navigation/CommandPalette.vue +304 -0
  61. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +224 -0
  62. package/dist/runtime/components/navigation/CommandPaletteGroup.vue +152 -0
  63. package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +63 -0
  64. package/dist/runtime/components/navigation/Pagination.vue +197 -0
  65. package/dist/runtime/components/navigation/Pagination.vue.d.ts +125 -0
  66. package/dist/runtime/components/navigation/Tabs.vue +138 -0
  67. package/dist/runtime/components/navigation/Tabs.vue.d.ts +69 -0
  68. package/dist/runtime/components/navigation/VerticalNavigation.vue +79 -0
  69. package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +37 -0
  70. package/dist/runtime/components/overlays/ContextMenu.vue +74 -0
  71. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +54 -0
  72. package/dist/runtime/components/overlays/Modal.vue +113 -0
  73. package/dist/runtime/components/overlays/Modal.vue.d.ts +82 -0
  74. package/dist/runtime/components/overlays/Notification.vue +197 -0
  75. package/dist/runtime/components/overlays/Notification.vue.d.ts +126 -0
  76. package/dist/runtime/components/overlays/Notifications.vue +61 -0
  77. package/dist/runtime/components/overlays/Notifications.vue.d.ts +41 -0
  78. package/dist/runtime/components/overlays/Popover.vue +139 -0
  79. package/dist/runtime/components/overlays/Popover.vue.d.ts +82 -0
  80. package/dist/runtime/components/overlays/Slideover.vue +103 -0
  81. package/dist/runtime/components/overlays/Slideover.vue.d.ts +84 -0
  82. package/dist/runtime/components/overlays/Tooltip.vue +118 -0
  83. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +82 -0
  84. package/dist/runtime/composables/defineShortcuts.d.ts +13 -0
  85. package/dist/runtime/composables/defineShortcuts.mjs +108 -0
  86. package/dist/runtime/composables/useCopyToClipboard.d.ts +10 -0
  87. package/dist/runtime/composables/useCopyToClipboard.mjs +26 -0
  88. package/dist/runtime/composables/useFormGroup.d.ts +6 -0
  89. package/dist/runtime/composables/useFormGroup.mjs +30 -0
  90. package/dist/runtime/composables/usePopper.d.ts +232 -0
  91. package/dist/runtime/composables/usePopper.mjs +78 -0
  92. package/dist/runtime/composables/useShortcuts.d.ts +12 -0
  93. package/dist/runtime/composables/useShortcuts.mjs +24 -0
  94. package/dist/runtime/composables/useTimer.d.ts +8 -0
  95. package/dist/runtime/composables/useTimer.mjs +51 -0
  96. package/dist/runtime/composables/useToast.d.ts +18 -0
  97. package/dist/runtime/composables/useToast.mjs +22 -0
  98. package/dist/runtime/plugins/colors.d.ts +2 -0
  99. package/dist/runtime/plugins/colors.mjs +46 -0
  100. package/dist/runtime/types/accordion.d.ts +9 -0
  101. package/dist/runtime/types/avatar.d.ts +9 -0
  102. package/dist/runtime/types/button.d.ts +23 -0
  103. package/dist/runtime/types/clipboard.d.ts +3 -0
  104. package/dist/runtime/types/command-palette.d.ts +26 -0
  105. package/dist/runtime/types/dropdown.d.ts +13 -0
  106. package/dist/runtime/types/form.d.ts +21 -0
  107. package/dist/runtime/types/index.d.ts +12 -0
  108. package/dist/runtime/types/link.d.ts +8 -0
  109. package/dist/runtime/types/notification.d.ts +22 -0
  110. package/dist/runtime/types/popper.d.ts +14 -0
  111. package/dist/runtime/types/tabs.d.ts +6 -0
  112. package/dist/runtime/types/vertical-navigation.d.ts +11 -0
  113. package/dist/runtime/ui.css +13 -0
  114. package/dist/runtime/utils/StateEmitter.d.ts +17 -0
  115. package/dist/runtime/utils/StateEmitter.mjs +21 -0
  116. package/dist/runtime/utils/index.d.ts +11 -0
  117. package/dist/runtime/utils/index.mjs +33 -0
  118. package/dist/types.d.mts +15 -0
  119. package/dist/types.d.ts +15 -0
  120. package/package.json +56 -39
  121. package/LICENSE +0 -21
  122. package/dist/assets/styles.css +0 -14
  123. package/dist/components/NButton.vue +0 -22
  124. package/dist/components/NCard.vue +0 -5
  125. package/dist/components/NCheckbox.vue +0 -35
  126. package/dist/components/NDarkToggle.vue +0 -28
  127. package/dist/components/NDialog.vue +0 -59
  128. package/dist/components/NDropdown.vue +0 -31
  129. package/dist/components/NIcon.vue +0 -9
  130. package/dist/components/NLink.vue +0 -20
  131. package/dist/components/NRadio.vue +0 -40
  132. package/dist/components/NSwitch.vue +0 -37
  133. package/dist/components/NTextInput.vue +0 -34
  134. package/dist/components/NTip.vue +0 -16
  135. package/dist/components/NuxtContentLogo.vue +0 -7
  136. package/dist/components/NuxtExampleLayout.vue +0 -82
  137. package/dist/components/NuxtLogo.vue +0 -20
  138. package/dist/components/nuxt/NDarkToggle.vue +0 -28
  139. package/dist/nuxt.d.ts +0 -16
  140. package/dist/nuxt.mjs +0 -36
  141. package/dist/unocss.d.ts +0 -7
  142. package/dist/unocss.mjs +0 -127
  143. package/nuxt.cjs +0 -7
@@ -0,0 +1,129 @@
1
+ /// <reference types="lodash" />
2
+ import type { PropType } from 'vue';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ value: {
5
+ type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
6
+ default: null;
7
+ };
8
+ modelValue: {
9
+ type: (BooleanConstructor | ArrayConstructor)[];
10
+ default: null;
11
+ };
12
+ name: {
13
+ type: StringConstructor;
14
+ default: null;
15
+ };
16
+ disabled: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ checked: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ indeterminate: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ help: {
29
+ type: StringConstructor;
30
+ default: null;
31
+ };
32
+ label: {
33
+ type: StringConstructor;
34
+ default: null;
35
+ };
36
+ required: {
37
+ type: BooleanConstructor;
38
+ default: boolean;
39
+ };
40
+ color: {
41
+ type: StringConstructor;
42
+ default: () => any;
43
+ validator(value: string): any;
44
+ };
45
+ inputClass: {
46
+ type: StringConstructor;
47
+ default: string;
48
+ };
49
+ ui: {
50
+ type: PropType<any>;
51
+ default: () => {};
52
+ };
53
+ }, {
54
+ attrs: import("lodash").Omit<{
55
+ [x: string]: unknown;
56
+ }, "class">;
57
+ ui: import("vue").ComputedRef<any>;
58
+ toggle: import("vue").WritableComputedRef<boolean | unknown[]>;
59
+ wrapperClass: import("vue").ComputedRef<string>;
60
+ inputClass: import("vue").ComputedRef<string>;
61
+ onChange: (event: Event) => void;
62
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
63
+ value: {
64
+ type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
65
+ default: null;
66
+ };
67
+ modelValue: {
68
+ type: (BooleanConstructor | ArrayConstructor)[];
69
+ default: null;
70
+ };
71
+ name: {
72
+ type: StringConstructor;
73
+ default: null;
74
+ };
75
+ disabled: {
76
+ type: BooleanConstructor;
77
+ default: boolean;
78
+ };
79
+ checked: {
80
+ type: BooleanConstructor;
81
+ default: boolean;
82
+ };
83
+ indeterminate: {
84
+ type: BooleanConstructor;
85
+ default: boolean;
86
+ };
87
+ help: {
88
+ type: StringConstructor;
89
+ default: null;
90
+ };
91
+ label: {
92
+ type: StringConstructor;
93
+ default: null;
94
+ };
95
+ required: {
96
+ type: BooleanConstructor;
97
+ default: boolean;
98
+ };
99
+ color: {
100
+ type: StringConstructor;
101
+ default: () => any;
102
+ validator(value: string): any;
103
+ };
104
+ inputClass: {
105
+ type: StringConstructor;
106
+ default: string;
107
+ };
108
+ ui: {
109
+ type: PropType<any>;
110
+ default: () => {};
111
+ };
112
+ }>> & {
113
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
114
+ onChange?: ((...args: any[]) => any) | undefined;
115
+ }, {
116
+ color: string;
117
+ ui: any;
118
+ name: string;
119
+ value: string | number | boolean | Record<string, any>;
120
+ label: string;
121
+ modelValue: boolean | unknown[];
122
+ indeterminate: boolean;
123
+ disabled: boolean;
124
+ required: boolean;
125
+ checked: boolean;
126
+ help: string;
127
+ inputClass: string;
128
+ }, {}>;
129
+ export default _default;
@@ -0,0 +1,186 @@
1
+ <template>
2
+ <form @submit.prevent="onSubmit">
3
+ <slot />
4
+ </form>
5
+ </template>
6
+
7
+ <script>
8
+ import { provide, ref, defineComponent } from "vue";
9
+ import { useEventBus } from "@vueuse/core";
10
+ import { safeParseAsync } from "valibot";
11
+ export default defineComponent({
12
+ props: {
13
+ schema: {
14
+ type: Object,
15
+ default: void 0
16
+ },
17
+ state: {
18
+ type: Object,
19
+ required: true
20
+ },
21
+ validate: {
22
+ type: Function,
23
+ default: () => []
24
+ },
25
+ validateOn: {
26
+ type: Array,
27
+ default: () => ["blur", "input", "change", "submit"]
28
+ }
29
+ },
30
+ emits: ["submit"],
31
+ setup(props, { expose, emit }) {
32
+ const seed = Math.random().toString(36).substring(7);
33
+ const bus = useEventBus(`form-${seed}`);
34
+ bus.on(async (event) => {
35
+ if (event.type !== "submit" && props.validateOn?.includes(event.type)) {
36
+ await validate(event.path, { silent: true });
37
+ }
38
+ });
39
+ const errors = ref([]);
40
+ provide("form-errors", errors);
41
+ provide("form-events", bus);
42
+ async function getErrors() {
43
+ let errs = await props.validate(props.state);
44
+ if (props.schema) {
45
+ if (isZodSchema(props.schema)) {
46
+ errs = errs.concat(await getZodErrors(props.state, props.schema));
47
+ } else if (isYupSchema(props.schema)) {
48
+ errs = errs.concat(await getYupErrors(props.state, props.schema));
49
+ } else if (isJoiSchema(props.schema)) {
50
+ errs = errs.concat(await getJoiErrors(props.state, props.schema));
51
+ } else if (isValibotSchema(props.schema)) {
52
+ errs = errs.concat(await getValibotError(props.state, props.schema));
53
+ } else {
54
+ throw new Error("Form validation failed: Unsupported form schema");
55
+ }
56
+ }
57
+ return errs;
58
+ }
59
+ async function validate(path, opts = { silent: false }) {
60
+ if (path) {
61
+ const otherErrors = errors.value.filter(
62
+ (error) => error.path !== path
63
+ );
64
+ const pathErrors = (await getErrors()).filter(
65
+ (error) => error.path === path
66
+ );
67
+ errors.value = otherErrors.concat(pathErrors);
68
+ } else {
69
+ errors.value = await getErrors();
70
+ }
71
+ if (!opts.silent && errors.value.length > 0) {
72
+ throw new Error(
73
+ `Form validation failed: ${JSON.stringify(errors.value, null, 2)}`
74
+ );
75
+ }
76
+ return props.state;
77
+ }
78
+ async function onSubmit(event) {
79
+ if (props.validateOn?.includes("submit")) {
80
+ await validate();
81
+ }
82
+ const submitEvent = event;
83
+ submitEvent.data = props.state;
84
+ emit("submit", event);
85
+ }
86
+ expose({
87
+ validate,
88
+ errors,
89
+ setErrors(errs, path) {
90
+ errors.value = errs;
91
+ if (path) {
92
+ errors.value = errors.value.filter(
93
+ (error) => error.path !== path
94
+ ).concat(errs);
95
+ } else {
96
+ errors.value = errs;
97
+ }
98
+ },
99
+ getErrors(path) {
100
+ if (path) {
101
+ return errors.value.filter((err) => err.path === path);
102
+ }
103
+ return errors.value;
104
+ },
105
+ clear(path) {
106
+ if (path) {
107
+ errors.value = errors.value.filter((err) => err.path === path);
108
+ } else {
109
+ errors.value = [];
110
+ }
111
+ }
112
+ });
113
+ return {
114
+ onSubmit
115
+ };
116
+ }
117
+ });
118
+ function isYupSchema(schema) {
119
+ return schema.validate && schema.__isYupSchema__;
120
+ }
121
+ function isYupError(error) {
122
+ return error.inner !== void 0;
123
+ }
124
+ async function getYupErrors(state, schema) {
125
+ try {
126
+ await schema.validate(state, { abortEarly: false });
127
+ return [];
128
+ } catch (error) {
129
+ if (isYupError(error)) {
130
+ return error.inner.map((issue) => ({
131
+ path: issue.path ?? "",
132
+ message: issue.message
133
+ }));
134
+ } else {
135
+ throw error;
136
+ }
137
+ }
138
+ }
139
+ function isZodSchema(schema) {
140
+ return schema.parse !== void 0;
141
+ }
142
+ async function getZodErrors(state, schema) {
143
+ const result = await schema.safeParseAsync(state);
144
+ if (result.success === false) {
145
+ return result.error.issues.map((issue) => ({
146
+ path: issue.path.join("."),
147
+ message: issue.message
148
+ }));
149
+ }
150
+ return [];
151
+ }
152
+ function isJoiSchema(schema) {
153
+ return schema.validateAsync !== void 0 && schema.id !== void 0;
154
+ }
155
+ function isJoiError(error) {
156
+ return error.isJoi === true;
157
+ }
158
+ async function getJoiErrors(state, schema) {
159
+ try {
160
+ await schema.validateAsync(state, { abortEarly: false });
161
+ return [];
162
+ } catch (error) {
163
+ if (isJoiError(error)) {
164
+ return error.details.map((detail) => ({
165
+ path: detail.path.join("."),
166
+ message: detail.message
167
+ }));
168
+ } else {
169
+ throw error;
170
+ }
171
+ }
172
+ }
173
+ function isValibotSchema(schema) {
174
+ return schema._parse !== void 0;
175
+ }
176
+ async function getValibotError(state, schema) {
177
+ const result = await safeParseAsync(schema, state);
178
+ if (result.success === false) {
179
+ return result.issues.map((issue) => ({
180
+ path: issue.path.map((p) => p.key).join("."),
181
+ message: issue.message
182
+ }));
183
+ }
184
+ return [];
185
+ }
186
+ </script>
@@ -0,0 +1,50 @@
1
+ import { type PropType } from 'vue';
2
+ import type { ZodSchema } from 'zod';
3
+ import type { Schema as JoiSchema } from 'joi';
4
+ import type { ObjectSchema as YupObjectSchema } from 'yup';
5
+ import type { ObjectSchema as ValibotObjectSchema } from 'valibot';
6
+ import type { FormError, FormEventType } from '../../types/form';
7
+ declare const _default: import("vue").DefineComponent<{
8
+ schema: {
9
+ type: PropType<ZodSchema<any, import("zod").ZodTypeDef, any>> | PropType<YupObjectSchema<any, import("yup").AnyObject, any, "">> | PropType<JoiSchema> | PropType<ValibotObjectSchema<any>>;
10
+ default: undefined;
11
+ };
12
+ state: {
13
+ type: ObjectConstructor;
14
+ required: true;
15
+ };
16
+ validate: {
17
+ type: PropType<(state: any) => Promise<FormError[]>> | PropType<(state: any) => FormError[]>;
18
+ default: () => never[];
19
+ };
20
+ validateOn: {
21
+ type: PropType<FormEventType[]>;
22
+ default: () => string[];
23
+ };
24
+ }, {
25
+ onSubmit: (event: SubmitEvent) => Promise<void>;
26
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "submit"[], "submit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
27
+ schema: {
28
+ type: PropType<ZodSchema<any, import("zod").ZodTypeDef, any>> | PropType<YupObjectSchema<any, import("yup").AnyObject, any, "">> | PropType<JoiSchema> | PropType<ValibotObjectSchema<any>>;
29
+ default: undefined;
30
+ };
31
+ state: {
32
+ type: ObjectConstructor;
33
+ required: true;
34
+ };
35
+ validate: {
36
+ type: PropType<(state: any) => Promise<FormError[]>> | PropType<(state: any) => FormError[]>;
37
+ default: () => never[];
38
+ };
39
+ validateOn: {
40
+ type: PropType<FormEventType[]>;
41
+ default: () => string[];
42
+ };
43
+ }>> & {
44
+ onSubmit?: ((...args: any[]) => any) | undefined;
45
+ }, {
46
+ schema: ZodSchema<any, import("zod").ZodTypeDef, any> | YupObjectSchema<any, import("yup").AnyObject, any, ""> | import("joi").AnySchema<any> | ValibotObjectSchema<any>;
47
+ validate: ((state: any) => Promise<FormError[]>) | ((state: any) => FormError[]);
48
+ validateOn: FormEventType[];
49
+ }, {}>;
50
+ export default _default;
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <div :class="wrapperClass" v-bind="attrs">
3
+ <label>
4
+ <div v-if="label" :class="[ui.label.wrapper, size]">
5
+ <p :class="[ui.label.base, required ? ui.label.required : '']">{{ label }}</p>
6
+ <span v-if="hint" :class="[ui.hint]">{{ hint }}</span>
7
+ </div>
8
+
9
+ <p v-if="description" :class="[ui.description, size]">{{ description }}</p>
10
+
11
+ <div :class="[label ? ui.container : '']">
12
+ <slot v-bind="{ error }" />
13
+
14
+ <p v-if="error && typeof error !== 'boolean'" :class="[ui.error, size]">{{ error }}</p>
15
+ <p v-else-if="help" :class="[ui.help, size]">{{ help }}</p>
16
+ </div>
17
+ </label>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import { computed, defineComponent, provide, inject } from "vue";
23
+ import { omit } from "lodash-es";
24
+ import { twMerge } from "tailwind-merge";
25
+ import { defuTwMerge } from "../../utils";
26
+ import { useAppConfig } from "#imports";
27
+ import appConfig from "#build/app.config";
28
+ export default defineComponent({
29
+ inheritAttrs: false,
30
+ props: {
31
+ name: {
32
+ type: String,
33
+ default: null
34
+ },
35
+ size: {
36
+ type: String,
37
+ default: null,
38
+ validator(value) {
39
+ return Object.keys(appConfig.ui.formGroup.size).includes(value);
40
+ }
41
+ },
42
+ label: {
43
+ type: String,
44
+ default: null
45
+ },
46
+ description: {
47
+ type: String,
48
+ default: null
49
+ },
50
+ required: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ help: {
55
+ type: String,
56
+ default: null
57
+ },
58
+ error: {
59
+ type: [String, Boolean],
60
+ default: null
61
+ },
62
+ hint: {
63
+ type: String,
64
+ default: null
65
+ },
66
+ ui: {
67
+ type: Object,
68
+ default: () => ({})
69
+ }
70
+ },
71
+ setup(props, { attrs }) {
72
+ const appConfig2 = useAppConfig();
73
+ const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.formGroup));
74
+ const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
75
+ const formErrors = inject("form-errors", null);
76
+ const error = computed(() => {
77
+ return props.error && typeof props.error === "string" || typeof props.error === "boolean" ? props.error : formErrors?.value?.find((error2) => error2.path === props.name)?.message;
78
+ });
79
+ const size = computed(() => ui.value.size[props.size ?? appConfig2.ui.input.default.size]);
80
+ provide("form-group", {
81
+ error,
82
+ name: computed(() => props.name),
83
+ size: computed(() => props.size)
84
+ });
85
+ return {
86
+ attrs: omit(attrs, ["class"]),
87
+ // eslint-disable-next-line vue/no-dupe-keys
88
+ ui,
89
+ wrapperClass,
90
+ // eslint-disable-next-line vue/no-dupe-keys
91
+ size,
92
+ // eslint-disable-next-line vue/no-dupe-keys
93
+ error
94
+ };
95
+ }
96
+ });
97
+ </script>
@@ -0,0 +1,98 @@
1
+ /// <reference types="lodash" />
2
+ import type { PropType } from 'vue';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ name: {
5
+ type: StringConstructor;
6
+ default: null;
7
+ };
8
+ size: {
9
+ type: StringConstructor;
10
+ default: null;
11
+ validator(value: string): boolean;
12
+ };
13
+ label: {
14
+ type: StringConstructor;
15
+ default: null;
16
+ };
17
+ description: {
18
+ type: StringConstructor;
19
+ default: null;
20
+ };
21
+ required: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ help: {
26
+ type: StringConstructor;
27
+ default: null;
28
+ };
29
+ error: {
30
+ type: (BooleanConstructor | StringConstructor)[];
31
+ default: null;
32
+ };
33
+ hint: {
34
+ type: StringConstructor;
35
+ default: null;
36
+ };
37
+ ui: {
38
+ type: PropType<any>;
39
+ default: () => {};
40
+ };
41
+ }, {
42
+ attrs: import("lodash").Omit<{
43
+ [x: string]: unknown;
44
+ }, "class">;
45
+ ui: import("vue").ComputedRef<any>;
46
+ wrapperClass: import("vue").ComputedRef<string>;
47
+ size: import("vue").ComputedRef<any>;
48
+ error: import("vue").ComputedRef<any>;
49
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
50
+ name: {
51
+ type: StringConstructor;
52
+ default: null;
53
+ };
54
+ size: {
55
+ type: StringConstructor;
56
+ default: null;
57
+ validator(value: string): boolean;
58
+ };
59
+ label: {
60
+ type: StringConstructor;
61
+ default: null;
62
+ };
63
+ description: {
64
+ type: StringConstructor;
65
+ default: null;
66
+ };
67
+ required: {
68
+ type: BooleanConstructor;
69
+ default: boolean;
70
+ };
71
+ help: {
72
+ type: StringConstructor;
73
+ default: null;
74
+ };
75
+ error: {
76
+ type: (BooleanConstructor | StringConstructor)[];
77
+ default: null;
78
+ };
79
+ hint: {
80
+ type: StringConstructor;
81
+ default: null;
82
+ };
83
+ ui: {
84
+ type: PropType<any>;
85
+ default: () => {};
86
+ };
87
+ }>>, {
88
+ error: string | boolean;
89
+ description: string;
90
+ ui: any;
91
+ name: string;
92
+ label: string;
93
+ required: boolean;
94
+ size: string;
95
+ help: string;
96
+ hint: string;
97
+ }, {}>;
98
+ export default _default;