layerchart 0.18.2 → 0.20.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/README.md +9 -1
- package/dist/components/Area.svelte +15 -12
- package/dist/components/AreaStack.svelte +4 -4
- package/dist/components/AreaStack.svelte.d.ts +4 -1
- package/dist/components/Chart.svelte +2 -2
- package/dist/components/ChartClipPath.svelte.d.ts +1 -1
- package/dist/components/CircleClipPath.svelte +2 -7
- package/dist/components/CircleClipPath.svelte.d.ts +0 -4
- package/dist/components/ClipPath.svelte +13 -1
- package/dist/components/ClipPath.svelte.d.ts +10 -0
- package/dist/components/HighlightLine.svelte +2 -6
- package/dist/components/Legend.svelte.d.ts +1 -1
- package/dist/components/MotionPath.svelte +44 -0
- package/dist/components/MotionPath.svelte.d.ts +28 -0
- package/dist/components/Point.svelte +10 -0
- package/dist/components/Point.svelte.d.ts +21 -0
- package/dist/components/RectClipPath.svelte +2 -8
- package/dist/components/RectClipPath.svelte.d.ts +0 -4
- package/dist/components/Sankey.svelte.d.ts +1 -1
- package/dist/components/Spline.svelte +103 -0
- package/dist/components/Spline.svelte.d.ts +38 -0
- package/dist/components/Text.svelte +1 -1
- package/dist/components/Text.svelte.d.ts +2 -2
- package/dist/components/TooltipItem.svelte +2 -1
- package/dist/components/TooltipItem.svelte.d.ts +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +3 -2
- package/dist/docs/Code.svelte +2 -2
- package/dist/docs/CurveMenuField.svelte +19 -0
- package/dist/docs/CurveMenuField.svelte.d.ts +16 -0
- package/dist/docs/PathDataMenuField.svelte +66 -0
- package/dist/docs/PathDataMenuField.svelte.d.ts +19 -0
- package/dist/docs/RangeField.svelte +19 -13
- package/dist/docs/ViewSourceButton.svelte +6 -2
- package/dist/docs/ZoomControls.svelte.d.ts +1 -1
- package/dist/stores/motionStore.d.ts +1 -1
- package/package.json +12 -8
- package/dist/components/Area.svelte.d.ts +0 -34
- package/dist/components/ClipPathUse.svelte +0 -17
- package/dist/components/ClipPathUse.svelte.d.ts +0 -27
- package/dist/components/Path.svelte +0 -53
- package/dist/components/Path.svelte.d.ts +0 -31
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Interactions
|
|
|
14
14
|
|
|
15
15
|
SVG
|
|
16
16
|
|
|
17
|
-
- Basic (Arc, Circle, Group, Line,
|
|
17
|
+
- Basic (Arc, Circle, Group, Line, Spline, Text)
|
|
18
18
|
- Gradients and Patterns
|
|
19
19
|
- ClipPath
|
|
20
20
|
- Multi-line text
|
|
@@ -22,3 +22,11 @@ SVG
|
|
|
22
22
|
Others
|
|
23
23
|
|
|
24
24
|
- Legends including ColorRamps
|
|
25
|
+
|
|
26
|
+
## Publishing
|
|
27
|
+
|
|
28
|
+
- `npm run changeset` for each changelog worthy change
|
|
29
|
+
- `npm run version` to bump `package.json` version based on changesets, materialize changesets into CHANGELOG.md
|
|
30
|
+
- Commit as `Version bump to x.y.z` (TODO: automate)
|
|
31
|
+
- `npm run publish` to publish version to npm
|
|
32
|
+
- `git push --tags` to publish tags to Github
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import { area as d3Area } from 'd3-shape';
|
|
3
|
-
import {
|
|
3
|
+
import { max } from 'd3-array';
|
|
4
4
|
import { interpolatePath } from 'd3-interpolate-path';
|
|
5
|
+
import { cls } from 'svelte-ux';
|
|
5
6
|
import { motionStore } from '../stores/motionStore';
|
|
6
|
-
import
|
|
7
|
+
import Spline from './Spline.svelte';
|
|
7
8
|
const { data: contextData, xGet, yGet, yRange } = getContext('LayerCake');
|
|
8
|
-
|
|
9
|
-
export let data = undefined;
|
|
9
|
+
/** Override data instead of using context */
|
|
10
|
+
export let data = undefined;
|
|
11
|
+
/** Pass `<path d={...} />` explicitly instead of calculating from data / context */
|
|
12
|
+
export let pathData = undefined;
|
|
13
|
+
/** Override x accessor */
|
|
10
14
|
export let x = undefined; // TODO: Update Type
|
|
15
|
+
/** Override y0 accessor. Defaults to max($yRange) */
|
|
11
16
|
export let y0 = undefined; // TODO: Update Type
|
|
17
|
+
/** Override y1 accessor. Defaults to y accessor */
|
|
12
18
|
export let y1 = undefined; // TODO: Update Type
|
|
13
|
-
|
|
14
|
-
export let clipPath = undefined;
|
|
19
|
+
/** Interpolate path data using d3-interpolate-path */
|
|
15
20
|
export let tweened = undefined;
|
|
21
|
+
export let clipPath = undefined;
|
|
16
22
|
export let curve = undefined;
|
|
17
23
|
export let defined = undefined;
|
|
18
|
-
|
|
19
|
-
export let opacity = 0.3;
|
|
24
|
+
/** Enable showing line */
|
|
20
25
|
export let line = false;
|
|
21
26
|
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
22
27
|
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
@@ -35,16 +40,14 @@ $: {
|
|
|
35
40
|
</script>
|
|
36
41
|
|
|
37
42
|
{#if line}
|
|
38
|
-
<
|
|
43
|
+
<Spline {data} {curve} {defined} {tweened} {...typeof line === 'object' ? line : null} />
|
|
39
44
|
{/if}
|
|
40
45
|
|
|
41
46
|
<path
|
|
42
|
-
class="path-area"
|
|
43
47
|
d={$tweened_d}
|
|
44
48
|
clip-path={clipPath}
|
|
45
|
-
fill={color}
|
|
46
|
-
fill-opacity={opacity}
|
|
47
49
|
{...$$restProps}
|
|
50
|
+
class={cls('path-area', $$props.class)}
|
|
48
51
|
on:click
|
|
49
52
|
on:mousemove
|
|
50
53
|
on:mouseleave
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>import { getContext } from 'svelte';
|
|
2
2
|
import Area from './Area.svelte';
|
|
3
|
-
import
|
|
3
|
+
import Spline from './Spline.svelte';
|
|
4
4
|
const { data, yScale, rGet } = getContext('LayerCake');
|
|
5
5
|
export let curve = undefined;
|
|
6
6
|
export let defined = undefined;
|
|
@@ -14,10 +14,10 @@ $: lineData = [...$data].reverse();
|
|
|
14
14
|
{#if line}
|
|
15
15
|
<g class="line-group">
|
|
16
16
|
{#each lineData as seriesData}
|
|
17
|
-
<
|
|
17
|
+
<Spline
|
|
18
18
|
data={seriesData}
|
|
19
19
|
y={(d) => $yScale(d[1])}
|
|
20
|
-
|
|
20
|
+
stroke={$rGet(seriesData)}
|
|
21
21
|
{curve}
|
|
22
22
|
{defined}
|
|
23
23
|
{tweened}
|
|
@@ -33,7 +33,7 @@ $: lineData = [...$data].reverse();
|
|
|
33
33
|
data={seriesData}
|
|
34
34
|
y0={(d) => $yScale(d[0])}
|
|
35
35
|
y1={(d) => $yScale(d[1])}
|
|
36
|
-
|
|
36
|
+
fill={$rGet(seriesData)}
|
|
37
37
|
{curve}
|
|
38
38
|
{defined}
|
|
39
39
|
{opacity}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { type ComponentProps } from 'svelte';
|
|
3
|
+
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
2
4
|
import type { CurveFactory } from 'd3-shape';
|
|
5
|
+
import Spline from './Spline.svelte';
|
|
3
6
|
declare const __propDef: {
|
|
4
7
|
props: {
|
|
5
8
|
curve?: CurveFactory | undefined;
|
|
6
|
-
defined?:
|
|
9
|
+
defined?: ComponentProps<Spline>['defined'] | undefined;
|
|
7
10
|
opacity?: number | undefined;
|
|
8
11
|
line?: boolean | any;
|
|
9
12
|
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
@@ -36,7 +36,7 @@ export let x = undefined;
|
|
|
36
36
|
export let y = undefined;
|
|
37
37
|
export let yScale = undefined;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* x value guaranteed to be visible in xDomain. Useful with optional negative values since `xDomain={[0, null]}` would ignore negative values
|
|
40
40
|
*/
|
|
41
41
|
export let xBaseline = null;
|
|
42
42
|
let xDomain = undefined;
|
|
@@ -45,7 +45,7 @@ $: if (xBaseline != null) {
|
|
|
45
45
|
xDomain = [min([xBaseline, ...xValues]), max([xBaseline, ...xValues])];
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* y value guaranteed to be visible in yDomain. Useful with optional negative values since `yDomain={[0, null]}` would ignore negative values
|
|
49
49
|
*/
|
|
50
50
|
export let yBaseline = null;
|
|
51
51
|
let yDomain = undefined;
|
|
@@ -11,11 +11,6 @@ export let tweened = undefined;
|
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<ClipPath {id}>
|
|
14
|
-
<Circle {cx} {cy} {r} {spring} {tweened} />
|
|
14
|
+
<Circle slot="clip" {cx} {cy} {r} {spring} {tweened} />
|
|
15
|
+
<slot {id} />
|
|
15
16
|
</ClipPath>
|
|
16
|
-
|
|
17
|
-
{#if $$slots.default}
|
|
18
|
-
<g style="clip-path: url(#{id})" on:click on:mousemove on:mouseleave>
|
|
19
|
-
<slot {id} />
|
|
20
|
-
</g>
|
|
21
|
-
{/if}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
<script>import { uniqueId } from 'svelte-ux';
|
|
2
2
|
/** Unique id for clipPath */
|
|
3
3
|
export let id = uniqueId('clipPath-');
|
|
4
|
+
/** Use existing path or shape (by id) for clipPath */
|
|
5
|
+
export let useId = undefined;
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
8
|
<defs>
|
|
7
9
|
<clipPath {id} {...$$restProps}>
|
|
8
|
-
<slot {id} />
|
|
10
|
+
<slot name="clip" {id} />
|
|
11
|
+
|
|
12
|
+
{#if useId}
|
|
13
|
+
<use href="#{useId}" />
|
|
14
|
+
{/if}
|
|
9
15
|
</clipPath>
|
|
10
16
|
</defs>
|
|
17
|
+
|
|
18
|
+
{#if $$slots.default}
|
|
19
|
+
<g style:clip-path="url(#{id})" on:click on:mousemove on:mouseleave on:keydown>
|
|
20
|
+
<slot {id} {useId} />
|
|
21
|
+
</g>
|
|
22
|
+
{/if}
|
|
@@ -3,13 +3,23 @@ declare const __propDef: {
|
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
id?: string | undefined;
|
|
6
|
+
useId?: string | undefined;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
9
|
+
click: MouseEvent;
|
|
10
|
+
mousemove: MouseEvent;
|
|
11
|
+
mouseleave: MouseEvent;
|
|
12
|
+
keydown: KeyboardEvent;
|
|
13
|
+
} & {
|
|
8
14
|
[evt: string]: CustomEvent<any>;
|
|
9
15
|
};
|
|
10
16
|
slots: {
|
|
17
|
+
clip: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
11
20
|
default: {
|
|
12
21
|
id: string;
|
|
22
|
+
useId: string | undefined;
|
|
13
23
|
};
|
|
14
24
|
};
|
|
15
25
|
};
|
|
@@ -122,10 +122,7 @@ $: if ($tooltip.data) {
|
|
|
122
122
|
y1={line.y1}
|
|
123
123
|
x2={line.x2}
|
|
124
124
|
y2={line.y2}
|
|
125
|
-
|
|
126
|
-
stroke-width={2}
|
|
127
|
-
style="pointerEvents: none"
|
|
128
|
-
stroke-dasharray="2,2"
|
|
125
|
+
class="stroke-black/50 stroke-2 [stroke-dasharray:2,2] pointer-events-none"
|
|
129
126
|
/>
|
|
130
127
|
{/each}
|
|
131
128
|
|
|
@@ -135,9 +132,8 @@ $: if ($tooltip.data) {
|
|
|
135
132
|
cx={point.x}
|
|
136
133
|
cy={point.y}
|
|
137
134
|
r={7}
|
|
138
|
-
|
|
135
|
+
class="fill-white/90 stroke-2"
|
|
139
136
|
stroke={point.color}
|
|
140
|
-
stroke-width={2}
|
|
141
137
|
/>
|
|
142
138
|
<Circle spring cx={point.x} cy={point.y} r={3} fill={point.color} />
|
|
143
139
|
{/each}
|
|
@@ -12,7 +12,7 @@ declare const __propDef: {
|
|
|
12
12
|
tickValues?: any[] | undefined;
|
|
13
13
|
tickFontSize?: number | undefined;
|
|
14
14
|
tickSize?: number | undefined;
|
|
15
|
-
placement?: ("
|
|
15
|
+
placement?: ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
16
16
|
classes?: {
|
|
17
17
|
root?: string | undefined;
|
|
18
18
|
title?: string | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
import { uniqueId } from 'svelte-ux';
|
|
3
|
+
/** Id of path to move object along */
|
|
4
|
+
export let pathId = uniqueId('motionPathId-');
|
|
5
|
+
/** Id of object to move along path */
|
|
6
|
+
export let objectId = uniqueId('motionObjectId-');
|
|
7
|
+
/** Duration of the animation */
|
|
8
|
+
export let duration;
|
|
9
|
+
/** Number of times the animation will occur */
|
|
10
|
+
export let repeatCount = undefined;
|
|
11
|
+
/** Final state of the animation. Freeze (last frame) or remove (first frame)
|
|
12
|
+
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
|
|
13
|
+
* */
|
|
14
|
+
export let fill = 'freeze';
|
|
15
|
+
/** Rotation applied to the element animated along a path, usually to make it pointing in the direction of the animation */
|
|
16
|
+
export let rotate = undefined;
|
|
17
|
+
// TODO: Investigate `calcMode:spline`, `keyTimes`, and `keySplines` to work with `svelte/easing`
|
|
18
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/calcMode
|
|
19
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/keyTimes
|
|
20
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/keySplines
|
|
21
|
+
// https://medium.com/javarevisited/animate-your-scalable-vector-graphics-svg-56f5800cd34b
|
|
22
|
+
// Restart animation anytime the component is remounted (otherwise it only ever plays once)
|
|
23
|
+
let animateEl;
|
|
24
|
+
onMount(() => {
|
|
25
|
+
animateEl.beginElement();
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<defs>
|
|
30
|
+
<animateMotion
|
|
31
|
+
href="#{objectId}"
|
|
32
|
+
dur={duration}
|
|
33
|
+
{repeatCount}
|
|
34
|
+
{fill}
|
|
35
|
+
{rotate}
|
|
36
|
+
bind:this={animateEl}
|
|
37
|
+
>
|
|
38
|
+
<mpath href="#{pathId}" />
|
|
39
|
+
</animateMotion>
|
|
40
|
+
</defs>
|
|
41
|
+
|
|
42
|
+
{#if $$slots.default}
|
|
43
|
+
<slot {pathId} {objectId} />
|
|
44
|
+
{/if}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** Id of path to move object along */ pathId?: string | undefined;
|
|
5
|
+
/** Id of object to move along path */ objectId?: string | undefined;
|
|
6
|
+
/** Duration of the animation */ duration: string;
|
|
7
|
+
/** Number of times the animation will occur */ repeatCount?: number | 'indefinite' | undefined;
|
|
8
|
+
/** Final state of the animation. Freeze (last frame) or remove (first frame)
|
|
9
|
+
* https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill#animate
|
|
10
|
+
* */ fill?: "remove" | "freeze" | undefined;
|
|
11
|
+
/** Rotation applied to the element animated along a path, usually to make it pointing in the direction of the animation */ rotate?: number | 'auto' | 'auto-reverse' | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
default: {
|
|
18
|
+
pathId: string;
|
|
19
|
+
objectId: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type MotionPathProps = typeof __propDef.props;
|
|
24
|
+
export type MotionPathEvents = typeof __propDef.events;
|
|
25
|
+
export type MotionPathSlots = typeof __propDef.slots;
|
|
26
|
+
export default class MotionPath extends SvelteComponentTyped<MotionPathProps, MotionPathEvents, MotionPathSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** Single data point to translate to x/y */ d: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {
|
|
11
|
+
x: any;
|
|
12
|
+
y: any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type PointProps = typeof __propDef.props;
|
|
17
|
+
export type PointEvents = typeof __propDef.events;
|
|
18
|
+
export type PointSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Point extends SvelteComponentTyped<PointProps, PointEvents, PointSlots> {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -12,12 +12,6 @@ export let tweened = undefined;
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<ClipPath {id}>
|
|
15
|
-
<Rect {x} {y} {width} {height} {spring} {tweened} />
|
|
15
|
+
<Rect slot="clip" {x} {y} {width} {height} {spring} {tweened} />
|
|
16
|
+
<slot {id} />
|
|
16
17
|
</ClipPath>
|
|
17
|
-
|
|
18
|
-
{#if $$slots.default}
|
|
19
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
20
|
-
<g style="clip-path: url(#{id})" on:click on:mousemove on:mouseleave>
|
|
21
|
-
<slot {id} />
|
|
22
|
-
</g>
|
|
23
|
-
{/if}
|
|
@@ -6,7 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
nodeId?: ((d: any) => any) | undefined;
|
|
7
7
|
/**
|
|
8
8
|
* see: https://github.com/d3/d3-sankey#alignments
|
|
9
|
-
*/ nodeAlign?: "
|
|
9
|
+
*/ nodeAlign?: "center" | "left" | "right" | "justify" | ((node: SankeyNode<any, any>, n: number) => number) | undefined;
|
|
10
10
|
nodeWidth?: number | undefined;
|
|
11
11
|
nodePadding?: number | undefined;
|
|
12
12
|
nodeSort?: undefined;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script>import { getContext, tick } from 'svelte';
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
import { tweened as tweenedStore } from 'svelte/motion';
|
|
4
|
+
import { draw as _drawTransition } from 'svelte/transition';
|
|
5
|
+
import { cubicInOut } from 'svelte/easing';
|
|
6
|
+
import { line as d3Line } from 'd3-shape';
|
|
7
|
+
// import { interpolateString } from 'd3-interpolate';
|
|
8
|
+
import { interpolatePath } from 'd3-interpolate-path';
|
|
9
|
+
import { cls } from 'svelte-ux';
|
|
10
|
+
import { motionStore } from '../stores/motionStore';
|
|
11
|
+
import Group from './Group.svelte';
|
|
12
|
+
const { data: contextData, xGet, yGet } = getContext('LayerCake');
|
|
13
|
+
/** Override data instead of using context */
|
|
14
|
+
export let data = undefined;
|
|
15
|
+
/** Pass `<path d={...} />` explicitly instead of calculating from data / context */
|
|
16
|
+
export let pathData = undefined;
|
|
17
|
+
/** Override x accessor */
|
|
18
|
+
export let x = undefined; // TODO: Update Type
|
|
19
|
+
/** Override y accessor */
|
|
20
|
+
export let y = undefined; // TODO: Update Type
|
|
21
|
+
/** Interpolate path data using d3-interpolate-path. Works best without `draw` enabled */
|
|
22
|
+
export let tweened = undefined;
|
|
23
|
+
/** Draw path over time. Works best without `tweened` enabled */
|
|
24
|
+
export let draw = undefined;
|
|
25
|
+
export let curve = undefined;
|
|
26
|
+
export let defined = undefined;
|
|
27
|
+
let d = '';
|
|
28
|
+
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
29
|
+
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
30
|
+
$: {
|
|
31
|
+
const path = d3Line()
|
|
32
|
+
.x(x ?? $xGet)
|
|
33
|
+
.y(y ?? $yGet);
|
|
34
|
+
if (curve)
|
|
35
|
+
path.curve(curve);
|
|
36
|
+
if (defined)
|
|
37
|
+
path.defined(defined);
|
|
38
|
+
d = pathData ?? path(data ?? $contextData);
|
|
39
|
+
tweened_d.set(d);
|
|
40
|
+
}
|
|
41
|
+
$: drawTransition = draw ? _drawTransition : () => ({});
|
|
42
|
+
let key = Symbol();
|
|
43
|
+
$: if (draw) {
|
|
44
|
+
// Anytime the path data changes, redraw
|
|
45
|
+
$tweened_d;
|
|
46
|
+
key = Symbol();
|
|
47
|
+
}
|
|
48
|
+
let pathEl = undefined;
|
|
49
|
+
const startPoint = writable(undefined);
|
|
50
|
+
$: endPoint = motionStore(undefined, {
|
|
51
|
+
tweened: draw
|
|
52
|
+
? {
|
|
53
|
+
duration: (typeof draw === 'object' && draw.duration) || 800,
|
|
54
|
+
easing: (typeof draw === 'object' && draw.easing) || cubicInOut,
|
|
55
|
+
interpolate(a, b) {
|
|
56
|
+
return (t) => {
|
|
57
|
+
const totalLength = pathEl.getTotalLength();
|
|
58
|
+
const point = pathEl.getPointAtLength(totalLength * t);
|
|
59
|
+
return point;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
: false
|
|
64
|
+
});
|
|
65
|
+
$: {
|
|
66
|
+
if ($$slots.start || $$slots.end) {
|
|
67
|
+
// Wait for path data to update DOM, then update
|
|
68
|
+
d;
|
|
69
|
+
tick().then(() => {
|
|
70
|
+
if (pathEl) {
|
|
71
|
+
startPoint.set(pathEl.getPointAtLength(0));
|
|
72
|
+
const totalLength = pathEl.getTotalLength();
|
|
73
|
+
endPoint.set(pathEl.getPointAtLength(totalLength));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
{#key key}
|
|
81
|
+
<path
|
|
82
|
+
d={$tweened_d}
|
|
83
|
+
{...$$restProps}
|
|
84
|
+
class={cls('path-line fill-none', !$$props.stroke && 'stroke-black', $$props.class)}
|
|
85
|
+
in:drawTransition={typeof draw === 'object' ? draw : undefined}
|
|
86
|
+
on:click
|
|
87
|
+
on:mousemove
|
|
88
|
+
on:mouseleave
|
|
89
|
+
bind:this={pathEl}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
{#if $$slots.start && $startPoint}
|
|
93
|
+
<Group x={$startPoint.x} y={$startPoint.y}>
|
|
94
|
+
<slot name="start" point={$startPoint} />
|
|
95
|
+
</Group>
|
|
96
|
+
{/if}
|
|
97
|
+
|
|
98
|
+
{#if $$slots.end && $endPoint}
|
|
99
|
+
<Group x={$endPoint.x} y={$endPoint.y}>
|
|
100
|
+
<slot name="end" point={$endPoint} />
|
|
101
|
+
</Group>
|
|
102
|
+
{/if}
|
|
103
|
+
{/key}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import { tweened as tweenedStore } from 'svelte/motion';
|
|
3
|
+
import { draw as _drawTransition } from 'svelte/transition';
|
|
4
|
+
import type { CurveFactory, CurveFactoryLineOnly, Line } from 'd3-shape';
|
|
5
|
+
declare const __propDef: {
|
|
6
|
+
props: {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
data?: any;
|
|
9
|
+
pathData?: string | undefined | null;
|
|
10
|
+
x?: any;
|
|
11
|
+
y?: any;
|
|
12
|
+
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
13
|
+
draw?: boolean | Parameters<typeof _drawTransition>[1];
|
|
14
|
+
curve?: CurveFactory | CurveFactoryLineOnly | undefined;
|
|
15
|
+
defined?: Parameters<Line<any>['defined']>[0] | undefined;
|
|
16
|
+
};
|
|
17
|
+
events: {
|
|
18
|
+
click: MouseEvent;
|
|
19
|
+
mousemove: MouseEvent;
|
|
20
|
+
mouseleave: MouseEvent;
|
|
21
|
+
} & {
|
|
22
|
+
[evt: string]: CustomEvent<any>;
|
|
23
|
+
};
|
|
24
|
+
slots: {
|
|
25
|
+
start: {
|
|
26
|
+
point: DOMPoint | undefined;
|
|
27
|
+
};
|
|
28
|
+
end: {
|
|
29
|
+
point: DOMPoint | undefined;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type SplineProps = typeof __propDef.props;
|
|
34
|
+
export type SplineEvents = typeof __propDef.events;
|
|
35
|
+
export type SplineSlots = typeof __propDef.slots;
|
|
36
|
+
export default class Spline extends SvelteComponentTyped<SplineProps, SplineEvents, SplineSlots> {
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -121,7 +121,7 @@ function isValidXOrY(xOrY) {
|
|
|
121
121
|
|
|
122
122
|
<!-- `overflow: visible` allow contents to be shown outside element -->
|
|
123
123
|
<!-- `paint-order: stroke` supports stroke outlining text -->
|
|
124
|
-
<svg x={dx} y={dy}
|
|
124
|
+
<svg x={dx} y={dy} class="overflow-visible [paint-order:stroke]">
|
|
125
125
|
{#if isValidXOrY(x) && isValidXOrY(y)}
|
|
126
126
|
<text {x} {y} {transform} text-anchor={textAnchor} {...$$restProps}>
|
|
127
127
|
{#each wordsByLines as line, index}
|
|
@@ -11,8 +11,8 @@ declare const __propDef: {
|
|
|
11
11
|
lineHeight?: string | undefined;
|
|
12
12
|
capHeight?: string | undefined;
|
|
13
13
|
scaleToFit?: boolean | undefined;
|
|
14
|
-
textAnchor?: "start" | "
|
|
15
|
-
verticalAnchor?: "start" | "
|
|
14
|
+
textAnchor?: "start" | "end" | "middle" | "inherit" | undefined;
|
|
15
|
+
verticalAnchor?: "start" | "end" | "middle" | "inherit" | undefined;
|
|
16
16
|
rotate?: number | undefined;
|
|
17
17
|
};
|
|
18
18
|
events: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { cls, format as formatUtil } from 'svelte-ux';
|
|
2
2
|
export let label;
|
|
3
|
-
|
|
3
|
+
/** Value to be formatted and displayed. Can also be passed as default slot */
|
|
4
|
+
export let value = undefined;
|
|
4
5
|
export let format = undefined;
|
|
5
6
|
export let valueAlign = 'left';
|
|
6
7
|
export let classes = {};
|
|
@@ -6,7 +6,7 @@ declare const __propDef: {
|
|
|
6
6
|
label: any;
|
|
7
7
|
value?: any;
|
|
8
8
|
format?: FormatType;
|
|
9
|
-
valueAlign?: "
|
|
9
|
+
valueAlign?: "center" | "left" | "right" | undefined;
|
|
10
10
|
classes?: {
|
|
11
11
|
label?: string | undefined;
|
|
12
12
|
value?: string | undefined;
|
|
@@ -10,7 +10,6 @@ export { default as ChartClipPath } from './ChartClipPath.svelte';
|
|
|
10
10
|
export { default as Circle } from './Circle.svelte';
|
|
11
11
|
export { default as CircleClipPath } from './CircleClipPath.svelte';
|
|
12
12
|
export { default as ClipPath } from './ClipPath.svelte';
|
|
13
|
-
export { default as ClipPathUse } from './ClipPathUse.svelte';
|
|
14
13
|
export { default as ColorRamp } from './ColorRamp.svelte';
|
|
15
14
|
export { default as ConnectedPoints } from './ConnectedPoints.svelte';
|
|
16
15
|
export { default as Frame } from './Frame.svelte';
|
|
@@ -25,13 +24,15 @@ export { default as HighlightRect } from './HighlightRect.svelte';
|
|
|
25
24
|
export { default as Labels } from './Labels.svelte';
|
|
26
25
|
export { default as Legend } from './Legend.svelte';
|
|
27
26
|
export { default as Line } from './Line.svelte';
|
|
27
|
+
export { default as Spline } from './Spline.svelte';
|
|
28
28
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
29
29
|
export { default as Link } from './Link.svelte';
|
|
30
|
+
export { default as MotionPath } from './MotionPath.svelte';
|
|
30
31
|
export { default as Pack } from './Pack.svelte';
|
|
31
32
|
export { default as Partition } from './Partition.svelte';
|
|
32
|
-
export { default as Path } from './Path.svelte';
|
|
33
33
|
export { default as Pattern } from './Pattern.svelte';
|
|
34
34
|
export { default as Pie } from './Pie.svelte';
|
|
35
|
+
export { default as Point } from './Point.svelte';
|
|
35
36
|
export { default as Points } from './Points.svelte';
|
|
36
37
|
export { default as Rect } from './Rect.svelte';
|
|
37
38
|
export { default as RectClipPath } from './RectClipPath.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export { default as ChartClipPath } from './ChartClipPath.svelte';
|
|
|
10
10
|
export { default as Circle } from './Circle.svelte';
|
|
11
11
|
export { default as CircleClipPath } from './CircleClipPath.svelte';
|
|
12
12
|
export { default as ClipPath } from './ClipPath.svelte';
|
|
13
|
-
export { default as ClipPathUse } from './ClipPathUse.svelte';
|
|
14
13
|
export { default as ColorRamp } from './ColorRamp.svelte';
|
|
15
14
|
export { default as ConnectedPoints } from './ConnectedPoints.svelte';
|
|
16
15
|
export { default as Frame } from './Frame.svelte';
|
|
@@ -25,13 +24,15 @@ export { default as HighlightRect } from './HighlightRect.svelte';
|
|
|
25
24
|
export { default as Labels } from './Labels.svelte';
|
|
26
25
|
export { default as Legend } from './Legend.svelte';
|
|
27
26
|
export { default as Line } from './Line.svelte';
|
|
27
|
+
export { default as Spline } from './Spline.svelte';
|
|
28
28
|
export { default as LinearGradient } from './LinearGradient.svelte';
|
|
29
29
|
export { default as Link } from './Link.svelte';
|
|
30
|
+
export { default as MotionPath } from './MotionPath.svelte';
|
|
30
31
|
export { default as Pack } from './Pack.svelte';
|
|
31
32
|
export { default as Partition } from './Partition.svelte';
|
|
32
|
-
export { default as Path } from './Path.svelte';
|
|
33
33
|
export { default as Pattern } from './Pattern.svelte';
|
|
34
34
|
export { default as Pie } from './Pie.svelte';
|
|
35
|
+
export { default as Point } from './Point.svelte';
|
|
35
36
|
export { default as Points } from './Points.svelte';
|
|
36
37
|
export { default as Rect } from './Rect.svelte';
|
|
37
38
|
export { default as RectClipPath } from './RectClipPath.svelte';
|
package/dist/docs/Code.svelte
CHANGED
|
@@ -13,8 +13,8 @@ export let highlightedSource = source
|
|
|
13
13
|
{#if source}
|
|
14
14
|
<div class="relative">
|
|
15
15
|
<pre class="language-{language} rounded" style="margin: 0; white-space: normal;">
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
<code class="language-{language}">{@html highlightedSource}</code>
|
|
17
|
+
</pre>
|
|
18
18
|
|
|
19
19
|
<div class="absolute top-0 right-0 p-2">
|
|
20
20
|
<Button
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
import * as d3shapes from 'd3-shape';
|
|
3
|
+
import { MenuField } from 'svelte-ux';
|
|
4
|
+
export let value = undefined;
|
|
5
|
+
const options = Object.keys(d3shapes)
|
|
6
|
+
.filter((key) => key.startsWith('curve'))
|
|
7
|
+
.filter((key) => !key.endsWith('Open') && !key.endsWith('Closed'))
|
|
8
|
+
.map((key) => {
|
|
9
|
+
return {
|
|
10
|
+
label: key.replace('curve', ''),
|
|
11
|
+
value: d3shapes[key]
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
onMount(() => {
|
|
15
|
+
value = d3shapes['curveLinear'];
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<MenuField label="Curve" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value?: any | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type CurveMenuFieldProps = typeof __propDef.props;
|
|
12
|
+
export type CurveMenuFieldEvents = typeof __propDef.events;
|
|
13
|
+
export type CurveMenuFieldSlots = typeof __propDef.slots;
|
|
14
|
+
export default class CurveMenuField extends SvelteComponentTyped<CurveMenuFieldProps, CurveMenuFieldEvents, CurveMenuFieldSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
import * as easings from 'svelte/easing';
|
|
3
|
+
import { MenuField } from 'svelte-ux';
|
|
4
|
+
export let value = undefined;
|
|
5
|
+
// TODO: Allow updating externally without loosing selection
|
|
6
|
+
export let amplitude = 1;
|
|
7
|
+
export let frequency = 10;
|
|
8
|
+
export let phase = 0;
|
|
9
|
+
$: mathOptions = [
|
|
10
|
+
{
|
|
11
|
+
label: 'sin',
|
|
12
|
+
group: 'math',
|
|
13
|
+
value: (x) => amplitude * Math.sin(x * frequency) + phase
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'cos',
|
|
17
|
+
group: 'math',
|
|
18
|
+
value: (x) => amplitude * Math.cos(x * frequency) + phase
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: 'tan',
|
|
22
|
+
group: 'math',
|
|
23
|
+
value: (x) => amplitude * Math.tan(x * frequency) + phase
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: 'sqrt',
|
|
27
|
+
group: 'math',
|
|
28
|
+
value: (x) => amplitude * Math.sqrt(x * frequency) + phase
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'ceil',
|
|
32
|
+
group: 'math',
|
|
33
|
+
value: (x) => amplitude * Math.ceil(x * frequency) + phase
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'floor',
|
|
37
|
+
group: 'math',
|
|
38
|
+
value: (x) => amplitude * Math.floor(x * frequency) + phase
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'round',
|
|
42
|
+
group: 'math',
|
|
43
|
+
value: (x) => amplitude * Math.round(x * frequency) + phase
|
|
44
|
+
},
|
|
45
|
+
{ label: 'random', group: 'math', value: (x) => amplitude * Math.random() + phase },
|
|
46
|
+
{
|
|
47
|
+
label: 'pow',
|
|
48
|
+
group: 'math',
|
|
49
|
+
value: (x) => amplitude * Math.pow(x, frequency) + phase
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
const easingOptions = Object.entries(easings).map(([key, value]) => {
|
|
53
|
+
return {
|
|
54
|
+
label: key,
|
|
55
|
+
value,
|
|
56
|
+
group: 'easing'
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
$: options = [...mathOptions, ...easingOptions];
|
|
60
|
+
// Select initial option
|
|
61
|
+
onMount(() => {
|
|
62
|
+
value = options[0].value;
|
|
63
|
+
});
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<MenuField label="Path data" {options} bind:value stepper classes={{ menuIcon: 'hidden' }} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value?: any | undefined;
|
|
5
|
+
amplitude?: number | undefined;
|
|
6
|
+
frequency?: number | undefined;
|
|
7
|
+
phase?: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type PathDataMenuFieldProps = typeof __propDef.props;
|
|
15
|
+
export type PathDataMenuFieldEvents = typeof __propDef.events;
|
|
16
|
+
export type PathDataMenuFieldSlots = typeof __propDef.slots;
|
|
17
|
+
export default class PathDataMenuField extends SvelteComponentTyped<PathDataMenuFieldProps, PathDataMenuFieldEvents, PathDataMenuFieldSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -6,23 +6,29 @@ export let max = 100;
|
|
|
6
6
|
export let step = 1;
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
|
-
<Field let:id classes={{ input: 'mt-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
<Field let:id classes={{ input: 'mt-2 mb-1' }} {...$$restProps}>
|
|
10
|
+
<span slot="prepend">
|
|
11
|
+
<Button
|
|
12
|
+
icon={mdiChevronLeft}
|
|
13
|
+
on:click={() => (value -= value > min ? step : 0)}
|
|
14
|
+
class="mr-2"
|
|
15
|
+
size="sm"
|
|
16
|
+
/>
|
|
17
|
+
</span>
|
|
18
|
+
|
|
16
19
|
<input type="range" bind:value {min} {max} {step} {id} class="h-6 w-full" />
|
|
17
20
|
<span class="ml-2 text-sm text-black/50 tabular-nums text-right inline-grid">
|
|
18
21
|
<span class="col-span-full row-span-full invisible">{min}</span>
|
|
19
22
|
<span class="col-span-full row-span-full">{value}</span>
|
|
20
23
|
<span class="col-span-full row-span-full invisible">{max}</span>
|
|
21
24
|
</span>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
|
|
26
|
+
<span slot="append">
|
|
27
|
+
<Button
|
|
28
|
+
icon={mdiChevronRight}
|
|
29
|
+
on:click={() => (value += value < max ? step : 0)}
|
|
30
|
+
class="ml-2"
|
|
31
|
+
size="sm"
|
|
32
|
+
/>
|
|
33
|
+
</span>
|
|
28
34
|
</Field>
|
|
@@ -10,7 +10,11 @@ export let icon;
|
|
|
10
10
|
{#if source}
|
|
11
11
|
<Toggle let:on={open} let:toggle>
|
|
12
12
|
<Button {icon} on:click={toggle} variant="fill-light" color="blue" size="sm">{label}</Button>
|
|
13
|
-
<Dialog
|
|
13
|
+
<Dialog
|
|
14
|
+
{open}
|
|
15
|
+
on:close={toggle}
|
|
16
|
+
class="max-h-[98vh] md:max-h-[90vh] max-w-[98vw] md:max-w-[90vw] grid grid-rows-[auto,1fr,auto]"
|
|
17
|
+
>
|
|
14
18
|
<div class="grid grid-cols-[1fr,auto] gap-3 items-center p-4">
|
|
15
19
|
<div class="overflow-auto">
|
|
16
20
|
<div class="text-lg font-semibold">{label}</div>
|
|
@@ -24,7 +28,7 @@ export let icon;
|
|
|
24
28
|
{/if}
|
|
25
29
|
</div>
|
|
26
30
|
|
|
27
|
-
<div class="
|
|
31
|
+
<div class="overflow-auto">
|
|
28
32
|
<Code {source} language={source.startsWith('<script') ? 'svelte' : 'js'} />
|
|
29
33
|
</div>
|
|
30
34
|
|
|
@@ -3,7 +3,7 @@ import type Zoom from '../components/Zoom.svelte';
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
zoom: Zoom;
|
|
6
|
-
placement?: ("
|
|
6
|
+
placement?: ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right") | undefined;
|
|
7
7
|
orientation?: "horizontal" | "vertical" | undefined;
|
|
8
8
|
};
|
|
9
9
|
events: {
|
|
@@ -16,7 +16,7 @@ export type PropMotionOptions = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Convenient wrapper to create a motion store (spring(), tweened()) based on properties, or fall back to basic writable() store
|
|
18
18
|
*/
|
|
19
|
-
export declare function motionStore(value: any, options: MotionOptions): import("svelte/motion").
|
|
19
|
+
export declare function motionStore<T = any>(value: any, options: MotionOptions): import("svelte/motion").Spring<T> | import("svelte/motion").Tweened<T> | import("svelte/store").Writable<T>;
|
|
20
20
|
/**
|
|
21
21
|
* Helper to resolve motion options with specific property option (useful for specifying per-prop delays)
|
|
22
22
|
*/
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "techniq/layerchart",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.20.0",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite dev",
|
|
9
9
|
"build": "vite build",
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
|
|
16
16
|
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
|
|
17
17
|
"changeset": "changeset",
|
|
18
|
-
"version": "changeset version"
|
|
18
|
+
"version": "changeset version",
|
|
19
|
+
"version-status": "changeset status -v",
|
|
20
|
+
"publish": "changeset publish"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"@rollup/plugin-dsv": "^3.0.2",
|
|
22
24
|
"@sveltejs/adapter-vercel": "^3.0.1",
|
|
23
|
-
"@sveltejs/kit": "^1.22.
|
|
25
|
+
"@sveltejs/kit": "^1.22.1",
|
|
24
26
|
"@sveltejs/package": "^2.1.0",
|
|
25
27
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
26
28
|
"@tailwindcss/typography": "^0.5.9",
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
"@types/d3-geo": "^3.0.3",
|
|
31
33
|
"@types/d3-hierarchy": "^3.1.2",
|
|
32
34
|
"@types/d3-interpolate": "^3.0.1",
|
|
35
|
+
"@types/d3-interpolate-path": "^2.0.0",
|
|
33
36
|
"@types/d3-quadtree": "^3.0.2",
|
|
34
37
|
"@types/d3-random": "^3.0.1",
|
|
35
38
|
"@types/d3-sankey": "^0.12.1",
|
|
@@ -40,21 +43,22 @@
|
|
|
40
43
|
"@types/shapefile": "^0.6.1",
|
|
41
44
|
"@types/topojson-client": "^3.1.1",
|
|
42
45
|
"autoprefixer": "^10.4.14",
|
|
43
|
-
"
|
|
46
|
+
"execa": "^7.1.1",
|
|
47
|
+
"marked": "^5.1.1",
|
|
44
48
|
"mdsvex": "^0.11.0",
|
|
45
49
|
"prettier": "^2.8.8",
|
|
46
50
|
"prettier-plugin-svelte": "^2.10.1",
|
|
47
51
|
"prism-themes": "^1.9.0",
|
|
48
52
|
"rehype-slug": "^5.1.0",
|
|
49
|
-
"svelte-check": "^3.4.
|
|
53
|
+
"svelte-check": "^3.4.5",
|
|
50
54
|
"svelte-preprocess": "^5.0.4",
|
|
51
|
-
"svelte2tsx": "^0.6.
|
|
55
|
+
"svelte2tsx": "^0.6.19",
|
|
52
56
|
"tailwindcss": "^3.3.2",
|
|
53
57
|
"tslib": "^2.6.0",
|
|
54
58
|
"typescript": "^5.1.6",
|
|
55
59
|
"unist-util-visit": "^4.1.2",
|
|
56
60
|
"us-atlas": "^3.0.1",
|
|
57
|
-
"vite": "^4.
|
|
61
|
+
"vite": "^4.4.2",
|
|
58
62
|
"vite-plugin-sveld": "^1.1.0"
|
|
59
63
|
},
|
|
60
64
|
"type": "module",
|
|
@@ -81,7 +85,7 @@
|
|
|
81
85
|
"lodash-es": "^4.17.21",
|
|
82
86
|
"shapefile": "^0.6.6",
|
|
83
87
|
"svelte": "^3.59.1",
|
|
84
|
-
"svelte-ux": "^0.43.
|
|
88
|
+
"svelte-ux": "^0.43.11",
|
|
85
89
|
"topojson-client": "^3.1.0"
|
|
86
90
|
},
|
|
87
91
|
"main": "./dist/index.js",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
3
|
-
import type { CurveFactory } from 'd3-shape';
|
|
4
|
-
declare const __propDef: {
|
|
5
|
-
props: {
|
|
6
|
-
[x: string]: any;
|
|
7
|
-
data?: any;
|
|
8
|
-
x?: any;
|
|
9
|
-
y0?: any;
|
|
10
|
-
y1?: any;
|
|
11
|
-
pathData?: string | undefined;
|
|
12
|
-
clipPath?: string | undefined;
|
|
13
|
-
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
14
|
-
curve?: CurveFactory | undefined;
|
|
15
|
-
defined?: ((d: any, index: number, data: any[]) => boolean) | undefined;
|
|
16
|
-
color?: string | undefined;
|
|
17
|
-
opacity?: number | undefined;
|
|
18
|
-
line?: boolean | any;
|
|
19
|
-
};
|
|
20
|
-
events: {
|
|
21
|
-
click: MouseEvent;
|
|
22
|
-
mousemove: MouseEvent;
|
|
23
|
-
mouseleave: MouseEvent;
|
|
24
|
-
} & {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots: {};
|
|
28
|
-
};
|
|
29
|
-
export type AreaProps = typeof __propDef.props;
|
|
30
|
-
export type AreaEvents = typeof __propDef.events;
|
|
31
|
-
export type AreaSlots = typeof __propDef.slots;
|
|
32
|
-
export default class Area extends SvelteComponentTyped<AreaProps, AreaEvents, AreaSlots> {
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script>import { uniqueId } from 'svelte-ux';
|
|
2
|
-
import ClipPath from './ClipPath.svelte';
|
|
3
|
-
/** Id of path or shape */
|
|
4
|
-
export let refId;
|
|
5
|
-
/** Unique id for clipPath */
|
|
6
|
-
export let clipPathId = uniqueId('clipPath-');
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<ClipPath id={clipPathId}>
|
|
10
|
-
<use href="#{refId}" />
|
|
11
|
-
</ClipPath>
|
|
12
|
-
|
|
13
|
-
{#if $$slots.default}
|
|
14
|
-
<g style="clip-path: url(#{clipPathId})" on:click on:mousemove on:mouseleave on:keydown>
|
|
15
|
-
<slot {refId} {clipPathId} />
|
|
16
|
-
</g>
|
|
17
|
-
{/if}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
/** Id of path or shape */ refId: string;
|
|
5
|
-
/** Unique id for clipPath */ clipPathId?: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
click: MouseEvent;
|
|
9
|
-
mousemove: MouseEvent;
|
|
10
|
-
mouseleave: MouseEvent;
|
|
11
|
-
keydown: KeyboardEvent;
|
|
12
|
-
} & {
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {
|
|
16
|
-
default: {
|
|
17
|
-
refId: string;
|
|
18
|
-
clipPathId: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type ClipPathUseProps = typeof __propDef.props;
|
|
23
|
-
export type ClipPathUseEvents = typeof __propDef.events;
|
|
24
|
-
export type ClipPathUseSlots = typeof __propDef.slots;
|
|
25
|
-
export default class ClipPathUse extends SvelteComponentTyped<ClipPathUseProps, ClipPathUseEvents, ClipPathUseSlots> {
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<script>/*
|
|
2
|
-
TODO:
|
|
3
|
-
- [ ] Show path progressively show / animated in on load. Also fix sliding in from left side (at last in from bottom)
|
|
4
|
-
*/
|
|
5
|
-
import { getContext } from 'svelte';
|
|
6
|
-
import { line as d3Line } from 'd3-shape';
|
|
7
|
-
// import { interpolateString } from 'd3-interpolate';
|
|
8
|
-
import { interpolatePath } from 'd3-interpolate-path';
|
|
9
|
-
import { motionStore } from '../stores/motionStore';
|
|
10
|
-
const { data: contextData, xGet, yGet } = getContext('LayerCake');
|
|
11
|
-
// Properties to override what is used from context
|
|
12
|
-
export let data = undefined; // TODO: Update Type
|
|
13
|
-
export let x = undefined; // TODO: Update Type
|
|
14
|
-
export let y = undefined; // TODO: Update Type
|
|
15
|
-
export let pathData = undefined;
|
|
16
|
-
export let tweened = undefined;
|
|
17
|
-
export let curve = undefined;
|
|
18
|
-
export let defined = undefined;
|
|
19
|
-
export let color = 'black';
|
|
20
|
-
export let width = undefined;
|
|
21
|
-
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
|
|
22
|
-
$: tweened_d = motionStore('', { tweened: tweenedOptions });
|
|
23
|
-
$: {
|
|
24
|
-
const path = d3Line()
|
|
25
|
-
.x(x ?? $xGet)
|
|
26
|
-
.y(y ?? $yGet);
|
|
27
|
-
if (curve)
|
|
28
|
-
path.curve(curve);
|
|
29
|
-
if (defined)
|
|
30
|
-
path.defined(defined);
|
|
31
|
-
const d = pathData ?? path(data ?? $contextData);
|
|
32
|
-
tweened_d.set(d);
|
|
33
|
-
}
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<path
|
|
37
|
-
class="path-line"
|
|
38
|
-
d={$tweened_d}
|
|
39
|
-
stroke={color}
|
|
40
|
-
stroke-width={width}
|
|
41
|
-
{...$$restProps}
|
|
42
|
-
on:click
|
|
43
|
-
on:mousemove
|
|
44
|
-
on:mouseleave
|
|
45
|
-
/>
|
|
46
|
-
|
|
47
|
-
<style>
|
|
48
|
-
.path-line {
|
|
49
|
-
fill: none;
|
|
50
|
-
stroke-linejoin: round;
|
|
51
|
-
stroke-linecap: round;
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { tweened as tweenedStore } from 'svelte/motion';
|
|
3
|
-
import type { CurveFactory, CurveFactoryLineOnly } from 'd3-shape';
|
|
4
|
-
declare const __propDef: {
|
|
5
|
-
props: {
|
|
6
|
-
[x: string]: any;
|
|
7
|
-
data?: any;
|
|
8
|
-
x?: any;
|
|
9
|
-
y?: any;
|
|
10
|
-
pathData?: string | undefined;
|
|
11
|
-
tweened?: boolean | Parameters<typeof tweenedStore>[1];
|
|
12
|
-
curve?: CurveFactory | CurveFactoryLineOnly | undefined;
|
|
13
|
-
defined?: ((d: any, index: number, data: any[]) => boolean) | undefined;
|
|
14
|
-
color?: string | undefined;
|
|
15
|
-
width?: undefined;
|
|
16
|
-
};
|
|
17
|
-
events: {
|
|
18
|
-
click: MouseEvent;
|
|
19
|
-
mousemove: MouseEvent;
|
|
20
|
-
mouseleave: MouseEvent;
|
|
21
|
-
} & {
|
|
22
|
-
[evt: string]: CustomEvent<any>;
|
|
23
|
-
};
|
|
24
|
-
slots: {};
|
|
25
|
-
};
|
|
26
|
-
export type PathProps = typeof __propDef.props;
|
|
27
|
-
export type PathEvents = typeof __propDef.events;
|
|
28
|
-
export type PathSlots = typeof __propDef.slots;
|
|
29
|
-
export default class Path extends SvelteComponentTyped<PathProps, PathEvents, PathSlots> {
|
|
30
|
-
}
|
|
31
|
-
export {};
|