@dxos/react-ui-mosaic 0.8.4-main.bc674ce → 0.8.4-main.c85a9c8dae
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/chunk-7S4PIFKU.mjs +953 -0
- package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +596 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/playwright/index.mjs +138 -0
- package/dist/lib/browser/playwright/index.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +61 -232
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs +955 -0
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +596 -70
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/playwright/index.mjs +140 -0
- package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +61 -232
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/Board/Board.d.ts +81 -0
- package/dist/types/src/components/Board/Board.d.ts.map +1 -0
- package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +15 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
- package/dist/types/src/components/Board/Column.d.ts +40 -0
- package/dist/types/src/components/Board/Column.d.ts.map +1 -0
- package/dist/types/src/components/Board/Item.d.ts +9 -0
- package/dist/types/src/components/Board/Item.d.ts.map +1 -0
- package/dist/types/src/components/Board/index.d.ts +2 -0
- package/dist/types/src/components/Board/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +5 -4
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
- package/dist/types/src/components/Focus/index.d.ts +0 -1
- package/dist/types/src/components/Focus/index.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +42 -0
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +35 -118
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Root.d.ts +36 -0
- package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts +23 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
- package/dist/types/src/components/{Stack → Mosaic}/Stack.stories.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts +48 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/types.d.ts +9 -2
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
- package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
- package/dist/types/src/playwright/board-manager.d.ts +45 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/index.d.ts +9 -0
- package/dist/types/src/playwright/index.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +5 -4
- package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
- package/dist/types/src/testing/DefaultStackTile.d.ts +2 -2
- package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts +21 -0
- package/dist/types/src/testing/types.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -28
- package/src/components/Board/Board.stories.tsx +273 -0
- package/src/components/Board/Board.tsx +191 -0
- package/src/components/Board/Column.tsx +300 -0
- package/src/components/Board/Item.tsx +116 -0
- package/src/components/{Layout → Board}/index.ts +1 -1
- package/src/components/Focus/Focus.tsx +26 -17
- package/src/components/Focus/index.ts +0 -2
- package/src/components/Mosaic/Container.tsx +289 -0
- package/src/components/Mosaic/Mosaic.tsx +35 -913
- package/src/components/Mosaic/Placeholder.tsx +133 -0
- package/src/components/Mosaic/Root.tsx +292 -0
- package/src/components/{Stack → Mosaic}/Stack.stories.tsx +30 -26
- package/src/components/Mosaic/Stack.tsx +246 -0
- package/src/components/Mosaic/Tile.tsx +242 -0
- package/src/components/Mosaic/extension.ts +1 -1
- package/src/components/Mosaic/styles.ts +9 -8
- package/src/components/Mosaic/types.ts +15 -3
- package/src/components/index.ts +1 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useContainerDebug.tsx +4 -2
- package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
- package/src/hooks/useEventHandlerAdapter.ts +15 -6
- package/src/hooks/useVisibleItems.ts +7 -2
- package/src/playwright/board-manager.ts +154 -0
- package/src/playwright/index.ts +13 -0
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +138 -0
- package/src/testing/CardContainer.tsx +30 -18
- package/src/testing/DefaultStackTile.tsx +27 -16
- package/src/testing/index.ts +1 -1
- package/src/testing/types.ts +38 -0
- package/src/translations.ts +5 -1
- package/dist/lib/browser/chunk-UMBPEG4F.mjs +0 -1637
- package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
- package/dist/lib/browser/index.css +0 -13
- package/dist/lib/browser/index.css.map +0 -7
- package/dist/lib/browser/testing/index.css +0 -13
- package/dist/lib/browser/testing/index.css.map +0 -7
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs +0 -1639
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
- package/dist/lib/node-esm/index.css +0 -13
- package/dist/lib/node-esm/index.css.map +0 -7
- package/dist/lib/node-esm/testing/index.css +0 -13
- package/dist/lib/node-esm/testing/index.css.map +0 -7
- package/dist/types/src/components/Card/Card.d.ts +0 -121
- package/dist/types/src/components/Card/Card.d.ts.map +0 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +0 -21
- package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Card/CardDragPreview.d.ts +0 -6
- package/dist/types/src/components/Card/CardDragPreview.d.ts.map +0 -1
- package/dist/types/src/components/Card/index.d.ts +0 -4
- package/dist/types/src/components/Card/index.d.ts.map +0 -1
- package/dist/types/src/components/Card/styles.d.ts +0 -13
- package/dist/types/src/components/Card/styles.d.ts.map +0 -1
- package/dist/types/src/components/Focus/styles.d.ts +0 -6
- package/dist/types/src/components/Focus/styles.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.d.ts +0 -14
- package/dist/types/src/components/Image/Image.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
- package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
- package/dist/types/src/components/Image/index.d.ts +0 -2
- package/dist/types/src/components/Image/index.d.ts.map +0 -1
- package/dist/types/src/components/Layout/Layout.d.ts +0 -33
- package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
- package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
- package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
- package/dist/types/src/components/Layout/index.d.ts +0 -2
- package/dist/types/src/components/Layout/index.d.ts.map +0 -1
- package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
- package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/index.d.ts +0 -2
- package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
- package/dist/types/src/components/Stack/Stack.d.ts +0 -22
- package/dist/types/src/components/Stack/Stack.d.ts.map +0 -1
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +0 -1
- package/dist/types/src/components/Stack/index.d.ts +0 -2
- package/dist/types/src/components/Stack/index.d.ts.map +0 -1
- package/dist/types/src/testing/Board.d.ts +0 -45
- package/dist/types/src/testing/Board.d.ts.map +0 -1
- package/dist/types/src/testing/Slot.stories.d.ts +0 -14
- package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
- package/dist/types/src/testing/Virtualizer.stories.d.ts +0 -12
- package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
- package/src/components/Card/Card.stories.tsx +0 -148
- package/src/components/Card/Card.tsx +0 -458
- package/src/components/Card/CardDragPreview.tsx +0 -23
- package/src/components/Card/index.ts +0 -8
- package/src/components/Card/styles.ts +0 -23
- package/src/components/Focus/styles.ts +0 -24
- package/src/components/Image/Image.stories.tsx +0 -86
- package/src/components/Image/Image.tsx +0 -223
- package/src/components/Image/index.ts +0 -5
- package/src/components/Layout/Layout.stories.tsx +0 -59
- package/src/components/Layout/Layout.tsx +0 -108
- package/src/components/Mosaic/Mosaic.stories.tsx +0 -113
- package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
- package/src/components/Scrollable/Scrollable.tsx +0 -88
- package/src/components/Scrollable/index.ts +0 -5
- package/src/components/Scrollable/scrollable.css +0 -20
- package/src/components/Stack/Stack.tsx +0 -210
- package/src/components/Stack/index.ts +0 -5
- package/src/testing/Board.tsx +0 -278
- package/src/testing/Slot.stories.tsx +0 -101
- package/src/testing/Virtualizer.stories.tsx +0 -133
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Mosaic,
|
|
5
|
-
styles3 as styles,
|
|
6
|
-
useContainerDebug,
|
|
7
|
-
useEventHandlerAdapter,
|
|
8
|
-
useRootContext
|
|
9
|
-
} from "../chunk-UMBPEG4F.mjs";
|
|
2
|
+
Mosaic
|
|
3
|
+
} from "../chunk-7S4PIFKU.mjs";
|
|
10
4
|
|
|
11
5
|
// src/testing/decorator.tsx
|
|
12
6
|
import React from "react";
|
|
@@ -14,16 +8,10 @@ var withMosaic = () => {
|
|
|
14
8
|
return (Story) => /* @__PURE__ */ React.createElement(Mosaic.Root, null, /* @__PURE__ */ React.createElement(Story, null));
|
|
15
9
|
};
|
|
16
10
|
|
|
17
|
-
// src/testing/
|
|
18
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
11
|
+
// src/testing/types.ts
|
|
19
12
|
import * as Schema from "effect/Schema";
|
|
20
|
-
import
|
|
21
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
13
|
+
import { Ref, Type } from "@dxos/echo";
|
|
22
14
|
import { ObjectId } from "@dxos/keys";
|
|
23
|
-
import { useObject } from "@dxos/react-client/echo";
|
|
24
|
-
import { Tag } from "@dxos/react-ui";
|
|
25
|
-
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
26
|
-
import { getHashStyles, mx } from "@dxos/ui-theme";
|
|
27
15
|
var TestItem = Schema.Struct({
|
|
28
16
|
name: Schema.String,
|
|
29
17
|
description: Schema.optional(Schema.String),
|
|
@@ -34,221 +22,47 @@ var TestItem = Schema.Struct({
|
|
|
34
22
|
}));
|
|
35
23
|
var TestColumn = Schema.Struct({
|
|
36
24
|
id: ObjectId,
|
|
37
|
-
|
|
25
|
+
name: Schema.String,
|
|
26
|
+
items: Schema.mutable(Schema.Array(Ref.Ref(TestItem)))
|
|
38
27
|
}).pipe(Type.object({
|
|
39
28
|
typename: "example.com/type/Column",
|
|
40
29
|
version: "0.1.0"
|
|
41
30
|
}));
|
|
42
|
-
var Root = /* @__PURE__ */ forwardRef(({ id, columns, debug }, forwardedRef) => {
|
|
43
|
-
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
44
|
-
const [viewport, setViewport] = useState(null);
|
|
45
|
-
const eventHandler = useEventHandlerAdapter({
|
|
46
|
-
id,
|
|
47
|
-
items: columns,
|
|
48
|
-
getId: (data) => data.id,
|
|
49
|
-
get: (data) => data,
|
|
50
|
-
make: (object) => object,
|
|
51
|
-
canDrop: ({ source }) => Obj.instanceOf(TestColumn, source.data)
|
|
52
|
-
});
|
|
53
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
54
|
-
role: "none",
|
|
55
|
-
className: mx("plb-2 grid bs-full is-full overflow-hidden", debug && "grid-cols-[1fr_20rem] gap-2"),
|
|
56
|
-
ref: forwardedRef
|
|
57
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
58
|
-
asChild: true,
|
|
59
|
-
axis: "horizontal"
|
|
60
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Container, {
|
|
61
|
-
asChild: true,
|
|
62
|
-
withFocus: true,
|
|
63
|
-
axis: "horizontal",
|
|
64
|
-
autoScroll: viewport,
|
|
65
|
-
eventHandler,
|
|
66
|
-
debug: debugHandler
|
|
67
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Viewport, {
|
|
68
|
-
axis: "horizontal",
|
|
69
|
-
padding: true,
|
|
70
|
-
viewportRef: setViewport
|
|
71
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Stack, {
|
|
72
|
-
axis: "horizontal",
|
|
73
|
-
items: columns,
|
|
74
|
-
getId: (item) => item.id,
|
|
75
|
-
Tile: Column,
|
|
76
|
-
debug
|
|
77
|
-
})))), /* @__PURE__ */ React2.createElement(DebugInfo, null));
|
|
78
|
-
});
|
|
79
|
-
var Column = /* @__PURE__ */ forwardRef(({ classNames, location, data, debug }, forwardedRef) => {
|
|
80
|
-
const [column, updateColumn] = useObject(data);
|
|
81
|
-
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
82
|
-
const dragHandleRef = useRef(null);
|
|
83
|
-
const [viewport, setViewport] = useState(null);
|
|
84
|
-
const eventHandler = useEventHandlerAdapter({
|
|
85
|
-
id: data.id,
|
|
86
|
-
items: column.items,
|
|
87
|
-
getId: (data2) => data2.dxn.toString(),
|
|
88
|
-
get: (data2) => data2.target,
|
|
89
|
-
make: (object) => Ref.make(object),
|
|
90
|
-
canDrop: ({ source }) => Obj.instanceOf(TestItem, source.data.target),
|
|
91
|
-
onChange: (mutator) => updateColumn((column2) => mutator(column2.items))
|
|
92
|
-
});
|
|
93
|
-
const menuItems = useMemo(() => [
|
|
94
|
-
{
|
|
95
|
-
label: "Delete",
|
|
96
|
-
onClick: (obj) => {
|
|
97
|
-
updateColumn((column2) => {
|
|
98
|
-
const idx = column2.items.findIndex((item) => item.target?.id === obj?.id);
|
|
99
|
-
if (idx !== -1) {
|
|
100
|
-
column2.items.splice(idx, 1);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
], [
|
|
106
|
-
updateColumn
|
|
107
|
-
]);
|
|
108
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
|
|
109
|
-
asChild: true,
|
|
110
|
-
dragHandle: dragHandleRef.current,
|
|
111
|
-
location,
|
|
112
|
-
id: data.id,
|
|
113
|
-
data,
|
|
114
|
-
debug
|
|
115
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
116
|
-
asChild: true
|
|
117
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
118
|
-
className: mx("grid bs-full card-default-width overflow-hidden bg-deckSurface", debug ? "grid-rows-[min-content_1fr_20rem]" : "grid-rows-[min-content_1fr_min-content]", classNames),
|
|
119
|
-
ref: forwardedRef
|
|
120
|
-
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
|
|
121
|
-
ref: dragHandleRef
|
|
122
|
-
}), /* @__PURE__ */ React2.createElement(Card.Title, null, column.id), /* @__PURE__ */ React2.createElement(Card.Menu, {
|
|
123
|
-
items: []
|
|
124
|
-
})), /* @__PURE__ */ React2.createElement(Card.Context, {
|
|
125
|
-
value: {
|
|
126
|
-
menuItems
|
|
127
|
-
}
|
|
128
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Container, {
|
|
129
|
-
asChild: true,
|
|
130
|
-
withFocus: true,
|
|
131
|
-
axis: "vertical",
|
|
132
|
-
autoScroll: viewport,
|
|
133
|
-
eventHandler,
|
|
134
|
-
debug: debugHandler
|
|
135
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Viewport, {
|
|
136
|
-
axis: "vertical",
|
|
137
|
-
padding: true,
|
|
138
|
-
viewportRef: setViewport
|
|
139
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Stack, {
|
|
140
|
-
axis: "vertical",
|
|
141
|
-
items: column.items,
|
|
142
|
-
getId: (data2) => data2.dxn.toString(),
|
|
143
|
-
Tile: Item
|
|
144
|
-
})))), /* @__PURE__ */ React2.createElement("div", {
|
|
145
|
-
role: "none"
|
|
146
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
147
|
-
className: "grow flex p-1 justify-center text-xs"
|
|
148
|
-
}, column.items.length), /* @__PURE__ */ React2.createElement(DebugInfo, null)))));
|
|
149
|
-
});
|
|
150
|
-
Column.displayName = "Column";
|
|
151
|
-
var Item = /* @__PURE__ */ forwardRef(({ classNames, data: ref, location, debug }, forwardedRef) => {
|
|
152
|
-
const rootRef = useRef(null);
|
|
153
|
-
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
154
|
-
const dragHandleRef = useRef(null);
|
|
155
|
-
const object = ref.target;
|
|
156
|
-
if (!object) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
|
|
160
|
-
asChild: true,
|
|
161
|
-
dragHandle: dragHandleRef.current,
|
|
162
|
-
id: ref.dxn.toString(),
|
|
163
|
-
data: ref,
|
|
164
|
-
location,
|
|
165
|
-
debug
|
|
166
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
167
|
-
asChild: true
|
|
168
|
-
}, /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
169
|
-
classNames,
|
|
170
|
-
onClick: () => rootRef.current?.focus(),
|
|
171
|
-
ref: composedRef
|
|
172
|
-
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
|
|
173
|
-
ref: dragHandleRef
|
|
174
|
-
}), /* @__PURE__ */ React2.createElement(Card.Title, null, object.name), /* @__PURE__ */ React2.createElement(Card.Menu, {
|
|
175
|
-
context: object
|
|
176
|
-
})), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
177
|
-
icon: "ph--note--regular",
|
|
178
|
-
classNames: "text-description"
|
|
179
|
-
}, object.description), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
180
|
-
icon: "ph--tag--regular"
|
|
181
|
-
}, object.label && /* @__PURE__ */ React2.createElement("div", {
|
|
182
|
-
role: "none",
|
|
183
|
-
className: "flex shrink-0 gap-1 text-xs items-center"
|
|
184
|
-
}, /* @__PURE__ */ React2.createElement(Tag, {
|
|
185
|
-
palette: getHashStyles(object.label).hue
|
|
186
|
-
}, object.label))))));
|
|
187
|
-
});
|
|
188
|
-
Item.displayName = "Item";
|
|
189
|
-
var Placeholder = (props) => {
|
|
190
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Placeholder, {
|
|
191
|
-
...props,
|
|
192
|
-
classNames: styles.placeholder.root
|
|
193
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
194
|
-
className: mx("flex bs-full border border-dashed border-separator rounded-sm", styles.placeholder.content)
|
|
195
|
-
}));
|
|
196
|
-
};
|
|
197
|
-
Placeholder.displayName = "Placeholder";
|
|
198
|
-
var Debug = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
199
|
-
const { containers, dragging } = useRootContext(Debug.displayName);
|
|
200
|
-
const counter = useRef(0);
|
|
201
|
-
return /* @__PURE__ */ React2.createElement(Json, {
|
|
202
|
-
data: {
|
|
203
|
-
containers,
|
|
204
|
-
dragging,
|
|
205
|
-
count: counter.current++
|
|
206
|
-
},
|
|
207
|
-
classNames: mx("text-xs", classNames),
|
|
208
|
-
ref: forwardedRef
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
Debug.displayName = "Debug";
|
|
212
|
-
var Board = {
|
|
213
|
-
Root,
|
|
214
|
-
Column,
|
|
215
|
-
Item,
|
|
216
|
-
Placeholder,
|
|
217
|
-
Debug
|
|
218
|
-
};
|
|
219
31
|
|
|
220
32
|
// src/testing/CardContainer.tsx
|
|
221
33
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
222
|
-
import
|
|
34
|
+
import React2 from "react";
|
|
223
35
|
import { Icon, Popover } from "@dxos/react-ui";
|
|
224
36
|
import { ResizeHandle, resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
225
37
|
var DEFAULT_BLOCK_SIZE = 22;
|
|
226
38
|
var MIN_BLOCK_SIZE = 8;
|
|
227
|
-
var CardContainer = ({ children, icon = "ph--
|
|
39
|
+
var CardContainer = ({ children, role, icon = "ph--arrow-line-down--regular" }) => {
|
|
228
40
|
switch (role) {
|
|
229
|
-
case "
|
|
230
|
-
return /* @__PURE__ */
|
|
41
|
+
case "popover":
|
|
42
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
43
|
+
role: "none",
|
|
44
|
+
className: "flex justify-center"
|
|
45
|
+
}, /* @__PURE__ */ React2.createElement(PopoverCardContainer, {
|
|
231
46
|
icon
|
|
232
|
-
}, children);
|
|
233
|
-
case "
|
|
47
|
+
}, children));
|
|
48
|
+
case "intrinsic":
|
|
234
49
|
default:
|
|
235
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ React2.createElement(IntrinsicCardContainer, null, children);
|
|
236
51
|
}
|
|
237
52
|
};
|
|
238
|
-
var
|
|
239
|
-
|
|
240
|
-
return /* @__PURE__ */ React3.createElement(Popover.Root, {
|
|
53
|
+
var PopoverCardContainer = ({ children, icon = "ph--arrow-line-down--regular" }) => {
|
|
54
|
+
return /* @__PURE__ */ React2.createElement(Popover.Root, {
|
|
241
55
|
open: true
|
|
242
|
-
}, /* @__PURE__ */
|
|
243
|
-
onOpenAutoFocus: (event) => event.preventDefault()
|
|
244
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, {
|
|
245
|
-
classNames: "popover-card-width"
|
|
246
|
-
}, children), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)), /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
56
|
+
}, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
247
57
|
asChild: true
|
|
248
|
-
}, /* @__PURE__ */
|
|
58
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
249
59
|
icon,
|
|
250
60
|
size: 5
|
|
251
|
-
}))
|
|
61
|
+
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
62
|
+
onOpenAutoFocus: (event) => event.preventDefault()
|
|
63
|
+
}, /* @__PURE__ */ React2.createElement(Popover.Viewport, {
|
|
64
|
+
classNames: "dx-card-popover"
|
|
65
|
+
}, children), /* @__PURE__ */ React2.createElement(Popover.Arrow, null))));
|
|
252
66
|
};
|
|
253
67
|
var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeChange }) => {
|
|
254
68
|
const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState({
|
|
@@ -256,11 +70,15 @@ var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeCha
|
|
|
256
70
|
defaultProp: defaultSize,
|
|
257
71
|
onChange: onSizeChange
|
|
258
72
|
});
|
|
259
|
-
return /* @__PURE__ */
|
|
260
|
-
|
|
73
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
74
|
+
role: "none",
|
|
75
|
+
className: "relative p-2 grid overflow-hidden border-2 border-dashed border-green-500 rounded-lg",
|
|
261
76
|
style: sizeStyle(size, "horizontal"),
|
|
262
77
|
...resizeAttributes
|
|
263
|
-
},
|
|
78
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
79
|
+
role: "none",
|
|
80
|
+
className: "flex flex-col w-full h-full overflow-hidden"
|
|
81
|
+
}, children), /* @__PURE__ */ React2.createElement(ResizeHandle, {
|
|
264
82
|
side: "inline-end",
|
|
265
83
|
fallbackSize: DEFAULT_BLOCK_SIZE,
|
|
266
84
|
minSize: MIN_BLOCK_SIZE,
|
|
@@ -270,34 +88,45 @@ var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeCha
|
|
|
270
88
|
};
|
|
271
89
|
|
|
272
90
|
// src/testing/DefaultStackTile.tsx
|
|
273
|
-
import
|
|
274
|
-
import { Obj
|
|
275
|
-
import {
|
|
91
|
+
import React3, { useMemo, useRef, useState } from "react";
|
|
92
|
+
import { Obj } from "@dxos/echo";
|
|
93
|
+
import { Card, Toolbar } from "@dxos/react-ui";
|
|
94
|
+
import { Menu, createMenuAction } from "@dxos/react-ui-menu";
|
|
95
|
+
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
276
96
|
var DefaultStackTile = (props) => {
|
|
277
|
-
const dragHandleRef =
|
|
278
|
-
const [open, setOpen] =
|
|
279
|
-
|
|
97
|
+
const dragHandleRef = useRef(null);
|
|
98
|
+
const [open, setOpen] = useState(false);
|
|
99
|
+
const menuItems = useMemo(() => [
|
|
100
|
+
createMenuAction("toggle-details", () => setOpen((prev) => !prev), {
|
|
101
|
+
label: open ? "Hide details" : "Show details",
|
|
102
|
+
icon: "ph--placeholder--regular"
|
|
103
|
+
})
|
|
104
|
+
], [
|
|
105
|
+
open
|
|
106
|
+
]);
|
|
107
|
+
return /* @__PURE__ */ React3.createElement(Mosaic.Tile, {
|
|
280
108
|
...props,
|
|
281
|
-
className: "border border-separator rounded-
|
|
282
|
-
}, /* @__PURE__ */
|
|
109
|
+
className: "border border-separator rounded-xs font-mono"
|
|
110
|
+
}, /* @__PURE__ */ React3.createElement(Menu.Root, null, /* @__PURE__ */ React3.createElement(Card.Toolbar, null, /* @__PURE__ */ React3.createElement(Card.DragHandle, {
|
|
283
111
|
ref: dragHandleRef
|
|
284
|
-
}), /* @__PURE__ */
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
112
|
+
}), /* @__PURE__ */ React3.createElement(Card.Title, null, Obj.getLabel(props.data) ?? props.data.id), /* @__PURE__ */ React3.createElement(Menu.Trigger, {
|
|
113
|
+
asChild: true,
|
|
114
|
+
disabled: !menuItems?.length
|
|
115
|
+
}, /* @__PURE__ */ React3.createElement(Toolbar.IconButton, {
|
|
116
|
+
iconOnly: true,
|
|
117
|
+
variant: "ghost",
|
|
118
|
+
icon: "ph--dots-three-vertical--regular",
|
|
119
|
+
label: "Menu"
|
|
120
|
+
})), /* @__PURE__ */ React3.createElement(Menu.Content, {
|
|
121
|
+
items: menuItems
|
|
122
|
+
}))), open && /* @__PURE__ */ React3.createElement(Card.Row, null, /* @__PURE__ */ React3.createElement(Json, {
|
|
292
123
|
data: props.data,
|
|
293
124
|
classNames: "text-xs"
|
|
294
125
|
})));
|
|
295
126
|
};
|
|
296
127
|
DefaultStackTile.displayName = "DefaultStackTile";
|
|
297
128
|
export {
|
|
298
|
-
Board,
|
|
299
129
|
CardContainer,
|
|
300
|
-
Debug,
|
|
301
130
|
DefaultStackTile,
|
|
302
131
|
IntrinsicCardContainer,
|
|
303
132
|
PopoverCardContainer,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/decorator.tsx", "../../../../src/testing/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react-vite';\nimport React from 'react';\n\nimport { Mosaic } from '../components';\n\nexport const withMosaic = (): Decorator => {\n return (Story) => (\n <Mosaic.Root>\n <Story />\n </Mosaic.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport * as Schema from 'effect/Schema';\nimport React, { forwardRef, useMemo, useRef, useState } from 'react';\n\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { ObjectId } from '@dxos/keys';\nimport { useObject } from '@dxos/react-client/echo';\nimport { Tag, type ThemedClassName } from '@dxos/react-ui';\nimport { Json } from '@dxos/react-ui-syntax-highlighter';\nimport { getHashStyles, mx } from '@dxos/ui-theme';\n\nimport {\n Card,\n type CardMenuProps,\n Focus,\n Mosaic,\n type MosaicTileProps,\n type MosiacPlaceholderProps,\n mosaicStyles,\n useMosaic,\n} from '../components';\nimport { useContainerDebug, useEventHandlerAdapter } from '../hooks';\n\n//\n// Test Data\n//\n\nexport const TestItem = Schema.Struct({\n name: Schema.String,\n description: Schema.optional(Schema.String),\n label: Schema.optional(Schema.String),\n}).pipe(\n Type.object({\n typename: 'example.com/type/Item',\n version: '0.1.0',\n }),\n);\n\nexport interface TestItem extends Schema.Schema.Type<typeof TestItem> {}\n\nexport const TestColumn = Schema.Struct({\n id: ObjectId,\n items: Schema.mutable(Schema.Array(Type.Ref(TestItem))),\n}).pipe(\n Type.object({\n typename: 'example.com/type/Column',\n version: '0.1.0',\n }),\n);\n\nexport interface TestColumn extends Schema.Schema.Type<typeof TestColumn> {}\n\n//\n// Root\n//\n\ntype RootProps = {\n id: string;\n columns: TestColumn[];\n debug?: boolean;\n};\n\nconst Root = forwardRef<HTMLDivElement, RootProps>(({ id, columns, debug }, forwardedRef) => {\n const [DebugInfo, debugHandler] = useContainerDebug(debug);\n const [viewport, setViewport] = useState<HTMLElement | null>(null);\n\n const eventHandler = useEventHandlerAdapter({\n id,\n items: columns,\n getId: (data) => data.id,\n get: (data) => data,\n make: (object) => object,\n canDrop: ({ source }) => Obj.instanceOf(TestColumn, source.data),\n });\n\n return (\n <div\n role='none'\n className={mx('plb-2 grid bs-full is-full overflow-hidden', debug && 'grid-cols-[1fr_20rem] gap-2')}\n ref={forwardedRef}\n >\n <Focus.Group asChild axis='horizontal'>\n <Mosaic.Container\n asChild\n withFocus\n axis='horizontal'\n autoScroll={viewport}\n eventHandler={eventHandler}\n debug={debugHandler}\n >\n <Mosaic.Viewport axis='horizontal' padding viewportRef={setViewport}>\n <Mosaic.Stack axis='horizontal' items={columns} getId={(item) => item.id} Tile={Column} debug={debug} />\n </Mosaic.Viewport>\n </Mosaic.Container>\n </Focus.Group>\n <DebugInfo />\n </div>\n );\n});\n\n//\n// Column\n//\n\ntype ColumnProps = Pick<MosaicTileProps<TestColumn>, 'classNames' | 'location' | 'data' | 'debug'>;\n\nconst Column = forwardRef<HTMLDivElement, ColumnProps>(({ classNames, location, data, debug }, forwardedRef) => {\n const [column, updateColumn] = useObject(data);\n const [DebugInfo, debugHandler] = useContainerDebug(debug);\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const [viewport, setViewport] = useState<HTMLElement | null>(null);\n const eventHandler = useEventHandlerAdapter<Ref.Unknown>({\n id: data.id,\n items: column.items,\n getId: (data) => data.dxn.toString(),\n get: (data) => data.target!,\n make: (object) => Ref.make(object),\n canDrop: ({ source }) => Obj.instanceOf(TestItem, source.data.target),\n onChange: (mutator) => updateColumn((column) => mutator(column.items)),\n });\n\n // Context menu.\n const menuItems = useMemo<NonNullable<CardMenuProps<TestItem>['items']>>(\n () => [\n {\n label: 'Delete',\n onClick: (obj) => {\n updateColumn((column) => {\n const idx = column.items.findIndex((item) => item.target?.id === obj?.id);\n if (idx !== -1) {\n column.items.splice(idx, 1);\n }\n });\n },\n },\n ],\n [updateColumn],\n );\n\n return (\n <Mosaic.Tile asChild dragHandle={dragHandleRef.current} location={location} id={data.id} data={data} debug={debug}>\n <Focus.Group asChild>\n <div\n className={mx(\n 'grid bs-full card-default-width overflow-hidden bg-deckSurface',\n debug ? 'grid-rows-[min-content_1fr_20rem]' : 'grid-rows-[min-content_1fr_min-content]',\n classNames,\n )}\n ref={forwardedRef}\n >\n <Card.Toolbar>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{column.id}</Card.Title>\n <Card.Menu items={[]} />\n </Card.Toolbar>\n <Card.Context value={{ menuItems }}>\n <Mosaic.Container\n asChild\n withFocus\n axis='vertical'\n autoScroll={viewport}\n eventHandler={eventHandler}\n debug={debugHandler}\n >\n <Mosaic.Viewport axis='vertical' padding viewportRef={setViewport}>\n <Mosaic.Stack axis='vertical' items={column.items} getId={(data) => data.dxn.toString()} Tile={Item} />\n </Mosaic.Viewport>\n </Mosaic.Container>\n </Card.Context>\n <div role='none'>\n <div className='grow flex p-1 justify-center text-xs'>{column.items.length}</div>\n <DebugInfo />\n </div>\n </div>\n </Focus.Group>\n </Mosaic.Tile>\n );\n});\n\nColumn.displayName = 'Column';\n\n//\n// Item\n//\n\ntype ItemProps = Pick<MosaicTileProps<Ref.Ref<TestItem>>, 'classNames' | 'location' | 'data' | 'debug'>;\n\nconst Item = forwardRef<HTMLDivElement, ItemProps>(({ classNames, data: ref, location, debug }, forwardedRef) => {\n const rootRef = useRef<HTMLDivElement>(null);\n const composedRef = useComposedRefs<HTMLDivElement>(rootRef, forwardedRef);\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const object = ref.target;\n if (!object) {\n return null;\n }\n\n return (\n <Mosaic.Tile\n asChild\n dragHandle={dragHandleRef.current}\n id={ref.dxn.toString()}\n data={ref}\n location={location}\n debug={debug}\n >\n <Focus.Group asChild>\n <Card.Root classNames={classNames} onClick={() => rootRef.current?.focus()} ref={composedRef}>\n <Card.Toolbar>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{object.name}</Card.Title>\n <Card.Menu context={object} />\n </Card.Toolbar>\n <Card.Row icon='ph--note--regular' classNames='text-description'>\n {object.description}\n </Card.Row>\n <Card.Row icon='ph--tag--regular'>\n {object.label && (\n <div role='none' className='flex shrink-0 gap-1 text-xs items-center'>\n <Tag palette={getHashStyles(object.label).hue}>{object.label}</Tag>\n </div>\n )}\n </Card.Row>\n </Card.Root>\n </Focus.Group>\n </Mosaic.Tile>\n );\n});\n\nItem.displayName = 'Item';\n\n//\n// Placeholder\n//\n\nconst Placeholder = (props: MosiacPlaceholderProps<number>) => {\n return (\n <Mosaic.Placeholder {...props} classNames={mosaicStyles.placeholder.root}>\n <div\n className={mx(\n 'flex bs-full border border-dashed border-separator rounded-sm',\n mosaicStyles.placeholder.content,\n )}\n />\n </Mosaic.Placeholder>\n );\n};\n\nPlaceholder.displayName = 'Placeholder';\n\n//\n// Debug\n//\n\nexport const Debug = forwardRef<HTMLDivElement, ThemedClassName>(({ classNames }, forwardedRef) => {\n const { containers, dragging } = useMosaic(Debug.displayName!);\n const counter = useRef(0);\n return (\n <Json\n data={{ containers, dragging, count: counter.current++ }}\n classNames={mx('text-xs', classNames)}\n ref={forwardedRef}\n />\n );\n});\n\nDebug.displayName = 'Debug';\n\n//\n// Board\n//\n\nexport const Board = { Root, Column, Item, Placeholder, Debug };\n\nexport type { RootProps, ColumnProps, ItemProps };\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Icon, Popover } from '@dxos/react-ui';\nimport { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';\n\nconst DEFAULT_BLOCK_SIZE = 22;\nconst MIN_BLOCK_SIZE = 8;\n\n//\n// Card container.\n//\n\nexport const CardContainer = ({\n children,\n icon = 'ph--placeholder--regular',\n role,\n}: PropsWithChildren<{ icon?: string; role?: string }>) => {\n switch (role) {\n case 'card--popover':\n return <PopoverCardContainer icon={icon}>{children}</PopoverCardContainer>;\n case 'card--intrinsic':\n default:\n return <IntrinsicCardContainer>{children}</IntrinsicCardContainer>;\n }\n};\n\nconst border = 'relative border border-dashed border-subduedSeparator p-4 rounded-lg overflow-x-auto';\n\n//\n// Popover\n//\n\nexport type PopoverCardContainerProps = PropsWithChildren<{ icon?: string }>;\n\nexport const PopoverCardContainer = ({ children, icon = 'ph--placeholder--regular' }: PopoverCardContainerProps) => {\n return (\n <Popover.Root open>\n <Popover.Content onOpenAutoFocus={(event) => event.preventDefault()}>\n <Popover.Viewport classNames='popover-card-width'>{children}</Popover.Viewport>\n <Popover.Arrow />\n </Popover.Content>\n <Popover.Trigger asChild>\n <Icon icon={icon} size={5} />\n </Popover.Trigger>\n </Popover.Root>\n );\n};\n\n//\n// Intrinsic card container (size constrained by card).\n//\n\nexport type IntrinsicCardContainerProps = PropsWithChildren<{\n defaultSize?: Size;\n size?: Size;\n onSizeChange?: (size: Size, commit?: boolean) => void;\n}>;\n\nexport const IntrinsicCardContainer = ({\n children,\n defaultSize,\n size: propSize,\n onSizeChange,\n}: IntrinsicCardContainerProps) => {\n const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState<Size>({\n prop: propSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n\n return (\n <div className={border} style={sizeStyle(size, 'horizontal')} {...resizeAttributes}>\n {children}\n <ResizeHandle\n side='inline-end'\n fallbackSize={DEFAULT_BLOCK_SIZE}\n minSize={MIN_BLOCK_SIZE}\n size={size}\n onSizeChange={setSize}\n />\n </div>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useRef, useState } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { Json } from '@dxos/react-ui-syntax-highlighter';\n\nimport { Card, Mosaic, type StackTileComponent } from '../components';\n\nexport const DefaultStackTile: StackTileComponent<Obj.Any> = (props) => {\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(false);\n return (\n <Mosaic.Tile {...props} className='border border-separator rounded-sm font-mono'>\n <Card.Toolbar>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{Obj.getLabel(props.data) ?? props.data.id}</Card.Title>\n <Card.Menu\n items={[\n {\n label: open ? 'Hide details' : 'Show details',\n onClick: () => setOpen((open) => !open),\n },\n ]}\n />\n </Card.Toolbar>\n {open && (\n <Card.Row>\n <Json data={props.data} classNames='text-xs' />\n </Card.Row>\n )}\n </Mosaic.Tile>\n );\n};\n\nDefaultStackTile.displayName = 'DefaultStackTile';\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "withMosaic", "Story", "Mosaic", "Root", "
|
|
3
|
+
"sources": ["../../../../src/testing/decorator.tsx", "../../../../src/testing/types.ts", "../../../../src/testing/CardContainer.tsx", "../../../../src/testing/DefaultStackTile.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Decorator } from '@storybook/react-vite';\nimport React from 'react';\n\nimport { Mosaic } from '../components';\n\nexport const withMosaic = (): Decorator => {\n return (Story) => (\n <Mosaic.Root>\n <Story />\n </Mosaic.Root>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Ref, Type } from '@dxos/echo';\nimport { ObjectId } from '@dxos/keys';\n\n//\n// Test Data\n//\n\nexport const TestItem = Schema.Struct({\n name: Schema.String,\n description: Schema.optional(Schema.String),\n label: Schema.optional(Schema.String),\n}).pipe(\n Type.object({\n typename: 'example.com/type/Item',\n version: '0.1.0',\n }),\n);\n\nexport interface TestItem extends Schema.Schema.Type<typeof TestItem> {}\n\nexport const TestColumn = Schema.Struct({\n id: ObjectId,\n name: Schema.String,\n items: Schema.mutable(Schema.Array(Ref.Ref(TestItem))),\n}).pipe(\n Type.object({\n typename: 'example.com/type/Column',\n version: '0.1.0',\n }),\n);\n\nexport interface TestColumn extends Schema.Schema.Type<typeof TestColumn> {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { Icon, Popover } from '@dxos/react-ui';\nimport { ResizeHandle, type Size, resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';\n\nconst DEFAULT_BLOCK_SIZE = 22;\nconst MIN_BLOCK_SIZE = 8;\n\n//\n// Card container.\n//\n\nexport type CardContainerProps = PropsWithChildren<{ role?: 'popover' | 'intrinsic'; icon?: string }>;\n\nexport const CardContainer = ({ children, role, icon = 'ph--arrow-line-down--regular' }: CardContainerProps) => {\n switch (role) {\n case 'popover':\n return (\n <div role='none' className='flex justify-center'>\n <PopoverCardContainer icon={icon}>{children}</PopoverCardContainer>\n </div>\n );\n case 'intrinsic':\n default:\n return <IntrinsicCardContainer>{children}</IntrinsicCardContainer>;\n }\n};\n\n//\n// Popover\n//\n\nexport type PopoverCardContainerProps = PropsWithChildren<{ icon?: string }>;\n\nexport const PopoverCardContainer = ({\n children,\n icon = 'ph--arrow-line-down--regular',\n}: PopoverCardContainerProps) => {\n return (\n <Popover.Root open>\n <Popover.Trigger asChild>\n <Icon icon={icon} size={5} />\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content onOpenAutoFocus={(event: Event) => event.preventDefault()}>\n <Popover.Viewport classNames='dx-card-popover'>{children}</Popover.Viewport>\n <Popover.Arrow />\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n};\n\n//\n// Intrinsic card container (size constrained by card itself).\n//\n\nexport type IntrinsicCardContainerProps = PropsWithChildren<{\n defaultSize?: Size;\n size?: Size;\n onSizeChange?: (size: Size, commit?: boolean) => void;\n}>;\n\nexport const IntrinsicCardContainer = ({\n children,\n defaultSize,\n size: propSize,\n onSizeChange,\n}: IntrinsicCardContainerProps) => {\n const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState<Size>({\n prop: propSize,\n defaultProp: defaultSize,\n onChange: onSizeChange,\n });\n\n return (\n <div\n role='none'\n className='relative p-2 grid overflow-hidden border-2 border-dashed border-green-500 rounded-lg'\n style={sizeStyle(size, 'horizontal')}\n {...resizeAttributes}\n >\n <div role='none' className='flex flex-col w-full h-full overflow-hidden'>\n {children}\n </div>\n <ResizeHandle\n side='inline-end'\n fallbackSize={DEFAULT_BLOCK_SIZE}\n minSize={MIN_BLOCK_SIZE}\n size={size}\n onSizeChange={setSize}\n />\n </div>\n );\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { useMemo, useRef, useState } from 'react';\n\nimport { Obj } from '@dxos/echo';\nimport { Card, Toolbar } from '@dxos/react-ui';\nimport { Menu, createMenuAction } from '@dxos/react-ui-menu';\nimport { Json } from '@dxos/react-ui-syntax-highlighter';\n\nimport { Mosaic, type MosaicStackTileComponent } from '../components';\n\nexport const DefaultStackTile: MosaicStackTileComponent<Obj.Any> = (props) => {\n const dragHandleRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(false);\n const menuItems = useMemo(\n () => [\n createMenuAction('toggle-details', () => setOpen((prev) => !prev), {\n label: open ? 'Hide details' : 'Show details',\n icon: 'ph--placeholder--regular',\n }),\n ],\n [open],\n );\n\n return (\n <Mosaic.Tile {...props} className='border border-separator rounded-xs font-mono'>\n <Menu.Root>\n <Card.Toolbar>\n <Card.DragHandle ref={dragHandleRef} />\n <Card.Title>{Obj.getLabel(props.data) ?? props.data.id}</Card.Title>\n {/* TODO(wittjosiah): Reconcile with Card.Menu. */}\n <Menu.Trigger asChild disabled={!menuItems?.length}>\n <Toolbar.IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label='Menu' />\n </Menu.Trigger>\n <Menu.Content items={menuItems} />\n </Card.Toolbar>\n </Menu.Root>\n {open && (\n <Card.Row>\n <Json data={props.data} classNames='text-xs' />\n </Card.Row>\n )}\n </Mosaic.Tile>\n );\n};\n\nDefaultStackTile.displayName = 'DefaultStackTile';\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["React", "withMosaic", "Story", "Mosaic", "Root", "Schema", "Ref", "Type", "ObjectId", "TestItem", "Struct", "name", "String", "description", "optional", "label", "pipe", "Type", "object", "typename", "version", "TestColumn", "id", "ObjectId", "items", "mutable", "Array", "Ref", "useControllableState", "React", "Icon", "Popover", "ResizeHandle", "resizeAttributes", "sizeStyle", "DEFAULT_BLOCK_SIZE", "MIN_BLOCK_SIZE", "CardContainer", "children", "role", "icon", "React", "div", "className", "PopoverCardContainer", "IntrinsicCardContainer", "Popover", "Root", "open", "Trigger", "asChild", "Icon", "size", "Portal", "Content", "onOpenAutoFocus", "event", "preventDefault", "Viewport", "classNames", "Arrow", "defaultSize", "propSize", "onSizeChange", "setSize", "useControllableState", "prop", "defaultProp", "onChange", "style", "sizeStyle", "resizeAttributes", "ResizeHandle", "side", "fallbackSize", "minSize", "React", "useMemo", "useRef", "useState", "Obj", "Card", "Toolbar", "Menu", "createMenuAction", "Json", "DefaultStackTile", "props", "dragHandleRef", "useRef", "open", "setOpen", "useState", "menuItems", "useMemo", "createMenuAction", "prev", "label", "icon", "React", "Mosaic", "Tile", "className", "Menu", "Root", "Card", "Toolbar", "DragHandle", "ref", "Title", "Obj", "getLabel", "data", "id", "Trigger", "asChild", "disabled", "length", "IconButton", "iconOnly", "variant", "Content", "items", "Row", "Json", "classNames", "displayName"]
|
|
7
7
|
}
|