@byeolnaerim/flex-layout 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -1,9 +1,10 @@
1
- import { useState, useEffect, useRef, useCallback } from 'react';
1
+ import { createContext, memo, useRef, useState, useEffect, Children, isValidElement, Fragment as Fragment$1, useCallback, useContext, useLayoutEffect, cloneElement } from 'react';
2
2
  import equal from 'fast-deep-equal';
3
- import { BehaviorSubject, Subject, combineLatest, map as map$1, filter as filter$1, switchMap, EMPTY, fromEvent, buffer, debounceTime, distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs';
4
- import { filter, map, distinctUntilChanged } from 'rxjs/operators';
3
+ import { BehaviorSubject, Subject, fromEvent, combineLatest, map as map$1, filter as filter$1, switchMap, EMPTY, buffer, debounceTime, distinctUntilChanged as distinctUntilChanged$1, take as take$1 } from 'rxjs';
4
+ import { throttleTime, take, filter, map, distinctUntilChanged } from 'rxjs/operators';
5
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
6
 
6
- // src/flex-layout/providers/FlexLayoutHooks.tsx
7
+ // src/flex-layout/components/FlexLayout.tsx
7
8
  function updateScrollStore(subject, newValue) {
8
9
  const currentValue = subject.getValue();
9
10
  if (!equal(currentValue, newValue)) {
@@ -600,6 +601,451 @@ var useDoubleClick = (containerName, opt) => {
600
601
  }, [containerName]);
601
602
  return { isOpen, isDoubleClick, setIsDoubleClick };
602
603
  };
604
+
605
+ // src/flex-layout/styles/FlexLayout.module.css
606
+ var FlexLayout_default = {};
607
+ var FlexLayoutContext = createContext(null);
608
+ function useFlexLayoutContext() {
609
+ const context = useContext(FlexLayoutContext);
610
+ if (!context) {
611
+ throw new Error(
612
+ "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
613
+ );
614
+ }
615
+ return context;
616
+ }
617
+ function FlexLayoutProvider({
618
+ value,
619
+ children
620
+ }) {
621
+ return /* @__PURE__ */ jsx(FlexLayoutContext.Provider, { value, children });
622
+ }
623
+ var FlexLayout = ({
624
+ layoutName,
625
+ direction,
626
+ children,
627
+ ref,
628
+ className,
629
+ panelClassName,
630
+ panelMovementMode = "divorce",
631
+ ...props
632
+ }) => {
633
+ const containerCount = Children.count(children);
634
+ const fitContent = direction === "row" ? "width" : "height";
635
+ const isFragmentElement = (node) => isValidElement(node) && node.type === Fragment$1;
636
+ const nodes = Children.toArray(children).flatMap(
637
+ (node) => isFragmentElement(node) ? Children.toArray(node.props.children) : [node]
638
+ );
639
+ const flattenedChildren = nodes.filter(
640
+ isValidElement
641
+ );
642
+ if (flattenedChildren.length === 0) {
643
+ return null;
644
+ }
645
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
646
+ FlexLayoutProvider,
647
+ {
648
+ value: {
649
+ layoutName,
650
+ direction,
651
+ panelMovementMode,
652
+ panelClassName,
653
+ containerCount,
654
+ fitContent
655
+ },
656
+ children: /* @__PURE__ */ jsx(
657
+ "div",
658
+ {
659
+ className: `${FlexLayout_default["flex-layout"]} ${className && className !== "" ? className : ""}`,
660
+ ...ref ? { ref } : {},
661
+ ...props,
662
+ "data-layout_name": layoutName,
663
+ "data-direction": direction,
664
+ children: flattenedChildren.map((child, index) => {
665
+ if (!child || !isValidElement(child)) return null;
666
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
667
+ child,
668
+ /* @__PURE__ */ jsx(
669
+ ContainerOpenCloseProvider,
670
+ {
671
+ layoutName,
672
+ containerName: child.props.containerName,
673
+ sizeName: fitContent
674
+ }
675
+ )
676
+ ] }, index);
677
+ })
678
+ }
679
+ )
680
+ }
681
+ ) });
682
+ };
683
+ var FlexLayout_default2 = FlexLayout;
684
+ var useSize = (sizeName) => {
685
+ const ref = useRef(null);
686
+ const [size, setSize] = useState(void 0);
687
+ useLayoutEffect(() => {
688
+ if (!ref.current) return;
689
+ const handleResize = () => {
690
+ if (ref.current) {
691
+ const newSize = ref.current.getBoundingClientRect()[sizeName];
692
+ setSize(newSize);
693
+ }
694
+ };
695
+ handleResize();
696
+ const resizeObserver = new ResizeObserver(() => {
697
+ handleResize();
698
+ });
699
+ resizeObserver.observe(ref.current);
700
+ window.addEventListener("resize", handleResize);
701
+ return () => {
702
+ resizeObserver.disconnect();
703
+ window.removeEventListener("resize", handleResize);
704
+ };
705
+ }, [sizeName]);
706
+ return { ref, size };
707
+ };
708
+ var flexDirectionModel = {
709
+ row: {
710
+ xy: "x",
711
+ targetDirection: "left",
712
+ nextDirection: "right",
713
+ sizeName: "width",
714
+ resizeCursor: "ew-resize"
715
+ },
716
+ column: {
717
+ xy: "y",
718
+ targetDirection: "top",
719
+ nextDirection: "bottom",
720
+ sizeName: "height",
721
+ resizeCursor: "ns-resize"
722
+ }
723
+ };
724
+ var FlexLayoutResizePanel = ({
725
+ direction,
726
+ containerCount,
727
+ panelMode = "default",
728
+ containerName,
729
+ layoutName,
730
+ panelClassName,
731
+ panelMovementMode
732
+ }) => {
733
+ let isResizePanelClickRef = useRef(false);
734
+ let prevTouchEvent = null;
735
+ let parentSizeRef = useRef(0);
736
+ let totalMovementRef = useRef(0);
737
+ const containerCountRef = useRef(containerCount);
738
+ useEffect(() => {
739
+ return () => {
740
+ document.body.style.cursor = "";
741
+ };
742
+ }, []);
743
+ useEffect(() => {
744
+ containerCountRef.current = containerCount;
745
+ }, [containerCount]);
746
+ const panelRef = useRef(null);
747
+ const panelMouseDownEvent = (event) => {
748
+ if (!panelRef.current || !panelRef.current.parentElement) return;
749
+ isResizePanelClickRef.current = true;
750
+ containerCountRef.current = [
751
+ ...panelRef.current.parentElement.children
752
+ ].filter((e) => e.hasAttribute("data-container_name")).length;
753
+ const sizeName = flexDirectionModel[direction].sizeName;
754
+ parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
755
+ prevTouchEvent = null;
756
+ totalMovementRef.current = 0;
757
+ if (!parentSizeRef.current) return;
758
+ document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
759
+ };
760
+ const panelMouseUpEvent = () => {
761
+ isResizePanelClickRef.current = false;
762
+ parentSizeRef.current = 0;
763
+ prevTouchEvent = null;
764
+ totalMovementRef.current = 0;
765
+ document.body.style.cursor = "";
766
+ };
767
+ function moveMouseFlex(originTarget, resizePanel, moveEvent) {
768
+ const model = flexDirectionModel[direction];
769
+ const movement = moveEvent["movement" + model.xy.toUpperCase()];
770
+ totalMovementRef.current += movement;
771
+ const minSizeName = "min-" + model.sizeName;
772
+ const maxSizeName = "max-" + model.sizeName;
773
+ let targetElement = findNotCloseFlexContent(
774
+ originTarget,
775
+ "previousElementSibling"
776
+ );
777
+ if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
778
+ targetElement = originTarget;
779
+ let nextElement = findNotCloseFlexContent(
780
+ resizePanel.nextElementSibling,
781
+ "nextElementSibling"
782
+ );
783
+ if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
784
+ nextElement = resizePanel.nextElementSibling;
785
+ if (!targetElement || !nextElement) return;
786
+ const targetRect = targetElement.getBoundingClientRect();
787
+ const targetStyle = window.getComputedStyle(targetElement);
788
+ const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
789
+ const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
790
+ const nextRect = nextElement.getBoundingClientRect();
791
+ const nextStyle = window.getComputedStyle(nextElement);
792
+ const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
793
+ const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
794
+ let targetSize = targetRect[model.sizeName] + movement;
795
+ let nextElementSize = nextRect[model.sizeName] - movement;
796
+ if (targetMaxSize > 0 && targetSize > targetMaxSize) {
797
+ return;
798
+ }
799
+ if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
800
+ return;
801
+ }
802
+ if (isOverMove(targetSize, targetMinSize)) {
803
+ targetSize = 0;
804
+ nextElementSize = nextRect[model.sizeName];
805
+ } else if (isOverMove(nextElementSize, nextMinSize)) {
806
+ nextElementSize = 0;
807
+ targetSize = targetRect[model.sizeName];
808
+ }
809
+ const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
810
+ const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
811
+ targetElement.style.flex = `${targetFlexGrow} 1 0%`;
812
+ nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
813
+ }
814
+ useEffect(() => {
815
+ const addGlobalMoveEvent = (event) => {
816
+ if (!isResizePanelClickRef.current || !panelRef.current) {
817
+ return;
818
+ }
819
+ event.preventDefault();
820
+ const targetElement = panelRef.current.previousElementSibling;
821
+ const targetPanel = panelRef.current;
822
+ if (!targetElement || !targetPanel) return;
823
+ let move = { movementX: 0, movementY: 0 };
824
+ if (window.TouchEvent && event instanceof window.TouchEvent) {
825
+ if (!prevTouchEvent) {
826
+ prevTouchEvent = event;
827
+ return;
828
+ }
829
+ move.movementX = (prevTouchEvent.touches[0].pageX - event.touches[0].pageX) * -2;
830
+ move.movementY = (prevTouchEvent.touches[0].pageY - event.touches[0].pageY) * -2;
831
+ prevTouchEvent = event;
832
+ } else {
833
+ move.movementX = event.movementX;
834
+ move.movementY = event.movementY;
835
+ }
836
+ moveMouseFlex(targetElement, targetPanel, move);
837
+ };
838
+ ["mousemove", "touchmove"].forEach((eventName) => {
839
+ window.addEventListener(eventName, addGlobalMoveEvent, {
840
+ passive: false
841
+ });
842
+ });
843
+ ["mouseup", "touchend"].forEach((eventName) => {
844
+ window.addEventListener(eventName, panelMouseUpEvent);
845
+ });
846
+ return () => {
847
+ ["mousemove", "touchmove"].forEach((eventName) => {
848
+ window.removeEventListener(eventName, addGlobalMoveEvent);
849
+ });
850
+ ["mouseup", "touchend"].forEach((eventName) => {
851
+ window.removeEventListener(eventName, panelMouseUpEvent);
852
+ });
853
+ };
854
+ }, []);
855
+ useEffect(() => {
856
+ if (!panelRef.current) return;
857
+ setResizePanelRef(layoutName, containerName, panelRef);
858
+ }, [containerName, layoutName]);
859
+ return /* @__PURE__ */ jsx(
860
+ "div",
861
+ {
862
+ id: containerName + "_resize_panel",
863
+ className: `${FlexLayout_default["flex-resize-panel"]} ${FlexLayout_default[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
864
+ ref: panelRef,
865
+ onMouseDown: panelMouseDownEvent,
866
+ onTouchStart: panelMouseDownEvent,
867
+ children: /* @__PURE__ */ jsx("div", { className: FlexLayout_default.hover })
868
+ }
869
+ );
870
+ };
871
+ var FlexLayoutResizePanel_default = FlexLayoutResizePanel;
872
+ var FlexLayoutContainer = ({
873
+ isFitContent,
874
+ isFitResize,
875
+ // fitContent,
876
+ // containerCount,
877
+ // layoutName,
878
+ containerName,
879
+ grow: initialGrow,
880
+ prevGrow: initialPrevGrow,
881
+ isInitialResizable,
882
+ isResizePanel,
883
+ children,
884
+ className,
885
+ panelMode
886
+ }) => {
887
+ const {
888
+ direction,
889
+ panelMovementMode,
890
+ panelClassName,
891
+ layoutName,
892
+ fitContent,
893
+ containerCount
894
+ } = useFlexLayoutContext();
895
+ const { ref, size } = (
896
+ // isFitContent && fitContent
897
+ //?
898
+ useSize(fitContent)
899
+ );
900
+ const flexContainerNodeRef = useRef(null);
901
+ const flexContainerRef = useCallback(
902
+ (node) => {
903
+ flexContainerNodeRef.current = node;
904
+ if (node !== null) {
905
+ setContainerRef(layoutName, containerName, { current: node });
906
+ }
907
+ },
908
+ [layoutName, containerName]
909
+ );
910
+ const [growState, setGrowState] = useState(initialGrow);
911
+ useEffect(() => {
912
+ setGrowState(initialGrow);
913
+ }, [initialGrow]);
914
+ const [prevGrowState, setPrevGrowState] = useState(
915
+ initialPrevGrow
916
+ );
917
+ const [isFirstLoad, setIsFirstLoad] = useState(true);
918
+ useEffect(() => {
919
+ if (!flexContainerNodeRef.current) return;
920
+ setContainerRef(layoutName, containerName, flexContainerNodeRef);
921
+ return () => {
922
+ setContainerRef(layoutName, containerName, {
923
+ current: null
924
+ });
925
+ };
926
+ }, [containerName, layoutName]);
927
+ useEffect(() => {
928
+ if (typeof window == "undefined" || flexContainerNodeRef.current === null)
929
+ return;
930
+ const storedGrow = sessionStorage.getItem(containerName);
931
+ if (storedGrow !== null) {
932
+ const parsed = parseFloat(storedGrow);
933
+ if (!isNaN(parsed)) {
934
+ flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
935
+ setGrowState(parsed);
936
+ }
937
+ }
938
+ }, [containerName]);
939
+ useEffect(() => {
940
+ if (!flexContainerNodeRef.current) return;
941
+ const targetNode = flexContainerNodeRef.current;
942
+ const observer = new MutationObserver((mutations) => {
943
+ for (const mutation of mutations) {
944
+ if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
945
+ const flexValue = targetNode.style.flex;
946
+ const parsedGrow = parseFloat(flexValue.split(" ")[0]);
947
+ if (!isNaN(parsedGrow)) {
948
+ setGrowState(parsedGrow);
949
+ }
950
+ }
951
+ }
952
+ });
953
+ observer.observe(targetNode, {
954
+ attributes: true,
955
+ attributeFilter: ["style"],
956
+ attributeOldValue: true
957
+ });
958
+ return () => {
959
+ observer.disconnect();
960
+ };
961
+ }, [containerName]);
962
+ useEffect(() => {
963
+ if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent)
964
+ return;
965
+ requestAnimationFrame(() => {
966
+ if (!flexContainerNodeRef.current) return;
967
+ const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
968
+ const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
969
+ if (isFitContent) {
970
+ flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
971
+ }
972
+ if (!isFitResize && isFirstLoad) {
973
+ setIsFirstLoad(false);
974
+ return;
975
+ }
976
+ if (getGrow(flexContainerNodeRef.current) != 0 && isFitResize) {
977
+ const newGrow = mathGrow(size, parentSize, containerCount);
978
+ setPrevGrowState(growState);
979
+ setGrowState(newGrow);
980
+ }
981
+ });
982
+ }, [size, containerCount, isFitResize, children]);
983
+ useEffect(() => {
984
+ if (!flexContainerNodeRef.current) return;
985
+ let notGrowList = [];
986
+ let containerList = [
987
+ ...flexContainerNodeRef.current.parentElement?.children || []
988
+ ].filter((e) => e.hasAttribute("data-container_name"));
989
+ let remainingGrow = containerList.reduce((t, e, i) => {
990
+ let item = e;
991
+ if (item.classList.contains(FlexLayout_default["flex-resize-panel"])) return t;
992
+ if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
993
+ notGrowList.push(item);
994
+ return t;
995
+ }
996
+ let grow = parseFloat(item.dataset.grow || "");
997
+ item.style.flex = `${grow} 1 0%`;
998
+ t -= grow;
999
+ return t;
1000
+ }, containerList.length);
1001
+ if (notGrowList.length != 0) {
1002
+ let resizeWeight = mathWeight(notGrowList.length, remainingGrow);
1003
+ notGrowList.forEach((e) => {
1004
+ e.dataset.grow = resizeWeight.toString();
1005
+ e.style.flex = `${resizeWeight} 1 0%`;
1006
+ });
1007
+ }
1008
+ }, []);
1009
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1010
+ /* @__PURE__ */ jsx(
1011
+ "div",
1012
+ {
1013
+ id: containerName,
1014
+ "data-container_name": containerName,
1015
+ ref: flexContainerRef,
1016
+ className: `${FlexLayout_default["flex-container"]} ${className && className !== "" ? className : ""}`,
1017
+ ...growState !== void 0 ? { ["data-grow"]: growState } : {},
1018
+ ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
1019
+ "data-is_resize": isInitialResizable,
1020
+ "data-is_resize_panel": isResizePanel,
1021
+ style: growState !== void 0 && {
1022
+ flex: `${growState} 1 0%`
1023
+ } || {},
1024
+ children: isFitContent && /* @__PURE__ */ jsx(
1025
+ "div",
1026
+ {
1027
+ className: `${FlexLayout_default["flex-content-fit-wrapper"]}`,
1028
+ ref,
1029
+ children
1030
+ }
1031
+ ) || children
1032
+ }
1033
+ ),
1034
+ isResizePanel && /* @__PURE__ */ jsx(
1035
+ FlexLayoutResizePanel_default,
1036
+ {
1037
+ containerName,
1038
+ layoutName,
1039
+ direction,
1040
+ containerCount,
1041
+ panelMode,
1042
+ panelClassName,
1043
+ panelMovementMode
1044
+ }
1045
+ )
1046
+ ] });
1047
+ };
1048
+ var FlexLayoutContainer_default = FlexLayoutContainer;
603
1049
  var dragState = new Subject();
604
1050
  var filterChildren = (obj) => {
605
1051
  const { children, ...rest } = obj || {};
@@ -810,7 +1256,2150 @@ var useFolderEvent = () => {
810
1256
  }, []);
811
1257
  return { folderEvent };
812
1258
  };
1259
+ function useFlexLayoutSplitScreen({
1260
+ isSplitInitial = false,
1261
+ parentDirection,
1262
+ directionInitial = "row",
1263
+ selfContainerName,
1264
+ parentLayoutName,
1265
+ layoutName
1266
+ }) {
1267
+ const [direction, setDirection] = useState(
1268
+ directionInitial
1269
+ );
1270
+ const [isSplit, setIsSplit] = useState(isSplitInitial);
1271
+ const [boundaryContainerSize, setBoundaryContainerSize] = useState(null);
1272
+ const [centerDropTargetComponent, setCenterDropTargetComponent] = useState([]);
1273
+ const [afterDropTargetComponent, setAfterDropTargetComponent] = useState([]);
1274
+ const [beforeDropTargetComponent, setBeforeDropTargetComponent] = useState([]);
1275
+ const layoutRef = useRef(null);
1276
+ const dragState2 = useDragCapture(layoutRef);
1277
+ useEffect(() => {
1278
+ if (!dragState2) {
1279
+ setBoundaryContainerSize(null);
1280
+ return;
1281
+ }
1282
+ const {
1283
+ isDrop,
1284
+ isDragging,
1285
+ positionName,
1286
+ containerName,
1287
+ children: dropComponent,
1288
+ isOver,
1289
+ navigationTitle,
1290
+ dropEndCallback,
1291
+ x,
1292
+ y,
1293
+ screenKey
1294
+ } = dragState2;
1295
+ const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
1296
+ if ((isOver || isDrop) && boundaryContainerSize) {
1297
+ setBoundaryContainerSize(null);
1298
+ }
1299
+ if (selfContainerName.startsWith(containerName)) {
1300
+ return;
1301
+ }
1302
+ if (isDrop && screenKey) {
1303
+ const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
1304
+ if (!isSplit && !isOver) {
1305
+ if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
1306
+ setIsSplit(true);
1307
+ setDirection(dropDirection);
1308
+ }
1309
+ dropMovementEventSubject.next({
1310
+ state: "append",
1311
+ targetContainerName: containerName,
1312
+ targetParentLayoutName: parentLayoutName,
1313
+ targetLayoutName: layoutName,
1314
+ targetComponent: dropComponent,
1315
+ orderName,
1316
+ x,
1317
+ y,
1318
+ dropEndCallback,
1319
+ dropTargetComponentEvent: {
1320
+ navigationTitle,
1321
+ dropDocumentOutsideOption: dragState2?.dropDocumentOutsideOption,
1322
+ direction: dropDirection,
1323
+ screenKey
1324
+ }
1325
+ });
1326
+ }
1327
+ }
1328
+ if (isDragging && !isSplit && !isOver) {
1329
+ const newSize = {
1330
+ left: positionName === "rightBoundary" ? "50%" : "0",
1331
+ top: positionName === "bottomBoundary" ? "50%" : "0",
1332
+ width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
1333
+ height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
1334
+ };
1335
+ if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
1336
+ setBoundaryContainerSize(newSize);
1337
+ }
1338
+ }
1339
+ }, [
1340
+ dragState2,
1341
+ isSplit,
1342
+ boundaryContainerSize,
1343
+ parentLayoutName,
1344
+ layoutName,
1345
+ selfContainerName,
1346
+ direction
1347
+ ]);
1348
+ return {
1349
+ direction,
1350
+ setDirection,
1351
+ isSplit,
1352
+ setIsSplit,
1353
+ boundaryContainerSize,
1354
+ //setBoundaryContainerSize,
1355
+ centerDropTargetComponent,
1356
+ afterDropTargetComponent,
1357
+ beforeDropTargetComponent,
1358
+ setAfterDropTargetComponent,
1359
+ setBeforeDropTargetComponent,
1360
+ setCenterDropTargetComponent,
1361
+ //dropTargetComponent,
1362
+ //setDropTargetComponent,
1363
+ //setDropPosition,
1364
+ isOver: dragState2?.isOver,
1365
+ layoutRef
1366
+ };
1367
+ }
1368
+ var MAX_STEP = 18;
1369
+ function edgeVelocity(x, y) {
1370
+ const w = window.innerWidth, h = window.innerHeight;
1371
+ const mx = w * 0.15, my = h * 0.15;
1372
+ let vx = 0;
1373
+ if (x < mx)
1374
+ vx = -((mx - x) / mx) * MAX_STEP;
1375
+ else if (x > w - mx)
1376
+ vx = (x - (w - mx)) / mx * MAX_STEP;
1377
+ let vy = 0;
1378
+ if (y < my)
1379
+ vy = -((my - y) / my) * MAX_STEP;
1380
+ else if (y > h - my)
1381
+ vy = (y - (h - my)) / my * MAX_STEP;
1382
+ return { vx, vy };
1383
+ }
1384
+ function FlexLayoutSplitScreenDragBox({
1385
+ onMouseDown,
1386
+ onTouchStart,
1387
+ dropEndCallback,
1388
+ style,
1389
+ navigationTitle,
1390
+ targetComponent,
1391
+ containerName,
1392
+ children,
1393
+ className,
1394
+ dropDocumentOutsideOption,
1395
+ screenKey = Array.from(
1396
+ window.crypto.getRandomValues(new Uint32Array(16)),
1397
+ (e) => e.toString(32).padStart(2, "0")
1398
+ ).join(""),
1399
+ isBlockingActiveInput = false,
1400
+ customData = {},
1401
+ scrollTargetRef,
1402
+ ...props
1403
+ }) {
1404
+ const scrollRAF = useRef(null);
1405
+ const velocity = useRef({ vx: 0, vy: 0 });
1406
+ const ref = useRef(null);
1407
+ const clonedNodeRef = useRef(null);
1408
+ const clonedWidth = useRef(null);
1409
+ const clonedHeight = useRef(null);
1410
+ const hrefUrlRef = useRef("");
1411
+ const { handleStart, handleMove, handleEnd } = useDragEvents({
1412
+ isBlockingActiveInput
1413
+ });
1414
+ const handleMoveWrapper = (event) => {
1415
+ let x = 0;
1416
+ let y = 0;
1417
+ if (event.type === "touchmove") {
1418
+ const t = event.touches[0];
1419
+ x = t.clientX;
1420
+ y = t.clientY;
1421
+ } else {
1422
+ const m = event;
1423
+ x = m.clientX;
1424
+ y = m.clientY;
1425
+ }
1426
+ const { vx, vy } = edgeVelocity(x, y);
1427
+ const inEdge = vx !== 0 || vy !== 0;
1428
+ if (clonedNodeRef.current?.isConnected && !inEdge) {
1429
+ event.preventDefault();
1430
+ if (scrollRAF.current) {
1431
+ cancelAnimationFrame(scrollRAF.current);
1432
+ scrollRAF.current = null;
1433
+ }
1434
+ }
1435
+ if (clonedNodeRef.current?.isConnected && inEdge) {
1436
+ event.preventDefault();
1437
+ velocity.current = { vx, vy };
1438
+ if (!scrollRAF.current) {
1439
+ const step = () => {
1440
+ scrollTargetRef?.current?.scrollBy(
1441
+ velocity.current.vx,
1442
+ velocity.current.vy
1443
+ );
1444
+ if (velocity.current.vx === 0 && velocity.current.vy === 0) {
1445
+ scrollRAF.current = null;
1446
+ return;
1447
+ }
1448
+ scrollRAF.current = requestAnimationFrame(step);
1449
+ };
1450
+ scrollRAF.current = requestAnimationFrame(step);
1451
+ }
1452
+ }
1453
+ if (event.type !== "touchmove") {
1454
+ event.preventDefault();
1455
+ }
1456
+ handleMove({
1457
+ event,
1458
+ notDragCallback: ({ x: x2, y: y2 }) => {
1459
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1460
+ },
1461
+ dragStartCallback: ({ x: x2, y: y2 }) => {
1462
+ if (!clonedNodeRef.current) return;
1463
+ navigator.vibrate(100);
1464
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1465
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1466
+ },
1467
+ moveingCallback: ({ x: x2, y: y2 }) => {
1468
+ if (clonedNodeRef.current?.isConnected) {
1469
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1470
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1471
+ }
1472
+ dragState.next({
1473
+ isDragging: true,
1474
+ isDrop: false,
1475
+ navigationTitle,
1476
+ children: targetComponent,
1477
+ x: x2,
1478
+ y: y2,
1479
+ containerName,
1480
+ dropDocumentOutsideOption,
1481
+ customData
1482
+ });
1483
+ }
1484
+ });
1485
+ };
1486
+ const handleEndWrapper = (event) => {
1487
+ if (scrollRAF.current !== null) {
1488
+ cancelAnimationFrame(scrollRAF.current);
1489
+ scrollRAF.current = null;
1490
+ }
1491
+ velocity.current = { vx: 0, vy: 0 };
1492
+ handleEnd({
1493
+ event,
1494
+ dragEndCallback: ({ x, y }) => {
1495
+ const href = hrefUrlRef.current;
1496
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1497
+ if (dropDocumentOutsideOption && isDocumentOut({ x, y })) {
1498
+ if (dropDocumentOutsideOption.isNewTap || !dropDocumentOutsideOption.widthRatio && !dropDocumentOutsideOption.heightRatio) {
1499
+ window.open(href, "_blank");
1500
+ } else {
1501
+ const width = window.innerWidth * (dropDocumentOutsideOption.widthRatio || 1);
1502
+ const height = window.innerHeight * (dropDocumentOutsideOption.heightRatio || 1);
1503
+ window.open(
1504
+ href,
1505
+ "_blank",
1506
+ `width=${width},height=${height},left=${window.screenLeft - x * -1 - width},top=${window.screenTop + y}`
1507
+ );
1508
+ }
1509
+ }
1510
+ dragState.next({
1511
+ isDragging: false,
1512
+ isDrop: true,
1513
+ navigationTitle,
1514
+ children: targetComponent,
1515
+ x,
1516
+ y,
1517
+ containerName,
1518
+ dropDocumentOutsideOption,
1519
+ dropEndCallback,
1520
+ screenKey,
1521
+ customData
1522
+ });
1523
+ }
1524
+ });
1525
+ };
1526
+ useEffect(() => {
1527
+ if (ref.current) {
1528
+ const clone = ref.current.cloneNode(true);
1529
+ const originRect = ref.current.getBoundingClientRect();
1530
+ clone.style.width = originRect.width + "px";
1531
+ clone.style.height = originRect.height + "px";
1532
+ clone.style.opacity = "0.3";
1533
+ clone.style.backdropFilter = "blur(6px)";
1534
+ clonedWidth.current = originRect.width;
1535
+ clonedHeight.current = originRect.height;
1536
+ if (dropDocumentOutsideOption?.openUrl) {
1537
+ hrefUrlRef.current = dropDocumentOutsideOption.openUrl;
1538
+ const href = document.createElement("span");
1539
+ href.textContent = hrefUrlRef.current;
1540
+ clone.prepend(href);
1541
+ }
1542
+ if (navigationTitle) {
1543
+ const title = document.createElement("span");
1544
+ title.textContent = navigationTitle;
1545
+ clone.prepend(title);
1546
+ }
1547
+ clone.style.position = "fixed";
1548
+ clonedNodeRef.current = clone;
1549
+ clonedNodeRef.current.classList.add(
1550
+ FlexLayout_default["flex-split-screen-drag-box-clone"]
1551
+ );
1552
+ }
1553
+ }, []);
1554
+ useEffect(() => {
1555
+ const moveEvents = [
1556
+ "mousemove",
1557
+ "touchmove"
1558
+ ];
1559
+ const endEvents = ["mouseup", "touchend"];
1560
+ moveEvents.forEach((eventName) => {
1561
+ window.addEventListener(eventName, handleMoveWrapper, {
1562
+ passive: false
1563
+ });
1564
+ });
1565
+ endEvents.forEach((eventName) => {
1566
+ window.addEventListener(eventName, handleEndWrapper);
1567
+ });
1568
+ return () => {
1569
+ moveEvents.forEach((eventName) => {
1570
+ window.removeEventListener(eventName, handleMoveWrapper);
1571
+ });
1572
+ endEvents.forEach((eventName) => {
1573
+ window.removeEventListener(eventName, handleEndWrapper);
1574
+ });
1575
+ };
1576
+ }, [
1577
+ customData,
1578
+ targetComponent,
1579
+ dropDocumentOutsideOption,
1580
+ screenKey,
1581
+ isBlockingActiveInput,
1582
+ containerName,
1583
+ navigationTitle,
1584
+ dropEndCallback
1585
+ ]);
1586
+ useEffect(() => {
1587
+ const el = ref.current;
1588
+ if (!el) return;
1589
+ const onCtx = (e) => e.preventDefault();
1590
+ el.addEventListener("contextmenu", onCtx);
1591
+ return () => {
1592
+ el.removeEventListener("contextmenu", onCtx);
1593
+ };
1594
+ }, []);
1595
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1596
+ "div",
1597
+ {
1598
+ className: `${className || ""} ${FlexLayout_default["flex-split-screen-drag-box"]}`,
1599
+ ref,
1600
+ onContextMenu: (e) => e.preventDefault(),
1601
+ onMouseDown: (ev) => {
1602
+ if (onMouseDown) {
1603
+ Promise.resolve().then(() => onMouseDown(ev));
1604
+ }
1605
+ handleStart({
1606
+ event: ev,
1607
+ dragStartCallback: ({ x, y }) => {
1608
+ if (clonedNodeRef.current) {
1609
+ document.body.appendChild(
1610
+ clonedNodeRef.current
1611
+ );
1612
+ if (ref.current) {
1613
+ const originRect = ref.current.getBoundingClientRect();
1614
+ clonedNodeRef.current.style.width = originRect.width + "px";
1615
+ clonedNodeRef.current.style.height = originRect.height + "px";
1616
+ clonedWidth.current = originRect.width;
1617
+ clonedHeight.current = originRect.height;
1618
+ }
1619
+ }
1620
+ if (clonedNodeRef.current?.isConnected) {
1621
+ navigator.vibrate(100);
1622
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1623
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1624
+ }
1625
+ dragState.next({
1626
+ isDragging: true,
1627
+ isDrop: false,
1628
+ navigationTitle,
1629
+ children: targetComponent,
1630
+ x,
1631
+ y,
1632
+ containerName,
1633
+ dropDocumentOutsideOption,
1634
+ customData
1635
+ });
1636
+ }
1637
+ });
1638
+ },
1639
+ onTouchStart: (ev) => {
1640
+ if (onTouchStart) {
1641
+ Promise.resolve().then(() => onTouchStart(ev));
1642
+ }
1643
+ handleStart({
1644
+ event: ev,
1645
+ dragStartCallback: ({ x, y }) => {
1646
+ if (clonedNodeRef.current) {
1647
+ document.body.appendChild(
1648
+ clonedNodeRef.current
1649
+ );
1650
+ if (ref.current) {
1651
+ const originRect = ref.current.getBoundingClientRect();
1652
+ clonedNodeRef.current.style.width = originRect.width + "px";
1653
+ clonedNodeRef.current.style.height = originRect.height + "px";
1654
+ clonedWidth.current = originRect.width;
1655
+ clonedHeight.current = originRect.height;
1656
+ }
1657
+ }
1658
+ if (clonedNodeRef.current?.isConnected) {
1659
+ navigator.vibrate(100);
1660
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1661
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1662
+ }
1663
+ dragState.next({
1664
+ isDragging: true,
1665
+ isDrop: false,
1666
+ navigationTitle,
1667
+ children: targetComponent,
1668
+ x,
1669
+ y,
1670
+ containerName,
1671
+ dropDocumentOutsideOption,
1672
+ customData
1673
+ });
1674
+ }
1675
+ });
1676
+ },
1677
+ style: { ...style },
1678
+ ...props,
1679
+ children
1680
+ }
1681
+ ) });
1682
+ }
1683
+
1684
+ // src/flex-layout/styles/listScroll.module.css
1685
+ var listScroll_default = {};
1686
+ var FlexLayoutSplitScreenScrollBox = ({
1687
+ className,
1688
+ children,
1689
+ keyName,
1690
+ direction,
1691
+ isDefaultScrollStyle = false,
1692
+ ...props
1693
+ }) => {
1694
+ const scrollRef = useRef(null);
1695
+ const [isMouseDown, setIsMouseDown] = useState(false);
1696
+ const scrollEventSubject = useRef(new Subject());
1697
+ useEffect(() => {
1698
+ const mouseUpSubscribe = fromEvent(
1699
+ window,
1700
+ "mouseup"
1701
+ ).subscribe(() => {
1702
+ setIsMouseDown(false);
1703
+ });
1704
+ const scrollEventSubscribe = scrollEventSubject.current.pipe(throttleTime(70)).subscribe((position) => {
1705
+ setScrollPosition(keyName, position);
1706
+ });
1707
+ const scrollSubscribe = getScrollPosition(keyName).pipe(take(1)).subscribe((position) => {
1708
+ if (scrollRef.current && position) {
1709
+ scrollRef.current.scrollLeft = position.x;
1710
+ scrollRef.current.scrollTop = position.y;
1711
+ }
1712
+ });
1713
+ return () => {
1714
+ removeScrollPosition(keyName);
1715
+ mouseUpSubscribe.unsubscribe();
1716
+ scrollSubscribe.unsubscribe();
1717
+ scrollEventSubscribe.unsubscribe();
1718
+ };
1719
+ }, [keyName]);
1720
+ useEffect(() => {
1721
+ if (!scrollRef.current) return;
1722
+ let animationFrameId = null;
1723
+ const handleWheel = (event) => {
1724
+ if (!scrollRef.current || direction !== "x") return;
1725
+ if (scrollRef.current.matches(":hover")) {
1726
+ event.preventDefault();
1727
+ const { deltaY } = event;
1728
+ const newScrollLeft = scrollRef.current.scrollLeft + deltaY;
1729
+ if (animationFrameId) {
1730
+ cancelAnimationFrame(animationFrameId);
1731
+ }
1732
+ animationFrameId = requestAnimationFrame(() => {
1733
+ scrollRef.current.scrollLeft = newScrollLeft;
1734
+ scrollEventSubject.current.next({
1735
+ x: newScrollLeft,
1736
+ y: scrollRef.current.scrollTop
1737
+ });
1738
+ animationFrameId = null;
1739
+ });
1740
+ }
1741
+ };
1742
+ scrollRef.current.addEventListener("wheel", handleWheel, {
1743
+ passive: false
1744
+ });
1745
+ return () => {
1746
+ scrollRef.current?.removeEventListener("wheel", handleWheel);
1747
+ };
1748
+ }, []);
1749
+ return /* @__PURE__ */ jsx(
1750
+ "div",
1751
+ {
1752
+ ref: scrollRef,
1753
+ onMouseUp: () => setIsMouseDown(false),
1754
+ onMouseDown: () => setIsMouseDown(true),
1755
+ onMouseMove: (event) => {
1756
+ if (!scrollRef.current || !isMouseDown || direction !== "x")
1757
+ return;
1758
+ scrollRef.current.scrollLeft += event.movementX * -1;
1759
+ scrollEventSubject.current.next({
1760
+ x: scrollRef.current.scrollLeft,
1761
+ y: scrollRef.current.scrollTop
1762
+ });
1763
+ },
1764
+ onScroll: () => {
1765
+ if (!scrollRef.current) return;
1766
+ scrollEventSubject.current.next({
1767
+ x: scrollRef.current.scrollLeft,
1768
+ y: scrollRef.current.scrollTop
1769
+ });
1770
+ },
1771
+ className: `${className || ""} ${isDefaultScrollStyle ? listScroll_default["default-scroll"] : listScroll_default["list-scroll"]} ${direction ? listScroll_default[direction] : ""}`,
1772
+ ...props,
1773
+ children
1774
+ }
1775
+ );
1776
+ };
1777
+ var FlexLayoutSplitScreenScrollBox_default = memo(FlexLayoutSplitScreenScrollBox);
1778
+ function FlexLayoutSplitScreenDragBoxContainer({
1779
+ className,
1780
+ children,
1781
+ layoutName,
1782
+ ...props
1783
+ }) {
1784
+ return /* @__PURE__ */ jsx(
1785
+ FlexLayoutSplitScreenScrollBox_default,
1786
+ {
1787
+ keyName: layoutName,
1788
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-container"]} ${className && className !== "" && className || ""}`,
1789
+ direction: "x",
1790
+ ...props,
1791
+ children
1792
+ }
1793
+ );
1794
+ }
1795
+ function FlexLayoutSplitScreenDragBoxItem({
1796
+ children,
1797
+ onClose,
1798
+ isActive,
1799
+ ...props
1800
+ }) {
1801
+ useEffect(() => {
1802
+ allSplitScreenCount.next(allSplitScreenCount.value + 1);
1803
+ return () => {
1804
+ if (allSplitScreenCount.value <= 1) return;
1805
+ allSplitScreenCount.next(allSplitScreenCount.value - 1);
1806
+ };
1807
+ }, []);
1808
+ return /* @__PURE__ */ jsxs(
1809
+ "div",
1810
+ {
1811
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-item"]} ${isActive ? FlexLayout_default["active"] : ""}`,
1812
+ ...props,
1813
+ children: [
1814
+ children,
1815
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: (ev) => onClose(ev), children: "X" })
1816
+ ]
1817
+ }
1818
+ );
1819
+ }
1820
+ function FlexLayoutSplitScreenDragBoxTitleMore({
1821
+ className,
1822
+ ...props
1823
+ }) {
1824
+ return /* @__PURE__ */ jsxs(
1825
+ "button",
1826
+ {
1827
+ ...props,
1828
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-more"]} ${className || ""}`,
1829
+ children: [
1830
+ /* @__PURE__ */ jsx("span", { children: "." }),
1831
+ /* @__PURE__ */ jsx("span", { children: "." }),
1832
+ /* @__PURE__ */ jsx("span", { children: "." })
1833
+ ]
1834
+ }
1835
+ );
1836
+ }
1837
+ function isOverDrop({
1838
+ x,
1839
+ y,
1840
+ element
1841
+ }) {
1842
+ const {
1843
+ x: elementX,
1844
+ y: elementY,
1845
+ right: elementRight,
1846
+ bottom: elementBottom
1847
+ } = element.getBoundingClientRect();
1848
+ const isElementOver = x < elementX || x > elementRight || y < elementY || y > elementBottom;
1849
+ return isElementOver;
1850
+ }
1851
+ function isInnerDrop({
1852
+ x,
1853
+ y,
1854
+ element
1855
+ }) {
1856
+ const {
1857
+ x: elementX,
1858
+ y: elementY,
1859
+ right: elementRight,
1860
+ bottom: elementBottom
1861
+ } = element.getBoundingClientRect();
1862
+ const isElementInner = x >= elementX && x <= elementRight && y >= elementY && y <= elementBottom;
1863
+ return isElementInner;
1864
+ }
1865
+ var handleUpdateDropTargetComponents = ({
1866
+ orderName,
1867
+ parentOrderName,
1868
+ containerName,
1869
+ parentLayoutName,
1870
+ layoutName,
1871
+ dropComponent,
1872
+ navigationTitle,
1873
+ nextContainerName,
1874
+ isUsePrefix = true,
1875
+ beforeDropTargetComponent,
1876
+ afterDropTargetComponent,
1877
+ centerDropTargetComponent,
1878
+ dropDocumentOutsideOption,
1879
+ screenKey = Array.from(
1880
+ window.crypto.getRandomValues(new Uint32Array(16)),
1881
+ (e) => e.toString(32).padStart(2, "0")
1882
+ ).join("")
1883
+ }) => {
1884
+ const nextContainerNameOrderName = parentOrderName ? parentOrderName : orderName;
1885
+ let listMap;
1886
+ let list;
1887
+ let key;
1888
+ if (nextContainerNameOrderName === orderName || nextContainerNameOrderName === "center") {
1889
+ listMap = orderName === "before" ? { beforeDropTargetComponent } : orderName === "after" ? { afterDropTargetComponent } : {
1890
+ centerDropTargetComponent: centerDropTargetComponent.filter(
1891
+ (e) => !e.containerName.split("_").at(0).startsWith(
1892
+ containerName.split("_").at(0)
1893
+ )
1894
+ )
1895
+ };
1896
+ } else {
1897
+ listMap = nextContainerNameOrderName === "before" ? { beforeDropTargetComponent } : { afterDropTargetComponent };
1898
+ }
1899
+ const entries = Object.entries(listMap)[0];
1900
+ key = entries[0];
1901
+ list = entries[1];
1902
+ const newComponent = {
1903
+ containerName: `${containerName + "_" + layoutName}${isUsePrefix ? "_" + orderName + "-" + list.length : ""}`,
1904
+ component: cloneElement(
1905
+ dropComponent,
1906
+ { key: screenKey, screenKey }
1907
+ ),
1908
+ navigationTitle,
1909
+ dropDocumentOutsideOption,
1910
+ screenKey: screenKey || Array.from(
1911
+ window.crypto.getRandomValues(new Uint32Array(16)),
1912
+ (e) => e.toString(32).padStart(2, "0")
1913
+ ).join("")
1914
+ };
1915
+ let allComponents;
1916
+ if (nextContainerName) {
1917
+ const index = list.findIndex(
1918
+ (item) => item.containerName === nextContainerName
1919
+ );
1920
+ if (index !== -1) {
1921
+ if (nextContainerNameOrderName === orderName) {
1922
+ if (orderName === "before") {
1923
+ allComponents = [
1924
+ ...list.slice(0, index),
1925
+ newComponent,
1926
+ ...list.slice(index)
1927
+ ];
1928
+ } else {
1929
+ allComponents = [
1930
+ ...list.slice(0, index + 1),
1931
+ newComponent,
1932
+ ...list.slice(index + 1)
1933
+ ];
1934
+ }
1935
+ } else {
1936
+ if (nextContainerNameOrderName === "after" && orderName === "before") {
1937
+ allComponents = [
1938
+ ...list.slice(0, index),
1939
+ newComponent,
1940
+ ...list.slice(index)
1941
+ ];
1942
+ } else if (nextContainerNameOrderName === "before" && orderName === "after") {
1943
+ allComponents = [
1944
+ ...list.slice(0, index + 1),
1945
+ newComponent,
1946
+ ...list.slice(index + 1)
1947
+ ];
1948
+ } else {
1949
+ if (orderName === "before") {
1950
+ allComponents = [
1951
+ ...list.slice(0, index),
1952
+ newComponent,
1953
+ ...list.slice(index)
1954
+ ];
1955
+ } else {
1956
+ allComponents = [
1957
+ ...list.slice(0, index + 1),
1958
+ newComponent,
1959
+ ...list.slice(index + 1)
1960
+ ];
1961
+ }
1962
+ }
1963
+ }
1964
+ } else {
1965
+ if (nextContainerNameOrderName === "center" && orderName === "after") {
1966
+ allComponents = [newComponent, ...list];
1967
+ } else if (nextContainerNameOrderName === "center" && orderName === "before") {
1968
+ allComponents = [...list, newComponent];
1969
+ } else {
1970
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1971
+ }
1972
+ }
1973
+ } else {
1974
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1975
+ }
1976
+ const seen = /* @__PURE__ */ new Set();
1977
+ const result = allComponents.filter((item) => {
1978
+ if (seen.has(item.containerName)) {
1979
+ return false;
1980
+ }
1981
+ seen.add(item.containerName);
1982
+ return true;
1983
+ });
1984
+ dropMovementEventSubject.next({
1985
+ state: "append",
1986
+ targetParentLayoutName: parentLayoutName,
1987
+ targetLayoutName: layoutName,
1988
+ targetContainerName: containerName,
1989
+ orderName
1990
+ });
1991
+ return { [key]: result };
1992
+ };
1993
+ var handleRemove = (list, targetContainerName, orderNameSetter) => {
1994
+ const result = list.filter((e) => e.containerName !== targetContainerName);
1995
+ if (result.length != list.length)
1996
+ orderNameSetter(list.length - result.length);
1997
+ return result;
1998
+ };
1999
+ function getAdjacentItem(items, currentIndex) {
2000
+ if (currentIndex + 1 < items.length) {
2001
+ return {
2002
+ adjacentItem: items[currentIndex + 1],
2003
+ adjacentIndex: currentIndex + 1
2004
+ };
2005
+ } else if (currentIndex - 1 >= 0) {
2006
+ return {
2007
+ adjacentItem: items[currentIndex - 1],
2008
+ adjacentIndex: currentIndex - 1
2009
+ };
2010
+ }
2011
+ return { adjacentItem: null, adjacentIndex: currentIndex };
2012
+ }
2013
+ var getSelfOrderName = (containerName) => {
2014
+ const result = containerName.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);
2015
+ if (["before", "center", "after"].some((e) => e === result)) {
2016
+ return result;
2017
+ } else {
2018
+ return;
2019
+ }
2020
+ };
2021
+ function FlexLayoutSplitScreen({
2022
+ children,
2023
+ containerName,
2024
+ layoutName,
2025
+ navigationTitle,
2026
+ dropDocumentOutsideOption,
2027
+ screenKey
2028
+ }) {
2029
+ const {
2030
+ direction,
2031
+ isSplit,
2032
+ boundaryContainerSize,
2033
+ afterDropTargetComponent,
2034
+ beforeDropTargetComponent,
2035
+ centerDropTargetComponent,
2036
+ setAfterDropTargetComponent,
2037
+ setBeforeDropTargetComponent,
2038
+ setCenterDropTargetComponent,
2039
+ layoutRef,
2040
+ setIsSplit,
2041
+ setDirection
2042
+ } = useFlexLayoutSplitScreen({
2043
+ isSplitInitial: false,
2044
+ directionInitial: "row",
2045
+ selfContainerName: containerName,
2046
+ parentLayoutName: "",
2047
+ layoutName
2048
+ });
2049
+ useEffect(() => {
2050
+ resetRootSplitScreen(layoutName);
2051
+ const subscribe = getSplitScreen(layoutName, layoutName).subscribe((layoutInfo) => {
2052
+ if (layoutInfo) {
2053
+ setBeforeDropTargetComponent([
2054
+ ...layoutInfo.beforeDropTargetComponent
2055
+ ]);
2056
+ setAfterDropTargetComponent([
2057
+ ...layoutInfo.afterDropTargetComponent
2058
+ ]);
2059
+ setCenterDropTargetComponent([
2060
+ ...layoutInfo.centerDropTargetComponent
2061
+ ]);
2062
+ setDirection(layoutInfo.direction);
2063
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
2064
+ setIsSplit(true);
2065
+ }
2066
+ } else {
2067
+ setSplitScreen(layoutName, layoutName, {
2068
+ afterDropTargetComponent: [],
2069
+ beforeDropTargetComponent: [],
2070
+ centerDropTargetComponent: [
2071
+ {
2072
+ containerName,
2073
+ component: children,
2074
+ navigationTitle,
2075
+ dropDocumentOutsideOption,
2076
+ screenKey: screenKey ? screenKey : Array.from(
2077
+ window.crypto.getRandomValues(
2078
+ new Uint32Array(16)
2079
+ ),
2080
+ (e) => e.toString(32).padStart(2, "0")
2081
+ ).join("")
2082
+ }
2083
+ ],
2084
+ direction
2085
+ });
2086
+ }
2087
+ });
2088
+ return () => {
2089
+ subscribe.unsubscribe();
2090
+ resetRootSplitScreen(layoutName);
2091
+ };
2092
+ }, [layoutName]);
2093
+ useEffect(() => {
2094
+ const subscribe = dropMovementEventSubject.pipe(
2095
+ distinctUntilChanged$1((prev, curr) => {
2096
+ const filterChildren2 = (obj) => {
2097
+ const {
2098
+ children: children2,
2099
+ component,
2100
+ targetComponent,
2101
+ x,
2102
+ y,
2103
+ ...rest
2104
+ } = obj || {};
2105
+ return rest;
2106
+ };
2107
+ return equal(filterChildren2(prev), filterChildren2(curr));
2108
+ })
2109
+ ).subscribe((event) => {
2110
+ if (event.state === "remove") {
2111
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
2112
+ requestAnimationFrame(() => {
2113
+ let removeCallback = (removeOrderName) => {
2114
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
2115
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2116
+ orderName: removeOrderName,
2117
+ containerName: event.nextContainerName,
2118
+ parentLayoutName: "",
2119
+ layoutName,
2120
+ dropComponent: event.targetComponent,
2121
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
2122
+ isUsePrefix: true,
2123
+ afterDropTargetComponent,
2124
+ beforeDropTargetComponent,
2125
+ centerDropTargetComponent,
2126
+ dropDocumentOutsideOption,
2127
+ screenKey: event.dropTargetComponentEvent.screenKey
2128
+ });
2129
+ setSplitScreen(layoutName, layoutName, {
2130
+ ...getCurrentSplitScreenComponents(
2131
+ layoutName,
2132
+ layoutName
2133
+ ) || {
2134
+ afterDropTargetComponent,
2135
+ beforeDropTargetComponent,
2136
+ centerDropTargetComponent,
2137
+ direction
2138
+ },
2139
+ ...targetComponentsMap
2140
+ });
2141
+ Promise.resolve().then(
2142
+ () => event.dropEndCallback && event.dropEndCallback({
2143
+ x: event.x,
2144
+ y: event.y,
2145
+ containerName
2146
+ })
2147
+ );
2148
+ }
2149
+ };
2150
+ const currentComponents = getCurrentSplitScreenComponents(
2151
+ layoutName,
2152
+ layoutName
2153
+ );
2154
+ const afterList = handleRemove(
2155
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
2156
+ event.targetContainerName,
2157
+ () => removeCallback("after")
2158
+ );
2159
+ const beforList = handleRemove(
2160
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
2161
+ event.targetContainerName,
2162
+ () => removeCallback("before")
2163
+ );
2164
+ const centerList = handleRemove(
2165
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
2166
+ event.targetContainerName,
2167
+ () => removeCallback("center")
2168
+ );
2169
+ setSplitScreen(layoutName, layoutName, {
2170
+ afterDropTargetComponent: afterList,
2171
+ beforeDropTargetComponent: beforList,
2172
+ centerDropTargetComponent: centerList,
2173
+ direction
2174
+ });
2175
+ });
2176
+ }
2177
+ } else if (event.state === "append") {
2178
+ const {
2179
+ x,
2180
+ y,
2181
+ dropEndCallback,
2182
+ dropTargetComponentEvent,
2183
+ orderName,
2184
+ parentOrderName,
2185
+ targetLayoutName,
2186
+ targetParentLayoutName,
2187
+ targetContainerName,
2188
+ targetComponent,
2189
+ nextContainerName
2190
+ } = event;
2191
+ if (layoutRef.current && orderName && x && y && targetComponent && dropTargetComponentEvent && targetLayoutName === layoutName && isInnerDrop({ x, y, element: layoutRef.current })) {
2192
+ const {
2193
+ direction: dropDirection,
2194
+ navigationTitle: navigationTitle2,
2195
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2196
+ } = dropTargetComponentEvent;
2197
+ const isOrderNameNotCenter = orderName !== "center";
2198
+ const isOrderNameCenterAndFirstScreen = orderName === "center" && centerDropTargetComponent.length <= 1;
2199
+ if (isOrderNameNotCenter || isOrderNameCenterAndFirstScreen) {
2200
+ setIsSplit(true);
2201
+ if (isOrderNameNotCenter) {
2202
+ setDirection(dropDirection);
2203
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2204
+ orderName,
2205
+ parentOrderName,
2206
+ containerName: targetContainerName,
2207
+ nextContainerName,
2208
+ dropComponent: targetComponent,
2209
+ parentLayoutName: "",
2210
+ layoutName,
2211
+ navigationTitle: navigationTitle2,
2212
+ isUsePrefix: true,
2213
+ afterDropTargetComponent,
2214
+ beforeDropTargetComponent,
2215
+ centerDropTargetComponent,
2216
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2217
+ });
2218
+ setSplitScreen(layoutName, layoutName, {
2219
+ ...{
2220
+ afterDropTargetComponent,
2221
+ beforeDropTargetComponent,
2222
+ centerDropTargetComponent,
2223
+ direction: dropDirection
2224
+ },
2225
+ ...targetComponentsMap,
2226
+ ...{ direction: dropDirection }
2227
+ });
2228
+ Promise.resolve().then(
2229
+ () => dropEndCallback && dropEndCallback({
2230
+ x: event.x,
2231
+ y: event.y,
2232
+ containerName
2233
+ })
2234
+ );
2235
+ } else {
2236
+ const childScreenInfo = getCurrentSplitScreenComponents(
2237
+ layoutName,
2238
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`
2239
+ ) || {
2240
+ afterDropTargetComponent: [],
2241
+ beforeDropTargetComponent: [],
2242
+ centerDropTargetComponent: [],
2243
+ direction
2244
+ };
2245
+ setSplitScreen(
2246
+ layoutName,
2247
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`,
2248
+ {
2249
+ ...childScreenInfo,
2250
+ ...{
2251
+ centerDropTargetComponent: [
2252
+ centerDropTargetComponent[0],
2253
+ {
2254
+ containerName: `${targetContainerName}_${layoutName}_${orderName}`,
2255
+ component: targetComponent,
2256
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2257
+ screenKey: centerDropTargetComponent[0].screenKey,
2258
+ navigationTitle: navigationTitle2
2259
+ }
2260
+ ]
2261
+ }
2262
+ }
2263
+ );
2264
+ }
2265
+ }
2266
+ }
2267
+ }
2268
+ });
2269
+ return () => {
2270
+ subscribe.unsubscribe();
2271
+ };
2272
+ }, [
2273
+ direction,
2274
+ layoutName,
2275
+ isSplit,
2276
+ beforeDropTargetComponent,
2277
+ afterDropTargetComponent,
2278
+ centerDropTargetComponent
2279
+ ]);
2280
+ return /* @__PURE__ */ jsxs("div", { className: `${FlexLayout_default["flex-split-screen"]}`, ref: layoutRef, children: [
2281
+ /* @__PURE__ */ jsxs(
2282
+ FlexLayout_default2,
2283
+ {
2284
+ direction,
2285
+ layoutName,
2286
+ "data-is_split": isSplit,
2287
+ panelMovementMode: "bulldozer",
2288
+ children: [
2289
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
2290
+ ({
2291
+ containerName: cName,
2292
+ component,
2293
+ navigationTitle: navigationTitle2,
2294
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2295
+ screenKey: screenKey2
2296
+ }, i) => /* @__PURE__ */ jsx(
2297
+ FlexLayoutContainer_default,
2298
+ {
2299
+ containerName: cName,
2300
+ isInitialResizable: true,
2301
+ isResizePanel: true,
2302
+ children: /* @__PURE__ */ jsx(
2303
+ FlexLayoutSplitScreenChild,
2304
+ {
2305
+ parentDirection: direction,
2306
+ layoutName: `${layoutName}_before`,
2307
+ parentLayoutName: layoutName,
2308
+ containerName: cName,
2309
+ depth: 1,
2310
+ rootRef: layoutRef,
2311
+ screenKey: screenKey2,
2312
+ initialCenterComponents: [
2313
+ {
2314
+ navigationTitle: navigationTitle2,
2315
+ component,
2316
+ containerName: cName,
2317
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2318
+ screenKey: screenKey2
2319
+ }
2320
+ ],
2321
+ rootName: layoutName
2322
+ }
2323
+ )
2324
+ },
2325
+ cName
2326
+ )
2327
+ ) }) : /* @__PURE__ */ jsx("div", {}),
2328
+ centerDropTargetComponent.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx(
2329
+ FlexLayoutContainer_default,
2330
+ {
2331
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2332
+ isInitialResizable: true,
2333
+ isResizePanel: isSplit,
2334
+ children: isSplit ? /* @__PURE__ */ jsx(
2335
+ FlexLayoutSplitScreenChild,
2336
+ {
2337
+ parentDirection: direction,
2338
+ layoutName: `${layoutName}_center`,
2339
+ parentLayoutName: layoutName,
2340
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2341
+ depth: 0,
2342
+ rootRef: layoutRef,
2343
+ screenKey: centerDropTargetComponent[0].screenKey,
2344
+ initialCenterComponents: [
2345
+ {
2346
+ navigationTitle: centerDropTargetComponent[0].navigationTitle,
2347
+ component: centerDropTargetComponent[0].component,
2348
+ containerName: centerDropTargetComponent[0].containerName,
2349
+ dropDocumentOutsideOption: centerDropTargetComponent[0].dropDocumentOutsideOption,
2350
+ screenKey: centerDropTargetComponent[0].screenKey
2351
+ }
2352
+ ],
2353
+ rootName: layoutName
2354
+ }
2355
+ ) : /* @__PURE__ */ jsx(
2356
+ FlexLayoutSplitScreenScrollBox_default,
2357
+ {
2358
+ keyName: centerDropTargetComponent[0].containerName,
2359
+ isDefaultScrollStyle: true,
2360
+ children: centerDropTargetComponent[0].component
2361
+ }
2362
+ )
2363
+ }
2364
+ ),
2365
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
2366
+ ({
2367
+ containerName: cName,
2368
+ component,
2369
+ navigationTitle: navigationTitle2,
2370
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2371
+ screenKey: screenKey2
2372
+ }, i) => /* @__PURE__ */ jsx(
2373
+ FlexLayoutContainer_default,
2374
+ {
2375
+ containerName: cName,
2376
+ isInitialResizable: true,
2377
+ isResizePanel: afterDropTargetComponent.length - 1 !== i,
2378
+ children: /* @__PURE__ */ jsx(
2379
+ FlexLayoutSplitScreenChild,
2380
+ {
2381
+ parentDirection: direction,
2382
+ layoutName: `${layoutName}_after`,
2383
+ parentLayoutName: layoutName,
2384
+ containerName: cName,
2385
+ depth: 1,
2386
+ rootRef: layoutRef,
2387
+ screenKey: screenKey2,
2388
+ initialCenterComponents: [
2389
+ {
2390
+ navigationTitle: navigationTitle2,
2391
+ component,
2392
+ containerName: cName,
2393
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2394
+ screenKey: screenKey2
2395
+ }
2396
+ ],
2397
+ rootName: layoutName
2398
+ }
2399
+ )
2400
+ },
2401
+ cName
2402
+ )
2403
+ ) }) : /* @__PURE__ */ jsx("div", {})
2404
+ ]
2405
+ }
2406
+ ),
2407
+ boundaryContainerSize && /* @__PURE__ */ jsx(
2408
+ "div",
2409
+ {
2410
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
2411
+ style: { ...boundaryContainerSize },
2412
+ children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
2413
+ }
2414
+ )
2415
+ ] });
2416
+ }
2417
+ function FlexLayoutSplitScreenChild({
2418
+ containerName,
2419
+ layoutName,
2420
+ parentLayoutName,
2421
+ parentDirection,
2422
+ depth,
2423
+ //isSplit: isSplitInitial,
2424
+ rootRef,
2425
+ rootName,
2426
+ initialCenterComponents,
2427
+ screenKey
2428
+ }) {
2429
+ const {
2430
+ direction,
2431
+ isSplit,
2432
+ boundaryContainerSize,
2433
+ afterDropTargetComponent,
2434
+ beforeDropTargetComponent,
2435
+ centerDropTargetComponent,
2436
+ setAfterDropTargetComponent,
2437
+ setBeforeDropTargetComponent,
2438
+ setCenterDropTargetComponent,
2439
+ layoutRef,
2440
+ setIsSplit,
2441
+ setDirection
2442
+ } = useFlexLayoutSplitScreen({
2443
+ isSplitInitial: false,
2444
+ directionInitial: "row",
2445
+ parentDirection,
2446
+ selfContainerName: containerName,
2447
+ parentLayoutName,
2448
+ layoutName
2449
+ });
2450
+ const [isEmptyContent, setIsEmptyContent] = useState(false);
2451
+ const [activeIndex, setActiveIndex] = useState(0);
2452
+ const centerDropTargetComponentRef = useRef(centerDropTargetComponent);
2453
+ const activeIndexRef = useRef(activeIndex);
2454
+ useEffect(() => {
2455
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).pipe(take$1(1)).subscribe((layoutInfo) => {
2456
+ setSplitScreen(rootName, `${layoutName}=${screenKey}`, {
2457
+ afterDropTargetComponent: layoutInfo?.afterDropTargetComponent || [],
2458
+ beforeDropTargetComponent: layoutInfo?.beforeDropTargetComponent || [],
2459
+ centerDropTargetComponent: layoutInfo?.centerDropTargetComponent || initialCenterComponents || [],
2460
+ direction: layoutInfo?.direction || direction
2461
+ });
2462
+ });
2463
+ return () => {
2464
+ removeSplitScreenChild(rootName, layoutName);
2465
+ subscribe.unsubscribe();
2466
+ };
2467
+ }, [rootName, layoutName, initialCenterComponents]);
2468
+ useEffect(() => {
2469
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).subscribe((layoutInfo) => {
2470
+ if (layoutInfo) {
2471
+ setBeforeDropTargetComponent([
2472
+ ...layoutInfo.beforeDropTargetComponent
2473
+ ]);
2474
+ setAfterDropTargetComponent([
2475
+ ...layoutInfo.afterDropTargetComponent
2476
+ ]);
2477
+ setCenterDropTargetComponent([
2478
+ ...layoutInfo.centerDropTargetComponent
2479
+ ]);
2480
+ setDirection(layoutInfo.direction);
2481
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
2482
+ setIsSplit(true);
2483
+ } else if (layoutInfo.beforeDropTargetComponent.length === 0 && layoutInfo.centerDropTargetComponent.length === 0 && layoutInfo.afterDropTargetComponent.length === 0) {
2484
+ dropMovementEventSubject.next({
2485
+ state: "remove",
2486
+ targetContainerName: containerName,
2487
+ targetParentLayoutName: "",
2488
+ targetLayoutName: parentLayoutName
2489
+ });
2490
+ setIsEmptyContent(true);
2491
+ }
2492
+ }
2493
+ });
2494
+ return () => {
2495
+ subscribe.unsubscribe();
2496
+ };
2497
+ }, [rootName, layoutName]);
2498
+ useEffect(() => {
2499
+ const subscribe = dropMovementEventSubject.pipe(
2500
+ distinctUntilChanged$1((prev, curr) => {
2501
+ const filterChildren2 = (obj) => {
2502
+ const {
2503
+ children,
2504
+ component,
2505
+ targetComponent,
2506
+ x,
2507
+ y,
2508
+ ...rest
2509
+ } = obj || {};
2510
+ return rest;
2511
+ };
2512
+ return equal(filterChildren2(prev), filterChildren2(curr));
2513
+ })
2514
+ ).subscribe((event) => {
2515
+ if (event.state === "remove") {
2516
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
2517
+ requestAnimationFrame(() => {
2518
+ let removeCallback = (removeOrderName) => {
2519
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
2520
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2521
+ orderName: removeOrderName,
2522
+ containerName: event.nextContainerName,
2523
+ parentLayoutName,
2524
+ layoutName,
2525
+ dropComponent: event.targetComponent,
2526
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
2527
+ isUsePrefix: true,
2528
+ afterDropTargetComponent,
2529
+ beforeDropTargetComponent,
2530
+ centerDropTargetComponent,
2531
+ dropDocumentOutsideOption: event.dropTargetComponentEvent?.dropDocumentOutsideOption,
2532
+ screenKey: event.dropTargetComponentEvent.screenKey
2533
+ });
2534
+ setSplitScreen(
2535
+ rootName,
2536
+ `${layoutName}=${screenKey}`,
2537
+ {
2538
+ ...getCurrentSplitScreenComponents(
2539
+ rootName,
2540
+ `${layoutName}=${screenKey}`
2541
+ ) || {
2542
+ afterDropTargetComponent,
2543
+ beforeDropTargetComponent,
2544
+ centerDropTargetComponent,
2545
+ direction
2546
+ },
2547
+ ...targetComponentsMap
2548
+ }
2549
+ );
2550
+ Promise.resolve().then(
2551
+ () => event.dropEndCallback && event.dropEndCallback({
2552
+ x: event.x,
2553
+ y: event.y,
2554
+ containerName
2555
+ })
2556
+ );
2557
+ }
2558
+ };
2559
+ const currentComponents = getCurrentSplitScreenComponents(
2560
+ rootName,
2561
+ `${layoutName}=${screenKey}`
2562
+ );
2563
+ const afterList = handleRemove(
2564
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
2565
+ event.targetContainerName,
2566
+ () => removeCallback("after")
2567
+ );
2568
+ const beforList = handleRemove(
2569
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
2570
+ event.targetContainerName,
2571
+ () => removeCallback("before")
2572
+ );
2573
+ const centerList = handleRemove(
2574
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
2575
+ event.targetContainerName,
2576
+ () => removeCallback("center")
2577
+ );
2578
+ setSplitScreen(
2579
+ rootName,
2580
+ `${layoutName}=${screenKey}`,
2581
+ {
2582
+ afterDropTargetComponent: afterList,
2583
+ beforeDropTargetComponent: beforList,
2584
+ centerDropTargetComponent: centerList,
2585
+ direction
2586
+ }
2587
+ );
2588
+ });
2589
+ }
2590
+ } else if (event.state === "append") {
2591
+ const {
2592
+ x,
2593
+ y,
2594
+ dropEndCallback,
2595
+ dropTargetComponentEvent,
2596
+ orderName,
2597
+ targetLayoutName,
2598
+ targetParentLayoutName,
2599
+ targetContainerName,
2600
+ targetComponent,
2601
+ nextContainerName,
2602
+ parentOrderName
2603
+ } = event;
2604
+ if (layoutRef.current && orderName && x && y && dropTargetComponentEvent && isInnerDrop({ x, y, element: layoutRef.current })) {
2605
+ const {
2606
+ direction: dropDirection,
2607
+ navigationTitle,
2608
+ dropDocumentOutsideOption,
2609
+ screenKey: containerScreenKey
2610
+ } = dropTargetComponentEvent;
2611
+ if (
2612
+ //orderName !== 'center' &&
2613
+ targetLayoutName === layoutName && targetComponent
2614
+ ) {
2615
+ if (dropDirection === parentDirection && orderName !== "center") {
2616
+ dropMovementEventSubject.next({
2617
+ state: "append",
2618
+ targetContainerName,
2619
+ targetParentLayoutName: "",
2620
+ targetLayoutName: parentLayoutName,
2621
+ targetComponent,
2622
+ nextContainerName: containerName,
2623
+ parentOrderName: getSelfOrderName(layoutName) || orderName,
2624
+ orderName,
2625
+ x,
2626
+ y,
2627
+ dropEndCallback,
2628
+ dropTargetComponentEvent: {
2629
+ navigationTitle,
2630
+ dropDocumentOutsideOption,
2631
+ direction: parentDirection,
2632
+ screenKey
2633
+ }
2634
+ });
2635
+ } else {
2636
+ if (orderName !== "center") {
2637
+ setDirection(dropDirection);
2638
+ setIsSplit(true);
2639
+ }
2640
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2641
+ orderName,
2642
+ parentOrderName,
2643
+ containerName: targetContainerName,
2644
+ nextContainerName,
2645
+ parentLayoutName,
2646
+ layoutName,
2647
+ dropComponent: targetComponent,
2648
+ navigationTitle,
2649
+ isUsePrefix: orderName !== "center",
2650
+ afterDropTargetComponent,
2651
+ beforeDropTargetComponent,
2652
+ centerDropTargetComponent,
2653
+ dropDocumentOutsideOption
2654
+ });
2655
+ setSplitScreen(
2656
+ rootName,
2657
+ `${layoutName}=${screenKey}`,
2658
+ {
2659
+ ...getCurrentSplitScreenComponents(
2660
+ rootName,
2661
+ `${layoutName}=${screenKey}`
2662
+ ) || {
2663
+ afterDropTargetComponent,
2664
+ beforeDropTargetComponent,
2665
+ centerDropTargetComponent,
2666
+ direction
2667
+ },
2668
+ ...targetComponentsMap,
2669
+ ...{ direction: dropDirection }
2670
+ }
2671
+ );
2672
+ Promise.resolve().then(
2673
+ () => event.dropEndCallback && event.dropEndCallback({
2674
+ x: event.x,
2675
+ y: event.y,
2676
+ containerName
2677
+ })
2678
+ );
2679
+ }
2680
+ }
2681
+ }
2682
+ }
2683
+ });
2684
+ return () => {
2685
+ subscribe.unsubscribe();
2686
+ };
2687
+ }, [
2688
+ direction,
2689
+ parentDirection,
2690
+ parentLayoutName,
2691
+ layoutName,
2692
+ beforeDropTargetComponent,
2693
+ afterDropTargetComponent,
2694
+ centerDropTargetComponent
2695
+ ]);
2696
+ useEffect(() => {
2697
+ centerDropTargetComponentRef.current = centerDropTargetComponent;
2698
+ }, [centerDropTargetComponent]);
2699
+ useEffect(() => {
2700
+ activeIndexRef.current = activeIndex;
2701
+ }, [activeIndex]);
2702
+ const [isOnlyOneScreen, setIsOnlyOneScreen] = useState(false);
2703
+ return /* @__PURE__ */ jsx(Fragment, { children: !isEmptyContent && /* @__PURE__ */ jsxs(
2704
+ "div",
2705
+ {
2706
+ className: `${FlexLayout_default["flex-split-screen"]}`,
2707
+ ref: layoutRef,
2708
+ children: [
2709
+ /* @__PURE__ */ jsxs(
2710
+ FlexLayout_default2,
2711
+ {
2712
+ direction,
2713
+ layoutName: `${layoutName}`,
2714
+ panelMovementMode: "bulldozer",
2715
+ children: [
2716
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
2717
+ ({
2718
+ containerName: cName,
2719
+ component,
2720
+ navigationTitle,
2721
+ dropDocumentOutsideOption,
2722
+ screenKey: screenKey2
2723
+ }, i) => /* @__PURE__ */ jsx(
2724
+ FlexLayoutContainer_default,
2725
+ {
2726
+ containerName: cName,
2727
+ isInitialResizable: true,
2728
+ isResizePanel: true,
2729
+ children: /* @__PURE__ */ jsx(
2730
+ FlexLayoutSplitScreenChild,
2731
+ {
2732
+ parentDirection: direction,
2733
+ layoutName: `${layoutName}_before-${depth}`,
2734
+ parentLayoutName: layoutName,
2735
+ containerName: cName,
2736
+ depth: depth + 1,
2737
+ rootRef,
2738
+ screenKey: screenKey2,
2739
+ initialCenterComponents: [
2740
+ {
2741
+ navigationTitle,
2742
+ component,
2743
+ containerName: cName,
2744
+ dropDocumentOutsideOption,
2745
+ screenKey: screenKey2
2746
+ }
2747
+ ],
2748
+ rootName
2749
+ }
2750
+ )
2751
+ },
2752
+ cName
2753
+ )
2754
+ ) }) : /* @__PURE__ */ jsx("div", {}),
2755
+ centerDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2756
+ FlexLayoutContainer_default,
2757
+ {
2758
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2759
+ isInitialResizable: true,
2760
+ isResizePanel: isSplit,
2761
+ children: isSplit ? /* @__PURE__ */ jsx("div", { "data-key": screenKey, children: /* @__PURE__ */ jsx(
2762
+ FlexLayoutSplitScreenChild,
2763
+ {
2764
+ parentDirection: direction,
2765
+ layoutName: `${layoutName}_center-${depth}`,
2766
+ parentLayoutName: layoutName,
2767
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2768
+ depth: depth + 1,
2769
+ rootRef,
2770
+ initialCenterComponents: centerDropTargetComponent.map(
2771
+ ({
2772
+ navigationTitle,
2773
+ component,
2774
+ containerName: cName,
2775
+ dropDocumentOutsideOption,
2776
+ screenKey: centerScreenKey
2777
+ }) => ({
2778
+ navigationTitle,
2779
+ component,
2780
+ containerName: cName,
2781
+ dropDocumentOutsideOption,
2782
+ screenKey: centerScreenKey
2783
+ })
2784
+ ),
2785
+ screenKey,
2786
+ rootName
2787
+ }
2788
+ ) }) : /* @__PURE__ */ jsxs(
2789
+ FlexLayoutSplitScreenScrollBox_default,
2790
+ {
2791
+ keyName: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName,
2792
+ isDefaultScrollStyle: true,
2793
+ children: [
2794
+ !isOnlyOneScreen && /* @__PURE__ */ jsx(
2795
+ "div",
2796
+ {
2797
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper-sticky"]}`,
2798
+ children: /* @__PURE__ */ jsxs(
2799
+ "div",
2800
+ {
2801
+ "data-is_split": isSplit,
2802
+ "data-layout_name": layoutName,
2803
+ "data-parent_layout_name": parentLayoutName,
2804
+ "data-container_name": `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2805
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper"]}`,
2806
+ children: [
2807
+ /* @__PURE__ */ jsx(
2808
+ FlexLayoutSplitScreenDragBoxContainer,
2809
+ {
2810
+ "data-layout_name": layoutName,
2811
+ layoutName,
2812
+ children: centerDropTargetComponent.map(
2813
+ (item, index) => /* @__PURE__ */ jsx(
2814
+ FlexLayoutSplitScreenDragBoxItem,
2815
+ {
2816
+ onClose: (ev) => {
2817
+ if (activeIndexRef.current === index && centerDropTargetComponent.length === 1) {
2818
+ dropMovementEventSubject.next(
2819
+ {
2820
+ state: "remove",
2821
+ targetContainerName: containerName,
2822
+ targetParentLayoutName: parentLayoutName,
2823
+ targetLayoutName: layoutName
2824
+ }
2825
+ );
2826
+ } else {
2827
+ if (centerDropTargetComponent.length === activeIndexRef.current + 1) {
2828
+ setActiveIndex(
2829
+ activeIndexRef.current - 1
2830
+ );
2831
+ }
2832
+ setCenterDropTargetComponent(
2833
+ (prev) => {
2834
+ const result = handleRemove(
2835
+ prev,
2836
+ item.containerName,
2837
+ () => {
2838
+ }
2839
+ );
2840
+ return result;
2841
+ }
2842
+ );
2843
+ }
2844
+ },
2845
+ isActive: activeIndex === index,
2846
+ children: /* @__PURE__ */ jsx(
2847
+ FlexLayoutSplitScreenDragBox,
2848
+ {
2849
+ onClick: () => {
2850
+ setActiveIndex(
2851
+ index
2852
+ );
2853
+ },
2854
+ containerName: item.containerName,
2855
+ dropDocumentOutsideOption: item.dropDocumentOutsideOption,
2856
+ targetComponent: item.component,
2857
+ navigationTitle: item.navigationTitle,
2858
+ "data-container-name": item.containerName,
2859
+ "data-layout-name": layoutName,
2860
+ "data-parent-layout-name": parentLayoutName,
2861
+ dropEndCallback: ({
2862
+ x,
2863
+ y,
2864
+ containerName: appendContainerName
2865
+ }) => {
2866
+ if (!rootRef.current || !layoutRef.current)
2867
+ return;
2868
+ const isRootOver = isOverDrop(
2869
+ {
2870
+ x,
2871
+ y,
2872
+ element: rootRef.current
2873
+ }
2874
+ );
2875
+ const isLayoutInner = isInnerDrop(
2876
+ {
2877
+ x,
2878
+ y,
2879
+ element: layoutRef.current
2880
+ }
2881
+ );
2882
+ if (!isRootOver && !isLayoutInner || !isRootOver && isLayoutInner && centerDropTargetComponentRef.current.length > 1) {
2883
+ const option = {};
2884
+ if (centerDropTargetComponentRef.current.length > 1) {
2885
+ const {
2886
+ adjacentItem,
2887
+ adjacentIndex
2888
+ } = getAdjacentItem(
2889
+ centerDropTargetComponentRef.current,
2890
+ activeIndexRef.current
2891
+ );
2892
+ if (adjacentItem && activeIndexRef.current === index) {
2893
+ Object.assign(
2894
+ option,
2895
+ {
2896
+ x,
2897
+ y,
2898
+ targetComponent: adjacentItem.component,
2899
+ nextContainerName: adjacentItem.containerName,
2900
+ orderName: "center",
2901
+ dropTargetComponentEvent: {
2902
+ navigationTitle: adjacentItem.navigationTitle,
2903
+ dropDocumentOutsideOption: adjacentItem.dropDocumentOutsideOption,
2904
+ direction,
2905
+ screenKey
2906
+ }
2907
+ }
2908
+ );
2909
+ }
2910
+ }
2911
+ if (index === 0) {
2912
+ dropMovementEventSubject.next(
2913
+ {
2914
+ state: "remove",
2915
+ targetContainerName: item.containerName,
2916
+ targetParentLayoutName: parentLayoutName,
2917
+ targetLayoutName: layoutName,
2918
+ ...option
2919
+ }
2920
+ );
2921
+ } else {
2922
+ dropMovementEventSubject.next(
2923
+ {
2924
+ state: "remove",
2925
+ targetContainerName: item.containerName,
2926
+ targetParentLayoutName: "",
2927
+ targetLayoutName: layoutName,
2928
+ ...option
2929
+ }
2930
+ );
2931
+ }
2932
+ }
2933
+ },
2934
+ children: item.navigationTitle
2935
+ }
2936
+ )
2937
+ },
2938
+ item.navigationTitle + layoutName + item.containerName
2939
+ )
2940
+ )
2941
+ },
2942
+ layoutName
2943
+ ),
2944
+ /* @__PURE__ */ jsx(FlexLayoutSplitScreenDragBoxTitleMore, {})
2945
+ ]
2946
+ }
2947
+ )
2948
+ }
2949
+ ),
2950
+ (() => {
2951
+ const target = centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0];
2952
+ return target.component;
2953
+ })()
2954
+ ]
2955
+ }
2956
+ )
2957
+ },
2958
+ (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName
2959
+ ) }) : /* @__PURE__ */ jsx("div", {}),
2960
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
2961
+ ({
2962
+ containerName: cName,
2963
+ component,
2964
+ navigationTitle,
2965
+ dropDocumentOutsideOption,
2966
+ screenKey: screenKey2
2967
+ }, i) => /* @__PURE__ */ jsx(
2968
+ FlexLayoutContainer_default,
2969
+ {
2970
+ containerName: cName,
2971
+ isInitialResizable: true,
2972
+ isResizePanel: i !== afterDropTargetComponent.length - 1,
2973
+ children: /* @__PURE__ */ jsx(
2974
+ FlexLayoutSplitScreenChild,
2975
+ {
2976
+ parentDirection: direction,
2977
+ layoutName: `${layoutName}_after-${depth}`,
2978
+ parentLayoutName: layoutName,
2979
+ containerName: cName,
2980
+ depth: depth + 1,
2981
+ rootRef,
2982
+ screenKey: screenKey2,
2983
+ initialCenterComponents: [
2984
+ {
2985
+ navigationTitle,
2986
+ component,
2987
+ containerName: cName,
2988
+ dropDocumentOutsideOption,
2989
+ screenKey: screenKey2
2990
+ }
2991
+ ],
2992
+ rootName
2993
+ }
2994
+ )
2995
+ },
2996
+ cName
2997
+ )
2998
+ ) }) : /* @__PURE__ */ jsx("div", {})
2999
+ ]
3000
+ }
3001
+ ),
3002
+ boundaryContainerSize && /* @__PURE__ */ jsx(
3003
+ "div",
3004
+ {
3005
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
3006
+ style: { ...boundaryContainerSize },
3007
+ children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
3008
+ }
3009
+ )
3010
+ ]
3011
+ }
3012
+ ) });
3013
+ }
3014
+ FlexLayoutSplitScreen.displayName = "FlexLayoutSplitScreen";
3015
+ var FlexLayoutSplitScreen_default = FlexLayoutSplitScreen;
3016
+ function clamp(n, min, max) {
3017
+ return Math.max(min, Math.min(max, n));
3018
+ }
3019
+ function pickDefaultScrollRoot() {
3020
+ if (typeof document === "undefined") return null;
3021
+ let el = document.body;
3022
+ while (el && el !== document.documentElement && el !== document.body) {
3023
+ const style = getComputedStyle(el);
3024
+ const oy = style.overflowY;
3025
+ const ox = style.overflowX;
3026
+ const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
3027
+ if (scrollable) return el;
3028
+ el = el.parentElement;
3029
+ }
3030
+ return null;
3031
+ }
3032
+ function isVerticalScroll(root) {
3033
+ if (typeof window == "undefined") return true;
3034
+ if (!root) {
3035
+ return document.documentElement.scrollHeight > window.innerHeight + 1;
3036
+ }
3037
+ const el = root;
3038
+ return el.scrollHeight > el.clientHeight + 1;
3039
+ }
3040
+ var dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
3041
+ function quantizeToDevicePixel(n) {
3042
+ return Math.round(n * dpr) / dpr;
3043
+ }
3044
+ var FlexLayoutStickyBox = ({
3045
+ edge = "auto",
3046
+ offset = 16,
3047
+ scrollRoot = null,
3048
+ debug = false,
3049
+ children,
3050
+ style,
3051
+ className,
3052
+ onTranslateChange = () => {
3053
+ },
3054
+ ...rest
3055
+ }) => {
3056
+ const offsetRef = useRef(offset);
3057
+ const rootRef = useRef(null);
3058
+ const contentRef = useRef(null);
3059
+ const mutatingRef = useRef(false);
3060
+ const lastOffsetRef = useRef(0);
3061
+ const [resolvedEdge, setResolvedEdge] = useState("top");
3062
+ const rafId = useRef(null);
3063
+ const [contentDynamicStyle, setContentDynamicStyle] = useState({});
3064
+ useEffect(() => {
3065
+ setContentDynamicStyle({
3066
+ willChange: "transform",
3067
+ transition: "transform 50ms linear"
3068
+ });
3069
+ }, []);
3070
+ useEffect(() => {
3071
+ offsetRef.current = offset;
3072
+ scheduleUpdate();
3073
+ }, [offset]);
3074
+ const [ioRoot, setIoRoot] = useState(null);
3075
+ useEffect(() => {
3076
+ const root = scrollRoot ?? pickDefaultScrollRoot();
3077
+ setResolvedEdge(
3078
+ edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
3079
+ );
3080
+ setIoRoot(root);
3081
+ }, [edge, scrollRoot]);
3082
+ useEffect(() => {
3083
+ if (edge !== "auto") {
3084
+ setResolvedEdge(edge);
3085
+ return;
3086
+ }
3087
+ const vertical = isVerticalScroll(ioRoot);
3088
+ setResolvedEdge(vertical ? "top" : "left");
3089
+ }, [edge, ioRoot]);
3090
+ useEffect(() => {
3091
+ }, []);
3092
+ const scheduleUpdate = () => {
3093
+ if (rafId.current != null) return;
3094
+ rafId.current = requestAnimationFrame(() => {
3095
+ rafId.current = null;
3096
+ doUpdate();
3097
+ });
3098
+ };
3099
+ const doUpdate = () => {
3100
+ if (mutatingRef.current) return;
3101
+ mutatingRef.current = true;
3102
+ const rootEl = rootRef.current;
3103
+ const contentEl = contentRef.current;
3104
+ if (!rootEl || !contentEl) {
3105
+ mutatingRef.current = false;
3106
+ return;
3107
+ }
3108
+ const parentEl = rootEl.parentElement;
3109
+ if (!parentEl) {
3110
+ mutatingRef.current = false;
3111
+ return;
3112
+ }
3113
+ const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
3114
+ const parentRect = parentEl.getBoundingClientRect();
3115
+ const contentRect = contentEl.getBoundingClientRect();
3116
+ let newOffset = 0;
3117
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
3118
+ const maxTranslate = Math.max(
3119
+ 0,
3120
+ parentRect.height - contentRect.height
3121
+ );
3122
+ let desiredTop = 0;
3123
+ if (resolvedEdge === "top") {
3124
+ desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
3125
+ } else {
3126
+ const targetBottomFromParentTop = Math.min(
3127
+ parentRect.bottom,
3128
+ rootBounds.bottom - offsetRef.current
3129
+ ) - parentRect.top;
3130
+ desiredTop = targetBottomFromParentTop - contentRect.height;
3131
+ }
3132
+ newOffset = clamp(desiredTop, 0, maxTranslate);
3133
+ } else {
3134
+ const maxTranslate = Math.max(
3135
+ 0,
3136
+ parentRect.width - contentRect.width
3137
+ );
3138
+ let desiredLeft = 0;
3139
+ if (resolvedEdge === "left") {
3140
+ desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
3141
+ } else {
3142
+ const targetRightFromParentLeft = Math.min(
3143
+ parentRect.right,
3144
+ rootBounds.right - offsetRef.current
3145
+ ) - parentRect.left;
3146
+ desiredLeft = targetRightFromParentLeft - contentRect.width;
3147
+ }
3148
+ newOffset = clamp(desiredLeft, 0, maxTranslate);
3149
+ }
3150
+ const nextOffset = quantizeToDevicePixel(newOffset);
3151
+ if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
3152
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
3153
+ contentEl.style.transform = `translateY(${nextOffset}px)`;
3154
+ } else {
3155
+ contentEl.style.transform = `translateX(${nextOffset}px)`;
3156
+ }
3157
+ lastOffsetRef.current = nextOffset;
3158
+ onTranslateChange(nextOffset, rootRef, contentRef);
3159
+ }
3160
+ if (debug) {
3161
+ rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
3162
+ contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
3163
+ }
3164
+ queueMicrotask(() => {
3165
+ mutatingRef.current = false;
3166
+ });
3167
+ };
3168
+ useEffect(() => {
3169
+ if (typeof window == "undefined") return;
3170
+ const rootEl = rootRef.current;
3171
+ if (!rootEl) return;
3172
+ const parentEl = rootEl.parentElement;
3173
+ console.log(parentEl);
3174
+ if (!parentEl) return;
3175
+ const targets = [parentEl];
3176
+ const observerCallback = () => {
3177
+ if (!mutatingRef.current) scheduleUpdate();
3178
+ };
3179
+ const io = new IntersectionObserver(observerCallback, {
3180
+ root: ioRoot instanceof Element ? ioRoot : null,
3181
+ threshold: 0,
3182
+ rootMargin: "1px"
3183
+ });
3184
+ const ro = new ResizeObserver(observerCallback);
3185
+ targets.forEach((t) => io.observe(t));
3186
+ ro.observe(parentEl);
3187
+ if (contentRef.current) {
3188
+ ro.observe(contentRef.current);
3189
+ }
3190
+ const scrollTarget = ioRoot || window;
3191
+ scrollTarget.addEventListener("scroll", scheduleUpdate, {
3192
+ passive: true
3193
+ });
3194
+ window.addEventListener("resize", scheduleUpdate);
3195
+ scheduleUpdate();
3196
+ return () => {
3197
+ io.disconnect();
3198
+ ro.disconnect();
3199
+ scrollTarget.removeEventListener("scroll", scheduleUpdate);
3200
+ window.removeEventListener("resize", scheduleUpdate);
3201
+ if (rafId.current != null) {
3202
+ cancelAnimationFrame(rafId.current);
3203
+ rafId.current = null;
3204
+ }
3205
+ };
3206
+ }, [ioRoot, resolvedEdge, offset, debug]);
3207
+ return /* @__PURE__ */ jsx(
3208
+ "div",
3209
+ {
3210
+ ref: rootRef,
3211
+ className,
3212
+ style: {
3213
+ display: "block",
3214
+ minWidth: 0,
3215
+ minHeight: 0,
3216
+ height: "100%",
3217
+ // 부모 높이를 채우도록 설정
3218
+ ...style
3219
+ },
3220
+ ...rest,
3221
+ children: /* @__PURE__ */ jsx(
3222
+ "div",
3223
+ {
3224
+ ref: contentRef,
3225
+ style: contentDynamicStyle,
3226
+ children
3227
+ }
3228
+ )
3229
+ }
3230
+ );
3231
+ };
3232
+ var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
3233
+ var useListPagingForSentinel = ({
3234
+ //initPageNumber,
3235
+ //initPageSize,
3236
+ onReachTerminal
3237
+ }) => {
3238
+ const [firstChildNode, setFirstChildNode] = useState(null);
3239
+ const [lastChildNode, setLastChildNode] = useState(null);
3240
+ const observerRef = useRef(null);
3241
+ const firstChildRef = useCallback((node) => {
3242
+ setFirstChildNode(node);
3243
+ }, []);
3244
+ const lastChildRef = useCallback((node) => {
3245
+ setLastChildNode(node);
3246
+ }, []);
3247
+ useEffect(() => {
3248
+ if (firstChildNode && observerRef.current)
3249
+ observerRef.current.unobserve(firstChildNode);
3250
+ if (lastChildNode && observerRef.current)
3251
+ observerRef.current.unobserve(lastChildNode);
3252
+ const handleIntersect = (entries, observer2) => {
3253
+ entries.forEach((entry) => {
3254
+ if (entry.isIntersecting) {
3255
+ if (entry.target === firstChildNode) {
3256
+ if (onReachTerminal)
3257
+ onReachTerminal({
3258
+ isFirst: true,
3259
+ isLast: false,
3260
+ observer: observer2
3261
+ });
3262
+ }
3263
+ if (entry.target === lastChildNode) {
3264
+ if (onReachTerminal)
3265
+ onReachTerminal({
3266
+ isFirst: false,
3267
+ isLast: true,
3268
+ observer: observer2
3269
+ });
3270
+ }
3271
+ }
3272
+ });
3273
+ };
3274
+ const observer = new IntersectionObserver(handleIntersect, {
3275
+ threshold: 0.1
3276
+ });
3277
+ observerRef.current = observer;
3278
+ if (firstChildNode) observer.observe(firstChildNode);
3279
+ if (lastChildNode) observer.observe(lastChildNode);
3280
+ return () => {
3281
+ if (observerRef.current) {
3282
+ observerRef.current.disconnect();
3283
+ }
3284
+ };
3285
+ }, [firstChildNode, lastChildNode]);
3286
+ return {
3287
+ firstChildRef,
3288
+ lastChildRef
3289
+ };
3290
+ };
3291
+ var usePaginationViewNumber = ({
3292
+ initPageNumber
3293
+ }) => {
3294
+ const [showCurrentPageNumber, setShowCurrentPageNumber] = useState(initPageNumber);
3295
+ const observerRef = useRef(null);
3296
+ const showCurrentPageObserveTarget = useCallback(
3297
+ (node) => {
3298
+ if (!node) return;
3299
+ if (!observerRef.current) {
3300
+ observerRef.current = new IntersectionObserver(
3301
+ (entries) => {
3302
+ entries.forEach((entry) => {
3303
+ if (entry.isIntersecting) {
3304
+ const pageIndexAttr = entry.target.getAttribute(
3305
+ "data-page-index"
3306
+ );
3307
+ if (!pageIndexAttr) return;
3308
+ const pageIndex = parseInt(pageIndexAttr, 10);
3309
+ setShowCurrentPageNumber(pageIndex);
3310
+ }
3311
+ });
3312
+ },
3313
+ {
3314
+ threshold: 0.1
3315
+ // 예: 10% 이상 보여야 intersect로 판단
3316
+ }
3317
+ );
3318
+ }
3319
+ observerRef.current.observe(node);
3320
+ },
3321
+ []
3322
+ );
3323
+ useEffect(() => {
3324
+ const currentObserver = observerRef.current;
3325
+ return () => {
3326
+ if (currentObserver) {
3327
+ currentObserver.disconnect();
3328
+ }
3329
+ };
3330
+ }, []);
3331
+ return {
3332
+ showCurrentPageNumber,
3333
+ showCurrentPageObserveTarget
3334
+ };
3335
+ };
3336
+ var usePagingHandler = ({
3337
+ lastCallPageNumber,
3338
+ dataListRef
3339
+ }) => {
3340
+ const jumpingPageNumberRef = useRef(lastCallPageNumber);
3341
+ useEffect(() => {
3342
+ if (jumpingPageNumberRef.current) {
3343
+ setTimeout(() => {
3344
+ jumpingPageNumberRef.current = null;
3345
+ }, 1e3);
3346
+ }
3347
+ }, [jumpingPageNumberRef]);
3348
+ const paginationScrollIntoViewTarget = useRef({});
3349
+ const pageNumberRef = useRef(lastCallPageNumber);
3350
+ const setPaginationRef = useCallback(
3351
+ (i) => (node) => {
3352
+ if (!node) return;
3353
+ paginationScrollIntoViewTarget.current[i] = node;
3354
+ if (jumpingPageNumberRef.current !== null && i === jumpingPageNumberRef.current) {
3355
+ node.scrollIntoView({
3356
+ behavior: "instant",
3357
+ // 필요한 경우 'smooth' 등으로 수정 가능
3358
+ block: "start"
3359
+ });
3360
+ jumpingPageNumberRef.current = null;
3361
+ }
3362
+ },
3363
+ []
3364
+ );
3365
+ const handleReachTerminal = ({ isFirst, isLast, observer }, dataCallFetch) => {
3366
+ if (dataListRef.current.length === 0) return;
3367
+ if (jumpingPageNumberRef.current != null) return;
3368
+ if (!isFirst && !isLast) return;
3369
+ const callPageNumber = isFirst ? Math.max(pageNumberRef.current - 1, 0) : pageNumberRef.current + 1;
3370
+ if (dataListRef.current[callPageNumber] != null && (dataListRef.current[callPageNumber]?.length || 0) > 0)
3371
+ return;
3372
+ jumpingPageNumberRef.current = callPageNumber;
3373
+ setTimeout(() => {
3374
+ jumpingPageNumberRef.current = null;
3375
+ }, 1e3);
3376
+ dataCallFetch(callPageNumber);
3377
+ };
3378
+ const handleClickPageChange = (page, dataCallFetch) => {
3379
+ const pageData = dataListRef.current[page];
3380
+ if (pageData != null && Array.isArray(pageData) && pageData.length > 0) {
3381
+ paginationScrollIntoViewTarget.current[page]?.scrollIntoView({
3382
+ behavior: "smooth",
3383
+ block: "start"
3384
+ });
3385
+ return;
3386
+ }
3387
+ jumpingPageNumberRef.current = page;
3388
+ setTimeout(() => {
3389
+ jumpingPageNumberRef.current = null;
3390
+ }, 1e3);
3391
+ dataCallFetch(page);
3392
+ };
3393
+ return {
3394
+ jumpingPageNumberRef,
3395
+ paginationScrollIntoViewTarget,
3396
+ pageNumberRef,
3397
+ setPaginationRef,
3398
+ handleReachTerminal,
3399
+ handleClickPageChange
3400
+ };
3401
+ };
813
3402
 
