@gtkx/storybook 0.0.1 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAyDpD,MAAM,aAAa,GAAY,EAAE,CAAC;AAElC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAS,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAE5G,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAClE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEzE,MAAM,gBAAgB,GAAG,CACrB,QAAkB,EAClB,KAAyC,EACzC,IAAyB,EACzB,OAAgB,EACR,EAAE;IACV,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,KAAK,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,MAAM,OAAO,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO;YAChD,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAEhF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS;QACb,CAAC;QAED,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,UAAU,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,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,YAAY,CAAC,CAAC;QACnF,IAAI,CAAC,YAAY,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,CAAC;YACT,GAAG,IAAI,CAAC,QAAQ;YAChB,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC;SACzC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import type { Args, ArgTypes, ComponentMeta, ComposedStory, Preview, StoryAnnotations } from \"./types.js\";\nimport { composeStories } from \"./compose.js\";\nimport { storyNameFromExport } from \"./upstream.js\";\n\n/** A lazily loaded CSF module discovered in a Storybook project. */\ntype StorySource = {\n /** Stable module identifier used for caching and error reporting. */\n id: string;\n /** Fallback story group title when the module does not declare one. */\n title: string;\n /** Imports the module and resolves to its CSF exports. */\n load: () => Promise<unknown>;\n};\n\n/** A composed story and the metadata used to display it in the explorer. */\ntype StoryEntry = {\n /** Storybook identifier used to preserve the selected story across updates. */\n id: string;\n /** Component group title declared by the module or derived from its source. */\n title: string;\n /** Display name declared by the story or derived from its export name. */\n name: string;\n /** Name of the CSF export that defines this story. */\n exportName: string;\n /** Identifier of the module containing this story. */\n source: string;\n /** Renderable story with its metadata, decorators, and default args composed. */\n story: ComposedStory;\n /** Resolved arg types with explicitly configured explorer controls. */\n controls: ArgTypes;\n};\n\n/** A source loading or composition failure displayed alongside healthy stories. */\ntype StoryLoadError = {\n /** Identifier of the failed source, or Storybook for a session failure. */\n source: string;\n /** Normalized error raised while loading or composing the source. */\n error: Error;\n};\n\n/** Current explorer contents and loading state exposed to subscribers. */\ntype StoryCatalogSnapshot = {\n /** Successfully composed stories with duplicate identifiers excluded. */\n stories: StoryEntry[];\n /** Failures encountered during the latest load or reported by the session. */\n errors: StoryLoadError[];\n /** Whether the catalog is waiting for the latest source load to finish. */\n isLoading: boolean;\n};\n\ntype CachedStories = {\n module: unknown;\n title: string;\n preview: Preview;\n entries: StoryEntry[];\n};\n\ntype LoadedSource = StoryLoadError | { source: StorySource; cached: CachedStories };\n\nconst EMPTY_PREVIEW: Preview = {};\n\nconst normalizeError = (cause: unknown): Error => cause instanceof Error ? cause : new Error(String(cause));\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst explicitControls = (\n resolved: ArgTypes,\n story: StoryAnnotations<Args> | undefined,\n meta: ComponentMeta<Args>,\n preview: Preview,\n): ArgTypes => {\n const controls: ArgTypes = {};\n\n for (const [argument, annotation] of Object.entries(resolved)) {\n const control = story?.argTypes?.[argument]?.control ??\n meta.argTypes?.[argument]?.control ?? preview.argTypes?.[argument]?.control;\n\n if (control === undefined) {\n continue;\n }\n\n controls[argument] = { ...annotation, control: control === false ? false : annotation?.control ?? control };\n }\n\n return controls;\n};\n\nconst displayName = (story: StoryAnnotations<Args> | undefined, exportName: string): string => {\n const name = story?.name;\n\n if (name === undefined) {\n return storyNameFromExport(exportName);\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"Expected a story display name\");\n }\n\n return name;\n};\n\nconst composeSource = (source: StorySource, module: unknown, preview: Preview): StoryEntry[] => {\n if (!isObject(module) || !isObject(module.default)) {\n throw new TypeError(`Expected CSF3 component metadata in ${source.id}`);\n }\n\n const title = module.default.title ?? source.title;\n\n if (typeof title !== \"string\" || title.trim().length === 0) {\n throw new TypeError(`Expected a story title in ${source.id}`);\n }\n\n const annotations = {\n ...module,\n default: { ...module.default, title },\n } as Record<string, StoryAnnotations<Args>> & { default: ComponentMeta<Args> };\n const stories = composeStories(annotations, preview);\n\n return Object.entries(stories).map(([exportName, story]) => ({\n id: story.id,\n title,\n name: displayName(annotations[exportName], exportName),\n exportName,\n source: source.id,\n story,\n controls: explicitControls(story.argTypes, annotations[exportName], annotations.default, preview),\n }));\n};\n\nconst withoutDuplicateIds = (entries: StoryEntry[], errors: StoryLoadError[]): StoryEntry[] => {\n const counts: Map<string, number> = new Map();\n\n for (const entry of entries) {\n counts.set(entry.id, (counts.get(entry.id) ?? 0) + 1);\n }\n\n return entries.filter((entry) => {\n if (counts.get(entry.id) === 1) {\n return true;\n }\n\n errors.push({ source: entry.source, error: new Error(`Duplicate story ID: ${entry.id}`) });\n\n return false;\n });\n};\n\nconst collectSources = (loaded: LoadedSource[]) => {\n const cache: Map<string, CachedStories> = new Map();\n const entries: StoryEntry[] = [];\n const errors: StoryLoadError[] = [];\n\n for (const result of loaded) {\n if (\"error\" in result) {\n errors.push(result);\n } else {\n cache.set(result.source.id, result.cached);\n entries.push(...result.cached.entries);\n }\n }\n\n return { cache, stories: withoutDuplicateIds(entries, errors), errors };\n};\n\nconst createSourceCache = (): Map<string, CachedStories> => new Map();\n\nconst loadSource = async (\n source: StorySource,\n preview: Preview,\n getCache: () => Map<string, CachedStories>,\n): Promise<LoadedSource> => {\n try {\n const module = await source.load();\n const previous = getCache().get(source.id);\n const cached = previous !== undefined && previous.module === module &&\n previous.title === source.title && previous.preview === preview\n ? previous\n : { module, title: source.title, preview, entries: composeSource(source, module, preview) };\n\n return { source, cached };\n } catch (error) {\n return { source: source.id, error: normalizeError(error) };\n }\n};\n\n/** Loads CSF modules and publishes subscribable explorer snapshots. */\nclass StoryCatalog {\n private snapshot: StoryCatalogSnapshot = { stories: [], errors: [], isLoading: false };\n private readonly listeners: Set<() => void> = new Set();\n private readonly loadFailures: WeakSet<Error> = new WeakSet();\n private cache = createSourceCache();\n private sessionError: StoryLoadError | undefined;\n private revision = 0;\n\n /** Returns the current snapshot, retaining its identity until the next update. */\n getSnapshot = (): StoryCatalogSnapshot => this.snapshot;\n\n /** Registers a snapshot listener and returns a function that unsubscribes it. */\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n private publish(snapshot: StoryCatalogSnapshot): void {\n this.snapshot = snapshot;\n\n for (const listener of this.listeners) {\n listener();\n }\n }\n\n /**\n * Replaces the catalog with stories composed from the supplied sources and preview.\n * Only the latest load publishes results; unchanged module identities reuse composed stories.\n * Rejects with an AggregateError after publishing healthy stories when any source fails.\n */\n async load(sources: StorySource[], preview: Preview = EMPTY_PREVIEW): Promise<void> {\n const revision = ++this.revision;\n this.publish({ ...this.snapshot, isLoading: true });\n const loaded = await Promise.all(sources.map((source) => loadSource(source, preview, () => this.cache)));\n\n if (revision !== this.revision) {\n return;\n }\n\n const { cache, stories, errors } = collectSources(loaded);\n this.cache = cache;\n this.sessionError = undefined;\n this.publish({ stories, errors, isLoading: false });\n\n if (errors.length > 0) {\n const failure = new AggregateError(errors.map(({ error }) => error), \"Some stories could not be loaded\");\n this.loadFailures.add(failure);\n throw failure;\n }\n }\n\n /**\n * Replaces the current session failure while preserving source errors and superseding pending loads.\n * Ignores aggregate failures already published by this catalog's load operation.\n */\n reportError(cause: unknown): void {\n if (cause instanceof Error && this.loadFailures.has(cause)) {\n return;\n }\n\n this.revision++;\n const errors = this.snapshot.errors.filter((entry) => entry !== this.sessionError);\n this.sessionError = { source: \"Storybook\", error: normalizeError(cause) };\n this.publish({\n ...this.snapshot,\n isLoading: false,\n errors: [...errors, this.sessionError],\n });\n }\n}\n\nexport { StoryCatalog };\nexport type { StoryCatalogSnapshot, StoryEntry, StoryLoadError, StorySource };\n"]}
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAyDpD,MAAM,aAAa,GAAY,EAAE,CAAC;AAElC,MAAM,Q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KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAEpD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,IAAI,cAAc,CAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAChC,kCAAkC,CACrC,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC/B,MAAM,OAAO,CAAC;QAClB,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,KAAc;QACtB,IAAI,KAAK,YAAY,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,YAAY,CAAC,CAAC;QACnF,IAAI,CAAC,YAAY,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,CAAC;YACT,GAAG,IAAI,CAAC,QAAQ;YAChB,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC;SACzC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { normalizeError } from \"@gtkx/utils\";\nimport type { Args, ArgTypes, ComponentMeta, ComposedStory, Preview, StoryAnnotations } from \"./types.js\";\nimport { composeStories } from \"./compose.js\";\nimport { storyNameFromExport } from \"./upstream.js\";\n\n/** A lazily loaded CSF module discovered in a Storybook project. */\ntype StorySource = {\n /** Stable module identifier used for caching and error reporting. */\n id: string;\n /** Fallback story group title when the module does not declare one. */\n title: string;\n /** Imports the module and resolves to its CSF exports. */\n load: () => Promise<unknown>;\n};\n\n/** A composed story and the metadata used to display it in the explorer. */\ntype StoryEntry = {\n /** Storybook identifier used to preserve the selected story across updates. */\n id: string;\n /** Component group title declared by the module or derived from its source. */\n title: string;\n /** Display name declared by the story or derived from its export name. */\n name: string;\n /** Name of the CSF export that defines this story. */\n exportName: string;\n /** Identifier of the module containing this story. */\n source: string;\n /** Renderable story with its metadata, decorators, and default args composed. */\n story: ComposedStory;\n /** Resolved arg types with explicitly configured explorer controls. */\n controls: ArgTypes;\n};\n\n/** A source loading or composition failure displayed alongside healthy stories. */\ntype StoryLoadError = {\n /** Identifier of the failed source, or Storybook for a session failure. */\n source: string;\n /** Normalized error raised while loading or composing the source. */\n error: Error;\n};\n\n/** Current explorer contents and loading state exposed to subscribers. */\ntype StoryCatalogSnapshot = {\n /** Successfully composed stories with duplicate identifiers excluded. */\n stories: StoryEntry[];\n /** Failures encountered during the latest load or reported by the session. */\n errors: StoryLoadError[];\n /** Whether the catalog is waiting for the latest source load to finish. */\n isLoading: boolean;\n};\n\ntype CachedStories = {\n module: unknown;\n title: string;\n preview: Preview;\n entries: StoryEntry[];\n};\n\ntype LoadedSource = StoryLoadError | { source: StorySource; cached: CachedStories };\n\nconst EMPTY_PREVIEW: Preview = {};\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst explicitControls = (\n resolved: ArgTypes,\n story: StoryAnnotations<Args> | undefined,\n meta: ComponentMeta<Args>,\n preview: Preview,\n): ArgTypes => {\n const controls: ArgTypes = {};\n\n for (const [argument, annotation] of Object.entries(resolved)) {\n const control =\n story?.argTypes?.[argument]?.control ??\n meta.argTypes?.[argument]?.control ??\n preview.argTypes?.[argument]?.control;\n\n if (control === undefined) {\n continue;\n }\n\n controls[argument] = { ...annotation, control: control !== false && (annotation?.control ?? control) };\n }\n\n return controls;\n};\n\nconst displayName = (story: StoryAnnotations<Args> | undefined, exportName: string): string => {\n const name = story?.name;\n\n if (name === undefined) {\n return storyNameFromExport(exportName);\n }\n\n if (typeof name !== \"string\") {\n throw new TypeError(\"Expected a story display name\");\n }\n\n return name;\n};\n\nconst composeSource = (source: StorySource, module: unknown, preview: Preview): StoryEntry[] => {\n if (!isObject(module) || !isObject(module.default)) {\n throw new TypeError(`Expected CSF3 component metadata in ${source.id}`);\n }\n\n const title = module.default.title ?? source.title;\n\n if (typeof title !== \"string\" || title.trim().length === 0) {\n throw new TypeError(`Expected a story title in ${source.id}`);\n }\n\n const annotations = {\n ...module,\n default: { ...module.default, title },\n } as Record<string, StoryAnnotations<Args>> & { default: ComponentMeta<Args> };\n const stories = composeStories(annotations, preview);\n\n return Object.entries(stories).map(([exportName, story]) => ({\n id: story.id,\n title,\n name: displayName(annotations[exportName], exportName),\n exportName,\n source: source.id,\n story,\n controls: explicitControls(story.argTypes, annotations[exportName], annotations.default, preview),\n }));\n};\n\nconst withoutDuplicateIds = (entries: StoryEntry[], errors: StoryLoadError[]): StoryEntry[] => {\n const counts: Map<string, number> = new Map();\n\n for (const entry of entries) {\n counts.set(entry.id, (counts.get(entry.id) ?? 0) + 1);\n }\n\n return entries.filter((entry) => {\n if (counts.get(entry.id) === 1) {\n return true;\n }\n\n errors.push({ source: entry.source, error: new Error(`Duplicate story ID: ${entry.id}`) });\n\n return false;\n });\n};\n\nconst collectSources = (loaded: LoadedSource[]) => {\n const cache: Map<string, CachedStories> = new Map();\n const entries: StoryEntry[] = [];\n const errors: StoryLoadError[] = [];\n\n for (const result of loaded) {\n if (\"error\" in result) {\n errors.push(result);\n } else {\n cache.set(result.source.id, result.cached);\n entries.push(...result.cached.entries);\n }\n }\n\n return { cache, stories: withoutDuplicateIds(entries, errors), errors };\n};\n\nconst createSourceCache = (): Map<string, CachedStories> => new Map();\n\nconst loadSource = async (\n source: StorySource,\n preview: Preview,\n getCache: () => Map<string, CachedStories>,\n): Promise<LoadedSource> => {\n try {\n const module = await source.load();\n const previous = getCache().get(source.id);\n const cached =\n previous !== undefined &&\n previous.module === module &&\n previous.title === source.title &&\n previous.preview === preview\n ? previous\n : { module, title: source.title, preview, entries: composeSource(source, module, preview) };\n\n return { source, cached };\n } catch (error) {\n return { source: source.id, error: normalizeError(error) };\n }\n};\n\n/** Loads CSF modules and publishes subscribable explorer snapshots. */\nclass StoryCatalog {\n private snapshot: StoryCatalogSnapshot = { stories: [], errors: [], isLoading: false };\n private readonly listeners: Set<() => void> = new Set();\n private readonly loadFailures: WeakSet<Error> = new WeakSet();\n private cache = createSourceCache();\n private sessionError: StoryLoadError | undefined;\n private revision = 0;\n\n /** Returns the current snapshot, retaining its identity until the next update. */\n getSnapshot = (): StoryCatalogSnapshot => this.snapshot;\n\n /** Registers a snapshot listener and returns a function that unsubscribes it. */\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n private publish(snapshot: StoryCatalogSnapshot): void {\n this.snapshot = snapshot;\n\n for (const listener of this.listeners) {\n listener();\n }\n }\n\n /**\n * Replaces the catalog with stories composed from the supplied sources and preview.\n * Only the latest load publishes results; unchanged module identities reuse composed stories.\n * Rejects with an AggregateError after publishing healthy stories when any source fails.\n */\n async load(sources: StorySource[], preview: Preview = EMPTY_PREVIEW): Promise<void> {\n const revision = ++this.revision;\n this.publish({ ...this.snapshot, isLoading: true });\n const loaded = await Promise.all(sources.map((source) => loadSource(source, preview, () => this.cache)));\n\n if (revision !== this.revision) {\n return;\n }\n\n const { cache, stories, errors } = collectSources(loaded);\n this.cache = cache;\n this.sessionError = undefined;\n this.publish({ stories, errors, isLoading: false });\n\n if (errors.length > 0) {\n const failure = new AggregateError(\n errors.map(({ error }) => error),\n \"Some stories could not be loaded\",\n );\n this.loadFailures.add(failure);\n throw failure;\n }\n }\n\n /**\n * Replaces the current session failure while preserving source errors and superseding pending loads.\n * Ignores aggregate failures already published by this catalog's load operation.\n */\n reportError(cause: unknown): void {\n if (cause instanceof Error && this.loadFailures.has(cause)) {\n return;\n }\n\n this.revision++;\n const errors = this.snapshot.errors.filter((entry) => entry !== this.sessionError);\n this.sessionError = { source: \"Storybook\", error: normalizeError(cause) };\n this.publish({\n ...this.snapshot,\n isLoading: false,\n errors: [...errors, this.sessionError],\n });\n }\n}\n\nexport { StoryCatalog };\nexport type { StoryCatalogSnapshot, StoryEntry, StoryLoadError, StorySource };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EACf,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,WAAW,EACd,MAAM,YAAY,CAAC;AASpB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,YAAY,GAAI,KAAK,SAAS,MAAM,EACtC,OAAO,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EACvC,MAAM,aAAa,CAAC,KAAK,CAAC,EAC1B,UAAS,OAAY,EACrB,aAAa,MAAM,KACpB,aAAa,CAAC,KAAK,CAkBrB,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,GAAI,OAAO,SAAS,WAAW,EAC/C,SAAS,OAAO,EAChB,UAAS,OAAY,KACtB,eAAe,CAAC,OAAO,CAuBzB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAER,aAAa,EACb,eAAe,EACf,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,WAAW,EACd,MAAM,YAAY,CAAC;AASpB;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,YAAY,GAAI,KAAK,SAAS,MAAM,SAC/B,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QACjC,aAAa,CAAC,KAAK,CAAC,YACjB,OAAO,eACH,MAAM,KACpB,aAAa,CAAC,KAAK,CAoBrB,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,cAAc,GAAI,OAAO,SAAS,WAAW,WACtC,OAAO,YACP,OAAO,KACjB,eAAe,CAAC,OAAO,CAqBzB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
package/dist/compose.js CHANGED
@@ -18,9 +18,6 @@ const requireObject = (value) => {
18
18
  * @throws If an annotation is not an object or no component or render function is available.
19
19
  */
20
20
  const composeStory = (story, meta, preview = {}, exportName) => {
21
- requireObject(story);
22
- requireObject(meta);
23
- requireObject(preview);
24
21
  if (!story.render && !meta.render && !preview.render && !meta.component) {
25
22
  throw new TypeError("A story needs a component or render function");
26
23
  }
@@ -44,9 +41,7 @@ const composeStory = (story, meta, preview = {}, exportName) => {
44
41
  * @throws If metadata or a selected export is invalid, or a selected story has no renderer.
45
42
  */
46
43
  const composeStories = (stories, preview = {}) => {
47
- requireObject(stories);
48
44
  requireObject(stories.default);
49
- requireObject(preview);
50
45
  const meta = stories.default;
51
46
  const composed = {};
52
47
  for (const [exportName, story] of Object.entries(stories)) {
@@ -1 +1 @@
1
- {"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAUtC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC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AAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,qBAAqB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;YACvG,SAAS;QACb,CAAC;QAED,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE;YACxC,KAAK,EAAE,YAAY,CAAC,KAA+B,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC;YAC/E,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,QAAoC,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { createElement } from \"react\";\nimport type {\n Args,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Preview,\n StoryAnnotations,\n StoryModule,\n} from \"./types.js\";\nimport { composeStoryAnnotations, isExportStory } from \"./upstream.js\";\n\nconst requireObject = (value: unknown): void => {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"Expected a CSF3 annotation object\");\n }\n};\n\n/**\n * Composes a CSF3 story into a native React component with resolved defaults and decorators.\n * Compose outside render to preserve component identity. Rendering props override the composed args.\n * This function does not create an application, window, or Storybook preview lifecycle.\n *\n * @param story The named story's annotations.\n * @param meta The module's default component metadata.\n * @param preview Shared project annotations, scoped to this composition.\n * @param exportName Export name used for the story identifier and default display name.\n * @returns A renderable component exposing its composed annotations.\n * @throws If an annotation is not an object or no component or render function is available.\n */\nconst composeStory = <TArgs extends object>(\n story: StoryAnnotations<NoInfer<TArgs>>,\n meta: ComponentMeta<TArgs>,\n preview: Preview = {},\n exportName?: string,\n): ComposedStory<TArgs> => {\n requireObject(story);\n requireObject(meta);\n requireObject(preview);\n\n if (!story.render && !meta.render && !preview.render && !meta.component) {\n throw new TypeError(\"A story needs a component or render function\");\n }\n\n return composeStoryAnnotations(story, { ...meta }, preview, {\n render: (args) => {\n if (!meta.component) {\n throw new TypeError(\"A story needs a component or render function\");\n }\n\n return createElement(meta.component, args);\n },\n }, exportName);\n};\n\n/**\n * Composes the selected CSF3 exports of a module into native React components.\n * The default export supplies metadata; its includeStories and excludeStories select named exports.\n * Returned keys retain the original export names.\n *\n * @param stories A story module containing default metadata and named story objects.\n * @param preview Shared project annotations, scoped to the returned compositions.\n * @returns Composed components keyed by the selected export names.\n * @throws If metadata or a selected export is invalid, or a selected story has no renderer.\n */\nconst composeStories = <TModule extends StoryModule>(\n stories: TModule,\n preview: Preview = {},\n): ComposedStories<TModule> => {\n requireObject(stories);\n requireObject(stories.default);\n requireObject(preview);\n\n const meta = stories.default as ComponentMeta<Args>;\n const composed: Partial<ComposedStories<TModule>> = {};\n\n for (const [exportName, story] of Object.entries(stories)) {\n if (exportName === \"default\" || exportName === \"__namedExportsOrder\" || !isExportStory(exportName, meta)) {\n continue;\n }\n\n requireObject(story);\n Object.defineProperty(composed, exportName, {\n value: composeStory(story as StoryAnnotations<Args>, meta, preview, exportName),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n\n return composed as ComposedStories<TModule>;\n};\n\nexport { composeStory, composeStories };\n"]}
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAUtC,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IAC7D,CAAC;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AQ,EAAE,UAAU,EAAE;YACxC,KAAK,EAAE,YAAY,CAAC,KAA+B,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC;YAC/E,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,QAAoC,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { createElement } from \"react\";\nimport type {\n Args,\n ComponentMeta,\n ComposedStories,\n ComposedStory,\n Preview,\n StoryAnnotations,\n StoryModule,\n} from \"./types.js\";\nimport { composeStoryAnnotations, isExportStory } from \"./upstream.js\";\n\nconst requireObject = (value: unknown): void => {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"Expected a CSF3 annotation object\");\n }\n};\n\n/**\n * Composes a CSF3 story into a native React component with resolved defaults and decorators.\n * Compose outside render to preserve component identity. Rendering props override the composed args.\n * This function does not create an application, window, or Storybook preview lifecycle.\n *\n * @param story The named story's annotations.\n * @param meta The module's default component metadata.\n * @param preview Shared project annotations, scoped to this composition.\n * @param exportName Export name used for the story identifier and default display name.\n * @returns A renderable component exposing its composed annotations.\n * @throws If an annotation is not an object or no component or render function is available.\n */\nconst composeStory = <TArgs extends object>(\n story: StoryAnnotations<NoInfer<TArgs>>,\n meta: ComponentMeta<TArgs>,\n preview: Preview = {},\n exportName?: string,\n): ComposedStory<TArgs> => {\n if (!story.render && !meta.render && !preview.render && !meta.component) {\n throw new TypeError(\"A story needs a component or render function\");\n }\n\n return composeStoryAnnotations(\n story,\n { ...meta },\n preview,\n {\n render: (args) => {\n if (!meta.component) {\n throw new TypeError(\"A story needs a component or render function\");\n }\n\n return createElement(meta.component, args);\n },\n },\n exportName,\n );\n};\n\n/**\n * Composes the selected CSF3 exports of a module into native React components.\n * The default export supplies metadata; its includeStories and excludeStories select named exports.\n * Returned keys retain the original export names.\n *\n * @param stories A story module containing default metadata and named story objects.\n * @param preview Shared project annotations, scoped to the returned compositions.\n * @returns Composed components keyed by the selected export names.\n * @throws If metadata or a selected export is invalid, or a selected story has no renderer.\n */\nconst composeStories = <TModule extends StoryModule>(\n stories: TModule,\n preview: Preview = {},\n): ComposedStories<TModule> => {\n requireObject(stories.default);\n\n const meta = stories.default as ComponentMeta<Args>;\n const composed: Partial<ComposedStories<TModule>> = {};\n\n for (const [exportName, story] of Object.entries(stories)) {\n if (exportName === \"default\" || exportName === \"__namedExportsOrder\" || !isExportStory(exportName, meta)) {\n continue;\n }\n\n requireObject(story);\n Object.defineProperty(composed, exportName, {\n value: composeStory(story as StoryAnnotations<Args>, meta, preview, exportName),\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n\n return composed as ComposedStories<TModule>;\n};\n\nexport { composeStory, composeStories };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,KAAK,eAAe,GAAG;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,yFAAyF;AACzF,QAAA,MAAM,YAAY,GAAI,QAAQ,eAAe,KAAG,eAAyB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,KAAK,eAAe,GAAG;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,yFAAyF;AACzF,QAAA,MAAM,YAAY,WAAY,eAAe,KAAG,eAAyB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,aAAa,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,CAAA;CAAE,CAAC;AAwK1F,QAAA,MAAM,QAAQ,GAAI,8BAA8B,aAAa,KAAG,SA4B/D,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,aAAa,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,CAAA;CAAE,CAAC;AAgM1F,QAAA,MAAM,QAAQ,iCAAkC,aAAa,KAAG,SA4B/D,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/controls.js CHANGED
@@ -3,9 +3,11 @@ import { ComboRow } from "@gtkx/components";
3
3
  import { markupEscapeText } from "@gtkx/gi/glib";
4
4
  import { AdwActionRow, AdwEntryRow, AdwPreferencesGroup, AdwSpinRow, AdwSwitchRow } from "@gtkx/jsx/adw";
5
5
  import { GtkAdjustment } from "@gtkx/jsx/gtk";
6
+ const NO_SELECTION_ID = "no-selection";
7
+ const NO_SELECTION_LABEL = "Choose option...";
6
8
  const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
7
9
  const isWithinBoundsOrAbsent = (value, min, max) => value === undefined || (typeof value === "number" && Number.isFinite(value) && value >= min && value <= max);
8
- const controlTitle = (name, argument) => typeof name === "string" ? name : argument;
10
+ const controlTitle = (name, argument) => (typeof name === "string" ? name : argument);
9
11
  const numberDigits = (step) => {
10
12
  const [coefficient = "", exponent = "0"] = String(step).split("e", 2);
11
13
  const fraction = coefficient.split(".", 2)[1]?.length ?? 0;
@@ -17,36 +19,53 @@ const NumberControl = ({ argument, title, value, settings, isDisabled, onChange,
17
19
  const min = settings.min ?? -Number.MAX_SAFE_INTEGER;
18
20
  const max = settings.max ?? Number.MAX_SAFE_INTEGER;
19
21
  const step = settings.step ?? 1;
20
- if (typeof min !== "number" || typeof max !== "number" || typeof step !== "number" ||
21
- !Number.isFinite(min) || !Number.isFinite(max) || !Number.isFinite(step) ||
22
- step <= 0 || min > max || !isWithinBoundsOrAbsent(value, min, max)) {
22
+ if (typeof min !== "number" ||
23
+ typeof max !== "number" ||
24
+ typeof step !== "number" ||
25
+ !Number.isFinite(min) ||
26
+ !Number.isFinite(max) ||
27
+ !Number.isFinite(step) ||
28
+ step <= 0 ||
29
+ min > max ||
30
+ !isWithinBoundsOrAbsent(value, min, max)) {
23
31
  return _jsx(UnsupportedControl, { title: title, description: "Provide a finite number and valid bounds." });
24
32
  }
25
33
  const currentValue = typeof value === "number" ? value : Math.max(min, Math.min(0, max));
26
- return (_jsx(AdwSpinRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, value: currentValue, digits: numberDigits(step), numeric: true, widthChars: 8, adjustment: (_jsx(GtkAdjustment, { lower: min, upper: max, stepIncrement: step, pageIncrement: Math.min(Number.MAX_VALUE, step * 10), value: currentValue })), onNotifyValue: (next) => {
27
- if (typeof next === "number" && Number.isFinite(next) &&
28
- next >= min && next <= max && !Object.is(next, value)) {
34
+ return (_jsx(AdwSpinRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, value: currentValue, digits: numberDigits(step), numeric: true, widthChars: 8, adjustment: _jsx(GtkAdjustment, { lower: min, upper: max, stepIncrement: step, pageIncrement: Math.min(Number.MAX_VALUE, step * 10), value: currentValue }), onNotifyValue: (next) => {
35
+ if (!Object.is(next, value)) {
29
36
  onChange({ [argument]: next });
30
37
  }
31
38
  } }));
32
39
  };
33
40
  const SelectControl = (props) => {
34
41
  const { argument, title, value, options, settings, isDisabled, onChange } = props;
35
- if (!Array.isArray(options) || options.length === 0 || options.some((option) => option !== null && typeof option !== "string" && typeof option !== "number" && typeof option !== "boolean")) {
42
+ if (!Array.isArray(options) ||
43
+ options.length === 0 ||
44
+ options.some((option) => option !== null &&
45
+ typeof option !== "string" &&
46
+ typeof option !== "number" &&
47
+ typeof option !== "boolean")) {
36
48
  return _jsx(UnsupportedControl, { title: title, description: "Provide a list of text, number, or boolean options." });
37
49
  }
38
50
  const values = options;
39
51
  const selected = values.findIndex((option) => Object.is(option, value));
40
52
  const labels = isObject(settings.labels) ? settings.labels : {};
41
- const items = values.map((option, index) => {
42
- const label = labels[String(option)];
43
- return { id: String(index), value: typeof label === "string" ? label : String(option) };
44
- });
45
- return (_jsx(ComboRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, items: items, selectedId: selected === -1 ? null : String(selected), onSelectionChanged: (id) => {
46
- const index = Number(id);
47
- if (Number.isSafeInteger(index) && index >= 0 && index < values.length) {
48
- onChange({ [argument]: values[index] });
53
+ const items = [
54
+ { id: NO_SELECTION_ID, value: NO_SELECTION_LABEL },
55
+ ...values.map((option, index) => {
56
+ const label = labels[String(option)];
57
+ return { id: String(index), value: typeof label === "string" ? label : String(option) };
58
+ }),
59
+ ];
60
+ return (_jsx(ComboRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, items: items, selectedId: selected === -1 ? NO_SELECTION_ID : String(selected), onSelectionChanged: (id) => {
61
+ if (id === NO_SELECTION_ID) {
62
+ onChange({ [argument]: undefined });
63
+ return;
49
64
  }
65
+ if (id === null) {
66
+ return;
67
+ }
68
+ onChange({ [argument]: values[Number(id)] });
50
69
  } }));
51
70
  };
52
71
  const Control = (props) => {
@@ -54,14 +73,14 @@ const Control = (props) => {
54
73
  switch (type) {
55
74
  case "boolean": {
56
75
  return (_jsx(AdwSwitchRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, active: value === true, onNotifyActive: (active) => {
57
- if (typeof active === "boolean" && !Object.is(active, value)) {
76
+ if (!Object.is(active, value)) {
58
77
  onChange({ [argument]: active });
59
78
  }
60
79
  } }));
61
80
  }
62
81
  case "text": {
63
82
  return (_jsx(AdwEntryRow, { name: `storybook-control-${argument}`, title: markupEscapeText(title, -1), sensitive: !isDisabled, text: typeof value === "string" ? value : "", onNotifyText: (text) => {
64
- if (typeof text === "string" && !Object.is(text, value)) {
83
+ if (!Object.is(text, value)) {
65
84
  onChange({ [argument]: text });
66
85
  }
67
86
  } }));
@@ -82,13 +101,13 @@ const Control = (props) => {
82
101
  };
83
102
  const Controls = ({ argTypes, args, onChange }) => (_jsx(AdwPreferencesGroup, { title: "Controls", children: Object.entries(argTypes).map(([argument, annotation]) => {
84
103
  const control = annotation?.control;
85
- const table = annotation?.table;
86
- if (control === undefined || control === false || (isObject(table) && table.disable === true)) {
104
+ const table = isObject(annotation?.table) ? annotation.table : {};
105
+ if (control === undefined || control === false || table.disable === true) {
87
106
  return null;
88
107
  }
89
108
  const settings = isObject(control) ? control : {};
90
109
  const type = typeof control === "string" ? control : settings.type;
91
- return (_jsx(Control, { argument: argument, title: controlTitle(annotation?.name, argument), value: args[argument], type: typeof type === "string" ? type : "unknown", settings: settings, options: annotation?.options, isDisabled: settings.disable === true, onChange: onChange }, argument));
110
+ return (_jsx(Control, { argument: argument, title: controlTitle(annotation?.name, argument), value: args[argument], type: typeof type === "string" ? type : "unknown", settings: settings, options: annotation?.options, isDisabled: settings.disable === true || table.readonly === true, onChange: onChange }, argument));
92
111
  }) }));
93
112
  export { Controls };
94
113
  //# sourceMappingURL=controls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"controls.js","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAgB9C,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAiB,EAAE,CAC/C,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEzE,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAE,GAAW,EAAE,GAAW,EAAW,EAAE,CACjF,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC;AAEjH,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,QAAgB,EAAU,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AAE7G,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IAC1C,MAAM,CAAC,WAAW,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,CAAC,GAAG,MAAM,CAA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/components\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport { AdwActionRow, AdwEntryRow, AdwPreferencesGroup, AdwSpinRow, AdwSwitchRow } from \"@gtkx/jsx/adw\";\nimport { GtkAdjustment } from \"@gtkx/jsx/gtk\";\nimport type { Args, ArgTypes } from \"./types.js\";\n\ntype ControlsProps = { argTypes: ArgTypes; args: Args; onChange: (update: Args) => void };\n\ntype ControlProps = {\n argument: string;\n title: string;\n value: unknown;\n type: string;\n settings: Args;\n options: unknown;\n isDisabled: boolean;\n onChange: (update: Args) => void;\n};\n\nconst isObject = (value: unknown): value is Args =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst isWithinBoundsOrAbsent = (value: unknown, min: number, max: number): boolean =>\n value === undefined || (typeof value === \"number\" && Number.isFinite(value) && value >= min && value <= max);\n\nconst controlTitle = (name: unknown, argument: string): string => typeof name === \"string\" ? name : argument;\n\nconst numberDigits = (step: number): number => {\n const [coefficient = \"\", exponent = \"0\"] = String(step).split(\"e\", 2);\n const fraction = coefficient.split(\".\", 2)[1]?.length ?? 0;\n const digits = Math.max(0, fraction - Number(exponent));\n\n return Math.min(20, digits);\n};\n\nconst UnsupportedControl = ({ title, description }: { title: string; description: string }): ReactNode => (\n <AdwActionRow title={markupEscapeText(title, -1)} subtitle={markupEscapeText(description, -1)} sensitive={false} />\n);\n\nconst NumberControl = ({\n argument,\n title,\n value,\n settings,\n isDisabled,\n onChange,\n}: Omit<ControlProps, \"type\" | \"options\">): ReactNode => {\n const min = settings.min ?? -Number.MAX_SAFE_INTEGER;\n const max = settings.max ?? Number.MAX_SAFE_INTEGER;\n const step = settings.step ?? 1;\n\n if (\n typeof min !== \"number\" || typeof max !== \"number\" || typeof step !== \"number\" ||\n !Number.isFinite(min) || !Number.isFinite(max) || !Number.isFinite(step) ||\n step <= 0 || min > max || !isWithinBoundsOrAbsent(value, min, max)\n ) {\n return <UnsupportedControl title={title} description=\"Provide a finite number and valid bounds.\" />;\n }\n\n const currentValue = typeof value === \"number\" ? value : Math.max(min, Math.min(0, max));\n\n return (\n <AdwSpinRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n value={currentValue}\n digits={numberDigits(step)}\n numeric\n widthChars={8}\n adjustment={(\n <GtkAdjustment\n lower={min}\n upper={max}\n stepIncrement={step}\n pageIncrement={Math.min(Number.MAX_VALUE, step * 10)}\n value={currentValue}\n />\n )}\n onNotifyValue={(next) => {\n if (\n typeof next === \"number\" && Number.isFinite(next) &&\n next >= min && next <= max && !Object.is(next, value)\n ) {\n onChange({ [argument]: next });\n }\n }}\n />\n );\n};\n\nconst SelectControl = (props: Omit<ControlProps, \"type\">): ReactNode => {\n const { argument, title, value, options, settings, isDisabled, onChange } = props;\n if (!Array.isArray(options) || options.length === 0 || options.some((option: unknown) =>\n option !== null && typeof option !== \"string\" && typeof option !== \"number\" && typeof option !== \"boolean\")) {\n return <UnsupportedControl title={title} description=\"Provide a list of text, number, or boolean options.\" />;\n }\n\n const values: unknown[] = options;\n const selected = values.findIndex((option) => Object.is(option, value));\n const labels = isObject(settings.labels) ? settings.labels : {};\n const items = values.map((option, index) => {\n const label = labels[String(option)];\n\n return { id: String(index), value: typeof label === \"string\" ? label : String(option) };\n });\n\n return (\n <ComboRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n items={items}\n selectedId={selected === -1 ? null : String(selected)}\n onSelectionChanged={(id) => {\n const index = Number(id);\n\n if (Number.isSafeInteger(index) && index >= 0 && index < values.length) {\n onChange({ [argument]: values[index] });\n }\n }}\n />\n );\n};\n\nconst Control = (props: ControlProps): ReactNode => {\n const { argument, title, value, type, isDisabled, onChange } = props;\n\n switch (type) {\n case \"boolean\": {\n return (\n <AdwSwitchRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n active={value === true}\n onNotifyActive={(active) => {\n if (typeof active === \"boolean\" && !Object.is(active, value)) {\n onChange({ [argument]: active });\n }\n }}\n />\n );\n }\n case \"text\": {\n return (\n <AdwEntryRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n text={typeof value === \"string\" ? value : \"\"}\n onNotifyText={(text) => {\n if (typeof text === \"string\" && !Object.is(text, value)) {\n onChange({ [argument]: text });\n }\n }}\n />\n );\n }\n case \"number\":\n case \"range\": {\n return <NumberControl {...props} />;\n }\n case \"select\":\n case \"radio\":\n case \"inline-radio\": {\n return <SelectControl {...props} />;\n }\n default: {\n return <UnsupportedControl title={title} description={`Unsupported control: ${type}`} />;\n }\n }\n};\n\nconst Controls = ({ argTypes, args, onChange }: ControlsProps): ReactNode => (\n <AdwPreferencesGroup title=\"Controls\">\n {Object.entries(argTypes).map(([argument, annotation]) => {\n const control: unknown = annotation?.control;\n const table: unknown = annotation?.table;\n\n if (control === undefined || control === false || (isObject(table) && table.disable === true)) {\n return null;\n }\n\n const settings = isObject(control) ? control : {};\n const type = typeof control === \"string\" ? control : settings.type;\n\n return (\n <Control\n key={argument}\n argument={argument}\n title={controlTitle(annotation?.name, argument)}\n value={args[argument]}\n type={typeof type === \"string\" ? type : \"unknown\"}\n settings={settings}\n options={annotation?.options}\n isDisabled={settings.disable === true}\n onChange={onChange}\n />\n );\n })}\n </AdwPreferencesGroup>\n);\n\nexport { Controls };\n"]}
1
+ {"version":3,"file":"controls.js","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,MAAM,eAAe,GAAG,cAAc,CAAC;AACvC,MAAM,kBAAkB,GAAG,kBAAk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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAEnE,OAAO,CACH,KAAC,OAAO,IAEJ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,EAC/C,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,EACrB,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,UAAU,EAAE,OAAO,EAC5B,UAAU,EAAE,QAAQ,CAAC,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAChE,QAAQ,EAAE,QAAQ,IARb,QAAQ,CASf,CACL,CAAC;IACN,CAAC,CAAC,GACgB,CACzB,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { ComboRow } from \"@gtkx/components\";\nimport { markupEscapeText } from \"@gtkx/gi/glib\";\nimport { AdwActionRow, AdwEntryRow, AdwPreferencesGroup, AdwSpinRow, AdwSwitchRow } from \"@gtkx/jsx/adw\";\nimport { GtkAdjustment } from \"@gtkx/jsx/gtk\";\nimport type { Args, ArgTypes } from \"./types.js\";\n\ntype ControlsProps = { argTypes: ArgTypes; args: Args; onChange: (update: Args) => void };\n\nconst NO_SELECTION_ID = \"no-selection\";\nconst NO_SELECTION_LABEL = \"Choose option...\";\n\ntype ControlProps = {\n argument: string;\n title: string;\n value: unknown;\n type: string;\n settings: Args;\n options: unknown;\n isDisabled: boolean;\n onChange: (update: Args) => void;\n};\n\nconst isObject = (value: unknown): value is Args =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst isWithinBoundsOrAbsent = (value: unknown, min: number, max: number): boolean =>\n value === undefined || (typeof value === \"number\" && Number.isFinite(value) && value >= min && value <= max);\n\nconst controlTitle = (name: unknown, argument: string): string => (typeof name === \"string\" ? name : argument);\n\nconst numberDigits = (step: number): number => {\n const [coefficient = \"\", exponent = \"0\"] = String(step).split(\"e\", 2);\n const fraction = coefficient.split(\".\", 2)[1]?.length ?? 0;\n const digits = Math.max(0, fraction - Number(exponent));\n\n return Math.min(20, digits);\n};\n\nconst UnsupportedControl = ({ title, description }: { title: string; description: string }): ReactNode => (\n <AdwActionRow title={markupEscapeText(title, -1)} subtitle={markupEscapeText(description, -1)} sensitive={false} />\n);\n\nconst NumberControl = ({\n argument,\n title,\n value,\n settings,\n isDisabled,\n onChange,\n}: Omit<ControlProps, \"type\" | \"options\">): ReactNode => {\n const min = settings.min ?? -Number.MAX_SAFE_INTEGER;\n const max = settings.max ?? Number.MAX_SAFE_INTEGER;\n const step = settings.step ?? 1;\n\n if (\n typeof min !== \"number\" ||\n typeof max !== \"number\" ||\n typeof step !== \"number\" ||\n !Number.isFinite(min) ||\n !Number.isFinite(max) ||\n !Number.isFinite(step) ||\n step <= 0 ||\n min > max ||\n !isWithinBoundsOrAbsent(value, min, max)\n ) {\n return <UnsupportedControl title={title} description=\"Provide a finite number and valid bounds.\" />;\n }\n\n const currentValue = typeof value === \"number\" ? value : Math.max(min, Math.min(0, max));\n\n return (\n <AdwSpinRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n value={currentValue}\n digits={numberDigits(step)}\n numeric\n widthChars={8}\n adjustment={\n <GtkAdjustment\n lower={min}\n upper={max}\n stepIncrement={step}\n pageIncrement={Math.min(Number.MAX_VALUE, step * 10)}\n value={currentValue}\n />\n }\n onNotifyValue={(next) => {\n if (!Object.is(next, value)) {\n onChange({ [argument]: next });\n }\n }}\n />\n );\n};\n\nconst SelectControl = (props: Omit<ControlProps, \"type\">): ReactNode => {\n const { argument, title, value, options, settings, isDisabled, onChange } = props;\n if (\n !Array.isArray(options) ||\n options.length === 0 ||\n options.some(\n (option: unknown) =>\n option !== null &&\n typeof option !== \"string\" &&\n typeof option !== \"number\" &&\n typeof option !== \"boolean\",\n )\n ) {\n return <UnsupportedControl title={title} description=\"Provide a list of text, number, or boolean options.\" />;\n }\n\n const values: unknown[] = options;\n const selected = values.findIndex((option) => Object.is(option, value));\n const labels = isObject(settings.labels) ? settings.labels : {};\n const items = [\n { id: NO_SELECTION_ID, value: NO_SELECTION_LABEL },\n ...values.map((option, index) => {\n const label = labels[String(option)];\n\n return { id: String(index), value: typeof label === \"string\" ? label : String(option) };\n }),\n ];\n\n return (\n <ComboRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n items={items}\n selectedId={selected === -1 ? NO_SELECTION_ID : String(selected)}\n onSelectionChanged={(id) => {\n if (id === NO_SELECTION_ID) {\n onChange({ [argument]: undefined });\n\n return;\n }\n\n if (id === null) {\n return;\n }\n\n onChange({ [argument]: values[Number(id)] });\n }}\n />\n );\n};\n\nconst Control = (props: ControlProps): ReactNode => {\n const { argument, title, value, type, isDisabled, onChange } = props;\n\n switch (type) {\n case \"boolean\": {\n return (\n <AdwSwitchRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n active={value === true}\n onNotifyActive={(active) => {\n if (!Object.is(active, value)) {\n onChange({ [argument]: active });\n }\n }}\n />\n );\n }\n case \"text\": {\n return (\n <AdwEntryRow\n name={`storybook-control-${argument}`}\n title={markupEscapeText(title, -1)}\n sensitive={!isDisabled}\n text={typeof value === \"string\" ? value : \"\"}\n onNotifyText={(text) => {\n if (!Object.is(text, value)) {\n onChange({ [argument]: text });\n }\n }}\n />\n );\n }\n case \"number\":\n case \"range\": {\n return <NumberControl {...props} />;\n }\n case \"select\":\n case \"radio\":\n case \"inline-radio\": {\n return <SelectControl {...props} />;\n }\n default: {\n return <UnsupportedControl title={title} description={`Unsupported control: ${type}`} />;\n }\n }\n};\n\nconst Controls = ({ argTypes, args, onChange }: ControlsProps): ReactNode => (\n <AdwPreferencesGroup title=\"Controls\">\n {Object.entries(argTypes).map(([argument, annotation]) => {\n const control: unknown = annotation?.control;\n const table = isObject(annotation?.table) ? annotation.table : {};\n\n if (control === undefined || control === false || table.disable === true) {\n return null;\n }\n\n const settings = isObject(control) ? control : {};\n const type = typeof control === \"string\" ? control : settings.type;\n\n return (\n <Control\n key={argument}\n argument={argument}\n title={controlTitle(annotation?.name, argument)}\n value={args[argument]}\n type={typeof type === \"string\" ? type : \"unknown\"}\n settings={settings}\n options={annotation?.options}\n isDisabled={settings.disable === true || table.readonly === true}\n onChange={onChange}\n />\n );\n })}\n </AdwPreferencesGroup>\n);\n\nexport { Controls };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"explorer-navigator.d.ts","sourceRoot":"","sources":["../src/explorer-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,KAAK,cAAc,GAAG;IAClB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AA4DF,QAAA,MAAM,cAAc,GAAI,2CAA2C,cAAc,KAAG,SA4CnF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"explorer-navigator.d.ts","sourceRoot":"","sources":["../src/explorer-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,KAAK,cAAc,GAAG;IAClB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,cAA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OAAO,EAAE,OAAO,EAChB,UAAU,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 );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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 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 = 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"]}
@@ -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;AAM/C,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,UAAU,CAAC;CACrB,CAAC;AA6JF,QAAA,MAAM,gBAAgB,cAAe,YAAY,KAAG,SAoCnD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,9 +1,10 @@
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";
@@ -13,14 +14,12 @@ class PreviewBoundary extends Component {
13
14
  return props.args === state.args ? null : { error: null, args: props.args };
14
15
  }
15
16
  static getDerivedStateFromError(error) {
16
- return { error: error instanceof Error ? error : new Error(String(error)) };
17
+ return { error: normalizeError(error) };
17
18
  }
18
19
  state = { error: null, args: this.props.args };
19
20
  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." }));
21
+ 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) +
22
+ "\n\nAdjust controls, reset the preview, or select another story to continue." }));
24
23
  }
25
24
  }
26
25
  const previewMode = (story) => {
@@ -80,10 +79,8 @@ const usePreviewState = ({ entry }) => {
80
79
  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 })] }) }));
81
80
  const StorybookPreview = ({ entry }) => {
82
81
  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 })] }) }));
82
+ 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 ? (_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) +
83
+ "\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
84
  };
