@nuxt/ui 0.4.1 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +185 -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,250 @@
1
+ <template>
2
+ <div :class="wrapperClass">
3
+ <input
4
+ ref="input"
5
+ :name="name"
6
+ :value="modelValue"
7
+ :type="type"
8
+ :required="required"
9
+ :placeholder="placeholder"
10
+ :disabled="disabled || loading"
11
+ class="form-input"
12
+ :class="inputClass"
13
+ v-bind="attrs"
14
+ @input="onInput"
15
+ @blur="onBlur"
16
+ >
17
+ <slot />
18
+
19
+ <span v-if="(isLeading && leadingIconName) || $slots.leading" :class="leadingWrapperIconClass">
20
+ <slot name="leading" :disabled="disabled" :loading="loading">
21
+ <UIcon :name="leadingIconName" :class="leadingIconClass" />
22
+ </slot>
23
+ </span>
24
+
25
+ <span v-if="(isTrailing && trailingIconName) || $slots.trailing" :class="trailingWrapperIconClass">
26
+ <slot name="trailing" :disabled="disabled" :loading="loading">
27
+ <UIcon :name="trailingIconName" :class="trailingIconClass" />
28
+ </slot>
29
+ </span>
30
+ </div>
31
+ </template>
32
+
33
+ <script>
34
+ import { ref, computed, onMounted, defineComponent } from "vue";
35
+ import { omit } from "lodash-es";
36
+ import { twMerge, twJoin } from "tailwind-merge";
37
+ import UIcon from "../elements/Icon.vue";
38
+ import { defuTwMerge } from "../../utils";
39
+ import { useFormGroup } from "../../composables/useFormGroup";
40
+ import { useAppConfig } from "#imports";
41
+ import appConfig from "#build/app.config";
42
+ export default defineComponent({
43
+ components: {
44
+ UIcon
45
+ },
46
+ inheritAttrs: false,
47
+ props: {
48
+ modelValue: {
49
+ type: [String, Number],
50
+ default: ""
51
+ },
52
+ type: {
53
+ type: String,
54
+ default: "text"
55
+ },
56
+ name: {
57
+ type: String,
58
+ default: null
59
+ },
60
+ placeholder: {
61
+ type: String,
62
+ default: null
63
+ },
64
+ required: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ disabled: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ autofocus: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ icon: {
77
+ type: String,
78
+ default: null
79
+ },
80
+ loadingIcon: {
81
+ type: String,
82
+ default: () => appConfig.ui.input.default.loadingIcon
83
+ },
84
+ leadingIcon: {
85
+ type: String,
86
+ default: null
87
+ },
88
+ trailingIcon: {
89
+ type: String,
90
+ default: null
91
+ },
92
+ trailing: {
93
+ type: Boolean,
94
+ default: false
95
+ },
96
+ leading: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ loading: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ padded: {
105
+ type: Boolean,
106
+ default: true
107
+ },
108
+ size: {
109
+ type: String,
110
+ default: () => appConfig.ui.input.default.size,
111
+ validator(value) {
112
+ return Object.keys(appConfig.ui.input.size).includes(value);
113
+ }
114
+ },
115
+ color: {
116
+ type: String,
117
+ default: () => appConfig.ui.input.default.color,
118
+ validator(value) {
119
+ return [...appConfig.ui.colors, ...Object.keys(appConfig.ui.input.color)].includes(value);
120
+ }
121
+ },
122
+ variant: {
123
+ type: String,
124
+ default: () => appConfig.ui.input.default.variant,
125
+ validator(value) {
126
+ return [
127
+ ...Object.keys(appConfig.ui.input.variant),
128
+ ...Object.values(appConfig.ui.input.color).flatMap((value2) => Object.keys(value2))
129
+ ].includes(value);
130
+ }
131
+ },
132
+ inputClass: {
133
+ type: String,
134
+ default: null
135
+ },
136
+ ui: {
137
+ type: Object,
138
+ default: () => ({})
139
+ }
140
+ },
141
+ emits: ["update:modelValue", "blur"],
142
+ setup(props, { emit, attrs, slots }) {
143
+ const appConfig2 = useAppConfig();
144
+ const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.input));
145
+ const { emitFormBlur, emitFormInput, formGroup } = useFormGroup();
146
+ const color = computed(() => formGroup?.error?.value ? "red" : props.color);
147
+ const size = computed(() => formGroup?.size?.value ?? props.size);
148
+ const input = ref(null);
149
+ const autoFocus = () => {
150
+ if (props.autofocus) {
151
+ input.value?.focus();
152
+ }
153
+ };
154
+ const onInput = (event) => {
155
+ emit("update:modelValue", event.target.value);
156
+ emitFormInput();
157
+ };
158
+ const onBlur = (event) => {
159
+ emitFormBlur();
160
+ emit("blur", event);
161
+ };
162
+ onMounted(() => {
163
+ setTimeout(() => {
164
+ autoFocus();
165
+ }, 100);
166
+ });
167
+ const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
168
+ const inputClass = computed(() => {
169
+ const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
170
+ return twMerge(twJoin(
171
+ ui.value.base,
172
+ ui.value.rounded,
173
+ ui.value.placeholder,
174
+ ui.value.size[size.value],
175
+ props.padded ? ui.value.padding[size.value] : "p-0",
176
+ variant?.replaceAll("{color}", color.value),
177
+ (isLeading.value || slots.leading) && ui.value.leading.padding[size.value],
178
+ (isTrailing.value || slots.trailing) && ui.value.trailing.padding[size.value]
179
+ ), props.inputClass);
180
+ });
181
+ const isLeading = computed(() => {
182
+ return props.icon && props.leading || props.icon && !props.trailing || props.loading && !props.trailing || props.leadingIcon;
183
+ });
184
+ const isTrailing = computed(() => {
185
+ return props.icon && props.trailing || props.loading && props.trailing || props.trailingIcon;
186
+ });
187
+ const leadingIconName = computed(() => {
188
+ if (props.loading) {
189
+ return props.loadingIcon;
190
+ }
191
+ return props.leadingIcon || props.icon;
192
+ });
193
+ const trailingIconName = computed(() => {
194
+ if (props.loading && !isLeading.value) {
195
+ return props.loadingIcon;
196
+ }
197
+ return props.trailingIcon || props.icon;
198
+ });
199
+ const leadingWrapperIconClass = computed(() => {
200
+ return twJoin(
201
+ ui.value.icon.leading.wrapper,
202
+ ui.value.icon.leading.pointer,
203
+ ui.value.icon.leading.padding[size.value]
204
+ );
205
+ });
206
+ const leadingIconClass = computed(() => {
207
+ return twJoin(
208
+ ui.value.icon.base,
209
+ appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
210
+ ui.value.icon.size[size.value],
211
+ props.loading && "animate-spin"
212
+ );
213
+ });
214
+ const trailingWrapperIconClass = computed(() => {
215
+ return twJoin(
216
+ ui.value.icon.trailing.wrapper,
217
+ ui.value.icon.trailing.pointer,
218
+ ui.value.icon.trailing.padding[size.value]
219
+ );
220
+ });
221
+ const trailingIconClass = computed(() => {
222
+ return twJoin(
223
+ ui.value.icon.base,
224
+ appConfig2.ui.colors.includes(color.value) && ui.value.icon.color.replaceAll("{color}", color.value),
225
+ ui.value.icon.size[size.value],
226
+ props.loading && !isLeading.value && "animate-spin"
227
+ );
228
+ });
229
+ return {
230
+ attrs: omit(attrs, ["class"]),
231
+ // eslint-disable-next-line vue/no-dupe-keys
232
+ ui,
233
+ input,
234
+ isLeading,
235
+ isTrailing,
236
+ wrapperClass,
237
+ // eslint-disable-next-line vue/no-dupe-keys
238
+ inputClass,
239
+ leadingIconName,
240
+ leadingIconClass,
241
+ leadingWrapperIconClass,
242
+ trailingIconName,
243
+ trailingIconClass,
244
+ trailingWrapperIconClass,
245
+ onInput,
246
+ onBlur
247
+ };
248
+ }
249
+ });
250
+ </script>
@@ -0,0 +1,214 @@
1
+ /// <reference types="lodash" />
2
+ import type { PropType } from 'vue';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ modelValue: {
5
+ type: (StringConstructor | NumberConstructor)[];
6
+ default: string;
7
+ };
8
+ type: {
9
+ type: StringConstructor;
10
+ default: string;
11
+ };
12
+ name: {
13
+ type: StringConstructor;
14
+ default: null;
15
+ };
16
+ placeholder: {
17
+ type: StringConstructor;
18
+ default: null;
19
+ };
20
+ required: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ disabled: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ autofocus: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ icon: {
33
+ type: StringConstructor;
34
+ default: null;
35
+ };
36
+ loadingIcon: {
37
+ type: StringConstructor;
38
+ default: () => any;
39
+ };
40
+ leadingIcon: {
41
+ type: StringConstructor;
42
+ default: null;
43
+ };
44
+ trailingIcon: {
45
+ type: StringConstructor;
46
+ default: null;
47
+ };
48
+ trailing: {
49
+ type: BooleanConstructor;
50
+ default: boolean;
51
+ };
52
+ leading: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ loading: {
57
+ type: BooleanConstructor;
58
+ default: boolean;
59
+ };
60
+ padded: {
61
+ type: BooleanConstructor;
62
+ default: boolean;
63
+ };
64
+ size: {
65
+ type: StringConstructor;
66
+ default: () => any;
67
+ validator(value: string): boolean;
68
+ };
69
+ color: {
70
+ type: StringConstructor;
71
+ default: () => any;
72
+ validator(value: string): boolean;
73
+ };
74
+ variant: {
75
+ type: StringConstructor;
76
+ default: () => any;
77
+ validator(value: string): boolean;
78
+ };
79
+ inputClass: {
80
+ type: StringConstructor;
81
+ default: null;
82
+ };
83
+ ui: {
84
+ type: PropType<any>;
85
+ default: () => {};
86
+ };
87
+ }, {
88
+ attrs: import("lodash").Omit<{
89
+ [x: string]: unknown;
90
+ }, "class">;
91
+ ui: import("vue").ComputedRef<any>;
92
+ input: import("vue").Ref<HTMLInputElement | null>;
93
+ isLeading: import("vue").ComputedRef<string | true>;
94
+ isTrailing: import("vue").ComputedRef<string | true>;
95
+ wrapperClass: import("vue").ComputedRef<string>;
96
+ inputClass: import("vue").ComputedRef<string>;
97
+ leadingIconName: import("vue").ComputedRef<string | undefined>;
98
+ leadingIconClass: import("vue").ComputedRef<string>;
99
+ leadingWrapperIconClass: import("vue").ComputedRef<string>;
100
+ trailingIconName: import("vue").ComputedRef<string | undefined>;
101
+ trailingIconClass: import("vue").ComputedRef<string>;
102
+ trailingWrapperIconClass: import("vue").ComputedRef<string>;
103
+ onInput: (event: InputEvent) => void;
104
+ onBlur: (event: FocusEvent) => void;
105
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "update:modelValue")[], "blur" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
106
+ modelValue: {
107
+ type: (StringConstructor | NumberConstructor)[];
108
+ default: string;
109
+ };
110
+ type: {
111
+ type: StringConstructor;
112
+ default: string;
113
+ };
114
+ name: {
115
+ type: StringConstructor;
116
+ default: null;
117
+ };
118
+ placeholder: {
119
+ type: StringConstructor;
120
+ default: null;
121
+ };
122
+ required: {
123
+ type: BooleanConstructor;
124
+ default: boolean;
125
+ };
126
+ disabled: {
127
+ type: BooleanConstructor;
128
+ default: boolean;
129
+ };
130
+ autofocus: {
131
+ type: BooleanConstructor;
132
+ default: boolean;
133
+ };
134
+ icon: {
135
+ type: StringConstructor;
136
+ default: null;
137
+ };
138
+ loadingIcon: {
139
+ type: StringConstructor;
140
+ default: () => any;
141
+ };
142
+ leadingIcon: {
143
+ type: StringConstructor;
144
+ default: null;
145
+ };
146
+ trailingIcon: {
147
+ type: StringConstructor;
148
+ default: null;
149
+ };
150
+ trailing: {
151
+ type: BooleanConstructor;
152
+ default: boolean;
153
+ };
154
+ leading: {
155
+ type: BooleanConstructor;
156
+ default: boolean;
157
+ };
158
+ loading: {
159
+ type: BooleanConstructor;
160
+ default: boolean;
161
+ };
162
+ padded: {
163
+ type: BooleanConstructor;
164
+ default: boolean;
165
+ };
166
+ size: {
167
+ type: StringConstructor;
168
+ default: () => any;
169
+ validator(value: string): boolean;
170
+ };
171
+ color: {
172
+ type: StringConstructor;
173
+ default: () => any;
174
+ validator(value: string): boolean;
175
+ };
176
+ variant: {
177
+ type: StringConstructor;
178
+ default: () => any;
179
+ validator(value: string): boolean;
180
+ };
181
+ inputClass: {
182
+ type: StringConstructor;
183
+ default: null;
184
+ };
185
+ ui: {
186
+ type: PropType<any>;
187
+ default: () => {};
188
+ };
189
+ }>> & {
190
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
191
+ onBlur?: ((...args: any[]) => any) | undefined;
192
+ }, {
193
+ icon: string;
194
+ color: string;
195
+ ui: any;
196
+ name: string;
197
+ type: string;
198
+ modelValue: string | number;
199
+ loading: boolean;
200
+ disabled: boolean;
201
+ variant: string;
202
+ required: boolean;
203
+ size: string;
204
+ placeholder: string;
205
+ padded: boolean;
206
+ loadingIcon: string;
207
+ leadingIcon: string;
208
+ trailingIcon: string;
209
+ trailing: boolean;
210
+ leading: boolean;
211
+ autofocus: boolean;
212
+ inputClass: string;
213
+ }, {}>;
214
+ export default _default;
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <div :class="wrapperClass">
3
+ <div class="flex items-center h-5">
4
+ <input
5
+ :id="`${name}-${value}`"
6
+ v-model="pick"
7
+ :name="name"
8
+ :required="required"
9
+ :value="value"
10
+ :disabled="disabled"
11
+ type="radio"
12
+ class="form-radio"
13
+ :class="inputClass"
14
+ v-bind="attrs"
15
+ >
16
+ </div>
17
+ <div v-if="label || $slots.label" class="ms-3 text-sm">
18
+ <label :for="`${name}-${value}`" :class="ui.label">
19
+ <slot name="label">{{ label }}</slot>
20
+ <span v-if="required" :class="ui.required">*</span>
21
+ </label>
22
+ <p v-if="help" :class="ui.help">
23
+ {{ help }}
24
+ </p>
25
+ </div>
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+ import { computed, defineComponent } from "vue";
31
+ import { omit } from "lodash-es";
32
+ import { twMerge, twJoin } from "tailwind-merge";
33
+ import { defuTwMerge } from "../../utils";
34
+ import { useFormGroup } from "../../composables/useFormGroup";
35
+ import { useAppConfig } from "#imports";
36
+ import appConfig from "#build/app.config";
37
+ export default defineComponent({
38
+ inheritAttrs: false,
39
+ props: {
40
+ value: {
41
+ type: [String, Number, Boolean],
42
+ default: null
43
+ },
44
+ modelValue: {
45
+ type: [String, Number, Boolean, Object],
46
+ default: null
47
+ },
48
+ name: {
49
+ type: String,
50
+ default: null
51
+ },
52
+ disabled: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ help: {
57
+ type: String,
58
+ default: null
59
+ },
60
+ label: {
61
+ type: String,
62
+ default: null
63
+ },
64
+ required: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ color: {
69
+ type: String,
70
+ default: () => appConfig.ui.radio.default.color,
71
+ validator(value) {
72
+ return appConfig.ui.colors.includes(value);
73
+ }
74
+ },
75
+ inputClass: {
76
+ type: String,
77
+ default: null
78
+ },
79
+ ui: {
80
+ type: Object,
81
+ default: () => ({})
82
+ }
83
+ },
84
+ emits: ["update:modelValue"],
85
+ setup(props, { emit, attrs }) {
86
+ const appConfig2 = useAppConfig();
87
+ const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.radio));
88
+ const { emitFormChange, formGroup } = useFormGroup();
89
+ const color = computed(() => formGroup?.error?.value ? "red" : props.color);
90
+ const pick = computed({
91
+ get() {
92
+ return props.modelValue;
93
+ },
94
+ set(value) {
95
+ emit("update:modelValue", value);
96
+ if (value) {
97
+ emitFormChange();
98
+ }
99
+ }
100
+ });
101
+ const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
102
+ const inputClass = computed(() => {
103
+ return twMerge(twJoin(
104
+ ui.value.base,
105
+ ui.value.background,
106
+ ui.value.border,
107
+ ui.value.ring.replaceAll("{color}", color.value),
108
+ ui.value.color.replaceAll("{color}", color.value)
109
+ ), props.inputClass);
110
+ });
111
+ return {
112
+ attrs: omit(attrs, ["class"]),
113
+ // eslint-disable-next-line vue/no-dupe-keys
114
+ ui,
115
+ pick,
116
+ wrapperClass,
117
+ // eslint-disable-next-line vue/no-dupe-keys
118
+ inputClass
119
+ };
120
+ }
121
+ });
122
+ </script>
@@ -0,0 +1,109 @@
1
+ /// <reference types="lodash" />
2
+ import type { PropType } from 'vue';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ value: {
5
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
6
+ default: null;
7
+ };
8
+ modelValue: {
9
+ type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
10
+ default: null;
11
+ };
12
+ name: {
13
+ type: StringConstructor;
14
+ default: null;
15
+ };
16
+ disabled: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
20
+ help: {
21
+ type: StringConstructor;
22
+ default: null;
23
+ };
24
+ label: {
25
+ type: StringConstructor;
26
+ default: null;
27
+ };
28
+ required: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ color: {
33
+ type: StringConstructor;
34
+ default: () => any;
35
+ validator(value: string): any;
36
+ };
37
+ inputClass: {
38
+ type: StringConstructor;
39
+ default: null;
40
+ };
41
+ ui: {
42
+ type: PropType<any>;
43
+ default: () => {};
44
+ };
45
+ }, {
46
+ attrs: import("lodash").Omit<{
47
+ [x: string]: unknown;
48
+ }, "class">;
49
+ ui: import("vue").ComputedRef<any>;
50
+ pick: import("vue").WritableComputedRef<string | number | boolean | Record<string, any>>;
51
+ wrapperClass: import("vue").ComputedRef<string>;
52
+ inputClass: import("vue").ComputedRef<string>;
53
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
54
+ value: {
55
+ type: (BooleanConstructor | StringConstructor | NumberConstructor)[];
56
+ default: null;
57
+ };
58
+ modelValue: {
59
+ type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[];
60
+ default: null;
61
+ };
62
+ name: {
63
+ type: StringConstructor;
64
+ default: null;
65
+ };
66
+ disabled: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
70
+ help: {
71
+ type: StringConstructor;
72
+ default: null;
73
+ };
74
+ label: {
75
+ type: StringConstructor;
76
+ default: null;
77
+ };
78
+ required: {
79
+ type: BooleanConstructor;
80
+ default: boolean;
81
+ };
82
+ color: {
83
+ type: StringConstructor;
84
+ default: () => any;
85
+ validator(value: string): any;
86
+ };
87
+ inputClass: {
88
+ type: StringConstructor;
89
+ default: null;
90
+ };
91
+ ui: {
92
+ type: PropType<any>;
93
+ default: () => {};
94
+ };
95
+ }>> & {
96
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
97
+ }, {
98
+ color: string;
99
+ ui: any;
100
+ name: string;
101
+ value: string | number | boolean;
102
+ label: string;
103
+ modelValue: string | number | boolean | Record<string, any>;
104
+ disabled: boolean;
105
+ required: boolean;
106
+ help: string;
107
+ inputClass: string;
108
+ }, {}>;
109
+ export default _default;