@codezee/sixtify-brahma 0.2.134 → 0.2.136

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 (33) hide show
  1. package/package.json +1 -1
  2. package/packages/shared-components/dist/ActionButtons/ActionButtons.js +1 -1
  3. package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.d.ts.map +1 -1
  4. package/packages/shared-components/dist/FormFields/FileUpload/FileUpload.js +151 -38
  5. package/packages/shared-components/dist/FormFields/TextField/TextField.d.ts.map +1 -1
  6. package/packages/shared-components/dist/FormFields/TextField/TextField.js +5 -4
  7. package/packages/shared-components/dist/Svgs/SvgBranches.d.ts +8 -0
  8. package/packages/shared-components/dist/Svgs/SvgBranches.d.ts.map +1 -0
  9. package/packages/shared-components/dist/Svgs/SvgBranches.js +23 -0
  10. package/packages/shared-components/dist/Svgs/index.d.ts +2 -0
  11. package/packages/shared-components/dist/Svgs/index.d.ts.map +1 -1
  12. package/packages/shared-components/dist/Svgs/index.js +2 -0
  13. package/packages/shared-components/dist/Tree/DesktopTreeNode.d.ts +10 -0
  14. package/packages/shared-components/dist/Tree/DesktopTreeNode.d.ts.map +1 -0
  15. package/packages/shared-components/dist/Tree/DesktopTreeNode.js +21 -0
  16. package/packages/shared-components/dist/Tree/MobileTreeNode.d.ts +9 -0
  17. package/packages/shared-components/dist/Tree/MobileTreeNode.d.ts.map +1 -0
  18. package/packages/shared-components/dist/Tree/MobileTreeNode.js +17 -0
  19. package/packages/shared-components/dist/Tree/Node.d.ts +9 -0
  20. package/packages/shared-components/dist/Tree/Node.d.ts.map +1 -0
  21. package/packages/shared-components/dist/Tree/Node.js +18 -0
  22. package/packages/shared-components/dist/Tree/Node.styled.d.ts +10 -0
  23. package/packages/shared-components/dist/Tree/Node.styled.d.ts.map +1 -0
  24. package/packages/shared-components/dist/Tree/Node.styled.js +28 -0
  25. package/packages/shared-components/dist/Tree/Tree.d.ts +20 -0
  26. package/packages/shared-components/dist/Tree/Tree.d.ts.map +1 -0
  27. package/packages/shared-components/dist/Tree/Tree.js +147 -0
  28. package/packages/shared-components/dist/Tree/index.d.ts +3 -0
  29. package/packages/shared-components/dist/Tree/index.d.ts.map +1 -0
  30. package/packages/shared-components/dist/Tree/index.js +18 -0
  31. package/packages/shared-components/dist/index.d.ts +1 -0
  32. package/packages/shared-components/dist/index.d.ts.map +1 -1
  33. package/packages/shared-components/dist/index.js +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codezee/sixtify-brahma",
3
- "version": "0.2.134",
3
+ "version": "0.2.136",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
@@ -9,7 +9,7 @@ const material_1 = require("@mui/material");
9
9
  const noop_1 = __importDefault(require("lodash/noop"));
10
10
  const react_1 = require("react");
11
11
  const utils_1 = require("../utils");
