@gjsify/stories 0.36.0 → 0.38.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/lib/types/types.d.ts +12 -23
- package/package.json +3 -3
package/lib/types/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Value type for a single story argument — covers every {@link ControlType}.
|
|
3
|
-
* `null` represents "not set".
|
|
4
|
-
*/
|
|
1
|
+
/** A single story argument, for every {@link ControlType}; `null` means "not set". */
|
|
5
2
|
export type StoryArgValue = string | number | boolean | null;
|
|
6
3
|
/** Map of story-argument name → current value. */
|
|
7
4
|
export type StoryArgs = Record<string, StoryArgValue>;
|
|
@@ -20,14 +17,12 @@ export interface StorySelectOption {
|
|
|
20
17
|
value: StoryArgValue;
|
|
21
18
|
}
|
|
22
19
|
interface StoryControlBase {
|
|
23
|
-
/** Argument key this control drives (
|
|
20
|
+
/** Argument key this control drives (a key in {@link StoryArgs}). */
|
|
24
21
|
name: string;
|
|
25
|
-
/** Human-readable label shown beside the control. */
|
|
26
22
|
label: string;
|
|
27
|
-
/**
|
|
23
|
+
/** Help / tooltip text. */
|
|
28
24
|
description?: string;
|
|
29
25
|
}
|
|
30
|
-
/** Free-text control. */
|
|
31
26
|
export interface StoryTextControl extends StoryControlBase {
|
|
32
27
|
type: ControlType.TEXT;
|
|
33
28
|
defaultValue?: string;
|
|
@@ -37,7 +32,6 @@ export interface StoryColorControl extends StoryControlBase {
|
|
|
37
32
|
type: ControlType.COLOR;
|
|
38
33
|
defaultValue?: string;
|
|
39
34
|
}
|
|
40
|
-
/** Toggle control. */
|
|
41
35
|
export interface StoryBooleanControl extends StoryControlBase {
|
|
42
36
|
type: ControlType.BOOLEAN;
|
|
43
37
|
defaultValue?: boolean;
|
|
@@ -57,17 +51,14 @@ export interface StorySelectControl extends StoryControlBase {
|
|
|
57
51
|
defaultValue?: StoryArgValue;
|
|
58
52
|
}
|
|
59
53
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* on SELECT).
|
|
54
|
+
* Discriminated on `type`, so per-kind fields are compile-time-checked: `min`/`max`/`step`
|
|
55
|
+
* only on NUMBER/RANGE, `options` only on SELECT.
|
|
63
56
|
*/
|
|
64
57
|
export type StoryControl = StoryTextControl | StoryColorControl | StoryBooleanControl | StoryNumberControl | StorySelectControl;
|
|
65
58
|
/**
|
|
66
|
-
* Metadata
|
|
67
|
-
*
|
|
68
|
-
* `
|
|
69
|
-
* GTK renderer passes a `GObject.GType`, a future web renderer might pass a tag
|
|
70
|
-
* name. It is display-only.
|
|
59
|
+
* Metadata for one story, or for a group of variants of one component. `TComponent`
|
|
60
|
+
* defaults to `unknown` to keep the contract platform-free — the GTK renderer passes a
|
|
61
|
+
* `GObject.GType`, a web renderer a tag name — and is display-only either way.
|
|
71
62
|
*/
|
|
72
63
|
export interface StoryMeta<TComponent = unknown> {
|
|
73
64
|
/** `"Category/Name"` — the slash-prefix groups the navigation sidebar. */
|
|
@@ -82,9 +73,8 @@ export interface StoryMeta<TComponent = unknown> {
|
|
|
82
73
|
controls?: StoryControl[];
|
|
83
74
|
}
|
|
84
75
|
/**
|
|
85
|
-
* A renderer's story-widget contract: a zero-arg constructor that also exposes
|
|
86
|
-
*
|
|
87
|
-
* (the GTK renderer's `StoryWidget`, a future web renderer's element).
|
|
76
|
+
* A renderer's story-widget contract: a zero-arg constructor that also exposes static
|
|
77
|
+
* metadata, with `TWidget` specialised to that renderer's own base class.
|
|
88
78
|
*/
|
|
89
79
|
export interface StoryComponentConstructor<TWidget = unknown> {
|
|
90
80
|
new (): TWidget;
|
|
@@ -99,9 +89,8 @@ export interface StoryModule<TWidget = unknown> {
|
|
|
99
89
|
instances?: TWidget[];
|
|
100
90
|
}
|
|
101
91
|
/**
|
|
102
|
-
* Wraps a story's content-build step
|
|
103
|
-
*
|
|
104
|
-
* initialize path: call `build()` to perform the default construction.
|
|
92
|
+
* Wraps a story's content-build step, e.g. to install a shared action group or a mock
|
|
93
|
+
* environment around every story in a module. Call `build()` for the default construction.
|
|
105
94
|
*/
|
|
106
95
|
export type StoryDecorator<TWidget = unknown> = (build: () => void, widget: TWidget) => void;
|
|
107
96
|
/** Narrowing guard — `true` when `value` is a {@link StoryModule}. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/stories",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Runtime-agnostic story-authoring contract (controls, args, metadata) shared by every gjsify storybook renderer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@gjsify/cli": "^0.
|
|
39
|
-
"@gjsify/unit": "^0.
|
|
38
|
+
"@gjsify/cli": "^0.38.0",
|
|
39
|
+
"@gjsify/unit": "^0.38.0",
|
|
40
40
|
"@types/node": "^25.9.2",
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
},
|