@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.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/dist/components/accordion/Accordion.js +60 -0
  4. package/dist/components/accordion/Accordion.vue.d.ts +28 -0
  5. package/dist/components/accordion/AccordionItem.js +102 -0
  6. package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
  7. package/dist/components/avatar/Avatar.js +52 -0
  8. package/dist/components/avatar/Avatar.vue.d.ts +26 -0
  9. package/dist/components/avatar/AvatarGroup.js +48 -0
  10. package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
  11. package/dist/components/button/Button.js +95 -0
  12. package/dist/components/button/Button.vue.d.ts +74 -0
  13. package/dist/components/button/IconButton.js +47 -0
  14. package/dist/components/button/IconButton.vue.d.ts +115 -0
  15. package/dist/components/checkbox/Checkbox.js +93 -0
  16. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  17. package/dist/components/combobox/Combobox.js +294 -0
  18. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  19. package/dist/components/context-menu/ContextMenu.js +170 -0
  20. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  21. package/dist/components/dialog/ConfirmDialog.js +103 -0
  22. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  23. package/dist/components/dialog/Dialog.js +160 -0
  24. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  25. package/dist/components/field/FieldMessage.js +31 -0
  26. package/dist/components/input/Input.js +111 -0
  27. package/dist/components/input/Input.vue.d.ts +50 -0
  28. package/dist/components/kbd/Kbd.js +48 -0
  29. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  30. package/dist/components/menu/Menu.js +124 -0
  31. package/dist/components/menu/Menu.vue.d.ts +41 -0
  32. package/dist/components/otp-input/OtpInput.js +179 -0
  33. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  34. package/dist/components/popover/Popover.js +83 -0
  35. package/dist/components/popover/Popover.vue.d.ts +37 -0
  36. package/dist/components/radio-group/RadioGroup.js +125 -0
  37. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  38. package/dist/components/segmented/Segmented.js +110 -0
  39. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  40. package/dist/components/select/Select.js +231 -0
  41. package/dist/components/select/Select.vue.d.ts +59 -0
  42. package/dist/components/slider/Slider.js +196 -0
  43. package/dist/components/slider/Slider.vue.d.ts +49 -0
  44. package/dist/components/spin-button/SpinButton.js +231 -0
  45. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  46. package/dist/components/split-button/SplitButton.js +69 -0
  47. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  48. package/dist/components/switch/Switch.js +95 -0
  49. package/dist/components/switch/Switch.vue.d.ts +42 -0
  50. package/dist/components/table/Table.js +173 -0
  51. package/dist/components/table/Table.vue.d.ts +45 -0
  52. package/dist/components/tabs/Tabs.js +99 -0
  53. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  54. package/dist/components/textarea/Textarea.js +118 -0
  55. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  56. package/dist/components/toast/ToastItem.js +91 -0
  57. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  58. package/dist/components/toast/ToastViewport.js +56 -0
  59. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  60. package/dist/components/toolbar/Toolbar.js +91 -0
  61. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  62. package/dist/components/tooltip/Tooltip.js +85 -0
  63. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  64. package/dist/composables/internal/env.js +5 -0
  65. package/dist/composables/internal/is-equal.js +14 -0
  66. package/dist/composables/internal/on-click-outside.js +18 -0
  67. package/dist/composables/internal/standard-schema.d.ts +38 -0
  68. package/dist/composables/internal/use-document-visibility.js +16 -0
  69. package/dist/composables/internal/use-event-listener.js +24 -0
  70. package/dist/composables/internal/use-interval-fn.js +21 -0
  71. package/dist/composables/internal/use-resize-observer.js +21 -0
  72. package/dist/composables/internal/use-timeout-fn.js +25 -0
  73. package/dist/composables/use-accordion.d.ts +9 -0
  74. package/dist/composables/use-accordion.js +10 -0
  75. package/dist/composables/use-combobox.d.ts +44 -0
  76. package/dist/composables/use-combobox.js +185 -0
  77. package/dist/composables/use-field.d.ts +17 -0
  78. package/dist/composables/use-field.js +27 -0
  79. package/dist/composables/use-form.d.ts +44 -0
  80. package/dist/composables/use-form.js +146 -0
  81. package/dist/composables/use-menu.d.ts +26 -0
  82. package/dist/composables/use-menu.js +117 -0
  83. package/dist/composables/use-platform.d.ts +17 -0
  84. package/dist/composables/use-platform.js +126 -0
  85. package/dist/composables/use-popover.d.ts +35 -0
  86. package/dist/composables/use-popover.js +49 -0
  87. package/dist/composables/use-roving-selection.d.ts +22 -0
  88. package/dist/composables/use-roving-selection.js +65 -0
  89. package/dist/composables/use-select.d.ts +31 -0
  90. package/dist/composables/use-select.js +169 -0
  91. package/dist/composables/use-slide-indicator.d.ts +24 -0
  92. package/dist/composables/use-slide-indicator.js +52 -0
  93. package/dist/composables/use-toast.d.ts +23 -0
  94. package/dist/composables/use-toast.js +51 -0
  95. package/dist/config.d.ts +40 -0
  96. package/dist/config.js +35 -0
  97. package/dist/docs/README.md +44 -0
  98. package/dist/docs/changelog.md +14 -0
  99. package/dist/docs/components/accordion.md +100 -0
  100. package/dist/docs/components/avatar-group.md +58 -0
  101. package/dist/docs/components/avatar.md +40 -0
  102. package/dist/docs/components/button.md +109 -0
  103. package/dist/docs/components/checkbox.md +123 -0
  104. package/dist/docs/components/combobox.md +207 -0
  105. package/dist/docs/components/confirm-dialog.md +107 -0
  106. package/dist/docs/components/context-menu.md +98 -0
  107. package/dist/docs/components/dialog.md +127 -0
  108. package/dist/docs/components/icon-button.md +47 -0
  109. package/dist/docs/components/input.md +89 -0
  110. package/dist/docs/components/kbd.md +41 -0
  111. package/dist/docs/components/menu.md +112 -0
  112. package/dist/docs/components/otp-input.md +92 -0
  113. package/dist/docs/components/popover.md +72 -0
  114. package/dist/docs/components/radio-group.md +114 -0
  115. package/dist/docs/components/segmented.md +96 -0
  116. package/dist/docs/components/select.md +129 -0
  117. package/dist/docs/components/slider.md +105 -0
  118. package/dist/docs/components/spin-button.md +73 -0
  119. package/dist/docs/components/split-button.md +64 -0
  120. package/dist/docs/components/switch.md +71 -0
  121. package/dist/docs/components/table.md +241 -0
  122. package/dist/docs/components/tabs.md +106 -0
  123. package/dist/docs/components/textarea.md +46 -0
  124. package/dist/docs/components/toast.md +135 -0
  125. package/dist/docs/components/toolbar.md +71 -0
  126. package/dist/docs/components/tooltip.md +57 -0
  127. package/dist/docs/forms.md +182 -0
  128. package/dist/docs/index.md +11 -0
  129. package/dist/docs/installation.md +73 -0
  130. package/dist/docs/localisation.md +40 -0
  131. package/dist/docs/ssr.md +24 -0
  132. package/dist/docs/styling.md +66 -0
  133. package/dist/index.d.ts +46 -0
  134. package/dist/index.js +44 -0
  135. package/dist/nuxt/module.d.ts +15 -0
  136. package/dist/nuxt/module.js +72 -0
  137. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  138. package/dist/nuxt/runtime/plugin.js +24 -0
  139. package/dist/package.js +4 -0
  140. package/dist/styles/core.css +284 -0
  141. package/dist/translations.d.ts +71 -0
  142. package/dist/translations.js +55 -0
  143. package/dist/types.d.ts +61 -0
  144. package/package.json +93 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 humanonlyweb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,46 @@
