@dxos/react-ui-stack 0.7.4 → 0.7.5-feature-compute.4d9d99a
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 +176 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +183 -109
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +176 -103
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/LayoutControls.d.ts.map +1 -1
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +9 -4
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem.d.ts +12 -9
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItemContent.d.ts +35 -2
- package/dist/types/src/components/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItemDragHandle.d.ts +6 -0
- package/dist/types/src/components/StackItemDragHandle.d.ts.map +1 -0
- package/dist/types/src/components/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItemResizeHandle.d.ts +1 -0
- package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +21 -20
- package/src/components/LayoutControls.tsx +1 -3
- package/src/components/Stack.stories.tsx +5 -4
- package/src/components/Stack.tsx +56 -8
- package/src/components/StackContext.tsx +13 -4
- package/src/components/StackItem.tsx +18 -17
- package/src/components/StackItemContent.tsx +45 -32
- package/src/components/StackItemDragHandle.tsx +22 -0
- package/src/components/StackItemHeading.tsx +2 -4
- package/src/components/StackItemResizeHandle.tsx +7 -6
- package/src/components/StackItemSigil.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/dist/types/src/testing/EditorContent.d.ts +0 -8
- package/dist/types/src/testing/EditorContent.d.ts.map +0 -1
- package/src/testing/EditorContent.tsx +0 -60
package/dist/lib/node/index.cjs
CHANGED
|
@@ -35,47 +35,58 @@ __export(node_exports, {
|
|
|
35
35
|
Stack: () => Stack,
|
|
36
36
|
StackContext: () => StackContext,
|
|
37
37
|
StackItem: () => StackItem,
|
|
38
|
+
StackItemContext: () => StackItemContext,
|
|
38
39
|
railGridHorizontal: () => railGridHorizontal,
|
|
39
40
|
railGridVertical: () => railGridVertical,
|
|
40
|
-
translations: () => translations_default
|
|
41
|
+
translations: () => translations_default,
|
|
42
|
+
useStack: () => useStack,
|
|
43
|
+
useStackItem: () => useStackItem
|
|
41
44
|
});
|
|
42
45
|
module.exports = __toCommonJS(node_exports);
|
|
46
|
+
var import_adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
47
|
+
var import_closest_edge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
43
48
|
var import_react_tabster = require("@fluentui/react-tabster");
|
|
49
|
+
var import_react_compose_refs = require("@radix-ui/react-compose-refs");
|
|
44
50
|
var import_react = __toESM(require("react"));
|
|
51
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
45
52
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
46
53
|
var import_react2 = require("react");
|
|
47
54
|
var import_combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
48
|
-
var
|
|
49
|
-
var
|
|
55
|
+
var import_adapter2 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
56
|
+
var import_disable_native_drag_preview = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
|
|
57
|
+
var import_prevent_unhandled = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
|
|
58
|
+
var import_closest_edge2 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
50
59
|
var import_react_tabster2 = require("@fluentui/react-tabster");
|
|
51
|
-
var
|
|
60
|
+
var import_react_compose_refs2 = require("@radix-ui/react-compose-refs");
|
|
52
61
|
var import_react3 = __toESM(require("react"));
|
|
62
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
53
63
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
54
64
|
var import_react4 = __toESM(require("react"));
|
|
55
65
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
56
|
-
var
|
|
66
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
57
67
|
var import_react5 = __toESM(require("react"));
|
|
68
|
+
var import_react_tabster3 = require("@fluentui/react-tabster");
|
|
69
|
+
var import_react6 = __toESM(require("react"));
|
|
58
70
|
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
59
71
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var import_react6 = __toESM(require("react"));
|
|
64
|
-
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
72
|
+
var import_adapter3 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
73
|
+
var import_disable_native_drag_preview2 = require("@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview");
|
|
74
|
+
var import_prevent_unhandled2 = require("@atlaskit/pragmatic-drag-and-drop/prevent-unhandled");
|
|
65
75
|
var import_react7 = __toESM(require("react"));
|
|
76
|
+
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
77
|
+
var import_react8 = __toESM(require("react"));
|
|
66
78
|
var import_keyboard = require("@dxos/keyboard");
|
|
67
|
-
var
|
|
79
|
+
var import_react_ui3 = require("@dxos/react-ui");
|
|
68
80
|
var import_react_ui_attention2 = require("@dxos/react-ui-attention");
|
|
69
81
|
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
70
82
|
var import_util = require("@dxos/util");
|
|
71
|
-
var import_react8 = __toESM(require("react"));
|
|
72
83
|
var import_react9 = __toESM(require("react"));
|
|
73
|
-
var
|
|
84
|
+
var import_react10 = __toESM(require("react"));
|
|
85
|
+
var import_react_ui4 = require("@dxos/react-ui");
|
|
74
86
|
var StackContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
75
87
|
orientation: "vertical",
|
|
76
88
|
rail: true,
|
|
77
|
-
size: "intrinsic"
|
|
78
|
-
separators: true
|
|
89
|
+
size: "intrinsic"
|
|
79
90
|
});
|
|
80
91
|
var useStack = () => (0, import_react2.useContext)(StackContext);
|
|
81
92
|
var StackItemContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
@@ -88,7 +99,10 @@ var StackItemContext = /* @__PURE__ */ (0, import_react2.createContext)({
|
|
|
88
99
|
var useStackItem = () => (0, import_react2.useContext)(StackItemContext);
|
|
89
100
|
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
90
101
|
var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
91
|
-
var Stack = /* @__PURE__ */ (0, import_react.forwardRef)(({ children, classNames, style, orientation = "vertical", rail = true,
|
|
102
|
+
var Stack = /* @__PURE__ */ (0, import_react.forwardRef)(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = import_react.Children.count(children), ...props }, forwardedRef) => {
|
|
103
|
+
const [stackElement, stackRef] = (0, import_react.useState)(null);
|
|
104
|
+
const composedItemRef = (0, import_react_compose_refs.composeRefs)(stackRef, forwardedRef);
|
|
105
|
+
const [dropping, setDropping] = (0, import_react.useState)(false);
|
|
92
106
|
const arrowNavigationGroup = (0, import_react_tabster.useArrowNavigationGroup)({
|
|
93
107
|
axis: orientation
|
|
94
108
|
});
|
|
@@ -96,28 +110,72 @@ var Stack = /* @__PURE__ */ (0, import_react.forwardRef)(({ children, classNames
|
|
|
96
110
|
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
|
|
97
111
|
...style
|
|
98
112
|
};
|
|
113
|
+
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
114
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
115
|
+
if (!stackElement || !selfDroppable) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const acceptSourceType = orientation === "horizontal" ? "column" : "card";
|
|
119
|
+
return (0, import_adapter.dropTargetForElements)({
|
|
120
|
+
element: stackElement,
|
|
121
|
+
getData: ({ input, element }) => {
|
|
122
|
+
return (0, import_closest_edge.attachClosestEdge)({
|
|
123
|
+
id: props.id,
|
|
124
|
+
type: orientation === "horizontal" ? "card" : "column"
|
|
125
|
+
}, {
|
|
126
|
+
input,
|
|
127
|
+
element,
|
|
128
|
+
allowedEdges: [
|
|
129
|
+
orientation === "horizontal" ? "left" : "top"
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
onDragEnter: ({ source }) => {
|
|
134
|
+
if (source.data.type === acceptSourceType) {
|
|
135
|
+
setDropping(true);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
onDrag: ({ source }) => {
|
|
139
|
+
if (source.data.type === acceptSourceType) {
|
|
140
|
+
setDropping(true);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
onDragLeave: () => setDropping(false),
|
|
144
|
+
onDrop: ({ self, source }) => {
|
|
145
|
+
setDropping(false);
|
|
146
|
+
if (source.data.type === acceptSourceType && selfDroppable) {
|
|
147
|
+
onRearrange(source.data, self.data, (0, import_closest_edge.extractClosestEdge)(self.data));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}, [
|
|
152
|
+
stackElement,
|
|
153
|
+
selfDroppable
|
|
154
|
+
]);
|
|
99
155
|
return /* @__PURE__ */ import_react.default.createElement(StackContext.Provider, {
|
|
100
156
|
value: {
|
|
101
157
|
orientation,
|
|
102
158
|
rail,
|
|
103
159
|
size,
|
|
104
|
-
|
|
160
|
+
onRearrange
|
|
105
161
|
}
|
|
106
162
|
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
107
163
|
...props,
|
|
108
164
|
...arrowNavigationGroup,
|
|
109
|
-
className: (0, import_react_ui_theme.mx)("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1" : "grid-cols-1", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"),
|
|
165
|
+
className: (0, import_react_ui_theme.mx)("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1" : "grid-cols-1", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"), classNames),
|
|
110
166
|
"aria-orientation": orientation,
|
|
111
167
|
style: styles,
|
|
112
|
-
ref:
|
|
113
|
-
}, children
|
|
168
|
+
ref: composedItemRef
|
|
169
|
+
}, children, selfDroppable && dropping && /* @__PURE__ */ import_react.default.createElement(import_react_ui.ListItem.DropIndicator, {
|
|
170
|
+
edge: orientation === "horizontal" ? "left" : "top"
|
|
171
|
+
})));
|
|
114
172
|
});
|
|
115
|
-
var StackItemContent = ({ children, toolbar
|
|
116
|
-
const { size
|
|
173
|
+
var StackItemContent = /* @__PURE__ */ (0, import_react4.forwardRef)(({ children, toolbar, statusbar, classNames, size = "intrinsic", ...props }, forwardedRef) => {
|
|
174
|
+
const { size: stackItemSize } = useStack();
|
|
117
175
|
return /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
118
176
|
role: "none",
|
|
119
177
|
...props,
|
|
120
|
-
className: (0, import_react_ui_theme3.mx)("group grid grid-cols-[100%]",
|
|
178
|
+
className: (0, import_react_ui_theme3.mx)("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
|
|
121
179
|
style: {
|
|
122
180
|
gridTemplateRows: [
|
|
123
181
|
...toolbar ? [
|
|
@@ -128,30 +186,37 @@ var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...pr
|
|
|
128
186
|
"var(--statusbar-size)"
|
|
129
187
|
] : []
|
|
130
188
|
].join(" ")
|
|
131
|
-
}
|
|
189
|
+
},
|
|
190
|
+
ref: forwardedRef
|
|
191
|
+
}, children);
|
|
192
|
+
});
|
|
193
|
+
var StackItemDragHandle = ({ asChild, children }) => {
|
|
194
|
+
const { selfDragHandleRef } = useStackItem();
|
|
195
|
+
const Root = asChild ? import_react_slot.Slot : "div";
|
|
196
|
+
return /* @__PURE__ */ import_react5.default.createElement(Root, {
|
|
197
|
+
ref: selfDragHandleRef,
|
|
198
|
+
role: "button"
|
|
132
199
|
}, children);
|
|
133
200
|
};
|
|
134
201
|
var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
135
202
|
const { orientation } = useStack();
|
|
136
|
-
const { selfDragHandleRef } = useStackItem();
|
|
137
203
|
const focusableGroupAttrs = (0, import_react_tabster3.useFocusableGroup)({
|
|
138
204
|
tabBehavior: "limited"
|
|
139
205
|
});
|
|
140
|
-
return /* @__PURE__ */
|
|
206
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
141
207
|
role: "heading",
|
|
142
208
|
...props,
|
|
143
209
|
tabIndex: 0,
|
|
144
210
|
...focusableGroupAttrs,
|
|
145
|
-
className: (0, import_react_ui_theme4.mx)("flex items-center ch-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames)
|
|
146
|
-
ref: selfDragHandleRef
|
|
211
|
+
className: (0, import_react_ui_theme4.mx)("flex items-center ch-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames)
|
|
147
212
|
}, children);
|
|
148
213
|
};
|
|
149
|
-
var StackItemHeadingLabel = /* @__PURE__ */ (0,
|
|
214
|
+
var StackItemHeadingLabel = /* @__PURE__ */ (0, import_react6.forwardRef)(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
150
215
|
const { hasAttention, isAncestor, isRelated } = (0, import_react_ui_attention.useAttention)(attendableId);
|
|
151
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ import_react6.default.createElement("h1", {
|
|
152
217
|
...props,
|
|
153
218
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
154
|
-
className: (0, import_react_ui_theme4.mx)("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
|
|
219
|
+
className: (0, import_react_ui_theme4.mx)("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
|
|
155
220
|
ref: forwardedRef
|
|
156
221
|
});
|
|
157
222
|
});
|
|
@@ -170,20 +235,20 @@ var getNextSize = (startSize, location, client) => {
|
|
|
170
235
|
var StackItemResizeHandle = () => {
|
|
171
236
|
const { orientation } = useStack();
|
|
172
237
|
const { setSize, size } = useStackItem();
|
|
173
|
-
const buttonRef = (0,
|
|
174
|
-
const dragStartSize = (0,
|
|
238
|
+
const buttonRef = (0, import_react7.useRef)(null);
|
|
239
|
+
const dragStartSize = (0, import_react7.useRef)(size);
|
|
175
240
|
const client = orientation === "horizontal" ? "clientX" : "clientY";
|
|
176
|
-
(0,
|
|
241
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
177
242
|
if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
|
|
178
243
|
return;
|
|
179
244
|
}
|
|
180
|
-
(0,
|
|
245
|
+
(0, import_adapter3.draggable)({
|
|
181
246
|
element: buttonRef.current,
|
|
182
247
|
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
183
|
-
(0,
|
|
248
|
+
(0, import_disable_native_drag_preview2.disableNativeDragPreview)({
|
|
184
249
|
nativeSetDragImage
|
|
185
250
|
});
|
|
186
|
-
|
|
251
|
+
import_prevent_unhandled2.preventUnhandled.start();
|
|
187
252
|
},
|
|
188
253
|
onDragStart: () => {
|
|
189
254
|
dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
|
|
@@ -204,38 +269,38 @@ var StackItemResizeHandle = () => {
|
|
|
204
269
|
}
|
|
205
270
|
});
|
|
206
271
|
}, []);
|
|
207
|
-
return /* @__PURE__ */
|
|
272
|
+
return /* @__PURE__ */ import_react7.default.createElement("button", {
|
|
208
273
|
ref: buttonRef,
|
|
209
274
|
className: (0, import_react_ui_theme5.mx)(orientation === "horizontal" ? "cursor-col-resize" : "cursor-row-resize", "group absolute is-3 bs-full inline-end-[-1px] !border-lb-0", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:inset-block-0 before:inline-end-0 before:is-1 before:bg-accentFocusIndicator")
|
|
210
|
-
}, /* @__PURE__ */
|
|
275
|
+
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
211
276
|
role: "none",
|
|
212
277
|
className: "absolute block-start-0 inline-end-[1px] bs-[--rail-size] flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0"
|
|
213
|
-
}, /* @__PURE__ */
|
|
278
|
+
}, /* @__PURE__ */ import_react7.default.createElement(DragHandleSignifier, null)));
|
|
214
279
|
};
|
|
215
280
|
var DragHandleSignifier = () => {
|
|
216
|
-
return /* @__PURE__ */
|
|
281
|
+
return /* @__PURE__ */ import_react7.default.createElement("svg", {
|
|
217
282
|
xmlns: "http://www.w3.org/2000/svg",
|
|
218
283
|
viewBox: "0 0 256 256",
|
|
219
284
|
fill: "currentColor",
|
|
220
285
|
className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
|
|
221
|
-
}, /* @__PURE__ */
|
|
286
|
+
}, /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
222
287
|
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
223
|
-
}), /* @__PURE__ */
|
|
288
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
224
289
|
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
225
|
-
}), /* @__PURE__ */
|
|
290
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
226
291
|
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
227
|
-
}), /* @__PURE__ */
|
|
292
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
228
293
|
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
229
294
|
}));
|
|
230
295
|
};
|
|
231
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
296
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ import_react9.default.createElement("svg", {
|
|
232
297
|
className: "absolute block-end-[7px]",
|
|
233
298
|
width: 20,
|
|
234
299
|
height: 2,
|
|
235
300
|
viewBox: "0 0 20 2",
|
|
236
301
|
stroke: "currentColor",
|
|
237
302
|
opacity: 0.5
|
|
238
|
-
}, /* @__PURE__ */
|
|
303
|
+
}, /* @__PURE__ */ import_react9.default.createElement("line", {
|
|
239
304
|
x1: 0.5,
|
|
240
305
|
y1: 0.75,
|
|
241
306
|
x2: 19,
|
|
@@ -261,25 +326,25 @@ var translations_default = [
|
|
|
261
326
|
}
|
|
262
327
|
}
|
|
263
328
|
];
|
|
264
|
-
var StackItemSigilButton = /* @__PURE__ */ (0,
|
|
329
|
+
var StackItemSigilButton = /* @__PURE__ */ (0, import_react8.forwardRef)(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
|
|
265
330
|
const { hasAttention, isAncestor, isRelated } = (0, import_react_ui_attention2.useAttention)(attendableId);
|
|
266
331
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
267
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Button, {
|
|
268
333
|
...props,
|
|
269
334
|
variant,
|
|
270
335
|
classNames: [
|
|
271
|
-
"
|
|
336
|
+
"shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative",
|
|
272
337
|
classNames
|
|
273
338
|
],
|
|
274
339
|
ref: forwardedRef
|
|
275
|
-
}, /* @__PURE__ */
|
|
340
|
+
}, /* @__PURE__ */ import_react8.default.createElement(MenuSignifierHorizontal, null), children);
|
|
276
341
|
});
|
|
277
|
-
var StackItemSigil = /* @__PURE__ */ (0,
|
|
278
|
-
const { t } = (0,
|
|
279
|
-
const suppressNextTooltip = (0,
|
|
280
|
-
const [optionsMenuOpen, setOptionsMenuOpen] = (0,
|
|
281
|
-
const [triggerTooltipOpen, setTriggerTooltipOpen] = (0,
|
|
282
|
-
return /* @__PURE__ */
|
|
342
|
+
var StackItemSigil = /* @__PURE__ */ (0, import_react8.forwardRef)(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
343
|
+
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
344
|
+
const suppressNextTooltip = (0, import_react8.useRef)(false);
|
|
345
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = (0, import_react8.useState)(false);
|
|
346
|
+
const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react8.useState)(false);
|
|
347
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Root, {
|
|
283
348
|
open: triggerTooltipOpen,
|
|
284
349
|
onOpenChange: (nextOpen) => {
|
|
285
350
|
if (suppressNextTooltip.current) {
|
|
@@ -289,7 +354,7 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
289
354
|
setTriggerTooltipOpen(nextOpen);
|
|
290
355
|
}
|
|
291
356
|
}
|
|
292
|
-
}, /* @__PURE__ */
|
|
357
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Root, {
|
|
293
358
|
open: optionsMenuOpen,
|
|
294
359
|
onOpenChange: (nextOpen) => {
|
|
295
360
|
if (!nextOpen) {
|
|
@@ -297,30 +362,30 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
297
362
|
}
|
|
298
363
|
return setOptionsMenuOpen(nextOpen);
|
|
299
364
|
}
|
|
300
|
-
}, /* @__PURE__ */
|
|
365
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Trigger, {
|
|
301
366
|
asChild: true
|
|
302
|
-
}, /* @__PURE__ */
|
|
367
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Trigger, {
|
|
303
368
|
asChild: true,
|
|
304
369
|
ref: forwardedRef
|
|
305
|
-
}, /* @__PURE__ */
|
|
370
|
+
}, /* @__PURE__ */ import_react8.default.createElement(StackItemSigilButton, {
|
|
306
371
|
attendableId,
|
|
307
372
|
related
|
|
308
|
-
}, /* @__PURE__ */
|
|
373
|
+
}, /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
309
374
|
className: "sr-only"
|
|
310
|
-
}, triggerLabel), /* @__PURE__ */
|
|
375
|
+
}, triggerLabel), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
311
376
|
icon,
|
|
312
377
|
size: 5
|
|
313
|
-
})))), /* @__PURE__ */
|
|
378
|
+
})))), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Content, {
|
|
314
379
|
classNames: "z-[31]"
|
|
315
|
-
}, /* @__PURE__ */
|
|
316
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
317
|
-
return /* @__PURE__ */
|
|
380
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
381
|
+
const separator = index > 0 ? /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Separator, null) : null;
|
|
382
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.Fragment, {
|
|
318
383
|
key: index
|
|
319
384
|
}, separator, actions.map((action) => {
|
|
320
385
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[(0, import_util.getHostPlatform)()];
|
|
321
386
|
const menuItemType = action.properties.menuItemType;
|
|
322
|
-
const Root = menuItemType === "toggle" ?
|
|
323
|
-
return /* @__PURE__ */
|
|
387
|
+
const Root = menuItemType === "toggle" ? import_react_ui3.DropdownMenu.CheckboxItem : import_react_ui3.DropdownMenu.Item;
|
|
388
|
+
return /* @__PURE__ */ import_react8.default.createElement(Root, {
|
|
324
389
|
key: action.id,
|
|
325
390
|
onClick: (event) => {
|
|
326
391
|
if (action.properties.disabled) {
|
|
@@ -337,38 +402,35 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
337
402
|
...action.properties?.testId && {
|
|
338
403
|
"data-testid": action.properties.testId
|
|
339
404
|
}
|
|
340
|
-
}, /* @__PURE__ */
|
|
405
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
341
406
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
342
407
|
size: 4
|
|
343
|
-
}), /* @__PURE__ */
|
|
408
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
344
409
|
className: "grow truncate"
|
|
345
|
-
}, (0,
|
|
410
|
+
}, (0, import_react_ui3.toLocalizedString)(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.ItemIndicator, {
|
|
346
411
|
asChild: true
|
|
347
|
-
}, /* @__PURE__ */
|
|
412
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
348
413
|
icon: "ph--check--regular",
|
|
349
414
|
size: 4
|
|
350
|
-
})), shortcut && /* @__PURE__ */
|
|
415
|
+
})), shortcut && /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
351
416
|
className: (0, import_react_ui_theme6.mx)("shrink-0", import_react_ui_theme6.descriptionText)
|
|
352
417
|
}, (0, import_keyboard.keySymbols)(shortcut).join("")));
|
|
353
418
|
}));
|
|
354
|
-
}), children), /* @__PURE__ */
|
|
355
|
-
style: {
|
|
356
|
-
zIndex: 70
|
|
357
|
-
},
|
|
419
|
+
}), children), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Arrow, null)))), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Content, {
|
|
358
420
|
side: "bottom"
|
|
359
|
-
}, triggerLabel, /* @__PURE__ */
|
|
421
|
+
}, triggerLabel, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
|
|
360
422
|
});
|
|
361
423
|
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
362
424
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
363
425
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
364
|
-
var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, children, classNames,
|
|
426
|
+
var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, ...props }, forwardedRef) => {
|
|
365
427
|
const [itemElement, itemRef] = (0, import_react3.useState)(null);
|
|
366
428
|
const [selfDragHandleElement, selfDragHandleRef] = (0, import_react3.useState)(null);
|
|
367
|
-
const [
|
|
368
|
-
const { orientation, rail,
|
|
429
|
+
const [closestEdge, setEdge] = (0, import_react3.useState)(null);
|
|
430
|
+
const { orientation, rail, onRearrange } = useStack();
|
|
369
431
|
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = (0, import_react3.useState)(propsSize);
|
|
370
432
|
const Root = role ?? "div";
|
|
371
|
-
const composedItemRef = (0,
|
|
433
|
+
const composedItemRef = (0, import_react_compose_refs2.composeRefs)(itemRef, forwardedRef);
|
|
372
434
|
const setSize = (0, import_react3.useCallback)((nextSize, commit) => {
|
|
373
435
|
setInternalSize(nextSize);
|
|
374
436
|
if (commit) {
|
|
@@ -382,7 +444,7 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
382
444
|
if (!itemElement || !onRearrange) {
|
|
383
445
|
return;
|
|
384
446
|
}
|
|
385
|
-
return (0, import_combine.combine)((0,
|
|
447
|
+
return (0, import_combine.combine)((0, import_adapter2.draggable)({
|
|
386
448
|
element: itemElement,
|
|
387
449
|
...selfDragHandleElement && {
|
|
388
450
|
dragHandle: selfDragHandleElement
|
|
@@ -390,11 +452,18 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
390
452
|
getInitialData: () => ({
|
|
391
453
|
id: item.id,
|
|
392
454
|
type
|
|
393
|
-
})
|
|
394
|
-
|
|
455
|
+
}),
|
|
456
|
+
// TODO(thure): tabster focus honeypots are causing the preview to render with the wrong dimensions; what do?
|
|
457
|
+
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
458
|
+
(0, import_disable_native_drag_preview.disableNativeDragPreview)({
|
|
459
|
+
nativeSetDragImage
|
|
460
|
+
});
|
|
461
|
+
import_prevent_unhandled.preventUnhandled.start();
|
|
462
|
+
}
|
|
463
|
+
}), (0, import_adapter2.dropTargetForElements)({
|
|
395
464
|
element: itemElement,
|
|
396
465
|
getData: ({ input, element }) => {
|
|
397
|
-
return (0,
|
|
466
|
+
return (0, import_closest_edge2.attachClosestEdge)({
|
|
398
467
|
id: item.id,
|
|
399
468
|
type
|
|
400
469
|
}, {
|
|
@@ -411,19 +480,19 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
411
480
|
},
|
|
412
481
|
onDragEnter: ({ self, source }) => {
|
|
413
482
|
if (source.data.type === self.data.type) {
|
|
414
|
-
setEdge((0,
|
|
483
|
+
setEdge((0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
415
484
|
}
|
|
416
485
|
},
|
|
417
486
|
onDrag: ({ self, source }) => {
|
|
418
487
|
if (source.data.type === self.data.type) {
|
|
419
|
-
setEdge((0,
|
|
488
|
+
setEdge((0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
420
489
|
}
|
|
421
490
|
},
|
|
422
491
|
onDragLeave: () => setEdge(null),
|
|
423
492
|
onDrop: ({ self, source }) => {
|
|
424
493
|
setEdge(null);
|
|
425
494
|
if (source.data.type === self.data.type) {
|
|
426
|
-
onRearrange(source.data, self.data, (0,
|
|
495
|
+
onRearrange(source.data, self.data, (0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
427
496
|
}
|
|
428
497
|
}
|
|
429
498
|
}));
|
|
@@ -447,7 +516,7 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
447
516
|
...props,
|
|
448
517
|
tabIndex: 0,
|
|
449
518
|
...focusGroupAttrs,
|
|
450
|
-
className: (0, import_react_ui_theme2.mx)("group/stack-item grid relative ch-focus-ring-inset-over-all", size === "min-content" && (orientation === "horizontal" ? "is-min" : "bs-min"), orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"),
|
|
519
|
+
className: (0, import_react_ui_theme2.mx)("group/stack-item grid relative ch-focus-ring-inset-over-all", size === "min-content" && (orientation === "horizontal" ? "is-min" : "bs-min"), orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
|
|
451
520
|
"data-dx-stack-item": true,
|
|
452
521
|
style: {
|
|
453
522
|
...size !== "min-content" && {
|
|
@@ -459,7 +528,9 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
459
528
|
...style
|
|
460
529
|
},
|
|
461
530
|
ref: composedItemRef
|
|
462
|
-
}, children
|
|
531
|
+
}, children, closestEdge && /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ListItem.DropIndicator, {
|
|
532
|
+
edge: closestEdge
|
|
533
|
+
})));
|
|
463
534
|
});
|
|
464
535
|
var StackItem = {
|
|
465
536
|
Root: StackItemRoot,
|
|
@@ -467,51 +538,51 @@ var StackItem = {
|
|
|
467
538
|
Heading: StackItemHeading,
|
|
468
539
|
HeadingLabel: StackItemHeadingLabel,
|
|
469
540
|
ResizeHandle: StackItemResizeHandle,
|
|
541
|
+
DragHandle: StackItemDragHandle,
|
|
470
542
|
Sigil: StackItemSigil,
|
|
471
543
|
SigilButton: StackItemSigilButton
|
|
472
544
|
};
|
|
473
545
|
var LayoutControl = ({ icon, label, ...props }) => {
|
|
474
|
-
return /* @__PURE__ */
|
|
546
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
475
547
|
asChild: true
|
|
476
|
-
}, /* @__PURE__ */
|
|
548
|
+
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Button, {
|
|
477
549
|
variant: "ghost",
|
|
478
550
|
...props
|
|
479
|
-
}, /* @__PURE__ */
|
|
551
|
+
}, /* @__PURE__ */ import_react10.default.createElement("span", {
|
|
480
552
|
className: "sr-only"
|
|
481
|
-
}, label), /* @__PURE__ */
|
|
553
|
+
}, label), /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Icon, {
|
|
482
554
|
icon
|
|
483
|
-
}))), /* @__PURE__ */
|
|
484
|
-
side: "bottom"
|
|
485
|
-
classNames: "z-[70]"
|
|
555
|
+
}))), /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Content, {
|
|
556
|
+
side: "bottom"
|
|
486
557
|
}, label)));
|
|
487
558
|
};
|
|
488
|
-
var LayoutControls = /* @__PURE__ */ (0,
|
|
489
|
-
const { t } = (0,
|
|
559
|
+
var LayoutControls = /* @__PURE__ */ (0, import_react10.forwardRef)(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
|
|
560
|
+
const { t } = (0, import_react_ui4.useTranslation)(translationKey);
|
|
490
561
|
const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
|
|
491
|
-
return /* @__PURE__ */
|
|
562
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.ButtonGroup, {
|
|
492
563
|
...props,
|
|
493
564
|
ref: forwardedRef
|
|
494
565
|
}, pin && !isSolo && [
|
|
495
566
|
"both",
|
|
496
567
|
"start"
|
|
497
|
-
].includes(pin) && /* @__PURE__ */
|
|
568
|
+
].includes(pin) && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
498
569
|
label: t("pin start label"),
|
|
499
570
|
variant: "ghost",
|
|
500
571
|
classNames: buttonClassNames,
|
|
501
572
|
onClick: () => onClick?.("pin-start"),
|
|
502
573
|
icon: "ph--caret-line-left--regular"
|
|
503
|
-
}), can.solo && /* @__PURE__ */
|
|
574
|
+
}), can.solo && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
504
575
|
label: t("solo layout label"),
|
|
505
576
|
classNames: buttonClassNames,
|
|
506
577
|
onClick: () => onClick?.("solo"),
|
|
507
578
|
icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
|
|
508
|
-
}), !isSolo && can.solo && /* @__PURE__ */
|
|
579
|
+
}), !isSolo && can.solo && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
509
580
|
label: t("increment start label"),
|
|
510
581
|
disabled: !can.incrementStart,
|
|
511
582
|
classNames: buttonClassNames,
|
|
512
583
|
onClick: () => onClick?.("increment-start"),
|
|
513
584
|
icon: "ph--caret-left--regular"
|
|
514
|
-
}), /* @__PURE__ */
|
|
585
|
+
}), /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
515
586
|
label: t("increment end label"),
|
|
516
587
|
disabled: !can.incrementEnd,
|
|
517
588
|
classNames: buttonClassNames,
|
|
@@ -520,12 +591,12 @@ var LayoutControls = /* @__PURE__ */ (0, import_react9.forwardRef)(({ onClick, v
|
|
|
520
591
|
})), pin && !isSolo && [
|
|
521
592
|
"both",
|
|
522
593
|
"end"
|
|
523
|
-
].includes(pin) && /* @__PURE__ */
|
|
594
|
+
].includes(pin) && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
524
595
|
label: t("pin end label"),
|
|
525
596
|
classNames: buttonClassNames,
|
|
526
597
|
onClick: () => onClick?.("pin-end"),
|
|
527
598
|
icon: "ph--caret-line-right--regular"
|
|
528
|
-
}), close && !isSolo && /* @__PURE__ */
|
|
599
|
+
}), close && !isSolo && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
529
600
|
label: t(`${typeof close === "string" ? "minify" : "close"} label`),
|
|
530
601
|
classNames: buttonClassNames,
|
|
531
602
|
onClick: () => onClick?.("close"),
|
|
@@ -542,8 +613,11 @@ var LayoutControls = /* @__PURE__ */ (0, import_react9.forwardRef)(({ onClick, v
|
|
|
542
613
|
Stack,
|
|
543
614
|
StackContext,
|
|
544
615
|
StackItem,
|
|
616
|
+
StackItemContext,
|
|
545
617
|
railGridHorizontal,
|
|
546
618
|
railGridVertical,
|
|
547
|
-
translations
|
|
619
|
+
translations,
|
|
620
|
+
useStack,
|
|
621
|
+
useStackItem
|
|
548
622
|
});
|
|
549
623
|
//# sourceMappingURL=index.cjs.map
|