@pie-lib/tools 2.0.3-next.0 → 2.0.3-next.57

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/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +626 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/anchor-utils.js +193 -0
  5. package/lib/anchor-utils.js.map +1 -0
  6. package/lib/anchor.js +33 -0
  7. package/lib/anchor.js.map +1 -0
  8. package/lib/index.js +33 -0
  9. package/lib/index.js.map +1 -0
  10. package/lib/protractor/graphic.js +147 -0
  11. package/lib/protractor/graphic.js.map +1 -0
  12. package/lib/protractor/index.js +90 -0
  13. package/lib/protractor/index.js.map +1 -0
  14. package/lib/rotatable.js +335 -0
  15. package/lib/rotatable.js.map +1 -0
  16. package/lib/ruler/graphic.js +89 -0
  17. package/lib/ruler/graphic.js.map +1 -0
  18. package/lib/ruler/index.js +114 -0
  19. package/lib/ruler/index.js.map +1 -0
  20. package/lib/ruler/unit-type.js +55 -0
  21. package/lib/ruler/unit-type.js.map +1 -0
  22. package/lib/ruler/unit.js +124 -0
  23. package/lib/ruler/unit.js.map +1 -0
  24. package/lib/style-utils.js +21 -0
  25. package/lib/style-utils.js.map +1 -0
  26. package/lib/transform-origin.js +71 -0
  27. package/lib/transform-origin.js.map +1 -0
  28. package/package.json +26 -32
  29. package/src/__tests__/anchor-utils.test.js +131 -0
  30. package/src/__tests__/rotatable.test.jsx +263 -0
  31. package/src/__tests__/transform-origin.test.jsx +24 -0
  32. package/src/anchor-utils.js +153 -0
  33. package/src/anchor.jsx +20 -0
  34. package/src/index.js +6 -0
  35. package/src/protractor/__tests__/graphic.test.jsx +64 -0
  36. package/src/protractor/__tests__/index.test.jsx +65 -0
  37. package/src/protractor/graphic.jsx +82 -0
  38. package/src/protractor/index.jsx +67 -0
  39. package/src/rotatable.jsx +290 -0
  40. package/src/ruler/__tests__/graphic.test.jsx +64 -0
  41. package/src/ruler/__tests__/index.test.jsx +85 -0
  42. package/src/ruler/__tests__/unit-type.test.jsx +66 -0
  43. package/src/ruler/__tests__/unit.test.jsx +68 -0
  44. package/src/ruler/graphic.jsx +48 -0
  45. package/src/ruler/index.jsx +78 -0
  46. package/src/ruler/unit-type.jsx +39 -0
  47. package/src/ruler/unit.jsx +83 -0
  48. package/src/style-utils.js +7 -0
  49. package/src/transform-origin.jsx +60 -0
  50. package/dist/_virtual/_rolldown/runtime.js +0 -11
  51. package/dist/anchor-utils.d.ts +0 -60
  52. package/dist/anchor-utils.js +0 -87
  53. package/dist/anchor.d.ts +0 -13
  54. package/dist/anchor.js +0 -17
  55. package/dist/index.d.ts +0 -13
  56. package/dist/index.js +0 -5
  57. package/dist/node_modules/.bun/assert@1.5.1/node_modules/assert/assert.js +0 -174
  58. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js +0 -13
  59. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js +0 -8
  60. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js +0 -8
  61. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js +0 -16
  62. package/dist/node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js +0 -8
  63. package/dist/node_modules/.bun/call-bound@1.0.4/node_modules/call-bound/index.js +0 -14
  64. package/dist/node_modules/.bun/degrees-radians@1.0.3/node_modules/degrees-radians/index.js +0 -12
  65. package/dist/node_modules/.bun/dunder-proto@1.0.1/node_modules/dunder-proto/get.js +0 -19
  66. package/dist/node_modules/.bun/es-define-property@1.0.1/node_modules/es-define-property/index.js +0 -14
  67. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/eval.js +0 -8
  68. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/index.js +0 -8
  69. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/range.js +0 -8
  70. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/ref.js +0 -8
  71. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/syntax.js +0 -8
  72. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/type.js +0 -8
  73. package/dist/node_modules/.bun/es-errors@1.3.0/node_modules/es-errors/uri.js +0 -8
  74. package/dist/node_modules/.bun/es-object-atoms@1.1.2/node_modules/es-object-atoms/index.js +0 -8
  75. package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/implementation.js +0 -34
  76. package/dist/node_modules/.bun/function-bind@1.1.2/node_modules/function-bind/index.js +0 -10
  77. package/dist/node_modules/.bun/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js +0 -283
  78. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js +0 -9
  79. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -8
  80. package/dist/node_modules/.bun/get-proto@1.0.1/node_modules/get-proto/index.js +0 -19
  81. package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/gOPD.js +0 -8
  82. package/dist/node_modules/.bun/gopd@1.2.0/node_modules/gopd/index.js +0 -15
  83. package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/index.js +0 -12
  84. package/dist/node_modules/.bun/has-symbols@1.1.0/node_modules/has-symbols/shams.js +0 -23
  85. package/dist/node_modules/.bun/hasown@2.0.4/node_modules/hasown/index.js +0 -10
  86. package/dist/node_modules/.bun/inherits@2.0.3/node_modules/inherits/inherits_browser.js +0 -19
  87. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js +0 -8
  88. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js +0 -8
  89. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js +0 -10
  90. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js +0 -8
  91. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js +0 -8
  92. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js +0 -8
  93. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js +0 -8
  94. package/dist/node_modules/.bun/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js +0 -12
  95. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/implementation.js +0 -77
  96. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/index.js +0 -20
  97. package/dist/node_modules/.bun/object-keys@1.1.1/node_modules/object-keys/isArguments.js +0 -12
  98. package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/implementation.js +0 -29
  99. package/dist/node_modules/.bun/object.assign@4.1.7/node_modules/object.assign/polyfill.js +0 -27
  100. package/dist/node_modules/.bun/radians-degrees@1.0.0/node_modules/radians-degrees/index.js +0 -11
  101. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/LegacyPortal.js +0 -77
  102. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/Portal.js +0 -55
  103. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/PortalCompat.js +0 -9
  104. package/dist/node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/utils.js +0 -4
  105. package/dist/node_modules/.bun/trigonometry-calculator@2.0.0/node_modules/trigonometry-calculator/lib/index.js +0 -53
  106. package/dist/node_modules/.bun/trigonometry-equations@2.0.1/node_modules/trigonometry-equations/lib/index.js +0 -129
  107. package/dist/node_modules/.bun/util@0.10.4/node_modules/util/support/isBufferBrowser.js +0 -10
  108. package/dist/node_modules/.bun/util@0.10.4/node_modules/util/util.js +0 -262
  109. package/dist/protractor/graphic.d.ts +0 -13
  110. package/dist/protractor/graphic.js +0 -85
  111. package/dist/protractor/index.d.ts +0 -29
  112. package/dist/protractor/index.js +0 -56
  113. package/dist/rotatable.d.ts +0 -56
  114. package/dist/rotatable.js +0 -210
  115. package/dist/ruler/graphic.d.ts +0 -20
  116. package/dist/ruler/graphic.js +0 -53
  117. package/dist/ruler/index.d.ts +0 -32
  118. package/dist/ruler/index.js +0 -77
  119. package/dist/ruler/unit-type.d.ts +0 -30
  120. package/dist/ruler/unit-type.js +0 -38
  121. package/dist/ruler/unit.d.ts +0 -21
  122. package/dist/ruler/unit.js +0 -69
  123. package/dist/style-utils.d.ts +0 -12
  124. package/dist/style-utils.js +0 -5
  125. package/dist/transform-origin.d.ts +0 -18
  126. package/dist/transform-origin.js +0 -21