1
- # Temporary Holding Version
1
+ # @humanonlyweb/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Headless, accessible, SSR-safe Vue 3 components, for modern browsers. No dependencies besides `vue`.
4
+
5
+ **Docs:** [ui.humanonlyweb.com](https://ui.humanonlyweb.com) · for AI agents: [llms.txt](https://ui.humanonlyweb.com/llms.txt), or the same docs in the package, at `node_modules/@humanonlyweb/ui/dist/docs`
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add @humanonlyweb/ui
11
+ ```
12
+
13
+ **Nuxt**
14
+
15
+ ```ts
16
+ export default defineNuxtConfig({
17
+ modules: ["@humanonlyweb/ui/nuxt"],
18
+ });
19
+ ```
20
+
21
+ **Vue**
22
+
23
+ ```ts
24
+ import { createUi } from "@humanonlyweb/ui";
25
+ import "@humanonlyweb/ui/core.css";
26
+
27
+ createApp(App).use(createUi()).mount("#app");
28
+ ```
29
+
30
+ See [Installation](https://ui.humanonlyweb.com/installation) for options, and [Styling](https://ui.humanonlyweb.com/styling) for how to style the components.
31
+
32
+ ## Development
33
+
34
+ ```bash
35
+ bun install
36
+ bunx playwright install chromium firefox webkit # once, for the browser tests
37
+ bun run build # library and its Markdown docs → dist/
38
+ bun run test # Node (SSR) + Chromium and WebKit; CI adds Firefox
39
+ bun run check # format, lint, types
40
+ bun run typecheck # vue-tsc
41
+ bun run docs # docs site, from source
42
+ ```
43
+
44
+ ## License
45
+
46
+ MIT
@@ -0,0 +1,60 @@
1
+ import { ACCORDION_KEY } from "../../composables/use-accordion.js";
2
+ import { createElementBlock, defineComponent, mergeModels, openBlock, provide, renderSlot, useModel, useTemplateRef } from "vue";
3
+ //#region src/components/accordion/Accordion.vue
4
+ const _sfc_main = /*@__PURE__*/ defineComponent({
5
+ __name: "Accordion",
6
+ props: /*@__PURE__*/ mergeModels({ multiple: {
7
+ type: Boolean,
8
+ default: false
9
+ } }, {
10
+ "modelValue": {},
11
+ "modelModifiers": {}
12
+ }),
13
+ emits: ["update:modelValue"],
14
+ setup(__props) {
15
+ /** Open item value, or values with `multiple`. */
16
+ const model = useModel(__props, "modelValue");
17
+ const openValues = () => {
18
+ const value = model.value;
19
+ if (value == null) return [];
20
+ return Array.isArray(value) ? value : [value];
21
+ };
22
+ provide(ACCORDION_KEY, {
23
+ isOpen: (value) => openValues().includes(value),
24
+ toggle: (value) => {
25
+ const isOpen = openValues().includes(value);
26
+ if (__props.multiple) model.value = isOpen ? openValues().filter((v) => v !== value) : [...openValues(), value];
27
+ else model.value = isOpen ? void 0 : value;
28
+ }
29
+ });
30
+ const rootRef = useTemplateRef("root");
31
+ function onKeydown(event) {
32
+ if (event.defaultPrevented) return;
33
+ const target = event.target;
34
+ if (!(target instanceof HTMLButtonElement) || target.dataset.part !== "accordion-trigger") return;
35
+ const root = rootRef.value;
36
+ const triggers = [...root?.querySelectorAll("[data-part=\"accordion-trigger\"]") ?? []].filter((trigger) => !trigger.disabled && trigger.closest("[data-part=\"accordion\"]") === root);
37
+ const current = triggers.indexOf(target);
38
+ if (current < 0) return;
39
+ const last = triggers.length - 1;
40
+ const next = {
41
+ ArrowDown: current === last ? 0 : current + 1,
42
+ ArrowUp: current === 0 ? last : current - 1,
43
+ Home: 0,
44
+ End: last
45
+ }[event.key];
46
+ if (next === void 0) return;
47
+ event.preventDefault();
48
+ triggers[next]?.focus();
49
+ }
50
+ return (_ctx, _cache) => {
51
+ return openBlock(), createElementBlock("div", {
52
+ ref: "root",
53
+ "data-part": "accordion",
54
+ onKeydown
55
+ }, [renderSlot(_ctx.$slots, "default")], 544);
56
+ };
57
+ }
58
+ });
59
+ //#endregion
60
+ export { _sfc_main as default };
@@ -0,0 +1,28 @@
1
+ //#region src/components/accordion/Accordion.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Allow several items open at once; `v-model` is then a `string[]`. */
4
+ multiple?: boolean;
5
+ };
6
+ type __VLS_Slots = {
7
+ /** `<AccordionItem>`s. */
8
+ default?(): unknown;
9
+ };
10
+ type __VLS_ModelProps = {
11
+ /** Open item value, or values with `multiple`. */
12
+ modelValue?: string | string[];
13
+ };
14
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
15
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ "update:modelValue": (value: string | string[] | undefined) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: string | string[] | undefined) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
+ declare const _default: typeof __VLS_export;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
27
+ //#endregion
28
+ export { _default as default };
@@ -0,0 +1,102 @@
1
+ import { useAccordionItem } from "../../composables/use-accordion.js";
2
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, openBlock, ref, renderSlot, resolveDynamicComponent, toDisplayString, unref, useId, useTemplateRef, watch, withCtx } from "vue";
3
+ //#region src/components/accordion/AccordionItem.vue
4
+ const _hoisted_1 = ["data-accordion-open"];
5
+ const _hoisted_2 = [
6
+ "aria-expanded",
7
+ "disabled",
8
+ "data-accordion-open"
9
+ ];
10
+ const _hoisted_3 = { "data-part": "accordion-title" };
11
+ const _hoisted_4 = {
12
+ "data-part": "accordion-indicator",
13
+ "aria-hidden": "true"
14
+ };
15
+ const _hoisted_5 = [
16
+ "data-accordion-open",
17
+ "hidden",
18
+ "inert"
19
+ ];
20
+ const _hoisted_6 = { "data-part": "accordion-clip" };
21
+ const _hoisted_7 = { "data-part": "accordion-content" };
22
+ const _sfc_main = /*@__PURE__*/ defineComponent({
23
+ __name: "AccordionItem",
24
+ props: {
25
+ value: {},
26
+ title: {},
27
+ disabled: {
28
+ type: Boolean,
29
+ default: false
30
+ },
31
+ level: { default: 3 }
32
+ },
33
+ setup(__props) {
34
+ const { isOpen, toggle } = useAccordionItem();
35
+ const isExpanded = computed(() => isOpen(__props.value));
36
+ const uid = useId();
37
+ const triggerId = `${uid}-trigger`;
38
+ const panelId = `${uid}-panel`;
39
+ const panelRef = useTemplateRef("panel");
40
+ const concealed = ref(!isExpanded.value);
41
+ function isAnimated(el) {
42
+ return getComputedStyle(el).transitionDuration.split(",").some((duration) => Number.parseFloat(duration) > 0);
43
+ }
44
+ watch(isExpanded, (open) => {
45
+ if (open) concealed.value = false;
46
+ else if (!panelRef.value || !isAnimated(panelRef.value)) concealed.value = true;
47
+ });
48
+ function onTransitionend(event) {
49
+ if (event.target === panelRef.value && !isExpanded.value) concealed.value = true;
50
+ }
51
+ function onBeforematch() {
52
+ if (!isExpanded.value) toggle(__props.value);
53
+ }
54
+ return (_ctx, _cache) => {
55
+ return openBlock(), createElementBlock("div", {
56
+ "data-part": "accordion-item",
57
+ "data-accordion-open": isExpanded.value || void 0
58
+ }, [
59
+ (openBlock(), createBlock(resolveDynamicComponent(`h${__props.level}`), { "data-part": "accordion-heading" }, {
60
+ default: withCtx(() => [createElementVNode("button", {
61
+ id: triggerId,
62
+ type: "button",
63
+ "data-part": "accordion-trigger",
64
+ "aria-expanded": isExpanded.value,
65
+ "aria-controls": panelId,
66
+ disabled: __props.disabled,
67
+ "data-accordion-open": isExpanded.value || void 0,
68
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(toggle)(__props.value))
69
+ }, [createElementVNode("span", _hoisted_3, [renderSlot(_ctx.$slots, "title", { open: isExpanded.value }, () => [createTextVNode(toDisplayString(__props.title), 1)])]), createElementVNode("span", _hoisted_4, [renderSlot(_ctx.$slots, "indicator", { open: isExpanded.value }, () => [_cache[1] || (_cache[1] = createElementVNode("svg", {
70
+ viewBox: "0 0 16 16",
71
+ width: "14",
72
+ height: "14",
73
+ focusable: "false"
74
+ }, [createElementVNode("path", {
75
+ d: "M4 6l4 4 4-4",
76
+ fill: "none",
77
+ stroke: "currentColor",
78
+ "stroke-width": "1.5",
79
+ "stroke-linecap": "round",
80
+ "stroke-linejoin": "round"
81
+ })], -1))])])], 8, _hoisted_2)]),
82
+ _: 3
83
+ })),
84
+ createCommentVNode(" Always rendered, so the content is in the server HTML. "),
85
+ createElementVNode("div", {
86
+ id: panelId,
87
+ ref: "panel",
88
+ role: "region",
89
+ "aria-labelledby": triggerId,
90
+ "data-part": "accordion-panel",
91
+ "data-accordion-open": isExpanded.value || void 0,
92
+ hidden: concealed.value ? "until-found" : void 0,
93
+ inert: !isExpanded.value && !concealed.value || void 0,
94
+ onTransitionend,
95
+ onBeforematch
96
+ }, [createElementVNode("div", _hoisted_6, [createElementVNode("div", _hoisted_7, [renderSlot(_ctx.$slots, "default")])])], 40, _hoisted_5)
97
+ ], 8, _hoisted_1);
98
+ };
99
+ }
100
+ });
101
+ //#endregion
102
+ export { _sfc_main as default };
@@ -0,0 +1,33 @@
1
+ //#region src/components/accordion/AccordionItem.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Identifies the item in the accordion's `v-model`. */
4
+ value: string;
5
+ /** Header text. The `title` slot overrides it. */
6
+ title: string;
7
+ /** Prevents toggling. */
8
+ disabled?: boolean;
9
+ /** Heading level wrapping the trigger, to fit the page's outline. */
10
+ level?: 2 | 3 | 4 | 5 | 6;
11
+ };
12
+ type __VLS_Slots = {
13
+ /** Panel content. */
14
+ default?(): unknown;
15
+ /** Replaces the `title` text. */
16
+ title?(props: {
17
+ open: boolean;
18
+ }): unknown;
19
+ /** Replaces the chevron. */
20
+ indicator?(props: {
21
+ open: boolean;
22
+ }): unknown;
23
+ };
24
+ 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>;
25
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
26
+ declare const _default: typeof __VLS_export;
27
+ type __VLS_WithSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
32
+ //#endregion
33
+ export { _default as default };
@@ -0,0 +1,52 @@
1
+ import { computed, createCommentVNode, createElementBlock, createTextVNode, defineComponent, onMounted, openBlock, ref, renderSlot, toDisplayString, useTemplateRef, watch } from "vue";
2
+ //#region src/components/avatar/Avatar.vue
3
+ const _hoisted_1 = ["data-avatar-size", "aria-label"];
4
+ const _hoisted_2 = ["src"];
5
+ const _sfc_main = /*@__PURE__*/ defineComponent({
6
+ __name: "Avatar",
7
+ props: {
8
+ name: {},
9
+ src: {},
10
+ size: { default: "medium" }
11
+ },
12
+ setup(__props) {
13
+ const imageFailed = ref(false);
14
+ const imageLoaded = ref(false);
15
+ watch(() => __props.src, () => {
16
+ imageFailed.value = false;
17
+ imageLoaded.value = false;
18
+ });
19
+ const imageRef = useTemplateRef("image");
20
+ onMounted(() => {
21
+ const img = imageRef.value;
22
+ if (!img?.complete) return;
23
+ if (img.naturalWidth === 0) imageFailed.value = true;
24
+ else imageLoaded.value = true;
25
+ });
26
+ const showImage = computed(() => Boolean(__props.src) && !imageFailed.value);
27
+ const showFallback = computed(() => !showImage.value || !imageLoaded.value);
28
+ const initials = computed(() => {
29
+ const words = __props.name.trim().split(/\s+/).filter(Boolean);
30
+ if (!words.length) return "";
31
+ return (words.length === 1 ? [words[0]] : [words[0], words.at(-1)]).map((word) => Array.from(word)[0].toUpperCase()).join("");
32
+ });
33
+ return (_ctx, _cache) => {
34
+ return openBlock(), createElementBlock("span", {
35
+ "data-part": "avatar",
36
+ "data-avatar-size": __props.size,
37
+ role: "img",
38
+ "aria-label": __props.name
39
+ }, [showFallback.value ? renderSlot(_ctx.$slots, "fallback", { initials: initials.value }, () => [createTextVNode(toDisplayString(initials.value), 1)], void 0, 0) : createCommentVNode("v-if", true), showImage.value ? (openBlock(), createElementBlock("img", {
40
+ key: 1,
41
+ ref: "image",
42
+ src: __props.src,
43
+ alt: "",
44
+ "data-part": "avatar-image",
45
+ onLoad: _cache[0] || (_cache[0] = ($event) => imageLoaded.value = true),
46
+ onError: _cache[1] || (_cache[1] = ($event) => imageFailed.value = true)
47
+ }, null, 40, _hoisted_2)) : createCommentVNode("v-if", true)], 8, _hoisted_1);
48
+ };
49
+ }
50
+ });
51
+ //#endregion
52
+ export { _sfc_main as default };
@@ -0,0 +1,26 @@
1
+ import { AvatarSize } from "../../types.js";
2
+ //#region src/components/avatar/Avatar.vue.d.ts
3
+ type __VLS_Props = {
4
+ /** Accessible name, and the source of the initials fallback. */
5
+ name: string;
6
+ /** Image URL. Falls back to initials if it's missing or fails to load. */
7
+ src?: string;
8
+ /** Size hook, exposed as `data-avatar-size`. */
9
+ size?: AvatarSize;
10
+ };
11
+ type __VLS_Slots = {
12
+ /** Shown without an image. Defaults to the initials. */
13
+ fallback?(props: {
14
+ initials: string;
15
+ }): unknown;
16
+ };
17
+ 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>;
18
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
19
+ declare const _default: typeof __VLS_export;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
25
+ //#endregion
26
+ export { _default as default };
@@ -0,0 +1,48 @@
1
+ import _sfc_main$1 from "./Avatar.js";
2
+ import { useTranslations } from "../../config.js";
3
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, openBlock, renderList, toDisplayString } from "vue";
4
+ //#region src/components/avatar/AvatarGroup.vue
5
+ const _hoisted_1 = ["data-avatar-size"];
6
+ const _hoisted_2 = ["data-avatar-size", "aria-label"];
7
+ const _sfc_main = /*@__PURE__*/ defineComponent({
8
+ __name: "AvatarGroup",
9
+ props: {
10
+ items: { default: () => [] },
11
+ max: {},
12
+ size: { default: "medium" },
13
+ overflowLabel: { type: Function }
14
+ },
15
+ setup(__props) {
16
+ const isCapped = computed(() => __props.max != null && __props.items.length > __props.max);
17
+ const visibleItems = computed(() => isCapped.value ? __props.items.slice(0, Math.max(__props.max - 1, 0)) : __props.items);
18
+ const hiddenCount = computed(() => __props.items.length - visibleItems.value.length);
19
+ const translations = useTranslations();
20
+ const overflowName = computed(() => (__props.overflowLabel ?? translations.value.moreAvatars)(hiddenCount.value));
21
+ return (_ctx, _cache) => {
22
+ return openBlock(), createElementBlock("div", {
23
+ "data-part": "avatar-group",
24
+ "data-avatar-size": __props.size
25
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(visibleItems.value, (item, i) => {
26
+ return openBlock(), createBlock(_sfc_main$1, {
27
+ key: item.id ?? `${item.name}-${i}`,
28
+ name: item.name,
29
+ src: item.src,
30
+ size: __props.size
31
+ }, null, 8, [
32
+ "name",
33
+ "src",
34
+ "size"
35
+ ]);
36
+ }), 128)), hiddenCount.value > 0 ? (openBlock(), createElementBlock("span", {
37
+ key: 0,
38
+ "data-part": "avatar",
39
+ "data-avatar-overflow": "",
40
+ "data-avatar-size": __props.size,
41
+ role: "img",
42
+ "aria-label": overflowName.value
43
+ }, " +" + toDisplayString(hiddenCount.value), 9, _hoisted_2)) : createCommentVNode("v-if", true)], 8, _hoisted_1);
44
+ };
45
+ }
46
+ });
47
+ //#endregion
48
+ export { _sfc_main as default };
@@ -0,0 +1,16 @@
1
+ import { AvatarItem, AvatarSize } from "../../types.js";
2
+ //#region src/components/avatar/AvatarGroup.vue.d.ts
3
+ type __VLS_Props = {
4
+ /** People to show, in order. */
5
+ items?: AvatarItem[];
6
+ /** Most circles to show, counting the "+N" chip: `max` 4 shows 3 avatars and "+N". */
7
+ max?: number;
8
+ /** Size passed to every avatar. */
9
+ size?: AvatarSize;
10
+ /** Spoken name of the "+N" chip, e.g. `(n) => \`${n} more recipients\``. Defaults to the `moreAvatars` translation. */
11
+ overflowLabel?: (count: number) => string;
12
+ };
13
+ declare const __VLS_export: 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>;
14
+ declare const _default: typeof __VLS_export;
15
+ //#endregion
16
+ export { _default as default };
@@ -0,0 +1,95 @@
1
+ import { useUiConfig } from "../../config.js";
2
+ import { computed, createBlock, createCommentVNode, createElementBlock, defineComponent, mergeProps, openBlock, renderSlot, resolveDynamicComponent, withCtx } from "vue";
3
+ //#region src/components/button/Button.vue
4
+ const _hoisted_1 = {
5
+ key: 0,
6
+ "data-part": "button-spinner",
7
+ "aria-hidden": "true"
8
+ };
9
+ const _hoisted_2 = {
10
+ key: 1,
11
+ "data-part": "button-label"
12
+ };
13
+ const _sfc_main = /*@__PURE__*/ defineComponent({
14
+ __name: "Button",
15
+ props: {
16
+ variant: {},
17
+ size: {},
18
+ fullWidth: { type: Boolean },
19
+ loading: { type: Boolean },
20
+ disabled: { type: Boolean },
21
+ type: {},
22
+ href: {},
23
+ to: {},
24
+ target: {}
25
+ },
26
+ setup(__props) {
27
+ const props = __props;
28
+ const { link } = useUiConfig();
29
+ const isDisabled = computed(() => Boolean(props.disabled || props.loading));
30
+ const routerTo = computed(() => props.to != null && link ? props.to : void 0);
31
+ const href = computed(() => props.href ?? (typeof props.to === "string" && !link ? props.to : void 0));
32
+ const isLink = computed(() => routerTo.value != null || href.value != null);
33
+ const tag = computed(() => {
34
+ if (isLink.value && isDisabled.value) return "a";
35
+ if (routerTo.value != null) return link;
36
+ if (href.value != null) return "a";
37
+ return "button";
38
+ });
39
+ const elementProps = computed(() => {
40
+ if (isLink.value) {
41
+ if (isDisabled.value) return {
42
+ role: "link",
43
+ "aria-disabled": "true",
44
+ tabindex: -1
45
+ };
46
+ return routerTo.value != null ? {
47
+ to: routerTo.value,
48
+ target: props.target
49
+ } : {
50
+ href: href.value,
51
+ target: props.target
52
+ };
53
+ }
54
+ return {
55
+ type: props.type ?? "button",
56
+ disabled: props.disabled,
57
+ "aria-disabled": props.loading || void 0
58
+ };
59
+ });
60
+ function blockWhileInert(event) {
61
+ if (!isDisabled.value) return;
62
+ event.preventDefault();
63
+ event.stopImmediatePropagation();
64
+ }
65
+ return (_ctx, _cache) => {
66
+ return openBlock(), createBlock(resolveDynamicComponent(tag.value), mergeProps(elementProps.value, {
67
+ "data-part": "button",
68
+ "data-button-variant": __props.variant ?? "primary",
69
+ "data-button-size": __props.size ?? "medium",
70
+ "data-button-full-width": __props.fullWidth || void 0,
71
+ "data-button-disabled": isDisabled.value || void 0,
72
+ "data-button-loading": __props.loading || void 0,
73
+ "aria-busy": __props.loading || void 0,
74
+ onClick: blockWhileInert
75
+ }), {
76
+ default: withCtx(() => [
77
+ renderSlot(_ctx.$slots, "leading"),
78
+ __props.loading ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "spinner")])) : createCommentVNode("v-if", true),
79
+ _ctx.$slots.default ? (openBlock(), createElementBlock("span", _hoisted_2, [renderSlot(_ctx.$slots, "default")])) : createCommentVNode("v-if", true),
80
+ renderSlot(_ctx.$slots, "trailing")
81
+ ]),
82
+ _: 3
83
+ }, 16, [
84
+ "data-button-variant",
85
+ "data-button-size",
86
+ "data-button-full-width",
87
+ "data-button-disabled",
88
+ "data-button-loading",
89
+ "aria-busy"
90
+ ]);
91
+ };
92
+ }
93
+ });
94
+ //#endregion
95
+ export { _sfc_main as default };
@@ -0,0 +1,74 @@
1
+ import { ButtonSize, ButtonType, ButtonVariant, LinkTarget, LinkTo } from "../../types.js";
2
+ //#region src/components/button/Button.vue.d.ts
3
+ type BaseButtonProps = {
4
+ /** Style hook, exposed as `data-button-variant`. */
5
+ variant?: ButtonVariant;
6
+ /** Size hook, exposed as `data-button-size`. */
7
+ size?: ButtonSize;
8
+ /** Layout hook, exposed as `data-button-full-width`. */
9
+ fullWidth?: boolean;
10
+ /** Busy state: blocks clicks and sets `aria-busy`, but stays focusable. */
11
+ loading?: boolean;
12
+ /** Disables the button. A disabled link loses its `href` and leaves the tab order. */
13
+ disabled?: boolean;
14
+ };
15
+ type __VLS_Slots = {
16
+ /** Label. */
17
+ default?(): unknown;
18
+ /** Before the label, e.g. an icon. */
19
+ leading?(): unknown;
20
+ /** After the label, e.g. an icon. */
21
+ trailing?(): unknown;
22
+ /** Shown while `loading`. */
23
+ spinner?(): unknown;
24
+ };
25
+ declare const __VLS_base: import("vue").DefineComponent<(BaseButtonProps & {
26
+ /** Native button type. */
27
+ type?: ButtonType;
28
+ href?: never;
29
+ to?: never;
30
+ target?: never;
31
+ }) | (BaseButtonProps & {
32
+ /** Route for the router link given to `createUi({ link })`, rendering it instead of a `<button>`. */
33
+ to: LinkTo;
34
+ href?: never;
35
+ type?: never;
36
+ /** Link target. */
37
+ target?: LinkTarget;
38
+ }) | (BaseButtonProps & {
39
+ /** Renders an `<a>` to this URL instead of a `<button>`. */
40
+ href: string;
41
+ /** Link target. */
42
+ target?: LinkTarget;
43
+ type?: never;
44
+ to?: never;
45
+ }), {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<(BaseButtonProps & {
46
+ /** Native button type. */
47
+ type?: ButtonType;
48
+ href?: never;
49
+ to?: never;
50
+ target?: never;
51
+ }) | (BaseButtonProps & {
52
+ /** Route for the router link given to `createUi({ link })`, rendering it instead of a `<button>`. */
53
+ to: LinkTo;
54
+ href?: never;
55
+ type?: never;
56
+ /** Link target. */
57
+ target?: LinkTarget;
58
+ }) | (BaseButtonProps & {
59
+ /** Renders an `<a>` to this URL instead of a `<button>`. */
60
+ href: string;
61
+ /** Link target. */
62
+ target?: LinkTarget;
63
+ type?: never;
64
+ to?: never;
65
+ })> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
66
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
67
+ declare const _default: typeof __VLS_export;
68
+ type __VLS_WithSlots<T, S> = T & {
69
+ new (): {
70
+ $slots: S;
71
+ };
72
+ };
73
+ //#endregion
74
+ export { _default as default };
@@ -0,0 +1,47 @@
1
+ import _sfc_main$1 from "./Button.js";
2
+ import { createBlock, createPropsRestProxy, createSlots, defineComponent, mergeProps, openBlock, renderSlot, withCtx } from "vue";
3
+ //#region src/components/button/IconButton.vue
4
+ const _sfc_main = /*@__PURE__*/ defineComponent({
5
+ __name: "IconButton",
6
+ props: {
7
+ variant: { default: "ghost" },
8
+ size: {},
9
+ fullWidth: { type: Boolean },
10
+ loading: { type: Boolean },
11
+ disabled: { type: Boolean },
12
+ type: {},
13
+ href: {},
14
+ to: {},
15
+ target: {},
16
+ label: {},
17
+ shape: {}
18
+ },
19
+ setup(__props) {
20
+ const rest = createPropsRestProxy(__props, [
21
+ "label",
22
+ "shape",
23
+ "variant"
24
+ ]);
25
+ return (_ctx, _cache) => {
26
+ return openBlock(), createBlock(_sfc_main$1, mergeProps(rest, {
27
+ variant: __props.variant,
28
+ "aria-label": __props.label,
29
+ "data-button-shape": __props.shape,
30
+ "data-button-icon-only": ""
31
+ }), createSlots({
32
+ spinner: withCtx(() => [renderSlot(_ctx.$slots, "spinner")]),
33
+ _: 2
34
+ }, [!rest.loading ? {
35
+ name: "leading",
36
+ fn: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
37
+ key: "0"
38
+ } : void 0]), 1040, [
39
+ "variant",
40
+ "aria-label",
41
+ "data-button-shape"
42
+ ]);
43
+ };
44
+ }
45
+ });
46
+ //#endregion
47
+ export { _sfc_main as default };