@eldrajs/ui 0.2.8 → 0.2.9

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 (85) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +259 -87
  3. package/dist/{VariantPicker-CjWUVhlm.js → VariantPicker-Da41_oGA.js} +2244 -1399
  4. package/dist/componentNames.d.ts +1 -1
  5. package/dist/components/button/Button.vue.d.ts +3 -0
  6. package/dist/components/button/types.d.ts +32 -3
  7. package/dist/components/card/ContentCard.vue.d.ts +1 -1
  8. package/dist/components/checkbox/Checkbox.vue.d.ts +2 -0
  9. package/dist/components/checkbox/types.d.ts +12 -1
  10. package/dist/components/chip/Chip.vue.d.ts +4 -3
  11. package/dist/components/dialog/Dialog.vue.d.ts +12 -7
  12. package/dist/components/dialog/types.d.ts +11 -2
  13. package/dist/components/drawer/Drawer.vue.d.ts +1 -0
  14. package/dist/components/field-wrapper/FieldWrapper.vue.d.ts +3 -0
  15. package/dist/components/field-wrapper/RequiredMark.vue.d.ts +15 -0
  16. package/dist/components/field-wrapper/context.d.ts +8 -0
  17. package/dist/components/field-wrapper/types.d.ts +12 -4
  18. package/dist/components/filter-panel/FilterGroup.vue.d.ts +1 -0
  19. package/dist/components/filter-panel/FilterPanel.vue.d.ts +3 -2
  20. package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +1 -0
  21. package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +1 -0
  22. package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +2 -1
  23. package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +1 -0
  24. package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +1 -0
  25. package/dist/components/input/Input.vue.d.ts +7 -2
  26. package/dist/components/input/classes.d.ts +9 -0
  27. package/dist/components/input/reassertValue.d.ts +13 -0
  28. package/dist/components/input/types.d.ts +14 -5
  29. package/dist/components/input/useAdornmentRoom.d.ts +15 -0
  30. package/dist/components/lightbox/Lightbox.vue.d.ts +1 -0
  31. package/dist/components/nav-menu/NavMenu.vue.d.ts +1 -0
  32. package/dist/components/pagination/Pagination.vue.d.ts +154 -0
  33. package/dist/components/pagination/types.d.ts +31 -0
  34. package/dist/components/popover/Popover.vue.d.ts +28 -1
  35. package/dist/components/popover/types.d.ts +57 -3
  36. package/dist/components/product-card/ProductCard.vue.d.ts +1 -1
  37. package/dist/components/radio/Radio.vue.d.ts +33 -0
  38. package/dist/components/radio/RadioGroup.vue.d.ts +4 -0
  39. package/dist/components/radio/recipes.d.ts +37 -0
  40. package/dist/components/radio/types.d.ts +64 -3
  41. package/dist/components/range-slider/RangeSlider.vue.d.ts +1 -0
  42. package/dist/components/search-bar/SearchBar.vue.d.ts +1 -0
  43. package/dist/components/search-modal/SearchModal.vue.d.ts +1 -0
  44. package/dist/components/select/MultiSelect.vue.d.ts +48 -1
  45. package/dist/components/select/Select.vue.d.ts +20 -0
  46. package/dist/components/select/SelectPanel.vue.d.ts +23 -0
  47. package/dist/components/select/SelectTags.vue.d.ts +50 -0
  48. package/dist/components/select/openRegistry.d.ts +14 -4
  49. package/dist/components/select/panelParts.d.ts +28 -2
  50. package/dist/components/select/types.d.ts +45 -7
  51. package/dist/components/select/useOptionList.d.ts +31 -4
  52. package/dist/components/select/usePopover.d.ts +36 -39
  53. package/dist/components/select/useSummaryFit.d.ts +21 -0
  54. package/dist/components/select/useTagRows.d.ts +17 -0
  55. package/dist/components/site-form/SiteForm.vue.d.ts +2 -1
  56. package/dist/components/switch/Switch.vue.d.ts +15 -8
  57. package/dist/components/switch/types.d.ts +25 -1
  58. package/dist/components/tabs/Tab.vue.d.ts +1 -0
  59. package/dist/components/tabs/context.d.ts +6 -2
  60. package/dist/components/tabs/types.d.ts +9 -0
  61. package/dist/components/textarea/Textarea.vue.d.ts +21 -1
  62. package/dist/components/textarea/types.d.ts +11 -2
  63. package/dist/components/toast/Toast.vue.d.ts +2 -0
  64. package/dist/components/toast/Toaster.vue.d.ts +7 -1
  65. package/dist/components/toast/types.d.ts +43 -2
  66. package/dist/components.css +312 -13
  67. package/dist/composables/useDialog.d.ts +7 -3
  68. package/dist/composables/useEldraScope.d.ts +26 -0
  69. package/dist/composables/useFloating.d.ts +21 -8
  70. package/dist/composables/useOverlay.d.ts +10 -5
  71. package/dist/composables/useToast.d.ts +3 -0
  72. package/dist/index.d.ts +7 -4
  73. package/dist/index.js +1296 -405
  74. package/dist/messages/en-US.d.ts +2 -0
  75. package/dist/messages/is-IS.js +1 -0
  76. package/dist/resolver.js +1 -0
  77. package/dist/scoped.css +4623 -0
  78. package/dist/style.css +312 -13
  79. package/dist/tailwind.css +43 -12
  80. package/dist/useMessages-B5nzZghs.js +592 -0
  81. package/dist/vee-validate.js +42 -6
  82. package/dist/vue-i18n/index.d.ts +50 -0
  83. package/dist/vue-i18n/shapes.d.ts +40 -0
  84. package/dist/vue-i18n.js +289 -0
  85. package/package.json +16 -3
