@dxos/react-ui-stack 0.6.14-staging.9e90729 → 0.6.14-staging.c117501

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.
Files changed (91) hide show
  1. package/dist/lib/browser/index.mjs +494 -335
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs +3 -6
  5. package/dist/lib/browser/testing/index.mjs.map +3 -3
  6. package/dist/lib/node/index.cjs +478 -326
  7. package/dist/lib/node/index.cjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node/testing/index.cjs +3 -6
  10. package/dist/lib/node/testing/index.cjs.map +3 -3
  11. package/dist/lib/node-esm/index.mjs +494 -335
  12. package/dist/lib/node-esm/index.mjs.map +4 -4
  13. package/dist/lib/node-esm/meta.json +1 -1
  14. package/dist/lib/node-esm/testing/index.mjs +3 -6
  15. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  16. package/dist/types/src/components/LayoutControls.d.ts +19 -0
  17. package/dist/types/src/components/LayoutControls.d.ts.map +1 -0
  18. package/dist/types/src/components/MenuSignifier.d.ts +4 -0
  19. package/dist/types/src/components/MenuSignifier.d.ts.map +1 -0
  20. package/dist/types/src/components/Stack.d.ts +12 -12
  21. package/dist/types/src/components/Stack.d.ts.map +1 -1
  22. package/dist/types/src/components/Stack.stories.d.ts +6 -83
  23. package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/StackContext.d.ts +19 -0
  25. package/dist/types/src/components/StackContext.d.ts.map +1 -0
  26. package/dist/types/src/components/StackItem.d.ts +41 -0
  27. package/dist/types/src/components/StackItem.d.ts.map +1 -0
  28. package/dist/types/src/components/StackItemContent.d.ts +9 -0
  29. package/dist/types/src/components/StackItemContent.d.ts.map +1 -0
  30. package/dist/types/src/components/StackItemHeading.d.ts +8 -0
  31. package/dist/types/src/components/StackItemHeading.d.ts.map +1 -0
  32. package/dist/types/src/components/StackItemResizeHandle.d.ts +3 -0
  33. package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -0
  34. package/dist/types/src/components/StackItemSigil.d.ts +31 -0
  35. package/dist/types/src/components/StackItemSigil.d.ts.map +1 -0
  36. package/dist/types/src/components/index.d.ts +2 -1
  37. package/dist/types/src/components/index.d.ts.map +1 -1
  38. package/dist/types/src/testing/EditorContent.d.ts +2 -2
  39. package/dist/types/src/testing/EditorContent.d.ts.map +1 -1
  40. package/dist/types/src/testing/stack-manager.d.ts +0 -1
  41. package/dist/types/src/testing/stack-manager.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +8 -8
  43. package/package.json +19 -20
  44. package/src/components/LayoutControls.tsx +131 -0
  45. package/src/components/MenuSignifier.tsx +33 -0
  46. package/src/components/Stack.stories.tsx +109 -182
  47. package/src/components/Stack.tsx +61 -156
  48. package/src/components/StackContext.tsx +38 -0
  49. package/src/components/StackItem.tsx +173 -0
  50. package/src/components/StackItemContent.tsx +49 -0
  51. package/src/components/StackItemHeading.tsx +55 -0
  52. package/src/components/StackItemResizeHandle.tsx +115 -0
  53. package/src/components/StackItemSigil.tsx +170 -0
  54. package/src/components/index.ts +3 -2
  55. package/src/playwright/smoke.spec.ts +3 -3
  56. package/src/testing/EditorContent.tsx +4 -4
  57. package/src/testing/stack-manager.ts +3 -7
  58. package/src/translations.ts +8 -8
  59. package/dist/types/src/components/CaretDownUp.d.ts +0 -4
  60. package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
  61. package/dist/types/src/components/ContentTypes.stories.d.ts +0 -96
  62. package/dist/types/src/components/ContentTypes.stories.d.ts.map +0 -1
  63. package/dist/types/src/components/Deck.stories.d.ts +0 -19
  64. package/dist/types/src/components/Deck.stories.d.ts.map +0 -1
  65. package/dist/types/src/components/Section.d.ts +0 -53
  66. package/dist/types/src/components/Section.d.ts.map +0 -1
  67. package/dist/types/src/components/Section.stories.d.ts +0 -36
  68. package/dist/types/src/components/Section.stories.d.ts.map +0 -1
  69. package/dist/types/src/components/style-fragments.d.ts +0 -2
  70. package/dist/types/src/components/style-fragments.d.ts.map +0 -1
  71. package/dist/types/src/next/Stack.d.ts +0 -9
  72. package/dist/types/src/next/Stack.d.ts.map +0 -1
  73. package/dist/types/src/next/Stack.stories.d.ts +0 -8
  74. package/dist/types/src/next/Stack.stories.d.ts.map +0 -1
  75. package/dist/types/src/next/StackItem.d.ts +0 -14
  76. package/dist/types/src/next/StackItem.d.ts.map +0 -1
  77. package/dist/types/src/next/index.d.ts +0 -2
  78. package/dist/types/src/next/index.d.ts.map +0 -1
  79. package/dist/types/src/testing/TableContent.d.ts +0 -20
  80. package/dist/types/src/testing/TableContent.d.ts.map +0 -1
  81. package/src/components/CaretDownUp.tsx +0 -31
  82. package/src/components/ContentTypes.stories.tsx +0 -104
  83. package/src/components/Deck.stories.tsx +0 -362
  84. package/src/components/Section.stories.tsx +0 -50
  85. package/src/components/Section.tsx +0 -378
  86. package/src/components/style-fragments.ts +0 -5
  87. package/src/next/Stack.stories.tsx +0 -148
  88. package/src/next/Stack.tsx +0 -30
  89. package/src/next/StackItem.tsx +0 -78
  90. package/src/next/index.ts +0 -5
  91. package/src/testing/TableContent.tsx +0 -119
