@dxos/react-ui-stack 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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 +188 -416
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +23 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +188 -416
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +25 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- 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 +5 -5
- package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.stories.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/hooks/useStackDropForElements.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/playwright/stack-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -35
- package/src/components/Stack/Stack.stories.tsx +8 -10
- package/src/components/Stack/Stack.tsx +197 -210
- package/src/components/StackItem/MenuSignifier.tsx +2 -9
- package/src/components/StackItem/StackItem.stories.tsx +4 -4
- package/src/components/StackItem/StackItem.tsx +13 -15
- package/src/components/StackItem/StackItemContent.tsx +6 -6
- package/src/components/StackItem/StackItemDragHandle.tsx +4 -3
- package/src/components/StackItem/StackItemHeading.tsx +13 -12
- package/src/components/StackItem/StackItemResizeHandle.tsx +1 -2
- package/src/components/StackItem/StackItemSigil.tsx +8 -5
- package/src/components/index.ts +1 -1
- package/src/hooks/useStackDropForElements.ts +2 -2
- package/src/index.ts +0 -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 -12
- 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 -195
- package/src/components/CardStack/CardStackDragPreview.tsx +0 -64
- package/src/components/CardStack/index.ts +0 -6
- package/src/components/deprecated/LayoutControls.tsx +0 -112
|
@@ -1,20 +1,14 @@
|
|
|
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
|
|
|
13
7
|
// src/hooks/useStackDropForElements.ts
|
|
14
|
-
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
15
|
-
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
16
8
|
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
17
9
|
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
10
|
+
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
11
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
18
12
|
import { useLayoutEffect, useState } from "react";
|
|
19
13
|
var noop = () => {
|
|
20
14
|
};
|
|
@@ -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
|
-
|
|
160
|
-
}, [
|
|
161
|
-
stackId,
|
|
162
|
-
props.onBlur
|
|
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);
|
|
144
|
+
onBlur?.(event);
|
|
250
145
|
}, [
|
|
251
|
-
props.onKeyDown,
|
|
252
146
|
stackId,
|
|
253
|
-
|
|
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,234 +198,133 @@ 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, ScrollArea, 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(ScrollArea.Root, {
|
|
493
|
-
orientation: "vertical"
|
|
494
|
-
}, /* @__PURE__ */ React3.createElement(ScrollArea.Viewport, {
|
|
495
|
-
classNames: mx3("pli-2 plb-1 gap-2", 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
|
-
};
|
|
286
|
+
onKeyDown?.(event);
|
|
287
|
+
}, [
|
|
288
|
+
onKeyDown,
|
|
289
|
+
stackId,
|
|
290
|
+
circularFocus
|
|
291
|
+
]);
|
|
509
292
|
|
|
510
293
|
// src/components/StackItem/StackItem.tsx
|
|
294
|
+
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
511
295
|
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
512
296
|
import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
513
297
|
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
514
298
|
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
515
|
-
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
516
299
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
517
300
|
import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
|
|
518
|
-
import
|
|
301
|
+
import React8, { forwardRef as forwardRef5, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
519
302
|
import { createPortal } from "react-dom";
|
|
520
303
|
import { ListItem as ListItem2 } from "@dxos/react-ui";
|
|
521
304
|
import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
522
|
-
import { mx as
|
|
305
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
523
306
|
|
|
524
307
|
// src/components/StackItem/StackItemContent.tsx
|
|
525
|
-
import
|
|
526
|
-
import { mx as
|
|
527
|
-
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) => {
|
|
528
311
|
const { size: stackItemSize } = useStack();
|
|
529
312
|
const { role } = useStackItem();
|
|
530
|
-
const style =
|
|
313
|
+
const style = useMemo(() => ({
|
|
531
314
|
gridTemplateRows: [
|
|
532
|
-
toolbar && role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)",
|
|
315
|
+
toolbar && role === "section" ? "calc(var(--dx-toolbar-size) - 1px)" : "var(--dx-toolbar-size)",
|
|
533
316
|
"1fr",
|
|
534
|
-
statusbar && "var(--statusbar-size)"
|
|
317
|
+
statusbar && "var(--dx-statusbar-size)"
|
|
535
318
|
].filter(Boolean).join(" ")
|
|
536
319
|
}), [
|
|
537
320
|
toolbar,
|
|
538
321
|
statusbar
|
|
539
322
|
]);
|
|
540
|
-
return /* @__PURE__ */
|
|
323
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
541
324
|
...props,
|
|
542
325
|
role: "none",
|
|
543
326
|
style,
|
|
544
|
-
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),
|
|
545
328
|
"data-popover-collision-boundary": true,
|
|
546
329
|
ref: forwardedRef
|
|
547
330
|
}, children);
|
|
@@ -549,56 +332,58 @@ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, tool
|
|
|
549
332
|
StackItemContent.displayName = "StackItemContent";
|
|
550
333
|
|
|
551
334
|
// src/components/StackItem/StackItemDragHandle.tsx
|
|
552
|
-
import {
|
|
553
|
-
import
|
|
335
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
336
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
337
|
+
import React3 from "react";
|
|
554
338
|
var StackItemDragHandle = ({ asChild, children }) => {
|
|
555
339
|
const { selfDragHandleRef } = useStackItem();
|
|
556
|
-
const
|
|
557
|
-
return /* @__PURE__ */
|
|
340
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
341
|
+
return /* @__PURE__ */ React3.createElement(Comp, {
|
|
558
342
|
ref: selfDragHandleRef,
|
|
559
343
|
role: "button"
|
|
560
344
|
}, children);
|
|
561
345
|
};
|
|
562
346
|
|
|
563
347
|
// src/components/StackItem/StackItemHeading.tsx
|
|
564
|
-
import {
|
|
565
|
-
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";
|
|
566
351
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
567
|
-
import { mx as
|
|
568
|
-
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 }) => {
|
|
569
354
|
const { orientation } = useStack();
|
|
570
|
-
const
|
|
571
|
-
return /* @__PURE__ */
|
|
572
|
-
role: "heading",
|
|
355
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
356
|
+
return /* @__PURE__ */ React4.createElement(Comp, {
|
|
573
357
|
...props,
|
|
574
|
-
|
|
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)
|
|
575
360
|
}, children);
|
|
576
361
|
};
|
|
577
362
|
var StackItemHeadingStickyContent = ({ children }) => {
|
|
578
|
-
return /* @__PURE__ */
|
|
363
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
579
364
|
role: "none",
|
|
580
|
-
className: "sticky
|
|
365
|
+
className: "sticky top-0 bg-(--sticky-bg) p-1 w-full"
|
|
581
366
|
}, children);
|
|
582
367
|
};
|
|
583
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
368
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
584
369
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
585
|
-
return /* @__PURE__ */
|
|
370
|
+
return /* @__PURE__ */ React4.createElement("h1", {
|
|
586
371
|
...props,
|
|
587
372
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
588
|
-
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),
|
|
589
374
|
ref: forwardedRef
|
|
590
375
|
});
|
|
591
376
|
});
|
|
592
377
|
|
|
593
378
|
// src/components/StackItem/StackItemResizeHandle.tsx
|
|
594
|
-
import
|
|
379
|
+
import React5 from "react";
|
|
595
380
|
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
596
381
|
var MIN_WIDTH = 20;
|
|
597
382
|
var MIN_HEIGHT = 3;
|
|
598
|
-
var StackItemResizeHandle = () => {
|
|
383
|
+
var StackItemResizeHandle = (_) => {
|
|
599
384
|
const { orientation } = useStack();
|
|
600
385
|
const { setSize, size } = useStackItem();
|
|
601
|
-
return /* @__PURE__ */
|
|
386
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
602
387
|
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
603
388
|
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
604
389
|
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
@@ -608,23 +393,24 @@ var StackItemResizeHandle = () => {
|
|
|
608
393
|
};
|
|
609
394
|
|
|
610
395
|
// src/components/StackItem/StackItemSigil.tsx
|
|
611
|
-
import
|
|
396
|
+
import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
|
|
612
397
|
import { keySymbols } from "@dxos/keyboard";
|
|
613
|
-
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation
|
|
398
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
614
399
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
615
|
-
import {
|
|
400
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
616
401
|
import { getHostPlatform } from "@dxos/util";
|
|
402
|
+
import { translationKey } from "#translations";
|
|
617
403
|
|
|
618
404
|
// src/components/StackItem/MenuSignifier.tsx
|
|
619
|
-
import
|
|
620
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
621
|
-
className: "absolute
|
|
405
|
+
import React6 from "react";
|
|
406
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
|
|
407
|
+
className: "absolute bottom-[7px]",
|
|
622
408
|
width: 20,
|
|
623
409
|
height: 2,
|
|
624
410
|
viewBox: "0 0 20 2",
|
|
625
411
|
stroke: "currentColor",
|
|
626
412
|
opacity: 0.5
|
|
627
|
-
}, /* @__PURE__ */
|
|
413
|
+
}, /* @__PURE__ */ React6.createElement("line", {
|
|
628
414
|
x1: 0.5,
|
|
629
415
|
y1: 0.75,
|
|
630
416
|
x2: 19,
|
|
@@ -636,56 +422,55 @@ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg",
|
|
|
636
422
|
}));
|
|
637
423
|
|
|
638
424
|
// src/components/StackItem/StackItemSigil.tsx
|
|
639
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
425
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
|
|
640
426
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
641
427
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
642
|
-
return /* @__PURE__ */
|
|
428
|
+
return /* @__PURE__ */ React7.createElement(Button, {
|
|
643
429
|
...props,
|
|
644
430
|
variant,
|
|
645
431
|
classNames: [
|
|
646
|
-
"shrink-0
|
|
432
|
+
"shrink-0 px-0 min-h-0 w-(--dx-rail-action) h-(--dx-rail-action) relative dx-app-no-drag",
|
|
647
433
|
classNames
|
|
648
434
|
],
|
|
649
435
|
ref: forwardedRef
|
|
650
|
-
}, isMenu && /* @__PURE__ */
|
|
436
|
+
}, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
651
437
|
});
|
|
652
|
-
var StackItemSigil = /* @__PURE__ */
|
|
653
|
-
const { t } =
|
|
438
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
439
|
+
const { t } = useTranslation(translationKey);
|
|
654
440
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
655
441
|
const hasActions = actionGroups && actionGroups.length > 0;
|
|
656
|
-
const button = /* @__PURE__ */
|
|
442
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
657
443
|
attendableId,
|
|
658
444
|
related,
|
|
659
445
|
isMenu: hasActions,
|
|
660
446
|
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
661
447
|
// Remove underscore icon when no actions are available?
|
|
662
448
|
classNames: !hasActions && "cursor-default"
|
|
663
|
-
}, /* @__PURE__ */
|
|
449
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
664
450
|
className: "sr-only"
|
|
665
|
-
}, triggerLabel), /* @__PURE__ */
|
|
666
|
-
icon
|
|
667
|
-
size: 5
|
|
451
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
452
|
+
icon
|
|
668
453
|
}));
|
|
669
454
|
if (!hasActions) {
|
|
670
455
|
return button;
|
|
671
456
|
}
|
|
672
|
-
return /* @__PURE__ */
|
|
457
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
673
458
|
open: optionsMenuOpen,
|
|
674
459
|
onOpenChange: setOptionsMenuOpen
|
|
675
|
-
}, /* @__PURE__ */
|
|
460
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
676
461
|
asChild: true,
|
|
677
462
|
ref: forwardedRef
|
|
678
|
-
}, button), /* @__PURE__ */
|
|
463
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
679
464
|
classNames: "z-[31]"
|
|
680
|
-
}, /* @__PURE__ */
|
|
681
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
682
|
-
return /* @__PURE__ */
|
|
465
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
466
|
+
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
467
|
+
return /* @__PURE__ */ React7.createElement(Fragment, {
|
|
683
468
|
key: index
|
|
684
469
|
}, separator, actions.map((action) => {
|
|
685
470
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
686
471
|
const menuItemType = action.properties.menuItemType;
|
|
687
472
|
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
688
|
-
return /* @__PURE__ */
|
|
473
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
689
474
|
key: action.id,
|
|
690
475
|
onClick: (event) => {
|
|
691
476
|
if (action.properties.disabled) {
|
|
@@ -701,28 +486,28 @@ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAct
|
|
|
701
486
|
...action.properties?.testId && {
|
|
702
487
|
"data-testid": action.properties.testId
|
|
703
488
|
}
|
|
704
|
-
}, /* @__PURE__ */
|
|
489
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
705
490
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
706
491
|
size: 4
|
|
707
|
-
}), /* @__PURE__ */
|
|
492
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
708
493
|
className: "grow truncate"
|
|
709
|
-
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */
|
|
494
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
|
|
710
495
|
asChild: true
|
|
711
|
-
}, /* @__PURE__ */
|
|
496
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
712
497
|
icon: "ph--check--regular",
|
|
713
498
|
size: 4
|
|
714
|
-
})), shortcut && /* @__PURE__ */
|
|
715
|
-
className:
|
|
499
|
+
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
500
|
+
className: mx4("shrink-0", "text-description")
|
|
716
501
|
}, keySymbols(shortcut).join("")));
|
|
717
502
|
}));
|
|
718
|
-
}), children), /* @__PURE__ */
|
|
503
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
719
504
|
});
|
|
720
505
|
|
|
721
506
|
// src/components/StackItem/StackItem.tsx
|
|
722
|
-
var DEFAULT_HORIZONTAL_SIZE = 48;
|
|
723
507
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
508
|
+
var DEFAULT_HORIZONTAL_SIZE = 50;
|
|
724
509
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
725
|
-
var StackItemRoot = /* @__PURE__ */
|
|
510
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ classNames, children, style, role, item, order, prevSiblingId, nextSiblingId, size: sizeProp, onSizeChange, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
726
511
|
const [itemElement, itemRef] = useState4(null);
|
|
727
512
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
728
513
|
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
@@ -730,7 +515,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
730
515
|
const [sourceId, setSourceId] = useState4(null);
|
|
731
516
|
const [dragState, setDragState] = useState4(idle);
|
|
732
517
|
const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
|
|
733
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(
|
|
518
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(sizeProp);
|
|
734
519
|
const Root = role ?? "div";
|
|
735
520
|
const setSize = useCallback2((nextSize, commit) => {
|
|
736
521
|
setInternalSize(nextSize);
|
|
@@ -861,7 +646,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
861
646
|
}
|
|
862
647
|
return true;
|
|
863
648
|
};
|
|
864
|
-
const stackItemContextValue =
|
|
649
|
+
const stackItemContextValue = useMemo2(() => ({
|
|
865
650
|
selfDragHandleRef,
|
|
866
651
|
size,
|
|
867
652
|
setSize,
|
|
@@ -876,13 +661,13 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
876
661
|
setDragState,
|
|
877
662
|
role
|
|
878
663
|
]);
|
|
879
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
|
|
880
665
|
value: stackItemContextValue
|
|
881
|
-
}, /* @__PURE__ */
|
|
666
|
+
}, /* @__PURE__ */ React8.createElement(Root, {
|
|
882
667
|
...props,
|
|
883
668
|
tabIndex: 0,
|
|
884
669
|
...focusableGroupAttrs,
|
|
885
|
-
className:
|
|
670
|
+
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),
|
|
886
671
|
"data-dx-stack-item": stackId,
|
|
887
672
|
"data-dx-item-id": item.id,
|
|
888
673
|
...resizeAttributes,
|
|
@@ -894,7 +679,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
894
679
|
...style
|
|
895
680
|
},
|
|
896
681
|
ref: composedItemRef
|
|
897
|
-
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */
|
|
682
|
+
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
898
683
|
lineInset: 8,
|
|
899
684
|
terminalInset: -8,
|
|
900
685
|
edge: closestEdge
|
|
@@ -919,26 +704,13 @@ var StackItem = {
|
|
|
919
704
|
SigilButton: StackItemSigilButton
|
|
920
705
|
};
|
|
921
706
|
export {
|
|
922
|
-
CardStack,
|
|
923
|
-
CardStackDragPreview,
|
|
924
707
|
DEFAULT_EXTRINSIC_SIZE,
|
|
925
708
|
DEFAULT_HORIZONTAL_SIZE,
|
|
926
709
|
DEFAULT_VERTICAL_SIZE,
|
|
927
710
|
Stack,
|
|
928
711
|
StackContext,
|
|
929
712
|
StackItem,
|
|
930
|
-
autoScrollRootAttributes,
|
|
931
|
-
cardStackContent,
|
|
932
|
-
cardStackDefaultInlineSizeRem,
|
|
933
|
-
cardStackFooter,
|
|
934
|
-
cardStackHeading,
|
|
935
|
-
cardStackItem,
|
|
936
|
-
cardStackRoot,
|
|
937
713
|
railGridHorizontal,
|
|
938
|
-
|
|
939
|
-
railGridVertical,
|
|
940
|
-
railGridVerticalContainFitContent,
|
|
941
|
-
translationKey,
|
|
942
|
-
translations
|
|
714
|
+
railGridVertical
|
|
943
715
|
};
|
|
944
716
|
//# sourceMappingURL=index.mjs.map
|