@byeolnaerim/flex-layout 0.0.4 → 0.0.6

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 (82) hide show
  1. package/README.en.md +314 -0
  2. package/README.ko.md +312 -0
  3. package/README.md +314 -0
  4. package/dist/components.cjs +651 -657
  5. package/dist/components.cjs.map +1 -1
  6. package/dist/components.js +3027 -5
  7. package/dist/components.js.map +1 -1
  8. package/dist/flex-layout/components/FlexLayout.d.ts +2 -0
  9. package/dist/flex-layout/components/FlexLayoutContainer.d.ts +2 -0
  10. package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +2 -0
  11. package/dist/flex-layout/components/FlexLayoutSplitScreen.d.ts +11 -0
  12. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +27 -0
  13. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.d.ts +5 -0
  14. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.d.ts +8 -0
  15. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.d.ts +3 -0
  16. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.d.ts +9 -0
  17. package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +29 -0
  18. package/dist/flex-layout/components/index.d.ts +7 -0
  19. package/dist/flex-layout/hooks/index.d.ts +2 -0
  20. package/dist/{useDrag-DR01Ob3s.d.ts → flex-layout/hooks/useDrag.d.ts} +19 -22
  21. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.d.ts +28 -0
  22. package/dist/{hooks.d.ts → flex-layout/hooks/useListPaging.d.ts} +6 -12
  23. package/dist/flex-layout/hooks/useSizes.d.ts +8 -0
  24. package/dist/flex-layout/index.d.ts +5 -0
  25. package/dist/flex-layout/providers/FlexLayoutContext.d.ts +8 -0
  26. package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +51 -0
  27. package/dist/flex-layout/providers/index.d.ts +1 -0
  28. package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +62 -0
  29. package/dist/flex-layout/store/index.d.ts +1 -0
  30. package/dist/flex-layout/styles/FlexLayout.module.css +416 -0
  31. package/dist/flex-layout/styles/listScroll.module.css +85 -0
  32. package/dist/flex-layout/styles/shake.module.css +41 -0
  33. package/dist/flex-layout/types/FlexDirectionTypes.d.ts +6 -0
  34. package/dist/flex-layout/types/FlexLayoutTypes.d.ts +53 -0
  35. package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +26 -0
  36. package/dist/flex-layout/utils/index.d.ts +1 -0
  37. package/dist/hooks.cjs.map +1 -1
  38. package/dist/hooks.js +407 -3
  39. package/dist/hooks.js.map +1 -1
  40. package/dist/index.cjs +681 -687
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +1 -10
  43. package/dist/index.js +3396 -9
  44. package/dist/index.js.map +1 -1
  45. package/dist/providers.js +400 -4
  46. package/dist/providers.js.map +1 -1
  47. package/dist/store.js +180 -2
  48. package/dist/store.js.map +1 -1
  49. package/dist/utils.js +195 -2
  50. package/dist/utils.js.map +1 -1
  51. package/package.json +18 -45
  52. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.cts +0 -31
  53. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.ts +0 -31
  54. package/dist/chunk-3EDKZTM3.js +0 -3
  55. package/dist/chunk-3EDKZTM3.js.map +0 -1
  56. package/dist/chunk-5HWEFTNQ.js +0 -176
  57. package/dist/chunk-5HWEFTNQ.js.map +0 -1
  58. package/dist/chunk-7J5JUVZK.js +0 -3
  59. package/dist/chunk-7J5JUVZK.js.map +0 -1
  60. package/dist/chunk-CFQQ6ZDC.js +0 -182
  61. package/dist/chunk-CFQQ6ZDC.js.map +0 -1
  62. package/dist/chunk-JM3CZ5DU.js +0 -238
  63. package/dist/chunk-JM3CZ5DU.js.map +0 -1
  64. package/dist/chunk-PMTZFSP4.js +0 -219
  65. package/dist/chunk-PMTZFSP4.js.map +0 -1
  66. package/dist/chunk-UYI4Z27V.js +0 -2432
  67. package/dist/chunk-UYI4Z27V.js.map +0 -1
  68. package/dist/chunk-W4CNFJTK.js +0 -197
  69. package/dist/chunk-W4CNFJTK.js.map +0 -1
  70. package/dist/chunk-YIHCWXKY.js +0 -3
  71. package/dist/chunk-YIHCWXKY.js.map +0 -1
  72. package/dist/components.d.cts +0 -122
  73. package/dist/components.d.ts +0 -122
  74. package/dist/hooks.d.cts +0 -37
  75. package/dist/index.d.cts +0 -10
  76. package/dist/providers.d.cts +0 -54
  77. package/dist/providers.d.ts +0 -54
  78. package/dist/store.d.cts +0 -67
  79. package/dist/store.d.ts +0 -67
  80. package/dist/useDrag-CYQnhUFk.d.cts +0 -108
  81. package/dist/utils.d.cts +0 -28
  82. package/dist/utils.d.ts +0 -28
