@gridui/select 1.2.2 → 1.5.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gridui/select
2
2
 
3
- Core family. Public API: `Autocomplete`, `AutocompleteProps`, `Combobox`, `ComboboxProps`, `MultiSelect`, `MultiSelectProps`, `Select`, `SelectAction`, `SelectGroup`, `SelectOption`, `SelectProps`.
3
+ Core family. Public API: `AutocompleteSuggestions`, `AutocompleteSuggestionsProps`, `AutocompleteInputPropsGetter`, `Autocomplete`, `AutocompleteProps`, `Combobox`, `ComboboxProps`, `MultiSelect`, `MultiSelectProps`, `Select`, `SelectAction`, `SelectGroup`, `SelectOption`, `SelectProps`.
4
4
 
5
5
  Import components from `@gridui/select`. Load these styles in order for Select,
6
6
  Combobox, and MultiSelect:
@@ -70,6 +70,16 @@ disabled, or already-empty controls.
70
70
  Combobox also disables clearing while `readOnly`; external controlled updates and
71
71
  native form reset retain their normal behavior.
72
72
 
73
+ ### Selection appearance
74
+
75
+ Select, Combobox, and MultiSelect accept `selectionAppearance="filled" | "indicator"`,
76
+ using the same Overlay CVA variant as DropdownMenu and Preferences. `"filled"`
77
+ (default) shows the selected background and trailing check; `"indicator"` keeps
78
+ the check without the selected background. Unselected options retain their check
79
+ slot so labels do not shift. This affects both flat and grouped options, including
80
+ multiple selected rows. Keyboard/pointer highlights, search, form values, actions,
81
+ and disabled behavior remain independent of this presentation choice.
82
+
73
83
  ### Actions
74
84
 
75
85
  Both components accept `actions: readonly SelectAction[]`. Each action has a
@@ -143,8 +153,7 @@ reset observation. `selection-actions.tsx` renders independent links and buttons
143
153
 
144
154
  `types.ts` owns shared option, action, and selection contracts; `options.ts` owns
145
155
  pure filtering and flattening; `style.ts` owns selection-specific presentation and composes Overlay surface
146
- styles without translating variables into DropdownMenu names. DropdownMenu still
147
- owns the public option-row style. `selection-popup.tsx` shares Combobox/MultiSelect
156
+ styles without translating variables into DropdownMenu names. Overlay owns the public option-row style shared with DropdownMenu. `selection-popup.tsx` shares Combobox/MultiSelect
148
157
  portal geometry, explicit anchor containment, and focus/escape event plumbing;
149
158
  callers choose initial focus and dismissal policy. MultiSelect uses Form's
150
159
  ListFieldControl with useListField for the native multiple-value bridge. Internal parts
@@ -200,3 +209,44 @@ Search result calculation is independent of popup visibility. Closing updates th
200
209
  control and query callbacks immediately while retaining the last open popup
201
210
  content through exit. A rapid reopen renders current results; reduced motion
202
211
  unmounts without waiting for an animation event.
212
+
213
+ Shared animation policy and tempo come from `MotionConfig` in `@gridui/motion`.
214
+ Disabled or reduced-motion policy settles decoration without disabling interaction.
215
+ See the [motion guide](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-core/motion)
216
+ for CSS scopes, portal behavior, and specialized timing contracts.
217
+
218
+ ## Compose suggestions with a host-owned input
219
+
220
+ `AutocompleteSuggestions` owns suggestion filtering, navigation, announcements
221
+ and popup dismissal. It owns no text value, text callback, native form value,
222
+ or text-reset state. Pass the host's current `value`, selection options and
223
+ `onOptionSelect(option)`, then render an input through its `getInputProps` child:
224
+
225
+ ```tsx
226
+ <AutocompleteSuggestions
227
+ value={draft}
228
+ options={options}
229
+ searchLabel="Tag suggestions"
230
+ emptyLabel="Enter a new tag"
231
+ onOptionSelect={option => addTag(option.value)}
232
+ >
233
+ {getInputProps => <input {...getInputProps({
234
+ value: draft,
235
+ onChange: event => setDraft(event.currentTarget.value),
236
+ onKeyDown: handleFreeText,
237
+ })} />}
238
+ </AutocompleteSuggestions>
239
+ ```
240
+
241
+ Forward the returned ref, ARIA attributes and event handlers to one native input
242
+ (or `Input`). Suggestions claim arrow navigation and an explicitly highlighted
243
+ Enter before the input's `onKeyDown`; the host receives only unhandled keys.
244
+ The wrapper's optional `onKeyDown` runs first and may cancel either behavior.
245
+ Pass `disabled`, `readOnly`, `dir` and an external `form` owner to the wrapper
246
+ when applicable. Its form reset listener dismisses the popup while the host
247
+ resets text. `Autocomplete` composes this layer with its own free-text field;
248
+ TagInput composes it with its existing draft and tag state.
249
+
250
+ Search result availability, active-item fallback and clamped navigation reuse
251
+ Interaction's React-free searchable-list model. A defined `errorLabel`, including
252
+ an empty string, removes stale options without losing committed value labels.
@@ -0,0 +1,18 @@
1
+ import type { SelectGroup, SelectionSearchProps, SelectOption } from "../shared/types";
2
+ import { type ComponentPropsWithRef, type FC, type ReactNode } from "react";
3
+ type InputProps = ComponentPropsWithRef<"input">;
4
+ /** Bind a host-owned input. Suggestions claim navigation before the input's own key handler. */
5
+ export type AutocompleteInputPropsGetter = (props: InputProps) => InputProps;
6
+ export type AutocompleteSuggestionsProps = Omit<SelectionSearchProps, "query" | "onQueryChange"> & Pick<InputProps, "disabled" | "readOnly" | "dir" | "onKeyDown" | "form"> & {
7
+ readonly value: string;
8
+ readonly options: readonly (SelectOption | SelectGroup)[];
9
+ readonly searchLabel: string;
10
+ readonly emptyLabel: string;
11
+ readonly portalContainer?: HTMLElement | undefined;
12
+ readonly rootClassName?: string | undefined;
13
+ readonly onOptionSelect: (option: SelectOption) => void;
14
+ readonly children: (getInputProps: AutocompleteInputPropsGetter) => ReactNode;
15
+ };
16
+ /** Own only suggestion navigation and its popup; the host owns text, validation and form reset. */
17
+ export declare const AutocompleteSuggestions: FC<AutocompleteSuggestionsProps>;
18
+ export {};
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@
6
6
  */
7
7
  export type { AutocompleteProps } from "./autocomplete/autocomplete";
8
8
  export { Autocomplete } from "./autocomplete/autocomplete";
9
+ export type { AutocompleteInputPropsGetter, AutocompleteSuggestionsProps } from "./autocomplete-suggestions/autocomplete-suggestions";
10
+ export { AutocompleteSuggestions } from "./autocomplete-suggestions/autocomplete-suggestions";
9
11
  export type { ComboboxProps } from "./combobox/combobox";
10
12
  export { Combobox } from "./combobox/combobox";
11
13
  export type { MultiSelectProps } from "./multi-select/multi-select";