@lanfermann/ui 0.4.0 → 0.6.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 (177) hide show
  1. package/dist/components/action-bar/action-bar.d.ts +59 -0
  2. package/dist/components/action-bar/action-bar.js +116 -0
  3. package/dist/components/alert/alert.d.ts +1 -1
  4. package/dist/components/alert/alert.js +3 -17
  5. package/dist/components/alert-dialog/alert-dialog.d.ts +1 -1
  6. package/dist/components/app-shell/app-shell.d.ts +33 -0
  7. package/dist/components/app-shell/app-shell.js +93 -0
  8. package/dist/components/attachment/attachment.d.ts +46 -0
  9. package/dist/components/attachment/attachment.js +222 -0
  10. package/dist/components/attachment/kinds.d.ts +7 -0
  11. package/dist/components/attachment/kinds.js +100 -0
  12. package/dist/components/avatar/avatar.d.ts +14 -4
  13. package/dist/components/avatar/avatar.js +57 -13
  14. package/dist/components/avatar-group/avatar-group.d.ts +33 -0
  15. package/dist/components/avatar-group/avatar-group.js +110 -0
  16. package/dist/components/avatar-group/people.d.ts +12 -0
  17. package/dist/components/avatar-group/people.js +24 -0
  18. package/dist/components/badge/badge.d.ts +9 -3
  19. package/dist/components/badge/badge.js +21 -6
  20. package/dist/components/banner/banner.d.ts +39 -0
  21. package/dist/components/banner/banner.js +149 -0
  22. package/dist/components/card/card.d.ts +11 -3
  23. package/dist/components/card/card.js +18 -4
  24. package/dist/components/checkbox-card/checkbox-card.d.ts +21 -0
  25. package/dist/components/checkbox-card/checkbox-card.js +49 -0
  26. package/dist/components/chip/chip-group.d.ts +15 -0
  27. package/dist/components/chip/chip-group.js +44 -0
  28. package/dist/components/chip/chip-variants.d.ts +6 -0
  29. package/dist/components/chip/chip-variants.js +28 -0
  30. package/dist/components/chip/chip.d.ts +39 -0
  31. package/dist/components/chip/chip.js +71 -0
  32. package/dist/components/code-block/code-block-live.d.ts +13 -1
  33. package/dist/components/code-block/code-block-live.js +10 -4
  34. package/dist/components/code-block/code-block.d.ts +1 -0
  35. package/dist/components/code-block/code-copy.d.ts +3 -11
  36. package/dist/components/code-block/code-copy.js +15 -62
  37. package/dist/components/code-block/code-keys.js +10 -22
  38. package/dist/components/code-block/code-lines-live.d.ts +7 -0
  39. package/dist/components/code-block/code-lines-live.js +167 -0
  40. package/dist/components/code-block/code-lines-view.d.ts +1 -0
  41. package/dist/components/code-block/code-lines-view.js +50 -18
  42. package/dist/components/code-block/code-lines.d.ts +3 -0
  43. package/dist/components/code-block/code-tabs.d.ts +1 -0
  44. package/dist/components/code-block/highlight.d.ts +1 -0
  45. package/dist/components/code-block/line-diff.js +135 -0
  46. package/dist/components/combobox/combobox.d.ts +50 -2
  47. package/dist/components/combobox/combobox.js +178 -9
  48. package/dist/components/command/command.d.ts +131 -0
  49. package/dist/components/command/command.js +335 -0
  50. package/dist/components/consent/consent-card.js +365 -0
  51. package/dist/components/consent/consent-embed.d.ts +21 -0
  52. package/dist/components/consent/consent-embed.js +111 -0
  53. package/dist/components/consent/consent-labels.d.ts +70 -0
  54. package/dist/components/consent/consent-labels.js +61 -0
  55. package/dist/components/consent/consent-record.d.ts +95 -0
  56. package/dist/components/consent/consent-record.js +112 -0
  57. package/dist/components/consent/consent-store.d.ts +26 -0
  58. package/dist/components/consent/consent-store.js +240 -0
  59. package/dist/components/consent/consent.d.ts +86 -0
  60. package/dist/components/consent/consent.js +306 -0
  61. package/dist/components/container/container.d.ts +1 -1
  62. package/dist/components/context-menu/context-menu.d.ts +23 -0
  63. package/dist/components/context-menu/context-menu.js +50 -0
  64. package/dist/components/conversation/conversation.d.ts +45 -0
  65. package/dist/components/conversation/conversation.js +295 -0
  66. package/dist/components/conversation/stick.js +23 -0
  67. package/dist/components/copy-button/copy-button.d.ts +50 -0
  68. package/dist/components/copy-button/copy-button.js +65 -0
  69. package/dist/components/copy-page/copy-page.js +7 -17
  70. package/dist/components/copy-pill/copy-pill.js +1 -1
  71. package/dist/components/description-list/description-list.d.ts +32 -0
  72. package/dist/components/description-list/description-list.js +51 -0
  73. package/dist/components/empty/empty.d.ts +38 -0
  74. package/dist/components/empty/empty.js +57 -0
  75. package/dist/components/field/field.js +1 -1
  76. package/dist/components/file-upload/file-upload.d.ts +96 -0
  77. package/dist/components/file-upload/file-upload.js +347 -0
  78. package/dist/components/file-upload/files.d.ts +39 -0
  79. package/dist/components/file-upload/files.js +74 -0
  80. package/dist/components/grow/grow.d.ts +15 -3
  81. package/dist/components/grow/grow.js +31 -10
  82. package/dist/components/heading/heading.d.ts +1 -1
  83. package/dist/components/icon/icon.d.ts +1 -1
  84. package/dist/components/input/input.js +1 -1
  85. package/dist/components/message/message.d.ts +73 -0
  86. package/dist/components/message/message.js +196 -0
  87. package/dist/components/otp-field/otp-field.d.ts +37 -0
  88. package/dist/components/otp-field/otp-field.js +126 -0
  89. package/dist/components/pagination/pagination.d.ts +50 -0
  90. package/dist/components/pagination/pagination.js +188 -0
  91. package/dist/components/prompt-input/keys.js +15 -0
  92. package/dist/components/prompt-input/prompt-input.d.ts +89 -0
  93. package/dist/components/prompt-input/prompt-input.js +331 -0
  94. package/dist/components/radio-card/radio-card.d.ts +23 -0
  95. package/dist/components/radio-card/radio-card.js +48 -0
  96. package/dist/components/rolling-number/rolling-number.d.ts +30 -0
  97. package/dist/components/rolling-number/rolling-number.js +149 -0
  98. package/dist/components/seam/seam.d.ts +1 -1
  99. package/dist/components/secret-field/secret-field.d.ts +53 -0
  100. package/dist/components/secret-field/secret-field.js +121 -0
  101. package/dist/components/section/section.d.ts +1 -1
  102. package/dist/components/select/select.d.ts +1 -1
  103. package/dist/components/select/select.js +1 -1
  104. package/dist/components/shortcut/shortcut.d.ts +46 -0
  105. package/dist/components/shortcut/shortcut.js +87 -0
  106. package/dist/components/sidebar/sidebar-context.js +16 -0
  107. package/dist/components/sidebar/sidebar.d.ts +161 -0
  108. package/dist/components/sidebar/sidebar.js +588 -0
  109. package/dist/components/site-header/site-header.js +1 -1
  110. package/dist/components/skeleton/loaded.d.ts +21 -0
  111. package/dist/components/skeleton/loaded.js +57 -0
  112. package/dist/components/skeleton/skeleton.d.ts +43 -0
  113. package/dist/components/skeleton/skeleton.js +48 -0
  114. package/dist/components/sources/source-list.d.ts +17 -0
  115. package/dist/components/sources/source-list.js +26 -0
  116. package/dist/components/sources/sources.d.ts +45 -0
  117. package/dist/components/sources/sources.js +167 -0
  118. package/dist/components/stat/stat.d.ts +57 -0
  119. package/dist/components/stat/stat.js +110 -0
  120. package/dist/components/steps/steps.d.ts +57 -0
  121. package/dist/components/steps/steps.js +131 -0
  122. package/dist/components/table/table.d.ts +18 -9
  123. package/dist/components/table/table.js +21 -13
  124. package/dist/components/text/text.d.ts +1 -1
  125. package/dist/components/theme-switch/theme-switch.js +1 -1
  126. package/dist/components/time-field/time-field.js +1 -1
  127. package/dist/components/timeline/timeline.d.ts +45 -0
  128. package/dist/components/timeline/timeline.js +86 -0
  129. package/dist/components/toast/toast.js +10 -26
  130. package/dist/components/toggle/toggle.d.ts +24 -0
  131. package/dist/components/toggle/toggle.js +53 -0
  132. package/dist/components/toggle-group/toggle-group.d.ts +27 -0
  133. package/dist/components/toggle-group/toggle-group.js +38 -0
  134. package/dist/components/toolbar/toolbar-context.js +12 -0
  135. package/dist/components/toolbar/toolbar.d.ts +45 -0
  136. package/dist/components/toolbar/toolbar.js +92 -0
  137. package/dist/components/trace/trace.d.ts +2 -1
  138. package/dist/components/trace/trace.js +14 -26
  139. package/dist/index.d.ts +46 -3
  140. package/dist/index.js +44 -3
  141. package/dist/internal/arriving-pieces.js +56 -0
  142. package/dist/internal/arriving.js +171 -0
  143. package/dist/internal/avatar-cut.d.ts +15 -0
  144. package/dist/internal/avatar-cut.js +83 -0
  145. package/dist/internal/choice-card.d.ts +15 -0
  146. package/dist/internal/choice-card.js +65 -0
  147. package/dist/internal/clipboard.js +37 -0
  148. package/dist/internal/copy.js +58 -0
  149. package/dist/internal/field.js +24 -4
  150. package/dist/internal/glyphs.js +26 -1
  151. package/dist/internal/live-list.js +41 -0
  152. package/dist/internal/number-places.js +156 -0
  153. package/dist/internal/picker-sheet.js +1 -1
  154. package/dist/internal/presence-dot.js +24 -0
  155. package/dist/internal/presence.js +104 -0
  156. package/dist/internal/rail-mark.d.ts +3 -0
  157. package/dist/internal/rail-mark.js +33 -0
  158. package/dist/internal/status-icon.js +22 -0
  159. package/dist/internal/travelling-mark.js +204 -0
  160. package/dist/lib/cn.js +4 -0
  161. package/dist/lib/shortcut.d.ts +11 -0
  162. package/dist/lib/shortcut.js +165 -0
  163. package/package.json +1 -1
  164. package/src/styles/action-bar.css +28 -0
  165. package/src/styles/assistant.css +83 -0
  166. package/src/styles/avatar.css +24 -0
  167. package/src/styles/code.css +89 -1
  168. package/src/styles/consent.css +65 -0
  169. package/src/styles/copy.css +12 -11
  170. package/src/styles/depth.css +46 -2
  171. package/src/styles/marks.css +20 -2
  172. package/src/styles/rail.css +49 -0
  173. package/src/styles/rolling-number.css +94 -0
  174. package/src/styles/steps.css +98 -0
  175. package/src/styles/timeline.css +48 -0
  176. package/src/styles/travel.css +36 -0
  177. package/src/styles.css +9 -0
