@gridui/select 1.3.0 → 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 +42 -1
- package/dist/autocomplete-suggestions/autocomplete-suggestions.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +326 -292
- package/dist/index.js.map +4 -4
- package/dist/select/select.d.ts +0 -6
- package/dist/shared/popup/selection-popup.d.ts +0 -6
- package/dist/shared/search/calculate-search-options.d.ts +3 -5
- package/dist/shared/search/use-search-options.d.ts +2 -1
- package/dist/styles.css +1 -0
- package/docs/catalog.json +17 -1
- package/docs/reference/README.md +1 -0
- package/docs/reference/autocomplete-suggestions.md +77 -0
- package/package.json +7 -6
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:
|
|
@@ -209,3 +209,44 @@ Search result calculation is independent of popup visibility. Closing updates th
|
|
|
209
209
|
control and query callbacks immediately while retaining the last open popup
|
|
210
210
|
content through exit. A rapid reopen renders current results; reduced motion
|
|
211
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";
|