frontile 0.18.0-alpha.13 → 0.18.0-alpha.15

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 (96) hide show
  1. package/declarations/components/buttons/chip.d.ts +35 -4
  2. package/declarations/components/collections/dropdown.d.ts +18 -0
  3. package/declarations/components/collections/listbox/item.d.ts +13 -0
  4. package/declarations/components/collections/listbox/listbox.d.ts +15 -6
  5. package/declarations/components/forms/autocomplete.d.ts +13 -5
  6. package/declarations/components/forms/checkbox-group.d.ts +20 -0
  7. package/declarations/components/forms/checkbox.d.ts +22 -0
  8. package/declarations/components/forms/form-control.d.ts +49 -0
  9. package/declarations/components/forms/form-description.d.ts +12 -0
  10. package/declarations/components/forms/form-feedback.d.ts +21 -0
  11. package/declarations/components/forms/form.d.ts +1 -1
  12. package/declarations/components/forms/input.d.ts +44 -1
  13. package/declarations/components/forms/label.d.ts +13 -0
  14. package/declarations/components/forms/native-select.d.ts +103 -6
  15. package/declarations/components/forms/radio-group.d.ts +21 -0
  16. package/declarations/components/forms/radio.d.ts +27 -0
  17. package/declarations/components/forms/select/end-content.d.ts +31 -0
  18. package/declarations/components/forms/select/native-mirror.d.ts +44 -0
  19. package/declarations/components/forms/select/select.d.ts +425 -0
  20. package/declarations/components/forms/select/selected-items.d.ts +80 -0
  21. package/declarations/components/forms/select/trigger.d.ts +76 -0
  22. package/declarations/components/forms/select/types.d.ts +411 -0
  23. package/declarations/components/forms/select.d.ts +2 -531
  24. package/declarations/components/forms/textarea.d.ts +35 -0
  25. package/declarations/components/overlays/drawer.d.ts +3 -0
  26. package/declarations/components/overlays/modal.d.ts +3 -0
  27. package/declarations/components/overlays/overlay.d.ts +23 -0
  28. package/declarations/components/overlays/popover.d.ts +62 -0
  29. package/declarations/components/overlays/portal-target.d.ts +5 -1
  30. package/declarations/components/status/progress-bar.d.ts +5 -0
  31. package/declarations/components/utilities/divider.d.ts +14 -0
  32. package/declarations/components/utilities/spinner.d.ts +8 -0
  33. package/declarations/utils/listManager.d.ts +30 -5
  34. package/dist/components/buttons/chip.js +1 -1
  35. package/dist/components/buttons/chip.js.map +1 -1
  36. package/dist/components/collections/dropdown.js +13 -1
  37. package/dist/components/collections/dropdown.js.map +1 -1
  38. package/dist/components/collections/listbox/item.js +13 -1
  39. package/dist/components/collections/listbox/item.js.map +1 -1
  40. package/dist/components/collections/listbox/listbox.js +12 -1
  41. package/dist/components/collections/listbox/listbox.js.map +1 -1
  42. package/dist/components/collections/simple-table/column.js +1 -1
  43. package/dist/components/collections/simple-table/column.js.map +1 -1
  44. package/dist/components/forms/autocomplete.js +0 -3
  45. package/dist/components/forms/autocomplete.js.map +1 -1
  46. package/dist/components/forms/checkbox-group.js.map +1 -1
  47. package/dist/components/forms/checkbox.js.map +1 -1
  48. package/dist/components/forms/field.js +1 -1
  49. package/dist/components/forms/form-control.js +1 -1
  50. package/dist/components/forms/form-control.js.map +1 -1
  51. package/dist/components/forms/form-description.js.map +1 -1
  52. package/dist/components/forms/form-feedback.js.map +1 -1
  53. package/dist/components/forms/index.js +1 -1
  54. package/dist/components/forms/input.js +32 -1
  55. package/dist/components/forms/input.js.map +1 -1
  56. package/dist/components/forms/label.js.map +1 -1
  57. package/dist/components/forms/native-select.js +2 -2
  58. package/dist/components/forms/native-select.js.map +1 -1
  59. package/dist/components/forms/radio-group.js.map +1 -1
  60. package/dist/components/forms/radio.js.map +1 -1
  61. package/dist/components/forms/select/end-content.js +24 -0
  62. package/dist/components/forms/select/end-content.js.map +1 -0
  63. package/dist/components/forms/select/native-mirror.js +29 -0
  64. package/dist/components/forms/select/native-mirror.js.map +1 -0
  65. package/dist/components/forms/select/select.js +599 -0
  66. package/dist/components/forms/select/select.js.map +1 -0
  67. package/dist/components/forms/select/selected-items.js +63 -0
  68. package/dist/components/forms/select/selected-items.js.map +1 -0
  69. package/dist/components/forms/select/trigger.js +30 -0
  70. package/dist/components/forms/select/trigger.js.map +1 -0
  71. package/dist/components/forms/select/types.js +2 -0
  72. package/dist/components/forms/select/types.js.map +1 -0
  73. package/dist/components/forms/select.js +1 -387
  74. package/dist/components/forms/select.js.map +1 -1
  75. package/dist/components/forms/textarea.js.map +1 -1
  76. package/dist/components/overlays/drawer.js.map +1 -1
  77. package/dist/components/overlays/modal.js.map +1 -1
  78. package/dist/components/overlays/overlay.js.map +1 -1
  79. package/dist/components/overlays/popover.js +53 -2
  80. package/dist/components/overlays/popover.js.map +1 -1
  81. package/dist/components/overlays/portal-target.js.map +1 -1
  82. package/dist/components/status/progress-bar.js +8 -1
  83. package/dist/components/status/progress-bar.js.map +1 -1
  84. package/dist/components/utilities/avatar.js +1 -1
  85. package/dist/components/utilities/avatar.js.map +1 -1
  86. package/dist/components/utilities/divider.js +8 -2
  87. package/dist/components/utilities/divider.js.map +1 -1
  88. package/dist/components/utilities/spinner.js +1 -1
  89. package/dist/components/utilities/spinner.js.map +1 -1
  90. package/dist/forms.js +1 -1
  91. package/dist/index.js +1 -1
  92. package/dist/utils/listManager.js +63 -4
  93. package/dist/utils/listManager.js.map +1 -1
  94. package/dist/utils/nested-data.js +10 -1
  95. package/dist/utils/nested-data.js.map +1 -1
  96. package/package.json +4 -4
