@datocms/svelte 0.0.1

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/components/Head/Head.svelte +14 -0
  4. package/components/Head/Head.svelte.d.ts +61 -0
  5. package/components/Head/README.md +68 -0
  6. package/components/Head/__tests__/Head.test.d.ts +1 -0
  7. package/components/Head/__tests__/Head.test.js +11 -0
  8. package/components/Head/__tests__/__fixtures__/head.d.ts +2 -0
  9. package/components/Head/__tests__/__fixtures__/head.js +280 -0
  10. package/components/Head/__tests__/__snapshots__/Head.test.ts.snap +221 -0
  11. package/components/Image/Image.svelte +172 -0
  12. package/components/Image/Image.svelte.d.ts +83 -0
  13. package/components/Image/Placeholder.svelte +31 -0
  14. package/components/Image/Placeholder.svelte.d.ts +22 -0
  15. package/components/Image/README.md +167 -0
  16. package/components/Image/Sizer.svelte +17 -0
  17. package/components/Image/Sizer.svelte.d.ts +19 -0
  18. package/components/Image/Source.svelte +6 -0
  19. package/components/Image/Source.svelte.d.ts +18 -0
  20. package/components/Image/__tests__/Image.svelte.test.d.ts +1 -0
  21. package/components/Image/__tests__/Image.svelte.test.js +44 -0
  22. package/components/Image/__tests__/__fixtures__/image.d.ts +40 -0
  23. package/components/Image/__tests__/__fixtures__/image.js +40 -0
  24. package/components/Image/__tests__/__snapshots__/Image.svelte.test.ts.snap +927 -0
  25. package/components/StructuredText/Node.svelte +112 -0
  26. package/components/StructuredText/Node.svelte.d.ts +22 -0
  27. package/components/StructuredText/README.md +201 -0
  28. package/components/StructuredText/StructuredText.svelte +15 -0
  29. package/components/StructuredText/StructuredText.svelte.d.ts +19 -0
  30. package/components/StructuredText/__tests__/StructuredText.svelte.test.d.ts +1 -0
  31. package/components/StructuredText/__tests__/StructuredText.svelte.test.js +163 -0
  32. package/components/StructuredText/__tests__/__fixtures__/Block.svelte +11 -0
  33. package/components/StructuredText/__tests__/__fixtures__/Block.svelte.d.ts +19 -0
  34. package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte +49 -0
  35. package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte.d.ts +19 -0
  36. package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte +8 -0
  37. package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte.d.ts +19 -0
  38. package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte +8 -0
  39. package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte.d.ts +19 -0
  40. package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte +15 -0
  41. package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte.d.ts +21 -0
  42. package/components/StructuredText/__tests__/__fixtures__/structuredText.d.ts +6 -0
  43. package/components/StructuredText/__tests__/__fixtures__/structuredText.js +537 -0
  44. package/components/StructuredText/__tests__/__fixtures__/types.d.ts +27 -0
  45. package/components/StructuredText/__tests__/__fixtures__/types.js +1 -0
  46. package/components/StructuredText/__tests__/__snapshots__/StructuredText.svelte.test.ts.snap +463 -0
  47. package/components/StructuredText/nodes/Blockquote.svelte +5 -0
  48. package/components/StructuredText/nodes/Blockquote.svelte.d.ts +19 -0
  49. package/components/StructuredText/nodes/Code.svelte +6 -0
  50. package/components/StructuredText/nodes/Code.svelte.d.ts +17 -0
  51. package/components/StructuredText/nodes/Heading.svelte +8 -0
  52. package/components/StructuredText/nodes/Heading.svelte.d.ts +19 -0
  53. package/components/StructuredText/nodes/Link.svelte +6 -0
  54. package/components/StructuredText/nodes/Link.svelte.d.ts +19 -0
  55. package/components/StructuredText/nodes/List.svelte +10 -0
  56. package/components/StructuredText/nodes/List.svelte.d.ts +19 -0
  57. package/components/StructuredText/nodes/ListItem.svelte +5 -0
  58. package/components/StructuredText/nodes/ListItem.svelte.d.ts +19 -0
  59. package/components/StructuredText/nodes/Paragraph.svelte +5 -0
  60. package/components/StructuredText/nodes/Paragraph.svelte.d.ts +19 -0
  61. package/components/StructuredText/nodes/Root.svelte +5 -0
  62. package/components/StructuredText/nodes/Root.svelte.d.ts +19 -0
  63. package/components/StructuredText/nodes/Span.svelte +49 -0
  64. package/components/StructuredText/nodes/Span.svelte.d.ts +19 -0
  65. package/components/StructuredText/nodes/ThematicBreak.svelte +5 -0
  66. package/components/StructuredText/nodes/ThematicBreak.svelte.d.ts +17 -0
  67. package/components/StructuredText/utils/Lines.svelte +11 -0
  68. package/components/StructuredText/utils/Lines.svelte.d.ts +16 -0
  69. package/index.d.ts +9 -0
  70. package/index.js +3 -0
  71. package/package.json +61 -0
