@cjlapao/ui-kit 0.2.6 → 0.2.7

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/markdown.cjs CHANGED
@@ -300,9 +300,11 @@ var inputVariantTokens = {
300
300
  translucent: true
301
301
  }
302
302
  };
303
+ var FILL_CLASS = /^(?:dark:)?bg-(?:[a-z]+-\d{2,3}(?:\/\d+)?|white(?:\/\d+)?|black(?:\/\d+)?|transparent|current|inherit)$/;
304
+ var stripFillClass = (surface) => surface.split(/\s+/).filter((token) => token !== "" && !FILL_CLASS.test(token)).join(" ");
303
305
  var TEXT_COLOR_CLASS = /^(?:dark:)?text-(?:[a-z]+-\d{2,3}(?:\/\d+)?|white(?:\/\d+)?|black(?:\/\d+)?|transparent|current|inherit)$/;
304
306
  var hasTextColor = (className) => Boolean(className) && className.split(/\s+/).some((token) => TEXT_COLOR_CLASS.test(token));
305
- var getInputVariantTokens = (variant, tone = "neutral", corner = "auto") => {
307
+ var getInputVariantTokens = (variant, tone = "neutral", corner = "auto", options) => {
306
308
  const tokens = inputVariantTokens[variant] ?? inputVariantTokens.elevated;
307
309
  let resolved = tokens;
308
310
  if (variant === "ghost") {
@@ -316,6 +318,13 @@ var getInputVariantTokens = (variant, tone = "neutral", corner = "auto") => {
316
318
  ].join(" ")
317
319
  };
318
320
  }
321
+ if (variant === "glass" && options?.explicitTone) {
322
+ const tint = options.explicitTone;
323
+ resolved = {
324
+ ...resolved,
325
+ surface: `${stripFillClass(resolved.surface)} bg-${tint}-100/45 dark:bg-${tint}-500/10`
326
+ };
327
+ }
319
328
  if (corner === "auto") return resolved;
320
329
  return {
321
330
  ...resolved,
@@ -1756,7 +1765,8 @@ var DE_KIT_CATALOG = {
1756
1765
  collapseSidebar: "Seitenleiste einklappen",
1757
1766
  verbCollapse: "Einklappen",
1758
1767
  verbExpand: "Auskklappen",
1759
- toggleSubmenu: "{verb} Untermen\xFC {label}"
1768
+ toggleSubmenu: "{verb} Untermen\xFC {label}",
1769
+ dismissCta: "Ausblenden"
1760
1770
  },
1761
1771
  splitview: {
1762
1772
  moreOptions: "Weitere Optionen",
@@ -2100,7 +2110,8 @@ var EN_KIT_CATALOG = {
2100
2110
  collapseSidebar: "Collapse sidebar",
2101
2111
  verbCollapse: "Collapse",
2102
2112
  verbExpand: "Expand",
2103
- toggleSubmenu: "{verb} {label} submenu"
2113
+ toggleSubmenu: "{verb} {label} submenu",
2114
+ dismissCta: "Dismiss"
2104
2115
  },
2105
2116
  splitview: {
2106
2117
  moreOptions: "More options",
@@ -2444,7 +2455,8 @@ var ES_KIT_CATALOG = {
2444
2455
  collapseSidebar: "Contraer barra lateral",
2445
2456
  verbCollapse: "Contraer",
2446
2457
  verbExpand: "Expandir",
2447
- toggleSubmenu: "{verb} el submen\xFA {label}"
2458
+ toggleSubmenu: "{verb} el submen\xFA {label}",
2459
+ dismissCta: "Descartar"
2448
2460
  },
2449
2461
  splitview: {
2450
2462
  moreOptions: "M\xE1s opciones",
@@ -2788,7 +2800,8 @@ var FR_KIT_CATALOG = {
2788
2800
  collapseSidebar: "R\xE9duire la barre lat\xE9rale",
2789
2801
  verbCollapse: "R\xE9duire",
2790
2802
  verbExpand: "D\xE9ployer",
2791
- toggleSubmenu: "{verb} le sous-menu {label}"
2803
+ toggleSubmenu: "{verb} le sous-menu {label}",
2804
+ dismissCta: "Ignorer"
2792
2805
  },
2793
2806
  splitview: {
2794
2807
  moreOptions: "Plus d\\'options",
@@ -3132,7 +3145,8 @@ var PT_KIT_CATALOG = {
3132
3145
  collapseSidebar: "Recolher barra lateral",
3133
3146
  verbCollapse: "Recolher",
3134
3147
  verbExpand: "Expandir",
3135
- toggleSubmenu: "{verb} o submenu {label}"
3148
+ toggleSubmenu: "{verb} o submenu {label}",
3149
+ dismissCta: "Dispensar"
3136
3150
  },
3137
3151
  splitview: {
3138
3152
  moreOptions: "Mais op\xE7\xF5es",
@@ -9328,6 +9342,43 @@ var Loader = ({
9328
9342
  };
9329
9343
  var Loader_default = Loader;
9330
9344
 
9345
+ // ../common/a11y/interactive.ts
9346
+ var INTERACTIVE_SELECTOR = [
9347
+ "a[href]",
9348
+ "button",
9349
+ "input",
9350
+ "select",
9351
+ "textarea",
9352
+ "summary",
9353
+ '[contenteditable=""]',
9354
+ '[contenteditable="true"]',
9355
+ "audio[controls]",
9356
+ "video[controls]",
9357
+ '[role="button"]',
9358
+ '[role="link"]',
9359
+ '[role="checkbox"]',
9360
+ '[role="radio"]',
9361
+ '[role="switch"]',
9362
+ '[role="tab"]',
9363
+ '[role="menuitem"]',
9364
+ '[role="option"]',
9365
+ '[role="combobox"]',
9366
+ '[role="slider"]'
9367
+ ].join(",");
9368
+ var NO_CLICK_ATTR_SELECTOR = "[data-panel-no-click]";
9369
+ function isClickOwnedByDescendant(root, target) {
9370
+ if (!root || !target) return false;
9371
+ if (typeof target.closest !== "function") return false;
9372
+ const hit = target.closest(
9373
+ `${INTERACTIVE_SELECTOR},${NO_CLICK_ATTR_SELECTOR}`
9374
+ );
9375
+ return hit !== null && hit !== root && root.contains(hit);
9376
+ }
9377
+ function hasInteractiveDescendant(root) {
9378
+ if (!root || typeof root.querySelector !== "function") return false;
9379
+ return root.querySelector(INTERACTIVE_SELECTOR) !== null;
9380
+ }
9381
+
9331
9382
  // src/components/Panel.tsx
9332
9383
  var import_jsx_runtime156 = require("react/jsx-runtime");
9333
9384
  var variantBaseStyles = {
@@ -9357,7 +9408,12 @@ var actionWrapperLayout = {
9357
9408
  inline: "flex-wrap items-center gap-3"
9358
9409
  };
9359
9410
  var defaultActionColor = "neutral";
9360
- var SkeletonBar = ({ width, height = "h-3", ink = "bg-black/10 dark:bg-white/10", className }) => /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
9411
+ var SkeletonBar = ({
9412
+ width,
9413
+ height = "h-3",
9414
+ ink = "bg-black/10 dark:bg-white/10",
9415
+ className
9416
+ }) => /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
9361
9417
  "span",
9362
9418
  {
9363
9419
  className: (0, import_classnames7.default)("block rounded-full", ink, height, className),
@@ -9455,6 +9511,19 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9455
9511
  hoverShadow = false,
9456
9512
  decoration = "none",
9457
9513
  hoverable,
9514
+ clickable,
9515
+ // Pulled out of `rest` so the card can wrap them. `onClick` becomes the
9516
+ // guarded handler below; `role`, `tabIndex` and `onKeyDown` are the
9517
+ // caller's overrides, and they win over what a clickable card would have
9518
+ // set for itself.
9519
+ onClick,
9520
+ role,
9521
+ tabIndex,
9522
+ onKeyDown,
9523
+ // Chained, not replaced: the drag measurement has to see the press and
9524
+ // the release, and the caller still gets both.
9525
+ onMouseDown,
9526
+ onMouseUp,
9458
9527
  titleClassName,
9459
9528
  subtitleClassName,
9460
9529
  descriptionClassName,
@@ -9472,7 +9541,54 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9472
9541
  const resolvedTone = resolvePanelTone(tone, color);
9473
9542
  const palette = getPanelToneStyles(resolvedTone);
9474
9543
  const surfaceText = getSurfaceTextTokens(variant);
9475
- const isHoverable = hoverable ?? Boolean(rest.onClick);
9544
+ const isHoverable = hoverable ?? Boolean(onClick);
9545
+ const isClickable = clickable ?? Boolean(onClick);
9546
+ const trigger = getSurfaceTriggerTokens(resolvedTone);
9547
+ const sectionRef = import_react155.default.useRef(null);
9548
+ const bodyRef = import_react155.default.useRef(null);
9549
+ const setSectionRef = import_react155.default.useCallback(
9550
+ (node) => {
9551
+ sectionRef.current = node;
9552
+ if (typeof ref === "function") ref(node);
9553
+ else if (ref)
9554
+ ref.current = node;
9555
+ },
9556
+ [ref]
9557
+ );
9558
+ const pressRef = import_react155.default.useRef(null);
9559
+ const draggedRef = import_react155.default.useRef(false);
9560
+ const handleCardMouseDown = (event) => {
9561
+ pressRef.current = { x: event.clientX, y: event.clientY };
9562
+ draggedRef.current = false;
9563
+ };
9564
+ const handleCardMouseUp = (event) => {
9565
+ const press = pressRef.current;
9566
+ if (!press) return;
9567
+ draggedRef.current = Math.abs(event.clientX - press.x) > 4 || Math.abs(event.clientY - press.y) > 4;
9568
+ };
9569
+ const handleCardClick = (event) => {
9570
+ if (isClickOwnedByDescendant(sectionRef.current, event.target)) return;
9571
+ if (draggedRef.current) {
9572
+ draggedRef.current = false;
9573
+ return;
9574
+ }
9575
+ onClick?.(event);
9576
+ };
9577
+ const handleCardKeyDown = (event) => {
9578
+ if (event.target !== sectionRef.current) return;
9579
+ if (event.key !== "Enter" && event.key !== " ") return;
9580
+ event.preventDefault();
9581
+ sectionRef.current?.click();
9582
+ };
9583
+ import_react155.default.useEffect(() => {
9584
+ if (!isClickable) return;
9585
+ if (hasInteractiveDescendant(bodyRef.current)) {
9586
+ devWarnA11yOnce(
9587
+ "Panel:clickable-nested-interactive",
9588
+ "Panel: a clickable Panel whose body contains controls is announced as a single button named after all of its text, with those controls nested inside it. Pass clickable={false} when the body owns the interaction, or render the card's primary action as a real Button/Link."
9589
+ );
9590
+ }
9591
+ }, [isClickable, loading]);
9476
9592
  const isGlass = GLASS_VARIANTS.includes(variant);
9477
9593
  const resolvedSpecularMode = (() => {
9478
9594
  if (specularMode !== void 0) return specularMode;
@@ -9628,6 +9744,7 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9628
9744
  const bodyContent = children ? /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
9629
9745
  "div",
9630
9746
  {
9747
+ ref: bodyRef,
9631
9748
  className: (0, import_classnames7.default)(
9632
9749
  padding === "none" ? "" : "space-y-3 leading-6",
9633
9750
  // min-h-0 lets this flex item shrink below its content height, so
@@ -9738,7 +9855,7 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9738
9855
  return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(SurfaceProvider, { variant, children: /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(
9739
9856
  "section",
9740
9857
  {
9741
- ref,
9858
+ ref: setSectionRef,
9742
9859
  className: (0, import_classnames7.default)(
9743
9860
  "relative flex w-full min-h-0 flex-col overflow-hidden shrink-0",
9744
9861
  !isOverlay && surfaceText.body,
@@ -9748,7 +9865,15 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9748
9865
  fullWidth ? "w-full" : void 0,
9749
9866
  isOverlay ? overlayClasses : void 0,
9750
9867
  hoverShadow && "transition-shadow duration-200 hover:shadow-xl hover:-translate-y-[1px]",
9751
- isHoverable && "group cursor-pointer",
9868
+ isHoverable && "group",
9869
+ // Additive, not moved. A hoverable-only panel has shown a pointer
9870
+ // cursor as long as it has existed, so callers must keep it; a
9871
+ // clickable one now gets it even with `hoverable={false}`.
9872
+ (isHoverable || isClickable) && (disabled ? "cursor-not-allowed" : "cursor-pointer"),
9873
+ // The ring is the shared trigger token, whose inset exists precisely
9874
+ // because an outer ring is clipped by `overflow: hidden` — which
9875
+ // every Panel has.
9876
+ isClickable && !disabled && trigger.focusRing,
9752
9877
  isHoverable && hoverColorName && `hover:bg-${hoverColorName}-50 dark:hover:bg-${hoverColorName}-900/20`,
9753
9878
  className
9754
9879
  ),
@@ -9757,6 +9882,19 @@ var Panel = import_react155.default.forwardRef(function Panel2({
9757
9882
  "data-tone": resolvedTone,
9758
9883
  "aria-busy": loading,
9759
9884
  ...rest,
9885
+ role: role ?? (isClickable ? "button" : void 0),
9886
+ tabIndex: tabIndex ?? (isClickable ? disabled ? -1 : 0 : void 0),
9887
+ "aria-disabled": isClickable && disabled ? true : void 0,
9888
+ onClick: disabled || !onClick ? void 0 : handleCardClick,
9889
+ onMouseDown: disabled || !onClick ? void 0 : (event) => {
9890
+ onMouseDown?.(event);
9891
+ handleCardMouseDown(event);
9892
+ },
9893
+ onMouseUp: disabled || !onClick ? void 0 : (event) => {
9894
+ onMouseUp?.(event);
9895
+ handleCardMouseUp(event);
9896
+ },
9897
+ onKeyDown: onKeyDown ?? (isClickable && !disabled && onClick ? handleCardKeyDown : void 0),
9760
9898
  children: [
9761
9899
  isOverlay && !showSkeleton && /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(import_jsx_runtime156.Fragment, { children: [
9762
9900
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "h-full w-full", children: media }) }),
@@ -9931,12 +10069,13 @@ var SearchBar = ({
9931
10069
  leadingIcon = "Search",
9932
10070
  variant = "elevated",
9933
10071
  size = "md",
9934
- color = "blue",
10072
+ color: colorProp,
9935
10073
  gradientFrom,
9936
10074
  gradientTo,
9937
10075
  glowIntensity = DEFAULT_GLOW_INTENSITY,
9938
10076
  loading = false
9939
10077
  }) => {
10078
+ const color = colorProp ?? "blue";
9940
10079
  const t = useKitT();
9941
10080
  const [resolvedFrom, resolvedTo] = resolveGlowGradient(
9942
10081
  color,
@@ -10046,7 +10185,9 @@ var SearchBar = ({
10046
10185
  }
10047
10186
  ) : null;
10048
10187
  const sizeToken = getFieldSizeTokens(size);
10049
- const variantTokens = getInputVariantTokens(variant, color);
10188
+ const variantTokens = getInputVariantTokens(variant, color, "auto", {
10189
+ explicitTone: colorProp
10190
+ });
10050
10191
  const bar = /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)(
10051
10192
  "div",
10052
10193
  {
@@ -10162,6 +10303,7 @@ var FITTING_THUMB = { size: 0, offset: 0, ratio: 0 };
10162
10303
  var ScrollArea = ({
10163
10304
  variant = "auto",
10164
10305
  mask = false,
10306
+ horizontal = true,
10165
10307
  tabIndex = 0,
10166
10308
  contentClassName,
10167
10309
  viewportClassName,
@@ -10215,12 +10357,14 @@ var ScrollArea = ({
10215
10357
  const viewport = viewportRef.current;
10216
10358
  if (!viewport) return;
10217
10359
  setOverflow({
10218
- x: viewport.scrollWidth - viewport.clientWidth > 1,
10360
+ x: horizontal && viewport.scrollWidth - viewport.clientWidth > 1,
10219
10361
  y: viewport.scrollHeight - viewport.clientHeight > 1
10220
10362
  });
10221
10363
  setThumbY(thumb(viewport, yTrackRef.current, "y"));
10222
- setThumbX(thumb(viewport, xTrackRef.current, "x"));
10223
- }, [thumb]);
10364
+ setThumbX(
10365
+ horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB
10366
+ );
10367
+ }, [thumb, horizontal]);
10224
10368
  (0, import_react157.useEffect)(() => {
10225
10369
  update();
10226
10370
  let observer;
@@ -10329,7 +10473,10 @@ var ScrollArea = ({
10329
10473
  "data-overflow-x": overflow.x ? "" : void 0,
10330
10474
  "data-overflow-y": overflow.y ? "" : void 0,
10331
10475
  onScroll: handleScroll,
10332
- style: maskStyle(),
10476
+ style: {
10477
+ ...maskStyle(),
10478
+ ...horizontal ? null : { overflowX: "hidden" }
10479
+ },
10333
10480
  className: (0, import_classnames9.default)(
10334
10481
  "h-full w-full max-h-[inherit] overflow-auto rounded-[inherit] outline-none",
10335
10482
  // `max-height: inherit` is what makes a `max-h-*` frame work: a
@@ -10383,7 +10530,7 @@ var ScrollArea = ({
10383
10530
  ) })
10384
10531
  }
10385
10532
  ),
10386
- /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
10533
+ horizontal && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
10387
10534
  "div",
10388
10535
  {
10389
10536
  "data-slot": "scrollarea-scrollbar",