svelteplot 0.5.2-pr-251.0 → 0.5.2-pr-251.2

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.
@@ -1,3 +1,7 @@
1
+ <!--
2
+ @component
3
+ For showing images positioned at x/y coordinates
4
+ -->
1
5
  <script lang="ts" generics="Datum extends DataRecord">
2
6
  interface ImageMarkProps extends BaseMarkProps<Datum>, LinkableMarkProps<Datum> {
3
7
  data: Datum[];
@@ -24,6 +28,7 @@
24
28
  import CustomMark from './CustomMark.svelte';
25
29
  import { getPlotDefaults } from '../hooks/plotDefaults';
26
30
  import { sort } from '../transforms';
31
+ import Anchor from './helpers/Anchor.svelte';
27
32
 
28
33
  let markProps: ImageMarkProps = $props();
29
34
 
@@ -39,6 +44,7 @@
39
44
  height,
40
45
  src,
41
46
  title,
47
+ imageClass,
42
48
  preserveAspectRatio,
43
49
  ...options
44
50
  }: ImageMarkProps = $derived({
@@ -54,14 +60,17 @@
54
60
  {@const w = record.r !== undefined ? record.r * 2 : resolveProp(width, record.datum, 20)}
55
61
  {@const h =
56
62
  record.r !== undefined ? record.r * 2 : resolveProp(height || width, record.datum, 20)}
57
- <image
58
- href={resolveProp(src, record.datum, '')}
59
- x={record.x - w * 0.5}
60
- y={record.y - h * 0.5}
61
- {preserveAspectRatio}
62
- clip-path={record.r !== undefined ? `circle(${record.r}px)` : null}
63
- width={w}
64
- height={h}
65
- >{#if title}<title>{resolveProp(title, record.datum, '')}</title>{/if}</image>
63
+ <Anchor {options} datum={record.datum}>
64
+ <image
65
+ class={resolveProp(imageClass, record.datum, null)}
66
+ href={resolveProp(src, record.datum, '')}
67
+ x={record.x - w * 0.5}
68
+ y={record.y - h * 0.5}
69
+ {preserveAspectRatio}
70
+ clip-path={record.r !== undefined ? `circle(${record.r}px)` : null}
71
+ width={w}
72
+ height={h}
73
+ >{#if title}<title>{resolveProp(title, record.datum, '')}</title>{/if}</image>
74
+ </Anchor>
66
75
  {/snippet}
67
76
  </CustomMark>
@@ -13,6 +13,7 @@ interface $$IsomorphicComponent {
13
13
  <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
14
14
  z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
15
15
  }
16
+ /** For showing images positioned at x/y coordinates */
16
17
  declare const Image: $$IsomorphicComponent;
17
18
  type Image<Datum extends DataRecord> = InstanceType<typeof Image<Datum>>;
18
19
  export default Image;
@@ -1,7 +1,21 @@
1
- <script>
1
+ <script lang="ts" generics="Datum extends Record<string, any>">
2
2
  import { resolveProp } from '../../helpers/resolve.js';
3
+ import type { ConstantAccessor } from '../../types';
3
4
 
4
- let { datum = {}, options = {}, children } = $props();
5
+ interface AnchorProps {
6
+ datum?: Datum;
7
+ options?: {
8
+ href?: ConstantAccessor<string, Datum>;
9
+ target?: ConstantAccessor<string, Datum>;
10
+ rel?: ConstantAccessor<string, Datum>;
11
+ type?: ConstantAccessor<string, Datum>;
12
+ download?: ConstantAccessor<string, Datum>;
13
+ [key: string]: any;
14
+ };
15
+ children?: () => any;
16
+ }
17
+
18
+ let { datum = {}, options = {}, children }: AnchorProps = $props();
5
19
 
6
20
  const href = $derived(resolveProp(options.href, datum, null));
7
21
  const target = $derived(resolveProp(options.target, datum, null));
@@ -1,15 +1,29 @@
1
+ import type { ConstantAccessor } from '../../types';
2
+ declare class __sveltets_Render<Datum extends Record<string, any>> {
3
+ props(): {
4
+ datum?: Datum | undefined;
5
+ options?: {
6
+ [key: string]: any;
7
+ href?: ConstantAccessor<string, Datum_1>;
8
+ target?: ConstantAccessor<string, Datum_1>;
9
+ rel?: ConstantAccessor<string, Datum_1>;
10
+ type?: ConstantAccessor<string, Datum_1>;
11
+ download?: ConstantAccessor<string, Datum_1>;
12
+ } | undefined;
13
+ children?: (() => any) | undefined;
14
+ };
15
+ events(): {};
16
+ slots(): {};
17
+ bindings(): "";
18
+ exports(): {};
19
+ }
20
+ interface $$IsomorphicComponent {
21
+ new <Datum extends Record<string, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
22
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
23
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
24
+ <Datum extends Record<string, any>>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
25
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
26
+ }
27
+ declare const Anchor: $$IsomorphicComponent;
28
+ type Anchor<Datum extends Record<string, any>> = InstanceType<typeof Anchor<Datum>>;
1
29
  export default Anchor;
2
- type Anchor = {
3
- $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<$$ComponentProps>): void;
5
- };
6
- declare const Anchor: import("svelte").Component<{
7
- datum?: Record<string, any>;
8
- options?: Record<string, any>;
9
- children: any;
10
- }, {}, "">;
11
- type $$ComponentProps = {
12
- datum?: Record<string, any>;
13
- options?: Record<string, any>;
14
- children: any;
15
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.5.2-pr-251.0",
3
+ "version": "0.5.2-pr-251.2",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",