@manakind/ui-core 0.20.0 → 0.22.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.
Files changed (49) hide show
  1. package/README.md +9 -6
  2. package/dist/breadcrumb/breadcrumb.css +47 -0
  3. package/dist/breadcrumb/breadcrumb.css.d.ts +2 -0
  4. package/dist/breadcrumb/breadcrumb.d.ts +43 -0
  5. package/dist/breadcrumb/breadcrumb.d.ts.map +1 -0
  6. package/dist/breadcrumb/breadcrumb.js +21 -0
  7. package/dist/breadcrumb/breadcrumb.js.map +1 -0
  8. package/dist/breadcrumb/index.d.ts +3 -0
  9. package/dist/breadcrumb/index.d.ts.map +1 -0
  10. package/dist/breadcrumb/index.js +2 -0
  11. package/dist/breadcrumb/index.js.map +1 -0
  12. package/dist/combobox/combobox.css +186 -2
  13. package/dist/combobox/combobox.d.ts +87 -15
  14. package/dist/combobox/combobox.d.ts.map +1 -1
  15. package/dist/combobox/combobox.js +329 -41
  16. package/dist/combobox/combobox.js.map +1 -1
  17. package/dist/combobox/index.d.ts +1 -1
  18. package/dist/combobox/index.d.ts.map +1 -1
  19. package/dist/combobox/index.js.map +1 -1
  20. package/dist/date-input/date-input.d.ts +5 -3
  21. package/dist/date-input/date-input.d.ts.map +1 -1
  22. package/dist/date-input/date-input.js +13 -2
  23. package/dist/date-input/date-input.js.map +1 -1
  24. package/dist/fallback-glyphs.d.ts +1 -0
  25. package/dist/fallback-glyphs.d.ts.map +1 -1
  26. package/dist/fallback-glyphs.js +2 -0
  27. package/dist/fallback-glyphs.js.map +1 -1
  28. package/dist/index.d.ts +3 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +2 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/link-component.d.ts +12 -0
  33. package/dist/link-component.d.ts.map +1 -0
  34. package/dist/link-component.js +2 -0
  35. package/dist/link-component.js.map +1 -0
  36. package/dist/menu/action-menu.d.ts +2 -4
  37. package/dist/menu/action-menu.d.ts.map +1 -1
  38. package/dist/menu/action-menu.js.map +1 -1
  39. package/dist/menu/menu.css +1 -1
  40. package/dist/menu/menu.d.ts +6 -0
  41. package/dist/menu/menu.d.ts.map +1 -1
  42. package/dist/menu/menu.js +1 -1
  43. package/dist/menu/menu.js.map +1 -1
  44. package/dist/segment-group/segment-group.css +31 -0
  45. package/dist/segment-group/segment-group.d.ts +14 -1
  46. package/dist/segment-group/segment-group.d.ts.map +1 -1
  47. package/dist/segment-group/segment-group.js +2 -2
  48. package/dist/segment-group/segment-group.js.map +1 -1
  49. package/package.json +13 -4
package/README.md CHANGED
@@ -50,30 +50,32 @@ importing `ui-core` directly.
50
50
 
51
51
  ## Exports
52
52
 
53
- Every component is available from the root, or on its own subpath when you want to
54
- import just one. The `./css/*` subpaths carry each component's structural CSS
53
+ Every component is available from the root and its own subpath when you
54
+ want to import just one.
55
+ The `./css/*` subpaths carry each component's structural CSS
55
56
  separately, so an app can load only what it renders.
56
57
 
57
58
  | Entry | Contents |
58
59
  |---|---|
59
- | `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`) for compositions that want the same defaults |
60
+ | `@manakind/ui-core` | Everything below, plus every prop type, the `cx` helper, and the built-in fallback glyphs (`FallbackChevronLeft`, `FallbackChevronRight`, `FallbackCheck`, `FallbackCross`, `FallbackPin`) for compositions that want the same defaults |
60
61
  | `@manakind/ui-core/alert` | `Alert` |
61
62
  | `@manakind/ui-core/avatar` | `Avatar` + `initialsOf` |
62
63
  | `@manakind/ui-core/badge` | `Badge` |
64
+ | `@manakind/ui-core/breadcrumb` | `Breadcrumb` |
63
65
  | `@manakind/ui-core/button` | `Button` + `IconButton` |
