@cjlapao/ui-kit 0.2.40 → 0.2.41

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.cjs CHANGED
@@ -70445,6 +70445,7 @@ var import_jsx_runtime344 = require("react/jsx-runtime");
70445
70445
  var CONNECTOR_LEFT = 9;
70446
70446
  var CONNECTOR_TOP = 24;
70447
70447
  var NESTED_INDENT = 32;
70448
+ var SUB_STEP_ROOT_MARGIN = 120;
70448
70449
  var LEGEND_ORDER = [
70449
70450
  "done",
70450
70451
  "in_progress",
@@ -70457,43 +70458,202 @@ var LEGEND_ORDER = [
70457
70458
  var NestedSubSteps = ({
70458
70459
  stepId,
70459
70460
  subSteps,
70461
+ maxVisible,
70462
+ loadMode = "scroll",
70463
+ order = "reverse",
70460
70464
  palette,
70461
70465
  customStatuses,
70462
70466
  surfaces,
70467
+ labels,
70463
70468
  onSubStepSelect
70464
- }) => /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70465
- "div",
70466
- {
70467
- className: (0, import_classnames116.default)("mt-3 rounded-lg p-3", surfaces.nestedBox),
70468
- style: { marginLeft: NESTED_INDENT },
70469
- children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("ul", { className: "space-y-2.5", children: subSteps.map((subStep) => {
70470
- const status = normalizeStatus(subStep.status, customStatuses);
70471
- const isActive = status === "running" || status === "in_progress";
70472
- const content = /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(import_jsx_runtime344.Fragment, { children: [
70473
- /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(WorkflowStatusNode_default, { status, palette, customStatuses, size: "sm" }),
70474
- /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70475
- "span",
70476
- {
70477
- className: (0, import_classnames116.default)(
70478
- "text-sm",
70479
- isActive ? "font-semibold text-neutral-900 dark:text-white" : "text-neutral-600 dark:text-neutral-300"
70480
- ),
70481
- children: subStep.label
70482
- }
70483
- )
70484
- ] });
70485
- return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("li", { children: onSubStepSelect ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70486
- "button",
70469
+ }) => {
70470
+ const total = subSteps.length;
70471
+ const capped = maxVisible !== void 0 && maxVisible > 0 && maxVisible < total;
70472
+ const [visibleCount, setVisibleCount] = (0, import_react322.useState)(maxVisible ?? total);
70473
+ const shownCount = Math.min(visibleCount, total);
70474
+ const visible = subSteps.slice(
70475
+ order === "reverse" ? total - shownCount : 0,
70476
+ order === "reverse" ? total : shownCount
70477
+ );
70478
+ const hasMore = capped && shownCount < total;
70479
+ const viewportRef = (0, import_react322.useRef)(null);
70480
+ const sentinelRef = (0, import_react322.useRef)(null);
70481
+ const listRef = (0, import_react322.useRef)(null);
70482
+ const [frozenMaxPx, setFrozenMaxPx] = (0, import_react322.useState)(null);
70483
+ const hasObserver = typeof IntersectionObserver !== "undefined";
70484
+ const scrolls = capped && loadMode === "scroll" && hasObserver;
70485
+ const reverse = order === "reverse";
70486
+ const capRef = (0, import_react322.useRef)(maxVisible);
70487
+ (0, import_react322.useEffect)(() => {
70488
+ if (capRef.current === maxVisible) return;
70489
+ capRef.current = maxVisible;
70490
+ setVisibleCount(
70491
+ maxVisible !== void 0 && maxVisible > 0 ? Math.min(maxVisible, total) : total
70492
+ );
70493
+ setFrozenMaxPx(null);
70494
+ }, [maxVisible, total]);
70495
+ (0, import_react322.useLayoutEffect)(() => {
70496
+ if (!scrolls || frozenMaxPx != null) return;
70497
+ const height = listRef.current?.offsetHeight ?? 0;
70498
+ if (height > 0) setFrozenMaxPx(height);
70499
+ }, [scrolls, frozenMaxPx]);
70500
+ const anchorRef = (0, import_react322.useRef)(null);
70501
+ (0, import_react322.useLayoutEffect)(() => {
70502
+ const before = anchorRef.current;
70503
+ if (before == null) return;
70504
+ anchorRef.current = null;
70505
+ const vp = viewportRef.current;
70506
+ if (vp) vp.scrollTop += vp.scrollHeight - before;
70507
+ }, [shownCount]);
70508
+ const bottomedRef = (0, import_react322.useRef)(false);
70509
+ (0, import_react322.useLayoutEffect)(() => {
70510
+ if (!scrolls || !reverse || bottomedRef.current || frozenMaxPx == null) return;
70511
+ const vp = viewportRef.current;
70512
+ if (vp) {
70513
+ vp.scrollTop = vp.scrollHeight;
70514
+ bottomedRef.current = true;
70515
+ }
70516
+ }, [scrolls, reverse, frozenMaxPx]);
70517
+ const atBottomRef = (0, import_react322.useRef)(true);
70518
+ (0, import_react322.useEffect)(() => {
70519
+ if (!scrolls || !reverse) return;
70520
+ const vp = viewportRef.current;
70521
+ if (!vp) return;
70522
+ const onScroll = () => {
70523
+ atBottomRef.current = vp.scrollHeight - vp.scrollTop - vp.clientHeight <= 8;
70524
+ };
70525
+ vp.addEventListener("scroll", onScroll, { passive: true });
70526
+ return () => vp.removeEventListener("scroll", onScroll);
70527
+ }, [scrolls, reverse]);
70528
+ const prevTotalRef = (0, import_react322.useRef)(total);
70529
+ (0, import_react322.useLayoutEffect)(() => {
70530
+ const delta = total - prevTotalRef.current;
70531
+ const prevTotal = prevTotalRef.current;
70532
+ prevTotalRef.current = total;
70533
+ if (delta <= 0 || !reverse) return;
70534
+ setVisibleCount(
70535
+ (count) => count >= prevTotal || maxVisible === void 0 || count > maxVisible ? count + delta : count
70536
+ );
70537
+ const vp = viewportRef.current;
70538
+ if (vp && atBottomRef.current) vp.scrollTop = vp.scrollHeight;
70539
+ }, [total, reverse, maxVisible]);
70540
+ const scroll = useInfiniteScroll({
70541
+ rootRef: viewportRef,
70542
+ sentinelRef,
70543
+ hasMore: scrolls && hasMore,
70544
+ itemCount: shownCount,
70545
+ rootMargin: SUB_STEP_ROOT_MARGIN,
70546
+ onLoadMore: async () => {
70547
+ if (reverse) anchorRef.current = viewportRef.current?.scrollHeight ?? null;
70548
+ setVisibleCount(
70549
+ (count) => Math.min(count + (maxVisible ?? total), total)
70550
+ );
70551
+ }
70552
+ });
70553
+ const list = /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("ul", { ref: listRef, className: "space-y-2.5", children: visible.map((subStep) => {
70554
+ const status = normalizeStatus(subStep.status, customStatuses);
70555
+ const isActive = status === "running" || status === "in_progress";
70556
+ const content = /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(import_jsx_runtime344.Fragment, { children: [
70557
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(WorkflowStatusNode_default, { status, palette, customStatuses, size: "sm" }),
70558
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70559
+ "span",
70487
70560
  {
70488
- type: "button",
70489
- onClick: () => onSubStepSelect(stepId, subStep.id),
70490
- className: "flex w-full items-center gap-2.5 rounded-sm text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 dark:focus-visible:ring-neutral-500",
70491
- children: content
70561
+ className: (0, import_classnames116.default)(
70562
+ "min-w-0 flex-1 truncate text-sm",
70563
+ isActive ? "font-semibold text-neutral-900 dark:text-white" : "text-neutral-600 dark:text-neutral-300"
70564
+ ),
70565
+ children: subStep.label
70492
70566
  }
70493
- ) : /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "flex items-center gap-2.5", children: content }) }, subStep.id);
70494
- }) })
70495
- }
70496
- );
70567
+ )
70568
+ ] });
70569
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("li", { children: onSubStepSelect ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70570
+ "button",
70571
+ {
70572
+ type: "button",
70573
+ onClick: () => onSubStepSelect(stepId, subStep.id),
70574
+ className: "flex w-full min-w-0 items-center gap-2.5 rounded-sm text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 dark:focus-visible:ring-neutral-500",
70575
+ children: content
70576
+ }
70577
+ ) : /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "flex w-full min-w-0 items-center gap-2.5", children: content }) }, subStep.id);
70578
+ }) });
70579
+ const scrollTail = /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(import_jsx_runtime344.Fragment, { children: [
70580
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { ref: sentinelRef, "aria-hidden": "true" }),
70581
+ scroll.error ? /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(
70582
+ "div",
70583
+ {
70584
+ "data-slot": "workflow-substeps-scroll-error",
70585
+ className: (0, import_classnames116.default)(
70586
+ "flex items-center justify-center gap-2 text-xs text-rose-600 dark:text-rose-400",
70587
+ reverse ? "mb-2" : "mt-2"
70588
+ ),
70589
+ children: [
70590
+ labels.loadMoreError,
70591
+ /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Button_default, { size: "xs", variant: "link", onClick: () => void scroll.loadMore(), children: "Try again" })
70592
+ ]
70593
+ }
70594
+ ) : scroll.isLoadingMore ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70595
+ "div",
70596
+ {
70597
+ "data-slot": "workflow-substeps-scroll-loading",
70598
+ className: (0, import_classnames116.default)("flex justify-center py-1", reverse ? "mb-1" : "mt-1"),
70599
+ role: "status",
70600
+ "aria-label": labels.loadingMore,
70601
+ children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(Spinner_default, { size: "xs", color: palette.accent })
70602
+ }
70603
+ ) : null
70604
+ ] });
70605
+ const remaining = total - shownCount;
70606
+ const buttonTail = hasMore ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "mt-2 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70607
+ Button_default,
70608
+ {
70609
+ size: "xs",
70610
+ variant: "link",
70611
+ color: palette.accent,
70612
+ onClick: () => setVisibleCount(
70613
+ (count) => Math.min(count + (maxVisible ?? total), total)
70614
+ ),
70615
+ children: labels.showMore.replace(
70616
+ "{count}",
70617
+ String(Math.min(maxVisible ?? remaining, remaining))
70618
+ )
70619
+ }
70620
+ ) }) : capped ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("div", { className: "mt-2 flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70621
+ Button_default,
70622
+ {
70623
+ size: "xs",
70624
+ variant: "link",
70625
+ color: palette.accent,
70626
+ onClick: () => setVisibleCount(maxVisible ?? total),
70627
+ children: labels.showLess
70628
+ }
70629
+ ) }) : null;
70630
+ return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70631
+ "div",
70632
+ {
70633
+ className: (0, import_classnames116.default)("mt-3 overflow-hidden rounded-lg p-3", surfaces.nestedBox),
70634
+ style: { marginLeft: NESTED_INDENT },
70635
+ children: scrolls ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
70636
+ ScrollArea_default,
70637
+ {
70638
+ variant: "hover",
70639
+ horizontal: false,
70640
+ viewportRef,
70641
+ style: frozenMaxPx != null ? { maxHeight: frozenMaxPx } : void 0,
70642
+ viewportClassName: "overscroll-contain",
70643
+ contentClassName: "table-fixed w-full",
70644
+ children: /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)("div", { children: [
70645
+ reverse && scrollTail,
70646
+ list,
70647
+ !reverse && scrollTail
70648
+ ] })
70649
+ }
70650
+ ) : /* @__PURE__ */ (0, import_jsx_runtime344.jsxs)(import_jsx_runtime344.Fragment, { children: [
70651
+ list,
70652
+ hasMore || capped ? buttonTail : null
70653
+ ] })
70654
+ }
70655
+ );
70656
+ };
70497
70657
  var WorkflowTimeline = ({
70498
70658
  disableFutureSteps = false,
70499
70659
  controls,
@@ -70512,6 +70672,9 @@ var WorkflowTimeline = ({
70512
70672
  fillHeight = false,
70513
70673
  steps,
70514
70674
  activeStepId,
70675
+ maxVisibleSubSteps,
70676
+ subStepLoadMode = "scroll",
70677
+ subStepOrder = "reverse",
70515
70678
  palette,
70516
70679
  customStatuses,
70517
70680
  surfaces,
@@ -70627,10 +70790,18 @@ var WorkflowTimeline = ({
70627
70790
  ScrollArea_default,
70628
70791
  {
70629
70792
  variant: "hover",
70793
+ horizontal: false,
70630
70794
  className: fillHeight ? "min-h-0 flex-1" : void 0,
70631
70795
  style: fillHeight ? { flex: `${hasFooter ? 100 - footer.percentage : 100} 1 0%` } : void 0,
70632
70796
  viewportClassName: "overscroll-contain",
70633
70797
  contentClassName: (0, import_classnames116.default)(
70798
+ // The rail is a vertical list: the content table must size to the
70799
+ // viewport, never to the widest row. Without this, one long
70800
+ // unbreakable label sets the table's min-content width wider than
70801
+ // the card (the row's truncation cannot help — a table sizes from
70802
+ // descendants' min-content), and the scroller — or the card's own
70803
+ // edge, clipped — eats the rows.
70804
+ "table-fixed w-full",
70634
70805
  !loading && !isEmpty2 && (collapsed ? "px-2 py-4" : "px-5 py-5")
70635
70806
  ),
70636
70807
  children: loading ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(WorkflowRailSkeleton, { rows: loadingRows, collapsed }) : isEmpty2 ? collapsed ? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)("span", { className: "sr-only", children: labels.empty }) : emptyState ?? /* @__PURE__ */ (0, import_jsx_runtime344.jsx)(
@@ -70818,9 +70989,13 @@ var WorkflowTimeline = ({
70818
70989
  {
70819
70990
  stepId: step.id,
70820
70991
  subSteps: nested,
70992
+ maxVisible: maxVisibleSubSteps,
70993
+ loadMode: subStepLoadMode,
70994
+ order: subStepOrder,
70821
70995
  palette,
70822
70996
  customStatuses,
70823
70997
  surfaces,
70998
+ labels,
70824
70999
  onSubStepSelect: disabled ? void 0 : onSubStepSelect
70825
71000
  }
70826
71001
  )
@@ -70857,9 +71032,10 @@ var WorkflowTimeline = ({
70857
71032
  ScrollArea_default,
70858
71033
  {
70859
71034
  variant: "hover",
71035
+ horizontal: false,
70860
71036
  className: fillHeight ? "min-h-0 flex-1" : void 0,
70861
71037
  viewportClassName: "overscroll-contain",
70862
- contentClassName: (0, import_classnames116.default)(collapsed ? "px-2 pb-4" : "px-5 pb-4", !hasFooterHeader && "pt-4"),
71038
+ contentClassName: (0, import_classnames116.default)("table-fixed w-full", collapsed ? "px-2 pb-4" : "px-5 pb-4", !hasFooterHeader && "pt-4"),
70863
71039
  children: controls
70864
71040
  }
70865
71041
  )
@@ -70919,6 +71095,10 @@ var DEFAULT_LABELS = {
70919
71095
  noActiveStep: "No step selected",
70920
71096
  details: "Step details",
70921
71097
  quickActions: "Quick actions",
71098
+ showMore: "Show {count} more",
71099
+ showLess: "Show less",
71100
+ loadMoreError: "Couldn\u2019t load more",
71101
+ loadingMore: "Loading more",
70922
71102
  statuses: {
70923
71103
  done: "Done",
70924
71104
  in_progress: "In progress",
@@ -71269,6 +71449,9 @@ var WorkflowTrackerRail = ({
71269
71449
  footerResizeLabel = "Resize workflow footer",
71270
71450
  stepPopoverProps,
71271
71451
  data = sampleWorkflow,
71452
+ maxVisibleSubSteps,
71453
+ subStepLoadMode = "scroll",
71454
+ subStepOrder = "reverse",
71272
71455
  loading = false,
71273
71456
  loadingRows = 6,
71274
71457
  showLegend = true,
@@ -71433,6 +71616,9 @@ var WorkflowTrackerRail = ({
71433
71616
  fillHeight: scrollBody,
71434
71617
  steps,
71435
71618
  activeStepId: active?.step.id,
71619
+ maxVisibleSubSteps,
71620
+ subStepLoadMode,
71621
+ subStepOrder,
71436
71622
  palette,
71437
71623
  customStatuses,
71438
71624
  surfaces,
@@ -71896,6 +72082,9 @@ var WorkflowTracker = ({
71896
72082
  fillHeightOffset = 0,
71897
72083
  loading = false,
71898
72084
  loadingRows = 6,
72085
+ maxVisibleSubSteps,
72086
+ subStepLoadMode = "scroll",
72087
+ subStepOrder = "reverse",
71899
72088
  emptyState,
71900
72089
  showHeader = true,
71901
72090
  showLegend = true,
@@ -72012,6 +72201,9 @@ var WorkflowTracker = ({
72012
72201
  data,
72013
72202
  loading,
72014
72203
  loadingRows,
72204
+ maxVisibleSubSteps,
72205
+ subStepLoadMode,
72206
+ subStepOrder,
72015
72207
  showLegend,
72016
72208
  emptyState,
72017
72209
  labels: labelOverrides,
@@ -81162,6 +81354,7 @@ function FilterBar({
81162
81354
  buttonVariant = "outline",
81163
81355
  secondaryButtonVariant = "ghost",
81164
81356
  applyButtonVariant = "solid",
81357
+ searchButtonVariant = "icon",
81165
81358
  buttonTone = color2,
81166
81359
  buttonSize = size,
81167
81360
  buttonCorner,
@@ -81298,7 +81491,8 @@ function FilterBar({
81298
81491
  Button_default,
81299
81492
  {
81300
81493
  ...actionStyle,
81301
- variant: "icon",
81494
+ variant: searchButtonVariant,
81495
+ iconOnly: true,
81302
81496
  leadingIcon: "Search",
81303
81497
  "aria-label": t("kit.filterbar.search"),
81304
81498
  "aria-expanded": expanded,