@pie-element/number-line 13.1.1 → 13.1.2-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/author/arrows.d.ts +28 -0
- package/dist/author/arrows.js +69 -0
- package/dist/author/card-bar.d.ts +20 -0
- package/dist/author/card-bar.js +41 -0
- package/dist/author/defaults.d.ts +178 -0
- package/dist/author/defaults.js +144 -0
- package/dist/author/domain.d.ts +15 -0
- package/dist/author/domain.js +54 -0
- package/dist/author/index.d.ts +23 -0
- package/dist/author/index.js +89 -0
- package/dist/author/main.d.ts +44 -0
- package/dist/author/main.js +485 -0
- package/dist/author/number-text-field.d.ts +13 -0
- package/dist/author/number-text-field.js +13 -0
- package/dist/author/point-config.d.ts +25 -0
- package/dist/author/point-config.js +69 -0
- package/dist/author/size.d.ts +24 -0
- package/dist/author/size.js +48 -0
- package/dist/author/ticks.d.ts +22 -0
- package/dist/author/ticks.js +115 -0
- package/dist/author/utils.d.ts +9 -0
- package/dist/author/utils.js +4 -0
- package/dist/browser/author/index.js +40259 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/controller/index.js +569 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +2 -0
- package/dist/browser/delivery-Ci_kZyOM.js +17903 -0
- package/dist/browser/delivery-Ci_kZyOM.js.map +1 -0
- package/dist/browser/dist-D5T-OaLo.js +19038 -0
- package/dist/browser/dist-D5T-OaLo.js.map +1 -0
- package/dist/browser/impureFunctionsAny.generated-Bqfato71.js +10162 -0
- package/dist/browser/impureFunctionsAny.generated-Bqfato71.js.map +1 -0
- package/dist/browser/number-line.css +2 -0
- package/dist/controller/defaults.d.ts +58 -0
- package/dist/controller/defaults.js +50 -0
- package/dist/controller/index.d.ts +47 -0
- package/dist/controller/index.js +165 -0
- package/dist/controller/tickUtils.d.ts +21 -0
- package/dist/controller/tickUtils.js +252 -0
- package/dist/controller/utils.d.ts +9 -0
- package/dist/controller/utils.js +68 -0
- package/dist/delivery/data-converter.d.ts +64 -0
- package/dist/delivery/data-converter.js +70 -0
- package/dist/delivery/draggable/index.d.ts +33 -0
- package/dist/delivery/draggable/index.js +39 -0
- package/dist/delivery/index.d.ts +35 -0
- package/dist/delivery/index.js +109 -0
- package/dist/delivery/number-line/colors.d.ts +11 -0
- package/dist/delivery/number-line/colors.js +5 -0
- package/dist/delivery/number-line/feedback.d.ts +19 -0
- package/dist/delivery/number-line/feedback.js +57 -0
- package/dist/delivery/number-line/graph/arrow.d.ts +30 -0
- package/dist/delivery/number-line/graph/arrow.js +27 -0
- package/dist/delivery/number-line/graph/elements/base.d.ts +16 -0
- package/dist/delivery/number-line/graph/elements/base.js +11 -0
- package/dist/delivery/number-line/graph/elements/builder.d.ts +33 -0
- package/dist/delivery/number-line/graph/elements/builder.js +30 -0
- package/dist/delivery/number-line/graph/elements/line.d.ts +51 -0
- package/dist/delivery/number-line/graph/elements/line.js +188 -0
- package/dist/delivery/number-line/graph/elements/point.d.ts +43 -0
- package/dist/delivery/number-line/graph/elements/point.js +127 -0
- package/dist/delivery/number-line/graph/elements/ray.d.ts +43 -0
- package/dist/delivery/number-line/graph/elements/ray.js +130 -0
- package/dist/delivery/number-line/graph/index.d.ts +59 -0
- package/dist/delivery/number-line/graph/index.js +196 -0
- package/dist/delivery/number-line/graph/line.d.ts +46 -0
- package/dist/delivery/number-line/graph/line.js +27 -0
- package/dist/delivery/number-line/graph/stacks.d.ts +10 -0
- package/dist/delivery/number-line/graph/stacks.js +40 -0
- package/dist/delivery/number-line/graph/tick-utils.d.ts +80 -0
- package/dist/delivery/number-line/graph/tick-utils.js +295 -0
- package/dist/delivery/number-line/graph/ticks.d.ts +46 -0
- package/dist/delivery/number-line/graph/ticks.js +115 -0
- package/dist/delivery/number-line/index.d.ts +35 -0
- package/dist/delivery/number-line/index.js +215 -0
- package/dist/delivery/number-line/point-chooser/button.d.ts +31 -0
- package/dist/delivery/number-line/point-chooser/button.js +36 -0
- package/dist/delivery/number-line/point-chooser/img.d.ts +10 -0
- package/dist/delivery/number-line/point-chooser/img.js +4 -0
- package/dist/delivery/number-line/point-chooser/index.d.ts +37 -0
- package/dist/delivery/number-line/point-chooser/index.js +154 -0
- package/dist/delivery/number-line/point-chooser/styles.d.ts +192 -0
- package/dist/delivery/number-line/transitions/fade.d.ts +34 -0
- package/dist/delivery/number-line/transitions/fade.js +75 -0
- package/dist/delivery/number-line/transitions/index.d.ts +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +197 -0
- package/dist/index.js +2 -0
- package/dist/runtime-support.d.ts +12 -0
- package/dist/runtime-support.js +12 -0
- package/package.json +87 -21
- package/CHANGELOG.json +0 -1247
- package/CHANGELOG.md +0 -2435
- package/LICENSE.md +0 -5
- package/README.md +0 -28
- package/configure/CHANGELOG.json +0 -827
- package/configure/CHANGELOG.md +0 -2082
- package/configure/lib/arrows.js +0 -89
- package/configure/lib/arrows.js.map +0 -1
- package/configure/lib/card-bar.js +0 -57
- package/configure/lib/card-bar.js.map +0 -1
- package/configure/lib/defaults.js +0 -177
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/domain.js +0 -87
- package/configure/lib/domain.js.map +0 -1
- package/configure/lib/index.js +0 -176
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -815
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/number-text-field.js +0 -26
- package/configure/lib/number-text-field.js.map +0 -1
- package/configure/lib/point-config.js +0 -84
- package/configure/lib/point-config.js.map +0 -1
- package/configure/lib/size.js +0 -66
- package/configure/lib/size.js.map +0 -1
- package/configure/lib/ticks.js +0 -234
- package/configure/lib/ticks.js.map +0 -1
- package/configure/lib/utils.js +0 -12
- package/configure/lib/utils.js.map +0 -1
- package/configure/package.json +0 -20
- package/controller/CHANGELOG.json +0 -332
- package/controller/CHANGELOG.md +0 -1360
- package/controller/lib/defaults.js +0 -56
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -430
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/tickUtils.js +0 -294
- package/controller/lib/tickUtils.js.map +0 -1
- package/controller/lib/utils.js +0 -168
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -20
- package/demo.gif +0 -0
- package/docs/config-schema.json +0 -2532
- package/docs/config-schema.json.md +0 -1844
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -39
- package/docs/demo/index.html +0 -1
- package/docs/pie-schema.json +0 -2461
- package/docs/pie-schema.json.md +0 -1228
- package/docs/schemas/config.json +0 -256
- package/lib/data-converter.js +0 -96
- package/lib/data-converter.js.map +0 -1
- package/lib/draggable/index.js +0 -114
- package/lib/draggable/index.js.map +0 -1
- package/lib/index.js +0 -196
- package/lib/index.js.map +0 -1
- package/lib/number-line/colors.js +0 -11
- package/lib/number-line/colors.js.map +0 -1
- package/lib/number-line/feedback.js +0 -92
- package/lib/number-line/feedback.js.map +0 -1
- package/lib/number-line/graph/arrow.js +0 -44
- package/lib/number-line/graph/arrow.js.map +0 -1
- package/lib/number-line/graph/elements/base.js +0 -20
- package/lib/number-line/graph/elements/base.js.map +0 -1
- package/lib/number-line/graph/elements/builder.js +0 -37
- package/lib/number-line/graph/elements/builder.js.map +0 -1
- package/lib/number-line/graph/elements/line.js +0 -259
- package/lib/number-line/graph/elements/line.js.map +0 -1
- package/lib/number-line/graph/elements/point.js +0 -204
- package/lib/number-line/graph/elements/point.js.map +0 -1
- package/lib/number-line/graph/elements/ray.js +0 -190
- package/lib/number-line/graph/elements/ray.js.map +0 -1
- package/lib/number-line/graph/index.js +0 -262
- package/lib/number-line/graph/index.js.map +0 -1
- package/lib/number-line/graph/line.js +0 -38
- package/lib/number-line/graph/line.js.map +0 -1
- package/lib/number-line/graph/stacks.js +0 -78
- package/lib/number-line/graph/stacks.js.map +0 -1
- package/lib/number-line/graph/tick-utils.js +0 -347
- package/lib/number-line/graph/tick-utils.js.map +0 -1
- package/lib/number-line/graph/ticks.js +0 -188
- package/lib/number-line/graph/ticks.js.map +0 -1
- package/lib/number-line/index.js +0 -384
- package/lib/number-line/index.js.map +0 -1
- package/lib/number-line/point-chooser/button.js +0 -49
- package/lib/number-line/point-chooser/button.js.map +0 -1
- package/lib/number-line/point-chooser/img.js +0 -8
- package/lib/number-line/point-chooser/img.js.map +0 -1
- package/lib/number-line/point-chooser/index.js +0 -197
- package/lib/number-line/point-chooser/index.js.map +0 -1
- package/lib/number-line/point-chooser/styles.js +0 -77
- package/lib/number-line/point-chooser/styles.js.map +0 -1
- package/lib/number-line/transitions/fade.js +0 -88
- package/lib/number-line/transitions/fade.js.map +0 -1
- package/lib/number-line/transitions/index.js +0 -14
- package/lib/number-line/transitions/index.js.map +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { snapTo as e } from "./tick-utils.js";
|
|
2
|
+
import t from "./elements/point.js";
|
|
3
|
+
import n from "./elements/line.js";
|
|
4
|
+
import r from "./arrow.js";
|
|
5
|
+
import i from "./elements/ray.js";
|
|
6
|
+
import a from "./line.js";
|
|
7
|
+
import o from "./ticks.js";
|
|
8
|
+
import s from "./stacks.js";
|
|
9
|
+
import c from "../transitions/fade.js";
|
|
10
|
+
import l, { createElement as u } from "react";
|
|
11
|
+
import d from "prop-types";
|
|
12
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
13
|
+
import { scaleLinear as m } from "d3-scale";
|
|
14
|
+
import { pointer as h, select as g } from "d3-selection";
|
|
15
|
+
import { color as _ } from "@pie-lib/render-ui";
|
|
16
|
+
import { DndContext as v } from "@dnd-kit/core";
|
|
17
|
+
import { TransitionGroup as y } from "react-transition-group";
|
|
18
|
+
//#region src/delivery/number-line/graph/index.tsx
|
|
19
|
+
var b = (e, t, n, r) => {
|
|
20
|
+
if (e === void 0 || t === void 0 || n === void 0) throw Error("missing min/max/width");
|
|
21
|
+
return m().domain([e, t]).range([r, n - r]);
|
|
22
|
+
}, x = class extends l.Component {
|
|
23
|
+
static childContextTypes = {
|
|
24
|
+
xScale: d.func.isRequired,
|
|
25
|
+
snapValue: d.func.isRequired
|
|
26
|
+
};
|
|
27
|
+
static propTypes = {
|
|
28
|
+
domain: d.shape({
|
|
29
|
+
min: d.number.isRequired,
|
|
30
|
+
max: d.number.isRequired
|
|
31
|
+
}).isRequired,
|
|
32
|
+
ticks: d.shape({
|
|
33
|
+
minor: d.number,
|
|
34
|
+
major: d.number
|
|
35
|
+
}).isRequired,
|
|
36
|
+
fraction: d.bool,
|
|
37
|
+
width: d.number.isRequired,
|
|
38
|
+
height: d.number.isRequired,
|
|
39
|
+
onToggleElement: d.func.isRequired,
|
|
40
|
+
onMoveElement: d.func.isRequired,
|
|
41
|
+
onAddElement: d.func.isRequired,
|
|
42
|
+
debug: d.bool,
|
|
43
|
+
elements: d.array,
|
|
44
|
+
disabled: d.bool,
|
|
45
|
+
onDeselectElements: d.func,
|
|
46
|
+
arrows: d.shape({
|
|
47
|
+
left: d.bool,
|
|
48
|
+
right: d.bool
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
static defaultProps = { debug: !1 };
|
|
52
|
+
constructor(e) {
|
|
53
|
+
super(e), this.state = {};
|
|
54
|
+
}
|
|
55
|
+
xScaleFn() {
|
|
56
|
+
let { domain: e, width: t } = this.props, { max: n, min: r } = e || {}, i = 20;
|
|
57
|
+
return n && (i = n.toString().length * 4 + 15), b(r, n, t, i);
|
|
58
|
+
}
|
|
59
|
+
snapValueFn() {
|
|
60
|
+
let { domain: t, ticks: n } = this.props;
|
|
61
|
+
return e.bind(null, t.min, t.max, n.minor);
|
|
62
|
+
}
|
|
63
|
+
getChildContext() {
|
|
64
|
+
return {
|
|
65
|
+
xScale: this.xScaleFn(),
|
|
66
|
+
snapValue: this.snapValueFn()
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
onRectClick(e) {
|
|
70
|
+
let { elements: t, disabled: n } = this.props;
|
|
71
|
+
if (!n) if (t.some((e) => e.selected)) this.props.onDeselectElements();
|
|
72
|
+
else {
|
|
73
|
+
let t = h(e, this.rect), n = this.xScaleFn().invert(t[0]);
|
|
74
|
+
this.addElement(n);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
componentDidMount() {
|
|
78
|
+
g(this.rect).on("click", this.onRectClick.bind(this));
|
|
79
|
+
}
|
|
80
|
+
addElement(e) {
|
|
81
|
+
let t = this.snapValueFn()(e);
|
|
82
|
+
this.props.onAddElement(t);
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
let { domain: e, width: l, ticks: d, height: m, onToggleElement: h, onMoveElement: g, disabled: b, fraction: x } = this.props, { arrows: S } = this.props;
|
|
86
|
+
S ||= {
|
|
87
|
+
left: !0,
|
|
88
|
+
right: !0
|
|
89
|
+
};
|
|
90
|
+
let { min: C, max: w } = e;
|
|
91
|
+
if (e.max <= e.min) return /* @__PURE__ */ p("div", { children: [
|
|
92
|
+
e.max,
|
|
93
|
+
" is less than or equal to ",
|
|
94
|
+
e.min
|
|
95
|
+
] });
|
|
96
|
+
{
|
|
97
|
+
let T = m - 30, E = new s(e), D = this.props.elements.map((e, r) => {
|
|
98
|
+
let a = E.add(e);
|
|
99
|
+
if (a === -1) throw Error("stack index is -1, cant add element");
|
|
100
|
+
let o = {
|
|
101
|
+
key: r,
|
|
102
|
+
y: T - a * 25,
|
|
103
|
+
selected: e.selected && !b,
|
|
104
|
+
interval: d.minor,
|
|
105
|
+
disabled: b,
|
|
106
|
+
correct: e.correct
|
|
107
|
+
}, s = h.bind(null, r, e), c = g.bind(null, r, e);
|
|
108
|
+
if (e.type === "line") {
|
|
109
|
+
let t = {
|
|
110
|
+
left: e.leftPoint === "empty",
|
|
111
|
+
right: e.rightPoint === "empty"
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ u(n, {
|
|
114
|
+
...o,
|
|
115
|
+
domain: {
|
|
116
|
+
min: C,
|
|
117
|
+
max: w
|
|
118
|
+
},
|
|
119
|
+
onMoveLine: c,
|
|
120
|
+
onToggleSelect: s,
|
|
121
|
+
position: e.position,
|
|
122
|
+
empty: t,
|
|
123
|
+
key: r
|
|
124
|
+
});
|
|
125
|
+
} else if (e.type === "point") {
|
|
126
|
+
let n = {
|
|
127
|
+
left: C - e.position,
|
|
128
|
+
right: w - e.position
|
|
129
|
+
};
|
|
130
|
+
return /* @__PURE__ */ u(t, {
|
|
131
|
+
...o,
|
|
132
|
+
empty: e.pointType === "empty",
|
|
133
|
+
position: e.position,
|
|
134
|
+
bounds: n,
|
|
135
|
+
onClick: s,
|
|
136
|
+
onMove: c,
|
|
137
|
+
key: r
|
|
138
|
+
});
|
|
139
|
+
} else if (e.type === "ray") return /* @__PURE__ */ u(i, {
|
|
140
|
+
...o,
|
|
141
|
+
domain: {
|
|
142
|
+
min: C,
|
|
143
|
+
max: w
|
|
144
|
+
},
|
|
145
|
+
direction: e.direction,
|
|
146
|
+
position: e.position,
|
|
147
|
+
onMove: c,
|
|
148
|
+
onToggleSelect: s,
|
|
149
|
+
width: l,
|
|
150
|
+
empty: e.pointType === "empty",
|
|
151
|
+
key: r
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
return /* @__PURE__ */ f(v, { children: /* @__PURE__ */ f("div", {
|
|
155
|
+
style: { display: "inline-block" },
|
|
156
|
+
children: /* @__PURE__ */ p("svg", {
|
|
157
|
+
width: l,
|
|
158
|
+
height: x ? m + 20 : m,
|
|
159
|
+
children: [
|
|
160
|
+
!1,
|
|
161
|
+
/* @__PURE__ */ f(a, {
|
|
162
|
+
y: T,
|
|
163
|
+
width: l
|
|
164
|
+
}),
|
|
165
|
+
S.left && /* @__PURE__ */ f(r, { y: T }),
|
|
166
|
+
S.right && /* @__PURE__ */ f(r, {
|
|
167
|
+
x: l,
|
|
168
|
+
y: T,
|
|
169
|
+
direction: "right"
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ f(o, {
|
|
172
|
+
y: T,
|
|
173
|
+
domain: e,
|
|
174
|
+
width: l,
|
|
175
|
+
ticks: d,
|
|
176
|
+
fraction: x
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ f("rect", {
|
|
179
|
+
ref: (e) => this.rect = e,
|
|
180
|
+
fill: _.primary(),
|
|
181
|
+
fillOpacity: "0.0",
|
|
182
|
+
width: l,
|
|
183
|
+
height: m
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ f(y, {
|
|
186
|
+
component: "g",
|
|
187
|
+
children: D.map((e, t) => /* @__PURE__ */ f(c, { children: e }, t))
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
}) });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
export { x as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/number-line/src/number-line/graph/line.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 function Line({ y, width, classes }: {
|
|
12
|
+
y: any;
|
|
13
|
+
width: any;
|
|
14
|
+
classes: any;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
export declare namespace Line {
|
|
17
|
+
var propTypes: {
|
|
18
|
+
y: PropTypes.Validator<number>;
|
|
19
|
+
width: PropTypes.Validator<number>;
|
|
20
|
+
classes: PropTypes.Validator<object>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare const _default: React.ComponentType<Pick<Omit<{
|
|
24
|
+
y: any;
|
|
25
|
+
width: any;
|
|
26
|
+
classes: any;
|
|
27
|
+
}, "classes"> & {
|
|
28
|
+
classes?: Partial<{
|
|
29
|
+
root: string;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
innerRef?: React.RefObject<any> | ((instance: any) => void);
|
|
32
|
+
}, "classes" | "innerRef"> & Pick<PropTypes.InferProps<{
|
|
33
|
+
y: PropTypes.Validator<number>;
|
|
34
|
+
width: PropTypes.Validator<number>;
|
|
35
|
+
classes: PropTypes.Validator<object>;
|
|
36
|
+
}>, "y" | "width"> & Pick<Omit<{
|
|
37
|
+
y: any;
|
|
38
|
+
width: any;
|
|
39
|
+
classes: any;
|
|
40
|
+
}, "classes"> & {
|
|
41
|
+
classes?: Partial<{
|
|
42
|
+
root: string;
|
|
43
|
+
}> | undefined;
|
|
44
|
+
innerRef?: React.RefObject<any> | ((instance: any) => void);
|
|
45
|
+
}, "innerRef">>;
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import e from "prop-types";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
import { color as n } from "@pie-lib/render-ui";
|
|
5
|
+
import r from "react-jss";
|
|
6
|
+
//#region src/delivery/number-line/graph/line.tsx
|
|
7
|
+
var i = { root: {
|
|
8
|
+
strokeWidth: 2,
|
|
9
|
+
stroke: n.primary()
|
|
10
|
+
} };
|
|
11
|
+
function a({ y: e, width: n, classes: r }) {
|
|
12
|
+
return /* @__PURE__ */ t("line", {
|
|
13
|
+
x1: 0,
|
|
14
|
+
y1: e,
|
|
15
|
+
x2: n,
|
|
16
|
+
y2: e,
|
|
17
|
+
className: r.root
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
a.propTypes = {
|
|
21
|
+
y: e.number.isRequired,
|
|
22
|
+
width: e.number.isRequired,
|
|
23
|
+
classes: e.object.isRequired
|
|
24
|
+
};
|
|
25
|
+
var o = r(i)(a);
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/number-line/src/number-line/graph/stacks.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
|
+
export default function Stacks(domain: any): void;
|
|
10
|
+
export declare function Stack(domain: any): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/delivery/number-line/graph/stacks.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let n = [new t(e)];
|
|
4
|
+
this.add = function(r) {
|
|
5
|
+
let i = n.find((e) => e.add(r));
|
|
6
|
+
return n.indexOf(i) === -1 && (i = new t(e), n.push(i), i.add(r)), n.indexOf(i);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function t(e) {
|
|
10
|
+
let t = [];
|
|
11
|
+
this.add = function(i) {
|
|
12
|
+
let a = r(i);
|
|
13
|
+
return a.left < e.min || a.right > e.max || t.some((e) => n(e, a)) ? !1 : (t.push(i), !0);
|
|
14
|
+
}, this.elements = function() {
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
let n = (e, t) => {
|
|
18
|
+
let n = r(e), i = t.left < n.left && t.right < n.left, a = t.left > n.right && t.right > n.right;
|
|
19
|
+
return !(i || a);
|
|
20
|
+
}, r = (t) => {
|
|
21
|
+
let { type: n, position: r } = t;
|
|
22
|
+
switch (n) {
|
|
23
|
+
case "point": return {
|
|
24
|
+
left: r,
|
|
25
|
+
right: r
|
|
26
|
+
};
|
|
27
|
+
case "line": return r;
|
|
28
|
+
case "ray": return t.direction === "positive" ? {
|
|
29
|
+
left: r,
|
|
30
|
+
right: e.max
|
|
31
|
+
} : {
|
|
32
|
+
left: e.min,
|
|
33
|
+
right: r
|
|
34
|
+
};
|
|
35
|
+
default: return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { e as default };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-elements/packages/number-line/src/number-line/graph/tick-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 * as math from 'mathjs';
|
|
10
|
+
export declare const decimalTickValues: number[];
|
|
11
|
+
export declare const fractionTickValues: string[];
|
|
12
|
+
export declare const labelMultiplier: {
|
|
13
|
+
1: number[];
|
|
14
|
+
2: number[];
|
|
15
|
+
3: number[];
|
|
16
|
+
4: number[];
|
|
17
|
+
5: number[];
|
|
18
|
+
6: number[];
|
|
19
|
+
7: number[];
|
|
20
|
+
8: number[];
|
|
21
|
+
9: number[];
|
|
22
|
+
10: number[];
|
|
23
|
+
12: number[];
|
|
24
|
+
15: number[];
|
|
25
|
+
16: number[];
|
|
26
|
+
20: number[];
|
|
27
|
+
25: number[];
|
|
28
|
+
32: number[];
|
|
29
|
+
50: number[];
|
|
30
|
+
64: number[];
|
|
31
|
+
100: number[];
|
|
32
|
+
1000: number[];
|
|
33
|
+
};
|
|
34
|
+
export declare const fractionRange: (start: any, end: any, interval: any) => any[];
|
|
35
|
+
export declare const zbrErrorMessage: (start: any, end: any) => string;
|
|
36
|
+
export declare const zeroBasedRange: (start: any, end: any, interval: any) => any[];
|
|
37
|
+
/**
|
|
38
|
+
* the lodash range was causing too much variance in the rounding errors
|
|
39
|
+
* such that it was hard to round the numbers.
|
|
40
|
+
* This is a more simplistic version but makes rounding work.
|
|
41
|
+
*/
|
|
42
|
+
export declare const simpleRange: (start: any, end: any, interval: any) => (string | math.MathType)[];
|
|
43
|
+
export declare const closeTo: (a: any, b: any, precision: any) => boolean;
|
|
44
|
+
export declare const getMinorLimits: (domain: any, width: any) => {
|
|
45
|
+
min: number & (number | math.MathCollection<math.MathNumericType>);
|
|
46
|
+
max: number;
|
|
47
|
+
};
|
|
48
|
+
export declare const isMultiple: (multiple: any, src: any) => boolean | math.MathCollection<math.MathNumericType>;
|
|
49
|
+
/**
|
|
50
|
+
* Accepts a fraction object {n,d,s} or number.
|
|
51
|
+
* @param {*} v
|
|
52
|
+
* @return mathjs.fraction
|
|
53
|
+
*/
|
|
54
|
+
export declare const fraction: (v: any) => math.Fraction | undefined;
|
|
55
|
+
export declare const normalizeTicks: (domain: any, width: any, ticks: any, opts: any) => {
|
|
56
|
+
major: any;
|
|
57
|
+
minor: any;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Build ticks as an array of mathjs Fractions
|
|
61
|
+
*/
|
|
62
|
+
export declare const buildTickDataAsFractions: (domain: any, width: any, ticks: any, opts: any) => {
|
|
63
|
+
x: string | math.MathType;
|
|
64
|
+
type: string;
|
|
65
|
+
}[];
|
|
66
|
+
export declare const generateMinorValues: (minorLimits: any) => {
|
|
67
|
+
fraction: never[];
|
|
68
|
+
decimal: never[];
|
|
69
|
+
};
|
|
70
|
+
export declare const generateMajorValuesForMinor: (minor: any, domain: any, width: any) => {
|
|
71
|
+
decimal: never[];
|
|
72
|
+
fraction: never[];
|
|
73
|
+
};
|
|
74
|
+
export declare const buildTickData: (domain: any, width: any, ticks: any, opts: any) => {
|
|
75
|
+
x: string | math.MathType;
|
|
76
|
+
type: string;
|
|
77
|
+
}[];
|
|
78
|
+
export declare const fractionSnapTo: (min: any, max: any, interval: any, value: any) => any;
|
|
79
|
+
export declare const snapTo: (min: any, max: any, interval: any, value: any) => number;
|
|
80
|
+
export declare const snapElements: (domain: any, ticks: any, elements: any) => any;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { __exportAll as e } from "../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import * as t from "mathjs";
|
|
3
|
+
import { isNumber as n, isObject as r, uniqWith as i } from "@pie-element/shared-lodash";
|
|
4
|
+
//#region src/delivery/number-line/graph/tick-utils.ts
|
|
5
|
+
var a = /* @__PURE__ */ e({
|
|
6
|
+
buildTickData: () => w,
|
|
7
|
+
buildTickDataAsFractions: () => x,
|
|
8
|
+
closeTo: () => h,
|
|
9
|
+
decimalTickValues: () => o,
|
|
10
|
+
fraction: () => y,
|
|
11
|
+
fractionRange: () => l,
|
|
12
|
+
fractionSnapTo: () => T,
|
|
13
|
+
fractionTickValues: () => s,
|
|
14
|
+
generateMajorValuesForMinor: () => C,
|
|
15
|
+
generateMinorValues: () => S,
|
|
16
|
+
getMinorLimits: () => _,
|
|
17
|
+
isMultiple: () => v,
|
|
18
|
+
labelMultiplier: () => c,
|
|
19
|
+
normalizeTicks: () => b,
|
|
20
|
+
simpleRange: () => m,
|
|
21
|
+
snapElements: () => D,
|
|
22
|
+
snapTo: () => E,
|
|
23
|
+
zbrErrorMessage: () => u,
|
|
24
|
+
zeroBasedRange: () => d
|
|
25
|
+
}), o = [
|
|
26
|
+
.001,
|
|
27
|
+
.01,
|
|
28
|
+
.02,
|
|
29
|
+
.04,
|
|
30
|
+
.05,
|
|
31
|
+
.1,
|
|
32
|
+
.125,
|
|
33
|
+
.2,
|
|
34
|
+
.25,
|
|
35
|
+
.5
|
|
36
|
+
], s = [
|
|
37
|
+
"1/1000",
|
|
38
|
+
"1/100",
|
|
39
|
+
"1/64",
|
|
40
|
+
"1/50",
|
|
41
|
+
"1/32",
|
|
42
|
+
"1/25",
|
|
43
|
+
"1/20",
|
|
44
|
+
"1/16",
|
|
45
|
+
"1/15",
|
|
46
|
+
"1/12",
|
|
47
|
+
"1/10",
|
|
48
|
+
"1/9",
|
|
49
|
+
"1/8",
|
|
50
|
+
"1/7",
|
|
51
|
+
"1/6",
|
|
52
|
+
"1/5",
|
|
53
|
+
"1/4",
|
|
54
|
+
"1/3",
|
|
55
|
+
"1/2"
|
|
56
|
+
], c = {
|
|
57
|
+
1: [
|
|
58
|
+
1,
|
|
59
|
+
2,
|
|
60
|
+
3,
|
|
61
|
+
4,
|
|
62
|
+
5,
|
|
63
|
+
6,
|
|
64
|
+
7,
|
|
65
|
+
8,
|
|
66
|
+
9,
|
|
67
|
+
10
|
|
68
|
+
],
|
|
69
|
+
2: [
|
|
70
|
+
1,
|
|
71
|
+
2,
|
|
72
|
+
4,
|
|
73
|
+
6,
|
|
74
|
+
8,
|
|
75
|
+
10
|
|
76
|
+
],
|
|
77
|
+
3: [
|
|
78
|
+
1,
|
|
79
|
+
3,
|
|
80
|
+
6,
|
|
81
|
+
9
|
|
82
|
+
],
|
|
83
|
+
4: [
|
|
84
|
+
1,
|
|
85
|
+
2,
|
|
86
|
+
4,
|
|
87
|
+
8
|
|
88
|
+
],
|
|
89
|
+
5: [
|
|
90
|
+
1,
|
|
91
|
+
5,
|
|
92
|
+
10
|
|
93
|
+
],
|
|
94
|
+
6: [
|
|
95
|
+
1,
|
|
96
|
+
2,
|
|
97
|
+
3,
|
|
98
|
+
6
|
|
99
|
+
],
|
|
100
|
+
7: [1, 7],
|
|
101
|
+
8: [
|
|
102
|
+
1,
|
|
103
|
+
2,
|
|
104
|
+
4,
|
|
105
|
+
8
|
|
106
|
+
],
|
|
107
|
+
9: [
|
|
108
|
+
1,
|
|
109
|
+
3,
|
|
110
|
+
9
|
|
111
|
+
],
|
|
112
|
+
10: [
|
|
113
|
+
1,
|
|
114
|
+
2,
|
|
115
|
+
5,
|
|
116
|
+
10
|
|
117
|
+
],
|
|
118
|
+
12: [
|
|
119
|
+
1,
|
|
120
|
+
2,
|
|
121
|
+
3,
|
|
122
|
+
4,
|
|
123
|
+
6
|
|
124
|
+
],
|
|
125
|
+
15: [
|
|
126
|
+
1,
|
|
127
|
+
3,
|
|
128
|
+
5
|
|
129
|
+
],
|
|
130
|
+
16: [
|
|
131
|
+
1,
|
|
132
|
+
2,
|
|
133
|
+
4,
|
|
134
|
+
8
|
|
135
|
+
],
|
|
136
|
+
20: [
|
|
137
|
+
1,
|
|
138
|
+
2,
|
|
139
|
+
4,
|
|
140
|
+
5,
|
|
141
|
+
10
|
|
142
|
+
],
|
|
143
|
+
25: [1, 5],
|
|
144
|
+
32: [
|
|
145
|
+
1,
|
|
146
|
+
2,
|
|
147
|
+
4,
|
|
148
|
+
8
|
|
149
|
+
],
|
|
150
|
+
50: [
|
|
151
|
+
1,
|
|
152
|
+
2,
|
|
153
|
+
5,
|
|
154
|
+
10
|
|
155
|
+
],
|
|
156
|
+
64: [
|
|
157
|
+
1,
|
|
158
|
+
2,
|
|
159
|
+
4,
|
|
160
|
+
8
|
|
161
|
+
],
|
|
162
|
+
100: [
|
|
163
|
+
1,
|
|
164
|
+
2,
|
|
165
|
+
4,
|
|
166
|
+
5,
|
|
167
|
+
10
|
|
168
|
+
],
|
|
169
|
+
1e3: [
|
|
170
|
+
1,
|
|
171
|
+
2,
|
|
172
|
+
4,
|
|
173
|
+
5,
|
|
174
|
+
8,
|
|
175
|
+
10
|
|
176
|
+
]
|
|
177
|
+
}, l = (e, n, r) => {
|
|
178
|
+
let i = t.mod(t.abs(e), t.abs(r));
|
|
179
|
+
if (!t.equal(i, 0)) throw Error("start point must be divisible by interval");
|
|
180
|
+
if (t.equal(e, n)) return [];
|
|
181
|
+
let a = t.subtract(n, t.mod(n, t.abs(r))), o = t.larger(r, 0) ? "positive" : "negative";
|
|
182
|
+
if (o === "negative" && t.largerEq(n, e)) throw Error("start must be > than end when doing a negative decrement");
|
|
183
|
+
if (o === "positive" && t.smallerEq(n, e)) throw Error("start must be < end when doing increments");
|
|
184
|
+
let s;
|
|
185
|
+
s = o === "positive" ? t.smallerEq : t.equal(a, n) ? t.largerEq : t.larger;
|
|
186
|
+
let c = [], l = e;
|
|
187
|
+
for (; s(l, a);) c.push(l), l = t.add(l, r);
|
|
188
|
+
return c;
|
|
189
|
+
}, u = (e, t) => `Can only do a positive or negative range, but got: start: ${e} and end:${t}`, d = (e, n, r) => {
|
|
190
|
+
e = t.fraction(e), n = t.fraction(n), r = t.fraction(r);
|
|
191
|
+
let i = t.abs(t.subtract(n, e));
|
|
192
|
+
if (t.larger(i, t.abs(n))) throw Error(u(e, n));
|
|
193
|
+
let a = {
|
|
194
|
+
start: t.abs(e),
|
|
195
|
+
end: t.abs(n),
|
|
196
|
+
interval: t.abs(r),
|
|
197
|
+
multiplier: t.smaller(r, 0) ? -1 : 1
|
|
198
|
+
}, o = t.mod(a.start, a.interval), s = l(t.larger(o, 0) ? t.add(t.subtract(a.start, o), a.interval) : a.start, a.end, a.interval), c = a.multiplier === -1 ? s.map((e) => t.multiply(e, -1)) : s;
|
|
199
|
+
return t.smaller(r, 0) && c.reverse(), c;
|
|
200
|
+
}, f = (e, n) => (e = t.fraction(e), n = t.fraction(n), t.smaller(e, n) ? e : n), p = (e, n) => (e = t.fraction(e), n = t.fraction(n), t.larger(e, n) ? e : n), m = (e, n, r) => {
|
|
201
|
+
e = t.fraction(e), n = t.fraction(n), r = t.fraction(r);
|
|
202
|
+
let a = t.larger(n, 0) ? d(p(0, e), n, r) : [];
|
|
203
|
+
return i((t.smaller(e, 0) ? d(f(0, n), e, t.multiply(r, -1)) : []).concat(a), t.equal);
|
|
204
|
+
}, h = (e, t, n) => {
|
|
205
|
+
n ||= 2;
|
|
206
|
+
let r = 10 ** -n / 2;
|
|
207
|
+
return Math.abs(e - t) < r;
|
|
208
|
+
}, g = (e, n, r) => t.smaller(y(e), y(n)) ? n : t.larger(y(e), y(r)) ? r : e, _ = (e, n) => {
|
|
209
|
+
let r = e.max - e.min, i = t.number(t.multiply(10, t.divide(t.fraction(r), n)));
|
|
210
|
+
return {
|
|
211
|
+
min: i,
|
|
212
|
+
max: t.number(t.multiply(20, i))
|
|
213
|
+
};
|
|
214
|
+
}, v = (e, n) => {
|
|
215
|
+
let r = t.mod(e, n);
|
|
216
|
+
return t.equal(r, 0);
|
|
217
|
+
}, y = (e) => {
|
|
218
|
+
if (r(e)) return t.fraction(e.n * e.s, e.d);
|
|
219
|
+
if (n(e)) return t.fraction(e);
|
|
220
|
+
}, b = (e, n, r, i) => {
|
|
221
|
+
let a = i ? i.limit !== !1 : !0, o = _(e, n), s = a ? g(y(r.minor), o.min, o.max) : y(r.minor), c = a ? g(y(r.major), s, t.multiply(s, 20)) : y(r.major);
|
|
222
|
+
if (!v(c, s)) {
|
|
223
|
+
let e = t.divide(c, s), n = e <= 2 ? 2 : Math.round(e);
|
|
224
|
+
return {
|
|
225
|
+
minor: s,
|
|
226
|
+
major: t.multiply(s, n)
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
major: c,
|
|
231
|
+
minor: s
|
|
232
|
+
};
|
|
233
|
+
}, x = (e, n, r, i) => (r = b(e, n, r, i), m(e.min, e.max, r.minor).filter((n) => t.smallerEq(n, t.fraction(e.max))).map((e) => {
|
|
234
|
+
let n = "minor", i = t.mod(e, r.major);
|
|
235
|
+
return h(t.number(i), 0) && (n = "major"), {
|
|
236
|
+
x: e,
|
|
237
|
+
type: n
|
|
238
|
+
};
|
|
239
|
+
})), S = (e) => {
|
|
240
|
+
let n = {
|
|
241
|
+
fraction: [],
|
|
242
|
+
decimal: []
|
|
243
|
+
};
|
|
244
|
+
return o.forEach((t) => {
|
|
245
|
+
t >= e.min && t <= e.max && n.decimal.push(t);
|
|
246
|
+
}), s.forEach((r) => {
|
|
247
|
+
let i = t.number(t.fraction(r));
|
|
248
|
+
i >= e.min && i <= e.max && n.fraction.push(r);
|
|
249
|
+
}), n;
|
|
250
|
+
}, C = (e, n, r) => {
|
|
251
|
+
let i = {
|
|
252
|
+
decimal: [],
|
|
253
|
+
fraction: []
|
|
254
|
+
}, a = t.fraction(t.number(t.number(e))), o = a.n, s = a.d;
|
|
255
|
+
if (o >= 1 && s === 1) for (let a = 1; a <= 10; a++) {
|
|
256
|
+
let s = t.number(t.multiply(o, a));
|
|
257
|
+
w(n, r, {
|
|
258
|
+
minor: e,
|
|
259
|
+
major: s
|
|
260
|
+
}, { fraction: void 0 }).filter((e) => e.type === "major").length > 1 && (i.fraction.push(s.toString()), i.decimal.push(s));
|
|
261
|
+
}
|
|
262
|
+
else for (let a in c[s]) {
|
|
263
|
+
let l = t.multiply(t.fraction(o, s), c[s][a]);
|
|
264
|
+
w(n, r, {
|
|
265
|
+
minor: e,
|
|
266
|
+
major: t.number(l)
|
|
267
|
+
}, { fraction: void 0 }).filter((e) => e.type === "major").length > 1 && (l.d === 1 ? i.fraction.push(l.n.toString()) : i.fraction.push(l.n + "/" + l.d), i.decimal.push(t.number(l)));
|
|
268
|
+
}
|
|
269
|
+
return i;
|
|
270
|
+
}, w = (e, n, r, i) => x(e, n, r, i).map((e) => i.fraction ? e : {
|
|
271
|
+
...e,
|
|
272
|
+
x: t.number(e.x) || 0
|
|
273
|
+
}), T = (e, n, r, i) => {
|
|
274
|
+
i = p(f(i, n), e);
|
|
275
|
+
let a = i.mod(r), o, s = r.div(2);
|
|
276
|
+
if (t.largerEq(t.abs(a), s)) {
|
|
277
|
+
let e = r.sub(t.abs(a)), n = t.largerEq(i, 0) ? "add" : "sub";
|
|
278
|
+
o = i[n](e);
|
|
279
|
+
} else {
|
|
280
|
+
let e = t.largerEq(i, 0) ? "sub" : "add";
|
|
281
|
+
o = i[e](t.abs(a));
|
|
282
|
+
}
|
|
283
|
+
return o;
|
|
284
|
+
}, E = (e, n, r, i) => {
|
|
285
|
+
let a = T(t.fraction(e), t.fraction(n), t.fraction(r), t.fraction(i));
|
|
286
|
+
return t.number(a);
|
|
287
|
+
}, D = (e, t, n) => n.map((n) => {
|
|
288
|
+
let r = Number.isFinite(n.size) ? E(0, n.size, t.minor, n.size) : void 0, i = E(e.min, e.max, t.minor, n.domainPosition), a = {
|
|
289
|
+
...n,
|
|
290
|
+
domainPosition: i
|
|
291
|
+
};
|
|
292
|
+
return Number.isFinite(r) && (a.size = r), a;
|
|
293
|
+
});
|
|
294
|
+
//#endregion
|
|
295
|
+
export { w as buildTickData, C as generateMajorValuesForMinor, S as generateMinorValues, _ as getMinorLimits, D as snapElements, E as snapTo, a as tick_utils_exports };
|