package/dist/store.js CHANGED
@@ -1,4 +1,182 @@
1
- import './chunk-YIHCWXKY.js';
2
- export { flexContainerStore, flexResizePanelStore, getContainerRef, getCurrentSplitScreenComponents, getLayoutInfos, getResizePanelRef, getScrollPosition, getSplitScreen, layoutSplitScreenStore, removeScrollPosition, removeSplitScreenChild, resetRootSplitScreen, scrollPositions, setContainerRef, setResizePanelRef, setScrollPosition, setSplitScreen } from './chunk-CFQQ6ZDC.js';
1
+ import equal from 'fast-deep-equal';
2
+ import { BehaviorSubject, combineLatest } from 'rxjs';
3
+ import { filter, map, distinctUntilChanged } from 'rxjs/operators';
4
+
5
+ // src/flex-layout/store/FlexLayoutContainerStore.ts
6
+ function updateScrollStore(subject, newValue) {
7
+ const currentValue = subject.getValue();
8
+ if (!equal(currentValue, newValue)) {
9
+ subject.next(newValue);
10
+ }
11
+ }
12
+ function updateRefStore(store, newState) {
13
+ const prevState = store.getValue();
14
+ if (!equal(prevState, newState)) {
15
+ store.next(newState);
16
+ }
17
+ }
18
+ function updateSplitScreenStore(newValue) {
19
+ const prevValue = layoutSplitScreenStore.getValue();
20
+ if (!equal(prevValue, newValue)) {
21
+ layoutSplitScreenStore.next(newValue);
22
+ }
23
+ }
24
+ var scrollPositions = {};
25
+ var scrollPositionsSubject = new BehaviorSubject(scrollPositions);
26
+ var setScrollPosition = (layoutName, position) => {
27
+ const current = scrollPositionsSubject.getValue();
28
+ const prevPos = current[layoutName];
29
+ if (prevPos && prevPos.x === position.x && prevPos.y === position.y) {
30
+ return;
31
+ }
32
+ const newPositions = {
33
+ ...current,
34
+ [layoutName]: position
35
+ };
36
+ updateScrollStore(scrollPositionsSubject, newPositions);
37
+ };
38
+ var getScrollPosition = (layoutName) => {
39
+ return scrollPositionsSubject.pipe(
40
+ // 해당 layoutName이 정의되지 않았을 때는 제외
41
+ filter((e) => e[layoutName] !== void 0),
42
+ map((positions) => positions[layoutName]),
43
+ distinctUntilChanged(
44
+ (prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y
45
+ )
46
+ );
47
+ };
48
+ var removeScrollPosition = (layoutName) => {
49
+ const current = scrollPositionsSubject.getValue();
50
+ delete current[layoutName];
51
+ const newPositions = { ...current };
52
+ updateScrollStore(scrollPositionsSubject, newPositions);
53
+ };
54
+ var layoutSplitScreenStore = new BehaviorSubject({});
55
+ var setSplitScreen = (rootName, layoutName, newComponents) => {
56
+ const current = layoutSplitScreenStore.getValue();
57
+ const updatedLayout = { ...current[rootName] || {} };
58
+ updatedLayout[layoutName] = newComponents;
59
+ const newStoreValue = {
60
+ ...current,
61
+ [rootName]: updatedLayout
62
+ };
63
+ updateSplitScreenStore(newStoreValue);
64
+ };
65
+ var resetRootSplitScreen = (rootName) => {
66
+ const current = layoutSplitScreenStore.getValue();
67
+ const newStoreValue = {
68
+ ...current,
69
+ [rootName]: {}
70
+ };
71
+ updateSplitScreenStore(newStoreValue);
72
+ };
73
+ var removeSplitScreenChild = (rootName, layoutName) => {
74
+ const current = layoutSplitScreenStore.getValue();
75
+ if (!current[rootName]) return;
76
+ const updatedLayout = { ...current[rootName] };
77
+ delete updatedLayout[layoutName];
78
+ const newStoreValue = {
79
+ ...current,
80
+ [rootName]: updatedLayout
81
+ };
82
+ updateSplitScreenStore(newStoreValue);
83
+ };
84
+ var getCurrentSplitScreenComponents = (rootName, layoutName) => {
85
+ const current = layoutSplitScreenStore.getValue();
86
+ if (!current[rootName]) return;
87
+ return current[rootName][layoutName];
88
+ };
89
+ var getSplitScreen = (rootName, layoutName) => {
90
+ return layoutSplitScreenStore.pipe(
91
+ map((splitScreen) => splitScreen[rootName][layoutName]),
92
+ distinctUntilChanged((prev, curr) => {
93
+ const filterChildren = (obj) => {
94
+ const { children, component, targetComponent, x, y, ...rest } = obj || {};
95
+ return rest;
96
+ };
97
+ return equal(filterChildren(prev), filterChildren(curr));
98
+ })
99
+ );
100
+ };
101
+ var flexContainerStore = new BehaviorSubject({});
102
+ var flexResizePanelStore = new BehaviorSubject({});
103
+ var setContainerRef = (layoutName, containerName, ref) => {
104
+ const currentRefs = flexContainerStore.getValue();
105
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
106
+ if (ref === null) {
107
+ delete updatedLayoutRefs[containerName];
108
+ } else {
109
+ updatedLayoutRefs[containerName] = ref;
110
+ }
111
+ const newRefs = {
112
+ ...currentRefs,
113
+ [layoutName]: updatedLayoutRefs
114
+ };
115
+ updateRefStore(flexContainerStore, newRefs);
116
+ };
117
+ var setResizePanelRef = (layoutName, containerName, ref) => {
118
+ const currentRefs = flexResizePanelStore.getValue();
119
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
120
+ if (ref === null) {
121
+ delete updatedLayoutRefs[containerName];
122
+ } else {
123
+ updatedLayoutRefs[containerName] = ref;
124
+ }
125
+ const newRefs = {
126
+ ...currentRefs,
127
+ [layoutName]: updatedLayoutRefs
128
+ };
129
+ updateRefStore(flexResizePanelStore, newRefs);
130
+ };
131
+ var getLayoutInfos = (layoutName) => {
132
+ return combineLatest([flexContainerStore, flexResizePanelStore]).pipe(
133
+ map(([containerRefs, resizePanelRefs]) => {
134
+ const containerData = containerRefs[layoutName] || {};
135
+ const resizePanelData = resizePanelRefs[layoutName] || {};
136
+ return {
137
+ container: containerData,
138
+ resizePanel: resizePanelData
139
+ };
140
+ }),
141
+ filter((result) => result.container !== null)
142
+ // 빈 객체 제외
143
+ );
144
+ };
145
+ var getContainerRef = ({
146
+ containerName,
147
+ layoutName
148
+ }) => {
149
+ return flexContainerStore.pipe(
150
+ map((refs) => {
151
+ if (layoutName) {
152
+ return refs[layoutName]?.[containerName] || null;
153
+ } else {
154
+ return Object.entries(refs).find(
155
+ ([key, value]) => refs[key][containerName]
156
+ )?.[1][containerName];
157
+ }
158
+ }),
159
+ filter((ref) => ref !== null)
160
+ );
161
+ };
162
+ var getResizePanelRef = ({
163
+ containerName,
164
+ layoutName
165
+ }) => {
166
+ return flexResizePanelStore.pipe(
167
+ map((refs) => {
168
+ if (layoutName) {
169
+ return refs[layoutName]?.[containerName] || null;
170
+ } else {
171
+ return Object.entries(refs).find(
172
+ ([key, value]) => refs[key][containerName]
173
+ )?.[1][containerName];
174
+ }
175
+ }),
176
+ filter((ref) => ref !== null)
177
+ );
178
+ };
179
+
180
+ export { flexContainerStore, flexResizePanelStore, getContainerRef, getCurrentSplitScreenComponents, getLayoutInfos, getResizePanelRef, getScrollPosition, getSplitScreen, layoutSplitScreenStore, removeScrollPosition, removeSplitScreenChild, resetRootSplitScreen, scrollPositions, setContainerRef, setResizePanelRef, setScrollPosition, setSplitScreen };
3
181
  //# sourceMappingURL=store.js.map
4
182
  //# sourceMappingURL=store.js.map
package/dist/store.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"store.js"}
1
+ {"version":3,"sources":["../src/flex-layout/store/FlexLayoutContainerStore.ts"],"names":[],"mappings":";;;;;AAUA,SAAS,iBAAA,CAAqB,SAA6B,QAAA,EAAa;AACvE,EAAA,MAAM,YAAA,GAAe,QAAQ,QAAA,EAAS;AAEtC,EAAA,IAAI,CAAC,KAAA,CAAM,YAAA,EAAc,QAAQ,CAAA,EAAG;AACnC,IAAA,OAAA,CAAQ,KA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1C,GAAI,CAAC,CAAA,CAAE,aAAa,CAAA;AAAA,MACrB;AAAA,IAUD,CAAC,CAAA;AAAA,IACD,MAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,KAAQ,IAAI;AAAA,GAC7B;AACD","file":"store.js","sourcesContent":["\"use client\";\r\nimport equal from \"fast-deep-equal\";\r\nimport { RefObject } from \"react\";\r\nimport { BehaviorSubject, combineLatest } from \"rxjs\";\r\nimport { distinctUntilChanged, filter, map } from \"rxjs/operators\";\r\nimport { DropTargetComponent } from \"../hooks/useDrag\";\r\n\r\n/**\r\n * 이전 값과 새 값이 동일하지 않을 때만 store를 업데이트하는 유틸 함수\r\n */\r\nfunction updateScrollStore<T>(subject: BehaviorSubject<T>, newValue: T) {\r\n\tconst currentValue = subject.getValue();\r\n\t// deep 비교를 통해 실제 변경이 있는 경우만 next\r\n\tif (!equal(currentValue, newValue)) {\r\n\t\tsubject.next(newValue);\r\n\t}\r\n}\r\n// 동일한지 확인 후 업데이트하는 유틸\r\nfunction updateRefStore(store: BehaviorSubject<RefStore>, newState: RefStore) {\r\n\tconst prevState = store.getValue();\r\n\tif (!equal(prevState, newState)) {\r\n\t\tstore.next(newState);\r\n\t}\r\n}\r\n\r\nfunction updateSplitScreenStore(newValue: LayoutSplitScreenState) {\r\n\tconst prevValue = layoutSplitScreenStore.getValue();\r\n\t// deep-equal 로 비교\r\n\tif (!equal(prevValue, newValue)) {\r\n\t\tlayoutSplitScreenStore.next(newValue);\r\n\t}\r\n}\r\n\r\n// 구독 시 이전 상태들을 축적하여 관리\r\n// const stateWithHistory$ = flexContainerStore.pipe(\r\n// scan((acc, newState) => [...acc, newState], [] as RefStore[])\r\n// );\r\n\r\nexport interface ScrollPosition {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport const scrollPositions: Record<string, ScrollPosition> = {};\r\n\r\nconst scrollPositionsSubject = new BehaviorSubject<\r\n\tRecord<string, ScrollPosition>\r\n>(scrollPositions);\r\n\r\n/**\r\n * 스크롤 위치 업데이트 함수\r\n *\r\n * 기존: 항상 store.next()가 호출됨 → 바뀌지 않았다면 건너뛰도록 변경\r\n */\r\nexport const setScrollPosition = (\r\n\tlayoutName: string,\r\n\tposition: ScrollPosition,\r\n) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst prevPos = current[layoutName];\r\n\r\n\t// x, y 모두 동일하면 업데이트할 필요가 없으므로 조기 반환\r\n\tif (prevPos && prevPos.x === position.x && prevPos.y === position.y) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// 변경사항이 있으면 새 객체를 만들어 넘김\r\n\tconst newPositions = {\r\n\t\t...current,\r\n\t\t[layoutName]: position,\r\n\t};\r\n\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\n/**\r\n * 스크롤 위치 구독\r\n */\r\nexport const getScrollPosition = (layoutName: string) => {\r\n\treturn scrollPositionsSubject.pipe(\r\n\t\t// 해당 layoutName이 정의되지 않았을 때는 제외\r\n\t\tfilter((e) => e[layoutName] !== undefined),\r\n\t\tmap((positions) => positions[layoutName]),\r\n\t\tdistinctUntilChanged(\r\n\t\t\t(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y,\r\n\t\t),\r\n\t);\r\n};\r\n\r\nexport const removeScrollPosition = (layoutName: string) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tdelete current[layoutName];\r\n\r\n\t// 꼭 삭제 후에도 이전 상태와 달라졌는지 확인\r\n\tconst newPositions = { ...current };\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\nexport type SplitScreenComponents = {\r\n\tafterDropTargetComponent: DropTargetComponent[];\r\n\tbeforeDropTargetComponent: DropTargetComponent[];\r\n\tcenterDropTargetComponent: DropTargetComponent[];\r\n\tdirection: \"row\" | \"column\";\r\n};\r\n\r\nexport type LayoutSplitScreenState = Record<\r\n\tstring,\r\n\tRecord<string, SplitScreenComponents>\r\n>;\r\n\r\nexport const layoutSplitScreenStore =\r\n\tnew BehaviorSubject<LayoutSplitScreenState>({});\r\n\r\nexport const setSplitScreen = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n\tnewComponents: SplitScreenComponents,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tconst updatedLayout = { ...(current[rootName] || {}) };\r\n\tupdatedLayout[layoutName] = newComponents;\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const resetRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\t// rootName 아래만 초기화\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: {},\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const removeSplitScreenChild = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\r\n\tconst updatedLayout = { ...current[rootName] };\r\n\tdelete updatedLayout[layoutName];\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const getCurrentSplitScreenComponents = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\treturn current[rootName][layoutName];\r\n};\r\n\r\nexport const getSplitScreen = (rootName: string, layoutName: string) => {\r\n\treturn layoutSplitScreenStore.pipe(\r\n\t\tmap((splitScreen) => splitScreen[rootName][layoutName]),\r\n\t\tdistinctUntilChanged((prev, curr) => {\r\n\t\t\t// 이전 상태와 현재 상태를 비교하여 동일하면 필터링\r\n\t\t\tconst filterChildren = (obj: any) => {\r\n\t\t\t\t// 객체 복사 후 children 속성 제거\r\n\t\t\t\tconst { children, component, targetComponent, x, y, ...rest } =\r\n\t\t\t\t\tobj || {};\r\n\t\t\t\treturn rest;\r\n\t\t\t};\r\n\t\t\treturn equal(filterChildren(prev), filterChildren(curr));\r\n\t\t}),\r\n\t);\r\n};\r\n\r\n// 중첩된 객체 구조로 ref를 관리하는 타입\r\ntype RefStore = {\r\n\t[layoutName: string]: {\r\n\t\t[containerName: string]: RefObject<HTMLElement | null>;\r\n\t};\r\n};\r\n\r\n// 초기값으로 빈 객체를 설정한 BehaviorSubject 생성\r\nexport const flexContainerStore = new BehaviorSubject<RefStore>({});\r\n\r\nexport const flexResizePanelStore = new BehaviorSubject<RefStore>({});\r\n/**\r\n * ref를 업데이트하는 함수\r\n * - 기존: 무조건 next() → 새/이전 상태 비교 후 다를 경우에만 next()\r\n */\r\nexport const setContainerRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: React.RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexContainerStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexContainerStore, newRefs);\r\n};\r\n\r\nexport const setResizePanelRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: React.RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexResizePanelStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexResizePanelStore, newRefs);\r\n};\r\n\r\nexport const getLayoutInfos = (layoutName: string) => {\r\n\treturn combineLatest([flexContainerStore, flexResizePanelStore]).pipe(\r\n\t\tmap(([containerRefs, resizePanelRefs]) => {\r\n\t\t\t// 두 Store에서 layoutName에 해당하는 값을 병합\r\n\t\t\tconst containerData = containerRefs[layoutName] || {};\r\n\t\t\tconst resizePanelData = resizePanelRefs[layoutName] || {};\r\n\r\n\t\t\t// container와 resizePanel 데이터 합치기\r\n\t\t\treturn {\r\n\t\t\t\tcontainer: containerData,\r\n\t\t\t\tresizePanel: resizePanelData,\r\n\t\t\t};\r\n\t\t}),\r\n\t\tfilter((result) => result.container !== null), // 빈 객체 제외\r\n\t);\r\n};\r\n\r\n// 특정 containerName의 ref를 구독하는 함수\r\n// layoutName이 지정되지 않으면 전체 layout에서 해당하는 containerName의 ref를 찾음\r\nexport const getContainerRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexContainerStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n\r\nexport const getResizePanelRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexResizePanelStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n"]}
package/dist/utils.js CHANGED
@@ -1,4 +1,197 @@
1
- import './chunk-7J5JUVZK.js';
2
- export { closeFlex, findNotCloseFlexContent, getClientXy, getGrow, isDocumentOut, isOverMove, mathGrow, mathWeight, openFlex, remain, resize } from './chunk-W4CNFJTK.js';
1
+ // src/flex-layout/utils/FlexLayoutUtils.ts
2
+ function isDocumentOut({ x, y }) {
3
+ if (typeof window == "undefined") return;
4
+ const { innerWidth, innerHeight, scrollX, scrollY } = window;
5
+ return x < 0 || y < 0 || x > innerWidth + scrollX || y > innerHeight + scrollY;
6
+ }
7
+ var lastTouchEvent;
8
+ function getClientXy(event) {
9
+ let clientX;
10
+ let clientY;
11
+ if (window.MouseEvent && event instanceof window.MouseEvent) {
12
+ clientX = event.clientX;
13
+ clientY = event.clientY;
14
+ } else if (window.TouchEvent && event instanceof window.TouchEvent) {
15
+ const _event = event.touches.length == 0 ? lastTouchEvent : event;
16
+ clientX = _event.touches[0].clientX;
17
+ clientY = _event.touches[0].clientY;
18
+ lastTouchEvent = event;
19
+ } else {
20
+ return;
21
+ }
22
+ return { clientX, clientY };
23
+ }
24
+ function isOverMove(elementSize, elementMinSize) {
25
+ return Math.floor(elementSize) <= 0 || (isNaN(elementMinSize) ? false : elementMinSize >= Math.floor(elementSize));
26
+ }
27
+ function findNotCloseFlexContent(target, direction) {
28
+ if (!target) return target;
29
+ let _target = target;
30
+ const isCloseCheck = () => {
31
+ let grow = parseFloat(window.getComputedStyle(_target).flex.split(" ")[0]) || 0;
32
+ if (grow == 0) {
33
+ return true;
34
+ } else {
35
+ return false;
36
+ }
37
+ };
38
+ while (isCloseCheck()) {
39
+ let nextTarget = _target[direction]?.[direction];
40
+ _target = nextTarget;
41
+ if (!_target) {
42
+ break;
43
+ }
44
+ }
45
+ return _target;
46
+ }
47
+ function remain(flexContainerList) {
48
+ return new Promise((resolve) => {
49
+ let notGrowList = [];
50
+ let totalGrow = flexContainerList.reduce((t, e, i) => {
51
+ if (e.hasAttribute("data-grow") == false) {
52
+ notGrowList.push(e);
53
+ return t;
54
+ }
55
+ let grow = parseFloat(e.dataset.grow || "");
56
+ e.style.flex = `${grow} 1 0%`;
57
+ t -= grow;
58
+ return t;
59
+ }, flexContainerList.length);
60
+ if (notGrowList.length != 0) {
61
+ resize(notGrowList, totalGrow);
62
+ }
63
+ resolve(flexContainerList);
64
+ });
65
+ }
66
+ function resize(list, totalGrow) {
67
+ return new Promise((resolve) => {
68
+ let resizeWeight = totalGrow / list.length;
69
+ list.forEach((e) => {
70
+ e.dataset.grow = resizeWeight.toString();
71
+ e.style.flex = `${resizeWeight} 1 0%`;
72
+ });
73
+ resolve(resizeWeight);
74
+ });
75
+ }
76
+ function mathWeight(totalCount, totalGrow) {
77
+ return 1 + (totalGrow - totalCount) / totalCount;
78
+ }
79
+ function mathGrow(childSize, parentSize, containerCount) {
80
+ return containerCount * (childSize / parentSize);
81
+ }
82
+ function getGrow(growTarget) {
83
+ const target = growTarget instanceof Element ? growTarget : growTarget;
84
+ return parseFloat(target.style.flex.split(" ")[0]) || parseFloat(target.dataset.grow || "");
85
+ }
86
+ function closeFlex(resizeTarget, containers, {
87
+ isResize = false,
88
+ isDsiabledResizePanel = false,
89
+ sizeName
90
+ }) {
91
+ return new Promise((resolve) => {
92
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (isDsiabledResizePanel) {
93
+ resizeTarget.dataset.is_resize_panel = "false";
94
+ }
95
+ resizeTarget.dataset.prev_grow = getGrow(resizeTarget).toString();
96
+ let notCloseList = containers.filter(
97
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
98
+ );
99
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
100
+ notCloseAndOpenTargetList.forEach((e) => {
101
+ e.style.transition = "flex 0.5s";
102
+ e.ontransitionend = (event) => {
103
+ if (event.propertyName != "flex-grow") {
104
+ return;
105
+ }
106
+ notCloseAndOpenTargetList.forEach(
107
+ (e2) => e2.style.transition = ""
108
+ );
109
+ e.ontransitionend = () => {
110
+ };
111
+ };
112
+ if (e == resizeTarget) {
113
+ e.dataset.grow = "0";
114
+ e.style.flex = `0 1 0%`;
115
+ return;
116
+ }
117
+ if (isResize) {
118
+ return;
119
+ }
120
+ let percent = getGrow(e) / containers.length;
121
+ if (notCloseList.length == 1) {
122
+ e.dataset.grow = containers.length.toString();
123
+ e.style.flex = `${containers.length} 1 0%`;
124
+ return;
125
+ }
126
+ e.dataset.grow = (containers.length * percent).toString();
127
+ e.style.flex = `${containers.length * percent} 1 0%`;
128
+ });
129
+ if (isResize) {
130
+ resize(notCloseList, containers.length);
131
+ }
132
+ resolve(resizeTarget);
133
+ });
134
+ }
135
+ function openFlex(resizeTarget, containers, {
136
+ isPrevSizeOpen = false,
137
+ isResize = false,
138
+ openGrowImportant = 0,
139
+ sizeName
140
+ }) {
141
+ return new Promise((resolve) => {
142
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (resizeTarget.hasAttribute("data-is_resize_panel") && resizeTarget.dataset.is_resize_panel == "false") {
143
+ resizeTarget.dataset.is_resize_panel = "true";
144
+ }
145
+ let notCloseList = containers.filter(
146
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
147
+ );
148
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
149
+ let openTargetGrow = 1;
150
+ const sizeStyleName = "client" + sizeName.charAt(0).toUpperCase() + sizeName.substring(1);
151
+ const parentSize = sizeName && resizeTarget.parentElement && resizeTarget.parentElement[sizeStyleName] || 0;
152
+ if (isPrevSizeOpen && resizeTarget.hasAttribute("data-prev_grow")) {
153
+ openTargetGrow = parseFloat(resizeTarget.dataset.prev_grow || "1") || 1;
154
+ } else if (parentSize && parentSize !== 0) {
155
+ openTargetGrow = parentSize / notCloseList.length / (parentSize - 1) * containers.length;
156
+ } else {
157
+ openTargetGrow = 1;
158
+ }
159
+ if (openGrowImportant) {
160
+ openTargetGrow = openGrowImportant;
161
+ }
162
+ openTargetGrow = openTargetGrow === Infinity ? 1 : openTargetGrow;
163
+ notCloseAndOpenTargetList.forEach((e) => {
164
+ e.style.transition = "flex 0.5s";
165
+ e.ontransitionend = (event) => {
166
+ if (event.propertyName != "flex-grow") {
167
+ return;
168
+ }
169
+ notCloseAndOpenTargetList.forEach(
170
+ (e2) => e2.style.transition = ""
171
+ );
172
+ e.ontransitionend = () => {
173
+ };
174
+ };
175
+ if (e == resizeTarget) {
176
+ resizeTarget.dataset.grow = openTargetGrow.toString();
177
+ resizeTarget.style.flex = `${openTargetGrow} 1 0%`;
178
+ return;
179
+ }
180
+ if (isResize) {
181
+ return;
182
+ }
183
+ let grow = parentSize / notCloseList.length / (parentSize - 1) * (containers.length - openTargetGrow);
184
+ grow = grow === Infinity ? 1 : grow;
185
+ e.dataset.grow = grow.toString();
186
+ e.style.flex = `${grow} 1 0%`;
187
+ });
188
+ if (isResize) {
189
+ resize(notCloseAndOpenTargetList, containers.length);
190
+ }
191
+ resolve(openTargetGrow);
192
+ });
193
+ }
194
+
195
+ export { closeFlex, findNotCloseFlexContent, getClientXy, getGrow, isDocumentOut, isOverMove, mathGrow, mathWeight, openFlex, remain, resize };
3
196
  //# sourceMappingURL=utils.js.map
