@abuzareal/contour-ui 0.5.0 → 0.6.1

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 (87) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/COMBOBOX.md +87 -0
  3. package/COMPOSITION.md +4 -0
  4. package/CONTRACTS.md +27 -27
  5. package/DOCS.md +86 -0
  6. package/FORMS.md +4 -0
  7. package/FOUNDATION.md +35 -0
  8. package/GETTING-STARTED.md +67 -0
  9. package/HELPERS.md +33 -0
  10. package/HOOKS.md +67 -0
  11. package/MANUAL-QA.md +38 -0
  12. package/MIGRATION.md +44 -0
  13. package/MODELS.md +18 -0
  14. package/NEXTJS.md +3 -1
  15. package/OVERLAYS.md +4 -0
  16. package/PROP-REFERENCE.md +37 -0
  17. package/PUBLIC-API.md +174 -164
  18. package/README.md +9 -5
  19. package/RECIPES.md +43 -0
  20. package/REFERENCE.md +193 -0
  21. package/RELEASING.md +8 -2
  22. package/SIZE.md +9 -3
  23. package/STYLING.md +4 -0
  24. package/SUPPORT.md +36 -0
  25. package/THREE.md +40 -0
  26. package/dist/components/ui/Combobox.d.ts +325 -0
  27. package/dist/components/ui/Combobox.js +135 -0
  28. package/dist/components/ui/Combobox.types.d.ts +46 -0
  29. package/dist/components/ui/Combobox.types.js +1 -0
  30. package/dist/components/ui/DataTable.js +5 -4
  31. package/dist/components/ui/Field.js +1 -1
  32. package/dist/components/ui/FloatingPortal.js +2 -40
  33. package/dist/components/ui/FloatingScope.d.ts +9 -0
  34. package/dist/components/ui/FloatingScope.js +43 -0
  35. package/dist/components/ui/Table.d.ts +20 -0
  36. package/dist/components/ui/Table.js +9 -0
  37. package/dist/hooks/useComboboxAnchor.d.ts +17 -0
  38. package/dist/hooks/useComboboxAnchor.js +61 -0
  39. package/dist/hooks/useInitialHashScroll.js +5 -1
  40. package/dist/hooks/usePrintPreparation.js +12 -1
  41. package/dist/hooks/useScrollSpy.js +6 -3
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +2 -0
  44. package/dist/kit/data-display.css +6 -0
  45. package/dist/kit/forms.css +34 -0
  46. package/dist/lib/componentClasses.js +1 -1
  47. package/dist/scoped/kit/data-display.css +6 -0
  48. package/dist/scoped/kit/forms.css +34 -0
  49. package/docs/prop-metadata.json +2668 -0
  50. package/examples/onboarding/SettingsForm.jsx +30 -0
  51. package/examples/onboarding/SettingsForm.tsx +50 -0
  52. package/examples/optional/LazyScene.tsx +78 -0
  53. package/examples/optional/OptionalSmoothScroll.tsx +25 -0
  54. package/examples/optional/SmoothScrollOwner.tsx +7 -0
  55. package/examples/optional/optional.css +25 -0
  56. package/examples/recipes/AsyncProjectPicker.tsx +82 -0
  57. package/examples/recipes/DeleteProjectConfirmation.tsx +97 -0
  58. package/examples/recipes/InputCompositions.tsx +49 -0
  59. package/examples/recipes/RemoteRecordsTable.tsx +256 -0
  60. package/examples/recipes/useRemoteResource.ts +81 -0
  61. package/examples/reference/HookExamples.tsx +146 -0
  62. package/examples/reproduction/README.md +9 -0
  63. package/examples/reproduction/index.html +14 -0
  64. package/examples/reproduction/package.json +27 -0
  65. package/examples/reproduction/src/main.tsx +33 -0
  66. package/examples/reproduction/src/style.css +19 -0
  67. package/examples/reproduction/tsconfig.json +18 -0
  68. package/examples/reproduction/vite.config.ts +19 -0
  69. package/examples/starters/next/README.md +18 -0
  70. package/examples/starters/next/app/Demo.tsx +65 -0
  71. package/examples/starters/next/app/layout.tsx +25 -0
  72. package/examples/starters/next/app/next-page/page.tsx +9 -0
  73. package/examples/starters/next/app/page.tsx +11 -0
  74. package/examples/starters/next/app/style.css +19 -0
  75. package/examples/starters/next/next-env.d.ts +2 -0
  76. package/examples/starters/next/next.config.mjs +1 -0
  77. package/examples/starters/next/package.json +27 -0
  78. package/examples/starters/next/proxy.ts +16 -0
  79. package/examples/starters/next/tsconfig.json +30 -0
  80. package/examples/starters/vite/README.md +16 -0
  81. package/examples/starters/vite/index.html +14 -0
  82. package/examples/starters/vite/package.json +27 -0
  83. package/examples/starters/vite/src/main.tsx +81 -0
  84. package/examples/starters/vite/src/style.css +19 -0
  85. package/examples/starters/vite/tsconfig.json +18 -0
  86. package/examples/starters/vite/vite.config.ts +19 -0
  87. package/package.json +37 -4