@@ -0,0 +1,411 @@
1
+ import type { ListboxSignature } from '../../collections/listbox';
2
+ import type { SelectSlots, SelectVariants, SlotsToClasses } from '@frontile/theme';
3
+ import type { useStyles } from '@frontile/theme';
4
+ import type { PopoverSignature, ContentSignature } from '../../overlays/popover';
5
+ import type { FormControlSharedArgs } from '../form-control';
6
+ import type { ChipSignature } from '../../buttons/chip';
7
+ /**
8
+ * One selected option: the single description of a selection every
9
+ * presentation of it reads -- the chips, the comma-joined text, and any custom
10
+ * content a consumer renders per selection.
11
+ */
12
+ interface SelectedItem {
13
+ key: string;
14
+ textValue: string;
15
+ /**
16
+ * The entry of `@items` this selection came from, so a consumer can reach
17
+ * their own object and not just its key and label.
18
+ *
19
+ * Undefined when the option was written out in block form rather than
20
+ * rendered from `@items`: there is no collection entry behind it.
21
+ */
22
+ item?: unknown;
23
+ }
24
+ /**
25
+ * What the `:selectedItem` block is handed for one selected option.
26
+ *
27
+ * Deliberately the same `{ item, key, label }` shape the `:item` block yields,
28
+ * so markup can move between the two blocks without being renamed. It is the
29
+ * public face of {@link SelectedItem}: `label` is that projection's
30
+ * `textValue`.
31
+ */
32
+ interface SelectedItemBlockArg<T = unknown> {
33
+ /**
34
+ * The entry of `@items` this selection came from.
35
+ *
36
+ * Undefined for an option written out in block form rather than rendered
37
+ * from `@items` -- there is no collection entry behind it, so only `key` and
38
+ * `label` are available there.
39
+ */
40
+ item?: T;
41
+ key: string;
42
+ /** The option's text, i.e. what would be rendered without this block. */
43
+ label: string;
44
+ }
45
+ /**
46
+ * Appearance options forwarded to the {@link Chip} rendered for each selected
47
+ * option in multiple selection mode. Derived from {@link ChipSignature} so the
48
+ * two can never drift apart; see {@link MultipleSelectArgs.chip} for the
49
+ * Select-specific defaults applied on top of Chip's own.
50
+ */
51
+ interface SelectChipOptions extends Pick<ChipSignature['Args'], 'radius' | 'withDot'> {
52
+ /**
53
+ * The chip appearance.
54
+ *
55
+ * @defaultValue 'faded'
56
+ */
57
+ appearance?: ChipSignature['Args']['appearance'];
58
+ /**
59
+ * The intent of the chip. Defaults to the Select's own `@intent`.
60
+ */
61
+ intent?: ChipSignature['Args']['intent'];
62
+ /**
63
+ * The size of the chip.
64
+ *
65
+ * @defaultValue 'sm'
66
+ */
67
+ size?: ChipSignature['Args']['size'];
68
+ }
69
+ interface BaseSelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'appearance' | 'intent' | 'disabledKeys' | 'allowEmpty' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
70
+ }
71
+ interface BaseSingleSelectArgs<T> extends BaseSelectArgs<T> {
72
+ /**
73
+ * The currently selected key for single selection mode.
74
+ *
75
+ * **Data Flow:**
76
+ * - Pass this to set the initial selection
77
+ * - Update this in your `onSelectionChange` handler to maintain two-way binding
78
+ * - The component calls `onSelectionChange` whenever the user changes the selection
79
+ *
80
+ * @example
81
+ * ```gts
82
+ * import { tracked } from '@glimmer/tracking';
83
+ *
84
+ * class MyComponent {
85
+ * @tracked selectedKey = 'option1';
86
+ *
87
+ * handleSelectionChange = (key: string | null) => {
88
+ * this.selectedKey = key; // Update parent state
89
+ * }
90
+ *
91
+ * <template>
92
+ * <Select
93
+ * @selectedKey={{this.selectedKey}}
94
+ * @onSelectionChange={{this.handleSelectionChange}}
95
+ * @items={{this.items}}
96
+ * />
97
+ * </template>
98
+ * }
99
+ * ```
100
+ */
101
+ selectedKey?: string | null;
102
+ /**
103
+ * @deprecated Use selectedKey for single selection mode
104
+ */
105
+ selectedKeys?: never;
106
+ /**
107
+ * Callback fired when the selection changes in single mode.
108
+ *
109
+ * Update your `@selectedKey` state in this callback to maintain two-way binding.
110
+ *
111
+ * @param key - The newly selected key, or null if selection was cleared
112
+ */
113
+ onSelectionChange?: (key: string | null) => void;
114
+ }
115
+ interface ExplicitSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
116
+ /**
117
+ * Determines the selection mode of the select component.
118
+ * - 'single': Only one item can be selected at a time.
119
+ */
120
+ selectionMode: 'single';
121
+ /**
122
+ * Not applicable in single selection mode.
123
+ */
124
+ selectedItemsDisplay?: never;
125
+ /**
126
+ * Not applicable in single selection mode.
127
+ */
128
+ chip?: never;
129
+ }
130
+ interface DefaultSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
131
+ /**
132
+ * Determines the selection mode of the select component.
133
+ * - 'single': Only one item can be selected at a time.
134
+ * @defaultValue 'single'
135
+ */
136
+ selectionMode?: undefined;
137
+ /**
138
+ * Not applicable in single selection mode.
139
+ */
140
+ selectedItemsDisplay?: never;
141
+ /**
142
+ * Not applicable in single selection mode.
143
+ */
144
+ chip?: never;
145
+ }
146
+ interface MultipleSelectArgs<T> extends BaseSelectArgs<T> {
147
+ /**
148
+ * Determines the selection mode of the select component.
149
+ * - 'multiple': Allows multiple selections.
150
+ */
151
+ selectionMode: 'multiple';
152
+ /**
153
+ * How the selected options are presented in the trigger.
154
+ *
155
+ * - `'chips'`: each selection renders as a removable {@link Chip}.
156
+ * - `'text'`: the selections render as a comma-joined string.
157
+ *
158
+ * @defaultValue 'chips'
159
+ */
160
+ selectedItemsDisplay?: 'chips' | 'text';
161
+ /**
162
+ * Appearance of the chips rendered for each selected option.
163
+ * Only applies when `@selectedItemsDisplay` is `'chips'` (the default).
164
+ *
165
+ * Options are the same ones {@link Chip} itself accepts (`appearance`,
166
+ * `intent`, `size`, `radius`, `withDot`), but Select applies its own
167
+ * defaults tuned for sitting inside a field, rather than Chip's:
168
+ * - `appearance` defaults to `'faded'`
169
+ * - `intent` defaults to the Select's own `@intent`, so `@intent="primary"`
170
+ * colors the listbox items and the chips together
171
+ * - `size` defaults to `'sm'`
172
+ * - `radius` and `withDot` fall back to Chip's own defaults
173
+ *
174
+ * @example
175
+ * ```gts
176
+ * <Select
177
+ * @selectionMode="multiple"
178
+ * @chip={{hash appearance="outlined" size="md" radius="full"}}
179
+ * />
180
+ * ```
181
+ */
182
+ chip?: SelectChipOptions;
183
+ /**
184
+ * @deprecated Use selectedKeys for multiple selection mode
185
+ */
186
+ selectedKey?: never;
187
+ /**
188
+ * The currently selected keys for multiple selection mode.
189
+ *
190
+ * **Data Flow:**
191
+ * - Pass this to set the initial selection (array of keys)
192
+ * - Update this in your `onSelectionChange` handler to maintain two-way binding
193
+ * - The component calls `onSelectionChange` whenever the user changes the selection
194
+ *
195
+ * @example
196
+ * ```gts
197
+ * import { tracked } from '@glimmer/tracking';
198
+ *
199
+ * class MyComponent {
200
+ * @tracked selectedKeys = ['option1', 'option2'];
201
+ *
202
+ * handleSelectionChange = (keys: string[]) => {
203
+ * this.selectedKeys = keys; // Update parent state
204
+ * }
205
+ *
206
+ * <template>
207
+ * <Select
208
+ * @selectionMode="multiple"
209
+ * @selectedKeys={{this.selectedKeys}}
210
+ * @onSelectionChange={{this.handleSelectionChange}}
211
+ * @items={{this.items}}
212
+ * />
213
+ * </template>
214
+ * }
215
+ * ```
216
+ */
217
+ selectedKeys?: string[];
218
+ /**
219
+ * Callback fired when the selection changes in multiple mode.
220
+ *
221
+ * Update your `@selectedKeys` state in this callback to maintain two-way binding.
222
+ *
223
+ * @param keys - The newly selected keys (empty array if all selections cleared)
224
+ */
225
+ onSelectionChange?: (keys: string[]) => void;
226
+ }
227
+ type SelectArgs<T> = (ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T> | MultipleSelectArgs<T>) & {
228
+ /**
229
+ * The unique identifier for the select component.
230
+ */
231
+ id?: string;
232
+ /**
233
+ * Defines the input size of the select.
234
+ */
235
+ inputSize?: SelectVariants['size'];
236
+ /**
237
+ * Defines the size of the popover dropdown.
238
+ * - 'sm': Small
239
+ * - 'md': Medium
240
+ * - 'lg': Large
241
+ * - 'trigger': Same size as the trigger
242
+ *
243
+ * @defaultValue 'trigger'
244
+ */
245
+ popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';
246
+ /**
247
+ * Custom classes to style different slots within the select component.
248
+ */
249
+ classes?: SlotsToClasses<SelectSlots>;
250
+ /**
251
+ * Whether the select should close upon selecting an item.
252
+ *
253
+ * @defaultValue true
254
+ */
255
+ closeOnItemSelect?: boolean;
256
+ /**
257
+ * Whether scrolling should be blocked when the select dropdown is open.
258
+ *
259
+ * @defaultValue true
260
+ */
261
+ blockScroll?: boolean;
262
+ /**
263
+ * Whether the focus trap should be disabled when the dropdown is open.
264
+ *
265
+ * @defaultValue true
266
+ */
267
+ disableFocusTrap?: boolean;
268
+ /**
269
+ * The placeholder text displayed when no option is selected.
270
+ */
271
+ placeholder?: string;
272
+ /**
273
+ * Whether the select should be disabled, preventing user interaction.
274
+ */
275
+ isDisabled?: boolean;
276
+ /**
277
+ * Allows filtering of the items in the select dropdown.
278
+ * If true, a search input is displayed for filtering.
279
+ *
280
+ * @defaultValue false
281
+ */
282
+ isFilterable?: boolean;
283
+ /**
284
+ * Function to filter the items in the select.
285
+ * The default implementation performs a case-insensitive search.
286
+ *
287
+ * @param itemValue - The value of an item in the dropdown.
288
+ * @param filterValue - The user's input in the filter/search box.
289
+ * @returns A boolean indicating whether the item should be shown.
290
+ */
291
+ filter?: (itemValue: string, filterValue: string) => boolean;
292
+ /**
293
+ * If true, the select will show a loading spinner instead of the dropdown icon.
294
+ */
295
+ isLoading?: boolean;
296
+ /**
297
+ * The name attribute for the select component, useful for form submissions.
298
+ */
299
+ name?: string;
300
+ /**
301
+ * Whether to include a clear button in the select component.
302
+ * If enabled, this allows users to clear the selection.
303
+ * This option ignores the `allowEmpty` setting.
304
+ *
305
+ * @defaultValue false
306
+ */
307
+ isClearable?: boolean;
308
+ /**
309
+ * Controls pointer-events property of startContent.
310
+ * If you want to pass the click event to the input, set it to `none`.
311
+ *
312
+ * @defaultValue 'auto'
313
+ */
314
+ startContentPointerEvents?: 'none' | 'auto';
315
+ /**
316
+ * Controls pointer-events property of endContent.
317
+ * Defaults to `none` to pass click events to the input. If your content
318
+ * needs to capture events, add the `pointer-events-auto` class to that element.
319
+ *
320
+ * @defaultValue 'none'
321
+ */
322
+ endContentPointerEvents?: 'none' | 'auto';
323
+ /**
324
+ * If true, hides the empty content when there are no options available.
325
+ *
326
+ * @defaultValue false
327
+ */
328
+ hideEmptyContent?: boolean;
329
+ /**
330
+ * Callback fired when the select component loses focus.
331
+ */
332
+ onBlur?: () => void;
333
+ };
334
+ interface SelectSignature<T> {
335
+ Args: SelectArgs<T>;
336
+ Element: HTMLDivElement;
337
+ Blocks: ListboxSignature<T>['Blocks'] & {
338
+ /**
339
+ * Content to display at the **beginning** of the select component.
340
+ * This can be an icon, a label, or any custom UI element.
341
+ *
342
+ * Example: A search icon or a custom label.
343
+ */
344
+ startContent: [];
345
+ /**
346
+ * Content to display at the **end** of the select component.
347
+ * This can be an icon, a button, or any custom UI element.
348
+ *
349
+ * Example: A clear button or a dropdown arrow.
350
+ */
351
+ endContent: [];
352
+ /**
353
+ * The content to display when there are no available options.
354
+ * If `hideEmptyContent` argument is true, this content will not be shown.
355
+ */
356
+ emptyContent: [];
357
+ /**
358
+ * Custom content for each *selected* option, in place of its plain text.
359
+ *
360
+ * Renders wherever the selection is drawn as markup: inside the
361
+ * single-mode trigger, inside each chip in multiple mode (the chip chrome,
362
+ * `@chip` options and close button are kept), and once per selection --
363
+ * comma-separated -- under `@selectedItemsDisplay="text"`.
364
+ *
365
+ * **Not** inside a filterable trigger: that is an `<input>`, which cannot
366
+ * hold markup, so a filterable Select still shows the selection as plain
367
+ * text there. The chips beside the input do use the block.
368
+ *
369
+ * Yields the same `{ item, key, label }` the `:item` block does, so the
370
+ * same markup works in both. `item` is undefined for options written in
371
+ * block form rather than rendered from `@items`.
372
+ *
373
+ * Because a block rendering only graphics would otherwise leave the
374
+ * single-mode trigger with no accessible name, supplying this block also
375
+ * gives that (button) trigger an `aria-label` composed from the field
376
+ * label and the selected options' text. That name replaces what the block
377
+ * renders, so a block whose visible text is not the option's `label`
378
+ * should carry the label too, or set `@label`/`@placeholder` to the
379
+ * wording that is visible -- see the guide.
380
+ *
381
+ * @example
382
+ * ```gts
383
+ * <Select @items={{this.users}} as |s|>
384
+ * <:selectedItem as |selected|>
385
+ * <Avatar @src={{selected.item.avatar}} />
386
+ * {{selected.label}}
387
+ * </:selectedItem>
388
+ * </Select>
389
+ * ```
390
+ */
391
+ selectedItem: [SelectedItemBlockArg<T>];
392
+ };
393
+ }
394
+ /**
395
+ * The resolved Tailwind Variants slot functions for the Select, as produced by
396
+ * `useStyles().select(...)`. Passed down to the pieces of the field so every
397
+ * one of them styles itself from the same `tv()` call.
398
+ */
399
+ type SelectClasses = ReturnType<ReturnType<typeof useStyles>['select']>;
400
+ /**
401
+ * {@link SelectChipOptions} with every Select-specific default already applied,
402
+ * so the chips do not have to restate them.
403
+ */
404
+ interface ResolvedSelectChipOptions {
405
+ appearance: NonNullable<SelectChipOptions['appearance']>;
406
+ intent: NonNullable<SelectChipOptions['intent']>;
407
+ size: NonNullable<SelectChipOptions['size']>;
408
+ radius: SelectChipOptions['radius'];
409
+ withDot: boolean;
410
+ }
411
+ export { type SelectClasses, type ResolvedSelectChipOptions, type SelectedItem, type SelectedItemBlockArg, type SelectChipOptions, type BaseSelectArgs, type ExplicitSingleSelectArgs, type DefaultSingleSelectArgs, type MultipleSelectArgs, type SelectArgs, type SelectSignature };