@yorab/react-paint 0.6.4 → 0.7.1
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/README.md +5 -5
- package/dist/components/App.js +236 -423
- package/dist/components/Canvas.js +120 -139
- package/dist/components/common/Button.js +41 -50
- package/dist/components/common/Loading.js +24 -33
- package/dist/components/common/Modal.js +18 -17
- package/dist/components/common/Panel.js +20 -28
- package/dist/components/common/Snackbar.js +31 -38
- package/dist/components/settings/ColorField.js +59 -68
- package/dist/components/settings/DeleteButton.js +10 -9
- package/dist/components/settings/FontFamilyField.js +25 -20
- package/dist/components/settings/LayoutButton.js +11 -9
- package/dist/components/settings/Layouts.js +111 -111
- package/dist/components/settings/LineArrowField.js +25 -22
- package/dist/components/settings/LineTypeField.js +23 -20
- package/dist/components/settings/PointsNumberField.js +14 -13
- package/dist/components/settings/RangeField.js +35 -47
- package/dist/components/settings/SelectField.js +34 -43
- package/dist/components/settings/SettingsBar.js +100 -121
- package/dist/components/settings/ToggleField.js +18 -25
- package/dist/components/toolbox/EditTextBox.js +62 -49
- package/dist/components/toolbox/LoadFileTool.js +19 -21
- package/dist/components/toolbox/MenuGroup.js +66 -100
- package/dist/components/toolbox/PictureUrlInput.js +33 -62
- package/dist/components/toolbox/Tool.js +13 -13
- package/dist/components/toolbox/Toolbar.js +79 -113
- package/dist/components/toolbox/ToolbarGroup.js +60 -63
- package/dist/constants/app.js +51 -0
- package/dist/constants/icons.js +42 -48
- package/dist/constants/loading.js +8 -0
- package/dist/constants/shapes.js +10 -8
- package/dist/constants/snackbar.js +7 -15
- package/dist/constants/style.js +21 -18
- package/dist/constants/tools.js +99 -103
- package/dist/hooks/useComponent.js +15 -20
- package/dist/hooks/useDoubleClick.js +12 -12
- package/dist/hooks/useDrag.js +24 -32
- package/dist/hooks/useDrawableCanvas.js +106 -122
- package/dist/hooks/useKeyboard.js +80 -63
- package/dist/hooks/useResizeObserver.js +18 -16
- package/dist/hooks/useShapes.js +92 -144
- package/dist/hooks/useSnackbar.js +28 -58
- package/dist/styles.css +16 -13
- package/dist/types/Mode.js +1 -13
- package/dist/types/Shapes.js +1 -17
- package/dist/types/snackbar.js +5 -0
- package/dist/types/tools.js +1 -18
- package/dist/utils/canvas.js +49 -0
- package/dist/utils/data.js +15 -274
- package/dist/utils/dom.js +12 -0
- package/dist/utils/file.js +75 -120
- package/dist/utils/intersect.js +54 -131
- package/dist/utils/migration.js +59 -0
- package/dist/utils/selection.js +18 -20
- package/dist/utils/shapes/brush.js +135 -0
- package/dist/utils/shapes/circle.js +93 -0
- package/dist/utils/shapes/curve.js +55 -0
- package/dist/utils/shapes/default.js +73 -0
- package/dist/utils/shapes/ellipse.js +101 -0
- package/dist/utils/shapes/grid.js +36 -0
- package/dist/utils/shapes/index.js +341 -0
- package/dist/utils/shapes/line.js +179 -0
- package/dist/utils/shapes/picture.js +88 -0
- package/dist/utils/shapes/polygon.js +69 -0
- package/dist/utils/shapes/rectangle.js +100 -0
- package/dist/utils/shapes/text.js +128 -0
- package/dist/utils/shapes/triangle.js +24 -0
- package/dist/utils/string.js +10 -16
- package/dist/utils/style.js +11 -13
- package/dist/utils/toolbar.js +35 -49
- package/dist/utils/transform.js +47 -339
- package/dist/utils/trigo.js +42 -0
- package/package.json +6 -6
- package/Changelog.md +0 -119
- package/dist/types/keyboard.js +0 -28
- package/dist/utils/draw.js +0 -461
- package/dist/utils/shapeData.js +0 -173
|
@@ -2,203 +2,184 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
+
exports.default = void 0;
|
|
13
9
|
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
11
|
|
|
16
12
|
var _react2 = require("@linaria/react");
|
|
17
13
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _Shapes = require("../types/Shapes");
|
|
21
|
-
|
|
22
|
-
var _draw = require("../utils/draw");
|
|
23
|
-
|
|
24
|
-
var _Mode = require("../types/Mode");
|
|
25
|
-
|
|
26
|
-
var _transform = require("../utils/transform");
|
|
14
|
+
var _canvas = require("../utils/canvas");
|
|
27
15
|
|
|
28
16
|
var _EditTextBox = _interopRequireDefault(require("./toolbox/EditTextBox"));
|
|
29
17
|
|
|
30
|
-
var
|
|
18
|
+
var _useDrawableCanvas = _interopRequireDefault(require("../hooks/useDrawableCanvas"));
|
|
31
19
|
|
|
32
|
-
var
|
|
20
|
+
var _shapes = require("../utils/shapes");
|
|
33
21
|
|
|
34
|
-
var
|
|
22
|
+
var _text = require("../utils/shapes/text");
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
var _grid = require("../utils/shapes/grid");
|
|
37
25
|
|
|
38
|
-
function
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
27
|
|
|
40
|
-
function
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
29
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
const renderDrawCanvas = (drawCtx, selectionMode, canvasSize, gridFormat, canvasOffset, shapes, selectionPadding, selectedShape) => {
|
|
31
|
+
const {
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
scaleRatio
|
|
35
|
+
} = canvasSize;
|
|
48
36
|
drawCtx.clearRect(0, 0, width, height);
|
|
37
|
+
(0, _canvas.initCanvasContext)(drawCtx);
|
|
38
|
+
gridFormat && (0, _grid.drawGrid)(drawCtx, width, height, scaleRatio, canvasOffset, gridFormat);
|
|
49
39
|
|
|
50
|
-
for (
|
|
51
|
-
if (selectionMode.mode !==
|
|
52
|
-
(0,
|
|
40
|
+
for (let i = shapes.length - 1; i >= 0; i--) {
|
|
41
|
+
if (selectionMode.mode !== 'textedition' || shapes[i] !== selectedShape) {
|
|
42
|
+
(0, _shapes.drawShape)(drawCtx, shapes[i], scaleRatio, canvasOffset, selectionPadding);
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
45
|
};
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
const renderSelectionCanvas = (selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape) => {
|
|
48
|
+
const {
|
|
49
|
+
width,
|
|
50
|
+
height,
|
|
51
|
+
scaleRatio
|
|
52
|
+
} = canvasSize;
|
|
61
53
|
selectionCtx.clearRect(0, 0, width, height);
|
|
62
|
-
selectedShape && activeTool.type !==
|
|
54
|
+
selectedShape && activeTool.type !== 'brush' && (0, _shapes.drawShapeSelection)({
|
|
63
55
|
ctx: selectionCtx,
|
|
64
56
|
shape: selectedShape,
|
|
65
|
-
scaleRatio
|
|
66
|
-
canvasOffset
|
|
67
|
-
selectionPadding
|
|
68
|
-
selectionWidth
|
|
69
|
-
selectionColor
|
|
70
|
-
withAnchors: selectionMode.mode !==
|
|
57
|
+
scaleRatio,
|
|
58
|
+
canvasOffset,
|
|
59
|
+
selectionPadding,
|
|
60
|
+
selectionWidth,
|
|
61
|
+
selectionColor,
|
|
62
|
+
withAnchors: selectionMode.mode !== 'textedition'
|
|
71
63
|
});
|
|
72
64
|
};
|
|
73
65
|
|
|
74
|
-
|
|
66
|
+
const StyledCanvasBox = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
75
67
|
name: "StyledCanvasBox",
|
|
76
|
-
|
|
68
|
+
class: "s9czb9p"
|
|
77
69
|
});
|
|
78
|
-
|
|
70
|
+
const StyledCanvasContainer = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
79
71
|
name: "StyledCanvasContainer",
|
|
80
|
-
|
|
72
|
+
class: "s1538eht"
|
|
81
73
|
});
|
|
82
|
-
|
|
74
|
+
const StyledDrawCanvas = /*#__PURE__*/(0, _react2.styled)('canvas')({
|
|
83
75
|
name: "StyledDrawCanvas",
|
|
84
|
-
|
|
76
|
+
class: "s101qxdc"
|
|
85
77
|
});
|
|
86
|
-
|
|
78
|
+
const StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)('canvas')({
|
|
87
79
|
name: "StyledSelectionCanvas",
|
|
88
|
-
|
|
80
|
+
class: "sa4oq48",
|
|
89
81
|
vars: {
|
|
90
|
-
"sa4oq48-0": [
|
|
91
|
-
|
|
82
|
+
"sa4oq48-0": [_ref => {
|
|
83
|
+
let {
|
|
84
|
+
cursor
|
|
85
|
+
} = _ref;
|
|
92
86
|
return cursor;
|
|
93
87
|
}]
|
|
94
88
|
}
|
|
95
89
|
});
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
(0, _react.
|
|
126
|
-
|
|
91
|
+
const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
92
|
+
let {
|
|
93
|
+
gridFormat,
|
|
94
|
+
canGrow,
|
|
95
|
+
disabled = false,
|
|
96
|
+
canvasSize,
|
|
97
|
+
shapes,
|
|
98
|
+
addShape,
|
|
99
|
+
updateSingleShape,
|
|
100
|
+
selectedShape,
|
|
101
|
+
setSelectedShape,
|
|
102
|
+
saveShapes,
|
|
103
|
+
activeTool,
|
|
104
|
+
setActiveTool,
|
|
105
|
+
canvasOffsetStartPosition,
|
|
106
|
+
setCanvasOffsetStartPosition,
|
|
107
|
+
canvasOffset,
|
|
108
|
+
setCanvasOffset,
|
|
109
|
+
isInsideComponent,
|
|
110
|
+
selectionMode,
|
|
111
|
+
setSelectionMode,
|
|
112
|
+
selectionWidth,
|
|
113
|
+
selectionColor,
|
|
114
|
+
selectionPadding,
|
|
115
|
+
isEditMode,
|
|
116
|
+
isShiftPressed
|
|
117
|
+
} = _ref2;
|
|
118
|
+
const drawCanvasRef = (0, _react.useRef)(null);
|
|
119
|
+
const selectionCanvasRef = (0, _react.useRef)(null); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
120
|
+
|
|
121
|
+
(0, _react.useImperativeHandle)(ref, () => drawCanvasRef.current);
|
|
122
|
+
const {
|
|
123
|
+
hoverMode
|
|
124
|
+
} = (0, _useDrawableCanvas.default)({
|
|
125
|
+
disabled,
|
|
126
|
+
addShape,
|
|
127
|
+
canvasSize,
|
|
128
|
+
drawCanvasRef,
|
|
129
|
+
setActiveTool,
|
|
130
|
+
shapes,
|
|
131
|
+
selectionMode,
|
|
132
|
+
activeTool,
|
|
133
|
+
isInsideComponent,
|
|
134
|
+
setCanvasOffset,
|
|
135
|
+
selectedShape,
|
|
136
|
+
selectionCanvasRef,
|
|
137
|
+
canvasOffsetStartPosition,
|
|
138
|
+
setSelectedShape,
|
|
139
|
+
setCanvasOffsetStartPosition,
|
|
140
|
+
updateSingleShape,
|
|
141
|
+
gridFormat,
|
|
142
|
+
canvasOffset,
|
|
143
|
+
saveShapes,
|
|
144
|
+
setSelectionMode,
|
|
145
|
+
selectionPadding,
|
|
146
|
+
isShiftPressed
|
|
127
147
|
});
|
|
148
|
+
const updateSelectedShapeText = (0, _react.useCallback)(newText => {
|
|
149
|
+
var _drawCanvasRef$curren;
|
|
128
150
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
addShape: addShape,
|
|
132
|
-
canvasSize: canvasSize,
|
|
133
|
-
drawCanvasRef: drawCanvasRef,
|
|
134
|
-
setActiveTool: setActiveTool,
|
|
135
|
-
shapes: shapes,
|
|
136
|
-
selectionMode: selectionMode,
|
|
137
|
-
activeTool: activeTool,
|
|
138
|
-
isInsideComponent: isInsideComponent,
|
|
139
|
-
setCanvasOffset: setCanvasOffset,
|
|
140
|
-
selectedShape: selectedShape,
|
|
141
|
-
selectionCanvasRef: selectionCanvasRef,
|
|
142
|
-
canvasOffsetStartPosition: canvasOffsetStartPosition,
|
|
143
|
-
setSelectedShape: setSelectedShape,
|
|
144
|
-
setCanvasOffsetStartPosition: setCanvasOffsetStartPosition,
|
|
145
|
-
updateSingleShape: updateSingleShape,
|
|
146
|
-
canvasOffset: canvasOffset,
|
|
147
|
-
saveShapes: saveShapes,
|
|
148
|
-
setSelectionMode: setSelectionMode,
|
|
149
|
-
selectionPadding: selectionPadding
|
|
150
|
-
}),
|
|
151
|
-
hoverMode = _useDrawableCanvas.hoverMode;
|
|
152
|
-
|
|
153
|
-
var updateSelectedShapeText = (0, _react.useCallback)(function (newText) {
|
|
154
|
-
var _drawCanvasRef$curren, _newShape$style$fontB, _newShape$style, _newShape$style$fontI, _newShape$style2, _newShape$style3;
|
|
155
|
-
|
|
156
|
-
if ((selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) !== _Shapes.ShapeEnum.text) return;
|
|
157
|
-
var ctx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
151
|
+
if ((selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) !== 'text') return;
|
|
152
|
+
const ctx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
158
153
|
if (!ctx) return;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var resizedShape = _objectSpread(_objectSpread({}, newShape), {}, {
|
|
165
|
-
width: newWidth,
|
|
166
|
-
height: newShape.fontSize * newShape.value.length
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
updateSingleShape(resizedShape);
|
|
170
|
-
}, [updateSingleShape, selectedShape]);
|
|
171
|
-
(0, _react.useEffect)(function () {
|
|
154
|
+
const newShape = (0, _text.resizeTextShapeWithNewContent)(ctx, selectedShape, newText, canvasOffset);
|
|
155
|
+
updateSingleShape(newShape);
|
|
156
|
+
}, [updateSingleShape, selectedShape, canvasOffset]);
|
|
157
|
+
(0, _react.useEffect)(() => {
|
|
172
158
|
var _drawCanvasRef$curren2;
|
|
173
159
|
|
|
174
|
-
|
|
175
|
-
drawCtx && window.requestAnimationFrame(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}, [shapes, selectionMode, selectedShape, canvasOffset, canvasSize, selectionPadding]);
|
|
179
|
-
(0, _react.useEffect)(function () {
|
|
160
|
+
const drawCtx = (_drawCanvasRef$curren2 = drawCanvasRef.current) === null || _drawCanvasRef$curren2 === void 0 ? void 0 : _drawCanvasRef$curren2.getContext('2d');
|
|
161
|
+
drawCtx && window.requestAnimationFrame(() => renderDrawCanvas(drawCtx, selectionMode, canvasSize, gridFormat, canvasOffset, shapes, selectionPadding, selectedShape));
|
|
162
|
+
}, [shapes, gridFormat, selectionMode, selectedShape, canvasOffset, canvasSize, selectionPadding]);
|
|
163
|
+
(0, _react.useEffect)(() => {
|
|
180
164
|
var _selectionCanvasRef$c;
|
|
181
165
|
|
|
182
|
-
|
|
183
|
-
selectionCtx && window.requestAnimationFrame(
|
|
184
|
-
return renderSelectionCanvas(selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape);
|
|
185
|
-
});
|
|
166
|
+
const selectionCtx = (_selectionCanvasRef$c = selectionCanvasRef.current) === null || _selectionCanvasRef$c === void 0 ? void 0 : _selectionCanvasRef$c.getContext('2d');
|
|
167
|
+
selectionCtx && window.requestAnimationFrame(() => renderSelectionCanvas(selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape));
|
|
186
168
|
}, [selectionMode, selectedShape, activeTool, canvasOffset, canvasSize, selectionPadding, selectionWidth, selectionColor]);
|
|
187
|
-
return /*#__PURE__*/_react
|
|
188
|
-
"data-grid": withGrid,
|
|
169
|
+
return /*#__PURE__*/_react.default.createElement(StyledCanvasBox, null, /*#__PURE__*/_react.default.createElement(StyledCanvasContainer, {
|
|
189
170
|
"data-grow": canGrow
|
|
190
|
-
}, /*#__PURE__*/_react
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(StyledDrawCanvas, {
|
|
191
172
|
ref: drawCanvasRef,
|
|
192
173
|
"data-grow": canGrow,
|
|
193
174
|
width: canvasSize.width,
|
|
194
175
|
height: canvasSize.height
|
|
195
|
-
}), isEditMode && /*#__PURE__*/_react
|
|
176
|
+
}), isEditMode && /*#__PURE__*/_react.default.createElement(StyledSelectionCanvas, {
|
|
196
177
|
ref: selectionCanvasRef,
|
|
197
178
|
width: canvasSize.width,
|
|
198
179
|
height: canvasSize.height,
|
|
199
180
|
"data-grow": canGrow,
|
|
200
|
-
cursor: activeTool.type !==
|
|
201
|
-
}), isEditMode && selectionMode.mode ===
|
|
181
|
+
cursor: activeTool.type !== 'selection' && activeTool.type !== 'move' || hoverMode.mode === 'resize' ? 'crosshair' : activeTool.type === 'move' || hoverMode.mode === 'translate' ? 'move' : hoverMode.mode === 'rotate' ? 'grab' : 'default'
|
|
182
|
+
}), isEditMode && selectionMode.mode === 'textedition' && (selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) === 'text' && /*#__PURE__*/_react.default.createElement(_EditTextBox.default, {
|
|
202
183
|
scaleRatio: canvasSize.scaleRatio,
|
|
203
184
|
disabled: disabled,
|
|
204
185
|
shape: selectedShape,
|
|
@@ -209,4 +190,4 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
209
190
|
});
|
|
210
191
|
|
|
211
192
|
var _default = Canvas;
|
|
212
|
-
exports
|
|
193
|
+
exports.default = _default;
|
|
@@ -5,50 +5,45 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
12
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
12
|
var _react = _interopRequireDefault(require("react"));
|
|
15
13
|
|
|
16
14
|
var _react2 = require("@linaria/react");
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
_excluded2 = ["hidden", "disabled", "selected", "icon", "children", "type"];
|
|
20
|
-
var StyledButton = /*#__PURE__*/(0, _react2.styled)("button")({
|
|
16
|
+
const StyledButton = /*#__PURE__*/(0, _react2.styled)('button')({
|
|
21
17
|
name: "StyledButton",
|
|
22
|
-
|
|
18
|
+
class: "sq3bzv4"
|
|
23
19
|
});
|
|
24
|
-
|
|
20
|
+
const StyledButtonContent = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
25
21
|
name: "StyledButtonContent",
|
|
26
|
-
|
|
22
|
+
class: "sst453j"
|
|
27
23
|
});
|
|
28
|
-
|
|
24
|
+
const StyledIcon = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
29
25
|
name: "StyledIcon",
|
|
30
|
-
|
|
26
|
+
class: "s1q5lsc2"
|
|
31
27
|
});
|
|
32
|
-
|
|
28
|
+
const StyledChildren = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
33
29
|
name: "StyledChildren",
|
|
34
|
-
|
|
30
|
+
class: "s1dis2j8"
|
|
35
31
|
});
|
|
36
32
|
|
|
37
|
-
|
|
33
|
+
const Button = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
38
34
|
if (props.type === 'file' || props.type === 'color') {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return /*#__PURE__*/_react["default"].createElement(StyledButton, {
|
|
35
|
+
const {
|
|
36
|
+
hidden = false,
|
|
37
|
+
disabled = false,
|
|
38
|
+
selected = false,
|
|
39
|
+
icon,
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
title,
|
|
43
|
+
onClick,
|
|
44
|
+
...fileProps
|
|
45
|
+
} = props;
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(StyledButton, {
|
|
52
47
|
as: "label",
|
|
53
48
|
className: className,
|
|
54
49
|
title: title,
|
|
@@ -56,42 +51,38 @@ var Button = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
|
56
51
|
"data-disabled": +disabled,
|
|
57
52
|
"data-selected": +selected,
|
|
58
53
|
"data-hidden": +hidden
|
|
59
|
-
}, /*#__PURE__*/_react
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
|
|
60
55
|
ref: ref,
|
|
61
56
|
disabled: disabled
|
|
62
|
-
}, fileProps)), /*#__PURE__*/_react
|
|
57
|
+
}, fileProps)), /*#__PURE__*/_react.default.createElement(StyledButtonContent, null, children && /*#__PURE__*/_react.default.createElement(StyledChildren, null, children), icon && /*#__PURE__*/_react.default.createElement(StyledIcon, {
|
|
63
58
|
dangerouslySetInnerHTML: {
|
|
64
59
|
__html: icon
|
|
65
60
|
}
|
|
66
61
|
})));
|
|
67
62
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
79
|
-
_fileProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded2);
|
|
80
|
-
|
|
81
|
-
return /*#__PURE__*/_react["default"].createElement(StyledButton, (0, _extends2["default"])({
|
|
63
|
+
const {
|
|
64
|
+
hidden = false,
|
|
65
|
+
disabled = false,
|
|
66
|
+
selected = false,
|
|
67
|
+
icon,
|
|
68
|
+
children,
|
|
69
|
+
type = 'button',
|
|
70
|
+
...fileProps
|
|
71
|
+
} = props;
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(StyledButton, (0, _extends2.default)({
|
|
82
73
|
ref: ref,
|
|
83
|
-
disabled:
|
|
84
|
-
"data-disabled": +
|
|
85
|
-
"data-selected": +
|
|
86
|
-
"data-hidden": +
|
|
74
|
+
disabled: disabled,
|
|
75
|
+
"data-disabled": +disabled,
|
|
76
|
+
"data-selected": +selected,
|
|
77
|
+
"data-hidden": +hidden,
|
|
87
78
|
type: type
|
|
88
|
-
},
|
|
79
|
+
}, fileProps), /*#__PURE__*/_react.default.createElement(StyledButtonContent, null, children && /*#__PURE__*/_react.default.createElement(StyledChildren, null, children), icon && /*#__PURE__*/_react.default.createElement(StyledIcon, {
|
|
89
80
|
dangerouslySetInnerHTML: {
|
|
90
|
-
__html:
|
|
81
|
+
__html: icon
|
|
91
82
|
}
|
|
92
83
|
})));
|
|
93
84
|
}
|
|
94
85
|
});
|
|
95
86
|
|
|
96
87
|
var _default = Button;
|
|
97
|
-
exports
|
|
88
|
+
exports.default = _default;
|
|
@@ -1,66 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
3
|
Object.defineProperty(exports, "__esModule", {
|
|
8
4
|
value: true
|
|
9
5
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
6
|
+
exports.default = void 0;
|
|
13
7
|
|
|
14
8
|
var _react = require("@linaria/react");
|
|
15
9
|
|
|
10
|
+
var _app = require("../../constants/app");
|
|
11
|
+
|
|
12
|
+
var _loading = require("../../constants/loading");
|
|
13
|
+
|
|
16
14
|
var _style = require("../../constants/style");
|
|
17
15
|
|
|
18
16
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
19
17
|
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
19
|
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
var StyledLoading = /*#__PURE__*/(0, _react.styled)("div")({
|
|
22
|
+
const StyledLoading = /*#__PURE__*/(0, _react.styled)('div')({
|
|
26
23
|
name: "StyledLoading",
|
|
27
|
-
|
|
24
|
+
class: "s9j48u3"
|
|
28
25
|
});
|
|
29
|
-
|
|
26
|
+
const StyledLoader = /*#__PURE__*/(0, _react.styled)('div')({
|
|
30
27
|
name: "StyledLoader",
|
|
31
|
-
|
|
28
|
+
class: "s4auclc"
|
|
32
29
|
});
|
|
33
|
-
|
|
30
|
+
const StyledShape = /*#__PURE__*/(0, _react.styled)('div')({
|
|
34
31
|
name: "StyledShape",
|
|
35
|
-
|
|
32
|
+
class: "s1l3fbq"
|
|
36
33
|
});
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
loadingState = _useState2[0],
|
|
45
|
-
setLoadingState = _useState2[1];
|
|
46
|
-
|
|
47
|
-
(0, _react2.useEffect)(function () {
|
|
35
|
+
const Loading = _ref => {
|
|
36
|
+
let {
|
|
37
|
+
isLoading = false
|
|
38
|
+
} = _ref;
|
|
39
|
+
const [loadingState, setLoadingState] = (0, _react2.useState)('hidden');
|
|
40
|
+
(0, _react2.useEffect)(() => {
|
|
48
41
|
if (isLoading) {
|
|
49
42
|
setLoadingState('visible');
|
|
50
43
|
} else {
|
|
51
44
|
setLoadingState('fadeOut');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, TRANSITION_DURATION);
|
|
55
|
-
return function () {
|
|
45
|
+
const fadeOutTimeout = setTimeout(() => setLoadingState('hidden'), _loading.LOADING_TRANSITION_DURATION);
|
|
46
|
+
return () => {
|
|
56
47
|
clearTimeout(fadeOutTimeout);
|
|
57
48
|
};
|
|
58
49
|
}
|
|
59
50
|
}, [isLoading]);
|
|
60
|
-
return loadingState === 'hidden' ? null : /*#__PURE__*/_react2
|
|
51
|
+
return loadingState === 'hidden' ? null : /*#__PURE__*/_react2.default.createElement(StyledLoading, {
|
|
61
52
|
"data-loading": loadingState
|
|
62
|
-
}, /*#__PURE__*/_react2
|
|
53
|
+
}, /*#__PURE__*/_react2.default.createElement(StyledLoader, null, /*#__PURE__*/_react2.default.createElement(StyledShape, null), /*#__PURE__*/_react2.default.createElement(StyledShape, null), /*#__PURE__*/_react2.default.createElement(StyledShape, null), /*#__PURE__*/_react2.default.createElement(StyledShape, null)));
|
|
63
54
|
};
|
|
64
55
|
|
|
65
56
|
var _default = Loading;
|
|
66
|
-
exports
|
|
57
|
+
exports.default = _default;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
@@ -13,33 +13,34 @@ var _react2 = require("@linaria/react");
|
|
|
13
13
|
|
|
14
14
|
var _style = require("../../constants/style");
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const StyledModal = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
17
17
|
name: "StyledModal",
|
|
18
|
-
|
|
18
|
+
class: "s1c8tp02"
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
const StyledPanel = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
21
21
|
name: "StyledPanel",
|
|
22
|
-
|
|
22
|
+
class: "svkxpz4"
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
const StyledMask = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
25
25
|
name: "StyledMask",
|
|
26
|
-
|
|
26
|
+
class: "s1s9jyyg"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const Modal = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
children,
|
|
32
|
+
onClose,
|
|
33
|
+
position = 'center',
|
|
34
|
+
className
|
|
35
|
+
} = _ref;
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(StyledModal, {
|
|
36
37
|
"data-position": position
|
|
37
|
-
}, /*#__PURE__*/_react
|
|
38
|
+
}, /*#__PURE__*/_react.default.createElement(StyledMask, {
|
|
38
39
|
onClick: onClose
|
|
39
|
-
}), /*#__PURE__*/_react
|
|
40
|
+
}), /*#__PURE__*/_react.default.createElement(StyledPanel, {
|
|
40
41
|
className: className
|
|
41
42
|
}, children));
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
var _default = Modal;
|
|
45
|
-
exports
|
|
46
|
+
exports.default = _default;
|