@pollinations/ui 0.1.0-alpha.39 → 0.1.0-alpha.40

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.
@@ -3,9 +3,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  type MarkdownProps = {
4
4
  children: string;
5
5
  className?: string;
6
+ /** Quiet links stay grey, so they don't compete with a title beside them. */
7
+ linkTone?: "accent" | "quiet";
6
8
  };
7
9
  /** Compact markdown for cards and snippets. Use Prose for document-style content. */
8
- declare function Markdown({ children, className }: MarkdownProps): react_jsx_runtime.JSX.Element;
10
+ declare function Markdown({ children, className, linkTone, }: MarkdownProps): react_jsx_runtime.JSX.Element;
9
11
 
10
12
  type ProseProps = {
11
13
  children: string;
package/dist/markdown.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  CodeBlock
3
- } from "./chunk-R423OI5W.js";
3
+ } from "./chunk-MU7JQOTF.js";
4
4
  import {
5
5
  headingClassName
6
6
  } from "./chunk-QPNEXTZ5.js";
7
7
  import "./chunk-KLAOGE6Y.js";
8
+ import "./chunk-B7T42IY2.js";
8
9
  import {
9
10
  InlineLink
10
11
  } from "./chunk-WV4XTYMU.js";
@@ -73,6 +74,11 @@ function MarkdownCodeBlock({ children }) {
73
74
  );
74
75
  return /* @__PURE__ */ jsx(CodeBlock, { code, language, className: "polli:my-3" });
75
76
  }
77
+ var link = (tone) => ({ node, href, ...props }) => {
78
+ const media = inlineMedia(href, textContent(props.children));
79
+ if (media) return media;
80
+ return /* @__PURE__ */ jsx(InlineLink, { href, tone, ...props });
81
+ };
76
82
  var components = {
77
83
  ul: ({ node, ...props }) => /* @__PURE__ */ jsx(
78
84
  "ul",
@@ -121,13 +127,14 @@ var components = {
121
127
  }
122
128
  );
123
129
  },
124
- a: ({ node, href, ...props }) => {
125
- const media = inlineMedia(href, textContent(props.children));
126
- if (media) return media;
127
- return /* @__PURE__ */ jsx(InlineLink, { href, ...props });
128
- }
130
+ a: link("accent")
129
131
  };
130
- function Markdown({ children, className }) {
132
+ var quietComponents = { ...components, a: link("quiet") };
133
+ function Markdown({
134
+ children,
135
+ className,
136
+ linkTone = "accent"
137
+ }) {
131
138
  return /* @__PURE__ */ jsx(
132
139
  "div",
133
140
  {
@@ -135,7 +142,14 @@ function Markdown({ children, className }) {
135
142
  "polli:min-w-0 polli:font-body polli:leading-relaxed",
136
143
  className
137
144
  ),
138
- children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components, children })
145
+ children: /* @__PURE__ */ jsx(
146
+ ReactMarkdown,
147
+ {
148
+ remarkPlugins: [remarkGfm],
149
+ components: linkTone === "quiet" ? quietComponents : components,
150
+ children
151
+ }
152
+ )
139
153
  }
140
154
  );
