@cognitap/radiant 0.0.80 → 0.0.81

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 (43) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/library/charts/Charts.d.ts +1 -2
  3. package/dist/library/charts/Charts.d.ts.map +1 -1
  4. package/dist/library/charts/Charts.js +4 -4
  5. package/dist/library/charts/Charts.js.map +1 -1
  6. package/dist/library/components/AppShell/AppShell.d.ts +1 -6
  7. package/dist/library/components/AppShell/AppShell.d.ts.map +1 -1
  8. package/dist/library/components/AppShell/AppShell.js +4 -10
  9. package/dist/library/components/AppShell/AppShell.js.map +1 -1
  10. package/dist/library/components/Carousel/Carousel.d.ts +9 -5
  11. package/dist/library/components/Carousel/Carousel.d.ts.map +1 -1
  12. package/dist/library/components/Carousel/Carousel.js +14 -6
  13. package/dist/library/components/Carousel/Carousel.js.map +1 -1
  14. package/dist/library/components/Combobox/Combobox.d.ts +6 -0
  15. package/dist/library/components/Combobox/Combobox.d.ts.map +1 -1
  16. package/dist/library/components/Combobox/Combobox.js +41 -6
  17. package/dist/library/components/Combobox/Combobox.js.map +1 -1
  18. package/dist/library/components/Combobox/comboboxStyles.d.ts +3 -0
  19. package/dist/library/components/Combobox/comboboxStyles.d.ts.map +1 -1
  20. package/dist/library/components/Combobox/comboboxStyles.js +20 -1
  21. package/dist/library/components/Combobox/comboboxStyles.js.map +1 -1
  22. package/dist/library/components/MultiSelect/MultiSelect.d.ts +4 -1
  23. package/dist/library/components/MultiSelect/MultiSelect.d.ts.map +1 -1
  24. package/dist/library/components/MultiSelect/MultiSelect.js +6 -1
  25. package/dist/library/components/MultiSelect/MultiSelect.js.map +1 -1
  26. package/dist/library/index.d.ts +6 -6
  27. package/dist/library/index.d.ts.map +1 -1
  28. package/dist/library/index.js +3 -3
  29. package/dist/library/index.js.map +1 -1
  30. package/dist/library/react/useComboboxPopup.d.ts.map +1 -1
  31. package/dist/library/react/useComboboxPopup.js +5 -3
  32. package/dist/library/react/useComboboxPopup.js.map +1 -1
  33. package/dist/library/styles.css +1 -1
  34. package/docs/theming.md +10 -10
  35. package/package.json +1 -1
  36. package/src/charts/Charts.tsx +10 -7
  37. package/src/components/AppShell/AppShell.tsx +4 -14
  38. package/src/components/Carousel/Carousel.tsx +34 -6
  39. package/src/components/Combobox/Combobox.tsx +76 -13
  40. package/src/components/Combobox/comboboxStyles.ts +22 -1
  41. package/src/components/MultiSelect/MultiSelect.tsx +8 -0
  42. package/src/index.ts +7 -4
  43. package/src/react/useComboboxPopup.ts +5 -3
