@humanonlyweb/ui 0.1.0 → 0.2.1

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 (48) hide show
  1. package/dist/components/breadcrumbs/Breadcrumbs.js +59 -0
  2. package/dist/components/breadcrumbs/Breadcrumbs.vue.d.ts +14 -0
  3. package/dist/components/checkbox-group/CheckboxGroup.js +89 -0
  4. package/dist/components/checkbox-group/CheckboxGroup.vue.d.ts +43 -0
  5. package/dist/components/fieldset/Fieldset.js +59 -0
  6. package/dist/components/fieldset/Fieldset.vue.d.ts +29 -0
  7. package/dist/components/pagination/Pagination.js +128 -0
  8. package/dist/components/pagination/Pagination.vue.d.ts +24 -0
  9. package/dist/components/password-input/PasswordInput.js +151 -0
  10. package/dist/components/password-input/PasswordInput.vue.d.ts +32 -0
  11. package/dist/components/progress/Progress.js +52 -0
  12. package/dist/components/progress/Progress.vue.d.ts +17 -0
  13. package/dist/components/segmented/Segmented.js +5 -5
  14. package/dist/components/tabs/Tabs.js +29 -25
  15. package/dist/components/tag-input/TagInput.js +186 -0
  16. package/dist/components/tag-input/TagInput.vue.d.ts +36 -0
  17. package/dist/components/toggle/Toggle.js +42 -0
  18. package/dist/components/toggle/Toggle.vue.d.ts +30 -0
  19. package/dist/components/toggle-group/ToggleGroup.js +98 -0
  20. package/dist/components/toggle-group/ToggleGroup.vue.d.ts +41 -0
  21. package/dist/components/visually-hidden/VisuallyHidden.js +16 -0
  22. package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +19 -0
  23. package/dist/docs/README.md +10 -0
  24. package/dist/docs/changelog.md +12 -1
  25. package/dist/docs/components/breadcrumbs.md +81 -0
  26. package/dist/docs/components/checkbox-group.md +118 -0
  27. package/dist/docs/components/fieldset.md +65 -0
  28. package/dist/docs/components/pagination.md +62 -0
  29. package/dist/docs/components/password-input.md +55 -0
  30. package/dist/docs/components/progress.md +56 -0
  31. package/dist/docs/components/tag-input.md +88 -0
  32. package/dist/docs/components/toggle-group.md +125 -0
  33. package/dist/docs/components/toggle.md +81 -0
  34. package/dist/docs/components/visually-hidden.md +53 -0
  35. package/dist/docs/forms.md +1 -1
  36. package/dist/docs/installation.md +0 -2
  37. package/dist/docs/localisation.md +2 -0
  38. package/dist/docs/styling.md +16 -0
  39. package/dist/index.d.ts +44 -28
  40. package/dist/index.js +41 -27
  41. package/dist/nuxt/module.d.ts +1 -1
  42. package/dist/nuxt/module.js +11 -1
  43. package/dist/package.js +1 -1
  44. package/dist/styles/core.css +26 -0
  45. package/dist/translations.d.ts +15 -1
  46. package/dist/translations.js +7 -0
  47. package/dist/types.d.ts +8 -0
  48. package/package.json +1 -1
