@inf-monkeys-tech/monkeys-design 1.0.44 → 1.0.45

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.
@@ -8769,13 +8769,146 @@ function WorkbenchMasonryLayout({
8769
8769
  }
8770
8770
  );
8771
8771
  }
8772
+ var DEFAULT_PROVISIONAL_CAPACITY = 12;
8773
+ var DEFAULT_GRID_ASPECT_RATIOS = [1];
8774
+ var DEFAULT_RAIL_ASPECT_RATIOS = [4 / 3];
8775
+ var DEFAULT_MASONRY_ASPECT_RATIOS = [1, 4 / 5, 3 / 2, 3 / 4, 5 / 4];
8776
+ var MIN_SKELETON_ASPECT_RATIO = 0.5;
8777
+ var MAX_SKELETON_ASPECT_RATIO = 2;
8778
+ var SKELETON_BACKGROUND_COLOR = "hsl(var(--monkeys-color-muted, var(--muted)))";
8779
+ function clamp2(value, min, max) {
8780
+ return Math.min(Math.max(value, min), max);
8781
+ }
8782
+ function normalizeCount(value, fallback, max) {
8783
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return fallback;
8784
+ return clamp2(Math.round(value), 1, max);
8785
+ }
8786
+ function getDefaultAspectRatios(mode) {
8787
+ if (mode === "masonry" || mode === "dense") return DEFAULT_MASONRY_ASPECT_RATIOS;
8788
+ if (mode === "rail") return DEFAULT_RAIL_ASPECT_RATIOS;
8789
+ return DEFAULT_GRID_ASPECT_RATIOS;
8790
+ }
8791
+ function resolveAspectRatios(mode, values) {
8792
+ const normalized = values?.filter((value) => typeof value === "number" && Number.isFinite(value) && value > 0).map((value) => clamp2(value, MIN_SKELETON_ASPECT_RATIO, MAX_SKELETON_ASPECT_RATIO));
8793
+ return normalized?.length ? normalized : getDefaultAspectRatios(mode);
8794
+ }
8795
+ function resolveWorkbenchCollectionSkeletonCapacity(config) {
8796
+ return normalizeCount(config?.count, DEFAULT_PROVISIONAL_CAPACITY, 48);
8797
+ }
8798
+ function resolveWorkbenchCollectionLoadingVariant(value) {
8799
+ if (value === void 0) return "skeleton";
8800
+ if (value === "skeleton" || value === "spinner") return value;
8801
+ throw new TypeError('WorkbenchCollection loading.variant must be "skeleton" or "spinner".');
8802
+ }
8803
+ function resolveSkeletonCount({
8804
+ columnCount,
8805
+ config,
8806
+ phase
8807
+ }) {
8808
+ if (phase === "initial") {
8809
+ const fallback2 = clamp2(columnCount * 2, 6, 24);
8810
+ return normalizeCount(config?.count, fallback2, 48);
8811
+ }
8812
+ const fallback = clamp2(columnCount, 1, 12);
8813
+ return normalizeCount(config?.loadMoreCount, fallback, 24);
8814
+ }
8815
+ function getSkeletonHeight(columnWidth, aspectRatio) {
8816
+ return Math.max(1, columnWidth / aspectRatio);
8817
+ }
8818
+ function WorkbenchCollectionSkeleton({
8819
+ mode,
8820
+ phase,
8821
+ columnCount,
8822
+ columnWidth,
8823
+ cardWidth,
8824
+ gap,
8825
+ rowHeight,
8826
+ config,
8827
+ ariaLabel,
8828
+ className
8829
+ }) {
8830
+ const count = resolveSkeletonCount({ columnCount, config, phase });
8831
+ const aspectRatios = resolveAspectRatios(mode, config?.aspectRatios);
8832
+ const animated = config?.animated ?? true;
8833
+ const items = useMemo(
8834
+ () => Array.from({ length: count }, (_, index) => ({
8835
+ aspectRatio: aspectRatios[index % aspectRatios.length],
8836
+ key: `${phase}-${index}`
8837
+ })),
8838
+ [aspectRatios, count, phase]
8839
+ );
8840
+ const renderSkeleton = (item, style) => /* @__PURE__ */ jsx(
8841
+ BaseSkeleton,
8842
+ {
8843
+ variant: "block",
8844
+ animated,
8845
+ className: "h-auto w-full",
8846
+ style: {
8847
+ backgroundColor: SKELETON_BACKGROUND_COLOR,
8848
+ ...style ?? { aspectRatio: String(item.aspectRatio) }
8849
+ },
8850
+ "data-collection-skeleton-item": "",
8851
+ "data-skeleton-aspect-ratio": item.aspectRatio
8852
+ }
8853
+ );
8854
+ return /* @__PURE__ */ jsx(
8855
+ "div",
8856
+ {
8857
+ role: "status",
8858
+ "aria-label": ariaLabel,
8859
+ "aria-atomic": "true",
8860
+ "data-collection-loading": phase,
8861
+ "data-layout-mode": mode,
8862
+ className: "min-w-0",
8863
+ children: mode === "masonry" || mode === "dense" ? /* @__PURE__ */ jsx(
8864
+ WorkbenchMasonryLayout,
8865
+ {
8866
+ items,
8867
+ columnCount,
8868
+ columnWidth,
8869
+ gap,
8870
+ rowHeight,
8871
+ placementStrategy: mode === "dense" ? "dense" : "shortest",
8872
+ className,
8873
+ containerProps: { "aria-hidden": true },
8874
+ getItemKey: (item) => item.key,
8875
+ getItemSize: (item, layout) => ({
8876
+ height: getSkeletonHeight(layout.columnWidth, item.aspectRatio)
8877
+ }),
8878
+ renderItem: (item, layout) => renderSkeleton(item, {
8879
+ height: `${getSkeletonHeight(layout.columnWidth, item.aspectRatio)}px`
8880
+ })
8881
+ }
8882
+ ) : mode === "rail" ? /* @__PURE__ */ jsx(
8883
+ "div",
8884
+ {
8885
+ "aria-hidden": "true",
8886
+ className: cn("grid min-w-0 grid-flow-col items-start overflow-x-auto", className),
8887
+ style: {
8888
+ gap,
8889
+ gridAutoColumns: typeof cardWidth === "number" ? `${cardWidth}px` : cardWidth ?? `${columnWidth}px`
8890
+ },
8891
+ children: items.map((item) => /* @__PURE__ */ jsx("div", { children: renderSkeleton(item) }, item.key))
8892
+ }
8893
+ ) : /* @__PURE__ */ jsx(
8894
+ "div",
8895
+ {
8896
+ "aria-hidden": "true",
8897
+ className: cn("grid min-w-0 items-start", className),
8898
+ style: { gap, gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` },
8899
+ children: items.map((item) => /* @__PURE__ */ jsx("div", { children: renderSkeleton(item) }, item.key))
8900
+ }
8901
+ )
8902
+ }
8903
+ );
8904
+ }
8772
8905
  var DEFAULT_GAP_PX = 12;
8773
8906
  var DEFAULT_ROW_HEIGHT_PX = 8;
8774
8907
  var DEFAULT_CARD_WIDTH_PX = 280;
8775
8908
  var BREAKPOINT_TABLET_PX = 640;
8776
8909
  var BREAKPOINT_DESKTOP_PX = 1024;
8777
8910
  var MAX_COLUMN_COUNT = 24;
8778
- function clamp2(value, min, max) {
8911
+ function clamp3(value, min, max) {
8779
8912
  return Math.min(Math.max(value, min), max);
8780
8913
  }
8781
8914
  function resolveRenderableSlot(slot, context) {
@@ -8799,7 +8932,7 @@ function resolveLengthToPixels2(value, fallback, node) {
8799
8932
  }
8800
8933
  function normalizeColumns(value) {
8801
8934
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return void 0;
8802
- return clamp2(Math.round(value), 1, MAX_COLUMN_COUNT);
8935
+ return clamp3(Math.round(value), 1, MAX_COLUMN_COUNT);
8803
8936
  }
8804
8937
  function resolveResponsiveColumns(columns, containerWidth) {
8805
8938
  if (columns === "auto" || columns === void 0) return void 0;
@@ -8860,7 +8993,7 @@ function normalizeRowHeight(value) {
8860
8993
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : DEFAULT_ROW_HEIGHT_PX;
8861
8994
  }
8862
8995
  function normalizeThreshold(value) {
8863
- return typeof value === "number" && Number.isFinite(value) ? clamp2(value, 0, 1) : 0;
8996
+ return typeof value === "number" && Number.isFinite(value) ? clamp3(value, 0, 1) : 0;
8864
8997
  }
8865
8998
  function normalizeItemSize(size, aspectRatio, columnWidth) {
8866
8999
  const normalizedAspectRatio = Number.isFinite(aspectRatio) && Number(aspectRatio) > 0 ? Number(aspectRatio) : void 0;
@@ -8920,7 +9053,7 @@ function warnOnDuplicateKeys(keys) {
8920
9053
  }
8921
9054
  function normalizeTitleMaxLines(value) {
8922
9055
  if (!Number.isFinite(value) || Number(value) <= 0) return void 0;
8923
- return clamp2(Math.round(Number(value)), 1, 12);
9056
+ return clamp3(Math.round(Number(value)), 1, 12);
8924
9057
  }
8925
9058
  function WorkbenchCollection({
8926
9059
  items,
@@ -8970,6 +9103,12 @@ function WorkbenchCollection({
8970
9103
  [normalizedItems]
8971
9104
  );
8972
9105
  const keysSignature = normalizedItems.map(({ stringKey }) => stringKey).join("");
9106
+ const state = config.state;
9107
+ const loading = state?.loading === true;
9108
+ const loadingMore = state?.loadingMore === true;
9109
+ const hasMore = state?.hasMore === true;
9110
+ const loadingVariant = resolveWorkbenchCollectionLoadingVariant(config.loading?.variant);
9111
+ const layoutItemCount = loading && normalizedItems.length === 0 && loadingVariant === "skeleton" ? resolveWorkbenchCollectionSkeletonCapacity(config.loading?.skeleton) : normalizedItems.length;
8973
9112
  useEffect(() => warnOnDuplicateKeys(keys), [keys, keysSignature]);
8974
9113
  const selectionMode = config.selection?.mode ?? "none";
8975
9114
  const controlledSelection = config.selection?.selectedKeys !== void 0;
@@ -9004,7 +9143,7 @@ function WorkbenchCollection({
9004
9143
  }, [itemsNode]);
9005
9144
  const columnCount = resolveColumnCount({
9006
9145
  containerWidth,
9007
- itemCount: normalizedItems.length,
9146
+ itemCount: layoutItemCount,
9008
9147
  gap,
9009
9148
  columns: config.layout.columns,
9010
9149
  maxColumns: config.layout.maxColumns,
@@ -9089,10 +9228,6 @@ function WorkbenchCollection({
9089
9228
  owner.removeEventListener("scroll", saveScrollPosition);
9090
9229
  };
9091
9230
  }, [config.scrollRestorationKey, resolveScrollOwner]);
9092
- const state = config.state;
9093
- const loading = state?.loading === true;
9094
- const loadingMore = state?.loadingMore === true;
9095
- const hasMore = state?.hasMore === true;
9096
9231
  const canLoadMore = typeof callbacks?.onLoadMore === "function";
9097
9232
  const effectiveError = state?.error ?? virtualizationError;
9098
9233
  useEffect(() => {
@@ -9443,7 +9578,7 @@ function WorkbenchCollection({
9443
9578
  },
9444
9579
  children: group.items.map((entry) => {
9445
9580
  const customSize = config.layout.getItemSize?.(entry.item, baseLayoutContext);
9446
- const span = clamp2(Math.round(Number(customSize?.columnSpan) || 1), 1, columnCount);
9581
+ const span = clamp3(Math.round(Number(customSize?.columnSpan) || 1), 1, columnCount);
9447
9582
  const aspectRatio = config.layout.getItemAspectRatio?.(entry.item, entry.index);
9448
9583
  return /* @__PURE__ */ jsx(
9449
9584
  "div",
@@ -9530,7 +9665,28 @@ function WorkbenchCollection({
9530
9665
  title: labels.offline,
9531
9666
  actions: statusStates.error?.showRetry !== false && callbacks?.onRetry ? /* @__PURE__ */ jsx(BaseButton, { size: "sm", label: labels.retry, onClick: callbacks.onRetry }) : void 0
9532
9667
  }
9533
- ) : showInitialLoading ? hasRenderableNode(loadingSlot) ? loadingSlot : /* @__PURE__ */ jsx(BaseLoadingState, { title: labels.loading }) : showInitialError ? hasRenderableNode(errorSlot) ? errorSlot : /* @__PURE__ */ jsx(
9668
+ ) : showInitialLoading ? hasRenderableNode(loadingSlot) ? loadingSlot : loadingVariant === "spinner" ? /* @__PURE__ */ jsx(BaseLoadingState, { title: labels.loading, variant: "spinner" }) : /* @__PURE__ */ jsx(
9669
+ "div",
9670
+ {
9671
+ ref: registerItemsNode,
9672
+ className: cn("min-w-0", classNames?.items),
9673
+ children: /* @__PURE__ */ jsx(
9674
+ WorkbenchCollectionSkeleton,
9675
+ {
9676
+ mode,
9677
+ phase: "initial",
9678
+ columnCount,
9679
+ columnWidth,
9680
+ cardWidth: config.layout.cardWidth ?? config.layout.idealCardWidth,
9681
+ gap,
9682
+ rowHeight,
9683
+ config: config.loading?.skeleton,
9684
+ ariaLabel: labels.loading,
9685
+ className: classNames?.layout
9686
+ }
9687
+ )
9688
+ }
9689
+ ) : showInitialError ? hasRenderableNode(errorSlot) ? errorSlot : /* @__PURE__ */ jsx(
9534
9690
  BaseSystemState,
9535
9691
  {
9536
9692
  kind: "error",
@@ -9574,7 +9730,21 @@ function WorkbenchCollection({
9574
9730
  actions: statusStates.error?.showRetry !== false && callbacks?.onRetry ? /* @__PURE__ */ jsx(BaseButton, { size: "sm", label: labels.retry, onClick: callbacks.onRetry }) : void 0
9575
9731
  }
9576
9732
  ) }) : null,
9577
- items.length > 0 && (hasMore || loadingMore) ? /* @__PURE__ */ jsx("div", { ref: loadMoreRef, className: classNames?.loadMore, "data-collection-load-more": "", children: hasRenderableNode(loadMoreSlot) ? loadMoreSlot : loadingMore ? /* @__PURE__ */ jsx(BaseLoadingState, { title: labels.loadingMore }) : null }) : null,
9733
+ items.length > 0 && (hasMore || loadingMore) ? /* @__PURE__ */ jsx("div", { ref: loadMoreRef, className: classNames?.loadMore, "data-collection-load-more": "", children: hasRenderableNode(loadMoreSlot) ? loadMoreSlot : loadingMore ? loadingVariant === "spinner" ? /* @__PURE__ */ jsx(BaseLoadingState, { title: labels.loadingMore, variant: "spinner" }) : /* @__PURE__ */ jsx(
9734
+ WorkbenchCollectionSkeleton,
9735
+ {
9736
+ mode,
9737
+ phase: "load-more",
9738
+ columnCount,
9739
+ columnWidth,
9740
+ cardWidth: config.layout.cardWidth ?? config.layout.idealCardWidth,
9741
+ gap,
9742
+ rowHeight,
9743
+ config: config.loading?.skeleton,
9744
+ ariaLabel: labels.loadingMore,
9745
+ className: classNames?.layout
9746
+ }
9747
+ ) : null }) : null,
9578
9748
  hasRenderableNode(footer) ? /* @__PURE__ */ jsx("div", { className: classNames?.footer, children: footer }) : null
9579
9749
  ]
9580
9750
  }
@@ -10445,7 +10615,7 @@ var getDomain = (values, min, max) => {
10445
10615
  return lower < upper ? [lower, upper] : [upper, lower];
10446
10616
  };
10447
10617
  var scale = (value, domain, start, end) => start + (value - domain[0]) / (domain[1] - domain[0]) * (end - start);
10448
- var clamp3 = (value, min, max) => Math.min(max, Math.max(min, value));
10618
+ var clamp4 = (value, min, max) => Math.min(max, Math.max(min, value));
10449
10619
  var activatePoint = (event, point, onPointSelect) => {
10450
10620
  if (!onPointSelect || event.key !== "Enter" && event.key !== " ") return;
10451
10621
  event.preventDefault();
@@ -10527,9 +10697,9 @@ function WorkbenchScatterPlot({
10527
10697
  xThreshold === void 0 ? null : /* @__PURE__ */ jsx(
10528
10698
  "line",
10529
10699
  {
10530
- x1: clamp3(xThreshold, plotLeft, plotRight),
10700
+ x1: clamp4(xThreshold, plotLeft, plotRight),
10531
10701
  y1: plotTop,
10532
- x2: clamp3(xThreshold, plotLeft, plotRight),
10702
+ x2: clamp4(xThreshold, plotLeft, plotRight),
10533
10703
  y2: plotBottom,
10534
10704
  className: "stroke-muted-foreground/50",
10535
10705
  strokeDasharray: "5 5"
@@ -10539,9 +10709,9 @@ function WorkbenchScatterPlot({
10539
10709
  "line",
10540
10710
  {
10541
10711
  x1: plotLeft,
10542
- y1: clamp3(yThreshold, plotTop, plotBottom),
10712
+ y1: clamp4(yThreshold, plotTop, plotBottom),
10543
10713
  x2: plotRight,
10544
- y2: clamp3(yThreshold, plotTop, plotBottom),
10714
+ y2: clamp4(yThreshold, plotTop, plotBottom),
10545
10715
  className: "stroke-muted-foreground/50",
10546
10716
  strokeDasharray: "5 5"
10547
10717
  }
@@ -10568,17 +10738,17 @@ function WorkbenchScatterPlot({
10568
10738
  }
10569
10739
  ),
10570
10740
  validPoints.map((point) => {
10571
- const x = clamp3(
10741
+ const x = clamp4(
10572
10742
  scale(point.x, xDomain, plotLeft, plotRight),
10573
10743
  plotLeft,
10574
10744
  plotRight
10575
10745
  );
10576
- const y = clamp3(
10746
+ const y = clamp4(
10577
10747
  scale(point.y, yDomain, plotBottom, plotTop),
10578
10748
  plotTop,
10579
10749
  plotBottom
10580
10750
  );
10581
- const radius = point.size === void 0 ? 9 : clamp3(scale(point.size, sizeDomain, 7, 18), 7, 18);
10751
+ const radius = point.size === void 0 ? 9 : clamp4(scale(point.size, sizeDomain, 7, 18), 7, 18);
10582
10752
  const selected = selectedPointId === point.id;
10583
10753
  return /* @__PURE__ */ jsxs(
10584
10754
  "g",
@@ -11118,7 +11288,7 @@ var getDomain2 = (values, min, max) => {
11118
11288
  return lower < upper ? [lower, upper] : [upper, lower];
11119
11289
  };
11120
11290
  var scale2 = (value, domain, start, end) => start + (value - domain[0]) / (domain[1] - domain[0]) * (end - start);
11121
- var clamp4 = (value, min, max) => Math.min(max, Math.max(min, value));
11291
+ var clamp5 = (value, min, max) => Math.min(max, Math.max(min, value));
11122
11292
  var toneVariable = {
11123
11293
  primary: "--radar-series-one",
11124
11294
  secondary: "--radar-series-two",
@@ -11181,7 +11351,7 @@ function WorkbenchRadarMatrix({
11181
11351
  const plotRight = width;
11182
11352
  const plotTop = 0;
11183
11353
  const plotBottom = height;
11184
- const xThreshold = clamp4(
11354
+ const xThreshold = clamp5(
11185
11355
  scale2(
11186
11356
  Number.isFinite(thresholds?.x) ? Number(thresholds?.x) : (xDomain[0] + xDomain[1]) / 2,
11187
11357
  xDomain,
@@ -11191,7 +11361,7 @@ function WorkbenchRadarMatrix({
11191
11361
  plotLeft,
11192
11362
  plotRight
11193
11363
  );
11194
- const yThreshold = clamp4(
11364
+ const yThreshold = clamp5(
11195
11365
  scale2(
11196
11366
  Number.isFinite(thresholds?.y) ? Number(thresholds?.y) : (yDomain[0] + yDomain[1]) / 2,
11197
11367
  yDomain,
@@ -11299,13 +11469,13 @@ function WorkbenchRadarMatrix({
11299
11469
  ] }, quadrant.id);
11300
11470
  }),
11301
11471
  validPoints.map((point, index) => {
11302
- const x = clamp4(scale2(point.x, xDomain, 40, width - 40), 40, width - 40);
11303
- const y = clamp4(scale2(point.y, yDomain, height - 48, 54), 54, height - 48);
11472
+ const x = clamp5(scale2(point.x, xDomain, 40, width - 40), 40, width - 40);
11473
+ const y = clamp5(scale2(point.y, yDomain, height - 48, 54), 54, height - 48);
11304
11474
  const tone = point.tone || (index % 2 === 0 ? "primary" : "accent");
11305
11475
  const selected = selectedPointId === point.id;
11306
11476
  const labelled = labelledPointIds.has(point.id);
11307
- const radius = labelled ? clamp4(scale2(point.size ?? 1, sizeDomain, 5, 9), 5, 9) : 3.5;
11308
- const fontSize = labelled ? clamp4(scale2(point.size ?? 1, sizeDomain, 14, 31), 14, 31) : 0;
11477
+ const radius = labelled ? clamp5(scale2(point.size ?? 1, sizeDomain, 5, 9), 5, 9) : 3.5;
11478
+ const fontSize = labelled ? clamp5(scale2(point.size ?? 1, sizeDomain, 14, 31), 14, 31) : 0;
11309
11479
  const pointStyle = {
11310
11480
  fill: toneColor(tone),
11311
11481
  stroke: "hsl(var(--foreground) / 0.74)"
@@ -11407,8 +11577,8 @@ function WorkbenchRadarMatrix({
11407
11577
  validPoints.map((point, index) => /* @__PURE__ */ jsx(
11408
11578
  "circle",
11409
11579
  {
11410
- cx: clamp4(scale2(point.x, xDomain, 40, width - 40), 40, width - 40),
11411
- cy: clamp4(scale2(point.y, yDomain, height - 48, 54), 54, height - 48),
11580
+ cx: clamp5(scale2(point.x, xDomain, 40, width - 40), 40, width - 40),
11581
+ cy: clamp5(scale2(point.y, yDomain, height - 48, 54), 54, height - 48),
11412
11582
  r: "8",
11413
11583
  style: { fill: toneColor(point.tone || (index % 2 === 0 ? "primary" : "accent")) }
11414
11584
  },