@nxgt/material 3.41.0 → 3.42.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/{components-BUFDh6nQ.js → components-g8mWYJE8.js} +12143 -12202
- package/dist/components.js +6 -6
- package/dist/editor.js +529 -529
- package/dist/lib/components/ui/selection/autocomplete/autocomplete-form-field.d.ts +5 -2
- package/dist/lib/components/ui/selection/autocomplete/autocomplete-text-rules.d.ts +20 -0
- package/dist/lib/components/ui/selection/autocomplete/autocomplete.d.ts +1 -1
- package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-chip-input.d.ts +13 -0
- package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-chips.d.ts +7 -1
- package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-text-input.d.ts +15 -0
- package/dist/lib/components/ui/selection/autocomplete/types.d.ts +15 -0
- package/dist/lib/components/ui/selection/autocomplete/use-autocomplete-handlers.d.ts +10 -3
- package/dist/lib/components/ui/selection/autocomplete/use-autocomplete.d.ts +6 -1
- package/dist/lib/components/ui/selection/combobox/combobox-input.d.ts +3 -1
- package/dist/main.js +6 -6
- package/dist/{use-chat-composer-DrFgIE3T.js → use-chat-composer-D_hfO99B.js} +2635 -2462
- package/docs/components/selection-and-choice.md +47 -1
- package/package.json +1 -1
|
@@ -373,7 +373,7 @@ export function Framework() {
|
|
|
373
373
|
|
|
374
374
|

|
|
375
375
|
|
|
376
|
-
Single or multiple (chips) autocomplete with free-solo values, accent-insensitive matching and a debounced server search.
|
|
376
|
+
Single or multiple (chips) autocomplete with free-solo values, accent-insensitive matching and a debounced server search; a single value can be the input's own text (`display="text"`).
|
|
377
377
|
|
|
378
378
|
```tsx
|
|
379
379
|
import { Autocomplete } from '@nxgt/material/components';
|
|
@@ -409,6 +409,8 @@ disabled with the field; Backspace in the empty input removes the last one.
|
|
|
409
409
|
| Prop | Type | Default | Effect |
|
|
410
410
|
| --- | --- | --- | --- |
|
|
411
411
|
| `mode` | `'single' \| 'multiple'` | — | required; decides the `value` type |
|
|
412
|
+
| `display` | `'chip' \| 'text'` | `'chip'` | `mode="single"` only: how the value is drawn, a removable chip beside the input (and its placeholder), or the input's own text (type `AutocompleteDisplay`; see [One value as text](#one-value-as-text)). Ignored in `multiple` |
|
|
413
|
+
| `clearable` | `boolean` | `true` | shows the "Clear" button; with `display="text"`, whether emptying the text and leaving the field clears the value |
|
|
412
414
|
| `value` | `string` / `string[]` | — | required, per `mode` |
|
|
413
415
|
| `onValueChange` | `(value?: string \| null) => void` / `(value?: string[] \| null) => void` | — | per `mode` |
|
|
414
416
|
| `options` | `T[]` (`{ value, label, disabled? }` by default) | `[]` | the items (`disabled` on one: listed, announced as disabled, never picked); with `onSearch`, the list before a search and the selected options' labels |
|
|
@@ -435,6 +437,50 @@ An avatar in the rows and the chips:
|
|
|
435
437
|
`getOptionLeading={(person) => <Avatar src={person.photo} alt="" />}`; see
|
|
436
438
|
[the field look](../guides/field-look-2-x.md#autocomplete-and-the-chips-box).
|
|
437
439
|
|
|
440
|
+
### One value as text
|
|
441
|
+
|
|
442
|
+
By default a single value is drawn as a chip, like a multi-select with one
|
|
443
|
+
entry. For picking one entry out of a long directory (a person, a place, a
|
|
444
|
+
resource), `display="text"` makes the chosen option's label the input's own
|
|
445
|
+
text, as a `Select` shows it, and keeps the search:
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
<Autocomplete
|
|
449
|
+
mode="single"
|
|
450
|
+
display="text"
|
|
451
|
+
label="Member"
|
|
452
|
+
placeholder="Search a member"
|
|
453
|
+
options={selected ? [selected] : []}
|
|
454
|
+
onSearch={searchMembers}
|
|
455
|
+
value={value}
|
|
456
|
+
onValueChange={(next) => setValue(next ?? '')}
|
|
457
|
+
/>
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
- The label fills the input (on the server too); the placeholder shows only
|
|
461
|
+
while the field is empty. The text is selected on focus, so typing replaces
|
|
462
|
+
it and searches again (`onSearch` or the local `filter`); the list opened on
|
|
463
|
+
the label is the whole `options`, not filtered by it.
|
|
464
|
+
- Typing changes nothing until an option is picked. **Escape**, or leaving
|
|
465
|
+
the field (Tab, a click elsewhere), drops the typed text and brings the
|
|
466
|
+
label back; the value never moved. Escape on a closed list does the same
|
|
467
|
+
instead of clearing.
|
|
468
|
+
- The "Clear" button empties the text and the value. Emptying the text by
|
|
469
|
+
hand and leaving the field clears the value too, since the field is
|
|
470
|
+
`clearable`. With `clearable={false}` there is no button, and an emptied text
|
|
471
|
+
gets the label back on leave: the value can only be replaced by another pick.
|
|
472
|
+
- The option's `getOptionLeading` (or `renderSelectedLeading`) avatar shows
|
|
473
|
+
before the text while it is picked.
|
|
474
|
+
- `freeSolo` still adds through its "Add" button; text left in the input and
|
|
475
|
+
not added is dropped on leave, as any other typed text.
|
|
476
|
+
- Keep the selected option in `options` (as with `onSearch` and chips): a value
|
|
477
|
+
with no matching option has no label, so the input stays empty.
|
|
478
|
+
- The input is the combobox: `aria-expanded` follows the list,
|
|
479
|
+
`aria-activedescendant` names the highlighted option, the picked option is
|
|
480
|
+
`aria-selected`, and the field's live region announces the suggestions as
|
|
481
|
+
before. `AutocompleteFormField` takes `display` and `clearable` too. Leaving the
|
|
482
|
+
window (Alt-Tab) is not leaving the field: the typed text waits.
|
|
483
|
+
|
|
438
484
|
### Searching a server
|
|
439
485
|
|
|
440
486
|
`onSearch` takes the query and an `AbortSignal`; hand the signal to `fetch`
|