@dxos/react-ui-stack 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +188 -416
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +23 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +188 -416
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +25 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/Stack/Stack.d.ts +4 -9
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/MenuSignifier.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.d.ts +5 -5
- package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemDragHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
- package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts +1 -1
- package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- package/dist/types/src/playwright/stack-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -35
- package/src/components/Stack/Stack.stories.tsx +8 -10
- package/src/components/Stack/Stack.tsx +197 -210
- package/src/components/StackItem/MenuSignifier.tsx +2 -9
- package/src/components/StackItem/StackItem.stories.tsx +4 -4
- package/src/components/StackItem/StackItem.tsx +13 -15
- package/src/components/StackItem/StackItemContent.tsx +6 -6
- package/src/components/StackItem/StackItemDragHandle.tsx +4 -3
- package/src/components/StackItem/StackItemHeading.tsx +13 -12
- package/src/components/StackItem/StackItemResizeHandle.tsx +1 -2
- package/src/components/StackItem/StackItemSigil.tsx +8 -5
- package/src/components/index.ts +1 -1
- package/src/hooks/useStackDropForElements.ts +2 -2
- package/src/index.ts +0 -1
- package/src/playwright/playwright.config.ts +1 -1
- package/src/translations.ts +8 -8
- package/dist/types/src/components/CardStack/CardStack.d.ts +0 -47
- package/dist/types/src/components/CardStack/CardStack.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts +0 -15
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts +0 -12
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +0 -1
- package/dist/types/src/components/CardStack/index.d.ts +0 -3
- package/dist/types/src/components/CardStack/index.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/LayoutControls.d.ts +0 -22
- package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +0 -1
- package/src/components/CardStack/CardStack.stories.tsx +0 -173
- package/src/components/CardStack/CardStack.tsx +0 -195
- package/src/components/CardStack/CardStackDragPreview.tsx +0 -64
- package/src/components/CardStack/index.ts +0 -6
- package/src/components/deprecated/LayoutControls.tsx +0 -112
|
@@ -1,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,133 @@ 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
327
|
role: "none",
|
|
545
328
|
style,
|
|
546
|
-
className:
|
|
329
|
+
className: mx2("group grid grid-cols-[100%] dx-density-coarse", stackItemSize === "contain" && "min-h-0 overflow-hidden", toolbar && role === "section" && "[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:top-0 [&_.dx-toolbar]:-mb-px [&_.dx-toolbar]:min-w-0", toolbar && "[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-b [&>.dx-toolbar]:border-subdued-separator", classNames),
|
|
547
330
|
"data-popover-collision-boundary": true,
|
|
548
331
|
ref: forwardedRef
|
|
549
332
|
}, children);
|
|
@@ -551,56 +334,58 @@ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, tool
|
|
|
551
334
|
StackItemContent.displayName = "StackItemContent";
|
|
552
335
|
|
|
553
336
|
// src/components/StackItem/StackItemDragHandle.tsx
|
|
554
|
-
import {
|
|
555
|
-
import
|
|
337
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
338
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
339
|
+
import React3 from "react";
|
|
556
340
|
var StackItemDragHandle = ({ asChild, children }) => {
|
|
557
341
|
const { selfDragHandleRef } = useStackItem();
|
|
558
|
-
const
|
|
559
|
-
return /* @__PURE__ */
|
|
342
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
343
|
+
return /* @__PURE__ */ React3.createElement(Comp, {
|
|
560
344
|
ref: selfDragHandleRef,
|
|
561
345
|
role: "button"
|
|
562
346
|
}, children);
|
|
563
347
|
};
|
|
564
348
|
|
|
565
349
|
// src/components/StackItem/StackItemHeading.tsx
|
|
566
|
-
import {
|
|
567
|
-
import
|
|
350
|
+
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
351
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
352
|
+
import React4, { forwardRef as forwardRef3 } from "react";
|
|
568
353
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
569
|
-
import { mx as
|
|
570
|
-
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
|
|
354
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
355
|
+
var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, role, ...props }) => {
|
|
571
356
|
const { orientation } = useStack();
|
|
572
|
-
const
|
|
573
|
-
return /* @__PURE__ */
|
|
574
|
-
role: "heading",
|
|
357
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
358
|
+
return /* @__PURE__ */ React4.createElement(Comp, {
|
|
575
359
|
...props,
|
|
576
|
-
|
|
360
|
+
role: role ?? "heading",
|
|
361
|
+
className: mx3("flex items-center border-x-0! bg-header-surface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subdued-separator' : "border-subdued-separator", orientation === "horizontal" ? "h-(--dx-rail-size)" : "w-(--dx-rail-size) flex-col", orientation === "horizontal" ? "border-b" : "border-e", classNames)
|
|
577
362
|
}, children);
|
|
578
363
|
};
|
|
579
364
|
var StackItemHeadingStickyContent = ({ children }) => {
|
|
580
|
-
return /* @__PURE__ */
|
|
365
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
581
366
|
role: "none",
|
|
582
|
-
className: "sticky
|
|
367
|
+
className: "sticky top-0 bg-(--sticky-bg) p-1 w-full"
|
|
583
368
|
}, children);
|
|
584
369
|
};
|
|
585
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
370
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
586
371
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
587
|
-
return /* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ React4.createElement("h1", {
|
|
588
373
|
...props,
|
|
589
374
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
590
|
-
className:
|
|
375
|
+
className: mx3("px-1 min-w-0 w-0 grow truncate font-medium text-base-surface-text data-[attention=true]:text-accent-text self-center", classNames),
|
|
591
376
|
ref: forwardedRef
|
|
592
377
|
});
|
|
593
378
|
});
|
|
594
379
|
|
|
595
380
|
// src/components/StackItem/StackItemResizeHandle.tsx
|
|
596
|
-
import
|
|
381
|
+
import React5 from "react";
|
|
597
382
|
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
598
383
|
var MIN_WIDTH = 20;
|
|
599
384
|
var MIN_HEIGHT = 3;
|
|
600
|
-
var StackItemResizeHandle = () => {
|
|
385
|
+
var StackItemResizeHandle = (_) => {
|
|
601
386
|
const { orientation } = useStack();
|
|
602
387
|
const { setSize, size } = useStackItem();
|
|
603
|
-
return /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
604
389
|
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
605
390
|
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
606
391
|
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
@@ -610,23 +395,24 @@ var StackItemResizeHandle = () => {
|
|
|
610
395
|
};
|
|
611
396
|
|
|
612
397
|
// src/components/StackItem/StackItemSigil.tsx
|
|
613
|
-
import
|
|
398
|
+
import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
|
|
614
399
|
import { keySymbols } from "@dxos/keyboard";
|
|
615
|
-
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation
|
|
400
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
616
401
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
617
|
-
import {
|
|
402
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
618
403
|
import { getHostPlatform } from "@dxos/util";
|
|
404
|
+
import { translationKey } from "#translations";
|
|
619
405
|
|
|
620
406
|
// src/components/StackItem/MenuSignifier.tsx
|
|
621
|
-
import
|
|
622
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
623
|
-
className: "absolute
|
|
407
|
+
import React6 from "react";
|
|
408
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
|
|
409
|
+
className: "absolute bottom-[7px]",
|
|
624
410
|
width: 20,
|
|
625
411
|
height: 2,
|
|
626
412
|
viewBox: "0 0 20 2",
|
|
627
413
|
stroke: "currentColor",
|
|
628
414
|
opacity: 0.5
|
|
629
|
-
}, /* @__PURE__ */
|
|
415
|
+
}, /* @__PURE__ */ React6.createElement("line", {
|
|
630
416
|
x1: 0.5,
|
|
631
417
|
y1: 0.75,
|
|
632
418
|
x2: 19,
|
|
@@ -638,56 +424,55 @@ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg",
|
|
|
638
424
|
}));
|
|
639
425
|
|
|
640
426
|
// src/components/StackItem/StackItemSigil.tsx
|
|
641
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
427
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
|
|
642
428
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
643
429
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
644
|
-
return /* @__PURE__ */
|
|
430
|
+
return /* @__PURE__ */ React7.createElement(Button, {
|
|
645
431
|
...props,
|
|
646
432
|
variant,
|
|
647
433
|
classNames: [
|
|
648
|
-
"shrink-0
|
|
434
|
+
"shrink-0 px-0 min-h-0 w-(--dx-rail-action) h-(--dx-rail-action) relative dx-app-no-drag",
|
|
649
435
|
classNames
|
|
650
436
|
],
|
|
651
437
|
ref: forwardedRef
|
|
652
|
-
}, isMenu && /* @__PURE__ */
|
|
438
|
+
}, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
653
439
|
});
|
|
654
|
-
var StackItemSigil = /* @__PURE__ */
|
|
655
|
-
const { t } =
|
|
440
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
441
|
+
const { t } = useTranslation(translationKey);
|
|
656
442
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
657
443
|
const hasActions = actionGroups && actionGroups.length > 0;
|
|
658
|
-
const button = /* @__PURE__ */
|
|
444
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
659
445
|
attendableId,
|
|
660
446
|
related,
|
|
661
447
|
isMenu: hasActions,
|
|
662
448
|
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
663
449
|
// Remove underscore icon when no actions are available?
|
|
664
450
|
classNames: !hasActions && "cursor-default"
|
|
665
|
-
}, /* @__PURE__ */
|
|
451
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
666
452
|
className: "sr-only"
|
|
667
|
-
}, triggerLabel), /* @__PURE__ */
|
|
668
|
-
icon
|
|
669
|
-
size: 5
|
|
453
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
454
|
+
icon
|
|
670
455
|
}));
|
|
671
456
|
if (!hasActions) {
|
|
672
457
|
return button;
|
|
673
458
|
}
|
|
674
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
675
460
|
open: optionsMenuOpen,
|
|
676
461
|
onOpenChange: setOptionsMenuOpen
|
|
677
|
-
}, /* @__PURE__ */
|
|
462
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
678
463
|
asChild: true,
|
|
679
464
|
ref: forwardedRef
|
|
680
|
-
}, button), /* @__PURE__ */
|
|
465
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
681
466
|
classNames: "z-[31]"
|
|
682
|
-
}, /* @__PURE__ */
|
|
683
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
684
|
-
return /* @__PURE__ */
|
|
467
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
468
|
+
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
469
|
+
return /* @__PURE__ */ React7.createElement(Fragment, {
|
|
685
470
|
key: index
|
|
686
471
|
}, separator, actions.map((action) => {
|
|
687
472
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
688
473
|
const menuItemType = action.properties.menuItemType;
|
|
689
474
|
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
690
|
-
return /* @__PURE__ */
|
|
475
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
691
476
|
key: action.id,
|
|
692
477
|
onClick: (event) => {
|
|
693
478
|
if (action.properties.disabled) {
|
|
@@ -703,28 +488,28 @@ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAct
|
|
|
703
488
|
...action.properties?.testId && {
|
|
704
489
|
"data-testid": action.properties.testId
|
|
705
490
|
}
|
|
706
|
-
}, /* @__PURE__ */
|
|
491
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
707
492
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
708
493
|
size: 4
|
|
709
|
-
}), /* @__PURE__ */
|
|
494
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
710
495
|
className: "grow truncate"
|
|
711
|
-
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */
|
|
496
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
|
|
712
497
|
asChild: true
|
|
713
|
-
}, /* @__PURE__ */
|
|
498
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
714
499
|
icon: "ph--check--regular",
|
|
715
500
|
size: 4
|
|
716
|
-
})), shortcut && /* @__PURE__ */
|
|
717
|
-
className:
|
|
501
|
+
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
502
|
+
className: mx4("shrink-0", "text-description")
|
|
718
503
|
}, keySymbols(shortcut).join("")));
|
|
719
504
|
}));
|
|
720
|
-
}), children), /* @__PURE__ */
|
|
505
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
721
506
|
});
|
|
722
507
|
|
|
723
508
|
// src/components/StackItem/StackItem.tsx
|
|
724
|
-
var DEFAULT_HORIZONTAL_SIZE = 48;
|
|
725
509
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
510
|
+
var DEFAULT_HORIZONTAL_SIZE = 50;
|
|
726
511
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
727
|
-
var StackItemRoot = /* @__PURE__ */
|
|
512
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ classNames, children, style, role, item, order, prevSiblingId, nextSiblingId, size: sizeProp, onSizeChange, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
728
513
|
const [itemElement, itemRef] = useState4(null);
|
|
729
514
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
730
515
|
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
@@ -732,7 +517,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
732
517
|
const [sourceId, setSourceId] = useState4(null);
|
|
733
518
|
const [dragState, setDragState] = useState4(idle);
|
|
734
519
|
const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
|
|
735
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(
|
|
520
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(sizeProp);
|
|
736
521
|
const Root = role ?? "div";
|
|
737
522
|
const setSize = useCallback2((nextSize, commit) => {
|
|
738
523
|
setInternalSize(nextSize);
|
|
@@ -863,7 +648,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
863
648
|
}
|
|
864
649
|
return true;
|
|
865
650
|
};
|
|
866
|
-
const stackItemContextValue =
|
|
651
|
+
const stackItemContextValue = useMemo2(() => ({
|
|
867
652
|
selfDragHandleRef,
|
|
868
653
|
size,
|
|
869
654
|
setSize,
|
|
@@ -878,13 +663,13 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
878
663
|
setDragState,
|
|
879
664
|
role
|
|
880
665
|
]);
|
|
881
|
-
return /* @__PURE__ */
|
|
666
|
+
return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
|
|
882
667
|
value: stackItemContextValue
|
|
883
|
-
}, /* @__PURE__ */
|
|
668
|
+
}, /* @__PURE__ */ React8.createElement(Root, {
|
|
884
669
|
...props,
|
|
885
670
|
tabIndex: 0,
|
|
886
671
|
...focusableGroupAttrs,
|
|
887
|
-
className:
|
|
672
|
+
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
673
|
"data-dx-stack-item": stackId,
|
|
889
674
|
"data-dx-item-id": item.id,
|
|
890
675
|
...resizeAttributes,
|
|
@@ -896,7 +681,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, s
|
|
|
896
681
|
...style
|
|
897
682
|
},
|
|
898
683
|
ref: composedItemRef
|
|
899
|
-
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */
|
|
684
|
+
}, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
900
685
|
lineInset: 8,
|
|
901
686
|
terminalInset: -8,
|
|
902
687
|
edge: closestEdge
|
|
@@ -921,26 +706,13 @@ var StackItem = {
|
|
|
921
706
|
SigilButton: StackItemSigilButton
|
|
922
707
|
};
|
|
923
708
|
export {
|
|
924
|
-
CardStack,
|
|
925
|
-
CardStackDragPreview,
|
|
926
709
|
DEFAULT_EXTRINSIC_SIZE,
|
|
927
710
|
DEFAULT_HORIZONTAL_SIZE,
|
|
928
711
|
DEFAULT_VERTICAL_SIZE,
|
|
929
712
|
Stack,
|
|
930
713
|
StackContext,
|
|
931
714
|
StackItem,
|
|
932
|
-
autoScrollRootAttributes,
|
|
933
|
-
cardStackContent,
|
|
934
|
-
cardStackDefaultInlineSizeRem,
|
|
935
|
-
cardStackFooter,
|
|
936
|
-
cardStackHeading,
|
|
937
|
-
cardStackItem,
|
|
938
|
-
cardStackRoot,
|
|
939
715
|
railGridHorizontal,
|
|
940
|
-
|
|
941
|
-
railGridVertical,
|
|
942
|
-
railGridVerticalContainFitContent,
|
|
943
|
-
translationKey,
|
|
944
|
-
translations
|
|
716
|
+
railGridVertical
|
|
945
717
|
};
|
|
946
718
|
//# sourceMappingURL=index.mjs.map
|