@dxos/react-ui-mosaic 0.8.4-main.69d29f4 → 0.8.4-main.937b3ca

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.
@@ -619,11 +619,11 @@ var dropField = StateField.define({
619
619
  provide: (field) => EditorView.decorations.from(field)
620
620
  });
621
621
 
622
- // src/hooks/useContainerDebug.tsx
623
- import React7, { forwardRef as forwardRef6, useMemo as useMemo5, useRef as useRef5 } from "react";
624
- import { createPortal as createPortal2 } from "react-dom";
625
- import { Json } from "@dxos/react-ui-syntax-highlighter";
626
- import { mx as mx7 } from "@dxos/ui-theme";
622
+ // src/components/Stack/Stack.tsx
623
+ import { useVirtualizer } from "@tanstack/react-virtual";
624
+ import React6, { Fragment, forwardRef as forwardRef5 } from "react";
625
+ import { invariant } from "@dxos/invariant";
626
+ import { mx as mx6 } from "@dxos/ui-theme";
627
627
 
628
628
  // src/components/Mosaic/Mosaic.tsx
629
629
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
@@ -638,10 +638,10 @@ import { createContext as createContext3 } from "@radix-ui/react-context";
638
638
  import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
639
639
  import { Slot as Slot3 } from "@radix-ui/react-slot";
640
640
  import { bind } from "bind-event-listener";
641
- import React6, { forwardRef as forwardRef5, useCallback as useCallback2, useEffect as useEffect2, useLayoutEffect, useMemo as useMemo4, useRef as useRef4, useState as useState3 } from "react";
641
+ import React5, { forwardRef as forwardRef4, useCallback as useCallback2, useEffect as useEffect2, useLayoutEffect, useMemo as useMemo2, useRef as useRef4, useState as useState3 } from "react";
642
642
  import { createPortal } from "react-dom";
643
- import { log as log2 } from "@dxos/log";
644
- import { mx as mx6 } from "@dxos/ui-theme";
643
+ import { log } from "@dxos/log";
644
+ import { mx as mx5 } from "@dxos/ui-theme";
645
645
  import { isTruthy } from "@dxos/util";
646
646
 
647
647
  // src/components/Scrollable/Scrollable.tsx
@@ -713,230 +713,14 @@ var Scrollable = /* @__PURE__ */ forwardRef3(({ classNames, axis = "vertical", p
713
713
  });
714
714
  });
715
715
 