4
197
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
1
+ {"version":3,"sources":["../src/flex-layout/utils/FlexLayoutUtils.ts"],"names":["e"],"mappings":";AAAO,SAAS,aAAA,CAAc,EAAE,CAAA,EAAG,CAAA,EAAE,EAA6B;AAC9D,EAAA,IAAI,OAAO,UAAU,WAAA,EAAa;AAClC,EAAA,MAAM,EAAE,UAAA,EAAY,WAAA,EAAa,OAAA,EAAS,SAAQ,GAAI,MAAA;AAEtD,EAAA,OACI,CAAA,GAAI,KAAK,CAAA,GAAI,CAAA,IAAK,IAAI,UAAA,GAAa,OAAA,IAAW,IAAI,WAAA,GAAc,OAAA;AAExE;AAEA,IAAI,cAAA;AACG,SAAS,YAAY,KAAA,EAAc;AACtC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,MAAA,CAAO,UAAA,IAAc,KAAA,YAAiB,MAAA,CAAO,UAAA,EAAY;AACzD,IAAA,OAAA,GAAU,KAAA,CAAM,OAAA;AAChB,IAAA,OAAA,GAAU,KAAA,CAAM,OAAA;AAAA,EACpB,CAAA,MAAA,IAAW,MAAA,CAAO,UAAA,IAAc,KAAA,YAAiB,OAAO,UAAA,EAAY;AAChE,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,OAAA,CAAQ,MAAA,IAAU,IAAI,cAAA,GAAiB,KAAA;AAC5D,IAAA,OAAA,GAAU,MAAA,CAAQ,OAAA,CAAQ,CAAC,CAAA,CAAE,OAAA;AAC7B,IAAA,OAAA,GAAU,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A;AAAA,IACvD;AAEA,IAAA,OAAA,CAAQ,cAAc,CAAA;AAAA,EAC1B,CAAC,CAAA;AACL","file":"utils.js","sourcesContent":["export function isDocumentOut({ x, y }: { x: number; y: number }) {\r\n if (typeof window == 'undefined') return;\r\n const { innerWidth, innerHeight, scrollX, scrollY } = window;\r\n\r\n return (\r\n x < 0 || y < 0 || x > innerWidth + scrollX || y > innerHeight + scrollY\r\n );\r\n}\r\n\r\nlet lastTouchEvent: globalThis.TouchEvent;\r\nexport function getClientXy(event: Event) {\r\n let clientX: number;\r\n let clientY: number;\r\n if (window.MouseEvent && event instanceof window.MouseEvent) {\r\n clientX = event.clientX;\r\n clientY = event.clientY;\r\n } else if (window.TouchEvent && event instanceof window.TouchEvent) {\r\n const _event = event.touches.length == 0 ? lastTouchEvent : event;\r\n clientX = _event!.touches[0].clientX;\r\n clientY = _event!.touches[0].clientY;\r\n lastTouchEvent = event;\r\n } else {\r\n return; // 해당 이벤트 타입이 MouseEvent나 TouchEvent가 아니라면 무시\r\n }\r\n return { clientX, clientY };\r\n}\r\n\r\nexport function isOverMove(elementSize: number, elementMinSize: number) {\r\n return (\r\n Math.floor(elementSize) <= 0 ||\r\n (isNaN(elementMinSize)\r\n ? false\r\n : elementMinSize >= Math.floor(elementSize))\r\n );\r\n}\r\n\r\nexport function findNotCloseFlexContent(\r\n target: HTMLElement | Element | null,\r\n direction: 'previousElementSibling' | 'nextElementSibling'\r\n) {\r\n if (!target) return target;\r\n let _target = target as HTMLElement;\r\n const isCloseCheck = () => {\r\n let grow =\r\n parseFloat(window.getComputedStyle(_target).flex.split(' ')[0]) ||\r\n 0;\r\n if (grow == 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n };\r\n while (isCloseCheck()) {\r\n let nextTarget = _target[direction]?.[direction];\r\n _target = nextTarget as HTMLElement;\r\n if (!_target) {\r\n break;\r\n }\r\n }\r\n return _target as HTMLElement | HTMLDivElement | null;\r\n}\r\n\r\nexport function remain(flexContainerList: Array<HTMLElement>) {\r\n return new Promise(resolve => {\r\n let notGrowList: Array<HTMLElement> = [];\r\n let totalGrow = flexContainerList.reduce((t, e, i) => {\r\n if (e.hasAttribute('data-grow') == false) {\r\n notGrowList.push(e);\r\n return t;\r\n }\r\n let grow = parseFloat(e.dataset.grow || '');\r\n e.style.flex = `${grow} 1 0%`;\r\n t -= grow;\r\n return t;\r\n }, flexContainerList.length);\r\n\r\n if (notGrowList.length != 0) {\r\n resize(notGrowList, totalGrow);\r\n }\r\n\r\n resolve(flexContainerList);\r\n });\r\n}\r\n\r\nexport function resize(list: Array<HTMLElement>, totalGrow: number) {\r\n return new Promise(resolve => {\r\n // totalGrow 값을 리스트의 개수로 나누어 균등 할당\r\n let resizeWeight = totalGrow / list.length;\r\n list.forEach(e => {\r\n e.dataset.grow = resizeWeight.toString();\r\n e.style.flex = `${resizeWeight} 1 0%`;\r\n });\r\n resolve(resizeWeight);\r\n });\r\n}\r\n\r\nexport function mathWeight(totalCount: number, totalGrow: number) {\r\n return 1 + (totalGrow - totalCount) / totalCount;\r\n}\r\nexport function mathGrow(\r\n childSize: number,\r\n parentSize: number,\r\n containerCount: number\r\n) {\r\n return containerCount * (childSize / parentSize);\r\n}\r\n\r\nexport function getGrow(growTarget: HTMLElement | Element) {\r\n const target =\r\n growTarget instanceof Element\r\n ? (growTarget as HTMLElement)\r\n : growTarget;\r\n return (\r\n parseFloat(target.style.flex.split(' ')[0]) ||\r\n parseFloat(target.dataset.grow || '')\r\n );\r\n}\r\n\r\nexport function closeFlex(\r\n resizeTarget: HTMLElement,\r\n containers: HTMLElement[],\r\n {\r\n isResize = false,\r\n isDsiabledResizePanel = false,\r\n sizeName,\r\n }: {\r\n isResize?: boolean;\r\n isDsiabledResizePanel?: boolean;\r\n sizeName: 'width' | 'height';\r\n }\r\n) {\r\n return new Promise(resolve => {\r\n if (!resizeTarget.hasAttribute('data-is_resize_panel')) {\r\n // resolve(resizeTarget);\r\n // return;\r\n } else if (isDsiabledResizePanel) {\r\n resizeTarget.dataset.is_resize_panel = 'false';\r\n }\r\n\r\n resizeTarget.dataset.prev_grow = getGrow(resizeTarget).toString();\r\n\r\n let notCloseList = containers.filter(\r\n e => e.style.flex != '0 1 0%' && e != resizeTarget\r\n );\r\n let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];\r\n //let resizeWeight = this.mathWeight(notCloseList, this.#forResizeList.length);\r\n notCloseAndOpenTargetList.forEach(e => {\r\n e.style.transition = 'flex 0.5s';\r\n e.ontransitionend = event => {\r\n if (event.propertyName != 'flex-grow') {\r\n return;\r\n }\r\n notCloseAndOpenTargetList.forEach(\r\n e => (e.style.transition = '')\r\n );\r\n //e.style.transition = '';\r\n e.ontransitionend = () => {};\r\n };\r\n\r\n if (e == resizeTarget) {\r\n e.dataset.grow = '0';\r\n e.style.flex = `0 1 0%`;\r\n return;\r\n }\r\n\r\n if (isResize) {\r\n return;\r\n }\r\n\r\n let percent = getGrow(e) / containers.length;\r\n //let percentWeight = this.#forResizeList.length * percent;\r\n //let remainWeight = resizeWeight * percent;\r\n if (notCloseList.length == 1) {\r\n e.dataset.grow = containers.length.toString();\r\n e.style.flex = `${containers.length} 1 0%`;\r\n return;\r\n }\r\n e.dataset.grow = (containers.length * percent).toString();\r\n e.style.flex = `${containers.length * percent} 1 0%`;\r\n });\r\n\r\n if (isResize) {\r\n resize(notCloseList, containers.length);\r\n }\r\n\r\n resolve(resizeTarget);\r\n });\r\n}\r\n\r\nexport function openFlex(\r\n resizeTarget: HTMLElement,\r\n containers: HTMLElement[],\r\n {\r\n isPrevSizeOpen = false,\r\n isResize = false,\r\n openGrowImportant = 0,\r\n sizeName,\r\n }: {\r\n isPrevSizeOpen?: boolean;\r\n isResize?: boolean;\r\n openGrowImportant?: number;\r\n sizeName?: 'width' | 'height'; // 유니언 타입으로 수정\r\n }\r\n) {\r\n return new Promise(resolve => {\r\n if (!resizeTarget.hasAttribute('data-is_resize_panel')) {\r\n // resolve(resizeTarget);\r\n // return;\r\n } else if (\r\n resizeTarget.hasAttribute('data-is_resize_panel') &&\r\n resizeTarget.dataset.is_resize_panel == 'false'\r\n ) {\r\n resizeTarget.dataset.is_resize_panel = 'true';\r\n }\r\n\r\n let notCloseList = containers.filter(\r\n e => e.style.flex != '0 1 0%' && e != resizeTarget\r\n );\r\n let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];\r\n //let resizeWeight = this.mathWeight(notCloseAndOpenTargetList, this.#forResizeList.length);\r\n let openTargetGrow = 1;\r\n const sizeStyleName = ('client' +\r\n sizeName!.charAt(0).toUpperCase() +\r\n sizeName!.substring(1)) as 'clientHeight' | 'clientWidth';\r\n const parentSize =\r\n (sizeName &&\r\n resizeTarget.parentElement &&\r\n resizeTarget.parentElement[sizeStyleName]) ||\r\n 0;\r\n if (isPrevSizeOpen && resizeTarget.hasAttribute('data-prev_grow')) {\r\n openTargetGrow =\r\n parseFloat(resizeTarget.dataset.prev_grow || '1') || 1;\r\n //resizeTarget.removeAttribute('data-prev_grow');\r\n } else if (parentSize && parentSize !== 0) {\r\n openTargetGrow =\r\n (parentSize / notCloseList.length / (parentSize - 1)) *\r\n containers.length;\r\n } else {\r\n openTargetGrow = 1;\r\n }\r\n if (openGrowImportant) {\r\n openTargetGrow = openGrowImportant;\r\n }\r\n openTargetGrow = openTargetGrow === Infinity ? 1 : openTargetGrow;\r\n //notCloseList.forEach(e=>{\r\n notCloseAndOpenTargetList.forEach(e => {\r\n e.style.transition = 'flex 0.5s';\r\n e.ontransitionend = event => {\r\n if (event.propertyName != 'flex-grow') {\r\n return;\r\n }\r\n notCloseAndOpenTargetList.forEach(\r\n e => (e.style.transition = '')\r\n );\r\n //e.style.transition = '';\r\n e.ontransitionend = () => {};\r\n };\r\n\r\n if (e == resizeTarget) {\r\n resizeTarget.dataset.grow = openTargetGrow.toString();\r\n resizeTarget.style.flex = `${openTargetGrow} 1 0%`;\r\n return;\r\n }\r\n\r\n if (isResize) {\r\n return;\r\n }\r\n\r\n let grow =\r\n (parentSize / notCloseList.length / (parentSize - 1)) *\r\n (containers.length - openTargetGrow);\r\n grow = grow === Infinity ? 1 : grow;\r\n //let percent = getGrow(e) / totalGrow - openTargetGrow / totalGrow;\r\n e.dataset.grow = grow.toString();\r\n\r\n e.style.flex = `${grow} 1 0%`;\r\n });\r\n\r\n if (isResize) {\r\n resize(notCloseAndOpenTargetList, containers.length);\r\n }\r\n\r\n resolve(openTargetGrow);\r\n });\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byeolnaerim/flex-layout",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Joohyoung Kim (@oozu1994)",
@@ -34,6 +34,12 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/joohyoungkim19940805/flex-layout/issues"
36
36
  },
37
+ "files": [
38
+ "dist"
39
+ ],
40
+ "sideEffects": [
41
+ "**/*.css"
42
+ ],
37
43
  "main": "./dist/index.cjs",
38
44
  "module": "./dist/index.js",
39
45
  "types": "./dist/index.d.ts",
@@ -41,45 +47,17 @@
41
47
  ".": {
42
48
  "types": "./dist/index.d.ts",
43
49
  "import": "./dist/index.js",
44
- "require": "./dist/index.cjs"
45
- },
46
- "./components": {
47
- "types": "./dist/components.d.ts",
48
- "import": "./dist/components.js",
49
- "require": "./dist/components.cjs"
50
- },
51
- "./hooks": {
52
- "types": "./dist/hooks.d.ts",
53
- "import": "./dist/hooks.js",
54
- "require": "./dist/hooks.cjs"
55
- },
56
- "./providers": {
57
- "types": "./dist/providers.d.ts",
58
- "import": "./dist/providers.js",
59
- "require": "./dist/providers.cjs"
60
- },
61
- "./utils": {
62
- "types": "./dist/utils.d.ts",
63
- "import": "./dist/utils.js",
64
- "require": "./dist/utils.cjs"
50
+ "require": "./dist/index.cjs",
51
+ "default": "./dist/index.js"
65
52
  },
66
- "./store": {
67
- "types": "./dist/store.d.ts",
68
- "import": "./dist/store.js",
69
- "require": "./dist/store.cjs"
70
- }
53
+ "./package.json": "./package.json"
71
54
  },
