@byeolnaerim/flex-layout 0.0.9 → 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 (122) hide show
  1. package/dist/flex-layout/components/FlexLayout.cjs +1 -110
  2. package/dist/flex-layout/components/FlexLayout.js +1 -85
  3. package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -262
  4. package/dist/flex-layout/components/FlexLayoutContainer.js +1 -232
  5. package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -68
  6. package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -44
  7. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -246
  8. package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -216
  9. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1252
  10. package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1236
  11. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -532
  12. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -509
  13. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -55
  14. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
  15. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -63
  16. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -33
  17. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -53
  18. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -23
  19. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -133
  20. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -107
  21. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -245
  22. package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -229
  23. package/dist/flex-layout/components/index.cjs +1 -57
  24. package/dist/flex-layout/components/index.js +1 -17
  25. package/dist/flex-layout/hooks/index.cjs +1 -25
  26. package/dist/flex-layout/hooks/index.js +1 -3
  27. package/dist/flex-layout/hooks/useDrag.cjs +1 -289
  28. package/dist/flex-layout/hooks/useDrag.d.ts +15 -0
  29. package/dist/flex-layout/hooks/useDrag.js +1 -258
  30. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -139
  31. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -118
  32. package/dist/flex-layout/hooks/useListPaging.cjs +1 -212
  33. package/dist/flex-layout/hooks/useListPaging.js +1 -191
  34. package/dist/flex-layout/hooks/useSizes.cjs +1 -126
  35. package/dist/flex-layout/hooks/useSizes.js +1 -101
  36. package/dist/flex-layout/index.cjs +1 -31
  37. package/dist/flex-layout/index.js +1 -6
  38. package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -49
  39. package/dist/flex-layout/providers/FlexLayoutContext.js +1 -24
  40. package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -276
  41. package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
  42. package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -263
  43. package/dist/flex-layout/providers/index.cjs +1 -23
  44. package/dist/flex-layout/providers/index.js +1 -2
  45. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -257
  46. package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -206
  47. package/dist/flex-layout/store/index.cjs +1 -23
  48. package/dist/flex-layout/store/index.js +1 -2
  49. package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
  50. package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -17
  51. package/dist/flex-layout/types/FlexDirectionTypes.js +0 -1
  52. package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -17
  53. package/dist/flex-layout/types/FlexLayoutTypes.js +0 -1
  54. package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -245
  55. package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -211
  56. package/dist/flex-layout/utils/index.cjs +1 -23
  57. package/dist/flex-layout/utils/index.js +1 -2
  58. package/dist/index.cjs +1 -23
  59. package/dist/index.js +1 -2
  60. package/dist/types/css.d.cjs +0 -1
  61. package/dist/types/css.d.js +0 -1
  62. package/package.json +116 -113
  63. package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
  64. package/dist/flex-layout/components/FlexLayout.js.map +0 -1
  65. package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
  66. package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
  67. package/dist/flex-layout/components/FlexLayoutIFramePane.cjs.map +0 -1
  68. package/dist/flex-layout/components/FlexLayoutIFramePane.js.map +0 -1
  69. package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
  70. package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
  71. package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
  72. package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
  73. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
  74. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
  75. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
  76. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
  77. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
  78. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
  79. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
  80. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
  81. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
  82. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
  83. package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
  84. package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
  85. package/dist/flex-layout/components/index.cjs.map +0 -1
  86. package/dist/flex-layout/components/index.js.map +0 -1
  87. package/dist/flex-layout/hooks/index.cjs.map +0 -1
  88. package/dist/flex-layout/hooks/index.js.map +0 -1
  89. package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
  90. package/dist/flex-layout/hooks/useDrag.js.map +0 -1
  91. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
  92. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
  93. package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
  94. package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
  95. package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
  96. package/dist/flex-layout/hooks/useSizes.js.map +0 -1
  97. package/dist/flex-layout/index.cjs.map +0 -1
  98. package/dist/flex-layout/index.js.map +0 -1
  99. package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
  100. package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
  101. package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
  102. package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
  103. package/dist/flex-layout/providers/index.cjs.map +0 -1
  104. package/dist/flex-layout/providers/index.js.map +0 -1
  105. package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
  106. package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
  107. package/dist/flex-layout/store/index.cjs.map +0 -1
  108. package/dist/flex-layout/store/index.js.map +0 -1
  109. package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
  110. package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
  111. package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
  112. package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
  113. package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
  114. package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
  115. package/dist/flex-layout/utils/index.cjs.map +0 -1
  116. package/dist/flex-layout/utils/index.js.map +0 -1
  117. package/dist/index.cjs.map +0 -1
  118. package/dist/index.js.map +0 -1
  119. package/dist/metafile-cjs.json +0 -1
  120. package/dist/metafile-esm.json +0 -1
  121. package/dist/types/css.d.cjs.map +0 -1
  122. package/dist/types/css.d.js.map +0 -1
