@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,173 @@
|
|
|
1
|
+
import { useTranslations } from "../../config.js";
|
|
2
|
+
import { useResizeObserver } from "../../composables/internal/use-resize-observer.js";
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useId, useModel, useSlots, useTemplateRef } from "vue";
|
|
4
|
+
//#region src/components/table/Table.vue
|
|
5
|
+
const _hoisted_1 = [
|
|
6
|
+
"tabindex",
|
|
7
|
+
"data-table-overflow",
|
|
8
|
+
"role",
|
|
9
|
+
"aria-labelledby"
|
|
10
|
+
];
|
|
11
|
+
const _hoisted_2 = {
|
|
12
|
+
ref: "table",
|
|
13
|
+
"data-part": "table"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_3 = ["id"];
|
|
16
|
+
const _hoisted_4 = { key: 1 };
|
|
17
|
+
const _hoisted_5 = { "data-part": "table-header" };
|
|
18
|
+
const _hoisted_6 = { "data-part": "table-row" };
|
|
19
|
+
const _hoisted_7 = [
|
|
20
|
+
"data-table-align",
|
|
21
|
+
"data-table-numeric",
|
|
22
|
+
"data-table-sort",
|
|
23
|
+
"aria-sort"
|
|
24
|
+
];
|
|
25
|
+
const _hoisted_8 = ["data-table-sort", "onClick"];
|
|
26
|
+
const _hoisted_9 = {
|
|
27
|
+
"data-part": "table-sort-indicator",
|
|
28
|
+
"aria-hidden": "true"
|
|
29
|
+
};
|
|
30
|
+
const _hoisted_10 = {
|
|
31
|
+
key: 0,
|
|
32
|
+
viewBox: "0 0 16 16",
|
|
33
|
+
width: "12",
|
|
34
|
+
height: "12",
|
|
35
|
+
focusable: "false"
|
|
36
|
+
};
|
|
37
|
+
const _hoisted_11 = ["d"];
|
|
38
|
+
const _hoisted_12 = ["data-table-align", "data-table-numeric"];
|
|
39
|
+
const _hoisted_13 = {
|
|
40
|
+
key: 0,
|
|
41
|
+
"data-part": "table-row"
|
|
42
|
+
};
|
|
43
|
+
const _hoisted_14 = ["colspan"];
|
|
44
|
+
const _hoisted_15 = {
|
|
45
|
+
key: 2,
|
|
46
|
+
"data-part": "table-footer"
|
|
47
|
+
};
|
|
48
|
+
const _hoisted_16 = { "data-part": "table-row" };
|
|
49
|
+
const _hoisted_17 = ["data-table-align", "data-table-numeric"];
|
|
50
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
51
|
+
__name: "Table",
|
|
52
|
+
props: /*@__PURE__*/ mergeModels({
|
|
53
|
+
columns: {},
|
|
54
|
+
rows: {},
|
|
55
|
+
rowKey: { type: Function },
|
|
56
|
+
caption: {}
|
|
57
|
+
}, {
|
|
58
|
+
"sort": {},
|
|
59
|
+
"sortModifiers": {}
|
|
60
|
+
}),
|
|
61
|
+
emits: ["update:sort"],
|
|
62
|
+
setup(__props) {
|
|
63
|
+
/** The sorted column and direction, set by `sortable` columns' headers. Rows aren't reordered for you. */
|
|
64
|
+
const sort = useModel(__props, "sort");
|
|
65
|
+
const slots = useSlots();
|
|
66
|
+
const captionId = useId();
|
|
67
|
+
const translations = useTranslations();
|
|
68
|
+
const hasWidths = computed(() => __props.columns.some((column) => column.width));
|
|
69
|
+
const hasFooter = computed(() => __props.columns.some((column) => slots[`${column.key}-footer`]));
|
|
70
|
+
function keyFor(row, index) {
|
|
71
|
+
if (typeof __props.rowKey === "function") return __props.rowKey(row, index);
|
|
72
|
+
if (__props.rowKey != null) return row[__props.rowKey];
|
|
73
|
+
return index;
|
|
74
|
+
}
|
|
75
|
+
function valueFor(row, column) {
|
|
76
|
+
return column.accessor ? column.accessor(row) : row[column.key];
|
|
77
|
+
}
|
|
78
|
+
const directionOf = (column) => sort.value?.key === column.key ? sort.value.direction : void 0;
|
|
79
|
+
function toggleSort(column) {
|
|
80
|
+
const direction = directionOf(column) === "ascending" ? "descending" : "ascending";
|
|
81
|
+
sort.value = {
|
|
82
|
+
key: column.key,
|
|
83
|
+
direction
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const scrollRef = useTemplateRef("scroll");
|
|
87
|
+
const tableRef = useTemplateRef("table");
|
|
88
|
+
const overflows = ref(false);
|
|
89
|
+
function measure() {
|
|
90
|
+
const el = scrollRef.value;
|
|
91
|
+
if (el) overflows.value = el.scrollWidth > el.clientWidth;
|
|
92
|
+
}
|
|
93
|
+
useResizeObserver(scrollRef, measure);
|
|
94
|
+
useResizeObserver(tableRef, measure);
|
|
95
|
+
return (_ctx, _cache) => {
|
|
96
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" Focusable when it overflows, so keyboard users can scroll it. "), createElementVNode("div", {
|
|
97
|
+
ref: "scroll",
|
|
98
|
+
"data-part": "table-scroll",
|
|
99
|
+
tabindex: overflows.value ? 0 : void 0,
|
|
100
|
+
"data-table-overflow": overflows.value || void 0,
|
|
101
|
+
role: __props.caption ? "region" : void 0,
|
|
102
|
+
"aria-labelledby": __props.caption ? unref(captionId) : void 0
|
|
103
|
+
}, [createElementVNode("table", _hoisted_2, [
|
|
104
|
+
__props.caption ? (openBlock(), createElementBlock("caption", {
|
|
105
|
+
key: 0,
|
|
106
|
+
id: unref(captionId),
|
|
107
|
+
"data-part": "table-caption"
|
|
108
|
+
}, toDisplayString(__props.caption), 9, _hoisted_3)) : createCommentVNode("v-if", true),
|
|
109
|
+
hasWidths.value ? (openBlock(), createElementBlock("colgroup", _hoisted_4, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
|
|
110
|
+
return openBlock(), createElementBlock("col", {
|
|
111
|
+
key: column.key,
|
|
112
|
+
style: normalizeStyle({ width: column.width })
|
|
113
|
+
}, null, 4);
|
|
114
|
+
}), 128))])) : createCommentVNode("v-if", true),
|
|
115
|
+
createElementVNode("thead", _hoisted_5, [createElementVNode("tr", _hoisted_6, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
|
|
116
|
+
return openBlock(), createElementBlock("th", {
|
|
117
|
+
key: column.key,
|
|
118
|
+
scope: "col",
|
|
119
|
+
"data-part": "table-cell",
|
|
120
|
+
"data-table-align": column.align || void 0,
|
|
121
|
+
"data-table-numeric": column.numeric || void 0,
|
|
122
|
+
"data-table-sort": directionOf(column),
|
|
123
|
+
"aria-sort": column.sortable ? directionOf(column) ?? "none" : void 0
|
|
124
|
+
}, [column.sortable ? (openBlock(), createElementBlock("button", {
|
|
125
|
+
key: 0,
|
|
126
|
+
type: "button",
|
|
127
|
+
"data-part": "table-sort",
|
|
128
|
+
"data-table-sort": directionOf(column),
|
|
129
|
+
onClick: ($event) => toggleSort(column)
|
|
130
|
+
}, [renderSlot(_ctx.$slots, `${column.key}-header`, { column }, () => [createTextVNode(toDisplayString(column.header), 1)]), createElementVNode("span", _hoisted_9, [renderSlot(_ctx.$slots, "sort-indicator", { direction: directionOf(column) }, () => [directionOf(column) ? (openBlock(), createElementBlock("svg", _hoisted_10, [createElementVNode("path", {
|
|
131
|
+
d: directionOf(column) === "ascending" ? "M8 13V3M4 7l4-4 4 4" : "M8 3v10M4 9l4 4 4-4",
|
|
132
|
+
fill: "none",
|
|
133
|
+
stroke: "currentColor",
|
|
134
|
+
"stroke-width": "1.5",
|
|
135
|
+
"stroke-linecap": "round",
|
|
136
|
+
"stroke-linejoin": "round"
|
|
137
|
+
}, null, 8, _hoisted_11)])) : createCommentVNode("v-if", true)])])], 8, _hoisted_8)) : renderSlot(_ctx.$slots, `${column.key}-header`, { column }, () => [createTextVNode(toDisplayString(column.header), 1)], void 0, 1)], 8, _hoisted_7);
|
|
138
|
+
}), 128))])]),
|
|
139
|
+
createElementVNode("tbody", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.rows, (row, rowIndex) => {
|
|
140
|
+
return openBlock(), createElementBlock("tr", {
|
|
141
|
+
key: keyFor(row, rowIndex),
|
|
142
|
+
"data-part": "table-row"
|
|
143
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
|
|
144
|
+
return openBlock(), createElementBlock("td", {
|
|
145
|
+
key: column.key,
|
|
146
|
+
"data-part": "table-cell",
|
|
147
|
+
"data-table-align": column.align || void 0,
|
|
148
|
+
"data-table-numeric": column.numeric || void 0
|
|
149
|
+
}, [renderSlot(_ctx.$slots, `${column.key}-cell`, {
|
|
150
|
+
row,
|
|
151
|
+
value: valueFor(row, column),
|
|
152
|
+
column,
|
|
153
|
+
rowIndex
|
|
154
|
+
}, () => [createTextVNode(toDisplayString(valueFor(row, column)), 1)])], 8, _hoisted_12);
|
|
155
|
+
}), 128))]);
|
|
156
|
+
}), 128)), !__props.rows.length ? (openBlock(), createElementBlock("tr", _hoisted_13, [createElementVNode("td", {
|
|
157
|
+
"data-part": "table-empty",
|
|
158
|
+
colspan: __props.columns.length
|
|
159
|
+
}, [renderSlot(_ctx.$slots, "empty", {}, () => [createTextVNode(toDisplayString(unref(translations).noData), 1)])], 8, _hoisted_14)])) : createCommentVNode("v-if", true)]),
|
|
160
|
+
hasFooter.value ? (openBlock(), createElementBlock("tfoot", _hoisted_15, [createElementVNode("tr", _hoisted_16, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (column) => {
|
|
161
|
+
return openBlock(), createElementBlock("td", {
|
|
162
|
+
key: column.key,
|
|
163
|
+
"data-part": "table-cell",
|
|
164
|
+
"data-table-align": column.align || void 0,
|
|
165
|
+
"data-table-numeric": column.numeric || void 0
|
|
166
|
+
}, [renderSlot(_ctx.$slots, `${column.key}-footer`, { column })], 8, _hoisted_17);
|
|
167
|
+
}), 128))])])) : createCommentVNode("v-if", true)
|
|
168
|
+
], 512)], 8, _hoisted_1)], 2112);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
//#endregion
|
|
173
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TableColumn, TableSort } from "../../types.js";
|
|
2
|
+
//#region src/components/table/Table.vue.d.ts
|
|
3
|
+
declare const __VLS_export: <T>(__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
|
+
/** Column definitions: `key`, `header`, and optional `accessor`, `align`, `numeric`, `width`. */
|
|
6
|
+
columns: TableColumn<T>[];
|
|
7
|
+
/** Row data. */
|
|
8
|
+
rows: T[];
|
|
9
|
+
/** Stable key per row: a property name or a function. Defaults to the index. */
|
|
10
|
+
rowKey?: keyof T | ((row: T, index: number) => PropertyKey);
|
|
11
|
+
/** Visible caption. Also names the scroll region. */
|
|
12
|
+
caption?: string;
|
|
13
|
+
} & {
|
|
14
|
+
/** The sorted column and direction, set by `sortable` columns' headers. Rows aren't reordered for you. */
|
|
15
|
+
sort?: TableSort;
|
|
16
|
+
}) & {
|
|
17
|
+
"onUpdate:sort"?: ((value: TableSort | undefined) => any) | undefined;
|
|
18
|
+
}> & (typeof globalThis extends {
|
|
19
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
20
|
+
} ? P : {});
|
|
21
|
+
expose: (exposed: {}) => void;
|
|
22
|
+
attrs: any;
|
|
23
|
+
slots: Record<`${string}-cell`, (props: {
|
|
24
|
+
row: T;
|
|
25
|
+
value: unknown;
|
|
26
|
+
column: TableColumn<T>;
|
|
27
|
+
rowIndex: number;
|
|
28
|
+
}) => unknown> & Record<`${string}-header` | `${string}-footer`, (props: {
|
|
29
|
+
column: TableColumn<T>;
|
|
30
|
+
}) => unknown> & {
|
|
31
|
+
/** Shown when there are no rows. */
|
|
32
|
+
empty?: () => unknown;
|
|
33
|
+
/** Replaces a sortable header's direction arrow. */
|
|
34
|
+
"sort-indicator"?: (props: {
|
|
35
|
+
direction: TableSort["direction"] | undefined;
|
|
36
|
+
}) => unknown;
|
|
37
|
+
};
|
|
38
|
+
emit: (event: "update:sort", value: TableSort | undefined) => void;
|
|
39
|
+
}>) => import("vue").VNode & {
|
|
40
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
41
|
+
};
|
|
42
|
+
declare const _default: typeof __VLS_export;
|
|
43
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { _default as default };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useRovingSelection } from "../../composables/use-roving-selection.js";
|
|
2
|
+
import { useSlideIndicator } from "../../composables/use-slide-indicator.js";
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
|
|
4
|
+
//#region src/components/tabs/Tabs.vue
|
|
5
|
+
const _hoisted_1 = { "data-part": "tabs" };
|
|
6
|
+
const _hoisted_2 = [
|
|
7
|
+
"data-tabs-sliding",
|
|
8
|
+
"data-tabs-animate",
|
|
9
|
+
"aria-label"
|
|
10
|
+
];
|
|
11
|
+
const _hoisted_3 = [
|
|
12
|
+
"id",
|
|
13
|
+
"aria-selected",
|
|
14
|
+
"tabindex",
|
|
15
|
+
"disabled",
|
|
16
|
+
"data-tab-selected",
|
|
17
|
+
"onClick"
|
|
18
|
+
];
|
|
19
|
+
const _hoisted_4 = ["aria-labelledby"];
|
|
20
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
21
|
+
__name: "Tabs",
|
|
22
|
+
props: /*@__PURE__*/ mergeModels({
|
|
23
|
+
items: { default: () => [] },
|
|
24
|
+
label: {},
|
|
25
|
+
disabled: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
"modelValue": {},
|
|
31
|
+
"modelModifiers": {}
|
|
32
|
+
}),
|
|
33
|
+
emits: ["update:modelValue"],
|
|
34
|
+
setup(__props) {
|
|
35
|
+
/** The selected tab's value. */
|
|
36
|
+
const model = useModel(__props, "modelValue");
|
|
37
|
+
const uid = useId();
|
|
38
|
+
const panelId = `${uid}-panel`;
|
|
39
|
+
const tabId = (index) => `${uid}-tab-${index}`;
|
|
40
|
+
const activeIndex = computed(() => __props.items.findIndex((item) => item.value === model.value));
|
|
41
|
+
const activeTabId = computed(() => activeIndex.value < 0 ? void 0 : tabId(activeIndex.value));
|
|
42
|
+
const tablistRef = useTemplateRef("tablist");
|
|
43
|
+
const tabRefs = useTemplateRef("tabs");
|
|
44
|
+
const { isTabStop, select, onKeydown } = useRovingSelection({
|
|
45
|
+
items: () => __props.items,
|
|
46
|
+
elements: () => tabRefs.value,
|
|
47
|
+
disabled: () => __props.disabled,
|
|
48
|
+
orientation: () => "horizontal",
|
|
49
|
+
model
|
|
50
|
+
});
|
|
51
|
+
const { style, isMeasured, canAnimate } = useSlideIndicator({
|
|
52
|
+
container: tablistRef,
|
|
53
|
+
items: () => tabRefs.value,
|
|
54
|
+
activeIndex: () => activeIndex.value
|
|
55
|
+
});
|
|
56
|
+
return (_ctx, _cache) => {
|
|
57
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", {
|
|
58
|
+
ref: "tablist",
|
|
59
|
+
role: "tablist",
|
|
60
|
+
"data-part": "tablist",
|
|
61
|
+
"data-tabs-sliding": unref(isMeasured) || void 0,
|
|
62
|
+
"data-tabs-animate": unref(canAnimate) || void 0,
|
|
63
|
+
"aria-label": __props.label,
|
|
64
|
+
onKeydown: _cache[0] || (_cache[0] = (...args) => unref(onKeydown) && unref(onKeydown)(...args))
|
|
65
|
+
}, [
|
|
66
|
+
createCommentVNode(" Hidden until measured with a style binding, not v-show, so the server HTML\n carries the hidden state even from a prebuilt render function. "),
|
|
67
|
+
createElementVNode("span", {
|
|
68
|
+
style: normalizeStyle([unref(style), unref(isMeasured) ? void 0 : { display: "none" }]),
|
|
69
|
+
"data-part": "tab-indicator",
|
|
70
|
+
"aria-hidden": "true"
|
|
71
|
+
}, null, 4),
|
|
72
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
|
|
73
|
+
return openBlock(), createElementBlock("button", {
|
|
74
|
+
id: tabId(i),
|
|
75
|
+
ref_for: true,
|
|
76
|
+
ref: "tabs",
|
|
77
|
+
key: item.value,
|
|
78
|
+
type: "button",
|
|
79
|
+
role: "tab",
|
|
80
|
+
"data-part": "tab",
|
|
81
|
+
"aria-selected": item.value === model.value,
|
|
82
|
+
"aria-controls": panelId,
|
|
83
|
+
tabindex: unref(isTabStop)(item, i) ? 0 : -1,
|
|
84
|
+
disabled: __props.disabled || item.disabled,
|
|
85
|
+
"data-tab-selected": item.value === model.value || void 0,
|
|
86
|
+
onClick: ($event) => unref(select)(item)
|
|
87
|
+
}, [renderSlot(_ctx.$slots, "tab", {
|
|
88
|
+
item,
|
|
89
|
+
selected: item.value === model.value
|
|
90
|
+
}, () => [createTextVNode(toDisplayString(item.label), 1)])], 8, _hoisted_3);
|
|
91
|
+
}), 128))
|
|
92
|
+
], 40, _hoisted_2), createElementVNode("div", {
|
|
93
|
+
id: panelId,
|
|
94
|
+
role: "tabpanel",
|
|
95
|
+
"data-part": "tabpanel",
|
|
96
|
+
tabindex: "0",
|
|
97
|
+
"aria-labelledby": activeTabId.value
|
|
98
|
+
}, [renderSlot(_ctx.$slots, "default", { value: model.value })], 8, _hoisted_4)]);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
//#endregion
|
|
103
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SelectOption } from "../../types.js";
|
|
2
|
+
//#region src/components/tabs/Tabs.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
|
+
/** Tabs to render, in order. */
|
|
6
|
+
items?: SelectOption<T>[];
|
|
7
|
+
/** Accessible name for the tablist. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Disables every tab. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
} & {
|
|
12
|
+
/** The selected tab's value. */
|
|
13
|
+
modelValue?: T;
|
|
14
|
+
}) & {
|
|
15
|
+
"onUpdate:modelValue"?: ((value: T | undefined) => any) | undefined;
|
|
16
|
+
}> & (typeof globalThis extends {
|
|
17
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
18
|
+
} ? P : {});
|
|
19
|
+
expose: (exposed: {}) => void;
|
|
20
|
+
attrs: any;
|
|
21
|
+
slots: {
|
|
22
|
+
/** Panel content for the selected tab. */
|
|
23
|
+
default?(props: {
|
|
24
|
+
value: T | undefined;
|
|
25
|
+
}): unknown;
|
|
26
|
+
/** Tab content. */
|
|
27
|
+
tab?(props: {
|
|
28
|
+
item: SelectOption<T>;
|
|
29
|
+
selected: boolean;
|
|
30
|
+
}): unknown;
|
|
31
|
+
};
|
|
32
|
+
emit: (event: "update:modelValue", value: T | undefined) => void;
|
|
33
|
+
}>) => import("vue").VNode & {
|
|
34
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
35
|
+
};
|
|
36
|
+
declare const _default: typeof __VLS_export;
|
|
37
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { _default as default };
|
|
@@ -0,0 +1,186 @@
|
|
|
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, toDisplayString, unref, useModel, useTemplateRef, vModelText, withDirectives, withModifiers } from "vue";
|
|
5
|
+
//#region src/components/tag-input/TagInput.vue
|
|
6
|
+
const _hoisted_1 = ["data-field-error", "data-field-name"];
|
|
7
|
+
const _hoisted_2 = ["for"];
|
|
8
|
+
const _hoisted_3 = {
|
|
9
|
+
key: 0,
|
|
10
|
+
"data-part": "field-optional"
|
|
11
|
+
};
|
|
12
|
+
const _hoisted_4 = ["data-tag-input-disabled", "data-tag-input-full"];
|
|
13
|
+
const _hoisted_5 = { "data-part": "tag-input-chip-label" };
|
|
14
|
+
const _hoisted_6 = [
|
|
15
|
+
"aria-label",
|
|
16
|
+
"disabled",
|
|
17
|
+
"onClick"
|
|
18
|
+
];
|
|
19
|
+
const _hoisted_7 = [
|
|
20
|
+
"id",
|
|
21
|
+
"placeholder",
|
|
22
|
+
"disabled",
|
|
23
|
+
"aria-invalid",
|
|
24
|
+
"aria-describedby"
|
|
25
|
+
];
|
|
26
|
+
const _hoisted_8 = ["name", "value"];
|
|
27
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
28
|
+
inheritAttrs: false,
|
|
29
|
+
__name: "TagInput",
|
|
30
|
+
props: /*@__PURE__*/ mergeModels({
|
|
31
|
+
label: {},
|
|
32
|
+
hint: {},
|
|
33
|
+
error: { type: [String, Boolean] },
|
|
34
|
+
optional: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
placeholder: {},
|
|
43
|
+
max: {},
|
|
44
|
+
name: {},
|
|
45
|
+
id: {}
|
|
46
|
+
}, {
|
|
47
|
+
"modelValue": {},
|
|
48
|
+
"modelModifiers": {}
|
|
49
|
+
}),
|
|
50
|
+
emits: ["update:modelValue"],
|
|
51
|
+
setup(__props, { expose: __expose }) {
|
|
52
|
+
/** The tags. */
|
|
53
|
+
const model = useModel(__props, "modelValue");
|
|
54
|
+
const { id, hintId, errorId, isError, errorMessage, describedBy } = useField({
|
|
55
|
+
id: () => __props.id,
|
|
56
|
+
hint: () => __props.hint,
|
|
57
|
+
error: () => __props.error
|
|
58
|
+
});
|
|
59
|
+
const translations = useTranslations();
|
|
60
|
+
const inputRef = useTemplateRef("input");
|
|
61
|
+
const draft = ref("");
|
|
62
|
+
const tags = computed(() => model.value ?? []);
|
|
63
|
+
const isFull = computed(() => __props.max != null && tags.value.length >= __props.max);
|
|
64
|
+
/** Adds every non-empty part until `max` is reached. Duplicates are kept. */
|
|
65
|
+
function add(parts) {
|
|
66
|
+
if (__props.disabled) return;
|
|
67
|
+
const fresh = parts.map((part) => part.trim()).filter(Boolean);
|
|
68
|
+
if (!fresh.length) return;
|
|
69
|
+
const room = __props.max == null ? fresh.length : Math.max(__props.max - tags.value.length, 0);
|
|
70
|
+
if (!room) return;
|
|
71
|
+
model.value = [...tags.value, ...fresh.slice(0, room)];
|
|
72
|
+
}
|
|
73
|
+
/** Commits the text field, which always clears, even when `max` is reached. */
|
|
74
|
+
function commit() {
|
|
75
|
+
const value = draft.value;
|
|
76
|
+
draft.value = "";
|
|
77
|
+
add([value]);
|
|
78
|
+
}
|
|
79
|
+
function removeAt(index) {
|
|
80
|
+
if (__props.disabled || index < 0) return;
|
|
81
|
+
model.value = tags.value.filter((_, i) => i !== index);
|
|
82
|
+
inputRef.value?.focus();
|
|
83
|
+
}
|
|
84
|
+
function remove(tag) {
|
|
85
|
+
removeAt(tags.value.indexOf(tag));
|
|
86
|
+
}
|
|
87
|
+
function onKeydown(event) {
|
|
88
|
+
if (__props.disabled) return;
|
|
89
|
+
if (event.key === "Enter" || event.key === ",") {
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
commit();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (event.key === "Backspace" && !draft.value && tags.value.length) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
removeAt(tags.value.length - 1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function onPaste(event) {
|
|
100
|
+
const text = event.clipboardData?.getData("text") ?? "";
|
|
101
|
+
if (!/[,\n]/.test(text)) return;
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
commit();
|
|
104
|
+
add(text.split(/[,\n]/));
|
|
105
|
+
}
|
|
106
|
+
__expose({ focus: () => inputRef.value?.focus() });
|
|
107
|
+
return (_ctx, _cache) => {
|
|
108
|
+
return openBlock(), createElementBlock("div", {
|
|
109
|
+
"data-part": "field",
|
|
110
|
+
"data-field-error": unref(isError) || void 0,
|
|
111
|
+
"data-field-name": __props.name
|
|
112
|
+
}, [
|
|
113
|
+
__props.label ? (openBlock(), createElementBlock("label", {
|
|
114
|
+
key: 0,
|
|
115
|
+
for: unref(id),
|
|
116
|
+
"data-part": "field-label"
|
|
117
|
+
}, [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),
|
|
118
|
+
createElementVNode("div", {
|
|
119
|
+
"data-part": "tag-input-control",
|
|
120
|
+
"data-tag-input-disabled": __props.disabled || void 0,
|
|
121
|
+
"data-tag-input-full": isFull.value || void 0,
|
|
122
|
+
onClick: _cache[1] || (_cache[1] = ($event) => inputRef.value?.focus())
|
|
123
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(tags.value, (tag, index) => {
|
|
124
|
+
return openBlock(), createElementBlock("span", {
|
|
125
|
+
key: `${tag}-${index}`,
|
|
126
|
+
"data-part": "tag-input-chip"
|
|
127
|
+
}, [createElementVNode("span", _hoisted_5, toDisplayString(tag), 1), createElementVNode("button", {
|
|
128
|
+
type: "button",
|
|
129
|
+
"data-part": "tag-input-chip-remove",
|
|
130
|
+
"aria-label": unref(translations).removeItem(tag),
|
|
131
|
+
disabled: __props.disabled,
|
|
132
|
+
onClick: withModifiers(($event) => remove(tag), ["stop"])
|
|
133
|
+
}, [..._cache[2] || (_cache[2] = [createElementVNode("svg", {
|
|
134
|
+
viewBox: "0 0 16 16",
|
|
135
|
+
width: "12",
|
|
136
|
+
height: "12",
|
|
137
|
+
"aria-hidden": "true",
|
|
138
|
+
focusable: "false"
|
|
139
|
+
}, [createElementVNode("path", {
|
|
140
|
+
d: "M4 4l8 8M12 4l-8 8",
|
|
141
|
+
stroke: "currentColor",
|
|
142
|
+
"stroke-width": "1.5",
|
|
143
|
+
"stroke-linecap": "round"
|
|
144
|
+
})], -1)])], 8, _hoisted_6)]);
|
|
145
|
+
}), 128)), withDirectives(createElementVNode("input", mergeProps({
|
|
146
|
+
id: unref(id),
|
|
147
|
+
ref: "input",
|
|
148
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => draft.value = $event)
|
|
149
|
+
}, _ctx.$attrs, {
|
|
150
|
+
type: "text",
|
|
151
|
+
autocomplete: "off",
|
|
152
|
+
placeholder: __props.placeholder,
|
|
153
|
+
disabled: __props.disabled,
|
|
154
|
+
"aria-invalid": unref(isError) || void 0,
|
|
155
|
+
"aria-describedby": unref(describedBy),
|
|
156
|
+
"data-part": "tag-input",
|
|
157
|
+
onKeydown,
|
|
158
|
+
onBlur: commit,
|
|
159
|
+
onPaste
|
|
160
|
+
}), null, 16, _hoisted_7), [[vModelText, draft.value]])], 8, _hoisted_4),
|
|
161
|
+
createCommentVNode(" Buttons don't submit values, so the form gets one hidden input per tag instead. "),
|
|
162
|
+
__props.name ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(tags.value, (tag, index) => {
|
|
163
|
+
return openBlock(), createElementBlock("input", {
|
|
164
|
+
key: index,
|
|
165
|
+
type: "hidden",
|
|
166
|
+
name: __props.name,
|
|
167
|
+
value: tag
|
|
168
|
+
}, null, 8, _hoisted_8);
|
|
169
|
+
}), 128)) : createCommentVNode("v-if", true),
|
|
170
|
+
createVNode(_sfc_main$1, {
|
|
171
|
+
"error-id": unref(errorId),
|
|
172
|
+
"hint-id": unref(hintId),
|
|
173
|
+
"error-message": unref(errorMessage),
|
|
174
|
+
hint: __props.hint
|
|
175
|
+
}, null, 8, [
|
|
176
|
+
"error-id",
|
|
177
|
+
"hint-id",
|
|
178
|
+
"error-message",
|
|
179
|
+
"hint"
|
|
180
|
+
])
|
|
181
|
+
], 8, _hoisted_1);
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
//#endregion
|
|
186
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/components/tag-input/TagInput.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
|
+
/** Appends the `optional` translation to the label. */
|
|
10
|
+
optional?: boolean;
|
|
11
|
+
/** Disables the control and its remove buttons. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Placeholder for the text field. */
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
/** Most tags allowed; unlimited when omitted. */
|
|
16
|
+
max?: number;
|
|
17
|
+
/** Form field name: submits one hidden input per tag. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Id for the text field; generated with `useId()` when omitted. */
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
type __VLS_ModelProps = {
|
|
23
|
+
/** The tags. */
|
|
24
|
+
modelValue?: string[];
|
|
25
|
+
};
|
|
26
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
27
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
28
|
+
focus: () => void | undefined;
|
|
29
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
30
|
+
"update:modelValue": (value: string[] | undefined) => any;
|
|
31
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
32
|
+
"onUpdate:modelValue"?: ((value: string[] | undefined) => any) | undefined;
|
|
33
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
+
declare const _default: typeof __VLS_export;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { _default as default };
|