@samizdata/mozaic 0.5.1 → 0.6.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.
Files changed (33) hide show
  1. package/dist/frame/Source.svelte +32 -3
  2. package/dist/frame/Source.svelte.d.ts +13 -4
  3. package/dist/frame/index.d.ts +1 -0
  4. package/dist/frame/types.d.ts +7 -0
  5. package/dist/frame/types.js +1 -0
  6. package/dist/recipes/ArrowChart.svelte +4 -3
  7. package/dist/recipes/ArrowChart.svelte.d.ts +3 -1
  8. package/dist/recipes/BarChart.svelte +4 -3
  9. package/dist/recipes/BarChart.svelte.d.ts +3 -1
  10. package/dist/recipes/BarDotChart.svelte +4 -3
  11. package/dist/recipes/BarDotChart.svelte.d.ts +3 -1
  12. package/dist/recipes/ColumnChart.svelte +4 -3
  13. package/dist/recipes/ColumnChart.svelte.d.ts +3 -1
  14. package/dist/recipes/LineChart.svelte +4 -3
  15. package/dist/recipes/LineChart.svelte.d.ts +3 -1
  16. package/dist/recipes/MosaicChart.svelte +4 -3
  17. package/dist/recipes/MosaicChart.svelte.d.ts +3 -1
  18. package/dist/recipes/PercentileChart.svelte +4 -3
  19. package/dist/recipes/PercentileChart.svelte.d.ts +3 -1
  20. package/dist/recipes/ScatterChart.svelte +4 -3
  21. package/dist/recipes/ScatterChart.svelte.d.ts +3 -1
  22. package/dist/recipes/StackedBarChart.svelte +4 -3
  23. package/dist/recipes/StackedBarChart.svelte.d.ts +3 -1
  24. package/package.json +1 -1
  25. package/src/lib/recipes/ArrowChart.svelte +4 -3
  26. package/src/lib/recipes/BarChart.svelte +4 -3
  27. package/src/lib/recipes/BarDotChart.svelte +4 -3
  28. package/src/lib/recipes/ColumnChart.svelte +4 -3
  29. package/src/lib/recipes/LineChart.svelte +4 -3
  30. package/src/lib/recipes/MosaicChart.svelte +4 -3
  31. package/src/lib/recipes/PercentileChart.svelte +4 -3
  32. package/src/lib/recipes/ScatterChart.svelte +4 -3
  33. package/src/lib/recipes/StackedBarChart.svelte +4 -3
@@ -1,18 +1,38 @@
1
1
  <!--
2
2
  @component
3
- "Source: …", with the label in the chart's language. Set `plural` for several sources.
3
+ "Source: …", with the label in the chart's language. Pass `sources` as text or as a list of
4
+ sources with optional links (`[{ label: 'ANRE', href: 'https://anre.md/…' }, …]`, joined with
5
+ "; "), or write the text as children. The label turns plural for more than one listed source,
6
+ or set `plural`. Links open in a new tab; in print they are plain text.
4
7
  -->
5
8
  <script lang="ts">
6
9
  import type { Snippet } from 'svelte';
7
10
  import { useChart } from '../core/context.js';
11
+ import type { SourceItem } from './types.js';
8
12
 
9
- let { plural = false, children }: { plural?: boolean; children?: Snippet } = $props();
13
+ interface Props {
14
+ /** The sources: plain text, or a list of sources with optional links. */
15
+ sources?: string | SourceItem[];
16
+ /** Use the plural label ("Sources"). Defaults to true for more than one item in `sources`. */
17
+ plural?: boolean;
18
+ children?: Snippet;
19
+ }
20
+
21
+ let { sources, plural, children }: Props = $props();
10
22
 
11
23
  const chart = useChart();
24
+ const items = $derived<SourceItem[]>(typeof sources === 'string' ? [{ label: sources }] : (sources ?? []));
25
+ const many = $derived(plural ?? (Array.isArray(sources) && sources.length > 1));
26
+ const linked = $derived(chart.medium !== 'print');
12
27
  </script>
13
28
 