@@ -1,13 +1,23 @@
1
1
  "use client";
2
+ import { chipDisabledLook, chipFace, chipMotion, chipRemoveKey, chipShape } from "../chip/chip-variants.js";
2
3
  import { useGround } from "../ground/ground.js";
4
+ import { Grow } from "../grow/grow.js";
3
5
  import { Icon } from "../icon/icon.js";
4
- import { bareControl, fieldShell, fieldShellSize, focusFieldControl } from "../../internal/field.js";
5
- import { ChevronDownGlyph, CloseGlyph } from "../../internal/glyphs.js";
6
+ import { bareControl, fieldShell, fieldShellGrowing, fieldShellGrowingSize, fieldShellSize, fieldText, focusFieldControl } from "../../internal/field.js";
7
+ import { ChevronDownGlyph, CloseGlyph, PlusGlyph } from "../../internal/glyphs.js";
6
8
  import { listGroupLabel, listItem, listSeparator, listSheet, popupMotion } from "../../internal/popup.js";
9
+ import { placeInRow, placeProps, useLive, usePresence } from "../../internal/presence.js";
7
10
  import { cn, mergeClassName } from "../../lib/cn.js";
8
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
+ import { useRef, useState } from "react";
9
13
  import { Combobox as Combobox$1 } from "@base-ui/react/combobox";