141
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compositions/Markdown.tsx","../src/compositions/Prose.tsx"],"sourcesContent":["import { isValidElement, type ReactNode } from \"react\";\nimport ReactMarkdown, { type Components } from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn } from \"../lib/cn.ts\";\nimport { InlineLink } from \"../primitives/InlineLink.tsx\";\nimport { CodeBlock } from \"./CodeBlock.tsx\";\n\nexport type MarkdownProps = {\n children: string;\n className?: string;\n};\n\nfunction textContent(value: ReactNode): string {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value);\n }\n if (Array.isArray(value)) return value.map(textContent).join(\"\");\n if (isValidElement<{ children?: ReactNode }>(value)) {\n return textContent(value.props.children);\n }\n return \"\";\n}\n\nconst VIDEO_EXTENSIONS = new Set([\"m4v\", \"mov\", \"mp4\", \"webm\"]);\nconst AUDIO_EXTENSIONS = new Set([\n \"aac\",\n \"flac\",\n \"m4a\",\n \"mp3\",\n \"ogg\",\n \"opus\",\n \"wav\",\n]);\n\nfunction urlExtension(src: string): string {\n // Only the path names a file; the base resolves relative links.\n try {\n const { pathname } = new URL(src, \"http://localhost\");\n return pathname.split(\".\").pop()?.toLowerCase() ?? \"\";\n } catch {\n return \"\";\n }\n}\n\nfunction inlineMedia(src: string | undefined, label: string | undefined) {\n if (!src) return null;\n const extension = urlExtension(src);\n // Agent tool results use these labels for stored URLs without extensions.\n const video =\n VIDEO_EXTENSIONS.has(extension) || label === \"Generated video\";\n const audio =\n AUDIO_EXTENSIONS.has(extension) || label === \"Generated audio\";\n if (!video && !audio) return null;\n const Element = video ? \"video\" : \"audio\";\n return (\n <Element\n src={src}\n aria-label={label}\n controls\n playsInline={video || undefined}\n preload=\"metadata\"\n className=\"polli:max-w-full polli:rounded-lg\"\n />\n );\n}\n\nfunction MarkdownCodeBlock({ children }: { children?: ReactNode }) {\n const child = isValidElement<{\n children?: ReactNode;\n className?: string;\n }>(children)\n ? children\n : null;\n const language = child?.props.className?.match(/language-([^\\s]+)/)?.[1];\n const code = textContent(child?.props.children ?? children).replace(\n /\\n$/,\n \"\",\n );\n\n return <CodeBlock code={code} language={language} className=\"polli:my-3\" />;\n}\n\nconst components: Components = {\n ul: ({ node, ...props }) => (\n <ul\n className=\"polli:flex polli:min-w-0 polli:list-disc polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted\"\n {...props}\n />\n ),\n ol: ({ node, ...props }) => (\n <ol\n className=\"polli:flex polli:min-w-0 polli:list-decimal polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted\"\n {...props}\n />\n ),\n p: ({ node, ...props }) => (\n <p className=\"polli:mb-2 polli:last:mb-0\" {...props} />\n ),\n strong: ({ node, ...props }) => (\n <strong\n className=\"polli:font-semibold polli:text-theme-text-strong\"\n {...props}\n />\n ),\n code: ({ node, ...props }) => (\n <code\n className=\"polli:break-words polli:rounded polli:bg-theme-bg-subtle polli:px-1 polli:py-0.5 polli:font-mono polli:text-xs\"\n {...props}\n />\n ),\n pre: ({ children }) => <MarkdownCodeBlock>{children}</MarkdownCodeBlock>,\n img: ({ node, src, alt, ...props }) => {\n const media = inlineMedia(\n typeof src === \"string\" ? src : undefined,\n alt,\n );\n if (media) return media;\n return (\n <img\n src={src}\n alt={alt}\n loading=\"lazy\"\n className=\"polli:max-w-full polli:rounded-lg\"\n {...props}\n />\n );\n },\n a: ({ node, href, ...props }) => {\n const media = inlineMedia(href, textContent(props.children));\n if (media) return media;\n return <InlineLink href={href} {...props} />;\n },\n};\n\n/** Compact markdown for cards and snippets. Use Prose for document-style content. */\nexport function Markdown({ children, className }: MarkdownProps) {\n return (\n <div\n className={cn(\n \"polli:min-w-0 polli:font-body polli:leading-relaxed\",\n className,\n )}\n >\n <ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>\n {children}\n </ReactMarkdown>\n </div>\n );\n}\n","import Markdown, { type Components } from \"react-markdown\";\nimport rehypeSlug from \"rehype-slug\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn } from \"../lib/cn.ts\";\nimport { InlineLink } from \"../primitives/InlineLink.tsx\";\nimport { headingClassName } from \"../primitives/Typography.tsx\";\n\nexport type ProseProps = {\n children: string;\n className?: string;\n};\n\nconst components: Components = {\n h1: ({ node, ...props }) => (\n <h1\n className={headingClassName(\"title\", \"polli:mt-0 polli:mb-5\")}\n {...props}\n />\n ),\n h2: ({ node, ...props }) => (\n <h2\n className={headingClassName(\"section\", \"polli:mt-8 polli:mb-3\")}\n {...props}\n />\n ),\n h3: ({ node, ...props }) => (\n <h3\n className={headingClassName(\"subsection\", \"polli:mt-6 polli:mb-2\")}\n {...props}\n />\n ),\n p: ({ node, ...props }) => (\n <p className=\"polli:my-4 polli:leading-relaxed\" {...props} />\n ),\n a: ({ node, ...props }) => <InlineLink {...props} />,\n ul: ({ node, ...props }) => (\n <ul\n className=\"polli:my-4 polli:list-disc polli:pl-6 polli:leading-relaxed\"\n {...props}\n />\n ),\n ol: ({ node, ...props }) => (\n <ol\n className=\"polli:my-4 polli:list-decimal polli:pl-6 polli:leading-relaxed\"\n {...props}\n />\n ),\n blockquote: ({ node, ...props }) => (\n <blockquote\n className=\"polli:my-4 polli:border-l-4 polli:border-theme-border polli:pl-4 polli:text-theme-text-soft\"\n {...props}\n />\n ),\n code: ({ node, ...props }) => (\n <code\n className=\"polli:rounded polli:bg-theme-bg-active polli:px-1 polli:py-0.5 polli:font-pixel polli:text-sm\"\n {...props}\n />\n ),\n pre: ({ node, ...props }) => (\n <pre\n className=\"polli:my-4 polli:overflow-x-auto polli:rounded-lg polli:bg-theme-bg-active polli:p-4\"\n {...props}\n />\n ),\n table: ({ node, ...props }) => (\n <table\n className=\"polli:my-4 polli:w-full polli:border-collapse polli:text-sm\"\n {...props}\n />\n ),\n th: ({ node, ...props }) => (\n <th\n className=\"polli:border polli:border-theme-border polli:px-3 polli:py-2 polli:text-left polli:font-semibold\"\n {...props}\n />\n ),\n td: ({ node, ...props }) => (\n <td\n className=\"polli:border polli:border-theme-border polli:px-3 polli:py-2\"\n {...props}\n />\n ),\n hr: ({ node, ...props }) => (\n <hr className=\"polli:my-6 polli:border-theme-border\" {...props} />\n ),\n};\n\nexport function Prose({ children, className }: ProseProps) {\n return (\n <div\n className={cn(\n \"polli:font-body polli:text-theme-text-base polli:leading-relaxed\",\n className,\n )}\n >\n <Markdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeSlug]}\n components={components}\n >\n {children}\n </Markdown>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,sBAAsC;AAC/C,OAAO,mBAAwC;AAC/C,OAAO,eAAe;AAqDd;AA3CR,SAAS,YAAY,OAA0B;AAC3C,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AACxD,WAAO,OAAO,KAAK;AAAA,EACvB;AACA,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,WAAW,EAAE,KAAK,EAAE;AAC/D,MAAI,eAAyC,KAAK,GAAG;AACjD,WAAO,YAAY,MAAM,MAAM,QAAQ;AAAA,EAC3C;AACA,SAAO;AACX;AAEA,IAAM,mBAAmB,oBAAI,IAAI,CAAC,OAAO,OAAO,OAAO,MA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WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,MACnB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,MACrB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA,KAAC,QAAG,WAAU,wCAAwC,GAAG,OAAO;AAExE;AAEO,SAAS,MAAM,EAAE,UAAU,UAAU,GAAe;AACvD,SACI,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAW;AAAA,QACP;AAAA,QACA;AAAA,MACJ;AAAA,MAEA,0BAAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACG,eAAe,CAACC,UAAS;AAAA,UACzB,eAAe,CAAC,UAAU;AAAA,UAC1B,YAAYF;AAAA,UAEX;AAAA;AAAA,MACL;AAAA;AAAA,EACJ;AAER;","names":["Markdown","remarkGfm","jsx","components","Markdown","remarkGfm"]}
1
+ {"version":3,"sources":["../src/compositions/Markdown.tsx","../src/compositions/Prose.tsx"],"sourcesContent":["import { isValidElement, type ReactNode } from \"react\";\nimport ReactMarkdown, { type Components } from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn } from \"../lib/cn.ts\";\nimport { InlineLink } from \"../primitives/InlineLink.tsx\";\nimport { CodeBlock } from \"./CodeBlock.tsx\";\n\nexport type MarkdownProps = {\n children: string;\n className?: string;\n /** Quiet links stay grey, so they don't compete with a title beside them. */\n linkTone?: \"accent\" | \"quiet\";\n};\n\nfunction textContent(value: ReactNode): string {\n if (typeof value === \"string\" || typeof value === \"number\") {\n return String(value);\n }\n if (Array.isArray(value)) return value.map(textContent).join(\"\");\n if (isValidElement<{ children?: ReactNode }>(value)) {\n return textContent(value.props.children);\n }\n return \"\";\n}\n\nconst VIDEO_EXTENSIONS = new Set([\"m4v\", \"mov\", \"mp4\", \"webm\"]);\nconst AUDIO_EXTENSIONS = new Set([\n \"aac\",\n \"flac\",\n \"m4a\",\n \"mp3\",\n \"ogg\",\n \"opus\",\n \"wav\",\n]);\n\nfunction urlExtension(src: string): string {\n // Only the path names a file; the base resolves relative links.\n try {\n const { pathname } = new URL(src, \"http://localhost\");\n return pathname.split(\".\").pop()?.toLowerCase() ?? \"\";\n } catch {\n return \"\";\n }\n}\n\nfunction inlineMedia(src: string | undefined, label: string | undefined) {\n if (!src) return null;\n const extension = urlExtension(src);\n // Agent tool results use these labels for stored URLs without extensions.\n const video =\n VIDEO_EXTENSIONS.has(extension) || label === \"Generated video\";\n const audio =\n AUDIO_EXTENSIONS.has(extension) || label === \"Generated audio\";\n if (!video && !audio) return null;\n const Element = video ? \"video\" : \"audio\";\n return (\n <Element\n src={src}\n aria-label={label}\n controls\n playsInline={video || undefined}\n preload=\"metadata\"\n className=\"polli:max-w-full polli:rounded-lg\"\n />\n );\n}\n\nfunction MarkdownCodeBlock({ children }: { children?: ReactNode }) {\n const child = isValidElement<{\n children?: ReactNode;\n className?: string;\n }>(children)\n ? children\n : null;\n const language = child?.props.className?.match(/language-([^\\s]+)/)?.[1];\n const code = textContent(child?.props.children ?? children).replace(\n /\\n$/,\n \"\",\n );\n\n return <CodeBlock code={code} language={language} className=\"polli:my-3\" />;\n}\n\n/** A markdown link: an inline link, or the media it points to. */\nconst link =\n (tone: \"accent\" | \"quiet\"): Components[\"a\"] =>\n ({ node, href, ...props }) => {\n const media = inlineMedia(href, textContent(props.children));\n if (media) return media;\n return <InlineLink href={href} tone={tone} {...props} />;\n };\n\nconst components: Components = {\n ul: ({ node, ...props }) => (\n <ul\n className=\"polli:flex polli:min-w-0 polli:list-disc polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted\"\n {...props}\n />\n ),\n ol: ({ node, ...props }) => (\n <ol\n className=\"polli:flex polli:min-w-0 polli:list-decimal polli:flex-col polli:gap-1 polli:pl-5 polli:marker:text-theme-text-muted\"\n {...props}\n />\n ),\n p: ({ node, ...props }) => (\n <p className=\"polli:mb-2 polli:last:mb-0\" {...props} />\n ),\n strong: ({ node, ...props }) => (\n <strong\n className=\"polli:font-semibold polli:text-theme-text-strong\"\n {...props}\n />\n ),\n code: ({ node, ...props }) => (\n <code\n className=\"polli:break-words polli:rounded polli:bg-theme-bg-subtle polli:px-1 polli:py-0.5 polli:font-mono polli:text-xs\"\n {...props}\n />\n ),\n pre: ({ children }) => <MarkdownCodeBlock>{children}</MarkdownCodeBlock>,\n img: ({ node, src, alt, ...props }) => {\n const media = inlineMedia(\n typeof src === \"string\" ? src : undefined,\n alt,\n );\n if (media) return media;\n return (\n <img\n src={src}\n alt={alt}\n loading=\"lazy\"\n className=\"polli:max-w-full polli:rounded-lg\"\n {...props}\n />\n );\n },\n a: link(\"accent\"),\n};\nconst quietComponents: Components = { ...components, a: link(\"quiet\") };\n\n/** Compact markdown for cards and snippets. Use Prose for document-style content. */\nexport function Markdown({\n children,\n className,\n linkTone = \"accent\",\n}: MarkdownProps) {\n return (\n <div\n className={cn(\n \"polli:min-w-0 polli:font-body polli:leading-relaxed\",\n className,\n )}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={linkTone === \"quiet\" ? quietComponents : components}\n >\n {children}\n </ReactMarkdown>\n </div>\n );\n}\n","import Markdown, { type Components } from \"react-markdown\";\nimport rehypeSlug from \"rehype-slug\";\nimport remarkGfm from \"remark-gfm\";\nimport { cn } from \"../lib/cn.ts\";\nimport { InlineLink } from \"../primitives/InlineLink.tsx\";\nimport { headingClassName } from \"../primitives/Typography.tsx\";\n\nexport type ProseProps = {\n children: string;\n className?: string;\n};\n\nconst components: Components = {\n h1: ({ node, ...props }) => (\n <h1\n className={headingClassName(\"title\", \"polli:mt-0 polli:mb-5\")}\n {...props}\n />\n ),\n h2: ({ node, ...props }) => (\n <h2\n className={headingClassName(\"section\", \"polli:mt-8 polli:mb-3\")}\n {...props}\n />\n ),\n h3: ({ node, ...props }) => (\n <h3\n className={headingClassName(\"subsection\", \"polli:mt-6 polli:mb-2\")}\n {...props}\n />\n ),\n p: ({ node, ...props }) => (\n <p className=\"polli:my-4 polli:leading-relaxed\" {...props} />\n ),\n a: ({ node, ...props }) => <InlineLink {...props} />,\n ul: ({ node, ...props }) => (\n <ul\n className=\"polli:my-4 polli:list-disc polli:pl-6 polli:leading-relaxed\"\n {...props}\n />\n ),\n ol: ({ node, ...props }) => (\n <ol\n className=\"polli:my-4 polli:list-decimal polli:pl-6 polli:leading-relaxed\"\n {...props}\n />\n ),\n blockquote: ({ node, ...props }) => (\n <blockquote\n className=\"polli:my-4 polli:border-l-4 polli:border-theme-border polli:pl-4 polli:text-theme-text-soft\"\n {...props}\n />\n ),\n code: ({ node, ...props }) => (\n <code\n className=\"polli:rounded polli:bg-theme-bg-active polli:px-1 polli:py-0.5 polli:font-pixel polli:text-sm\"\n {...props}\n />\n ),\n pre: ({ node, ...props }) => (\n <pre\n className=\"polli:my-4 polli:overflow-x-auto polli:rounded-lg polli:bg-theme-bg-active polli:p-4\"\n {...props}\n />\n ),\n table: ({ node, ...props }) => (\n <table\n className=\"polli:my-4 polli:w-full polli:border-collapse polli:text-sm\"\n {...props}\n />\n ),\n th: ({ node, ...props }) => (\n <th\n className=\"polli:border polli:border-theme-border polli:px-3 polli:py-2 polli:text-left polli:font-semibold\"\n {...props}\n />\n ),\n td: ({ node, ...props }) => (\n <td\n className=\"polli:border polli:border-theme-border polli:px-3 polli:py-2\"\n {...props}\n />\n ),\n hr: ({ node, ...props }) => (\n <hr className=\"polli:my-6 polli:border-theme-border\" {...props} />\n ),\n};\n\nexport function Prose({ children, className }: ProseProps) {\n return (\n <div\n className={cn(\n \"polli:font-body polli:text-theme-text-base polli:leading-relaxed\",\n className,\n )}\n >\n <Markdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeSlug]}\n components={components}\n >\n {children}\n </Markdown>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,sBAAsC;AAC/C,OAAO,mBAAwC;AAC/C,OAAO,eAAe;AAuDd;AA3CR,SAAS,YAAY,OAA0B;AAC3C,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AACxD,WAAO,OAAO,KAAK;AAAA,EACvB;AACA,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,WAAW,EAAE,KAAK,EAAE;AAC/D,MAAI,eAAyC,KAAK,GAAG;AACjD,WAAO,YAAY,MAAM,MAAM,QAAQ;AAAA,EAC3C;AACA,SAAO;AACX;AAEA,IAAM,mBAAmB,oBAAI,IAAI,CAAC,OAAO,OAAO,OAAO,MAAM,CAAC;AAC9D,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAED,SAAS,aAAa,KAAqB;AAEvC,MAAI;AACA,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,KAAK,kBAAkB;AACpD,WAAO,SAAS,MAAM,GAAG,EAAE,IAAI,GAAG,YAAY,KAAK;AAAA,EACvD,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAEA,SAAS,YAAY,KAAyB,OAA2B;AACrE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,YAAY,aAAa,GAAG;AAElC,QAAM,QACF,iBAAiB,IA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ACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAU;AAAA,MACT,GAAG;AAAA;AAAA,EACR;AAAA,EAEJ,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,MAClB,gBAAAA,KAAC,QAAG,WAAU,wCAAwC,GAAG,OAAO;AAExE;AAEO,SAAS,MAAM,EAAE,UAAU,UAAU,GAAe;AACvD,SACI,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACG,WAAW;AAAA,QACP;AAAA,QACA;AAAA,MACJ;AAAA,MAEA,0BAAAA;AAAA,QAACE;AAAA,QAAA;AAAA,UACG,eAAe,CAACC,UAAS;AAAA,UACzB,eAAe,CAAC,UAAU;AAAA,UAC1B,YAAYF;AAAA,UAEX;AAAA;AAAA,MACL;AAAA;AAAA,EACJ;AAER;","names":["Markdown","remarkGfm","jsx","components","Markdown","remarkGfm"]}
@@ -42,6 +42,21 @@ type WalletKindIconProps = {
42
42
  };
43
43
  /** The paid/Quest marker: a card for paid balance or sprout for Quest Pollen. */
44
44
  declare const WalletKindIcon: FC<WalletKindIconProps>;
45
+ type WalletAmountProps = {
46
+ kind: WalletBalanceKind;
47
+ /** The formatted amount, e.g. "$5". */
48
+ children: ReactNode;
49
+ /** Grey, for amounts already claimed. */
50
+ muted?: boolean;
51
+ /** Inside a button the hint opens on hover only, so a tap still
52
+ * presses the button. */
53
+ inButton?: boolean;
54
+ className?: string;
55
+ };
56
+ /** An amount led by its balance's icon: "🌱 $5" or "💳 $5". Both balances
57
+ * are dollars, so the icon tells them apart; hovering or tapping it explains
58
+ * the balance, like the Models page chips. */
59
+ declare const WalletAmount: FC<WalletAmountProps>;
45
60
  type WalletBalanceCardProps = {
46
61
  tone?: "balance" | "neutral";
47
62
  kind: WalletBalanceKind;
@@ -54,4 +69,4 @@ type WalletBalanceCardProps = {
54
69
  };
55
70
  declare const WalletBalanceCard: FC<WalletBalanceCardProps>;
56
71
 
57
- export { AccountPollen, PAID_BALANCE_CHART_COLOR, PaidChip, TIER_BALANCE_CHART_COLOR, TierChip, WalletBalanceCard, type WalletBalanceCardProps, type WalletChipProps, WalletKindIcon, type WalletKindIconProps, formatPollen };
72
+ export { AccountPollen, PAID_BALANCE_CHART_COLOR, PaidChip, TIER_BALANCE_CHART_COLOR, TierChip, WalletAmount, type WalletAmountProps, WalletBalanceCard, type WalletBalanceCardProps, type WalletChipProps, WalletKindIcon, type WalletKindIconProps, formatPollen };
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  AccountPollen,
3
+ WalletAmount,
3
4
  WalletBalanceCard,
4
5
  WalletKindIcon,
5
6
  formatPollen
6
- } from "../chunk-QVKXUBIA.js";
7
+ } from "../chunk-MS2GGEMU.js";
7
8
  import {
8
9
  Chip
9
10
  } from "../chunk-OWQ2HDQB.js";