814
- export { ContainerOpenCloseProvider, allSplitScreenCount, closeFlex, containerOpenCloseSubjectMap, containerSpreadSubjectMap, dragState, dropMovementEventSubject, findNotCloseFlexContent, flexContainerStore, flexResizePanelStore, folderEventSubject, getClientXy, getContainerRef, getCurrentSplitScreenComponents, getGrow, getLayoutInfos, getResizePanelRef, getScrollPosition, getSplitScreen, isDocumentOut, isOverMove, layoutSplitScreenStore, mathGrow, mathWeight, openFlex, remain, removeScrollPosition, removeSplitScreenChild, resetRootSplitScreen, resize, scrollPositions, setContainerRef, setFolderEvent, setResizePanelRef, setScrollPosition, setSplitScreen, useContainerSize, useContainers, useDecompositionLayout, useDoubleClick, useDragCapture, useDragEvents, useFolderEvent, useLayoutName };
3403
+ export { ContainerOpenCloseProvider, FlexLayout_default2 as FlexLayout, FlexLayoutContainer_default as FlexLayoutContainer, FlexLayoutResizePanel_default as FlexLayoutResizePanel, FlexLayoutSplitScreen_default as FlexLayoutSplitScreen, FlexLayoutSplitScreenDragBox, FlexLayoutSplitScreenScrollBox_default as FlexLayoutSplitScreenScrollBox, FlexLayoutStickyBox_default as FlexLayoutStickyBox, allSplitScreenCount, closeFlex, containerOpenCloseSubjectMap, containerSpreadSubjectMap, dragState, dropMovementEventSubject, findNotCloseFlexContent, flexContainerStore, flexResizePanelStore, folderEventSubject, getClientXy, getContainerRef, getCurrentSplitScreenComponents, getGrow, getLayoutInfos, getResizePanelRef, getScrollPosition, getSplitScreen, isDocumentOut, isOverMove, layoutSplitScreenStore, mathGrow, mathWeight, openFlex, remain, removeScrollPosition, removeSplitScreenChild, resetRootSplitScreen, resize, scrollPositions, setContainerRef, setFolderEvent, setResizePanelRef, setScrollPosition, setSplitScreen, useContainerSize, useContainers, useDecompositionLayout, useDoubleClick, useDragCapture, useDragEvents, useFolderEvent, useLayoutName, useListPagingForSentinel, usePaginationViewNumber, usePagingHandler };
815
3404
  //# sourceMappingURL=index.js.map
816
3405
  //# sourceMappingURL=index.js.map