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