11
+ import "../chunk-B7T42IY2.js";
10
12
  import "../chunk-WV4XTYMU.js";
11
13
  import {
12
14
  cn
@@ -34,6 +36,7 @@ export {
34
36
  PaidChip,
35
37
  TIER_BALANCE_CHART_COLOR,
36
38
  TierChip,
39
+ WalletAmount,
37
40
  WalletBalanceCard,
38
41
  WalletKindIcon,
39
42
  formatPollen
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modules/wallet/chips.tsx","../../src/modules/wallet/colors.ts"],"sourcesContent":["import type { FC } from \"react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip, type ChipProps } from \"../../primitives/Chip.tsx\";\n\nexport type WalletChipProps = Omit<ChipProps, \"intent\">;\n\nexport const PaidChip: FC<WalletChipProps> = ({\n className,\n children,\n ...props\n}) => (\n <Chip {...props} className={cn(\"polli-wallet-chip-paid\", className)}>\n {children}\n </Chip>\n);\n\nexport const TierChip: FC<WalletChipProps> = ({\n className,\n children,\n ...props\n}) => (\n <Chip {...props} className={cn(\"polli-wallet-chip-tier\", className)}>\n {children}\n </Chip>\n);\n","export const PAID_BALANCE_CHART_COLOR = \"var(--polli-color-paid-soft)\";\nexport const TIER_BALANCE_CHART_COLOR = \"var(--polli-color-tier-soft)\";\n"],"mappings":";;;;;;;;;;;;;;;AAWI;AALG,IAAM,WAAgC,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,GAAG;AACP,MACI,oBAAC,QAAM,GAAG,OAAO,WAAW,GAAG,0BAA0B,SAAS,GAC7D,UACL;AAGG,IAAM,WAAgC,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,GAAG;AACP,MACI,oBAAC,QAAM,GAAG,OAAO,WAAW,GAAG,0BAA0B,SAAS,GAC7D,UACL;;;ACvBG,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/modules/wallet/chips.tsx","../../src/modules/wallet/colors.ts"],"sourcesContent":["import type { FC } from \"react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip, type ChipProps } from \"../../primitives/Chip.tsx\";\n\nexport type WalletChipProps = Omit<ChipProps, \"intent\">;\n\nexport const PaidChip: FC<WalletChipProps> = ({\n className,\n children,\n ...props\n}) => (\n <Chip {...props} className={cn(\"polli-wallet-chip-paid\", className)}>\n {children}\n </Chip>\n);\n\nexport const TierChip: FC<WalletChipProps> = ({\n className,\n children,\n ...props\n}) => (\n <Chip {...props} className={cn(\"polli-wallet-chip-tier\", className)}>\n {children}\n </Chip>\n);\n","export const PAID_BALANCE_CHART_COLOR = \"var(--polli-color-paid-soft)\";\nexport const TIER_BALANCE_CHART_COLOR = \"var(--polli-color-tier-soft)\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAWI;AALG,IAAM,WAAgC,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,GAAG;AACP,MACI,oBAAC,QAAM,GAAG,OAAO,WAAW,GAAG,0BAA0B,SAAS,GAC7D,UACL;AAGG,IAAM,WAAgC,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,GAAG;AACP,MACI,oBAAC,QAAM,GAAG,OAAO,WAAW,GAAG,0BAA0B,SAAS,GAC7D,UACL;;;ACvBG,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pollinations/ui",
3
- "version": "0.1.0-alpha.39",
3
+ "version": "0.1.0-alpha.40",
4
4
  "description": "Design primitives and UI modules for Pollinations apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/modules/wallet/format-pollen.ts","../src/modules/wallet/wallet-display.tsx","../src/modules/wallet/AccountPollen.tsx"],"sourcesContent":["// 5-digit budget for pollen display. Integer takes its space, decimals fill\n// the remainder (capped at 4), floor toward -infinity, trailing zeros stripped.\n// Integers needing >=6 digits switch to compact (K/M/B, 3 sig figs).\n// Decimal point and minus sign do not count toward the budget.\n\nconst BUDGET = 5;\nconst MAX_DECIMALS = 4;\nconst COMPACT_THRESHOLD = 100_000;\n\nfunction floorTo(value: number, decimals: number): number {\n // Avoid scaling error when the value already fits the display precision.\n if (Number(value.toFixed(decimals)) === value) return value;\n const factor = 10 ** decimals;\n return Math.floor(value * factor) / factor;\n}\n\nfunction formatCompact(value: number): string {\n const abs = Math.abs(value);\n const sign = value < 0 ? \"-\" : \"\";\n const [unit, scale] =\n abs >= 1e9\n ? ([\"B\", 1e9] as const)\n : abs >= 1e6\n ? ([\"M\", 1e6] as const)\n : ([\"K\", 1e3] as const);\n const ratio = abs / scale;\n const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);\n const decimals = Math.max(0, 3 - intDigits);\n const floored = floorTo(ratio, decimals);\n return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;\n}\n\nexport function formatPollen(value: number): string {\n if (!Number.isFinite(value) || value === 0) return \"0\";\n\n const abs = Math.abs(value);\n\n if (abs >= COMPACT_THRESHOLD) return formatCompact(value);\n\n const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;\n const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));\n const floored = floorTo(value, decimals);\n if (floored === 0) return \"0\";\n return Number(floored.toFixed(decimals)).toString();\n}\n","import type { FC, ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { CardIcon, SproutIcon } from \"../../primitives/icons/index.tsx\";\n\ntype WalletBalanceKind = \"paid\" | \"tier\";\n\nconst walletPanelClasses: Record<WalletBalanceKind, string> = {\n paid: \"polli-wallet-panel-paid\",\n tier: \"polli-wallet-panel-tier\",\n};\n\nconst walletTextClasses: Record<WalletBalanceKind, string> = {\n paid: \"polli-wallet-text-paid\",\n tier: \"polli-wallet-text-tier\",\n};\n\nconst walletKindIcons: Record<WalletBalanceKind, typeof CardIcon> = {\n paid: CardIcon,\n tier: SproutIcon,\n};\n\nexport type WalletKindIconProps = {\n kind: WalletBalanceKind;\n className?: string;\n};\n\n/** The paid/Quest marker: a card for paid balance or sprout for Quest Pollen. */\nexport const WalletKindIcon: FC<WalletKindIconProps> = ({\n kind,\n className,\n}) => {\n const Icon = walletKindIcons[kind];\n return (\n <Icon\n aria-hidden=\"true\"\n className={cn(\n \"polli:h-3.5 polli:w-3.5 polli:shrink-0\",\n walletTextClasses[kind],\n className,\n )}\n />\n );\n};\n\nexport type WalletBalanceCardProps = {\n tone?: \"balance\" | \"neutral\";\n kind: WalletBalanceKind;\n label: ReactNode;\n value: ReactNode;\n icon?: ReactNode;\n info?: ReactNode;\n footer?: ReactNode;\n className?: string;\n};\n\nexport const WalletBalanceCard: FC<WalletBalanceCardProps> = ({\n tone = \"balance\",\n kind,\n label,\n value,\n icon,\n info,\n footer,\n className,\n}) => {\n const Icon = walletKindIcons[kind];\n const textColor =\n tone === \"neutral\"\n ? \"polli:text-theme-text-strong\"\n : walletTextClasses[kind];\n return (\n <div\n className={cn(\n \"polli:min-w-0 polli:rounded-card polli:p-3.5 polli:sm:p-5\",\n tone === \"neutral\"\n ? \"polli:bg-surface-opaque\"\n : walletPanelClasses[kind],\n className,\n )}\n >\n <span className=\"polli:flex polli:items-center polli:gap-2\">\n {icon ?? (\n <Icon\n aria-hidden=\"true\"\n className={cn(\n \"polli:h-3.5 polli:w-3.5 polli:shrink-0\",\n textColor,\n )}\n />\n )}\n <span\n className={cn(\n \"polli:text-sm polli:font-bold polli:uppercase polli:tracking-wide\",\n textColor,\n )}\n >\n {label}\n </span>\n {info}\n </span>\n <div\n className={cn(\n \"polli-wallet-balance-value polli:[overflow-wrap:anywhere] polli:mt-1 polli:font-bold polli:leading-none polli:tracking-tight polli:tabular-nums\",\n textColor,\n )}\n >\n {value}\n </div>\n {footer && (\n <div className=\"polli:mt-1.5 polli:text-sm polli:font-bold polli:tabular-nums polli:text-intent-success-text\">\n {footer}\n </div>\n )}\n </div>\n );\n};\n","import { Chip } from \"../../primitives/Chip.tsx\";\nimport { InlineLink } from \"../../primitives/InlineLink.tsx\";\nimport {\n KeyIcon,\n WalletIcon,\n WarningIcon,\n} from \"../../primitives/icons/index.tsx\";\nimport { formatPollen } from \"./format-pollen.ts\";\nimport { WalletKindIcon } from \"./wallet-display.tsx\";\n\nexport type AccountPollenSource =\n | {\n type: \"wallet\";\n /** Undefined while the balance is unavailable. */\n balances?: { paid: number; quest: number };\n }\n | {\n type: \"budget\";\n /** The app's remaining budget, never the owner's wallet total. `null` = unlimited. */\n remaining?: number | null;\n generationEnabled?: boolean;\n }\n /** Pollinations is down, so the amount can't be read. */\n | { type: \"unavailable\" };\n\nfunction isEmpty(amount: number | null | undefined): boolean {\n return amount != null && amount <= 0;\n}\n\ntype PollenStatus = \"limit-reached\" | \"no-pollen\" | \"unlimited\" | \"unavailable\";\n\nconst labels: Record<PollenStatus, string> = {\n \"limit-reached\": \"Limit reached\",\n \"no-pollen\": \"No balance\",\n unlimited: \"Unlimited\",\n unavailable: \"Balance unavailable\",\n};\n\nconst intents = {\n \"limit-reached\": \"danger\",\n \"no-pollen\": \"danger\",\n unlimited: \"info\",\n unavailable: \"warning\",\n} as const satisfies Record<PollenStatus, string>;\n\nconst icons = {\n \"limit-reached\": KeyIcon,\n \"no-pollen\": WalletIcon,\n unlimited: KeyIcon,\n unavailable: WarningIcon,\n} satisfies Record<PollenStatus, unknown>;\n\nfunction PollenStatusBadge({\n state,\n topUpHref,\n}: {\n state: PollenStatus;\n topUpHref?: string;\n}) {\n const Icon = icons[state];\n const label = labels[state];\n return (\n <Chip size=\"sm\" intent={intents[state]} aria-label={label}>\n <Icon\n aria-hidden=\"true\"\n className=\"polli:h-3.5 polli:w-3.5 polli:shrink-0\"\n />\n {label}\n {state === \"no-pollen\" && topUpHref && (\n <>\n <span aria-hidden=\"true\">·</span>\n <InlineLink\n href={topUpHref}\n aria-label={`${label}. Top up`}\n >\n Top up\n </InlineLink>\n </>\n )}\n </Chip>\n );\n}\n\n/** Icon + amount; unlimited, exhausted, or empty states become a badge. */\nexport function AccountPollen({\n source,\n topUpHref,\n}: {\n source: AccountPollenSource;\n /** Shown in the empty-wallet badge. A menu keeps recovery links in its dropdown. */\n topUpHref?: string;\n}) {\n if (source.type === \"unavailable\")\n return <PollenStatusBadge state=\"unavailable\" />;\n if (source.type === \"budget\") {\n if (source.generationEnabled === false) return null;\n // null is the API's explicit \"no budget\"; undefined is not loaded yet.\n const unlimited = source.remaining === null;\n if (!unlimited && source.remaining === undefined) return null;\n if (unlimited) return <PollenStatusBadge state=\"unlimited\" />;\n const remaining = source.remaining as number;\n if (isEmpty(remaining))\n return <PollenStatusBadge state=\"limit-reached\" />;\n return (\n <span\n title=\"App budget left\"\n className=\"polli:inline-flex polli:items-center polli:gap-1 polli:tabular-nums\"\n >\n <KeyIcon\n aria-hidden=\"true\"\n className=\"polli:h-3.5 polli:w-3.5 polli:shrink-0\"\n />\n <span className=\"polli:sr-only\">App budget: </span>$\n {formatPollen(remaining)}\n </span>\n );\n }\n const { balances } = source;\n if (!balances) return null;\n if (isEmpty(balances.paid) && isEmpty(balances.quest))\n return <PollenStatusBadge state=\"no-pollen\" topUpHref={topUpHref} />;\n return (\n <span className=\"polli:inline-flex polli:items-center polli:gap-2 polli:tabular-nums\">\n {/* Quest Pollen is spent first, so it comes first. */}\n {([\"quest\", \"paid\"] as const).map((kind) => {\n const amount = balances[kind];\n return (\n <span\n key={kind}\n className=\"polli:inline-flex polli:items-center polli:gap-1\"\n >\n <WalletKindIcon\n kind={kind === \"paid\" ? \"paid\" : \"tier\"}\n />\n <span className=\"polli:sr-only\">\n {kind === \"paid\" ? \"Paid\" : \"Quest\"} balance:{\" \"}\n </span>\n {formatPollen(Math.max(0, amount))}\n </span>\n );\n })}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAM,SAAS;AACf,IAAM,eAAe;AACrB,IAAM,oBAAoB;AAE1B,SAAS,QAAQ,OAAe,UAA0B;AAEtD,MAAI,OAAO,MAAM,QAAQ,QAAQ,CAAC,MAAM,MAAO,QAAO;AACtD,QAAM,SAAS,MAAM;AACrB,SAAO,KAAK,MAAM,QAAQ,MAAM,IAAI;AACxC;AAEA,SAAS,cAAc,OAAuB;AAC1C,QAAM,MAAM,KAAK,IAAI,KAAK;AAC1B,QAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,QAAM,CAAC,MAAM,KAAK,IACd,OAAO,MACA,CAAC,KAAK,GAAG,IACV,OAAO,MACJ,CAAC,KAAK,GAAG,IACT,CAAC,KAAK,GAAG;AACtB,QAAM,QAAQ,MAAM;AACpB,QAAM,YAAY,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,MAAM,KAAK,CAAC,IAAI,CAAC;AAC/D,QAAM,WAAW,KAAK,IAAI,GAAG,IAAI,SAAS;AAC1C,QAAM,UAAU,QAAQ,OAAO,QAAQ;AACvC,SAAO,GAAG,IAA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I,CAAC,SAAS;AACxC,UAAM,SAAS,SAAS,IAAI;AAC5B,WACI,gBAAAC;AAAA,MAAC;AAAA;AAAA,QAEG,WAAU;AAAA,QAEV;AAAA,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACG,MAAM,SAAS,SAAS,SAAS;AAAA;AAAA,UACrC;AAAA,UACA,gBAAAC,MAAC,UAAK,WAAU,iBACX;AAAA,qBAAS,SAAS,SAAS;AAAA,YAAQ;AAAA,YAAU;AAAA,aAClD;AAAA,UACC,aAAa,KAAK,IAAI,GAAG,MAAM,CAAC;AAAA;AAAA;AAAA,MAT5B;AAAA,IAUT;AAAA,EAER,CAAC,GACL;AAER;","names":["jsx","jsxs"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/primitives/Tooltip.tsx","../src/compositions/CopyButton.tsx","../src/compositions/CodeBlock.tsx"],"sourcesContent":["import {\n type CSSProperties,\n cloneElement,\n type FC,\n type FocusEvent,\n Fragment,\n isValidElement,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn.ts\";\n\nconst TOOLTIP_MAX_WIDTH = 288;\nconst TOOLTIP_VIEWPORT_MARGIN = 12;\n\n/** Internal geometry, using the popup's measured size rather than its max-width. */\nexport function getTooltipPosition(\n trigger: Pick<DOMRect, \"top\" | \"bottom\" | \"left\" | \"width\">,\n popup: Pick<DOMRect, \"width\" | \"height\">,\n viewport: { width: number; height: number },\n align: \"start\" | \"center\",\n clampToViewport: boolean,\n) {\n let left =\n align === \"center\"\n ? trigger.left + (trigger.width - popup.width) / 2\n : trigger.left;\n if (clampToViewport) {\n left = Math.max(\n TOOLTIP_VIEWPORT_MARGIN,\n Math.min(\n left,\n viewport.width - popup.width - TOOLTIP_VIEWPORT_MARGIN,\n ),\n );\n }\n let top = trigger.bottom + 4;\n if (top + popup.height > viewport.height - TOOLTIP_VIEWPORT_MARGIN) {\n top = trigger.top - popup.height - 4;\n }\n return { top: Math.max(TOOLTIP_VIEWPORT_MARGIN, top), left };\n}\n\ntype TooltipProps = {\n children: ReactNode;\n content: ReactNode;\n align?: \"start\" | \"center\";\n ariaLabel?: string;\n clampToViewport?: boolean;\n className?: string;\n maxWidth?: number;\n onClick?: () => void;\n stopClickPropagation?: boolean;\n style?: CSSProperties;\n tapEnabled?: boolean;\n triggerAs?: \"button\" | \"span\";\n /**\n * When true, the inner cursor wrapper uses display:contents so the\n * trigger's flex/grid layout applies directly to the caller's children\n * without an inline wrapper in the way.\n */\n displayContents?: boolean;\n};\n\nexport const Tooltip: FC<TooltipProps> = ({\n children,\n content,\n align = \"start\",\n ariaLabel,\n clampToViewport = true,\n className,\n maxWidth = TOOLTIP_MAX_WIDTH,\n onClick,\n stopClickPropagation = true,\n style,\n tapEnabled = false,\n triggerAs = \"button\",\n displayContents = false,\n}) => {\n const [showTooltip, setShowTooltip] = useState(false);\n const [tooltipPosition, setTooltipPosition] = useState<{\n top: number;\n left: number;\n }>({\n top: 0,\n left: 0,\n });\n const triggerRef = useRef<HTMLElement | null>(null);\n const popupRef = useRef<HTMLSpanElement | null>(null);\n const tapPinnedRef = useRef(false);\n const closeTimeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);\n const tooltipId = useId();\n\n const openTooltip = () => {\n clearTimeout(closeTimeoutRef.current);\n setShowTooltip(true);\n };\n const closeTooltip = () => {\n clearTimeout(closeTimeoutRef.current);\n tapPinnedRef.current = false;\n setShowTooltip(false);\n };\n const scheduleCloseTooltip = () => {\n clearTimeout(closeTimeoutRef.current);\n // Leave time to cross the gap between the trigger and popup.\n closeTimeoutRef.current = setTimeout(() => {\n if (\n !tapPinnedRef.current &&\n !triggerRef.current?.matches(\n \":hover, :focus-visible, :has(:focus-visible)\",\n ) &&\n !popupRef.current?.matches(\":hover\")\n ) {\n setShowTooltip(false);\n }\n }, 150);\n };\n\n useEffect(() => () => clearTimeout(closeTimeoutRef.current), []);\n\n useEffect(() => {\n if (!showTooltip) return;\n\n const dismissOnOutsideTap = (event: PointerEvent) => {\n if (\n triggerRef.current?.contains(event.target as Node) ||\n popupRef.current?.contains(event.target as Node)\n )\n return;\n clearTimeout(closeTimeoutRef.current);\n tapPinnedRef.current = false;\n setShowTooltip(false);\n };\n const dismissOnEscape = (event: globalThis.KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n tapPinnedRef.current = false;\n setShowTooltip(false);\n };\n const dismissOnViewportChange = () => {\n tapPinnedRef.current = false;\n setShowTooltip(false);\n };\n\n document.addEventListener(\"pointerdown\", dismissOnOutsideTap);\n document.addEventListener(\"keydown\", dismissOnEscape);\n window.addEventListener(\"scroll\", dismissOnViewportChange, {\n capture: true,\n passive: true,\n });\n window.addEventListener(\"resize\", dismissOnViewportChange);\n return () => {\n document.removeEventListener(\"pointerdown\", dismissOnOutsideTap);\n document.removeEventListener(\"keydown\", dismissOnEscape);\n window.removeEventListener(\"scroll\", dismissOnViewportChange, true);\n window.removeEventListener(\"resize\", dismissOnViewportChange);\n };\n }, [showTooltip]);\n\n useLayoutEffect(() => {\n if (showTooltip && triggerRef.current && popupRef.current) {\n setTooltipPosition(\n getTooltipPosition(\n triggerRef.current.getBoundingClientRect(),\n popupRef.current.getBoundingClientRect(),\n { width: window.innerWidth, height: window.innerHeight },\n align,\n clampToViewport,\n ),\n );\n }\n }, [showTooltip, align, clampToViewport, maxWidth, content]);\n\n // Informational triggers use help; action wrappers can override the cursor.\n // Only real controls get the expanded tap area; on a plain span wrapper it\n // would cover the interactive child (e.g. IconButton) on mobile.\n const isControl = triggerAs === \"button\" || tapEnabled;\n const triggerClassName = cn(\n isControl && \"polli-control\",\n \"polli:relative polli:cursor-help polli:text-left polli:inline-flex polli:items-center\",\n className,\n );\n\n const cursorClass = displayContents\n ? \"polli:contents\"\n : \"polli:cursor-inherit\";\n const descriptionId = content && showTooltip ? tooltipId : undefined;\n // Span wrappers around actions must describe the action itself. Custom\n // children must forward aria-describedby to their underlying control.\n const describeChild =\n !isControl &&\n isValidElement<{ \"aria-describedby\"?: string }>(children) &&\n children.type !== Fragment;\n const describedChildren =\n describeChild && descriptionId\n ? cloneElement(children, {\n \"aria-describedby\": [\n children.props[\"aria-describedby\"],\n descriptionId,\n ]\n .filter(Boolean)\n .join(\" \"),\n })\n : children;\n\n // Portal past the trigger's layout; stay inside modal dialogs so the popup\n // shares their stacking and accessible subtree.\n const popupClasses =\n \"polli:fixed polli:box-border polli:w-max polli:px-2 polli:py-1 polli:bg-surface-menu polli:text-theme-text-base polli:font-normal polli:leading-snug polli:tracking-normal polli:normal-case polli:not-italic polli:text-xs polli:rounded-md polli:shadow-md polli:z-[130] polli:transition-opacity polli:whitespace-pre-line polli:break-words\";\n\n const popupNode = content ? (\n <span\n ref={popupRef}\n id={tooltipId}\n role=\"tooltip\"\n aria-hidden={!showTooltip}\n style={{\n top: tooltipPosition.top,\n left: tooltipPosition.left,\n maxWidth: `min(${maxWidth}px, calc(100vw - ${TOOLTIP_VIEWPORT_MARGIN * 2}px))`,\n }}\n onMouseEnter={openTooltip}\n onMouseLeave={scheduleCloseTooltip}\n onClick={(event) => event.stopPropagation()}\n className={`${\n showTooltip\n ? \"polli:visible polli:opacity-100\"\n : \"polli:invisible polli:opacity-0\"\n } ${popupClasses}`}\n >\n {content}\n </span>\n ) : null;\n const tooltipPopup =\n popupNode && typeof document !== \"undefined\"\n ? createPortal(\n popupNode,\n triggerRef.current?.closest('[role=\"dialog\"]') ??\n document.body,\n )\n : popupNode;\n const contentNode = (\n <>\n <span className={cursorClass}>{describedChildren}</span>\n {tooltipPopup}\n </>\n );\n\n const sharedProps = {\n \"aria-label\": ariaLabel,\n \"aria-describedby\": describeChild ? undefined : descriptionId,\n className: triggerClassName,\n onMouseEnter: openTooltip,\n onMouseLeave: scheduleCloseTooltip,\n onClick: (e: MouseEvent) => {\n if (stopClickPropagation) e.stopPropagation();\n if (onClick) {\n onClick();\n }\n if (!tapEnabled || !content) return;\n if (tapPinnedRef.current) {\n closeTooltip();\n return;\n }\n tapPinnedRef.current = true;\n openTooltip();\n },\n // Keyboard focus opens the tooltip. A click also focuses the trigger;\n // counting that would keep the tooltip up after the pointer leaves.\n onFocus: (event: FocusEvent) => {\n if ((event.target as HTMLElement).matches(\":focus-visible\")) {\n openTooltip();\n }\n },\n onBlur: () => {\n tapPinnedRef.current = false;\n scheduleCloseTooltip();\n },\n style,\n };\n\n if (triggerAs === \"span\") {\n const handleKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {\n if (!tapEnabled || !content) return;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n if (tapPinnedRef.current) {\n closeTooltip();\n return;\n }\n tapPinnedRef.current = true;\n openTooltip();\n };\n const spanInteractionProps = {\n ...sharedProps,\n role: tapEnabled && content ? \"button\" : undefined,\n tabIndex: tapEnabled && content ? 0 : undefined,\n onKeyDown: tapEnabled && content ? handleKeyDown : undefined,\n };\n\n return (\n <span\n ref={(node) => {\n triggerRef.current = node;\n }}\n {...spanInteractionProps}\n >\n {contentNode}\n </span>\n );\n }\n\n return (\n <button\n ref={(node) => {\n triggerRef.current = node;\n }}\n type=\"button\"\n aria-label={ariaLabel}\n aria-describedby={content && showTooltip ? tooltipId : undefined}\n className={triggerClassName}\n onMouseEnter={sharedProps.onMouseEnter}\n onMouseLeave={sharedProps.onMouseLeave}\n onClick={sharedProps.onClick}\n onFocus={sharedProps.onFocus}\n onBlur={sharedProps.onBlur}\n style={style}\n >\n {contentNode}\n </button>\n );\n};\n","import {\n type ButtonHTMLAttributes,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { Button, type ButtonProps } from \"../primitives/Button.tsx\";\nimport { CheckIcon, ClipboardIcon } from \"../primitives/icons/index.tsx\";\nimport type { IconProps } from \"../primitives/icons/types.ts\";\nimport { Tooltip } from \"../primitives/Tooltip.tsx\";\n\n/** The copy state as an icon: a clipboard, then an amber check once copied.\n * The icon is the only thing a copy changes: labels and colours stay put. */\nexport function CopyStateIcon({\n copied,\n className,\n ...props\n}: IconProps & { copied: boolean }) {\n return copied ? (\n <CheckIcon\n {...props}\n data-theme=\"accent\"\n className={cn(className, \"polli:text-theme-text-soft\")}\n />\n ) : (\n <ClipboardIcon {...props} className={className} />\n );\n}\n\ntype CopyValue = string | (() => string | Promise<string>);\n\n/** How long the check shows, the same for every copy button. */\nconst COPIED_MS = 1500;\n\nexport type CopyButtonProps = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"children\" | \"className\" | \"onClick\" | \"type\" | \"value\"\n> & {\n value: CopyValue;\n children: ReactNode | ((copied: boolean) => ReactNode);\n /** Extra hover content, e.g. the full value behind a short label. Copy\n * buttons don't need one to say \"copy\": the icon does. */\n tooltip?: ReactNode;\n tooltipAlign?: \"start\" | \"center\";\n tooltipClampToViewport?: boolean;\n tooltipMaxWidth?: number;\n tooltipClassName?: string;\n className?: string | ((copied: boolean) => string);\n variant?: \"plain\" | \"button\";\n /** Button intent, used with `variant=\"button\"`. */\n intent?: ButtonProps<\"button\">[\"intent\"];\n onCopied?: () => void;\n onCopyError?: (error: unknown) => void;\n};\n\nexport function CopyButton({\n value,\n children,\n tooltip,\n tooltipAlign,\n tooltipClampToViewport,\n tooltipMaxWidth,\n tooltipClassName,\n className,\n variant = \"plain\",\n intent,\n onCopied,\n onCopyError,\n ...buttonProps\n}: CopyButtonProps) {\n const [copied, setCopied] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n },\n [],\n );\n\n async function handleCopy(event: MouseEvent<HTMLButtonElement>) {\n event.stopPropagation();\n try {\n const text = typeof value === \"function\" ? await value() : value;\n await navigator.clipboard.writeText(text);\n setCopied(true);\n onCopied?.();\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => setCopied(false), COPIED_MS);\n } catch (error) {\n onCopyError?.(error);\n }\n }\n\n const Control = variant === \"button\" ? Button : \"button\";\n const button = (\n <Control\n {...buttonProps}\n {...(variant === \"button\" && intent ? { intent } : {})}\n type=\"button\"\n onClick={handleCopy}\n className={cn(\n \"polli-control\",\n buttonProps.disabled\n ? \"polli:cursor-not-allowed\"\n : \"polli:cursor-pointer\",\n typeof className === \"function\" ? className(copied) : className,\n )}\n >\n {typeof children === \"function\" ? children(copied) : children}\n {/* Said, not shown: the icon is the visible answer. */}\n <span className=\"polli:sr-only\" aria-live=\"polite\">\n {copied ? \"Copied\" : \"\"}\n </span>\n </Control>\n );\n\n if (!tooltip) return button;\n\n return (\n <Tooltip\n triggerAs=\"span\"\n content={tooltip}\n align={tooltipAlign}\n clampToViewport={tooltipClampToViewport}\n maxWidth={tooltipMaxWidth}\n displayContents\n tapEnabled={false}\n className={cn(\n buttonProps.disabled\n ? \"polli:cursor-not-allowed\"\n : \"polli:cursor-pointer\",\n tooltipClassName,\n )}\n >\n {button}\n </Tooltip>\n );\n}\n","import type { ComponentPropsWithoutRef, FC } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { CopyButton, CopyStateIcon } from \"./CopyButton.tsx\";\n\ntype CodeBlockOwnProps = {\n code: string;\n codeClassName?: string;\n language?: string;\n};\n\nexport type CodeBlockProps = CodeBlockOwnProps &\n Omit<ComponentPropsWithoutRef<\"div\">, keyof CodeBlockOwnProps | \"children\">;\n\nexport const CodeBlock: FC<CodeBlockProps> = ({\n code,\n codeClassName,\n language,\n className,\n ...rest\n}) => {\n const label = language || \"Code\";\n\n return (\n <div\n {...rest}\n className={cn(\n \"polli:min-w-0 polli:max-w-full polli:overflow-hidden polli:rounded-lg polli:border polli:border-theme-border polli:bg-theme-bg-pale\",\n className,\n )}\n >\n <div className=\"polli:flex polli:min-h-9 polli:items-center polli:justify-between polli:gap-3 polli:bg-theme-bg-subtle polli:px-3 polli:py-1.5\">\n <span className=\"polli:truncate polli:font-mono polli:text-[11px] polli:font-medium polli:uppercase polli:tracking-wide polli:text-theme-text-muted\">\n {label}\n </span>\n <CopyButton\n value={code}\n aria-label=\"Copy code\"\n className=\"polli:flex polli:items-center polli:gap-1.5 polli:rounded-md polli:px-2 polli:py-1 polli:text-xs polli:font-medium polli:text-theme-text-base polli:transition-colors polli:hover:bg-theme-fill-wash polli:hover:text-theme-text-strong\"\n >\n {(copied) => (\n <>\n <CopyStateIcon\n copied={copied}\n className=\"polli:size-3.5\"\n />\n <span>Copy</span>\n </>\n )}\n </CopyButton>\n </div>\n <pre\n className={cn(\n \"polli:m-0 polli:min-w-0 polli:whitespace-pre-wrap polli:break-words polli:[overflow-wrap:anywhere] polli:[tab-size:4] polli:p-3 polli:font-mono polli:text-xs polli:leading-6 polli:text-theme-text-strong\",\n codeClassName,\n )}\n >\n <code>{code}</code>\n </pre>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EAEI;AAAA,EAGA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,oBAAoB;AAyMrB,SA+BA,YAAAA,WA/BA,KA+BA,YA/BA;AAtMR,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAGzB,SAAS,mBACZ,SACA,OACA,UACA,OACA,iBACF;AACE,MAAI,OACA,UAAU,WACJ,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,SAAS,IAC/C,QAAQ;AAClB,MAAI,iBAAiB;AACjB,WAAO,KAAK;AAAA,MACR;AAAA,MACA,KAAK;AAAA,QACD;AAAA,QACA,SAAS,QAAQ,MAAM,QAAQ;AAAA,MACnC;AAAA,IACJ;AAAA,EACJ;AACA,MAAI,MAAM,QAAQ,SAAS;AAC3B,MAAI,MAAM,MAAM,SAAS,SAAS,SAAS,yBAAyB;AAChE,UAAM,QAAQ,MAAM,MAAM,SAAS;AAAA,EACvC;AACA,SAAO,EAAE,KAAK,KAAK,I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YACG,WAAW;AAAA,cACP;AAAA,cACA;AAAA,YACJ;AAAA,YAEA,0BAAAA,KAAC,UAAM,gBAAK;AAAA;AAAA,QAChB;AAAA;AAAA;AAAA,EACJ;AAER;","names":["Fragment","useEffect","useRef","useState","jsx","jsxs","useState","useRef","useEffect","Fragment","jsx","jsxs"]}