@@ -0,0 +1,52 @@
1
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeStyle, openBlock, toDisplayString } from "vue";
2
+ //#region src/components/progress/Progress.vue
3
+ const _hoisted_1 = [
4
+ "aria-valuemax",
5
+ "aria-label",
6
+ "aria-valuenow",
7
+ "aria-valuetext",
8
+ "data-progress-indeterminate"
9
+ ];
10
+ const _hoisted_2 = { "data-part": "progress-track" };
11
+ const _hoisted_3 = {
12
+ key: 0,
13
+ "data-part": "progress-value",
14
+ "aria-hidden": "true"
15
+ };
16
+ const _sfc_main = /*@__PURE__*/ defineComponent({
17
+ __name: "Progress",
18
+ props: {
19
+ value: {},
20
+ max: { default: 100 },
21
+ label: {},
22
+ valueText: {},
23
+ showValue: {
24
+ type: Boolean,
25
+ default: false
26
+ }
27
+ },
28
+ setup(__props) {
29
+ const indeterminate = computed(() => __props.value == null || !Number.isFinite(__props.value));
30
+ const maximum = computed(() => __props.max > 0 ? __props.max : 100);
31
+ const clamped = computed(() => indeterminate.value ? 0 : Math.min(Math.max(__props.value ?? 0, 0), maximum.value));
32
+ const percent = computed(() => clamped.value / maximum.value * 100);
33
+ const display = computed(() => __props.valueText ?? `${Math.round(percent.value)}%`);
34
+ return (_ctx, _cache) => {
35
+ return openBlock(), createElementBlock("div", {
36
+ "data-part": "progress",
37
+ role: "progressbar",
38
+ "aria-valuemin": "0",
39
+ "aria-valuemax": maximum.value,
40
+ "aria-label": __props.label,
41
+ "aria-valuenow": indeterminate.value ? void 0 : clamped.value,
42
+ "aria-valuetext": indeterminate.value ? void 0 : __props.valueText,
43
+ "data-progress-indeterminate": indeterminate.value || void 0
44
+ }, [createElementVNode("div", _hoisted_2, [createElementVNode("div", {
45
+ "data-part": "progress-indicator",
46
+ style: normalizeStyle({ "--ui-progress": `${percent.value}%` })
47
+ }, null, 4)]), __props.showValue && !indeterminate.value ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(display.value), 1)) : createCommentVNode("v-if", true)], 8, _hoisted_1);
48
+ };
49
+ }
50
+ });
51
+ //#endregion
52
+ export { _sfc_main as default };
@@ -0,0 +1,17 @@
1
+ //#region src/components/progress/Progress.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Current value. Omit it, or pass a non-finite number, for an indeterminate bar. */
4
+ value?: number;
5
+ /** The value at which the bar is full. */
6
+ max?: number;
7
+ /** Accessible name, e.g. "Uploading". */
8
+ label?: string;
9
+ /** Spoken and displayed text for the value, e.g. "3 of 5 files". Defaults to a percentage. */
10
+ valueText?: string;
11
+ /** Shows the value next to the bar. */
12
+ showValue?: boolean;
13
+ };
14
+ 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>;
15
+ declare const _default: typeof __VLS_export;
16
+ //#endregion
17
+ export { _default as default };
@@ -1,6 +1,6 @@
1
1
  import { useRovingSelection } from "../../composables/use-roving-selection.js";
2
2
  import { useSlideIndicator } from "../../composables/use-slide-indicator.js";
3
- import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef, vShow, withDirectives } from "vue";
3
+ import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useModel, useTemplateRef } from "vue";
4
4
  //#region src/components/segmented/Segmented.vue
