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

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
  @import "tailwindcss";
2
- @import "vueless";
2
+ @import "vueless/tailwind.css";
3
3
 
4
4
  /* -------------------- Storybook Preview UI -------------------- */
5
5
  /* -------------------- General -------------------- */
@@ -2,7 +2,7 @@ import { defineConfig } from "vite";
2
2
 
3
3
  // Plugins
4
4
  import Vue from "@vitejs/plugin-vue";
5
- import { Vueless, TailwindCSS } from "vueless/plugin-vite";
5
+ import { Vueless, TailwindCSS } from "vueless/plugin-vite.js";
6
6
  import { STORYBOOK_ENV } from "vueless/constants.js";
7
7
 
8
8
  export default defineConfig({
@@ -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
  @import "tailwindcss";
2
- @import "vueless";
2
+ @import "vueless/tailwind.css";
3
3
 
4
4
  /* -------------------- Storybook Preview UI -------------------- */
5
5
  /* -------------------- General -------------------- */
@@ -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
  }
@@ -2,7 +2,7 @@ import { defineConfig } from "vite";
2
2
 
3
3
  // Plugins
4
4
  import Vue from "@vitejs/plugin-vue";
5
- import { Vueless, TailwindCSS } from "vueless/plugin-vite";
5
+ import { Vueless, TailwindCSS } from "vueless/plugin-vite.js";
6
6
  import { STORYBOOK_ENV } from "vueless/constants.js";
7
7
 
8
8
  export default defineConfig({
package/README.md CHANGED
@@ -16,7 +16,7 @@ npm install vueless
16
16
  npm install -D @vueless/storybook
17
17
 
18
18
  # Copy Vueless Storybook preset into your project.
19
- npx @vueless/storybook
19
+ npx @vueless/storybook init
20
20
  ```
21
21
 
22
22
  ## Contributing
package/bin/index.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator.js";
2
+ export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator.js";
package/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator";
2
- export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator";
1
+ export declare function defineConfigWithVueless(options?: any): () => any;
2
+ export declare function getVuelessStoriesGlob(vuelessEnv?: string): Promise<string[]>;
3
+
4
+ export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator.js";
5
+ export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator.js";
package/index.js CHANGED
@@ -1,2 +1,88 @@
1
- export { storyDarkModeDecorator } from "./decorators/storyDarkModeDecorator";
2
- export { vue3SourceDecorator } from "./decorators/vue3SourceDecorator";
1
+ export { buildWebTypes } from "./webTypes/index.js";
2
+
3
+ import { getVuelessConfig } from "vueless/utils/node/vuelessConfig.js";
4
+ import {
5
+ COMPONENTS,
6
+ DIRECTIVES,
7
+ INTERNAL_ENV,
8
+ VUELESS_LOCAL_DIR,
9
+ VUELESS_PACKAGE_DIR,
10
+ } from "vueless/constants.js";
11
+
12
+ /**
13
+ * Defines the config for Storybook.
14
+ *
15
+ * @param {Object} config - The config object.
16
+ * @return {Promise<Object>} A promise that resolves to the modified config object.
17
+ */
18
+ export function defineConfigWithVueless(config) {
19
+ return (async () => ({
20
+ ...config,
21
+ stories: [...config.stories, ...(await getVuelessStoriesGlob(config?.vuelessEnv))],
22
+ addons: [
23
+ ...new Set([
24
+ ...(config.addons || []),
25
+ "@storybook/addon-docs",
26
+ "@storybook/addon-links",
27
+ "@vueless/storybook-dark-mode",
28
+ "@storybook/addon-themes",
29
+ ]),
30
+ ],
31
+ staticDirs: ["public"],
32
+ framework: {
33
+ ...config.framework,
34
+ name: "@storybook/vue3-vite",
35
+ options: {
36
+ ...config.framework?.options,
37
+ builder: {
38
+ ...config.framework?.options?.builder,
39
+ viteConfigPath: ".storybook/vite.config.js",
40
+ },
41
+ },
42
+ },
43
+ env: (envConfig) => ({
44
+ ...envConfig,
45
+ BASE_URL: "/",
46
+ }),
47
+ }))();
48
+ }
49
+
50
+ /**
51
+ * Retrieves the glob pattern for Vueless stories based on the provided Vueless environment.
52
+ *
53
+ * @param {string} vuelessEnv - The Vueless environment.
54
+ * @return {Promise<string[]>} A promise that resolves to an array of glob patterns for Vueless stories.
55
+ */
56
+ async function getVuelessStoriesGlob(vuelessEnv) {
57
+ const vuelessSrcDir = vuelessEnv === INTERNAL_ENV ? VUELESS_LOCAL_DIR : VUELESS_PACKAGE_DIR;
58
+ const vuelessConfig = await getVuelessConfig();
59
+ const storiesGlob = [];
60
+
61
+ for (const [directiveName, directiveDir] of Object.entries(DIRECTIVES)) {
62
+ const directiveGlobalConfig = vuelessConfig.directives?.[directiveName];
63
+ const isHiddenStoriesByDirective = directiveGlobalConfig === false;
64
+ const isHiddenStoriesByKey = directiveGlobalConfig?.storybook === false;
65
+
66
+ if (isHiddenStoriesByDirective || isHiddenStoriesByKey) {
67
+ continue;
68
+ }
69
+
70
+ storiesGlob.push(`../${vuelessSrcDir}/${directiveDir}/storybook/stories.{js,ts}`);
71
+ storiesGlob.push(`../${vuelessSrcDir}/${directiveDir}/storybook/docs.mdx`);
72
+ }
73
+
74
+ for (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
75
+ const componentGlobalConfig = vuelessConfig.components?.[componentName];
76
+ const isHiddenStoriesByComponent = componentGlobalConfig === false;
77
+ const isHiddenStoriesByKey = componentGlobalConfig?.storybook === false;
78
+
79
+ if (isHiddenStoriesByComponent || isHiddenStoriesByKey) {
80
+ continue;
81
+ }
82
+
83
+ storiesGlob.push(`../${vuelessSrcDir}/${componentDir}/storybook/stories.{js,ts}`);
84
+ storiesGlob.push(`../${vuelessSrcDir}/${componentDir}/storybook/docs.mdx`);
85
+ }
86
+
87
+ return storiesGlob;
88
+ }
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@vueless/storybook",
3
- "version": "1.2.1-beta.3",
3
+ "version": "1.2.1-beta.5",
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",
7
7
  "license": "MIT",
8
- "main": "index.js",
9
- "type": "module",
10
8
  "publishConfig": {
11
9
  "access": "public"
12
10
  },
@@ -58,6 +56,16 @@
58
56
  "vue-tsc": "^3.0.6",
59
57
  "vueless": "^1.2.2"
60
58
  },
59
+ "type": "module",
60
+ "main": "index.js",
61
+ "types": "./index.d.ts",
62
+ "exports": {
63
+ ".": {
64
+ "node": "./index.js",
65
+ "types": "./index.d.ts",
66
+ "browser": "./index.browser.js"
67
+ }
68
+ },
61
69
  "overrides": {
62
70
  "vue-docgen-api": {
63
71
  "vue": "latest",
package/webTypes/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { extractConfig } from "./lib/config.js";
3
3
  import build from "./lib/build.js";
4
4
 
5
- export default async function buildWebTypes(vuelessConfig, srcDir) {
5
+ export async function buildWebTypes(vuelessConfig, srcDir) {
6
6
  const config = await extractConfig();
7
7
 
8
8
  build(config, vuelessConfig, srcDir);
@@ -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
- }