@@ -1,110 +1 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var FlexLayout_exports = {};
31
- __export(FlexLayout_exports, {
32
- default: () => FlexLayout
33
- });
34
- module.exports = __toCommonJS(FlexLayout_exports);
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = require("react");
37
- var import_FlexLayoutHooks = require("../providers/FlexLayoutHooks");
38
- var import_FlexLayout = __toESM(require("../styles/FlexLayout.module.css"), 1);
39
- var import_FlexLayoutContext = require("../providers/FlexLayoutContext");
40
- const withFlexLayout = (layoutName, fitContent, containerCount) => (WrappedComponent) => {
41
- if (WrappedComponent.type === import_react.Fragment || WrappedComponent.type === "div" || WrappedComponent.type === "span") {
42
- return WrappedComponent;
43
- }
44
- return (0, import_react.cloneElement)(WrappedComponent, {
45
- layoutName,
46
- fitContent,
47
- containerCount
48
- });
49
- };
50
- function FlexLayout({
51
- layoutName,
52
- direction,
53
- children,
54
- ref,
55
- className,
56
- panelClassName,
57
- panelMovementMode = "divorce",
58
- ...props
59
- }) {
60
- const containerCount = import_react.Children.count(children);
61
- const fitContent = direction === "row" ? "width" : "height";
62
- const isFragmentElement = (node) => (0, import_react.isValidElement)(node) && node.type === import_react.Fragment;
63
- const nodes = import_react.Children.toArray(children).flatMap(
64
- (node) => isFragmentElement(node) ? import_react.Children.toArray(node.props.children) : [node]
65
- );
66
- const flattenedChildren = nodes.filter(
67
- import_react.isValidElement
68
- );
69
- if (flattenedChildren.length === 0) {
70
- return null;
71
- }
72
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
73
- import_FlexLayoutContext.FlexLayoutProvider,
74
- {
75
- value: {
76
- layoutName,
77
- direction,
78
- panelMovementMode,
79
- panelClassName,
80
- containerCount,
81
- fitContent
82
- },
83
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
- "div",
85
- {
86
- className: `${import_FlexLayout.default["flex-layout"]} ${className && className !== "" ? className : ""}`,
87
- ...ref ? { ref } : {},
88
- ...props,
89
- "data-layout_name": layoutName,
90
- "data-direction": direction,
91
- children: flattenedChildren.map((child, index) => {
92
- if (!child || !(0, import_react.isValidElement)(child)) return null;
93
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
94
- child,
95
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
- import_FlexLayoutHooks.ContainerOpenCloseProvider,
97
- {
98
- layoutName,
99
- containerName: child.props.containerName,
100
- sizeName: fitContent
101
- }
102
- )
103
- ] }, index);
104
- })
105
- }
106
- )
107
- }
108
- ) });
109
- }
110
- //# sourceMappingURL=FlexLayout.cjs.map
1
+ "use strict";"use client";var E=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of P(t))!w.call(e,l)&&l!==n&&m(e,l,{get:()=>t[l],enumerable:!(o=L(t,l))||o.enumerable});return e};var T=(e,t,n)=>(n=e!=null?E(R(e)):{},y(t||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e)),A=e=>y(m({},"__esModule",{value:!0}),e);var O={};N(O,{default:()=>p});module.exports=A(O);var i=require("react/jsx-runtime"),r=require("react"),F=require("../providers/FlexLayoutHooks"),c=T(require("../styles/FlexLayout.module.css"),1),d=require("../providers/FlexLayoutContext");const B=(e,t,n)=>o=>o.type===r.Fragment||o.type==="div"||o.type==="span"?o:(0,r.cloneElement)(o,{layoutName:e,fitContent:t,containerCount:n});function p({layoutName:e,direction:t,children:n,ref:o,className:l,panelClassName:f,panelMovementMode:x="divorce",...h}){const g=r.Children.count(n),s=t==="row"?"width":"height",v=a=>(0,r.isValidElement)(a)&&a.type===r.Fragment,u=r.Children.toArray(n).flatMap(a=>v(a)?r.Children.toArray(a.props.children):[a]).filter(r.isValidElement);return u.length===0?null:(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(d.FlexLayoutProvider,{value:{layoutName:e,direction:t,panelMovementMode:x,panelClassName:f,containerCount:g,fitContent:s},children:(0,i.jsx)("div",{className:`${c.default["flex-layout"]} ${l&&l!==""?l:""}`,...o?{ref:o}:{},...h,"data-layout_name":e,"data-direction":t,children:u.map((a,C)=>!a||!(0,r.isValidElement)(a)?null:(0,i.jsxs)(r.Fragment,{children:[a,(0,i.jsx)(F.ContainerOpenCloseProvider,{layoutName:e,containerName:a.props.containerName,sizeName:s})]},C))})})})}
@@ -1,85 +1 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import {
4
- Children,
5
- cloneElement,
6
- Fragment as Fragment2,
7
- isValidElement
8
- } from "react";
9
- import { ContainerOpenCloseProvider } from "../providers/FlexLayoutHooks";
10
- import styles from "../styles/FlexLayout.module.css";
11
- import { FlexLayoutProvider } from "../providers/FlexLayoutContext";
12
- const withFlexLayout = (layoutName, fitContent, containerCount) => (WrappedComponent) => {
13
- if (WrappedComponent.type === Fragment2 || WrappedComponent.type === "div" || WrappedComponent.type === "span") {
14
- return WrappedComponent;
15
- }
16
- return cloneElement(WrappedComponent, {
17
- layoutName,
18
- fitContent,
19
- containerCount
20
- });
21
- };
22
- function FlexLayout({
23
- layoutName,
24
- direction,
25
- children,
26
- ref,
27
- className,
28
- panelClassName,
29
- panelMovementMode = "divorce",
30
- ...props
31
- }) {
32
- const containerCount = Children.count(children);
33
- const fitContent = direction === "row" ? "width" : "height";
34
- const isFragmentElement = (node) => isValidElement(node) && node.type === Fragment2;
35
- const nodes = Children.toArray(children).flatMap(
36
- (node) => isFragmentElement(node) ? Children.toArray(node.props.children) : [node]
37
- );
38
- const flattenedChildren = nodes.filter(
39
- isValidElement
40
- );
41
- if (flattenedChildren.length === 0) {
42
- return null;
43
- }
44
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
45
- FlexLayoutProvider,
46
- {
47
- value: {
48
- layoutName,
49
- direction,
50
- panelMovementMode,
51
- panelClassName,
52
- containerCount,
53
- fitContent
54
- },
55
- children: /* @__PURE__ */ jsx(
56
- "div",
57
- {
58
- className: `${styles["flex-layout"]} ${className && className !== "" ? className : ""}`,
59
- ...ref ? { ref } : {},
60
- ...props,
61
- "data-layout_name": layoutName,
62
- "data-direction": direction,
63
- children: flattenedChildren.map((child, index) => {
64
- if (!child || !isValidElement(child)) return null;
65
- return /* @__PURE__ */ jsxs(Fragment2, { children: [
66
- child,
67
- /* @__PURE__ */ jsx(
68
- ContainerOpenCloseProvider,
69
- {
70
- layoutName,
71
- containerName: child.props.containerName,
72
- sizeName: fitContent
73
- }
74
- )
75
- ] }, index);
76
- })
77
- }
78
- )
79
- }
80
- ) });
81
- }
82
- export {
83
- FlexLayout as default
84
- };
85
- //# sourceMappingURL=FlexLayout.js.map
1
+ "use client";import{Fragment as P,jsx as a,jsxs as L}from"react/jsx-runtime";import{Children as i,cloneElement as h,Fragment as m,isValidElement as s}from"react";import{ContainerOpenCloseProvider as g}from"../providers/FlexLayoutHooks";import v from"../styles/FlexLayout.module.css";import{FlexLayoutProvider as C}from"../providers/FlexLayoutContext";const V=(r,n,o)=>t=>t.type===m||t.type==="div"||t.type==="span"?t:h(t,{layoutName:r,fitContent:n,containerCount:o});function E({layoutName:r,direction:n,children:o,ref:t,className:l,panelClassName:F,panelMovementMode:c="divorce",...d}){const p=i.count(o),u=n==="row"?"width":"height",f=e=>s(e)&&e.type===m,y=i.toArray(o).flatMap(e=>f(e)?i.toArray(e.props.children):[e]).filter(s);return y.length===0?null:a(P,{children:a(C,{value:{layoutName:r,direction:n,panelMovementMode:c,panelClassName:F,containerCount:p,fitContent:u},children:a("div",{className:`${v["flex-layout"]} ${l&&l!==""?l:""}`,...t?{ref:t}:{},...d,"data-layout_name":r,"data-direction":n,children:y.map((e,x)=>!e||!s(e)?null:L(m,{children:[e,a(g,{layoutName:r,containerName:e.props.containerName,sizeName:u})]},x))})})})}export{E as default};
@@ -1,262 +1 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var FlexLayoutContainer_exports = {};
31
- __export(FlexLayoutContainer_exports, {
32
- default: () => FlexLayoutContainer
33
- });
34
- module.exports = __toCommonJS(FlexLayoutContainer_exports);
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = require("react");
37
- var import_useSizes = require("../hooks/useSizes");
38
- var import_FlexLayoutContext = require("../providers/FlexLayoutContext");
39
- var import_FlexLayoutContainerStore = require("../store/FlexLayoutContainerStore");
40
- var import_FlexLayout = __toESM(require("../styles/FlexLayout.module.css"), 1);
41
- var import_FlexLayoutUtils = require("../utils/FlexLayoutUtils");
42
- var import_FlexLayoutResizePanel = __toESM(require("./FlexLayoutResizePanel"), 1);
43
- function FlexLayoutContainer({
44
- isFitContent,
45
- isFitResize,
46
- // fitContent,
47
- // containerCount,
48
- // layoutName,
49
- containerName,
50
- grow: initialGrow,
51
- prevGrow: initialPrevGrow,
52
- isInitialResizable,
53
- isResizePanel,
54
- children,
55
- className,
56
- panelMode
57
- }) {
58
- const {
59
- direction,
60
- panelMovementMode,
61
- panelClassName,
62
- layoutName,
63
- fitContent,
64
- containerCount
65
- } = (0, import_FlexLayoutContext.useFlexLayoutContext)();
66
- const { ref, size } = (
67
- // isFitContent && fitContent
68
- //?
69
- (0, import_useSizes.useSize)(fitContent)
70
- );
71
- const flexContainerNodeRef = (0, import_react.useRef)(null);
72
- const isUserResizingRef = (0, import_react.useRef)(false);
73
- const handleResizingChange = (0, import_react.useCallback)((v) => {
74
- isUserResizingRef.current = v;
75
- }, []);
76
- const flexContainerRef = (0, import_react.useCallback)(
77
- (node) => {
78
- flexContainerNodeRef.current = node;
79
- if (node) {
80
- (0, import_FlexLayoutContainerStore.setContainerRef)(
81
- layoutName,
82
- containerName,
83
- flexContainerNodeRef
84
- );
85
- } else {
86
- (0, import_FlexLayoutContainerStore.setContainerRef)(layoutName, containerName, null);
87
- }
88
- },
89
- [layoutName, containerName]
90
- );
91
- const [growState, setGrowState] = (0, import_react.useState)(initialGrow);
92
- (0, import_react.useEffect)(() => {
93
- setGrowState(initialGrow);
94
- }, [initialGrow]);
95
- const [prevGrowState, setPrevGrowState] = (0, import_react.useState)(
96
- initialPrevGrow
97
- );
98
- const [isFirstLoad, setIsFirstLoad] = (0, import_react.useState)(true);
99
- (0, import_react.useEffect)(() => {
100
- if (typeof window == "undefined" || flexContainerNodeRef.current === null)
101
- return;
102
- const storedGrow = sessionStorage.getItem(containerName);
103
- if (storedGrow !== null) {
104
- const parsed = parseFloat(storedGrow);
105
- if (!isNaN(parsed)) {
106
- flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
107
- setGrowState(parsed);
108
- }
109
- }
110
- }, [containerName]);
111
- (0, import_react.useEffect)(() => {
112
- if (!flexContainerNodeRef.current) return;
113
- const targetNode = flexContainerNodeRef.current;
114
- const observer = new MutationObserver((mutations) => {
115
- for (const mutation of mutations) {
116
- if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
117
- const flexValue = targetNode.style.flex;
118
- const parsedGrow = parseFloat(flexValue.split(" ")[0]);
119
- if (!isNaN(parsedGrow)) {
120
- setGrowState(parsedGrow);
121
- }
122
- }
123
- }
124
- });
125
- observer.observe(targetNode, {
126
- attributes: true,
127
- attributeFilter: ["style"],
128
- attributeOldValue: true
129
- });
130
- return () => {
131
- observer.disconnect();
132
- };
133
- }, [containerName]);
134
- (0, import_react.useEffect)(() => {
135
- if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent || // getGrow(flexContainerNodeRef.current) == 0 ||
136
- isUserResizingRef.current)
137
- return;
138
- requestAnimationFrame(() => {
139
- if (!flexContainerNodeRef.current) return;
140
- const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
141
- const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
142
- if (isFitContent) {
143
- flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
144
- }
145
- if (!isFitResize && isFirstLoad) {
146
- setIsFirstLoad(false);
147
- return;
148
- }
149
- if ((0, import_FlexLayoutUtils.getGrow)(flexContainerNodeRef.current) != 0 && isFitResize) {
150
- const newGrow = (0, import_FlexLayoutUtils.mathGrow)(size, parentSize, containerCount);
151
- setPrevGrowState(growState);
152
- setGrowState(newGrow);
153
- }
154
- });
155
- }, [size, containerCount, isFitResize, children]);
156
- (0, import_react.useEffect)(() => {
157
- if (!flexContainerNodeRef.current) return;
158
- let notGrowList = [];
159
- let containerList = [
160
- ...flexContainerNodeRef.current.parentElement?.children || []
161
- ].filter((e) => e.hasAttribute("data-container_name"));
162
- let remainingGrow = containerList.reduce((t, e, i) => {
163
- let item = e;
164
- if (item.classList.contains(import_FlexLayout.default["flex-resize-panel"])) return t;
165
- if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
166
- notGrowList.push(item);
167
- return t;
168
- }
169
- let grow = parseFloat(item.dataset.grow || "");
170
- item.style.flex = `${grow} 1 0%`;
171
- t -= grow;
172
- return t;
173
- }, containerList.length);
174
- if (notGrowList.length != 0) {
175
- let resizeWeight = (0, import_FlexLayoutUtils.mathWeight)(notGrowList.length, remainingGrow);
176
- notGrowList.forEach((e) => {
177
- e.dataset.grow = resizeWeight.toString();
178
- e.style.flex = `${resizeWeight} 1 0%`;
179
- });
180
- }
181
- }, []);
182
- (0, import_react.useEffect)(() => {
183
- if (!flexContainerNodeRef.current || !isFitContent || !fitContent || !size || (0, import_FlexLayoutUtils.getGrow)(flexContainerNodeRef.current) == 0)
184
- return;
185
- const parent = flexContainerNodeRef.current.parentElement;
186
- if (!parent) return;
187
- const sizeName = fitContent.charAt(0).toUpperCase() + fitContent.substring(1);
188
- const parentSize = parent["client" + sizeName] || 0;
189
- if (!parentSize || containerCount <= 0) return;
190
- const nextGrowRaw = (0, import_FlexLayoutUtils.mathGrow)(size, parentSize, containerCount);
191
- const nextGrow = Math.min(containerCount, Math.max(0, nextGrowRaw));
192
- const currentGrow = (0, import_FlexLayoutUtils.getGrow)(flexContainerNodeRef.current);
193
- if (Math.abs(nextGrow - currentGrow) < 1e-3) return;
194
- setPrevGrowState(currentGrow);
195
- setGrowState(nextGrow);
196
- const containers = [...parent.children || []].filter((el) => {
197
- const item = el;
198
- return item.hasAttribute("data-container_name") && !item.classList.contains(import_FlexLayout.default["flex-resize-panel"]);
199
- });
200
- const siblings = containers.filter(
201
- (el) => el !== flexContainerNodeRef.current
202
- );
203
- const adjustable = siblings.filter((el) => el.style.flex !== "0 1 0%");
204
- const remaining = containerCount - nextGrow;
205
- if (remaining <= 0 || adjustable.length === 0) return;
206
- const oldSum = adjustable.reduce((sum, el) => sum + (0, import_FlexLayoutUtils.getGrow)(el), 0);
207
- if (oldSum <= 0) {
208
- const each = remaining / adjustable.length;
209
- adjustable.forEach((el) => {
210
- el.dataset.grow = each.toString();
211
- el.style.flex = `${each} 1 0%`;
212
- });
213
- } else {
214
- adjustable.forEach((el) => {
215
- const g = (0, import_FlexLayoutUtils.getGrow)(el);
216
- const scaled = remaining * (g / oldSum);
217
- el.dataset.grow = scaled.toString();
218
- el.style.flex = `${scaled} 1 0%`;
219
- });
220
- }
221
- }, [size, isFitContent, fitContent, containerCount]);
222
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
223
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
224
- "div",
225
- {
226
- id: containerName,
227
- "data-container_name": containerName,
228
- ref: flexContainerRef,
229
- className: `${import_FlexLayout.default["flex-container"]} ${className && className !== "" ? className : ""}`,
230
- ...growState !== void 0 ? { ["data-grow"]: growState } : {},
231
- ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
232
- "data-is_resize": isInitialResizable,
233
- "data-is_resize_panel": isResizePanel,
234
- style: growState !== void 0 && {
235
- flex: `${growState} 1 0%`
236
- } || {},
237
- children: isFitContent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
- "div",
239
- {
240
- className: `${import_FlexLayout.default["flex-content-fit-wrapper"]}`,
241
- ref,
242
- children
243
- }
244
- ) || children
245
- }
246
- ),
247
- isResizePanel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
248
- import_FlexLayoutResizePanel.default,
249
- {
250
- containerName,
251
- layoutName,
252
- direction,
253
- containerCount,
254
- panelMode,
255
- panelClassName,
256
- panelMovementMode,
257
- onResizingChange: handleResizingChange
258
- }
259
- )
260
- ] });
261
- }
262
- //# sourceMappingURL=FlexLayoutContainer.cjs.map
1
+ "use strict";"use client";var ee=Object.create;var z=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ae=(t,a)=>{for(var n in a)z(t,n,{get:a[n],enumerable:!0})},U=(t,a,n,w)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of re(a))!se.call(t,h)&&h!==n&&z(t,h,{get:()=>a[h],enumerable:!(w=te(a,h))||w.enumerable});return t};var D=(t,a,n)=>(n=t!=null?ee(ne(t)):{},U(a||!t||!t.__esModule?z(n,"default",{value:t,enumerable:!0}):n,t)),oe=t=>U(z({},"__esModule",{value:!0}),t);var ie={};ae(ie,{default:()=>k});module.exports=oe(ie);var g=require("react/jsx-runtime"),s=require("react"),I=require("../hooks/useSizes"),O=require("../providers/FlexLayoutContext"),F=require("../store/FlexLayoutContainerStore"),E=D(require("../styles/FlexLayout.module.css"),1),c=require("../utils/FlexLayoutUtils"),V=D(require("./FlexLayoutResizePanel"),1);function k({isFitContent:t,isFitResize:a,containerName:n,grow:w,prevGrow:h,isInitialResizable:q,isResizePanel:R,children:S,className:G,panelMode:j}){const{direction:B,panelMovementMode:J,panelClassName:K,layoutName:C,fitContent:d,containerCount:m}=(0,O.useFlexLayoutContext)(),{ref:H,size:x}=(0,I.useSize)(d),r=(0,s.useRef)(null),$=(0,s.useRef)(!1),Q=(0,s.useCallback)(e=>{$.current=e},[]),X=(0,s.useCallback)(e=>{r.current=e,e?(0,F.setContainerRef)(C,n,r):(0,F.setContainerRef)(C,n,null)},[C,n]),[y,L]=(0,s.useState)(w);(0,s.useEffect)(()=>{L(w)},[w]);const[T,N]=(0,s.useState)(h),[Y,Z]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{if(typeof window>"u"||r.current===null)return;const e=sessionStorage.getItem(n);if(e!==null){const l=parseFloat(e);isNaN(l)||(r.current.style.flex=`${l} 1 0%`,L(l))}},[n]),(0,s.useEffect)(()=>{if(!r.current)return;const e=r.current,l=new MutationObserver(p=>{for(const o of p)if(o.type==="attributes"&&o.attributeName==="style"&&e.style.flex){const u=e.style.flex,b=parseFloat(u.split(" ")[0]);isNaN(b)||L(b)}});return l.observe(e,{attributes:!0,attributeFilter:["style"],attributeOldValue:!0}),()=>{l.disconnect()}},[n]),(0,s.useEffect)(()=>{!r.current||!H||!H.current||!x||!d||$.current||requestAnimationFrame(()=>{if(!r.current)return;const e=`${d.charAt(0).toUpperCase()+d.substring(1)}`,l=r.current.parentElement&&r.current.parentElement["client"+e]||0;if(t&&(r.current.style["max"+e]=x+"px"),!a&&Y){Z(!1);return}if((0,c.getGrow)(r.current)!=0&&a){const p=(0,c.mathGrow)(x,l,m);N(y),L(p)}})},[x,m,a,S]),(0,s.useEffect)(()=>{if(!r.current)return;let e=[],l=[...r.current.parentElement?.children||[]].filter(o=>o.hasAttribute("data-container_name")),p=l.reduce((o,u,b)=>{let M=u;if(M.classList.contains(E.default["flex-resize-panel"]))return o;if(u.hasAttribute("data-grow")==!1||u.getAttribute("data-is_resize")==="true")return e.push(M),o;let A=parseFloat(M.dataset.grow||"");return M.style.flex=`${A} 1 0%`,o-=A,o},l.length);if(e.length!=0){let o=(0,c.mathWeight)(e.length,p);e.forEach(u=>{u.dataset.grow=o.toString(),u.style.flex=`${o} 1 0%`})}},[]),(0,s.useEffect)(()=>{if(!r.current||!t||!d||!x||(0,c.getGrow)(r.current)==0||$.current)return;const e=r.current.parentElement;if(!e)return;const l=d.charAt(0).toUpperCase()+d.substring(1),p=e["client"+l]||0;if(!p||m<=0)return;const o=(0,c.mathGrow)(x,p,m),u=Math.min(m,Math.max(0,o)),b=(0,c.getGrow)(r.current);if(Math.abs(u-b)<.001)return;N(b),L(u);const v=[...e.children||[]].filter(i=>{const f=i;return f.hasAttribute("data-container_name")&&!f.classList.contains(E.default["flex-resize-panel"])}).filter(i=>i!==r.current).filter(i=>i.style.flex!=="0 1 0%"),_=m-u;if(_<=0||v.length===0)return;const W=v.reduce((i,f)=>i+(0,c.getGrow)(f),0);if(W<=0){const i=_/v.length;v.forEach(f=>{f.dataset.grow=i.toString(),f.style.flex=`${i} 1 0%`})}else v.forEach(i=>{const f=(0,c.getGrow)(i),P=_*(f/W);i.dataset.grow=P.toString(),i.style.flex=`${P} 1 0%`})},[x,t,d,m]),(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{id:n,"data-container_name":n,ref:X,className:`${E.default["flex-container"]} ${G&&G!==""?G:""}`,...y!==void 0?{"data-grow":y}:{},...T!=null?{"data-prev_grow":T}:{},"data-is_resize":q,"data-is_resize_panel":R,style:y!==void 0&&{flex:`${y} 1 0%`}||{},children:t&&(0,g.jsx)("div",{className:`${E.default["flex-content-fit-wrapper"]}`,ref:H,children:S})||S}),R&&(0,g.jsx)(V.default,{containerName:n,layoutName:C,direction:B,containerCount:m,panelMode:j,panelClassName:K,panelMovementMode:J,onResizingChange:Q})]})}