@@ -0,0 +1,325 @@
1
+ export type { ComboboxOption, ComboboxProps } from "./Combobox.types.js";
2
+ import type { ComboboxOption } from "./Combobox.types.js";
3
+ /** Searchable allowed-value selection. The forwarded ref targets the visible input. */
4
+ declare const Combobox: import("react").ForwardRefExoticComponent<import("../../hooks/useFloatingPanel.js").FloatingOptions & {
5
+ label: string;
6
+ options: readonly ComboboxOption[];
7
+ filteredOptions?: readonly ComboboxOption[];
8
+ value?: string | null;
9
+ defaultValue?: string | null;
10
+ onValueChange?: (value: string | null) => void;
11
+ inputValue?: string;
12
+ defaultInputValue?: string;
13
+ onInputValueChange?: (query: string) => void;
14
+ open?: boolean;
15
+ defaultOpen?: boolean;
16
+ onOpenChange?: (open: boolean) => void;
17
+ id?: string;
18
+ name?: string;
19
+ form?: string;
20
+ required?: boolean;
21
+ disabled?: boolean;
22
+ readOnly?: boolean;
23
+ hint?: string;
24
+ error?: string;
25
+ hideLabel?: boolean;
26
+ loading?: boolean;
27
+ searchError?: string;
28
+ onRetry?: () => void;
29
+ loadingText?: string;
30
+ emptyText?: string;
31
+ retryLabel?: string;
32
+ triggerLabel?: string;
33
+ missingValueText?: string;
34
+ inputProps?: {
35
+ [x: `data-${string}`]: string | number | boolean | undefined;
36
+ title?: string | undefined | undefined;
37
+ ref?: ((instance: HTMLInputElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLInputElement> | null | undefined;
38
+ suppressHydrationWarning?: boolean | undefined | undefined;
39
+ className?: string | undefined | undefined;
40
+ color?: string | undefined | undefined;
41
+ height?: number | string | undefined | undefined;
42
+ lang?: string | undefined | undefined;
43
+ max?: number | string | undefined | undefined;
44
+ min?: number | string | undefined | undefined;
45
+ style?: import("react").CSSProperties | undefined;
46
+ width?: number | string | undefined | undefined;
47
+ role?: import("react").AriaRole | undefined;
48
+ tabIndex?: number | undefined | undefined;
49
+ "aria-activedescendant"?: string | undefined | undefined;
50
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
51
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
52
+ "aria-braillelabel"?: string | undefined | undefined;
53
+ "aria-brailleroledescription"?: string | undefined | undefined;
54
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
55
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
56
+ "aria-colcount"?: number | undefined | undefined;
57
+ "aria-colindex"?: number | undefined | undefined;
58
+ "aria-colindextext"?: string | undefined | undefined;
59
+ "aria-colspan"?: number | undefined | undefined;
60
+ "aria-controls"?: string | undefined | undefined;
61
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
62
+ "aria-describedby"?: string | undefined | undefined;
63
+ "aria-description"?: string | undefined | undefined;
64
+ "aria-details"?: string | undefined | undefined;
65
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
66
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
67
+ "aria-errormessage"?: string | undefined | undefined;
68
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
69
+ "aria-flowto"?: string | undefined | undefined;
70
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
71
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
72
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
73
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
74
+ "aria-keyshortcuts"?: string | undefined | undefined;
75
+ "aria-label"?: string | undefined | undefined;
76
+ "aria-labelledby"?: string | undefined | undefined;
77
+ "aria-level"?: number | undefined | undefined;
78
+ "aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
79
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
80
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
81
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
82
+ "aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
83
+ "aria-owns"?: string | undefined | undefined;
84
+ "aria-placeholder"?: string | undefined | undefined;
85
+ "aria-posinset"?: number | undefined | undefined;
86
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
87
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
88
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
89
+ "aria-required"?: (boolean | "true" | "false") | undefined;
90
+ "aria-roledescription"?: string | undefined | undefined;
91
+ "aria-rowcount"?: number | undefined | undefined;
92
+ "aria-rowindex"?: number | undefined | undefined;
93
+ "aria-rowindextext"?: string | undefined | undefined;
94
+ "aria-rowspan"?: number | undefined | undefined;
95
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
96
+ "aria-setsize"?: number | undefined | undefined;
97
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
98
+ "aria-valuemax"?: number | undefined | undefined;
99
+ "aria-valuemin"?: number | undefined | undefined;
100
+ "aria-valuenow"?: number | undefined | undefined;
101
+ "aria-valuetext"?: string | undefined | undefined;
102
+ onCopy?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
103
+ onCopyCapture?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
104
+ onCut?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
105
+ onCutCapture?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
106
+ onPaste?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
107
+ onPasteCapture?: import("react").ClipboardEventHandler<HTMLInputElement> | undefined;
108
+ onCompositionEnd?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
109
+ onCompositionEndCapture?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
110
+ onCompositionStart?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
111
+ onCompositionStartCapture?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
112
+ onCompositionUpdate?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
113
+ onCompositionUpdateCapture?: import("react").CompositionEventHandler<HTMLInputElement> | undefined;
114
+ onFocus?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
115
+ onFocusCapture?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
116
+ onBlur?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
117
+ onBlurCapture?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
118
+ onChange?: import("react").ChangeEventHandler<HTMLInputElement> | undefined;
119
+ onChangeCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
120
+ onBeforeInput?: import("react").InputEventHandler<HTMLInputElement> | undefined;
121
+ onBeforeInputCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
122
+ onInput?: import("react").FormEventHandler<HTMLInputElement> | undefined;
123
+ onInputCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
124
+ onReset?: import("react").FormEventHandler<HTMLInputElement> | undefined;
125
+ onResetCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
126
+ onSubmit?: import("react").FormEventHandler<HTMLInputElement> | undefined;
127
+ onSubmitCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
128
+ onInvalid?: import("react").FormEventHandler<HTMLInputElement> | undefined;
129
+ onInvalidCapture?: import("react").FormEventHandler<HTMLInputElement> | undefined;
130
+ onLoad?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
131
+ onLoadCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
132
+ onError?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
133
+ onErrorCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
134
+ onKeyDown?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
135
+ onKeyDownCapture?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
136
+ onKeyPress?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
137
+ onKeyPressCapture?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
138
+ onKeyUp?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
139
+ onKeyUpCapture?: import("react").KeyboardEventHandler<HTMLInputElement> | undefined;
140
+ onAbort?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
141
+ onAbortCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
142
+ onCanPlay?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
143
+ onCanPlayCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
144
+ onCanPlayThrough?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
145
+ onCanPlayThroughCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
146
+ onDurationChange?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
147
+ onDurationChangeCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
148
+ onEmptied?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
149
+ onEmptiedCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
150
+ onEncrypted?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
151
+ onEncryptedCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
152
+ onEnded?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
153
+ onEndedCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
154
+ onLoadedData?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
155
+ onLoadedDataCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
156
+ onLoadedMetadata?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
157
+ onLoadedMetadataCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
158
+ onLoadStart?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
159
+ onLoadStartCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
160
+ onPause?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
161
+ onPauseCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
162
+ onPlay?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
163
+ onPlayCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
164
+ onPlaying?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
165
+ onPlayingCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
166
+ onProgress?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
167
+ onProgressCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
168
+ onRateChange?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
169
+ onRateChangeCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
170
+ onSeeked?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
171
+ onSeekedCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
172
+ onSeeking?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
173
+ onSeekingCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
174
+ onStalled?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
175
+ onStalledCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
176
+ onSuspend?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
177
+ onSuspendCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
178
+ onTimeUpdate?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
179
+ onTimeUpdateCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
180
+ onVolumeChange?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
181
+ onVolumeChangeCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
182
+ onWaiting?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
183
+ onWaitingCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
184
+ onAuxClick?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
185
+ onAuxClickCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
186
+ onClick?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
187
+ onClickCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
188
+ onContextMenu?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
189
+ onContextMenuCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
190
+ onDoubleClick?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
191
+ onDoubleClickCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
192
+ onDrag?: import("react").DragEventHandler<HTMLInputElement> | undefined;
193
+ onDragCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
194
+ onDragEnd?: import("react").DragEventHandler<HTMLInputElement> | undefined;
195
+ onDragEndCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
196
+ onDragEnter?: import("react").DragEventHandler<HTMLInputElement> | undefined;
197
+ onDragEnterCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
198
+ onDragExit?: import("react").DragEventHandler<HTMLInputElement> | undefined;
199
+ onDragExitCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
200
+ onDragLeave?: import("react").DragEventHandler<HTMLInputElement> | undefined;
201
+ onDragLeaveCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
202
+ onDragOver?: import("react").DragEventHandler<HTMLInputElement> | undefined;
203
+ onDragOverCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
204
+ onDragStart?: import("react").DragEventHandler<HTMLInputElement> | undefined;
205
+ onDragStartCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
206
+ onDrop?: import("react").DragEventHandler<HTMLInputElement> | undefined;
207
+ onDropCapture?: import("react").DragEventHandler<HTMLInputElement> | undefined;
208
+ onMouseDown?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
209
+ onMouseDownCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
210
+ onMouseEnter?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
211
+ onMouseLeave?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
212
+ onMouseMove?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
213
+ onMouseMoveCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
214
+ onMouseOut?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
215
+ onMouseOutCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
216
+ onMouseOver?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
217
+ onMouseOverCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
218
+ onMouseUp?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
219
+ onMouseUpCapture?: import("react").MouseEventHandler<HTMLInputElement> | undefined;
220
+ onSelect?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
221
+ onSelectCapture?: import("react").ReactEventHandler<HTMLInputElement> | undefined;
222
+ onTouchCancel?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
223
+ onTouchCancelCapture?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
224
+ onTouchEnd?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
225
+ onTouchEndCapture?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
226
+ onTouchMove?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
227
+ onTouchMoveCapture?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
228
+ onTouchStart?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
229
+ onTouchStartCapture?: import("react").TouchEventHandler<HTMLInputElement> | undefined;
230
+ onPointerDown?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
231
+ onPointerDownCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
232
+ onPointerMove?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
233
+ onPointerMoveCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
234
+ onPointerUp?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
235
+ onPointerUpCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
236
+ onPointerCancel?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
237
+ onPointerCancelCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
238
+ onPointerEnter?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
239
+ onPointerLeave?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
240
+ onPointerOver?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
241
+ onPointerOverCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
242
+ onPointerOut?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
243
+ onPointerOutCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
244
+ onGotPointerCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
245
+ onGotPointerCaptureCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
246
+ onLostPointerCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
247
+ onLostPointerCaptureCapture?: import("react").PointerEventHandler<HTMLInputElement> | undefined;
248
+ onScroll?: import("react").UIEventHandler<HTMLInputElement> | undefined;
249
+ onScrollCapture?: import("react").UIEventHandler<HTMLInputElement> | undefined;
250
+ onWheel?: import("react").WheelEventHandler<HTMLInputElement> | undefined;
251
+ onWheelCapture?: import("react").WheelEventHandler<HTMLInputElement> | undefined;
252
+ onAnimationStart?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
253
+ onAnimationStartCapture?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
254
+ onAnimationEnd?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
255
+ onAnimationEndCapture?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
256
+ onAnimationIteration?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
257
+ onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLInputElement> | undefined;
258
+ onTransitionEnd?: import("react").TransitionEventHandler<HTMLInputElement> | undefined;
259
+ onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLInputElement> | undefined;
260
+ key?: import("react").Key | null | undefined;
261
+ size?: number | undefined | undefined;
262
+ list?: string | undefined | undefined;
263
+ src?: string | undefined | undefined;
264
+ alt?: string | undefined | undefined;
265
+ step?: number | string | undefined | undefined;
266
+ formAction?: string | undefined;
267
+ formEncType?: string | undefined | undefined;
268
+ formMethod?: string | undefined | undefined;
269
+ formNoValidate?: boolean | undefined | undefined;
270
+ formTarget?: string | undefined | undefined;
271
+ defaultChecked?: boolean | undefined | undefined;
272
+ suppressContentEditableWarning?: boolean | undefined | undefined;
273
+ accessKey?: string | undefined | undefined;
274
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
275
+ autoFocus?: boolean | undefined | undefined;
276
+ contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
277
+ contextMenu?: string | undefined | undefined;
278
+ dir?: string | undefined | undefined;
279
+ draggable?: (boolean | "true" | "false") | undefined;
280
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
281
+ hidden?: boolean | undefined | undefined;
282
+ nonce?: string | undefined | undefined;
283
+ slot?: string | undefined | undefined;
284
+ spellCheck?: (boolean | "true" | "false") | undefined;
285
+ translate?: "yes" | "no" | undefined | undefined;
286
+ radioGroup?: string | undefined | undefined;
287
+ about?: string | undefined | undefined;
288
+ content?: string | undefined | undefined;
289
+ datatype?: string | undefined | undefined;
290
+ inlist?: any;
291
+ prefix?: string | undefined | undefined;
292
+ property?: string | undefined | undefined;
293
+ rel?: string | undefined | undefined;
294
+ resource?: string | undefined | undefined;
295
+ rev?: string | undefined | undefined;
296
+ typeof?: string | undefined | undefined;
297
+ vocab?: string | undefined | undefined;
298
+ autoCorrect?: string | undefined | undefined;
299
+ autoSave?: string | undefined | undefined;
300
+ itemProp?: string | undefined | undefined;
301
+ itemScope?: boolean | undefined | undefined;
302
+ itemType?: string | undefined | undefined;
303
+ itemID?: string | undefined | undefined;
304
+ itemRef?: string | undefined | undefined;
305
+ results?: number | undefined | undefined;
306
+ security?: string | undefined | undefined;
307
+ unselectable?: "on" | "off" | undefined | undefined;
308
+ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
309
+ is?: string | undefined | undefined;
310
+ exportparts?: string | undefined | undefined;
311
+ part?: string | undefined | undefined;
312
+ accept?: string | undefined | undefined;
313
+ autoComplete?: import("react").HTMLInputAutoCompleteAttribute | undefined;
314
+ capture?: boolean | "user" | "environment" | undefined | undefined;
315
+ checked?: boolean | undefined | undefined;
316
+ maxLength?: number | undefined | undefined;
317
+ minLength?: number | undefined | undefined;
318
+ multiple?: boolean | undefined | undefined;
319
+ pattern?: string | undefined | undefined;
320
+ placeholder?: string | undefined | undefined;
321
+ };
322
+ popupProps?: import("../../lib/componentProps.js").NativePartProps<"div">;
323
+ rootProps?: import("../../lib/componentProps.js").NativePartProps<"div">;
324
+ } & import("react").RefAttributes<HTMLInputElement>>;
325
+ export default Combobox;
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useContext, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
4
+ import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
5
+ import { DirectionProvider } from "@base-ui/react/direction-provider";
6
+ import { Check, ChevronDown } from "lucide-react";
7
+ import { ccx } from "../../lib/classNames.js";
8
+ import { fieldDescribedBy } from "../../lib/a11y.js";
9
+ import { composeRefs } from "../../lib/composeRefs.js";
10
+ import { LayerVisibility } from "../../lib/layers.js";
11
+ import { floatingContainer } from "../../hooks/useFloatingPanel.js";
12
+ import useControlRef from "../../hooks/useControlRef.js";
13
+ import useFormReset from "../../hooks/useFormReset.js";
14
+ import useLayerDismiss from "../../hooks/useLayerDismiss.js";
15
+ import useOpenState from "../../hooks/useOpenState.js";
16
+ import useComboboxAnchor from "../../hooks/useComboboxAnchor.js";
17
+ import FloatingScope from "./FloatingScope.js";
18
+ import Field from "./Field.js";
19
+ /** Searchable allowed-value selection. The forwarded ref targets the visible input. */
20
+ const Combobox = forwardRef(function Combobox({ label, options, filteredOptions, value: controlledValue, defaultValue = null, onValueChange, inputValue, defaultInputValue, onInputValueChange, open: controlledOpen, defaultOpen = false, onOpenChange, id: providedId, name, form, required, disabled, readOnly, hint, error, hideLabel, loading = false, searchError, onRetry, loadingText = "Loading choices…", emptyText = "No matching choices.", retryLabel = "Retry search", triggerLabel = "Show choices", missingValueText = "Selected option is unavailable. Choose another.", side = "bottom", align = "start", sideOffset = 8, collisionPadding = 8, portal = true, container, inputProps, popupProps, rootProps, }, forwardedRef) {
21
+ const generatedId = useId();
22
+ const id = providedId ?? generatedId;
23
+ const [internalValue, setInternalValue] = useState(defaultValue);
24
+ const value = controlledValue === undefined ? internalValue : controlledValue;
25
+ const selected = options.find((option) => option.value === value);
26
+ const missing = value !== null && !selected;
27
+ const [query, setQuery] = useState(defaultInputValue ?? null);
28
+ const [open, changeOpen] = useOpenState(controlledOpen, defaultOpen, onOpenChange);
29
+ const available = useContext(LayerVisibility) && !disabled && !readOnly;
30
+ const visible = available && open;
31
+ const { ref: input, attach } = useControlRef(forwardedRef);
32
+ const [anchor, setAnchor] = useState(null);
33
+ const attachInput = useMemo(() => composeRefs(attach, inputProps?.ref, setAnchor), [attach, inputProps?.ref]);
34
+ const actions = useRef(null);
35
+ // The custom non-modal popup has no exit animation. Complete the public close
36
+ // lifecycle after it is hidden so controlled query text returns to the selected label.
37
+ useLayoutEffect(() => {
38
+ if (!visible)
39
+ actions.current?.unmount();
40
+ }, [visible]);
41
+ const root = useRef(null);
42
+ const attachRoot = useMemo(() => composeRefs(root, rootProps?.ref), [rootProps?.ref]);
43
+ const positioner = useRef(null);
44
+ const [, mountedPositioner] = useState(null);
45
+ const attachPositioner = useMemo(() => composeRefs(positioner, mountedPositioner), []);
46
+ const [direction, setDirection] = useState("ltr");
47
+ const target = anchor && portal ? floatingContainer(anchor, { container }) : null;
48
+ const collection = useMemo(() => BaseCombobox.createItems(options, {
49
+ getValue: (option) => option.value,
50
+ getLabel: (option) => option.label,
51
+ }), [options]);
52
+ const close = () => {
53
+ changeOpen(false);
54
+ setQuery(null);
55
+ };
56
+ useLayerDismiss(root, visible, close, {
57
+ branches: [positioner, input],
58
+ layerElement: positioner,
59
+ });
60
+ useFormReset(input, () => {
61
+ if (controlledValue === undefined)
62
+ setInternalValue(defaultValue);
63
+ setQuery(null);
64
+ changeOpen(false);
65
+ });
66
+ useLayoutEffect(() => {
67
+ const element = input.current;
68
+ element?.setCustomValidity(missing ? missingValueText : "");
69
+ return () => element?.setCustomValidity("");
70
+ }, [input, missing, missingValueText]);
71
+ const fieldError = error ?? (missing ? missingValueText : undefined);
72
+ const results = loading || searchError ? [] : filteredOptions;
73
+ const statusId = `${id}-search-status`;
74
+ const positioning = useComboboxAnchor(anchor, positioner);
75
+ const popup = (_jsx(FloatingScope, { anchor: anchor, open: visible, target: target, onDirectionChange: setDirection, children: _jsx(BaseCombobox.Positioner, { ...positioning, ref: attachPositioner, className: ccx("combobox-positioner"), positionMethod: "fixed", side: side, align: align, sideOffset: Number.isFinite(sideOffset) ? sideOffset : 8, collisionPadding: Number.isFinite(collisionPadding) ? Math.max(0, collisionPadding) : 8, children: _jsxs("div", { role: "region", "aria-labelledby": `${id}-label`, ...popupProps, className: ccx("combobox-popup", popupProps?.className), hidden: !visible, children: [_jsx(BaseCombobox.Empty, { className: ccx("combobox-status"), children: loading ? loadingText : (searchError ?? emptyText) }), searchError && onRetry && (_jsx("button", { type: "button", className: ccx("combobox-retry"), onClick: onRetry, children: retryLabel })), _jsx(BaseCombobox.List, { className: ccx("combobox-list"), "aria-labelledby": `${id}-label`, children: (option) => (_jsxs(BaseCombobox.Item, { className: ccx("combobox-option"), value: option.value, disabled: option.disabled, children: [_jsx("span", { children: option.label }), _jsx(BaseCombobox.ItemIndicator, { children: _jsx(Check, { size: 14, "aria-hidden": "true" }) })] }, option.value)) })] }) }) }));
76
+ return (_jsx(DirectionProvider, { direction: direction, children: _jsx("div", { ...rootProps, ref: attachRoot, className: ccx("combobox", rootProps?.className), children: _jsxs(BaseCombobox.Root, { actionsRef: actions, items: collection, filteredItems: results, value: missing ? null : value, onValueChange: (next) => {
77
+ if (controlledValue === undefined)
78
+ setInternalValue(next);
79
+ setQuery(null);
80
+ onValueChange?.(next);
81
+ }, inputValue: inputValue ?? query ?? selected?.label ?? "", onInputValueChange: (next, details) => {
82
+ setQuery(details.reason === "input-change" ||
83
+ details.reason === "input-clear"
84
+ ? next
85
+ : null);
86
+ onInputValueChange?.(next);
87
+ }, open: visible, onOpenChange: (next, details) => {
88
+ // Keep native observers informed; a prevented Escape must not dismiss the host layer.
89
+ details.allowPropagation();
90
+ if ((next && !available) ||
91
+ (details.reason === "escape-key" &&
92
+ details.event.defaultPrevented)) {
93
+ details.cancel();
94
+ return;
95
+ }
96
+ if (!next) {
97
+ details.preventUnmountOnClose();
98
+ setQuery(null);
99
+ }
100
+ changeOpen(next);
101
+ }, name: name, form: form, required: required, disabled: disabled, readOnly: readOnly, children: [_jsx(Field, { id: id, label: label, hint: hint, error: fieldError, required: required, disabled: disabled, hideLabel: hideLabel, children: _jsxs(BaseCombobox.InputGroup, { className: ccx("field-control combobox-control"), children: [_jsx(BaseCombobox.Input, { ...inputProps, onMouseDown: (event) => {
102
+ inputProps?.onMouseDown?.(event);
103
+ // Own activation on click; leave native focus/caret behavior intact and avoid stale touch timers.
104
+ event.preventBaseUIHandler();
105
+ }, onClick: (event) => {
106
+ inputProps?.onClick?.(event);
107
+ if (!event.defaultPrevented && available)
108
+ changeOpen(true);
109
+ }, onKeyDown: (event) => {
110
+ inputProps?.onKeyDown?.(event);
111
+ // Contour preserves a closed selection and lets the enclosing layer own Escape.
112
+ // Cancelling only Base UI's handler leaves the native document event intact.
113
+ if (event.defaultPrevented ||
114
+ (event.key === "Escape" && !visible))
115
+ event.preventBaseUIHandler();
116
+ else if (event.key === "Tab" && visible) {
117
+ // Close even when native traversal leaves the document (for example Safari's last field).
118
+ // Do not preventDefault: the browser still owns the next keyboard target.
119
+ event.preventBaseUIHandler();
120
+ close();
121
+ }
122
+ }, ref: attachInput, id: id, form: form, "aria-labelledby": [
123
+ `${id}-label`,
124
+ inputProps?.["aria-labelledby"],
125
+ ]
126
+ .filter(Boolean)
127
+ .join(" "), "aria-invalid": fieldError ? true : inputProps?.["aria-invalid"], "aria-busy": loading || undefined, "aria-describedby": [
128
+ inputProps?.["aria-describedby"],
129
+ fieldDescribedBy(id, hint, fieldError),
130
+ statusId,
131
+ ]
132
+ .filter(Boolean)
133
+ .join(" ") }), _jsx(BaseCombobox.Trigger, { disabled: disabled || readOnly, className: ccx("combobox-trigger"), "aria-label": triggerLabel, children: _jsx(ChevronDown, { size: 16, "aria-hidden": "true" }) })] }) }), _jsx("span", { id: statusId, role: "status", className: ccx("visually-hidden"), children: loading ? loadingText : (searchError ?? "") }), _jsx(BaseCombobox.Portal, { container: portal ? (target ?? undefined) : root, children: popup })] }) }) }));
134
+ });
135
+ export default Combobox;
@@ -0,0 +1,46 @@
1
+ import type { NativePartProps } from "../../lib/componentProps.js";
2
+ import type { FloatingOptions } from "../../hooks/useFloatingPanel.js";
3
+ export type ComboboxOption = {
4
+ /** Unique, nonempty form value. Labels are presentation, never identity. */
5
+ value: string;
6
+ label: string;
7
+ disabled?: boolean;
8
+ };
9
+ type InputPart = Omit<NativePartProps<"input">, "value" | "defaultValue" | "name" | "form" | "id" | "disabled" | "required" | "readOnly" | "type">;
10
+ export type ComboboxProps = FloatingOptions & {
11
+ label: string;
12
+ options: readonly ComboboxOption[];
13
+ /** Application-filtered results. Retain the selected option in options for async searches. */
14
+ filteredOptions?: readonly ComboboxOption[];
15
+ value?: string | null;
16
+ defaultValue?: string | null;
17
+ onValueChange?: (value: string | null) => void;
18
+ inputValue?: string;
19
+ defaultInputValue?: string;
20
+ onInputValueChange?: (query: string) => void;
21
+ open?: boolean;
22
+ defaultOpen?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ id?: string;
25
+ name?: string;
26
+ form?: string;
27
+ required?: boolean;
28
+ disabled?: boolean;
29
+ readOnly?: boolean;
30
+ hint?: string;
31
+ error?: string;
32
+ hideLabel?: boolean;
33
+ loading?: boolean;
34
+ /** Search/service failure, distinct from field validation. Results are hidden until retry succeeds. */
35
+ searchError?: string;
36
+ onRetry?: () => void;
37
+ loadingText?: string;
38
+ emptyText?: string;
39
+ retryLabel?: string;
40
+ triggerLabel?: string;
41
+ missingValueText?: string;
42
+ inputProps?: InputPart;
43
+ popupProps?: NativePartProps<"div">;
44
+ rootProps?: NativePartProps<"div">;
45
+ };
46
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { ccx } from "../../lib/classNames.js";
4
4
  /** Editorial data table with mono headers, optional column sorting, and horizontal scroll on small screens. */
5
5
  import { useMemo, useState } from "react";
6
+ import Table from "./Table.js";
6
7
  import { ArrowDown, ArrowUp } from "lucide-react";
7
8
  export default function DataTable({ caption, columns, rows, rowKey, }) {
8
9
  const [sort, setSort] = useState(null);
@@ -22,8 +23,8 @@ export default function DataTable({ caption, columns, rows, rowKey, }) {
22
23
  const toggleSort = (key) => setSort((current) => current?.key === key && current.direction === "ascending"
23
24
  ? { key, direction: "descending" }
24
25
  : { key, direction: "ascending" });
25
- return (_jsx("div", { className: ccx("table-scroll"), tabIndex: 0, role: "region", "aria-label": caption, children: _jsxs("table", { className: ccx("data-table"), children: [_jsx("caption", { className: ccx("visually-hidden"), children: caption }), _jsx("thead", { className: ccx("mono"), children: _jsx("tr", { children: columns.map((column) => {
26
- const direction = sort?.key === column.key ? sort.direction : undefined;
27
- return (_jsx("th", { scope: "col", "aria-sort": column.sortable ? (direction ?? "none") : undefined, "data-align": column.align, children: column.sortable ? (_jsxs("button", { type: "button", onClick: () => toggleSort(column.key), children: [column.header, direction === "descending" ? (_jsx(ArrowDown, { size: 12, "aria-hidden": "true" })) : (_jsx(ArrowUp, { size: 12, "aria-hidden": "true", className: ccx(direction ? undefined : "data-table-idle") }))] })) : (column.header) }, column.key));
28
- }) }) }), _jsx("tbody", { children: sortedRows.map((row) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { "data-align": column.align, children: column.render ? column.render(row) : row[column.key] }, column.key))) }, String(row[rowKey])))) })] }) }));
26
+ return (_jsxs(Table, { caption: caption, children: [_jsx("thead", { className: ccx("mono"), children: _jsx("tr", { children: columns.map((column) => {
27
+ const direction = sort?.key === column.key ? sort.direction : undefined;
28
+ return (_jsx("th", { scope: "col", "aria-sort": column.sortable ? (direction ?? "none") : undefined, "data-align": column.align, children: column.sortable ? (_jsxs("button", { type: "button", onClick: () => toggleSort(column.key), children: [column.header, direction === "descending" ? (_jsx(ArrowDown, { size: 12, "aria-hidden": "true" })) : (_jsx(ArrowUp, { size: 12, "aria-hidden": "true", className: ccx(direction ? undefined : "data-table-idle") }))] })) : (column.header) }, column.key));
29
+ }) }) }), _jsx("tbody", { children: sortedRows.map((row) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { "data-align": column.align, children: column.render ? column.render(row) : row[column.key] }, column.key))) }, String(row[rowKey])))) })] }));
29
30
  }
