@nuxt/ui 2.8.1 → 2.9.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.
- package/README.md +1 -0
- package/dist/module.d.mts +1147 -1096
- package/dist/module.d.ts +1147 -1096
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -10
- package/dist/runtime/components/data/Table.vue +42 -29
- package/dist/runtime/components/data/Table.vue.d.ts +20 -13
- package/dist/runtime/components/elements/Accordion.vue +25 -22
- package/dist/runtime/components/elements/Accordion.vue.d.ts +21 -17
- package/dist/runtime/components/elements/Alert.vue +22 -18
- package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
- package/dist/runtime/components/elements/Avatar.vue +22 -16
- package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
- package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
- package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
- package/dist/runtime/components/elements/Badge.vue +21 -17
- package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
- package/dist/runtime/components/elements/Button.vue +22 -18
- package/dist/runtime/components/elements/Button.vue.d.ts +26 -17
- package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
- package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
- package/dist/runtime/components/elements/Dropdown.vue +15 -13
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +20 -17
- package/dist/runtime/components/elements/Kbd.vue +16 -12
- package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
- package/dist/runtime/components/elements/Link.vue +18 -5
- package/dist/runtime/components/forms/Checkbox.vue +27 -17
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
- package/dist/runtime/components/forms/Form.vue +2 -2
- package/dist/runtime/components/forms/FormGroup.vue +51 -27
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
- package/dist/runtime/components/forms/Input.vue +36 -28
- package/dist/runtime/components/forms/Input.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Radio.vue +27 -17
- package/dist/runtime/components/forms/Radio.vue.d.ts +35 -17
- package/dist/runtime/components/forms/Range.vue +26 -16
- package/dist/runtime/components/forms/Range.vue.d.ts +36 -17
- package/dist/runtime/components/forms/Select.vue +34 -26
- package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
- package/dist/runtime/components/forms/SelectMenu.vue +43 -33
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +49 -30
- package/dist/runtime/components/forms/Textarea.vue +38 -30
- package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Toggle.vue +26 -15
- package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
- package/dist/runtime/components/layout/Card.vue +15 -10
- package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Container.vue +15 -10
- package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Skeleton.vue +15 -10
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
- package/dist/runtime/components/navigation/CommandPalette.vue +50 -38
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +23 -22
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
- package/dist/runtime/components/navigation/Pagination.vue +64 -55
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +29 -22
- package/dist/runtime/components/navigation/Tabs.vue +16 -13
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
- package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
- package/dist/runtime/components/overlays/ContextMenu.vue +14 -9
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +18 -10
- package/dist/runtime/components/overlays/Modal.vue +15 -13
- package/dist/runtime/components/overlays/Modal.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Notification.vue +18 -14
- package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
- package/dist/runtime/components/overlays/Notifications.vue +18 -12
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
- package/dist/runtime/components/overlays/Popover.vue +18 -16
- package/dist/runtime/components/overlays/Popover.vue.d.ts +18 -11
- package/dist/runtime/components/overlays/Slideover.vue +15 -13
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Tooltip.vue +15 -13
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +18 -11
- package/dist/runtime/composables/useFormGroup.d.ts +12 -2
- package/dist/runtime/composables/useFormGroup.mjs +10 -4
- package/dist/runtime/composables/usePopper.mjs +40 -30
- package/dist/runtime/composables/useToast.d.ts +3 -3
- package/dist/runtime/composables/useUI.d.ts +10 -0
- package/dist/runtime/composables/useUI.mjs +24 -0
- package/dist/runtime/types/avatar.d.ts +10 -4
- package/dist/runtime/types/badge.d.ts +14 -0
- package/dist/runtime/types/button.d.ts +10 -3
- package/dist/runtime/types/command-palette.d.ts +2 -1
- package/dist/runtime/types/form.d.ts +8 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/link.d.ts +1 -0
- package/dist/runtime/types/notification.d.ts +5 -3
- package/dist/runtime/types/tabs.d.ts +1 -0
- package/dist/runtime/types/utils.d.ts +11 -0
- package/dist/runtime/ui.config.d.ts +1207 -0
- package/dist/runtime/{app.config.mjs → ui.config.mjs} +52 -80
- package/dist/runtime/utils/index.d.ts +5 -11
- package/dist/runtime/utils/index.mjs +21 -9
- package/dist/runtime/utils/lodash.d.ts +2 -0
- package/dist/runtime/utils/lodash.mjs +23 -0
- package/dist/runtime/utils/uid.d.ts +1 -0
- package/dist/runtime/utils/uid.mjs +4 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +19 -21
- package/dist/runtime/app.config.d.ts +0 -1203
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
|
-
import type { PopperOptions } from '../../types
|
|
2
|
+
import type { PopperOptions } from '../../types';
|
|
4
3
|
declare const _default: import("vue").DefineComponent<{
|
|
5
4
|
modelValue: {
|
|
6
|
-
type: (ObjectConstructor |
|
|
5
|
+
type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
|
|
7
6
|
default: string;
|
|
8
7
|
};
|
|
9
8
|
by: {
|
|
@@ -17,6 +16,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
17
16
|
}[]>;
|
|
18
17
|
default: () => never[];
|
|
19
18
|
};
|
|
19
|
+
id: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: null;
|
|
22
|
+
};
|
|
20
23
|
name: {
|
|
21
24
|
type: StringConstructor;
|
|
22
25
|
default: null;
|
|
@@ -90,17 +93,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
90
93
|
default: boolean;
|
|
91
94
|
};
|
|
92
95
|
size: {
|
|
93
|
-
type:
|
|
94
|
-
default:
|
|
96
|
+
type: PropType<string | number | symbol>;
|
|
97
|
+
default: null;
|
|
95
98
|
validator(value: string): boolean;
|
|
96
99
|
};
|
|
97
100
|
color: {
|
|
98
|
-
type:
|
|
101
|
+
type: PropType<any>;
|
|
99
102
|
default: () => any;
|
|
100
103
|
validator(value: string): boolean;
|
|
101
104
|
};
|
|
102
105
|
variant: {
|
|
103
|
-
type:
|
|
106
|
+
type: PropType<any>;
|
|
104
107
|
default: () => any;
|
|
105
108
|
validator(value: string): boolean;
|
|
106
109
|
};
|
|
@@ -124,24 +127,30 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
124
127
|
type: StringConstructor;
|
|
125
128
|
default: null;
|
|
126
129
|
};
|
|
127
|
-
|
|
130
|
+
class: {
|
|
128
131
|
type: PropType<any>;
|
|
129
|
-
default:
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
ui: {
|
|
135
|
+
type: PropType<Partial<any>>;
|
|
136
|
+
default: undefined;
|
|
130
137
|
};
|
|
131
138
|
uiMenu: {
|
|
132
|
-
type: PropType<any
|
|
133
|
-
default:
|
|
139
|
+
type: PropType<Partial<any>>;
|
|
140
|
+
default: undefined;
|
|
134
141
|
};
|
|
135
142
|
}, {
|
|
136
|
-
|
|
137
|
-
[x: string]: unknown;
|
|
138
|
-
}, "class">;
|
|
143
|
+
ui: import("vue").ComputedRef<any>;
|
|
139
144
|
uiMenu: import("vue").ComputedRef<any>;
|
|
145
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
146
|
+
[x: string]: unknown;
|
|
147
|
+
}, string>>;
|
|
148
|
+
name: import("vue").ComputedRef<any>;
|
|
149
|
+
inputId: import("vue").ComputedRef<any>;
|
|
140
150
|
trigger: import("vue").Ref<import("@vueuse/core").MaybeElement>;
|
|
141
151
|
container: import("vue").Ref<import("@vueuse/core").MaybeElement>;
|
|
142
152
|
isLeading: import("vue").ComputedRef<string | true>;
|
|
143
153
|
isTrailing: import("vue").ComputedRef<string | true | undefined>;
|
|
144
|
-
wrapperClass: import("vue").ComputedRef<string>;
|
|
145
154
|
selectClass: import("vue").ComputedRef<string>;
|
|
146
155
|
leadingIconName: import("vue").ComputedRef<string | undefined>;
|
|
147
156
|
leadingIconClass: import("vue").ComputedRef<string>;
|
|
@@ -157,7 +166,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
157
166
|
onUpdate: (event: any) => void;
|
|
158
167
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "close" | "open" | "update:modelValue")[], "change" | "close" | "open" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
159
168
|
modelValue: {
|
|
160
|
-
type: (ObjectConstructor |
|
|
169
|
+
type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
|
|
161
170
|
default: string;
|
|
162
171
|
};
|
|
163
172
|
by: {
|
|
@@ -171,6 +180,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
171
180
|
}[]>;
|
|
172
181
|
default: () => never[];
|
|
173
182
|
};
|
|
183
|
+
id: {
|
|
184
|
+
type: StringConstructor;
|
|
185
|
+
default: null;
|
|
186
|
+
};
|
|
174
187
|
name: {
|
|
175
188
|
type: StringConstructor;
|
|
176
189
|
default: null;
|
|
@@ -244,17 +257,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
244
257
|
default: boolean;
|
|
245
258
|
};
|
|
246
259
|
size: {
|
|
247
|
-
type:
|
|
248
|
-
default:
|
|
260
|
+
type: PropType<string | number | symbol>;
|
|
261
|
+
default: null;
|
|
249
262
|
validator(value: string): boolean;
|
|
250
263
|
};
|
|
251
264
|
color: {
|
|
252
|
-
type:
|
|
265
|
+
type: PropType<any>;
|
|
253
266
|
default: () => any;
|
|
254
267
|
validator(value: string): boolean;
|
|
255
268
|
};
|
|
256
269
|
variant: {
|
|
257
|
-
type:
|
|
270
|
+
type: PropType<any>;
|
|
258
271
|
default: () => any;
|
|
259
272
|
validator(value: string): boolean;
|
|
260
273
|
};
|
|
@@ -278,13 +291,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
278
291
|
type: StringConstructor;
|
|
279
292
|
default: null;
|
|
280
293
|
};
|
|
281
|
-
|
|
294
|
+
class: {
|
|
282
295
|
type: PropType<any>;
|
|
283
|
-
default:
|
|
296
|
+
default: undefined;
|
|
297
|
+
};
|
|
298
|
+
ui: {
|
|
299
|
+
type: PropType<Partial<any>>;
|
|
300
|
+
default: undefined;
|
|
284
301
|
};
|
|
285
302
|
uiMenu: {
|
|
286
|
-
type: PropType<any
|
|
287
|
-
default:
|
|
303
|
+
type: PropType<Partial<any>>;
|
|
304
|
+
default: undefined;
|
|
288
305
|
};
|
|
289
306
|
}>> & {
|
|
290
307
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
@@ -292,23 +309,25 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
292
309
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
293
310
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
294
311
|
}, {
|
|
312
|
+
id: string;
|
|
295
313
|
icon: string;
|
|
296
|
-
color:
|
|
297
|
-
ui: any
|
|
298
|
-
name: string;
|
|
314
|
+
color: any;
|
|
315
|
+
ui: Partial<any>;
|
|
299
316
|
options: string[] | {
|
|
300
317
|
[key: string]: any;
|
|
301
318
|
disabled?: boolean | undefined;
|
|
302
319
|
}[];
|
|
303
320
|
popper: PopperOptions;
|
|
321
|
+
name: string;
|
|
322
|
+
class: any;
|
|
304
323
|
modelValue: string | number | unknown[] | Record<string, any>;
|
|
305
324
|
by: string;
|
|
306
325
|
loading: boolean;
|
|
307
326
|
disabled: boolean;
|
|
308
327
|
multiple: boolean;
|
|
309
|
-
variant:
|
|
328
|
+
variant: any;
|
|
310
329
|
required: boolean;
|
|
311
|
-
size: string;
|
|
330
|
+
size: string | number | symbol;
|
|
312
331
|
placeholder: string;
|
|
313
332
|
padded: boolean;
|
|
314
333
|
loadingIcon: string;
|
|
@@ -325,6 +344,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
325
344
|
debounce: number;
|
|
326
345
|
creatable: boolean;
|
|
327
346
|
searchAttributes: unknown[];
|
|
328
|
-
uiMenu: any
|
|
347
|
+
uiMenu: Partial<any>;
|
|
329
348
|
}, {}>;
|
|
330
349
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="
|
|
2
|
+
<div :class="ui.wrapper">
|
|
3
3
|
<textarea
|
|
4
|
+
:id="inputId"
|
|
4
5
|
ref="textarea"
|
|
5
6
|
:value="modelValue"
|
|
6
7
|
:name="name"
|
|
@@ -18,13 +19,14 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<script>
|
|
21
|
-
import { ref, computed, watch, onMounted, nextTick, defineComponent } from "vue";
|
|
22
|
-
import { omit } from "lodash-es";
|
|
22
|
+
import { ref, computed, toRef, watch, onMounted, nextTick, defineComponent } from "vue";
|
|
23
23
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
24
|
-
import {
|
|
24
|
+
import { useUI } from "../../composables/useUI";
|
|
25
25
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
26
|
-
import {
|
|
26
|
+
import { mergeConfig } from "../../utils";
|
|
27
27
|
import appConfig from "#build/app.config";
|
|
28
|
+
import { textarea } from "#ui/ui.config";
|
|
29
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.textarea, textarea);
|
|
28
30
|
export default defineComponent({
|
|
29
31
|
inheritAttrs: false,
|
|
30
32
|
props: {
|
|
@@ -32,6 +34,10 @@ export default defineComponent({
|
|
|
32
34
|
type: [String, Number],
|
|
33
35
|
default: ""
|
|
34
36
|
},
|
|
37
|
+
id: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: null
|
|
40
|
+
},
|
|
35
41
|
name: {
|
|
36
42
|
type: String,
|
|
37
43
|
default: null
|
|
@@ -70,25 +76,25 @@ export default defineComponent({
|
|
|
70
76
|
},
|
|
71
77
|
size: {
|
|
72
78
|
type: String,
|
|
73
|
-
default:
|
|
79
|
+
default: null,
|
|
74
80
|
validator(value) {
|
|
75
|
-
return Object.keys(
|
|
81
|
+
return Object.keys(config.size).includes(value);
|
|
76
82
|
}
|
|
77
83
|
},
|
|
78
84
|
color: {
|
|
79
85
|
type: String,
|
|
80
|
-
default: () =>
|
|
86
|
+
default: () => config.default.color,
|
|
81
87
|
validator(value) {
|
|
82
|
-
return [...appConfig.ui.colors, ...Object.keys(
|
|
88
|
+
return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value);
|
|
83
89
|
}
|
|
84
90
|
},
|
|
85
91
|
variant: {
|
|
86
92
|
type: String,
|
|
87
|
-
default: () =>
|
|
93
|
+
default: () => config.default.variant,
|
|
88
94
|
validator(value) {
|
|
89
95
|
return [
|
|
90
|
-
...Object.keys(
|
|
91
|
-
...Object.values(
|
|
96
|
+
...Object.keys(config.variant),
|
|
97
|
+
...Object.values(config.color).flatMap((value2) => Object.keys(value2))
|
|
92
98
|
].includes(value);
|
|
93
99
|
}
|
|
94
100
|
},
|
|
@@ -96,39 +102,40 @@ export default defineComponent({
|
|
|
96
102
|
type: String,
|
|
97
103
|
default: null
|
|
98
104
|
},
|
|
105
|
+
class: {
|
|
106
|
+
type: [String, Object, Array],
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
99
109
|
ui: {
|
|
100
110
|
type: Object,
|
|
101
|
-
default:
|
|
111
|
+
default: void 0
|
|
102
112
|
}
|
|
103
113
|
},
|
|
104
114
|
emits: ["update:modelValue", "blur"],
|
|
105
|
-
setup(props, { emit
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const { emitFormBlur, emitFormInput, formGroup } = useFormGroup();
|
|
110
|
-
const color = computed(() => formGroup?.error?.value ? "red" : props.color);
|
|
111
|
-
const size = computed(() => formGroup?.size?.value ?? props.size);
|
|
115
|
+
setup(props, { emit }) {
|
|
116
|
+
const { ui, attrs } = useUI("textarea", toRef(props, "ui"), config, toRef(props, "class"));
|
|
117
|
+
const { emitFormBlur, emitFormInput, inputId, color, size, name } = useFormGroup(props, config);
|
|
118
|
+
const textarea2 = ref(null);
|
|
112
119
|
const autoFocus = () => {
|
|
113
120
|
if (props.autofocus) {
|
|
114
|
-
|
|
121
|
+
textarea2.value?.focus();
|
|
115
122
|
}
|
|
116
123
|
};
|
|
117
124
|
const autoResize = () => {
|
|
118
125
|
if (props.autoresize) {
|
|
119
|
-
if (!
|
|
126
|
+
if (!textarea2.value) {
|
|
120
127
|
return;
|
|
121
128
|
}
|
|
122
|
-
|
|
123
|
-
const styles = window.getComputedStyle(
|
|
129
|
+
textarea2.value.rows = props.rows;
|
|
130
|
+
const styles = window.getComputedStyle(textarea2.value);
|
|
124
131
|
const paddingTop = parseInt(styles.paddingTop);
|
|
125
132
|
const paddingBottom = parseInt(styles.paddingBottom);
|
|
126
133
|
const padding = paddingTop + paddingBottom;
|
|
127
134
|
const lineHeight = parseInt(styles.lineHeight);
|
|
128
|
-
const { scrollHeight } =
|
|
135
|
+
const { scrollHeight } = textarea2.value;
|
|
129
136
|
const newRows = (scrollHeight - padding) / lineHeight;
|
|
130
137
|
if (newRows > props.rows) {
|
|
131
|
-
|
|
138
|
+
textarea2.value.rows = newRows;
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
};
|
|
@@ -155,7 +162,6 @@ export default defineComponent({
|
|
|
155
162
|
autoResize();
|
|
156
163
|
}, 100);
|
|
157
164
|
});
|
|
158
|
-
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
159
165
|
const textareaClass = computed(() => {
|
|
160
166
|
const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
|
|
161
167
|
return twMerge(twJoin(
|
|
@@ -169,11 +175,13 @@ export default defineComponent({
|
|
|
169
175
|
), props.textareaClass);
|
|
170
176
|
});
|
|
171
177
|
return {
|
|
172
|
-
attrs: omit(attrs, ["class"]),
|
|
173
178
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
174
179
|
ui,
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
attrs,
|
|
181
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
182
|
+
name,
|
|
183
|
+
inputId,
|
|
184
|
+
textarea: textarea2,
|
|
177
185
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
178
186
|
textareaClass,
|
|
179
187
|
onInput,
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
2
|
declare const _default: import("vue").DefineComponent<{
|
|
4
3
|
modelValue: {
|
|
5
|
-
type: (
|
|
4
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
6
5
|
default: string;
|
|
7
6
|
};
|
|
7
|
+
id: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: null;
|
|
10
|
+
};
|
|
8
11
|
name: {
|
|
9
12
|
type: StringConstructor;
|
|
10
13
|
default: null;
|
|
@@ -42,17 +45,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
42
45
|
default: boolean;
|
|
43
46
|
};
|
|
44
47
|
size: {
|
|
45
|
-
type:
|
|
46
|
-
default:
|
|
48
|
+
type: PropType<string | number | symbol>;
|
|
49
|
+
default: null;
|
|
47
50
|
validator(value: string): boolean;
|
|
48
51
|
};
|
|
49
52
|
color: {
|
|
50
|
-
type:
|
|
53
|
+
type: PropType<any>;
|
|
51
54
|
default: () => any;
|
|
52
55
|
validator(value: string): boolean;
|
|
53
56
|
};
|
|
54
57
|
variant: {
|
|
55
|
-
type:
|
|
58
|
+
type: PropType<any>;
|
|
56
59
|
default: () => any;
|
|
57
60
|
validator(value: string): boolean;
|
|
58
61
|
};
|
|
@@ -60,25 +63,34 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
60
63
|
type: StringConstructor;
|
|
61
64
|
default: null;
|
|
62
65
|
};
|
|
63
|
-
|
|
66
|
+
class: {
|
|
64
67
|
type: PropType<any>;
|
|
65
|
-
default:
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
ui: {
|
|
71
|
+
type: PropType<Partial<any>>;
|
|
72
|
+
default: undefined;
|
|
66
73
|
};
|
|
67
74
|
}, {
|
|
68
|
-
attrs: import("lodash").Omit<{
|
|
69
|
-
[x: string]: unknown;
|
|
70
|
-
}, "class">;
|
|
71
75
|
ui: import("vue").ComputedRef<any>;
|
|
76
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
77
|
+
[x: string]: unknown;
|
|
78
|
+
}, string>>;
|
|
79
|
+
name: import("vue").ComputedRef<any>;
|
|
80
|
+
inputId: import("vue").ComputedRef<any>;
|
|
72
81
|
textarea: import("vue").Ref<HTMLTextAreaElement | null>;
|
|
73
|
-
wrapperClass: import("vue").ComputedRef<string>;
|
|
74
82
|
textareaClass: import("vue").ComputedRef<string>;
|
|
75
83
|
onInput: (event: InputEvent) => void;
|
|
76
84
|
onBlur: (event: FocusEvent) => void;
|
|
77
85
|
}, 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<{
|
|
78
86
|
modelValue: {
|
|
79
|
-
type: (
|
|
87
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
80
88
|
default: string;
|
|
81
89
|
};
|
|
90
|
+
id: {
|
|
91
|
+
type: StringConstructor;
|
|
92
|
+
default: null;
|
|
93
|
+
};
|
|
82
94
|
name: {
|
|
83
95
|
type: StringConstructor;
|
|
84
96
|
default: null;
|
|
@@ -116,17 +128,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
116
128
|
default: boolean;
|
|
117
129
|
};
|
|
118
130
|
size: {
|
|
119
|
-
type:
|
|
120
|
-
default:
|
|
131
|
+
type: PropType<string | number | symbol>;
|
|
132
|
+
default: null;
|
|
121
133
|
validator(value: string): boolean;
|
|
122
134
|
};
|
|
123
135
|
color: {
|
|
124
|
-
type:
|
|
136
|
+
type: PropType<any>;
|
|
125
137
|
default: () => any;
|
|
126
138
|
validator(value: string): boolean;
|
|
127
139
|
};
|
|
128
140
|
variant: {
|
|
129
|
-
type:
|
|
141
|
+
type: PropType<any>;
|
|
130
142
|
default: () => any;
|
|
131
143
|
validator(value: string): boolean;
|
|
132
144
|
};
|
|
@@ -134,24 +146,30 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
134
146
|
type: StringConstructor;
|
|
135
147
|
default: null;
|
|
136
148
|
};
|
|
137
|
-
|
|
149
|
+
class: {
|
|
138
150
|
type: PropType<any>;
|
|
139
|
-
default:
|
|
151
|
+
default: undefined;
|
|
152
|
+
};
|
|
153
|
+
ui: {
|
|
154
|
+
type: PropType<Partial<any>>;
|
|
155
|
+
default: undefined;
|
|
140
156
|
};
|
|
141
157
|
}>> & {
|
|
142
158
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
143
159
|
onBlur?: ((...args: any[]) => any) | undefined;
|
|
144
160
|
}, {
|
|
145
161
|
resize: boolean;
|
|
146
|
-
|
|
147
|
-
|
|
162
|
+
id: string;
|
|
163
|
+
color: any;
|
|
164
|
+
ui: Partial<any>;
|
|
148
165
|
name: string;
|
|
166
|
+
class: any;
|
|
149
167
|
modelValue: string | number;
|
|
150
168
|
rows: number;
|
|
151
169
|
disabled: boolean;
|
|
152
|
-
variant:
|
|
170
|
+
variant: any;
|
|
153
171
|
required: boolean;
|
|
154
|
-
size: string;
|
|
172
|
+
size: string | number | symbol;
|
|
155
173
|
placeholder: string;
|
|
156
174
|
padded: boolean;
|
|
157
175
|
autofocus: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<HSwitch
|
|
3
|
+
:id="inputId"
|
|
3
4
|
v-model="active"
|
|
4
5
|
:name="name"
|
|
5
6
|
:disabled="disabled"
|
|
@@ -18,15 +19,16 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<script>
|
|
21
|
-
import { computed, defineComponent } from "vue";
|
|
22
|
+
import { computed, toRef, defineComponent } from "vue";
|
|
22
23
|
import { Switch as HSwitch } from "@headlessui/vue";
|
|
23
|
-
import { omit } from "lodash-es";
|
|
24
24
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
25
25
|
import UIcon from "../elements/Icon.vue";
|
|
26
|
-
import {
|
|
26
|
+
import { useUI } from "../../composables/useUI";
|
|
27
27
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
28
|
-
import {
|
|
28
|
+
import { mergeConfig } from "../../utils";
|
|
29
29
|
import appConfig from "#build/app.config";
|
|
30
|
+
import { toggle } from "#ui/ui.config";
|
|
31
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.toggle, toggle);
|
|
30
32
|
export default defineComponent({
|
|
31
33
|
components: {
|
|
32
34
|
HSwitch,
|
|
@@ -34,6 +36,10 @@ export default defineComponent({
|
|
|
34
36
|
},
|
|
35
37
|
inheritAttrs: false,
|
|
36
38
|
props: {
|
|
39
|
+
id: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: null
|
|
42
|
+
},
|
|
37
43
|
name: {
|
|
38
44
|
type: String,
|
|
39
45
|
default: null
|
|
@@ -48,30 +54,32 @@ export default defineComponent({
|
|
|
48
54
|
},
|
|
49
55
|
onIcon: {
|
|
50
56
|
type: String,
|
|
51
|
-
default: () =>
|
|
57
|
+
default: () => config.default.onIcon
|
|
52
58
|
},
|
|
53
59
|
offIcon: {
|
|
54
60
|
type: String,
|
|
55
|
-
default: () =>
|
|
61
|
+
default: () => config.default.offIcon
|
|
56
62
|
},
|
|
57
63
|
color: {
|
|
58
64
|
type: String,
|
|
59
|
-
default: () =>
|
|
65
|
+
default: () => config.default.color,
|
|
60
66
|
validator(value) {
|
|
61
67
|
return appConfig.ui.colors.includes(value);
|
|
62
68
|
}
|
|
63
69
|
},
|
|
70
|
+
class: {
|
|
71
|
+
type: [String, Object, Array],
|
|
72
|
+
default: void 0
|
|
73
|
+
},
|
|
64
74
|
ui: {
|
|
65
75
|
type: Object,
|
|
66
|
-
default:
|
|
76
|
+
default: void 0
|
|
67
77
|
}
|
|
68
78
|
},
|
|
69
79
|
emits: ["update:modelValue"],
|
|
70
|
-
setup(props, { emit
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const { emitFormChange, formGroup } = useFormGroup();
|
|
74
|
-
const color = computed(() => formGroup?.error?.value ? "red" : props.color);
|
|
80
|
+
setup(props, { emit }) {
|
|
81
|
+
const { ui, attrs } = useUI("toggle", toRef(props, "ui"), config);
|
|
82
|
+
const { emitFormChange, color, inputId, name } = useFormGroup(props);
|
|
75
83
|
const active = computed({
|
|
76
84
|
get() {
|
|
77
85
|
return props.modelValue;
|
|
@@ -87,7 +95,7 @@ export default defineComponent({
|
|
|
87
95
|
ui.value.rounded,
|
|
88
96
|
ui.value.ring.replaceAll("{color}", color.value),
|
|
89
97
|
(active.value ? ui.value.active : ui.value.inactive).replaceAll("{color}", color.value)
|
|
90
|
-
),
|
|
98
|
+
), props.class);
|
|
91
99
|
});
|
|
92
100
|
const onIconClass = computed(() => {
|
|
93
101
|
return twJoin(
|
|
@@ -100,9 +108,12 @@ export default defineComponent({
|
|
|
100
108
|
);
|
|
101
109
|
});
|
|
102
110
|
return {
|
|
103
|
-
attrs: omit(attrs, ["class"]),
|
|
104
111
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
105
112
|
ui,
|
|
113
|
+
attrs,
|
|
114
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
115
|
+
name,
|
|
116
|
+
inputId,
|
|
106
117
|
active,
|
|
107
118
|
switchClass,
|
|
108
119
|
onIconClass,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
2
|
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
id: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: null;
|
|
6
|
+
};
|
|
4
7
|
name: {
|
|
5
8
|
type: StringConstructor;
|
|
6
9
|
default: null;
|
|
@@ -22,24 +25,34 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
22
25
|
default: () => any;
|
|
23
26
|
};
|
|
24
27
|
color: {
|
|
25
|
-
type:
|
|
28
|
+
type: PropType<any>;
|
|
26
29
|
default: () => any;
|
|
27
30
|
validator(value: string): any;
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
class: {
|
|
30
33
|
type: PropType<any>;
|
|
31
|
-
default:
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
ui: {
|
|
37
|
+
type: PropType<Partial<any>>;
|
|
38
|
+
default: undefined;
|
|
32
39
|
};
|
|
33
40
|
}, {
|
|
34
|
-
attrs: import("lodash").Omit<{
|
|
35
|
-
[x: string]: unknown;
|
|
36
|
-
}, "class">;
|
|
37
41
|
ui: import("vue").ComputedRef<any>;
|
|
42
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
43
|
+
[x: string]: unknown;
|
|
44
|
+
}, string>>;
|
|
45
|
+
name: import("vue").ComputedRef<any>;
|
|
46
|
+
inputId: import("vue").ComputedRef<any>;
|
|
38
47
|
active: import("vue").WritableComputedRef<boolean>;
|
|
39
48
|
switchClass: import("vue").ComputedRef<string>;
|
|
40
49
|
onIconClass: import("vue").ComputedRef<string>;
|
|
41
50
|
offIconClass: import("vue").ComputedRef<string>;
|
|
42
51
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
id: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: null;
|
|
55
|
+
};
|
|
43
56
|
name: {
|
|
44
57
|
type: StringConstructor;
|
|
45
58
|
default: null;
|
|
@@ -61,20 +74,26 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
61
74
|
default: () => any;
|
|
62
75
|
};
|
|
63
76
|
color: {
|
|
64
|
-
type:
|
|
77
|
+
type: PropType<any>;
|
|
65
78
|
default: () => any;
|
|
66
79
|
validator(value: string): any;
|
|
67
80
|
};
|
|
68
|
-
|
|
81
|
+
class: {
|
|
69
82
|
type: PropType<any>;
|
|
70
|
-
default:
|
|
83
|
+
default: undefined;
|
|
84
|
+
};
|
|
85
|
+
ui: {
|
|
86
|
+
type: PropType<Partial<any>>;
|
|
87
|
+
default: undefined;
|
|
71
88
|
};
|
|
72
89
|
}>> & {
|
|
73
90
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
74
91
|
}, {
|
|
75
|
-
|
|
76
|
-
|
|
92
|
+
id: string;
|
|
93
|
+
color: any;
|
|
94
|
+
ui: Partial<any>;
|
|
77
95
|
name: string;
|
|
96
|
+
class: any;
|
|
78
97
|
modelValue: boolean;
|
|
79
98
|
disabled: boolean;
|
|
80
99
|
onIcon: string;
|