@poveste/plugin-svelte 0.2.0 → 0.3.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.
- package/assets/poveste-svelte-text.svg +14 -88
- package/assets/poveste-svelte.svg +13 -51
- package/dist/client/MountStory.js +1 -1
- package/dist/client/MountStory.svelte +14 -11
- package/dist/client/MountVariant.svelte +35 -35
- package/dist/client/RenderStory.js +1 -1
- package/dist/client/RenderStory.svelte +13 -13
- package/dist/client/RenderVariant.js +1 -1
- package/dist/client/RenderVariant.svelte +18 -15
- package/dist/client/Wrap.svelte +47 -46
- package/dist/client/mount.d.ts +4 -4
- package/dist/client/mount.js +1 -1
- package/dist/client/render.d.ts +4 -4
- package/dist/client/render.js +1 -1
- package/dist/client/util.js +1 -1
- package/dist/collect/Story.svelte +25 -25
- package/dist/collect/Variant.svelte +17 -17
- package/dist/collect/index.js +1 -1
- package/package.json +8 -8
- package/src/client/MountStory.svelte +14 -11
- package/src/client/MountVariant.svelte +35 -35
- package/src/client/RenderStory.svelte +13 -13
- package/src/client/RenderVariant.svelte +18 -15
- package/src/client/Wrap.svelte +47 -46
- package/src/client/util.ts +21 -10
- package/src/collect/Story.svelte +25 -25
- package/src/collect/Variant.svelte +17 -17
- package/tsconfig.json +1 -1
|
@@ -1,89 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
id="layer1">
|
|
16
|
-
<rect
|
|
17
|
-
style="opacity:0.5;fill:#ff3e00;fill-opacity:1;stroke-width:1.00375"
|
|
18
|
-
id="rect1372"
|
|
19
|
-
width="314.30923"
|
|
20
|
-
height="406.60901"
|
|
21
|
-
x="-26.565063"
|
|
22
|
-
y="134.75079"
|
|
23
|
-
transform="rotate(-23.821262)"
|
|
24
|
-
ry="8" />
|
|
25
|
-
<rect
|
|
26
|
-
style="fill:#ff3e00;fill-opacity:1;stroke-width:1.00375"
|
|
27
|
-
id="rect850"
|
|
28
|
-
width="314.30923"
|
|
29
|
-
height="406.60901"
|
|
30
|
-
x="77.571838"
|
|
31
|
-
y="72.808708"
|
|
32
|
-
ry="8"
|
|
33
|
-
transform="rotate(-4.5744534)" />
|
|
34
|
-
</g>
|
|
35
|
-
<g
|
|
36
|
-
id="layer3">
|
|
37
|
-
<path
|
|
38
|
-
id="path1657-3"
|
|
39
|
-
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:8.34923;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
40
|
-
d="M 359.38947,355.95134 320.72935,176.52942 238.34613,238.94118 Z M 273.64124,273.06608 152.59788,156.05591 191.25804,335.47786 Z" />
|
|
41
|
-
<g
|
|
42
|
-
aria-label="Histoire"
|
|
43
|
-
id="text1821"
|
|
44
|
-
style="font-size:231.926px;line-height:1.25;font-family:Sen;-inkscape-font-specification:Sen;fill:#ff3e00;stroke-width:5.79813;fill-opacity:1"
|
|
45
|
-
transform="matrix(1.1500556,0,0,1.1500556,-105.40156,-38.414233)">
|
|
46
|
-
<path
|
|
47
|
-
d="M 693.87591,344.24783 V 181.89964 h 25.04801 v 162.34819 z m -105.99018,0 V 181.89964 h 25.04801 v 162.34819 z m 10.90052,-68.88202 v -24.1203 h 106.22211 v 24.1203 z"
|
|
48
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
49
|
-
id="path16857" />
|
|
50
|
-
<path
|
|
51
|
-
d="M 762.294,344.24783 V 222.48669 h 23.88838 v 121.76114 z m 11.5963,-148.66456 q -7.65356,0 -11.82822,-3.94274 -4.17467,-3.94274 -4.17467,-11.13245 0,-6.72585 4.17467,-10.90052 4.40659,-4.17467 11.82822,-4.17467 7.65356,0 11.82823,3.94274 4.17466,3.94275 4.17466,11.13245 0,6.72585 -4.40659,10.90052 -4.17467,4.17467 -11.5963,4.17467 z"
|
|
52
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
53
|
-
id="path16859" />
|
|
54
|
-
<path
|
|
55
|
-
d="m 863.41371,346.56709 q -15.30711,0 -27.59919,-5.33429 -12.29208,-5.3343 -20.40949,-15.77097 l 16.23482,-13.91556 q 6.95778,8.11741 15.07519,11.82822 8.34934,3.47889 18.78601,3.47889 4.17466,0 7.65355,-0.9277 3.71082,-1.15963 6.26201,-3.24696 2.78311,-2.08734 4.17466,-4.87045 1.39156,-3.01504 1.39156,-6.49393 0,-6.03007 -4.40659,-9.74089 -2.31926,-1.62348 -7.42164,-3.47889 -4.87044,-2.08733 -12.75593,-4.17467 -13.4517,-3.47889 -22.03297,-7.88548 -8.58126,-4.4066 -13.21978,-9.97282 -3.47889,-4.40659 -5.10237,-9.50897 -1.62348,-5.33429 -1.62348,-11.59629 0,-7.65356 3.24696,-13.91556 3.47889,-6.49393 9.27704,-11.13245 6.03008,-4.87045 13.91556,-7.42163 8.11741,-2.55119 17.16253,-2.55119 8.58126,0 16.93059,2.31926 8.58126,2.31926 15.77097,6.72585 7.18971,4.4066 12.06015,10.43667 l -13.68363,15.07519 q -4.4066,-4.40659 -9.74089,-7.65355 -5.10237,-3.47889 -10.43667,-5.3343 -5.3343,-1.85541 -9.74089,-1.85541 -4.87045,0 -8.81319,0.9277 -3.94274,0.92771 -6.72586,2.78312 -2.55118,1.8554 -3.94274,4.63852 -1.39155,2.78311 -1.39155,6.262 0.23192,3.01504 1.39155,5.79815 1.39156,2.55118 3.71082,4.40659 2.55118,1.85541 7.65356,3.94274 5.10237,2.08734 12.98785,3.94274 11.5963,3.01504 19.01793,6.72586 7.65356,3.47889 12.06015,8.11741 4.63852,4.40659 6.49393,10.20474 1.85541,5.79815 1.85541,12.98786 0,10.43667 -6.03008,18.786 -5.79815,8.11741 -15.77096,12.75593 -9.97282,4.63852 -22.2649,4.63852 z"
|
|
56
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
57
|
-
id="path16861" />
|
|
58
|
-
<path
|
|
59
|
-
d="M 948.99398,344.24783 V 191.4086 h 23.88838 v 152.83923 z m -25.27993,-98.56854 v -23.1926 h 77.46325 v 23.1926 z"
|
|
60
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
61
|
-
id="path16863" />
|
|
62
|
-
<path
|
|
63
|
-
d="m 1076.5528,346.56709 q -17.8583,0 -32.0058,-8.11741 -13.9156,-8.34933 -22.033,-22.49682 -8.1174,-14.37941 -8.1174,-32.70156 0,-18.32216 8.1174,-32.46964 8.1174,-14.37941 22.033,-22.49682 14.1475,-8.34934 32.0058,-8.34934 17.6263,0 31.5419,8.34934 14.1475,8.11741 22.2649,22.49682 8.1174,14.14748 8.1174,32.46964 0,18.32215 -8.1174,32.70156 -8.1174,14.14749 -22.2649,22.49682 -13.9156,8.11741 -31.5419,8.11741 z m 0,-21.80104 q 10.9005,0 19.4818,-5.3343 8.5812,-5.56622 13.4517,-14.84326 4.8704,-9.50897 4.6385,-21.33719 0.2319,-12.06016 -4.6385,-21.33719 -4.8705,-9.50897 -13.4517,-14.84327 -8.5813,-5.3343 -19.4818,-5.3343 -10.9005,0 -19.7137,5.56623 -8.5813,5.3343 -13.4517,14.84326 -4.8705,9.27704 -4.6386,21.10527 -0.2319,11.82822 4.6386,21.33719 4.8704,9.27704 13.4517,14.84326 8.8132,5.3343 19.7137,5.3343 z"
|
|
64
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
65
|
-
id="path16865" />
|
|
66
|
-
<path
|
|
67
|
-
d="M 1168.3954,344.24783 V 222.48669 h 23.8884 v 121.76114 z m 11.5963,-148.66456 q -7.6536,0 -11.8282,-3.94274 -4.1747,-3.94274 -4.1747,-11.13245 0,-6.72585 4.1747,-10.90052 4.4065,-4.17467 11.8282,-4.17467 7.6535,0 11.8282,3.94274 4.1747,3.94275 4.1747,11.13245 0,6.72585 -4.4066,10.90052 -4.1747,4.17467 -11.5963,4.17467 z"
|
|
68
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
69
|
-
id="path16867" />
|
|
70
|
-
<path
|
|
71
|
-
d="M 1228.928,344.24783 V 222.48669 h 24.1203 v 38.26779 l -2.3192,-9.27704 q 2.5512,-8.81319 8.5812,-16.0029 6.262,-7.1897 14.1475,-11.36437 8.1174,-4.17467 16.6987,-4.17467 3.9427,0 7.4216,0.69578 3.7109,0.69578 5.7982,1.62348 l -6.262,25.97571 q -2.7831,-1.15963 -6.262,-1.85541 -3.247,-0.9277 -6.4939,-0.9277 -6.262,0 -12.0602,2.55119 -5.5662,2.31926 -9.9728,6.72585 -4.1747,4.17467 -6.7259,9.97282 -2.5512,5.56622 -2.5512,12.29207 v 67.25854 z"
|
|
72
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
73
|
-
id="path16869" />
|
|
74
|
-
<path
|
|
75
|
-
d="m 1374.1134,346.56709 q -18.786,0 -33.3973,-7.88548 -14.3794,-8.11741 -22.7288,-22.03297 -8.1174,-13.91556 -8.1174,-32.00579 0,-14.37941 4.6386,-26.20763 4.6385,-11.82823 12.7559,-20.40949 8.3493,-8.81319 19.7137,-13.45171 11.5963,-4.87045 25.048,-4.87045 11.8282,0 22.033,4.63852 10.2047,4.4066 17.6263,12.29208 7.6536,7.88549 11.5963,18.78601 4.1747,10.66859 3.9428,23.42452 l -0.2319,10.20475 h -99.4963 l -5.3343,-19.01794 h 84.1891 l -3.4788,3.94275 v -5.56623 q -0.6958,-7.65355 -5.1024,-13.68363 -4.4066,-6.03008 -11.1325,-9.50897 -6.7258,-3.47889 -14.6113,-3.47889 -12.524,0 -21.1053,4.87045 -8.5812,4.63852 -12.9878,13.91556 -4.4066,9.04511 -4.4066,22.49682 0,12.75593 5.3343,22.2649 5.3343,9.27704 15.0752,14.37941 9.7409,5.10237 22.4968,5.10237 9.0451,0 16.6987,-3.01504 7.8855,-3.01504 16.9306,-10.90052 l 12.0601,16.9306 q -5.5662,5.56622 -13.6836,9.74089 -7.8855,4.17467 -16.9306,6.72585 -8.8132,2.31926 -17.3945,2.31926 z"
|
|
76
|
-
style="font-family:'Lexend Deca';-inkscape-font-specification:'Lexend Deca';fill:#ff3e00;fill-opacity:1"
|
|
77
|
-
id="path16871" />
|
|
78
|
-
</g>
|
|
79
|
-
</g>
|
|
80
|
-
<g
|
|
81
|
-
id="layer2"
|
|
82
|
-
style="display:none">
|
|
83
|
-
<path
|
|
84
|
-
id="path1657"
|
|
85
|
-
style="fill:#b4fae2;fill-opacity:1;stroke:#b4fae2;stroke-width:8;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
86
|
-
d="m 296,103.98242 -135.53125,177.9668 h 88.70117 z M 262.83008,230.05078 216,408.01758 351.53125,230.05078 Z"
|
|
87
|
-
transform="rotate(-4.156553,256,256.00691)" />
|
|
88
|
-
</g>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1870 512" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="pvsvw" x1="96" y1="416" x2="416" y2="96" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop offset="0" stop-color="#FF3E00"/>
|
|
5
|
+
<stop offset="1" stop-color="#FF8A00"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect x="16" y="16" width="480" height="480" rx="112" fill="url(#pvsvw)"/>
|
|
9
|
+
<rect x="140" y="142" width="232" height="44" rx="16" fill="#fff"/>
|
|
10
|
+
<rect x="151" y="217" width="88" height="146" rx="9" stroke="#fff" stroke-width="22"/>
|
|
11
|
+
<rect x="172" y="244" width="30" height="92" rx="13" fill="#fff"/>
|
|
12
|
+
<rect x="262" y="206" width="110" height="168" rx="20" fill="#fff"/>
|
|
13
|
+
<rect x="284" y="226" width="66" height="58" rx="13" fill="url(#pvsvw)"/>
|
|
14
|
+
<text x="676" y="256" dominant-baseline="central" font-family="ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" font-size="320" font-weight="400" letter-spacing="-4" fill="#FF3E00">Poveste</text>
|
|
89
15
|
</svg>
|
|
@@ -1,52 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
<g
|
|
15
|
-
id="layer1">
|
|
16
|
-
<rect
|
|
17
|
-
style="opacity:0.5;fill:#ff3e00;fill-opacity:1;stroke-width:1.00375"
|
|
18
|
-
id="rect1372"
|
|
19
|
-
width="314.30923"
|
|
20
|
-
height="406.60901"
|
|
21
|
-
x="-26.565063"
|
|
22
|
-
y="134.75079"
|
|
23
|
-
transform="rotate(-23.821262)"
|
|
24
|
-
ry="8" />
|
|
25
|
-
<rect
|
|
26
|
-
style="fill:#ff3e00;fill-opacity:1;stroke-width:1.00375"
|
|
27
|
-
id="rect850"
|
|
28
|
-
width="314.30923"
|
|
29
|
-
height="406.60901"
|
|
30
|
-
x="77.571838"
|
|
31
|
-
y="72.808708"
|
|
32
|
-
ry="8"
|
|
33
|
-
transform="rotate(-4.5744534)" />
|
|
34
|
-
</g>
|
|
35
|
-
<g
|
|
36
|
-
id="layer3"
|
|
37
|
-
style="display:inline">
|
|
38
|
-
<path
|
|
39
|
-
id="path1657-3"
|
|
40
|
-
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:8.34923;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
41
|
-
d="M 359.38947,355.95134 320.72935,176.52942 238.34613,238.94118 Z M 273.64124,273.06608 152.59788,156.05591 191.25804,335.47786 Z" />
|
|
42
|
-
</g>
|
|
43
|
-
<g
|
|
44
|
-
id="layer2"
|
|
45
|
-
style="display:none">
|
|
46
|
-
<path
|
|
47
|
-
id="path1657"
|
|
48
|
-
style="fill:#b4fae2;fill-opacity:1;stroke:#b4fae2;stroke-width:8;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
49
|
-
d="m 296,103.98242 -135.53125,177.9668 h 88.70117 z M 262.83008,230.05078 216,408.01758 351.53125,230.05078 Z"
|
|
50
|
-
transform="rotate(-4.156553,256,256.00691)" />
|
|
51
|
-
</g>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="pvsv" x1="96" y1="416" x2="416" y2="96" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop offset="0" stop-color="#FF3E00"/>
|
|
5
|
+
<stop offset="1" stop-color="#FF8A00"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect x="16" y="16" width="480" height="480" rx="112" fill="url(#pvsv)"/>
|
|
9
|
+
<rect x="140" y="142" width="232" height="44" rx="16" fill="#fff"/>
|
|
10
|
+
<rect x="151" y="217" width="88" height="146" rx="9" stroke="#fff" stroke-width="22"/>
|
|
11
|
+
<rect x="172" y="244" width="30" height="92" rx="13" fill="#fff"/>
|
|
12
|
+
<rect x="262" y="206" width="110" height="168" rx="20" fill="#fff"/>
|
|
13
|
+
<rect x="284" y="226" width="66" height="58" rx="13" fill="url(#pvsv)"/>
|
|
52
14
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./MountVariant.svelte";import{getContext as t,setContext as n}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as r from"svelte/internal/client";import{omitInheritStoryProps as i}from"@poveste/shared";function a(a,o){let s=r.sanitize_slots(o),c=r.legacy_rest_props(o,[`children`,`$$slots`,`$$events`,`$$legacy`]),l=r.legacy_rest_props(c,[]);r.push(o,!1);let u=
|
|
1
|
+
import e from"./MountVariant.svelte";import{getContext as t,setContext as n}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as r from"svelte/internal/client";import{omitInheritStoryProps as i}from"@poveste/shared";function a(a,o){let s=r.sanitize_slots(o),c=r.legacy_rest_props(o,[`children`,`$$slots`,`$$events`,`$$legacy`]),l=r.legacy_rest_props(c,[]);r.push(o,!1);let u=t(`__pvtStory`);n(`__pvtIndex`,{value:0}),n(`__pvtSlots`,s);let d=Object.keys(u).filter(e=>!i.includes(e)).reduce((e,t)=>(e[t]=u[t],e),{});r.init();var f=r.comment(),p=r.first_child(f),m=t=>{e(t,r.spread_props(()=>d,()=>l,{implicit:!0,children:(e,t)=>{var n=r.comment(),i=r.first_child(n);r.slot(i,o,`default`,{},null),r.append(e,n)},$$slots:{default:!0,controls:(e,t)=>{var n=r.comment(),i=r.first_child(n);r.slot(i,o,`controls`,{},null),r.append(e,n)}}}))},h=e=>{var t=r.comment(),n=r.first_child(t);r.slot(n,o,`default`,{},null),r.append(e,t)};r.if(p,e=>{r.untrack(()=>u.variants.length===1&&u.variants[0].id===`_default`)?e(m):e(h,-1)}),r.append(a,f),r.pop()}export{a as default};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { omitInheritStoryProps } from '@poveste/shared'
|
|
3
|
-
import { getContext, setContext } from 'svelte'
|
|
4
|
-
import MountVariant from './MountVariant.svelte'
|
|
2
|
+
import { omitInheritStoryProps } from '@poveste/shared'
|
|
3
|
+
import { getContext, setContext } from 'svelte'
|
|
4
|
+
import MountVariant from './MountVariant.svelte'
|
|
5
5
|
|
|
6
|
-
const story = getContext('__pvtStory')
|
|
7
|
-
|
|
8
|
-
setContext('__pvtIndex', index)
|
|
9
|
-
setContext('__pvtSlots', $$slots)
|
|
6
|
+
const story = getContext('__pvtStory')
|
|
7
|
+
const index = { value: 0 }
|
|
8
|
+
setContext('__pvtIndex', index)
|
|
9
|
+
setContext('__pvtSlots', $$slots)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// Not `$:`: Svelte invalidates a reactive statement when a variable it
|
|
12
|
+
// references is reassigned, and `story` is a const read from context that
|
|
13
|
+
// never is — so the statement ran exactly once whichever way it is written.
|
|
14
|
+
const inheritedFromStory = Object.keys(story).filter(key => !omitInheritStoryProps.includes(key)).reduce((acc, key) => {
|
|
15
|
+
acc[key] = story[key]
|
|
16
|
+
return acc
|
|
17
|
+
}, {})
|
|
15
18
|
</script>
|
|
16
19
|
|
|
17
20
|
{#if story.variants.length === 1 && story.variants[0].id === '_default'}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { afterUpdate, getContext } from 'svelte'
|
|
2
|
+
import { afterUpdate, getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let source = null
|
|
5
|
-
export let responsiveDisabled = false
|
|
6
|
-
export let autoPropsDisabled = false
|
|
7
|
-
export let setupApp = null
|
|
8
|
-
export let implicit = false
|
|
4
|
+
export let source = null
|
|
5
|
+
export let responsiveDisabled = false
|
|
6
|
+
export let autoPropsDisabled = false
|
|
7
|
+
export let setupApp = null
|
|
8
|
+
export let implicit = false
|
|
9
9
|
|
|
10
|
-
const story = getContext('__pvtStory')
|
|
11
|
-
const index = getContext('__pvtIndex')
|
|
12
|
-
const storySlots = getContext('__pvtSlots')
|
|
10
|
+
const story = getContext('__pvtStory')
|
|
11
|
+
const index = getContext('__pvtIndex')
|
|
12
|
+
const storySlots = getContext('__pvtSlots')
|
|
13
13
|
|
|
14
|
-
const variant = story.variants[index.value]
|
|
15
|
-
index.value++
|
|
14
|
+
const variant = story.variants[index.value]
|
|
15
|
+
index.value++
|
|
16
16
|
|
|
17
|
-
function updateVariant
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
if (!implicit && !story.meta?.hasVariantChildComponents) {
|
|
31
|
-
story.meta = story.meta || {}
|
|
32
|
-
Object.assign(story.meta, {
|
|
33
|
-
hasVariantChildComponents: true,
|
|
17
|
+
function updateVariant() {
|
|
18
|
+
Object.assign(variant, {
|
|
19
|
+
slots: () => ({
|
|
20
|
+
default: true,
|
|
21
|
+
controls: $$slots.controls ?? storySlots.controls,
|
|
22
|
+
}),
|
|
23
|
+
source,
|
|
24
|
+
responsiveDisabled,
|
|
25
|
+
autoPropsDisabled,
|
|
26
|
+
setupApp,
|
|
27
|
+
configReady: true,
|
|
34
28
|
})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
updateVariant()
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
if (!implicit && !story.meta?.hasVariantChildComponents) {
|
|
31
|
+
story.meta = story.meta || {}
|
|
32
|
+
Object.assign(story.meta, {
|
|
33
|
+
hasVariantChildComponents: true,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
40
37
|
updateVariant()
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
afterUpdate(() => {
|
|
40
|
+
updateVariant()
|
|
41
|
+
})
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
44
|
{#if false}
|
|
45
|
-
<slot />
|
|
46
|
-
<slot name="controls" />
|
|
45
|
+
<slot />
|
|
46
|
+
<slot name="controls" />
|
|
47
47
|
{/if}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getContext as e,setContext as t}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as n from"svelte/internal/client";var r=n.from_html(`<!> <!>`,1);function i(i,a){n.push(a,!1);let o=e(`__pvtStory`),s=e(`__pvtVariant`),c=e(`__pvtSlot`);t(`__pvtIndex`,{value:0});let l=n.prop(a,`source`,8,null);n.legacy_pre_effect(()=>n.deep_read_state(l()),()=>{l()!=null&&Object.assign(s,{source:l()})}),n.legacy_pre_effect_reset(),n.init();var u=r(),d=n.first_child(u),f=e=>{var t=n.comment(),r=n.first_child(t);n.slot(r,a,`controls`,{},null),n.append(e,t)};n.if(d,e=>{c===`controls`&&e(f)});var p=n.sibling(d,2),m=e=>{var t=n.comment(),r=n.first_child(t);n.slot(r,a,`default`,{},null),n.append(e,t)};n.if(p,e=>{n.untrack(()=>c
|
|
1
|
+
import{getContext as e,setContext as t}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as n from"svelte/internal/client";var r=n.from_html(`<!> <!>`,1);function i(i,a){n.push(a,!1);let o=e(`__pvtStory`),s=e(`__pvtVariant`),c=e(`__pvtSlot`);t(`__pvtIndex`,{value:0});let l=n.prop(a,`source`,8,null);n.legacy_pre_effect(()=>n.deep_read_state(l()),()=>{l()!=null&&Object.assign(s,{source:l()})}),n.legacy_pre_effect_reset(),n.init();var u=r(),d=n.first_child(u),f=e=>{var t=n.comment(),r=n.first_child(t);n.slot(r,a,`controls`,{},null),n.append(e,t)};n.if(d,e=>{c===`controls`&&e(f)});var p=n.sibling(d,2),m=e=>{var t=n.comment(),r=n.first_child(t);n.slot(r,a,`default`,{},null),n.append(e,t)};n.if(p,e=>{n.untrack(()=>c==="default"||o.meta?.hasVariantChildComponents)&&e(m)}),n.append(i,u),n.pop()}export{i as default};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext, setContext } from 'svelte'
|
|
2
|
+
import { getContext, setContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
const story = getContext('__pvtStory')
|
|
5
|
-
const currentVariant = getContext('__pvtVariant')
|
|
6
|
-
const slotName = getContext('__pvtSlot')
|
|
4
|
+
const story = getContext('__pvtStory')
|
|
5
|
+
const currentVariant = getContext('__pvtVariant')
|
|
6
|
+
const slotName = getContext('__pvtSlot')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
setContext('__pvtIndex', index)
|
|
8
|
+
const index = { value: 0 }
|
|
9
|
+
setContext('__pvtIndex', index)
|
|
10
10
|
|
|
11
|
-
export let source = null
|
|
11
|
+
export let source = null
|
|
12
12
|
|
|
13
|
-
$: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
$: {
|
|
14
|
+
if (source != null) {
|
|
15
|
+
Object.assign(currentVariant, {
|
|
16
|
+
source,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
|
-
}
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
{#if slotName === 'controls'}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getContext as e}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as t from"svelte/internal/client";var n=t.from_html(`<!> <!>`,1);function r(r,i){t.push(i,!1);let a=
|
|
1
|
+
import{getContext as e}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as t from"svelte/internal/client";var n=t.from_html(`<!> <!>`,1);function r(r,i){t.push(i,!1);let a=e(`__pvtStory`),o=e(`__pvtVariant`),s=e(`__pvtSlot`),c=e(`__pvtIndex`),l=a.variants[c.value];c.value++;let u=o.id===l.id,d=t.prop(i,`source`,8,null);t.legacy_pre_effect(()=>t.deep_read_state(d()),()=>{d()!=null&&Object.assign(o,{source:d()})}),t.legacy_pre_effect_reset(),t.init();var f=t.comment(),p=t.first_child(f),m=e=>{var r=n(),a=t.first_child(r),o=e=>{var n=t.comment(),r=t.first_child(n);t.slot(r,i,`default`,{},null),t.append(e,n)};t.if(a,e=>{s==="default"&&e(o)});var c=t.sibling(a,2),l=e=>{var n=t.comment(),r=t.first_child(n);t.slot(r,i,`controls`,{},null),t.append(e,n)};t.if(c,e=>{s===`controls`&&e(l)}),t.append(e,r)};t.if(p,e=>{u&&e(m)}),t.append(r,f),t.pop()}export{r as default};
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
const story = getContext('__pvtStory')
|
|
5
|
-
const currentVariant = getContext('__pvtVariant')
|
|
6
|
-
const slotName = getContext('__pvtSlot')
|
|
7
|
-
const index = getContext('__pvtIndex')
|
|
4
|
+
const story = getContext('__pvtStory')
|
|
5
|
+
const currentVariant = getContext('__pvtVariant')
|
|
6
|
+
const slotName = getContext('__pvtSlot')
|
|
7
|
+
const index = getContext('__pvtIndex')
|
|
8
8
|
|
|
9
|
-
const variant = story.variants[index.value]
|
|
10
|
-
index.value++
|
|
9
|
+
const variant = story.variants[index.value]
|
|
10
|
+
index.value++
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// Not `$:`: Svelte invalidates a reactive statement when a variable it
|
|
13
|
+
// references is reassigned, and both of these are consts that never are —
|
|
14
|
+
// so the statement ran exactly once whichever way it is written.
|
|
15
|
+
const shouldRender = currentVariant.id === variant.id
|
|
13
16
|
|
|
14
|
-
export let source = null
|
|
17
|
+
export let source = null
|
|
15
18
|
|
|
16
|
-
$: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
$: {
|
|
20
|
+
if (source != null) {
|
|
21
|
+
Object.assign(currentVariant, {
|
|
22
|
+
source,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
|
-
}
|
|
23
26
|
</script>
|
|
24
27
|
|
|
25
28
|
{#if shouldRender}
|
package/dist/client/Wrap.svelte
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
import {
|
|
3
|
+
createApp as _createApp,
|
|
4
|
+
h as _h,
|
|
5
|
+
reactive as _reactive,
|
|
6
|
+
} from '@poveste/vendors/vue'
|
|
7
|
+
import { createEventDispatcher, onMount } from 'svelte'
|
|
8
8
|
|
|
9
|
-
export let controlComponent
|
|
10
|
-
export let value
|
|
9
|
+
export let controlComponent
|
|
10
|
+
export let value
|
|
11
11
|
|
|
12
|
-
const dispatch = createEventDispatcher()
|
|
12
|
+
const dispatch = createEventDispatcher()
|
|
13
13
|
|
|
14
|
-
let el
|
|
14
|
+
let el
|
|
15
15
|
|
|
16
|
-
let app
|
|
16
|
+
let app
|
|
17
17
|
|
|
18
|
-
const state = _reactive({})
|
|
18
|
+
const state = _reactive({})
|
|
19
19
|
|
|
20
|
-
function updateState
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
onMount(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
function updateState(value, attrs) {
|
|
21
|
+
Object.assign(state, {
|
|
22
|
+
value,
|
|
23
|
+
attrs,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onMount(() => {
|
|
28
|
+
updateState(value, $$restProps)
|
|
29
|
+
|
|
30
|
+
app = _createApp({
|
|
31
|
+
render() {
|
|
32
|
+
const finalListeners = {}
|
|
33
|
+
if (controlComponent.emits) {
|
|
34
|
+
for (const k in controlComponent.emits) {
|
|
35
|
+
const key = Array.isArray(controlComponent.emits) ? controlComponent.emits[k] : k
|
|
36
|
+
const finalKey = key === 'input' ? 'update:modelValue' : key
|
|
37
|
+
finalListeners[`on${finalKey.charAt(0).toUpperCase()}${finalKey.substring(1)}`] = (...args) => {
|
|
38
|
+
if (key === 'update:modelValue') {
|
|
39
|
+
value = args[0]
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
dispatch(key, ...args)
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
47
|
+
|
|
48
|
+
return _h(controlComponent, {
|
|
49
|
+
modelValue: value,
|
|
50
|
+
...state.attrs,
|
|
51
|
+
...finalListeners,
|
|
52
|
+
key: 'component',
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
app.mount(el)
|
|
54
57
|
})
|
|
55
|
-
app.mount(el)
|
|
56
|
-
})
|
|
57
58
|
|
|
58
|
-
$: updateState(value, $$restProps)
|
|
59
|
+
$: updateState(value, $$restProps)
|
|
59
60
|
</script>
|
|
60
61
|
|
|
61
62
|
<div bind:this={el}>
|
package/dist/client/mount.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Story } from '@poveste/shared';
|
|
2
2
|
import type { PropType as _PropType } from '@poveste/vendors/vue';
|
|
3
|
-
declare const _default: import("
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
4
|
story: {
|
|
5
5
|
type: _PropType<Story>;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
8
|
}>, {
|
|
9
|
-
el: import("
|
|
10
|
-
}, {}, {}, {}, import("
|
|
9
|
+
el: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
11
|
story: {
|
|
12
12
|
type: _PropType<Story>;
|
|
13
13
|
required: true;
|
|
14
14
|
};
|
|
15
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("
|
|
15
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
16
16
|
export default _default;
|
package/dist/client/mount.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./MountVariant.svelte";import r from"./MountStory.svelte";import i from"./Stub.svelte";import{components as a}from"@poveste/controls";import{defineComponent as o,h as s,onMounted as c,onUnmounted as l,ref as u,watch as d}from"@poveste/vendors/vue";import*as f from"virtual:$poveste-generated-global-setup";import*as p from"virtual:$poveste-setup";var m=o({name:`MountStory`,props:{story:{type:Object,required:!0}},setup(i){let a=u(),o,s,m=null;async function g(){s=document.createElement(`div`),a.value.appendChild(s);let c=await t(i.story.file.component,{target:s,props:{Hst:{Story:r,Variant:n,...h()}},context:new Map(Object.entries({__pvtStory:i.story}))},`client`);o=c.app,m=c.destroy
|
|
1
|
+
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./MountVariant.svelte";import r from"./MountStory.svelte";import i from"./Stub.svelte";import{components as a}from"@poveste/controls";import{defineComponent as o,h as s,onMounted as c,onUnmounted as l,ref as u,watch as d}from"@poveste/vendors/vue";import*as f from"virtual:$poveste-generated-global-setup";import*as p from"virtual:$poveste-setup";var m=o({name:`MountStory`,props:{story:{type:Object,required:!0}},setup(i){let a=u(),o,s,m=null;async function g(){s=document.createElement(`div`),a.value.appendChild(s);let c=await t(i.story.file.component,{target:s,props:{Hst:{Story:r,Variant:n,...h()}},context:new Map(Object.entries({__pvtStory:i.story}))},`client`);o=c.app,m=c.destroy;let l={app:o,story:i.story,variant:null};await e(f,p,l)}function _(){m?.(),m=null,s&&=(s.parentNode?.removeChild(s),null),o=null}return d(()=>i.story.id,async()=>{_(),await g()}),c(async()=>{await g()}),l(()=>{_()}),{el:a}},render(){return s(`div`,{ref:`el`})}});function h(){let e={};for(let t in a)e[t.substring(3)]=i;return e}export{m as default};
|
package/dist/client/render.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Story, Variant } from '@poveste/shared';
|
|
2
2
|
import type { PropType as _PropType } from '@poveste/vendors/vue';
|
|
3
|
-
declare const _default: import("
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
4
|
variant: {
|
|
5
5
|
type: _PropType<Variant>;
|
|
6
6
|
required: true;
|
|
@@ -14,8 +14,8 @@ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue
|
|
|
14
14
|
default: string;
|
|
15
15
|
};
|
|
16
16
|
}>, {
|
|
17
|
-
el: import("
|
|
18
|
-
}, {}, {}, {}, import("
|
|
17
|
+
el: import("vue").Ref<HTMLDivElement, HTMLDivElement>;
|
|
18
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
19
|
variant: {
|
|
20
20
|
type: _PropType<Variant>;
|
|
21
21
|
required: true;
|
|
@@ -30,5 +30,5 @@ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue
|
|
|
30
30
|
};
|
|
31
31
|
}>> & Readonly<{}>, {
|
|
32
32
|
slotName: string;
|
|
33
|
-
}, {}, {}, {}, string, import("
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
34
34
|
export default _default;
|
package/dist/client/render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,createWrappedComponent as t,getLegacyStateApi as n,mountSvelteComponent as r}from"../util/svelte.js";import i from"./RenderStory.svelte";import a from"./RenderVariant.svelte";import{syncState as o}from"./util.js";import s from"./Wrap.svelte";import{components as c}from"@poveste/controls";import{defineComponent as l,h as u,onMounted as d,onUnmounted as f,ref as p,watch as m}from"@poveste/vendors/vue";import*as h from"virtual:$poveste-generated-global-setup";import*as g from"virtual:$poveste-setup";var _=l({name:`RenderStory`,props:{variant:{type:Object,required:!0},story:{type:Object,required:!0},slotName:{type:String,default:`default`}},setup(t,{emit:s}){let c=p(),l,u,_=[];function y(e,t){document.addEventListener(e,t);let n=()=>document.removeEventListener(e,t);return _.push(n),{off:n}}async function b(){u=document.createElement(`div`),c.value.appendChild(u);let d=[],{off:f}=y(`SvelteRegisterComponent`,e=>{let{component:t}=e.detail;d.push(t)}),p=await r(t.story.file.component,{target:u,props:{Hst:{Story:i,Variant:a,...v()}},context:new Map(Object.entries({__pvtStory:t.story,__pvtVariant:t.variant,__pvtSlot:t.slotName}))},`client`);l=p.app,_.push(()=>{p.destroy()});let m=d.find(e=>e.$$&&l?.$$&&e.$$===l.$$)??l;f(),d=[];function b(){let e=m?.$replace;e&&(m.$replace=(...t)=>{let n=e.apply(m,t);return m=n??m,n})}b();let x=n(m);if(x){let{apply:e,stop:n}=o(t.variant.state,e=>{x.injectState(e)});_.push(n);let r,i=()=>{e(x.captureState()),r=requestAnimationFrame(i)};r=requestAnimationFrame(i),_.push(()=>{cancelAnimationFrame(r)}),e(x.captureState())}
|
|
1
|
+
import{callSetupFunctions as e,createWrappedComponent as t,getLegacyStateApi as n,mountSvelteComponent as r}from"../util/svelte.js";import i from"./RenderStory.svelte";import a from"./RenderVariant.svelte";import{syncState as o}from"./util.js";import s from"./Wrap.svelte";import{components as c}from"@poveste/controls";import{defineComponent as l,h as u,onMounted as d,onUnmounted as f,ref as p,watch as m}from"@poveste/vendors/vue";import*as h from"virtual:$poveste-generated-global-setup";import*as g from"virtual:$poveste-setup";var _=l({name:`RenderStory`,props:{variant:{type:Object,required:!0},story:{type:Object,required:!0},slotName:{type:String,default:`default`}},setup(t,{emit:s}){let c=p(),l,u,_=[];function y(e,t){document.addEventListener(e,t);let n=()=>document.removeEventListener(e,t);return _.push(n),{off:n}}async function b(){u=document.createElement(`div`),c.value.appendChild(u);let d=[],{off:f}=y(`SvelteRegisterComponent`,e=>{let{component:t}=e.detail;d.push(t)}),p=await r(t.story.file.component,{target:u,props:{Hst:{Story:i,Variant:a,...v()}},context:new Map(Object.entries({__pvtStory:t.story,__pvtVariant:t.variant,__pvtSlot:t.slotName}))},`client`);l=p.app,_.push(()=>{p.destroy()});let m=d.find(e=>e.$$&&l?.$$&&e.$$===l.$$)??l;f(),d=[];function b(){let e=m?.$replace;e&&(m.$replace=(...t)=>{let n=e.apply(m,t);return m=n??m,n})}b();let x=n(m);if(x){let{apply:e,stop:n}=o(t.variant.state,e=>{x.injectState(e)});_.push(n);let r,i=()=>{e(x.captureState()),r=requestAnimationFrame(i)};r=requestAnimationFrame(i),_.push(()=>{cancelAnimationFrame(r)}),e(x.captureState())}let S={app:l,story:t.story,variant:t.variant};await e(h,g,S,t.variant.setupApp),s(`ready`)}function x(){_.forEach(e=>e()),_=[],u&&=(u.parentNode?.removeChild(u),null),l=null}return m(()=>t.story.id,async()=>{x(),await b()}),d(async()=>{await b()}),f(()=>{x()}),{el:c}},render(){return u(`div`,{ref:`el`})}});function v(){let e={};for(let t in c)e[t.substring(3)]=y(c[t]);return e}function y(e){return t(s,e)}export{_ as default};
|
package/dist/client/util.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{watch as e}from"@poveste/vendors/vue";import{applyState as t,clone as n}from"@poveste/shared";function r(e){let t={};for(let n in e){if(n===`Hst`)continue;let r=e[n];typeof r!=`function`&&r!==void 0&&(r instanceof HTMLElement||typeof r==`object`&&r?.$$||(t[n]=r))}return t}function i(i,a){let o=!1,s=e(()=>i,e=>{e!=null
|
|
1
|
+
import{watch as e}from"@poveste/vendors/vue";import{applyState as t,clone as n}from"@poveste/shared";function r(e){let t={};for(let n in e){if(n===`Hst`)continue;let r=e[n];typeof r!=`function`&&r!==void 0&&(r instanceof HTMLElement||typeof r==`object`&&r?.$$||(t[n]=r))}return t}function i(i,a){let o=!1,s=e(()=>i,e=>{if(e!=null){if(o){o=!1;return}o=!0,a(r(e))}},{deep:!0,immediate:!0});function c(e){if(e!=null){if(o){o=!1;return}o=t(i,n(r(e)))}}return{apply:c,stop(){s()}}}export{i as syncState};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext, setContext } from 'svelte'
|
|
2
|
+
import { getContext, setContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let title = null
|
|
5
|
-
export let id = null
|
|
6
|
-
export let group = null
|
|
7
|
-
export let layout = null
|
|
8
|
-
export let icon = null
|
|
9
|
-
export let iconColor = null
|
|
10
|
-
export let docsOnly = false
|
|
4
|
+
export let title = null
|
|
5
|
+
export let id = null
|
|
6
|
+
export let group = null
|
|
7
|
+
export let layout = null
|
|
8
|
+
export let icon = null
|
|
9
|
+
export let iconColor = null
|
|
10
|
+
export let docsOnly = false
|
|
11
11
|
|
|
12
|
-
const addStory = getContext('__pvtAddStory')
|
|
13
|
-
const file = getContext('__pvtStoryFile')
|
|
12
|
+
const addStory = getContext('__pvtAddStory')
|
|
13
|
+
const file = getContext('__pvtStoryFile')
|
|
14
14
|
|
|
15
|
-
const story = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
15
|
+
const story = {
|
|
16
|
+
id: id ?? file.id,
|
|
17
|
+
title: title ?? file.fileName,
|
|
18
|
+
group,
|
|
19
|
+
layout,
|
|
20
|
+
icon,
|
|
21
|
+
iconColor,
|
|
22
|
+
docsOnly,
|
|
23
|
+
variants: [],
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
addStory(story)
|
|
26
|
+
addStory(story)
|
|
27
27
|
|
|
28
|
-
setContext('__pvtStory', story)
|
|
29
|
-
setContext('__pvtAddVariant', (variant) => {
|
|
30
|
-
|
|
31
|
-
})
|
|
28
|
+
setContext('__pvtStory', story)
|
|
29
|
+
setContext('__pvtAddVariant', (variant) => {
|
|
30
|
+
story.variants.push(variant)
|
|
31
|
+
})
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<slot />
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let title = 'untitled'
|
|
5
|
-
export let id = null
|
|
6
|
-
export let icon = null
|
|
7
|
-
export let iconColor = null
|
|
4
|
+
export let title = 'untitled'
|
|
5
|
+
export let id = null
|
|
6
|
+
export let icon = null
|
|
7
|
+
export let iconColor = null
|
|
8
8
|
|
|
9
|
-
const story = getContext('__pvtStory')
|
|
10
|
-
const addVariant = getContext('__pvtAddVariant')
|
|
9
|
+
const story = getContext('__pvtStory')
|
|
10
|
+
const addVariant = getContext('__pvtAddVariant')
|
|
11
11
|
|
|
12
|
-
function generateId
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
function generateId() {
|
|
13
|
+
return `${story.id}-${story.variants.length}`
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
const variant = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
16
|
+
const variant = {
|
|
17
|
+
id: id ?? generateId(),
|
|
18
|
+
title,
|
|
19
|
+
icon,
|
|
20
|
+
iconColor,
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
addVariant(variant)
|
|
23
|
+
addVariant(variant)
|
|
24
24
|
</script>
|
package/dist/collect/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./Story.svelte";import r from"./Variant.svelte";import*as i from"virtual:$poveste-generated-global-setup";import*as a from"virtual:$poveste-setup";import{tick as o}from"svelte";async function s({file:s,el:c,storyData:l}){let{default:u}=await import(/* @vite-ignore */s.moduleId),d=await t(u,{target:c,props:{Hst:{Story:n,Variant:r}},context:new Map(Object.entries({__pvtAddStory(e){l.push(e)},__pvtStoryFile:s}))},`client`)
|
|
1
|
+
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./Story.svelte";import r from"./Variant.svelte";import*as i from"virtual:$poveste-generated-global-setup";import*as a from"virtual:$poveste-setup";import{tick as o}from"svelte";async function s({file:s,el:c,storyData:l}){let{default:u}=await import(/* @vite-ignore */s.moduleId),d=await t(u,{target:c,props:{Hst:{Story:n,Variant:r}},context:new Map(Object.entries({__pvtAddStory(e){l.push(e)},__pvtStoryFile:s}))},`client`),f={app:d.app,story:null,variant:null};await e(i,a,f),await o(),l[0]?.variants.length||l[0].variants.push({id:`_default`,title:`default`}),d.destroy()}export{s as run};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/plugin-svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "Poveste plugin for Svelte
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "Poveste plugin for Svelte 5 and SvelteKit support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
8
8
|
},
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"module": "./dist/index.node.js",
|
|
26
26
|
"types": "./dist/index.node.d.ts",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"svelte": "^
|
|
29
|
-
"poveste": "^0.
|
|
28
|
+
"svelte": "^5.0.0",
|
|
29
|
+
"poveste": "^0.3.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"change-case": "^5.4.4",
|
|
33
33
|
"globby": "^14.0.2",
|
|
34
34
|
"launch-editor": "^2.9.1",
|
|
35
35
|
"pathe": "^1.1.2",
|
|
36
|
-
"@poveste/controls": "^0.
|
|
37
|
-
"@poveste/shared": "^0.
|
|
38
|
-
"@poveste/vendors": "^0.
|
|
36
|
+
"@poveste/controls": "^0.3.0",
|
|
37
|
+
"@poveste/shared": "^0.3.0",
|
|
38
|
+
"@poveste/vendors": "^0.3.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"svelte-preprocess": "^6.0.3",
|
|
48
48
|
"typescript": "5.6.3",
|
|
49
49
|
"vite": "^8.0.0",
|
|
50
|
-
"poveste": "0.
|
|
50
|
+
"poveste": "0.3.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { omitInheritStoryProps } from '@poveste/shared'
|
|
3
|
-
import { getContext, setContext } from 'svelte'
|
|
4
|
-
import MountVariant from './MountVariant.svelte'
|
|
2
|
+
import { omitInheritStoryProps } from '@poveste/shared'
|
|
3
|
+
import { getContext, setContext } from 'svelte'
|
|
4
|
+
import MountVariant from './MountVariant.svelte'
|
|
5
5
|
|
|
6
|
-
const story = getContext('__pvtStory')
|
|
7
|
-
|
|
8
|
-
setContext('__pvtIndex', index)
|
|
9
|
-
setContext('__pvtSlots', $$slots)
|
|
6
|
+
const story = getContext('__pvtStory')
|
|
7
|
+
const index = { value: 0 }
|
|
8
|
+
setContext('__pvtIndex', index)
|
|
9
|
+
setContext('__pvtSlots', $$slots)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// Not `$:`: Svelte invalidates a reactive statement when a variable it
|
|
12
|
+
// references is reassigned, and `story` is a const read from context that
|
|
13
|
+
// never is — so the statement ran exactly once whichever way it is written.
|
|
14
|
+
const inheritedFromStory = Object.keys(story).filter(key => !omitInheritStoryProps.includes(key)).reduce((acc, key) => {
|
|
15
|
+
acc[key] = story[key]
|
|
16
|
+
return acc
|
|
17
|
+
}, {})
|
|
15
18
|
</script>
|
|
16
19
|
|
|
17
20
|
{#if story.variants.length === 1 && story.variants[0].id === '_default'}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { afterUpdate, getContext } from 'svelte'
|
|
2
|
+
import { afterUpdate, getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let source = null
|
|
5
|
-
export let responsiveDisabled = false
|
|
6
|
-
export let autoPropsDisabled = false
|
|
7
|
-
export let setupApp = null
|
|
8
|
-
export let implicit = false
|
|
4
|
+
export let source = null
|
|
5
|
+
export let responsiveDisabled = false
|
|
6
|
+
export let autoPropsDisabled = false
|
|
7
|
+
export let setupApp = null
|
|
8
|
+
export let implicit = false
|
|
9
9
|
|
|
10
|
-
const story = getContext('__pvtStory')
|
|
11
|
-
const index = getContext('__pvtIndex')
|
|
12
|
-
const storySlots = getContext('__pvtSlots')
|
|
10
|
+
const story = getContext('__pvtStory')
|
|
11
|
+
const index = getContext('__pvtIndex')
|
|
12
|
+
const storySlots = getContext('__pvtSlots')
|
|
13
13
|
|
|
14
|
-
const variant = story.variants[index.value]
|
|
15
|
-
index.value++
|
|
14
|
+
const variant = story.variants[index.value]
|
|
15
|
+
index.value++
|
|
16
16
|
|
|
17
|
-
function updateVariant
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
if (!implicit && !story.meta?.hasVariantChildComponents) {
|
|
31
|
-
story.meta = story.meta || {}
|
|
32
|
-
Object.assign(story.meta, {
|
|
33
|
-
hasVariantChildComponents: true,
|
|
17
|
+
function updateVariant() {
|
|
18
|
+
Object.assign(variant, {
|
|
19
|
+
slots: () => ({
|
|
20
|
+
default: true,
|
|
21
|
+
controls: $$slots.controls ?? storySlots.controls,
|
|
22
|
+
}),
|
|
23
|
+
source,
|
|
24
|
+
responsiveDisabled,
|
|
25
|
+
autoPropsDisabled,
|
|
26
|
+
setupApp,
|
|
27
|
+
configReady: true,
|
|
34
28
|
})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
updateVariant()
|
|
38
29
|
|
|
39
|
-
|
|
30
|
+
if (!implicit && !story.meta?.hasVariantChildComponents) {
|
|
31
|
+
story.meta = story.meta || {}
|
|
32
|
+
Object.assign(story.meta, {
|
|
33
|
+
hasVariantChildComponents: true,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
40
37
|
updateVariant()
|
|
41
|
-
|
|
38
|
+
|
|
39
|
+
afterUpdate(() => {
|
|
40
|
+
updateVariant()
|
|
41
|
+
})
|
|
42
42
|
</script>
|
|
43
43
|
|
|
44
44
|
{#if false}
|
|
45
|
-
<slot />
|
|
46
|
-
<slot name="controls" />
|
|
45
|
+
<slot />
|
|
46
|
+
<slot name="controls" />
|
|
47
47
|
{/if}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext, setContext } from 'svelte'
|
|
2
|
+
import { getContext, setContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
const story = getContext('__pvtStory')
|
|
5
|
-
const currentVariant = getContext('__pvtVariant')
|
|
6
|
-
const slotName = getContext('__pvtSlot')
|
|
4
|
+
const story = getContext('__pvtStory')
|
|
5
|
+
const currentVariant = getContext('__pvtVariant')
|
|
6
|
+
const slotName = getContext('__pvtSlot')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
setContext('__pvtIndex', index)
|
|
8
|
+
const index = { value: 0 }
|
|
9
|
+
setContext('__pvtIndex', index)
|
|
10
10
|
|
|
11
|
-
export let source = null
|
|
11
|
+
export let source = null
|
|
12
12
|
|
|
13
|
-
$: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
$: {
|
|
14
|
+
if (source != null) {
|
|
15
|
+
Object.assign(currentVariant, {
|
|
16
|
+
source,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
|
-
}
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
22
|
{#if slotName === 'controls'}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
const story = getContext('__pvtStory')
|
|
5
|
-
const currentVariant = getContext('__pvtVariant')
|
|
6
|
-
const slotName = getContext('__pvtSlot')
|
|
7
|
-
const index = getContext('__pvtIndex')
|
|
4
|
+
const story = getContext('__pvtStory')
|
|
5
|
+
const currentVariant = getContext('__pvtVariant')
|
|
6
|
+
const slotName = getContext('__pvtSlot')
|
|
7
|
+
const index = getContext('__pvtIndex')
|
|
8
8
|
|
|
9
|
-
const variant = story.variants[index.value]
|
|
10
|
-
index.value++
|
|
9
|
+
const variant = story.variants[index.value]
|
|
10
|
+
index.value++
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// Not `$:`: Svelte invalidates a reactive statement when a variable it
|
|
13
|
+
// references is reassigned, and both of these are consts that never are —
|
|
14
|
+
// so the statement ran exactly once whichever way it is written.
|
|
15
|
+
const shouldRender = currentVariant.id === variant.id
|
|
13
16
|
|
|
14
|
-
export let source = null
|
|
17
|
+
export let source = null
|
|
15
18
|
|
|
16
|
-
$: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
$: {
|
|
20
|
+
if (source != null) {
|
|
21
|
+
Object.assign(currentVariant, {
|
|
22
|
+
source,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
|
-
}
|
|
23
26
|
</script>
|
|
24
27
|
|
|
25
28
|
{#if shouldRender}
|
package/src/client/Wrap.svelte
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
2
|
+
import {
|
|
3
|
+
createApp as _createApp,
|
|
4
|
+
h as _h,
|
|
5
|
+
reactive as _reactive,
|
|
6
|
+
} from '@poveste/vendors/vue'
|
|
7
|
+
import { createEventDispatcher, onMount } from 'svelte'
|
|
8
8
|
|
|
9
|
-
export let controlComponent
|
|
10
|
-
export let value
|
|
9
|
+
export let controlComponent
|
|
10
|
+
export let value
|
|
11
11
|
|
|
12
|
-
const dispatch = createEventDispatcher()
|
|
12
|
+
const dispatch = createEventDispatcher()
|
|
13
13
|
|
|
14
|
-
let el
|
|
14
|
+
let el
|
|
15
15
|
|
|
16
|
-
let app
|
|
16
|
+
let app
|
|
17
17
|
|
|
18
|
-
const state = _reactive({})
|
|
18
|
+
const state = _reactive({})
|
|
19
19
|
|
|
20
|
-
function updateState
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
onMount(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
function updateState(value, attrs) {
|
|
21
|
+
Object.assign(state, {
|
|
22
|
+
value,
|
|
23
|
+
attrs,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onMount(() => {
|
|
28
|
+
updateState(value, $$restProps)
|
|
29
|
+
|
|
30
|
+
app = _createApp({
|
|
31
|
+
render() {
|
|
32
|
+
const finalListeners = {}
|
|
33
|
+
if (controlComponent.emits) {
|
|
34
|
+
for (const k in controlComponent.emits) {
|
|
35
|
+
const key = Array.isArray(controlComponent.emits) ? controlComponent.emits[k] : k
|
|
36
|
+
const finalKey = key === 'input' ? 'update:modelValue' : key
|
|
37
|
+
finalListeners[`on${finalKey.charAt(0).toUpperCase()}${finalKey.substring(1)}`] = (...args) => {
|
|
38
|
+
if (key === 'update:modelValue') {
|
|
39
|
+
value = args[0]
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
dispatch(key, ...args)
|
|
43
|
+
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
47
|
+
|
|
48
|
+
return _h(controlComponent, {
|
|
49
|
+
modelValue: value,
|
|
50
|
+
...state.attrs,
|
|
51
|
+
...finalListeners,
|
|
52
|
+
key: 'component',
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
app.mount(el)
|
|
54
57
|
})
|
|
55
|
-
app.mount(el)
|
|
56
|
-
})
|
|
57
58
|
|
|
58
|
-
$: updateState(value, $$restProps)
|
|
59
|
+
$: updateState(value, $$restProps)
|
|
59
60
|
</script>
|
|
60
61
|
|
|
61
62
|
<div bind:this={el}>
|
package/src/client/util.ts
CHANGED
|
@@ -16,17 +16,30 @@ function cleanupState(state: Record<string, any>): Record<string, any> {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function syncState(variantState, onChange: (state) => unknown) {
|
|
19
|
+
// Same flag, same #95 caveat as `plugin-vue` and the sandbox bridge: `apply`
|
|
20
|
+
// may only claim the next firing when its write will actually cause one, and
|
|
21
|
+
// `applyState` reports that. It matters more here than anywhere else, because
|
|
22
|
+
// the render loop calls `apply` on *every animation frame* whether or not the
|
|
23
|
+
// story did anything — set the flag unconditionally and it is set through
|
|
24
|
+
// roughly every other frame, ready to eat whatever lands in it.
|
|
25
|
+
//
|
|
26
|
+
// The `onChange` direction below still sets it blind. Nothing here can see
|
|
27
|
+
// whether handing the state to the component changed anything, so the same
|
|
28
|
+
// hazard remains on that side. It cannot be exercised today: `syncState` is
|
|
29
|
+
// only reachable through `getLegacyStateApi`, which needs Svelte 4's
|
|
30
|
+
// `$capture_state`/`$inject_state`, and the Svelte example is on 5 with both
|
|
31
|
+
// state-sync specs already `fixme` under #81. Whoever revives that path
|
|
32
|
+
// inherits this note.
|
|
19
33
|
let syncing = false
|
|
20
34
|
|
|
21
35
|
const _stop = _watch(() => variantState, (value) => {
|
|
22
36
|
if (value == null) return
|
|
23
|
-
if (
|
|
24
|
-
syncing = true
|
|
25
|
-
onChange(cleanupState(value))
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
37
|
+
if (syncing) {
|
|
28
38
|
syncing = false
|
|
39
|
+
return
|
|
29
40
|
}
|
|
41
|
+
syncing = true
|
|
42
|
+
onChange(cleanupState(value))
|
|
30
43
|
}, {
|
|
31
44
|
deep: true,
|
|
32
45
|
immediate: true,
|
|
@@ -34,13 +47,11 @@ export function syncState(variantState, onChange: (state) => unknown) {
|
|
|
34
47
|
|
|
35
48
|
function apply(value) {
|
|
36
49
|
if (value == null) return
|
|
37
|
-
if (
|
|
38
|
-
syncing = true
|
|
39
|
-
applyState(variantState, clone(cleanupState(value)))
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
50
|
+
if (syncing) {
|
|
42
51
|
syncing = false
|
|
52
|
+
return
|
|
43
53
|
}
|
|
54
|
+
syncing = applyState(variantState, clone(cleanupState(value)))
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
return {
|
package/src/collect/Story.svelte
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext, setContext } from 'svelte'
|
|
2
|
+
import { getContext, setContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let title = null
|
|
5
|
-
export let id = null
|
|
6
|
-
export let group = null
|
|
7
|
-
export let layout = null
|
|
8
|
-
export let icon = null
|
|
9
|
-
export let iconColor = null
|
|
10
|
-
export let docsOnly = false
|
|
4
|
+
export let title = null
|
|
5
|
+
export let id = null
|
|
6
|
+
export let group = null
|
|
7
|
+
export let layout = null
|
|
8
|
+
export let icon = null
|
|
9
|
+
export let iconColor = null
|
|
10
|
+
export let docsOnly = false
|
|
11
11
|
|
|
12
|
-
const addStory = getContext('__pvtAddStory')
|
|
13
|
-
const file = getContext('__pvtStoryFile')
|
|
12
|
+
const addStory = getContext('__pvtAddStory')
|
|
13
|
+
const file = getContext('__pvtStoryFile')
|
|
14
14
|
|
|
15
|
-
const story = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
15
|
+
const story = {
|
|
16
|
+
id: id ?? file.id,
|
|
17
|
+
title: title ?? file.fileName,
|
|
18
|
+
group,
|
|
19
|
+
layout,
|
|
20
|
+
icon,
|
|
21
|
+
iconColor,
|
|
22
|
+
docsOnly,
|
|
23
|
+
variants: [],
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
addStory(story)
|
|
26
|
+
addStory(story)
|
|
27
27
|
|
|
28
|
-
setContext('__pvtStory', story)
|
|
29
|
-
setContext('__pvtAddVariant', (variant) => {
|
|
30
|
-
|
|
31
|
-
})
|
|
28
|
+
setContext('__pvtStory', story)
|
|
29
|
+
setContext('__pvtAddVariant', (variant) => {
|
|
30
|
+
story.variants.push(variant)
|
|
31
|
+
})
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<slot />
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { getContext } from 'svelte'
|
|
2
|
+
import { getContext } from 'svelte'
|
|
3
3
|
|
|
4
|
-
export let title = 'untitled'
|
|
5
|
-
export let id = null
|
|
6
|
-
export let icon = null
|
|
7
|
-
export let iconColor = null
|
|
4
|
+
export let title = 'untitled'
|
|
5
|
+
export let id = null
|
|
6
|
+
export let icon = null
|
|
7
|
+
export let iconColor = null
|
|
8
8
|
|
|
9
|
-
const story = getContext('__pvtStory')
|
|
10
|
-
const addVariant = getContext('__pvtAddVariant')
|
|
9
|
+
const story = getContext('__pvtStory')
|
|
10
|
+
const addVariant = getContext('__pvtAddVariant')
|
|
11
11
|
|
|
12
|
-
function generateId
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
function generateId() {
|
|
13
|
+
return `${story.id}-${story.variants.length}`
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
const variant = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
16
|
+
const variant = {
|
|
17
|
+
id: id ?? generateId(),
|
|
18
|
+
title,
|
|
19
|
+
icon,
|
|
20
|
+
iconColor,
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
addVariant(variant)
|
|
23
|
+
addVariant(variant)
|
|
24
24
|
</script>
|