@byeolnaerim/flex-layout 0.0.8 → 0.0.10

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 (125) hide show
  1. package/dist/flex-layout/components/FlexLayout.cjs +1 -76
  2. package/dist/flex-layout/components/FlexLayout.js +1 -70
  3. package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -196
  4. package/dist/flex-layout/components/FlexLayoutContainer.js +1 -189
  5. package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -0
  6. package/dist/flex-layout/components/FlexLayoutIFramePane.d.ts +4 -0
  7. package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -0
  8. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -192
  9. package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +1 -1
  10. package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -186
  11. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1211
  12. package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1197
  13. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -339
  14. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +1 -1
  15. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -333
  16. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -32
  17. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
  18. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -40
  19. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -34
  20. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -30
  21. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -24
  22. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -109
  23. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -103
  24. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -226
  25. package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +1 -0
  26. package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -224
  27. package/dist/flex-layout/components/index.cjs +1 -52
  28. package/dist/flex-layout/components/index.js +1 -9
  29. package/dist/flex-layout/hooks/index.cjs +1 -21
  30. package/dist/flex-layout/hooks/index.js +1 -4
  31. package/dist/flex-layout/hooks/useDrag.cjs +1 -232
  32. package/dist/flex-layout/hooks/useDrag.d.ts +20 -0
  33. package/dist/flex-layout/hooks/useDrag.js +1 -219
  34. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -118
  35. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -116
  36. package/dist/flex-layout/hooks/useListPaging.cjs +1 -179
  37. package/dist/flex-layout/hooks/useListPaging.js +1 -175
  38. package/dist/flex-layout/hooks/useSizes.cjs +1 -104
  39. package/dist/flex-layout/hooks/useSizes.js +1 -101
  40. package/dist/flex-layout/index.cjs +1 -42
  41. package/dist/flex-layout/index.js +1 -7
  42. package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -26
  43. package/dist/flex-layout/providers/FlexLayoutContext.js +1 -23
  44. package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -247
  45. package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
  46. package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -238
  47. package/dist/flex-layout/providers/index.cjs +1 -14
  48. package/dist/flex-layout/providers/index.js +1 -3
  49. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -203
  50. package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +1 -0
  51. package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -181
  52. package/dist/flex-layout/store/index.cjs +1 -14
  53. package/dist/flex-layout/store/index.js +1 -3
  54. package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
  55. package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -4
  56. package/dist/flex-layout/types/FlexDirectionTypes.js +0 -3
  57. package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -4
  58. package/dist/flex-layout/types/FlexLayoutTypes.d.ts +1 -3
  59. package/dist/flex-layout/types/FlexLayoutTypes.js +0 -3
  60. package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -208
  61. package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +4 -4
  62. package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -196
  63. package/dist/flex-layout/utils/index.cjs +1 -14
  64. package/dist/flex-layout/utils/index.js +1 -3
  65. package/dist/index.cjs +1 -14
  66. package/dist/index.js +1 -3
  67. package/dist/types/css.d.cjs +1 -4
  68. package/dist/types/css.d.js +0 -3
  69. package/package.json +116 -109
  70. package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
  71. package/dist/flex-layout/components/FlexLayout.js.map +0 -1
  72. package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
  73. package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
  74. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
  75. package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
  76. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
  77. package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
  78. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
  79. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
  80. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
  81. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
  82. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
  83. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
  84. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
  85. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
  86. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
  87. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
  88. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
  89. package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
  90. package/dist/flex-layout/components/index.cjs.map +0 -1
  91. package/dist/flex-layout/components/index.js.map +0 -1
  92. package/dist/flex-layout/hooks/index.cjs.map +0 -1
  93. package/dist/flex-layout/hooks/index.js.map +0 -1
  94. package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
  95. package/dist/flex-layout/hooks/useDrag.js.map +0 -1
  96. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
  97. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
  98. package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
  99. package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
  100. package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
  101. package/dist/flex-layout/hooks/useSizes.js.map +0 -1
  102. package/dist/flex-layout/index.cjs.map +0 -1
  103. package/dist/flex-layout/index.js.map +0 -1
  104. package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
  105. package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
  106. package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
  107. package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
  108. package/dist/flex-layout/providers/index.cjs.map +0 -1
  109. package/dist/flex-layout/providers/index.js.map +0 -1
  110. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
  111. package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
  112. package/dist/flex-layout/store/index.cjs.map +0 -1
  113. package/dist/flex-layout/store/index.js.map +0 -1
  114. package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
  115. package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
  116. package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
  117. package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
  118. package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
  119. package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
  120. package/dist/flex-layout/utils/index.cjs.map +0 -1
  121. package/dist/flex-layout/utils/index.js.map +0 -1
  122. package/dist/index.cjs.map +0 -1
  123. package/dist/index.js.map +0 -1
  124. package/dist/types/css.d.cjs.map +0 -1
  125. package/dist/types/css.d.js.map +0 -1
