@cboxdk/cbox-ui 0.16.1 → 0.17.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 +3 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +530 -219
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/tokens/controls.css +130 -0
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ Plain CSS in `tokens/controls.css` (`cbx-ui-*` classes in `@layer components`),
|
|
|
120
120
|
an app without the tokens import. In a Tailwind v4 app a utility on `className` (`w-full`,
|
|
121
121
|
`mt-2`) wins over the component's own rule. Light and dark come from the tokens; fields are 16px
|
|
122
122
|
below 768px so iOS does not zoom. The few words the components say themselves ("Close",
|
|
123
|
-
"(required)", "(optional)") go through `CboxLocalizationProvider`; everything else is a prop.
|
|
123
|
+
"(required)", "(optional)", "Create “{query}”", "Add “{tag}”", "Remove {tag}", "Add a tag…" and the TagInput messages) go through `CboxLocalizationProvider`; everything else is a prop.
|
|
124
124
|
|
|
125
125
|
| Export | What it does |
|
|
126
126
|
|---|---|
|
|
@@ -131,6 +131,8 @@ below 768px so iOS does not zoom. The few words the components say themselves ("
|
|
|
131
131
|
| `RadioGroup` | A labelled group of native radios: arrow keys move, Tab enters at the checked one. Options take a `hint` and `disabled`; `labelHidden` keeps the question for screen readers only. |
|
|
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
|
+
| `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` (e.g. lower case), `validate(tag)`, `maxLength`, `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`. |
|
|
134
136
|
| `Spinner` | The indeterminate progress ring. Silent by default; `label` makes it a live status. |
|
|
135
137
|
|
|
136
138
|
### Charts
|
package/dist/index.d.ts
CHANGED
|
@@ -1058,8 +1058,16 @@ declare function CboxServiceMark({ appKey, className, fallback }: CboxServiceMar
|
|
|
1058
1058
|
* - Optional avatar per option, optional secondary line.
|
|
1059
1059
|
* - Optional grouped sections with mono-tracked headers.
|
|
1060
1060
|
* - Optional footer link (eg "+ New environment").
|
|
1061
|
+
* - Optional `onCreate`: a "Create “…”" row when what was typed matches
|
|
1062
|
+
* no option, so a person makes the missing thing without leaving the form.
|
|
1061
1063
|
* - Empty-state copy when the filter excludes everything.
|
|
1062
1064
|
*
|
|
1065
|
+
* The panel is portalled (into the Sheet it sits in, else `<body>`) and
|
|
1066
|
+
* placed against the trigger: never clipped by an `overflow: hidden`
|
|
1067
|
+
* parent, flipped above the trigger near the bottom of the screen, at
|
|
1068
|
+
* least 16rem wide so labels and the search field are not cut off.
|
|
1069
|
+
* Styled by `tokens/controls.css` (`cbx-ui-combo-*`), no Tailwind scan.
|
|
1070
|
+
*
|
|
1063
1071
|
* Two modes:
|
|
1064
1072
|
* - Value mode (default): `value` + `onChange` — Combobox manages
|
|
1065
1073
|
* selection state, host treats it like a controlled input.
|
|
@@ -1133,6 +1141,16 @@ type CommonProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
|
|
|
1133
1141
|
label: string;
|
|
1134
1142
|
href: string;
|
|
1135
1143
|
};
|
|
1144
|
+
/**
|
|
1145
|
+
* Offer to create what was typed when it matches no option's label
|
|
1146
|
+
* (case-insensitive). Called with the trimmed text; the panel closes
|
|
1147
|
+
* when it returns. Return a promise to keep the panel open with a
|
|
1148
|
+
* spinner until it settles (it stays open when it rejects). The host
|
|
1149
|
+
* selects the new item itself (`onChange` / its own state).
|
|
1150
|
+
*/
|
|
1151
|
+
onCreate?: (query: string) => void | Promise<unknown>;
|
|
1152
|
+
/** The create row's text. Default "Create “{query}”", through the host's translator. */
|
|
1153
|
+
createLabel?: (query: string) => string;
|
|
1136
1154
|
/** Disable the entire combobox (greyed-out trigger). */
|
|
1137
1155
|
disabled?: boolean;
|
|
1138
1156
|
/** Required-field marker on the trigger. */
|
|
@@ -1740,6 +1758,46 @@ type SwitchProps = {
|
|
|
1740
1758
|
*/
|
|
1741
1759
|
declare const Switch: react.ForwardRefExoticComponent<SwitchProps & react.RefAttributes<HTMLButtonElement>>;
|
|
1742
1760
|
|
|
1761
|
+
type TagInputProps = Pick<AriaAttributes, 'aria-describedby' | 'aria-invalid'> & {
|
|
1762
|
+
/** The tags, in the order they were added. */
|
|
1763
|
+
value: string[];
|
|
1764
|
+
onChange: (value: string[]) => void;
|
|
1765
|
+
/** Tags to offer as the person types. An option's `value` is the tag; its `label` is shown. */
|
|
1766
|
+
suggestions?: ComboboxOption[];
|
|
1767
|
+
/** Accept a tag that is not among the suggestions (default). `false` allows suggestions only. */
|
|
1768
|
+
creatable?: boolean;
|
|
1769
|
+
/** Turns typed text into a tag before it is checked and added. Default: trimmed. Pass `(tag) => tag.trim().toLowerCase()` for lower-case tags. */
|
|
1770
|
+
normalize?: (tag: string) => string;
|
|
1771
|
+
/** A message when `tag` (normalized) is not allowed, else nothing. Shown under the field as the person types. */
|
|
1772
|
+
validate?: (tag: string) => string | null | undefined;
|
|
1773
|
+
/** The most characters a tag may have. */
|
|
1774
|
+
maxLength?: number;
|
|
1775
|
+
/** The most tags. */
|
|
1776
|
+
maxTags?: number;
|
|
1777
|
+
/** Shown in the empty input. Default "Add a tag…". */
|
|
1778
|
+
placeholder?: string;
|
|
1779
|
+
/** When nothing among `suggestions` matches and new tags are not allowed. */
|
|
1780
|
+
emptyText?: string;
|
|
1781
|
+
disabled?: boolean;
|
|
1782
|
+
required?: boolean;
|
|
1783
|
+
/** The input's id. Inside a `Field` it comes from the Field. */
|
|
1784
|
+
id?: string;
|
|
1785
|
+
ariaLabel?: string;
|
|
1786
|
+
className?: string;
|
|
1787
|
+
};
|
|
1788
|
+
/**
|
|
1789
|
+
* Tags as chips in one field. Enter adds the highlighted suggestion, else what was typed; a comma
|
|
1790
|
+
* always adds what was typed (pasting "a, b, c" adds three),
|
|
1791
|
+
* Backspace in the empty input removes the last chip, a chip's × removes it. With `suggestions` a
|
|
1792
|
+
* list filters as the person types; arrows and Enter pick from it, and "Add “…”" adds what was
|
|
1793
|
+
* typed when no suggestion matches it exactly. Problems (a duplicate, too long, `validate`) are
|
|
1794
|
+
* shown in the list's place as the person types and announced; the chip row does not move.
|
|
1795
|
+
*
|
|
1796
|
+
* Inside a `<Field>` it takes the Field's label, hint, error and required state. Its words go
|
|
1797
|
+
* through the host's translator.
|
|
1798
|
+
*/
|
|
1799
|
+
declare function TagInput(props: TagInputProps): react_jsx_runtime.JSX.Element;
|
|
1800
|
+
|
|
1743
1801
|
/**
|
|
1744
1802
|
* Cross-app surface contract — the API hosts opt into and that
|
|
1745
1803
|
* cbox-ui's runtime renders. Each `SurfaceId` corresponds to a
|
|
@@ -1985,4 +2043,4 @@ declare function Sparkline({ values, color, width, height }: {
|
|
|
1985
2043
|
height?: number;
|
|
1986
2044
|
}): react_jsx_runtime.JSX.Element | null;
|
|
1987
2045
|
|
|
1988
|
-
export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, Textarea, type TextareaProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|
|
2046
|
+
export { APP_HUES, AppContent, type AppKey, AppShell, Button, type ButtonProps, type ButtonSize, type ButtonVariant, CHART_PALETTE, CboxAppCatalog, type CboxAppCatalogProps, CboxAppIcon, type CboxAppIconProps, type CboxAppKey, type CboxAppLink, CboxBrand, type CboxBrandProps, type CboxIdContextValue, CboxIdProvider, CboxKnownApp, CboxLocalizationProvider, type CboxNotificationPreviewItem, type CboxNotificationsState, type CboxOrganization, CboxServiceMark, type CboxServiceMarkProps, CboxShell, type CboxShellProps, CboxSurfaces, type CboxSurfacesProps, type CboxTranslationValues, type CboxTranslator, type CboxUser, Checkbox, type CheckboxProps, Combobox, type ComboboxAvatar, type ComboboxGroup, type ComboboxOption, type ComboboxProps, type ContextItem, type ContextLevel, type ContextTone, CreateField, CreateForm, CreateRefField, CreateSubmit, DataPanel, Dialog, DialogClose, type DialogProps, type DialogSize, EmptyState, Field, type FieldControlProps, type FieldProps, Heading, type HelpArticle, type HelpState, type HelpStore, type InboxState, type InferUrlState, Input, type InputProps, KeyValue, KeyValueList, type ListPage, type NavArea, type NavPage, PageHeader, type PageIntent, PageShell, type PageTabSpec, PageTabs, type PageTabsProps, type PageWidth, type PaletteAction, type PaletteRecord, PanelBody, RadioGroup, type RadioGroupProps, type RadioOption, type RealtimeState, type RealtimeStatus, RowLink, type RowLinkProps, SHELL_ICONS, SectionHeader, Sheet, SheetClose, type SheetProps, type SheetSize, type Shell, type ShellAccount, type Link as ShellActionLink, type ShellApp, type ShellBanner, type ShellCatalogState, type ShellCreatable, type ShellCreate, type ShellCreateForm, type ShellCreated, type ShellHelp, type ShellHelpArticle, type ShellIcon, type ShellLinkComponent, type ShellNavigate, type ShellNotifications, type ShellOption, type ShellPreferenceChange, type ShellPreferences, type ShellRecordSearch, type ShellRenderCreate, type ShellTheme, Slider, type SliderProps, Sparkline, Spinner, type SpinnerProps, StatTile, StatusPill, type SupportUpdate, type SurfaceArgs, type SurfaceConfig, type SurfaceController, type SurfaceId, Switch, type SwitchBody, type SwitchProps, TagInput, type TagInputProps, Textarea, type TextareaProps, type Transport, type UrlField, type UrlSchema, applyTheme, buildUrlSearch, buttonClassName, cn, contextTrail, createHelpStore, defineUrlSchema, environmentFor, groupItems, hueFor, initialsOf, interpolate, isLive, pageIntent, parseListPage, parseShellCatalog, parseUrlSearch, quickEnvironments, settingsHref, switchBody, switchPayload, themeBootScript, urlBoolean, urlEnum, urlNumber, urlString, urlStringArray, useCboxId, useCboxIdOptional, useCboxLocalization, useCboxSurfaces, useCboxSurfacesOptional, useDialogClose, useFieldControl, useKnownAppCatalog, useSheetClose, useShellCreate, useShellHelp, useShellPageTitle, withQuery };
|