@pie-lib/graphing 2.4.9 → 2.4.12
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/CHANGELOG.md +33 -0
- package/lib/axis/arrow.js +17 -13
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +57 -51
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +5 -1
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +16 -14
- package/lib/bg.js.map +1 -1
- package/lib/container/index.js +21 -15
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js +4 -4
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +29 -25
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +56 -42
- package/lib/graph.js.map +1 -1
- package/lib/grid.js +20 -14
- package/lib/grid.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/labels.js +28 -24
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +16 -8
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +18 -16
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +22 -16
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +26 -18
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +30 -28
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +4 -4
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/index.js +16 -15
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +12 -6
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +4 -4
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +21 -17
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +2 -2
- package/lib/tools/polygon/component.js +55 -47
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +12 -8
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +26 -18
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +26 -18
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +12 -6
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js +4 -2
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +4 -4
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +46 -44
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +28 -20
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +8 -6
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +21 -15
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +22 -50
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +22 -16
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +8 -4
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +1 -1
- package/lib/tools/shared/types.js +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +4 -4
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +21 -8
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js +20 -16
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +7 -3
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +70 -5
- package/lib/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/axis/axes.jsx +1 -1
- package/src/graph.jsx +13 -6
- package/src/tools/shared/point/arrow.jsx +1 -30
- package/src/tools/vector/component.jsx +20 -6
- package/src/utils.js +62 -4
package/lib/labels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/labels.jsx"],"names":["rotations","left","top","bottom","right","getTransform","side","width","height","t","x","y","rotate","getY","RawLabel","props","text","graphProps","classes","size","transform","__html","axisLabel","React","Component","PropTypes","string","object","types","GraphPropsType","isRequired","Label","theme","label","fill","color","secondary","fontSize","typography","textAlign","LabelType","Labels","value","className","shape"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/labels.jsx"],"names":["rotations","left","top","bottom","right","getTransform","side","width","height","t","x","y","rotate","getY","RawLabel","props","text","graphProps","classes","size","transform","__html","axisLabel","React","Component","PropTypes","string","object","types","GraphPropsType","isRequired","Label","theme","label","fill","color","secondary","fontSize","typography","textAlign","LabelType","Labels","value","className","shape"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG;AAChBC,EAAAA,IAAI,EAAE,CAAC,EADS;AAEhBC,EAAAA,GAAG,EAAE,CAFW;AAGhBC,EAAAA,MAAM,EAAE,CAHQ;AAIhBC,EAAAA,KAAK,EAAE;AAJS,CAAlB;;AAOO,IAAMC,YAAY,GAAG,SAAfA,YAAe,CAACC,IAAD,EAAOC,KAAP,EAAcC,MAAd,EAAyB;AACnD,MAAMC,CAAC,GAAG,SAAJA,CAAI,CAACC,CAAD,EAAIC,CAAJ,EAAOC,MAAP;AAAA,+BAA+BF,CAA/B,eAAqCC,CAArC,uBAAmDC,MAAnD;AAAA,GAAV;;AAEA,MAAIN,IAAI,KAAK,MAAb,EAAqB;AACnB,WAAOG,CAAC,CAAC,CAAC,EAAF,EAAMD,MAAM,GAAG,CAAf,EAAkBR,SAAS,CAACM,IAAD,CAA3B,CAAR;AACD;;AACD,MAAIA,IAAI,KAAK,OAAb,EAAsB;AACpB,WAAOG,CAAC,CAACF,KAAK,GAAG,EAAT,EAAaC,MAA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Content":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { types } from '@pie-lib/plot';\nimport { color, Readable } from '@pie-lib/render-ui';\n\nconst rotations = {\n left: -90,\n top: 0,\n bottom: 0,\n right: 90\n};\n\nexport const getTransform = (side, width, height) => {\n const t = (x, y, rotate) => `translate(${x}, ${y}), rotate(${rotate})`;\n\n if (side === 'left') {\n return t(-20, height / 2, rotations[side]);\n }\n if (side === 'right') {\n return t(width + 30, height / 2, rotations[side]);\n }\n if (side === 'top') {\n return t(width / 2, -20, rotations[side]);\n }\n if (side === 'bottom') {\n return t(width / 2, height + 30, rotations[side]);\n }\n};\n\nconst getY = (side, height) => {\n switch (side) {\n case 'left':\n return -height;\n case 'top':\n return -height + 10;\n case 'right':\n return -height + 10;\n default:\n return 0;\n }\n};\n\nclass RawLabel extends React.Component {\n static propTypes = {\n text: PropTypes.string,\n side: PropTypes.string,\n classes: PropTypes.object,\n graphProps: types.GraphPropsType.isRequired\n };\n\n render() {\n const { text, side, graphProps, classes } = this.props;\n\n const { size } = graphProps;\n\n const transform = getTransform(side, size.width, size.height);\n const width = side === 'left' || side === 'right' ? size.height : size.width;\n const height = 36;\n const y = getY(side, height);\n\n return (\n <foreignObject\n x={-(width / 2)}\n y={y}\n width={width}\n height={height}\n transform={transform}\n textAnchor=\"middle\"\n >\n <Readable false>\n <div dangerouslySetInnerHTML={{ __html: text }} className={classes.axisLabel} />\n </Readable>\n </foreignObject>\n );\n }\n}\n\nconst Label = withStyles(theme => ({\n label: {\n fill: color.secondary()\n },\n axisLabel: {\n fontSize: theme.typography.fontSize,\n textAlign: 'center'\n }\n}))(RawLabel);\n\nexport const LabelType = {\n left: PropTypes.string,\n top: PropTypes.string,\n bottom: PropTypes.string,\n right: PropTypes.string\n};\n\nexport class Labels extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n value: PropTypes.shape(LabelType),\n graphProps: PropTypes.object\n };\n\n static defaultProps = {};\n render() {\n const { value, graphProps } = this.props;\n return (\n <React.Fragment>\n {value && value.left && (\n <Label key=\"left\" side=\"left\" text={value.left} graphProps={graphProps} />\n )}\n {value && value.top && (\n <Label key=\"top\" side=\"top\" text={value.top} graphProps={graphProps} />\n )}\n {value && value.bottom && (\n <Label key=\"bottom\" side=\"bottom\" text={value.bottom} graphProps={graphProps} />\n )}\n {value && value.right && (\n <Label key=\"right\" side=\"right\" text={value.right} graphProps={graphProps} />\n )}\n </React.Fragment>\n );\n }\n}\n\nexport default Labels;\n"],"file":"labels.js"}
|
package/lib/mark-label.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports["default"] = exports.
|
|
8
|
+
exports.position = exports["default"] = exports.coordinates = exports.MarkLabel = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
@@ -23,19 +25,25 @@ var _renderUi = require("@pie-lib/render-ui");
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
27
31
|
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
33
|
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
35
|
|
|
32
36
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
37
|
|
|
34
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
38
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
+
|
|
40
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
|
+
|
|
42
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
43
|
|
|
36
|
-
function
|
|
44
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
45
|
|
|
38
|
-
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e
|
|
46
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
39
47
|
|
|
40
48
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
49
|
|
|
@@ -168,7 +176,7 @@ var MarkLabel = function MarkLabel(props) {
|
|
|
168
176
|
pointerEvents: 'auto'
|
|
169
177
|
}, leftTop);
|
|
170
178
|
|
|
171
|
-
return _react["default"].createElement(_reactInputAutosize["default"], {
|
|
179
|
+
return /*#__PURE__*/_react["default"].createElement(_reactInputAutosize["default"], {
|
|
172
180
|
inputRef: function inputRef(r) {
|
|
173
181
|
_ref(r);
|
|
174
182
|
|
package/lib/mark-label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mark-label.jsx"],"names":["styles","theme","input","padding","spacing","unit","fontFamily","typography","fontSize","border","color","secondary","borderRadius","primaryDark","disabled","background","position","graphProps","mark","rect","width","height","scale","domain","range","shift","rightEdge","x","bottomEdge","y","h","max","v","min","coordinates","left","top","MarkLabel","props","setInput","_ref","node","classes","externalInputRef","inputRef","label","setLabel","onChange","e","target","value","debouncedLabel","getBoundingClientRect","pos","leftTop","style","pointerEvents","r","propTypes","PropTypes","bool","func","types","GraphPropsType","object"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/mark-label.jsx"],"names":["styles","theme","input","padding","spacing","unit","fontFamily","typography","fontSize","border","color","secondary","borderRadius","primaryDark","disabled","background","position","graphProps","mark","rect","width","height","scale","domain","range","shift","rightEdge","x","bottomEdge","y","h","max","v","min","coordinates","left","top","MarkLabel","props","setInput","_ref","node","classes","externalInputRef","inputRef","label","setLabel","onChange","e","target","value","debouncedLabel","getBoundingClientRect","pos","leftTop","style","pointerEvents","r","propTypes","PropTypes","bool","func","types","GraphPropsType","object"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,KAAK,EAAE;AACL,eAAO,OADF;AAELC,MAAAA,OAAO,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,GAFzB;AAGLC,MAAAA,UAAU,EAAEL,KAAK,CAACM,UAAN,CAAiBD,UAHxB;AAILE,MAAAA,QAAQ,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import React, { useState, useCallback, useEffect } from 'react';\nimport cn from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport AutosizeInput from 'react-input-autosize';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { useDebounce } from './use-debounce';\nimport { color } from '@pie-lib/render-ui';\n\nconst styles = theme => ({\n input: {\n float: 'right',\n padding: theme.spacing.unit * 0.5,\n fontFamily: theme.typography.fontFamily,\n fontSize: theme.typography.fontSize,\n border: `solid 1px ${color.secondary()}`,\n borderRadius: '3px',\n color: color.primaryDark()\n },\n disabled: {\n border: `solid 1px ${color.primaryDark()}`,\n background: color.background()\n }\n});\n\nexport const position = (graphProps, mark, rect) => {\n rect = rect || { width: 0, height: 0 };\n const { scale, domain, range } = graphProps;\n const shift = 10;\n\n const rightEdge = scale.x(mark.x) + rect.width + shift;\n const bottomEdge = scale.y(mark.y) + rect.height + shift;\n\n const h = rightEdge >= scale.x(domain.max) ? 'left' : 'right';\n const v = bottomEdge >= scale.y(range.min) ? 'top' : 'bottom';\n return `${v}-${h}`;\n};\n\nexport const coordinates = (graphProps, mark, rect, position) => {\n const { scale } = graphProps;\n const shift = 10;\n rect = rect || { width: 0, height: 0 };\n\n switch (position) {\n case 'bottom-right': {\n return { left: scale.x(mark.x) + shift, top: scale.y(mark.y) + shift };\n }\n case 'bottom-left': {\n return { left: scale.x(mark.x) - shift - rect.width, top: scale.y(mark.y) + shift };\n }\n case 'top-left': {\n return {\n left: scale.x(mark.x) - shift - rect.width,\n top: scale.y(mark.y) - shift - rect.height\n };\n }\n case 'top-right': {\n return {\n left: scale.x(mark.x) + shift,\n top: scale.y(mark.y) - shift - rect.height\n };\n }\n }\n};\n\nexport const MarkLabel = props => {\n const [input, setInput] = useState(null);\n const _ref = useCallback(node => setInput(node));\n\n const { mark, graphProps, classes, disabled, inputRef: externalInputRef } = props;\n const [label, setLabel] = useState(mark.label);\n\n const onChange = e => setLabel(e.target.value);\n\n const debouncedLabel = useDebounce(label, 200);\n\n // useState only sets the value once, to synch props to state need useEffect\n useEffect(() => {\n setLabel(mark.label);\n }, [mark.label]);\n\n // pick up the change to debouncedLabel and save it\n useEffect(() => {\n if (typeof debouncedLabel === 'string' && debouncedLabel !== mark.label) {\n props.onChange(debouncedLabel);\n }\n }, [debouncedLabel]);\n\n const rect = input ? input.getBoundingClientRect() : { width: 0, height: 0 };\n const pos = position(graphProps, mark, rect);\n const leftTop = coordinates(graphProps, mark, rect, pos);\n\n const style = {\n position: 'absolute',\n pointerEvents: 'auto',\n ...leftTop\n };\n\n return (\n <AutosizeInput\n inputRef={r => {\n _ref(r);\n externalInputRef(r);\n }}\n disabled={disabled}\n inputClassName={cn(classes.input, disabled && classes.disabled)}\n value={label}\n style={style}\n onChange={onChange}\n />\n );\n};\n\nMarkLabel.propTypes = {\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType,\n classes: PropTypes.object,\n inputRef: PropTypes.func,\n mark: PropTypes.object\n};\n\nexport default withStyles(styles)(MarkLabel);\n"],"file":"mark-label.js"}
|
package/lib/toggle-bar.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -21,23 +23,25 @@ var _index = require("./tools/index");
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
25
|
-
|
|
26
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
27
|
|
|
28
28
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
29
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
39
|
|
|
36
40
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
41
|
|
|
38
|
-
function
|
|
42
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
43
|
|
|
40
|
-
function
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
45
|
|
|
42
46
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
47
|
|
|
@@ -75,7 +79,7 @@ var MiniButton = (0, _styles.withStyles)(buttonStyles)(function (props) {
|
|
|
75
79
|
selected = props.selected,
|
|
76
80
|
value = props.value,
|
|
77
81
|
onClick = props.onClick;
|
|
78
|
-
return _react["default"].createElement(_Button["default"], {
|
|
82
|
+
return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
79
83
|
size: "small",
|
|
80
84
|
disabled: disabled,
|
|
81
85
|
className: (0, _classnames["default"])(classes.root, selected && classes.selected, className),
|
|
@@ -98,14 +102,12 @@ MiniButton.propTypes = {
|
|
|
98
102
|
onClick: _propTypes["default"].func
|
|
99
103
|
};
|
|
100
104
|
|
|
101
|
-
var ToggleBar =
|
|
102
|
-
/*#__PURE__*/
|
|
103
|
-
function (_React$Component) {
|
|
105
|
+
var ToggleBar = /*#__PURE__*/function (_React$Component) {
|
|
104
106
|
_inherits(ToggleBar, _React$Component);
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
var _getPrototypeOf2;
|
|
108
|
+
var _super = _createSuper(ToggleBar);
|
|
108
109
|
|
|
110
|
+
function ToggleBar() {
|
|
109
111
|
var _this;
|
|
110
112
|
|
|
111
113
|
_classCallCheck(this, ToggleBar);
|
|
@@ -114,7 +116,7 @@ function (_React$Component) {
|
|
|
114
116
|
args[_key] = arguments[_key];
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
_this =
|
|
119
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
118
120
|
|
|
119
121
|
_defineProperty(_assertThisInitialized(_this), "select", function (e) {
|
|
120
122
|
return _this.props.onChange(e.target.textContent);
|
|
@@ -134,12 +136,12 @@ function (_React$Component) {
|
|
|
134
136
|
disabled = _this$props.disabled,
|
|
135
137
|
options = _this$props.options,
|
|
136
138
|
selectedToolType = _this$props.selectedToolType;
|
|
137
|
-
return _react["default"].createElement("div", {
|
|
139
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
138
140
|
className: (0, _classnames["default"])(className)
|
|
139
141
|
}, (options || []).map(function (option) {
|
|
140
142
|
if ((_index.allTools || []).includes(option)) {
|
|
141
143
|
var isSelected = option === selectedToolType;
|
|
142
|
-
return _react["default"].createElement(MiniButton, {
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement(MiniButton, {
|
|
143
145
|
key: option,
|
|
144
146
|
className: (0, _classnames["default"])(classes.button, isSelected && classes.selected),
|
|
145
147
|
disabled: disabled,
|
package/lib/toggle-bar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/toggle-bar.jsx"],"names":["buttonStyles","root","color","text","backgroundColor","primary","selected","background","border","secondary","notSelected","disabled","MiniButton","props","classes","className","value","onClick","propTypes","PropTypes","bool","string","disabledClassName","func","ToggleBar","e","onChange","target","textContent","options","selectedToolType","map","option","allTools","includes","isSelected","button","select","React","Component","object","isRequired","arrayOf","styles","theme","marginRight","spacing","unit","marginBottom"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/toggle-bar.jsx"],"names":["buttonStyles","root","color","text","backgroundColor","primary","selected","background","border","secondary","notSelected","disabled","MiniButton","props","classes","className","value","onClick","propTypes","PropTypes","bool","string","disabledClassName","func","ToggleBar","e","onChange","target","textContent","options","selectedToolType","map","option","allTools","includes","isSelected","button","select","React","Component","object","isRequired","arrayOf","styles","theme","marginRight","spacing","unit","marginBottom"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAe;AAAA,SAAO;AAC1BC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJ,iBAAW;AACTC,QAAAA,eAAe,EAAEF,gBAAMG,OAAN;AADR;AAFP,KADoB;AAO1BC,IAAAA,QAAQ,EAAE;AACRF,MAAAA,eAAe,EAAEF,gBAAMK,UAAN,EADT;AAERC,MAAAA,MAAM,sBAAeN,gBAAMO,SAAN,EAAf;AAFE,KAPgB;AAW1BC,IAAAA,WAAW,EAAE;AACX,gBAAU;AACRR,QAAAA,KAAK,EAAEA,gBAAMG,OAAN;AADC,OADC;AAIXD,MAAAA,eAAe,EAAEF,gBAAMK,UAAN;AAJN,KAXa;AAiB1BI,IAAAA,QAAQ,EAAE;AACR,gBAAU;AACRT,QAAAA,KAAK,EAAEA,gBAAMG,OAAN;AADC,OADF;AAIRD,MAAAA,eAAe,EAAEF,gBAAMS,QAAN;AAJT;AAjBgB,GAAP;AAAA,CAArB;;AAyBO,IAAMC,UAAU,GAAG,wBAAWZ,YAAX,EAAyB,UAAAa,KAAK,EAAI;AAC1D,MAAQF,QAAR,GAAmEE,KAAnE,CAAQF,QAAR;AAAA,MAAkBG,OAAlB,GAAmED,KAAnE,CAAkBC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,MAAM,EAAE;AACNS,MAAAA,WAAW,EAAED,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAD5B;AAENC,MAAAA,YAAY,EAAEJ,KAAK,CAACE,OAAN,CAAcC,IAAd,GAAqB,CAF7B;AAGN7C,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EAHD;AAINC,MAAAA,eAAe,EAAEF,gBAAMK,UAAN;AAJX;AADe,GAAL;AAAA,CAApB;;eASe,wBAAWoC,MAAX,EAAmBnB,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport cn from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport { color } from '@pie-lib/render-ui';\nimport { allTools } from './tools/index';\n\nconst buttonStyles = () => ({\n root: {\n color: color.text(),\n '&:hover': {\n backgroundColor: color.primary()\n }\n },\n selected: {\n backgroundColor: color.background(),\n border: `1px solid ${color.secondary()}`\n },\n notSelected: {\n '& span': {\n color: color.primary()\n },\n backgroundColor: color.background()\n },\n disabled: {\n '& span': {\n color: color.primary()\n },\n backgroundColor: color.disabled()\n }\n});\n\nexport const MiniButton = withStyles(buttonStyles)(props => {\n const { disabled, classes, className, selected, value, onClick } = props;\n\n return (\n <Button\n size=\"small\"\n disabled={disabled}\n className={cn(classes.root, selected && classes.selected, className)}\n classes={{ disabled: cn(disabled && classes.disabled) }}\n value={value}\n key={value}\n variant=\"outlined\"\n onClick={onClick}\n >\n {value}\n </Button>\n );\n});\n\nMiniButton.propTypes = {\n disabled: PropTypes.bool,\n className: PropTypes.string,\n disabledClassName: PropTypes.string,\n selected: PropTypes.bool,\n value: PropTypes.string,\n onClick: PropTypes.func\n};\n\nexport class ToggleBar extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n options: PropTypes.arrayOf(PropTypes.string),\n selectedToolType: PropTypes.string,\n disabled: PropTypes.bool,\n onChange: PropTypes.func\n };\n\n static defaultProps = {};\n\n select = e => this.props.onChange(e.target.textContent);\n\n render() {\n const { classes, className, disabled, options, selectedToolType } = this.props;\n return (\n <div className={cn(className)}>\n {(options || []).map(option => {\n if ((allTools || []).includes(option)) {\n const isSelected = option === selectedToolType;\n\n return (\n <MiniButton\n key={option}\n className={cn(classes.button, isSelected && classes.selected)}\n disabled={disabled}\n disableRipple={true}\n onClick={this.select}\n value={option}\n selected={isSelected}\n />\n );\n }\n })}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n button: {\n marginRight: theme.spacing.unit / 2,\n marginBottom: theme.spacing.unit / 2,\n color: color.text(),\n backgroundColor: color.background()\n }\n});\n\nexport default withStyles(styles)(ToggleBar);\n"],"file":"toggle-bar.js"}
|
package/lib/tool-menu.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -13,39 +15,43 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
15
|
|
|
14
16
|
var _toggleBar = _interopRequireWildcard(require("./toggle-bar"));
|
|
15
17
|
|
|
16
|
-
function
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
19
|
|
|
18
|
-
function
|
|
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; }
|
|
19
21
|
|
|
20
|
-
function
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
|
|
22
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
25
|
|
|
24
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
27
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
33
|
|
|
32
|
-
function
|
|
34
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
+
|
|
40
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
+
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
43
|
|
|
38
44
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
45
|
|
|
40
|
-
var ToolMenu =
|
|
41
|
-
/*#__PURE__*/
|
|
42
|
-
function (_React$Component) {
|
|
46
|
+
var ToolMenu = /*#__PURE__*/function (_React$Component) {
|
|
43
47
|
_inherits(ToolMenu, _React$Component);
|
|
44
48
|
|
|
49
|
+
var _super = _createSuper(ToolMenu);
|
|
50
|
+
|
|
45
51
|
function ToolMenu() {
|
|
46
52
|
_classCallCheck(this, ToolMenu);
|
|
47
53
|
|
|
48
|
-
return
|
|
54
|
+
return _super.apply(this, arguments);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
_createClass(ToolMenu, [{
|
|
@@ -65,14 +71,14 @@ function (_React$Component) {
|
|
|
65
71
|
toolbarTools = (toolbarTools || []).filter(function (tT) {
|
|
66
72
|
return tT !== 'label';
|
|
67
73
|
});
|
|
68
|
-
return _react["default"].createElement("div", {
|
|
74
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
69
75
|
className: (0, _classnames["default"])(className)
|
|
70
|
-
}, _react["default"].createElement(_toggleBar["default"], {
|
|
76
|
+
}, /*#__PURE__*/_react["default"].createElement(_toggleBar["default"], {
|
|
71
77
|
disabled: disabled,
|
|
72
78
|
options: toolbarTools,
|
|
73
79
|
selectedToolType: currentToolType,
|
|
74
80
|
onChange: onChange
|
|
75
|
-
}), showLabel && _react["default"].createElement(_toggleBar.MiniButton, {
|
|
81
|
+
}), showLabel && /*#__PURE__*/_react["default"].createElement(_toggleBar.MiniButton, {
|
|
76
82
|
disabled: disabled,
|
|
77
83
|
value: 'Label',
|
|
78
84
|
onClick: onToggleLabelMode,
|
package/lib/tool-menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tool-menu.jsx"],"names":["ToolMenu","props","className","currentToolType","disabled","labelModeEnabled","onToggleLabelMode","onChange","toolbarTools","showLabel","some","t","filter","tT","React","Component","PropTypes","string","bool","func","arrayOf"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/tool-menu.jsx"],"names":["ToolMenu","props","className","currentToolType","disabled","labelModeEnabled","onToggleLabelMode","onChange","toolbarTools","showLabel","some","t","filter","tT","React","Component","PropTypes","string","bool","func","arrayOf"],"mappings":";;;;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B,EAAEW,sBAAUE,IAJX;AAKjBX,EAAAA,QAAQ,EAAES,sBAAUG,IALH;AAMjBb,EAAAA,iBAAiB,EAAEU,sBAAUG,IANZ;AAOjBX,EAAAA,YAAY,EAAEQ,sBAAUI,OAAV,CAAkBJ,sBAAUC,MAA5B;AAPG,C;;gBADRjB,Q,kBAWW;AACpBQ,EAAAA,YAAY,EAAE;AADM,C;;eAyCTR,Q","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\n\nimport ToggleBar, { MiniButton } from './toggle-bar';\n\nexport class ToolMenu extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n currentToolType: PropTypes.string,\n disabled: PropTypes.bool,\n labelModeEnabled: PropTypes.bool,\n onChange: PropTypes.func,\n onToggleLabelMode: PropTypes.func,\n toolbarTools: PropTypes.arrayOf(PropTypes.string)\n };\n\n static defaultProps = {\n toolbarTools: []\n };\n\n render() {\n const {\n className,\n currentToolType,\n disabled,\n labelModeEnabled,\n onToggleLabelMode,\n onChange\n } = this.props;\n let { toolbarTools } = this.props;\n\n const showLabel = toolbarTools && toolbarTools.some(t => t === 'label');\n\n toolbarTools = (toolbarTools || []).filter(tT => tT !== 'label');\n\n return (\n <div className={classNames(className)}>\n <ToggleBar\n disabled={disabled}\n options={toolbarTools}\n selectedToolType={currentToolType}\n onChange={onChange}\n />\n\n {showLabel && (\n <MiniButton\n disabled={disabled}\n value={'Label'}\n onClick={onToggleLabelMode}\n selected={labelModeEnabled}\n />\n )}\n </div>\n );\n }\n}\n\nexport default ToolMenu;\n"],"file":"tool-menu.js"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -21,15 +23,17 @@ var utils = _interopRequireWildcard(require("../../utils"));
|
|
|
21
23
|
|
|
22
24
|
var _styles2 = require("../shared/styles");
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
var _excluded = ["classes", "disabled", "className", "correctness", "x", "y", "radius", "graphProps"];
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
29
|
|
|
26
|
-
function
|
|
30
|
+
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; }
|
|
27
31
|
|
|
28
|
-
function
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
33
|
|
|
30
|
-
function
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
35
|
|
|
32
|
-
function
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
37
|
|
|
34
38
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
35
39
|
|
|
@@ -41,17 +45,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
41
45
|
|
|
42
46
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
47
|
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
48
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
49
|
|
|
46
|
-
function
|
|
50
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
51
|
|
|
48
|
-
function
|
|
52
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
53
|
|
|
50
|
-
function
|
|
54
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
55
|
|
|
52
|
-
function
|
|
56
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
53
57
|
|
|
54
|
-
function
|
|
58
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
59
|
+
|
|
60
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
|
+
|
|
62
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
63
|
|
|
56
64
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
65
|
|
|
@@ -61,15 +69,15 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
61
69
|
* TODO: This and base point have a lot of similarities - merge commonality
|
|
62
70
|
*
|
|
63
71
|
*/
|
|
64
|
-
var RawCircle =
|
|
65
|
-
/*#__PURE__*/
|
|
66
|
-
function (_React$Component) {
|
|
72
|
+
var RawCircle = /*#__PURE__*/function (_React$Component) {
|
|
67
73
|
_inherits(RawCircle, _React$Component);
|
|
68
74
|
|
|
75
|
+
var _super = _createSuper(RawCircle);
|
|
76
|
+
|
|
69
77
|
function RawCircle() {
|
|
70
78
|
_classCallCheck(this, RawCircle);
|
|
71
79
|
|
|
72
|
-
return
|
|
80
|
+
return _super.apply(this, arguments);
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
_createClass(RawCircle, [{
|
|
@@ -84,12 +92,12 @@ function (_React$Component) {
|
|
|
84
92
|
y = _this$props.y,
|
|
85
93
|
radius = _this$props.radius,
|
|
86
94
|
graphProps = _this$props.graphProps,
|
|
87
|
-
rest = _objectWithoutProperties(_this$props,
|
|
95
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
88
96
|
|
|
89
97
|
var scale = graphProps.scale;
|
|
90
98
|
var rx = Math.abs(scale.x(x + radius) - scale.x(x));
|
|
91
99
|
var ry = Math.abs(scale.y(y + radius) - scale.y(y));
|
|
92
|
-
return _react["default"].createElement("ellipse", _extends({
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement("ellipse", _extends({
|
|
93
101
|
className: (0, _classnames["default"])(classes.bgCircle, disabled && classes.disabled, classes[correctness], className),
|
|
94
102
|
cx: scale.x(x),
|
|
95
103
|
cy: scale.y(y),
|
|
@@ -114,7 +122,7 @@ _defineProperty(RawCircle, "propTypes", {
|
|
|
114
122
|
});
|
|
115
123
|
|
|
116
124
|
var applyStyle = function applyStyle(fn) {
|
|
117
|
-
return _objectSpread({}, fn('stroke'), {
|
|
125
|
+
return _objectSpread(_objectSpread({}, fn('stroke')), {}, {
|
|
118
126
|
'&:hover': _objectSpread({
|
|
119
127
|
strokeWidth: 3
|
|
120
128
|
}, fn('stroke'))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tools/circle/bg-circle.jsx"],"names":["RawCircle","props","classes","disabled","className","correctness","x","y","radius","graphProps","rest","scale","rx","Math","abs","ry","bgCircle","React","Component","PropTypes","object","isRequired","string","bool","number","types","GraphPropsType","applyStyle","fn","strokeWidth","styles","fill","stroke","color","primaryLight","transition","primaryDark","correct","incorrect","BgCircle","bounds","domain","range","area","left","top","bottom","right","utils","anchorPoint","fromDelta","delta","newPoint","point","add"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/tools/circle/bg-circle.jsx"],"names":["RawCircle","props","classes","disabled","className","correctness","x","y","radius","graphProps","rest","scale","rx","Math","abs","ry","bgCircle","React","Component","PropTypes","object","isRequired","string","bool","number","types","GraphPropsType","applyStyle","fn","strokeWidth","styles","fill","stroke","color","primaryLight","transition","primaryDark","correct","incorrect","BgCircle","bounds","domain","range","area","left","top","bottom","right","utils","anchorPoint","fromDelta","delta","newPoint","point","add"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;IACMA,S;;;;;;;;;;;;;WAYJ,kBAAS;AACP,wBAUI,KAAKC,KAVT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,QAFF,eAEEA,QAFF;AAAA,UAGEC,SAHF,eAGEA,SAHF;AAAA,UAIEC,WAJF,eAIEA,WAJF;AAAA,UAKEC,CALF,eAKEA,CALF;AAAA,UAMEC,CANF,eAMEA,CANF;AAAA,UAOEC,MAPF,eAOEA,MAPF;AAAA,UAQEC,UARF,eAQEA,UARF;AAAA,UASKC,IATL;;AAWA,UAAQC,KAAR,GAAkBF,UAAlB,CAAQE,KAAR;AACA,UAAMC,EAAE,GAAGC,IAAI,CAACC,GAAL,CAASH,KAAK,CAACL,CAAN,CAAQA,CAAC,GAAGE,MAAZ,IAAsBG,KAAK,CAACL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ADA;AAAL,KAAP;AACD,GAT0B;AAU3B2C,EAAAA,SAAS,EAAE,mBAACjD,KAAD,EAAQkD,KAAR,EAAkB;AAC3B,QAAMC,QAAQ,GAAGJ,KAAK,CAACK,KAAN,CAAYpD,KAAZ,EAAmBqD,GAAnB,CAAuBN,KAAK,CAACK,KAAN,CAAYF,KAAZ,CAAvB,CAAjB;AACA,WAAOC,QAAP;AACD;AAb0B,CAAd,EAcZb,QAdY,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { types, gridDraggable } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport * as utils from '../../utils';\nimport { disabled, correct, incorrect } from '../shared/styles';\n\n/**\n * A low level circle component\n *\n * TODO: This and base point have a lot of similarities - merge commonality\n *\n */\nclass RawCircle extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n correctness: PropTypes.string,\n disabled: PropTypes.bool,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n radius: PropTypes.number,\n graphProps: types.GraphPropsType.isRequired\n };\n\n render() {\n const {\n classes,\n disabled,\n className,\n correctness,\n x,\n y,\n radius,\n graphProps,\n ...rest\n } = this.props;\n const { scale } = graphProps;\n const rx = Math.abs(scale.x(x + radius) - scale.x(x));\n const ry = Math.abs(scale.y(y + radius) - scale.y(y));\n\n return (\n <ellipse\n className={classNames(\n classes.bgCircle,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n cx={scale.x(x)}\n cy={scale.y(y)}\n rx={rx}\n ry={ry}\n {...rest}\n />\n );\n }\n}\n\nconst applyStyle = fn => ({\n ...fn('stroke'),\n '&:hover': {\n strokeWidth: 3,\n ...fn('stroke')\n }\n});\n\nconst styles = () => ({\n bgCircle: {\n fill: 'transparent',\n stroke: color.primaryLight(),\n strokeWidth: 3,\n transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',\n '&:hover': {\n strokeWidth: 6,\n stroke: color.primaryDark()\n }\n },\n disabled: applyStyle(disabled),\n correct: applyStyle(correct),\n incorrect: applyStyle(incorrect)\n});\n\nexport const BgCircle = withStyles(styles)(RawCircle);\n\nexport default gridDraggable({\n bounds: (props, { domain, range }) => {\n const { x, y } = props;\n const area = { left: x, top: y, bottom: y, right: x };\n return utils.bounds(area, domain, range);\n },\n anchorPoint: props => {\n const { x, y } = props;\n return { x, y };\n },\n fromDelta: (props, delta) => {\n const newPoint = utils.point(props).add(utils.point(delta));\n return newPoint;\n }\n})(BgCircle);\n"],"file":"bg-circle.js"}
|