@dxos/react-ui-stack 0.7.4-staging.f7e8224 → 0.7.5-main.499c70c
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 +166 -94
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +178 -105
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +166 -94
- 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 +5 -8
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- 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 +2 -7
- package/src/components/StackItemDragHandle.tsx +22 -0
- package/src/components/StackItemHeading.tsx +1 -3
- package/src/components/StackItemResizeHandle.tsx +7 -6
- package/src/components/StackItemSigil.tsx +1 -1
- package/src/components/index.ts +1 -0
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
173
|
var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...props }) => {
|
|
116
|
-
const { size
|
|
174
|
+
const { size } = 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%]", size === "contain" && "min-bs-0 overflow-hidden",
|
|
178
|
+
className: (0, import_react_ui_theme3.mx)("group grid grid-cols-[100%]", size === "contain" && "min-bs-0 overflow-hidden", classNames),
|
|
121
179
|
style: {
|
|
122
180
|
gridTemplateRows: [
|
|
123
181
|
...toolbar ? [
|
|
@@ -131,24 +189,30 @@ var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...pr
|
|
|
131
189
|
}
|
|
132
190
|
}, children);
|
|
133
191
|
};
|
|
192
|
+
var StackItemDragHandle = ({ asChild, children }) => {
|
|
193
|
+
const { selfDragHandleRef } = useStackItem();
|
|
194
|
+
const Root = asChild ? import_react_slot.Slot : "div";
|
|
195
|
+
return /* @__PURE__ */ import_react5.default.createElement(Root, {
|
|
196
|
+
ref: selfDragHandleRef,
|
|
197
|
+
role: "button"
|
|
198
|
+
}, children);
|
|
199
|
+
};
|
|
134
200
|
var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
135
201
|
const { orientation } = useStack();
|
|
136
|
-
const { selfDragHandleRef } = useStackItem();
|
|
137
202
|
const focusableGroupAttrs = (0, import_react_tabster3.useFocusableGroup)({
|
|
138
203
|
tabBehavior: "limited"
|
|
139
204
|
});
|
|
140
|
-
return /* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
141
206
|
role: "heading",
|
|
142
207
|
...props,
|
|
143
208
|
tabIndex: 0,
|
|
144
209
|
...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
|
|
210
|
+
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
211
|
}, children);
|
|
148
212
|
};
|
|
149
|
-
var StackItemHeadingLabel = /* @__PURE__ */ (0,
|
|
213
|
+
var StackItemHeadingLabel = /* @__PURE__ */ (0, import_react6.forwardRef)(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
150
214
|
const { hasAttention, isAncestor, isRelated } = (0, import_react_ui_attention.useAttention)(attendableId);
|
|
151
|
-
return /* @__PURE__ */
|
|
215
|
+
return /* @__PURE__ */ import_react6.default.createElement("h1", {
|
|
152
216
|
...props,
|
|
153
217
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
154
218
|
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),
|
|
@@ -170,20 +234,20 @@ var getNextSize = (startSize, location, client) => {
|
|
|
170
234
|
var StackItemResizeHandle = () => {
|
|
171
235
|
const { orientation } = useStack();
|
|
172
236
|
const { setSize, size } = useStackItem();
|
|
173
|
-
const buttonRef = (0,
|
|
174
|
-
const dragStartSize = (0,
|
|
237
|
+
const buttonRef = (0, import_react7.useRef)(null);
|
|
238
|
+
const dragStartSize = (0, import_react7.useRef)(size);
|
|
175
239
|
const client = orientation === "horizontal" ? "clientX" : "clientY";
|
|
176
|
-
(0,
|
|
240
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
177
241
|
if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
|
|
178
242
|
return;
|
|
179
243
|
}
|
|
180
|
-
(0,
|
|
244
|
+
(0, import_adapter3.draggable)({
|
|
181
245
|
element: buttonRef.current,
|
|
182
246
|
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
183
|
-
(0,
|
|
247
|
+
(0, import_disable_native_drag_preview2.disableNativeDragPreview)({
|
|
184
248
|
nativeSetDragImage
|
|
185
249
|
});
|
|
186
|
-
|
|
250
|
+
import_prevent_unhandled2.preventUnhandled.start();
|
|
187
251
|
},
|
|
188
252
|
onDragStart: () => {
|
|
189
253
|
dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
|
|
@@ -204,38 +268,38 @@ var StackItemResizeHandle = () => {
|
|
|
204
268
|
}
|
|
205
269
|
});
|
|
206
270
|
}, []);
|
|
207
|
-
return /* @__PURE__ */
|
|
271
|
+
return /* @__PURE__ */ import_react7.default.createElement("button", {
|
|
208
272
|
ref: buttonRef,
|
|
209
273
|
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__ */
|
|
274
|
+
}, /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
211
275
|
role: "none",
|
|
212
276
|
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__ */
|
|
277
|
+
}, /* @__PURE__ */ import_react7.default.createElement(DragHandleSignifier, null)));
|
|
214
278
|
};
|
|
215
279
|
var DragHandleSignifier = () => {
|
|
216
|
-
return /* @__PURE__ */
|
|
280
|
+
return /* @__PURE__ */ import_react7.default.createElement("svg", {
|
|
217
281
|
xmlns: "http://www.w3.org/2000/svg",
|
|
218
282
|
viewBox: "0 0 256 256",
|
|
219
283
|
fill: "currentColor",
|
|
220
284
|
className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
|
|
221
|
-
}, /* @__PURE__ */
|
|
285
|
+
}, /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
222
286
|
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
223
|
-
}), /* @__PURE__ */
|
|
287
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
224
288
|
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
225
|
-
}), /* @__PURE__ */
|
|
289
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
226
290
|
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
227
|
-
}), /* @__PURE__ */
|
|
291
|
+
}), /* @__PURE__ */ import_react7.default.createElement("path", {
|
|
228
292
|
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
229
293
|
}));
|
|
230
294
|
};
|
|
231
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
295
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ import_react9.default.createElement("svg", {
|
|
232
296
|
className: "absolute block-end-[7px]",
|
|
233
297
|
width: 20,
|
|
234
298
|
height: 2,
|
|
235
299
|
viewBox: "0 0 20 2",
|
|
236
300
|
stroke: "currentColor",
|
|
237
301
|
opacity: 0.5
|
|
238
|
-
}, /* @__PURE__ */
|
|
302
|
+
}, /* @__PURE__ */ import_react9.default.createElement("line", {
|
|
239
303
|
x1: 0.5,
|
|
240
304
|
y1: 0.75,
|
|
241
305
|
x2: 19,
|
|
@@ -261,10 +325,10 @@ var translations_default = [
|
|
|
261
325
|
}
|
|
262
326
|
}
|
|
263
327
|
];
|
|
264
|
-
var StackItemSigilButton = /* @__PURE__ */ (0,
|
|
328
|
+
var StackItemSigilButton = /* @__PURE__ */ (0, import_react8.forwardRef)(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
|
|
265
329
|
const { hasAttention, isAncestor, isRelated } = (0, import_react_ui_attention2.useAttention)(attendableId);
|
|
266
330
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
267
|
-
return /* @__PURE__ */
|
|
331
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Button, {
|
|
268
332
|
...props,
|
|
269
333
|
variant,
|
|
270
334
|
classNames: [
|
|
@@ -272,14 +336,14 @@ var StackItemSigilButton = /* @__PURE__ */ (0, import_react7.forwardRef)(({ atte
|
|
|
272
336
|
classNames
|
|
273
337
|
],
|
|
274
338
|
ref: forwardedRef
|
|
275
|
-
}, /* @__PURE__ */
|
|
339
|
+
}, /* @__PURE__ */ import_react8.default.createElement(MenuSignifierHorizontal, null), children);
|
|
276
340
|
});
|
|
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__ */
|
|
341
|
+
var StackItemSigil = /* @__PURE__ */ (0, import_react8.forwardRef)(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
342
|
+
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
343
|
+
const suppressNextTooltip = (0, import_react8.useRef)(false);
|
|
344
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = (0, import_react8.useState)(false);
|
|
345
|
+
const [triggerTooltipOpen, setTriggerTooltipOpen] = (0, import_react8.useState)(false);
|
|
346
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Root, {
|
|
283
347
|
open: triggerTooltipOpen,
|
|
284
348
|
onOpenChange: (nextOpen) => {
|
|
285
349
|
if (suppressNextTooltip.current) {
|
|
@@ -289,7 +353,7 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
289
353
|
setTriggerTooltipOpen(nextOpen);
|
|
290
354
|
}
|
|
291
355
|
}
|
|
292
|
-
}, /* @__PURE__ */
|
|
356
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Root, {
|
|
293
357
|
open: optionsMenuOpen,
|
|
294
358
|
onOpenChange: (nextOpen) => {
|
|
295
359
|
if (!nextOpen) {
|
|
@@ -297,30 +361,30 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
297
361
|
}
|
|
298
362
|
return setOptionsMenuOpen(nextOpen);
|
|
299
363
|
}
|
|
300
|
-
}, /* @__PURE__ */
|
|
364
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Trigger, {
|
|
301
365
|
asChild: true
|
|
302
|
-
}, /* @__PURE__ */
|
|
366
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Trigger, {
|
|
303
367
|
asChild: true,
|
|
304
368
|
ref: forwardedRef
|
|
305
|
-
}, /* @__PURE__ */
|
|
369
|
+
}, /* @__PURE__ */ import_react8.default.createElement(StackItemSigilButton, {
|
|
306
370
|
attendableId,
|
|
307
371
|
related
|
|
308
|
-
}, /* @__PURE__ */
|
|
372
|
+
}, /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
309
373
|
className: "sr-only"
|
|
310
|
-
}, triggerLabel), /* @__PURE__ */
|
|
374
|
+
}, triggerLabel), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
311
375
|
icon,
|
|
312
376
|
size: 5
|
|
313
|
-
})))), /* @__PURE__ */
|
|
377
|
+
})))), /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Content, {
|
|
314
378
|
classNames: "z-[31]"
|
|
315
|
-
}, /* @__PURE__ */
|
|
316
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
317
|
-
return /* @__PURE__ */
|
|
379
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
380
|
+
const separator = index > 0 ? /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.Separator, null) : null;
|
|
381
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.Fragment, {
|
|
318
382
|
key: index
|
|
319
383
|
}, separator, actions.map((action) => {
|
|
320
384
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[(0, import_util.getHostPlatform)()];
|
|
321
385
|
const menuItemType = action.properties.menuItemType;
|
|
322
|
-
const Root = menuItemType === "toggle" ?
|
|
323
|
-
return /* @__PURE__ */
|
|
386
|
+
const Root = menuItemType === "toggle" ? import_react_ui3.DropdownMenu.CheckboxItem : import_react_ui3.DropdownMenu.Item;
|
|
387
|
+
return /* @__PURE__ */ import_react8.default.createElement(Root, {
|
|
324
388
|
key: action.id,
|
|
325
389
|
onClick: (event) => {
|
|
326
390
|
if (action.properties.disabled) {
|
|
@@ -337,38 +401,35 @@ var StackItemSigil = /* @__PURE__ */ (0, import_react7.forwardRef)(({ actions: a
|
|
|
337
401
|
...action.properties?.testId && {
|
|
338
402
|
"data-testid": action.properties.testId
|
|
339
403
|
}
|
|
340
|
-
}, /* @__PURE__ */
|
|
404
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
341
405
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
342
406
|
size: 4
|
|
343
|
-
}), /* @__PURE__ */
|
|
407
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
344
408
|
className: "grow truncate"
|
|
345
|
-
}, (0,
|
|
409
|
+
}, (0, import_react_ui3.toLocalizedString)(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.DropdownMenu.ItemIndicator, {
|
|
346
410
|
asChild: true
|
|
347
|
-
}, /* @__PURE__ */
|
|
411
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Icon, {
|
|
348
412
|
icon: "ph--check--regular",
|
|
349
413
|
size: 4
|
|
350
|
-
})), shortcut && /* @__PURE__ */
|
|
414
|
+
})), shortcut && /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
351
415
|
className: (0, import_react_ui_theme6.mx)("shrink-0", import_react_ui_theme6.descriptionText)
|
|
352
416
|
}, (0, import_keyboard.keySymbols)(shortcut).join("")));
|
|
353
417
|
}));
|
|
354
|
-
}), children), /* @__PURE__ */
|
|
355
|
-
style: {
|
|
356
|
-
zIndex: 70
|
|
357
|
-
},
|
|
418
|
+
}), 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
419
|
side: "bottom"
|
|
359
|
-
}, triggerLabel, /* @__PURE__ */
|
|
420
|
+
}, triggerLabel, /* @__PURE__ */ import_react8.default.createElement(import_react_ui3.Tooltip.Arrow, null))));
|
|
360
421
|
});
|
|
361
422
|
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
362
423
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
363
424
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
364
|
-
var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, children, classNames,
|
|
425
|
+
var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, ...props }, forwardedRef) => {
|
|
365
426
|
const [itemElement, itemRef] = (0, import_react3.useState)(null);
|
|
366
427
|
const [selfDragHandleElement, selfDragHandleRef] = (0, import_react3.useState)(null);
|
|
367
|
-
const [
|
|
368
|
-
const { orientation, rail,
|
|
428
|
+
const [closestEdge, setEdge] = (0, import_react3.useState)(null);
|
|
429
|
+
const { orientation, rail, onRearrange } = useStack();
|
|
369
430
|
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = (0, import_react3.useState)(propsSize);
|
|
370
431
|
const Root = role ?? "div";
|
|
371
|
-
const composedItemRef = (0,
|
|
432
|
+
const composedItemRef = (0, import_react_compose_refs2.composeRefs)(itemRef, forwardedRef);
|
|
372
433
|
const setSize = (0, import_react3.useCallback)((nextSize, commit) => {
|
|
373
434
|
setInternalSize(nextSize);
|
|
374
435
|
if (commit) {
|
|
@@ -382,7 +443,7 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
382
443
|
if (!itemElement || !onRearrange) {
|
|
383
444
|
return;
|
|
384
445
|
}
|
|
385
|
-
return (0, import_combine.combine)((0,
|
|
446
|
+
return (0, import_combine.combine)((0, import_adapter2.draggable)({
|
|
386
447
|
element: itemElement,
|
|
387
448
|
...selfDragHandleElement && {
|
|
388
449
|
dragHandle: selfDragHandleElement
|
|
@@ -390,11 +451,18 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
390
451
|
getInitialData: () => ({
|
|
391
452
|
id: item.id,
|
|
392
453
|
type
|
|
393
|
-
})
|
|
394
|
-
|
|
454
|
+
}),
|
|
455
|
+
// TODO(thure): tabster focus honeypots are causing the preview to render with the wrong dimensions; what do?
|
|
456
|
+
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
457
|
+
(0, import_disable_native_drag_preview.disableNativeDragPreview)({
|
|
458
|
+
nativeSetDragImage
|
|
459
|
+
});
|
|
460
|
+
import_prevent_unhandled.preventUnhandled.start();
|
|
461
|
+
}
|
|
462
|
+
}), (0, import_adapter2.dropTargetForElements)({
|
|
395
463
|
element: itemElement,
|
|
396
464
|
getData: ({ input, element }) => {
|
|
397
|
-
return (0,
|
|
465
|
+
return (0, import_closest_edge2.attachClosestEdge)({
|
|
398
466
|
id: item.id,
|
|
399
467
|
type
|
|
400
468
|
}, {
|
|
@@ -411,19 +479,19 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
411
479
|
},
|
|
412
480
|
onDragEnter: ({ self, source }) => {
|
|
413
481
|
if (source.data.type === self.data.type) {
|
|
414
|
-
setEdge((0,
|
|
482
|
+
setEdge((0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
415
483
|
}
|
|
416
484
|
},
|
|
417
485
|
onDrag: ({ self, source }) => {
|
|
418
486
|
if (source.data.type === self.data.type) {
|
|
419
|
-
setEdge((0,
|
|
487
|
+
setEdge((0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
420
488
|
}
|
|
421
489
|
},
|
|
422
490
|
onDragLeave: () => setEdge(null),
|
|
423
491
|
onDrop: ({ self, source }) => {
|
|
424
492
|
setEdge(null);
|
|
425
493
|
if (source.data.type === self.data.type) {
|
|
426
|
-
onRearrange(source.data, self.data, (0,
|
|
494
|
+
onRearrange(source.data, self.data, (0, import_closest_edge2.extractClosestEdge)(self.data));
|
|
427
495
|
}
|
|
428
496
|
}
|
|
429
497
|
}));
|
|
@@ -447,7 +515,7 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
447
515
|
...props,
|
|
448
516
|
tabIndex: 0,
|
|
449
517
|
...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"),
|
|
518
|
+
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
519
|
"data-dx-stack-item": true,
|
|
452
520
|
style: {
|
|
453
521
|
...size !== "min-content" && {
|
|
@@ -459,7 +527,9 @@ var StackItemRoot = /* @__PURE__ */ (0, import_react3.forwardRef)(({ item, child
|
|
|
459
527
|
...style
|
|
460
528
|
},
|
|
461
529
|
ref: composedItemRef
|
|
462
|
-
}, children
|
|
530
|
+
}, children, closestEdge && /* @__PURE__ */ import_react3.default.createElement(import_react_ui2.ListItem.DropIndicator, {
|
|
531
|
+
edge: closestEdge
|
|
532
|
+
})));
|
|
463
533
|
});
|
|
464
534
|
var StackItem = {
|
|
465
535
|
Root: StackItemRoot,
|
|
@@ -467,51 +537,51 @@ var StackItem = {
|
|
|
467
537
|
Heading: StackItemHeading,
|
|
468
538
|
HeadingLabel: StackItemHeadingLabel,
|
|
469
539
|
ResizeHandle: StackItemResizeHandle,
|
|
540
|
+
DragHandle: StackItemDragHandle,
|
|
470
541
|
Sigil: StackItemSigil,
|
|
471
542
|
SigilButton: StackItemSigilButton
|
|
472
543
|
};
|
|
473
544
|
var LayoutControl = ({ icon, label, ...props }) => {
|
|
474
|
-
return /* @__PURE__ */
|
|
545
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Root, null, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Trigger, {
|
|
475
546
|
asChild: true
|
|
476
|
-
}, /* @__PURE__ */
|
|
547
|
+
}, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Button, {
|
|
477
548
|
variant: "ghost",
|
|
478
549
|
...props
|
|
479
|
-
}, /* @__PURE__ */
|
|
550
|
+
}, /* @__PURE__ */ import_react10.default.createElement("span", {
|
|
480
551
|
className: "sr-only"
|
|
481
|
-
}, label), /* @__PURE__ */
|
|
552
|
+
}, label), /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Icon, {
|
|
482
553
|
icon
|
|
483
|
-
}))), /* @__PURE__ */
|
|
484
|
-
side: "bottom"
|
|
485
|
-
classNames: "z-[70]"
|
|
554
|
+
}))), /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Portal, null, /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.Tooltip.Content, {
|
|
555
|
+
side: "bottom"
|
|
486
556
|
}, label)));
|
|
487
557
|
};
|
|
488
|
-
var LayoutControls = /* @__PURE__ */ (0,
|
|
489
|
-
const { t } = (0,
|
|
558
|
+
var LayoutControls = /* @__PURE__ */ (0, import_react10.forwardRef)(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
|
|
559
|
+
const { t } = (0, import_react_ui4.useTranslation)(translationKey);
|
|
490
560
|
const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
|
|
491
|
-
return /* @__PURE__ */
|
|
561
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react_ui4.ButtonGroup, {
|
|
492
562
|
...props,
|
|
493
563
|
ref: forwardedRef
|
|
494
564
|
}, pin && !isSolo && [
|
|
495
565
|
"both",
|
|
496
566
|
"start"
|
|
497
|
-
].includes(pin) && /* @__PURE__ */
|
|
567
|
+
].includes(pin) && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
498
568
|
label: t("pin start label"),
|
|
499
569
|
variant: "ghost",
|
|
500
570
|
classNames: buttonClassNames,
|
|
501
571
|
onClick: () => onClick?.("pin-start"),
|
|
502
572
|
icon: "ph--caret-line-left--regular"
|
|
503
|
-
}), can.solo && /* @__PURE__ */
|
|
573
|
+
}), can.solo && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
504
574
|
label: t("solo layout label"),
|
|
505
575
|
classNames: buttonClassNames,
|
|
506
576
|
onClick: () => onClick?.("solo"),
|
|
507
577
|
icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
|
|
508
|
-
}), !isSolo && can.solo && /* @__PURE__ */
|
|
578
|
+
}), !isSolo && can.solo && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
509
579
|
label: t("increment start label"),
|
|
510
580
|
disabled: !can.incrementStart,
|
|
511
581
|
classNames: buttonClassNames,
|
|
512
582
|
onClick: () => onClick?.("increment-start"),
|
|
513
583
|
icon: "ph--caret-left--regular"
|
|
514
|
-
}), /* @__PURE__ */
|
|
584
|
+
}), /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
515
585
|
label: t("increment end label"),
|
|
516
586
|
disabled: !can.incrementEnd,
|
|
517
587
|
classNames: buttonClassNames,
|
|
@@ -520,12 +590,12 @@ var LayoutControls = /* @__PURE__ */ (0, import_react9.forwardRef)(({ onClick, v
|
|
|
520
590
|
})), pin && !isSolo && [
|
|
521
591
|
"both",
|
|
522
592
|
"end"
|
|
523
|
-
].includes(pin) && /* @__PURE__ */
|
|
593
|
+
].includes(pin) && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
524
594
|
label: t("pin end label"),
|
|
525
595
|
classNames: buttonClassNames,
|
|
526
596
|
onClick: () => onClick?.("pin-end"),
|
|
527
597
|
icon: "ph--caret-line-right--regular"
|
|
528
|
-
}), close && !isSolo && /* @__PURE__ */
|
|
598
|
+
}), close && !isSolo && /* @__PURE__ */ import_react10.default.createElement(LayoutControl, {
|
|
529
599
|
label: t(`${typeof close === "string" ? "minify" : "close"} label`),
|
|
530
600
|
classNames: buttonClassNames,
|
|
531
601
|
onClick: () => onClick?.("close"),
|
|
@@ -542,8 +612,11 @@ var LayoutControls = /* @__PURE__ */ (0, import_react9.forwardRef)(({ onClick, v
|
|
|
542
612
|
Stack,
|
|
543
613
|
StackContext,
|
|
544
614
|
StackItem,
|
|
615
|
+
StackItemContext,
|
|
545
616
|
railGridHorizontal,
|
|
546
617
|
railGridVertical,
|
|
547
|
-
translations
|
|
618
|
+
translations,
|
|
619
|
+
useStack,
|
|
620
|
+
useStackItem
|
|
548
621
|
});
|
|
549
622
|
//# sourceMappingURL=index.cjs.map
|