@designa8/vibedesign-inkwire-ds-v1-176b 0.1.1 → 0.1.2
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/README.md +1 -1
- package/dist/index.cjs +72 -36
- package/dist/index.js +72 -36
- package/dist/styles.css +18 -3
- package/package.json +1 -1
- package/src/molecules/Combobox/Combobox.tsx +4 -2
- package/src/molecules/Dropdown/Dropdown.tsx +72 -10
- package/src/molecules/Dropdown/preview.tsx +65 -0
- package/src/molecules/Toast/Toast.tsx +27 -23
- package/src/molecules/Toast/preview.tsx +90 -41
- package/src/organisms/Accordion/Accordion.tsx +23 -16
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-inkwire-ds-v1-176b
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.1.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.1.2**.
|
|
4
4
|
Tokens, atoms, molecules, organisms, and templates — import from the package root;
|
|
5
5
|
never hardcode visual values in consumer code.
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -3083,8 +3083,8 @@ var Combobox = React32.forwardRef(
|
|
|
3083
3083
|
}
|
|
3084
3084
|
),
|
|
3085
3085
|
children: [
|
|
3086
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "
|
|
3087
|
-
opt.description ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "
|
|
3086
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "min-w-0 shrink-0 max-w-[60%] truncate text-ink", children: opt.label }),
|
|
3087
|
+
opt.description ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "min-w-0 flex-1 truncate text-right text-body-sm text-muted", children: opt.description }) : null
|
|
3088
3088
|
]
|
|
3089
3089
|
},
|
|
3090
3090
|
opt.value
|
|
@@ -3371,6 +3371,11 @@ var toneClass5 = {
|
|
|
3371
3371
|
warning: "text-semantic-warning",
|
|
3372
3372
|
error: "text-semantic-error"
|
|
3373
3373
|
};
|
|
3374
|
+
var PANEL_GAP = 4;
|
|
3375
|
+
var VIEWPORT_MARGIN = 8;
|
|
3376
|
+
var ROW_HEIGHT = { sm: 28, md: 32, lg: 36 };
|
|
3377
|
+
var PANEL_PADDING_Y = 8;
|
|
3378
|
+
var estimatePanelHeight = (count, size) => count * (ROW_HEIGHT[size] ?? 32) + PANEL_PADDING_Y;
|
|
3374
3379
|
var Dropdown = React34.forwardRef(
|
|
3375
3380
|
({
|
|
3376
3381
|
options,
|
|
@@ -3396,7 +3401,7 @@ var Dropdown = React34.forwardRef(
|
|
|
3396
3401
|
const [innerValue, setInnerValue] = React34.useState(defaultValue);
|
|
3397
3402
|
const [innerOpen, setInnerOpen] = React34.useState(false);
|
|
3398
3403
|
const [active, setActive] = React34.useState(-1);
|
|
3399
|
-
const [
|
|
3404
|
+
const [placement, setPlacement] = React34.useState(null);
|
|
3400
3405
|
const [mounted, setMounted] = React34.useState(false);
|
|
3401
3406
|
const value = valueProp !== void 0 ? valueProp : innerValue;
|
|
3402
3407
|
const open = openProp ?? innerOpen;
|
|
@@ -3408,9 +3413,28 @@ var Dropdown = React34.forwardRef(
|
|
|
3408
3413
|
else if (ref) ref.current = node;
|
|
3409
3414
|
};
|
|
3410
3415
|
const place = React34.useCallback(() => {
|
|
3411
|
-
const
|
|
3412
|
-
if (
|
|
3413
|
-
|
|
3416
|
+
const el = triggerRef.current;
|
|
3417
|
+
if (!el) return;
|
|
3418
|
+
const box2 = el.getBoundingClientRect();
|
|
3419
|
+
const viewportW = window.innerWidth;
|
|
3420
|
+
const viewportH = window.innerHeight;
|
|
3421
|
+
const margin = VIEWPORT_MARGIN;
|
|
3422
|
+
const gap = PANEL_GAP;
|
|
3423
|
+
const panel2 = panelRef.current;
|
|
3424
|
+
const measuredHeight = panel2?.offsetHeight ?? 0;
|
|
3425
|
+
const measuredWidth = panel2?.offsetWidth ?? 0;
|
|
3426
|
+
const panelHeight = measuredHeight > 0 ? measuredHeight : estimatePanelHeight(options.length, size);
|
|
3427
|
+
const spaceBelow = viewportH - box2.bottom - gap - margin;
|
|
3428
|
+
const spaceAbove = box2.top - gap - margin;
|
|
3429
|
+
const openUp = spaceBelow < panelHeight && spaceAbove > spaceBelow;
|
|
3430
|
+
const available = Math.max(0, Math.min(panelHeight, openUp ? spaceAbove : spaceBelow));
|
|
3431
|
+
let top = openUp ? box2.top - gap - panelHeight : box2.bottom + gap;
|
|
3432
|
+
top = Math.min(Math.max(margin, top), Math.max(margin, viewportH - margin - available));
|
|
3433
|
+
const panelWidth = Math.max(measuredWidth, box2.width);
|
|
3434
|
+
const width = Math.min(panelWidth, viewportW - margin * 2);
|
|
3435
|
+
const left = Math.max(margin, Math.min(box2.left, viewportW - width - margin));
|
|
3436
|
+
setPlacement({ top, left, minWidth: box2.width, maxHeight: available });
|
|
3437
|
+
}, [options.length, size]);
|
|
3414
3438
|
const setOpen = (next) => {
|
|
3415
3439
|
if (next) place();
|
|
3416
3440
|
if (openProp === void 0) setInnerOpen(next);
|
|
@@ -3427,6 +3451,12 @@ var Dropdown = React34.forwardRef(
|
|
|
3427
3451
|
setOpen(false);
|
|
3428
3452
|
triggerRef.current?.focus();
|
|
3429
3453
|
};
|
|
3454
|
+
React34.useLayoutEffect(() => {
|
|
3455
|
+
if (!open) return;
|
|
3456
|
+
place();
|
|
3457
|
+
const frame = window.requestAnimationFrame(() => place());
|
|
3458
|
+
return () => window.cancelAnimationFrame(frame);
|
|
3459
|
+
}, [open, place]);
|
|
3430
3460
|
React34.useEffect(() => {
|
|
3431
3461
|
if (!open) return;
|
|
3432
3462
|
place();
|
|
@@ -3482,9 +3512,13 @@ var Dropdown = React34.forwardRef(
|
|
|
3482
3512
|
"data-state": open ? "open" : "closed",
|
|
3483
3513
|
style: {
|
|
3484
3514
|
position: "fixed",
|
|
3485
|
-
top:
|
|
3486
|
-
left:
|
|
3487
|
-
|
|
3515
|
+
top: placement?.top ?? 0,
|
|
3516
|
+
left: placement?.left ?? 0,
|
|
3517
|
+
minWidth: placement?.minWidth,
|
|
3518
|
+
width: "max-content",
|
|
3519
|
+
maxWidth: `calc(100vw - ${VIEWPORT_MARGIN * 2}px)`,
|
|
3520
|
+
maxHeight: placement?.maxHeight,
|
|
3521
|
+
overflowY: "auto",
|
|
3488
3522
|
zIndex: "var(--z-popover, 1300)"
|
|
3489
3523
|
},
|
|
3490
3524
|
className: "origin-top rounded-md border border-hairline bg-surface p-xs text-ink shadow-overlay transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:-translate-y-1 data-[state=closed]:opacity-0",
|
|
@@ -3508,13 +3542,13 @@ var Dropdown = React34.forwardRef(
|
|
|
3508
3542
|
"span",
|
|
3509
3543
|
{
|
|
3510
3544
|
className: cn32(
|
|
3511
|
-
"inline-flex h-4 w-4 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
3545
|
+
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
3512
3546
|
isSelected ? "scale-100 opacity-100" : "scale-75 opacity-0"
|
|
3513
3547
|
),
|
|
3514
3548
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Icon, { name: "check", size: 10, strokeWidth: 3 })
|
|
3515
3549
|
}
|
|
3516
3550
|
),
|
|
3517
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "flex-1
|
|
3551
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "flex-1 whitespace-nowrap text-ink", children: opt.label })
|
|
3518
3552
|
},
|
|
3519
3553
|
opt.value
|
|
3520
3554
|
);
|
|
@@ -4626,7 +4660,7 @@ var Toast = React46.forwardRef(
|
|
|
4626
4660
|
},
|
|
4627
4661
|
style: { zIndex: "var(--z-toast, 1400)", ...style },
|
|
4628
4662
|
className: cn44(
|
|
4629
|
-
"relative flex w-full items-
|
|
4663
|
+
"relative flex w-full items-start gap-md rounded-lg border border-hairline-strong bg-surface py-sm pl-base pr-sm text-ink shadow-overlay",
|
|
4630
4664
|
"transition duration-200 ease-out",
|
|
4631
4665
|
"data-[state=open]:translate-y-0 data-[state=open]:opacity-100",
|
|
4632
4666
|
"data-[state=closed]:pointer-events-none data-[state=closed]:translate-y-2 data-[state=closed]:opacity-0",
|
|
@@ -4652,30 +4686,32 @@ var Toast = React46.forwardRef(
|
|
|
4652
4686
|
)
|
|
4653
4687
|
}
|
|
4654
4688
|
) : null,
|
|
4655
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "min-w-0 flex-1
|
|
4656
|
-
|
|
4657
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.
|
|
4689
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "min-w-0 flex-1 break-words line-clamp-2 text-label-md text-ink", children: title }),
|
|
4690
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("span", { className: "flex shrink-0 items-center gap-md", children: [
|
|
4691
|
+
actionLabel ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
4692
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Divider, { orientation: "vertical", tone: "strong", className: "my-xs" }),
|
|
4693
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4694
|
+
Button,
|
|
4695
|
+
{
|
|
4696
|
+
variant: "ghost",
|
|
4697
|
+
size: "sm",
|
|
4698
|
+
onClick: onAction,
|
|
4699
|
+
className: "text-link-blue! hover:text-link-blue!",
|
|
4700
|
+
children: actionLabel
|
|
4701
|
+
}
|
|
4702
|
+
)
|
|
4703
|
+
] }) : null,
|
|
4658
4704
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4659
|
-
|
|
4705
|
+
IconButton,
|
|
4660
4706
|
{
|
|
4707
|
+
icon: "x",
|
|
4661
4708
|
variant: "ghost",
|
|
4662
4709
|
size: "sm",
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
children: actionLabel
|
|
4710
|
+
"aria-label": "Close notification",
|
|
4711
|
+
onClick: () => onOpenChange?.(false)
|
|
4666
4712
|
}
|
|
4667
4713
|
)
|
|
4668
|
-
] })
|
|
4669
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4670
|
-
IconButton,
|
|
4671
|
-
{
|
|
4672
|
-
icon: "x",
|
|
4673
|
-
variant: "ghost",
|
|
4674
|
-
size: "sm",
|
|
4675
|
-
"aria-label": "Close notification",
|
|
4676
|
-
onClick: () => onOpenChange?.(false)
|
|
4677
|
-
}
|
|
4678
|
-
)
|
|
4714
|
+
] })
|
|
4679
4715
|
]
|
|
4680
4716
|
}
|
|
4681
4717
|
);
|
|
@@ -4785,28 +4821,28 @@ var Accordion = React47.forwardRef(
|
|
|
4785
4821
|
item.icon ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Icon, { name: item.icon, size: 18, className: "shrink-0 text-body" }) : null,
|
|
4786
4822
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "min-w-0 flex-1 truncate text-label-md text-ink", children: item.title }),
|
|
4787
4823
|
item.meta ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "min-w-0 shrink-0 truncate text-body-sm text-muted", children: item.meta }) : null,
|
|
4788
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "inline-flex shrink-0 items-center md:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4789
4825
|
Icon,
|
|
4790
4826
|
{
|
|
4791
4827
|
name: "chevron-right",
|
|
4792
4828
|
size: 18,
|
|
4793
4829
|
className: cn45(
|
|
4794
|
-
"
|
|
4830
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
4795
4831
|
isOpen && "rotate-90"
|
|
4796
4832
|
)
|
|
4797
4833
|
}
|
|
4798
|
-
),
|
|
4799
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4834
|
+
) }),
|
|
4835
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hidden shrink-0 items-center md:inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
4800
4836
|
Icon,
|
|
4801
4837
|
{
|
|
4802
4838
|
name: "chevron-down",
|
|
4803
4839
|
size: 16,
|
|
4804
4840
|
className: cn45(
|
|
4805
|
-
"
|
|
4841
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
4806
4842
|
isOpen && "rotate-180"
|
|
4807
4843
|
)
|
|
4808
4844
|
}
|
|
4809
|
-
)
|
|
4845
|
+
) })
|
|
4810
4846
|
]
|
|
4811
4847
|
}
|
|
4812
4848
|
),
|
package/dist/index.js
CHANGED
|
@@ -2964,8 +2964,8 @@ var Combobox = React32.forwardRef(
|
|
|
2964
2964
|
}
|
|
2965
2965
|
),
|
|
2966
2966
|
children: [
|
|
2967
|
-
/* @__PURE__ */ jsx32("span", { className: "
|
|
2968
|
-
opt.description ? /* @__PURE__ */ jsx32("span", { className: "
|
|
2967
|
+
/* @__PURE__ */ jsx32("span", { className: "min-w-0 shrink-0 max-w-[60%] truncate text-ink", children: opt.label }),
|
|
2968
|
+
opt.description ? /* @__PURE__ */ jsx32("span", { className: "min-w-0 flex-1 truncate text-right text-body-sm text-muted", children: opt.description }) : null
|
|
2969
2969
|
]
|
|
2970
2970
|
},
|
|
2971
2971
|
opt.value
|
|
@@ -3252,6 +3252,11 @@ var toneClass5 = {
|
|
|
3252
3252
|
warning: "text-semantic-warning",
|
|
3253
3253
|
error: "text-semantic-error"
|
|
3254
3254
|
};
|
|
3255
|
+
var PANEL_GAP = 4;
|
|
3256
|
+
var VIEWPORT_MARGIN = 8;
|
|
3257
|
+
var ROW_HEIGHT = { sm: 28, md: 32, lg: 36 };
|
|
3258
|
+
var PANEL_PADDING_Y = 8;
|
|
3259
|
+
var estimatePanelHeight = (count, size) => count * (ROW_HEIGHT[size] ?? 32) + PANEL_PADDING_Y;
|
|
3255
3260
|
var Dropdown = React34.forwardRef(
|
|
3256
3261
|
({
|
|
3257
3262
|
options,
|
|
@@ -3277,7 +3282,7 @@ var Dropdown = React34.forwardRef(
|
|
|
3277
3282
|
const [innerValue, setInnerValue] = React34.useState(defaultValue);
|
|
3278
3283
|
const [innerOpen, setInnerOpen] = React34.useState(false);
|
|
3279
3284
|
const [active, setActive] = React34.useState(-1);
|
|
3280
|
-
const [
|
|
3285
|
+
const [placement, setPlacement] = React34.useState(null);
|
|
3281
3286
|
const [mounted, setMounted] = React34.useState(false);
|
|
3282
3287
|
const value = valueProp !== void 0 ? valueProp : innerValue;
|
|
3283
3288
|
const open = openProp ?? innerOpen;
|
|
@@ -3289,9 +3294,28 @@ var Dropdown = React34.forwardRef(
|
|
|
3289
3294
|
else if (ref) ref.current = node;
|
|
3290
3295
|
};
|
|
3291
3296
|
const place = React34.useCallback(() => {
|
|
3292
|
-
const
|
|
3293
|
-
if (
|
|
3294
|
-
|
|
3297
|
+
const el = triggerRef.current;
|
|
3298
|
+
if (!el) return;
|
|
3299
|
+
const box2 = el.getBoundingClientRect();
|
|
3300
|
+
const viewportW = window.innerWidth;
|
|
3301
|
+
const viewportH = window.innerHeight;
|
|
3302
|
+
const margin = VIEWPORT_MARGIN;
|
|
3303
|
+
const gap = PANEL_GAP;
|
|
3304
|
+
const panel2 = panelRef.current;
|
|
3305
|
+
const measuredHeight = panel2?.offsetHeight ?? 0;
|
|
3306
|
+
const measuredWidth = panel2?.offsetWidth ?? 0;
|
|
3307
|
+
const panelHeight = measuredHeight > 0 ? measuredHeight : estimatePanelHeight(options.length, size);
|
|
3308
|
+
const spaceBelow = viewportH - box2.bottom - gap - margin;
|
|
3309
|
+
const spaceAbove = box2.top - gap - margin;
|
|
3310
|
+
const openUp = spaceBelow < panelHeight && spaceAbove > spaceBelow;
|
|
3311
|
+
const available = Math.max(0, Math.min(panelHeight, openUp ? spaceAbove : spaceBelow));
|
|
3312
|
+
let top = openUp ? box2.top - gap - panelHeight : box2.bottom + gap;
|
|
3313
|
+
top = Math.min(Math.max(margin, top), Math.max(margin, viewportH - margin - available));
|
|
3314
|
+
const panelWidth = Math.max(measuredWidth, box2.width);
|
|
3315
|
+
const width = Math.min(panelWidth, viewportW - margin * 2);
|
|
3316
|
+
const left = Math.max(margin, Math.min(box2.left, viewportW - width - margin));
|
|
3317
|
+
setPlacement({ top, left, minWidth: box2.width, maxHeight: available });
|
|
3318
|
+
}, [options.length, size]);
|
|
3295
3319
|
const setOpen = (next) => {
|
|
3296
3320
|
if (next) place();
|
|
3297
3321
|
if (openProp === void 0) setInnerOpen(next);
|
|
@@ -3308,6 +3332,12 @@ var Dropdown = React34.forwardRef(
|
|
|
3308
3332
|
setOpen(false);
|
|
3309
3333
|
triggerRef.current?.focus();
|
|
3310
3334
|
};
|
|
3335
|
+
React34.useLayoutEffect(() => {
|
|
3336
|
+
if (!open) return;
|
|
3337
|
+
place();
|
|
3338
|
+
const frame = window.requestAnimationFrame(() => place());
|
|
3339
|
+
return () => window.cancelAnimationFrame(frame);
|
|
3340
|
+
}, [open, place]);
|
|
3311
3341
|
React34.useEffect(() => {
|
|
3312
3342
|
if (!open) return;
|
|
3313
3343
|
place();
|
|
@@ -3363,9 +3393,13 @@ var Dropdown = React34.forwardRef(
|
|
|
3363
3393
|
"data-state": open ? "open" : "closed",
|
|
3364
3394
|
style: {
|
|
3365
3395
|
position: "fixed",
|
|
3366
|
-
top:
|
|
3367
|
-
left:
|
|
3368
|
-
|
|
3396
|
+
top: placement?.top ?? 0,
|
|
3397
|
+
left: placement?.left ?? 0,
|
|
3398
|
+
minWidth: placement?.minWidth,
|
|
3399
|
+
width: "max-content",
|
|
3400
|
+
maxWidth: `calc(100vw - ${VIEWPORT_MARGIN * 2}px)`,
|
|
3401
|
+
maxHeight: placement?.maxHeight,
|
|
3402
|
+
overflowY: "auto",
|
|
3369
3403
|
zIndex: "var(--z-popover, 1300)"
|
|
3370
3404
|
},
|
|
3371
3405
|
className: "origin-top rounded-md border border-hairline bg-surface p-xs text-ink shadow-overlay transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:-translate-y-1 data-[state=closed]:opacity-0",
|
|
@@ -3389,13 +3423,13 @@ var Dropdown = React34.forwardRef(
|
|
|
3389
3423
|
"span",
|
|
3390
3424
|
{
|
|
3391
3425
|
className: cn32(
|
|
3392
|
-
"inline-flex h-4 w-4 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
3426
|
+
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
3393
3427
|
isSelected ? "scale-100 opacity-100" : "scale-75 opacity-0"
|
|
3394
3428
|
),
|
|
3395
3429
|
children: /* @__PURE__ */ jsx34(Icon, { name: "check", size: 10, strokeWidth: 3 })
|
|
3396
3430
|
}
|
|
3397
3431
|
),
|
|
3398
|
-
children: /* @__PURE__ */ jsx34("span", { className: "flex-1
|
|
3432
|
+
children: /* @__PURE__ */ jsx34("span", { className: "flex-1 whitespace-nowrap text-ink", children: opt.label })
|
|
3399
3433
|
},
|
|
3400
3434
|
opt.value
|
|
3401
3435
|
);
|
|
@@ -4507,7 +4541,7 @@ var Toast = React46.forwardRef(
|
|
|
4507
4541
|
},
|
|
4508
4542
|
style: { zIndex: "var(--z-toast, 1400)", ...style },
|
|
4509
4543
|
className: cn44(
|
|
4510
|
-
"relative flex w-full items-
|
|
4544
|
+
"relative flex w-full items-start gap-md rounded-lg border border-hairline-strong bg-surface py-sm pl-base pr-sm text-ink shadow-overlay",
|
|
4511
4545
|
"transition duration-200 ease-out",
|
|
4512
4546
|
"data-[state=open]:translate-y-0 data-[state=open]:opacity-100",
|
|
4513
4547
|
"data-[state=closed]:pointer-events-none data-[state=closed]:translate-y-2 data-[state=closed]:opacity-0",
|
|
@@ -4533,30 +4567,32 @@ var Toast = React46.forwardRef(
|
|
|
4533
4567
|
)
|
|
4534
4568
|
}
|
|
4535
4569
|
) : null,
|
|
4536
|
-
/* @__PURE__ */ jsx46("span", { className: "min-w-0 flex-1
|
|
4537
|
-
|
|
4538
|
-
/* @__PURE__ */
|
|
4570
|
+
/* @__PURE__ */ jsx46("span", { className: "min-w-0 flex-1 break-words line-clamp-2 text-label-md text-ink", children: title }),
|
|
4571
|
+
/* @__PURE__ */ jsxs41("span", { className: "flex shrink-0 items-center gap-md", children: [
|
|
4572
|
+
actionLabel ? /* @__PURE__ */ jsxs41(Fragment7, { children: [
|
|
4573
|
+
/* @__PURE__ */ jsx46(Divider, { orientation: "vertical", tone: "strong", className: "my-xs" }),
|
|
4574
|
+
/* @__PURE__ */ jsx46(
|
|
4575
|
+
Button,
|
|
4576
|
+
{
|
|
4577
|
+
variant: "ghost",
|
|
4578
|
+
size: "sm",
|
|
4579
|
+
onClick: onAction,
|
|
4580
|
+
className: "text-link-blue! hover:text-link-blue!",
|
|
4581
|
+
children: actionLabel
|
|
4582
|
+
}
|
|
4583
|
+
)
|
|
4584
|
+
] }) : null,
|
|
4539
4585
|
/* @__PURE__ */ jsx46(
|
|
4540
|
-
|
|
4586
|
+
IconButton,
|
|
4541
4587
|
{
|
|
4588
|
+
icon: "x",
|
|
4542
4589
|
variant: "ghost",
|
|
4543
4590
|
size: "sm",
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
children: actionLabel
|
|
4591
|
+
"aria-label": "Close notification",
|
|
4592
|
+
onClick: () => onOpenChange?.(false)
|
|
4547
4593
|
}
|
|
4548
4594
|
)
|
|
4549
|
-
] })
|
|
4550
|
-
/* @__PURE__ */ jsx46(
|
|
4551
|
-
IconButton,
|
|
4552
|
-
{
|
|
4553
|
-
icon: "x",
|
|
4554
|
-
variant: "ghost",
|
|
4555
|
-
size: "sm",
|
|
4556
|
-
"aria-label": "Close notification",
|
|
4557
|
-
onClick: () => onOpenChange?.(false)
|
|
4558
|
-
}
|
|
4559
|
-
)
|
|
4595
|
+
] })
|
|
4560
4596
|
]
|
|
4561
4597
|
}
|
|
4562
4598
|
);
|
|
@@ -4666,28 +4702,28 @@ var Accordion = React47.forwardRef(
|
|
|
4666
4702
|
item.icon ? /* @__PURE__ */ jsx47(Icon, { name: item.icon, size: 18, className: "shrink-0 text-body" }) : null,
|
|
4667
4703
|
/* @__PURE__ */ jsx47("span", { className: "min-w-0 flex-1 truncate text-label-md text-ink", children: item.title }),
|
|
4668
4704
|
item.meta ? /* @__PURE__ */ jsx47("span", { className: "min-w-0 shrink-0 truncate text-body-sm text-muted", children: item.meta }) : null,
|
|
4669
|
-
/* @__PURE__ */ jsx47(
|
|
4705
|
+
/* @__PURE__ */ jsx47("span", { className: "inline-flex shrink-0 items-center md:hidden", children: /* @__PURE__ */ jsx47(
|
|
4670
4706
|
Icon,
|
|
4671
4707
|
{
|
|
4672
4708
|
name: "chevron-right",
|
|
4673
4709
|
size: 18,
|
|
4674
4710
|
className: cn45(
|
|
4675
|
-
"
|
|
4711
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
4676
4712
|
isOpen && "rotate-90"
|
|
4677
4713
|
)
|
|
4678
4714
|
}
|
|
4679
|
-
),
|
|
4680
|
-
/* @__PURE__ */ jsx47(
|
|
4715
|
+
) }),
|
|
4716
|
+
/* @__PURE__ */ jsx47("span", { className: "hidden shrink-0 items-center md:inline-flex", children: /* @__PURE__ */ jsx47(
|
|
4681
4717
|
Icon,
|
|
4682
4718
|
{
|
|
4683
4719
|
name: "chevron-down",
|
|
4684
4720
|
size: 16,
|
|
4685
4721
|
className: cn45(
|
|
4686
|
-
"
|
|
4722
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
4687
4723
|
isOpen && "rotate-180"
|
|
4688
4724
|
)
|
|
4689
4725
|
}
|
|
4690
|
-
)
|
|
4726
|
+
) })
|
|
4691
4727
|
]
|
|
4692
4728
|
}
|
|
4693
4729
|
),
|
package/dist/styles.css
CHANGED
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
--spacing-lg: 24px;
|
|
127
127
|
--spacing-xl: 32px;
|
|
128
128
|
--spacing-xxl: 48px;
|
|
129
|
+
--spacing-section: 64px;
|
|
129
130
|
--spacing-gutter: 16px;
|
|
130
131
|
--container-drawer: 28rem;
|
|
131
132
|
--grid-template-columns-system: repeat(12, minmax(0, 1fr));
|
|
@@ -711,12 +712,18 @@
|
|
|
711
712
|
.min-h-24 {
|
|
712
713
|
min-height: calc(var(--spacing) * 24);
|
|
713
714
|
}
|
|
715
|
+
.min-h-section {
|
|
716
|
+
min-height: var(--spacing-section);
|
|
717
|
+
}
|
|
714
718
|
.w-1 {
|
|
715
719
|
width: var(--spacing);
|
|
716
720
|
}
|
|
717
721
|
.w-1\.5 {
|
|
718
722
|
width: calc(var(--spacing) * 1.5);
|
|
719
723
|
}
|
|
724
|
+
.w-1\/3 {
|
|
725
|
+
width: calc(1 / 3 * 100%);
|
|
726
|
+
}
|
|
720
727
|
.w-2 {
|
|
721
728
|
width: calc(var(--spacing) * 2);
|
|
722
729
|
}
|
|
@@ -765,6 +772,9 @@
|
|
|
765
772
|
.w-24 {
|
|
766
773
|
width: calc(var(--spacing) * 24);
|
|
767
774
|
}
|
|
775
|
+
.w-32 {
|
|
776
|
+
width: calc(var(--spacing) * 32);
|
|
777
|
+
}
|
|
768
778
|
.w-40 {
|
|
769
779
|
width: calc(var(--spacing) * 40);
|
|
770
780
|
}
|
|
@@ -789,9 +799,6 @@
|
|
|
789
799
|
.max-w-full {
|
|
790
800
|
max-width: 100%;
|
|
791
801
|
}
|
|
792
|
-
.max-w-md {
|
|
793
|
-
max-width: var(--spacing-md);
|
|
794
|
-
}
|
|
795
802
|
.max-w-sm {
|
|
796
803
|
max-width: var(--spacing-sm);
|
|
797
804
|
}
|
|
@@ -837,6 +844,9 @@
|
|
|
837
844
|
.shrink-0 {
|
|
838
845
|
flex-shrink: 0;
|
|
839
846
|
}
|
|
847
|
+
.grow {
|
|
848
|
+
flex-grow: 1;
|
|
849
|
+
}
|
|
840
850
|
.table-fixed {
|
|
841
851
|
table-layout: fixed;
|
|
842
852
|
}
|
|
@@ -2524,6 +2534,11 @@
|
|
|
2524
2534
|
display: none;
|
|
2525
2535
|
}
|
|
2526
2536
|
}
|
|
2537
|
+
.md\:inline-flex {
|
|
2538
|
+
@media (width >= 768px) {
|
|
2539
|
+
display: inline-flex;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2527
2542
|
.md\:h-12 {
|
|
2528
2543
|
@media (width >= 768px) {
|
|
2529
2544
|
height: calc(var(--spacing) * 12);
|
package/package.json
CHANGED
|
@@ -248,9 +248,11 @@ export const Combobox = React.forwardRef<HTMLInputElement, ComboboxProps>(
|
|
|
248
248
|
</span>
|
|
249
249
|
}
|
|
250
250
|
>
|
|
251
|
-
<span className="
|
|
251
|
+
<span className="min-w-0 shrink-0 max-w-[60%] truncate text-ink">{opt.label}</span>
|
|
252
252
|
{opt.description ? (
|
|
253
|
-
<span className="
|
|
253
|
+
<span className="min-w-0 flex-1 truncate text-right text-body-sm text-muted">
|
|
254
|
+
{opt.description}
|
|
255
|
+
</span>
|
|
254
256
|
) : null}
|
|
255
257
|
</Button>
|
|
256
258
|
);
|
|
@@ -48,7 +48,27 @@ const toneClass: Record<DropdownIconTone, string> = {
|
|
|
48
48
|
error: "text-semantic-error",
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
/** Distance kept between the trigger and the panel. */
|
|
52
|
+
const PANEL_GAP = 4;
|
|
53
|
+
/** Distance kept between the panel and the viewport edges. */
|
|
54
|
+
const VIEWPORT_MARGIN = 8;
|
|
55
|
+
|
|
56
|
+
/** Row height per trigger size — used only to estimate the panel before it paints. */
|
|
57
|
+
const ROW_HEIGHT: Partial<Record<ButtonSize, number>> = { sm: 28, md: 32, lg: 36 };
|
|
58
|
+
/** Vertical padding inside the panel (p-xs top + bottom) — estimate only. */
|
|
59
|
+
const PANEL_PADDING_Y = 8;
|
|
60
|
+
|
|
61
|
+
const estimatePanelHeight = (count: number, size: ButtonSize) =>
|
|
62
|
+
count * (ROW_HEIGHT[size] ?? 32) + PANEL_PADDING_Y;
|
|
63
|
+
|
|
64
|
+
type Placement = {
|
|
65
|
+
top: number;
|
|
66
|
+
left: number;
|
|
67
|
+
/** The trigger's width — the panel is never narrower than this. */
|
|
68
|
+
minWidth: number;
|
|
69
|
+
/** Space available on the chosen side; the panel scrolls past it. */
|
|
70
|
+
maxHeight: number;
|
|
71
|
+
};
|
|
52
72
|
|
|
53
73
|
export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
54
74
|
(
|
|
@@ -78,7 +98,7 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
78
98
|
const [innerValue, setInnerValue] = React.useState<string | null>(defaultValue);
|
|
79
99
|
const [innerOpen, setInnerOpen] = React.useState(false);
|
|
80
100
|
const [active, setActive] = React.useState(-1);
|
|
81
|
-
const [
|
|
101
|
+
const [placement, setPlacement] = React.useState<Placement | null>(null);
|
|
82
102
|
const [mounted, setMounted] = React.useState(false);
|
|
83
103
|
|
|
84
104
|
const value = valueProp !== undefined ? valueProp : innerValue;
|
|
@@ -93,10 +113,40 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
93
113
|
else if (ref) ref.current = node;
|
|
94
114
|
};
|
|
95
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Anchors the panel under the trigger, flipping it above when there is not
|
|
118
|
+
* enough room below, clamping it inside the viewport, and letting it grow to
|
|
119
|
+
* its content so long option labels are never clipped by the trigger width.
|
|
120
|
+
*/
|
|
96
121
|
const place = React.useCallback(() => {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
122
|
+
const el = triggerRef.current;
|
|
123
|
+
if (!el) return;
|
|
124
|
+
const box = el.getBoundingClientRect();
|
|
125
|
+
const viewportW = window.innerWidth;
|
|
126
|
+
const viewportH = window.innerHeight;
|
|
127
|
+
const margin = VIEWPORT_MARGIN;
|
|
128
|
+
const gap = PANEL_GAP;
|
|
129
|
+
const panel = panelRef.current;
|
|
130
|
+
const measuredHeight = panel?.offsetHeight ?? 0;
|
|
131
|
+
const measuredWidth = panel?.offsetWidth ?? 0;
|
|
132
|
+
const panelHeight = measuredHeight > 0 ? measuredHeight : estimatePanelHeight(options.length, size);
|
|
133
|
+
|
|
134
|
+
const spaceBelow = viewportH - box.bottom - gap - margin;
|
|
135
|
+
const spaceAbove = box.top - gap - margin;
|
|
136
|
+
const openUp = spaceBelow < panelHeight && spaceAbove > spaceBelow;
|
|
137
|
+
|
|
138
|
+
const available = Math.max(0, Math.min(panelHeight, openUp ? spaceAbove : spaceBelow));
|
|
139
|
+
|
|
140
|
+
let top = openUp ? box.top - gap - panelHeight : box.bottom + gap;
|
|
141
|
+
top = Math.min(Math.max(margin, top), Math.max(margin, viewportH - margin - available));
|
|
142
|
+
|
|
143
|
+
// Width follows the content (min = trigger width); keep the right edge on screen.
|
|
144
|
+
const panelWidth = Math.max(measuredWidth, box.width);
|
|
145
|
+
const width = Math.min(panelWidth, viewportW - margin * 2);
|
|
146
|
+
const left = Math.max(margin, Math.min(box.left, viewportW - width - margin));
|
|
147
|
+
|
|
148
|
+
setPlacement({ top, left, minWidth: box.width, maxHeight: available });
|
|
149
|
+
}, [options.length, size]);
|
|
100
150
|
|
|
101
151
|
const setOpen = (next: boolean) => {
|
|
102
152
|
if (next) place();
|
|
@@ -116,6 +166,14 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
116
166
|
triggerRef.current?.focus();
|
|
117
167
|
};
|
|
118
168
|
|
|
169
|
+
// Re-measure once the panel has painted, so the flip decision uses its real height.
|
|
170
|
+
React.useLayoutEffect(() => {
|
|
171
|
+
if (!open) return;
|
|
172
|
+
place();
|
|
173
|
+
const frame = window.requestAnimationFrame(() => place());
|
|
174
|
+
return () => window.cancelAnimationFrame(frame);
|
|
175
|
+
}, [open, place]);
|
|
176
|
+
|
|
119
177
|
React.useEffect(() => {
|
|
120
178
|
if (!open) return;
|
|
121
179
|
place();
|
|
@@ -178,9 +236,13 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
178
236
|
data-state={open ? "open" : "closed"}
|
|
179
237
|
style={{
|
|
180
238
|
position: "fixed",
|
|
181
|
-
top:
|
|
182
|
-
left:
|
|
183
|
-
|
|
239
|
+
top: placement?.top ?? 0,
|
|
240
|
+
left: placement?.left ?? 0,
|
|
241
|
+
minWidth: placement?.minWidth,
|
|
242
|
+
width: "max-content",
|
|
243
|
+
maxWidth: `calc(100vw - ${VIEWPORT_MARGIN * 2}px)`,
|
|
244
|
+
maxHeight: placement?.maxHeight,
|
|
245
|
+
overflowY: "auto",
|
|
184
246
|
zIndex: "var(--z-popover, 1300)",
|
|
185
247
|
}}
|
|
186
248
|
className="origin-top rounded-md border border-hairline bg-surface p-xs text-ink shadow-overlay transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:-translate-y-1 data-[state=closed]:opacity-0"
|
|
@@ -204,7 +266,7 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
204
266
|
trailingIcon={
|
|
205
267
|
<span
|
|
206
268
|
className={cn(
|
|
207
|
-
"inline-flex h-4 w-4 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
269
|
+
"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-primary text-on-primary transition duration-150 ease-out",
|
|
208
270
|
isSelected ? "scale-100 opacity-100" : "scale-75 opacity-0",
|
|
209
271
|
)}
|
|
210
272
|
>
|
|
@@ -212,7 +274,7 @@ export const Dropdown = React.forwardRef<HTMLButtonElement, DropdownProps>(
|
|
|
212
274
|
</span>
|
|
213
275
|
}
|
|
214
276
|
>
|
|
215
|
-
<span className="flex-1
|
|
277
|
+
<span className="flex-1 whitespace-nowrap text-ink">{opt.label}</span>
|
|
216
278
|
</Button>
|
|
217
279
|
);
|
|
218
280
|
})}
|
|
@@ -8,10 +8,28 @@ const lists: DropdownOption[] = [
|
|
|
8
8
|
{ value: "apac", label: "Trade queue", icon: "layout-grid", iconTone: "success" },
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
+
const replies: DropdownOption[] = [
|
|
12
|
+
{ value: "thanks", label: "Thanks — we'll look into this today" },
|
|
13
|
+
{ value: "tracking", label: "Your order is on the way, tracking attached" },
|
|
14
|
+
{ value: "refund", label: "Your refund has been approved" },
|
|
15
|
+
{ value: "escalate", label: "Escalating to a specialist now" },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const snooze: DropdownOption[] = [
|
|
19
|
+
{ value: "1h", label: "In 1 hour" },
|
|
20
|
+
{ value: "tomorrow", label: "Tomorrow morning" },
|
|
21
|
+
{ value: "weekend", label: "This weekend" },
|
|
22
|
+
{ value: "week", label: "Next week" },
|
|
23
|
+
];
|
|
24
|
+
|
|
11
25
|
export default function DropdownPreview() {
|
|
12
26
|
const [view, setView] = React.useState<string>("uk-eu");
|
|
13
27
|
const [open, setOpen] = React.useState(false);
|
|
14
28
|
const [other, setOther] = React.useState<string | null>(null);
|
|
29
|
+
const [reply, setReply] = React.useState<string | null>("tracking");
|
|
30
|
+
const [replyOpen, setReplyOpen] = React.useState(false);
|
|
31
|
+
const [delay, setDelay] = React.useState<string | null>("1h");
|
|
32
|
+
const [composerOpen, setComposerOpen] = React.useState(false);
|
|
15
33
|
|
|
16
34
|
return (
|
|
17
35
|
<div className="mx-auto w-full max-w-3xl space-y-lg p-lg">
|
|
@@ -41,6 +59,53 @@ export default function DropdownPreview() {
|
|
|
41
59
|
<p className="text-label-sm text-muted">Disabled</p>
|
|
42
60
|
<Dropdown aria-label="Conversation view (disabled)" options={lists} value="uk-eu" disabled />
|
|
43
61
|
</div>
|
|
62
|
+
<div className="space-y-sm">
|
|
63
|
+
<p className="text-label-sm text-muted">Narrow trigger, full labels</p>
|
|
64
|
+
<div className="w-32">
|
|
65
|
+
<Dropdown
|
|
66
|
+
aria-label="Snooze"
|
|
67
|
+
options={snooze}
|
|
68
|
+
value={delay}
|
|
69
|
+
onValueChange={setDelay}
|
|
70
|
+
placeholder="Snooze"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<div className="space-y-sm">
|
|
77
|
+
<p className="text-label-sm text-muted">Saved replies — long labels widen the panel</p>
|
|
78
|
+
<div className="w-40">
|
|
79
|
+
<Dropdown
|
|
80
|
+
aria-label="Saved replies"
|
|
81
|
+
options={replies}
|
|
82
|
+
value={reply}
|
|
83
|
+
onValueChange={setReply}
|
|
84
|
+
placeholder="Saved replies"
|
|
85
|
+
open={replyOpen}
|
|
86
|
+
onOpenChange={setReplyOpen}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div className="space-y-sm">
|
|
92
|
+
<p className="text-label-sm text-muted">Pinned to the bottom — the panel opens upward</p>
|
|
93
|
+
<div className="flex min-h-section w-full flex-col justify-between gap-lg rounded-lg border border-hairline bg-surface p-md">
|
|
94
|
+
<p className="text-body-sm text-muted">
|
|
95
|
+
A composer sits here, so its toolbar is pressed against the bottom edge of the viewport.
|
|
96
|
+
</p>
|
|
97
|
+
<div className="w-40">
|
|
98
|
+
<Dropdown
|
|
99
|
+
aria-label="Saved replies (bottom of viewport)"
|
|
100
|
+
options={replies}
|
|
101
|
+
value={reply}
|
|
102
|
+
onValueChange={setReply}
|
|
103
|
+
placeholder="Saved replies"
|
|
104
|
+
open={composerOpen}
|
|
105
|
+
onOpenChange={setComposerOpen}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
44
109
|
</div>
|
|
45
110
|
</div>
|
|
46
111
|
);
|
|
@@ -13,7 +13,7 @@ export interface ToastProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "
|
|
|
13
13
|
onOpenChange?: (open: boolean) => void;
|
|
14
14
|
/** Status mark at the start: green check, red exclamation, blue info, or none. */
|
|
15
15
|
tone?: ToastTone;
|
|
16
|
-
/**
|
|
16
|
+
/** Message. Wraps to at most two lines, then clamps. */
|
|
17
17
|
title: React.ReactNode;
|
|
18
18
|
/** Optional action label (e.g. "Undo", "View"), shown after a divider. */
|
|
19
19
|
actionLabel?: string;
|
|
@@ -66,7 +66,7 @@ export const Toast = React.forwardRef<HTMLDivElement, ToastProps>(
|
|
|
66
66
|
}}
|
|
67
67
|
style={{ zIndex: "var(--z-toast, 1400)", ...style }}
|
|
68
68
|
className={cn(
|
|
69
|
-
"relative flex w-full items-
|
|
69
|
+
"relative flex w-full items-start gap-md rounded-lg border border-hairline-strong bg-surface py-sm pl-base pr-sm text-ink shadow-overlay",
|
|
70
70
|
"transition duration-200 ease-out",
|
|
71
71
|
"data-[state=open]:translate-y-0 data-[state=open]:opacity-100",
|
|
72
72
|
"data-[state=closed]:pointer-events-none data-[state=closed]:translate-y-2 data-[state=closed]:opacity-0",
|
|
@@ -89,27 +89,31 @@ export const Toast = React.forwardRef<HTMLDivElement, ToastProps>(
|
|
|
89
89
|
/>
|
|
90
90
|
</span>
|
|
91
91
|
) : null}
|
|
92
|
-
<span className="min-w-0 flex-1
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
92
|
+
<span className="min-w-0 flex-1 break-words line-clamp-2 text-label-md text-ink">
|
|
93
|
+
{title}
|
|
94
|
+
</span>
|
|
95
|
+
<span className="flex shrink-0 items-center gap-md">
|
|
96
|
+
{actionLabel ? (
|
|
97
|
+
<>
|
|
98
|
+
<Divider orientation="vertical" tone="strong" className="my-xs" />
|
|
99
|
+
<Button
|
|
100
|
+
variant="ghost"
|
|
101
|
+
size="sm"
|
|
102
|
+
onClick={onAction}
|
|
103
|
+
className="text-link-blue! hover:text-link-blue!"
|
|
104
|
+
>
|
|
105
|
+
{actionLabel}
|
|
106
|
+
</Button>
|
|
107
|
+
</>
|
|
108
|
+
) : null}
|
|
109
|
+
<IconButton
|
|
110
|
+
icon="x"
|
|
111
|
+
variant="ghost"
|
|
112
|
+
size="sm"
|
|
113
|
+
aria-label="Close notification"
|
|
114
|
+
onClick={() => onOpenChange?.(false)}
|
|
115
|
+
/>
|
|
116
|
+
</span>
|
|
113
117
|
</div>
|
|
114
118
|
);
|
|
115
119
|
},
|
|
@@ -3,51 +3,100 @@ import { Toast } from "./Toast";
|
|
|
3
3
|
import { Button } from "../../atoms/Button";
|
|
4
4
|
|
|
5
5
|
export default function ToastPreview() {
|
|
6
|
-
const [
|
|
7
|
-
const [
|
|
8
|
-
const [
|
|
6
|
+
const [success, setSuccess] = React.useState(false);
|
|
7
|
+
const [error, setError] = React.useState(false);
|
|
8
|
+
const [neutral, setNeutral] = React.useState(false);
|
|
9
|
+
const [wrapped, setWrapped] = React.useState(false);
|
|
10
|
+
|
|
11
|
+
const hideAll = () => {
|
|
12
|
+
setSuccess(false);
|
|
13
|
+
setError(false);
|
|
14
|
+
setNeutral(false);
|
|
15
|
+
setWrapped(false);
|
|
16
|
+
};
|
|
9
17
|
|
|
10
18
|
return (
|
|
11
|
-
<div className="w-full max-w-3xl mx-auto p-lg
|
|
12
|
-
<div className="flex flex-wrap gap-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
</
|
|
16
|
-
<Button variant="
|
|
17
|
-
|
|
18
|
-
</Button>
|
|
19
|
-
<Button variant="secondary" size="sm" onClick={() => setFailed(true)}>
|
|
20
|
-
Retry failed reply
|
|
19
|
+
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg bg-canvas">
|
|
20
|
+
<div className="flex flex-wrap items-center justify-between gap-md">
|
|
21
|
+
<p className="text-body-sm text-muted">
|
|
22
|
+
Press a trigger to show its toast, then close it to see the slide and fade.
|
|
23
|
+
</p>
|
|
24
|
+
<Button variant="ghost" size="sm" onClick={hideAll}>
|
|
25
|
+
Hide all
|
|
21
26
|
</Button>
|
|
22
27
|
</div>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
|
|
29
|
+
<div className="space-y-md">
|
|
30
|
+
<div className="flex items-center gap-md">
|
|
31
|
+
<Button variant="outline" size="sm" onClick={() => setSuccess(true)}>
|
|
32
|
+
Success
|
|
33
|
+
</Button>
|
|
34
|
+
<div className="min-w-0 flex-1">
|
|
35
|
+
<Toast
|
|
36
|
+
open={success}
|
|
37
|
+
onOpenChange={setSuccess}
|
|
38
|
+
tone="success"
|
|
39
|
+
duration={0}
|
|
40
|
+
title="Changes saved to your workspace"
|
|
41
|
+
actionLabel="Undo"
|
|
42
|
+
onAction={() => setSuccess(false)}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div className="flex items-center gap-md">
|
|
48
|
+
<Button variant="outline" size="sm" onClick={() => setError(true)}>
|
|
49
|
+
Error
|
|
50
|
+
</Button>
|
|
51
|
+
<div className="min-w-0 flex-1">
|
|
52
|
+
<Toast
|
|
53
|
+
open={error}
|
|
54
|
+
onOpenChange={setError}
|
|
55
|
+
tone="error"
|
|
56
|
+
duration={0}
|
|
57
|
+
title="Upload failed — check your connection and try again"
|
|
58
|
+
actionLabel="Retry"
|
|
59
|
+
onAction={() => setError(false)}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div className="flex items-center gap-md">
|
|
65
|
+
<Button variant="outline" size="sm" onClick={() => setNeutral(true)}>
|
|
66
|
+
Neutral
|
|
67
|
+
</Button>
|
|
68
|
+
<div className="min-w-0 flex-1">
|
|
69
|
+
<Toast
|
|
70
|
+
open={neutral}
|
|
71
|
+
onOpenChange={setNeutral}
|
|
72
|
+
tone="neutral"
|
|
73
|
+
duration={0}
|
|
74
|
+
title="Draft restored"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div className="space-y-sm">
|
|
81
|
+
<p className="text-caption text-muted">
|
|
82
|
+
Narrow column — a long message wraps to two lines and clamps
|
|
83
|
+
</p>
|
|
84
|
+
<div className="flex items-center gap-md">
|
|
85
|
+
<Button variant="outline" size="sm" onClick={() => setWrapped(true)}>
|
|
86
|
+
Long message
|
|
87
|
+
</Button>
|
|
88
|
+
<div className="min-w-0 w-1/3">
|
|
89
|
+
<Toast
|
|
90
|
+
open={wrapped}
|
|
91
|
+
onOpenChange={setWrapped}
|
|
92
|
+
tone="info"
|
|
93
|
+
duration={0}
|
|
94
|
+
title="The public help site opens in the full product"
|
|
95
|
+
actionLabel="Open"
|
|
96
|
+
onAction={() => setWrapped(false)}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
51
100
|
</div>
|
|
52
101
|
</div>
|
|
53
102
|
);
|
|
@@ -142,22 +142,29 @@ export const Accordion = React.forwardRef<HTMLDivElement, AccordionProps>(
|
|
|
142
142
|
{item.meta ? (
|
|
143
143
|
<span className="min-w-0 shrink-0 truncate text-body-sm text-muted">{item.meta}</span>
|
|
144
144
|
) : null}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
{/* The wrapper owns the responsive display: the Icon atom always
|
|
146
|
+
renders `inline-block`, so `hidden` on the Icon itself loses
|
|
147
|
+
the cascade and both chevrons would show below `md`. */}
|
|
148
|
+
<span className="inline-flex shrink-0 items-center md:hidden">
|
|
149
|
+
<Icon
|
|
150
|
+
name="chevron-right"
|
|
151
|
+
size={18}
|
|
152
|
+
className={cn(
|
|
153
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
154
|
+
isOpen && "rotate-90",
|
|
155
|
+
)}
|
|
156
|
+
/>
|
|
157
|
+
</span>
|
|
158
|
+
<span className="hidden shrink-0 items-center md:inline-flex">
|
|
159
|
+
<Icon
|
|
160
|
+
name="chevron-down"
|
|
161
|
+
size={16}
|
|
162
|
+
className={cn(
|
|
163
|
+
"text-muted transition-transform duration-200 ease-out",
|
|
164
|
+
isOpen && "rotate-180",
|
|
165
|
+
)}
|
|
166
|
+
/>
|
|
167
|
+
</span>
|
|
161
168
|
</button>
|
|
162
169
|
<div
|
|
163
170
|
id={panelId}
|