@frontile/forms 0.17.0-beta.9 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/declarations/components/checkbox-group.d.ts +9 -8
  2. package/declarations/components/checkbox.d.ts +7 -6
  3. package/declarations/components/field-types.d.ts +14 -0
  4. package/declarations/components/field.d.ts +85 -0
  5. package/declarations/components/form-control.d.ts +1 -1
  6. package/declarations/components/form-description.d.ts +0 -1
  7. package/declarations/components/form-feedback.d.ts +0 -1
  8. package/declarations/components/form.d.ts +245 -10
  9. package/declarations/components/icons.d.ts +0 -1
  10. package/declarations/components/input.d.ts +17 -12
  11. package/declarations/components/label.d.ts +4 -5
  12. package/declarations/components/native-select.d.ts +26 -12
  13. package/declarations/components/radio-group.d.ts +7 -8
  14. package/declarations/components/radio.d.ts +7 -6
  15. package/declarations/components/select.d.ts +281 -25
  16. package/declarations/components/switch.d.ts +37 -33
  17. package/declarations/components/textarea.d.ts +8 -7
  18. package/declarations/index.d.ts +3 -1
  19. package/declarations/template-registry.d.ts +0 -1
  20. package/declarations/test-support.d.ts +0 -1
  21. package/declarations/utils/index.d.ts +1 -1
  22. package/declarations/utils/nested-data.d.ts +44 -0
  23. package/declarations/utils/standard-validator.d.ts +151 -0
  24. package/dist/_app_/components/field-types.js +1 -0
  25. package/dist/_app_/components/field.js +1 -0
  26. package/dist/components/checkbox-group.js +1 -1
  27. package/dist/components/checkbox-group.js.map +1 -1
  28. package/dist/components/checkbox.js +8 -2
  29. package/dist/components/checkbox.js.map +1 -1
  30. package/dist/components/field-types.js +2 -0
  31. package/dist/components/field-types.js.map +1 -0
  32. package/dist/components/field.js +103 -0
  33. package/dist/components/field.js.map +1 -0
  34. package/dist/components/form-control.js.map +1 -1
  35. package/dist/components/form-description.js.map +1 -1
  36. package/dist/components/form-feedback.js.map +1 -1
  37. package/dist/components/form.js +12 -42
  38. package/dist/components/form.js.map +1 -1
  39. package/dist/components/icons.js.map +1 -1
  40. package/dist/components/input.js +11 -5
  41. package/dist/components/input.js.map +1 -1
  42. package/dist/components/label.js.map +1 -1
  43. package/dist/components/native-select.js +42 -7
  44. package/dist/components/native-select.js.map +1 -1
  45. package/dist/components/radio-group.js +1 -1
  46. package/dist/components/radio-group.js.map +1 -1
  47. package/dist/components/radio.js +8 -2
  48. package/dist/components/radio.js.map +1 -1
  49. package/dist/components/select.js +229 -13
  50. package/dist/components/select.js.map +1 -1
  51. package/dist/components/switch.js +5 -2
  52. package/dist/components/switch.js.map +1 -1
  53. package/dist/components/textarea.js +8 -2
  54. package/dist/components/textarea.js.map +1 -1
  55. package/dist/form-CVuJDJUq.js +726 -0
  56. package/dist/form-CVuJDJUq.js.map +1 -0
  57. package/dist/index-CeaQc-U7.js.map +1 -1
  58. package/dist/index.js +2 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/{runtime-BPCpkOf1-BKOwiRJp.js → runtime-BPCpkOf1-B5Lbloj7.js} +2 -2
  61. package/dist/{runtime-BPCpkOf1-BKOwiRJp.js.map → runtime-BPCpkOf1-B5Lbloj7.js.map} +1 -1
  62. package/dist/test-support.js +2 -2
  63. package/dist/test-support.js.map +1 -1
  64. package/package.json +12 -8
  65. package/declarations/components/checkbox-group.d.ts.map +0 -1
  66. package/declarations/components/checkbox.d.ts.map +0 -1
  67. package/declarations/components/form-control.d.ts.map +0 -1
  68. package/declarations/components/form-description.d.ts.map +0 -1
  69. package/declarations/components/form-feedback.d.ts.map +0 -1
  70. package/declarations/components/form.d.ts.map +0 -1
  71. package/declarations/components/icons.d.ts.map +0 -1
  72. package/declarations/components/input.d.ts.map +0 -1
  73. package/declarations/components/label.d.ts.map +0 -1
  74. package/declarations/components/native-select.d.ts.map +0 -1
  75. package/declarations/components/radio-group.d.ts.map +0 -1
  76. package/declarations/components/radio.d.ts.map +0 -1
  77. package/declarations/components/select.d.ts.map +0 -1
  78. package/declarations/components/switch.d.ts.map +0 -1
  79. package/declarations/components/textarea.d.ts.map +0 -1
  80. package/declarations/index.d.ts.map +0 -1
  81. package/declarations/template-registry.d.ts.map +0 -1
  82. package/declarations/test-support.d.ts.map +0 -1
  83. package/declarations/utils/index.d.ts.map +0 -1
