@cjlapao/ui-kit 0.2.5 → 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.
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { u as CapsuleBlueprintParameter } from './CapsuleBlueprint-BI0jdbTt.cjs';
3
- export { ah as HelpButton } from './CapsuleBlueprint-BI0jdbTt.cjs';
2
+ import { u as CapsuleBlueprintParameter } from './CapsuleBlueprint-DzjbCo3k.cjs';
3
+ export { ah as HelpButton } from './CapsuleBlueprint-DzjbCo3k.cjs';
4
4
 
5
5
  interface MarkdownEditorProps {
6
6
  value?: string;
@@ -1,6 +1,6 @@
1
1
  import React__default from 'react';
2
- import { u as CapsuleBlueprintParameter } from './CapsuleBlueprint-BI0jdbTt.js';
3
- export { ah as HelpButton } from './CapsuleBlueprint-BI0jdbTt.js';
2
+ import { u as CapsuleBlueprintParameter } from './CapsuleBlueprint-DzjbCo3k.js';
3
+ export { ah as HelpButton } from './CapsuleBlueprint-DzjbCo3k.js';
4
4
 
5
5
  interface MarkdownEditorProps {
6
6
  value?: string;
package/dist/markdown.js CHANGED
@@ -265,9 +265,11 @@ var inputVariantTokens = {
265
265
  translucent: true
266
266
  }
267
267
  };
268
+ var FILL_CLASS = /^(?:dark:)?bg-(?:[a-z]+-\d{2,3}(?:\/\d+)?|white(?:\/\d+)?|black(?:\/\d+)?|transparent|current|inherit)$/;
269
+ var stripFillClass = (surface) => surface.split(/\s+/).filter((token) => token !== "" && !FILL_CLASS.test(token)).join(" ");
268
270
  var TEXT_COLOR_CLASS = /^(?:dark:)?text-(?:[a-z]+-\d{2,3}(?:\/\d+)?|white(?:\/\d+)?|black(?:\/\d+)?|transparent|current|inherit)$/;
269
271
  var hasTextColor = (className) => Boolean(className) && className.split(/\s+/).some((token) => TEXT_COLOR_CLASS.test(token));
270
- var getInputVariantTokens = (variant, tone = "neutral", corner = "auto") => {
272
+ var getInputVariantTokens = (variant, tone = "neutral", corner = "auto", options) => {
271
273
  const tokens = inputVariantTokens[variant] ?? inputVariantTokens.elevated;
272
274
  let resolved = tokens;
273
275
  if (variant === "ghost") {
@@ -281,6 +283,13 @@ var getInputVariantTokens = (variant, tone = "neutral", corner = "auto") => {
281
283
  ].join(" ")
282
284
  };
283
285
  }
286
+ if (variant === "glass" && options?.explicitTone) {
287
+ const tint = options.explicitTone;
288
+ resolved = {
289
+ ...resolved,
290
+ surface: `${stripFillClass(resolved.surface)} bg-${tint}-100/45 dark:bg-${tint}-500/10`
291
+ };
292
+ }
284
293
  if (corner === "auto") return resolved;
285
294
  return {
286
295
  ...resolved,
@@ -1726,7 +1735,8 @@ var DE_KIT_CATALOG = {
1726
1735
  collapseSidebar: "Seitenleiste einklappen",
1727
1736
  verbCollapse: "Einklappen",
1728
1737
  verbExpand: "Auskklappen",
1729
- toggleSubmenu: "{verb} Untermen\xFC {label}"
1738
+ toggleSubmenu: "{verb} Untermen\xFC {label}",
1739
+ dismissCta: "Ausblenden"
1730
1740
  },
1731
1741
  splitview: {
1732
1742
  moreOptions: "Weitere Optionen",
@@ -2070,7 +2080,8 @@ var EN_KIT_CATALOG = {
2070
2080
  collapseSidebar: "Collapse sidebar",
2071
2081
  verbCollapse: "Collapse",
2072
2082
  verbExpand: "Expand",
2073
- toggleSubmenu: "{verb} {label} submenu"
2083
+ toggleSubmenu: "{verb} {label} submenu",
2084
+ dismissCta: "Dismiss"
2074
2085
  },
2075
2086
  splitview: {
2076
2087
  moreOptions: "More options",
@@ -2414,7 +2425,8 @@ var ES_KIT_CATALOG = {
2414
2425
  collapseSidebar: "Contraer barra lateral",
2415
2426
  verbCollapse: "Contraer",
2416
2427
  verbExpand: "Expandir",
2417
- toggleSubmenu: "{verb} el submen\xFA {label}"
2428
+ toggleSubmenu: "{verb} el submen\xFA {label}",
2429
+ dismissCta: "Descartar"
2418
2430
  },
2419
2431
  splitview: {
2420
2432
  moreOptions: "M\xE1s opciones",
@@ -2758,7 +2770,8 @@ var FR_KIT_CATALOG = {
2758
2770
  collapseSidebar: "R\xE9duire la barre lat\xE9rale",
2759
2771
  verbCollapse: "R\xE9duire",
2760
2772
  verbExpand: "D\xE9ployer",
2761
- toggleSubmenu: "{verb} le sous-menu {label}"
2773
+ toggleSubmenu: "{verb} le sous-menu {label}",
2774
+ dismissCta: "Ignorer"
2762
2775
  },
2763
2776
  splitview: {
2764
2777
  moreOptions: "Plus d\\'options",
@@ -3102,7 +3115,8 @@ var PT_KIT_CATALOG = {
3102
3115
  collapseSidebar: "Recolher barra lateral",
3103
3116
  verbCollapse: "Recolher",
3104
3117
  verbExpand: "Expandir",
3105
- toggleSubmenu: "{verb} o submenu {label}"
3118
+ toggleSubmenu: "{verb} o submenu {label}",
3119
+ dismissCta: "Dispensar"
3106
3120
  },
3107
3121
  splitview: {
3108
3122
  moreOptions: "Mais op\xE7\xF5es",
@@ -9306,6 +9320,43 @@ var Loader = ({
9306
9320
  };
9307
9321
  var Loader_default = Loader;
9308
9322
 
9323
+ // ../common/a11y/interactive.ts
9324
+ var INTERACTIVE_SELECTOR = [
9325
+ "a[href]",
9326
+ "button",
9327
+ "input",
9328
+ "select",
9329
+ "textarea",
9330
+ "summary",
9331
+ '[contenteditable=""]',
9332
+ '[contenteditable="true"]',
9333
+ "audio[controls]",
9334
+ "video[controls]",
9335
+ '[role="button"]',
9336
+ '[role="link"]',
9337
+ '[role="checkbox"]',
9338
+ '[role="radio"]',
9339
+ '[role="switch"]',
9340
+ '[role="tab"]',
9341
+ '[role="menuitem"]',
9342
+ '[role="option"]',
9343
+ '[role="combobox"]',
9344
+ '[role="slider"]'
9345
+ ].join(",");
9346
+ var NO_CLICK_ATTR_SELECTOR = "[data-panel-no-click]";
9347
+ function isClickOwnedByDescendant(root, target) {
9348
+ if (!root || !target) return false;
9349
+ if (typeof target.closest !== "function") return false;
9350
+ const hit = target.closest(
9351
+ `${INTERACTIVE_SELECTOR},${NO_CLICK_ATTR_SELECTOR}`
9352
+ );
9353
+ return hit !== null && hit !== root && root.contains(hit);
9354
+ }
9355
+ function hasInteractiveDescendant(root) {
9356
+ if (!root || typeof root.querySelector !== "function") return false;
9357
+ return root.querySelector(INTERACTIVE_SELECTOR) !== null;
9358
+ }
9359
+
9309
9360
  // src/components/Panel.tsx
9310
9361
  import { Fragment as Fragment3, jsx as jsx156, jsxs as jsxs58 } from "react/jsx-runtime";
9311
9362
  var variantBaseStyles = {
@@ -9335,7 +9386,12 @@ var actionWrapperLayout = {
9335
9386
  inline: "flex-wrap items-center gap-3"
9336
9387
  };
9337
9388
  var defaultActionColor = "neutral";
9338
- var SkeletonBar = ({ width, height = "h-3", ink = "bg-black/10 dark:bg-white/10", className }) => /* @__PURE__ */ jsx156(
9389
+ var SkeletonBar = ({
9390
+ width,
9391
+ height = "h-3",
9392
+ ink = "bg-black/10 dark:bg-white/10",
9393
+ className
9394
+ }) => /* @__PURE__ */ jsx156(
9339
9395
  "span",
9340
9396
  {
9341
9397
  className: classNames7("block rounded-full", ink, height, className),
@@ -9433,6 +9489,19 @@ var Panel = React10.forwardRef(function Panel2({
9433
9489
  hoverShadow = false,
9434
9490
  decoration = "none",
9435
9491
  hoverable,
9492
+ clickable,
9493
+ // Pulled out of `rest` so the card can wrap them. `onClick` becomes the
9494
+ // guarded handler below; `role`, `tabIndex` and `onKeyDown` are the
9495
+ // caller's overrides, and they win over what a clickable card would have
9496
+ // set for itself.
9497
+ onClick,
9498
+ role,
9499
+ tabIndex,
9500
+ onKeyDown,
9501
+ // Chained, not replaced: the drag measurement has to see the press and
9502
+ // the release, and the caller still gets both.
9503
+ onMouseDown,
9504
+ onMouseUp,
9436
9505
  titleClassName,
9437
9506
  subtitleClassName,
9438
9507
  descriptionClassName,
@@ -9450,7 +9519,54 @@ var Panel = React10.forwardRef(function Panel2({
9450
9519
  const resolvedTone = resolvePanelTone(tone, color);
9451
9520
  const palette = getPanelToneStyles(resolvedTone);
9452
9521
  const surfaceText = getSurfaceTextTokens(variant);
9453
- const isHoverable = hoverable ?? Boolean(rest.onClick);
9522
+ const isHoverable = hoverable ?? Boolean(onClick);
9523
+ const isClickable = clickable ?? Boolean(onClick);
9524
+ const trigger = getSurfaceTriggerTokens(resolvedTone);
9525
+ const sectionRef = React10.useRef(null);
9526
+ const bodyRef = React10.useRef(null);
9527
+ const setSectionRef = React10.useCallback(
9528
+ (node) => {
9529
+ sectionRef.current = node;
9530
+ if (typeof ref === "function") ref(node);
9531
+ else if (ref)
9532
+ ref.current = node;
9533
+ },
9534
+ [ref]
9535
+ );
9536
+ const pressRef = React10.useRef(null);
9537
+ const draggedRef = React10.useRef(false);
9538
+ const handleCardMouseDown = (event) => {
9539
+ pressRef.current = { x: event.clientX, y: event.clientY };
9540
+ draggedRef.current = false;
9541
+ };
9542
+ const handleCardMouseUp = (event) => {
9543
+ const press = pressRef.current;
9544
+ if (!press) return;
9545
+ draggedRef.current = Math.abs(event.clientX - press.x) > 4 || Math.abs(event.clientY - press.y) > 4;
9546
+ };
9547
+ const handleCardClick = (event) => {
9548
+ if (isClickOwnedByDescendant(sectionRef.current, event.target)) return;
9549
+ if (draggedRef.current) {
9550
+ draggedRef.current = false;
9551
+ return;
9552
+ }
9553
+ onClick?.(event);
9554
+ };
9555
+ const handleCardKeyDown = (event) => {
9556
+ if (event.target !== sectionRef.current) return;
9557
+ if (event.key !== "Enter" && event.key !== " ") return;
9558
+ event.preventDefault();
9559
+ sectionRef.current?.click();
9560
+ };
9561
+ React10.useEffect(() => {
9562
+ if (!isClickable) return;
9563
+ if (hasInteractiveDescendant(bodyRef.current)) {
9564
+ devWarnA11yOnce(
9565
+ "Panel:clickable-nested-interactive",
9566
+ "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."
9567
+ );
9568
+ }
9569
+ }, [isClickable, loading]);
9454
9570
  const isGlass = GLASS_VARIANTS.includes(variant);
9455
9571
  const resolvedSpecularMode = (() => {
9456
9572
  if (specularMode !== void 0) return specularMode;
@@ -9606,6 +9722,7 @@ var Panel = React10.forwardRef(function Panel2({
9606
9722
  const bodyContent = children ? /* @__PURE__ */ jsx156(
9607
9723
  "div",
9608
9724
  {
9725
+ ref: bodyRef,
9609
9726
  className: classNames7(
9610
9727
  padding === "none" ? "" : "space-y-3 leading-6",
9611
9728
  // min-h-0 lets this flex item shrink below its content height, so
@@ -9716,7 +9833,7 @@ var Panel = React10.forwardRef(function Panel2({
9716
9833
  return /* @__PURE__ */ jsx156(SurfaceProvider, { variant, children: /* @__PURE__ */ jsxs58(
9717
9834
  "section",
9718
9835
  {
9719
- ref,
9836
+ ref: setSectionRef,
9720
9837
  className: classNames7(
9721
9838
  "relative flex w-full min-h-0 flex-col overflow-hidden shrink-0",
9722
9839
  !isOverlay && surfaceText.body,
@@ -9726,7 +9843,15 @@ var Panel = React10.forwardRef(function Panel2({
9726
9843
  fullWidth ? "w-full" : void 0,
9727
9844
  isOverlay ? overlayClasses : void 0,
9728
9845
  hoverShadow && "transition-shadow duration-200 hover:shadow-xl hover:-translate-y-[1px]",
9729
- isHoverable && "group cursor-pointer",
9846
+ isHoverable && "group",
9847
+ // Additive, not moved. A hoverable-only panel has shown a pointer
9848
+ // cursor as long as it has existed, so callers must keep it; a
9849
+ // clickable one now gets it even with `hoverable={false}`.
9850
+ (isHoverable || isClickable) && (disabled ? "cursor-not-allowed" : "cursor-pointer"),
9851
+ // The ring is the shared trigger token, whose inset exists precisely
9852
+ // because an outer ring is clipped by `overflow: hidden` — which
9853
+ // every Panel has.
9854
+ isClickable && !disabled && trigger.focusRing,
9730
9855
  isHoverable && hoverColorName && `hover:bg-${hoverColorName}-50 dark:hover:bg-${hoverColorName}-900/20`,
9731
9856
  className
9732
9857
  ),
@@ -9735,6 +9860,19 @@ var Panel = React10.forwardRef(function Panel2({
9735
9860
  "data-tone": resolvedTone,
9736
9861
  "aria-busy": loading,
9737
9862
  ...rest,
9863
+ role: role ?? (isClickable ? "button" : void 0),
9864
+ tabIndex: tabIndex ?? (isClickable ? disabled ? -1 : 0 : void 0),
9865
+ "aria-disabled": isClickable && disabled ? true : void 0,
9866
+ onClick: disabled || !onClick ? void 0 : handleCardClick,
9867
+ onMouseDown: disabled || !onClick ? void 0 : (event) => {
9868
+ onMouseDown?.(event);
9869
+ handleCardMouseDown(event);
9870
+ },
9871
+ onMouseUp: disabled || !onClick ? void 0 : (event) => {
9872
+ onMouseUp?.(event);
9873
+ handleCardMouseUp(event);
9874
+ },
9875
+ onKeyDown: onKeyDown ?? (isClickable && !disabled && onClick ? handleCardKeyDown : void 0),
9738
9876
  children: [
9739
9877
  isOverlay && !showSkeleton && /* @__PURE__ */ jsxs58(Fragment3, { children: [
9740
9878
  /* @__PURE__ */ jsx156("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ jsx156("div", { className: "h-full w-full", children: media }) }),
@@ -9909,12 +10047,13 @@ var SearchBar = ({
9909
10047
  leadingIcon = "Search",
9910
10048
  variant = "elevated",
9911
10049
  size = "md",
9912
- color = "blue",
10050
+ color: colorProp,
9913
10051
  gradientFrom,
9914
10052
  gradientTo,
9915
10053
  glowIntensity = DEFAULT_GLOW_INTENSITY,
9916
10054
  loading = false
9917
10055
  }) => {
10056
+ const color = colorProp ?? "blue";
9918
10057
  const t = useKitT();
9919
10058
  const [resolvedFrom, resolvedTo] = resolveGlowGradient(
9920
10059
  color,
@@ -10024,7 +10163,9 @@ var SearchBar = ({
10024
10163
  }
10025
10164
  ) : null;
10026
10165
  const sizeToken = getFieldSizeTokens(size);
10027
- const variantTokens = getInputVariantTokens(variant, color);
10166
+ const variantTokens = getInputVariantTokens(variant, color, "auto", {
10167
+ explicitTone: colorProp
10168
+ });
10028
10169
  const bar = /* @__PURE__ */ jsxs59(
10029
10170
  "div",
10030
10171
  {
@@ -10146,14 +10287,26 @@ var FITTING_THUMB = { size: 0, offset: 0, ratio: 0 };
10146
10287
  var ScrollArea = ({
10147
10288
  variant = "auto",
10148
10289
  mask = false,
10290
+ horizontal = true,
10149
10291
  tabIndex = 0,
10150
10292
  contentClassName,
10293
+ viewportClassName,
10294
+ viewportRef: viewportRefProp,
10151
10295
  children,
10152
10296
  className = "",
10153
10297
  ...rest
10154
10298
  }) => {
10155
10299
  const viewportId = useId2();
10156
10300
  const viewportRef = useRef3(null);
10301
+ const setViewportRef = useCallback3(
10302
+ (el) => {
10303
+ viewportRef.current = el;
10304
+ if (typeof viewportRefProp === "function") viewportRefProp(el);
10305
+ else if (viewportRefProp)
10306
+ viewportRefProp.current = el;
10307
+ },
10308
+ [viewportRefProp]
10309
+ );
10157
10310
  const contentRef = useRef3(null);
10158
10311
  const yTrackRef = useRef3(null);
10159
10312
  const xTrackRef = useRef3(null);
@@ -10188,12 +10341,14 @@ var ScrollArea = ({
10188
10341
  const viewport = viewportRef.current;
10189
10342
  if (!viewport) return;
10190
10343
  setOverflow({
10191
- x: viewport.scrollWidth - viewport.clientWidth > 1,
10344
+ x: horizontal && viewport.scrollWidth - viewport.clientWidth > 1,
10192
10345
  y: viewport.scrollHeight - viewport.clientHeight > 1
10193
10346
  });
10194
10347
  setThumbY(thumb(viewport, yTrackRef.current, "y"));
10195
- setThumbX(thumb(viewport, xTrackRef.current, "x"));
10196
- }, [thumb]);
10348
+ setThumbX(
10349
+ horizontal ? thumb(viewport, xTrackRef.current, "x") : FITTING_THUMB
10350
+ );
10351
+ }, [thumb, horizontal]);
10197
10352
  useEffect3(() => {
10198
10353
  update();
10199
10354
  let observer;
@@ -10295,14 +10450,17 @@ var ScrollArea = ({
10295
10450
  /* @__PURE__ */ jsx158(
10296
10451
  "div",
10297
10452
  {
10298
- ref: viewportRef,
10453
+ ref: setViewportRef,
10299
10454
  id: viewportId,
10300
10455
  "data-slot": "scrollarea-viewport",
10301
10456
  tabIndex: overflow.x || overflow.y ? tabIndex : -1,
10302
10457
  "data-overflow-x": overflow.x ? "" : void 0,
10303
10458
  "data-overflow-y": overflow.y ? "" : void 0,
10304
10459
  onScroll: handleScroll,
10305
- style: maskStyle(),
10460
+ style: {
10461
+ ...maskStyle(),
10462
+ ...horizontal ? null : { overflowX: "hidden" }
10463
+ },
10306
10464
  className: classNames9(
10307
10465
  "h-full w-full max-h-[inherit] overflow-auto rounded-[inherit] outline-none",
10308
10466
  // `max-height: inherit` is what makes a `max-h-*` frame work: a
@@ -10310,7 +10468,8 @@ var ScrollArea = ({
10310
10468
  // and the viewport would simply grow past the frame's cap, get
10311
10469
  // clipped by `overflow-hidden` and never learn it was scrollable.
10312
10470
  "[scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
10313
- "focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400"
10471
+ "focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400",
10472
+ viewportClassName
10314
10473
  ),
10315
10474
  children: /* @__PURE__ */ jsx158(
10316
10475
  "div",
@@ -10355,7 +10514,7 @@ var ScrollArea = ({
10355
10514
  ) })
10356
10515
  }
10357
10516
  ),
10358
- /* @__PURE__ */ jsx158(
10517
+ horizontal && /* @__PURE__ */ jsx158(
10359
10518
  "div",
10360
10519
  {
10361
10520
  "data-slot": "scrollarea-scrollbar",