histoire 0.4.4 → 0.5.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 (77) hide show
  1. package/dist/bundled/HomeView.js +1 -0
  2. package/dist/bundled/MobileOverlay.js +3 -1
  3. package/dist/bundled/SandboxVue3.js +649 -0
  4. package/dist/bundled/SearchPane.js +2 -0
  5. package/dist/bundled/StoryView.js +551 -622
  6. package/dist/bundled/global-components.js +16 -6
  7. package/dist/bundled/index2.js +114 -43
  8. package/dist/bundled/sandbox.js +3 -11
  9. package/dist/bundled/state.js +55 -0
  10. package/dist/bundled/story.js +1 -1
  11. package/dist/client/app/App.vue +18 -0
  12. package/dist/client/app/codegen/serialize-js.js +1 -1
  13. package/dist/client/app/codegen/vue3.d.ts +2 -0
  14. package/dist/client/app/codegen/vue3.js +37 -12
  15. package/dist/client/app/components/app/InitialLoading.vue +46 -0
  16. package/dist/client/app/components/app/MobileOverlay.vue +1 -1
  17. package/dist/client/app/components/base/BaseSelect.vue +72 -0
  18. package/dist/client/app/components/exposed/Story.vue +2 -1
  19. package/dist/client/app/components/exposed/Variant.vue +4 -4
  20. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +96 -0
  21. package/dist/client/app/components/panel/ControlsComponentProps.vue +33 -0
  22. package/dist/client/app/components/panel/StatePresets.vue +195 -0
  23. package/dist/client/app/components/panel/StoryControls.vue +31 -2
  24. package/dist/client/app/components/sandbox/SandboxVue3.vue +70 -2
  25. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +2 -14
  26. package/dist/client/app/index.js +5 -0
  27. package/dist/client/app/sandbox.js +2 -11
  28. package/dist/client/app/style/transitions.pcss +12 -0
  29. package/dist/client/app/types.d.ts +11 -0
  30. package/dist/client/app/util/mapping.js +11 -1
  31. package/dist/client/app/util/state.d.ts +5 -0
  32. package/dist/client/app/util/state.js +55 -0
  33. package/dist/client/app/util/variant.d.ts +1 -1
  34. package/dist/node/build.js +4 -6
  35. package/dist/node/collect/index.js +6 -0
  36. package/dist/node/collect/worker.js +0 -4
  37. package/dist/node/commands/preview.js +1 -1
  38. package/dist/node/config.d.ts +23 -23
  39. package/dist/node/plugin.d.ts +2 -2
  40. package/dist/node/server.js +66 -47
  41. package/dist/node/vite.d.ts +1 -1
  42. package/dist/node/vite.js +10 -2
  43. package/dist/style.css +162 -50
  44. package/package.json +4 -4
  45. package/src/client/app/App.vue +18 -0
  46. package/src/client/app/codegen/serialize-js.ts +1 -1
  47. package/src/client/app/codegen/vue3.ts +40 -12
  48. package/src/client/app/components/app/InitialLoading.vue +46 -0
  49. package/src/client/app/components/app/MobileOverlay.vue +1 -1
  50. package/src/client/app/components/base/BaseSelect.vue +72 -0
  51. package/src/client/app/components/exposed/Story.vue +2 -1
  52. package/src/client/app/components/exposed/Variant.vue +4 -4
  53. package/src/client/app/components/panel/ControlsComponentPropItem.vue +96 -0
  54. package/src/client/app/components/panel/ControlsComponentProps.vue +33 -0
  55. package/src/client/app/components/panel/StatePresets.vue +195 -0
  56. package/src/client/app/components/panel/StoryControls.vue +31 -2
  57. package/src/client/app/components/sandbox/SandboxVue3.vue +70 -2
  58. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +2 -14
  59. package/src/client/app/index.ts +6 -0
  60. package/src/client/app/sandbox.ts +2 -10
  61. package/src/client/app/style/transitions.pcss +12 -0
  62. package/src/client/app/types.ts +13 -0
  63. package/src/client/app/util/mapping.ts +12 -1
  64. package/src/client/app/util/state.ts +61 -0
  65. package/src/client/app/util/variant.ts +1 -1
  66. package/src/node/build.ts +4 -6
  67. package/src/node/collect/index.ts +7 -0
  68. package/src/node/collect/worker.ts +0 -4
  69. package/src/node/commands/preview.ts +1 -1
  70. package/src/node/server.ts +72 -49
  71. package/src/node/vite.ts +11 -2
  72. package/vite.config.ts +25 -0
  73. package/dist/bundled/dark.js +0 -4
  74. package/dist/bundled/reactivity.js +0 -96
  75. package/dist/client/app/util/reactivity.d.ts +0 -1
  76. package/dist/client/app/util/reactivity.js +0 -16
  77. package/src/client/app/util/reactivity.ts +0 -22