10
14
  // src/components/combobox/combobox.tsx
15
+ function isOption(value) {
16
+ return typeof value === "object" && value !== null && "label" in value;
17
+ }
18
+ function isCreateOption(value) {
19
+ return isOption(value) && "create" in value;
20
+ }
11
21
  /**
12
22
  * A select you can type into: for lists too long to scan (a customer out of two hundred), where
13
23
  * people know what they are looking for. Typing filters the list; only an entry of the list can
@@ -17,20 +27,65 @@ import { Combobox as Combobox$1 } from "@base-ui/react/combobox";
17
27
  * object, is the value: `defaultValue={items[0]}`, `onValueChange={(option) => …}`. In a form
18
28
  * its `value` is what is submitted.
19
29
  *
30
+ * With `multiple` the value is a list of options and the field is a `ComboboxChips`: every
31
+ * chosen option is a chip in it. The list then stays open after a choice, so several can be
32
+ * taken in a row, and each is submitted under the field's name.
33
+ *
20
34
  * Typing ignores case and accents: "gart" finds "Gärtnerei" and "cafe" finds "Café". Pass
21
35
  * `locale` (`"de-DE"`) so that does not depend on the machine. The first match is highlighted
22
36
  * while typing, so Enter takes it.
23
37
  */
24
- function Combobox({ autoHighlight = true, filter, locale, ...props }) {
38
+ function Combobox({ autoHighlight = true, filter, locale, items, multiple, onCreate, createLabel = (label) => `„${label}“ anlegen`, inputValue, defaultInputValue, onInputValueChange, onValueChange, onOpenChange, ...props }) {
25
39
  const folding = Combobox$1.useFilter({
26
40
  locale,
27
41
  usage: "sort",
28
42
  sensitivity: "base"
29
43
  });
44
+ const [typed, setTyped] = useState(typeof defaultInputValue === "string" ? defaultInputValue : "");
45
+ const ownsText = multiple === true && inputValue === void 0;
46
+ const wanted = onCreate ? typed.trim() : "";
47
+ let offered = items;
48
+ if (wanted !== "" && Array.isArray(items) && items.every(isOption)) {
49
+ const sameName = new Intl.Collator(locale, { sensitivity: "base" });
50
+ if (!items.some((option) => sameName.compare(option.label, wanted) === 0)) {
51
+ const create = {
52
+ value: wanted,
53
+ label: wanted,
54
+ create: createLabel(wanted)
55
+ };
56
+ offered = [...items, create];
57
+ }
58
+ }
59
+ const changed = (next, details) => {
60
+ if (ownsText && details.reason === "item-press") setTyped("");
61
+ const chosen = Array.isArray(next) ? next : [next];
62
+ const made = onCreate ? chosen.find(isCreateOption) : void 0;
63
+ if (!made || !onCreate) {
64
+ onValueChange?.(next, details);
65
+ return;
66
+ }
67
+ const option = onCreate(made.label);
68
+ const others = chosen.filter((entry) => !isCreateOption(entry));
69
+ const value = multiple ? option === void 0 ? others : [...others, option] : option ?? null;
70
+ onValueChange?.(value, details);
71
+ };
30
72
  return /* @__PURE__ */ jsx(Combobox$1.Root, {
31
73
  autoHighlight,
32
74
  locale,
33
75
  filter: filter === void 0 ? folding.contains : filter,
76
+ items: offered,
77
+ multiple,
78
+ inputValue: ownsText ? typed : inputValue,
79
+ defaultInputValue: ownsText ? void 0 : defaultInputValue,
80
+ onInputValueChange: (value, details) => {
81
+ setTyped(value);
82
+ onInputValueChange?.(value, details);
83
+ },
84
+ onValueChange: changed,
85
+ onOpenChange: (open, details) => {
86
+ if (multiple && !open && details.reason === "item-press") details.cancel();
87
+ onOpenChange?.(open, details);
88
+ },
34
89
  ...props
35
90
  });
36
91
  }
@@ -74,6 +129,116 @@ function ComboboxInput({ className, size = "md", clearLabel = "Auswahl löschen"
74
129
  ]
75
130
  });
