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