@salemcobalt/ui 0.2.0-rc.14 → 0.2.0-rc.16

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.js CHANGED
@@ -1342,19 +1342,11 @@ var sizeByLevel = {
1342
1342
  5: "md",
1343
1343
  6: "sm"
1344
1344
  };
1345
- function Heading({
1346
- level = 2,
1347
- size,
1348
- as,
1349
- tone = "default",
1350
- truncate = false,
1351
- className,
1352
- ...rest
1353
- }) {
1345
+ function Heading({ level = 2, size, as, tone, truncate = false, className, ...rest }) {
1354
1346
  return createElement3(as ?? `h${level}`, {
1355
1347
  className: cx("sc-heading", className),
1356
1348
  "data-size": size ?? sizeByLevel[level],
1357
- "data-tone": tone,
1349
+ "data-tone": tone ?? (size === "overline" ? "muted" : "default"),
1358
1350
  "data-truncate": truncate || void 0,
1359
1351
  ...rest
1360
1352
  });
@@ -1370,6 +1362,7 @@ function Text({
1370
1362
  align,
1371
1363
  truncate = false,
1372
1364
  numeric = false,
1365
+ family = "sans",
1373
1366
  className,
1374
1367
  style,
1375
1368
  ...rest
@@ -1383,6 +1376,7 @@ function Text({
1383
1376
  "data-align": align,
1384
1377
  "data-truncate": truncate === true ? "" : clamp2 !== void 0 ? "clamp" : void 0,
1385
1378
  "data-numeric": numeric || void 0,
1379
+ "data-family": family === "mono" ? "mono" : void 0,
1386
1380
  style: clamp2 !== void 0 ? { ...style, "--sc-text-lines": clamp2 } : style,
1387
1381
  ...rest
1388
1382
  });
@@ -2813,16 +2807,25 @@ function placePanel({ anchor, panel, viewport, gutter, offset, rtl = false }) {
2813
2807
  }
2814
2808
 
2815
2809
  // src/components/PriorityNav/PriorityNav.tsx
2816
- import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
2810
+ import { Fragment as Fragment9, jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
2817
2811
  var defaultCountLabel2 = (n) => n === 1 ? "1 link" : `${n} links`;
2818
2812
  var defaultLink = ({ children, ...props }) => /* @__PURE__ */ jsx31("a", { ...props, children });
2819
2813
  var keyOf = (item) => item.id ?? item.href;
2814
+ var badgeOf = (item) => item.badge === "dot" ? "dot" : typeof item.badge === "number" && item.badge > 0 && Number.isFinite(item.badge) ? item.badge : null;
2815
+ var badgeTextOf = (item) => {
2816
+ const badge = badgeOf(item);
2817
+ if (badge === null) return null;
2818
+ return item.badgeLabel ?? (badge === "dot" ? null : String(badge));
2819
+ };
2820
+ function Badge2({ value }) {
2821
+ return /* @__PURE__ */ jsx31("span", { className: "sc-priority-nav__badge", "data-kind": value === "dot" ? "dot" : "count", "aria-hidden": "true", children: value === "dot" ? null : value });
2822
+ }
2820
2823
  var supportsAnchor = () => typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name: --a");
2821
2824
  var supportsPopover = (el) => typeof el.showPopover === "function";
2822
2825
  function signatureOf(items) {
2823
2826
  return items.map((item) => {
2824
2827
  const text = typeof item.label === "string" || typeof item.label === "number" ? item.label : "";
2825
- return `${keyOf(item)}${text}`;
2828
+ return `${keyOf(item)}${text}${badgeOf(item) ?? ""}`;
2826
2829
  }).join("");
2827
2830
  }
2828
2831
  function PriorityNav({
@@ -2925,6 +2928,10 @@ function PriorityNav({
2925
2928
  const flags = measuring ? null : inlineFlags(items.length, current, fit.count);
2926
2929
  const overflow = flags ? items.filter((_, i) => !flags[i]) : [];
2927
2930
  const expanded = open && overflow.length > 0;
2931
+ const overflowBadges = overflow.map(badgeOf).filter((b) => b !== null);
2932
+ const overflowCount = overflowBadges.reduce((sum, b) => sum + (b === "dot" ? 0 : b), 0);
2933
+ const moreBadge = overflowCount > 0 ? overflowCount : overflowBadges.length > 0 ? "dot" : null;
2934
+ const moreBadgeText = overflow.map(badgeTextOf).filter((text) => text !== null).map((text) => `, ${text}`).join("");
2928
2935
  useLayoutEffect2(() => {
2929
2936
  const panel = panelRef.current;
2930
2937
  if (!panel || !supportsPopover(panel)) return;
@@ -2984,16 +2991,27 @@ function PriorityNav({
2984
2991
  const onBlur = (event) => {
2985
2992
  if (!event.currentTarget.contains(event.relatedTarget)) setOpen(false);
2986
2993
  };
2987
- const link = (item, inPanel) => renderLink(
2988
- {
2989
- href: item.href,
2990
- className: "sc-priority-nav__link",
2991
- "aria-current": item.current ? "page" : void 0,
2992
- onClick: inPanel ? () => setOpen(false) : void 0,
2993
- children: /* @__PURE__ */ jsx31("span", { className: "sc-priority-nav__label", children: item.label })
2994
- },
2995
- item
2996
- );
2994
+ const link = (item, inPanel) => {
2995
+ const badge = badgeOf(item);
2996
+ const badgeText = badgeTextOf(item);
2997
+ return renderLink(
2998
+ {
2999
+ href: item.href,
3000
+ className: "sc-priority-nav__link",
3001
+ "aria-current": item.current ? "page" : void 0,
3002
+ onClick: inPanel ? () => setOpen(false) : void 0,
3003
+ children: /* @__PURE__ */ jsxs26(Fragment9, { children: [
3004
+ /* @__PURE__ */ jsx31("span", { className: "sc-priority-nav__label", children: item.label }),
3005
+ badge !== null ? /* @__PURE__ */ jsx31(Badge2, { value: badge }) : null,
3006
+ badgeText !== null ? /* @__PURE__ */ jsxs26("span", { className: "sc-visually-hidden", children: [
3007
+ ", ",
3008
+ badgeText
3009
+ ] }) : null
3010
+ ] })
3011
+ },
3012
+ item
3013
+ );
3014
+ };
2997
3015
  return /* @__PURE__ */ jsx31(
2998
3016
  "nav",
2999
3017
  {
@@ -3028,8 +3046,10 @@ function PriorityNav({
3028
3046
  /* @__PURE__ */ jsx31("span", { className: "sc-priority-nav__toggle-label", children: moreLabel }),
3029
3047
  /* @__PURE__ */ jsxs26("span", { className: "sc-visually-hidden", children: [
3030
3048
  ", ",
3031
- moreCountLabel(overflow.length)
3049
+ moreCountLabel(overflow.length),
3050
+ moreBadgeText
3032
3051
  ] }),
3052
+ moreBadge !== null ? /* @__PURE__ */ jsx31(Badge2, { value: moreBadge }) : null,
3033
3053
  /* @__PURE__ */ jsx31(ChevronDownIcon, { size: "sm", className: "sc-priority-nav__chevron" })
3034
3054
  ]
3035
3055
  }
@@ -3476,6 +3496,127 @@ var FullScreenFlow = {
3476
3496
  Footer
3477
3497
  };
3478
3498
 
3499
+ // src/components/Score/Score.tsx
3500
+ import { jsx as jsx35, jsxs as jsxs30 } from "react/jsx-runtime";
3501
+ function Score({
3502
+ value,
3503
+ max = 100,
3504
+ tone = "accent",
3505
+ variant = "tile",
3506
+ size = "sm",
3507
+ caption,
3508
+ label = "Score",
3509
+ valueText,
3510
+ selected = false,
3511
+ className,
3512
+ style,
3513
+ ...rest
3514
+ }) {
3515
+ const scored = value !== null;
3516
+ const fraction = scored && max > 0 ? Math.min(1, Math.max(0, value / max)) : 0;
3517
+ return /* @__PURE__ */ jsxs30(
3518
+ "span",
3519
+ {
3520
+ className: cx("sc-score", className),
3521
+ "data-variant": variant,
3522
+ "data-size": variant === "tile" ? size : void 0,
3523
+ "data-tone": scored ? tone : void 0,
3524
+ "data-unscored": scored ? void 0 : true,
3525
+ "data-selected": selected || void 0,
3526
+ style: variant === "ring" ? { ...style, "--sc-score-fill": (fraction * 100).toFixed(2) } : style,
3527
+ ...rest,
3528
+ children: [
3529
+ /* @__PURE__ */ jsx35("span", { className: "sc-visually-hidden", children: valueText ?? (scored ? `${label} ${value} out of ${max}` : `${label}: not scored`) }),
3530
+ variant === "ring" ? /* @__PURE__ */ jsxs30("svg", { className: "sc-score__ring", viewBox: "0 0 64 64", "aria-hidden": "true", focusable: "false", children: [
3531
+ /* @__PURE__ */ jsx35("circle", { className: "sc-score__track", cx: "32", cy: "32", r: "29", pathLength: 100 }),
3532
+ fraction > 0 ? /* @__PURE__ */ jsx35("circle", { className: "sc-score__arc", cx: "32", cy: "32", r: "29", pathLength: 100 }) : null
3533
+ ] }) : null,
3534
+ /* @__PURE__ */ jsxs30("span", { className: "sc-score__body", "aria-hidden": "true", children: [
3535
+ /* @__PURE__ */ jsx35("span", { className: "sc-score__value", children: scored ? value : "\u2013" }),
3536
+ caption != null ? /* @__PURE__ */ jsx35("span", { className: "sc-score__caption", children: caption }) : null
3537
+ ] })
3538
+ ]
3539
+ }
3540
+ );
3541
+ }
3542
+
3543
+ // src/components/ReasonList/ReasonList.tsx
3544
+ import { jsx as jsx36 } from "react/jsx-runtime";
3545
+ function ReasonListRoot({ tone, size = "md", divider = false, className, ...rest }) {
3546
+ return /* @__PURE__ */ jsx36(
3547
+ "ul",
3548
+ {
3549
+ className: cx("sc-reason-list", className),
3550
+ "data-tone": tone,
3551
+ "data-size": size,
3552
+ "data-divider": divider || void 0,
3553
+ ...rest
3554
+ }
3555
+ );
3556
+ }
3557
+ function ReasonListItem({ className, ...rest }) {
3558
+ return /* @__PURE__ */ jsx36("li", { className: cx("sc-reason-list__item", className), ...rest });
3559
+ }
3560
+ var ReasonList = Object.assign(ReasonListRoot, { Item: ReasonListItem });
3561
+
3562
+ // src/components/WordDiff/WordDiff.tsx
3563
+ import { createElement as createElement7, Fragment as Fragment10 } from "react";
3564
+ import { Fragment as Fragment11, jsx as jsx37, jsxs as jsxs31 } from "react/jsx-runtime";
3565
+ var edges = /^(\s*)([\s\S]*?)(\s*)$/;
3566
+ function Change({ kind, text, label }) {
3567
+ const [, lead = "", core = "", trail = ""] = edges.exec(text) ?? [];
3568
+ if (!core) return /* @__PURE__ */ jsx37(Fragment11, { children: text });
3569
+ const Tag = kind === "added" ? "ins" : "del";
3570
+ return /* @__PURE__ */ jsxs31(Fragment11, { children: [
3571
+ lead,
3572
+ /* @__PURE__ */ jsxs31(Tag, { className: `sc-word-diff__${kind}`, children: [
3573
+ /* @__PURE__ */ jsxs31("span", { className: "sc-visually-hidden", children: [
3574
+ "[",
3575
+ label,
3576
+ ": "
3577
+ ] }),
3578
+ core,
3579
+ /* @__PURE__ */ jsx37("span", { className: "sc-visually-hidden", children: "]" })
3580
+ ] }),
3581
+ trail
3582
+ ] });
3583
+ }
3584
+ function WordDiff({
3585
+ parts,
3586
+ as = "p",
3587
+ size = "sm",
3588
+ addedLabel = "added",
3589
+ removedLabel = "removed",
3590
+ className,
3591
+ ...rest
3592
+ }) {
3593
+ const children = parts.map(
3594
+ (part, i) => part.kind === "same" ? /* @__PURE__ */ jsx37(Fragment10, { children: part.text }, i) : /* @__PURE__ */ jsx37(
3595
+ Change,
3596
+ {
3597
+ kind: part.kind,
3598
+ text: part.text,
3599
+ label: part.kind === "added" ? addedLabel : removedLabel
3600
+ },
3601
+ i
3602
+ )
3603
+ );
3604
+ return createElement7(
3605
+ as,
3606
+ { className: cx("sc-word-diff", className), "data-size": size, ...rest },
3607
+ children
3608
+ );
3609
+ }
3610
+
3611
+ // src/components/Quote/Quote.tsx
3612
+ import { jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
3613
+ function Quote({ label, className, children, ...rest }) {
3614
+ return /* @__PURE__ */ jsxs32("figure", { className: cx("sc-quote", className), ...rest, children: [
3615
+ /* @__PURE__ */ jsx38("figcaption", { className: "sc-quote__label", children: label }),
3616
+ /* @__PURE__ */ jsx38("blockquote", { className: "sc-quote__text", children })
3617
+ ] });
3618
+ }
3619
+
3479
3620
  // src/index.ts
3480
3621
  var version = "0.1.1";
3481
3622
  export {
@@ -3539,7 +3680,10 @@ export {
3539
3680
  Popover,
3540
3681
  PriorityNav,
3541
3682
  Progress,
3683
+ Quote,
3684
+ ReasonList,
3542
3685
  RefreshIcon,
3686
+ Score,
3543
3687
  SearchIcon,
3544
3688
  Select,
3545
3689
  SelectionBar,
@@ -3564,6 +3708,7 @@ export {
3564
3708
  UndoIcon,
3565
3709
  UserIcon,
3566
3710
  WarningIcon,
3711
+ WordDiff,
3567
3712
  XIcon,
3568
3713
  iconNames,
3569
3714
  useRowSelection,