76
131
  }
132
+ const chipKey = (item) => String(isOption(item) ? item.value : item);
133
+ const chipText = (item) => isOption(item) ? item.label : String(item);
134
+ /**
135
+ * The chips and the input, in one row that wraps. A chip that its owner took out of the value
136
+ * stays where it stood until it has faded, as in a `ChipGroup`, but as a plain copy: Base UI
137
+ * counts its chips to know which one Backspace takes, and one that is gone must not be counted.
138
+ */
139
+ function ChipsRow({ chosen, chipVariant, chipsLabel, removeLabel, chipsHint, placeholder, ...props }) {
140
+ const live = useLive();
141
+ const row = useRef(null);
142
+ const { places, left } = usePresence(chosen, chipKey, row);
143
+ const look = cn(chipShape, chipFace[chipVariant], "pr-0.5");
144
+ return /* @__PURE__ */ jsxs(Combobox$1.Chips, {
145
+ ref: row,
146
+ "data-slot": "combobox-chips",
147
+ "data-live": live ? "" : void 0,
148
+ "aria-label": chosen.length > 0 ? chipsLabel : void 0,
149
+ className: "flex min-h-(--field-height) min-w-0 flex-1 flex-wrap items-center gap-(--chip-gap) p-[calc((var(--field-height)-1.375rem)/2)] [--chip-gap:0.25rem]",
150
+ children: [places.map((place) => {
151
+ const text = chipText(place.item);
152
+ return /* @__PURE__ */ jsx("span", {
153
+ "data-slot": "chip-place",
154
+ ...placeProps(place, left),
155
+ className: placeInRow,
156
+ children: /* @__PURE__ */ jsx("span", {
157
+ className: "flex min-w-0 *:shrink-0",
158
+ children: place.leaving ? /* @__PURE__ */ jsxs("span", {
159
+ "aria-hidden": true,
160
+ "data-slot": "combobox-chip",
161
+ className: cn(look, "opacity-0 transition-opacity spring-leave starting:opacity-100"),
162
+ children: [text, /* @__PURE__ */ jsx("span", {
163
+ className: "flex size-[1.125rem] items-center justify-center text-fg-muted",
164
+ children: /* @__PURE__ */ jsx(CloseGlyph, {
165
+ width: 8,
166
+ height: 8
167
+ })
168
+ })]
169
+ }) : /* @__PURE__ */ jsxs(Combobox$1.Chip, {
170
+ "data-slot": "combobox-chip",
171
+ "aria-label": text,
172
+ className: cn(look, chipDisabledLook, "data-disabled:pr-2", chipMotion, "focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent"),
173
+ children: [/* @__PURE__ */ jsx("span", {
174
+ "data-slot": "chip-label",
175
+ className: "truncate",
176
+ children: text
177
+ }), /* @__PURE__ */ jsx(Combobox$1.ChipRemove, {
178
+ "data-slot": "chip-remove",
179
+ "aria-label": `${text} ${removeLabel}`,
180
+ className: cn(chipRemoveKey, "data-disabled:hidden"),
181
+ children: /* @__PURE__ */ jsx(CloseGlyph, {
182
+ width: 8,
183
+ height: 8
184
+ })
185
+ })]
186
+ })
187
+ })
188
+ }, place.key);
189
+ }), /* @__PURE__ */ jsx(Combobox$1.Input, {
190
+ "data-slot": "combobox-input",
191
+ "data-field-control": "",
192
+ placeholder: chosen.length > 0 ? void 0 : placeholder,
193
+ "aria-description": chosen.length > 0 ? chipsHint(chosen.length) : void 0,
194
+ className: cn("h-[1.375rem] bg-transparent px-1.5 text-control text-fg focus:outline-hidden data-disabled:text-on-disabled", "w-12 max-w-full min-w-12 grow supports-[field-sizing:content]:[field-sizing:content] supports-[field-sizing:content]:w-auto supports-[field-sizing:content]:min-w-6", "first:pl-[calc(var(--field-pad)-(var(--field-height)-1.375rem)/2)]", fieldText),
195
+ ...props
196
+ })]
197
+ });
198
+ }
199
+ /**
200
+ * The field of a `Combobox multiple`: every chosen option is a chip in it, and the input stands
201
+ * after the last one. Backspace in the empty input takes the last chip, Arrow left walks into
202
+ * the chips, and each chip has a key that takes it away.
203
+ *
204
+ * A chip that joins seats into its place, one that leaves fades while its neighbours close up,
205
+ * and when the chips need another line the field eases to its new height, so what stands below
206
+ * is pushed and does not jump. Give it a name with a `FieldLabel` or an `aria-label`; the
207
+ * placeholder is an example and shows only while nothing is chosen.
208
+ */
209
+ function ComboboxChips({ className, size = "md", chipVariant = "flat", chipsLabel = "Ausgewählt", removeLabel = "entfernen", chipsHint = (count) => `${count} ausgewählt. Am Anfang des Felds führt die Pfeiltaste nach links zu den gewählten Einträgen.`, clearLabel = "Auswahl löschen", openLabel = "Liste öffnen", ...props }) {
210
+ return /* @__PURE__ */ jsxs(Combobox$1.InputGroup, {
211
+ "data-slot": "combobox-input-group",
212
+ "data-size": size,
213
+ render: /* @__PURE__ */ jsx(Grow, {
214
+ contentClassName: "flex items-start",
215
+ className: cn(fieldShellGrowing, fieldShellGrowingSize[size], "has-[[data-slot=combobox-chip]:focus-visible]:depth-field-focus", className)
216
+ }),
217
+ onMouseDown: focusFieldControl,
218
+ children: [
219
+ /* @__PURE__ */ jsx(Combobox$1.Value, { children: (chosen) => /* @__PURE__ */ jsx(ChipsRow, {
220
+ chosen: chosen ?? [],
221
+ chipVariant,
222
+ chipsLabel,
223
+ removeLabel,
224
+ chipsHint,
225
+ ...props
226
+ }) }),
227
+ /* @__PURE__ */ jsx(Combobox$1.Clear, {
228
+ "data-slot": "combobox-clear",
229
+ "aria-label": clearLabel,
230
+ className: cn(innerButton, "mt-1 transition-[opacity,scale] spring-snap data-disabled:hidden data-starting-style:scale-75 data-starting-style:opacity-0", "data-ending-style:opacity-0 data-ending-style:spring-leave"),
231
+ children: /* @__PURE__ */ jsx(CloseGlyph, {})
232
+ }),
233
+ /* @__PURE__ */ jsx(Combobox$1.Trigger, {
234
+ "data-slot": "combobox-trigger",
235
+ "aria-label": openLabel,
236
+ className: cn(innerButton, "mt-1"),
237
+ children: /* @__PURE__ */ jsx(ChevronDownGlyph, {})
238
+ })
239
+ ]
240
+ });
241
+ }
77
242
  /**
78
243
  * The list, as a sheet that grows out of the field and is at least as wide. It looks and behaves
79
244
  * like the list of a `Select` or a `Menu`.
@@ -109,9 +274,6 @@ function ComboboxContent({ className, side = "bottom", align = "start", sideOffs
109
274
  })
110
275
  }) });
111
276
  }
112
- function isOption(value) {
113
- return typeof value === "object" && value !== null && "label" in value;
114
- }
115
277
  /**
116
278
  * One row. Pass the option as `value`; its label, icon and detail are shown unless you give
117
279
  * children or props of your own. The chosen row carries the disc, as in a `Select`.
@@ -127,7 +289,14 @@ function ComboboxItem({ className, children, icon, detail, value, ...props }) {
127
289
  className: mergeClassName(["group", listItem], className),
128
290
  ...props,
129
291
  children: [
130
- /* @__PURE__ */ jsx("span", {
292
+ isCreateOption(itemValue) ? /* @__PURE__ */ jsx("span", {
293
+ "aria-hidden": true,
294
+ className: "flex size-2 shrink-0 items-center justify-center text-fg-muted",
295
+ children: /* @__PURE__ */ jsx(PlusGlyph, {
296
+ width: 10,
297
+ height: 10
298
+ })
299
+ }) : /* @__PURE__ */ jsx("span", {
131
300
  "aria-hidden": true,
132
301
  className: "mark mark-quiet group-data-selected:mark-on"
133
302
  }),
@@ -138,7 +307,7 @@ function ComboboxItem({ className, children, icon, detail, value, ...props }) {
138
307
  /* @__PURE__ */ jsx("span", {
139
308
  "data-slot": "combobox-item-text",
140
309
  className: "min-w-0 truncate",
141
- children: children ?? option?.label
310
+ children: children ?? (isCreateOption(itemValue) ? itemValue.create : option?.label)
142
311
  }),
143
312
  resolvedDetail !== void 0 && /* @__PURE__ */ jsx("span", {
144
313
  "data-slot": "combobox-item-detail",
@@ -166,4 +335,4 @@ function ComboboxSeparator({ className, ...props }) {
166
335
  ...props
167
336
  });
168
337
  }
169
- export { Combobox, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator };
338
+ export { Combobox, ComboboxChips, ComboboxCollection, ComboboxContent, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator };
@@ -0,0 +1,131 @@
1
+ import { IconSvgElement } from "../icon/icon.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ import { Autocomplete } from "@base-ui/react/autocomplete";
4
+ import { Dialog } from "@base-ui/react/dialog";
5
+ /** One thing the palette offers: a page to go to, or something to do. */
6
+ export type CommandEntry = {
7
+ /** Tells the entries apart. */
8
+ value: string;
9
+ /** What is shown and typed against. */
10
+ label: string;
11
+ /** Stands before the label. Give every entry of a list one or none. */
12
+ icon?: IconSvgElement;
13
+ /** Other words it is found by: "neu" and "erstellen" for "Angebot schreiben". */
14
+ keywords?: readonly string[];
15
+ /** A quiet fact at the end of the row: where it belongs, how many there are. */
16
+ detail?: ReactNode;
17
+ /** The shortcut that does the same without the palette, written as `Shortcut` writes one. */
18
+ shortcut?: string;
19
+ /** What choosing it does. The palette closes afterwards. */
20
+ onSelect?: () => void;
21
+ /**
22
+ * Entries of its own. Choosing it then opens them as a second list in the same sheet,
23
+ * instead of closing: "Kunde zuweisen …" opens the customers.
24
+ */
25
+ page?: CommandItems;
26
+ /** The placeholder of the field while its page is open: an example of one of its entries. */
27
+ pagePlaceholder?: string;
28
+ disabled?: boolean;
29
+ };
30
+ /** Entries that belong together, under their name (`value`). */
31
+ export type CommandSection = {
32
+ value: string;
33
+ items: readonly CommandEntry[];
34
+ };
35
+ /** What a list holds: entries, or sections of entries. */
36
+ export type CommandItems = readonly CommandEntry[] | readonly CommandSection[];
37
+ export type CommandProps = {
38
+ /** What the palette offers: entries, or sections of entries. */
39
+ items: CommandItems;
40
+ /** Whether the palette is open (controlled). */
41
+ open?: boolean;
42
+ /** Whether the palette is open at first. */
43
+ defaultOpen?: boolean;
44
+ onOpenChange?: (open: boolean) => void;
45
+ /** The shortcut that opens and closes it, written as `Shortcut` writes one. `false` for none. */
46
+ shortcut?: string | false;
47
+ /** What stands in the field when the palette opens. Nothing unless set. */
48
+ defaultQuery?: string;
49
+ /** Called with what is typed, for a palette that fetches its entries. */
50
+ onQueryChange?: (query: string) => void;
51
+ /** The name of the palette and of its field for assistive tech. */
52
+ label?: string;
53
+ /** The language entries are compared in while typing (`"de-DE"`). The machine's unless set. */
54
+ locale?: Intl.LocalesArgument;
55
+ /**
56
+ * Whether the page behind is inert. Leave it on: the palette is a dialog. `false` is for a
57
+ * palette that is shown standing open, as in a picture of it.
58
+ */
59
+ modal?: boolean;
60
+ children: ReactNode;
61
+ };
62
+ /**
63
+ * The command palette: every page and every action of an app, reached by typing a few letters.
64
+ * It opens on ⌘K over whatever one is doing, and leaves as soon as something is chosen. It is
65
+ * for people who know what they want; everything in it must also be reachable by pointing.
66
+ *
67
+ * Give it the entries as `items` and put a `CommandContent` inside, with a `CommandInput`, a
68
+ * `CommandList` and a `CommandFooter`. An entry does something (`onSelect`) or opens a list of
69
+ * its own (`page`). Typing filters by label and keywords, ignoring case and accents.
70
+ *
71
+ * Word an entry like a button, the thing first and the action last ("Angebot schreiben"), or
72
+ * as the place it leads to ("Einstellungen"). An entry that opens a second list ends in an
73
+ * ellipsis ("Kunde zuweisen …").
74
+ */
75
+ export declare function Command({ items, open: controlled, defaultOpen, onOpenChange, shortcut, defaultQuery, onQueryChange, label, locale, modal, children }: CommandProps): import("react").JSX.Element;
76
+ /**
77
+ * A button that opens the palette, for those who do not know the shortcut yet. Render a
78
+ * `Button` through it and show the shortcut inside:
79
+ * `<CommandTrigger render={<Button />}>Suchen <Shortcut keys="mod+k" /></CommandTrigger>`.
80
+ */
81
+ export declare function CommandTrigger(props: Dialog.Trigger.Props): import("react").JSX.Element;
82
+ export type CommandContentProps = Dialog.Popup.Props;
83
+ /**
84
+ * The sheet, with its scrim: the page behind is dimmed as it is behind a dialog. It stands in
85
+ * the upper third of the window, where the eyes are and where a phone's keyboard leaves it
86
+ * alone.
87
+ *
88
+ * It is opened many times a day, mostly from the keyboard, so it does not make an entrance: it
89
+ * is there on `snap`, grown by a fiftieth and without travel, and it leaves by fading.
90
+ */
91
+ export declare function CommandContent({ className, children, ...props }: CommandContentProps): import("react").JSX.Element;
92
+ export type CommandInputProps = Omit<Autocomplete.Input.Props, "className"> & {
93
+ className?: string;
94
+ };
95
+ /**
96
+ * The field one types into. It has no frame of its own: it is the head of the sheet. A page
97
+ * that was opened stands before the text as a small plug, and Backspace in the empty field
98
+ * goes back out of it.
99
+ *
100
+ * The placeholder is an example of what can be typed ("z. B. Angebot schreiben"), not an
101
+ * instruction.
102
+ */
103
+ export declare function CommandInput({ className, placeholder, onKeyDown, ...props }: CommandInputProps): import("react").JSX.Element;
104
+ export type CommandListProps = Omit<ComponentProps<"div">, "children"> & {
105
+ /**
106
+ * What stands there when nothing matches: one sentence that names the kind of thing that was
107
+ * looked for ("Zu dieser Suche wurde nichts gefunden.").
108
+ */
109
+ empty?: ReactNode;
110
+ };
111
+ /**
112
+ * The entries that match what was typed, in their sections. The first one is highlighted, so
113
+ * Enter takes it; the arrows move the highlight, which is instant like a menu's. The list is
114
+ * as tall as what it holds, up to a limit, and the sheet follows it instead of jumping.
115
+ */
116
+ export declare function CommandList({ empty, className, ...props }: CommandListProps): import("react").JSX.Element;
117
+ export type CommandFooterProps = ComponentProps<"div"> & {
118
+ /** What Enter does with the highlighted entry. */
119
+ chooseLabel?: string;
120
+ /** What the arrow keys do. */
121
+ moveLabel?: string;
122
+ /** What Backspace does inside a page. */
123
+ backLabel?: string;
124
+ /** What Escape does. */
125
+ closeLabel?: string;
126
+ };
127
+ /**
128
+ * The foot of the sheet: the keys that work here, said once. It is for the eye only, and it is
129
+ * not there on a touch screen, which has no keys. Pass children to put something else there.
130
+ */
131
+ export declare function CommandFooter({ chooseLabel, moveLabel, backLabel, closeLabel, className, children, ...props }: CommandFooterProps): import("react").JSX.Element;