@pie-lib/tools 2.0.2 → 2.0.3-next.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.
Files changed (126) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +11 -0
  2. package/dist/anchor-utils.d.ts +60 -0
  3. package/dist/anchor-utils.js +87 -0
  4. package/dist/anchor.d.ts +13 -0
  5. package/dist/anchor.js +17 -0
  6. package/dist/index.d.ts +13 -0
  7. package/dist/index.js +5 -0
  8. package/dist/node_modules/.bun/assert@1.5.1/node_modules/assert/assert.js +174 -0
  9. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js +13 -0
  10. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js +8 -0
  11. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js +8 -0
  12. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js +16 -0
  13. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js +8 -0
  14. package/dist/node_modules/.bun/call-bound@1.0.4/node_modules/call-bound/index.js +14 -0
  15. package/dist/node_modules/.bun/degrees-radians@1.0.3/node_modules/degrees-radians/index.js +12 -0
  16. package/dist/node_modules/.bun/dunder-proto@1.0.1/node_modules/dunder-proto/get.js +19 -0
  17. package/dist/node_modules/.bun/es-define-property@1.0.1/node_modules/es-define-property/index.js +14 -0
  18. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/eval.js +8 -0
  19. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/index.js +8 -0
  20. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/range.js +8 -0
  21. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/ref.js +8 -0
  22. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/syntax.js +8 -0
  23. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/type.js +8 -0
  24. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/uri.js +8 -0
  25. package/dist/node_modules/.bun/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js +8 -0
  26. package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/implementation.js +34 -0
  27. package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/index.js +10 -0
  28. package/dist/node_modules/.bun/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js +283 -0
  29. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js +9 -0
  30. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js +8 -0
  31. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/index.js +19 -0
  32. package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/gOPD.js +8 -0
  33. package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/index.js +15 -0
  34. package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/index.js +12 -0
  35. package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/shams.js +23 -0
  36. package/dist/node_modules/.bun/hasown@2.0.4/node_modules/hasown/index.js +10 -0
  37. package/dist/node_modules/.bun/inherits@2.0.3/node_modules/inherits/inherits_browser.js +19 -0
  38. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js +8 -0
  39. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js +8 -0
  40. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js +10 -0
  41. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js +8 -0
  42. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js +8 -0
  43. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js +8 -0
  44. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js +8 -0
  45. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js +12 -0
  46. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/implementation.js +77 -0
  47. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/index.js +20 -0
  48. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/isArguments.js +12 -0
  49. package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/implementation.js +29 -0
  50. package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/polyfill.js +27 -0
  51. package/dist/node_modules/.bun/radians-degrees@1.0.0/node_modules/radians-degrees/index.js +11 -0
  52. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/LegacyPortal.js +77 -0
  53. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/Portal.js +55 -0
  54. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/PortalCompat.js +9 -0
  55. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/utils.js +4 -0
  56. package/dist/node_modules/.bun/trigonometry-calculator@2.0.0/node_modules/trigonometry-calculator/lib/index.js +53 -0
  57. package/dist/node_modules/.bun/trigonometry-equations@2.0.1/node_modules/trigonometry-equations/lib/index.js +129 -0
  58. package/dist/node_modules/.bun/util@0.10.4/node_modules/util/support/isBufferBrowser.js +10 -0
  59. package/dist/node_modules/.bun/util@0.10.4/node_modules/util/util.js +262 -0
  60. package/dist/protractor/graphic.d.ts +13 -0
  61. package/dist/protractor/graphic.js +85 -0
  62. package/dist/protractor/index.d.ts +29 -0
  63. package/dist/protractor/index.js +56 -0
  64. package/dist/rotatable.d.ts +56 -0
  65. package/dist/rotatable.js +210 -0
  66. package/dist/ruler/graphic.d.ts +20 -0
  67. package/dist/ruler/graphic.js +53 -0
  68. package/dist/ruler/index.d.ts +32 -0
  69. package/dist/ruler/index.js +77 -0
  70. package/dist/ruler/unit-type.d.ts +30 -0
  71. package/dist/ruler/unit-type.js +38 -0
  72. package/dist/ruler/unit.d.ts +21 -0
  73. package/dist/ruler/unit.js +69 -0
  74. package/dist/style-utils.d.ts +12 -0
  75. package/dist/style-utils.js +5 -0
  76. package/dist/transform-origin.d.ts +18 -0
  77. package/dist/transform-origin.js +21 -0
  78. package/package.json +31 -25
  79. package/CHANGELOG.json +0 -1
  80. package/CHANGELOG.md +0 -626
  81. package/LICENSE.md +0 -5
  82. package/lib/anchor-utils.js +0 -193
  83. package/lib/anchor-utils.js.map +0 -1
  84. package/lib/anchor.js +0 -33
  85. package/lib/anchor.js.map +0 -1
  86. package/lib/index.js +0 -33
  87. package/lib/index.js.map +0 -1
  88. package/lib/protractor/graphic.js +0 -147
  89. package/lib/protractor/graphic.js.map +0 -1
  90. package/lib/protractor/index.js +0 -90
  91. package/lib/protractor/index.js.map +0 -1
  92. package/lib/rotatable.js +0 -335
  93. package/lib/rotatable.js.map +0 -1
  94. package/lib/ruler/graphic.js +0 -89
  95. package/lib/ruler/graphic.js.map +0 -1
  96. package/lib/ruler/index.js +0 -114
  97. package/lib/ruler/index.js.map +0 -1
  98. package/lib/ruler/unit-type.js +0 -55
  99. package/lib/ruler/unit-type.js.map +0 -1
  100. package/lib/ruler/unit.js +0 -124
  101. package/lib/ruler/unit.js.map +0 -1
  102. package/lib/style-utils.js +0 -21
  103. package/lib/style-utils.js.map +0 -1
  104. package/lib/transform-origin.js +0 -71
  105. package/lib/transform-origin.js.map +0 -1
  106. package/src/__tests__/anchor-utils.test.js +0 -131
  107. package/src/__tests__/rotatable.test.jsx +0 -263
  108. package/src/__tests__/transform-origin.test.jsx +0 -24
  109. package/src/anchor-utils.js +0 -153
  110. package/src/anchor.jsx +0 -20
  111. package/src/index.js +0 -6
  112. package/src/protractor/__tests__/graphic.test.jsx +0 -64
  113. package/src/protractor/__tests__/index.test.jsx +0 -65
  114. package/src/protractor/graphic.jsx +0 -82
  115. package/src/protractor/index.jsx +0 -67
  116. package/src/rotatable.jsx +0 -290
  117. package/src/ruler/__tests__/graphic.test.jsx +0 -64
  118. package/src/ruler/__tests__/index.test.jsx +0 -85
  119. package/src/ruler/__tests__/unit-type.test.jsx +0 -66
  120. package/src/ruler/__tests__/unit.test.jsx +0 -68
  121. package/src/ruler/graphic.jsx +0 -48
  122. package/src/ruler/index.jsx +0 -78
  123. package/src/ruler/unit-type.jsx +0 -39
  124. package/src/ruler/unit.jsx +0 -83
  125. package/src/style-utils.js +0 -7
  126. package/src/transform-origin.jsx +0 -60