5
5
  const _hoisted_1 = [
6
6
  "data-field-name",
@@ -70,12 +70,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
70
70
  "aria-disabled": __props.disabled || void 0,
71
71
  onKeydown: _cache[0] || (_cache[0] = (...args) => unref(onKeydown) && unref(onKeydown)(...args))
72
72
  }, [
73
- createCommentVNode(" Until measured (e.g. before hydration) style the checked segment itself,\n via [data-segment-checked], so the selection is never invisible. "),
74
- withDirectives(createElementVNode("span", {
73
+ createCommentVNode(" Until measured (e.g. before hydration) style the checked segment itself,\n via [data-segment-checked], so the selection is never invisible. Hiding the\n indicator with a style binding, not v-show, keeps that in the server HTML:\n directives' SSR props don't reach prebuilt render functions. "),
74
+ createElementVNode("span", {
75
+ style: normalizeStyle([unref(style), unref(isMeasured) ? void 0 : { display: "none" }]),
75
76
  "data-part": "segmented-indicator",
76
- style: normalizeStyle(unref(style)),
77
77
  "aria-hidden": "true"
78
- }, null, 4), [[vShow, unref(isMeasured)]]),
78
+ }, null, 4),
79
79
  (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option, i) => {
80
80
  return openBlock(), createElementBlock("button", {
81
81
  ref_for: true,
@@ -1,6 +1,6 @@
1
1
  import { useRovingSelection } from "../../composables/use-roving-selection.js";
2
2
  import { useSlideIndicator } from "../../composables/use-slide-indicator.js";
3
- import { Fragment, computed, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, vShow, withDirectives } from "vue";
3
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeModels, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef } from "vue";
4
4
  //#region src/components/tabs/Tabs.vue
5
5
  const _hoisted_1 = { "data-part": "tabs" };
6
6
  const _hoisted_2 = [
@@ -62,30 +62,34 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
62
62
  "data-tabs-animate": unref(canAnimate) || void 0,
63
63
  "aria-label": __props.label,
64
64
  onKeydown: _cache[0] || (_cache[0] = (...args) => unref(onKeydown) && unref(onKeydown)(...args))
65
- }, [withDirectives(createElementVNode("span", {
66
- "data-part": "tab-indicator",
67
- style: normalizeStyle(unref(style)),
68
- "aria-hidden": "true"
69
- }, null, 4), [[vShow, unref(isMeasured)]]), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item, i) => {
70
- return openBlock(), createElementBlock("button", {
71
- id: tabId(i),
72
- ref_for: true,
73
- ref: "tabs",
74
- key: item.value,
75
- type: "button",
76
- role: "tab",
77
- "data-part": "tab",
78
- "aria-selected": item.value === model.value,
79
- "aria-controls": panelId,
80
- tabindex: unref(isTabStop)(item, i) ? 0 : -1,
81
- disabled: __props.disabled || item.disabled,
82
- "data-tab-selected": item.value === model.value || void 0,
83
- onClick: ($event) => unref(select)(item)
84
- }, [renderSlot(_ctx.$slots, "tab", {
85
- item,
86
- selected: item.value === model.value
87
- }, () => [createTextVNode(toDisplayString(item.label), 1)])], 8, _hoisted_3);
88
- }), 128))], 40, _hoisted_2), createElementVNode("div", {
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", {
89
93
  id: panelId,
90
94
  role: "tabpanel",
91
95
  "data-part": "tabpanel",
@@ -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 };
@@ -0,0 +1,42 @@
1
+ import { createElementBlock, defineComponent, mergeModels, openBlock, renderSlot, useModel } from "vue";
2
+ //#region src/components/toggle/Toggle.vue
3
+ const _hoisted_1 = [
4
+ "data-toggle-pressed",
5
+ "aria-pressed",
6
+ "disabled",
7
+ "aria-label"
8
+ ];
9
+ const _sfc_main = /*@__PURE__*/ defineComponent({
10
+ __name: "Toggle",
11
+ props: /*@__PURE__*/ mergeModels({
12
+ disabled: {
13
+ type: Boolean,
14
+ default: false
15
+ },
16
+ label: {}
17
+ }, {
18
+ "modelValue": {
19
+ type: Boolean,
20
+ default: false
21
+ },
22
+ "modelModifiers": {}
23
+ }),
24
+ emits: ["update:modelValue"],
25
+ setup(__props) {
26
+ /** Whether the button is pressed. */
27
+ const model = useModel(__props, "modelValue");
28
+ return (_ctx, _cache) => {
29
+ return openBlock(), createElementBlock("button", {
30
+ type: "button",
31
+ "data-part": "toggle",
32
+ "data-toggle-pressed": model.value || void 0,
33
+ "aria-pressed": model.value,
34
+ disabled: __props.disabled,
35
+ "aria-label": __props.label,
36
+ onClick: _cache[0] || (_cache[0] = ($event) => model.value = !model.value)
37
+ }, [renderSlot(_ctx.$slots, "default")], 8, _hoisted_1);
38
+ };
39
+ }
40
+ });
41
+ //#endregion
42
+ export { _sfc_main as default };
@@ -0,0 +1,30 @@
1
+ //#region src/components/toggle/Toggle.vue.d.ts
2
+ type __VLS_Props = {
3
+ /** Disables the toggle. */
4
+ disabled?: boolean;
5
+ /** Accessible name when the content is only an icon; otherwise the slot content names it. */
6
+ label?: string;
7
+ };
8
+ type __VLS_Slots = {
9
+ /** The button content. */
10
+ default?(): unknown;
11
+ };
12
+ type __VLS_ModelProps = {
13
+ /** Whether the button is pressed. */
14
+ modelValue?: boolean;
15
+ };
16
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
17
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ "update:modelValue": (value: boolean) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
+ declare const _default: typeof __VLS_export;
24
+ type __VLS_WithSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
29
+ //#endregion
30
+ export { _default as default };
@@ -0,0 +1,98 @@
1
+ import _sfc_main$1 from "../toggle/Toggle.js";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, defineComponent, mergeModels, openBlock, renderList, renderSlot, toDisplayString, useModel, withCtx } from "vue";
3
+ //#region src/components/toggle-group/ToggleGroup.vue
4
+ const _hoisted_1 = [
5
+ "aria-label",
6
+ "data-orientation",
7
+ "data-field-name",
8
+ "data-toggle-group-disabled"
9
+ ];
10
+ const _hoisted_2 = ["name", "value"];
11
+ const _hoisted_3 = ["name", "value"];
12
+ const _sfc_main = /*@__PURE__*/ defineComponent({
13
+ __name: "ToggleGroup",
14
+ props: /*@__PURE__*/ mergeModels({
15
+ options: { default: () => [] },
16
+ label: {},
17
+ multiple: {
18
+ type: Boolean,
19
+ default: false
20
+ },
21
+ orientation: { default: "horizontal" },
22
+ disabled: {
23
+ type: Boolean,
24
+ default: false
25
+ },
26
+ name: {}
27
+ }, {
28
+ "modelValue": {},
29
+ "modelModifiers": {}
30
+ }),
31
+ emits: ["update:modelValue"],
32
+ setup(__props) {
33
+ /** The pressed value; with `multiple`, an array of pressed values. */
34
+ const model = useModel(__props, "modelValue");
35
+ const singleValue = computed(() => Array.isArray(model.value) ? void 0 : model.value);
36
+ const pressedValues = computed(() => {
37
+ if (__props.multiple) return Array.isArray(model.value) ? model.value : [];
38
+ return singleValue.value == null ? [] : [singleValue.value];
39
+ });
40
+ const pressed = computed(() => new Set(pressedValues.value));
41
+ const isPressed = (value) => pressed.value.has(value);
42
+ function toggle(value, on) {
43
+ if (!__props.multiple) {
44
+ if (on) model.value = value;
45
+ return;
46
+ }
47
+ const values = new Set(pressedValues.value);
48
+ if (on) values.add(value);
49
+ else values.delete(value);
50
+ model.value = __props.options.filter((option) => values.has(option.value)).map((option) => option.value);
51
+ }
52
+ return (_ctx, _cache) => {
53
+ return openBlock(), createElementBlock("div", {
54
+ "data-part": "toggle-group",
55
+ role: "group",
56
+ "aria-label": __props.label,
57
+ "data-orientation": __props.orientation,
58
+ "data-field-name": __props.name,
59
+ "data-toggle-group-disabled": __props.disabled || void 0
60
+ }, [
61
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option) => {
62
+ return openBlock(), createBlock(_sfc_main$1, {
63
+ key: option.value,
64
+ "model-value": isPressed(option.value),
65
+ disabled: __props.disabled || option.disabled,
66
+ "onUpdate:modelValue": (on) => toggle(option.value, on)
67
+ }, {
68
+ default: withCtx(() => [renderSlot(_ctx.$slots, "option", {
69
+ option,
70
+ pressed: isPressed(option.value)
71
+ }, () => [createTextVNode(toDisplayString(option.label), 1)])]),
72
+ _: 2
73
+ }, 1032, [
74
+ "model-value",
75
+ "disabled",
76
+ "onUpdate:modelValue"
77
+ ]);
78
+ }), 128)),
79
+ createCommentVNode(" The toggles are buttons, which don't submit values; hidden inputs do. "),
80
+ __props.name ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [__props.multiple ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(pressedValues.value, (value) => {
81
+ return openBlock(), createElementBlock("input", {
82
+ key: value,
83
+ type: "hidden",
84
+ name: __props.name,
85
+ value
86
+ }, null, 8, _hoisted_2);
87
+ }), 128)) : singleValue.value != null ? (openBlock(), createElementBlock("input", {
88
+ key: 1,
89
+ type: "hidden",
90
+ name: __props.name,
91
+ value: singleValue.value
92
+ }, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)], 64)) : createCommentVNode("v-if", true)
93
+ ], 8, _hoisted_1);
94
+ };
95
+ }
96
+ });
97
+ //#endregion
98
+ export { _sfc_main as default };
@@ -0,0 +1,41 @@
1
+ import { SelectOption, SelectValue } from "../../types.js";
2
+ //#region src/components/toggle-group/ToggleGroup.vue.d.ts
3
+ declare const __VLS_export: <T extends SelectValue>(__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
+ /** Toggles to render, in order. */
6
+ options?: SelectOption<T>[];
7
+ /** Accessible name for the group. */
8
+ label?: string;
9
+ /** Allow several options pressed at once; the model is then an array. */
10
+ multiple?: boolean;
11
+ /** Layout hook, exposed as `data-orientation`. */
12
+ orientation?: "horizontal" | "vertical";
13
+ /** Disables every toggle. */
14
+ disabled?: boolean;
15
+ /** Form field name: submits the pressed value with a native form, via hidden inputs. */
16
+ name?: string;
17
+ } & {
18
+ /** The pressed value; with `multiple`, an array of pressed values. */
19
+ modelValue?: T | T[];
20
+ }) & {
21
+ "onUpdate:modelValue"?: ((value: T | T[] | undefined) => any) | undefined;
22
+ }> & (typeof globalThis extends {
23
+ __VLS_PROPS_FALLBACK: infer P;
24
+ } ? P : {});
25
+ expose: (exposed: {}) => void;
26
+ attrs: any;
27
+ slots: {
28
+ /** Toggle content, replacing the label, e.g. an icon. */
29
+ option?(props: {
30
+ option: SelectOption<T>;
31
+ pressed: boolean;
32
+ }): unknown;
33
+ };
34
+ emit: (event: "update:modelValue", value: T | T[] | undefined) => void;
35
+ }>) => import("vue").VNode & {
36
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
37
+ };
38
+ declare const _default: typeof __VLS_export;
39
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
40
+ //#endregion
41
+ export { _default as default };
@@ -0,0 +1,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 };