@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,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 };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { Fragment, computed, createElementBlock, createElementVNode, defineComponent, mergeModels, openBlock, renderList, toDisplayString, unref, useModel } from "vue";
|
|
3
|
+
//#region src/components/pagination/Pagination.vue
|
|
4
|
+
const _hoisted_1 = ["aria-label", "data-pagination-disabled"];
|
|
5
|
+
const _hoisted_2 = { "data-part": "pagination-list" };
|
|
6
|
+
const _hoisted_3 = { "data-part": "pagination-item" };
|
|
7
|
+
const _hoisted_4 = ["disabled", "aria-label"];
|
|
8
|
+
const _hoisted_5 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
"data-part": "pagination-item"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_6 = [
|
|
13
|
+
"aria-label",
|
|
14
|
+
"aria-current",
|
|
15
|
+
"data-pagination-current",
|
|
16
|
+
"disabled",
|
|
17
|
+
"onClick"
|
|
18
|
+
];
|
|
19
|
+
const _hoisted_7 = {
|
|
20
|
+
key: 1,
|
|
21
|
+
"data-part": "pagination-item"
|
|
22
|
+
};
|
|
23
|
+
const _hoisted_8 = { "data-part": "pagination-item" };
|
|
24
|
+
const _hoisted_9 = ["disabled", "aria-label"];
|
|
25
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
26
|
+
__name: "Pagination",
|
|
27
|
+
props: /*@__PURE__*/ mergeModels({
|
|
28
|
+
pageCount: {},
|
|
29
|
+
siblingCount: { default: 1 },
|
|
30
|
+
label: {},
|
|
31
|
+
disabled: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
"modelValue": {},
|
|
37
|
+
"modelModifiers": {}
|
|
38
|
+
}),
|
|
39
|
+
emits: ["update:modelValue"],
|
|
40
|
+
setup(__props) {
|
|
41
|
+
/** The current page, 1-based. */
|
|
42
|
+
const page = useModel(__props, "modelValue");
|
|
43
|
+
const translations = useTranslations();
|
|
44
|
+
const total = computed(() => Math.max(1, Math.floor(__props.pageCount)));
|
|
45
|
+
const current = computed(() => Math.min(Math.max(page.value ?? 1, 1), total.value));
|
|
46
|
+
/** Page numbers to show, with `"ellipsis"` standing in for a skipped run. */
|
|
47
|
+
const pages = computed(() => {
|
|
48
|
+
if (total.value <= 2 * __props.siblingCount + 5) return Array.from({ length: total.value }, (_, index) => index + 1);
|
|
49
|
+
const shown = /* @__PURE__ */ new Set([1, total.value]);
|
|
50
|
+
for (let index = current.value - __props.siblingCount; index <= current.value + __props.siblingCount; index++) if (index >= 1 && index <= total.value) shown.add(index);
|
|
51
|
+
const list = [];
|
|
52
|
+
let previous = 0;
|
|
53
|
+
for (const index of [...shown].toSorted((a, b) => a - b)) {
|
|
54
|
+
if (index - previous > 1) list.push("ellipsis");
|
|
55
|
+
list.push(index);
|
|
56
|
+
previous = index;
|
|
57
|
+
}
|
|
58
|
+
return list;
|
|
59
|
+
});
|
|
60
|
+
function goTo(target) {
|
|
61
|
+
page.value = Math.min(Math.max(target, 1), total.value);
|
|
62
|
+
}
|
|
63
|
+
return (_ctx, _cache) => {
|
|
64
|
+
return openBlock(), createElementBlock("nav", {
|
|
65
|
+
"data-part": "pagination",
|
|
66
|
+
"aria-label": __props.label ?? unref(translations).pagination,
|
|
67
|
+
"data-pagination-disabled": __props.disabled || void 0
|
|
68
|
+
}, [createElementVNode("ul", _hoisted_2, [
|
|
69
|
+
createElementVNode("li", _hoisted_3, [createElementVNode("button", {
|
|
70
|
+
type: "button",
|
|
71
|
+
"data-part": "pagination-previous",
|
|
72
|
+
disabled: __props.disabled || current.value <= 1,
|
|
73
|
+
"aria-label": unref(translations).previousPage,
|
|
74
|
+
onClick: _cache[0] || (_cache[0] = ($event) => goTo(current.value - 1))
|
|
75
|
+
}, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
|
|
76
|
+
viewBox: "0 0 16 16",
|
|
77
|
+
width: "14",
|
|
78
|
+
height: "14",
|
|
79
|
+
fill: "none",
|
|
80
|
+
"aria-hidden": "true",
|
|
81
|
+
focusable: "false"
|
|
82
|
+
}, [createElementVNode("path", {
|
|
83
|
+
d: "M10 3 5 8l5 5",
|
|
84
|
+
stroke: "currentColor",
|
|
85
|
+
"stroke-width": "1.5",
|
|
86
|
+
"stroke-linecap": "round",
|
|
87
|
+
"stroke-linejoin": "round"
|
|
88
|
+
})], -1)])], 8, _hoisted_4)]),
|
|
89
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(pages.value, (item, index) => {
|
|
90
|
+
return openBlock(), createElementBlock(Fragment, { key: `${item}-${index}` }, [typeof item === "number" ? (openBlock(), createElementBlock("li", _hoisted_5, [createElementVNode("button", {
|
|
91
|
+
type: "button",
|
|
92
|
+
"data-part": "pagination-page",
|
|
93
|
+
"aria-label": unref(translations).page(item),
|
|
94
|
+
"aria-current": item === current.value ? "page" : void 0,
|
|
95
|
+
"data-pagination-current": item === current.value || void 0,
|
|
96
|
+
disabled: __props.disabled,
|
|
97
|
+
onClick: ($event) => goTo(item)
|
|
98
|
+
}, toDisplayString(item), 9, _hoisted_6)])) : (openBlock(), createElementBlock("li", _hoisted_7, [..._cache[3] || (_cache[3] = [createElementVNode("span", {
|
|
99
|
+
"data-part": "pagination-ellipsis",
|
|
100
|
+
"aria-hidden": "true"
|
|
101
|
+
}, "…", -1)])]))], 64);
|
|
102
|
+
}), 128)),
|
|
103
|
+
createElementVNode("li", _hoisted_8, [createElementVNode("button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
"data-part": "pagination-next",
|
|
106
|
+
disabled: __props.disabled || current.value >= total.value,
|
|
107
|
+
"aria-label": unref(translations).nextPage,
|
|
108
|
+
onClick: _cache[1] || (_cache[1] = ($event) => goTo(current.value + 1))
|
|
109
|
+
}, [..._cache[4] || (_cache[4] = [createElementVNode("svg", {
|
|
110
|
+
viewBox: "0 0 16 16",
|
|
111
|
+
width: "14",
|
|
112
|
+
height: "14",
|
|
113
|
+
fill: "none",
|
|
114
|
+
"aria-hidden": "true",
|
|
115
|
+
focusable: "false"
|
|
116
|
+
}, [createElementVNode("path", {
|
|
117
|
+
d: "M6 3l5 5-5 5",
|
|
118
|
+
stroke: "currentColor",
|
|
119
|
+
"stroke-width": "1.5",
|
|
120
|
+
"stroke-linecap": "round",
|
|
121
|
+
"stroke-linejoin": "round"
|
|
122
|
+
})], -1)])], 8, _hoisted_9)])
|
|
123
|
+
])], 8, _hoisted_1);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
//#endregion
|
|
128
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/components/pagination/Pagination.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Number of pages, at least 1. */
|
|
4
|
+
pageCount: number;
|
|
5
|
+
/** Pages shown either side of the current one. */
|
|
6
|
+
siblingCount?: number;
|
|
7
|
+
/** Accessible name for the navigation landmark, when the `pagination` translation isn't wanted. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Disables every button. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
/** The current page, 1-based. */
|
|
14
|
+
modelValue?: number;
|
|
15
|
+
};
|
|
16
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
17
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
"update:modelValue": (value: number | undefined) => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
20
|
+
"onUpdate:modelValue"?: ((value: number | undefined) => any) | undefined;
|
|
21
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { _default as default };
|