64
66
  | `@manakind/ui-core/calendar` | `Calendar` |
65
67
  | `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardLink`, `CardDescription`, `CardContent`, `CardFooter` |
66
68
  | `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
67
69
  | `@manakind/ui-core/icon` | `Icon` |
68
70
  | `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
69
- | `@manakind/ui-core/menu` | `Menu`, `MenuTrigger`, `ActionMenu` |
71
+ | `@manakind/ui-core/menu` | `Menu`, `MenuTrigger`, `ActionMenu`; `MenuItem.icon` adds a decorative glyph before its label |
70
72
  | `@manakind/ui-core/popover` | `Popover` |
71
73
  | `@manakind/ui-core/checkbox` | `Checkbox` |
72
- | `@manakind/ui-core/combobox` | `Combobox` |
74
+ | `@manakind/ui-core/combobox` | `Combobox`; `ComboboxItem.group` collects options under named headings, with keyboard navigation in displayed order; `toolbar`, `status` and `facets` put filters, a status line and a pinnable facet column inside the open list |
73
75
  | `@manakind/ui-core/date-input` | `DateInput` |
74
76
  | `@manakind/ui-core/progress` | `Progress` |
75
77
  | `@manakind/ui-core/reorder-control` | `ReorderControl` |
76
- | `@manakind/ui-core/segment-group` | `SegmentGroup` |
78
+ | `@manakind/ui-core/segment-group` | `SegmentGroup`; `fit="content"` sizes segments to their labels, `density="dense"` reduces inline padding |
77
79
  | `@manakind/ui-core/select` | `Select` |
78
80
  | `@manakind/ui-core/switch` | `Switch` |
79
81
  | `@manakind/ui-core/field` | `Field`, `Input`, `Textarea`, `useFieldControl` |
@@ -94,6 +96,7 @@ separately, so an app can load only what it renders.
94
96
  | `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
95
97
  | `@manakind/ui-core/css/avatar` | Avatar structural CSS; its fallback glyph also needs `css/icon` |
96
98
  | `@manakind/ui-core/css/badge` | Badge structural CSS |
99
+ | `@manakind/ui-core/css/breadcrumb` | Breadcrumb structural CSS; a custom separator also needs `css/icon` |
97
100
  | `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
98
101
  | `@manakind/ui-core/css/calendar` | Calendar structural CSS; its paging buttons also need `css/button` and `css/icon` |
99
102
  | `@manakind/ui-core/css/card` | Card structural CSS |