14
29
  <p class="mz-source">
15
- <span class="mz-label">{plural ? chart.locale.strings.sources : chart.locale.strings.source}:</span>
30
+ <span class="mz-label">{many ? chart.locale.strings.sources : chart.locale.strings.source}:</span>
31
+ {#each items as item, i (i)}{i > 0 ? '; ' : ''}{#if item.href && linked}<a
32
+ href={item.href}
33
+ target="_blank"
34
+ rel="noopener">{item.label}</a
35
+ >{:else}{item.label}{/if}{/each}
16
36
  {@render children?.()}
17
37
  </p>
18
38
 
@@ -26,4 +46,13 @@
26
46
  text-transform: var(--mz-label-transform);
27
47
  letter-spacing: var(--mz-label-tracking);
28
48
  }
49
+ .mz-source a {
50
+ color: inherit;
51
+ text-decoration-line: underline;
52
+ text-decoration-thickness: 1px;
53
+ text-underline-offset: 2px;
54
+ }
55
+ .mz-source a:hover {
56
+ text-decoration-thickness: 2px;
57
+ }
29
58
  </style>
@@ -1,9 +1,18 @@
1
1
  import type { Snippet } from 'svelte';
2
- type $$ComponentProps = {
2
+ import type { SourceItem } from './types.js';
3
+ interface Props {
4
+ /** The sources: plain text, or a list of sources with optional links. */
5
+ sources?: string | SourceItem[];
6
+ /** Use the plural label ("Sources"). Defaults to true for more than one item in `sources`. */
3
7
  plural?: boolean;
4
8
  children?: Snippet;
5
- };
6
- /** "Source: …", with the label in the chart's language. Set `plural` for several sources. */
7
- declare const Source: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ }
10
+ /**
11
+ * "Source: …", with the label in the chart's language. Pass `sources` as text or as a list of
12
+ * sources with optional links (`[{ label: 'ANRE', href: 'https://anre.md/…' }, …]`, joined with
13
+ * "; "), or write the text as children. The label turns plural for more than one listed source,
14
+ * or set `plural`. Links open in a new tab; in print they are plain text.
15
+ */
16
+ declare const Source: import("svelte").Component<Props, {}, "">;
8
17
  type Source = ReturnType<typeof Source>;
9
18
  export default Source;
@@ -10,3 +10,4 @@ export { default as Byline } from './Byline.svelte';
10
10
  export { default as DataTable } from './DataTable.svelte';
11
11
  export { default as DataDownload } from './DataDownload.svelte';
12
12
  export { setDownloads, useChart, useLocale, useTheme } from '../core/context.js';
