@vueless/storybook 1.2.1-beta.3 → 1.2.1-beta.4

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.
@@ -1,5 +1,5 @@
1
1
  /** @type { import('@storybook/vue3-vite').StorybookConfig } */
2
- import { defineConfigWithVueless } from "vueless/storybook";
2
+ import { defineConfigWithVueless } from "@vueless/storybook";
3
3
 
4
4
  export default defineConfigWithVueless({
5
5
  stories: [
@@ -1,5 +1,5 @@
1
1
  /** @type { import('@storybook/vue3-vite').StorybookConfig } */
2
- import { defineConfigWithVueless } from "vueless/storybook";
2
+ import { defineConfigWithVueless } from "@vueless/storybook";
3
3
 
4
4
  export default defineConfigWithVueless({
5
5
  stories: [
@@ -1,11 +1,38 @@
1
1
  {
2
- "files": [],
3
- "references": [
4
- {
5
- "path": "./tsconfig.node.json"
6
- },
7
- {
8
- "path": "./tsconfig.app.json"
9
- }
10
- ]
2
+ "include": [
3
+ "**/*"
4
+ ],
5
+ "compilerOptions": {
6
+ /* General */
7
+ "module": "ESNext",
8
+ "target": "ESNext",
9
+ "esModuleInterop": true,
10
+ "useDefineForClassFields": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "verbatimModuleSyntax": true, // This is important for `<script setup>`.
13
+ "tsBuildInfoFile": "./node_modules/.tmp/storybookTsconfig.app.tsbuildinfo",
14
+ "removeComments": true,
15
+ "skipLibCheck": true,
16
+ "composite": true,
17
+ "noEmit": true,
18
+
19
+ /* Path settings */
20
+ "baseUrl": ".",
21
+
22
+ /* Enables all strict type-checking options. */
23
+ "strict": true,
24
+ "noImplicitThis": true,
25
+
26
+ /* Bundlers settings */
27
+ "moduleResolution": "bundler",
28
+ "resolveJsonModule": true,
29
+
30
+ /* JS file support. */
31
+ "allowJs": true,
32
+
33
+ "types": [
34
+ "vite/client",
35
+ "vueless/modules"
36
+ ]
37
+ }
11
38
  }
package/bin/index.js CHANGED
File without changes
package/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
+ import { UnknownObject } from "vueless";
2
+
1
3
  export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator";
2
4
  export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator";
5
+
6
+ export declare function defineConfigWithVueless(options?: UnknownObject): () => UnknownObject;
7
+ export function getVuelessStoriesGlob(vuelessEnv?: string): Promise<string[]>;
package/index.js CHANGED
@@ -1,2 +1,89 @@
1
1
  export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator";
2
2
  export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator";
3
+
4
+ import { getVuelessConfig } from "vueless/utils/node/vuelessConfig.js";
5
+ import {
6
+ COMPONENTS,
7
+ DIRECTIVES,
8
+ INTERNAL_ENV,
9
+ VUELESS_LOCAL_DIR,
10
+ VUELESS_PACKAGE_DIR,
11
+ } from "vueless/constants.js";
12
+
13
+ /**
14
+ * Defines the config for Storybook.
15
+ *
16
+ * @param {Object} config - The config object.
17
+ * @return {Promise<Object>} A promise that resolves to the modified config object.
18
+ */
19
+ export function defineConfigWithVueless(config) {
20
+ return (async () => ({
21
+ ...config,
22
+ stories: [...config.stories, ...(await getVuelessStoriesGlob(config?.vuelessEnv))],
23
+ addons: [
24
+ ...new Set([
25
+ ...(config.addons || []),
26
+ "@storybook/addon-docs",
27
+ "@storybook/addon-links",
28
+ "@vueless/storybook-dark-mode",
29
+ "@storybook/addon-themes",
30
+ ]),
31
+ ],
32
+ staticDirs: ["public"],
33
+ framework: {
34
+ ...config.framework,
35
+ name: "@storybook/vue3-vite",
36
+ options: {
37
+ ...config.framework?.options,
38
+ builder: {
39
+ ...config.framework?.options?.builder,
40
+ viteConfigPath: ".storybook/vite.config.js",
41
+ },
42
+ },
43
+ },
44
+ env: (envConfig) => ({
45
+ ...envConfig,
46
+ BASE_URL: "/",
47
+ }),
48
+ }))();
49
+ }
50
+
51
+ /**
52
+ * Retrieves the glob pattern for Vueless stories based on the provided Vueless environment.
53
+ *
54
+ * @param {string} vuelessEnv - The Vueless environment.
55
+ * @return {Promise<string[]>} A promise that resolves to an array of glob patterns for Vueless stories.
56
+ */
57
+ async function getVuelessStoriesGlob(vuelessEnv) {
58
+ const vuelessSrcDir = vuelessEnv === INTERNAL_ENV ? VUELESS_LOCAL_DIR : VUELESS_PACKAGE_DIR;
59
+ const vuelessConfig = await getVuelessConfig();
60
+ const storiesGlob = [];
61
+
62
+ for (const [directiveName, directiveDir] of Object.entries(DIRECTIVES)) {
63
+ const directiveGlobalConfig = vuelessConfig.directives?.[directiveName];
64
+ const isHiddenStoriesByDirective = directiveGlobalConfig === false;
65
+ const isHiddenStoriesByKey = directiveGlobalConfig?.storybook === false;
66
+
67
+ if (isHiddenStoriesByDirective || isHiddenStoriesByKey) {
68
+ continue;
69
+ }
70
+
71
+ storiesGlob.push(`../${vuelessSrcDir}/${directiveDir}/storybook/stories.{js,ts}`);
72
+ storiesGlob.push(`../${vuelessSrcDir}/${directiveDir}/storybook/docs.mdx`);
73
+ }
74
+
75
+ for (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
76
+ const componentGlobalConfig = vuelessConfig.components?.[componentName];
77
+ const isHiddenStoriesByComponent = componentGlobalConfig === false;
78
+ const isHiddenStoriesByKey = componentGlobalConfig?.storybook === false;
79
+
80
+ if (isHiddenStoriesByComponent || isHiddenStoriesByKey) {
81
+ continue;
82
+ }
83
+
84
+ storiesGlob.push(`../${vuelessSrcDir}/${componentDir}/storybook/stories.{js,ts}`);
85
+ storiesGlob.push(`../${vuelessSrcDir}/${componentDir}/storybook/docs.mdx`);
86
+ }
87
+
88
+ return storiesGlob;
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/storybook",
3
- "version": "1.2.1-beta.3",
3
+ "version": "1.2.1-beta.4",
4
4
  "description": "Simplifies Storybook configuration for Vueless UI library.",
5
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
6
  "homepage": "https://vueless.com",
@@ -1,10 +0,0 @@
1
- /// <reference lib="dom" />
2
- /// <reference lib="dom.iterable" />
3
- /// <reference types="vite/client" />
4
- /// <reference types="vueless/modules" />
5
-
6
- declare module "@vueless/storybook" {
7
- import type { UnknownObject } from "vueless";
8
- export function storyDarkModeDecorator(): Promise<UnknownObject>;
9
- export function vue3SourceDecorator(): Promise<UnknownObject>;
10
- }
@@ -1,34 +0,0 @@
1
- {
2
- "include": [
3
- "env.d.ts",
4
- "**/*"
5
- ],
6
- "compilerOptions": {
7
- /* General */
8
- "module": "ESNext",
9
- "target": "ESNext",
10
- "esModuleInterop": true,
11
- "useDefineForClassFields": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "verbatimModuleSyntax": true, // This is important for `<script setup>`.
14
- "tsBuildInfoFile": "./node_modules/.tmp/storybookTsconfig.app.tsbuildinfo",
15
- "removeComments": true,
16
- "skipLibCheck": true,
17
- "composite": true,
18
- "noEmit": true,
19
-
20
- /* Path settings */
21
- "baseUrl": ".",
22
-
23
- /* Enables all strict type-checking options. */
24
- "strict": true,
25
- "noImplicitThis": true,
26
-
27
- /* Bundlers settings */
28
- "moduleResolution": "bundler",
29
- "resolveJsonModule": true,
30
-
31
- /* JS file support. */
32
- "allowJs": true
33
- }
34
- }
@@ -1,13 +0,0 @@
1
- {
2
- "include": [
3
- "vite.config.*"
4
- ],
5
- "compilerOptions": {
6
- "module": "ESNext",
7
- "noEmit": true,
8
- "composite": true,
9
- "tsBuildInfoFile": "./node_modules/.tmp/storybookTsconfig.node.tsbuildinfo",
10
- "moduleResolution": "Bundler"
11
- },
12
-
13
- }