72
- "files": [
73
- "dist"
74
- ],
75
- "sideEffects": [
76
- "**/*.css"
77
- ],
78
55
  "scripts": {
79
- "build": "tsup && npm run copy:assets",
80
- "copy:assets": "cpy \"**/*.css\" \"../dist\" --cwd=src --parents",
56
+ "build": "tsup && tsc -p tsconfig.build.json && npm run copy:assets",
57
+ "copy:assets": "cpy \"src/**/*.css\" \"dist\"",
81
58
  "dev": "tsup --watch",
82
- "prepack": "npm run build"
59
+ "prepack": "npm run build",
60
+ "prepare": "npm run build"
83
61
  },
84
62
  "devDependencies": {
85
63
  "@types/react": "^18",
@@ -92,16 +70,11 @@
92
70
  "typescript": "5.9.3"
93
71
  },
94
72
  "peerDependencies": {
95
- "react": ">=19",
96
- "react-dom": ">=19",
97
- "rxjs": ">=7"
98
- },
99
- "peerDependenciesMeta": {
100
- "rxjs": {
101
- "optional": true
102
- }
73
+ "react": ">=18",
74
+ "react-dom": ">=18"
103
75
  },
104
76
  "dependencies": {
105
- "fast-deep-equal": "^3.1.3"
77
+ "fast-deep-equal": "^3.1.3",
78
+ "rxjs": ">=7"
106
79
  }