@@ -1,6 +1,11 @@
1
1
  import { SelectOption, SelectProps, SelectSize } from './types.js';
2
2
  declare const __VLS_template: () => {
3
3
  __VLS_Slots: {
4
+ leading?: (props: {
5
+ option: SelectOption | undefined;
6
+ open: boolean;
7
+ }) => any;
8
+ } & {
4
9
  value?: (props: {
5
10
  option: SelectOption;
6
11
  }) => any;
@@ -10,8 +15,17 @@ declare const __VLS_template: () => {
10
15
  selected: boolean;
11
16
  active: boolean;
12
17
  }) => any;
18
+ } & {
19
+ optionContent?: (props: {
20
+ option: SelectOption;
21
+ selected: boolean;
22
+ active: boolean;
23
+ match: import('./useOptionList.js').MatchParts | null;
24
+ }) => any;
13
25
  } & {
14
26
  empty?: (props: {}) => any;
27
+ } & {
28
+ loading?: (props: {}) => any;
15
29
  };
16
30
  };
17
31
  type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
@@ -22,6 +36,7 @@ declare const __VLS_base: import('vue').DefineComponent<SelectProps, {}, {}, {},
22
36
  open: () => any;
23
37
  close: () => any;
24
38
  change: (value: string) => any;
39
+ create: (query: string) => any;
25
40
  }, string, import('vue').PublicProps, Readonly<SelectProps> & Readonly<{
26
41
  onClear?: (() => any) | undefined;
27
42
  onSearch?: ((query: string) => any) | undefined;
@@ -29,6 +44,7 @@ declare const __VLS_base: import('vue').DefineComponent<SelectProps, {}, {}, {},
29
44
  onOpen?: (() => any) | undefined;
30
45
  onClose?: (() => any) | undefined;
31
46
  onChange?: ((value: string) => any) | undefined;
47
+ onCreate?: ((query: string) => any) | undefined;
32
48
  }>, {
33
49
  size: SelectSize;
34
50
  name: string;
@@ -36,6 +52,7 @@ declare const __VLS_base: import('vue').DefineComponent<SelectProps, {}, {}, {},
36
52
  modelValue: string;
37
53
  required: boolean;
38
54
  placeholder: string;
55
+ loading: boolean;
39
56
  id: string;
40
57
  leadingIcon: import('../../index.js').IconComponent;
41
58
  disabled: boolean;
@@ -59,6 +76,7 @@ declare const __VLS_base: import('vue').DefineComponent<SelectProps, {}, {}, {},
59
76
  noResults: string;
60
77
  noResultsFor: (query: string) => string;
61
78
  noMatchesFor: (query: string) => string;
79
+ createOption: (query: string) => string;
62
80
  moreSelected: (n: number) => string;
63
81
  removeTag: (label: string) => string;
64
82
  selected: string;
@@ -196,6 +214,8 @@ declare const __VLS_base: import('vue').DefineComponent<SelectProps, {}, {}, {},
196
214
  searchPlaceholder: string;
197
215
  placement: import('./types.js').SelectPlacement;
198
216
  teleport: string | boolean;
217
+ creatable: boolean;
218
+ renderBatch: number;
199
219
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
200
220
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
201
221
  declare const _default: typeof __VLS_export;
@@ -48,6 +48,14 @@ type __VLS_Props = {
48
48
  fallbackLabel?: string;
49
49
  /** Checkbox rows and `aria-multiselectable="true"`. */
50
50
  multiple?: boolean;
51
+ /** Draws the loading row in place of the list and the empty state. */
52
+ loading?: boolean;
53
+ /** The loading row's text. */
54
+ loadingText?: string;
55
+ /** The "Create “query”" row, last in the list; `undefined` draws none. */
56
+ createOption?: SelectOption;
57
+ /** The create row's text ("Create “teal”"). */
58
+ createText?: string;
51
59
  /** Inline position from `useFloating`, and the placement it resolved to. */
52
60
  panelStyle?: Record<string, string>;
53
61
  placement?: string;
@@ -60,6 +68,15 @@ declare const __VLS_template: () => {
60
68
  selected: boolean;
61
69
  active: boolean;
62
70
  }) => any;
71
+ } & {
72
+ optionContent?: (props: {
73
+ option: SelectOption;
74
+ selected: boolean;
75
+ active: boolean;
76
+ match: MatchParts | null;
77
+ }) => any;
78
+ } & {
79
+ loading?: (props: {}) => any;
63
80
  } & {
64
81
  empty?: (props: {}) => any;
65
82
  } & {
@@ -75,18 +92,24 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {
75
92
  search: (query: string) => any;
76
93
  keydown: (event: KeyboardEvent) => any;
77
94
  activate: (value: string) => any;
95
+ scrollEnd: () => any;
78
96
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
79
97
  onSelect?: ((option: SelectOption) => any) | undefined;
80
98
  onSearch?: ((query: string) => any) | undefined;
81
99
  onKeydown?: ((event: KeyboardEvent) => any) | undefined;
82
100
  onActivate?: ((value: string) => any) | undefined;
101
+ onScrollEnd?: (() => any) | undefined;
83
102
  }>, {
84
103
  multiple: boolean;
85
104
  classes: Partial<Record<import('./types.js').SelectPart, string>>;
105
+ loading: boolean;
106
+ createOption: SelectOption;
86
107
  placement: string;
87
108
  activeValue: string;
88
109
  labelledBy: string;
89
110
  fallbackLabel: string;
111
+ loadingText: string;
112
+ createText: string;
90
113
  panelStyle: Record<string, string>;
91
114
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
92
115
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -0,0 +1,50 @@
1
+ import { MultiSelectPart, SelectOption } from './types.js';
2
+ /**
3
+ * A multi-select's chosen values as removable chips: below the control, or inside its field
4
+ * (`inside`, where `more` counts the chips `maxTagRows` hides and the list is `display: contents`,
5
+ * so its chips wrap in the field's own row with the trigger). Internal, so `MultiSelect` draws the
6
+ * one list in either place.
7
+ */
8
+ type __VLS_Props = {
9
+ options: SelectOption[];
10
+ id: string;
11
+ label: string;
12
+ labelledBy?: string;
13
+ inside: boolean;
14
+ classes?: Partial<Record<MultiSelectPart, string>>;
15
+ removable: boolean;
16
+ removeLabel: (label: string) => string;
17
+ more: number;
18
+ moreLabel: string;
19
+ };
20
+ declare const __VLS_template: () => {
21
+ __VLS_Slots: {
22
+ tagItem?: (props: {
23
+ option: SelectOption;
24
+ remove: () => void;
25
+ removable: boolean;
26
+ removeLabel: string;
27
+ }) => any;
28
+ } & {
29
+ tag?: (props: {
30
+ option: SelectOption;
31
+ remove: () => void;
32
+ }) => any;
33
+ };
34
+ };
35
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
36
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
37
+ remove: (value: string) => any;
38
+ deselect: (value: string) => any;
39
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
40
+ onRemove?: ((value: string) => any) | undefined;
41
+ onDeselect?: ((value: string) => any) | undefined;
42
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
43
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
44
+ declare const _default: typeof __VLS_export;
45
+ export default _default;
46
+ type __VLS_WithSlots<T, S> = T & {
47
+ new (): {
48
+ $slots: S;
49
+ };
50
+ };
@@ -1,11 +1,21 @@
1
+ export interface RegisterOpenOptions {
2
+ /** The element the opening popup is anchored to — its trigger. */
3
+ anchor?: Node | null;
4
+ /**
5
+ * Whether a node belongs to the opening popup (its `useOverlay` `isInside`). Asked later, when
6
+ * another popup opens: one whose `anchor` this popup contains is *nested* in it — a `Select` in
7
+ * a `Popover`'s panel — and opening it leaves this one open.
8
+ */
9
+ contains?: (node: Node) => boolean;
10
+ }
1
11
  /**
2
- * Claim the slot and close whatever held it.
12
+ * Claim the slot and close whatever held it — except the popups the new one is nested in.
3
13
  *
4
- * The slot is reassigned *before* the previous popup is closed, so the `unregisterOpen` that
14
+ * The slot is reassigned *before* the previous popups are closed, so the `unregisterOpen` that
5
15
  * closing triggers sees a slot that is no longer its own and leaves the new owner alone.
6
16
  */
7
- export declare function registerOpen(close: () => void): void;
17
+ export declare function registerOpen(close: () => void, options?: RegisterOpenOptions): void;
8
18
  /** Release the slot, if it is still this popup's. */
9
19
  export declare function unregisterOpen(close: () => void): void;
10
- /** The currently open popup's close function, or `null`. Exposed for tests. */
20
+ /** The innermost open popup's close function, or `null`. Exposed for tests. */
11
21
  export declare function currentOpen(): (() => void) | null;
@@ -34,7 +34,10 @@ export type PanelClasses = Partial<Record<SelectPart, string>>;
34
34
  * (or on the teleport target), which is what the README's Customisation section already asks for.
35
35
  */
36
36
  export declare function panelClass(classes: PanelClasses | undefined): string;
37
- /** Spec "Select" → Sizes, Search field: 2.5rem tall, text from 2.125rem, inset focus ring. */
37
+ /**
38
+ * Spec "Select" → Sizes, Search field: 2.5rem tall, text from 2.125rem. No focus ring (a README
39
+ * Deviation): focus sits here whenever the panel is open, so the caret and the active row show it.
40
+ */
38
41
  export declare function searchClass(classes: PanelClasses | undefined): string;
39
42
  export declare function listboxClass(classes: PanelClasses | undefined, hasOptions: boolean): string;
40
43
  /** Spec: "Every group after the first gets a 1px `border` hairline and 0.25rem gap above it." */
@@ -52,7 +55,8 @@ export declare function optionClass(classes: PanelClasses | undefined, option: S
52
55
  selected: boolean;
53
56
  multiple: boolean;
54
57
  }): string;
55
- export declare function optionLabelClass(classes: PanelClasses | undefined, option: SelectOption): string;
58
+ /** A disabled row reads as disabled through the row's `muted` text and cursor, like `Checkbox`. */
59
+ export declare function optionLabelClass(classes: PanelClasses | undefined): string;
56
60
  export declare function optionHintClass(classes: PanelClasses | undefined): string;
57
61
  export declare function optionMetaClass(classes: PanelClasses | undefined, option: SelectOption): string;
58
62
  export declare function optionSwatchClass(classes: PanelClasses | undefined): string;
@@ -75,6 +79,19 @@ export declare function optionBoxClass(classes: PanelClasses | undefined, state:
75
79
  }): string;
