/** * Story authoring helpers: attribute and class-map builders, conditional * attribute helpers, keyed list rendering, and escape-only text rendering. * * @module bquery/storybook */ import type { StoryValue } from './story-html'; import type { UnsafeHtmlMarker } from './unsafe-html'; /** * Builds a space-joined class value from a record of class → boolean. * Truthy values include the class, falsy values skip it. * * @remarks * Mirrors the `lit-html` `classMap` directive for ergonomic parity with * existing community examples. * * @param classes - Record of class names → truthiness predicate * @returns A space-joined class value, or empty when no classes apply * * @example * ```ts * storyHtml`Save`; * ``` */ export declare const classMap: (classes: Record) => string; /** * Builds a `style="..."` attribute value from a record of CSS properties. * * @remarks * Property names are passed through unchanged — supply hyphenated names like * `'background-color'`, or camelCase names which are converted to hyphenated * form (matching the `lit-html` `styleMap` semantics). * * Values are coerced to strings; `null`/`undefined`/`false` skip the property. * * @example * ```ts * storyHtml`
`; * ``` */ export declare const styleMap: (styles: Record) => string; /** * Conditionally includes an attribute value. When `value` is `null` or * `undefined`, returns an empty string so the surrounding template emits an * empty attribute value (`attr=""`). Otherwise the value is stringified. * * @example * ```ts * storyHtml``; * ``` */ export declare const ifDefined: (value: string | number | null | undefined) => string; /** * Maps each item in `items` through `render` and joins the results, attaching * a stable key marker to each item so consumers can identify list entries. * * @remarks * Because Storybook's string renderer has no DOM diffing, `repeat` simply * concatenates fragments. Plain-string results are escaped as text; to insert * trusted markup, wrap the fragment with {@link unsafeHtml}. The key is * rendered as a `data-bq-key` attribute on the first opening tag of each * fragment if present, otherwise the fragment is inserted unchanged. The * optional `key` function is invoked once per item. * * @example * ```ts * storyHtml``; * ``` */ export declare const repeat: (items: readonly T[], render: (item: T, index: number) => StoryValue, key?: (item: T, index: number) => string | number) => UnsafeHtmlMarker; /** * Escape-only helper for text-only fragments. Returns the input with HTML * entities encoded so it is safe to interpolate directly into a story * template. * * @remarks * Unlike {@link storyHtml}, `storyText` does not parse the template for tags * or attributes — it is intended for plain text. Use it whenever you want * args-provided strings to render verbatim without HTML interpretation. * * @example * ```ts * storyHtml`${storyText(args.label)}`; * ``` */ export declare const storyText: (text: string | number | null | undefined) => string; //# sourceMappingURL=helpers.d.ts.map