@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,170 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { onClickOutside } from "../../composables/internal/on-click-outside.js";
|
|
3
|
+
import { useAnchor } from "../../composables/use-popover.js";
|
|
4
|
+
import { useTimeoutFn } from "../../composables/internal/use-timeout-fn.js";
|
|
5
|
+
import { isMenuSeparator, useMenu } from "../../composables/use-menu.js";
|
|
6
|
+
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, normalizeStyle, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
|
|
7
|
+
//#region src/components/context-menu/ContextMenu.vue
|
|
8
|
+
const _hoisted_1 = ["data-context-menu-open"];
|
|
9
|
+
const _hoisted_2 = ["id", "aria-label"];
|
|
10
|
+
const _hoisted_3 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
role: "separator",
|
|
13
|
+
"data-part": "menu-separator"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_4 = [
|
|
16
|
+
"data-menu-index",
|
|
17
|
+
"disabled",
|
|
18
|
+
"data-menu-active",
|
|
19
|
+
"onClick",
|
|
20
|
+
"onPointermove"
|
|
21
|
+
];
|
|
22
|
+
const _hoisted_5 = { "data-part": "menu-item-label" };
|
|
23
|
+
const _hoisted_6 = {
|
|
24
|
+
key: 0,
|
|
25
|
+
"data-part": "menu-item-hint",
|
|
26
|
+
"aria-hidden": "true"
|
|
27
|
+
};
|
|
28
|
+
const LONG_PRESS = 500;
|
|
29
|
+
const SLOP = 10;
|
|
30
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
31
|
+
__name: "ContextMenu",
|
|
32
|
+
props: /*@__PURE__*/ mergeModels({
|
|
33
|
+
items: { default: () => [] },
|
|
34
|
+
label: {},
|
|
35
|
+
disabled: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
"open": {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
"openModifiers": {}
|
|
45
|
+
}),
|
|
46
|
+
emits: /*@__PURE__*/ mergeModels(["select"], ["update:open"]),
|
|
47
|
+
setup(__props, { emit: __emit }) {
|
|
48
|
+
const emit = __emit;
|
|
49
|
+
/** Whether the menu is open. */
|
|
50
|
+
const open = useModel(__props, "open");
|
|
51
|
+
const menuId = useId();
|
|
52
|
+
const translations = useTranslations();
|
|
53
|
+
const panelRef = useTemplateRef("panel");
|
|
54
|
+
const { anchorStyle, panelStyle } = useAnchor();
|
|
55
|
+
const point = ref({
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
});
|
|
59
|
+
let returnFocus = null;
|
|
60
|
+
const { activeIndex, setActive, activate, close, onMenuKeydown } = useMenu({
|
|
61
|
+
trigger: () => returnFocus,
|
|
62
|
+
panel: panelRef,
|
|
63
|
+
open,
|
|
64
|
+
itemCount: () => __props.items.length,
|
|
65
|
+
isDisabled: (i) => {
|
|
66
|
+
const item = __props.items[i];
|
|
67
|
+
return isMenuSeparator(item) || Boolean(item?.disabled);
|
|
68
|
+
},
|
|
69
|
+
labelAt: (i) => {
|
|
70
|
+
const item = __props.items[i];
|
|
71
|
+
return isMenuSeparator(item) ? void 0 : item?.label;
|
|
72
|
+
},
|
|
73
|
+
onActivate: (i) => {
|
|
74
|
+
const item = __props.items[i];
|
|
75
|
+
if (item && !isMenuSeparator(item)) emit("select", item.value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
onClickOutside(panelRef, () => close(false), { active: () => open.value });
|
|
79
|
+
function openAt(x, y) {
|
|
80
|
+
if (__props.disabled || !__props.items.length) return;
|
|
81
|
+
const active = document.activeElement;
|
|
82
|
+
returnFocus = active instanceof HTMLElement && active !== document.body ? active : null;
|
|
83
|
+
point.value = {
|
|
84
|
+
x,
|
|
85
|
+
y
|
|
86
|
+
};
|
|
87
|
+
open.value = true;
|
|
88
|
+
}
|
|
89
|
+
function onContextmenu(event) {
|
|
90
|
+
if (__props.disabled) return;
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
if (event.clientX === 0 && event.clientY === 0 && event.target instanceof Element) {
|
|
93
|
+
const rect = event.target.getBoundingClientRect();
|
|
94
|
+
openAt(rect.left, rect.bottom);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
openAt(event.clientX, event.clientY);
|
|
98
|
+
}
|
|
99
|
+
let pressStart = null;
|
|
100
|
+
const press = useTimeoutFn(() => {
|
|
101
|
+
if (pressStart) openAt(pressStart.x, pressStart.y);
|
|
102
|
+
pressStart = null;
|
|
103
|
+
}, LONG_PRESS);
|
|
104
|
+
function onPointerdown(event) {
|
|
105
|
+
if (event.pointerType !== "touch" || __props.disabled) return;
|
|
106
|
+
pressStart = {
|
|
107
|
+
x: event.clientX,
|
|
108
|
+
y: event.clientY
|
|
109
|
+
};
|
|
110
|
+
press.start();
|
|
111
|
+
}
|
|
112
|
+
function onPointermove(event) {
|
|
113
|
+
if (!pressStart) return;
|
|
114
|
+
if (Math.hypot(event.clientX - pressStart.x, event.clientY - pressStart.y) > SLOP) cancelPress();
|
|
115
|
+
}
|
|
116
|
+
function cancelPress() {
|
|
117
|
+
pressStart = null;
|
|
118
|
+
press.stop();
|
|
119
|
+
}
|
|
120
|
+
return (_ctx, _cache) => {
|
|
121
|
+
return openBlock(), createElementBlock("div", {
|
|
122
|
+
"data-part": "context-menu",
|
|
123
|
+
"data-context-menu-open": open.value || void 0,
|
|
124
|
+
onContextmenu,
|
|
125
|
+
onPointerdown,
|
|
126
|
+
onPointermove,
|
|
127
|
+
onPointerup: cancelPress,
|
|
128
|
+
onPointercancel: cancelPress
|
|
129
|
+
}, [
|
|
130
|
+
renderSlot(_ctx.$slots, "default"),
|
|
131
|
+
createElementVNode("span", {
|
|
132
|
+
"data-part": "context-menu-anchor",
|
|
133
|
+
"aria-hidden": "true",
|
|
134
|
+
style: normalizeStyle([unref(anchorStyle), {
|
|
135
|
+
left: `${point.value.x}px`,
|
|
136
|
+
top: `${point.value.y}px`
|
|
137
|
+
}])
|
|
138
|
+
}, null, 4),
|
|
139
|
+
createElementVNode("div", {
|
|
140
|
+
id: unref(menuId),
|
|
141
|
+
ref: "panel",
|
|
142
|
+
role: "menu",
|
|
143
|
+
popover: "manual",
|
|
144
|
+
"data-part": "menu-list",
|
|
145
|
+
"aria-label": __props.label ?? unref(translations).contextMenu,
|
|
146
|
+
style: normalizeStyle(unref(panelStyle)),
|
|
147
|
+
onKeydown: _cache[0] || (_cache[0] = (...args) => unref(onMenuKeydown) && unref(onMenuKeydown)(...args))
|
|
148
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
|
|
149
|
+
return openBlock(), createElementBlock(Fragment, { key: unref(isMenuSeparator)(item) ? `separator-${i}` : item.value }, [unref(isMenuSeparator)(item) ? (openBlock(), createElementBlock("div", _hoisted_3)) : (openBlock(), createElementBlock("button", {
|
|
150
|
+
key: 1,
|
|
151
|
+
type: "button",
|
|
152
|
+
role: "menuitem",
|
|
153
|
+
"data-part": "menu-item",
|
|
154
|
+
tabindex: "-1",
|
|
155
|
+
"data-menu-index": i,
|
|
156
|
+
disabled: item.disabled,
|
|
157
|
+
"data-menu-active": i === unref(activeIndex) || void 0,
|
|
158
|
+
onClick: ($event) => unref(activate)(i),
|
|
159
|
+
onPointermove: ($event) => !item.disabled && i !== unref(activeIndex) && unref(setActive)(i)
|
|
160
|
+
}, [renderSlot(_ctx.$slots, "item", {
|
|
161
|
+
item,
|
|
162
|
+
active: i === unref(activeIndex)
|
|
163
|
+
}, () => [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);
|
|
164
|
+
}), 128))], 44, _hoisted_2)
|
|
165
|
+
], 40, _hoisted_1);
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
//#endregion
|
|
170
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MenuEntry, MenuItem } from "../../types.js";
|
|
2
|
+
//#region src/components/context-menu/ContextMenu.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
|
+
/** Accessible name for the menu. Defaults to the `contextMenu` translation. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Leaves the browser's own context menu in place. */
|
|
10
|
+
disabled?: boolean;
|
|
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
|
+
/** The area that opens the menu on right-click, long-press, or Shift+F10. */
|
|
24
|
+
default?(): unknown;
|
|
25
|
+
/** Item content. */
|
|
26
|
+
item?(props: {
|
|
27
|
+
item: MenuItem<T>;
|
|
28
|
+
active: boolean;
|
|
29
|
+
}): unknown;
|
|
30
|
+
};
|
|
31
|
+
emit: ((evt: "select", value: T) => void) & ((event: "update:open", value: boolean) => void);
|
|
32
|
+
}>) => import("vue").VNode & {
|
|
33
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
34
|
+
};
|
|
35
|
+
declare const _default: typeof __VLS_export;
|
|
36
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { _default as default };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import _sfc_main$1 from "../button/Button.js";
|
|
3
|
+
import _sfc_main$2 from "./Dialog.js";
|
|
4
|
+
import { createBlock, createSlots, createTextVNode, createVNode, defineComponent, mergeModels, openBlock, renderSlot, toDisplayString, unref, useModel, useSlots, watch, withCtx } from "vue";
|
|
5
|
+
//#region src/components/dialog/ConfirmDialog.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: "ConfirmDialog",
|
|
8
|
+
props: /*@__PURE__*/ mergeModels({
|
|
9
|
+
title: {},
|
|
10
|
+
description: {},
|
|
11
|
+
confirmText: {},
|
|
12
|
+
cancelText: {},
|
|
13
|
+
danger: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false
|
|
16
|
+
},
|
|
17
|
+
loading: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
keepOpen: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
"open": {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
},
|
|
30
|
+
"openModifiers": {}
|
|
31
|
+
}),
|
|
32
|
+
emits: /*@__PURE__*/ mergeModels(["confirm", "cancel"], ["update:open"]),
|
|
33
|
+
setup(__props, { emit: __emit }) {
|
|
34
|
+
const slots = useSlots();
|
|
35
|
+
/** Whether the dialog is open. */
|
|
36
|
+
const open = useModel(__props, "open");
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const translations = useTranslations();
|
|
39
|
+
let decided = false;
|
|
40
|
+
function decide(outcome) {
|
|
41
|
+
if (__props.loading) return;
|
|
42
|
+
decided = true;
|
|
43
|
+
if (outcome === "cancel") emit("cancel");
|
|
44
|
+
else emit("confirm");
|
|
45
|
+
if (outcome === "cancel" || !__props.keepOpen) open.value = false;
|
|
46
|
+
}
|
|
47
|
+
watch(() => __props.loading, (isLoading, wasLoading) => {
|
|
48
|
+
if (wasLoading && !isLoading && open.value) decided = false;
|
|
49
|
+
});
|
|
50
|
+
function onClose() {
|
|
51
|
+
if (!decided) emit("cancel");
|
|
52
|
+
decided = false;
|
|
53
|
+
}
|
|
54
|
+
return (_ctx, _cache) => {
|
|
55
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
56
|
+
open: open.value,
|
|
57
|
+
"onUpdate:open": _cache[2] || (_cache[2] = ($event) => open.value = $event),
|
|
58
|
+
role: "alertdialog",
|
|
59
|
+
title: __props.title,
|
|
60
|
+
description: __props.description,
|
|
61
|
+
"close-on-backdrop": false,
|
|
62
|
+
"show-close-button": false,
|
|
63
|
+
dismissible: !__props.loading,
|
|
64
|
+
onClose
|
|
65
|
+
}, {
|
|
66
|
+
footer: withCtx(() => [createVNode(_sfc_main$1, {
|
|
67
|
+
variant: "ghost",
|
|
68
|
+
autofocus: __props.danger,
|
|
69
|
+
disabled: __props.loading,
|
|
70
|
+
onClick: _cache[0] || (_cache[0] = ($event) => decide("cancel"))
|
|
71
|
+
}, {
|
|
72
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.cancelText ?? unref(translations).cancel), 1)]),
|
|
73
|
+
_: 1
|
|
74
|
+
}, 8, ["autofocus", "disabled"]), createVNode(_sfc_main$1, {
|
|
75
|
+
variant: __props.danger ? "danger" : "primary",
|
|
76
|
+
autofocus: !__props.danger,
|
|
77
|
+
loading: __props.loading,
|
|
78
|
+
onClick: _cache[1] || (_cache[1] = ($event) => decide("confirm"))
|
|
79
|
+
}, createSlots({
|
|
80
|
+
default: withCtx(() => [createTextVNode(" " + toDisplayString(__props.confirmText ?? unref(translations).confirm), 1)]),
|
|
81
|
+
_: 2
|
|
82
|
+
}, [slots.spinner ? {
|
|
83
|
+
name: "spinner",
|
|
84
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "spinner")]),
|
|
85
|
+
key: "0"
|
|
86
|
+
} : void 0]), 1032, [
|
|
87
|
+
"variant",
|
|
88
|
+
"autofocus",
|
|
89
|
+
"loading"
|
|
90
|
+
])]),
|
|
91
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
92
|
+
_: 3
|
|
93
|
+
}, 8, [
|
|
94
|
+
"open",
|
|
95
|
+
"title",
|
|
96
|
+
"description",
|
|
97
|
+
"dismissible"
|
|
98
|
+
]);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
//#endregion
|
|
103
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/components/dialog/ConfirmDialog.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Heading, which names the dialog. */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Supporting text, announced as the dialog's description. */
|
|
6
|
+
description?: string;
|
|
7
|
+
/** Confirm button text. Defaults to the `confirm` translation. */
|
|
8
|
+
confirmText?: string;
|
|
9
|
+
/** Cancel button text. Defaults to the `cancel` translation. */
|
|
10
|
+
cancelText?: string;
|
|
11
|
+
/** Destructive action: a danger-styled confirm, and Cancel takes initial focus. */
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
/** The confirmed action is running: Confirm shows it, and the dialog can't be cancelled. */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** Stay open after Confirm, e.g. while `loading`; close it by setting `open` to false. */
|
|
16
|
+
keepOpen?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type __VLS_Slots = {
|
|
19
|
+
/** Extra body content. */
|
|
20
|
+
default?(): unknown;
|
|
21
|
+
/** The Confirm button's spinner while `loading`. */
|
|
22
|
+
spinner?(): unknown;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_ModelProps = {
|
|
25
|
+
/** Whether the dialog is open. */
|
|
26
|
+
"open"?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
29
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
30
|
+
"update:open": (value: boolean) => any;
|
|
31
|
+
confirm: () => any;
|
|
32
|
+
cancel: () => any;
|
|
33
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
34
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
35
|
+
onConfirm?: (() => any) | undefined;
|
|
36
|
+
onCancel?: (() => any) | undefined;
|
|
37
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
39
|
+
declare const _default: typeof __VLS_export;
|
|
40
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
41
|
+
new (): {
|
|
42
|
+
$slots: S;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { _default as default };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, nextTick, onBeforeUnmount, openBlock, ref, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, watch } from "vue";
|
|
3
|
+
//#region src/components/dialog/Dialog.vue
|
|
4
|
+
const _hoisted_1 = [
|
|
5
|
+
"data-dialog-size",
|
|
6
|
+
"data-dialog-flush",
|
|
7
|
+
"aria-labelledby",
|
|
8
|
+
"aria-label",
|
|
9
|
+
"aria-describedby"
|
|
10
|
+
];
|
|
11
|
+
const _hoisted_2 = { "data-part": "dialog-panel" };
|
|
12
|
+
const _hoisted_3 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
"data-part": "dialog-header"
|
|
15
|
+
};
|
|
16
|
+
const _hoisted_4 = { "data-part": "dialog-header-text" };
|
|
17
|
+
const _hoisted_5 = ["id"];
|
|
18
|
+
const _hoisted_6 = ["id"];
|
|
19
|
+
const _hoisted_7 = ["aria-label"];
|
|
20
|
+
const _hoisted_8 = {
|
|
21
|
+
key: 1,
|
|
22
|
+
"data-part": "dialog-body"
|
|
23
|
+
};
|
|
24
|
+
const _hoisted_9 = {
|
|
25
|
+
key: 2,
|
|
26
|
+
"data-part": "dialog-footer"
|
|
27
|
+
};
|
|
28
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
29
|
+
__name: "Dialog",
|
|
30
|
+
props: /*@__PURE__*/ mergeModels({
|
|
31
|
+
title: {},
|
|
32
|
+
label: {},
|
|
33
|
+
description: {},
|
|
34
|
+
dismissible: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: true
|
|
37
|
+
},
|
|
38
|
+
size: { default: "md" },
|
|
39
|
+
flush: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
closeOnBackdrop: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true
|
|
46
|
+
},
|
|
47
|
+
showCloseButton: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
"open": {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
"openModifiers": {}
|
|
57
|
+
}),
|
|
58
|
+
emits: /*@__PURE__*/ mergeModels(["close"], ["update:open"]),
|
|
59
|
+
setup(__props, { emit: __emit }) {
|
|
60
|
+
const emit = __emit;
|
|
61
|
+
/** Whether the dialog is open. */
|
|
62
|
+
const open = useModel(__props, "open");
|
|
63
|
+
const dialogRef = useTemplateRef("dialog");
|
|
64
|
+
const translations = useTranslations();
|
|
65
|
+
const titleId = useId();
|
|
66
|
+
const descriptionId = useId();
|
|
67
|
+
const hasOpened = ref(open.value);
|
|
68
|
+
watch(open, async (isOpen) => {
|
|
69
|
+
if (isOpen) hasOpened.value = true;
|
|
70
|
+
await nextTick();
|
|
71
|
+
const dialog = dialogRef.value;
|
|
72
|
+
if (!dialog) return;
|
|
73
|
+
if (isOpen && !dialog.open) dialog.showModal();
|
|
74
|
+
else if (!isOpen && dialog.open) dialog.close();
|
|
75
|
+
}, {
|
|
76
|
+
immediate: true,
|
|
77
|
+
flush: "post"
|
|
78
|
+
});
|
|
79
|
+
onBeforeUnmount(() => {
|
|
80
|
+
if (dialogRef.value?.open) dialogRef.value.close();
|
|
81
|
+
});
|
|
82
|
+
/** Closes it from the app's own controls, which `dismissible` doesn't restrict. */
|
|
83
|
+
function close() {
|
|
84
|
+
open.value = false;
|
|
85
|
+
}
|
|
86
|
+
/** Escape, the backdrop and the close button: only when `dismissible`. */
|
|
87
|
+
function dismiss() {
|
|
88
|
+
if (__props.dismissible) close();
|
|
89
|
+
}
|
|
90
|
+
function onKeydown(event) {
|
|
91
|
+
if (!__props.dismissible && event.key === "Escape") event.preventDefault();
|
|
92
|
+
}
|
|
93
|
+
let pressedBackdrop = false;
|
|
94
|
+
function onDialogPointerdown(event) {
|
|
95
|
+
pressedBackdrop = event.target === dialogRef.value;
|
|
96
|
+
}
|
|
97
|
+
function onDialogClick(event) {
|
|
98
|
+
const fromBackdrop = pressedBackdrop && event.target === dialogRef.value;
|
|
99
|
+
pressedBackdrop = false;
|
|
100
|
+
if (__props.closeOnBackdrop && fromBackdrop) dismiss();
|
|
101
|
+
}
|
|
102
|
+
function onClose() {
|
|
103
|
+
if (open.value && !__props.dismissible) {
|
|
104
|
+
dialogRef.value?.showModal();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (open.value) open.value = false;
|
|
108
|
+
emit("close");
|
|
109
|
+
}
|
|
110
|
+
function onCancel(event) {
|
|
111
|
+
if (!__props.dismissible) event.preventDefault();
|
|
112
|
+
}
|
|
113
|
+
return (_ctx, _cache) => {
|
|
114
|
+
return openBlock(), createElementBlock("dialog", {
|
|
115
|
+
ref: "dialog",
|
|
116
|
+
"data-part": "dialog",
|
|
117
|
+
"data-dialog-size": __props.size,
|
|
118
|
+
"data-dialog-flush": __props.flush || void 0,
|
|
119
|
+
"aria-labelledby": __props.title ? unref(titleId) : void 0,
|
|
120
|
+
"aria-label": __props.title ? void 0 : __props.label,
|
|
121
|
+
"aria-describedby": __props.description ? unref(descriptionId) : void 0,
|
|
122
|
+
onPointerdown: onDialogPointerdown,
|
|
123
|
+
onClick: onDialogClick,
|
|
124
|
+
onKeydown,
|
|
125
|
+
onClose,
|
|
126
|
+
onCancel
|
|
127
|
+
}, [createElementVNode("div", _hoisted_2, [
|
|
128
|
+
__props.title || _ctx.$slots.header ? (openBlock(), createElementBlock("header", _hoisted_3, [renderSlot(_ctx.$slots, "header", {}, () => [createElementVNode("div", _hoisted_4, [createElementVNode("h2", {
|
|
129
|
+
id: unref(titleId),
|
|
130
|
+
"data-part": "dialog-title"
|
|
131
|
+
}, toDisplayString(__props.title), 9, _hoisted_5), __props.description ? (openBlock(), createElementBlock("p", {
|
|
132
|
+
key: 0,
|
|
133
|
+
id: unref(descriptionId),
|
|
134
|
+
"data-part": "dialog-description"
|
|
135
|
+
}, toDisplayString(__props.description), 9, _hoisted_6)) : createCommentVNode("v-if", true)])]), __props.showCloseButton && __props.dismissible ? (openBlock(), createElementBlock("button", {
|
|
136
|
+
key: 0,
|
|
137
|
+
type: "button",
|
|
138
|
+
"data-part": "dialog-close",
|
|
139
|
+
"aria-label": unref(translations).close,
|
|
140
|
+
onClick: dismiss
|
|
141
|
+
}, [renderSlot(_ctx.$slots, "close-icon", {}, () => [_cache[0] || (_cache[0] = createElementVNode("svg", {
|
|
142
|
+
viewBox: "0 0 16 16",
|
|
143
|
+
width: "16",
|
|
144
|
+
height: "16",
|
|
145
|
+
"aria-hidden": "true",
|
|
146
|
+
focusable: "false"
|
|
147
|
+
}, [createElementVNode("path", {
|
|
148
|
+
d: "M4 4l8 8M12 4l-8 8",
|
|
149
|
+
stroke: "currentColor",
|
|
150
|
+
"stroke-width": "1.5",
|
|
151
|
+
"stroke-linecap": "round"
|
|
152
|
+
})], -1))])], 8, _hoisted_7)) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true),
|
|
153
|
+
hasOpened.value ? (openBlock(), createElementBlock("div", _hoisted_8, [renderSlot(_ctx.$slots, "default", { close })])) : createCommentVNode("v-if", true),
|
|
154
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("footer", _hoisted_9, [renderSlot(_ctx.$slots, "footer", { close })])) : createCommentVNode("v-if", true)
|
|
155
|
+
])], 40, _hoisted_1);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
//#endregion
|
|
160
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/components/dialog/Dialog.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Heading, which names the dialog. */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Accessible name when there's no visible `title`. */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Supporting text, announced as the dialog's description. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Whether Escape, the backdrop and the header's close button can close it. The slots' `close` always can. */
|
|
10
|
+
dismissible?: boolean;
|
|
11
|
+
/** Size hook, exposed as `data-dialog-size`. */
|
|
12
|
+
size?: "sm" | "md" | "lg" | "xl";
|
|
13
|
+
/** Layout hook for edge-to-edge content, exposed as `data-dialog-flush`. */
|
|
14
|
+
flush?: boolean;
|
|
15
|
+
/** Close when the backdrop is clicked. */
|
|
16
|
+
closeOnBackdrop?: boolean;
|
|
17
|
+
/** Render the header's close button. */
|
|
18
|
+
showCloseButton?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type __VLS_Slots = {
|
|
21
|
+
/** Body content. Mounted on first open. */
|
|
22
|
+
default?(props: {
|
|
23
|
+
close: () => void;
|
|
24
|
+
}): unknown;
|
|
25
|
+
/** Replaces the title and description. */
|
|
26
|
+
header?(): unknown;
|
|
27
|
+
/** Actions, e.g. buttons. */
|
|
28
|
+
footer?(props: {
|
|
29
|
+
close: () => void;
|
|
30
|
+
}): unknown;
|
|
31
|
+
/** Replaces the close button's icon. */
|
|
32
|
+
"close-icon"?(): unknown;
|
|
33
|
+
};
|
|
34
|
+
type __VLS_ModelProps = {
|
|
35
|
+
/** Whether the dialog is open. */
|
|
36
|
+
"open"?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
39
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
40
|
+
"update:open": (value: boolean) => any;
|
|
41
|
+
close: () => any;
|
|
42
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
43
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
44
|
+
onClose?: (() => any) | undefined;
|
|
45
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
46
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
47
|
+
declare const _default: typeof __VLS_export;
|
|
48
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
49
|
+
new (): {
|
|
50
|
+
$slots: S;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { _default as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createCommentVNode, createElementBlock, defineComponent, openBlock, toDisplayString } from "vue";
|
|
2
|
+
//#region src/components/field/FieldMessage.vue
|
|
3
|
+
const _hoisted_1 = ["id"];
|
|
4
|
+
const _hoisted_2 = ["id"];
|
|
5
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
|
+
__name: "FieldMessage",
|
|
7
|
+
props: {
|
|
8
|
+
errorId: {},
|
|
9
|
+
hintId: {},
|
|
10
|
+
errorMessage: {},
|
|
11
|
+
hint: {}
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
return (_ctx, _cache) => {
|
|
15
|
+
return __props.errorMessage ? (openBlock(), createElementBlock("p", {
|
|
16
|
+
key: 0,
|
|
17
|
+
id: __props.errorId,
|
|
18
|
+
role: "alert",
|
|
19
|
+
"data-part": "field-message",
|
|
20
|
+
"data-field-tone": "error"
|
|
21
|
+
}, toDisplayString(__props.errorMessage), 9, _hoisted_1)) : __props.hint ? (openBlock(), createElementBlock("p", {
|
|
22
|
+
key: 1,
|
|
23
|
+
id: __props.hintId,
|
|
24
|
+
"data-part": "field-message",
|
|
25
|
+
"data-field-tone": "hint"
|
|
26
|
+
}, toDisplayString(__props.hint), 9, _hoisted_2)) : createCommentVNode("v-if", true);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { _sfc_main as default };
|