76
80
  /** Spec "Select" → Sizes, Empty state: "0.875rem, `muted`, centred, padding 1rem 0.75rem". */
77
81
  export declare function emptyClass(classes: PanelClasses | undefined): string;
82
+ /**
83
+ * The loading row: the empty state's box, with the shared spinner before its text. It stands in
84
+ * for the list and the empty state while a `loading` control's options are being fetched.
85
+ */
86
+ export declare function loadingClass(classes: PanelClasses | undefined): string;
87
+ /**
88
+ * The "Create “query”" row of a `creatable` control: an option row's own box and active fill, with
89
+ * a `plus` where a row draws its mark. After other rows it sits under a group's hairline (drawn
90
+ * by `SelectPanel`), so it reads as an action rather than one more match.
91
+ */
92
+ export declare function createOptionClass(classes: PanelClasses | undefined, state: {
93
+ active: boolean;
94
+ }): string;
78
95
  /**
79
96
  * The tick inside that box (spec "Multi-select" → Sizes: "a `primary-contrast` tick (0.25 × 0.5rem,
80
97
  * 2px stroke)").
@@ -89,3 +106,12 @@ export declare function emptyClass(classes: PanelClasses | undefined): string;
89
106
  * `duration-fast` the way `Checkbox`'s does.
90
107
  */
