@dxos/react-ui-stack 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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/lib/browser/index.mjs +201 -411
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +201 -411
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Stack/Stack.d.ts +4 -9
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/MenuSignifier.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.d.ts +2 -2
- package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemDragHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts +1 -1
- package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -25
- package/src/components/Stack/Stack.stories.tsx +2 -3
- package/src/components/Stack/Stack.tsx +197 -210
- package/src/components/StackItem/MenuSignifier.tsx +2 -9
- package/src/components/StackItem/StackItem.stories.tsx +5 -5
- package/src/components/StackItem/StackItem.tsx +1 -1
- package/src/components/StackItem/StackItemContent.tsx +11 -9
- package/src/components/StackItem/StackItemDragHandle.tsx +4 -3
- package/src/components/StackItem/StackItemHeading.tsx +13 -12
- package/src/components/StackItem/StackItemResizeHandle.tsx +1 -1
- package/src/components/StackItem/StackItemSigil.tsx +7 -4
- package/src/components/index.ts +1 -1
- package/src/playwright/playwright.config.ts +1 -1
- package/src/translations.ts +8 -8
- package/dist/types/src/components/CardStack/CardStack.d.ts +0 -47
- package/dist/types/src/components/CardStack/CardStack.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts +0 -15
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts +0 -9
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/index.d.ts +0 -3
- package/dist/types/src/components/CardStack/index.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/LayoutControls.d.ts +0 -22
- package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +0 -1
- package/src/components/CardStack/CardStack.stories.tsx +0 -173
- package/src/components/CardStack/CardStack.tsx +0 -196
- package/src/components/CardStack/CardStackDragPreview.tsx +0 -61
- package/src/components/CardStack/index.ts +0 -6
- package/src/components/deprecated/LayoutControls.tsx +0 -112
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
// src/components/CardStack/CardStack.tsx
|
|
4
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
-
import React2, { forwardRef as forwardRef2 } from "react";
|
|
6
|
-
import { Card } from "@dxos/react-ui-mosaic";
|
|
7
|
-
import { cardDefaultInlineSize, mx as mx2 } from "@dxos/ui-theme";
|
|
8
|
-
|
|
9
3
|
// src/components/Stack/Stack.tsx
|
|
10
4
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
11
|
-
import React, { Children, forwardRef, useCallback, useEffect,
|
|
5
|
+
import React, { Children, forwardRef, useCallback, useEffect, useState as useState2 } from "react";
|
|
12
6
|
import { ListItem, useId } from "@dxos/react-ui";
|
|
13
7
|
import { mx } from "@dxos/ui-theme";
|
|
14
8
|
|
|
@@ -101,13 +95,8 @@ var StackItemContext = /* @__PURE__ */ createContext({
|
|
|
101
95
|
var useStackItem = () => useContext(StackItemContext);
|
|
102
96
|
|
|
103
97
|
// src/components/Stack/Stack.tsx
|
|
104
|
-
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
105
|
-
var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
106
|
-
var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
107
|
-
var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
108
|
-
var autoScrollRootAttributes = {
|
|
109
|
-
"data-drag-autoscroll": "idle"
|
|
110
|
-
};
|
|
98
|
+
var railGridHorizontal = "grid-rows-[[rail-start]_var(--dx-rail-size)_[content-start]_1fr_[content-end]]";
|
|
99
|
+
var railGridVertical = "grid-cols-[[rail-start]_var(--dx-rail-size)_[content-start]_1fr_[content-end]]";
|
|
111
100
|
var PERPENDICULAR_FOCUS_THRESHHOLD = 128;
|
|
112
101
|
var scrollIntoViewAndFocus = (el, orientation) => {
|
|
113
102
|
el.scrollIntoView({
|
|
@@ -116,18 +105,14 @@ var scrollIntoViewAndFocus = (el, orientation) => {
|
|
|
116
105
|
});
|
|
117
106
|
return el.focus();
|
|
118
107
|
};
|
|
119
|
-
var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic",
|
|
120
|
-
const stackId = useId("stack",
|
|
108
|
+
var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, id, style, orientation = "vertical", rail = true, size = "intrinsic", itemsCount = Children.count(children), circularFocus, separatorOnScroll, getDropElement, onBlur, onKeyDown, onRearrange, ...props }, forwardedRef) => {
|
|
109
|
+
const stackId = useId("stack", id);
|
|
121
110
|
const [stackElement, stackRef] = useState2(null);
|
|
122
111
|
const [lastFocusedItem, setLastFocusedItem] = useState2();
|
|
123
112
|
const composedItemRef = composeRefs(stackRef, forwardedRef);
|
|
124
|
-
const
|
|
125
|
-
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
|
|
126
|
-
...style
|
|
127
|
-
};
|
|
128
|
-
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
113
|
+
const selfDroppable = !!(itemsCount < 1 && onRearrange && id);
|
|
129
114
|
const { dropping } = useStackDropForElements({
|
|
130
|
-
id
|
|
115
|
+
id,
|
|
131
116
|
element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
|
|
132
117
|
scrollElement: stackElement,
|
|
133
118
|
selfDroppable,
|
|
@@ -158,116 +143,12 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
158
143
|
setLastFocusedItem(closestStackItem?.getAttribute("data-dx-item-id") ?? void 0);
|
|
159
144
|
}
|
|
160
145
|
}
|
|
161
|
-
|
|
146
|
+
onBlur?.(event);
|
|
162
147
|
}, [
|
|
163
148
|
stackId,
|
|
164
|
-
|
|
165
|
-
]);
|
|
166
|
-
const handleKeyDown = useCallback((event) => {
|
|
167
|
-
const target = event.target;
|
|
168
|
-
if (event.key.startsWith("Arrow") && !target.closest(`input, textarea, [role="textbox"], [data-tabster*="mover"], [data-arrow-keys="all"], [data-arrow-keys~="${event.key.toLowerCase().slice(5)}"]`)) {
|
|
169
|
-
const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
|
|
170
|
-
const closestStack = target.closest("[data-dx-stack]");
|
|
171
|
-
const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
|
|
172
|
-
const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
|
|
173
|
-
const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
|
|
174
|
-
if (closestOwnedItem && closestStack) {
|
|
175
|
-
const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
|
|
176
|
-
const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
|
|
177
|
-
const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
|
|
178
|
-
if (parallelDelta !== 0) {
|
|
179
|
-
const currentIndex = closestStackItems.indexOf(closestOwnedItem);
|
|
180
|
-
const nextIndex = currentIndex + parallelDelta;
|
|
181
|
-
let adjacentItem;
|
|
182
|
-
if (circularFocus) {
|
|
183
|
-
adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
|
|
184
|
-
} else {
|
|
185
|
-
if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
|
|
186
|
-
adjacentItem = closestStackItems[nextIndex];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (adjacentItem) {
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (perpendicularDelta !== 0) {
|
|
195
|
-
if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
|
|
196
|
-
const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
|
|
197
|
-
const currentStackIndex = siblingStacks.indexOf(closestStack);
|
|
198
|
-
const nextStackIndex = currentStackIndex + perpendicularDelta;
|
|
199
|
-
let adjacentStack;
|
|
200
|
-
if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
|
|
201
|
-
adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
|
|
202
|
-
} else {
|
|
203
|
-
if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
|
|
204
|
-
adjacentStack = siblingStacks[nextStackIndex];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
|
|
208
|
-
const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
|
|
209
|
-
if (adjacentStack && adjacentStackItems.length > 0) {
|
|
210
|
-
let closestItem = adjacentStackItems[0];
|
|
211
|
-
const lastFocusedItem2 = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
|
|
212
|
-
if (lastFocusedItem2) {
|
|
213
|
-
closestItem = lastFocusedItem2;
|
|
214
|
-
} else {
|
|
215
|
-
const ownedItemRect = closestOwnedItem.getBoundingClientRect();
|
|
216
|
-
const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
|
|
217
|
-
let closestDistance = Infinity;
|
|
218
|
-
for (const item of adjacentStackItems) {
|
|
219
|
-
const itemRect = item.getBoundingClientRect();
|
|
220
|
-
const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
|
|
221
|
-
const distance = Math.abs(itemPosition - targetPosition);
|
|
222
|
-
if (distance < closestDistance) {
|
|
223
|
-
closestDistance = distance;
|
|
224
|
-
closestItem = item;
|
|
225
|
-
}
|
|
226
|
-
if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
event.preventDefault();
|
|
232
|
-
scrollIntoViewAndFocus(closestItem, closestStackOrientation);
|
|
233
|
-
} else if (adjacentStackSelfItem) {
|
|
234
|
-
event.preventDefault();
|
|
235
|
-
scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
|
|
236
|
-
}
|
|
237
|
-
} else if (closestOwnedItem) {
|
|
238
|
-
const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
|
|
239
|
-
const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
|
|
240
|
-
if (closestOwnedItemStackItems.length > 0) {
|
|
241
|
-
event.preventDefault();
|
|
242
|
-
scrollIntoViewAndFocus(closestOwnedItemStackItems[[
|
|
243
|
-
"ArrowUp",
|
|
244
|
-
"ArrowLeft"
|
|
245
|
-
].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
props.onKeyDown?.(event);
|
|
252
|
-
}, [
|
|
253
|
-
props.onKeyDown,
|
|
254
|
-
stackId,
|
|
255
|
-
circularFocus
|
|
256
|
-
]);
|
|
257
|
-
const gridClasses = useMemo(() => {
|
|
258
|
-
if (!rail) {
|
|
259
|
-
return orientation === "horizontal" ? "grid-rows-1 pli-[--stack-gap]" : "grid-cols-1 plb-[--stack-gap]";
|
|
260
|
-
}
|
|
261
|
-
if (orientation === "horizontal") {
|
|
262
|
-
return railGridHorizontal;
|
|
263
|
-
} else {
|
|
264
|
-
return railGridVertical;
|
|
265
|
-
}
|
|
266
|
-
}, [
|
|
267
|
-
rail,
|
|
268
|
-
orientation,
|
|
269
|
-
size
|
|
149
|
+
onBlur
|
|
270
150
|
]);
|
|
151
|
+
const handleKeyDown = useKeyDown(stackId, circularFocus, onKeyDown);
|
|
271
152
|
useEffect(() => {
|
|
272
153
|
if (!(stackElement && Number.isFinite(separatorOnScroll))) {
|
|
273
154
|
return;
|
|
@@ -288,27 +169,30 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
288
169
|
]);
|
|
289
170
|
return /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
290
171
|
value: {
|
|
172
|
+
stackId,
|
|
291
173
|
orientation,
|
|
292
174
|
rail,
|
|
293
175
|
size,
|
|
294
|
-
onRearrange
|
|
295
|
-
stackId
|
|
176
|
+
onRearrange
|
|
296
177
|
}
|
|
297
178
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
298
179
|
...props,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
180
|
+
...Number.isFinite(separatorOnScroll) && {
|
|
181
|
+
onScroll: handleScroll
|
|
182
|
+
},
|
|
183
|
+
className: mx("relative grid [--stack-gap:var(--spacing-trim-xs)]", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto overscroll-x-contain min-h-0 max-h-full h-full" : "overflow-y-auto min-w-0 max-w-full w-full"), rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1 px-(--stack-gap)" : "grid-cols-1 py-(--stack-gap)", classNames),
|
|
184
|
+
style: {
|
|
185
|
+
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
|
|
186
|
+
...style
|
|
187
|
+
},
|
|
188
|
+
"aria-orientation": orientation,
|
|
302
189
|
"data-dx-stack": stackId,
|
|
303
190
|
"data-dx-stack-circular-focus": circularFocus,
|
|
304
191
|
"data-dx-last-focused-item": lastFocusedItem,
|
|
305
192
|
"data-rail": rail,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
ref: composedItemRef
|
|
309
|
-
...Number.isFinite(separatorOnScroll) && {
|
|
310
|
-
onScroll: handleScroll
|
|
311
|
-
}
|
|
193
|
+
onBlur: handleBlur,
|
|
194
|
+
onKeyDown: handleKeyDown,
|
|
195
|
+
ref: composedItemRef
|
|
312
196
|
}, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
|
|
313
197
|
lineInset: 8,
|
|
314
198
|
terminalInset: -8,
|
|
@@ -316,196 +200,97 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
316
200
|
edge: orientation === "horizontal" ? "left" : "top"
|
|
317
201
|
})));
|
|
318
202
|
});
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
402
|
-
var cardStackHeading = "mli-2 order-first bg-transparent rounded-bs-md flex items-center";
|
|
403
|
-
var CardStackHeading = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "heading", ...props }, forwardedRef) => {
|
|
404
|
-
const Root = asChild ? Slot : "div";
|
|
405
|
-
const rootProps = asChild ? {
|
|
406
|
-
classNames: [
|
|
407
|
-
cardStackHeading,
|
|
408
|
-
classNames
|
|
409
|
-
]
|
|
410
|
-
} : {
|
|
411
|
-
className: mx2(cardStackHeading, classNames),
|
|
412
|
-
role
|
|
413
|
-
};
|
|
414
|
-
return /* @__PURE__ */ React2.createElement(Root, {
|
|
415
|
-
...props,
|
|
416
|
-
...rootProps,
|
|
417
|
-
ref: forwardedRef
|
|
418
|
-
}, children);
|
|
419
|
-
});
|
|
420
|
-
var cardStackFooter = 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
|
|
421
|
-
var CardStackFooter = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
|
|
422
|
-
const Root = asChild ? Slot : "div";
|
|
423
|
-
const rootProps = asChild ? {
|
|
424
|
-
classNames: [
|
|
425
|
-
cardStackFooter,
|
|
426
|
-
classNames
|
|
427
|
-
]
|
|
428
|
-
} : {
|
|
429
|
-
className: mx2(cardStackFooter, classNames),
|
|
430
|
-
role
|
|
431
|
-
};
|
|
432
|
-
return /* @__PURE__ */ React2.createElement(Root, {
|
|
433
|
-
...props,
|
|
434
|
-
...rootProps,
|
|
435
|
-
ref: forwardedRef
|
|
436
|
-
}, children);
|
|
437
|
-
});
|
|
438
|
-
var CardStackDragHandle = Card.DragHandle;
|
|
439
|
-
var CardStack = {
|
|
440
|
-
Root: CardStackRoot,
|
|
441
|
-
Content: CardStackContent,
|
|
442
|
-
Stack: CardStackStack,
|
|
443
|
-
Heading: CardStackHeading,
|
|
444
|
-
Footer: CardStackFooter,
|
|
445
|
-
DragHandle: CardStackDragHandle,
|
|
446
|
-
Item: CardStackItem
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// src/components/CardStack/CardStackDragPreview.tsx
|
|
450
|
-
import React3 from "react";
|
|
451
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
452
|
-
import { mx as mx3 } from "@dxos/ui-theme";
|
|
453
|
-
|
|
454
|
-
// src/translations.ts
|
|
455
|
-
var translationKey = "@dxos/react-ui-stack";
|
|
456
|
-
var translations = [
|
|
457
|
-
{
|
|
458
|
-
"en-US": {
|
|
459
|
-
[translationKey]: {
|
|
460
|
-
"resize label": "Drag to resize",
|
|
461
|
-
"drag handle label": "Drag to rearrange",
|
|
462
|
-
"pin start label": "Pin to the left sidebar",
|
|
463
|
-
"pin end label": "Pin to the right sidebar",
|
|
464
|
-
"increment start label": "Move to the left",
|
|
465
|
-
"increment end label": "Move to the right",
|
|
466
|
-
"close label": "Close",
|
|
467
|
-
"minify label": "Minify"
|
|
203
|
+
var useKeyDown = (stackId, circularFocus, onKeyDown) => useCallback((event) => {
|
|
204
|
+
const target = event.target;
|
|
205
|
+
if (event.key.startsWith("Arrow") && !target.closest(`input, textarea, [role="textbox"], [data-tabster*="mover"], [data-arrow-keys="all"], [data-arrow-keys~="${event.key.toLowerCase().slice(5)}"]`)) {
|
|
206
|
+
const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
|
|
207
|
+
const closestStack = target.closest("[data-dx-stack]");
|
|
208
|
+
const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
|
|
209
|
+
const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
|
|
210
|
+
const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
|
|
211
|
+
if (closestOwnedItem && closestStack) {
|
|
212
|
+
const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
|
|
213
|
+
const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
|
|
214
|
+
const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
|
|
215
|
+
if (parallelDelta !== 0) {
|
|
216
|
+
const currentIndex = closestStackItems.indexOf(closestOwnedItem);
|
|
217
|
+
const nextIndex = currentIndex + parallelDelta;
|
|
218
|
+
let adjacentItem;
|
|
219
|
+
if (circularFocus) {
|
|
220
|
+
adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
|
|
221
|
+
} else {
|
|
222
|
+
if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
|
|
223
|
+
adjacentItem = closestStackItems[nextIndex];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (adjacentItem) {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (perpendicularDelta !== 0) {
|
|
232
|
+
if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
|
|
233
|
+
const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
|
|
234
|
+
const currentStackIndex = siblingStacks.indexOf(closestStack);
|
|
235
|
+
const nextStackIndex = currentStackIndex + perpendicularDelta;
|
|
236
|
+
let adjacentStack;
|
|
237
|
+
if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
|
|
238
|
+
adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
|
|
239
|
+
} else {
|
|
240
|
+
if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
|
|
241
|
+
adjacentStack = siblingStacks[nextStackIndex];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
|
|
245
|
+
const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
|
|
246
|
+
if (adjacentStack && adjacentStackItems.length > 0) {
|
|
247
|
+
let closestItem = adjacentStackItems[0];
|
|
248
|
+
const lastFocusedItem = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
|
|
249
|
+
if (lastFocusedItem) {
|
|
250
|
+
closestItem = lastFocusedItem;
|
|
251
|
+
} else {
|
|
252
|
+
const ownedItemRect = closestOwnedItem.getBoundingClientRect();
|
|
253
|
+
const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
|
|
254
|
+
let closestDistance = Infinity;
|
|
255
|
+
for (const item of adjacentStackItems) {
|
|
256
|
+
const itemRect = item.getBoundingClientRect();
|
|
257
|
+
const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
|
|
258
|
+
const distance = Math.abs(itemPosition - targetPosition);
|
|
259
|
+
if (distance < closestDistance) {
|
|
260
|
+
closestDistance = distance;
|
|
261
|
+
closestItem = item;
|
|
262
|
+
}
|
|
263
|
+
if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
scrollIntoViewAndFocus(closestItem, closestStackOrientation);
|
|
270
|
+
} else if (adjacentStackSelfItem) {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
|
|
273
|
+
}
|
|
274
|
+
} else if (closestOwnedItem) {
|
|
275
|
+
const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
|
|
276
|
+
const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
|
|
277
|
+
if (closestOwnedItemStackItems.length > 0) {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
scrollIntoViewAndFocus(closestOwnedItemStackItems[[
|
|
280
|
+
"ArrowUp",
|
|
281
|
+
"ArrowLeft"
|
|
282
|
+
].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
468
285
|
}
|
|
469
286
|
}
|
|
470
287
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}, /* @__PURE__ */ React3.createElement("div", {
|
|
478
|
-
className: "rounded-md max-bs-[calc(100dvh-1rem)] overflow-hidden bg-baseSurface border border-separator ring-focusLine ring-neutralFocusIndicator flex flex-col"
|
|
479
|
-
}, children));
|
|
480
|
-
};
|
|
481
|
-
var CardStackDragPreviewHeading = ({ children }) => {
|
|
482
|
-
const { t } = useTranslation(translationKey);
|
|
483
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
484
|
-
className: "flex items-center p-2"
|
|
485
|
-
}, /* @__PURE__ */ React3.createElement(IconButton, {
|
|
486
|
-
iconOnly: true,
|
|
487
|
-
icon: "ph--dots-six-vertical--regular",
|
|
488
|
-
variant: "ghost",
|
|
489
|
-
label: t("column drag handle label"),
|
|
490
|
-
classNames: "pli-2"
|
|
491
|
-
}), children);
|
|
492
|
-
};
|
|
493
|
-
var CardStackDragPreviewContent = ({ children, itemsCount = 0 }) => {
|
|
494
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
495
|
-
className: mx3("overflow-y-auto flex-1 pli-2 flex flex-col gap-2", "plb-1", itemsCount > 0 ? "plb-2" : "plb-1")
|
|
496
|
-
}, children);
|
|
497
|
-
};
|
|
498
|
-
var CardStackDragPreviewFooter = ({ children }) => {
|
|
499
|
-
return /* @__PURE__ */ React3.createElement("div", {
|
|
500
|
-
className: "p-2 border-bs border-separator"
|
|
501
|
-
}, children);
|
|
502
|
-
};
|
|
503
|
-
var CardStackDragPreview = {
|
|
504
|
-
Root: CardStackDragPreviewRoot,
|
|
505
|
-
Heading: CardStackDragPreviewHeading,
|
|
506
|
-
Content: CardStackDragPreviewContent,
|
|
507
|
-
Footer: CardStackDragPreviewFooter
|
|
508
|
-
};
|
|
288
|
+
onKeyDown?.(event);
|
|
289
|
+
}, [
|
|
290
|
+
onKeyDown,
|
|
291
|
+
stackId,
|
|
292
|
+
circularFocus
|
|
293
|
+
]);
|
|
509
294
|
|
|
510
295
|
// src/components/StackItem/StackItem.tsx
|
|
511
296
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
@@ -515,37 +300,33 @@ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/el
|
|
|
515
300
|
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
516
301
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
517
302
|
import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
|
|
518
|
-
import
|
|
303
|
+
import React8, { forwardRef as forwardRef5, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
519
304
|
import { createPortal } from "react-dom";
|
|
520
305
|
import { ListItem as ListItem2 } from "@dxos/react-ui";
|
|
521
306
|
import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
522
|
-
import { mx as
|
|
307
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
523
308
|
|
|
524
309
|
// src/components/StackItem/StackItemContent.tsx
|
|
525
|
-
import
|
|
526
|
-
import { mx as
|
|
527
|
-
var StackItemContent = /* @__PURE__ */
|
|
310
|
+
import React2, { forwardRef as forwardRef2, useMemo } from "react";
|
|
311
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
312
|
+
var StackItemContent = /* @__PURE__ */ forwardRef2(({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
|
|
528
313
|
const { size: stackItemSize } = useStack();
|
|
529
314
|
const { role } = useStackItem();
|
|
530
|
-
const style =
|
|
315
|
+
const style = useMemo(() => ({
|
|
531
316
|
gridTemplateRows: [
|
|
532
|
-
|
|
533
|
-
role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)"
|
|
534
|
-
] : [],
|
|
317
|
+
toolbar && role === "section" ? "calc(var(--dx-toolbar-size) - 1px)" : "var(--dx-toolbar-size)",
|
|
535
318
|
"1fr",
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
] : []
|
|
539
|
-
].join(" ")
|
|
319
|
+
statusbar && "var(--dx-statusbar-size)"
|
|
320
|
+
].filter(Boolean).join(" ")
|
|
540
321
|
}), [
|
|
541
322
|
toolbar,
|
|
542
323
|
statusbar
|
|
543
324
|
]);
|
|
544
|
-
return /* @__PURE__ */
|
|
325
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
545
326
|
...props,
|
|
546
327
|
role: "none",
|
|
547
328
|
style,
|
|
548
|
-
className:
|
|
329
|
+
className: mx2("group grid grid-cols-[100%] dx-density-coarse", stackItemSize === "contain" && "min-h-0 overflow-hidden", toolbar && role === "section" && "[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:top-0 [&_.dx-toolbar]:-mb-px [&_.dx-toolbar]:min-w-0", toolbar && "[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-b [&>.dx-toolbar]:border-subdued-separator", classNames),
|
|
549
330
|
"data-popover-collision-boundary": true,
|
|
550
331
|
ref: forwardedRef
|
|
551
332
|
}, children);
|
|
@@ -553,56 +334,58 @@ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, tool
|
|
|
553
334
|
StackItemContent.displayName = "StackItemContent";
|
|
554
335
|
|
|
555
336
|
// src/components/StackItem/StackItemDragHandle.tsx
|
|
556
|
-
import {
|
|
557
|
-
import
|
|
337
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
338
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
339
|
+
import React3 from "react";
|
|
558
340
|
var StackItemDragHandle = ({ asChild, children }) => {
|
|
559
341
|
const { selfDragHandleRef } = useStackItem();
|
|
560
|
-
const
|
|
561
|
-
return /* @__PURE__ */
|
|
342
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
343
|
+
return /* @__PURE__ */ React3.createElement(Comp, {
|
|
562
344
|
ref: selfDragHandleRef,
|
|
563
345
|
role: "button"
|
|
564
346
|
}, children);
|
|
565
347
|
};
|
|
566
348
|
|
|
567
349
|
// src/components/StackItem/StackItemHeading.tsx
|
|
568
|
-
import {
|
|
569
|
-
import
|
|
350
|
+
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
351
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
352
|
+
import React4, { forwardRef as forwardRef3 } from "react";
|
|
570
353
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
571
|
-
import { mx as
|
|
572
|
-
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
|
|
354
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
355
|
+
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, role, ...props }) => {
|
|
573
356
|
const { orientation } = useStack();
|
|
574
|
-
const
|
|
575
|
-
return /* @__PURE__ */
|
|
576
|
-
role: "heading",
|
|
357
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
358
|
+
return /* @__PURE__ */ React4.createElement(Comp, {
|
|
577
359
|
...props,
|
|
578
|
-
|
|
360
|
+
role: role ?? "heading",
|
|
361
|
+
className: mx3("flex items-center border-x-0! bg-header-surface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subdued-separator' : "border-subdued-separator", orientation === "horizontal" ? "h-(--dx-rail-size)" : "w-(--dx-rail-size) flex-col", orientation === "horizontal" ? "border-b" : "border-e", classNames)
|
|
579
362
|
}, children);
|
|
580
363
|
};
|
|
581
364
|
var StackItemHeadingStickyContent = ({ children }) => {
|
|
582
|
-
return /* @__PURE__ */
|
|
365
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
583
366
|
role: "none",
|
|
584
|
-
className: "sticky
|
|
367
|
+
className: "sticky top-0 bg-(--sticky-bg) p-1 w-full"
|
|
585
368
|
}, children);
|
|
586
369
|
};
|
|
587
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
370
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
588
371
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
589
|
-
return /* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ React4.createElement("h1", {
|
|
590
373
|
...props,
|
|
591
374
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
592
|
-
className:
|
|
375
|
+
className: mx3("px-1 min-w-0 w-0 grow truncate font-medium text-base-surface-text data-[attention=true]:text-accent-text self-center", classNames),
|
|
593
376
|
ref: forwardedRef
|
|
594
377
|
});
|
|
595
378
|
});
|
|
596
379
|
|
|
597
380
|
// src/components/StackItem/StackItemResizeHandle.tsx
|
|
598
|
-
import
|
|
381
|
+
import React5 from "react";
|
|
599
382
|
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
600
383
|
var MIN_WIDTH = 20;
|
|
601
384
|
var MIN_HEIGHT = 3;
|
|
602
|
-
var StackItemResizeHandle = () => {
|
|
385
|
+
var StackItemResizeHandle = (_) => {
|
|
603
386
|
const { orientation } = useStack();
|
|
604
387
|
const { setSize, size } = useStackItem();
|
|
605
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
606
389
|
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
607
390
|
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
608
391
|
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
@@ -612,23 +395,42 @@ var StackItemResizeHandle = () => {
|
|
|
612
395
|
};
|
|
613
396
|
|
|
614
397
|
// src/components/StackItem/StackItemSigil.tsx
|
|
615
|
-
import
|
|
398
|
+
import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
|
|
616
399
|
import { keySymbols } from "@dxos/keyboard";
|
|
617
|
-
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation
|
|
400
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
618
401
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
619
|
-
import {
|
|
402
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
620
403
|
import { getHostPlatform } from "@dxos/util";
|
|
621
404
|
|
|
405
|
+
// src/translations.ts
|
|
406
|
+
var translationKey = "@dxos/react-ui-stack";
|
|
407
|
+
var translations = [
|
|
408
|
+
{
|
|
409
|
+
"en-US": {
|
|
410
|
+
[translationKey]: {
|
|
411
|
+
"resize.label": "Drag to resize",
|
|
412
|
+
"drag-handle.label": "Drag to rearrange",
|
|
413
|
+
"pin-start.label": "Pin to the left sidebar",
|
|
414
|
+
"pin-end.label": "Pin to the right sidebar",
|
|
415
|
+
"increment-start.label": "Move to the left",
|
|
416
|
+
"increment-end.label": "Move to the right",
|
|
417
|
+
"close.label": "Close",
|
|
418
|
+
"minify.label": "Minify"
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
];
|
|
423
|
+
|
|
622
424
|
// src/components/StackItem/MenuSignifier.tsx
|
|
623
|
-
import
|
|
624
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
625
|
-
className: "absolute
|
|
425
|
+
import React6 from "react";
|
|
426
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
|
|
427
|
+
className: "absolute bottom-[7px]",
|
|
626
428
|
width: 20,
|
|
627
429
|
height: 2,
|
|
628
430
|
viewBox: "0 0 20 2",
|
|
629
431
|
stroke: "currentColor",
|
|
630
432
|
opacity: 0.5
|
|
631
|
-
}, /* @__PURE__ */
|
|
433
|
+
}, /* @__PURE__ */ React6.createElement("line", {
|
|
632
434
|
x1: 0.5,
|
|
633
435
|
y1: 0.75,
|
|
634
436
|
x2: 19,
|
|
@@ -640,56 +442,55 @@ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg",
|
|
|
640
442
|
}));
|
|
641
443
|
|
|
642
444
|
// src/components/StackItem/StackItemSigil.tsx
|
|
643
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
445
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
|
|
644
446
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
645
447
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
646
|
-
return /* @__PURE__ */
|
|
448
|
+
return /* @__PURE__ */ React7.createElement(Button, {
|
|
647
449
|
...props,
|
|
648
450
|
variant,
|
|
649
451
|
classNames: [
|
|
650
|
-
"shrink-0
|
|
452
|
+
"shrink-0 px-0 min-h-0 w-(--dx-rail-action) h-(--dx-rail-action) relative dx-app-no-drag",
|
|
651
453
|
classNames
|
|
652
454
|
],
|
|
653
455
|
ref: forwardedRef
|
|
654
|
-
}, isMenu && /* @__PURE__ */
|
|
456
|
+
}, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
655
457
|
});
|
|
656
|
-
var StackItemSigil = /* @__PURE__ */
|
|
657
|
-
const { t } =
|
|
458
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
459
|
+
const { t } = useTranslation(translationKey);
|
|
658
460
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
659
461
|
const hasActions = actionGroups && actionGroups.length > 0;
|
|
660
|
-
const button = /* @__PURE__ */
|
|
462
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
661
463
|
attendableId,
|
|
662
464
|
related,
|
|
663
465
|
isMenu: hasActions,
|
|
664
466
|
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
665
467
|
// Remove underscore icon when no actions are available?
|
|
666
468
|
classNames: !hasActions && "cursor-default"
|
|
667
|
-
}, /* @__PURE__ */
|
|
469
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
668
470
|
className: "sr-only"
|
|
669
|
-
}, triggerLabel), /* @__PURE__ */
|
|
670
|
-
icon
|
|
671
|
-
size: 5
|
|
471
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
472
|
+
icon
|
|
672
473
|
}));
|
|
673
474
|
if (!hasActions) {
|
|
674
475
|
return button;
|
|
675
476
|
}
|
|
676
|
-
return /* @__PURE__ */
|
|
477
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
677
478
|
open: optionsMenuOpen,
|
|
678
479
|
onOpenChange: setOptionsMenuOpen
|
|
679
|
-
}, /* @__PURE__ */
|
|
480
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
680
481
|
asChild: true,
|
|
681
482
|
ref: forwardedRef
|
|
682
|
-
}, button), /* @__PURE__ */
|
|
483
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
683
484
|
classNames: "z-[31]"
|
|
684
|
-
}, /* @__PURE__ */
|
|
685
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
686
|
-
return /* @__PURE__ */
|
|
485
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
486
|
+
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
487
|
+
return /* @__PURE__ */ React7.createElement(Fragment, {
|
|
687
488
|
key: index
|
|
688
489
|
}, separator, actions.map((action) => {
|
|
689
490
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
690
491
|
const menuItemType = action.properties.menuItemType;
|
|
691
492
|
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
692
|
-
return /* @__PURE__ */
|
|
493
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
693
494
|
key: action.id,
|
|
694
495
|
onClick: (event) => {
|
|
695
496
|
if (action.properties.disabled) {
|
|
@@ -705,28 +506,28 @@ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAct
|
|
|
705
506
|
...action.properties?.testId && {
|
|
706
507
|
"data-testid": action.properties.testId
|
|
707
508
|
}
|
|
708
|
-
}, /* @__PURE__ */
|
|
509
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
709
510
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
710
511
|
size: 4
|
|
711
|
-
}), /* @__PURE__ */
|
|
512
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
712
513
|
className: "grow truncate"
|
|
713
|
-
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */
|
|
514
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
|
|
714
515
|
asChild: true
|
|
715
|
-
}, /* @__PURE__ */
|
|
516
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
716
517
|
icon: "ph--check--regular",
|
|
717
518
|
size: 4
|
|
718
|
-
})), shortcut && /* @__PURE__ */
|
|
719
|
-
className:
|
|
519
|
+
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
520
|
+
className: mx4("shrink-0", "text-description")
|
|
720
521
|
}, keySymbols(shortcut).join("")));
|
|
721
522
|
}));
|
|
722
|
-
}), children), /* @__PURE__ */
|
|
523
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
723
524
|
});
|
|
724
525
|
|
|
725
526
|
// src/components/StackItem/StackItem.tsx
|
|
726
527
|
var DEFAULT_HORIZONTAL_SIZE = 48;
|
|
727
528
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
728
529
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
729
|
-
var StackItemRoot = /* @__PURE__ */
|
|
530
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
730
531
|
const [itemElement, itemRef] = useState4(null);
|
|
731
532
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
732
533
|
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
@@ -865,7 +666,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
865
666
|
}
|
|
866
667
|
return true;
|
|
867
668
|
};
|
|
868
|
-
const stackItemContextValue =
|
|
669
|
+
const stackItemContextValue = useMemo2(() => ({
|
|
869
670
|
selfDragHandleRef,
|
|
870
671
|
size,
|
|
871
672
|
setSize,
|
|
@@ -880,13 +681,13 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
880
681
|
setDragState,
|
|
881
682
|
role
|
|
882
683
|
]);
|
|
883
|
-
return /* @__PURE__ */
|
|
684
|
+
return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
|
|
884
685
|
value: stackItemContextValue
|
|
885
|
-
}, /* @__PURE__ */
|
|
686
|
+
}, /* @__PURE__ */ React8.createElement(Root, {
|
|
886
687
|
...props,
|
|
887
688
|
tabIndex: 0,
|
|
888
689
|
...focusableGroupAttrs,
|
|
889
|
-
className:
|
|
690
|
+
className: mx5("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : focusIndicatorVariant === "over-all-always" ? "dx-focus-ring-inset-over-all-always" : orientation === "horizontal" ? focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-x-always" : "dx-focus-ring-group-x" : focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-y-always" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), role === "section" && orientation !== "horizontal" && "border-b border-subdued-separator", classNames),
|
|
890
691
|
"data-dx-stack-item": stackId,
|
|
891
692
|
"data-dx-item-id": item.id,
|
|
892
693
|
...resizeAttributes,
|
|
@@ -898,7 +699,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
898
699
|
...style
|
|
899
700
|
},
|
|
900
701
|
ref: composedItemRef
|
|
901
|
-
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */
|
|
702
|
+
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
902
703
|
lineInset: 8,
|
|
903
704
|
terminalInset: -8,
|
|
904
705
|
edge: closestEdge
|
|
@@ -923,25 +724,14 @@ var StackItem = {
|
|
|
923
724
|
SigilButton: StackItemSigilButton
|
|
924
725
|
};
|
|
925
726
|
export {
|
|
926
|
-
CardStack,
|
|
927
|
-
CardStackDragPreview,
|
|
928
727
|
DEFAULT_EXTRINSIC_SIZE,
|
|
929
728
|
DEFAULT_HORIZONTAL_SIZE,
|
|
930
729
|
DEFAULT_VERTICAL_SIZE,
|
|
931
730
|
Stack,
|
|
932
731
|
StackContext,
|
|
933
732
|
StackItem,
|
|
934
|
-
autoScrollRootAttributes,
|
|
935
|
-
cardStackContent,
|
|
936
|
-
cardStackDefaultInlineSizeRem,
|
|
937
|
-
cardStackFooter,
|
|
938
|
-
cardStackHeading,
|
|
939
|
-
cardStackItem,
|
|
940
|
-
cardStackRoot,
|
|
941
733
|
railGridHorizontal,
|
|
942
|
-
railGridHorizontalContainFitContent,
|
|
943
734
|
railGridVertical,
|
|
944
|
-
railGridVerticalContainFitContent,
|
|
945
735
|
translationKey,
|
|
946
736
|
translations
|
|
947
737
|
};
|