@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.
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/components/Head/Head.svelte +14 -0
- package/components/Head/Head.svelte.d.ts +61 -0
- package/components/Head/README.md +68 -0
- package/components/Head/__tests__/Head.test.d.ts +1 -0
- package/components/Head/__tests__/Head.test.js +11 -0
- package/components/Head/__tests__/__fixtures__/head.d.ts +2 -0
- package/components/Head/__tests__/__fixtures__/head.js +280 -0
- package/components/Head/__tests__/__snapshots__/Head.test.ts.snap +221 -0
- package/components/Image/Image.svelte +172 -0
- package/components/Image/Image.svelte.d.ts +83 -0
- package/components/Image/Placeholder.svelte +31 -0
- package/components/Image/Placeholder.svelte.d.ts +22 -0
- package/components/Image/README.md +167 -0
- package/components/Image/Sizer.svelte +17 -0
- package/components/Image/Sizer.svelte.d.ts +19 -0
- package/components/Image/Source.svelte +6 -0
- package/components/Image/Source.svelte.d.ts +18 -0
- package/components/Image/__tests__/Image.svelte.test.d.ts +1 -0
- package/components/Image/__tests__/Image.svelte.test.js +44 -0
- package/components/Image/__tests__/__fixtures__/image.d.ts +40 -0
- package/components/Image/__tests__/__fixtures__/image.js +40 -0
- package/components/Image/__tests__/__snapshots__/Image.svelte.test.ts.snap +927 -0
- package/components/StructuredText/Node.svelte +112 -0
- package/components/StructuredText/Node.svelte.d.ts +22 -0
- package/components/StructuredText/README.md +201 -0
- package/components/StructuredText/StructuredText.svelte +15 -0
- package/components/StructuredText/StructuredText.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/StructuredText.svelte.test.d.ts +1 -0
- package/components/StructuredText/__tests__/StructuredText.svelte.test.js +163 -0
- package/components/StructuredText/__tests__/__fixtures__/Block.svelte +11 -0
- package/components/StructuredText/__tests__/__fixtures__/Block.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte +49 -0
- package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte +8 -0
- package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte +8 -0
- package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte +15 -0
- package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte.d.ts +21 -0
- package/components/StructuredText/__tests__/__fixtures__/structuredText.d.ts +6 -0
- package/components/StructuredText/__tests__/__fixtures__/structuredText.js +537 -0
- package/components/StructuredText/__tests__/__fixtures__/types.d.ts +27 -0
- package/components/StructuredText/__tests__/__fixtures__/types.js +1 -0
- package/components/StructuredText/__tests__/__snapshots__/StructuredText.svelte.test.ts.snap +463 -0
- package/components/StructuredText/nodes/Blockquote.svelte +5 -0
- package/components/StructuredText/nodes/Blockquote.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Code.svelte +6 -0
- package/components/StructuredText/nodes/Code.svelte.d.ts +17 -0
- package/components/StructuredText/nodes/Heading.svelte +8 -0
- package/components/StructuredText/nodes/Heading.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Link.svelte +6 -0
- package/components/StructuredText/nodes/Link.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/List.svelte +10 -0
- package/components/StructuredText/nodes/List.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/ListItem.svelte +5 -0
- package/components/StructuredText/nodes/ListItem.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Paragraph.svelte +5 -0
- package/components/StructuredText/nodes/Paragraph.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Root.svelte +5 -0
- package/components/StructuredText/nodes/Root.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Span.svelte +49 -0
- package/components/StructuredText/nodes/Span.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/ThematicBreak.svelte +5 -0
- package/components/StructuredText/nodes/ThematicBreak.svelte.d.ts +17 -0
- package/components/StructuredText/utils/Lines.svelte +11 -0
- package/components/StructuredText/utils/Lines.svelte.d.ts +16 -0
- package/index.d.ts +9 -0
- package/index.js +3 -0
- package/package.json +61 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script>import Lines from "../utils/Lines.svelte";
|
|
2
|
+
export let node;
|
|
3
|
+
$:
|
|
4
|
+
({ type, value, marks } = node);
|
|
5
|
+
$:
|
|
6
|
+
[mark, ...otherMarks] = marks ?? [];
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if mark}
|
|
10
|
+
{#if mark === 'emphasis'}
|
|
11
|
+
<em>
|
|
12
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
13
|
+
<slot />
|
|
14
|
+
</svelte:self>
|
|
15
|
+
</em>
|
|
16
|
+
{:else if mark === 'highlight'}
|
|
17
|
+
<mark>
|
|
18
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
19
|
+
<slot />
|
|
20
|
+
</svelte:self>
|
|
21
|
+
</mark>
|
|
22
|
+
{:else if mark === 'strikethrough'}
|
|
23
|
+
<del>
|
|
24
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
25
|
+
<slot />
|
|
26
|
+
</svelte:self>
|
|
27
|
+
</del>
|
|
28
|
+
{:else if mark === 'strong'}
|
|
29
|
+
<strong>
|
|
30
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
31
|
+
<slot />
|
|
32
|
+
</svelte:self>
|
|
33
|
+
</strong>
|
|
34
|
+
{:else if mark === 'underline'}
|
|
35
|
+
<u>
|
|
36
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
37
|
+
<slot />
|
|
38
|
+
</svelte:self>
|
|
39
|
+
</u>
|
|
40
|
+
{:else if mark === 'code'}
|
|
41
|
+
<pre>
|
|
42
|
+
<svelte:self node={{ type, value, marks: otherMarks }}>
|
|
43
|
+
<slot />
|
|
44
|
+
</svelte:self>
|
|
45
|
+
</pre>
|
|
46
|
+
{/if}
|
|
47
|
+
{:else}
|
|
48
|
+
<Lines lines={node.value.split(/\n/)} />
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Span } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: Span;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type SpanProps = typeof __propDef.props;
|
|
15
|
+
export type SpanEvents = typeof __propDef.events;
|
|
16
|
+
export type SpanSlots = typeof __propDef.slots;
|
|
17
|
+
export default class Span extends SvelteComponentTyped<SpanProps, SpanEvents, SpanSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { ThematicBreak } from 'datocms-structured-text-utils';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
node: ThematicBreak;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type ThematicBreakProps = typeof __propDef.props;
|
|
13
|
+
export type ThematicBreakEvents = typeof __propDef.events;
|
|
14
|
+
export type ThematicBreakSlots = typeof __propDef.slots;
|
|
15
|
+
export default class ThematicBreak extends SvelteComponentTyped<ThematicBreakProps, ThematicBreakEvents, ThematicBreakSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
lines?: string[] | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type LinesProps = typeof __propDef.props;
|
|
12
|
+
export type LinesEvents = typeof __propDef.events;
|
|
13
|
+
export type LinesSlots = typeof __propDef.slots;
|
|
14
|
+
export default class Lines extends SvelteComponentTyped<LinesProps, LinesEvents, LinesSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Node } from 'datocms-structured-text-utils';
|
|
2
|
+
import type { SvelteComponentTyped } from 'svelte';
|
|
3
|
+
export { default as StructuredText } from './components/StructuredText/StructuredText.svelte';
|
|
4
|
+
export { default as Image } from './components/Image/Image.svelte';
|
|
5
|
+
export { default as Head } from './components/Head/Head.svelte';
|
|
6
|
+
export type PredicateComponentTuple = [
|
|
7
|
+
(n: Node) => boolean,
|
|
8
|
+
new (...any: any) => SvelteComponentTyped
|
|
9
|
+
];
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datocms/svelte",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"devDependencies": {
|
|
5
|
+
"@sveltejs/adapter-auto": "^1.0.0",
|
|
6
|
+
"@sveltejs/kit": "^1.0.0",
|
|
7
|
+
"@sveltejs/package": "^1.0.0",
|
|
8
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
9
|
+
"@testing-library/svelte": "^3.2.2",
|
|
10
|
+
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
11
|
+
"@typescript-eslint/parser": "^5.45.0",
|
|
12
|
+
"csstype": "^3.1.1",
|
|
13
|
+
"datocms-structured-text-generic-html-renderer": "^2.0.4",
|
|
14
|
+
"eslint": "^8.28.0",
|
|
15
|
+
"eslint-config-prettier": "^8.5.0",
|
|
16
|
+
"eslint-plugin-svelte3": "^4.0.0",
|
|
17
|
+
"jsdom": "^21.1.0",
|
|
18
|
+
"jsdom-testing-mocks": "^1.7.0",
|
|
19
|
+
"prettier": "^2.8.0",
|
|
20
|
+
"prettier-plugin-svelte": "^2.8.1",
|
|
21
|
+
"svelte": "^3.54.0",
|
|
22
|
+
"svelte-check": "^3.0.1",
|
|
23
|
+
"tslib": "^2.4.1",
|
|
24
|
+
"typescript": "^4.9.3",
|
|
25
|
+
"vite": "^4.0.0",
|
|
26
|
+
"vitest": "^0.25.3"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"datocms-structured-text-utils": "^2.0.4",
|
|
31
|
+
"np": "^7.6.3",
|
|
32
|
+
"svelte-intersection-observer": "^0.10.0",
|
|
33
|
+
"universal-base64": "^2.1.0"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
"./package.json": "./package.json",
|
|
37
|
+
"./components/Head/Head.svelte": "./components/Head/Head.svelte",
|
|
38
|
+
"./components/Head/README.md": "./components/Head/README.md",
|
|
39
|
+
"./components/Image/Image.svelte": "./components/Image/Image.svelte",
|
|
40
|
+
"./components/Image/Placeholder.svelte": "./components/Image/Placeholder.svelte",
|
|
41
|
+
"./components/Image/README.md": "./components/Image/README.md",
|
|
42
|
+
"./components/Image/Sizer.svelte": "./components/Image/Sizer.svelte",
|
|
43
|
+
"./components/Image/Source.svelte": "./components/Image/Source.svelte",
|
|
44
|
+
"./components/StructuredText/Node.svelte": "./components/StructuredText/Node.svelte",
|
|
45
|
+
"./components/StructuredText/README.md": "./components/StructuredText/README.md",
|
|
46
|
+
"./components/StructuredText/StructuredText.svelte": "./components/StructuredText/StructuredText.svelte",
|
|
47
|
+
"./components/StructuredText/nodes/Blockquote.svelte": "./components/StructuredText/nodes/Blockquote.svelte",
|
|
48
|
+
"./components/StructuredText/nodes/Code.svelte": "./components/StructuredText/nodes/Code.svelte",
|
|
49
|
+
"./components/StructuredText/nodes/Heading.svelte": "./components/StructuredText/nodes/Heading.svelte",
|
|
50
|
+
"./components/StructuredText/nodes/Link.svelte": "./components/StructuredText/nodes/Link.svelte",
|
|
51
|
+
"./components/StructuredText/nodes/List.svelte": "./components/StructuredText/nodes/List.svelte",
|
|
52
|
+
"./components/StructuredText/nodes/ListItem.svelte": "./components/StructuredText/nodes/ListItem.svelte",
|
|
53
|
+
"./components/StructuredText/nodes/Paragraph.svelte": "./components/StructuredText/nodes/Paragraph.svelte",
|
|
54
|
+
"./components/StructuredText/nodes/Root.svelte": "./components/StructuredText/nodes/Root.svelte",
|
|
55
|
+
"./components/StructuredText/nodes/Span.svelte": "./components/StructuredText/nodes/Span.svelte",
|
|
56
|
+
"./components/StructuredText/nodes/ThematicBreak.svelte": "./components/StructuredText/nodes/ThematicBreak.svelte",
|
|
57
|
+
"./components/StructuredText/utils/Lines.svelte": "./components/StructuredText/utils/Lines.svelte",
|
|
58
|
+
".": "./index.js"
|
|
59
|
+
},
|
|
60
|
+
"svelte": "./index.js"
|
|
61
|
+
}
|