@inf-monkeys-tech/monkeys-design 1.0.38 → 1.0.39
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/components/agent-workbench/index.js +9 -0
- package/dist/components/agent-workbench/index.js.map +1 -1
- package/dist/components/agent-workbench/index.mjs +9 -0
- package/dist/components/agent-workbench/index.mjs.map +1 -1
- package/dist/components/base/index.js +9 -0
- package/dist/components/base/index.js.map +1 -1
- package/dist/components/base/index.mjs +9 -0
- package/dist/components/base/index.mjs.map +1 -1
- package/dist/components/data-explorer/index.js +9 -0
- package/dist/components/data-explorer/index.js.map +1 -1
- package/dist/components/data-explorer/index.mjs +9 -0
- package/dist/components/data-explorer/index.mjs.map +1 -1
- package/dist/components/layout/index.js +9 -0
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/index.mjs +9 -0
- package/dist/components/layout/index.mjs.map +1 -1
- package/dist/components/runtime/index.js +9 -0
- package/dist/components/runtime/index.js.map +1 -1
- package/dist/components/runtime/index.mjs +9 -0
- package/dist/components/runtime/index.mjs.map +1 -1
- package/dist/components/toast/index.d.mts +1 -1
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/index.js +9 -0
- package/dist/components/toast/index.js.map +1 -1
- package/dist/components/toast/index.mjs +9 -0
- package/dist/components/toast/index.mjs.map +1 -1
- package/dist/components/toolbar/index.js +9 -0
- package/dist/components/toolbar/index.js.map +1 -1
- package/dist/components/toolbar/index.mjs +9 -0
- package/dist/components/toolbar/index.mjs.map +1 -1
- package/dist/components/workbench/index.d.mts +218 -6
- package/dist/components/workbench/index.d.ts +218 -6
- package/dist/components/workbench/index.js +1088 -97
- package/dist/components/workbench/index.js.map +1 -1
- package/dist/components/workbench/index.mjs +1089 -99
- package/dist/components/workbench/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +838 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +838 -101
- package/dist/index.mjs.map +1 -1
- package/dist/locale/index.d.mts +20 -2
- package/dist/locale/index.d.ts +20 -2
- package/dist/locale/index.js +22 -0
- package/dist/locale/index.js.map +1 -1
- package/dist/locale/index.mjs +22 -0
- package/dist/locale/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +2 -2
- package/dist/provider/index.d.ts +2 -2
- package/dist/provider/index.js +22 -0
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +22 -0
- package/dist/provider/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{types-b8d18b1454c2.d.mts → types-453d18eab188.d.mts} +10 -0
- package/dist/{types-b8d18b1454c2.d.ts → types-453d18eab188.d.ts} +10 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3037,6 +3037,15 @@ var enUS = {
|
|
|
3037
3037
|
}
|
|
3038
3038
|
},
|
|
3039
3039
|
workbench: {
|
|
3040
|
+
collection: {
|
|
3041
|
+
label: "Collection",
|
|
3042
|
+
loading: "Loading items",
|
|
3043
|
+
empty: "No items",
|
|
3044
|
+
loadError: "Unable to load items",
|
|
3045
|
+
refreshError: "Unable to refresh items",
|
|
3046
|
+
retry: "Retry",
|
|
3047
|
+
loadingMore: "Loading more items"
|
|
3048
|
+
},
|
|
3040
3049
|
interactiveTable: {
|
|
3041
3050
|
columnActions: "Column actions",
|
|
3042
3051
|
freezeColumn: "Freeze to left",
|
|
@@ -3308,6 +3317,15 @@ var zhCN = {
|
|
|
3308
3317
|
}
|
|
3309
3318
|
},
|
|
3310
3319
|
workbench: {
|
|
3320
|
+
collection: {
|
|
3321
|
+
label: "\u5185\u5BB9\u96C6\u5408",
|
|
3322
|
+
loading: "\u6B63\u5728\u52A0\u8F7D\u5185\u5BB9",
|
|
3323
|
+
empty: "\u6682\u65E0\u5185\u5BB9",
|
|
3324
|
+
loadError: "\u65E0\u6CD5\u52A0\u8F7D\u5185\u5BB9",
|
|
3325
|
+
refreshError: "\u65E0\u6CD5\u5237\u65B0\u5185\u5BB9",
|
|
3326
|
+
retry: "\u91CD\u8BD5",
|
|
3327
|
+
loadingMore: "\u6B63\u5728\u52A0\u8F7D\u66F4\u591A\u5185\u5BB9"
|
|
3328
|
+
},
|
|
3311
3329
|
interactiveTable: {
|
|
3312
3330
|
columnActions: "\u5217\u64CD\u4F5C",
|
|
3313
3331
|
freezeColumn: "\u56FA\u5B9A\u5230\u5DE6\u4FA7",
|
|
@@ -3599,6 +3617,10 @@ function mergeMonkeysLocaleMessages(base, override) {
|
|
|
3599
3617
|
}
|
|
3600
3618
|
},
|
|
3601
3619
|
workbench: {
|
|
3620
|
+
collection: {
|
|
3621
|
+
...base.workbench.collection,
|
|
3622
|
+
...override.workbench?.collection
|
|
3623
|
+
},
|
|
3602
3624
|
interactiveTable: {
|
|
3603
3625
|
...base.workbench.interactiveTable,
|
|
3604
3626
|
...override.workbench?.interactiveTable
|
|
@@ -21975,6 +21997,7 @@ var DEFAULT_MASONRY_GAP_PX = 12;
|
|
|
21975
21997
|
var DEFAULT_MASONRY_ROW_HEIGHT_PX = 8;
|
|
21976
21998
|
var DEFAULT_MASONRY_COLUMN_WIDTH_PX = 280;
|
|
21977
21999
|
var DEFAULT_MASONRY_ITEM_HEIGHT_PX = 240;
|
|
22000
|
+
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
21978
22001
|
function clamp3(value, min5, max5) {
|
|
21979
22002
|
return Math.min(Math.max(value, min5), max5);
|
|
21980
22003
|
}
|
|
@@ -22079,9 +22102,12 @@ function WorkbenchMasonryLayout({
|
|
|
22079
22102
|
getItemKey = (item, index) => item?.id ?? item?.key ?? index,
|
|
22080
22103
|
getItemSize,
|
|
22081
22104
|
columnWidth = DEFAULT_MASONRY_COLUMN_WIDTH_PX,
|
|
22105
|
+
columnCount: requestedColumnCount,
|
|
22082
22106
|
gap = DEFAULT_MASONRY_GAP_PX,
|
|
22083
22107
|
rowHeight = DEFAULT_MASONRY_ROW_HEIGHT_PX,
|
|
22084
22108
|
placementStrategy = "shelf",
|
|
22109
|
+
containerProps,
|
|
22110
|
+
getItemProps,
|
|
22085
22111
|
className
|
|
22086
22112
|
}) {
|
|
22087
22113
|
const containerRef = useRef(null);
|
|
@@ -22112,8 +22138,9 @@ function WorkbenchMasonryLayout({
|
|
|
22112
22138
|
}, []);
|
|
22113
22139
|
useEffect(() => {
|
|
22114
22140
|
setMeasuredHeights((prev) => {
|
|
22141
|
+
const currentItemKeys = new Set(itemKeys);
|
|
22115
22142
|
const next = Object.fromEntries(
|
|
22116
|
-
Object.entries(prev).filter(([key]) =>
|
|
22143
|
+
Object.entries(prev).filter(([key]) => currentItemKeys.has(key))
|
|
22117
22144
|
);
|
|
22118
22145
|
return areMeasurementMapsEqual(prev, next) ? prev : next;
|
|
22119
22146
|
});
|
|
@@ -22124,7 +22151,8 @@ function WorkbenchMasonryLayout({
|
|
|
22124
22151
|
containerRef.current
|
|
22125
22152
|
);
|
|
22126
22153
|
const isDensePlacement = placementStrategy === "dense";
|
|
22127
|
-
const
|
|
22154
|
+
const normalizedRequestedColumnCount = Number.isFinite(requestedColumnCount) && Number(requestedColumnCount) > 0 ? clamp3(Math.round(Number(requestedColumnCount)), 1, 24) : void 0;
|
|
22155
|
+
const columnCount = normalizedRequestedColumnCount || getMasonryColumnCount({
|
|
22128
22156
|
containerWidth,
|
|
22129
22157
|
itemCount: items.length,
|
|
22130
22158
|
targetColumnWidth: resolvedTargetColumnWidth,
|
|
@@ -22170,7 +22198,7 @@ function WorkbenchMasonryLayout({
|
|
|
22170
22198
|
resolvedColumnWidth,
|
|
22171
22199
|
rowHeight
|
|
22172
22200
|
]);
|
|
22173
|
-
|
|
22201
|
+
useIsomorphicLayoutEffect(() => {
|
|
22174
22202
|
const nextMeasurements = {};
|
|
22175
22203
|
itemNodesRef.current.forEach((node, key) => {
|
|
22176
22204
|
const nextHeight = Math.ceil(node.getBoundingClientRect().height);
|
|
@@ -22232,10 +22260,21 @@ function WorkbenchMasonryLayout({
|
|
|
22232
22260
|
const positionedItems = layoutItems.map(({ key, item, columnSpan, rowSpan, size }) => {
|
|
22233
22261
|
const resolvedSpan = clamp3(columnSpan, 1, columnCount);
|
|
22234
22262
|
let startColumn = nextColumnIndex;
|
|
22235
|
-
if (
|
|
22236
|
-
|
|
22263
|
+
if (placementStrategy === "shortest") {
|
|
22264
|
+
let shortestBottom = Number.POSITIVE_INFINITY;
|
|
22265
|
+
for (let candidate = 0; candidate <= columnCount - resolvedSpan; candidate += 1) {
|
|
22266
|
+
const candidateBottom = Math.max(...columnBottoms.slice(candidate, candidate + resolvedSpan));
|
|
22267
|
+
if (candidateBottom < shortestBottom) {
|
|
22268
|
+
shortestBottom = candidateBottom;
|
|
22269
|
+
startColumn = candidate;
|
|
22270
|
+
}
|
|
22271
|
+
}
|
|
22272
|
+
} else {
|
|
22273
|
+
if (startColumn + resolvedSpan > columnCount) {
|
|
22274
|
+
startColumn = 0;
|
|
22275
|
+
}
|
|
22276
|
+
startColumn = Math.min(startColumn, columnCount - resolvedSpan);
|
|
22237
22277
|
}
|
|
22238
|
-
startColumn = Math.min(startColumn, columnCount - resolvedSpan);
|
|
22239
22278
|
const itemWidth = resolvedColumnWidth * resolvedSpan + gap * Math.max(resolvedSpan - 1, 0);
|
|
22240
22279
|
const itemHeight = getResolvedItemHeight({
|
|
22241
22280
|
size,
|
|
@@ -22248,9 +22287,11 @@ function WorkbenchMasonryLayout({
|
|
|
22248
22287
|
columnBottoms[columnIndex] = bottom + gap;
|
|
22249
22288
|
}
|
|
22250
22289
|
maxBottom = Math.max(maxBottom, bottom);
|
|
22251
|
-
|
|
22252
|
-
|
|
22253
|
-
nextColumnIndex
|
|
22290
|
+
if (placementStrategy !== "shortest") {
|
|
22291
|
+
nextColumnIndex = startColumn + resolvedSpan;
|
|
22292
|
+
if (nextColumnIndex >= columnCount) {
|
|
22293
|
+
nextColumnIndex = 0;
|
|
22294
|
+
}
|
|
22254
22295
|
}
|
|
22255
22296
|
return {
|
|
22256
22297
|
key,
|
|
@@ -22273,33 +22314,38 @@ function WorkbenchMasonryLayout({
|
|
|
22273
22314
|
"div",
|
|
22274
22315
|
{
|
|
22275
22316
|
ref: containerRef,
|
|
22276
|
-
|
|
22277
|
-
|
|
22317
|
+
...containerProps,
|
|
22318
|
+
className: cn("relative w-full", className, containerProps?.className),
|
|
22319
|
+
style: { ...containerProps?.style, height: `${orderedLayout.containerHeight}px` },
|
|
22278
22320
|
children: orderedLayout.positionedItems.map(({ key, item, columnSpan, rowSpan, size, itemWidth, left, top }) => {
|
|
22279
22321
|
const unresolvedSingleColumnWidth = containerWidth <= 0 && columnCount === 1;
|
|
22280
22322
|
const itemWidthValue = unresolvedSingleColumnWidth ? "100%" : `${itemWidth}px`;
|
|
22323
|
+
const layoutContext = {
|
|
22324
|
+
columnCount,
|
|
22325
|
+
columnSpan,
|
|
22326
|
+
columnWidth: resolvedColumnWidth,
|
|
22327
|
+
containerWidth,
|
|
22328
|
+
gap,
|
|
22329
|
+
itemWidth,
|
|
22330
|
+
placementStrategy,
|
|
22331
|
+
rowSpan,
|
|
22332
|
+
rowHeight,
|
|
22333
|
+
size
|
|
22334
|
+
};
|
|
22335
|
+
const itemProps = getItemProps?.(item, layoutContext);
|
|
22281
22336
|
return /* @__PURE__ */ jsx(
|
|
22282
22337
|
"div",
|
|
22283
22338
|
{
|
|
22284
|
-
|
|
22339
|
+
...itemProps,
|
|
22340
|
+
className: cn("absolute min-w-0", itemProps?.className),
|
|
22285
22341
|
style: {
|
|
22342
|
+
...itemProps?.style,
|
|
22286
22343
|
left: unresolvedSingleColumnWidth ? 0 : `${left}px`,
|
|
22287
22344
|
top: `${top}px`,
|
|
22288
22345
|
width: itemWidthValue,
|
|
22289
22346
|
maxWidth: itemWidthValue
|
|
22290
22347
|
},
|
|
22291
|
-
children: /* @__PURE__ */ jsx("div", { ref: (node) => registerItemNode(key, node), className: "min-w-0", children: renderItem(item,
|
|
22292
|
-
columnCount,
|
|
22293
|
-
columnSpan,
|
|
22294
|
-
columnWidth: resolvedColumnWidth,
|
|
22295
|
-
containerWidth,
|
|
22296
|
-
gap,
|
|
22297
|
-
itemWidth,
|
|
22298
|
-
placementStrategy,
|
|
22299
|
-
rowSpan,
|
|
22300
|
-
rowHeight,
|
|
22301
|
-
size
|
|
22302
|
-
}) })
|
|
22348
|
+
children: /* @__PURE__ */ jsx("div", { ref: (node) => registerItemNode(key, node), role: "presentation", className: "min-w-0", children: renderItem(item, layoutContext) })
|
|
22303
22349
|
},
|
|
22304
22350
|
key
|
|
22305
22351
|
);
|
|
@@ -22311,35 +22357,717 @@ function WorkbenchMasonryLayout({
|
|
|
22311
22357
|
"div",
|
|
22312
22358
|
{
|
|
22313
22359
|
ref: containerRef,
|
|
22314
|
-
|
|
22360
|
+
...containerProps,
|
|
22361
|
+
className: cn("grid w-full items-start", className, containerProps?.className),
|
|
22315
22362
|
style: {
|
|
22363
|
+
...containerProps?.style,
|
|
22316
22364
|
gap: `${gap}px`,
|
|
22317
22365
|
gridAutoFlow: "row dense",
|
|
22318
22366
|
gridAutoRows: `${rowHeight}px`,
|
|
22319
22367
|
gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))`
|
|
22320
22368
|
},
|
|
22321
|
-
children: layoutItems.map(({ key, item, columnSpan, rowSpan, size }) =>
|
|
22322
|
-
|
|
22369
|
+
children: layoutItems.map(({ key, item, columnSpan, rowSpan, size }) => {
|
|
22370
|
+
const layoutContext = {
|
|
22371
|
+
columnCount,
|
|
22372
|
+
columnSpan,
|
|
22373
|
+
columnWidth: resolvedColumnWidth,
|
|
22374
|
+
containerWidth,
|
|
22375
|
+
gap,
|
|
22376
|
+
placementStrategy,
|
|
22377
|
+
rowSpan,
|
|
22378
|
+
rowHeight,
|
|
22379
|
+
size
|
|
22380
|
+
};
|
|
22381
|
+
const itemProps = getItemProps?.(item, layoutContext);
|
|
22382
|
+
return /* @__PURE__ */ jsx(
|
|
22383
|
+
"div",
|
|
22384
|
+
{
|
|
22385
|
+
...itemProps,
|
|
22386
|
+
className: cn("min-w-0", itemProps?.className),
|
|
22387
|
+
style: {
|
|
22388
|
+
...itemProps?.style,
|
|
22389
|
+
gridColumn: `span ${columnSpan}`,
|
|
22390
|
+
gridRow: `span ${rowSpan}`
|
|
22391
|
+
},
|
|
22392
|
+
children: /* @__PURE__ */ jsx("div", { ref: (node) => registerItemNode(key, node), role: "presentation", className: "min-w-0", children: renderItem(item, layoutContext) })
|
|
22393
|
+
},
|
|
22394
|
+
key
|
|
22395
|
+
);
|
|
22396
|
+
})
|
|
22397
|
+
}
|
|
22398
|
+
);
|
|
22399
|
+
}
|
|
22400
|
+
var DEFAULT_GAP_PX = 12;
|
|
22401
|
+
var DEFAULT_ROW_HEIGHT_PX = 8;
|
|
22402
|
+
var DEFAULT_CARD_WIDTH_PX = 280;
|
|
22403
|
+
var BREAKPOINT_TABLET_PX = 640;
|
|
22404
|
+
var BREAKPOINT_DESKTOP_PX = 1024;
|
|
22405
|
+
var MAX_COLUMN_COUNT = 24;
|
|
22406
|
+
function clamp4(value, min5, max5) {
|
|
22407
|
+
return Math.min(Math.max(value, min5), max5);
|
|
22408
|
+
}
|
|
22409
|
+
function resolveRenderableSlot(slot, context) {
|
|
22410
|
+
return typeof slot === "function" ? slot(context) : slot;
|
|
22411
|
+
}
|
|
22412
|
+
function resolveLengthToPixels2(value, fallback, node) {
|
|
22413
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
22414
|
+
if (typeof value !== "string") return fallback;
|
|
22415
|
+
const normalized = value.trim().toLowerCase();
|
|
22416
|
+
if (!normalized) return fallback;
|
|
22417
|
+
if (/^\d+(\.\d+)?(px)?$/.test(normalized)) {
|
|
22418
|
+
const parsed = Number.parseFloat(normalized);
|
|
22419
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
22420
|
+
}
|
|
22421
|
+
if (normalized.endsWith("rem")) {
|
|
22422
|
+
const parsed = Number.parseFloat(normalized);
|
|
22423
|
+
const rootFontSize = typeof window === "undefined" ? 16 : Number.parseFloat(window.getComputedStyle(node || document.documentElement).fontSize) || 16;
|
|
22424
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed * rootFontSize : fallback;
|
|
22425
|
+
}
|
|
22426
|
+
return fallback;
|
|
22427
|
+
}
|
|
22428
|
+
function normalizeColumns(value) {
|
|
22429
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return void 0;
|
|
22430
|
+
return clamp4(Math.round(value), 1, MAX_COLUMN_COUNT);
|
|
22431
|
+
}
|
|
22432
|
+
function resolveResponsiveColumns(columns, containerWidth) {
|
|
22433
|
+
if (columns === "auto" || columns === void 0) return void 0;
|
|
22434
|
+
if (typeof columns === "number") return normalizeColumns(columns);
|
|
22435
|
+
const mobile = normalizeColumns(columns.mobile);
|
|
22436
|
+
const tablet = normalizeColumns(columns.tablet);
|
|
22437
|
+
const desktop = normalizeColumns(columns.desktop);
|
|
22438
|
+
if (containerWidth >= BREAKPOINT_DESKTOP_PX) return desktop ?? tablet ?? mobile;
|
|
22439
|
+
if (containerWidth >= BREAKPOINT_TABLET_PX) return tablet ?? mobile ?? desktop;
|
|
22440
|
+
return mobile ?? tablet ?? desktop;
|
|
22441
|
+
}
|
|
22442
|
+
function resolveColumnCount({
|
|
22443
|
+
containerWidth,
|
|
22444
|
+
itemCount,
|
|
22445
|
+
gap,
|
|
22446
|
+
columns,
|
|
22447
|
+
minCardWidth,
|
|
22448
|
+
idealCardWidth,
|
|
22449
|
+
maxCardWidth,
|
|
22450
|
+
node
|
|
22451
|
+
}) {
|
|
22452
|
+
const fixedColumns = resolveResponsiveColumns(columns, containerWidth);
|
|
22453
|
+
if (fixedColumns) return fixedColumns;
|
|
22454
|
+
if (!containerWidth) return 1;
|
|
22455
|
+
const idealWidth = resolveLengthToPixels2(idealCardWidth, DEFAULT_CARD_WIDTH_PX, node);
|
|
22456
|
+
const minWidth = resolveLengthToPixels2(minCardWidth, idealWidth * 0.78, node);
|
|
22457
|
+
const maxWidth = Math.max(
|
|
22458
|
+
minWidth,
|
|
22459
|
+
resolveLengthToPixels2(maxCardWidth, idealWidth * 1.35, node)
|
|
22460
|
+
);
|
|
22461
|
+
const safeItemCount = Math.max(itemCount, 1);
|
|
22462
|
+
const maxCandidate = Math.max(
|
|
22463
|
+
1,
|
|
22464
|
+
Math.min(
|
|
22465
|
+
safeItemCount,
|
|
22466
|
+
Math.ceil((containerWidth + gap) / (Math.max(minWidth * 0.75, 1) + gap))
|
|
22467
|
+
)
|
|
22468
|
+
);
|
|
22469
|
+
let bestCount = 1;
|
|
22470
|
+
let bestScore = Number.POSITIVE_INFINITY;
|
|
22471
|
+
for (let candidate = 1; candidate <= maxCandidate; candidate += 1) {
|
|
22472
|
+
const width = (containerWidth - gap * Math.max(candidate - 1, 0)) / candidate;
|
|
22473
|
+
if (!Number.isFinite(width) || width <= 0) continue;
|
|
22474
|
+
const score = Math.abs(width - idealWidth) + Math.max(0, minWidth - width) * 3 + Math.max(0, width - maxWidth) * 2;
|
|
22475
|
+
if (score < bestScore) {
|
|
22476
|
+
bestScore = score;
|
|
22477
|
+
bestCount = candidate;
|
|
22478
|
+
}
|
|
22479
|
+
}
|
|
22480
|
+
return bestCount;
|
|
22481
|
+
}
|
|
22482
|
+
function normalizeGap(value) {
|
|
22483
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : DEFAULT_GAP_PX;
|
|
22484
|
+
}
|
|
22485
|
+
function normalizeRowHeight(value) {
|
|
22486
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : DEFAULT_ROW_HEIGHT_PX;
|
|
22487
|
+
}
|
|
22488
|
+
function normalizeThreshold(value) {
|
|
22489
|
+
return typeof value === "number" && Number.isFinite(value) ? clamp4(value, 0, 1) : 0;
|
|
22490
|
+
}
|
|
22491
|
+
function normalizeItemSize(size, aspectRatio, columnWidth) {
|
|
22492
|
+
const normalizedAspectRatio = Number.isFinite(aspectRatio) && Number(aspectRatio) > 0 ? Number(aspectRatio) : void 0;
|
|
22493
|
+
const normalizedHeight = size?.height ?? (normalizedAspectRatio ? Math.max(1, columnWidth / normalizedAspectRatio) : void 0);
|
|
22494
|
+
return {
|
|
22495
|
+
...size,
|
|
22496
|
+
height: normalizedHeight
|
|
22497
|
+
};
|
|
22498
|
+
}
|
|
22499
|
+
function getDefaultItemKey(item, index) {
|
|
22500
|
+
if (item && typeof item === "object") {
|
|
22501
|
+
const candidate = item;
|
|
22502
|
+
if (typeof candidate.id === "string" || typeof candidate.id === "number") return candidate.id;
|
|
22503
|
+
if (typeof candidate.key === "string" || typeof candidate.key === "number") return candidate.key;
|
|
22504
|
+
}
|
|
22505
|
+
return index;
|
|
22506
|
+
}
|
|
22507
|
+
function getScrollStorageKey(key) {
|
|
22508
|
+
return `@inf-monkeys-tech/monkeys-design:workbench-collection:${key}`;
|
|
22509
|
+
}
|
|
22510
|
+
function getParentScrollOwner(node) {
|
|
22511
|
+
let current = node?.parentElement ?? null;
|
|
22512
|
+
while (current) {
|
|
22513
|
+
if (typeof window === "undefined") return current;
|
|
22514
|
+
const overflowY = window.getComputedStyle(current).overflowY;
|
|
22515
|
+
if (overflowY === "auto" || overflowY === "scroll") return current;
|
|
22516
|
+
current = current.parentElement;
|
|
22517
|
+
}
|
|
22518
|
+
return null;
|
|
22519
|
+
}
|
|
22520
|
+
function setsEqual(left, right) {
|
|
22521
|
+
if (left.size !== right.size) return false;
|
|
22522
|
+
for (const value of left) {
|
|
22523
|
+
if (!right.has(value)) return false;
|
|
22524
|
+
}
|
|
22525
|
+
return true;
|
|
22526
|
+
}
|
|
22527
|
+
function isInteractiveEventTarget(target, currentTarget) {
|
|
22528
|
+
if (typeof Element === "undefined" || !(target instanceof Element) || target === currentTarget) return false;
|
|
22529
|
+
const control = target.closest(
|
|
22530
|
+
'a, button, input, select, textarea, summary, [contenteditable="true"], [data-collection-action]'
|
|
22531
|
+
);
|
|
22532
|
+
return Boolean(control && currentTarget.contains(control));
|
|
22533
|
+
}
|
|
22534
|
+
function warnOnDuplicateKeys(keys) {
|
|
22535
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
22536
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22537
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
22538
|
+
keys.forEach((key) => {
|
|
22539
|
+
const stringKey = String(key);
|
|
22540
|
+
if (seen.has(stringKey)) duplicates.add(stringKey);
|
|
22541
|
+
seen.add(stringKey);
|
|
22542
|
+
});
|
|
22543
|
+
if (duplicates.size) {
|
|
22544
|
+
console.warn(`WorkbenchCollection received duplicate item keys: ${Array.from(duplicates).join(", ")}`);
|
|
22545
|
+
}
|
|
22546
|
+
}
|
|
22547
|
+
function WorkbenchCollection({
|
|
22548
|
+
items,
|
|
22549
|
+
config,
|
|
22550
|
+
renderItem,
|
|
22551
|
+
slots,
|
|
22552
|
+
callbacks,
|
|
22553
|
+
className,
|
|
22554
|
+
classNames,
|
|
22555
|
+
style,
|
|
22556
|
+
ariaLabel
|
|
22557
|
+
}) {
|
|
22558
|
+
const componentAttributes = useMonkeysComponentAttributes();
|
|
22559
|
+
const localeMessages = useMonkeysLocaleMessages().workbench.collection;
|
|
22560
|
+
const componentId = useId().replace(/:/g, "");
|
|
22561
|
+
const rootRef = useRef(null);
|
|
22562
|
+
const itemsRef = useRef(null);
|
|
22563
|
+
const loadMoreRef = useRef(null);
|
|
22564
|
+
const lastSelectedIndexRef = useRef(null);
|
|
22565
|
+
const loadMoreLockedRef = useRef(false);
|
|
22566
|
+
const layoutReadyRef = useRef(false);
|
|
22567
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
22568
|
+
const [itemsNode, setItemsNode] = useState(null);
|
|
22569
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = useState(
|
|
22570
|
+
() => new Set(config.selection?.defaultSelectedKeys ?? [])
|
|
22571
|
+
);
|
|
22572
|
+
const callbacksRef = useRef(callbacks);
|
|
22573
|
+
callbacksRef.current = callbacks;
|
|
22574
|
+
const registerItemsNode = useCallback((node) => {
|
|
22575
|
+
itemsRef.current = node;
|
|
22576
|
+
setItemsNode(node);
|
|
22577
|
+
}, []);
|
|
22578
|
+
const mode = config.layout.mode;
|
|
22579
|
+
if (mode !== "grid" && mode !== "masonry" && mode !== "dense" && mode !== "rail") {
|
|
22580
|
+
throw new TypeError(`WorkbenchCollection layout.mode "${String(mode)}" is not supported.`);
|
|
22581
|
+
}
|
|
22582
|
+
const gap = normalizeGap(config.layout.gap);
|
|
22583
|
+
const rowHeight = normalizeRowHeight(config.layout.rowHeight);
|
|
22584
|
+
const getItemKey = config.getItemKey ?? getDefaultItemKey;
|
|
22585
|
+
const normalizedItems = useMemo(() => items.map((item, index) => {
|
|
22586
|
+
const key = getItemKey(item, index);
|
|
22587
|
+
return { item, index, key, stringKey: String(key) };
|
|
22588
|
+
}), [getItemKey, items]);
|
|
22589
|
+
const keys = useMemo(
|
|
22590
|
+
() => normalizedItems.map(({ key }) => key),
|
|
22591
|
+
[normalizedItems]
|
|
22592
|
+
);
|
|
22593
|
+
const keysSignature = normalizedItems.map(({ stringKey }) => stringKey).join("");
|
|
22594
|
+
useEffect(() => warnOnDuplicateKeys(keys), [keys, keysSignature]);
|
|
22595
|
+
const selectionMode = config.selection?.mode ?? "none";
|
|
22596
|
+
const controlledSelection = config.selection?.selectedKeys !== void 0;
|
|
22597
|
+
const selectedKeys = useMemo(
|
|
22598
|
+
() => selectionMode === "none" ? /* @__PURE__ */ new Set() : controlledSelection ? new Set(config.selection?.selectedKeys ?? []) : internalSelectedKeys,
|
|
22599
|
+
[config.selection?.selectedKeys, controlledSelection, internalSelectedKeys, selectionMode]
|
|
22600
|
+
);
|
|
22601
|
+
useEffect(() => {
|
|
22602
|
+
if (controlledSelection) return;
|
|
22603
|
+
const availableKeys = new Set(keys);
|
|
22604
|
+
setInternalSelectedKeys((previous) => {
|
|
22605
|
+
const next = new Set(Array.from(previous).filter((key) => availableKeys.has(key)));
|
|
22606
|
+
return setsEqual(previous, next) ? previous : next;
|
|
22607
|
+
});
|
|
22608
|
+
}, [controlledSelection, keys, keysSignature]);
|
|
22609
|
+
useEffect(() => {
|
|
22610
|
+
const node = itemsNode;
|
|
22611
|
+
if (!node) return void 0;
|
|
22612
|
+
const updateWidth = () => {
|
|
22613
|
+
const nextWidth = Math.round(node.getBoundingClientRect().width);
|
|
22614
|
+
setContainerWidth((previous) => previous === nextWidth ? previous : nextWidth);
|
|
22615
|
+
};
|
|
22616
|
+
updateWidth();
|
|
22617
|
+
if (typeof ResizeObserver === "function") {
|
|
22618
|
+
const observer = new ResizeObserver(updateWidth);
|
|
22619
|
+
observer.observe(node);
|
|
22620
|
+
return () => observer.disconnect();
|
|
22621
|
+
}
|
|
22622
|
+
if (typeof window === "undefined") return void 0;
|
|
22623
|
+
window.addEventListener("resize", updateWidth);
|
|
22624
|
+
return () => window.removeEventListener("resize", updateWidth);
|
|
22625
|
+
}, [itemsNode]);
|
|
22626
|
+
const columnCount = resolveColumnCount({
|
|
22627
|
+
containerWidth,
|
|
22628
|
+
itemCount: normalizedItems.length,
|
|
22629
|
+
gap,
|
|
22630
|
+
columns: config.layout.columns,
|
|
22631
|
+
minCardWidth: config.layout.minCardWidth,
|
|
22632
|
+
idealCardWidth: config.layout.idealCardWidth ?? config.layout.columnWidth,
|
|
22633
|
+
maxCardWidth: config.layout.maxCardWidth,
|
|
22634
|
+
node: itemsRef.current
|
|
22635
|
+
});
|
|
22636
|
+
const columnWidth = containerWidth > 0 ? Math.max(0, (containerWidth - gap * Math.max(columnCount - 1, 0)) / columnCount) : resolveLengthToPixels2(
|
|
22637
|
+
config.layout.cardWidth ?? config.layout.columnWidth ?? config.layout.idealCardWidth,
|
|
22638
|
+
DEFAULT_CARD_WIDTH_PX,
|
|
22639
|
+
itemsRef.current
|
|
22640
|
+
);
|
|
22641
|
+
const placementStrategy = config.layout.placementStrategy ?? (mode === "dense" ? "dense" : mode === "masonry" ? "shortest" : "shelf");
|
|
22642
|
+
const labels = useMemo(() => ({
|
|
22643
|
+
collection: config.labels?.collection ?? localeMessages.label,
|
|
22644
|
+
loading: config.labels?.loading ?? localeMessages.loading,
|
|
22645
|
+
empty: config.labels?.empty ?? localeMessages.empty,
|
|
22646
|
+
loadError: config.labels?.loadError ?? localeMessages.loadError,
|
|
22647
|
+
refreshError: config.labels?.refreshError ?? localeMessages.refreshError,
|
|
22648
|
+
retry: config.labels?.retry ?? localeMessages.retry,
|
|
22649
|
+
loadingMore: config.labels?.loadingMore ?? localeMessages.loadingMore
|
|
22650
|
+
}), [config.labels, localeMessages]);
|
|
22651
|
+
const virtualizationError = useMemo(() => {
|
|
22652
|
+
const virtualization = config.virtualization;
|
|
22653
|
+
if (virtualization?.enabled !== true || virtualization.fallback !== "error") return null;
|
|
22654
|
+
if (!virtualization.adapter) {
|
|
22655
|
+
return new Error("WorkbenchCollection virtualization requires an adapter.");
|
|
22656
|
+
}
|
|
22657
|
+
if (virtualization.adapter.supports?.(mode) === false) {
|
|
22658
|
+
return new Error(`WorkbenchCollection virtualization adapter does not support mode "${mode}".`);
|
|
22659
|
+
}
|
|
22660
|
+
return null;
|
|
22661
|
+
}, [config.virtualization, mode]);
|
|
22662
|
+
const layoutSnapshot = useMemo(() => ({
|
|
22663
|
+
mode,
|
|
22664
|
+
columnCount,
|
|
22665
|
+
columnWidth,
|
|
22666
|
+
containerWidth,
|
|
22667
|
+
gap,
|
|
22668
|
+
itemCount: normalizedItems.length
|
|
22669
|
+
}), [columnCount, columnWidth, containerWidth, gap, mode, normalizedItems.length]);
|
|
22670
|
+
useEffect(() => {
|
|
22671
|
+
callbacksRef.current?.onLayoutChange?.(layoutSnapshot);
|
|
22672
|
+
if (containerWidth > 0 && !layoutReadyRef.current) {
|
|
22673
|
+
layoutReadyRef.current = true;
|
|
22674
|
+
callbacksRef.current?.onLayoutReady?.(layoutSnapshot);
|
|
22675
|
+
}
|
|
22676
|
+
}, [layoutSnapshot, containerWidth]);
|
|
22677
|
+
useEffect(() => {
|
|
22678
|
+
layoutReadyRef.current = false;
|
|
22679
|
+
}, [mode]);
|
|
22680
|
+
const resolveScrollOwner = useCallback(() => {
|
|
22681
|
+
const requestedOwner = config.layout.scrollOwner;
|
|
22682
|
+
if (requestedOwner && requestedOwner !== "self" && requestedOwner !== "parent") return requestedOwner;
|
|
22683
|
+
if (requestedOwner === "parent") return getParentScrollOwner(rootRef.current);
|
|
22684
|
+
return rootRef.current;
|
|
22685
|
+
}, [config.layout.scrollOwner]);
|
|
22686
|
+
useEffect(() => {
|
|
22687
|
+
const restorationKey = config.scrollRestorationKey?.trim();
|
|
22688
|
+
if (!restorationKey || typeof window === "undefined") return void 0;
|
|
22689
|
+
const owner = resolveScrollOwner();
|
|
22690
|
+
if (!owner) return void 0;
|
|
22691
|
+
const storageKey = getScrollStorageKey(restorationKey);
|
|
22692
|
+
try {
|
|
22693
|
+
const stored = Number.parseFloat(window.sessionStorage.getItem(storageKey) ?? "");
|
|
22694
|
+
if (Number.isFinite(stored) && stored >= 0) owner.scrollTop = stored;
|
|
22695
|
+
} catch {
|
|
22696
|
+
}
|
|
22697
|
+
const saveScrollPosition = () => {
|
|
22698
|
+
try {
|
|
22699
|
+
window.sessionStorage.setItem(storageKey, String(owner.scrollTop));
|
|
22700
|
+
} catch {
|
|
22701
|
+
}
|
|
22702
|
+
};
|
|
22703
|
+
owner.addEventListener("scroll", saveScrollPosition, { passive: true });
|
|
22704
|
+
return () => {
|
|
22705
|
+
saveScrollPosition();
|
|
22706
|
+
owner.removeEventListener("scroll", saveScrollPosition);
|
|
22707
|
+
};
|
|
22708
|
+
}, [config.scrollRestorationKey, resolveScrollOwner]);
|
|
22709
|
+
const state = config.state;
|
|
22710
|
+
const loading = state?.loading === true;
|
|
22711
|
+
const loadingMore = state?.loadingMore === true;
|
|
22712
|
+
const hasMore = state?.hasMore === true;
|
|
22713
|
+
const canLoadMore = typeof callbacks?.onLoadMore === "function";
|
|
22714
|
+
const effectiveError = state?.error ?? virtualizationError;
|
|
22715
|
+
useEffect(() => {
|
|
22716
|
+
if (!loadingMore || !hasMore) loadMoreLockedRef.current = false;
|
|
22717
|
+
}, [hasMore, loadingMore, normalizedItems.length, keysSignature]);
|
|
22718
|
+
useEffect(() => {
|
|
22719
|
+
const sentinel = loadMoreRef.current;
|
|
22720
|
+
if (!sentinel || !canLoadMore || !hasMore || loadingMore) return void 0;
|
|
22721
|
+
if (typeof IntersectionObserver !== "function") return void 0;
|
|
22722
|
+
const owner = resolveScrollOwner();
|
|
22723
|
+
const observer = new IntersectionObserver((entries) => {
|
|
22724
|
+
if (!entries.some((entry) => entry.isIntersecting) || loadMoreLockedRef.current) return;
|
|
22725
|
+
loadMoreLockedRef.current = true;
|
|
22726
|
+
try {
|
|
22727
|
+
const result = callbacksRef.current?.onLoadMore?.();
|
|
22728
|
+
if (result && typeof result.then === "function") {
|
|
22729
|
+
void result.catch(() => {
|
|
22730
|
+
loadMoreLockedRef.current = false;
|
|
22731
|
+
});
|
|
22732
|
+
}
|
|
22733
|
+
} catch (error) {
|
|
22734
|
+
loadMoreLockedRef.current = false;
|
|
22735
|
+
throw error;
|
|
22736
|
+
}
|
|
22737
|
+
}, {
|
|
22738
|
+
root: owner === rootRef.current ? owner : owner || null,
|
|
22739
|
+
rootMargin: config.loading?.rootMargin ?? "240px",
|
|
22740
|
+
threshold: normalizeThreshold(config.loading?.threshold)
|
|
22741
|
+
});
|
|
22742
|
+
observer.observe(sentinel);
|
|
22743
|
+
return () => observer.disconnect();
|
|
22744
|
+
}, [canLoadMore, config.loading?.rootMargin, config.loading?.threshold, hasMore, keysSignature, loadingMore, normalizedItems.length, resolveScrollOwner]);
|
|
22745
|
+
const groups = useMemo(() => {
|
|
22746
|
+
if (!config.grouping) {
|
|
22747
|
+
return [{ key: "__all__", stringKey: "__all__", items: normalizedItems }];
|
|
22748
|
+
}
|
|
22749
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
22750
|
+
normalizedItems.forEach((entry) => {
|
|
22751
|
+
const groupKey = config.grouping?.getGroupKey(entry.item, entry.index) ?? "__all__";
|
|
22752
|
+
const stringKey = String(groupKey);
|
|
22753
|
+
const existing = grouped.get(stringKey);
|
|
22754
|
+
if (existing) {
|
|
22755
|
+
existing.items.push(entry);
|
|
22756
|
+
return;
|
|
22757
|
+
}
|
|
22758
|
+
grouped.set(stringKey, {
|
|
22759
|
+
key: groupKey,
|
|
22760
|
+
stringKey,
|
|
22761
|
+
label: config.grouping?.getGroupLabel?.(groupKey, entry.item),
|
|
22762
|
+
items: [entry]
|
|
22763
|
+
});
|
|
22764
|
+
});
|
|
22765
|
+
return Array.from(grouped.values());
|
|
22766
|
+
}, [config.grouping, normalizedItems]);
|
|
22767
|
+
const setSelection = useCallback((entry, behavior = config.selection?.behavior ?? (selectionMode === "multiple" ? "toggle" : "replace")) => {
|
|
22768
|
+
if (selectionMode === "none" || config.selection?.isItemDisabled?.(entry.item, entry.index)) return;
|
|
22769
|
+
const current = new Set(selectedKeys);
|
|
22770
|
+
const next = /* @__PURE__ */ new Set();
|
|
22771
|
+
if (selectionMode === "single") {
|
|
22772
|
+
if (!(behavior === "toggle" && current.has(entry.key))) next.add(entry.key);
|
|
22773
|
+
} else if (behavior === "range" && lastSelectedIndexRef.current !== null) {
|
|
22774
|
+
current.forEach((key) => next.add(key));
|
|
22775
|
+
const start = Math.min(lastSelectedIndexRef.current, entry.index);
|
|
22776
|
+
const end = Math.max(lastSelectedIndexRef.current, entry.index);
|
|
22777
|
+
normalizedItems.slice(start, end + 1).forEach((candidate) => {
|
|
22778
|
+
if (!config.selection?.isItemDisabled?.(candidate.item, candidate.index)) next.add(candidate.key);
|
|
22779
|
+
});
|
|
22780
|
+
} else if (behavior === "replace") {
|
|
22781
|
+
next.add(entry.key);
|
|
22782
|
+
} else {
|
|
22783
|
+
current.forEach((key) => next.add(key));
|
|
22784
|
+
if (next.has(entry.key)) next.delete(entry.key);
|
|
22785
|
+
else next.add(entry.key);
|
|
22786
|
+
}
|
|
22787
|
+
lastSelectedIndexRef.current = entry.index;
|
|
22788
|
+
if (!controlledSelection) setInternalSelectedKeys(next);
|
|
22789
|
+
callbacks?.onSelectionChange?.(next, { item: entry.item, key: entry.key, behavior });
|
|
22790
|
+
}, [callbacks, config.selection, controlledSelection, normalizedItems, selectedKeys, selectionMode]);
|
|
22791
|
+
const createItemContext = useCallback((entry, layout) => {
|
|
22792
|
+
const disabled = config.selection?.isItemDisabled?.(entry.item, entry.index) ?? false;
|
|
22793
|
+
const context = {
|
|
22794
|
+
item: entry.item,
|
|
22795
|
+
index: entry.index,
|
|
22796
|
+
key: entry.key,
|
|
22797
|
+
status: config.getItemStatus?.(entry.item, entry.index) ?? "idle",
|
|
22798
|
+
disabled,
|
|
22799
|
+
selected: selectedKeys.has(entry.key),
|
|
22800
|
+
selectionMode,
|
|
22801
|
+
layout,
|
|
22802
|
+
select: (behavior) => setSelection(entry, behavior),
|
|
22803
|
+
preview: () => callbacks?.onItemPreview?.(entry.item, context),
|
|
22804
|
+
detail: () => callbacks?.onItemDetail?.(entry.item, context),
|
|
22805
|
+
renderSlot: (name) => {
|
|
22806
|
+
return slots?.item?.[name]?.(entry.item, context);
|
|
22807
|
+
},
|
|
22808
|
+
notifyMediaLoad: () => callbacks?.onMediaLoad?.(entry.item, context),
|
|
22809
|
+
notifyMediaError: (error) => callbacks?.onMediaError?.(entry.item, context, error)
|
|
22810
|
+
};
|
|
22811
|
+
return context;
|
|
22812
|
+
}, [callbacks, config.getItemStatus, config.selection, selectedKeys, selectionMode, setSelection, slots?.item]);
|
|
22813
|
+
const getItemInteractionProps = useCallback((entry, context) => {
|
|
22814
|
+
const handleKeyboard = (event) => {
|
|
22815
|
+
if (event.target !== event.currentTarget || event.key !== "Enter" && event.key !== " ") return;
|
|
22816
|
+
event.preventDefault();
|
|
22817
|
+
if (selectionMode !== "none") context.select(event.shiftKey ? "range" : void 0);
|
|
22818
|
+
else callbacks?.onItemClick?.(entry.item, context, event);
|
|
22819
|
+
};
|
|
22820
|
+
return {
|
|
22821
|
+
id: `${componentId}-item-${entry.index}`,
|
|
22822
|
+
"data-monkeys-collection-item": "",
|
|
22823
|
+
"data-item-key": entry.stringKey,
|
|
22824
|
+
"data-selected": context.selected || void 0,
|
|
22825
|
+
"data-disabled": context.disabled || void 0,
|
|
22826
|
+
"data-status": context.status,
|
|
22827
|
+
role: selectionMode === "none" ? "listitem" : "option",
|
|
22828
|
+
"aria-selected": selectionMode === "none" ? void 0 : context.selected,
|
|
22829
|
+
"aria-disabled": context.disabled || void 0,
|
|
22830
|
+
tabIndex: callbacks?.onItemClick || selectionMode !== "none" ? 0 : void 0,
|
|
22831
|
+
draggable: callbacks?.onItemDragStart ? true : void 0,
|
|
22832
|
+
className: cn(
|
|
22833
|
+
"min-w-0 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
22834
|
+
config.appearance?.hover === "lift" && "transition-transform hover:-translate-y-0.5 motion-reduce:transform-none",
|
|
22835
|
+
config.appearance?.selection === "ring" && context.selected && "ring-2 ring-primary",
|
|
22836
|
+
config.appearance?.selection === "outline" && context.selected && "outline outline-2 outline-primary",
|
|
22837
|
+
classNames?.item
|
|
22838
|
+
),
|
|
22839
|
+
onClick: (event) => {
|
|
22840
|
+
if (isInteractiveEventTarget(event.target, event.currentTarget)) return;
|
|
22841
|
+
if (selectionMode !== "none") context.select(event.shiftKey ? "range" : void 0);
|
|
22842
|
+
callbacks?.onItemClick?.(entry.item, context, event);
|
|
22843
|
+
},
|
|
22844
|
+
onDoubleClick: (event) => {
|
|
22845
|
+
if (isInteractiveEventTarget(event.target, event.currentTarget)) return;
|
|
22846
|
+
callbacks?.onItemDoubleClick?.(entry.item, context, event);
|
|
22847
|
+
},
|
|
22848
|
+
onKeyDown: handleKeyboard,
|
|
22849
|
+
onDragStart: (event) => callbacks?.onItemDragStart?.(entry.item, context, event),
|
|
22850
|
+
onDragOver: callbacks?.onItemDrop ? (event) => event.preventDefault() : void 0,
|
|
22851
|
+
onDrop: (event) => callbacks?.onItemDrop?.(entry.item, context, event)
|
|
22852
|
+
};
|
|
22853
|
+
}, [callbacks, classNames?.item, componentId, config.appearance, selectionMode]);
|
|
22854
|
+
const renderEntry = useCallback((entry, layout, includeShell = true) => {
|
|
22855
|
+
const context = createItemContext(entry, layout);
|
|
22856
|
+
if (!includeShell) return renderItem(entry.item, context);
|
|
22857
|
+
return /* @__PURE__ */ jsx("div", { ...getItemInteractionProps(entry, context), children: renderItem(entry.item, context) });
|
|
22858
|
+
}, [createItemContext, getItemInteractionProps, renderItem]);
|
|
22859
|
+
const baseLayoutContext = useMemo(() => ({
|
|
22860
|
+
mode,
|
|
22861
|
+
columnCount,
|
|
22862
|
+
columnWidth,
|
|
22863
|
+
containerWidth,
|
|
22864
|
+
gap,
|
|
22865
|
+
placementStrategy,
|
|
22866
|
+
rowHeight
|
|
22867
|
+
}), [columnCount, columnWidth, containerWidth, gap, mode, placementStrategy, rowHeight]);
|
|
22868
|
+
const renderGroupItems = (group) => {
|
|
22869
|
+
const virtualization = config.virtualization;
|
|
22870
|
+
const adapter = virtualization?.adapter;
|
|
22871
|
+
const virtualizationRequested = virtualization?.enabled === true;
|
|
22872
|
+
if (virtualizationRequested && (!adapter || adapter.supports?.(mode) === false)) {
|
|
22873
|
+
if (virtualization?.fallback === "error") {
|
|
22874
|
+
return null;
|
|
22875
|
+
}
|
|
22876
|
+
}
|
|
22877
|
+
if (virtualizationRequested && adapter && adapter.supports?.(mode) !== false) {
|
|
22878
|
+
return adapter.render({
|
|
22879
|
+
items: group.items.map(({ item }) => item),
|
|
22880
|
+
keys: group.items.map(({ key }) => key),
|
|
22881
|
+
layout: config.layout,
|
|
22882
|
+
scrollOwner: resolveScrollOwner(),
|
|
22883
|
+
renderItem: (item, localIndex, layout) => {
|
|
22884
|
+
const entry = group.items[localIndex];
|
|
22885
|
+
return entry ? renderEntry(entry, layout) : null;
|
|
22886
|
+
}
|
|
22887
|
+
});
|
|
22888
|
+
}
|
|
22889
|
+
if (mode === "masonry" || mode === "dense") {
|
|
22890
|
+
return /* @__PURE__ */ jsx(
|
|
22891
|
+
WorkbenchMasonryLayout,
|
|
22323
22892
|
{
|
|
22324
|
-
|
|
22325
|
-
|
|
22326
|
-
|
|
22327
|
-
|
|
22893
|
+
items: group.items,
|
|
22894
|
+
columnCount,
|
|
22895
|
+
columnWidth: config.layout.cardWidth ?? config.layout.columnWidth ?? config.layout.idealCardWidth,
|
|
22896
|
+
gap,
|
|
22897
|
+
rowHeight,
|
|
22898
|
+
placementStrategy: mode === "dense" ? "dense" : placementStrategy,
|
|
22899
|
+
className: classNames?.layout,
|
|
22900
|
+
containerProps: {
|
|
22901
|
+
role: selectionMode === "none" ? "list" : "listbox",
|
|
22902
|
+
"aria-label": ariaLabel ?? labels.collection,
|
|
22903
|
+
"aria-multiselectable": selectionMode === "multiple" || void 0
|
|
22328
22904
|
},
|
|
22329
|
-
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
|
|
22336
|
-
|
|
22337
|
-
|
|
22338
|
-
|
|
22339
|
-
|
|
22905
|
+
getItemProps: (entry, masonryLayout) => {
|
|
22906
|
+
const context = createItemContext(entry, { ...masonryLayout, mode });
|
|
22907
|
+
return getItemInteractionProps(entry, context);
|
|
22908
|
+
},
|
|
22909
|
+
getItemKey: (entry) => entry.key,
|
|
22910
|
+
getItemSize: (entry, masonryLayout) => {
|
|
22911
|
+
const layout = {
|
|
22912
|
+
...masonryLayout,
|
|
22913
|
+
mode
|
|
22914
|
+
};
|
|
22915
|
+
const customSize = config.layout.getItemSize?.(entry.item, layout);
|
|
22916
|
+
const aspectRatio = config.layout.getItemAspectRatio?.(entry.item, entry.index);
|
|
22917
|
+
return normalizeItemSize(customSize, aspectRatio, masonryLayout.columnWidth);
|
|
22918
|
+
},
|
|
22919
|
+
renderItem: (entry, masonryLayout) => renderEntry(entry, {
|
|
22920
|
+
...masonryLayout,
|
|
22921
|
+
mode
|
|
22922
|
+
}, false)
|
|
22923
|
+
}
|
|
22924
|
+
);
|
|
22925
|
+
}
|
|
22926
|
+
if (mode === "rail") {
|
|
22927
|
+
const cardWidth = config.layout.cardWidth ?? config.layout.idealCardWidth ?? DEFAULT_CARD_WIDTH_PX;
|
|
22928
|
+
return /* @__PURE__ */ jsx(
|
|
22929
|
+
"div",
|
|
22930
|
+
{
|
|
22931
|
+
role: selectionMode === "none" ? "list" : "listbox",
|
|
22932
|
+
"aria-label": ariaLabel ?? labels.collection,
|
|
22933
|
+
"aria-multiselectable": selectionMode === "multiple" || void 0,
|
|
22934
|
+
className: cn("grid min-w-0 grid-flow-col items-start overflow-x-auto", classNames?.layout),
|
|
22935
|
+
style: { gap, gridAutoColumns: typeof cardWidth === "number" ? `${cardWidth}px` : cardWidth },
|
|
22936
|
+
children: group.items.map((entry) => /* @__PURE__ */ jsx(Fragment$1, { children: renderEntry(entry, baseLayoutContext) }, entry.stringKey))
|
|
22937
|
+
}
|
|
22938
|
+
);
|
|
22939
|
+
}
|
|
22940
|
+
return /* @__PURE__ */ jsx(
|
|
22941
|
+
"div",
|
|
22942
|
+
{
|
|
22943
|
+
role: selectionMode === "none" ? "list" : "listbox",
|
|
22944
|
+
"aria-label": ariaLabel ?? labels.collection,
|
|
22945
|
+
"aria-multiselectable": selectionMode === "multiple" || void 0,
|
|
22946
|
+
className: cn("grid min-w-0 items-start", classNames?.layout),
|
|
22947
|
+
style: {
|
|
22948
|
+
gap,
|
|
22949
|
+
gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))`
|
|
22340
22950
|
},
|
|
22341
|
-
|
|
22342
|
-
|
|
22951
|
+
children: group.items.map((entry) => {
|
|
22952
|
+
const customSize = config.layout.getItemSize?.(entry.item, baseLayoutContext);
|
|
22953
|
+
const span = clamp4(Math.round(Number(customSize?.columnSpan) || 1), 1, columnCount);
|
|
22954
|
+
const aspectRatio = config.layout.getItemAspectRatio?.(entry.item, entry.index);
|
|
22955
|
+
return /* @__PURE__ */ jsx(
|
|
22956
|
+
"div",
|
|
22957
|
+
{
|
|
22958
|
+
...getItemInteractionProps(
|
|
22959
|
+
entry,
|
|
22960
|
+
createItemContext(entry, { ...baseLayoutContext, columnSpan: span, size: customSize })
|
|
22961
|
+
),
|
|
22962
|
+
style: {
|
|
22963
|
+
gridColumn: span > 1 ? `span ${span}` : void 0,
|
|
22964
|
+
aspectRatio: Number.isFinite(aspectRatio) && Number(aspectRatio) > 0 ? String(aspectRatio) : void 0
|
|
22965
|
+
},
|
|
22966
|
+
children: renderEntry(entry, { ...baseLayoutContext, columnSpan: span, size: customSize }, false)
|
|
22967
|
+
},
|
|
22968
|
+
entry.stringKey
|
|
22969
|
+
);
|
|
22970
|
+
})
|
|
22971
|
+
}
|
|
22972
|
+
);
|
|
22973
|
+
};
|
|
22974
|
+
const slotContext = {
|
|
22975
|
+
items,
|
|
22976
|
+
error: effectiveError,
|
|
22977
|
+
loading,
|
|
22978
|
+
loadingMore,
|
|
22979
|
+
selectedKeys,
|
|
22980
|
+
retry: () => callbacks?.onRetry?.()
|
|
22981
|
+
};
|
|
22982
|
+
const header = resolveRenderableSlot(slots?.header, slotContext);
|
|
22983
|
+
const toolbar = resolveRenderableSlot(slots?.toolbar, slotContext);
|
|
22984
|
+
const selectionToolbar = selectedKeys.size > 0 ? resolveRenderableSlot(slots?.selectionToolbar, slotContext) : null;
|
|
22985
|
+
const beforeItems = resolveRenderableSlot(slots?.beforeItems, slotContext);
|
|
22986
|
+
const footer = resolveRenderableSlot(slots?.footer, slotContext);
|
|
22987
|
+
const showInitialLoading = loading && items.length === 0;
|
|
22988
|
+
const showInitialError = Boolean(effectiveError) && items.length === 0 && !showInitialLoading;
|
|
22989
|
+
const showEmpty = !showInitialLoading && !showInitialError && (state?.empty === true || items.length === 0);
|
|
22990
|
+
const loadingSlot = resolveRenderableSlot(slots?.loading, slotContext);
|
|
22991
|
+
const errorSlot = resolveRenderableSlot(slots?.error, slotContext);
|
|
22992
|
+
const emptySlot = resolveRenderableSlot(slots?.empty, slotContext);
|
|
22993
|
+
const loadMoreSlot = resolveRenderableSlot(slots?.loadMore, slotContext);
|
|
22994
|
+
const selfScrollable = config.layout.scrollOwner === "self" || config.layout.scrollOwner === void 0 && (config.layout.fillHeight || config.layout.maxHeight);
|
|
22995
|
+
const rootStyle = {
|
|
22996
|
+
...style,
|
|
22997
|
+
padding: config.layout.padding ?? style?.padding,
|
|
22998
|
+
height: config.layout.fillHeight ? "100%" : style?.height,
|
|
22999
|
+
maxHeight: config.layout.maxHeight ?? style?.maxHeight,
|
|
23000
|
+
overflow: selfScrollable ? "auto" : style?.overflow
|
|
23001
|
+
};
|
|
23002
|
+
return /* @__PURE__ */ jsxs(
|
|
23003
|
+
"section",
|
|
23004
|
+
{
|
|
23005
|
+
ref: rootRef,
|
|
23006
|
+
...componentAttributes,
|
|
23007
|
+
"data-monkeys-component": "workbench-collection",
|
|
23008
|
+
"data-layout-mode": mode,
|
|
23009
|
+
"data-density": config.appearance?.density,
|
|
23010
|
+
"data-radius": config.appearance?.radius,
|
|
23011
|
+
"data-media-fit": config.appearance?.mediaFit,
|
|
23012
|
+
"aria-label": ariaLabel ?? labels.collection,
|
|
23013
|
+
"aria-busy": loading || loadingMore || void 0,
|
|
23014
|
+
className: cn("min-h-0 min-w-0", config.layout.fillHeight && "h-full", classNames?.root, className),
|
|
23015
|
+
style: rootStyle,
|
|
23016
|
+
children: [
|
|
23017
|
+
hasRenderableNode(header) ? /* @__PURE__ */ jsx("div", { className: classNames?.header, children: header }) : null,
|
|
23018
|
+
hasRenderableNode(toolbar) ? /* @__PURE__ */ jsx("div", { className: classNames?.toolbar, children: toolbar }) : null,
|
|
23019
|
+
hasRenderableNode(selectionToolbar) ? /* @__PURE__ */ jsx("div", { className: classNames?.selectionToolbar, children: selectionToolbar }) : null,
|
|
23020
|
+
hasRenderableNode(beforeItems) ? /* @__PURE__ */ jsx("div", { className: classNames?.beforeItems, children: beforeItems }) : null,
|
|
23021
|
+
showInitialLoading ? hasRenderableNode(loadingSlot) ? loadingSlot : /* @__PURE__ */ jsx(BaseLoadingState, { title: labels.loading }) : showInitialError ? hasRenderableNode(errorSlot) ? errorSlot : /* @__PURE__ */ jsx(
|
|
23022
|
+
BaseNotice,
|
|
23023
|
+
{
|
|
23024
|
+
tone: "danger",
|
|
23025
|
+
role: "alert",
|
|
23026
|
+
"aria-live": "assertive",
|
|
23027
|
+
title: labels.loadError,
|
|
23028
|
+
actions: callbacks?.onRetry ? /* @__PURE__ */ jsx(BaseButton, { size: "sm", label: labels.retry, onClick: callbacks.onRetry }) : void 0
|
|
23029
|
+
}
|
|
23030
|
+
) : showEmpty ? hasRenderableNode(emptySlot) ? emptySlot : /* @__PURE__ */ jsx(BaseEmptyState, { title: labels.empty }) : /* @__PURE__ */ jsx(
|
|
23031
|
+
"div",
|
|
23032
|
+
{
|
|
23033
|
+
ref: registerItemsNode,
|
|
23034
|
+
className: cn("min-w-0", classNames?.items),
|
|
23035
|
+
children: groups.map((group, groupIndex) => {
|
|
23036
|
+
const groupContext = {
|
|
23037
|
+
key: group.key,
|
|
23038
|
+
label: group.label,
|
|
23039
|
+
items: group.items.map(({ item }) => item),
|
|
23040
|
+
groupIndex
|
|
23041
|
+
};
|
|
23042
|
+
const heading = config.grouping ? slots?.groupHeading?.(groupContext, slotContext) ?? group.label : null;
|
|
23043
|
+
const headingId = `${componentId}-group-${groupIndex}`;
|
|
23044
|
+
return /* @__PURE__ */ jsxs(
|
|
23045
|
+
"div",
|
|
23046
|
+
{
|
|
23047
|
+
"data-collection-group": group.stringKey,
|
|
23048
|
+
className: classNames?.group,
|
|
23049
|
+
children: [
|
|
23050
|
+
hasRenderableNode(heading) ? /* @__PURE__ */ jsx("div", { id: headingId, role: "heading", "aria-level": 2, className: classNames?.groupHeading, children: heading }) : null,
|
|
23051
|
+
renderGroupItems(group)
|
|
23052
|
+
]
|
|
23053
|
+
},
|
|
23054
|
+
group.stringKey
|
|
23055
|
+
);
|
|
23056
|
+
})
|
|
23057
|
+
}
|
|
23058
|
+
),
|
|
23059
|
+
items.length > 0 && effectiveError ? /* @__PURE__ */ jsx("div", { className: classNames?.status, children: hasRenderableNode(errorSlot) ? errorSlot : /* @__PURE__ */ jsx(
|
|
23060
|
+
BaseNotice,
|
|
23061
|
+
{
|
|
23062
|
+
tone: "danger",
|
|
23063
|
+
role: "alert",
|
|
23064
|
+
title: labels.refreshError,
|
|
23065
|
+
actions: callbacks?.onRetry ? /* @__PURE__ */ jsx(BaseButton, { size: "sm", label: labels.retry, onClick: callbacks.onRetry }) : void 0
|
|
23066
|
+
}
|
|
23067
|
+
) }) : null,
|
|
23068
|
+
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,
|
|
23069
|
+
hasRenderableNode(footer) ? /* @__PURE__ */ jsx("div", { className: classNames?.footer, children: footer }) : null
|
|
23070
|
+
]
|
|
22343
23071
|
}
|
|
22344
23072
|
);
|
|
22345
23073
|
}
|
|
@@ -22780,45 +23508,54 @@ function WorkbenchGalleryView({
|
|
|
22780
23508
|
);
|
|
22781
23509
|
if (isMasonry) {
|
|
22782
23510
|
return /* @__PURE__ */ jsx(
|
|
22783
|
-
|
|
23511
|
+
WorkbenchCollection,
|
|
22784
23512
|
{
|
|
22785
23513
|
items: rows,
|
|
22786
|
-
className,
|
|
22787
|
-
|
|
22788
|
-
|
|
22789
|
-
|
|
22790
|
-
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22800
|
-
|
|
22801
|
-
|
|
22802
|
-
|
|
22803
|
-
|
|
22804
|
-
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
|
|
23514
|
+
classNames: { layout: className },
|
|
23515
|
+
config: {
|
|
23516
|
+
getItemKey: (row, rowIndex) => row?.id || row?.linkKey || rowIndex,
|
|
23517
|
+
layout: {
|
|
23518
|
+
mode: masonryPlacementStrategy === "dense" ? "dense" : "masonry",
|
|
23519
|
+
gap: GALLERY_GRID_GAP_PX,
|
|
23520
|
+
idealCardWidth: resolvedMasonryColumnWidth,
|
|
23521
|
+
placementStrategy: masonryPlacementStrategy,
|
|
23522
|
+
getItemSize: (row, layout) => {
|
|
23523
|
+
const defaultSize = getDefaultGalleryMasonryItemSize({
|
|
23524
|
+
row,
|
|
23525
|
+
columns,
|
|
23526
|
+
galleryFieldKey,
|
|
23527
|
+
galleryDensity,
|
|
23528
|
+
galleryBentoColumns,
|
|
23529
|
+
galleryDetailVisibility,
|
|
23530
|
+
galleryDetailLimit,
|
|
23531
|
+
getFieldValue: resolvedGetFieldValue,
|
|
23532
|
+
isMediaColumn: resolvedIsMediaColumn,
|
|
23533
|
+
isTitleCandidate: resolvedIsTitleCandidate,
|
|
23534
|
+
isSummaryCandidate: resolvedIsSummaryCandidate,
|
|
23535
|
+
getDisplayText: resolvedGetDisplayText,
|
|
23536
|
+
isImageField: resolvedIsImageField,
|
|
23537
|
+
isAudioField: resolvedIsAudioField,
|
|
23538
|
+
cardVariant,
|
|
23539
|
+
renderPreview,
|
|
23540
|
+
renderLeadingVisual,
|
|
23541
|
+
hiddenDetailFieldKeys,
|
|
23542
|
+
layout,
|
|
23543
|
+
resolveRecordVisual
|
|
23544
|
+
});
|
|
23545
|
+
if (typeof getMasonryItemSize !== "function") return defaultSize;
|
|
23546
|
+
const customSize = getMasonryItemSize(row, {
|
|
23547
|
+
...layout,
|
|
23548
|
+
placementStrategy: layout.placementStrategy === "dense" ? "dense" : "shelf",
|
|
23549
|
+
defaultSize
|
|
23550
|
+
}) || {};
|
|
23551
|
+
return {
|
|
23552
|
+
...defaultSize,
|
|
23553
|
+
...customSize
|
|
23554
|
+
};
|
|
23555
|
+
}
|
|
23556
|
+
}
|
|
22820
23557
|
},
|
|
22821
|
-
renderItem: (row) => renderGalleryCard(row,
|
|
23558
|
+
renderItem: (row, context) => renderGalleryCard(row, context.index)
|
|
22822
23559
|
}
|
|
22823
23560
|
);
|
|
22824
23561
|
}
|
|
@@ -23336,7 +24073,7 @@ var getDomain = (values, min5, max5) => {
|
|
|
23336
24073
|
return lower < upper ? [lower, upper] : [upper, lower];
|
|
23337
24074
|
};
|
|
23338
24075
|
var scale = (value, domain, start, end) => start + (value - domain[0]) / (domain[1] - domain[0]) * (end - start);
|
|
23339
|
-
var
|
|
24076
|
+
var clamp5 = (value, min5, max5) => Math.min(max5, Math.max(min5, value));
|
|
23340
24077
|
var activatePoint = (event, point, onPointSelect) => {
|
|
23341
24078
|
if (!onPointSelect || event.key !== "Enter" && event.key !== " ") return;
|
|
23342
24079
|
event.preventDefault();
|
|
@@ -23418,9 +24155,9 @@ function WorkbenchScatterPlot({
|
|
|
23418
24155
|
xThreshold === void 0 ? null : /* @__PURE__ */ jsx(
|
|
23419
24156
|
"line",
|
|
23420
24157
|
{
|
|
23421
|
-
x1:
|
|
24158
|
+
x1: clamp5(xThreshold, plotLeft, plotRight),
|
|
23422
24159
|
y1: plotTop,
|
|
23423
|
-
x2:
|
|
24160
|
+
x2: clamp5(xThreshold, plotLeft, plotRight),
|
|
23424
24161
|
y2: plotBottom,
|
|
23425
24162
|
className: "stroke-muted-foreground/50",
|
|
23426
24163
|
strokeDasharray: "5 5"
|
|
@@ -23430,9 +24167,9 @@ function WorkbenchScatterPlot({
|
|
|
23430
24167
|
"line",
|
|
23431
24168
|
{
|
|
23432
24169
|
x1: plotLeft,
|
|
23433
|
-
y1:
|
|
24170
|
+
y1: clamp5(yThreshold, plotTop, plotBottom),
|
|
23434
24171
|
x2: plotRight,
|
|
23435
|
-
y2:
|
|
24172
|
+
y2: clamp5(yThreshold, plotTop, plotBottom),
|
|
23436
24173
|
className: "stroke-muted-foreground/50",
|
|
23437
24174
|
strokeDasharray: "5 5"
|
|
23438
24175
|
}
|
|
@@ -23459,17 +24196,17 @@ function WorkbenchScatterPlot({
|
|
|
23459
24196
|
}
|
|
23460
24197
|
),
|
|
23461
24198
|
validPoints.map((point) => {
|
|
23462
|
-
const x =
|
|
24199
|
+
const x = clamp5(
|
|
23463
24200
|
scale(point.x, xDomain, plotLeft, plotRight),
|
|
23464
24201
|
plotLeft,
|
|
23465
24202
|
plotRight
|
|
23466
24203
|
);
|
|
23467
|
-
const y =
|
|
24204
|
+
const y = clamp5(
|
|
23468
24205
|
scale(point.y, yDomain, plotBottom, plotTop),
|
|
23469
24206
|
plotTop,
|
|
23470
24207
|
plotBottom
|
|
23471
24208
|
);
|
|
23472
|
-
const radius = point.size === void 0 ? 9 :
|
|
24209
|
+
const radius = point.size === void 0 ? 9 : clamp5(scale(point.size, sizeDomain, 7, 18), 7, 18);
|
|
23473
24210
|
const selected = selectedPointId === point.id;
|
|
23474
24211
|
return /* @__PURE__ */ jsxs(
|
|
23475
24212
|
"g",
|
|
@@ -24001,7 +24738,7 @@ var getDomain2 = (values, min5, max5) => {
|
|
|
24001
24738
|
return lower < upper ? [lower, upper] : [upper, lower];
|
|
24002
24739
|
};
|
|
24003
24740
|
var scale2 = (value, domain, start, end) => start + (value - domain[0]) / (domain[1] - domain[0]) * (end - start);
|
|
24004
|
-
var
|
|
24741
|
+
var clamp6 = (value, min5, max5) => Math.min(max5, Math.max(min5, value));
|
|
24005
24742
|
var toneVariable = {
|
|
24006
24743
|
primary: "--radar-series-one",
|
|
24007
24744
|
secondary: "--radar-series-two",
|
|
@@ -24064,7 +24801,7 @@ function WorkbenchRadarMatrix({
|
|
|
24064
24801
|
const plotRight = width;
|
|
24065
24802
|
const plotTop = 0;
|
|
24066
24803
|
const plotBottom = height;
|
|
24067
|
-
const xThreshold =
|
|
24804
|
+
const xThreshold = clamp6(
|
|
24068
24805
|
scale2(
|
|
24069
24806
|
Number.isFinite(thresholds?.x) ? Number(thresholds?.x) : (xDomain[0] + xDomain[1]) / 2,
|
|
24070
24807
|
xDomain,
|
|
@@ -24074,7 +24811,7 @@ function WorkbenchRadarMatrix({
|
|
|
24074
24811
|
plotLeft,
|
|
24075
24812
|
plotRight
|
|
24076
24813
|
);
|
|
24077
|
-
const yThreshold =
|
|
24814
|
+
const yThreshold = clamp6(
|
|
24078
24815
|
scale2(
|
|
24079
24816
|
Number.isFinite(thresholds?.y) ? Number(thresholds?.y) : (yDomain[0] + yDomain[1]) / 2,
|
|
24080
24817
|
yDomain,
|
|
@@ -24182,13 +24919,13 @@ function WorkbenchRadarMatrix({
|
|
|
24182
24919
|
] }, quadrant.id);
|
|
24183
24920
|
}),
|
|
24184
24921
|
validPoints.map((point, index) => {
|
|
24185
|
-
const x =
|
|
24186
|
-
const y =
|
|
24922
|
+
const x = clamp6(scale2(point.x, xDomain, 40, width - 40), 40, width - 40);
|
|
24923
|
+
const y = clamp6(scale2(point.y, yDomain, height - 48, 54), 54, height - 48);
|
|
24187
24924
|
const tone = point.tone || (index % 2 === 0 ? "primary" : "accent");
|
|
24188
24925
|
const selected = selectedPointId === point.id;
|
|
24189
24926
|
const labelled = labelledPointIds.has(point.id);
|
|
24190
|
-
const radius = labelled ?
|
|
24191
|
-
const fontSize = labelled ?
|
|
24927
|
+
const radius = labelled ? clamp6(scale2(point.size ?? 1, sizeDomain, 5, 9), 5, 9) : 3.5;
|
|
24928
|
+
const fontSize = labelled ? clamp6(scale2(point.size ?? 1, sizeDomain, 14, 31), 14, 31) : 0;
|
|
24192
24929
|
const pointStyle = {
|
|
24193
24930
|
fill: toneColor(tone),
|
|
24194
24931
|
stroke: "hsl(var(--foreground) / 0.74)"
|
|
@@ -24290,8 +25027,8 @@ function WorkbenchRadarMatrix({
|
|
|
24290
25027
|
validPoints.map((point, index) => /* @__PURE__ */ jsx(
|
|
24291
25028
|
"circle",
|
|
24292
25029
|
{
|
|
24293
|
-
cx:
|
|
24294
|
-
cy:
|
|
25030
|
+
cx: clamp6(scale2(point.x, xDomain, 40, width - 40), 40, width - 40),
|
|
25031
|
+
cy: clamp6(scale2(point.y, yDomain, height - 48, 54), 54, height - 48),
|
|
24295
25032
|
r: "8",
|
|
24296
25033
|
style: { fill: toneColor(point.tone || (index % 2 === 0 ? "primary" : "accent")) }
|
|
24297
25034
|
},
|
|
@@ -27776,7 +28513,7 @@ var DEFAULT_ZOOM_STEP = 1.18;
|
|
|
27776
28513
|
var DEFAULT_STAGE_PADDING = 16;
|
|
27777
28514
|
var MAX_SAFE_SCALE = 1e6;
|
|
27778
28515
|
var MIN_SAFE_SCALE = 1e-6;
|
|
27779
|
-
var
|
|
28516
|
+
var clamp7 = (value, min5, max5) => Math.min(max5, Math.max(min5, value));
|
|
27780
28517
|
var isNoDragTarget = (target) => target instanceof Element && Boolean(target.closest('[data-no-drag="true"]'));
|
|
27781
28518
|
function ResetIcon() {
|
|
27782
28519
|
return /* @__PURE__ */ jsxs(
|
|
@@ -27900,7 +28637,7 @@ function DataExplorerImagePreview({
|
|
|
27900
28637
|
availableWidth / size.width,
|
|
27901
28638
|
availableHeight / size.height
|
|
27902
28639
|
);
|
|
27903
|
-
const nextScale =
|
|
28640
|
+
const nextScale = clamp7(
|
|
27904
28641
|
fitScale,
|
|
27905
28642
|
normalizedMinScale,
|
|
27906
28643
|
normalizedMaxScale
|
|
@@ -27954,7 +28691,7 @@ function DataExplorerImagePreview({
|
|
|
27954
28691
|
if (!Number.isFinite(factor) || factor === 1) return;
|
|
27955
28692
|
if (!Number.isFinite(stageX) || !Number.isFinite(stageY)) return;
|
|
27956
28693
|
setView((current) => {
|
|
27957
|
-
const nextScale =
|
|
28694
|
+
const nextScale = clamp7(
|
|
27958
28695
|
current.scale * factor,
|
|
27959
28696
|
normalizedMinScale,
|
|
27960
28697
|
normalizedMaxScale
|
|
@@ -29794,6 +30531,6 @@ function useDarkMode() {
|
|
|
29794
30531
|
return { mode, setMode, resolvedMode };
|
|
29795
30532
|
}
|
|
29796
30533
|
|
|
29797
|
-
export { AgentWorkbenchActivity, AgentWorkbenchSidebar, AgentWorkbenchTaskDetails, AgentWorkbenchTool, AppHeader, AppLayout, AppShellSidebar, AppSidebar, ApplicationHandoffLink, BaseAccordion, BaseAspectRatio, BaseAvatar, BaseBadge, BaseBreadcrumb, BaseButton, BaseCheckbox, BaseCode, BaseContainer, BaseContextMenu, BaseContextMenuCheckboxItem, BaseContextMenuContent, BaseContextMenuItem, BaseContextMenuLabel, BaseContextMenuRadioGroup, BaseContextMenuRadioItem, BaseContextMenuSeparator, BaseContextMenuSub, BaseContextMenuSubContent, BaseContextMenuSubTrigger, BaseContextMenuTrigger, BaseDescriptionList, BaseDialog, BaseDivider, BaseDropdownMenu, BaseEmptyState, BaseField, BaseFieldset, BaseGrid, BaseHeading, BaseInline, BaseInput, BaseInputGroup, BaseKbd, BaseLayout, BaseLayoutPane, BaseLayoutResizeHandle, BaseLayoutSplit, BaseLink, BaseList, BaseListItem, BaseLoadingState, BaseMultiSelect, BaseNotice, BaseNumberInput, BasePagination, BasePanel, BasePasswordInput, BasePortal, BaseProgress, BaseRadioGroup, BaseScrollArea, BaseSectionHeader, BaseSegmentedControl, BaseSelect, BaseSkeleton, BaseSpinner, BaseStack, BaseSteps, BaseSwitch, BaseTable, BaseTableBody, BaseTableCaption, BaseTableCell, BaseTableContainer, BaseTableEmpty, BaseTableFooter, BaseTableFooterBar, BaseTableHead, BaseTableHeader, BaseTableLoading, BaseTableRow, BaseTabs, BaseText, BaseTextarea, BaseToolbar, BaseTooltip, BaseVisuallyHidden, DarkModeSelector, DarkModeSubMenu, DataExplorerActionBar, DataExplorerButton, DataExplorerCheckbox, DataExplorerCollectionFooter, DataExplorerDetailField, DataExplorerDetailSection, DataExplorerDetailShell, DataExplorerDisplayActionMenu, DataExplorerDisplayCard, DataExplorerDisplayCollectionView, DataExplorerDisplayListItem, DataExplorerDisplayMedia, DataExplorerImagePreview, DataExplorerPage, DataExplorerRecordCard, DataExplorerSelect, DataExplorerToolbarActions, DataExplorerToolbarShell, DataExplorerTree, DataExplorerTreeShell, DataExplorerView, DataExplorerViewCollection, DataExplorerViewItem, DataExplorerViewItemShell, DataExplorerViewShell, DataExplorerViewTree, I18nSelector, InteractiveTable, InteractiveTableEditableTextCell, InteractiveTableReadonlyCell, InteractiveTableSelectCell, LoginPage, MonkeysProvider, MonkeysToastProvider, MonkeysToaster, NavButton, NavigationLayout, OverlayNodeHost, RenderNodeHost, MonkeysToastProvider as ToastProvider, MonkeysToaster as Toaster, UserAccountMenu, WorkbenchAssetGallery, WorkbenchContentPane, WorkbenchContentToolbar, WorkbenchDetailSidebar, WorkbenchEvidenceList, WorkbenchGalleryCard, WorkbenchGallerySettingsButton, WorkbenchGallerySettingsPanel, WorkbenchGalleryView, WorkbenchJourneyNavigation, WorkbenchLaneView, WorkbenchMasonryLayout, WorkbenchMetricGrid, WorkbenchRadarFilterChip, WorkbenchRadarInspectorSection, WorkbenchRadarMatrix, WorkbenchRadarNavigation, WorkbenchRadarWorkspace, WorkbenchRankedList, WorkbenchRelationshipGraph, WorkbenchResizableSidebar, WorkbenchScatterPlot, WorkbenchSelectionTray, WorkbenchTableView, applyThemeTokens, browserOverlayHistoryAdapter, buildOverlayUrl, calculateHue, calculateLightness, calculateSaturation, cn2 as cn, compileThemeTokens, createAgentWorkbenchActivityModel, createAgentWorkbenchDetailsModel, createSolidColorScale, defaultMonkeysLocale, enUS, extractToastMessage, genTailwindTheme, getBaseBadgeToneClassName, getBaseButtonToneClassName, getBaseMenuItemToneClassName, getBaseNoticeToneClassName, getDataExplorerActionToneClassName, getDataExplorerMenuItemToneClassName, getOverlayPresentationClassNames, getOverlayZIndex, getRenderNodeDataAttributes, getThemeTokenCssValue, isOverlayUrlActive, markDarkColor, mergeMonkeysLocaleMessages, resolveBaseAppearance, resolveDataExplorerAppearance, resolveMonkeysLocale, resolveRenderNodePolicyState, resolveToastVariantForMessage, sessionRenderNodeScrollRestoration, setTailwindTheme, toast, useDarkMode, useMonkeysBaseAppearance, useMonkeysComponentAttributes, useMonkeysDataExplorerAppearance, useMonkeysDirection, useMonkeysEnvironment, useMonkeysLocale, useMonkeysLocaleMessages, useMonkeysPortalOptions, useMonkeysResolvedTheme, useToastFeed, useToastOnValue, zhCN };
|
|
30534
|
+
export { AgentWorkbenchActivity, AgentWorkbenchSidebar, AgentWorkbenchTaskDetails, AgentWorkbenchTool, AppHeader, AppLayout, AppShellSidebar, AppSidebar, ApplicationHandoffLink, BaseAccordion, BaseAspectRatio, BaseAvatar, BaseBadge, BaseBreadcrumb, BaseButton, BaseCheckbox, BaseCode, BaseContainer, BaseContextMenu, BaseContextMenuCheckboxItem, BaseContextMenuContent, BaseContextMenuItem, BaseContextMenuLabel, BaseContextMenuRadioGroup, BaseContextMenuRadioItem, BaseContextMenuSeparator, BaseContextMenuSub, BaseContextMenuSubContent, BaseContextMenuSubTrigger, BaseContextMenuTrigger, BaseDescriptionList, BaseDialog, BaseDivider, BaseDropdownMenu, BaseEmptyState, BaseField, BaseFieldset, BaseGrid, BaseHeading, BaseInline, BaseInput, BaseInputGroup, BaseKbd, BaseLayout, BaseLayoutPane, BaseLayoutResizeHandle, BaseLayoutSplit, BaseLink, BaseList, BaseListItem, BaseLoadingState, BaseMultiSelect, BaseNotice, BaseNumberInput, BasePagination, BasePanel, BasePasswordInput, BasePortal, BaseProgress, BaseRadioGroup, BaseScrollArea, BaseSectionHeader, BaseSegmentedControl, BaseSelect, BaseSkeleton, BaseSpinner, BaseStack, BaseSteps, BaseSwitch, BaseTable, BaseTableBody, BaseTableCaption, BaseTableCell, BaseTableContainer, BaseTableEmpty, BaseTableFooter, BaseTableFooterBar, BaseTableHead, BaseTableHeader, BaseTableLoading, BaseTableRow, BaseTabs, BaseText, BaseTextarea, BaseToolbar, BaseTooltip, BaseVisuallyHidden, DarkModeSelector, DarkModeSubMenu, DataExplorerActionBar, DataExplorerButton, DataExplorerCheckbox, DataExplorerCollectionFooter, DataExplorerDetailField, DataExplorerDetailSection, DataExplorerDetailShell, DataExplorerDisplayActionMenu, DataExplorerDisplayCard, DataExplorerDisplayCollectionView, DataExplorerDisplayListItem, DataExplorerDisplayMedia, DataExplorerImagePreview, DataExplorerPage, DataExplorerRecordCard, DataExplorerSelect, DataExplorerToolbarActions, DataExplorerToolbarShell, DataExplorerTree, DataExplorerTreeShell, DataExplorerView, DataExplorerViewCollection, DataExplorerViewItem, DataExplorerViewItemShell, DataExplorerViewShell, DataExplorerViewTree, I18nSelector, InteractiveTable, InteractiveTableEditableTextCell, InteractiveTableReadonlyCell, InteractiveTableSelectCell, LoginPage, MonkeysProvider, MonkeysToastProvider, MonkeysToaster, NavButton, NavigationLayout, OverlayNodeHost, RenderNodeHost, MonkeysToastProvider as ToastProvider, MonkeysToaster as Toaster, UserAccountMenu, WorkbenchAssetGallery, WorkbenchCollection, WorkbenchContentPane, WorkbenchContentToolbar, WorkbenchDetailSidebar, WorkbenchEvidenceList, WorkbenchGalleryCard, WorkbenchGallerySettingsButton, WorkbenchGallerySettingsPanel, WorkbenchGalleryView, WorkbenchJourneyNavigation, WorkbenchLaneView, WorkbenchMasonryLayout, WorkbenchMetricGrid, WorkbenchRadarFilterChip, WorkbenchRadarInspectorSection, WorkbenchRadarMatrix, WorkbenchRadarNavigation, WorkbenchRadarWorkspace, WorkbenchRankedList, WorkbenchRelationshipGraph, WorkbenchResizableSidebar, WorkbenchScatterPlot, WorkbenchSelectionTray, WorkbenchTableView, applyThemeTokens, browserOverlayHistoryAdapter, buildOverlayUrl, calculateHue, calculateLightness, calculateSaturation, cn2 as cn, compileThemeTokens, createAgentWorkbenchActivityModel, createAgentWorkbenchDetailsModel, createSolidColorScale, defaultMonkeysLocale, enUS, extractToastMessage, genTailwindTheme, getBaseBadgeToneClassName, getBaseButtonToneClassName, getBaseMenuItemToneClassName, getBaseNoticeToneClassName, getDataExplorerActionToneClassName, getDataExplorerMenuItemToneClassName, getOverlayPresentationClassNames, getOverlayZIndex, getRenderNodeDataAttributes, getThemeTokenCssValue, isOverlayUrlActive, markDarkColor, mergeMonkeysLocaleMessages, resolveBaseAppearance, resolveDataExplorerAppearance, resolveMonkeysLocale, resolveRenderNodePolicyState, resolveToastVariantForMessage, sessionRenderNodeScrollRestoration, setTailwindTheme, toast, useDarkMode, useMonkeysBaseAppearance, useMonkeysComponentAttributes, useMonkeysDataExplorerAppearance, useMonkeysDirection, useMonkeysEnvironment, useMonkeysLocale, useMonkeysLocaleMessages, useMonkeysPortalOptions, useMonkeysResolvedTheme, useToastFeed, useToastOnValue, zhCN };
|
|
29798
30535
|
//# sourceMappingURL=index.mjs.map
|
|
29799
30536
|
//# sourceMappingURL=index.mjs.map
|