107
80
  }
@@ -1,31 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { HTMLAttributes, MouseEvent, TouchEvent, CSSProperties, ReactElement, ReactNode, RefObject } from 'react';
3
-
4
- interface FlexLayoutSplitScreenDragBoxProps<E extends HTMLElement = HTMLElement> extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
5
- onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
6
- onTouchStart?: (event: TouchEvent<HTMLDivElement>) => void;
7
- dropEndCallback?: ({ x, y, containerName, }: {
8
- x: number;
9
- y: number;
10
- containerName: string;
11
- }) => void;
12
- style?: CSSProperties;
13
- navigationTitle?: string;
14
- targetComponent?: ReactElement;
15
- dropDocumentOutsideOption?: DropDocumentOutsideOption;
16
- children: ReactNode;
17
- containerName: string;
18
- screenKey?: string;
19
- isBlockingActiveInput?: boolean;
20
- customData?: Record<string, string | number | boolean | undefined>;
21
- scrollTargetRef?: RefObject<E>;
22
- }
23
- interface DropDocumentOutsideOption {
24
- openUrl: string;
25
- widthRatio?: number;
26
- heightRatio?: number;
27
- isNewTap?: boolean;
28
- }
29
- declare function FlexLayoutSplitScreenDragBox<E extends HTMLElement>({ onMouseDown, onTouchStart, dropEndCallback, style, navigationTitle, targetComponent, containerName, children, className, dropDocumentOutsideOption, screenKey, isBlockingActiveInput, customData, scrollTargetRef, ...props }: FlexLayoutSplitScreenDragBoxProps): react_jsx_runtime.JSX.Element;
30
-
31
- export { type DropDocumentOutsideOption as D, FlexLayoutSplitScreenDragBox as F };
@@ -1,31 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { HTMLAttributes, MouseEvent, TouchEvent, CSSProperties, ReactElement, ReactNode, RefObject } from 'react';
3
-
4
- interface FlexLayoutSplitScreenDragBoxProps<E extends HTMLElement = HTMLElement> extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
5
- onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;
6
- onTouchStart?: (event: TouchEvent<HTMLDivElement>) => void;
7
- dropEndCallback?: ({ x, y, containerName, }: {
8
- x: number;
9
- y: number;
10
- containerName: string;
11
- }) => void;
12
- style?: CSSProperties;
13
- navigationTitle?: string;
14
- targetComponent?: ReactElement;
15
- dropDocumentOutsideOption?: DropDocumentOutsideOption;
16
- children: ReactNode;
17
- containerName: string;
18
- screenKey?: string;
19
- isBlockingActiveInput?: boolean;
20
- customData?: Record<string, string | number | boolean | undefined>;
21
- scrollTargetRef?: RefObject<E>;
22
- }
23
- interface DropDocumentOutsideOption {
24
- openUrl: string;
25
- widthRatio?: number;
26
- heightRatio?: number;
27
- isNewTap?: boolean;
28
- }
29
- declare function FlexLayoutSplitScreenDragBox<E extends HTMLElement>({ onMouseDown, onTouchStart, dropEndCallback, style, navigationTitle, targetComponent, containerName, children, className, dropDocumentOutsideOption, screenKey, isBlockingActiveInput, customData, scrollTargetRef, ...props }: FlexLayoutSplitScreenDragBoxProps): react_jsx_runtime.JSX.Element;
30
-
31
- export { type DropDocumentOutsideOption as D, FlexLayoutSplitScreenDragBox as F };
@@ -1,3 +0,0 @@
1
-
2
- //# sourceMappingURL=chunk-3EDKZTM3.js.map
3
- //# sourceMappingURL=chunk-3EDKZTM3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-3EDKZTM3.js"}