@humanonlyweb/ui 0.0.0-stage → 0.1.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/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/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/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/popover/Popover.js +83 -0
- package/dist/components/popover/Popover.vue.d.ts +37 -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 +99 -0
- package/dist/components/tabs/Tabs.vue.d.ts +39 -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/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 +44 -0
- package/dist/docs/changelog.md +14 -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/button.md +109 -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/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/popover.md +72 -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/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/forms.md +182 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/installation.md +73 -0
- package/dist/docs/localisation.md +40 -0
- package/dist/docs/ssr.md +24 -0
- package/dist/docs/styling.md +66 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +44 -0
- package/dist/nuxt/module.d.ts +15 -0
- package/dist/nuxt/module.js +72 -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 +284 -0
- package/dist/translations.d.ts +71 -0
- package/dist/translations.js +55 -0
- package/dist/types.d.ts +61 -0
- package/package.json +93 -4
|
@@ -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 };
|
|
@@ -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 { useEventListener } from "../../composables/internal/use-event-listener.js";
|
|
5
|
+
import { useTimeoutFn } from "../../composables/internal/use-timeout-fn.js";
|
|
6
|
+
import { useIntervalFn } from "../../composables/internal/use-interval-fn.js";
|
|
7
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, ref, renderSlot, toDisplayString, unref, useModel, useTemplateRef } from "vue";
|
|
8
|
+
//#region src/components/spin-button/SpinButton.vue
|
|
9
|
+
const _hoisted_1 = ["data-field-error"];
|
|
10
|
+
const _hoisted_2 = ["for"];
|
|
11
|
+
const _hoisted_3 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
"data-part": "field-optional"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_4 = ["data-spinbutton-error", "data-spinbutton-disabled"];
|
|
16
|
+
const _hoisted_5 = ["aria-label", "disabled"];
|
|
17
|
+
const _hoisted_6 = [
|
|
18
|
+
"id",
|
|
19
|
+
"value",
|
|
20
|
+
"disabled",
|
|
21
|
+
"aria-valuenow",
|
|
22
|
+
"aria-valuemin",
|
|
23
|
+
"aria-valuemax",
|
|
24
|
+
"aria-invalid",
|
|
25
|
+
"aria-describedby"
|
|
26
|
+
];
|
|
27
|
+
const _hoisted_7 = ["aria-label", "disabled"];
|
|
28
|
+
const REPEAT_DELAY = 400;
|
|
29
|
+
const REPEAT_INTERVAL = 60;
|
|
30
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
__name: "SpinButton",
|
|
33
|
+
props: /*@__PURE__*/ mergeModels({
|
|
34
|
+
id: {},
|
|
35
|
+
min: { default: () => Number.NEGATIVE_INFINITY },
|
|
36
|
+
max: { default: () => Number.POSITIVE_INFINITY },
|
|
37
|
+
step: { default: 1 },
|
|
38
|
+
hint: {},
|
|
39
|
+
label: {},
|
|
40
|
+
optional: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
disabled: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
error: { type: [String, Boolean] }
|
|
49
|
+
}, {
|
|
50
|
+
"modelValue": {},
|
|
51
|
+
"modelModifiers": {}
|
|
52
|
+
}),
|
|
53
|
+
emits: ["update:modelValue"],
|
|
54
|
+
setup(__props, { expose: __expose }) {
|
|
55
|
+
/** The value. `undefined` while the input is empty. */
|
|
56
|
+
const model = useModel(__props, "modelValue");
|
|
57
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
58
|
+
id: () => __props.id,
|
|
59
|
+
hint: () => __props.hint,
|
|
60
|
+
error: () => __props.error
|
|
61
|
+
});
|
|
62
|
+
const translations = useTranslations();
|
|
63
|
+
const pageStep = computed(() => __props.step * 10);
|
|
64
|
+
const decimals = computed(() => String(__props.step).split(".")[1]?.length ?? 0);
|
|
65
|
+
function clamp(value) {
|
|
66
|
+
const bounded = Math.min(__props.max, Math.max(__props.min, value));
|
|
67
|
+
return decimals.value ? Number(bounded.toFixed(decimals.value)) : bounded;
|
|
68
|
+
}
|
|
69
|
+
const draft = ref(null);
|
|
70
|
+
const inputValue = computed(() => {
|
|
71
|
+
if (draft.value !== null) return draft.value;
|
|
72
|
+
return model.value == null ? "" : String(model.value);
|
|
73
|
+
});
|
|
74
|
+
function onInput(event) {
|
|
75
|
+
if (!(event.target instanceof HTMLInputElement)) return;
|
|
76
|
+
const raw = event.target.value;
|
|
77
|
+
draft.value = raw;
|
|
78
|
+
const parsed = Number.parseFloat(raw);
|
|
79
|
+
model.value = Number.isNaN(parsed) ? void 0 : parsed;
|
|
80
|
+
}
|
|
81
|
+
function onBlur() {
|
|
82
|
+
draft.value = null;
|
|
83
|
+
if (model.value != null) model.value = clamp(model.value);
|
|
84
|
+
}
|
|
85
|
+
function commit(value) {
|
|
86
|
+
if (__props.disabled) return;
|
|
87
|
+
model.value = clamp(value);
|
|
88
|
+
draft.value = null;
|
|
89
|
+
}
|
|
90
|
+
function nudge(direction, amount = __props.step) {
|
|
91
|
+
const base = model.value ?? (Number.isFinite(__props.min) ? __props.min : 0);
|
|
92
|
+
commit(model.value == null ? base : base + direction * amount);
|
|
93
|
+
}
|
|
94
|
+
const atMin = computed(() => model.value != null && model.value <= __props.min);
|
|
95
|
+
const atMax = computed(() => model.value != null && model.value >= __props.max);
|
|
96
|
+
function onKeydown(event) {
|
|
97
|
+
const action = {
|
|
98
|
+
ArrowUp: () => nudge(1),
|
|
99
|
+
ArrowDown: () => nudge(-1),
|
|
100
|
+
PageUp: () => nudge(1, pageStep.value),
|
|
101
|
+
PageDown: () => nudge(-1, pageStep.value),
|
|
102
|
+
Home: () => {
|
|
103
|
+
if (Number.isFinite(__props.min)) commit(__props.min);
|
|
104
|
+
},
|
|
105
|
+
End: () => {
|
|
106
|
+
if (Number.isFinite(__props.max)) commit(__props.max);
|
|
107
|
+
}
|
|
108
|
+
}[event.key];
|
|
109
|
+
if (!action) return;
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
action();
|
|
112
|
+
}
|
|
113
|
+
let heldDirection = 1;
|
|
114
|
+
const repeat = useIntervalFn(() => nudge(heldDirection), REPEAT_INTERVAL);
|
|
115
|
+
const repeatDelay = useTimeoutFn(repeat.resume, REPEAT_DELAY);
|
|
116
|
+
function stopRepeat() {
|
|
117
|
+
repeatDelay.stop();
|
|
118
|
+
repeat.pause();
|
|
119
|
+
}
|
|
120
|
+
for (const type of [
|
|
121
|
+
"pointerup",
|
|
122
|
+
"pointercancel",
|
|
123
|
+
"blur"
|
|
124
|
+
]) useEventListener(() => window, type, stopRepeat);
|
|
125
|
+
function onPointerdown(event, direction) {
|
|
126
|
+
if (event.button !== 0) return;
|
|
127
|
+
if (event.currentTarget instanceof HTMLElement) event.currentTarget.setPointerCapture(event.pointerId);
|
|
128
|
+
heldDirection = direction;
|
|
129
|
+
nudge(direction);
|
|
130
|
+
repeatDelay.start();
|
|
131
|
+
}
|
|
132
|
+
function onClick(event, direction) {
|
|
133
|
+
if (event.detail === 0) nudge(direction);
|
|
134
|
+
}
|
|
135
|
+
const inputRef = useTemplateRef("input");
|
|
136
|
+
__expose({ focus: () => inputRef.value?.focus() });
|
|
137
|
+
return (_ctx, _cache) => {
|
|
138
|
+
return openBlock(), createElementBlock("div", {
|
|
139
|
+
"data-part": "field",
|
|
140
|
+
"data-field-error": unref(isError) || void 0
|
|
141
|
+
}, [
|
|
142
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
143
|
+
key: 0,
|
|
144
|
+
for: unref(id),
|
|
145
|
+
"data-part": "field-label"
|
|
146
|
+
}, [createTextVNode(toDisplayString(__props.label), 1), __props.optional ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(` ${unref(translations).optional}`), 1)) : createCommentVNode("v-if", true)], 8, _hoisted_2)) : createCommentVNode("v-if", true),
|
|
147
|
+
createElementVNode("div", {
|
|
148
|
+
"data-part": "spinbutton",
|
|
149
|
+
"data-spinbutton-error": unref(isError) || void 0,
|
|
150
|
+
"data-spinbutton-disabled": __props.disabled || void 0
|
|
151
|
+
}, [
|
|
152
|
+
createCommentVNode(" Out of the tab order: the arrow keys on the input do the same, and the\n buttons are a pointer convenience. "),
|
|
153
|
+
createElementVNode("button", {
|
|
154
|
+
type: "button",
|
|
155
|
+
tabindex: "-1",
|
|
156
|
+
"aria-label": unref(translations).decrease,
|
|
157
|
+
"data-part": "spinbutton-decrement",
|
|
158
|
+
disabled: __props.disabled || atMin.value,
|
|
159
|
+
onPointerdown: _cache[0] || (_cache[0] = ($event) => onPointerdown($event, -1)),
|
|
160
|
+
onClick: _cache[1] || (_cache[1] = ($event) => onClick($event, -1))
|
|
161
|
+
}, [renderSlot(_ctx.$slots, "decrement", {}, () => [_cache[4] || (_cache[4] = createElementVNode("svg", {
|
|
162
|
+
viewBox: "0 0 16 16",
|
|
163
|
+
width: "14",
|
|
164
|
+
height: "14",
|
|
165
|
+
"aria-hidden": "true",
|
|
166
|
+
focusable: "false"
|
|
167
|
+
}, [createElementVNode("path", {
|
|
168
|
+
d: "M4 8h8",
|
|
169
|
+
stroke: "currentColor",
|
|
170
|
+
"stroke-width": "1.5",
|
|
171
|
+
"stroke-linecap": "round"
|
|
172
|
+
})], -1))])], 40, _hoisted_5),
|
|
173
|
+
createElementVNode("input", mergeProps({
|
|
174
|
+
id: unref(id),
|
|
175
|
+
ref: "input",
|
|
176
|
+
type: "text",
|
|
177
|
+
role: "spinbutton",
|
|
178
|
+
inputmode: "decimal",
|
|
179
|
+
autocomplete: "off",
|
|
180
|
+
spellcheck: "false"
|
|
181
|
+
}, _ctx.$attrs, {
|
|
182
|
+
value: inputValue.value,
|
|
183
|
+
disabled: __props.disabled,
|
|
184
|
+
"aria-valuenow": model.value,
|
|
185
|
+
"aria-valuemin": Number.isFinite(__props.min) ? __props.min : void 0,
|
|
186
|
+
"aria-valuemax": Number.isFinite(__props.max) ? __props.max : void 0,
|
|
187
|
+
"aria-invalid": unref(isError) || void 0,
|
|
188
|
+
"aria-describedby": unref(describedBy),
|
|
189
|
+
"data-part": "spinbutton-input",
|
|
190
|
+
onInput,
|
|
191
|
+
onBlur,
|
|
192
|
+
onKeydown
|
|
193
|
+
}), null, 16, _hoisted_6),
|
|
194
|
+
createElementVNode("button", {
|
|
195
|
+
type: "button",
|
|
196
|
+
tabindex: "-1",
|
|
197
|
+
"aria-label": unref(translations).increase,
|
|
198
|
+
"data-part": "spinbutton-increment",
|
|
199
|
+
disabled: __props.disabled || atMax.value,
|
|
200
|
+
onPointerdown: _cache[2] || (_cache[2] = ($event) => onPointerdown($event, 1)),
|
|
201
|
+
onClick: _cache[3] || (_cache[3] = ($event) => onClick($event, 1))
|
|
202
|
+
}, [renderSlot(_ctx.$slots, "increment", {}, () => [_cache[5] || (_cache[5] = createElementVNode("svg", {
|
|
203
|
+
viewBox: "0 0 16 16",
|
|
204
|
+
width: "14",
|
|
205
|
+
height: "14",
|
|
206
|
+
"aria-hidden": "true",
|
|
207
|
+
focusable: "false"
|
|
208
|
+
}, [createElementVNode("path", {
|
|
209
|
+
d: "M4 8h8M8 4v8",
|
|
210
|
+
stroke: "currentColor",
|
|
211
|
+
"stroke-width": "1.5",
|
|
212
|
+
"stroke-linecap": "round"
|
|
213
|
+
})], -1))])], 40, _hoisted_7)
|
|
214
|
+
], 8, _hoisted_4),
|
|
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,48 @@
|
|
|
1
|
+
//#region src/components/spin-button/SpinButton.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Id for the control; generated with `useId()` when omitted. */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Lowest value. Home jumps here. */
|
|
6
|
+
min?: number;
|
|
7
|
+
/** Highest value. End jumps here. */
|
|
8
|
+
max?: number;
|
|
9
|
+
/** Arrow-key and button increment; PageUp/PageDown move ten steps. Its decimals set the rounding. */
|
|
10
|
+
step?: number;
|
|
11
|
+
/** Help text under the control, announced as its description. */
|
|
12
|
+
hint?: string;
|
|
13
|
+
/** Visible label, linked to the control. */
|
|
14
|
+
label?: string;
|
|
15
|
+
/** Appends the `optional` translation to the label. */
|
|
16
|
+
optional?: boolean;
|
|
17
|
+
/** Disables the control. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
|
|
20
|
+
error?: string | boolean;
|
|
21
|
+
};
|
|
22
|
+
type __VLS_Slots = {
|
|
23
|
+
/** Decrease button icon. */
|
|
24
|
+
decrement?(): unknown;
|
|
25
|
+
/** Increase button icon. */
|
|
26
|
+
increment?(): unknown;
|
|
27
|
+
};
|
|
28
|
+
type __VLS_ModelProps = {
|
|
29
|
+
/** The value. `undefined` while the input is empty. */
|
|
30
|
+
modelValue?: number;
|
|
31
|
+
};
|
|
32
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
33
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
34
|
+
focus: () => void | undefined;
|
|
35
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
36
|
+
"update:modelValue": (value: number | undefined) => any;
|
|
37
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
38
|
+
"onUpdate:modelValue"?: ((value: number | undefined) => any) | undefined;
|
|
39
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
|
+
declare const _default: typeof __VLS_export;
|
|
42
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
43
|
+
new (): {
|
|
44
|
+
$slots: S;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { _default as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { computed, createElementBlock, createElementVNode, defineComponent, mergeProps, openBlock, renderSlot } from "vue";
|
|
2
|
+
//#region src/components/split-button/SplitButton.vue
|
|
3
|
+
const _hoisted_1 = ["data-split-variant"];
|
|
4
|
+
const _hoisted_2 = ["disabled"];
|
|
5
|
+
const _hoisted_3 = { "data-part": "button-label" };
|
|
6
|
+
const _hoisted_4 = ["disabled", "aria-label"];
|
|
7
|
+
const _hoisted_5 = ["data-split-open"];
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
__name: "SplitButton",
|
|
10
|
+
props: {
|
|
11
|
+
menuLabel: {},
|
|
12
|
+
triggerAttrs: {},
|
|
13
|
+
variant: { default: "secondary" },
|
|
14
|
+
size: { default: "medium" },
|
|
15
|
+
disabled: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
emits: ["action", "toggle"],
|
|
21
|
+
setup(__props, { emit: __emit }) {
|
|
22
|
+
const emit = __emit;
|
|
23
|
+
const isOpen = computed(() => __props.triggerAttrs?.["aria-expanded"] === true);
|
|
24
|
+
const sharedAttrs = computed(() => ({
|
|
25
|
+
"data-part": "button",
|
|
26
|
+
"data-button-variant": __props.variant,
|
|
27
|
+
"data-button-size": __props.size,
|
|
28
|
+
"data-button-disabled": __props.disabled || void 0
|
|
29
|
+
}));
|
|
30
|
+
return (_ctx, _cache) => {
|
|
31
|
+
return openBlock(), createElementBlock("div", {
|
|
32
|
+
"data-part": "split-button",
|
|
33
|
+
"data-split-variant": __props.variant
|
|
34
|
+
}, [createElementVNode("button", mergeProps(sharedAttrs.value, {
|
|
35
|
+
type: "button",
|
|
36
|
+
"data-split-part": "action",
|
|
37
|
+
disabled: __props.disabled,
|
|
38
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("action"))
|
|
39
|
+
}), [createElementVNode("span", _hoisted_3, [renderSlot(_ctx.$slots, "default")])], 16, _hoisted_2), createElementVNode("button", mergeProps({
|
|
40
|
+
...sharedAttrs.value,
|
|
41
|
+
...__props.triggerAttrs
|
|
42
|
+
}, {
|
|
43
|
+
type: "button",
|
|
44
|
+
"data-split-part": "toggle",
|
|
45
|
+
disabled: __props.disabled,
|
|
46
|
+
"aria-label": __props.menuLabel,
|
|
47
|
+
onClick: _cache[1] || (_cache[1] = ($event) => emit("toggle"))
|
|
48
|
+
}), [createElementVNode("span", {
|
|
49
|
+
"data-split-part": "caret",
|
|
50
|
+
"data-split-open": isOpen.value || void 0,
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}, [renderSlot(_ctx.$slots, "caret", { open: isOpen.value }, () => [_cache[2] || (_cache[2] = createElementVNode("svg", {
|
|
53
|
+
viewBox: "0 0 16 16",
|
|
54
|
+
width: "14",
|
|
55
|
+
height: "14",
|
|
56
|
+
focusable: "false"
|
|
57
|
+
}, [createElementVNode("path", {
|
|
58
|
+
d: "M4 6l4 4 4-4",
|
|
59
|
+
fill: "none",
|
|
60
|
+
stroke: "currentColor",
|
|
61
|
+
"stroke-width": "1.5",
|
|
62
|
+
"stroke-linecap": "round",
|
|
63
|
+
"stroke-linejoin": "round"
|
|
64
|
+
})], -1))])], 8, _hoisted_5)], 16, _hoisted_4)], 8, _hoisted_1);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
//#endregion
|
|
69
|
+
export { _sfc_main as default };
|