@byeolnaerim/flex-layout 0.0.9 → 0.0.12

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.
Files changed (132) hide show
  1. package/dist/flex-layout/components/FlexLayout.cjs +1 -110
  2. package/dist/flex-layout/components/FlexLayout.d.ts +2 -1
  3. package/dist/flex-layout/components/FlexLayout.js +1 -85
  4. package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -262
  5. package/dist/flex-layout/components/FlexLayoutContainer.d.ts +1 -1
  6. package/dist/flex-layout/components/FlexLayoutContainer.js +1 -232
  7. package/dist/flex-layout/components/FlexLayoutDynamicHeight.cjs +1 -0
  8. package/dist/flex-layout/components/FlexLayoutDynamicHeight.d.ts +6 -0
  9. package/dist/flex-layout/components/FlexLayoutDynamicHeight.js +1 -0
  10. package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -68
  11. package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -44
  12. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -246
  13. package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -216
  14. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1252
  15. package/dist/flex-layout/components/FlexLayoutSplitScreen.d.ts +14 -1
  16. package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1236
  17. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -532
  18. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -509
  19. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -55
  20. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
  21. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -63
  22. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -33
  23. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -53
  24. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -23
  25. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -133
  26. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -107
  27. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -245
  28. package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -229
  29. package/dist/flex-layout/components/index.cjs +1 -57
  30. package/dist/flex-layout/components/index.d.ts +1 -0
  31. package/dist/flex-layout/components/index.js +1 -17
  32. package/dist/flex-layout/hooks/index.cjs +1 -25
  33. package/dist/flex-layout/hooks/index.js +1 -3
  34. package/dist/flex-layout/hooks/useDrag.cjs +1 -289
  35. package/dist/flex-layout/hooks/useDrag.d.ts +15 -0
  36. package/dist/flex-layout/hooks/useDrag.js +1 -258
  37. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -139
  38. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -118
  39. package/dist/flex-layout/hooks/useListPaging.cjs +1 -212
  40. package/dist/flex-layout/hooks/useListPaging.js +1 -191
  41. package/dist/flex-layout/hooks/useSizes.cjs +1 -126
  42. package/dist/flex-layout/hooks/useSizes.d.ts +6 -3
  43. package/dist/flex-layout/hooks/useSizes.js +1 -101
  44. package/dist/flex-layout/index.cjs +1 -31
  45. package/dist/flex-layout/index.js +1 -6
  46. package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -49
  47. package/dist/flex-layout/providers/FlexLayoutContext.js +1 -24
  48. package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -276
  49. package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
  50. package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -263
  51. package/dist/flex-layout/providers/index.cjs +1 -23
  52. package/dist/flex-layout/providers/index.js +1 -2
  53. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -257
  54. package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -206
  55. package/dist/flex-layout/store/index.cjs +1 -23
  56. package/dist/flex-layout/store/index.js +1 -2
  57. package/dist/flex-layout/styles/FlexLayout.module.css +499 -416
  58. package/dist/flex-layout/styles/sentinelStyle.module.css +11 -0
  59. package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -17
  60. package/dist/flex-layout/types/FlexDirectionTypes.js +0 -1
  61. package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -17
  62. package/dist/flex-layout/types/FlexLayoutTypes.d.ts +38 -2
  63. package/dist/flex-layout/types/FlexLayoutTypes.js +0 -1
  64. package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -245
  65. package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -211
  66. package/dist/flex-layout/utils/index.cjs +1 -23
  67. package/dist/flex-layout/utils/index.js +1 -2
  68. package/dist/index.cjs +1 -23
  69. package/dist/index.js +1 -2
  70. package/dist/types/css.d.cjs +0 -1
  71. package/dist/types/css.d.js +0 -1
  72. package/package.json +116 -113
  73. package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
  74. package/dist/flex-layout/components/FlexLayout.js.map +0 -1
  75. package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
  76. package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
  77. package/dist/flex-layout/components/FlexLayoutIFramePane.cjs.map +0 -1
  78. package/dist/flex-layout/components/FlexLayoutIFramePane.js.map +0 -1
  79. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
  80. package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
  81. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
  82. package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
  83. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
  84. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
  85. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
  86. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
  87. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
  88. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
  89. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
  90. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
  91. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
  92. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
  93. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
  94. package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
  95. package/dist/flex-layout/components/index.cjs.map +0 -1
  96. package/dist/flex-layout/components/index.js.map +0 -1
  97. package/dist/flex-layout/hooks/index.cjs.map +0 -1
  98. package/dist/flex-layout/hooks/index.js.map +0 -1
  99. package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
  100. package/dist/flex-layout/hooks/useDrag.js.map +0 -1
  101. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
  102. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
  103. package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
  104. package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
  105. package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
  106. package/dist/flex-layout/hooks/useSizes.js.map +0 -1
  107. package/dist/flex-layout/index.cjs.map +0 -1
  108. package/dist/flex-layout/index.js.map +0 -1
  109. package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
  110. package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
  111. package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
  112. package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
  113. package/dist/flex-layout/providers/index.cjs.map +0 -1
  114. package/dist/flex-layout/providers/index.js.map +0 -1
  115. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
  116. package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
  117. package/dist/flex-layout/store/index.cjs.map +0 -1
  118. package/dist/flex-layout/store/index.js.map +0 -1
  119. package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
  120. package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
  121. package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
  122. package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
  123. package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
  124. package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
  125. package/dist/flex-layout/utils/index.cjs.map +0 -1
  126. package/dist/flex-layout/utils/index.js.map +0 -1
  127. package/dist/index.cjs.map +0 -1
  128. package/dist/index.js.map +0 -1
  129. package/dist/metafile-cjs.json +0 -1
  130. package/dist/metafile-esm.json +0 -1
  131. package/dist/types/css.d.cjs.map +0 -1
  132. package/dist/types/css.d.js.map +0 -1
