@pie-lib/plot 2.1.5 → 2.1.10-next.258
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/CHANGELOG.md +29 -207
- package/lib/draggable.js +20 -14
- package/lib/draggable.js.map +1 -1
- package/lib/grid-draggable.js +32 -22
- package/lib/grid-draggable.js.map +1 -1
- package/lib/index.js +14 -10
- package/lib/index.js.map +1 -1
- package/lib/root.js +25 -20
- package/lib/root.js.map +1 -1
- package/lib/trig.js +1 -1
- package/lib/trig.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/utils.js +5 -2
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/root.jsx +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,410 +3,232 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [2.1.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **graphing:** Modified labels size and bug fixes ([e6dd79a](https://github.com/pie-framework/pie-lib/commit/e6dd79a))
|
|
6
|
+
## [2.1.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.7...@pie-lib/plot@2.1.9) (2021-06-25)
|
|
12
7
|
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/plot
|
|
13
9
|
|
|
10
|
+
## [2.1.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.6...@pie-lib/plot@2.1.7) (2021-06-25)
|
|
14
11
|
|
|
12
|
+
**Note:** Version bump only for package @pie-lib/plot
|
|
15
13
|
|
|
14
|
+
## [2.1.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.5...@pie-lib/plot@2.1.6) (2021-04-06)
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/plot
|
|
18
17
|
|
|
18
|
+
## [2.1.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.4...@pie-lib/plot@2.1.5) (2021-04-02)
|
|
19
19
|
|
|
20
20
|
### Bug Fixes
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
* **graphing:** increase width and height for labels, depending on labels length PD-988 ([5f64c47](https://github.com/pie-framework/pie-lib/commit/5f64c47))
|
|
24
|
-
* **graphing:** increase width for range axisLabel PD-988 ([e4e5b8f](https://github.com/pie-framework/pie-lib/commit/e4e5b8f))
|
|
25
|
-
|
|
22
|
+
- **graphing:** Modified labels size and bug fixes ([e6dd79a](https://github.com/pie-framework/pie-lib/commit/e6dd79a))
|
|
26
23
|
|
|
24
|
+
## [2.1.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.3...@pie-lib/plot@2.1.4) (2021-03-15)
|
|
27
25
|
|
|
26
|
+
### Bug Fixes
|
|
28
27
|
|
|
28
|
+
- **graphing:** calculate the amount of necessary width for domain axis label PD-988 ([0085feb](https://github.com/pie-framework/pie-lib/commit/0085feb))
|
|
29
|
+
- **graphing:** increase width and height for labels, depending on labels length PD-988 ([5f64c47](https://github.com/pie-framework/pie-lib/commit/5f64c47))
|
|
30
|
+
- **graphing:** increase width for range axisLabel PD-988 ([e4e5b8f](https://github.com/pie-framework/pie-lib/commit/e4e5b8f))
|
|
29
31
|
|
|
30
32
|
## [2.1.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.2...@pie-lib/plot@2.1.3) (2021-02-15)
|
|
31
33
|
|
|
32
34
|
**Note:** Version bump only for package @pie-lib/plot
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
36
|
## [2.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.1.0...@pie-lib/plot@2.1.2) (2021-02-15)
|
|
39
37
|
|
|
40
38
|
**Note:** Version bump only for package @pie-lib/plot
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
40
|
# [2.1.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.0.0...@pie-lib/plot@2.1.0) (2020-10-07)
|
|
47
41
|
|
|
48
|
-
|
|
49
42
|
### Features
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
- **charting:** add color theme support ([606d45e](https://github.com/pie-framework/pie-lib/commit/606d45e))
|
|
56
45
|
|
|
57
46
|
# [2.0.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.16...@pie-lib/plot@2.0.0) (2020-05-15)
|
|
58
47
|
|
|
59
|
-
|
|
60
48
|
### Bug Fixes
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
- Graphing issues and inconsistencies PD-123 ([291b053](https://github.com/pie-framework/pie-lib/commit/291b053))
|
|
64
51
|
|
|
65
52
|
### BREAKING CHANGES
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
- tools, currentTool, defaultTool and hideLabel should not be used as params anymore, instead, send only toolbarTools, which is an array of strings, where each string should be a valid tool type. eg. ['point', 'line', 'label']
|
|
72
55
|
|
|
73
56
|
## [1.3.16](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.15...@pie-lib/plot@1.3.16) (2020-04-14)
|
|
74
57
|
|
|
75
58
|
**Note:** Version bump only for package @pie-lib/plot
|
|
76
59
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
60
|
## [1.3.15](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.14...@pie-lib/plot@1.3.15) (2020-04-08)
|
|
82
61
|
|
|
83
62
|
**Note:** Version bump only for package @pie-lib/plot
|
|
84
63
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
64
|
## [1.3.14](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.13...@pie-lib/plot@1.3.14) (2020-03-31)
|
|
90
65
|
|
|
91
66
|
**Note:** Version bump only for package @pie-lib/plot
|
|
92
67
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
68
|
## [1.3.13](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.12...@pie-lib/plot@1.3.13) (2020-03-31)
|
|
98
69
|
|
|
99
70
|
**Note:** Version bump only for package @pie-lib/plot
|
|
100
71
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
72
|
## [1.3.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.11...@pie-lib/plot@1.3.12) (2020-03-31)
|
|
106
73
|
|
|
107
74
|
**Note:** Version bump only for package @pie-lib/plot
|
|
108
75
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
76
|
## [1.3.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.10...@pie-lib/plot@1.3.11) (2020-03-30)
|
|
114
77
|
|
|
115
78
|
**Note:** Version bump only for package @pie-lib/plot
|
|
116
79
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
80
|
## [1.3.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.9...@pie-lib/plot@1.3.10) (2020-03-30)
|
|
122
81
|
|
|
123
82
|
**Note:** Version bump only for package @pie-lib/plot
|
|
124
83
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
84
|
## [1.3.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.8...@pie-lib/plot@1.3.9) (2020-03-30)
|
|
130
85
|
|
|
131
86
|
**Note:** Version bump only for package @pie-lib/plot
|
|
132
87
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
88
|
## [1.3.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.7...@pie-lib/plot@1.3.8) (2020-03-30)
|
|
138
89
|
|
|
139
90
|
**Note:** Version bump only for package @pie-lib/plot
|
|
140
91
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
92
|
## [1.3.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.6...@pie-lib/plot@1.3.7) (2020-03-30)
|
|
146
93
|
|
|
147
|
-
|
|
148
94
|
### Bug Fixes
|
|
149
95
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
96
|
+
- correct export syntax ([db7fcc0](https://github.com/pie-framework/pie-lib/commit/db7fcc0))
|
|
155
97
|
|
|
156
98
|
## [1.3.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.5...@pie-lib/plot@1.3.6) (2020-03-30)
|
|
157
99
|
|
|
158
100
|
**Note:** Version bump only for package @pie-lib/plot
|
|
159
101
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
102
|
## [1.3.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.4...@pie-lib/plot@1.3.5) (2020-03-30)
|
|
165
103
|
|
|
166
|
-
|
|
167
104
|
### Bug Fixes
|
|
168
105
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
106
|
+
- add module prop to package.json ([387232f](https://github.com/pie-framework/pie-lib/commit/387232f))
|
|
174
107
|
|
|
175
108
|
## [1.3.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.3...@pie-lib/plot@1.3.4) (2020-03-18)
|
|
176
109
|
|
|
177
110
|
**Note:** Version bump only for package @pie-lib/plot
|
|
178
111
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
112
|
## [1.3.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.2...@pie-lib/plot@1.3.3) (2020-02-18)
|
|
184
113
|
|
|
185
|
-
|
|
186
114
|
### Bug Fixes
|
|
187
115
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
116
|
+
- 5325: Graphing: Axis labels overlapping numeric labels ([678c61a](https://github.com/pie-framework/pie-lib/commit/678c61a))
|
|
193
117
|
|
|
194
118
|
## [1.3.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.1...@pie-lib/plot@1.3.2) (2020-02-11)
|
|
195
119
|
|
|
196
120
|
**Note:** Version bump only for package @pie-lib/plot
|
|
197
121
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
122
|
## [1.3.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.3.0...@pie-lib/plot@1.3.1) (2019-08-21)
|
|
203
123
|
|
|
204
124
|
**Note:** Version bump only for package @pie-lib/plot
|
|
205
125
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
126
|
# [1.3.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.2.1...@pie-lib/plot@1.3.0) (2019-08-05)
|
|
211
127
|
|
|
212
|
-
|
|
213
128
|
### Features
|
|
214
129
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
130
|
+
- **charting:** Added Dot Plot chart type and Line Plot chart type. (WIP) ([b9cafc3](https://github.com/pie-framework/pie-lib/commit/b9cafc3))
|
|
220
131
|
|
|
221
132
|
## [1.2.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.2.0...@pie-lib/plot@1.2.1) (2019-07-19)
|
|
222
133
|
|
|
223
134
|
**Note:** Version bump only for package @pie-lib/plot
|
|
224
135
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
136
|
# [1.2.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.1.4...@pie-lib/plot@1.2.0) (2019-07-16)
|
|
230
137
|
|
|
231
|
-
|
|
232
138
|
### Features
|
|
233
139
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
140
|
+
- support dragging when having a grid defined by decimal values ([5a5e505](https://github.com/pie-framework/pie-lib/commit/5a5e505))
|
|
239
141
|
|
|
240
142
|
## [1.1.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.1.3...@pie-lib/plot@1.1.4) (2019-07-08)
|
|
241
143
|
|
|
242
144
|
**Note:** Version bump only for package @pie-lib/plot
|
|
243
145
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
146
|
## [1.1.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.1.2...@pie-lib/plot@1.1.3) (2019-07-05)
|
|
249
147
|
|
|
250
148
|
**Note:** Version bump only for package @pie-lib/plot
|
|
251
149
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
150
|
## [1.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@1.1.1...@pie-lib/plot@1.1.2) (2019-07-02)
|
|
257
151
|
|
|
258
152
|
**Note:** Version bump only for package @pie-lib/plot
|
|
259
153
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
154
|
## [1.1.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.2.2...@pie-lib/plot@1.1.1) (2019-06-28)
|
|
265
155
|
|
|
266
|
-
|
|
267
156
|
### Bug Fixes
|
|
268
157
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
158
|
+
- fix version conflict ([397b5de](https://github.com/pie-framework/pie-lib/commit/397b5de))
|
|
274
159
|
|
|
275
160
|
## [0.2.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.2.1...@pie-lib/plot@0.2.2) (2019-06-28)
|
|
276
161
|
|
|
277
|
-
|
|
278
162
|
### Bug Fixes
|
|
279
163
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
164
|
+
- calculate edge when points are on same horizontal or vertical line ([5cba298](https://github.com/pie-framework/pie-lib/commit/5cba298))
|
|
285
165
|
|
|
286
166
|
## [0.2.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.2.0...@pie-lib/plot@0.2.1) (2019-06-17)
|
|
287
167
|
|
|
288
168
|
**Note:** Version bump only for package @pie-lib/plot
|
|
289
169
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
170
|
# [0.2.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.12...@pie-lib/plot@0.2.0) (2019-06-12)
|
|
295
171
|
|
|
296
|
-
|
|
297
172
|
### Bug Fixes
|
|
298
173
|
|
|
299
|
-
|
|
300
|
-
|
|
174
|
+
- fix bounded drag calculation ([08097bd](https://github.com/pie-framework/pie-lib/commit/08097bd))
|
|
301
175
|
|
|
302
176
|
### Features
|
|
303
177
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
178
|
+
- plot updates ([6856d56](https://github.com/pie-framework/pie-lib/commit/6856d56))
|
|
309
179
|
|
|
310
180
|
## [0.1.12](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.11...@pie-lib/plot@0.1.12) (2019-03-15)
|
|
311
181
|
|
|
312
|
-
|
|
313
182
|
### Bug Fixes
|
|
314
183
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
184
|
+
- rm child prepack in favour of root prepack ([381d8d6](https://github.com/pie-framework/pie-lib/commit/381d8d6))
|
|
320
185
|
|
|
321
186
|
## [0.1.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.10...@pie-lib/plot@0.1.11) (2019-03-14)
|
|
322
187
|
|
|
323
188
|
**Note:** Version bump only for package @pie-lib/plot
|
|
324
189
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
190
|
## [0.1.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.9...@pie-lib/plot@0.1.10) (2019-03-14)
|
|
330
191
|
|
|
331
192
|
**Note:** Version bump only for package @pie-lib/plot
|
|
332
193
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
194
|
## [0.1.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.8...@pie-lib/plot@0.1.9) (2019-03-14)
|
|
338
195
|
|
|
339
196
|
**Note:** Version bump only for package @pie-lib/plot
|
|
340
197
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
198
|
## [0.1.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.7...@pie-lib/plot@0.1.8) (2019-03-14)
|
|
346
199
|
|
|
347
200
|
**Note:** Version bump only for package @pie-lib/plot
|
|
348
201
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
202
|
## [0.1.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.6...@pie-lib/plot@0.1.7) (2019-03-13)
|
|
354
203
|
|
|
355
204
|
**Note:** Version bump only for package @pie-lib/plot
|
|
356
205
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
206
|
## [0.1.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.5...@pie-lib/plot@0.1.6) (2019-03-13)
|
|
362
207
|
|
|
363
208
|
**Note:** Version bump only for package @pie-lib/plot
|
|
364
209
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
210
|
## [0.1.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.4...@pie-lib/plot@0.1.5) (2019-03-13)
|
|
370
211
|
|
|
371
212
|
**Note:** Version bump only for package @pie-lib/plot
|
|
372
213
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
214
|
## [0.1.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.2...@pie-lib/plot@0.1.4) (2019-02-17)
|
|
378
215
|
|
|
379
|
-
|
|
380
216
|
### Bug Fixes
|
|
381
217
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
218
|
+
- force version bump ([dd057a5](https://github.com/pie-framework/pie-lib/commit/dd057a5))
|
|
387
219
|
|
|
388
220
|
## [0.1.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.1...@pie-lib/plot@0.1.2) (2019-02-17)
|
|
389
221
|
|
|
390
|
-
|
|
391
222
|
### Bug Fixes
|
|
392
223
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
224
|
+
- fix tests ([1363aa4](https://github.com/pie-framework/pie-lib/commit/1363aa4))
|
|
398
225
|
|
|
399
226
|
## [0.1.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@0.1.0...@pie-lib/plot@0.1.1) (2019-01-30)
|
|
400
227
|
|
|
401
228
|
**Note:** Version bump only for package @pie-lib/plot
|
|
402
229
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
230
|
# 0.1.0 (2019-01-30)
|
|
408
231
|
|
|
409
|
-
|
|
410
232
|
### Features
|
|
411
233
|
|
|
412
|
-
|
|
234
|
+
- new package plot ([1adf654](https://github.com/pie-framework/pie-lib/commit/1adf654))
|
package/lib/draggable.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -13,39 +15,43 @@ exports["default"] = void 0;
|
|
|
13
15
|
|
|
14
16
|
var _reactDraggable = _interopRequireWildcard(require("react-draggable"));
|
|
15
17
|
|
|
16
|
-
function
|
|
18
|
+
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); }
|
|
17
19
|
|
|
18
|
-
function
|
|
20
|
+
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; }
|
|
19
21
|
|
|
20
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
23
|
|
|
22
24
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
23
25
|
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
31
33
|
|
|
32
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
37
39
|
|
|
38
|
-
function
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function (_Draggable) {
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
|
+
|
|
46
|
+
var LocalDraggable = /*#__PURE__*/function (_Draggable) {
|
|
43
47
|
_inherits(LocalDraggable, _Draggable);
|
|
44
48
|
|
|
49
|
+
var _super = _createSuper(LocalDraggable);
|
|
50
|
+
|
|
45
51
|
function LocalDraggable() {
|
|
46
52
|
_classCallCheck(this, LocalDraggable);
|
|
47
53
|
|
|
48
|
-
return
|
|
54
|
+
return _super.apply(this, arguments);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
_createClass(LocalDraggable, [{
|
package/lib/draggable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/draggable.jsx"],"names":["LocalDraggable","next","setState","x","y","Draggable"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/draggable.jsx"],"names":["LocalDraggable","next","setState","x","y","Draggable"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEqBA,c;;;;;;;;;;;;;WACnB,mCAA0BC,IAA1B,EAAgC;AAC9B,oGAAgCA,IAAhC,EAD8B,CAE9B;;;AACA,WAAKC,QAAL,CAAc;AAAEC,QAAAA,CAAC,EAAE,CAAL;AAAQC,QAAAA,CAAC,EAAE;AAAX,OAAd;AACD;;;;EALyCC,0B","sourcesContent":["import Draggable, { DraggableCore } from 'react-draggable';\n\nexport default class LocalDraggable extends Draggable {\n componentWillReceiveProps(next) {\n super.componentWillReceiveProps(next);\n //Remove the x/y state as these values have now been updated and will come through as props.\n this.setState({ x: 0, y: 0 });\n }\n}\n\nexport { DraggableCore };\n"],"file":"draggable.js"}
|
package/lib/grid-draggable.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -23,11 +25,13 @@ var _invariant = _interopRequireDefault(require("invariant"));
|
|
|
23
25
|
|
|
24
26
|
var _d3Selection = require("d3-selection");
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
var _excluded = ["disabled", "onClick"];
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
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); }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
35
|
|
|
32
36
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
37
|
|
|
@@ -35,11 +39,15 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
35
39
|
|
|
36
40
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
37
41
|
|
|
38
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
42
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
43
|
|
|
40
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
44
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
45
|
|
|
42
|
-
function
|
|
46
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
47
|
+
|
|
48
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
49
|
+
|
|
50
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
43
51
|
|
|
44
52
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
53
|
|
|
@@ -47,17 +55,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
47
55
|
|
|
48
56
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
49
57
|
|
|
50
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
51
59
|
|
|
52
|
-
function
|
|
60
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
53
61
|
|
|
54
|
-
function
|
|
62
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
63
|
+
|
|
64
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
65
|
+
|
|
66
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
55
67
|
|
|
56
68
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
69
|
|
|
58
|
-
function
|
|
70
|
+
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; } }
|
|
59
71
|
|
|
60
|
-
function
|
|
72
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
61
73
|
|
|
62
74
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
63
75
|
|
|
@@ -80,17 +92,15 @@ exports.deltaFn = deltaFn;
|
|
|
80
92
|
|
|
81
93
|
var gridDraggable = function gridDraggable(opts) {
|
|
82
94
|
return function (Comp) {
|
|
83
|
-
var _class
|
|
95
|
+
var _class;
|
|
84
96
|
|
|
85
97
|
(0, _invariant["default"])(!!opts && (0, _isFunction["default"])(opts.fromDelta) && (0, _isFunction["default"])(opts.bounds) && (0, _isFunction["default"])(opts.anchorPoint), 'You must supply an object with: { anchorPoint: Function, fromDelta: Function, bounds: Function }');
|
|
86
|
-
return
|
|
87
|
-
/*#__PURE__*/
|
|
88
|
-
function (_React$Component) {
|
|
98
|
+
return _class = /*#__PURE__*/function (_React$Component) {
|
|
89
99
|
_inherits(GridDraggable, _React$Component);
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
var _getPrototypeOf2;
|
|
101
|
+
var _super = _createSuper(GridDraggable);
|
|
93
102
|
|
|
103
|
+
function GridDraggable() {
|
|
94
104
|
var _this;
|
|
95
105
|
|
|
96
106
|
_classCallCheck(this, GridDraggable);
|
|
@@ -99,7 +109,7 @@ var gridDraggable = function gridDraggable(opts) {
|
|
|
99
109
|
args[_key] = arguments[_key];
|
|
100
110
|
}
|
|
101
111
|
|
|
102
|
-
_this =
|
|
112
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
103
113
|
|
|
104
114
|
_defineProperty(_assertThisInitialized(_this), "grid", function () {
|
|
105
115
|
var graphProps = _this.props.graphProps;
|
|
@@ -315,7 +325,7 @@ var gridDraggable = function gridDraggable(opts) {
|
|
|
315
325
|
var _this$props3 = this.props,
|
|
316
326
|
disabled = _this$props3.disabled,
|
|
317
327
|
onClick = _this$props3.onClick,
|
|
318
|
-
rest = _objectWithoutProperties(_this$props3,
|
|
328
|
+
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
319
329
|
/* eslint-enable no-unused-vars */
|
|
320
330
|
|
|
321
331
|
|
|
@@ -331,7 +341,7 @@ var gridDraggable = function gridDraggable(opts) {
|
|
|
331
341
|
|
|
332
342
|
|
|
333
343
|
var isDragging = this.state ? !!this.state.startX : false;
|
|
334
|
-
return _react["default"].createElement(_draggable.DraggableCore, {
|
|
344
|
+
return /*#__PURE__*/_react["default"].createElement(_draggable.DraggableCore, {
|
|
335
345
|
disabled: disabled,
|
|
336
346
|
onMouseDown: onMouseDown,
|
|
337
347
|
onStart: this.onStart,
|
|
@@ -339,7 +349,7 @@ var gridDraggable = function gridDraggable(opts) {
|
|
|
339
349
|
onStop: this.onStop,
|
|
340
350
|
axis: opts.axis || 'both',
|
|
341
351
|
grid: [grid.x, grid.y]
|
|
342
|
-
}, _react["default"].createElement(Comp, _extends({}, rest, {
|
|
352
|
+
}, /*#__PURE__*/_react["default"].createElement(Comp, _extends({}, rest, {
|
|
343
353
|
disabled: disabled,
|
|
344
354
|
isDragging: isDragging
|
|
345
355
|
})));
|
|
@@ -355,7 +365,7 @@ var gridDraggable = function gridDraggable(opts) {
|
|
|
355
365
|
onClick: _propTypes["default"].func,
|
|
356
366
|
onMove: _propTypes["default"].func,
|
|
357
367
|
graphProps: _types.GraphPropsType.isRequired
|
|
358
|
-
}),
|
|
368
|
+
}), _class;
|
|
359
369
|
};
|
|
360
370
|
};
|
|
361
371
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/grid-draggable.jsx"],"names":["log","deltaFn","scale","snap","val","delta","normalized","inverted","invert","gridDraggable","opts","Comp","fromDelta","bounds","anchorPoint","graphProps","props","domain","range","x","step","y","e","onDragStart","document","activeElement","blur","setState","startX","clientX","startY","clientY","key","event","K","toUpperCase","end","start","state","Math","abs","out","grid","scaled","left","interval","right","top","bottom","dd","rootNode","getRootNode","rawX","rawY","xOutside","deltaX","min","max","yOutside","deltaY","onDrag","getScaledBounds","skipDragOutsideOfBounds","dragArg","applyDelta","undefined","point","pos","position","p","utils","getDelta","onDragStop","onClick","lastX","lastY","isClick","tiny","target","disabled","rest","onMouseDown","nativeEvent","preventDefault","isDragging","onStart","onStop","axis","React","Component","PropTypes","bool","func","onMove","GraphPropsType","isRequired"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,6BAAN,CAAZ;;AACO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,IAAR,EAAcC,GAAd;AAAA,SAAsB,UAAAC,KAAK,EAAI;AACpD,QAAMC,UAAU,GAAGD,KAAK,GAAGH,KAAK,CAAC,CAAD,CAAhC;AACA,QAAMK,QAAQ,GAAGL,KAAK,CAACM,MAAN,CAAaF,UAAb,CAAjB;AACA,WAAOH,IAAI,CAACC,GAAG,GAAGG,QAAP,CAAX;AACD,GAJsB;AAAA,CAAhB;AAKP;;;;;;;;AAIO,IAAME,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,IAAI;AAAA,SAAI,UAAAC,IAAI,EAAI;AAAA;;AAC3C,+BACE,CAAC,CAACD,IAAF,IAAU,4BAAWA,IAAI,CAACE,SAAhB,CAAV,IAAwC,4BAAWF,IAAI,CAACG,MAAhB,CAAxC,IAAmE,4BAAWH,IAAI,CAACI,WAAhB,CADrE,EAEE,kGAFF;AAIA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA,+DAUS,YAAM;AAAA,cACHC,UADG,GACY,MAAKC,KADjB,CACHD,UADG;AAAA,cAEHb,KAFG,GAEsBa,UAFtB,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,YAAA,WAAW,EAAEE,WAFf;AAGE,YAAA,OAAO,EAAE,KAAKI,OAHhB;AAIE,YAAA,MAAM,EAAE,KAAKzB,MAJf;AAKE,YAAA,MAAM,EAAE,KAAK0B,MALf;AAME,YAAA,IAAI,EAAE5E,IAAI,CAAC6E,IAAL,IAAa,MANrB;AAOE,YAAA,IAAI,EAAE,CAAC7C,IAAI,CAACvB,CAAN,EAASuB,IAAI,CAACrB,CAAd;AAPR,aASE,gCAAC,IAAD,eAAU2D,IAAV;AAAgB,YAAA,QAAQ,EAAED,QAA1B;AAAoC,YAAA,UAAU,EAAEK;AAAhD,aATF,CADF;AAaD;AAlMH;;AAAA;AAAA,MAAmCI,kBAAMC,SAAzC,wCACqB;AACjBV,MAAAA,QAAQ,EAAEW,sBAAUC,IADH;AAEjBpE,MAAAA,WAAW,EAAEmE,sBAAUE,IAFN;AAGjBhC,MAAAA,MAAM,EAAE8B,sBAAUE,IAHD;AAIjBpB,MAAAA,UAAU,EAAEkB,sBAAUE,IAJL;AAKjBnB,MAAAA,OAAO,EAAEiB,sBAAUE,IALF;AAMjBC,MAAAA,MAAM,EAAEH,sBAAUE,IAND;AAOjB7E,MAAAA,UAAU,EAAE+E,sBAAeC;AAPV,KADrB;AAoMD,GAzMgC;AAAA,CAA1B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { GraphPropsType } from './types';\nimport { DraggableCore } from './draggable';\nimport debug from 'debug';\nimport * as utils from './utils';\nimport isFunction from 'lodash/isFunction';\nimport invariant from 'invariant';\nimport { clientPoint } from 'd3-selection';\nconst log = debug('pie-lib:plot:grid-draggable');\nexport const deltaFn = (scale, snap, val) => delta => {\n const normalized = delta + scale(0);\n const inverted = scale.invert(normalized);\n return snap(val + inverted);\n};\n/**\n * Creates a Component that is draggable, within a bounded grid.\n * @param {*} opts\n */\nexport const gridDraggable = opts => Comp => {\n invariant(\n !!opts && isFunction(opts.fromDelta) && isFunction(opts.bounds) && isFunction(opts.anchorPoint),\n 'You must supply an object with: { anchorPoint: Function, fromDelta: Function, bounds: Function }'\n );\n return class GridDraggable extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n onDragStart: PropTypes.func,\n onDrag: PropTypes.func,\n onDragStop: PropTypes.func,\n onClick: PropTypes.func,\n onMove: PropTypes.func,\n graphProps: GraphPropsType.isRequired\n };\n grid = () => {\n const { graphProps } = this.props;\n const { scale, domain, range } = graphProps;\n return {\n x: scale.x(domain.step) - scale.x(0),\n y: scale.y(range.step) - scale.y(0)\n };\n };\n onStart = e => {\n const { onDragStart } = this.props;\n if (document.activeElement) {\n document.activeElement.blur();\n }\n this.setState({ startX: e.clientX, startY: e.clientY });\n if (onDragStart) {\n onDragStart();\n }\n };\n position = () => {\n const { x, y } = opts.anchorPoint(this.props);\n const { graphProps } = this.props;\n const { scale, snap } = graphProps;\n return {\n anchorPoint: {\n x,\n y\n },\n x: deltaFn(scale.x, snap.x, x),\n y: deltaFn(scale.y, snap.y, y)\n };\n };\n\n tiny = (key, event) => {\n const K = key.toUpperCase();\n const end = event[`client${K}`];\n const start = this.state[`start${K}`];\n const delta = Math.abs(end - start);\n const out = delta < Math.abs(this.grid()[key]) / 10;\n log('[tiny] key: ', key, 'delta: ', delta, 'out: ', out);\n return out;\n };\n\n getScaledBounds = () => {\n const bounds = opts.bounds(this.props, this.props.graphProps);\n log('bounds: ', bounds);\n const grid = this.grid();\n\n const scaled = {\n left: (bounds.left / grid.interval) * grid.x,\n right: (bounds.right / grid.interval) * grid.x,\n top: (bounds.top / grid.interval) * grid.y,\n bottom: (bounds.bottom / grid.interval) * grid.y\n };\n log('[getScaledBounds]: ', scaled);\n return scaled;\n };\n\n skipDragOutsideOfBounds = (dd, e, graphProps) => {\n // ignore drag movement outside of the domain and range.\n const rootNode = graphProps.getRootNode();\n const [rawX, rawY] = clientPoint(rootNode, e);\n const { scale, domain, range } = graphProps;\n let x = scale.x.invert(rawX);\n let y = scale.y.invert(rawY);\n\n const xOutside = (dd.deltaX > 0 && x < domain.min) || (dd.deltaX < 0 && x > domain.max);\n const yOutside = (dd.deltaY > 0 && y > range.max) || (dd.deltaY < 0 && y < range.min);\n return xOutside || yOutside;\n };\n\n onDrag = (e, dd) => {\n const { onDrag, graphProps } = this.props;\n\n if (!onDrag) {\n return;\n }\n\n const bounds = this.getScaledBounds();\n\n if (dd.deltaX < 0 && dd.deltaX < bounds.left) {\n return;\n }\n\n if (dd.deltaX > 0 && dd.deltaX > bounds.right) {\n return;\n }\n\n if (dd.deltaY < 0 && dd.deltaY < bounds.top) {\n return;\n }\n\n if (dd.deltaY > 0 && dd.deltaY > bounds.bottom) {\n return;\n }\n\n if (this.skipDragOutsideOfBounds(dd, e, graphProps)) {\n return;\n }\n\n const dragArg = this.applyDelta({ x: dd.deltaX, y: dd.deltaY });\n\n if (dragArg !== undefined || dragArg !== null) {\n onDrag(dragArg);\n }\n };\n\n getDelta = point => {\n const pos = this.position();\n\n const p = {\n x: pos.x(point.x),\n y: pos.y(point.y)\n };\n\n return utils.getDelta(pos.anchorPoint, p);\n };\n\n applyDelta = point => {\n const delta = this.getDelta(point);\n log('[applyDelta] delta:', delta);\n return opts.fromDelta(this.props, delta);\n };\n\n onStop = (e, dd) => {\n log('[onStop] dd:', dd);\n const { onDragStop, onClick } = this.props;\n\n if (onDragStop) {\n onDragStop();\n }\n\n log('[onStop] lastX/Y: ', dd.lastX, dd.lastY);\n const isClick = this.tiny('x', e) && this.tiny('y', e);\n\n if (isClick) {\n if (onClick) {\n log('call onClick');\n this.setState({ startX: null });\n const { graphProps } = this.props;\n const { scale, snap } = graphProps;\n const [rawX, rawY] = clientPoint(e.target, e);\n let x = scale.x.invert(rawX);\n let y = scale.y.invert(rawY);\n x = snap.x(x);\n y = snap.y(y);\n onClick({ x, y });\n return false;\n }\n }\n\n this.setState({ startX: null, startY: null });\n // return false to prevent state updates in the underlying draggable - a move will have triggered an update already.\n return false;\n };\n\n render() {\n /* eslint-disable no-unused-vars */\n //Note: we pull onClick out so that it's not in ...rest.\n const { disabled, onClick, ...rest } = this.props;\n /* eslint-enable no-unused-vars */\n\n const grid = this.grid();\n //prevent the text select icon from rendering.\n const onMouseDown = e => e.nativeEvent.preventDefault();\n\n /**\n * TODO: This shouldnt be necessary, we should be able to use the r-d classnames.\n * But they aren't being unset. If we continue with this lib, we'll have to fix this.\n */\n const isDragging = this.state ? !!this.state.startX : false;\n\n return (\n <DraggableCore\n disabled={disabled}\n onMouseDown={onMouseDown}\n onStart={this.onStart}\n onDrag={this.onDrag}\n onStop={this.onStop}\n axis={opts.axis || 'both'}\n grid={[grid.x, grid.y]}\n >\n <Comp {...rest} disabled={disabled} isDragging={isDragging} />\n </DraggableCore>\n );\n }\n };\n};\n"],"file":"grid-draggable.js"}
|
|
1
|
+
{"version":3,"sources":["../src/grid-draggable.jsx"],"names":["log","deltaFn","scale","snap","val","delta","normalized","inverted","invert","gridDraggable","opts","Comp","fromDelta","bounds","anchorPoint","graphProps","props","domain","range","x","step","y","e","onDragStart","document","activeElement","blur","setState","startX","clientX","startY","clientY","key","event","K","toUpperCase","end","start","state","Math","abs","out","grid","scaled","left","interval","right","top","bottom","dd","rootNode","getRootNode","rawX","rawY","xOutside","deltaX","min","max","yOutside","deltaY","onDrag","getScaledBounds","skipDragOutsideOfBounds","dragArg","applyDelta","undefined","point","pos","position","p","utils","getDelta","onDragStop","onClick","lastX","lastY","isClick","tiny","target","disabled","rest","onMouseDown","nativeEvent","preventDefault","isDragging","onStart","onStop","axis","React","Component","PropTypes","bool","func","onMove","GraphPropsType","isRequired"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,6BAAN,CAAZ;;AACO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,IAAR,EAAcC,GAAd;AAAA,SAAsB,UAAAC,KAAK,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E,sBAAUE,IAFN;AAGjBhC,MAAAA,MAAM,EAAE8B,sBAAUE,IAHD;AAIjBpB,MAAAA,UAAU,EAAEkB,sBAAUE,IAJL;AAKjBnB,MAAAA,OAAO,EAAEiB,sBAAUE,IALF;AAMjBC,MAAAA,MAAM,EAAEH,sBAAUE,IAND;AAOjB7E,MAAAA,UAAU,EAAE+E,sBAAeC;AAPV,KADrB;AAoMD,GAzMgC;AAAA,CAA1B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { GraphPropsType } from './types';\nimport { DraggableCore } from './draggable';\nimport debug from 'debug';\nimport * as utils from './utils';\nimport isFunction from 'lodash/isFunction';\nimport invariant from 'invariant';\nimport { clientPoint } from 'd3-selection';\nconst log = debug('pie-lib:plot:grid-draggable');\nexport const deltaFn = (scale, snap, val) => delta => {\n const normalized = delta + scale(0);\n const inverted = scale.invert(normalized);\n return snap(val + inverted);\n};\n/**\n * Creates a Component that is draggable, within a bounded grid.\n * @param {*} opts\n */\nexport const gridDraggable = opts => Comp => {\n invariant(\n !!opts && isFunction(opts.fromDelta) && isFunction(opts.bounds) && isFunction(opts.anchorPoint),\n 'You must supply an object with: { anchorPoint: Function, fromDelta: Function, bounds: Function }'\n );\n return class GridDraggable extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n onDragStart: PropTypes.func,\n onDrag: PropTypes.func,\n onDragStop: PropTypes.func,\n onClick: PropTypes.func,\n onMove: PropTypes.func,\n graphProps: GraphPropsType.isRequired\n };\n grid = () => {\n const { graphProps } = this.props;\n const { scale, domain, range } = graphProps;\n return {\n x: scale.x(domain.step) - scale.x(0),\n y: scale.y(range.step) - scale.y(0)\n };\n };\n onStart = e => {\n const { onDragStart } = this.props;\n if (document.activeElement) {\n document.activeElement.blur();\n }\n this.setState({ startX: e.clientX, startY: e.clientY });\n if (onDragStart) {\n onDragStart();\n }\n };\n position = () => {\n const { x, y } = opts.anchorPoint(this.props);\n const { graphProps } = this.props;\n const { scale, snap } = graphProps;\n return {\n anchorPoint: {\n x,\n y\n },\n x: deltaFn(scale.x, snap.x, x),\n y: deltaFn(scale.y, snap.y, y)\n };\n };\n\n tiny = (key, event) => {\n const K = key.toUpperCase();\n const end = event[`client${K}`];\n const start = this.state[`start${K}`];\n const delta = Math.abs(end - start);\n const out = delta < Math.abs(this.grid()[key]) / 10;\n log('[tiny] key: ', key, 'delta: ', delta, 'out: ', out);\n return out;\n };\n\n getScaledBounds = () => {\n const bounds = opts.bounds(this.props, this.props.graphProps);\n log('bounds: ', bounds);\n const grid = this.grid();\n\n const scaled = {\n left: (bounds.left / grid.interval) * grid.x,\n right: (bounds.right / grid.interval) * grid.x,\n top: (bounds.top / grid.interval) * grid.y,\n bottom: (bounds.bottom / grid.interval) * grid.y\n };\n log('[getScaledBounds]: ', scaled);\n return scaled;\n };\n\n skipDragOutsideOfBounds = (dd, e, graphProps) => {\n // ignore drag movement outside of the domain and range.\n const rootNode = graphProps.getRootNode();\n const [rawX, rawY] = clientPoint(rootNode, e);\n const { scale, domain, range } = graphProps;\n let x = scale.x.invert(rawX);\n let y = scale.y.invert(rawY);\n\n const xOutside = (dd.deltaX > 0 && x < domain.min) || (dd.deltaX < 0 && x > domain.max);\n const yOutside = (dd.deltaY > 0 && y > range.max) || (dd.deltaY < 0 && y < range.min);\n return xOutside || yOutside;\n };\n\n onDrag = (e, dd) => {\n const { onDrag, graphProps } = this.props;\n\n if (!onDrag) {\n return;\n }\n\n const bounds = this.getScaledBounds();\n\n if (dd.deltaX < 0 && dd.deltaX < bounds.left) {\n return;\n }\n\n if (dd.deltaX > 0 && dd.deltaX > bounds.right) {\n return;\n }\n\n if (dd.deltaY < 0 && dd.deltaY < bounds.top) {\n return;\n }\n\n if (dd.deltaY > 0 && dd.deltaY > bounds.bottom) {\n return;\n }\n\n if (this.skipDragOutsideOfBounds(dd, e, graphProps)) {\n return;\n }\n\n const dragArg = this.applyDelta({ x: dd.deltaX, y: dd.deltaY });\n\n if (dragArg !== undefined || dragArg !== null) {\n onDrag(dragArg);\n }\n };\n\n getDelta = point => {\n const pos = this.position();\n\n const p = {\n x: pos.x(point.x),\n y: pos.y(point.y)\n };\n\n return utils.getDelta(pos.anchorPoint, p);\n };\n\n applyDelta = point => {\n const delta = this.getDelta(point);\n log('[applyDelta] delta:', delta);\n return opts.fromDelta(this.props, delta);\n };\n\n onStop = (e, dd) => {\n log('[onStop] dd:', dd);\n const { onDragStop, onClick } = this.props;\n\n if (onDragStop) {\n onDragStop();\n }\n\n log('[onStop] lastX/Y: ', dd.lastX, dd.lastY);\n const isClick = this.tiny('x', e) && this.tiny('y', e);\n\n if (isClick) {\n if (onClick) {\n log('call onClick');\n this.setState({ startX: null });\n const { graphProps } = this.props;\n const { scale, snap } = graphProps;\n const [rawX, rawY] = clientPoint(e.target, e);\n let x = scale.x.invert(rawX);\n let y = scale.y.invert(rawY);\n x = snap.x(x);\n y = snap.y(y);\n onClick({ x, y });\n return false;\n }\n }\n\n this.setState({ startX: null, startY: null });\n // return false to prevent state updates in the underlying draggable - a move will have triggered an update already.\n return false;\n };\n\n render() {\n /* eslint-disable no-unused-vars */\n //Note: we pull onClick out so that it's not in ...rest.\n const { disabled, onClick, ...rest } = this.props;\n /* eslint-enable no-unused-vars */\n\n const grid = this.grid();\n //prevent the text select icon from rendering.\n const onMouseDown = e => e.nativeEvent.preventDefault();\n\n /**\n * TODO: This shouldnt be necessary, we should be able to use the r-d classnames.\n * But they aren't being unset. If we continue with this lib, we'll have to fix this.\n */\n const isDragging = this.state ? !!this.state.startX : false;\n\n return (\n <DraggableCore\n disabled={disabled}\n onMouseDown={onMouseDown}\n onStart={this.onStart}\n onDrag={this.onDrag}\n onStop={this.onStop}\n axis={opts.axis || 'both'}\n grid={[grid.x, grid.y]}\n >\n <Comp {...rest} disabled={disabled} isDragging={isDragging} />\n </DraggableCore>\n );\n }\n };\n};\n"],"file":"grid-draggable.js"}
|
package/lib/index.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
Object.defineProperty(exports, "Root", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _root["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
8
|
Object.defineProperty(exports, "Draggable", {
|
|
13
9
|
enumerable: true,
|
|
14
10
|
get: function get() {
|
|
15
11
|
return _draggable["default"];
|
|
16
12
|
}
|
|
17
13
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "Root", {
|
|
19
15
|
enumerable: true,
|
|
20
16
|
get: function get() {
|
|
21
|
-
return
|
|
17
|
+
return _root["default"];
|
|
22
18
|
}
|
|
23
19
|
});
|
|
24
20
|
Object.defineProperty(exports, "createGraphProps", {
|
|
@@ -27,7 +23,13 @@ Object.defineProperty(exports, "createGraphProps", {
|
|
|
27
23
|
return _graphProps.create;
|
|
28
24
|
}
|
|
29
25
|
});
|
|
30
|
-
|
|
26
|
+
Object.defineProperty(exports, "gridDraggable", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _gridDraggable.gridDraggable;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.utils = exports.types = exports.trig = void 0;
|
|
31
33
|
|
|
32
34
|
var _root = _interopRequireDefault(require("./root"));
|
|
33
35
|
|
|
@@ -49,7 +51,9 @@ exports.types = types;
|
|
|
49
51
|
|
|
50
52
|
var _graphProps = require("./graph-props");
|
|
51
53
|
|
|
52
|
-
function
|
|
54
|
+
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); }
|
|
55
|
+
|
|
56
|
+
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; }
|
|
53
57
|
|
|
54
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
55
59
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import Root from './root';\nimport Draggable from './draggable';\nimport { gridDraggable } from './grid-draggable';\nimport * as utils from './utils';\nimport * as trig from './trig';\nimport * as types from './types';\nimport { create as createGraphProps } from './graph-props';\n\nexport { Root, Draggable, gridDraggable, utils, trig, types, createGraphProps };\n"],"file":"index.js"}
|
package/lib/root.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -23,23 +25,25 @@ var _utils = require("./utils");
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
27
|
-
|
|
28
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
29
|
|
|
30
30
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
31
|
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
|
+
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
37
41
|
|
|
38
42
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
43
|
|
|
40
|
-
function
|
|
44
|
+
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; } }
|
|
41
45
|
|
|
42
|
-
function
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
47
|
|
|
44
48
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
49
|
|
|
@@ -55,22 +59,23 @@ var GraphTitle = (0, _styles.withStyles)(function (theme) {
|
|
|
55
59
|
})(function (_ref) {
|
|
56
60
|
var value = _ref.value,
|
|
57
61
|
classes = _ref.classes;
|
|
58
|
-
return _react["default"].createElement(_Typography["default"], {
|
|
62
|
+
return /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
59
63
|
className: classes.title,
|
|
64
|
+
color: "primary",
|
|
60
65
|
variant: "h5",
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
dangerouslySetInnerHTML: {
|
|
67
|
+
__html: value
|
|
68
|
+
}
|
|
69
|
+
});
|
|
63
70
|
});
|
|
64
71
|
exports.GraphTitle = GraphTitle;
|
|
65
72
|
|
|
66
|
-
var Root =
|
|
67
|
-
/*#__PURE__*/
|
|
68
|
-
function (_React$Component) {
|
|
73
|
+
var Root = /*#__PURE__*/function (_React$Component) {
|
|
69
74
|
_inherits(Root, _React$Component);
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
var _getPrototypeOf2;
|
|
76
|
+
var _super = _createSuper(Root);
|
|
73
77
|
|
|
78
|
+
function Root() {
|
|
74
79
|
var _this;
|
|
75
80
|
|
|
76
81
|
_classCallCheck(this, Root);
|
|
@@ -79,7 +84,7 @@ function (_React$Component) {
|
|
|
79
84
|
args[_key] = arguments[_key];
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
_this =
|
|
87
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
83
88
|
|
|
84
89
|
_defineProperty(_assertThisInitialized(_this), "mouseMove", function (g) {
|
|
85
90
|
var _this$props = _this.props,
|
|
@@ -136,15 +141,15 @@ function (_React$Component) {
|
|
|
136
141
|
var increaseWidth = (0, _utils.amountToIncreaseWidth)(longestWord);
|
|
137
142
|
var finalWidth = size.width + padding * 2 + increaseWidth;
|
|
138
143
|
var finalHeight = size.height + padding * 2;
|
|
139
|
-
return _react["default"].createElement("div", {
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
140
145
|
className: classes.root
|
|
141
|
-
}, title && _react["default"].createElement(GraphTitle, {
|
|
146
|
+
}, title && /*#__PURE__*/_react["default"].createElement(GraphTitle, {
|
|
142
147
|
value: title
|
|
143
|
-
}), _react["default"].createElement("svg", {
|
|
148
|
+
}), /*#__PURE__*/_react["default"].createElement("svg", {
|
|
144
149
|
width: finalWidth,
|
|
145
150
|
height: finalHeight,
|
|
146
151
|
className: classes.svg
|
|
147
|
-
}, _react["default"].createElement("g", {
|
|
152
|
+
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
148
153
|
ref: function ref(r) {
|
|
149
154
|
_this2.g = r;
|
|
150
155
|
|
package/lib/root.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.jsx"],"names":["GraphTitle","theme","title","color","text","textAlign","paddingTop","spacing","unit","fontSize","typography","value","classes","Root","g","props","graphProps","onMouseMove","scale","snap","coords","_groups","x","invert","y","snapped","on","mouseMove","bind","children","rootRef","paddingLeft","size","domain","padding","longestWord","axisLabel","increaseWidth","finalWidth","width","finalHeight","height","root","svg","r","graphBox","React","Component","PropTypes","string","ChildrenType","GraphPropsType","isRequired","func","object","number","styles","border","primaryLight","backgroundColor","background","cursor","userSelect"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/root.jsx"],"names":["GraphTitle","theme","title","color","text","textAlign","paddingTop","spacing","unit","fontSize","typography","value","classes","__html","Root","g","props","graphProps","onMouseMove","scale","snap","coords","_groups","x","invert","y","snapped","on","mouseMove","bind","children","rootRef","paddingLeft","size","domain","padding","longestWord","axisLabel","increaseWidth","finalWidth","width","finalHeight","height","root","svg","r","graphBox","React","Component","PropTypes","string","ChildrenType","GraphPropsType","isRequired","func","object","number","styles","border","primaryLight","backgroundColor","background","cursor","userSelect"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,UA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APU,GAAP;AAAA,CAAf;;eAae,wBAAWN,MAAX,EAAmB3C,IAAnB,C","sourcesContent":["import React from 'react';\nimport { ChildrenType } from './types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport { select, mouse } from 'd3-selection';\nimport PropTypes from 'prop-types';\nimport { GraphPropsType } from './types';\nimport { color } from '@pie-lib/render-ui';\nimport { findLongestWord, amountToIncreaseWidth } from './utils';\n\nexport const GraphTitle = withStyles(theme => ({\n title: {\n color: color.text(),\n textAlign: 'center',\n paddingTop: theme.spacing.unit * 2,\n fontSize: theme.typography.fontSize + 6\n }\n}))(({ value, classes }) => (\n <Typography\n className={classes.title}\n color=\"primary\"\n variant=\"h5\"\n dangerouslySetInnerHTML={{ __html: value }}\n />\n));\n\nexport class Root extends React.Component {\n static propTypes = {\n title: PropTypes.string,\n children: ChildrenType,\n graphProps: GraphPropsType.isRequired,\n onMouseMove: PropTypes.func,\n classes: PropTypes.object.isRequired,\n rootRef: PropTypes.func,\n paddingLeft: PropTypes.number\n };\n\n mouseMove = g => {\n const { graphProps, onMouseMove } = this.props;\n\n if (!onMouseMove) {\n return;\n }\n\n const { scale, snap } = graphProps;\n const coords = mouse(g._groups[0][0]);\n const x = scale.x.invert(coords[0]);\n const y = scale.y.invert(coords[1]);\n\n const snapped = {\n x: snap.x(x),\n y: snap.y(y)\n };\n\n onMouseMove(snapped);\n };\n\n componentDidMount() {\n const g = select(this.g);\n g.on('mousemove', this.mouseMove.bind(this, g));\n }\n\n componentWillUnmount() {\n const g = select(this.g);\n g.on('mousemove', null);\n }\n\n render() {\n const { graphProps, children, classes, title, rootRef, paddingLeft } = this.props;\n const { size, domain } = graphProps;\n const padding = 50;\n const longestWord = findLongestWord(domain.axisLabel);\n const increaseWidth = amountToIncreaseWidth(longestWord);\n\n const finalWidth = size.width + padding * 2 + increaseWidth;\n const finalHeight = size.height + padding * 2;\n\n return (\n <div className={classes.root}>\n {title && <GraphTitle value={title} />}\n <svg width={finalWidth} height={finalHeight} className={classes.svg}>\n <g\n ref={r => {\n this.g = r;\n if (rootRef) {\n rootRef(r);\n }\n }}\n className={classes.graphBox}\n transform={`translate(${paddingLeft || padding}, ${padding})`}\n >\n {children}\n </g>\n </svg>\n </div>\n );\n }\n}\nconst styles = () => ({\n root: {\n border: `solid 1px ${color.primaryLight()}`,\n color: color.text(),\n backgroundColor: color.background()\n },\n svg: {},\n graphBox: {\n cursor: 'pointer',\n userSelect: 'none'\n }\n});\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
|
package/lib/trig.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.toRadians = exports.toDegrees = exports.hypotenuse = exports.getOpposingSide = exports.edges = exports.diffEdge = exports.angle = exports.acuteYAngle = exports.acuteXAngle = void 0;
|
|
7
7
|
|
|
8
8
|
var _utils = require("../lib/utils");
|
|
9
9
|
|
package/lib/trig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trig.js"],"names":["log","toDegrees","radians","Math","PI","toRadians","degrees","angle","a","b","vd","y","hd","x","atan2","NINETY","ONE_EIGHTY","TWO_SEVENTY","acuteXAngle","abs","acuteYAngle","hypotenuse","alpha","out","sin","edges","domain","range","destX","max","min","destY","aToB","diffEdge","dX","dY","bToA","getOpposingSide","hyp","getShortestSide","xh","yh","Number","isFinite","isNaN","Infinity","console","warn","bounds","l","enabled","bind","xRadians","yRadians","xSide","xH","ySide","yH","side","Error","point","Point","multiplier","multByPoint","normalized","add"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,OAAO;AAAA,SAAIA,OAAO,IAAI,MAAMC,IAAI,CAACC,EAAf,CAAX;A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AI,GAAGnB,eAAe,CAACgB,EAAD,EAAKE,EAAL,CAA5B;;AAEA,MAAIC,IAAI,KAAK,GAAT,IAAgBA,IAAI,KAAK,GAA7B,EAAkC;AAChC,UAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAMC,KAAK,GACTF,IAAI,KAAK,GAAT,GACI,IAAIG,yBAAJ,CAAUP,KAAV,EAAiBjB,eAAe,CAACkB,EAAD,EAAKH,QAAL,CAAhC,CADJ,GAEI,IAAIS,yBAAJ,CAAUxB,eAAe,CAACoB,EAAD,EAAKJ,QAAL,CAAzB,EAAyCG,KAAzC,CAHN;AAKAP,EAAAA,CAAC,CAAC,QAAD,EAAWW,KAAX,CAAD;AACA,MAAME,UAAU,GAAG,IAAID,yBAAJ,CAAUpD,CAAC,CAACI,CAAF,GAAML,CAAC,CAACK,CAAR,GAAY,CAAC,CAAb,GAAiB,CAA3B,EAA8BJ,CAAC,CAACE,CAAF,GAAMH,CAAC,CAACG,CAAR,GAAY,CAAC,CAAb,GAAiB,CAA/C,CAAnB;AACAsC,EAAAA,CAAC,CAAC,aAAD,EAAgBa,UAAhB,CAAD;AACA,MAAMvC,GAAG,GAAGqC,KAAK,CAACG,WAAN,CAAkBD,UAAlB,CAAZ;AACAb,EAAAA,CAAC,CAAC,MAAD,EAAS1B,GAAT,CAAD;AACA,MAAMyC,UAAU,GAAGzC,GAAG,CAAC0C,GAAJ,CAAQ,IAAIJ,yBAAJ,CAAUrD,CAAC,CAACK,CAAZ,EAAeL,CAAC,CAACG,CAAjB,CAAR,CAAnB;AACAsC,EAAAA,CAAC,CAAC,aAAD,EAAgBe,UAAhB,CAAD;AACA,SAAOA,UAAP;AACD,CAxCM","sourcesContent":["import { xy } from '../lib/utils';\nimport Point from '@mapbox/point-geometry';\nimport debug from 'debug';\nconst log = debug('pie-lib:plot:trig');\n\nexport const toDegrees = radians => radians * (180 / Math.PI);\nexport const toRadians = degrees => degrees * (Math.PI / 180);\n/**\n * return angle in radians between 2 points using counting degrees counter clockwise\n *\n * 0,0 + 1,1 = 45 in radians\n * 1,1 + 0,0 = 45?\n * @param {Point} a\n * @param {Point} b\n */\nexport const angle = (a, b) => {\n const vd = b.y - a.y;\n const hd = b.x - a.x;\n log(a, b, 'vd: ', vd, 'hd: ', hd);\n const radians = Math.atan2(vd, hd);\n return radians < 0 ? radians + Math.PI * 2 : radians;\n};\n\nconst NINETY = Math.PI / 2;\nconst ONE_EIGHTY = Math.PI;\nconst TWO_SEVENTY = ONE_EIGHTY + NINETY;\n\nexport const acuteXAngle = a => {\n log(toDegrees(a));\n\n if (a < NINETY) {\n return a;\n }\n\n if (a < ONE_EIGHTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n if (a < TWO_SEVENTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n return Math.abs(Math.PI * 2 - a);\n};\n\nexport const acuteYAngle = a => NINETY - acuteXAngle(a);\n\nexport const hypotenuse = (a, alpha) => {\n const out = Math.abs(a / Math.sin(alpha));\n\n return out;\n};\n\n/**\n * return 2 edge points for a,b within domain + range.\n * - one edge is from following a -> b to the bounds\n * - one edge is from following b -> a to the bounds\n * @param {{min: number, max: number}} domain\n * @param {{min: number, max: number}} range\n * @param {{x: number, y: number}} a\n * @param {{x: number, y: number}} b\n * @returns [{x: number, y: number}, {x: number, y: number}]\n */\nexport const edges = (domain, range) => (a, b) => {\n // const xDest =\n const destX = a.x < b.x ? domain.max : domain.min;\n const destY = a.y < b.y ? range.max : range.min;\n const aToB = diffEdge(xy(destX, destY), a, b);\n\n const dX = b.x < a.x ? domain.max : domain.min;\n const dY = b.y < a.y ? range.max : range.min;\n const bToA = diffEdge(xy(dX, dY), b, a);\n return [aToB, bToA];\n};\n\n/** get length of side A of a triangle from H and angle Alpha */\nexport const getOpposingSide = (hyp, angle) => {\n log('[getOpposingSide] hyp: ', hyp, 'angle:', angle);\n return Math.abs(hyp * Math.sin(angle));\n};\n\nconst getShortestSide = (xh, yh) => {\n if (Number.isFinite(xh) && Number.isFinite(yh)) {\n if (xh === 0 && yh > 0) {\n return 'y';\n }\n if (yh === 0 && xh > 0) {\n return 'x';\n }\n return xh < yh ? 'x' : 'y';\n }\n if (isNaN(xh) && !isNaN(yh)) {\n return 'y';\n }\n if (!isNaN(xh) && isNaN(yh)) {\n return 'x';\n }\n if (xh === Infinity) {\n return 'y';\n }\n if (yh === Infinity) {\n return 'x';\n }\n\n // eslint-disable-next-line no-console\n console.warn('hypotenuse - which is shorter? x:', xh, 'y:', yh);\n};\n/**\n * return the difference between bounds and a as a Point\n * @param {*} bounds\n */\nexport const diffEdge = (bounds, a, b) => {\n let l = log.enabled ? log.bind(log, `diffEdge: [${a.x},${a.y} -> ${b.x},${b.y}]`) : () => {};\n const xRadians = angle(a, b);\n l('x angle', toDegrees(xRadians));\n const yRadians = Math.abs(xRadians - toRadians(90));\n l('y angle', toDegrees(yRadians));\n const xSide = Math.abs(a.x - bounds.x);\n\n /**\n * Draw 2 triangles:\n * 1 with a horizontal line from a to the graph x edge\n * 1 with a vertical line from a to the graph y edge\n * Calculate the hypotenuse for both, whichever is shorter\n * indicates that we should use that triangle to get the edge point.\n */\n const xH = hypotenuse(xSide, yRadians);\n\n const ySide = Math.abs(a.y - bounds.y);\n const yH = hypotenuse(ySide, xRadians);\n\n l('x: side', xSide, 'h:', xH);\n l('y: side', ySide, 'h:', yH);\n const side = getShortestSide(xH, yH);\n\n if (side !== 'x' && side !== 'y') {\n throw new Error('Cant decide which hypotenuse to use');\n }\n const point =\n side === 'x'\n ? new Point(xSide, getOpposingSide(xH, xRadians))\n : new Point(getOpposingSide(yH, yRadians), ySide);\n\n l('point:', point);\n const multiplier = new Point(b.x < a.x ? -1 : 1, b.y < a.y ? -1 : 1);\n l('multiplier:', multiplier);\n const out = point.multByPoint(multiplier);\n l('out:', out);\n const normalized = out.add(new Point(a.x, a.y));\n l('normalized:', normalized);\n return normalized;\n};\n"],"file":"trig.js"}
|
|
1
|
+
{"version":3,"sources":["../src/trig.js"],"names":["log","toDegrees","radians","Math","PI","toRadians","degrees","angle","a","b","vd","y","hd","x","atan2","NINETY","ONE_EIGHTY","TWO_SEVENTY","acuteXAngle","abs","acuteYAngle","hypotenuse","alpha","out","sin","edges","domain","range","destX","max","min","destY","aToB","diffEdge","dX","dY","bToA","getOpposingSide","hyp","getShortestSide","xh","yh","Number","isFinite","isNaN","Infinity","console","warn","bounds","l","enabled","bind","xRadians","yRadians","xSide","xH","ySide","yH","side","Error","point","Point","multiplier","multByPoint","normalized","add"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;AAEO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,OAAO;AAAA,SAAIA,OAAO,IAAI,MAAMC,IAAI,CAACC,EAAf,CAAX;AAAA,CAAzB;;;;AACA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,OAAO;AAAA,SAAIA,OAAO,IAAIH,IAAI,CAACC,EAAL,GAAU,GAAd,CAAX;AAAA,CAAzB;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,IAAMG,KAAK,GAAG,SAARA,KAAQ,CAACC,CAAD,EAAIC,CAAJ,EAAU;AAC7B,MAAMC,EAAE,GAAGD,CAAC,CAACE,CAAF,GAAMH,CAAC,CAACG,CAAnB;AACA,MAAMC,EAAE,GAAGH,CAAC,CAACI,CAAF,GAAML,CAAC,CAACK,CAAnB;AACAb,EAAAA,GAAG,CAACQ,CAAD,EAAIC,CAAJ,EAAO,MAAP,EAAeC,EAAf,EAAmB,MAAnB,EAA2BE,EAA3B,CAAH;AACA,MAAMV,OAAO,GAAGC,IAAI,CAACW,KAAL,CAAWJ,EAAX,EAAeE,EAAf,CAAhB;AACA,SAAOV,OAAO,GAAG,CAAV,GAAcA,OAAO,GAAGC,IAAI,CAACC,EAAL,GAAU,CAAlC,GAAsCF,OAA7C;AACD,CANM;;;AAQP,IAAMa,MAAM,GAAG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,CAAb,GAAiB,CAA/C,CAAnB;AACAsC,EAAAA,CAAC,CAAC,aAAD,EAAgBa,UAAhB,CAAD;AACA,MAAMvC,GAAG,GAAGqC,KAAK,CAACG,WAAN,CAAkBD,UAAlB,CAAZ;AACAb,EAAAA,CAAC,CAAC,MAAD,EAAS1B,GAAT,CAAD;AACA,MAAMyC,UAAU,GAAGzC,GAAG,CAAC0C,GAAJ,CAAQ,IAAIJ,yBAAJ,CAAUrD,CAAC,CAACK,CAAZ,EAAeL,CAAC,CAACG,CAAjB,CAAR,CAAnB;AACAsC,EAAAA,CAAC,CAAC,aAAD,EAAgBe,UAAhB,CAAD;AACA,SAAOA,UAAP;AACD,CAxCM","sourcesContent":["import { xy } from '../lib/utils';\nimport Point from '@mapbox/point-geometry';\nimport debug from 'debug';\nconst log = debug('pie-lib:plot:trig');\n\nexport const toDegrees = radians => radians * (180 / Math.PI);\nexport const toRadians = degrees => degrees * (Math.PI / 180);\n/**\n * return angle in radians between 2 points using counting degrees counter clockwise\n *\n * 0,0 + 1,1 = 45 in radians\n * 1,1 + 0,0 = 45?\n * @param {Point} a\n * @param {Point} b\n */\nexport const angle = (a, b) => {\n const vd = b.y - a.y;\n const hd = b.x - a.x;\n log(a, b, 'vd: ', vd, 'hd: ', hd);\n const radians = Math.atan2(vd, hd);\n return radians < 0 ? radians + Math.PI * 2 : radians;\n};\n\nconst NINETY = Math.PI / 2;\nconst ONE_EIGHTY = Math.PI;\nconst TWO_SEVENTY = ONE_EIGHTY + NINETY;\n\nexport const acuteXAngle = a => {\n log(toDegrees(a));\n\n if (a < NINETY) {\n return a;\n }\n\n if (a < ONE_EIGHTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n if (a < TWO_SEVENTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n return Math.abs(Math.PI * 2 - a);\n};\n\nexport const acuteYAngle = a => NINETY - acuteXAngle(a);\n\nexport const hypotenuse = (a, alpha) => {\n const out = Math.abs(a / Math.sin(alpha));\n\n return out;\n};\n\n/**\n * return 2 edge points for a,b within domain + range.\n * - one edge is from following a -> b to the bounds\n * - one edge is from following b -> a to the bounds\n * @param {{min: number, max: number}} domain\n * @param {{min: number, max: number}} range\n * @param {{x: number, y: number}} a\n * @param {{x: number, y: number}} b\n * @returns [{x: number, y: number}, {x: number, y: number}]\n */\nexport const edges = (domain, range) => (a, b) => {\n // const xDest =\n const destX = a.x < b.x ? domain.max : domain.min;\n const destY = a.y < b.y ? range.max : range.min;\n const aToB = diffEdge(xy(destX, destY), a, b);\n\n const dX = b.x < a.x ? domain.max : domain.min;\n const dY = b.y < a.y ? range.max : range.min;\n const bToA = diffEdge(xy(dX, dY), b, a);\n return [aToB, bToA];\n};\n\n/** get length of side A of a triangle from H and angle Alpha */\nexport const getOpposingSide = (hyp, angle) => {\n log('[getOpposingSide] hyp: ', hyp, 'angle:', angle);\n return Math.abs(hyp * Math.sin(angle));\n};\n\nconst getShortestSide = (xh, yh) => {\n if (Number.isFinite(xh) && Number.isFinite(yh)) {\n if (xh === 0 && yh > 0) {\n return 'y';\n }\n if (yh === 0 && xh > 0) {\n return 'x';\n }\n return xh < yh ? 'x' : 'y';\n }\n if (isNaN(xh) && !isNaN(yh)) {\n return 'y';\n }\n if (!isNaN(xh) && isNaN(yh)) {\n return 'x';\n }\n if (xh === Infinity) {\n return 'y';\n }\n if (yh === Infinity) {\n return 'x';\n }\n\n // eslint-disable-next-line no-console\n console.warn('hypotenuse - which is shorter? x:', xh, 'y:', yh);\n};\n/**\n * return the difference between bounds and a as a Point\n * @param {*} bounds\n */\nexport const diffEdge = (bounds, a, b) => {\n let l = log.enabled ? log.bind(log, `diffEdge: [${a.x},${a.y} -> ${b.x},${b.y}]`) : () => {};\n const xRadians = angle(a, b);\n l('x angle', toDegrees(xRadians));\n const yRadians = Math.abs(xRadians - toRadians(90));\n l('y angle', toDegrees(yRadians));\n const xSide = Math.abs(a.x - bounds.x);\n\n /**\n * Draw 2 triangles:\n * 1 with a horizontal line from a to the graph x edge\n * 1 with a vertical line from a to the graph y edge\n * Calculate the hypotenuse for both, whichever is shorter\n * indicates that we should use that triangle to get the edge point.\n */\n const xH = hypotenuse(xSide, yRadians);\n\n const ySide = Math.abs(a.y - bounds.y);\n const yH = hypotenuse(ySide, xRadians);\n\n l('x: side', xSide, 'h:', xH);\n l('y: side', ySide, 'h:', yH);\n const side = getShortestSide(xH, yH);\n\n if (side !== 'x' && side !== 'y') {\n throw new Error('Cant decide which hypotenuse to use');\n }\n const point =\n side === 'x'\n ? new Point(xSide, getOpposingSide(xH, xRadians))\n : new Point(getOpposingSide(yH, yRadians), ySide);\n\n l('point:', point);\n const multiplier = new Point(b.x < a.x ? -1 : 1, b.y < a.y ? -1 : 1);\n l('multiplier:', multiplier);\n const out = point.multByPoint(multiplier);\n l('out:', out);\n const normalized = out.add(new Point(a.x, a.y));\n l('normalized:', normalized);\n return normalized;\n};\n"],"file":"trig.js"}
|
package/lib/types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SnapType = exports.SizeType = exports.ScaleType = exports.RangeType = exports.PointType = exports.GraphPropsType = exports.DomainType = exports.ChildrenType = exports.BaseDomainRangeType = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
package/lib/utils.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.buildSizeArray = exports.bounds = exports.bandKey = exports.amountToIncreaseWidth = void 0;
|
|
7
|
+
exports.buildTickModel = buildTickModel;
|
|
8
|
+
exports.getDelta = exports.findLongestWord = void 0;
|
|
6
9
|
exports.getInterval = getInterval;
|
|
10
|
+
exports.polygonToArea = exports.point = exports.lineToArea = exports.isDomainRangeEqual = void 0;
|
|
7
11
|
exports.snapTo = snapTo;
|
|
8
|
-
exports.
|
|
9
|
-
exports.amountToIncreaseWidth = exports.findLongestWord = exports.isDomainRangeEqual = exports.bandKey = exports.getDelta = exports.point = exports.bounds = exports.lineToArea = exports.polygonToArea = exports.tickCount = exports.buildSizeArray = exports.xy = void 0;
|
|
12
|
+
exports.xy = exports.tickCount = void 0;
|
|
10
13
|
|
|
11
14
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
12
15
|
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["xy","x","y","buildSizeArray","size","padding","Number","isFinite","Math","max","half","round","tickCount","min","step","abs","getInterval","domain","ticks","major","minor","Error","distance","minorTicks","normalizedMajor","isNaN","divider","raw","parseFloat","toFixed","mkRange","interval","splice","length","snapTo","value","rng","filter","v","reduce","prev","curr","currentDistance","previousDistance","buildTickModel","scaleFn","map","r","index","isMajor","polygonToArea","points","h","area","left","top","bottom","right","a","p","lineToArea","from","to","bounds","range","point","o","Point","getDelta","sub","bandKey","d","label","isDomainRangeEqual","graphProps","nextGraphProps","findLongestWord","longestWord","replace","split","sort","b","amountToIncreaseWidth"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,EAAE,GAAG,SAALA,EAAK,CAACC,CAAD,EAAIC,CAAJ;AAAA,SAAW;AAAED,IAAAA,CAAC,EAADA,CAAF;AAAKC,IAAAA,CAAC,EAADA;AAAL,GAAX;AAAA,CAAX;;;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD,EAAOC,OAAP,EAAmB;AAC/CA,EAAAA,OAAO,GAAGC,MAAM,CAACC,QAAP,CAAgBF,OAAhB,IAA2BG,IAAI,CAACC,GAAL,CAASJ,OAAT,EAAkB,CAAlB,CAA3B,GAAkD,CAA5D;AACA,6BAAUA,OAAO,GAAGD,IAApB,EAA0B,gCAA1B;A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B;AACD,CAPM,C,CASP;;;;;AACO,IAAMiD,qBAAqB,GAAG,SAAxBA,qBAAwB,CAAAL,WAAW,EAAI;AAClD,MAAI,CAACA,WAAL,EAAkB;AAChB,WAAO,CAAP;AACD;;AAED,SAAOA,WAAW,GAAG,EAArB;AACD,CANM","sourcesContent":["import invariant from 'invariant';\nimport range from 'lodash/range';\nimport Point from '@mapbox/point-geometry';\nimport head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport isEqual from 'lodash/isEqual';\n\nexport const xy = (x, y) => ({ x, y });\n\nexport const buildSizeArray = (size, padding) => {\n padding = Number.isFinite(padding) ? Math.max(padding, 0) : 0;\n invariant(padding < size, 'padding must be less than size');\n const half = Math.round(padding * 0.5);\n return [half, size - half];\n};\n\nexport const tickCount = (min, max, step) => {\n invariant(min < max, 'min must be less than max');\n const size = Math.abs(min - max);\n return Math.round(size / step);\n};\n\nexport function getInterval(domain, ticks) {\n const { min, max } = domain;\n const { major, minor } = ticks;\n\n if (min >= max) {\n throw new Error(`min is > max: ${min} > ${max}`);\n }\n\n const distance = max - min;\n const minorTicks = minor > 0 ? minor + 1 : 1;\n const normalizedMajor = major - 1;\n\n if (isNaN(normalizedMajor)) {\n throw new Error('Tick Frequency must be 2 or higher');\n }\n\n if (normalizedMajor <= 0) {\n throw new Error('Tick Frequency must be 2 or higher');\n }\n\n const divider = normalizedMajor * minorTicks;\n const raw = distance / divider;\n return parseFloat(Number(raw).toFixed(4));\n}\n\nconst mkRange = (min, max, interval) => {\n const raw = range(min, max, interval);\n /* Fix the last step due to rounding errors */\n raw.splice(raw.length, 1, max);\n return raw;\n};\n\nexport function snapTo(min, max, interval, value) {\n if (value >= max) {\n return max;\n }\n\n if (value <= min) {\n return min;\n }\n\n let rng = mkRange(min, max, interval);\n\n rng = rng.filter(v => {\n return Math.abs(value - v) <= interval;\n });\n\n return (\n rng.length &&\n rng.reduce((prev, curr) => {\n const currentDistance = Math.abs(curr - value);\n const previousDistance = Math.abs(prev - value);\n return currentDistance <= previousDistance ? curr : prev;\n })\n );\n}\n\nexport function buildTickModel(domain, ticks, interval, scaleFn) {\n const rng = mkRange(domain.min, domain.max, interval);\n\n return rng.map((r, index) => {\n const isMajor = index % (ticks.minor + 1) === 0;\n\n return {\n value: r,\n major: isMajor,\n x: scaleFn(r)\n };\n });\n}\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => {\n const left = Math.min(from.x, to.x);\n const top = Math.max(from.y, to.y);\n const bottom = Math.min(from.y, to.y);\n const right = Math.max(from.x, to.x);\n return { left, top, bottom, right };\n};\n\nexport const bounds = (area, domain, range) => {\n return {\n left: domain.min - area.left,\n right: Math.abs(area.right - domain.max),\n top: Math.abs(area.top - range.max),\n bottom: range.min - area.bottom\n };\n};\n\nexport const point = o => new Point(o.x, o.y);\nexport const getDelta = (from, to) => {\n return point(to).sub(point(from));\n};\n\nexport const bandKey = (d, index) => `${index}-${d.label || '-'}`;\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\n// findLongestWord is also used in grapghing\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in grapghing\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n"],"file":"utils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["xy","x","y","buildSizeArray","size","padding","Number","isFinite","Math","max","half","round","tickCount","min","step","abs","getInterval","domain","ticks","major","minor","Error","distance","minorTicks","normalizedMajor","isNaN","divider","raw","parseFloat","toFixed","mkRange","interval","splice","length","snapTo","value","rng","filter","v","reduce","prev","curr","currentDistance","previousDistance","buildTickModel","scaleFn","map","r","index","isMajor","polygonToArea","points","h","area","left","top","bottom","right","a","p","lineToArea","from","to","bounds","range","point","o","Point","getDelta","sub","bandKey","d","label","isDomainRangeEqual","graphProps","nextGraphProps","findLongestWord","longestWord","replace","split","sort","b","amountToIncreaseWidth"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,EAAE,GAAG,SAALA,EAAK,CAACC,CAAD,EAAIC,CAAJ;AAAA,SAAW;AAAED,IAAAA,CAAC,EAADA,CAAF;AAAKC,IAAAA,CAAC,EAADA;AAAL,GAAX;AAAA,CAAX;;;;AAEA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,IAAD,EAAOC,OAAP,EAAmB;AAC/CA,EAAAA,OAAO,GAAGC,MAAM,CAACC,QAAP,CAAgBF,OAAhB,IAA2BG,IAAI,CAACC,GAAL,CAASJ,OAAT,EAAkB,CAAlB,CAA3B,GAAkD,CAA5D;AACA,6BAAUA,OAAO,GAAGD,IAApB,EAA0B,gCAA1B;AACA,MAAMM,IAAI,GAAGF,IAAI,CAACG,KAAL,CAAWN,OAAO,GAAG,GAArB,CAAb;AACA,SAAO,CAACK,IAAD,EAAON,IAAI,GAAGM,IAAd,CAAP;AACD,CALM;;;;AAOA,IAAME,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAMJ,GAAN,EAAWK,IAAX,EAAoB;AAC3C,6BAAUD,GAAG,GAAGJ,GAAhB,EAAqB,2BAArB;AACA,MAAML,IAAI,GAAGI,IAAI,CAACO,GAAL,CAASF,GAAG,GAAGJ,GAAf,CAAb;AACA,SAAOD,IAAI,CAACG,KAAL,CAAWP,IAAI,GAAGU,IAAlB,CAAP;AACD,CAJM;;;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,GAAV,CAAcJ,KAAK,CAACJ,IAAD,CAAnB,CAAP;AACD,CAFM;;;;AAIA,IAAMS,OAAO,GAAG,SAAVA,OAAU,CAACC,CAAD,EAAIvB,KAAJ;AAAA,mBAAiBA,KAAjB,cAA0BuB,CAAC,CAACC,KAAF,IAAW,GAArC;AAAA,CAAhB;;;;AAEA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,UAAD,EAAaC,cAAb,EAAgC;AAChE,SACE,yBAAQD,UAAU,CAACzD,MAAnB,EAA2B0D,cAAc,CAAC1D,MAA1C,KACA,yBAAQyD,UAAU,CAACV,KAAnB,EAA0BW,cAAc,CAACX,KAAzC,CAFF;AAID,CALM,C,CAOP;;;;;AACO,IAAMY,eAAe,GAAG,SAAlBA,eAAkB,CAAAJ,KAAK,EAAI;AACtC,MAAIK,WAAW,GAAG,CAACL,KAAK,IAAI,EAAV,EACfM,OADe,CACP,UADO,EACK,EADL,EAEfC,KAFe,CAET,GAFS,EAGfC,IAHe,CAGV,UAACtB,CAAD,EAAIuB,CAAJ;AAAA,WAAUA,CAAC,CAAChD,MAAF,GAAWyB,CAAC,CAACzB,MAAvB;AAAA,GAHU,CAAlB;AAKA,SAAO4C,WAAW,CAAC,CAAD,CAAX,CAAe5C,MAAtB;AACD,CAPM,C,CASP;;;;;AACO,IAAMiD,qBAAqB,GAAG,SAAxBA,qBAAwB,CAAAL,WAAW,EAAI;AAClD,MAAI,CAACA,WAAL,EAAkB;AAChB,WAAO,CAAP;AACD;;AAED,SAAOA,WAAW,GAAG,EAArB;AACD,CANM","sourcesContent":["import invariant from 'invariant';\nimport range from 'lodash/range';\nimport Point from '@mapbox/point-geometry';\nimport head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport isEqual from 'lodash/isEqual';\n\nexport const xy = (x, y) => ({ x, y });\n\nexport const buildSizeArray = (size, padding) => {\n padding = Number.isFinite(padding) ? Math.max(padding, 0) : 0;\n invariant(padding < size, 'padding must be less than size');\n const half = Math.round(padding * 0.5);\n return [half, size - half];\n};\n\nexport const tickCount = (min, max, step) => {\n invariant(min < max, 'min must be less than max');\n const size = Math.abs(min - max);\n return Math.round(size / step);\n};\n\nexport function getInterval(domain, ticks) {\n const { min, max } = domain;\n const { major, minor } = ticks;\n\n if (min >= max) {\n throw new Error(`min is > max: ${min} > ${max}`);\n }\n\n const distance = max - min;\n const minorTicks = minor > 0 ? minor + 1 : 1;\n const normalizedMajor = major - 1;\n\n if (isNaN(normalizedMajor)) {\n throw new Error('Tick Frequency must be 2 or higher');\n }\n\n if (normalizedMajor <= 0) {\n throw new Error('Tick Frequency must be 2 or higher');\n }\n\n const divider = normalizedMajor * minorTicks;\n const raw = distance / divider;\n return parseFloat(Number(raw).toFixed(4));\n}\n\nconst mkRange = (min, max, interval) => {\n const raw = range(min, max, interval);\n /* Fix the last step due to rounding errors */\n raw.splice(raw.length, 1, max);\n return raw;\n};\n\nexport function snapTo(min, max, interval, value) {\n if (value >= max) {\n return max;\n }\n\n if (value <= min) {\n return min;\n }\n\n let rng = mkRange(min, max, interval);\n\n rng = rng.filter(v => {\n return Math.abs(value - v) <= interval;\n });\n\n return (\n rng.length &&\n rng.reduce((prev, curr) => {\n const currentDistance = Math.abs(curr - value);\n const previousDistance = Math.abs(prev - value);\n return currentDistance <= previousDistance ? curr : prev;\n })\n );\n}\n\nexport function buildTickModel(domain, ticks, interval, scaleFn) {\n const rng = mkRange(domain.min, domain.max, interval);\n\n return rng.map((r, index) => {\n const isMajor = index % (ticks.minor + 1) === 0;\n\n return {\n value: r,\n major: isMajor,\n x: scaleFn(r)\n };\n });\n}\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => {\n const left = Math.min(from.x, to.x);\n const top = Math.max(from.y, to.y);\n const bottom = Math.min(from.y, to.y);\n const right = Math.max(from.x, to.x);\n return { left, top, bottom, right };\n};\n\nexport const bounds = (area, domain, range) => {\n return {\n left: domain.min - area.left,\n right: Math.abs(area.right - domain.max),\n top: Math.abs(area.top - range.max),\n bottom: range.min - area.bottom\n };\n};\n\nexport const point = o => new Point(o.x, o.y);\nexport const getDelta = (from, to) => {\n return point(to).sub(point(from));\n};\n\nexport const bandKey = (d, index) => `${index}-${d.label || '-'}`;\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\n// findLongestWord is also used in grapghing\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in grapghing\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n"],"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.1.
|
|
6
|
+
"version": "2.1.10-next.258+a608e1b7",
|
|
7
7
|
"description": "Some underlying components for building charts/graphs",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "^16.8.1"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a608e1b78c1f40ac815d0e09a935513b349da0b2",
|
|
42
42
|
"scripts": {}
|
|
43
43
|
}
|
package/src/root.jsx
CHANGED
|
@@ -16,9 +16,12 @@ export const GraphTitle = withStyles(theme => ({
|
|
|
16
16
|
fontSize: theme.typography.fontSize + 6
|
|
17
17
|
}
|
|
18
18
|
}))(({ value, classes }) => (
|
|
19
|
-
<Typography
|
|
20
|
-
{
|
|
21
|
-
|
|
19
|
+
<Typography
|
|
20
|
+
className={classes.title}
|
|
21
|
+
color="primary"
|
|
22
|
+
variant="h5"
|
|
23
|
+
dangerouslySetInnerHTML={{ __html: value }}
|
|
24
|
+
/>
|
|
22
25
|
));
|
|
23
26
|
|
|
24
27
|
export class Root extends React.Component {
|