package/dist/style.css CHANGED
@@ -30,7 +30,8 @@
30
30
  .v-popper__popper{
31
31
  z-index:10000;
32
32
  top:0;
33
- left:0
33
+ left:0;
34
+ outline:none
34
35
  }
35
36
 
36
37
  .v-popper__popper.v-popper__popper--hidden{
@@ -204,6 +205,42 @@
204
205
  border-color:#000c
205
206
  }
206
207
 
208
+ .v-popper{
209
+ line-height:0
210
+ }
211
+
212
+ .htw-dark .v-popper--theme-dropdown .v-popper__inner{
213
+ --tw-border-opacity: 1;
214
+ border-color:rgb(31 31 33 / var(--tw-border-opacity));
215
+ --tw-bg-opacity: 1;
216
+ background-color:rgb(63 63 70 / var(--tw-bg-opacity));
217
+ --tw-text-opacity: 1;
218
+ color:rgb(244 244 245 / var(--tw-text-opacity))
219
+ }
220
+
221
+ .htw-dark .v-popper--theme-dropdown .v-popper__arrow-inner{
222
+ --tw-border-opacity: 1;
223
+ border-color:rgb(63 63 70 / var(--tw-border-opacity))
224
+ }
225
+
226
+ .htw-dark .v-popper--theme-dropdown .v-popper__arrow-outer{
227
+ --tw-border-opacity: 1;
228
+ border-color:rgb(31 31 33 / var(--tw-border-opacity))
229
+ }
230
+
231
+ .v-popper--theme-dropdown.v-popper__popper--show-from .v-popper__wrapper{
232
+ transform:scale(.75)
233
+ }
234
+
235
+ .v-popper--theme-dropdown.v-popper__popper--show-to .v-popper__wrapper{
236
+ transform:none;
237
+ transition:transform .15s cubic-bezier(0,1,.5,1)
238
+ }
239
+
240
+ .v-popper__popper:focus-visible{
241
+ outline:none
242
+ }
243
+
207
244
  .htw-bind-col-size{
208
245
  grid-template-columns:repeat(auto-fill,minmax(var(--histoire-col-size),1fr))
209
246
  }
@@ -270,12 +307,22 @@
270
307
 
271
308
  .__histoire-fade-enter-active,
272
309
  .__histoire-fade-leave-active {
273
- transition: transform .15s, opacity .15s;
274
- transform: translateY(0px);
310
+ transition: opacity .15s;
275
311
  }
276
312
 
277
313
  .__histoire-fade-enter-from,
278
314
  .__histoire-fade-leave-to {
315
+ opacity: 0;
316
+ }
317
+
318
+ .__histoire-fade-bottom-enter-active,
319
+ .__histoire-fade-bottom-leave-active {
320
+ transition: transform .15s, opacity .15s;
321
+ transform: translateY(0px);
322
+ }
323
+
324
+ .__histoire-fade-bottom-enter-from,
325
+ .__histoire-fade-bottom-leave-to {
279
326
  transform: translateY(32px);
280
327
  opacity: 0;
281
328
  }
@@ -891,6 +938,11 @@ button {
891
938
  margin:0.25rem
892
939
  }
893
940
 