@@ -2,5 +2,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AlertCircle } from "lucide-react";
3
3
  import { ccx } from "../../lib/classNames.js";
4
4
  export default function Field({ id, label, children, hint, error, required, hideLabel, counter, disabled, }) {
5
- return (_jsxs("div", { className: ccx("field", error && "field-invalid", disabled && "field-disabled"), children: [_jsxs("label", { htmlFor: id, className: ccx("field-label mono", hideLabel && "visually-hidden"), children: [label, required && (_jsx("span", { className: ccx("field-required"), "aria-hidden": "true", children: "*" }))] }), children, (hint || error || counter) && (_jsxs("div", { className: ccx("field-footer mono"), children: [error ? (_jsxs("span", { id: `${id}-error`, className: ccx("field-error"), children: [_jsx(AlertCircle, { size: 13, "aria-hidden": "true" }), error] })) : (hint && _jsx("span", { id: `${id}-hint`, children: hint })), counter && _jsx("span", { className: ccx("field-counter"), children: counter })] }))] }));
5
+ return (_jsxs("div", { className: ccx("field", error && "field-invalid", disabled && "field-disabled"), children: [_jsxs("label", { htmlFor: id, className: ccx("field-label mono", hideLabel && "visually-hidden"), children: [_jsx("span", { id: `${id}-label`, children: label }), required && (_jsx("span", { className: ccx("field-required"), "aria-hidden": "true", children: "*" }))] }), children, (hint || error || counter) && (_jsxs("div", { className: ccx("field-footer mono"), children: [error ? (_jsxs("span", { id: `${id}-error`, className: ccx("field-error"), children: [_jsx(AlertCircle, { size: 13, "aria-hidden": "true" }), error] })) : (hint && _jsx("span", { id: `${id}-hint`, children: hint })), counter && _jsx("span", { className: ccx("field-counter"), children: counter })] }))] }));
6
6
  }