@@ -1,232 +1 @@
1
- 'use strict';
2
-
3
- var equal = require('fast-deep-equal');
4
- var react = require('react');
5
- var rxjs = require('rxjs');
6
- var FlexLayoutUtils = require('../utils/FlexLayoutUtils');
7
-
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
-
10
- var equal__default = /*#__PURE__*/_interopDefault(equal);
11
-
12
- const dragState = new rxjs.Subject();
13
- const filterChildren = (obj) => {
14
- const { children, ...rest } = obj || {};
15
- return rest;
16
- };
17
- const useDragCapture = (targetRef) => {
18
- const stateRef = react.useRef(null);
19
- const forceUpdate = react.useRef(0);
20
- react.useEffect(() => {
21
- const subscription = dragState.pipe(
22
- rxjs.map((value) => {
23
- if (!targetRef || !targetRef.current) return null;
24
- const { x, y } = value;
25
- const rect = targetRef.current.getBoundingClientRect();
26
- const {
27
- width,
28
- height,
29
- x: rectX,
30
- y: rectY,
31
- right,
32
- bottom
33
- } = rect;
34
- let isOver = false;
35
- if (x < rectX || x > right || y < rectY || y > bottom) {
36
- isOver = true;
37
- }
38
- const leftBoundary = rectX + width * 0.2;
39
- const rightBoundary = right - width * 0.2;
40
- const topBoundary = rectY + height * 0.2;
41
- const bottomBoundary = bottom - height * 0.2;
42
- let position = "centerBoundary";
43
- if (x < leftBoundary) {
44
- position = "leftBoundary";
45
- } else if (x > rightBoundary) {
46
- position = "rightBoundary";
47
- } else if (y < topBoundary) {
48
- position = "topBoundary";
49
- } else if (y > bottomBoundary) {
50
- position = "bottomBoundary";
51
- }
52
- return {
53
- positionName: position,
54
- isOver,
55
- ...value
56
- };
57
- }),
58
- rxjs.distinctUntilChanged(
59
- (prev, curr) => equal__default.default(filterChildren(prev), filterChildren(curr))
60
- )
61
- ).subscribe({
62
- next: (value) => {
63
- if (value && !equal__default.default(
64
- filterChildren(stateRef.current),
65
- filterChildren(value)
66
- )) {
67
- stateRef.current = value;
68
- forceUpdate.current++;
69
- }
70
- },
71
- error: (err) => console.error(err)
72
- });
73
- return () => subscription.unsubscribe();
74
- }, [targetRef]);
75
- const [, rerender] = react.useState({});
76
- react.useEffect(() => {
77
- const interval = setInterval(() => {
78
- rerender({});
79
- }, 50);
80
- return () => clearInterval(interval);
81
- }, []);
82
- return stateRef.current;
83
- };
84
- const dropMovementEventSubject = new rxjs.Subject();
85
- const allSplitScreenCount = new rxjs.BehaviorSubject(0);
86
- const useDragEvents = ({
87
- isBlockingActiveInput = false
88
- }) => {
89
- const dragResumeTimer = react.useRef(null);
90
- const scrollThreshold = 10;
91
- const isScrolling = react.useRef(false);
92
- const isPending = react.useRef(false);
93
- const isMouseDown = react.useRef(false);
94
- const isDragging = react.useRef(false);
95
- const touchStartX = react.useRef(0);
96
- const touchStartY = react.useRef(0);
97
- const handleStart = react.useCallback(
98
- ({
99
- event: _event,
100
- dragStartCallback
101
- }) => {
102
- const event = _event instanceof Event ? _event : _event.nativeEvent;
103
- if (dragResumeTimer.current) {
104
- clearTimeout(dragResumeTimer.current);
105
- dragResumeTimer.current = null;
106
- }
107
- if (event.target.contentEditable === "true" || isBlockingActiveInput && document.activeElement === event.target) {
108
- return;
109
- }
110
- if (event.cancelable) {
111
- event.preventDefault();
112
- }
113
- isPending.current = true;
114
- isMouseDown.current = true;
115
- if (event instanceof globalThis.TouchEvent) {
116
- const touch = event.touches[0];
117
- touchStartX.current = touch.clientX;
118
- touchStartY.current = touch.clientY;
119
- } else if (event instanceof globalThis.MouseEvent) {
120
- touchStartX.current = event.clientX;
121
- touchStartY.current = event.clientY;
122
- }
123
- setTimeout(() => {
124
- if (!isPending.current || isScrolling.current) return;
125
- isPending.current = false;
126
- isDragging.current = true;
127
- const xy = FlexLayoutUtils.getClientXy(event);
128
- if (!xy) return;
129
- const { clientX, clientY } = xy;
130
- dragStartCallback({ x: clientX, y: clientY });
131
- }, 300);
132
- },
133
- [isBlockingActiveInput]
134
- );
135
- const handleMove = react.useCallback(
136
- ({
137
- event: _event,
138
- notDragCallback,
139
- dragStartCallback,
140
- moveingCallback
141
- }) => {
142
- if (!isMouseDown.current) return;
143
- const event = _event instanceof Event ? _event : _event.nativeEvent;
144
- const xy = FlexLayoutUtils.getClientXy(event);
145
- if (!xy) return;
146
- const { clientX, clientY } = xy;
147
- const deltaX = Math.abs(clientX - touchStartX.current);
148
- const deltaY = Math.abs(clientY - touchStartY.current);
149
- if (isPending.current && (deltaX > scrollThreshold || deltaY > scrollThreshold)) {
150
- isScrolling.current = true;
151
- isPending.current = false;
152
- isDragging.current = false;
153
- if (notDragCallback)
154
- notDragCallback({ x: clientX, y: clientY });
155
- if (dragResumeTimer.current) {
156
- clearTimeout(dragResumeTimer.current);
157
- dragResumeTimer.current = null;
158
- }
159
- dragResumeTimer.current = setTimeout(() => {
160
- if (!isMouseDown.current) return;
161
- if (dragStartCallback)
162
- dragStartCallback({ x: clientX, y: clientY });
163
- isPending.current = true;
164
- isScrolling.current = false;
165
- handleStart({ event: _event, dragStartCallback });
166
- }, 400);
167
- return;
168
- }
169
- if (!isDragging.current || isPending.current) return;
170
- moveingCallback({ x: clientX, y: clientY });
171
- },
172
- [isBlockingActiveInput]
173
- );
174
- const handleEnd = react.useCallback(
175
- ({
176
- event: _event,
177
- dragEndCallback
178
- }) => {
179
- isScrolling.current = false;
180
- isMouseDown.current = false;
181
- if (isPending.current) {
182
- isPending.current = false;
183
- return;
184
- }
185
- const event = _event instanceof Event ? _event : _event.nativeEvent;
186
- if (!isDragging.current) return;
187
- isDragging.current = false;
188
- const xy = FlexLayoutUtils.getClientXy(event);
189
- if (!xy) return;
190
- const { clientX, clientY } = xy;
191
- dragEndCallback({ x: clientX, y: clientY });
192
- },
193
- [isBlockingActiveInput]
194
- );
195
- return {
196
- handleStart,
197
- handleMove,
198
- handleEnd
199
- };
200
- };
201
- const folderEventSubject = new rxjs.Subject();
202
- const setFolderEvent = (newValue) => {
203
- folderEventSubject.next(newValue);
204
- };
205
- const useFolderEvent = () => {
206
- const [folderEvent, setFolderEvent2] = react.useState(
207
- null
208
- );
209
- react.useEffect(() => {
210
- const subscription = folderEventSubject.subscribe((e) => {
211
- if (!e) return;
212
- setFolderEvent2(e);
213
- });
214
- return () => {
215
- if (subscription) {
216
- subscription.unsubscribe();
217
- }
218
- };
219
- }, []);
220
- return { folderEvent };
221
- };
222
-
223
- exports.allSplitScreenCount = allSplitScreenCount;
224
- exports.dragState = dragState;
225
- exports.dropMovementEventSubject = dropMovementEventSubject;
226
- exports.folderEventSubject = folderEventSubject;
227
- exports.setFolderEvent = setFolderEvent;
228
- exports.useDragCapture = useDragCapture;
229
- exports.useDragEvents = useDragEvents;
230
- exports.useFolderEvent = useFolderEvent;
231
- //# sourceMappingURL=useDrag.cjs.map
232
- //# sourceMappingURL=useDrag.cjs.map
1
+ "use strict";var j=Object.create;var S=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var L=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},O=(e,n,t,m)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of F(n))!P.call(e,o)&&o!==t&&S(e,o,{get:()=>n[o],enumerable:!(m=X(n,o))||m.enumerable});return e};var z=(e,n,t)=>(t=e!=null?j(Y(e)):{},O(n||!e||!e.__esModule?S(t,"default",{value:e,enumerable:!0}):t,e)),k=e=>O(S({},"__esModule",{value:!0}),e);var Q={};L(Q,{allSplitScreenCount:()=>U,dragState:()=>H,dragStateSubject:()=>C,dropMovementEventSubject:()=>q,folderEventSubject:()=>N,isResizingSubject:()=>I,resizeDragSubject:()=>K,setFolderEvent:()=>G,useDragCapture:()=>W,useDragEvents:()=>V,useFolderEvent:()=>J});module.exports=k(Q);var B=z(require("fast-deep-equal"),1),r=require("react"),c=require("rxjs"),x=require("../utils/FlexLayoutUtils");const C=new c.Subject,H=C,I=new c.BehaviorSubject(!1),K=new c.Subject,R=e=>{const{children:n,...t}=e||{};return t},W=e=>{const[n,t]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const m=C.pipe((0,c.auditTime)(0,c.animationFrameScheduler),(0,c.map)(o=>{if(!e||!e.current)return null;const{x:u,y:p}=o,d=e.current.getBoundingClientRect(),{width:v,height:b,x:E,y:T,right:h,bottom:i}=d;let f=!1;(u<E||u>h||p<T||p>i)&&(f=!0);const a=E+v*.2,s=h-v*.2,y=T+b*.2,g=i-b*.2;let l="centerBoundary";return u<a?l="leftBoundary":u>s?l="rightBoundary":p<y?l="topBoundary":p>g&&(l="bottomBoundary"),{positionName:l,isOver:f,...o}}),(0,c.distinctUntilChanged)((o,u)=>{const{children:p,...d}=o||{},{children:v,...b}=u||{};return(0,B.default)(R(d),R(b))})).subscribe({next:t,error:o=>console.error(o)});return()=>m.unsubscribe()},[e]),n},q=new c.Subject,U=new c.BehaviorSubject(0),V=({isBlockingActiveInput:e=!1})=>{const n=(0,r.useRef)(null),t=(0,r.useRef)(null),m=10,o=(0,r.useRef)(!1),u=(0,r.useRef)(!1),p=(0,r.useRef)(!1),d=(0,r.useRef)(!1),v=(0,r.useRef)(0),b=(0,r.useRef)(0);(0,r.useEffect)(()=>()=>{n.current&&(clearTimeout(n.current),n.current=null),t.current&&(clearTimeout(t.current),t.current=null)},[]);const E=(0,r.useCallback)(({event:i,dragStartCallback:f})=>{const a=i instanceof Event?i:i.nativeEvent;if(n.current&&(clearTimeout(n.current),n.current=null),t.current&&(clearTimeout(t.current),t.current=null),a.target.contentEditable==="true"||e&&document.activeElement===a.target)return;a.cancelable&&!(a instanceof globalThis.TouchEvent)&&a.preventDefault(),u.current=!0,p.current=!0,o.current=!1;const s=(0,x.getClientXy)(a);if(s){if(v.current=s.clientX,b.current=s.clientY,a.type.toLowerCase().startsWith("touch")||a instanceof globalThis.TouchEvent){u.current=!1,d.current=!0,f({x:s.clientX,y:s.clientY});return}t.current=setTimeout(()=>{if(!u.current||o.current)return;u.current=!1,d.current=!0;const y=(0,x.getClientXy)(a);if(!y)return;const{clientX:g,clientY:l}=y;f({x:g,y:l})},300)}},[e]),T=(0,r.useCallback)(({event:i,notDragCallback:f,dragStartCallback:a,moveingCallback:s})=>{if(!p.current)return;const y=i instanceof Event?i:i.nativeEvent,g=(0,x.getClientXy)(y);if(!g)return;const{clientX:l,clientY:D}=g,M=Math.abs(l-v.current),w=Math.abs(D-b.current);if(u.current&&(y.type.toLowerCase().startsWith("touch")||y instanceof globalThis.TouchEvent)&&(M>m||w>m)){t.current&&(clearTimeout(t.current),t.current=null),o.current=!0,u.current=!1,d.current=!1,f&&f({x:l,y:D}),n.current&&(clearTimeout(n.current),n.current=null),n.current=setTimeout(()=>{p.current&&(v.current=l,b.current=D,u.current=!0,o.current=!1,E({event:i,dragStartCallback:a}))},400);return}!d.current||u.current||s({x:l,y:D})},[e]),h=(0,r.useCallback)(({event:i,dragEndCallback:f})=>{if(o.current=!1,p.current=!1,u.current){u.current=!1,t.current&&(clearTimeout(t.current),t.current=null);return}const a=i instanceof Event?i:i.nativeEvent;if(!d.current)return;d.current=!1;const s=(0,x.getClientXy)(a);if(!s)return;const{clientX:y,clientY:g}=s;f({x:y,y:g})},[e]);return{handleStart:E,handleMove:T,handleEnd:h}},N=new c.Subject,G=e=>{N.next(e)},J=()=>{const[e,n]=(0,r.useState)(null);return(0,r.useEffect)(()=>{const t=N.subscribe(m=>{m&&n(m)});return()=>{t&&t.unsubscribe()}},[]),{folderEvent:e}};0&&(module.exports={allSplitScreenCount,dragState,dragStateSubject,dropMovementEventSubject,folderEventSubject,isResizingSubject,resizeDragSubject,setFolderEvent,useDragCapture,useDragEvents,useFolderEvent});
@@ -23,7 +23,27 @@ export interface DragStateResultType extends DragStateType {
23
23
  positionName: PositionName;
24
24
  isOver: boolean;
25
25
  }