@@ -1,54 +1,226 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // packages/ui/react-ui-stack/src/components/Stack.tsx
4
- import { useArrowNavigationGroup, useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
5
- import React3, { forwardRef as forwardRef2, useCallback } from "react";
6
- import { useResizeDetector } from "react-resize-detector";
7
- import { List as List2, useTranslation as useTranslation2 } from "@dxos/react-ui";
8
- import { Mosaic, Path, useContainer, useItemsWithPreview, useMosaic as useMosaic2 } from "@dxos/react-ui-mosaic";
9
- import { dropRingInner } from "@dxos/react-ui-theme";
4
+ import { useArrowNavigationGroup } from "@fluentui/react-tabster";
5
+ import React, { Children, forwardRef } from "react";
6
+ import { mx } from "@dxos/react-ui-theme";
10
7
 
11
- // packages/ui/react-ui-stack/src/components/Section.tsx
12
- import { useFocusableGroup, useTabsterAttributes } from "@fluentui/react-tabster";
13
- import { ArrowLineDown, ArrowLineUp, ArrowSquareOut, CaretUpDown, Trash } from "@phosphor-icons/react";
14
- import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
15
- import React2, { forwardRef, useState } from "react";
16
- import { Button, DropdownMenu, Icon, List, ListItem, ScrollArea, Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
17
- import { useAttendableAttributes } from "@dxos/react-ui-attention";
18
- import { DropDownMenuDragHandleTrigger, resizeHandle, resizeHandleHorizontal } from "@dxos/react-ui-deck";
19
- import { useMosaic } from "@dxos/react-ui-mosaic";
20
- import { focusRing, getSize, hoverableControlItem, hoverableControls, hoverableFocusedWithinControls, mx } from "@dxos/react-ui-theme";
8
+ // packages/ui/react-ui-stack/src/components/StackContext.tsx
9
+ import { createContext, useContext } from "react";
10
+ var StackContext = /* @__PURE__ */ createContext({
11
+ orientation: "vertical",
12
+ rail: true,
13
+ size: "intrinsic",
14
+ separators: true
15
+ });
16
+ var useStack = () => useContext(StackContext);
17
+ var StackItemContext = /* @__PURE__ */ createContext({
18
+ selfDragHandleRef: () => {
19
+ },
20
+ size: "min-content",
21
+ setSize: () => {
22
+ }
23
+ });
24
+ var useStackItem = () => useContext(StackItemContext);
21
25
 
22
- // packages/ui/react-ui-stack/src/components/CaretDownUp.tsx
23
- import React from "react";
24
- var CaretDownUp = ({ children, weight, ...props }) => {
25
- return /* @__PURE__ */ React.createElement("svg", {
26
+ // packages/ui/react-ui-stack/src/components/Stack.tsx
27
+ var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
28
+ var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
29
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, separators = true, size = "intrinsic", itemsCount = Children.count(children), ...props }, forwardedRef) => {
30
+ const arrowNavigationGroup = useArrowNavigationGroup({
31
+ axis: orientation
32
+ });
33
+ const styles = {
34
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
35
+ ...style
36
+ };
37
+ return /* @__PURE__ */ React.createElement(StackContext.Provider, {
38
+ value: {
39
+ orientation,
40
+ rail,
41
+ size,
42
+ separators
43
+ }
44
+ }, /* @__PURE__ */ React.createElement("div", {
45
+ ...props,
46
+ ...arrowNavigationGroup,
47
+ className: 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"), separators && (orientation === "horizontal" ? "divide-separator divide-x" : "divide-separator divide-y"), classNames),
48
+ "aria-orientation": orientation,
49
+ style: styles,
50
+ ref: forwardedRef
51
+ }, children));
52
+ });
53
+
54
+ // packages/ui/react-ui-stack/src/components/StackItem.tsx
55
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
56
+ import { draggable as draggable2, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
57
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
58
+ import { DropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
59
+ import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
60
+ import { composeRefs } from "@radix-ui/react-compose-refs";
61
+ import React7, { forwardRef as forwardRef4, useLayoutEffect as useLayoutEffect2, useState as useState2, useCallback } from "react";
62
+ import { mx as mx6 } from "@dxos/react-ui-theme";
63
+
64
+ // packages/ui/react-ui-stack/src/components/StackItemContent.tsx
65
+ import React2 from "react";
66
+ import { mx as mx2 } from "@dxos/react-ui-theme";
67
+ var StackItemContent = ({ children, toolbar = true, statusbar, contentSize = "cover", classNames, ...props }) => {
68
+ const { size, separators } = useStack();
69
+ return /* @__PURE__ */ React2.createElement("div", {
70
+ role: "none",
71
+ ...props,
72
+ className: mx2("group grid grid-cols-[100%]", size === "contain" && "min-bs-0 overflow-hidden", separators && "divide-separator divide-y", classNames),
73
+ style: {
74
+ gridTemplateRows: [
75
+ ...toolbar ? [
76
+ "var(--rail-action)"
77
+ ] : [],
78
+ "1fr",
79
+ ...statusbar ? [
80
+ "var(--statusbar-size)"
81
+ ] : []
82
+ ].join(" ")
83
+ }
84
+ }, children);
85
+ };
86
+
87
+ // packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
88
+ import { useFocusableGroup } from "@fluentui/react-tabster";
89
+ import React3, { forwardRef as forwardRef2 } from "react";
90
+ import { useAttention } from "@dxos/react-ui-attention";
91
+ import { mx as mx3 } from "@dxos/react-ui-theme";
92
+ var StackItemHeading = ({ children, classNames, ...props }) => {
93
+ const { orientation } = useStack();
94
+ const { selfDragHandleRef } = useStackItem();
95
+ const focusableGroupAttrs = useFocusableGroup({
96
+ tabBehavior: "limited"
97
+ });
98
+ return /* @__PURE__ */ React3.createElement("div", {
99
+ role: "heading",
100
+ ...props,
101
+ tabIndex: 0,
102
+ ...focusableGroupAttrs,
103
+ className: mx3("flex items-center ch-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames),
104
+ ref: selfDragHandleRef
105
+ }, children);
106
+ };
107
+ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef2(({ attendableId, related, classNames, ...props }, forwardedRef) => {
108
+ const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
109
+ return /* @__PURE__ */ React3.createElement("h1", {
110
+ ...props,
111
+ "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
112
+ className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
113
+ ref: forwardedRef
114
+ });
115
+ });
116
+
117
+ // packages/ui/react-ui-stack/src/components/StackItemResizeHandle.tsx
118
+ import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
119
+ import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
120
+ import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
121
+ import React4, { useLayoutEffect, useRef } from "react";
122
+ import { mx as mx4 } from "@dxos/react-ui-theme";
123
+ var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
124
+ var MIN_SIZE = 20;
125
+ var measureStackItem = (element) => {
126
+ const stackItemElement = element.closest("[data-dx-stack-item]");
127
+ return stackItemElement?.getBoundingClientRect() ?? {
128
+ width: DEFAULT_EXTRINSIC_SIZE,
129
+ height: DEFAULT_EXTRINSIC_SIZE
130
+ };
131
+ };
132
+ var getNextSize = (startSize, location, client) => {
133
+ return Math.max(MIN_SIZE, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
134
+ };
135
+ var StackItemResizeHandle = () => {
136
+ const { orientation } = useStack();
137
+ const { setSize, size } = useStackItem();
138
+ const buttonRef = useRef(null);
139
+ const dragStartSize = useRef(size);
140
+ const client = orientation === "horizontal" ? "clientX" : "clientY";
141
+ useLayoutEffect(() => {
142
+ if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
143
+ return;
144
+ }
145
+ draggable({
146
+ element: buttonRef.current,
147
+ onGenerateDragPreview: ({ nativeSetDragImage }) => {
148
+ disableNativeDragPreview({
149
+ nativeSetDragImage
150
+ });
151
+ preventUnhandled.start();
152
+ },
153
+ onDragStart: () => {
154
+ dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
155
+ },
156
+ onDrag: ({ location }) => {
157
+ if (typeof dragStartSize.current !== "number") {
158
+ return;
159
+ }
160
+ setSize(getNextSize(dragStartSize.current, location, client));
161
+ },
162
+ onDrop: ({ location }) => {
163
+ if (typeof dragStartSize.current !== "number") {
164
+ return;
165
+ }
166
+ const nextSize = getNextSize(dragStartSize.current, location, client);
167
+ setSize(nextSize, true);
168
+ dragStartSize.current = nextSize;
169
+ }
170
+ });
171
+ }, []);
172
+ return /* @__PURE__ */ React4.createElement("button", {
173
+ ref: buttonRef,
174
+ className: mx4(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")
175
+ }, /* @__PURE__ */ React4.createElement("div", {
176
+ role: "none",
177
+ 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"
178
+ }, /* @__PURE__ */ React4.createElement(DragHandleSignifier, null)));
179
+ };
180
+ var DragHandleSignifier = () => {
181
+ return /* @__PURE__ */ React4.createElement("svg", {
26
182
  xmlns: "http://www.w3.org/2000/svg",
27
183
  viewBox: "0 0 256 256",
28
- ...props
29
- }, /* @__PURE__ */ React.createElement("rect", {
30
- width: "256",
31
- height: "256",
32
- fill: "none"
33
- }), /* @__PURE__ */ React.createElement("polyline", {
34
- points: "80 224 128 176 176 224",
35
- fill: "none",
36
- stroke: "currentColor",
37
- strokeLinecap: "round",
38
- strokeLinejoin: "round",
39
- strokeWidth: "16"
40
- }), /* @__PURE__ */ React.createElement("polyline", {
41
- points: "80 32 128 80 176 32",
42
- fill: "none",
43
- stroke: "currentColor",
44
- strokeLinecap: "round",
45
- strokeLinejoin: "round",
46
- strokeWidth: "16"
47
- }), children);
184
+ fill: "currentColor",
185
+ className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
186
+ }, /* @__PURE__ */ React4.createElement("path", {
187
+ d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
188
+ }), /* @__PURE__ */ React4.createElement("path", {
189
+ d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
190
+ }), /* @__PURE__ */ React4.createElement("path", {
191
+ d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
192
+ }), /* @__PURE__ */ React4.createElement("path", {
193
+ d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
194
+ }));
48
195
  };
49
196
 
50
- // packages/ui/react-ui-stack/src/components/style-fragments.ts
51
- var stackColumns = "grid-cols-[var(--rail-size)_calc(100%-var(--rail-size))]";
197
+ // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
198
+ import React6, { Fragment, forwardRef as forwardRef3, useRef as useRef2, useState } from "react";
199
+ import { keySymbols } from "@dxos/keyboard";
200
+ import { Button, DropdownMenu, Icon, toLocalizedString, Tooltip, useTranslation } from "@dxos/react-ui";
201
+ import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
202
+ import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
203
+ import { getHostPlatform } from "@dxos/util";
204
+
205
+ // packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
206
+ import React5 from "react";
207
+ var MenuSignifierHorizontal = () => /* @__PURE__ */ React5.createElement("svg", {
208
+ className: "absolute block-end-[7px]",
209
+ width: 20,
210
+ height: 2,
211
+ viewBox: "0 0 20 2",
212
+ stroke: "currentColor",
213
+ opacity: 0.5
214
+ }, /* @__PURE__ */ React5.createElement("line", {
215
+ x1: 0.5,
216
+ y1: 0.75,
217
+ x2: 19,
218
+ y2: 0.75,
219
+ strokeWidth: 1.25,
220
+ strokeLinecap: "round",
221
+ strokeDasharray: "6 20",
222
+ strokeDashoffset: "-6.5"
223
+ }));
52
224
 
53
225
  // packages/ui/react-ui-stack/src/translations.ts
54
226
  var translationKey = "stack";
@@ -56,323 +228,310 @@ var translations_default = [
56
228
  {
57
229
  "en-US": {
58
230
  [translationKey]: {
59
- "empty stack message": "Drag items into the stack.",
60
- "remove section label": "Delete",
61
- "navigate to section label": "Navigate to item",
62
- "untitled section title": "Untitled section",
63
- "add section before label": "Add before",
64
- "add section after label": "Add after",
65
- "expand label": "Expand",
66
- "collapse label": "Collapse"
231
+ "resize label": "Drag to resize",
232
+ "pin start label": "Pin to the left sidebar",
233
+ "pin end label": "Pin to the right sidebar",
234
+ "increment start label": "Move to the left",
235
+ "increment end label": "Move to the right",
236
+ "solo plank label": "Toggle solo mode",
237
+ "close label": "Close",
238
+ "minify label": "Minify"
67
239
  }
68
240
  }
69
241
  }
70
242
  ];
71
243
 
72
- // packages/ui/react-ui-stack/src/components/Section.tsx
73
- var sectionActionDimensions = "p-1 shrink-0 min-bs-0 is-[--rail-action] bs-min";
74
- var resizeHandleStyles = mx(resizeHandle, resizeHandleHorizontal, "is-full bs-[--rail-action] col-start-2");
75
- var Section = /* @__PURE__ */ forwardRef(({ id, title, icon = "ph--placeholder--regular", size = "intrinsic", collapsed, active, isResizable, draggableProps, draggableStyle, onDelete, onNavigate, onAddBefore, onAddAfter, onCollapseSection, children }, forwardedRef) => {
244
+ // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
245
+ var StackItemSigilButton = /* @__PURE__ */ forwardRef3(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
246
+ const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
247
+ const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
248
+ return /* @__PURE__ */ React6.createElement(Button, {
249
+ ...props,
250
+ variant,
251
+ classNames: [
252
+ "m-1 shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative",
253
+ classNames
254
+ ],
255
+ ref: forwardedRef
256
+ }, /* @__PURE__ */ React6.createElement(MenuSignifierHorizontal, null), children);
257
+ });
258
+ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
76
259
  const { t } = useTranslation(translationKey);
260
+ const suppressNextTooltip = useRef2(false);
77
261
  const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
78
- const sectionActionsToolbar = useTabsterAttributes({
79
- groupper: {},
80
- focusable: {},
81
- mover: {
82
- cyclic: true,
83
- direction: 1,
84
- memorizeCurrent: false
262
+ const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
263
+ return /* @__PURE__ */ React6.createElement(Tooltip.Root, {
264
+ open: triggerTooltipOpen,
265
+ onOpenChange: (nextOpen) => {
266
+ if (suppressNextTooltip.current) {
267
+ setTriggerTooltipOpen(false);
268
+ suppressNextTooltip.current = false;
269
+ } else {
270
+ setTriggerTooltipOpen(nextOpen);
271
+ }
85
272
  }
86
- });
87
- const sectionContentGroup = useFocusableGroup({});
88
- const attendableAttrs = useAttendableAttributes(id);
89
- return /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Root, {
90
- asChild: true,
91
- open: !collapsed,
92
- onOpenChange: (nextOpen) => onCollapseSection?.(id, !nextOpen)
93
- }, /* @__PURE__ */ React2.createElement(ListItem.Root, {
94
- ref: forwardedRef,
95
- id,
96
- ...attendableAttrs,
97
- classNames: [
98
- "grid col-span-2 group/section",
99
- active === "overlay" ? stackColumns : "grid-cols-subgrid snap-start"
100
- ],
101
- style: draggableStyle
102
- }, /* @__PURE__ */ React2.createElement("div", {
103
- role: "none",
104
- className: mx("grid col-span-2 grid-cols-subgrid", "bg-base attention-surface", hoverableControls, hoverableFocusedWithinControls, (active === "origin" || active === "rearrange" || active === "destination") && "opacity-0")
105
- }, /* @__PURE__ */ React2.createElement("div", {
106
- role: "toolbar",
107
- "aria-orientation": "vertical",
108
- "aria-label": t("section controls label"),
109
- ...!active && {
110
- tabIndex: 0
111
- },
112
- ...!active && sectionActionsToolbar,
113
- className: mx("grid grid-cols-subgrid ch-focus-ring rounded-sm grid-rows-[min-content_min-content_1fr] m-1", "group-has-[[role=toolbar][aria-orientation=horizontal]]/section:pbs-[--rail-action]")
114
- }, /* @__PURE__ */ React2.createElement("div", {
115
- role: "none",
116
- className: "sticky -block-start-px bg-[--sticky-bg]"
117
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Root, {
273
+ }, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
118
274
  open: optionsMenuOpen,
119
- onOpenChange: setOptionsMenuOpen
120
- }, /* @__PURE__ */ React2.createElement(DropDownMenuDragHandleTrigger, {
121
- active: !!active,
122
- variant: "ghost",
123
- classNames: "m-0",
124
- ...draggableProps
125
- }, /* @__PURE__ */ React2.createElement(Icon, {
126
- icon,
127
- size: 5,
128
- classNames: "transition-opacity"
129
- })), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, collapsed ? /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
130
- onClick: onNavigate,
131
- "data-testid": "section.navigate-to"
132
- }, /* @__PURE__ */ React2.createElement(ArrowSquareOut, {
133
- className: mx(getSize(5), "mr-2")
134
- }), /* @__PURE__ */ React2.createElement("span", {
135
- className: "grow"
136
- }, t("navigate to section label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
137
- asChild: true
138
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React2.createElement(CaretDownUp, {
139
- className: mx(getSize(5), "mr-2")
140
- }), /* @__PURE__ */ React2.createElement("span", {
141
- className: "grow"
142
- }, t("collapse label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
143
- onClick: onAddBefore,
144
- "data-testid": "section.add-before"
145
- }, /* @__PURE__ */ React2.createElement(ArrowLineUp, {
146
- className: mx(getSize(5), "mr-2")
147
- }), /* @__PURE__ */ React2.createElement("span", {
148
- className: "grow"
149
- }, t("add section before label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
150
- onClick: onAddAfter,
151
- "data-testid": "section.add-after"
152
- }, /* @__PURE__ */ React2.createElement(ArrowLineDown, {
153
- className: mx(getSize(5), "mr-2")
154
- }), /* @__PURE__ */ React2.createElement("span", {
155
- className: "grow"
156
- }, t("add section after label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
157
- onClick: () => onDelete?.(),
158
- "data-testid": "section.remove"
159
- }, /* @__PURE__ */ React2.createElement(Trash, {
160
- className: mx(getSize(5), "mr-2")
161
- }), /* @__PURE__ */ React2.createElement("span", {
162
- className: "grow"
163
- }, t("remove section label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
164
- asChild: true
165
- }, /* @__PURE__ */ React2.createElement(Button, {
166
- variant: "ghost",
167
- classNames: sectionActionDimensions
168
- }, /* @__PURE__ */ React2.createElement("span", {
169
- className: "sr-only"
170
- }, t("expand label")), /* @__PURE__ */ React2.createElement(CaretUpDown, {
171
- className: getSize(4)
172
- }))) : /* @__PURE__ */ React2.createElement(Button, {
173
- variant: "ghost",
174
- classNames: sectionActionDimensions,
175
- onClick: onNavigate,
176
- "data-testid": "section.navigate-to"
177
- }, /* @__PURE__ */ React2.createElement(ArrowSquareOut, {
178
- className: mx(getSize(4))
179
- }), /* @__PURE__ */ React2.createElement("span", {
180
- className: "sr-only"
181
- }, t("navigate to section label"))))), /* @__PURE__ */ React2.createElement(ListItem.Heading, {
182
- classNames: collapsed ? [
183
- "grid grid-rows-subgrid grid-cols-subgrid items-center",
184
- focusRing
185
- ] : "sr-only",
186
- ...collapsed && {
187
- ...sectionContentGroup,
188
- tabIndex: 0
275
+ onOpenChange: (nextOpen) => {
276
+ if (!nextOpen) {
277
+ suppressNextTooltip.current = true;
278
+ }
279
+ return setOptionsMenuOpen(nextOpen);
189
280
  }
190
- }, /* @__PURE__ */ React2.createElement("span", {
191
- className: "truncate"
192
- }, title)), size === "intrinsic" ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, {
193
- ...!collapsed && {
194
- ...sectionContentGroup,
195
- tabIndex: 0
196
- },
197
- // TODO(burdon): Add margin to fragment?
198
- className: mx(focusRing, "m-[2px]")
199
- }, children) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, {
281
+ }, /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
200
282
  asChild: true
201
- }, /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
202
- type: "always",
203
- ...!collapsed && {
204
- ...sectionContentGroup,
205
- tabIndex: 0
206
- },
207
- classNames: mx(focusRing, "is-full has-[[data-radix-scroll-area-viewport]]:pbe-4")
208
- }, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, null, children), /* @__PURE__ */ React2.createElement(ScrollArea.Scrollbar, {
209
- orientation: "horizontal",
210
- variant: "coarse",
211
- classNames: "hidden has-[div]:flex !inline-end-[max(.25rem,var(--radix-scroll-area-corner-width))]"
212
- }, /* @__PURE__ */ React2.createElement(ScrollArea.Thumb, null)), /* @__PURE__ */ React2.createElement(ScrollArea.Scrollbar, {
213
- orientation: "vertical",
214
- variant: "coarse",
215
- classNames: "hidden has-[div]:flex"
216
- }, /* @__PURE__ */ React2.createElement(ScrollArea.Thumb, null)), /* @__PURE__ */ React2.createElement(ScrollArea.Corner, null)))), isResizable && !collapsed && /* @__PURE__ */ React2.createElement("button", {
217
- className: resizeHandleStyles
218
- }, /* @__PURE__ */ React2.createElement("span", {
283
+ }, /* @__PURE__ */ React6.createElement(DropdownMenu.Trigger, {
284
+ asChild: true,
285
+ ref: forwardedRef
286
+ }, /* @__PURE__ */ React6.createElement(StackItemSigilButton, {
287
+ attendableId,
288
+ related
289
+ }, /* @__PURE__ */ React6.createElement("span", {
219
290
  className: "sr-only"
220
- }, t("resize section label")))));
221
- });
222
- var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
223
- var SectionToolbar = ({ children, classNames }) => {
224
- return /* @__PURE__ */ React2.createElement(Toolbar.Root, {
225
- orientation: "horizontal",
226
- classNames: [
227
- sectionToolbarLayout,
228
- hoverableControlItem,
229
- classNames
230
- ]
231
- }, children);
232
- };
233
- var SectionTile = /* @__PURE__ */ forwardRef(({ path, type, active, draggableStyle, draggableProps, item, itemContext }, forwardedRef) => {
234
- const { t } = useTranslation(translationKey);
235
- const { activeItem } = useMosaic();
236
- const separation = !!itemContext?.separation;
237
- const isResizable = !!itemContext?.isResizable;
238
- const { transform, onDeleteSection, onNavigateToSection, onAddSection, onCollapseSection, SectionContent } = itemContext;
239
- const transformedItem = transform ? transform(
240
- item,
241
- // TODO(wittjosiah): `active` doesn't always seem to be accurate here.
242
- activeItem?.item.id === item.id ? activeItem?.type : type
243
- ) : item;
244
- const placeholder = transformedItem.metadata?.placeholder ?? [
245
- "untitled section title",
246
- {
247
- ns: translationKey
248
- }
249
- ];
250
- const title = transformedItem.view?.title ?? toLocalizedString(placeholder, t);
251
- const section = /* @__PURE__ */ React2.createElement(Section, {
252
- ref: forwardedRef,
253
- title,
254
- id: transformedItem.id,
255
- size: transformedItem.view?.size,
256
- icon: transformedItem.metadata?.icon,
257
- collapsed: transformedItem.view?.collapsed,
258
- separation,
259
- active,
260
- draggableProps,
261
- draggableStyle,
262
- onCollapseSection,
263
- isResizable,
264
- onDelete: () => onDeleteSection?.(path),
265
- onNavigate: () => onNavigateToSection?.(transformedItem),
266
- onAddAfter: () => onAddSection?.(path, "after"),
267
- onAddBefore: () => onAddSection?.(path, "before")
268
- }, SectionContent && /* @__PURE__ */ React2.createElement(SectionContent, {
269
- data: transformedItem.object
270
- }));
271
- return active === "overlay" ? /* @__PURE__ */ React2.createElement(List, null, section) : section;
291
+ }, triggerLabel), /* @__PURE__ */ React6.createElement(Icon, {
292
+ icon,
293
+ size: 5
294
+ })))), /* @__PURE__ */ React6.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React6.createElement(DropdownMenu.Content, {
295
+ classNames: "z-[31]"
296
+ }, /* @__PURE__ */ React6.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
297
+ const separator = index > 0 ? /* @__PURE__ */ React6.createElement(DropdownMenu.Separator, null) : null;
298
+ return /* @__PURE__ */ React6.createElement(Fragment, {
299
+ key: index
300
+ }, separator, actions.map((action) => {
301
+ const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
302
+ const menuItemType = action.properties.menuItemType;
303
+ const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
304
+ return /* @__PURE__ */ React6.createElement(Root, {
305
+ key: action.id,
306
+ onClick: (event) => {
307
+ if (action.properties.disabled) {
308
+ return;
309
+ }
310
+ event.stopPropagation();
311
+ suppressNextTooltip.current = true;
312
+ setOptionsMenuOpen(false);
313
+ onAction?.(action);
314
+ },
315
+ classNames: "gap-2",
316
+ disabled: action.properties.disabled,
317
+ checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
318
+ ...action.properties?.testId && {
319
+ "data-testid": action.properties.testId
320
+ }
321
+ }, /* @__PURE__ */ React6.createElement(Icon, {
322
+ icon: action.properties.icon ?? "ph--placeholder--regular",
323
+ size: 4
324
+ }), /* @__PURE__ */ React6.createElement("span", {
325
+ className: "grow truncate"
326
+ }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React6.createElement(DropdownMenu.ItemIndicator, {
327
+ asChild: true
328
+ }, /* @__PURE__ */ React6.createElement(Icon, {
329
+ icon: "ph--check--regular",
330
+ size: 4
331
+ })), shortcut && /* @__PURE__ */ React6.createElement("span", {
332
+ className: mx5("shrink-0", descriptionText)
333
+ }, keySymbols(shortcut).join("")));
334
+ }));
335
+ }), children), /* @__PURE__ */ React6.createElement(DropdownMenu.Arrow, null)))), /* @__PURE__ */ React6.createElement(Tooltip.Portal, null, /* @__PURE__ */ React6.createElement(Tooltip.Content, {
336
+ style: {
337
+ zIndex: 70
338
+ },
339
+ side: "bottom"
340
+ }, triggerLabel, /* @__PURE__ */ React6.createElement(Tooltip.Arrow, null))));
272
341
  });