12
- function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOpenMenuOnShortcut = false, shortcutKey = "a", }) {
12
+ function ActionButtons({ buttons, justifyContent = "end", sx, buttonSx, shouldOpenMenuOnShortcut = false, shortcutKey = "n", }) {
13
13
  const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
14
14
  const [openMenuKey, setOpenMenuKey] = (0, react_1.useState)(null);
15
15
  const buttonRefs = (0, react_1.useRef)({});
@@ -1 +1 @@
1
- {"version":3,"file":"FileUpload.d.ts","sourceRoot":"","sources":["../../../src/FormFields/FileUpload/FileUpload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAIrB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC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CAAC,GAAG;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC;AAEF,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,OAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,IAAS,EACT,IAAI,EACJ,QAAQ,EACR,MAA6B,EAC7B,WAAsD,EACtD,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CA6RpB"}
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.error_with_transaltion = void 0;
4
7
  exports.FileUpload = FileUpload;
5
8
  const jsx_runtime_1 = require("react/jsx-runtime");
6
9
  const material_1 = require("@mui/material");
7
- const lodash_1 = require("lodash");
10
+ const isFunction_1 = __importDefault(require("lodash/isFunction"));
11
+ const isNull_1 = __importDefault(require("lodash/isNull"));
8
12
  const react_1 = require("react");
9
13
  const react_i18next_1 = require("react-i18next");
10
14
  const PadBox_1 = require("../../PadBox");
@@ -15,53 +19,162 @@ const Skeleton_1 = require("./Skeleton");
15
19
  exports.error_with_transaltion = "error_with_transaltion";
16
20
  function FileUpload({ loading = false, onChange, isDisabled, multiple = false, required = false, error, helperText, label, fileNames, size = 10, name, setError, accept = utils_1.SUPPORTED_FILE_TYPES, acceptTitle = "Only JPG, PNG, PDF files are accepted.", ...restProps }) {
17
21
  const theme = (0, material_1.useTheme)();
18
- const { red, iron } = theme.palette.app.color;
22
+ const { red, iron, black } = theme.palette.app.color;
19
23
  const { t } = (0, react_i18next_1.useTranslation)();
20
24
  const inputRef = (0, react_1.useRef)(null);
21
- // eslint-disable-next-line sonarjs/cognitive-complexity
22
- const handleFileChange = (event) => {
23
- if (event.target.files) {
24
- const files = Array.from(event.target.files);
25
- const uploadFiles = [];
26
- const inValidFiles = [];
27
- let isShowError = false;
28
- for (const element of files) {
29
- if (!(0, utils_1.isFileSizeValid)(element, size)) {
30
- isShowError = true;
31
- inValidFiles.push(t("fileUpload.fileSize.error.message", {
32
- fileName: element.name,
33
- fileSize: size,
34
- }));
35
- }
36
- else if (accept.length && !(0, utils_1.isFileTypeValid)(element, accept)) {
37
- isShowError = true;
38
- inValidFiles.push(t("fileUpload.fileType.error.message", {
39
- fileName: element.name,
40
- }));
41
- }
42
- else {
43
- uploadFiles.push(element);
44
- }
25
+ const dragCounter = (0, react_1.useRef)(0);
26
+ const rafRef = (0, react_1.useRef)(null);
27
+ const animStartRef = (0, react_1.useRef)(null);
28
+ const animFromRef = (0, react_1.useRef)(0);
29
+ const animToRef = (0, react_1.useRef)(0);
30
+ const [dragProgress, setDragProgress] = (0, react_1.useState)(0);
31
+ const easeOutCubic = (x) => 1 - Math.pow(1 - x, 3);
32
+ const processFiles = (files) => {
33
+ const result = files.reduce((acc, currentFile) => {
34
+ const { name } = currentFile;
35
+ if (!(0, utils_1.isFileSizeValid)(currentFile, size)) {
36
+ acc.errors.push(t("fileUpload.fileSize.error.message", {
37
+ fileName: name,
38
+ fileSize: size,
39
+ }));
40
+ return acc;
45
41
  }
46
- if (isShowError) {
47
- if ((0, lodash_1.isFunction)(setError)) {
48
- setError(name, {
49
- type: exports.error_with_transaltion,
50
- message: inValidFiles.join("\n"),
51
- });
52
- }
53
- return;
42
+ if (accept.length && !(0, utils_1.isFileTypeValid)(currentFile, accept)) {
43
+ acc.errors.push(t("fileUpload.fileType.error.message", {
44
+ fileName: name,
45
+ }));
46
+ return acc;
54
47
  }
55
- if (uploadFiles?.length > 0) {
56
- onChange(uploadFiles);
57
- event.target.value = "";
48
+ acc.validFiles.push(currentFile);
49
+ return acc;
50
+ }, { validFiles: [], errors: [] });
51
+ const { errors, validFiles } = result;
52
+ if (errors.length && (0, isFunction_1.default)(setError)) {
53
+ setError(name, {
54
+ type: exports.error_with_transaltion,
55
+ message: errors.join("\n"),
56
+ });
57
+ return;
58
+ }
59
+ if (!validFiles.length) {
60
+ return;
61
+ }
62
+ onChange(validFiles);
63
+ if (inputRef.current) {
64
+ inputRef.current.value = "";
65
+ }
66
+ };
67
+ const handleFileChange = (event) => {
68
+ const files = event.target.files;
69
+ if (files) {
70
+ processFiles(Array.from(files));
71
+ event.target.value = "";
72
+ }
73
+ };
74
+ const animate = (timestamp) => {
75
+ if ((0, isNull_1.default)(animStartRef.current)) {
76
+ animStartRef.current = timestamp;
77
+ }
78
+ const duration = 220;
79
+ const elapsed = Math.min(timestamp - animStartRef.current, duration);
80
+ const tNorm = !duration ? 1 : elapsed / duration;
81
+ const eased = easeOutCubic(tNorm);
82
+ const value = animFromRef.current + (animToRef.current - animFromRef.current) * eased;
83
+ setDragProgress(Number(value.toFixed(3)));
84
+ if (elapsed < duration) {
85
+ rafRef.current = requestAnimationFrame(animate);
86
+ return;
87
+ }
88
+ setDragProgress(animToRef.current);
89
+ animStartRef.current = null;
90
+ rafRef.current = null;
91
+ };
92
+ const animateTo = (target) => {
93
+ const clamped = Math.max(0, Math.min(1, target));
94
+ if (rafRef.current) {
95
+ cancelAnimationFrame(rafRef.current);
96
+ rafRef.current = null;
97
+ }
98
+ animFromRef.current = dragProgress;
99
+ animToRef.current = clamped;
100
+ animStartRef.current = null;
101
+ rafRef.current = requestAnimationFrame(animate);
102
+ };
103
+ (0, react_1.useEffect)(() => {
104
+ // useEffect ensures RAF cleanup happens when the component unmounts
105
+ return () => {
106
+ if (rafRef.current) {
107
+ cancelAnimationFrame(rafRef.current);
108
+ rafRef.current = null;
58
109
  }
110
+ };
111
+ }, []);
112
+ const handleDragEnter = (e) => {
113
+ e.preventDefault();
114
+ e.stopPropagation();
115
+ if (isDisabled) {
116
+ return;
117
+ }
118
+ dragCounter.current += 1;
119
+ if (dragCounter.current) {
120
+ animateTo(1);
121
+ }
122
+ };
123
+ const handleDragOver = (e) => {
124
+ e.preventDefault();
125
+ e.stopPropagation();
126
+ if (isDisabled) {
127
+ return;
128
+ }
129
+ if (e.dataTransfer) {
130
+ e.dataTransfer.dropEffect = "copy";
131
+ }
132
+ };
133
+ const handleDragLeave = (e) => {
134
+ e.preventDefault();
135
+ e.stopPropagation();
136
+ if (isDisabled) {
137
+ return;
138
+ }
139
+ dragCounter.current -= 1;
140
+ if (dragCounter.current <= 0) {
141
+ dragCounter.current = 0;
142
+ animateTo(0);
143
+ }
144
+ };
145
+ const handleDrop = (e) => {
146
+ e.preventDefault();
147
+ e.stopPropagation();
148
+ if (isDisabled) {
149
+ return;
150
+ }
151
+ dragCounter.current = 0;
152
+ animateTo(0);
153
+ const dt = e.dataTransfer;
154
+ if (!dt) {
155
+ return;
156
+ }
157
+ const { files } = dt;
158
+ if (!files?.length) {
159
+ return;
160
+ }
161
+ const fileArray = Array.from(files);
162
+ processFiles(fileArray);
163
+ if (inputRef.current) {
164
+ inputRef.current.value = "";
59
165
  }
60
166
  };
61
167
  if (loading) {
62
168
  return (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {});
63
169
  }
64
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { disabled: isDisabled, required: required, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), error: error, disabled: isDisabled, ...restProps, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileInput, { disabled: isDisabled, type: "file", accept: accept.toString(), ref: inputRef, onChange: handleFileChange, multiple: multiple }), (0, jsx_runtime_1.jsx)(Svgs_1.SvgDrop, { disabled: isDisabled }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: isDisabled ? iron[800] : "revert-layer", children: "Drag & drop files or Browse" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: isDisabled ? iron[800] : "revert-layer", children: acceptTitle })] }) }) }), error && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: {
170
+ const boxShadowIntensity = 0.08 + 0.12 * dragProgress;
171
+ const scale = 1 + 0.02 * dragProgress;
172
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "5px", children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { disabled: isDisabled, required: required, children: label }), (0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileUploadContainer, { onClick: () => inputRef.current?.click(), onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, error: error, disabled: isDisabled, sx: {
173
+ transform: `scale(${scale})`,
174
+ transition: "transform 30ms linear",
175
+ boxShadow: `0 0px ${12 * dragProgress}px ${(0, material_1.alpha)(black[900], boxShadowIntensity)}`,
176
+ cursor: isDisabled ? "not-allowed" : "pointer",
177
+ }, ...restProps, children: (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: "20px" }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: "4px", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(FileUpload_styled_1.FileInput, { disabled: isDisabled, type: "file", accept: accept.toString(), ref: inputRef, onChange: handleFileChange, multiple: multiple }), (0, jsx_runtime_1.jsx)(Svgs_1.SvgDrop, { disabled: isDisabled }), (0, jsx_runtime_1.jsx)(material_1.Typography, { color: isDisabled ? iron[800] : "revert-layer", children: "Drag & drop files or Browse" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", color: isDisabled ? iron[800] : "revert-layer", children: acceptTitle })] }) }) }), error && ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: {
65
178
  color: `${red[900]}`,
66
179
  whiteSpace: "pre",
67
180
  textWrap: "wrap",
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/FormFields/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,IAAI,iBAAiB,EACxC,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAWzB,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,eAAe,GACf,uBAAuB,GACvB,gBAAgB,GAChB,oBAAoB,GACpB,QAAQ,CAAC;AAEb,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;AAY7D,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB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AC;CACH,CAAC;AAEJ,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAAE,EAC/C,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,KAAU,EACV,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAe,EACf,WAAgB,EAChB,YAAoB,EACpB,mBAA2B,EAC3B,IAAI,EACJ,aAAuC,EACvC,UAAoB,EACpB,QAAQ,EACR,cAAc,EACd,OAAkB,EAClB,WAAW,EACX,eAGC,EACD,GAAG,eAAe,EACnB,EAAE,cAAc,CAAC,CAAC,CAAC,2CAoJnB"}
@@ -73,7 +73,8 @@ function TextField({ control, name, defaultValue, label = "", rules, type, requi
73
73
  } }) }))] })), (0, jsx_runtime_1.jsx)(material_1.TextField, { disabled: disabled, required: required, fullWidth: true, onKeyDown: handleKeyDown, placeholder: styling === "default" ? placeholder : placeholder || label, type: type, label: styling === "default" ? label : undefined, sx: (0, commonStyles_1.getDefaultTextFieldSx)(styling), InputLabelProps: (0, commonStyles_1.getDefaultInputLabelProps)(styling), inputProps: {
74
74
  min: 0,
75
75
  }, error: Boolean(error), helperText: error?.message, onChange: (event) => {
76
- const { selectionStart, selectionEnd, setSelectionRange } = event.target;
76
+ const input = event.target;
77
+ const { selectionStart, selectionEnd } = input;
77
78
  let value = event.target.value || null;
78
79
  if (typeof value === "string" && value.trim() === "") {
79
80
  value = null;
@@ -97,8 +98,8 @@ function TextField({ control, name, defaultValue, label = "", rules, type, requi
97
98
  else {
98
99
  onChange(cleanedVal);
99
100
  }
100
- setTimeout(() => {
101
- setSelectionRange(selectionStart, selectionEnd);
102
- }, 0);
101
+ requestAnimationFrame(() => {
102
+ input.setSelectionRange(selectionStart, selectionEnd);
103
+ });
103
104
  }, value: typeof value === "string" ? value.trimStart() : (value ?? ""), ...restField, ...inputFieldProps })] }));
