poveste 0.1.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 (251) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +11 -0
  3. package/bin.mjs +4 -0
  4. package/client.d.ts +19 -0
  5. package/client.js +15 -0
  6. package/dist/controls.d.ts +2 -0
  7. package/dist/controls.d.ts.map +1 -0
  8. package/dist/controls.js +1 -0
  9. package/dist/node/alias.d.ts +3 -0
  10. package/dist/node/alias.d.ts.map +1 -0
  11. package/dist/node/alias.js +5 -0
  12. package/dist/node/bin.d.ts +2 -0
  13. package/dist/node/bin.d.ts.map +1 -0
  14. package/dist/node/bin.js +35 -0
  15. package/dist/node/build-serialize.d.ts +22 -0
  16. package/dist/node/build-serialize.d.ts.map +1 -0
  17. package/dist/node/build-serialize.js +36 -0
  18. package/dist/node/build.d.ts +3 -0
  19. package/dist/node/build.d.ts.map +1 -0
  20. package/dist/node/build.js +228 -0
  21. package/dist/node/builtin-plugins/pinceau-tokens.d.ts +7 -0
  22. package/dist/node/builtin-plugins/pinceau-tokens.d.ts.map +1 -0
  23. package/dist/node/builtin-plugins/pinceau-tokens.js +505 -0
  24. package/dist/node/builtin-plugins/tailwind-tokens.d.ts +6 -0
  25. package/dist/node/builtin-plugins/tailwind-tokens.d.ts.map +1 -0
  26. package/dist/node/builtin-plugins/tailwind-tokens.js +523 -0
  27. package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts +15 -0
  28. package/dist/node/builtin-plugins/vanilla-support/MountStory.d.ts.map +1 -0
  29. package/dist/node/builtin-plugins/vanilla-support/MountStory.js +39 -0
  30. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts +39 -0
  31. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts.map +1 -0
  32. package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +129 -0
  33. package/dist/node/builtin-plugins/vanilla-support/client.d.ts +4 -0
  34. package/dist/node/builtin-plugins/vanilla-support/client.d.ts.map +1 -0
  35. package/dist/node/builtin-plugins/vanilla-support/client.js +5 -0
  36. package/dist/node/builtin-plugins/vanilla-support/collect.d.ts +3 -0
  37. package/dist/node/builtin-plugins/vanilla-support/collect.d.ts.map +1 -0
  38. package/dist/node/builtin-plugins/vanilla-support/collect.js +33 -0
  39. package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts +3 -0
  40. package/dist/node/builtin-plugins/vanilla-support/plugin.d.ts.map +1 -0
  41. package/dist/node/builtin-plugins/vanilla-support/plugin.js +29 -0
  42. package/dist/node/builtin-plugins/vanilla-support/types.d.ts +36 -0
  43. package/dist/node/builtin-plugins/vanilla-support/types.d.ts.map +1 -0
  44. package/dist/node/builtin-plugins/vanilla-support/types.js +3 -0
  45. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts +4 -0
  46. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.d.ts.map +1 -0
  47. package/dist/node/builtin-plugins/vanilla-support/vanilla.story.js +55 -0
  48. package/dist/node/collect/index.d.ts +14 -0
  49. package/dist/node/collect/index.d.ts.map +1 -0
  50. package/dist/node/collect/index.js +129 -0
  51. package/dist/node/collect/run.d.ts +3 -0
  52. package/dist/node/collect/run.d.ts.map +1 -0
  53. package/dist/node/collect/run.js +7 -0
  54. package/dist/node/collect/worker.d.ts +14 -0
  55. package/dist/node/collect/worker.d.ts.map +1 -0
  56. package/dist/node/collect/worker.js +64 -0
  57. package/dist/node/colors.d.ts +287 -0
  58. package/dist/node/colors.d.ts.map +1 -0
  59. package/dist/node/colors.js +324 -0
  60. package/dist/node/commands/build.d.ts +5 -0
  61. package/dist/node/commands/build.d.ts.map +1 -0
  62. package/dist/node/commands/build.js +9 -0
  63. package/dist/node/commands/dev.d.ts +8 -0
  64. package/dist/node/commands/dev.d.ts.map +1 -0
  65. package/dist/node/commands/dev.js +52 -0
  66. package/dist/node/commands/preview.d.ts +5 -0
  67. package/dist/node/commands/preview.d.ts.map +1 -0
  68. package/dist/node/commands/preview.js +15 -0
  69. package/dist/node/config.d.ts +40 -0
  70. package/dist/node/config.d.ts.map +1 -0
  71. package/dist/node/config.js +330 -0
  72. package/dist/node/context.d.ts +18 -0
  73. package/dist/node/context.d.ts.map +1 -0
  74. package/dist/node/context.js +28 -0
  75. package/dist/node/dom/dom-keys.d.ts +5 -0
  76. package/dist/node/dom/dom-keys.d.ts.map +1 -0
  77. package/dist/node/dom/dom-keys.js +233 -0
  78. package/dist/node/dom/env.d.ts +5 -0
  79. package/dist/node/dom/env.d.ts.map +1 -0
  80. package/dist/node/dom/env.js +47 -0
  81. package/dist/node/dom/util.d.ts +11 -0
  82. package/dist/node/dom/util.d.ts.map +1 -0
  83. package/dist/node/dom/util.js +65 -0
  84. package/dist/node/index.d.ts +12 -0
  85. package/dist/node/index.d.ts.map +1 -0
  86. package/dist/node/index.js +4 -0
  87. package/dist/node/load.d.ts +9 -0
  88. package/dist/node/load.d.ts.map +1 -0
  89. package/dist/node/load.js +42 -0
  90. package/dist/node/markdown.d.ts +11 -0
  91. package/dist/node/markdown.d.ts.map +1 -0
  92. package/dist/node/markdown.js +228 -0
  93. package/dist/node/plugin.d.ts +42 -0
  94. package/dist/node/plugin.d.ts.map +1 -0
  95. package/dist/node/plugin.js +67 -0
  96. package/dist/node/preview.d.ts +8 -0
  97. package/dist/node/preview.d.ts.map +1 -0
  98. package/dist/node/preview.js +41 -0
  99. package/dist/node/search.d.ts +17 -0
  100. package/dist/node/search.d.ts.map +1 -0
  101. package/dist/node/search.js +72 -0
  102. package/dist/node/server.d.ts +12 -0
  103. package/dist/node/server.d.ts.map +1 -0
  104. package/dist/node/server.js +189 -0
  105. package/dist/node/stories.d.ts +22 -0
  106. package/dist/node/stories.d.ts.map +1 -0
  107. package/dist/node/stories.js +125 -0
  108. package/dist/node/tree.d.ts +4 -0
  109. package/dist/node/tree.d.ts.map +1 -0
  110. package/dist/node/tree.js +117 -0
  111. package/dist/node/util/find-up.d.ts +2 -0
  112. package/dist/node/util/find-up.d.ts.map +1 -0
  113. package/dist/node/util/find-up.js +20 -0
  114. package/dist/node/util/fs.d.ts +2 -0
  115. package/dist/node/util/fs.d.ts.map +1 -0
  116. package/dist/node/util/fs.js +1 -0
  117. package/dist/node/util/log.d.ts +2 -0
  118. package/dist/node/util/log.d.ts.map +1 -0
  119. package/dist/node/util/log.js +9 -0
  120. package/dist/node/util/slugify.d.ts +2 -0
  121. package/dist/node/util/slugify.d.ts.map +1 -0
  122. package/dist/node/util/slugify.js +22 -0
  123. package/dist/node/util/vendors.d.ts +3 -0
  124. package/dist/node/util/vendors.d.ts.map +1 -0
  125. package/dist/node/util/vendors.js +22 -0
  126. package/dist/node/vendors/controls.d.ts +2 -0
  127. package/dist/node/vendors/controls.d.ts.map +1 -0
  128. package/dist/node/vendors/controls.js +1 -0
  129. package/dist/node/vendors/vue.d.ts +2 -0
  130. package/dist/node/vendors/vue.d.ts.map +1 -0
  131. package/dist/node/vendors/vue.js +1 -0
  132. package/dist/node/virtual/index.d.ts +38 -0
  133. package/dist/node/virtual/index.d.ts.map +1 -0
  134. package/dist/node/virtual/index.js +49 -0
  135. package/dist/node/virtual/markdown.d.ts +3 -0
  136. package/dist/node/virtual/markdown.d.ts.map +1 -0
  137. package/dist/node/virtual/markdown.js +19 -0
  138. package/dist/node/virtual/noop.d.ts +2 -0
  139. package/dist/node/virtual/noop.d.ts.map +1 -0
  140. package/dist/node/virtual/noop.js +1 -0
  141. package/dist/node/virtual/resolved-commands.d.ts +3 -0
  142. package/dist/node/virtual/resolved-commands.d.ts.map +1 -0
  143. package/dist/node/virtual/resolved-commands.js +32 -0
  144. package/dist/node/virtual/resolved-config.d.ts +3 -0
  145. package/dist/node/virtual/resolved-config.d.ts.map +1 -0
  146. package/dist/node/virtual/resolved-config.js +10 -0
  147. package/dist/node/virtual/resolved-generated-global-setup.d.ts +3 -0
  148. package/dist/node/virtual/resolved-generated-global-setup.d.ts.map +1 -0
  149. package/dist/node/virtual/resolved-generated-global-setup.js +23 -0
  150. package/dist/node/virtual/resolved-generated-setup-code.d.ts +3 -0
  151. package/dist/node/virtual/resolved-generated-setup-code.d.ts.map +1 -0
  152. package/dist/node/virtual/resolved-generated-setup-code.js +5 -0
  153. package/dist/node/virtual/resolved-markdown-files.d.ts +3 -0
  154. package/dist/node/virtual/resolved-markdown-files.d.ts.map +1 -0
  155. package/dist/node/virtual/resolved-markdown-files.js +17 -0
  156. package/dist/node/virtual/resolved-stories.d.ts +3 -0
  157. package/dist/node/virtual/resolved-stories.d.ts.map +1 -0
  158. package/dist/node/virtual/resolved-stories.js +42 -0
  159. package/dist/node/virtual/resolved-support-plugins-client.d.ts +3 -0
  160. package/dist/node/virtual/resolved-support-plugins-client.d.ts.map +1 -0
  161. package/dist/node/virtual/resolved-support-plugins-client.js +11 -0
  162. package/dist/node/virtual/resolved-support-plugins-collect.d.ts +3 -0
  163. package/dist/node/virtual/resolved-support-plugins-collect.d.ts.map +1 -0
  164. package/dist/node/virtual/resolved-support-plugins-collect.js +11 -0
  165. package/dist/node/virtual/resolved-theme.d.ts +3 -0
  166. package/dist/node/virtual/resolved-theme.d.ts.map +1 -0
  167. package/dist/node/virtual/resolved-theme.js +12 -0
  168. package/dist/node/virtual/story-source.d.ts +3 -0
  169. package/dist/node/virtual/story-source.d.ts.map +1 -0
  170. package/dist/node/virtual/story-source.js +16 -0
  171. package/dist/node/virtual/story.d.ts +3 -0
  172. package/dist/node/virtual/story.d.ts.map +1 -0
  173. package/dist/node/virtual/story.js +7 -0
  174. package/dist/node/virtual/util.d.ts +3 -0
  175. package/dist/node/virtual/util.d.ts.map +1 -0
  176. package/dist/node/virtual/util.js +4 -0
  177. package/dist/node/virtual/vite-plugin.d.ts +4 -0
  178. package/dist/node/virtual/vite-plugin.d.ts.map +1 -0
  179. package/dist/node/virtual/vite-plugin.js +126 -0
  180. package/dist/node/vite.d.ts +9 -0
  181. package/dist/node/vite.d.ts.map +1 -0
  182. package/dist/node/vite.js +337 -0
  183. package/index.d.ts +1 -0
  184. package/package.json +89 -0
  185. package/plugin.d.ts +3 -0
  186. package/plugin.js +11 -0
  187. package/src/controls.ts +1 -0
  188. package/src/node/__tests__/markdown/test1.story.md +7 -0
  189. package/src/node/__tests__/markdown/test2.story.md +5 -0
  190. package/src/node/__tests__/markdown.spec.ts +61 -0
  191. package/src/node/__tests__/tree.spec.ts +109 -0
  192. package/src/node/alias.ts +8 -0
  193. package/src/node/bin.ts +43 -0
  194. package/src/node/build-serialize.ts +62 -0
  195. package/src/node/build.ts +283 -0
  196. package/src/node/builtin-plugins/pinceau-tokens.ts +521 -0
  197. package/src/node/builtin-plugins/tailwind-tokens.ts +536 -0
  198. package/src/node/builtin-plugins/vanilla-support/MountStory.ts +49 -0
  199. package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +164 -0
  200. package/src/node/builtin-plugins/vanilla-support/client.ts +6 -0
  201. package/src/node/builtin-plugins/vanilla-support/collect.ts +43 -0
  202. package/src/node/builtin-plugins/vanilla-support/plugin.ts +35 -0
  203. package/src/node/builtin-plugins/vanilla-support/types.ts +40 -0
  204. package/src/node/builtin-plugins/vanilla-support/vanilla.story.ts +63 -0
  205. package/src/node/collect/index.ts +160 -0
  206. package/src/node/collect/run.ts +9 -0
  207. package/src/node/collect/worker.ts +97 -0
  208. package/src/node/colors.ts +340 -0
  209. package/src/node/commands/build.ts +14 -0
  210. package/src/node/commands/dev.ts +67 -0
  211. package/src/node/commands/preview.ts +22 -0
  212. package/src/node/config.ts +385 -0
  213. package/src/node/context.ts +60 -0
  214. package/src/node/dom/dom-keys.ts +238 -0
  215. package/src/node/dom/env.ts +60 -0
  216. package/src/node/dom/util.ts +83 -0
  217. package/src/node/index.ts +12 -0
  218. package/src/node/load.ts +59 -0
  219. package/src/node/markdown.ts +267 -0
  220. package/src/node/plugin.ts +95 -0
  221. package/src/node/preview.ts +57 -0
  222. package/src/node/search.ts +84 -0
  223. package/src/node/server.ts +235 -0
  224. package/src/node/stories.ts +154 -0
  225. package/src/node/tree.ts +158 -0
  226. package/src/node/util/find-up.ts +24 -0
  227. package/src/node/util/fs.ts +1 -0
  228. package/src/node/util/log.ts +10 -0
  229. package/src/node/util/slugify.ts +26 -0
  230. package/src/node/util/vendors.ts +27 -0
  231. package/src/node/vendors/controls.ts +1 -0
  232. package/src/node/vendors/vue.ts +1 -0
  233. package/src/node/virtual/index.ts +50 -0
  234. package/src/node/virtual/markdown.ts +21 -0
  235. package/src/node/virtual/noop.ts +1 -0
  236. package/src/node/virtual/resolved-commands.ts +42 -0
  237. package/src/node/virtual/resolved-config.ts +12 -0
  238. package/src/node/virtual/resolved-generated-global-setup.ts +25 -0
  239. package/src/node/virtual/resolved-generated-setup-code.ts +7 -0
  240. package/src/node/virtual/resolved-markdown-files.ts +19 -0
  241. package/src/node/virtual/resolved-stories.ts +44 -0
  242. package/src/node/virtual/resolved-support-plugins-client.ts +14 -0
  243. package/src/node/virtual/resolved-support-plugins-collect.ts +14 -0
  244. package/src/node/virtual/resolved-theme.ts +14 -0
  245. package/src/node/virtual/story-source.ts +18 -0
  246. package/src/node/virtual/story.ts +9 -0
  247. package/src/node/virtual/util.ts +5 -0
  248. package/src/node/virtual/vite-plugin.ts +146 -0
  249. package/src/node/vite.ts +379 -0
  250. package/tsconfig.json +44 -0
  251. package/vitest.config.ts +10 -0
