@voiceflow/storybook-config 1.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.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # storybook-config
2
+
3
+ ## Install
4
+
5
+ Make sure the version of `storybook` installed matches the version specified in the `peerDependencies` of this package.
6
+ Storybook enforces that addons and the core package must be the same version.
7
+
8
+ ```bash
9
+ yarn add --exact -D @voiceflow/storybook-config storybook
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ Update the following files to enable the configuration
15
+
16
+ ```ts
17
+ // .storybook/main.ts
18
+
19
+ export { default } from '@voiceflow/storybook-config';
20
+ ```
21
+
22
+ ```ts
23
+ // .storybook/manager.ts
24
+
25
+ import '@voiceflow/storybook-config/setup';
26
+ ```
27
+
28
+ ```ts
29
+ // .storybook/preview.tsx
30
+
31
+ import type { Preview } from '@storybook/react';
32
+ import { TestIDs, useTestIDs } from '@voiceflow/storybook-config/plugins';
33
+ import React from 'react';
34
+
35
+ const preview: Preview = {
36
+ globalTypes: {
37
+ showTestIDs: TestIDs,
38
+ },
39
+
40
+ decorators: [
41
+ (Story, context) => {
42
+ useTestIDs(context.globals.showTestIDs);
43
+
44
+ return <Story />;
45
+ },
46
+ ],
47
+ };
48
+
49
+ export default preview;
50
+ ```
@@ -0,0 +1,4 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite';
2
+ declare const config: StorybookConfig;
3
+ export default config;
4
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQ7D,QAAA,MAAM,MAAM,EAAE,eAmBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/build/main.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_path_1 = require("node:path");
4
+ /**
5
+ * This function is used to resolve the absolute path of a package.
6
+ * It is needed in projects that use Yarn PnP or are set up within a monorepo.
7
+ */
8
+ const getAbsolutePath = (value) => (0, node_path_1.dirname)(require.resolve((0, node_path_1.join)(value, 'package.json')));
9
+ const config = {
10
+ stories: ['../src/**/*.mdx', '../src/**/*.story.@(js|jsx|ts|tsx)'],
11
+ addons: [
12
+ getAbsolutePath('storybook-addon-pseudo-states'),
13
+ getAbsolutePath('@storybook/addon-links'),
14
+ getAbsolutePath('@storybook/addon-essentials'),
15
+ getAbsolutePath('@storybook/addon-interactions'),
16
+ getAbsolutePath('storybook-dark-mode'),
17
+ ],
18
+ framework: {
19
+ name: getAbsolutePath('@storybook/react-vite'),
20
+ options: {},
21
+ },
22
+ docs: {
23
+ autodocs: 'tag',
24
+ },
25
+ core: {
26
+ builder: getAbsolutePath('@storybook/builder-vite'),
27
+ },
28
+ };
29
+ exports.default = config;
30
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAI1C;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAa,EAAO,EAAE,CAAC,IAAA,mBAAO,EAAC,OAAO,CAAC,OAAO,CAAC,IAAA,gBAAI,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAEtG,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,CAAC,iBAAiB,EAAE,oCAAoC,CAAC;IAClE,MAAM,EAAE;QACN,eAAe,CAAC,+BAA+B,CAAC;QAChD,eAAe,CAAC,wBAAwB,CAAC;QACzC,eAAe,CAAC,6BAA6B,CAAC;QAC9C,eAAe,CAAC,+BAA+B,CAAC;QAChD,eAAe,CAAC,qBAAqB,CAAC;KACvC;IACD,SAAS,EAAE;QACT,IAAI,EAAE,eAAe,CAAC,uBAAuB,CAAC;QAC9C,OAAO,EAAE,EAAE;KACZ;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,eAAe,CAAC,yBAAyB,CAAC;KACpD;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './test-ids';
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/plugins/main.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./test-ids"), exports);
18
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/plugins/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
@@ -0,0 +1,15 @@
1
+ export declare const TestIDs: {
2
+ description: string;
3
+ defaultValue: boolean;
4
+ toolbar: {
5
+ title: string;
6
+ icon: string;
7
+ items: {
8
+ value: boolean;
9
+ icon: string;
10
+ title: string;
11
+ }[];
12
+ };
13
+ };
14
+ export declare const useTestIDs: (showTestIDs: boolean) => void;
15
+ //# sourceMappingURL=test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-ids.d.ts","sourceRoot":"","sources":["../../src/plugins/test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;;;;;;;;;;;CAWnB,CAAC;AAEF,eAAO,MAAM,UAAU,gBAAiB,OAAO,SA8D5B,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTestIDs = exports.TestIDs = void 0;
4
+ const react_1 = require("react");
5
+ exports.TestIDs = {
6
+ description: 'Highlights elements with data-testid properties',
7
+ defaultValue: false,
8
+ toolbar: {
9
+ title: 'Test IDs',
10
+ icon: 'eye',
11
+ items: [
12
+ { value: true, icon: 'eye', title: 'On' },
13
+ { value: false, icon: 'eyeclose', title: 'Off' },
14
+ ],
15
+ },
16
+ };
17
+ const useTestIDs = (showTestIDs) => (0, react_1.useEffect)(() => {
18
+ if (!showTestIDs)
19
+ return undefined;
20
+ const elements = Array.from(document.querySelectorAll('[data-testid]'));
21
+ const highlights = [];
22
+ const label = document.createElement('label');
23
+ const prefix = document.createElement('span');
24
+ const text = document.createElement('span');
25
+ const suffix = document.createElement('span');
26
+ label.style.position = 'absolute';
27
+ label.style.left = '50%';
28
+ label.style.transform = 'translateX(-50%)';
29
+ label.style.top = '50%';
30
+ label.style.userSelect = 'none';
31
+ label.style.visibility = 'hidden';
32
+ label.style.background = '#fff';
33
+ prefix.style.opacity = '50%';
34
+ prefix.textContent = 'data-testid="';
35
+ suffix.style.opacity = '50%';
36
+ suffix.textContent = '"';
37
+ label.appendChild(prefix);
38
+ label.appendChild(text);
39
+ label.appendChild(suffix);
40
+ elements.forEach((element) => {
41
+ const highlight = document.createElement('div');
42
+ const rect = element.getBoundingClientRect();
43
+ highlights.push(highlight);
44
+ highlight.style.position = 'absolute';
45
+ highlight.style.left = `${rect.left}px`;
46
+ highlight.style.top = `${rect.top}px`;
47
+ highlight.style.width = `${rect.width}px`;
48
+ highlight.style.height = `${rect.height}px`;
49
+ highlight.style.border = '1px solid green';
50
+ highlight.style.textOverflow = 'overflow';
51
+ highlight.onmouseover = () => {
52
+ text.textContent = element.dataset.testid ?? '';
53
+ label.style.visibility = 'visible';
54
+ };
55
+ highlight.onmouseout = () => {
56
+ text.textContent = '';
57
+ label.style.visibility = 'hidden';
58
+ };
59
+ document.body.appendChild(highlight);
60
+ });
61
+ document.body.appendChild(label);
62
+ return () => {
63
+ highlights.forEach((element) => document.body.removeChild(element));
64
+ document.body.removeChild(label);
65
+ };
66
+ }, [showTestIDs]);
67
+ exports.useTestIDs = useTestIDs;
68
+ //# sourceMappingURL=test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-ids.js","sourceRoot":"","sources":["../../src/plugins/test-ids.ts"],"names":[],"mappings":";;;AAAA,iCAAkC;AAErB,QAAA,OAAO,GAAG;IACrB,WAAW,EAAE,iDAAiD;IAC9D,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE;QACP,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,KAAK;QACX,KAAK,EAAE;YACL,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;YACzC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;SACjD;KACF;CACF,CAAC;AAEK,MAAM,UAAU,GAAG,CAAC,WAAoB,EAAE,EAAE,CACjD,IAAA,iBAAS,EAAC,GAAG,EAAE;IACb,IAAI,CAAC,WAAW;QAAE,OAAO,SAAS,CAAC;IAEnC,MAAM,QAAQ,GAAkB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;IACvF,MAAM,UAAU,GAAkB,EAAE,CAAC;IAErC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,M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
2
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":""}
package/build/setup.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const manager_api_1 = require("@storybook/manager-api");
4
+ manager_api_1.addons.setConfig({
5
+ isFullscreen: false,
6
+ showNav: true,
7
+ showPanel: true,
8
+ panelPosition: 'bottom',
9
+ enableShortcuts: true,
10
+ showToolbar: true,
11
+ theme: undefined,
12
+ selectedPanel: undefined,
13
+ initialActive: 'sidebar',
14
+ sidebar: {
15
+ showRoots: false,
16
+ collapsedRoots: ['other'],
17
+ },
18
+ toolbar: {
19
+ title: { hidden: false },
20
+ zoom: { hidden: false },
21
+ eject: { hidden: false },
22
+ copy: { hidden: false },
23
+ fullscreen: { hidden: false },
24
+ },
25
+ });
26
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;AAAA,wDAAgD;AAEhD,oBAAM,CAAC,SAAS,CAAC;IACf,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,QAAQ;IACvB,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,IAAI;IACjB,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,OAAO,EAAE;QACP,SAAS,EAAE,KAAK;QAChB,cAAc,EAAE,CAAC,OAAO,CAAC;KAC1B;IACD,OAAO,EAAE;QACP,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACxB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACvB,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACxB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;QACvB,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;KAC9B;CACF,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@voiceflow/storybook-config",
3
+ "version": "1.1.0",
4
+ "exports": {
5
+ ".": "./build/main.js",
6
+ "./setup": "./build/setup.js",
7
+ "./plugins": "./build/plugins/main.js"
8
+ },
9
+ "main": "build/main.js",
10
+ "types": "build/main.d.ts",
11
+ "files": [
12
+ "build"
13
+ ],
14
+ "scripts": {
15
+ "build": "yarn g:build:pkg",
16
+ "clean": "yarn g:rimraf build",
17
+ "lint": "yarn g:run-p -c lint:eslint lint:prettier",
18
+ "lint:eslint": "yarn g:eslint",
19
+ "lint:fix": "yarn g:run-p -c \"lint:eslint --fix\" \"lint:prettier --write\"",
20
+ "lint:prettier": "yarn g:prettier --check"
21
+ },
22
+ "dependencies": {
23
+ "@storybook/addon-essentials": "8.5.0",
24
+ "@storybook/addon-interactions": "8.5.0",
25
+ "@storybook/addon-links": "8.5.0",
26
+ "@storybook/blocks": "8.5.0",
27
+ "@storybook/builder-vite": "8.5.0",
28
+ "@storybook/cli": "8.5.0",
29
+ "@storybook/react": "8.5.0",
30
+ "@storybook/react-vite": "8.5.0",
31
+ "@storybook/test": "8.5.0",
32
+ "@storybook/testing-library": "0.2.2",
33
+ "@storybook/types": "8.5.0",
34
+ "storybook-addon-pseudo-states": "4.0.2",
35
+ "storybook-dark-mode": "4.0.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "18.2.77"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18",
42
+ "storybook": "8.5.0"
43
+ },
44
+ "engines": {
45
+ "node": "20"
46
+ },
47
+ "volta": {
48
+ "extends": "../../package.json"
49
+ },
50
+ "gitHead": "7283bc2bd5d8610e97447f7f59d8ee2824dc9c6f"
51
+ }