-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAstroJs.astro
47 lines (40 loc) · 889 Bytes
/
AstroJs.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
import type { FromSchema, JSONSchema7, UiSchema } from '@jsfe/shoelace';
// -----------------------------------------------------------------------------
const mySchema = {
type: 'object',
properties: {
foo: {
type: 'string',
},
bar: {
type: 'boolean',
},
},
} as const satisfies JSONSchema7;
type MyData = FromSchema<typeof mySchema>;
const uiSchema: UiSchema = {
bar: {
'ui:widget': 'switch',
},
};
const dataInAstro: MyData = {
foo: 'hello',
};
---
<article id="astro">
<type-script-only>
<!-- You can set settings upfront from SSR -->
<jsf-shoelace
schema={JSON.stringify(mySchema)}
uiSchema={JSON.stringify(uiSchema)}
data={JSON.stringify(dataInAstro)}
>
</jsf-shoelace>
<pre id="debug">{JSON.stringify({ data: {} }, null, 2)}</pre>
</type-script-only>
</article>
<script>
// Client side
import './TypeScriptOnly.js';
</script>