@vendure-io/ui 2.1.0 → 3.0.0-next.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/package.json +19 -5
- package/src/components/atoms/accordion.tsx +21 -6
- package/src/components/atoms/alert-dialog.tsx +31 -6
- package/src/components/atoms/alert.tsx +73 -13
- package/src/components/atoms/avatar.tsx +1 -1
- package/src/components/atoms/badge.tsx +7 -2
- package/src/components/atoms/breadcrumb.tsx +137 -4
- package/src/components/atoms/button-group.tsx +30 -6
- package/src/components/atoms/button.tsx +128 -18
- package/src/components/atoms/calendar.tsx +6 -6
- package/src/components/atoms/card.tsx +130 -16
- package/src/components/atoms/carousel.tsx +16 -9
- package/src/components/atoms/chart.tsx +87 -1
- package/src/components/atoms/checkbox.tsx +85 -7
- package/src/components/atoms/collapsible.tsx +2 -1
- package/src/components/atoms/combobox.tsx +147 -21
- package/src/components/atoms/command.tsx +414 -12
- package/src/components/atoms/context-menu.tsx +28 -23
- package/src/components/atoms/dialog.tsx +151 -29
- package/src/components/atoms/direction.tsx +23 -2
- package/src/components/atoms/drawer.tsx +15 -10
- package/src/components/atoms/dropdown-menu.tsx +43 -28
- package/src/components/atoms/empty.tsx +4 -0
- package/src/components/atoms/field.tsx +41 -15
- package/src/components/atoms/hover-card.tsx +61 -8
- package/src/components/atoms/input-group.tsx +17 -9
- package/src/components/atoms/input-otp.tsx +6 -6
- package/src/components/atoms/input.tsx +7 -1
- package/src/components/atoms/item.tsx +3 -3
- package/src/components/atoms/kbd.tsx +32 -3
- package/src/components/atoms/label-swap.tsx +82 -0
- package/src/components/atoms/label.tsx +1 -1
- package/src/components/atoms/menubar.tsx +28 -26
- package/src/components/atoms/native-select.tsx +3 -2
- package/src/components/atoms/navigation-menu.tsx +13 -8
- package/src/components/atoms/pagination.tsx +2 -2
- package/src/components/atoms/popover.tsx +23 -5
- package/src/components/atoms/progress.tsx +46 -33
- package/src/components/atoms/radio-group.tsx +9 -4
- package/src/components/atoms/resizable.tsx +1 -1
- package/src/components/atoms/scroll-area.tsx +2 -2
- package/src/components/atoms/select.tsx +258 -19
- package/src/components/atoms/sheet.tsx +59 -23
- package/src/components/atoms/sidebar.tsx +333 -23
- package/src/components/atoms/skeleton.tsx +1 -1
- package/src/components/atoms/slider.tsx +1 -1
- package/src/components/atoms/sonner.tsx +128 -38
- package/src/components/atoms/spinner.tsx +1 -1
- package/src/components/atoms/switch.tsx +10 -5
- package/src/components/atoms/table.tsx +147 -7
- package/src/components/atoms/tabs.tsx +3 -3
- package/src/components/atoms/textarea.tsx +3 -1
- package/src/components/atoms/toggle-group.tsx +4 -2
- package/src/components/atoms/toggle.tsx +28 -6
- package/src/components/atoms/tooltip.tsx +85 -15
- package/src/components/molecules/anonymized-token.tsx +24 -8
- package/src/components/molecules/app-shell.tsx +53 -20
- package/src/components/molecules/arrow-link.tsx +40 -0
- package/src/components/molecules/chip.tsx +2 -2
- package/src/components/molecules/code-block.tsx +54 -31
- package/src/components/molecules/collapsible-section.tsx +129 -0
- package/src/components/molecules/confirm-dialog.tsx +113 -9
- package/src/components/molecules/copyable-text.tsx +75 -11
- package/src/components/molecules/data-table/data-table-bulk-actions.tsx +32 -4
- package/src/components/molecules/data-table/data-table-column-header.tsx +20 -3
- package/src/components/molecules/data-table/data-table-filters.tsx +1 -1
- package/src/components/molecules/data-table/data-table-helpers.tsx +68 -1
- package/src/components/molecules/data-table/data-table-selection-storage.tsx +115 -0
- package/src/components/molecules/data-table/data-table-types.tsx +138 -4
- package/src/components/molecules/data-table/data-table-view-options.tsx +2 -2
- package/src/components/molecules/data-table/data-table.tsx +916 -84
- package/src/components/molecules/data-table/table-pagination.tsx +2 -2
- package/src/components/molecules/date-picker.tsx +13 -7
- package/src/components/molecules/date-range-picker.tsx +13 -6
- package/src/components/molecules/date-time-picker.tsx +13 -7
- package/src/components/molecules/date-time.tsx +8 -1
- package/src/components/molecules/direction-link.tsx +130 -0
- package/src/components/molecules/elapsed-time.tsx +223 -0
- package/src/components/molecules/file-dropzone.tsx +2 -2
- package/src/components/molecules/id-chip.tsx +169 -32
- package/src/components/molecules/inline-code.tsx +4 -0
- package/src/components/molecules/issued-secret.tsx +318 -0
- package/src/components/molecules/list-row.tsx +349 -0
- package/src/components/molecules/live-indicator.tsx +83 -0
- package/src/components/molecules/page-header.tsx +117 -5
- package/src/components/molecules/password-input.tsx +2 -2
- package/src/components/molecules/relative-time.tsx +85 -56
- package/src/components/molecules/search-trigger.tsx +127 -0
- package/src/components/molecules/secret-value.tsx +26 -9
- package/src/components/molecules/skip-link.tsx +1 -1
- package/src/components/molecules/stat-card.tsx +4 -4
- package/src/components/molecules/state-views/empty-state.tsx +35 -17
- package/src/components/molecules/state-views/error-state.tsx +32 -14
- package/src/components/molecules/status-badge.tsx +415 -49
- package/src/components/molecules/time-tooltip.tsx +140 -0
- package/src/components/molecules/timeline.tsx +246 -0
- package/src/components/molecules/visibility-icon.tsx +89 -0
- package/src/hooks/use-active-label-size.ts +32 -0
- package/src/hooks/use-pinned-height.ts +55 -0
- package/src/hooks/use-scrolled.ts +27 -0
- package/src/lib/content-inset.ts +17 -0
- package/src/lib/control-name.ts +55 -0
- package/src/lib/dialog-padding.ts +48 -0
- package/src/lib/field-surface.ts +31 -0
- package/src/lib/format-elapsed.ts +67 -0
- package/src/lib/format-relative.ts +29 -1
- package/src/lib/highlight.ts +3 -3
- package/src/lib/menu-item.tsx +72 -0
- package/src/lib/outline-edge.ts +21 -0
- package/src/lib/popup-align.ts +67 -0
- package/src/lib/popup-direction.ts +22 -0
- package/src/lib/popup-motion.ts +19 -0
- package/src/lib/state-dictionary.ts +42 -6
- package/src/lib/syntax-colors.ts +8 -0
- package/src/lib/tint-recipes.ts +68 -0
- package/src/lib/tone-icons.ts +24 -0
- package/src/lib/trigger-slot.ts +16 -0
- package/src/lib/utils.ts +104 -1
|
@@ -4,6 +4,10 @@ import * as React from "react"
|
|
|
4
4
|
import { Combobox as ComboboxPrimitive } from "@base-ui/react"
|
|
5
5
|
|
|
6
6
|
import { cn } from "@vendure-io/ui/lib/utils"
|
|
7
|
+
import { MenuCheck, menuCheckItem, menuItemDisabled } from "../../lib/menu-item.tsx"
|
|
8
|
+
import { statusChipRing } from "@vendure-io/ui/lib/tint-recipes"
|
|
9
|
+
import { fieldSurface, fieldSurfaceWithin } from "@vendure-io/ui/lib/field-surface"
|
|
10
|
+
import { popupMotion } from "../../lib/popup-motion.ts"
|
|
7
11
|
import { Button } from "@vendure-io/ui/components/atoms/button"
|
|
8
12
|
import {
|
|
9
13
|
InputGroup,
|
|
@@ -11,9 +15,45 @@ import {
|
|
|
11
15
|
InputGroupButton,
|
|
12
16
|
InputGroupInput,
|
|
13
17
|
} from "@vendure-io/ui/components/atoms/input-group"
|
|
14
|
-
import { ChevronDownIcon, XIcon
|
|
18
|
+
import { ChevronDownIcon, XIcon } from "lucide-react"
|
|
19
|
+
import { usePopupDir } from "../../lib/popup-direction.ts"
|
|
20
|
+
import { usePopupAlign } from "../../lib/popup-align.ts"
|
|
21
|
+
import { hasName, nameFrom, useRegisteredRef } from "../../lib/control-name.ts"
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The controls of the nearest Combobox. Base UI names the trigger and the
|
|
25
|
+
* input but not the popup or the list, so ComboboxContent and ComboboxList
|
|
26
|
+
* take their name from here: the field trigger when there is one (the search
|
|
27
|
+
* input then sits in the popup), else the input.
|
|
28
|
+
*/
|
|
29
|
+
type ComboboxControls = {
|
|
30
|
+
trigger: HTMLElement | null
|
|
31
|
+
input: HTMLElement | null
|
|
32
|
+
setTrigger: (trigger: HTMLElement | null) => void
|
|
33
|
+
setInput: (input: HTMLElement | null) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const ComboboxControlsContext = React.createContext<ComboboxControls | null>(null)
|
|
37
|
+
|
|
38
|
+
function Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>(
|
|
39
|
+
props: ComboboxPrimitive.Root.Props<Value, Multiple, Item>
|
|
40
|
+
) {
|
|
41
|
+
const [trigger, setTrigger] = React.useState<HTMLElement | null>(null)
|
|
42
|
+
const [input, setInput] = React.useState<HTMLElement | null>(null)
|
|
43
|
+
const controls = React.useMemo(() => ({ trigger, input, setTrigger, setInput }), [trigger, input])
|
|
44
|
+
return (
|
|
45
|
+
<ComboboxControlsContext.Provider value={controls}>
|
|
46
|
+
<ComboboxPrimitive.Root {...props} />
|
|
47
|
+
</ComboboxControlsContext.Provider>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The name of the Combobox, for its popup and its list. */
|
|
52
|
+
function useComboboxName() {
|
|
53
|
+
const controls = React.useContext(ComboboxControlsContext)
|
|
54
|
+
if (controls?.trigger) return nameFrom(controls.trigger, { orSelf: true })
|
|
55
|
+
return nameFrom(controls?.input ?? null)
|
|
56
|
+
}
|
|
17
57
|
|
|
18
58
|
function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
|
|
19
59
|
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
|
|
@@ -27,16 +67,20 @@ function ComboboxTrigger({
|
|
|
27
67
|
className,
|
|
28
68
|
size = "default",
|
|
29
69
|
children,
|
|
70
|
+
ref,
|
|
30
71
|
...props
|
|
31
72
|
}: ComboboxPrimitive.Trigger.Props & {
|
|
32
73
|
size?: "sm" | "default"
|
|
33
74
|
}) {
|
|
75
|
+
const triggerRef = useRegisteredRef(ref, React.useContext(ComboboxControlsContext)?.setTrigger)
|
|
34
76
|
return (
|
|
35
77
|
<ComboboxPrimitive.Trigger
|
|
78
|
+
ref={triggerRef}
|
|
36
79
|
data-slot="combobox-trigger"
|
|
37
80
|
data-size={size}
|
|
38
81
|
className={cn(
|
|
39
|
-
|
|
82
|
+
fieldSurface,
|
|
83
|
+
"data-placeholder:text-faint-foreground flex w-fit items-center justify-between gap-1.5 px-2.5 py-2 text-sm whitespace-nowrap disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-8.5 data-[size=sm]:h-7 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
40
84
|
className
|
|
41
85
|
)}
|
|
42
86
|
{...props}
|
|
@@ -47,10 +91,15 @@ function ComboboxTrigger({
|
|
|
47
91
|
)
|
|
48
92
|
}
|
|
49
93
|
|
|
50
|
-
|
|
94
|
+
// Icon-only, so it carries a name. Like the open button, it stays out of the
|
|
95
|
+
// tab order: Backspace clears the input from the keyboard, and while the list
|
|
96
|
+
// is open Base UI hides it from assistive technology.
|
|
97
|
+
function ComboboxClear({ className, "aria-label": ariaLabel = "Clear", ...props }: ComboboxPrimitive.Clear.Props) {
|
|
51
98
|
return (
|
|
52
99
|
<ComboboxPrimitive.Clear
|
|
53
100
|
data-slot="combobox-clear"
|
|
101
|
+
aria-label={ariaLabel}
|
|
102
|
+
tabIndex={-1}
|
|
54
103
|
render={<InputGroupButton variant="ghost" size="icon-xs" />}
|
|
55
104
|
className={cn(className)}
|
|
56
105
|
{...props}
|
|
@@ -67,24 +116,38 @@ function ComboboxInput({
|
|
|
67
116
|
showTrigger = true,
|
|
68
117
|
showClear = false,
|
|
69
118
|
triggerLabel = "Open options",
|
|
119
|
+
clearLabel = "Clear",
|
|
120
|
+
ref,
|
|
70
121
|
...props
|
|
71
122
|
}: ComboboxPrimitive.Input.Props & {
|
|
72
123
|
showTrigger?: boolean
|
|
73
124
|
showClear?: boolean
|
|
74
125
|
/** Accessible name of the icon-only trigger button. */
|
|
75
126
|
triggerLabel?: string
|
|
127
|
+
/** Accessible name of the icon-only clear button. */
|
|
128
|
+
clearLabel?: string
|
|
76
129
|
}) {
|
|
130
|
+
const inputRef = useRegisteredRef(ref, React.useContext(ComboboxControlsContext)?.setInput)
|
|
77
131
|
return (
|
|
78
132
|
<InputGroup className={cn("w-auto", className)}>
|
|
79
133
|
<ComboboxPrimitive.Input
|
|
134
|
+
ref={inputRef}
|
|
80
135
|
render={<InputGroupInput disabled={disabled} />}
|
|
81
136
|
{...props}
|
|
82
137
|
/>
|
|
83
138
|
<InputGroupAddon align="inline-end">
|
|
84
139
|
{showTrigger && (
|
|
85
140
|
// The bare primitive, not ComboboxTrigger: the icon button inside
|
|
86
|
-
// the input group must not take the field styling.
|
|
141
|
+
// the input group must not take the field styling. It stays out of
|
|
142
|
+
// the tab order, as in the ARIA combobox pattern: the input opens
|
|
143
|
+
// the list with the arrow keys. While the list is open, Base UI
|
|
144
|
+
// hides everything but the input and the list from assistive
|
|
145
|
+
// technology, and a hidden element must not be tabbable.
|
|
146
|
+
// ComboboxPrimitive.Trigger renders a native <button>, so Base UI is
|
|
147
|
+
// told so: Button turns nativeButton off when `render` is set.
|
|
87
148
|
<InputGroupButton
|
|
149
|
+
nativeButton
|
|
150
|
+
tabIndex={-1}
|
|
88
151
|
size="icon-xs"
|
|
89
152
|
variant="ghost"
|
|
90
153
|
render={<ComboboxPrimitive.Trigger />}
|
|
@@ -96,40 +159,88 @@ function ComboboxInput({
|
|
|
96
159
|
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4" />
|
|
97
160
|
</InputGroupButton>
|
|
98
161
|
)}
|
|
99
|
-
{showClear && <ComboboxClear disabled={disabled} />}
|
|
162
|
+
{showClear && <ComboboxClear aria-label={clearLabel} disabled={disabled} />}
|
|
100
163
|
</InputGroupAddon>
|
|
101
164
|
{children}
|
|
102
165
|
</InputGroup>
|
|
103
166
|
)
|
|
104
167
|
}
|
|
105
168
|
|
|
169
|
+
/**
|
|
170
|
+
* The element a list lines up with, other than an explicit `anchor`: the
|
|
171
|
+
* field trigger when there is one (the search input then sits in the popup),
|
|
172
|
+
* else the input's whole field group. Base UI would take the bare input,
|
|
173
|
+
* which stops short of the open and clear buttons, so a list lined up on
|
|
174
|
+
* its right edge would end before the field does.
|
|
175
|
+
*/
|
|
176
|
+
function fieldAnchor(controls: ComboboxControls | null): Element | null {
|
|
177
|
+
if (controls?.trigger) return controls.trigger
|
|
178
|
+
return controls?.input?.closest("[data-slot=input-group]") ?? controls?.input ?? null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function resolveAnchor(anchor: ComboboxPrimitive.Positioner.Props["anchor"]): Element | null {
|
|
182
|
+
const resolved = typeof anchor === "function" ? anchor() : anchor && "current" in anchor ? anchor.current : anchor
|
|
183
|
+
return resolved instanceof Element ? resolved : null
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Without an `align`, the list opens toward the centre of the screen, as a
|
|
188
|
+
* DropdownMenu does: a field in the right half lines the list up with its
|
|
189
|
+
* right edge, one in the left half with its left edge. This shows only when
|
|
190
|
+
* the list is wider than its field. An explicit `align` always wins.
|
|
191
|
+
*/
|
|
106
192
|
function ComboboxContent({
|
|
107
193
|
className,
|
|
108
194
|
side = "bottom",
|
|
109
195
|
sideOffset = 6,
|
|
110
|
-
align
|
|
196
|
+
align,
|
|
111
197
|
alignOffset = 0,
|
|
112
198
|
anchor,
|
|
199
|
+
ref,
|
|
113
200
|
...props
|
|
114
201
|
}: ComboboxPrimitive.Popup.Props &
|
|
115
202
|
Pick<
|
|
116
203
|
ComboboxPrimitive.Positioner.Props,
|
|
117
204
|
"side" | "align" | "sideOffset" | "alignOffset" | "anchor"
|
|
118
205
|
>) {
|
|
206
|
+
const dir = usePopupDir()
|
|
207
|
+
const name = useComboboxName()
|
|
208
|
+
const controls = React.useContext(ComboboxControlsContext)
|
|
209
|
+
// Without a field trigger, the list lines up with the whole field group.
|
|
210
|
+
const fieldGroup = !anchor && !controls?.trigger ? fieldAnchor(controls) : null
|
|
211
|
+
const getTrigger = React.useCallback(
|
|
212
|
+
() => resolveAnchor(anchor) ?? fieldAnchor(controls),
|
|
213
|
+
[anchor, controls]
|
|
214
|
+
)
|
|
215
|
+
const { popupRef, align: positionAlign } = usePopupAlign(align, side, ref, getTrigger)
|
|
119
216
|
return (
|
|
120
217
|
<ComboboxPrimitive.Portal>
|
|
121
218
|
<ComboboxPrimitive.Positioner
|
|
219
|
+
dir={dir}
|
|
122
220
|
side={side}
|
|
123
221
|
sideOffset={sideOffset}
|
|
124
|
-
align={
|
|
222
|
+
align={positionAlign}
|
|
125
223
|
alignOffset={alignOffset}
|
|
126
|
-
anchor={anchor}
|
|
224
|
+
anchor={anchor ?? fieldGroup ?? undefined}
|
|
127
225
|
className="isolate z-50"
|
|
128
226
|
>
|
|
129
227
|
<ComboboxPrimitive.Popup
|
|
228
|
+
ref={popupRef}
|
|
130
229
|
data-slot="combobox-content"
|
|
131
230
|
data-chips={!!anchor}
|
|
132
|
-
|
|
231
|
+
data-field-group={!!fieldGroup}
|
|
232
|
+
className={cn("bg-popover text-popover-foreground shadow-overlay group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] overflow-hidden rounded-xl data-[chips=true]:min-w-(--anchor-width) data-[field-group=true]:min-w-(--anchor-width) *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none", popupMotion, className )}
|
|
233
|
+
// A closing list is gone for assistive technology: the input no
|
|
234
|
+
// longer points at it, and it takes no input while it fades out.
|
|
235
|
+
// With the search input inside it, the popup is a dialog: it takes
|
|
236
|
+
// the Combobox's name unless it has its own.
|
|
237
|
+
render={(popupProps, state) => (
|
|
238
|
+
<div
|
|
239
|
+
{...(popupProps.role === "dialog" && !hasName(popupProps) ? name : {})}
|
|
240
|
+
{...popupProps}
|
|
241
|
+
aria-hidden={state.open ? popupProps["aria-hidden"] : true}
|
|
242
|
+
/>
|
|
243
|
+
)}
|
|
133
244
|
{...props}
|
|
134
245
|
/>
|
|
135
246
|
</ComboboxPrimitive.Positioner>
|
|
@@ -138,8 +249,10 @@ function ComboboxContent({
|
|
|
138
249
|
}
|
|
139
250
|
|
|
140
251
|
function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
252
|
+
const name = useComboboxName()
|
|
141
253
|
return (
|
|
142
254
|
<ComboboxPrimitive.List
|
|
255
|
+
{...(hasName(props) ? {} : name)}
|
|
143
256
|
data-slot="combobox-list"
|
|
144
257
|
className={cn(
|
|
145
258
|
"no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
|
|
@@ -150,6 +263,11 @@ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
|
150
263
|
)
|
|
151
264
|
}
|
|
152
265
|
|
|
266
|
+
// The input keeps focus and the list moves a virtual highlight
|
|
267
|
+
// (`data-highlighted`), so `focus-visible` never fires on an option. An
|
|
268
|
+
// enabled option shows the highlight as the muted fill. A disabled one takes
|
|
269
|
+
// no fill: the arrow keys still stop on it, and it shows the focus ring at
|
|
270
|
+
// full strength instead, as a disabled menu item does under the arrow keys.
|
|
153
271
|
function ComboboxItem({
|
|
154
272
|
className,
|
|
155
273
|
children,
|
|
@@ -159,19 +277,17 @@ function ComboboxItem({
|
|
|
159
277
|
<ComboboxPrimitive.Item
|
|
160
278
|
data-slot="combobox-item"
|
|
161
279
|
className={cn(
|
|
162
|
-
|
|
280
|
+
menuItemDisabled,
|
|
281
|
+
menuCheckItem,
|
|
282
|
+
"not-data-disabled:data-highlighted:bg-muted not-data-disabled:data-highlighted:text-accent-foreground data-disabled:data-highlighted:outline-solid data-disabled:data-highlighted:outline-2 data-disabled:data-highlighted:-outline-offset-2 data-disabled:data-highlighted:outline-ring not-data-[variant=destructive]:not-data-disabled:data-highlighted:**:text-accent-foreground relative flex min-h-8.5 w-full cursor-default items-center gap-2 rounded-lg py-1.5 pe-8 ps-2 text-sm outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75] [&>svg:not([class*='opacity-'])]:opacity-55 [&>svg:not([class*='opacity-'])]:transition-opacity [&>svg:not([class*='opacity-'])]:duration-moderate not-data-disabled:data-highlighted:[&>svg:not([class*='opacity-'])]:opacity-85",
|
|
163
283
|
className
|
|
164
284
|
)}
|
|
165
285
|
{...props}
|
|
166
286
|
>
|
|
167
287
|
{children}
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
>
|
|
173
|
-
<CheckIcon className="pointer-events-none" />
|
|
174
|
-
</ComboboxPrimitive.ItemIndicator>
|
|
288
|
+
<span className="pointer-events-none absolute end-2 flex size-4 items-center justify-center">
|
|
289
|
+
<MenuCheck />
|
|
290
|
+
</span>
|
|
175
291
|
</ComboboxPrimitive.Item>
|
|
176
292
|
)
|
|
177
293
|
}
|
|
@@ -240,7 +356,8 @@ function ComboboxChips({
|
|
|
240
356
|
<ComboboxPrimitive.Chips
|
|
241
357
|
data-slot="combobox-chips"
|
|
242
358
|
className={cn(
|
|
243
|
-
|
|
359
|
+
fieldSurfaceWithin,
|
|
360
|
+
"flex min-h-8.5 flex-wrap items-center gap-1.5 px-2.5 py-1.5 text-sm has-data-[slot=combobox-chip]:px-1.5",
|
|
244
361
|
className
|
|
245
362
|
)}
|
|
246
363
|
{...props}
|
|
@@ -248,19 +365,24 @@ function ComboboxChips({
|
|
|
248
365
|
)
|
|
249
366
|
}
|
|
250
367
|
|
|
368
|
+
// A chip is the v3 look's grey chip: the accent fill, one step above the
|
|
369
|
+
// muted field it sits on, with a grey outline, so each value stands out.
|
|
251
370
|
function ComboboxChip({
|
|
252
371
|
className,
|
|
253
372
|
children,
|
|
254
373
|
showRemove = true,
|
|
374
|
+
removeLabel = "Remove",
|
|
255
375
|
...props
|
|
256
376
|
}: ComboboxPrimitive.Chip.Props & {
|
|
257
377
|
showRemove?: boolean
|
|
378
|
+
/** Accessible name of the icon-only remove button. */
|
|
379
|
+
removeLabel?: string
|
|
258
380
|
}) {
|
|
259
381
|
return (
|
|
260
382
|
<ComboboxPrimitive.Chip
|
|
261
383
|
data-slot="combobox-chip"
|
|
262
384
|
className={cn(
|
|
263
|
-
"bg-
|
|
385
|
+
"bg-accent [--status-tone:var(--neutral-text)]", statusChipRing, "text-foreground flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm px-1.5 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-0",
|
|
264
386
|
className
|
|
265
387
|
)}
|
|
266
388
|
{...props}
|
|
@@ -269,8 +391,9 @@ function ComboboxChip({
|
|
|
269
391
|
{showRemove && (
|
|
270
392
|
<ComboboxPrimitive.ChipRemove
|
|
271
393
|
render={<Button variant="ghost" size="icon-xs" />}
|
|
272
|
-
className="-
|
|
394
|
+
className="-ms-1 opacity-50 hover:opacity-100"
|
|
273
395
|
data-slot="combobox-chip-remove"
|
|
396
|
+
aria-label={removeLabel}
|
|
274
397
|
>
|
|
275
398
|
<XIcon className="pointer-events-none" />
|
|
276
399
|
</ComboboxPrimitive.ChipRemove>
|
|
@@ -281,10 +404,13 @@ function ComboboxChip({
|
|
|
281
404
|
|
|
282
405
|
function ComboboxChipsInput({
|
|
283
406
|
className,
|
|
407
|
+
ref,
|
|
284
408
|
...props
|
|
285
409
|
}: ComboboxPrimitive.Input.Props) {
|
|
410
|
+
const inputRef = useRegisteredRef(ref, React.useContext(ComboboxControlsContext)?.setInput)
|
|
286
411
|
return (
|
|
287
412
|
<ComboboxPrimitive.Input
|
|
413
|
+
ref={inputRef}
|
|
288
414
|
data-slot="combobox-chip-input"
|
|
289
415
|
className={cn("min-w-16 flex-1 outline-none", className)}
|
|
290
416
|
{...props}
|