package/lib/rotatable.js DELETED
@@ -1,335 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = exports.Rotatable = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _react = _interopRequireDefault(require("react"));
15
- var _propTypes = _interopRequireDefault(require("prop-types"));
16
- var _styles = require("@mui/material/styles");
17
- var _anchorUtils = require("./anchor-utils");
18
- var _reactPortal = require("react-portal");
19
- var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
20
- var _transformOrigin = require("./transform-origin");
21
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
22
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
- var AnchorSvg = (0, _styles.styled)('svg')({
24
- position: 'absolute',
25
- zIndex: 100,
26
- width: '200px',
27
- height: '80px'
28
- });
29
- var Anchor = function Anchor(_ref) {
30
- var left = _ref.left,
31
- top = _ref.top,
32
- color = _ref.color,
33
- fill = _ref.fill;
34
- color = color || 'green';
35
- fill = fill || 'white';
36
- return /*#__PURE__*/_react["default"].createElement(_reactPortal.Portal, null, /*#__PURE__*/_react["default"].createElement(AnchorSvg, {
37
- style: {
38
- left: left - 10,
39
- top: top - 10
40
- }
41
- }, /*#__PURE__*/_react["default"].createElement("circle", {
42
- cx: 10,
43
- cy: 10,
44
- r: 8,
45
- strokeWidth: 1,
46
- stroke: color,
47
- fill: fill
48
- })));
49
- };
50
-
51
- /**
52
- * Tip o' the hat to:
53
- * https://bl.ocks.org/joyrexus/7207044
54
- */
55
- var RotatableContainer = (0, _styles.styled)('div')({
56
- position: 'relative',
57
- display: 'inline-block',
58
- cursor: 'move'
59
- });
60
- var Rotatable = exports.Rotatable = /*#__PURE__*/function (_React$Component) {
61
- function Rotatable(props) {
62
- var _this;
63
- (0, _classCallCheck2["default"])(this, Rotatable);
64
- _this = _callSuper(this, Rotatable, [props]);
65
- (0, _defineProperty2["default"])(_this, "initHandles", function () {
66
- var handle = _this.props.handle;
67
- if (Array.isArray(handle)) {
68
- _this.handles = [];
69
- handle.forEach(function (h) {
70
- var el = _this.rotatable.querySelector(".".concat(h["class"]));
71
- if (el) {
72
- var mousedownHandler = _this.rotateStart(h.origin);
73
- el.addEventListener('mousedown', mousedownHandler);
74
- el.addEventListener('mouseup', _this.rotateStop);
75
- _this.handles.push({
76
- el: el,
77
- mousedownHandler: mousedownHandler
78
- });
79
- }
80
- });
81
- }
82
- });
83
- (0, _defineProperty2["default"])(_this, "addMouseUpHandler", function () {
84
- document.addEventListener('mouseup', _this.rotateStop);
85
- });
86
- (0, _defineProperty2["default"])(_this, "originToXY", function (origin) {
87
- var _this$rotatable = _this.rotatable,
88
- width = _this$rotatable.clientWidth,
89
- height = _this$rotatable.clientHeight;
90
- return (0, _transformOrigin.parse)({
91
- width: width,
92
- height: height
93
- }, origin);
94
- });
95
- /**
96
- * Get the anchor point for the given element, origin and rotation.
97
- * @returns {{left:number, top: number}} - the co-ordinates of the anchor point relative to the whole page.
98
- */
99
- (0, _defineProperty2["default"])(_this, "getAnchor", function (origin) {
100
- var rotation = _this.state.rotation;
101
- var _this$rotatable2 = _this.rotatable,
102
- clientWidth = _this$rotatable2.clientWidth,
103
- clientHeight = _this$rotatable2.clientHeight;
104
- var _this$rotatable$getBo = _this.rotatable.getBoundingClientRect(),
105
- top = _this$rotatable$getBo.top,
106
- left = _this$rotatable$getBo.left;
107
- var xy = _this.originToXY(origin);
108
- var _calcAnchor = (0, _anchorUtils.getAnchor)({
109
- width: clientWidth,
110
- height: clientHeight
111
- }, xy, rotation),
112
- anchorTop = _calcAnchor.top,
113
- anchorLeft = _calcAnchor.left;
114
- return {
115
- top: top + anchorTop,
116
- left: left + anchorLeft
117
- };
118
- });
119
- (0, _defineProperty2["default"])(_this, "rotateStart", function (origin) {
120
- return function (e) {
121
- var isRotating = _this.state.isRotating;
122
- if (isRotating) {
123
- return;
124
- }
125
- e.preventDefault();
126
- var anchor = _this.getAnchor(origin);
127
- var rotation = _this.state.rotation;
128
- var _this$getAngle = _this.getAngle(anchor, e),
129
- startAngle = _this$getAngle.angle;
130
- var diff = {
131
- x: 0,
132
- y: 0
133
- };
134
- if (origin !== _this.state.origin) {
135
- var _this$rotatable3 = _this.rotatable,
136
- width = _this$rotatable3.clientWidth,
137
- height = _this$rotatable3.clientHeight;
138
- diff = (0, _anchorUtils.distanceBetween)({
139
- width: width,
140
- height: height
141
- }, rotation, _this.state.origin, origin);
142
- }
143
- _this.setState({
144
- origin: origin,
145
- isRotating: true,
146
- startAngle: startAngle,
147
- anchor: anchor,
148
- position: {
149
- left: _this.state.position.left + diff.x,
150
- top: _this.state.position.top + diff.y
151
- }
152
- }, function () {
153
- document.addEventListener('mousemove', _this.rotate);
154
- });
155
- };
156
- });
157
- (0, _defineProperty2["default"])(_this, "rotateStop", function (e) {
158
- var isRotating = _this.state.isRotating;
159
- if (!isRotating) {
160
- return;
161
- }
162
- e.preventDefault();
163
- _this.setState({
164
- isRotating: false,
165
- angle: _this.state.rotation,
166
- anchor: null,
167
- current: null
168
- }, function () {
169
- document.removeEventListener('mousemove', _this.rotate);
170
- document.removeEventListener('mousemove', _this.drag);
171
- });
172
- });
173
- (0, _defineProperty2["default"])(_this, "rotate", function (e) {
174
- var isRotating = _this.state.isRotating;
175
- if (!isRotating) {
176
- return;
177
- }
178
- e.preventDefault();
179
- var _this$state = _this.state,
180
- startAngle = _this$state.startAngle,
181
- angle = _this$state.angle,
182
- anchor = _this$state.anchor;
183
- var _this$getAngle2 = _this.getAngle(anchor, e),
184
- current = _this$getAngle2.angle,
185
- x = _this$getAngle2.x,
186
- y = _this$getAngle2.y;
187
- var computedAnchor = {
188
- x: x,
189
- y: y
190
- };
191
- var diff = current - startAngle;
192
- var rotation = angle + diff;
193
- _this.setState({
194
- rotation: rotation,
195
- diff: diff,
196
- current: current,
197
- computedAnchor: computedAnchor
198
- });
199
- });
200
- (0, _defineProperty2["default"])(_this, "mouseDown", function (e) {
201
- var handle = _this.handles.find(function (h) {
202
- return h.el === e.target;
203
- });
204
- if (!handle) {
205
- _this.dragStart(e);
206
- }
207
- });
208
- (0, _defineProperty2["default"])(_this, "dragStart", function (e) {
209
- var dragPoint = new _pointGeometry["default"](e.pageX, e.pageY);
210
- _this.setState({
211
- dragPoint: dragPoint
212
- }, function () {
213
- document.addEventListener('mousemove', _this.drag);
214
- });
215
- });
216
- (0, _defineProperty2["default"])(_this, "drag", function (e) {
217
- e.preventDefault();
218
- var current = new _pointGeometry["default"](e.pageX, e.pageY);
219
- var translate = current.sub(_this.state.dragPoint);
220
- _this.setState({
221
- translate: translate
222
- });
223
- });
224
- (0, _defineProperty2["default"])(_this, "mouseUp", function () {
225
- if (!_this.state.translate) {
226
- return;
227
- }
228
- var _this$state2 = _this.state,
229
- lastPosition = _this$state2.position,
230
- translate = _this$state2.translate;
231
- var position = {
232
- left: lastPosition.left + translate.x,
233
- top: lastPosition.top + translate.y
234
- };
235
- document.removeEventListener('mousemove', _this.drag);
236
- _this.setState({
237
- position: position,
238
- dragPoint: null,
239
- translate: null
240
- });
241
- });
242
- _this.state = {
243
- isRotating: false,
244
- rotation: 0,
245
- startAngle: 0,
246
- angle: 0,
247
- position: {
248
- left: props.startPosition.left,
249
- top: props.startPosition.top
250
- }
251
- };
252
- return _this;
253
- }
254
- (0, _inherits2["default"])(Rotatable, _React$Component);
255
- return (0, _createClass2["default"])(Rotatable, [{
256
- key: "componentWillUnmount",
257
- value: function componentWillUnmount() {
258
- var _this2 = this;
259
- document.removeEventListener('mouseup', this.rotateStop);
260
- document.removeEventListener('mousemove', this.drag);
261
- document.removeEventListener('mousemove', this.rotate);
262
- this.handles.forEach(function (h) {
263
- h.el.removeEventListener('mousedown', h.mousedownHandler);
264
- h.el.removeEventListener('mouseup', _this2.rotateStop);
265
- });
266
- }
267
- }, {
268
- key: "componentDidMount",
269
- value: function componentDidMount() {
270
- this.addMouseUpHandler();
271
- this.initHandles();
272
- }
273
- }, {
274
- key: "getAngle",
275
- value: function getAngle(anchor, e) {
276
- var x = e.clientX - anchor.left;
277
- var y = (e.clientY - anchor.top) * -1;
278
- return {
279
- angle: (0, _anchorUtils.arctangent)(x, y),
280
- x: x,
281
- y: y
282
- };
283
- }
284
- }, {
285
- key: "render",
286
- value: function render() {
287
- var _this3 = this;
288
- var _this$props = this.props,
289
- children = _this$props.children,
290
- showAnchor = _this$props.showAnchor;
291
- var _this$state3 = this.state,
292
- rotation = _this$state3.rotation,
293
- anchor = _this$state3.anchor,
294
- origin = _this$state3.origin,
295
- translate = _this$state3.translate,
296
- position = _this$state3.position;
297
- var t = translate ? "translate(".concat(translate.x, "px, ").concat(translate.y, "px)") : '';
298
- var style = {
299
- left: position.left,
300
- top: position.top,
301
- transformOrigin: origin,
302
- transform: "".concat(t, " rotate(").concat(rotation, "deg)")
303
- };
304
- return /*#__PURE__*/_react["default"].createElement(RotatableContainer, {
305
- style: style,
306
- ref: function ref(r) {
307
- return _this3.rotatable = r;
308
- },
309
- onMouseDown: this.mouseDown,
310
- onMouseUp: this.mouseUp
311
- }, anchor && showAnchor && /*#__PURE__*/_react["default"].createElement(Anchor, anchor), children);
312
- }
313
- }]);
314
- }(_react["default"].Component);
315
- (0, _defineProperty2["default"])(Rotatable, "propTypes", {
316
- children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
317
- showAnchor: _propTypes["default"].bool,
318
- handle: _propTypes["default"].arrayOf(_propTypes["default"].shape({
319
- "class": _propTypes["default"].string.isRequired,
320
- origin: _propTypes["default"].string
321
- })),
322
- startPosition: _propTypes["default"].shape({
323
- left: _propTypes["default"].number,
324
- top: _propTypes["default"].number
325
- })
326
- });
327
- (0, _defineProperty2["default"])(Rotatable, "defaultProps", {
328
- showAnchor: false,
329
- startPosition: {
330
- left: 0,
331
- top: 0
332
- }
333
- });
334
- var _default = exports["default"] = Rotatable;
335
- //# sourceMappingURL=rotatable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rotatable.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_anchorUtils","_reactPortal","_pointGeometry","_transformOrigin","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","AnchorSvg","styled","position","zIndex","width","height","Anchor","_ref","left","top","color","fill","createElement","Portal","style","cx","cy","r","strokeWidth","stroke","RotatableContainer","display","cursor","Rotatable","exports","_React$Component","props","_this","_classCallCheck2","_defineProperty2","handle","Array","isArray","handles","forEach","h","el","rotatable","querySelector","concat","mousedownHandler","rotateStart","origin","addEventListener","rotateStop","push","document","_this$rotatable","clientWidth","clientHeight","parseOrigin","rotation","state","_this$rotatable2","_this$rotatable$getBo","getBoundingClientRect","xy","originToXY","_calcAnchor","calcAnchor","anchorTop","anchorLeft","isRotating","preventDefault","anchor","getAnchor","_this$getAngle","getAngle","startAngle","angle","diff","x","y","_this$rotatable3","distanceBetween","setState","rotate","current","removeEventListener","drag","_this$state","_this$getAngle2","computedAnchor","find","target","dragStart","dragPoint","Point","pageX","pageY","translate","sub","_this$state2","lastPosition","startPosition","_inherits2","_createClass2","key","value","componentWillUnmount","_this2","componentDidMount","addMouseUpHandler","initHandles","clientX","clientY","arctangent","render","_this3","_this$props","children","showAnchor","_this$state3","transformOrigin","transform","ref","onMouseDown","mouseDown","onMouseUp","mouseUp","React","Component","PropTypes","oneOfType","arrayOf","node","isRequired","bool","shape","string","number","_default"],"sources":["../src/rotatable.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { arctangent, distanceBetween, getAnchor as calcAnchor } from './anchor-utils';\nimport { Portal } from 'react-portal';\nimport Point from '@mapbox/point-geometry';\nimport { parse as parseOrigin } from './transform-origin';\n\nconst AnchorSvg = styled('svg')({\n position: 'absolute',\n zIndex: 100,\n width: '200px',\n height: '80px',\n});\n\nconst Anchor = ({ left, top, color, fill }) => {\n color = color || 'green';\n fill = fill || 'white';\n return (\n <Portal>\n <AnchorSvg\n style={{\n left: left - 10,\n top: top - 10,\n }}\n >\n <circle cx={10} cy={10} r={8} strokeWidth={1} stroke={color} fill={fill} />\n </AnchorSvg>\n </Portal>\n );\n};\n\n/**\n * Tip o' the hat to:\n * https://bl.ocks.org/joyrexus/7207044\n */\nconst RotatableContainer = styled('div')({\n position: 'relative',\n display: 'inline-block',\n cursor: 'move',\n});\n\nexport class Rotatable extends React.Component {\n static propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n showAnchor: PropTypes.bool,\n handle: PropTypes.arrayOf(\n PropTypes.shape({\n class: PropTypes.string.isRequired,\n origin: PropTypes.string,\n }),\n ),\n startPosition: PropTypes.shape({\n left: PropTypes.number,\n top: PropTypes.number,\n }),\n };\n\n static defaultProps = {\n showAnchor: false,\n startPosition: { left: 0, top: 0 },\n };\n\n constructor(props) {\n super(props);\n this.state = {\n isRotating: false,\n rotation: 0,\n startAngle: 0,\n angle: 0,\n position: {\n left: props.startPosition.left,\n top: props.startPosition.top,\n },\n };\n }\n\n componentWillUnmount() {\n document.removeEventListener('mouseup', this.rotateStop);\n document.removeEventListener('mousemove', this.drag);\n document.removeEventListener('mousemove', this.rotate);\n\n this.handles.forEach((h) => {\n h.el.removeEventListener('mousedown', h.mousedownHandler);\n h.el.removeEventListener('mouseup', this.rotateStop);\n });\n }\n\n componentDidMount() {\n this.addMouseUpHandler();\n this.initHandles();\n }\n\n initHandles = () => {\n const { handle } = this.props;\n\n if (Array.isArray(handle)) {\n this.handles = [];\n handle.forEach((h) => {\n const el = this.rotatable.querySelector(`.${h.class}`);\n\n if (el) {\n const mousedownHandler = this.rotateStart(h.origin);\n el.addEventListener('mousedown', mousedownHandler);\n el.addEventListener('mouseup', this.rotateStop);\n this.handles.push({ el, mousedownHandler });\n }\n });\n }\n };\n\n addMouseUpHandler = () => {\n document.addEventListener('mouseup', this.rotateStop);\n };\n\n originToXY = (origin) => {\n const { clientWidth: width, clientHeight: height } = this.rotatable;\n return parseOrigin({ width, height }, origin);\n };\n\n /**\n * Get the anchor point for the given element, origin and rotation.\n * @returns {{left:number, top: number}} - the co-ordinates of the anchor point relative to the whole page.\n */\n getAnchor = (origin) => {\n const { rotation } = this.state;\n const { clientWidth, clientHeight } = this.rotatable;\n const { top, left } = this.rotatable.getBoundingClientRect();\n const xy = this.originToXY(origin);\n const { top: anchorTop, left: anchorLeft } = calcAnchor(\n {\n width: clientWidth,\n height: clientHeight,\n },\n xy,\n rotation,\n );\n\n return {\n top: top + anchorTop,\n left: left + anchorLeft,\n };\n };\n\n rotateStart = (origin) => (e) => {\n const { isRotating } = this.state;\n if (isRotating) {\n return;\n }\n\n e.preventDefault();\n\n const anchor = this.getAnchor(origin);\n const { rotation } = this.state;\n const { angle: startAngle } = this.getAngle(anchor, e);\n\n let diff = { x: 0, y: 0 };\n if (origin !== this.state.origin) {\n const { clientWidth: width, clientHeight: height } = this.rotatable;\n diff = distanceBetween({ width, height }, rotation, this.state.origin, origin);\n }\n\n this.setState(\n {\n origin,\n isRotating: true,\n startAngle,\n anchor,\n position: {\n left: this.state.position.left + diff.x,\n top: this.state.position.top + diff.y,\n },\n },\n () => {\n document.addEventListener('mousemove', this.rotate);\n },\n );\n };\n\n rotateStop = (e) => {\n const { isRotating } = this.state;\n\n if (!isRotating) {\n return;\n }\n\n e.preventDefault();\n\n this.setState(\n {\n isRotating: false,\n angle: this.state.rotation,\n anchor: null,\n current: null,\n },\n () => {\n document.removeEventListener('mousemove', this.rotate);\n document.removeEventListener('mousemove', this.drag);\n },\n );\n };\n\n getAngle(anchor, e) {\n const x = e.clientX - anchor.left;\n const y = (e.clientY - anchor.top) * -1;\n return { angle: arctangent(x, y), x, y };\n }\n\n rotate = (e) => {\n const { isRotating } = this.state;\n if (!isRotating) {\n return;\n }\n\n e.preventDefault();\n\n const { startAngle, angle, anchor } = this.state;\n const { angle: current, x, y } = this.getAngle(anchor, e);\n const computedAnchor = { x, y };\n const diff = current - startAngle;\n const rotation = angle + diff;\n this.setState({ rotation, diff, current, computedAnchor });\n };\n\n mouseDown = (e) => {\n const handle = this.handles.find((h) => h.el === e.target);\n\n if (!handle) {\n this.dragStart(e);\n }\n };\n\n dragStart = (e) => {\n const dragPoint = new Point(e.pageX, e.pageY);\n this.setState({ dragPoint }, () => {\n document.addEventListener('mousemove', this.drag);\n });\n };\n\n drag = (e) => {\n e.preventDefault();\n const current = new Point(e.pageX, e.pageY);\n const translate = current.sub(this.state.dragPoint);\n this.setState({ translate });\n };\n\n mouseUp = () => {\n if (!this.state.translate) {\n return;\n }\n\n const { position: lastPosition, translate } = this.state;\n\n const position = {\n left: lastPosition.left + translate.x,\n top: lastPosition.top + translate.y,\n };\n\n document.removeEventListener('mousemove', this.drag);\n this.setState({ position, dragPoint: null, translate: null });\n };\n\n render() {\n const { children, showAnchor } = this.props;\n const { rotation, anchor, origin, translate, position } = this.state;\n\n const t = translate ? `translate(${translate.x}px, ${translate.y}px)` : '';\n\n const style = {\n left: position.left,\n top: position.top,\n transformOrigin: origin,\n transform: `${t} rotate(${rotation}deg)`,\n };\n\n return (\n <RotatableContainer\n style={style}\n ref={(r) => (this.rotatable = r)}\n onMouseDown={this.mouseDown}\n onMouseUp={this.mouseUp}\n >\n {anchor && showAnchor && <Anchor {...anchor} />}\n {children}\n </RotatableContainer>\n );\n }\n}\n\nexport default Rotatable;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAA0D,SAAAO,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAA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AO,CAACF,qBAAS,CAACG,IAAI,CAAC,EAAEH,qBAAS,CAACG,IAAI,CAAC,CAAC,CAACC,UAAU;EAC7Ff,UAAU,EAAEW,qBAAS,CAACK,IAAI;EAC1BjG,MAAM,EAAE4F,qBAAS,CAACE,OAAO,CACvBF,qBAAS,CAACM,KAAK,CAAC;IACd,SAAON,qBAAS,CAACO,MAAM,CAACH,UAAU;IAClCpF,MAAM,EAAEgF,qBAAS,CAACO;EACpB,CAAC,CACH,CAAC;EACDnC,aAAa,EAAE4B,qBAAS,CAACM,KAAK,CAAC;IAC7BxH,IAAI,EAAEkH,qBAAS,CAACQ,MAAM;IACtBzH,GAAG,EAAEiH,qBAAS,CAACQ;EACjB,CAAC;AACH,CAAC;AAAA,IAAArG,gBAAA,aAdUN,SAAS,kBAgBE;EACpBwF,UAAU,EAAE,KAAK;EACjBjB,aAAa,EAAE;IAAEtF,IAAI,EAAE,CAAC;IAAEC,GAAG,EAAE;EAAE;AACnC,CAAC;AAAA,IAAA0H,QAAA,GAAA3G,OAAA,cAoOYD,SAAS","ignoreList":[]}
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = exports.Graphic = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _react = _interopRequireDefault(require("react"));
15
- var _propTypes = _interopRequireDefault(require("prop-types"));
16
- var _styles = require("@mui/material/styles");
17
- var _unitType = _interopRequireDefault(require("./unit-type"));
18
- var _lodashEs = require("lodash-es");
19
- var _unit = _interopRequireDefault(require("./unit"));
20
- var _styleUtils = require("../style-utils");
21
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
22
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
23
- var StyledBg = (0, _styles.styled)('rect')(function (_ref) {
24
- var theme = _ref.theme;
25
- return {
26
- stroke: (0, _styleUtils.strokeColor)(theme),
27
- strokeWidth: '2px',
28
- fill: (0, _styleUtils.fillColor)(theme)
29
- };
30
- });
31
- var Bg = function Bg(_ref2) {
32
- var width = _ref2.width,
33
- height = _ref2.height;
34
- return /*#__PURE__*/_react["default"].createElement(StyledBg, {
35
- width: width,
36
- height: height,
37
- cx: 0,
38
- cy: 0
39
- });
40
- };
41
- Bg.propTypes = {
42
- width: _propTypes["default"].number.isRequired,
43
- height: _propTypes["default"].number.isRequired
44
- };
45
- var Graphic = exports.Graphic = /*#__PURE__*/function (_React$PureComponent) {
46
- function Graphic() {
47
- (0, _classCallCheck2["default"])(this, Graphic);
48
- return _callSuper(this, Graphic, arguments);
49
- }
50
- (0, _inherits2["default"])(Graphic, _React$PureComponent);
51
- return (0, _createClass2["default"])(Graphic, [{
52
- key: "render",
53
- value: function render() {
54
- var _this$props = this.props,
55
- width = _this$props.width,
56
- height = _this$props.height,
57
- units = _this$props.units,
58
- unit = _this$props.unit;
59
- var viewBox = "0 0 ".concat(width, " ").concat(height);
60
- var unitWidth = width / units;
61
- var unitHeight = height;
62
- return /*#__PURE__*/_react["default"].createElement("svg", {
63
- viewBox: viewBox
64
- }, /*#__PURE__*/_react["default"].createElement(Bg, {
65
- width: width,
66
- height: height
67
- }), /*#__PURE__*/_react["default"].createElement(_unitType["default"], {
68
- label: unit.type
69
- }), (0, _lodashEs.range)(1, units + 1).map(function (r) {
70
- return /*#__PURE__*/_react["default"].createElement(_unit["default"], {
71
- width: unitWidth,
72
- height: unitHeight,
73
- key: r,
74
- index: r,
75
- config: unit,
76
- last: r === units
77
- });
78
- }));
79
- }
80
- }]);
81
- }(_react["default"].PureComponent);
82
- (0, _defineProperty2["default"])(Graphic, "propTypes", {
83
- width: _propTypes["default"].number.isRequired,
84
- height: _propTypes["default"].number.isRequired,
85
- units: _propTypes["default"].number.isRequired,
86
- unit: _propTypes["default"].object.isRequired
87
- });
88
- var _default = exports["default"] = Graphic;
89
- //# sourceMappingURL=graphic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graphic.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_unitType","_lodashEs","_unit","_styleUtils","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","StyledBg","styled","_ref","theme","stroke","strokeColor","strokeWidth","fill","fillColor","Bg","_ref2","width","height","createElement","cx","cy","propTypes","PropTypes","number","isRequired","Graphic","exports","_React$PureComponent","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","render","_this$props","props","units","unit","viewBox","concat","unitWidth","unitHeight","label","type","range","map","r","index","config","last","React","PureComponent","_defineProperty2","object","_default"],"sources":["../../src/ruler/graphic.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport UnitType from './unit-type';\nimport { range } from 'lodash-es';\nimport Unit from './unit';\nimport { fillColor, strokeColor } from '../style-utils';\n\nconst StyledBg = styled('rect')(({ theme }) => ({\n stroke: strokeColor(theme),\n strokeWidth: '2px',\n fill: fillColor(theme),\n}));\n\nconst Bg = ({ width, height }) => <StyledBg width={width} height={height} cx={0} cy={0} />;\n\nBg.propTypes = {\n width: PropTypes.number.isRequired,\n height: PropTypes.number.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 };\n\n render() {\n const { width, height, 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} />\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}\n\nexport default Graphic;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAAwD,SAAAO,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,aAAAH,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAG,0BAAA,cAAAL,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAV,CAAA,aAAAK,yBAAA,YAAAA,0BAAA,aAAAL,CAAA;AAExD,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/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = exports.Ruler = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
- var _react = _interopRequireDefault(require("react"));
15
- var _styles = require("@mui/material/styles");
16
- var _rotatable = _interopRequireDefault(require("../rotatable"));
17
- var _graphic = _interopRequireDefault(require("./graphic"));
18
- var _propTypes = _interopRequireDefault(require("prop-types"));
19
- var _anchor = _interopRequireDefault(require("../anchor"));
20
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
21
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
- var StyledRuler = (0, _styles.styled)('div')(function (_ref) {
23
- var theme = _ref.theme;
24
- return {
25
- cursor: 'move',
26
- position: 'relative',
27
- backgroundColor: theme.palette.secondary.light,
28
- opacity: 1.0,
29
- border: "solid 0px ".concat(theme.palette.primary.main)
30
- };
31
- });
32
- var StyledLeftAnchor = (0, _styles.styled)(_anchor["default"])(function () {
33
- return {
34
- left: '-10px',
35
- top: '40%'
36
- };
37
- });
38
- var StyledRightAnchor = (0, _styles.styled)(_anchor["default"])(function () {
39
- return {
40
- right: '-10px',
41
- top: '40%'
42
- };
43
- });
44
- var Ruler = exports.Ruler = /*#__PURE__*/function (_React$Component) {
45
- function Ruler() {
46
- (0, _classCallCheck2["default"])(this, Ruler);
47
- return _callSuper(this, Ruler, arguments);
48
- }
49
- (0, _inherits2["default"])(Ruler, _React$Component);
50
- return (0, _createClass2["default"])(Ruler, [{
51
- key: "render",
52
- value: function render() {
53
- var _this$props = this.props,
54
- width = _this$props.width,
55
- height = _this$props.height,
56
- units = _this$props.units,
57
- measure = _this$props.measure,
58
- startPosition = _this$props.startPosition,
59
- label = _this$props.label,
60
- tickCount = _this$props.tickCount;
61
- var unit = measure === 'imperial' ? {
62
- type: label,
63
- ticks: tickCount && tickCount % 4 === 0 ? tickCount : 16
64
- } : {
65
- type: label,
66
- ticks: 10
67
- };
68
- return /*#__PURE__*/_react["default"].createElement(_rotatable["default"], {
69
- startPosition: startPosition,
70
- handle: [{
71
- "class": 'leftAnchor',
72
- origin: 'bottom right'
73
- }, {
74
- "class": 'rightAnchor',
75
- origin: 'bottom left'
76
- }]
77
- }, /*#__PURE__*/_react["default"].createElement(StyledRuler, {
78
- style: {
79
- width: "".concat(width, "px"),
80
- height: "".concat(height, "px")
81
- }
82
- }, /*#__PURE__*/_react["default"].createElement(_graphic["default"], {
83
- width: width,
84
- height: height,
85
- units: units,
86
- unit: unit
87
- }), /*#__PURE__*/_react["default"].createElement(StyledLeftAnchor, {
88
- className: "leftAnchor"
89
- }), /*#__PURE__*/_react["default"].createElement(StyledRightAnchor, {
90
- className: "rightAnchor"
91
- })));
92
- }
93
- }]);
94
- }(_react["default"].Component);
95
- (0, _defineProperty2["default"])(Ruler, "propTypes", {
96
- width: _propTypes["default"].number,
97
- height: _propTypes["default"].number,
98
- units: _propTypes["default"].number.isRequired,
99
- measure: _propTypes["default"].oneOf(['imperial', 'metric']).isRequired,
100
- startPosition: _propTypes["default"].shape({
101
- left: _propTypes["default"].number.isRequired,
102
- top: _propTypes["default"].number.isRequired
103
- }),
104
- label: _propTypes["default"].string,
105
- tickCount: _propTypes["default"].number
106
- });
107
- (0, _defineProperty2["default"])(Ruler, "defaultProps", {
108
- width: 480,
109
- height: 60,
110
- measure: 'imperial',
111
- units: 12
112
- });
113
- var _default = exports["default"] = Ruler;
114
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_styles","_rotatable","_graphic","_propTypes","_anchor","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","StyledRuler","styled","_ref","theme","cursor","position","backgroundColor","palette","secondary","light","opacity","border","concat","primary","main","StyledLeftAnchor","Anchor","left","top","StyledRightAnchor","right","Ruler","exports","_React$Component","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","render","_this$props","props","width","height","units","measure","startPosition","label","tickCount","unit","type","ticks","createElement","handle","origin","style","className","React","Component","_defineProperty2","PropTypes","number","isRequired","oneOf","shape","string","_default"],"sources":["../../src/ruler/index.jsx"],"sourcesContent":["import React from 'react';\nimport { styled } from '@mui/material/styles';\nimport Rotatable from '../rotatable';\nimport RulerGraphic from './graphic';\nimport PropTypes from 'prop-types';\nimport Anchor from '../anchor';\n\nconst StyledRuler = styled('div')(({ theme }) => ({\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\nconst StyledLeftAnchor = styled(Anchor)(() => ({\n left: '-10px',\n top: '40%',\n}));\n\nconst StyledRightAnchor = styled(Anchor)(() => ({\n right: '-10px',\n top: '40%',\n}));\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 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 { width, height, units, measure, 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 startPosition={startPosition}\n handle={[\n { class: 'leftAnchor', origin: 'bottom right' },\n { class: 'rightAnchor', origin: 'bottom left' },\n ]}\n >\n <StyledRuler style={{ width: `${width}px`, height: `${height}px` }}>\n <RulerGraphic width={width} height={height} units={units} unit={unit} />\n <StyledLeftAnchor className=\"leftAnchor\" />\n <StyledRightAnchor className=\"rightAnchor\" />\n </StyledRuler>\n </Rotatable>\n );\n }\n}\n\nexport default Ruler;\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AAA+B,SAAAM,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,aAAAF,CAAA,OAAAG,2BAAA,aAAAJ,CAAA,EAAAK,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,aAAAH,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAG,0BAAA,cAAAL,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAV,CAA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