@nxgt/material 3.41.0 → 3.42.1

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 (25) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/{components-BUFDh6nQ.js → components-7GE-Nyov.js} +12023 -12051
  4. package/dist/components.js +6 -6
  5. package/dist/editor.js +529 -529
  6. package/dist/lib/components/ui/collections/server-table/bulk-action.d.ts +23 -10
  7. package/dist/lib/components/ui/collections/server-table/partials/server-table-bulk-buttons.d.ts +3 -1
  8. package/dist/lib/components/ui/collections/server-table/partials/server-table-bulk-focus.d.ts +38 -9
  9. package/dist/lib/components/ui/collections/server-table/partials/server-table-bulk.d.ts +4 -1
  10. package/dist/lib/components/ui/collections/server-table/partials/server-table-grid.d.ts +3 -1
  11. package/dist/lib/components/ui/selection/autocomplete/autocomplete-form-field.d.ts +5 -2
  12. package/dist/lib/components/ui/selection/autocomplete/autocomplete-text-rules.d.ts +20 -0
  13. package/dist/lib/components/ui/selection/autocomplete/autocomplete.d.ts +1 -1
  14. package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-chip-input.d.ts +13 -0
  15. package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-chips.d.ts +7 -1
  16. package/dist/lib/components/ui/selection/autocomplete/partials/autocomplete-text-input.d.ts +15 -0
  17. package/dist/lib/components/ui/selection/autocomplete/types.d.ts +15 -0
  18. package/dist/lib/components/ui/selection/autocomplete/use-autocomplete-handlers.d.ts +10 -3
  19. package/dist/lib/components/ui/selection/autocomplete/use-autocomplete.d.ts +6 -1
  20. package/dist/lib/components/ui/selection/combobox/combobox-input.d.ts +3 -1
  21. package/dist/main.js +6 -6
  22. package/dist/{use-chat-composer-DrFgIE3T.js → use-chat-composer-D_hfO99B.js} +2635 -2462
  23. package/docs/components/data-table-filter-and-lists.md +18 -7
  24. package/docs/components/selection-and-choice.md +47 -1
  25. package/package.json +1 -1
@@ -898,13 +898,24 @@ export default function Students() {
898
898
  Under `max` again, the button returns. On a phone an action in the bar
899
899
  shows the notice inline; one in the More menu is a disabled item whose
900
900
  notice is its description (`aria-describedby`), so it reads under its label.
901
- - `onClick(ids, selection, rows, { trigger, focusTrigger })`: `trigger` is the
902
- button the action started from (the "More" button for a More-menu item),
903
- and `focusTrigger()` gives it the focus back, found again at call time, so
904
- it works after a re-render. When the action is gone by then (its count fell
905
- to 0, or past `max`) the focus goes to the next bulk action, else "More",
906
- else the table's "Select all" (the table itself without one), never the
907
- body. A handler that takes three parameters stays valid.
901
+ - `onClick(ids, selection, rows, { actionId, trigger, element, focusTrigger })`:
902
+ `focusTrigger()` gives the focus back to the action, found again in the
903
+ DOM when it is called by the stable key every bulk button carries,
904
+ `data-bulk-action="<id>"` (the More button carries `data-bulk-more`). It
905
+ works after the bar was drawn again (a resize, a rotation, the move
906
+ between the desktop toolbar and the phone's bar): the action's new button
907
+ gets the focus, and the More button when the action now sits in the More
908
+ menu. When the action is hidden by then (its count fell to 0, or past
909
+ `max`) the focus goes to the next bulk action, else "More", else the
910
+ table's "Select all" (the table itself without one), never the body.
911
+ `trigger` (and `element()`, the same as a function) is the action's
912
+ current button, or the More button, read when you read it: do not keep it
913
+ from the click, the node is disconnected after a redraw; use
914
+ `focusTrigger()`, and `actionId` is the key. A dialog opened from
915
+ `onClick` returns the focus to the button it was opened from by default,
916
+ which a redraw has disconnected: give it
917
+ `onCloseAutoFocus={(e) => { e.preventDefault(); ctx.focusTrigger(); }}`
918
+ as below. A handler that takes three parameters stays valid.
908
919
  ```tsx
909
920
  const [confirm, setConfirm] = useState<{ ids: string[]; focus: () => void } | null>(null);
910
921
  <ServerTable<Person>
@@ -373,7 +373,7 @@ export function Framework() {
373
373
 
374
374
  ![Autocomplete](../previews/selection-choice-autocomplete.webp)
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`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/material",
3
- "version": "3.41.0",
3
+ "version": "3.42.1",
4
4
  "license": "MIT",
5
5
  "bugs": {
6
6
  "email": "stevegires@gmail.com"