@dxos/react-ui-mosaic 0.8.4-main.2244d791bb → 0.8.4-main.4a85c3132b
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-XNANTBOP.mjs → chunk-7S4PIFKU.mjs} +58 -486
- package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +148 -135
- 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 +47 -28
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-LWXG4JVG.mjs → chunk-MK6KU66S.mjs} +58 -486
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +148 -135
- 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 +47 -28
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/components/Board/Board.d.ts +5 -6
- package/dist/types/src/components/Board/Board.d.ts.map +1 -1
- package/dist/types/src/components/Board/Board.stories.d.ts +5 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
- package/dist/types/src/components/Board/Column.d.ts +11 -6
- package/dist/types/src/components/Board/Column.d.ts.map +1 -1
- package/dist/types/src/components/Board/Item.d.ts.map +1 -1
- 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 +2 -2
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Stack.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Tile.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/src/testing/CardContainer.d.ts +4 -3
- package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
- package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -25
- package/src/components/Board/Board.stories.tsx +28 -19
- package/src/components/Board/Board.tsx +6 -8
- package/src/components/Board/Column.tsx +142 -112
- package/src/components/Board/Item.tsx +58 -26
- package/src/components/Focus/Focus.tsx +19 -8
- package/src/components/Focus/index.ts +0 -2
- package/src/components/Mosaic/Container.tsx +6 -6
- package/src/components/Mosaic/Placeholder.tsx +7 -7
- package/src/components/Mosaic/Root.tsx +3 -3
- package/src/components/Mosaic/Stack.stories.tsx +3 -3
- package/src/components/Mosaic/Stack.tsx +5 -5
- package/src/components/Mosaic/Tile.tsx +9 -7
- package/src/components/Mosaic/extension.ts +1 -1
- package/src/components/Mosaic/styles.ts +8 -8
- package/src/components/index.ts +0 -2
- package/src/playwright/board-manager.ts +14 -4
- package/src/playwright/index.ts +13 -0
- package/src/playwright/playwright.config.ts +2 -1
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/CardContainer.tsx +22 -15
- package/src/testing/DefaultStackTile.tsx +26 -15
- package/src/testing/types.ts +2 -2
- package/src/translations.ts +1 -0
- package/dist/lib/browser/chunk-XNANTBOP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LWXG4JVG.mjs.map +0 -7
- package/dist/types/src/components/Card/Card.d.ts +0 -123
- 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/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 -21
- 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
|
@@ -21,22 +21,6 @@ var useVisibleItems = ({ id, items, dragging, getId }) => {
|
|
|
21
21
|
return visibleItems;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
// src/components/Focus/styles.ts
|
|
25
|
-
var styles = {
|
|
26
|
-
container: {
|
|
27
|
-
root: [
|
|
28
|
-
// TODO(burdon): Option for border/rounded; ring/outline vs border?
|
|
29
|
-
"outline-none border border-separator md:rounded-sm",
|
|
30
|
-
// Focus (e.g., via tabster).
|
|
31
|
-
"focus:!border-accentSurface",
|
|
32
|
-
// Active (e.g., drop target).
|
|
33
|
-
"data-[focus-state=active]:border-neutralFocusIndicator",
|
|
34
|
-
// Error
|
|
35
|
-
"data-[focus-state=error]:border-rose-500"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
24
|
// src/components/Focus/Focus.tsx
|
|
41
25
|
import { useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from "@fluentui/react-tabster";
|
|
42
26
|
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
@@ -50,7 +34,7 @@ var useFocus = () => useContext(FocusContext);
|
|
|
50
34
|
var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChild, orientation = "vertical", ...props }, forwardedRef) => {
|
|
51
35
|
const rootRef = useRef(null);
|
|
52
36
|
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
53
|
-
const
|
|
37
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
54
38
|
const focusableGroupAttrs = useFocusableGroup({
|
|
55
39
|
tabBehavior: "limited-trap-focus"
|
|
56
40
|
});
|
|
@@ -64,14 +48,23 @@ var Group = /* @__PURE__ */ forwardRef(({ classNames, className, children, asChi
|
|
|
64
48
|
value: {
|
|
65
49
|
setFocus: setState
|
|
66
50
|
}
|
|
67
|
-
}, /* @__PURE__ */ React.createElement(
|
|
68
|
-
|
|
69
|
-
className: mx(styles.container.root, className, classNames),
|
|
51
|
+
}, /* @__PURE__ */ React.createElement(Comp, {
|
|
52
|
+
...props,
|
|
70
53
|
...tabsterAttrs,
|
|
71
54
|
...state && {
|
|
72
55
|
[`data-${FOCUS_STATE_ATTR}`]: state
|
|
73
56
|
},
|
|
74
|
-
|
|
57
|
+
tabIndex: 0,
|
|
58
|
+
className: mx([
|
|
59
|
+
// TODO(burdon): Option for border/rounded; ring/outline vs border?
|
|
60
|
+
"outline-hidden border border-separator md:rounded-xs",
|
|
61
|
+
// Focus (e.g., via tabster).
|
|
62
|
+
"focus:!border-accent-surface",
|
|
63
|
+
// Active (e.g., drop target).
|
|
64
|
+
"data-[focus-state=active]:border-neutral-focus-indicator",
|
|
65
|
+
// Error
|
|
66
|
+
"data-[focus-state=error]:border-rose-500"
|
|
67
|
+
], className, classNames),
|
|
75
68
|
ref: composedRef
|
|
76
69
|
}, children));
|
|
77
70
|
});
|
|
@@ -80,7 +73,7 @@ var Focus = {
|
|
|
80
73
|
};
|
|
81
74
|
|
|
82
75
|
// src/components/Mosaic/styles.ts
|
|
83
|
-
var
|
|
76
|
+
var styles = {
|
|
84
77
|
placeholder: {
|
|
85
78
|
root: [
|
|
86
79
|
"group opacity-0",
|
|
@@ -88,10 +81,10 @@ var styles2 = {
|
|
|
88
81
|
'group-data-[mosaic-debug="true"]:bg-orange-500',
|
|
89
82
|
"data-[mosaic-placeholder-state=active]:opacity-100",
|
|
90
83
|
"data-[mosaic-placeholder-orientation=vertical]:snap-start",
|
|
91
|
-
"data-[mosaic-placeholder-orientation=vertical]:
|
|
92
|
-
"data-[mosaic-placeholder-orientation=vertical]:data-[mosaic-placeholder-state=active]:
|
|
93
|
-
"data-[mosaic-placeholder-orientation=horizontal]:
|
|
94
|
-
"data-[mosaic-placeholder-orientation=horizontal]:data-[mosaic-placeholder-state=active]:
|
|
84
|
+
"data-[mosaic-placeholder-orientation=vertical]:py-1",
|
|
85
|
+
"data-[mosaic-placeholder-orientation=vertical]:data-[mosaic-placeholder-state=active]:py-2.5",
|
|
86
|
+
"data-[mosaic-placeholder-orientation=horizontal]:px-1",
|
|
87
|
+
"data-[mosaic-placeholder-orientation=horizontal]:data-[mosaic-placeholder-state=active]:px-2.5"
|
|
95
88
|
],
|
|
96
89
|
content: [
|
|
97
90
|
"transition-all duration-0",
|
|
@@ -99,10 +92,10 @@ var styles2 = {
|
|
|
99
92
|
// TODO(burdon): Flickers when start to drag since source is removed and then the placeholder shows up.
|
|
100
93
|
// - Use absolute positioning?
|
|
101
94
|
// 'group-data-[mosaic-placeholder-state=active]:duration-200',
|
|
102
|
-
"group-data-[mosaic-placeholder-orientation=vertical]:
|
|
103
|
-
"group-data-[mosaic-placeholder-orientation=vertical]:group-data-[mosaic-placeholder-state=active]:
|
|
104
|
-
"group-data-[mosaic-placeholder-orientation=horizontal]:
|
|
105
|
-
"group-data-[mosaic-placeholder-orientation=horizontal]:group-data-[mosaic-placeholder-state=active]:
|
|
95
|
+
"group-data-[mosaic-placeholder-orientation=vertical]:h-0",
|
|
96
|
+
"group-data-[mosaic-placeholder-orientation=vertical]:group-data-[mosaic-placeholder-state=active]:h-[var(--mosaic-placeholder-height)]",
|
|
97
|
+
"group-data-[mosaic-placeholder-orientation=horizontal]:w-0",
|
|
98
|
+
"group-data-[mosaic-placeholder-orientation=horizontal]:group-data-[mosaic-placeholder-state=active]:w-[var(--mosaic-placeholder-width)]"
|
|
106
99
|
]
|
|
107
100
|
}
|
|
108
101
|
};
|
|
@@ -129,7 +122,7 @@ var MOSAIC_ROOT_DEBUG_ATTR = "mosaic-debug";
|
|
|
129
122
|
var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, debug }, forwardedRef) => {
|
|
130
123
|
const rootRef = useRef2(null);
|
|
131
124
|
const composedRef = useComposedRefs2(rootRef, forwardedRef);
|
|
132
|
-
const
|
|
125
|
+
const Comp = asChild ? Slot2 : Primitive2.div;
|
|
133
126
|
const [handlers, setHandlers] = useState2({});
|
|
134
127
|
const [dragging, setDragging] = useState2();
|
|
135
128
|
const getSourceHandler = useCallback((source) => {
|
|
@@ -360,7 +353,7 @@ var MosaicRoot = /* @__PURE__ */ forwardRef2(({ classNames, children, asChild, d
|
|
|
360
353
|
};
|
|
361
354
|
}),
|
|
362
355
|
dragging
|
|
363
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
356
|
+
}, /* @__PURE__ */ React2.createElement(Comp, {
|
|
364
357
|
className: mx2("group", classNames),
|
|
365
358
|
[`data-${MOSAIC_ROOT_DEBUG_ATTR}`]: debug,
|
|
366
359
|
ref: composedRef
|
|
@@ -389,7 +382,7 @@ var counter = 0;
|
|
|
389
382
|
var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, children, eventHandler: eventHandlerProp, orientation = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
|
|
390
383
|
const rootRef = useRef3(null);
|
|
391
384
|
const composedRef = useComposedRefs3(rootRef, forwardedRef);
|
|
392
|
-
const
|
|
385
|
+
const Comp = asChild ? Slot3 : Primitive3.div;
|
|
393
386
|
const eventHandler = useMemo2(() => eventHandlerProp ?? {
|
|
394
387
|
id: `mosaic-container-${counter++}`
|
|
395
388
|
}, [
|
|
@@ -544,8 +537,8 @@ var MosaicContainer = /* @__PURE__ */ forwardRef3(({ classNames, className, chil
|
|
|
544
537
|
scrolling,
|
|
545
538
|
activeLocation,
|
|
546
539
|
setActiveLocation
|
|
547
|
-
}, /* @__PURE__ */ React3.createElement(
|
|
548
|
-
className: mx3("
|
|
540
|
+
}, /* @__PURE__ */ React3.createElement(Comp, {
|
|
541
|
+
className: mx3("h-full", className, classNames),
|
|
549
542
|
style: {
|
|
550
543
|
[MOSAIC_CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
|
|
551
544
|
[MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
|
|
@@ -573,10 +566,10 @@ import { mx as mx4 } from "@dxos/ui-theme";
|
|
|
573
566
|
var MOSAIC_TILE_NAME = "Mosaic.Tile";
|
|
574
567
|
var [MosaicTileContextProvider, useMosaicTileContext] = createContext4("MosaicTile");
|
|
575
568
|
var MOSAIC_TILE_STATE_ATTR = "mosaic-tile-state";
|
|
576
|
-
var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
|
|
569
|
+
var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _, ...props }, forwardedRef) => {
|
|
577
570
|
const rootRef = useRef4(null);
|
|
578
571
|
const composedRef = composeRefs(rootRef, forwardedRef);
|
|
579
|
-
const
|
|
572
|
+
const Comp = asChild ? Slot4 : Primitive4.div;
|
|
580
573
|
const { id: containerId, eventHandler, orientation, scrolling, setActiveLocation } = useMosaicContainerContext(MOSAIC_TILE_NAME);
|
|
581
574
|
const [state, setState] = useState4({
|
|
582
575
|
type: "idle"
|
|
@@ -707,12 +700,13 @@ var MosaicTile = /* @__PURE__ */ forwardRef4(({ classNames, className, children,
|
|
|
707
700
|
]);
|
|
708
701
|
return /* @__PURE__ */ React4.createElement(MosaicTileContextProvider, {
|
|
709
702
|
state
|
|
710
|
-
}, /* @__PURE__ */ React4.createElement(
|
|
703
|
+
}, /* @__PURE__ */ React4.createElement(Comp, {
|
|
704
|
+
...props,
|
|
711
705
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
712
706
|
role: "listitem",
|
|
713
707
|
className: mx4("relative", className, classNames),
|
|
714
708
|
ref: composedRef
|
|
715
|
-
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(
|
|
709
|
+
}, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(Comp, {
|
|
716
710
|
// NOTE: Use to control appearance while dragging.
|
|
717
711
|
[`data-${MOSAIC_TILE_STATE_ATTR}`]: state.type,
|
|
718
712
|
// TODO(burdon): Configure drop animation.
|
|
@@ -727,7 +721,7 @@ MosaicTile.displayName = MOSAIC_TILE_NAME;
|
|
|
727
721
|
|
|
728
722
|
// src/components/Mosaic/Placeholder.tsx
|
|
729
723
|
import { dropTargetForElements as dropTargetForElements3 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
730
|
-
import { DropIndicator as
|
|
724
|
+
import { DropIndicator as NaturalDropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
731
725
|
import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
|
|
732
726
|
import { Slot as Slot5 } from "@radix-ui/react-slot";
|
|
733
727
|
import React5, { useLayoutEffect as useLayoutEffect2, useMemo as useMemo4, useRef as useRef5 } from "react";
|
|
@@ -737,7 +731,7 @@ var MOSAIC_PLACEHOLDER_ORIENTATION_ATTR = "mosaic-placeholder-orientation";
|
|
|
737
731
|
var MOSAIC_PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
|
|
738
732
|
var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertical", location }) => {
|
|
739
733
|
const rootRef = useRef5(null);
|
|
740
|
-
const
|
|
734
|
+
const Comp = asChild ? Slot5 : Primitive5.div;
|
|
741
735
|
const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useMosaicContainerContext(MOSAIC_PLACEHOLDER_NAME);
|
|
742
736
|
const data = useMemo4(() => ({
|
|
743
737
|
type: "placeholder",
|
|
@@ -777,7 +771,7 @@ var MosaicPlaceholder = ({ classNames, children, asChild, orientation = "vertica
|
|
|
777
771
|
scrolling,
|
|
778
772
|
setActiveLocation
|
|
779
773
|
]);
|
|
780
|
-
return /* @__PURE__ */ React5.createElement(
|
|
774
|
+
return /* @__PURE__ */ React5.createElement(Comp, {
|
|
781
775
|
[`data-${MOSAIC_PLACEHOLDER_ORIENTATION_ATTR}`]: orientation,
|
|
782
776
|
[`data-${MOSAIC_PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
|
|
783
777
|
role: "none",
|
|
@@ -789,7 +783,7 @@ MosaicPlaceholder.displayName = MOSAIC_PLACEHOLDER_NAME;
|
|
|
789
783
|
var DROP_INDICATOR_NAME = "Mosaic.DropIndicator";
|
|
790
784
|
var MosaicDropIndicator = (props) => {
|
|
791
785
|
const { state } = useMosaicTileContext(DROP_INDICATOR_NAME);
|
|
792
|
-
return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(
|
|
786
|
+
return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(NaturalDropIndicator, {
|
|
793
787
|
...props,
|
|
794
788
|
edge: state.closestEdge
|
|
795
789
|
}) : null;
|
|
@@ -798,429 +792,12 @@ MosaicDropIndicator.displayName = DROP_INDICATOR_NAME;
|
|
|
798
792
|
|
|
799
793
|
// src/components/Mosaic/Stack.tsx
|
|
800
794
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
801
|
-
import
|
|
795
|
+
import React6, { Fragment, forwardRef as forwardRef5 } from "react";
|
|
802
796
|
import { invariant } from "@dxos/invariant";
|
|
803
|
-
import { mx as mx8 } from "@dxos/ui-theme";
|
|
804
|
-
|
|
805
|
-
// src/translations.ts
|
|
806
|
-
var translationKey = "@dxos/react-ui-mosaic";
|
|
807
|
-
var translations = [
|
|
808
|
-
{
|
|
809
|
-
"en-US": {
|
|
810
|
-
[translationKey]: {
|
|
811
|
-
"add item label": "Add item",
|
|
812
|
-
"delete menu label": "Delete"
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
];
|
|
817
|
-
|
|
818
|
-
// src/components/Card/styles.ts
|
|
819
|
-
var styles3 = {
|
|
820
|
-
root: "group/card relative min-bs-[--rail-item] is-full card-min-width overflow-hidden",
|
|
821
|
-
border: "bg-cardSurface border border-separator dark:border-subduedSeparator rounded-sm dx-focus-ring-group-y-indicator",
|
|
822
|
-
/**
|
|
823
|
-
* Row grid.
|
|
824
|
-
* NOTE: Rows should provide their own line padding (since they may need to encapsulate buttons, etc.)
|
|
825
|
-
*/
|
|
826
|
-
grid_3: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
|
|
827
|
-
grid_2: "grid grid-cols-[var(--rail-item)_minmax(0,1fr)] gap-x-1",
|
|
828
|
-
// TODO(burdon): Address density.
|
|
829
|
-
grid_3_coarse: "grid grid-cols-[var(--l0-avatar-size)_minmax(0,1fr)_var(--rail-item)] gap-x-1",
|
|
830
|
-
poster: "max-bs-[200px]"
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
// src/components/Card/Card.tsx
|
|
834
|
-
import { Slot as Slot6 } from "@radix-ui/react-slot";
|
|
835
|
-
import React7, { createContext as createContext5, forwardRef as forwardRef5, useContext as useContext2 } from "react";
|
|
836
|
-
import { Button, DropdownMenu, Icon, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
837
|
-
import { mx as mx7 } from "@dxos/ui-theme";
|
|
838
|
-
|
|
839
|
-
// src/components/Image/Image.tsx
|
|
840
|
-
import React6, { useCallback as useCallback2, useRef as useRef6, useState as useState5 } from "react";
|
|
841
797
|
import { mx as mx6 } from "@dxos/ui-theme";
|
|
842
|
-
var cache = /* @__PURE__ */ new Map();
|
|
843
|
-
var Image = ({ classNames, src, alt = "", crossOrigin = "anonymous", sampleSize = 64, contrast = 0.9 }) => {
|
|
844
|
-
const [crossOriginState, setCrossOriginState] = useState5(crossOrigin);
|
|
845
|
-
const [dominantColor, setDominantColor] = useState5(void 0);
|
|
846
|
-
const [imageLoaded, setImageLoaded] = useState5(false);
|
|
847
|
-
const canvasRef = useRef6(null);
|
|
848
|
-
const handleImageError = () => {
|
|
849
|
-
setCrossOriginState(void 0);
|
|
850
|
-
};
|
|
851
|
-
const handleImageLoad = useCallback2(({ target }) => {
|
|
852
|
-
const rgb = cache.get(src);
|
|
853
|
-
if (rgb) {
|
|
854
|
-
setDominantColor(rgb);
|
|
855
|
-
setImageLoaded(true);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
const img = target;
|
|
859
|
-
if (!canvasRef.current) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
try {
|
|
863
|
-
const color = extractDominantColor(canvasRef.current, img, {
|
|
864
|
-
sampleSize,
|
|
865
|
-
contrast
|
|
866
|
-
});
|
|
867
|
-
if (color) {
|
|
868
|
-
const rgb2 = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
|
|
869
|
-
cache.set(src, rgb2);
|
|
870
|
-
setDominantColor(rgb2);
|
|
871
|
-
}
|
|
872
|
-
} catch {
|
|
873
|
-
setCrossOriginState(void 0);
|
|
874
|
-
}
|
|
875
|
-
setImageLoaded(true);
|
|
876
|
-
}, [
|
|
877
|
-
sampleSize,
|
|
878
|
-
contrast,
|
|
879
|
-
src
|
|
880
|
-
]);
|
|
881
|
-
return /* @__PURE__ */ React6.createElement("div", {
|
|
882
|
-
className: mx6(`relative flex is-full justify-center overflow-hidden transition-all duration-700`, classNames),
|
|
883
|
-
style: {
|
|
884
|
-
backgroundColor: dominantColor
|
|
885
|
-
}
|
|
886
|
-
}, /* @__PURE__ */ React6.createElement("canvas", {
|
|
887
|
-
ref: canvasRef,
|
|
888
|
-
style: {
|
|
889
|
-
display: "none"
|
|
890
|
-
},
|
|
891
|
-
"aria-hidden": "true"
|
|
892
|
-
}), /* @__PURE__ */ React6.createElement("div", {
|
|
893
|
-
className: "absolute inset-0 pointer-events-none",
|
|
894
|
-
style: {
|
|
895
|
-
background: dominantColor ? `radial-gradient(circle at center, transparent 30%, ${dominantColor} 100%)` : void 0,
|
|
896
|
-
transition: "opacity 0.7s ease-in-out",
|
|
897
|
-
opacity: 0.5
|
|
898
|
-
}
|
|
899
|
-
}), /* @__PURE__ */ React6.createElement("img", {
|
|
900
|
-
src,
|
|
901
|
-
alt,
|
|
902
|
-
crossOrigin: crossOriginState,
|
|
903
|
-
onError: handleImageError,
|
|
904
|
-
onLoad: handleImageLoad,
|
|
905
|
-
className: mx6("z-10 object-contain transition-opacity duration-500", classNames),
|
|
906
|
-
style: {
|
|
907
|
-
opacity: imageLoaded ? 1 : 0
|
|
908
|
-
}
|
|
909
|
-
}));
|
|
910
|
-
};
|
|
911
|
-
var extractDominantColor = (canvas, img, { sampleSize = 64, contrast = 0.95 }) => {
|
|
912
|
-
const ctx = canvas.getContext("2d");
|
|
913
|
-
if (!ctx) {
|
|
914
|
-
return null;
|
|
915
|
-
}
|
|
916
|
-
canvas.width = sampleSize;
|
|
917
|
-
canvas.height = sampleSize;
|
|
918
|
-
ctx.drawImage(img, 0, 0, sampleSize, sampleSize);
|
|
919
|
-
const imageData = ctx.getImageData(0, 0, sampleSize, sampleSize);
|
|
920
|
-
const pixels = imageData.data;
|
|
921
|
-
if (isTransparent(pixels, sampleSize)) {
|
|
922
|
-
return null;
|
|
923
|
-
}
|
|
924
|
-
let r = 0;
|
|
925
|
-
let g = 0;
|
|
926
|
-
let b = 0;
|
|
927
|
-
let totalWeight = 0;
|
|
928
|
-
const cornerSize = Math.floor(sampleSize * 0.125);
|
|
929
|
-
for (let y = 0; y < sampleSize; y++) {
|
|
930
|
-
for (let x = 0; x < sampleSize; x++) {
|
|
931
|
-
const isInTopLeft = x < cornerSize && y < cornerSize;
|
|
932
|
-
const isInTopRight = x >= sampleSize - cornerSize && y < cornerSize;
|
|
933
|
-
const isInBottomLeft = x < cornerSize && y >= sampleSize - cornerSize;
|
|
934
|
-
const isInBottomRight = x >= sampleSize - cornerSize && y >= sampleSize - cornerSize;
|
|
935
|
-
if (!isInTopLeft && !isInTopRight && !isInBottomLeft && !isInBottomRight) {
|
|
936
|
-
continue;
|
|
937
|
-
}
|
|
938
|
-
const i = (y * sampleSize + x) * 4;
|
|
939
|
-
const red = pixels[i];
|
|
940
|
-
const green = pixels[i + 1];
|
|
941
|
-
const blue = pixels[i + 2];
|
|
942
|
-
const alpha = pixels[i + 3];
|
|
943
|
-
if (alpha === 0) continue;
|
|
944
|
-
const max = Math.max(red, green, blue);
|
|
945
|
-
const min = Math.min(red, green, blue);
|
|
946
|
-
const saturation = max === 0 ? 0 : (max - min) / max;
|
|
947
|
-
const weight = 1 + saturation * 2;
|
|
948
|
-
r += red * weight;
|
|
949
|
-
g += green * weight;
|
|
950
|
-
b += blue * weight;
|
|
951
|
-
totalWeight += weight;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
if (totalWeight > 0) {
|
|
955
|
-
r = Math.round(Math.round(r / totalWeight) * contrast);
|
|
956
|
-
g = Math.round(Math.round(g / totalWeight) * contrast);
|
|
957
|
-
b = Math.round(Math.round(b / totalWeight) * contrast);
|
|
958
|
-
return [
|
|
959
|
-
r,
|
|
960
|
-
g,
|
|
961
|
-
b
|
|
962
|
-
];
|
|
963
|
-
}
|
|
964
|
-
return null;
|
|
965
|
-
};
|
|
966
|
-
var isTransparent = (pixels, sampleSize, threshold = 0.5) => {
|
|
967
|
-
let edgeTransparentPixels = 0;
|
|
968
|
-
const edgePixels = sampleSize * 4 - 4;
|
|
969
|
-
for (let x = 0; x < sampleSize; x++) {
|
|
970
|
-
const topIndex = x * 4;
|
|
971
|
-
if (pixels[topIndex + 3] === 0) edgeTransparentPixels++;
|
|
972
|
-
const bottomIndex = ((sampleSize - 1) * sampleSize + x) * 4;
|
|
973
|
-
if (pixels[bottomIndex + 3] === 0) edgeTransparentPixels++;
|
|
974
|
-
}
|
|
975
|
-
for (let y = 1; y < sampleSize - 1; y++) {
|
|
976
|
-
const leftIndex = y * sampleSize * 4;
|
|
977
|
-
if (pixels[leftIndex + 3] === 0) edgeTransparentPixels++;
|
|
978
|
-
const rightIndex = (y * sampleSize + sampleSize - 1) * 4;
|
|
979
|
-
if (pixels[rightIndex + 3] === 0) edgeTransparentPixels++;
|
|
980
|
-
}
|
|
981
|
-
return edgeTransparentPixels / edgePixels > threshold;
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// src/components/Card/Card.tsx
|
|
985
|
-
var CardContext = /* @__PURE__ */ createContext5({});
|
|
986
|
-
var CardRoot = /* @__PURE__ */ forwardRef5(({ children, classNames, className, id, asChild, role = "group", border = true, fullWidth, ...props }, forwardedRef) => {
|
|
987
|
-
const Root = asChild ? Slot6 : "div";
|
|
988
|
-
return /* @__PURE__ */ React7.createElement(Root, {
|
|
989
|
-
...id && {
|
|
990
|
-
"data-object-id": id
|
|
991
|
-
},
|
|
992
|
-
...props,
|
|
993
|
-
role,
|
|
994
|
-
className: mx7(styles3.root, border && styles3.border, fullWidth && "!max-is-none", className, classNames),
|
|
995
|
-
ref: forwardedRef
|
|
996
|
-
}, children);
|
|
997
|
-
});
|
|
998
|
-
var CardToolbar = /* @__PURE__ */ forwardRef5(({ children, classNames, density = "fine", ...props }, forwardedRef) => {
|
|
999
|
-
return /* @__PURE__ */ React7.createElement(Toolbar.Root, {
|
|
1000
|
-
...props,
|
|
1001
|
-
classNames: [
|
|
1002
|
-
"density-fine bg-transparent",
|
|
1003
|
-
density === "fine" ? styles3.grid_3 : styles3.grid_3_coarse,
|
|
1004
|
-
classNames
|
|
1005
|
-
],
|
|
1006
|
-
ref: forwardedRef
|
|
1007
|
-
}, children);
|
|
1008
|
-
});
|
|
1009
|
-
var CardToolbarIconButton = Toolbar.IconButton;
|
|
1010
|
-
var CardToolbarSeparator = Toolbar.Separator;
|
|
1011
|
-
var CardDragHandle = /* @__PURE__ */ forwardRef5((_, forwardedRef) => {
|
|
1012
|
-
const { t } = useTranslation(translationKey);
|
|
1013
|
-
return /* @__PURE__ */ React7.createElement(Toolbar.IconButton, {
|
|
1014
|
-
"data-testid": "card-drag-handle",
|
|
1015
|
-
noTooltip: true,
|
|
1016
|
-
iconOnly: true,
|
|
1017
|
-
icon: "ph--dots-six-vertical--regular",
|
|
1018
|
-
variant: "ghost",
|
|
1019
|
-
label: t("drag handle label"),
|
|
1020
|
-
classNames: "cursor-pointer",
|
|
1021
|
-
size: 5,
|
|
1022
|
-
disabled: !forwardedRef,
|
|
1023
|
-
ref: forwardedRef
|
|
1024
|
-
});
|
|
1025
|
-
});
|
|
1026
|
-
var CardClose = /* @__PURE__ */ forwardRef5(({ onClick }, forwardedRef) => {
|
|
1027
|
-
const { t } = useTranslation(translationKey);
|
|
1028
|
-
return /* @__PURE__ */ React7.createElement(Toolbar.IconButton, {
|
|
1029
|
-
iconOnly: true,
|
|
1030
|
-
icon: "ph--x--regular",
|
|
1031
|
-
variant: "ghost",
|
|
1032
|
-
label: t("card close label"),
|
|
1033
|
-
classNames: "cursor-pointer",
|
|
1034
|
-
size: 5,
|
|
1035
|
-
onClick,
|
|
1036
|
-
ref: forwardedRef
|
|
1037
|
-
});
|
|
1038
|
-
});
|
|
1039
|
-
var CardMenu = ({ context, items }) => {
|
|
1040
|
-
const { t } = useTranslation(translationKey);
|
|
1041
|
-
const { menuItems } = useContext2(CardContext) ?? {};
|
|
1042
|
-
const combinedItems = [
|
|
1043
|
-
...items ?? [],
|
|
1044
|
-
...menuItems ?? []
|
|
1045
|
-
];
|
|
1046
|
-
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
1047
|
-
disabled: !combinedItems.length,
|
|
1048
|
-
asChild: true
|
|
1049
|
-
}, /* @__PURE__ */ React7.createElement(Card.ToolbarIconButton, {
|
|
1050
|
-
iconOnly: true,
|
|
1051
|
-
variant: "ghost",
|
|
1052
|
-
icon: "ph--dots-three-vertical--regular",
|
|
1053
|
-
label: t("action menu label")
|
|
1054
|
-
})), (combinedItems?.length ?? 0) > 0 && /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, combinedItems?.map(({ label, onClick: onSelect }, i) => /* @__PURE__ */ React7.createElement(DropdownMenu.Item, {
|
|
1055
|
-
key: i,
|
|
1056
|
-
onSelect: () => onSelect(context)
|
|
1057
|
-
}, label))), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
1058
|
-
};
|
|
1059
|
-
var CardTitle = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "heading", ...props }, forwardedRef) => {
|
|
1060
|
-
const Root = asChild ? Slot6 : "div";
|
|
1061
|
-
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1062
|
-
...props,
|
|
1063
|
-
role,
|
|
1064
|
-
className: mx7("grow truncate", classNames, className),
|
|
1065
|
-
ref: forwardedRef
|
|
1066
|
-
}, children);
|
|
1067
|
-
});
|
|
1068
|
-
var CardContent = /* @__PURE__ */ forwardRef5(({ children, ...props }, forwardedRef) => {
|
|
1069
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1070
|
-
role: "none",
|
|
1071
|
-
className: "contents [&>:last-child]:pbe-1",
|
|
1072
|
-
...props,
|
|
1073
|
-
ref: forwardedRef
|
|
1074
|
-
}, children);
|
|
1075
|
-
});
|
|
1076
|
-
var CardRow = /* @__PURE__ */ forwardRef5(({ children, classNames, className, role = "none", icon, ...props }, forwardedRef) => {
|
|
1077
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1078
|
-
...props,
|
|
1079
|
-
role,
|
|
1080
|
-
className: mx7(styles3.grid_2, "pli-1", classNames, className),
|
|
1081
|
-
ref: forwardedRef
|
|
1082
|
-
}, icon && /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1083
|
-
classNames: "text-subdued",
|
|
1084
|
-
icon
|
|
1085
|
-
}) || /* @__PURE__ */ React7.createElement("div", null), children);
|
|
1086
|
-
});
|
|
1087
|
-
var CardHeading = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "heading", variant = "default", ...props }, forwardedRef) => {
|
|
1088
|
-
const Root = asChild ? Slot6 : "div";
|
|
1089
|
-
const variantClassNames = {
|
|
1090
|
-
default: "plb-1",
|
|
1091
|
-
subtitle: "plb-2 text-xs text-description font-medium uppercase"
|
|
1092
|
-
};
|
|
1093
|
-
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1094
|
-
...props,
|
|
1095
|
-
role,
|
|
1096
|
-
className: mx7(variantClassNames[variant], classNames, className),
|
|
1097
|
-
ref: forwardedRef
|
|
1098
|
-
}, children);
|
|
1099
|
-
});
|
|
1100
|
-
var CardText = /* @__PURE__ */ forwardRef5(({ children, classNames, className, asChild, role = "none", truncate, variant = "default", ...props }, forwardedRef) => {
|
|
1101
|
-
const Root = asChild ? Slot6 : "div";
|
|
1102
|
-
const variantClassNames = {
|
|
1103
|
-
default: {
|
|
1104
|
-
root: "plb-1"
|
|
1105
|
-
},
|
|
1106
|
-
description: {
|
|
1107
|
-
root: "plb-1.5",
|
|
1108
|
-
span: "text-sm text-description line-clamp-3"
|
|
1109
|
-
}
|
|
1110
|
-
};
|
|
1111
|
-
return /* @__PURE__ */ React7.createElement(Root, {
|
|
1112
|
-
...props,
|
|
1113
|
-
role,
|
|
1114
|
-
className: mx7("flex overflow-hidden", variantClassNames[variant].root, classNames, className),
|
|
1115
|
-
ref: forwardedRef
|
|
1116
|
-
}, /* @__PURE__ */ React7.createElement("span", {
|
|
1117
|
-
className: mx7(variantClassNames[variant].span, truncate && "truncate")
|
|
1118
|
-
}, children));
|
|
1119
|
-
});
|
|
1120
|
-
var CardPoster = (props) => {
|
|
1121
|
-
const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
|
|
1122
|
-
if (props.image) {
|
|
1123
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1124
|
-
role: "none",
|
|
1125
|
-
className: "mbe-1"
|
|
1126
|
-
}, /* @__PURE__ */ React7.createElement(Image, {
|
|
1127
|
-
classNames: [
|
|
1128
|
-
styles3.poster,
|
|
1129
|
-
aspect,
|
|
1130
|
-
props.classNames
|
|
1131
|
-
],
|
|
1132
|
-
src: props.image,
|
|
1133
|
-
alt: props.alt
|
|
1134
|
-
}));
|
|
1135
|
-
}
|
|
1136
|
-
if (props.icon) {
|
|
1137
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1138
|
-
role: "image",
|
|
1139
|
-
className: mx7("grid place-items-center bg-inputSurface text-subdued", styles3.poster, aspect, props.classNames),
|
|
1140
|
-
"aria-label": props.alt
|
|
1141
|
-
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
1142
|
-
icon: props.icon,
|
|
1143
|
-
size: 10
|
|
1144
|
-
}));
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
var CardAction = ({ icon, actionIcon = "ph--arrow-right--regular", label, onClick }) => {
|
|
1148
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1149
|
-
role: "none",
|
|
1150
|
-
className: "is-full pli-1"
|
|
1151
|
-
}, /* @__PURE__ */ React7.createElement(Button, {
|
|
1152
|
-
variant: "ghost",
|
|
1153
|
-
classNames: mx7(styles3.grid_3, "!p-0 is-full text-start overflow-hidden"),
|
|
1154
|
-
onClick
|
|
1155
|
-
}, icon ? /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1156
|
-
classNames: "text-subdued",
|
|
1157
|
-
icon
|
|
1158
|
-
}) : /* @__PURE__ */ React7.createElement("div", null), /* @__PURE__ */ React7.createElement("span", {
|
|
1159
|
-
className: mx7("min-is-0 flex-1 truncate", !actionIcon && "col-span-2")
|
|
1160
|
-
}, label), actionIcon && /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1161
|
-
icon: actionIcon
|
|
1162
|
-
})));
|
|
1163
|
-
};
|
|
1164
|
-
var CardLink = ({ label, href }) => {
|
|
1165
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1166
|
-
role: "none",
|
|
1167
|
-
className: "is-full pli-1"
|
|
1168
|
-
}, /* @__PURE__ */ React7.createElement("a", {
|
|
1169
|
-
className: mx7(styles3.grid_3, "group !p-0 dx-button dx-focus-ring !min-bs-1"),
|
|
1170
|
-
"data-variant": "ghost",
|
|
1171
|
-
href,
|
|
1172
|
-
target: "_blank",
|
|
1173
|
-
rel: "noreferrer"
|
|
1174
|
-
}, /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1175
|
-
classNames: "text-subdued",
|
|
1176
|
-
icon: "ph--link--regular"
|
|
1177
|
-
}), /* @__PURE__ */ React7.createElement("span", {
|
|
1178
|
-
className: mx7("min-is-0 flex-1 truncate")
|
|
1179
|
-
}, label), /* @__PURE__ */ React7.createElement(CardIcon, {
|
|
1180
|
-
classNames: "invisible group-hover:visible",
|
|
1181
|
-
icon: "ph--arrow-square-out--regular"
|
|
1182
|
-
})));
|
|
1183
|
-
};
|
|
1184
|
-
var CardIconBlock = ({ classNames, children, role = "none", ...props }) => {
|
|
1185
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1186
|
-
...props,
|
|
1187
|
-
role,
|
|
1188
|
-
className: mx7("grid bs-[var(--rail-item)] is-[var(--rail-item)] place-items-center", classNames)
|
|
1189
|
-
}, children);
|
|
1190
|
-
};
|
|
1191
|
-
var CardIcon = ({ toolbar, ...props }) => {
|
|
1192
|
-
return /* @__PURE__ */ React7.createElement(CardIconBlock, null, /* @__PURE__ */ React7.createElement(Icon, {
|
|
1193
|
-
...props,
|
|
1194
|
-
size: toolbar ? 5 : 4
|
|
1195
|
-
}));
|
|
1196
|
-
};
|
|
1197
|
-
var Card = {
|
|
1198
|
-
Context: CardContext,
|
|
1199
|
-
Root: CardRoot,
|
|
1200
|
-
// Toolbar
|
|
1201
|
-
Toolbar: CardToolbar,
|
|
1202
|
-
ToolbarIconButton: CardToolbarIconButton,
|
|
1203
|
-
ToolbarSeparator: CardToolbarSeparator,
|
|
1204
|
-
DragHandle: CardDragHandle,
|
|
1205
|
-
Title: CardTitle,
|
|
1206
|
-
Close: CardClose,
|
|
1207
|
-
Menu: CardMenu,
|
|
1208
|
-
Icon: CardIcon,
|
|
1209
|
-
IconBlock: CardIconBlock,
|
|
1210
|
-
// Content
|
|
1211
|
-
Content: CardContent,
|
|
1212
|
-
Row: CardRow,
|
|
1213
|
-
Heading: CardHeading,
|
|
1214
|
-
Text: CardText,
|
|
1215
|
-
Poster: CardPoster,
|
|
1216
|
-
Action: CardAction,
|
|
1217
|
-
Link: CardLink
|
|
1218
|
-
};
|
|
1219
|
-
|
|
1220
|
-
// src/components/Mosaic/Stack.tsx
|
|
1221
798
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Stack.tsx";
|
|
1222
799
|
var MOSAIC_STACK_NAME = "MosaicStack";
|
|
1223
|
-
var MosaicStackInner = /* @__PURE__ */
|
|
800
|
+
var MosaicStackInner = /* @__PURE__ */ forwardRef5(({ classNames, className, role = "list", orientation: orientationProp = "vertical", draggable: draggable2 = true, items, getId, Tile, debug, ...props }, forwardedRef) => {
|
|
1224
801
|
invariant(Tile, void 0, {
|
|
1225
802
|
F: __dxlog_file2,
|
|
1226
803
|
L: 75,
|
|
@@ -1246,23 +823,23 @@ var MosaicStackInner = /* @__PURE__ */ forwardRef6(({ classNames, className, rol
|
|
|
1246
823
|
"`Invalid orientation: ${orientation}`"
|
|
1247
824
|
]
|
|
1248
825
|
});
|
|
1249
|
-
return /* @__PURE__ */
|
|
826
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1250
827
|
...props,
|
|
1251
828
|
role,
|
|
1252
|
-
className:
|
|
829
|
+
className: mx6("flex", orientation === "horizontal" && "h-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
|
|
1253
830
|
ref: forwardedRef
|
|
1254
|
-
}, /* @__PURE__ */
|
|
831
|
+
}, /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
|
|
1255
832
|
orientation,
|
|
1256
833
|
location: 0.5
|
|
1257
|
-
}), visibleItems?.map((item, index) => /* @__PURE__ */
|
|
834
|
+
}), visibleItems?.map((item, index) => /* @__PURE__ */ React6.createElement(Fragment, {
|
|
1258
835
|
key: getId(item)
|
|
1259
|
-
}, /* @__PURE__ */
|
|
836
|
+
}, /* @__PURE__ */ React6.createElement(Tile, {
|
|
1260
837
|
id: getId(item),
|
|
1261
838
|
data: item,
|
|
1262
839
|
location: index + 1,
|
|
1263
840
|
draggable: draggable2,
|
|
1264
841
|
debug
|
|
1265
|
-
}), /* @__PURE__ */
|
|
842
|
+
}), /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
|
|
1266
843
|
orientation,
|
|
1267
844
|
location: index + 1.5
|
|
1268
845
|
}))));
|
|
@@ -1270,7 +847,7 @@ var MosaicStackInner = /* @__PURE__ */ forwardRef6(({ classNames, className, rol
|
|
|
1270
847
|
MosaicStackInner.displayName = MOSAIC_STACK_NAME;
|
|
1271
848
|
var MosaicStack = MosaicStackInner;
|
|
1272
849
|
var MOSAIC_VIRTUAL_STACK_NAME = "MosaicVirtualStack";
|
|
1273
|
-
var MosaicVirtualStackInner = /* @__PURE__ */
|
|
850
|
+
var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef5(({ classNames, className, role = "list", orientation = "vertical", items, getId, Tile, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
|
|
1274
851
|
invariant(Tile, void 0, {
|
|
1275
852
|
F: __dxlog_file2,
|
|
1276
853
|
L: 142,
|
|
@@ -1295,10 +872,10 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef6(({ classNames, classNa
|
|
|
1295
872
|
onChange
|
|
1296
873
|
});
|
|
1297
874
|
const virtualItems = virtualizer.getVirtualItems();
|
|
1298
|
-
return /* @__PURE__ */
|
|
875
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1299
876
|
...props,
|
|
1300
877
|
role,
|
|
1301
|
-
className:
|
|
878
|
+
className: mx6("flex", orientation === "horizontal" && "h-full [&>*]:shrink-0", orientation === "vertical" && "flex-col", classNames, className),
|
|
1302
879
|
style: {
|
|
1303
880
|
position: "relative",
|
|
1304
881
|
...orientation === "vertical" ? {
|
|
@@ -1312,7 +889,7 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef6(({ classNames, classNa
|
|
|
1312
889
|
ref: forwardedRef
|
|
1313
890
|
}, virtualItems.map((virtualItem) => {
|
|
1314
891
|
const data = visibleItems[Math.floor(virtualItem.index / 2)];
|
|
1315
|
-
return /* @__PURE__ */
|
|
892
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1316
893
|
key: virtualItem.key,
|
|
1317
894
|
"data-index": virtualItem.index,
|
|
1318
895
|
style: {
|
|
@@ -1328,10 +905,10 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef6(({ classNames, classNa
|
|
|
1328
905
|
}
|
|
1329
906
|
},
|
|
1330
907
|
ref: virtualizer.measureElement
|
|
1331
|
-
}, virtualItem.index % 2 === 0 ? /* @__PURE__ */
|
|
908
|
+
}, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React6.createElement(InternalPlaceholder, {
|
|
1332
909
|
orientation,
|
|
1333
910
|
location: Math.floor(virtualItem.index / 2) + 0.5
|
|
1334
|
-
}) : /* @__PURE__ */
|
|
911
|
+
}) : /* @__PURE__ */ React6.createElement(Tile, {
|
|
1335
912
|
id: getId(data),
|
|
1336
913
|
data,
|
|
1337
914
|
location: Math.floor(virtualItem.index / 2) + 1,
|
|
@@ -1342,11 +919,11 @@ var MosaicVirtualStackInner = /* @__PURE__ */ forwardRef6(({ classNames, classNa
|
|
|
1342
919
|
MosaicVirtualStackInner.displayName = MOSAIC_VIRTUAL_STACK_NAME;
|
|
1343
920
|
var MosaicVirtualStack = MosaicVirtualStackInner;
|
|
1344
921
|
var InternalPlaceholder = (props) => {
|
|
1345
|
-
return /* @__PURE__ */
|
|
922
|
+
return /* @__PURE__ */ React6.createElement(MosaicPlaceholder, {
|
|
1346
923
|
...props,
|
|
1347
|
-
classNames:
|
|
1348
|
-
}, /* @__PURE__ */
|
|
1349
|
-
className:
|
|
924
|
+
classNames: styles.placeholder.root
|
|
925
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
926
|
+
className: mx6("flex h-full bg-base-surface border border-dashed border-separator rounded-xs", styles.placeholder.content)
|
|
1350
927
|
}));
|
|
1351
928
|
};
|
|
1352
929
|
InternalPlaceholder.displayName = "InternalPlaceholder";
|
|
@@ -1364,18 +941,13 @@ var Mosaic = {
|
|
|
1364
941
|
|
|
1365
942
|
export {
|
|
1366
943
|
useVisibleItems,
|
|
1367
|
-
styles,
|
|
1368
944
|
useFocus,
|
|
1369
945
|
Focus,
|
|
1370
|
-
|
|
946
|
+
styles,
|
|
1371
947
|
getSourceData,
|
|
1372
948
|
useMosaicRootContext,
|
|
1373
949
|
useMosaicContainerContext,
|
|
1374
950
|
useMosaicTileContext,
|
|
1375
|
-
Mosaic
|
|
1376
|
-
translationKey,
|
|
1377
|
-
styles3,
|
|
1378
|
-
Image,
|
|
1379
|
-
Card
|
|
951
|
+
Mosaic
|
|
1380
952
|
};
|
|
1381
|
-
//# sourceMappingURL=chunk-
|
|
953
|
+
//# sourceMappingURL=chunk-7S4PIFKU.mjs.map
|