@designa8/vibedesign-linear-internal-v1-b737 0.11.1 → 0.11.3
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 +139 -79
- package/dist/index.js +139 -79
- package/dist/styles.css +3 -0
- package/package.json +1 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +4 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +16 -4
- package/src/atoms/Badge/Badge.tsx +5 -1
- package/src/atoms/Button/Button.tsx +49 -6
- package/src/atoms/SegmentedControl/SegmentedControl.tsx +40 -5
- package/src/atoms/SegmentedControl/preview.tsx +21 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-linear-internal-v1-b737
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.11.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.11.3**.
|
|
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
|
@@ -600,7 +600,7 @@ var React6 = __toESM(require("react"));
|
|
|
600
600
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
601
601
|
var cn4 = (...parts) => parts.filter(Boolean).join(" ");
|
|
602
602
|
var base = "relative inline-flex shrink-0 select-none items-center justify-center whitespace-nowrap border font-weight-body-md cursor-pointer transition duration-150 ease-out active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100";
|
|
603
|
-
var rowBase = "relative flex w-full min-w-0 select-none items-center
|
|
603
|
+
var rowBase = "relative flex w-full min-w-0 select-none items-center border text-left font-weight-body-md cursor-pointer transition-colors duration-150 ease-out focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
604
604
|
var isRow = (v) => v === "field" || v === "item" || v === "media";
|
|
605
605
|
var variants = {
|
|
606
606
|
primary: "border-primary bg-primary text-on-primary shadow-sm enabled:hover:bg-primary-hover enabled:hover:border-primary-hover enabled:active:bg-primary-active",
|
|
@@ -617,6 +617,11 @@ var sizes = {
|
|
|
617
617
|
md: "h-8 gap-sm rounded-md px-md text-body-md",
|
|
618
618
|
lg: "h-9 gap-sm rounded-md px-base text-body-md"
|
|
619
619
|
};
|
|
620
|
+
var wrapSizes = {
|
|
621
|
+
sm: "gap-xs rounded-sm px-sm py-xs text-body-sm",
|
|
622
|
+
md: "gap-sm rounded-md px-md py-xs text-body-md",
|
|
623
|
+
lg: "gap-sm rounded-md px-base py-sm text-body-md"
|
|
624
|
+
};
|
|
620
625
|
var iconOnlySizes = {
|
|
621
626
|
sm: "h-7 w-7 rounded-sm px-0",
|
|
622
627
|
md: "h-8 w-8 rounded-md px-0",
|
|
@@ -633,6 +638,7 @@ var Button = React6.forwardRef(
|
|
|
633
638
|
trailingIcon,
|
|
634
639
|
fullWidth = false,
|
|
635
640
|
iconOnly = false,
|
|
641
|
+
wrap = false,
|
|
636
642
|
disabled,
|
|
637
643
|
type = "button",
|
|
638
644
|
className,
|
|
@@ -641,6 +647,8 @@ var Button = React6.forwardRef(
|
|
|
641
647
|
...rest
|
|
642
648
|
}, ref) => {
|
|
643
649
|
const media = variant === "media";
|
|
650
|
+
const row = isRow(variant);
|
|
651
|
+
const wrappedRow = row && wrap && !iconOnly;
|
|
644
652
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
645
653
|
"button",
|
|
646
654
|
{
|
|
@@ -651,9 +659,12 @@ var Button = React6.forwardRef(
|
|
|
651
659
|
"aria-disabled": loading || void 0,
|
|
652
660
|
onClick: loading ? (e) => e.preventDefault() : onClick,
|
|
653
661
|
className: cn4(
|
|
654
|
-
|
|
662
|
+
row ? cn4(
|
|
663
|
+
rowBase,
|
|
664
|
+
wrappedRow ? "items-start whitespace-normal" : "items-center whitespace-nowrap"
|
|
665
|
+
) : base,
|
|
655
666
|
variants[variant],
|
|
656
|
-
media ? "rounded-lg" : iconOnly ? iconOnlySizes[size] : sizes[size],
|
|
667
|
+
media ? "rounded-lg" : iconOnly ? iconOnlySizes[size] : wrappedRow ? wrapSizes[size] : sizes[size],
|
|
657
668
|
fullWidth && "w-full",
|
|
658
669
|
loading && "pointer-events-none",
|
|
659
670
|
className
|
|
@@ -667,9 +678,35 @@ var Button = React6.forwardRef(
|
|
|
667
678
|
size: iconSize[size],
|
|
668
679
|
className: "shrink-0 animate-spin text-muted"
|
|
669
680
|
}
|
|
670
|
-
) : leadingIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
671
|
-
|
|
672
|
-
|
|
681
|
+
) : leadingIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
682
|
+
"span",
|
|
683
|
+
{
|
|
684
|
+
className: cn4(
|
|
685
|
+
"inline-flex shrink-0 items-center",
|
|
686
|
+
wrappedRow && "self-start"
|
|
687
|
+
),
|
|
688
|
+
"aria-hidden": "true",
|
|
689
|
+
children: leadingIcon
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
iconOnly ? !loading && children : media ? children : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
693
|
+
"span",
|
|
694
|
+
{
|
|
695
|
+
className: row ? cn4("min-w-0 flex-1", !wrappedRow && "truncate") : void 0,
|
|
696
|
+
children: loading && loadingText ? loadingText : children
|
|
697
|
+
}
|
|
698
|
+
),
|
|
699
|
+
!loading && trailingIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
700
|
+
"span",
|
|
701
|
+
{
|
|
702
|
+
className: cn4(
|
|
703
|
+
"inline-flex shrink-0 items-center",
|
|
704
|
+
wrappedRow && "self-start"
|
|
705
|
+
),
|
|
706
|
+
"aria-hidden": "true",
|
|
707
|
+
children: trailingIcon
|
|
708
|
+
}
|
|
709
|
+
)
|
|
673
710
|
]
|
|
674
711
|
}
|
|
675
712
|
);
|
|
@@ -1225,6 +1262,7 @@ var AgentQuestionCard = React11.forwardRef(
|
|
|
1225
1262
|
variant: "item",
|
|
1226
1263
|
size: "md",
|
|
1227
1264
|
fullWidth: true,
|
|
1265
|
+
wrap: true,
|
|
1228
1266
|
role: "radio",
|
|
1229
1267
|
"aria-checked": isSelected,
|
|
1230
1268
|
"aria-label": option.label,
|
|
@@ -1278,6 +1316,7 @@ var AgentQuestionCard = React11.forwardRef(
|
|
|
1278
1316
|
variant: "item",
|
|
1279
1317
|
size: "md",
|
|
1280
1318
|
fullWidth: true,
|
|
1319
|
+
wrap: true,
|
|
1281
1320
|
role: "radio",
|
|
1282
1321
|
"aria-checked": false,
|
|
1283
1322
|
"aria-label": freeTextLabel ?? void 0,
|
|
@@ -1858,7 +1897,8 @@ var TONE = {
|
|
|
1858
1897
|
warning: "bg-semantic-warning-soft text-semantic-warning",
|
|
1859
1898
|
error: "bg-semantic-error-soft text-semantic-error",
|
|
1860
1899
|
info: "bg-semantic-info-soft text-semantic-info",
|
|
1861
|
-
"on-primary": "bg-on-primary/20 text-on-primary"
|
|
1900
|
+
"on-primary": "bg-on-primary/20 text-on-primary",
|
|
1901
|
+
"on-primary-solid": "bg-on-primary text-primary"
|
|
1862
1902
|
};
|
|
1863
1903
|
var SIZE = {
|
|
1864
1904
|
sm: "h-5 gap-xs rounded-sm px-xs text-caption",
|
|
@@ -9994,7 +10034,16 @@ var pillRadius = {
|
|
|
9994
10034
|
md: "rounded-md"
|
|
9995
10035
|
};
|
|
9996
10036
|
var SegmentedControl = React83.forwardRef(
|
|
9997
|
-
({
|
|
10037
|
+
({
|
|
10038
|
+
items,
|
|
10039
|
+
value,
|
|
10040
|
+
onValueChange,
|
|
10041
|
+
size = "sm",
|
|
10042
|
+
bare = false,
|
|
10043
|
+
fullWidth = false,
|
|
10044
|
+
className,
|
|
10045
|
+
...rest
|
|
10046
|
+
}, ref) => {
|
|
9998
10047
|
const trackRef = React83.useRef(null);
|
|
9999
10048
|
const itemRefs = React83.useRef({});
|
|
10000
10049
|
const [pill, setPill] = React83.useState(null);
|
|
@@ -10029,80 +10078,91 @@ var SegmentedControl = React83.forwardRef(
|
|
|
10029
10078
|
onValueChange(next.value);
|
|
10030
10079
|
itemRefs.current[next.value]?.focus();
|
|
10031
10080
|
};
|
|
10032
|
-
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10033
10082
|
"div",
|
|
10034
10083
|
{
|
|
10035
|
-
ref
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
"
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
"
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10084
|
+
ref,
|
|
10085
|
+
className: cn62("min-w-0", fullWidth ? "flex w-full" : "inline-flex max-w-full"),
|
|
10086
|
+
...rest,
|
|
10087
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
|
|
10088
|
+
"div",
|
|
10089
|
+
{
|
|
10090
|
+
ref: trackRef,
|
|
10091
|
+
role: "tablist",
|
|
10092
|
+
"aria-orientation": "horizontal",
|
|
10093
|
+
onKeyDown,
|
|
10094
|
+
className: cn62(
|
|
10095
|
+
"relative isolate inline-flex max-w-full items-center overflow-x-auto rounded-lg",
|
|
10096
|
+
frame[size],
|
|
10097
|
+
bare ? "bg-transparent" : "border border-hairline bg-canvas shadow-sm",
|
|
10098
|
+
fullWidth && "flex w-full",
|
|
10099
|
+
"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
10100
|
+
className
|
|
10101
|
+
),
|
|
10102
|
+
children: [
|
|
10103
|
+
!bare ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10104
|
+
"span",
|
|
10105
|
+
{
|
|
10106
|
+
"aria-hidden": "true",
|
|
10107
|
+
className: cn62(
|
|
10108
|
+
"pointer-events-none absolute top-xxs bottom-xxs left-0 -z-10 bg-primary shadow-sm transition-[transform,width] duration-200 ease-out",
|
|
10109
|
+
pillRadius[size]
|
|
10110
|
+
),
|
|
10111
|
+
style: pill ? { width: pill.width, transform: `translateX(${pill.offset}px)` } : { width: 0, opacity: 0 }
|
|
10112
|
+
}
|
|
10113
|
+
) : null,
|
|
10114
|
+
items.map((item) => {
|
|
10115
|
+
const active = item.value === value;
|
|
10116
|
+
const iconOnly = Boolean(item.icon) && item.label == null;
|
|
10117
|
+
const glyphSize3 = size === "sm" ? 14 : 16;
|
|
10118
|
+
const pillFallback = !bare && active && !pill ? "bg-primary" : false;
|
|
10119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10120
|
+
Button,
|
|
10121
|
+
{
|
|
10122
|
+
ref: (el) => {
|
|
10123
|
+
itemRefs.current[item.value] = el;
|
|
10124
|
+
},
|
|
10125
|
+
type: "button",
|
|
10126
|
+
role: "tab",
|
|
10127
|
+
"aria-selected": active,
|
|
10128
|
+
"aria-label": iconOnly ? item["aria-label"] ?? item.value : void 0,
|
|
10129
|
+
tabIndex: active || value === void 0 && item.value === firstEnabled ? 0 : -1,
|
|
10130
|
+
variant: bare ? active ? "primary" : "ghost" : "bare",
|
|
10131
|
+
size,
|
|
10132
|
+
iconOnly,
|
|
10133
|
+
disabled: item.disabled,
|
|
10134
|
+
onClick: () => onValueChange(item.value),
|
|
10135
|
+
className: cn62(segmentInteraction, pillFallback, fullWidth && "flex-1"),
|
|
10136
|
+
children: iconOnly ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Icon, { name: item.icon, size: glyphSize3 }) : /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("span", { className: "inline-flex min-w-0 items-center gap-xs", children: [
|
|
10137
|
+
item.dotClassName ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10138
|
+
"span",
|
|
10139
|
+
{
|
|
10140
|
+
"aria-hidden": "true",
|
|
10141
|
+
className: cn62("h-2 w-2 shrink-0 rounded-full", item.dotClassName)
|
|
10142
|
+
}
|
|
10143
|
+
) : null,
|
|
10144
|
+
item.icon ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Icon, { name: item.icon, size: glyphSize3 }) : null,
|
|
10145
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "truncate", children: item.label }),
|
|
10146
|
+
item.count !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
10147
|
+
Badge,
|
|
10148
|
+
{
|
|
10149
|
+
size: "sm",
|
|
10150
|
+
tone: active ? "on-primary-solid" : "neutral",
|
|
10151
|
+
"aria-label": `${item.count} items`,
|
|
10152
|
+
className: "min-w-5 justify-center",
|
|
10153
|
+
children: item.count
|
|
10154
|
+
}
|
|
10155
|
+
) : null
|
|
10156
|
+
] })
|
|
10157
|
+
},
|
|
10158
|
+
item.value
|
|
10159
|
+
);
|
|
10160
|
+
})
|
|
10161
|
+
]
|
|
10162
|
+
}
|
|
10163
|
+
)
|
|
10104
10164
|
}
|
|
10105
|
-
)
|
|
10165
|
+
);
|
|
10106
10166
|
}
|
|
10107
10167
|
);
|
|
10108
10168
|
SegmentedControl.displayName = "SegmentedControl";
|
package/dist/index.js
CHANGED
|
@@ -456,7 +456,7 @@ import * as React6 from "react";
|
|
|
456
456
|
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
457
457
|
var cn4 = (...parts) => parts.filter(Boolean).join(" ");
|
|
458
458
|
var base = "relative inline-flex shrink-0 select-none items-center justify-center whitespace-nowrap border font-weight-body-md cursor-pointer transition duration-150 ease-out active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100";
|
|
459
|
-
var rowBase = "relative flex w-full min-w-0 select-none items-center
|
|
459
|
+
var rowBase = "relative flex w-full min-w-0 select-none items-center border text-left font-weight-body-md cursor-pointer transition-colors duration-150 ease-out focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
460
460
|
var isRow = (v) => v === "field" || v === "item" || v === "media";
|
|
461
461
|
var variants = {
|
|
462
462
|
primary: "border-primary bg-primary text-on-primary shadow-sm enabled:hover:bg-primary-hover enabled:hover:border-primary-hover enabled:active:bg-primary-active",
|
|
@@ -473,6 +473,11 @@ var sizes = {
|
|
|
473
473
|
md: "h-8 gap-sm rounded-md px-md text-body-md",
|
|
474
474
|
lg: "h-9 gap-sm rounded-md px-base text-body-md"
|
|
475
475
|
};
|
|
476
|
+
var wrapSizes = {
|
|
477
|
+
sm: "gap-xs rounded-sm px-sm py-xs text-body-sm",
|
|
478
|
+
md: "gap-sm rounded-md px-md py-xs text-body-md",
|
|
479
|
+
lg: "gap-sm rounded-md px-base py-sm text-body-md"
|
|
480
|
+
};
|
|
476
481
|
var iconOnlySizes = {
|
|
477
482
|
sm: "h-7 w-7 rounded-sm px-0",
|
|
478
483
|
md: "h-8 w-8 rounded-md px-0",
|
|
@@ -489,6 +494,7 @@ var Button = React6.forwardRef(
|
|
|
489
494
|
trailingIcon,
|
|
490
495
|
fullWidth = false,
|
|
491
496
|
iconOnly = false,
|
|
497
|
+
wrap = false,
|
|
492
498
|
disabled,
|
|
493
499
|
type = "button",
|
|
494
500
|
className,
|
|
@@ -497,6 +503,8 @@ var Button = React6.forwardRef(
|
|
|
497
503
|
...rest
|
|
498
504
|
}, ref) => {
|
|
499
505
|
const media = variant === "media";
|
|
506
|
+
const row = isRow(variant);
|
|
507
|
+
const wrappedRow = row && wrap && !iconOnly;
|
|
500
508
|
return /* @__PURE__ */ jsxs4(
|
|
501
509
|
"button",
|
|
502
510
|
{
|
|
@@ -507,9 +515,12 @@ var Button = React6.forwardRef(
|
|
|
507
515
|
"aria-disabled": loading || void 0,
|
|
508
516
|
onClick: loading ? (e) => e.preventDefault() : onClick,
|
|
509
517
|
className: cn4(
|
|
510
|
-
|
|
518
|
+
row ? cn4(
|
|
519
|
+
rowBase,
|
|
520
|
+
wrappedRow ? "items-start whitespace-normal" : "items-center whitespace-nowrap"
|
|
521
|
+
) : base,
|
|
511
522
|
variants[variant],
|
|
512
|
-
media ? "rounded-lg" : iconOnly ? iconOnlySizes[size] : sizes[size],
|
|
523
|
+
media ? "rounded-lg" : iconOnly ? iconOnlySizes[size] : wrappedRow ? wrapSizes[size] : sizes[size],
|
|
513
524
|
fullWidth && "w-full",
|
|
514
525
|
loading && "pointer-events-none",
|
|
515
526
|
className
|
|
@@ -523,9 +534,35 @@ var Button = React6.forwardRef(
|
|
|
523
534
|
size: iconSize[size],
|
|
524
535
|
className: "shrink-0 animate-spin text-muted"
|
|
525
536
|
}
|
|
526
|
-
) : leadingIcon && /* @__PURE__ */ jsx6(
|
|
527
|
-
|
|
528
|
-
|
|
537
|
+
) : leadingIcon && /* @__PURE__ */ jsx6(
|
|
538
|
+
"span",
|
|
539
|
+
{
|
|
540
|
+
className: cn4(
|
|
541
|
+
"inline-flex shrink-0 items-center",
|
|
542
|
+
wrappedRow && "self-start"
|
|
543
|
+
),
|
|
544
|
+
"aria-hidden": "true",
|
|
545
|
+
children: leadingIcon
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
iconOnly ? !loading && children : media ? children : /* @__PURE__ */ jsx6(
|
|
549
|
+
"span",
|
|
550
|
+
{
|
|
551
|
+
className: row ? cn4("min-w-0 flex-1", !wrappedRow && "truncate") : void 0,
|
|
552
|
+
children: loading && loadingText ? loadingText : children
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
!loading && trailingIcon && /* @__PURE__ */ jsx6(
|
|
556
|
+
"span",
|
|
557
|
+
{
|
|
558
|
+
className: cn4(
|
|
559
|
+
"inline-flex shrink-0 items-center",
|
|
560
|
+
wrappedRow && "self-start"
|
|
561
|
+
),
|
|
562
|
+
"aria-hidden": "true",
|
|
563
|
+
children: trailingIcon
|
|
564
|
+
}
|
|
565
|
+
)
|
|
529
566
|
]
|
|
530
567
|
}
|
|
531
568
|
);
|
|
@@ -1081,6 +1118,7 @@ var AgentQuestionCard = React11.forwardRef(
|
|
|
1081
1118
|
variant: "item",
|
|
1082
1119
|
size: "md",
|
|
1083
1120
|
fullWidth: true,
|
|
1121
|
+
wrap: true,
|
|
1084
1122
|
role: "radio",
|
|
1085
1123
|
"aria-checked": isSelected,
|
|
1086
1124
|
"aria-label": option.label,
|
|
@@ -1134,6 +1172,7 @@ var AgentQuestionCard = React11.forwardRef(
|
|
|
1134
1172
|
variant: "item",
|
|
1135
1173
|
size: "md",
|
|
1136
1174
|
fullWidth: true,
|
|
1175
|
+
wrap: true,
|
|
1137
1176
|
role: "radio",
|
|
1138
1177
|
"aria-checked": false,
|
|
1139
1178
|
"aria-label": freeTextLabel ?? void 0,
|
|
@@ -1714,7 +1753,8 @@ var TONE = {
|
|
|
1714
1753
|
warning: "bg-semantic-warning-soft text-semantic-warning",
|
|
1715
1754
|
error: "bg-semantic-error-soft text-semantic-error",
|
|
1716
1755
|
info: "bg-semantic-info-soft text-semantic-info",
|
|
1717
|
-
"on-primary": "bg-on-primary/20 text-on-primary"
|
|
1756
|
+
"on-primary": "bg-on-primary/20 text-on-primary",
|
|
1757
|
+
"on-primary-solid": "bg-on-primary text-primary"
|
|
1718
1758
|
};
|
|
1719
1759
|
var SIZE = {
|
|
1720
1760
|
sm: "h-5 gap-xs rounded-sm px-xs text-caption",
|
|
@@ -9850,7 +9890,16 @@ var pillRadius = {
|
|
|
9850
9890
|
md: "rounded-md"
|
|
9851
9891
|
};
|
|
9852
9892
|
var SegmentedControl = React83.forwardRef(
|
|
9853
|
-
({
|
|
9893
|
+
({
|
|
9894
|
+
items,
|
|
9895
|
+
value,
|
|
9896
|
+
onValueChange,
|
|
9897
|
+
size = "sm",
|
|
9898
|
+
bare = false,
|
|
9899
|
+
fullWidth = false,
|
|
9900
|
+
className,
|
|
9901
|
+
...rest
|
|
9902
|
+
}, ref) => {
|
|
9854
9903
|
const trackRef = React83.useRef(null);
|
|
9855
9904
|
const itemRefs = React83.useRef({});
|
|
9856
9905
|
const [pill, setPill] = React83.useState(null);
|
|
@@ -9885,80 +9934,91 @@ var SegmentedControl = React83.forwardRef(
|
|
|
9885
9934
|
onValueChange(next.value);
|
|
9886
9935
|
itemRefs.current[next.value]?.focus();
|
|
9887
9936
|
};
|
|
9888
|
-
return /* @__PURE__ */ jsx83(
|
|
9937
|
+
return /* @__PURE__ */ jsx83(
|
|
9889
9938
|
"div",
|
|
9890
9939
|
{
|
|
9891
|
-
ref
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
"
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
"
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9940
|
+
ref,
|
|
9941
|
+
className: cn62("min-w-0", fullWidth ? "flex w-full" : "inline-flex max-w-full"),
|
|
9942
|
+
...rest,
|
|
9943
|
+
children: /* @__PURE__ */ jsxs77(
|
|
9944
|
+
"div",
|
|
9945
|
+
{
|
|
9946
|
+
ref: trackRef,
|
|
9947
|
+
role: "tablist",
|
|
9948
|
+
"aria-orientation": "horizontal",
|
|
9949
|
+
onKeyDown,
|
|
9950
|
+
className: cn62(
|
|
9951
|
+
"relative isolate inline-flex max-w-full items-center overflow-x-auto rounded-lg",
|
|
9952
|
+
frame[size],
|
|
9953
|
+
bare ? "bg-transparent" : "border border-hairline bg-canvas shadow-sm",
|
|
9954
|
+
fullWidth && "flex w-full",
|
|
9955
|
+
"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
9956
|
+
className
|
|
9957
|
+
),
|
|
9958
|
+
children: [
|
|
9959
|
+
!bare ? /* @__PURE__ */ jsx83(
|
|
9960
|
+
"span",
|
|
9961
|
+
{
|
|
9962
|
+
"aria-hidden": "true",
|
|
9963
|
+
className: cn62(
|
|
9964
|
+
"pointer-events-none absolute top-xxs bottom-xxs left-0 -z-10 bg-primary shadow-sm transition-[transform,width] duration-200 ease-out",
|
|
9965
|
+
pillRadius[size]
|
|
9966
|
+
),
|
|
9967
|
+
style: pill ? { width: pill.width, transform: `translateX(${pill.offset}px)` } : { width: 0, opacity: 0 }
|
|
9968
|
+
}
|
|
9969
|
+
) : null,
|
|
9970
|
+
items.map((item) => {
|
|
9971
|
+
const active = item.value === value;
|
|
9972
|
+
const iconOnly = Boolean(item.icon) && item.label == null;
|
|
9973
|
+
const glyphSize3 = size === "sm" ? 14 : 16;
|
|
9974
|
+
const pillFallback = !bare && active && !pill ? "bg-primary" : false;
|
|
9975
|
+
return /* @__PURE__ */ jsx83(
|
|
9976
|
+
Button,
|
|
9977
|
+
{
|
|
9978
|
+
ref: (el) => {
|
|
9979
|
+
itemRefs.current[item.value] = el;
|
|
9980
|
+
},
|
|
9981
|
+
type: "button",
|
|
9982
|
+
role: "tab",
|
|
9983
|
+
"aria-selected": active,
|
|
9984
|
+
"aria-label": iconOnly ? item["aria-label"] ?? item.value : void 0,
|
|
9985
|
+
tabIndex: active || value === void 0 && item.value === firstEnabled ? 0 : -1,
|
|
9986
|
+
variant: bare ? active ? "primary" : "ghost" : "bare",
|
|
9987
|
+
size,
|
|
9988
|
+
iconOnly,
|
|
9989
|
+
disabled: item.disabled,
|
|
9990
|
+
onClick: () => onValueChange(item.value),
|
|
9991
|
+
className: cn62(segmentInteraction, pillFallback, fullWidth && "flex-1"),
|
|
9992
|
+
children: iconOnly ? /* @__PURE__ */ jsx83(Icon, { name: item.icon, size: glyphSize3 }) : /* @__PURE__ */ jsxs77("span", { className: "inline-flex min-w-0 items-center gap-xs", children: [
|
|
9993
|
+
item.dotClassName ? /* @__PURE__ */ jsx83(
|
|
9994
|
+
"span",
|
|
9995
|
+
{
|
|
9996
|
+
"aria-hidden": "true",
|
|
9997
|
+
className: cn62("h-2 w-2 shrink-0 rounded-full", item.dotClassName)
|
|
9998
|
+
}
|
|
9999
|
+
) : null,
|
|
10000
|
+
item.icon ? /* @__PURE__ */ jsx83(Icon, { name: item.icon, size: glyphSize3 }) : null,
|
|
10001
|
+
/* @__PURE__ */ jsx83("span", { className: "truncate", children: item.label }),
|
|
10002
|
+
item.count !== void 0 ? /* @__PURE__ */ jsx83(
|
|
10003
|
+
Badge,
|
|
10004
|
+
{
|
|
10005
|
+
size: "sm",
|
|
10006
|
+
tone: active ? "on-primary-solid" : "neutral",
|
|
10007
|
+
"aria-label": `${item.count} items`,
|
|
10008
|
+
className: "min-w-5 justify-center",
|
|
10009
|
+
children: item.count
|
|
10010
|
+
}
|
|
10011
|
+
) : null
|
|
10012
|
+
] })
|
|
10013
|
+
},
|
|
10014
|
+
item.value
|
|
10015
|
+
);
|
|
10016
|
+
})
|
|
10017
|
+
]
|
|
10018
|
+
}
|
|
10019
|
+
)
|
|
9960
10020
|
}
|
|
9961
|
-
)
|
|
10021
|
+
);
|
|
9962
10022
|
}
|
|
9963
10023
|
);
|
|
9964
10024
|
SegmentedControl.displayName = "SegmentedControl";
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -83,6 +83,8 @@ const PANEL =
|
|
|
83
83
|
* The card that replaces the chat prompt while an agent waits on a choice.
|
|
84
84
|
* Options are a radiogroup (arrow keys move and select), the trailing row turns
|
|
85
85
|
* into an inline text field, and closing folds the card into a slim restore bar.
|
|
86
|
+
* Option labels wrap onto multiple lines — agent options are often full
|
|
87
|
+
* sentences — with the letter badge pinned to the first line.
|
|
86
88
|
*/
|
|
87
89
|
export const AgentQuestionCard = React.forwardRef<
|
|
88
90
|
HTMLDivElement,
|
|
@@ -289,6 +291,7 @@ export const AgentQuestionCard = React.forwardRef<
|
|
|
289
291
|
variant="item"
|
|
290
292
|
size="md"
|
|
291
293
|
fullWidth
|
|
294
|
+
wrap
|
|
292
295
|
role="radio"
|
|
293
296
|
aria-checked={isSelected}
|
|
294
297
|
aria-label={option.label}
|
|
@@ -355,6 +358,7 @@ export const AgentQuestionCard = React.forwardRef<
|
|
|
355
358
|
variant="item"
|
|
356
359
|
size="md"
|
|
357
360
|
fullWidth
|
|
361
|
+
wrap
|
|
358
362
|
role="radio"
|
|
359
363
|
aria-checked={false}
|
|
360
364
|
aria-label={freeTextLabel ?? undefined}
|
|
@@ -3,7 +3,11 @@ import { AgentQuestionCard } from "./AgentQuestionCard";
|
|
|
3
3
|
import type { AgentQuestionAnswer, AgentQuestionOption } from "./AgentQuestionCard";
|
|
4
4
|
|
|
5
5
|
const OPTIONS: AgentQuestionOption[] = [
|
|
6
|
-
{
|
|
6
|
+
{
|
|
7
|
+
id: "keep",
|
|
8
|
+
label:
|
|
9
|
+
"Keep the current layout and tighten spacing — I'll adjust the gutters and paddings only, no structural change",
|
|
10
|
+
},
|
|
7
11
|
{ id: "rebuild", label: "Rebuild the canvas grid from scratch" },
|
|
8
12
|
{ id: "defer", label: "Leave it as is for now" },
|
|
9
13
|
];
|
|
@@ -30,7 +34,7 @@ export default function Preview() {
|
|
|
30
34
|
|
|
31
35
|
return (
|
|
32
36
|
<div className="w-full max-w-3xl mx-auto p-lg space-y-lg">
|
|
33
|
-
<Section title="Live card — pick an option
|
|
37
|
+
<Section title="Live card — long sentences wrap, pick an option or close it">
|
|
34
38
|
<AgentQuestionCard
|
|
35
39
|
questionId="q-layout"
|
|
36
40
|
questionNumber={1}
|
|
@@ -63,7 +67,11 @@ export default function Preview() {
|
|
|
63
67
|
questionNumber={2}
|
|
64
68
|
question="Which token should the selected row use?"
|
|
65
69
|
options={[
|
|
66
|
-
{
|
|
70
|
+
{
|
|
71
|
+
id: "primary-soft",
|
|
72
|
+
label:
|
|
73
|
+
"primary-soft tint with a trailing check so the chosen row stays readable across the whole card",
|
|
74
|
+
},
|
|
67
75
|
{ id: "surface-soft", label: "surface-soft tint with no marker" },
|
|
68
76
|
]}
|
|
69
77
|
selectedOptionId={errorSelected}
|
|
@@ -84,7 +92,11 @@ export default function Preview() {
|
|
|
84
92
|
questionNumber={3}
|
|
85
93
|
question="Should I apply the change to every breakpoint?"
|
|
86
94
|
options={[
|
|
87
|
-
{
|
|
95
|
+
{
|
|
96
|
+
id: "all",
|
|
97
|
+
label:
|
|
98
|
+
"Yes, every breakpoint — mobile, tablet and desktop all get the new spacing",
|
|
99
|
+
},
|
|
88
100
|
{ id: "desktop", label: "Desktop only for now" },
|
|
89
101
|
]}
|
|
90
102
|
defaultSelectedOptionId="all"
|
|
@@ -6,6 +6,8 @@ import type { IconProps } from "../Icon";
|
|
|
6
6
|
* `on-primary` keeps a count legible when the badge sits on a solid primary
|
|
7
7
|
* fill (e.g. the active segment of a segmented control): it inverts to
|
|
8
8
|
* `on-primary` text over a translucent `on-primary` tint.
|
|
9
|
+
* `on-primary-solid` is the high-contrast companion for small caption text on
|
|
10
|
+
* that same fill: a solid `on-primary` chip with `primary` text.
|
|
9
11
|
*/
|
|
10
12
|
export type BadgeTone =
|
|
11
13
|
| "neutral"
|
|
@@ -14,7 +16,8 @@ export type BadgeTone =
|
|
|
14
16
|
| "warning"
|
|
15
17
|
| "error"
|
|
16
18
|
| "info"
|
|
17
|
-
| "on-primary"
|
|
19
|
+
| "on-primary"
|
|
20
|
+
| "on-primary-solid";
|
|
18
21
|
export type BadgeSize = "sm" | "md" | "lg";
|
|
19
22
|
|
|
20
23
|
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
@@ -32,6 +35,7 @@ const TONE: Record<BadgeTone, string> = {
|
|
|
32
35
|
error: "bg-semantic-error-soft text-semantic-error",
|
|
33
36
|
info: "bg-semantic-info-soft text-semantic-info",
|
|
34
37
|
"on-primary": "bg-on-primary/20 text-on-primary",
|
|
38
|
+
"on-primary-solid": "bg-on-primary text-primary",
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
const SIZE: Record<BadgeSize, string> = {
|
|
@@ -38,6 +38,12 @@ export interface ButtonProps extends React.ComponentPropsWithoutRef<"button"> {
|
|
|
38
38
|
fullWidth?: boolean;
|
|
39
39
|
/** Square, icon-only shape (no horizontal padding). Pass the glyph as children and set aria-label. */
|
|
40
40
|
iconOnly?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Row variants only: lets the label wrap onto multiple lines instead of
|
|
43
|
+
* truncating, with the row growing to fit and leading / trailing icons
|
|
44
|
+
* aligned to the first line.
|
|
45
|
+
*/
|
|
46
|
+
wrap?: boolean;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
@@ -48,7 +54,7 @@ const base =
|
|
|
48
54
|
|
|
49
55
|
/** Full-width rows: no press scale, left-aligned, background-only press. */
|
|
50
56
|
const rowBase =
|
|
51
|
-
"relative flex w-full min-w-0 select-none items-center
|
|
57
|
+
"relative flex w-full min-w-0 select-none items-center border text-left font-weight-body-md cursor-pointer transition-colors duration-150 ease-out focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50";
|
|
52
58
|
|
|
53
59
|
const isRow = (v: ButtonVariant) => v === "field" || v === "item" || v === "media";
|
|
54
60
|
|
|
@@ -77,6 +83,13 @@ const sizes: Record<ButtonSize, string> = {
|
|
|
77
83
|
lg: "h-9 gap-sm rounded-md px-base text-body-md",
|
|
78
84
|
};
|
|
79
85
|
|
|
86
|
+
/** Same rhythm as `sizes`, but auto height so a wrapped label can grow. */
|
|
87
|
+
const wrapSizes: Record<ButtonSize, string> = {
|
|
88
|
+
sm: "gap-xs rounded-sm px-sm py-xs text-body-sm",
|
|
89
|
+
md: "gap-sm rounded-md px-md py-xs text-body-md",
|
|
90
|
+
lg: "gap-sm rounded-md px-base py-sm text-body-md",
|
|
91
|
+
};
|
|
92
|
+
|
|
80
93
|
const iconOnlySizes: Record<ButtonSize, string> = {
|
|
81
94
|
sm: "h-7 w-7 rounded-sm px-0",
|
|
82
95
|
md: "h-8 w-8 rounded-md px-0",
|
|
@@ -96,6 +109,7 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
96
109
|
trailingIcon,
|
|
97
110
|
fullWidth = false,
|
|
98
111
|
iconOnly = false,
|
|
112
|
+
wrap = false,
|
|
99
113
|
disabled,
|
|
100
114
|
type = "button",
|
|
101
115
|
className,
|
|
@@ -106,6 +120,8 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
106
120
|
ref,
|
|
107
121
|
) => {
|
|
108
122
|
const media = variant === "media";
|
|
123
|
+
const row = isRow(variant);
|
|
124
|
+
const wrappedRow = row && wrap && !iconOnly;
|
|
109
125
|
return (
|
|
110
126
|
<button
|
|
111
127
|
ref={ref}
|
|
@@ -115,13 +131,22 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
115
131
|
aria-disabled={loading || undefined}
|
|
116
132
|
onClick={loading ? (e) => e.preventDefault() : onClick}
|
|
117
133
|
className={cn(
|
|
118
|
-
|
|
134
|
+
row
|
|
135
|
+
? cn(
|
|
136
|
+
rowBase,
|
|
137
|
+
wrappedRow
|
|
138
|
+
? "items-start whitespace-normal"
|
|
139
|
+
: "items-center whitespace-nowrap",
|
|
140
|
+
)
|
|
141
|
+
: base,
|
|
119
142
|
variants[variant],
|
|
120
143
|
media
|
|
121
144
|
? "rounded-lg"
|
|
122
145
|
: iconOnly
|
|
123
146
|
? iconOnlySizes[size]
|
|
124
|
-
:
|
|
147
|
+
: wrappedRow
|
|
148
|
+
? wrapSizes[size]
|
|
149
|
+
: sizes[size],
|
|
125
150
|
fullWidth && "w-full",
|
|
126
151
|
loading && "pointer-events-none",
|
|
127
152
|
className,
|
|
@@ -136,7 +161,13 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
136
161
|
/>
|
|
137
162
|
) : (
|
|
138
163
|
leadingIcon && (
|
|
139
|
-
<span
|
|
164
|
+
<span
|
|
165
|
+
className={cn(
|
|
166
|
+
"inline-flex shrink-0 items-center",
|
|
167
|
+
wrappedRow && "self-start",
|
|
168
|
+
)}
|
|
169
|
+
aria-hidden="true"
|
|
170
|
+
>
|
|
140
171
|
{leadingIcon}
|
|
141
172
|
</span>
|
|
142
173
|
)
|
|
@@ -146,12 +177,24 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
146
177
|
) : media ? (
|
|
147
178
|
children
|
|
148
179
|
) : (
|
|
149
|
-
<span
|
|
180
|
+
<span
|
|
181
|
+
className={
|
|
182
|
+
row
|
|
183
|
+
? cn("min-w-0 flex-1", !wrappedRow && "truncate")
|
|
184
|
+
: undefined
|
|
185
|
+
}
|
|
186
|
+
>
|
|
150
187
|
{loading && loadingText ? loadingText : children}
|
|
151
188
|
</span>
|
|
152
189
|
)}
|
|
153
190
|
{!loading && trailingIcon && (
|
|
154
|
-
<span
|
|
191
|
+
<span
|
|
192
|
+
className={cn(
|
|
193
|
+
"inline-flex shrink-0 items-center",
|
|
194
|
+
wrappedRow && "self-start",
|
|
195
|
+
)}
|
|
196
|
+
aria-hidden="true"
|
|
197
|
+
>
|
|
155
198
|
{trailingIcon}
|
|
156
199
|
</span>
|
|
157
200
|
)}
|
|
@@ -19,7 +19,7 @@ export interface SegmentedControlItem {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface SegmentedControlProps
|
|
22
|
-
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
22
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "className"> {
|
|
23
23
|
items: SegmentedControlItem[];
|
|
24
24
|
/** Selected value. Pass `undefined` for "no segment selected". */
|
|
25
25
|
value: string | undefined;
|
|
@@ -27,6 +27,13 @@ export interface SegmentedControlProps
|
|
|
27
27
|
size?: "sm" | "md";
|
|
28
28
|
/** Drop the frame (border, surface, shadow), e.g. when nested in a toolbar. */
|
|
29
29
|
bare?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Stretch the control to the full width of its container and share the space
|
|
32
|
+
* between segments. Defaults to `false`, which sizes the control to content.
|
|
33
|
+
*/
|
|
34
|
+
fullWidth?: boolean;
|
|
35
|
+
/** Lands on the tablist itself, so consumers can shape it without a wrapper. */
|
|
36
|
+
className?: string;
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
@@ -54,9 +61,25 @@ const pillRadius: Record<"sm" | "md", string> = {
|
|
|
54
61
|
* A compact segmented control: one framed surface, a single primary indicator
|
|
55
62
|
* that slides between segments, and segments that only report the chosen value
|
|
56
63
|
* (`onValueChange`) — no panels, unlike Tabs.
|
|
64
|
+
*
|
|
65
|
+
* The active segment carries a `bg-primary` fallback that the sliding pill
|
|
66
|
+
* replaces once it is measured, so the on-primary label never renders
|
|
67
|
+
* invisible on first paint.
|
|
57
68
|
*/
|
|
58
69
|
export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(
|
|
59
|
-
(
|
|
70
|
+
(
|
|
71
|
+
{
|
|
72
|
+
items,
|
|
73
|
+
value,
|
|
74
|
+
onValueChange,
|
|
75
|
+
size = "sm",
|
|
76
|
+
bare = false,
|
|
77
|
+
fullWidth = false,
|
|
78
|
+
className,
|
|
79
|
+
...rest
|
|
80
|
+
},
|
|
81
|
+
ref,
|
|
82
|
+
) => {
|
|
60
83
|
const trackRef = React.useRef<HTMLDivElement | null>(null);
|
|
61
84
|
const itemRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});
|
|
62
85
|
const [pill, setPill] = React.useState<{ offset: number; width: number } | null>(null);
|
|
@@ -96,7 +119,11 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
96
119
|
};
|
|
97
120
|
|
|
98
121
|
return (
|
|
99
|
-
<div
|
|
122
|
+
<div
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={cn("min-w-0", fullWidth ? "flex w-full" : "inline-flex max-w-full")}
|
|
125
|
+
{...rest}
|
|
126
|
+
>
|
|
100
127
|
<div
|
|
101
128
|
ref={trackRef}
|
|
102
129
|
role="tablist"
|
|
@@ -106,7 +133,9 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
106
133
|
"relative isolate inline-flex max-w-full items-center overflow-x-auto rounded-lg",
|
|
107
134
|
frame[size],
|
|
108
135
|
bare ? "bg-transparent" : "border border-hairline bg-canvas shadow-sm",
|
|
136
|
+
fullWidth && "flex w-full",
|
|
109
137
|
"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
138
|
+
className,
|
|
110
139
|
)}
|
|
111
140
|
>
|
|
112
141
|
{!bare ? (
|
|
@@ -128,6 +157,12 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
128
157
|
const active = item.value === value;
|
|
129
158
|
const iconOnly = Boolean(item.icon) && item.label == null;
|
|
130
159
|
const glyphSize = size === "sm" ? 14 : 16;
|
|
160
|
+
/**
|
|
161
|
+
* Until the sliding pill is measured (first paint, before the
|
|
162
|
+
* layout effect runs) the active segment paints its own primary
|
|
163
|
+
* fill, so `on-primary` text is never invisible on `canvas`.
|
|
164
|
+
*/
|
|
165
|
+
const pillFallback = !bare && active && !pill ? "bg-primary" : false;
|
|
131
166
|
return (
|
|
132
167
|
<Button
|
|
133
168
|
key={item.value}
|
|
@@ -144,7 +179,7 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
144
179
|
iconOnly={iconOnly}
|
|
145
180
|
disabled={item.disabled}
|
|
146
181
|
onClick={() => onValueChange(item.value)}
|
|
147
|
-
className={segmentInteraction}
|
|
182
|
+
className={cn(segmentInteraction, pillFallback, fullWidth && "flex-1")}
|
|
148
183
|
>
|
|
149
184
|
{iconOnly ? (
|
|
150
185
|
<Icon name={item.icon!} size={glyphSize} />
|
|
@@ -161,7 +196,7 @@ export const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedContro
|
|
|
161
196
|
{item.count !== undefined ? (
|
|
162
197
|
<Badge
|
|
163
198
|
size="sm"
|
|
164
|
-
tone={active ? "on-primary" : "neutral"}
|
|
199
|
+
tone={active ? "on-primary-solid" : "neutral"}
|
|
165
200
|
aria-label={`${item.count} items`}
|
|
166
201
|
className="min-w-5 justify-center"
|
|
167
202
|
>
|
|
@@ -21,11 +21,18 @@ const STATE_ITEMS: SegmentedControlItem[] = [
|
|
|
21
21
|
{ value: "archived", label: "Archived", disabled: true },
|
|
22
22
|
];
|
|
23
23
|
|
|
24
|
+
const RANGE_ITEMS: SegmentedControlItem[] = [
|
|
25
|
+
{ value: "day", label: "Day" },
|
|
26
|
+
{ value: "week", label: "Week" },
|
|
27
|
+
{ value: "month", label: "Month" },
|
|
28
|
+
];
|
|
29
|
+
|
|
24
30
|
export default function SegmentedControlPreview() {
|
|
25
31
|
const [kind, setKind] = React.useState("all");
|
|
26
32
|
const [viewport, setViewport] = React.useState("desktop");
|
|
27
33
|
const [state, setState] = React.useState("review");
|
|
28
34
|
const [toolbarView, setToolbarView] = React.useState("grid");
|
|
35
|
+
const [range, setRange] = React.useState("week");
|
|
29
36
|
|
|
30
37
|
return (
|
|
31
38
|
<div className="w-full max-w-3xl mx-auto space-y-xl p-lg">
|
|
@@ -64,6 +71,20 @@ export default function SegmentedControlPreview() {
|
|
|
64
71
|
/>
|
|
65
72
|
</section>
|
|
66
73
|
|
|
74
|
+
<section className="space-y-sm">
|
|
75
|
+
<p className="text-caption text-muted">
|
|
76
|
+
Full width — segments share the available space
|
|
77
|
+
</p>
|
|
78
|
+
<SegmentedControl
|
|
79
|
+
items={RANGE_ITEMS}
|
|
80
|
+
value={range}
|
|
81
|
+
onValueChange={setRange}
|
|
82
|
+
size="md"
|
|
83
|
+
fullWidth
|
|
84
|
+
aria-label="Range"
|
|
85
|
+
/>
|
|
86
|
+
</section>
|
|
87
|
+
|
|
67
88
|
<section className="space-y-sm">
|
|
68
89
|
<p className="text-caption text-muted">Bare — nested inside a toolbar row</p>
|
|
69
90
|
<div className="space-y-xs rounded-lg border border-hairline bg-surface-soft p-sm">
|