@antscorp/antsomi-ui 1.3.3-beta.30 → 1.3.3-beta.32

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 (72) hide show
  1. package/es/components/atoms/InputDynamic/InputDynamic.d.ts +2 -1
  2. package/es/components/atoms/InputDynamic/styled.d.ts +1 -1
  3. package/es/components/atoms/InputDynamic/styled.js +3 -1
  4. package/es/components/atoms/Spin/Spin.d.ts +2 -1
  5. package/es/components/common/ConfigProvider/GlobalStyle.js +2 -2
  6. package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
  7. package/es/components/icons/AudioRecordIcon.d.ts +2 -1
  8. package/es/components/icons/BugIcon.d.ts +2 -1
  9. package/es/components/icons/CameraIcon.d.ts +2 -1
  10. package/es/components/icons/CaptureIcon.d.ts +2 -1
  11. package/es/components/icons/CheckSlimIcon.d.ts +2 -1
  12. package/es/components/icons/CloseIcon.d.ts +2 -1
  13. package/es/components/icons/CommentIcon.d.ts +2 -1
  14. package/es/components/icons/EventIcon.d.ts +2 -1
  15. package/es/components/icons/FreeDrawIcon.d.ts +2 -1
  16. package/es/components/icons/GPTIcon.d.ts +2 -1
  17. package/es/components/icons/GPTIconV2.d.ts +2 -1
  18. package/es/components/icons/GPTIconV3.d.ts +2 -1
  19. package/es/components/icons/HighlightIcon.d.ts +2 -1
  20. package/es/components/icons/IdeaIcon.d.ts +2 -1
  21. package/es/components/icons/InvisibleIcon.d.ts +2 -1
  22. package/es/components/icons/MuteIcon.d.ts +2 -1
  23. package/es/components/icons/OpenUrlIcon.d.ts +2 -1
  24. package/es/components/icons/PauseIcon.d.ts +2 -1
  25. package/es/components/icons/PlaneIcon.d.ts +2 -1
  26. package/es/components/icons/RequestIcon.d.ts +2 -1
  27. package/es/components/icons/StopRecordIcon.d.ts +2 -1
  28. package/es/components/icons/UserIcon.d.ts +2 -1
  29. package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
  30. package/es/components/icons/WarningIcon.d.ts +2 -1
  31. package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
  32. package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
  33. package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
  34. package/es/components/molecules/Modal/styled.d.ts +1 -1
  35. package/es/components/molecules/ModalV2/styled.d.ts +1 -1
  36. package/es/components/molecules/ResizeGrid/ResizeGrid.js +119 -51
  37. package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +2 -1
  38. package/es/components/molecules/ResizeGrid/constant.d.ts +1 -1
  39. package/es/components/molecules/ResizeGrid/constant.js +1 -1
  40. package/es/components/molecules/ResizeGrid/styled.js +1 -0
  41. package/es/components/molecules/ResizeGrid/types.d.ts +3 -2
  42. package/es/components/molecules/Select/Test.d.ts +2 -1
  43. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +1 -1
  44. package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
  45. package/es/constants/storybook.d.ts +2 -1
  46. package/es/test.d.ts +2 -1
  47. package/package.json +1 -1
  48. package/dist/0173b5993573afa04880.woff +0 -0
  49. package/dist/0dfb9214dfd945cd7290.png +0 -1
  50. package/dist/2883cad25a2b4e87ce5f.eot +0 -0
  51. package/dist/4f54a37971347e3d7122.png +0 -1
  52. package/dist/574b7bee0563a9fe9a29.png +0 -1
  53. package/dist/6b586356e837581204dc.svg +0 -1
  54. package/dist/72eec5c1c786b45a667f.ttf +0 -0
  55. package/dist/bc6bf11c6f5e6743aa4c.png +0 -1
  56. package/dist/dbc405edd6e0806efbc9.svg +0 -1
  57. package/dist/e32f09119052a55cce3c.png +0 -1
  58. package/dist/e3851b9384a984c6fdb5.png +0 -1
  59. package/dist/index.js +0 -2
  60. package/dist/index.js.LICENSE.txt +0 -69
  61. package/dist/main.css +0 -69
  62. package/dist/public/icons/2d496b55d85a9545d7311c073af442bb.png +0 -0
  63. package/dist/public/icons/2fbb4e0927d18e3f8e5c6511ab88d5b3.png +0 -0
  64. package/dist/public/icons/725a52bd91a3ce534b10833df510e5fa.png +0 -0
  65. package/dist/public/icons/7d037e0b378e87a82804443636cd0e13.svg +0 -346
  66. package/dist/public/icons/90553767e0a05b9585a54797cfd9ce51.png +0 -0
  67. package/dist/public/icons/bb64e23a1ff390a416d765ee556096ab.svg +0 -87
  68. package/dist/public/icons/d327b24e9c5d8f486f08d253aab58ce6.png +0 -0
  69. package/dist/public/icons/f1cf266d0a0a53ce07f2dbb859869b7a.png +0 -0
  70. package/dist/public/icons/placeholder-image.png +0 -0
  71. package/dist/public/icons/stars_slider.png +0 -0
  72. package/dist/public/icons/transparent.svg +0 -1
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { DisableShortLinkTypeProps } from './PopupShortLink';
2
3
  export type KeyTagType = 'shortlink' | 'shortlink_static';
