@nuxt/ui 2.9.0 → 2.11.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 +11 -0
- package/dist/module.d.mts +449 -72
- package/dist/module.d.ts +449 -72
- package/dist/module.json +1 -1
- package/dist/module.mjs +32 -6
- package/dist/runtime/components/data/Table.vue +8 -6
- package/dist/runtime/components/data/Table.vue.d.ts +2 -1
- package/dist/runtime/components/elements/Accordion.vue +15 -13
- package/dist/runtime/components/elements/Accordion.vue.d.ts +5 -2
- package/dist/runtime/components/elements/Alert.vue +7 -6
- package/dist/runtime/components/elements/Alert.vue.d.ts +6 -5
- package/dist/runtime/components/elements/Avatar.vue.d.ts +5 -4
- package/dist/runtime/components/elements/AvatarGroup.d.ts +4 -3
- package/dist/runtime/components/elements/Badge.vue +4 -2
- package/dist/runtime/components/elements/Badge.vue.d.ts +5 -5
- package/dist/runtime/components/elements/Button.vue +8 -6
- package/dist/runtime/components/elements/Button.vue.d.ts +7 -7
- package/dist/runtime/components/elements/ButtonGroup.d.ts +5 -4
- package/dist/runtime/components/elements/ButtonGroup.mjs +19 -32
- package/dist/runtime/components/elements/Chip.vue +85 -0
- package/dist/runtime/components/elements/Chip.vue.d.ts +90 -0
- package/dist/runtime/components/elements/Dropdown.vue +45 -25
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +8 -0
- package/dist/runtime/components/elements/Icon.vue +16 -2
- package/dist/runtime/components/elements/Icon.vue.d.ts +14 -2
- package/dist/runtime/components/elements/Kbd.vue.d.ts +5 -4
- package/dist/runtime/components/elements/Link.vue +2 -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 +2 -4
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +6 -6
- package/dist/runtime/components/forms/Form.vue +32 -7
- package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
- package/dist/runtime/components/forms/FormGroup.vue +7 -3
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +15 -5
- package/dist/runtime/components/forms/Input.vue +41 -6
- package/dist/runtime/components/forms/Input.vue.d.ts +42 -10
- package/dist/runtime/components/forms/Radio.vue +16 -9
- package/dist/runtime/components/forms/Radio.vue.d.ts +8 -7
- 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.d.ts +8 -7
- package/dist/runtime/components/forms/Select.vue +5 -2
- package/dist/runtime/components/forms/Select.vue.d.ts +10 -9
- package/dist/runtime/components/forms/SelectMenu.vue +80 -58
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +23 -13
- package/dist/runtime/components/forms/Textarea.vue +38 -4
- package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -9
- package/dist/runtime/components/forms/Toggle.vue +19 -1
- package/dist/runtime/components/forms/Toggle.vue.d.ts +16 -3
- package/dist/runtime/components/layout/Divider.vue +107 -0
- package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
- package/dist/runtime/components/navigation/Breadcrumb.vue +78 -0
- package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +50 -0
- package/dist/runtime/components/navigation/CommandPalette.vue +18 -7
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +2 -2
- package/dist/runtime/components/navigation/Pagination.vue +65 -9
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +45 -7
- package/dist/runtime/components/navigation/Tabs.vue +1 -1
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/ContextMenu.vue +7 -2
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +2 -1
- package/dist/runtime/components/overlays/Modal.vue +1 -1
- package/dist/runtime/components/overlays/Modal.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/Notification.vue +32 -27
- package/dist/runtime/components/overlays/Notification.vue.d.ts +4 -3
- package/dist/runtime/components/overlays/Notifications.vue +16 -14
- package/dist/runtime/components/overlays/Popover.vue +31 -7
- package/dist/runtime/components/overlays/Popover.vue.d.ts +27 -2
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +1 -1
- package/dist/runtime/components/overlays/Tooltip.vue +16 -10
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +1 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -1
- package/dist/runtime/composables/defineShortcuts.mjs +8 -4
- package/dist/runtime/composables/useButtonGroup.d.ts +20 -0
- package/dist/runtime/composables/useButtonGroup.mjs +52 -0
- package/dist/runtime/composables/useFormGroup.d.ts +6 -4
- package/dist/runtime/composables/useFormGroup.mjs +19 -7
- package/dist/runtime/composables/usePopper.d.ts +3 -3
- package/dist/runtime/composables/usePopper.mjs +7 -1
- package/dist/runtime/composables/useShortcuts.d.ts +2 -2
- package/dist/runtime/composables/useUI.d.ts +2 -2
- package/dist/runtime/composables/useUI.mjs +2 -2
- package/dist/runtime/types/alert.d.ts +7 -0
- package/dist/runtime/types/avatar.d.ts +3 -1
- package/dist/runtime/types/badge.d.ts +5 -4
- package/dist/runtime/types/breadcrumb.d.ts +7 -0
- package/dist/runtime/types/button.d.ts +5 -4
- package/dist/runtime/types/chip.d.ts +11 -0
- package/dist/runtime/types/command-palette.d.ts +1 -0
- package/dist/runtime/types/dropdown.d.ts +2 -2
- package/dist/runtime/types/form-group.d.ts +5 -0
- package/dist/runtime/types/form.d.ts +14 -6
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/input.d.ts +8 -0
- package/dist/runtime/types/kbd.d.ts +5 -0
- package/dist/runtime/types/meter.d.ts +5 -0
- package/dist/runtime/types/popper.d.ts +1 -0
- package/dist/runtime/types/progress.d.ts +4 -0
- package/dist/runtime/types/range.d.ts +5 -0
- package/dist/runtime/types/select.d.ts +8 -0
- package/dist/runtime/types/textarea.d.ts +8 -0
- package/dist/runtime/types/toggle.d.ts +5 -0
- package/dist/runtime/types/utils.d.ts +22 -5
- package/dist/runtime/ui.config/_popperArrow.d.ts +9 -0
- package/dist/runtime/ui.config/_popperArrow.mjs +8 -0
- package/dist/runtime/ui.config/data/table.d.ts +60 -0
- package/dist/runtime/ui.config/data/table.mjs +59 -0
- package/dist/runtime/ui.config/elements/accordion.d.ts +21 -0
- package/dist/runtime/ui.config/elements/accordion.mjs +20 -0
- package/dist/runtime/ui.config/elements/alert.d.ts +40 -0
- package/dist/runtime/ui.config/elements/alert.mjs +39 -0
- package/dist/runtime/ui.config/elements/avatar.d.ts +60 -0
- package/dist/runtime/ui.config/elements/avatar.mjs +59 -0
- package/dist/runtime/ui.config/elements/avatarGroup.d.ts +6 -0
- package/dist/runtime/ui.config/elements/avatarGroup.mjs +5 -0
- package/dist/runtime/ui.config/elements/badge.d.ts +34 -0
- package/dist/runtime/ui.config/elements/badge.mjs +33 -0
- package/dist/runtime/ui.config/elements/button.d.ts +77 -0
- package/dist/runtime/ui.config/elements/button.mjs +76 -0
- package/dist/runtime/ui.config/elements/buttonGroup.d.ts +9 -0
- package/dist/runtime/ui.config/elements/buttonGroup.mjs +8 -0
- package/dist/runtime/ui.config/elements/chip.d.ts +35 -0
- package/dist/runtime/ui.config/elements/chip.mjs +34 -0
- package/dist/runtime/ui.config/elements/dropdown.d.ts +53 -0
- package/dist/runtime/ui.config/elements/dropdown.mjs +51 -0
- package/dist/runtime/ui.config/elements/kbd.d.ts +17 -0
- package/dist/runtime/ui.config/elements/kbd.mjs +16 -0
- package/dist/runtime/ui.config/elements/meter.d.ts +77 -0
- package/dist/runtime/ui.config/elements/meter.mjs +76 -0
- package/dist/runtime/ui.config/elements/meterGroup.d.ts +12 -0
- package/dist/runtime/ui.config/elements/meterGroup.mjs +11 -0
- package/dist/runtime/ui.config/elements/progress.d.ts +75 -0
- package/dist/runtime/ui.config/elements/progress.mjs +74 -0
- package/dist/runtime/ui.config/forms/checkbox.d.ts +16 -0
- package/dist/runtime/ui.config/forms/checkbox.mjs +15 -0
- package/dist/runtime/ui.config/forms/formGroup.d.ts +25 -0
- package/dist/runtime/ui.config/forms/formGroup.mjs +25 -0
- package/dist/runtime/ui.config/forms/input.d.ts +105 -0
- package/dist/runtime/ui.config/forms/input.mjs +104 -0
- package/dist/runtime/ui.config/forms/radio.d.ts +15 -0
- package/dist/runtime/ui.config/forms/radio.mjs +14 -0
- package/dist/runtime/ui.config/forms/radioGroup.d.ts +8 -0
- package/dist/runtime/ui.config/forms/radioGroup.mjs +7 -0
- package/dist/runtime/ui.config/forms/range.d.ts +64 -0
- package/dist/runtime/ui.config/forms/range.mjs +63 -0
- package/dist/runtime/ui.config/forms/select.d.ts +106 -0
- package/dist/runtime/ui.config/forms/select.mjs +12 -0
- package/dist/runtime/ui.config/forms/selectMenu.d.ts +63 -0
- package/dist/runtime/ui.config/forms/selectMenu.mjs +61 -0
- package/dist/runtime/ui.config/forms/textarea.d.ts +104 -0
- package/dist/runtime/ui.config/forms/textarea.mjs +9 -0
- package/dist/runtime/ui.config/forms/toggle.d.ts +61 -0
- package/dist/runtime/ui.config/forms/toggle.mjs +60 -0
- package/dist/runtime/ui.config/index.d.ts +40 -0
- package/dist/runtime/ui.config/index.mjs +40 -0
- package/dist/runtime/ui.config/layout/card.d.ts +24 -0
- package/dist/runtime/ui.config/layout/card.mjs +23 -0
- package/dist/runtime/ui.config/layout/container.d.ts +6 -0
- package/dist/runtime/ui.config/layout/container.mjs +5 -0
- package/dist/runtime/ui.config/layout/divider.d.ts +30 -0
- package/dist/runtime/ui.config/layout/divider.mjs +29 -0
- package/dist/runtime/ui.config/layout/skeleton.d.ts +6 -0
- package/dist/runtime/ui.config/layout/skeleton.mjs +5 -0
- package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +20 -0
- package/dist/runtime/ui.config/navigation/breadcrumb.mjs +19 -0
- package/dist/runtime/ui.config/navigation/commandPalette.d.ts +68 -0
- package/dist/runtime/ui.config/navigation/commandPalette.mjs +67 -0
- package/dist/runtime/ui.config/navigation/pagination.d.ts +35 -0
- package/dist/runtime/ui.config/navigation/pagination.mjs +34 -0
- package/dist/runtime/ui.config/navigation/tabs.d.ts +34 -0
- package/dist/runtime/ui.config/navigation/tabs.mjs +33 -0
- package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +28 -0
- package/dist/runtime/ui.config/navigation/verticalNavigation.mjs +27 -0
- package/dist/runtime/ui.config/overlays/contextMenu.d.ts +31 -0
- package/dist/runtime/ui.config/overlays/contextMenu.mjs +25 -0
- package/dist/runtime/ui.config/overlays/modal.d.ts +35 -0
- package/dist/runtime/ui.config/overlays/modal.mjs +36 -0
- package/dist/runtime/ui.config/overlays/notification.d.ts +49 -0
- package/dist/runtime/ui.config/overlays/notification.mjs +49 -0
- package/dist/runtime/ui.config/overlays/notifications.d.ts +7 -0
- package/dist/runtime/ui.config/overlays/notifications.mjs +6 -0
- package/dist/runtime/ui.config/overlays/popover.d.ts +42 -0
- package/dist/runtime/ui.config/overlays/popover.mjs +36 -0
- package/dist/runtime/ui.config/overlays/slideover.d.ts +27 -0
- package/dist/runtime/ui.config/overlays/slideover.mjs +28 -0
- package/dist/runtime/ui.config/overlays/tooltip.d.ts +32 -0
- package/dist/runtime/ui.config/overlays/tooltip.mjs +26 -0
- package/dist/runtime/utils/index.d.ts +5 -0
- package/dist/runtime/utils/index.mjs +6 -2
- package/dist/types.d.mts +3 -2
- package/dist/types.d.ts +3 -2
- package/package.json +41 -28
- package/dist/runtime/ui.config.d.ts +0 -1207
- package/dist/runtime/ui.config.mjs +0 -1029
- package/dist/runtime/utils/StateEmitter.d.ts +0 -17
- package/dist/runtime/utils/StateEmitter.mjs +0 -21
|
@@ -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, isFieldset: true }, 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
|
+
ui: Partial<any>;
|
|
107
|
+
color: 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,4 +1,5 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
+
import type { RangeSize } from '../../types';
|
|
2
3
|
declare const _default: import("vue").DefineComponent<{
|
|
3
4
|
modelValue: {
|
|
4
5
|
type: NumberConstructor;
|
|
@@ -29,7 +30,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
29
30
|
default: number;
|
|
30
31
|
};
|
|
31
32
|
size: {
|
|
32
|
-
type: PropType<
|
|
33
|
+
type: PropType<RangeSize>;
|
|
33
34
|
default: null;
|
|
34
35
|
validator(value: string): boolean;
|
|
35
36
|
};
|
|
@@ -55,8 +56,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
55
56
|
attrs: import("vue").ComputedRef<Pick<{
|
|
56
57
|
[x: string]: unknown;
|
|
57
58
|
}, string>>;
|
|
58
|
-
name: import("vue").ComputedRef<
|
|
59
|
-
inputId: import("vue").
|
|
59
|
+
name: import("vue").ComputedRef<string | undefined>;
|
|
60
|
+
inputId: import("vue").Ref<string | null | undefined>;
|
|
60
61
|
value: import("vue").WritableComputedRef<number>;
|
|
61
62
|
wrapperClass: import("vue").ComputedRef<string>;
|
|
62
63
|
inputClass: import("vue").ComputedRef<string>;
|
|
@@ -97,7 +98,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
97
98
|
default: number;
|
|
98
99
|
};
|
|
99
100
|
size: {
|
|
100
|
-
type: PropType<
|
|
101
|
+
type: PropType<RangeSize>;
|
|
101
102
|
default: null;
|
|
102
103
|
validator(value: string): boolean;
|
|
103
104
|
};
|
|
@@ -122,17 +123,17 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
122
123
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
123
124
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
124
125
|
}, {
|
|
126
|
+
size: RangeSize;
|
|
127
|
+
ui: Partial<any>;
|
|
125
128
|
id: string;
|
|
126
129
|
color: any;
|
|
127
|
-
ui: Partial<any>;
|
|
128
130
|
name: string;
|
|
129
131
|
class: any;
|
|
130
132
|
modelValue: number;
|
|
131
133
|
disabled: boolean;
|
|
132
|
-
size: string | number | symbol;
|
|
133
134
|
max: number;
|
|
134
|
-
inputClass: string;
|
|
135
135
|
min: number;
|
|
136
|
+
inputClass: string;
|
|
136
137
|
step: number;
|
|
137
138
|
}, {}>;
|
|
138
139
|
export default _default;
|
|
@@ -60,6 +60,7 @@ import UIcon from "../elements/Icon.vue";
|
|
|
60
60
|
import { useUI } from "../../composables/useUI";
|
|
61
61
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
62
62
|
import { mergeConfig, get } from "../../utils";
|
|
63
|
+
import { useInjectButtonGroup } from "../../composables/useButtonGroup";
|
|
63
64
|
import appConfig from "#build/app.config";
|
|
64
65
|
import { select } from "#ui/ui.config";
|
|
65
66
|
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
|
|
@@ -177,7 +178,9 @@ export default defineComponent({
|
|
|
177
178
|
emits: ["update:modelValue", "change"],
|
|
178
179
|
setup(props, { emit, slots }) {
|
|
179
180
|
const { ui, attrs } = useUI("select", toRef(props, "ui"), config, toRef(props, "class"));
|
|
180
|
-
const {
|
|
181
|
+
const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
|
|
182
|
+
const { emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
|
|
183
|
+
const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
|
|
181
184
|
const onInput = (event) => {
|
|
182
185
|
emit("update:modelValue", event.target.value);
|
|
183
186
|
};
|
|
@@ -232,7 +235,7 @@ export default defineComponent({
|
|
|
232
235
|
const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
|
|
233
236
|
return twMerge(twJoin(
|
|
234
237
|
ui.value.base,
|
|
235
|
-
|
|
238
|
+
rounded.value,
|
|
236
239
|
ui.value.size[size.value],
|
|
237
240
|
props.padded ? ui.value.padding[size.value] : "p-0",
|
|
238
241
|
variant?.replaceAll("{color}", color.value),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PropType, ComputedRef } from 'vue';
|
|
2
|
+
import type { SelectSize, SelectVariant } from '../../types';
|
|
2
3
|
declare const _default: import("vue").DefineComponent<{
|
|
3
4
|
modelValue: {
|
|
4
5
|
type: (ObjectConstructor | NumberConstructor | StringConstructor)[];
|
|
@@ -61,7 +62,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
61
62
|
default: () => never[];
|
|
62
63
|
};
|
|
63
64
|
size: {
|
|
64
|
-
type: PropType<
|
|
65
|
+
type: PropType<SelectSize>;
|
|
65
66
|
default: null;
|
|
66
67
|
validator(value: string): boolean;
|
|
67
68
|
};
|
|
@@ -71,7 +72,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
71
72
|
validator(value: string): boolean;
|
|
72
73
|
};
|
|
73
74
|
variant: {
|
|
74
|
-
type: PropType<
|
|
75
|
+
type: PropType<SelectVariant>;
|
|
75
76
|
default: () => any;
|
|
76
77
|
validator(value: string): boolean;
|
|
77
78
|
};
|
|
@@ -100,8 +101,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
100
101
|
attrs: ComputedRef<Pick<{
|
|
101
102
|
[x: string]: unknown;
|
|
102
103
|
}, string>>;
|
|
103
|
-
name: ComputedRef<
|
|
104
|
-
inputId:
|
|
104
|
+
name: ComputedRef<string | undefined>;
|
|
105
|
+
inputId: import("vue").Ref<string | null | undefined>;
|
|
105
106
|
normalizedOptionsWithPlaceholder: ComputedRef<{
|
|
106
107
|
disabled?: boolean | undefined;
|
|
107
108
|
children: {
|
|
@@ -182,7 +183,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
182
183
|
default: () => never[];
|
|
183
184
|
};
|
|
184
185
|
size: {
|
|
185
|
-
type: PropType<
|
|
186
|
+
type: PropType<SelectSize>;
|
|
186
187
|
default: null;
|
|
187
188
|
validator(value: string): boolean;
|
|
188
189
|
};
|
|
@@ -192,7 +193,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
192
193
|
validator(value: string): boolean;
|
|
193
194
|
};
|
|
194
195
|
variant: {
|
|
195
|
-
type: PropType<
|
|
196
|
+
type: PropType<SelectVariant>;
|
|
196
197
|
default: () => any;
|
|
197
198
|
validator(value: string): boolean;
|
|
198
199
|
};
|
|
@@ -220,19 +221,19 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
220
221
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
221
222
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
222
223
|
}, {
|
|
224
|
+
size: SelectSize;
|
|
225
|
+
ui: Partial<any>;
|
|
223
226
|
id: string;
|
|
224
227
|
icon: string;
|
|
225
228
|
color: any;
|
|
226
|
-
ui: Partial<any>;
|
|
227
229
|
options: unknown[];
|
|
228
230
|
name: string;
|
|
229
231
|
class: any;
|
|
230
232
|
modelValue: string | number | Record<string, any>;
|
|
231
233
|
loading: boolean;
|
|
232
234
|
disabled: boolean;
|
|
233
|
-
variant:
|
|
235
|
+
variant: SelectVariant;
|
|
234
236
|
required: boolean;
|
|
235
|
-
size: string | number | symbol;
|
|
236
237
|
placeholder: string;
|
|
237
238
|
padded: boolean;
|
|
238
239
|
loadingIcon: string;
|
|
@@ -52,64 +52,67 @@
|
|
|
52
52
|
|
|
53
53
|
<div v-if="open" ref="container" :class="[uiMenu.container, uiMenu.width]">
|
|
54
54
|
<Transition appear v-bind="uiMenu.transition">
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
v-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
55
|
+
<div>
|
|
56
|
+
<div v-if="popper.arrow" data-popper-arrow :class="['invisible before:visible before:block before:rotate-45 before:z-[-1]', Object.values(uiMenu.arrow)]" />
|
|
57
|
+
<component :is="searchable ? 'HComboboxOptions' : 'HListboxOptions'" static :class="[uiMenu.base, uiMenu.divide, uiMenu.ring, uiMenu.rounded, uiMenu.shadow, uiMenu.background, uiMenu.padding, uiMenu.height]">
|
|
58
|
+
<HComboboxInput
|
|
59
|
+
v-if="searchable"
|
|
60
|
+
ref="searchInput"
|
|
61
|
+
:display-value="() => query"
|
|
62
|
+
name="q"
|
|
63
|
+
:placeholder="searchablePlaceholder"
|
|
64
|
+
autofocus
|
|
65
|
+
autocomplete="off"
|
|
66
|
+
:class="uiMenu.input"
|
|
67
|
+
@change="query = $event.target.value"
|
|
68
|
+
/>
|
|
69
|
+
<component
|
|
70
|
+
:is="searchable ? 'HComboboxOption' : 'HListboxOption'"
|
|
71
|
+
v-for="(option, index) in filteredOptions"
|
|
72
|
+
v-slot="{ active, selected, disabled: optionDisabled }"
|
|
73
|
+
:key="index"
|
|
74
|
+
as="template"
|
|
75
|
+
:value="valueAttribute ? option[valueAttribute] : option"
|
|
76
|
+
:disabled="option.disabled"
|
|
77
|
+
>
|
|
78
|
+
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive, selected && uiMenu.option.selected, optionDisabled && uiMenu.option.disabled]">
|
|
79
|
+
<div :class="uiMenu.option.container">
|
|
80
|
+
<slot name="option" :option="option" :active="active" :selected="selected">
|
|
81
|
+
<UIcon v-if="option.icon" :name="option.icon" :class="[uiMenu.option.icon.base, active ? uiMenu.option.icon.active : uiMenu.option.icon.inactive, option.iconClass]" aria-hidden="true" />
|
|
82
|
+
<UAvatar
|
|
83
|
+
v-else-if="option.avatar"
|
|
84
|
+
v-bind="{ size: uiMenu.option.avatar.size, ...option.avatar }"
|
|
85
|
+
:class="uiMenu.option.avatar.base"
|
|
86
|
+
aria-hidden="true"
|
|
87
|
+
/>
|
|
88
|
+
<span v-else-if="option.chip" :class="uiMenu.option.chip.base" :style="{ background: `#${option.chip}` }" />
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
<span class="truncate">{{ ['string', 'number'].includes(typeof option) ? option : option[optionAttribute] }}</span>
|
|
91
|
+
</slot>
|
|
92
|
+
</div>
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
<span v-if="selected" :class="[uiMenu.option.selectedIcon.wrapper, uiMenu.option.selectedIcon.padding]">
|
|
95
|
+
<UIcon :name="selectedIcon" :class="uiMenu.option.selectedIcon.base" aria-hidden="true" />
|
|
96
|
+
</span>
|
|
97
|
+
</li>
|
|
98
|
+
</component>
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
<component :is="searchable ? 'HComboboxOption' : 'HListboxOption'" v-if="creatable && queryOption && !filteredOptions.length" v-slot="{ active, selected }" :value="queryOption" as="template">
|
|
101
|
+
<li :class="[uiMenu.option.base, uiMenu.option.rounded, uiMenu.option.padding, uiMenu.option.size, uiMenu.option.color, active ? uiMenu.option.active : uiMenu.option.inactive]">
|
|
102
|
+
<div :class="uiMenu.option.container">
|
|
103
|
+
<slot name="option-create" :option="queryOption" :active="active" :selected="selected">
|
|
104
|
+
<span class="block truncate">Create "{{ queryOption[optionAttribute] }}"</span>
|
|
105
|
+
</slot>
|
|
106
|
+
</div>
|
|
107
|
+
</li>
|
|
108
|
+
</component>
|
|
109
|
+
<p v-else-if="searchable && query && !filteredOptions.length" :class="uiMenu.option.empty">
|
|
110
|
+
<slot name="option-empty" :query="query">
|
|
111
|
+
No results for "{{ query }}".
|
|
112
|
+
</slot>
|
|
113
|
+
</p>
|
|
106
114
|
</component>
|
|
107
|
-
|
|
108
|
-
<slot name="option-empty" :query="query">
|
|
109
|
-
No results for "{{ query }}".
|
|
110
|
-
</slot>
|
|
111
|
-
</p>
|
|
112
|
-
</component>
|
|
115
|
+
</div>
|
|
113
116
|
</Transition>
|
|
114
117
|
</div>
|
|
115
118
|
</component>
|
|
@@ -136,7 +139,8 @@ import UAvatar from "../elements/Avatar.vue";
|
|
|
136
139
|
import { useUI } from "../../composables/useUI";
|
|
137
140
|
import { usePopper } from "../../composables/usePopper";
|
|
138
141
|
import { useFormGroup } from "../../composables/useFormGroup";
|
|
139
|
-
import { mergeConfig } from "../../utils";
|
|
142
|
+
import { get, mergeConfig } from "../../utils";
|
|
143
|
+
import { useInjectButtonGroup } from "../../composables/useButtonGroup";
|
|
140
144
|
import appConfig from "#build/app.config";
|
|
141
145
|
import { select, selectMenu } from "#ui/ui.config";
|
|
142
146
|
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.select, select);
|
|
@@ -229,6 +233,10 @@ export default defineComponent({
|
|
|
229
233
|
type: String,
|
|
230
234
|
default: "Search..."
|
|
231
235
|
},
|
|
236
|
+
clearSearchOnClose: {
|
|
237
|
+
type: Boolean,
|
|
238
|
+
default: () => configMenu.default.clearOnClose
|
|
239
|
+
},
|
|
232
240
|
debounce: {
|
|
233
241
|
type: Number,
|
|
234
242
|
default: 200
|
|
@@ -308,14 +316,16 @@ export default defineComponent({
|
|
|
308
316
|
const { ui: uiMenu } = useUI("selectMenu", toRef(props, "uiMenu"), configMenu);
|
|
309
317
|
const popper = computed(() => defu({}, props.popper, uiMenu.value.popper));
|
|
310
318
|
const [trigger, container] = usePopper(popper.value);
|
|
311
|
-
const {
|
|
319
|
+
const { size: sizeButtonGroup, rounded } = useInjectButtonGroup({ ui, props });
|
|
320
|
+
const { emitFormBlur, emitFormChange, inputId, color, size: sizeFormGroup, name } = useFormGroup(props, config);
|
|
321
|
+
const size = computed(() => sizeButtonGroup.value || sizeFormGroup.value);
|
|
312
322
|
const query = ref("");
|
|
313
323
|
const searchInput = ref();
|
|
314
324
|
const selectClass = computed(() => {
|
|
315
325
|
const variant = ui.value.color?.[color.value]?.[props.variant] || ui.value.variant[props.variant];
|
|
316
326
|
return twMerge(twJoin(
|
|
317
327
|
ui.value.base,
|
|
318
|
-
|
|
328
|
+
rounded.value,
|
|
319
329
|
"text-left cursor-default",
|
|
320
330
|
ui.value.size[size.value],
|
|
321
331
|
ui.value.gap[size.value],
|
|
@@ -384,17 +394,27 @@ export default defineComponent({
|
|
|
384
394
|
}
|
|
385
395
|
return props.options.filter((option) => {
|
|
386
396
|
return (props.searchAttributes?.length ? props.searchAttributes : [props.optionAttribute]).some((searchAttribute) => {
|
|
387
|
-
|
|
397
|
+
if (["string", "number"].includes(typeof option)) {
|
|
398
|
+
return String(option).search(new RegExp(query.value, "i")) !== -1;
|
|
399
|
+
}
|
|
400
|
+
const child = get(option, searchAttribute);
|
|
401
|
+
return child !== null && child !== void 0 && String(child).search(new RegExp(query.value, "i")) !== -1;
|
|
388
402
|
});
|
|
389
403
|
});
|
|
390
404
|
});
|
|
391
405
|
const queryOption = computed(() => {
|
|
392
406
|
return query.value === "" ? null : { [props.optionAttribute]: query.value };
|
|
393
407
|
});
|
|
408
|
+
function clearOnClose() {
|
|
409
|
+
if (props.clearSearchOnClose) {
|
|
410
|
+
query.value = "";
|
|
411
|
+
}
|
|
412
|
+
}
|
|
394
413
|
watch(container, (value) => {
|
|
395
414
|
if (value) {
|
|
396
415
|
emit("open");
|
|
397
416
|
} else {
|
|
417
|
+
clearOnClose();
|
|
398
418
|
emit("close");
|
|
399
419
|
emitFormBlur();
|
|
400
420
|
}
|
|
@@ -417,6 +437,8 @@ export default defineComponent({
|
|
|
417
437
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
418
438
|
name,
|
|
419
439
|
inputId,
|
|
440
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
441
|
+
popper,
|
|
420
442
|
trigger,
|
|
421
443
|
container,
|
|
422
444
|
isLeading,
|