@teja-app/ui 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/context.d.ts +9 -0
- package/dist/instrumentation/context.d.ts.map +1 -0
- package/dist/instrumentation/index.cjs +8 -0
- package/dist/instrumentation/index.cjs.map +1 -0
- package/dist/instrumentation/index.d.ts +10 -0
- package/dist/instrumentation/index.d.ts.map +1 -0
- package/dist/instrumentation/index.js +8 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/instrumentation/tracker.d.ts +28 -0
- package/dist/instrumentation/tracker.d.ts.map +1 -0
- package/dist/instrumentation/useInstrumentedClick.d.ts +31 -0
- package/dist/instrumentation/useInstrumentedClick.d.ts.map +1 -0
- package/dist/theme/components/AIComposeButton.d.ts +2 -0
- package/dist/theme/components/AIComposeButton.d.ts.map +1 -1
- package/dist/theme/components/Accordion.d.ts +75 -0
- package/dist/theme/components/Accordion.d.ts.map +1 -0
- package/dist/theme/components/Badge.d.ts +21 -1
- package/dist/theme/components/Badge.d.ts.map +1 -1
- package/dist/theme/components/Button.d.ts +2 -0
- package/dist/theme/components/Button.d.ts.map +1 -1
- package/dist/theme/components/Card.d.ts +37 -2
- package/dist/theme/components/Card.d.ts.map +1 -1
- package/dist/theme/components/DarkScope.d.ts +54 -0
- package/dist/theme/components/DarkScope.d.ts.map +1 -0
- package/dist/theme/components/IconButton.d.ts +2 -0
- package/dist/theme/components/IconButton.d.ts.map +1 -1
- package/dist/theme/components/Menu.d.ts +84 -0
- package/dist/theme/components/Menu.d.ts.map +1 -0
- package/dist/theme/components/SegmentedControl.d.ts.map +1 -1
- package/dist/theme/components/SelectableCard.d.ts +34 -0
- package/dist/theme/components/SelectableCard.d.ts.map +1 -0
- package/dist/theme/components/Toast.d.ts +79 -0
- package/dist/theme/components/Toast.d.ts.map +1 -0
- package/dist/theme/components/ToggleChip.d.ts +38 -0
- package/dist/theme/components/ToggleChip.d.ts.map +1 -0
- package/dist/theme/components/Tooltip.d.ts +40 -0
- package/dist/theme/components/Tooltip.d.ts.map +1 -0
- package/dist/theme/components/index.d.ts +8 -1
- package/dist/theme/components/index.d.ts.map +1 -1
- package/dist/theme/index.cjs +992 -16
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.js +993 -17
- package/dist/theme/index.js.map +1 -1
- package/dist/useInstrumentedClick-B7QAnoBt.js +68 -0
- package/dist/useInstrumentedClick-B7QAnoBt.js.map +1 -0
- package/dist/useInstrumentedClick-COxikkTF.cjs +67 -0
- package/dist/useInstrumentedClick-COxikkTF.cjs.map +1 -0
- package/package.json +6 -1
package/dist/theme/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
+
const instrumentation = require("@teja-app/ui/instrumentation");
|
|
5
6
|
const ReactDOM = require("react-dom");
|
|
6
7
|
function _interopNamespaceDefault(e2) {
|
|
7
8
|
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -658,7 +659,7 @@ const VARIANT_STYLES = {
|
|
|
658
659
|
border: "1px solid transparent"
|
|
659
660
|
}
|
|
660
661
|
};
|
|
661
|
-
const SIZE_DIMS$
|
|
662
|
+
const SIZE_DIMS$2 = {
|
|
662
663
|
sm: { h: 28, pad: "0 10px", fz: 12 },
|
|
663
664
|
md: { h: 32, pad: "0 12px", fz: 13 },
|
|
664
665
|
lg: { h: 38, pad: "0 16px", fz: 14 }
|
|
@@ -674,9 +675,17 @@ const Button$1 = React.forwardRef(function Button2({
|
|
|
674
675
|
type = "button",
|
|
675
676
|
disabled,
|
|
676
677
|
testId,
|
|
678
|
+
telemetryId,
|
|
679
|
+
onClick,
|
|
677
680
|
...rest
|
|
678
681
|
}, ref) {
|
|
679
|
-
const dims = SIZE_DIMS$
|
|
682
|
+
const dims = SIZE_DIMS$2[size2];
|
|
683
|
+
const instrumentedClick = instrumentation.useInstrumentedClick(onClick, {
|
|
684
|
+
telemetryId,
|
|
685
|
+
testId,
|
|
686
|
+
kind: "Button",
|
|
687
|
+
variant
|
|
688
|
+
});
|
|
680
689
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
681
690
|
"button",
|
|
682
691
|
{
|
|
@@ -684,6 +693,7 @@ const Button$1 = React.forwardRef(function Button2({
|
|
|
684
693
|
type,
|
|
685
694
|
disabled,
|
|
686
695
|
"data-testid": testId,
|
|
696
|
+
onClick: instrumentedClick,
|
|
687
697
|
style: {
|
|
688
698
|
height: dims.h,
|
|
689
699
|
padding: dims.pad,
|
|
@@ -740,13 +750,15 @@ function Badge({
|
|
|
740
750
|
tone = "neutral",
|
|
741
751
|
size: size2 = "md",
|
|
742
752
|
dot,
|
|
753
|
+
colors,
|
|
743
754
|
children,
|
|
744
755
|
style,
|
|
745
756
|
testId,
|
|
746
757
|
"data-testid": dataTestId,
|
|
747
758
|
...rest
|
|
748
759
|
}) {
|
|
749
|
-
const
|
|
760
|
+
const base = TONES$1[tone] ?? TONES$1.neutral;
|
|
761
|
+
const t2 = colors ? { bg: colors.bg, fg: colors.fg, dot: colors.dot ?? colors.fg } : base;
|
|
750
762
|
const h2 = size2 === "sm" ? 18 : 22;
|
|
751
763
|
const fz = size2 === "sm" ? 10.5 : 11.5;
|
|
752
764
|
const merged = {
|
|
@@ -783,16 +795,80 @@ function Badge({
|
|
|
783
795
|
children
|
|
784
796
|
] });
|
|
785
797
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
798
|
+
const Card = React.forwardRef(function Card2({
|
|
799
|
+
padding = 20,
|
|
800
|
+
children,
|
|
801
|
+
style,
|
|
802
|
+
testId,
|
|
803
|
+
selected = false,
|
|
804
|
+
interactive,
|
|
805
|
+
onClick,
|
|
806
|
+
onKeyDown,
|
|
807
|
+
...rest
|
|
808
|
+
}, ref) {
|
|
809
|
+
const isInteractive = interactive ?? !!onClick;
|
|
810
|
+
const surfaceStyle = {
|
|
811
|
+
background: selected ? "var(--primary-soft)" : "var(--surface-0)",
|
|
812
|
+
borderRadius: isInteractive ? "var(--r-md)" : "var(--r-lg)",
|
|
813
|
+
border: selected ? "1px solid var(--primary)" : "1px solid var(--border)",
|
|
814
|
+
boxShadow: selected ? "0 0 0 3px var(--primary-ring)" : isInteractive ? "var(--shadow-xs)" : void 0,
|
|
791
815
|
padding,
|
|
816
|
+
cursor: isInteractive ? "pointer" : void 0,
|
|
817
|
+
transition: isInteractive ? "background .12s, box-shadow .12s" : void 0,
|
|
818
|
+
fontFamily: "inherit",
|
|
819
|
+
fontSize: "inherit",
|
|
820
|
+
textAlign: "inherit",
|
|
792
821
|
...style
|
|
793
822
|
};
|
|
794
|
-
|
|
795
|
-
|
|
823
|
+
if (isInteractive) {
|
|
824
|
+
const handleKeyDown = (e2) => {
|
|
825
|
+
if ((e2.key === "Enter" || e2.key === " ") && onClick) {
|
|
826
|
+
e2.preventDefault();
|
|
827
|
+
onClick(
|
|
828
|
+
e2
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
if (onKeyDown) {
|
|
832
|
+
onKeyDown(e2);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
836
|
+
"button",
|
|
837
|
+
{
|
|
838
|
+
ref,
|
|
839
|
+
type: "button",
|
|
840
|
+
"data-testid": testId,
|
|
841
|
+
"data-selected": selected ? "true" : void 0,
|
|
842
|
+
"data-interactive": "true",
|
|
843
|
+
onClick,
|
|
844
|
+
onKeyDown: handleKeyDown,
|
|
845
|
+
style: {
|
|
846
|
+
// Reset default button chrome
|
|
847
|
+
appearance: "none",
|
|
848
|
+
WebkitAppearance: "none",
|
|
849
|
+
display: "block",
|
|
850
|
+
width: "100%",
|
|
851
|
+
...surfaceStyle,
|
|
852
|
+
// Re-apply border after reset (border: 'none' from reset would win)
|
|
853
|
+
border: surfaceStyle.border
|
|
854
|
+
},
|
|
855
|
+
...rest,
|
|
856
|
+
children
|
|
857
|
+
}
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
861
|
+
"div",
|
|
862
|
+
{
|
|
863
|
+
ref,
|
|
864
|
+
"data-testid": testId,
|
|
865
|
+
"data-selected": selected ? "true" : void 0,
|
|
866
|
+
style: surfaceStyle,
|
|
867
|
+
...rest,
|
|
868
|
+
children
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
});
|
|
796
872
|
function TejaMark({ size: size2 = 22, style, testId }) {
|
|
797
873
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
798
874
|
"svg",
|
|
@@ -13311,6 +13387,65 @@ function RoleTile({
|
|
|
13311
13387
|
}
|
|
13312
13388
|
);
|
|
13313
13389
|
}
|
|
13390
|
+
const SelectableCard = React.forwardRef(
|
|
13391
|
+
function SelectableCard2({
|
|
13392
|
+
selected,
|
|
13393
|
+
role = "radio",
|
|
13394
|
+
onSelect,
|
|
13395
|
+
disabled = false,
|
|
13396
|
+
testId,
|
|
13397
|
+
children,
|
|
13398
|
+
style,
|
|
13399
|
+
onClick,
|
|
13400
|
+
...rest
|
|
13401
|
+
}, ref) {
|
|
13402
|
+
const cardStyle = {
|
|
13403
|
+
// Layout
|
|
13404
|
+
display: "block",
|
|
13405
|
+
width: "100%",
|
|
13406
|
+
textAlign: "left",
|
|
13407
|
+
// Spacing — matches RoleTile (padding: 12)
|
|
13408
|
+
padding: 12,
|
|
13409
|
+
// Border — 1.5px primary when selected, border-strong when not
|
|
13410
|
+
border: `1.5px solid ${selected ? "var(--primary)" : "var(--border-strong)"}`,
|
|
13411
|
+
// Background — primary-soft when selected, surface-0 when not
|
|
13412
|
+
background: selected ? "var(--primary-soft)" : "var(--surface-0)",
|
|
13413
|
+
// Shape — matches RoleTile
|
|
13414
|
+
borderRadius: "var(--r-md)",
|
|
13415
|
+
// Shadow — shadow-xs when selected, none when not (matches RoleTile)
|
|
13416
|
+
boxShadow: selected ? "var(--shadow-xs)" : "none",
|
|
13417
|
+
// Typography reset
|
|
13418
|
+
font: "inherit",
|
|
13419
|
+
// Cursor
|
|
13420
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
13421
|
+
// Disabled dimming
|
|
13422
|
+
opacity: disabled ? 0.5 : 1,
|
|
13423
|
+
// Merge caller overrides last
|
|
13424
|
+
...style
|
|
13425
|
+
};
|
|
13426
|
+
function handleClick(e2) {
|
|
13427
|
+
if (!disabled) {
|
|
13428
|
+
onSelect?.();
|
|
13429
|
+
onClick?.(e2);
|
|
13430
|
+
}
|
|
13431
|
+
}
|
|
13432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13433
|
+
"button",
|
|
13434
|
+
{
|
|
13435
|
+
ref,
|
|
13436
|
+
type: "button",
|
|
13437
|
+
role,
|
|
13438
|
+
"aria-checked": selected,
|
|
13439
|
+
"data-testid": testId,
|
|
13440
|
+
disabled,
|
|
13441
|
+
onClick: handleClick,
|
|
13442
|
+
style: cardStyle,
|
|
13443
|
+
...rest,
|
|
13444
|
+
children
|
|
13445
|
+
}
|
|
13446
|
+
);
|
|
13447
|
+
}
|
|
13448
|
+
);
|
|
13314
13449
|
const CELL_COUNT = 6;
|
|
13315
13450
|
const EMPTY_CELLS = Array.from(
|
|
13316
13451
|
{ length: CELL_COUNT },
|
|
@@ -14197,6 +14332,7 @@ function SegmentedControl({
|
|
|
14197
14332
|
role: "tab",
|
|
14198
14333
|
"aria-selected": active,
|
|
14199
14334
|
"data-state": active ? "active" : "inactive",
|
|
14335
|
+
"data-active": active ? "true" : "false",
|
|
14200
14336
|
"data-testid": testId ? `${testId}-${it.value}` : void 0,
|
|
14201
14337
|
onClick: () => onChange?.(it.value),
|
|
14202
14338
|
style: {
|
|
@@ -15426,7 +15562,7 @@ function Drawer$1({
|
|
|
15426
15562
|
testId,
|
|
15427
15563
|
ariaLabel,
|
|
15428
15564
|
style,
|
|
15429
|
-
panelStyle
|
|
15565
|
+
panelStyle: panelStyle2
|
|
15430
15566
|
}) {
|
|
15431
15567
|
const panelRef = React.useRef(null);
|
|
15432
15568
|
const previouslyFocusedRef = React.useRef(null);
|
|
@@ -15528,7 +15664,7 @@ function Drawer$1({
|
|
|
15528
15664
|
display: "flex",
|
|
15529
15665
|
flexDirection: "column",
|
|
15530
15666
|
outline: "none",
|
|
15531
|
-
...
|
|
15667
|
+
...panelStyle2
|
|
15532
15668
|
},
|
|
15533
15669
|
children: [
|
|
15534
15670
|
header,
|
|
@@ -15663,7 +15799,7 @@ function Modal$1({
|
|
|
15663
15799
|
testId,
|
|
15664
15800
|
ariaLabel,
|
|
15665
15801
|
style,
|
|
15666
|
-
panelStyle
|
|
15802
|
+
panelStyle: panelStyle2
|
|
15667
15803
|
}) {
|
|
15668
15804
|
const panelRef = React.useRef(null);
|
|
15669
15805
|
const previouslyFocusedRef = React.useRef(null);
|
|
@@ -15773,7 +15909,7 @@ function Modal$1({
|
|
|
15773
15909
|
boxShadow: "0 24px 64px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.12)",
|
|
15774
15910
|
overflow: "hidden",
|
|
15775
15911
|
outline: "none",
|
|
15776
|
-
...
|
|
15912
|
+
...panelStyle2
|
|
15777
15913
|
},
|
|
15778
15914
|
children: [
|
|
15779
15915
|
header ?? (title || description ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -16397,8 +16533,14 @@ const Switch = React.forwardRef(function Switch2({ on = false, onChange, size: s
|
|
|
16397
16533
|
});
|
|
16398
16534
|
const SIZE_PX$1 = { sm: 22, md: 26, lg: 32 };
|
|
16399
16535
|
const IconButton = React.forwardRef(
|
|
16400
|
-
function IconButton2({ children, size: size2 = "md", tone = "default", style, testId, type = "button", ...rest }, ref) {
|
|
16536
|
+
function IconButton2({ children, size: size2 = "md", tone = "default", style, testId, telemetryId, onClick, type = "button", ...rest }, ref) {
|
|
16401
16537
|
const dim = SIZE_PX$1[size2];
|
|
16538
|
+
const instrumentedClick = instrumentation.useInstrumentedClick(onClick, {
|
|
16539
|
+
telemetryId,
|
|
16540
|
+
testId,
|
|
16541
|
+
kind: "IconButton",
|
|
16542
|
+
variant: tone
|
|
16543
|
+
});
|
|
16402
16544
|
const merged = {
|
|
16403
16545
|
width: dim,
|
|
16404
16546
|
height: dim,
|
|
@@ -16422,6 +16564,7 @@ const IconButton = React.forwardRef(
|
|
|
16422
16564
|
type,
|
|
16423
16565
|
"data-testid": testId,
|
|
16424
16566
|
"data-tone": tone,
|
|
16567
|
+
onClick: instrumentedClick,
|
|
16425
16568
|
style: merged,
|
|
16426
16569
|
...rest,
|
|
16427
16570
|
children
|
|
@@ -16712,6 +16855,79 @@ const Chip = React.forwardRef(function Chip2({ active, count: count2, tone = "pr
|
|
|
16712
16855
|
}
|
|
16713
16856
|
);
|
|
16714
16857
|
});
|
|
16858
|
+
const SIZE_DIMS$1 = {
|
|
16859
|
+
sm: { height: 24, padding: "0 10px", fontSize: 11, gap: 4 },
|
|
16860
|
+
md: { height: 28, padding: "0 12px", fontSize: 12, gap: 6 }
|
|
16861
|
+
};
|
|
16862
|
+
const ToggleChip = React.forwardRef(
|
|
16863
|
+
function ToggleChip2({
|
|
16864
|
+
pressed,
|
|
16865
|
+
onPressedChange,
|
|
16866
|
+
icon,
|
|
16867
|
+
tone = "primary",
|
|
16868
|
+
size: size2 = "md",
|
|
16869
|
+
disabled = false,
|
|
16870
|
+
style,
|
|
16871
|
+
testId,
|
|
16872
|
+
onClick,
|
|
16873
|
+
children,
|
|
16874
|
+
...rest
|
|
16875
|
+
}, ref) {
|
|
16876
|
+
const dims = SIZE_DIMS$1[size2];
|
|
16877
|
+
const pillStyle = {
|
|
16878
|
+
// Geometry — from PillSelector item template
|
|
16879
|
+
display: "inline-flex",
|
|
16880
|
+
alignItems: "center",
|
|
16881
|
+
justifyContent: "center",
|
|
16882
|
+
gap: dims.gap,
|
|
16883
|
+
height: dims.height,
|
|
16884
|
+
padding: dims.padding,
|
|
16885
|
+
fontSize: dims.fontSize,
|
|
16886
|
+
fontWeight: 500,
|
|
16887
|
+
borderRadius: "var(--r-pill)",
|
|
16888
|
+
// Colours — tokens only, never hardcoded
|
|
16889
|
+
border: "1px solid",
|
|
16890
|
+
borderColor: pressed ? `var(--${tone})` : "var(--border)",
|
|
16891
|
+
background: pressed ? `var(--${tone}-soft)` : "var(--surface-0)",
|
|
16892
|
+
color: pressed ? `var(--${tone})` : "var(--ink-2)",
|
|
16893
|
+
// Interaction
|
|
16894
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
16895
|
+
opacity: disabled ? 0.5 : 1,
|
|
16896
|
+
whiteSpace: "nowrap",
|
|
16897
|
+
flexShrink: 0,
|
|
16898
|
+
transition: "background .12s, border-color .12s, color .12s",
|
|
16899
|
+
// Reset button defaults
|
|
16900
|
+
outline: "none",
|
|
16901
|
+
...style
|
|
16902
|
+
};
|
|
16903
|
+
const handleClick = (e2) => {
|
|
16904
|
+
if (disabled) return;
|
|
16905
|
+
onPressedChange?.(!pressed);
|
|
16906
|
+
onClick?.(e2);
|
|
16907
|
+
};
|
|
16908
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
16909
|
+
"button",
|
|
16910
|
+
{
|
|
16911
|
+
ref,
|
|
16912
|
+
type: "button",
|
|
16913
|
+
disabled,
|
|
16914
|
+
"aria-pressed": pressed,
|
|
16915
|
+
"data-state": pressed ? "on" : "off",
|
|
16916
|
+
"data-active": pressed ? "true" : "false",
|
|
16917
|
+
"data-tone": tone,
|
|
16918
|
+
"data-testid": testId,
|
|
16919
|
+
style: pillStyle,
|
|
16920
|
+
onClick: handleClick,
|
|
16921
|
+
...rest,
|
|
16922
|
+
children: [
|
|
16923
|
+
icon != null ? icon : null,
|
|
16924
|
+
children != null ? /* @__PURE__ */ jsxRuntime.jsx("span", { children }) : null
|
|
16925
|
+
]
|
|
16926
|
+
}
|
|
16927
|
+
);
|
|
16928
|
+
}
|
|
16929
|
+
);
|
|
16930
|
+
ToggleChip.displayName = "ToggleChip";
|
|
16715
16931
|
const SIZE_DIMS = {
|
|
16716
16932
|
sm: { height: 24, padding: "0 10px", fontSize: 11, gap: 4, iconSize: 12 },
|
|
16717
16933
|
md: { height: 28, padding: "0 12px", fontSize: 12, gap: 6, iconSize: 14 },
|
|
@@ -17041,8 +17257,14 @@ function AIBadge({
|
|
|
17041
17257
|
] });
|
|
17042
17258
|
}
|
|
17043
17259
|
const AIComposeButton = React.forwardRef(
|
|
17044
|
-
function AIComposeButton2({ size: size2 = "md", children = "Compose with AI", style, testId, type = "button", ...rest }, ref) {
|
|
17260
|
+
function AIComposeButton2({ size: size2 = "md", children = "Compose with AI", style, testId, telemetryId, onClick, type = "button", ...rest }, ref) {
|
|
17045
17261
|
const h2 = size2 === "sm" ? 28 : 32;
|
|
17262
|
+
const instrumentedClick = instrumentation.useInstrumentedClick(onClick, {
|
|
17263
|
+
telemetryId,
|
|
17264
|
+
testId,
|
|
17265
|
+
kind: "AIComposeButton",
|
|
17266
|
+
variant: size2
|
|
17267
|
+
});
|
|
17046
17268
|
const fz = size2 === "sm" ? 12 : 13;
|
|
17047
17269
|
const merged = {
|
|
17048
17270
|
height: h2,
|
|
@@ -17067,6 +17289,7 @@ const AIComposeButton = React.forwardRef(
|
|
|
17067
17289
|
type,
|
|
17068
17290
|
"data-testid": testId,
|
|
17069
17291
|
"data-size": size2,
|
|
17292
|
+
onClick: instrumentedClick,
|
|
17070
17293
|
style: merged,
|
|
17071
17294
|
...rest,
|
|
17072
17295
|
children: [
|
|
@@ -18121,6 +18344,747 @@ function ConfirmDialog({
|
|
|
18121
18344
|
}
|
|
18122
18345
|
);
|
|
18123
18346
|
}
|
|
18347
|
+
function panelStyle(placement, minWidth, zIndex) {
|
|
18348
|
+
const isTop = placement.startsWith("top");
|
|
18349
|
+
const isStart = placement.endsWith("start");
|
|
18350
|
+
return {
|
|
18351
|
+
position: "absolute",
|
|
18352
|
+
// vertical
|
|
18353
|
+
...isTop ? { bottom: "100%", marginBottom: 4 } : { top: "100%", marginTop: 4 },
|
|
18354
|
+
// horizontal
|
|
18355
|
+
...isStart ? { left: 0 } : { right: 0 },
|
|
18356
|
+
zIndex,
|
|
18357
|
+
minWidth,
|
|
18358
|
+
background: "var(--surface-0)",
|
|
18359
|
+
border: "1px solid var(--border)",
|
|
18360
|
+
borderRadius: "var(--r-md)",
|
|
18361
|
+
boxShadow: "var(--shadow-pop)",
|
|
18362
|
+
padding: 4,
|
|
18363
|
+
overflow: "hidden"
|
|
18364
|
+
};
|
|
18365
|
+
}
|
|
18366
|
+
function Menu({
|
|
18367
|
+
open,
|
|
18368
|
+
onClose,
|
|
18369
|
+
trigger,
|
|
18370
|
+
children,
|
|
18371
|
+
placement = "bottom-end",
|
|
18372
|
+
minWidth = 220,
|
|
18373
|
+
zIndex = 200,
|
|
18374
|
+
testId,
|
|
18375
|
+
style
|
|
18376
|
+
}) {
|
|
18377
|
+
const panelRef = React.useRef(null);
|
|
18378
|
+
React.useEffect(() => {
|
|
18379
|
+
if (!open) return;
|
|
18380
|
+
const onKey = (e2) => {
|
|
18381
|
+
if (e2.key === "Escape") {
|
|
18382
|
+
onClose();
|
|
18383
|
+
return;
|
|
18384
|
+
}
|
|
18385
|
+
if (e2.key === "ArrowDown" || e2.key === "ArrowUp") {
|
|
18386
|
+
e2.preventDefault();
|
|
18387
|
+
const panel = panelRef.current;
|
|
18388
|
+
if (!panel) return;
|
|
18389
|
+
const items = Array.from(
|
|
18390
|
+
panel.querySelectorAll('button[role="menuitem"]:not(:disabled)')
|
|
18391
|
+
);
|
|
18392
|
+
if (items.length === 0) return;
|
|
18393
|
+
const focused = items.indexOf(document.activeElement);
|
|
18394
|
+
const next = e2.key === "ArrowDown" ? (focused + 1) % items.length : (focused - 1 + items.length) % items.length;
|
|
18395
|
+
items[next]?.focus();
|
|
18396
|
+
}
|
|
18397
|
+
};
|
|
18398
|
+
window.addEventListener("keydown", onKey);
|
|
18399
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
18400
|
+
}, [open, onClose]);
|
|
18401
|
+
React.useEffect(() => {
|
|
18402
|
+
if (!open) return;
|
|
18403
|
+
const panel = panelRef.current;
|
|
18404
|
+
if (!panel) return;
|
|
18405
|
+
const first = panel.querySelector('button[role="menuitem"]:not(:disabled)');
|
|
18406
|
+
if (first && !panel.contains(document.activeElement)) {
|
|
18407
|
+
first.focus();
|
|
18408
|
+
}
|
|
18409
|
+
}, [open]);
|
|
18410
|
+
const ps = panelStyle(placement, minWidth, zIndex);
|
|
18411
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative", display: "inline-flex" }, children: [
|
|
18412
|
+
trigger,
|
|
18413
|
+
open && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18414
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18415
|
+
"div",
|
|
18416
|
+
{
|
|
18417
|
+
"aria-hidden": "true",
|
|
18418
|
+
onClick: onClose,
|
|
18419
|
+
style: { position: "fixed", inset: 0, zIndex: zIndex - 1 }
|
|
18420
|
+
}
|
|
18421
|
+
),
|
|
18422
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18423
|
+
"div",
|
|
18424
|
+
{
|
|
18425
|
+
ref: panelRef,
|
|
18426
|
+
role: "menu",
|
|
18427
|
+
"aria-label": "menu",
|
|
18428
|
+
"data-testid": testId,
|
|
18429
|
+
onClick: onClose,
|
|
18430
|
+
style: { ...ps, ...style },
|
|
18431
|
+
children
|
|
18432
|
+
}
|
|
18433
|
+
)
|
|
18434
|
+
] })
|
|
18435
|
+
] });
|
|
18436
|
+
}
|
|
18437
|
+
const MenuItem = React.forwardRef(function MenuItem2({ icon, danger = false, children, onClick, disabled, testId, style, ...rest }, ref) {
|
|
18438
|
+
const [hovered, setHovered] = React.useState(false);
|
|
18439
|
+
const handleClick = React.useCallback(
|
|
18440
|
+
(e2) => {
|
|
18441
|
+
onClick?.(e2);
|
|
18442
|
+
},
|
|
18443
|
+
[onClick]
|
|
18444
|
+
);
|
|
18445
|
+
const merged = {
|
|
18446
|
+
display: "flex",
|
|
18447
|
+
alignItems: "center",
|
|
18448
|
+
gap: 8,
|
|
18449
|
+
width: "100%",
|
|
18450
|
+
padding: "8px 10px",
|
|
18451
|
+
border: 0,
|
|
18452
|
+
borderRadius: "var(--r-sm)",
|
|
18453
|
+
background: hovered && !disabled ? "var(--surface-1)" : "transparent",
|
|
18454
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
18455
|
+
fontFamily: "inherit",
|
|
18456
|
+
fontSize: 12.5,
|
|
18457
|
+
color: disabled ? "var(--ink-4)" : danger ? "var(--danger)" : "var(--ink-1)",
|
|
18458
|
+
textAlign: "left",
|
|
18459
|
+
opacity: disabled ? 0.55 : 1,
|
|
18460
|
+
transition: "background .1s",
|
|
18461
|
+
outline: "none",
|
|
18462
|
+
...style
|
|
18463
|
+
};
|
|
18464
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18465
|
+
"button",
|
|
18466
|
+
{
|
|
18467
|
+
ref,
|
|
18468
|
+
role: "menuitem",
|
|
18469
|
+
type: "button",
|
|
18470
|
+
disabled,
|
|
18471
|
+
"data-testid": testId,
|
|
18472
|
+
"data-danger": danger ? "true" : void 0,
|
|
18473
|
+
style: merged,
|
|
18474
|
+
onMouseEnter: () => setHovered(true),
|
|
18475
|
+
onMouseLeave: () => setHovered(false),
|
|
18476
|
+
onClick: handleClick,
|
|
18477
|
+
...rest,
|
|
18478
|
+
children: [
|
|
18479
|
+
icon ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
18480
|
+
Icon,
|
|
18481
|
+
{
|
|
18482
|
+
name: icon,
|
|
18483
|
+
size: 12,
|
|
18484
|
+
color: disabled ? "var(--ink-4)" : danger ? "var(--danger)" : "var(--ink-3)"
|
|
18485
|
+
}
|
|
18486
|
+
) : null,
|
|
18487
|
+
children
|
|
18488
|
+
]
|
|
18489
|
+
}
|
|
18490
|
+
);
|
|
18491
|
+
});
|
|
18492
|
+
function MenuDivider({ style, ...rest }) {
|
|
18493
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18494
|
+
"hr",
|
|
18495
|
+
{
|
|
18496
|
+
role: "separator",
|
|
18497
|
+
style: {
|
|
18498
|
+
border: 0,
|
|
18499
|
+
borderTop: "1px solid var(--divider)",
|
|
18500
|
+
margin: "4px 2px",
|
|
18501
|
+
...style
|
|
18502
|
+
},
|
|
18503
|
+
...rest
|
|
18504
|
+
}
|
|
18505
|
+
);
|
|
18506
|
+
}
|
|
18507
|
+
const GAP = 8;
|
|
18508
|
+
const ARROW_SIZE = 5;
|
|
18509
|
+
function getBubbleStyle(placement) {
|
|
18510
|
+
const base = {
|
|
18511
|
+
position: "absolute",
|
|
18512
|
+
zIndex: "var(--z-tooltip)"
|
|
18513
|
+
};
|
|
18514
|
+
switch (placement) {
|
|
18515
|
+
case "top":
|
|
18516
|
+
return {
|
|
18517
|
+
...base,
|
|
18518
|
+
bottom: `calc(100% + ${GAP}px)`,
|
|
18519
|
+
left: "50%",
|
|
18520
|
+
transform: "translateX(-50%)"
|
|
18521
|
+
};
|
|
18522
|
+
case "bottom":
|
|
18523
|
+
return {
|
|
18524
|
+
...base,
|
|
18525
|
+
top: `calc(100% + ${GAP}px)`,
|
|
18526
|
+
left: "50%",
|
|
18527
|
+
transform: "translateX(-50%)"
|
|
18528
|
+
};
|
|
18529
|
+
case "left":
|
|
18530
|
+
return {
|
|
18531
|
+
...base,
|
|
18532
|
+
right: `calc(100% + ${GAP}px)`,
|
|
18533
|
+
top: "50%",
|
|
18534
|
+
transform: "translateY(-50%)"
|
|
18535
|
+
};
|
|
18536
|
+
case "right":
|
|
18537
|
+
return {
|
|
18538
|
+
...base,
|
|
18539
|
+
left: `calc(100% + ${GAP}px)`,
|
|
18540
|
+
top: "50%",
|
|
18541
|
+
transform: "translateY(-50%)"
|
|
18542
|
+
};
|
|
18543
|
+
}
|
|
18544
|
+
}
|
|
18545
|
+
function getArrowStyle(placement) {
|
|
18546
|
+
const base = {
|
|
18547
|
+
position: "absolute",
|
|
18548
|
+
width: ARROW_SIZE * 2,
|
|
18549
|
+
height: ARROW_SIZE * 2,
|
|
18550
|
+
background: "var(--ink-1)",
|
|
18551
|
+
transform: "rotate(45deg)"
|
|
18552
|
+
};
|
|
18553
|
+
switch (placement) {
|
|
18554
|
+
case "top":
|
|
18555
|
+
return {
|
|
18556
|
+
...base,
|
|
18557
|
+
bottom: -4,
|
|
18558
|
+
left: "50%",
|
|
18559
|
+
marginLeft: -ARROW_SIZE
|
|
18560
|
+
};
|
|
18561
|
+
case "bottom":
|
|
18562
|
+
return {
|
|
18563
|
+
...base,
|
|
18564
|
+
top: -4,
|
|
18565
|
+
left: "50%",
|
|
18566
|
+
marginLeft: -ARROW_SIZE
|
|
18567
|
+
};
|
|
18568
|
+
case "left":
|
|
18569
|
+
return {
|
|
18570
|
+
...base,
|
|
18571
|
+
right: -4,
|
|
18572
|
+
top: "50%",
|
|
18573
|
+
marginTop: -ARROW_SIZE
|
|
18574
|
+
};
|
|
18575
|
+
case "right":
|
|
18576
|
+
return {
|
|
18577
|
+
...base,
|
|
18578
|
+
left: -4,
|
|
18579
|
+
top: "50%",
|
|
18580
|
+
marginTop: -ARROW_SIZE
|
|
18581
|
+
};
|
|
18582
|
+
}
|
|
18583
|
+
}
|
|
18584
|
+
const Tooltip = React.forwardRef(function Tooltip2({
|
|
18585
|
+
label,
|
|
18586
|
+
placement = "top",
|
|
18587
|
+
delay = 400,
|
|
18588
|
+
children,
|
|
18589
|
+
testId,
|
|
18590
|
+
maxWidth = 220,
|
|
18591
|
+
style,
|
|
18592
|
+
...rest
|
|
18593
|
+
}, ref) {
|
|
18594
|
+
const [visible, setVisible] = React.useState(false);
|
|
18595
|
+
const timerRef = React.useRef(null);
|
|
18596
|
+
const tooltipId = React.useId();
|
|
18597
|
+
const show = React.useCallback(() => {
|
|
18598
|
+
timerRef.current = setTimeout(() => setVisible(true), delay);
|
|
18599
|
+
}, [delay]);
|
|
18600
|
+
const hide = React.useCallback(() => {
|
|
18601
|
+
if (timerRef.current !== null) {
|
|
18602
|
+
clearTimeout(timerRef.current);
|
|
18603
|
+
timerRef.current = null;
|
|
18604
|
+
}
|
|
18605
|
+
setVisible(false);
|
|
18606
|
+
}, []);
|
|
18607
|
+
React.useEffect(() => {
|
|
18608
|
+
return () => {
|
|
18609
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
18610
|
+
};
|
|
18611
|
+
}, []);
|
|
18612
|
+
React.useEffect(() => {
|
|
18613
|
+
if (!visible) return;
|
|
18614
|
+
const onKey = (e2) => {
|
|
18615
|
+
if (e2.key === "Escape") hide();
|
|
18616
|
+
};
|
|
18617
|
+
document.addEventListener("keydown", onKey);
|
|
18618
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
18619
|
+
}, [visible, hide]);
|
|
18620
|
+
const wrapperStyle = {
|
|
18621
|
+
position: "relative",
|
|
18622
|
+
display: "inline-flex",
|
|
18623
|
+
alignItems: "center",
|
|
18624
|
+
justifyContent: "center",
|
|
18625
|
+
...style
|
|
18626
|
+
};
|
|
18627
|
+
const bubbleStyle = {
|
|
18628
|
+
...getBubbleStyle(placement),
|
|
18629
|
+
background: "var(--ink-1)",
|
|
18630
|
+
color: "var(--surface-0)",
|
|
18631
|
+
fontSize: 12,
|
|
18632
|
+
fontWeight: 500,
|
|
18633
|
+
lineHeight: 1.4,
|
|
18634
|
+
padding: "6px 8px",
|
|
18635
|
+
borderRadius: "var(--r-sm)",
|
|
18636
|
+
boxShadow: "var(--shadow-pop)",
|
|
18637
|
+
maxWidth,
|
|
18638
|
+
whiteSpace: "nowrap",
|
|
18639
|
+
pointerEvents: "none",
|
|
18640
|
+
// Fade in
|
|
18641
|
+
opacity: visible ? 1 : 0,
|
|
18642
|
+
transition: "opacity 0.12s ease"
|
|
18643
|
+
};
|
|
18644
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18645
|
+
"div",
|
|
18646
|
+
{
|
|
18647
|
+
ref,
|
|
18648
|
+
"data-testid": testId,
|
|
18649
|
+
"data-placement": placement,
|
|
18650
|
+
style: wrapperStyle,
|
|
18651
|
+
onMouseEnter: show,
|
|
18652
|
+
onMouseLeave: hide,
|
|
18653
|
+
onFocusCapture: show,
|
|
18654
|
+
onBlurCapture: hide,
|
|
18655
|
+
...rest,
|
|
18656
|
+
children: [
|
|
18657
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18658
|
+
"span",
|
|
18659
|
+
{
|
|
18660
|
+
"aria-describedby": visible ? tooltipId : void 0,
|
|
18661
|
+
style: { display: "contents" },
|
|
18662
|
+
children
|
|
18663
|
+
}
|
|
18664
|
+
),
|
|
18665
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
18666
|
+
"div",
|
|
18667
|
+
{
|
|
18668
|
+
id: tooltipId,
|
|
18669
|
+
role: "tooltip",
|
|
18670
|
+
"aria-hidden": !visible,
|
|
18671
|
+
style: bubbleStyle,
|
|
18672
|
+
children: [
|
|
18673
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, style: getArrowStyle(placement) }),
|
|
18674
|
+
label
|
|
18675
|
+
]
|
|
18676
|
+
}
|
|
18677
|
+
)
|
|
18678
|
+
]
|
|
18679
|
+
}
|
|
18680
|
+
);
|
|
18681
|
+
});
|
|
18682
|
+
const DarkScope = React.forwardRef(
|
|
18683
|
+
function DarkScope2({ children, style, testId, "data-testid": dataTestId, ...rest }, ref) {
|
|
18684
|
+
const merged = {
|
|
18685
|
+
colorScheme: "dark",
|
|
18686
|
+
...style
|
|
18687
|
+
};
|
|
18688
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18689
|
+
"div",
|
|
18690
|
+
{
|
|
18691
|
+
ref,
|
|
18692
|
+
"data-theme": "dark",
|
|
18693
|
+
"data-testid": dataTestId ?? testId,
|
|
18694
|
+
style: merged,
|
|
18695
|
+
...rest,
|
|
18696
|
+
children
|
|
18697
|
+
}
|
|
18698
|
+
);
|
|
18699
|
+
}
|
|
18700
|
+
);
|
|
18701
|
+
const TONE_SPECS = {
|
|
18702
|
+
success: {
|
|
18703
|
+
accent: "var(--success)",
|
|
18704
|
+
iconBg: "var(--success-soft)",
|
|
18705
|
+
iconColor: "var(--success)",
|
|
18706
|
+
defaultIcon: "check-circle"
|
|
18707
|
+
},
|
|
18708
|
+
danger: {
|
|
18709
|
+
accent: "var(--danger)",
|
|
18710
|
+
iconBg: "var(--danger-soft)",
|
|
18711
|
+
iconColor: "var(--danger)",
|
|
18712
|
+
defaultIcon: "alert-circle"
|
|
18713
|
+
},
|
|
18714
|
+
info: {
|
|
18715
|
+
accent: "var(--primary)",
|
|
18716
|
+
iconBg: "var(--primary-soft)",
|
|
18717
|
+
iconColor: "var(--primary)",
|
|
18718
|
+
defaultIcon: "info"
|
|
18719
|
+
},
|
|
18720
|
+
neutral: {
|
|
18721
|
+
accent: "var(--border)",
|
|
18722
|
+
iconBg: "var(--surface-2)",
|
|
18723
|
+
iconColor: "var(--ink-2)",
|
|
18724
|
+
defaultIcon: "bell"
|
|
18725
|
+
}
|
|
18726
|
+
};
|
|
18727
|
+
const ToastContext = React.createContext(null);
|
|
18728
|
+
let _idCounter = 0;
|
|
18729
|
+
const nextId = () => `toast-${++_idCounter}`;
|
|
18730
|
+
function useToast() {
|
|
18731
|
+
const ctx = React.useContext(ToastContext);
|
|
18732
|
+
if (!ctx) {
|
|
18733
|
+
throw new Error("useToast must be used within a <ToastHost />");
|
|
18734
|
+
}
|
|
18735
|
+
return ctx;
|
|
18736
|
+
}
|
|
18737
|
+
const Toast = React.forwardRef(function Toast2({
|
|
18738
|
+
message: message2,
|
|
18739
|
+
tone = "success",
|
|
18740
|
+
icon,
|
|
18741
|
+
action,
|
|
18742
|
+
onDismiss,
|
|
18743
|
+
style,
|
|
18744
|
+
testId,
|
|
18745
|
+
...rest
|
|
18746
|
+
}, ref) {
|
|
18747
|
+
const t2 = TONE_SPECS[tone];
|
|
18748
|
+
const iconName = icon ?? t2.defaultIcon;
|
|
18749
|
+
const merged = {
|
|
18750
|
+
display: "flex",
|
|
18751
|
+
alignItems: "flex-start",
|
|
18752
|
+
gap: 10,
|
|
18753
|
+
padding: "11px 14px",
|
|
18754
|
+
background: "var(--surface-0)",
|
|
18755
|
+
border: "1px solid var(--border)",
|
|
18756
|
+
borderLeft: `3px solid ${t2.accent}`,
|
|
18757
|
+
borderRadius: "var(--r-md)",
|
|
18758
|
+
boxShadow: "var(--shadow-pop)",
|
|
18759
|
+
maxWidth: 320,
|
|
18760
|
+
width: 320,
|
|
18761
|
+
pointerEvents: "auto",
|
|
18762
|
+
...style
|
|
18763
|
+
};
|
|
18764
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, "data-testid": testId, "data-tone": tone, style: merged, ...rest, children: [
|
|
18765
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18766
|
+
"span",
|
|
18767
|
+
{
|
|
18768
|
+
"aria-hidden": true,
|
|
18769
|
+
style: {
|
|
18770
|
+
width: 26,
|
|
18771
|
+
height: 26,
|
|
18772
|
+
borderRadius: 999,
|
|
18773
|
+
flexShrink: 0,
|
|
18774
|
+
background: t2.iconBg,
|
|
18775
|
+
display: "inline-flex",
|
|
18776
|
+
alignItems: "center",
|
|
18777
|
+
justifyContent: "center"
|
|
18778
|
+
},
|
|
18779
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: iconName, size: 12, color: t2.iconColor })
|
|
18780
|
+
}
|
|
18781
|
+
),
|
|
18782
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0, alignSelf: "center" }, children: [
|
|
18783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18784
|
+
"div",
|
|
18785
|
+
{
|
|
18786
|
+
style: {
|
|
18787
|
+
fontSize: 12.5,
|
|
18788
|
+
fontWeight: 600,
|
|
18789
|
+
color: "var(--ink-1)",
|
|
18790
|
+
lineHeight: 1.4
|
|
18791
|
+
},
|
|
18792
|
+
children: message2
|
|
18793
|
+
}
|
|
18794
|
+
),
|
|
18795
|
+
action ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
18796
|
+
"button",
|
|
18797
|
+
{
|
|
18798
|
+
type: "button",
|
|
18799
|
+
onClick: () => {
|
|
18800
|
+
action.onClick();
|
|
18801
|
+
onDismiss?.();
|
|
18802
|
+
},
|
|
18803
|
+
style: {
|
|
18804
|
+
marginTop: 4,
|
|
18805
|
+
fontSize: 11.5,
|
|
18806
|
+
fontWeight: 500,
|
|
18807
|
+
color: "var(--primary)",
|
|
18808
|
+
background: "none",
|
|
18809
|
+
border: 0,
|
|
18810
|
+
padding: 0,
|
|
18811
|
+
cursor: "pointer",
|
|
18812
|
+
lineHeight: 1
|
|
18813
|
+
},
|
|
18814
|
+
children: action.label
|
|
18815
|
+
}
|
|
18816
|
+
) : null
|
|
18817
|
+
] }),
|
|
18818
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18819
|
+
"button",
|
|
18820
|
+
{
|
|
18821
|
+
type: "button",
|
|
18822
|
+
"aria-label": "Dismiss",
|
|
18823
|
+
onClick: onDismiss,
|
|
18824
|
+
style: {
|
|
18825
|
+
background: "none",
|
|
18826
|
+
border: 0,
|
|
18827
|
+
padding: 2,
|
|
18828
|
+
cursor: "pointer",
|
|
18829
|
+
color: "var(--ink-3)",
|
|
18830
|
+
display: "inline-flex",
|
|
18831
|
+
alignItems: "center",
|
|
18832
|
+
flexShrink: 0,
|
|
18833
|
+
borderRadius: "var(--r-sm)"
|
|
18834
|
+
},
|
|
18835
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "x", size: 12 })
|
|
18836
|
+
}
|
|
18837
|
+
)
|
|
18838
|
+
] });
|
|
18839
|
+
});
|
|
18840
|
+
function ToastEntry({ item, onRemove }) {
|
|
18841
|
+
const [visible, setVisible] = React.useState(false);
|
|
18842
|
+
const timerRef = React.useRef(null);
|
|
18843
|
+
React.useEffect(() => {
|
|
18844
|
+
const raf = requestAnimationFrame(() => setVisible(true));
|
|
18845
|
+
return () => cancelAnimationFrame(raf);
|
|
18846
|
+
}, []);
|
|
18847
|
+
React.useEffect(() => {
|
|
18848
|
+
timerRef.current = setTimeout(() => {
|
|
18849
|
+
setVisible(false);
|
|
18850
|
+
setTimeout(() => {
|
|
18851
|
+
onRemove(item.id);
|
|
18852
|
+
item.then?.();
|
|
18853
|
+
}, 220);
|
|
18854
|
+
}, item.ms);
|
|
18855
|
+
return () => {
|
|
18856
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
18857
|
+
};
|
|
18858
|
+
}, [item, onRemove]);
|
|
18859
|
+
const handleDismiss = React.useCallback(() => {
|
|
18860
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
18861
|
+
setVisible(false);
|
|
18862
|
+
setTimeout(() => {
|
|
18863
|
+
onRemove(item.id);
|
|
18864
|
+
item.then?.();
|
|
18865
|
+
}, 220);
|
|
18866
|
+
}, [item, onRemove]);
|
|
18867
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18868
|
+
"div",
|
|
18869
|
+
{
|
|
18870
|
+
style: {
|
|
18871
|
+
transition: "opacity 0.2s ease, transform 0.2s ease",
|
|
18872
|
+
opacity: visible ? 1 : 0,
|
|
18873
|
+
transform: visible ? "translateX(0)" : "translateX(24px)"
|
|
18874
|
+
},
|
|
18875
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18876
|
+
Toast,
|
|
18877
|
+
{
|
|
18878
|
+
message: item.message,
|
|
18879
|
+
tone: item.tone,
|
|
18880
|
+
icon: item.icon,
|
|
18881
|
+
action: item.action,
|
|
18882
|
+
onDismiss: handleDismiss,
|
|
18883
|
+
testId: `toast-${item.id}`
|
|
18884
|
+
}
|
|
18885
|
+
)
|
|
18886
|
+
}
|
|
18887
|
+
);
|
|
18888
|
+
}
|
|
18889
|
+
function ToastHost({ children, container }) {
|
|
18890
|
+
const [items, setItems] = React.useState([]);
|
|
18891
|
+
const showToast = React.useCallback((message2, opts = {}) => {
|
|
18892
|
+
const tone = opts.tone ?? "success";
|
|
18893
|
+
const t2 = TONE_SPECS[tone];
|
|
18894
|
+
const item = {
|
|
18895
|
+
id: nextId(),
|
|
18896
|
+
message: message2,
|
|
18897
|
+
tone,
|
|
18898
|
+
icon: opts.icon ?? t2.defaultIcon,
|
|
18899
|
+
ms: opts.ms ?? 2500,
|
|
18900
|
+
action: opts.action,
|
|
18901
|
+
then: opts.then
|
|
18902
|
+
};
|
|
18903
|
+
setItems((prev) => [...prev, item]);
|
|
18904
|
+
}, []);
|
|
18905
|
+
const removeItem = React.useCallback((id) => {
|
|
18906
|
+
setItems((prev) => prev.filter((i2) => i2.id !== id));
|
|
18907
|
+
}, []);
|
|
18908
|
+
const hostStyle = {
|
|
18909
|
+
position: "fixed",
|
|
18910
|
+
top: 80,
|
|
18911
|
+
right: 20,
|
|
18912
|
+
zIndex: 200,
|
|
18913
|
+
display: "flex",
|
|
18914
|
+
flexDirection: "column",
|
|
18915
|
+
gap: 8,
|
|
18916
|
+
pointerEvents: "none"
|
|
18917
|
+
// Ensure toasts stack above most content
|
|
18918
|
+
};
|
|
18919
|
+
const portal = ReactDOM.createPortal(
|
|
18920
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18921
|
+
"div",
|
|
18922
|
+
{
|
|
18923
|
+
role: "region",
|
|
18924
|
+
"aria-live": "polite",
|
|
18925
|
+
"aria-label": "Notifications",
|
|
18926
|
+
style: hostStyle,
|
|
18927
|
+
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(ToastEntry, { item, onRemove: removeItem }, item.id))
|
|
18928
|
+
}
|
|
18929
|
+
),
|
|
18930
|
+
container ?? document.body
|
|
18931
|
+
);
|
|
18932
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ToastContext.Provider, { value: { showToast }, children: [
|
|
18933
|
+
children,
|
|
18934
|
+
portal
|
|
18935
|
+
] });
|
|
18936
|
+
}
|
|
18937
|
+
const AccordionContext = React.createContext(null);
|
|
18938
|
+
function useAccordionCtx() {
|
|
18939
|
+
const ctx = React.useContext(AccordionContext);
|
|
18940
|
+
if (!ctx) {
|
|
18941
|
+
throw new Error("AccordionItem must be rendered inside an Accordion.");
|
|
18942
|
+
}
|
|
18943
|
+
return ctx;
|
|
18944
|
+
}
|
|
18945
|
+
function Accordion({
|
|
18946
|
+
multiple = false,
|
|
18947
|
+
defaultValue,
|
|
18948
|
+
value: controlledValue,
|
|
18949
|
+
onChange,
|
|
18950
|
+
children,
|
|
18951
|
+
style,
|
|
18952
|
+
testId
|
|
18953
|
+
}) {
|
|
18954
|
+
const [internalOpen, setInternalOpen] = React.useState(() => {
|
|
18955
|
+
if (defaultValue === void 0) return /* @__PURE__ */ new Set();
|
|
18956
|
+
return new Set(Array.isArray(defaultValue) ? defaultValue : [defaultValue]);
|
|
18957
|
+
});
|
|
18958
|
+
const isControlled = controlledValue !== void 0;
|
|
18959
|
+
const openSet = React.useMemo(
|
|
18960
|
+
() => isControlled ? new Set(Array.isArray(controlledValue) ? controlledValue : [controlledValue]) : internalOpen,
|
|
18961
|
+
[isControlled, controlledValue, internalOpen]
|
|
18962
|
+
);
|
|
18963
|
+
const isOpen = React.useCallback((v2) => openSet.has(v2), [openSet]);
|
|
18964
|
+
const toggle = React.useCallback(
|
|
18965
|
+
(v2) => {
|
|
18966
|
+
let next;
|
|
18967
|
+
if (openSet.has(v2)) {
|
|
18968
|
+
next = new Set([...openSet].filter((x2) => x2 !== v2));
|
|
18969
|
+
} else if (multiple) {
|
|
18970
|
+
next = /* @__PURE__ */ new Set([...openSet, v2]);
|
|
18971
|
+
} else {
|
|
18972
|
+
next = /* @__PURE__ */ new Set([v2]);
|
|
18973
|
+
}
|
|
18974
|
+
if (!isControlled) {
|
|
18975
|
+
setInternalOpen(next);
|
|
18976
|
+
}
|
|
18977
|
+
if (onChange) {
|
|
18978
|
+
const arr = [...next];
|
|
18979
|
+
onChange(multiple ? arr : arr[0] ?? "");
|
|
18980
|
+
}
|
|
18981
|
+
},
|
|
18982
|
+
[openSet, multiple, isControlled, onChange]
|
|
18983
|
+
);
|
|
18984
|
+
const ctx = { isOpen, toggle };
|
|
18985
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18986
|
+
"div",
|
|
18987
|
+
{
|
|
18988
|
+
"data-testid": testId,
|
|
18989
|
+
style: {
|
|
18990
|
+
display: "flex",
|
|
18991
|
+
flexDirection: "column",
|
|
18992
|
+
gap: 0,
|
|
18993
|
+
...style
|
|
18994
|
+
},
|
|
18995
|
+
children
|
|
18996
|
+
}
|
|
18997
|
+
) });
|
|
18998
|
+
}
|
|
18999
|
+
const AccordionItem = React.forwardRef(
|
|
19000
|
+
function AccordionItem2({ value, title, children, testId, style, ...rest }, ref) {
|
|
19001
|
+
const { isOpen, toggle } = useAccordionCtx();
|
|
19002
|
+
const open = isOpen(value);
|
|
19003
|
+
const uid = React.useId();
|
|
19004
|
+
const headerId = `accordion-header-${uid}`;
|
|
19005
|
+
const panelId = `accordion-panel-${uid}`;
|
|
19006
|
+
const [hovered, setHovered] = React.useState(false);
|
|
19007
|
+
const headerStyle = {
|
|
19008
|
+
display: "flex",
|
|
19009
|
+
alignItems: "center",
|
|
19010
|
+
justifyContent: "space-between",
|
|
19011
|
+
width: "100%",
|
|
19012
|
+
padding: "10px 12px",
|
|
19013
|
+
border: 0,
|
|
19014
|
+
borderRadius: "var(--r-md)",
|
|
19015
|
+
background: hovered ? "var(--surface-1)" : "transparent",
|
|
19016
|
+
cursor: "pointer",
|
|
19017
|
+
fontFamily: "inherit",
|
|
19018
|
+
textAlign: "left",
|
|
19019
|
+
transition: "background .1s",
|
|
19020
|
+
outline: "none"
|
|
19021
|
+
};
|
|
19022
|
+
const titleStyle = {
|
|
19023
|
+
fontSize: 13,
|
|
19024
|
+
fontWeight: 600,
|
|
19025
|
+
color: "var(--ink-1)",
|
|
19026
|
+
flex: 1,
|
|
19027
|
+
minWidth: 0
|
|
19028
|
+
};
|
|
19029
|
+
const chevronStyle = {
|
|
19030
|
+
flexShrink: 0,
|
|
19031
|
+
display: "inline-flex",
|
|
19032
|
+
alignItems: "center",
|
|
19033
|
+
justifyContent: "center",
|
|
19034
|
+
transform: open ? "rotate(180deg)" : "rotate(0deg)",
|
|
19035
|
+
transition: "transform .15s"
|
|
19036
|
+
};
|
|
19037
|
+
const panelStyle2 = {
|
|
19038
|
+
paddingTop: 8
|
|
19039
|
+
};
|
|
19040
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...style }, children: [
|
|
19041
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
19042
|
+
"button",
|
|
19043
|
+
{
|
|
19044
|
+
ref,
|
|
19045
|
+
id: headerId,
|
|
19046
|
+
type: "button",
|
|
19047
|
+
"aria-expanded": open,
|
|
19048
|
+
"aria-controls": panelId,
|
|
19049
|
+
"data-testid": testId ? `${testId}-header` : void 0,
|
|
19050
|
+
onClick: () => toggle(value),
|
|
19051
|
+
onMouseEnter: () => setHovered(true),
|
|
19052
|
+
onMouseLeave: () => setHovered(false),
|
|
19053
|
+
style: headerStyle,
|
|
19054
|
+
...rest,
|
|
19055
|
+
children: [
|
|
19056
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: titleStyle, children: title }),
|
|
19057
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, style: chevronStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
19058
|
+
"svg",
|
|
19059
|
+
{
|
|
19060
|
+
width: 11,
|
|
19061
|
+
height: 11,
|
|
19062
|
+
viewBox: "0 0 16 16",
|
|
19063
|
+
fill: "none",
|
|
19064
|
+
stroke: "var(--ink-3)",
|
|
19065
|
+
strokeWidth: 1.5,
|
|
19066
|
+
strokeLinecap: "round",
|
|
19067
|
+
strokeLinejoin: "round",
|
|
19068
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 6l4 4 4-4" })
|
|
19069
|
+
}
|
|
19070
|
+
) })
|
|
19071
|
+
]
|
|
19072
|
+
}
|
|
19073
|
+
),
|
|
19074
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
19075
|
+
"div",
|
|
19076
|
+
{
|
|
19077
|
+
id: panelId,
|
|
19078
|
+
role: "region",
|
|
19079
|
+
"aria-labelledby": headerId,
|
|
19080
|
+
"data-testid": testId ? `${testId}-panel` : void 0,
|
|
19081
|
+
style: panelStyle2,
|
|
19082
|
+
children
|
|
19083
|
+
}
|
|
19084
|
+
)
|
|
19085
|
+
] });
|
|
19086
|
+
}
|
|
19087
|
+
);
|
|
18124
19088
|
exports.AIBadge = AIBadge;
|
|
18125
19089
|
exports.AICard = AICard;
|
|
18126
19090
|
exports.AIChip = AIChip;
|
|
@@ -18130,6 +19094,8 @@ exports.AISectionHeader = AISectionHeader;
|
|
|
18130
19094
|
exports.AISparkle = AISparkle;
|
|
18131
19095
|
exports.AIWorking = AIWorking;
|
|
18132
19096
|
exports.AI_OPTIONS = AI_OPTIONS;
|
|
19097
|
+
exports.Accordion = Accordion;
|
|
19098
|
+
exports.AccordionItem = AccordionItem;
|
|
18133
19099
|
exports.Alert = Alert;
|
|
18134
19100
|
exports.AppShell = AppShell;
|
|
18135
19101
|
exports.AskTeja = AskTeja;
|
|
@@ -18148,6 +19114,7 @@ exports.CountryPicker = CountryPicker;
|
|
|
18148
19114
|
exports.DEFAULT_LANG_OPTIONS = DEFAULT_LANG_OPTIONS;
|
|
18149
19115
|
exports.DENSITY_OPTIONS = DENSITY_OPTIONS;
|
|
18150
19116
|
exports.DISPLAY_OPTIONS = DISPLAY_OPTIONS;
|
|
19117
|
+
exports.DarkScope = DarkScope;
|
|
18151
19118
|
exports.DateInput = DateInput;
|
|
18152
19119
|
exports.Divider = Divider;
|
|
18153
19120
|
exports.Drawer = Drawer;
|
|
@@ -18166,6 +19133,9 @@ exports.IconButton = IconButton;
|
|
|
18166
19133
|
exports.KV = KV;
|
|
18167
19134
|
exports.LabelGroup = LabelGroup;
|
|
18168
19135
|
exports.LangSwitcher = LangSwitcher;
|
|
19136
|
+
exports.Menu = Menu;
|
|
19137
|
+
exports.MenuDivider = MenuDivider;
|
|
19138
|
+
exports.MenuItem = MenuItem;
|
|
18169
19139
|
exports.MiniStat = MiniStat;
|
|
18170
19140
|
exports.Modal = Modal;
|
|
18171
19141
|
exports.ModalFooter = ModalFooter;
|
|
@@ -18188,6 +19158,7 @@ exports.SURFACE_OPTIONS = SURFACE_OPTIONS;
|
|
|
18188
19158
|
exports.SectionLabel = SectionLabel;
|
|
18189
19159
|
exports.SegmentedControl = SegmentedControl;
|
|
18190
19160
|
exports.Select = Select$1;
|
|
19161
|
+
exports.SelectableCard = SelectableCard;
|
|
18191
19162
|
exports.SettingRow = SettingRow;
|
|
18192
19163
|
exports.Sidebar = Sidebar;
|
|
18193
19164
|
exports.SidebarNav = SidebarNav;
|
|
@@ -18221,7 +19192,11 @@ exports.Textarea = Textarea;
|
|
|
18221
19192
|
exports.ThemeProvider = ThemeProvider;
|
|
18222
19193
|
exports.TimeZonePicker = TimeZonePicker;
|
|
18223
19194
|
exports.TimelineRow = TimelineRow;
|
|
19195
|
+
exports.Toast = Toast;
|
|
19196
|
+
exports.ToastHost = ToastHost;
|
|
19197
|
+
exports.ToggleChip = ToggleChip;
|
|
18224
19198
|
exports.ToolbarSearch = ToolbarSearch;
|
|
19199
|
+
exports.Tooltip = Tooltip;
|
|
18225
19200
|
exports.TopBar = TopBar;
|
|
18226
19201
|
exports.US_STATES = US_STATES;
|
|
18227
19202
|
exports.ViewToggle = ViewToggle;
|
|
@@ -18240,4 +19215,5 @@ exports.parseDate = parseDate;
|
|
|
18240
19215
|
exports.resolveThemeMode = resolveThemeMode;
|
|
18241
19216
|
exports.shouldShowSidebarNavItem = shouldShowNavItem;
|
|
18242
19217
|
exports.useTheme = useTheme;
|
|
19218
|
+
exports.useToast = useToast;
|
|
18243
19219
|
//# sourceMappingURL=index.cjs.map
|