273
342
 
274
- // packages/ui/react-ui-stack/src/components/Stack.tsx
275
- var DEFAULT_TYPE = "stack-section";
276
- var Stack = ({ id, type = DEFAULT_TYPE, SectionContent, items = [], separation = true, transform, onOver, onDrop, onAddSection, onDeleteSection, onNavigateToSection, onCollapseSection, ...props }) => {
277
- const { ref: containerRef, width = 0 } = useResizeDetector({
278
- refreshRate: 200
279
- });
280
- const { operation, overItem } = useMosaic2();
281
- const itemsWithPreview = useItemsWithPreview({
282
- path: id,
283
- items
284
- });
285
- const getOverlayStyle = useCallback(() => ({
286
- width
287
- }), [
288
- width
343
+ // packages/ui/react-ui-stack/src/components/StackItem.tsx
344
+ var DEFAULT_HORIZONTAL_SIZE = 44;
345
+ var DEFAULT_VERTICAL_SIZE = "min-content";
346
+ var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
347
+ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, onRearrange, size: propsSize, onSizeChange, role, order, style, ...props }, forwardedRef) => {
348
+ const [itemElement, itemRef] = useState2(null);
349
+ const [selfDragHandleElement, selfDragHandleRef] = useState2(null);
350
+ const [closestEdge, setEdge] = useState2(null);
351
+ const { orientation, rail, separators } = useStack();
352
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState2(propsSize);
353
+ const Root = role ?? "div";
354
+ const composedItemRef = composeRefs(itemRef, forwardedRef);
355
+ const setSize = useCallback((nextSize, commit) => {
356
+ setInternalSize(nextSize);
357
+ if (commit) {
358
+ onSizeChange?.(nextSize);
359
+ }
360
+ }, [
361
+ onSizeChange
289
362
  ]);
290
- const getOverlayProps = useCallback(() => ({
291
- itemContext: {
292
- transform,
293
- SectionContent
363
+ const type = orientation === "horizontal" ? "column" : "card";
364
+ useLayoutEffect2(() => {
365
+ if (!itemElement || !onRearrange) {
366
+ return;
294
367
  }
295
- }), [
296
- transform,
297
- SectionContent
368
+ return combine(draggable2({
369
+ element: itemElement,
370
+ ...selfDragHandleElement && {
371
+ dragHandle: selfDragHandleElement
372
+ },
373
+ getInitialData: () => ({
374
+ id: item.id,
375
+ type
376
+ })
377
+ }), dropTargetForElements({
378
+ element: itemElement,
379
+ getData: ({ input, element }) => {
380
+ return attachClosestEdge({
381
+ id: item.id,
382
+ type
383
+ }, {
384
+ input,
385
+ element,
386
+ allowedEdges: orientation === "horizontal" ? [
387
+ "left",
388
+ "right"
389
+ ] : [
390
+ "top",
391
+ "bottom"
392
+ ]
393
+ });
394
+ },
395
+ onDragEnter: ({ self, source }) => {
396
+ if (source.data.type === self.data.type) {
397
+ setEdge(extractClosestEdge(self.data));
398
+ }
399
+ },
400
+ onDrag: ({ self, source }) => {
401
+ if (source.data.type === self.data.type) {
402
+ setEdge(extractClosestEdge(self.data));
403
+ }
404
+ },
405
+ onDragLeave: () => setEdge(null),
406
+ onDrop: ({ self, source }) => {
407
+ setEdge(null);
408
+ if (source.data.type === self.data.type) {
409
+ onRearrange(source.data, self.data, extractClosestEdge(self.data));
410
+ }
411
+ }
412
+ }));
413
+ }, [
414
+ orientation,
415
+ item,
416
+ onRearrange,
417
+ selfDragHandleElement,
418
+ itemElement
298
419
  ]);
299
- const stackModifier = useCallback((_activeItem, { transform: transform2, activeNodeRect, overlayNodeRect }) => {
300
- if (activeNodeRect && overlayNodeRect) {
301
- transform2.y += activeNodeRect?.top - overlayNodeRect?.top;
420
+ const focusGroupAttrs = useFocusableGroup2({
421
+ tabBehavior: "limited"
422
+ });
423
+ return /* @__PURE__ */ React7.createElement(StackItemContext.Provider, {
424
+ value: {
425
+ selfDragHandleRef,
426
+ size,
427
+ setSize
302
428
  }
303
- return transform2;
304
- }, []);
305
- return /* @__PURE__ */ React3.createElement(Mosaic.Container, {
306
- id,
307
- type,
308
- Component: SectionTile,
309
- getOverlayStyle,
310
- getOverlayProps,
311
- onOver,
312
- onDrop,
313
- modifier: stackModifier
314
- }, /* @__PURE__ */ React3.createElement(Mosaic.DroppableTile, {
315
- path: id,
316
- type,
317
- item: {
318
- id,
319
- items: itemsWithPreview
320
- },
321
- // TODO(wittjosiah): Should this actually be a context?
322
- itemContext: {
323
- separation,
324
- transform,
325
- onDeleteSection,
326
- onNavigateToSection,
327
- onAddSection,
328
- onCollapseSection,
329
- SectionContent
330
- },
331
- isOver: overItem && !!overItem.path && Path.hasRoot(overItem.path, id) && (operation === "copy" || operation === "transfer"),
332
- Component: StackTile,
429
+ }, /* @__PURE__ */ React7.createElement(Root, {
333
430
  ...props,
334
- ref: containerRef
335
- }));
431
+ tabIndex: 0,
432
+ ...focusGroupAttrs,
433
+ className: mx6("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"), separators && (orientation === "horizontal" ? "divide-separator divide-y" : "divide-separator divide-x"), classNames),
434
+ "data-dx-stack-item": true,
435
+ style: {
436
+ ...size !== "min-content" && {
437
+ [orientation === "horizontal" ? "inlineSize" : "blockSize"]: `${size}rem`
438
+ },
439
+ ...Number.isFinite(order) && {
440
+ [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
441
+ },
442
+ ...style
443
+ },
444
+ ref: composedItemRef
445
+ }, children, closestEdge && /* @__PURE__ */ React7.createElement(DropIndicator, {
446
+ edge: closestEdge
447
+ })));
448
+ });
449
+ var StackItem = {
450
+ Root: StackItemRoot,
451
+ Content: StackItemContent,
452
+ Heading: StackItemHeading,
453
+ HeadingLabel: StackItemHeadingLabel,
454
+ ResizeHandle: StackItemResizeHandle,
455
+ Sigil: StackItemSigil,
456
+ SigilButton: StackItemSigilButton
336
457
  };
337
- var StackTile = /* @__PURE__ */ forwardRef2(({ classNames, path, isOver, item: { items }, itemContext, type: _type, emptyComponent, ...props }, forwardedRef) => {
338
- const { t } = useTranslation2(translationKey);
339
- const { Component, type } = useContainer();
340
- const domAttributes = useArrowNavigationGroup({
341
- axis: "grid"
342
- });
343
- const { activeItem } = useMosaic2();
344
- const _group = useFocusableGroup2();
345
- return /* @__PURE__ */ React3.createElement(List2, {
346
- ref: forwardedRef,
347
- classNames: [
348
- "grid relative",
349
- stackColumns,
350
- isOver && dropRingInner,
351
- classNames
352
- ],
353
- ...!activeItem && domAttributes,
458
+
459
+ // packages/ui/react-ui-stack/src/components/LayoutControls.tsx
460
+ import React8, { forwardRef as forwardRef5 } from "react";
461
+ import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip as Tooltip2, useTranslation as useTranslation2 } from "@dxos/react-ui";
462
+ var LayoutControl = ({ icon, label, ...props }) => {
463
+ return /* @__PURE__ */ React8.createElement(Tooltip2.Root, null, /* @__PURE__ */ React8.createElement(Tooltip2.Trigger, {
464
+ asChild: true
465
+ }, /* @__PURE__ */ React8.createElement(Button2, {
466
+ variant: "ghost",
354
467
  ...props
355
- }, items.length > 0 ? /* @__PURE__ */ React3.createElement(Mosaic.SortableContext, {
356
- items,
357
- direction: "vertical"
358
- }, items.map((item, index) => /* @__PURE__ */ React3.createElement(Mosaic.SortableTile, {
359
- key: item.id,
360
- item,
361
- itemContext,
362
- path,
363
- type,
364
- position: index,
365
- Component
366
- }))) : emptyComponent !== void 0 ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, emptyComponent) : /* @__PURE__ */ React3.createElement("p", {
367
- className: "grid col-span-2 text-center p-4 border border-dashed border-neutral-500/50 rounded",
368
- "data-testid": "stack.empty"
369
- }, t("empty stack message")));
468
+ }, /* @__PURE__ */ React8.createElement("span", {
469
+ className: "sr-only"
470
+ }, label), /* @__PURE__ */ React8.createElement(Icon2, {
471
+ icon
472
+ }))), /* @__PURE__ */ React8.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip2.Content, {
473
+ side: "bottom",
474
+ classNames: "z-[70]"
475
+ }, label)));
476
+ };
477
+ var LayoutControls = /* @__PURE__ */ forwardRef5(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
478
+ const { t } = useTranslation2(translationKey);
479
+ const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
480
+ return /* @__PURE__ */ React8.createElement(ButtonGroup, {
481
+ ...props,
482
+ ref: forwardedRef
483
+ }, pin && !isSolo && [
484
+ "both",
485
+ "start"
486
+ ].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
487
+ label: t("pin start label"),
488
+ variant: "ghost",
489
+ classNames: buttonClassNames,
490
+ onClick: () => onClick?.("pin-start"),
491
+ icon: "ph--caret-line-left--regular"
492
+ }), can.solo && /* @__PURE__ */ React8.createElement(LayoutControl, {
493
+ label: t("solo layout label"),
494
+ classNames: buttonClassNames,
495
+ onClick: () => onClick?.("solo"),
496
+ icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
497
+ }), !isSolo && can.solo && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(LayoutControl, {
498
+ label: t("increment start label"),
499
+ disabled: !can.incrementStart,
500
+ classNames: buttonClassNames,
501
+ onClick: () => onClick?.("increment-start"),
502
+ icon: "ph--caret-left--regular"
503
+ }), /* @__PURE__ */ React8.createElement(LayoutControl, {
504
+ label: t("increment end label"),
505
+ disabled: !can.incrementEnd,
506
+ classNames: buttonClassNames,
507
+ onClick: () => onClick?.("increment-end"),
508
+ icon: "ph--caret-right--regular"
509
+ })), pin && !isSolo && [
510
+ "both",
511
+ "end"
512
+ ].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
513
+ label: t("pin end label"),
514
+ classNames: buttonClassNames,
515
+ onClick: () => onClick?.("pin-end"),
516
+ icon: "ph--caret-line-right--regular"
517
+ }), close && !isSolo && /* @__PURE__ */ React8.createElement(LayoutControl, {
518
+ label: t(`${typeof close === "string" ? "minify" : "close"} label`),
519
+ classNames: buttonClassNames,
520
+ onClick: () => onClick?.("close"),
521
+ "data-testid": "layoutHeading.close",
522
+ icon: close === "minify-start" ? "ph--caret-line-left--regular" : close === "minify-end" ? "ph--caret-line-right--regular" : "ph--minus--regular"
523
+ }), children);
370
524
  });
371
525
  export {
372
- DEFAULT_TYPE,
373
- SectionToolbar,
526
+ DEFAULT_EXTRINSIC_SIZE,
527
+ DEFAULT_HORIZONTAL_SIZE,
528
+ DEFAULT_VERTICAL_SIZE,
529
+ LayoutControls,
374
530
  Stack,
375
- sectionToolbarLayout,
531
+ StackContext,
532
+ StackItem,
533
+ railGridHorizontal,
534
+ railGridVertical,
376
535
  translations_default as translations
377
536
  };
378
537
  //# sourceMappingURL=index.mjs.map