@haklex/rich-editor-ui 0.0.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 (37) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +152 -0
  3. package/dist/components/color-picker/index.d.ts +7 -0
  4. package/dist/components/color-picker/index.d.ts.map +1 -0
  5. package/dist/components/color-picker/styles.css.d.ts +11 -0
  6. package/dist/components/color-picker/styles.css.d.ts.map +1 -0
  7. package/dist/components/dialog/index.d.ts +28 -0
  8. package/dist/components/dialog/index.d.ts.map +1 -0
  9. package/dist/components/dialog/stack.d.ts +3 -0
  10. package/dist/components/dialog/stack.d.ts.map +1 -0
  11. package/dist/components/dialog/store.d.ts +24 -0
  12. package/dist/components/dialog/store.d.ts.map +1 -0
  13. package/dist/components/dialog/styles.css.d.ts +8 -0
  14. package/dist/components/dialog/styles.css.d.ts.map +1 -0
  15. package/dist/components/dropdown-menu/index.d.ts +37 -0
  16. package/dist/components/dropdown-menu/index.d.ts.map +1 -0
  17. package/dist/components/dropdown-menu/styles.css.d.ts +7 -0
  18. package/dist/components/dropdown-menu/styles.css.d.ts.map +1 -0
  19. package/dist/components/popover/index.d.ts +36 -0
  20. package/dist/components/popover/index.d.ts.map +1 -0
  21. package/dist/components/popover/styles.css.d.ts +5 -0
  22. package/dist/components/popover/styles.css.d.ts.map +1 -0
  23. package/dist/components/segmented-control/index.d.ts +16 -0
  24. package/dist/components/segmented-control/index.d.ts.map +1 -0
  25. package/dist/components/segmented-control/styles.css.d.ts +11 -0
  26. package/dist/components/segmented-control/styles.css.d.ts.map +1 -0
  27. package/dist/components/tooltip/index.d.ts +25 -0
  28. package/dist/components/tooltip/index.d.ts.map +1 -0
  29. package/dist/components/tooltip/styles.css.d.ts +2 -0
  30. package/dist/components/tooltip/styles.css.d.ts.map +1 -0
  31. package/dist/index.d.ts +17 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.mjs +743 -0
  34. package/dist/lib/get-strict-context.d.ts +9 -0
  35. package/dist/lib/get-strict-context.d.ts.map +1 -0
  36. package/dist/rich-editor-ui.css +487 -0
  37. package/package.json +47 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,743 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { ChevronDown, Check, X } from "lucide-react";