@@ -0,0 +1,523 @@
1
+ import { findUp } from '../util/find-up.js';
2
+ import { getInjectedImport } from '../util/vendors.js';
3
+ export function tailwindTokens(options = {}) {
4
+ const tailwindConfigFile = options.configFile ?? findUp(process.cwd(), [
5
+ 'tailwind.config.js',
6
+ 'tailwind.config.cjs',
7
+ 'tailwind.config.mjs',
8
+ 'tailwind.config.ts',
9
+ 'tailwind-config.js',
10
+ 'tailwind-config.cjs',
11
+ 'tailwind-config.mjs',
12
+ 'tailwind-config.ts',
13
+ ]);
14
+ async function generate(api) {
15
+ try {
16
+ await api.fs.ensureDir(api.pluginTempDir);
17
+ await api.fs.emptyDir(api.pluginTempDir);
18
+ api.moduleLoader.clearCache();
19
+ await api.fs.writeFile(api.path.resolve(api.pluginTempDir, 'style.css'), css);
20
+ const tailwindConfig = await api.moduleLoader.loadModule(tailwindConfigFile);
21
+ const { default: resolveConfig } = await import('tailwindcss/resolveConfig.js');
22
+ const resolvedTailwindConfig = resolveConfig(tailwindConfig.default ?? tailwindConfig);
23
+ const storyFile = api.path.resolve(api.pluginTempDir, 'Tailwind.story.js');
24
+ await api.fs.writeFile(storyFile, storyTemplate(resolvedTailwindConfig));
25
+ api.addStoryFile(storyFile);
26
+ }
27
+ catch (e) {
28
+ api.error(e.stack ?? e.message);
29
+ }
30
+ }
31
+ return {
32
+ name: 'builtin:tailwind-tokens',
33
+ config(config) {
34
+ if (tailwindConfigFile) {
35
+ // Add 'design-system' group
36
+ if (!config.tree) {
37
+ config.tree = {};
38
+ }
39
+ if (!config.tree.groups) {
40
+ config.tree.groups = [];
41
+ }
42
+ if (!config.tree.groups.some(g => g.id === 'design-system')) {
43
+ let index = 0;
44
+ // After 'top' group
45
+ const topIndex = config.tree.groups.findIndex(g => g.id === 'top');
46
+ if (topIndex > -1) {
47
+ index = topIndex + 1;
48
+ }
49
+ // Insert group
50
+ config.tree.groups.splice(index, 0, {
51
+ id: 'design-system',
52
+ title: 'Design System',
53
+ });
54
+ }
55
+ }
56
+ },
57
+ onDev(api, onCleanup) {
58
+ if (tailwindConfigFile) {
59
+ const watcher = api.watcher.watch(tailwindConfigFile)
60
+ .on('change', () => generate(api))
61
+ .on('add', () => generate(api));
62
+ onCleanup(() => {
63
+ watcher.close();
64
+ });
65
+ }
66
+ },
67
+ async onBuild(api) {
68
+ if (tailwindConfigFile) {
69
+ await generate(api);
70
+ }
71
+ },
72
+ };
73
+ }
74
+ function storyTemplate(tailwindConfig) {
75
+ return `
76
+ import 'histoire-style'
77
+ import './style.css'
78
+ import { createApp, h, markRaw, ref } from ${getInjectedImport('@poveste/vendors/vue')}
79
+ import {
80
+ HstColorShades,
81
+ HstTokenList,
82
+ HstTokenGrid,
83
+ HstText,
84
+ HstTextarea,
85
+ HstNumber,
86
+ } from ${getInjectedImport('@poveste/controls')}
87
+
88
+ const config = markRaw(${JSON.stringify(tailwindConfig, null, 2)})
89
+ const search = ref('')
90
+ const sampleText = ref('Cat sit like bread eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap mrow cat cat moo moo lick ears lick paws')
91
+ const fontSize = ref(16)
92
+
93
+ function mountApp ({ el, state, onUnmount }, render) {
94
+ Object.assign(state, {
95
+ search,
96
+ sampleText,
97
+ fontSize,
98
+ })
99
+
100
+ const app = createApp({
101
+ render,
102
+ })
103
+ app.mount(el)
104
+
105
+ onUnmount(() => {
106
+ app.unmount()
107
+ })
108
+ }
109
+
110
+ export default {
111
+ id: 'tailwind',
112
+ title: 'Tailwind',
113
+ group: 'design-system',
114
+ icon: 'mdi:tailwind',
115
+ responsiveDisabled: true,
116
+ layout: { type: 'single', iframe: false },
117
+ variants: [
118
+ {
119
+ id: 'background-color',
120
+ title: 'Background Color',
121
+ icon: 'carbon:color-palette',
122
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.backgroundColor).map(([key, shades]) => h(HstColorShades, {
123
+ key,
124
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
125
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
126
+ search: search.value,
127
+ }, ({ color}) => h('div', {
128
+ class: '__hst-shade',
129
+ style: {
130
+ backgroundColor: color.replace('<alpha-value>', 1),
131
+ },
132
+ })))),
133
+ onMountControls: (api) => mountApp(api, () => [
134
+ h(HstText, {
135
+ title: 'Filter...',
136
+ modelValue: search.value,
137
+ 'onUpdate:modelValue': value => { search.value = value },
138
+ }),
139
+ ]),
140
+ },
141
+ {
142
+ id: 'text-color',
143
+ title: 'Text Color',
144
+ icon: 'carbon:text-color',
145
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.textColor).map(([key, shades]) => h(HstColorShades, {
146
+ key,
147
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
148
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
149
+ search: search.value,
150
+ }, ({ color}) => h('div', {
151
+ class: '__hst-shade __hst-text',
152
+ style: {
153
+ color: color.replace('<alpha-value>', 1),
154
+ },
155
+ }, 'Aa')))),
156
+ onMountControls: (api) => mountApp(api, () => [
157
+ h(HstText, {
158
+ title: 'Filter...',
159
+ modelValue: search.value,
160
+ 'onUpdate:modelValue': value => { search.value = value },
161
+ }),
162
+ ]),
163
+ },
164
+ {
165
+ id: 'border-color',
166
+ title: 'Border Color',
167
+ icon: 'carbon:color-palette',
168
+ onMount: (api) => mountApp(api, () => Object.entries(config.theme.borderColor).map(([key, shades]) => h(HstColorShades, {
169
+ key,
170
+ shades: typeof shades === 'object' ? shades : { DEFAULT: shades },
171
+ getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
172
+ search: search.value,
173
+ }, ({ color}) => h('div', {
174
+ class: '__hst-shade __hst-border',
175
+ style: {
176
+ borderColor: color.replace('<alpha-value>', 1),
177
+ },
178
+ })))),
179
+ onMountControls: (api) => mountApp(api, () => [
180
+ h(HstText, {
181
+ title: 'Filter...',
182
+ modelValue: search.value,
183
+ 'onUpdate:modelValue': value => { search.value = value },
184
+ }),
185
+ ]),
186
+ },
187
+ {
188
+ id: 'padding',
189
+ title: 'Padding',
190
+ icon: 'carbon:area',
191
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
192
+ tokens: config.theme.padding,
193
+ getName: key => \`\${config.prefix ?? ''}p-\${key}\`,
194
+ }, ({ token }) => h('div', {
195
+ class: '__hst-padding',
196
+ style: {
197
+ padding: token.value,
198
+ },
199
+ }, [
200
+ h('div', {
201
+ class: '__hst-padding-box',
202
+ }),
203
+ ]))),
204
+ },
205
+ {
206
+ id: 'margin',
207
+ title: 'Margin',
208
+ icon: 'carbon:area',
209
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
210
+ tokens: config.theme.margin,
211
+ getName: key => \`\${config.prefix ?? ''}m-\${key}\`,
212
+ }, ({ token }) => h('div', {
213
+ class: '__hst-margin',
214
+ }, [
215
+ h('div', {
216
+ class: '__hst-margin-box',
217
+ style: {
218
+ margin: token.value,
219
+ },
220
+ }),
221
+ ]))),
222
+ },
223
+ {
224
+ id: 'font-size',
225
+ title: 'Font Size',
226
+ icon: 'carbon:text-font',
227
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
228
+ tokens: config.theme.fontSize,
229
+ getName: key => \`\${config.prefix ?? ''}text-\${key}\`,
230
+ }, ({ token }) => h('div', {
231
+ class: '__hst-truncate',
232
+ style: {
233
+ fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
234
+ ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
235
+ },
236
+ }, sampleText.value))),
237
+ onMountControls: (api) => mountApp(api, () => [
238
+ h(HstTextarea, {
239
+ title: 'Sample text',
240
+ modelValue: sampleText.value,
241
+ 'onUpdate:modelValue': value => { sampleText.value = value },
242
+ rows: 5,
243
+ }),
244
+ ]),
245
+ },
246
+ {
247
+ id: 'font-weight',
248
+ title: 'Font Weight',
249
+ icon: 'carbon:text-font',
250
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
251
+ tokens: config.theme.fontWeight,
252
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
253
+ }, ({ token }) => h('div', {
254
+ class: '__hst-truncate',
255
+ style: {
256
+ fontWeight: token.value,
257
+ fontSize: \`\${fontSize.value}px\`,
258
+ },
259
+ }, sampleText.value))),
260
+ onMountControls: (api) => mountApp(api, () => [
261
+ h(HstTextarea, {
262
+ title: 'Sample text',
263
+ modelValue: sampleText.value,
264
+ 'onUpdate:modelValue': value => { sampleText.value = value },
265
+ rows: 5,
266
+ }),
267
+ h(HstNumber, {
268
+ title: 'Font size',
269
+ modelValue: fontSize.value,
270
+ 'onUpdate:modelValue': value => { fontSize.value = value },
271
+ min: 1,
272
+ }),
273
+ ]),
274
+ },
275
+ {
276
+ id: 'font-family',
277
+ title: 'Font Family',
278
+ icon: 'carbon:text-font',
279
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
280
+ tokens: config.theme.fontFamily,
281
+ getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
282
+ }, ({ token }) => h('div', {
283
+ class: '__hst-truncate',
284
+ style: {
285
+ fontFamily: token.value,
286
+ fontSize: \`\${fontSize.value}px\`,
287
+ },
288
+ }, sampleText.value))),
289
+ onMountControls: (api) => mountApp(api, () => [
290
+ h(HstTextarea, {
291
+ title: 'Sample text',
292
+ modelValue: sampleText.value,
293
+ 'onUpdate:modelValue': value => { sampleText.value = value },
294
+ rows: 5,
295
+ }),
296
+ h(HstNumber, {
297
+ title: 'Font size',
298
+ modelValue: fontSize.value,
299
+ 'onUpdate:modelValue': value => { fontSize.value = value },
300
+ min: 1,
301
+ }),
302
+ ]),
303
+ },
304
+ {
305
+ id: 'letter-spacing',
306
+ title: 'Letter Spacing',
307
+ icon: 'carbon:text-font',
308
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
309
+ tokens: config.theme.letterSpacing,
310
+ getName: key => \`\${config.prefix ?? ''}tracking-\${key}\`,
311
+ }, ({ token }) => h('div', {
312
+ class: '__hst-truncate',
313
+ style: {
314
+ letterSpacing: token.value,
315
+ fontSize: \`\${fontSize.value}px\`,
316
+ },
317
+ }, sampleText.value))),
318
+ onMountControls: (api) => mountApp(api, () => [
319
+ h(HstTextarea, {
320
+ title: 'Sample text',
321
+ modelValue: sampleText.value,
322
+ 'onUpdate:modelValue': value => { sampleText.value = value },
323
+ rows: 5,
324
+ }),
325
+ h(HstNumber, {
326
+ title: 'Font size',
327
+ modelValue: fontSize.value,
328
+ 'onUpdate:modelValue': value => { fontSize.value = value },
329
+ min: 1,
330
+ }),
331
+ ]),
332
+ },
333
+ {
334
+ id: 'line-height',
335
+ title: 'Line Height',
336
+ icon: 'carbon:text-font',
337
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
338
+ tokens: config.theme.lineHeight,
339
+ getName: key => \`\${config.prefix ?? ''}leading-\${key}\`,
340
+ }, ({ token }) => h('div', {
341
+ style: {
342
+ lineHeight: token.value,
343
+ },
344
+ }, sampleText.value))),
345
+ onMountControls: (api) => mountApp(api, () => [
346
+ h(HstTextarea, {
347
+ title: 'Sample text',
348
+ modelValue: sampleText.value,
349
+ 'onUpdate:modelValue': value => { sampleText.value = value },
350
+ rows: 5,
351
+ }),
352
+ // @TODO select font size
353
+ ]),
354
+ },
355
+ {
356
+ id: 'drop-shadow',
357
+ title: 'Drop Shadow',
358
+ icon: 'carbon:shape-except',
359
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
360
+ tokens: config.theme.dropShadow,
361
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
362
+ colSize: 180,
363
+ }, ({ token }) => h('div', {
364
+ class: '__hst-drop-shadow',
365
+ style: {
366
+ filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
367
+ },
368
+ }))),
369
+ },
370
+ {
371
+ id: 'border-radius',
372
+ title: 'Border Radius',
373
+ icon: 'carbon:condition-wait-point',
374
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
375
+ tokens: config.theme.borderRadius,
376
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
377
+ colSize: 180,
378
+ }, ({ token }) => h('div', {
379
+ class: '__hst-border-radius',
380
+ style: {
381
+ borderRadius: token.value,
382
+ },
383
+ }))),
384
+ },
385
+ {
386
+ id: 'border-width',
387
+ title: 'Border Width',
388
+ icon: 'carbon:checkbox',
389
+ onMount: (api) => mountApp(api, () => h(HstTokenGrid, {
390
+ tokens: config.theme.borderWidth,
391
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
392
+ colSize: 180,
393
+ }, ({ token }) => h('div', {
394
+ class: '__hst-border-width',
395
+ style: {
396
+ borderWidth: token.value,
397
+ },
398
+ }))),
399
+ },
400
+ {
401
+ id: 'width',
402
+ title: 'Width',
403
+ icon: 'carbon:pan-horizontal',
404
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
405
+ tokens: config.theme.width,
406
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
407
+ }, ({ token }) => h('div', {
408
+ class: '__hst-width',
409
+ }, [
410
+ h('div', {
411
+ class: '__hst-width-box',
412
+ style: {
413
+ width: token.value,
414
+ },
415
+ }),
416
+ ]))),
417
+ },
418
+ {
419
+ id: 'height',
420
+ title: 'Height',
421
+ icon: 'carbon:pan-vertical',
422
+ onMount: (api) => mountApp(api, () => h(HstTokenList, {
423
+ tokens: config.theme.height,
424
+ getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
425
+ }, ({ token }) => h('div', {
426
+ class: '__hst-height',
427
+ style: {
428
+ height: token.value,
429
+ },
430
+ }))),
431
+ },
432
+ {
433
+ id: 'full-config',
434
+ title: 'Full Config',
435
+ icon: 'carbon:code',
436
+ onMount: (api) => mountApp(api, () => h('pre', JSON.stringify(config, null, 2))),
437
+ },
438
+ ],
439
+ }`;
440
+ }
441
+ const css = `.__hst-shade {
442
+ height: 80px;
443
+ border-radius: 4px;
444
+ }
445
+
446
+ .__hst-text {
447
+ font-size: 4rem;
448
+ display: flex;
449
+ align-items: flex-end;
450
+ }
451
+
452
+ .__hst-border {
453
+ border-style: solid;
454
+ border-width: 2px;
455
+ }
456
+
457
+ .__hst-padding {
458
+ background-color: rgb(113 113 122 / 0.1);
459
+ width: min-content;
460
+ }
461
+
462
+ .__hst-margin {
463
+ border: dashed 1px rgb(113 113 122 / 0.5);
464
+ width: min-content;
465
+ }
466
+
467
+ .__hst-padding-box,
468
+ .__hst-margin-box {
469
+ width: 5rem;
470
+ height: 5rem;
471
+ background-color: rgb(113 113 122 / 0.5);
472
+ }
473
+
474
+ .__hst-padding,
475
+ .__hst-padding-box,
476
+ .__hst-margin,
477
+ .__hst-margin-box,
478
+ .__hst-drop-shadow {
479
+ border-radius: 4px;
480
+ }
481
+
482
+ .__hst-truncate {
483
+ overflow: hidden;
484
+ text-overflow: ellipsis;
485
+ white-space: nowrap;
486
+ }
487
+
488
+ .__hst-drop-shadow {
489
+ width: 8rem;
490
+ height: 8rem;
491
+ background: white;
492
+ margin-bottom: 0.5rem;
493
+ }
494
+
495
+ .__hst-drop-shadow {
496
+ background: #4e4e57;
497
+ }
498
+
499
+ .__hst-border-radius {
500
+ width: 8rem;
501
+ height: 8rem;
502
+ background-color: rgb(113 113 122 / 0.5);
503
+ }
504
+
505
+ .__hst-border-width {
506
+ width: 8rem;
507
+ height: 8rem;
508
+ border-color: rgb(113 113 122 / 0.5);
509
+ background-color: rgb(113 113 122 / 0.1);
510
+ }
511
+
512
+ .__hst-width {
513
+ background-color: rgb(113 113 122 / 0.1);
514
+ }
515
+
516
+ .__hst-width-box,
517
+ .__hst-height {
518
+ background-color: rgb(113 113 122 / 0.5);
519
+ }
520
+
521
+ .__hst-width-box {
522
+ height: 5rem;
523
+ }`;
@@ -0,0 +1,15 @@
1
+ import type { Story } from '@poveste/shared';
2
+ import type { PropType as _PropType } from '@poveste/vendors/vue';
3
+ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ExtractPropTypes<{
4
+ story: {
5
+ type: _PropType<Story>;
6
+ required: true;
7
+ };
8
+ }>, void, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<{
9
+ story: {
10
+ type: _PropType<Story>;
11
+ required: true;
12
+ };
13
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
14
+ export default _default;
15
+ //# sourceMappingURL=MountStory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MountStory.d.ts","sourceRoot":"","sources":["../../../../src/node/builtin-plugins/vanilla-support/MountStory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;;;cAS3C,SAAS,CAAC,KAAK,CAAC;;;;;cAAhB,SAAS,CAAC,KAAK,CAAC;;;;AALtC,wBA2CE"}
@@ -0,0 +1,39 @@
1
+ import { defineComponent as _defineComponent } from '@poveste/vendors/vue';
2
+ export default _defineComponent({
3
+ name: 'MountStory',
4
+ props: {
5
+ story: {
6
+ type: Object,
7
+ required: true,
8
+ },
9
+ },
10
+ setup(props) {
11
+ const options = props.story.file.component;
12
+ let rawVariants = [];
13
+ if (options.onMount) {
14
+ rawVariants = [{
15
+ id: '_default',
16
+ title: 'default',
17
+ onMount: options.onMount,
18
+ onMountControls: options.onMountControls,
19
+ }];
20
+ }
21
+ else {
22
+ rawVariants = options.variants;
23
+ }
24
+ for (const index in props.story.variants) {
25
+ const rawVariant = rawVariants[index];
26
+ Object.assign(props.story.variants[index], {
27
+ slots: () => ({ default: rawVariant.onMount, controls: rawVariant.onMountControls }),
28
+ source: rawVariant.source ?? options.source,
29
+ responsiveDisabled: rawVariant.responsiveDisabled ?? options.responsiveDisabled,
30
+ autoPropsDisabled: rawVariant.autoPropsDisabled ?? options.autoPropsDisabled,
31
+ setupApp: rawVariant.setupApp ?? options.setupApp,
32
+ configReady: true,
33
+ });
34
+ }
35
+ },
36
+ render() {
37
+ return null;
38
+ },
39
+ });
@@ -0,0 +1,39 @@
1
+ import type { Story, Variant } from '@poveste/shared';
2
+ import type { PropType as _PropType } from '@poveste/vendors/vue';
3
+ declare const _default: import("@vue/runtime-core").DefineComponent<import("@vue/runtime-core").ExtractPropTypes<{
4
+ variant: {
5
+ type: _PropType<Variant>;
6
+ required: true;
7
+ };
8
+ story: {
9
+ type: _PropType<Story>;
10
+ required: true;
11
+ };
12
+ slotName: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ }>, {
17
+ sandbox: import("@vue/reactivity").Ref<HTMLDivElement, HTMLDivElement>;
18
+ }, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {
19
+ ready: () => true;
20
+ }, string, import("@vue/runtime-core").PublicProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<{
21
+ variant: {
22
+ type: _PropType<Variant>;
23
+ required: true;
24
+ };
25
+ story: {
26
+ type: _PropType<Story>;
27
+ required: true;
28
+ };
29
+ slotName: {
30
+ type: StringConstructor;
31
+ default: string;
32
+ };
33
+ }>> & Readonly<{
34
+ onReady?: () => any;
35
+ }>, {
36
+ slotName: string;
37
+ }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
38
+ export default _default;
39
+ //# sourceMappingURL=RenderStory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderStory.d.ts","sourceRoot":"","sources":["../../../../src/node/builtin-plugins/vanilla-support/RenderStory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;;;cAoB3C,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;cALhB,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;AAVtC,wBAmJE"}