26
+ export type ResizeDragEvent = {
27
+ type: "START";
28
+ sessionId: string;
29
+ targets: string[];
30
+ cursor?: string;
31
+ } | {
32
+ type: "MOVE";
33
+ sessionId: string;
34
+ movementX: number;
35
+ movementY: number;
36
+ } | {
37
+ type: "END";
38
+ sessionId: string;
39
+ };
40
+ export declare const dragStateSubject: Subject<DragStateType>;
41
+ /**
42
+ * @deprecated Use `dragStateSubject` instead. This alias will be removed in a future release.
43
+ */
26
44
  export declare const dragState: Subject<DragStateType>;
45
+ export declare const isResizingSubject: BehaviorSubject<boolean>;
46
+ export declare const resizeDragSubject: Subject<ResizeDragEvent>;
27
47
  export declare const useDragCapture: (targetRef: RefObject<HTMLElement | null>) => DragStateResultType | null;
28
48
  export interface DropTargetComponent {
29
49
  containerName: string;
@@ -1,219 +1 @@
1
- import equal from 'fast-deep-equal';
2
- import { useRef, useEffect, useState, useCallback } from 'react';
3
- import { Subject, BehaviorSubject, map, distinctUntilChanged } from 'rxjs';
4
- import { getClientXy } from '../utils/FlexLayoutUtils';
5
-
6
- const dragState = new Subject();
7
- const filterChildren = (obj) => {
8
- const { children, ...rest } = obj || {};
9
- return rest;
10
- };
11
- const useDragCapture = (targetRef) => {
12
- const stateRef = useRef(null);
13
- const forceUpdate = useRef(0);
14
- useEffect(() => {
15
- const subscription = dragState.pipe(
16
- map((value) => {
17
- if (!targetRef || !targetRef.current) return null;
18
- const { x, y } = value;
19
- const rect = targetRef.current.getBoundingClientRect();
20
- const {
21
- width,
22
- height,
23
- x: rectX,
24
- y: rectY,
25
- right,
26
- bottom
27
- } = rect;
28
- let isOver = false;
29
- if (x < rectX || x > right || y < rectY || y > bottom) {
30
- isOver = true;
31
- }
32
- const leftBoundary = rectX + width * 0.2;
33
- const rightBoundary = right - width * 0.2;
34
- const topBoundary = rectY + height * 0.2;
35
- const bottomBoundary = bottom - height * 0.2;
36
- let position = "centerBoundary";
37
- if (x < leftBoundary) {
38
- position = "leftBoundary";
39
- } else if (x > rightBoundary) {
40
- position = "rightBoundary";
41
- } else if (y < topBoundary) {
42
- position = "topBoundary";
43
- } else if (y > bottomBoundary) {
44
- position = "bottomBoundary";
45
- }
46
- return {
47
- positionName: position,
48
- isOver,
49
- ...value
50
- };
51
- }),
52
- distinctUntilChanged(
53
- (prev, curr) => equal(filterChildren(prev), filterChildren(curr))
54
- )
55
- ).subscribe({
56
- next: (value) => {
57
- if (value && !equal(
58
- filterChildren(stateRef.current),
59
- filterChildren(value)
60
- )) {
61
- stateRef.current = value;
62
- forceUpdate.current++;
63
- }
64
- },
65
- error: (err) => console.error(err)
66
- });
67
- return () => subscription.unsubscribe();
68
- }, [targetRef]);
69
- const [, rerender] = useState({});
70
- useEffect(() => {
71
- const interval = setInterval(() => {
72
- rerender({});
73
- }, 50);
74
- return () => clearInterval(interval);
75
- }, []);
76
- return stateRef.current;
77
- };
78
- const dropMovementEventSubject = new Subject();
79
- const allSplitScreenCount = new BehaviorSubject(0);
80
- const useDragEvents = ({
81
- isBlockingActiveInput = false
82
- }) => {
83
- const dragResumeTimer = useRef(null);
84
- const scrollThreshold = 10;
85
- const isScrolling = useRef(false);
86
- const isPending = useRef(false);
87
- const isMouseDown = useRef(false);
88
- const isDragging = useRef(false);
89
- const touchStartX = useRef(0);
90
- const touchStartY = useRef(0);
91
- const handleStart = useCallback(
92
- ({
93
- event: _event,
94
- dragStartCallback
95
- }) => {
96
- const event = _event instanceof Event ? _event : _event.nativeEvent;
97
- if (dragResumeTimer.current) {
98
- clearTimeout(dragResumeTimer.current);
99
- dragResumeTimer.current = null;
100
- }
101
- if (event.target.contentEditable === "true" || isBlockingActiveInput && document.activeElement === event.target) {
102
- return;
103
- }
104
- if (event.cancelable) {
105
- event.preventDefault();
106
- }
107
- isPending.current = true;
108
- isMouseDown.current = true;
109
- if (event instanceof globalThis.TouchEvent) {
110
- const touch = event.touches[0];
111
- touchStartX.current = touch.clientX;
112
- touchStartY.current = touch.clientY;
113
- } else if (event instanceof globalThis.MouseEvent) {
114
- touchStartX.current = event.clientX;
115
- touchStartY.current = event.clientY;
116
- }
117
- setTimeout(() => {
118
- if (!isPending.current || isScrolling.current) return;
119
- isPending.current = false;
120
- isDragging.current = true;
121
- const xy = getClientXy(event);
122
- if (!xy) return;
123
- const { clientX, clientY } = xy;
124
- dragStartCallback({ x: clientX, y: clientY });
125
- }, 300);
126
- },
127
- [isBlockingActiveInput]
128
- );
129
- const handleMove = useCallback(
130
- ({
131
- event: _event,
132
- notDragCallback,
133
- dragStartCallback,
134
- moveingCallback
135
- }) => {
136
- if (!isMouseDown.current) return;
137
- const event = _event instanceof Event ? _event : _event.nativeEvent;
138
- const xy = getClientXy(event);
139
- if (!xy) return;
140
- const { clientX, clientY } = xy;
141
- const deltaX = Math.abs(clientX - touchStartX.current);
142
- const deltaY = Math.abs(clientY - touchStartY.current);
143
- if (isPending.current && (deltaX > scrollThreshold || deltaY > scrollThreshold)) {
144
- isScrolling.current = true;
145
- isPending.current = false;
146
- isDragging.current = false;
147
- if (notDragCallback)
148
- notDragCallback({ x: clientX, y: clientY });
149
- if (dragResumeTimer.current) {
150
- clearTimeout(dragResumeTimer.current);
151
- dragResumeTimer.current = null;
152
- }
153
- dragResumeTimer.current = setTimeout(() => {
154
- if (!isMouseDown.current) return;
155
- if (dragStartCallback)
156
- dragStartCallback({ x: clientX, y: clientY });
157
- isPending.current = true;
158
- isScrolling.current = false;
159
- handleStart({ event: _event, dragStartCallback });
160
- }, 400);
161
- return;
162
- }
163
- if (!isDragging.current || isPending.current) return;
164
- moveingCallback({ x: clientX, y: clientY });
165
- },
166
- [isBlockingActiveInput]
167
- );
168
- const handleEnd = useCallback(
169
- ({
170
- event: _event,
171
- dragEndCallback
172
- }) => {
173
- isScrolling.current = false;
174
- isMouseDown.current = false;
175
- if (isPending.current) {
176
- isPending.current = false;
177
- return;
178
- }
179
- const event = _event instanceof Event ? _event : _event.nativeEvent;
180
- if (!isDragging.current) return;
181
- isDragging.current = false;
182
- const xy = getClientXy(event);
183
- if (!xy) return;
184
- const { clientX, clientY } = xy;
185
- dragEndCallback({ x: clientX, y: clientY });
186
- },
187
- [isBlockingActiveInput]
188
- );
189
- return {
190
- handleStart,
191
- handleMove,
192
- handleEnd
193
- };
194
- };
195
- const folderEventSubject = new Subject();
196
- const setFolderEvent = (newValue) => {
197
- folderEventSubject.next(newValue);
198
- };
199
- const useFolderEvent = () => {
200
- const [folderEvent, setFolderEvent2] = useState(
201
- null
202
- );
203
- useEffect(() => {
204
- const subscription = folderEventSubject.subscribe((e) => {
205
- if (!e) return;
206
- setFolderEvent2(e);
207
- });
208
- return () => {
209
- if (subscription) {
210
- subscription.unsubscribe();
211
- }
212
- };
213
- }, []);
214
- return { folderEvent };
215
- };
216
-
217
- export { allSplitScreenCount, dragState, dropMovementEventSubject, folderEventSubject, setFolderEvent, useDragCapture, useDragEvents, useFolderEvent };
218
- //# sourceMappingURL=useDrag.js.map
219
- //# sourceMappingURL=useDrag.js.map
1
+ import X from"fast-deep-equal";import{useCallback as S,useEffect as C,useRef as y,useState as N}from"react";import{animationFrameScheduler as F,auditTime as Y,BehaviorSubject as O,distinctUntilChanged as P,map as L,Subject as h}from"rxjs";import{getClientXy as D}from"../utils/FlexLayoutUtils";const R=new h,J=R,Q=new O(!1),Z=new h,B=n=>{const{children:r,...e}=n||{};return e},$=n=>{const[r,e]=N(null);return C(()=>{const b=R.pipe(Y(0,F),L(c=>{if(!n||!n.current)return null;const{x:t,y:s}=c,l=n.current.getBoundingClientRect(),{width:g,height:d,x:v,y:E,right:x,bottom:o}=l;let m=!1;(t<v||t>x||s<E||s>o)&&(m=!0);const u=v+g*.2,i=x-g*.2,p=E+d*.2,f=o-d*.2;let a="centerBoundary";return t<u?a="leftBoundary":t>i?a="rightBoundary":s<p?a="topBoundary":s>f&&(a="bottomBoundary"),{positionName:a,isOver:m,...c}}),P((c,t)=>{const{children:s,...l}=c||{},{children:g,...d}=t||{};return X(B(l),B(d))})).subscribe({next:e,error:c=>console.error(c)});return()=>b.unsubscribe()},[n]),r},A=new h,_=new O(0),ee=({isBlockingActiveInput:n=!1})=>{const r=y(null),e=y(null),b=10,c=y(!1),t=y(!1),s=y(!1),l=y(!1),g=y(0),d=y(0);C(()=>()=>{r.current&&(clearTimeout(r.current),r.current=null),e.current&&(clearTimeout(e.current),e.current=null)},[]);const v=S(({event:o,dragStartCallback:m})=>{const u=o instanceof Event?o:o.nativeEvent;if(r.current&&(clearTimeout(r.current),r.current=null),e.current&&(clearTimeout(e.current),e.current=null),u.target.contentEditable==="true"||n&&document.activeElement===u.target)return;u.cancelable&&!(u instanceof globalThis.TouchEvent)&&u.preventDefault(),t.current=!0,s.current=!0,c.current=!1;const i=D(u);if(i){if(g.current=i.clientX,d.current=i.clientY,u.type.toLowerCase().startsWith("touch")||u instanceof globalThis.TouchEvent){t.current=!1,l.current=!0,m({x:i.clientX,y:i.clientY});return}e.current=setTimeout(()=>{if(!t.current||c.current)return;t.current=!1,l.current=!0;const p=D(u);if(!p)return;const{clientX:f,clientY:a}=p;m({x:f,y:a})},300)}},[n]),E=S(({event:o,notDragCallback:m,dragStartCallback:u,moveingCallback:i})=>{if(!s.current)return;const p=o instanceof Event?o:o.nativeEvent,f=D(p);if(!f)return;const{clientX:a,clientY:T}=f,w=Math.abs(a-g.current),j=Math.abs(T-d.current);if(t.current&&(p.type.toLowerCase().startsWith("touch")||p instanceof globalThis.TouchEvent)&&(w>b||j>b)){e.current&&(clearTimeout(e.current),e.current=null),c.current=!0,t.current=!1,l.current=!1,m&&m({x:a,y:T}),r.current&&(clearTimeout(r.current),r.current=null),r.current=setTimeout(()=>{s.current&&(g.current=a,d.current=T,t.current=!0,c.current=!1,v({event:o,dragStartCallback:u}))},400);return}!l.current||t.current||i({x:a,y:T})},[n]),x=S(({event:o,dragEndCallback:m})=>{if(c.current=!1,s.current=!1,t.current){t.current=!1,e.current&&(clearTimeout(e.current),e.current=null);return}const u=o instanceof Event?o:o.nativeEvent;if(!l.current)return;l.current=!1;const i=D(u);if(!i)return;const{clientX:p,clientY:f}=i;m({x:p,y:f})},[n]);return{handleStart:v,handleMove:E,handleEnd:x}},M=new h,te=n=>{M.next(n)},ne=()=>{const[n,r]=N(null);return C(()=>{const e=M.subscribe(b=>{b&&r(b)});return()=>{e&&e.unsubscribe()}},[]),{folderEvent:n}};export{_ as allSplitScreenCount,J as dragState,R as dragStateSubject,A as dropMovementEventSubject,M as folderEventSubject,Q as isResizingSubject,Z as resizeDragSubject,te as setFolderEvent,$ as useDragCapture,ee as useDragEvents,ne as useFolderEvent};
@@ -1,118 +1 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
- var useDrag = require('./useDrag');
5
-
6
- function useFlexLayoutSplitScreen({
7
- isSplitInitial = false,
8
- parentDirection,
9
- directionInitial = "row",
10
- selfContainerName,
11
- parentLayoutName,
12
- layoutName
13
- }) {
14
- const [direction, setDirection] = react.useState(
15
- directionInitial
16
- );
17
- const [isSplit, setIsSplit] = react.useState(isSplitInitial);
18
- const [boundaryContainerSize, setBoundaryContainerSize] = react.useState(null);
19
- const [centerDropTargetComponent, setCenterDropTargetComponent] = react.useState([]);
20
- const [afterDropTargetComponent, setAfterDropTargetComponent] = react.useState([]);
21
- const [beforeDropTargetComponent, setBeforeDropTargetComponent] = react.useState([]);
22
- const layoutRef = react.useRef(null);
23
- const dragState = useDrag.useDragCapture(layoutRef);
24
- react.useEffect(() => {
25
- if (!dragState) {
26
- setBoundaryContainerSize(null);
27
- return;
28
- }
29
- const {
30
- isDrop,
31
- isDragging,
32
- positionName,
33
- containerName,
34
- children: dropComponent,
35
- isOver,
36
- navigationTitle,
37
- dropEndCallback,
38
- x,
39
- y,
40
- screenKey
41
- } = dragState;
42
- const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
43
- if ((isOver || isDrop) && boundaryContainerSize) {
44
- setBoundaryContainerSize(null);
45
- }
46
- if (selfContainerName.startsWith(containerName)) {
47
- return;
48
- }
49
- if (isDrop && screenKey) {
50
- const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
51
- if (!isSplit && !isOver) {
52
- if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
53
- setIsSplit(true);
54
- setDirection(dropDirection);
55
- }
56
- useDrag.dropMovementEventSubject.next({
57
- state: "append",
58
- targetContainerName: containerName,
59
- targetParentLayoutName: parentLayoutName,
60
- targetLayoutName: layoutName,
61
- targetComponent: dropComponent,
62
- orderName,
63
- x,
64
- y,
65
- dropEndCallback,
66
- dropTargetComponentEvent: {
67
- navigationTitle,
68
- dropDocumentOutsideOption: dragState?.dropDocumentOutsideOption,
69
- direction: dropDirection,
70
- screenKey
71
- }
72
- });
73
- }
74
- }
75
- if (isDragging && !isSplit && !isOver) {
76
- const newSize = {
77
- left: positionName === "rightBoundary" ? "50%" : "0",
78
- top: positionName === "bottomBoundary" ? "50%" : "0",
79
- width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
80
- height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
81
- };
82
- if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
83
- setBoundaryContainerSize(newSize);
84
- }
85
- }
86
- }, [
87
- dragState,
88
- isSplit,
89
- boundaryContainerSize,
90
- parentLayoutName,
91
- layoutName,
92
- selfContainerName,
93
- direction
94
- ]);
95
- return {
96
- direction,
97
- setDirection,
98
- isSplit,
99
- setIsSplit,
100
- boundaryContainerSize,
101
- //setBoundaryContainerSize,
102
- centerDropTargetComponent,
103
- afterDropTargetComponent,
104
- beforeDropTargetComponent,
105
- setAfterDropTargetComponent,
106
- setBeforeDropTargetComponent,
107
- setCenterDropTargetComponent,
108
- //dropTargetComponent,
109
- //setDropTargetComponent,
110
- //setDropPosition,
111
- isOver: dragState?.isOver,
112
- layoutRef
113
- };
114
- }
115
-
116
- exports.useFlexLayoutSplitScreen = useFlexLayoutSplitScreen;
117
- //# sourceMappingURL=useFlexLayoutSplitScreen.cjs.map
118
- //# sourceMappingURL=useFlexLayoutSplitScreen.cjs.map
1
+ "use strict";var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var F=(n,o)=>{for(var i in o)f(n,i,{get:o[i],enumerable:!0})},H=(n,o,i,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!A.call(n,r)&&r!==i&&f(n,r,{get:()=>o[r],enumerable:!(a=j(o,r))||a.enumerable});return n};var K=n=>H(f({},"__esModule",{value:!0}),n);var W={};F(W,{useFlexLayoutSplitScreen:()=>P});module.exports=K(W);var e=require("react"),l=require("./useDrag");function P({isSplitInitial:n=!1,parentDirection:o,directionInitial:i="row",selfContainerName:a,parentLayoutName:r,layoutName:y}){const[D,C]=(0,e.useState)(i),[u,B]=(0,e.useState)(n),[g,c]=(0,e.useState)(null),[b,O]=(0,e.useState)([]),[v,w]=(0,e.useState)([]),[N,E]=(0,e.useState)([]),S=(0,e.useRef)(null),s=(0,l.useDragCapture)(S);return(0,e.useEffect)(()=>{if(!s){c(null);return}const{isDrop:T,isDragging:x,positionName:t,containerName:d,children:L,isOver:m,navigationTitle:z,dropEndCallback:I,x:J,y:M,screenKey:h}=s,R=t==="leftBoundary"||t==="topBoundary"?"before":t==="rightBoundary"||t==="bottomBoundary"?"after":"center";if((m||T)&&g&&c(null),!(a===d||a.startsWith(d+"_"))){if(T&&h){const p=t==="leftBoundary"||t==="rightBoundary"?"row":"column";!u&&!m&&(t!=="centerBoundary"&&p!==o&&(B(!0),C(p)),l.dropMovementEventSubject.next({state:"append",targetContainerName:d,targetParentLayoutName:r,targetLayoutName:y,targetComponent:L,orderName:R,x:J,y:M,dropEndCallback:I,dropTargetComponentEvent:{navigationTitle:z,dropDocumentOutsideOption:s?.dropDocumentOutsideOption,direction:p,screenKey:h}}))}if(x&&!u&&!m){const p={left:t==="rightBoundary"?"50%":"0",top:t==="bottomBoundary"?"50%":"0",width:t==="leftBoundary"||t==="rightBoundary"?"50%":"100%",height:t==="topBoundary"||t==="bottomBoundary"?"50%":"100%"};JSON.stringify(g)!==JSON.stringify(p)&&c(p)}}},[s,u,g,r,y,a,D]),{direction:D,setDirection:C,isSplit:u,setIsSplit:B,boundaryContainerSize:g,centerDropTargetComponent:b,afterDropTargetComponent:v,beforeDropTargetComponent:N,setAfterDropTargetComponent:w,setBeforeDropTargetComponent:E,setCenterDropTargetComponent:O,isOver:s?.isOver,layoutRef:S}}0&&(module.exports={useFlexLayoutSplitScreen});