@visual-check/storybook 0.0.0 → 0.1.1
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/LICENSE +21 -0
- package/THIRD-PARTY-NOTICES.md +51 -0
- package/dist/angular-port/combinations.d.ts +89 -0
- package/dist/angular-port/combinations.d.ts.map +1 -0
- package/dist/angular-port/combinations.js +97 -0
- package/dist/angular-port/combinations.js.map +1 -0
- package/dist/angular.d.ts +4 -0
- package/dist/angular.d.ts.map +1 -0
- package/dist/angular.js +4 -0
- package/dist/angular.js.map +1 -0
- package/dist/dom-port/combinations.d.ts +59 -0
- package/dist/dom-port/combinations.d.ts.map +1 -0
- package/dist/dom-port/combinations.js +137 -0
- package/dist/dom-port/combinations.js.map +1 -0
- package/dist/forced-state/force-states.d.ts +68 -0
- package/dist/forced-state/force-states.d.ts.map +1 -0
- package/dist/forced-state/force-states.js +388 -0
- package/dist/forced-state/force-states.js.map +1 -0
- package/dist/forced-state/forced-states.d.ts +27 -0
- package/dist/forced-state/forced-states.d.ts.map +1 -0
- package/dist/forced-state/forced-states.js +41 -0
- package/dist/forced-state/forced-states.js.map +1 -0
- package/dist/forced-state/prototype-hooks.d.ts +28 -0
- package/dist/forced-state/prototype-hooks.d.ts.map +1 -0
- package/dist/forced-state/prototype-hooks.js +49 -0
- package/dist/forced-state/prototype-hooks.js.map +1 -0
- package/dist/forced-state/style-sheet-rewrite.d.ts +29 -0
- package/dist/forced-state/style-sheet-rewrite.d.ts.map +1 -0
- package/dist/forced-state/style-sheet-rewrite.js +148 -0
- package/dist/forced-state/style-sheet-rewrite.js.map +1 -0
- package/dist/forced-state/twin-selectors.d.ts +21 -0
- package/dist/forced-state/twin-selectors.d.ts.map +1 -0
- package/dist/forced-state/twin-selectors.js +316 -0
- package/dist/forced-state/twin-selectors.js.map +1 -0
- package/dist/grid-story/grid-layout.d.ts +156 -0
- package/dist/grid-story/grid-layout.d.ts.map +1 -0
- package/dist/grid-story/grid-layout.js +163 -0
- package/dist/grid-story/grid-layout.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/per-story-options/define-visual-check.d.ts +247 -0
- package/dist/per-story-options/define-visual-check.d.ts.map +1 -0
- package/dist/per-story-options/define-visual-check.js +60 -0
- package/dist/per-story-options/define-visual-check.js.map +1 -0
- package/dist/react-port/combinations.d.ts +27 -0
- package/dist/react-port/combinations.d.ts.map +1 -0
- package/dist/react-port/combinations.js +45 -0
- package/dist/react-port/combinations.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +4 -0
- package/dist/react.js.map +1 -0
- package/dist/vue-port/combinations.d.ts +35 -0
- package/dist/vue-port/combinations.d.ts.map +1 -0
- package/dist/vue-port/combinations.js +75 -0
- package/dist/vue-port/combinations.js.map +1 -0
- package/dist/vue.d.ts +4 -0
- package/dist/vue.d.ts.map +1 -0
- package/dist/vue.js +4 -0
- package/dist/vue.js.map +1 -0
- package/package.json +78 -4
- package/README.md +0 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AllowedComponentProps, type Component, type ComponentPublicInstance, type VNodeProps } from 'vue';
|
|
2
|
+
import { type GridInput } from '../grid-story/grid-layout.js';
|
|
3
|
+
/**
|
|
4
|
+
* The props a cell's component takes: a component's own props, without the ones Vue adds to every component, or a
|
|
5
|
+
* functional component's parameter.
|
|
6
|
+
*/
|
|
7
|
+
type CellPropsOf<C> = C extends new (...args: never) => {
|
|
8
|
+
$props: infer P;
|
|
9
|
+
} ? Omit<P, keyof VNodeProps | keyof AllowedComponentProps> : C extends (props: infer P, ...args: never) => unknown ? P : Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* What `<Combinations>` takes: the component in every cell, and the grid's inputs, props typed by the component.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface CombinationsProps<C extends Component> extends GridInput<CellPropsOf<C>> {
|
|
16
|
+
/**
|
|
17
|
+
* The component each cell renders, with its row's props. Its props type `props`, `args` and `caption`.
|
|
18
|
+
*/
|
|
19
|
+
component: C;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders one component in every combination of the props it lists, as captioned rows in one grid. The cells are
|
|
23
|
+
* children of the grid in Vue's own tree, with no second app and no Teleport, so what is provided around the grid, and
|
|
24
|
+
* by the app, reaches them. Nothing here depends on Storybook. It works with Vue 3.
|
|
25
|
+
*
|
|
26
|
+
* With `states`, a header row names the columns, and each state cell carries its state's class. The page's stylesheets
|
|
27
|
+
* are rewritten to force those states from just before the grid mounts until it unmounts, and never while rendering on
|
|
28
|
+
* the server.
|
|
29
|
+
*
|
|
30
|
+
* @throws When a prop lists no values, or `states` lists an unknown state or one twice.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const Combinations: new <C extends Component>(props: CombinationsProps<C>) => ComponentPublicInstance<CombinationsProps<C>>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=combinations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinations.d.ts","sourceRoot":"","sources":["../../src/vue-port/combinations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,uBAAuB,EAM5B,KAAK,UAAU,EAEhB,MAAM,KAAK,CAAA;AAGZ,OAAO,EAAE,KAAK,SAAS,EAAgD,MAAM,8BAA8B,CAAA;AAE3G;;;GAGG;AACH,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,KAC9B,GAAG,IAAI,EAAE,KAAK,KACX;IAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACpB,IAAI,CAAC,CAAC,EAAE,MAAM,UAAU,GAAG,MAAM,qBAAqB,CAAC,GACvD,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,GACnD,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAO7B;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,SAAS,CAAE,SAAQ,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACvF;;OAEG;IACH,SAAS,EAAE,CAAC,CAAA;CACb;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,EAiER,KAAK,CAAC,SAAS,SAAS,EACvC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KACxB,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { computed, defineComponent, h, onBeforeMount, onUnmounted, watch, } from 'vue';
|
|
2
|
+
import { forceStates } from '../forced-state/force-states.js';
|
|
3
|
+
import { checkedStatesOf } from '../forced-state/forced-states.js';
|
|
4
|
+
import { gridAttribute, gridLayoutOf } from '../grid-story/grid-layout.js';
|
|
5
|
+
/**
|
|
6
|
+
* Renders one component in every combination of the props it lists, as captioned rows in one grid. The cells are
|
|
7
|
+
* children of the grid in Vue's own tree, with no second app and no Teleport, so what is provided around the grid, and
|
|
8
|
+
* by the app, reaches them. Nothing here depends on Storybook. It works with Vue 3.
|
|
9
|
+
*
|
|
10
|
+
* With `states`, a header row names the columns, and each state cell carries its state's class. The page's stylesheets
|
|
11
|
+
* are rewritten to force those states from just before the grid mounts until it unmounts, and never while rendering on
|
|
12
|
+
* the server.
|
|
13
|
+
*
|
|
14
|
+
* @throws When a prop lists no values, or `states` lists an unknown state or one twice.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export const Combinations = defineComponent({
|
|
18
|
+
// biome-ignore lint/style/useVueMultiWordComponentNames: same name as the React port's <Combinations>
|
|
19
|
+
name: 'Combinations',
|
|
20
|
+
// The grid's element takes no attribute besides its own, as in every other port.
|
|
21
|
+
inheritAttrs: false,
|
|
22
|
+
props: ['component', 'props', 'args', 'cellWidth', 'states', 'caption'],
|
|
23
|
+
setup(props) {
|
|
24
|
+
// Safe enough: templates and TSX check the props through the construct signature below, and `h()` callers are
|
|
25
|
+
// trusted. At runtime the values are taken as `GridInput`, and `gridLayoutOf` validates what matters.
|
|
26
|
+
const input = props;
|
|
27
|
+
// Shared by forcing and the render function. It never throws: Vue reads it outside its error handling when it
|
|
28
|
+
// checks the watcher below before an update, so only the render function throws the layout's error.
|
|
29
|
+
// `gridLayoutOf` reads only the grid's inputs, not `component`.
|
|
30
|
+
const result = computed(() => {
|
|
31
|
+
try {
|
|
32
|
+
return { layout: gridLayoutOf(input) };
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return { error };
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// A string, so forcing stays put across re-renders that list the same states. An invalid layout forces nothing.
|
|
39
|
+
const statesKey = () => ('error' in result.value ? '' : result.value.layout.states.join(' '));
|
|
40
|
+
let stop;
|
|
41
|
+
/**
|
|
42
|
+
* Stops forcing the previous states, then forces the key's, if any.
|
|
43
|
+
*/
|
|
44
|
+
function start(key) {
|
|
45
|
+
const previous = stop;
|
|
46
|
+
stop = undefined;
|
|
47
|
+
previous?.();
|
|
48
|
+
if (key !== '') {
|
|
49
|
+
stop = forceStates(checkedStatesOf(key.split(' '), 'the grid'));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Before mount, so the twins exist before any cell is set up or inserted; SSR never calls it. A states change
|
|
53
|
+
// restarts before the re-render patches the cells, as `watch` flushes before rendering.
|
|
54
|
+
onBeforeMount(() => start(statesKey()));
|
|
55
|
+
watch(statesKey, start);
|
|
56
|
+
onUnmounted(() => stop?.());
|
|
57
|
+
return () => {
|
|
58
|
+
if ('error' in result.value) {
|
|
59
|
+
throw result.value.error;
|
|
60
|
+
}
|
|
61
|
+
const { layout } = result.value;
|
|
62
|
+
return h('div', { [gridAttribute]: '', style: layout.style }, [
|
|
63
|
+
...layout.headers.map((header) => h('div', { style: header.style }, header.text)),
|
|
64
|
+
...layout.rows.flatMap((row) => [
|
|
65
|
+
...(row.caption ? [h('div', { style: row.caption.style }, row.caption.text)] : []),
|
|
66
|
+
...row.cells.map((cell) => h('div', { ...(cell.stateClass === null ? {} : { class: cell.stateClass }), style: cell.style }, [
|
|
67
|
+
// A copy per cell: Vue normalizes `class` and `style` on the props object in place.
|
|
68
|
+
h(input.component, { ...row.props }),
|
|
69
|
+
])),
|
|
70
|
+
]),
|
|
71
|
+
]);
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=combinations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinations.js","sourceRoot":"","sources":["../../src/vue-port/combinations.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,aAAa,EACb,WAAW,EAEX,KAAK,GACN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAmC,aAAa,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AA+B3G;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,sGAAsG;IACtG,IAAI,EAAE,cAAc;IACpB,iFAAiF;IACjF,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC;IACvE,KAAK,CAAC,KAAK;QACT,8GAA8G;QAC9G,sGAAsG;QACtG,MAAM,KAAK,GAAG,KAAgD,CAAA;QAC9D,8GAA8G;QAC9G,oGAAoG;QACpG,gEAAgE;QAChE,MAAM,MAAM,GAA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AAE,MAAM,4BAA4B,CAAA;AAEjF,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/vue.js
ADDED
package/dist/vue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.js","sourceRoot":"","sources":["../src/vue.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,YAAY,EAA0B,MAAM,4BAA4B,CAAA;AAGjF,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,81 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-check/storybook",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/visual-check/visual-check.git",
|
|
9
|
+
"directory": "packages/storybook"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"THIRD-PARTY-NOTICES.md"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react.d.ts",
|
|
22
|
+
"default": "./dist/react.js"
|
|
23
|
+
},
|
|
24
|
+
"./vue": {
|
|
25
|
+
"types": "./dist/vue.d.ts",
|
|
26
|
+
"default": "./dist/vue.js"
|
|
27
|
+
},
|
|
28
|
+
"./angular": {
|
|
29
|
+
"types": "./dist/angular.d.ts",
|
|
30
|
+
"default": "./dist/angular.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@angular/common": ">=18.0.0",
|
|
35
|
+
"@angular/core": ">=18.0.0",
|
|
36
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
37
|
+
"storybook": "^9.1.0 || ^10.0.0 || ^11.0.0-0",
|
|
38
|
+
"vue": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"@angular/common": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"@angular/core": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"react": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"storybook": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"vue": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@angular/animations": "18.2.14",
|
|
59
|
+
"@angular/common": "18.2.14",
|
|
60
|
+
"@angular/compiler": "18.2.14",
|
|
61
|
+
"@angular/core": "18.2.14",
|
|
62
|
+
"@angular/platform-browser": "18.2.14",
|
|
63
|
+
"@angular/platform-server": "18.2.14",
|
|
64
|
+
"@bramus/specificity": "2.4.4",
|
|
65
|
+
"@types/react": "19.3.0",
|
|
66
|
+
"@types/react-dom": "19.3.0",
|
|
67
|
+
"react": "18.3.1",
|
|
68
|
+
"react-dom": "18.3.1",
|
|
69
|
+
"storybook": "10.6.7",
|
|
70
|
+
"typescript": "7.0.2",
|
|
71
|
+
"vitest": "5.1.0",
|
|
72
|
+
"vue": "3.5.45",
|
|
73
|
+
"zone.js": "0.14.10",
|
|
74
|
+
"@visual-check/typescript-config": "0.0.0"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsc -p tsconfig.build.json",
|
|
78
|
+
"test:type": "tsc --noEmit",
|
|
79
|
+
"test:unit": "vitest run"
|
|
80
|
+
}
|
|
81
|
+
}
|
package/README.md
DELETED