104
105
  }
@@ -0,0 +1,8 @@
1
+ export type PathDefinition = {
2
+ definition: string;
3
+ };
4
+ export declare const SvgBranches: import("react").ForwardRefExoticComponent<Readonly<{
5
+ paths: PathDefinition[];
6
+ strokeColor?: string;
7
+ }> & import("react").RefAttributes<SVGSVGElement>>;
8
+ //# sourceMappingURL=SvgBranches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SvgBranches.d.ts","sourceRoot":"","sources":["../../src/Svgs/SvgBranches.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAOF,eAAO,MAAM,WAAW;WAJf,cAAc,EAAE;kBACT,MAAM;kDAqCrB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SvgBranches = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const material_1 = require("@mui/material");
9
+ const map_1 = __importDefault(require("lodash/map"));
10
+ const react_1 = require("react");
11
+ exports.SvgBranches = (0, react_1.forwardRef)(({ paths, strokeColor }, ref) => {
12
+ const theme = (0, material_1.useTheme)();
13
+ const { butterflyBlue } = theme.palette.app.color;
14
+ const color = strokeColor ?? butterflyBlue[900];
15
+ return ((0, jsx_runtime_1.jsx)("svg", { ref: ref, style: {
16
+ position: "absolute",
17
+ left: 0,
18
+ top: 0,
19
+ pointerEvents: "none",
20
+ overflow: "visible",
21
+ }, children: (0, map_1.default)(paths, ({ definition }) => ((0, jsx_runtime_1.jsx)("path", { d: definition, stroke: color, strokeWidth: 2, fill: "none", strokeLinecap: "round", strokeLinejoin: "round", opacity: 0.95 }, definition))) }));
22
+ });
23
+ exports.SvgBranches.displayName = "SvgBranches";
@@ -33,6 +33,8 @@ export * from "./SvgPageNotFound";
33
33
  export * from "./SvgProfile";