91
108
  export declare function optionTickClass(selected: boolean): string;
109
+ /**
110
+ * The cell a trigger stacks its chosen value in, with an invisible copy of the placeholder
111
+ * (`data-placeholder`, drawn by `::after`) in the same grid cell: a content-sized trigger keeps at
112
+ * least its placeholder's width once a value is chosen, as a native input keeps its width. The copy
113
+ * is generated content under `visibility: hidden`, so it adds no text and no accessible name.
114
+ */
115
+ export declare const TRIGGER_VALUE_STACK: string;
116
+ /** The chosen value inside `TRIGGER_VALUE_STACK`, in the cell the placeholder copy shares. */
117
+ export declare const TRIGGER_VALUE_CELL = "col-start-1 row-start-1";
@@ -5,8 +5,8 @@ import { IconComponent } from '../icon/types.js';
5
5
  *
6
6
  * Everything past `value`/`label` is the spec's "Rich options" variant: a `swatch` (a colour from
7
7
  * product data), an `icon`, a `hint` line under the label, a `meta` note aligned to the end, and
8
- * `disabled` for a sold-out choice — which the spec asks to *show*, struck through with its
9
- * reason, rather than hide.
8
+ * `disabled` for a choice that cannot change (sold out, or always on) — shown muted, with any reason
9
+ * in `hint` or `meta`, rather than hidden.
10
10
  */