716
- // src/components/Stack/Stack.tsx
717
- import { useVirtualizer } from "@tanstack/react-virtual";
718
- import React5, { Fragment, forwardRef as forwardRef4 } from "react";
719
- import { invariant } from "@dxos/invariant";
720
- import { mx as mx5 } from "@dxos/ui-theme";
721
-
722
- // src/hooks/useEventHandlerAdapter.ts
723
- import { useMemo as useMemo2 } from "react";
724
- import { log } from "@dxos/log";
725
- import { arrayMove } from "@dxos/util";
726
- var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/hooks/useEventHandlerAdapter.ts";
727
- var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) => {
728
- return useMemo2(() => ({
729
- ...props,
730
- onTake: ({ source }, cb) => {
731
- log.info("onTake", {
732
- source
733
- }, {
734
- F: __dxlog_file,
735
- L: 58,
736
- S: void 0,
737
- C: (f, a) => f(...a)
738
- });
739
- const mutate = (items2) => {
740
- const from = items2.findIndex((item) => getId(item) === source.id);
741
- if (from !== -1) {
742
- items2.splice(from, 1);
743
- }
744
- };
745
- if (onChange) {
746
- onChange(mutate);
747
- } else {
748
- mutate(items);
749
- }
750
- void cb(source.data);
751
- },
752
- onDrop: ({ source, target }) => {
753
- const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : -1;
754
- log.info("onDrop", {
755
- source,
756
- target,
757
- to
758
- }, {
759
- F: __dxlog_file,
760
- L: 76,
761
- S: void 0,
762
- C: (f, a) => f(...a)
763
- });
764
- const mutate = (items2) => {
765
- const from = items2.findIndex((item) => getId(item) === source.id);
766
- if (to !== -1) {
767
- if (from !== -1) {
768
- arrayMove(items2, from, to);
769
- } else {
770
- items2.splice(to, 0, make(get(source.data)));
771
- }
772
- }
773
- };
774
- if (onChange) {
775
- onChange(mutate);
776
- } else {
777
- mutate(items);
778
- }
779
- }
780
- }), [
781
- items,
782
- onChange
783
- ]);
784
- };
785
-
786
- // src/hooks/useVisibleItems.ts
787
- import { useMemo as useMemo3 } from "react";
788
- var useVisibleItems = ({ id, items, dragging, getId }) => {
789
- const visibleItems = useMemo3(() => {
790
- if (!items || !dragging || id !== dragging.containerId) {
791
- return items ?? [];
792
- }
793
- const idx = items.findIndex((item) => getId(item) === dragging.id);
794
- if (idx === -1) {
795
- return items;
796
- }
797
- const visibleItems2 = items.slice();
798
- visibleItems2.splice(idx, 1);
799
- return visibleItems2;
800
- }, [
801
- id,
802
- items,
803
- dragging,
804
- getId
805
- ]);
806
- return visibleItems;
807
- };
808
-
809
- // src/components/Stack/Stack.tsx
810
- var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Stack/Stack.tsx";
811
- var StackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", draggable: draggable2 = true, items, getId, Tile: Tile2, debug, ...props }, forwardedRef) => {
812
- invariant(Tile2, void 0, {
813
- F: __dxlog_file2,
814
- L: 44,
815
- S: void 0,
816
- A: [
817
- "Tile",
818
- ""
819
- ]
820
- });
821
- const { id, dragging } = useContainerContext(StackInner.displayName);
822
- const visibleItems = useVisibleItems({
823
- id,
824
- items,
825
- dragging: dragging?.source.data,
826
- getId
827
- });
828
- return /* @__PURE__ */ React5.createElement("div", {
829
- ...props,
830
- role,
831
- className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
832
- ref: forwardedRef
833
- }, /* @__PURE__ */ React5.createElement(Placeholder, {
834
- axis,
835
- location: 0.5
836
- }), visibleItems?.map((item, index) => /* @__PURE__ */ React5.createElement(Fragment, {
837
- key: getId(item)
838
- }, /* @__PURE__ */ React5.createElement(Tile2, {
839
- id: getId(item),
840
- data: item,
841
- location: index + 1,
842
- draggable: draggable2,
843
- debug
844
- }), /* @__PURE__ */ React5.createElement(Placeholder, {
845
- axis,
846
- location: index + 1.5
847
- }))));
848
- });
849
- StackInner.displayName = "Stack";
850
- var Stack = StackInner;
851
- var VirtualStackInner = /* @__PURE__ */ forwardRef4(({ className, classNames, role = "list", axis = "vertical", items, getId, Tile: Tile2, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
852
- invariant(Tile2, void 0, {
853
- F: __dxlog_file2,
854
- L: 106,
855
- S: void 0,
856
- A: [
857
- "Tile",
858
- ""
859
- ]
860
- });
861
- const { id, dragging } = useContainerContext(VirtualStackInner.displayName);
862
- const visibleItems = useVisibleItems({
863
- id,
864
- items,
865
- dragging: dragging?.source.data,
866
- getId
867
- });
868
- const virtualizer = useVirtualizer({
869
- count: visibleItems.length * 2 + 1,
870
- estimateSize,
871
- getScrollElement,
872
- overscan,
873
- onChange
874
- });
875
- const virtualItems = virtualizer.getVirtualItems();
876
- return /* @__PURE__ */ React5.createElement("div", {
877
- ...props,
878
- role,
879
- className: mx5("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
880
- style: {
881
- position: "relative",
882
- ...axis === "vertical" ? {
883
- width: "100%",
884
- height: virtualizer.getTotalSize()
885
- } : {
886
- width: virtualizer.getTotalSize(),
887
- height: "100%"
888
- }
889
- },
890
- ref: forwardedRef
891
- }, virtualItems.map((virtualItem) => {
892
- const data = visibleItems[Math.floor(virtualItem.index / 2)];
893
- return /* @__PURE__ */ React5.createElement("div", {
894
- key: virtualItem.key,
895
- "data-index": virtualItem.index,
896
- style: {
897
- position: "absolute",
898
- top: 0,
899
- left: 0,
900
- ...axis === "vertical" ? {
901
- width: "100%",
902
- transform: `translateY(${virtualItem.start}px)`
903
- } : {
904
- height: "100%",
905
- transform: `translateX(${virtualItem.start}px)`
906
- }
907
- },
908
- ref: virtualizer.measureElement
909
- }, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React5.createElement(Placeholder, {
910
- axis,
911
- location: Math.floor(virtualItem.index / 2) + 0.5
912
- }) : /* @__PURE__ */ React5.createElement(Tile2, {
913
- id: getId(data),
914
- data,
915
- location: Math.floor(virtualItem.index / 2) + 1,
916
- debug
917
- }));
918
- }));
919
- });
920
- VirtualStackInner.displayName = "VirtualStackInner";
921
- var VirtualStack = VirtualStackInner;
922
- var Placeholder = (props) => {
923
- return /* @__PURE__ */ React5.createElement(Mosaic.Placeholder, {
924
- ...props,
925
- classNames: styles3.placeholder.root
926
- }, /* @__PURE__ */ React5.createElement("div", {
927
- className: mx5("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles3.placeholder.content)
928
- }));
929
- };
930
- Placeholder.displayName = "Placeholder";
931
-
932
716
  // src/components/Mosaic/Mosaic.tsx
933
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Mosaic.tsx";
717
+ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Mosaic/Mosaic.tsx";
934
718
  var getSourceData = (source) => {
935
719
  return source.data.type === "tile" ? source.data : null;
936
720
  };
937
721
  var [RootContextProvider, useRootContext] = createContext3("MosaicRoot");
938
722
  var ROOT_DEBUG_ATTR = "mosaic-debug";
939
- var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }, forwardedRef) => {
723
+ var Root = /* @__PURE__ */ forwardRef4(({ classNames, children, asChild, debug }, forwardedRef) => {
940
724
  const rootRef = useRef4(null);
941
725
  const composedRef = useComposedRefs2(rootRef, forwardedRef);
942
726
  const Root2 = asChild ? Slot3 : Primitive2.div;
@@ -1013,11 +797,11 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1013
797
  * Dragging started within any container.
1014
798
  */
1015
799
  onDragStart: ({ source, location }) => {
1016
- log2("Root.onDragStart", {
800
+ log("Root.onDragStart", {
1017
801
  source: source.data,
1018
802
  location: location.current.dropTargets.map((target) => target.data)
1019
803
  }, {
1020
- F: __dxlog_file3,
804
+ F: __dxlog_file,
1021
805
  L: 215,
1022
806
  S: void 0,
1023
807
  C: (f, a) => f(...a)
@@ -1032,11 +816,11 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1032
816
  */
1033
817
  onDropTargetChange: ({ source, location }) => {
1034
818
  clearTimeout(noTargetTimeout);
1035
- log2("Root.onDropTargetChange", {
819
+ log("Root.onDropTargetChange", {
1036
820
  source: source.data,
1037
821
  location: location.current.dropTargets.map((target) => target.data)
1038
822
  }, {
1039
- F: __dxlog_file3,
823
+ F: __dxlog_file,
1040
824
  L: 228,
1041
825
  S: void 0,
1042
826
  C: (f, a) => f(...a)
@@ -1071,22 +855,22 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1071
855
  * Dragging ended.
1072
856
  */
1073
857
  onDrop: ({ source, location }) => {
1074
- log2.info("Root.onDrop", {
858
+ log.info("Root.onDrop", {
1075
859
  source: source.data,
1076
860
  location: location.current.dropTargets.map((target) => target.data)
1077
861
  }, {
1078
- F: __dxlog_file3,
862
+ F: __dxlog_file,
1079
863
  L: 257,
1080
864
  S: void 0,
1081
865
  C: (f, a) => f(...a)
1082
866
  });
1083
867
  const { data: sourceData, handler: sourceHandler } = getSourceHandler(source);
1084
868
  if (!sourceHandler) {
1085
- log2.warn("invalid source", {
869
+ log.warn("invalid source", {
1086
870
  source: sourceData,
1087
871
  handlers: Object.keys(handlers)
1088
872
  }, {
1089
- F: __dxlog_file3,
873
+ F: __dxlog_file,
1090
874
  L: 265,
1091
875
  S: void 0,
1092
876
  C: (f, a) => f(...a)
@@ -1095,8 +879,8 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1095
879
  }
1096
880
  try {
1097
881
  if (location.current.dropTargets.length === 0) {
1098
- log2.info("cancelled", void 0, {
1099
- F: __dxlog_file3,
882
+ log.info("cancelled", void 0, {
883
+ F: __dxlog_file,
1100
884
  L: 280,
1101
885
  S: void 0,
1102
886
  C: (f, a) => f(...a)
@@ -1104,12 +888,12 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1104
888
  } else {
1105
889
  const { data: targetData, handler: targetHandler } = getTargetHandler(location);
1106
890
  if (!targetHandler) {
1107
- log2.warn("invalid target", {
891
+ log.warn("invalid target", {
1108
892
  source: sourceData,
1109
893
  location,
1110
894
  handlers: Object.keys(handlers)
1111
895
  }, {
1112
- F: __dxlog_file3,
896
+ F: __dxlog_file,
1113
897
  L: 285,
1114
898
  S: void 0,
1115
899
  C: (f, a) => f(...a)
@@ -1123,10 +907,10 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1123
907
  });
1124
908
  } else {
1125
909
  if (!sourceHandler.onTake) {
1126
- log2.warn("invalid source", {
910
+ log.warn("invalid source", {
1127
911
  source: sourceData
1128
912
  }, {
1129
- F: __dxlog_file3,
913
+ F: __dxlog_file,
1130
914
  L: 301,
1131
915
  S: void 0,
1132
916
  C: (f, a) => f(...a)
@@ -1158,7 +942,7 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1158
942
  getSourceHandler,
1159
943
  getTargetHandler
1160
944
  ]);
1161
- return /* @__PURE__ */ React6.createElement(RootContextProvider, {
945
+ return /* @__PURE__ */ React5.createElement(RootContextProvider, {
1162
946
  containers: handlers,
1163
947
  addContainer: (container) => setHandlers((containers) => ({
1164
948
  ...containers,
@@ -1171,8 +955,8 @@ var Root = /* @__PURE__ */ forwardRef5(({ classNames, children, asChild, debug }
1171
955
  };
1172
956
  }),
1173
957
  dragging
1174
- }, /* @__PURE__ */ React6.createElement(Root2, {
1175
- className: mx6("group overflow-hidden", classNames),
958
+ }, /* @__PURE__ */ React5.createElement(Root2, {
959
+ className: mx5("group overflow-hidden", classNames),
1176
960
  [`data-${ROOT_DEBUG_ATTR}`]: debug,
1177
961
  ref: composedRef
1178
962
  }, children));
@@ -1182,11 +966,11 @@ var CONTAINER_STATE_ATTR = "mosaic-container-state";
1182
966
  var CONTAINER_PLACEHOLDER_WIDTH = "--mosaic-placeholder-width";
1183
967
  var CONTAINER_PLACEHOLDER_HEIGHT = "--mosaic-placeholder-height";
1184
968
  var counter = 0;
1185
- var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children, eventHandler: eventHandlerProp, axis = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
969
+ var Container = /* @__PURE__ */ forwardRef4(({ className, classNames, children, eventHandler: eventHandlerProp, axis = "vertical", asChild, autoScroll: autoscrollElement, withFocus, debug, ...props }, forwardedRef) => {
1186
970
  const rootRef = useRef4(null);
1187
971
  const composedRef = useComposedRefs2(rootRef, forwardedRef);
1188
972
  const Root2 = asChild ? Slot3 : Primitive2.div;
1189
- const eventHandler = useMemo4(() => eventHandlerProp ?? {
973
+ const eventHandler = useMemo2(() => eventHandlerProp ?? {
1190
974
  id: `mosaic-container-${counter++}`
1191
975
  }, [
1192
976
  eventHandlerProp
@@ -1214,7 +998,7 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1214
998
  }, [
1215
999
  eventHandler
1216
1000
  ]);
1217
- const data = useMemo4(() => ({
1001
+ const data = useMemo2(() => ({
1218
1002
  type: "container",
1219
1003
  id: eventHandler.id
1220
1004
  }), [
@@ -1330,7 +1114,7 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1330
1114
  data,
1331
1115
  autoscrollElement
1332
1116
  ]);
1333
- return /* @__PURE__ */ React6.createElement(ContainerContextProvider, {
1117
+ return /* @__PURE__ */ React5.createElement(ContainerContextProvider, {
1334
1118
  id: eventHandler.id,
1335
1119
  eventHandler,
1336
1120
  axis,
@@ -1339,8 +1123,8 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1339
1123
  scrolling,
1340
1124
  activeLocation,
1341
1125
  setActiveLocation
1342
- }, /* @__PURE__ */ React6.createElement(Root2, {
1343
- className: mx6("bs-full", className, classNames),
1126
+ }, /* @__PURE__ */ React5.createElement(Root2, {
1127
+ className: mx5("bs-full", className, classNames),
1344
1128
  style: {
1345
1129
  [CONTAINER_PLACEHOLDER_WIDTH]: state.type === "active" && state.bounds ? `${state.bounds.width}px` : "0px",
1346
1130
  [CONTAINER_PLACEHOLDER_HEIGHT]: state.type === "active" && state.bounds ? `${state.bounds.height}px` : "0px"
@@ -1353,7 +1137,7 @@ var Container = /* @__PURE__ */ forwardRef5(({ className, classNames, children,
1353
1137
  Container.displayName = "MosaicContainer";
1354
1138
  var [TileContextProvider, useTileContext] = createContext3("MosaicTile");
1355
1139
  var TILE_STATE_ATTR = "mosaic-tile-state";
1356
- var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
1140
+ var Tile = /* @__PURE__ */ forwardRef4(({ className, classNames, children, asChild, dragHandle, allowedEdges: allowedEdgesProp, location, id, data: dataProp, debug: _ }, forwardedRef) => {
1357
1141
  const rootRef = useRef4(null);
1358
1142
  const composedRef = composeRefs(rootRef, forwardedRef);
1359
1143
  const Root2 = asChild ? Slot3 : Primitive2.div;
@@ -1361,7 +1145,7 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1361
1145
  const [state, setState] = useState3({
1362
1146
  type: "idle"
1363
1147
  });
1364
- const allowedEdges = useMemo4(() => allowedEdgesProp || (axis === "vertical" ? [
1148
+ const allowedEdges = useMemo2(() => allowedEdgesProp || (axis === "vertical" ? [
1365
1149
  "top",
1366
1150
  "bottom"
1367
1151
  ] : [
@@ -1371,7 +1155,7 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1371
1155
  allowedEdgesProp,
1372
1156
  axis
1373
1157
  ]);
1374
- const data = useMemo4(() => ({
1158
+ const data = useMemo2(() => ({
1375
1159
  type: "tile",
1376
1160
  id,
1377
1161
  containerId,
@@ -1485,18 +1269,18 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1485
1269
  allowedEdges,
1486
1270
  setActiveLocation
1487
1271
  ]);
1488
- return /* @__PURE__ */ React6.createElement(TileContextProvider, {
1272
+ return /* @__PURE__ */ React5.createElement(TileContextProvider, {
1489
1273
  state
1490
- }, /* @__PURE__ */ React6.createElement(Root2, {
1274
+ }, /* @__PURE__ */ React5.createElement(Root2, {
1491
1275
  [`data-${TILE_STATE_ATTR}`]: state.type,
1492
1276
  role: "listitem",
1493
- className: mx6("relative", className, classNames),
1277
+ className: mx5("relative", className, classNames),
1494
1278
  ref: composedRef
1495
- }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(Root2, {
1279
+ }, children), state.type === "preview" && /* @__PURE__ */ createPortal(/* @__PURE__ */ React5.createElement(Root2, {
1496
1280
  // NOTE: Use to control appearance while dragging.
1497
1281
  [`data-${TILE_STATE_ATTR}`]: state.type,
1498
1282
  // TODO(burdon): Configure drop animation.
1499
- className: mx6("relative", className, classNames),
1283
+ className: mx5("relative", className, classNames),
1500
1284
  style: {
1501
1285
  width: `${state.rect.width}px`,
1502
1286
  height: `${state.rect.height}px`
@@ -1506,11 +1290,11 @@ var Tile = /* @__PURE__ */ forwardRef5(({ className, classNames, children, asChi
1506
1290
  Tile.displayName = "MosaicTile";
1507
1291
  var PLACEHOLDER_AXIS_ATTR = "mosaic-placeholder-axis";
1508
1292
  var PLACEHOLDER_STATE_ATTR = "mosaic-placeholder-state";
1509
- var Placeholder2 = ({ classNames, children, asChild, axis = "vertical", location }) => {
1293
+ var Placeholder = ({ classNames, children, asChild, axis = "vertical", location }) => {
1510
1294
  const rootRef = useRef4(null);
1511
1295
  const Root2 = asChild ? Slot3 : Primitive2.div;
1512
- const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useContainerContext(Placeholder2.displayName);
1513
- const data = useMemo4(() => ({
1296
+ const { id: containerId, eventHandler, scrolling, activeLocation, setActiveLocation } = useContainerContext(Placeholder.displayName);
1297
+ const data = useMemo2(() => ({
1514
1298
  type: "placeholder",
1515
1299
  containerId,
1516
1300
  location
@@ -1548,18 +1332,18 @@ var Placeholder2 = ({ classNames, children, asChild, axis = "vertical", location
1548
1332
  scrolling,
1549
1333
  setActiveLocation
1550
1334
  ]);
1551
- return /* @__PURE__ */ React6.createElement(Root2, {
1335
+ return /* @__PURE__ */ React5.createElement(Root2, {
1552
1336
  [`data-${PLACEHOLDER_AXIS_ATTR}`]: axis,
1553
1337
  [`data-${PLACEHOLDER_STATE_ATTR}`]: data.location === activeLocation ? "active" : "idle",
1554
1338
  role: "none",
1555
- className: mx6("relative", classNames),
1339
+ className: mx5("relative", classNames),
1556
1340
  ref: rootRef
1557
1341
  }, children);
1558
1342
  };
1559
- Placeholder2.displayName = "MosaicPlaceholder";
1343
+ Placeholder.displayName = "MosaicPlaceholder";
1560
1344
  var DropIndicator = (props) => {
1561
1345
  const { state } = useTileContext(DropIndicator.displayName);
1562
- return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React6.createElement(NativeDropIndicator, {
1346
+ return state.type === "target" && state.closestEdge ? /* @__PURE__ */ React5.createElement(NativeDropIndicator, {
1563
1347
  ...props,
1564
1348
  edge: state.closestEdge
1565
1349
  }) : null;
@@ -1569,7 +1353,7 @@ var Mosaic = {
1569
1353
  Root,
1570
1354
  Container,
1571
1355
  Tile,
1572
- Placeholder: Placeholder2,
1356
+ Placeholder,
1573
1357
  DropIndicator,
1574
1358
  // TODO(burdon): Move out of Mosaic namespace?
1575
1359
  Viewport: Scrollable,
@@ -1577,45 +1361,151 @@ var Mosaic = {
1577
1361
  VirtualStack
1578
1362
  };
1579
1363
 
1580
- // src/hooks/useContainerDebug.tsx
1581
- var useContainerDebug = (debug) => {
1582
- const debugRef = useRef5(null);
1583
- return useMemo5(() => {
1584
- if (!debug) {
1585
- return [
1586
- () => null,
1587
- void 0
1588
- ];
1364
+ // src/hooks/useVisibleItems.ts
1365
+ import { useMemo as useMemo3 } from "react";
1366
+ var useVisibleItems = ({ id, items, dragging, getId }) => {
1367
+ const visibleItems = useMemo3(() => {
1368
+ if (!items || !dragging || id !== dragging.containerId) {
1369
+ return items ?? [];
1589
1370
  }
1590
- return [
1591
- ({ classNames }) => /* @__PURE__ */ React7.createElement("div", {
1592
- role: "none",
1593
- className: mx7("overflow-hidden", classNames),
1594
- ref: debugRef
1595
- }),
1596
- () => debugRef.current && /* @__PURE__ */ createPortal2(/* @__PURE__ */ React7.createElement(ContainerInfo, null), debugRef.current)
1597
- ];
1371
+ const idx = items.findIndex((item) => getId(item) === dragging.id);
1372
+ if (idx === -1) {
1373
+ return items;
1374
+ }
1375
+ const visibleItems2 = items.slice();
1376
+ visibleItems2.splice(idx, 1);
1377
+ return visibleItems2;
1598
1378
  }, [
1599
- debug,
1600
- debugRef
1379
+ id,
1380
+ items,
1381
+ dragging,
1382
+ getId
1601
1383
  ]);
1384
+ return visibleItems;
1602
1385
  };
1603
- var ContainerInfo = /* @__PURE__ */ forwardRef6(({ classNames }, forwardedRef) => {
1604
- const { id, state, activeLocation, scrolling } = useContainerContext(ContainerInfo.displayName);
1605
- const counter2 = useRef5(0);
1606
- return /* @__PURE__ */ React7.createElement(Json, {
1607
- data: {
1608
- id,
1609
- activeLocation,
1610
- scrolling,
1611
- state,
1612
- count: counter2.current++
1613
- },
1614
- classNames: mx7("text-xs", classNames),
1386
+
1387
+ // src/components/Stack/Stack.tsx
1388
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/components/Stack/Stack.tsx";
1389
+ var StackInner = /* @__PURE__ */ forwardRef5(({ className, classNames, role = "list", axis = "vertical", draggable: draggable2 = true, items, getId, Tile: Tile2, debug, ...props }, forwardedRef) => {
1390
+ invariant(Tile2, void 0, {
1391
+ F: __dxlog_file2,
1392
+ L: 44,
1393
+ S: void 0,
1394
+ A: [
1395
+ "Tile",
1396
+ ""
1397
+ ]
1398
+ });
1399
+ const { id, dragging } = useContainerContext(StackInner.displayName);
1400
+ const visibleItems = useVisibleItems({
1401
+ id,
1402
+ items,
1403
+ dragging: dragging?.source.data,
1404
+ getId
1405
+ });
1406
+ return /* @__PURE__ */ React6.createElement("div", {
1407
+ ...props,
1408
+ role,
1409
+ className: mx6("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
1615
1410
  ref: forwardedRef
1411
+ }, /* @__PURE__ */ React6.createElement(Placeholder2, {
1412
+ axis,
1413
+ location: 0.5
1414
+ }), visibleItems?.map((item, index) => /* @__PURE__ */ React6.createElement(Fragment, {
1415
+ key: getId(item)
1416
+ }, /* @__PURE__ */ React6.createElement(Tile2, {
1417
+ id: getId(item),
1418
+ data: item,
1419
+ location: index + 1,
1420
+ draggable: draggable2,
1421
+ debug
1422
+ }), /* @__PURE__ */ React6.createElement(Placeholder2, {
1423
+ axis,
1424
+ location: index + 1.5
1425
+ }))));
1426
+ });
1427
+ StackInner.displayName = "Stack";
1428
+ var Stack = StackInner;
1429
+ var VirtualStackInner = /* @__PURE__ */ forwardRef5(({ className, classNames, role = "list", axis = "vertical", items, getId, Tile: Tile2, estimateSize, getScrollElement, overscan = 8, onChange, debug, ...props }, forwardedRef) => {
1430
+ invariant(Tile2, void 0, {
1431
+ F: __dxlog_file2,
1432
+ L: 106,
1433
+ S: void 0,
1434
+ A: [
1435
+ "Tile",
1436
+ ""
1437
+ ]
1438
+ });
1439
+ const { id, dragging } = useContainerContext(VirtualStackInner.displayName);
1440
+ const visibleItems = useVisibleItems({
1441
+ id,
1442
+ items,
1443
+ dragging: dragging?.source.data,
1444
+ getId
1616
1445
  });
1446
+ const virtualizer = useVirtualizer({
1447
+ count: visibleItems.length * 2 + 1,
1448
+ estimateSize,
1449
+ getScrollElement,
1450
+ overscan,
1451
+ onChange
1452
+ });
1453
+ const virtualItems = virtualizer.getVirtualItems();
1454
+ return /* @__PURE__ */ React6.createElement("div", {
1455
+ ...props,
1456
+ role,
1457
+ className: mx6("flex", axis === "horizontal" && "bs-full [&>*]:shrink-0", axis === "vertical" && "flex-col", classNames, className),
1458
+ style: {
1459
+ position: "relative",
1460
+ ...axis === "vertical" ? {
1461
+ width: "100%",
1462
+ height: virtualizer.getTotalSize()
1463
+ } : {
1464
+ width: virtualizer.getTotalSize(),
1465
+ height: "100%"
1466
+ }
1467
+ },
1468
+ ref: forwardedRef
1469
+ }, virtualItems.map((virtualItem) => {
1470
+ const data = visibleItems[Math.floor(virtualItem.index / 2)];
1471
+ return /* @__PURE__ */ React6.createElement("div", {
1472
+ key: virtualItem.key,
1473
+ "data-index": virtualItem.index,
1474
+ style: {
1475
+ position: "absolute",
1476
+ top: 0,
1477
+ left: 0,
1478
+ ...axis === "vertical" ? {
1479
+ width: "100%",
1480
+ transform: `translateY(${virtualItem.start}px)`
1481
+ } : {
1482
+ height: "100%",
1483
+ transform: `translateX(${virtualItem.start}px)`
1484
+ }
1485
+ },
1486
+ ref: virtualizer.measureElement
1487
+ }, virtualItem.index % 2 === 0 ? /* @__PURE__ */ React6.createElement(Placeholder2, {
1488
+ axis,
1489
+ location: Math.floor(virtualItem.index / 2) + 0.5
1490
+ }) : /* @__PURE__ */ React6.createElement(Tile2, {
1491
+ id: getId(data),
1492
+ data,
1493
+ location: Math.floor(virtualItem.index / 2) + 1,
1494
+ debug
1495
+ }));
1496
+ }));
1617
1497
  });
1618
- ContainerInfo.displayName = "ContainerInfo";
1498
+ VirtualStackInner.displayName = "VirtualStackInner";
1499
+ var VirtualStack = VirtualStackInner;
1500
+ var Placeholder2 = (props) => {
1501
+ return /* @__PURE__ */ React6.createElement(Mosaic.Placeholder, {
1502
+ ...props,
1503
+ classNames: styles3.placeholder.root
1504
+ }, /* @__PURE__ */ React6.createElement("div", {
1505
+ className: mx6("flex bs-full bg-baseSurface border border-dashed border-separator rounded-sm", styles3.placeholder.content)
1506
+ }));
1507
+ };
1508
+ Placeholder2.displayName = "Placeholder";
1619
1509
 
1620
1510
  export {
1621
1511
  styles,
@@ -1626,9 +1516,6 @@ export {
1626
1516
  Focus,
1627
1517
  styles3,
1628
1518
  dropHandler,
1629
- useContainerDebug,
1630
- useEventHandlerAdapter,
1631
- useVisibleItems,
1632
1519
  Stack,
1633
1520
  VirtualStack,
1634
1521
  useRootContext,
@@ -1636,4 +1523,4 @@ export {
1636
1523
  useTileContext,
1637
1524
  Mosaic
1638
1525
  };
1639
- //# sourceMappingURL=chunk-4VDZJ3HV.mjs.map
1526
+ //# sourceMappingURL=chunk-QKMUWO5X.mjs.map