@cboxdk/cbox-ui 0.17.0 → 0.17.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.
- package/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,7 +132,7 @@ below 768px so iOS does not zoom. The few words the components say themselves ("
|
|
|
132
132
|
| `Switch` | An immediate on/off (`role="switch"`). Named by its `Field`, or `aria-label`. A setting that waits for Save is a `Checkbox`. |
|
|
133
133
|
| `Sheet` / `SheetClose` / `useSheetClose` | A modal sheet portalled to `<body>`, never a centred modal: a panel sliding in from the right from 768px (`size` sm / md / lg: 26, 30 or 44rem wide), a bottom sheet on a phone that drags down to close. `title`, `description`, `footer`. Focus moves in (to `autoFocus` / `data-autofocus`, else the first field, else Close, never a footer action), Tab stays inside, the page behind is `inert` and does not scroll, Escape / Close / the scrim close it (`dismissible={false}` keeps the scrim from closing it), and focus goes back to the opener. `SheetClose` is a Button that closes the sheet it is in. `Dialog` / `DialogClose` / `useDialogClose` are deprecated aliases that render the same sheet. |
|
|
134
134
|
| `Combobox` | The select (native `<select>` is not used). A 36px trigger that never changes size; the panel is portalled (into the Sheet it sits in, else `<body>`) and placed against the trigger, so an `overflow: hidden` parent never clips it, it opens upwards near the bottom of the screen, and it is at least 16rem wide (up to 22rem for long labels). Search, groups, avatars, `footerLink`, value mode (`value` + `onChange`) or navigation mode (`href` + `LinkComponent`). `onCreate(query)` adds a "Create “…”" row when what was typed matches no label; return a promise to show a spinner until it settles. `createLabel(query)` changes its text. Escape closes only the panel. |
|
|
135
|
-
| `TagInput` | Tags as chips in one field: Enter adds the highlighted suggestion or what was typed, a comma (or a pasted list) adds the text as typed, Backspace in the empty input removes the last chip, × removes one. `suggestions` (Combobox options) filter as the person types; `creatable={false}` allows suggestions only. `normalize` (
|
|
135
|
+
| `TagInput` | Tags as chips in one field: Enter adds the highlighted suggestion or what was typed, a comma (or a pasted list) adds the text as typed, Backspace in the empty input removes the last chip, × removes one. `suggestions` (Combobox options) filter as the person types; `creatable={false}` allows suggestions only. `normalize` cleans what was typed into a tag (do the housekeeping there: lower case, spaces to dashes; the "Add “…”" row shows the result), `maxLength` cuts a longer tag to length, `validate(tag)` for what cannot be cleaned up, `maxTags`: a problem shows in the list's place and is announced, the field does not move. Takes its label, hint and error from a `Field`. |
|
|
136
136
|
| `Spinner` | The indeterminate progress ring. Silent by default; `label` makes it a live status. |
|
|
137
137
|
|
|
138
138
|
### Charts
|
package/dist/index.d.ts
CHANGED
|
@@ -1770,7 +1770,7 @@ type TagInputProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> &
|
|
|
1770
1770
|
normalize?: (tag: string) => string;
|
|
1771
1771
|
/** A message when `tag` (normalized) is not allowed, else nothing. Shown under the field as the person types. */
|
|
1772
1772
|
validate?: (tag: string) => string | null | undefined;
|
|
1773
|
-
/** The most characters a tag may have. */
|
|
1773
|
+
/** The most characters a tag may have. A longer one is cut to length (the "Add “…”" row shows the cut tag), never refused. */
|
|
1774
1774
|
maxLength?: number;
|
|
1775
1775
|
/** The most tags. */
|
|
1776
1776
|
maxTags?: number;
|
package/dist/index.js
CHANGED
|
@@ -6045,12 +6045,16 @@ function TagInput(props) {
|
|
|
6045
6045
|
const problemWith = (tag, current) => {
|
|
6046
6046
|
if (current.includes(tag)) return t("\u201C{tag}\u201D is already added.", { tag: labelOf(tag) });
|
|
6047
6047
|
if (maxTags !== void 0 && current.length >= maxTags) return t("Up to {count} tags.", { count: maxTags });
|
|
6048
|
-
if (maxLength !== void 0 && tag.length > maxLength) return t("Keep it to {count} characters.", { count: maxLength });
|
|
6049
6048
|
if (!creatable && !suggestions.some((option) => option.value === tag)) return t("Choose one of the suggestions.");
|
|
6050
6049
|
return validate?.(tag) ?? null;
|
|
6051
6050
|
};
|
|
6051
|
+
const clean = (text) => {
|
|
6052
|
+
const tag = normalize(text);
|
|
6053
|
+
const chars = Array.from(tag);
|
|
6054
|
+
return maxLength !== void 0 && chars.length > maxLength ? normalize(chars.slice(0, maxLength).join("")) : tag;
|
|
6055
|
+
};
|
|
6052
6056
|
const typed = query2.trim();
|
|
6053
|
-
const candidate = typed === "" ? "" :
|
|
6057
|
+
const candidate = typed === "" ? "" : clean(query2);
|
|
6054
6058
|
const lower = typed.toLowerCase();
|
|
6055
6059
|
const full = maxTags !== void 0 && value.length >= maxTags;
|
|
6056
6060
|
const matches2 = useMemo(
|
|
@@ -6079,7 +6083,7 @@ function TagInput(props) {
|
|
|
6079
6083
|
let left = null;
|
|
6080
6084
|
for (const part of parts) {
|
|
6081
6085
|
if (part.trim() === "") continue;
|
|
6082
|
-
const tag =
|
|
6086
|
+
const tag = clean(part);
|
|
6083
6087
|
const known = suggestions.find((option) => option.value === tag || option.label.toLowerCase() === part.trim().toLowerCase());
|
|
6084
6088
|
const resolved = known?.value ?? tag;
|
|
6085
6089
|
if (problemWith(resolved, next) === null) next.push(resolved);
|