11
11
  export interface SelectOption {
12
12
  /** The value posted, and the one `modelValue` holds when this option is chosen. */
@@ -25,8 +25,13 @@ export interface SelectOption {
25
25
  swatch?: string;
26
26
  /** A decorative icon for this option, shown in the row and in the trigger when it is chosen. */
27
27
  icon?: IconComponent;
28
- /** Sold out / unavailable. Skipped by the arrow keys, cannot be chosen, struck through. */
28
+ /** Sold out, or fixed. Skipped by the arrow keys, cannot be toggled, drawn muted. */
29
29
  disabled?: boolean;
30
+ /**
31
+ * More words the search field matches this option by, beside its label (an icon's tags, a
32
+ * country's code). Never drawn: a row found through a keyword shows its label unhighlighted.
33
+ */
34
+ keywords?: string[];
30
35
  }
31
36
  /**
32
37
  * The parts a consumer can restyle through `classes`, named as the spec's anatomy names them.
@@ -40,7 +45,7 @@ export interface SelectOption {
40
45
  * or a form helper can find it, but the element is `hidden`, so `classes.native` merges onto
41
46
  * nothing and has no effect. Every other part takes classes.
42
47
  */
43
- export type SelectPart = 'root' | 'trigger' | 'leadingIcon' | 'value' | 'placeholder' | 'chevron' | 'clearButton' | 'panel' | 'search' | 'listbox' | 'group' | 'groupLabel' | 'option' | 'optionLabel' | 'optionHint' | 'optionMeta' | 'optionSwatch' | 'optionIcon' | 'optionCheck' | 'empty' | 'native';
48
+ export type SelectPart = 'root' | 'trigger' | 'leadingIcon' | 'value' | 'placeholder' | 'chevron' | 'clearButton' | 'panel' | 'search' | 'listbox' | 'group' | 'groupLabel' | 'option' | 'optionLabel' | 'optionHint' | 'optionMeta' | 'optionSwatch' | 'optionIcon' | 'optionCheck' | 'empty' | 'loading' | 'createOption' | 'native';
44
49
  /** The shared control box, exactly as `Input`'s: 2rem, 2.5rem or 3rem tall. */
45
50
  export type SelectSize = 'sm' | 'md' | 'lg';
46
51
  /**
@@ -90,6 +95,24 @@ export interface SelectProps {
90
95
  * Read once, like `placement`.
91
96
  */
92
97
  teleport?: boolean | string;
98
+ /**
99
+ * Draws the panel's loading row ("Loading", with a spinner, in a polite status region) in place
100
+ * of the list, for options that are still being fetched. The list is not navigable meanwhile.
101
+ */
102
+ loading?: boolean;
103
+ /**
104
+ * Adds a "Create “query”" row at the end of the list while the search field holds a query that
105
+ * no option's label already equals (ignoring case and accents). Choosing it emits `create` with
106
+ * the trimmed query; adding the option, and choosing it, is the consumer's. Turns `searchable`
107
+ * on unless `searchable` says otherwise.
108
+ */
109
+ creatable?: boolean;
110
+ /**
111
+ * Renders the list this many rows at a time: the first batch on open, the next as the list is
112
+ * scrolled near its end or the keyboard moves past the last rendered row. Search still covers
113
+ * every option. For lists of thousands; unset renders every row.
114
+ */
115
+ renderBatch?: number;
93
116
  /** Message overrides for this control alone. */
94
117
  messages?: Partial<UiMessages>;
95
118
  /** Per-part class overrides, merged with `tailwind-merge`. */
@@ -109,7 +132,7 @@ export interface SelectProps {
109
132
  * none either. Both are kept in the union rather than subtracted from it, so that one `classes`
110
133
  * object can be handed to either control.
111
134
  */
112
- export type MultiSelectPart = SelectPart | 'summary' | 'summaryMore' | 'tags' | 'tag' | 'tagRemove' | 'footer' | 'footerCount' | 'footerClear' | 'footerDone';
135
+ export type MultiSelectPart = SelectPart | 'summary' | 'summaryMore' | 'tags' | 'tag' | 'tagRemove' | 'tagMore' | 'field' | 'footer' | 'footerCount' | 'footerClear' | 'footerDone';
113
136
  /**
114
137
  * Everything a `Select` takes except the three the spec redefines: the value is a list, the
115
138
  * placeholder's default is `"Any"` rather than `"Select"`, and there is no `clearable` — "the clear
@@ -122,8 +145,23 @@ export interface MultiSelectProps extends Omit<SelectProps, 'modelValue' | 'plac
122
145
  placeholder?: string;
123
146
  /** The removable tag list under the control. `false` for compact toolbars. */
124
147
  showTags?: boolean;
125
- /** How many labels the trigger lists before the "+N" pill. Defaults to 2. */
126
- maxSummary?: number;
148
+ /**
149
+ * Where the tags go. `'below'` (the default) lists them under the control and summarises the
150
+ * selection in the trigger; `'inside'` draws them in the field itself, which wraps and grows, with
151
+ * the trigger after the last tag. `showTags` and `maxSummary` apply to `'below'` only.
152
+ */
153
+ tagPlacement?: 'below' | 'inside';
154
+ /**
155
+ * With `tagPlacement: 'inside'`, how many rows of tags the field shows before the rest collapse
156
+ * into a "+N" tag. Defaults to 2; `0` shows every tag.
157
+ */
158
+ maxTagRows?: number;
159
+ /**
160
+ * How many labels the trigger lists before the "+N" pill. `'fit'` (the default) lists as many as
161
+ * fit the trigger's width, re-measured as it resizes, and never fewer than one; a number lists
162
+ * exactly that many.
163
+ */
164
+ maxSummary?: number | 'fit';
127
165
  /** Per-part class overrides, merged with `tailwind-merge`. */
128
166
  classes?: Partial<Record<MultiSelectPart, string>>;
129
167
  }
@@ -32,6 +32,11 @@ export declare function matchRange(label: string, rawQuery: string): {
32
32
  * answers first"). Options with no `group` form an unlabelled section of their own.
33
33
  */
34
34
  export declare function groupOptions(list: SelectOption[], idPrefix: string, controlId: string): PanelSection[];
35
+ /**
36
+ * The value of the "Create “query”" row a `creatable` control appends. A control character no
37
+ * merchant value holds, so it never collides with an option's own value.
38
+ */
39
+ export declare const CREATE_VALUE = "\0eldra-create";
35
40
  export interface UseOptionListOptions {
36
41
  /** Every option the control was given, in the order the consumer wrote them. */
37
42
  options: () => SelectOption[];
@@ -40,22 +45,44 @@ export interface UseOptionListOptions {
40
45
  searchable: () => boolean;
41
46
  /** The control's own id, which the group headings' ids are built from. */
42
47
  controlId: () => string;
48
+ /** While loading, no row is visible or reachable. The native select still has every option. */
49
+ loading?: () => boolean;
50
+ /** Whether a query no label equals offers a "Create" row. */
51
+ creatable?: () => boolean;
52
+ /** How many rows to render at a time; `undefined` (or anything below 1) renders all of them. */
53
+ renderBatch?: () => number | undefined;
43
54
  }
44
55
  export interface UseOptionListReturn {
45
- /** The visible options bucketed into the panel's sections. */
56
+ /** The rendered options bucketed into the panel's sections. */
46
57
  sections: ComputedRef<PanelSection[]>;
47
58
  /** *Every* option bucketed, for the hidden native select's `<optgroup>`s. */
48
59
  nativeSections: ComputedRef<PanelSection[]>;
49
- /** The visible rows in DOM order — the section order, not the prop order, once groups interleave. */
60
+ /**
61
+ * Every row the keyboard can reach, in DOM order — the section order, not the prop order, once
62
+ * groups interleave — with the create row, when there is one, last. With `renderBatch` it runs
63
+ * past the rendered rows; reaching one renders it.
64
+ */
50
65
  listOptions: ComputedRef<SelectOption[]>;
51
66
  hasOptions: ComputedRef<boolean>;
52
67
  /** Per option value, where the query matched its label — or `null` when it did not. */
53
68
  highlights: ComputedRef<Map<string, MatchParts | null>>;
69
+ /** The "Create “query”" row, whose `label` is the trimmed query; `undefined` when there is none. */
70
+ createOption: ComputedRef<SelectOption | undefined>;
71
+ /** Render the next batch. The panel calls it when its list is scrolled near the end. */
72
+ renderMore: () => void;
73
+ /**
74
+ * Render every batch up to the row holding `value`, so a keyboard move past the rendered rows
75
+ * lands on a row that exists. Call it synchronously whenever the active row changes.
76
+ */
77
+ reveal: (value: string | undefined) => void;
78
+ /** Back to the first batch, for closing. */
79
+ resetBatch: () => void;
54
80
  }
55
81
  /**
56
- * The list a select panel shows: filtering, grouping and match highlighting.
82
+ * The list a select panel shows: filtering, grouping, match highlighting, the create row and the
83
+ * render batch.
57
84
  *
58
85
  * Shared by `Select` and `MultiSelect`, which differ in what choosing a row *does* and in nothing
59
- * about which rows there are. Pure derivation — no DOM, no state of its own.
86
+ * about which rows there are. No DOM; its one piece of state is how many rows are rendered.
60
87
  */
61
88
  export declare function useOptionList(options: UseOptionListOptions): UseOptionListReturn;
@@ -1,4 +1,5 @@
1
- import { ComputedRef, Ref } from 'vue';
1
+ import { ReferenceElement } from '@floating-ui/vue';
2
+ import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
2
3
  import { FloatingPlacement } from '../../composables/useFloating.js';
3
4
  export interface UsePopoverOptions {
4
5
  /** The control that opens the popup, and the element focus goes back to. */
@@ -7,14 +8,37 @@ export interface UsePopoverOptions {
7
8
  content: Ref<HTMLElement | null> | ComputedRef<HTMLElement | null>;
8
9
  /** Whether the control may open at all (a disabled or read-only field may not). Default `true`. */
9
10
  canOpen?: () => boolean;
10
- /** Read once, like every `useFloating` option. Default `'auto'`. */
11
- placement?: FloatingPlacement;
12
- /** The gap between the control and the panel, in pixels. Default `4` (0.25rem). */
13
- offset?: number;
11
+ /** Default `'auto'`. A ref or getter is followed, as `useFloating` follows it. */
12
+ placement?: MaybeRefOrGetter<FloatingPlacement>;
13
+ /** The gap between the control and the panel, in pixels. Default `4` (0.25rem). Followed. */
14
+ offset?: MaybeRefOrGetter<number | undefined>;
15
+ /** The least room kept between the panel and the viewport edge, in pixels. Default `8`. */
16
+ padding?: MaybeRefOrGetter<number | undefined>;
17
+ /**
18
+ * What the panel is positioned against, when not the trigger: another element, or a Floating UI
19
+ * virtual element (a caret, a pointer position). `null` (the default) means the trigger.
20
+ * Focus still returns to the trigger, and the teleport target is still looked up from it — or
21
+ * from this element, when there is no trigger.
22
+ */
23
+ anchor?: Readonly<Ref<ReferenceElement | null>>;
24
+ /**
25
+ * Take part in "only one open at a time" (`openRegistry`). Default `true`. A getter is asked on
26
+ * every open. `false` opens without closing any other popup, and no other popup's opening
27
+ * closes this one.
28
+ */
29
+ exclusive?: boolean | (() => boolean);
30
+ /** Passed to `useOverlay`. Default `true`. */
31
+ closeOnOutsideClick?: boolean | (() => boolean);
32
+ /** Passed to `useOverlay`. Default: whatever `closeOnOutsideClick` is. */
33
+ closeOnFocusOutside?: boolean | (() => boolean);
34
+ /** Passed to `useOverlay`. Default `true`. */
35
+ closeOnEscape?: boolean | (() => boolean);
36
+ /** Passed to `useOverlay`: return focus to the trigger on `Esc`. Default `true`. */
37
+ returnFocus?: boolean | (() => boolean);
14
38
  /** Give the panel a `minWidth` equal to the control's — and, under `'exact'`, a `maxWidth` too. */
15
39
  matchWidth?: boolean | 'exact';
16
40
  /**
17
- * Where the panel is rendered. Read once, like every `useFloating` option.
41
+ * Where the panel is rendered. Read once.
18
42
  *
19
43
  * - `true` (the default) — through a `<Teleport>` to `document.body`, or to the nearest **open
20
44
  * native `<dialog>`** above the trigger when there is one (see `teleportTo` below).
@@ -110,38 +134,11 @@ export interface UsePopoverReturn {
110
134
  /** Put these two on the trigger to get the label-forwarded-click rule (see below). */
111
135
  onTriggerPointerDown(): void;
112
136
  onTriggerClick(event: MouseEvent): void;
137
+ /** Focus the panel's first tab stop, if it has one. */
138
+ focusFirst(): void;
139
+ /** Whether a node belongs to this popup (`useOverlay`'s `isInside`). */
140
+ isInside(node: EventTarget | null): boolean;
141
+ /** Reposition now — after a virtual `anchor` has moved. */
142
+ update(): void;
113
143
  }
114
- /**
115
- * The open/closed life of a **non-modal popup** anchored to a control: `Select`'s panel,
116
- * `MultiSelect`'s, and the `SearchBar`'s results panel.
117
- *
118
- * Every one of them needs the same six things, and before this composable the first two controls
119
- * held a line-identical copy of all of them:
120
- *
121
- * - **"Only one open at a time"** (`openRegistry`): opening claims a module-level slot and closes
122
- * whatever held it. The handle is stable per instance, so a late close cannot blank out the
123
- * popup that took its place.
124
- * - **Closing** (`useOverlay`): an outside pointer press, focus leaving, `Escape`. Non-modal, so
125
- * nothing is trapped and `Tab` always moves on.
126
- * - **Getting out of the way of the page** (`teleport`): the panel is rendered through a
127
- * `<Teleport>` to `body` — or to the modal `<dialog>` the trigger is in, which is the one place
128
- * `body` would be *behind* — and positioned with floating-ui's `fixed` strategy, so no ancestor's
129
- * `overflow: hidden` clips it and no later stacking context paints over it. `tabRedirect` puts a
130
- * panel that has real tab stops back into the `Tab` walk it left with its place in the DOM.
131
- * - **Positioning** (`useFloating`), plus the `--eldra-popover-origin` the entrance keyframes read,
132
- * so a panel that flips after floating-ui measures changes a custom property rather than its
133
- * `animation-name` (which would replay the entrance).
134
- * - **The open sequence**: open, make a row active, and — only when the call actually changed the
135
- * state — run `afterOpen` a tick later, which is where focus moves into the panel.
136
- * - **The label-forwarded-click latch**: a `<label for>` naming the trigger forwards its click to
137
- * it, and the spec is explicit that clicking a field's label focuses the control **without**
138
- * opening it. A forwarded click is indistinguishable from a real one except that no pointer was
139
- * pressed on the trigger and its `detail` is 0 — the same shape as a programmatic
140
- * `element.click()`. The latch is armed on `pointerdown` and released on the `pointerup` or
141
- * `pointercancel` that follows, wherever it lands: a press that ends off the trigger (a drag, a
142
- * cancelled touch) would otherwise leave the latch standing and arm the *next* click.
143
- *
144
- * What stays with each control is what actually differs: which rows there are, what choosing one
145
- * does, and which element the popup is anchored to.
146
- */
147
144
  export declare function usePopover(options: UsePopoverOptions): UsePopoverReturn;
@@ -0,0 +1,21 @@
1
+ import { Ref } from 'vue';
2
+ /** How many labels a summary lists before the trigger has been measured (server, first paint). */
3
+ export declare const UNMEASURED_SUMMARY = 2;
4
+ /**
5
+ * How many of a multi-select's chosen labels fit in its trigger beside the "+N" pill.
6
+ *
7
+ * `box` is the summary cell, whose width is set by the trigger alone (it carries
8
+ * `contain: inline-size`, so its labels never widen it and the count cannot feed back into the
9
+ * width it is measured against). `run` is an invisible copy of every label, each in its own
10
+ * `[data-label]` span, laid out on one line; `pill` is an invisible pill holding the widest count.
11
+ * The count is the most labels whose run, plus the gap and the pill when any are left over, fits
12
+ * the cell's content box; never fewer than one, which then truncates with an ellipsis.
13
+ *
14
+ * Client only, re-measured whenever the cell resizes or `labels` change. On the server, before the
15
+ * first measurement, and where layout reports no width (a test DOM), it is `UNMEASURED_SUMMARY`.
16
+ */
17
+ export declare function useSummaryFit(box: Ref<HTMLElement | null>, run: Ref<HTMLElement | null>, pill: Ref<HTMLElement | null>, labels: () => readonly string[]): {
18
+ count: Ref<number>;
19
+ mounted: Ref<boolean>;
20
+ measure: () => void;
21
+ };
@@ -0,0 +1,17 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * How many chips an inside tag list shows before `maxRows` would be exceeded, or `null` for all.
4
+ *
5
+ * Every chip is rendered and its row read from its top. When they take more than `maxRows` rows,
6
+ * the chips on the rows allowed are kept and the "+N" chip added, then one chip at a time is
7
+ * dropped until the "+N" fits on those rows as well (never below one chip).
8
+ *
9
+ * Re-measured when `watched` changes (the selection) and when the field's **width** changes; a height change alone is ignored, because hiding chips is what changes the
10
+ * height, and reacting to it would loop.
11
+ *
12
+ * Client only. On the server and wherever layout reports no boxes, every chip shows.
13
+ */
14
+ export declare function useTagRows(field: Ref<HTMLElement | null>, maxRows: () => number, enabled: () => boolean, watched: () => unknown): {
15
+ visible: Ref<number | null>;
16
+ measure: () => Promise<void>;
17
+ };
@@ -23,7 +23,6 @@ declare const __VLS_base: import('vue').DefineComponent<SiteFormProps, {}, {}, {
23
23
  }>, {
24
24
  classes: Partial<Record<import('./types.js').SiteFormPart, string>>;
25
25
  headingLevel: import('../../index.js').FormLayoutHeadingLevel;
26
- layout: import('./types.js').SiteFormLayout;
27
26
  messages: Partial<{
28
27
  clear: string;
29
28
  close: string;
@@ -42,6 +41,7 @@ declare const __VLS_base: import('vue').DefineComponent<SiteFormProps, {}, {}, {
42
41
  noResults: string;
43
42
  noResultsFor: (query: string) => string;
44
43
  noMatchesFor: (query: string) => string;
44
+ createOption: (query: string) => string;
45
45
  moreSelected: (n: number) => string;
46
46
  removeTag: (label: string) => string;
47
47
  selected: string;
@@ -173,6 +173,7 @@ declare const __VLS_base: import('vue').DefineComponent<SiteFormProps, {}, {}, {
173
173
  formPendingTitle: string;
174
174
  formPendingMessage: string;
175
175
  }>;
176
+ layout: import('./types.js').SiteFormLayout;
176
177
  heading: string;
177
178
  definition: import('@eldrajs/sdk').EldraFormDefinition | null;
178
179
  formKey: string;
@@ -1,12 +1,16 @@
1
- import { SwitchProps, SwitchSize } from './types.js';
2
- declare const __VLS_template: () => {
3
- __VLS_Slots: {
4
- default?: (props: {}) => any;
5
- } & {
6
- description?: (props: {}) => any;
7
- };
1
+ import { SwitchProps, SwitchSize, SwitchSlotProps } from './types.js';
2
+ type __VLS_Slots = {
3
+ /** The label. */
4
+ default?: () => unknown;
5
+ /** The second line under the label; `description` is its fallback. */
6
+ description?: () => unknown;
7
+ /** Replaces what the thumb draws (the check icon when on, nothing when off). */
8
+ thumb?: (props: SwitchSlotProps) => unknown;
9
+ /** Drawn on the track where the thumb rests when off, so it shows while the switch is on. */
10
+ trackStart?: (props: SwitchSlotProps) => unknown;
11
+ /** Drawn on the track where the thumb rests when on, so it shows while the switch is off. */
12
+ trackEnd?: (props: SwitchSlotProps) => unknown;
8
13
  };
9
- type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
10
14
  declare const __VLS_base: import('vue').DefineComponent<SwitchProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
11
15
  "update:modelValue": (checked: boolean) => any;
12
16
  change: (checked: boolean) => any;
@@ -18,8 +22,11 @@ declare const __VLS_base: import('vue').DefineComponent<SwitchProps, {}, {}, {},
18
22
  name: string;
19
23
  classes: Partial<Record<import('./types.js').SwitchPart, string>>;
20
24
  modelValue: boolean;
25
+ error: string;
21
26
  id: string;
22
27
  disabled: boolean;
28
+ invalid: boolean;
29
+ requiredMark: boolean;
23
30
  description: string;
24
31
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -1,5 +1,13 @@
1
1
  /** The parts a consumer can restyle through `classes`, named as the spec's anatomy names them. */
2
- export type SwitchPart = 'root' | 'track' | 'thumb' | 'label' | 'description';
2
+ export type SwitchPart = 'root' | 'track' | 'thumb' | 'label' | 'description' | 'trackStart' | 'trackEnd' | 'requiredMark' | 'error' | 'errorIcon';
3
+ /** What the `thumb`, `trackStart` and `trackEnd` slots are handed. Their content is decorative
4
+ * (`aria-hidden`): the switch's name and `aria-checked` carry the meaning. */
5
+ export interface SwitchSlotProps {
6
+ /** On or off. */
7
+ checked: boolean;
8
+ /** Whether the switch is disabled. */
9
+ disabled: boolean;
10
+ }
3
11
  /** The spec's two sizes: the default and the filter-bar/dense-list compact one. */
4
12
  export type SwitchSize = 'md' | 'sm';
5
13
  export interface SwitchProps {
@@ -11,6 +19,22 @@ export interface SwitchProps {
11
19
  description?: string;
12
20
  /** Native `disabled`. */
13
21
  disabled?: boolean;
22
+ /**
23
+ * Shows `FieldWrapper`'s `*` after the label text, with the visually hidden "Required" message
24
+ * (a switch has no native `required` to announce it). Default `false`.
25
+ */
26
+ requiredMark?: boolean;
27
+ /**
28
+ * An error message drawn under the switch in `FieldWrapper`'s error row, linked first in
29
+ * `aria-describedby`, and `aria-invalid="true"` on the switch. The row is a sibling after it.
30
+ */
31
+ error?: string;
32
+ /**
33
+ * `aria-invalid="true"` on the switch without an error row, for a caller that shows its own
34
+ * message, like `RadioGroup`'s `invalid`. The Switch design draws no danger state on the track,
35
+ * so `error` and `invalid` change nothing visual on the control. Default `false`.
36
+ */
37
+ invalid?: boolean;
14
38
  /** The control's id. Comes from the `FieldWrapper` when there is one; this wins over it. */
15
39
  id?: string;
16
40
  /** Native form field name, carried by the hidden mirror `<input type="checkbox">`. */