@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,118 @@
|
|
|
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 { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeModels, mergeProps, openBlock, toDisplayString, unref, useModel, useTemplateRef, vModelText, withDirectives } from "vue";
|
|
5
|
+
//#region src/components/textarea/Textarea.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 = [
|
|
13
|
+
"id",
|
|
14
|
+
"rows",
|
|
15
|
+
"disabled",
|
|
16
|
+
"maxlength",
|
|
17
|
+
"aria-invalid",
|
|
18
|
+
"aria-describedby"
|
|
19
|
+
];
|
|
20
|
+
const _hoisted_5 = {
|
|
21
|
+
key: 1,
|
|
22
|
+
"data-part": "field-footer"
|
|
23
|
+
};
|
|
24
|
+
const _hoisted_6 = ["id", "data-field-count-exceeded"];
|
|
25
|
+
const _hoisted_7 = { "aria-hidden": "true" };
|
|
26
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
__name: "Textarea",
|
|
29
|
+
props: /*@__PURE__*/ mergeModels({
|
|
30
|
+
label: {},
|
|
31
|
+
hint: {},
|
|
32
|
+
error: { type: [String, Boolean] },
|
|
33
|
+
maxLength: {},
|
|
34
|
+
optional: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
rows: { default: 4 },
|
|
43
|
+
id: {}
|
|
44
|
+
}, {
|
|
45
|
+
"modelValue": {},
|
|
46
|
+
"modelModifiers": {}
|
|
47
|
+
}),
|
|
48
|
+
emits: ["update:modelValue"],
|
|
49
|
+
setup(__props, { expose: __expose }) {
|
|
50
|
+
/** The value. */
|
|
51
|
+
const model = useModel(__props, "modelValue");
|
|
52
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
53
|
+
id: () => __props.id,
|
|
54
|
+
hint: () => __props.hint,
|
|
55
|
+
error: () => __props.error
|
|
56
|
+
});
|
|
57
|
+
const translations = useTranslations();
|
|
58
|
+
const countId = computed(() => `${id.value}-count`);
|
|
59
|
+
const charCount = computed(() => model.value?.length ?? 0);
|
|
60
|
+
const isOverLimit = computed(() => __props.maxLength != null && charCount.value > __props.maxLength);
|
|
61
|
+
const describedByAll = computed(() => {
|
|
62
|
+
const ids = [describedBy.value, __props.maxLength == null ? void 0 : countId.value].filter(Boolean);
|
|
63
|
+
return ids.length ? ids.join(" ") : void 0;
|
|
64
|
+
});
|
|
65
|
+
const visuallyHidden = {
|
|
66
|
+
position: "absolute",
|
|
67
|
+
width: "1px",
|
|
68
|
+
height: "1px",
|
|
69
|
+
overflow: "hidden",
|
|
70
|
+
clipPath: "inset(50%)",
|
|
71
|
+
whiteSpace: "nowrap"
|
|
72
|
+
};
|
|
73
|
+
const textareaRef = useTemplateRef("textarea");
|
|
74
|
+
__expose({ focus: () => textareaRef.value?.focus() });
|
|
75
|
+
return (_ctx, _cache) => {
|
|
76
|
+
return openBlock(), createElementBlock("div", {
|
|
77
|
+
"data-part": "field",
|
|
78
|
+
"data-field-error": unref(isError) || void 0
|
|
79
|
+
}, [
|
|
80
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
81
|
+
key: 0,
|
|
82
|
+
for: unref(id),
|
|
83
|
+
"data-part": "field-label"
|
|
84
|
+
}, [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),
|
|
85
|
+
withDirectives(createElementVNode("textarea", mergeProps({
|
|
86
|
+
id: unref(id),
|
|
87
|
+
ref: "textarea",
|
|
88
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
|
|
89
|
+
rows: __props.rows
|
|
90
|
+
}, _ctx.$attrs, {
|
|
91
|
+
disabled: __props.disabled,
|
|
92
|
+
maxlength: __props.maxLength,
|
|
93
|
+
"aria-invalid": unref(isError) || isOverLimit.value || void 0,
|
|
94
|
+
"aria-describedby": describedByAll.value,
|
|
95
|
+
"data-part": "textarea"
|
|
96
|
+
}), null, 16, _hoisted_4), [[vModelText, model.value]]),
|
|
97
|
+
unref(errorMessage) || __props.hint || __props.maxLength != null ? (openBlock(), createElementBlock("div", _hoisted_5, [createVNode(_sfc_main$1, {
|
|
98
|
+
"error-id": unref(errorId),
|
|
99
|
+
"hint-id": unref(hintId),
|
|
100
|
+
"error-message": unref(errorMessage),
|
|
101
|
+
hint: __props.hint
|
|
102
|
+
}, null, 8, [
|
|
103
|
+
"error-id",
|
|
104
|
+
"hint-id",
|
|
105
|
+
"error-message",
|
|
106
|
+
"hint"
|
|
107
|
+
]), __props.maxLength != null ? (openBlock(), createElementBlock("span", {
|
|
108
|
+
key: 0,
|
|
109
|
+
id: countId.value,
|
|
110
|
+
"data-part": "field-count",
|
|
111
|
+
"data-field-count-exceeded": isOverLimit.value || void 0
|
|
112
|
+
}, [createElementVNode("span", _hoisted_7, toDisplayString(charCount.value) + "/" + toDisplayString(__props.maxLength), 1), createElementVNode("span", { style: visuallyHidden }, toDisplayString(unref(translations).characterCount(charCount.value, __props.maxLength)), 1)], 8, _hoisted_6)) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true)
|
|
113
|
+
], 8, _hoisted_1);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
//#endregion
|
|
118
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/components/textarea/Textarea.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
|
+
/** Character limit. Shows a live counter and flags values already over it. */
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
/** Appends the `optional` translation to the label. */
|
|
12
|
+
optional?: boolean;
|
|
13
|
+
/** Disables the control. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Visible text lines. */
|
|
16
|
+
rows?: number;
|
|
17
|
+
/** Id for the control; generated with `useId()` when omitted. */
|
|
18
|
+
id?: string;
|
|
19
|
+
};
|
|
20
|
+
type __VLS_ModelProps = {
|
|
21
|
+
/** The value. */
|
|
22
|
+
modelValue?: string;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
25
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
26
|
+
focus: () => void | undefined;
|
|
27
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
28
|
+
"update:modelValue": (value: string | undefined) => any;
|
|
29
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
30
|
+
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
31
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { _default as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { useTimeoutFn } from "../../composables/internal/use-timeout-fn.js";
|
|
3
|
+
import { useDocumentVisibility } from "../../composables/internal/use-document-visibility.js";
|
|
4
|
+
import { createCommentVNode, createElementBlock, createElementVNode, defineComponent, onMounted, openBlock, renderSlot, toDisplayString, unref, useTemplateRef, watch } from "vue";
|
|
5
|
+
//#region src/components/toast/ToastItem.vue
|
|
6
|
+
const _hoisted_1 = ["data-toast-tone"];
|
|
7
|
+
const _hoisted_2 = ["role"];
|
|
8
|
+
const _hoisted_3 = ["aria-label"];
|
|
9
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
10
|
+
__name: "ToastItem",
|
|
11
|
+
props: { toast: {} },
|
|
12
|
+
emits: ["dismiss"],
|
|
13
|
+
setup(__props, { emit: __emit }) {
|
|
14
|
+
const emit = __emit;
|
|
15
|
+
const dismiss = () => emit("dismiss", __props.toast.id);
|
|
16
|
+
const translations = useTranslations();
|
|
17
|
+
const timer = useTimeoutFn(dismiss, __props.toast.duration);
|
|
18
|
+
const visibility = useDocumentVisibility();
|
|
19
|
+
const rootRef = useTemplateRef("root");
|
|
20
|
+
let remaining = __props.toast.duration;
|
|
21
|
+
let startedAt = 0;
|
|
22
|
+
let running = false;
|
|
23
|
+
function resume() {
|
|
24
|
+
if (running || __props.toast.duration <= 0 || visibility.value !== "visible") return;
|
|
25
|
+
running = true;
|
|
26
|
+
startedAt = Date.now();
|
|
27
|
+
timer.start(remaining);
|
|
28
|
+
}
|
|
29
|
+
function pause() {
|
|
30
|
+
if (!running) return;
|
|
31
|
+
running = false;
|
|
32
|
+
timer.stop();
|
|
33
|
+
remaining = Math.max(0, remaining - (Date.now() - startedAt));
|
|
34
|
+
}
|
|
35
|
+
onMounted(resume);
|
|
36
|
+
watch(visibility, (state) => state === "hidden" ? pause() : resume());
|
|
37
|
+
function runAction() {
|
|
38
|
+
__props.toast.action?.onClick();
|
|
39
|
+
dismiss();
|
|
40
|
+
}
|
|
41
|
+
function onFocusOut(event) {
|
|
42
|
+
if (event.relatedTarget instanceof Node && rootRef.value?.contains(event.relatedTarget)) return;
|
|
43
|
+
resume();
|
|
44
|
+
}
|
|
45
|
+
return (_ctx, _cache) => {
|
|
46
|
+
return openBlock(), createElementBlock("div", {
|
|
47
|
+
ref: "root",
|
|
48
|
+
"data-part": "toast",
|
|
49
|
+
"data-toast-tone": __props.toast.tone,
|
|
50
|
+
onPointerenter: pause,
|
|
51
|
+
onPointerleave: resume,
|
|
52
|
+
onFocusin: pause,
|
|
53
|
+
onFocusout: onFocusOut
|
|
54
|
+
}, [renderSlot(_ctx.$slots, "default", {
|
|
55
|
+
toast: __props.toast,
|
|
56
|
+
dismiss
|
|
57
|
+
}, () => [
|
|
58
|
+
createCommentVNode(" An error is announced at once; others wait their turn in the polite region.\n Only the message: the buttons' names aren't part of what's announced. "),
|
|
59
|
+
createElementVNode("p", {
|
|
60
|
+
"data-part": "toast-message",
|
|
61
|
+
role: __props.toast.tone === "danger" ? "alert" : void 0
|
|
62
|
+
}, toDisplayString(__props.toast.message), 9, _hoisted_2),
|
|
63
|
+
__props.toast.action ? (openBlock(), createElementBlock("button", {
|
|
64
|
+
key: 0,
|
|
65
|
+
type: "button",
|
|
66
|
+
"data-part": "toast-action",
|
|
67
|
+
onClick: runAction
|
|
68
|
+
}, toDisplayString(__props.toast.action.label), 1)) : createCommentVNode("v-if", true),
|
|
69
|
+
createElementVNode("button", {
|
|
70
|
+
type: "button",
|
|
71
|
+
"data-part": "toast-close",
|
|
72
|
+
"aria-label": unref(translations).dismissToast,
|
|
73
|
+
onClick: dismiss
|
|
74
|
+
}, [renderSlot(_ctx.$slots, "close-icon", {}, () => [_cache[0] || (_cache[0] = createElementVNode("svg", {
|
|
75
|
+
viewBox: "0 0 16 16",
|
|
76
|
+
width: "14",
|
|
77
|
+
height: "14",
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
focusable: "false"
|
|
80
|
+
}, [createElementVNode("path", {
|
|
81
|
+
d: "M4 4l8 8M12 4l-8 8",
|
|
82
|
+
stroke: "currentColor",
|
|
83
|
+
"stroke-width": "1.5",
|
|
84
|
+
"stroke-linecap": "round"
|
|
85
|
+
})], -1))])], 8, _hoisted_3)
|
|
86
|
+
])], 40, _hoisted_1);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Toast } from "../../types.js";
|
|
2
|
+
//#region src/components/toast/ToastItem.vue.d.ts
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** The toast to render, from `useToast().items`. */
|
|
5
|
+
toast: Toast;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
/** Replaces the message and close button. */
|
|
9
|
+
default?(props: {
|
|
10
|
+
toast: Toast;
|
|
11
|
+
dismiss: () => void;
|
|
12
|
+
}): unknown;
|
|
13
|
+
/** Replaces the close button's icon. */
|
|
14
|
+
"close-icon"?(): unknown;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
dismiss: (id: number) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onDismiss?: ((id: number) => any) | undefined;
|
|
20
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
24
|
+
new (): {
|
|
25
|
+
$slots: S;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { _default as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useToast } from "../../composables/use-toast.js";
|
|
2
|
+
import { useTranslations } from "../../config.js";
|
|
3
|
+
import _sfc_main$1 from "./ToastItem.js";
|
|
4
|
+
import { Fragment, TransitionGroup, createBlock, createElementBlock, createSlots, defineComponent, onMounted, openBlock, renderList, renderSlot, unref, useTemplateRef, watch, withCtx } from "vue";
|
|
5
|
+
//#region src/components/toast/ToastViewport.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
__name: "ToastViewport",
|
|
8
|
+
props: { label: {} },
|
|
9
|
+
setup(__props) {
|
|
10
|
+
const { items, dismiss } = useToast();
|
|
11
|
+
const translations = useTranslations();
|
|
12
|
+
const viewportRef = useTemplateRef("viewport");
|
|
13
|
+
const element = () => viewportRef.value?.$el;
|
|
14
|
+
onMounted(() => element()?.showPopover());
|
|
15
|
+
watch(() => items.value.length, (count, previous) => {
|
|
16
|
+
const el = element();
|
|
17
|
+
if (!el || count <= (previous ?? 0) || !document.querySelector(":modal")) return;
|
|
18
|
+
el.hidePopover();
|
|
19
|
+
el.showPopover();
|
|
20
|
+
}, { flush: "post" });
|
|
21
|
+
return (_ctx, _cache) => {
|
|
22
|
+
return openBlock(), createBlock(TransitionGroup, {
|
|
23
|
+
ref: "viewport",
|
|
24
|
+
tag: "section",
|
|
25
|
+
popover: "manual",
|
|
26
|
+
name: "ui-toast",
|
|
27
|
+
"data-part": "toast-viewport",
|
|
28
|
+
"aria-label": __props.label ?? unref(translations).notifications,
|
|
29
|
+
"aria-live": "polite",
|
|
30
|
+
"aria-relevant": "additions"
|
|
31
|
+
}, {
|
|
32
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(items), (toast) => {
|
|
33
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
34
|
+
key: toast.id,
|
|
35
|
+
toast,
|
|
36
|
+
onDismiss: unref(dismiss)
|
|
37
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.default ? {
|
|
38
|
+
name: "default",
|
|
39
|
+
fn: withCtx(({ dismiss: close }) => [renderSlot(_ctx.$slots, "default", {
|
|
40
|
+
toast,
|
|
41
|
+
dismiss: close
|
|
42
|
+
})]),
|
|
43
|
+
key: "0"
|
|
44
|
+
} : void 0, _ctx.$slots["close-icon"] ? {
|
|
45
|
+
name: "close-icon",
|
|
46
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "close-icon")]),
|
|
47
|
+
key: "1"
|
|
48
|
+
} : void 0]), 1032, ["toast", "onDismiss"]);
|
|
49
|
+
}), 128))]),
|
|
50
|
+
_: 3
|
|
51
|
+
}, 8, ["aria-label"]);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
56
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Toast } from "../../types.js";
|
|
2
|
+
//#region src/components/toast/ToastViewport.vue.d.ts
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** Accessible name of the live region. Defaults to the `notifications` translation. */
|
|
5
|
+
label?: string;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
/** Renders each toast, replacing the message and close button. */
|
|
9
|
+
default?(props: {
|
|
10
|
+
toast: Toast;
|
|
11
|
+
dismiss: () => void;
|
|
12
|
+
}): unknown;
|
|
13
|
+
/** Replaces each close button's icon. */
|
|
14
|
+
"close-icon"?(): unknown;
|
|
15
|
+
};
|
|
16
|
+
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>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
20
|
+
new (): {
|
|
21
|
+
$slots: S;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { _default as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { createElementBlock, defineComponent, onMounted, onScopeDispose, openBlock, renderSlot, useTemplateRef } from "vue";
|
|
2
|
+
//#region src/components/toolbar/Toolbar.vue
|
|
3
|
+
const _hoisted_1 = [
|
|
4
|
+
"data-orientation",
|
|
5
|
+
"aria-label",
|
|
6
|
+
"aria-orientation"
|
|
7
|
+
];
|
|
8
|
+
const ITEMS = "button, a[href], input, select, textarea, [role='button'], [role='checkbox'], [role='switch'], [tabindex]";
|
|
9
|
+
const NESTED = "[popover], [role='menu'], [role='listbox'], [role='radiogroup'], [role='tablist']";
|
|
10
|
+
/** The controls the arrow keys move between, in DOM order. */
|
|
11
|
+
const TEXT_ENTRY = "textarea, [contenteditable=''], [contenteditable='true'], input";
|
|
12
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
13
|
+
__name: "Toolbar",
|
|
14
|
+
props: {
|
|
15
|
+
label: {},
|
|
16
|
+
orientation: { default: "horizontal" }
|
|
17
|
+
},
|
|
18
|
+
setup(__props) {
|
|
19
|
+
const rootRef = useTemplateRef("root");
|
|
20
|
+
function items() {
|
|
21
|
+
const root = rootRef.value;
|
|
22
|
+
if (!root) return [];
|
|
23
|
+
return [...root.querySelectorAll(ITEMS)].filter((el) => {
|
|
24
|
+
if (el.matches(":disabled, [aria-hidden='true'], [hidden]")) return false;
|
|
25
|
+
const nested = el.parentElement?.closest(NESTED);
|
|
26
|
+
return !nested || !root.contains(nested);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
let current = null;
|
|
30
|
+
function roveTo(target) {
|
|
31
|
+
const list = items();
|
|
32
|
+
current = target && list.includes(target) ? target : list[0] ?? null;
|
|
33
|
+
for (const el of list) el.tabIndex = el === current ? 0 : -1;
|
|
34
|
+
}
|
|
35
|
+
function onFocusin(event) {
|
|
36
|
+
if (event.target instanceof HTMLElement && items().includes(event.target)) roveTo(event.target);
|
|
37
|
+
}
|
|
38
|
+
const isTextEntry = (el) => el.matches(TEXT_ENTRY) && !(el instanceof HTMLInputElement && [
|
|
39
|
+
"checkbox",
|
|
40
|
+
"radio",
|
|
41
|
+
"button",
|
|
42
|
+
"submit"
|
|
43
|
+
].includes(el.type));
|
|
44
|
+
function onKeydown(event) {
|
|
45
|
+
if (event.defaultPrevented || !(event.target instanceof HTMLElement)) return;
|
|
46
|
+
const horizontal = __props.orientation === "horizontal";
|
|
47
|
+
const rtl = getComputedStyle(rootRef.value).direction === "rtl";
|
|
48
|
+
const next = horizontal ? rtl ? "ArrowLeft" : "ArrowRight" : "ArrowDown";
|
|
49
|
+
const prev = horizontal ? rtl ? "ArrowRight" : "ArrowLeft" : "ArrowUp";
|
|
50
|
+
if (isTextEntry(event.target) && (event.key === next || event.key === prev)) return;
|
|
51
|
+
const list = items();
|
|
52
|
+
const index = list.indexOf(event.target);
|
|
53
|
+
if (index < 0) return;
|
|
54
|
+
const target = {
|
|
55
|
+
[next]: list[(index + 1) % list.length],
|
|
56
|
+
[prev]: list[(index - 1 + list.length) % list.length],
|
|
57
|
+
Home: list[0],
|
|
58
|
+
End: list.at(-1)
|
|
59
|
+
}[event.key];
|
|
60
|
+
if (!target) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
roveTo(target);
|
|
63
|
+
target.focus();
|
|
64
|
+
}
|
|
65
|
+
let observer;
|
|
66
|
+
onMounted(() => {
|
|
67
|
+
roveTo(null);
|
|
68
|
+
observer = new MutationObserver(() => roveTo(current));
|
|
69
|
+
observer.observe(rootRef.value, {
|
|
70
|
+
childList: true,
|
|
71
|
+
subtree: true,
|
|
72
|
+
attributeFilter: ["disabled", "hidden"]
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
onScopeDispose(() => observer?.disconnect());
|
|
76
|
+
return (_ctx, _cache) => {
|
|
77
|
+
return openBlock(), createElementBlock("div", {
|
|
78
|
+
ref: "root",
|
|
79
|
+
role: "toolbar",
|
|
80
|
+
"data-part": "toolbar",
|
|
81
|
+
"data-orientation": __props.orientation,
|
|
82
|
+
"aria-label": __props.label,
|
|
83
|
+
"aria-orientation": __props.orientation,
|
|
84
|
+
onFocusin,
|
|
85
|
+
onKeydown
|
|
86
|
+
}, [renderSlot(_ctx.$slots, "default")], 40, _hoisted_1);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/components/toolbar/Toolbar.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Accessible name for the toolbar. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Which arrow keys move between controls; also `aria-orientation`. */
|
|
6
|
+
orientation?: "horizontal" | "vertical";
|
|
7
|
+
};
|
|
8
|
+
type __VLS_Slots = {
|
|
9
|
+
/** Buttons, toggles, menus and other controls. */
|
|
10
|
+
default?(): unknown;
|
|
11
|
+
};
|
|
12
|
+
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>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { _default as default };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEventListener } from "../../composables/internal/use-event-listener.js";
|
|
2
|
+
import { useAnchor } from "../../composables/use-popover.js";
|
|
3
|
+
import { useTimeoutFn } from "../../composables/internal/use-timeout-fn.js";
|
|
4
|
+
import { computed, createCommentVNode, createElementBlock, defineComponent, normalizeStyle, openBlock, ref, renderSlot, toDisplayString, unref, useId, useTemplateRef } from "vue";
|
|
5
|
+
//#region src/components/tooltip/Tooltip.vue
|
|
6
|
+
const _hoisted_1 = ["id", "data-tooltip-side"];
|
|
7
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
|
+
__name: "Tooltip",
|
|
9
|
+
props: {
|
|
10
|
+
text: {},
|
|
11
|
+
delay: { default: 250 }
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
const tooltipId = useId();
|
|
15
|
+
const triggerAttrs = computed(() => ({ "aria-describedby": __props.text ? tooltipId : void 0 }));
|
|
16
|
+
const rootRef = useTemplateRef("root");
|
|
17
|
+
const tooltipRef = useTemplateRef("tooltip");
|
|
18
|
+
const { anchorStyle, panelStyle } = useAnchor();
|
|
19
|
+
const side = ref("top");
|
|
20
|
+
const arrowX = ref(0);
|
|
21
|
+
const isOpen = ref(false);
|
|
22
|
+
function place() {
|
|
23
|
+
const tip = tooltipRef.value?.getBoundingClientRect();
|
|
24
|
+
const anchor = rootRef.value?.getBoundingClientRect();
|
|
25
|
+
if (!tip || !anchor) return;
|
|
26
|
+
side.value = tip.top >= anchor.bottom ? "bottom" : "top";
|
|
27
|
+
arrowX.value = anchor.left + anchor.width / 2 - tip.left;
|
|
28
|
+
}
|
|
29
|
+
function show() {
|
|
30
|
+
const el = tooltipRef.value;
|
|
31
|
+
if (!el?.isConnected || el.matches(":popover-open")) return;
|
|
32
|
+
el.showPopover();
|
|
33
|
+
isOpen.value = true;
|
|
34
|
+
place();
|
|
35
|
+
}
|
|
36
|
+
function hide() {
|
|
37
|
+
timer.stop();
|
|
38
|
+
const el = tooltipRef.value;
|
|
39
|
+
if (el?.matches(":popover-open")) el.hidePopover();
|
|
40
|
+
isOpen.value = false;
|
|
41
|
+
}
|
|
42
|
+
const timer = useTimeoutFn(show, __props.delay);
|
|
43
|
+
function onPointerenter(event) {
|
|
44
|
+
if (__props.text && event.pointerType === "mouse") timer.start();
|
|
45
|
+
}
|
|
46
|
+
function onFocusin(event) {
|
|
47
|
+
if (__props.text && event.target instanceof Element && event.target.matches(":focus-visible")) timer.start();
|
|
48
|
+
}
|
|
49
|
+
function onPointerleave() {
|
|
50
|
+
if (rootRef.value?.querySelector(":focus-visible")) return;
|
|
51
|
+
hide();
|
|
52
|
+
}
|
|
53
|
+
function onFocusout(event) {
|
|
54
|
+
if (event.relatedTarget instanceof Node && rootRef.value?.contains(event.relatedTarget)) return;
|
|
55
|
+
hide();
|
|
56
|
+
}
|
|
57
|
+
useEventListener(() => isOpen.value ? document : null, "keydown", (event) => {
|
|
58
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
hide();
|
|
61
|
+
});
|
|
62
|
+
return (_ctx, _cache) => {
|
|
63
|
+
return openBlock(), createElementBlock("span", {
|
|
64
|
+
ref: "root",
|
|
65
|
+
"data-part": "tooltip-root",
|
|
66
|
+
style: normalizeStyle(unref(anchorStyle)),
|
|
67
|
+
onPointerenter,
|
|
68
|
+
onPointerleave,
|
|
69
|
+
onFocusin,
|
|
70
|
+
onFocusout
|
|
71
|
+
}, [renderSlot(_ctx.$slots, "default", { attrs: triggerAttrs.value }), __props.text ? (openBlock(), createElementBlock("span", {
|
|
72
|
+
key: 0,
|
|
73
|
+
id: unref(tooltipId),
|
|
74
|
+
ref: "tooltip",
|
|
75
|
+
popover: "manual",
|
|
76
|
+
role: "tooltip",
|
|
77
|
+
"data-part": "tooltip",
|
|
78
|
+
"data-tooltip-side": side.value,
|
|
79
|
+
style: normalizeStyle([unref(panelStyle), { "--ui-tooltip-arrow-x": `${arrowX.value}px` }])
|
|
80
|
+
}, toDisplayString(__props.text), 13, _hoisted_1)) : createCommentVNode("v-if", true)], 36);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/components/tooltip/Tooltip.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Tooltip text. Without it, only the trigger renders. */
|
|
4
|
+
text?: string;
|
|
5
|
+
/** Milliseconds of hover or focus before it shows. */
|
|
6
|
+
delay?: number;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_Slots = {
|
|
9
|
+
/** The trigger. Bind `attrs` to it so the tooltip describes it. */
|
|
10
|
+
default(props: {
|
|
11
|
+
attrs: {
|
|
12
|
+
"aria-describedby"?: string;
|
|
13
|
+
};
|
|
14
|
+
}): unknown;
|
|
15
|
+
};
|
|
16
|
+
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>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
20
|
+
new (): {
|
|
21
|
+
$slots: S;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { _default as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createBlock, defineComponent, openBlock, renderSlot, resolveDynamicComponent, withCtx } from "vue";
|
|
2
|
+
//#region src/components/visually-hidden/VisuallyHidden.vue
|
|
3
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
4
|
+
__name: "VisuallyHidden",
|
|
5
|
+
props: { as: { default: "span" } },
|
|
6
|
+
setup(__props) {
|
|
7
|
+
return (_ctx, _cache) => {
|
|
8
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.as), { "data-part": "visually-hidden" }, {
|
|
9
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
10
|
+
_: 3
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/components/visually-hidden/VisuallyHidden.vue.d.ts
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Element to render, e.g. "div". */
|
|
4
|
+
as?: string;
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = {
|
|
7
|
+
/** The text to keep for assistive technology. */
|
|
8
|
+
default?(): unknown;
|
|
9
|
+
};
|
|
10
|
+
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>;
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
14
|
+
new (): {
|
|
15
|
+
$slots: S;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { _default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/composables/internal/is-equal.ts
|
|
2
|
+
const isRecord = (value) => !Array.isArray(value);
|
|
3
|
+
/** Structural equality for form values: primitives, arrays, plain objects, Dates. */
|
|
4
|
+
function isEqual(a, b) {
|
|
5
|
+
if (Object.is(a, b)) return true;
|
|
6
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
7
|
+
if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
8
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => isEqual(item, b[i]));
|
|
9
|
+
if (!isRecord(a) || !isRecord(b)) return false;
|
|
10
|
+
const aKeys = Object.keys(a);
|
|
11
|
+
return aKeys.length === Object.keys(b).length && aKeys.every((key) => Object.hasOwn(b, key) && isEqual(a[key], b[key]));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { isEqual };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEventListener } from "./use-event-listener.js";
|
|
2
|
+
import { toValue } from "vue";
|
|
3
|
+
//#region src/composables/internal/on-click-outside.ts
|
|
4
|
+
/** Calls `handler` on a pointerdown outside `target` and every `ignore` element. */
|
|
5
|
+
function onClickOutside(target, handler, { ignore = [], active = () => true } = {}) {
|
|
6
|
+
return useEventListener(() => active() ? document : null, "pointerdown", (event) => {
|
|
7
|
+
const path = event.composedPath();
|
|
8
|
+
if (![target, ...ignore].some((el) => {
|
|
9
|
+
const node = toValue(el);
|
|
10
|
+
return node != null && path.includes(node);
|
|
11
|
+
})) handler(event);
|
|
12
|
+
}, {
|
|
13
|
+
capture: true,
|
|
14
|
+
passive: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { onClickOutside };
|