@@ -1,51 +1,13 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useLayoutEffect, useRef } from "react";
4
3
  import { createPortal } from "react-dom";
5
4
  import useFloatingPanel, { floatingContainer, } from "../../hooks/useFloatingPanel.js";
5
+ import FloatingScope from "./FloatingScope.js";
6
6
  export default function FloatingPortal({ anchor, anchorElement, panel, open, options, children, }) {
7
- const scope = useRef(null);
8
7
  const target = anchorElement && options.portal !== false
9
8
  ? floatingContainer(anchorElement, options)
10
9
  : null;
11
- useLayoutEffect(() => {
12
- const root = scope.current;
13
- if (!open || !anchorElement || !root)
14
- return;
15
- const view = anchorElement.ownerDocument.defaultView;
16
- if (!view)
17
- return;
18
- const synchronize = () => {
19
- const computed = view.getComputedStyle(anchorElement);
20
- // Copy inherited CSS variables without controlling the host document's theme.
21
- for (let index = 0; index < computed.length; index++) {
22
- const name = computed.item(index);
23
- if (name.startsWith("--"))
24
- root.style.setProperty(name, computed.getPropertyValue(name));
25
- }
26
- root.dir = computed.direction;
27
- root.style.fontFamily = computed.fontFamily;
28
- root.style.color = computed.color;
29
- };
30
- synchronize();
31
- const observer = new view.MutationObserver(synchronize);
32
- let ancestor = anchorElement;
33
- while (ancestor) {
34
- observer.observe(ancestor, {
35
- attributes: true,
36
- attributeFilter: [
37
- "style",
38
- "class",
39
- "dir",
40
- "data-theme",
41
- "data-contour-theme",
42
- ],
43
- });
44
- ancestor = ancestor.parentElement;
45
- }
46
- return () => observer.disconnect();
47
- }, [anchorElement, target, open]);
48
10
  useFloatingPanel(anchor, panel, open, { ...options, container: target });
49
- const content = (_jsx("span", { ref: scope, className: "contour-floating-root contour-root", style: { display: "contents" }, children: children }));
11
+ const content = (_jsx(FloatingScope, { anchor: anchorElement, open: open, target: target, children: children }));
50
12
  return target ? createPortal(content, target) : content;
51
13
  }
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from "react";
2
+ /** Carry the anchor's inherited theme into a portal without changing its host. */
3
+ export default function FloatingScope({ anchor, open, target, onDirectionChange, children, }: {
4
+ anchor: HTMLElement | null;
5
+ open: boolean;
6
+ target: Node | null;
7
+ onDirectionChange?: (direction: "ltr" | "rtl") => void;
8
+ children: ReactNode;
9
+ }): import("react").JSX.Element;