@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,3 @@
1
+ import { FC } from 'react';
2
+ import { CellProps } from '../../types';
3
+ export declare const Cell: FC<CellProps>;
@@ -0,0 +1,86 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { buildGridArea, buildTranform } from '../../constant';
3
+ import { StyledCell } from './styled';
4
+ import { useDeepCompareEffect } from '../../../../../hooks/useDeepCompareEffect';
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
+ const { objectFit, image } = cell;
7
+ const downRef = useRef(false);
8
+ const timeoutRef = useRef();
9
+ const cellRef = useRef(null);
10
+ useDeepCompareEffect(() => {
11
+ clearTimeout(timeoutRef.current);
12
+ timeoutRef.current = setTimeout(() => {
13
+ setCordinate(idx, cellRef);
14
+ }, 500);
15
+ }, [idx, cell, rowPercentage, colPercentage, cellRef]);
16
+ useEffect(() => {
17
+ setRef(idx, cellRef);
18
+ }, [idx, cell]);
19
+ const handleHoverSelect = e => {
20
+ hoverSelect(idx, cell);
21
+ };
22
+ const handleDownCell = e => {
23
+ downSelect(idx, cell);
24
+ };
25
+ const handleUpCell = e => {
26
+ upSelect(idx, cell);
27
+ };
28
+ const handleDown = (e, direction, idx) => {
29
+ e.stopPropagation();
30
+ downRef.current = true;
31
+ // console.log('down', direction, idx, e)
32
+ const type = ['top', 'bottom'].includes(direction) ? 'row' : 'column';
33
+ const line = {
34
+ top: cell.rowStart,
35
+ right: cell.colEnd,
36
+ bottom: cell.rowEnd,
37
+ left: cell.colStart,
38
+ }[direction];
39
+ if ((ctrlKeyRef === null || ctrlKeyRef === void 0 ? void 0 : ctrlKeyRef.current) ||
40
+ (direction === 'top' && cell.movedTop) ||
41
+ (direction === 'right' && cell.movedRight) ||
42
+ (direction === 'bottom' && cell.movedBottom) ||
43
+ (direction === 'left' && cell.movedLeft)) {
44
+ downCell(e, type, line, idx, direction, cell, cellRef);
45
+ }
46
+ else {
47
+ down(e, type, line, idx, direction, cell, cellRef);
48
+ }
49
+ };
50
+ const handleUp = (e, direction, idx) => {
51
+ e.stopPropagation();
52
+ // console.log('up', direction, idx, e)
53
+ downRef.current = false;
54
+ up(e, direction, idx);
55
+ };
56
+ const handlUnMerge = e => {
57
+ unMerge(cell, idx);
58
+ };
59
+ const renderCellContent = () => renderCell
60
+ ? renderCell(cell, idx)
61
+ : !!image &&
62
+ image.imageUrl && (React.createElement("div", { className: "imageWrapper" },
63
+ React.createElement("img", { src: image.imageUrl, alt: "menu", style: image.imageStyles })));
64
+ // const handleActiveCell = e => {
65
+ // activeCell(e, cell, idx);
66
+ // };
67
+ // const handleDrag = (direction, idx, e) => {
68
+ // if (!downRef.current) return;
69
+ // console.log(direction, idx, e)
70
+ // drag(e, direction, idx)
71
+ // }
72
+ // console.log('TRANSFORM', idx, buildTranform(cell))
73
+ return (React.createElement(StyledCell, { ref: cellRef, className: "cell",
74
+ // onClick={handleActiveCell}
75
+ onMouseOver: handleHoverSelect, onFocus: e => e, onMouseDown: handleDownCell, onMouseUp: handleUpCell, onDoubleClick: handlUnMerge, borderStyle: borderStyle || 'unset', style: Object.assign(Object.assign({ gridArea: buildGridArea(cell), width: cell.sizeX ? `${cell.sizeX}px` : 'unset', height: cell.sizeY ? `${cell.sizeY}px` : 'unset', transform: buildTranform(cell) }, (cell.active &&
76
+ (activeStyle || {
77
+ outline: '1px solid #005eb8',
78
+ }))), style) },
79
+ React.createElement("div", { className: "cell-content" }, renderCellContent()),
80
+ React.createElement("div", { className: "cell-border", style: {
81
+ borderTop: cell.rowStart === 1 ? borderStyle : 'unset',
82
+ borderLeft: cell.colStart === 1 ? borderStyle : 'unset',
83
+ display: isPreview ? 'none' : 'block',
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) })))));
86
+ };
@@ -0,0 +1 @@
1
+ export { Cell } from './Cell';
@@ -0,0 +1 @@
1
+ export { Cell } from './Cell';
@@ -0,0 +1,3 @@
1
+ export declare const StyledCell: import("styled-components").StyledComponent<"div", any, {
2
+ borderStyle: string;
3
+ }, never>;
@@ -0,0 +1,80 @@
1
+ // Libraries
2
+ import styled from 'styled-components';
3
+ export const StyledCell = styled.div `
4
+ // border: ${props => props.borderStyle};
5
+ // border-top: none;
6
+ // border-left: none;
7
+ // box-shadow: 1px 1px 0px 1px rgba(0, 0, 0, 0.1);
8
+ position: relative;
9
+ user-select: none;
10
+
11
+ .cell-border {
12
+ position: absolute;
13
+ inset: 0;
14
+ border: 1px solid #005eb8;
15
+ box-sizing: border-box;
16
+ border: ${props => props.borderStyle};
17
+ border-top: none;
18
+ border-left: none;
19
+ z-index: 1;
20
+ }
21
+ .cell-content {
22
+ position: relative;
23
+ height: 100%;
24
+ width: 100%;
25
+ z-index: 2;
26
+ }
27
+ .resize-top,
28
+ .resize-right,
29
+ .resize-bottom,
30
+ .resize-left {
31
+ position: absolute;
32
+ z-index: 3;
33
+ }
34
+
35
+ .resize-top,
36
+ .resize-bottom {
37
+ width: 100%;
38
+ height: 3px;
39
+ left: -1px;
40
+ cursor: row-resize;
41
+ }
42
+ .resize-left,
43
+ .resize-right {
44
+ width: 3px;
45
+ height: 100%;
46
+ top: -1px;
47
+ cursor: col-resize;
48
+ }
49
+
50
+ .resize-top {
51
+ // background: red;
52
+ top: -1px;
53
+ }
54
+ .resize-right {
55
+ // background: green;
56
+ right: -1px;
57
+ }
58
+ .resize-bottom {
59
+ // background: blue;
60
+ bottom: -1px;
61
+ }
62
+ .resize-left {
63
+ // background: yellow;
64
+ left: -1px;
65
+ }
66
+ .imageWrapper {
67
+ height: 100%;
68
+ max-width: 100%;
69
+ max-height: 100%;
70
+ img {
71
+ display: block;
72
+ width: 100%;
73
+ height: 100%;
74
+ max-width: 100%;
75
+ max-height: 100%;
76
+ object-fit: contain;
77
+ -webkit-user-drag: none;
78
+ }
79
+ }
80
+ `;
@@ -0,0 +1,35 @@
1
+ import { TGrid } from './types';
2
+ export declare const GRID_TEMPLATE: {
3
+ GRID_2_3: {
4
+ rows: number;
5
+ cols: number;
6
+ };
7
+ GRID_5_5: {
8
+ rows: number;
9
+ cols: number;
10
+ };
11
+ GRID_2_2: {
12
+ rows: number;
13
+ cols: number;
14
+ };
15
+ GRID_2_3_1: {
16
+ rows: number;
17
+ cols: number;
18
+ childs: ({
19
+ rowStart: number;
20
+ colStart: number;
21
+ colEnd: number;
22
+ } | {
23
+ rowStart: number;
24
+ colStart: number;
25
+ colEnd?: undefined;
26
+ })[];
27
+ };
28
+ };
29
+ export declare const buildCell: (cell: any) => any;
30
+ export declare const buildGrid: (inputGrid: Partial<TGrid>) => TGrid;
31
+ export declare const buildGridArea: (box: any) => string;
32
+ export declare const buildTranform: (box: any) => string;
33
+ export declare const MIN_SIZE = 32;
34
+ export declare const THREADHOLD = 5;
35
+ export declare const getSafety: (fn: any, defaultValue?: string) => any;
@@ -0,0 +1,111 @@
1
+ export const GRID_TEMPLATE = {
2
+ GRID_2_3: {
3
+ rows: 2,
4
+ cols: 3,
5
+ },
6
+ GRID_5_5: {
7
+ rows: 5,
8
+ cols: 5,
9
+ },
10
+ GRID_2_2: {
11
+ rows: 2,
12
+ cols: 2,
13
+ },
14
+ GRID_2_3_1: {
15
+ rows: 2,
16
+ cols: 3,
17
+ childs: [
18
+ {
19
+ rowStart: 1,
20
+ colStart: 1,
21
+ colEnd: 4,
22
+ },
23
+ {
24
+ rowStart: 2,
25
+ colStart: 1,
26
+ },
27
+ {
28
+ rowStart: 2,
29
+ colStart: 2,
30
+ },
31
+ {
32
+ rowStart: 2,
33
+ colStart: 3,
34
+ },
35
+ ],
36
+ },
37
+ };
38
+ export const buildCell = cell => (Object.assign({ rowEnd: cell.rowEnd || cell.rowStart + 1, colEnd: cell.colEnd || cell.colStart + 1 }, cell));
39
+ export const buildGrid = (inputGrid) => {
40
+ let childs = [];
41
+ const grid = JSON.parse(JSON.stringify(inputGrid));
42
+ let buildCol = !grid.gridTemplateColumns || !grid.gridTemplateColumns.length;
43
+ const buildRow = !grid.gridTemplateRows || !grid.gridTemplateRows.length;
44
+ const buildChild = !grid.childs || !grid.childs.length;
45
+ const gridTemplateColumns = grid.gridTemplateColumns || [];
46
+ const gridTemplateRows = grid.gridTemplateRows || [];
47
+ if (!buildChild && grid.childs) {
48
+ childs = grid.childs.map(buildCell);
49
+ }
50
+ if (buildChild || buildRow || buildCol) {
51
+ Array(grid.rows)
52
+ .fill(1)
53
+ .forEach((_, row) => {
54
+ if (buildRow && grid.rows) {
55
+ gridTemplateRows.push(100 / grid.rows);
56
+ }
57
+ Array(grid.cols)
58
+ .fill(1)
59
+ .forEach((__, col) => {
60
+ if (buildChild) {
61
+ childs.push({
62
+ rowStart: row + 1,
63
+ rowEnd: row + 2,
64
+ colStart: col + 1,
65
+ colEnd: col + 2,
66
+ active: false,
67
+ // image: {
68
+ // imageStyles: {},
69
+ // imageSettings: {},
70
+ // imageUrl: 'https://source.unsplash.com/random/300×300'
71
+ // },
72
+ objectFit: 'contain',
73
+ });
74
+ }
75
+ if (buildCol && grid.cols) {
76
+ gridTemplateColumns.push(100 / grid.cols);
77
+ }
78
+ });
79
+ buildCol = false;
80
+ });
81
+ }
82
+ return Object.assign(Object.assign({ rows: grid.rows || 1, cols: grid.rows || 1 }, grid), { gridTemplateColumns,
83
+ gridTemplateRows,
84
+ childs });
85
+ };
86
+ export const buildGridArea = box =>
87
+ // console.log('area', box, `${box.rowStart} / ${box.colStart} / ${box.rowEnd} / ${box.colEnd}`)
88
+ `${box.rowStart} / ${box.colStart} / ${box.rowEnd} / ${box.colEnd}`;
89
+ export const buildTranform = box => {
90
+ const { transformX, transformY } = box;
91
+ if (transformX && transformY) {
92
+ return `translate(${transformX}px, ${transformY}px)`;
93
+ }
94
+ if (transformX) {
95
+ return `translateX(${transformX}px)`;
96
+ }
97
+ if (transformY) {
98
+ return `translateY(${transformY}px)`;
99
+ }
100
+ return 'unset';
101
+ };
102
+ export const MIN_SIZE = 32;
103
+ export const THREADHOLD = 5;
104
+ export const getSafety = (fn, defaultValue = '') => {
105
+ try {
106
+ return fn();
107
+ }
108
+ catch (e) {
109
+ return defaultValue;
110
+ }
111
+ };
@@ -0,0 +1,2 @@
1
+ export { ResizeGrid } from './ResizeGrid';
2
+ export type { TGrid, TCell, IResizeGridProps } from './types';
@@ -0,0 +1 @@
1
+ export { ResizeGrid } from './ResizeGrid';
@@ -0,0 +1,10 @@
1
+ export declare const StyledGrid: import("styled-components").StyledComponent<"div", any, {
2
+ isCompact: boolean;
3
+ }, never>;
4
+ export declare const StyledMiddleLayer: import("styled-components").StyledComponent<"div", any, {
5
+ isCompact?: boolean | undefined;
6
+ }, never>;
7
+ export declare const StyledBGLayer: import("styled-components").StyledComponent<"div", any, {
8
+ isCompact?: boolean | undefined;
9
+ }, never>;
10
+ export declare const StyledLine: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,56 @@
1
+ // Libraries
2
+ import styled from 'styled-components';
3
+ export const StyledGrid = styled.div `
4
+ width: 100%;
5
+ box-sizing: border-box;
6
+ position: relative;
7
+
8
+ * {
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ .grid-container {
13
+ position: relative;
14
+ width: 100%;
15
+ height: 100%;
16
+ display: grid;
17
+ background: transparent;
18
+ aspect-ratio: ${props => (props.isCompact ? '3 / 1' : '3 / 2')};
19
+ z-index: 3;
20
+ }
21
+ `;
22
+ export const StyledMiddleLayer = styled.div `
23
+ width: 100%;
24
+ height: 100%;
25
+ position: absolute;
26
+ inset: 0;
27
+ // background: red;
28
+ z-index: 2;
29
+ `;
30
+ export const StyledBGLayer = styled.div `
31
+ width: 100%;
32
+ height: 100%;
33
+ position: absolute;
34
+ inset: 0;
35
+ // background: red;
36
+ z-index: 1;
37
+ background-repeat: no-repeat;
38
+ background-position: top left;
39
+ background-size: 100% 100%;
40
+ `;
41
+ export const StyledLine = styled.div `
42
+ position: absolute;
43
+ width: 100%;
44
+ height: 100%;
45
+ top: -1px;
46
+ left: -1px;
47
+ background: red;
48
+ display: none;
49
+
50
+ &.vertical {
51
+ width: 1px;
52
+ }
53
+ &.horizontal {
54
+ height: 1px;
55
+ }
56
+ `;
@@ -0,0 +1,147 @@
1
+ /// <reference types="react" />
2
+ export type TImageStyles = {
3
+ borderTopLeftRadius?: string;
4
+ borderTopRightRadius?: string;
5
+ borderBottomRightRadius?: string;
6
+ borderBottomLeftRadius?: string;
7
+ borderTopWidth?: string;
8
+ borderRightWidth?: string;
9
+ borderBottomWidth?: string;
10
+ borderLeftWidth?: string;
11
+ borderStyle?: string;
12
+ borderColor?: string;
13
+ boxShadow?: string;
14
+ opacity?: number;
15
+ width?: string;
16
+ height?: string;
17
+ objectPosition?: string;
18
+ objectFit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
19
+ paddingTop?: string;
20
+ paddingRight?: string;
21
+ paddingBottom?: string;
22
+ paddingLeft?: string;
23
+ };
24
+ export type TImageSettings = {
25
+ borderRadiusStyle?: string;
26
+ borderRadiusSuffix?: string;
27
+ linkedBorderRadiusInput?: boolean;
28
+ linkedBorderWidthInput?: boolean;
29
+ linkedPaddingInput?: boolean;
30
+ paddingSuffix?: string;
31
+ boxShadowStyle?: string;
32
+ boxShadowColor?: string;
33
+ boxShadowBlur?: string;
34
+ boxShadowSpread?: string;
35
+ boxShadowHorizontal?: string;
36
+ boxShadowVertical?: string;
37
+ boxShadowInset?: boolean;
38
+ widthSuffix?: string;
39
+ heightSuffix?: string;
40
+ };
41
+ export type TImage = {
42
+ imageUrl: string;
43
+ imageStyles: TImageStyles;
44
+ imageSettings: TImageSettings;
45
+ };
46
+ export type TCell = {
47
+ idx?: number;
48
+ cellRef?: React.RefObject<HTMLElement>;
49
+ rowStart: number;
50
+ rowEnd: number;
51
+ colStart: number;
52
+ colEnd: number;
53
+ width?: number;
54
+ height?: number;
55
+ sizeX?: number;
56
+ sizeY?: number;
57
+ transformX?: number;
58
+ transformY?: number;
59
+ movedTop?: boolean;
60
+ movedRight?: boolean;
61
+ movedBottom?: boolean;
62
+ movedLeft?: boolean;
63
+ image?: TImage;
64
+ objectFit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
65
+ active?: boolean;
66
+ };
67
+ export interface CellProps {
68
+ cell: TCell;
69
+ idx: number;
70
+ rowPercentage: number;
71
+ colPercentage: number;
72
+ down: Function;
73
+ downCell: Function;
74
+ up: Function;
75
+ setRef: Function;
76
+ setCordinate: Function;
77
+ downSelect: Function;
78
+ upSelect: Function;
79
+ hoverSelect: Function;
80
+ unMerge: Function;
81
+ renderCell?: Function;
82
+ activeCell?: Function;
83
+ borderStyle?: string;
84
+ style?: React.CSSProperties;
85
+ activeStyle?: React.CSSProperties;
86
+ isPreview?: boolean;
87
+ ctrlKeyRef?: React.RefObject<boolean>;
88
+ }
89
+ export type TGrid = {
90
+ rows: number;
91
+ cols: number;
92
+ gridTemplateColumns: number[];
93
+ gridTemplateRows: number[];
94
+ childs: TCell[];
95
+ };
96
+ export type TStartRef = {
97
+ clientX: number;
98
+ clientY: number;
99
+ type: 'row' | 'column';
100
+ line: number;
101
+ };
102
+ export type TCellExtend = TCell & {
103
+ cellRef: React.RefObject<HTMLElement>;
104
+ idx: number;
105
+ };
106
+ export type TStartCellRef = {
107
+ clientX: number;
108
+ clientY: number;
109
+ direction: 'top' | 'right' | 'bottom' | 'left';
110
+ isRevert: boolean;
111
+ leftCells: Record<string, TCellExtend>;
112
+ rightCells: Record<string, TCellExtend>;
113
+ fallback?: boolean;
114
+ };
115
+ export type TSelected = {
116
+ idx: number;
117
+ cell: TCell;
118
+ };
119
+ export type TSelectedEnd = {
120
+ cell: TCell;
121
+ idx: number;
122
+ hCells: number[];
123
+ };
124
+ export interface IResizeGridProps {
125
+ grid?: Partial<TGrid>;
126
+ renderCell?: Function;
127
+ onChange?: Function;
128
+ selectColor?: string;
129
+ image?: string;
130
+ imageSize?: 'cover' | 'contain' | 'fill';
131
+ imagePosition?: string;
132
+ cellStyle?: React.CSSProperties;
133
+ isPreview?: boolean;
134
+ cellBorder?: string;
135
+ cellActiveStyle?: React.CSSProperties;
136
+ containerStyle?: React.CSSProperties;
137
+ isCompact?: boolean;
138
+ delayUpdate?: number;
139
+ }
140
+ export type TCordinate = {
141
+ x: number;
142
+ y: number;
143
+ width: number;
144
+ height: number;
145
+ xEnd: number;
146
+ yEnd: number;
147
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { RichMenu } from '@antscorp/antsomi-ui/es/types';
3
+ export interface RichMenuBlockProps {
4
+ richMenu: RichMenu;
5
+ isPreview?: boolean;
6
+ onClickCell?: (cellIdx: number) => void;
7
+ onChange?: (richMenu: RichMenu, source?: 'user' | 'system') => void;
8
+ }
9
+ export declare const RichMenuBlock: React.FC<RichMenuBlockProps>;
@@ -0,0 +1,49 @@
1
+ // Libraries
2
+ import React from 'react';
3
+ import { cloneDeep, pick } from 'lodash';
4
+ // Components
5
+ import { ResizeGrid } from '@antscorp/antsomi-ui/es/components';
6
+ import { RichMenuCell } from './RichMenuCell';
7
+ // Utils
8
+ import { tryCatchWrapper } from '@antscorp/antsomi-ui/es/utils';
9
+ const PATH = 'src/app/modules/Dashboard/containers/RichMenu/containers/Design/components/Workspace/components/RichMenuBlock/index.tsx';
10
+ export const RichMenuBlock = props => {
11
+ const { richMenu, isPreview, onClickCell, onChange } = props;
12
+ const { gridTemplateCols = [], gridTemplateRows = [], cells = [], uploadMode, image, layoutType, rows, cols, } = richMenu || {};
13
+ const { imageUrl, imageStyles } = image || {};
14
+ const grid = {
15
+ rows,
16
+ cols,
17
+ gridTemplateColumns: gridTemplateCols.map(col => +String(col).replace('%', '')),
18
+ gridTemplateRows: gridTemplateRows.map(row => +String(row).replace('%', '')),
19
+ childs: cells.map(item => item),
20
+ };
21
+ const isSingleUploadMode = uploadMode === 'single';
22
+ // Handlers
23
+ const handleClickCell = (cellIdx) => {
24
+ // If is preview is true then not do anything
25
+ if (isPreview)
26
+ return;
27
+ if (onClickCell) {
28
+ onClickCell(cellIdx);
29
+ }
30
+ };
31
+ const handleGridChange = tryCatchWrapper((gridInfo, ctx, source) => {
32
+ if (richMenu) {
33
+ const { rows, cols, gridTemplateRows, gridTemplateColumns, childs } = gridInfo;
34
+ const gridTemplateColsUnit = (gridTemplateColumns === null || gridTemplateColumns === void 0 ? void 0 : gridTemplateColumns.map(col => `${col}%`)) || [];
35
+ const gridTemplateRowsUnit = (gridTemplateRows === null || gridTemplateRows === void 0 ? void 0 : gridTemplateRows.map(row => `${row}%`)) || [];
36
+ const cells = childs === null || childs === void 0 ? void 0 : childs.map((child, idx) => {
37
+ const item = cloneDeep(child);
38
+ const cellBounds = pick(ctx[idx], ['x', 'y', 'width', 'height']);
39
+ return Object.assign(Object.assign({}, item), cellBounds);
40
+ });
41
+ const newRichMenu = Object.assign(Object.assign({}, richMenu), { rows: rows || 1, cols: cols || 1, gridTemplateRows: gridTemplateRowsUnit, gridTemplateCols: gridTemplateColsUnit, cells: cells });
42
+ if (onChange) {
43
+ onChange(newRichMenu, source);
44
+ }
45
+ }
46
+ }, PATH);
47
+ const renderCell = (cellInfo, ctx) => (React.createElement(RichMenuCell, { context: ctx, cell: cellInfo, isSingleMode: isSingleUploadMode, onClick: handleClickCell }));
48
+ return (React.createElement(ResizeGrid, { grid: grid, image: imageUrl, isPreview: isPreview, containerStyle: imageStyles, imagePosition: imageStyles === null || imageStyles === void 0 ? void 0 : imageStyles.objectPosition, imageSize: imageStyles === null || imageStyles === void 0 ? void 0 : imageStyles.objectFit, isCompact: layoutType === 'compact', renderCell: renderCell, cellActiveStyle: { background: 'rgba(0, 95, 184, 0.5)' }, cellBorder: isSingleUploadMode ? '1px solid rgba(0, 95, 184, 1)' : '1px dotted #000000', onChange: handleGridChange }));
49
+ };
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { TChildrenCell } from '@antscorp/antsomi-ui/es/types';
3
+ interface RichMenuCellProps {
4
+ cell: TChildrenCell;
5
+ context: number;
6
+ isSingleMode: boolean;
7
+ onClick: (index: number) => void;
8
+ }
9
+ export declare const RichMenuCell: FC<RichMenuCellProps>;
10
+ export {};
@@ -0,0 +1,47 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ // Libraries
13
+ import React from 'react';
14
+ import { isEmpty } from 'lodash';
15
+ // Components
16
+ import { Icon } from '@antscorp/antsomi-ui/es/components';
17
+ // Styled
18
+ import { AddContainer, AddLabel, CellContainer, CellImage } from './styled';
19
+ // Utils
20
+ import { tryCatchWrapper } from '@antscorp/antsomi-ui/es/utils';
21
+ // Translations
22
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
23
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
24
+ const PATH = 'src/app/modules/Dashboard/containers/RichMenu/containers/Design/components/Workspace/components/RichMenuCell';
25
+ export const RichMenuCell = props => {
26
+ const { cell, context, isSingleMode, onClick } = props;
27
+ const { areaStyles } = cell;
28
+ // Translations
29
+ const { t } = i18nInstance;
30
+ const renderCellContent = (isShow, cellInfo) => {
31
+ if (!isShow)
32
+ return null;
33
+ const { image } = cellInfo;
34
+ const { imageUrl, imageStyles } = image;
35
+ const { objectPosition, objectFit } = imageStyles, restImageStyles = __rest(imageStyles, ["objectPosition", "objectFit"]);
36
+ const isBlank = isEmpty(imageUrl);
37
+ if (isBlank)
38
+ return (React.createElement(AddContainer, null,
39
+ React.createElement(Icon, { type: "icon-ants-plus-circle", size: 20, style: { color: 'rgba(0, 95, 184, 1)' } }),
40
+ React.createElement(AddLabel, null, t(translations.cellAction).toString())));
41
+ return (React.createElement(CellImage, { src: imageUrl, imagePosition: objectPosition, imageSize: objectFit, style: restImageStyles }));
42
+ };
43
+ return (React.createElement(CellContainer, { key: context, style: !isSingleMode ? areaStyles : {}, onClick: e => {
44
+ e.stopPropagation();
45
+ tryCatchWrapper(onClick, PATH)(context);
46
+ } }, renderCellContent(!isSingleMode, cell)));
47
+ };