@pie-lib/tools 2.0.2-next.1 → 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 -622
  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
@@ -1,78 +0,0 @@
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;
@@ -1,39 +0,0 @@
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;
@@ -1,83 +0,0 @@
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;
@@ -1,7 +0,0 @@
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})`;
@@ -1,60 +0,0 @@
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
- };