@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,212 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useListPaging_exports = {};
20
- __export(useListPaging_exports, {
21
- useListPagingForSentinel: () => useListPagingForSentinel,
22
- usePaginationViewNumber: () => usePaginationViewNumber,
23
- usePagingHandler: () => usePagingHandler
24
- });
25
- module.exports = __toCommonJS(useListPaging_exports);
26
- var import_react = require("react");
27
- const useListPagingForSentinel = ({
28
- //initPageNumber,
29
- //initPageSize,
30
- onReachTerminal
31
- }) => {
32
- const [firstChildNode, setFirstChildNode] = (0, import_react.useState)(null);
33
- const [lastChildNode, setLastChildNode] = (0, import_react.useState)(null);
34
- const observerRef = (0, import_react.useRef)(null);
35
- const firstChildRef = (0, import_react.useCallback)((node) => {
36
- setFirstChildNode(node);
37
- }, []);
38
- const lastChildRef = (0, import_react.useCallback)((node) => {
39
- setLastChildNode(node);
40
- }, []);
41
- (0, import_react.useEffect)(() => {
42
- if (firstChildNode && observerRef.current)
43
- observerRef.current.unobserve(firstChildNode);
44
- if (lastChildNode && observerRef.current)
45
- observerRef.current.unobserve(lastChildNode);
46
- const handleIntersect = (entries, observer2) => {
47
- entries.forEach((entry) => {
48
- if (entry.isIntersecting) {
49
- if (entry.target === firstChildNode) {
50
- if (onReachTerminal)
51
- onReachTerminal({
52
- isFirst: true,
53
- isLast: false,
54
- observer: observer2
55
- });
56
- }
57
- if (entry.target === lastChildNode) {
58
- if (onReachTerminal)
59
- onReachTerminal({
60
- isFirst: false,
61
- isLast: true,
62
- observer: observer2
63
- });
64
- }
65
- }
66
- });
67
- };
68
- const observer = new IntersectionObserver(handleIntersect, {
69
- threshold: 0.1
70
- });
71
- observerRef.current = observer;
72
- if (firstChildNode) observer.observe(firstChildNode);
73
- if (lastChildNode) observer.observe(lastChildNode);
74
- return () => {
75
- if (observerRef.current) {
76
- observerRef.current.disconnect();
77
- }
78
- };
79
- }, [firstChildNode, lastChildNode]);
80
- return {
81
- firstChildRef,
82
- lastChildRef
83
- };
84
- };
85
- const usePaginationViewNumber = ({
86
- initPageNumber
87
- }) => {
88
- const [showCurrentPageNumber, setShowCurrentPageNumber] = (0, import_react.useState)(initPageNumber);
89
- const observerRef = (0, import_react.useRef)(null);
90
- const showCurrentPageObserveTarget = (0, import_react.useCallback)(
91
- (node) => {
92
- if (!node) return;
93
- if (!observerRef.current) {
94
- observerRef.current = new IntersectionObserver(
95
- (entries) => {
96
- entries.forEach((entry) => {
97
- if (entry.isIntersecting) {
98
- const pageIndexAttr = entry.target.getAttribute(
99
- "data-page-index"
100
- );
101
- if (!pageIndexAttr) return;
102
- const pageIndex = parseInt(pageIndexAttr, 10);
103
- setShowCurrentPageNumber(pageIndex);
104
- }
105
- });
106
- },
107
- {
108
- threshold: 0.1
109
- // 예: 10% 이상 보여야 intersect로 판단
110
- }
111
- );
112
- }
113
- observerRef.current.observe(node);
114
- },
115
- []
116
- );
117
- (0, import_react.useEffect)(() => {
118
- const currentObserver = observerRef.current;
119
- return () => {
120
- if (currentObserver) {
121
- currentObserver.disconnect();
122
- }
123
- };
124
- }, []);
125
- return {
126
- showCurrentPageNumber,
127
- showCurrentPageObserveTarget
128
- };
129
- };
130
- const usePagingHandler = ({
131
- lastCallPageNumber,
132
- dataListRef
133
- }) => {
134
- const jumpingPageNumberRef = (0, import_react.useRef)(lastCallPageNumber);
135
- const paginationScrollIntoViewTarget = (0, import_react.useRef)({});
136
- const pageNumberRef = (0, import_react.useRef)(lastCallPageNumber);
137
- const resetJumpTimerIdRef = (0, import_react.useRef)(
138
- null
139
- );
140
- const clearResetTimer = (0, import_react.useCallback)(() => {
141
- if (resetJumpTimerIdRef.current !== null) {
142
- window.clearTimeout(resetJumpTimerIdRef.current);
143
- resetJumpTimerIdRef.current = null;
144
- }
145
- }, []);
146
- const armResetTimer = (0, import_react.useCallback)(() => {
147
- clearResetTimer();
148
- resetJumpTimerIdRef.current = window.setTimeout(() => {
149
- jumpingPageNumberRef.current = null;
150
- resetJumpTimerIdRef.current = null;
151
- }, 1e3);
152
- }, [clearResetTimer]);
153
- (0, import_react.useEffect)(() => {
154
- return () => {
155
- clearResetTimer();
156
- };
157
- }, [clearResetTimer]);
158
- const setPaginationRef = (0, import_react.useCallback)(
159
- (i) => (node) => {
160
- if (!node) return;
161
- paginationScrollIntoViewTarget.current[i] = node;
162
- if (jumpingPageNumberRef.current !== null && i === jumpingPageNumberRef.current) {
163
- node.scrollIntoView({
164
- behavior: "instant",
165
- // 필요한 경우 'smooth' 등으로 수정 가능
166
- block: "start"
167
- });
168
- jumpingPageNumberRef.current = null;
169
- }
170
- },
171
- []
172
- );
173
- const handleReachTerminal = ({ isFirst, isLast, observer }, dataCallFetch) => {
174
- if (dataListRef.current.length === 0) return;
175
- if (jumpingPageNumberRef.current != null) return;
176
- if (!isFirst && !isLast) return;
177
- const callPageNumber = isFirst ? Math.max(pageNumberRef.current - 1, 0) : pageNumberRef.current + 1;
178
- if (dataListRef.current[callPageNumber] != null && (dataListRef.current[callPageNumber]?.length || 0) > 0)
179
- return;
180
- jumpingPageNumberRef.current = callPageNumber;
181
- armResetTimer();
182
- dataCallFetch(callPageNumber);
183
- };
184
- const handleClickPageChange = (page, dataCallFetch) => {
185
- const pageData = dataListRef.current[page];
186
- if (pageData != null && Array.isArray(pageData) && pageData.length > 0) {
187
- paginationScrollIntoViewTarget.current[page]?.scrollIntoView({
188
- behavior: "smooth",
189
- block: "start"
190
- });
191
- return;
192
- }
193
- jumpingPageNumberRef.current = page;
194
- armResetTimer();
195
- dataCallFetch(page);
196
- };
197
- return {
198
- jumpingPageNumberRef,
199
- paginationScrollIntoViewTarget,
200
- pageNumberRef,
201
- setPaginationRef,
202
- handleReachTerminal,
203
- handleClickPageChange
204
- };
205
- };
206
- // Annotate the CommonJS export names for ESM import in node:
207
- 0 && (module.exports = {
208
- useListPagingForSentinel,
209
- usePaginationViewNumber,
210
- usePagingHandler
211
- });
212
- //# sourceMappingURL=useListPaging.cjs.map
1
+ "use strict";var h=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var I=(u,e)=>{for(var l in e)h(u,l,{get:e[l],enumerable:!0})},P=(u,e,l,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!R.call(u,s)&&s!==l&&h(u,s,{get:()=>e[s],enumerable:!(t=T(e,s))||t.enumerable});return u};var C=u=>P(h({},"__esModule",{value:!0}),u);var O={};I(O,{useListPagingForSentinel:()=>E,usePaginationViewNumber:()=>w,usePagingHandler:()=>N});module.exports=C(O);var r=require("react");const E=({onReachTerminal:u})=>{const[e,l]=(0,r.useState)(null),[t,s]=(0,r.useState)(null),n=(0,r.useRef)(null),a=(0,r.useCallback)(o=>{l(o)},[]),b=(0,r.useCallback)(o=>{s(o)},[]);return(0,r.useEffect)(()=>{e&&n.current&&n.current.unobserve(e),t&&n.current&&n.current.unobserve(t);const o=(d,i)=>{d.forEach(c=>{c.isIntersecting&&(c.target===e&&u&&u({isFirst:!0,isLast:!1,observer:i}),c.target===t&&u&&u({isFirst:!1,isLast:!0,observer:i}))})},f=new IntersectionObserver(o,{threshold:.1});return n.current=f,e&&f.observe(e),t&&f.observe(t),()=>{n.current&&n.current.disconnect()}},[e,t]),{firstChildRef:a,lastChildRef:b}},w=({initPageNumber:u})=>{const[e,l]=(0,r.useState)(u),t=(0,r.useRef)(null),s=(0,r.useCallback)(n=>{n&&(t.current||(t.current=new IntersectionObserver(a=>{a.forEach(b=>{if(b.isIntersecting){const o=b.target.getAttribute("data-page-index");if(!o)return;const f=parseInt(o,10);l(f)}})},{threshold:.1})),t.current.observe(n))},[]);return(0,r.useEffect)(()=>{const n=t.current;return()=>{n&&n.disconnect()}},[]),{showCurrentPageNumber:e,showCurrentPageObserveTarget:s}},N=({lastCallPageNumber:u,dataListRef:e})=>{const l=(0,r.useRef)(u),t=(0,r.useRef)({}),s=(0,r.useRef)(u),n=(0,r.useRef)(null),a=(0,r.useCallback)(()=>{n.current!==null&&(window.clearTimeout(n.current),n.current=null)},[]),b=(0,r.useCallback)(()=>{a(),n.current=window.setTimeout(()=>{l.current=null,n.current=null},1e3)},[a]);(0,r.useEffect)(()=>()=>{a()},[a]);const o=(0,r.useCallback)(i=>c=>{c&&(t.current[i]=c,l.current!==null&&i===l.current&&(c.scrollIntoView({behavior:"instant",block:"start"}),l.current=null))},[]);return{jumpingPageNumberRef:l,paginationScrollIntoViewTarget:t,pageNumberRef:s,setPaginationRef:o,handleReachTerminal:({isFirst:i,isLast:c,observer:m},v)=>{if(e.current.length===0||l.current!=null||!i&&!c)return;const g=i?Math.max(s.current-1,0):s.current+1;e.current[g]!=null&&(e.current[g]?.length||0)>0||(l.current=g,b(),v(g))},handleClickPageChange:(i,c)=>{const m=e.current[i];if(m!=null&&Array.isArray(m)&&m.length>0){t.current[i]?.scrollIntoView({behavior:"smooth",block:"start"});return}l.current=i,b(),c(i)}}};0&&(module.exports={useListPagingForSentinel,usePaginationViewNumber,usePagingHandler});
@@ -1,191 +1 @@
1
- import {
2
- useCallback,
3
- useEffect,
4
- useRef,
5
- useState
6
- } from "react";
7
- const useListPagingForSentinel = ({
8
- //initPageNumber,
9
- //initPageSize,
10
- onReachTerminal
11
- }) => {
12
- const [firstChildNode, setFirstChildNode] = useState(null);
13
- const [lastChildNode, setLastChildNode] = useState(null);
14
- const observerRef = useRef(null);
15
- const firstChildRef = useCallback((node) => {
16
- setFirstChildNode(node);
17
- }, []);
18
- const lastChildRef = useCallback((node) => {
19
- setLastChildNode(node);
20
- }, []);
21
- useEffect(() => {
22
- if (firstChildNode && observerRef.current)
23
- observerRef.current.unobserve(firstChildNode);
24
- if (lastChildNode && observerRef.current)
25
- observerRef.current.unobserve(lastChildNode);
26
- const handleIntersect = (entries, observer2) => {
27
- entries.forEach((entry) => {
28
- if (entry.isIntersecting) {
29
- if (entry.target === firstChildNode) {
30
- if (onReachTerminal)
31
- onReachTerminal({
32
- isFirst: true,
33
- isLast: false,
34
- observer: observer2
35
- });
36
- }
37
- if (entry.target === lastChildNode) {
38
- if (onReachTerminal)
39
- onReachTerminal({
40
- isFirst: false,
41
- isLast: true,
42
- observer: observer2
43
- });
44
- }
45
- }
46
- });
47
- };
48
- const observer = new IntersectionObserver(handleIntersect, {
49
- threshold: 0.1
50
- });
51
- observerRef.current = observer;
52
- if (firstChildNode) observer.observe(firstChildNode);
53
- if (lastChildNode) observer.observe(lastChildNode);
54
- return () => {
55
- if (observerRef.current) {
56
- observerRef.current.disconnect();
57
- }
58
- };
59
- }, [firstChildNode, lastChildNode]);
60
- return {
61
- firstChildRef,
62
- lastChildRef
63
- };
64
- };
65
- const usePaginationViewNumber = ({
66
- initPageNumber
67
- }) => {
68
- const [showCurrentPageNumber, setShowCurrentPageNumber] = useState(initPageNumber);
69
- const observerRef = useRef(null);
70
- const showCurrentPageObserveTarget = useCallback(
71
- (node) => {
72
- if (!node) return;
73
- if (!observerRef.current) {
74
- observerRef.current = new IntersectionObserver(
75
- (entries) => {
76
- entries.forEach((entry) => {
77
- if (entry.isIntersecting) {
78
- const pageIndexAttr = entry.target.getAttribute(
79
- "data-page-index"
80
- );
81
- if (!pageIndexAttr) return;
82
- const pageIndex = parseInt(pageIndexAttr, 10);
83
- setShowCurrentPageNumber(pageIndex);
84
- }
85
- });
86
- },
87
- {
88
- threshold: 0.1
89
- // 예: 10% 이상 보여야 intersect로 판단
90
- }
91
- );
92
- }
93
- observerRef.current.observe(node);
94
- },
95
- []
96
- );
97
- useEffect(() => {
98
- const currentObserver = observerRef.current;
99
- return () => {
100
- if (currentObserver) {
101
- currentObserver.disconnect();
102
- }
103
- };
104
- }, []);
105
- return {
106
- showCurrentPageNumber,
107
- showCurrentPageObserveTarget
108
- };
109
- };
110
- const usePagingHandler = ({
111
- lastCallPageNumber,
112
- dataListRef
113
- }) => {
114
- const jumpingPageNumberRef = useRef(lastCallPageNumber);
115
- const paginationScrollIntoViewTarget = useRef({});
116
- const pageNumberRef = useRef(lastCallPageNumber);
117
- const resetJumpTimerIdRef = useRef(
118
- null
119
- );
120
- const clearResetTimer = useCallback(() => {
121
- if (resetJumpTimerIdRef.current !== null) {
122
- window.clearTimeout(resetJumpTimerIdRef.current);
123
- resetJumpTimerIdRef.current = null;
124
- }
125
- }, []);
126
- const armResetTimer = useCallback(() => {
127
- clearResetTimer();
128
- resetJumpTimerIdRef.current = window.setTimeout(() => {
129
- jumpingPageNumberRef.current = null;
130
- resetJumpTimerIdRef.current = null;
131
- }, 1e3);
132
- }, [clearResetTimer]);
133
- useEffect(() => {
134
- return () => {
135
- clearResetTimer();
136
- };
137
- }, [clearResetTimer]);
138
- const setPaginationRef = useCallback(
139
- (i) => (node) => {
140
- if (!node) return;
141
- paginationScrollIntoViewTarget.current[i] = node;
142
- if (jumpingPageNumberRef.current !== null && i === jumpingPageNumberRef.current) {
143
- node.scrollIntoView({
144
- behavior: "instant",
145
- // 필요한 경우 'smooth' 등으로 수정 가능
146
- block: "start"
147
- });
148
- jumpingPageNumberRef.current = null;
149
- }
150
- },
151
- []
152
- );
153
- const handleReachTerminal = ({ isFirst, isLast, observer }, dataCallFetch) => {
154
- if (dataListRef.current.length === 0) return;
155
- if (jumpingPageNumberRef.current != null) return;
156
- if (!isFirst && !isLast) return;
157
- const callPageNumber = isFirst ? Math.max(pageNumberRef.current - 1, 0) : pageNumberRef.current + 1;
158
- if (dataListRef.current[callPageNumber] != null && (dataListRef.current[callPageNumber]?.length || 0) > 0)
159
- return;
160
- jumpingPageNumberRef.current = callPageNumber;
161
- armResetTimer();
162
- dataCallFetch(callPageNumber);
163
- };
164
- const handleClickPageChange = (page, dataCallFetch) => {
165
- const pageData = dataListRef.current[page];
166
- if (pageData != null && Array.isArray(pageData) && pageData.length > 0) {
167
- paginationScrollIntoViewTarget.current[page]?.scrollIntoView({
168
- behavior: "smooth",
169
- block: "start"
170
- });
171
- return;
172
- }
173
- jumpingPageNumberRef.current = page;
174
- armResetTimer();
175
- dataCallFetch(page);
176
- };
177
- return {
178
- jumpingPageNumberRef,
179
- paginationScrollIntoViewTarget,
180
- pageNumberRef,
181
- setPaginationRef,
182
- handleReachTerminal,
183
- handleClickPageChange
184
- };
185
- };
186
- export {
187
- useListPagingForSentinel,
188
- usePaginationViewNumber,
189
- usePagingHandler
190
- };
191
- //# sourceMappingURL=useListPaging.js.map
1
+ import{useCallback as f,useEffect as d,useRef as m,useState as v}from"react";const P=({onReachTerminal:i})=>{const[n,u]=v(null),[r,o]=v(null),e=m(null),c=f(s=>{u(s)},[]),a=f(s=>{o(s)},[]);return d(()=>{n&&e.current&&e.current.unobserve(n),r&&e.current&&e.current.unobserve(r);const s=(T,t)=>{T.forEach(l=>{l.isIntersecting&&(l.target===n&&i&&i({isFirst:!0,isLast:!1,observer:t}),l.target===r&&i&&i({isFirst:!1,isLast:!0,observer:t}))})},b=new IntersectionObserver(s,{threshold:.1});return e.current=b,n&&b.observe(n),r&&b.observe(r),()=>{e.current&&e.current.disconnect()}},[n,r]),{firstChildRef:c,lastChildRef:a}},C=({initPageNumber:i})=>{const[n,u]=v(i),r=m(null),o=f(e=>{e&&(r.current||(r.current=new IntersectionObserver(c=>{c.forEach(a=>{if(a.isIntersecting){const s=a.target.getAttribute("data-page-index");if(!s)return;const b=parseInt(s,10);u(b)}})},{threshold:.1})),r.current.observe(e))},[]);return d(()=>{const e=r.current;return()=>{e&&e.disconnect()}},[]),{showCurrentPageNumber:n,showCurrentPageObserveTarget:o}},E=({lastCallPageNumber:i,dataListRef:n})=>{const u=m(i),r=m({}),o=m(i),e=m(null),c=f(()=>{e.current!==null&&(window.clearTimeout(e.current),e.current=null)},[]),a=f(()=>{c(),e.current=window.setTimeout(()=>{u.current=null,e.current=null},1e3)},[c]);d(()=>()=>{c()},[c]);const s=f(t=>l=>{l&&(r.current[t]=l,u.current!==null&&t===u.current&&(l.scrollIntoView({behavior:"instant",block:"start"}),u.current=null))},[]);return{jumpingPageNumberRef:u,paginationScrollIntoViewTarget:r,pageNumberRef:o,setPaginationRef:s,handleReachTerminal:({isFirst:t,isLast:l,observer:g},p)=>{if(n.current.length===0||u.current!=null||!t&&!l)return;const h=t?Math.max(o.current-1,0):o.current+1;n.current[h]!=null&&(n.current[h]?.length||0)>0||(u.current=h,a(),p(h))},handleClickPageChange:(t,l)=>{const g=n.current[t];if(g!=null&&Array.isArray(g)&&g.length>0){r.current[t]?.scrollIntoView({behavior:"smooth",block:"start"});return}u.current=t,a(),l(t)}}};export{P as useListPagingForSentinel,C as usePaginationViewNumber,E as usePagingHandler};
@@ -1,126 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useSizes_exports = {};
20
- __export(useSizes_exports, {
21
- useFirstChildSize: () => useFirstChildSize,
22
- useSize: () => useSize
23
- });
24
- module.exports = __toCommonJS(useSizes_exports);
25
- var import_react = require("react");
26
- var import_rxjs = require("rxjs");
27
- const useSize = (sizeName) => {
28
- const ref = (0, import_react.useRef)(null);
29
- const [size, setSize] = (0, import_react.useState)(void 0);
30
- (0, import_react.useLayoutEffect)(() => {
31
- if (!ref.current) return;
32
- const handleResize = () => {
33
- if (ref.current) {
34
- const newSize = ref.current.getBoundingClientRect()[sizeName];
35
- setSize(newSize);
36
- }
37
- };
38
- handleResize();
39
- const resizeObserver = new ResizeObserver(() => {
40
- handleResize();
41
- });
42
- resizeObserver.observe(ref.current);
43
- window.addEventListener("resize", handleResize);
44
- return () => {
45
- resizeObserver.disconnect();
46
- window.removeEventListener("resize", handleResize);
47
- };
48
- }, [sizeName]);
49
- return { ref, size };
50
- };
51
- const useFirstChildSize = (sizeName) => {
52
- const ref = (0, import_react.useRef)(null);
53
- const [sizes, setSizes] = (0, import_react.useState)();
54
- (0, import_react.useEffect)(() => {
55
- if (!ref.current || !ref.current.children[0]) return;
56
- if (!sizes || sizes.length === 0) {
57
- setSizes([
58
- ref.current.getBoundingClientRect()[sizeName],
59
- ref.current.children[0].getBoundingClientRect()[sizeName]
60
- ]);
61
- }
62
- }, []);
63
- (0, import_react.useEffect)(() => {
64
- if (!ref.current || !ref.current.children[0]) return;
65
- const childrenChangeObserver = new MutationObserver(
66
- (mutationList, observer) => {
67
- mutationList.forEach((mutation) => {
68
- if (!ref.current || !sizes || !ref.current.children[0])
69
- return;
70
- const newSize = ref.current.getBoundingClientRect()[sizeName];
71
- setSizes([
72
- newSize,
73
- ref.current.children[0].getBoundingClientRect()[sizeName]
74
- ]);
75
- });
76
- }
77
- );
78
- childrenChangeObserver.observe(ref.current, {
79
- childList: true,
80
- subtree: true
81
- });
82
- let isFocus = false;
83
- const windowResizeSubscribe = (0, import_rxjs.fromEvent)(window, "resize").pipe(
84
- (0, import_rxjs.distinctUntilChanged)(),
85
- (0, import_rxjs.filter)(
86
- () => document.activeElement?.tagName !== "INPUT" && !isFocus
87
- )
88
- ).subscribe((ev) => {
89
- if (!ref.current || !ref.current.children[0]) return;
90
- setSizes([
91
- ref.current.getBoundingClientRect()[sizeName],
92
- ref.current.children[0].getBoundingClientRect()[sizeName]
93
- ]);
94
- });
95
- const documentFocusoutSubscribe = (0, import_rxjs.fromEvent)(
96
- document,
97
- "focusout"
98
- ).pipe(
99
- (0, import_rxjs.auditTime)(1e3),
100
- (0, import_rxjs.filter)((ev) => document.activeElement?.tagName !== "INPUT")
101
- ).subscribe({
102
- next: () => {
103
- if (isFocus) isFocus = false;
104
- }
105
- });
106
- const documentFocusinSubscribe = (0, import_rxjs.fromEvent)(
107
- document,
108
- "focusin"
109
- ).subscribe({
110
- next: (ev) => isFocus = ev.target.tagName === "INPUT"
111
- });
112
- return () => {
113
- windowResizeSubscribe.unsubscribe();
114
- documentFocusoutSubscribe.unsubscribe();
115
- documentFocusinSubscribe.unsubscribe();
116
- childrenChangeObserver.disconnect();
117
- };
118
- }, [sizeName, sizes]);
119
- return { ref, sizes };
120
- };
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- useFirstChildSize,
124
- useSize
125
- });
126
- //# sourceMappingURL=useSizes.cjs.map
1
+ "use strict";var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},h=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of R(e))!v.call(t,i)&&i!==n&&d(t,i,{get:()=>e[i],enumerable:!(r=m(e,i))||r.enumerable});return t};var E=t=>h(d({},"__esModule",{value:!0}),t);var D={};g(D,{useFirstChildSize:()=>O,useSize:()=>M});module.exports=E(D);var u=require("react"),c=require("rxjs");const M=(t,e)=>{const n=(0,u.useRef)(null),r=e??n,[i,s]=(0,u.useState)(void 0);return(0,u.useLayoutEffect)(()=>{if(!r.current)return;const o=()=>{if(r.current){const f=r.current.getBoundingClientRect()[t];s(f)}};o();const b=new ResizeObserver(()=>{o()});return b.observe(r.current),window.addEventListener("resize",o),()=>{b.disconnect(),window.removeEventListener("resize",o)}},[t]),{ref:r,size:i}},O=t=>{const e=(0,u.useRef)(null),[n,r]=(0,u.useState)();return(0,u.useEffect)(()=>{!e.current||!e.current.children[0]||(!n||n.length===0)&&r([e.current.getBoundingClientRect()[t],e.current.children[0].getBoundingClientRect()[t]])},[]),(0,u.useEffect)(()=>{if(!e.current||!e.current.children[0])return;const i=new MutationObserver((l,w)=>{l.forEach(y=>{if(!e.current||!n||!e.current.children[0])return;const a=e.current.getBoundingClientRect()[t];r([a,e.current.children[0].getBoundingClientRect()[t]])})});i.observe(e.current,{childList:!0,subtree:!0});let s=!1;const o=(0,c.fromEvent)(window,"resize").pipe((0,c.distinctUntilChanged)(),(0,c.filter)(()=>document.activeElement?.tagName!=="INPUT"&&!s)).subscribe(l=>{!e.current||!e.current.children[0]||r([e.current.getBoundingClientRect()[t],e.current.children[0].getBoundingClientRect()[t]])}),b=(0,c.fromEvent)(document,"focusout").pipe((0,c.auditTime)(1e3),(0,c.filter)(l=>document.activeElement?.tagName!=="INPUT")).subscribe({next:()=>{s&&(s=!1)}}),f=(0,c.fromEvent)(document,"focusin").subscribe({next:l=>s=l.target.tagName==="INPUT"});return()=>{o.unsubscribe(),b.unsubscribe(),f.unsubscribe(),i.disconnect()}},[t,n]),{ref:e,sizes:n}};0&&(module.exports={useFirstChildSize,useSize});
@@ -1,8 +1,11 @@
1
- export declare const useSize: (sizeName: "height" | "width") => {
2
- ref: import("react").RefObject<HTMLDivElement>;
1
+ import { MutableRefObject, RefObject } from "react";
2
+ type DivRef = MutableRefObject<HTMLDivElement | null> | RefObject<HTMLDivElement | null>;
3
+ export declare const useSize: (sizeName: "height" | "width", externalRef?: DivRef) => {
4
+ ref: MutableRefObject<HTMLDivElement | null>;
3
5
  size: number | undefined;
4
6
  };
5
7
  export declare const useFirstChildSize: (sizeName: string) => {
6
- ref: import("react").RefObject<HTMLDivElement>;
8
+ ref: RefObject<HTMLDivElement>;
7
9
  sizes: number[] | undefined;
8
10
  };
11
+ export {};
@@ -1,101 +1 @@
1
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
2
- import { auditTime, distinctUntilChanged, filter, fromEvent } from "rxjs";
3
- const useSize = (sizeName) => {
4
- const ref = useRef(null);
5
- const [size, setSize] = useState(void 0);
6
- useLayoutEffect(() => {
7
- if (!ref.current) return;
8
- const handleResize = () => {
9
- if (ref.current) {
10
- const newSize = ref.current.getBoundingClientRect()[sizeName];
11
- setSize(newSize);
12
- }
13
- };
14
- handleResize();
15
- const resizeObserver = new ResizeObserver(() => {
16
- handleResize();
17
- });
18
- resizeObserver.observe(ref.current);
19
- window.addEventListener("resize", handleResize);
20
- return () => {
21
- resizeObserver.disconnect();
22
- window.removeEventListener("resize", handleResize);
23
- };
24
- }, [sizeName]);
25
- return { ref, size };
26
- };
27
- const useFirstChildSize = (sizeName) => {
28
- const ref = useRef(null);
29
- const [sizes, setSizes] = useState();
30
- useEffect(() => {
31
- if (!ref.current || !ref.current.children[0]) return;
32
- if (!sizes || sizes.length === 0) {
33
- setSizes([
34
- ref.current.getBoundingClientRect()[sizeName],
35
- ref.current.children[0].getBoundingClientRect()[sizeName]
36
- ]);
37
- }
38
- }, []);
39
- useEffect(() => {
40
- if (!ref.current || !ref.current.children[0]) return;
41
- const childrenChangeObserver = new MutationObserver(
42
- (mutationList, observer) => {
43
- mutationList.forEach((mutation) => {
44
- if (!ref.current || !sizes || !ref.current.children[0])
45
- return;
46
- const newSize = ref.current.getBoundingClientRect()[sizeName];
47
- setSizes([
48
- newSize,
49
- ref.current.children[0].getBoundingClientRect()[sizeName]
50
- ]);
51
- });
52
- }
53
- );
54
- childrenChangeObserver.observe(ref.current, {
55
- childList: true,
56
- subtree: true
57
- });
58
- let isFocus = false;
59
- const windowResizeSubscribe = fromEvent(window, "resize").pipe(
60
- distinctUntilChanged(),
61
- filter(
62
- () => document.activeElement?.tagName !== "INPUT" && !isFocus
63
- )
64
- ).subscribe((ev) => {
65
- if (!ref.current || !ref.current.children[0]) return;
66
- setSizes([
67
- ref.current.getBoundingClientRect()[sizeName],
68
- ref.current.children[0].getBoundingClientRect()[sizeName]
69
- ]);
70
- });
71
- const documentFocusoutSubscribe = fromEvent(
72
- document,
73
- "focusout"
74
- ).pipe(
75
- auditTime(1e3),
76
- filter((ev) => document.activeElement?.tagName !== "INPUT")
77
- ).subscribe({
78
- next: () => {
79
- if (isFocus) isFocus = false;
80
- }
81
- });
82
- const documentFocusinSubscribe = fromEvent(
83
- document,
84
- "focusin"
85
- ).subscribe({
86
- next: (ev) => isFocus = ev.target.tagName === "INPUT"
87
- });
88
- return () => {
89
- windowResizeSubscribe.unsubscribe();
90
- documentFocusoutSubscribe.unsubscribe();
91
- documentFocusinSubscribe.unsubscribe();
92
- childrenChangeObserver.disconnect();
93
- };
94
- }, [sizeName, sizes]);
95
- return { ref, sizes };
96
- };
97
- export {
98
- useFirstChildSize,
99
- useSize
100
- };
101
- //# sourceMappingURL=useSizes.js.map
1
+ import{useEffect as f,useLayoutEffect as v,useRef as d,useState as a}from"react";import{auditTime as g,distinctUntilChanged as h,filter as m,fromEvent as b}from"rxjs";const C=(t,e)=>{const r=d(null),n=e??r,[s,c]=a(void 0);return v(()=>{if(!n.current)return;const u=()=>{if(n.current){const l=n.current.getBoundingClientRect()[t];c(l)}};u();const o=new ResizeObserver(()=>{u()});return o.observe(n.current),window.addEventListener("resize",u),()=>{o.disconnect(),window.removeEventListener("resize",u)}},[t]),{ref:n,size:s}},S=t=>{const e=d(null),[r,n]=a();return f(()=>{!e.current||!e.current.children[0]||(!r||r.length===0)&&n([e.current.getBoundingClientRect()[t],e.current.children[0].getBoundingClientRect()[t]])},[]),f(()=>{if(!e.current||!e.current.children[0])return;const s=new MutationObserver((i,E)=>{i.forEach(M=>{if(!e.current||!r||!e.current.children[0])return;const R=e.current.getBoundingClientRect()[t];n([R,e.current.children[0].getBoundingClientRect()[t]])})});s.observe(e.current,{childList:!0,subtree:!0});let c=!1;const u=b(window,"resize").pipe(h(),m(()=>document.activeElement?.tagName!=="INPUT"&&!c)).subscribe(i=>{!e.current||!e.current.children[0]||n([e.current.getBoundingClientRect()[t],e.current.children[0].getBoundingClientRect()[t]])}),o=b(document,"focusout").pipe(g(1e3),m(i=>document.activeElement?.tagName!=="INPUT")).subscribe({next:()=>{c&&(c=!1)}}),l=b(document,"focusin").subscribe({next:i=>c=i.target.tagName==="INPUT"});return()=>{u.unsubscribe(),o.unsubscribe(),l.unsubscribe(),s.disconnect()}},[t,r]),{ref:e,sizes:r}};export{S as useFirstChildSize,C as useSize};