@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,13 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Mosaic,
|
|
6
|
-
styles3 as styles,
|
|
7
|
-
useContainerDebug,
|
|
8
|
-
useEventHandlerAdapter,
|
|
9
|
-
useRootContext
|
|
10
|
-
} from "../chunk-X6GV7SMK.mjs";
|
|
3
|
+
Mosaic
|
|
4
|
+
} from "../chunk-MK6KU66S.mjs";
|
|
11
5
|
|
|
12
6
|
// src/testing/decorator.tsx
|
|
13
7
|
import React from "react";
|
|
@@ -15,16 +9,10 @@ var withMosaic = () => {
|
|
|
15
9
|
return (Story) => /* @__PURE__ */ React.createElement(Mosaic.Root, null, /* @__PURE__ */ React.createElement(Story, null));
|
|
16
10
|
};
|
|
17
11
|
|
|
18
|
-
// src/testing/
|
|
19
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
12
|
+
// src/testing/types.ts
|
|
20
13
|
import * as Schema from "effect/Schema";
|
|
21
|
-
import
|
|
22
|
-
import { Obj, Ref, Type } from "@dxos/echo";
|
|
14
|
+
import { Ref, Type } from "@dxos/echo";
|
|
23
15
|
import { ObjectId } from "@dxos/keys";
|
|
24
|
-
import { useObject } from "@dxos/react-client/echo";
|
|
25
|
-
import { Tag } from "@dxos/react-ui";
|
|
26
|
-
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
27
|
-
import { getHashStyles, mx } from "@dxos/ui-theme";
|
|
28
16
|
var TestItem = Schema.Struct({
|
|
29
17
|
name: Schema.String,
|
|
30
18
|
description: Schema.optional(Schema.String),
|
|
@@ -35,221 +23,47 @@ var TestItem = Schema.Struct({
|
|
|
35
23
|
}));
|
|
36
24
|
var TestColumn = Schema.Struct({
|
|
37
25
|
id: ObjectId,
|
|
38
|
-
|
|
26
|
+
name: Schema.String,
|
|
27
|
+
items: Schema.mutable(Schema.Array(Ref.Ref(TestItem)))
|
|
39
28
|
}).pipe(Type.object({
|
|
40
29
|
typename: "example.com/type/Column",
|
|
41
30
|
version: "0.1.0"
|
|
42
31
|
}));
|
|
43
|
-
var Root = /* @__PURE__ */ forwardRef(({ id, columns, debug }, forwardedRef) => {
|
|
44
|
-
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
45
|
-
const [viewport, setViewport] = useState(null);
|
|
46
|
-
const eventHandler = useEventHandlerAdapter({
|
|
47
|
-
id,
|
|
48
|
-
items: columns,
|
|
49
|
-
getId: (data) => data.id,
|
|
50
|
-
get: (data) => data,
|
|
51
|
-
make: (object) => object,
|
|
52
|
-
canDrop: ({ source }) => Obj.instanceOf(TestColumn, source.data)
|
|
53
|
-
});
|
|
54
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
55
|
-
role: "none",
|
|
56
|
-
className: mx("plb-2 grid bs-full is-full overflow-hidden", debug && "grid-cols-[1fr_20rem] gap-2"),
|
|
57
|
-
ref: forwardedRef
|
|
58
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
59
|
-
asChild: true,
|
|
60
|
-
axis: "horizontal"
|
|
61
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Container, {
|
|
62
|
-
asChild: true,
|
|
63
|
-
withFocus: true,
|
|
64
|
-
axis: "horizontal",
|
|
65
|
-
autoScroll: viewport,
|
|
66
|
-
eventHandler,
|
|
67
|
-
debug: debugHandler
|
|
68
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Viewport, {
|
|
69
|
-
axis: "horizontal",
|
|
70
|
-
padding: true,
|
|
71
|
-
viewportRef: setViewport
|
|
72
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Stack, {
|
|
73
|
-
axis: "horizontal",
|
|
74
|
-
items: columns,
|
|
75
|
-
getId: (item) => item.id,
|
|
76
|
-
Tile: Column,
|
|
77
|
-
debug
|
|
78
|
-
})))), /* @__PURE__ */ React2.createElement(DebugInfo, null));
|
|
79
|
-
});
|
|
80
|
-
var Column = /* @__PURE__ */ forwardRef(({ classNames, location, data, debug }, forwardedRef) => {
|
|
81
|
-
const [column, updateColumn] = useObject(data);
|
|
82
|
-
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
83
|
-
const dragHandleRef = useRef(null);
|
|
84
|
-
const [viewport, setViewport] = useState(null);
|
|
85
|
-
const eventHandler = useEventHandlerAdapter({
|
|
86
|
-
id: data.id,
|
|
87
|
-
items: column.items,
|
|
88
|
-
getId: (data2) => data2.dxn.toString(),
|
|
89
|
-
get: (data2) => data2.target,
|
|
90
|
-
make: (object) => Ref.make(object),
|
|
91
|
-
canDrop: ({ source }) => Obj.instanceOf(TestItem, source.data.target),
|
|
92
|
-
onChange: (mutator) => updateColumn((column2) => mutator(column2.items))
|
|
93
|
-
});
|
|
94
|
-
const menuItems = useMemo(() => [
|
|
95
|
-
{
|
|
96
|
-
label: "Delete",
|
|
97
|
-
onClick: (obj) => {
|
|
98
|
-
updateColumn((column2) => {
|
|
99
|
-
const idx = column2.items.findIndex((item) => item.target?.id === obj?.id);
|
|
100
|
-
if (idx !== -1) {
|
|
101
|
-
column2.items.splice(idx, 1);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
], [
|
|
107
|
-
updateColumn
|
|
108
|
-
]);
|
|
109
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
|
|
110
|
-
asChild: true,
|
|
111
|
-
dragHandle: dragHandleRef.current,
|
|
112
|
-
location,
|
|
113
|
-
id: data.id,
|
|
114
|
-
data,
|
|
115
|
-
debug
|
|
116
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
117
|
-
asChild: true
|
|
118
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
119
|
-
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),
|
|
120
|
-
ref: forwardedRef
|
|
121
|
-
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
|
|
122
|
-
ref: dragHandleRef
|
|
123
|
-
}), /* @__PURE__ */ React2.createElement(Card.Title, null, column.id), /* @__PURE__ */ React2.createElement(Card.Menu, {
|
|
124
|
-
items: []
|
|
125
|
-
})), /* @__PURE__ */ React2.createElement(Card.Context, {
|
|
126
|
-
value: {
|
|
127
|
-
menuItems
|
|
128
|
-
}
|
|
129
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Container, {
|
|
130
|
-
asChild: true,
|
|
131
|
-
withFocus: true,
|
|
132
|
-
axis: "vertical",
|
|
133
|
-
autoScroll: viewport,
|
|
134
|
-
eventHandler,
|
|
135
|
-
debug: debugHandler
|
|
136
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Viewport, {
|
|
137
|
-
axis: "vertical",
|
|
138
|
-
padding: true,
|
|
139
|
-
viewportRef: setViewport
|
|
140
|
-
}, /* @__PURE__ */ React2.createElement(Mosaic.Stack, {
|
|
141
|
-
axis: "vertical",
|
|
142
|
-
items: column.items,
|
|
143
|
-
getId: (data2) => data2.dxn.toString(),
|
|
144
|
-
Tile: Item
|
|
145
|
-
})))), /* @__PURE__ */ React2.createElement("div", {
|
|
146
|
-
role: "none"
|
|
147
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
148
|
-
className: "grow flex p-1 justify-center text-xs"
|
|
149
|
-
}, column.items.length), /* @__PURE__ */ React2.createElement(DebugInfo, null)))));
|
|
150
|
-
});
|
|
151
|
-
Column.displayName = "Column";
|
|
152
|
-
var Item = /* @__PURE__ */ forwardRef(({ classNames, data: ref, location, debug }, forwardedRef) => {
|
|
153
|
-
const rootRef = useRef(null);
|
|
154
|
-
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
155
|
-
const dragHandleRef = useRef(null);
|
|
156
|
-
const object = ref.target;
|
|
157
|
-
if (!object) {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
|
|
161
|
-
asChild: true,
|
|
162
|
-
dragHandle: dragHandleRef.current,
|
|
163
|
-
id: ref.dxn.toString(),
|
|
164
|
-
data: ref,
|
|
165
|
-
location,
|
|
166
|
-
debug
|
|
167
|
-
}, /* @__PURE__ */ React2.createElement(Focus.Group, {
|
|
168
|
-
asChild: true
|
|
169
|
-
}, /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
170
|
-
classNames,
|
|
171
|
-
onClick: () => rootRef.current?.focus(),
|
|
172
|
-
ref: composedRef
|
|
173
|
-
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
|
|
174
|
-
ref: dragHandleRef
|
|
175
|
-
}), /* @__PURE__ */ React2.createElement(Card.Title, null, object.name), /* @__PURE__ */ React2.createElement(Card.Menu, {
|
|
176
|
-
context: object
|
|
177
|
-
})), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
178
|
-
icon: "ph--note--regular",
|
|
179
|
-
classNames: "text-description"
|
|
180
|
-
}, object.description), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
181
|
-
icon: "ph--tag--regular"
|
|
182
|
-
}, object.label && /* @__PURE__ */ React2.createElement("div", {
|
|
183
|
-
role: "none",
|
|
184
|
-
className: "flex shrink-0 gap-1 text-xs items-center"
|
|
185
|
-
}, /* @__PURE__ */ React2.createElement(Tag, {
|
|
186
|
-
palette: getHashStyles(object.label).hue
|
|
187
|
-
}, object.label))))));
|
|
188
|
-
});
|
|
189
|
-
Item.displayName = "Item";
|
|
190
|
-
var Placeholder = (props) => {
|
|
191
|
-
return /* @__PURE__ */ React2.createElement(Mosaic.Placeholder, {
|
|
192
|
-
...props,
|
|
193
|
-
classNames: styles.placeholder.root
|
|
194
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
195
|
-
className: mx("flex bs-full border border-dashed border-separator rounded-sm", styles.placeholder.content)
|
|
196
|
-
}));
|
|
197
|
-
};
|
|
198
|
-
Placeholder.displayName = "Placeholder";
|
|
199
|
-
var Debug = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
200
|
-
const { containers, dragging } = useRootContext(Debug.displayName);
|
|
201
|
-
const counter = useRef(0);
|
|
202
|
-
return /* @__PURE__ */ React2.createElement(Json, {
|
|
203
|
-
data: {
|
|
204
|
-
containers,
|
|
205
|
-
dragging,
|
|
206
|
-
count: counter.current++
|
|
207
|
-
},
|
|
208
|
-
classNames: mx("text-xs", classNames),
|
|
209
|
-
ref: forwardedRef
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
Debug.displayName = "Debug";
|
|
213
|
-
var Board = {
|
|
214
|
-
Root,
|
|
215
|
-
Column,
|
|
216
|
-
Item,
|
|
217
|
-
Placeholder,
|
|
218
|
-
Debug
|
|
219
|
-
};
|
|
220
32
|
|
|
221
33
|
// src/testing/CardContainer.tsx
|
|
222
34
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
223
|
-
import
|
|
35
|
+
import React2 from "react";
|
|
224
36
|
import { Icon, Popover } from "@dxos/react-ui";
|
|
225
37
|
import { ResizeHandle, resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
226
38
|
var DEFAULT_BLOCK_SIZE = 22;
|
|
227
39
|
var MIN_BLOCK_SIZE = 8;
|
|
228
|
-
var CardContainer = ({ children, icon = "ph--
|
|
40
|
+
var CardContainer = ({ children, role, icon = "ph--arrow-line-down--regular" }) => {
|
|
229
41
|
switch (role) {
|
|
230
|
-
case "
|
|
231
|
-
return /* @__PURE__ */
|
|
42
|
+
case "popover":
|
|
43
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
44
|
+
role: "none",
|
|
45
|
+
className: "flex justify-center"
|
|
46
|
+
}, /* @__PURE__ */ React2.createElement(PopoverCardContainer, {
|
|
232
47
|
icon
|
|
233
|
-
}, children);
|
|
234
|
-
case "
|
|
48
|
+
}, children));
|
|
49
|
+
case "intrinsic":
|
|
235
50
|
default:
|
|
236
|
-
return /* @__PURE__ */
|
|
51
|
+
return /* @__PURE__ */ React2.createElement(IntrinsicCardContainer, null, children);
|
|
237
52
|
}
|
|
238
53
|
};
|
|
239
|
-
var
|
|
240
|
-
|
|
241
|
-
return /* @__PURE__ */ React3.createElement(Popover.Root, {
|
|
54
|
+
var PopoverCardContainer = ({ children, icon = "ph--arrow-line-down--regular" }) => {
|
|
55
|
+
return /* @__PURE__ */ React2.createElement(Popover.Root, {
|
|
242
56
|
open: true
|
|
243
|
-
}, /* @__PURE__ */
|
|
244
|
-
onOpenAutoFocus: (event) => event.preventDefault()
|
|
245
|
-
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, {
|
|
246
|
-
classNames: "popover-card-width"
|
|
247
|
-
}, children), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)), /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
57
|
+
}, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
248
58
|
asChild: true
|
|
249
|
-
}, /* @__PURE__ */
|
|
59
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
250
60
|
icon,
|
|
251
61
|
size: 5
|
|
252
|
-
}))
|
|
62
|
+
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
63
|
+
onOpenAutoFocus: (event) => event.preventDefault()
|
|
64
|
+
}, /* @__PURE__ */ React2.createElement(Popover.Viewport, {
|
|
65
|
+
classNames: "dx-card-popover"
|
|
66
|
+
}, children), /* @__PURE__ */ React2.createElement(Popover.Arrow, null))));
|
|
253
67
|
};
|
|
254
68
|
var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeChange }) => {
|
|
255
69
|
const [size = DEFAULT_BLOCK_SIZE, setSize] = useControllableState({
|
|
@@ -257,11 +71,15 @@ var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeCha
|
|
|
257
71
|
defaultProp: defaultSize,
|
|
258
72
|
onChange: onSizeChange
|
|
259
73
|
});
|
|
260
|
-
return /* @__PURE__ */
|
|
261
|
-
|
|
74
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
75
|
+
role: "none",
|
|
76
|
+
className: "relative p-2 grid overflow-hidden border-2 border-dashed border-green-500 rounded-lg",
|
|
262
77
|
style: sizeStyle(size, "horizontal"),
|
|
263
78
|
...resizeAttributes
|
|
264
|
-
},
|
|
79
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
80
|
+
role: "none",
|
|
81
|
+
className: "flex flex-col w-full h-full overflow-hidden"
|
|
82
|
+
}, children), /* @__PURE__ */ React2.createElement(ResizeHandle, {
|
|
265
83
|
side: "inline-end",
|
|
266
84
|
fallbackSize: DEFAULT_BLOCK_SIZE,
|
|
267
85
|
minSize: MIN_BLOCK_SIZE,
|
|
@@ -271,34 +89,45 @@ var IntrinsicCardContainer = ({ children, defaultSize, size: propSize, onSizeCha
|
|
|
271
89
|
};
|
|
272
90
|
|
|
273
91
|
// src/testing/DefaultStackTile.tsx
|
|
274
|
-
import
|
|
275
|
-
import { Obj
|
|
276
|
-
import {
|
|
92
|
+
import React3, { useMemo, useRef, useState } from "react";
|
|
93
|
+
import { Obj } from "@dxos/echo";
|
|
94
|
+
import { Card, Toolbar } from "@dxos/react-ui";
|
|
95
|
+
import { Menu, createMenuAction } from "@dxos/react-ui-menu";
|
|
96
|
+
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
277
97
|
var DefaultStackTile = (props) => {
|
|
278
|
-
const dragHandleRef =
|
|
279
|
-
const [open, setOpen] =
|
|
280
|
-
|
|
98
|
+
const dragHandleRef = useRef(null);
|
|
99
|
+
const [open, setOpen] = useState(false);
|
|
100
|
+
const menuItems = useMemo(() => [
|
|
101
|
+
createMenuAction("toggle-details", () => setOpen((prev) => !prev), {
|
|
102
|
+
label: open ? "Hide details" : "Show details",
|
|
103
|
+
icon: "ph--placeholder--regular"
|
|
104
|
+
})
|
|
105
|
+
], [
|
|
106
|
+
open
|
|
107
|
+
]);
|
|
108
|
+
return /* @__PURE__ */ React3.createElement(Mosaic.Tile, {
|
|
281
109
|
...props,
|
|
282
|
-
className: "border border-separator rounded-
|
|
283
|
-
}, /* @__PURE__ */
|
|
110
|
+
className: "border border-separator rounded-xs font-mono"
|
|
111
|
+
}, /* @__PURE__ */ React3.createElement(Menu.Root, null, /* @__PURE__ */ React3.createElement(Card.Toolbar, null, /* @__PURE__ */ React3.createElement(Card.DragHandle, {
|
|
284
112
|
ref: dragHandleRef
|
|
285
|
-
}), /* @__PURE__ */
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
113
|
+
}), /* @__PURE__ */ React3.createElement(Card.Title, null, Obj.getLabel(props.data) ?? props.data.id), /* @__PURE__ */ React3.createElement(Menu.Trigger, {
|
|
114
|
+
asChild: true,
|
|
115
|
+
disabled: !menuItems?.length
|
|
116
|
+
}, /* @__PURE__ */ React3.createElement(Toolbar.IconButton, {
|
|
117
|
+
iconOnly: true,
|
|
118
|
+
variant: "ghost",
|
|
119
|
+
icon: "ph--dots-three-vertical--regular",
|
|
120
|
+
label: "Menu"
|
|
121
|
+
})), /* @__PURE__ */ React3.createElement(Menu.Content, {
|
|
122
|
+
items: menuItems
|
|
123
|
+
}))), open && /* @__PURE__ */ React3.createElement(Card.Row, null, /* @__PURE__ */ React3.createElement(Json, {
|
|
293
124
|
data: props.data,
|
|
294
125
|
classNames: "text-xs"
|
|
295
126
|
})));
|
|
296
127
|
};
|
|
297
128
|
DefaultStackTile.displayName = "DefaultStackTile";
|
|
298
129
|
export {
|
|
299
|
-
Board,
|
|
300
130
|
CardContainer,
|
|
301
|
-
Debug,
|
|
302
131
|
DefaultStackTile,
|
|
303
132
|
IntrinsicCardContainer,
|
|
304
133
|
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
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
2
|
+
import React, { type PropsWithChildren, type ReactElement, type Ref as ReactRef } from 'react';
|
|
3
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
+
import { type GetId, type MosaicEventHandler, type MosaicPlaceholderProps, type MosaicStackProps } from '../Mosaic';
|
|
5
|
+
import { type BoardColumnProps, useBoardColumn } from './Column';
|
|
6
|
+
import { type BoardItemProps } from './Item';
|
|
7
|
+
export interface BoardModel<TColumn = any, TItem = any> {
|
|
8
|
+
getColumnId: GetId<TColumn>;
|
|
9
|
+
getItemId: GetId<TItem>;
|
|
10
|
+
isColumn: (obj: unknown) => obj is TColumn;
|
|
11
|
+
isItem: (obj: unknown) => obj is TItem;
|
|
12
|
+
columns: Atom.Atom<readonly TColumn[] | TColumn[]>;
|
|
13
|
+
items: (column: TColumn) => Atom.Atom<TItem[]>;
|
|
14
|
+
getColumns: () => TColumn[];
|
|
15
|
+
getItems: (column: TColumn) => TItem[];
|
|
16
|
+
onColumnCreate?: () => Promise<TColumn>;
|
|
17
|
+
onColumnDelete?: (column: TColumn) => void;
|
|
18
|
+
onItemCreate?: (column: TColumn) => Promise<TItem>;
|
|
19
|
+
onItemDelete?: (column: TColumn, item: TItem) => void;
|
|
20
|
+
}
|
|
21
|
+
type BoardContextValue<TColumn = any, TItem = any> = {
|
|
22
|
+
model: BoardModel<TColumn, TItem>;
|
|
23
|
+
};
|
|
24
|
+
/** Hook to read the board model from context (e.g. in custom column tiles). Pass TColumn and TItem for typed model. */
|
|
25
|
+
declare function useBoard<TColumn = any, TItem = any>(displayName?: string): BoardContextValue<TColumn, TItem>;
|
|
26
|
+
type BoardRootProps<TColumn = any, TItem = any> = PropsWithChildren<BoardContextValue<TColumn, TItem>>;
|
|
27
|
+
type BoardContentProps<TColumn = any> = ThemedClassName<{
|
|
28
|
+
id: string;
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
eventHandler?: MosaicEventHandler<TColumn>;
|
|
31
|
+
Tile?: MosaicStackProps<TColumn>['Tile'];
|
|
32
|
+
}>;
|
|
33
|
+
export declare const BoardDebug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
|
|
34
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
35
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
export declare const Board: {
|
|
37
|
+
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => ReactElement;
|
|
38
|
+
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
|
|
39
|
+
ref?: ReactRef<HTMLDivElement>;
|
|
40
|
+
}) => ReactElement;
|
|
41
|
+
Column: {
|
|
42
|
+
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
|
|
43
|
+
children?: React.ReactNode | undefined;
|
|
44
|
+
} & {
|
|
45
|
+
dragHandleRef?: React.RefObject<HTMLButtonElement | null>;
|
|
46
|
+
}) & {
|
|
47
|
+
ref?: ReactRef<HTMLDivElement>;
|
|
48
|
+
}) => ReactElement;
|
|
49
|
+
Header: React.ForwardRefExoticComponent<Omit<{
|
|
50
|
+
label: string;
|
|
51
|
+
dragHandleRef: ReactRef<HTMLButtonElement>;
|
|
52
|
+
}, "className"> & {
|
|
53
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
54
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
Body: {
|
|
56
|
+
({ data, eventHandler, Tile, debug }: Pick<BoardColumnProps<any>, "data"> & Pick<import("..").MosaicContainerProps, "debug" | "eventHandler"> & {
|
|
57
|
+
Tile?: MosaicStackProps<import("@dxos/echo/Obj").Unknown>["Tile"];
|
|
58
|
+
}): React.JSX.Element;
|
|
59
|
+
displayName: string;
|
|
60
|
+
};
|
|
61
|
+
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
|
|
62
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
63
|
+
} & {
|
|
64
|
+
data?: any;
|
|
65
|
+
onAdd?: () => void;
|
|
66
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
67
|
+
};
|
|
68
|
+
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
|
|
69
|
+
ref?: ReactRef<HTMLDivElement>;
|
|
70
|
+
}) => ReactElement;
|
|
71
|
+
Placeholder: {
|
|
72
|
+
(props: MosaicPlaceholderProps<number>): React.JSX.Element;
|
|
73
|
+
displayName: string;
|
|
74
|
+
};
|
|
75
|
+
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
|
|
76
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
77
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
78
|
+
};
|
|
79
|
+
export { useBoard, useBoardColumn };
|
|
80
|
+
export type { BoardRootProps, BoardContentProps, BoardColumnProps, BoardItemProps };
|
|
81
|
+
//# sourceMappingURL=Board.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Board.d.ts","sourceRoot":"","sources":["../../../../../src/components/Board/Board.tsx"],"names":[],"mappings":"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"}
|
|
@@ -2,6 +2,7 @@ import { type StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
type StoryProps = {
|
|
4
4
|
columns?: number;
|
|
5
|
+
items?: (column: number) => number;
|
|
5
6
|
debug?: boolean;
|
|
6
7
|
};
|
|
7
8
|
declare const meta: {
|
|
@@ -10,6 +11,15 @@ declare const meta: {
|
|
|
10
11
|
decorators: import("@storybook/react").Decorator[];
|
|
11
12
|
parameters: {
|
|
12
13
|
layout: string;
|
|
14
|
+
translations: [{
|
|
15
|
+
readonly 'en-US': {
|
|
16
|
+
readonly "@dxos/react-ui-mosaic": {
|
|
17
|
+
readonly 'action menu label': "Actions";
|
|
18
|
+
readonly 'add item label': "Add item";
|
|
19
|
+
readonly 'delete menu label': "Delete";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}];
|
|
13
23
|
};
|
|
14
24
|
argTypes: {
|
|
15
25
|
columns: {
|
|
@@ -23,5 +33,9 @@ declare const meta: {
|
|
|
23
33
|
export default meta;
|
|
24
34
|
type Story = StoryObj<typeof meta>;
|
|
25
35
|
export declare const Default: Story;
|
|
36
|
+
export declare const SingleColumn: Story;
|
|
37
|
+
export declare const Empty: Story;
|
|
38
|
+
export declare const EmptyColumn: Story;
|
|
26
39
|
export declare const Debug: Story;
|
|
27
|
-
|
|
40
|
+
export declare const Spec: Story;
|
|
41
|
+
//# sourceMappingURL=Board.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Board.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Board/Board.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAA8B,MAAM,OAAO,CAAC;AA8CnD,KAAK,UAAU,GAAG;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAsIF,QAAA,MAAM,IAAI;;wBAxB+B,UAAU;;;;;;;;;;;;;;;;;;;;;;CAqDd,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAU,CAAC;AAE/B,eAAO,MAAM,WAAW,EAAE,KAIzB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAkBlB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { type PropsWithChildren, type ReactElement, type Ref as ReactRef, type RefObject } from 'react';
|
|
2
|
+
import { Obj } from '@dxos/echo';
|
|
3
|
+
import { type MosaicContainerProps, type MosaicStackProps, type MosaicTileProps } from '../Mosaic';
|
|
4
|
+
export type BoardColumnContextValue<TColumn = unknown> = {
|
|
5
|
+
column: TColumn;
|
|
6
|
+
};
|
|
7
|
+
/** Returns the current column when rendered inside a board column (e.g., in column header or item tile). */
|
|
8
|
+
export declare function useBoardColumn<TColumn = unknown>(): TColumn | undefined;
|
|
9
|
+
type BoardColumnProps<TColumn = any> = Pick<MosaicTileProps<TColumn>, 'classNames' | 'location' | 'data' | 'debug'>;
|
|
10
|
+
type BoardColumnRootProps<TColumn = any> = PropsWithChildren<BoardColumnProps<TColumn>> & {
|
|
11
|
+
dragHandleRef?: RefObject<HTMLButtonElement | null>;
|
|
12
|
+
};
|
|
13
|
+
type BoardColumnBodyProps = Pick<BoardColumnProps, 'data'> & Pick<MosaicContainerProps, 'eventHandler' | 'debug'> & {
|
|
14
|
+
Tile?: MosaicStackProps<Obj.Unknown>['Tile'];
|
|
15
|
+
};
|
|
16
|
+
declare const DefaultBoardColumn: React.ForwardRefExoticComponent<BoardColumnProps<any> & Pick<BoardColumnBodyProps, "Tile"> & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
export declare const BoardColumn: {
|
|
18
|
+
Root: <TColumn = unknown>(props: BoardColumnRootProps<TColumn> & {
|
|
19
|
+
ref?: ReactRef<HTMLDivElement>;
|
|
20
|
+
}) => ReactElement;
|
|
21
|
+
Header: React.ForwardRefExoticComponent<Omit<{
|
|
22
|
+
label: string;
|
|
23
|
+
dragHandleRef: ReactRef<HTMLButtonElement>;
|
|
24
|
+
}, "className"> & {
|
|
25
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
26
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
Body: {
|
|
28
|
+
({ data, eventHandler, Tile, debug }: BoardColumnBodyProps): React.JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
31
|
+
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
|
|
32
|
+
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
33
|
+
} & {
|
|
34
|
+
data?: any;
|
|
35
|
+
onAdd?: () => void;
|
|
36
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
37
|
+
};
|
|
38
|
+
export { DefaultBoardColumn };
|
|
39
|
+
export { type BoardColumnProps };
|
|
40
|
+
//# sourceMappingURL=Column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Column.d.ts","sourceRoot":"","sources":["../../../../../src/components/Board/Column.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EACZ,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,GAAG,IAAI,QAAQ,EACpB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,GAAG,EAAO,MAAM,YAAY,CAAC;AAStC,OAAO,EAAU,KAAK,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAW3G,MAAM,MAAM,uBAAuB,CAAC,OAAO,GAAG,OAAO,IAAI;IACvD,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAOF,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,OAAO,GAAG,OAAO,KAAK,OAAO,GAAG,SAAS,CAGvE;AAED,KAAK,gBAAgB,CAAC,OAAO,GAAG,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAQpH,KAAK,oBAAoB,CAAC,OAAO,GAAG,GAAG,IAAI,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG;IACxF,aAAa,CAAC,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CACrD,CAAC;AAqGF,KAAK,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GACxD,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG;IACrD,IAAI,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAyEJ,QAAA,MAAM,kBAAkB,mIA2CvB,CAAC;AAQF,eAAO,MAAM,WAAW;WA9LyB,OAAO,mBAC/C,oBAAoB,CAAC,OAAO,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAA;KAAE,KACtE,YAAY;;eAQsC,MAAM;uBAAiB,QAAQ,CAAC,iBAAiB,CAAC;;;;;8CA0D/B,oBAAoB;;;;;;eAgCrF,GAAG;gBACF,MAAM,IAAI;;CA8FnB,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,OAAO,EAAE,KAAK,gBAAgB,EAAE,CAAC"}
|