@antscorp/antsomi-ui 1.3.3-beta.4 → 1.3.3-beta.41

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 (197) hide show
  1. package/es/assets/images/iphone-top-bar.png +0 -0
  2. package/es/assets/images/iphone.png +0 -0
  3. package/es/assets/images/stars_slider.png +0 -0
  4. package/es/components/atoms/Input/Input.d.ts +3 -0
  5. package/es/components/atoms/Input/Input.js +4 -3
  6. package/es/components/atoms/InputDynamic/EditCaretPositioning.d.ts +2 -0
  7. package/es/components/atoms/InputDynamic/EditCaretPositioning.js +89 -0
  8. package/es/components/atoms/InputDynamic/InputDynamic.d.ts +30 -0
  9. package/es/components/atoms/InputDynamic/InputDynamic.js +320 -0
  10. package/es/components/atoms/InputDynamic/PopupShortLink.d.ts +16 -0
  11. package/es/components/atoms/InputDynamic/PopupShortLink.js +85 -0
  12. package/es/components/atoms/InputDynamic/index.d.ts +2 -0
  13. package/es/components/atoms/InputDynamic/index.js +1 -0
  14. package/es/components/atoms/InputDynamic/styled.d.ts +12 -0
  15. package/es/components/atoms/InputDynamic/styled.js +281 -0
  16. package/es/components/atoms/InputDynamic/utils.d.ts +22 -0
  17. package/es/components/atoms/InputDynamic/utils.js +751 -0
  18. package/es/components/atoms/MobileFrame/MobileFrame.d.ts +4 -0
  19. package/es/components/atoms/MobileFrame/MobileFrame.js +22 -0
  20. package/es/components/atoms/MobileFrame/constants.d.ts +4 -0
  21. package/es/components/atoms/MobileFrame/constants.js +4 -0
  22. package/es/components/atoms/MobileFrame/index.d.ts +2 -0
  23. package/es/components/atoms/MobileFrame/index.js +1 -0
  24. package/es/components/atoms/MobileFrame/styled.d.ts +3 -0
  25. package/es/components/atoms/MobileFrame/styled.js +33 -0
  26. package/es/components/atoms/Pagination/index.d.ts +1 -0
  27. package/es/components/atoms/PreviewTabs/PreviewTabs.d.ts +7 -0
  28. package/es/components/atoms/PreviewTabs/PreviewTabs.js +67 -0
  29. package/es/components/atoms/PreviewTabs/index.d.ts +2 -0
  30. package/es/components/atoms/PreviewTabs/index.js +1 -0
  31. package/es/components/atoms/PreviewTabs/styled.d.ts +6 -0
  32. package/es/components/atoms/PreviewTabs/styled.js +79 -0
  33. package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
  34. package/es/components/atoms/RateV2/RateV2.js +73 -0
  35. package/es/components/atoms/RateV2/index.d.ts +1 -0
  36. package/es/components/atoms/RateV2/index.js +1 -0
  37. package/es/components/atoms/RequiredLabel/index.d.ts +1 -0
  38. package/es/components/atoms/RequiredLabel/index.js +4 -3
  39. package/es/components/atoms/Slider/index.d.ts +2 -1
  40. package/es/components/atoms/Slider/index.js +7 -14
  41. package/es/components/atoms/SliderV2/index.d.ts +6 -0
  42. package/es/components/atoms/SliderV2/index.js +21 -0
  43. package/es/components/atoms/Spin/Spin.d.ts +2 -1
  44. package/es/components/atoms/Spin/styled.d.ts +1 -1
  45. package/es/components/atoms/index.d.ts +7 -0
  46. package/es/components/atoms/index.js +5 -0
  47. package/es/components/common/ConfigProvider/GlobalStyle.js +66 -2
  48. package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
  49. package/es/components/icons/AudioRecordIcon.d.ts +2 -1
  50. package/es/components/icons/BugIcon.d.ts +2 -1
  51. package/es/components/icons/CameraIcon.d.ts +2 -1
  52. package/es/components/icons/CaptureIcon.d.ts +2 -1
  53. package/es/components/icons/CheckSlimIcon.d.ts +2 -1
  54. package/es/components/icons/CloseIcon.d.ts +2 -1
  55. package/es/components/icons/CommentIcon.d.ts +2 -1
  56. package/es/components/icons/EventIcon.d.ts +2 -1
  57. package/es/components/icons/FreeDrawIcon.d.ts +2 -1
  58. package/es/components/icons/GPTIcon.d.ts +2 -1
  59. package/es/components/icons/GPTIconV2.d.ts +2 -1
  60. package/es/components/icons/GPTIconV3.d.ts +2 -1
  61. package/es/components/icons/HighlightIcon.d.ts +2 -1
  62. package/es/components/icons/IdeaIcon.d.ts +2 -1
  63. package/es/components/icons/InvisibleIcon.d.ts +2 -1
  64. package/es/components/icons/MuteIcon.d.ts +2 -1
  65. package/es/components/icons/OpenUrlIcon.d.ts +2 -1
  66. package/es/components/icons/PauseIcon.d.ts +2 -1
  67. package/es/components/icons/PlaneIcon.d.ts +2 -1
  68. package/es/components/icons/RequestIcon.d.ts +2 -1
  69. package/es/components/icons/StopRecordIcon.d.ts +2 -1
  70. package/es/components/icons/UserIcon.d.ts +2 -1
  71. package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
  72. package/es/components/icons/WarningIcon.d.ts +2 -1
  73. package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
  74. package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
  75. package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
  76. package/es/components/molecules/FontSetting/constants.d.ts +3 -0
  77. package/es/components/molecules/FontSetting/constants.js +22 -0
  78. package/es/components/molecules/FontSetting/index.d.ts +10 -4
  79. package/es/components/molecules/FontSetting/index.js +36 -35
  80. package/es/components/molecules/FontSetting/types.d.ts +1 -1
  81. package/es/components/molecules/Modal/Modal.d.ts +2 -2
  82. package/es/components/molecules/Modal/index.d.ts +1 -0
  83. package/es/components/molecules/Modal/styled.d.ts +1 -1
  84. package/es/components/molecules/ModalV2/ModalV2.d.ts +5 -0
  85. package/es/components/molecules/ModalV2/ModalV2.js +26 -0
  86. package/es/components/molecules/ModalV2/index.d.ts +2 -0
  87. package/es/components/molecules/ModalV2/index.js +1 -0
  88. package/es/components/molecules/ModalV2/styled.d.ts +7 -0
  89. package/es/components/molecules/ModalV2/styled.js +22 -0
  90. package/es/components/molecules/PreviewModal/PreviewModal.d.ts +7 -0
  91. package/es/components/molecules/PreviewModal/PreviewModal.js +30 -0
  92. package/es/components/molecules/PreviewModal/index.d.ts +2 -0
  93. package/es/components/molecules/PreviewModal/index.js +1 -0
  94. package/es/components/molecules/PreviewModal/styled.d.ts +4 -0
  95. package/es/components/molecules/PreviewModal/styled.js +39 -0
  96. package/es/components/molecules/ResizeGrid/ResizeGrid.d.ts +3 -0
  97. package/es/components/molecules/ResizeGrid/ResizeGrid.js +719 -0
  98. package/es/components/molecules/ResizeGrid/components/Cell/Cell.d.ts +3 -0
  99. package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +86 -0
  100. package/es/components/molecules/ResizeGrid/components/Cell/index.d.ts +1 -0
  101. package/es/components/molecules/ResizeGrid/components/Cell/index.js +1 -0
  102. package/es/components/molecules/ResizeGrid/components/Cell/styled.d.ts +3 -0
  103. package/es/components/molecules/ResizeGrid/components/Cell/styled.js +80 -0
  104. package/es/components/molecules/ResizeGrid/constant.d.ts +35 -0
  105. package/es/components/molecules/ResizeGrid/constant.js +111 -0
  106. package/es/components/molecules/ResizeGrid/index.d.ts +2 -0
  107. package/es/components/molecules/ResizeGrid/index.js +1 -0
  108. package/es/components/molecules/ResizeGrid/styled.d.ts +10 -0
  109. package/es/components/molecules/ResizeGrid/styled.js +56 -0
  110. package/es/components/molecules/ResizeGrid/types.d.ts +147 -0
  111. package/es/components/molecules/ResizeGrid/types.js +1 -0
  112. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +9 -0
  113. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +49 -0
  114. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.d.ts +10 -0
  115. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.js +47 -0
  116. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.d.ts +8 -0
  117. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.js +36 -0
  118. package/es/components/molecules/RichMenu/RichMenuBlock/constants.d.ts +2 -0
  119. package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +765 -0
  120. package/es/components/molecules/RichMenu/RichMenuBlock/index.d.ts +3 -0
  121. package/es/components/molecules/RichMenu/RichMenuBlock/index.js +2 -0
  122. package/es/components/molecules/RichMenu/RichMenuBlock/styled.d.ts +9 -0
  123. package/es/components/molecules/RichMenu/RichMenuBlock/styled.js +17 -0
  124. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +10 -0
  125. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +32 -0
  126. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.d.ts +6 -0
  127. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.js +15 -0
  128. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.d.ts +4 -0
  129. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.js +47 -0
  130. package/es/components/molecules/RichMenu/RichMenuChatBar/index.d.ts +2 -0
  131. package/es/components/molecules/RichMenu/RichMenuChatBar/index.js +1 -0
  132. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +9 -0
  133. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +37 -0
  134. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +10 -0
  135. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +37 -0
  136. package/es/components/molecules/RichMenu/RichMenuMobileView/index.d.ts +1 -0
  137. package/es/components/molecules/RichMenu/RichMenuMobileView/index.js +1 -0
  138. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +6 -0
  139. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +20 -0
  140. package/es/components/molecules/RichMenu/index.d.ts +3 -0
  141. package/es/components/molecules/RichMenu/index.js +3 -0
  142. package/es/components/molecules/Select/Select.d.ts +4 -2
  143. package/es/components/molecules/Select/Test.d.ts +2 -1
  144. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +4 -2
  145. package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
  146. package/es/components/molecules/index.d.ts +6 -0
  147. package/es/components/molecules/index.js +4 -0
  148. package/es/components/organism/Help/styled.d.ts +6 -2
  149. package/es/constants/index.d.ts +1 -0
  150. package/es/constants/index.js +1 -0
  151. package/es/constants/richMenu.d.ts +19 -0
  152. package/es/constants/richMenu.js +19 -0
  153. package/es/constants/storybook.d.ts +2 -1
  154. package/es/constants/theme.js +13 -2
  155. package/es/hooks/useDeepCompareEffect.d.ts +1 -0
  156. package/es/hooks/useDeepCompareEffect.js +21 -0
  157. package/es/locales/en/translation.json +3 -1
  158. package/es/locales/i18n.d.ts +3 -0
  159. package/es/locales/translations.d.ts +2 -0
  160. package/es/locales/vi/translation.json +2 -1
  161. package/es/test.d.ts +2 -1
  162. package/es/test.js +164 -66
  163. package/es/types/index.d.ts +12 -0
  164. package/es/types/index.js +2 -1
  165. package/es/types/richMenu.d.ts +191 -0
  166. package/es/types/richMenu.js +1 -0
  167. package/es/types/variables.d.ts +2 -0
  168. package/es/types/variables.js +1 -0
  169. package/es/utils/common.d.ts +2 -0
  170. package/es/utils/common.js +16 -0
  171. package/es/utils/handleError.d.ts +32 -2
  172. package/es/utils/handleError.js +42 -4
  173. package/package.json +8 -6
  174. package/dist/0173b5993573afa04880.woff +0 -0
  175. package/dist/0dfb9214dfd945cd7290.png +0 -1
  176. package/dist/2883cad25a2b4e87ce5f.eot +0 -0
  177. package/dist/4f54a37971347e3d7122.png +0 -1
  178. package/dist/574b7bee0563a9fe9a29.png +0 -1
  179. package/dist/6b586356e837581204dc.svg +0 -1
  180. package/dist/72eec5c1c786b45a667f.ttf +0 -0
  181. package/dist/bc6bf11c6f5e6743aa4c.png +0 -1
  182. package/dist/dbc405edd6e0806efbc9.svg +0 -1
  183. package/dist/e32f09119052a55cce3c.png +0 -1
  184. package/dist/e3851b9384a984c6fdb5.png +0 -1
  185. package/dist/index.js +0 -2
  186. package/dist/index.js.LICENSE.txt +0 -69
  187. package/dist/main.css +0 -69
  188. package/dist/public/icons/2d496b55d85a9545d7311c073af442bb.png +0 -0
  189. package/dist/public/icons/2fbb4e0927d18e3f8e5c6511ab88d5b3.png +0 -0
  190. package/dist/public/icons/725a52bd91a3ce534b10833df510e5fa.png +0 -0
  191. package/dist/public/icons/7d037e0b378e87a82804443636cd0e13.svg +0 -346
  192. package/dist/public/icons/90553767e0a05b9585a54797cfd9ce51.png +0 -0
  193. package/dist/public/icons/bb64e23a1ff390a416d765ee556096ab.svg +0 -87
  194. package/dist/public/icons/d327b24e9c5d8f486f08d253aab58ce6.png +0 -0
  195. package/dist/public/icons/f1cf266d0a0a53ce07f2dbb859869b7a.png +0 -0
  196. package/dist/public/icons/placeholder-image.png +0 -0
  197. package/dist/public/icons/transparent.svg +0 -1
