@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,101 +1 @@
1
- import { useRef, useState, useLayoutEffect, useEffect } from 'react';
2
- import { fromEvent, distinctUntilChanged, filter, auditTime } from 'rxjs';
3
-
4
- const useSize = (sizeName) => {
5
- const ref = useRef(null);
6
- const [size, setSize] = useState(void 0);
7
- useLayoutEffect(() => {
8
- if (!ref.current) return;
9
- const handleResize = () => {
10
- if (ref.current) {
11
- const newSize = ref.current.getBoundingClientRect()[sizeName];
12
- setSize(newSize);
13
- }
14
- };
15
- handleResize();
16
- const resizeObserver = new ResizeObserver(() => {
17
- handleResize();
18
- });
19
- resizeObserver.observe(ref.current);
20
- window.addEventListener("resize", handleResize);
21
- return () => {
22
- resizeObserver.disconnect();
23
- window.removeEventListener("resize", handleResize);
24
- };
25
- }, [sizeName]);
26
- return { ref, size };
27
- };
28
- const useFirstChildSize = (sizeName) => {
29
- const ref = useRef(null);
30
- const [sizes, setSizes] = useState();
31
- useEffect(() => {
32
- if (!ref.current || !ref.current.children[0]) return;
33
- if (!sizes || sizes.length === 0) {
34
- setSizes([
35
- ref.current.getBoundingClientRect()[sizeName],
36
- ref.current.children[0].getBoundingClientRect()[sizeName]
37
- ]);
38
- }
39
- }, []);
40
- useEffect(() => {
41
- if (!ref.current || !ref.current.children[0]) return;
42
- const childrenChangeObserver = new MutationObserver(
43
- (mutationList, observer) => {
44
- mutationList.forEach((mutation) => {
45
- if (!ref.current || !sizes || !ref.current.children[0])
46
- return;
47
- const newSize = ref.current.getBoundingClientRect()[sizeName];
48
- setSizes([
49
- newSize,
50
- ref.current.children[0].getBoundingClientRect()[sizeName]
51
- ]);
52
- });
53
- }
54
- );
55
- childrenChangeObserver.observe(ref.current, {
56
- childList: true,
57
- subtree: true
58
- });
59
- let isFocus = false;
60
- const windowResizeSubscribe = fromEvent(window, "resize").pipe(
61
- distinctUntilChanged(),
62
- filter(
63
- () => document.activeElement?.tagName !== "INPUT" && !isFocus
64
- )
65
- ).subscribe((ev) => {
66
- if (!ref.current || !ref.current.children[0]) return;
67
- setSizes([
68
- ref.current.getBoundingClientRect()[sizeName],
69
- ref.current.children[0].getBoundingClientRect()[sizeName]
70
- ]);
71
- });
72
- const documentFocusoutSubscribe = fromEvent(
73
- document,
74
- "focusout"
75
- ).pipe(
76
- auditTime(1e3),
77
- filter((ev) => document.activeElement?.tagName !== "INPUT")
78
- ).subscribe({
79
- next: () => {
80
- if (isFocus) isFocus = false;
81
- }
82
- });
83
- const documentFocusinSubscribe = fromEvent(
84
- document,
85
- "focusin"
86
- ).subscribe({
87
- next: (ev) => isFocus = ev.target.tagName === "INPUT"
88
- });
89
- return () => {
90
- windowResizeSubscribe.unsubscribe();
91
- documentFocusoutSubscribe.unsubscribe();
92
- documentFocusinSubscribe.unsubscribe();
93
- childrenChangeObserver.disconnect();
94
- };
95
- }, [sizeName, sizes]);
96
- return { ref, sizes };
97
- };
98
-
99
- export { useFirstChildSize, useSize };
100
- //# sourceMappingURL=useSizes.js.map
101
- //# sourceMappingURL=useSizes.js.map
1
+ import{useEffect as d,useLayoutEffect as v,useRef as b,useState as f}from"react";import{auditTime as h,distinctUntilChanged as R,filter as l,fromEvent as o}from"rxjs";const M=n=>{const e=b(null),[t,u]=f(void 0);return v(()=>{if(!e.current)return;const r=()=>{if(e.current){const s=e.current.getBoundingClientRect()[n];u(s)}};r();const c=new ResizeObserver(()=>{r()});return c.observe(e.current),window.addEventListener("resize",r),()=>{c.disconnect(),window.removeEventListener("resize",r)}},[n]),{ref:e,size:t}},S=n=>{const e=b(null),[t,u]=f();return d(()=>{!e.current||!e.current.children[0]||(!t||t.length===0)&&u([e.current.getBoundingClientRect()[n],e.current.children[0].getBoundingClientRect()[n]])},[]),d(()=>{if(!e.current||!e.current.children[0])return;const r=new MutationObserver((i,E)=>{i.forEach(w=>{if(!e.current||!t||!e.current.children[0])return;const g=e.current.getBoundingClientRect()[n];u([g,e.current.children[0].getBoundingClientRect()[n]])})});r.observe(e.current,{childList:!0,subtree:!0});let c=!1;const s=o(window,"resize").pipe(R(),l(()=>document.activeElement?.tagName!=="INPUT"&&!c)).subscribe(i=>{!e.current||!e.current.children[0]||u([e.current.getBoundingClientRect()[n],e.current.children[0].getBoundingClientRect()[n]])}),a=o(document,"focusout").pipe(h(1e3),l(i=>document.activeElement?.tagName!=="INPUT")).subscribe({next:()=>{c&&(c=!1)}}),m=o(document,"focusin").subscribe({next:i=>c=i.target.tagName==="INPUT"});return()=>{s.unsubscribe(),a.unsubscribe(),m.unsubscribe(),r.disconnect()}},[n,t]),{ref:e,sizes:t}};export{S as useFirstChildSize,M as useSize};
@@ -1,42 +1 @@
1
- 'use strict';
2
-
3
- var components = require('./components');
4
- var hooks = require('./hooks');
5
- var providers = require('./providers');
6
- var utils = require('./utils');
7
- var store = require('./store');
8
-
9
-
10
-
11
- Object.keys(components).forEach(function (k) {
12
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
13
- enumerable: true,
14
- get: function () { return components[k]; }
15
- });
16
- });
17
- Object.keys(hooks).forEach(function (k) {
18
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
19
- enumerable: true,
20
- get: function () { return hooks[k]; }
21
- });
22
- });
23
- Object.keys(providers).forEach(function (k) {
24
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
25
- enumerable: true,
26
- get: function () { return providers[k]; }
27
- });
28
- });
29
- Object.keys(utils).forEach(function (k) {
30
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
31
- enumerable: true,
32
- get: function () { return utils[k]; }
33
- });
34
- });
35
- Object.keys(store).forEach(function (k) {
36
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
37
- enumerable: true,
38
- get: function () { return store[k]; }
39
- });
40
- });
41
- //# sourceMappingURL=index.cjs.map
42
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("./components"),module.exports);r(o,require("./hooks"),module.exports);r(o,require("./providers"),module.exports);r(o,require("./utils"),module.exports);r(o,require("./store"),module.exports);0&&(module.exports={...require("./components"),...require("./hooks"),...require("./providers"),...require("./utils"),...require("./store")});
@@ -1,7 +1 @@
1
- export * from './components';
2
- export * from './hooks';
3
- export * from './providers';
4
- export * from './utils';
5
- export * from './store';
6
- //# sourceMappingURL=index.js.map
7
- //# sourceMappingURL=index.js.map
1
+ export*from"./components";export*from"./hooks";export*from"./providers";export*from"./utils";export*from"./store";
@@ -1,26 +1 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
-
6
- const FlexLayoutContext = react.createContext(null);
7
- function useFlexLayoutContext() {
8
- const context = react.useContext(FlexLayoutContext);
9
- if (!context) {
10
- throw new Error(
11
- "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
12
- );
13
- }
14
- return context;
15
- }
16
- function FlexLayoutProvider({
17
- value,
18
- children
19
- }) {
20
- return /* @__PURE__ */ jsxRuntime.jsx(FlexLayoutContext.Provider, { value, children });
21
- }
22
-
23
- exports.FlexLayoutProvider = FlexLayoutProvider;
24
- exports.useFlexLayoutContext = useFlexLayoutContext;
25
- //# sourceMappingURL=FlexLayoutContext.cjs.map
26
- //# sourceMappingURL=FlexLayoutContext.cjs.map
1
+ "use strict";"use client";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!F.call(e,o)&&o!==r&&n(e,o,{get:()=>t[o],enumerable:!(x=i(t,o))||x.enumerable});return e};var d=e=>c(n({},"__esModule",{value:!0}),e);var v={};L(v,{FlexLayoutProvider:()=>s,useFlexLayoutContext:()=>C});module.exports=d(v);var a=require("react/jsx-runtime"),u=require("react");const l=(0,u.createContext)(null);function C(){const e=(0,u.useContext)(l);if(!e)throw new Error("useFlexLayoutContext must be used within FlexLayoutContext.Provider");return e}function s({value:e,children:t}){return(0,a.jsx)(l.Provider,{value:e,children:t})}0&&(module.exports={FlexLayoutProvider,useFlexLayoutContext});
@@ -1,23 +1 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useContext } from 'react';
3
-
4
- const FlexLayoutContext = createContext(null);
5
- function useFlexLayoutContext() {
6
- const context = useContext(FlexLayoutContext);
7
- if (!context) {
8
- throw new Error(
9
- "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
10
- );
11
- }
12
- return context;
13
- }
14
- function FlexLayoutProvider({
15
- value,
16
- children
17
- }) {
18
- return /* @__PURE__ */ jsx(FlexLayoutContext.Provider, { value, children });
19
- }
20
-
21
- export { FlexLayoutProvider, useFlexLayoutContext };
22
- //# sourceMappingURL=FlexLayoutContext.js.map
23
- //# sourceMappingURL=FlexLayoutContext.js.map
1
+ "use client";import{jsx as n}from"react/jsx-runtime";import{createContext as r,useContext as u}from"react";const t=r(null);function y(){const e=u(t);if(!e)throw new Error("useFlexLayoutContext must be used within FlexLayoutContext.Provider");return e}function F({value:e,children:o}){return n(t.Provider,{value:e,children:o})}export{F as FlexLayoutProvider,y as useFlexLayoutContext};
@@ -1,247 +1 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
- var FlexLayoutContainerStore = require('../store/FlexLayoutContainerStore');
5
- var FlexLayoutUtils = require('../utils/FlexLayoutUtils');
6
- var rxjs = require('rxjs');
7
-
8
- const g = globalThis;
9
- g.__FLEX_SUBJECTS__ ?? (g.__FLEX_SUBJECTS__ = { openClose: {}, spread: {} });
10
- const containerOpenCloseSubjectMap = g.__FLEX_SUBJECTS__.openClose;
11
- const containerSpreadSubjectMap = g.__FLEX_SUBJECTS__.spread;
12
- const ContainerOpenCloseProvider = ({
13
- layoutName,
14
- containerName,
15
- sizeName
16
- }) => {
17
- if (!containerOpenCloseSubjectMap[containerName]) {
18
- containerOpenCloseSubjectMap[containerName] = new rxjs.Subject();
19
- }
20
- if (!containerSpreadSubjectMap[containerName]) {
21
- containerSpreadSubjectMap[containerName] = new rxjs.Subject();
22
- }
23
- const [containers, setContainers] = react.useState([]);
24
- const [container, setContainer] = react.useState();
25
- react.useEffect(() => {
26
- const subscription = FlexLayoutContainerStore.getLayoutInfos(layoutName).subscribe(
27
- (layout) => {
28
- if (!layout || !layout.container[containerName] || !layout.container[containerName].current)
29
- return;
30
- setContainers(
31
- Object.values(layout.container).filter(
32
- (e) => e.current !== null
33
- ).map((e) => e.current)
34
- );
35
- setContainer(layout.container[containerName].current);
36
- }
37
- );
38
- return () => subscription.unsubscribe();
39
- }, [containerName, layoutName]);
40
- react.useEffect(() => {
41
- const styleName = `${sizeName.charAt(0).toUpperCase() + sizeName.substring(1)}`;
42
- const clientSize = "client" + styleName;
43
- const outerSize = "outer" + styleName;
44
- const maxSize = "max" + styleName;
45
- const subscribe = containerOpenCloseSubjectMap[containerName].subscribe(
46
- ({
47
- mode,
48
- initOpenState: isOpenState,
49
- onClose,
50
- onOpen,
51
- openOption = {},
52
- closeOption = {}
53
- }) => {
54
- if (!container || containers.length === 0) return;
55
- const currentGrow = FlexLayoutUtils.getGrow(container);
56
- const styleMap = window.getComputedStyle(container);
57
- const maxSizeGrow = FlexLayoutUtils.mathGrow(
58
- parseInt(styleMap[maxSize]),
59
- container.parentElement && container.parentElement[clientSize] || window[outerSize],
60
- containers.length
61
- );
62
- const open = () => FlexLayoutUtils.openFlex(container, containers, {
63
- sizeName,
64
- ...isNaN(maxSizeGrow) ? {} : {
65
- openGrowImportant: maxSizeGrow
66
- },
67
- ...openOption
68
- }).then((openTargetGrow) => {
69
- if (onOpen) onOpen();
70
- containerSpreadSubjectMap[containerName].next({
71
- isOpen: true,
72
- grow: openTargetGrow,
73
- targetContainer: container
74
- });
75
- });
76
- const close = () => FlexLayoutUtils.closeFlex(container, containers, {
77
- sizeName,
78
- ...closeOption
79
- }).then(() => {
80
- if (onClose) onClose();
81
- containerSpreadSubjectMap[containerName].next({
82
- isOpen: false,
83
- grow: 0,
84
- targetContainer: container
85
- });
86
- });
87
- if (mode === "toggle") {
88
- if (currentGrow === 0) {
89
- open();
90
- } else {
91
- close();
92
- }
93
- } else if (mode === "open") {
94
- if (currentGrow === 0) {
95
- open();
96
- }
97
- } else if (mode === "close") {
98
- if (currentGrow !== 0) {
99
- close();
100
- }
101
- }
102
- }
103
- );
104
- return () => {
105
- subscribe.unsubscribe();
106
- };
107
- }, [containerName, container, containers, sizeName]);
108
- return null;
109
- };
110
- const useContainers = (layoutName) => {
111
- const [containers, setContainers] = react.useState([]);
112
- react.useEffect(() => {
113
- const subscription = FlexLayoutContainerStore.getLayoutInfos(layoutName).subscribe(
114
- (layout) => {
115
- setContainers(
116
- Object.values(layout.container).filter(
117
- (e) => e.current !== null
118
- ).map((e) => e.current)
119
- );
120
- }
121
- );
122
- return () => subscription.unsubscribe();
123
- }, [layoutName]);
124
- return containers;
125
- };
126
- const useLayoutName = (containerName) => {
127
- const [layoutName, setLayoutName] = react.useState();
128
- react.useEffect(() => {
129
- const subscribe = FlexLayoutContainerStore.flexContainerStore.pipe(
130
- rxjs.map(
131
- (layouts) => Object.entries(layouts).filter(([_, v]) => v[containerName]).map(([k]) => k)[0]
132
- // 첫 번째 결과 가져오기
133
- )
134
- ).subscribe(setLayoutName);
135
- return () => subscribe.unsubscribe();
136
- }, [containerName]);
137
- return layoutName;
138
- };
139
- const useDecompositionLayout = ({
140
- layoutName: initialLayoutName,
141
- containerName
142
- }) => {
143
- const derivedLayoutName = useLayoutName(containerName);
144
- const finalLayoutName = initialLayoutName || derivedLayoutName;
145
- const [containers, setContainers] = react.useState([]);
146
- const [container, setContainer] = react.useState();
147
- const [resizePanel, setResizePanel] = react.useState();
148
- react.useEffect(() => {
149
- if (!finalLayoutName) return;
150
- const subscription = FlexLayoutContainerStore.getLayoutInfos(finalLayoutName).subscribe(
151
- (layout) => {
152
- if (!layout) return;
153
- setContainers(
154
- Object.values(layout.container).filter(
155
- (e) => e.current !== null
156
- ).map((e) => e.current)
157
- );
158
- if (containerName && layout.container[containerName] && layout.container[containerName].current) {
159
- setContainer(layout.container[containerName].current);
160
- if (layout.resizePanel[containerName] && layout.resizePanel[containerName].current) {
161
- setResizePanel(
162
- layout.resizePanel[containerName].current
163
- );
164
- }
165
- }
166
- }
167
- );
168
- return () => subscription.unsubscribe();
169
- }, [containerName, finalLayoutName]);
170
- return { layout: containers, container, resizePanel };
171
- };
172
- const useContainerSize = (containerName) => {
173
- const { layout, container, resizePanel } = useDecompositionLayout({
174
- containerName
175
- });
176
- const [size, setSize] = react.useState();
177
- react.useEffect(() => {
178
- if (!container) return;
179
- const observer = new ResizeObserver((entries) => {
180
- for (const entry of entries) {
181
- setSize({
182
- width: entry.contentRect.width,
183
- height: entry.contentRect.height
184
- });
185
- }
186
- });
187
- observer.observe(container);
188
- return () => observer.disconnect();
189
- }, [container]);
190
- return { size };
191
- };
192
- const useDoubleClick = (containerName, opt) => {
193
- const [isOpen, setIsOpen] = react.useState();
194
- const [isDoubleClick, setIsDoubleClick] = react.useState();
195
- react.useEffect(() => {
196
- const resizePanelClickEvent = FlexLayoutContainerStore.getResizePanelRef({
197
- containerName
198
- }).pipe(
199
- rxjs.filter(
200
- (resizePanelref) => resizePanelref != void 0 && resizePanelref.current != void 0
201
- ),
202
- //take(1),
203
- rxjs.switchMap((resizePanelref) => {
204
- if (!resizePanelref || !resizePanelref.current) return rxjs.EMPTY;
205
- return rxjs.fromEvent(resizePanelref.current, "click");
206
- })
207
- );
208
- const subscribe = resizePanelClickEvent.pipe(
209
- rxjs.buffer(resizePanelClickEvent.pipe(rxjs.debounceTime(500))),
210
- rxjs.filter((clickEventArray) => clickEventArray.length >= 2),
211
- rxjs.map((events) => {
212
- containerOpenCloseSubjectMap[containerName].next({
213
- ...opt,
214
- openOption: {
215
- ...opt.openOption,
216
- isPrevSizeOpen: false
217
- },
218
- onClose: () => {
219
- if (opt.onClose) opt.onClose();
220
- setIsOpen(false);
221
- setIsDoubleClick(true);
222
- },
223
- onOpen: () => {
224
- if (opt.onOpen) opt.onOpen();
225
- setIsOpen(true);
226
- setIsDoubleClick(true);
227
- }
228
- });
229
- })
230
- ).subscribe();
231
- return () => {
232
- subscribe.unsubscribe();
233
- };
234
- }, [containerName]);
235
- return { isOpen, isDoubleClick, setIsDoubleClick };
236
- };
237
-
238
- exports.ContainerOpenCloseProvider = ContainerOpenCloseProvider;
239
- exports.containerOpenCloseSubjectMap = containerOpenCloseSubjectMap;
240
- exports.containerSpreadSubjectMap = containerSpreadSubjectMap;
241
- exports.useContainerSize = useContainerSize;
242
- exports.useContainers = useContainers;
243
- exports.useDecompositionLayout = useDecompositionLayout;
244
- exports.useDoubleClick = useDoubleClick;
245
- exports.useLayoutName = useLayoutName;
246
- //# sourceMappingURL=FlexLayoutHooks.cjs.map
247
- //# sourceMappingURL=FlexLayoutHooks.cjs.map
1
+ "use strict";"use client";var m=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)m(t,r,{get:e[r],enumerable:!0})},G=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of D(e))!I.call(t,c)&&c!==r&&m(t,c,{get:()=>e[c],enumerable:!(s=k(e,c))||s.enumerable});return t};var F=t=>G(m({},"__esModule",{value:!0}),t);var X={};y(X,{ContainerOpenCloseProvider:()=>q,containerOpenCloseSubjectMap:()=>h,containerSpreadSubjectMap:()=>d,useContainerSize:()=>B,useContainers:()=>U,useDecompositionLayout:()=>_,useDoubleClick:()=>W,useDoubleClickToggle:()=>J,useLayoutName:()=>v});module.exports=F(X);var i=require("react"),b=require("../store/FlexLayoutContainerStore"),f=require("../utils/FlexLayoutUtils"),o=require("rxjs");const S=globalThis;S.__FLEX_SUBJECTS__??(S.__FLEX_SUBJECTS__={openClose:{},spread:{}});const h=S.__FLEX_SUBJECTS__.openClose,d=S.__FLEX_SUBJECTS__.spread,q=({layoutName:t,containerName:e,sizeName:r})=>{h[e]||(h[e]=new o.Subject),d[e]||(d[e]=new o.Subject);const[s,c]=(0,i.useState)([]),[n,l]=(0,i.useState)();return(0,i.useEffect)(()=>{const p=(0,b.getLayoutInfos)(t).subscribe(u=>{!u||!u.container[e]||!u.container[e].current||(c(Object.values(u.container).filter(g=>g.current!==null).map(g=>g.current)),l(u.container[e].current))});return()=>p.unsubscribe()},[e,t]),(0,i.useEffect)(()=>{const p=`${r.charAt(0).toUpperCase()+r.substring(1)}`,u="client"+p,g="outer"+p,E="max"+p,a=h[e].subscribe(({mode:C,initOpenState:$,onClose:w,onOpen:x,openOption:R={},closeOption:H={}})=>{if(!n||s.length===0)return;const O=(0,f.getGrow)(n),P=window.getComputedStyle(n),L=(0,f.mathGrow)(parseInt(P[E]),n.parentElement&&n.parentElement[u]||window[g],s.length),T=()=>(0,f.openFlex)(n,s,{sizeName:r,...isNaN(L)?{}:{openGrowImportant:L},...R}).then(j=>{x&&x(),d[e].next({isOpen:!0,grow:j,targetContainer:n})}),M=()=>(0,f.closeFlex)(n,s,{sizeName:r,...H}).then(()=>{w&&w(),d[e].next({isOpen:!1,grow:0,targetContainer:n})});C==="toggle"?O===0?T():M():C==="open"?O===0&&T():C==="close"&&O!==0&&M()});return()=>{a.unsubscribe()}},[e,n,s,r]),null},U=t=>{const[e,r]=(0,i.useState)([]);return(0,i.useEffect)(()=>{const s=(0,b.getLayoutInfos)(t).subscribe(c=>{r(Object.values(c.container).filter(n=>n.current!==null).map(n=>n.current))});return()=>s.unsubscribe()},[t]),e},v=t=>{const[e,r]=(0,i.useState)();return(0,i.useEffect)(()=>{const s=b.flexContainerStore.pipe((0,o.map)(c=>Object.entries(c).filter(([n,l])=>l[t]).map(([n])=>n)[0])).subscribe(r);return()=>s.unsubscribe()},[t]),e},_=({layoutName:t,containerName:e})=>{const r=v(e),s=t||r,[c,n]=(0,i.useState)([]),[l,p]=(0,i.useState)(),[u,g]=(0,i.useState)();return(0,i.useEffect)(()=>{if(!s)return;const E=(0,b.getLayoutInfos)(s).subscribe(a=>{a&&(n(Object.values(a.container).filter(C=>C.current!==null).map(C=>C.current)),e&&a.container[e]&&a.container[e].current&&(p(a.container[e].current),a.resizePanel[e]&&a.resizePanel[e].current&&g(a.resizePanel[e].current)))});return()=>E.unsubscribe()},[e,s]),{layout:c,container:l,resizePanel:u}},B=t=>{const{layout:e,container:r,resizePanel:s}=_({containerName:t}),[c,n]=(0,i.useState)();return(0,i.useEffect)(()=>{if(!r)return;const l=new ResizeObserver(p=>{for(const u of p)n({width:u.contentRect.width,height:u.contentRect.height})});return l.observe(r),()=>l.disconnect()},[r]),{size:c}},z=t=>(0,b.getResizePanelRef)({containerName:t}).pipe((0,o.filter)(e=>e!=null&&e.current!=null),(0,o.switchMap)(e=>!e||!e.current?o.EMPTY:(0,o.fromEvent)(e.current,"click"))),J=(t,e)=>{const[r,s]=(0,i.useState)(),[c,n]=(0,i.useState)();return(0,i.useEffect)(()=>{const l=z(t),p=l.pipe((0,o.buffer)(l.pipe((0,o.debounceTime)(500))),(0,o.filter)(u=>u.length>=2)).subscribe(()=>{h[t].next({...e,openOption:{...e.openOption,isPrevSizeOpen:!1},onClose:()=>{e.onClose&&e.onClose(),s(!1),n(!0)},onOpen:()=>{e.onOpen&&e.onOpen(),s(!0),n(!0)}})});return()=>{p.unsubscribe()}},[t]),{isOpen:r,isDoubleClick:c,setIsDoubleClick:n}},W=t=>{const[e,r]=(0,i.useState)();return(0,i.useEffect)(()=>{const s=z(t),c=s.pipe((0,o.buffer)(s.pipe((0,o.debounceTime)(500))),(0,o.filter)(n=>n.length>=2)).subscribe(()=>{r(!0)});return()=>{c.unsubscribe()}},[t]),{isDoubleClick:e,setIsDoubleClick:r}};0&&(module.exports={ContainerOpenCloseProvider,containerOpenCloseSubjectMap,containerSpreadSubjectMap,useContainerSize,useContainers,useDecompositionLayout,useDoubleClick,useDoubleClickToggle,useLayoutName});
@@ -43,9 +43,13 @@ export declare const useContainerSize: (containerName: string) => {
43
43
  height: number;
44
44
  } | undefined;
45
45
  };
46
- export declare const useDoubleClick: (containerName: string, opt: ContainerStateRequest) => {
46
+ export declare const useDoubleClickToggle: (containerName: string, opt: ContainerStateRequest) => {
47
47
  isOpen: boolean | undefined;
48
48
  isDoubleClick: boolean | undefined;
49
49
  setIsDoubleClick: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
50
50
  };
51
+ export declare const useDoubleClick: (containerName: string) => {
52
+ isDoubleClick: boolean | undefined;
53
+ setIsDoubleClick: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
54
+ };
51
55
  export {};