941
+ .-htw-my-1{
942
+ margin-top:-0.25rem;
943
+ margin-bottom:-0.25rem
944
+ }
945
+
894
946
  .htw-mx-1{
895
947
  margin-left:0.25rem;
896
948
  margin-right:0.25rem
@@ -921,11 +973,6 @@ button {
921
973
  margin-right:1rem
922
974
  }
923
975
 
924
- .-htw-my-1{
925
- margin-top:-0.25rem;
926
- margin-bottom:-0.25rem
927
- }
928
-
929
976
  .htw-mt-2{
930
977
  margin-top:0.5rem
931
978
  }
@@ -1010,6 +1057,10 @@ button {
1010
1057
  height:1.25rem
1011
1058
  }
1012
1059
 
1060
+ .htw-h-3{
1061
+ height:0.75rem
1062
+ }
1063
+
1013
1064
  .htw-h-8{
1014
1065
  height:2rem
1015
1066
  }
@@ -1026,10 +1077,18 @@ button {
1026
1077
  height:2.5rem
1027
1078
  }
1028
1079
 
1080
+ .htw-h-\[27px\]{
1081
+ height:27px
1082
+ }
1083
+
1029
1084
  .htw-h-\[2px\]{
1030
1085
  height:2px
1031
1086
  }
1032
1087
 
1088
+ .htw-h-9{
1089
+ height:2.25rem
1090
+ }
1091
+
1033
1092
  .htw-h-\[51px\]{
1034
1093
  height:51px
1035
1094
  }
@@ -1092,6 +1151,10 @@ button {
1092
1151
  width:1.25rem
1093
1152
  }
1094
1153
 
1154
+ .htw-w-3{
1155
+ width:0.75rem
1156
+ }
1157
+
1095
1158
  .htw-w-screen{
1096
1159
  width:100vw
1097
1160
  }
@@ -1156,14 +1219,14 @@ button {
1156
1219
  min-width:1rem
1157
1220
  }
1158
1221
 
1159
- .htw-min-w-16{
1160
- min-width:4rem
1161
- }
1162
-
1163
1222
  .htw-min-w-0{
1164
1223
  min-width:0px
1165
1224
  }
1166
1225
 
1226
+ .htw-min-w-16{
1227
+ min-width:4rem
1228
+ }
1229
+
1167
1230
  .htw-max-w-full{
1168
1231
  max-width:100%
1169
1232
  }
@@ -1205,6 +1268,12 @@ button {
1205
1268
  transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
1206
1269
  }
1207
1270
 
1271
+ .htw-scale-0{
1272
+ --tw-scale-x:0;
1273
+ --tw-scale-y:0;
1274
+ transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
1275
+ }
1276
+
1208
1277
  .htw-cursor-pointer{
1209
1278
  cursor:pointer
1210
1279
  }
@@ -1288,6 +1357,10 @@ button {
1288
1357
  gap:0.5rem
1289
1358
  }
1290
1359
 
1360
+ .htw-gap-6{
1361
+ gap:1.5rem
1362
+ }
1363
+
1291
1364
  .htw-gap-4{
1292
1365
  gap:1rem
1293
1366
  }
@@ -1463,6 +1536,11 @@ button {
1463
1536
  border-color:rgb(0 0 0 / 0.2)
1464
1537
  }
1465
1538
 
1539
+ .htw-border-gray-850{
1540
+ --tw-border-opacity:1;
1541
+ border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-border-opacity))
1542
+ }
1543
+
1466
1544
  .htw-bg-white{
1467
1545
  --tw-bg-opacity:1;
1468
1546
  background-color:rgb(255 255 255 / var(--tw-bg-opacity))
@@ -1473,15 +1551,33 @@ button {
1473
1551
  background-color:rgb(var(--_histoire-color-gray-500) / var(--tw-bg-opacity))
1474
1552
  }
1475
1553
 
1554
+ .htw-bg-primary-500\/10{
1555
+ background-color:rgb(var(--_histoire-color-primary-500) / 0.1)
1556
+ }
1557
+
1476
1558
  .htw-bg-primary-500{
1477
1559
  --tw-bg-opacity:1;
1478
1560
  background-color:rgb(var(--_histoire-color-primary-500) / var(--tw-bg-opacity))
1479
1561
  }
1480
1562
 
1563
+ .htw-bg-gray-50{
1564
+ --tw-bg-opacity:1;
1565
+ background-color:rgb(var(--_histoire-color-gray-50) / var(--tw-bg-opacity))
1566
+ }
1567
+
1568
+ .htw-bg-primary-200{
1569
+ --tw-bg-opacity:1;
1570
+ background-color:rgb(var(--_histoire-color-primary-200) / var(--tw-bg-opacity))
1571
+ }
1572
+
1481
1573
  .htw-bg-primary-500\/25{
1482
1574
  background-color:rgb(var(--_histoire-color-primary-500) / 0.25)
1483
1575
  }
1484
1576
 
1577
+ .htw-bg-transparent{
1578
+ background-color:transparent
1579
+ }
1580
+
1485
1581
  .htw-bg-primary-50{
1486
1582
  --tw-bg-opacity:1;
1487
1583
  background-color:rgb(var(--_histoire-color-primary-50) / var(--tw-bg-opacity))
@@ -1492,10 +1588,6 @@ button {
1492
1588
  background-color:rgb(var(--_histoire-color-gray-100) / var(--tw-bg-opacity))
1493
1589
  }
1494
1590
 
1495
- .htw-bg-transparent{
1496
- background-color:transparent
1497
- }
1498
-
1499
1591
  .htw-bg-white\/80{
1500
1592
  background-color:rgb(255 255 255 / 0.8)
1501
1593
  }
@@ -1505,16 +1597,6 @@ button {
1505
1597
  background-color:rgb(var(--_histoire-color-gray-200) / var(--tw-bg-opacity))
1506
1598
  }
1507
1599
 
1508
- .htw-bg-primary-200{
1509
- --tw-bg-opacity:1;
1510
- background-color:rgb(var(--_histoire-color-primary-200) / var(--tw-bg-opacity))
1511
- }
1512
-
1513
- .htw-bg-gray-50{
1514
- --tw-bg-opacity:1;
1515
- background-color:rgb(var(--_histoire-color-gray-50) / var(--tw-bg-opacity))
1516
- }
1517
-
1518
1600
  .htw-bg-gray-500\/10{
1519
1601
  background-color:rgb(var(--_histoire-color-gray-500) / 0.1)
1520
1602
  }
@@ -1523,6 +1605,11 @@ button {
1523
1605
  background-color:rgb(var(--_histoire-color-gray-500) / 0.5)
1524
1606
  }
1525
1607
 
1608
+ .htw-bg-gray-700{
1609
+ --tw-bg-opacity:1;
1610
+ background-color:rgb(var(--_histoire-color-gray-700) / var(--tw-bg-opacity))
1611
+ }
1612
+
1526
1613
  .htw-stroke-white{
1527
1614
  stroke:#fff
1528
1615
  }
@@ -1568,6 +1655,16 @@ button {
1568
1655
  padding-bottom:3rem
1569
1656
  }
1570
1657
 
1658
+ .htw-px-2{
1659
+ padding-left:0.5rem;
1660
+ padding-right:0.5rem
1661
+ }
1662
+
1663
+ .htw-py-1{
1664
+ padding-top:0.25rem;
1665
+ padding-bottom:0.25rem
1666
+ }
1667
+
1571
1668
  .htw-px-0\.5{
1572
1669
  padding-left:0.125rem;
1573
1670
  padding-right:0.125rem
@@ -1588,11 +1685,6 @@ button {
1588
1685
  padding-bottom:1rem
1589
1686
  }
1590
1687
 
1591
- .htw-px-2{
1592
- padding-left:0.5rem;
1593
- padding-right:0.5rem
1594
- }
1595
-
1596
1688
  .htw-py-0\.5{
1597
1689
  padding-top:0.125rem;
1598
1690
  padding-bottom:0.125rem
@@ -1603,11 +1695,6 @@ button {
1603
1695
  padding-bottom:0px
1604
1696
  }
1605
1697
 
1606
- .htw-py-1{
1607
- padding-top:0.25rem;
1608
- padding-bottom:0.25rem
1609
- }
1610
-
1611
1698
  .htw-pr-2{
1612
1699
  padding-right:0.5rem
1613
1700
  }
@@ -1701,6 +1788,15 @@ button {
1701
1788
  color:rgb(var(--_histoire-color-gray-400) / var(--tw-text-opacity))
1702
1789
  }
1703
1790
 
1791
+ .htw-text-orange-500{
1792
+ --tw-text-opacity:1;
1793
+ color:rgb(249 115 22 / var(--tw-text-opacity))
1794
+ }
1795
+
1796
+ .htw-text-inherit{
1797
+ color:inherit
1798
+ }
1799
+
1704
1800
  .htw-text-red-500{
1705
1801
  --tw-text-opacity:1;
1706
1802
  color:rgb(239 68 68 / var(--tw-text-opacity))
@@ -1719,10 +1815,6 @@ button {
1719
1815
  color:rgb(var(--_histoire-color-primary-800) / var(--tw-text-opacity))
1720
1816
  }
1721
1817
 
1722
- .htw-text-inherit{
1723
- color:inherit
1724
- }
1725
-
1726
1818
  .htw-opacity-25{
1727
1819
  opacity:0.25
1728
1820
  }
@@ -1735,14 +1827,14 @@ button {
1735
1827
  opacity:0.5
1736
1828
  }
1737
1829
 
1738
- .htw-opacity-60{
1739
- opacity:0.6
1740
- }
1741
-
1742
1830
  .htw-opacity-30{
1743
1831
  opacity:0.3
1744
1832
  }
1745
1833
 
1834
+ .htw-opacity-60{
1835
+ opacity:0.6
1836
+ }
1837
+
1746
1838
  .htw-opacity-20{
1747
1839
  opacity:0.2
1748
1840
  }
@@ -1762,6 +1854,12 @@ button {
1762
1854
  outline-offset:2px
1763
1855
  }
1764
1856
 
1857
+ .htw-transition-transform{
1858
+ transition-property:transform;
1859
+ transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1860
+ transition-duration:150ms
1861
+ }
1862
+
1765
1863
  .htw-transition-border{
1766
1864
  transition-property:border;
1767
1865
  transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
@@ -1786,12 +1884,6 @@ button {
1786
1884
  transition-duration:150ms
1787
1885
  }
1788
1886
 
1789
- .htw-transition-transform{
1790
- transition-property:transform;
1791
- transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);
1792
- transition-duration:150ms
1793
- }
1794
-
1795
1887
  .htw-delay-150{
1796
1888
  transition-delay:150ms
1797
1889
  }
@@ -1862,6 +1954,11 @@ body {
1862
1954
  margin-bottom:0px
1863
1955
  }
1864
1956
 
1957
+ .hover\:htw-border-primary-500:hover{
1958
+ --tw-border-opacity:1;
1959
+ border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
1960
+ }
1961
+
1865
1962
  .hover\:htw-bg-primary-100:hover{
1866
1963
  --tw-bg-opacity:1;
1867
1964
  background-color:rgb(var(--_histoire-color-primary-100) / var(--tw-bg-opacity))
@@ -1959,6 +2056,11 @@ body {
1959
2056
  border-color:rgb(var(--_histoire-color-gray-800) / var(--tw-divide-opacity))
1960
2057
  }
1961
2058
 
2059
+ .htw-dark .dark\:htw-divide-gray-750 > :not([hidden]) ~ :not([hidden]){
2060
+ --tw-divide-opacity:1;
2061
+ border-color:rgb(var(--_histoire-color-gray-750) / var(--tw-divide-opacity))
2062
+ }
2063
+
1962
2064
  .htw-dark .dark\:htw-divide-gray-850 > :not([hidden]) ~ :not([hidden]){
1963
2065
  --tw-divide-opacity:1;
1964
2066
  border-color:rgb(var(--_histoire-color-gray-850) / var(--tw-divide-opacity))
@@ -2010,6 +2112,11 @@ body {
2010
2112
  background-color:rgb(var(--_histoire-color-primary-400) / var(--tw-bg-opacity))
2011
2113
  }
2012
2114
 
2115
+ .htw-dark .dark\:htw-bg-primary-800{
2116
+ --tw-bg-opacity:1;
2117
+ background-color:rgb(var(--_histoire-color-primary-800) / var(--tw-bg-opacity))
2118
+ }
2119
+
2013
2120
  .htw-dark .dark\:htw-bg-primary-600{
2014
2121
  --tw-bg-opacity:1;
2015
2122
  background-color:rgb(var(--_histoire-color-primary-600) / var(--tw-bg-opacity))
@@ -2073,6 +2180,11 @@ body {
2073
2180
  color:rgb(var(--_histoire-color-primary-200) / var(--tw-text-opacity))
2074
2181
  }
2075
2182
 
2183
+ .htw-dark .dark\:hover\:htw-border-primary-500:hover{
2184
+ --tw-border-opacity:1;
2185
+ border-color:rgb(var(--_histoire-color-primary-500) / var(--tw-border-opacity))
2186
+ }
2187
+
2076
2188
  .htw-dark .dark\:hover\:htw-bg-primary-700:hover{
2077
2189
  --tw-bg-opacity:1;
2078
2190
  background-color:rgb(var(--_histoire-color-primary-700) / var(--tw-bg-opacity))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,7 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.4.4",
36
+ "@histoire/controls": "^0.5.0",
37
37
  "@iconify/vue": "^3.2.1",
38
38
  "@types/markdown-it": "^12.2.3",
39
39
  "@vueuse/core": "^8.2.5",
@@ -61,7 +61,7 @@
61
61
  "shiki": "^0.10.1",
62
62
  "sirv": "^2.0.2",
63
63
  "tinypool": "^0.1.2",
64
- "vite-node": "0.7.6",
64
+ "vite-node": "0.12.1",
65
65
  "vue-router": "^4.0.14",
66
66
  "vue": "^3.2.31"
67
67
  },
@@ -74,7 +74,7 @@
74
74
  "@types/flexsearch": "^0.7.3",
75
75
  "@types/fs-extra": "^9.0.13",
76
76
  "@types/markdown-it": "^12.2.3",
77
- "@types/node": "^17.0.23",
77
+ "@types/node": "^17.0.32",
78
78
  "@vitejs/plugin-vue": "^2.3.1",
79
79
  "autoprefixer": "^10.4.4",
80
80
  "concurrently": "^7.1.0",
@@ -20,6 +20,7 @@ import { onKeyboardShortcut } from './util/keyboard'
20
20
  import { isMobile } from './util/responsive'
21
21
  import Breadcrumb from './components/app/Breadcrumb.vue'
22
22
  import SearchModal from './components/search/SearchModal.vue'
23
+ import InitialLoading from './components/app/InitialLoading.vue'
23
24
 
24
25
  const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
25
26
  const tree = ref<Tree>(rawTree)
@@ -72,6 +73,17 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
72
73
  isSearchOpen.value = true
73
74
  event.preventDefault()
74
75
  })
76
+
77
+ const loading = ref(false)
78
+
79
+ // @ts-expect-error vite hot api
80
+ if (import.meta.hot && !rawFiles.length) {
81
+ loading.value = true
82
+ // @ts-expect-error vite hot api
83
+ import.meta.hot.on('histoire:all-stories-loaded', () => {
84
+ loading.value = false
85
+ })
86
+ }
75
87
  </script>
76
88
 
77
89
  <template>
@@ -130,5 +142,11 @@ onKeyboardShortcut(['ctrl+k', 'meta+k'], (event) => {
130
142
  :shown="isSearchOpen"
131
143
  @close="isSearchOpen = false"
132
144
  />
145
+
146
+ <transition name="__histoire-fade">
147
+ <InitialLoading
148
+ v-if="loading"
149
+ />
150
+ </transition>
133
151
  </div>
134
152
  </template>
@@ -66,7 +66,7 @@ function arrayToSourceLines (array: any[], indentCount = 0) {
66
66
  })
67
67
  if (contentLines.length === 0) {
68
68
  lines.push('[]')
69
- } else if (contentLines.length <= MAX_SINGLE_LINE_ARRAY_LENGTH) {
69
+ } else if (contentLines.length <= MAX_SINGLE_LINE_ARRAY_LENGTH && !contentLines.some(line => line.spaces > 1)) {
70
70
  const [first] = contentLines
71
71
  first.line = contentLines.map(({ line }) => line.substring(0, line.length - 1)).join(', ')
72
72
  first.line = `[${first.line}]`
@@ -1,5 +1,4 @@
1
- // @ts-nocheck
2
- // @TODO remove no-check and fix vnode type errors
1
+ // @TODO remove @ts-ignore
3
2
 
4
3
  import { VNode, vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic, Text } from 'vue'
5
4
  import { pascal } from 'case'
@@ -12,15 +11,17 @@ export async function generateSourceCode (variant: Variant) {
12
11
  const vnode = variant.slots().default?.({ state: variant.state ?? {} }) ?? []
13
12
  const list = Array.isArray(vnode) ? vnode : [vnode]
14
13
  const lines: string[] = []
15
- for (const vnode of list) {
16
- lines.push(...(await printVNode(vnode)).lines)
14
+ for (const n in list) {
15
+ const vnode = list[n]
16
+ lines.push(...(await printVNode(vnode, variant.state?._hPropState?.[n])).lines)
17
17
  }
18
18
  return lines.join('\n')
19
19
  }
20
20
 
21
- async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: boolean }> {
21
+ async function printVNode (vnode: VNode, propsOverrides: Record<string, any> = null): Promise<{ lines: string[], isText?: boolean }> {
22
22
  if (vnode.type === Text) {
23
23
  return {
24
+ // @ts-ignore
24
25
  lines: [vnode.children],
25
26
  isText: true,
26
27
  }
@@ -30,7 +31,9 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
30
31
 
31
32
  if (typeof vnode.type === 'object' || typeof vnode.type === 'string') {
32
33
  // Wait for async component
34
+ // @ts-ignore
33
35
  if (vnode.type?.__asyncLoader && !vnode.type.__asyncResolved) {
36
+ // @ts-ignore
34
37
  await vnode.type.__asyncLoader()
35
38
  }
36
39
 
@@ -85,7 +88,9 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
85
88
  }
86
89
  }
87
90
  genDirective('model', dir, valueCode)
91
+ // @ts-ignore
88
92
  } else if (dir.instance._ || dir.instance.$) {
93
+ // @ts-ignore
89
94
  const target = dir.instance.$ ?? dir.instance._
90
95
  let dirName: string
91
96
  for (const directives of [target.directives, target.appContext.directives]) {
@@ -105,11 +110,8 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
105
110
  }
106
111
 
107
112
  // Attributes
108
- for (const prop in vnode.props) {
109
- if (skipProps.includes(prop)) {
110
- continue
111
- }
112
- const value = vnode.props[prop]
113
+ function addAttr (prop: string, value: any) {
114
+ // @ts-ignore
113
115
  if (typeof value !== 'string' || vnode.dynamicProps?.includes(prop)) {
114
116
  let directive = ':'
115
117
  if (prop.startsWith('on')) {
@@ -119,6 +121,7 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
119
121
 
120
122
  // v-model on component
121
123
  const vmodelListener = `onUpdate:${prop}`
124
+ // @ts-ignore
122
125
  if (directive === ':' && vnode.dynamicProps?.includes(vmodelListener)) {
123
126
  // Listener
124
127
  skipProps.push(vmodelListener)
@@ -141,7 +144,7 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
141
144
  modifiers,
142
145
  value,
143
146
  }, valueCode)
144
- continue
147
+ return
145
148
  }
146
149
 
147
150
  let serialized: string[]
@@ -177,6 +180,21 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
177
180
  attrs.push([`${prop}="${value}"`])
178
181
  }
179
182
  }
183
+
184
+ for (const prop in vnode.props) {
185
+ if (skipProps.includes(prop) || (propsOverrides && prop in propsOverrides)) {
186
+ continue
187
+ }
188
+ const value = vnode.props[prop]
189
+ addAttr(prop, value)
190
+ }
191
+
192
+ if (propsOverrides) {
193
+ for (const prop in propsOverrides) {
194
+ addAttr(prop, propsOverrides[prop])
195
+ }
196
+ }
197
+
180
198
  if (attrs.length > 1) {
181
199
  multilineAttrs = true
182
200
  }
@@ -197,6 +215,7 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
197
215
  } else if (Array.isArray(vnode.children)) {
198
216
  let isAllChildText
199
217
  for (const child of vnode.children) {
218
+ // @ts-ignore
200
219
  const result = await printVNode(child)
201
220
  if (result.isText) {
202
221
  if (isAllChildText === undefined) {
@@ -230,6 +249,7 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
230
249
  return () => false
231
250
  }
232
251
  })
252
+ // @ts-ignore
233
253
  const children = vnode.children[key](autoObject.proxy)
234
254
  const slotLines: string[] = []
235
255
  for (const child of children) {
@@ -286,6 +306,7 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
286
306
  lines.push(`${tag[0]}${isVoid ? '' : ' /'}>`)
287
307
  }
288
308
  } else if (vnode?.shapeFlag & 1 << 4) {
309
+ // @ts-ignore
289
310
  for (const child of vnode.children) {
290
311
  lines.push(...(await printVNode(child)).lines)
291
312
  }
@@ -296,15 +317,21 @@ async function printVNode (vnode: VNode): Promise<{ lines: string[], isText?: bo
296
317
  }
297
318
  }
298
319
 
299
- function getTagName (vnode: VNode) {
320
+ export function getTagName (vnode: VNode) {
300
321
  if (typeof vnode.type === 'string') {
301
322
  return vnode.type
323
+ // @ts-ignore
302
324
  } else if (vnode.type?.__asyncResolved) {
325
+ // @ts-ignore
303
326
  const asyncComp = vnode.type?.__asyncResolved
304
327
  return asyncComp.name ?? getNameFromFile(asyncComp.__file)
328
+ // @ts-ignore
305
329
  } else if (vnode.type?.name) {
330
+ // @ts-ignore
306
331
  return vnode.type.name
332
+ // @ts-ignore
307
333
  } else if (vnode.type?.__file) {
334
+ // @ts-ignore
308
335
  return getNameFromFile(vnode.type.__file)
309
336
  }
310
337
  return 'Anonymous'
@@ -322,6 +349,7 @@ function serializeAndCleanJs (value: any) {
322
349
  const isAutoBuildingObject = !!value?.__autoBuildingObject
323
350
  const result = serializeJs(value)
324
351
  if (isAutoBuildingObject) {
352
+ // @ts-ignore
325
353
  return [cleanupExpression(result.__autoBuildingObjectGetKey)]
326
354
  } else {
327
355
  return cleanupExpression(result).split('\n')
@@ -0,0 +1,46 @@
1
+ <script lang="ts" setup>
2
+ import { reactive } from 'vue'
3
+
4
+ const progress = reactive({
5
+ loaded: 0,
6
+ total: 0,
7
+ })
8
+
9
+ const maxCols = window.innerWidth / 20
10
+
11
+ // @ts-expect-error vite hot api
12
+ if (import.meta.hot) {
13
+ // @ts-expect-error vite hot api
14
+ import.meta.hot.on('histoire:stories-loading-progress', (data) => {
15
+ progress.loaded = data.loadedFileCount
16
+ progress.total = data.totalFileCount
17
+ })
18
+ }
19
+ </script>
20
+
21
+ <template>
22
+ <div class="htw-fixed htw-inset-0 htw-bg-white dark:htw-bg-gray-700 htw-flex htw-flex-col htw-gap-6 htw-items-center htw-justify-center">
23
+ <transition name="__histoire-fade">
24
+ <div
25
+ v-if="progress.total > 0"
26
+ class="htw-grid htw-gap-2"
27
+ :style="{
28
+ gridTemplateColumns: `repeat(${Math.min(Math.ceil(Math.sqrt(progress.total)), maxCols)}, minmax(0, 1fr))`,
29
+ }"
30
+ >
31
+ <div
32
+ v-for="n in progress.total"
33
+ :key="n"
34
+ class="htw-bg-primary-500/10 htw-rounded-full"
35
+ >
36
+ <div
37
+ class="htw-w-3 htw-h-3 htw-bg-primary-500 htw-rounded-full htw-duration-150 htw-ease-out"
38
+ :class="{
39
+ 'htw-transition-transform htw-scale-0': n >= progress.loaded,
40
+ }"
41
+ />
42
+ </div>
43
+ </div>
44
+ </transition>
45
+ </div>
46
+ </template>
@@ -10,7 +10,7 @@ const emits = defineEmits<{(e: 'close'): void}>()
10
10
  </script>
11
11
 
12
12
  <template>
13
- <transition name="__histoire-fade">
13
+ <transition name="__histoire-fade-bottom">
14
14
  <div
15
15
  v-if="opened"
16
16
  class="htw-absolute htw-z-10 htw-bg-white dark:htw-bg-gray-700 htw-w-screen htw-h-screen htw-inset-0 htw-overflow-hidden htw-flex htw-flex-col"