88
85
  export { StorybookPreview };
89
86
  //# 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,MAAM,aAAa,CAAC;AACxD,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;AACx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K,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,wBAAwB,CAAC,KAAoB,EAAE,KAAoB;QACtE,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAc;QAC1C,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5C,CAAC;IAEQ,KAAK,GAAkB,EAAE,KAAK,EAAE,I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AM,EACF,KAAC,YAAY,IACT,WAAW,EAAE,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,KAAK,GAAI,EACzE,GAAG,EAAE,KAAC,SAAS,IAAC,KAAK,EAAC,aAAa,EAAC,SAAS,EAAE,KAAK,GAAI,GAC1D,YAGN,MAAC,MAAM,eACH,KAAC,MAAM,IAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,QAAC,OAAO,kBAC1D,KAAC,eAAe,IAAwB,IAAI,EAAE,KAAK,CAAC,IAAI,YACnD,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CACpB,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,GAAI,CAC1D,CAAC,CAAC,CAAC,CACA,KAAC,aAAa,IACV,IAAI,EAAC,yBAAyB,EAC9B,KAAK,EAAC,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, 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,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;CAClB,CAAC;AAsDF,uGAAuG;AACvG,QAAA,MAAM,SAAS,uCAIZ,cAAc,KAAG,SAMnB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -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: (_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." }) })) }));
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,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,EA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AAmB,KAAK,EAAE,QAAQ,IAA5B,QAAQ,CAAC,EAAE,CAAqB;YACzD,CAAC,CAAC,CACM,KAAC,cAAc,IAAC,MAAM,EAAE,KAAC,YAAY,KAAG,YACpC,KAAC,aAAa,IACV,IAAI,EAAC,iBAAiB,EACtB,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,EAChE,QAAQ,EAAC,mCAAmC,EAC5C,WAAW,EAAC,kDAAkD,GAChE,GACW,CACpB,GACS,CACzB,CAAC;AACN,CAAC,CAAC;AAEF,uGAAuG;AACvG,MAAM,SAAS,GAAG,CAAC,EACf,OAAO,EACP,aAAa,GAAG,oBAAoB,EACpC,KAAK,GAAG,gBAAgB,GACX,EAAa,EAAE,CAAC,CAC7B,KAAC,cAAc,IAAC,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,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,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,CAAC,CAAC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AAC,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 +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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