@@ -0,0 +1,47 @@
1
+ @layer components {
2
+ .ds-breadcrumb {
3
+ min-width: 0;
4
+ color: var(--ds-breadcrumb-text);
5
+ font-size: var(--ds-breadcrumb-font-size);
6
+ }
7
+
8
+ .ds-breadcrumb__list {
9
+ display: flex;
10
+ flex-wrap: wrap;
11
+ align-items: center;
12
+ gap: var(--ds-breadcrumb-gap);
13
+ margin: 0;
14
+ padding: 0;
15
+ list-style: none;
16
+ }
17
+
18
+ .ds-breadcrumb__item {
19
+ display: inline-flex;
20
+ align-items: center;
21
+ gap: var(--ds-breadcrumb-gap);
22
+ min-width: 0;
23
+ overflow-wrap: anywhere;
24
+ }
25
+
26
+ .ds-breadcrumb__separator {
27
+ flex-shrink: 0;
28
+ color: var(--ds-breadcrumb-separator);
29
+ }
30
+
31
+ .ds-breadcrumb__link {
32
+ color: inherit;
33
+ text-decoration: none;
34
+ border-radius: var(--ds-breadcrumb-radius);
35
+
36
+ &:hover {
37
+ color: var(--ds-breadcrumb-text-hover);
38
+ text-decoration: underline;
39
+ text-underline-offset: 0.2em;
40
+ }
41
+
42
+ &:focus-visible {
43
+ outline: 2px solid var(--ds-breadcrumb-focus-ring);
44
+ outline-offset: 3px;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { ElementType, ReactNode } from 'react';
2
+ import { type IconSource } from '../icon';
3
+ import type { LinkComponentProps } from '../link-component';
4
+ import './breadcrumb.css';
5
+ /** One ancestor in the trail. */
6
+ export interface BreadcrumbItem {
7
+ /** Stable key. */
8
+ id: string;
9
+ /** What the ancestor is called. A node, so a product can pass a richer label (a category's colour mark, say). */
10
+ label: ReactNode;
11
+ /** Makes the item a link to the ancestor. */
12
+ href?: string;
13
+ }
14
+ /** What the link component receives; the props every `linkComponent` takes. */
15
+ export type BreadcrumbLinkProps = LinkComponentProps;
16
+ export interface BreadcrumbProps {
17
+ /** The ancestors, outermost first. Renders nothing when empty. */
18
+ items: BreadcrumbItem[];
19
+ /**
20
+ * The trail's accessible name: its navigation landmark's. Required, since a
21
+ * list of rows each with a trail would otherwise repeat one landmark name;
22
+ * name it after what it locates ("Where Book the physio lives").
23
+ */
24
+ label: string;
25
+ /** Glyph between items, supplied by the product. Must point RIGHT in a left-to-right layout. Falls back to "/". */
26
+ separator?: IconSource;
27
+ /** Renders each link, so a product passes its router's link. Defaults to `<a>`. */
28
+ linkComponent?: ElementType<BreadcrumbLinkProps>;
29
+ /** Extra class names on the `<nav>`. */
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Where something lives: its ancestors, outermost first, each a link when it
34
+ * has a place of its own. Above a page title, or above a list row's title
35
+ * when the row is filed in a hierarchy.
36
+ *
37
+ * @remarks
38
+ * The trail lists ancestors only — the thing itself is the heading beside it —
39
+ * so no item carries `aria-current`. The separators are decorative; a screen
40
+ * reader hears a list of links in a navigation landmark.
41
+ */
42
+ export declare function Breadcrumb({ items, label, separator, linkComponent: Link, className, }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element | null;
43
+ //# sourceMappingURL=breadcrumb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb.d.ts","sourceRoot":"","sources":["../../src/breadcrumb/breadcrumb.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kBAAkB,CAAC;AAE1B,iCAAiC;AACjC,MAAM,WAAW,cAAc;IAC7B,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,iHAAiH;IACjH,KAAK,EAAE,SAAS,CAAC;IACjB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,+EAA+E;AAC/E,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,mHAAmH;IACnH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,mFAAmF;IACnF,aAAa,CAAC,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACjD,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,SAAS,EACT,aAAa,EAAE,IAAU,EACzB,SAAS,GACV,EAAE,eAAe,kDA2BjB"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from '../cx';
3
+ import { Icon } from '../icon';
4
+ import './breadcrumb.css';
5
+ /**
6
+ * Where something lives: its ancestors, outermost first, each a link when it
7
+ * has a place of its own. Above a page title, or above a list row's title
8
+ * when the row is filed in a hierarchy.
9
+ *
10
+ * @remarks
11
+ * The trail lists ancestors only — the thing itself is the heading beside it —
12
+ * so no item carries `aria-current`. The separators are decorative; a screen
13
+ * reader hears a list of links in a navigation landmark.
14
+ */
15
+ export function Breadcrumb({ items, label, separator, linkComponent: Link = 'a', className, }) {
16
+ if (items.length === 0)
17
+ return null;
18
+ const divider = separator ? (_jsx(Icon, { source: separator, size: "sm", decorative: true, className: "ds-breadcrumb__separator" })) : (_jsx("span", { className: "ds-breadcrumb__separator", "aria-hidden": "true", children: "/" }));
19
+ return (_jsx("nav", { "aria-label": label, className: cx('ds-breadcrumb', className), children: _jsx("ol", { className: "ds-breadcrumb__list", children: items.map((item, index) => (_jsxs("li", { className: "ds-breadcrumb__item", children: [index > 0 && divider, item.href ? (_jsx(Link, { href: item.href, className: "ds-breadcrumb__link", children: item.label })) : (_jsx("span", { className: "ds-breadcrumb__text", children: item.label }))] }, item.id))) }) }));
20
+ }
21
+ //# sourceMappingURL=breadcrumb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb.js","sourceRoot":"","sources":["../../src/breadcrumb/breadcrumb.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAmB,MAAM,SAAS,CAAC;AAEhD,OAAO,kBAAkB,CAAC;AAgC1B;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,SAAS,EACT,aAAa,EAAE,IAAI,GAAG,GAAG,EACzB,SAAS,GACO;IAChB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAC1B,KAAC,IAAI,IAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,QAAC,SAAS,EAAC,0BAA0B,GAAG,CACtF,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,0BAA0B,iBAAa,MAAM,kBAEtD,CACR,CAAC;IACF,OAAO,CACL,4BAAiB,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,YAC/D,aAAI,SAAS,EAAC,qBAAqB,YAChC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,cAAkB,SAAS,EAAC,qBAAqB,aAC9C,KAAK,GAAG,CAAC,IAAI,OAAO,EACpB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACX,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAC,qBAAqB,YACnD,IAAI,CAAC,KAAK,GACN,CACR,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,qBAAqB,YAAE,IAAI,CAAC,KAAK,GAAQ,CAC1D,KARM,IAAI,CAAC,EAAE,CASX,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { BreadcrumbItem, BreadcrumbLinkProps, BreadcrumbProps } from './breadcrumb';
2
+ export { Breadcrumb } from './breadcrumb';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/breadcrumb/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Breadcrumb } from './breadcrumb';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/breadcrumb/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -12,6 +12,11 @@
12
12
  display: none;
13
13
  }
14
14
 
15
+ /*
16
+ * The header stays put and the list under it scrolls, so the controls are
17
+ * always in reach. The popup is no taller than the room the positioner
18
+ * finds below (or above) the field.
19
+ */
15
20
  .ds-combobox__content {
16
21
  display: flex;
17
22
  flex-direction: column;
@@ -19,13 +24,87 @@
19
24
  border: 1px solid var(--ds-select-content-border);
20
25
  border-radius: var(--ds-select-content-radius);
21
26
  background-color: var(--ds-select-content-bg);
22
- max-height: 20rem;
23
- overflow-y: auto;
27
+ max-height: min(20rem, var(--available-height, 20rem));
24
28
  overflow-wrap: anywhere;
25
29
  /* The `popup` layer in ds-config/scripts/stacking.ts, as Select's list. */
26
30
  z-index: 60;
27
31
  }
28
32
 
33
+ .ds-combobox__header {
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: var(--ds-field-gap);
37
+ flex: none;
38
+ padding: var(--ds-select-item-padding-block) var(--ds-select-item-padding-inline);
39
+ margin-block-end: var(--ds-select-content-padding);
40
+ border-block-end: 1px solid var(--ds-select-content-border);
41
+ }
42
+
43
+ .ds-combobox__toolbar {
44
+ display: flex;
45
+ flex-wrap: wrap;
46
+ align-items: center;
47
+ justify-content: space-between;
48
+ gap: var(--ds-field-gap);
49
+ }
50
+
51
+ .ds-combobox__status {
52
+ display: flex;
53
+ flex-wrap: wrap;
54
+ align-items: center;
55
+ gap: var(--ds-field-gap);
56
+ margin: 0;
57
+ color: var(--ds-field-hint-text);
58
+ font-size: var(--ds-field-hint-font-size);
59
+ }
60
+
61
+ /* A pinned facet: the highlighted-item surface, so it reads as chosen. */
62
+ .ds-combobox__chip {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ gap: var(--ds-field-gap);
66
+ padding-inline-start: var(--ds-select-item-padding-inline);
67
+ border-radius: var(--ds-select-content-radius);
68
+ background-color: var(--ds-select-item-bg-highlighted);
69
+ color: var(--ds-select-item-text-highlighted);
70
+ }
71
+
72
+ .ds-combobox__chip-remove,
73
+ .ds-combobox__pin {
74
+ display: inline-flex;
75
+ align-items: center;
76
+ justify-content: center;
77
+ padding: var(--ds-select-content-padding);
78
+ border: 0;
79
+ border-radius: var(--ds-select-content-radius);
80
+ background: none;
81
+ color: inherit;
82
+ cursor: pointer;
83
+
84
+ &:focus-visible {
85
+ outline: 2px solid var(--ds-input-focus-ring);
86
+ outline-offset: 1px;
87
+ }
88
+ }
89
+
90
+ .ds-combobox__list {
91
+ flex: 1 1 auto;
92
+ min-height: 0;
93
+ overflow-y: auto;
94
+ }
95
+
96
+ /*
97
+ * A block, so it can scroll; its row groups then share one anonymous
98
+ * table, so the columns line up across groups. A container, so the facet
99
+ * column can be capped at a share of its width.
100
+ */
101
+ .ds-combobox__list--grid {
102
+ display: block;
103
+ container-type: inline-size;
104
+ border-collapse: separate;
105
+ border-spacing: 0;
106
+ }
107
+
29
108
  .ds-combobox__item {
30
109
  display: flex;
31
110
  flex-direction: column;
@@ -49,11 +128,116 @@
49
128
  }
50
129
  }
51
130
 
131
+ /*
132
+ * A grid row is a table row, which can't round its corners, so its
133
+ * padding, corners and highlight go on its cells. The facet column is as
134
+ * wide as its longest name and the option column takes the rest.
135
+ */
136
+ tr.ds-combobox__item {
137
+ display: table-row;
138
+ padding: 0;
139
+
140
+ &[data-highlighted] {
141
+ background-color: transparent;
142
+ }
143
+
144
+ & > td {
145
+ padding: var(--ds-select-item-padding-block) var(--ds-select-item-padding-inline);
146
+ vertical-align: middle;
147
+ }
148
+
149
+ &[data-highlighted] > td {
150
+ background-color: var(--ds-select-item-bg-highlighted);
151
+ }
152
+
153
+ & > td:first-child {
154
+ border-start-start-radius: inherit;
155
+ border-end-start-radius: inherit;
156
+ }
157
+
158
+ & > td:last-child {
159
+ border-start-end-radius: inherit;
160
+ border-end-end-radius: inherit;
161
+ }
162
+ }
163
+
164
+ .ds-combobox__facet {
165
+ width: 1%;
166
+ color: var(--ds-field-hint-text);
167
+ font-size: var(--ds-field-hint-font-size);
168
+ }
169
+
170
+ /*
171
+ * As wide as the facet's name, so a short one never wraps in its 1% wide
172
+ * column, but no wider than two fifths of the list: a long name wraps
173
+ * there and leaves the option column its room.
174
+ */
175
+ .ds-combobox__facet-content {
176
+ display: inline-flex;
177
+ align-items: center;
178
+ gap: var(--ds-field-gap);
179
+ inline-size: max-content;
180
+ max-inline-size: 40cqi;
181
+ }
182
+
183
+ .ds-combobox__facet-label {
184
+ min-width: 0;
185
+ overflow-wrap: anywhere;
186
+ }
187
+
188
+ /*
189
+ * The pin answers the keyboard too: with the row's pin cell active, the
190
+ * field keeps focus, so the ring is drawn from `data-active`.
191
+ */
192
+ .ds-combobox__pin {
193
+ &[data-active] {
194
+ outline: 2px solid var(--ds-input-focus-ring);
195
+ outline-offset: 1px;
196
+ }
197
+
198
+ &[aria-pressed="true"] {
199
+ color: var(--ds-select-item-text-highlighted);
200
+ }
201
+ }
202
+
203
+ .ds-combobox__item[data-highlighted] .ds-combobox__facet {
204
+ color: inherit;
205
+ }
206
+
207
+ /*
208
+ * A group of options under its heading, set apart from the group above by
209
+ * more space than separates two options, so the groups read as groups.
210
+ */
211
+ .ds-combobox__group + .ds-combobox__group,
212
+ .ds-combobox__item + .ds-combobox__group {
213
+ margin-block-start: var(--ds-combobox-group-gap);
214
+ }
215
+
216
+ /* A grid's row groups take no margin; their heading cell carries the gap. */
217
+ tbody.ds-combobox__group:not(:first-of-type) > tr:first-child > th {
218
+ padding-block-start: calc(var(--ds-select-item-padding-block) + var(--ds-combobox-group-gap));
219
+ }
220
+
221
+ .ds-combobox__group-label {
222
+ display: block;
223
+ padding: var(--ds-select-item-padding-block) var(--ds-select-item-padding-inline);
224
+ color: var(--ds-combobox-group-label-text);
225
+ font-size: var(--ds-combobox-group-label-font-size);
226
+ font-weight: var(--ds-combobox-group-label-font-weight);
227
+ text-align: start;
228
+ }
229
+
52
230
  .ds-combobox__item-description {
53
231
  color: var(--ds-field-hint-text);
54
232
  font-size: var(--ds-field-hint-font-size);
55
233
  }
56
234
 
235
+ /* In a grid the label and description stack inside their table cell. */
236
+ .ds-combobox__cell > .ds-combobox__item-label,
237
+ .ds-combobox__cell > .ds-combobox__item-description {
238
+ display: block;
239
+ }
240
+
57
241
  /*
58
242
  * A highlighted row takes the highlighted text colour, which the hint
59
243
  * colour was never measured against; the description follows the row.
@@ -1,23 +1,62 @@
1
1
  import { type ReactNode, type Ref } from 'react';
2
+ import { type IconSource } from '../icon/icon';
3
+ import '../visually-hidden/visually-hidden.css';
2
4
  import './combobox.css';
3
5
  export type ComboboxSize = 'sm' | 'md' | 'lg';
6
+ /** What an option belongs to, shown in a second column: its category, its project. */
7
+ export interface ComboboxFacet {
8
+ /** Stable value reported when the facet is pinned. */
9
+ value: string;
10
+ /** Text in the facet column, and in the pinned chip. */
11
+ label: string;
12
+ /** Decorative mark before the label, such as the category's icon. */
13
+ icon?: ReactNode;
14
+ }
4
15
  export interface ComboboxItem {
5
16
  /** Stable value reported by `onSelect`. */
6
17
  value: string;
7
- /** Option text, also what typeahead and screen readers use. */
18
+ /** Option text, also what screen readers use. */
8
19
  label: string;
9
20
  /** Optional secondary line under the label, shown muted. */
10
21
  description?: string;
11
22
  /** Individually disable this option without removing it. */
12
23
  disabled?: boolean;
24
+ /**
25
+ * The group the option is listed under, by its heading. Options sharing a
26
+ * group are listed together under it, groups in the order they first
27
+ * appear; options without one (or with an empty name) are listed before
28
+ * any group.
29
+ */
30
+ group?: string;
31
+ /** What the option belongs to, shown in the facet column when `facets` is set. */
32
+ facet?: ComboboxFacet;
33
+ }
34
+ /**
35
+ * A second column naming what each option belongs to, with a pin that
36
+ * narrows the list to it.
37
+ */
38
+ export interface ComboboxFacets {
39
+ /** Heading of the option column, for assistive tech: "Action". */
40
+ itemLabel: string;
41
+ /** Heading of the facet column, for assistive tech: "Category". */
42
+ label: string;
43
+ /** The facet the list is narrowed to, shown as a removable chip in the status line. */
44
+ pinned?: ComboboxFacet | null;
45
+ /**
46
+ * Pins a row's facet, or unpins it with `null` (its pin pressed again, the
47
+ * chip's remove button, or Backspace in the empty field). The caller does
48
+ * the narrowing. Without it, the facet column shows no pins.
49
+ */
50
+ onPinnedChange?: (facet: ComboboxFacet | null) => void;
13
51
  }
14
52
  export interface ComboboxProps {
15
53
  /**
16
54
  * Suggestions for the current text.
17
55
  *
18
- * The caller filters them; the component does not. What counts as a match
19
- * (a prefix, a substring, anything not already chosen) is the product's
20
- * call, and the list it passes is the list that shows.
56
+ * The caller filters, sorts and groups them; the component does not. What
57
+ * counts as a match (a prefix, a substring, a category's name, anything
58
+ * not already chosen) is the product's call, and the list it passes is the
59
+ * list that shows.
21
60
  */
22
61
  items: ComboboxItem[];
23
62
  /** Controlled text in the input. */
@@ -41,6 +80,23 @@ export interface ComboboxProps {
41
80
  placeholder?: string;
42
81
  /** Shown in the open list when `items` is empty. */
43
82
  emptyText?: ReactNode;
83
+ /**
84
+ * Controls at the top of the open list that change what it shows: a
85
+ * `Switch`, a small `SegmentGroup`. One row of them, so the options stay
86
+ * in view; Tab moves into them from the field.
87
+ */
88
+ toolbar?: ReactNode;
89
+ /**
90
+ * One line under the toolbar saying what the list shows, such as "Showing
91
+ * all actions in Health". Announced politely as it changes.
92
+ */
93
+ status?: ReactNode;
94
+ /** Adds the facet column, with its pins. The list becomes a grid. */
95
+ facets?: ComboboxFacets;
96
+ /** Glyph of a row's pin. Defaults to the inlined fallback pin. */
97
+ pinIcon?: IconSource;
98
+ /** Glyph of the pinned chip's remove button. Defaults to the inlined fallback cross. */
99
+ removeIcon?: IconSource;
44
100
  /** Control height and type scale. */
45
101
  size?: ComboboxSize;
46
102
  /** Disable the whole control. */
@@ -53,32 +109,48 @@ export interface ComboboxProps {
53
109
  inputRef?: Ref<HTMLInputElement>;
54
110
  }
55
111
  /**
56
- * A text input that suggests options as you type, built on Ark UI.
112
+ * A text input that suggests options as you type, with optional controls at
113
+ * the top of the open list.
57
114
  *
58
115
  * Choosing a suggestion reports it through `onSelect` and empties the input,
59
116
  * so the field is ready for the next one: the control for adding items to a
60
117
  * list one at a time. It never holds a selection itself; the caller keeps
61
118
  * the list. For a field that keeps one choice, use `Select`.
62
119
  *
63
- * Ark owns the combobox semantics, keyboard navigation (the first suggestion
64
- * is highlighted as you type, so Enter takes it) and dismiss behaviour. This
65
- * wrapper contributes `ds-` classes, binds the input to the `--ds-input-*`
66
- * keys and the list to the `--ds-select-*` keys, so it reads as one family
67
- * with `Input` and `Select`, and offers a flat `items` API.
120
+ * The open list can carry what narrows it, so nothing sits outside the
121
+ * field: a `toolbar` row of switches or a segment group, a `status` line
122
+ * saying what is shown, and with `facets` a second column naming what each
123
+ * option belongs to, whose pin narrows the list to it.
68
124
  *
69
125
  * ```tsx
70
126
  * <Combobox
71
- * label="Add an action"
127
+ * label="Add actions"
72
128
  * items={matches}
73
129
  * inputValue={query}
74
130
  * onInputValueChange={setQuery}
75
131
  * onSelect={(value) => setPicked((list) => [...list, value])}
76
- * emptyText="No matching actions"
132
+ * toolbar={<Switch size="sm" label="Include categories" checked={…} onCheckedChange={…} />}
133
+ * status={`Showing all actions that contain “${query}”`}
134
+ * facets={{ itemLabel: 'Action', label: 'Category', pinned, onPinnedChange: setPinned }}
77
135
  * />
78
136
  * ```
79
137
  *
80
- * The list portals like `Select`'s: into `<body>`, or into the panel of the
81
- * ui-core `Dialog` it opens in, at `z-index: 60`.
138
+ * The field is the APG editable combobox. Focus stays in the input, and the
139
+ * active option is `aria-activedescendant`. Typing highlights the first
140
+ * option, so Enter takes it, and Up and Down walk the options in their drawn
141
+ * order. With `facets` the popup is a grid instead of a listbox: Right, at
142
+ * the end of the text, moves onto the row's pin and Enter then pins it, and
143
+ * Left moves back. Tab moves from the field into the toolbar and the chip,
144
+ * and on out to the next field.
145
+ *
146
+ * The popup is an Ark Popover anchored to the field, so it takes part in
147
+ * the dismiss stack. Escape closes it before a `Dialog` around it, and a
148
+ * click outside closes it. Its wrapper drops the Popover's dialog role, so
149
+ * the listbox or grid inside is the popup assistive tech meets. It portals
150
+ * like `Select`'s list: into `<body>`, or into the panel of the ui-core
151
+ * `Dialog` it opens in, at `z-index: 60`.
152
+ * The field reads the `--ds-input-*` keys and the list the `--ds-select-*`
153
+ * keys, so it reads as one family with `Input` and `Select`.
82
154
  */
83
- export declare function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, size, disabled, invalid, className, inputRef, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
155
+ export declare function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, toolbar, status, facets, pinIcon, removeIcon, size, disabled, invalid, className, inputRef, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
84
156
  //# sourceMappingURL=combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/combobox/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,E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