@@ -0,0 +1,719 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import React, { useState, useRef, useEffect } from 'react';
22
+ import { Cell } from './components/Cell';
23
+ import { GRID_TEMPLATE, MIN_SIZE, THREADHOLD, buildGrid } from './constant';
24
+ import { StyledGrid, StyledMiddleLayer, StyledBGLayer, StyledLine } from './styled';
25
+ import { useDeepCompareEffect } from '../../../hooks/useDeepCompareEffect';
26
+ const defaultProps = {
27
+ containerStyle: {},
28
+ cellBorder: '1px dotted',
29
+ cellStyle: {},
30
+ cellActiveStyle: { background: '#2f79bf80' },
31
+ isPreview: false,
32
+ isCompact: false,
33
+ delayUpdate: 100,
34
+ selectColor: '#2f79bf80',
35
+ };
36
+ export const ResizeGrid = props => {
37
+ const { containerStyle, cellBorder, cellStyle, cellActiveStyle, isPreview, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, onChange, delayUpdate, selectColor, } = props;
38
+ const [grid, setGrid] = useState(buildGrid(initGrid || GRID_TEMPLATE.GRID_2_3));
39
+ const startRef = useRef(null);
40
+ const startCellRef = useRef(null);
41
+ const selectRef = useRef(null);
42
+ const selectEndRef = useRef(null);
43
+ const gridRef = useRef();
44
+ const containerRef = useRef(null);
45
+ const verticalLineRef = useRef(null);
46
+ const horizontalLineRef = useRef(null);
47
+ const layersRef = useRef(null);
48
+ const cellsRef = useRef({});
49
+ const cordinatesRef = useRef({});
50
+ const onChangeTimoutRef = useRef();
51
+ const onChangeDelayRef = useRef();
52
+ const acceptUpdateRef = useRef(false);
53
+ const firstChangeRef = useRef(true);
54
+ const ctrlKeyRef = useRef(false);
55
+ // console.log('grid', grid)
56
+ function lineVertical(isShow = true, left = 0) {
57
+ if (verticalLineRef.current && layersRef.current) {
58
+ verticalLineRef.current.style.display = isShow ? 'block' : 'none';
59
+ layersRef.current.style.opacity = isShow ? '.5' : '1';
60
+ verticalLineRef.current.style.left = `${left}px`;
61
+ }
62
+ }
63
+ function lineHorizontal(isShow = true, top = 0) {
64
+ if (horizontalLineRef.current && layersRef.current) {
65
+ horizontalLineRef.current.style.display = isShow ? 'block' : 'none';
66
+ layersRef.current.style.opacity = isShow ? '.5' : '1';
67
+ horizontalLineRef.current.style.top = `${top}px`;
68
+ }
69
+ }
70
+ const handleChangeGrid = () => {
71
+ clearTimeout(onChangeTimoutRef.current);
72
+ onChangeTimoutRef.current = setTimeout(() => {
73
+ if (containerRef.current && cellsRef.current && cellsRef.current[0]) {
74
+ const container = containerRef.current.getBoundingClientRect();
75
+ // Object.values(cordinatesRef.current);
76
+ const childs = Object.values(cellsRef.current).map(cell => {
77
+ if (!cell || !cell.current)
78
+ return;
79
+ const childBox = cell.current.getBoundingClientRect();
80
+ return {
81
+ width: childBox.width,
82
+ height: childBox.height,
83
+ x: childBox.x - container.x,
84
+ y: childBox.y - container.y,
85
+ };
86
+ });
87
+ if (typeof onChange === 'function') {
88
+ onChange(grid, childs, firstChangeRef.current ? 'system' : 'user');
89
+ acceptUpdateRef.current = false;
90
+ firstChangeRef.current = false;
91
+ clearTimeout(onChangeDelayRef.current);
92
+ onChangeDelayRef.current = setTimeout(() => {
93
+ acceptUpdateRef.current = true;
94
+ }, delayUpdate);
95
+ }
96
+ }
97
+ }, 300);
98
+ };
99
+ const isFollow = (cell, line, isCol = true) => isCol
100
+ ? (cell.colEnd !== line || !cell.sizeX) && (cell.colStart !== line || !cell.sizeX)
101
+ : (cell.rowEnd !== line || !cell.sizeY) && (cell.rowStart !== line || !cell.sizeY);
102
+ const notFollow = (cell, line, isCol = true) => !isFollow(cell, line, isCol);
103
+ const floorSize = size => Math.floor(size);
104
+ useEffect(() => {
105
+ handleChangeGrid();
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ }, [grid]);
108
+ useDeepCompareEffect(() => {
109
+ // console.log('changed grid', initGrid, acceptUpdateRef.current, initGrid?.rows, initGrid?.cols)
110
+ if (acceptUpdateRef.current && (initGrid === null || initGrid === void 0 ? void 0 : initGrid.rows) && (initGrid === null || initGrid === void 0 ? void 0 : initGrid.cols)) {
111
+ // console.log('apply change...', buildGrid(initGrid))
112
+ firstChangeRef.current = true;
113
+ setGrid(buildGrid(initGrid));
114
+ resetBackgroundCellRef();
115
+ }
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
117
+ }, [initGrid]);
118
+ useEffect(() => {
119
+ const handleMove = e => {
120
+ // Resize Grid
121
+ if (startRef.current && gridRef.current && containerRef.current) {
122
+ const { type, line } = startRef.current;
123
+ const idx = line - 1;
124
+ const { gridTemplateRows, gridTemplateColumns, rows, cols, childs } = gridRef.current;
125
+ if (idx <= 0 || (type === 'row' && idx >= rows) || (type === 'column' && idx >= cols))
126
+ return;
127
+ const { clientX, clientY } = e;
128
+ if (type === 'row') {
129
+ const gridHeight = containerRef.current.offsetHeight;
130
+ const yDistant = clientY - startRef.current.clientY;
131
+ const yPercentDistant = (100 * yDistant) / gridHeight;
132
+ const minPercent = (100 * MIN_SIZE) / gridHeight;
133
+ // console.log('move Y', clientY, yDistant, yPercentDistant);
134
+ const newArr = [...gridTemplateRows];
135
+ newArr[idx - 1] += yPercentDistant;
136
+ newArr[idx] -= yPercentDistant;
137
+ if (newArr[idx - 1] >= minPercent && newArr[idx] >= minPercent) {
138
+ const newChilds = JSON.parse(JSON.stringify(childs));
139
+ let isValidChildSize = true;
140
+ newChilds.forEach((child, idx) => {
141
+ var _a, _b;
142
+ if (isValidChildSize && notFollow(child, (_a = startRef.current) === null || _a === void 0 ? void 0 : _a.line, false)) {
143
+ if (child.rowStart === ((_b = startRef.current) === null || _b === void 0 ? void 0 : _b.line)) {
144
+ if (child.transformY) {
145
+ child.transformY = +child.transformY - yDistant;
146
+ }
147
+ else {
148
+ child.sizeY = +child.sizeY - yDistant;
149
+ }
150
+ }
151
+ else {
152
+ child.transformY &&
153
+ !child.movedBottom &&
154
+ (child.sizeY = +child.sizeY + yDistant);
155
+ }
156
+ // console.log('check...', startRef.current.line, child.transformY, yDistant, +child.transformY - yDistant)
157
+ if (child.sizeY < MIN_SIZE) {
158
+ isValidChildSize = false;
159
+ }
160
+ }
161
+ });
162
+ isValidChildSize &&
163
+ setGrid(Object.assign(Object.assign({}, gridRef.current), { gridTemplateRows: newArr, childs: newChilds }));
164
+ }
165
+ }
166
+ else {
167
+ const xDistant = clientX - startRef.current.clientX;
168
+ const gridWidth = containerRef.current.offsetWidth;
169
+ const xPercentDistant = (100 * xDistant) / gridWidth;
170
+ const minPercent = (100 * MIN_SIZE) / gridWidth;
171
+ // console.log('move X', clientX, xDistant, xPercentDistant);
172
+ const newArr = [...gridTemplateColumns];
173
+ newArr[idx - 1] += xPercentDistant;
174
+ newArr[idx] -= xPercentDistant;
175
+ if (newArr[idx - 1] >= minPercent && newArr[idx] >= minPercent) {
176
+ const newChilds = JSON.parse(JSON.stringify(childs));
177
+ let isValidChildSize = true;
178
+ newChilds.forEach(child => {
179
+ if (isValidChildSize && notFollow(child, line)) {
180
+ if (child.colStart === line) {
181
+ if (child.transformX) {
182
+ child.transformX = +child.transformX - xDistant;
183
+ }
184
+ else {
185
+ child.sizeX = +child.sizeX - xDistant;
186
+ }
187
+ }
188
+ else {
189
+ child.transformX && !child.movedRight && (child.sizeX = +child.sizeX + xDistant);
190
+ }
191
+ // console.log('check...', startRef.current.line, child.transformX, xDistant, +child.transformX - xDistant)
192
+ if (child.sizeX < MIN_SIZE) {
193
+ isValidChildSize = false;
194
+ }
195
+ }
196
+ });
197
+ isValidChildSize &&
198
+ setGrid(Object.assign(Object.assign({}, gridRef.current), { gridTemplateColumns: newArr, childs: newChilds }));
199
+ }
200
+ }
201
+ }
202
+ //-------------------------------------------
203
+ // Resize Cell
204
+ if (startCellRef.current && gridRef.current) {
205
+ const { clientX: startClientX, clientY: startClientY, direction, isRevert, leftCells, rightCells, } = startCellRef.current;
206
+ // const { rowStart, rowEnd, colStart, colEnd, transformX, transformY } = cell;
207
+ // const { gridTemplateRows, gridTemplateColumns, rows, cols, childs } = gridRef.current;
208
+ // if (
209
+ // idx < 0 ||
210
+ // (direction === 'top' && rowStart === 1) ||
211
+ // (direction === 'right' && colEnd === cols + 1) ||
212
+ // (direction === 'bottom' && rowEnd === rows + 1) ||
213
+ // (direction === 'left' && colStart === 1)
214
+ // )
215
+ // return;
216
+ const { clientX, clientY } = e;
217
+ if (['top', 'bottom'].includes(direction)) {
218
+ // const cellHeight = cellRef.current.offsetHeight;
219
+ let yDistant = clientY - startClientY;
220
+ // console.log('move Y', clientY, yDistant);
221
+ if (Math.abs(yDistant) > THREADHOLD) {
222
+ startCellRef.current.fallback = true;
223
+ }
224
+ let isValid = true;
225
+ const mapNewSizeTop = {};
226
+ const mapNewSizeBottom = {};
227
+ const leftKeys = Object.keys(leftCells);
228
+ leftKeys.forEach(cellIdx => {
229
+ const cell = leftCells[cellIdx];
230
+ let newHeight = (cell.sizeY || 0) + yDistant;
231
+ if (newHeight < MIN_SIZE) {
232
+ isValid = false;
233
+ }
234
+ else {
235
+ const cellCordinate = cordinatesRef.current[cellIdx];
236
+ // const cell = gridRef.current.childs[cellIdx];
237
+ const newYEnd = cellCordinate.y + newHeight;
238
+ const nearestCells = Object.entries(cordinatesRef.current).filter(cor => gridRef.current &&
239
+ gridRef.current.childs[cor[0]] &&
240
+ !leftKeys.includes(cor[0]) &&
241
+ gridRef.current.childs[cor[0]].colStart !== cell.colStart &&
242
+ Math.abs(cor[1].yEnd - newYEnd) <= THREADHOLD);
243
+ // console.log('nearestCells', nearestCells, newXEnd, leftKeys, cordinatesRef.current);
244
+ if (nearestCells.length && startCellRef.current) {
245
+ const nearestY = Math.abs(nearestCells[0][1].y - newYEnd) <= THREADHOLD
246
+ ? nearestCells[0][1].y
247
+ : nearestCells[0][1].yEnd;
248
+ const delta = nearestY - newYEnd;
249
+ if (startCellRef.current.fallback ||
250
+ floorSize(cellCordinate.height) !== floorSize(newHeight + delta)) {
251
+ newHeight += delta;
252
+ yDistant += delta;
253
+ lineHorizontal(true, nearestY - 1);
254
+ }
255
+ }
256
+ else {
257
+ lineHorizontal(false);
258
+ }
259
+ mapNewSizeTop[cellIdx] = newHeight;
260
+ }
261
+ });
262
+ Object.keys(rightCells).forEach(cellIdx => {
263
+ const nextCell = rightCells[cellIdx];
264
+ const newHeightNextCell = (nextCell.sizeY || 0) - yDistant;
265
+ if (newHeightNextCell < MIN_SIZE) {
266
+ isValid = false;
267
+ }
268
+ mapNewSizeBottom[cellIdx] = [newHeightNextCell, nextCell];
269
+ });
270
+ if (isValid) {
271
+ const newChilds = [...gridRef.current.childs];
272
+ Object.keys(mapNewSizeTop).forEach(cellIdx => {
273
+ newChilds[cellIdx] = Object.assign(Object.assign({}, newChilds[cellIdx]), { sizeY: mapNewSizeTop[cellIdx], movedBottom: true });
274
+ });
275
+ Object.keys(mapNewSizeBottom).forEach(cellIdx => {
276
+ newChilds[cellIdx] = Object.assign(Object.assign({}, newChilds[cellIdx]), { sizeY: mapNewSizeBottom[cellIdx][0], transformY: (mapNewSizeBottom[cellIdx][1].transformY || 0) + yDistant, movedTop: true });
277
+ });
278
+ setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
279
+ }
280
+ }
281
+ else {
282
+ // const cellWidth = cellRef.current.offsetWidth;
283
+ let xDistant = clientX - startClientX;
284
+ // console.log('move X', clientX, xDistant);
285
+ if (Math.abs(xDistant) > THREADHOLD) {
286
+ startCellRef.current.fallback = true;
287
+ }
288
+ let isValid = true;
289
+ const mapNewSizeLeft = {};
290
+ const mapNewSizeRight = {};
291
+ const mapReset = {};
292
+ const leftKeys = Object.keys(leftCells);
293
+ leftKeys.forEach(cellIdx => {
294
+ const cell = leftCells[cellIdx];
295
+ let newWidth = (cell.sizeX || 0) + xDistant;
296
+ if (newWidth < MIN_SIZE) {
297
+ isValid = false;
298
+ }
299
+ else if (gridRef.current) {
300
+ const cellCordinate = cordinatesRef.current[cellIdx];
301
+ // const cell = gridRef.current.childs[cellIdx];
302
+ const newXEnd = cellCordinate.x + newWidth;
303
+ const nearestCells = Object.entries(cordinatesRef.current).filter(cor => gridRef.current &&
304
+ gridRef.current.childs[cor[0]] &&
305
+ !leftKeys.includes(cor[0]) &&
306
+ gridRef.current.childs[cor[0]].rowStart !== cell.rowStart &&
307
+ Math.abs(cor[1].xEnd - newXEnd) <= THREADHOLD);
308
+ // console.log('nearestCells', nearestCells, newXEnd, leftKeys, cordinatesRef.current);
309
+ if (nearestCells.length && startCellRef.current) {
310
+ const nearestX = Math.abs(nearestCells[0][1].x - newXEnd) <= THREADHOLD
311
+ ? nearestCells[0][1].x
312
+ : nearestCells[0][1].xEnd;
313
+ const delta = nearestX - newXEnd;
314
+ if (startCellRef.current.fallback ||
315
+ floorSize(cellCordinate.width) !== floorSize(newWidth + delta)) {
316
+ newWidth += delta;
317
+ xDistant += delta;
318
+ lineVertical(true, nearestX - 1);
319
+ }
320
+ }
321
+ else {
322
+ lineVertical(false);
323
+ }
324
+ mapNewSizeLeft[cellIdx] = newWidth;
325
+ }
326
+ });
327
+ Object.keys(rightCells).forEach(cellIdx => {
328
+ const nextCell = rightCells[cellIdx];
329
+ const newWidthNextCell = (nextCell.sizeX || 0) - xDistant;
330
+ if (newWidthNextCell < MIN_SIZE) {
331
+ isValid = false;
332
+ }
333
+ mapNewSizeRight[cellIdx] = [newWidthNextCell, nextCell];
334
+ });
335
+ if (isValid) {
336
+ const newChilds = [...gridRef.current.childs];
337
+ Object.keys(mapNewSizeLeft).forEach(cellIdx => {
338
+ newChilds[cellIdx] = Object.assign(Object.assign({}, newChilds[cellIdx]), { sizeX: mapNewSizeLeft[cellIdx], movedRight: true });
339
+ });
340
+ Object.keys(mapNewSizeRight).forEach(cellIdx => {
341
+ newChilds[cellIdx] = Object.assign(Object.assign({}, newChilds[cellIdx]), { sizeX: mapNewSizeRight[cellIdx][0], transformX: (mapNewSizeRight[cellIdx][1].transformX || 0) + xDistant, movedLeft: true });
342
+ });
343
+ setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
344
+ }
345
+ }
346
+ }
347
+ //------------------------------------------
348
+ // if (selectRef.current) {}
349
+ };
350
+ const handleUp = () => {
351
+ startRef.current = null;
352
+ startCellRef.current = null;
353
+ lineVertical(false);
354
+ lineHorizontal(false);
355
+ };
356
+ const isMac = () => navigator.platform.indexOf('Mac') >= 0;
357
+ window.addEventListener('mousemove', handleMove);
358
+ window.addEventListener('mouseup', handleUp);
359
+ const handleKeyDown = e => {
360
+ if (!ctrlKeyRef.current && ((isMac() && e.metaKey) || (!isMac() && e.key === 'Control'))) {
361
+ ctrlKeyRef.current = true;
362
+ // console.log('ctrlKeyRef', ctrlKeyRef.current);
363
+ }
364
+ };
365
+ const handleKeyUp = () => {
366
+ ctrlKeyRef.current = false;
367
+ // console.log('ctrlKeyRef', ctrlKeyRef.current);
368
+ };
369
+ window.addEventListener('keydown', handleKeyDown);
370
+ window.addEventListener('keyup', handleKeyUp);
371
+ return () => {
372
+ window.removeEventListener('mousemove', handleMove);
373
+ window.removeEventListener('mouseup', handleUp);
374
+ window.removeEventListener('keydown', handleKeyDown);
375
+ window.removeEventListener('keyup', handleKeyUp);
376
+ };
377
+ }, []);
378
+ // const rebaseCordinate = (x, y, ...rest) => {
379
+ // if (containerRef.current) {
380
+ // const container = containerRef.current.getBoundingClientRect();
381
+ // console.log('rebased', x - container.x, y - container.y, ...rest);
382
+ // }
383
+ // };
384
+ const activeCell = ({ idx }) => {
385
+ setGrid(prev => (Object.assign(Object.assign({}, prev), { childs: prev.childs.map((c, i) => (Object.assign(Object.assign({}, c), { active: i === idx }))) })));
386
+ };
387
+ const findResizeCells = ({ type, line, direction, idx,
388
+ // cell,
389
+ isRevert, leftCols = [], rightCols = [], dones = [], level = 0, }) => {
390
+ // left is current cell and right is the opposite
391
+ if (dones.includes(idx)) {
392
+ return null;
393
+ }
394
+ const { childs } = grid;
395
+ const cellBox = cordinatesRef.current[idx];
396
+ dones.push(idx);
397
+ if (level === 0 && !leftCols.length) {
398
+ leftCols.push(idx);
399
+ }
400
+ let isEnd = true;
401
+ if (type === 'column') {
402
+ childs.forEach((cell, i) => {
403
+ if (((direction === 'left' &&
404
+ cell.colEnd === line &&
405
+ Math.abs(cellBox.x - cordinatesRef.current[i].xEnd) < 1) ||
406
+ (direction === 'right' &&
407
+ cell.colStart === line &&
408
+ Math.abs(cellBox.xEnd - cordinatesRef.current[i].x) < 1)) &&
409
+ !(floorSize(cordinatesRef.current[i].y) >= floorSize(cellBox.yEnd) ||
410
+ floorSize(cordinatesRef.current[i].yEnd) <= floorSize(cellBox.y))) {
411
+ if (!rightCols.includes(i)) {
412
+ rightCols.push(i);
413
+ // const cellIRef = cellsRef.current[i];
414
+ // if (cellIRef.current) {
415
+ // cellIRef.current.style.background = 'green';
416
+ // }
417
+ isEnd = false;
418
+ }
419
+ // else if (direction === 'right' && !leftCols.includes(i)) {
420
+ // leftCols.push(i);
421
+ // const cellIRef = cellsRef.current[i];
422
+ // if (cellIRef.current) {
423
+ // cellIRef.current.style.background = 'blue';
424
+ // }
425
+ // isEnd = false;
426
+ // }
427
+ }
428
+ });
429
+ }
430
+ else {
431
+ childs.forEach((cell, i) => {
432
+ if (((direction === 'top' &&
433
+ cell.rowEnd === line &&
434
+ Math.abs(cellBox.y - cordinatesRef.current[i].yEnd) < 1) ||
435
+ (direction === 'bottom' &&
436
+ cell.rowStart === line &&
437
+ Math.abs(cellBox.yEnd - cordinatesRef.current[i].y) < 1)) &&
438
+ !(floorSize(cordinatesRef.current[i].x) >= floorSize(cellBox.xEnd) ||
439
+ floorSize(cordinatesRef.current[i].xEnd) <= floorSize(cellBox.x))) {
440
+ if (!rightCols.includes(i)) {
441
+ rightCols.push(i);
442
+ // const cellIRef = cellsRef.current[i];
443
+ // if (cellIRef.current) {
444
+ // cellIRef.current.style.background = 'green';
445
+ // }
446
+ isEnd = false;
447
+ }
448
+ // else if (direction === 'bottom' && !leftCols.includes(i)) {
449
+ // leftCols.push(i);
450
+ // const cellIRef = cellsRef.current[i];
451
+ // if (cellIRef.current) {
452
+ // cellIRef.current.style.background = 'blue';
453
+ // }
454
+ // isEnd = false;
455
+ // }
456
+ }
457
+ });
458
+ }
459
+ // console.log(' find', direction, idx, leftCols, rightCols, dones, cordinatesRef.current);
460
+ if (!isEnd) {
461
+ // console.log('continue find', leftCols, rightCols);
462
+ rightCols
463
+ .filter(i => !dones.includes(i))
464
+ .forEach(i => {
465
+ findResizeCells({
466
+ type,
467
+ line,
468
+ direction: { left: 'right', right: 'left', top: 'bottom', bottom: 'top' }[direction] || '',
469
+ idx: i,
470
+ isRevert,
471
+ leftCols: rightCols,
472
+ rightCols: leftCols,
473
+ dones,
474
+ level: level + 1,
475
+ });
476
+ });
477
+ }
478
+ return { leftCols, rightCols };
479
+ };
480
+ const handleDownCell = (e, type, line, idx, direction, cell, cellRef) => {
481
+ const { clientX, clientY } = e;
482
+ // rebaseCordinate(clientX, clientY, type, line);
483
+ const isRevert = ['top', 'left'].includes(direction);
484
+ // let newIdx = isRevert ? idx - 1 : idx;
485
+ // let nextCellIdx = isRevert ? idx - 1 : idx + 1;
486
+ const leftCols = [idx];
487
+ const rightCols = [];
488
+ findResizeCells({ type, line, direction, idx, isRevert, leftCols, rightCols });
489
+ // console.log('change cell', leftCols, rightCols);
490
+ // if (['top', 'bottom'].includes(direction)) {
491
+ // nextCellIdx = grid.childs.findIndex(
492
+ // b =>
493
+ // b.colStart === cell.colStart &&
494
+ // ((isRevert && b.rowEnd === cell.rowStart) || (!isRevert && b.rowStart === cell.rowEnd)),
495
+ // );
496
+ // newIdx = isRevert ? nextCellIdx : idx;
497
+ // }
498
+ // if (nextCellIdx < 0) return;
499
+ if (!leftCols.length || !rightCols.length)
500
+ return;
501
+ const leftCells = {};
502
+ const rightCells = {};
503
+ leftCols.forEach(i => {
504
+ var _a, _b;
505
+ const cell = grid.childs[i];
506
+ const cellRef = cellsRef.current[i];
507
+ leftCells[i] = Object.assign({ sizeX: cell.sizeX || ((_a = cellRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 0, sizeY: cell.sizeY || ((_b = cellRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0, transformX: cell.transformX || 0, transformY: cell.transformY || 0, idx: i, cellRef }, cell);
508
+ });
509
+ rightCols.forEach(i => {
510
+ var _a, _b;
511
+ const cell = grid.childs[i];
512
+ const cellRef = cellsRef.current[i];
513
+ rightCells[i] = Object.assign({ sizeX: cell.sizeX || ((_a = cellRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 0, sizeY: cell.sizeY || ((_b = cellRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0, transformX: cell.transformX || 0, transformY: cell.transformY || 0, idx: i, cellRef }, cell);
514
+ });
515
+ const newDirection = isRevert
516
+ ? {
517
+ left: 'right',
518
+ right: 'left',
519
+ top: 'bottom',
520
+ bottom: 'top',
521
+ }[direction]
522
+ : direction;
523
+ startCellRef.current = {
524
+ clientX,
525
+ clientY,
526
+ // idx: newIdx,
527
+ direction: newDirection,
528
+ isRevert,
529
+ leftCells: isRevert ? rightCells : leftCells,
530
+ rightCells: !isRevert ? rightCells : leftCells,
531
+ };
532
+ // console.log('down cell', clientX, clientY, idx, direction, cell, cellRef);
533
+ gridRef.current = grid;
534
+ };
535
+ const handleDown = (e, type, line, idx, direction, cell, cellRef) => {
536
+ const { clientX, clientY } = e;
537
+ // rebaseCordinate(clientX, clientY, type, line);
538
+ startRef.current = { clientX, clientY, type, line };
539
+ // const isRevert = ['top', 'left'].includes(direction);
540
+ // const { leftCols, rightCols } = findResizeCells({ type, line, direction, idx, isRevert });
541
+ // console.log('change cell', leftCols, rightCols);
542
+ // console.log('down', type, line, clientX, clientY);
543
+ gridRef.current = JSON.parse(JSON.stringify(grid));
544
+ };
545
+ const handleUp = (e, direction, idx) => {
546
+ // console.log('up', direction, idx, e);
547
+ startRef.current = null;
548
+ startCellRef.current = null;
549
+ lineVertical(false);
550
+ lineHorizontal(false);
551
+ };
552
+ const downSelect = (idx, cell) => {
553
+ // console.log('dow select', idx, cell);
554
+ !cell.active && activeCell({ idx });
555
+ selectRef.current = { idx, cell };
556
+ gridRef.current = grid;
557
+ };
558
+ const unMerge = (cell, idx) => {
559
+ const { colStart, colEnd, rowStart, rowEnd } = cell;
560
+ if (colStart + 1 === colEnd && rowStart + 1 === rowEnd) {
561
+ return;
562
+ }
563
+ const newChilds = [...grid.childs];
564
+ for (let i = rowStart; i < rowEnd; i++) {
565
+ for (let j = colStart; j < colEnd; j++) {
566
+ const rStart = i;
567
+ const cStart = j;
568
+ const rEnd = rStart + 1;
569
+ const cEnd = cStart + 1;
570
+ // console.log('merge', i, j, rStart, cStart, rEnd, cEnd)
571
+ const newChild = {
572
+ colStart: cStart,
573
+ colEnd: cEnd,
574
+ rowStart: rStart,
575
+ rowEnd: rEnd,
576
+ };
577
+ if (i === rowStart && j === colStart) {
578
+ newChilds[idx] = newChild;
579
+ }
580
+ else if (rStart !== rowStart ||
581
+ rEnd !== rowEnd ||
582
+ cStart !== colStart ||
583
+ cEnd !== colEnd) {
584
+ newChilds.splice(idx, 0, newChild);
585
+ }
586
+ }
587
+ }
588
+ setGrid(prev => (Object.assign(Object.assign({}, prev), { childs: newChilds })));
589
+ };
590
+ function resetBackgroundCellRef() {
591
+ Object.values(cellsRef.current).forEach(r => {
592
+ if (r.current) {
593
+ r.current.style.background = 'unset';
594
+ }
595
+ });
596
+ }
597
+ const upSelect = (idx, cell) => {
598
+ // console.log('up select', idx, cell);
599
+ if (selectRef.current &&
600
+ selectEndRef.current &&
601
+ gridRef.current &&
602
+ selectRef.current.idx !== selectEndRef.current.idx &&
603
+ (selectEndRef.current.cell.rowEnd > selectRef.current.cell.rowEnd ||
604
+ selectEndRef.current.cell.colEnd > selectRef.current.cell.colEnd)) {
605
+ resetBackgroundCellRef();
606
+ // console.log('merge', selectRef.current, selectEndRef.current)
607
+ const { cell: cellStart, idx: idxStart } = selectRef.current;
608
+ const { cell: cellEnd, idx: idxEnd, hCells } = selectEndRef.current;
609
+ const newChilds = JSON.parse(JSON.stringify(gridRef.current.childs));
610
+ newChilds[idxStart].rowEnd = cellEnd.rowEnd;
611
+ newChilds[idxStart].colEnd = cellEnd.colEnd;
612
+ delete newChilds[idxStart].sizeX;
613
+ delete newChilds[idxStart].sizeY;
614
+ hCells.reverse().forEach(i => {
615
+ if (i !== idxStart) {
616
+ newChilds.splice(i, 1);
617
+ delete cellsRef.current[i];
618
+ delete cordinatesRef.current[i];
619
+ // console.log('del corr', i, cordinatesRef.current)
620
+ }
621
+ });
622
+ setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
623
+ }
624
+ selectRef.current = null;
625
+ selectEndRef.current = null;
626
+ };
627
+ const hoverSelect = (idx, cell) => {
628
+ if (selectRef.current && gridRef.current) {
629
+ // console.log('hover select', idx, cell);
630
+ const { cell: cellStart, idx: idxStart } = selectRef.current;
631
+ const hCells = [];
632
+ gridRef.current.childs.forEach((child, i) => {
633
+ if (child.rowStart >= cellStart.rowStart &&
634
+ child.rowEnd <= cell.rowEnd &&
635
+ child.colStart >= cellStart.colStart &&
636
+ child.colEnd <= cell.colEnd) {
637
+ hCells.push(i);
638
+ }
639
+ });
640
+ // console.log('hCells', hCells)
641
+ resetBackgroundCellRef();
642
+ hCells.forEach(i => {
643
+ const cellRef = cellsRef.current[i];
644
+ if (cellRef && cellRef.current) {
645
+ cellRef.current.style.background = selectColor || 'unset';
646
+ }
647
+ });
648
+ selectEndRef.current = { cell, idx, hCells };
649
+ gridRef.current = grid;
650
+ }
651
+ };
652
+ const setRef = (idx, ref) => {
653
+ cellsRef.current[idx] = ref;
654
+ // console.log('cellsRef.current', cellsRef.current)
655
+ };
656
+ const setCordinate = (idx) => __awaiter(void 0, void 0, void 0, function* () {
657
+ // while(!cellsRef[idx]) {
658
+ // await new Promise(r => {setTimeout(r, 100)});
659
+ // console.log('wait', idx, cellsRef[idx])
660
+ // }
661
+ var _b;
662
+ if (containerRef.current) {
663
+ const container = containerRef.current.getBoundingClientRect();
664
+ const childRef = cellsRef.current[idx];
665
+ const childBox = (_b = childRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
666
+ if (childBox) {
667
+ const cordinate = {
668
+ width: childBox.width,
669
+ height: childBox.height,
670
+ x: childBox.x - container.x,
671
+ y: childBox.y - container.y,
672
+ xEnd: childBox.x - container.x + childBox.width,
673
+ yEnd: childBox.y - container.y + childBox.height,
674
+ };
675
+ cordinatesRef.current[idx] = cordinate;
676
+ // console.log('set cor', idx, cordinate);
677
+ }
678
+ }
679
+ // console.log('set corr', idx, cordinatesRef.current)
680
+ });
681
+ const renderGrid = (style) => {
682
+ const { gridTemplateColumns, gridTemplateRows, childs } = grid;
683
+ // console.log('grid', { gridTemplateColumns, gridTemplateRows, childs });
684
+ return (React.createElement("div", { className: "grid-container", ref: containerRef, style: Object.assign({ gridTemplateColumns: gridTemplateColumns.map(fr => `${fr}%`).join(' '), gridTemplateRows: gridTemplateRows.map(fr => `${fr}%`).join(' ') }, style) }, childs.map((cell, idx) => (React.createElement(Cell, { key: `${cell.rowStart}-${cell.colStart}-${cell.rowEnd}-${cell.colEnd}`, idx: idx, cell: cell, down: handleDown, downCell: handleDownCell, up: handleUp, setRef: setRef, setCordinate: setCordinate, downSelect: downSelect, upSelect: upSelect, hoverSelect: hoverSelect, unMerge: unMerge, renderCell: renderCell, borderStyle: cellBorder, style: cellStyle, activeStyle: cellActiveStyle, isPreview: isPreview, rowPercentage: grid.gridTemplateRows[cell.rowStart - 1], colPercentage: grid.gridTemplateColumns[cell.colStart - 1], ctrlKeyRef: ctrlKeyRef })))));
685
+ };
686
+ const handleUpLine = () => {
687
+ lineVertical(false);
688
+ lineHorizontal(false);
689
+ };
690
+ const _a = containerStyle || {}, { borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderStyle, borderColor } = _a, rest = __rest(_a, ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomRightRadius", "borderBottomLeftRadius", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderStyle", "borderColor"]);
691
+ const renderLines = () => (React.createElement(React.Fragment, null,
692
+ React.createElement(StyledLine, { ref: verticalLineRef, className: "vertical", onMouseUp: handleUpLine }),
693
+ React.createElement(StyledLine, { ref: horizontalLineRef, className: "horizontal", onMouseUp: handleUpLine })));
694
+ return (React.createElement(StyledGrid, { className: "grid-wrapper", isCompact: !!isCompact },
695
+ React.createElement("div", { className: "layers", ref: layersRef },
696
+ React.createElement(StyledBGLayer, { style: {
697
+ backgroundImage: image ? `url(${image})` : 'unset',
698
+ backgroundSize: imageSize === 'fill' ? '100% 100%' : imageSize,
699
+ backgroundPosition: imagePosition,
700
+ } }),
701
+ React.createElement(StyledMiddleLayer, { style: {
702
+ borderTopLeftRadius,
703
+ borderTopRightRadius,
704
+ borderBottomRightRadius,
705
+ borderBottomLeftRadius,
706
+ borderTopWidth,
707
+ borderRightWidth,
708
+ borderBottomWidth,
709
+ borderLeftWidth,
710
+ borderStyle,
711
+ borderColor,
712
+ } }),
713
+ renderGrid(Object.assign(Object.assign({}, rest), { borderTopLeftRadius,
714
+ borderTopRightRadius,
715
+ borderBottomRightRadius,
716
+ borderBottomLeftRadius }))),
717
+ renderLines()));
718
+ };
719
+ ResizeGrid.defaultProps = defaultProps;