@humanonlyweb/ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/components/accordion/Accordion.js +60 -0
- package/dist/components/accordion/Accordion.vue.d.ts +28 -0
- package/dist/components/accordion/AccordionItem.js +102 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
- package/dist/components/avatar/Avatar.js +52 -0
- package/dist/components/avatar/Avatar.vue.d.ts +26 -0
- package/dist/components/avatar/AvatarGroup.js +48 -0
- package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
- package/dist/components/breadcrumbs/Breadcrumbs.js +59 -0
- package/dist/components/breadcrumbs/Breadcrumbs.vue.d.ts +14 -0
- package/dist/components/button/Button.js +95 -0
- package/dist/components/button/Button.vue.d.ts +74 -0
- package/dist/components/button/IconButton.js +47 -0
- package/dist/components/button/IconButton.vue.d.ts +115 -0
- package/dist/components/checkbox/Checkbox.js +93 -0
- package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
- package/dist/components/checkbox-group/CheckboxGroup.js +89 -0
- package/dist/components/checkbox-group/CheckboxGroup.vue.d.ts +43 -0
- package/dist/components/combobox/Combobox.js +294 -0
- package/dist/components/combobox/Combobox.vue.d.ts +80 -0
- package/dist/components/context-menu/ContextMenu.js +170 -0
- package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
- package/dist/components/dialog/ConfirmDialog.js +103 -0
- package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
- package/dist/components/dialog/Dialog.js +160 -0
- package/dist/components/dialog/Dialog.vue.d.ts +54 -0
- package/dist/components/field/FieldMessage.js +31 -0
- package/dist/components/fieldset/Fieldset.js +59 -0
- package/dist/components/fieldset/Fieldset.vue.d.ts +29 -0
- package/dist/components/input/Input.js +111 -0
- package/dist/components/input/Input.vue.d.ts +50 -0
- package/dist/components/kbd/Kbd.js +48 -0
- package/dist/components/kbd/Kbd.vue.d.ts +24 -0
- package/dist/components/menu/Menu.js +124 -0
- package/dist/components/menu/Menu.vue.d.ts +41 -0
- package/dist/components/otp-input/OtpInput.js +179 -0
- package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
- package/dist/components/pagination/Pagination.js +128 -0
- package/dist/components/pagination/Pagination.vue.d.ts +24 -0
- package/dist/components/password-input/PasswordInput.js +151 -0
- package/dist/components/password-input/PasswordInput.vue.d.ts +32 -0
- package/dist/components/popover/Popover.js +83 -0
- package/dist/components/popover/Popover.vue.d.ts +37 -0
- package/dist/components/progress/Progress.js +52 -0
- package/dist/components/progress/Progress.vue.d.ts +17 -0
- package/dist/components/radio-group/RadioGroup.js +125 -0
- package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
- package/dist/components/segmented/Segmented.js +110 -0
- package/dist/components/segmented/Segmented.vue.d.ts +41 -0
- package/dist/components/select/Select.js +231 -0
- package/dist/components/select/Select.vue.d.ts +59 -0
- package/dist/components/slider/Slider.js +196 -0
- package/dist/components/slider/Slider.vue.d.ts +49 -0
- package/dist/components/spin-button/SpinButton.js +231 -0
- package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
- package/dist/components/split-button/SplitButton.js +69 -0
- package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
- package/dist/components/switch/Switch.js +95 -0
- package/dist/components/switch/Switch.vue.d.ts +42 -0
- package/dist/components/table/Table.js +173 -0
- package/dist/components/table/Table.vue.d.ts +45 -0
- package/dist/components/tabs/Tabs.js +103 -0
- package/dist/components/tabs/Tabs.vue.d.ts +39 -0
- package/dist/components/tag-input/TagInput.js +186 -0
- package/dist/components/tag-input/TagInput.vue.d.ts +36 -0
- package/dist/components/textarea/Textarea.js +118 -0
- package/dist/components/textarea/Textarea.vue.d.ts +34 -0
- package/dist/components/toast/ToastItem.js +91 -0
- package/dist/components/toast/ToastItem.vue.d.ts +29 -0
- package/dist/components/toast/ToastViewport.js +56 -0
- package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
- package/dist/components/toolbar/Toolbar.js +91 -0
- package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
- package/dist/components/tooltip/Tooltip.js +85 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
- package/dist/components/visually-hidden/VisuallyHidden.js +16 -0
- package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +19 -0
- package/dist/composables/internal/env.js +5 -0
- package/dist/composables/internal/is-equal.js +14 -0
- package/dist/composables/internal/on-click-outside.js +18 -0
- package/dist/composables/internal/standard-schema.d.ts +38 -0
- package/dist/composables/internal/use-document-visibility.js +16 -0
- package/dist/composables/internal/use-event-listener.js +24 -0
- package/dist/composables/internal/use-interval-fn.js +21 -0
- package/dist/composables/internal/use-resize-observer.js +21 -0
- package/dist/composables/internal/use-timeout-fn.js +25 -0
- package/dist/composables/use-accordion.d.ts +9 -0
- package/dist/composables/use-accordion.js +10 -0
- package/dist/composables/use-combobox.d.ts +44 -0
- package/dist/composables/use-combobox.js +185 -0
- package/dist/composables/use-field.d.ts +17 -0
- package/dist/composables/use-field.js +27 -0
- package/dist/composables/use-form.d.ts +44 -0
- package/dist/composables/use-form.js +146 -0
- package/dist/composables/use-menu.d.ts +26 -0
- package/dist/composables/use-menu.js +117 -0
- package/dist/composables/use-platform.d.ts +17 -0
- package/dist/composables/use-platform.js +126 -0
- package/dist/composables/use-popover.d.ts +35 -0
- package/dist/composables/use-popover.js +49 -0
- package/dist/composables/use-roving-selection.d.ts +22 -0
- package/dist/composables/use-roving-selection.js +65 -0
- package/dist/composables/use-select.d.ts +31 -0
- package/dist/composables/use-select.js +169 -0
- package/dist/composables/use-slide-indicator.d.ts +24 -0
- package/dist/composables/use-slide-indicator.js +52 -0
- package/dist/composables/use-toast.d.ts +23 -0
- package/dist/composables/use-toast.js +51 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.js +35 -0
- package/dist/docs/README.md +52 -0
- package/dist/docs/changelog.md +21 -0
- package/dist/docs/components/accordion.md +100 -0
- package/dist/docs/components/avatar-group.md +58 -0
- package/dist/docs/components/avatar.md +40 -0
- package/dist/docs/components/breadcrumbs.md +81 -0
- package/dist/docs/components/button.md +109 -0
- package/dist/docs/components/checkbox-group.md +118 -0
- package/dist/docs/components/checkbox.md +123 -0
- package/dist/docs/components/combobox.md +207 -0
- package/dist/docs/components/confirm-dialog.md +107 -0
- package/dist/docs/components/context-menu.md +98 -0
- package/dist/docs/components/dialog.md +127 -0
- package/dist/docs/components/fieldset.md +65 -0
- package/dist/docs/components/icon-button.md +47 -0
- package/dist/docs/components/input.md +89 -0
- package/dist/docs/components/kbd.md +41 -0
- package/dist/docs/components/menu.md +112 -0
- package/dist/docs/components/otp-input.md +92 -0
- package/dist/docs/components/pagination.md +62 -0
- package/dist/docs/components/password-input.md +55 -0
- package/dist/docs/components/popover.md +72 -0
- package/dist/docs/components/progress.md +56 -0
- package/dist/docs/components/radio-group.md +114 -0
- package/dist/docs/components/segmented.md +96 -0
- package/dist/docs/components/select.md +129 -0
- package/dist/docs/components/slider.md +105 -0
- package/dist/docs/components/spin-button.md +73 -0
- package/dist/docs/components/split-button.md +64 -0
- package/dist/docs/components/switch.md +71 -0
- package/dist/docs/components/table.md +241 -0
- package/dist/docs/components/tabs.md +106 -0
- package/dist/docs/components/tag-input.md +88 -0
- package/dist/docs/components/textarea.md +46 -0
- package/dist/docs/components/toast.md +135 -0
- package/dist/docs/components/toolbar.md +71 -0
- package/dist/docs/components/tooltip.md +57 -0
- package/dist/docs/components/visually-hidden.md +53 -0
- package/dist/docs/forms.md +182 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/installation.md +71 -0
- package/dist/docs/localisation.md +42 -0
- package/dist/docs/ssr.md +24 -0
- package/dist/docs/styling.md +82 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +56 -0
- package/dist/nuxt/module.d.ts +15 -0
- package/dist/nuxt/module.js +80 -0
- package/dist/nuxt/runtime/plugin.d.ts +4 -0
- package/dist/nuxt/runtime/plugin.js +24 -0
- package/dist/package.js +4 -0
- package/dist/styles/core.css +310 -0
- package/dist/translations.d.ts +85 -0
- package/dist/translations.js +62 -0
- package/dist/types.d.ts +69 -0
- package/package.json +93 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SelectOption } from "../../types.js";
|
|
2
|
+
//#region src/components/segmented/Segmented.vue.d.ts
|
|
3
|
+
declare const __VLS_export: <T extends string | number>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
5
|
+
/** Segments to render, in order. */
|
|
6
|
+
options?: SelectOption<T>[];
|
|
7
|
+
/** Accessible name for the group. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Size hook, exposed as `data-segmented-size`. */
|
|
10
|
+
size?: "small" | "medium";
|
|
11
|
+
/** Segments render only the `option` slot (e.g. an icon); labels become their accessible names. */
|
|
12
|
+
iconOnly?: boolean;
|
|
13
|
+
/** Disables every segment. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Form field name: submits the value with a native form, via hidden inputs. */
|
|
16
|
+
name?: string;
|
|
17
|
+
} & {
|
|
18
|
+
/** The selected value. */
|
|
19
|
+
modelValue?: T;
|
|
20
|
+
}) & {
|
|
21
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
22
|
+
}> & (typeof globalThis extends {
|
|
23
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
24
|
+
} ? P : {});
|
|
25
|
+
expose: (exposed: {}) => void;
|
|
26
|
+
attrs: any;
|
|
27
|
+
slots: {
|
|
28
|
+
/** Segment content, e.g. an icon. */
|
|
29
|
+
option?(props: {
|
|
30
|
+
option: SelectOption<T>;
|
|
31
|
+
checked: boolean;
|
|
32
|
+
}): unknown;
|
|
33
|
+
};
|
|
34
|
+
emit: (event: "update:modelValue", value: T | undefined) => void;
|
|
35
|
+
}>) => import("vue").VNode & {
|
|
36
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
37
|
+
};
|
|
38
|
+
declare const _default: typeof __VLS_export;
|
|
39
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { _default as default };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { useField } from "../../composables/use-field.js";
|
|
3
|
+
import _sfc_main$1 from "../field/FieldMessage.js";
|
|
4
|
+
import { useAnchor } from "../../composables/use-popover.js";
|
|
5
|
+
import { useSelect } from "../../composables/use-select.js";
|
|
6
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef, withModifiers } from "vue";
|
|
7
|
+
//#region src/components/select/Select.vue
|
|
8
|
+
const _hoisted_1 = ["data-field-error", "data-field-name"];
|
|
9
|
+
const _hoisted_2 = ["id", "for"];
|
|
10
|
+
const _hoisted_3 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
"data-part": "field-optional"
|
|
13
|
+
};
|
|
14
|
+
const _hoisted_4 = [
|
|
15
|
+
"id",
|
|
16
|
+
"aria-expanded",
|
|
17
|
+
"aria-controls",
|
|
18
|
+
"aria-activedescendant",
|
|
19
|
+
"aria-labelledby",
|
|
20
|
+
"aria-invalid",
|
|
21
|
+
"aria-describedby",
|
|
22
|
+
"disabled",
|
|
23
|
+
"data-select-open",
|
|
24
|
+
"data-select-error"
|
|
25
|
+
];
|
|
26
|
+
const _hoisted_5 = ["data-select-placeholder"];
|
|
27
|
+
const _hoisted_6 = {
|
|
28
|
+
"data-part": "select-chevron",
|
|
29
|
+
"aria-hidden": "true"
|
|
30
|
+
};
|
|
31
|
+
const _hoisted_7 = [
|
|
32
|
+
"id",
|
|
33
|
+
"aria-multiselectable",
|
|
34
|
+
"aria-labelledby"
|
|
35
|
+
];
|
|
36
|
+
const _hoisted_8 = [
|
|
37
|
+
"id",
|
|
38
|
+
"aria-selected",
|
|
39
|
+
"aria-disabled",
|
|
40
|
+
"data-select-active",
|
|
41
|
+
"onClick",
|
|
42
|
+
"onPointermove"
|
|
43
|
+
];
|
|
44
|
+
const _hoisted_9 = {
|
|
45
|
+
"data-part": "select-option-check",
|
|
46
|
+
"aria-hidden": "true"
|
|
47
|
+
};
|
|
48
|
+
const _hoisted_10 = { "data-part": "select-option-label" };
|
|
49
|
+
const _hoisted_11 = ["name", "value"];
|
|
50
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
__name: "Select",
|
|
53
|
+
props: /*@__PURE__*/ mergeModels({
|
|
54
|
+
options: { default: () => [] },
|
|
55
|
+
error: { type: [String, Boolean] },
|
|
56
|
+
placeholder: { default: "Select an option" },
|
|
57
|
+
multiple: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
optional: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
disabled: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
68
|
+
},
|
|
69
|
+
label: {},
|
|
70
|
+
hint: {},
|
|
71
|
+
name: {},
|
|
72
|
+
id: {}
|
|
73
|
+
}, {
|
|
74
|
+
"modelValue": {},
|
|
75
|
+
"modelModifiers": {}
|
|
76
|
+
}),
|
|
77
|
+
emits: ["update:modelValue"],
|
|
78
|
+
setup(__props) {
|
|
79
|
+
/** The selected value, or values with `multiple`. */
|
|
80
|
+
const model = useModel(__props, "modelValue");
|
|
81
|
+
const submittedValues = computed(() => {
|
|
82
|
+
const value = model.value;
|
|
83
|
+
if (value == null) return [];
|
|
84
|
+
return Array.isArray(value) ? value : [value];
|
|
85
|
+
});
|
|
86
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
87
|
+
error: () => __props.error,
|
|
88
|
+
id: () => __props.id,
|
|
89
|
+
hint: () => __props.hint
|
|
90
|
+
});
|
|
91
|
+
const labelId = computed(() => `${id.value}-label`);
|
|
92
|
+
const listboxId = computed(() => `${id.value}-listbox`);
|
|
93
|
+
const { anchorStyle, panelStyle } = useAnchor();
|
|
94
|
+
const triggerRef = useTemplateRef("trigger");
|
|
95
|
+
const listboxRef = useTemplateRef("listbox");
|
|
96
|
+
const labelRef = useTemplateRef("label");
|
|
97
|
+
const { isOpen, activeId, optionId, activeIndex, isSelected, selectedOptions, selectAt, setActive, onTriggerKeydown, onTriggerPointerdown } = useSelect({
|
|
98
|
+
options: () => __props.options,
|
|
99
|
+
multiple: () => __props.multiple,
|
|
100
|
+
disabled: () => __props.disabled,
|
|
101
|
+
baseId: () => id.value,
|
|
102
|
+
model,
|
|
103
|
+
trigger: triggerRef,
|
|
104
|
+
listbox: listboxRef,
|
|
105
|
+
label: labelRef
|
|
106
|
+
});
|
|
107
|
+
const translations = useTranslations();
|
|
108
|
+
const displayLabel = computed(() => {
|
|
109
|
+
const [first, ...rest] = selectedOptions.value;
|
|
110
|
+
if (!first) return __props.placeholder;
|
|
111
|
+
return rest.length ? `${first.label} ${translations.value.moreSelected(rest.length)}` : first.label;
|
|
112
|
+
});
|
|
113
|
+
return (_ctx, _cache) => {
|
|
114
|
+
return openBlock(), createElementBlock("div", {
|
|
115
|
+
"data-part": "field",
|
|
116
|
+
"data-field-error": unref(isError) || void 0,
|
|
117
|
+
"data-field-name": __props.name
|
|
118
|
+
}, [
|
|
119
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
120
|
+
key: 0,
|
|
121
|
+
id: labelId.value,
|
|
122
|
+
ref: "label",
|
|
123
|
+
for: unref(id),
|
|
124
|
+
"data-part": "field-label",
|
|
125
|
+
onPointerdown: _cache[0] || (_cache[0] = (...args) => unref(onTriggerPointerdown) && unref(onTriggerPointerdown)(...args))
|
|
126
|
+
}, [createTextVNode(toDisplayString(__props.label), 1), __props.optional ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(` ${unref(translations).optional}`), 1)) : createCommentVNode("v-if", true)], 40, _hoisted_2)) : createCommentVNode("v-if", true),
|
|
127
|
+
createElementVNode("div", {
|
|
128
|
+
"data-part": "select-control",
|
|
129
|
+
style: normalizeStyle(unref(anchorStyle))
|
|
130
|
+
}, [createElementVNode("button", mergeProps({
|
|
131
|
+
id: unref(id),
|
|
132
|
+
ref: "trigger",
|
|
133
|
+
type: "button",
|
|
134
|
+
role: "combobox",
|
|
135
|
+
"data-part": "select-trigger",
|
|
136
|
+
"aria-haspopup": "listbox",
|
|
137
|
+
"aria-expanded": unref(isOpen),
|
|
138
|
+
"aria-controls": listboxId.value,
|
|
139
|
+
"aria-activedescendant": unref(activeId),
|
|
140
|
+
"aria-labelledby": __props.label ? `${labelId.value} ${unref(id)}` : void 0,
|
|
141
|
+
"aria-invalid": unref(isError) || void 0,
|
|
142
|
+
"aria-describedby": unref(describedBy),
|
|
143
|
+
disabled: __props.disabled,
|
|
144
|
+
"data-select-open": unref(isOpen) || void 0,
|
|
145
|
+
"data-select-error": unref(isError) || void 0
|
|
146
|
+
}, _ctx.$attrs, {
|
|
147
|
+
onKeydown: _cache[1] || (_cache[1] = (...args) => unref(onTriggerKeydown) && unref(onTriggerKeydown)(...args)),
|
|
148
|
+
onPointerdown: _cache[2] || (_cache[2] = (...args) => unref(onTriggerPointerdown) && unref(onTriggerPointerdown)(...args))
|
|
149
|
+
}), [createElementVNode("span", {
|
|
150
|
+
"data-part": "select-value",
|
|
151
|
+
"data-select-placeholder": !unref(selectedOptions).length || void 0
|
|
152
|
+
}, [renderSlot(_ctx.$slots, "value", {
|
|
153
|
+
selected: unref(selectedOptions),
|
|
154
|
+
placeholder: __props.placeholder
|
|
155
|
+
}, () => [createTextVNode(toDisplayString(displayLabel.value), 1)])], 8, _hoisted_5), createElementVNode("span", _hoisted_6, [renderSlot(_ctx.$slots, "chevron", {}, () => [_cache[4] || (_cache[4] = createElementVNode("svg", {
|
|
156
|
+
viewBox: "0 0 16 16",
|
|
157
|
+
width: "14",
|
|
158
|
+
height: "14",
|
|
159
|
+
focusable: "false"
|
|
160
|
+
}, [createElementVNode("path", {
|
|
161
|
+
d: "M4 6l4 4 4-4",
|
|
162
|
+
fill: "none",
|
|
163
|
+
stroke: "currentColor",
|
|
164
|
+
"stroke-width": "1.5",
|
|
165
|
+
"stroke-linecap": "round",
|
|
166
|
+
"stroke-linejoin": "round"
|
|
167
|
+
})], -1))])])], 16, _hoisted_4), createElementVNode("ul", {
|
|
168
|
+
id: listboxId.value,
|
|
169
|
+
ref: "listbox",
|
|
170
|
+
role: "listbox",
|
|
171
|
+
popover: "manual",
|
|
172
|
+
"data-part": "select-listbox",
|
|
173
|
+
style: normalizeStyle(unref(panelStyle)),
|
|
174
|
+
"aria-multiselectable": __props.multiple || void 0,
|
|
175
|
+
"aria-labelledby": __props.label ? labelId.value : void 0
|
|
176
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (opt, i) => {
|
|
177
|
+
return openBlock(), createElementBlock("li", {
|
|
178
|
+
id: unref(optionId)(i),
|
|
179
|
+
key: opt.value,
|
|
180
|
+
role: "option",
|
|
181
|
+
"data-part": "select-option",
|
|
182
|
+
"aria-selected": unref(isSelected)(opt.value),
|
|
183
|
+
"aria-disabled": opt.disabled || void 0,
|
|
184
|
+
"data-select-active": i === unref(activeIndex) || void 0,
|
|
185
|
+
onClick: ($event) => unref(selectAt)(i),
|
|
186
|
+
onPointerdown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["prevent"])),
|
|
187
|
+
onPointermove: ($event) => !opt.disabled && unref(setActive)(i)
|
|
188
|
+
}, [renderSlot(_ctx.$slots, "option", {
|
|
189
|
+
option: opt,
|
|
190
|
+
selected: unref(isSelected)(opt.value),
|
|
191
|
+
active: i === unref(activeIndex)
|
|
192
|
+
}, () => [createElementVNode("span", _hoisted_9, [unref(isSelected)(opt.value) ? renderSlot(_ctx.$slots, "check", {}, () => [_cache[5] || (_cache[5] = createElementVNode("svg", {
|
|
193
|
+
viewBox: "0 0 16 16",
|
|
194
|
+
width: "14",
|
|
195
|
+
height: "14",
|
|
196
|
+
focusable: "false"
|
|
197
|
+
}, [createElementVNode("path", {
|
|
198
|
+
d: "M3.5 8.5l3 3 6-7",
|
|
199
|
+
fill: "none",
|
|
200
|
+
stroke: "currentColor",
|
|
201
|
+
"stroke-width": "1.5",
|
|
202
|
+
"stroke-linecap": "round",
|
|
203
|
+
"stroke-linejoin": "round"
|
|
204
|
+
})], -1))], void 0, 0) : createCommentVNode("v-if", true)]), createElementVNode("span", _hoisted_10, toDisplayString(opt.label), 1)])], 40, _hoisted_8);
|
|
205
|
+
}), 128))], 12, _hoisted_7)], 4),
|
|
206
|
+
createCommentVNode(" Buttons don't submit values, so the form gets hidden inputs instead. "),
|
|
207
|
+
__props.name ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(submittedValues.value, (value) => {
|
|
208
|
+
return openBlock(), createElementBlock("input", {
|
|
209
|
+
key: value,
|
|
210
|
+
type: "hidden",
|
|
211
|
+
name: __props.name,
|
|
212
|
+
value
|
|
213
|
+
}, null, 8, _hoisted_11);
|
|
214
|
+
}), 128)) : createCommentVNode("v-if", true),
|
|
215
|
+
createVNode(_sfc_main$1, {
|
|
216
|
+
"error-id": unref(errorId),
|
|
217
|
+
"hint-id": unref(hintId),
|
|
218
|
+
"error-message": unref(errorMessage),
|
|
219
|
+
hint: __props.hint
|
|
220
|
+
}, null, 8, [
|
|
221
|
+
"error-id",
|
|
222
|
+
"hint-id",
|
|
223
|
+
"error-message",
|
|
224
|
+
"hint"
|
|
225
|
+
])
|
|
226
|
+
], 8, _hoisted_1);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
//#endregion
|
|
231
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SelectOption } from "../../types.js";
|
|
2
|
+
//#region src/components/select/Select.vue.d.ts
|
|
3
|
+
declare const __VLS_export: <T extends string | number>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
5
|
+
/** Options to choose from. */
|
|
6
|
+
options?: SelectOption<T>[];
|
|
7
|
+
/** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
|
|
8
|
+
error?: string | boolean;
|
|
9
|
+
/** Shown when nothing is selected. */
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Allow several selections; `v-model` becomes an array and the list stays open while picking. */
|
|
12
|
+
multiple?: boolean;
|
|
13
|
+
/** Appends the `optional` translation to the label. */
|
|
14
|
+
optional?: boolean;
|
|
15
|
+
/** Disables the control. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Visible label, linked to the control. */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Help text under the control, announced as its description. */
|
|
20
|
+
hint?: string;
|
|
21
|
+
/** Form field name: submits the value with a native form, via hidden inputs. */
|
|
22
|
+
name?: string;
|
|
23
|
+
/** Id for the control; generated with `useId()` when omitted. */
|
|
24
|
+
id?: string;
|
|
25
|
+
} & {
|
|
26
|
+
/** The selected value, or values with `multiple`. */
|
|
27
|
+
modelValue?: T | T[];
|
|
28
|
+
}) & {
|
|
29
|
+
"onUpdate:modelValue"?: ((value: T | T[] | undefined) => any) | undefined;
|
|
30
|
+
}> & (typeof globalThis extends {
|
|
31
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
32
|
+
} ? P : {});
|
|
33
|
+
expose: (exposed: {}) => void;
|
|
34
|
+
attrs: any;
|
|
35
|
+
slots: {
|
|
36
|
+
/** Trigger content, replacing the selected label or placeholder. */
|
|
37
|
+
value?(props: {
|
|
38
|
+
selected: SelectOption<T>[];
|
|
39
|
+
placeholder: string;
|
|
40
|
+
}): unknown;
|
|
41
|
+
/** Option content. */
|
|
42
|
+
option?(props: {
|
|
43
|
+
option: SelectOption<T>;
|
|
44
|
+
selected: boolean;
|
|
45
|
+
active: boolean;
|
|
46
|
+
}): unknown;
|
|
47
|
+
/** Replaces the trigger's chevron. */
|
|
48
|
+
chevron?(): unknown;
|
|
49
|
+
/** Replaces the selected option's check mark. */
|
|
50
|
+
check?(): unknown;
|
|
51
|
+
};
|
|
52
|
+
emit: (event: "update:modelValue", value: T | T[] | undefined) => void;
|
|
53
|
+
}>) => import("vue").VNode & {
|
|
54
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
55
|
+
};
|
|
56
|
+
declare const _default: typeof __VLS_export;
|
|
57
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { _default as default };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
|
|
3
|
+
//#region src/components/slider/Slider.vue
|
|
4
|
+
const _hoisted_1 = ["data-orientation", "data-slider-disabled"];
|
|
5
|
+
const _hoisted_2 = ["id"];
|
|
6
|
+
const _hoisted_3 = [
|
|
7
|
+
"data-slider-thumb",
|
|
8
|
+
"tabindex",
|
|
9
|
+
"aria-valuemin",
|
|
10
|
+
"aria-valuemax",
|
|
11
|
+
"aria-valuenow",
|
|
12
|
+
"aria-valuetext",
|
|
13
|
+
"aria-orientation",
|
|
14
|
+
"aria-disabled",
|
|
15
|
+
"aria-labelledby",
|
|
16
|
+
"aria-label",
|
|
17
|
+
"onKeydown"
|
|
18
|
+
];
|
|
19
|
+
const _hoisted_4 = ["name", "value"];
|
|
20
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
21
|
+
__name: "Slider",
|
|
22
|
+
props: /*@__PURE__*/ mergeModels({
|
|
23
|
+
min: { default: 0 },
|
|
24
|
+
max: { default: 100 },
|
|
25
|
+
step: { default: 1 },
|
|
26
|
+
largeStep: {},
|
|
27
|
+
orientation: { default: "horizontal" },
|
|
28
|
+
disabled: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
label: {},
|
|
33
|
+
thumbLabels: {},
|
|
34
|
+
formatValue: { type: Function },
|
|
35
|
+
name: {}
|
|
36
|
+
}, {
|
|
37
|
+
"modelValue": {},
|
|
38
|
+
"modelModifiers": {}
|
|
39
|
+
}),
|
|
40
|
+
emits: /*@__PURE__*/ mergeModels(["commit"], ["update:modelValue"]),
|
|
41
|
+
setup(__props, { emit: __emit }) {
|
|
42
|
+
const emit = __emit;
|
|
43
|
+
/** A number, or `[start, end]` for a range. Empty starts at `min`. */
|
|
44
|
+
const model = useModel(__props, "modelValue");
|
|
45
|
+
const labelId = useId();
|
|
46
|
+
const translations = useTranslations();
|
|
47
|
+
const rootRef = useTemplateRef("root");
|
|
48
|
+
const controlRef = useTemplateRef("control");
|
|
49
|
+
const thumbRefs = useTemplateRef("thumbs");
|
|
50
|
+
const isRange = computed(() => Array.isArray(model.value));
|
|
51
|
+
const values = computed(() => {
|
|
52
|
+
const value = model.value;
|
|
53
|
+
if (Array.isArray(value)) return [...value];
|
|
54
|
+
return [value ?? __props.min];
|
|
55
|
+
});
|
|
56
|
+
const decimals = computed(() => String(__props.step).split(".")[1]?.length ?? 0);
|
|
57
|
+
function snap(value) {
|
|
58
|
+
const snapped = Math.round((value - __props.min) / __props.step) * __props.step + __props.min;
|
|
59
|
+
const clamped = Math.min(__props.max, Math.max(__props.min, snapped));
|
|
60
|
+
return Number(clamped.toFixed(decimals.value));
|
|
61
|
+
}
|
|
62
|
+
const percent = (value) => __props.max === __props.min ? 0 : (value - __props.min) / (__props.max - __props.min) * 100;
|
|
63
|
+
const rootStyle = computed(() => {
|
|
64
|
+
const [first = __props.min, second] = values.value;
|
|
65
|
+
return {
|
|
66
|
+
"--ui-slider-start": `${isRange.value ? percent(first) : 0}%`,
|
|
67
|
+
"--ui-slider-end": `${percent(isRange.value ? second ?? __props.max : first)}%`
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
/** Thumbs can't cross: each is bounded by its neighbour. */
|
|
71
|
+
function setValue(index, value) {
|
|
72
|
+
const next = snap(value);
|
|
73
|
+
if (!isRange.value) {
|
|
74
|
+
model.value = next;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const [start = __props.min, end = __props.max] = values.value;
|
|
78
|
+
model.value = index === 0 ? [Math.min(next, end), end] : [start, Math.max(next, start)];
|
|
79
|
+
}
|
|
80
|
+
function commit() {
|
|
81
|
+
const value = model.value;
|
|
82
|
+
if (value === void 0) return;
|
|
83
|
+
emit("commit", Array.isArray(value) ? [...value] : value);
|
|
84
|
+
}
|
|
85
|
+
function isRtl() {
|
|
86
|
+
return rootRef.value ? getComputedStyle(rootRef.value).direction === "rtl" : false;
|
|
87
|
+
}
|
|
88
|
+
function onKeydown(event, index) {
|
|
89
|
+
if (__props.disabled) return;
|
|
90
|
+
const value = values.value[index];
|
|
91
|
+
const big = __props.largeStep ?? __props.step * 10;
|
|
92
|
+
const forward = isRtl() && __props.orientation === "horizontal" ? -1 : 1;
|
|
93
|
+
const target = {
|
|
94
|
+
ArrowRight: value + __props.step * forward,
|
|
95
|
+
ArrowLeft: value - __props.step * forward,
|
|
96
|
+
ArrowUp: value + __props.step,
|
|
97
|
+
ArrowDown: value - __props.step,
|
|
98
|
+
PageUp: value + big,
|
|
99
|
+
PageDown: value - big,
|
|
100
|
+
Home: __props.min,
|
|
101
|
+
End: __props.max
|
|
102
|
+
}[event.key];
|
|
103
|
+
if (target === void 0) return;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
setValue(index, target);
|
|
106
|
+
commit();
|
|
107
|
+
}
|
|
108
|
+
function valueAt(event) {
|
|
109
|
+
const rect = controlRef.value.getBoundingClientRect();
|
|
110
|
+
const ratio = __props.orientation === "vertical" ? (rect.bottom - event.clientY) / rect.height : isRtl() ? (rect.right - event.clientX) / rect.width : (event.clientX - rect.left) / rect.width;
|
|
111
|
+
return __props.min + Math.min(1, Math.max(0, ratio)) * (__props.max - __props.min);
|
|
112
|
+
}
|
|
113
|
+
let dragging = -1;
|
|
114
|
+
function onPointerdown(event) {
|
|
115
|
+
if (__props.disabled || event.button !== 0) return;
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
const value = valueAt(event);
|
|
118
|
+
const distances = values.value.map((v) => Math.abs(v - value));
|
|
119
|
+
const nearest = Math.min(...distances);
|
|
120
|
+
const ties = distances.flatMap((d, i) => d === nearest ? [i] : []);
|
|
121
|
+
dragging = ties.length > 1 && value > values.value[0] ? ties.at(-1) : ties[0];
|
|
122
|
+
controlRef.value.setPointerCapture(event.pointerId);
|
|
123
|
+
setValue(dragging, value);
|
|
124
|
+
thumbRefs.value?.[dragging]?.focus();
|
|
125
|
+
}
|
|
126
|
+
function onPointermove(event) {
|
|
127
|
+
if (dragging < 0) return;
|
|
128
|
+
setValue(dragging, valueAt(event));
|
|
129
|
+
}
|
|
130
|
+
function onPointerup() {
|
|
131
|
+
if (dragging < 0) return;
|
|
132
|
+
dragging = -1;
|
|
133
|
+
commit();
|
|
134
|
+
}
|
|
135
|
+
const thumbName = (index) => {
|
|
136
|
+
if (!isRange.value) return void 0;
|
|
137
|
+
return __props.thumbLabels?.[index] ?? [translations.value.rangeStart, translations.value.rangeEnd][index];
|
|
138
|
+
};
|
|
139
|
+
return (_ctx, _cache) => {
|
|
140
|
+
return openBlock(), createElementBlock("div", {
|
|
141
|
+
ref: "root",
|
|
142
|
+
"data-part": "slider",
|
|
143
|
+
"data-orientation": __props.orientation,
|
|
144
|
+
"data-slider-disabled": __props.disabled || void 0,
|
|
145
|
+
style: normalizeStyle(rootStyle.value)
|
|
146
|
+
}, [
|
|
147
|
+
__props.label ? (openBlock(), createElementBlock("span", {
|
|
148
|
+
key: 0,
|
|
149
|
+
id: unref(labelId),
|
|
150
|
+
"data-part": "slider-label"
|
|
151
|
+
}, toDisplayString(__props.label), 9, _hoisted_2)) : createCommentVNode("v-if", true),
|
|
152
|
+
createElementVNode("div", {
|
|
153
|
+
ref: "control",
|
|
154
|
+
"data-part": "slider-control",
|
|
155
|
+
onPointerdown,
|
|
156
|
+
onPointermove,
|
|
157
|
+
onPointerup,
|
|
158
|
+
onPointercancel: onPointerup
|
|
159
|
+
}, [_cache[0] || (_cache[0] = createElementVNode("span", { "data-part": "slider-track" }, [createElementVNode("span", { "data-part": "slider-range" })], -1)), (openBlock(true), createElementBlock(Fragment, null, renderList(values.value, (value, index) => {
|
|
160
|
+
return openBlock(), createElementBlock("span", {
|
|
161
|
+
ref_for: true,
|
|
162
|
+
ref: "thumbs",
|
|
163
|
+
key: index,
|
|
164
|
+
role: "slider",
|
|
165
|
+
"data-part": "slider-thumb",
|
|
166
|
+
"data-slider-thumb": index === 0 ? "start" : "end",
|
|
167
|
+
tabindex: __props.disabled ? void 0 : 0,
|
|
168
|
+
"aria-valuemin": __props.min,
|
|
169
|
+
"aria-valuemax": __props.max,
|
|
170
|
+
"aria-valuenow": value,
|
|
171
|
+
"aria-valuetext": __props.formatValue?.(value),
|
|
172
|
+
"aria-orientation": __props.orientation,
|
|
173
|
+
"aria-disabled": __props.disabled || void 0,
|
|
174
|
+
"aria-labelledby": __props.label && !thumbName(index) ? unref(labelId) : void 0,
|
|
175
|
+
"aria-label": thumbName(index) && __props.label ? `${__props.label}, ${thumbName(index)}` : thumbName(index),
|
|
176
|
+
style: normalizeStyle({ "--ui-slider-value": `${percent(value)}%` }),
|
|
177
|
+
onKeydown: ($event) => onKeydown($event, index)
|
|
178
|
+
}, [renderSlot(_ctx.$slots, "thumb", {
|
|
179
|
+
value,
|
|
180
|
+
index
|
|
181
|
+
})], 44, _hoisted_3);
|
|
182
|
+
}), 128))], 544),
|
|
183
|
+
__props.name ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(values.value, (value, index) => {
|
|
184
|
+
return openBlock(), createElementBlock("input", {
|
|
185
|
+
key: index,
|
|
186
|
+
type: "hidden",
|
|
187
|
+
name: __props.name,
|
|
188
|
+
value
|
|
189
|
+
}, null, 8, _hoisted_4);
|
|
190
|
+
}), 128)) : createCommentVNode("v-if", true)
|
|
191
|
+
], 12, _hoisted_1);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
//#endregion
|
|
196
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/components/slider/Slider.vue.d.ts
|
|
2
|
+
declare const __VLS_export: <T extends number | [number, number]>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
4
|
+
/** Lowest value. */
|
|
5
|
+
min?: number;
|
|
6
|
+
/** Highest value. */
|
|
7
|
+
max?: number;
|
|
8
|
+
/** Arrow-key increment. Values snap to it. */
|
|
9
|
+
step?: number;
|
|
10
|
+
/** PageUp/PageDown increment. Defaults to ten steps. */
|
|
11
|
+
largeStep?: number;
|
|
12
|
+
/** Layout hook, exposed as `data-orientation` and `aria-orientation`. */
|
|
13
|
+
orientation?: "horizontal" | "vertical";
|
|
14
|
+
/** Disables the slider. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Visible label, which names the thumb(s). */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Accessible names for the two thumbs of a range. Default to `rangeStart` / `rangeEnd`. */
|
|
19
|
+
thumbLabels?: [string, string];
|
|
20
|
+
/** Text for `aria-valuetext`, e.g. `(v) => \`${v}%\``. */
|
|
21
|
+
formatValue?: (value: number) => string;
|
|
22
|
+
/** Form field name; renders a hidden input per value. */
|
|
23
|
+
name?: string;
|
|
24
|
+
} & {
|
|
25
|
+
/** A number, or `[start, end]` for a range. Empty starts at `min`. */
|
|
26
|
+
modelValue?: T;
|
|
27
|
+
}) & {
|
|
28
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
29
|
+
onCommit?: ((value: T) => any) | undefined;
|
|
30
|
+
}> & (typeof globalThis extends {
|
|
31
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
32
|
+
} ? P : {});
|
|
33
|
+
expose: (exposed: {}) => void;
|
|
34
|
+
attrs: any;
|
|
35
|
+
slots: {
|
|
36
|
+
/** Thumb content, e.g. a value bubble. */
|
|
37
|
+
thumb?(props: {
|
|
38
|
+
value: number;
|
|
39
|
+
index: number;
|
|
40
|
+
}): unknown;
|
|
41
|
+
};
|
|
42
|
+
emit: ((evt: "commit", value: T) => void) & ((event: "update:modelValue", value: T | undefined) => void);
|
|
43
|
+
}>) => import("vue").VNode & {
|
|
44
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
45
|
+
};
|
|
46
|
+
declare const _default: typeof __VLS_export;
|
|
47
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { _default as default };
|