34
34
  export * from "./SvgReGenerate";
35
35
  export * from "./SvgView";
36
+ export * from "./SvgKeyBoard";
37
+ export * from "./SvgBranches";
36
38
  export * from "./SvgEmail";
37
39
  export * from "./SvgIndicator";
38
40
  export * from "./SvgPhone";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Svgs/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Svgs/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -49,6 +49,8 @@ __exportStar(require("./SvgPageNotFound"), exports);
49
49
  __exportStar(require("./SvgProfile"), exports);
50
50
  __exportStar(require("./SvgReGenerate"), exports);
51
51
  __exportStar(require("./SvgView"), exports);
52
+ __exportStar(require("./SvgKeyBoard"), exports);
53
+ __exportStar(require("./SvgBranches"), exports);
52
54
  __exportStar(require("./SvgEmail"), exports);
53
55
  __exportStar(require("./SvgIndicator"), exports);
54
56
  __exportStar(require("./SvgPhone"), exports);
@@ -0,0 +1,10 @@
1
+ import type { Nodes } from "./Tree";
2
+ type DesktopTreeNodeProps = Readonly<{
3
+ node: Nodes;
4
+ setRef: (id: string, element: HTMLDivElement | null) => void;
5
+ themeColor?: string;
6
+ itemWidth: string;
7
+ }>;
8
+ export declare const DesktopTreeNode: ({ node, setRef, themeColor, itemWidth, }: DesktopTreeNodeProps) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=DesktopTreeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DesktopTreeNode.d.ts","sourceRoot":"","sources":["../../src/Tree/DesktopTreeNode.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,eAAO,MAAM,eAAe,GAAI,0CAK7B,oBAAoB,4CAqCtB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DesktopTreeNode = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const material_1 = require("@mui/material");
9
+ const map_1 = __importDefault(require("lodash/map"));
10
+ const Node_1 = require("./Node");
11
+ const DesktopTreeNode = ({ node, setRef, themeColor, itemWidth, }) => {
12
+ const { id, children } = node;
13
+ const hasChildren = !!children?.length;
14
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
15
+ display: "flex",
16
+ gap: 3,
17
+ alignItems: "flex-start",
18
+ flex: `1 0 ${itemWidth}`,
19
+ }, children: [(0, jsx_runtime_1.jsx)(Node_1.Node, { node: node, isParent: hasChildren, innerRef: (el) => setRef(id, el), themeColor: themeColor }), hasChildren && ((0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 1, sx: { mt: 0.5 }, children: (0, map_1.default)(children, (child) => ((0, jsx_runtime_1.jsx)(exports.DesktopTreeNode, { node: child, setRef: setRef, themeColor: themeColor, itemWidth: itemWidth }, child.id))) }))] }, id));
20
+ };
21
+ exports.DesktopTreeNode = DesktopTreeNode;
@@ -0,0 +1,9 @@
1
+ import type { Nodes } from "./Tree";
2
+ type MobileTreeNodeProps = Readonly<{
3
+ node: Nodes;
4
+ setRef: (id: string, element: HTMLDivElement | null) => void;
5
+ themeColor?: string;
6
+ }>;
7
+ export declare const MobileTreeNode: ({ node, setRef, themeColor, }: MobileTreeNodeProps) => import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=MobileTreeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MobileTreeNode.d.ts","sourceRoot":"","sources":["../../src/Tree/MobileTreeNode.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,KAAK,mBAAmB,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,+BAI5B,mBAAmB,4CA8BrB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MobileTreeNode = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const material_1 = require("@mui/material");
9
+ const map_1 = __importDefault(require("lodash/map"));
10
+ const PadBox_1 = require("../PadBox");
11
+ const Node_1 = require("./Node");
12
+ const MobileTreeNode = ({ node, setRef, themeColor, }) => {
13
+ const { id, children } = node;
14
+ const hasChildren = !!children?.length;
15
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 1, children: [(0, jsx_runtime_1.jsx)(Node_1.Node, { node: node, isParent: hasChildren, innerRef: (el) => setRef(id, el), themeColor: themeColor }), hasChildren && ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { paddingLeft: 3, paddingTop: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 1, children: (0, map_1.default)(children, (child) => ((0, jsx_runtime_1.jsx)(exports.MobileTreeNode, { node: child, setRef: setRef, themeColor: themeColor }, child.id))) }) }))] }, id));
16
+ };
17
+ exports.MobileTreeNode = MobileTreeNode;
@@ -0,0 +1,9 @@
1
+ import type { Nodes } from "./Tree";
2
+ export type NodeProps = Readonly<{
3
+ node: Nodes;
4
+ innerRef?: React.RefCallback<HTMLDivElement>;
5
+ isParent?: boolean;
6
+ themeColor?: string;
7
+ }>;
8
+ export declare const Node: ({ node, innerRef, isParent, themeColor, }: NodeProps) => import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=Node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Node.d.ts","sourceRoot":"","sources":["../../src/Tree/Node.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,IAAI,GAAI,2CAKlB,SAAS,4CA4CX,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Node = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ const PadBox_1 = require("../PadBox");
7
+ const Node_styled_1 = require("./Node.styled");
8
+ const Node = ({ node, innerRef, isParent = false, themeColor, }) => {
9
+ const { id, title, subtitle, value } = node;
10
+ const theme = (0, material_1.useTheme)();
11
+ const { butterflyBlue, slate } = theme.palette.app.color;
12
+ const baseColor = themeColor ?? butterflyBlue[900];
13
+ const nodeBorderColor = isParent ? baseColor : (0, material_1.alpha)(baseColor, 0.7);
14
+ const nodeBackgroundColor = isParent ? (0, material_1.alpha)(baseColor, 0.1) : "none";
15
+ const nodeSubtitleColor = slate[900];
16
+ return ((0, jsx_runtime_1.jsxs)(Node_styled_1.StyledNodePaper, { elevation: isParent ? 3 : 0, ref: innerRef, isParent: isParent, borderColor: nodeBorderColor, backgroundColor: nodeBackgroundColor, baseColor: baseColor, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", noWrap: true, children: title }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "subtitle2", color: nodeSubtitleColor, noWrap: true, children: subtitle })] }), (0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { paddingLeft: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { ml: "auto", textAlign: "right" }, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { noWrap: true, variant: "body2", children: value }) }) })] }, id));
17
+ };
18
+ exports.Node = Node;
@@ -0,0 +1,10 @@
1
+ import type { PaperProps } from "@mui/material";
2
+ import type React from "react";
3
+ export type StyledNodePaperProps = {
4
+ isParent: boolean;
5
+ borderColor: string;
6
+ backgroundColor: string;
7
+ baseColor: string;
8
+ };
9
+ export declare const StyledNodePaper: React.ComponentType<PaperProps & StyledNodePaperProps>;
10
+ //# sourceMappingURL=Node.styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Node.styled.d.ts","sourceRoot":"","sources":["../../src/Tree/Node.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAC/C,UAAU,GAAG,oBAAoB,CA0BlC,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StyledNodePaper = void 0;
4
+ const material_1 = require("@mui/material");
5
+ const styles_1 = require("@mui/material/styles");
6
+ exports.StyledNodePaper = (0, styles_1.styled)(material_1.Paper, {
7
+ shouldForwardProp: (prop) => prop !== "$isParent" &&
8
+ prop !== "$borderColor" &&
9
+ prop !== "$backgroundColor" &&
10
+ prop !== "$baseColor",
11
+ })(({ theme, isParent, borderColor, backgroundColor, baseColor }) => ({
12
+ width: "auto",
13
+ minWidth: 0,
14
+ padding: theme.spacing(1),
15
+ borderRadius: 12,
16
+ border: `1px solid ${borderColor}`,
17
+ boxShadow: isParent ? `0 6px 18px ${(0, material_1.alpha)(baseColor, 0.2)}` : "none",
18
+ backgroundColor,
19
+ display: "flex",
20
+ alignItems: "center",
21
+ gap: theme.spacing(1),
22
+ minHeight: 40,
23
+ overflow: "hidden",
24
+ flex: "1 1 auto",
25
+ [theme.breakpoints.down("sm")]: {
26
+ flex: "1 1 100%",
27
+ },
28
+ }));
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Nodes type definition.
4
+ * @property id - Must be unique in Every Nodes, including children nodes.
5
+ */
6
+ export type Nodes = {
7
+ id: string;
8
+ title: ReactNode;
9
+ subtitle?: ReactNode;
10
+ value?: string | number;
11
+ children?: Nodes[];
12
+ };
13
+ export type TreeProps = Readonly<{
14
+ nodes: Nodes[];
15
+ direction?: "horizontal" | "vertical";
16
+ columns?: number;
17
+ color?: string;
18
+ }>;
19
+ export declare const Tree: ({ nodes, direction, columns, color, }: TreeProps) => import("react/jsx-runtime").JSX.Element;
20
+ //# sourceMappingURL=Tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../src/Tree/Tree.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOpE;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,eAAO,MAAM,IAAI,GAAI,uCAKlB,SAAS,4CA+QX,CAAC"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tree = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const material_1 = require("@mui/material");
9
+ const forEach_1 = __importDefault(require("lodash/forEach"));
10
+ const map_1 = __importDefault(require("lodash/map"));
11
+ const omit_1 = __importDefault(require("lodash/omit"));
12
+ const values_1 = __importDefault(require("lodash/values"));
13
+ const react_1 = require("react");
14
+ const PadBox_1 = require("../PadBox");
15
+ const Svgs_1 = require("../Svgs");
16
+ const utils_1 = require("../utils");
17
+ const DesktopTreeNode_1 = require("./DesktopTreeNode");
18
+ const MobileTreeNode_1 = require("./MobileTreeNode");
19
+ const Tree = ({ nodes, direction = "horizontal", columns = 3, color, }) => {
20
+ const { isMobile } = (0, utils_1.useGetDeviceType)();
21
+ const refs = (0, react_1.useRef)({});
22
+ const containerRef = (0, react_1.useRef)(null);
23
+ const svgRef = (0, react_1.useRef)(null);
24
+ const resizeObserverRef = (0, react_1.useRef)(null);
25
+ const [paths, setPaths] = (0, react_1.useState)([]);
26
+ const setRef = (id, element) => {
27
+ if (element) {
28
+ refs.current[id] = element;
29
+ if (resizeObserverRef.current) {
30
+ resizeObserverRef.current.observe(element);
31
+ }
32
+ return;
33
+ }
34
+ refs.current = (0, omit_1.default)(refs.current, id);
35
+ };
36
+ const getRectangleElementPosition = (element) => {
37
+ if (!element) {
38
+ return null;
39
+ }
40
+ return element.getBoundingClientRect();
41
+ };
42
+ const createMobilePath = (parentRectangle, currentRectangle, svgRect) => {
43
+ const { left: parentLeft, width: parentWidth, bottom: parentBottom, } = parentRectangle;
44
+ const { left: currentLeft, width: currentWidth, top: currentTop, } = currentRectangle;
45
+ const { left: svgLeft, top: svgTop } = svgRect;
46
+ const startX = parentLeft + parentWidth / 2 - svgLeft;
47
+ const startY = parentBottom - svgTop;
48
+ const endX = currentLeft + currentWidth / 2 - svgLeft;
49
+ const endY = currentTop - svgTop;
50
+ const midY = startY + Math.max(12, (endY - startY) / 2);
51
+ return `M ${startX} ${startY} C ${startX} ${midY} ${endX} ${midY} ${endX} ${endY}`;
52
+ };
53
+ const createDesktopPath = (parentRectangle, currentRectangle, svgRect) => {
54
+ const { right: parentRight, top: parentTop, height: parentHeight, } = parentRectangle;
55
+ const { left: currentLeft, top: currentTop, height: currentHeight, } = currentRectangle;
56
+ const { left: svgLeft, top: svgTop } = svgRect;
57
+ const startX = parentRight - svgLeft;
58
+ const startY = parentTop + parentHeight / 2 - svgTop;
59
+ const endX = currentLeft - svgLeft;
60
+ const endY = currentTop + currentHeight / 2 - svgTop;
61
+ const dx = endX - startX;
62
+ const absDx = Math.abs(dx);
63
+ const curvature = Math.min(120, Math.max(24, absDx / 2));
64
+ const direction = dx >= 0 ? 1 : -1;
65
+ const c1x = startX + curvature * direction;
66
+ const c1y = startY;
67
+ const c2x = endX - curvature * direction;
68
+ const c2y = endY;
69
+ return `M ${startX} ${startY} C ${c1x} ${c1y} ${c2x} ${c2y} ${endX} ${endY}`;
70
+ };
71
+ const computePathsRecursive = (nodeList, svgRect, paths) => {
72
+ (0, forEach_1.default)(nodeList, (node) => {
73
+ const { id, children } = node;
74
+ if (!children?.length) {
75
+ return;
76
+ }
77
+ const parentElement = refs.current[id];
78
+ if (!parentElement) {
79
+ return;
80
+ }
81
+ const parentRectangle = getRectangleElementPosition(parentElement);
82
+ if (!parentRectangle) {
83
+ return;
84
+ }
85
+ (0, forEach_1.default)(children, (child) => {
86
+ const { id, children } = child;
87
+ const currentElement = refs.current[id];
88
+ if (!currentElement) {
89
+ return;
90
+ }
91
+ const currentRectangle = getRectangleElementPosition(currentElement);
92
+ if (!currentRectangle) {
93
+ return;
94
+ }
95
+ const pathData = isMobile || direction === "vertical"
96
+ ? createMobilePath(parentRectangle, currentRectangle, svgRect)
97
+ : createDesktopPath(parentRectangle, currentRectangle, svgRect);
98
+ paths.push({ definition: pathData });
99
+ if (children?.length) {
100
+ computePathsRecursive([child], svgRect, paths);
101
+ }
102
+ });
103
+ });
104
+ };
105
+ const computePaths = () => {
106
+ const svg = svgRef.current;
107
+ const container = containerRef.current;
108
+ if (!svg || !container) {
109
+ return;
110
+ }
111
+ const width = container.clientWidth;
112
+ svg.setAttribute("width", String(width));
113
+ svg.setAttribute("height", "auto");
114
+ const svgRect = container.getBoundingClientRect();
115
+ const newPaths = [];
116
+ computePathsRecursive(nodes, svgRect, newPaths);
117
+ setPaths(newPaths);
118
+ };
119
+ (0, react_1.useEffect)(() => {
120
+ const scheduleCompute = () => {
121
+ return requestAnimationFrame(() => {
122
+ computePaths();
123
+ });
124
+ };
125
+ const initialId = scheduleCompute();
126
+ const observer = new ResizeObserver(scheduleCompute);
127
+ resizeObserverRef.current = observer;
128
+ if (containerRef.current) {
129
+ observer.observe(containerRef.current);
130
+ }
131
+ (0, values_1.default)(refs.current).forEach((el) => observer.observe(el));
132
+ const handleResize = scheduleCompute;
133
+ window.addEventListener("resize", handleResize);
134
+ return () => {
135
+ cancelAnimationFrame(initialId);
136
+ observer.disconnect();
137
+ resizeObserverRef.current = null;
138
+ window.removeEventListener("resize", handleResize);
139
+ };
140
+ }, [nodes, isMobile, direction]);
141
+ const itemWidth = `calc(${100 / columns}% - 24px)`;
142
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { ref: containerRef, variant: "outlined", component: material_1.Paper, position: "relative", sx: {
143
+ overflowX: "hidden",
144
+ overflowY: "visible",
145
+ }, children: [(0, jsx_runtime_1.jsx)(Svgs_1.SvgBranches, { ref: svgRef, paths: paths, strokeColor: color }), isMobile || direction === "vertical" ? ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 3, children: (0, map_1.default)(nodes, (node) => ((0, jsx_runtime_1.jsx)(MobileTreeNode_1.MobileTreeNode, { node: node, setRef: setRef, themeColor: color }, node.id))) }) })) : ((0, jsx_runtime_1.jsx)(PadBox_1.PadBox, { padding: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", alignItems: "flex-start", justifyContent: "flex-start", flexWrap: "wrap", gap: 3, children: (0, map_1.default)(nodes, (node) => ((0, jsx_runtime_1.jsx)(DesktopTreeNode_1.DesktopTreeNode, { node: node, setRef: setRef, themeColor: color, itemWidth: itemWidth }, node.id))) }) }))] }));
146
+ };
147
+ exports.Tree = Tree;
@@ -0,0 +1,3 @@
1
+ export * from "./Tree";
2
+ export * from "./Node";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Tree/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Tree"), exports);
18
+ __exportStar(require("./Node"), exports);
@@ -32,4 +32,5 @@ export * from "./Toast";
32
32
  export * from "./Tooltip";
33
33
  export * from "./UserProfileMenu";
34
34
  export * from "./utils";
35
+ export * from "./Tree";
35
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -48,3 +48,4 @@ __exportStar(require("./Toast"), exports);
48
48
  __exportStar(require("./Tooltip"), exports);
49
49
  __exportStar(require("./UserProfileMenu"), exports);
50
50
  __exportStar(require("./utils"), exports);
51
+ __exportStar(require("./Tree"), exports);