@esri/solutions-components 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/buffer-tools_6.cjs.entry.js +26 -8
- package/dist/cjs/calcite-combobox_3.cjs.entry.js +2 -2
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +6 -4
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
- package/dist/cjs/{csvUtils-83af7ae1.js → csvUtils-34666909.js} +1 -1
- package/dist/cjs/{interfaces-772edf61.js → interfaces-17c631bf.js} +1 -1
- package/dist/cjs/layer-table.cjs.entry.js +3 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-card.cjs.entry.js +1 -1
- package/dist/cjs/{mapViewUtils-55ac76cb.js → mapViewUtils-24d1d859.js} +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +41 -7
- package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
- package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
- package/dist/cjs/{solution-store-39726b81.js → solution-store-2dbab624.js} +1 -1
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/buffer-tools/buffer-tools.js +48 -0
- package/dist/collection/components/map-draw-tools/map-draw-tools.js +10 -4
- package/dist/collection/components/public-notification/public-notification.css +12 -12
- package/dist/collection/components/public-notification/public-notification.js +50 -4
- package/dist/collection/components/refine-selection/refine-selection.js +4 -2
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.css +1 -0
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +3 -1
- package/dist/collection/demos/new-public-notification.html +7 -6
- package/dist/collection/utils/interfaces.js +1 -1
- package/dist/collection/utils/interfaces.ts +7 -2
- package/dist/components/buffer-tools2.js +10 -0
- package/dist/components/interfaces3.js +1 -1
- package/dist/components/map-draw-tools2.js +10 -4
- package/dist/components/public-notification.js +40 -6
- package/dist/components/refine-selection-tools2.js +4 -2
- package/dist/components/refine-selection2.js +4 -2
- package/dist/esm/buffer-tools_6.entry.js +26 -8
- package/dist/esm/calcite-combobox_3.entry.js +2 -2
- package/dist/esm/calcite-input-message_5.entry.js +6 -4
- package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
- package/dist/esm/{csvUtils-eb231cfb.js → csvUtils-ae3004b9.js} +1 -1
- package/dist/esm/{interfaces-3b23a5f9.js → interfaces-d0d83efa.js} +1 -1
- package/dist/esm/layer-table.entry.js +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-card.entry.js +1 -1
- package/dist/esm/{mapViewUtils-e5d8a1e1.js → mapViewUtils-541e7a3c.js} +1 -1
- package/dist/esm/public-notification.entry.js +41 -7
- package/dist/esm/solution-configuration.entry.js +2 -2
- package/dist/esm/solution-contents_3.entry.js +2 -2
- package/dist/esm/{solution-store-c0bf9200.js → solution-store-41e15f1c.js} +1 -1
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/new-public-notification.html +7 -6
- package/dist/solutions-components/p-05e64bd1.js +498 -2
- package/dist/solutions-components/p-08a95b33.entry.js +138 -0
- package/dist/solutions-components/p-0da5bbdf.entry.js +91 -0
- package/dist/solutions-components/p-0ef91144.entry.js +913 -0
- package/dist/solutions-components/p-0f523243.entry.js +1916 -0
- package/dist/solutions-components/p-11b9510e.entry.js +173 -0
- package/dist/solutions-components/p-1b875d94.entry.js +58 -0
- package/dist/solutions-components/p-1c567f3a.js +23 -16
- package/dist/solutions-components/p-1c883db9.entry.js +43 -0
- package/dist/solutions-components/p-1f225056.js +322 -0
- package/dist/solutions-components/p-1f499e67.entry.js +72 -0
- package/dist/solutions-components/p-20d3d758.entry.js +881 -0
- package/dist/solutions-components/p-2274ac9e.entry.js +160 -0
- package/dist/solutions-components/p-23ec5ac5.entry.js +93 -0
- package/dist/solutions-components/p-2447798c.entry.js +155 -0
- package/dist/solutions-components/p-2525e691.entry.js +432 -0
- package/dist/solutions-components/p-2561f5b5.js +4092 -0
- package/dist/solutions-components/p-29f887c0.entry.js +234 -0
- package/dist/solutions-components/p-2a0d8047.entry.js +345 -0
- package/dist/solutions-components/p-2c177e6a.entry.js +101 -0
- package/dist/solutions-components/p-2e9ed892.js +46 -1
- package/dist/solutions-components/p-316f56db.js +219 -2
- package/dist/solutions-components/p-327f3ebf.entry.js +98 -0
- package/dist/solutions-components/p-356f8b54.entry.js +138 -0
- package/dist/solutions-components/p-359c58de.entry.js +172 -0
- package/dist/solutions-components/p-37336c0d.entry.js +116 -0
- package/dist/solutions-components/p-374a5031.js +105 -2
- package/dist/solutions-components/p-39ea6ef4.entry.js +71 -0
- package/dist/solutions-components/p-3b010ce1.js +17 -1
- package/dist/solutions-components/p-4307dacd.js +194 -1
- package/dist/solutions-components/p-44da2507.js +405 -14
- package/dist/solutions-components/p-46bdffe8.entry.js +54 -0
- package/dist/solutions-components/p-4894bbeb.js +53 -2
- package/dist/solutions-components/p-4cd569f1.entry.js +1298 -0
- package/dist/solutions-components/p-4d4160f9.entry.js +121 -0
- package/dist/solutions-components/p-4e32bf8c.js +482 -1
- package/dist/solutions-components/p-4e9cbd32.entry.js +184 -0
- package/dist/solutions-components/p-508317b3.js +13 -2
- package/dist/solutions-components/p-54697d58.entry.js +198 -0
- package/dist/solutions-components/p-55c79103.entry.js +311 -0
- package/dist/solutions-components/p-57fd19c0.entry.js +706 -0
- package/dist/solutions-components/p-59b48fde.entry.js +443 -0
- package/dist/solutions-components/p-60e0e6a0.entry.js +214 -0
- package/dist/solutions-components/p-621d0534.entry.js +123 -0
- package/dist/solutions-components/p-63f6e8f1.js +14 -1
- package/dist/solutions-components/p-66aeec57.entry.js +61 -0
- package/dist/solutions-components/p-69834f46.entry.js +618 -0
- package/dist/solutions-components/p-6d9da8e5.entry.js +21530 -0
- package/dist/solutions-components/p-6e0da576.js +13 -1
- package/dist/solutions-components/p-6ec3f294.entry.js +106 -0
- package/dist/solutions-components/p-6fe17794.js +9 -1
- package/dist/solutions-components/p-7024cb16.entry.js +72 -0
- package/dist/solutions-components/p-70535506.entry.js +226 -0
- package/dist/solutions-components/p-708a63a8.js +12 -1
- package/dist/solutions-components/p-729708a3.js +14 -1
- package/dist/solutions-components/p-73e23995.js +6 -1
- package/dist/solutions-components/p-74b29d75.entry.js +231 -0
- package/dist/solutions-components/p-74b7ee25.entry.js +711 -0
- package/dist/solutions-components/p-77182c3a.js +3015 -1
- package/dist/solutions-components/p-78b3ef80.entry.js +456 -0
- package/dist/solutions-components/p-79709c19.js +60 -3
- package/dist/solutions-components/p-7a46ef97.js +181 -2
- package/dist/solutions-components/p-7be159e6.entry.js +175 -0
- package/dist/solutions-components/p-7d4451c2.entry.js +71 -0
- package/dist/solutions-components/p-7daea1df.js +41 -1
- package/dist/solutions-components/p-7e39e5ad.entry.js +102 -0
- package/dist/solutions-components/p-7fb45059.entry.js +43 -0
- package/dist/solutions-components/p-815533de.js +306 -3
- package/dist/solutions-components/p-816622ca.entry.js +248 -0
- package/dist/solutions-components/p-83166522.js +205 -2
- package/dist/solutions-components/p-83bd1991.entry.js +36 -0
- package/dist/solutions-components/p-856464d7.entry.js +572 -0
- package/dist/solutions-components/p-8c349bad.entry.js +347 -0
- package/dist/solutions-components/p-8dccb390.entry.js +1986 -0
- package/dist/solutions-components/p-904c185a.entry.js +228 -0
- package/dist/solutions-components/p-9092f8b3.entry.js +156 -0
- package/dist/solutions-components/p-9371145a.entry.js +477 -0
- package/dist/solutions-components/p-93d3119d.js +1948 -1
- package/dist/solutions-components/p-95ec8062.entry.js +173 -0
- package/dist/solutions-components/p-991ee695.js +109 -1
- package/dist/solutions-components/p-9a57dab7.entry.js +213 -0
- package/dist/solutions-components/p-9a9955db.js +41 -1
- package/dist/solutions-components/p-9c1ebc90.js +35 -16
- package/dist/solutions-components/p-9eba5c66.js +399 -3
- package/dist/solutions-components/p-a033a507.entry.js +252 -0
- package/dist/solutions-components/p-a3773415.entry.js +1132 -0
- package/dist/solutions-components/p-a44fe40f.entry.js +94 -0
- package/dist/solutions-components/p-a5b1ab03.js +33 -3
- package/dist/solutions-components/p-a5b2c13d.entry.js +723 -0
- package/dist/solutions-components/p-a6d729b7.entry.js +85 -0
- package/dist/solutions-components/p-a8005026.entry.js +565 -0
- package/dist/solutions-components/p-a80b3880.js +14 -1
- package/dist/solutions-components/p-a89198a3.entry.js +2620 -0
- package/dist/solutions-components/p-aa04bd1f.entry.js +95 -0
- package/dist/solutions-components/p-aa0a0922.entry.js +80 -0
- package/dist/solutions-components/p-ae1fd76b.js +11 -1
- package/dist/solutions-components/p-b2cf435e.entry.js +87 -0
- package/dist/solutions-components/p-b359dc78.js +41 -1
- package/dist/solutions-components/p-b57bc4eb.entry.js +71 -0
- package/dist/solutions-components/p-b75cc407.entry.js +145 -0
- package/dist/solutions-components/p-b911cb75.entry.js +71 -0
- package/dist/solutions-components/p-b965e177.entry.js +335 -0
- package/dist/solutions-components/p-b978636e.js +14 -1
- package/dist/solutions-components/p-ba10a5c8.entry.js +42 -0
- package/dist/solutions-components/p-bd67334c.js +122 -2
- package/dist/solutions-components/p-bde20dba.entry.js +212 -0
- package/dist/solutions-components/p-be0b5a94.entry.js +248 -0
- package/dist/solutions-components/p-c023e6a1.js +2028 -2
- package/dist/solutions-components/p-c27b0c2d.entry.js +150 -0
- package/dist/solutions-components/p-c579ed60.entry.js +447 -0
- package/dist/solutions-components/p-c92bc231.js +101 -2
- package/dist/solutions-components/p-cc815aca.js +839 -16
- package/dist/solutions-components/p-cc8beabb.entry.js +695 -0
- package/dist/solutions-components/p-cdc46c0c.js +1751 -2
- package/dist/solutions-components/p-d12e6992.entry.js +118 -0
- package/dist/solutions-components/p-d1dfed6b.entry.js +179 -0
- package/dist/solutions-components/p-d48a24e6.js +754 -2
- package/dist/solutions-components/p-d96ee3ef.entry.js +579 -0
- package/dist/solutions-components/p-dbc9a5a8.js +80 -0
- package/dist/solutions-components/p-dcdbe712.entry.js +278 -0
- package/dist/solutions-components/p-de39206f.entry.js +113 -0
- package/dist/solutions-components/p-de5416e8.js +28 -1
- package/dist/solutions-components/p-df420d54.entry.js +213 -0
- package/dist/solutions-components/p-e3138cf0.entry.js +20 -0
- package/dist/solutions-components/p-e4845fec.entry.js +152 -0
- package/dist/solutions-components/p-e611d8c8.js +28 -1
- package/dist/solutions-components/p-e947d3b0.js +5 -1
- package/dist/solutions-components/p-ea534300.js +41 -2
- package/dist/solutions-components/p-ec84ee85.entry.js +55 -0
- package/dist/solutions-components/p-ed36c637.entry.js +85 -0
- package/dist/solutions-components/p-f0add71c.js +74 -0
- package/dist/solutions-components/p-f42e014b.js +171 -2
- package/dist/solutions-components/p-fc02e7de.entry.js +308 -0
- package/dist/solutions-components/p-fc884dd6.js +28 -16
- package/dist/solutions-components/p-fcbfa59c.entry.js +181 -0
- package/dist/solutions-components/p-fdc5cf5f.entry.js +138 -0
- package/dist/solutions-components/solutions-components.esm.js +20 -1
- package/dist/solutions-components/utils/interfaces.ts +7 -2
- package/dist/types/components/buffer-tools/buffer-tools.d.ts +9 -1
- package/dist/types/components/public-notification/public-notification.d.ts +26 -0
- package/dist/types/components.d.ts +9 -1
- package/dist/types/preact.d.ts +3 -1
- package/dist/types/utils/interfaces.d.ts +4 -0
- package/package.json +1 -1
- package/dist/solutions-components/p-021432b8.entry.js +0 -12
- package/dist/solutions-components/p-03440b1e.entry.js +0 -11
- package/dist/solutions-components/p-0512635b.entry.js +0 -6
- package/dist/solutions-components/p-086ef115.entry.js +0 -29
- package/dist/solutions-components/p-0b4bf57f.entry.js +0 -6
- package/dist/solutions-components/p-0c088725.entry.js +0 -6
- package/dist/solutions-components/p-0f820c08.entry.js +0 -6
- package/dist/solutions-components/p-164780a0.entry.js +0 -6
- package/dist/solutions-components/p-179a68a0.entry.js +0 -6
- package/dist/solutions-components/p-184b5005.entry.js +0 -11
- package/dist/solutions-components/p-1d082fee.entry.js +0 -11
- package/dist/solutions-components/p-1e6c02a2.entry.js +0 -11
- package/dist/solutions-components/p-20a58e62.entry.js +0 -17
- package/dist/solutions-components/p-20b2458c.entry.js +0 -11
- package/dist/solutions-components/p-245d47c1.entry.js +0 -6
- package/dist/solutions-components/p-2cb057a9.entry.js +0 -11
- package/dist/solutions-components/p-2cc72806.entry.js +0 -23
- package/dist/solutions-components/p-2de1db9c.entry.js +0 -11
- package/dist/solutions-components/p-2e9c7055.entry.js +0 -11
- package/dist/solutions-components/p-2ed5e6c8.entry.js +0 -11
- package/dist/solutions-components/p-3109d940.entry.js +0 -6
- package/dist/solutions-components/p-31a8bcfa.entry.js +0 -6
- package/dist/solutions-components/p-3f88ba73.entry.js +0 -6
- package/dist/solutions-components/p-3fa9b3c8.js +0 -36
- package/dist/solutions-components/p-40c41709.entry.js +0 -6
- package/dist/solutions-components/p-40e963c7.entry.js +0 -11
- package/dist/solutions-components/p-40f480da.entry.js +0 -11
- package/dist/solutions-components/p-49d5d2d3.entry.js +0 -11
- package/dist/solutions-components/p-4f7049a4.entry.js +0 -11
- package/dist/solutions-components/p-506e4d78.entry.js +0 -6
- package/dist/solutions-components/p-576fdcab.entry.js +0 -6
- package/dist/solutions-components/p-5bd0cf34.entry.js +0 -23
- package/dist/solutions-components/p-65e177f1.entry.js +0 -6
- package/dist/solutions-components/p-67d710c2.entry.js +0 -6
- package/dist/solutions-components/p-7268b445.entry.js +0 -11
- package/dist/solutions-components/p-75ea4667.entry.js +0 -6
- package/dist/solutions-components/p-778c0a36.entry.js +0 -17
- package/dist/solutions-components/p-7a22509b.entry.js +0 -12
- package/dist/solutions-components/p-7bff51db.entry.js +0 -6
- package/dist/solutions-components/p-7d2d0d5d.entry.js +0 -6
- package/dist/solutions-components/p-7f0036f1.entry.js +0 -11
- package/dist/solutions-components/p-8060fb94.entry.js +0 -6
- package/dist/solutions-components/p-80a1b305.entry.js +0 -6
- package/dist/solutions-components/p-81eae877.entry.js +0 -12
- package/dist/solutions-components/p-84e86b8b.entry.js +0 -6
- package/dist/solutions-components/p-877dd0dc.entry.js +0 -18
- package/dist/solutions-components/p-9106950a.entry.js +0 -11
- package/dist/solutions-components/p-979804a4.entry.js +0 -11
- package/dist/solutions-components/p-9862baa8.entry.js +0 -11
- package/dist/solutions-components/p-9b5a9117.entry.js +0 -12
- package/dist/solutions-components/p-9deff0c2.entry.js +0 -6
- package/dist/solutions-components/p-9f400eeb.entry.js +0 -6
- package/dist/solutions-components/p-a0639ad1.entry.js +0 -11
- package/dist/solutions-components/p-a33c044e.entry.js +0 -6
- package/dist/solutions-components/p-a516c658.entry.js +0 -6
- package/dist/solutions-components/p-aa0ef36d.entry.js +0 -11
- package/dist/solutions-components/p-aaccbdf3.entry.js +0 -18
- package/dist/solutions-components/p-ab03a5c9.entry.js +0 -11
- package/dist/solutions-components/p-ad469b92.entry.js +0 -11
- package/dist/solutions-components/p-adc86ac3.entry.js +0 -6
- package/dist/solutions-components/p-addc1156.entry.js +0 -11
- package/dist/solutions-components/p-ae846934.entry.js +0 -11
- package/dist/solutions-components/p-b0572fc4.entry.js +0 -37
- package/dist/solutions-components/p-b4e476b7.js +0 -257
- package/dist/solutions-components/p-b668daf8.js +0 -21
- package/dist/solutions-components/p-b6e6eae1.entry.js +0 -6
- package/dist/solutions-components/p-bc317a7f.entry.js +0 -6
- package/dist/solutions-components/p-bd4d0773.entry.js +0 -6
- package/dist/solutions-components/p-be41429f.js +0 -21
- package/dist/solutions-components/p-bf6b6353.entry.js +0 -11
- package/dist/solutions-components/p-c2e3dfbb.entry.js +0 -11
- package/dist/solutions-components/p-c4afae53.entry.js +0 -12
- package/dist/solutions-components/p-c9da1c26.entry.js +0 -6
- package/dist/solutions-components/p-cbf8cd49.entry.js +0 -6
- package/dist/solutions-components/p-cc1a064a.entry.js +0 -11
- package/dist/solutions-components/p-d09a168c.entry.js +0 -6
- package/dist/solutions-components/p-d377f913.entry.js +0 -11
- package/dist/solutions-components/p-d4cefead.entry.js +0 -37
- package/dist/solutions-components/p-d7bc0baf.entry.js +0 -16
- package/dist/solutions-components/p-d8968487.entry.js +0 -11
- package/dist/solutions-components/p-e00a0b86.entry.js +0 -11
- package/dist/solutions-components/p-e9a7ed49.entry.js +0 -11
- package/dist/solutions-components/p-ec27e493.entry.js +0 -11
- package/dist/solutions-components/p-ed6404eb.entry.js +0 -6
- package/dist/solutions-components/p-ef21e195.entry.js +0 -23
- package/dist/solutions-components/p-f6068a2d.entry.js +0 -11
- package/dist/solutions-components/p-f6c4cff3.entry.js +0 -11
- package/dist/solutions-components/p-f847291f.entry.js +0 -6
- package/dist/solutions-components/p-f90fd262.entry.js +0 -11
- package/dist/solutions-components/p-fc973005.entry.js +0 -6
- package/dist/solutions-components/p-ff9fb6bc.entry.js +0 -11
@@ -0,0 +1,231 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { r as registerInstance, h, g as getElement, f as forceUpdate } from './p-c023e6a1.js';
|
7
|
+
import { g as guid } from './p-a80b3880.js';
|
8
|
+
import { c as createObserver } from './p-9a9955db.js';
|
9
|
+
|
10
|
+
/*!
|
11
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
12
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
13
|
+
* v1.0.0-beta.97
|
14
|
+
*/
|
15
|
+
/**
|
16
|
+
* Calculate slope of the tangents
|
17
|
+
* uses Steffen interpolation as it's monotonic
|
18
|
+
* http://jrwalsh1.github.io/posts/interpolations/
|
19
|
+
*
|
20
|
+
* @param p0
|
21
|
+
* @param p1
|
22
|
+
* @param p2
|
23
|
+
*/
|
24
|
+
function slope(p0, p1, p2) {
|
25
|
+
const dx = p1[0] - p0[0];
|
26
|
+
const dx1 = p2[0] - p1[0];
|
27
|
+
const dy = p1[1] - p0[1];
|
28
|
+
const dy1 = p2[1] - p1[1];
|
29
|
+
const m = dy / (dx || (dx1 < 0 && 0));
|
30
|
+
const m1 = dy1 / (dx1 || (dx < 0 && 0));
|
31
|
+
const p = (m * dx1 + m1 * dx) / (dx + dx1);
|
32
|
+
return (Math.sign(m) + Math.sign(m1)) * Math.min(Math.abs(m), Math.abs(m1), 0.5 * Math.abs(p)) || 0;
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Calculate slope for just one tangent (single-sided)
|
36
|
+
*
|
37
|
+
* @param p0
|
38
|
+
* @param p1
|
39
|
+
* @param m
|
40
|
+
*/
|
41
|
+
function slopeSingle(p0, p1, m) {
|
42
|
+
const dx = p1[0] - p0[0];
|
43
|
+
const dy = p1[1] - p0[1];
|
44
|
+
return dx ? ((3 * dy) / dx - m) / 2 : m;
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Given two points and their tangent slopes,
|
48
|
+
* calculate the bezier handle coordinates and return draw command.
|
49
|
+
*
|
50
|
+
* Translates Hermite Spline to Beziér curve:
|
51
|
+
* stackoverflow.com/questions/42574940/
|
52
|
+
*
|
53
|
+
* @param p0
|
54
|
+
* @param p1
|
55
|
+
* @param m0
|
56
|
+
* @param m1
|
57
|
+
* @param t
|
58
|
+
*/
|
59
|
+
function bezier(p0, p1, m0, m1, t) {
|
60
|
+
const [x0, y0] = p0;
|
61
|
+
const [x1, y1] = p1;
|
62
|
+
const dx = (x1 - x0) / 3;
|
63
|
+
const h1 = t([x0 + dx, y0 + dx * m0]).join(",");
|
64
|
+
const h2 = t([x1 - dx, y1 - dx * m1]).join(",");
|
65
|
+
const p = t([x1, y1]).join(",");
|
66
|
+
return `C ${h1} ${h2} ${p}`;
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Generate a function which will translate a point
|
70
|
+
* from the data coordinate space to svg viewbox oriented pixels
|
71
|
+
*
|
72
|
+
* @param root0
|
73
|
+
* @param root0.width
|
74
|
+
* @param root0.height
|
75
|
+
* @param root0.min
|
76
|
+
* @param root0.max
|
77
|
+
*/
|
78
|
+
function translate({ width, height, min, max }) {
|
79
|
+
const rangeX = max[0] - min[0];
|
80
|
+
const rangeY = max[1] - min[1];
|
81
|
+
return (point) => {
|
82
|
+
const x = ((point[0] - min[0]) / rangeX) * width;
|
83
|
+
const y = height - (point[1] / rangeY) * height;
|
84
|
+
return [x, y];
|
85
|
+
};
|
86
|
+
}
|
87
|
+
/**
|
88
|
+
* Get the min and max values from the dataset
|
89
|
+
*
|
90
|
+
* @param data
|
91
|
+
*/
|
92
|
+
function range(data) {
|
93
|
+
const [startX, startY] = data[0];
|
94
|
+
const min = [startX, startY];
|
95
|
+
const max = [startX, startY];
|
96
|
+
return data.reduce(({ min, max }, [x, y]) => ({
|
97
|
+
min: [Math.min(min[0], x), Math.min(min[1], y)],
|
98
|
+
max: [Math.max(max[0], x), Math.max(max[1], y)]
|
99
|
+
}), { min, max });
|
100
|
+
}
|
101
|
+
/**
|
102
|
+
* Generate drawing commands for an area graph
|
103
|
+
* returns a string can can be passed directly to a path element's `d` attribute
|
104
|
+
*
|
105
|
+
* @param root0
|
106
|
+
* @param root0.data
|
107
|
+
* @param root0.min
|
108
|
+
* @param root0.max
|
109
|
+
* @param root0.t
|
110
|
+
*/
|
111
|
+
function area({ data, min, max, t }) {
|
112
|
+
if (data.length === 0) {
|
113
|
+
return "";
|
114
|
+
}
|
115
|
+
// important points for beginning and ending the path
|
116
|
+
const [startX, startY] = t(data[0]);
|
117
|
+
const [minX, minY] = t(min);
|
118
|
+
const [maxX] = t(max);
|
119
|
+
// keep track of previous slope/points
|
120
|
+
let m;
|
121
|
+
let p0;
|
122
|
+
let p1;
|
123
|
+
// iterate over data points, calculating command for each
|
124
|
+
const commands = data.reduce((acc, point, i) => {
|
125
|
+
p0 = data[i - 2];
|
126
|
+
p1 = data[i - 1];
|
127
|
+
if (i > 1) {
|
128
|
+
const m1 = slope(p0, p1, point);
|
129
|
+
const m0 = m === undefined ? slopeSingle(p0, p1, m1) : m;
|
130
|
+
const command = bezier(p0, p1, m0, m1, t);
|
131
|
+
m = m1;
|
132
|
+
return `${acc} ${command}`;
|
133
|
+
}
|
134
|
+
return acc;
|
135
|
+
}, `M ${minX},${minY} L ${minX},${startY} L ${startX},${startY}`);
|
136
|
+
// close the path
|
137
|
+
const last = data[data.length - 1];
|
138
|
+
const end = bezier(p1, last, m, slopeSingle(p1, last, m), t);
|
139
|
+
return `${commands} ${end} L ${maxX},${minY} Z`;
|
140
|
+
}
|
141
|
+
|
142
|
+
const graphCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:block;block-size:100%}.svg{fill:currentColor;stroke:transparent;margin:0px;display:block;block-size:100%;inline-size:100%;padding:0px}.svg .graph-path--highlight{fill:var(--calcite-ui-brand);opacity:0.5}";
|
143
|
+
|
144
|
+
const Graph = class {
|
145
|
+
constructor(hostRef) {
|
146
|
+
registerInstance(this, hostRef);
|
147
|
+
//--------------------------------------------------------------------------
|
148
|
+
//
|
149
|
+
// Properties
|
150
|
+
//
|
151
|
+
//--------------------------------------------------------------------------
|
152
|
+
/**
|
153
|
+
* Array of tuples describing a single data point ([x, y])
|
154
|
+
* These data points should be sorted by x-axis value
|
155
|
+
*/
|
156
|
+
this.data = [];
|
157
|
+
//--------------------------------------------------------------------------
|
158
|
+
//
|
159
|
+
// Private State/Props
|
160
|
+
//
|
161
|
+
//--------------------------------------------------------------------------
|
162
|
+
this.graphId = `calcite-graph-${guid()}`;
|
163
|
+
this.resizeObserver = createObserver("resize", () => forceUpdate(this));
|
164
|
+
}
|
165
|
+
//--------------------------------------------------------------------------
|
166
|
+
//
|
167
|
+
// Lifecycle
|
168
|
+
//
|
169
|
+
//--------------------------------------------------------------------------
|
170
|
+
connectedCallback() {
|
171
|
+
var _a;
|
172
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
|
173
|
+
}
|
174
|
+
disconnectedCallback() {
|
175
|
+
var _a;
|
176
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
177
|
+
}
|
178
|
+
render() {
|
179
|
+
const { data, colorStops, el, highlightMax, highlightMin, min, max } = this;
|
180
|
+
const id = this.graphId;
|
181
|
+
const { clientHeight: height, clientWidth: width } = el;
|
182
|
+
// if we have no data, return empty svg
|
183
|
+
if (!data || data.length === 0) {
|
184
|
+
return (h("svg", { class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }));
|
185
|
+
}
|
186
|
+
const { min: rangeMin, max: rangeMax } = range(data);
|
187
|
+
let currentMin = rangeMin;
|
188
|
+
let currentMax = rangeMax;
|
189
|
+
if (min < rangeMin[0] || min > rangeMin[0]) {
|
190
|
+
currentMin = [min, 0];
|
191
|
+
}
|
192
|
+
if (max > rangeMax[0] || max < rangeMax[0]) {
|
193
|
+
currentMax = [max, rangeMax[1]];
|
194
|
+
}
|
195
|
+
const t = translate({ min: currentMin, max: currentMax, width, height });
|
196
|
+
const [hMinX] = t([highlightMin, currentMax[1]]);
|
197
|
+
const [hMaxX] = t([highlightMax, currentMax[1]]);
|
198
|
+
const areaPath = area({ data, min: rangeMin, max: rangeMax, t });
|
199
|
+
const fill = colorStops ? `url(#linear-gradient-${id})` : undefined;
|
200
|
+
return (h("svg", { class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }, colorStops ? (h("defs", null, h("linearGradient", { id: `linear-gradient-${id}`, x1: "0", x2: "1", y1: "0", y2: "0" }, colorStops.map(({ offset, color, opacity }) => (h("stop", { offset: `${offset * 100}%`, "stop-color": color, "stop-opacity": opacity })))))) : null, highlightMin !== undefined ? ([
|
201
|
+
h("mask", { height: "100%", id: `${id}1`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
|
202
|
+
M 0,0
|
203
|
+
L ${hMinX - 1},0
|
204
|
+
L ${hMinX - 1},${height}
|
205
|
+
L 0,${height}
|
206
|
+
Z
|
207
|
+
`, fill: "white" })),
|
208
|
+
h("mask", { height: "100%", id: `${id}2`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
|
209
|
+
M ${hMinX + 1},0
|
210
|
+
L ${hMaxX - 1},0
|
211
|
+
L ${hMaxX - 1},${height}
|
212
|
+
L ${hMinX + 1}, ${height}
|
213
|
+
Z
|
214
|
+
`, fill: "white" })),
|
215
|
+
h("mask", { height: "100%", id: `${id}3`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
|
216
|
+
M ${hMaxX + 1},0
|
217
|
+
L ${width},0
|
218
|
+
L ${width},${height}
|
219
|
+
L ${hMaxX + 1}, ${height}
|
220
|
+
Z
|
221
|
+
`, fill: "white" })),
|
222
|
+
h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}1)` }),
|
223
|
+
h("path", { class: "graph-path--highlight", d: areaPath, fill: fill, mask: `url(#${id}2)` }),
|
224
|
+
h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}3)` })
|
225
|
+
]) : (h("path", { class: "graph-path", d: areaPath, fill: fill }))));
|
226
|
+
}
|
227
|
+
get el() { return getElement(this); }
|
228
|
+
};
|
229
|
+
Graph.style = graphCss;
|
230
|
+
|
231
|
+
export { Graph as calcite_graph };
|