layerchart 0.54.0 → 0.55.0
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/dist/components/Arc.svelte +170 -144
- package/dist/components/Area.svelte +96 -67
- package/dist/components/Area.svelte.d.ts +1 -0
- package/dist/components/Axis.svelte +205 -155
- package/dist/components/Bar.svelte +72 -45
- package/dist/components/Bars.svelte +45 -34
- package/dist/components/Blur.svelte +5 -3
- package/dist/components/Bounds.svelte +37 -21
- package/dist/components/Brush.svelte +269 -112
- package/dist/components/Brush.svelte.d.ts +7 -0
- package/dist/components/Calendar.svelte +51 -38
- package/dist/components/Chart.svelte +295 -74
- package/dist/components/Chart.svelte.d.ts +17 -17
- package/dist/components/ChartClipPath.svelte +8 -5
- package/dist/components/ChartContext.svelte +243 -93
- package/dist/components/ChartContext.svelte.d.ts +15 -23
- package/dist/components/Circle.svelte +25 -16
- package/dist/components/CircleClipPath.svelte +16 -10
- package/dist/components/ClipPath.svelte +11 -7
- package/dist/components/ColorRamp.svelte +12 -10
- package/dist/components/ForceSimulation.svelte +185 -116
- package/dist/components/Frame.svelte +10 -6
- package/dist/components/GeoCircle.svelte +15 -9
- package/dist/components/GeoContext.svelte +109 -62
- package/dist/components/GeoEdgeFade.svelte +20 -14
- package/dist/components/GeoPath.svelte +107 -69
- package/dist/components/GeoPoint.svelte +32 -18
- package/dist/components/GeoSpline.svelte +30 -22
- package/dist/components/GeoTile.svelte +40 -30
- package/dist/components/GeoVisible.svelte +10 -7
- package/dist/components/Graticule.svelte +14 -8
- package/dist/components/Grid.svelte +75 -48
- package/dist/components/Group.svelte +43 -31
- package/dist/components/Highlight.svelte +284 -243
- package/dist/components/HitCanvas.svelte +75 -42
- package/dist/components/Hull.svelte +40 -20
- package/dist/components/Labels.svelte +81 -70
- package/dist/components/Legend.svelte +105 -74
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/Line.svelte +65 -19
- package/dist/components/Line.svelte.d.ts +13 -1
- package/dist/components/LinearGradient.svelte +21 -15
- package/dist/components/Link.svelte +94 -22
- package/dist/components/Link.svelte.d.ts +17 -1
- package/dist/components/Marker.svelte +81 -0
- package/dist/components/Marker.svelte.d.ts +28 -0
- package/dist/components/MonthPath.svelte +23 -16
- package/dist/components/MotionPath.svelte +34 -25
- package/dist/components/Pack.svelte +21 -14
- package/dist/components/Partition.svelte +35 -20
- package/dist/components/Pattern.svelte +8 -6
- package/dist/components/Pie.svelte +76 -57
- package/dist/components/Point.svelte +11 -7
- package/dist/components/Points.svelte +178 -143
- package/dist/components/RadialGradient.svelte +25 -18
- package/dist/components/Rect.svelte +33 -19
- package/dist/components/RectClipPath.svelte +16 -11
- package/dist/components/Rule.svelte +50 -42
- package/dist/components/Sankey.svelte +55 -30
- package/dist/components/Spline.svelte +167 -96
- package/dist/components/Spline.svelte.d.ts +15 -0
- package/dist/components/Text.svelte +137 -104
- package/dist/components/Threshold.svelte +18 -7
- package/dist/components/TileImage.svelte +56 -50
- package/dist/components/TransformContext.svelte +235 -135
- package/dist/components/TransformControls.svelte +57 -29
- package/dist/components/TransformControls.svelte.d.ts +1 -1
- package/dist/components/Tree.svelte +33 -23
- package/dist/components/Treemap.svelte +69 -41
- package/dist/components/Voronoi.svelte +55 -28
- package/dist/components/charts/AreaChart.svelte +138 -87
- package/dist/components/charts/AreaChart.svelte.d.ts +4 -4
- package/dist/components/charts/BarChart.svelte +179 -114
- package/dist/components/charts/BarChart.svelte.d.ts +4 -4
- package/dist/components/charts/LineChart.svelte +97 -53
- package/dist/components/charts/LineChart.svelte.d.ts +4 -4
- package/dist/components/charts/PieChart.svelte +104 -54
- package/dist/components/charts/PieChart.svelte.d.ts +3 -3
- package/dist/components/charts/ScatterChart.svelte +83 -48
- package/dist/components/charts/ScatterChart.svelte.d.ts +4 -4
- package/dist/components/layout/Canvas.svelte +63 -43
- package/dist/components/layout/Html.svelte +28 -18
- package/dist/components/layout/Svg.svelte +47 -32
- package/dist/components/tooltip/Tooltip.svelte +137 -91
- package/dist/components/tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContext.svelte +315 -249
- package/dist/components/tooltip/TooltipHeader.svelte +9 -3
- package/dist/components/tooltip/TooltipItem.svelte +17 -9
- package/dist/components/tooltip/TooltipList.svelte +2 -1
- package/dist/components/tooltip/TooltipSeparator.svelte +3 -2
- package/dist/docs/Blockquote.svelte +4 -3
- package/dist/docs/Code.svelte +15 -8
- package/dist/docs/CurveMenuField.svelte +17 -12
- package/dist/docs/GeoDebug.svelte +13 -9
- package/dist/docs/Header1.svelte +2 -1
- package/dist/docs/Json.svelte +6 -4
- package/dist/docs/Layout.svelte +6 -6
- package/dist/docs/PathDataMenuField.svelte +52 -44
- package/dist/docs/Preview.svelte +39 -33
- package/dist/docs/TilesetField.svelte +80 -62
- package/dist/docs/TransformDebug.svelte +8 -5
- package/dist/docs/ViewSourceButton.svelte +13 -9
- package/dist/stores/motionStore.d.ts +1 -1
- package/dist/utils/scales.d.ts +3 -3
- package/package.json +29 -30
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export let
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
export let
|
|
9
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { format as formatUtil, type FormatType } from '@layerstack/utils';
|
|
3
|
+
import { cls } from '@layerstack/tailwind';
|
|
4
|
+
|
|
5
|
+
export let label: any;
|
|
6
|
+
/** Value to be formatted and displayed. Can also be passed as default slot */
|
|
7
|
+
export let value: any = undefined;
|
|
8
|
+
export let format: FormatType | undefined = undefined;
|
|
9
|
+
export let valueAlign: 'left' | 'right' | 'center' = 'left';
|
|
10
|
+
export let color: string | undefined = undefined;
|
|
11
|
+
|
|
12
|
+
export let classes: {
|
|
13
|
+
root?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
} = {};
|
|
10
18
|
</script>
|
|
11
19
|
|
|
12
20
|
<div class={cls('contents', classes.root, $$props.class)} {...$$restProps}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cls } from '@layerstack/tailwind';
|
|
2
3
|
</script>
|
|
3
4
|
|
|
4
|
-
<div class={cls('rounded bg-surface-content/20 my-1 col-span-full h-px', $$props.class)}
|
|
5
|
+
<div class={cls('rounded bg-surface-content/20 my-1 col-span-full h-px', $$props.class)}></div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { mdiInformation } from '@mdi/js';
|
|
3
|
+
import { Icon } from 'svelte-ux';
|
|
4
|
+
import { cls } from '@layerstack/tailwind';
|
|
4
5
|
</script>
|
|
5
6
|
|
|
6
7
|
<div
|
package/dist/docs/Code.svelte
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import '
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Prism from 'prismjs';
|
|
3
|
+
import 'prism-svelte';
|
|
4
|
+
import { CopyButton } from 'svelte-ux';
|
|
5
|
+
import { cls } from '@layerstack/tailwind';
|
|
6
|
+
|
|
7
|
+
export let source: string | null = null;
|
|
8
|
+
export let language = 'svelte';
|
|
9
|
+
export let highlightedSource = source
|
|
8
10
|
? Prism.highlight(source, Prism.languages[language] ?? Prism.languages.text, language)
|
|
9
11
|
: '';
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
export let classes: {
|
|
14
|
+
root?: string;
|
|
15
|
+
pre?: string;
|
|
16
|
+
code?: string;
|
|
17
|
+
} = {};
|
|
11
18
|
</script>
|
|
12
19
|
|
|
13
20
|
<div class={cls('Code', 'rounded', classes.root, $$props.class)}>
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as d3shapes from 'd3-shape';
|
|
3
|
+
|
|
4
|
+
import { MenuField } from 'svelte-ux';
|
|
5
|
+
import { entries } from '@layerstack/utils';
|
|
6
|
+
|
|
7
|
+
export let value: any | undefined = d3shapes['curveLinear'];
|
|
8
|
+
export let showOpenClosed = false;
|
|
9
|
+
|
|
10
|
+
const options = entries(d3shapes)
|
|
7
11
|
.filter(([key]) => {
|
|
8
|
-
|
|
12
|
+
return (
|
|
13
|
+
key.startsWith('curve') &&
|
|
9
14
|
(showOpenClosed ? true : !key.endsWith('Open') && !key.endsWith('Closed')) &&
|
|
10
15
|
!key.includes('Bundle') // Not compatibile with area
|
|
11
|
-
|
|
12
|
-
})
|
|
16
|
+
);
|
|
17
|
+
})
|
|
13
18
|
.map(([key, value]) => {
|
|
14
|
-
|
|
19
|
+
return {
|
|
15
20
|
label: key.replace('curve', ''),
|
|
16
21
|
value: value,
|
|
17
|
-
|
|
18
|
-
});
|
|
22
|
+
};
|
|
23
|
+
});
|
|
19
24
|
</script>
|
|
20
25
|
|
|
21
26
|
<MenuField label="Curve" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox } from 'svelte-ux';
|
|
3
|
+
import { cls } from '@layerstack/tailwind';
|
|
4
|
+
import { format } from '@layerstack/utils';
|
|
5
|
+
|
|
6
|
+
import { chartContext } from '../components/ChartContext.svelte';
|
|
7
|
+
import { geoContext } from '../components/GeoContext.svelte';
|
|
8
|
+
|
|
9
|
+
const { width, height } = chartContext();
|
|
10
|
+
const geo = geoContext();
|
|
11
|
+
|
|
12
|
+
let showCenter = false;
|
|
9
13
|
</script>
|
|
10
14
|
|
|
11
15
|
<div class={cls('bg-surface-300/50 rounded m-1 backdrop-blur p-2 tabular-nums', $$props.class)}>
|
|
@@ -45,5 +49,5 @@ let showCenter = false;
|
|
|
45
49
|
{#if showCenter}
|
|
46
50
|
<div
|
|
47
51
|
class="absolute w-2 h-2 bg-danger/80 rounded-full z-[1] left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
48
|
-
|
|
52
|
+
></div>
|
|
49
53
|
{/if}
|
package/dist/docs/Header1.svelte
CHANGED
package/dist/docs/Json.svelte
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import JsonTree from 'svelte-json-tree';
|
|
3
|
+
import { cls } from '@layerstack/tailwind';
|
|
4
|
+
|
|
5
|
+
export let value: any;
|
|
6
|
+
export let defaultExpandedPaths = ['$'];
|
|
5
7
|
</script>
|
|
6
8
|
|
|
7
9
|
<div class={cls('overflow-auto px-4 py-2 bg-[#1e1e1e]', $$props.class)}>
|
package/dist/docs/Layout.svelte
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
export { a, blockquote };
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
|
-
<script
|
|
11
|
-
// frontmatter: https://mdsvex.com/docs#frontmatter-1
|
|
12
|
-
// export let name = undefined;
|
|
13
|
-
// export let sourceUrl = undefined;
|
|
14
|
-
// export let docUrl = undefined;
|
|
15
|
-
// export let description = undefined;
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
// frontmatter: https://mdsvex.com/docs#frontmatter-1
|
|
12
|
+
// export let name = undefined;
|
|
13
|
+
// export let sourceUrl = undefined;
|
|
14
|
+
// export let docUrl = undefined;
|
|
15
|
+
// export let description = undefined;
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
18
|
<slot />
|
|
@@ -1,66 +1,74 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import * as easings from 'svelte/easing';
|
|
4
|
+
|
|
5
|
+
import { MenuField } from 'svelte-ux';
|
|
6
|
+
|
|
7
|
+
export let value: any | undefined = undefined;
|
|
8
|
+
|
|
9
|
+
// TODO: Allow updating externally without loosing selection
|
|
10
|
+
export let amplitude = 1;
|
|
11
|
+
export let frequency = 10;
|
|
12
|
+
export let phase = 0;
|
|
13
|
+
|
|
14
|
+
$: mathOptions = [
|
|
10
15
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
label: 'sin',
|
|
17
|
+
group: 'math',
|
|
18
|
+
value: (x: number) => amplitude * Math.sin(x * frequency) + phase,
|
|
14
19
|
},
|
|
15
20
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
label: 'cos',
|
|
22
|
+
group: 'math',
|
|
23
|
+
value: (x: number) => amplitude * Math.cos(x * frequency) + phase,
|
|
19
24
|
},
|
|
20
25
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
label: 'tan',
|
|
27
|
+
group: 'math',
|
|
28
|
+
value: (x: number) => amplitude * Math.tan(x * frequency) + phase,
|
|
24
29
|
},
|
|
25
30
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
label: 'sqrt',
|
|
32
|
+
group: 'math',
|
|
33
|
+
value: (x: number) => amplitude * Math.sqrt(x * frequency) + phase,
|
|
29
34
|
},
|
|
30
35
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
label: 'ceil',
|
|
37
|
+
group: 'math',
|
|
38
|
+
value: (x: number) => amplitude * Math.ceil(x * frequency) + phase,
|
|
34
39
|
},
|
|
35
40
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
label: 'floor',
|
|
42
|
+
group: 'math',
|
|
43
|
+
value: (x: number) => amplitude * Math.floor(x * frequency) + phase,
|
|
39
44
|
},
|
|
40
45
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
label: 'round',
|
|
47
|
+
group: 'math',
|
|
48
|
+
value: (x: number) => amplitude * Math.round(x * frequency) + phase,
|
|
44
49
|
},
|
|
45
|
-
{ label: 'random', group: 'math', value: (x) => amplitude * Math.random() + phase },
|
|
50
|
+
{ label: 'random', group: 'math', value: (x: number) => amplitude * Math.random() + phase },
|
|
46
51
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
label: 'pow',
|
|
53
|
+
group: 'math',
|
|
54
|
+
value: (x: number) => amplitude * Math.pow(x, frequency) + phase,
|
|
50
55
|
},
|
|
51
|
-
];
|
|
52
|
-
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const easingOptions = Object.entries(easings).map(([key, value]) => {
|
|
53
59
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
label: key,
|
|
61
|
+
value,
|
|
62
|
+
group: 'easing',
|
|
57
63
|
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
$: options = [...mathOptions, ...easingOptions];
|
|
67
|
+
|
|
68
|
+
// Select initial option
|
|
69
|
+
onMount(() => {
|
|
62
70
|
value = options[0].value;
|
|
63
|
-
});
|
|
71
|
+
});
|
|
64
72
|
</script>
|
|
65
73
|
|
|
66
74
|
<MenuField label="Path data" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
|
package/dist/docs/Preview.svelte
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { slide } from 'svelte/transition';
|
|
3
|
+
// TODO: No longer copy from svelte-ux after prismjs is migrated to ESM (commonjs causes issue with Vite from another library)
|
|
4
|
+
import Prism from 'prismjs';
|
|
5
|
+
import 'prism-svelte';
|
|
6
|
+
import { mdiCodeTags, mdiTable } from '@mdi/js';
|
|
7
|
+
|
|
8
|
+
import { Button, CopyButton, Dialog, Toggle, Tooltip } from 'svelte-ux';
|
|
9
|
+
import { cls } from '@layerstack/tailwind';
|
|
10
|
+
import { entries, fromEntries } from '@layerstack/utils';
|
|
11
|
+
import { isLiteralObject } from '@layerstack/utils/object';
|
|
12
|
+
|
|
13
|
+
import Code from './Code.svelte';
|
|
14
|
+
import Json from './Json.svelte';
|
|
15
|
+
|
|
16
|
+
export let code: string | undefined = undefined;
|
|
17
|
+
export let data: any | undefined = undefined;
|
|
18
|
+
export let language = 'svelte';
|
|
19
|
+
export let highlightedCode = code ? Prism.highlight(code, Prism.languages.svelte, language) : '';
|
|
20
|
+
export let showCode = false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Custom JSON replacer (to use with JSON.stringify()) to convert `Date` instances to `new Date()`
|
|
24
|
+
*/
|
|
25
|
+
function replacer(this: any, key: string, value: any): any {
|
|
21
26
|
// TODO: Improve handling of circular structures and handle other data types (Map, Set, etc)
|
|
22
27
|
if (this[key] instanceof Date) {
|
|
23
|
-
|
|
28
|
+
return `new Date('${this[key].toISOString()}')`;
|
|
24
29
|
}
|
|
30
|
+
|
|
25
31
|
return value;
|
|
26
|
-
}
|
|
27
|
-
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getDataAsString(_data: typeof data) {
|
|
28
35
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return '';
|
|
36
|
+
// Regular expression to match quoted instantiation (ex. `"new Date(...)"`) and stripe the quotes (`new Date(...)`)
|
|
37
|
+
const datePattern = /"(new \w+\([^)]*\))"/g;
|
|
38
|
+
return JSON.stringify(_data, replacer, 2).replace(datePattern, '$1');
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error('Error capturing value to copy', e);
|
|
41
|
+
return '';
|
|
36
42
|
}
|
|
37
|
-
}
|
|
43
|
+
}
|
|
38
44
|
</script>
|
|
39
45
|
|
|
40
46
|
<div class={cls('Preview border rounded bg-surface-100', $$props.class)}>
|
|
@@ -60,12 +66,12 @@ function getDataAsString(_data) {
|
|
|
60
66
|
{/if}
|
|
61
67
|
|
|
62
68
|
{#if data}
|
|
63
|
-
<Toggle let:on={open} let:toggle>
|
|
69
|
+
<Toggle let:on={open} let:toggle let:toggleOff>
|
|
64
70
|
<Button icon={mdiTable} class="text-surface-content/70 py-1" on:click={toggle}>View data</Button
|
|
65
71
|
>
|
|
66
72
|
<Dialog
|
|
67
73
|
{open}
|
|
68
|
-
on:close={
|
|
74
|
+
on:close={toggleOff}
|
|
69
75
|
class="max-h-[98dvh] md:max-h-[90dvh] max-w-[98vw] md:max-w-[90vw] grid grid-rows-[auto,1fr,auto]"
|
|
70
76
|
>
|
|
71
77
|
<div class="grid grid-cols-[1fr,auto] gap-3 items-center p-4">
|
|
@@ -1,84 +1,102 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// https://docs.mapbox.com/
|
|
11
|
-
$:
|
|
12
|
-
return `https
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SelectField, Switch } from 'svelte-ux';
|
|
3
|
+
|
|
4
|
+
export let doubleScale = devicePixelRatio > 1;
|
|
5
|
+
|
|
6
|
+
// TODO: Access via context, or possibly global state
|
|
7
|
+
const ACCESS_TOKEN =
|
|
8
|
+
'pk.eyJ1IjoidGVjaG5pcTM1IiwiYSI6ImNsZTR5cDd0ZjAyNm8zdnFvczhzdnFpcXkifQ.-LAr8sl5BZ3y-H0pDyD1qA';
|
|
9
|
+
|
|
10
|
+
// https://docs.mapbox.com/api/maps/styles/
|
|
11
|
+
$: mapboxv1 = (style: string) => (x: number, y: number, z: number) => {
|
|
12
|
+
return `https://api.mapbox.com/styles/v1/mapbox/${style}/tiles/${z}/${x}/${y}${
|
|
13
|
+
doubleScale ? '@2x' : ''
|
|
14
|
+
}?access_token=${ACCESS_TOKEN}`;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// https://docs.mapbox.com/api/maps/raster-tiles/
|
|
18
|
+
// https://docs.mapbox.com/data/tilesets/reference/mapbox-streets-v8/
|
|
19
|
+
$: mapboxv4 = (tileset: string) => (x: number, y: number, z: number) => {
|
|
20
|
+
return `https://${'abc'[Math.abs(x + y) % 3]}.tiles.mapbox.com/v4/${tileset}/${z}/${x}/${y}${
|
|
21
|
+
doubleScale ? '@2x' : ''
|
|
22
|
+
}.png?access_token=${ACCESS_TOKEN}`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// https://apps.nationalmap.gov/services/
|
|
26
|
+
const nationalmap = (tileset: string) => (x: number, y: number, z: number) => {
|
|
16
27
|
return `https://basemap.nationalmap.gov/arcgis/rest/services/${tileset}/MapServer/tile/${z}/${y}/${x}`;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// https://
|
|
20
|
-
// https://www.arcgis.com/
|
|
21
|
-
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// https://services.arcgisonline.com/arcgis/rest/services
|
|
31
|
+
// https://www.arcgis.com/home/webmap/viewer.html?useExisting=1
|
|
32
|
+
// https://www.arcgis.com/apps/mapviewer/index.html
|
|
33
|
+
const arcgis = (tileset: string) => (x: number, y: number, z: number) => {
|
|
22
34
|
return `https://services.arcgisonline.com/ArcGIS/rest/services/${tileset}/MapServer/tile/${z}/${y}/${x}`;
|
|
23
|
-
};
|
|
24
|
-
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const arcgisVector = (tileset: string) => (x: number, y: number, z: number) => {
|
|
25
38
|
return `https://basemaps.arcgis.com/arcgis/rest/services/${tileset}/VectorTileServer/tile/${z}/${y}/${x}.pbf`;
|
|
26
39
|
// https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/12/1572/1108.pbf
|
|
27
|
-
};
|
|
28
|
-
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
$: services = {
|
|
29
43
|
'mapbox v1': {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
'streets-v11': mapboxv1('streets-v11'),
|
|
45
|
+
'light-v10': mapboxv1('light-v10'),
|
|
46
|
+
'dark-v10': mapboxv1('dark-v10'),
|
|
47
|
+
'outdoors-v12': mapboxv1('outdoors-v12'),
|
|
48
|
+
'satelllite-v9': mapboxv1('satellite-v9'),
|
|
49
|
+
'satelllite-streets-v12': mapboxv1('satellite-streets-v12'),
|
|
50
|
+
'navigation-day-v1': mapboxv1('navigation-day-v1'),
|
|
51
|
+
'navigation-night-v1': mapboxv1('navigation-night-v1'),
|
|
38
52
|
},
|
|
39
53
|
'mapbox v4': {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
'natural-earth-2': mapboxv4('mapbox.natural-earth-2'),
|
|
55
|
+
satellite: mapboxv4('mapbox.satellite'),
|
|
56
|
+
streets: mapboxv4('mapbox.mapbox-streets-v8'),
|
|
57
|
+
terrain: mapboxv4('mapbox.mapbox-terrain-v2'),
|
|
58
|
+
'terrain-dem': mapboxv4('mapbox.mapbox-terrain-dem-v1'),
|
|
59
|
+
traffic: mapboxv4('mapbox.mapbox-traffic-v1'),
|
|
60
|
+
// 'transit (mapbox v4)': mapboxv4('mapbox.transit-v2'),
|
|
47
61
|
},
|
|
48
62
|
'National Map Services': {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
Hydrography: nationalmap('USGSHydroCached'),
|
|
64
|
+
'USGS Imagery Topo Base Map': nationalmap('USGSImageryTopo'),
|
|
65
|
+
'USGS Imagery Only Base Map': nationalmap('USGSImageryOnly'),
|
|
66
|
+
'USGS Shaded Relief': nationalmap('USGSShadedReliefOnly'),
|
|
67
|
+
'USGS Topo Base Map': nationalmap('USGSTopo'),
|
|
54
68
|
},
|
|
55
69
|
ArcGIS: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
'USA Topo Map': arcgis('USA_Topo_Maps'),
|
|
71
|
+
'National Geographic World Map': arcgis('NatGeo_World_Map'),
|
|
72
|
+
'World Imagery': arcgis('World_Imagery'),
|
|
73
|
+
'World Physicial Map': arcgis('World_Physical_Map'),
|
|
74
|
+
'World Shaded Relief': arcgis('World_Shaded_Relief'),
|
|
75
|
+
'World Street Map': arcgis('World_Street_Map'),
|
|
76
|
+
'World Terrain Base': arcgis('World_Terrain_Base'),
|
|
77
|
+
'World Topo Map': arcgis('World_Topo_Map'),
|
|
64
78
|
},
|
|
65
79
|
// 'ArcGIS Vector': {
|
|
66
80
|
// 'Community Map', url: arcgisVector('World_Basemap_v2'),
|
|
67
81
|
// }
|
|
68
|
-
}
|
|
69
|
-
|
|
82
|
+
} as Record<string, Record<string, Function>>;
|
|
83
|
+
|
|
84
|
+
$: serviceOptions = Object.entries(services).flatMap(([group, service]) => {
|
|
70
85
|
return Object.entries(service).map(([label, value]) => {
|
|
71
|
-
|
|
86
|
+
return { label, value: `${group}:${label}`, group, serviceUrl: value };
|
|
72
87
|
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
$: defaultServiceUrl = services['mapbox v1']['streets-v11'];
|
|
91
|
+
export let serviceUrl = defaultServiceUrl;
|
|
92
|
+
|
|
93
|
+
$: getServiceUrl = (option: string) => {
|
|
77
94
|
const [selectedService, selectedTileset] = selected.split(':');
|
|
78
95
|
return services[selectedService][selectedTileset];
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
let selected = 'mapbox v1:streets-v11';
|
|
99
|
+
$: serviceUrl = getServiceUrl(selected);
|
|
82
100
|
</script>
|
|
83
101
|
|
|
84
102
|
<SelectField
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cls } from '@layerstack/tailwind';
|
|
3
|
+
import { format } from '@layerstack/utils';
|
|
4
|
+
|
|
5
|
+
import { transformContext } from '../components/TransformContext.svelte';
|
|
6
|
+
|
|
7
|
+
const transform = transformContext();
|
|
8
|
+
const { translate, scale } = transform;
|
|
6
9
|
</script>
|
|
7
10
|
|
|
8
11
|
<div class={cls('bg-surface-300/50 rounded m-1 backdrop-blur p-2 tabular-nums', $$props.class)}>
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
import { Button, Dialog, Toggle, Tooltip } from 'svelte-ux';
|
|
4
|
+
import { mdiGithub } from '@mdi/js';
|
|
5
|
+
|
|
6
|
+
import Code from './Code.svelte';
|
|
7
|
+
|
|
8
|
+
export let label: string;
|
|
9
|
+
export let source: string | undefined = undefined;
|
|
10
|
+
export let href: string | undefined = undefined;
|
|
11
|
+
export let icon: ComponentProps<Button>['icon'];
|
|
8
12
|
</script>
|
|
9
13
|
|
|
10
14
|
{#if source}
|
|
11
|
-
<Toggle let:on={open} let:toggle>
|
|
15
|
+
<Toggle let:on={open} let:toggle let:toggleOff>
|
|
12
16
|
<Button {icon} on:click={toggle} variant="fill-light" color="primary" size="sm">{label}</Button>
|
|
13
17
|
<Dialog
|
|
14
18
|
{open}
|
|
15
|
-
on:close={
|
|
19
|
+
on:close={toggleOff}
|
|
16
20
|
class="max-h-[98dvh] md:max-h-[90dvh] max-w-[98vw] md:max-w-[90vw] grid grid-rows-[auto,1fr,auto]"
|
|
17
21
|
>
|
|
18
22
|
<div class="grid grid-cols-[1fr,auto] gap-3 items-center p-4">
|