@gtkx/storybook 2.0.0-beta.11 → 2.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/actions-panel.d.ts.map +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +2 -1
- package/dist/actions.js.map +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +7 -4
- package/dist/catalog.js.map +1 -1
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +22 -8
- package/dist/controls.js.map +1 -1
- package/dist/explorer-navigator.d.ts.map +1 -1
- package/dist/explorer-navigator.js.map +1 -1
- package/dist/explorer-preview.d.ts.map +1 -1
- package/dist/explorer-preview.js +7 -10
- package/dist/explorer-preview.js.map +1 -1
- package/dist/explorer-view.d.ts.map +1 -1
- package/dist/explorer-view.js +1 -3
- package/dist/explorer-view.js.map +1 -1
- package/dist/explorer.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/upstream.d.ts.map +1 -1
- package/dist/upstream.js.map +1 -1
- package/package.json +14 -21
- package/src/actions.ts +28 -33
- package/src/catalog.ts +16 -9
- package/src/compose.ts +13 -7
- package/src/controls.tsx +31 -13
- package/src/explorer-navigator.tsx +18 -24
- package/src/explorer-preview.tsx +41 -36
- package/src/explorer-view.tsx +18 -18
- package/src/types.ts +25 -25
- package/src/upstream.ts +1 -7
|
@@ -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,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AE,OAAO,QAAC,OAAO,kBAC1D,KAAC,eAAe,IAAwB,IAAI,EAAE,KAAK,CAAC,IAAI,YACnD,KAAK,CAAC,KAAK,KAAK,IAAI;4BACjB,CAAC,CAAC,KAAC,cAAc,IAAC,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;AAiBzC,MAAM,eAAgB,SAAQ,SAAuC;IACjE,MAAM,CAAC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AAC,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, 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: 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 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(\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 () => 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 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} 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={\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"]}
|
|
@@ -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,
|
|
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,uCAIZ,cAAc,KAAG,SAMnB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/explorer-view.js
CHANGED
|
@@ -14,9 +14,7 @@ const StorybookView = ({ catalog, title = "GTKX Storybook" }) => {
|
|
|
14
14
|
if (selectedId !== selected?.id) {
|
|
15
15
|
setSelectedId(selected?.id);
|
|
16
16
|
}
|
|
17
|
-
return (_jsx(AdwOverlaySplitView, { minSidebarWidth: 220, maxSidebarWidth: 300, sidebar:
|
|
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." }) })) }));
|
|
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 ? (_jsx(StorybookPreview, { entry: selected }, selected.id)) : (_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." }) })) }));
|
|
20
18
|
};
|
|
21
19
|
/** Renders the Adwaita explorer application with navigation, story previews, controls, and actions. */
|
|
22
20
|
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 }) }) }));
|
|
@@ -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,OAA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\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"]}
|
package/dist/explorer.d.ts.map
CHANGED
|
@@ -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,
|
|
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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,YAAY,GAAG,qBAAqB,GAC9E,KAAK,GACL,OAAO,CAAC,GAAG,CAAC,SAAS,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GACjE,GAAG,GACH,KAAK;CAChB,CAAC,MAAM,OAAO,CAAC,GACZ,MAAM,CAAC;AAEX,8DAA8D;AAC9D,KAAK,eAAe,CAAC,OAAO,SAAS,WAAW,IAAI,MAAM,CACtD,SAAS,CAAC,OAAO,CAAC,EAClB,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAC9C,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>
|
|
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/** 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] &\n 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"]}
|
package/dist/upstream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvG,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"}
|
package/dist/upstream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"upstream.js","sourceRoot":"","sources":["../src/upstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAarD,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 { 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\nexport { composeStoryAnnotations };\n\nexport { isExportStory, storyNameFromExport } from \"storybook/internal/csf\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/storybook",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
|
+
"description": "Native component stories for GTKX.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
7
7
|
"gtk",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"react",
|
|
11
11
|
"storybook",
|
|
12
12
|
"csf",
|
|
13
|
-
"linux"
|
|
13
|
+
"linux",
|
|
14
|
+
"gnome",
|
|
15
|
+
"desktop"
|
|
14
16
|
],
|
|
15
17
|
"homepage": "https://gtkx.dev",
|
|
16
18
|
"bugs": {
|
|
@@ -50,36 +52,27 @@
|
|
|
50
52
|
"dist",
|
|
51
53
|
"src"
|
|
52
54
|
],
|
|
53
|
-
"nx": {
|
|
54
|
-
"targets": {
|
|
55
|
-
"lint": {
|
|
56
|
-
"options": {
|
|
57
|
-
"cwd": ".",
|
|
58
|
-
"command": "eslint {projectRoot}"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
55
|
"engines": {
|
|
64
56
|
"node": ">=26.7.0"
|
|
65
57
|
},
|
|
66
58
|
"dependencies": {
|
|
67
|
-
"@gtkx/components": "2.0.0-beta.
|
|
68
|
-
"@gtkx/react": "2.0.0-beta.
|
|
69
|
-
"
|
|
59
|
+
"@gtkx/components": "2.0.0-beta.12",
|
|
60
|
+
"@gtkx/react": "2.0.0-beta.12",
|
|
61
|
+
"@gtkx/utils": "2.0.0-beta.12",
|
|
62
|
+
"storybook": "10.6.2"
|
|
70
63
|
},
|
|
71
64
|
"peerDependencies": {
|
|
72
65
|
"@types/react": "^19.3",
|
|
73
66
|
"react": "^19.3"
|
|
74
67
|
},
|
|
75
68
|
"devDependencies": {
|
|
76
|
-
"@gtkx/config": "2.0.0-beta.
|
|
77
|
-
"@gtkx/testing": "2.0.0-beta.
|
|
78
|
-
"@gtkx/vitest": "2.0.0-beta.
|
|
69
|
+
"@gtkx/config": "2.0.0-beta.12",
|
|
70
|
+
"@gtkx/testing": "2.0.0-beta.12",
|
|
71
|
+
"@gtkx/vitest": "2.0.0-beta.12",
|
|
79
72
|
"@types/react": "^19.3.0",
|
|
80
|
-
"vitest": "
|
|
73
|
+
"vitest": "5.0.5"
|
|
81
74
|
},
|
|
82
75
|
"scripts": {
|
|
83
|
-
"release": "
|
|
76
|
+
"release": "node ../../scripts/release/publish-package.ts"
|
|
84
77
|
}
|
|
85
78
|
}
|
package/src/actions.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeError } from "@gtkx/utils";
|
|
1
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import { inspect } from "node:util";
|
|
3
4
|
import type { Args, ArgTypes } from "./types.js";
|
|
@@ -133,40 +134,39 @@ const settleCallback = async (
|
|
|
133
134
|
}
|
|
134
135
|
};
|
|
135
136
|
|
|
136
|
-
const bindCallback =
|
|
137
|
-
store: ActionStore,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
store.record(options.name, values, error);
|
|
137
|
+
const bindCallback =
|
|
138
|
+
(store: ActionStore, options: CallbackOptions): EventCallback =>
|
|
139
|
+
(...values) => {
|
|
140
|
+
const succeed = (): void => {
|
|
141
|
+
store.record(options.name, values);
|
|
142
|
+
};
|
|
143
|
+
const fail = (cause: unknown): void => {
|
|
144
|
+
const error = normalizeError(cause);
|
|
145
|
+
store.record(options.name, values, error);
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
if (options.onError === undefined) {
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
options.onError(error);
|
|
152
|
+
};
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
try {
|
|
155
|
+
const result = actionScope.run(store, () => options.callback?.(...values));
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
if (result instanceof Promise) {
|
|
158
|
+
return settleCallback(result, succeed, fail);
|
|
159
|
+
}
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
succeed();
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
return result;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
fail(error);
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
};
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
170
|
|
|
171
171
|
const actionName = (value: unknown, configuredName: unknown): string | undefined => {
|
|
172
172
|
if (typeof configuredName === "string") {
|
|
@@ -195,12 +195,7 @@ const callbackOptions = (
|
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
const bindActions = (
|
|
199
|
-
args: Args,
|
|
200
|
-
argTypes: ArgTypes,
|
|
201
|
-
store: ActionStore,
|
|
202
|
-
onError?: (error: Error) => void,
|
|
203
|
-
): Args => {
|
|
198
|
+
const bindActions = (args: Args, argTypes: ArgTypes, store: ActionStore, onError?: (error: Error) => void): Args => {
|
|
204
199
|
const bound = { ...args };
|
|
205
200
|
const names = new Set([...Object.keys(args), ...Object.keys(argTypes)]);
|
|
206
201
|
|
package/src/catalog.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeError } from "@gtkx/utils";
|
|
1
2
|
import type { Args, ArgTypes, ComponentMeta, ComposedStory, Preview, StoryAnnotations } from "./types.js";
|
|
2
3
|
import { composeStories } from "./compose.js";
|
|
3
4
|
import { storyNameFromExport } from "./upstream.js";
|
|
@@ -59,8 +60,6 @@ type LoadedSource = StoryLoadError | { source: StorySource; cached: CachedStorie
|
|
|
59
60
|
|
|
60
61
|
const EMPTY_PREVIEW: Preview = {};
|
|
61
62
|
|
|
62
|
-
const normalizeError = (cause: unknown): Error => cause instanceof Error ? cause : new Error(String(cause));
|
|
63
|
-
|
|
64
63
|
const isObject = (value: unknown): value is Record<string, unknown> =>
|
|
65
64
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
66
65
|
|
|
@@ -73,8 +72,10 @@ const explicitControls = (
|
|
|
73
72
|
const controls: ArgTypes = {};
|
|
74
73
|
|
|
75
74
|
for (const [argument, annotation] of Object.entries(resolved)) {
|
|
76
|
-
const control =
|
|
77
|
-
|
|
75
|
+
const control =
|
|
76
|
+
story?.argTypes?.[argument]?.control ??
|
|
77
|
+
meta.argTypes?.[argument]?.control ??
|
|
78
|
+
preview.argTypes?.[argument]?.control;
|
|
78
79
|
|
|
79
80
|
if (control === undefined) {
|
|
80
81
|
continue;
|
|
@@ -173,10 +174,13 @@ const loadSource = async (
|
|
|
173
174
|
try {
|
|
174
175
|
const module = await source.load();
|
|
175
176
|
const previous = getCache().get(source.id);
|
|
176
|
-
const cached =
|
|
177
|
-
previous
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
const cached =
|
|
178
|
+
previous !== undefined &&
|
|
179
|
+
previous.module === module &&
|
|
180
|
+
previous.title === source.title &&
|
|
181
|
+
previous.preview === preview
|
|
182
|
+
? previous
|
|
183
|
+
: { module, title: source.title, preview, entries: composeSource(source, module, preview) };
|
|
180
184
|
|
|
181
185
|
return { source, cached };
|
|
182
186
|
} catch (error) {
|
|
@@ -233,7 +237,10 @@ class StoryCatalog {
|
|
|
233
237
|
this.publish({ stories, errors, isLoading: false });
|
|
234
238
|
|
|
235
239
|
if (errors.length > 0) {
|
|
236
|
-
const failure = new AggregateError(
|
|
240
|
+
const failure = new AggregateError(
|
|
241
|
+
errors.map(({ error }) => error),
|
|
242
|
+
"Some stories could not be loaded",
|
|
243
|
+
);
|
|
237
244
|
this.loadFailures.add(failure);
|
|
238
245
|
throw failure;
|
|
239
246
|
}
|
package/src/compose.ts
CHANGED
|
@@ -38,15 +38,21 @@ const composeStory = <TArgs extends object>(
|
|
|
38
38
|
throw new TypeError("A story needs a component or render function");
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return composeStoryAnnotations(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
return composeStoryAnnotations(
|
|
42
|
+
story,
|
|
43
|
+
{ ...meta },
|
|
44
|
+
preview,
|
|
45
|
+
{
|
|
46
|
+
render: (args) => {
|
|
47
|
+
if (!meta.component) {
|
|
48
|
+
throw new TypeError("A story needs a component or render function");
|
|
49
|
+
}
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
return createElement(meta.component, args);
|
|
52
|
+
},
|
|
48
53
|
},
|
|
49
|
-
|
|
54
|
+
exportName,
|
|
55
|
+
);
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
/**
|
package/src/controls.tsx
CHANGED
|
@@ -27,7 +27,7 @@ const isObject = (value: unknown): value is Args =>
|
|
|
27
27
|
const isWithinBoundsOrAbsent = (value: unknown, min: number, max: number): boolean =>
|
|
28
28
|
value === undefined || (typeof value === "number" && Number.isFinite(value) && value >= min && value <= max);
|
|
29
29
|
|
|
30
|
-
const controlTitle = (name: unknown, argument: string): string => typeof name === "string" ? name : argument;
|
|
30
|
+
const controlTitle = (name: unknown, argument: string): string => (typeof name === "string" ? name : argument);
|
|
31
31
|
|
|
32
32
|
const numberDigits = (step: number): number => {
|
|
33
33
|
const [coefficient = "", exponent = "0"] = String(step).split("e", 2);
|
|
@@ -54,9 +54,15 @@ const NumberControl = ({
|
|
|
54
54
|
const step = settings.step ?? 1;
|
|
55
55
|
|
|
56
56
|
if (
|
|
57
|
-
typeof min !== "number" ||
|
|
58
|
-
|
|
59
|
-
step
|
|
57
|
+
typeof min !== "number" ||
|
|
58
|
+
typeof max !== "number" ||
|
|
59
|
+
typeof step !== "number" ||
|
|
60
|
+
!Number.isFinite(min) ||
|
|
61
|
+
!Number.isFinite(max) ||
|
|
62
|
+
!Number.isFinite(step) ||
|
|
63
|
+
step <= 0 ||
|
|
64
|
+
min > max ||
|
|
65
|
+
!isWithinBoundsOrAbsent(value, min, max)
|
|
60
66
|
) {
|
|
61
67
|
return <UnsupportedControl title={title} description="Provide a finite number and valid bounds." />;
|
|
62
68
|
}
|
|
@@ -72,7 +78,7 @@ const NumberControl = ({
|
|
|
72
78
|
digits={numberDigits(step)}
|
|
73
79
|
numeric
|
|
74
80
|
widthChars={8}
|
|
75
|
-
adjustment={
|
|
81
|
+
adjustment={
|
|
76
82
|
<GtkAdjustment
|
|
77
83
|
lower={min}
|
|
78
84
|
upper={max}
|
|
@@ -80,7 +86,7 @@ const NumberControl = ({
|
|
|
80
86
|
pageIncrement={Math.min(Number.MAX_VALUE, step * 10)}
|
|
81
87
|
value={currentValue}
|
|
82
88
|
/>
|
|
83
|
-
|
|
89
|
+
}
|
|
84
90
|
onNotifyValue={(next) => {
|
|
85
91
|
if (!Object.is(next, value)) {
|
|
86
92
|
onChange({ [argument]: next });
|
|
@@ -92,19 +98,31 @@ const NumberControl = ({
|
|
|
92
98
|
|
|
93
99
|
const SelectControl = (props: Omit<ControlProps, "type">): ReactNode => {
|
|
94
100
|
const { argument, title, value, options, settings, isDisabled, onChange } = props;
|
|
95
|
-
if (
|
|
96
|
-
|
|
101
|
+
if (
|
|
102
|
+
!Array.isArray(options) ||
|
|
103
|
+
options.length === 0 ||
|
|
104
|
+
options.some(
|
|
105
|
+
(option: unknown) =>
|
|
106
|
+
option !== null &&
|
|
107
|
+
typeof option !== "string" &&
|
|
108
|
+
typeof option !== "number" &&
|
|
109
|
+
typeof option !== "boolean",
|
|
110
|
+
)
|
|
111
|
+
) {
|
|
97
112
|
return <UnsupportedControl title={title} description="Provide a list of text, number, or boolean options." />;
|
|
98
113
|
}
|
|
99
114
|
|
|
100
115
|
const values: unknown[] = options;
|
|
101
116
|
const selected = values.findIndex((option) => Object.is(option, value));
|
|
102
117
|
const labels = isObject(settings.labels) ? settings.labels : {};
|
|
103
|
-
const items = [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
const items = [
|
|
119
|
+
{ id: NO_SELECTION_ID, value: NO_SELECTION_LABEL },
|
|
120
|
+
...values.map((option, index) => {
|
|
121
|
+
const label = labels[String(option)];
|
|
122
|
+
|
|
123
|
+
return { id: String(index), value: typeof label === "string" ? label : String(option) };
|
|
124
|
+
}),
|
|
125
|
+
];
|
|
108
126
|
|
|
109
127
|
return (
|
|
110
128
|
<ComboRow
|
|
@@ -20,14 +20,7 @@ type GroupProps = Pick<NavigatorProps, "selectedId" | "onSelect"> & {
|
|
|
20
20
|
|
|
21
21
|
const StoryGroup = ({ title, entries, selectedId, onSelect }: GroupProps): ReactNode => (
|
|
22
22
|
<GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={6}>
|
|
23
|
-
<GtkLabel
|
|
24
|
-
label={title}
|
|
25
|
-
xalign={0}
|
|
26
|
-
marginStart={18}
|
|
27
|
-
marginEnd={18}
|
|
28
|
-
cssClasses={["heading"]}
|
|
29
|
-
wrap
|
|
30
|
-
/>
|
|
23
|
+
<GtkLabel label={title} xalign={0} marginStart={18} marginEnd={18} cssClasses={["heading"]} wrap />
|
|
31
24
|
<GtkListBox
|
|
32
25
|
cssClasses={["navigation-sidebar"]}
|
|
33
26
|
selectedIndex={entries.findIndex((entry) => entry.id === selectedId)}
|
|
@@ -54,22 +47,23 @@ const StoryGroup = ({ title, entries, selectedId, onSelect }: GroupProps): React
|
|
|
54
47
|
</GtkBox>
|
|
55
48
|
);
|
|
56
49
|
|
|
57
|
-
const LoadErrors = ({ errors }: Pick<NavigatorProps, "errors">): ReactNode =>
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
const LoadErrors = ({ errors }: Pick<NavigatorProps, "errors">): ReactNode =>
|
|
51
|
+
errors.length > 0 && (
|
|
52
|
+
<GtkBox name="storybook-load-errors" orientation={Gtk.Orientation.VERTICAL} spacing={6}>
|
|
53
|
+
{errors.map(({ source, error }, index) => (
|
|
54
|
+
<GtkLabel
|
|
55
|
+
key={`${source}-${String(index)}`}
|
|
56
|
+
label={`${source}\n${error.message.slice(0, 500)}`}
|
|
57
|
+
cssClasses={["error"]}
|
|
58
|
+
marginStart={18}
|
|
59
|
+
marginEnd={18}
|
|
60
|
+
wrap
|
|
61
|
+
selectable
|
|
62
|
+
xalign={0}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</GtkBox>
|
|
66
|
+
);
|
|
73
67
|
|
|
74
68
|
const StoryNavigator = ({ stories, errors, selectedId, onSelect }: NavigatorProps): ReactNode => {
|
|
75
69
|
const [search, setSearch] = useState("");
|