@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
package/dist/rotatable.js DELETED
@@ -1,210 +0,0 @@
1
- import { parse as e } from "./transform-origin.js";
2
- import { arctangent as t, distanceBetween as n, getAnchor as r } from "./anchor-utils.js";
3
- import i from "./node_modules/.bun/react-portal@4.3.0_6dbf9a050bc9aadb/node_modules/react-portal/es/PortalCompat.js";
4
- import a from "react";
5
- import { styled as o } from "@mui/material/styles";
6
- import s from "prop-types";
7
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
- import u from "@mapbox/point-geometry";
9
- //#region src/rotatable.tsx
10
- var d = o("svg")({
11
- position: "absolute",
12
- zIndex: 100,
13
- width: "200px",
14
- height: "80px"
15
- }), f = ({ left: e, top: t, color: n, fill: r }) => (n ||= "green", r ||= "white", /* @__PURE__ */ c(i, { children: /* @__PURE__ */ c(d, {
16
- style: {
17
- left: e - 10,
18
- top: t - 10
19
- },
20
- children: /* @__PURE__ */ c("circle", {
21
- cx: 10,
22
- cy: 10,
23
- r: 8,
24
- strokeWidth: 1,
25
- stroke: n,
26
- fill: r
27
- })
28
- }) })), p = o("div")({
29
- position: "relative",
30
- display: "inline-block",
31
- cursor: "move"
32
- }), m = class extends a.Component {
33
- static propTypes = {
34
- children: s.oneOfType([s.arrayOf(s.node), s.node]).isRequired,
35
- showAnchor: s.bool,
36
- handle: s.arrayOf(s.shape({
37
- class: s.string.isRequired,
38
- origin: s.string
39
- })),
40
- startPosition: s.shape({
41
- left: s.number,
42
- top: s.number
43
- })
44
- };
45
- static defaultProps = {
46
- showAnchor: !1,
47
- startPosition: {
48
- left: 0,
49
- top: 0
50
- }
51
- };
52
- constructor(e) {
53
- super(e), this.state = {
54
- isRotating: !1,
55
- rotation: 0,
56
- startAngle: 0,
57
- angle: 0,
58
- position: {
59
- left: e.startPosition.left,
60
- top: e.startPosition.top
61
- }
62
- };
63
- }
64
- componentWillUnmount() {
65
- document.removeEventListener("mouseup", this.rotateStop), document.removeEventListener("mousemove", this.drag), document.removeEventListener("mousemove", this.rotate), this.handles.forEach((e) => {
66
- e.el.removeEventListener("mousedown", e.mousedownHandler), e.el.removeEventListener("mouseup", this.rotateStop);
67
- });
68
- }
69
- componentDidMount() {
70
- this.addMouseUpHandler(), this.initHandles();
71
- }
72
- initHandles = () => {
73
- let { handle: e } = this.props;
74
- Array.isArray(e) && (this.handles = [], e.forEach((e) => {
75
- let t = this.rotatable.querySelector(`.${e.class}`);
76
- if (t) {
77
- let n = this.rotateStart(e.origin);
78
- t.addEventListener("mousedown", n), t.addEventListener("mouseup", this.rotateStop), this.handles.push({
79
- el: t,
80
- mousedownHandler: n
81
- });
82
- }
83
- }));
84
- };
85
- addMouseUpHandler = () => {
86
- document.addEventListener("mouseup", this.rotateStop);
87
- };
88
- originToXY = (t) => {
89
- let { clientWidth: n, clientHeight: r } = this.rotatable;
90
- return e({
91
- width: n,
92
- height: r
93
- }, t);
94
- };
95
- getAnchor = (e) => {
96
- let { rotation: t } = this.state, { clientWidth: n, clientHeight: i } = this.rotatable, { top: a, left: o } = this.rotatable.getBoundingClientRect(), s = this.originToXY(e), { top: c, left: l } = r({
97
- width: n,
98
- height: i
99
- }, s, t);
100
- return {
101
- top: a + c,
102
- left: o + l
103
- };
104
- };
105
- rotateStart = (e) => (t) => {
106
- let { isRotating: r } = this.state;
107
- if (r) return;
108
- t.preventDefault();
109
- let i = this.getAnchor(e), { rotation: a } = this.state, { angle: o } = this.getAngle(i, t), s = {
110
- x: 0,
111
- y: 0
112
- };
113
- if (e !== this.state.origin) {
114
- let { clientWidth: t, clientHeight: r } = this.rotatable;
115
- s = n({
116
- width: t,
117
- height: r
118
- }, a, this.state.origin, e);
119
- }
120
- this.setState({
121
- origin: e,
122
- isRotating: !0,
123
- startAngle: o,
124
- anchor: i,
125
- position: {
126
- left: this.state.position.left + s.x,
127
- top: this.state.position.top + s.y
128
- }
129
- }, () => {
130
- document.addEventListener("mousemove", this.rotate);
131
- });
132
- };
133
- rotateStop = (e) => {
134
- let { isRotating: t } = this.state;
135
- t && (e.preventDefault(), this.setState({
136
- isRotating: !1,
137
- angle: this.state.rotation,
138
- anchor: null,
139
- current: null
140
- }, () => {
141
- document.removeEventListener("mousemove", this.rotate), document.removeEventListener("mousemove", this.drag);
142
- }));
143
- };
144
- getAngle(e, n) {
145
- let r = n.clientX - e.left, i = (n.clientY - e.top) * -1;
146
- return {
147
- angle: t(r, i),
148
- x: r,
149
- y: i
150
- };
151
- }
152
- rotate = (e) => {
153
- let { isRotating: t } = this.state;
154
- if (!t) return;
155
- e.preventDefault();
156
- let { startAngle: n, angle: r, anchor: i } = this.state, { angle: a, x: o, y: s } = this.getAngle(i, e), c = {
157
- x: o,
158
- y: s
159
- }, l = a - n, u = r + l;
160
- this.setState({
161
- rotation: u,
162
- diff: l,
163
- current: a,
164
- computedAnchor: c
165
- });
166
- };
167
- mouseDown = (e) => {
168
- this.handles.find((t) => t.el === e.target) || this.dragStart(e);
169
- };
170
- dragStart = (e) => {
171
- let t = new u(e.pageX, e.pageY);
172
- this.setState({ dragPoint: t }, () => {
173
- document.addEventListener("mousemove", this.drag);
174
- });
175
- };
176
- drag = (e) => {
177
- e.preventDefault();
178
- let t = new u(e.pageX, e.pageY).sub(this.state.dragPoint);
179
- this.setState({ translate: t });
180
- };
181
- mouseUp = () => {
182
- if (!this.state.translate) return;
183
- let { position: e, translate: t } = this.state, n = {
184
- left: e.left + t.x,
185
- top: e.top + t.y
186
- };
187
- document.removeEventListener("mousemove", this.drag), this.setState({
188
- position: n,
189
- dragPoint: null,
190
- translate: null
191
- });
192
- };
193
- render() {
194
- let { children: e, showAnchor: t } = this.props, { rotation: n, anchor: r, origin: i, translate: a, position: o } = this.state, s = a ? `translate(${a.x}px, ${a.y}px)` : "";
195
- return /* @__PURE__ */ l(p, {
196
- style: {
197
- left: o.left,
198
- top: o.top,
199
- transformOrigin: i,
200
- transform: `${s} rotate(${n}deg)`
201
- },
202
- ref: (e) => this.rotatable = e,
203
- onMouseDown: this.mouseDown,
204
- onMouseUp: this.mouseUp,
205
- children: [r && t && /* @__PURE__ */ c(f, { ...r }), e]
206
- });
207
- }
208
- };
209
- //#endregion
210
- export { m as default };
@@ -1,20 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/ruler/graphic.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
- import PropTypes from 'prop-types';
11
- export declare class Graphic extends React.PureComponent {
12
- static propTypes: {
13
- width: PropTypes.Validator<number>;
14
- height: PropTypes.Validator<number>;
15
- units: PropTypes.Validator<number>;
16
- unit: PropTypes.Validator<object>;
17
- };
18
- render(): React.JSX.Element;
19
- }
20
- export default Graphic;
@@ -1,53 +0,0 @@
1
- import { fillColor as e, strokeColor as t } from "../style-utils.js";
2
- import n from "./unit-type.js";
3
- import r from "./unit.js";
4
- import i from "react";
5
- import { styled as a } from "@mui/material/styles";
6
- import o from "prop-types";
7
- import { range as s } from "@pie-element/shared-lodash";
8
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
9
- //#region src/ruler/graphic.tsx
10
- var u = a("rect")(({ theme: n }) => ({
11
- stroke: t(n),
12
- strokeWidth: "2px",
13
- fill: e(n)
14
- })), d = ({ width: e, height: t }) => /* @__PURE__ */ c(u, {
15
- width: e,
16
- height: t,
17
- cx: 0,
18
- cy: 0
19
- });
20
- d.propTypes = {
21
- width: o.number.isRequired,
22
- height: o.number.isRequired
23
- };
24
- var f = class extends i.PureComponent {
25
- static propTypes = {
26
- width: o.number.isRequired,
27
- height: o.number.isRequired,
28
- units: o.number.isRequired,
29
- unit: o.object.isRequired
30
- };
31
- render() {
32
- let { width: e, height: t, units: i, unit: a } = this.props, o = `0 0 ${e} ${t}`, u = e / i, f = t;
33
- return /* @__PURE__ */ l("svg", {
34
- viewBox: o,
35
- children: [
36
- /* @__PURE__ */ c(d, {
37
- width: e,
38
- height: t
39
- }),
40
- /* @__PURE__ */ c(n, { label: a.type }),
41
- s(1, i + 1).map((e) => /* @__PURE__ */ c(r, {
42
- width: u,
43
- height: f,
44
- index: e,
45
- config: a,
46
- last: e === i
47
- }, e))
48
- ]
49
- });
50
- }
51
- };
52
- //#endregion
53
- export { f as default };
@@ -1,32 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/ruler/index.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
- import PropTypes from 'prop-types';
11
- export declare class Ruler extends React.Component {
12
- static propTypes: {
13
- width: PropTypes.Requireable<number>;
14
- height: PropTypes.Requireable<number>;
15
- units: PropTypes.Validator<number>;
16
- measure: PropTypes.Validator<string>;
17
- startPosition: PropTypes.Requireable<PropTypes.InferProps<{
18
- left: PropTypes.Validator<number>;
19
- top: PropTypes.Validator<number>;
20
- }>>;
21
- label: PropTypes.Requireable<string>;
22
- tickCount: PropTypes.Requireable<number>;
23
- };
24
- static defaultProps: {
25
- width: number;
26
- height: number;
27
- measure: string;
28
- units: number;
29
- };
30
- render(): React.JSX.Element;
31
- }
32
- export default Ruler;
@@ -1,77 +0,0 @@
1
- import e from "../anchor.js";
2
- import t from "../rotatable.js";
3
- import n from "./graphic.js";
4
- import r from "react";
5
- import { styled as i } from "@mui/material/styles";
6
- import a from "prop-types";
7
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
- //#region src/ruler/index.tsx
9
- var c = i("div")(({ theme: e }) => ({
10
- cursor: "move",
11
- position: "relative",
12
- backgroundColor: e.palette.secondary.light,
13
- opacity: 1,
14
- border: `solid 0px ${e.palette.primary.main}`
15
- })), l = i(e)(() => ({
16
- left: "-10px",
17
- top: "40%"
18
- })), u = i(e)(() => ({
19
- right: "-10px",
20
- top: "40%"
21
- })), d = class extends r.Component {
22
- static propTypes = {
23
- width: a.number,
24
- height: a.number,
25
- units: a.number.isRequired,
26
- measure: a.oneOf(["imperial", "metric"]).isRequired,
27
- startPosition: a.shape({
28
- left: a.number.isRequired,
29
- top: a.number.isRequired
30
- }),
31
- label: a.string,
32
- tickCount: a.number
33
- };
34
- static defaultProps = {
35
- width: 480,
36
- height: 60,
37
- measure: "imperial",
38
- units: 12
39
- };
40
- render() {
41
- let { width: e, height: r, units: i, measure: a, startPosition: d, label: f, tickCount: p } = this.props, m = a === "imperial" ? {
42
- type: f,
43
- ticks: p && p % 4 == 0 ? p : 16
44
- } : {
45
- type: f,
46
- ticks: 10
47
- };
48
- return /* @__PURE__ */ o(t, {
49
- startPosition: d,
50
- handle: [{
51
- class: "leftAnchor",
52
- origin: "bottom right"
53
- }, {
54
- class: "rightAnchor",
55
- origin: "bottom left"
56
- }],
57
- children: /* @__PURE__ */ s(c, {
58
- style: {
59
- width: `${e}px`,
60
- height: `${r}px`
61
- },
62
- children: [
63
- /* @__PURE__ */ o(n, {
64
- width: e,
65
- height: r,
66
- units: i,
67
- unit: m
68
- }),
69
- /* @__PURE__ */ o(l, { className: "leftAnchor" }),
70
- /* @__PURE__ */ o(u, { className: "rightAnchor" })
71
- ]
72
- })
73
- });
74
- }
75
- };
76
- //#endregion
77
- export { d as default };
@@ -1,30 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/ruler/unit-type.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
- import PropTypes from 'prop-types';
11
- export declare const UnitType: {
12
- (props: any): React.JSX.Element;
13
- propTypes: {
14
- label: PropTypes.Validator<string>;
15
- x: PropTypes.Requireable<number>;
16
- y: PropTypes.Requireable<number>;
17
- textAlign: PropTypes.Requireable<string>;
18
- fill: PropTypes.Requireable<string>;
19
- fontSize: PropTypes.Requireable<number>;
20
- stroke: PropTypes.Requireable<string>;
21
- };
22
- defaultProps: {
23
- textAnchor: string;
24
- fontSize: number;
25
- stroke: string;
26
- x: number;
27
- y: number;
28
- };
29
- };
30
- export default UnitType;
@@ -1,38 +0,0 @@
1
- import { noSelect as e, strokeColor as t } from "../style-utils.js";
2
- import "react";
3
- import { styled as n } from "@mui/material/styles";
4
- import r from "prop-types";
5
- import { jsx as i } from "react/jsx-runtime";
6
- //#region src/ruler/unit-type.tsx
7
- var a = n("text")(({ theme: n }) => ({
8
- ...e(),
9
- fill: t(n)
10
- })), o = (e) => {
11
- let { label: t, x: n, y: r, textAlign: o, fill: s, fontSize: c, stroke: l } = e;
12
- return /* @__PURE__ */ i(a, {
13
- x: n,
14
- y: r,
15
- textAnchor: o,
16
- stroke: l,
17
- fill: s,
18
- fontSize: c,
19
- children: t
20
- });
21
- };
22
- o.propTypes = {
23
- label: r.string.isRequired,
24
- x: r.number,
25
- y: r.number,
26
- textAlign: r.string,
27
- fill: r.string,
28
- fontSize: r.number,
29
- stroke: r.string
30
- }, o.defaultProps = {
31
- textAnchor: "start",
32
- fontSize: 11,
33
- stroke: "none",
34
- x: 8,
35
- y: 14
36
- };
37
- //#endregion
38
- export { o as default };
@@ -1,21 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/ruler/unit.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
- import PropTypes from 'prop-types';
11
- export declare class Unit extends React.Component {
12
- static propTypes: {
13
- index: PropTypes.Validator<number>;
14
- width: PropTypes.Validator<number>;
15
- height: PropTypes.Validator<number>;
16
- last: PropTypes.Validator<boolean>;
17
- config: PropTypes.Validator<object>;
18
- };
19
- render(): React.JSX.Element;
20
- }
21
- export default Unit;
@@ -1,69 +0,0 @@
1
- import { noSelect as e, strokeColor as t } from "../style-utils.js";
2
- import n from "react";
3
- import { styled as r } from "@mui/material/styles";
4
- import i from "prop-types";
5
- import { range as a } from "@pie-element/shared-lodash";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
- //#region src/ruler/unit.tsx
8
- var c = r("line")(({ theme: e }) => ({ stroke: t(e) })), l = ({ x: e, height: t, bottom: n, major: r, minor: i }) => /* @__PURE__ */ o(c, {
9
- y1: r ? n - t * 2 : i ? n - t * 1.5 : n - t,
10
- y2: n,
11
- x1: e,
12
- x2: e
13
- }), u = ({ count: e, width: t, height: r }) => /* @__PURE__ */ o(n.Fragment, { children: a(1, e).map((n) => /* @__PURE__ */ o(l, {
14
- value: n,
15
- x: t / e * n,
16
- major: n % (e / 2) == 0,
17
- minor: n % (e / 4) == 0,
18
- bottom: r,
19
- height: 10
20
- }, n)) });
21
- u.propTypes = {
22
- count: i.number.isRequired,
23
- width: i.number.isRequired,
24
- height: i.number.isRequired
25
- };
26
- var d = r("line")(({ theme: e }) => ({
27
- stroke: t(e),
28
- strokeWidth: 1
29
- })), f = r("text")(({ theme: n }) => ({
30
- textAnchor: "end",
31
- fontSize: "12px",
32
- fill: t(n),
33
- ...e()
34
- })), p = class extends n.Component {
35
- static propTypes = {
36
- index: i.number.isRequired,
37
- width: i.number.isRequired,
38
- height: i.number.isRequired,
39
- last: i.bool.isRequired,
40
- config: i.object.isRequired
41
- };
42
- render() {
43
- let { index: e, width: t, height: n, last: r, config: i } = this.props;
44
- return /* @__PURE__ */ s("g", {
45
- style: { transform: `translate(${t * (e - 1)}px, 0px)` },
46
- children: [
47
- !r && /* @__PURE__ */ o(d, {
48
- x1: t,
49
- y1: 0,
50
- x2: t,
51
- y2: n
52
- }),
53
- /* @__PURE__ */ o(u, {
54
- count: i.ticks,
55
- width: t,
56
- height: n
57
- }),
58
- /* @__PURE__ */ o(f, {
59
- width: t,
60
- x: t - 5,
61
- y: 15,
62
- children: e
63
- })
64
- ]
65
- });
66
- }
67
- };
68
- //#endregion
69
- export { p as default };
@@ -1,12 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/style-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 { noSelect } from '@pie-lib/style-utils';
10
- export { noSelect };
11
- export declare const strokeColor: (theme: any) => string;
12
- export declare const fillColor: (theme: any) => string;
@@ -1,5 +0,0 @@
1
- import { noSelect as e } from "@pie-lib/style-utils";
2
- //#region src/style-utils.ts
3
- var t = (e) => `var(--ruler-stroke, ${e.palette.primary.main})`, n = (e) => `var(--ruler-bg, ${e.palette.primary.contrastText})`;
4
- //#endregion
5
- export { n as fillColor, e as noSelect, t as strokeColor };
@@ -1,18 +0,0 @@
1
- /**
2
- * @synced-from pie-lib/packages/tools/src/transform-origin.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
- /**
10
- * Parse a transform origin string to x/y values.
11
- * @param {{width: number, height: number}} rect
12
- * @param {string} value
13
- * @returns {x:number, y:number}
14
- */
15
- export declare const parse: (rect: any, value: any) => {
16
- x: number;
17
- y: number;
18
- } | undefined;
@@ -1,21 +0,0 @@
1
- //#region src/transform-origin.tsx
2
- var e = (e) => e === "left" || e === "top" ? 0 : e === "right" || e === "bottom" ? 100 : e === "center" ? 50 : e.endsWith("%") ? parseFloat(e) : e, t = (t, n) => t.endsWith("px") ? parseFloat(t) : (t = e(t), t / 100 * n), n = (e) => e[0] === "bottom" || e[0] === "top" || e[1] === "left" || e[1] === "right" ? [e[1], e[0]] : e, r = (e, r) => {
3
- if (!r) return {
4
- x: e.width / 2,
5
- y: e.height / 2
6
- };
7
- let i = r.split(" ");
8
- if (i.length === 1) return {
9
- x: t(i[0], e.width),
10
- y: t("50%", e.height)
11
- };
12
- if (i.length === 2) {
13
- let r = n(i);
14
- return {
15
- x: t(r[0], e.width),
16
- y: t(r[1], e.height)
17
- };
18
- } else if (i.length === 3) throw Error("transform-origin values with 3 fields not supported.");
19
- };
20
- //#endregion
21
- export { r as parse };