@@ -0,0 +1,463 @@
1
+ // Vitest Snapshot v1
2
+
3
+ exports[`StructuredText > with a dast including links and blocks > with default rules > renders the document 1`] = `
4
+ <body>
5
+ <div>
6
+ <h1>
7
+ This is a
8
+
9
+
10
+ <!--&lt;Lines&gt;-->
11
+
12
+ <!--&lt;Span&gt;-->
13
+
14
+
15
+
16
+ <!--&lt;Node&gt;-->
17
+ <mark>
18
+ title
19
+
20
+
21
+ <!--&lt;Lines&gt;-->
22
+
23
+ <!--&lt;Span&gt;-->
24
+ </mark>
25
+
26
+
27
+ <!--&lt;Span&gt;-->
28
+
29
+
30
+
31
+ <!--&lt;Node&gt;-->
32
+ <a
33
+ href="/docs/how-to-code"
34
+ >
35
+ How to code
36
+ </a>
37
+ ;
38
+
39
+ <!--&lt;InlineItem&gt;-->
40
+
41
+
42
+
43
+ <!--&lt;Node&gt;-->
44
+ <a
45
+ href="/docs/how-to-code"
46
+ target="_blank"
47
+ >
48
+ here!
49
+
50
+
51
+ <!--&lt;Lines&gt;-->
52
+
53
+ <!--&lt;Span&gt;-->
54
+
55
+
56
+
57
+ <!--&lt;Node&gt;-->
58
+
59
+
60
+ </a>
61
+
62
+ <!--&lt;ItemLink&gt;-->
63
+
64
+
65
+
66
+ <!--&lt;Node&gt;-->
67
+
68
+
69
+ </h1>
70
+
71
+ <!--&lt;Heading&gt;-->
72
+
73
+
74
+
75
+ <!--&lt;Node&gt;-->
76
+ <figure>
77
+ <blockquote>
78
+ Foo bar.
79
+ </blockquote>
80
+
81
+ <figcaption>
82
+ Mark Smith
83
+ </figcaption>
84
+ </figure>
85
+
86
+ <!--&lt;Block&gt;-->
87
+
88
+
89
+
90
+ <!--&lt;Node&gt;-->
91
+
92
+
93
+ <!--&lt;Root&gt;-->
94
+
95
+
96
+
97
+ <!--&lt;Node&gt;-->
98
+
99
+ <!--&lt;StructuredText&gt;-->
100
+ </div>
101
+ </body>
102
+ `;
103
+
104
+ exports[`StructuredText > with a dast including links and blocks > with missing blocks > raises an error 1`] = `"The Structured Text document contains a 'block' node, but cannot find a record with ID 456 inside data.blocks!"`;
105
+
106
+ exports[`StructuredText > with a dast including links and blocks > with missing component for blocks > raises an error 1`] = `"The Structured Text document contains a 'block' node, but no component for rendering is specified!"`;
107
+
108
+ exports[`StructuredText > with a dast including links and blocks > with missing component for inline items > raises an error 1`] = `"The Structured Text document contains an 'inlineItem' node, but no component for rendering is specified!"`;
109
+
110
+ exports[`StructuredText > with a dast including links and blocks > with missing component for item links > raises an error 1`] = `"The Structured Text document contains an 'itemLink' node, but no component for rendering is specified!"`;
111
+
112
+ exports[`StructuredText > with a dast including links and blocks > with missing links > raises an error 1`] = `"The Structured Text document contains an 'itemLink' node, but cannot find a record with ID 123 inside data.links!"`;
113
+
114
+ exports[`StructuredText > with a dast with no links nor blocks > with custom rules > renders the document 1`] = `
115
+ <body>
116
+ <div>
117
+ <h2>
118
+ This
119
+
120
+ <br />
121
+
122
+ is a
123
+
124
+
125
+ <!--&lt;Lines&gt;-->
126
+
127
+ <!--&lt;Lines&gt;-->
128
+
129
+ <!--&lt;Span&gt;-->
130
+
131
+
132
+
133
+ <!--&lt;Node&gt;-->
134
+ <strong>
135
+ title
136
+
137
+
138
+ <!--&lt;Lines&gt;-->
139
+
140
+ <!--&lt;Span&gt;-->
141
+ </strong>
142
+
143
+
144
+ <!--&lt;Span&gt;-->
145
+
146
+
147
+
148
+ <!--&lt;Node&gt;-->
149
+
150
+
151
+ </h2>
152
+
153
+ <!--&lt;IncreasedLevelHeading&gt;-->
154
+
155
+
156
+
157
+ <!--&lt;Node&gt;-->
158
+
159
+
160
+ <!--&lt;Root&gt;-->
161
+
162
+
163
+
164
+ <!--&lt;Node&gt;-->
165
+
166
+ <!--&lt;StructuredText&gt;-->
167
+ </div>
168
+ </body>
169
+ `;
170
+
171
+ exports[`StructuredText > with a dast with no links nor blocks > with default rules > renders the document 1`] = `
172
+ <body>
173
+ <div>
174
+ <h1>
175
+ This
176
+
177
+ <br />
178
+
179
+ is a
180
+
181
+
182
+ <!--&lt;Lines&gt;-->
183
+
184
+ <!--&lt;Lines&gt;-->
185
+
186
+ <!--&lt;Span&gt;-->
187
+
188
+
189
+
190
+ <!--&lt;Node&gt;-->
191
+ <strong>
192
+ title
193
+
194
+
195
+ <!--&lt;Lines&gt;-->
196
+
197
+ <!--&lt;Span&gt;-->
198
+ </strong>
199
+
200
+
201
+ <!--&lt;Span&gt;-->
202
+
203
+
204
+
205
+ <!--&lt;Node&gt;-->
206
+
207
+
208
+ </h1>
209
+
210
+ <!--&lt;Heading&gt;-->
211
+
212
+
213
+
214
+ <!--&lt;Node&gt;-->
215
+
216
+
217
+ <!--&lt;Root&gt;-->
218
+
219
+
220
+
221
+ <!--&lt;Node&gt;-->
222
+
223
+ <!--&lt;StructuredText&gt;-->
224
+ </div>
225
+ </body>
226
+ `;
227
+
228
+ exports[`StructuredText > with a very simple dast > with custom mark rules > renders the document 1`] = `
229
+ <body>
230
+ <div>
231
+ <h1>
232
+ This
233
+
234
+ <br />
235
+
236
+ is a
237
+
238
+
239
+ <!--&lt;Lines&gt;-->
240
+
241
+ <!--&lt;Lines&gt;-->
242
+
243
+ <!--&lt;CustomSpan&gt;-->
244
+
245
+
246
+
247
+ <!--&lt;Node&gt;-->
248
+ <b>
249
+ title
250
+
251
+
252
+ <!--&lt;Lines&gt;-->
253
+
254
+ <!--&lt;CustomSpan&gt;-->
255
+ </b>
256
+
257
+
258
+ <!--&lt;CustomSpan&gt;-->
259
+
260
+
261
+
262
+ <!--&lt;Node&gt;-->
263
+
264
+
265
+ </h1>
266
+
267
+ <!--&lt;Heading&gt;-->
268
+
269
+
270
+
271
+ <!--&lt;Node&gt;-->
272
+
273
+
274
+ <!--&lt;Root&gt;-->
275
+
276
+
277
+
278
+ <!--&lt;Node&gt;-->
279
+
280
+ <!--&lt;StructuredText&gt;-->
281
+ </div>
282
+ </body>
283
+ `;
284
+
285
+ exports[`StructuredText > with a very simple dast > with default rules > renders the document 1`] = `
286
+ <body>
287
+ <div>
288
+ <h1>
289
+ This
290
+
291
+ <br />
292
+
293
+ is a
294
+
295
+
296
+ <!--&lt;Lines&gt;-->
297
+
298
+ <!--&lt;Lines&gt;-->
299
+
300
+ <!--&lt;Span&gt;-->
301
+
302
+
303
+
304
+ <!--&lt;Node&gt;-->
305
+ <strong>
306
+ title
307
+
308
+
309
+ <!--&lt;Lines&gt;-->
310
+
311
+ <!--&lt;Span&gt;-->
312
+ </strong>
313
+
314
+
315
+ <!--&lt;Span&gt;-->
316
+
317
+
318
+
319
+ <!--&lt;Node&gt;-->
320
+
321
+
322
+ </h1>
323
+
324
+ <!--&lt;Heading&gt;-->
325
+
326
+
327
+
328
+ <!--&lt;Node&gt;-->
329
+
330
+
331
+ <!--&lt;Root&gt;-->
332
+
333
+
334
+
335
+ <!--&lt;Node&gt;-->
336
+
337
+ <!--&lt;StructuredText&gt;-->
338
+ </div>
339
+ </body>
340
+ `;
341
+
342
+ exports[`StructuredText > with a very simple pure dast (only the \`value\` of a structured text) > with custom mark rules > renders the document 1`] = `
343
+ <body>
344
+ <div>
345
+ <h1>
346
+ This
347
+
348
+ <br />
349
+
350
+ is a
351
+
352
+
353
+ <!--&lt;Lines&gt;-->
354
+
355
+ <!--&lt;Lines&gt;-->
356
+
357
+ <!--&lt;CustomSpan&gt;-->
358
+
359
+
360
+
361
+ <!--&lt;Node&gt;-->
362
+ <b>
363
+ title
364
+
365
+
366
+ <!--&lt;Lines&gt;-->
367
+
368
+ <!--&lt;CustomSpan&gt;-->
369
+ </b>
370
+
371
+
372
+ <!--&lt;CustomSpan&gt;-->
373
+
374
+
375
+
376
+ <!--&lt;Node&gt;-->
377
+
378
+
379
+ </h1>
380
+
381
+ <!--&lt;Heading&gt;-->
382
+
383
+
384
+
385
+ <!--&lt;Node&gt;-->
386
+
387
+
388
+ <!--&lt;Root&gt;-->
389
+
390
+
391
+
392
+ <!--&lt;Node&gt;-->
393
+
394
+ <!--&lt;StructuredText&gt;-->
395
+ </div>
396
+ </body>
397
+ `;
398
+
399
+ exports[`StructuredText > with a very simple pure dast (only the \`value\` of a structured text) > with default rules > renders the document 1`] = `
400
+ <body>
401
+ <div>
402
+ <h1>
403
+ This
404
+
405
+ <br />
406
+
407
+ is a
408
+
409
+
410
+ <!--&lt;Lines&gt;-->
411
+
412
+ <!--&lt;Lines&gt;-->
413
+
414
+ <!--&lt;Span&gt;-->
415
+
416
+
417
+
418
+ <!--&lt;Node&gt;-->
419
+ <strong>
420
+ title
421
+
422
+
423
+ <!--&lt;Lines&gt;-->
424
+
425
+ <!--&lt;Span&gt;-->
426
+ </strong>
427
+
428
+
429
+ <!--&lt;Span&gt;-->
430
+
431
+
432
+
433
+ <!--&lt;Node&gt;-->
434
+
435
+
436
+ </h1>
437
+
438
+ <!--&lt;Heading&gt;-->
439
+
440
+
441
+
442
+ <!--&lt;Node&gt;-->
443
+
444
+
445
+ <!--&lt;Root&gt;-->
446
+
447
+
448
+
449
+ <!--&lt;Node&gt;-->
450
+
451
+ <!--&lt;StructuredText&gt;-->
452
+ </div>
453
+ </body>
454
+ `;
455
+
456
+ exports[`StructuredText > with no value > renders null 1`] = `
457
+ <body>
458
+ <div>
459
+
460
+ <!--&lt;StructuredText&gt;-->
461
+ </div>
462
+ </body>
463
+ `;
@@ -0,0 +1,5 @@
1
+ <script>export let node;
2
+ node;
3
+ </script>
4
+
5
+ <blockquote><slot /></blockquote>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Blockquote } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Blockquote;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type BlockquoteProps = typeof __propDef.props;
15
+ export type BlockquoteEvents = typeof __propDef.events;
16
+ export type BlockquoteSlots = typeof __propDef.slots;
17
+ export default class Blockquote extends SvelteComponentTyped<BlockquoteProps, BlockquoteEvents, BlockquoteSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,6 @@
1
+ <script>export let node;
2
+ $:
3
+ ({ code, language } = node);
4
+ </script>
5
+
6
+ <pre class={language}>{code}</pre>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Code } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Code;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type CodeProps = typeof __propDef.props;
13
+ export type CodeEvents = typeof __propDef.events;
14
+ export type CodeSlots = typeof __propDef.slots;
15
+ export default class Code extends SvelteComponentTyped<CodeProps, CodeEvents, CodeSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,8 @@
1
+ <script>export let node;
2
+ $:
3
+ ({ level = 1 } = node);
4
+ $:
5
+ element = `h${level}`;
6
+ </script>
7
+
8
+ <svelte:element this={element}><slot /></svelte:element>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Heading } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Heading;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type HeadingProps = typeof __propDef.props;
15
+ export type HeadingEvents = typeof __propDef.events;
16
+ export type HeadingSlots = typeof __propDef.slots;
17
+ export default class Heading extends SvelteComponentTyped<HeadingProps, HeadingEvents, HeadingSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,6 @@
1
+ <script>export let node;
2
+ $:
3
+ ({ url } = node);
4
+ </script>
5
+
6
+ <a href={url}><slot /></a>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Link } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Link;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type LinkProps = typeof __propDef.props;
15
+ export type LinkEvents = typeof __propDef.events;
16
+ export type LinkSlots = typeof __propDef.slots;
17
+ export default class Link extends SvelteComponentTyped<LinkProps, LinkEvents, LinkSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,10 @@
1
+ <script>export let node;
2
+ $:
3
+ ({ style } = node);
4
+ </script>
5
+
6
+ {#if style === 'numbered'}
7
+ <ol><slot /></ol>
8
+ {:else}
9
+ <ul><slot /></ul>
10
+ {/if}
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { List } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: List;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type ListProps = typeof __propDef.props;
15
+ export type ListEvents = typeof __propDef.events;
16
+ export type ListSlots = typeof __propDef.slots;
17
+ export default class List extends SvelteComponentTyped<ListProps, ListEvents, ListSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,5 @@
1
+ <script>export let node;
2
+ node;
3
+ </script>
4
+
5
+ <li><slot /></li>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ListItem } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: ListItem;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type ListItemProps = typeof __propDef.props;
15
+ export type ListItemEvents = typeof __propDef.events;
16
+ export type ListItemSlots = typeof __propDef.slots;
17
+ export default class ListItem extends SvelteComponentTyped<ListItemProps, ListItemEvents, ListItemSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,5 @@
1
+ <script>export let node;
2
+ node;
3
+ </script>
4
+
5
+ <p><slot /></p>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Paragraph } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Paragraph;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type ParagraphProps = typeof __propDef.props;
15
+ export type ParagraphEvents = typeof __propDef.events;
16
+ export type ParagraphSlots = typeof __propDef.slots;
17
+ export default class Paragraph extends SvelteComponentTyped<ParagraphProps, ParagraphEvents, ParagraphSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,5 @@
1
+ <script>export let node;
2
+ node;
3
+ </script>
4
+
5
+ <slot />
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Root } from 'datocms-structured-text-utils';
3
+ declare const __propDef: {
4
+ props: {
5
+ node: Root;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {
11
+ default: {};
12
+ };
13
+ };
14
+ export type RootProps = typeof __propDef.props;
15
+ export type RootEvents = typeof __propDef.events;
16
+ export type RootSlots = typeof __propDef.slots;
17
+ export default class Root extends SvelteComponentTyped<RootProps, RootEvents, RootSlots> {
18
+ }
19
+ export {};