13
+ export type { SourceItem } from './types.js';
@@ -0,0 +1,7 @@
1
+ /** One source in `<Source sources={…}>` or a recipe's `source` prop. */
2
+ export interface SourceItem {
3
+ /** What the reader sees, e.g. "ANRE" or "Eurostat (nrg_ti_gas)". */
4
+ label: string;
5
+ /** Link to the data or document. */
6
+ href?: string;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -11,7 +11,7 @@ project and change anything.
11
11
  import type { Snippet } from 'svelte';
12
12
  import { scaleBand, scaleLinear } from 'd3-scale';
13
13
  import { max, min } from 'd3-array';
14
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
14
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
15
15
  import type { ChartEmbed } from '../embed/index.js';
16
16
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
17
17
  import { Arrows } from '../marks/index.js';
@@ -38,7 +38,8 @@ project and change anything.
38
38
  title?: string;
39
39
  subtitle?: string;
40
40
  notes?: string;
41
- source?: string;
41
+ /** Plain text, or sources with optional links (see `<Source>`). */
42
+ source?: string | SourceItem[];
42
43
  alt?: string;
43
44
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
44
45
  embed?: ChartEmbed;
@@ -215,7 +216,7 @@ project and change anything.
215
216
  {#if notes || source}
216
217
  <Footer>
217
218
  {#if notes}<Notes>{notes}</Notes>{/if}
218
- {#if source}<Source>{source}</Source>{/if}
219
+ {#if source}<Source sources={source} />{/if}
219
220
  </Footer>
220
221
  {/if}
221
222
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -21,7 +22,8 @@ declare function $$render<T>(): {
21
22
  title?: string;
22
23
  subtitle?: string;
23
24
  notes?: string;
24
- source?: string;
25
+ /** Plain text, or sources with optional links (see `<Source>`). */
26
+ source?: string | SourceItem[];
25
27
  alt?: string;
26
28
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
27
29
  embed?: ChartEmbed;
@@ -8,7 +8,7 @@ file into your project and change anything.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleBand, scaleLinear } from 'd3-scale';
10
10
  import { max, min } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
14
14
  import { Bars, Rules, Text } from '../marks/index.js';
@@ -28,7 +28,8 @@ file into your project and change anything.
28
28
  title?: string;
29
29
  subtitle?: string;
30
30
  notes?: string;
31
- source?: string;
31
+ /** Plain text, or sources with optional links (see `<Source>`). */
32
+ source?: string | SourceItem[];
32
33
  alt?: string;
33
34
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
34
35
  embed?: ChartEmbed;
@@ -116,7 +117,7 @@ file into your project and change anything.
116
117
  {#if notes || source}
117
118
  <Footer>
118
119
  {#if notes}<Notes>{notes}</Notes>{/if}
119
- {#if source}<Source>{source}</Source>{/if}
120
+ {#if source}<Source sources={source} />{/if}
120
121
  </Footer>
121
122
  {/if}
122
123
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -15,7 +16,8 @@ declare function $$render<T>(): {
15
16
  title?: string;
16
17
  subtitle?: string;
17
18
  notes?: string;
18
- source?: string;
19
+ /** Plain text, or sources with optional links (see `<Source>`). */
20
+ source?: string | SourceItem[];
19
21
  alt?: string;
20
22
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
21
23
  embed?: ChartEmbed;
@@ -11,7 +11,7 @@ anything.
11
11
  import type { Snippet } from 'svelte';
12
12
  import { scaleBand, scaleLinear } from 'd3-scale';
13
13
  import { max, min } from 'd3-array';
14
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
14
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
15
15
  import type { ChartEmbed } from '../embed/index.js';
16
16
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
17
17
  import { Bars, Points } from '../marks/index.js';
@@ -38,7 +38,8 @@ anything.
38
38
  title?: string;
39
39
  subtitle?: string;
40
40
  notes?: string;
41
- source?: string;
41
+ /** Plain text, or sources with optional links (see `<Source>`). */
42
+ source?: string | SourceItem[];
42
43
  alt?: string;
43
44
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
44
45
  embed?: ChartEmbed;
@@ -178,7 +179,7 @@ anything.
178
179
  {#if notes || source}
179
180
  <Footer>
180
181
  {#if notes}<Notes>{notes}</Notes>{/if}
181
- {#if source}<Source>{source}</Source>{/if}
182
+ {#if source}<Source sources={source} />{/if}
182
183
  </Footer>
183
184
  {/if}
184
185
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -21,7 +22,8 @@ declare function $$render<T>(): {
21
22
  title?: string;
22
23
  subtitle?: string;
23
24
  notes?: string;
24
- source?: string;
25
+ /** Plain text, or sources with optional links (see `<Source>`). */
26
+ source?: string | SourceItem[];
25
27
  alt?: string;
26
28
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
27
29
  embed?: ChartEmbed;
@@ -8,7 +8,7 @@ copies this file into your project.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleBand, scaleLinear } from 'd3-scale';
10
10
  import { max, min } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, scaled, type PlotContext } from '../core/index.js';
14
14
  import { Bars, Rules } from '../marks/index.js';
@@ -29,7 +29,8 @@ copies this file into your project.
29
29
  title?: string;
30
30
  subtitle?: string;
31
31
  notes?: string;
32
- source?: string;
32
+ /** Plain text, or sources with optional links (see `<Source>`). */
33
+ source?: string | SourceItem[];
33
34
  alt?: string;
34
35
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
35
36
  embed?: ChartEmbed;
@@ -113,7 +114,7 @@ copies this file into your project.
113
114
  {#if notes || source}
114
115
  <Footer>
115
116
  {#if notes}<Notes>{notes}</Notes>{/if}
116
- {#if source}<Source>{source}</Source>{/if}
117
+ {#if source}<Source sources={source} />{/if}
117
118
  </Footer>
118
119
  {/if}
119
120
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -16,7 +17,8 @@ declare function $$render<T>(): {
16
17
  title?: string;
17
18
  subtitle?: string;
18
19
  notes?: string;
19
- source?: string;
20
+ /** Plain text, or sources with optional links (see `<Source>`). */
21
+ source?: string | SourceItem[];
20
22
  alt?: string;
21
23
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
22
24
  embed?: ChartEmbed;
@@ -10,7 +10,7 @@ project.
10
10
  import { scaleLinear, scaleTime } from 'd3-scale';
11
11
  import { bisector, extent, max, min } from 'd3-array';
12
12
  import { curveMonotoneX } from 'd3-shape';
13
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
13
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
14
14
  import type { ChartEmbed } from '../embed/index.js';
15
15
  import { Plot, Svg, Html, type PlotContext } from '../core/index.js';
16
16
  import { Line, LineEndLabels } from '../marks/index.js';
@@ -33,7 +33,8 @@ project.
33
33
  title?: string;
34
34
  subtitle?: string;
35
35
  notes?: string;
36
- source?: string;
36
+ /** Plain text, or sources with optional links (see `<Source>`). */
37
+ source?: string | SourceItem[];
37
38
  alt?: string;
38
39
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
39
40
  embed?: ChartEmbed;
@@ -153,7 +154,7 @@ project.
153
154
  {#if notes || source}
154
155
  <Footer>
155
156
  {#if notes}<Notes>{notes}</Notes>{/if}
156
- {#if source}<Source>{source}</Source>{/if}
157
+ {#if source}<Source sources={source} />{/if}
157
158
  </Footer>
158
159
  {/if}
159
160
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -18,7 +19,8 @@ declare function $$render<S, P>(): {
18
19
  title?: string;
19
20
  subtitle?: string;
20
21
  notes?: string;
21
- source?: string;
22
+ /** Plain text, or sources with optional links (see `<Source>`). */
23
+ source?: string | SourceItem[];
22
24
  alt?: string;
23
25
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
24
26
  embed?: ChartEmbed;
@@ -13,7 +13,7 @@ project and change anything.
13
13
  import type { Snippet } from 'svelte';
14
14
  import { scaleLinear } from 'd3-scale';
15
15
  import { group, sum } from 'd3-array';
16
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
16
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
17
17
  import type { ChartEmbed } from '../embed/index.js';
18
18
  import { Plot, Svg, estimateTextWidth, type PlotContext } from '../core/index.js';
19
19
  import { Rects } from '../marks/index.js';
@@ -51,7 +51,8 @@ project and change anything.
51
51
  title?: string;
52
52
  subtitle?: string;
53
53
  notes?: string;
54
- source?: string;
54
+ /** Plain text, or sources with optional links (see `<Source>`). */
55
+ source?: string | SourceItem[];
55
56
  alt?: string;
56
57
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
57
58
  embed?: ChartEmbed;
@@ -232,7 +233,7 @@ project and change anything.
232
233
  {#if notes || source}
233
234
  <Footer>
234
235
  {#if notes}<Notes>{notes}</Notes>{/if}
235
- {#if source}<Source>{source}</Source>{/if}
236
+ {#if source}<Source sources={source} />{/if}
236
237
  </Footer>
237
238
  {/if}
238
239
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -35,7 +36,8 @@ declare function $$render<T>(): {
35
36
  title?: string;
36
37
  subtitle?: string;
37
38
  notes?: string;
38
- source?: string;
39
+ /** Plain text, or sources with optional links (see `<Source>`). */
40
+ source?: string | SourceItem[];
39
41
  alt?: string;
40
42
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
41
43
  embed?: ChartEmbed;
@@ -15,7 +15,7 @@ your project and change anything.
15
15
  import type { Snippet } from 'svelte';
16
16
  import { scaleBand, scaleLinear } from 'd3-scale';
17
17
  import { max, min } from 'd3-array';
18
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
18
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
19
19
  import type { ChartEmbed } from '../embed/index.js';
20
20
  import { Plot, Svg, estimateTextWidth, type PlotContext } from '../core/index.js';
21
21
  import { AxisX, GridX, Legend } from '../guides/index.js';
@@ -68,7 +68,8 @@ your project and change anything.
68
68
  title?: string;
69
69
  subtitle?: string;
70
70
  notes?: string;
71
- source?: string;
71
+ /** Plain text, or sources with optional links (see `<Source>`). */
72
+ source?: string | SourceItem[];
72
73
  alt?: string;
73
74
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
74
75
  embed?: ChartEmbed;
@@ -343,7 +344,7 @@ your project and change anything.
343
344
  {#if notes || source}
344
345
  <Footer>
345
346
  {#if notes}<Notes>{notes}</Notes>{/if}
346
- {#if source}<Source>{source}</Source>{/if}
347
+ {#if source}<Source sources={source} />{/if}
347
348
  </Footer>
348
349
  {/if}
349
350
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type PercentileRank } from '../transforms/index.js';
@@ -50,7 +51,8 @@ declare function $$render<T>(): {
50
51
  title?: string;
51
52
  subtitle?: string;
52
53
  notes?: string;
53
- source?: string;
54
+ /** Plain text, or sources with optional links (see `<Source>`). */
55
+ source?: string | SourceItem[];
54
56
  alt?: string;
55
57
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
56
58
  embed?: ChartEmbed;
@@ -8,7 +8,7 @@ copies this file into your project.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleLinear, scaleSqrt } from 'd3-scale';
10
10
  import { extent, max } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, type PlotContext } from '../core/index.js';
14
14
  import { Points, Voronoi } from '../marks/index.js';
@@ -37,7 +37,8 @@ copies this file into your project.
37
37
  title?: string;
38
38
  subtitle?: string;
39
39
  notes?: string;
40
- source?: string;
40
+ /** Plain text, or sources with optional links (see `<Source>`). */
41
+ source?: string | SourceItem[];
41
42
  alt?: string;
42
43
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
43
44
  embed?: ChartEmbed;
@@ -161,7 +162,7 @@ copies this file into your project.
161
162
  {#if notes || source}
162
163
  <Footer>
163
164
  {#if notes}<Notes>{notes}</Notes>{/if}
164
- {#if source}<Source>{source}</Source>{/if}
165
+ {#if source}<Source sources={source} />{/if}
165
166
  </Footer>
166
167
  {/if}
167
168
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -23,7 +24,8 @@ declare function $$render<T>(): {
23
24
  title?: string;
24
25
  subtitle?: string;
25
26
  notes?: string;
26
- source?: string;
27
+ /** Plain text, or sources with optional links (see `<Source>`). */
28
+ source?: string | SourceItem[];
27
29
  alt?: string;
28
30
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
29
31
  embed?: ChartEmbed;
@@ -13,7 +13,7 @@ your project and change anything.
13
13
  <script lang="ts" generics="T">
14
14
  import type { Snippet } from 'svelte';
15
15
  import { scaleBand, scaleLinear } from 'd3-scale';
16
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
16
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
17
17
  import type { ChartEmbed } from '../embed/index.js';
18
18
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
19
19
  import { Rects } from '../marks/index.js';
@@ -59,7 +59,8 @@ your project and change anything.
59
59
  title?: string;
60
60
  subtitle?: string;
61
61
  notes?: string;
62
- source?: string;
62
+ /** Plain text, or sources with optional links (see `<Source>`). */
63
+ source?: string | SourceItem[];
63
64
  alt?: string;
64
65
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
65
66
  embed?: ChartEmbed;
@@ -243,7 +244,7 @@ your project and change anything.
243
244
  {#if notes || source}
244
245
  <Footer>
245
246
  {#if notes}<Notes>{notes}</Notes>{/if}
246
- {#if source}<Source>{source}</Source>{/if}
247
+ {#if source}<Source sources={source} />{/if}
247
248
  </Footer>
248
249
  {/if}
249
250
  </Chart>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type SourceItem } from '../frame/index.js';
2
3
  import type { ChartEmbed } from '../embed/index.js';
3
4
  import { type PlotContext } from '../core/index.js';
4
5
  import { type LocaleCode } from '../locale/index.js';
@@ -40,7 +41,8 @@ declare function $$render<T>(): {
40
41
  title?: string;
41
42
  subtitle?: string;
42
43
  notes?: string;
43
- source?: string;
44
+ /** Plain text, or sources with optional links (see `<Source>`). */
45
+ source?: string | SourceItem[];
44
46
  alt?: string;
45
47
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
46
48
  embed?: ChartEmbed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samizdata/mozaic",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Chart components for the web and print, built on Svelte 5 and d3.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Nicu Calcea",
@@ -11,7 +11,7 @@ project and change anything.
11
11
  import type { Snippet } from 'svelte';
12
12
  import { scaleBand, scaleLinear } from 'd3-scale';
13
13
  import { max, min } from 'd3-array';
14
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
14
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
15
15
  import type { ChartEmbed } from '../embed/index.js';
16
16
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
17
17
  import { Arrows } from '../marks/index.js';
@@ -38,7 +38,8 @@ project and change anything.
38
38
  title?: string;
39
39
  subtitle?: string;
40
40
  notes?: string;
41
- source?: string;
41
+ /** Plain text, or sources with optional links (see `<Source>`). */
42
+ source?: string | SourceItem[];
42
43
  alt?: string;
43
44
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
44
45
  embed?: ChartEmbed;
@@ -215,7 +216,7 @@ project and change anything.
215
216
  {#if notes || source}
216
217
  <Footer>
217
218
  {#if notes}<Notes>{notes}</Notes>{/if}
218
- {#if source}<Source>{source}</Source>{/if}
219
+ {#if source}<Source sources={source} />{/if}
219
220
  </Footer>
220
221
  {/if}
221
222
  </Chart>
@@ -8,7 +8,7 @@ file into your project and change anything.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleBand, scaleLinear } from 'd3-scale';
10
10
  import { max, min } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
14
14
  import { Bars, Rules, Text } from '../marks/index.js';
@@ -28,7 +28,8 @@ file into your project and change anything.
28
28
  title?: string;
29
29
  subtitle?: string;
30
30
  notes?: string;
31
- source?: string;
31
+ /** Plain text, or sources with optional links (see `<Source>`). */
32
+ source?: string | SourceItem[];
32
33
  alt?: string;
33
34
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
34
35
  embed?: ChartEmbed;
@@ -116,7 +117,7 @@ file into your project and change anything.
116
117
  {#if notes || source}
117
118
  <Footer>
118
119
  {#if notes}<Notes>{notes}</Notes>{/if}
119
- {#if source}<Source>{source}</Source>{/if}
120
+ {#if source}<Source sources={source} />{/if}
120
121
  </Footer>
121
122
  {/if}
122
123
  </Chart>
@@ -11,7 +11,7 @@ anything.
11
11
  import type { Snippet } from 'svelte';
12
12
  import { scaleBand, scaleLinear } from 'd3-scale';
13
13
  import { max, min } from 'd3-array';
14
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
14
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
15
15
  import type { ChartEmbed } from '../embed/index.js';
16
16
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
17
17
  import { Bars, Points } from '../marks/index.js';
@@ -38,7 +38,8 @@ anything.
38
38
  title?: string;
39
39
  subtitle?: string;
40
40
  notes?: string;
41
- source?: string;
41
+ /** Plain text, or sources with optional links (see `<Source>`). */
42
+ source?: string | SourceItem[];
42
43
  alt?: string;
43
44
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
44
45
  embed?: ChartEmbed;
@@ -178,7 +179,7 @@ anything.
178
179
  {#if notes || source}
179
180
  <Footer>
180
181
  {#if notes}<Notes>{notes}</Notes>{/if}
181
- {#if source}<Source>{source}</Source>{/if}
182
+ {#if source}<Source sources={source} />{/if}
182
183
  </Footer>
183
184
  {/if}
184
185
  </Chart>
@@ -8,7 +8,7 @@ copies this file into your project.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleBand, scaleLinear } from 'd3-scale';
10
10
  import { max, min } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, scaled, type PlotContext } from '../core/index.js';
14
14
  import { Bars, Rules } from '../marks/index.js';
@@ -29,7 +29,8 @@ copies this file into your project.
29
29
  title?: string;
30
30
  subtitle?: string;
31
31
  notes?: string;
32
- source?: string;
32
+ /** Plain text, or sources with optional links (see `<Source>`). */
33
+ source?: string | SourceItem[];
33
34
  alt?: string;
34
35
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
35
36
  embed?: ChartEmbed;
@@ -113,7 +114,7 @@ copies this file into your project.
113
114
  {#if notes || source}
114
115
  <Footer>
115
116
  {#if notes}<Notes>{notes}</Notes>{/if}
116
- {#if source}<Source>{source}</Source>{/if}
117
+ {#if source}<Source sources={source} />{/if}
117
118
  </Footer>
118
119
  {/if}
119
120
  </Chart>
@@ -10,7 +10,7 @@ project.
10
10
  import { scaleLinear, scaleTime } from 'd3-scale';
11
11
  import { bisector, extent, max, min } from 'd3-array';
12
12
  import { curveMonotoneX } from 'd3-shape';
13
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
13
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
14
14
  import type { ChartEmbed } from '../embed/index.js';
15
15
  import { Plot, Svg, Html, type PlotContext } from '../core/index.js';
16
16
  import { Line, LineEndLabels } from '../marks/index.js';
@@ -33,7 +33,8 @@ project.
33
33
  title?: string;
34
34
  subtitle?: string;
35
35
  notes?: string;
36
- source?: string;
36
+ /** Plain text, or sources with optional links (see `<Source>`). */
37
+ source?: string | SourceItem[];
37
38
  alt?: string;
38
39
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
39
40
  embed?: ChartEmbed;
@@ -153,7 +154,7 @@ project.
153
154
  {#if notes || source}
154
155
  <Footer>
155
156
  {#if notes}<Notes>{notes}</Notes>{/if}
156
- {#if source}<Source>{source}</Source>{/if}
157
+ {#if source}<Source sources={source} />{/if}
157
158
  </Footer>
158
159
  {/if}
159
160
  </Chart>
@@ -13,7 +13,7 @@ project and change anything.
13
13
  import type { Snippet } from 'svelte';
14
14
  import { scaleLinear } from 'd3-scale';
15
15
  import { group, sum } from 'd3-array';
16
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
16
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
17
17
  import type { ChartEmbed } from '../embed/index.js';
18
18
  import { Plot, Svg, estimateTextWidth, type PlotContext } from '../core/index.js';
19
19
  import { Rects } from '../marks/index.js';
@@ -51,7 +51,8 @@ project and change anything.
51
51
  title?: string;
52
52
  subtitle?: string;
53
53
  notes?: string;
54
- source?: string;
54
+ /** Plain text, or sources with optional links (see `<Source>`). */
55
+ source?: string | SourceItem[];
55
56
  alt?: string;
56
57
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
57
58
  embed?: ChartEmbed;
@@ -232,7 +233,7 @@ project and change anything.
232
233
  {#if notes || source}
233
234
  <Footer>
234
235
  {#if notes}<Notes>{notes}</Notes>{/if}
235
- {#if source}<Source>{source}</Source>{/if}
236
+ {#if source}<Source sources={source} />{/if}
236
237
  </Footer>
237
238
  {/if}
238
239
  </Chart>
@@ -15,7 +15,7 @@ your project and change anything.
15
15
  import type { Snippet } from 'svelte';
16
16
  import { scaleBand, scaleLinear } from 'd3-scale';
17
17
  import { max, min } from 'd3-array';
18
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
18
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
19
19
  import type { ChartEmbed } from '../embed/index.js';
20
20
  import { Plot, Svg, estimateTextWidth, type PlotContext } from '../core/index.js';
21
21
  import { AxisX, GridX, Legend } from '../guides/index.js';
@@ -68,7 +68,8 @@ your project and change anything.
68
68
  title?: string;
69
69
  subtitle?: string;
70
70
  notes?: string;
71
- source?: string;
71
+ /** Plain text, or sources with optional links (see `<Source>`). */
72
+ source?: string | SourceItem[];
72
73
  alt?: string;
73
74
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
74
75
  embed?: ChartEmbed;
@@ -343,7 +344,7 @@ your project and change anything.
343
344
  {#if notes || source}
344
345
  <Footer>
345
346
  {#if notes}<Notes>{notes}</Notes>{/if}
346
- {#if source}<Source>{source}</Source>{/if}
347
+ {#if source}<Source sources={source} />{/if}
347
348
  </Footer>
348
349
  {/if}
349
350
  </Chart>
@@ -8,7 +8,7 @@ copies this file into your project.
8
8
  import type { Snippet } from 'svelte';
9
9
  import { scaleLinear, scaleSqrt } from 'd3-scale';
10
10
  import { extent, max } from 'd3-array';
11
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
11
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
12
12
  import type { ChartEmbed } from '../embed/index.js';
13
13
  import { Plot, Svg, Html, type PlotContext } from '../core/index.js';
14
14
  import { Points, Voronoi } from '../marks/index.js';
@@ -37,7 +37,8 @@ copies this file into your project.
37
37
  title?: string;
38
38
  subtitle?: string;
39
39
  notes?: string;
40
- source?: string;
40
+ /** Plain text, or sources with optional links (see `<Source>`). */
41
+ source?: string | SourceItem[];
41
42
  alt?: string;
42
43
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
43
44
  embed?: ChartEmbed;
@@ -161,7 +162,7 @@ copies this file into your project.
161
162
  {#if notes || source}
162
163
  <Footer>
163
164
  {#if notes}<Notes>{notes}</Notes>{/if}
164
- {#if source}<Source>{source}</Source>{/if}
165
+ {#if source}<Source sources={source} />{/if}
165
166
  </Footer>
166
167
  {/if}
167
168
  </Chart>
@@ -13,7 +13,7 @@ your project and change anything.
13
13
  <script lang="ts" generics="T">
14
14
  import type { Snippet } from 'svelte';
15
15
  import { scaleBand, scaleLinear } from 'd3-scale';
16
- import { Chart, Header, Title, Subtitle, Footer, Source, Notes } from '../frame/index.js';
16
+ import { Chart, Header, Title, Subtitle, Footer, Source, Notes, type SourceItem } from '../frame/index.js';
17
17
  import type { ChartEmbed } from '../embed/index.js';
18
18
  import { Plot, Svg, estimateTextWidth, scaled, type PlotContext } from '../core/index.js';
19
19
  import { Rects } from '../marks/index.js';
@@ -59,7 +59,8 @@ your project and change anything.
59
59
  title?: string;
60
60
  subtitle?: string;
61
61
  notes?: string;
62
- source?: string;
62
+ /** Plain text, or sources with optional links (see `<Source>`). */
63
+ source?: string | SourceItem[];
63
64
  alt?: string;
64
65
  /** The chart's embed page, for the embed code under the chart (see `<Chart embed>`). */
65
66
  embed?: ChartEmbed;
@@ -243,7 +244,7 @@ your project and change anything.
243
244
  {#if notes || source}
244
245
  <Footer>
245
246
  {#if notes}<Notes>{notes}</Notes>{/if}
246
- {#if source}<Source>{source}</Source>{/if}
247
+ {#if source}<Source sources={source} />{/if}
247
248
  </Footer>
248
249
  {/if}
249
250
  </Chart>