@jfrader/storybook-docs 0.10.0 → 0.11.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/dist/component-demo.d.ts +2 -3
- package/dist/controls.d.ts +1 -1
- package/dist/index.js +22 -16
- package/package.json +1 -1
package/dist/component-demo.d.ts
CHANGED
|
@@ -7,10 +7,9 @@ export interface ComponentDemoProps {
|
|
|
7
7
|
story: string;
|
|
8
8
|
storyName: string;
|
|
9
9
|
authoredStory?: string;
|
|
10
|
-
|
|
10
|
+
notice?: string | null;
|
|
11
11
|
controls: StoryControl[];
|
|
12
12
|
args: Record<string, unknown>;
|
|
13
|
-
unavailable: string | null;
|
|
14
13
|
changed: boolean;
|
|
15
14
|
onControlChange: (name: string, value: unknown) => void;
|
|
16
15
|
onReset: () => void;
|
|
@@ -20,4 +19,4 @@ export interface ComponentDemoProps {
|
|
|
20
19
|
children: ReactNode;
|
|
21
20
|
}
|
|
22
21
|
export declare function hasHorizontalOverflow({ scrollWidth, clientWidth }: Pick<HTMLElement, 'scrollWidth' | 'clientWidth'>): boolean;
|
|
23
|
-
export declare function ComponentDemo({ story, storyName, authoredStory,
|
|
22
|
+
export declare function ComponentDemo({ story, storyName, authoredStory, notice, controls, args, changed, onControlChange, onReset, storyLayout, snippet, codeLanguage, children, }: ComponentDemoProps): import("react").JSX.Element;
|
package/dist/controls.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export declare function getStoryControls(meta: StoryShape, story: StoryShape, co
|
|
|
38
38
|
[x: string]: unknown;
|
|
39
39
|
};
|
|
40
40
|
controls: StoryControl[];
|
|
41
|
-
unavailable: string | null;
|
|
42
41
|
};
|
|
42
|
+
export declare function skippedNotice(meta: StoryShape, definition: StoryShape): string | null;
|
|
43
43
|
export declare function ControlledStoryFrame({ module, story, componentName, componentDefaults, renderSource }: {
|
|
44
44
|
module: Record<string, unknown>;
|
|
45
45
|
story: string;
|
package/dist/index.js
CHANGED
|
@@ -932,10 +932,9 @@ function ComponentDemo({
|
|
|
932
932
|
story,
|
|
933
933
|
storyName,
|
|
934
934
|
authoredStory,
|
|
935
|
-
|
|
935
|
+
notice,
|
|
936
936
|
controls,
|
|
937
937
|
args,
|
|
938
|
-
unavailable,
|
|
939
938
|
changed,
|
|
940
939
|
onControlChange,
|
|
941
940
|
onReset,
|
|
@@ -986,12 +985,8 @@ function ComponentDemo({
|
|
|
986
985
|
/* @__PURE__ */ jsx6("span", { "data-toc-slot": "", children: /* @__PURE__ */ jsx6(CopyLink, { name: storyName, story }) })
|
|
987
986
|
] }),
|
|
988
987
|
authoredStory ? /* @__PURE__ */ jsx6("p", { className: "story-blurb", children: authoredStory }) : null,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
skipped.join(", "),
|
|
992
|
-
". See it in Storybook."
|
|
993
|
-
] }) : null,
|
|
994
|
-
unavailable ? /* @__PURE__ */ jsx6("p", { className: "sd-controls-note", children: unavailable }) : /* @__PURE__ */ jsxs4("div", { className: "sd-controls", role: "group", "aria-labelledby": controlsLabelId, children: [
|
|
988
|
+
notice ? /* @__PURE__ */ jsx6("p", { className: "sd-controls-note", children: notice }) : null,
|
|
989
|
+
controls.length ? /* @__PURE__ */ jsxs4("div", { className: "sd-controls", role: "group", "aria-labelledby": controlsLabelId, children: [
|
|
995
990
|
/* @__PURE__ */ jsxs4("p", { className: "sd-controls-label", id: controlsLabelId, children: [
|
|
996
991
|
"Controls for ",
|
|
997
992
|
storyName
|
|
@@ -1008,7 +1003,7 @@ function ComponentDemo({
|
|
|
1008
1003
|
)),
|
|
1009
1004
|
/* @__PURE__ */ jsx6("button", { className: "sd-controls-reset", type: "button", disabled: !changed, onClick: onReset, children: "Reset" })
|
|
1010
1005
|
] })
|
|
1011
|
-
] }),
|
|
1006
|
+
] }) : null,
|
|
1012
1007
|
/* @__PURE__ */ jsx6(
|
|
1013
1008
|
"div",
|
|
1014
1009
|
{
|
|
@@ -1077,14 +1072,27 @@ function getStoryControls(meta, story, componentDefaults = {}) {
|
|
|
1077
1072
|
}
|
|
1078
1073
|
return {
|
|
1079
1074
|
args,
|
|
1080
|
-
controls
|
|
1081
|
-
unavailable: controls.length === 0 ? "No controls." : null
|
|
1075
|
+
controls
|
|
1082
1076
|
};
|
|
1083
1077
|
}
|
|
1078
|
+
function skippedNotice(meta, definition) {
|
|
1079
|
+
const hasSetup = Boolean(meta.loaders || definition.loaders || meta.beforeEach || definition.beforeEach);
|
|
1080
|
+
const hasViewport = Boolean(definition.parameters?.viewport ?? meta.parameters?.viewport);
|
|
1081
|
+
if (hasSetup && hasViewport) {
|
|
1082
|
+
return "Setup not run here and shown at this page\u2019s width. Open it in Storybook.";
|
|
1083
|
+
}
|
|
1084
|
+
if (hasSetup) {
|
|
1085
|
+
return "Setup not run here. Open it in Storybook.";
|
|
1086
|
+
}
|
|
1087
|
+
if (hasViewport) {
|
|
1088
|
+
return "Shown at this page\u2019s width. Open it in Storybook.";
|
|
1089
|
+
}
|
|
1090
|
+
return null;
|
|
1091
|
+
}
|
|
1084
1092
|
function ControlledStoryFrame({ module, story, componentName, componentDefaults, renderSource }) {
|
|
1085
1093
|
const meta = module.default ?? {};
|
|
1086
1094
|
const definition = module[story] ?? {};
|
|
1087
|
-
const { args: defaults, controls
|
|
1095
|
+
const { args: defaults, controls } = getStoryControls(meta, definition, componentDefaults);
|
|
1088
1096
|
const [edits, setEdits] = useState5({});
|
|
1089
1097
|
const args = { ...defaults, ...edits };
|
|
1090
1098
|
const changed = Object.entries(edits).some(([name, value]) => !Object.is(value, defaults[name]));
|
|
@@ -1095,8 +1103,7 @@ function ControlledStoryFrame({ module, story, componentName, componentDefaults,
|
|
|
1095
1103
|
const authoredCode = frameSource(meta, definition);
|
|
1096
1104
|
const authoredStory = docsOverride?.description?.story ?? docsMeta?.description?.story;
|
|
1097
1105
|
const storyName = definition.name ?? story;
|
|
1098
|
-
const
|
|
1099
|
-
if (definition.parameters?.viewport ?? meta.parameters?.viewport) skipped.push("viewport");
|
|
1106
|
+
const notice = skippedNotice(meta, definition);
|
|
1100
1107
|
const codeLanguage = authoredCode?.trim() ? docsOverride?.source?.language ?? docsMeta?.source?.language ?? "tsx" : "tsx";
|
|
1101
1108
|
const snippet = buildUsageSnippet({
|
|
1102
1109
|
componentName,
|
|
@@ -1115,10 +1122,9 @@ function ControlledStoryFrame({ module, story, componentName, componentDefaults,
|
|
|
1115
1122
|
story,
|
|
1116
1123
|
storyName,
|
|
1117
1124
|
authoredStory,
|
|
1118
|
-
|
|
1125
|
+
notice,
|
|
1119
1126
|
controls,
|
|
1120
1127
|
args,
|
|
1121
|
-
unavailable,
|
|
1122
1128
|
changed,
|
|
1123
1129
|
storyLayout,
|
|
1124
1130
|
snippet,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jfrader/storybook-docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A documentation front for any design system that has Storybook: navigation, live examples and API tables are generated from the story files themselves.",
|
|
6
6
|
"exports": {
|