@dxos/react-ui-stack 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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 -418
- 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 -418
- 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/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/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 +7 -9
- 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 -7
- package/src/components/StackItem/StackItemDragHandle.tsx +4 -3
- package/src/components/StackItem/StackItemHeading.tsx +13 -16
- 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,132 @@ 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
|
-
role: "none",
|
|
543
325
|
style,
|
|
544
|
-
className:
|
|
326
|
+
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
327
|
"data-popover-collision-boundary": true,
|
|
546
328
|
ref: forwardedRef
|
|
547
329
|
}, children);
|
|
@@ -549,56 +331,57 @@ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, tool
|
|
|
549
331
|
StackItemContent.displayName = "StackItemContent";
|
|
550
332
|
|
|
551
333
|
// src/components/StackItem/StackItemDragHandle.tsx
|
|
552
|
-
import {
|
|
553
|
-
import
|
|
334
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
335
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
336
|
+
import React3 from "react";
|
|
554
337
|
var StackItemDragHandle = ({ asChild, children }) => {
|
|
555
338
|
const { selfDragHandleRef } = useStackItem();
|
|
556
|
-
const
|
|
557
|
-
return /* @__PURE__ */
|
|
339
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
340
|
+
return /* @__PURE__ */ React3.createElement(Comp, {
|
|
558
341
|
ref: selfDragHandleRef,
|
|
559
342
|
role: "button"
|
|
560
343
|
}, children);
|
|
561
344
|
};
|
|
562
345
|
|
|
563
346
|
// src/components/StackItem/StackItemHeading.tsx
|
|
564
|
-
import {
|
|
565
|
-
import
|
|
347
|
+
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
348
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
349
|
+
import React4, { forwardRef as forwardRef3 } from "react";
|
|
566
350
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
567
|
-
import { mx as
|
|
568
|
-
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
|
|
351
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
352
|
+
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, role, ...props }) => {
|
|
569
353
|
const { orientation } = useStack();
|
|
570
|
-
const
|
|
571
|
-
return /* @__PURE__ */
|
|
572
|
-
role: "heading",
|
|
354
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
355
|
+
return /* @__PURE__ */ React4.createElement(Comp, {
|
|
573
356
|
...props,
|
|
574
|
-
|
|
357
|
+
role: role ?? "heading",
|
|
358
|
+
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
359
|
}, children);
|
|
576
360
|
};
|
|
577
361
|
var StackItemHeadingStickyContent = ({ children }) => {
|
|
578
|
-
return /* @__PURE__ */
|
|
579
|
-
|
|
580
|
-
className: "sticky block-start-0 bg-[--sticky-bg] p-1 is-full"
|
|
362
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
363
|
+
className: "sticky top-0 bg-(--sticky-bg) p-1 w-full"
|
|
581
364
|
}, children);
|
|
582
365
|
};
|
|
583
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
366
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
584
367
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
585
|
-
return /* @__PURE__ */
|
|
368
|
+
return /* @__PURE__ */ React4.createElement("h1", {
|
|
586
369
|
...props,
|
|
587
370
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
588
|
-
className:
|
|
371
|
+
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
372
|
ref: forwardedRef
|
|
590
373
|
});
|
|
591
374
|
});
|
|
592
375
|
|
|
593
376
|
// src/components/StackItem/StackItemResizeHandle.tsx
|
|
594
|
-
import
|
|
377
|
+
import React5 from "react";
|
|
595
378
|
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
596
379
|
var MIN_WIDTH = 20;
|
|
597
380
|
var MIN_HEIGHT = 3;
|
|
598
|
-
var StackItemResizeHandle = () => {
|
|
381
|
+
var StackItemResizeHandle = (_) => {
|
|
599
382
|
const { orientation } = useStack();
|
|
600
383
|
const { setSize, size } = useStackItem();
|
|
601
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
602
385
|
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
603
386
|
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
604
387
|
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
@@ -608,23 +391,24 @@ var StackItemResizeHandle = () => {
|
|
|
608
391
|
};
|
|
609
392
|
|
|
610
393
|
// src/components/StackItem/StackItemSigil.tsx
|
|
611
|
-
import
|
|
394
|
+
import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
|
|
612
395
|
import { keySymbols } from "@dxos/keyboard";
|
|
613
|
-
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation
|
|
396
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
614
397
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
615
|
-
import {
|
|
398
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
616
399
|
import { getHostPlatform } from "@dxos/util";
|
|
400
|
+
import { translationKey } from "#translations";
|
|
617
401
|
|
|
618
402
|
// src/components/StackItem/MenuSignifier.tsx
|
|
619
|
-
import
|
|
620
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
621
|
-
className: "absolute
|
|
403
|
+
import React6 from "react";
|
|
404
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
|
|
405
|
+
className: "absolute bottom-[7px]",
|
|
622
406
|
width: 20,
|
|
623
407
|
height: 2,
|
|
624
408
|
viewBox: "0 0 20 2",
|
|
625
409
|
stroke: "currentColor",
|
|
626
410
|
opacity: 0.5
|
|
627
|
-
}, /* @__PURE__ */
|
|
411
|
+
}, /* @__PURE__ */ React6.createElement("line", {
|
|
628
412
|
x1: 0.5,
|
|
629
413
|
y1: 0.75,
|
|
630
414
|
x2: 19,
|
|
@@ -636,56 +420,55 @@ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg",
|
|
|
636
420
|
}));
|
|
637
421
|
|
|
638
422
|
// src/components/StackItem/StackItemSigil.tsx
|
|
639
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
423
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
|
|
640
424
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
641
425
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
642
|
-
return /* @__PURE__ */
|
|
426
|
+
return /* @__PURE__ */ React7.createElement(Button, {
|
|
643
427
|
...props,
|
|
644
428
|
variant,
|
|
645
429
|
classNames: [
|
|
646
|
-
"shrink-0
|
|
430
|
+
"shrink-0 px-0 min-h-0 w-(--dx-rail-action) h-(--dx-rail-action) relative dx-app-no-drag",
|
|
647
431
|
classNames
|
|
648
432
|
],
|
|
649
433
|
ref: forwardedRef
|
|
650
|
-
}, isMenu && /* @__PURE__ */
|
|
434
|
+
}, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
651
435
|
});
|
|
652
|
-
var StackItemSigil = /* @__PURE__ */
|
|
653
|
-
const { t } =
|
|
436
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
437
|
+
const { t } = useTranslation(translationKey);
|
|
654
438
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
655
439
|
const hasActions = actionGroups && actionGroups.length > 0;
|
|
656
|
-
const button = /* @__PURE__ */
|
|
440
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
657
441
|
attendableId,
|
|
658
442
|
related,
|
|
659
443
|
isMenu: hasActions,
|
|
660
444
|
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
661
445
|
// Remove underscore icon when no actions are available?
|
|
662
446
|
classNames: !hasActions && "cursor-default"
|
|
663
|
-
}, /* @__PURE__ */
|
|
447
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
664
448
|
className: "sr-only"
|
|
665
|
-
}, triggerLabel), /* @__PURE__ */
|
|
666
|
-
icon
|
|
667
|
-
size: 5
|
|
449
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
450
|
+
icon
|
|
668
451
|
}));
|
|
669
452
|
if (!hasActions) {
|
|
670
453
|
return button;
|
|
671
454
|
}
|
|
672
|
-
return /* @__PURE__ */
|
|
455
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
673
456
|
open: optionsMenuOpen,
|
|
674
457
|
onOpenChange: setOptionsMenuOpen
|
|
675
|
-
}, /* @__PURE__ */
|
|
458
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
676
459
|
asChild: true,
|
|
677
460
|
ref: forwardedRef
|
|
678
|
-
}, button), /* @__PURE__ */
|
|
461
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
679
462
|
classNames: "z-[31]"
|
|
680
|
-
}, /* @__PURE__ */
|
|
681
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
682
|
-
return /* @__PURE__ */
|
|
463
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
464
|
+
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
465
|
+
return /* @__PURE__ */ React7.createElement(Fragment, {
|
|
683
466
|
key: index
|
|
684
467
|
}, separator, actions.map((action) => {
|
|
685
468
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
686
469
|
const menuItemType = action.properties.menuItemType;
|
|
687
470
|
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
688
|
-
return /* @__PURE__ */
|
|
471
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
689
472
|
key: action.id,
|
|
690
473
|
onClick: (event) => {
|
|
691
474
|
if (action.properties.disabled) {
|
|
@@ -701,28 +484,28 @@ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAct
|
|
|
701
484
|
...action.properties?.testId && {
|
|
702
485
|
"data-testid": action.properties.testId
|
|
703
486
|
}
|
|
704
|
-
}, /* @__PURE__ */
|
|
487
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
705
488
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
706
489
|
size: 4
|
|
707
|
-
}), /* @__PURE__ */
|
|
490
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
708
491
|
className: "grow truncate"
|
|
709
|
-
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */
|
|
492
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
|
|
710
493
|
asChild: true
|
|
711
|
-
}, /* @__PURE__ */
|
|
494
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
712
495
|
icon: "ph--check--regular",
|
|
713
496
|
size: 4
|
|
714
|
-
})), shortcut && /* @__PURE__ */
|
|
715
|
-
className:
|
|
497
|
+
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
498
|
+
className: mx4("shrink-0", "text-description")
|
|
716
499
|
}, keySymbols(shortcut).join("")));
|
|
717
500
|
}));
|
|
718
|
-
}), children), /* @__PURE__ */
|
|
501
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
719
502
|
});
|
|
720
503
|
|
|
721
504
|
// src/components/StackItem/StackItem.tsx
|
|
722
|
-
var DEFAULT_HORIZONTAL_SIZE = 48;
|
|
723
505
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
506
|
+
var DEFAULT_HORIZONTAL_SIZE = 50;
|
|
724
507
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
725
|
-
var StackItemRoot = /* @__PURE__ */
|
|
508
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ classNames, children, style, role, item, order, prevSiblingId, nextSiblingId, size: sizeProp, onSizeChange, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
726
509
|
const [itemElement, itemRef] = useState4(null);
|
|
727
510
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
728
511
|
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
@@ -730,7 +513,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
730
513
|
const [sourceId, setSourceId] = useState4(null);
|
|
731
514
|
const [dragState, setDragState] = useState4(idle);
|
|
732
515
|
const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
|
|
733
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(
|
|
516
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(sizeProp);
|
|
734
517
|
const Root = role ?? "div";
|
|
735
518
|
const setSize = useCallback2((nextSize, commit) => {
|
|
736
519
|
setInternalSize(nextSize);
|
|
@@ -861,7 +644,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
861
644
|
}
|
|
862
645
|
return true;
|
|
863
646
|
};
|
|
864
|
-
const stackItemContextValue =
|
|
647
|
+
const stackItemContextValue = useMemo2(() => ({
|
|
865
648
|
selfDragHandleRef,
|
|
866
649
|
size,
|
|
867
650
|
setSize,
|
|
@@ -876,13 +659,13 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
876
659
|
setDragState,
|
|
877
660
|
role
|
|
878
661
|
]);
|
|
879
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
|
|
880
663
|
value: stackItemContextValue
|
|
881
|
-
}, /* @__PURE__ */
|
|
664
|
+
}, /* @__PURE__ */ React8.createElement(Root, {
|
|
882
665
|
...props,
|
|
883
666
|
tabIndex: 0,
|
|
884
667
|
...focusableGroupAttrs,
|
|
885
|
-
className:
|
|
668
|
+
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
669
|
"data-dx-stack-item": stackId,
|
|
887
670
|
"data-dx-item-id": item.id,
|
|
888
671
|
...resizeAttributes,
|
|
@@ -894,7 +677,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
894
677
|
...style
|
|
895
678
|
},
|
|
896
679
|
ref: composedItemRef
|
|
897
|
-
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */
|
|
680
|
+
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
898
681
|
lineInset: 8,
|
|
899
682
|
terminalInset: -8,
|
|
900
683
|
edge: closestEdge
|
|
@@ -919,26 +702,13 @@ var StackItem = {
|
|
|
919
702
|
SigilButton: StackItemSigilButton
|
|
920
703
|
};
|
|
921
704
|
export {
|
|
922
|
-
CardStack,
|
|
923
|
-
CardStackDragPreview,
|
|
924
705
|
DEFAULT_EXTRINSIC_SIZE,
|
|
925
706
|
DEFAULT_HORIZONTAL_SIZE,
|
|
926
707
|
DEFAULT_VERTICAL_SIZE,
|
|
927
708
|
Stack,
|
|
928
709
|
StackContext,
|
|
929
710
|
StackItem,
|
|
930
|
-
autoScrollRootAttributes,
|
|
931
|
-
cardStackContent,
|
|
932
|
-
cardStackDefaultInlineSizeRem,
|
|
933
|
-
cardStackFooter,
|
|
934
|
-
cardStackHeading,
|
|
935
|
-
cardStackItem,
|
|
936
|
-
cardStackRoot,
|
|
937
711
|
railGridHorizontal,
|
|
938
|
-
|
|
939
|
-
railGridVertical,
|
|
940
|
-
railGridVerticalContainFitContent,
|
|
941
|
-
translationKey,
|
|
942
|
-
translations
|
|
712
|
+
railGridVertical
|
|
943
713
|
};
|
|
944
714
|
//# sourceMappingURL=index.mjs.map
|