@pie-lib/tools 0.16.0 → 0.18.0
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 +10 -15
- package/lib/anchor-utils.js +249 -0
- package/lib/anchor-utils.js.map +1 -0
- package/lib/anchor.js +41 -0
- package/lib/anchor.js.map +1 -0
- package/lib/index.js +43 -0
- package/lib/index.js.map +1 -0
- package/lib/protractor/graphic.js +184 -0
- package/lib/protractor/graphic.js.map +1 -0
- package/lib/protractor/index.js +120 -0
- package/lib/protractor/index.js.map +1 -0
- package/lib/rotatable.js +403 -0
- package/lib/rotatable.js.map +1 -0
- package/lib/ruler/graphic.js +126 -0
- package/lib/ruler/graphic.js.map +1 -0
- package/lib/ruler/index.js +146 -0
- package/lib/ruler/index.js.map +1 -0
- package/lib/ruler/unit-type.js +72 -0
- package/lib/ruler/unit-type.js.map +1 -0
- package/lib/ruler/unit.js +161 -0
- package/lib/ruler/unit.js.map +1 -0
- package/lib/style-utils.js +28 -0
- package/lib/style-utils.js.map +1 -0
- package/lib/transform-origin.js +82 -0
- package/lib/transform-origin.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Graphic = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
+
|
|
26
|
+
var _styles = require("@material-ui/core/styles");
|
|
27
|
+
|
|
28
|
+
var _unitType = _interopRequireDefault(require("./unit-type"));
|
|
29
|
+
|
|
30
|
+
var _range = _interopRequireDefault(require("lodash/range"));
|
|
31
|
+
|
|
32
|
+
var _unit = _interopRequireDefault(require("./unit"));
|
|
33
|
+
|
|
34
|
+
var _styleUtils = require("../style-utils");
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
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
|
+
|
|
40
|
+
var Bg = function Bg(_ref) {
|
|
41
|
+
var width = _ref.width,
|
|
42
|
+
height = _ref.height,
|
|
43
|
+
className = _ref.className;
|
|
44
|
+
return /*#__PURE__*/_react["default"].createElement("rect", {
|
|
45
|
+
width: width,
|
|
46
|
+
height: height,
|
|
47
|
+
cx: 0,
|
|
48
|
+
cy: 0,
|
|
49
|
+
className: className
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Bg.propTypes = {
|
|
54
|
+
width: _propTypes["default"].number.isRequired,
|
|
55
|
+
height: _propTypes["default"].number.isRequired,
|
|
56
|
+
className: _propTypes["default"].string.isRequired
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var Graphic = /*#__PURE__*/function (_React$PureComponent) {
|
|
60
|
+
(0, _inherits2["default"])(Graphic, _React$PureComponent);
|
|
61
|
+
|
|
62
|
+
var _super = _createSuper(Graphic);
|
|
63
|
+
|
|
64
|
+
function Graphic() {
|
|
65
|
+
(0, _classCallCheck2["default"])(this, Graphic);
|
|
66
|
+
return _super.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
(0, _createClass2["default"])(Graphic, [{
|
|
70
|
+
key: "render",
|
|
71
|
+
value: function render() {
|
|
72
|
+
var _this$props = this.props,
|
|
73
|
+
width = _this$props.width,
|
|
74
|
+
height = _this$props.height,
|
|
75
|
+
classes = _this$props.classes,
|
|
76
|
+
units = _this$props.units,
|
|
77
|
+
unit = _this$props.unit;
|
|
78
|
+
var viewBox = "0 0 ".concat(width, " ").concat(height);
|
|
79
|
+
var unitWidth = width / units;
|
|
80
|
+
var unitHeight = height;
|
|
81
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
82
|
+
viewBox: viewBox
|
|
83
|
+
}, /*#__PURE__*/_react["default"].createElement(Bg, {
|
|
84
|
+
width: width,
|
|
85
|
+
height: height,
|
|
86
|
+
className: classes.bg
|
|
87
|
+
}), /*#__PURE__*/_react["default"].createElement(_unitType["default"], {
|
|
88
|
+
label: unit.type
|
|
89
|
+
}), (0, _range["default"])(1, units + 1).map(function (r) {
|
|
90
|
+
return /*#__PURE__*/_react["default"].createElement(_unit["default"], {
|
|
91
|
+
width: unitWidth,
|
|
92
|
+
height: unitHeight,
|
|
93
|
+
key: r,
|
|
94
|
+
index: r,
|
|
95
|
+
config: unit,
|
|
96
|
+
last: r === units
|
|
97
|
+
});
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
}]);
|
|
101
|
+
return Graphic;
|
|
102
|
+
}(_react["default"].PureComponent);
|
|
103
|
+
|
|
104
|
+
exports.Graphic = Graphic;
|
|
105
|
+
(0, _defineProperty2["default"])(Graphic, "propTypes", {
|
|
106
|
+
width: _propTypes["default"].number.isRequired,
|
|
107
|
+
height: _propTypes["default"].number.isRequired,
|
|
108
|
+
units: _propTypes["default"].number.isRequired,
|
|
109
|
+
unit: _propTypes["default"].object.isRequired,
|
|
110
|
+
classes: _propTypes["default"].object.isRequired
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
var styles = function styles(theme) {
|
|
114
|
+
return {
|
|
115
|
+
bg: {
|
|
116
|
+
stroke: (0, _styleUtils.strokeColor)(theme),
|
|
117
|
+
strokeWidth: '2px',
|
|
118
|
+
fill: (0, _styleUtils.fillColor)(theme)
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
var _default = (0, _styles.withStyles)(styles)(Graphic);
|
|
124
|
+
|
|
125
|
+
exports["default"] = _default;
|
|
126
|
+
//# sourceMappingURL=graphic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ruler/graphic.jsx"],"names":["Bg","width","height","className","propTypes","PropTypes","number","isRequired","string","Graphic","props","classes","units","unit","viewBox","unitWidth","unitHeight","bg","type","map","r","React","PureComponent","object","styles","theme","stroke","strokeWidth","fill"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,EAAE,GAAG,SAALA,EAAK;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,MAAUC,MAAV,QAAUA,MAAV;AAAA,MAAkBC,SAAlB,QAAkBA,SAAlB;AAAA,sBAAkC;AAAM,IAAA,KAAK,EAAEF,KAAb;AAAoB,IAAA,MAAM,EAAEC,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UAAA,IAAI,EAAEO,CAAC,KAAKR;AAAxF,UADuB;AAAA,OAAxB,CAHH,CADF;AASD;;;EAxB0BS,kBAAMC,a;;;iCAAtBb,O,eACQ;AACjBR,EAAAA,KAAK,EAAEI,sBAAUC,MAAV,CAAiBC,UADP;AAEjBL,EAAAA,MAAM,EAAEG,sBAAUC,MAAV,CAAiBC,UAFR;AAGjBK,EAAAA,KAAK,EAAEP,sBAAUC,MAAV,CAAiBC,UAHP;AAIjBM,EAAAA,IAAI,EAAER,sBAAUkB,MAAV,CAAiBhB,UAJN;AAKjBI,EAAAA,OAAO,EAAEN,sBAAUkB,MAAV,CAAiBhB;AALT,C;;AAyBrB,IAAMiB,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBR,IAAAA,EAAE,EAAE;AACFS,MAAAA,MAAM,EAAE,6BAAYD,KAAZ,CADN;AAEFE,MAAAA,WAAW,EAAE,KAFX;AAGFC,MAAAA,IAAI,EAAE,2BAAUH,KAAV;AAHJ;AADqB,GAAZ;AAAA,CAAf;;eAQe,wBAAWD,MAAX,EAAmBf,OAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport UnitType from './unit-type';\nimport range from 'lodash/range';\nimport Unit from './unit';\nimport { strokeColor, fillColor } from '../style-utils';\n\nconst Bg = ({ width, height, className }) => <rect width={width} height={height} cx={0} cy={0} className={className} />;\n\nBg.propTypes = {\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n className: PropTypes.string.isRequired,\n};\n\nexport class Graphic extends React.PureComponent {\n static propTypes = {\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n units: PropTypes.number.isRequired,\n unit: PropTypes.object.isRequired,\n classes: PropTypes.object.isRequired,\n };\n\n render() {\n const { width, height, classes, units, unit } = this.props;\n const viewBox = `0 0 ${width} ${height}`;\n const unitWidth = width / units;\n const unitHeight = height;\n\n return (\n <svg viewBox={viewBox}>\n <Bg width={width} height={height} className={classes.bg} />\n <UnitType label={unit.type} />\n {range(1, units + 1).map((r) => (\n <Unit width={unitWidth} height={unitHeight} key={r} index={r} config={unit} last={r === units} />\n ))}\n </svg>\n );\n }\n}\nconst styles = (theme) => ({\n bg: {\n stroke: strokeColor(theme),\n strokeWidth: '2px',\n fill: fillColor(theme),\n },\n});\n\nexport default withStyles(styles)(Graphic);\n"],"file":"graphic.js"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Ruler = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _styles = require("@material-ui/core/styles");
|
|
25
|
+
|
|
26
|
+
var _rotatable = _interopRequireDefault(require("../rotatable"));
|
|
27
|
+
|
|
28
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
29
|
+
|
|
30
|
+
var _graphic = _interopRequireDefault(require("./graphic"));
|
|
31
|
+
|
|
32
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
33
|
+
|
|
34
|
+
var _anchor = _interopRequireDefault(require("../anchor"));
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
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
|
+
|
|
40
|
+
var Ruler = /*#__PURE__*/function (_React$Component) {
|
|
41
|
+
(0, _inherits2["default"])(Ruler, _React$Component);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(Ruler);
|
|
44
|
+
|
|
45
|
+
function Ruler() {
|
|
46
|
+
(0, _classCallCheck2["default"])(this, Ruler);
|
|
47
|
+
return _super.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
(0, _createClass2["default"])(Ruler, [{
|
|
51
|
+
key: "render",
|
|
52
|
+
value: function render() {
|
|
53
|
+
var _this$props = this.props,
|
|
54
|
+
classes = _this$props.classes,
|
|
55
|
+
width = _this$props.width,
|
|
56
|
+
height = _this$props.height,
|
|
57
|
+
units = _this$props.units,
|
|
58
|
+
measure = _this$props.measure,
|
|
59
|
+
className = _this$props.className,
|
|
60
|
+
startPosition = _this$props.startPosition,
|
|
61
|
+
label = _this$props.label,
|
|
62
|
+
tickCount = _this$props.tickCount;
|
|
63
|
+
var unit = measure === 'imperial' ? {
|
|
64
|
+
type: label,
|
|
65
|
+
ticks: tickCount && tickCount % 4 === 0 ? tickCount : 16
|
|
66
|
+
} : {
|
|
67
|
+
type: label,
|
|
68
|
+
ticks: 10
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/_react["default"].createElement(_rotatable["default"], {
|
|
71
|
+
className: className,
|
|
72
|
+
startPosition: startPosition,
|
|
73
|
+
handle: [{
|
|
74
|
+
"class": 'leftAnchor',
|
|
75
|
+
origin: 'bottom right'
|
|
76
|
+
}, {
|
|
77
|
+
"class": 'rightAnchor',
|
|
78
|
+
origin: 'bottom left'
|
|
79
|
+
}]
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
+
className: classes.ruler,
|
|
82
|
+
style: {
|
|
83
|
+
width: "".concat(width, "px"),
|
|
84
|
+
height: "".concat(height, "px")
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/_react["default"].createElement(_graphic["default"], {
|
|
87
|
+
width: width,
|
|
88
|
+
height: height,
|
|
89
|
+
units: units,
|
|
90
|
+
unit: unit
|
|
91
|
+
}), /*#__PURE__*/_react["default"].createElement(_anchor["default"], {
|
|
92
|
+
className: (0, _classnames["default"])('leftAnchor', classes.leftAnchor)
|
|
93
|
+
}), /*#__PURE__*/_react["default"].createElement(_anchor["default"], {
|
|
94
|
+
className: (0, _classnames["default"])('rightAnchor', classes.rightAnchor)
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
97
|
+
}]);
|
|
98
|
+
return Ruler;
|
|
99
|
+
}(_react["default"].Component);
|
|
100
|
+
|
|
101
|
+
exports.Ruler = Ruler;
|
|
102
|
+
(0, _defineProperty2["default"])(Ruler, "propTypes", {
|
|
103
|
+
width: _propTypes["default"].number,
|
|
104
|
+
height: _propTypes["default"].number,
|
|
105
|
+
units: _propTypes["default"].number.isRequired,
|
|
106
|
+
measure: _propTypes["default"].oneOf(['imperial', 'metric']).isRequired,
|
|
107
|
+
classes: _propTypes["default"].object.isRequired,
|
|
108
|
+
className: _propTypes["default"].string,
|
|
109
|
+
startPosition: _propTypes["default"].shape({
|
|
110
|
+
left: _propTypes["default"].number.isRequired,
|
|
111
|
+
top: _propTypes["default"].number.isRequired
|
|
112
|
+
}),
|
|
113
|
+
label: _propTypes["default"].string,
|
|
114
|
+
tickCount: _propTypes["default"].number
|
|
115
|
+
});
|
|
116
|
+
(0, _defineProperty2["default"])(Ruler, "defaultProps", {
|
|
117
|
+
width: 480,
|
|
118
|
+
height: 60,
|
|
119
|
+
measure: 'imperial',
|
|
120
|
+
units: 12
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
var styles = function styles(theme) {
|
|
124
|
+
return {
|
|
125
|
+
ruler: {
|
|
126
|
+
cursor: 'move',
|
|
127
|
+
position: 'relative',
|
|
128
|
+
backgroundColor: theme.palette.secondary.light,
|
|
129
|
+
opacity: 1.0,
|
|
130
|
+
border: "solid 0px ".concat(theme.palette.primary.main)
|
|
131
|
+
},
|
|
132
|
+
leftAnchor: {
|
|
133
|
+
left: '-10px',
|
|
134
|
+
top: '40%'
|
|
135
|
+
},
|
|
136
|
+
rightAnchor: {
|
|
137
|
+
right: '-10px',
|
|
138
|
+
top: '40%'
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
var _default = (0, _styles.withStyles)(styles)(Ruler);
|
|
144
|
+
|
|
145
|
+
exports["default"] = _default;
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ruler/index.jsx"],"names":["Ruler","props","classes","width","height","units","measure","className","startPosition","label","tickCount","unit","type","ticks","origin","ruler","leftAnchor","rightAnchor","React","Component","PropTypes","number","isRequired","oneOf","object","string","shape","left","top","styles","theme","cursor","position","backgroundColor","palette","secondary","light","opacity","border","primary","main","right"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,K;;;;;;;;;;;;WAuBX,kBAAS;AACP,wBAA+F,KAAK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AJJ;AAKLC,MAAAA,MAAM,sBAAeR,KAAK,CAACI,OAAN,CAAcK,OAAd,CAAsBC,IAArC;AALD,KADkB;AAQzBxB,IAAAA,UAAU,EAAE;AACVW,MAAAA,IAAI,EAAE,OADI;AAEVC,MAAAA,GAAG,EAAE;AAFK,KARa;AAYzBX,IAAAA,WAAW,EAAE;AACXwB,MAAAA,KAAK,EAAE,OADI;AAEXb,MAAAA,GAAG,EAAE;AAFM;AAZY,GAAZ;AAAA,CAAf;;eAkBe,wBAAWC,MAAX,EAAmB7B,KAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport Rotatable from '../rotatable';\nimport classNames from 'classnames';\nimport RulerGraphic from './graphic';\nimport PropTypes from 'prop-types';\nimport Anchor from '../anchor';\n\nexport class Ruler extends React.Component {\n static propTypes = {\n width: PropTypes.number,\n height: PropTypes.number,\n units: PropTypes.number.isRequired,\n measure: PropTypes.oneOf(['imperial', 'metric']).isRequired,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n startPosition: PropTypes.shape({\n left: PropTypes.number.isRequired,\n top: PropTypes.number.isRequired,\n }),\n label: PropTypes.string,\n tickCount: PropTypes.number,\n };\n\n static defaultProps = {\n width: 480,\n height: 60,\n measure: 'imperial',\n units: 12,\n };\n\n render() {\n const { classes, width, height, units, measure, className, startPosition, label, tickCount } = this.props;\n\n const unit =\n measure === 'imperial'\n ? {\n type: label,\n ticks: tickCount && tickCount % 4 === 0 ? tickCount : 16,\n }\n : {\n type: label,\n ticks: 10,\n };\n return (\n <Rotatable\n className={className}\n startPosition={startPosition}\n handle={[\n { class: 'leftAnchor', origin: 'bottom right' },\n { class: 'rightAnchor', origin: 'bottom left' },\n ]}\n >\n <div className={classes.ruler} style={{ width: `${width}px`, height: `${height}px` }}>\n <RulerGraphic width={width} height={height} units={units} unit={unit} />\n <Anchor className={classNames('leftAnchor', classes.leftAnchor)} />\n <Anchor className={classNames('rightAnchor', classes.rightAnchor)} />\n </div>\n </Rotatable>\n );\n }\n}\nconst styles = (theme) => ({\n ruler: {\n cursor: 'move',\n position: 'relative',\n backgroundColor: theme.palette.secondary.light,\n opacity: 1.0,\n border: `solid 0px ${theme.palette.primary.main}`,\n },\n leftAnchor: {\n left: '-10px',\n top: '40%',\n },\n rightAnchor: {\n right: '-10px',\n top: '40%',\n },\n});\n\nexport default withStyles(styles)(Ruler);\n"],"file":"index.js"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.UnitType = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _styleUtils = require("../style-utils");
|
|
17
|
+
|
|
18
|
+
var _styles = require("@material-ui/core/styles");
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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) { (0, _defineProperty2["default"])(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; }
|
|
23
|
+
|
|
24
|
+
var UnitType = function UnitType(props) {
|
|
25
|
+
var classes = props.classes,
|
|
26
|
+
label = props.label,
|
|
27
|
+
x = props.x,
|
|
28
|
+
y = props.y,
|
|
29
|
+
textAlign = props.textAlign,
|
|
30
|
+
fill = props.fill,
|
|
31
|
+
fontSize = props.fontSize,
|
|
32
|
+
stroke = props.stroke;
|
|
33
|
+
return /*#__PURE__*/_react["default"].createElement("text", {
|
|
34
|
+
className: classes.unitType,
|
|
35
|
+
x: x,
|
|
36
|
+
y: y,
|
|
37
|
+
textAnchor: textAlign,
|
|
38
|
+
stroke: stroke,
|
|
39
|
+
fill: fill,
|
|
40
|
+
fontSize: fontSize
|
|
41
|
+
}, label);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.UnitType = UnitType;
|
|
45
|
+
UnitType.propTypes = {
|
|
46
|
+
classes: _propTypes["default"].object.isRequired,
|
|
47
|
+
label: _propTypes["default"].string.isRequired,
|
|
48
|
+
x: _propTypes["default"].number,
|
|
49
|
+
y: _propTypes["default"].number,
|
|
50
|
+
textAlign: _propTypes["default"].string,
|
|
51
|
+
fill: _propTypes["default"].string,
|
|
52
|
+
fontSize: _propTypes["default"].number,
|
|
53
|
+
stroke: _propTypes["default"].string
|
|
54
|
+
};
|
|
55
|
+
UnitType.defaultProps = {
|
|
56
|
+
textAnchor: 'start',
|
|
57
|
+
fontSize: 11,
|
|
58
|
+
stroke: 'none',
|
|
59
|
+
x: 8,
|
|
60
|
+
y: 14
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var _default = (0, _styles.withStyles)(function (theme) {
|
|
64
|
+
return {
|
|
65
|
+
unitType: _objectSpread(_objectSpread({}, (0, _styleUtils.noSelect)()), {}, {
|
|
66
|
+
fill: (0, _styleUtils.strokeColor)(theme)
|
|
67
|
+
})
|
|
68
|
+
};
|
|
69
|
+
})(UnitType);
|
|
70
|
+
|
|
71
|
+
exports["default"] = _default;
|
|
72
|
+
//# sourceMappingURL=unit-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ruler/unit-type.jsx"],"names":["UnitType","props","classes","label","x","y","textAlign","fill","fontSize","stroke","unitType","propTypes","PropTypes","object","isRequired","string","number","defaultProps","textAnchor","theme"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;AACjC,MAAQC,OAAR,GAAoED,KAApE,CAAQC,OAAR;AAAA,MAAiBC,KAAjB,GAAoEF,KAApE,CAAiBE,KAAjB;AAAA,MAAwBC,CAAxB,GAAoEH,KAApE,CAAwBG,CAAxB;AAAA,MAA2BC,CAA3B,GAAoEJ,KAApE,CAA2BI,CAA3B;AAAA,MAA8BC,SAA9B,GAAoEL,KAApE,CAA8BK,SAA9B;AAAA,MAAyCC,IAAzC,GAAoEN,KAApE,CAAyCM,IAAzC;AAAA,MAA+CC,QAA/C,GAAoEP,KAApE,CAA+CO,QAA/C;AAAA,MAAyDC,MAAzD,GAAoER,KAApE,CAAyDQ,MAAzD;AAEA,sBACE;AACE,IAAA,SAAS,EAAEP,OAAO,CAACQ,QADrB;AAEE,IAAA,CAAC,EAAEN,CAFL;AAGE,IAAA,CAAC,EAAEC,CAHL;AAIE,IAAA,UAAU,EAAEC,SAJd;AAKE,IAAA,MAAM,EAAEG,MALV;AAME,IAAA,IAAI,EAAEF,IANR;AAOE,IAAA,QAAQ,EAAEC;AAPZ,KASGL,KATH,CADF;AAaD,CAhBM;;;AAkBPH,QAAQ,CAACW,SAAT,GAAqB;AACnBT,EAAAA,OAAO,EAAEU,sBAAUC,MAAV,CAAiBC,UADP;AAEnBX,EAAAA,KAAK,EAAES,sBAAUG,MAAV,CAAiBD,UAFL;AAGnBV,EAAAA,CAAC,EAAEQ,sBAAUI,MAHM;AAInBX,EAAAA,CAAC,EAAEO,sBAAUI,MAJM;AAKnBV,EAAAA,SAAS,EAAEM,sBAAUG,MALF;AAMnBR,EAAAA,IAAI,EAAEK,sBAAUG,MANG;AAOnBP,EAAAA,QAAQ,EAAEI,sBAAUI,MAPD;AAQnBP,EAAAA,MAAM,EAAEG,sBAAUG;AARC,CAArB;AAWAf,QAAQ,CAACiB,YAAT,GAAwB;AACtBC,EAAAA,UAAU,EAAE,OADU;AAEtBV,EAAAA,QAAQ,EAAE,EAFY;AAGtBC,EAAAA,MAAM,EAAE,MAHc;AAItBL,EAAAA,CAAC,EAAE,CAJmB;AAKtBC,EAAAA,CAAC,EAAE;AALmB,CAAxB;;eAQe,wBAAW,UAACc,KAAD;AAAA,SAAY;AACpCT,IAAAA,QAAQ,kCAAO,2BAAP;AAAmBH,MAAAA,IAAI,EAAE,6BAAYY,KAAZ;AAAzB;AAD4B,GAAZ;AAAA,CAAX,EAEXnB,QAFW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { noSelect, strokeColor } from '../style-utils';\nimport { withStyles } from '@material-ui/core/styles';\n\nexport const UnitType = (props) => {\n const { classes, label, x, y, textAlign, fill, fontSize, stroke } = props;\n\n return (\n <text\n className={classes.unitType}\n x={x}\n y={y}\n textAnchor={textAlign}\n stroke={stroke}\n fill={fill}\n fontSize={fontSize}\n >\n {label}\n </text>\n );\n};\n\nUnitType.propTypes = {\n classes: PropTypes.object.isRequired,\n label: PropTypes.string.isRequired,\n x: PropTypes.number,\n y: PropTypes.number,\n textAlign: PropTypes.string,\n fill: PropTypes.string,\n fontSize: PropTypes.number,\n stroke: PropTypes.string,\n};\n\nUnitType.defaultProps = {\n textAnchor: 'start',\n fontSize: 11,\n stroke: 'none',\n x: 8,\n y: 14,\n};\n\nexport default withStyles((theme) => ({\n unitType: { ...noSelect(), fill: strokeColor(theme) },\n}))(UnitType);\n"],"file":"unit-type.js"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Unit = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
+
|
|
26
|
+
var _styles = require("@material-ui/core/styles");
|
|
27
|
+
|
|
28
|
+
var _styleUtils = require("../style-utils");
|
|
29
|
+
|
|
30
|
+
var _range = _interopRequireDefault(require("lodash/range"));
|
|
31
|
+
|
|
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; }
|
|
33
|
+
|
|
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) { (0, _defineProperty2["default"])(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; }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
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
|
+
|
|
40
|
+
var Tick = (0, _styles.withStyles)(function (theme) {
|
|
41
|
+
return {
|
|
42
|
+
tick: {
|
|
43
|
+
stroke: (0, _styleUtils.strokeColor)(theme)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
})(function (_ref) {
|
|
47
|
+
var x = _ref.x,
|
|
48
|
+
height = _ref.height,
|
|
49
|
+
bottom = _ref.bottom,
|
|
50
|
+
classes = _ref.classes,
|
|
51
|
+
major = _ref.major,
|
|
52
|
+
minor = _ref.minor;
|
|
53
|
+
var y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement("line", {
|
|
55
|
+
y1: y1,
|
|
56
|
+
y2: bottom,
|
|
57
|
+
x1: x,
|
|
58
|
+
x2: x,
|
|
59
|
+
className: classes.tick
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var Ticks = function Ticks(_ref2) {
|
|
64
|
+
var count = _ref2.count,
|
|
65
|
+
width = _ref2.width,
|
|
66
|
+
height = _ref2.height;
|
|
67
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _range["default"])(1, count).map(function (r) {
|
|
68
|
+
return /*#__PURE__*/_react["default"].createElement(Tick, {
|
|
69
|
+
key: r,
|
|
70
|
+
value: r,
|
|
71
|
+
x: r * (width / count),
|
|
72
|
+
major: r % (count / 2) === 0,
|
|
73
|
+
minor: r % (count / 4) === 0,
|
|
74
|
+
bottom: height,
|
|
75
|
+
height: 10
|
|
76
|
+
});
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Ticks.propTypes = {
|
|
81
|
+
count: _propTypes["default"].number.isRequired,
|
|
82
|
+
width: _propTypes["default"].number.isRequired,
|
|
83
|
+
height: _propTypes["default"].number.isRequired
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var Unit = /*#__PURE__*/function (_React$Component) {
|
|
87
|
+
(0, _inherits2["default"])(Unit, _React$Component);
|
|
88
|
+
|
|
89
|
+
var _super = _createSuper(Unit);
|
|
90
|
+
|
|
91
|
+
function Unit() {
|
|
92
|
+
(0, _classCallCheck2["default"])(this, Unit);
|
|
93
|
+
return _super.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
(0, _createClass2["default"])(Unit, [{
|
|
97
|
+
key: "render",
|
|
98
|
+
value: function render() {
|
|
99
|
+
var _this$props = this.props,
|
|
100
|
+
index = _this$props.index,
|
|
101
|
+
width = _this$props.width,
|
|
102
|
+
height = _this$props.height,
|
|
103
|
+
classes = _this$props.classes,
|
|
104
|
+
last = _this$props.last,
|
|
105
|
+
config = _this$props.config;
|
|
106
|
+
var style = {
|
|
107
|
+
transform: "translate(".concat(width * (index - 1), "px, 0px)")
|
|
108
|
+
};
|
|
109
|
+
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
110
|
+
style: style
|
|
111
|
+
}, !last && /*#__PURE__*/_react["default"].createElement("line", {
|
|
112
|
+
x1: width,
|
|
113
|
+
y1: 0,
|
|
114
|
+
x2: width,
|
|
115
|
+
y2: height,
|
|
116
|
+
className: classes.endTick
|
|
117
|
+
}), /*#__PURE__*/_react["default"].createElement(Ticks, {
|
|
118
|
+
count: config.ticks,
|
|
119
|
+
width: width,
|
|
120
|
+
height: height
|
|
121
|
+
}), /*#__PURE__*/_react["default"].createElement("text", {
|
|
122
|
+
width: width,
|
|
123
|
+
className: classes.label,
|
|
124
|
+
x: width - 5,
|
|
125
|
+
y: 15
|
|
126
|
+
}, index));
|
|
127
|
+
}
|
|
128
|
+
}]);
|
|
129
|
+
return Unit;
|
|
130
|
+
}(_react["default"].Component);
|
|
131
|
+
|
|
132
|
+
exports.Unit = Unit;
|
|
133
|
+
(0, _defineProperty2["default"])(Unit, "propTypes", {
|
|
134
|
+
index: _propTypes["default"].number.isRequired,
|
|
135
|
+
width: _propTypes["default"].number.isRequired,
|
|
136
|
+
height: _propTypes["default"].number.isRequired,
|
|
137
|
+
classes: _propTypes["default"].object.isRequired,
|
|
138
|
+
last: _propTypes["default"].bool.isRequired,
|
|
139
|
+
config: _propTypes["default"].object.isRequired
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
var _default = (0, _styles.withStyles)(function (theme) {
|
|
143
|
+
return {
|
|
144
|
+
endTick: {
|
|
145
|
+
stroke: (0, _styleUtils.strokeColor)(theme),
|
|
146
|
+
strokeWidth: 1
|
|
147
|
+
},
|
|
148
|
+
label: _objectSpread({
|
|
149
|
+
textAnchor: 'end',
|
|
150
|
+
fontSize: '12px',
|
|
151
|
+
fill: (0, _styleUtils.strokeColor)(theme)
|
|
152
|
+
}, (0, _styleUtils.noSelect)()),
|
|
153
|
+
base: {
|
|
154
|
+
fill: 'none',
|
|
155
|
+
stroke: 'red'
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
})(Unit);
|
|
159
|
+
|
|
160
|
+
exports["default"] = _default;
|
|
161
|
+
//# sourceMappingURL=unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ruler/unit.jsx"],"names":["Tick","theme","tick","stroke","x","height","bottom","classes","major","minor","y1","Ticks","count","width","map","r","propTypes","PropTypes","number","isRequired","Unit","props","index","last","config","style","transform","endTick","ticks","label","React","Component","object","bool","strokeWidth","textAnchor","fontSize","fill","base"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,IAAI,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AAClCC,IAAAA,IAAI,EAAE;AACJC,MAAAA,MAAM,EAAE,6BAAYF,KAAZ;AADJ;AAD4B,GAAZ;AAAA,CAAX,EAIT,gBAAkD;AAAA,MAA/CG,CAA+C,QAA/CA,CAA+C;AAAA,MAA5CC,MAA4C,QAA5CA,MAA4C;AAAA,MAApCC,MAAoC,QAApCA,MAAoC;AAAA,MAA5BC,OAA4B,QAA5BA,OAA4B;AAAA,MAAnBC,KAAmB,QAAnBA,KAAmB;AAAA,MAAZC,KAAY,QAAZA,KAAY;AACpD,MAAMC,EAAE,GAAGF,KAAK,GAAGF,MAAM,GAAGD,MAAM,GAAG,CAArB,GAAyBI,KAAK,GAAGH,MAAM,GAAGD,MAAM,GAAG,GAArB,GAA2BC,MAAM,GAAGD,MAAlF;AAEA,sBAAO;AAAM,IAAA,EAAE,EAAEK,EAAV;AAAc,IAAA,EAAE,EAAEJ,MAAlB;AAA0B,IAAA,EAAE,EAAEF,CAA9B;AAAiC,IAAA,EAAE,EAAEA,CAArC;AAAwC,IAAA,SAAS,EAAEG,OAAO,CAACL;AAA3D,IAAP;AACD,CARY,CAAb;;AAUA,IAAMS,KAAK,GAAG,SAARA,KAAQ,QAA8B;AAAA,MAA3BC,KAA2B,SAA3BA,KAA2B;AAAA,MAApBC,KAAoB,SAApBA,KAAoB;AAAA,MAAbR,MAAa,SAAbA,MAAa;AAC1C,sBACE,gCAAC,iBAAD,CAAO,QAAP,QACG,uBAAM,CAAN,EAASO,KAAT,EAAgBE,G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from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { noSelect, strokeColor } from '../style-utils';\nimport range from 'lodash/range';\n\nconst Tick = withStyles((theme) => ({\n tick: {\n stroke: strokeColor(theme),\n },\n}))(({ x, height, bottom, classes, major, minor }) => {\n const y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;\n\n return <line y1={y1} y2={bottom} x1={x} x2={x} className={classes.tick} />;\n});\n\nconst Ticks = ({ count, width, height }) => {\n return (\n <React.Fragment>\n {range(1, count).map((r) => {\n return (\n <Tick\n key={r}\n value={r}\n x={r * (width / count)}\n major={r % (count / 2) === 0}\n minor={r % (count / 4) === 0}\n bottom={height}\n height={10}\n />\n );\n })}\n </React.Fragment>\n );\n};\n\nTicks.propTypes = {\n count: PropTypes.number.isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n};\n\nexport class Unit extends React.Component {\n static propTypes = {\n index: PropTypes.number.isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n classes: PropTypes.object.isRequired,\n last: PropTypes.bool.isRequired,\n config: PropTypes.object.isRequired,\n };\n\n render() {\n const { index, width, height, classes, last, config } = this.props;\n\n const style = {\n transform: `translate(${width * (index - 1)}px, 0px)`,\n };\n return (\n <g style={style}>\n {!last && <line x1={width} y1={0} x2={width} y2={height} className={classes.endTick} />}\n\n <Ticks count={config.ticks} width={width} height={height} />\n <text width={width} className={classes.label} x={width - 5} y={15}>\n {index}\n </text>\n </g>\n );\n }\n}\n\nexport default withStyles((theme) => ({\n endTick: {\n stroke: strokeColor(theme),\n strokeWidth: 1,\n },\n label: {\n textAnchor: 'end',\n fontSize: '12px',\n fill: strokeColor(theme),\n ...noSelect(),\n },\n base: {\n fill: 'none',\n stroke: 'red',\n },\n}))(Unit);\n"],"file":"unit.js"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fillColor = void 0;
|
|
7
|
+
Object.defineProperty(exports, "noSelect", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _styleUtils.noSelect;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.strokeColor = void 0;
|
|
14
|
+
|
|
15
|
+
var _styleUtils = require("@pie-lib/style-utils");
|
|
16
|
+
|
|
17
|
+
var strokeColor = function strokeColor(theme) {
|
|
18
|
+
return "var(--ruler-stroke, ".concat(theme.palette.primary.main, ")");
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.strokeColor = strokeColor;
|
|
22
|
+
|
|
23
|
+
var fillColor = function fillColor(theme) {
|
|
24
|
+
return "var(--ruler-bg, ".concat(theme.palette.primary.contrastText, ")");
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.fillColor = fillColor;
|
|
28
|
+
//# sourceMappingURL=style-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/style-utils.js"],"names":["strokeColor","theme","palette","primary","main","fillColor","contrastText"],"mappings":";;;;;;;;;;;;;;AAAA;;AAIO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD;AAAA,uCAAkCA,KAAK,CAACC,OAAN,CAAcC,OAAd,CAAsBC,IAAxD;AAAA,CAApB;;;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAACJ,KAAD;AAAA,mCAA8BA,KAAK,CAACC,OAAN,CAAcC,OAAd,CAAsBG,YAApD;AAAA,CAAlB","sourcesContent":["import { noSelect } from '@pie-lib/style-utils';\n\nexport { noSelect };\n\nexport const strokeColor = (theme) => `var(--ruler-stroke, ${theme.palette.primary.main})`;\n\nexport const fillColor = (theme) => `var(--ruler-bg, ${theme.palette.primary.contrastText})`;\n"],"file":"style-utils.js"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parse = void 0;
|
|
7
|
+
|
|
8
|
+
var keyWordToPercent = function keyWordToPercent(v) {
|
|
9
|
+
if (v === 'left' || v === 'top') {
|
|
10
|
+
return 0;
|
|
11
|
+
} else if (v === 'right' || v === 'bottom') {
|
|
12
|
+
return 100;
|
|
13
|
+
} else if (v === 'center') {
|
|
14
|
+
return 50;
|
|
15
|
+
} else if (v.endsWith('%')) {
|
|
16
|
+
return parseFloat(v);
|
|
17
|
+
} else {
|
|
18
|
+
return v;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var getValue = function getValue(s, length) {
|
|
23
|
+
if (s.endsWith('px')) {
|
|
24
|
+
return parseFloat(s);
|
|
25
|
+
} else {
|
|
26
|
+
s = keyWordToPercent(s);
|
|
27
|
+
var v = length * (s / 100);
|
|
28
|
+
return v;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var normalize = function normalize(a) {
|
|
33
|
+
if (a[0] === 'bottom' || a[0] === 'top' || a[1] === 'left' || a[1] === 'right') {
|
|
34
|
+
return [a[1], a[0]];
|
|
35
|
+
} else {
|
|
36
|
+
return a;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Parse a transform origin string to x/y values.
|
|
41
|
+
* @param {{width: number, height: number}} rect
|
|
42
|
+
* @param {string} value
|
|
43
|
+
* @returns {x:number, y:number}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
var parse = function parse(rect, value) {
|
|
48
|
+
if (!value) {
|
|
49
|
+
return {
|
|
50
|
+
x: rect.width / 2,
|
|
51
|
+
y: rect.height / 2
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var arr = value.split(' ');
|
|
56
|
+
|
|
57
|
+
if (arr.length === 1) {
|
|
58
|
+
//1 val
|
|
59
|
+
var x = getValue(arr[0], rect.width);
|
|
60
|
+
var y = getValue('50%', rect.height);
|
|
61
|
+
return {
|
|
62
|
+
x: x,
|
|
63
|
+
y: y
|
|
64
|
+
};
|
|
65
|
+
} else if (arr.length === 2) {
|
|
66
|
+
var sorted = normalize(arr);
|
|
67
|
+
|
|
68
|
+
var _x = getValue(sorted[0], rect.width);
|
|
69
|
+
|
|
70
|
+
var _y = getValue(sorted[1], rect.height);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
x: _x,
|
|
74
|
+
y: _y
|
|
75
|
+
};
|
|
76
|
+
} else if (arr.length === 3) {
|
|
77
|
+
throw new Error('transform-origin values with 3 fields not supported.');
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.parse = parse;
|
|
82
|
+
//# sourceMappingURL=transform-origin.js.map
|