@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,111 @@
|
|
|
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 { createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, renderSlot, toDisplayString, unref, useModel, useSlots, useTemplateRef, vModelDynamic, withDirectives } from "vue";
|
|
5
|
+
//#region src/components/input/Input.vue
|
|
6
|
+
const _hoisted_1 = ["data-field-size", "data-field-error"];
|
|
7
|
+
const _hoisted_2 = ["for"];
|
|
8
|
+
const _hoisted_3 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
"data-part": "field-optional"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_4 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
"data-part": "input-prefix"
|
|
16
|
+
};
|
|
17
|
+
const _hoisted_5 = [
|
|
18
|
+
"id",
|
|
19
|
+
"type",
|
|
20
|
+
"disabled",
|
|
21
|
+
"aria-invalid",
|
|
22
|
+
"aria-describedby"
|
|
23
|
+
];
|
|
24
|
+
const _hoisted_6 = {
|
|
25
|
+
key: 1,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
"data-part": "input-suffix"
|
|
28
|
+
};
|
|
29
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
30
|
+
inheritAttrs: false,
|
|
31
|
+
__name: "Input",
|
|
32
|
+
props: /*@__PURE__*/ mergeModels({
|
|
33
|
+
label: {},
|
|
34
|
+
hint: {},
|
|
35
|
+
error: { type: [String, Boolean] },
|
|
36
|
+
prefix: {},
|
|
37
|
+
suffix: {},
|
|
38
|
+
optional: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
disabled: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
type: { default: "text" },
|
|
47
|
+
size: { default: "medium" },
|
|
48
|
+
id: {}
|
|
49
|
+
}, {
|
|
50
|
+
"modelValue": {},
|
|
51
|
+
"modelModifiers": {}
|
|
52
|
+
}),
|
|
53
|
+
emits: ["update:modelValue"],
|
|
54
|
+
setup(__props, { expose: __expose }) {
|
|
55
|
+
const slots = useSlots();
|
|
56
|
+
/** The value. */
|
|
57
|
+
const model = useModel(__props, "modelValue");
|
|
58
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
59
|
+
error: () => __props.error,
|
|
60
|
+
hint: () => __props.hint,
|
|
61
|
+
id: () => __props.id
|
|
62
|
+
});
|
|
63
|
+
const translations = useTranslations();
|
|
64
|
+
const inputRef = useTemplateRef("input");
|
|
65
|
+
__expose({ focus: () => inputRef.value?.focus() });
|
|
66
|
+
return (_ctx, _cache) => {
|
|
67
|
+
return openBlock(), createElementBlock("div", {
|
|
68
|
+
"data-part": "field",
|
|
69
|
+
"data-field-size": __props.size,
|
|
70
|
+
"data-field-error": unref(isError) || void 0
|
|
71
|
+
}, [
|
|
72
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
73
|
+
key: 0,
|
|
74
|
+
for: unref(id),
|
|
75
|
+
"data-part": "field-label"
|
|
76
|
+
}, [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),
|
|
77
|
+
createElementVNode("div", {
|
|
78
|
+
"data-part": "input-control",
|
|
79
|
+
onClick: _cache[1] || (_cache[1] = ($event) => inputRef.value?.focus())
|
|
80
|
+
}, [
|
|
81
|
+
__props.prefix || slots.prefix ? (openBlock(), createElementBlock("span", _hoisted_4, [renderSlot(_ctx.$slots, "prefix", {}, () => [createTextVNode(toDisplayString(__props.prefix), 1)])])) : createCommentVNode("v-if", true),
|
|
82
|
+
withDirectives(createElementVNode("input", mergeProps({
|
|
83
|
+
id: unref(id),
|
|
84
|
+
ref: "input",
|
|
85
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event)
|
|
86
|
+
}, _ctx.$attrs, {
|
|
87
|
+
type: __props.type,
|
|
88
|
+
disabled: __props.disabled,
|
|
89
|
+
"aria-invalid": unref(isError) || void 0,
|
|
90
|
+
"aria-describedby": unref(describedBy),
|
|
91
|
+
"data-part": "input"
|
|
92
|
+
}), null, 16, _hoisted_5), [[vModelDynamic, model.value]]),
|
|
93
|
+
__props.suffix || slots.suffix ? (openBlock(), createElementBlock("span", _hoisted_6, [renderSlot(_ctx.$slots, "suffix", {}, () => [createTextVNode(toDisplayString(__props.suffix), 1)])])) : createCommentVNode("v-if", true)
|
|
94
|
+
]),
|
|
95
|
+
createVNode(_sfc_main$1, {
|
|
96
|
+
"error-id": unref(errorId),
|
|
97
|
+
"hint-id": unref(hintId),
|
|
98
|
+
"error-message": unref(errorMessage),
|
|
99
|
+
hint: __props.hint
|
|
100
|
+
}, null, 8, [
|
|
101
|
+
"error-id",
|
|
102
|
+
"hint-id",
|
|
103
|
+
"error-message",
|
|
104
|
+
"hint"
|
|
105
|
+
])
|
|
106
|
+
], 8, _hoisted_1);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/components/input/Input.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Visible label, linked to the control. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Help text under the control, announced as its description. */
|
|
6
|
+
hint?: string;
|
|
7
|
+
/** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
|
|
8
|
+
error?: string | boolean;
|
|
9
|
+
/** Text shown before the input, e.g. a currency sign. Hidden from assistive tech. */
|
|
10
|
+
prefix?: string;
|
|
11
|
+
/** Text shown after the input, e.g. a unit. Hidden from assistive tech. */
|
|
12
|
+
suffix?: string;
|
|
13
|
+
/** Appends the `optional` translation to the label. */
|
|
14
|
+
optional?: boolean;
|
|
15
|
+
/** Disables the control. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Native input type. */
|
|
18
|
+
type?: "text" | "email" | "search" | "url" | "tel" | "password" | "number" | "date" | "time" | "datetime-local" | "month" | "week";
|
|
19
|
+
/** Size hook, exposed as `data-field-size`. */
|
|
20
|
+
size?: "small" | "medium";
|
|
21
|
+
/** Id for the control; generated with `useId()` when omitted. */
|
|
22
|
+
id?: string;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_Slots = {
|
|
25
|
+
/** Replaces the `prefix` text, e.g. with an icon. */
|
|
26
|
+
prefix?(): unknown;
|
|
27
|
+
/** Replaces the `suffix` text. */
|
|
28
|
+
suffix?(): unknown;
|
|
29
|
+
};
|
|
30
|
+
type __VLS_ModelProps = {
|
|
31
|
+
/** The value. */
|
|
32
|
+
modelValue?: string | number;
|
|
33
|
+
};
|
|
34
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
35
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
36
|
+
focus: () => void | undefined;
|
|
37
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
38
|
+
"update:modelValue": (value: string | number | undefined) => any;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
40
|
+
"onUpdate:modelValue"?: ((value: string | number | undefined) => any) | undefined;
|
|
41
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
42
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
43
|
+
declare const _default: typeof __VLS_export;
|
|
44
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
45
|
+
new (): {
|
|
46
|
+
$slots: S;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { _default as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { parseChord, usePlatform } from "../../composables/use-platform.js";
|
|
3
|
+
import { Fragment, computed, createElementBlock, createElementVNode, defineComponent, openBlock, renderList, renderSlot, toDisplayString } from "vue";
|
|
4
|
+
//#region src/components/kbd/Kbd.vue
|
|
5
|
+
const _hoisted_1 = ["data-kbd-size"];
|
|
6
|
+
const _hoisted_2 = {
|
|
7
|
+
key: 1,
|
|
8
|
+
"data-part": "key"
|
|
9
|
+
};
|
|
10
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
11
|
+
__name: "Kbd",
|
|
12
|
+
props: {
|
|
13
|
+
keys: {},
|
|
14
|
+
size: { default: "medium" },
|
|
15
|
+
platform: {}
|
|
16
|
+
},
|
|
17
|
+
setup(__props) {
|
|
18
|
+
const detected = usePlatform();
|
|
19
|
+
const translations = useTranslations();
|
|
20
|
+
const keyCaps = computed(() => __props.keys ? parseChord(__props.keys, __props.platform ?? detected.value, translations.value.keys) : []);
|
|
21
|
+
const label = computed(() => keyCaps.value.map((cap) => cap.label).join(" "));
|
|
22
|
+
const visuallyHidden = {
|
|
23
|
+
position: "absolute",
|
|
24
|
+
width: "1px",
|
|
25
|
+
height: "1px",
|
|
26
|
+
overflow: "hidden",
|
|
27
|
+
clipPath: "inset(50%)",
|
|
28
|
+
whiteSpace: "nowrap"
|
|
29
|
+
};
|
|
30
|
+
return (_ctx, _cache) => {
|
|
31
|
+
return openBlock(), createElementBlock("kbd", {
|
|
32
|
+
"data-part": "kbd",
|
|
33
|
+
"data-kbd-size": __props.size
|
|
34
|
+
}, [keyCaps.value.length ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [(openBlock(true), createElementBlock(Fragment, null, renderList(keyCaps.value, (cap, i) => {
|
|
35
|
+
return openBlock(), createElementBlock("kbd", {
|
|
36
|
+
key: `${cap.glyph}-${i}`,
|
|
37
|
+
"data-part": "key",
|
|
38
|
+
"aria-hidden": "true"
|
|
39
|
+
}, toDisplayString(cap.glyph), 1);
|
|
40
|
+
}), 128)), createElementVNode("span", {
|
|
41
|
+
"data-part": "kbd-label",
|
|
42
|
+
style: visuallyHidden
|
|
43
|
+
}, toDisplayString(label.value), 1)], 64)) : (openBlock(), createElementBlock("kbd", _hoisted_2, [renderSlot(_ctx.$slots, "default")]))], 8, _hoisted_1);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//#endregion
|
|
48
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Platform } from "../../types.js";
|
|
2
|
+
//#region src/components/kbd/Kbd.vue.d.ts
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** Chord written as "mod+k" or "shift enter". `mod` is ⌘ on Apple, Ctrl elsewhere. */
|
|
5
|
+
keys?: string;
|
|
6
|
+
/** Size hook, exposed as `data-kbd-size`. */
|
|
7
|
+
size?: "small" | "medium";
|
|
8
|
+
/** Forces a platform's key caps instead of the detected one. */
|
|
9
|
+
platform?: Platform;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
/** A single literal key, when `keys` isn't set. */
|
|
13
|
+
default?(): unknown;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
19
|
+
new (): {
|
|
20
|
+
$slots: S;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { _default as default };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { useAnchor } from "../../composables/use-popover.js";
|
|
3
|
+
import { isMenuSeparator, useMenu } from "../../composables/use-menu.js";
|
|
4
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, mergeProps, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
|
|
5
|
+
//#region src/components/menu/Menu.vue
|
|
6
|
+
const _hoisted_1 = ["data-menu-open"];
|
|
7
|
+
const _hoisted_2 = [
|
|
8
|
+
"id",
|
|
9
|
+
"data-menu-align",
|
|
10
|
+
"aria-labelledby"
|
|
11
|
+
];
|
|
12
|
+
const _hoisted_3 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
role: "separator",
|
|
15
|
+
"data-part": "menu-separator"
|
|
16
|
+
};
|
|
17
|
+
const _hoisted_4 = [
|
|
18
|
+
"data-menu-index",
|
|
19
|
+
"disabled",
|
|
20
|
+
"data-menu-active",
|
|
21
|
+
"onClick",
|
|
22
|
+
"onPointermove"
|
|
23
|
+
];
|
|
24
|
+
const _hoisted_5 = { "data-part": "menu-item-label" };
|
|
25
|
+
const _hoisted_6 = {
|
|
26
|
+
key: 0,
|
|
27
|
+
"data-part": "menu-item-hint",
|
|
28
|
+
"aria-hidden": "true"
|
|
29
|
+
};
|
|
30
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
31
|
+
__name: "Menu",
|
|
32
|
+
props: /*@__PURE__*/ mergeModels({
|
|
33
|
+
items: { default: () => [] },
|
|
34
|
+
label: {},
|
|
35
|
+
align: { default: "start" }
|
|
36
|
+
}, {
|
|
37
|
+
"open": {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
"openModifiers": {}
|
|
42
|
+
}),
|
|
43
|
+
emits: /*@__PURE__*/ mergeModels(["select"], ["update:open"]),
|
|
44
|
+
setup(__props, { emit: __emit }) {
|
|
45
|
+
const emit = __emit;
|
|
46
|
+
/** Whether the menu is open. */
|
|
47
|
+
const open = useModel(__props, "open");
|
|
48
|
+
const triggerId = useId();
|
|
49
|
+
const menuId = useId();
|
|
50
|
+
const rootRef = useTemplateRef("root");
|
|
51
|
+
const panelRef = useTemplateRef("panel");
|
|
52
|
+
const { anchorStyle, panelStyle } = useAnchor();
|
|
53
|
+
const translations = useTranslations();
|
|
54
|
+
const trigger = () => rootRef.value?.querySelector(`#${CSS.escape(triggerId)}`);
|
|
55
|
+
const { activeIndex, setActive, activate, onTriggerKeydown, onMenuKeydown } = useMenu({
|
|
56
|
+
trigger,
|
|
57
|
+
panel: panelRef,
|
|
58
|
+
open,
|
|
59
|
+
itemCount: () => __props.items.length,
|
|
60
|
+
isDisabled: (i) => {
|
|
61
|
+
const item = __props.items[i];
|
|
62
|
+
return isMenuSeparator(item) || Boolean(item?.disabled);
|
|
63
|
+
},
|
|
64
|
+
labelAt: (i) => {
|
|
65
|
+
const item = __props.items[i];
|
|
66
|
+
return isMenuSeparator(item) ? void 0 : item?.label;
|
|
67
|
+
},
|
|
68
|
+
onActivate: (i) => {
|
|
69
|
+
const item = __props.items[i];
|
|
70
|
+
if (item && !isMenuSeparator(item)) emit("select", item.value);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const triggerAttrs = computed(() => ({
|
|
74
|
+
id: triggerId,
|
|
75
|
+
popovertarget: menuId,
|
|
76
|
+
"aria-haspopup": "menu",
|
|
77
|
+
"aria-controls": menuId,
|
|
78
|
+
"aria-expanded": open.value,
|
|
79
|
+
onKeydown: onTriggerKeydown
|
|
80
|
+
}));
|
|
81
|
+
return (_ctx, _cache) => {
|
|
82
|
+
return openBlock(), createElementBlock("div", {
|
|
83
|
+
ref: "root",
|
|
84
|
+
"data-part": "menu",
|
|
85
|
+
style: normalizeStyle(unref(anchorStyle))
|
|
86
|
+
}, [renderSlot(_ctx.$slots, "trigger", {
|
|
87
|
+
isOpen: open.value,
|
|
88
|
+
attrs: triggerAttrs.value
|
|
89
|
+
}, () => [createElementVNode("button", mergeProps(triggerAttrs.value, {
|
|
90
|
+
type: "button",
|
|
91
|
+
"data-part": "menu-trigger",
|
|
92
|
+
"data-menu-open": open.value || void 0
|
|
93
|
+
}), toDisplayString(__props.label ?? unref(translations).menu), 17, _hoisted_1)]), createElementVNode("div", {
|
|
94
|
+
id: unref(menuId),
|
|
95
|
+
ref: "panel",
|
|
96
|
+
role: "menu",
|
|
97
|
+
popover: "auto",
|
|
98
|
+
"data-part": "menu-list",
|
|
99
|
+
"data-menu-align": __props.align,
|
|
100
|
+
"aria-labelledby": unref(triggerId),
|
|
101
|
+
style: normalizeStyle(unref(panelStyle)),
|
|
102
|
+
onKeydown: _cache[0] || (_cache[0] = (...args) => unref(onMenuKeydown) && unref(onMenuKeydown)(...args))
|
|
103
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
|
|
104
|
+
return openBlock(), createElementBlock(Fragment, { key: unref(isMenuSeparator)(item) ? `separator-${i}` : item.value }, [unref(isMenuSeparator)(item) ? (openBlock(), createElementBlock("div", _hoisted_3)) : (openBlock(), createElementBlock("button", {
|
|
105
|
+
key: 1,
|
|
106
|
+
type: "button",
|
|
107
|
+
role: "menuitem",
|
|
108
|
+
"data-part": "menu-item",
|
|
109
|
+
tabindex: "-1",
|
|
110
|
+
"data-menu-index": i,
|
|
111
|
+
disabled: item.disabled,
|
|
112
|
+
"data-menu-active": i === unref(activeIndex) || void 0,
|
|
113
|
+
onClick: ($event) => unref(activate)(i),
|
|
114
|
+
onPointermove: ($event) => !item.disabled && i !== unref(activeIndex) && unref(setActive)(i)
|
|
115
|
+
}, [renderSlot(_ctx.$slots, "item", {
|
|
116
|
+
item,
|
|
117
|
+
active: i === unref(activeIndex)
|
|
118
|
+
}, () => [createElementVNode("span", _hoisted_5, toDisplayString(item.label), 1), item.hint ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(item.hint), 1)) : createCommentVNode("v-if", true)])], 40, _hoisted_4))], 64);
|
|
119
|
+
}), 128))], 44, _hoisted_2)], 4);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
//#endregion
|
|
124
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MenuEntry, MenuItem } from "../../types.js";
|
|
2
|
+
//#region src/components/menu/Menu.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
|
+
/** Menu items in order; `{ separator: true }` draws a line between groups. */
|
|
6
|
+
items?: MenuEntry<T>[];
|
|
7
|
+
/** Trigger text for the default trigger, and the menu's accessible name. Defaults to the `menu` translation. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Which trigger edge the menu lines up with. Flips automatically near the viewport edge. */
|
|
10
|
+
align?: "start" | "end";
|
|
11
|
+
} & {
|
|
12
|
+
/** Whether the menu is open. */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
}) & {
|
|
15
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
16
|
+
onSelect?: ((value: T) => any) | undefined;
|
|
17
|
+
}> & (typeof globalThis extends {
|
|
18
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
19
|
+
} ? P : {});
|
|
20
|
+
expose: (exposed: {}) => void;
|
|
21
|
+
attrs: any;
|
|
22
|
+
slots: {
|
|
23
|
+
/** Custom trigger. Bind `attrs` to a `<button>`. */
|
|
24
|
+
trigger?(props: {
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
attrs: Record<string, unknown>;
|
|
27
|
+
}): unknown;
|
|
28
|
+
/** Item content. */
|
|
29
|
+
item?(props: {
|
|
30
|
+
item: MenuItem<T>;
|
|
31
|
+
active: boolean;
|
|
32
|
+
}): unknown;
|
|
33
|
+
};
|
|
34
|
+
emit: ((evt: "select", value: T) => void) & ((event: "update:open", value: boolean) => 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,179 @@
|
|
|
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 { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef } from "vue";
|
|
5
|
+
//#region src/components/otp-input/OtpInput.vue
|
|
6
|
+
const _hoisted_1 = ["data-field-error"];
|
|
7
|
+
const _hoisted_2 = ["for"];
|
|
8
|
+
const _hoisted_3 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
"data-part": "field-optional"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_4 = ["data-otp-focused", "data-otp-disabled"];
|
|
13
|
+
const _hoisted_5 = [
|
|
14
|
+
"id",
|
|
15
|
+
"inputmode",
|
|
16
|
+
"maxlength",
|
|
17
|
+
"pattern",
|
|
18
|
+
"value",
|
|
19
|
+
"disabled",
|
|
20
|
+
"aria-invalid",
|
|
21
|
+
"aria-describedby"
|
|
22
|
+
];
|
|
23
|
+
const _hoisted_6 = ["data-otp-active", "data-otp-filled"];
|
|
24
|
+
const _hoisted_7 = {
|
|
25
|
+
key: 0,
|
|
26
|
+
"data-part": "otp-caret"
|
|
27
|
+
};
|
|
28
|
+
const _hoisted_8 = {
|
|
29
|
+
key: 0,
|
|
30
|
+
"aria-hidden": "true",
|
|
31
|
+
"data-part": "otp-separator"
|
|
32
|
+
};
|
|
33
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
34
|
+
inheritAttrs: false,
|
|
35
|
+
__name: "OtpInput",
|
|
36
|
+
props: /*@__PURE__*/ mergeModels({
|
|
37
|
+
label: {},
|
|
38
|
+
hint: {},
|
|
39
|
+
error: { type: [String, Boolean] },
|
|
40
|
+
length: { default: 6 },
|
|
41
|
+
type: { default: "numeric" },
|
|
42
|
+
groupSize: {},
|
|
43
|
+
optional: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false
|
|
46
|
+
},
|
|
47
|
+
disabled: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
id: {}
|
|
52
|
+
}, {
|
|
53
|
+
"modelValue": { default: "" },
|
|
54
|
+
"modelModifiers": {}
|
|
55
|
+
}),
|
|
56
|
+
emits: /*@__PURE__*/ mergeModels(["complete"], ["update:modelValue"]),
|
|
57
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
58
|
+
const emit = __emit;
|
|
59
|
+
/** The code typed so far. */
|
|
60
|
+
const model = useModel(__props, "modelValue");
|
|
61
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
62
|
+
error: () => __props.error,
|
|
63
|
+
hint: () => __props.hint,
|
|
64
|
+
id: () => __props.id
|
|
65
|
+
});
|
|
66
|
+
const translations = useTranslations();
|
|
67
|
+
const inputRef = useTemplateRef("input");
|
|
68
|
+
const invalid = computed(() => __props.type === "numeric" ? /\D/g : /[^\da-z]/gi);
|
|
69
|
+
const pattern = computed(() => `${__props.type === "numeric" ? "\\d" : "[\\da-zA-Z]"}{${__props.length}}`);
|
|
70
|
+
const chars = computed(() => model.value.slice(0, __props.length));
|
|
71
|
+
const focused = ref(false);
|
|
72
|
+
const activeIndex = computed(() => focused.value ? Math.min(chars.value.length, __props.length - 1) : -1);
|
|
73
|
+
function pinCaret() {
|
|
74
|
+
const input = inputRef.value;
|
|
75
|
+
if (!input) return;
|
|
76
|
+
const end = input.value.length;
|
|
77
|
+
if (!(end > 0 && input.selectionStart === 0 && input.selectionEnd === end)) input.setSelectionRange(end, end);
|
|
78
|
+
}
|
|
79
|
+
function onInput(event) {
|
|
80
|
+
if (!(event.target instanceof HTMLInputElement)) return;
|
|
81
|
+
const input = event.target;
|
|
82
|
+
const code = input.value.replace(invalid.value, "").slice(0, __props.length);
|
|
83
|
+
if (input.value !== code) input.value = code;
|
|
84
|
+
const changed = code !== model.value;
|
|
85
|
+
model.value = code;
|
|
86
|
+
if (changed && code.length === __props.length) emit("complete", code);
|
|
87
|
+
}
|
|
88
|
+
function onPaste(event) {
|
|
89
|
+
const text = event.clipboardData?.getData("text");
|
|
90
|
+
if (!(event.target instanceof HTMLInputElement) || text == null) return;
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
const input = event.target;
|
|
93
|
+
const pasted = text.replace(invalid.value, "");
|
|
94
|
+
const { value, selectionStart: start, selectionEnd: end } = input;
|
|
95
|
+
input.value = pasted.length >= __props.length ? pasted : value.slice(0, start ?? value.length) + pasted + value.slice(end ?? value.length);
|
|
96
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
97
|
+
pinCaret();
|
|
98
|
+
}
|
|
99
|
+
function onFocus() {
|
|
100
|
+
focused.value = true;
|
|
101
|
+
requestAnimationFrame(pinCaret);
|
|
102
|
+
}
|
|
103
|
+
const CARET_KEYS = /* @__PURE__ */ new Set([
|
|
104
|
+
"ArrowLeft",
|
|
105
|
+
"ArrowRight",
|
|
106
|
+
"ArrowUp",
|
|
107
|
+
"ArrowDown",
|
|
108
|
+
"Home",
|
|
109
|
+
"End"
|
|
110
|
+
]);
|
|
111
|
+
function onKeydown(event) {
|
|
112
|
+
if (CARET_KEYS.has(event.key) && !event.shiftKey) event.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
function hasSeparatorAfter(index) {
|
|
115
|
+
return !!__props.groupSize && index < __props.length - 1 && (index + 1) % __props.groupSize === 0;
|
|
116
|
+
}
|
|
117
|
+
__expose({ focus: () => inputRef.value?.focus() });
|
|
118
|
+
return (_ctx, _cache) => {
|
|
119
|
+
return openBlock(), createElementBlock("div", {
|
|
120
|
+
"data-part": "field",
|
|
121
|
+
"data-field-error": unref(isError) || void 0
|
|
122
|
+
}, [
|
|
123
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
124
|
+
key: 0,
|
|
125
|
+
for: unref(id),
|
|
126
|
+
"data-part": "field-label"
|
|
127
|
+
}, [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),
|
|
128
|
+
createElementVNode("div", {
|
|
129
|
+
"data-part": "otp",
|
|
130
|
+
"data-otp-focused": focused.value || void 0,
|
|
131
|
+
"data-otp-disabled": __props.disabled || void 0
|
|
132
|
+
}, [createElementVNode("input", mergeProps({
|
|
133
|
+
id: unref(id),
|
|
134
|
+
ref: "input",
|
|
135
|
+
type: "text",
|
|
136
|
+
autocomplete: "one-time-code",
|
|
137
|
+
autocapitalize: "none",
|
|
138
|
+
autocorrect: "off",
|
|
139
|
+
spellcheck: "false",
|
|
140
|
+
inputmode: __props.type === "numeric" ? "numeric" : "text",
|
|
141
|
+
maxlength: __props.length,
|
|
142
|
+
pattern: pattern.value
|
|
143
|
+
}, _ctx.$attrs, {
|
|
144
|
+
value: model.value,
|
|
145
|
+
disabled: __props.disabled,
|
|
146
|
+
"aria-invalid": unref(isError) || void 0,
|
|
147
|
+
"aria-describedby": unref(describedBy),
|
|
148
|
+
"data-part": "otp-input",
|
|
149
|
+
onInput,
|
|
150
|
+
onPaste,
|
|
151
|
+
onFocus,
|
|
152
|
+
onBlur: _cache[0] || (_cache[0] = ($event) => focused.value = false),
|
|
153
|
+
onClick: pinCaret,
|
|
154
|
+
onKeydown
|
|
155
|
+
}), null, 16, _hoisted_5), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.length, (_, index) => {
|
|
156
|
+
return openBlock(), createElementBlock(Fragment, { key: index }, [createElementVNode("span", {
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
"data-part": "otp-slot",
|
|
159
|
+
"data-otp-active": index === activeIndex.value || void 0,
|
|
160
|
+
"data-otp-filled": chars.value[index] !== void 0 || void 0
|
|
161
|
+
}, [createTextVNode(toDisplayString(chars.value[index]), 1), index === activeIndex.value && chars.value[index] === void 0 ? (openBlock(), createElementBlock("span", _hoisted_7)) : createCommentVNode("v-if", true)], 8, _hoisted_6), hasSeparatorAfter(index) ? (openBlock(), createElementBlock("span", _hoisted_8, [renderSlot(_ctx.$slots, "separator", {}, () => [_cache[1] || (_cache[1] = createTextVNode("–", -1))])])) : createCommentVNode("v-if", true)], 64);
|
|
162
|
+
}), 128))], 8, _hoisted_4),
|
|
163
|
+
createVNode(_sfc_main$1, {
|
|
164
|
+
"error-id": unref(errorId),
|
|
165
|
+
"hint-id": unref(hintId),
|
|
166
|
+
"error-message": unref(errorMessage),
|
|
167
|
+
hint: __props.hint
|
|
168
|
+
}, null, 8, [
|
|
169
|
+
"error-id",
|
|
170
|
+
"hint-id",
|
|
171
|
+
"error-message",
|
|
172
|
+
"hint"
|
|
173
|
+
])
|
|
174
|
+
], 8, _hoisted_1);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
//#endregion
|
|
179
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/components/otp-input/OtpInput.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Visible label, linked to the control. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Help text under the control, announced as its description. */
|
|
6
|
+
hint?: string;
|
|
7
|
+
/** `true` marks the control invalid; a string also shows it as the message, replacing the hint. */
|
|
8
|
+
error?: string | boolean;
|
|
9
|
+
/** Number of characters in the code. */
|
|
10
|
+
length?: number;
|
|
11
|
+
/** `"numeric"` takes digits and shows the number pad; `"alphanumeric"` takes letters too. */
|
|
12
|
+
type?: "numeric" | "alphanumeric";
|
|
13
|
+
/** Puts a separator after every this many slots, e.g. `3` for `123–456`. */
|
|
14
|
+
groupSize?: number;
|
|
15
|
+
/** Appends the `optional` translation to the label. */
|
|
16
|
+
optional?: boolean;
|
|
17
|
+
/** Disables the control. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Id for the control; generated with `useId()` when omitted. */
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
type __VLS_Slots = {
|
|
23
|
+
/** Content between groups. Defaults to a dash. */
|
|
24
|
+
separator?(): unknown;
|
|
25
|
+
};
|
|
26
|
+
type __VLS_ModelProps = {
|
|
27
|
+
/** The code typed so far. */
|
|
28
|
+
modelValue?: string;
|
|
29
|
+
};
|
|
30
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
31
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
32
|
+
focus: () => void | undefined;
|
|
33
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
34
|
+
"update:modelValue": (value: string) => any;
|
|
35
|
+
complete: (code: string) => any;
|
|
36
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
37
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
38
|
+
onComplete?: ((code: string) => 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 };
|