3
4
  export type SelectedPropertiesProps = {
@@ -16,7 +17,7 @@ export type InputDynamicProps = {
16
17
  addMessageToQueue?: Function;
17
18
  };
18
19
  export declare const InputDynamic: {
19
- (props: InputDynamicProps): JSX.Element;
20
+ (props: InputDynamicProps): React.JSX.Element;
20
21
  defaultProps: {
21
22
  value: string;
22
23
  isViewMode: boolean;
@@ -4,7 +4,7 @@ export declare const SpanIcon: import("styled-components").StyledComponent<"span
4
4
  isDisabled?: boolean | undefined;
5
5
  }, never>;
6
6
  export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const InputShortLink: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof JSX.IntrinsicElements, any, import("../Input/Input").InputProps, any>;
7
+ export declare const InputShortLink: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof import("react").JSX.IntrinsicElements, any, import("../Input/Input").InputProps, any>;
8
8
  export declare const TooltipHover: import("styled-components").StyledComponent<"div", any, {
9
9
  top: number;
10
10
  left: number;
@@ -257,7 +257,9 @@ export const TooltipHover = styled.div `
257
257
  left: ${props => `${props.left}px`};
258
258
  top: ${props => `${props.top}px`};
259
259
 
260
- display: ${props => (props.isShow ? 'block' : 'none')};
260
+ display: ${props => (props.isShow ? 'flex' : 'none')};
261
+ justify-content: center;
262
+ align-items: center;
261
263
 
262
264
  background: rgba(0, 0, 0, 0.62);
263
265
  transition: opacity 186ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
@@ -1,9 +1,10 @@
1
+ import React from 'react';
1
2
  import { SpinProps as AntdSpinProps } from 'antd';
2
3
  export interface TSpinProps extends AntdSpinProps {
3
4
  indicatorSize?: number;
4
5
  children?: any;
5
6
  }
6
7
  export declare const Spin: {
7
- (props: TSpinProps): JSX.Element;
8
+ (props: TSpinProps): React.JSX.Element;
8
9
  defaultProps: {};
9
10
  };
@@ -504,10 +504,10 @@ export const GlobalStyle = () => {
504
504
  }
505
505
  }
506
506
  .antsomi-modal-footer {
507
- padding: 15px;
507
+ padding: 15px !important;
508
508
  text-align: right;
509
509
  background: transparent;
510
- border-top: 1px solid #f0f0f0;
510
+ border-top: 1px solid #f0f0f0 !important;
511
511
  border-radius: 0 0 2px 2px;
512
512
  }
513
513
  }
@@ -1 +1,2 @@
1
- export declare const ArrowGrowIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const ArrowGrowIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const AudioRecordIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const AudioRecordIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const BugIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const BugIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const CameraIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const CameraIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const CaptureIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const CaptureIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const CheckSlimIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const CheckSlimIcon: (props: any) => React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  export declare const CloseIcon: ({ ...props }: {
2
3
  [x: string]: any;
3
- }) => JSX.Element;
4
+ }) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const CommentIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const CommentIcon: (props: any) => React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  export declare const EventIcon: ({ ...props }: {
2
3
  [x: string]: any;
3
- }) => JSX.Element;
4
+ }) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const FreeDrawIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const FreeDrawIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const GPTIcon: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const GPTIcon: () => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const GPTIconV2: () => JSX.Element;
1
+ import React from 'react';
2
+ export declare const GPTIconV2: () => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const GPTIconV3: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const GPTIconV3: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const HighlightIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const HighlightIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const IdeaIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const IdeaIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const InvisibleIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const InvisibleIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const MuteIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const MuteIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const OpenUrlIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const OpenUrlIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const PauseIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const PauseIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const PlaneIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const PlaneIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const RequestIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const RequestIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const StopRecordIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const StopRecordIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const UserIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const UserIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const VerticalDotsIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const VerticalDotsIcon: (props: any) => React.JSX.Element;
@@ -1 +1,2 @@
1
- export declare const WarningIcon: (props: any) => JSX.Element;
1
+ import React from 'react';
2
+ export declare const WarningIcon: (props: any) => React.JSX.Element;
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import { IImageEditorProps } from './types';
2
3
  declare const CaptureScreen: {
3
- (props: IImageEditorProps): JSX.Element;
4
+ (props: IImageEditorProps): React.JSX.Element;
4
5
  defaultProps: {
5
6
  isOpen: boolean;
6
7
  src: string;
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import { CommentBoxProps } from './types';
2
3
  declare const CommentBox: {
3
- (props: CommentBoxProps): JSX.Element;
4
+ (props: CommentBoxProps): React.JSX.Element;
4
5
  defaultProps: {
5
6
  info: {
6
7
  id: string;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { CursorProps } from './types';
2
- declare const Cursor: (props: CursorProps) => JSX.Element | null;
3
+ declare const Cursor: (props: CursorProps) => React.JSX.Element | null;
3
4
  export { Cursor };
@@ -10,6 +10,6 @@ export declare const StyledModal: import("styled-components").StyledComponent<im
10
10
  useModal: typeof import("antd/es/modal/useModal").default;
11
11
  destroyAll: () => void;
12
12
  config: typeof import("antd/es/modal/confirm").modalGlobalConfig;
13
- _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/modal/PurePanel").PurePanelProps) => React.JSX.Element;
13
+ _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/modal/PurePanel").PurePanelProps) => import("react").JSX.Element;
14
14
  }, any, CustomModalProps, never>;
15
15
  export declare const WrapperSpin: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -3,5 +3,5 @@ export declare const StyledModal: import("styled-components").StyledComponent<im
3
3
  useModal: typeof import("antd/es/modal/useModal").default;
4
4
  destroyAll: () => void;
5
5
  config: typeof import("antd/es/modal/confirm").modalGlobalConfig;
6
- _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/modal/PurePanel").PurePanelProps) => React.JSX.Element;
6
+ _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/modal/PurePanel").PurePanelProps) => import("react").JSX.Element;
7
7
  }, any, {}, never>;
@@ -28,13 +28,13 @@ const defaultProps = {
28
28
  cellBorder: '1px dotted',
29
29
  cellStyle: {},
30
30
  cellActiveStyle: { background: '#2f79bf80' },
31
- isPreviewMode: false,
31
+ isPreview: false,
32
32
  isCompact: false,
33
33
  delayUpdate: 100,
34
34
  selectColor: '#2f79bf80',
35
35
  };
36
36
  export const ResizeGrid = props => {
37
- const { containerStyle, cellBorder, cellStyle, cellActiveStyle, isPreviewMode, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, onChange, delayUpdate, selectColor, } = props;
37
+ const { containerStyle, cellBorder, cellStyle, cellActiveStyle, isPreview, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, onChange, delayUpdate, selectColor, } = props;
38
38
  const [grid, setGrid] = useState(buildGrid(initGrid || GRID_TEMPLATE.GRID_2_3));
39
39
  const startRef = useRef(null);
40
40
  const startCellRef = useRef(null);
@@ -44,13 +44,29 @@ export const ResizeGrid = props => {
44
44
  const containerRef = useRef(null);
45
45
  const verticalLineRef = useRef(null);
46
46
  const horizontalLineRef = useRef(null);
47
+ const layersRef = useRef(null);
47
48
  const cellsRef = useRef({});
48
49
  const cordinatesRef = useRef({});
49
50
  const onChangeTimoutRef = useRef();
50
51
  const onChangeDelayRef = useRef();
51
52
  const acceptUpdateRef = useRef(false);
53
+ const firstChangeRef = useRef(true);
52
54
  const ctrlKeyRef = useRef(false);
53
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
+ }
54
70
  const handleChangeGrid = () => {
55
71
  clearTimeout(onChangeTimoutRef.current);
56
72
  onChangeTimoutRef.current = setTimeout(() => {
@@ -69,8 +85,9 @@ export const ResizeGrid = props => {
69
85
  };
70
86
  });
71
87
  if (typeof onChange === 'function') {
72
- onChange(grid, childs);
88
+ onChange(grid, childs, firstChangeRef.current ? 'system' : 'user');
73
89
  acceptUpdateRef.current = false;
90
+ firstChangeRef.current = false;
74
91
  clearTimeout(onChangeDelayRef.current);
75
92
  onChangeDelayRef.current = setTimeout(() => {
76
93
  acceptUpdateRef.current = true;
@@ -83,6 +100,7 @@ export const ResizeGrid = props => {
83
100
  ? (cell.colEnd !== line || !cell.width) && (cell.colStart !== line || !cell.width)
84
101
  : (cell.rowEnd !== line || !cell.height) && (cell.rowStart !== line || !cell.height);
85
102
  const notFollow = (cell, line, isCol = true) => !isFollow(cell, line, isCol);
103
+ const floorSize = size => Math.floor(size);
86
104
  useEffect(() => {
87
105
  handleChangeGrid();
88
106
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -128,7 +146,9 @@ export const ResizeGrid = props => {
128
146
  }
129
147
  }
130
148
  else {
131
- child.transformY && !child.movedBottom && (child.height = +child.height + yDistant);
149
+ child.transformY &&
150
+ !child.movedBottom &&
151
+ (child.height = +child.height + yDistant);
132
152
  }
133
153
  // console.log('check...', startRef.current.line, child.transformY, yDistant, +child.transformY - yDistant)
134
154
  if (child.height < MIN_SIZE) {
@@ -193,18 +213,48 @@ export const ResizeGrid = props => {
193
213
  const { clientX, clientY } = e;
194
214
  if (['top', 'bottom'].includes(direction)) {
195
215
  // const cellHeight = cellRef.current.offsetHeight;
196
- const yDistant = clientY - startClientY;
216
+ let yDistant = clientY - startClientY;
197
217
  // console.log('move Y', clientY, yDistant);
218
+ if (Math.abs(yDistant) > THREADHOLD) {
219
+ startCellRef.current.fallback = true;
220
+ }
198
221
  let isValid = true;
199
222
  const mapNewSizeTop = {};
200
223
  const mapNewSizeBottom = {};
201
- Object.keys(leftCells).forEach(cellIdx => {
224
+ const leftKeys = Object.keys(leftCells);
225
+ leftKeys.forEach(cellIdx => {
202
226
  const cell = leftCells[cellIdx];
203
- const newHeight = (cell.height || 0) + yDistant;
227
+ let newHeight = (cell.height || 0) + yDistant;
204
228
  if (newHeight < MIN_SIZE) {
205
229
  isValid = false;
206
230
  }
207
- mapNewSizeTop[cellIdx] = newHeight;
231
+ else {
232
+ const cellCordinate = cordinatesRef.current[cellIdx];
233
+ // const cell = gridRef.current.childs[cellIdx];
234
+ const newYEnd = cellCordinate.y + newHeight;
235
+ const nearestCells = Object.entries(cordinatesRef.current).filter(cor => gridRef.current &&
236
+ gridRef.current.childs[cor[0]] &&
237
+ !leftKeys.includes(cor[0]) &&
238
+ gridRef.current.childs[cor[0]].colStart !== cell.colStart &&
239
+ Math.abs(cor[1].yEnd - newYEnd) <= THREADHOLD);
240
+ // console.log('nearestCells', nearestCells, newXEnd, leftKeys, cordinatesRef.current);
241
+ if (nearestCells.length && startCellRef.current) {
242
+ const nearestY = Math.abs(nearestCells[0][1].y - newYEnd) <= THREADHOLD
243
+ ? nearestCells[0][1].y
244
+ : nearestCells[0][1].yEnd;
245
+ const delta = nearestY - newYEnd;
246
+ if (startCellRef.current.fallback ||
247
+ floorSize(cellCordinate.height) !== floorSize(newHeight + delta)) {
248
+ newHeight += delta;
249
+ yDistant += delta;
250
+ lineHorizontal(true, nearestY - 1);
251
+ }
252
+ }
253
+ else {
254
+ lineHorizontal(false);
255
+ }
256
+ mapNewSizeTop[cellIdx] = newHeight;
257
+ }
208
258
  });
209
259
  Object.keys(rightCells).forEach(cellIdx => {
210
260
  const nextCell = rightCells[cellIdx];
@@ -227,15 +277,19 @@ export const ResizeGrid = props => {
227
277
  }
228
278
  else {
229
279
  // const cellWidth = cellRef.current.offsetWidth;
230
- const xDistant = clientX - startClientX;
280
+ let xDistant = clientX - startClientX;
231
281
  // console.log('move X', clientX, xDistant);
282
+ if (Math.abs(xDistant) > THREADHOLD) {
283
+ startCellRef.current.fallback = true;
284
+ }
232
285
  let isValid = true;
233
286
  const mapNewSizeLeft = {};
234
287
  const mapNewSizeRight = {};
288
+ const mapReset = {};
235
289
  const leftKeys = Object.keys(leftCells);
236
290
  leftKeys.forEach(cellIdx => {
237
291
  const cell = leftCells[cellIdx];
238
- const newWidth = (cell.width || 0) + xDistant;
292
+ let newWidth = (cell.width || 0) + xDistant;
239
293
  if (newWidth < MIN_SIZE) {
240
294
  isValid = false;
241
295
  }
@@ -244,20 +298,26 @@ export const ResizeGrid = props => {
244
298
  // const cell = gridRef.current.childs[cellIdx];
245
299
  const newXEnd = cellCordinate.x + newWidth;
246
300
  const nearestCells = Object.entries(cordinatesRef.current).filter(cor => gridRef.current &&
301
+ gridRef.current.childs[cor[0]] &&
247
302
  !leftKeys.includes(cor[0]) &&
248
303
  gridRef.current.childs[cor[0]].rowStart !== cell.rowStart &&
249
- (Math.abs(cor[1].x - newXEnd) <= THREADHOLD ||
250
- Math.abs(cor[1].xEnd - newXEnd) <= THREADHOLD));
304
+ Math.abs(cor[1].xEnd - newXEnd) <= THREADHOLD);
251
305
  // console.log('nearestCells', nearestCells, newXEnd, leftKeys, cordinatesRef.current);
252
- // if (nearestCells.length) {
253
- // const nearestX =
254
- // Math.abs(nearestCells[0][1].x - newXEnd) <= THREADHOLD
255
- // ? nearestCells[0][1].x
256
- // : nearestCells[0][1].xEnd;
257
- // lineVertical(true, nearestX);
258
- // } else {
259
- // lineVertical(false);
260
- // }
306
+ if (nearestCells.length && startCellRef.current) {
307
+ const nearestX = Math.abs(nearestCells[0][1].x - newXEnd) <= THREADHOLD
308
+ ? nearestCells[0][1].x
309
+ : nearestCells[0][1].xEnd;
310
+ const delta = nearestX - newXEnd;
311
+ if (startCellRef.current.fallback ||
312
+ floorSize(cellCordinate.width) !== floorSize(newWidth + delta)) {
313
+ newWidth += delta;
314
+ xDistant += delta;
315
+ lineVertical(true, nearestX - 1);
316
+ }
317
+ }
318
+ else {
319
+ lineVertical(false);
320
+ }
261
321
  mapNewSizeLeft[cellIdx] = newWidth;
262
322
  }
263
323
  });
@@ -287,6 +347,8 @@ export const ResizeGrid = props => {
287
347
  const handleUp = () => {
288
348
  startRef.current = null;
289
349
  startCellRef.current = null;
350
+ lineVertical(false);
351
+ lineHorizontal(false);
290
352
  };
291
353
  const isMac = () => navigator.platform.indexOf('Mac') >= 0;
292
354
  window.addEventListener('mousemove', handleMove);
@@ -319,7 +381,6 @@ export const ResizeGrid = props => {
319
381
  const activeCell = ({ idx }) => {
320
382
  setGrid(prev => (Object.assign(Object.assign({}, prev), { childs: prev.childs.map((c, i) => (Object.assign(Object.assign({}, c), { active: i === idx }))) })));
321
383
  };
322
- const floorSize = size => Math.floor(size);
323
384
  const findResizeCells = ({ type, line, direction, idx,
324
385
  // cell,
325
386
  isRevert, leftCols = [], rightCols = [], dones = [], level = 0, }) => {
@@ -474,6 +535,8 @@ export const ResizeGrid = props => {
474
535
  // console.log('up', direction, idx, e);
475
536
  startRef.current = null;
476
537
  startCellRef.current = null;
538
+ lineVertical(false);
539
+ lineHorizontal(false);
477
540
  };
478
541
  const downSelect = (idx, cell) => {
479
542
  // console.log('dow select', idx, cell);
@@ -542,6 +605,7 @@ export const ResizeGrid = props => {
542
605
  newChilds.splice(i, 1);
543
606
  delete cellsRef.current[i];
544
607
  delete cordinatesRef.current[i];
608
+ // console.log('del corr', i, cordinatesRef.current)
545
609
  }
546
610
  });
547
611
  setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
@@ -579,12 +643,11 @@ export const ResizeGrid = props => {
579
643
  // console.log('cellsRef.current', cellsRef.current)
580
644
  };
581
645
  const setCordinate = (idx) => __awaiter(void 0, void 0, void 0, function* () {
582
- var _b;
583
646
  // while(!cellsRef[idx]) {
584
647
  // await new Promise(r => {setTimeout(r, 100)});
585
648
  // console.log('wait', idx, cellsRef[idx])
586
649
  // }
587
- // console.log('set corr', idx, cellsRef.current[idx], cellsRef)
650
+ var _b;
588
651
  if (containerRef.current) {
589
652
  const container = containerRef.current.getBoundingClientRect();
590
653
  const childRef = cellsRef.current[idx];
@@ -602,39 +665,44 @@ export const ResizeGrid = props => {
602
665
  // console.log('set cor', idx, cordinate);
603
666
  }
604
667
  }
668
+ // console.log('set corr', idx, cordinatesRef.current)
605
669
  });
606
670
  const renderGrid = (style) => {
607
671
  const { gridTemplateColumns, gridTemplateRows, childs } = grid;
608
672
  // console.log('grid', { gridTemplateColumns, gridTemplateRows, childs });
609
- 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, isPreviewMode: isPreviewMode, rowPercentage: grid.gridTemplateRows[cell.rowStart - 1], colPercentage: grid.gridTemplateColumns[cell.colStart - 1], ctrlKeyRef: ctrlKeyRef })))));
673
+ 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 })))));
610
674
  };
611
- function lineVertical(isShow = true, left = 0) {
612
- if (verticalLineRef.current) {
613
- verticalLineRef.current.style.display = isShow ? 'block' : 'none';
614
- if (isShow) {
615
- verticalLineRef.current.style.left = `${left}px`;
616
- }
617
- }
618
- }
619
- function lineHorizontal(isShow = true, top = 0) {
620
- if (horizontalLineRef.current) {
621
- horizontalLineRef.current.style.display = isShow ? 'block' : 'none';
622
- if (isShow) {
623
- horizontalLineRef.current.style.top = `${top}px`;
624
- }
625
- }
626
- }
627
- const _a = containerStyle || {}, { border, borderTop, borderRight, borderBottom, borderLeft } = _a, rest = __rest(_a, ["border", "borderTop", "borderRight", "borderBottom", "borderLeft"]);
675
+ const handleUpLine = () => {
676
+ lineVertical(false);
677
+ lineHorizontal(false);
678
+ };
679
+ 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"]);
628
680
  const renderLines = () => (React.createElement(React.Fragment, null,
629
- React.createElement(StyledLine, { ref: verticalLineRef, className: "vertical" }),
630
- React.createElement(StyledLine, { ref: horizontalLineRef, className: "horizontal" })));
681
+ React.createElement(StyledLine, { ref: verticalLineRef, className: "vertical", onMouseUp: handleUpLine }),
682
+ React.createElement(StyledLine, { ref: horizontalLineRef, className: "horizontal", onMouseUp: handleUpLine })));
631
683
  return (React.createElement(StyledGrid, { className: "grid-wrapper", isCompact: !!isCompact },
632
- React.createElement(StyledBGLayer, { style: {
633
- backgroundImage: image ? `url(${image})` : 'unset',
634
- backgroundSize: imageSize === 'fill' ? '100% 100%' : imageSize,
635
- backgroundPosition: imagePosition,
636
- } }),
637
- React.createElement(StyledMiddleLayer, { style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (border && { border })), (borderTop && { borderTop })), (borderRight && { borderRight })), (borderBottom && { borderBottom })), (borderLeft && { borderLeft })) }),
638
- renderGrid(rest)));
684
+ React.createElement("div", { className: "layers", ref: layersRef },
685
+ React.createElement(StyledBGLayer, { style: {
686
+ backgroundImage: image ? `url(${image})` : 'unset',
687
+ backgroundSize: imageSize === 'fill' ? '100% 100%' : imageSize,
688
+ backgroundPosition: imagePosition,
689
+ } }),
690
+ React.createElement(StyledMiddleLayer, { style: {
691
+ borderTopLeftRadius,
692
+ borderTopRightRadius,
693
+ borderBottomRightRadius,
694
+ borderBottomLeftRadius,
695
+ borderTopWidth,
696
+ borderRightWidth,
697
+ borderBottomWidth,
698
+ borderLeftWidth,
699
+ borderStyle,
700
+ borderColor,
701
+ } }),
702
+ renderGrid(Object.assign(Object.assign({}, rest), { borderTopLeftRadius,
703
+ borderTopRightRadius,
704
+ borderBottomRightRadius,
705
+ borderBottomLeftRadius }))),
706
+ renderLines()));
639
707
  };
640
708
  ResizeGrid.defaultProps = defaultProps;
@@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import { buildGridArea, buildTranform } from '../../constant';
3
3
  import { StyledCell } from './styled';
4
4
  import { useDeepCompareEffect } from '../../../../../hooks/useDeepCompareEffect';
5
- export const Cell = ({ cell, idx, down, downCell, up, setRef, downSelect, upSelect, hoverSelect, unMerge, renderCell, style, isPreviewMode, borderStyle, activeStyle, activeCell, setCordinate, rowPercentage, colPercentage, ctrlKeyRef, }) => {
5
+ export const Cell = ({ cell, idx, down, downCell, up, setRef, downSelect, upSelect, hoverSelect, unMerge, renderCell, style, isPreview, borderStyle, activeStyle, activeCell, setCordinate, rowPercentage, colPercentage, ctrlKeyRef, }) => {
6
6
  const { objectFit, image } = cell;
7
7
  const downRef = useRef(false);
8
8
  const timeoutRef = useRef();
@@ -80,6 +80,7 @@ export const Cell = ({ cell, idx, down, downCell, up, setRef, downSelect, upSele
80
80
  React.createElement("div", { className: "cell-border", style: {
81
81
  borderTop: cell.rowStart === 1 ? borderStyle : 'unset',
82
82
  borderLeft: cell.colStart === 1 ? borderStyle : 'unset',
83
+ display: isPreview ? 'none' : 'block',
83
84
  } }),
84
85
  ['top', 'right', 'bottom', 'left'].map(direction => (React.createElement("div", { key: direction, className: `resize-${direction}`, onMouseDown: e => handleDown(e, direction, idx), onMouseUp: e => handleUp(e, direction, idx) })))));
85
86
  };
@@ -31,5 +31,5 @@ export declare const buildGrid: (inputGrid: Partial<TGrid>) => TGrid;
31
31
  export declare const buildGridArea: (box: any) => string;
32
32
  export declare const buildTranform: (box: any) => string;
33
33
  export declare const MIN_SIZE = 32;
34
- export declare const THREADHOLD = 3;
34
+ export declare const THREADHOLD = 5;
35
35
  export declare const getSafety: (fn: any, defaultValue?: string) => any;
@@ -100,7 +100,7 @@ export const buildTranform = box => {
100
100
  return 'unset';
101
101
  };
102
102
  export const MIN_SIZE = 32;
103
- export const THREADHOLD = 3;
103
+ export const THREADHOLD = 5;
104
104
  export const getSafety = (fn, defaultValue = '') => {
105
105
  try {
106
106
  return fn();
@@ -45,6 +45,7 @@ export const StyledLine = styled.div `
45
45
  top: -1px;
46
46
  left: -1px;
47
47
  background: red;
48
+ display: none;
48
49
 
49
50
  &.vertical {
50
51
  width: 1px;