@pie-element/number-line 6.6.0 → 6.6.1-beta.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/package.json +3 -3
- package/controller/package.json +3 -3
- package/package.json +8 -7
- package/configure/lib/arrows.js +0 -117
- package/configure/lib/arrows.js.map +0 -1
- package/configure/lib/card-bar.js +0 -79
- package/configure/lib/card-bar.js.map +0 -1
- package/configure/lib/defaults.js +0 -68
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/domain.js +0 -106
- package/configure/lib/domain.js.map +0 -1
- package/configure/lib/index.js +0 -148
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -630
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/number-text-field.js +0 -97
- package/configure/lib/number-text-field.js.map +0 -1
- package/configure/lib/point-config.js +0 -145
- package/configure/lib/point-config.js.map +0 -1
- package/configure/lib/size.js +0 -58
- package/configure/lib/size.js.map +0 -1
- package/configure/lib/ticks.js +0 -92
- package/configure/lib/ticks.js.map +0 -1
- package/configure/lib/utils.js +0 -14
- package/configure/lib/utils.js.map +0 -1
- package/controller/lib/defaults.js +0 -47
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -443
- package/controller/lib/index.js.map +0 -1
- package/lib/data-converter.js +0 -100
- package/lib/data-converter.js.map +0 -1
- package/lib/draggable/index.js +0 -53
- package/lib/draggable/index.js.map +0 -1
- package/lib/index.js +0 -241
- package/lib/index.js.map +0 -1
- package/lib/number-line/colors.js +0 -21
- package/lib/number-line/colors.js.map +0 -1
- package/lib/number-line/feedback.js +0 -108
- package/lib/number-line/feedback.js.map +0 -1
- package/lib/number-line/graph/arrow.js +0 -63
- package/lib/number-line/graph/arrow.js.map +0 -1
- package/lib/number-line/graph/elements/base.js +0 -26
- package/lib/number-line/graph/elements/base.js.map +0 -1
- package/lib/number-line/graph/elements/builder.js +0 -38
- package/lib/number-line/graph/elements/builder.js.map +0 -1
- package/lib/number-line/graph/elements/line.js +0 -317
- package/lib/number-line/graph/elements/line.js.map +0 -1
- package/lib/number-line/graph/elements/point.js +0 -233
- package/lib/number-line/graph/elements/point.js.map +0 -1
- package/lib/number-line/graph/elements/ray.js +0 -227
- package/lib/number-line/graph/elements/ray.js.map +0 -1
- package/lib/number-line/graph/index.js +0 -326
- package/lib/number-line/graph/index.js.map +0 -1
- package/lib/number-line/graph/line.js +0 -48
- package/lib/number-line/graph/line.js.map +0 -1
- package/lib/number-line/graph/stacks.js +0 -101
- package/lib/number-line/graph/stacks.js.map +0 -1
- package/lib/number-line/graph/tick-utils.js +0 -295
- package/lib/number-line/graph/tick-utils.js.map +0 -1
- package/lib/number-line/graph/ticks.js +0 -244
- package/lib/number-line/graph/ticks.js.map +0 -1
- package/lib/number-line/index.js +0 -401
- package/lib/number-line/index.js.map +0 -1
- package/lib/number-line/point-chooser/button.js +0 -74
- package/lib/number-line/point-chooser/button.js.map +0 -1
- package/lib/number-line/point-chooser/img.js +0 -9
- package/lib/number-line/point-chooser/img.js.map +0 -1
- package/lib/number-line/point-chooser/index.js +0 -181
- package/lib/number-line/point-chooser/index.js.map +0 -1
- package/lib/number-line/point-chooser/styles.js +0 -98
- package/lib/number-line/point-chooser/styles.js.map +0 -1
- package/lib/number-line/transitions/fade.js +0 -67
- package/lib/number-line/transitions/fade.js.map +0 -1
- package/lib/number-line/transitions/index.js +0 -16
- package/lib/number-line/transitions/index.js.map +0 -1
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = exports.Ray = void 0;
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var colors = _interopRequireWildcard(require("../../colors"));
|
|
25
|
-
|
|
26
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
27
|
-
|
|
28
|
-
var _react = _interopRequireDefault(require("react"));
|
|
29
|
-
|
|
30
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
|
-
var _arrow = _interopRequireDefault(require("../arrow"));
|
|
33
|
-
|
|
34
|
-
var _point = _interopRequireDefault(require("./point"));
|
|
35
|
-
|
|
36
|
-
var _base = require("./base");
|
|
37
|
-
|
|
38
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
39
|
-
|
|
40
|
-
var _reactJss = _interopRequireDefault(require("react-jss"));
|
|
41
|
-
|
|
42
|
-
var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
|
|
43
|
-
|
|
44
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
|
-
|
|
46
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
|
-
|
|
48
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
49
|
-
|
|
50
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
51
|
-
|
|
52
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
53
|
-
|
|
54
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
55
|
-
|
|
56
|
-
var rayColor = function rayColor(_rayColor) {
|
|
57
|
-
return {
|
|
58
|
-
'& line': {
|
|
59
|
-
stroke: _rayColor
|
|
60
|
-
},
|
|
61
|
-
'& .arrow': {
|
|
62
|
-
fill: _rayColor,
|
|
63
|
-
strokeWidth: '1px',
|
|
64
|
-
stroke: _rayColor
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var style = {
|
|
70
|
-
ray: {
|
|
71
|
-
'& line': {
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
strokeWidth: '5px',
|
|
74
|
-
stroke: _renderUi.color.primary()
|
|
75
|
-
},
|
|
76
|
-
'& line, & .arrow': {
|
|
77
|
-
transition: 'stroke 150ms linear, fill 150ms linear'
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
selected: rayColor(colors.selected),
|
|
81
|
-
correct: rayColor(colors.correct),
|
|
82
|
-
incorrect: rayColor(colors.incorrect),
|
|
83
|
-
arrowCorrect: {
|
|
84
|
-
fill: colors.correct,
|
|
85
|
-
'--arrow-color': colors.correct
|
|
86
|
-
},
|
|
87
|
-
arrowIncorrect: {
|
|
88
|
-
fill: colors.incorrect,
|
|
89
|
-
'--arrow-color': colors.incorrect
|
|
90
|
-
},
|
|
91
|
-
arrowSelected: {
|
|
92
|
-
fill: colors.selected,
|
|
93
|
-
'--arrow-color': colors.selected
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
var Ray = /*#__PURE__*/function (_React$Component) {
|
|
98
|
-
(0, _inherits2["default"])(Ray, _React$Component);
|
|
99
|
-
|
|
100
|
-
var _super = _createSuper(Ray);
|
|
101
|
-
|
|
102
|
-
function Ray(props) {
|
|
103
|
-
var _this;
|
|
104
|
-
|
|
105
|
-
(0, _classCallCheck2["default"])(this, Ray);
|
|
106
|
-
_this = _super.call(this, props);
|
|
107
|
-
_this.state = {
|
|
108
|
-
dragPosition: null
|
|
109
|
-
};
|
|
110
|
-
return _this;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
(0, _createClass2["default"])(Ray, [{
|
|
114
|
-
key: "drag",
|
|
115
|
-
value: function drag(p) {
|
|
116
|
-
var domain = this.props.domain;
|
|
117
|
-
|
|
118
|
-
if (p >= domain.min && p <= domain.max) {
|
|
119
|
-
this.setState({
|
|
120
|
-
dragPosition: p
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "stopDrag",
|
|
126
|
-
value: function stopDrag() {
|
|
127
|
-
this.setState({
|
|
128
|
-
dragPosition: null
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}, {
|
|
132
|
-
key: "render",
|
|
133
|
-
value: function render() {
|
|
134
|
-
var _classNames, _classNames2;
|
|
135
|
-
|
|
136
|
-
/* eslint-disable */
|
|
137
|
-
var _this$props = this.props,
|
|
138
|
-
interval = _this$props.interval,
|
|
139
|
-
empty = _this$props.empty,
|
|
140
|
-
position = _this$props.position,
|
|
141
|
-
direction = _this$props.direction,
|
|
142
|
-
domain = _this$props.domain,
|
|
143
|
-
y = _this$props.y,
|
|
144
|
-
selected = _this$props.selected,
|
|
145
|
-
disabled = _this$props.disabled,
|
|
146
|
-
width = _this$props.width,
|
|
147
|
-
correct = _this$props.correct,
|
|
148
|
-
classes = _this$props.classes;
|
|
149
|
-
/* eslint-enable */
|
|
150
|
-
|
|
151
|
-
var xScale = this.context.xScale;
|
|
152
|
-
var drag = this.drag.bind(this);
|
|
153
|
-
var stopDrag = this.stopDrag.bind(this);
|
|
154
|
-
var finalPosition = (0, _isNumber["default"])(this.state.dragPosition) ? this.state.dragPosition : position;
|
|
155
|
-
var className = (0, _classnames["default"])(classes.ray, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.selected, selected), (0, _defineProperty2["default"])(_classNames, classes.correct, correct === true), (0, _defineProperty2["default"])(_classNames, classes.incorrect, correct === false), _classNames));
|
|
156
|
-
var positive = direction === 'positive';
|
|
157
|
-
var left = positive ? finalPosition : domain.min;
|
|
158
|
-
var right = positive ? domain.max : finalPosition; // const triangleX = positive ? xScale(right) : xScale(left);
|
|
159
|
-
//const et the line run all the way to 0 or width.
|
|
160
|
-
|
|
161
|
-
var x1 = positive ? xScale(left) : 8;
|
|
162
|
-
var x2 = positive ? width - 8 : xScale(right);
|
|
163
|
-
var arrowX = positive ? width : 0;
|
|
164
|
-
var arrowDirection = positive ? 'right' : 'left';
|
|
165
|
-
|
|
166
|
-
var noop = function noop() {};
|
|
167
|
-
|
|
168
|
-
var arrowClassNames = (0, _classnames["default"])((_classNames2 = {}, (0, _defineProperty2["default"])(_classNames2, classes.arrowCorrect, correct === true), (0, _defineProperty2["default"])(_classNames2, classes.arrowIncorrect, correct === false), (0, _defineProperty2["default"])(_classNames2, classes.arrowSelected, selected), _classNames2));
|
|
169
|
-
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
170
|
-
className: className,
|
|
171
|
-
transform: "translate(0, ".concat(y, ")")
|
|
172
|
-
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
173
|
-
onClick: disabled ? noop : this.props.onToggleSelect,
|
|
174
|
-
className: "line-handle",
|
|
175
|
-
x1: x1,
|
|
176
|
-
x2: x2
|
|
177
|
-
}), /*#__PURE__*/_react["default"].createElement(_point["default"], {
|
|
178
|
-
disabled: disabled,
|
|
179
|
-
correct: correct,
|
|
180
|
-
selected: selected,
|
|
181
|
-
empty: empty,
|
|
182
|
-
interval: interval,
|
|
183
|
-
bounds: {
|
|
184
|
-
left: domain.min - position,
|
|
185
|
-
right: domain.max - position
|
|
186
|
-
},
|
|
187
|
-
position: position,
|
|
188
|
-
onDrag: drag,
|
|
189
|
-
onDragStop: stopDrag,
|
|
190
|
-
onMove: this.props.onMove
|
|
191
|
-
}), /*#__PURE__*/_react["default"].createElement(_arrow["default"], {
|
|
192
|
-
x: arrowX,
|
|
193
|
-
className: arrowClassNames,
|
|
194
|
-
direction: arrowDirection
|
|
195
|
-
}));
|
|
196
|
-
}
|
|
197
|
-
}]);
|
|
198
|
-
return Ray;
|
|
199
|
-
}(_react["default"].Component);
|
|
200
|
-
|
|
201
|
-
exports.Ray = Ray;
|
|
202
|
-
(0, _defineProperty2["default"])(Ray, "propTypes", _objectSpread(_objectSpread({}, (0, _base.basePropTypes)()), {}, {
|
|
203
|
-
width: _propTypes["default"].number.isRequired,
|
|
204
|
-
selected: _propTypes["default"].bool,
|
|
205
|
-
disabled: _propTypes["default"].bool,
|
|
206
|
-
empty: _propTypes["default"].bool,
|
|
207
|
-
direction: _propTypes["default"].oneOf(['positive', 'negative']),
|
|
208
|
-
y: _propTypes["default"].number,
|
|
209
|
-
position: _propTypes["default"].number.isRequired,
|
|
210
|
-
onMove: _propTypes["default"].func.isRequired,
|
|
211
|
-
onToggleSelect: _propTypes["default"].func.isRequired
|
|
212
|
-
}));
|
|
213
|
-
(0, _defineProperty2["default"])(Ray, "defaultProps", {
|
|
214
|
-
selected: false,
|
|
215
|
-
direction: 'positive',
|
|
216
|
-
y: 0,
|
|
217
|
-
disabled: false
|
|
218
|
-
});
|
|
219
|
-
(0, _defineProperty2["default"])(Ray, "contextTypes", {
|
|
220
|
-
xScale: _propTypes["default"].func.isRequired,
|
|
221
|
-
snapValue: _propTypes["default"].func.isRequired
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
var _default = (0, _reactJss["default"])(style)(Ray);
|
|
225
|
-
|
|
226
|
-
exports["default"] = _default;
|
|
227
|
-
//# sourceMappingURL=ray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/number-line/graph/elements/ray.jsx"],"names":["rayColor","stroke","fill","strokeWidth","style","ray","cursor","color","primary","transition","selected","colors","correct","incorrect","arrowCorrect","arrowIncorrect","arrowSelected","Ray","props","state","dragPosition","p","domain","min","max","setState","interval","empty","position","direction","y","disabled","width","classes","xScale","context","drag","bind","stopDrag","finalPosition","className","positive","left","right","x1","x2","arrowX","arrowDirection","noop","arrowClassNames","onToggleSelect","onMove","React","Component","PropTypes","number","isRequired","bool","oneOf","func","snapValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,kBAACA,SAAD;AAAA,SAAe;AAC9B,cAAU;AACRC,MAAAA,MAAM,EAAED;AADA,KADoB;AAI9B,gBAAY;AACVE,MAAAA,IAAI,EAAEF,SADI;AAEVG,MAAAA,WAAW,EAAE,KAFH;AAGVF,MAAAA,MAAM,EAAED;AAHE;AAJkB,GAAf;AAAA,CAAjB;;AAWA,IAAMI,KAAK,GAAG;AACZC,EAAAA,GAAG,EAAE;AACH,cAAU;AACRC,MAAAA,MAAM,EAAE,SADA;AAERH,MAAAA,WAAW,EAAE,KAFL;AAGRF,MAAAA,MAAM,EAAEM,gBAAMC,OAAN;AAHA,KADP;AAMH,wBAAoB;AAClBC,MAAAA,UAAU,EAAE;AADM;AANjB,GADO;AAWZC,EAAAA,QAAQ,EAAEV,QAAQ,CAACW,MAAM,CAACD,QAAR,CAXN;AAYZE,EAAAA,OAAO,EAAEZ,QAAQ,CAACW,MAAM,CAACC,OAAR,CAZL;AAaZC,EAAAA,SAAS,EAAEb,QAAQ,CAACW,MAAM,CAACE,SAAR,CAbP;AAcZC,EAAAA,YAAY,EAAE;AACZZ,IAAAA,IAAI,EAAES,MAAM,CAACC,OADD;AAEZ,qBAAiBD,MAAM,CAACC;AAFZ,GAdF;AAkBZG,EAAAA,cAAc,EAAE;AACdb,IAAAA,IAAI,EAAES,MAAM,CAACE,SADC;AAEd,qBAAiBF,MAAM,CAACE;AAFV,GAlBJ;AAsBZG,EAAAA,aAAa,EAAE;AACbd,IAAAA,IAAI,EAAES,MAAM,CAACD,QADA;AAEb,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BAcW;AACpBP,EAAAA,QAAQ,EAAE,KADU;AAEpBmB,EAAAA,SAAS,EAAE,UAFS;AAGpBC,EAAAA,CAAC,EAAE,CAHiB;AAIpBC,EAAAA,QAAQ,EAAE;AAJU,C;iCAdXd,G,kBAqBW;AACpBiB,EAAAA,MAAM,EAAEoB,sBAAUK,IAAV,CAAeH,UADH;AAEpBI,EAAAA,SAAS,EAAEN,sBAAUK,IAAV,CAAeH;AAFN,C;;eAgFT,0BAAYpD,KAAZ,EAAmBa,GAAnB,C","sourcesContent":["import * as colors from '../../colors';\nimport { color } from '@pie-lib/render-ui';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport Arrow from '../arrow';\nimport Point from './point';\nimport { basePropTypes } from './base';\nimport classNames from 'classnames';\nimport injectSheet from 'react-jss';\nimport isNumber from 'lodash/isNumber';\n\nconst rayColor = (rayColor) => ({\n '& line': {\n stroke: rayColor,\n },\n '& .arrow': {\n fill: rayColor,\n strokeWidth: '1px',\n stroke: rayColor,\n },\n});\n\nconst style = {\n ray: {\n '& line': {\n cursor: 'pointer',\n strokeWidth: '5px',\n stroke: color.primary(),\n },\n '& line, & .arrow': {\n transition: 'stroke 150ms linear, fill 150ms linear',\n },\n },\n selected: rayColor(colors.selected),\n correct: rayColor(colors.correct),\n incorrect: rayColor(colors.incorrect),\n arrowCorrect: {\n fill: colors.correct,\n '--arrow-color': colors.correct,\n },\n arrowIncorrect: {\n fill: colors.incorrect,\n '--arrow-color': colors.incorrect,\n },\n arrowSelected: {\n fill: colors.selected,\n '--arrow-color': colors.selected,\n },\n};\n\nexport class Ray extends React.Component {\n static propTypes = {\n ...basePropTypes(),\n width: PropTypes.number.isRequired,\n selected: PropTypes.bool,\n disabled: PropTypes.bool,\n empty: PropTypes.bool,\n direction: PropTypes.oneOf(['positive', 'negative']),\n y: PropTypes.number,\n position: PropTypes.number.isRequired,\n onMove: PropTypes.func.isRequired,\n onToggleSelect: PropTypes.func.isRequired,\n };\n\n static defaultProps = {\n selected: false,\n direction: 'positive',\n y: 0,\n disabled: false,\n };\n\n static contextTypes = {\n xScale: PropTypes.func.isRequired,\n snapValue: PropTypes.func.isRequired,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n dragPosition: null,\n };\n }\n\n drag(p) {\n const { domain } = this.props;\n if (p >= domain.min && p <= domain.max) {\n this.setState({ dragPosition: p });\n }\n }\n\n stopDrag() {\n this.setState({ dragPosition: null });\n }\n\n render() {\n /* eslint-disable */\n const { interval, empty, position, direction, domain, y, selected, disabled, width, correct, classes } = this.props;\n /* eslint-enable */\n const { xScale } = this.context;\n\n const drag = this.drag.bind(this);\n const stopDrag = this.stopDrag.bind(this);\n\n const finalPosition = isNumber(this.state.dragPosition) ? this.state.dragPosition : position;\n\n const className = classNames(classes.ray, {\n [classes.selected]: selected,\n [classes.correct]: correct === true,\n [classes.incorrect]: correct === false,\n });\n\n const positive = direction === 'positive';\n const left = positive ? finalPosition : domain.min;\n const right = positive ? domain.max : finalPosition;\n // const triangleX = positive ? xScale(right) : xScale(left);\n\n //const et the line run all the way to 0 or width.\n const x1 = positive ? xScale(left) : 8;\n const x2 = positive ? width - 8 : xScale(right);\n const arrowX = positive ? width : 0;\n const arrowDirection = positive ? 'right' : 'left';\n\n const noop = () => {};\n\n const arrowClassNames = classNames({\n [classes.arrowCorrect]: correct === true,\n [classes.arrowIncorrect]: correct === false,\n [classes.arrowSelected]: selected,\n });\n\n return (\n <g className={className} transform={`translate(0, ${y})`}>\n <line onClick={disabled ? noop : this.props.onToggleSelect} className=\"line-handle\" x1={x1} x2={x2} />\n <Point\n disabled={disabled}\n correct={correct}\n selected={selected}\n empty={empty}\n interval={interval}\n bounds={{ left: domain.min - position, right: domain.max - position }}\n position={position}\n onDrag={drag}\n onDragStop={stopDrag}\n onMove={this.props.onMove}\n />\n <Arrow x={arrowX} className={arrowClassNames} direction={arrowDirection} />\n </g>\n );\n }\n}\n\nexport default injectSheet(style)(Ray);\n"],"file":"ray.js"}
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.NumberLineGraph = void 0;
|
|
9
|
-
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
|
-
var _d3Scale = require("d3-scale");
|
|
27
|
-
|
|
28
|
-
var _d3Selection = require("d3-selection");
|
|
29
|
-
|
|
30
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
31
|
-
|
|
32
|
-
var _point = _interopRequireDefault(require("./elements/point"));
|
|
33
|
-
|
|
34
|
-
var _line = _interopRequireDefault(require("./elements/line"));
|
|
35
|
-
|
|
36
|
-
var _ray = _interopRequireDefault(require("./elements/ray"));
|
|
37
|
-
|
|
38
|
-
var _line2 = _interopRequireDefault(require("./line"));
|
|
39
|
-
|
|
40
|
-
var _arrow = _interopRequireDefault(require("./arrow"));
|
|
41
|
-
|
|
42
|
-
var _ticks = _interopRequireDefault(require("./ticks"));
|
|
43
|
-
|
|
44
|
-
var _tickUtils = require("./tick-utils");
|
|
45
|
-
|
|
46
|
-
var _stacks = _interopRequireDefault(require("./stacks"));
|
|
47
|
-
|
|
48
|
-
var _reactTransitionGroup = require("react-transition-group");
|
|
49
|
-
|
|
50
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
51
|
-
|
|
52
|
-
var _transitions = require("../transitions");
|
|
53
|
-
|
|
54
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
55
|
-
|
|
56
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
|
-
|
|
58
|
-
var getXScale = function getXScale(min, max, width, padding) {
|
|
59
|
-
if (min === undefined || max === undefined || width === undefined) {
|
|
60
|
-
throw new Error('missing min/max/width');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (0, _d3Scale.scaleLinear)().domain([min, max]).range([padding, width - padding]);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var Debug = function Debug(props) {
|
|
67
|
-
return /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("text", {
|
|
68
|
-
x: "00",
|
|
69
|
-
y: "20"
|
|
70
|
-
}, JSON.stringify(props)));
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
var NumberLineGraph = /*#__PURE__*/function (_React$Component) {
|
|
74
|
-
(0, _inherits2["default"])(NumberLineGraph, _React$Component);
|
|
75
|
-
|
|
76
|
-
var _super = _createSuper(NumberLineGraph);
|
|
77
|
-
|
|
78
|
-
function NumberLineGraph(props) {
|
|
79
|
-
var _this;
|
|
80
|
-
|
|
81
|
-
(0, _classCallCheck2["default"])(this, NumberLineGraph);
|
|
82
|
-
_this = _super.call(this, props);
|
|
83
|
-
_this.state = {};
|
|
84
|
-
return _this;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
(0, _createClass2["default"])(NumberLineGraph, [{
|
|
88
|
-
key: "xScaleFn",
|
|
89
|
-
value: function xScaleFn() {
|
|
90
|
-
var _this$props = this.props,
|
|
91
|
-
domain = _this$props.domain,
|
|
92
|
-
width = _this$props.width;
|
|
93
|
-
|
|
94
|
-
var _ref = domain || {},
|
|
95
|
-
max = _ref.max,
|
|
96
|
-
min = _ref.min;
|
|
97
|
-
|
|
98
|
-
var padding = 20;
|
|
99
|
-
|
|
100
|
-
if (max) {
|
|
101
|
-
padding = max.toString().length * 4 + 15;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return getXScale(min, max, width, padding);
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "snapValueFn",
|
|
108
|
-
value: function snapValueFn() {
|
|
109
|
-
var _this$props2 = this.props,
|
|
110
|
-
domain = _this$props2.domain,
|
|
111
|
-
ticks = _this$props2.ticks;
|
|
112
|
-
return _tickUtils.snapTo.bind(null, domain.min, domain.max, ticks.minor);
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "getChildContext",
|
|
116
|
-
value: function getChildContext() {
|
|
117
|
-
return {
|
|
118
|
-
xScale: this.xScaleFn(),
|
|
119
|
-
snapValue: this.snapValueFn()
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Note: we use d3 click + mouse to give us domain values directly.
|
|
124
|
-
* Saves us having to calculate them ourselves from a MouseEvent.
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
}, {
|
|
128
|
-
key: "onRectClick",
|
|
129
|
-
value: function onRectClick(rect) {
|
|
130
|
-
var _this$props3 = this.props,
|
|
131
|
-
elements = _this$props3.elements,
|
|
132
|
-
disabled = _this$props3.disabled;
|
|
133
|
-
|
|
134
|
-
if (disabled) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var anyElementSelected = elements.some(function (e) {
|
|
139
|
-
return e.selected;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (anyElementSelected) {
|
|
143
|
-
this.props.onDeselectElements();
|
|
144
|
-
} else {
|
|
145
|
-
var coords = (0, _d3Selection.mouse)(rect._groups[0][0]);
|
|
146
|
-
var x = this.xScaleFn().invert(coords[0]);
|
|
147
|
-
this.addElement(x);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "componentDidMount",
|
|
152
|
-
value: function componentDidMount() {
|
|
153
|
-
var rect = (0, _d3Selection.select)(this.rect);
|
|
154
|
-
rect.on('click', this.onRectClick.bind(this, rect));
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
157
|
-
key: "addElement",
|
|
158
|
-
value: function addElement(x) {
|
|
159
|
-
var snapFn = this.snapValueFn();
|
|
160
|
-
var v = snapFn(x);
|
|
161
|
-
this.props.onAddElement(v);
|
|
162
|
-
}
|
|
163
|
-
}, {
|
|
164
|
-
key: "render",
|
|
165
|
-
value: function render() {
|
|
166
|
-
var _this2 = this;
|
|
167
|
-
|
|
168
|
-
var _this$props4 = this.props,
|
|
169
|
-
domain = _this$props4.domain,
|
|
170
|
-
width = _this$props4.width,
|
|
171
|
-
ticks = _this$props4.ticks,
|
|
172
|
-
height = _this$props4.height,
|
|
173
|
-
onToggleElement = _this$props4.onToggleElement,
|
|
174
|
-
onMoveElement = _this$props4.onMoveElement,
|
|
175
|
-
disabled = _this$props4.disabled,
|
|
176
|
-
fraction = _this$props4.fraction;
|
|
177
|
-
var arrows = this.props.arrows;
|
|
178
|
-
arrows = arrows || {
|
|
179
|
-
left: true,
|
|
180
|
-
right: true
|
|
181
|
-
};
|
|
182
|
-
var min = domain.min,
|
|
183
|
-
max = domain.max;
|
|
184
|
-
|
|
185
|
-
if (domain.max <= domain.min) {
|
|
186
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, domain.max, " is less than or equal to ", domain.min);
|
|
187
|
-
} else {
|
|
188
|
-
var lineY = height - 30;
|
|
189
|
-
var stacks = new _stacks["default"](domain);
|
|
190
|
-
var elements = this.props.elements.map(function (el, index) {
|
|
191
|
-
var stackIndex = stacks.add(el);
|
|
192
|
-
|
|
193
|
-
if (stackIndex === -1) {
|
|
194
|
-
throw new Error('stack index is -1, cant add element');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
var y = lineY - stackIndex * 25;
|
|
198
|
-
var commonProps = {
|
|
199
|
-
key: index,
|
|
200
|
-
y: y,
|
|
201
|
-
selected: el.selected && !disabled,
|
|
202
|
-
interval: ticks.minor,
|
|
203
|
-
disabled: disabled,
|
|
204
|
-
correct: el.correct
|
|
205
|
-
};
|
|
206
|
-
var toggleElement = onToggleElement.bind(null, index, el);
|
|
207
|
-
var moveElement = onMoveElement.bind(null, index, el);
|
|
208
|
-
|
|
209
|
-
if (el.type === 'line') {
|
|
210
|
-
var empty = {
|
|
211
|
-
left: el.leftPoint === 'empty',
|
|
212
|
-
right: el.rightPoint === 'empty'
|
|
213
|
-
};
|
|
214
|
-
return /*#__PURE__*/_react["default"].createElement(_line["default"], (0, _extends2["default"])({}, commonProps, {
|
|
215
|
-
domain: {
|
|
216
|
-
min: min,
|
|
217
|
-
max: max
|
|
218
|
-
},
|
|
219
|
-
onMoveLine: moveElement,
|
|
220
|
-
onToggleSelect: toggleElement,
|
|
221
|
-
position: el.position,
|
|
222
|
-
empty: empty
|
|
223
|
-
}));
|
|
224
|
-
} else if (el.type === 'point') {
|
|
225
|
-
var bounds = {
|
|
226
|
-
left: min - el.position,
|
|
227
|
-
right: max - el.position
|
|
228
|
-
};
|
|
229
|
-
return /*#__PURE__*/_react["default"].createElement(_point["default"], (0, _extends2["default"])({}, commonProps, {
|
|
230
|
-
empty: el.pointType === 'empty',
|
|
231
|
-
position: el.position,
|
|
232
|
-
bounds: bounds,
|
|
233
|
-
onClick: toggleElement,
|
|
234
|
-
onMove: moveElement
|
|
235
|
-
}));
|
|
236
|
-
} else if (el.type === 'ray') {
|
|
237
|
-
return /*#__PURE__*/_react["default"].createElement(_ray["default"], (0, _extends2["default"])({}, commonProps, {
|
|
238
|
-
domain: {
|
|
239
|
-
min: min,
|
|
240
|
-
max: max
|
|
241
|
-
},
|
|
242
|
-
direction: el.direction,
|
|
243
|
-
position: el.position,
|
|
244
|
-
onMove: moveElement,
|
|
245
|
-
onToggleSelect: toggleElement,
|
|
246
|
-
width: width,
|
|
247
|
-
empty: el.pointType === 'empty'
|
|
248
|
-
}));
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
252
|
-
width: width,
|
|
253
|
-
height: fraction ? height + 20 : height
|
|
254
|
-
}, false && /*#__PURE__*/_react["default"].createElement(Debug, {
|
|
255
|
-
domain: domain,
|
|
256
|
-
ticks: ticks
|
|
257
|
-
}), /*#__PURE__*/_react["default"].createElement(_line2["default"], {
|
|
258
|
-
y: lineY,
|
|
259
|
-
width: width
|
|
260
|
-
}), arrows.left && /*#__PURE__*/_react["default"].createElement(_arrow["default"], {
|
|
261
|
-
y: lineY
|
|
262
|
-
}), arrows.right && /*#__PURE__*/_react["default"].createElement(_arrow["default"], {
|
|
263
|
-
x: width,
|
|
264
|
-
y: lineY,
|
|
265
|
-
direction: "right"
|
|
266
|
-
}), /*#__PURE__*/_react["default"].createElement(_ticks["default"], {
|
|
267
|
-
y: lineY,
|
|
268
|
-
domain: domain,
|
|
269
|
-
ticks: ticks,
|
|
270
|
-
fraction: fraction
|
|
271
|
-
}), /*#__PURE__*/_react["default"].createElement("rect", {
|
|
272
|
-
ref: function ref(rect) {
|
|
273
|
-
return _this2.rect = rect;
|
|
274
|
-
} //need to have a fill for it to be clickable
|
|
275
|
-
,
|
|
276
|
-
fill: _renderUi.color.primary(),
|
|
277
|
-
fillOpacity: "0.0",
|
|
278
|
-
width: width,
|
|
279
|
-
height: height
|
|
280
|
-
}), /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.TransitionGroup, {
|
|
281
|
-
component: "g"
|
|
282
|
-
}, elements.map(function (c, index) {
|
|
283
|
-
return /*#__PURE__*/_react["default"].createElement(_transitions.Fade, {
|
|
284
|
-
key: index
|
|
285
|
-
}, c);
|
|
286
|
-
})));
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}]);
|
|
290
|
-
return NumberLineGraph;
|
|
291
|
-
}(_react["default"].Component);
|
|
292
|
-
|
|
293
|
-
exports.NumberLineGraph = NumberLineGraph;
|
|
294
|
-
(0, _defineProperty2["default"])(NumberLineGraph, "childContextTypes", {
|
|
295
|
-
xScale: _propTypes["default"].func.isRequired,
|
|
296
|
-
snapValue: _propTypes["default"].func.isRequired
|
|
297
|
-
});
|
|
298
|
-
(0, _defineProperty2["default"])(NumberLineGraph, "propTypes", {
|
|
299
|
-
domain: _propTypes["default"].shape({
|
|
300
|
-
min: _propTypes["default"].number.isRequired,
|
|
301
|
-
max: _propTypes["default"].number.isRequired
|
|
302
|
-
}).isRequired,
|
|
303
|
-
ticks: _propTypes["default"].shape({
|
|
304
|
-
minor: _propTypes["default"].number,
|
|
305
|
-
major: _propTypes["default"].number
|
|
306
|
-
}).isRequired,
|
|
307
|
-
width: _propTypes["default"].number.isRequired,
|
|
308
|
-
height: _propTypes["default"].number.isRequired,
|
|
309
|
-
onToggleElement: _propTypes["default"].func.isRequired,
|
|
310
|
-
onMoveElement: _propTypes["default"].func.isRequired,
|
|
311
|
-
onAddElement: _propTypes["default"].func.isRequired,
|
|
312
|
-
debug: _propTypes["default"].bool,
|
|
313
|
-
elements: _propTypes["default"].array,
|
|
314
|
-
disabled: _propTypes["default"].bool,
|
|
315
|
-
onDeselectElements: _propTypes["default"].func,
|
|
316
|
-
arrows: _propTypes["default"].shape({
|
|
317
|
-
left: _propTypes["default"].bool,
|
|
318
|
-
right: _propTypes["default"].bool
|
|
319
|
-
})
|
|
320
|
-
});
|
|
321
|
-
(0, _defineProperty2["default"])(NumberLineGraph, "defaultProps", {
|
|
322
|
-
debug: false
|
|
323
|
-
});
|
|
324
|
-
var _default = NumberLineGraph;
|
|
325
|
-
exports["default"] = _default;
|
|
326
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/number-line/graph/index.jsx"],"names":["getXScale","min","max","width","padding","undefined","Error","domain","range","Debug","props","JSON","stringify","NumberLineGraph","state","toString","length","ticks","snapTo","bind","minor","xScale","xScaleFn","snapValue","snapValueFn","rect","elements","disabled","anyElementSelected","some","e","selected","onDeselectElements","coords","_groups","x","invert","addElement","on","onRectClick","snapFn","v","onAddElement","height","onToggleElement","onMoveElement","fraction","arrows","left","right","lineY","stacks","Stacks","map","el","index","stackIndex","add","y","commonProps","key","interval","correct","toggleElement","moveElement","type","empty","leftPoint","rightPoint","position","bounds","pointType","direction","color","primary","c","React","Component","PropTypes","func","isRequired","shape","number","major","debug","bool","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAMC,GAAN,EAAWC,KAAX,EAAkBC,OAAlB,EAA8B;AAC9C,MAAIH,GAAG,KAAKI,SAAR,IAAqBH,GAAG,KAAKG,SAA7B,IAA0CF,KAAK,KAAKE,SAAxD,EAAmE;AACjE,UAAM,IAAIC,KAAJ,CAAU,uBAAV,CAAN;AACD;;AAED,SAAO,4BACJC,MADI,CACG,CAACN,GAAD,EAAMC,GAAN,CADH,EAEJM,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jBI,EAAAA,KAAK,EAAEN,sBAAUO,IAXA;AAYjB3D,EAAAA,QAAQ,EAAEoD,sBAAUQ,KAZH;AAajB3D,EAAAA,QAAQ,EAAEmD,sBAAUO,IAbH;AAcjBrD,EAAAA,kBAAkB,EAAE8C,sBAAUC,IAdb;AAejBhC,EAAAA,MAAM,EAAE+B,sBAAUG,KAAV,CAAgB;AAAEjC,IAAAA,IAAI,EAAE8B,sBAAUO,IAAlB;AAAwBpC,IAAAA,KAAK,EAAE6B,sBAAUO;AAAzC,GAAhB;AAfS,C;iCANRxE,e,kBAwBW;AACpBuE,EAAAA,KAAK,EAAE;AADa,C;eAoLTvE,e","sourcesContent":["import React from 'react';\nimport { scaleLinear } from 'd3-scale';\nimport { select, mouse } from 'd3-selection';\nimport { color } from '@pie-lib/render-ui';\nimport Point from './elements/point';\nimport Line from './elements/line';\nimport Ray from './elements/ray';\nimport BaseLine from './line';\nimport Arrow from './arrow';\nimport Ticks from './ticks';\nimport { snapTo } from './tick-utils';\nimport Stacks from './stacks';\nimport { TransitionGroup } from 'react-transition-group';\nimport PropTypes from 'prop-types';\nimport { Fade } from '../transitions';\n\nconst getXScale = (min, max, width, padding) => {\n if (min === undefined || max === undefined || width === undefined) {\n throw new Error('missing min/max/width');\n }\n\n return scaleLinear()\n .domain([min, max])\n .range([padding, width - padding]);\n};\n\nconst Debug = (props) => (\n <g>\n <text x=\"00\" y=\"20\">\n {JSON.stringify(props)}\n </text>\n </g>\n);\n\nexport class NumberLineGraph extends React.Component {\n static childContextTypes = {\n xScale: PropTypes.func.isRequired,\n snapValue: PropTypes.func.isRequired,\n };\n\n static propTypes = {\n domain: PropTypes.shape({\n min: PropTypes.number.isRequired,\n max: PropTypes.number.isRequired,\n }).isRequired,\n ticks: PropTypes.shape({ minor: PropTypes.number, major: PropTypes.number }).isRequired,\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n onToggleElement: PropTypes.func.isRequired,\n onMoveElement: PropTypes.func.isRequired,\n onAddElement: PropTypes.func.isRequired,\n debug: PropTypes.bool,\n elements: PropTypes.array,\n disabled: PropTypes.bool,\n onDeselectElements: PropTypes.func,\n arrows: PropTypes.shape({ left: PropTypes.bool, right: PropTypes.bool }),\n };\n\n static defaultProps = {\n debug: false,\n };\n\n constructor(props) {\n super(props);\n this.state = {};\n }\n\n xScaleFn() {\n const { domain, width } = this.props;\n const { max, min } = domain || {};\n\n let padding = 20;\n\n if (max) {\n padding = max.toString().length * 4 + 15;\n }\n\n return getXScale(min, max, width, padding);\n }\n\n snapValueFn() {\n const { domain, ticks } = this.props;\n return snapTo.bind(null, domain.min, domain.max, ticks.minor);\n }\n\n getChildContext() {\n return {\n xScale: this.xScaleFn(),\n snapValue: this.snapValueFn(),\n };\n }\n\n /**\n * Note: we use d3 click + mouse to give us domain values directly.\n * Saves us having to calculate them ourselves from a MouseEvent.\n */\n onRectClick(rect) {\n const { elements, disabled } = this.props;\n\n if (disabled) {\n return;\n }\n\n const anyElementSelected = elements.some((e) => e.selected);\n\n if (anyElementSelected) {\n this.props.onDeselectElements();\n } else {\n var coords = mouse(rect._groups[0][0]);\n const x = this.xScaleFn().invert(coords[0]);\n this.addElement(x);\n }\n }\n\n componentDidMount() {\n const rect = select(this.rect);\n rect.on('click', this.onRectClick.bind(this, rect));\n }\n\n addElement(x) {\n const snapFn = this.snapValueFn();\n const v = snapFn(x);\n this.props.onAddElement(v);\n }\n\n render() {\n const { domain, width, ticks, height, onToggleElement, onMoveElement, disabled, fraction } = this.props;\n let { arrows } = this.props;\n\n arrows = arrows || { left: true, right: true };\n const { min, max } = domain;\n\n if (domain.max <= domain.min) {\n return (\n <div>\n {domain.max} is less than or equal to {domain.min}\n </div>\n );\n } else {\n const lineY = height - 30;\n\n const stacks = new Stacks(domain);\n\n const elements = this.props.elements.map((el, index) => {\n const stackIndex = stacks.add(el);\n\n if (stackIndex === -1) {\n throw new Error('stack index is -1, cant add element');\n }\n\n const y = lineY - stackIndex * 25;\n\n const commonProps = {\n key: index,\n y,\n selected: el.selected && !disabled,\n interval: ticks.minor,\n disabled,\n correct: el.correct,\n };\n\n const toggleElement = onToggleElement.bind(null, index, el);\n const moveElement = onMoveElement.bind(null, index, el);\n\n if (el.type === 'line') {\n const empty = {\n left: el.leftPoint === 'empty',\n right: el.rightPoint === 'empty',\n };\n\n return (\n <Line\n {...commonProps}\n domain={{ min: min, max: max }}\n onMoveLine={moveElement}\n onToggleSelect={toggleElement}\n position={el.position}\n empty={empty}\n />\n );\n } else if (el.type === 'point') {\n const bounds = {\n left: min - el.position,\n right: max - el.position,\n };\n\n return (\n <Point\n {...commonProps}\n empty={el.pointType === 'empty'}\n position={el.position}\n bounds={bounds}\n onClick={toggleElement}\n onMove={moveElement}\n />\n );\n } else if (el.type === 'ray') {\n return (\n <Ray\n {...commonProps}\n domain={{ min: min, max: max }}\n direction={el.direction}\n position={el.position}\n onMove={moveElement}\n onToggleSelect={toggleElement}\n width={width}\n empty={el.pointType === 'empty'}\n />\n );\n }\n });\n\n return (\n <svg width={width} height={fraction ? height + 20 : height}>\n {false && <Debug domain={domain} ticks={ticks} />}\n <BaseLine y={lineY} width={width} />\n {arrows.left && <Arrow y={lineY} />}\n {arrows.right && <Arrow x={width} y={lineY} direction=\"right\" />}\n <Ticks y={lineY} domain={domain} ticks={ticks} fraction={fraction} />\n <rect\n ref={(rect) => (this.rect = rect)}\n //need to have a fill for it to be clickable\n fill={color.primary()}\n fillOpacity=\"0.0\"\n width={width}\n height={height}\n />\n <TransitionGroup component=\"g\">\n {elements.map((c, index) => (\n <Fade key={index}>{c}</Fade>\n ))}\n </TransitionGroup>\n </svg>\n );\n }\n }\n}\n\nexport default NumberLineGraph;\n"],"file":"index.js"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Line = Line;
|
|
9
|
-
exports["default"] = void 0;
|
|
10
|
-
|
|
11
|
-
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
|
-
var _reactJss = _interopRequireDefault(require("react-jss"));
|
|
14
|
-
|
|
15
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
-
|
|
17
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
18
|
-
|
|
19
|
-
var style = {
|
|
20
|
-
root: {
|
|
21
|
-
strokeWidth: 2,
|
|
22
|
-
stroke: _renderUi.color.primary()
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function Line(_ref) {
|
|
27
|
-
var y = _ref.y,
|
|
28
|
-
width = _ref.width,
|
|
29
|
-
classes = _ref.classes;
|
|
30
|
-
return /*#__PURE__*/_react["default"].createElement("line", {
|
|
31
|
-
x1: 0,
|
|
32
|
-
y1: y,
|
|
33
|
-
x2: width,
|
|
34
|
-
y2: y,
|
|
35
|
-
className: classes.root
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
Line.propTypes = {
|
|
40
|
-
y: _propTypes["default"].number.isRequired,
|
|
41
|
-
width: _propTypes["default"].number.isRequired,
|
|
42
|
-
classes: _propTypes["default"].object.isRequired
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var _default = (0, _reactJss["default"])(style)(Line);
|
|
46
|
-
|
|
47
|
-
exports["default"] = _default;
|
|
48
|
-
//# sourceMappingURL=line.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/number-line/graph/line.jsx"],"names":["style","root","strokeWidth","stroke","color","primary","Line","y","width","classes","propTypes","PropTypes","number","isRequired","object"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,IAAMA,KAAK,GAAG;AACZC,EAAAA,IAAI,EAAE;AACJC,IAAAA,WAAW,EAAE,CADT;AAEJC,IAAAA,MAAM,EAAEC,gBAAMC,OAAN;AAFJ;AADM,CAAd;;AAOO,SAASC,IAAT,OAAqC;AAAA,MAArBC,CAAqB,QAArBA,CAAqB;AAAA,MAAlBC,KAAkB,QAAlBA,KAAkB;AAAA,MAAXC,OAAW,QAAXA,OAAW;AAC1C,sBAAO;AAAM,IAAA,EAAE,EAAE,CAAV;AAAa,IAAA,EAAE,EAAEF,CAAjB;AAAoB,IAAA,EAAE,EAAEC,KAAxB;AAA+B,IAAA,EAAE,EAAED,CAAnC;AAAsC,IAAA,SAAS,EAAEE,OAAO,CAACR;AAAzD,IAAP;AACD;;AAEDK,IAAI,CAACI,SAAL,GAAiB;AACfH,EAAAA,CAAC,EAAEI,sBAAUC,MAAV,CAAiBC,UADL;AAEfL,EAAAA,KAAK,EAAEG,sBAAUC,MAAV,CAAiBC,UAFT;AAGfJ,EAAAA,OAAO,EAAEE,sBAAUG,MAAV,CAAiBD;AAHX,CAAjB;;eAMe,0BAAYb,KAAZ,EAAmBM,IAAnB,C","sourcesContent":["import React from 'react';\nimport injectSheet from 'react-jss';\nimport PropTypes from 'prop-types';\nimport { color } from '@pie-lib/render-ui';\n\nconst style = {\n root: {\n strokeWidth: 2,\n stroke: color.primary(),\n },\n};\n\nexport function Line({ y, width, classes }) {\n return <line x1={0} y1={y} x2={width} y2={y} className={classes.root} />;\n}\n\nLine.propTypes = {\n y: PropTypes.number.isRequired,\n width: PropTypes.number.isRequired,\n classes: PropTypes.object.isRequired,\n};\n\nexport default injectSheet(style)(Line);\n"],"file":"line.js"}
|