3
+ import { Popover as Popover$1 } from "@base-ui/react/popover";
4
+ import { createContext, useMemo, use, useState, useEffect, useSyncExternalStore, useCallback, createElement, useRef } from "react";
5
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
6
+ import { Menu } from "@base-ui/react/menu";
7
+ import { Tooltip } from "@base-ui/react/tooltip";
8
+ const PortalThemeContext = createContext({
9
+ className: ""
10
+ });
11
+ function PortalThemeProvider({
12
+ className,
13
+ children
14
+ }) {
15
+ return /* @__PURE__ */ jsx(
16
+ PortalThemeContext.Provider,
17
+ {
18
+ value: useMemo(() => ({ className }), [className]),
19
+ children
20
+ }
21
+ );
22
+ }
23
+ function usePortalTheme() {
24
+ return use(PortalThemeContext);
25
+ }
26
+ function PortalThemeWrapper({ children }) {
27
+ const { className } = usePortalTheme();
28
+ if (!className) return children;
29
+ return /* @__PURE__ */ jsx("div", { style: { display: "contents" }, className, children });
30
+ }
31
+ function getStrictContext(name) {
32
+ const Context = createContext(void 0);
33
+ const Provider = ({
34
+ value,
35
+ children
36
+ }) => /* @__PURE__ */ jsx(Context.Provider, { value, children });
37
+ const useSafeContext = () => {
38
+ const ctx = use(Context);
39
+ if (ctx === void 0) {
40
+ throw new Error(`useContext must be used within ${name}`);
41
+ }
42
+ return ctx;
43
+ };
44
+ return [Provider, useSafeContext];
45
+ }
46
+ var popup$3 = "f2q44l2";
47
+ var arrow = "f2q44l3";
48
+ var title$1 = "f2q44l4";
49
+ var description$1 = "f2q44l5";
50
+ const [PopoverProvider, usePopover] = getStrictContext("PopoverContext");
51
+ function Popover(props) {
52
+ const [isOpen, setIsOpen] = useState(props?.defaultOpen ?? false);
53
+ useEffect(() => {
54
+ if (props.open !== void 0) setIsOpen(props.open);
55
+ }, [props.open]);
56
+ const handleOpenChange = (open, details) => {
57
+ setIsOpen(open);
58
+ props.onOpenChange?.(open, details);
59
+ };
60
+ return /* @__PURE__ */ jsx(PopoverProvider, { value: { isOpen }, children: /* @__PURE__ */ jsx(Popover$1.Root, { ...props, onOpenChange: handleOpenChange }) });
61
+ }
62
+ function PopoverTrigger(props) {
63
+ return /* @__PURE__ */ jsx(Popover$1.Trigger, { ...props });
64
+ }
65
+ function PopoverPortal({ children, ...props }) {
66
+ return /* @__PURE__ */ jsx(Popover$1.Portal, { ...props, children: /* @__PURE__ */ jsx(PortalThemeWrapper, { children }) });
67
+ }
68
+ function PopoverPositioner(props) {
69
+ return /* @__PURE__ */ jsx(Popover$1.Positioner, { ...props });
70
+ }
71
+ function PopoverPopup({
72
+ className,
73
+ children,
74
+ ...props
75
+ }) {
76
+ return /* @__PURE__ */ jsx(
77
+ Popover$1.Popup,
78
+ {
79
+ className: `${popup$3}${className ? ` ${className}` : ""}`,
80
+ ...props,
81
+ children
82
+ }
83
+ );
84
+ }
85
+ function PopoverPanel({
86
+ align = "center",
87
+ side,
88
+ sideOffset = 4,
89
+ className,
90
+ children,
91
+ ...popupProps
92
+ }) {
93
+ return /* @__PURE__ */ jsx(PopoverPortal, { children: /* @__PURE__ */ jsx(PopoverPositioner, { align, side, sideOffset, children: /* @__PURE__ */ jsx(PopoverPopup, { className, ...popupProps, children }) }) });
94
+ }
95
+ function PopoverArrow({ className, ...props }) {
96
+ return /* @__PURE__ */ jsx(
97
+ Popover$1.Arrow,
98
+ {
99
+ className: `${arrow}${className ? ` ${className}` : ""}`,
100
+ ...props
101
+ }
102
+ );
103
+ }
104
+ function PopoverClose(props) {
105
+ return /* @__PURE__ */ jsx(Popover$1.Close, { ...props });
106
+ }
107
+ function PopoverTitle({ className, ...props }) {
108
+ return /* @__PURE__ */ jsx(
109
+ Popover$1.Title,
110
+ {
111
+ className: `${title$1}${className ? ` ${className}` : ""}`,
112
+ ...props
113
+ }
114
+ );
115
+ }
116
+ function PopoverDescription({
117
+ className,
118
+ ...props
119
+ }) {
120
+ return /* @__PURE__ */ jsx(
121
+ Popover$1.Description,
122
+ {
123
+ className: `${description$1}${className ? ` ${className}` : ""}`,
124
+ ...props
125
+ }
126
+ );
127
+ }
128
+ var trigger = "_17r50hf1";
129
+ var triggerLabel = "_17r50hf2";
130
+ var triggerLetter = "_17r50hf3";
131
+ var triggerBar = "_17r50hf4";
132
+ var triggerChevron = "_17r50hf5";
133
+ var panel = "_17r50hf6";
134
+ var grid = "_17r50hf7";
135
+ var swatch = "_17r50hf8";
136
+ var swatchDot = "_17r50hf9";
137
+ var swatchCheck = "_17r50hfa";
138
+ const TEXT_COLORS = [
139
+ { name: "Default", value: "inherit" },
140
+ { name: "Gray", value: "#6b7280" },
141
+ { name: "Red", value: "#ef4444" },
142
+ { name: "Orange", value: "#f97316" },
143
+ { name: "Amber", value: "#f59e0b" },
144
+ { name: "Green", value: "#22c55e" },
145
+ { name: "Teal", value: "#14b8a6" },
146
+ { name: "Blue", value: "#3b82f6" },
147
+ { name: "Indigo", value: "#6366f1" },
148
+ { name: "Pink", value: "#ec4899" }
149
+ ];
150
+ function ColorPicker({
151
+ currentColor,
152
+ onSelect,
153
+ className
154
+ }) {
155
+ const displayColor = currentColor === "inherit" || !currentColor ? "currentColor" : currentColor;
156
+ return /* @__PURE__ */ jsxs(Popover, { children: [
157
+ /* @__PURE__ */ jsxs(
158
+ PopoverTrigger,
159
+ {
160
+ className: `${trigger}${className ? ` ${className}` : ""}`,
161
+ render: /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: (e) => e.preventDefault() }),
162
+ children: [
163
+ /* @__PURE__ */ jsxs("span", { className: triggerLabel, children: [
164
+ /* @__PURE__ */ jsx("span", { className: triggerLetter, style: { color: displayColor }, children: "A" }),
165
+ /* @__PURE__ */ jsx(
166
+ "span",
167
+ {
168
+ className: triggerBar,
169
+ style: { backgroundColor: displayColor }
170
+ }
171
+ )
172
+ ] }),
173
+ /* @__PURE__ */ jsx(ChevronDown, { className: triggerChevron })
174
+ ]
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsx(PopoverPanel, { side: "bottom", sideOffset: 6, className: panel, children: /* @__PURE__ */ jsx("div", { className: grid, children: TEXT_COLORS.map((color) => /* @__PURE__ */ jsxs(
178
+ "button",
179
+ {
180
+ type: "button",
181
+ className: swatch,
182
+ "aria-label": color.name,
183
+ onMouseDown: (e) => {
184
+ e.preventDefault();
185
+ onSelect(color.value);
186
+ },
187
+ children: [
188
+ /* @__PURE__ */ jsx(
189
+ "span",
190
+ {
191
+ className: swatchDot,
192
+ style: {
193
+ backgroundColor: color.value === "inherit" ? "currentColor" : color.value
194
+ }
195
+ }
196
+ ),
197
+ currentColor === color.value && /* @__PURE__ */ jsx(Check, { className: swatchCheck })
198
+ ]
199
+ },
200
+ color.value
201
+ )) }) })
202
+ ] });
203
+ }
204
+ var backdrop = "vwlngv4";
205
+ var popup$2 = "vwlngv5";
206
+ var closeButton = "vwlngv6";
207
+ var header = "vwlngv7";
208
+ var footer = "vwlngv8";
209
+ var title = "vwlngv9";
210
+ var description = "vwlngva";
211
+ function Dialog(props) {
212
+ return /* @__PURE__ */ jsx(Dialog$1.Root, { ...props });
213
+ }
214
+ function DialogTrigger(props) {
215
+ return /* @__PURE__ */ jsx(Dialog$1.Trigger, { ...props });
216
+ }
217
+ function DialogPortal({ children, ...props }) {
218
+ return /* @__PURE__ */ jsx(Dialog$1.Portal, { ...props, children: /* @__PURE__ */ jsx(PortalThemeWrapper, { children }) });
219
+ }
220
+ function DialogBackdrop({ className, ...props }) {
221
+ return /* @__PURE__ */ jsx(
222
+ Dialog$1.Backdrop,
223
+ {
224
+ className: `${backdrop}${className ? ` ${className}` : ""}`,
225
+ ...props
226
+ }
227
+ );
228
+ }
229
+ function DialogPopup({
230
+ showCloseButton = true,
231
+ className,
232
+ children,
233
+ ...props
234
+ }) {
235
+ return /* @__PURE__ */ jsxs(DialogPortal, { children: [
236
+ /* @__PURE__ */ jsx(DialogBackdrop, {}),
237
+ /* @__PURE__ */ jsxs(
238
+ Dialog$1.Popup,
239
+ {
240
+ className: `${popup$2}${className ? ` ${className}` : ""}`,
241
+ ...props,
242
+ children: [
243
+ children,
244
+ showCloseButton && /* @__PURE__ */ jsx(Dialog$1.Close, { className: closeButton, children: /* @__PURE__ */ jsx(X, {}) })
245
+ ]
246
+ }
247
+ )
248
+ ] });
249
+ }
250
+ function DialogClose(props) {
251
+ return /* @__PURE__ */ jsx(Dialog$1.Close, { ...props });
252
+ }
253
+ function DialogHeader({ className, ...props }) {
254
+ return /* @__PURE__ */ jsx(
255
+ "div",
256
+ {
257
+ className: `${header}${className ? ` ${className}` : ""}`,
258
+ ...props
259
+ }
260
+ );
261
+ }
262
+ function DialogFooter({ className, ...props }) {
263
+ return /* @__PURE__ */ jsx(
264
+ "div",
265
+ {
266
+ className: `${footer}${className ? ` ${className}` : ""}`,
267
+ ...props
268
+ }
269
+ );
270
+ }
271
+ function DialogTitle({ className, ...props }) {
272
+ return /* @__PURE__ */ jsx(
273
+ Dialog$1.Title,
274
+ {
275
+ className: `${title}${className ? ` ${className}` : ""}`,
276
+ ...props
277
+ }
278
+ );
279
+ }
280
+ function DialogDescription({
281
+ className,
282
+ ...props
283
+ }) {
284
+ return /* @__PURE__ */ jsx(
285
+ Dialog$1.Description,
286
+ {
287
+ className: `${description}${className ? ` ${className}` : ""}`,
288
+ ...props
289
+ }
290
+ );
291
+ }
292
+ let stack = [];
293
+ let idCounter = 0;
294
+ const listeners = /* @__PURE__ */ new Set();
295
+ function emit() {
296
+ for (const fn of listeners) fn();
297
+ }
298
+ function subscribe(fn) {
299
+ listeners.add(fn);
300
+ return () => {
301
+ listeners.delete(fn);
302
+ };
303
+ }
304
+ function getSnapshot() {
305
+ return stack;
306
+ }
307
+ function presentDialog(props) {
308
+ const id = `dialog-${++idCounter}`;
309
+ stack = [...stack, { ...props, id, open: true }];
310
+ emit();
311
+ return () => dismissDialog(id);
312
+ }
313
+ function removeDialog(id) {
314
+ stack = stack.filter((item2) => item2.id !== id);
315
+ emit();
316
+ }
317
+ function dismissDialog(id) {
318
+ stack = stack.map(
319
+ (item2) => item2.id === id ? { ...item2, open: false } : item2
320
+ );
321
+ emit();
322
+ }
323
+ function dismissTopDialog() {
324
+ for (let i = stack.length - 1; i >= 0; i--) {
325
+ if (stack[i].open) {
326
+ dismissDialog(stack[i].id);
327
+ return;
328
+ }
329
+ }
330
+ }
331
+ function dismissAllDialogs() {
332
+ stack = stack.map((item2) => ({ ...item2, open: false }));
333
+ emit();
334
+ }
335
+ const CloseIcon = () => /* @__PURE__ */ jsx(X, {});
336
+ const PortalWrapper = ({
337
+ className,
338
+ children
339
+ }) => {
340
+ if (!className) return /* @__PURE__ */ jsx(Fragment, { children });
341
+ return /* @__PURE__ */ jsx("div", { className, children });
342
+ };
343
+ const DialogStackEntry = ({ item: item2, index }) => {
344
+ const {
345
+ id,
346
+ open,
347
+ title: title$12,
348
+ description: description$12,
349
+ content,
350
+ className,
351
+ portalClassName,
352
+ showCloseButton = true,
353
+ clickOutsideToDismiss = true
354
+ } = item2;
355
+ const dismiss = useCallback(() => dismissDialog(id), [id]);
356
+ useEffect(() => {
357
+ if (!open) {
358
+ const timer = setTimeout(() => {
359
+ removeDialog(id);
360
+ }, 150);
361
+ return () => clearTimeout(timer);
362
+ }
363
+ }, [open, id]);
364
+ const zIndex = 50 + index;
365
+ return /* @__PURE__ */ jsx(
366
+ Dialog$1.Root,
367
+ {
368
+ open,
369
+ disablePointerDismissal: !clickOutsideToDismiss,
370
+ onOpenChange: (open2) => {
371
+ if (!open2) dismiss();
372
+ },
373
+ children: /* @__PURE__ */ jsx(Dialog$1.Portal, { children: /* @__PURE__ */ jsx(PortalThemeProvider, { className: portalClassName ?? "", children: /* @__PURE__ */ jsxs(PortalWrapper, { className: portalClassName, children: [
374
+ /* @__PURE__ */ jsx(
375
+ Dialog$1.Backdrop,
376
+ {
377
+ className: backdrop,
378
+ style: { zIndex }
379
+ }
380
+ ),
381
+ /* @__PURE__ */ jsxs(
382
+ Dialog$1.Popup,
383
+ {
384
+ className: `${popup$2}${className ? ` ${className}` : ""}`,
385
+ style: { zIndex: zIndex + 1 },
386
+ children: [
387
+ (title$12 || description$12) && /* @__PURE__ */ jsxs("div", { className: header, children: [
388
+ title$12 && /* @__PURE__ */ jsx(Dialog$1.Title, { className: title, children: title$12 }),
389
+ description$12 && /* @__PURE__ */ jsx(Dialog$1.Description, { className: description, children: description$12 })
390
+ ] }),
391
+ createElement(content, { dismiss }),
392
+ showCloseButton && /* @__PURE__ */ jsx(Dialog$1.Close, { className: closeButton, children: /* @__PURE__ */ jsx(CloseIcon, {}) })
393
+ ]
394
+ }
395
+ )
396
+ ] }) }) })
397
+ }
398
+ );
399
+ };
400
+ const DialogStackProvider = ({ children }) => {
401
+ const stack2 = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
402
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
403
+ children,
404
+ stack2.map((item2, index) => /* @__PURE__ */ jsx(DialogStackEntry, { item: item2, index }, item2.id))
405
+ ] });
406
+ };
407
+ var popup$1 = "oih0op0";
408
+ var item$1 = "oih0op1";
409
+ var separator = "oih0op2";
410
+ var label = "oih0op3";
411
+ var checkboxIndicator = "oih0op4";
412
+ var radioIndicator = "oih0op5";
413
+ function DropdownMenu(props) {
414
+ return /* @__PURE__ */ jsx(Menu.Root, { ...props });
415
+ }
416
+ function DropdownMenuTrigger(props) {
417
+ return /* @__PURE__ */ jsx(Menu.Trigger, { ...props });
418
+ }
419
+ function DropdownMenuPortal({ children }) {
420
+ return /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(PortalThemeWrapper, { children }) });
421
+ }
422
+ function DropdownMenuContent({
423
+ align = "start",
424
+ alignOffset = 0,
425
+ side = "bottom",
426
+ sideOffset = 4,
427
+ className,
428
+ children,
429
+ ...popupProps
430
+ }) {
431
+ return /* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsx(
432
+ Menu.Positioner,
433
+ {
434
+ align,
435
+ alignOffset,
436
+ side,
437
+ sideOffset,
438
+ children: /* @__PURE__ */ jsx(
439
+ Menu.Popup,
440
+ {
441
+ className: `${popup$1}${className ? ` ${className}` : ""}`,
442
+ ...popupProps,
443
+ children
444
+ }
445
+ )
446
+ }
447
+ ) });
448
+ }
449
+ function DropdownMenuGroup(props) {
450
+ return /* @__PURE__ */ jsx(Menu.Group, { ...props });
451
+ }
452
+ function DropdownMenuLabel({
453
+ className,
454
+ ...props
455
+ }) {
456
+ return /* @__PURE__ */ jsx(
457
+ Menu.GroupLabel,
458
+ {
459
+ className: `${label}${className ? ` ${className}` : ""}`,
460
+ ...props
461
+ }
462
+ );
463
+ }
464
+ function DropdownMenuItem({
465
+ className,
466
+ ...props
467
+ }) {
468
+ return /* @__PURE__ */ jsx(
469
+ Menu.Item,
470
+ {
471
+ className: `${item$1}${className ? ` ${className}` : ""}`,
472
+ ...props
473
+ }
474
+ );
475
+ }
476
+ function DropdownMenuSeparator({
477
+ className,
478
+ ...props
479
+ }) {
480
+ return /* @__PURE__ */ jsx(
481
+ Menu.Separator,
482
+ {
483
+ className: `${separator}${className ? ` ${className}` : ""}`,
484
+ ...props
485
+ }
486
+ );
487
+ }
488
+ function DropdownMenuRadioGroup(props) {
489
+ return /* @__PURE__ */ jsx(Menu.RadioGroup, { ...props });
490
+ }
491
+ function DropdownMenuRadioItem({
492
+ className,
493
+ children,
494
+ ...props
495
+ }) {
496
+ return /* @__PURE__ */ jsxs(
497
+ Menu.RadioItem,
498
+ {
499
+ className: `${item$1}${className ? ` ${className}` : ""}`,
500
+ ...props,
501
+ children: [
502
+ /* @__PURE__ */ jsx(Menu.RadioItemIndicator, { className: radioIndicator, children: /* @__PURE__ */ jsx(CheckIcon, {}) }),
503
+ children
504
+ ]
505
+ }
506
+ );
507
+ }
508
+ function DropdownMenuCheckboxItem({
509
+ className,
510
+ children,
511
+ ...props
512
+ }) {
513
+ return /* @__PURE__ */ jsxs(
514
+ Menu.CheckboxItem,
515
+ {
516
+ className: `${item$1}${className ? ` ${className}` : ""}`,
517
+ ...props,
518
+ children: [
519
+ /* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, { className: checkboxIndicator, children: /* @__PURE__ */ jsx(CheckIcon, {}) }),
520
+ children
521
+ ]
522
+ }
523
+ );
524
+ }
525
+ function CheckIcon() {
526
+ return /* @__PURE__ */ jsx(Check, { size: 16 });
527
+ }
528
+ var container = "_6d8tz20";
529
+ var containerFullWidth = "_6d8tz21";
530
+ var sizeVariants = { sm: "_6d8tz22", md: "_6d8tz23" };
531
+ var indicator = "_6d8tz24";
532
+ var indicatorHidden = "_6d8tz25";
533
+ var item = "_6d8tz26";
534
+ var itemActive = "_6d8tz27";
535
+ var itemDisabled = "_6d8tz28";
536
+ var itemFullWidth = "_6d8tz29";
537
+ var itemPaddingVariants = { sm: "_6d8tz2a", md: "_6d8tz2b" };
538
+ function SegmentedControl({
539
+ items,
540
+ value,
541
+ onChange,
542
+ size = "sm",
543
+ fullWidth = false,
544
+ className
545
+ }) {
546
+ const containerRef = useRef(null);
547
+ const itemElementsRef = useRef(/* @__PURE__ */ new Map());
548
+ const [indicator$1, setIndicator] = useState({ left: 0, width: 0 });
549
+ const [isReady, setIsReady] = useState(false);
550
+ const updateIndicator = useCallback(() => {
551
+ const container2 = containerRef.current;
552
+ const activeEl = itemElementsRef.current.get(value);
553
+ if (!container2 || !activeEl) return;
554
+ const containerRect = container2.getBoundingClientRect();
555
+ const activeRect = activeEl.getBoundingClientRect();
556
+ setIndicator({
557
+ left: activeRect.left - containerRect.left,
558
+ width: activeRect.width
559
+ });
560
+ setIsReady(true);
561
+ }, [value]);
562
+ useEffect(() => {
563
+ updateIndicator();
564
+ }, [updateIndicator]);
565
+ useEffect(() => {
566
+ const container2 = containerRef.current;
567
+ if (!container2) return;
568
+ const observer = new ResizeObserver(() => {
569
+ updateIndicator();
570
+ });
571
+ observer.observe(container2);
572
+ return () => observer.disconnect();
573
+ }, [updateIndicator]);
574
+ const handleKeyDown = (e) => {
575
+ const enabledItems = items.filter((item2) => !item2.disabled);
576
+ const currentIndex = enabledItems.findIndex((item2) => item2.value === value);
577
+ let nextIndex = currentIndex;
578
+ switch (e.key) {
579
+ case "ArrowRight":
580
+ case "ArrowDown": {
581
+ e.preventDefault();
582
+ nextIndex = (currentIndex + 1) % enabledItems.length;
583
+ break;
584
+ }
585
+ case "ArrowLeft":
586
+ case "ArrowUp": {
587
+ e.preventDefault();
588
+ nextIndex = (currentIndex - 1 + enabledItems.length) % enabledItems.length;
589
+ break;
590
+ }
591
+ case "Home": {
592
+ e.preventDefault();
593
+ nextIndex = 0;
594
+ break;
595
+ }
596
+ case "End": {
597
+ e.preventDefault();
598
+ nextIndex = enabledItems.length - 1;
599
+ break;
600
+ }
601
+ }
602
+ if (nextIndex !== currentIndex) {
603
+ const nextItem = enabledItems[nextIndex];
604
+ onChange(nextItem.value);
605
+ itemElementsRef.current.get(nextItem.value)?.focus();
606
+ }
607
+ };
608
+ return /* @__PURE__ */ jsxs(
609
+ "div",
610
+ {
611
+ ref: containerRef,
612
+ role: "tablist",
613
+ "aria-orientation": "horizontal",
614
+ onKeyDown: handleKeyDown,
615
+ className: `${container} ${sizeVariants[size]} ${fullWidth ? containerFullWidth : ""} ${className || ""}`.trim(),
616
+ children: [
617
+ /* @__PURE__ */ jsx(
618
+ "div",
619
+ {
620
+ className: `${indicator} ${!isReady ? indicatorHidden : ""}`.trim(),
621
+ style: {
622
+ left: indicator$1.left,
623
+ width: indicator$1.width
624
+ },
625
+ "aria-hidden": "true"
626
+ }
627
+ ),
628
+ items.map((item$12) => {
629
+ const isActive = item$12.value === value;
630
+ return /* @__PURE__ */ jsx(
631
+ "button",
632
+ {
633
+ ref: (el) => {
634
+ if (el) itemElementsRef.current.set(item$12.value, el);
635
+ else itemElementsRef.current.delete(item$12.value);
636
+ },
637
+ role: "tab",
638
+ type: "button",
639
+ "aria-selected": isActive,
640
+ "data-active": isActive || void 0,
641
+ tabIndex: isActive ? 0 : -1,
642
+ disabled: item$12.disabled,
643
+ onClick: () => onChange(item$12.value),
644
+ className: `${item} ${itemPaddingVariants[size]} ${isActive ? itemActive : ""} ${item$12.disabled ? itemDisabled : ""} ${fullWidth ? itemFullWidth : ""}`.trim(),
645
+ children: item$12.label
646
+ },
647
+ item$12.value
648
+ );
649
+ })
650
+ ]
651
+ }
652
+ );
653
+ }
654
+ var popup = "_1cspf2m2";
655
+ function TooltipProvider(props) {
656
+ return /* @__PURE__ */ jsx(Tooltip.Provider, { ...props });
657
+ }
658
+ function TooltipRoot(props) {
659
+ return /* @__PURE__ */ jsx(Tooltip.Root, { ...props });
660
+ }
661
+ function TooltipTrigger(props) {
662
+ return /* @__PURE__ */ jsx(Tooltip.Trigger, { ...props });
663
+ }
664
+ function TooltipPortal({ children, ...props }) {
665
+ return /* @__PURE__ */ jsx(Tooltip.Portal, { ...props, children: /* @__PURE__ */ jsx(PortalThemeWrapper, { children }) });
666
+ }
667
+ function TooltipPositioner(props) {
668
+ return /* @__PURE__ */ jsx(Tooltip.Positioner, { ...props });
669
+ }
670
+ function TooltipPopup({
671
+ className,
672
+ children,
673
+ ...props
674
+ }) {
675
+ return /* @__PURE__ */ jsx(
676
+ Tooltip.Popup,
677
+ {
678
+ className: `${popup}${className ? ` ${className}` : ""}`,
679
+ ...props,
680
+ children
681
+ }
682
+ );
683
+ }
684
+ function TooltipContent({
685
+ side = "top",
686
+ sideOffset = 6,
687
+ align = "center",
688
+ className,
689
+ children,
690
+ ...popupProps
691
+ }) {
692
+ return /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx(TooltipPositioner, { side, sideOffset, align, children: /* @__PURE__ */ jsx(TooltipPopup, { className, ...popupProps, children }) }) });
693
+ }
694
+ export {
695
+ ColorPicker,
696
+ Dialog,
697
+ DialogBackdrop,
698
+ DialogClose,
699
+ DialogDescription,
700
+ DialogFooter,
701
+ DialogHeader,
702
+ DialogPopup,
703
+ DialogPortal,
704
+ DialogStackProvider,
705
+ DialogTitle,
706
+ DialogTrigger,
707
+ DropdownMenu,
708
+ DropdownMenuCheckboxItem,
709
+ DropdownMenuContent,
710
+ DropdownMenuGroup,
711
+ DropdownMenuItem,
712
+ DropdownMenuLabel,
713
+ DropdownMenuRadioGroup,
714
+ DropdownMenuRadioItem,
715
+ DropdownMenuSeparator,
716
+ DropdownMenuTrigger,
717
+ Popover,
718
+ PopoverArrow,
719
+ PopoverClose,
720
+ PopoverDescription,
721
+ PopoverPanel,
722
+ PopoverPopup,
723
+ PopoverPortal,
724
+ PopoverPositioner,
725
+ PopoverTitle,
726
+ PopoverTrigger,
727
+ PortalThemeProvider,
728
+ PortalThemeWrapper,
729
+ SegmentedControl,
730
+ TooltipContent,
731
+ TooltipPopup,
732
+ TooltipPortal,
733
+ TooltipPositioner,
734
+ TooltipProvider,
735
+ TooltipRoot,
736
+ TooltipTrigger,
737
+ dismissAllDialogs,
738
+ dismissDialog,
739
+ dismissTopDialog,
740
+ presentDialog,
741
+ usePopover,
742
+ usePortalTheme
743
+ };