@gtkx/storybook 2.0.0-beta.11 → 2.0.0-beta.13

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.
Files changed (51) hide show
  1. package/README.md +5 -5
  2. package/dist/actions-panel.d.ts.map +1 -1
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +2 -1
  5. package/dist/actions.js.map +1 -1
  6. package/dist/catalog.d.ts +1 -1
  7. package/dist/catalog.d.ts.map +1 -1
  8. package/dist/catalog.js +11 -5
  9. package/dist/catalog.js.map +1 -1
  10. package/dist/compose.d.ts.map +1 -1
  11. package/dist/compose.js.map +1 -1
  12. package/dist/config.d.ts +4 -1
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js.map +1 -1
  15. package/dist/controls.d.ts +2 -1
  16. package/dist/controls.d.ts.map +1 -1
  17. package/dist/controls.js +30 -12
  18. package/dist/controls.js.map +1 -1
  19. package/dist/explorer-navigator.d.ts.map +1 -1
  20. package/dist/explorer-navigator.js +29 -2
  21. package/dist/explorer-navigator.js.map +1 -1
  22. package/dist/explorer-preview.d.ts.map +1 -1
  23. package/dist/explorer-preview.js +29 -13
  24. package/dist/explorer-preview.js.map +1 -1
  25. package/dist/explorer-view.d.ts +5 -1
  26. package/dist/explorer-view.d.ts.map +1 -1
  27. package/dist/explorer-view.js +17 -9
  28. package/dist/explorer-view.js.map +1 -1
  29. package/dist/explorer.d.ts +4 -0
  30. package/dist/explorer.d.ts.map +1 -1
  31. package/dist/explorer.js +6 -1
  32. package/dist/explorer.js.map +1 -1
  33. package/dist/types.d.ts +8 -2
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/types.js.map +1 -1
  36. package/dist/upstream.d.ts +4 -2
  37. package/dist/upstream.d.ts.map +1 -1
  38. package/dist/upstream.js +3 -1
  39. package/dist/upstream.js.map +1 -1
  40. package/package.json +14 -21
  41. package/src/actions.ts +28 -33
  42. package/src/catalog.ts +29 -19
  43. package/src/compose.ts +13 -7
  44. package/src/config.ts +4 -1
  45. package/src/controls.tsx +42 -18
  46. package/src/explorer-navigator.tsx +63 -28
  47. package/src/explorer-preview.tsx +95 -54
  48. package/src/explorer-view.tsx +56 -27
  49. package/src/explorer.ts +12 -1
  50. package/src/types.ts +42 -30
  51. package/src/upstream.ts +6 -8
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-navigator.js","sourceRoot":"","sources":["../src/explorer-navigator.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAejC,MAAM,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAc,EAAa,EAAE,CAAC,CACpF,MAAC,MAAM,IAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,aACrD,KAAC,QAAQ,IACL,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,EAAE,EACf,SAAS,EAAE,EAAE,EACb,UAAU,EAAE,CAAC,SAAS,CAAC,EACvB,IAAI,SACN,EACF,KAAC,UAAU,IACP,UAAU,EAAE,CAAC,oBAAoB,CAAC,EAClC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,UAAU,CAAC,EACpE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE;gBACnB,MAAM,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,C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U,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,IAJb,KAAK,CAKZ,CACL,CAAC,EACD,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAClB,KAAC,aAAa,IACV,IAAI,EAAC,sBAAsB,EAC3B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EACnD,QAAQ,EAAC,wBAAwB,EACjC,UAAU,EAAE,CAAC,SAAS,CAAC,GACzB,CACL,EACD,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,GAAI,IACzB,GACO,IACf,CACZ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwActionRow, AdwStatusPage } from \"@gtkx/jsx/adw\";\nimport { GtkBox, GtkLabel, GtkListBox, GtkScrolledWindow, GtkSearchEntry } from \"@gtkx/jsx/gtk\";\nimport { useState } from \"react\";\nimport type { StoryEntry, StoryLoadError } from \"./catalog.js\";\n\ntype NavigatorProps = {\n stories: StoryEntry[];\n errors: StoryLoadError[];\n selectedId: string | undefined;\n onSelect: (id: string) => void;\n};\n\ntype GroupProps = Pick<NavigatorProps, \"selectedId\" | \"onSelect\"> & {\n title: string;\n entries: StoryEntry[];\n};\n\nconst StoryGroup = ({ title, entries, selectedId, onSelect }: GroupProps): ReactNode => (\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={6}>\n <GtkLabel\n label={title}\n xalign={0}\n marginStart={18}\n marginEnd={18}\n cssClasses={[\"heading\"]}\n wrap\n />\n <GtkListBox\n cssClasses={[\"navigation-sidebar\"]}\n selectedIndex={entries.findIndex((entry) => entry.id === selectedId)}\n onRowSelected={(row) => {\n const entry = row === null ? undefined : entries[row.getIndex()];\n\n if (entry) {\n onSelect(entry.id);\n }\n }}\n >\n {entries.map((entry) => (\n <AdwActionRow\n key={entry.id}\n name={`storybook-story-${entry.id}`}\n title={markupEscapeText(entry.name, -1)}\n activatable\n onActivated={() => {\n onSelect(entry.id);\n }}\n />\n ))}\n </GtkListBox>\n </GtkBox>\n);\n\nconst LoadErrors = ({ errors }: Pick<NavigatorProps, \"errors\">): ReactNode => errors.length > 0 && (\n <GtkBox name=\"storybook-load-errors\" orientation={Gtk.Orientation.VERTICAL} spacing={6}>\n {errors.map(({ source, error }, index) => (\n <GtkLabel\n key={`${source}-${String(index)}`}\n label={`${source}\\n${error.message.slice(0, 500)}`}\n cssClasses={[\"error\"]}\n marginStart={18}\n marginEnd={18}\n wrap\n selectable\n xalign={0}\n />\n ))}\n </GtkBox>\n);\n\nconst StoryNavigator = ({ stories, errors, selectedId, onSelect }: NavigatorProps): ReactNode => {\n const [search, setSearch] = useState(\"\");\n const query = search.trim().toLocaleLowerCase();\n const groups = Map.groupBy(\n stories.filter((entry) => `${entry.title} ${entry.name}`.toLocaleLowerCase().includes(query)),\n (entry) => entry.title,\n );\n\n return (\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}>\n <GtkSearchEntry\n name=\"storybook-search\"\n placeholderText=\"Search stories\"\n text={search}\n marginStart={12}\n marginEnd={12}\n onChanged={(entry) => {\n setSearch(entry.getText());\n }}\n />\n <GtkScrolledWindow hscrollbarPolicy={Gtk.PolicyType.NEVER} vexpand>\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={18} marginBottom={18}>\n {[...groups].map(([title, entries]) => (\n <StoryGroup\n key={title}\n title={title}\n entries={entries}\n selectedId={selectedId}\n onSelect={onSelect}\n />\n ))}\n {groups.size === 0 && (\n <AdwStatusPage\n name=\"storybook-no-matches\"\n title={query ? \"No matching stories\" : \"No stories\"}\n iconName=\"system-search-symbolic\"\n cssClasses={[\"compact\"]}\n />\n )}\n <LoadErrors errors={errors} />\n </GtkBox>\n </GtkScrolledWindow>\n </GtkBox>\n );\n};\n\nexport { StoryNavigator };\n"]}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KAAK,CAKZ,CACL,CAAC,EACD,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CACpB,KAAC,aAAa,IACV,IAAI,EAAC,sBAAsB,EAC3B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EACnD,QAAQ,EAAC,wBAAwB,EACjC,UAAU,EAAE,CAAC,SAAS,CAAC,GACzB,CACL,EACD,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,GAAI,IACzB,GACO,IACf,CACZ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwActionRow, AdwStatusPage } from \"@gtkx/jsx/adw\";\nimport { GtkBox, GtkLabel, GtkListBox, GtkScrolledWindow, GtkSearchEntry } from \"@gtkx/jsx/gtk\";\nimport { useState } from \"react\";\nimport type { StoryEntry, StoryLoadError } from \"./catalog.js\";\n\ntype NavigatorProps = {\n stories: StoryEntry[];\n errors: StoryLoadError[];\n selectedId: string | undefined;\n onSelect: (id: string) => void;\n};\n\ntype GroupProps = Pick<NavigatorProps, \"selectedId\" | \"onSelect\"> & {\n title: string;\n entries: StoryEntry[];\n};\n\ntype Group = {\n title: string;\n entries: StoryEntry[];\n path: number[];\n};\n\nconst TITLE_SEPARATOR = \"/\";\n\nconst titlePrefixes = (title: string): string[] =>\n title.split(TITLE_SEPARATOR).map((_, index, segments) => segments.slice(0, index + 1).join(TITLE_SEPARATOR));\n\nconst compareIndexPaths = (left: number[], right: number[]): number => {\n for (const [index, value] of left.entries()) {\n const other = right[index];\n\n if (other === undefined) {\n return 1;\n }\n\n if (value !== other) {\n return value - other;\n }\n }\n\n return left.length - right.length;\n};\n\n/**\n * Groups stories by title, keeping titles that share a path prefix together as Storybook's sidebar nests\n * them: the first title under each prefix decides where the prefix appears.\n */\nconst groupStoriesByTitle = (stories: StoryEntry[]): Group[] => {\n const firstOccurrence: Map<string, number> = new Map();\n const groups = [...Map.groupBy(stories, (entry) => entry.title)].map(([title, entries], order) => ({\n title,\n entries,\n path: titlePrefixes(title).map((prefix) => firstOccurrence.getOrInsert(prefix, order)),\n }));\n\n return groups.toSorted((left, right) => compareIndexPaths(left.path, right.path));\n};\n\nconst StoryGroup = ({ title, entries, selectedId, onSelect }: GroupProps): ReactNode => (\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={6}>\n <GtkLabel label={title} xalign={0} marginStart={18} marginEnd={18} cssClasses={[\"heading\"]} wrap />\n <GtkListBox\n cssClasses={[\"navigation-sidebar\"]}\n selectedIndex={entries.findIndex((entry) => entry.id === selectedId)}\n onRowSelected={(row) => {\n const entry = row === null ? undefined : entries[row.getIndex()];\n\n if (entry) {\n onSelect(entry.id);\n }\n }}\n >\n {entries.map((entry) => (\n <AdwActionRow\n key={entry.id}\n name={`storybook-story-${entry.id}`}\n title={markupEscapeText(entry.name, -1)}\n activatable\n onActivated={() => {\n onSelect(entry.id);\n }}\n />\n ))}\n </GtkListBox>\n </GtkBox>\n);\n\nconst LoadErrors = ({ errors }: Pick<NavigatorProps, \"errors\">): ReactNode =>\n errors.length > 0 && (\n <GtkBox name=\"storybook-load-errors\" orientation={Gtk.Orientation.VERTICAL} spacing={6}>\n {errors.map(({ source, error }, index) => (\n <GtkLabel\n key={`${source}-${String(index)}`}\n label={`${source}\\n${error.message.slice(0, 500)}`}\n cssClasses={[\"error\"]}\n marginStart={18}\n marginEnd={18}\n wrap\n selectable\n xalign={0}\n />\n ))}\n </GtkBox>\n );\n\nconst StoryNavigator = ({ stories, errors, selectedId, onSelect }: NavigatorProps): ReactNode => {\n const [search, setSearch] = useState(\"\");\n const query = search.trim().toLocaleLowerCase();\n const groups = groupStoriesByTitle(\n stories.filter((entry) => `${entry.title} ${entry.name}`.toLocaleLowerCase().includes(query)),\n );\n\n return (\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}>\n <GtkSearchEntry\n name=\"storybook-search\"\n placeholderText=\"Search stories\"\n text={search}\n marginStart={12}\n marginEnd={12}\n onChanged={(entry) => {\n setSearch(entry.getText());\n }}\n />\n <GtkScrolledWindow hscrollbarPolicy={Gtk.PolicyType.NEVER} vexpand>\n <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={18} marginBottom={18}>\n {groups.map(({ title, entries }) => (\n <StoryGroup\n key={title}\n title={title}\n entries={entries}\n selectedId={selectedId}\n onSelect={onSelect}\n />\n ))}\n {groups.length === 0 && (\n <AdwStatusPage\n name=\"storybook-no-matches\"\n title={query ? \"No matching stories\" : \"No stories\"}\n iconName=\"system-search-symbolic\"\n cssClasses={[\"compact\"]}\n />\n )}\n <LoadErrors errors={errors} />\n </GtkBox>\n </GtkScrolledWindow>\n </GtkBox>\n );\n};\n\nexport { StoryNavigator };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-preview.d.ts","sourceRoot":"","sources":["../src/explorer-preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM/C,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AA2JF,QAAA,MAAM,gBAAgB,GAAI,WAAW,YAAY,KAAG,SAkCnD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"explorer-preview.d.ts","sourceRoot":"","sources":["../src/explorer-preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO/C,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AAgMF,QAAA,MAAM,gBAAgB,cAAe,YAAY,KAAG,SAoCnD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,26 +1,26 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { markupEscapeText } from "@gtkx/gi/glib";
3
3
  import * as Gtk from "@gtkx/gi/gtk";
4
4
  import { AdwHeaderBar, AdwStatusPage, AdwToolbarView, AdwWindowTitle } from "@gtkx/jsx/adw";
5
5
  import { GtkBox, GtkButton, GtkScrolledWindow } from "@gtkx/jsx/gtk";
6
6
  import { createPortal, rootElement } from "@gtkx/react";
7
+ import { normalizeError } from "@gtkx/utils";
7
8
  import { Component, useCallback, useMemo, useState } from "react";
8
9
  import { ActionsPanel } from "./actions-panel.js";
9
10
  import { ActionStore, bindActions } from "./actions.js";
10
11
  import { Controls } from "./controls.js";
12
+ import { isConditionalArgIncluded } from "./upstream.js";
11
13
  class PreviewBoundary extends Component {
12
14
  static getDerivedStateFromProps(props, state) {
13
15
  return props.args === state.args ? null : { error: null, args: props.args };
14
16
  }
15
17
  static getDerivedStateFromError(error) {
16
- return { error: error instanceof Error ? error : new Error(String(error)) };
18
+ return { error: normalizeError(error) };
17
19
  }
18
20
  state = { error: null, args: this.props.args };
19
21
  render() {
20
- return this.state.error === null
21
- ? this.props.children
22
- : (_jsx(AdwStatusPage, { name: "storybook-preview-error", title: "Preview failed", iconName: "dialog-error-symbolic", description: markupEscapeText(this.state.error.message.slice(0, 500), -1) +
23
- "\n\nAdjust controls, reset the preview, or select another story to continue." }));
22
+ return this.state.error === null ? (this.props.children) : (_jsx(AdwStatusPage, { name: "storybook-preview-error", title: "Preview failed", iconName: "dialog-error-symbolic", description: markupEscapeText(this.state.error.message.slice(0, 500), -1) +
23
+ "\n\nAdjust controls, reset the preview, or select another story to continue." }));
24
24
  }
25
25
  }
26
26
  const previewMode = (story) => {
@@ -31,6 +31,24 @@ const previewMode = (story) => {
31
31
  }
32
32
  return mode;
33
33
  };
34
+ const mapValue = (value, mapping) => {
35
+ const key = String(value);
36
+ return Object.hasOwn(mapping, key) ? mapping[key] : value;
37
+ };
38
+ const mapArgs = (args, argTypes) => Object.fromEntries(Object.entries(args).map(([argument, value]) => {
39
+ const mapping = argTypes[argument]?.mapping;
40
+ if (mapping === undefined) {
41
+ return [argument, value];
42
+ }
43
+ return [
44
+ argument,
45
+ Array.isArray(value) ? value.map((item) => mapValue(item, mapping)) : mapValue(value, mapping),
46
+ ];
47
+ }));
48
+ const includedArgs = (args, argTypes, globals) => Object.fromEntries(Object.entries(args).map(([argument, value]) => [
49
+ argument,
50
+ isConditionalArgIncluded(argTypes[argument] ?? {}, args, globals) ? value : undefined,
51
+ ]));
34
52
  const PreviewContent = ({ story: Story, args }) => {
35
53
  const mode = previewMode(Story);
36
54
  if (mode !== "content") {
@@ -38,7 +56,7 @@ const PreviewContent = ({ story: Story, args }) => {
38
56
  }
39
57
  const margin = Story.parameters.layout === "fullscreen" ? 0 : 24;
40
58
  const align = Story.parameters.layout === "centered" ? Gtk.Align.CENTER : Gtk.Align.FILL;
41
- return (_jsx(GtkBox, { name: "storybook-canvas", orientation: Gtk.Orientation.VERTICAL, hexpand: true, vexpand: true, halign: align, valign: align, marginTop: margin, marginBottom: margin, marginStart: margin, marginEnd: margin, children: _jsx(Story, { ...args }) }));
59
+ return (_jsx(GtkScrolledWindow, { hexpand: true, vexpand: true, propagateNaturalWidth: true, propagateNaturalHeight: true, children: _jsx(GtkBox, { name: "storybook-canvas", orientation: Gtk.Orientation.VERTICAL, halign: align, valign: align, marginTop: margin, marginBottom: margin, marginStart: margin, marginEnd: margin, children: _jsx(Story, { ...args }) }) }));
42
60
  };
43
61
  const usePreviewState = ({ entry }) => {
44
62
  const [state, setState] = useState(() => ({
@@ -53,7 +71,7 @@ const usePreviewState = ({ entry }) => {
53
71
  ? { ...current, error }
54
72
  : current);
55
73
  }, [state.story, state.generation]);
56
- const boundArgs = useMemo(() => bindActions(state.args, state.story.argTypes, state.actions, onError), [state.args, state.story.argTypes, state.actions, onError]);
74
+ const boundArgs = useMemo(() => includedArgs(bindActions(mapArgs(state.args, state.story.argTypes), state.story.argTypes, state.actions, onError), state.story.argTypes, state.story.globals), [state.args, state.story.argTypes, state.story.globals, state.actions, onError]);
57
75
  if (state.story !== entry.story) {
58
76
  setState({
59
77
  story: entry.story,
@@ -77,13 +95,11 @@ const usePreviewState = ({ entry }) => {
77
95
  };
78
96
  return { state, boundArgs, reset, onChange };
79
97
  };
80
- const StoryInspector = ({ entry, actions, args, onChange }) => (_jsx(GtkScrolledWindow, { name: "storybook-inspector", widthRequest: 280, hscrollbarPolicy: Gtk.PolicyType.NEVER, vexpand: true, children: _jsxs(GtkBox, { orientation: Gtk.Orientation.VERTICAL, spacing: 24, marginTop: 18, marginBottom: 18, marginStart: 12, marginEnd: 12, children: [_jsx(Controls, { argTypes: entry.controls, args: args, onChange: onChange }), _jsx(ActionsPanel, { store: actions })] }) }));
98
+ const StoryInspector = ({ entry, actions, args, onChange }) => (_jsx(GtkScrolledWindow, { name: "storybook-inspector", widthRequest: 280, hscrollbarPolicy: Gtk.PolicyType.NEVER, vexpand: true, children: _jsxs(GtkBox, { orientation: Gtk.Orientation.VERTICAL, spacing: 24, marginTop: 18, marginBottom: 18, marginStart: 12, marginEnd: 12, children: [_jsx(Controls, { argTypes: entry.controls, args: args, globals: entry.story.globals, onChange: onChange }), _jsx(ActionsPanel, { store: actions })] }) }));
81
99
  const StorybookPreview = ({ entry }) => {
82
100
  const { state, boundArgs, reset, onChange } = usePreviewState({ entry });
83
- return (_jsx(AdwToolbarView, { hexpand: true, vexpand: true, topBar: (_jsx(AdwHeaderBar, { titleWidget: _jsx(AdwWindowTitle, { title: entry.name, subtitle: entry.title }), end: _jsx(GtkButton, { label: "Reset story", onClicked: reset }) })), children: _jsxs(GtkBox, { children: [_jsx(GtkBox, { orientation: Gtk.Orientation.VERTICAL, hexpand: true, vexpand: true, children: _jsx(PreviewBoundary, { args: state.args, children: state.error === null
84
- ? _jsx(PreviewContent, { story: entry.story, args: boundArgs })
85
- : (_jsx(AdwStatusPage, { name: "storybook-preview-error", title: "Story action failed", iconName: "dialog-error-symbolic", description: markupEscapeText(state.error.message.slice(0, 500), -1) +
86
- "\n\nReset the preview or select another story to continue." })) }, state.generation) }), _jsx(StoryInspector, { entry: entry, actions: state.actions, args: state.args, onChange: onChange })] }) }));
101
+ return (_jsx(AdwToolbarView, { hexpand: true, vexpand: true, top: _jsx(AdwHeaderBar, { titleWidget: _jsx(AdwWindowTitle, { title: entry.name, subtitle: entry.title }), end: _jsx(GtkButton, { label: "Reset story", onClicked: reset }) }), children: _jsxs(GtkBox, { children: [_jsx(GtkBox, { orientation: Gtk.Orientation.VERTICAL, hexpand: true, vexpand: true, children: _jsx(PreviewBoundary, { args: state.args, children: state.error === null ? (_jsx(PreviewContent, { story: entry.story, args: boundArgs })) : (_jsx(AdwStatusPage, { name: "storybook-preview-error", title: "Story action failed", iconName: "dialog-error-symbolic", description: markupEscapeText(state.error.message.slice(0, 500), -1) +
102
+ "\n\nReset the preview or select another story to continue." })) }, state.generation) }), _jsx(StoryInspector, { entry: entry, actions: state.actions, args: state.args, onChange: onChange })] }) }));
87
103
  };
88
104
  export { StorybookPreview };
89
105
  //# sourceMappingURL=explorer-preview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-preview.js","sourceRoot":"","sources":["../src/explorer-preview.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,M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AC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,GAAI;4BACzD,CAAC,CAAC,CACM,KAAC,aAAa,IACV,IAAI,EAAC,yBAAyB,EAC9B,KAAK,EAAC,qBAAqB,EAC3B,QAAQ,EAAC,uBAAuB,EAChC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;oCAChE,4DAA4D,GAClE,CACL,IAXS,KAAK,CAAC,UAAU,CAYpB,GACb,EACT,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAI,IACzF,GACI,CACpB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwHeaderBar, AdwStatusPage, AdwToolbarView, AdwWindowTitle } from \"@gtkx/jsx/adw\";\nimport { GtkBox, GtkButton, GtkScrolledWindow } from \"@gtkx/jsx/gtk\";\nimport { createPortal, rootElement } from \"@gtkx/react\";\nimport { Component, useCallback, useMemo, useState } from \"react\";\nimport type { StoryEntry } from \"./catalog.js\";\nimport type { Args, ComposedStory } from \"./types.js\";\nimport { ActionsPanel } from \"./actions-panel.js\";\nimport { ActionStore, bindActions } from \"./actions.js\";\nimport { Controls } from \"./controls.js\";\n\ntype PreviewProps = {\n entry: StoryEntry;\n};\n\ntype PreviewState = {\n story: ComposedStory;\n args: Args;\n generation: number;\n error: Error | null;\n actions: ActionStore;\n};\n\ntype BoundaryProps = { children: ReactNode; args: Args };\ntype BoundaryState = { error: Error | null; args: Args };\n\nclass PreviewBoundary extends Component<BoundaryProps, BoundaryState> {\n static getDerivedStateFromProps(props: BoundaryProps, state: BoundaryState): BoundaryState | null {\n return props.args === state.args ? null : { error: null, args: props.args };\n }\n\n static getDerivedStateFromError(error: unknown): Pick<BoundaryState, \"error\"> {\n return { error: error instanceof Error ? error : new Error(String(error)) };\n }\n\n override state: BoundaryState = { error: null, args: this.props.args };\n\n override render(): ReactNode {\n return this.state.error === null\n ? this.props.children\n : (\n <AdwStatusPage\n name=\"storybook-preview-error\"\n title=\"Preview failed\"\n iconName=\"dialog-error-symbolic\"\n description={markupEscapeText(this.state.error.message.slice(0, 500), -1) +\n \"\\n\\nAdjust controls, reset the preview, or select another story to continue.\"}\n />\n );\n }\n}\n\nconst previewMode = (story: ComposedStory): \"content\" | \"window\" | \"dialog\" => {\n const gtkx = story.parameters.gtkx;\n const mode = typeof gtkx === \"object\" && gtkx !== null && \"preview\" in gtkx ? gtkx.preview : \"content\";\n\n if (mode !== \"content\" && mode !== \"window\" && mode !== \"dialog\") {\n throw new Error(\"Unsupported GTKX story preview mode\");\n }\n\n return mode;\n};\n\nconst PreviewContent = ({ story: Story, args }: { story: ComposedStory; args: Args }): ReactNode => {\n const mode = previewMode(Story);\n\n if (mode !== \"content\") {\n return (\n <>\n <AdwStatusPage\n title={mode === \"window\" ? \"Window preview\" : \"Dialog preview\"}\n iconName=\"window-new-symbolic\"\n description=\"The story owns its presentation. Reset to open it again.\"\n />\n {createPortal(<Story {...args} />, rootElement)}\n </>\n );\n }\n\n const margin = Story.parameters.layout === \"fullscreen\" ? 0 : 24;\n const align = Story.parameters.layout === \"centered\" ? Gtk.Align.CENTER : Gtk.Align.FILL;\n\n return (\n <GtkBox\n name=\"storybook-canvas\"\n orientation={Gtk.Orientation.VERTICAL}\n hexpand\n vexpand\n halign={align}\n valign={align}\n marginTop={margin}\n marginBottom={margin}\n marginStart={margin}\n marginEnd={margin}\n >\n <Story {...args} />\n </GtkBox>\n );\n};\n\nconst usePreviewState = ({ entry }: PreviewProps) => {\n const [state, setState] = useState<PreviewState>(() => ({\n story: entry.story,\n args: { ...entry.story.args },\n generation: 0,\n error: null,\n actions: new ActionStore(),\n }));\n const onError = useCallback((error: Error) => {\n setState((current) => current.story === state.story && current.generation === state.generation\n ? { ...current, error }\n : current);\n }, [state.story, state.generation]);\n const boundArgs = useMemo(\n () => bindActions(state.args, state.story.argTypes, state.actions, onError),\n [state.args, state.story.argTypes, state.actions, onError],\n );\n\n if (state.story !== entry.story) {\n setState({\n story: entry.story,\n args: { ...entry.story.args },\n generation: state.generation + 1,\n error: null,\n actions: new ActionStore(),\n });\n }\n\n const reset = (): void => {\n setState((current) => ({\n story: entry.story,\n args: { ...entry.story.args },\n generation: current.generation + 1,\n error: null,\n actions: new ActionStore(),\n }));\n };\n\n const onChange = (args: Args): void => {\n setState((current) => ({ ...current, args: { ...current.args, ...args } }));\n };\n\n return { state, boundArgs, reset, onChange };\n};\n\ntype InspectorProps = PreviewProps & { actions: ActionStore; args: Args; onChange: (args: Args) => void };\n\nconst StoryInspector = ({ entry, actions, args, onChange }: InspectorProps): ReactNode => (\n <GtkScrolledWindow\n name=\"storybook-inspector\"\n widthRequest={280}\n hscrollbarPolicy={Gtk.PolicyType.NEVER}\n vexpand\n >\n <GtkBox\n orientation={Gtk.Orientation.VERTICAL}\n spacing={24}\n marginTop={18}\n marginBottom={18}\n marginStart={12}\n marginEnd={12}\n >\n <Controls argTypes={entry.controls} args={args} onChange={onChange} />\n <ActionsPanel store={actions} />\n </GtkBox>\n </GtkScrolledWindow>\n);\n\nconst StorybookPreview = ({ entry }: PreviewProps): ReactNode => {\n const { state, boundArgs, reset, onChange } = usePreviewState({ entry });\n\n return (\n <AdwToolbarView\n hexpand\n vexpand\n topBar={(\n <AdwHeaderBar\n titleWidget={<AdwWindowTitle title={entry.name} subtitle={entry.title} />}\n end={<GtkButton label=\"Reset story\" onClicked={reset} />}\n />\n )}\n >\n <GtkBox>\n <GtkBox orientation={Gtk.Orientation.VERTICAL} hexpand vexpand>\n <PreviewBoundary key={state.generation} args={state.args}>\n {state.error === null\n ? <PreviewContent story={entry.story} args={boundArgs} />\n : (\n <AdwStatusPage\n name=\"storybook-preview-error\"\n title=\"Story action failed\"\n iconName=\"dialog-error-symbolic\"\n description={markupEscapeText(state.error.message.slice(0, 500), -1) +\n \"\\n\\nReset the preview or select another story to continue.\"}\n />\n )}\n </PreviewBoundary>\n </GtkBox>\n <StoryInspector entry={entry} actions={state.actions} args={state.args} onChange={onChange} />\n </GtkBox>\n </AdwToolbarView>\n );\n};\n\nexport { StorybookPreview };\n"]}
1
+ {"version":3,"file":"explorer-preview.js","sourceRoot":"","sources":["../src/explorer-preview.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAiBzD,MAAM,eAAgB,SAAQ,SAAuC;IACjE,MAAM,CAAC,wBAAwB,CAAC,KAAoB,EAAE,KAAoB;QACtE,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAA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,qBAAqB,EAC3B,QAAQ,EAAC,uBAAuB,EAChC,WAAW,EACP,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gCACvD,4DAA4D,GAElE,CACL,IAbiB,KAAK,CAAC,UAAU,CAcpB,GACb,EACT,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAI,IACzF,GACI,CACpB,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { AdwHeaderBar, AdwStatusPage, AdwToolbarView, AdwWindowTitle } from \"@gtkx/jsx/adw\";\nimport { GtkBox, GtkButton, GtkScrolledWindow } from \"@gtkx/jsx/gtk\";\nimport { createPortal, rootElement } from \"@gtkx/react\";\nimport { normalizeError } from \"@gtkx/utils\";\nimport { Component, useCallback, useMemo, useState } from \"react\";\nimport type { StoryEntry } from \"./catalog.js\";\nimport type { Args, ArgTypes, ComposedStory } from \"./types.js\";\nimport { ActionsPanel } from \"./actions-panel.js\";\nimport { ActionStore, bindActions } from \"./actions.js\";\nimport { Controls } from \"./controls.js\";\nimport { isConditionalArgIncluded } from \"./upstream.js\";\n\ntype PreviewProps = {\n entry: StoryEntry;\n};\n\ntype PreviewState = {\n story: ComposedStory;\n args: Args;\n generation: number;\n error: Error | null;\n actions: ActionStore;\n};\n\ntype BoundaryProps = { children: ReactNode; args: Args };\ntype BoundaryState = { error: Error | null; args: Args };\n\nclass PreviewBoundary extends Component<BoundaryProps, BoundaryState> {\n static getDerivedStateFromProps(props: BoundaryProps, state: BoundaryState): BoundaryState | null {\n return props.args === state.args ? null : { error: null, args: props.args };\n }\n\n static getDerivedStateFromError(error: unknown): Pick<BoundaryState, \"error\"> {\n return { error: normalizeError(error) };\n }\n\n override state: BoundaryState = { error: null, args: this.props.args };\n\n override render(): ReactNode {\n return this.state.error === null ? (\n this.props.children\n ) : (\n <AdwStatusPage\n name=\"storybook-preview-error\"\n title=\"Preview failed\"\n iconName=\"dialog-error-symbolic\"\n description={\n markupEscapeText(this.state.error.message.slice(0, 500), -1) +\n \"\\n\\nAdjust controls, reset the preview, or select another story to continue.\"\n }\n />\n );\n }\n}\n\nconst previewMode = (story: ComposedStory): \"content\" | \"window\" | \"dialog\" => {\n const gtkx = story.parameters.gtkx;\n const mode = typeof gtkx === \"object\" && gtkx !== null && \"preview\" in gtkx ? gtkx.preview : \"content\";\n\n if (mode !== \"content\" && mode !== \"window\" && mode !== \"dialog\") {\n throw new Error(\"Unsupported GTKX story preview mode\");\n }\n\n return mode;\n};\n\nconst mapValue = (value: unknown, mapping: Record<string, unknown>): unknown => {\n const key = String(value);\n\n return Object.hasOwn(mapping, key) ? mapping[key] : value;\n};\n\nconst mapArgs = (args: Args, argTypes: ArgTypes): Args =>\n Object.fromEntries(\n Object.entries(args).map(([argument, value]) => {\n const mapping = argTypes[argument]?.mapping;\n\n if (mapping === undefined) {\n return [argument, value];\n }\n\n return [\n argument,\n Array.isArray(value) ? value.map((item) => mapValue(item, mapping)) : mapValue(value, mapping),\n ];\n }),\n );\n\nconst includedArgs = (args: Args, argTypes: ArgTypes, globals: Args): Args =>\n Object.fromEntries(\n Object.entries(args).map(([argument, value]) => [\n argument,\n isConditionalArgIncluded(argTypes[argument] ?? {}, args, globals) ? value : undefined,\n ]),\n );\n\nconst PreviewContent = ({ story: Story, args }: { story: ComposedStory; args: Args }): ReactNode => {\n const mode = previewMode(Story);\n\n if (mode !== \"content\") {\n return (\n <>\n <AdwStatusPage\n title={mode === \"window\" ? \"Window preview\" : \"Dialog preview\"}\n iconName=\"window-new-symbolic\"\n description=\"The story owns its presentation. Reset to open it again.\"\n />\n {createPortal(<Story {...args} />, rootElement)}\n </>\n );\n }\n\n const margin = Story.parameters.layout === \"fullscreen\" ? 0 : 24;\n const align = Story.parameters.layout === \"centered\" ? Gtk.Align.CENTER : Gtk.Align.FILL;\n\n return (\n <GtkScrolledWindow hexpand vexpand propagateNaturalWidth propagateNaturalHeight>\n <GtkBox\n name=\"storybook-canvas\"\n orientation={Gtk.Orientation.VERTICAL}\n halign={align}\n valign={align}\n marginTop={margin}\n marginBottom={margin}\n marginStart={margin}\n marginEnd={margin}\n >\n <Story {...args} />\n </GtkBox>\n </GtkScrolledWindow>\n );\n};\n\nconst usePreviewState = ({ entry }: PreviewProps) => {\n const [state, setState] = useState<PreviewState>(() => ({\n story: entry.story,\n args: { ...entry.story.args },\n generation: 0,\n error: null,\n actions: new ActionStore(),\n }));\n const onError = useCallback(\n (error: Error) => {\n setState((current) =>\n current.story === state.story && current.generation === state.generation\n ? { ...current, error }\n : current,\n );\n },\n [state.story, state.generation],\n );\n const boundArgs = useMemo(\n () =>\n includedArgs(\n bindActions(mapArgs(state.args, state.story.argTypes), state.story.argTypes, state.actions, onError),\n state.story.argTypes,\n state.story.globals,\n ),\n [state.args, state.story.argTypes, state.story.globals, state.actions, onError],\n );\n\n if (state.story !== entry.story) {\n setState({\n story: entry.story,\n args: { ...entry.story.args },\n generation: state.generation + 1,\n error: null,\n actions: new ActionStore(),\n });\n }\n\n const reset = (): void => {\n setState((current) => ({\n story: entry.story,\n args: { ...entry.story.args },\n generation: current.generation + 1,\n error: null,\n actions: new ActionStore(),\n }));\n };\n\n const onChange = (args: Args): void => {\n setState((current) => ({ ...current, args: { ...current.args, ...args } }));\n };\n\n return { state, boundArgs, reset, onChange };\n};\n\ntype InspectorProps = PreviewProps & { actions: ActionStore; args: Args; onChange: (args: Args) => void };\n\nconst StoryInspector = ({ entry, actions, args, onChange }: InspectorProps): ReactNode => (\n <GtkScrolledWindow name=\"storybook-inspector\" widthRequest={280} hscrollbarPolicy={Gtk.PolicyType.NEVER} vexpand>\n <GtkBox\n orientation={Gtk.Orientation.VERTICAL}\n spacing={24}\n marginTop={18}\n marginBottom={18}\n marginStart={12}\n marginEnd={12}\n >\n <Controls argTypes={entry.controls} args={args} globals={entry.story.globals} onChange={onChange} />\n <ActionsPanel store={actions} />\n </GtkBox>\n </GtkScrolledWindow>\n);\n\nconst StorybookPreview = ({ entry }: PreviewProps): ReactNode => {\n const { state, boundArgs, reset, onChange } = usePreviewState({ entry });\n\n return (\n <AdwToolbarView\n hexpand\n vexpand\n top={\n <AdwHeaderBar\n titleWidget={<AdwWindowTitle title={entry.name} subtitle={entry.title} />}\n end={<GtkButton label=\"Reset story\" onClicked={reset} />}\n />\n }\n >\n <GtkBox>\n <GtkBox orientation={Gtk.Orientation.VERTICAL} hexpand vexpand>\n <PreviewBoundary key={state.generation} args={state.args}>\n {state.error === null ? (\n <PreviewContent story={entry.story} args={boundArgs} />\n ) : (\n <AdwStatusPage\n name=\"storybook-preview-error\"\n title=\"Story action failed\"\n iconName=\"dialog-error-symbolic\"\n description={\n markupEscapeText(state.error.message.slice(0, 500), -1) +\n \"\\n\\nReset the preview or select another story to continue.\"\n }\n />\n )}\n </PreviewBoundary>\n </GtkBox>\n <StoryInspector entry={entry} actions={state.actions} args={state.args} onChange={onChange} />\n </GtkBox>\n </AdwToolbarView>\n );\n};\n\nexport { StorybookPreview };\n"]}
@@ -8,8 +8,12 @@ type StorybookProps = {
8
8
  applicationId?: string;
9
9
  /** Explorer window and sidebar title; defaults to GTKX Storybook. */
10
10
  title?: string;
11
+ /** Story selected once the catalog lists it; the first story is selected otherwise. */
12
+ initialStoryId?: string | undefined;
13
+ /** Called with the identifier of each story the explorer selects. */
14
+ onStorySelected?: ((id: string) => void) | undefined;
11
15
  };
12
16
  /** Renders the Adwaita explorer application with navigation, story previews, controls, and actions. */
13
- declare const Storybook: ({ catalog, applicationId, title, }: StorybookProps) => ReactNode;
17
+ declare const Storybook: ({ catalog, applicationId, title, initialStoryId, onStorySelected, }: StorybookProps) => ReactNode;
14
18
  export { Storybook };
15
19
  //# sourceMappingURL=explorer-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-view.d.ts","sourceRoot":"","sources":["../src/explorer-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,gEAAgE;AAChE,KAAK,cAAc,GAAG;IAClB,8EAA8E;IAC9E,OAAO,EAAE,YAAY,CAAC;IACtB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAsDF,uGAAuG;AACvG,QAAA,MAAM,SAAS,GAAI,oCAIhB,cAAc,KAAG,SAMnB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"explorer-view.d.ts","sourceRoot":"","sources":["../src/explorer-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,gEAAgE;AAChE,KAAK,cAAc,GAAG;IAClB,8EAA8E;IAC9E,OAAO,EAAE,YAAY,CAAC;IACtB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,qEAAqE;IACrE,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxD,CAAC;AAwEF,uGAAuG;AACvG,QAAA,MAAM,SAAS,wEAMZ,cAAc,KAAG,SAWnB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -2,23 +2,31 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as Gio from "@gtkx/gi/gio";
3
3
  import { AdwApplication, AdwApplicationWindow, AdwHeaderBar, AdwOverlaySplitView, AdwStatusPage, AdwToolbarView, AdwWindowTitle, } from "@gtkx/jsx/adw";
4
4
  import { quit } from "@gtkx/react";
5
- import { useCallback, useState, useSyncExternalStore } from "react";
5
+ import { useCallback, useEffect, useEffectEvent, useState, useSyncExternalStore } from "react";
6
6
  import { StoryNavigator } from "./explorer-navigator.js";
7
7
  import { StorybookPreview } from "./explorer-preview.js";
8
- const StorybookView = ({ catalog, title = "GTKX Storybook" }) => {
8
+ const storyCount = (count) => (count === 1 ? "1 story" : `${String(count)} stories`);
9
+ const StorybookView = ({ catalog, title = "GTKX Storybook", initialStoryId, onStorySelected, }) => {
9
10
  const subscribe = useCallback((listener) => catalog.subscribe(listener), [catalog]);
10
11
  const getSnapshot = useCallback(() => catalog.getSnapshot(), [catalog]);
11
12
  const snapshot = useSyncExternalStore(subscribe, getSnapshot);
12
- const [selectedId, setSelectedId] = useState();
13
+ const [selectedId, setSelectedId] = useState(initialStoryId);
13
14
  const selected = snapshot.stories.find((entry) => entry.id === selectedId) ?? snapshot.stories[0];
14
- if (selectedId !== selected?.id) {
15
- setSelectedId(selected?.id);
15
+ if (selected !== undefined && selectedId !== selected.id) {
16
+ setSelectedId(selected.id);
16
17
  }
17
- return (_jsx(AdwOverlaySplitView, { minSidebarWidth: 220, maxSidebarWidth: 300, sidebar: (_jsx(AdwToolbarView, { topBar: (_jsx(AdwHeaderBar, { titleWidget: (_jsx(AdwWindowTitle, { title: title, subtitle: `${String(snapshot.stories.length)} stories` })) })), children: _jsx(StoryNavigator, { stories: snapshot.stories, errors: snapshot.errors, selectedId: selected?.id, onSelect: setSelectedId }) })), children: selected
18
- ? _jsx(StorybookPreview, { entry: selected }, selected.id)
19
- : (_jsx(AdwToolbarView, { topBar: _jsx(AdwHeaderBar, {}), children: _jsx(AdwStatusPage, { name: "storybook-empty", title: snapshot.isLoading ? "Loading stories" : "Choose a story", iconName: "applications-development-symbolic", description: "Stories from your project appear in the sidebar." }) })) }));
18
+ const selectedStoryId = selected?.id;
19
+ const reportSelection = useEffectEvent((id) => {
20
+ onStorySelected?.(id);
21
+ });
22
+ useEffect(() => {
23
+ if (selectedStoryId !== undefined) {
24
+ reportSelection(selectedStoryId);
25
+ }
26
+ }, [selectedStoryId]);
27
+ return (_jsx(AdwOverlaySplitView, { minSidebarWidth: 220, maxSidebarWidth: 300, sidebar: _jsx(AdwToolbarView, { top: _jsx(AdwHeaderBar, { titleWidget: _jsx(AdwWindowTitle, { title: title, subtitle: storyCount(snapshot.stories.length) }) }), children: _jsx(StoryNavigator, { stories: snapshot.stories, errors: snapshot.errors, selectedId: selectedStoryId, onSelect: setSelectedId }) }), children: selected ? (_jsx(StorybookPreview, { entry: selected }, selected.id)) : (_jsx(AdwToolbarView, { top: _jsx(AdwHeaderBar, {}), children: _jsx(AdwStatusPage, { name: "storybook-empty", title: snapshot.isLoading ? "Loading stories" : "Choose a story", iconName: "applications-development-symbolic", description: "Stories from your project appear in the sidebar." }) })) }));
20
28
  };
21
29
  /** Renders the Adwaita explorer application with navigation, story previews, controls, and actions. */
22
- const Storybook = ({ catalog, applicationId = "org.gtkx.Storybook", title = "GTKX Storybook", }) => (_jsx(AdwApplication, { applicationId: applicationId, flags: Gio.ApplicationFlags.NON_UNIQUE, children: _jsx(AdwApplicationWindow, { title: title, defaultWidth: 1200, defaultHeight: 800, onCloseRequest: quit, children: _jsx(StorybookView, { catalog: catalog, title: title }) }) }));
30
+ const Storybook = ({ catalog, applicationId = "org.gtkx.Storybook", title = "GTKX Storybook", initialStoryId, onStorySelected, }) => (_jsx(AdwApplication, { applicationId: applicationId, flags: Gio.ApplicationFlags.NON_UNIQUE, children: _jsx(AdwApplicationWindow, { title: title, defaultWidth: 1200, defaultHeight: 800, onCloseRequest: quit, children: _jsx(StorybookView, { catalog: catalog, title: title, initialStoryId: initialStoryId, onStorySelected: onStorySelected }) }) }));
23
31
  export { Storybook };
24
32
  //# sourceMappingURL=explorer-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-view.js","sourceRoot":"","sources":["../src/explorer-view.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAczD,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,GAAG,gBAAgB,EAAsB,EAAa,EAAE;IAC3F,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,QAAoB,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAChG,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC9D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAU,CAAC;IACvD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,C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gBAAgB,CAAC,UAAU,YAChF,KAAC,oBAAoB,IAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,YAC5F,KAAC,aAAa,IAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAI,GAC9B,GACV,CACpB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport {\n AdwApplication,\n AdwApplicationWindow,\n AdwHeaderBar,\n AdwOverlaySplitView,\n AdwStatusPage,\n AdwToolbarView,\n AdwWindowTitle,\n} from \"@gtkx/jsx/adw\";\nimport { quit } from \"@gtkx/react\";\nimport { useCallback, useState, useSyncExternalStore } from \"react\";\nimport type { StoryCatalog } from \"./catalog.js\";\nimport { StoryNavigator } from \"./explorer-navigator.js\";\nimport { StorybookPreview } from \"./explorer-preview.js\";\n\n/** Configuration for the native Storybook application shell. */\ntype StorybookProps = {\n /** Source catalog whose stories and loading errors appear in the explorer. */\n catalog: StoryCatalog;\n /** Gio application identifier; defaults to org.gtkx.Storybook. */\n applicationId?: string;\n /** Explorer window and sidebar title; defaults to GTKX Storybook. */\n title?: string;\n};\n\ntype StorybookViewProps = Pick<StorybookProps, \"catalog\" | \"title\">;\n\nconst StorybookView = ({ catalog, title = \"GTKX Storybook\" }: StorybookViewProps): ReactNode => {\n const subscribe = useCallback((listener: () => void) => catalog.subscribe(listener), [catalog]);\n const getSnapshot = useCallback(() => catalog.getSnapshot(), [catalog]);\n const snapshot = useSyncExternalStore(subscribe, getSnapshot);\n const [selectedId, setSelectedId] = useState<string>();\n const selected = snapshot.stories.find((entry) => entry.id === selectedId) ?? snapshot.stories[0];\n\n if (selectedId !== selected?.id) {\n setSelectedId(selected?.id);\n }\n\n return (\n <AdwOverlaySplitView\n minSidebarWidth={220}\n maxSidebarWidth={300}\n sidebar={(\n <AdwToolbarView\n topBar={(\n <AdwHeaderBar\n titleWidget={(\n <AdwWindowTitle title={title} subtitle={`${String(snapshot.stories.length)} stories`} />\n )}\n />\n )}\n >\n <StoryNavigator\n stories={snapshot.stories}\n errors={snapshot.errors}\n selectedId={selected?.id}\n onSelect={setSelectedId}\n />\n </AdwToolbarView>\n )}\n >\n {selected\n ? <StorybookPreview key={selected.id} entry={selected} />\n : (\n <AdwToolbarView topBar={<AdwHeaderBar />}>\n <AdwStatusPage\n name=\"storybook-empty\"\n title={snapshot.isLoading ? \"Loading stories\" : \"Choose a story\"}\n iconName=\"applications-development-symbolic\"\n description=\"Stories from your project appear in the sidebar.\"\n />\n </AdwToolbarView>\n )}\n </AdwOverlaySplitView>\n );\n};\n\n/** Renders the Adwaita explorer application with navigation, story previews, controls, and actions. */\nconst Storybook = ({\n catalog,\n applicationId = \"org.gtkx.Storybook\",\n title = \"GTKX Storybook\",\n}: StorybookProps): ReactNode => (\n <AdwApplication applicationId={applicationId} flags={Gio.ApplicationFlags.NON_UNIQUE}>\n <AdwApplicationWindow title={title} defaultWidth={1200} defaultHeight={800} onCloseRequest={quit}>\n <StorybookView catalog={catalog} title={title} />\n </AdwApplicationWindow>\n </AdwApplication>\n);\n\nexport { Storybook };\n"]}
1
+ {"version":3,"file":"explorer-view.js","sourceRoot":"","sources":["../src/explorer-view.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE/F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,gBAA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,CAAC,UAAU,YAChF,KAAC,oBAAoB,IAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,YAC5F,KAAC,aAAa,IACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,GAClC,GACiB,GACV,CACpB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport {\n AdwApplication,\n AdwApplicationWindow,\n AdwHeaderBar,\n AdwOverlaySplitView,\n AdwStatusPage,\n AdwToolbarView,\n AdwWindowTitle,\n} from \"@gtkx/jsx/adw\";\nimport { quit } from \"@gtkx/react\";\nimport { useCallback, useEffect, useEffectEvent, useState, useSyncExternalStore } from \"react\";\nimport type { StoryCatalog } from \"./catalog.js\";\nimport { StoryNavigator } from \"./explorer-navigator.js\";\nimport { StorybookPreview } from \"./explorer-preview.js\";\n\n/** Configuration for the native Storybook application shell. */\ntype StorybookProps = {\n /** Source catalog whose stories and loading errors appear in the explorer. */\n catalog: StoryCatalog;\n /** Gio application identifier; defaults to org.gtkx.Storybook. */\n applicationId?: string;\n /** Explorer window and sidebar title; defaults to GTKX Storybook. */\n title?: string;\n /** Story selected once the catalog lists it; the first story is selected otherwise. */\n initialStoryId?: string | undefined;\n /** Called with the identifier of each story the explorer selects. */\n onStorySelected?: ((id: string) => void) | undefined;\n};\n\ntype StorybookViewProps = Pick<StorybookProps, \"catalog\" | \"title\" | \"initialStoryId\" | \"onStorySelected\">;\n\nconst storyCount = (count: number): string => (count === 1 ? \"1 story\" : `${String(count)} stories`);\n\nconst StorybookView = ({\n catalog,\n title = \"GTKX Storybook\",\n initialStoryId,\n onStorySelected,\n}: StorybookViewProps): ReactNode => {\n const subscribe = useCallback((listener: () => void) => catalog.subscribe(listener), [catalog]);\n const getSnapshot = useCallback(() => catalog.getSnapshot(), [catalog]);\n const snapshot = useSyncExternalStore(subscribe, getSnapshot);\n const [selectedId, setSelectedId] = useState(initialStoryId);\n const selected = snapshot.stories.find((entry) => entry.id === selectedId) ?? snapshot.stories[0];\n\n if (selected !== undefined && selectedId !== selected.id) {\n setSelectedId(selected.id);\n }\n\n const selectedStoryId = selected?.id;\n const reportSelection = useEffectEvent((id: string) => {\n onStorySelected?.(id);\n });\n\n useEffect(() => {\n if (selectedStoryId !== undefined) {\n reportSelection(selectedStoryId);\n }\n }, [selectedStoryId]);\n\n return (\n <AdwOverlaySplitView\n minSidebarWidth={220}\n maxSidebarWidth={300}\n sidebar={\n <AdwToolbarView\n top={\n <AdwHeaderBar\n titleWidget={\n <AdwWindowTitle title={title} subtitle={storyCount(snapshot.stories.length)} />\n }\n />\n }\n >\n <StoryNavigator\n stories={snapshot.stories}\n errors={snapshot.errors}\n selectedId={selectedStoryId}\n onSelect={setSelectedId}\n />\n </AdwToolbarView>\n }\n >\n {selected ? (\n <StorybookPreview key={selected.id} entry={selected} />\n ) : (\n <AdwToolbarView top={<AdwHeaderBar />}>\n <AdwStatusPage\n name=\"storybook-empty\"\n title={snapshot.isLoading ? \"Loading stories\" : \"Choose a story\"}\n iconName=\"applications-development-symbolic\"\n description=\"Stories from your project appear in the sidebar.\"\n />\n </AdwToolbarView>\n )}\n </AdwOverlaySplitView>\n );\n};\n\n/** Renders the Adwaita explorer application with navigation, story previews, controls, and actions. */\nconst Storybook = ({\n catalog,\n applicationId = \"org.gtkx.Storybook\",\n title = \"GTKX Storybook\",\n initialStoryId,\n onStorySelected,\n}: StorybookProps): ReactNode => (\n <AdwApplication applicationId={applicationId} flags={Gio.ApplicationFlags.NON_UNIQUE}>\n <AdwApplicationWindow title={title} defaultWidth={1200} defaultHeight={800} onCloseRequest={quit}>\n <StorybookView\n catalog={catalog}\n title={title}\n initialStoryId={initialStoryId}\n onStorySelected={onStorySelected}\n />\n </AdwApplicationWindow>\n </AdwApplication>\n);\n\nexport { Storybook };\n"]}
@@ -13,6 +13,10 @@ type StorybookSession = {
13
13
  declare const startStorybook: (options: {
14
14
  /** Gio application identifier assigned to the explorer application. */
15
15
  applicationId: string;
16
+ /** Story to select once it is loaded, such as the one a restarted explorer was showing. */
17
+ initialStoryId?: string | undefined;
18
+ /** Called with the identifier of each story the explorer selects. */
19
+ onStorySelected?: ((id: string) => void) | undefined;
16
20
  }) => StorybookSession;
17
21
  export { startStorybook };
18
22
  export type { StorybookSession };
@@ -1 +1 @@
1
- {"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../src/explorer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,2EAA2E;AAC3E,KAAK,gBAAgB,GAAG;IACpB,kGAAkG;IAClG,aAAa,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,sFAAsF;IACtF,oBAAoB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,wFAAwF;AACxF,QAAA,MAAM,cAAc,GAAI,SAAS;IAC7B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;CACzB,KAAG,gBAcH,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;AACjC,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"explorer.d.ts","sourceRoot":"","sources":["../src/explorer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,2EAA2E;AAC3E,KAAK,gBAAgB,GAAG;IACpB,kGAAkG;IAClG,aAAa,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,sFAAsF;IACtF,oBAAoB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,wFAAwF;AACxF,QAAA,MAAM,cAAc,YAAa;IAC7B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,2FAA2F;IAC3F,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,qEAAqE;IACrE,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxD,KAAG,gBAqBH,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;AACjC,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/explorer.js CHANGED
@@ -6,7 +6,12 @@ import { Storybook } from "./explorer-view.js";
6
6
  const startStorybook = (options) => {
7
7
  const catalog = new StoryCatalog();
8
8
  const root = createRoot(undefined, { onUncaughtError: catalog.reportError.bind(catalog) });
9
- root.render(createElement(Storybook, { catalog, applicationId: options.applicationId }));
9
+ root.render(createElement(Storybook, {
10
+ catalog,
11
+ applicationId: options.applicationId,
12
+ initialStoryId: options.initialStoryId,
13
+ onStorySelected: options.onStorySelected,
14
+ }));
10
15
  return {
11
16
  updateStories: (sources, preview) => catalog.load(sources, preview),
12
17
  reportStorybookError: (cause) => {
@@ -1 +1 @@
1
- {"version":3,"file":"explorer.js","sourceRoot":"","sources":["../src/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAY/C,wFAAwF;AACxF,MAAM,cAAc,GAAG,CAAC,OAGvB,EAAoB,EAAE;IACnB,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3F,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IAEzF,OAAO;QACH,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;QACnE,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACP,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["import { createRoot } from \"@gtkx/react\";\nimport { createElement } from \"react\";\nimport type { StorySource } from \"./catalog.js\";\nimport type { Preview } from \"./types.js\";\nimport { StoryCatalog } from \"./catalog.js\";\nimport { Storybook } from \"./explorer-view.js\";\n\n/** Controls a running native Storybook explorer and its source catalog. */\ntype StorybookSession = {\n /** Replaces discovered sources and preview annotations, rejecting if any source fails to load. */\n updateStories: (sources: StorySource[], preview?: Preview) => Promise<void>;\n /** Displays a session failure while keeping successfully loaded stories available. */\n reportStorybookError: (cause: unknown) => void;\n /** Unmounts the explorer and its story windows or dialogs. */\n stop: () => void;\n};\n\n/** Starts a native explorer and returns the handle used to load stories and stop it. */\nconst startStorybook = (options: {\n /** Gio application identifier assigned to the explorer application. */\n applicationId: string;\n}): StorybookSession => {\n const catalog = new StoryCatalog();\n const root = createRoot(undefined, { onUncaughtError: catalog.reportError.bind(catalog) });\n root.render(createElement(Storybook, { catalog, applicationId: options.applicationId }));\n\n return {\n updateStories: (sources, preview) => catalog.load(sources, preview),\n reportStorybookError: (cause) => {\n catalog.reportError(cause);\n },\n stop: () => {\n root.unmount();\n },\n };\n};\n\nexport { startStorybook };\nexport type { StorybookSession };\nexport type { StoryCatalogSnapshot, StoryEntry, StoryLoadError, StorySource } from \"./catalog.js\";\n\nexport { StoryCatalog } from \"./catalog.js\";\n\nexport { Storybook } from \"./explorer-view.js\";\n"]}
1
+ {"version":3,"file":"explorer.js","sourceRoot":"","sources":["../src/explorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAY/C,wFAAwF;AACxF,MAAM,cAAc,GAAG,CAAC,OAOvB,EAAoB,EAAE;IACnB,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3F,IAAI,CAAC,MAAM,CACP,aAAa,CAAC,SAAS,EAAE;QACrB,OAAO;QACP,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,eAAe,EAAE,OAAO,CAAC,eAAe;KAC3C,CAAC,CACL,CAAC;IAEF,OAAO;QACH,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;QACnE,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACP,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["import { createRoot } from \"@gtkx/react\";\nimport { createElement } from \"react\";\nimport type { StorySource } from \"./catalog.js\";\nimport type { Preview } from \"./types.js\";\nimport { StoryCatalog } from \"./catalog.js\";\nimport { Storybook } from \"./explorer-view.js\";\n\n/** Controls a running native Storybook explorer and its source catalog. */\ntype StorybookSession = {\n /** Replaces discovered sources and preview annotations, rejecting if any source fails to load. */\n updateStories: (sources: StorySource[], preview?: Preview) => Promise<void>;\n /** Displays a session failure while keeping successfully loaded stories available. */\n reportStorybookError: (cause: unknown) => void;\n /** Unmounts the explorer and its story windows or dialogs. */\n stop: () => void;\n};\n\n/** Starts a native explorer and returns the handle used to load stories and stop it. */\nconst startStorybook = (options: {\n /** Gio application identifier assigned to the explorer application. */\n applicationId: string;\n /** Story to select once it is loaded, such as the one a restarted explorer was showing. */\n initialStoryId?: string | undefined;\n /** Called with the identifier of each story the explorer selects. */\n onStorySelected?: ((id: string) => void) | undefined;\n}): StorybookSession => {\n const catalog = new StoryCatalog();\n const root = createRoot(undefined, { onUncaughtError: catalog.reportError.bind(catalog) });\n root.render(\n createElement(Storybook, {\n catalog,\n applicationId: options.applicationId,\n initialStoryId: options.initialStoryId,\n onStorySelected: options.onStorySelected,\n }),\n );\n\n return {\n updateStories: (sources, preview) => catalog.load(sources, preview),\n reportStorybookError: (cause) => {\n catalog.reportError(cause);\n },\n stop: () => {\n root.unmount();\n },\n };\n};\n\nexport { startStorybook };\nexport type { StorybookSession };\nexport type { StoryCatalogSnapshot, StoryEntry, StoryLoadError, StorySource } from \"./catalog.js\";\n\nexport { StoryCatalog } from \"./catalog.js\";\n\nexport { Storybook } from \"./explorer-view.js\";\n"]}
package/dist/types.d.ts CHANGED
@@ -119,11 +119,17 @@ type StoryModule = {
119
119
  /** Component metadata validated when the module is composed. */
120
120
  default: unknown;
121
121
  };
122
+ /** Whether a story's declared args name only args of the component metadata, as stories typed from the metadata do. */
123
+ type IsMetaArgs<TArgs, TMetaArgs> = [Exclude<keyof TArgs, keyof TMetaArgs>] extends [never] ? true : false;
124
+ /** Args of a story export: the component metadata's args, or the args type the story declares itself. */
125
+ type StoryArgs<TModule extends StoryModule, TStory> = TStory extends StoryAnnotations<infer TArgs extends object> ? IsMetaArgs<TArgs, ArgsFrom<TModule["default"]>> extends true ? TStory extends StoryAnnotations<ArgsFrom<TModule["default"]>> ? ArgsFrom<TModule["default"]> : TArgs : TArgs : never;
122
126
  /** Named module exports whose types match CSF3 stories, excluding module bookkeeping. */
123
127
  type StoryKeys<TModule extends StoryModule> = {
124
- [Key in keyof TModule]: Key extends "default" | "__esModule" | "__namedExportsOrder" ? never : TModule[Key] extends StoryAnnotations<ArgsFrom<TModule["default"]>> ? Key : never;
128
+ [Key in keyof TModule]: Key extends "default" | "__esModule" | "__namedExportsOrder" ? never : [StoryArgs<TModule, TModule[Key]>] extends [never] ? never : Key;
125
129
  }[keyof TModule] & string;
126
130
  /** Composed stories keyed by their original named exports. */
127
- type ComposedStories<TModule extends StoryModule> = Record<StoryKeys<TModule>, ComposedStory<ArgsFrom<TModule["default"]>>>;
131
+ type ComposedStories<TModule extends StoryModule> = {
132
+ [Key in StoryKeys<TModule>]: ComposedStory<StoryArgs<TModule, TModule[Key]>>;
133
+ };
128
134
  export type { Args, ArgTypes, ComponentMeta, ComposedStories, ComposedStory, Decorator, Meta, Preview, StoryAnnotations, StoryContext, StoryContextUpdate, StoryModule, StoryObj, StoryRender, };
129
135
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EACR,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,gBAAgB,IAAI,oBAAoB,EACxC,QAAQ,IAAI,iBAAiB,EAC7B,YAAY,IAAI,gBAAgB,EACnC,MAAM,0BAA0B,CAAC;AAElC,0FAA0F;AAC1F,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,iFAAiF;AACjF,KAAK,cAAc,CAAC,KAAK,SAAS,MAAM,GAAG,IAAI,IAAI,QAAQ,GAAG;IAC1D,kDAAkD;IAClD,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAChC,iDAAiD;IACjD,WAAW,EAAE,SAAS,CAAC;IACvB,0DAA0D;IAC1D,aAAa,EAAE,GAAG,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ACzG,KAAK,SAAS,CAAC,OAAO,SAAS,WAAW,EAAE,MAAM,IAC9C,MAAM,SAAS,gBAAgB,CAAC,MAAM,KAAK,SAAS,MAAM,CAAC,GACrD,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACxD,MAAM,SAAS,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GACzD,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAC5B,KAAK,GACT,KAAK,GACT,KAAK,CAAC;AAEhB,yFAAyF;AACzF,KAAK,SAAS,CAAC,OAAO,SAAS,WAAW,IAAI;KACzC,GAAG,IAAI,MAAM,OAAO,GAAG,GAAG,SAAS,SAAS,GAAG,YAAY,GAAG,qBAAqB,GAC9E,KAAK,GACL,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChD,KAAK,GACL,GAAG;CACd,CAAC,MAAM,OAAO,CAAC,GACZ,MAAM,CAAC;AAEX,8DAA8D;AAC9D,KAAK,eAAe,CAAC,OAAO,SAAS,WAAW,IAAI;KAC/C,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;CAC/E,CAAC;AAEF,YAAY,EACR,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,WAAW,GACd,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport type {\n ArgsFromMeta,\n ComponentAnnotations,\n GlobalTypes,\n Renderer,\n StoryAnnotations as StorybookAnnotations,\n ArgTypes as StorybookArgTypes,\n StoryContext as StorybookContext,\n} from \"storybook/internal/types\";\n\n/** Named values supplied to a story, including component props and custom render args. */\ntype Args = Record<string, unknown>;\n\n/** Storybook renderer types for React content rendered as native GTK widgets. */\ntype NativeRenderer<TArgs extends object = Args> = Renderer & {\n /** React component receiving the story's args. */\n component: ComponentType<TArgs>;\n /** React content returned by story rendering. */\n storyResult: ReactNode;\n /** Native widget type representing the preview canvas. */\n canvasElement: Gtk.Widget;\n};\n\n/** Explicit argument metadata used to configure native controls and named actions. */\ntype ArgTypes<TArgs extends object = Args> = Partial<StorybookArgTypes<TArgs>>;\n\n/** Composed story identity, args, and annotations available to render functions and decorators. */\ntype StoryContext<TArgs extends object = Args> = Pick<\n StorybookContext<NativeRenderer<TArgs>, TArgs>,\n \"id\" | \"name\" | \"title\" | \"args\" | \"initialArgs\" | \"argTypes\" | \"viewMode\"\n> & {\n /** Parameters merged from preview, component metadata, and the story. */\n parameters: Args;\n /** Global values after applying preview defaults and metadata or story overrides. */\n globals: Args;\n};\n\n/** Renders native React content from the current story args and composition context. */\ntype StoryRender<TArgs extends object = Args> = (args: TArgs, context: StoryContext<TArgs>) => ReactNode;\n\n/** Values a decorator can override when invoking the decorated story. */\ntype StoryContextUpdate<TArgs extends object = Args> = {\n /** Partial args merged into the current invocation without changing composed defaults. */\n args?: Partial<TArgs>;\n /** Global values overridden for the decorated invocation. */\n globals?: Args;\n};\n\n/** Wraps story content and can override args or globals when invoking the supplied Story function. */\ntype Decorator<TArgs extends object = Args> = (\n Story: (update?: StoryContextUpdate<TArgs>) => ReactNode,\n context: StoryContext<TArgs>,\n) => ReactNode;\n\n/** Shared CSF annotations accepted at preview, component, and story scope. */\ntype Annotations<TArgs extends object> = {\n /** Default args, with more specific annotation scopes taking precedence. */\n args?: Partial<TArgs>;\n /** Explicit argument descriptions, controls, and action registrations. */\n argTypes?: ArgTypes<TArgs>;\n /** Parameters merged across scopes, including native preview and layout settings. */\n parameters?: Args;\n /** Wrappers composed around the story's render function. */\n decorators?: Decorator<TArgs>[];\n /** Custom renderer used in place of the component or a less specific render annotation. */\n render?: StoryRender<TArgs>;\n /** Storybook tags composed with tags from other annotation scopes. */\n tags?: string[];\n};\n\n/** Default export metadata describing a component's stories and their shared annotations. */\ntype ComponentMeta<TArgs extends object> = Annotations<TArgs> & Pick<\n ComponentAnnotations<NativeRenderer<TArgs>, TArgs>,\n \"title\" | \"id\" | \"includeStories\" | \"excludeStories\"\n> & {\n /** Component rendered with story args when no custom render annotation applies. */\n component?: ComponentType<TArgs>;\n /** Global overrides shared by this component's stories. */\n globals?: Args;\n};\n\n/** Resolves a component's props or accepts an explicitly supplied args object type. */\ntype ComponentOrProps<T> = T extends ComponentType<infer Props extends object>\n ? Props\n : T extends object ? T : Args;\n\n/** Presents combined inferred args as a single object type. */\ntype Simplify<T> = { [Key in keyof T]: T[Key] };\n\n/** Infers story args from component props, render functions, decorators, or declared defaults. */\ntype ArgsFrom<T> = T extends { component?: infer Component; render?: unknown; decorators?: unknown }\n ? Simplify<\n (NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) &\n ArgsFromMeta<NativeRenderer, T>\n >\n : T extends { args: infer Defaults extends object } ? Defaults : Args;\n\n/** CSF3 default export metadata typed from a React component or an explicit args type. */\ntype Meta<T = Args> = ComponentMeta<ComponentOrProps<T>>;\n\n/** Annotations for one CSF3 story object, including its display name and global overrides. */\ntype StoryAnnotations<TArgs extends object> = Annotations<TArgs> & {\n /** Display name overriding the name derived from the story's named export. */\n name?: string;\n /** Global overrides applied specifically to this story. */\n globals?: Args;\n};\n\n/** Extracts args already defaulted by component metadata. */\ntype DefaultArgs<T> = T extends { args: infer Defaults } ? Defaults : Record<never, never>;\n\n/** Makes args with metadata defaults optional while preserving other required args. */\ntype RequiredStoryArgs<T, TArgs extends object> =\n Omit<TArgs, keyof DefaultArgs<T>> & Partial<Pick<TArgs, keyof TArgs & keyof DefaultArgs<T>>>;\n\n/** CSF3 story object inferred from metadata, a React component, or an explicit args type. */\ntype StoryObj<T = Args> = T extends { component?: unknown; render?: unknown; decorators?: unknown; args?: unknown }\n ? StoryAnnotations<ArgsFrom<T>> & Pick<\n StorybookAnnotations<NativeRenderer<ArgsFrom<T>>, ArgsFrom<T>, RequiredStoryArgs<T, ArgsFrom<T>>>,\n \"args\"\n >\n : StoryAnnotations<ComponentOrProps<T>>;\n\n/** Project annotations shared by all composed stories. */\ntype Preview = Annotations<Args> & {\n /** Initial global values available in story rendering and decorators. */\n initialGlobals?: Args;\n /** Storybook metadata describing global values; native toolbar controls are not provided. */\n globalTypes?: GlobalTypes;\n};\n\n/** Renderable story with merged annotations; props override its composed default args. */\ntype ComposedStory<TArgs extends object = Args> = ((args: Partial<TArgs>) => ReactNode) & {\n /** Default args merged across preview, component metadata, and story annotations. */\n args: Partial<TArgs>;\n /** Composed argument metadata available to native controls and actions. */\n argTypes: ArgTypes<TArgs>;\n /** Composed parameters available to the renderer and explorer. */\n parameters: Args;\n /** Composed global values available in story context. */\n globals: Args;\n /** Storybook identifier derived from component identity and the story export. */\n id: string;\n /** Story name attached by Storybook's portable composition API. */\n storyName: string;\n /** Tags resulting from composition across annotation scopes. */\n tags: string[];\n};\n\n/** Imported CSF module containing default metadata and named story exports. */\ntype StoryModule = {\n /** Component metadata validated when the module is composed. */\n default: unknown;\n};\n\n/** Named module exports whose types match CSF3 stories, excluding module bookkeeping. */\ntype StoryKeys<TModule extends StoryModule> = {\n [Key in keyof TModule]: Key extends \"default\" | \"__esModule\" | \"__namedExportsOrder\"\n ? never\n : TModule[Key] extends StoryAnnotations<ArgsFrom<TModule[\"default\"]>>\n ? Key\n : never;\n}[keyof TModule] & string;\n\n/** Composed stories keyed by their original named exports. */\ntype ComposedStories<TModule extends StoryModule> = Record<\n StoryKeys<TModule>,\n ComposedStory<ArgsFrom<TModule[\"default\"]>>\n>;\n\nexport type {\n Args,\n ArgTypes,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Decorator,\n Meta,\n Preview,\n StoryAnnotations,\n StoryContext,\n StoryContextUpdate,\n StoryModule,\n StoryObj,\n StoryRender,\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ComponentType, ReactNode } from \"react\";\nimport type {\n ArgsFromMeta,\n ComponentAnnotations,\n GlobalTypes,\n Renderer,\n StoryAnnotations as StorybookAnnotations,\n ArgTypes as StorybookArgTypes,\n StoryContext as StorybookContext,\n} from \"storybook/internal/types\";\n\n/** Named values supplied to a story, including component props and custom render args. */\ntype Args = Record<string, unknown>;\n\n/** Storybook renderer types for React content rendered as native GTK widgets. */\ntype NativeRenderer<TArgs extends object = Args> = Renderer & {\n /** React component receiving the story's args. */\n component: ComponentType<TArgs>;\n /** React content returned by story rendering. */\n storyResult: ReactNode;\n /** Native widget type representing the preview canvas. */\n canvasElement: Gtk.Widget;\n};\n\n/** Explicit argument metadata used to configure native controls and named actions. */\ntype ArgTypes<TArgs extends object = Args> = Partial<StorybookArgTypes<TArgs>>;\n\n/** Composed story identity, args, and annotations available to render functions and decorators. */\ntype StoryContext<TArgs extends object = Args> = Pick<\n StorybookContext<NativeRenderer<TArgs>, TArgs>,\n \"id\" | \"name\" | \"title\" | \"args\" | \"initialArgs\" | \"argTypes\" | \"viewMode\"\n> & {\n /** Parameters merged from preview, component metadata, and the story. */\n parameters: Args;\n /** Global values after applying preview defaults and metadata or story overrides. */\n globals: Args;\n};\n\n/** Renders native React content from the current story args and composition context. */\ntype StoryRender<TArgs extends object = Args> = (args: TArgs, context: StoryContext<TArgs>) => ReactNode;\n\n/** Values a decorator can override when invoking the decorated story. */\ntype StoryContextUpdate<TArgs extends object = Args> = {\n /** Partial args merged into the current invocation without changing composed defaults. */\n args?: Partial<TArgs>;\n /** Global values overridden for the decorated invocation. */\n globals?: Args;\n};\n\n/** Wraps story content and can override args or globals when invoking the supplied Story function. */\ntype Decorator<TArgs extends object = Args> = (\n Story: (update?: StoryContextUpdate<TArgs>) => ReactNode,\n context: StoryContext<TArgs>,\n) => ReactNode;\n\n/** Shared CSF annotations accepted at preview, component, and story scope. */\ntype Annotations<TArgs extends object> = {\n /** Default args, with more specific annotation scopes taking precedence. */\n args?: Partial<TArgs>;\n /** Explicit argument descriptions, controls, and action registrations. */\n argTypes?: ArgTypes<TArgs>;\n /** Parameters merged across scopes, including native preview and layout settings. */\n parameters?: Args;\n /** Wrappers composed around the story's render function. */\n decorators?: Decorator<TArgs>[];\n /** Custom renderer used in place of the component or a less specific render annotation. */\n render?: StoryRender<TArgs>;\n /** Storybook tags composed with tags from other annotation scopes. */\n tags?: string[];\n};\n\n/** Default export metadata describing a component's stories and their shared annotations. */\ntype ComponentMeta<TArgs extends object> = Annotations<TArgs> &\n Pick<ComponentAnnotations<NativeRenderer<TArgs>, TArgs>, \"title\" | \"id\" | \"includeStories\" | \"excludeStories\"> & {\n /** Component rendered with story args when no custom render annotation applies. */\n component?: ComponentType<TArgs>;\n /** Global overrides shared by this component's stories. */\n globals?: Args;\n };\n\n/** Resolves a component's props or accepts an explicitly supplied args object type. */\ntype ComponentOrProps<T> = T extends ComponentType<infer Props extends object> ? Props : T extends object ? T : Args;\n\n/** Presents combined inferred args as a single object type. */\ntype Simplify<T> = { [Key in keyof T]: T[Key] };\n\n/** Infers story args from component props, render functions, decorators, or declared defaults. */\ntype ArgsFrom<T> = T extends { component?: infer Component; render?: unknown; decorators?: unknown }\n ? Simplify<\n (NonNullable<Component> extends ComponentType<infer Props extends object> ? Props : object) &\n ArgsFromMeta<NativeRenderer, T>\n >\n : T extends { args: infer Defaults extends object }\n ? Defaults\n : Args;\n\n/** CSF3 default export metadata typed from a React component or an explicit args type. */\ntype Meta<T = Args> = ComponentMeta<ComponentOrProps<T>>;\n\n/** Annotations for one CSF3 story object, including its display name and global overrides. */\ntype StoryAnnotations<TArgs extends object> = Annotations<TArgs> & {\n /** Display name overriding the name derived from the story's named export. */\n name?: string;\n /** Global overrides applied specifically to this story. */\n globals?: Args;\n};\n\n/** Extracts args already defaulted by component metadata. */\ntype DefaultArgs<T> = T extends { args: infer Defaults } ? Defaults : Record<never, never>;\n\n/** Makes args with metadata defaults optional while preserving other required args. */\ntype RequiredStoryArgs<T, TArgs extends object> = Omit<TArgs, keyof DefaultArgs<T>> &\n Partial<Pick<TArgs, keyof TArgs & keyof DefaultArgs<T>>>;\n\n/** CSF3 story object inferred from metadata, a React component, or an explicit args type. */\ntype StoryObj<T = Args> = T extends { component?: unknown; render?: unknown; decorators?: unknown; args?: unknown }\n ? StoryAnnotations<ArgsFrom<T>> &\n Pick<\n StorybookAnnotations<NativeRenderer<ArgsFrom<T>>, ArgsFrom<T>, RequiredStoryArgs<T, ArgsFrom<T>>>,\n \"args\"\n >\n : StoryAnnotations<ComponentOrProps<T>>;\n\n/** Project annotations shared by all composed stories. */\ntype Preview = Annotations<Args> & {\n /** Initial global values available in story rendering and decorators. */\n initialGlobals?: Args;\n /** Storybook metadata describing global values; native toolbar controls are not provided. */\n globalTypes?: GlobalTypes;\n};\n\n/** Renderable story with merged annotations; props override its composed default args. */\ntype ComposedStory<TArgs extends object = Args> = ((args: Partial<TArgs>) => ReactNode) & {\n /** Default args merged across preview, component metadata, and story annotations. */\n args: Partial<TArgs>;\n /** Composed argument metadata available to native controls and actions. */\n argTypes: ArgTypes<TArgs>;\n /** Composed parameters available to the renderer and explorer. */\n parameters: Args;\n /** Composed global values available in story context. */\n globals: Args;\n /** Storybook identifier derived from component identity and the story export. */\n id: string;\n /** Story name attached by Storybook's portable composition API. */\n storyName: string;\n /** Tags resulting from composition across annotation scopes. */\n tags: string[];\n};\n\n/** Imported CSF module containing default metadata and named story exports. */\ntype StoryModule = {\n /** Component metadata validated when the module is composed. */\n default: unknown;\n};\n\n/** Whether a story's declared args name only args of the component metadata, as stories typed from the metadata do. */\ntype IsMetaArgs<TArgs, TMetaArgs> = [Exclude<keyof TArgs, keyof TMetaArgs>] extends [never] ? true : false;\n\n/** Args of a story export: the component metadata's args, or the args type the story declares itself. */\ntype StoryArgs<TModule extends StoryModule, TStory> =\n TStory extends StoryAnnotations<infer TArgs extends object>\n ? IsMetaArgs<TArgs, ArgsFrom<TModule[\"default\"]>> extends true\n ? TStory extends StoryAnnotations<ArgsFrom<TModule[\"default\"]>>\n ? ArgsFrom<TModule[\"default\"]>\n : TArgs\n : TArgs\n : never;\n\n/** Named module exports whose types match CSF3 stories, excluding module bookkeeping. */\ntype StoryKeys<TModule extends StoryModule> = {\n [Key in keyof TModule]: Key extends \"default\" | \"__esModule\" | \"__namedExportsOrder\"\n ? never\n : [StoryArgs<TModule, TModule[Key]>] extends [never]\n ? never\n : Key;\n}[keyof TModule] &\n string;\n\n/** Composed stories keyed by their original named exports. */\ntype ComposedStories<TModule extends StoryModule> = {\n [Key in StoryKeys<TModule>]: ComposedStory<StoryArgs<TModule, TModule[Key]>>;\n};\n\nexport type {\n Args,\n ArgTypes,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Decorator,\n Meta,\n Preview,\n StoryAnnotations,\n StoryContext,\n StoryContextUpdate,\n StoryModule,\n StoryObj,\n StoryRender,\n};\n"]}
@@ -1,4 +1,5 @@
1
- import type { ComponentMeta, ComposedStory, Preview, StoryAnnotations, StoryRender } from "./types.js";
1
+ import type { InputType } from "storybook/internal/types";
2
+ import type { Args, ComponentMeta, ComposedStory, Preview, StoryAnnotations, StoryRender } from "./types.js";
2
3
  type ComposeStory = <TArgs extends object>(...annotations: [
3
4
  story: StoryAnnotations<TArgs>,
4
5
  meta: ComponentMeta<TArgs>,
@@ -9,6 +10,7 @@ type ComposeStory = <TArgs extends object>(...annotations: [
9
10
  exportName?: string
10
11
  ]) => ComposedStory<TArgs>;
11
12
  declare const composeStoryAnnotations: ComposeStory;
12
- export { composeStoryAnnotations };
13
+ declare const isConditionalArgIncluded: (argType: InputType, args: Args, globals: Args) => boolean;
14
+ export { composeStoryAnnotations, isConditionalArgIncluded };
13
15
  export { isExportStory, storyNameFromExport } from "storybook/internal/csf";
14
16
  //# sourceMappingURL=upstream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,WAAW,EACd,MAAM,YAAY,CAAC;AAEpB,KAAK,YAAY,GAAG,CAAC,KAAK,SAAS,MAAM,EACrC,GAAG,WAAW,EAAE;IACZ,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC9B,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;IAC1B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;KAAE;IACxC,UAAU,CAAC,EAAE,MAAM;CACtB,KACA,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1B,QAAA,MAAM,uBAAuB,EAAmB,YAAY,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7G,KAAK,YAAY,GAAG,CAAC,KAAK,SAAS,MAAM,EACrC,GAAG,WAAW,EAAE;IACZ,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC;IAC9B,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;IAC1B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE;QAAE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;KAAE;IACxC,UAAU,CAAC,EAAE,MAAM;CACtB,KACA,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1B,QAAA,MAAM,uBAAuB,EAAmB,YAAY,CAAC;AAE7D,QAAA,MAAM,wBAAwB,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,OAA+B,CAAC;AAEnH,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/upstream.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { includeConditionalArg } from "storybook/internal/csf";
1
2
  import { composeStory } from "storybook/preview-api";
2
3
  const composeStoryAnnotations = composeStory;
3
- export { composeStoryAnnotations };
4
+ const isConditionalArgIncluded = includeConditionalArg;
5
+ export { composeStoryAnnotations, isConditionalArgIncluded };
4
6
  export { isExportStory, storyNameFromExport } from "storybook/internal/csf";
5
7
  //# sourceMappingURL=upstream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAmBrD,MAAM,uBAAuB,GAAG,YAA4B,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import { composeStory } from \"storybook/preview-api\";\nimport type {\n ComponentMeta,\n ComposedStory,\n Preview,\n StoryAnnotations,\n StoryRender,\n} from \"./types.js\";\n\ntype ComposeStory = <TArgs extends object>(\n ...annotations: [\n story: StoryAnnotations<TArgs>,\n meta: ComponentMeta<TArgs>,\n preview: Preview,\n renderer: { render: StoryRender<TArgs> },\n exportName?: string,\n ]\n) => ComposedStory<TArgs>;\n\nconst composeStoryAnnotations = composeStory as ComposeStory;\n\nexport { composeStoryAnnotations };\n\nexport { isExportStory, storyNameFromExport } from \"storybook/internal/csf\";\n"]}
1
+ {"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAarD,MAAM,uBAAuB,GAAG,YAA4B,CAAC;AAE7D,MAAM,wBAAwB,GAA+D,qBAAqB,CAAC;AAEnH,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import type { InputType } from \"storybook/internal/types\";\nimport { includeConditionalArg } from \"storybook/internal/csf\";\nimport { composeStory } from \"storybook/preview-api\";\nimport type { Args, ComponentMeta, ComposedStory, Preview, StoryAnnotations, StoryRender } from \"./types.js\";\n\ntype ComposeStory = <TArgs extends object>(\n ...annotations: [\n story: StoryAnnotations<TArgs>,\n meta: ComponentMeta<TArgs>,\n preview: Preview,\n renderer: { render: StoryRender<TArgs> },\n exportName?: string,\n ]\n) => ComposedStory<TArgs>;\n\nconst composeStoryAnnotations = composeStory as ComposeStory;\n\nconst isConditionalArgIncluded: (argType: InputType, args: Args, globals: Args) => boolean = includeConditionalArg;\n\nexport { composeStoryAnnotations, isConditionalArgIncluded };\n\nexport { isExportStory, storyNameFromExport } from \"storybook/internal/csf\";\n"]}