@nuxt/ui 2.8.1 → 2.10.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 +1411 -1092
- package/dist/module.d.ts +1411 -1092
- package/dist/module.json +1 -1
- package/dist/module.mjs +55 -11
- package/dist/runtime/components/data/Table.vue +47 -32
- package/dist/runtime/components/data/Table.vue.d.ts +22 -14
- package/dist/runtime/components/elements/Accordion.vue +33 -28
- package/dist/runtime/components/elements/Accordion.vue.d.ts +25 -18
- 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 +28 -19
- 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 +45 -37
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +22 -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/elements/Meter.vue +166 -0
- package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
- package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
- package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
- package/dist/runtime/components/elements/Progress.vue +284 -0
- package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
- 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 +34 -9
- package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
- 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 +41 -29
- package/dist/runtime/components/forms/Input.vue.d.ts +51 -24
- package/dist/runtime/components/forms/Radio.vue +32 -21
- package/dist/runtime/components/forms/Radio.vue.d.ts +36 -18
- package/dist/runtime/components/forms/RadioGroup.vue +136 -0
- package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
- package/dist/runtime/components/forms/Range.vue +26 -16
- package/dist/runtime/components/forms/Range.vue.d.ts +37 -18
- 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 +104 -89
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +53 -33
- package/dist/runtime/components/forms/Textarea.vue +43 -31
- package/dist/runtime/components/forms/Textarea.vue.d.ts +50 -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/Divider.vue +107 -0
- package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
- 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 +57 -38
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +24 -23
- 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 +129 -64
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +70 -25
- package/dist/runtime/components/navigation/Tabs.vue +17 -14
- 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 +21 -11
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +20 -11
- package/dist/runtime/components/overlays/Modal.vue +16 -14
- package/dist/runtime/components/overlays/Modal.vue.d.ts +18 -11
- package/dist/runtime/components/overlays/Notification.vue +25 -15
- package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
- package/dist/runtime/components/overlays/Notifications.vue +19 -13
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
- package/dist/runtime/components/overlays/Popover.vue +39 -22
- package/dist/runtime/components/overlays/Popover.vue.d.ts +32 -11
- package/dist/runtime/components/overlays/Slideover.vue +15 -13
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +18 -11
- package/dist/runtime/components/overlays/Tooltip.vue +31 -23
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +19 -11
- package/dist/runtime/composables/useFormGroup.d.ts +12 -2
- package/dist/runtime/composables/useFormGroup.mjs +21 -4
- package/dist/runtime/composables/usePopper.d.ts +3 -3
- package/dist/runtime/composables/usePopper.mjs +47 -31
- 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 +3 -1
- package/dist/runtime/types/form.d.ts +18 -4
- package/dist/runtime/types/index.d.ts +4 -0
- package/dist/runtime/types/link.d.ts +1 -0
- package/dist/runtime/types/meter.d.ts +5 -0
- package/dist/runtime/types/notification.d.ts +5 -3
- package/dist/runtime/types/popper.d.ts +1 -0
- package/dist/runtime/types/progress.d.ts +4 -0
- 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 +1470 -0
- package/dist/runtime/{app.config.mjs → ui.config.mjs} +313 -97
- 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 +27 -29
- package/dist/runtime/app.config.d.ts +0 -1203
- package/dist/runtime/utils/StateEmitter.d.ts +0 -17
- package/dist/runtime/utils/StateEmitter.mjs +0 -21
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="
|
|
2
|
+
<div :class="ui.wrapper">
|
|
3
3
|
<div class="flex items-center h-5">
|
|
4
4
|
<input
|
|
5
|
-
:id="
|
|
5
|
+
:id="id"
|
|
6
6
|
v-model="pick"
|
|
7
7
|
:name="name"
|
|
8
8
|
:required="required"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
v-bind="attrs"
|
|
15
15
|
>
|
|
16
16
|
</div>
|
|
17
|
-
<div v-if="label || $slots.label" class="ms-3
|
|
18
|
-
<label :for="
|
|
17
|
+
<div v-if="label || $slots.label" class="ms-3 inline-flex items-center">
|
|
18
|
+
<label :for="id" :class="ui.label">
|
|
19
19
|
<slot name="label">{{ label }}</slot>
|
|
20
20
|
<span v-if="required" :class="ui.required">*</span>
|
|
21
21
|
</label>
|
|
@@ -27,16 +27,23 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script>
|
|
30
|
-
import { computed, defineComponent } from "vue";
|
|
31
|
-
import { omit } from "lodash-es";
|
|
30
|
+
import { computed, defineComponent, inject, toRef } from "vue";
|
|
32
31
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { useAppConfig } from "#imports";
|
|
32
|
+
import { useUI } from "../../composables/useUI";
|
|
33
|
+
import { mergeConfig } from "../../utils";
|
|
36
34
|
import appConfig from "#build/app.config";
|
|
35
|
+
import { radio } from "#ui/ui.config";
|
|
36
|
+
import { uid } from "../../utils/uid";
|
|
37
|
+
import { useFormGroup } from "../../composables/useFormGroup";
|
|
38
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.radio, radio);
|
|
37
39
|
export default defineComponent({
|
|
38
40
|
inheritAttrs: false,
|
|
39
41
|
props: {
|
|
42
|
+
id: {
|
|
43
|
+
type: String,
|
|
44
|
+
// A default value is needed here to bind the label
|
|
45
|
+
default: () => uid()
|
|
46
|
+
},
|
|
40
47
|
value: {
|
|
41
48
|
type: [String, Number, Boolean],
|
|
42
49
|
default: null
|
|
@@ -67,7 +74,7 @@ export default defineComponent({
|
|
|
67
74
|
},
|
|
68
75
|
color: {
|
|
69
76
|
type: String,
|
|
70
|
-
default: () =>
|
|
77
|
+
default: () => config.default.color,
|
|
71
78
|
validator(value) {
|
|
72
79
|
return appConfig.ui.colors.includes(value);
|
|
73
80
|
}
|
|
@@ -76,29 +83,32 @@ export default defineComponent({
|
|
|
76
83
|
type: String,
|
|
77
84
|
default: null
|
|
78
85
|
},
|
|
86
|
+
class: {
|
|
87
|
+
type: [String, Object, Array],
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
79
90
|
ui: {
|
|
80
91
|
type: Object,
|
|
81
|
-
default:
|
|
92
|
+
default: void 0
|
|
82
93
|
}
|
|
83
94
|
},
|
|
84
|
-
emits: ["update:modelValue"],
|
|
85
|
-
setup(props, { emit
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const { emitFormChange,
|
|
89
|
-
const color = computed(() => formGroup?.error?.value ? "red" : props.color);
|
|
95
|
+
emits: ["update:modelValue", "change"],
|
|
96
|
+
setup(props, { emit }) {
|
|
97
|
+
const { ui, attrs } = useUI("radio", toRef(props, "ui"), config, toRef(props, "class"));
|
|
98
|
+
const radioGroup = inject("radio-group", null);
|
|
99
|
+
const { emitFormChange, color, name } = radioGroup ?? useFormGroup(props, config);
|
|
90
100
|
const pick = computed({
|
|
91
101
|
get() {
|
|
92
102
|
return props.modelValue;
|
|
93
103
|
},
|
|
94
104
|
set(value) {
|
|
95
105
|
emit("update:modelValue", value);
|
|
96
|
-
|
|
106
|
+
emit("change", value);
|
|
107
|
+
if (!radioGroup) {
|
|
97
108
|
emitFormChange();
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
111
|
});
|
|
101
|
-
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
102
112
|
const inputClass = computed(() => {
|
|
103
113
|
return twMerge(twJoin(
|
|
104
114
|
ui.value.base,
|
|
@@ -109,11 +119,12 @@ export default defineComponent({
|
|
|
109
119
|
), props.inputClass);
|
|
110
120
|
});
|
|
111
121
|
return {
|
|
112
|
-
attrs: omit(attrs, ["class"]),
|
|
113
122
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
114
123
|
ui,
|
|
124
|
+
attrs,
|
|
115
125
|
pick,
|
|
116
|
-
|
|
126
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
127
|
+
name,
|
|
117
128
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
118
129
|
inputClass
|
|
119
130
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
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: () => string;
|
|
6
|
+
};
|
|
4
7
|
value: {
|
|
5
|
-
type: (BooleanConstructor |
|
|
8
|
+
type: (BooleanConstructor | NumberConstructor | StringConstructor)[];
|
|
6
9
|
default: null;
|
|
7
10
|
};
|
|
8
11
|
modelValue: {
|
|
9
|
-
type: (ObjectConstructor | BooleanConstructor |
|
|
12
|
+
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
|
|
10
13
|
default: null;
|
|
11
14
|
};
|
|
12
15
|
name: {
|
|
@@ -30,7 +33,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
33
|
default: boolean;
|
|
31
34
|
};
|
|
32
35
|
color: {
|
|
33
|
-
type:
|
|
36
|
+
type: PropType<any>;
|
|
34
37
|
default: () => any;
|
|
35
38
|
validator(value: string): any;
|
|
36
39
|
};
|
|
@@ -38,25 +41,33 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
38
41
|
type: StringConstructor;
|
|
39
42
|
default: null;
|
|
40
43
|
};
|
|
41
|
-
|
|
44
|
+
class: {
|
|
42
45
|
type: PropType<any>;
|
|
43
|
-
default:
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
ui: {
|
|
49
|
+
type: PropType<Partial<any>>;
|
|
50
|
+
default: undefined;
|
|
44
51
|
};
|
|
45
52
|
}, {
|
|
46
|
-
attrs: import("lodash").Omit<{
|
|
47
|
-
[x: string]: unknown;
|
|
48
|
-
}, "class">;
|
|
49
53
|
ui: import("vue").ComputedRef<any>;
|
|
54
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
55
|
+
[x: string]: unknown;
|
|
56
|
+
}, string>>;
|
|
50
57
|
pick: import("vue").WritableComputedRef<string | number | boolean | Record<string, any>>;
|
|
51
|
-
|
|
58
|
+
name: import("vue").ComputedRef<string | undefined>;
|
|
52
59
|
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<{
|
|
60
|
+
}, 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<{
|
|
61
|
+
id: {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
default: () => string;
|
|
64
|
+
};
|
|
54
65
|
value: {
|
|
55
|
-
type: (BooleanConstructor |
|
|
66
|
+
type: (BooleanConstructor | NumberConstructor | StringConstructor)[];
|
|
56
67
|
default: null;
|
|
57
68
|
};
|
|
58
69
|
modelValue: {
|
|
59
|
-
type: (ObjectConstructor | BooleanConstructor |
|
|
70
|
+
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[];
|
|
60
71
|
default: null;
|
|
61
72
|
};
|
|
62
73
|
name: {
|
|
@@ -80,7 +91,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
80
91
|
default: boolean;
|
|
81
92
|
};
|
|
82
93
|
color: {
|
|
83
|
-
type:
|
|
94
|
+
type: PropType<any>;
|
|
84
95
|
default: () => any;
|
|
85
96
|
validator(value: string): any;
|
|
86
97
|
};
|
|
@@ -88,16 +99,23 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
88
99
|
type: StringConstructor;
|
|
89
100
|
default: null;
|
|
90
101
|
};
|
|
91
|
-
|
|
102
|
+
class: {
|
|
92
103
|
type: PropType<any>;
|
|
93
|
-
default:
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
ui: {
|
|
107
|
+
type: PropType<Partial<any>>;
|
|
108
|
+
default: undefined;
|
|
94
109
|
};
|
|
95
110
|
}>> & {
|
|
96
111
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
112
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
97
113
|
}, {
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
id: string;
|
|
115
|
+
color: any;
|
|
116
|
+
ui: Partial<any>;
|
|
100
117
|
name: string;
|
|
118
|
+
class: any;
|
|
101
119
|
value: string | number | boolean;
|
|
102
120
|
label: string;
|
|
103
121
|
modelValue: string | number | boolean | Record<string, any>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="ui.wrapper">
|
|
3
|
+
<fieldset v-bind="attrs">
|
|
4
|
+
<legend v-if="legend || $slots.legend" :class="ui.legend">
|
|
5
|
+
<slot name="legend">
|
|
6
|
+
{{ legend }}
|
|
7
|
+
</slot>
|
|
8
|
+
</legend>
|
|
9
|
+
<URadio
|
|
10
|
+
v-for="option in normalizedOptions"
|
|
11
|
+
:key="option.value"
|
|
12
|
+
:label="option.label"
|
|
13
|
+
:model-value="modelValue"
|
|
14
|
+
:value="option.value"
|
|
15
|
+
:disabled="disabled"
|
|
16
|
+
:ui="uiRadio"
|
|
17
|
+
@change="onUpdate(option.value)"
|
|
18
|
+
>
|
|
19
|
+
<template #label>
|
|
20
|
+
<slot name="label" v-bind="{ option }" />
|
|
21
|
+
</template>
|
|
22
|
+
</URadio>
|
|
23
|
+
</fieldset>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
import URadio from "./Radio.vue";
|
|
29
|
+
import { computed, defineComponent, provide, toRef } from "vue";
|
|
30
|
+
import { useUI } from "../../composables/useUI";
|
|
31
|
+
import { useFormGroup } from "../../composables/useFormGroup";
|
|
32
|
+
import { mergeConfig, get } from "../../utils";
|
|
33
|
+
import appConfig from "#build/app.config";
|
|
34
|
+
import { radioGroup, radio } from "#ui/ui.config";
|
|
35
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.radioGroup, radioGroup);
|
|
36
|
+
const configRadio = mergeConfig(appConfig.ui.strategy, appConfig.ui.radio, radio);
|
|
37
|
+
export default defineComponent({
|
|
38
|
+
components: {
|
|
39
|
+
URadio
|
|
40
|
+
},
|
|
41
|
+
inheritAttrs: false,
|
|
42
|
+
props: {
|
|
43
|
+
modelValue: {
|
|
44
|
+
type: [String, Number, Object],
|
|
45
|
+
default: ""
|
|
46
|
+
},
|
|
47
|
+
name: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: null
|
|
50
|
+
},
|
|
51
|
+
legend: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: null
|
|
54
|
+
},
|
|
55
|
+
options: {
|
|
56
|
+
type: Array,
|
|
57
|
+
default: () => []
|
|
58
|
+
},
|
|
59
|
+
optionAttribute: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: "label"
|
|
62
|
+
},
|
|
63
|
+
valueAttribute: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: "value"
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
color: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: () => config.default.color,
|
|
74
|
+
validator(value) {
|
|
75
|
+
return appConfig.ui.colors.includes(value);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
class: {
|
|
79
|
+
type: [String, Object, Array],
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
ui: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: void 0
|
|
85
|
+
},
|
|
86
|
+
uiRadio: {
|
|
87
|
+
type: Object,
|
|
88
|
+
default: void 0
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
emits: ["update:modelValue", "change"],
|
|
92
|
+
setup(props, { emit }) {
|
|
93
|
+
const { ui, attrs } = useUI("radioGroup", toRef(props, "ui"), config, toRef(props, "class"));
|
|
94
|
+
const { ui: uiRadio } = useUI("radio", toRef(props, "uiRadio"), configRadio);
|
|
95
|
+
const { emitFormChange, color, name } = useFormGroup(props, config);
|
|
96
|
+
provide("radio-group", { color, name });
|
|
97
|
+
const onUpdate = (value) => {
|
|
98
|
+
emit("update:modelValue", value);
|
|
99
|
+
emit("change", value);
|
|
100
|
+
emitFormChange();
|
|
101
|
+
};
|
|
102
|
+
const guessOptionValue = (option) => {
|
|
103
|
+
return get(option, props.valueAttribute, get(option, props.optionAttribute));
|
|
104
|
+
};
|
|
105
|
+
const guessOptionText = (option) => {
|
|
106
|
+
return get(option, props.optionAttribute, get(option, props.valueAttribute));
|
|
107
|
+
};
|
|
108
|
+
const normalizeOption = (option) => {
|
|
109
|
+
if (["string", "number", "boolean"].includes(typeof option)) {
|
|
110
|
+
return {
|
|
111
|
+
value: option,
|
|
112
|
+
label: option
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
...option,
|
|
117
|
+
value: guessOptionValue(option),
|
|
118
|
+
label: guessOptionText(option)
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const normalizedOptions = computed(() => {
|
|
122
|
+
return props.options.map((option) => normalizeOption(option));
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
126
|
+
ui,
|
|
127
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
128
|
+
uiRadio,
|
|
129
|
+
attrs,
|
|
130
|
+
normalizedOptions,
|
|
131
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
132
|
+
onUpdate
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
</script>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
modelValue: {
|
|
4
|
+
type: (ObjectConstructor | NumberConstructor | StringConstructor)[];
|
|
5
|
+
default: string;
|
|
6
|
+
};
|
|
7
|
+
name: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: null;
|
|
10
|
+
};
|
|
11
|
+
legend: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
default: null;
|
|
14
|
+
};
|
|
15
|
+
options: {
|
|
16
|
+
type: ArrayConstructor;
|
|
17
|
+
default: () => never[];
|
|
18
|
+
};
|
|
19
|
+
optionAttribute: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
valueAttribute: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
disabled: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: boolean;
|
|
30
|
+
};
|
|
31
|
+
color: {
|
|
32
|
+
type: PropType<any>;
|
|
33
|
+
default: () => any;
|
|
34
|
+
validator(value: string): any;
|
|
35
|
+
};
|
|
36
|
+
class: {
|
|
37
|
+
type: PropType<any>;
|
|
38
|
+
default: undefined;
|
|
39
|
+
};
|
|
40
|
+
ui: {
|
|
41
|
+
type: PropType<Partial<any>>;
|
|
42
|
+
default: undefined;
|
|
43
|
+
};
|
|
44
|
+
uiRadio: {
|
|
45
|
+
type: PropType<Partial<any>>;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
ui: import("vue").ComputedRef<any>;
|
|
50
|
+
uiRadio: import("vue").ComputedRef<any>;
|
|
51
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
}, string>>;
|
|
54
|
+
normalizedOptions: import("vue").ComputedRef<any[]>;
|
|
55
|
+
onUpdate: (value: any) => void;
|
|
56
|
+
}, 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<{
|
|
57
|
+
modelValue: {
|
|
58
|
+
type: (ObjectConstructor | NumberConstructor | StringConstructor)[];
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
name: {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
default: null;
|
|
64
|
+
};
|
|
65
|
+
legend: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: null;
|
|
68
|
+
};
|
|
69
|
+
options: {
|
|
70
|
+
type: ArrayConstructor;
|
|
71
|
+
default: () => never[];
|
|
72
|
+
};
|
|
73
|
+
optionAttribute: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
valueAttribute: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
default: string;
|
|
80
|
+
};
|
|
81
|
+
disabled: {
|
|
82
|
+
type: BooleanConstructor;
|
|
83
|
+
default: boolean;
|
|
84
|
+
};
|
|
85
|
+
color: {
|
|
86
|
+
type: PropType<any>;
|
|
87
|
+
default: () => any;
|
|
88
|
+
validator(value: string): any;
|
|
89
|
+
};
|
|
90
|
+
class: {
|
|
91
|
+
type: PropType<any>;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
ui: {
|
|
95
|
+
type: PropType<Partial<any>>;
|
|
96
|
+
default: undefined;
|
|
97
|
+
};
|
|
98
|
+
uiRadio: {
|
|
99
|
+
type: PropType<Partial<any>>;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
}>> & {
|
|
103
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
104
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
color: any;
|
|
107
|
+
ui: Partial<any>;
|
|
108
|
+
options: unknown[];
|
|
109
|
+
name: string;
|
|
110
|
+
class: any;
|
|
111
|
+
legend: string;
|
|
112
|
+
modelValue: string | number | Record<string, any>;
|
|
113
|
+
disabled: boolean;
|
|
114
|
+
optionAttribute: string;
|
|
115
|
+
valueAttribute: string;
|
|
116
|
+
uiRadio: Partial<any>;
|
|
117
|
+
}, {}>;
|
|
118
|
+
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="wrapperClass">
|
|
3
3
|
<input
|
|
4
|
+
:id="inputId"
|
|
4
5
|
ref="input"
|
|
5
6
|
v-model.number="value"
|
|
6
7
|
:name="name"
|
|
@@ -19,13 +20,14 @@
|
|
|
19
20
|
</template>
|
|
20
21
|
|
|
21
22
|
<script>
|
|
22
|
-
import { computed, defineComponent } from "vue";
|
|
23
|
-
import { omit } from "lodash-es";
|
|
23
|
+
import { computed, toRef, defineComponent } from "vue";
|
|
24
24
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
25
|
-
import {
|
|
25
|
+
import { useUI } from "../../composables/useUI";
|
|
26
26
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
27
|
-
import {
|
|
27
|
+
import { mergeConfig } from "../../utils";
|
|
28
28
|
import appConfig from "#build/app.config";
|
|
29
|
+
import { range } from "#ui/ui.config";
|
|
30
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.range, range);
|
|
29
31
|
export default defineComponent({
|
|
30
32
|
inheritAttrs: false,
|
|
31
33
|
props: {
|
|
@@ -33,6 +35,10 @@ export default defineComponent({
|
|
|
33
35
|
type: Number,
|
|
34
36
|
default: 0
|
|
35
37
|
},
|
|
38
|
+
id: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: null
|
|
41
|
+
},
|
|
36
42
|
name: {
|
|
37
43
|
type: String,
|
|
38
44
|
default: null
|
|
@@ -55,14 +61,14 @@ export default defineComponent({
|
|
|
55
61
|
},
|
|
56
62
|
size: {
|
|
57
63
|
type: String,
|
|
58
|
-
default:
|
|
64
|
+
default: null,
|
|
59
65
|
validator(value) {
|
|
60
|
-
return Object.keys(
|
|
66
|
+
return Object.keys(config.size).includes(value);
|
|
61
67
|
}
|
|
62
68
|
},
|
|
63
69
|
color: {
|
|
64
70
|
type: String,
|
|
65
|
-
default: () =>
|
|
71
|
+
default: () => config.default.color,
|
|
66
72
|
validator(value) {
|
|
67
73
|
return appConfig.ui.colors.includes(value);
|
|
68
74
|
}
|
|
@@ -71,18 +77,19 @@ export default defineComponent({
|
|
|
71
77
|
type: String,
|
|
72
78
|
default: null
|
|
73
79
|
},
|
|
80
|
+
class: {
|
|
81
|
+
type: [String, Object, Array],
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
74
84
|
ui: {
|
|
75
85
|
type: Object,
|
|
76
|
-
default:
|
|
86
|
+
default: void 0
|
|
77
87
|
}
|
|
78
88
|
},
|
|
79
89
|
emits: ["update:modelValue", "change"],
|
|
80
|
-
setup(props, { emit
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const { emitFormChange, formGroup } = useFormGroup();
|
|
84
|
-
const color = computed(() => formGroup?.error?.value ? "red" : props.color);
|
|
85
|
-
const size = computed(() => formGroup?.size?.value ?? props.size);
|
|
90
|
+
setup(props, { emit }) {
|
|
91
|
+
const { ui, attrs } = useUI("range", toRef(props, "ui"), config);
|
|
92
|
+
const { emitFormChange, inputId, color, size, name } = useFormGroup(props, config);
|
|
86
93
|
const value = computed({
|
|
87
94
|
get() {
|
|
88
95
|
return props.modelValue;
|
|
@@ -99,7 +106,7 @@ export default defineComponent({
|
|
|
99
106
|
return twMerge(twJoin(
|
|
100
107
|
ui.value.wrapper,
|
|
101
108
|
ui.value.size[size.value]
|
|
102
|
-
),
|
|
109
|
+
), props.class);
|
|
103
110
|
});
|
|
104
111
|
const inputClass = computed(() => {
|
|
105
112
|
return twMerge(twJoin(
|
|
@@ -145,9 +152,12 @@ export default defineComponent({
|
|
|
145
152
|
};
|
|
146
153
|
});
|
|
147
154
|
return {
|
|
148
|
-
attrs: omit(attrs, ["class"]),
|
|
149
155
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
150
156
|
ui,
|
|
157
|
+
attrs,
|
|
158
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
159
|
+
name,
|
|
160
|
+
inputId,
|
|
151
161
|
value,
|
|
152
162
|
wrapperClass,
|
|
153
163
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
@@ -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
4
|
type: NumberConstructor;
|
|
6
5
|
default: number;
|
|
7
6
|
};
|
|
7
|
+
id: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: null;
|
|
10
|
+
};
|
|
8
11
|
name: {
|
|
9
12
|
type: StringConstructor;
|
|
10
13
|
default: null;
|
|
@@ -26,12 +29,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
26
29
|
default: number;
|
|
27
30
|
};
|
|
28
31
|
size: {
|
|
29
|
-
type:
|
|
30
|
-
default:
|
|
32
|
+
type: PropType<string | number | symbol>;
|
|
33
|
+
default: null;
|
|
31
34
|
validator(value: string): boolean;
|
|
32
35
|
};
|
|
33
36
|
color: {
|
|
34
|
-
type:
|
|
37
|
+
type: PropType<any>;
|
|
35
38
|
default: () => any;
|
|
36
39
|
validator(value: string): any;
|
|
37
40
|
};
|
|
@@ -39,15 +42,21 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
39
42
|
type: StringConstructor;
|
|
40
43
|
default: null;
|
|
41
44
|
};
|
|
42
|
-
|
|
45
|
+
class: {
|
|
43
46
|
type: PropType<any>;
|
|
44
|
-
default:
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
ui: {
|
|
50
|
+
type: PropType<Partial<any>>;
|
|
51
|
+
default: undefined;
|
|
45
52
|
};
|
|
46
53
|
}, {
|
|
47
|
-
attrs: import("lodash").Omit<{
|
|
48
|
-
[x: string]: unknown;
|
|
49
|
-
}, "class">;
|
|
50
54
|
ui: import("vue").ComputedRef<any>;
|
|
55
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
56
|
+
[x: string]: unknown;
|
|
57
|
+
}, string>>;
|
|
58
|
+
name: import("vue").ComputedRef<string | undefined>;
|
|
59
|
+
inputId: import("vue").Ref<string | undefined>;
|
|
51
60
|
value: import("vue").WritableComputedRef<number>;
|
|
52
61
|
wrapperClass: import("vue").ComputedRef<string>;
|
|
53
62
|
inputClass: import("vue").ComputedRef<string>;
|
|
@@ -63,6 +72,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
63
72
|
type: NumberConstructor;
|
|
64
73
|
default: number;
|
|
65
74
|
};
|
|
75
|
+
id: {
|
|
76
|
+
type: StringConstructor;
|
|
77
|
+
default: null;
|
|
78
|
+
};
|
|
66
79
|
name: {
|
|
67
80
|
type: StringConstructor;
|
|
68
81
|
default: null;
|
|
@@ -84,12 +97,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
84
97
|
default: number;
|
|
85
98
|
};
|
|
86
99
|
size: {
|
|
87
|
-
type:
|
|
88
|
-
default:
|
|
100
|
+
type: PropType<string | number | symbol>;
|
|
101
|
+
default: null;
|
|
89
102
|
validator(value: string): boolean;
|
|
90
103
|
};
|
|
91
104
|
color: {
|
|
92
|
-
type:
|
|
105
|
+
type: PropType<any>;
|
|
93
106
|
default: () => any;
|
|
94
107
|
validator(value: string): any;
|
|
95
108
|
};
|
|
@@ -97,23 +110,29 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
110
|
type: StringConstructor;
|
|
98
111
|
default: null;
|
|
99
112
|
};
|
|
100
|
-
|
|
113
|
+
class: {
|
|
101
114
|
type: PropType<any>;
|
|
102
|
-
default:
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
117
|
+
ui: {
|
|
118
|
+
type: PropType<Partial<any>>;
|
|
119
|
+
default: undefined;
|
|
103
120
|
};
|
|
104
121
|
}>> & {
|
|
105
122
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
106
123
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
107
124
|
}, {
|
|
108
|
-
|
|
109
|
-
|
|
125
|
+
id: string;
|
|
126
|
+
color: any;
|
|
127
|
+
ui: Partial<any>;
|
|
110
128
|
name: string;
|
|
129
|
+
class: any;
|
|
111
130
|
modelValue: number;
|
|
112
131
|
disabled: boolean;
|
|
113
|
-
size: string;
|
|
132
|
+
size: string | number | symbol;
|
|
114
133
|
max: number;
|
|
115
|
-
inputClass: string;
|
|
116
134
|
min: number;
|
|
135
|
+
inputClass: string;
|
|
117
136
|
step: number;
|
|
118
137
|
}, {}>;
|
|
119
138
|
export default _default;
|