@@ -0,0 +1,78 @@
1
+ import React from 'react';
2
+ import { styled } from '@mui/material/styles';
3
+ import Rotatable from '../rotatable';
4
+ import RulerGraphic from './graphic';
5
+ import PropTypes from 'prop-types';
6
+ import Anchor from '../anchor';
7
+
8
+ const StyledRuler = styled('div')(({ theme }) => ({
9
+ cursor: 'move',
10
+ position: 'relative',
11
+ backgroundColor: theme.palette.secondary.light,
12
+ opacity: 1.0,
13
+ border: `solid 0px ${theme.palette.primary.main}`,
14
+ }));
15
+
16
+ const StyledLeftAnchor = styled(Anchor)(() => ({
17
+ left: '-10px',
18
+ top: '40%',
19
+ }));
20
+
21
+ const StyledRightAnchor = styled(Anchor)(() => ({
22
+ right: '-10px',
23
+ top: '40%',
24
+ }));
25
+
26
+ export class Ruler extends React.Component {
27
+ static propTypes = {
28
+ width: PropTypes.number,
29
+ height: PropTypes.number,
30
+ units: PropTypes.number.isRequired,
31
+ measure: PropTypes.oneOf(['imperial', 'metric']).isRequired,
32
+ startPosition: PropTypes.shape({
33
+ left: PropTypes.number.isRequired,
34
+ top: PropTypes.number.isRequired,
35
+ }),
36
+ label: PropTypes.string,
37
+ tickCount: PropTypes.number,
38
+ };
39
+
40
+ static defaultProps = {
41
+ width: 480,
42
+ height: 60,
43
+ measure: 'imperial',
44
+ units: 12,
45
+ };
46
+
47
+ render() {
48
+ const { width, height, units, measure, startPosition, label, tickCount } = this.props;
49
+
50
+ const unit =
51
+ measure === 'imperial'
52
+ ? {
53
+ type: label,
54
+ ticks: tickCount && tickCount % 4 === 0 ? tickCount : 16,
55
+ }
56
+ : {
57
+ type: label,
58
+ ticks: 10,
59
+ };
60
+ return (
61
+ <Rotatable
62
+ startPosition={startPosition}
63
+ handle={[
64
+ { class: 'leftAnchor', origin: 'bottom right' },
65
+ { class: 'rightAnchor', origin: 'bottom left' },
66
+ ]}
67
+ >
68
+ <StyledRuler style={{ width: `${width}px`, height: `${height}px` }}>
69
+ <RulerGraphic width={width} height={height} units={units} unit={unit} />
70
+ <StyledLeftAnchor className="leftAnchor" />
71
+ <StyledRightAnchor className="rightAnchor" />
72
+ </StyledRuler>
73
+ </Rotatable>
74
+ );
75
+ }
76
+ }
77
+
78
+ export default Ruler;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { noSelect, strokeColor } from '../style-utils';
4
+ import { styled } from '@mui/material/styles';
5
+
6
+ const StyledText = styled('text')(({ theme }) => ({
7
+ ...noSelect(),
8
+ fill: strokeColor(theme),
9
+ }));
10
+
11
+ export const UnitType = (props) => {
12
+ const { label, x, y, textAlign, fill, fontSize, stroke } = props;
13
+
14
+ return (
15
+ <StyledText x={x} y={y} textAnchor={textAlign} stroke={stroke} fill={fill} fontSize={fontSize}>
16
+ {label}
17
+ </StyledText>
18
+ );
19
+ };
20
+
21
+ UnitType.propTypes = {
22
+ label: PropTypes.string.isRequired,
23
+ x: PropTypes.number,
24
+ y: PropTypes.number,
25
+ textAlign: PropTypes.string,
26
+ fill: PropTypes.string,
27
+ fontSize: PropTypes.number,
28
+ stroke: PropTypes.string,
29
+ };
30
+
31
+ UnitType.defaultProps = {
32
+ textAnchor: 'start',
33
+ fontSize: 11,
34
+ stroke: 'none',
35
+ x: 8,
36
+ y: 14,
37
+ };
38
+
39
+ export default UnitType;
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
4
+ import { noSelect, strokeColor } from '../style-utils';
5
+ import { range } from 'lodash-es';
6
+
7
+ const StyledTick = styled('line')(({ theme }) => ({
8
+ stroke: strokeColor(theme),
9
+ }));
10
+
11
+ const Tick = ({ x, height, bottom, major, minor }) => {
12
+ const y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;
13
+
14
+ return <StyledTick y1={y1} y2={bottom} x1={x} x2={x} />;
15
+ };
16
+
17
+ const Ticks = ({ count, width, height }) => {
18
+ return (
19
+ <React.Fragment>
20
+ {range(1, count).map((r) => {
21
+ return (
22
+ <Tick
23
+ key={r}
24
+ value={r}
25
+ x={r * (width / count)}
26
+ major={r % (count / 2) === 0}
27
+ minor={r % (count / 4) === 0}
28
+ bottom={height}
29
+ height={10}
30
+ />
31
+ );
32
+ })}
33
+ </React.Fragment>
34
+ );
35
+ };
36
+
37
+ Ticks.propTypes = {
38
+ count: PropTypes.number.isRequired,
39
+ width: PropTypes.number.isRequired,
40
+ height: PropTypes.number.isRequired,
41
+ };
42
+
43
+ const StyledEndTick = styled('line')(({ theme }) => ({
44
+ stroke: strokeColor(theme),
45
+ strokeWidth: 1,
46
+ }));
47
+
48
+ const StyledLabel = styled('text')(({ theme }) => ({
49
+ textAnchor: 'end',
50
+ fontSize: '12px',
51
+ fill: strokeColor(theme),
52
+ ...noSelect(),
53
+ }));
54
+
55
+ export class Unit extends React.Component {
56
+ static propTypes = {
57
+ index: PropTypes.number.isRequired,
58
+ width: PropTypes.number.isRequired,
59
+ height: PropTypes.number.isRequired,
60
+ last: PropTypes.bool.isRequired,
61
+ config: PropTypes.object.isRequired,
62
+ };
63
+
64
+ render() {
65
+ const { index, width, height, last, config } = this.props;
66
+
67
+ const style = {
68
+ transform: `translate(${width * (index - 1)}px, 0px)`,
69
+ };
70
+ return (
71
+ <g style={style}>
72
+ {!last && <StyledEndTick x1={width} y1={0} x2={width} y2={height} />}
73
+
74
+ <Ticks count={config.ticks} width={width} height={height} />
75
+ <StyledLabel width={width} x={width - 5} y={15}>
76
+ {index}
77
+ </StyledLabel>
78
+ </g>
79
+ );
80
+ }
81
+ }
82
+
83
+ export default Unit;
@@ -0,0 +1,7 @@
1
+ import { noSelect } from '@pie-lib/style-utils';
2
+
3
+ export { noSelect };
4
+
5
+ export const strokeColor = (theme) => `var(--ruler-stroke, ${theme.palette.primary.main})`;
6
+
7
+ export const fillColor = (theme) => `var(--ruler-bg, ${theme.palette.primary.contrastText})`;
@@ -0,0 +1,60 @@
1
+ const keyWordToPercent = (v) => {
2
+ if (v === 'left' || v === 'top') {
3
+ return 0;
4
+ } else if (v === 'right' || v === 'bottom') {
5
+ return 100;
6
+ } else if (v === 'center') {
7
+ return 50;
8
+ } else if (v.endsWith('%')) {
9
+ return parseFloat(v);
10
+ } else {
11
+ return v;
12
+ }
13
+ };
14
+
15
+ const getValue = (s, length) => {
16
+ if (s.endsWith('px')) {
17
+ return parseFloat(s);
18
+ } else {
19
+ s = keyWordToPercent(s);
20
+ const v = length * (s / 100);
21
+ return v;
22
+ }
23
+ };
24
+
25
+ const normalize = (a) => {
26
+ if (a[0] === 'bottom' || a[0] === 'top' || a[1] === 'left' || a[1] === 'right') {
27
+ return [a[1], a[0]];
28
+ } else {
29
+ return a;
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Parse a transform origin string to x/y values.
35
+ * @param {{width: number, height: number}} rect
36
+ * @param {string} value
37
+ * @returns {x:number, y:number}
38
+ */
39
+ export const parse = (rect, value) => {
40
+ if (!value) {
41
+ return {
42
+ x: rect.width / 2,
43
+ y: rect.height / 2,
44
+ };
45
+ }
46
+ const arr = value.split(' ');
47
+ if (arr.length === 1) {
48
+ //1 val
49
+ const x = getValue(arr[0], rect.width);
50
+ const y = getValue('50%', rect.height);
51
+ return { x, y };
52
+ } else if (arr.length === 2) {
53
+ const sorted = normalize(arr);
54
+ const x = getValue(sorted[0], rect.width);
55
+ const y = getValue(sorted[1], rect.height);
56
+ return { x, y };
57
+ } else if (arr.length === 3) {
58
+ throw new Error('transform-origin values with 3 fields not supported.');
59
+ }
60
+ };
@@ -1,11 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = Object.defineProperty, t = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), n = (t, n) => {
3
- let r = {};
4
- for (var i in t) e(r, i, {
5
- get: t[i],
6
- enumerable: !0
7
- });
8
- return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
- };
10
- //#endregion
11
- export { t as __commonJSMin, n as __exportAll };
@@ -1,60 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/anchor-utils.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import Point from '@mapbox/point-geometry';
10
- export declare const toDegrees: (radians: any) => number;
11
- export declare const toRadians: (degrees: any) => number;
12
- export declare const normalizeAngle: (a: any) => any;
13
- export declare const toPoint: (rect: any, edge: any) => Point;
14
- /**
15
- * Get the distance between to anchor points in a rect.
16
- * @param {{width: number, height: number}} rect - the rect
17
- * @param {number} degrees - the degrees
18
- * @param {string} from - from anchor
19
- * @param {string} to - to anchor
20
- * @returns {Point} point - the distance as a Point
21
- */
22
- export declare const distanceBetween: (rect: any, degrees: any, from: any, to: any) => Point;
23
- /**
24
- * For a corner string, a point and a rect, return a relative x,y from that point to a corner.
25
- * Note that the y value descends as it goes down (unlike for a screen's y value), so this is only really useful for math functions.
26
- * @example
27
- * ```
28
- * getXAndY('top-left', {width: 100, height: 100}, 10, 10) //=> {x:10, y: -90}
29
- * ```
30
- * @param {*} corner
31
- * @param {*} rect
32
- * @param {*} point
33
- */
34
- export declare const getXAndY: (corner: any, rect: any, point: any) => {
35
- x: number;
36
- y: any;
37
- } | undefined;
38
- export declare const arctangent: (x: any, y: any) => number;
39
- export declare const getAngleAndHypotenuse: (corner: any, rect: any, point: any) => {
40
- x: any;
41
- y: any;
42
- degrees: number;
43
- hypotenuse: number;
44
- };
45
- export declare const getTop: (rect: any, point: any, angle: any) => any;
46
- export declare const getLeft: (rect: any, point: any, angle: any) => any;
47
- /**
48
- * Calculate the position of an anchor within a bounding rect, if the source rect has been rotated by an angle.
49
- * It does this by finding the appropriate corner of the src rect, that touches the bounding rect, calculates
50
- * the hypotenuse (h) of that anchor to that point. Then using that plus the rotation it calculates
51
- * the sides of the triangle and returns the length of the side that touches the bounding rect.
52
- * @param {{width: number, height: number}} rect - the rect which contains the point
53
- * @param {{x:number, y: number}} point - the point within the rect
54
- * @param {number} angle - the angle in degrees that the rect has rotated.
55
- * @returns {{left: number, top: number}} position
56
- */
57
- export declare const getAnchor: (rect: any, point: any, angle: any) => {
58
- top: any;
59
- left: any;
60
- };
@@ -1,87 +0,0 @@
1
- import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
2
- import { require_lib as t } from "./node_modules/.bun/trigonometry-calculator@2.0.0/node_modules/trigonometry-calculator/lib/index.js";
3
- import { parse as n } from "./transform-origin.js";
4
- import r from "@mapbox/point-geometry";
5
- import i from "debug";
6
- //#region src/anchor-utils.ts
7
- var a = /* @__PURE__ */ e({
8
- arctangent: () => m,
9
- distanceBetween: () => f,
10
- getAnchor: () => y,
11
- getAngleAndHypotenuse: () => h,
12
- getLeft: () => v,
13
- getTop: () => _,
14
- getXAndY: () => p,
15
- normalizeAngle: () => u,
16
- toDegrees: () => c,
17
- toPoint: () => d,
18
- toRadians: () => l
19
- }), o = t(), s = i("@pie-lib:tools:anchor-utils"), c = (e) => 180 / Math.PI * e, l = (e) => Math.PI / 180 * e, u = (e) => e > 360 ? e % 360 : e < 0 ? 360 + e % 360 : e, d = (e, t) => {
20
- let i = n(e, t);
21
- return new r(i.x, i.y);
22
- }, f = (e, t, n, i) => {
23
- let a = new r(e.width / 2, e.height / 2), o = l(t), s = a.rotateAround(o, d(e, n)), c = a.rotateAround(o, d(e, i));
24
- return s.sub(c);
25
- }, p = (e, t, n) => {
26
- if (e === "top-left") return {
27
- x: n.x * -1,
28
- y: n.y
29
- };
30
- if (e === "bottom-left") return {
31
- x: n.x * -1,
32
- y: n.y - t.height
33
- };
34
- if (e === "top-right") return {
35
- x: t.width - n.x,
36
- y: n.y
37
- };
38
- if (e === "bottom-right") return {
39
- x: t.width - n.x,
40
- y: n.y - t.height
41
- };
42
- }, m = (e, t) => c(Math.atan2(e, t)), h = (e, t, n) => {
43
- let { x: r, y: i } = p(e, t, n);
44
- return {
45
- x: r,
46
- y: i,
47
- degrees: m(r, i),
48
- hypotenuse: Math.sqrt(r ** 2 + i ** 2)
49
- };
50
- }, g = (e, t, n, r, i) => {
51
- if (r === 0) return e === "left" ? n.x : n.y;
52
- let a = b(r)[e], { degrees: s, hypotenuse: c } = h(a, t, n), l = i(s);
53
- return l === 0 ? c : (0, o.trigCalculator)({
54
- angles: {
55
- 0: l,
56
- 1: 90
57
- },
58
- sides: { 1: c }
59
- }).sides[2];
60
- }, _ = (e, t, n) => g("top", e, t, n, (e) => Math.abs(n + e)), v = (e, t, n) => g("left", e, t, n, (e) => Math.abs(n + e + 90)), y = (e, t, n) => {
61
- if (s("[getAnchor] rect: ", e, "point:", t, "angle: ", n), t.x > e.width) throw Error(`x: ${t.x} cannot be greater than width: ${e.width}`);
62
- if (t.y > e.height) throw Error(`y: ${t.y} cannot be greater than height: ${e.height}`);
63
- let r = u(n), i = _(e, t, r), a = v(e, t, r);
64
- return s("[getAnchor] top: ", i, "left: ", a), {
65
- top: i,
66
- left: a
67
- };
68
- }, b = (e) => {
69
- if (e <= 90) return {
70
- top: "top-left",
71
- left: "bottom-left"
72
- };
73
- if (e > 90 && e <= 180) return {
74
- top: "bottom-left",
75
- left: "bottom-right"
76
- };
77
- if (e > 180 && e <= 270) return {
78
- top: "bottom-right",
79
- left: "top-right"
80
- };
81
- if (e > 270 && e < 360) return {
82
- top: "top-right",
83
- left: "top-left"
84
- };
85
- };
86
- //#endregion
87
- export { a as anchor_utils_exports, m as arctangent, f as distanceBetween, y as getAnchor };
package/dist/anchor.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/anchor.jsx
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import React from 'react';
10
- declare const Anchor: ({ ...props }: {
11
- [x: string]: any;
12
- }) => React.JSX.Element;
13
- export default Anchor;
package/dist/anchor.js DELETED
@@ -1,17 +0,0 @@
1
- import "react";
2
- import { styled as e } from "@mui/material/styles";
3
- import { jsx as t } from "react/jsx-runtime";
4
- //#region src/anchor.tsx
5
- var n = e("div")(({ theme: e }) => ({
6
- cursor: "pointer",
7
- width: "20px",
8
- height: "20px",
9
- position: "absolute",
10
- borderRadius: "10px",
11
- backgroundColor: `var(--ruler-bg, ${e.palette.primary.contrastText})`,
12
- transition: "background-color 200ms ease-in",
13
- border: `solid 1px var(--ruler-stroke, ${e.palette.primary.dark})`,
14
- "&:hover": { backgroundColor: `var(--ruler-bg-hover, ${e.palette.primary.light})` }
15
- })), r = ({ ...e }) => /* @__PURE__ */ t(n, { ...e });
16
- //#endregion
17
- export { r as default };
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/index.js
3
- * @auto-generated
4
- *
5
- * This file is automatically synced from pie-elements and converted to TypeScript.
6
- * Manual edits will be overwritten on next sync.
7
- * To make changes, edit the upstream JavaScript file and run sync again.
8
- */
9
- import Protractor from './protractor/index.js';
10
- import Ruler from './ruler/index.js';
11
- import Rotatable from './rotatable.js';
12
- import * as utils from './anchor-utils.js';
13
- export { Protractor, Ruler, Rotatable, utils };
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { anchor_utils_exports as e } from "./anchor-utils.js";
2
- import t from "./rotatable.js";
3
- import n from "./protractor/index.js";
4
- import r from "./ruler/index.js";
5
- export { n as Protractor, t as Rotatable, r as Ruler, e as utils };
@@ -1,174 +0,0 @@
1
- import { __commonJSMin as e } from "../../../../../_virtual/_rolldown/runtime.js";
2
- import { require_polyfill as t } from "../../../object.assign@4.1.7/node_modules/object.assign/polyfill.js";
3
- import { require_util as n } from "../../../util@0.10.4/node_modules/util/util.js";
4
- //#region ../../../node_modules/.bun/assert@1.5.1/node_modules/assert/assert.js
5
- var r = /* @__PURE__ */ e(((e, r) => {
6
- var i = t()();
7
- function a(e, t) {
8
- if (e === t) return 0;
9
- for (var n = e.length, r = t.length, i = 0, a = Math.min(n, r); i < a; ++i) if (e[i] !== t[i]) {
10
- n = e[i], r = t[i];
11
- break;
12
- }
13
- return n < r ? -1 : +(r < n);
14
- }
15
- function o(e) {
16
- return global.Buffer && typeof global.Buffer.isBuffer == "function" ? global.Buffer.isBuffer(e) : !!(e != null && e._isBuffer);
17
- }
18
- var s = n(), c = Object.prototype.hasOwnProperty, l = Array.prototype.slice, u = function() {
19
- return function() {}.name === "foo";
20
- }();
21
- function d(e) {
22
- return Object.prototype.toString.call(e);
23
- }
24
- function f(e) {
25
- return o(e) || typeof global.ArrayBuffer != "function" ? !1 : typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e ? !!(e instanceof DataView || e.buffer && e.buffer instanceof ArrayBuffer) : !1;
26
- }
27
- var p = r.exports = b, m = /\s*function\s+([^\(\s]*)\s*/;
28
- function h(e) {
29
- if (s.isFunction(e)) {
30
- if (u) return e.name;
31
- var t = e.toString().match(m);
32
- return t && t[1];
33
- }
34
- }
35
- p.AssertionError = function(e) {
36
- this.name = "AssertionError", this.actual = e.actual, this.expected = e.expected, this.operator = e.operator, e.message ? (this.message = e.message, this.generatedMessage = !1) : (this.message = v(this), this.generatedMessage = !0);
37
- var t = e.stackStartFunction || y;
38
- if (Error.captureStackTrace) Error.captureStackTrace(this, t);
39
- else {
40
- var n = /* @__PURE__ */ Error();
41
- if (n.stack) {
42
- var r = n.stack, i = h(t), a = r.indexOf("\n" + i);
43
- if (a >= 0) {
44
- var o = r.indexOf("\n", a + 1);
45
- r = r.substring(o + 1);
46
- }
47
- this.stack = r;
48
- }
49
- }
50
- }, s.inherits(p.AssertionError, Error);
51
- function g(e, t) {
52
- return typeof e == "string" ? e.length < t ? e : e.slice(0, t) : e;
53
- }
54
- function _(e) {
55
- if (u || !s.isFunction(e)) return s.inspect(e);
56
- var t = h(e);
57
- return "[Function" + (t ? ": " + t : "") + "]";
58
- }
59
- function v(e) {
60
- return g(_(e.actual), 128) + " " + e.operator + " " + g(_(e.expected), 128);
61
- }
62
- function y(e, t, n, r, i) {
63
- throw new p.AssertionError({
64
- message: n,
65
- actual: e,
66
- expected: t,
67
- operator: r,
68
- stackStartFunction: i
69
- });
70
- }
71
- p.fail = y;
72
- function b(e, t) {
73
- e || y(e, !0, t, "==", p.ok);
74
- }
75
- p.ok = b, p.equal = function(e, t, n) {
76
- e != t && y(e, t, n, "==", p.equal);
77
- }, p.notEqual = function(e, t, n) {
78
- e == t && y(e, t, n, "!=", p.notEqual);
79
- }, p.deepEqual = function(e, t, n) {
80
- x(e, t, !1) || y(e, t, n, "deepEqual", p.deepEqual);
81
- }, p.deepStrictEqual = function(e, t, n) {
82
- x(e, t, !0) || y(e, t, n, "deepStrictEqual", p.deepStrictEqual);
83
- };
84
- function x(e, t, n, r) {
85
- if (e === t) return !0;
86
- if (o(e) && o(t)) return a(e, t) === 0;
87
- if (s.isDate(e) && s.isDate(t)) return e.getTime() === t.getTime();
88
- if (s.isRegExp(e) && s.isRegExp(t)) return e.source === t.source && e.global === t.global && e.multiline === t.multiline && e.lastIndex === t.lastIndex && e.ignoreCase === t.ignoreCase;
89
- if ((typeof e != "object" || !e) && (typeof t != "object" || !t)) return n ? e === t : e == t;
90
- if (f(e) && f(t) && d(e) === d(t) && !(e instanceof Float32Array || e instanceof Float64Array)) return a(new Uint8Array(e.buffer), new Uint8Array(t.buffer)) === 0;
91
- if (o(e) !== o(t)) return !1;
92
- r ||= {
93
- actual: [],
94
- expected: []
95
- };
96
- var i = r.actual.indexOf(e);
97
- return i !== -1 && i === r.expected.indexOf(t) ? !0 : (r.actual.push(e), r.expected.push(t), C(e, t, n, r));
98
- }
99
- function S(e) {
100
- return Object.prototype.toString.call(e) == "[object Arguments]";
101
- }
102
- function C(e, t, n, r) {
103
- if (e == null || t == null) return !1;
104
- if (s.isPrimitive(e) || s.isPrimitive(t)) return e === t;
105
- if (n && Object.getPrototypeOf(e) !== Object.getPrototypeOf(t)) return !1;
106
- var i = S(e), a = S(t);
107
- if (i && !a || !i && a) return !1;
108
- if (i) return e = l.call(e), t = l.call(t), x(e, t, n);
109
- var o = k(e), c = k(t), u, d;
110
- if (o.length !== c.length) return !1;
111
- for (o.sort(), c.sort(), d = o.length - 1; d >= 0; d--) if (o[d] !== c[d]) return !1;
112
- for (d = o.length - 1; d >= 0; d--) if (u = o[d], !x(e[u], t[u], n, r)) return !1;
113
- return !0;
114
- }
115
- p.notDeepEqual = function(e, t, n) {
116
- x(e, t, !1) && y(e, t, n, "notDeepEqual", p.notDeepEqual);
117
- }, p.notDeepStrictEqual = w;
118
- function w(e, t, n) {
119
- x(e, t, !0) && y(e, t, n, "notDeepStrictEqual", w);
120
- }
121
- p.strictEqual = function(e, t, n) {
122
- e !== t && y(e, t, n, "===", p.strictEqual);
123
- }, p.notStrictEqual = function(e, t, n) {
124
- e === t && y(e, t, n, "!==", p.notStrictEqual);
125
- };
126
- function T(e, t) {
127
- if (!e || !t) return !1;
128
- if (Object.prototype.toString.call(t) == "[object RegExp]") return t.test(e);
129
- try {
130
- if (e instanceof t) return !0;
131
- } catch {}
132
- return Error.isPrototypeOf(t) ? !1 : t.call({}, e) === !0;
133
- }
134
- function E(e) {
135
- var t;
136
- try {
137
- e();
138
- } catch (e) {
139
- t = e;
140
- }
141
- return t;
142
- }
143
- function D(e, t, n, r) {
144
- var i;
145
- if (typeof t != "function") throw TypeError("\"block\" argument must be a function");
146
- typeof n == "string" && (r = n, n = null), i = E(t), r = (n && n.name ? " (" + n.name + ")." : ".") + (r ? " " + r : "."), e && !i && y(i, n, "Missing expected exception" + r);
147
- var a = typeof r == "string", o = !e && s.isError(i), c = !e && i && !n;
148
- if ((o && a && T(i, n) || c) && y(i, n, "Got unwanted exception" + r), e && i && n && !T(i, n) || !e && i) throw i;
149
- }
150
- p.throws = function(e, t, n) {
151
- D(!0, e, t, n);
152
- }, p.doesNotThrow = function(e, t, n) {
153
- D(!1, e, t, n);
154
- }, p.ifError = function(e) {
155
- if (e) throw e;
156
- };
157
- function O(e, t) {
158
- e || y(e, !0, t, "==", O);
159
- }
160
- p.strict = i(O, p, {
161
- equal: p.strictEqual,
162
- deepEqual: p.deepStrictEqual,
163
- notEqual: p.notStrictEqual,
164
- notDeepEqual: p.notDeepStrictEqual
165
- }), p.strict.strict = p.strict;
166
- var k = Object.keys || function(e) {
167
- var t = [];
168
- for (var n in e) c.call(e, n) && t.push(n);
169
- return t;
170
- };
171
- }));
172
- //#endregion
173
- export default r();
174
- export { r as require_assert };
@@ -1,13 +0,0 @@
1
- import { __commonJSMin as e } from "../../../../../_virtual/_rolldown/runtime.js";
2
- import { require_function_bind as t } from "../../../function-bind@1.1.2/node_modules/function-bind/index.js";
3
- import { require_functionCall as n } from "./functionCall.js";
4
- import { require_functionApply as r } from "./functionApply.js";
5
- import { require_reflectApply as i } from "./reflectApply.js";
6
- //#region ../../../node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js
7
- var a = /* @__PURE__ */ e(((e, a) => {
8
- var o = t(), s = r(), c = n();
9
- a.exports = i() || o.call(c, s);
10
- }));
11
- //#endregion
12
- export default a();
13
- export { a as require_actualApply };
@@ -1,8 +0,0 @@
1
- import { __commonJSMin as e } from "../../../../../_virtual/_rolldown/runtime.js";
2
- //#region ../../../node_modules/.bun/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js
3
- var t = /* @__PURE__ */ e(((e, t) => {
4
- t.exports = Function.prototype.apply;
5
- }));
6
- //#endregion
7
- export default t();
8
- export { t as require_functionApply };