layerchart 0.59.1 → 0.59.3

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.
@@ -8,7 +8,7 @@
8
8
  import { createDimensionGetter } from '../utils/rect.js';
9
9
  import { isScaleBand } from '../utils/scales.js';
10
10
  import { accessor, type Accessor } from '../utils/common.js';
11
- import { greatestAbs } from '@layerstack/utils/array';
11
+ import { greatestAbs } from '@layerstack/utils';
12
12
 
13
13
  const { x: xContext, y: yContext, xScale } = chartContext();
14
14
 
@@ -41,6 +41,9 @@
41
41
  /** Inset the rect for amount of padding. Useful with multiple bars (bullet, overlap, etc) */
42
42
  export let inset = 0;
43
43
 
44
+ /** Define unique value for {#each} `(key)` expressions to improve transitions. `index` position used by default */
45
+ export let key: (d: any, index: number) => any = (d, i) => i;
46
+
44
47
  export let spring: ComponentProps<Rect>['spring'] = undefined;
45
48
  export let tweened: ComponentProps<Rect>['tweened'] = undefined;
46
49
 
@@ -49,7 +52,7 @@
49
52
 
50
53
  <g class="Bars">
51
54
  <slot>
52
- {#each _data as d, i}
55
+ {#each _data as d, i (key(d, i))}
53
56
  <Bar
54
57
  bar={d}
55
58
  {x}
@@ -15,6 +15,7 @@ declare const __propDef: {
15
15
  radius?: number | undefined;
16
16
  fill?: string | undefined;
17
17
  inset?: number | undefined;
18
+ key?: ((d: any, index: number) => any) | undefined;
18
19
  spring?: ComponentProps<Rect>["spring"];
19
20
  tweened?: ComponentProps<Rect>["tweened"];
20
21
  };
@@ -2,7 +2,7 @@
2
2
  import { type ComponentProps } from 'svelte';
3
3
  import { max, min } from 'd3-array';
4
4
  import { pointRadial, type Series, type SeriesPoint } from 'd3-shape';
5
- import { notNull } from '@layerstack/utils/typeGuards';
5
+ import { notNull } from '@layerstack/utils';
6
6
  import { cls } from '@layerstack/tailwind';
7
7
 
8
8
  import { chartContext } from './ChartContext.svelte';
@@ -18,6 +18,9 @@
18
18
  export let offset = placement === 'center' ? 0 : 4;
19
19
  export let format: FormatType | undefined = undefined;
20
20
 
21
+ /** Define unique value for {#each} `(key)` expressions to improve transitions. `index` position used by default */
22
+ export let key: (d: any, index: number) => any = (d, i) => i;
23
+
21
24
  $: getTextProps = (point: Point): ComponentProps<Text> => {
22
25
  // Used for positioning
23
26
  const pointValue = isScaleBand($yScale) ? point.xValue : point.yValue;
@@ -88,17 +91,20 @@
88
91
 
89
92
  <g class="Labels">
90
93
  <Points let:points>
91
- {#each points as point}
92
- <Text
93
- class={cls(
94
- 'text-xs',
95
- placement === 'inside'
96
- ? 'fill-surface-300 stroke-surface-content'
97
- : 'fill-surface-content stroke-surface-100'
98
- )}
99
- {...getTextProps(point)}
100
- {...$$restProps}
101
- />
94
+ {#each points as point, i (key(point.data, i))}
95
+ {@const textProps = getTextProps(point)}
96
+ <slot data={point} {textProps}>
97
+ <Text
98
+ class={cls(
99
+ 'text-xs',
100
+ placement === 'inside'
101
+ ? 'fill-surface-300 stroke-surface-content'
102
+ : 'fill-surface-content stroke-surface-100'
103
+ )}
104
+ {...textProps}
105
+ {...$$restProps}
106
+ />
107
+ </slot>
102
108
  {/each}
103
109
  </Points>
104
110
  </g>
@@ -1,5 +1,6 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import { type FormatType } from '@layerstack/utils';
3
+ import { type Point } from './Points.svelte';
3
4
  import { type Accessor } from '../utils/common.js';
4
5
  declare const __propDef: {
5
6
  props: {
@@ -8,11 +9,17 @@ declare const __propDef: {
8
9
  placement?: ("inside" | "outside" | "center") | undefined;
9
10
  offset?: number | undefined;
10
11
  format?: FormatType | undefined;
12
+ key?: ((d: any, index: number) => any) | undefined;
11
13
  };
12
14
  events: {
13
15
  [evt: string]: CustomEvent<any>;
14
16
  };
15
- slots: {};
17
+ slots: {
18
+ default: {
19
+ data: Point;
20
+ textProps: any;
21
+ };
22
+ };
16
23
  };
17
24
  export type LabelsProps = typeof __propDef.props;
18
25
  export type LabelsEvents = typeof __propDef.events;
@@ -7,7 +7,7 @@
7
7
  import type { Readable } from 'svelte/store';
8
8
  import { extent } from 'd3-array';
9
9
  import { pointRadial } from 'd3-shape';
10
- import { notNull } from '@layerstack/utils/typeGuards';
10
+ import { notNull } from '@layerstack/utils';
11
11
 
12
12
  import { chartContext } from './ChartContext.svelte';
13
13
  import Circle from './Circle.svelte';
@@ -195,7 +195,7 @@
195
195
  <slot name="belowMarks" {...slotProps} />
196
196
 
197
197
  <slot name="marks" {...slotProps}>
198
- {#each series as s, i}
198
+ {#each series as s, i (s.key)}
199
199
  <Area {...getAreaProps(s, i)} />
200
200
  {/each}
201
201
  </slot>
@@ -247,7 +247,7 @@
247
247
  {/if}
248
248
 
249
249
  <slot name="highlight" {...slotProps}>
250
- {#each series as s, i}
250
+ {#each series as s, i (s.key)}
251
251
  <Highlight
252
252
  y={stackSeries ? (d) => d.stackData[i][1] : (s.value ?? s.key)}
253
253
  points={{ fill: s.color }}
@@ -242,6 +242,7 @@ declare class __sveltets_Render<TData> {
242
242
  placement?: ("inside" | "outside" | "center") | undefined;
243
243
  offset?: number | undefined;
244
244
  format?: import("@layerstack/utils").FormatType | undefined;
245
+ key?: ((d: any, index: number) => any) | undefined;
245
246
  };
246
247
  legend?: boolean | {
247
248
  [x: string]: any;
@@ -244,7 +244,7 @@
244
244
  <slot name="belowMarks" {...slotProps} />
245
245
 
246
246
  <slot name="marks" {...slotProps}>
247
- {#each series as s, i}
247
+ {#each series as s, i (s.key)}
248
248
  <Bars {...getBarsProps(s, i)} />
249
249
  {/each}
250
250
  </slot>
@@ -242,6 +242,7 @@ declare class __sveltets_Render<TData> {
242
242
  placement?: ("inside" | "outside" | "center") | undefined;
243
243
  offset?: number | undefined;
244
244
  format?: import("@layerstack/utils").FormatType | undefined;
245
+ key?: ((d: any, index: number) => any) | undefined;
245
246
  };
246
247
  legend?: boolean | {
247
248
  [x: string]: any;
@@ -142,7 +142,7 @@
142
142
  <slot name="belowMarks" {...slotProps} />
143
143
 
144
144
  <slot name="marks" {...slotProps}>
145
- {#each series as s, i}
145
+ {#each series as s, i (s.key)}
146
146
  <Spline {...getSplineProps(s, i)} />
147
147
  {/each}
148
148
  </slot>
@@ -192,7 +192,7 @@
192
192
  {/if}
193
193
 
194
194
  <slot name="highlight" {...slotProps}>
195
- {#each series as s, i}
195
+ {#each series as s, i (s.key)}
196
196
  <Highlight
197
197
  data={s.data}
198
198
  y={s.value ?? s.key}
@@ -241,6 +241,7 @@ declare class __sveltets_Render<TData> {
241
241
  placement?: ("inside" | "outside" | "center") | undefined;
242
242
  offset?: number | undefined;
243
243
  format?: import("@layerstack/utils").FormatType | undefined;
244
+ key?: ((d: any, index: number) => any) | undefined;
244
245
  };
245
246
  legend?: boolean | {
246
247
  [x: string]: any;
@@ -164,7 +164,7 @@
164
164
  center={['left', 'right'].includes(placement) ? 'y' : undefined}
165
165
  {...props.group}
166
166
  >
167
- {#each series as s, i}
167
+ {#each series as s, i (s.key)}
168
168
  {@const singleArc = s.data?.length === 1 || chartData.length === 1}
169
169
  {#if singleArc}
170
170
  {@const d = s.data?.[0] || chartData[0]}
@@ -217,7 +217,8 @@ declare class __sveltets_Render<TData> {
217
217
  label?: string;
218
218
  tick?: string;
219
219
  swatches?: string;
220
- swatch?: string;
220
+ swatch
221
+ /** Key accessor */ ? /** Key accessor */: string;
221
222
  } | undefined;
222
223
  };
223
224
  maxValue?: number | undefined;
@@ -119,7 +119,7 @@
119
119
  <slot name="belowMarks" {...slotProps} />
120
120
 
121
121
  <slot name="marks" {...slotProps}>
122
- {#each series as s, i}
122
+ {#each series as s, i (s.key)}
123
123
  <Points {...getPointsProps(s, i)} />
124
124
  {/each}
125
125
  </slot>
@@ -240,6 +240,7 @@ declare class __sveltets_Render<TData> {
240
240
  placement?: ("inside" | "outside" | "center") | undefined;
241
241
  offset?: number | undefined;
242
242
  format?: import("@layerstack/utils").FormatType | undefined;
243
+ key?: ((d: any, index: number) => any) | undefined;
243
244
  };
244
245
  legend?: boolean | {
245
246
  [x: string]: any;
@@ -7,8 +7,6 @@
7
7
 
8
8
  import { Button, CopyButton, Dialog, Toggle, Tooltip } from 'svelte-ux';
9
9
  import { cls } from '@layerstack/tailwind';
10
- import { entries, fromEntries } from '@layerstack/utils';
11
- import { isLiteralObject } from '@layerstack/utils/object';
12
10
 
13
11
  import Code from './Code.svelte';
14
12
  import Json from './Json.svelte';
@@ -2,7 +2,7 @@ import { derived } from 'svelte/store';
2
2
  import { tweened, spring } from 'svelte/motion';
3
3
  import { motionStore } from '../stores/motionStore.js';
4
4
  import { scaleBand } from 'd3-scale';
5
- import { unique } from '@layerstack/utils/array';
5
+ import { unique } from '@layerstack/utils';
6
6
  /**
7
7
  * Implemenation for missing `scaleBand().invert()`
8
8
  *
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.59.1",
7
+ "version": "0.59.3",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.9",
10
10
  "@mdi/js": "^7.4.47",
@@ -67,10 +67,10 @@
67
67
  },
68
68
  "type": "module",
69
69
  "dependencies": {
70
- "@layerstack/svelte-actions": "^0.0.7",
71
- "@layerstack/svelte-stores": "^0.0.6",
72
- "@layerstack/tailwind": "^0.0.9",
73
- "@layerstack/utils": "^0.0.5",
70
+ "@layerstack/svelte-actions": "^0.0.8",
71
+ "@layerstack/svelte-stores": "^0.0.8",
72
+ "@layerstack/tailwind": "^0.0.10",
73
+ "@layerstack/utils": "^0.0.6",
74
74
  "d3-array": "^3.2.4",
75
75
  "d3-color": "^3.1.0",
76
76
  "d3-delaunay": "^6.0.4",
@@ -104,11 +104,13 @@
104
104
  "exports": {
105
105
  ".": {
106
106
  "types": "./dist/index.d.ts",
107
- "svelte": "./dist/index.js"
107
+ "svelte": "./dist/index.js",
108
+ "default": "./dist/index.js"
108
109
  },
109
110
  "./utils/*": {
110
111
  "types": "./dist/utils/*.d.ts",
111
- "svelte": "./dist/utils/*.js"
112
+ "svelte": "./dist/utils/*.js",
113
+ "default": "./dist/utils/*.js"
112
114
  }
113
115
  },
114
116
  "files": [