@antscorp/antsomi-ui 1.3.3-beta.2 → 1.3.3-beta.20
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.
- package/es/assets/images/stars_slider.png +0 -0
- package/es/components/atoms/Flex/Flex.d.ts +2 -0
- package/es/components/atoms/Flex/Flex.js +1 -0
- package/es/components/atoms/Flex/index.d.ts +1 -0
- package/es/components/atoms/Flex/index.js +1 -0
- package/es/components/atoms/Input/Input.d.ts +11 -3
- package/es/components/atoms/Input/Input.js +3 -0
- package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
- package/es/components/atoms/RateV2/RateV2.js +73 -0
- package/es/components/atoms/RateV2/index.d.ts +1 -0
- package/es/components/atoms/RateV2/index.js +1 -0
- package/es/components/atoms/Slider/index.d.ts +2 -1
- package/es/components/atoms/Slider/index.js +7 -14
- package/es/components/atoms/SliderV2/index.d.ts +6 -0
- package/es/components/atoms/SliderV2/index.js +21 -0
- package/es/components/atoms/Spin/Spin.d.ts +2 -1
- package/es/components/atoms/index.d.ts +3 -0
- package/es/components/atoms/index.js +3 -0
- package/es/components/common/ConfigProvider/GlobalStyle.js +38 -1
- package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
- package/es/components/icons/AudioRecordIcon.d.ts +2 -1
- package/es/components/icons/BugIcon.d.ts +2 -1
- package/es/components/icons/CameraIcon.d.ts +2 -1
- package/es/components/icons/CaptureIcon.d.ts +2 -1
- package/es/components/icons/CheckSlimIcon.d.ts +2 -1
- package/es/components/icons/CloseIcon.d.ts +2 -1
- package/es/components/icons/CommentIcon.d.ts +2 -1
- package/es/components/icons/EventIcon.d.ts +2 -1
- package/es/components/icons/FreeDrawIcon.d.ts +2 -1
- package/es/components/icons/GPTIcon.d.ts +2 -1
- package/es/components/icons/GPTIconV2.d.ts +2 -1
- package/es/components/icons/GPTIconV3.d.ts +2 -1
- package/es/components/icons/HighlightIcon.d.ts +2 -1
- package/es/components/icons/IdeaIcon.d.ts +2 -1
- package/es/components/icons/InvisibleIcon.d.ts +2 -1
- package/es/components/icons/MuteIcon.d.ts +2 -1
- package/es/components/icons/OpenUrlIcon.d.ts +2 -1
- package/es/components/icons/PauseIcon.d.ts +2 -1
- package/es/components/icons/PlaneIcon.d.ts +2 -1
- package/es/components/icons/RequestIcon.d.ts +2 -1
- package/es/components/icons/StopRecordIcon.d.ts +2 -1
- package/es/components/icons/UserIcon.d.ts +2 -1
- package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
- package/es/components/icons/WarningIcon.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
- package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
- package/es/components/molecules/Collapse/Collapse.d.ts +3 -3
- package/es/components/molecules/Collapse/Collapse.js +9 -0
- package/es/components/molecules/FontFamilySelect/constants.d.ts +307 -0
- package/es/components/molecules/FontFamilySelect/constants.js +257 -0
- package/es/components/molecules/FontFamilySelect/index.d.ts +17 -0
- package/es/components/molecules/FontFamilySelect/index.js +53 -0
- package/es/components/molecules/FontSetting/constants.d.ts +3 -0
- package/es/components/molecules/FontSetting/constants.js +22 -0
- package/es/components/molecules/FontSetting/index.d.ts +24 -0
- package/es/components/molecules/FontSetting/index.js +54 -0
- package/es/components/molecules/FontSetting/types.d.ts +22 -0
- package/es/components/molecules/FontSetting/types.js +1 -0
- package/es/components/molecules/FontWeightSelect/constants.d.ts +28 -0
- package/es/components/molecules/FontWeightSelect/constants.js +11 -0
- package/es/components/molecules/FontWeightSelect/index.d.ts +9 -0
- package/es/components/molecules/FontWeightSelect/index.js +39 -0
- package/es/components/molecules/Form/Form.d.ts +1 -0
- package/es/components/molecules/Form/Form.js +1 -0
- package/es/components/molecules/Form/index.d.ts +1 -0
- package/es/components/molecules/Form/index.js +1 -0
- package/es/components/molecules/Modal/styled.d.ts +1 -1
- package/es/components/molecules/ResizeGrid/ResizeGrid.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/ResizeGrid.js +353 -0
- package/es/components/molecules/ResizeGrid/components/Cell/Cell.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +67 -0
- package/es/components/molecules/ResizeGrid/components/Cell/index.d.ts +1 -0
- package/es/components/molecules/ResizeGrid/components/Cell/index.js +1 -0
- package/es/components/molecules/ResizeGrid/components/Cell/styled.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/components/Cell/styled.js +62 -0
- package/es/components/molecules/ResizeGrid/constant.d.ts +34 -0
- package/es/components/molecules/ResizeGrid/constant.js +108 -0
- package/es/components/molecules/ResizeGrid/index.d.ts +2 -0
- package/es/components/molecules/ResizeGrid/index.js +1 -0
- package/es/components/molecules/ResizeGrid/styled.d.ts +3 -0
- package/es/components/molecules/ResizeGrid/styled.js +20 -0
- package/es/components/molecules/ResizeGrid/types.d.ts +128 -0
- package/es/components/molecules/ResizeGrid/types.js +1 -0
- package/es/components/molecules/Select/Select.d.ts +3 -0
- package/es/components/molecules/Select/Select.js +23 -2
- package/es/components/molecules/Select/Test.d.ts +2 -1
- package/es/components/molecules/SettingWrapper/index.d.ts +1 -2
- package/es/components/molecules/SettingWrapperPopover/index.d.ts +16 -0
- package/es/components/molecules/SettingWrapperPopover/index.js +17 -0
- package/es/components/molecules/TextDecorationSelect/constants.d.ts +19 -0
- package/es/components/molecules/TextDecorationSelect/constants.js +26 -0
- package/es/components/molecules/TextDecorationSelect/index.d.ts +15 -0
- package/es/components/molecules/TextDecorationSelect/index.js +45 -0
- package/es/components/molecules/TextTransformSelect/constants.d.ts +13 -0
- package/es/components/molecules/TextTransformSelect/constants.js +19 -0
- package/es/components/molecules/TextTransformSelect/index.d.ts +9 -0
- package/es/components/molecules/TextTransformSelect/index.js +39 -0
- package/es/components/molecules/TreeSelect/TreeSelect.d.ts +1 -1
- package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
- package/es/components/molecules/index.d.ts +10 -0
- package/es/components/molecules/index.js +8 -0
- package/es/constants/storybook.d.ts +2 -1
- package/es/constants/theme.js +25 -3
- package/es/hooks/useDeepCompareEffect.d.ts +1 -0
- package/es/hooks/useDeepCompareEffect.js +21 -0
- package/es/test.d.ts +2 -1
- package/es/test.js +8 -1
- package/package.json +6 -5
- package/dist/0173b5993573afa04880.woff +0 -0
- package/dist/0dfb9214dfd945cd7290.png +0 -1
- package/dist/2883cad25a2b4e87ce5f.eot +0 -0
- package/dist/4f54a37971347e3d7122.png +0 -1
- package/dist/574b7bee0563a9fe9a29.png +0 -1
- package/dist/6b586356e837581204dc.svg +0 -1
- package/dist/72eec5c1c786b45a667f.ttf +0 -0
- package/dist/bc6bf11c6f5e6743aa4c.png +0 -1
- package/dist/dbc405edd6e0806efbc9.svg +0 -1
- package/dist/e32f09119052a55cce3c.png +0 -1
- package/dist/e3851b9384a984c6fdb5.png +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.LICENSE.txt +0 -69
- package/dist/main.css +0 -69
- package/dist/public/icons/2d496b55d85a9545d7311c073af442bb.png +0 -0
- package/dist/public/icons/2fbb4e0927d18e3f8e5c6511ab88d5b3.png +0 -0
- package/dist/public/icons/725a52bd91a3ce534b10833df510e5fa.png +0 -0
- package/dist/public/icons/7d037e0b378e87a82804443636cd0e13.svg +0 -346
- package/dist/public/icons/90553767e0a05b9585a54797cfd9ce51.png +0 -0
- package/dist/public/icons/bb64e23a1ff390a416d765ee556096ab.svg +0 -87
- package/dist/public/icons/d327b24e9c5d8f486f08d253aab58ce6.png +0 -0
- package/dist/public/icons/f1cf266d0a0a53ce07f2dbb859869b7a.png +0 -0
- package/dist/public/icons/placeholder-image.png +0 -0
- package/dist/public/icons/transparent.svg +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
/* Components */
|
|
3
|
+
import { Space, Switch } from '../../atoms';
|
|
4
|
+
import { ColorSetting } from '../ColorSetting';
|
|
5
|
+
import { SliderWithInputNumber } from '../SliderWithInputNumber';
|
|
6
|
+
import { SettingWrapper } from '../SettingWrapper';
|
|
7
|
+
import { SettingWrapperPopover } from '../SettingWrapperPopover';
|
|
8
|
+
import { FontFamilySelect } from '../FontFamilySelect';
|
|
9
|
+
import { FontWeightSelect } from '../FontWeightSelect';
|
|
10
|
+
import { TextTransformSelect } from '../TextTransformSelect';
|
|
11
|
+
import { TextDecorationSelect } from '../TextDecorationSelect';
|
|
12
|
+
import { FONT_SETTING_DEFAULT, FONT_STYLE_DEFAULT } from './constants';
|
|
13
|
+
export const FontSettingEdit = ({ settings, styles, showSettings, onChange, }) => {
|
|
14
|
+
const handleChange = (setting, style) => {
|
|
15
|
+
if (typeof onChange === 'function') {
|
|
16
|
+
const newSettings = Object.assign(Object.assign({}, settings), setting);
|
|
17
|
+
const newStyles = Object.assign(Object.assign({}, styles), style);
|
|
18
|
+
onChange(newSettings, newStyles);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const settingMap = useMemo(() => ({
|
|
22
|
+
fontFamily: (React.createElement(FontFamilySelect, { label: "Font Family", value: settings === null || settings === void 0 ? void 0 : settings.fontFamily, onChange: fontFamily => handleChange({ fontFamily }, { fontFamily }) })),
|
|
23
|
+
color: (React.createElement(ColorSetting, { label: "Font Color", color: settings === null || settings === void 0 ? void 0 : settings.fontColor, onChange: fontColor => handleChange({ fontColor }, { color: fontColor }) })),
|
|
24
|
+
fontSize: (React.createElement(SettingWrapper, { label: "Font Size", vertical: true },
|
|
25
|
+
React.createElement(SliderWithInputNumber, { value: typeof (settings === null || settings === void 0 ? void 0 : settings.fontSize) !== 'undefined' ? +settings.fontSize : 0, onAfterChange: fontSize => handleChange({ fontSize }, { fontSize }) }))),
|
|
26
|
+
fontWeight: (React.createElement(FontWeightSelect, { label: "Font Weight", value: settings === null || settings === void 0 ? void 0 : settings.fontWeight, onChange: fontWeight => handleChange({ fontWeight }, { fontWeight }) })),
|
|
27
|
+
lineHeight: (React.createElement(SettingWrapper, { label: "Line Height", vertical: true },
|
|
28
|
+
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.lineHeight) !== 'undefined' ? +settings.lineHeight : 0, min: 1, max: 5, step: 0.1, onAfterChange: lineHeight => handleChange({ lineHeight }, { lineHeight }) }))),
|
|
29
|
+
letterSpacing: (React.createElement(SettingWrapper, { label: "Letter Spacing", vertical: true },
|
|
30
|
+
React.createElement(SliderWithInputNumber, { defaultValue: typeof (settings === null || settings === void 0 ? void 0 : settings.letterSpacing) !== 'undefined' ? +settings.letterSpacing : 0, min: -10, max: 10, onAfterChange: letterSpacing => handleChange({ letterSpacing }, { letterSpacing }) }))),
|
|
31
|
+
textTransform: (React.createElement(TextTransformSelect, { label: "Text Transform", value: settings === null || settings === void 0 ? void 0 : settings.textTransform, onChange: textTransform => handleChange({ textTransform }, { textTransform }) })),
|
|
32
|
+
textDecoration: (React.createElement(TextDecorationSelect, { label: "Text Decoration", value: settings === null || settings === void 0 ? void 0 : settings.textDecoration, onChange: textDecoration => handleChange({ textDecoration }, { textDecoration }) })),
|
|
33
|
+
italic: (React.createElement(SettingWrapper, { label: "Font Style Italic" },
|
|
34
|
+
React.createElement(Switch, { checked: settings === null || settings === void 0 ? void 0 : settings.fontItalic, onChange: fontItalic => handleChange({ fontItalic }, { fontStyle: fontItalic ? 'italic' : 'normal' }) }))),
|
|
35
|
+
}),
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
[settings]);
|
|
38
|
+
const filteredSetting = useMemo(() => {
|
|
39
|
+
if (!showSettings || (showSettings === null || showSettings === void 0 ? void 0 : showSettings.length) === 0) {
|
|
40
|
+
return Object.keys(settingMap).map(keySetting => settingMap[keySetting]);
|
|
41
|
+
}
|
|
42
|
+
return showSettings.map(keySetting => settingMap[keySetting]);
|
|
43
|
+
}, [showSettings, settingMap]);
|
|
44
|
+
return React.createElement(Space, { direction: "vertical" }, filteredSetting);
|
|
45
|
+
};
|
|
46
|
+
export const FontSetting = (props) => {
|
|
47
|
+
const { label, settings, styles, wrapperProps, popoverProps, childrenProps, showSettings, onChange, } = props;
|
|
48
|
+
return (React.createElement(SettingWrapperPopover, { label: label !== null && label !== void 0 ? label : 'Font Settings', popoverProps: Object.assign({ overlayStyle: { top: 0 }, placement: 'bottomRight' }, popoverProps), wrapperProps: Object.assign({ containerStyle: { minWidth: '288px' } }, wrapperProps) },
|
|
49
|
+
React.createElement(FontSettingEdit, Object.assign({ settings: settings, styles: styles, showSettings: showSettings, onChange: onChange }, childrenProps))));
|
|
50
|
+
};
|
|
51
|
+
FontSetting.defaultProps = {
|
|
52
|
+
settings: FONT_SETTING_DEFAULT,
|
|
53
|
+
styles: FONT_STYLE_DEFAULT,
|
|
54
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type TFontSettings = {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
fontColor: string;
|
|
4
|
+
fontSize: string | number;
|
|
5
|
+
fontWeight: string | number;
|
|
6
|
+
lineHeight: string | number;
|
|
7
|
+
letterSpacing: string | number;
|
|
8
|
+
textTransform: string | number;
|
|
9
|
+
textDecoration: string;
|
|
10
|
+
fontItalic: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type TFontStyles = {
|
|
13
|
+
fontFamily: string;
|
|
14
|
+
color: string;
|
|
15
|
+
fontSize: string | number;
|
|
16
|
+
fontWeight: string | number;
|
|
17
|
+
lineHeight: string | number;
|
|
18
|
+
letterSpacing: string | number;
|
|
19
|
+
textTransform: string | number;
|
|
20
|
+
textDecoration: string;
|
|
21
|
+
fontStyle: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const OPTION_FONT_WEIGHT: readonly [{
|
|
2
|
+
readonly label: "Thin";
|
|
3
|
+
readonly value: "100";
|
|
4
|
+
}, {
|
|
5
|
+
readonly label: "Extra Light";
|
|
6
|
+
readonly value: "200";
|
|
7
|
+
}, {
|
|
8
|
+
readonly label: "Light";
|
|
9
|
+
readonly value: "300";
|
|
10
|
+
}, {
|
|
11
|
+
readonly label: "Regular";
|
|
12
|
+
readonly value: "400";
|
|
13
|
+
}, {
|
|
14
|
+
readonly label: "Medium";
|
|
15
|
+
readonly value: "500";
|
|
16
|
+
}, {
|
|
17
|
+
readonly label: "Semi Bold";
|
|
18
|
+
readonly value: "600";
|
|
19
|
+
}, {
|
|
20
|
+
readonly label: "Bold";
|
|
21
|
+
readonly value: "700";
|
|
22
|
+
}, {
|
|
23
|
+
readonly label: "Extra Bold";
|
|
24
|
+
readonly value: "800";
|
|
25
|
+
}, {
|
|
26
|
+
readonly label: "Black";
|
|
27
|
+
readonly value: "900";
|
|
28
|
+
}];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const OPTION_FONT_WEIGHT = [
|
|
2
|
+
{ label: 'Thin', value: '100' },
|
|
3
|
+
{ label: 'Extra Light', value: '200' },
|
|
4
|
+
{ label: 'Light', value: '300' },
|
|
5
|
+
{ label: 'Regular', value: '400' },
|
|
6
|
+
{ label: 'Medium', value: '500' },
|
|
7
|
+
{ label: 'Semi Bold', value: '600' },
|
|
8
|
+
{ label: 'Bold', value: '700' },
|
|
9
|
+
{ label: 'Extra Bold', value: '800' },
|
|
10
|
+
{ label: 'Black', value: '900' },
|
|
11
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SelectProps } from '../Select';
|
|
3
|
+
import { OPTION_FONT_WEIGHT } from './constants';
|
|
4
|
+
export type FontWeightSelectProps = Omit<SelectProps, 'onChange'> & {
|
|
5
|
+
label?: string;
|
|
6
|
+
showOptions?: (typeof OPTION_FONT_WEIGHT)[number]['label'][];
|
|
7
|
+
onChange?: (family: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const FontWeightSelect: React.FC<FontWeightSelectProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
13
|
+
import { Select } from '../Select';
|
|
14
|
+
import { SettingWrapper } from '../SettingWrapper';
|
|
15
|
+
import { OPTION_FONT_WEIGHT } from './constants';
|
|
16
|
+
export const FontWeightSelect = props => {
|
|
17
|
+
const { defaultValue, label, value, showOptions, onChange } = props, selectProps = __rest(props, ["defaultValue", "label", "value", "showOptions", "onChange"]);
|
|
18
|
+
const [selected, setSelected] = useState(defaultValue || value);
|
|
19
|
+
const fontWeightOptions = useMemo(() => {
|
|
20
|
+
let draftFontFamily = [...OPTION_FONT_WEIGHT];
|
|
21
|
+
if (showOptions === null || showOptions === void 0 ? void 0 : showOptions.length) {
|
|
22
|
+
draftFontFamily = OPTION_FONT_WEIGHT.filter(({ label }) => showOptions.some(font => font === label));
|
|
23
|
+
}
|
|
24
|
+
return draftFontFamily;
|
|
25
|
+
}, [showOptions]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setSelected(value === null || value === void 0 ? void 0 : value.toString());
|
|
28
|
+
}, [value]);
|
|
29
|
+
const handleChange = (value) => {
|
|
30
|
+
if (onChange && typeof onChange === 'function') {
|
|
31
|
+
onChange(value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return (React.createElement(SettingWrapper, { label: label !== null && label !== void 0 ? label : '', containerStyle: { width: '100%' }, vertical: true },
|
|
35
|
+
React.createElement(Select, Object.assign({ value: selected, options: [...fontWeightOptions], style: { fontFamily: value, width: '100%' }, onChange: select => {
|
|
36
|
+
setSelected(select);
|
|
37
|
+
handleChange(select);
|
|
38
|
+
}, showSearch: true }, selectProps))));
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from 'antd';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from 'antd';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from './Form';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from './Form';
|
|
@@ -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) =>
|
|
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>;
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { Cell } from './components/Cell';
|
|
3
|
+
import { GRID_TEMPLATE, MIN_SIZE, buildGrid } from './constant';
|
|
4
|
+
import { StyledGrid } from './styled';
|
|
5
|
+
import { useDeepCompareEffect } from '../../../hooks/useDeepCompareEffect';
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
containerStyle: {},
|
|
8
|
+
cellBorderStyle: '1px dashed',
|
|
9
|
+
cellStyle: {},
|
|
10
|
+
cellActiveStyle: {},
|
|
11
|
+
isPreviewMode: false,
|
|
12
|
+
isCompact: false,
|
|
13
|
+
};
|
|
14
|
+
export const ResizeGrid = props => {
|
|
15
|
+
const { containerStyle, cellBorderStyle, cellStyle, cellActiveStyle, isPreviewMode, renderCell, grid: initGrid, image, imageSize, imagePosition, isCompact, } = props;
|
|
16
|
+
const [grid, setGrid] = useState(buildGrid(initGrid || GRID_TEMPLATE.GRID_2_3));
|
|
17
|
+
const startRef = useRef(null);
|
|
18
|
+
const startCellRef = useRef(null);
|
|
19
|
+
const selectRef = useRef(null);
|
|
20
|
+
const selectEndRef = useRef(null);
|
|
21
|
+
const gridRef = useRef();
|
|
22
|
+
const containerRef = useRef(null);
|
|
23
|
+
const cellsRef = useRef({});
|
|
24
|
+
const onChangeTimout = useRef();
|
|
25
|
+
// console.log('grid', grid)
|
|
26
|
+
const onChangeGrid = () => {
|
|
27
|
+
clearTimeout(onChangeTimout.current);
|
|
28
|
+
onChangeTimout.current = setTimeout(() => {
|
|
29
|
+
if (containerRef.current && cellsRef.current && cellsRef.current[0]) {
|
|
30
|
+
const container = containerRef.current.getBoundingClientRect();
|
|
31
|
+
const childs = Object.values(cellsRef.current).map(cell => {
|
|
32
|
+
if (!cell || !cell.current)
|
|
33
|
+
return;
|
|
34
|
+
const childBox = cell.current.getBoundingClientRect();
|
|
35
|
+
return {
|
|
36
|
+
width: childBox.width,
|
|
37
|
+
height: childBox.height,
|
|
38
|
+
x: childBox.x - container.x,
|
|
39
|
+
y: childBox.y - container.y,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
if (typeof props.onChangeGrid === 'function') {
|
|
43
|
+
props.onChangeGrid(grid, childs);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, 300);
|
|
47
|
+
};
|
|
48
|
+
const isFollow = (cell, line, isCol = true) => isCol
|
|
49
|
+
? (cell.colEnd !== line || !cell.width) && (cell.colStart !== line || !cell.width)
|
|
50
|
+
: (cell.rowEnd !== line || !cell.height) && (cell.rowStart !== line || !cell.height);
|
|
51
|
+
const notFollow = (cell, line, isCol = true) => !isFollow(cell, line, isCol);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
onChangeGrid();
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, [grid]);
|
|
56
|
+
useDeepCompareEffect(() => {
|
|
57
|
+
if ((initGrid === null || initGrid === void 0 ? void 0 : initGrid.rows) && (initGrid === null || initGrid === void 0 ? void 0 : initGrid.cols)) {
|
|
58
|
+
setGrid(buildGrid(initGrid));
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, [initGrid === null || initGrid === void 0 ? void 0 : initGrid.rows, initGrid === null || initGrid === void 0 ? void 0 : initGrid.cols, initGrid === null || initGrid === void 0 ? void 0 : initGrid.gridTemplateColumns, initGrid === null || initGrid === void 0 ? void 0 : initGrid.gridTemplateRows]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const handleMove = e => {
|
|
64
|
+
if (startRef.current && gridRef.current && containerRef.current) {
|
|
65
|
+
const { type, line } = startRef.current;
|
|
66
|
+
const idx = line - 1;
|
|
67
|
+
const { gridTemplateRows, gridTemplateColumns, rows, cols, childs } = gridRef.current;
|
|
68
|
+
if (idx <= 0 || (type === 'row' && idx >= rows) || (type === 'column' && idx >= cols))
|
|
69
|
+
return;
|
|
70
|
+
const { clientX, clientY } = e;
|
|
71
|
+
if (type === 'row') {
|
|
72
|
+
const gridHeight = containerRef.current.offsetHeight;
|
|
73
|
+
const yDistant = clientY - startRef.current.clientY;
|
|
74
|
+
const yPercentDistant = (100 * yDistant) / gridHeight;
|
|
75
|
+
const minPercent = (100 * MIN_SIZE) / gridHeight;
|
|
76
|
+
// console.log('move Y', clientY, yDistant, yPercentDistant);
|
|
77
|
+
const newArr = [...gridTemplateRows];
|
|
78
|
+
newArr[idx - 1] += yPercentDistant;
|
|
79
|
+
newArr[idx] -= yPercentDistant;
|
|
80
|
+
if (newArr[idx - 1] >= minPercent && newArr[idx] >= minPercent) {
|
|
81
|
+
const newChilds = JSON.parse(JSON.stringify(childs));
|
|
82
|
+
let isValidChildSize = true;
|
|
83
|
+
newChilds.forEach(child => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
if (isValidChildSize && notFollow(child, (_a = startRef.current) === null || _a === void 0 ? void 0 : _a.line, false)) {
|
|
86
|
+
if (child.rowStart === ((_b = startRef.current) === null || _b === void 0 ? void 0 : _b.line)) {
|
|
87
|
+
if (child.transformY) {
|
|
88
|
+
child.transformY = +child.transformY - yDistant;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
child.height = +child.height - yDistant;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
child.transformY && (child.height = +child.height + yDistant);
|
|
96
|
+
}
|
|
97
|
+
// console.log('check...', startRef.current.line, child.transformY, yDistant, +child.transformY - yDistant)
|
|
98
|
+
if (child.height < MIN_SIZE) {
|
|
99
|
+
isValidChildSize = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
isValidChildSize &&
|
|
104
|
+
setGrid(Object.assign(Object.assign({}, gridRef.current), { gridTemplateRows: newArr, childs: newChilds }));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const xDistant = clientX - startRef.current.clientX;
|
|
109
|
+
const gridWidth = containerRef.current.offsetWidth;
|
|
110
|
+
const xPercentDistant = (100 * xDistant) / gridWidth;
|
|
111
|
+
const minPercent = (100 * MIN_SIZE) / gridWidth;
|
|
112
|
+
// console.log('move X', clientX, xDistant, xPercentDistant);
|
|
113
|
+
const newArr = [...gridTemplateColumns];
|
|
114
|
+
newArr[idx - 1] += xPercentDistant;
|
|
115
|
+
newArr[idx] -= xPercentDistant;
|
|
116
|
+
if (newArr[idx - 1] >= minPercent && newArr[idx] >= minPercent) {
|
|
117
|
+
const newChilds = JSON.parse(JSON.stringify(childs));
|
|
118
|
+
let isValidChildSize = true;
|
|
119
|
+
newChilds.forEach(child => {
|
|
120
|
+
if (isValidChildSize && notFollow(child, line)) {
|
|
121
|
+
if (child.colStart === line) {
|
|
122
|
+
if (child.transformX) {
|
|
123
|
+
child.transformX = +child.transformX - xDistant;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
child.width = +child.width - xDistant;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
child.transformX && !child.movedRight && (child.width = +child.width + xDistant);
|
|
131
|
+
}
|
|
132
|
+
// console.log('check...', startRef.current.line, child.transformX, xDistant, +child.transformX - xDistant)
|
|
133
|
+
if (child.width < MIN_SIZE) {
|
|
134
|
+
isValidChildSize = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
isValidChildSize &&
|
|
139
|
+
setGrid(Object.assign(Object.assign({}, gridRef.current), { gridTemplateColumns: newArr, childs: newChilds }));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//-------------------------------------------
|
|
144
|
+
if (startCellRef.current && gridRef.current) {
|
|
145
|
+
const { clientX: startClientX, clientY: startClientY, idx, direction, isRevert, cell, nextCell, } = startCellRef.current;
|
|
146
|
+
const { rowStart, rowEnd, colStart, colEnd, transformX, transformY } = cell;
|
|
147
|
+
const { gridTemplateRows, gridTemplateColumns, rows, cols, childs } = gridRef.current;
|
|
148
|
+
if (idx < 0 ||
|
|
149
|
+
(direction === 'top' && rowStart === 1) ||
|
|
150
|
+
(direction === 'right' && colEnd === cols + 1) ||
|
|
151
|
+
(direction === 'bottom' && rowEnd === rows + 1) ||
|
|
152
|
+
(direction === 'left' && colStart === 1))
|
|
153
|
+
return;
|
|
154
|
+
const { clientX, clientY } = e;
|
|
155
|
+
if (['top', 'bottom'].includes(direction)) {
|
|
156
|
+
// const cellHeight = cellRef.current.offsetHeight;
|
|
157
|
+
const yDistant = clientY - startClientY;
|
|
158
|
+
// console.log('move Y', clientY, yDistant);
|
|
159
|
+
const newHeight = (cell.height || 0) + yDistant;
|
|
160
|
+
const newHeightNextCell = (nextCell.height || 0) - yDistant;
|
|
161
|
+
if (newHeight >= MIN_SIZE && newHeightNextCell >= MIN_SIZE) {
|
|
162
|
+
const newChilds = [...childs];
|
|
163
|
+
newChilds[idx] = Object.assign(Object.assign({}, childs[idx]), { height: newHeight, movedBottom: true });
|
|
164
|
+
newChilds[nextCell.idx] = Object.assign(Object.assign({}, childs[nextCell.idx]), { height: newHeightNextCell, transformY: (nextCell.transformY || 0) + yDistant, movedTop: true });
|
|
165
|
+
setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// const cellWidth = cellRef.current.offsetWidth;
|
|
170
|
+
const xDistant = clientX - startClientX;
|
|
171
|
+
// console.log('move X', clientX, xDistant);
|
|
172
|
+
const newWidth = (cell.width || 0) + xDistant;
|
|
173
|
+
const newWidthNextCell = (nextCell.width || 0) - xDistant;
|
|
174
|
+
if (newWidth >= MIN_SIZE && newWidthNextCell >= MIN_SIZE) {
|
|
175
|
+
const newChilds = [...childs];
|
|
176
|
+
newChilds[idx] = Object.assign(Object.assign({}, childs[idx]), { width: newWidth, movedRight: true });
|
|
177
|
+
newChilds[idx + 1] = Object.assign(Object.assign({}, childs[idx + 1]), { width: newWidthNextCell, transformX: (nextCell.transformX || 0) + xDistant, movedLeft: true });
|
|
178
|
+
setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//------------------------------------------
|
|
183
|
+
// if (selectRef.current) {}
|
|
184
|
+
};
|
|
185
|
+
const handleUp = () => {
|
|
186
|
+
startRef.current = null;
|
|
187
|
+
startCellRef.current = null;
|
|
188
|
+
};
|
|
189
|
+
window.addEventListener('mousemove', handleMove);
|
|
190
|
+
window.addEventListener('mouseup', handleUp);
|
|
191
|
+
return () => {
|
|
192
|
+
window.removeEventListener('mousemove', handleMove);
|
|
193
|
+
window.removeEventListener('mouseup', handleUp);
|
|
194
|
+
};
|
|
195
|
+
}, []);
|
|
196
|
+
const handleDownCell = (e, idx, direction, cell, cellRef) => {
|
|
197
|
+
const { clientX, clientY } = e;
|
|
198
|
+
const isRevert = ['top', 'left'].includes(direction);
|
|
199
|
+
let newIdx = isRevert ? idx - 1 : idx;
|
|
200
|
+
let nextCellIdx = isRevert ? idx - 1 : idx + 1;
|
|
201
|
+
if (['top', 'bottom'].includes(direction)) {
|
|
202
|
+
nextCellIdx = grid.childs.findIndex(b => b.colStart === cell.colStart &&
|
|
203
|
+
((isRevert && b.rowEnd === cell.rowStart) || (!isRevert && b.rowStart === cell.rowEnd)));
|
|
204
|
+
newIdx = isRevert ? nextCellIdx : idx;
|
|
205
|
+
}
|
|
206
|
+
if (nextCellIdx < 0)
|
|
207
|
+
return;
|
|
208
|
+
const nextCell = grid.childs[nextCellIdx];
|
|
209
|
+
const nextCellRef = cellsRef.current[nextCellIdx];
|
|
210
|
+
if (nextCell && nextCellRef && nextCellRef.current) {
|
|
211
|
+
const newDirection = isRevert
|
|
212
|
+
? {
|
|
213
|
+
left: 'right',
|
|
214
|
+
top: 'bottom',
|
|
215
|
+
}[direction]
|
|
216
|
+
: direction;
|
|
217
|
+
const cellInfo = Object.assign({ width: cell.width || cellRef.current.clientWidth, height: cell.height || cellRef.current.clientHeight, transformX: cell.transformX || 0, transformY: cell.transformY || 0, idx,
|
|
218
|
+
cellRef }, cell);
|
|
219
|
+
const nextCellInfo = Object.assign({ width: nextCell.width || nextCellRef.current.clientWidth, height: nextCell.height || nextCellRef.current.clientHeight, transformX: nextCell.transformX || 0, transformY: nextCell.transformY || 0, cellRef: nextCellRef, idx: nextCellIdx }, nextCell);
|
|
220
|
+
// console.log({cellInfo, nextCellInfo})
|
|
221
|
+
startCellRef.current = {
|
|
222
|
+
clientX,
|
|
223
|
+
clientY,
|
|
224
|
+
idx: newIdx,
|
|
225
|
+
direction: newDirection,
|
|
226
|
+
isRevert,
|
|
227
|
+
cell: isRevert ? nextCellInfo : cellInfo,
|
|
228
|
+
nextCell: !isRevert ? nextCellInfo : cellInfo,
|
|
229
|
+
};
|
|
230
|
+
// console.log('down cell', clientX, clientY, idx, direction, cell, cellRef);
|
|
231
|
+
gridRef.current = grid;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const handleDown = (e, type, line) => {
|
|
235
|
+
const { clientX, clientY } = e;
|
|
236
|
+
startRef.current = { clientX, clientY, type, line };
|
|
237
|
+
// console.log('down', type, line, clientX, clientY);
|
|
238
|
+
gridRef.current = JSON.parse(JSON.stringify(grid));
|
|
239
|
+
};
|
|
240
|
+
const handleUp = (e, direction, idx) => {
|
|
241
|
+
// console.log('up', direction, idx, e);
|
|
242
|
+
startRef.current = null;
|
|
243
|
+
startCellRef.current = null;
|
|
244
|
+
};
|
|
245
|
+
const downSelect = (idx, cell) => {
|
|
246
|
+
// console.log('dow select', idx, cell);
|
|
247
|
+
selectRef.current = { idx, cell };
|
|
248
|
+
gridRef.current = grid;
|
|
249
|
+
};
|
|
250
|
+
const unMerge = (cell, idx) => {
|
|
251
|
+
const { colStart, colEnd, rowStart, rowEnd } = cell;
|
|
252
|
+
if (colStart + 1 === colEnd && rowStart + 1 === rowEnd) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const newChilds = [...grid.childs];
|
|
256
|
+
for (let i = rowStart; i < rowEnd; i++) {
|
|
257
|
+
for (let j = colStart; j < colEnd; j++) {
|
|
258
|
+
const rStart = i;
|
|
259
|
+
const cStart = j;
|
|
260
|
+
const rEnd = rStart + 1;
|
|
261
|
+
const cEnd = cStart + 1;
|
|
262
|
+
// console.log('merge', i, j, rStart, cStart, rEnd, cEnd)
|
|
263
|
+
const newChild = {
|
|
264
|
+
colStart: cStart,
|
|
265
|
+
colEnd: cEnd,
|
|
266
|
+
rowStart: rStart,
|
|
267
|
+
rowEnd: rEnd,
|
|
268
|
+
};
|
|
269
|
+
if (i === rowStart && j === colStart) {
|
|
270
|
+
newChilds[idx] = newChild;
|
|
271
|
+
}
|
|
272
|
+
else if (rStart !== rowStart ||
|
|
273
|
+
rEnd !== rowEnd ||
|
|
274
|
+
cStart !== colStart ||
|
|
275
|
+
cEnd !== colEnd) {
|
|
276
|
+
newChilds.splice(idx, 0, newChild);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
setGrid(prev => (Object.assign(Object.assign({}, prev), { childs: newChilds })));
|
|
281
|
+
};
|
|
282
|
+
const resetBackgroundCellRef = () => {
|
|
283
|
+
Object.values(cellsRef.current).forEach(r => {
|
|
284
|
+
if (r.current) {
|
|
285
|
+
r.current.style.background = 'unset';
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
};
|
|
289
|
+
const upSelect = (idx, cell) => {
|
|
290
|
+
// console.log('up select', idx, cell);
|
|
291
|
+
resetBackgroundCellRef();
|
|
292
|
+
if (selectRef.current &&
|
|
293
|
+
selectEndRef.current &&
|
|
294
|
+
gridRef.current &&
|
|
295
|
+
selectRef.current.idx !== selectEndRef.current.idx &&
|
|
296
|
+
(selectEndRef.current.cell.rowEnd > selectRef.current.cell.rowEnd ||
|
|
297
|
+
selectEndRef.current.cell.colEnd > selectRef.current.cell.colEnd)) {
|
|
298
|
+
// console.log('merge', selectRef.current, selectEndRef.current)
|
|
299
|
+
const { cell: cellStart, idx: idxStart } = selectRef.current;
|
|
300
|
+
const { cell: cellEnd, idx: idxEnd, hCells } = selectEndRef.current;
|
|
301
|
+
const newChilds = [...gridRef.current.childs];
|
|
302
|
+
newChilds[idxStart].rowEnd = cellEnd.rowEnd;
|
|
303
|
+
newChilds[idxStart].colEnd = cellEnd.colEnd;
|
|
304
|
+
delete newChilds[idxStart].width;
|
|
305
|
+
delete newChilds[idxStart].height;
|
|
306
|
+
hCells.reverse().forEach(i => {
|
|
307
|
+
if (i !== idxStart) {
|
|
308
|
+
newChilds.splice(i, 1);
|
|
309
|
+
delete cellsRef.current[i];
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
setGrid(Object.assign(Object.assign({}, gridRef.current), { childs: newChilds }));
|
|
313
|
+
}
|
|
314
|
+
selectRef.current = null;
|
|
315
|
+
selectEndRef.current = null;
|
|
316
|
+
};
|
|
317
|
+
const hoverSelect = (idx, cell) => {
|
|
318
|
+
if (selectRef.current && gridRef.current) {
|
|
319
|
+
// console.log('hover select', idx, cell);
|
|
320
|
+
const { cell: cellStart, idx: idxStart } = selectRef.current;
|
|
321
|
+
const hCells = [];
|
|
322
|
+
gridRef.current.childs.forEach((child, i) => {
|
|
323
|
+
if (child.rowStart >= cellStart.rowStart &&
|
|
324
|
+
child.rowEnd <= cell.rowEnd &&
|
|
325
|
+
child.colStart >= cellStart.colStart &&
|
|
326
|
+
child.colEnd <= cell.colEnd) {
|
|
327
|
+
hCells.push(i);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
// console.log('hCells', hCells)
|
|
331
|
+
resetBackgroundCellRef();
|
|
332
|
+
hCells.forEach(i => {
|
|
333
|
+
const cellRef = cellsRef.current[i];
|
|
334
|
+
if (cellRef && cellRef.current) {
|
|
335
|
+
cellRef.current.style.background = 'rgba(255, 0, 255, .5)';
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
selectEndRef.current = { cell, idx, hCells };
|
|
339
|
+
gridRef.current = grid;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
const setRef = (idx, ref) => {
|
|
343
|
+
cellsRef.current[idx] = ref;
|
|
344
|
+
// console.log('cellsRef.current', cellsRef.current)
|
|
345
|
+
};
|
|
346
|
+
const renderGrid = () => {
|
|
347
|
+
const { gridTemplateColumns, gridTemplateRows, childs } = grid;
|
|
348
|
+
// console.log('grid', { gridTemplateColumns, gridTemplateRows, childs });
|
|
349
|
+
return (React.createElement("div", { className: "grid-container", ref: containerRef, style: Object.assign({ backgroundImage: `url(${image})`, backgroundSize: imageSize, backgroundPosition: imagePosition, gridTemplateColumns: gridTemplateColumns.map(fr => `${fr}%`).join(' '), gridTemplateRows: gridTemplateRows.map(fr => `${fr}%`).join(' ') }, containerStyle) }, childs.map((cell, idx) => (React.createElement(Cell, { key: idx, idx: idx, cell: cell, down: handleDown, downCell: handleDownCell, up: handleUp, setRef: setRef, downSelect: downSelect, upSelect: upSelect, hoverSelect: hoverSelect, unMerge: unMerge, renderCell: renderCell, borderStyle: cellBorderStyle, style: cellStyle, activeStyle: cellActiveStyle, isPreviewMode: isPreviewMode })))));
|
|
350
|
+
};
|
|
351
|
+
return (React.createElement(StyledGrid, { className: "grid-wrapper", isCompact: !!isCompact }, renderGrid()));
|
|
352
|
+
};
|
|
353
|
+
ResizeGrid.defaultProps = defaultProps;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { buildGridArea, buildTranform } from '../../constant';
|
|
3
|
+
import { StyledCell } from './styled';
|
|
4
|
+
export const Cell = ({ cell, idx, down, downCell, up, setRef, downSelect, upSelect, hoverSelect, unMerge, renderCell, style, isPreviewMode, borderStyle = '1px dashed', activeStyle, }) => {
|
|
5
|
+
const { objectFit, image } = cell;
|
|
6
|
+
const downRef = useRef(false);
|
|
7
|
+
const cellRef = useRef(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setRef(idx, cellRef);
|
|
10
|
+
}, [idx, cell]);
|
|
11
|
+
const handleHoverSelect = e => {
|
|
12
|
+
hoverSelect(idx, cell);
|
|
13
|
+
};
|
|
14
|
+
const handleDownCell = e => {
|
|
15
|
+
downSelect(idx, cell);
|
|
16
|
+
};
|
|
17
|
+
const handleUpCell = e => {
|
|
18
|
+
upSelect(idx, cell);
|
|
19
|
+
};
|
|
20
|
+
const handleDown = (direction, idx, e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
downRef.current = true;
|
|
23
|
+
// console.log('down', direction, idx, e)
|
|
24
|
+
const type = ['top', 'bottom'].includes(direction) ? 'row' : 'column';
|
|
25
|
+
const line = {
|
|
26
|
+
top: cell.rowStart,
|
|
27
|
+
right: cell.colEnd,
|
|
28
|
+
bottom: cell.rowEnd,
|
|
29
|
+
left: cell.colStart,
|
|
30
|
+
}[direction];
|
|
31
|
+
if (window.event.ctrlKey ||
|
|
32
|
+
(direction === 'top' && cell.movedTop) ||
|
|
33
|
+
(direction === 'right' && cell.movedRight) ||
|
|
34
|
+
(direction === 'bottom' && cell.movedBottom) ||
|
|
35
|
+
(direction === 'left' && cell.movedLeft)) {
|
|
36
|
+
downCell(e, idx, direction, cell, cellRef);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
down(e, type, line);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleUp = (direction, idx, e) => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
// console.log('up', direction, idx, e)
|
|
45
|
+
downRef.current = false;
|
|
46
|
+
up(e, direction, idx);
|
|
47
|
+
};
|
|
48
|
+
const handlUnMerge = e => {
|
|
49
|
+
unMerge(cell, idx);
|
|
50
|
+
};
|
|
51
|
+
const renderCellContent = (cell, idx) => renderCell
|
|
52
|
+
? renderCell(cell, idx)
|
|
53
|
+
: !!image && image.imageUrl && (React.createElement("div", { className: "imageWrapper" },
|
|
54
|
+
React.createElement("img", { src: image.imageUrl, alt: "menu", style: image.imageStyles })));
|
|
55
|
+
// const handleDrag = (direction, idx, e) => {
|
|
56
|
+
// if (!downRef.current) return;
|
|
57
|
+
// console.log(direction, idx, e)
|
|
58
|
+
// drag(e, direction, idx)
|
|
59
|
+
// }
|
|
60
|
+
// console.log('TRANSFORM', idx, buildTranform(cell))
|
|
61
|
+
return (React.createElement(StyledCell, { ref: cellRef, className: "cell", onMouseOver: e => handleHoverSelect(e), onFocus: e => e, onMouseDown: e => handleDownCell(e), onMouseUp: e => handleUpCell(e), onDoubleClick: handlUnMerge, borderStyle: borderStyle, style: Object.assign(Object.assign({ gridArea: buildGridArea(cell), width: cell.width ? `${cell.width}px` : 'unset', height: cell.height ? `${cell.height}px` : 'unset', transform: buildTranform(cell), borderTop: cell.rowStart === 1 ? borderStyle : 'unset', borderLeft: cell.colStart === 1 ? borderStyle : 'unset' }, (cell.active &&
|
|
62
|
+
(activeStyle || {
|
|
63
|
+
outline: '1px solid #005eb8',
|
|
64
|
+
}))), style) },
|
|
65
|
+
renderCellContent(cell, idx),
|
|
66
|
+
['top', 'right', 'bottom', 'left'].map(direction => (React.createElement("div", { key: direction, className: `resize-${direction}`, onMouseDown: e => handleDown(direction, idx, e), onMouseUp: e => handleUp(direction, idx, e) })))));
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cell } from './Cell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cell } from './Cell';
|