package/docs/theming.md CHANGED
@@ -78,16 +78,16 @@ export function Save() {
78
78
 
79
79
  Each part reads one token role.
80
80
 
81
- | Role | Token group | Parts |
82
- | --------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
83
- | Action | `control.action` | `Button` and parts built on it, button-styled `Link`, `ButtonGroup`, and the typography of tabs and headers |
84
- | Field | `control.field` | `Input`, `Textarea`, `NativeSelect`, `InputGroup`, `OTPField` slots, `Select`, `Combobox`, `TagsInput` |
85
- | Indicator | `control.indicator` | `Checkbox` and `Radio` boxes, `Switch` track, `Switch` and `Slider` thumbs |
86
- | Track | `control.track` | `ToggleGroup` and `Tabs` lists, `Progress`, `Meter`, `Skeleton`, `Slider` and `ScrollArea` rails, `Menubar` |
87
- | Selected | `control.selected` | Pressed toggles, `ToggleGroup` indicator, active tab, `NavLink`, current page, chosen option, open menu |
88
- | Surface | `surface` | `Card`, `Alert`, `Collapsible`, `Accordion`, `TableContainer`, `EmptyState`, `CodeBlock`, `Sidebar` |
89
- | Overlay | `surface.overlay*`, `surface.backdropFilter` | `Popover`, `HoverCard`, `Menu`, listboxes, `Tooltip`, `Dialog`, `Drawer`, `NavigationMenu` viewport |
90
- | Item | `control.item` | Highlighted rows in menus, listboxes, and `Command` |
81
+ | Role | Token group | Parts |
82
+ | --------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
83
+ | Action | `control.action` | `Button` and parts built on it, button-styled `Link`, `ButtonGroup`, and the typography of tabs and headers |
84
+ | Field | `control.field` | `Input`, `Textarea`, `NativeSelect`, `InputGroup`, `OTPField` slots, `Select`, `Combobox`, `MultiSelect`, `TagsInput` |
85
+ | Indicator | `control.indicator` | `Checkbox` and `Radio` boxes, `Switch` track, `Switch` and `Slider` thumbs |
86
+ | Track | `control.track` | `ToggleGroup` and `Tabs` lists, `Progress`, `Meter`, `Skeleton`, `Slider` and `ScrollArea` rails, `Menubar` |
87
+ | Selected | `control.selected` | Pressed toggles, `ToggleGroup` indicator, active tab, `NavLink`, current page, chosen option, open menu |
88
+ | Surface | `surface` | `Card`, `Alert`, `Collapsible`, `Accordion`, `TableContainer`, `EmptyState`, `CodeBlock`, `Sidebar` |
89
+ | Overlay | `surface.overlay*`, `surface.backdropFilter` | `Popover`, `HoverCard`, `Menu`, listboxes, `Tooltip`, `Dialog`, `Drawer`, `NavigationMenu` viewport |
90
+ | Item | `control.item` | Highlighted rows in menus, listboxes, and `Command` |
91
91
 
92
92
  Shared geometry:
93
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognitap/radiant",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "React interaction components and presentation primitives",
5
5
  "homepage": "https://radiant-docs.pages.dev",
6
6
  "bugs": {
@@ -42,7 +42,6 @@ export type ChartProps = Omit<
42
42
  series: readonly ChartSeries[]
43
43
  formatValue?: (value: number, series: ChartSeries) => string
44
44
  categoryLabel?: string
45
- plotLabel?: string
46
45
  legendLabel?: string
47
46
  tableLabel?: string
48
47
  emptyText?: string
@@ -78,7 +77,7 @@ const pointClass = [
78
77
  focusRingClass
79
78
  ].join(' ')
80
79
  export type ChartDataTableProps = Omit<TableProps, 'children'> &
81
- Pick<ChartProps, 'data' | 'series' | 'formatValue' | 'categoryLabel'> & { label: string }
80
+ Pick<ChartProps, 'data' | 'series' | 'formatValue' | 'categoryLabel'> & { label: ReactNode }
82
81
  export function ChartDataTable({
83
82
  data,
84
83
  series,
@@ -130,7 +129,6 @@ function Chart({
130
129
  series,
131
130
  formatValue = format,
132
131
  categoryLabel = 'Category',
133
- plotLabel = 'Chart plot',
134
132
  legendLabel = 'Chart legend',
135
133
  tableLabel = 'View chart data',
136
134
  emptyText = 'No chart data to display.',
@@ -181,6 +179,7 @@ function Chart({
181
179
  >
182
180
  <figcaption
183
181
  id={captionId}
182
+ data-slot="chart-caption"
184
183
  className={cn(
185
184
  'font-[family-name:var(--rad-typography-roles-ui-title-family,system-ui,sans-serif)] font-[number:var(--rad-typography-roles-ui-title-weight,600)]',
186
185
  parts?.caption?.className
@@ -192,6 +191,7 @@ function Chart({
192
191
  {description && (
193
192
  <div
194
193
  id={descriptionId}
194
+ data-slot="chart-description"
195
195
  className={parts?.description?.className}
196
196
  style={parts?.description?.style}
197
197
  >
@@ -200,11 +200,12 @@ function Chart({
200
200
  )}
201
201
  {ordered.length ? (
202
202
  <ScrollArea
203
- aria-label={plotLabel}
203
+ aria-labelledby={captionId}
204
204
  orientation="horizontal"
205
205
  >
206
206
  <div
207
207
  ref={root}
208
+ data-slot="chart-plot"
208
209
  className={cn('relative h-[var(--rad-chart-height,20rem)]', parts?.plot?.className)}
209
210
  style={{ minWidth: Math.max(480, data.length * 72), ...parts?.plot?.style }}
210
211
  >
@@ -357,6 +358,7 @@ function Chart({
357
358
  <span aria-hidden="true">·</span>
358
359
  </TooltipTrigger>
359
360
  <TooltipContent
361
+ data-slot="chart-tooltip"
360
362
  className={parts?.tooltip?.className}
361
363
  style={parts?.tooltip?.style}
362
364
  >
@@ -369,9 +371,10 @@ function Chart({
369
371
  </div>
370
372
  </ScrollArea>
371
373
  ) : (
372
- <p>{emptyText}</p>
374
+ <p data-slot="chart-empty">{emptyText}</p>
373
375
  )}
374
376
  <ul
377
+ data-slot="chart-legend"
375
378
  className={cn('m-0 flex list-none flex-wrap gap-4 p-0', parts?.legend?.className)}
376
379
  style={parts?.legend?.style}
377
380
  aria-label={legendLabel}
@@ -403,10 +406,10 @@ function Chart({
403
406
  )
404
407
  )}
405
408
  </ul>
406
- <details>
409
+ <details data-slot="chart-disclosure">
407
410
  <summary className="cursor-pointer">{tableLabel}</summary>
408
411
  <ChartDataTable
409
- label={typeof label === 'string' ? `${label} data` : 'Chart data'}
412
+ label={label}
410
413
  data={data}
411
414
  series={series}
412
415
  formatValue={formatValue}
@@ -41,21 +41,18 @@ export type AppShellProps = Omit<ComponentProps<'div'>, 'style'> &
41
41
  onCollapsedChange?: (collapsed: boolean) => void
42
42
  onOpenChange?: (open: boolean) => void
43
43
  mainId?: string
44
- sidebarId?: string
45
44
  motion?: 'inherit' | 'off'
46
45
  }
47
46
  export type AppShellState = {
48
47
  collapsed: boolean
49
48
  open: boolean
50
49
  mobile: boolean
51
- collapsedControlled: boolean
52
- openControlled: boolean
53
50
  mainId: string
54
- sidebarId: string
55
51
  setCollapsed: (collapsed: boolean) => void
56
52
  setOpen: (open: boolean) => void
57
53
  }
58
54
  type Binding = AppShellState & {
55
+ sidebarId: string
59
56
  root: RefObject<HTMLDivElement | null>
60
57
  drawerId: string
61
58
  labelId: string
@@ -65,9 +62,6 @@ const Context = createContext<Binding | null>(null)
65
62
  export function useAppShell(): AppShellState | null {
66
63
  return useContext(Context)
67
64
  }
68
- export function useSidebar(): AppShellState | null {
69
- return useContext(Context)
70
- }
71
65
  function useBinding() {
72
66
  const value = useContext(Context)
73
67
  if (!value) throw new Error('AppShell and Sidebar parts must render inside AppShell.')
@@ -102,7 +96,6 @@ export function AppShell({
102
96
  defaultOpen,
103
97
  onOpenChange,
104
98
  mainId,
105
- sidebarId,
106
99
  motion = 'inherit',
107
100
  ref,
108
101
  className,
@@ -125,9 +118,8 @@ export function AppShell({
125
118
  })
126
119
  if (typeof collapse.value !== 'boolean' || typeof drawer.value !== 'boolean')
127
120
  throw new TypeError('AppShell states must be boolean.')
128
- for (const id of [mainId, sidebarId])
129
- if (id !== undefined && (!id || /\s/.test(id)))
130
- throw new TypeError('AppShell relationship IDs must be nonempty and contain no whitespace.')
121
+ if (mainId !== undefined && (!mainId || /\s/.test(mainId)))
122
+ throw new TypeError('AppShell mainId must be nonempty and contain no whitespace.')
131
123
  const root = useRef<HTMLDivElement>(null),
132
124
  host = useComposedRefs(root, ref),
133
125
  { ref: layoutRef } = useTransitionHost('layout', host, motion === 'off'),
@@ -186,12 +178,10 @@ export function AppShell({
186
178
  collapsed: collapse.value,
187
179
  open: drawer.value,
188
180
  mobile,
189
- collapsedControlled: collapse.controlled,
190
- openControlled: drawer.controlled,
191
181
  setCollapsed,
192
182
  setOpen,
193
183
  mainId: mainId ?? `${id}-main`,
194
- sidebarId: sidebarId ?? `${id}-sidebar`,
184
+ sidebarId: `${id}-sidebar`,
195
185
  labelId: `${id}-sidebar-label`,
196
186
  root,
197
187
  motion
@@ -16,11 +16,12 @@ import { Button, type ButtonProps } from '../Button/Button.js'
16
16
  import { cn } from 'cn'
17
17
  import { joinIds } from '../../internal/ids.js'
18
18
  import { requireAccessibleName, type AccessibleName } from '../../internal/accessibleName.js'
19
- import type { WithoutToggle } from '../../internal/types.js'
19
+ import type { DistributiveOmit, WithoutToggle } from '../../internal/types.js'
20
20
  import { useControllableState } from '../../react/useControllableState.js'
21
21
  import type { ValueOwner } from '../../react/useNativeOwner.js'
22
22
  import { useComposedRefs } from '../../react/useComposedRefs.js'
23
23
  import type { ThemeStyle } from '../../themes/defineTheme.js'
24
+ import type { ControlSize } from '../../presentation.js'
24
25
  import { scrollbarClass } from '../shared/scrollbarStyles.js'
25
26
  import { focusRingClass } from '../shared/focusStyles.js'
26
27
 
@@ -40,11 +41,11 @@ export type CarouselState = {
40
41
  value: string | null
41
42
  index: number
42
43
  count: number
43
- playing: boolean
44
44
  setValue: (value: string) => void
45
- setPlaying: (playing: boolean) => void
46
45
  }
47
46
  type Binding = CarouselState & {
47
+ playing: boolean
48
+ setPlaying: (playing: boolean) => void
48
49
  items: readonly CarouselItem[]
49
50
  viewportId: string
50
51
  setViewport: (node: HTMLDivElement | null) => void
@@ -53,7 +54,15 @@ type Binding = CarouselState & {
53
54
  }
54
55
  const Context = createContext<Binding | null>(null)
55
56
  export function useCarousel(): CarouselState | null {
56
- return useContext(Context)
57
+ const state = useContext(Context)
58
+ return (
59
+ state && {
60
+ value: state.value,
61
+ index: state.index,
62
+ count: state.count,
63
+ setValue: state.setValue
64
+ }
65
+ )
57
66
  }
58
67
  function useBinding() {
59
68
  const value = useContext(Context)
@@ -494,11 +503,13 @@ export function CarouselNext(props: CarouselActionProps) {
494
503
  }
495
504
  export type CarouselIndicatorsProps = Omit<ComponentProps<'div'>, 'children' | 'style'> & {
496
505
  style?: ThemeStyle
506
+ controlSize?: ControlSize
497
507
  indicatorLabel?: (index: number, count: number) => string
498
508
  'data-slot'?: string
499
509
  }
500
510
  export function CarouselIndicators({
501
511
  indicatorLabel = (index, count) => `Show slide ${index + 1} of ${count}`,
512
+ controlSize,
502
513
  className,
503
514
  ...props
504
515
  }: CarouselIndicatorsProps) {
@@ -514,6 +525,7 @@ export function CarouselIndicators({
514
525
  key={item.value}
515
526
  variant="ghost"
516
527
  tone="neutral"
528
+ controlSize={controlSize}
517
529
  aria-label={indicatorLabel(index, state.count)}
518
530
  aria-current={state.value === item.value ? 'true' : undefined}
519
531
  data-selected={state.value === item.value ? '' : undefined}
@@ -526,7 +538,21 @@ export function CarouselIndicators({
526
538
  </div>
527
539
  )
528
540
  }
529
- export function CarouselAutoPlay({ onClick, ...props }: CarouselActionProps) {
541
+ export type CarouselAutoPlayProps = DistributiveOmit<
542
+ CarouselActionProps,
543
+ 'children' | 'aria-label' | 'aria-labelledby'
544
+ > & {
545
+ playLabel?: string
546
+ pauseLabel?: string
547
+ }
548
+ export function CarouselAutoPlay({
549
+ playLabel = 'Play slides',
550
+ pauseLabel = 'Pause slides',
551
+ onClick,
552
+ ...props
553
+ }: CarouselAutoPlayProps) {
554
+ if (!playLabel.trim() || !pauseLabel.trim())
555
+ throw new TypeError('CarouselAutoPlay requires nonempty playLabel and pauseLabel.')
530
556
  const state = useBinding()
531
557
  return (
532
558
  <Button
@@ -535,13 +561,15 @@ export function CarouselAutoPlay({ onClick, ...props }: CarouselActionProps) {
535
561
  defaultPressed={undefined}
536
562
  onPressedChange={undefined}
537
563
  aria-pressed={undefined}
564
+ aria-label={undefined}
565
+ aria-labelledby={undefined}
538
566
  data-slot={joinIds('carousel-auto-play', props['data-slot'])}
539
567
  onClick={event => {
540
568
  onClick?.(event)
541
569
  if (!event.defaultPrevented) state.setPlaying(!state.playing)
542
570
  }}
543
571
  >
544
- {props.children ?? (state.playing ? 'Pause slides' : 'Play slides')}
572
+ {state.playing ? pauseLabel : playLabel}
545
573
  </Button>
546
574
  )
547
575
  }
@@ -32,7 +32,9 @@ import {
32
32
  comboboxInputClass,
33
33
  comboboxContentClass,
34
34
  comboboxItemClass,
35
- comboboxActionClass
35
+ comboboxActionClass,
36
+ comboboxWellClass,
37
+ comboboxWellInputClass
36
38
  } from './comboboxStyles.js'
37
39
  import { useControllableState } from '../../react/useControllableState.js'
38
40
  import { useComposedRefs } from '../../react/useComposedRefs.js'
@@ -549,14 +551,21 @@ export function ComboboxRoot(
549
551
  <ComboboxContext.Provider value={context}>
550
552
  {children ?? (
551
553
  <>
552
- {multiple && <ComboboxTags />}
553
- <div
554
- className="relative w-full min-w-0"
555
- data-slot={componentSlot(multiple, textMode, 'combobox-control')}
556
- >
557
- <ComboboxInput />
558
- <ComboboxTrigger className="absolute inset-y-0 end-0 w-12" />
559
- </div>
554
+ {multiple ? (
555
+ <ComboboxControl>
556
+ <ComboboxTags />
557
+ <ComboboxInput />
558
+ <ComboboxTrigger />
559
+ </ComboboxControl>
560
+ ) : (
561
+ <div
562
+ className="relative w-full min-w-0"
563
+ data-slot={componentSlot(multiple, textMode, 'combobox-control')}
564
+ >
565
+ <ComboboxInput />
566
+ <ComboboxTrigger className="absolute inset-y-0 end-0 w-12" />
567
+ </div>
568
+ )}
560
569
  <ComboboxPortal>
561
570
  <ComboboxContent />
562
571
  </ComboboxPortal>
@@ -654,6 +663,7 @@ export function ComboboxInput({
654
663
  'aria-invalid': props['aria-invalid'] ?? box.invalid
655
664
  })
656
665
  const inputRef = useComposedRefs(box.setInput, ref)
666
+ const inWell = useContext(WellContext)
657
667
  return (
658
668
  <input
659
669
  {...props}
@@ -668,7 +678,7 @@ export function ComboboxInput({
668
678
  autoComplete={props.autoComplete ?? 'off'}
669
679
  value={box.text}
670
680
  className={cn(
671
- comboboxInputClass,
681
+ inWell ? comboboxWellInputClass : comboboxInputClass,
672
682
  controlMetrics({ controlSize: box.controlSize }),
673
683
  className
674
684
  )}
@@ -822,6 +832,7 @@ export function ComboboxTrigger({
822
832
  ...props
823
833
  }: ComboboxTriggerProps) {
824
834
  const box = useComboboxContext()
835
+ const inWell = useContext(WellContext)
825
836
  return (
826
837
  <Button
827
838
  variant="ghost"
@@ -837,7 +848,10 @@ export function ComboboxTrigger({
837
848
  motion="off"
838
849
  controlSize={box.controlSize}
839
850
  render={resolved => {
840
- const native = { ...resolved, className: cn(comboboxActionClass, className) }
851
+ const native = {
852
+ ...resolved,
853
+ className: cn(comboboxActionClass, inWell && wellActionClass, className)
854
+ }
841
855
  return render ? render(native) : <button {...native} />
842
856
  }}
843
857
  tabIndex={-1}
@@ -893,6 +907,7 @@ export function ComboboxClear({
893
907
  ...props
894
908
  }: ComboboxClearProps) {
895
909
  const box = useComboboxContext()
910
+ const inWell = useContext(WellContext)
896
911
  if (
897
912
  box.textInput
898
913
  ? box.query === ''
@@ -914,7 +929,10 @@ export function ComboboxClear({
914
929
  motion="off"
915
930
  controlSize={box.controlSize}
916
931
  render={resolved => {
917
- const native = { ...resolved, className: cn(comboboxActionClass, className) }
932
+ const native = {
933
+ ...resolved,
934
+ className: cn(comboboxActionClass, inWell && wellActionClass, className)
935
+ }
918
936
  return render ? render(native) : <button {...native} />
919
937
  }}
920
938
  tabIndex={box.multiple ? 0 : -1}
@@ -1183,13 +1201,17 @@ export function ComboboxTags({
1183
1201
  ...props
1184
1202
  }: ComboboxTagsProps) {
1185
1203
  const box = useComboboxContext()
1204
+ const inWell = useContext(WellContext)
1186
1205
  if (!box.multiple) throw new Error('ComboboxTags requires a multiple Combobox.')
1187
1206
  return (
1188
1207
  <div
1189
1208
  {...props}
1190
1209
  data-slot={joinIds('combobox-tags', 'multi-select-tags', props['data-slot'])}
1191
1210
  className={cn(
1192
- 'flex flex-wrap items-center gap-[var(--rad-multi-select-gap,0.5rem)] mb-[var(--rad-multi-select-gap,0.5rem)] empty:hidden',
1211
+ // Inside the well the chips flow inline with the editor.
1212
+ inWell
1213
+ ? 'contents'
1214
+ : 'flex flex-wrap items-center gap-[var(--rad-multi-select-gap,0.5rem)] mb-[var(--rad-multi-select-gap,0.5rem)] empty:hidden',
1193
1215
  className
1194
1216
  )}
1195
1217
  >
@@ -1207,3 +1229,44 @@ export function ComboboxTags({
1207
1229
  </div>
1208
1230
  )
1209
1231
  }
1232
+
1233
+ const WellContext = createContext(false)
1234
+ const wellActionClass = 'self-stretch px-2'
1235
+ export type ComboboxControlProps = Omit<ComponentProps<'div'>, 'style'> & {
1236
+ style?: ThemeStyle
1237
+ 'data-slot'?: string
1238
+ }
1239
+ /** The field well around a multiple Combobox's chips, editor and buttons. */
1240
+ export function ComboboxControl({ className, onPointerDown, ...props }: ComboboxControlProps) {
1241
+ const box = useComboboxContext()
1242
+ if (!box.multiple) throw new Error('ComboboxControl requires a multiple Combobox.')
1243
+ return (
1244
+ <WellContext.Provider value>
1245
+ <div
1246
+ {...props}
1247
+ data-slot={joinIds('combobox-control', 'multi-select-control', props['data-slot'])}
1248
+ data-control-size={box.controlSize}
1249
+ className={cn(
1250
+ comboboxWellClass,
1251
+ controlMetrics({ controlSize: box.controlSize }),
1252
+ className
1253
+ )}
1254
+ onPointerDown={event => {
1255
+ onPointerDown?.(event)
1256
+ if (
1257
+ event.defaultPrevented ||
1258
+ event.target !== event.currentTarget ||
1259
+ event.button !== 0 ||
1260
+ !event.isPrimary ||
1261
+ !box.input ||
1262
+ box.input.disabled
1263
+ )
1264
+ return
1265
+ // A pointer convenience only: the native input remains the keyboard target.
1266
+ event.preventDefault()
1267
+ box.input.focus()
1268
+ }}
1269
+ />
1270
+ </WellContext.Provider>
1271
+ )
1272
+ }
@@ -1,5 +1,5 @@
1
1
  import { controlBorderClass } from '../shared/controlStyles.js'
2
- import { focusRingClass } from '../shared/focusStyles.js'
2
+ import { childFocusRingClass, focusRingClass } from '../shared/focusStyles.js'
3
3
 
4
4
  export const comboboxInputClass = [
5
5
  controlBorderClass,
@@ -45,3 +45,24 @@ export const comboboxActionClass = [
45
45
  'focus-visible:[--_rad-focus-color:var(--rad-combobox-focus-color)] focus-visible:[--_rad-focus-width:var(--rad-combobox-focus-width)] focus-visible:[--_rad-focus-offset:var(--rad-combobox-focus-offset)] focus-visible:[--_rad-focus-style:var(--rad-combobox-focus-style)]',
46
46
  'disabled:cursor-not-allowed forced-colors:text-[CanvasText] forced-colors:disabled:text-[GrayText]'
47
47
  ].join(' ')
48
+
49
+ /** Chips and the editor share one field well, so the input inside it draws no box of its own. */
50
+ export const comboboxWellClass = [
51
+ controlBorderClass,
52
+ 'box-border flex min-h-[var(--rad-combobox-height,var(--_rad-control-height))] w-full min-w-0 flex-wrap items-center gap-[var(--rad-multi-select-gap,0.5rem)] p-[0.25rem] cursor-text',
53
+ 'bg-[var(--rad-combobox-background,var(--rad-control-field-background,var(--rad-color-surface,white)))] [color:var(--rad-combobox-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',
54
+ '[border-width:var(--rad-combobox-border-width,var(--rad-control-border-width,1px))] [border-style:var(--rad-combobox-border-style,var(--rad-control-border-style,solid))] [border-color:var(--rad-combobox-border-color,var(--rad-control-field-border-color,var(--_rad-control-border)))]',
55
+ 'rounded-[var(--rad-combobox-radius,var(--rad-control-radius,0.5rem))] [corner-shape:var(--rad-combobox-corner-shape,var(--rad-control-corner-shape,round))] [box-shadow:var(--rad-combobox-shadow,var(--rad-control-field-shadow,none))] [backdrop-filter:var(--rad-control-field-backdrop-filter,none)]',
56
+ childFocusRingClass,
57
+ 'has-[>input:focus-visible]:[--_rad-focus-color:var(--rad-combobox-focus-color)] has-[>input:focus-visible]:[--_rad-focus-width:var(--rad-combobox-focus-width)] has-[>input:focus-visible]:[--_rad-focus-offset:var(--rad-combobox-focus-offset)] has-[>input:focus-visible]:[--_rad-focus-style:var(--rad-combobox-focus-style)]',
58
+ 'has-[>input[data-invalid]]:[border-color:var(--rad-color-invalid,oklch(0.56_0.19_25))]',
59
+ 'has-[>input:disabled]:cursor-not-allowed has-[>input:disabled]:bg-[var(--rad-color-disabled-background,oklch(0.96_0.005_286))]',
60
+ 'forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText]'
61
+ ].join(' ')
62
+
63
+ export const comboboxWellInputClass = [
64
+ 'box-border w-auto min-w-[8ch] flex-1 h-[calc(var(--rad-combobox-height,var(--_rad-control-height))-2*var(--rad-combobox-border-width,var(--rad-control-border-width,1px))-0.5rem)]',
65
+ 'ps-[calc(var(--rad-combobox-padding,var(--_rad-control-padding))-0.25rem)] pe-0 [[data-slot~=multi-select-tags]:not(:empty)~&]:ps-0 m-0 rounded-none [border-width:0] [box-shadow:none] [backdrop-filter:none] bg-transparent outline-none',
66
+ 'font-[family-name:var(--rad-combobox-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] text-[length:var(--rad-combobox-font-size,var(--_rad-control-font-size))] font-[number:var(--rad-combobox-font-weight,var(--rad-typography-roles-ui-body-weight,400))] leading-[var(--rad-typography-roles-ui-body-line-height,1.5)] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',
67
+ '[color:inherit] placeholder:[color:var(--rad-combobox-placeholder,var(--rad-color-placeholder))] disabled:cursor-not-allowed forced-colors:disabled:text-[GrayText]'
68
+ ].join(' ')
@@ -11,6 +11,7 @@ import {
11
11
  ComboboxItem,
12
12
  ComboboxStatus,
13
13
  ComboboxTags,
14
+ ComboboxControl,
14
15
  useCombobox,
15
16
  type ComboboxMultipleProps,
16
17
  type ComboboxMultipleState,
@@ -22,6 +23,7 @@ import {
22
23
  type ComboboxItemProps,
23
24
  type ComboboxStatusProps,
24
25
  type ComboboxTagsProps,
26
+ type ComboboxControlProps,
25
27
  type ComboboxRenderProps
26
28
  } from '../Combobox/Combobox.js'
27
29
  import type { DistributiveOmit } from '../../internal/types.js'
@@ -39,6 +41,7 @@ export type MultiSelectContentProps = ComboboxContentProps
39
41
  export type MultiSelectItemProps = ComboboxItemProps
40
42
  export type MultiSelectStatusProps = ComboboxStatusProps
41
43
  export type MultiSelectTagsProps = ComboboxTagsProps
44
+ export type MultiSelectControlProps = ComboboxControlProps
42
45
  export type MultiSelectRenderProps = ComboboxRenderProps
43
46
 
44
47
  export function useMultiSelect(): MultiSelectState | null {
@@ -91,3 +94,8 @@ export function MultiSelectTags(props: MultiSelectTagsProps) {
91
94
  useMultiSelectContext()
92
95
  return <ComboboxTags {...props} />
93
96
  }
97
+ /** The field well around the chips, input and buttons. */
98
+ export function MultiSelectControl(props: MultiSelectControlProps) {
99
+ useMultiSelectContext()
100
+ return <ComboboxControl {...props} />
101
+ }
package/src/index.ts CHANGED
@@ -573,11 +573,12 @@ export { Tag } from './components/Tag/Tag.js'
573
573
  export type { TagProps } from './components/Tag/Tag.js'
574
574
  export { TagsInput } from './components/TagsInput/TagsInput.js'
575
575
  export type { TagsInputProps } from './components/TagsInput/TagsInput.js'
576
- export { ComboboxTags } from './components/Combobox/Combobox.js'
576
+ export { ComboboxTags, ComboboxControl } from './components/Combobox/Combobox.js'
577
577
  export type {
578
578
  ComboboxMultipleProps,
579
579
  ComboboxMultipleState,
580
- ComboboxTagsProps
580
+ ComboboxTagsProps,
581
+ ComboboxControlProps
581
582
  } from './components/Combobox/Combobox.js'
582
583
  export { OTPField } from './components/OTPField/OTPField.js'
583
584
  export { ButtonGroup } from './components/ButtonGroup/ButtonGroup.js'
@@ -611,6 +612,7 @@ export {
611
612
  MultiSelectItem,
612
613
  MultiSelectStatus,
613
614
  MultiSelectTags,
615
+ MultiSelectControl,
614
616
  useMultiSelect
615
617
  } from './components/MultiSelect/MultiSelect.js'
616
618
  export type {
@@ -625,6 +627,7 @@ export type {
625
627
  MultiSelectItemProps,
626
628
  MultiSelectStatusProps,
627
629
  MultiSelectTagsProps,
630
+ MultiSelectControlProps,
628
631
  MultiSelectRenderProps
629
632
  } from './components/MultiSelect/MultiSelect.js'
630
633
 
@@ -769,8 +772,7 @@ export {
769
772
  SidebarTrigger,
770
773
  SidebarLabel,
771
774
  SidebarContent,
772
- useAppShell,
773
- useSidebar
775
+ useAppShell
774
776
  } from './components/AppShell/AppShell.js'
775
777
  export type {
776
778
  AppShellProps,
@@ -812,5 +814,6 @@ export {
812
814
  type CarouselState,
813
815
  type CarouselViewportProps,
814
816
  type CarouselActionProps,
817
+ type CarouselAutoPlayProps,
815
818
  type CarouselIndicatorsProps
816
819
  } from './components/Carousel/Carousel.js'
@@ -58,12 +58,14 @@ export function useComboboxPopup(
58
58
  }
59
59
  const doc = input.ownerDocument
60
60
  const win = doc.defaultView!
61
+ // A multiple Combobox anchors to the field well around its chips, not to the editor alone.
62
+ const anchorNode = input.closest<HTMLElement>('[data-slot~="multi-select-control"]') ?? input
61
63
  const seedWidth = () => {
62
64
  const available =
63
65
  (win.visualViewport?.width ?? win.innerWidth) - 2 * Math.max(0, collisionPadding)
64
66
  node.style.setProperty(
65
67
  '--_rad-combobox-width',
66
- `${Math.min(input.getBoundingClientRect().width, Math.max(0, available))}px`
68
+ `${Math.min(anchorNode.getBoundingClientRect().width, Math.max(0, available))}px`
67
69
  )
68
70
  }
69
71
  seedWidth()
@@ -73,7 +75,7 @@ export function useComboboxPopup(
73
75
  seedWidth()
74
76
  const viewport = win.visualViewport
75
77
  const css = win.getComputedStyle(node)
76
- const anchor = input.getBoundingClientRect()
78
+ const anchor = anchorNode.getBoundingClientRect()
77
79
  const padding = Math.max(0, collisionPadding)
78
80
  const list = node.querySelector<HTMLElement>('[data-slot~="combobox-listbox"]')
79
81
  const status = node.querySelector<HTMLElement>('[data-slot~="combobox-status"]')
@@ -139,7 +141,7 @@ export function useComboboxPopup(
139
141
  }
140
142
  const observer = new win.ResizeObserver(schedule)
141
143
  const mutations = new win.MutationObserver(schedule)
142
- observer.observe(input)
144
+ observer.observe(anchorNode)
143
145
  observer.observe(node)
144
146
  mutations.observe(node, { childList: true, subtree: true, characterData: true })
145
147
  doc.addEventListener('pointerdown', outside, true)