@@ -1,232 +1 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useCallback, useEffect, useRef, useState } from "react";
4
- import { useSize } from "../hooks/useSizes";
5
- import { useFlexLayoutContext } from "../providers/FlexLayoutContext";
6
- import { setContainerRef } from "../store/FlexLayoutContainerStore";
7
- import styles from "../styles/FlexLayout.module.css";
8
- import { getGrow, mathGrow, mathWeight } from "../utils/FlexLayoutUtils";
9
- import FlexLayoutResizePanel from "./FlexLayoutResizePanel";
10
- function FlexLayoutContainer({
11
- isFitContent,
12
- isFitResize,
13
- // fitContent,
14
- // containerCount,
15
- // layoutName,
16
- containerName,
17
- grow: initialGrow,
18
- prevGrow: initialPrevGrow,
19
- isInitialResizable,
20
- isResizePanel,
21
- children,
22
- className,
23
- panelMode
24
- }) {
25
- const {
26
- direction,
27
- panelMovementMode,
28
- panelClassName,
29
- layoutName,
30
- fitContent,
31
- containerCount
32
- } = useFlexLayoutContext();
33
- const { ref, size } = (
34
- // isFitContent && fitContent
35
- //?
36
- useSize(fitContent)
37
- );
38
- const flexContainerNodeRef = useRef(null);
39
- const isUserResizingRef = useRef(false);
40
- const handleResizingChange = useCallback((v) => {
41
- isUserResizingRef.current = v;
42
- }, []);
43
- const flexContainerRef = useCallback(
44
- (node) => {
45
- flexContainerNodeRef.current = node;
46
- if (node) {
47
- setContainerRef(
48
- layoutName,
49
- containerName,
50
- flexContainerNodeRef
51
- );
52
- } else {
53
- setContainerRef(layoutName, containerName, null);
54
- }
55
- },
56
- [layoutName, containerName]
57
- );
58
- const [growState, setGrowState] = useState(initialGrow);
59
- useEffect(() => {
60
- setGrowState(initialGrow);
61
- }, [initialGrow]);
62
- const [prevGrowState, setPrevGrowState] = useState(
63
- initialPrevGrow
64
- );
65
- const [isFirstLoad, setIsFirstLoad] = useState(true);
66
- useEffect(() => {
67
- if (typeof window == "undefined" || flexContainerNodeRef.current === null)
68
- return;
69
- const storedGrow = sessionStorage.getItem(containerName);
70
- if (storedGrow !== null) {
71
- const parsed = parseFloat(storedGrow);
72
- if (!isNaN(parsed)) {
73
- flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
74
- setGrowState(parsed);
75
- }
76
- }
77
- }, [containerName]);
78
- useEffect(() => {
79
- if (!flexContainerNodeRef.current) return;
80
- const targetNode = flexContainerNodeRef.current;
81
- const observer = new MutationObserver((mutations) => {
82
- for (const mutation of mutations) {
83
- if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
84
- const flexValue = targetNode.style.flex;
85
- const parsedGrow = parseFloat(flexValue.split(" ")[0]);
86
- if (!isNaN(parsedGrow)) {
87
- setGrowState(parsedGrow);
88
- }
89
- }
90
- }
91
- });
92
- observer.observe(targetNode, {
93
- attributes: true,
94
- attributeFilter: ["style"],
95
- attributeOldValue: true
96
- });
97
- return () => {
98
- observer.disconnect();
99
- };
100
- }, [containerName]);
101
- useEffect(() => {
102
- if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent || // getGrow(flexContainerNodeRef.current) == 0 ||
103
- isUserResizingRef.current)
104
- return;
105
- requestAnimationFrame(() => {
106
- if (!flexContainerNodeRef.current) return;
107
- const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
108
- const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
109
- if (isFitContent) {
110
- flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
111
- }
112
- if (!isFitResize && isFirstLoad) {
113
- setIsFirstLoad(false);
114
- return;
115
- }
116
- if (getGrow(flexContainerNodeRef.current) != 0 && isFitResize) {
117
- const newGrow = mathGrow(size, parentSize, containerCount);
118
- setPrevGrowState(growState);
119
- setGrowState(newGrow);
120
- }
121
- });
122
- }, [size, containerCount, isFitResize, children]);
123
- useEffect(() => {
124
- if (!flexContainerNodeRef.current) return;
125
- let notGrowList = [];
126
- let containerList = [
127
- ...flexContainerNodeRef.current.parentElement?.children || []
128
- ].filter((e) => e.hasAttribute("data-container_name"));
129
- let remainingGrow = containerList.reduce((t, e, i) => {
130
- let item = e;
131
- if (item.classList.contains(styles["flex-resize-panel"])) return t;
132
- if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
133
- notGrowList.push(item);
134
- return t;
135
- }
136
- let grow = parseFloat(item.dataset.grow || "");
137
- item.style.flex = `${grow} 1 0%`;
138
- t -= grow;
139
- return t;
140
- }, containerList.length);
141
- if (notGrowList.length != 0) {
142
- let resizeWeight = mathWeight(notGrowList.length, remainingGrow);
143
- notGrowList.forEach((e) => {
144
- e.dataset.grow = resizeWeight.toString();
145
- e.style.flex = `${resizeWeight} 1 0%`;
146
- });
147
- }
148
- }, []);
149
- useEffect(() => {
150
- if (!flexContainerNodeRef.current || !isFitContent || !fitContent || !size || getGrow(flexContainerNodeRef.current) == 0)
151
- return;
152
- const parent = flexContainerNodeRef.current.parentElement;
153
- if (!parent) return;
154
- const sizeName = fitContent.charAt(0).toUpperCase() + fitContent.substring(1);
155
- const parentSize = parent["client" + sizeName] || 0;
156
- if (!parentSize || containerCount <= 0) return;
157
- const nextGrowRaw = mathGrow(size, parentSize, containerCount);
158
- const nextGrow = Math.min(containerCount, Math.max(0, nextGrowRaw));
159
- const currentGrow = getGrow(flexContainerNodeRef.current);
160
- if (Math.abs(nextGrow - currentGrow) < 1e-3) return;
161
- setPrevGrowState(currentGrow);
162
- setGrowState(nextGrow);
163
- const containers = [...parent.children || []].filter((el) => {
164
- const item = el;
165
- return item.hasAttribute("data-container_name") && !item.classList.contains(styles["flex-resize-panel"]);
166
- });
167
- const siblings = containers.filter(
168
- (el) => el !== flexContainerNodeRef.current
169
- );
170
- const adjustable = siblings.filter((el) => el.style.flex !== "0 1 0%");
171
- const remaining = containerCount - nextGrow;
172
- if (remaining <= 0 || adjustable.length === 0) return;
173
- const oldSum = adjustable.reduce((sum, el) => sum + getGrow(el), 0);
174
- if (oldSum <= 0) {
175
- const each = remaining / adjustable.length;
176
- adjustable.forEach((el) => {
177
- el.dataset.grow = each.toString();
178
- el.style.flex = `${each} 1 0%`;
179
- });
180
- } else {
181
- adjustable.forEach((el) => {
182
- const g = getGrow(el);
183
- const scaled = remaining * (g / oldSum);
184
- el.dataset.grow = scaled.toString();
185
- el.style.flex = `${scaled} 1 0%`;
186
- });
187
- }
188
- }, [size, isFitContent, fitContent, containerCount]);
189
- return /* @__PURE__ */ jsxs(Fragment, { children: [
190
- /* @__PURE__ */ jsx(
191
- "div",
192
- {
193
- id: containerName,
194
- "data-container_name": containerName,
195
- ref: flexContainerRef,
196
- className: `${styles["flex-container"]} ${className && className !== "" ? className : ""}`,
197
- ...growState !== void 0 ? { ["data-grow"]: growState } : {},
198
- ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
199
- "data-is_resize": isInitialResizable,
200
- "data-is_resize_panel": isResizePanel,
201
- style: growState !== void 0 && {
202
- flex: `${growState} 1 0%`
203
- } || {},
204
- children: isFitContent && /* @__PURE__ */ jsx(
205
- "div",
206
- {
207
- className: `${styles["flex-content-fit-wrapper"]}`,
208
- ref,
209
- children
210
- }
211
- ) || children
212
- }
213
- ),
214
- isResizePanel && /* @__PURE__ */ jsx(
215
- FlexLayoutResizePanel,
216
- {
217
- containerName,
218
- layoutName,
219
- direction,
220
- containerCount,
221
- panelMode,
222
- panelClassName,
223
- panelMovementMode,
224
- onResizingChange: handleResizingChange
225
- }
226
- )
227
- ] });
228
- }
229
- export {
230
- FlexLayoutContainer as default
231
- };
232
- //# sourceMappingURL=FlexLayoutContainer.js.map
1
+ "use client";import{Fragment as ae,jsx as N,jsxs as ue}from"react/jsx-runtime";import{useCallback as A,useEffect as m,useLayoutEffect as k,useRef as y,useState as U}from"react";import{useSize as ee}from"../hooks/useSizes";import{useFlexLayoutContext as te}from"../providers/FlexLayoutContext";import{setContainerRef as B}from"../store/FlexLayoutContainerStore";import z from"../styles/FlexLayout.module.css";import{getGrow as ne,mathGrow as re,mathWeight as oe,resize as se}from"../utils/FlexLayoutUtils";import ie from"./FlexLayoutResizePanel";function le({isFitContent:C,isFitResize:_,containerName:u,grow:S,prevGrow:w,isInitialResizable:G,isResizePanel:g,stickyMode:a,children:v,className:F,panelMode:j}){const{direction:H,panelMovementMode:J,panelClassName:K,layoutName:x,fitContent:p,containerCount:$}=te(),{ref:h,size:c}=ee(p),o=y(null),T=y(!1),R=y(null),P=y(null),M=y(!1),Q=A(e=>{T.current=e},[]),X=A(e=>{o.current=e,e?B(x,u,o):B(x,u,null)},[x,u]),[E,O]=U(S),[W,I]=U(w);m(()=>{O(S)},[S]),m(()=>{I(w)},[w]);const L=A((e,n)=>{typeof e=="number"&&Number.isNaN(e)||O(i=>(typeof e=="number"&&typeof i=="number"?Math.abs(e-i)<.001:Object.is(e,i))?i:(I(n??i),e))},[]);k(()=>{if(typeof window>"u"||o.current===null)return;const e=sessionStorage.getItem(u);if(e!==null){const n=parseFloat(e);isNaN(n)||(o.current.style.flex=`${n} 1 0%`,L(n))}},[u,L]),m(()=>{if(!o.current)return;const e=o.current,n=r=>{if(!r)return;const s=r.match(/flex\s*:\s*([^;]+)/);if(!s)return;const t=parseFloat(s[1].trim().split(/\s+/)[0]);return Number.isNaN(t)?void 0:t},i=new MutationObserver(r=>{for(const s of r)if(s.type==="attributes"&&s.attributeName==="style"&&e.style.flex){const t=e.style.flex,l=parseFloat(t.split(" ")[0]);if(!isNaN(l)){const f=n(s.oldValue);L(l,f)}}});return i.observe(e,{attributes:!0,attributeFilter:["style"],attributeOldValue:!0}),()=>{i.disconnect()}},[u,L]),m(()=>{if(!o.current||!h||!h.current||!c||R.current==c||Math.abs((R.current??0)-c)<=5||T.current)return;R.current=c;const e=requestAnimationFrame(()=>{if(!o.current)return;const n=`${p.charAt(0).toUpperCase()+p.substring(1)}`,i=P.current;if(C&&(o.current.style["max"+n]=c+"px",P.current=c),!(!_&&M.current)){if(ne(o.current)!=0){const r=o.current.parentElement&&o.current.parentElement["client"+n]||0,s=re(c,r,$);if(i&&o.current.getBoundingClientRect()[p]/i<=.95)return;const t=[...o.current.parentElement?.children||[]].filter(l=>l.hasAttribute("data-container_name")).filter(l=>l.style.flex!="0 1 0%"&&l!=o.current);o.current.style.flex=`${s} 1 0%`,se(t,t.length+1-s)}M.current=!0}});return()=>{cancelAnimationFrame(e)}},[c,$,_,v,p,C,h]),m(()=>{if(!o.current)return;let e=[],n=[...o.current.parentElement?.children||[]].filter(r=>r.hasAttribute("data-container_name")),i=n.reduce((r,s,t)=>{let l=s;if(l.classList.contains(z["flex-resize-panel"]))return r;if(s.hasAttribute("data-grow")==!1||s.getAttribute("data-is_resize")==="true")return e.push(l),r;let f=parseFloat(l.dataset.grow||"");return l.style.flex=`${f} 1 0%`,r-=f,r},n.length);if(e.length!=0){let r=oe(e.length,i);e.forEach(s=>{s.dataset.grow=r.toString(),s.style.flex=`${r} 1 0%`})}},[]),m(()=>{if(!a||!g||!(a.stickyResizePanel??!0))return;const n=o.current;if(!n)return;const i=n.nextElementSibling,r=n.previousElementSibling,s=b=>!!b&&b.classList.contains(z["flex-resize-panel"]),t=a.position==="top"?s(i)?i:null:s(r)?r:null;if(!t)return;const l={position:t.style.position,top:t.style.top,bottom:t.style.bottom},f=a.offsetPx??0;let d=0;const q=()=>{if(!n.isConnected||!t.isConnected)return;const b=n.offsetHeight;if(t.style.position="sticky",H==="row"){a.position==="top"?(t.style.top=`${f}px`,t.style.bottom="auto"):(t.style.bottom=`${f}px`,t.style.top="auto");return}a.position==="top"?(t.style.top=`${f+b}px`,t.style.bottom="auto"):(t.style.bottom=`${f+b}px`,t.style.top="auto")},Z=()=>{d&&cancelAnimationFrame(d),d=requestAnimationFrame(q)};q();const D=typeof ResizeObserver<"u"?new ResizeObserver(Z):null;return D?.observe(n),()=>{d&&cancelAnimationFrame(d),D?.disconnect(),t.style.position=l.position,t.style.top=l.top,t.style.bottom=l.bottom}},[a,g,H]);const V=a?.offsetPx??0,Y=a&&a.position==="top"?{position:"sticky",top:V,bottom:"auto"}:a&&a.position==="bottom"?{position:"sticky",bottom:V,top:"auto"}:{};return ue(ae,{children:[N("div",{id:u,"data-container_name":u,"data-is_sticky":a?"true":"false",ref:X,className:`${z["flex-container"]} ${F&&F!==""?F:""}`,...E!==void 0?{"data-grow":E}:{},...W!=null?{"data-prev_grow":W}:{},"data-is_resize":G,"data-is_resize_panel":g,style:{...E!==void 0?{flex:`${E} 1 0%`}:{},...Y},children:C&&N("div",{className:`${z["flex-content-fit-wrapper"]}`,ref:h,children:v})||v}),g&&N(ie,{containerName:u,layoutName:x,direction:H,containerCount:$,panelMode:j,panelClassName:K,panelMovementMode:J,onResizingChange:Q})]})}export{le as default};
@@ -0,0 +1 @@
1
+ "use strict";"use client";var me=Object.create;var H=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var ge=(n,o)=>{for(var r in o)H(n,r,{get:o[r],enumerable:!0})},V=(n,o,r,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of he(o))!fe.call(n,a)&&a!==r&&H(n,a,{get:()=>o[a],enumerable:!(l=de(o,a))||l.enumerable});return n};var we=(n,o,r)=>(r=n!=null?me(pe(n)):{},V(o||!n||!n.__esModule?H(r,"default",{value:n,enumerable:!0}):r,n)),be=n=>V(H({},"__esModule",{value:!0}),n);var ve={};ge(ve,{default:()=>q});module.exports=be(ve);var G=require("react/jsx-runtime"),c=require("react"),e=require("rxjs"),j=we(require("./../styles/sentinelStyle.module.css"),1);function q({extraHeight:n=0,extraHeightUnit:o="px",targetRef:r}){const l=(0,c.useRef)(null),a=(0,c.useRef)(-1),$=(0,c.useRef)(null),S=(0,c.useRef)(-1);return(0,c.useLayoutEffect)(()=>{if(typeof window>"u")return;const M=$.current;if(!M)return;const t=(r?.current?r.current:M.parentElement)??null;if(!t)return;const k=t.style.height,J=t.style.minHeight;let x=!1,d=null;const E=1e3,K=30;let g=0,h=!1,p=null;const T=new e.Subject,B=new e.Subject,F=new e.Subscription,Q=()=>{if(l.current=null,performance.now()<g){h=!0;return}x=!0,d!=null&&cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{x=!1});const s=t.style.height,v=t.style.minHeight;try{t.style.height="auto",t.style.minHeight="0px";const u=Math.max(0,Math.round(window.visualViewport?.height??window.innerHeight??0)),f=window.getComputedStyle(t),re=t.getBoundingClientRect(),ie=Math.max(0,Math.round(re.top)),D=Math.max(0,u-ie),C=Math.max(0,Math.ceil(t.scrollHeight)),z=parseFloat(f.paddingTop)||0,N=parseFloat(f.paddingBottom)||0,I=parseFloat(f.borderTopWidth)||0,W=parseFloat(f.borderBottomWidth)||0;let L=0,y=0;f.boxSizing==="border-box"?(L=C+I+W,y=D):(L=Math.max(0,C-z-N),y=Math.max(0,D-z-N-I-W));let _=0,m=t.lastElementChild;for(;m&&m.dataset.flexLayoutDynamicHeightAnchor==="true";)m=m.previousElementSibling;if(m){const ue=window.getComputedStyle(m);_=parseFloat(ue.marginBottom)||0}const P=Number.isFinite(n)?n:0,se=o==="%"?"%":"px",U=Math.max(y,Math.ceil(L+_)),le=se==="px"?U+P:U*(1+P/100),O=Math.max(0,Math.ceil(le)),A=Math.max(0,Math.ceil(y)),ae=Math.abs(O-a.current)<1,ce=Math.abs(A-S.current)<1;if(ae&&ce){t.style.height=s,t.style.minHeight=v,T.next();return}a.current=O,S.current=A,t.style.height=`${O}px`,t.style.minHeight=`${A}px`}catch{t.style.height=s,t.style.minHeight=v}},R=()=>{if(performance.now()<g){h=!0;return}l.current==null&&(l.current=window.requestAnimationFrame(Q))},X=new e.Observable(i=>{const s=new MutationObserver(v=>{for(const u of v)if(!(u.type==="attributes"&&u.attributeName==="style"&&(u.target===t||u.target===M))){i.next();return}});return s.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),()=>s.disconnect()}),Y=new e.Observable(i=>{const s=new ResizeObserver(()=>{x||i.next()});return s.observe(t),t.firstElementChild&&s.observe(t.firstElementChild),()=>s.disconnect()}),Z=(0,e.fromEvent)(window,"resize",{passive:!0}),w=window.visualViewport,ee=w?(0,e.fromEvent)(w,"resize"):new e.Observable,te=w?(0,e.fromEvent)(w,"scroll"):new e.Observable,b=document.fonts,ne=b?.addEventListener?(0,e.fromEvent)(b,"loadingdone"):new e.Observable,oe=b?.addEventListener?(0,e.fromEvent)(b,"loadingerror"):new e.Observable;return F.add((0,e.merge)(X,Y,Z,ee,te,ne,oe,B).pipe((0,e.auditTime)(0,e.animationFrameScheduler)).subscribe(()=>R())),F.add(T.pipe((0,e.bufferTime)(E),(0,e.map)(i=>i.length),(0,e.filter)(i=>i>=K)).subscribe(()=>{const i=performance.now();g=Math.max(g,i+E),h=!0,p!=null&&window.clearTimeout(p),p=window.setTimeout(()=>{h&&(h=!1,R())},E)})),R(),()=>{l.current!=null&&cancelAnimationFrame(l.current),d!=null&&cancelAnimationFrame(d),p!=null&&window.clearTimeout(p),F.unsubscribe(),T.complete(),B.complete(),t.style.height=k,t.style.minHeight=J}},[n,o,r]),(0,G.jsx)("div",{ref:$,"data-flex-layout-dynamic-height-anchor":"true",className:j.default["flex-layout-sentinel-style"],"aria-hidden":"true"})}
@@ -0,0 +1,6 @@
1
+ import { type RefObject } from "react";
2
+ export default function FlexLayoutDynamicHeight({ extraHeight, extraHeightUnit, targetRef, }: {
3
+ extraHeight?: number;
4
+ extraHeightUnit?: "px" | "%";
5
+ targetRef?: RefObject<HTMLElement | null>;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ "use client";import{jsx as be}from"react/jsx-runtime";import{useLayoutEffect as ae,useRef as w}from"react";import{Observable as i,Subject as V,Subscription as ce,animationFrameScheduler as ue,auditTime as me,bufferTime as de,filter as he,fromEvent as m,map as pe,merge as fe}from"rxjs";import ge from"./../styles/sentinelStyle.module.css";function we({extraHeight:b=0,extraHeightUnit:O="px",targetRef:v}){const s=w(null),A=w(-1),$=w(null),S=w(-1);return ae(()=>{if(typeof window>"u")return;const y=$.current;if(!y)return;const e=(v?.current?v.current:y.parentElement)??null;if(!e)return;const j=e.style.height,q=e.style.minHeight;let H=!1,l=null;const M=1e3,G=30;let d=0,a=!1,c=null;const x=new V,B=new V,E=new ce,k=()=>{if(s.current=null,performance.now()<d){a=!0;return}H=!0,l!=null&&cancelAnimationFrame(l),l=window.requestAnimationFrame(()=>{H=!1});const n=e.style.height,f=e.style.minHeight;try{e.style.height="auto",e.style.minHeight="0px";const o=Math.max(0,Math.round(window.visualViewport?.height??window.innerHeight??0)),u=window.getComputedStyle(e),te=e.getBoundingClientRect(),ne=Math.max(0,Math.round(te.top)),D=Math.max(0,o-ne),C=Math.max(0,Math.ceil(e.scrollHeight)),z=parseFloat(u.paddingTop)||0,N=parseFloat(u.paddingBottom)||0,I=parseFloat(u.borderTopWidth)||0,W=parseFloat(u.borderBottomWidth)||0;let F=0,g=0;u.boxSizing==="border-box"?(F=C+I+W,g=D):(F=Math.max(0,C-z-N),g=Math.max(0,D-z-N-I-W));let _=0,r=e.lastElementChild;for(;r&&r.dataset.flexLayoutDynamicHeightAnchor==="true";)r=r.previousElementSibling;if(r){const le=window.getComputedStyle(r);_=parseFloat(le.marginBottom)||0}const P=Number.isFinite(b)?b:0,oe=O==="%"?"%":"px",U=Math.max(g,Math.ceil(F+_)),re=oe==="px"?U+P:U*(1+P/100),R=Math.max(0,Math.ceil(re)),L=Math.max(0,Math.ceil(g)),ie=Math.abs(R-A.current)<1,se=Math.abs(L-S.current)<1;if(ie&&se){e.style.height=n,e.style.minHeight=f,x.next();return}A.current=R,S.current=L,e.style.height=`${R}px`,e.style.minHeight=`${L}px`}catch{e.style.height=n,e.style.minHeight=f}},T=()=>{if(performance.now()<d){a=!0;return}s.current==null&&(s.current=window.requestAnimationFrame(k))},J=new i(t=>{const n=new MutationObserver(f=>{for(const o of f)if(!(o.type==="attributes"&&o.attributeName==="style"&&(o.target===e||o.target===y))){t.next();return}});return n.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),()=>n.disconnect()}),K=new i(t=>{const n=new ResizeObserver(()=>{H||t.next()});return n.observe(e),e.firstElementChild&&n.observe(e.firstElementChild),()=>n.disconnect()}),Q=m(window,"resize",{passive:!0}),h=window.visualViewport,X=h?m(h,"resize"):new i,Y=h?m(h,"scroll"):new i,p=document.fonts,Z=p?.addEventListener?m(p,"loadingdone"):new i,ee=p?.addEventListener?m(p,"loadingerror"):new i;return E.add(fe(J,K,Q,X,Y,Z,ee,B).pipe(me(0,ue)).subscribe(()=>T())),E.add(x.pipe(de(M),pe(t=>t.length),he(t=>t>=G)).subscribe(()=>{const t=performance.now();d=Math.max(d,t+M),a=!0,c!=null&&window.clearTimeout(c),c=window.setTimeout(()=>{a&&(a=!1,T())},M)})),T(),()=>{s.current!=null&&cancelAnimationFrame(s.current),l!=null&&cancelAnimationFrame(l),c!=null&&window.clearTimeout(c),E.unsubscribe(),x.complete(),B.complete(),e.style.height=j,e.style.minHeight=q}},[b,O,v]),be("div",{ref:$,"data-flex-layout-dynamic-height-anchor":"true",className:ge["flex-layout-sentinel-style"],"aria-hidden":"true"})}export{we as default};
@@ -1,68 +1 @@
1
- "use strict";
2
- "use client";
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var FlexLayoutIFramePane_exports = {};
21
- __export(FlexLayoutIFramePane_exports, {
22
- FlexLayoutIFramePane: () => FlexLayoutIFramePane
23
- });
24
- module.exports = __toCommonJS(FlexLayoutIFramePane_exports);
25
- var import_jsx_runtime = require("react/jsx-runtime");
26
- var import_react = require("react");
27
- var import_rxjs = require("rxjs");
28
- var import_hooks = require("../hooks");
29
- function FlexLayoutIFramePane({
30
- url,
31
- screenKey
32
- }) {
33
- const [blockPointer, setBlockPointer] = (0, import_react.useState)(false);
34
- (0, import_react.useEffect)(() => {
35
- const draggingSubject = import_hooks.dragStateSubject.pipe(
36
- (0, import_rxjs.map)((s) => !!s?.isDragging),
37
- (0, import_rxjs.startWith)(false),
38
- (0, import_rxjs.distinctUntilChanged)()
39
- );
40
- const sub = (0, import_rxjs.combineLatest)([draggingSubject, import_hooks.isResizingSubject]).pipe(
41
- (0, import_rxjs.map)(([dragging, resizing]) => dragging || resizing),
42
- (0, import_rxjs.distinctUntilChanged)()
43
- ).subscribe(setBlockPointer);
44
- return () => sub.unsubscribe();
45
- }, []);
46
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
- "iframe",
48
- {
49
- src: url,
50
- style: {
51
- width: "100%",
52
- height: "100%",
53
- border: 0,
54
- //리사이즈 및 드래깅 중 ifram이 이벤트 못먹게 방지
55
- pointerEvents: blockPointer ? "none" : "auto"
56
- },
57
- sandbox: "allow-same-origin allow-scripts allow-forms allow-popups",
58
- referrerPolicy: "no-referrer",
59
- loading: "lazy"
60
- },
61
- screenKey
62
- );
63
- }
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- FlexLayoutIFramePane
67
- });
68
- //# sourceMappingURL=FlexLayoutIFramePane.cjs.map
1
+ "use strict";"use client";var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},y=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of f(e))!m.call(t,i)&&i!==o&&c(t,i,{get:()=>e[i],enumerable:!(s=b(e,i))||s.enumerable});return t};var h=t=>y(c({},"__esModule",{value:!0}),t);var S={};d(S,{FlexLayoutIFramePane:()=>w});module.exports=h(S);var u=require("react/jsx-runtime"),n=require("react"),r=require("rxjs"),a=require("../hooks");function w({url:t,screenKey:e}){const[o,s]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{const i=a.dragStateSubject.pipe((0,r.map)(l=>!!l?.isDragging),(0,r.startWith)(!1),(0,r.distinctUntilChanged)()),g=(0,r.combineLatest)([i,a.isResizingSubject]).pipe((0,r.map)(([l,p])=>l||p),(0,r.distinctUntilChanged)()).subscribe(s);return()=>g.unsubscribe()},[]),(0,u.jsx)("iframe",{src:t,style:{width:"100%",height:"100%",border:0,pointerEvents:o?"none":"auto"},sandbox:"allow-same-origin allow-scripts allow-forms allow-popups",referrerPolicy:"no-referrer",loading:"lazy"},e)}0&&(module.exports={FlexLayoutIFramePane});
@@ -1,44 +1 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { useEffect, useState } from "react";
4
- import { combineLatest, distinctUntilChanged, map, startWith } from "rxjs";
5
- import { dragStateSubject, isResizingSubject } from "../hooks";
6
- function FlexLayoutIFramePane({
7
- url,
8
- screenKey
9
- }) {
10
- const [blockPointer, setBlockPointer] = useState(false);
11
- useEffect(() => {
12
- const draggingSubject = dragStateSubject.pipe(
13
- map((s) => !!s?.isDragging),
14
- startWith(false),
15
- distinctUntilChanged()
16
- );
17
- const sub = combineLatest([draggingSubject, isResizingSubject]).pipe(
18
- map(([dragging, resizing]) => dragging || resizing),
19
- distinctUntilChanged()
20
- ).subscribe(setBlockPointer);
21
- return () => sub.unsubscribe();
22
- }, []);
23
- return /* @__PURE__ */ jsx(
24
- "iframe",
25
- {
26
- src: url,
27
- style: {
28
- width: "100%",
29
- height: "100%",
30
- border: 0,
31
- //리사이즈 및 드래깅 중 ifram이 이벤트 못먹게 방지
32
- pointerEvents: blockPointer ? "none" : "auto"
33
- },
34
- sandbox: "allow-same-origin allow-scripts allow-forms allow-popups",
35
- referrerPolicy: "no-referrer",
36
- loading: "lazy"
37
- },
38
- screenKey
39
- );
40
- }
41
- export {
42
- FlexLayoutIFramePane
43
- };
44
- //# sourceMappingURL=FlexLayoutIFramePane.js.map
1
+ "use client";import{jsx as d}from"react/jsx-runtime";import{useEffect as u,useState as g}from"react";import{combineLatest as p,distinctUntilChanged as r,map as t,startWith as b}from"rxjs";import{dragStateSubject as f,isResizingSubject as m}from"../hooks";function S({url:i,screenKey:o}){const[s,n]=g(!1);return u(()=>{const a=f.pipe(t(e=>!!e?.isDragging),b(!1),r()),l=p([a,m]).pipe(t(([e,c])=>e||c),r()).subscribe(n);return()=>l.unsubscribe()},[]),d("iframe",{src:i,style:{width:"100%",height:"100%",border:0,pointerEvents:s?"none":"auto"},sandbox:"allow-same-origin allow-scripts allow-forms allow-popups",referrerPolicy:"no-referrer",loading:"lazy"},o)}export{S as FlexLayoutIFramePane};
@@ -1,246 +1 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var FlexLayoutResizePanel_exports = {};
31
- __export(FlexLayoutResizePanel_exports, {
32
- default: () => FlexLayoutResizePanel
33
- });
34
- module.exports = __toCommonJS(FlexLayoutResizePanel_exports);
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = require("react");
37
- var import_hooks = require("../hooks");
38
- var import_FlexLayoutContainerStore = require("../store/FlexLayoutContainerStore");
39
- var import_FlexLayout = __toESM(require("../styles/FlexLayout.module.css"), 1);
40
- var import_FlexLayoutUtils = require("../utils/FlexLayoutUtils");
41
- const flexDirectionModel = {
42
- row: {
43
- xy: "x",
44
- targetDirection: "left",
45
- nextDirection: "right",
46
- sizeName: "width",
47
- resizeCursor: "ew-resize"
48
- },
49
- column: {
50
- xy: "y",
51
- targetDirection: "top",
52
- nextDirection: "bottom",
53
- sizeName: "height",
54
- resizeCursor: "ns-resize"
55
- }
56
- };
57
- function FlexLayoutResizePanel({
58
- direction,
59
- containerCount,
60
- panelMode = "default",
61
- containerName,
62
- layoutName,
63
- panelClassName,
64
- panelMovementMode,
65
- onResizingChange
66
- }) {
67
- const directionRef = (0, import_react.useRef)(direction);
68
- const movementModeRef = (0, import_react.useRef)(panelMovementMode);
69
- (0, import_react.useEffect)(() => {
70
- directionRef.current = direction;
71
- }, [direction]);
72
- (0, import_react.useEffect)(() => {
73
- movementModeRef.current = panelMovementMode;
74
- }, [panelMovementMode]);
75
- const isResizePanelClickRef = (0, import_react.useRef)(false);
76
- const prevTouchEventRef = (0, import_react.useRef)(null);
77
- const parentSizeRef = (0, import_react.useRef)(0);
78
- const totalMovementRef = (0, import_react.useRef)(0);
79
- const containerCountRef = (0, import_react.useRef)(containerCount);
80
- const panelRef = (0, import_react.useRef)(null);
81
- (0, import_react.useEffect)(() => {
82
- return () => {
83
- import_hooks.isResizingSubject.next(false);
84
- document.body.style.cursor = "";
85
- };
86
- }, []);
87
- (0, import_react.useEffect)(() => {
88
- containerCountRef.current = containerCount;
89
- }, [containerCount]);
90
- const panelMouseDownEvent = (event) => {
91
- if (!panelRef.current || !panelRef.current.parentElement) return;
92
- isResizePanelClickRef.current = true;
93
- onResizingChange?.(true);
94
- containerCountRef.current = [
95
- ...panelRef.current.parentElement.children
96
- ].filter((e) => e.hasAttribute("data-container_name")).length;
97
- const sizeName = flexDirectionModel[direction].sizeName;
98
- parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
99
- prevTouchEventRef.current = null;
100
- totalMovementRef.current = 0;
101
- import_hooks.isResizingSubject.next(true);
102
- if (!parentSizeRef.current) return;
103
- document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
104
- };
105
- const panelMouseUpEvent = () => {
106
- isResizePanelClickRef.current = false;
107
- onResizingChange?.(false);
108
- parentSizeRef.current = 0;
109
- totalMovementRef.current = 0;
110
- prevTouchEventRef.current = null;
111
- import_hooks.isResizingSubject.next(false);
112
- document.body.style.cursor = "";
113
- };
114
- function moveMouseFlex(originTarget, resizePanel, moveEvent, dir, mode) {
115
- const model = flexDirectionModel[dir];
116
- const movement = moveEvent["movement" + model.xy.toUpperCase()];
117
- totalMovementRef.current += movement;
118
- const minSizeName = "min-" + model.sizeName;
119
- const maxSizeName = "max-" + model.sizeName;
120
- let targetElement = (0, import_FlexLayoutUtils.findNotCloseFlexContent)(
121
- originTarget,
122
- "previousElementSibling"
123
- );
124
- if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
125
- targetElement = originTarget;
126
- let nextElement = (0, import_FlexLayoutUtils.findNotCloseFlexContent)(
127
- resizePanel.nextElementSibling,
128
- "nextElementSibling"
129
- );
130
- if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
131
- nextElement = resizePanel.nextElementSibling;
132
- if (!targetElement || !nextElement) return;
133
- const targetRect = targetElement.getBoundingClientRect();
134
- const targetStyle = window.getComputedStyle(targetElement);
135
- const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
136
- const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
137
- const nextRect = nextElement.getBoundingClientRect();
138
- const nextStyle = window.getComputedStyle(nextElement);
139
- const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
140
- const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
141
- let targetSize = targetRect[model.sizeName] + movement;
142
- let nextElementSize = nextRect[model.sizeName] - movement;
143
- if (targetMaxSize > 0 && targetSize > targetMaxSize) {
144
- return;
145
- }
146
- if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
147
- return;
148
- }
149
- if ((0, import_FlexLayoutUtils.isOverMove)(targetSize, targetMinSize)) {
150
- targetSize = 0;
151
- nextElementSize = nextRect[model.sizeName];
152
- } else if ((0, import_FlexLayoutUtils.isOverMove)(nextElementSize, nextMinSize)) {
153
- nextElementSize = 0;
154
- targetSize = targetRect[model.sizeName];
155
- }
156
- const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
157
- const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
158
- if (!(targetElement instanceof HTMLElement)) return;
159
- if (!(nextElement instanceof HTMLElement)) return;
160
- targetElement.style.flex = `${targetFlexGrow} 1 0%`;
161
- nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
162
- }
163
- (0, import_react.useEffect)(() => {
164
- const addGlobalMoveEvent = (event) => {
165
- if (!isResizePanelClickRef.current || !panelRef.current) {
166
- return;
167
- }
168
- event.preventDefault();
169
- const dir = directionRef.current;
170
- const mode = movementModeRef.current;
171
- const targetElement = panelRef.current.previousElementSibling;
172
- const targetPanel = panelRef.current;
173
- if (!targetElement || !targetPanel) return;
174
- let move = { movementX: 0, movementY: 0 };
175
- if (window.TouchEvent && event instanceof window.TouchEvent) {
176
- const prev = prevTouchEventRef.current;
177
- if (!prev) {
178
- prevTouchEventRef.current = event;
179
- return;
180
- }
181
- move.movementX = (prev.touches[0].pageX - event.touches[0].pageX) * -1;
182
- move.movementY = (prev.touches[0].pageY - event.touches[0].pageY) * -1;
183
- prevTouchEventRef.current = event;
184
- } else {
185
- move.movementX = event.movementX;
186
- move.movementY = event.movementY;
187
- }
188
- moveMouseFlex(targetElement, targetPanel, move, dir, mode);
189
- };
190
- ["mousemove", "touchmove"].forEach((eventName) => {
191
- window.addEventListener(eventName, addGlobalMoveEvent, {
192
- passive: false
193
- });
194
- });
195
- [
196
- "mouseup",
197
- "touchend",
198
- "touchcancel",
199
- // 터치 제스처 시스템 인터럽트
200
- "pointerup",
201
- // 범용 포인터 이벤트
202
- "pointercancel",
203
- "blur"
204
- // 윈도우 포커스 아웃 (Alt+Tab 등)
205
- ].forEach((eventName) => {
206
- window.addEventListener(eventName, panelMouseUpEvent);
207
- });
208
- return () => {
209
- ["mousemove", "touchmove"].forEach((eventName) => {
210
- window.removeEventListener(eventName, addGlobalMoveEvent);
211
- });
212
- [
213
- "mouseup",
214
- "touchend",
215
- "touchcancel",
216
- // 터치 제스처 시스템 인터럽트
217
- "pointerup",
218
- // 범용 포인터 이벤트
219
- "pointercancel",
220
- "blur"
221
- // 윈도우 포커스 아웃 (Alt+Tab 등)
222
- ].forEach((eventName) => {
223
- window.removeEventListener(eventName, panelMouseUpEvent);
224
- });
225
- };
226
- }, []);
227
- (0, import_react.useEffect)(() => {
228
- if (!panelRef.current) return;
229
- (0, import_FlexLayoutContainerStore.setResizePanelRef)(layoutName, containerName, panelRef);
230
- return () => {
231
- (0, import_FlexLayoutContainerStore.setResizePanelRef)(layoutName, containerName, null);
232
- };
233
- }, [containerName, layoutName]);
234
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
235
- "div",
236
- {
237
- id: containerName + "_resize_panel",
238
- className: `${import_FlexLayout.default["flex-resize-panel"]} ${import_FlexLayout.default[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
239
- ref: panelRef,
240
- onMouseDown: panelMouseDownEvent,
241
- onTouchStart: panelMouseDownEvent,
242
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: import_FlexLayout.default.hover })
243
- }
244
- );
245
- }
246
- //# sourceMappingURL=FlexLayoutResizePanel.cjs.map
1
+ "use strict";"use client";var fe=Object.create;var G=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var Ee=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},te=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of pe(t))!ge.call(e,c)&&c!==n&&G(e,c,{get:()=>t[c],enumerable:!(r=de(t,c))||r.enumerable});return e};var ve=(e,t,n)=>(n=e!=null?fe(he(e)):{},te(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),Me=e=>te(G({},"__esModule",{value:!0}),e);var xe={};Ee(xe,{default:()=>oe});module.exports=Me(xe);var J=require("react/jsx-runtime"),u=require("react"),T=require("../hooks"),K=require("../store/FlexLayoutContainerStore"),C=ve(require("../styles/FlexLayout.module.css"),1),L=require("../utils/FlexLayoutUtils");const j={row:{xy:"x",targetDirection:"left",nextDirection:"right",sizeName:"width",resizeCursor:"ew-resize"},column:{xy:"y",targetDirection:"top",nextDirection:"bottom",sizeName:"height",resizeCursor:"ns-resize"}},h=4,ne=(e,t,n,r)=>{const c=new Map,l=(a,g)=>{const s=document.elementsFromPoint(a,g);for(const m of s){const M=m.closest?.(`.${C.default["flex-resize-panel"]}`);if(!M)continue;const f=M.dataset.resize_panel_key;f&&(c.has(f)||c.set(f,{el:M,key:f,dir:M.dataset.direction}))}};if([[0,0],[-h,0],[h,0],[0,-h],[0,h],[-h,-h],[h,-h],[-h,h],[h,h]].forEach(([a,g])=>l(e+a,t+g)),n&&r){const a=n.getBoundingClientRect(),g=r==="row"?a.width:r==="column"?a.height:1,s=Math.max(1,Math.ceil(g/2)),m=Math.ceil(h+g*2),p=Math.max(h,Math.ceil(g*2)),M=Array.from(new Set([1,Math.floor(p/2),Math.max(1,p-1)]));if(r==="row")for(let f=-m;f<=m;f+=s)for(const b of M)l(a.left-b,t+f),l(a.right+b,t+f);else if(r==="column")for(let f=-m;f<=m;f+=s)for(const b of M)l(e+f,a.top-b),l(e+f,a.bottom+b)}if(r){const g=[...c.values()].filter(s=>s.dir&&s.dir!==r);for(const s of g){const m=s.el.getBoundingClientRect(),p=s.dir==="row"?m.width:s.dir==="column"?m.height:1,M=Math.max(1,Math.ceil(p/2)),f=Math.ceil(h+p*2),b=Math.max(h,Math.ceil(p*2)),F=Array.from(new Set([1,Math.floor(b/2),Math.max(1,b-1)]));if(r==="column"&&s.dir==="row")for(let y=-f;y<=f;y+=M)for(const o of F)l(m.left-o,t+y),l(m.right+o,t+y);else if(r==="row"&&s.dir==="column")for(let y=-f;y<=f;y+=M)for(const o of F)l(e+y,m.top-o),l(e+y,m.bottom+o)}}return[...c.values()]},D=(e,t)=>{if(!e||e==="auto")return null;if(e.endsWith("px")){const r=parseFloat(e);return Number.isFinite(r)?r:null}if(e.endsWith("%")){const r=parseFloat(e);return Number.isFinite(r)?t*r/100:null}const n=parseFloat(e);return Number.isFinite(n)?n:null},ye=(e,t,n)=>e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom,be=e=>{const t=e.getBoundingClientRect(),n=getComputedStyle(e,"::after");if(!n||n.content==="none"||n.content==="normal"||n.display==="none"||n.visibility==="hidden")return null;const r=D(n.width,t.width),c=D(n.height,t.height);if(!r||!c)return null;const l=D(n.left,t.width),a=D(n.right,t.width),g=D(n.top,t.height),s=D(n.bottom,t.height);let m=t.left;l!==null?m=t.left+l:a!==null&&(m=t.right-a-r);let p=t.top;return g!==null?p=t.top+g:s!==null&&(p=t.bottom-s-c),{left:m,top:p,right:m+r,bottom:p+c}},re=(e,t,n,r,c)=>{const l=n.getBoundingClientRect(),a=be(n);if(a&&ye(e,t,a))return!1;const g=r==="row"?l.width:r==="column"?l.height:1,s=Math.max(c,Math.ceil(g));return r==="row"?e>=l.left-s&&e<=l.right+s:r==="column"?t>=l.top-s&&t<=l.bottom+s:!0};function oe({direction:e,containerCount:t,panelMode:n="default",containerName:r,layoutName:c,panelClassName:l,panelMovementMode:a,onResizingChange:g}){const s=(0,u.useRef)(e),m=(0,u.useRef)(a),p=(0,u.useMemo)(()=>`${c}::${r}`,[c,r]);(0,u.useEffect)(()=>{s.current=e},[e]),(0,u.useEffect)(()=>{m.current=a},[a]);const M=(0,u.useRef)(!1),f=(0,u.useRef)(null),b=(0,u.useRef)(0),F=(0,u.useRef)(0),y=(0,u.useRef)(t),o=(0,u.useRef)(null),B=(0,u.useRef)(null),k=(0,u.useRef)(null);(0,u.useEffect)(()=>()=>{T.isResizingSubject.next(!1),document.body.style.cursor="",k.current?.()},[]),(0,u.useEffect)(()=>{y.current=t},[t]);const se=()=>{if(!o.current||!o.current.parentElement)return;M.current=!0,g?.(!0),y.current=[...o.current.parentElement.children].filter(i=>i.hasAttribute("data-container_name")).length;const d=j[e].sizeName;b.current=o.current.parentElement.getBoundingClientRect()[d],f.current=null,F.current=0,T.isResizingSubject.next(!0)},ie=()=>{M.current=!1,g?.(!1),b.current=0,F.current=0,B.current=null,T.isResizingSubject.next(!1),document.body.style.cursor="",O()};function le(d,i,x,z,S){const E=j[z],H=x["movement"+E.xy.toUpperCase()];F.current+=H;const A="min-"+E.sizeName,X="max-"+E.sizeName;let R=(0,L.findNotCloseFlexContent)(d,"previousElementSibling");(S==="divorce"&&F.current>0||S==="bulldozer"&&H>0||!R)&&(R=d);let w=(0,L.findNotCloseFlexContent)(i.nextElementSibling,"nextElementSibling");if((S==="divorce"&&F.current<0||S==="bulldozer"&&H<0||!w)&&(w=i.nextElementSibling),!R||!w)return;const N=R.getBoundingClientRect(),$=window.getComputedStyle(R),Y=parseFloat($.getPropertyValue(A))||0,v=parseFloat($.getPropertyValue(X))||0,P=w.getBoundingClientRect(),I=window.getComputedStyle(w),W=parseFloat(I.getPropertyValue(A))||0,ee=parseFloat(I.getPropertyValue(X))||0;let _=N[E.sizeName]+H,V=P[E.sizeName]-H;if(v>0&&_>v||ee>0&&V>ee)return;(0,L.isOverMove)(_,Y)?(_=0,V=P[E.sizeName]):(0,L.isOverMove)(V,W)&&(V=0,_=N[E.sizeName]);const ae=_/(b.current-1)*y.current,me=V/(b.current-1)*y.current;R instanceof HTMLElement&&w instanceof HTMLElement&&(R.style.flex=`${ae} 1 0%`,w.style.flex=`${me} 1 0%`)}(0,u.useEffect)(()=>{const d=T.resizeDragSubject.subscribe(i=>{if(i.type==="START"){if(!i.targets.includes(p))return;B.current=i.sessionId,se(),i.cursor&&(document.body.style.cursor=i.cursor);return}if(i.type==="MOVE"){if(B.current!==i.sessionId||!M.current||!o.current)return;const x=s.current,z=m.current,S=o.current.previousElementSibling,E=o.current;if(!S||!E)return;le(S,E,{movementX:i.movementX,movementY:i.movementY},x,z);return}if(i.type==="END"){if(B.current!==i.sessionId)return;ie()}});return()=>d.unsubscribe()},[p]);const Q=d=>{if(!o.current)return;d.preventDefault?.();const i=d.nativeEvent,x=(0,L.getClientXy)(i);if(!x)return;const z=s.current,S=re(x.clientX,x.clientY,o.current,z,h),E=S?ne(x.clientX,x.clientY,o.current,z):[{el:o.current,key:p,dir:z}],H=new Set([p]);E.forEach(v=>H.add(v.key));const A=[...H],X=S&&A.length>=2?"move":j[z].resizeCursor,R=`${Date.now()}_${Math.random().toString(16).slice(2)}`;T.resizeDragSubject.next({type:"START",sessionId:R,targets:A,cursor:X}),k.current?.();let w=x.clientX,N=x.clientY;const $=v=>{v.preventDefault?.();const P=(0,L.getClientXy)(v);if(!P)return;const I=P.clientX-w,W=P.clientY-N;w=P.clientX,N=P.clientY,T.resizeDragSubject.next({type:"MOVE",sessionId:R,movementX:I,movementY:W})},Y=()=>{k.current?.(),k.current=null,T.resizeDragSubject.next({type:"END",sessionId:R})};["mousemove","touchmove"].forEach(v=>{window.addEventListener(v,$,{passive:!1})}),["mouseup","touchend","touchcancel","pointerup","pointercancel","blur"].forEach(v=>window.addEventListener(v,Y)),k.current=()=>{["mousemove","touchmove"].forEach(v=>window.removeEventListener(v,$)),["mouseup","touchend","touchcancel","pointerup","pointercancel","blur"].forEach(v=>window.removeEventListener(v,Y))}};(0,u.useEffect)(()=>{if(o.current)return(0,K.setResizePanelRef)(c,r,o),()=>{(0,K.setResizePanelRef)(c,r,null)}},[r,c]);const q=(0,u.useRef)([]),U=(0,u.useRef)(null),O=()=>{for(const d of q.current)d.querySelector(`.${C.default.hover}`)?.removeAttribute("data-is_hover");q.current=[]},ce=d=>{O();for(const i of d)i.querySelector(`.${C.default.hover}`)?.setAttribute("data-is_hover","");q.current=d},Z=d=>{o.current&&(U.current&&cancelAnimationFrame(U.current),U.current=requestAnimationFrame(()=>{const i=s.current;if(!re(d.clientX,d.clientY,o.current,i,h)){o.current.style.cursor="",O();return}const S=ne(d.clientX,d.clientY,o.current,i).filter(E=>E.dir&&E.dir!==i).map(E=>E.el);o.current.style.cursor=S.length>0?"move":"",ce(S)}))},ue=()=>{o.current&&(o.current.style.cursor="",O())};return(0,J.jsx)("div",{id:r+"_resize_panel","data-resize_panel_key":p,"data-direction":e,className:`${C.default["flex-resize-panel"]} ${C.default[n]} ${l&&l!==""?l:""}`,ref:o,onMouseDown:Q,onTouchStart:Q,onMouseMove:Z,onMouseEnter:Z,onMouseLeave:ue,children:(0,J.jsx)("div",{className:C.default.hover,"aria-hidden":!0})})}