@@ -1,12 +1,11 @@
1
1
  import Component from '@glimmer/component';
2
+ import type Owner from '@ember/owner';
2
3
  import { type NativeSelectSlots, type NativeSelectVariants, type SlotsToClasses } from '@frontile/theme';
3
4
  import { type FormControlSharedArgs } from './form-control';
4
5
  import { ListManager, type ListItem } from '@frontile/collections/utils/listManager';
5
6
  import type { WithBoundArgs } from '@glint/template';
6
7
  type ItemCompBounded = WithBoundArgs<typeof NativeSelectItem, 'manager'>;
7
- interface Args<T> extends FormControlSharedArgs {
8
- selectionMode?: 'single' | 'multiple';
9
- selectedKeys?: string[];
8
+ interface BaseArgs<T> extends FormControlSharedArgs {
10
9
  disabledKeys?: string[];
11
10
  allowEmpty?: boolean;
12
11
  items?: T[];
@@ -19,7 +18,6 @@ interface Args<T> extends FormControlSharedArgs {
19
18
  */
20
19
  placeholder?: string;
21
20
  onAction?: (key: string) => void;
22
- onSelectionChange?: (key: string[]) => void;
23
21
  /**
24
22
  * @internal
25
23
  */
@@ -41,6 +39,19 @@ interface Args<T> extends FormControlSharedArgs {
41
39
  */
42
40
  endContentPointerEvents?: 'none' | 'auto';
43
41
  }
42
+ interface SingleNativeSelectArgs<T> extends BaseArgs<T> {
43
+ selectionMode?: 'single' | undefined;
44
+ selectedKey?: string | null;
45
+ selectedKeys?: never;
46
+ onSelectionChange?: (key: string | null) => void;
47
+ }
48
+ interface MultipleNativeSelectArgs<T> extends BaseArgs<T> {
49
+ selectionMode: 'multiple';
50
+ selectedKey?: never;
51
+ selectedKeys?: string[];
52
+ onSelectionChange?: (keys: string[]) => void;
53
+ }
54
+ type Args<T> = SingleNativeSelectArgs<T> | MultipleNativeSelectArgs<T>;
44
55
  interface NativeSelectSignature<T> {
45
56
  Args: Args<T>;
46
57
  Element: HTMLSelectElement;
@@ -59,7 +70,11 @@ interface NativeSelectSignature<T> {
59
70
  };
60
71
  }
61
72
  declare class NativeSelect<T = unknown> extends Component<NativeSelectSignature<T>> {
73
+ constructor(owner: Owner, args: Args<T>);
74
+ validateArgs(): void;
75
+ get normalizedSelectedKeys(): string[];
62
76
  listManager: ListManager;
77
+ handleSelectionChange(keys: string[]): void;
63
78
  get classes(): {
64
79
  base: (slotProps?: ({
65
80
  size?: "sm" | "md" | "lg" | undefined;
@@ -67,35 +82,35 @@ declare class NativeSelect<T = unknown> extends Component<NativeSelectSignature<
67
82
  endContentPointerEvents?: "none" | "auto" | undefined;
68
83
  hasStartContent?: boolean | undefined;
69
84
  hasEndContent?: boolean | undefined;
70
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
85
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
71
86
  innerContainer: (slotProps?: ({
72
87
  size?: "sm" | "md" | "lg" | undefined;
73
88
  startContentPointerEvents?: "none" | "auto" | undefined;
74
89
  endContentPointerEvents?: "none" | "auto" | undefined;
75
90
  hasStartContent?: boolean | undefined;
76
91
  hasEndContent?: boolean | undefined;
77
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
92
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
78
93
  startContent: (slotProps?: ({
79
94
  size?: "sm" | "md" | "lg" | undefined;
80
95
  startContentPointerEvents?: "none" | "auto" | undefined;
81
96
  endContentPointerEvents?: "none" | "auto" | undefined;
82
97
  hasStartContent?: boolean | undefined;
83
98
  hasEndContent?: boolean | undefined;
84
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
99
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
85
100
  endContent: (slotProps?: ({
86
101
  size?: "sm" | "md" | "lg" | undefined;
87
102
  startContentPointerEvents?: "none" | "auto" | undefined;
88
103
  endContentPointerEvents?: "none" | "auto" | undefined;
89
104
  hasStartContent?: boolean | undefined;
90
105
  hasEndContent?: boolean | undefined;
91
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
106
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
92
107
  input: (slotProps?: ({
93
108
  size?: "sm" | "md" | "lg" | undefined;
94
109
  startContentPointerEvents?: "none" | "auto" | undefined;
95
110
  endContentPointerEvents?: "none" | "auto" | undefined;
96
111
  hasStartContent?: boolean | undefined;
97
112
  hasEndContent?: boolean | undefined;
98
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
113
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
99
114
  } & {
100
115
  input: (slotProps?: ({
101
116
  size?: "sm" | "md" | "lg" | undefined;
@@ -103,14 +118,14 @@ declare class NativeSelect<T = unknown> extends Component<NativeSelectSignature<
103
118
  endContentPointerEvents?: "none" | "auto" | undefined;
104
119
  hasStartContent?: boolean | undefined;
105
120
  hasEndContent?: boolean | undefined;
106
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
121
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
107
122
  icon: (slotProps?: ({
108
123
  size?: "sm" | "md" | "lg" | undefined;
109
124
  startContentPointerEvents?: "none" | "auto" | undefined;
110
125
  endContentPointerEvents?: "none" | "auto" | undefined;
111
126
  hasStartContent?: boolean | undefined;
112
127
  hasEndContent?: boolean | undefined;
113
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
128
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
114
129
  } & {};
115
130
  get isMultiple(): boolean;
116
131
  handleOnChange(event: Event): void;
@@ -137,4 +152,3 @@ declare class NativeSelectItem extends Component<SelectItemSignature> {
137
152
  }
138
153
  export { NativeSelect, type NativeSelectSignature, type ListItem };
139
154
  export default NativeSelect;
140
- //# sourceMappingURL=native-select.d.ts.map
@@ -15,7 +15,7 @@ interface RadioGroupSignature<T> {
15
15
  Args: Args<T>;
16
16
  Blocks: {
17
17
  default: [
18
- Radio: WithBoundArgs<typeof Radio, 'name' | 'onChange' | 'checkedValue'>
18
+ Radio: WithBoundArgs<typeof Radio, 'name' | 'onChange' | 'checkedValue' | 'isDisabled'>
19
19
  ];
20
20
  };
21
21
  Element: HTMLDivElement;
@@ -24,21 +24,20 @@ declare class RadioGroup<T extends string | number | boolean> extends Component<
24
24
  get classes(): {
25
25
  base: (slotProps?: ({
26
26
  size?: "sm" | "md" | "lg" | undefined;
27
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | ({
27
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
28
28
  size?: "sm" | "md" | "lg" | undefined;
29
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
29
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
30
30
  optionsContainer: (slotProps?: ({
31
31
  size?: "sm" | "md" | "lg" | undefined;
32
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | ({
32
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
33
33
  size?: "sm" | "md" | "lg" | undefined;
34
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
34
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
35
35
  label: (slotProps?: ({
36
36
  size?: "sm" | "md" | "lg" | undefined;
37
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | ({
37
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | ({
38
38
  size?: "sm" | "md" | "lg" | undefined;
39
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
39
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
40
40
  } & {} & {};
41
41
  }
42
42
  export { RadioGroup, type RadioGroupSignature };
43
43
  export default RadioGroup;
44
- //# sourceMappingURL=radio-group.d.ts.map
@@ -8,6 +8,7 @@ interface Args<T> extends FormControlSharedArgs {
8
8
  size?: RadioVariants['size'];
9
9
  classes?: SlotsToClasses<RadioSlots>;
10
10
  onChange?: (value: T, event: Event) => void;
11
+ onBlur?: () => void;
11
12
  }
12
13
  interface RadioSignature<T> {
13
14
  Args: Args<T>;
@@ -16,25 +17,25 @@ interface RadioSignature<T> {
16
17
  declare class Radio<T extends string | boolean | number> extends Component<RadioSignature<T>> {
17
18
  get isChecked(): boolean;
18
19
  handleChange(event: Event): void;
20
+ handleBlur(): void;
19
21
  get classes(): {
20
22
  base: (slotProps?: ({
21
23
  size?: "sm" | "md" | "lg" | undefined;
22
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
24
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
23
25
  input: (slotProps?: ({
24
26
  size?: "sm" | "md" | "lg" | undefined;
25
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
27
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
26
28
  labelContainer: (slotProps?: ({
27
29
  size?: "sm" | "md" | "lg" | undefined;
28
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
30
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
29
31
  label: (slotProps?: ({
30
32
  size?: "sm" | "md" | "lg" | undefined;
31
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
33
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
32
34
  } & {
33
35
  input: (slotProps?: ({
34
36
  size?: "sm" | "md" | "lg" | undefined;
35
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
37
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
36
38
  } & {};
37
39
  }
38
40
  export { Radio, type RadioSignature };
39
41
  export default Radio;
40
- //# sourceMappingURL=radio.d.ts.map
@@ -1,17 +1,122 @@
1
1
  import Component from '@glimmer/component';
2
+ import type Owner from '@ember/owner';
2
3
  import { type ListItem } from './native-select';
3
4
  import { type ListboxSignature } from '@frontile/collections';
4
5
  import { type SelectSlots, type SelectVariants, type SlotsToClasses } from '@frontile/theme';
5
6
  import { type PopoverSignature, type ContentSignature } from '@frontile/overlays';
6
7
  import { type FormControlSharedArgs } from './form-control';
7
- interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'appearance' | 'intent' | 'selectedKeys' | 'disabledKeys' | 'allowEmpty' | 'onSelectionChange' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
8
+ 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 {
9
+ }
10
+ interface BaseSingleSelectArgs<T> extends BaseSelectArgs<T> {
11
+ /**
12
+ * The currently selected key for single selection mode.
13
+ *
14
+ * **Data Flow:**
15
+ * - Pass this to set the initial selection
16
+ * - Update this in your `onSelectionChange` handler to maintain two-way binding
17
+ * - The component calls `onSelectionChange` whenever the user changes the selection
18
+ *
19
+ * @example
20
+ * ```gts
21
+ * import { tracked } from '@glimmer/tracking';
22
+ *
23
+ * class MyComponent {
24
+ * @tracked selectedKey = 'option1';
25
+ *
26
+ * handleSelectionChange = (key: string | null) => {
27
+ * this.selectedKey = key; // Update parent state
28
+ * }
29
+ *
30
+ * <template>
31
+ * <Select
32
+ * @selectedKey={{this.selectedKey}}
33
+ * @onSelectionChange={{this.handleSelectionChange}}
34
+ * @items={{this.items}}
35
+ * />
36
+ * </template>
37
+ * }
38
+ * ```
39
+ */
40
+ selectedKey?: string | null;
41
+ /**
42
+ * @deprecated Use selectedKey for single selection mode
43
+ */
44
+ selectedKeys?: never;
45
+ /**
46
+ * Callback fired when the selection changes in single mode.
47
+ *
48
+ * Update your `@selectedKey` state in this callback to maintain two-way binding.
49
+ *
50
+ * @param key - The newly selected key, or null if selection was cleared
51
+ */
52
+ onSelectionChange?: (key: string | null) => void;
53
+ }
54
+ interface ExplicitSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
55
+ /**
56
+ * Determines the selection mode of the select component.
57
+ * - 'single': Only one item can be selected at a time.
58
+ */
59
+ selectionMode: 'single';
60
+ }
61
+ interface DefaultSingleSelectArgs<T> extends BaseSingleSelectArgs<T> {
8
62
  /**
9
63
  * Determines the selection mode of the select component.
10
64
  * - 'single': Only one item can be selected at a time.
11
- * - 'multiple': Allows multiple selections.
12
65
  * @defaultValue 'single'
13
66
  */
14
- selectionMode?: 'single' | 'multiple';
67
+ selectionMode?: undefined;
68
+ }
69
+ interface MultipleSelectArgs<T> extends BaseSelectArgs<T> {
70
+ /**
71
+ * Determines the selection mode of the select component.
72
+ * - 'multiple': Allows multiple selections.
73
+ */
74
+ selectionMode: 'multiple';
75
+ /**
76
+ * @deprecated Use selectedKeys for multiple selection mode
77
+ */
78
+ selectedKey?: never;
79
+ /**
80
+ * The currently selected keys for multiple selection mode.
81
+ *
82
+ * **Data Flow:**
83
+ * - Pass this to set the initial selection (array of keys)
84
+ * - Update this in your `onSelectionChange` handler to maintain two-way binding
85
+ * - The component calls `onSelectionChange` whenever the user changes the selection
86
+ *
87
+ * @example
88
+ * ```gts
89
+ * import { tracked } from '@glimmer/tracking';
90
+ *
91
+ * class MyComponent {
92
+ * @tracked selectedKeys = ['option1', 'option2'];
93
+ *
94
+ * handleSelectionChange = (keys: string[]) => {
95
+ * this.selectedKeys = keys; // Update parent state
96
+ * }
97
+ *
98
+ * <template>
99
+ * <Select
100
+ * @selectionMode="multiple"
101
+ * @selectedKeys={{this.selectedKeys}}
102
+ * @onSelectionChange={{this.handleSelectionChange}}
103
+ * @items={{this.items}}
104
+ * />
105
+ * </template>
106
+ * }
107
+ * ```
108
+ */
109
+ selectedKeys?: string[];
110
+ /**
111
+ * Callback fired when the selection changes in multiple mode.
112
+ *
113
+ * Update your `@selectedKeys` state in this callback to maintain two-way binding.
114
+ *
115
+ * @param keys - The newly selected keys (empty array if all selections cleared)
116
+ */
117
+ onSelectionChange?: (keys: string[]) => void;
118
+ }
119
+ type SelectArgs<T> = (ExplicitSingleSelectArgs<T> | DefaultSingleSelectArgs<T> | MultipleSelectArgs<T>) & {
15
120
  /**
16
121
  * The unique identifier for the select component.
17
122
  */
@@ -25,8 +130,9 @@ interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'fl
25
130
  * - 'sm': Small
26
131
  * - 'md': Medium
27
132
  * - 'lg': Large
28
- * 'trigger': Same size as the trigger
29
- * @defaultValue 'trigger'
133
+ * - 'trigger': Same size as the trigger
134
+ *
135
+ * @defaultValue 'trigger'
30
136
  */
31
137
  popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';
32
138
  /**
@@ -100,9 +206,8 @@ interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'fl
100
206
  startContentPointerEvents?: 'none' | 'auto';
101
207
  /**
102
208
  * Controls pointer-events property of endContent.
103
- * Defauled to `none` to pass the click event to the input. If your content
104
- * needs to capture events, consider adding `pointer-events-auto` class to that
105
- * element only.
209
+ * Defaults to `none` to pass click events to the input. If your content
210
+ * needs to capture events, add the `pointer-events-auto` class to that element.
106
211
  *
107
212
  * @defaultValue 'none'
108
213
  */
@@ -113,7 +218,11 @@ interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'fl
113
218
  * @defaultValue false
114
219
  */
115
220
  hideEmptyContent?: boolean;
116
- }
221
+ /**
222
+ * Callback fired when the select component loses focus.
223
+ */
224
+ onBlur?: () => void;
225
+ };
117
226
  interface SelectSignature<T> {
118
227
  Args: SelectArgs<T>;
119
228
  Element: HTMLDivElement;
@@ -139,13 +248,75 @@ interface SelectSignature<T> {
139
248
  emptyContent: [];
140
249
  };
141
250
  }
251
+ /**
252
+ * Select Component - A feature-rich dropdown selection component
253
+ *
254
+ * ## Selection State Architecture
255
+ *
256
+ * This component uses a **two-way data binding pattern** for managing selection state:
257
+ *
258
+ * ### Data Flow
259
+ * 1. **External → Internal (Initialization & Updates)**
260
+ * - Parent passes `@selectedKey` or `@selectedKeys` as arguments
261
+ * - Constructor initializes internal tracked properties (`_selectedKey` or `_selectedKeys`)
262
+ * - Modifiers (`updateSingleSelectValue`, `updateMultipleSelectValue`) sync internal state
263
+ * when parent updates the arguments
264
+ *
265
+ * 2. **Internal State Management**
266
+ * - `_selectedKey` / `_selectedKeys`: Internal tracked state (prefixed with underscore)
267
+ * - These serve as the "source of truth" for rendering and reactivity
268
+ * - Getters (`getSelectedKey`, `selectedKeys`) expose this internal state to the template
269
+ *
270
+ * 3. **Internal → External (User Interactions)**
271
+ * - User interactions trigger selection change handlers
272
+ * - Handlers update internal `_selectedKey` / `_selectedKeys` for immediate UI update
273
+ * - Handlers call parent's `@onSelectionChange` callback to notify of state change
274
+ * - Parent updates its state, which flows back through step 1
275
+ *
276
+ * ### Why Both Internal State AND Callbacks?
277
+ * - **Internal state:** Enables immediate, responsive UI updates (`_selectedKey` / `_selectedKeys`)
278
+ * - **Parent callback:** Enables parent to take action when changes occur (`@onSelectionChange`)
279
+ * - This pattern provides both responsive UX and parent inclusion over state
280
+ *
281
+ * ### Example Flow
282
+ * ```
283
+ * User clicks item
284
+ * → onSelectionChange handler
285
+ * → Updates _selectedKey (immediate UI update)
286
+ * → Calls parent's @onSelectionChange callback
287
+ * → Parent updates its @selectedKey state
288
+ * → updateSingleSelectValue modifier syncs _selectedKey with new arg value
289
+ * ```
290
+ */
142
291
  declare class Select<T = unknown> extends Component<SelectSignature<T>> {
143
292
  nodes: ListItem[];
144
293
  isOpen: boolean;
294
+ /**
295
+ * Internal tracked state for single selection mode.
296
+ * Source of truth for rendering. Synced with @selectedKey via the updateSingleSelectValue modifier.
297
+ */
298
+ _selectedKey: string | null;
299
+ /**
300
+ * Internal tracked state for multiple selection mode.
301
+ * Source of truth for rendering. Synced with @selectedKeys via the updateMultipleSelectValue modifier.
302
+ */
145
303
  _selectedKeys: string[];
304
+ /**
305
+ * Initializes the component and sets up initial selection state.
306
+ *
307
+ * **Initialization:**
308
+ * 1. Determines selection mode (single vs multiple)
309
+ * 2. Copies external arg values (@selectedKey or @selectedKeys) to internal tracked state
310
+ * 3. Logs warnings if incorrect args are used for the selection mode
311
+ *
312
+ * Note: After instantiation, modifiers keep internal state synced with external arguments.
313
+ */
314
+ constructor(owner: Owner, args: SelectArgs<T>);
315
+ validateArgs(): void;
146
316
  filterValue?: string;
147
317
  containerRef: {
148
- readonly element: HTMLDivElement | undefined;
318
+ "__#1@#private": any;
319
+ current: HTMLDivElement | undefined;
149
320
  setup: import("ember-modifier").FunctionBasedModifier<{
150
321
  Args: {
151
322
  Positional: unknown[];
@@ -155,7 +326,8 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
155
326
  }>;
156
327
  };
157
328
  triggerRef: {
158
- readonly element: HTMLInputElement | HTMLButtonElement | undefined;
329
+ "__#1@#private": any;
330
+ current: HTMLInputElement | HTMLButtonElement | undefined;
159
331
  setup: import("ember-modifier").FunctionBasedModifier<{
160
332
  Args: {
161
333
  Positional: unknown[];
@@ -164,14 +336,67 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
164
336
  Element: HTMLInputElement | HTMLButtonElement;
165
337
  }>;
166
338
  };
339
+ /**
340
+ * Handles selection changes from the Listbox component.
341
+ *
342
+ * **Flow:**
343
+ * 1. Updates internal state (`_selectedKey` or `_selectedKeys`) for immediate UI updates
344
+ * 2. Calls parent's `@onSelectionChange` callback to notify of the change
345
+ * 3. Parent updates its state, which flows back via modifier to complete the cycle
346
+ *
347
+ * **Side effects:**
348
+ * - Clears filter value (for searchable selects)
349
+ * - Triggers form input event for native form integration
350
+ *
351
+ * @param keys - Array of selected keys from Listbox (converted to single value in single mode)
352
+ */
167
353
  onSelectionChange: (keys: string[]) => void;
354
+ /**
355
+ * Handles selection changes from the native <select> element.
356
+ *
357
+ * This is similar to `onSelectionChange` but accepts a single key directly
358
+ * rather than an array, matching the native select's single-value API.
359
+ *
360
+ * **Flow:**
361
+ * 1. Updates internal `_selectedKey` for immediate UI update
362
+ * 2. Calls parent's `@onSelectionChange` callback
363
+ *
364
+ * @param key - The selected key, or null if cleared
365
+ */
366
+ onSingleSelectionChange: (key: string | null) => void;
168
367
  onOpenChange: (isOpen: boolean) => void;
169
368
  onFilterChange: (event: Event) => void;
369
+ /**
370
+ * Returns current selection as an array for template rendering.
371
+ *
372
+ * Normalizes both single and multiple selection modes to a consistent array interface:
373
+ * - Multiple mode: Returns `_selectedKeys` directly
374
+ * - Single mode: Converts `_selectedKey` to array format (or empty array if null)
375
+ *
376
+ * Note: Always returns internal tracked state rather than arguments. External updates
377
+ * sync through modifiers to maintain consistency.
378
+ *
379
+ * @returns Array of selected keys (empty array if none selected)
380
+ */
170
381
  get selectedKeys(): string[];
382
+ /**
383
+ * Returns the selected key for single selection mode.
384
+ *
385
+ * **Returns:**
386
+ * - Single mode: Returns `_selectedKey` (string or null)
387
+ * - Multiple mode: Returns null (not applicable)
388
+ *
389
+ * Note: Always returns internal tracked state rather than arguments. External updates
390
+ * sync through modifiers to maintain consistency.
391
+ *
392
+ * @returns The selected key, or null if none selected or in multiple mode
393
+ */
394
+ get getSelectedKey(): string | null;
171
395
  get blockScroll(): boolean;
172
396
  get disableFocusTrap(): boolean;
173
397
  onAction: (key: string) => void;
174
- clearSelectedKeys: (event: Event) => void;
398
+ handleBlur(): void;
399
+ clearSelectedKeys: () => void;
175
400
  onItemsChange: (nodes: ListItem[], _: "add" | "remove") => void;
176
401
  didClose: () => void;
177
402
  get selectedText(): string;
@@ -184,35 +409,35 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
184
409
  endContentPointerEvents?: "none" | "auto" | undefined;
185
410
  hasStartContent?: boolean | undefined;
186
411
  hasEndContent?: boolean | undefined;
187
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
412
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
188
413
  innerContainer: (slotProps?: ({
189
414
  size?: "sm" | "md" | "lg" | undefined;
190
415
  startContentPointerEvents?: "none" | "auto" | undefined;
191
416
  endContentPointerEvents?: "none" | "auto" | undefined;
192
417
  hasStartContent?: boolean | undefined;
193
418
  hasEndContent?: boolean | undefined;
194
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
419
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
195
420
  startContent: (slotProps?: ({
196
421
  size?: "sm" | "md" | "lg" | undefined;
197
422
  startContentPointerEvents?: "none" | "auto" | undefined;
198
423
  endContentPointerEvents?: "none" | "auto" | undefined;
199
424
  hasStartContent?: boolean | undefined;
200
425
  hasEndContent?: boolean | undefined;
201
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
426
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
202
427
  endContent: (slotProps?: ({
203
428
  size?: "sm" | "md" | "lg" | undefined;
204
429
  startContentPointerEvents?: "none" | "auto" | undefined;
205
430
  endContentPointerEvents?: "none" | "auto" | undefined;
206
431
  hasStartContent?: boolean | undefined;
207
432
  hasEndContent?: boolean | undefined;
208
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
433
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
209
434
  input: (slotProps?: ({
210
435
  size?: "sm" | "md" | "lg" | undefined;
211
436
  startContentPointerEvents?: "none" | "auto" | undefined;
212
437
  endContentPointerEvents?: "none" | "auto" | undefined;
213
438
  hasStartContent?: boolean | undefined;
214
439
  hasEndContent?: boolean | undefined;
215
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
440
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
216
441
  } & {
217
442
  base: (slotProps?: ({
218
443
  size?: "sm" | "md" | "lg" | undefined;
@@ -220,56 +445,87 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
220
445
  endContentPointerEvents?: "none" | "auto" | undefined;
221
446
  hasStartContent?: boolean | undefined;
222
447
  hasEndContent?: boolean | undefined;
223
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
448
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
224
449
  placeholder: (slotProps?: ({
225
450
  size?: "sm" | "md" | "lg" | undefined;
226
451
  startContentPointerEvents?: "none" | "auto" | undefined;
227
452
  endContentPointerEvents?: "none" | "auto" | undefined;
228
453
  hasStartContent?: boolean | undefined;
229
454
  hasEndContent?: boolean | undefined;
230
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
455
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
231
456
  listbox: (slotProps?: ({
232
457
  size?: "sm" | "md" | "lg" | undefined;
233
458
  startContentPointerEvents?: "none" | "auto" | undefined;
234
459
  endContentPointerEvents?: "none" | "auto" | undefined;
235
460
  hasStartContent?: boolean | undefined;
236
461
  hasEndContent?: boolean | undefined;
237
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
462
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
238
463
  icon: (slotProps?: ({
239
464
  size?: "sm" | "md" | "lg" | undefined;
240
465
  startContentPointerEvents?: "none" | "auto" | undefined;
241
466
  endContentPointerEvents?: "none" | "auto" | undefined;
242
467
  hasStartContent?: boolean | undefined;
243
468
  hasEndContent?: boolean | undefined;
244
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
469
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
245
470
  clearButton: (slotProps?: ({
246
471
  size?: "sm" | "md" | "lg" | undefined;
247
472
  startContentPointerEvents?: "none" | "auto" | undefined;
248
473
  endContentPointerEvents?: "none" | "auto" | undefined;
249
474
  hasStartContent?: boolean | undefined;
250
475
  hasEndContent?: boolean | undefined;
251
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
476
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
252
477
  input: (slotProps?: ({
253
478
  size?: "sm" | "md" | "lg" | undefined;
254
479
  startContentPointerEvents?: "none" | "auto" | undefined;
255
480
  endContentPointerEvents?: "none" | "auto" | undefined;
256
481
  hasStartContent?: boolean | undefined;
257
482
  hasEndContent?: boolean | undefined;
258
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
483
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
259
484
  emptyContent: (slotProps?: ({
260
485
  size?: "sm" | "md" | "lg" | undefined;
261
486
  startContentPointerEvents?: "none" | "auto" | undefined;
262
487
  endContentPointerEvents?: "none" | "auto" | undefined;
263
488
  hasStartContent?: boolean | undefined;
264
489
  hasEndContent?: boolean | undefined;
265
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
490
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
266
491
  } & {};
267
492
  get isClearable(): boolean | undefined;
268
493
  get filterFieldValue(): string;
269
494
  get filteredItems(): T[] | undefined;
270
495
  get showEmptyContent(): boolean;
271
496
  get autoActivateMode(): 'first' | 'selected';
497
+ /**
498
+ * Syncs internal `_selectedKeys` with external `@selectedKeys` argument.
499
+ *
500
+ * Runs whenever `@selectedKeys` changes:
501
+ * - Updates `_selectedKeys` to match the new external value
502
+ * - Normalizes undefined/null to empty array
503
+ *
504
+ * This enables UI updates when the external value changes.
505
+ */
506
+ updateMultipleSelectValue: import("ember-modifier").FunctionBasedModifier<{
507
+ Args: {
508
+ Positional: [string[] | null | undefined];
509
+ Named: import("ember-modifier/-private/signature").EmptyObject;
510
+ };
511
+ Element: HTMLDivElement;
512
+ }>;
513
+ /**
514
+ * Syncs internal `_selectedKey` with external `@selectedKey` argument.
515
+ *
516
+ * Runs whenever `@selectedKey` changes:
517
+ * - Updates `_selectedKey` to match the new external value
518
+ * - Handles null values for cleared selections
519
+ *
520
+ * This enables UI updates when the external value changes.
521
+ */
522
+ updateSingleSelectValue: import("ember-modifier").FunctionBasedModifier<{
523
+ Args: {
524
+ Positional: [string | null | undefined];
525
+ Named: import("ember-modifier/-private/signature").EmptyObject;
526
+ };
527
+ Element: HTMLDivElement;
528
+ }>;
272
529
  }
273
530
  export { Select, type SelectSignature };
274
531
  export default Select;
275
- //# sourceMappingURL=select.d.ts.map