tempest-react-sdk 0.75.0 → 0.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +4 -2
  2. package/bin/create-tempest-app.e2e.test.mjs +112 -0
  3. package/bin/create-tempest-app.mjs +69 -28
  4. package/bin/lib/component/generate.mjs +191 -0
  5. package/bin/lib/component/generate.test.mjs +336 -0
  6. package/bin/lib/openapi/escape.mjs +210 -0
  7. package/bin/lib/openapi/generate.hostile.test.mjs +592 -0
  8. package/bin/lib/openapi/generate.mjs +93 -17
  9. package/bin/lib/openapi/schema-to-zod.mjs +41 -4
  10. package/bin/tempest.mjs +184 -3
  11. package/dist/auth/create-tempest-auth.cjs +1 -1
  12. package/dist/auth/create-tempest-auth.cjs.map +1 -1
  13. package/dist/auth/create-tempest-auth.js +127 -55
  14. package/dist/auth/create-tempest-auth.js.map +1 -1
  15. package/dist/auth/refresh-queue.cjs +1 -1
  16. package/dist/auth/refresh-queue.cjs.map +1 -1
  17. package/dist/auth/refresh-queue.js +13 -6
  18. package/dist/auth/refresh-queue.js.map +1 -1
  19. package/dist/br/pix.cjs +1 -1
  20. package/dist/br/pix.cjs.map +1 -1
  21. package/dist/br/pix.js +72 -62
  22. package/dist/br/pix.js.map +1 -1
  23. package/dist/br.d.ts +12 -4
  24. package/dist/components/Chat/ChatAttachments.cjs +1 -1
  25. package/dist/components/Chat/ChatAttachments.cjs.map +1 -1
  26. package/dist/components/Chat/ChatAttachments.js +46 -38
  27. package/dist/components/Chat/ChatAttachments.js.map +1 -1
  28. package/dist/components/Markdown/markdown-parse.cjs +7 -5
  29. package/dist/components/Markdown/markdown-parse.cjs.map +1 -1
  30. package/dist/components/Markdown/markdown-parse.js +151 -87
  31. package/dist/components/Markdown/markdown-parse.js.map +1 -1
  32. package/dist/components/Toast/Toast.module.cjs +1 -1
  33. package/dist/components/Toast/Toast.module.cjs.map +1 -1
  34. package/dist/components/Toast/Toast.module.js +7 -3
  35. package/dist/components/Toast/Toast.module.js.map +1 -1
  36. package/dist/components/Toast/ToastProvider.cjs +1 -1
  37. package/dist/components/Toast/ToastProvider.cjs.map +1 -1
  38. package/dist/components/Toast/ToastProvider.js +77 -51
  39. package/dist/components/Toast/ToastProvider.js.map +1 -1
  40. package/dist/data/create-data-provider.cjs +1 -1
  41. package/dist/data/create-data-provider.cjs.map +1 -1
  42. package/dist/data/create-data-provider.js +32 -21
  43. package/dist/data/create-data-provider.js.map +1 -1
  44. package/dist/http/api-client.cjs +1 -1
  45. package/dist/http/api-client.cjs.map +1 -1
  46. package/dist/http/api-client.js +81 -73
  47. package/dist/http/api-client.js.map +1 -1
  48. package/dist/http/errors.cjs +1 -1
  49. package/dist/http/errors.cjs.map +1 -1
  50. package/dist/http/errors.js +39 -35
  51. package/dist/http/errors.js.map +1 -1
  52. package/dist/neural.cjs +2 -0
  53. package/dist/neural.cjs.map +1 -0
  54. package/dist/neural.d.ts +110 -0
  55. package/dist/neural.js +48 -0
  56. package/dist/neural.js.map +1 -0
  57. package/dist/oauth/callback.cjs +2 -0
  58. package/dist/oauth/callback.cjs.map +1 -0
  59. package/dist/oauth/callback.js +42 -0
  60. package/dist/oauth/callback.js.map +1 -0
  61. package/dist/oauth/use-oauth-callback.cjs +1 -1
  62. package/dist/oauth/use-oauth-callback.cjs.map +1 -1
  63. package/dist/oauth/use-oauth-callback.js +13 -20
  64. package/dist/oauth/use-oauth-callback.js.map +1 -1
  65. package/dist/push/use-push-subscription.cjs +1 -1
  66. package/dist/push/use-push-subscription.cjs.map +1 -1
  67. package/dist/push/use-push-subscription.js +42 -42
  68. package/dist/push/use-push-subscription.js.map +1 -1
  69. package/dist/push/web-push-client.cjs +1 -1
  70. package/dist/push/web-push-client.cjs.map +1 -1
  71. package/dist/push/web-push-client.js +23 -3
  72. package/dist/push/web-push-client.js.map +1 -1
  73. package/dist/query/offline-persistence.cjs +1 -1
  74. package/dist/query/offline-persistence.cjs.map +1 -1
  75. package/dist/query/offline-persistence.js +68 -23
  76. package/dist/query/offline-persistence.js.map +1 -1
  77. package/dist/styles/component/Toast.css +6 -1
  78. package/dist/styles/feedback.css +6 -1
  79. package/dist/styles.css +1 -1
  80. package/dist/sw/background-sync.cjs +1 -1
  81. package/dist/sw/background-sync.cjs.map +1 -1
  82. package/dist/sw/background-sync.js +271 -60
  83. package/dist/sw/background-sync.js.map +1 -1
  84. package/dist/sw/cache-inspect.cjs.map +1 -1
  85. package/dist/sw/cache-inspect.js.map +1 -1
  86. package/dist/sw/cache.cjs +1 -1
  87. package/dist/sw/cache.cjs.map +1 -1
  88. package/dist/sw/cache.js +91 -64
  89. package/dist/sw/cache.js.map +1 -1
  90. package/dist/sw/credential-headers.cjs +2 -0
  91. package/dist/sw/credential-headers.cjs.map +1 -0
  92. package/dist/sw/credential-headers.js +17 -0
  93. package/dist/sw/credential-headers.js.map +1 -0
  94. package/dist/sw/session-data.cjs +2 -0
  95. package/dist/sw/session-data.cjs.map +1 -0
  96. package/dist/sw/session-data.js +17 -0
  97. package/dist/sw/session-data.js.map +1 -0
  98. package/dist/sw.cjs +1 -1
  99. package/dist/sw.d.ts +271 -23
  100. package/dist/sw.js +7 -5
  101. package/dist/telemetry/app-error-owner.cjs +2 -0
  102. package/dist/telemetry/app-error-owner.cjs.map +1 -0
  103. package/dist/telemetry/app-error-owner.js +18 -0
  104. package/dist/telemetry/app-error-owner.js.map +1 -0
  105. package/dist/telemetry/app-error-queue.cjs +1 -1
  106. package/dist/telemetry/app-error-queue.cjs.map +1 -1
  107. package/dist/telemetry/app-error-queue.js +19 -14
  108. package/dist/telemetry/app-error-queue.js.map +1 -1
  109. package/dist/telemetry/app-error-reporter.cjs +1 -1
  110. package/dist/telemetry/app-error-reporter.cjs.map +1 -1
  111. package/dist/telemetry/app-error-reporter.js +75 -34
  112. package/dist/telemetry/app-error-reporter.js.map +1 -1
  113. package/dist/telemetry/app-error-transport.cjs +1 -1
  114. package/dist/telemetry/app-error-transport.cjs.map +1 -1
  115. package/dist/telemetry/app-error-transport.js +16 -3
  116. package/dist/telemetry/app-error-transport.js.map +1 -1
  117. package/dist/tempest-react-sdk.cjs +1 -1
  118. package/dist/tempest-react-sdk.d.ts +979 -62
  119. package/dist/tempest-react-sdk.js +160 -156
  120. package/dist/utils/csv.cjs +3 -3
  121. package/dist/utils/csv.cjs.map +1 -1
  122. package/dist/utils/csv.js +16 -13
  123. package/dist/utils/csv.js.map +1 -1
  124. package/dist/utils/safe-url.cjs +2 -0
  125. package/dist/utils/safe-url.cjs.map +1 -0
  126. package/dist/utils/safe-url.js +39 -0
  127. package/dist/utils/safe-url.js.map +1 -0
  128. package/dist/vite/tempest-csp.cjs +2 -2
  129. package/dist/vite/tempest-csp.cjs.map +1 -1
  130. package/dist/vite/tempest-csp.js +118 -63
  131. package/dist/vite/tempest-csp.js.map +1 -1
  132. package/dist/vite.d.ts +21 -5
  133. package/dist/webrtc/peer-link.cjs +1 -1
  134. package/dist/webrtc/peer-link.cjs.map +1 -1
  135. package/dist/webrtc/peer-link.js +2 -10
  136. package/dist/webrtc/peer-link.js.map +1 -1
  137. package/dist/webrtc/peer-mesh.cjs +1 -1
  138. package/dist/webrtc/peer-mesh.cjs.map +1 -1
  139. package/dist/webrtc/peer-mesh.js +110 -72
  140. package/dist/webrtc/peer-mesh.js.map +1 -1
  141. package/package.json +11 -1
  142. package/template-pwa/src/pwa.tsx +22 -0
  143. package/template-pwa/src/sw.ts +27 -14
  144. package/dist/components/Markdown/markdown-url.cjs +0 -2
  145. package/dist/components/Markdown/markdown-url.cjs.map +0 -1
  146. package/dist/components/Markdown/markdown-url.js +0 -28
  147. package/dist/components/Markdown/markdown-url.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-parse.js","names":[],"sources":["../../../src/components/Markdown/markdown-parse.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines, function-lines — a Markdown block parser is a state\n * machine over line kinds: paragraph, heading, fence, list, quote, table and\n * thematic break each need to see the lines around them to know where they end.\n * parseBlocks is that loop, and cutting it into per-kind functions would hand each\n * one the same lookahead cursor.\n */\n// A small Markdown parser for the subset an app actually renders from untrusted\n// text: comments, ticket bodies, release notes, a product description.\n//\n// It produces a node tree, never an HTML string, and the renderer turns that into\n// React elements. No `dangerouslySetInnerHTML` exists anywhere in this component —\n// which is the property that makes rendering somebody else's Markdown safe, and it\n// is structural rather than a promise about escaping.\n//\n// Raw HTML in the input is therefore not \"sanitized\", it is **text**: `<script>` in\n// a comment renders as the four characters somebody typed. That is the whole point,\n// and it is also the documented limit — this is not a CommonMark implementation and\n// does not try to be.\n\nimport { safeImageUrl, safeLinkUrl } from \"./markdown-url\";\n\n/** Inline content. */\nexport type MarkdownInline =\n | { type: \"text\"; value: string }\n | { type: \"strong\"; children: MarkdownInline[] }\n | { type: \"em\"; children: MarkdownInline[] }\n | { type: \"del\"; children: MarkdownInline[] }\n | { type: \"code\"; value: string }\n | { type: \"link\"; href: string; children: MarkdownInline[] }\n | { type: \"image\"; src: string; alt: string }\n | { type: \"break\" };\n\n/** Column alignment of a table, from the delimiter row. */\nexport type MarkdownAlign = \"left\" | \"center\" | \"right\" | null;\n\n/** Block content. */\nexport type MarkdownBlock =\n | { type: \"heading\"; level: number; children: MarkdownInline[] }\n | { type: \"paragraph\"; children: MarkdownInline[] }\n | { type: \"code\"; language: string | null; value: string }\n | { type: \"quote\"; children: MarkdownBlock[] }\n | { type: \"list\"; ordered: boolean; start: number; items: MarkdownBlock[][] }\n | {\n type: \"table\";\n align: MarkdownAlign[];\n head: MarkdownInline[][];\n rows: MarkdownInline[][][];\n }\n | { type: \"rule\" };\n\nconst FENCE = /^\\s{0,3}(`{3,}|~{3,})\\s*([\\w+-]*)\\s*$/;\nconst HEADING = /^\\s{0,3}(#{1,6})\\s+(.*?)\\s*#*\\s*$/;\nconst RULE = /^\\s{0,3}([-*_])\\s*(?:\\1\\s*){2,}$/;\nconst QUOTE = /^\\s{0,3}>\\s?(.*)$/;\nconst BULLET = /^(\\s*)([-*+])\\s+(.*)$/;\nconst ORDERED = /^(\\s*)(\\d{1,9})[.)]\\s+(.*)$/;\nconst HARD_BREAK = / {2,}$/;\n/**\n * A table's delimiter row.\n *\n * The `|` is required somewhere in the line, and that is what tells a one-column\n * table (`| --- |`) apart from a thematic break (`---`) — a single column is a\n * legitimate table, and the first version of this regex demanded two.\n */\nconst TABLE_DELIMITER = /^\\s{0,3}\\|[\\s|:-]*$|^\\s{0,3}:?-+:?(\\s*\\|\\s*:?-+:?)+\\s*\\|?\\s*$/;\n\n/**\n * Parse a Markdown document into blocks.\n *\n * @param source - Raw Markdown.\n * @returns Block nodes in document order.\n */\nexport function parseMarkdown(source: string): MarkdownBlock[] {\n const lines = source.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n return parseBlocks(lines);\n}\n\n/** Parse a run of lines into blocks. */\nfunction parseBlocks(lines: string[]): MarkdownBlock[] {\n const blocks: MarkdownBlock[] = [];\n let i = 0;\n\n while (i < lines.length) {\n const line = lines[i];\n\n if (line.trim() === \"\") {\n i += 1;\n continue;\n }\n\n const fence = FENCE.exec(line);\n if (fence) {\n const marker = fence[1][0];\n const body: string[] = [];\n i += 1;\n while (i < lines.length && !new RegExp(`^\\\\s{0,3}${marker}{3,}\\\\s*$`).test(lines[i])) {\n body.push(lines[i]);\n i += 1;\n }\n // An unterminated fence still yields a code block: the alternative is to\n // render the rest of the document as prose full of backticks.\n i += 1;\n blocks.push({ type: \"code\", language: fence[2] || null, value: body.join(\"\\n\") });\n continue;\n }\n\n const heading = HEADING.exec(line);\n if (heading) {\n blocks.push({\n type: \"heading\",\n level: heading[1].length,\n children: parseInline(heading[2]),\n });\n i += 1;\n continue;\n }\n\n if (RULE.test(line)) {\n blocks.push({ type: \"rule\" });\n i += 1;\n continue;\n }\n\n if (QUOTE.test(line)) {\n const inner: string[] = [];\n while (i < lines.length) {\n const match = QUOTE.exec(lines[i]);\n if (match) {\n inner.push(match[1]);\n i += 1;\n continue;\n }\n // A blank line ends the quote; a plain line continues it (lazy\n // continuation), which is how people actually write quotes.\n if (lines[i].trim() === \"\") break;\n inner.push(lines[i]);\n i += 1;\n }\n blocks.push({ type: \"quote\", children: parseBlocks(inner) });\n continue;\n }\n\n if (BULLET.test(line) || ORDERED.test(line)) {\n const [list, next] = parseList(lines, i);\n blocks.push(list);\n i = next;\n continue;\n }\n\n if (i + 1 < lines.length && line.includes(\"|\") && TABLE_DELIMITER.test(lines[i + 1])) {\n const [table, next] = parseTable(lines, i);\n blocks.push(table);\n i = next;\n continue;\n }\n\n const paragraph: string[] = [];\n const hardBreaks: boolean[] = [];\n while (i < lines.length && lines[i].trim() !== \"\") {\n const current = lines[i];\n if (\n HEADING.test(current) ||\n RULE.test(current) ||\n FENCE.test(current) ||\n QUOTE.test(current) ||\n BULLET.test(current) ||\n ORDERED.test(current)\n ) {\n break;\n }\n paragraph.push(current.trim());\n hardBreaks.push(HARD_BREAK.test(current));\n i += 1;\n }\n if (paragraph.length > 0) {\n blocks.push({\n type: \"paragraph\",\n children: parseInline(joinParagraph(paragraph, hardBreaks)),\n });\n }\n }\n\n return blocks;\n}\n\n/**\n * Re-join the lines of a paragraph, keeping the two-space hard break.\n *\n * Every line is trimmed before it is parsed, because leading indentation is not\n * content and a trailing space is invisible noise in almost every line. The one\n * exception is the CommonMark hard break: two or more trailing spaces mean\n * \"break the line here\", so trimming first would delete the only mark that says\n * so and the ` \\n` inline rule could never match. The flag is recorded before\n * the trim and the marker put back here, on every line but the last — a break\n * after the final line of a paragraph would break into nothing.\n *\n * @param lines - The trimmed lines, in order.\n * @param hardBreaks - Whether each line ended in two or more spaces.\n * @returns The paragraph source the inline parser reads.\n */\nfunction joinParagraph(lines: readonly string[], hardBreaks: readonly boolean[]): string {\n return lines\n .map((line, index) => (hardBreaks[index] && index < lines.length - 1 ? `${line} ` : line))\n .join(\"\\n\");\n}\n\n/**\n * Parse a list, including nested lists and multi-line items.\n *\n * Nesting is decided by indentation relative to the **first** item's marker, so a\n * list indented inside a quote or another list still reads correctly.\n *\n * @returns The list node and the index of the first line after it.\n */\nfunction parseList(lines: string[], start: number): [MarkdownBlock, number] {\n const bulletStart = BULLET.exec(lines[start]);\n const orderedStart = ORDERED.exec(lines[start]);\n // The two markers are mutually exclusive — `-*+` versus digits — so whichever\n // matched decides the list kind.\n const ordered = orderedStart !== null;\n const first = orderedStart ?? bulletStart;\n const baseIndent = (first?.[1] ?? \"\").length;\n const startNumber = ordered ? Number(orderedStart?.[2] ?? 1) : 1;\n\n const items: MarkdownBlock[][] = [];\n let buffer: string[] = [];\n let i = start;\n\n const flush = (): void => {\n if (buffer.length === 0) return;\n items.push(parseBlocks(buffer));\n buffer = [];\n };\n\n while (i < lines.length) {\n const line = lines[i];\n if (line.trim() === \"\") {\n // A single blank line inside a list is a loose item, not the end. Two in\n // a row end it, which is what a blank-then-paragraph document means.\n if (i + 1 < lines.length && lines[i + 1].trim() !== \"\") {\n buffer.push(\"\");\n i += 1;\n continue;\n }\n break;\n }\n const bullet = BULLET.exec(line);\n const numbered = ORDERED.exec(line);\n const match = bullet ?? numbered;\n\n if (match && match[1].length <= baseIndent) {\n const sameKind = ordered ? Boolean(numbered) : Boolean(bullet);\n if (!sameKind) break;\n flush();\n buffer.push(match[3]);\n i += 1;\n continue;\n }\n if (match) {\n // Deeper marker: keep the indentation so the recursive call sees a list.\n buffer.push(line.slice(baseIndent));\n i += 1;\n continue;\n }\n if (line.search(/\\S/) > baseIndent) {\n buffer.push(line.trim());\n i += 1;\n continue;\n }\n break;\n }\n flush();\n\n return [{ type: \"list\", ordered, start: startNumber, items }, i];\n}\n\n/** Split a table row on unescaped pipes. */\nfunction splitRow(line: string): string[] {\n const trimmed = line.trim().replace(/^\\|/, \"\").replace(/\\|$/, \"\");\n const cells: string[] = [];\n let current = \"\";\n for (let i = 0; i < trimmed.length; i += 1) {\n if (trimmed[i] === \"\\\\\" && trimmed[i + 1] === \"|\") {\n current += \"|\";\n i += 1;\n continue;\n }\n if (trimmed[i] === \"|\") {\n cells.push(current);\n current = \"\";\n continue;\n }\n current += trimmed[i];\n }\n cells.push(current);\n return cells.map((cell) => cell.trim());\n}\n\n/**\n * Parse a GFM pipe table.\n *\n * @returns The table node and the index of the first line after it.\n */\nfunction parseTable(lines: string[], start: number): [MarkdownBlock, number] {\n const head = splitRow(lines[start]);\n const align: MarkdownAlign[] = splitRow(lines[start + 1]).map((cell) => {\n const left = cell.startsWith(\":\");\n const right = cell.endsWith(\":\");\n if (left && right) return \"center\";\n if (right) return \"right\";\n if (left) return \"left\";\n return null;\n });\n\n const rows: MarkdownInline[][][] = [];\n let i = start + 2;\n while (i < lines.length && lines[i].trim() !== \"\" && lines[i].includes(\"|\")) {\n rows.push(splitRow(lines[i]).map(parseInline));\n i += 1;\n }\n\n return [{ type: \"table\", align, head: head.map(parseInline), rows }, i];\n}\n\n/** Inline delimiters, longest marker first so `**` wins over `*`. */\nconst INLINE_RULES: Array<{\n pattern: RegExp;\n build: (match: RegExpExecArray) => MarkdownInline | null;\n}> = [\n {\n pattern: /^!\\[([^\\]]*)\\]\\(((?:[^()\\s]|\\([^()\\s]*\\))+)(?:\\s+\"[^\"]*\")?\\)/,\n build: (match) => {\n const src = safeImageUrl(match[2]);\n return src ? { type: \"image\", src, alt: match[1] } : { type: \"text\", value: match[1] };\n },\n },\n {\n pattern: /^\\[([^\\]]*)\\]\\(((?:[^()\\s]|\\([^()\\s]*\\))+)(?:\\s+\"[^\"]*\")?\\)/,\n build: (match) => {\n const href = safeLinkUrl(match[2]);\n const children = parseInline(match[1]);\n // A rejected URL keeps the label as plain text: dropping the text too\n // would silently delete words somebody wrote.\n return href ? { type: \"link\", href, children } : { type: \"text\", value: match[1] };\n },\n },\n { pattern: /^`([^`]+)`/, build: (match) => ({ type: \"code\", value: match[1] }) },\n {\n pattern: /^\\*\\*([\\s\\S]+?)\\*\\*/,\n build: (match) => ({ type: \"strong\", children: parseInline(match[1]) }),\n },\n {\n pattern: /^__([\\s\\S]+?)__/,\n build: (match) => ({ type: \"strong\", children: parseInline(match[1]) }),\n },\n {\n pattern: /^~~([\\s\\S]+?)~~/,\n build: (match) => ({ type: \"del\", children: parseInline(match[1]) }),\n },\n {\n pattern: /^\\*([^*\\n]+)\\*/,\n build: (match) => ({ type: \"em\", children: parseInline(match[1]) }),\n },\n {\n pattern: /^_([^_\\n]+)_/,\n build: (match) => ({ type: \"em\", children: parseInline(match[1]) }),\n },\n {\n pattern: /^<((?:https?:\\/\\/|mailto:)[^>\\s]+)>/,\n build: (match) => {\n const href = safeLinkUrl(match[1]);\n return href\n ? { type: \"link\", href, children: [{ type: \"text\", value: match[1] }] }\n : { type: \"text\", value: match[1] };\n },\n },\n { pattern: /^ {2,}\\n/, build: () => ({ type: \"break\" }) },\n { pattern: /^\\\\\\n/, build: () => ({ type: \"break\" }) },\n];\n\n/**\n * Parse inline Markdown.\n *\n * A backslash escapes the next character, so `\\*not italic\\*` renders with the\n * asterisks. Anything that matches no rule is text — an unclosed `**` is two\n * asterisks, not a bold run to the end of the paragraph.\n *\n * @param source - One block's text.\n * @returns Inline nodes.\n */\nexport function parseInline(source: string): MarkdownInline[] {\n const nodes: MarkdownInline[] = [];\n let text = \"\";\n let i = 0;\n\n const flush = (): void => {\n if (text) nodes.push({ type: \"text\", value: text });\n text = \"\";\n };\n\n while (i < source.length) {\n if (source[i] === \"\\\\\" && i + 1 < source.length && source[i + 1] !== \"\\n\") {\n text += source[i + 1];\n i += 2;\n continue;\n }\n\n const rest = source.slice(i);\n let matched = false;\n for (const rule of INLINE_RULES) {\n const match = rule.pattern.exec(rest);\n if (!match) continue;\n const node = rule.build(match);\n if (!node) continue;\n flush();\n nodes.push(node);\n i += match[0].length;\n matched = true;\n break;\n }\n if (matched) continue;\n\n text += source[i];\n i += 1;\n }\n\n flush();\n return nodes;\n}\n"],"mappings":";;AAmDA,IAAM,IAAQ,yCACR,IAAU,qCACV,IAAO,oCACP,IAAQ,qBACR,IAAS,yBACT,IAAU,+BACV,IAAa,UAQb,IAAkB;AA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,EAAO,IAAI,OAAO,MAAM;GAEvE,AADA,KAAQ,EAAO,IAAI,IACnB,KAAK;GACL;EACJ;EAEA,IAAM,IAAO,EAAO,MAAM,CAAC,GACvB,IAAU;EACd,KAAK,IAAM,KAAQ,GAAc;GAC7B,IAAM,IAAQ,EAAK,QAAQ,KAAK,CAAI;GACpC,IAAI,CAAC,GAAO;GACZ,IAAM,IAAO,EAAK,MAAM,CAAK;GACxB,OAIL;IAHA,EAAM,GACN,EAAM,KAAK,CAAI,GACf,KAAK,EAAM,EAAE,CAAC,QACd,IAAU;IACV;GADU;EAEd;EACI,MAEJ,KAAQ,EAAO,IACf,KAAK;CACT;CAGA,OADA,EAAM,GACC;AACX"}
1
+ {"version":3,"file":"markdown-parse.js","names":[],"sources":["../../../src/components/Markdown/markdown-parse.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines, function-lines — a Markdown block parser is a state\n * machine over line kinds: paragraph, heading, fence, list, quote, table and\n * thematic break each need to see the lines around them to know where they end.\n * parseBlocks is that loop, and cutting it into per-kind functions would hand each\n * one the same lookahead cursor.\n */\n// A small Markdown parser for the subset an app actually renders from untrusted\n// text: comments, ticket bodies, release notes, a product description.\n//\n// It produces a node tree, never an HTML string, and the renderer turns that into\n// React elements. No `dangerouslySetInnerHTML` exists anywhere in this component —\n// which is the property that makes rendering somebody else's Markdown safe, and it\n// is structural rather than a promise about escaping.\n//\n// Raw HTML in the input is therefore not \"sanitized\", it is **text**: `<script>` in\n// a comment renders as the four characters somebody typed. That is the whole point,\n// and it is also the documented limit — this is not a CommonMark implementation and\n// does not try to be.\n\nimport { safeImageUrl, safeLinkUrl } from \"@/utils/safe-url\";\n\n/** Inline content. */\nexport type MarkdownInline =\n | { type: \"text\"; value: string }\n | { type: \"strong\"; children: MarkdownInline[] }\n | { type: \"em\"; children: MarkdownInline[] }\n | { type: \"del\"; children: MarkdownInline[] }\n | { type: \"code\"; value: string }\n | { type: \"link\"; href: string; children: MarkdownInline[] }\n | { type: \"image\"; src: string; alt: string }\n | { type: \"break\" };\n\n/** Column alignment of a table, from the delimiter row. */\nexport type MarkdownAlign = \"left\" | \"center\" | \"right\" | null;\n\n/** Block content. */\nexport type MarkdownBlock =\n | { type: \"heading\"; level: number; children: MarkdownInline[] }\n | { type: \"paragraph\"; children: MarkdownInline[] }\n | { type: \"code\"; language: string | null; value: string }\n | { type: \"quote\"; children: MarkdownBlock[] }\n | { type: \"list\"; ordered: boolean; start: number; items: MarkdownBlock[][] }\n | {\n type: \"table\";\n align: MarkdownAlign[];\n head: MarkdownInline[][];\n rows: MarkdownInline[][][];\n }\n | { type: \"rule\" };\n\n/**\n * A fence opener, matched against the line **after** `trimEnd()`.\n *\n * The trailing `\\s*` lives in the `trimEnd()` rather than in the pattern: with it,\n * `\\s*([\\w+-]*)\\s*$` is two whitespace quantifiers separated by one that may be\n * empty, and a fence followed by 20 000 spaces and a stray `!` took 0.36 s (#437).\n */\nconst FENCE = /^\\s{0,3}(`{3,}|~{3,})\\s*([\\w+-]*)$/;\n/**\n * The opening marker of an ATX heading. The text and the optional closing `#` run\n * are cut by {@link matchHeading} with string operations, not by this pattern.\n */\nconst HEADING_OPEN = /^\\s{0,3}(#{1,6})\\s+/;\nconst RULE = /^\\s{0,3}([-*_])\\s*(?:\\1\\s*){2,}$/;\nconst QUOTE = /^\\s{0,3}>\\s?(.*)$/;\nconst BULLET = /^(\\s*)([-*+])\\s+(.*)$/;\nconst ORDERED = /^(\\s*)(\\d{1,9})[.)]\\s+(.*)$/;\n/**\n * A table's delimiter row, matched against the line **after** `trimEnd()`.\n *\n * The `|` is required somewhere in the line, and that is what tells a one-column\n * table (`| --- |`) apart from a thematic break (`---`) — a single column is a\n * legitimate table, and the first version of this regex demanded two. The trailing\n * whitespace is trimmed before the test for the same reason as {@link FENCE}: a\n * `\\s*\\|?\\s*$` tail backtracked quadratically on `- |` plus 50 000 spaces (#437).\n */\nconst TABLE_DELIMITER = /^\\s{0,3}\\|[\\s|:-]*$|^\\s{0,3}:?-+:?(\\s*\\|\\s*:?-+:?)+\\s*\\|?$/;\n\n/**\n * How deep quotes and lists may nest before the rest is read as a paragraph.\n *\n * Each level is one recursive {@link parseBlocks} call and one nested element in\n * the render, so `\"- \".repeat(20000)` used to throw `RangeError: Maximum call stack\n * size exceeded` out of the component (#437). Real documents stop at a handful of\n * levels; past this cap the words are kept, only the nesting is dropped.\n */\nconst MAX_NESTING_DEPTH = 32;\n\n/**\n * Match an ATX heading in linear time.\n *\n * The regex this replaces, `/^\\s{0,3}(#{1,6})\\s+(.*?)\\s*#*\\s*$/`, let a lazy `.*?`\n * and two `\\s*` race for the same run of spaces: `\"# a\" + \" \".repeat(4000) + \"b\"`\n * took about 4.7 s, cubic in the run (#437). Only the opening marker is a regex\n * now. The text is the rest of the line minus the longest suffix shaped like\n * `\\s*#*\\s*` — exactly what the lazy group left behind, so `# título #`,\n * `# título#` and `# #` read as before.\n *\n * @param line - One source line.\n * @returns The level and raw text, or `null` when the line is not a heading.\n */\nfunction matchHeading(line: string): { level: number; text: string } | null {\n const open = HEADING_OPEN.exec(line);\n if (!open) return null;\n let text = line.slice(open[0].length).trimEnd();\n let end = text.length;\n while (end > 0 && text[end - 1] === \"#\") end -= 1;\n text = text.slice(0, end).trimEnd();\n return { level: open[1].length, text };\n}\n\n/**\n * Whether a paragraph line ends in a hard break: two or more trailing spaces.\n *\n * `/ {2,}$/` was quadratic on a line with a long inner run of spaces — it retried\n * the run from every space and failed at the next word each time (0.57 s for\n * 50 000 spaces, #437).\n */\nfunction endsWithHardBreak(line: string): boolean {\n return line.endsWith(\" \");\n}\n\n/**\n * Parse a Markdown document into blocks.\n *\n * @param source - Raw Markdown.\n * @returns Block nodes in document order.\n */\nexport function parseMarkdown(source: string): MarkdownBlock[] {\n const lines = source.replace(/\\r\\n?/g, \"\\n\").split(\"\\n\");\n return parseBlocks(lines, 0);\n}\n\n/**\n * Parse a run of lines into blocks.\n *\n * @param lines - The lines of this container.\n * @param depth - How many quotes and lists enclose them. At\n * {@link MAX_NESTING_DEPTH} the lines become one paragraph instead of more\n * containers, so a hostile document cannot exhaust the stack.\n * @returns The blocks.\n */\nfunction parseBlocks(lines: string[], depth: number): MarkdownBlock[] {\n if (depth >= MAX_NESTING_DEPTH) {\n const source = lines\n .map((line) => line.trim())\n .filter(Boolean)\n .join(\"\\n\");\n return source ? [{ type: \"paragraph\", children: parseInline(source) }] : [];\n }\n const blocks: MarkdownBlock[] = [];\n let i = 0;\n\n while (i < lines.length) {\n const line = lines[i];\n\n if (line.trim() === \"\") {\n i += 1;\n continue;\n }\n\n const fence = FENCE.exec(line.trimEnd());\n if (fence) {\n const marker = fence[1][0];\n const body: string[] = [];\n i += 1;\n while (i < lines.length && !new RegExp(`^\\\\s{0,3}${marker}{3,}\\\\s*$`).test(lines[i])) {\n body.push(lines[i]);\n i += 1;\n }\n // An unterminated fence still yields a code block: the alternative is to\n // render the rest of the document as prose full of backticks.\n i += 1;\n blocks.push({ type: \"code\", language: fence[2] || null, value: body.join(\"\\n\") });\n continue;\n }\n\n const heading = matchHeading(line);\n if (heading) {\n blocks.push({\n type: \"heading\",\n level: heading.level,\n children: parseInline(heading.text),\n });\n i += 1;\n continue;\n }\n\n if (RULE.test(line)) {\n blocks.push({ type: \"rule\" });\n i += 1;\n continue;\n }\n\n if (QUOTE.test(line)) {\n const inner: string[] = [];\n while (i < lines.length) {\n const match = QUOTE.exec(lines[i]);\n if (match) {\n inner.push(match[1]);\n i += 1;\n continue;\n }\n // A blank line ends the quote; a plain line continues it (lazy\n // continuation), which is how people actually write quotes.\n if (lines[i].trim() === \"\") break;\n inner.push(lines[i]);\n i += 1;\n }\n blocks.push({ type: \"quote\", children: parseBlocks(inner, depth + 1) });\n continue;\n }\n\n if (BULLET.test(line) || ORDERED.test(line)) {\n const [list, next] = parseList(lines, i, depth);\n blocks.push(list);\n i = next;\n continue;\n }\n\n if (\n i + 1 < lines.length &&\n line.includes(\"|\") &&\n TABLE_DELIMITER.test(lines[i + 1].trimEnd())\n ) {\n const [table, next] = parseTable(lines, i);\n blocks.push(table);\n i = next;\n continue;\n }\n\n const paragraph: string[] = [];\n const hardBreaks: boolean[] = [];\n while (i < lines.length && lines[i].trim() !== \"\") {\n const current = lines[i];\n if (\n matchHeading(current) ||\n RULE.test(current) ||\n FENCE.test(current.trimEnd()) ||\n QUOTE.test(current) ||\n BULLET.test(current) ||\n ORDERED.test(current)\n ) {\n break;\n }\n paragraph.push(current.trim());\n hardBreaks.push(endsWithHardBreak(current));\n i += 1;\n }\n if (paragraph.length > 0) {\n blocks.push({\n type: \"paragraph\",\n children: parseInline(joinParagraph(paragraph, hardBreaks)),\n });\n }\n }\n\n return blocks;\n}\n\n/**\n * Re-join the lines of a paragraph, keeping the two-space hard break.\n *\n * Every line is trimmed before it is parsed, because leading indentation is not\n * content and a trailing space is invisible noise in almost every line. The one\n * exception is the CommonMark hard break: two or more trailing spaces mean\n * \"break the line here\", so trimming first would delete the only mark that says\n * so and the ` \\n` inline rule could never match. The flag is recorded before\n * the trim and the marker put back here, on every line but the last — a break\n * after the final line of a paragraph would break into nothing.\n *\n * @param lines - The trimmed lines, in order.\n * @param hardBreaks - Whether each line ended in two or more spaces.\n * @returns The paragraph source the inline parser reads.\n */\nfunction joinParagraph(lines: readonly string[], hardBreaks: readonly boolean[]): string {\n return lines\n .map((line, index) => (hardBreaks[index] && index < lines.length - 1 ? `${line} ` : line))\n .join(\"\\n\");\n}\n\n/**\n * Parse a list, including nested lists and multi-line items.\n *\n * Nesting is decided by indentation relative to the **first** item's marker, so a\n * list indented inside a quote or another list still reads correctly.\n *\n * @param lines - The lines of the enclosing container.\n * @param start - Index of the first item's line.\n * @param depth - Nesting depth of the enclosing container.\n * @returns The list node and the index of the first line after it.\n */\nfunction parseList(lines: string[], start: number, depth: number): [MarkdownBlock, number] {\n const bulletStart = BULLET.exec(lines[start]);\n const orderedStart = ORDERED.exec(lines[start]);\n // The two markers are mutually exclusive — `-*+` versus digits — so whichever\n // matched decides the list kind.\n const ordered = orderedStart !== null;\n const first = orderedStart ?? bulletStart;\n const baseIndent = (first?.[1] ?? \"\").length;\n const startNumber = ordered ? Number(orderedStart?.[2] ?? 1) : 1;\n\n const items: MarkdownBlock[][] = [];\n let buffer: string[] = [];\n let i = start;\n\n const flush = (): void => {\n if (buffer.length === 0) return;\n items.push(parseBlocks(buffer, depth + 1));\n buffer = [];\n };\n\n while (i < lines.length) {\n const line = lines[i];\n if (line.trim() === \"\") {\n // A single blank line inside a list is a loose item, not the end. Two in\n // a row end it, which is what a blank-then-paragraph document means.\n if (i + 1 < lines.length && lines[i + 1].trim() !== \"\") {\n buffer.push(\"\");\n i += 1;\n continue;\n }\n break;\n }\n const bullet = BULLET.exec(line);\n const numbered = ORDERED.exec(line);\n const match = bullet ?? numbered;\n\n if (match && match[1].length <= baseIndent) {\n const sameKind = ordered ? Boolean(numbered) : Boolean(bullet);\n if (!sameKind) break;\n flush();\n buffer.push(match[3]);\n i += 1;\n continue;\n }\n if (match) {\n // Deeper marker: keep the indentation so the recursive call sees a list.\n buffer.push(line.slice(baseIndent));\n i += 1;\n continue;\n }\n if (line.search(/\\S/) > baseIndent) {\n buffer.push(line.trim());\n i += 1;\n continue;\n }\n break;\n }\n flush();\n\n return [{ type: \"list\", ordered, start: startNumber, items }, i];\n}\n\n/** Split a table row on unescaped pipes. */\nfunction splitRow(line: string): string[] {\n const trimmed = line.trim().replace(/^\\|/, \"\").replace(/\\|$/, \"\");\n const cells: string[] = [];\n let current = \"\";\n for (let i = 0; i < trimmed.length; i += 1) {\n if (trimmed[i] === \"\\\\\" && trimmed[i + 1] === \"|\") {\n current += \"|\";\n i += 1;\n continue;\n }\n if (trimmed[i] === \"|\") {\n cells.push(current);\n current = \"\";\n continue;\n }\n current += trimmed[i];\n }\n cells.push(current);\n return cells.map((cell) => cell.trim());\n}\n\n/**\n * Parse a GFM pipe table.\n *\n * @returns The table node and the index of the first line after it.\n */\nfunction parseTable(lines: string[], start: number): [MarkdownBlock, number] {\n const head = splitRow(lines[start]);\n const align: MarkdownAlign[] = splitRow(lines[start + 1]).map((cell) => {\n const left = cell.startsWith(\":\");\n const right = cell.endsWith(\":\");\n if (left && right) return \"center\";\n if (right) return \"right\";\n if (left) return \"left\";\n return null;\n });\n\n const rows: MarkdownInline[][][] = [];\n let i = start + 2;\n while (i < lines.length && lines[i].trim() !== \"\" && lines[i].includes(\"|\")) {\n rows.push(splitRow(lines[i]).map(parseInline));\n i += 1;\n }\n\n return [{ type: \"table\", align, head: head.map(parseInline), rows }, i];\n}\n\n/**\n * The precheck a rule needs before its pattern may run, keyed by the opener the\n * pattern starts with.\n *\n * `link` covers links and images, whose label ends at the first `]`; `autolink`\n * covers `<scheme:...>`, which ends at the first `>` or whitespace. Without the\n * precheck each pattern scanned to the end of the text from every opener, and\n * `\"[\".repeat(50000)` took 0.6 s (#437).\n */\ntype InlineGuard = { kind: \"link\"; opener: \"[\" | \"![\" } | { kind: \"autolink\"; opener: \"<\" };\n\n/** Inline delimiters, longest marker first so `**` wins over `*`. */\nconst INLINE_RULES: Array<{\n first: string;\n pattern: RegExp;\n guard?: InlineGuard;\n build: (match: RegExpExecArray) => MarkdownInline | null;\n}> = [\n {\n guard: { kind: \"link\", opener: \"![\" },\n first: \"!\",\n pattern: /^!\\[([^\\]]*)\\]\\(((?:[^()\\s]|\\([^()\\s]*\\))+)(?:\\s+\"[^\"]*\")?\\)/,\n build: (match) => {\n const src = safeImageUrl(match[2]);\n return src ? { type: \"image\", src, alt: match[1] } : { type: \"text\", value: match[1] };\n },\n },\n {\n guard: { kind: \"link\", opener: \"[\" },\n first: \"[\",\n pattern: /^\\[([^\\]]*)\\]\\(((?:[^()\\s]|\\([^()\\s]*\\))+)(?:\\s+\"[^\"]*\")?\\)/,\n build: (match) => {\n const href = safeLinkUrl(match[2]);\n const children = parseInline(match[1]);\n // A rejected URL keeps the label as plain text: dropping the text too\n // would silently delete words somebody wrote.\n return href ? { type: \"link\", href, children } : { type: \"text\", value: match[1] };\n },\n },\n { first: \"`\", pattern: /^`([^`]+)`/, build: (match) => ({ type: \"code\", value: match[1] }) },\n {\n first: \"*\",\n pattern: /^\\*\\*([\\s\\S]+?)\\*\\*/,\n build: (match) => ({ type: \"strong\", children: parseInline(match[1]) }),\n },\n {\n first: \"_\",\n pattern: /^__([\\s\\S]+?)__/,\n build: (match) => ({ type: \"strong\", children: parseInline(match[1]) }),\n },\n {\n first: \"~\",\n pattern: /^~~([\\s\\S]+?)~~/,\n build: (match) => ({ type: \"del\", children: parseInline(match[1]) }),\n },\n {\n first: \"*\",\n pattern: /^\\*([^*\\n]+)\\*/,\n build: (match) => ({ type: \"em\", children: parseInline(match[1]) }),\n },\n {\n first: \"_\",\n pattern: /^_([^_\\n]+)_/,\n build: (match) => ({ type: \"em\", children: parseInline(match[1]) }),\n },\n {\n guard: { kind: \"autolink\", opener: \"<\" },\n first: \"<\",\n pattern: /^<((?:https?:\\/\\/|mailto:)[^>\\s]+)>/,\n build: (match) => {\n const href = safeLinkUrl(match[1]);\n return href\n ? { type: \"link\", href, children: [{ type: \"text\", value: match[1] }] }\n : { type: \"text\", value: match[1] };\n },\n },\n { first: \"\\\\\", pattern: /^\\\\\\n/, build: () => ({ type: \"break\" }) },\n];\n\n/** Characters some inline rule can start with; any other character is text. */\nconst INLINE_FIRST = new Set(INLINE_RULES.map((rule) => rule.first));\n\n/**\n * Parse inline Markdown.\n *\n * A backslash escapes the next character, so `\\*not italic\\*` renders with the\n * asterisks. Anything that matches no rule is text — an unclosed `**` is two\n * asterisks, not a bold run to the end of the paragraph.\n *\n * The parse is linear in the text, which matters because the text is somebody\n * else's (#437):\n *\n * - A run of spaces is consumed whole: it is a hard break when two or more of them\n * end at a newline, and text otherwise. Matching `^ {2,}\\n` from every space\n * rescanned the run each time.\n * - A link or image label ends at the first `]` after the opener, so every opener\n * before the same `]` shares the same `](...)` tail. The position of that `]` is\n * cached, an opener whose `]` is not followed by `(` is skipped without running\n * the pattern, and once a tail has failed no later opener retries it.\n * - An autolink ends at the first `>` or whitespace, also cached; when that stop\n * is not `>` the pattern cannot match and is not run.\n * - A rule runs only at its own first character, so a run of `[` costs one set\n * lookup per character instead of every pattern in the table.\n *\n * @param source - One block's text.\n * @returns Inline nodes.\n */\nexport function parseInline(source: string): MarkdownInline[] {\n const nodes: MarkdownInline[] = [];\n let text = \"\";\n let i = 0;\n\n let bracketAt = -1;\n let deadTailAt = -1;\n let stopAt = -1;\n const stops = /[>\\s]/g;\n\n const flush = (): void => {\n if (text) nodes.push({ type: \"text\", value: text });\n text = \"\";\n };\n\n const closingBracket = (from: number): number => {\n if (bracketAt < from) {\n const found = source.indexOf(\"]\", from);\n bracketAt = found === -1 ? source.length : found;\n }\n return bracketAt;\n };\n\n const autolinkStop = (from: number): number => {\n if (stopAt < from) {\n stops.lastIndex = from;\n stopAt = stops.exec(source)?.index ?? source.length;\n }\n return stopAt;\n };\n\n const allowed = (guard: InlineGuard | undefined): boolean => {\n if (!guard) return true;\n if (!source.startsWith(guard.opener, i)) return false;\n if (guard.kind === \"autolink\") return source[autolinkStop(i + 1)] === \">\";\n const close = closingBracket(i + guard.opener.length);\n return source[close + 1] === \"(\" && close !== deadTailAt;\n };\n\n while (i < source.length) {\n if (source[i] === \"\\\\\" && i + 1 < source.length && source[i + 1] !== \"\\n\") {\n text += source[i + 1];\n i += 2;\n continue;\n }\n\n if (source[i] === \" \") {\n let end = i;\n while (source[end] === \" \") end += 1;\n if (end - i >= 2 && source[end] === \"\\n\") {\n flush();\n nodes.push({ type: \"break\" });\n i = end + 1;\n } else {\n text += source.slice(i, end);\n i = end;\n }\n continue;\n }\n\n if (!INLINE_FIRST.has(source[i])) {\n text += source[i];\n i += 1;\n continue;\n }\n\n const rest = source.slice(i);\n let matched = false;\n for (const rule of INLINE_RULES) {\n if (rule.first !== source[i] || !allowed(rule.guard)) continue;\n const match = rule.pattern.exec(rest);\n if (!match) {\n if (rule.guard?.kind === \"link\") {\n deadTailAt = closingBracket(i + rule.guard.opener.length);\n }\n continue;\n }\n const node = rule.build(match);\n if (!node) continue;\n flush();\n nodes.push(node);\n i += match[0].length;\n matched = true;\n break;\n }\n if (matched) continue;\n\n text += source[i];\n i += 1;\n }\n\n flush();\n return nodes;\n}\n"],"mappings":";;AA0DA,IAAM,IAAQ,sCAKR,IAAe,uBACf,IAAO,oCACP,IAAQ,qBACR,IAAS,yBACT,IAAU,+BAUV,IAAkB,8DAUlB,IAAoB;AAe1B,SAAS,EAAa,GAAsD;CACxE,IAAM,IAAO,EAAa,KAAK,CAAI;CACnC,IAAI,CAAC,GAAM,OAAO;CAClB,IAAI,IAAO,EAAK,MAAM,EAAK,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,GAC1C,IAAM,EAAK;CACf,OAAO,IAAM,KAAK,EAAK,IAAM,OAAO,MAAK;CAEzC,OADA,IAAO,EAAK,MAAM,GAAG,CAAG,CAAC,CAAC,QAAQ,GAC3B;EAAE,OAAO,EAAK,EAAE,CAAC;EAAQ;CAAK;AACzC;AASA,SAAS,EAAkB,GAAuB;CAC9C,OAAO,EAAK,SAAS,IAAI;AAC7B;AAQA,SAAgB,EAAc,GAAiC;CAE3D,OAAO,EADO,EAAO,QAAQ,UAAU,IAAI,CAAC,CAAC,MAAM,IAChC,GAAO,CAAC;AAC/B;AAWA,SAAS,EAAY,GAAiB,GAAgC;CAClE,IAAI,KAAS,GAAmB;EAC5B,IAAM,IAAS,EACV,KAAK,MAAS,EAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO,CAAC,CACf,KAAK,IAAI;EACd,OAAO,IAAS,CAAC;GAAE,MAAM;GAAa,UAAU,EAAY,CAAM;EAAE,CAAC,IAAI,CAAC;CAC9E;CACA,IAAM,IAA0B,CAAC,GAC7B,IAAI;CAER,OAAO,IAAI,EAAM,SAAQ;EACrB,IAAM,IAAO,EAAM;EAEnB,IAAI,EAAK,KAAK,MAAM,IAAI;GACpB,KAAK;GACL;EACJ;EAEA,IAAM,IAAQ,EAAM,KAAK,EAAK,QAAQ,CAAC;EACv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,IAAI,EAAK,MAAM,OAAO,MAAM;IAE5D;GACJ;GACA,IAAM,IAAO,EAAK,MAAM,CAAK;GACxB,OAIL;IAHA,EAAM,GACN,EAAM,KAAK,CAAI,GACf,KAAK,EAAM,EAAE,CAAC,QACd,IAAU;IACV;GADU;EAEd;EACI,MAEJ,KAAQ,EAAO,IACf,KAAK;CACT;CAGA,OADA,EAAM,GACC;AACX"}
@@ -1,3 +1,3 @@
1
1
  require("../../styles/component/Toast.css");
2
- var e=`tempest_container_x4-Qm`,t=`tempest_positionTopRight_gbUCQ`,n=`tempest_positionTopLeft_Z-tMJ`,r=`tempest_positionTopCenter_A4Ze4`,i=`tempest_positionBottomRight_MGo19`,a=`tempest_positionBottomLeft_DpiNe`,o=`tempest_positionBottomCenter_XUdok`,s=`tempest_toast_FLdHz`,c=`tempest_tempest-toast-in_E2d-A`,l=`tempest_success_Oy694`,u=`tempest_warning_84GC8`,d=`tempest_error_hrQAA`,f=`tempest_info_eq5bQ`,p=`tempest_title_-H6R2`,m=`tempest_description_-QwfC`,h=`tempest_close_i10-s`,g={container:e,positionTopRight:t,positionTopLeft:n,positionTopCenter:r,positionBottomRight:i,positionBottomLeft:a,positionBottomCenter:o,toast:s,tempestToastIn:c,success:l,warning:u,error:d,info:f,title:p,description:m,close:h};exports.close=h,exports.container=e,exports.default=g,exports.description=m,exports.error=d,exports.info=f,exports.positionBottomCenter=o,exports.positionBottomLeft=a,exports.positionBottomRight=i,exports.positionTopCenter=r,exports.positionTopLeft=n,exports.positionTopRight=t,exports.success=l,exports.tempestToastIn=c,exports.title=p,exports.toast=s,exports.warning=u;
2
+ var e=`tempest_container_x4-Qm`,t=`tempest_positionTopRight_gbUCQ`,n=`tempest_positionTopLeft_Z-tMJ`,r=`tempest_positionTopCenter_A4Ze4`,i=`tempest_positionBottomRight_MGo19`,a=`tempest_positionBottomLeft_DpiNe`,o=`tempest_positionBottomCenter_XUdok`,s=`tempest_toast_FLdHz`,c=`tempest_tempest-toast-in_E2d-A`,l=`tempest_success_Oy694`,u=`tempest_warning_84GC8`,d=`tempest_error_hrQAA`,f=`tempest_info_eq5bQ`,p=`tempest_title_-H6R2`,m=`tempest_description_-QwfC`,h=`tempest_content_U6Xwq`,g=`tempest_withIcon_2Z8Sz`,_=`tempest_alignCenter_GpnzD`,v=`tempest_leading_L3de1`,y=`tempest_close_i10-s`,b={container:e,positionTopRight:t,positionTopLeft:n,positionTopCenter:r,positionBottomRight:i,positionBottomLeft:a,positionBottomCenter:o,toast:s,tempestToastIn:c,success:l,warning:u,error:d,info:f,title:p,description:m,content:h,withIcon:g,alignCenter:_,leading:v,close:y};exports.alignCenter=_,exports.close=y,exports.container=e,exports.content=h,exports.default=b,exports.description=m,exports.error=d,exports.info=f,exports.leading=v,exports.positionBottomCenter=o,exports.positionBottomLeft=a,exports.positionBottomRight=i,exports.positionTopCenter=r,exports.positionTopLeft=n,exports.positionTopRight=t,exports.success=l,exports.tempestToastIn=c,exports.title=p,exports.toast=s,exports.warning=u,exports.withIcon=g;
3
3
  //# sourceMappingURL=Toast.module.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.module.cjs","names":[],"sources":["../../../src/components/Toast/Toast.module.css"],"sourcesContent":[".container {\n position: fixed;\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-2);\n z-index: var(--tempest-z-toast);\n pointer-events: none;\n max-width: 100%;\n}\n\n/* Top */\n.positionTopRight {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionTopLeft {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionTopCenter {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Bottom */\n.positionBottomRight {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionBottomLeft {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionBottomCenter {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Mobile — stretch full width and respect safe areas. */\n@media (max-width: 480px) {\n .container {\n left: max(var(--tempest-space-3), var(--tempest-safe-area-left)) !important;\n right: max(var(--tempest-space-3), var(--tempest-safe-area-right)) !important;\n transform: none !important;\n }\n .positionTopRight,\n .positionTopLeft,\n .positionTopCenter {\n top: max(var(--tempest-space-3), var(--tempest-safe-area-top));\n }\n .positionBottomRight,\n .positionBottomLeft,\n .positionBottomCenter {\n bottom: max(var(--tempest-space-3), var(--tempest-safe-area-bottom));\n }\n .toast {\n min-width: 0;\n max-width: 100%;\n }\n}\n\n.toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n box-shadow: var(--tempest-shadow-lg);\n min-width: 280px;\n max-width: 420px;\n animation: tempest-toast-in var(--tempest-duration-base) var(--tempest-ease-emphasized);\n}\n\n.success {\n border-left: 4px solid var(--tempest-success-solid);\n}\n.warning {\n border-left: 4px solid var(--tempest-warning-solid);\n}\n.error {\n border-left: 4px solid var(--tempest-danger-solid);\n}\n.info {\n border-left: 4px solid var(--tempest-info-solid);\n}\n\n.title {\n font-family: var(--tempest-font-sans);\n font-weight: var(--tempest-weight-semibold);\n font-size: var(--tempest-text-base);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n margin: 0;\n}\n\n.description {\n font-size: var(--tempest-text-sm);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n margin: 2px 0 0 0;\n}\n\n.close {\n margin-left: auto;\n background: none;\n border: none;\n color: var(--tempest-text-muted);\n padding: 4px;\n border-radius: var(--tempest-radius-sm);\n display: flex;\n align-items: center;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .close:hover {\n background-color: var(--tempest-surface);\n color: var(--tempest-text);\n }\n}\n\n.close:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n@keyframes tempest-toast-in {\n from {\n transform: translateX(24px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"Toast.module.cjs","names":[],"sources":["../../../src/components/Toast/Toast.module.css"],"sourcesContent":[".container {\n position: fixed;\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-2);\n z-index: var(--tempest-z-toast);\n pointer-events: none;\n max-width: 100%;\n}\n\n/* Top */\n.positionTopRight {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionTopLeft {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionTopCenter {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Bottom */\n.positionBottomRight {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionBottomLeft {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionBottomCenter {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Mobile — stretch full width and respect safe areas. */\n@media (max-width: 480px) {\n .container {\n left: max(var(--tempest-space-3), var(--tempest-safe-area-left)) !important;\n right: max(var(--tempest-space-3), var(--tempest-safe-area-right)) !important;\n transform: none !important;\n }\n .positionTopRight,\n .positionTopLeft,\n .positionTopCenter {\n top: max(var(--tempest-space-3), var(--tempest-safe-area-top));\n }\n .positionBottomRight,\n .positionBottomLeft,\n .positionBottomCenter {\n bottom: max(var(--tempest-space-3), var(--tempest-safe-area-bottom));\n }\n .toast {\n min-width: 0;\n max-width: 100%;\n }\n}\n\n.toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n box-shadow: var(--tempest-shadow-lg);\n min-width: 280px;\n max-width: 420px;\n animation: tempest-toast-in var(--tempest-duration-base) var(--tempest-ease-emphasized);\n}\n\n.success {\n border-left: 4px solid var(--tempest-success-solid);\n}\n.warning {\n border-left: 4px solid var(--tempest-warning-solid);\n}\n.error {\n border-left: 4px solid var(--tempest-danger-solid);\n}\n.info {\n border-left: 4px solid var(--tempest-info-solid);\n}\n\n.title {\n font-family: var(--tempest-font-sans);\n font-weight: var(--tempest-weight-semibold);\n font-size: var(--tempest-text-base);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n margin: 0;\n}\n\n.description {\n font-size: var(--tempest-text-sm);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n margin: 2px 0 0 0;\n}\n\n.content {\n flex: 1 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.withIcon .content {\n align-self: center;\n}\n\n.alignCenter .content {\n text-align: center;\n}\n\n.leading {\n flex: 0 0 auto;\n align-self: center;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--tempest-text);\n}\n\n.leading img,\n.leading svg {\n display: block;\n max-width: var(--tempest-space-8);\n max-height: var(--tempest-space-8);\n object-fit: contain;\n}\n\n.close {\n flex: 0 0 auto;\n margin-left: auto;\n background: none;\n border: none;\n color: var(--tempest-text-muted);\n padding: 4px;\n border-radius: var(--tempest-radius-sm);\n display: flex;\n align-items: center;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .close:hover {\n background-color: var(--tempest-surface);\n color: var(--tempest-text);\n }\n}\n\n.close:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n@keyframes tempest-toast-in {\n from {\n transform: translateX(24px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n}\n"],"mappings":";"}
@@ -1,6 +1,6 @@
1
1
  import "../../styles/component/Toast.css";
2
2
  //#region src/components/Toast/Toast.module.css
3
- var e = "tempest_container_x4-Qm", t = "tempest_positionTopRight_gbUCQ", n = "tempest_positionTopLeft_Z-tMJ", r = "tempest_positionTopCenter_A4Ze4", i = "tempest_positionBottomRight_MGo19", a = "tempest_positionBottomLeft_DpiNe", o = "tempest_positionBottomCenter_XUdok", s = "tempest_toast_FLdHz", c = "tempest_tempest-toast-in_E2d-A", l = "tempest_success_Oy694", u = "tempest_warning_84GC8", d = "tempest_error_hrQAA", f = "tempest_info_eq5bQ", p = "tempest_title_-H6R2", m = "tempest_description_-QwfC", h = "tempest_close_i10-s", g = {
3
+ var e = "tempest_container_x4-Qm", t = "tempest_positionTopRight_gbUCQ", n = "tempest_positionTopLeft_Z-tMJ", r = "tempest_positionTopCenter_A4Ze4", i = "tempest_positionBottomRight_MGo19", a = "tempest_positionBottomLeft_DpiNe", o = "tempest_positionBottomCenter_XUdok", s = "tempest_toast_FLdHz", c = "tempest_tempest-toast-in_E2d-A", l = "tempest_success_Oy694", u = "tempest_warning_84GC8", d = "tempest_error_hrQAA", f = "tempest_info_eq5bQ", p = "tempest_title_-H6R2", m = "tempest_description_-QwfC", h = "tempest_content_U6Xwq", g = "tempest_withIcon_2Z8Sz", _ = "tempest_alignCenter_GpnzD", v = "tempest_leading_L3de1", y = "tempest_close_i10-s", b = {
4
4
  container: e,
5
5
  positionTopRight: t,
6
6
  positionTopLeft: n,
@@ -16,9 +16,13 @@ var e = "tempest_container_x4-Qm", t = "tempest_positionTopRight_gbUCQ", n = "te
16
16
  info: f,
17
17
  title: p,
18
18
  description: m,
19
- close: h
19
+ content: h,
20
+ withIcon: g,
21
+ alignCenter: _,
22
+ leading: v,
23
+ close: y
20
24
  };
21
25
  //#endregion
22
- export { h as close, e as container, g as default, m as description, d as error, f as info, o as positionBottomCenter, a as positionBottomLeft, i as positionBottomRight, r as positionTopCenter, n as positionTopLeft, t as positionTopRight, l as success, c as tempestToastIn, p as title, s as toast, u as warning };
26
+ export { _ as alignCenter, y as close, e as container, h as content, b as default, m as description, d as error, f as info, v as leading, o as positionBottomCenter, a as positionBottomLeft, i as positionBottomRight, r as positionTopCenter, n as positionTopLeft, t as positionTopRight, l as success, c as tempestToastIn, p as title, s as toast, u as warning, g as withIcon };
23
27
 
24
28
  //# sourceMappingURL=Toast.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.module.js","names":[],"sources":["../../../src/components/Toast/Toast.module.css"],"sourcesContent":[".container {\n position: fixed;\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-2);\n z-index: var(--tempest-z-toast);\n pointer-events: none;\n max-width: 100%;\n}\n\n/* Top */\n.positionTopRight {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionTopLeft {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionTopCenter {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Bottom */\n.positionBottomRight {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionBottomLeft {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionBottomCenter {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Mobile — stretch full width and respect safe areas. */\n@media (max-width: 480px) {\n .container {\n left: max(var(--tempest-space-3), var(--tempest-safe-area-left)) !important;\n right: max(var(--tempest-space-3), var(--tempest-safe-area-right)) !important;\n transform: none !important;\n }\n .positionTopRight,\n .positionTopLeft,\n .positionTopCenter {\n top: max(var(--tempest-space-3), var(--tempest-safe-area-top));\n }\n .positionBottomRight,\n .positionBottomLeft,\n .positionBottomCenter {\n bottom: max(var(--tempest-space-3), var(--tempest-safe-area-bottom));\n }\n .toast {\n min-width: 0;\n max-width: 100%;\n }\n}\n\n.toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n box-shadow: var(--tempest-shadow-lg);\n min-width: 280px;\n max-width: 420px;\n animation: tempest-toast-in var(--tempest-duration-base) var(--tempest-ease-emphasized);\n}\n\n.success {\n border-left: 4px solid var(--tempest-success-solid);\n}\n.warning {\n border-left: 4px solid var(--tempest-warning-solid);\n}\n.error {\n border-left: 4px solid var(--tempest-danger-solid);\n}\n.info {\n border-left: 4px solid var(--tempest-info-solid);\n}\n\n.title {\n font-family: var(--tempest-font-sans);\n font-weight: var(--tempest-weight-semibold);\n font-size: var(--tempest-text-base);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n margin: 0;\n}\n\n.description {\n font-size: var(--tempest-text-sm);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n margin: 2px 0 0 0;\n}\n\n.close {\n margin-left: auto;\n background: none;\n border: none;\n color: var(--tempest-text-muted);\n padding: 4px;\n border-radius: var(--tempest-radius-sm);\n display: flex;\n align-items: center;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .close:hover {\n background-color: var(--tempest-surface);\n color: var(--tempest-text);\n }\n}\n\n.close:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n@keyframes tempest-toast-in {\n from {\n transform: translateX(24px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n}\n"],"mappings":";"}
1
+ {"version":3,"file":"Toast.module.js","names":[],"sources":["../../../src/components/Toast/Toast.module.css"],"sourcesContent":[".container {\n position: fixed;\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-2);\n z-index: var(--tempest-z-toast);\n pointer-events: none;\n max-width: 100%;\n}\n\n/* Top */\n.positionTopRight {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionTopLeft {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionTopCenter {\n top: max(var(--tempest-space-4), var(--tempest-safe-area-top));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Bottom */\n.positionBottomRight {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n right: max(var(--tempest-space-4), var(--tempest-safe-area-right));\n}\n.positionBottomLeft {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: max(var(--tempest-space-4), var(--tempest-safe-area-left));\n}\n.positionBottomCenter {\n bottom: max(var(--tempest-space-4), var(--tempest-safe-area-bottom));\n left: 50%;\n transform: translateX(-50%);\n align-items: center;\n}\n\n/* Mobile — stretch full width and respect safe areas. */\n@media (max-width: 480px) {\n .container {\n left: max(var(--tempest-space-3), var(--tempest-safe-area-left)) !important;\n right: max(var(--tempest-space-3), var(--tempest-safe-area-right)) !important;\n transform: none !important;\n }\n .positionTopRight,\n .positionTopLeft,\n .positionTopCenter {\n top: max(var(--tempest-space-3), var(--tempest-safe-area-top));\n }\n .positionBottomRight,\n .positionBottomLeft,\n .positionBottomCenter {\n bottom: max(var(--tempest-space-3), var(--tempest-safe-area-bottom));\n }\n .toast {\n min-width: 0;\n max-width: 100%;\n }\n}\n\n.toast {\n pointer-events: auto;\n display: flex;\n align-items: flex-start;\n gap: var(--tempest-space-3);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n border-radius: var(--tempest-radius-lg);\n background-color: var(--tempest-bg);\n border: 1px solid var(--tempest-border);\n box-shadow: var(--tempest-shadow-lg);\n min-width: 280px;\n max-width: 420px;\n animation: tempest-toast-in var(--tempest-duration-base) var(--tempest-ease-emphasized);\n}\n\n.success {\n border-left: 4px solid var(--tempest-success-solid);\n}\n.warning {\n border-left: 4px solid var(--tempest-warning-solid);\n}\n.error {\n border-left: 4px solid var(--tempest-danger-solid);\n}\n.info {\n border-left: 4px solid var(--tempest-info-solid);\n}\n\n.title {\n font-family: var(--tempest-font-sans);\n font-weight: var(--tempest-weight-semibold);\n font-size: var(--tempest-text-base);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n margin: 0;\n}\n\n.description {\n font-size: var(--tempest-text-sm);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n margin: 2px 0 0 0;\n}\n\n.content {\n flex: 1 1 auto;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.withIcon .content {\n align-self: center;\n}\n\n.alignCenter .content {\n text-align: center;\n}\n\n.leading {\n flex: 0 0 auto;\n align-self: center;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--tempest-text);\n}\n\n.leading img,\n.leading svg {\n display: block;\n max-width: var(--tempest-space-8);\n max-height: var(--tempest-space-8);\n object-fit: contain;\n}\n\n.close {\n flex: 0 0 auto;\n margin-left: auto;\n background: none;\n border: none;\n color: var(--tempest-text-muted);\n padding: 4px;\n border-radius: var(--tempest-radius-sm);\n display: flex;\n align-items: center;\n transition: var(--tempest-transition-color);\n}\n\n@media (hover: hover) and (pointer: fine) {\n .close:hover {\n background-color: var(--tempest-surface);\n color: var(--tempest-text);\n }\n}\n\n.close:focus-visible {\n outline: var(--tempest-focus-ring-width) solid var(--tempest-focus-ring-color);\n outline-offset: var(--tempest-focus-ring-offset);\n}\n\n@keyframes tempest-toast-in {\n from {\n transform: translateX(24px);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n}\n"],"mappings":";"}
@@ -1,2 +1,2 @@
1
- const e=require("../../utils/cn.cjs"),t=require("../Portal/portal-host.cjs"),n=require("./Toast.module.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("react-dom");var o=(0,r.createContext)(null);function s(){let e=(0,r.useContext)(o);if(!e)throw Error(`useToast must be used inside a <ToastProvider>`);return e}function c({children:e,defaultDuration:t=4e3,position:n=`top-right`}){let[a,s]=(0,r.useState)([]),c=(0,r.useRef)(0),l=(0,r.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[]),d=(0,r.useCallback)(e=>{let n=e.id??`toast-${++c.current}`,r={id:n,title:e.title,description:e.description,variant:e.variant??`info`,duration:e.duration??t};return s(e=>[...e,r]),n},[t]),f=(0,r.useMemo)(()=>({show:d,dismiss:l,success:(e,t)=>d({...t,description:e,variant:`success`}),error:(e,t)=>d({...t,description:e,variant:`error`}),warning:(e,t)=>d({...t,description:e,variant:`warning`}),info:(e,t)=>d({...t,description:e,variant:`info`})}),[d,l]);return(0,i.jsxs)(o.Provider,{value:f,children:[e,(0,i.jsx)(u,{toasts:a,onDismiss:l,position:n})]})}function l(e){switch(e){case`top-left`:return n.default.positionTopLeft;case`top-center`:return n.default.positionTopCenter;case`bottom-right`:return n.default.positionBottomRight;case`bottom-left`:return n.default.positionBottomLeft;case`bottom-center`:return n.default.positionBottomCenter;default:return n.default.positionTopRight}}function u({toasts:r,onDismiss:o,position:s}){let c=t.usePortalHost();return c?(0,a.createPortal)((0,i.jsx)(`div`,{className:e.cn(n.default.container,l(s)),"aria-live":`polite`,"aria-atomic":`false`,children:r.map(e=>(0,i.jsx)(d,{toast:e,onDismiss:o},e.id))}),c):null}function d({toast:t,onDismiss:a}){return(0,r.useEffect)(()=>{if(!t.duration)return;let e=setTimeout(()=>a(t.id),t.duration);return()=>clearTimeout(e)},[t.id,t.duration,a]),(0,i.jsxs)(`div`,{className:e.cn(n.default.toast,n.default[t.variant]),children:[(0,i.jsxs)(`div`,{children:[t.title&&(0,i.jsx)(`p`,{className:n.default.title,children:t.title}),t.description&&(0,i.jsx)(`p`,{className:n.default.description,children:t.description})]}),(0,i.jsx)(`button`,{type:`button`,className:n.default.close,"aria-label":`Fechar notificação`,onClick:()=>a(t.id),children:(0,i.jsx)(f,{})})]})}function f(){return(0,i.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,children:(0,i.jsx)(`path`,{d:`M6 6l12 12M6 18L18 6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})}exports.ToastProvider=c,exports.useToast=s;
1
+ const e=require("../../utils/cn.cjs"),t=require("../Portal/portal-host.cjs"),n=require("./Toast.module.cjs");let r=require("react"),i=require("react/jsx-runtime"),a=require("react-dom");var o=(0,r.createContext)(null);function s(){let e=(0,r.useContext)(o);if(!e)throw Error(`useToast must be used inside a <ToastProvider>`);return e}function c({children:e,defaultDuration:t=4e3,position:n=`top-right`}){let[a,s]=(0,r.useState)([]),c=(0,r.useRef)(0),l=(0,r.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[]),d=(0,r.useCallback)(e=>{let n=e.id??`toast-${++c.current}`,r={id:n,title:e.title,description:e.description,variant:e.variant??`info`,duration:e.duration??t,icon:e.icon,iconLabel:e.iconLabel,align:e.align??`start`};return s(e=>[...e,r]),n},[t]),f=(0,r.useMemo)(()=>({show:d,dismiss:l,success:(e,t)=>d({...t,description:e,variant:`success`}),error:(e,t)=>d({...t,description:e,variant:`error`}),warning:(e,t)=>d({...t,description:e,variant:`warning`}),info:(e,t)=>d({...t,description:e,variant:`info`})}),[d,l]);return(0,i.jsxs)(o.Provider,{value:f,children:[e,(0,i.jsx)(u,{toasts:a,onDismiss:l,position:n})]})}function l(e){switch(e){case`top-left`:return n.default.positionTopLeft;case`top-center`:return n.default.positionTopCenter;case`bottom-right`:return n.default.positionBottomRight;case`bottom-left`:return n.default.positionBottomLeft;case`bottom-center`:return n.default.positionBottomCenter;default:return n.default.positionTopRight}}function u({toasts:r,onDismiss:o,position:s}){let c=t.usePortalHost();return c?(0,a.createPortal)((0,i.jsx)(`div`,{className:e.cn(n.default.container,l(s)),"aria-live":`polite`,"aria-atomic":`false`,children:r.map(e=>(0,i.jsx)(d,{toast:e,onDismiss:o},e.id))}),c):null}function d({toast:t,onDismiss:a}){(0,r.useEffect)(()=>{if(!t.duration)return;let e=setTimeout(()=>a(t.id),t.duration);return()=>clearTimeout(e)},[t.id,t.duration,a]);let o=f(t.icon);return(0,i.jsxs)(`div`,{className:e.cn(n.default.toast,n.default[t.variant],o&&n.default.withIcon,t.align===`center`&&n.default.alignCenter),children:[o&&(0,i.jsx)(`div`,{ref:p,className:n.default.leading,...t.iconLabel?{role:`img`,"aria-label":t.iconLabel}:{"aria-hidden":!0},children:t.icon}),(0,i.jsxs)(`div`,{className:n.default.content,children:[t.title&&(0,i.jsx)(`p`,{className:n.default.title,children:t.title}),t.description&&(0,i.jsx)(`p`,{className:n.default.description,children:t.description})]}),(0,i.jsx)(`button`,{type:`button`,className:n.default.close,"aria-label":`Fechar notificação`,onClick:()=>a(t.id),children:(0,i.jsx)(m,{})})]})}function f(e){return r.Children.toArray(e).some(e=>e===``?!1:(0,r.isValidElement)(e)&&e.type===r.Fragment?f(e.props.children):!0)}function p(e){e?.setAttribute(`inert`,``)}function m(){return(0,i.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,children:(0,i.jsx)(`path`,{d:`M6 6l12 12M6 18L18 6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})}exports.ToastProvider=c,exports.useToast=s;
2
2
  //# sourceMappingURL=ToastProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastProvider.cjs","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines — the provider is the queue: enqueue, dedupe, auto-\n * dismiss timers, pause on hover and the portal that renders them. Splitting the\n * queue from the renderer would put a timer in one file and the element it dismisses\n * in another.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Toast.module.css\";\nimport { usePortalHost } from \"../Portal/portal-host\";\n\nexport type ToastVariant = \"success\" | \"warning\" | \"error\" | \"info\";\n\nexport interface ToastOptions {\n id?: string;\n title?: string;\n description?: string;\n variant?: ToastVariant;\n /** Auto-dismiss timeout in ms. Pass `0` to keep the toast until dismissed manually. */\n duration?: number;\n}\n\ninterface ToastEntry extends Required<Omit<ToastOptions, \"id\" | \"title\" | \"description\">> {\n id: string;\n title?: string;\n description?: string;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => string;\n dismiss: (id: string) => void;\n success: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n error: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n warning: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n info: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/**\n * Access the toast API. Must be used inside a {@link ToastProvider}.\n *\n * @returns Methods to show and dismiss toasts.\n */\nexport function useToast(): ToastApi {\n const ctx = useContext(ToastContext);\n if (!ctx) throw new Error(\"useToast must be used inside a <ToastProvider>\");\n return ctx;\n}\n\nexport type ToastPosition =\n \"top-right\" | \"top-left\" | \"top-center\" | \"bottom-right\" | \"bottom-left\" | \"bottom-center\";\n\nexport interface ToastProviderProps {\n children: ReactNode;\n /** Default auto-dismiss duration (ms). Default 4000. */\n defaultDuration?: number;\n /** Stack position on screen. Default `\"top-right\"`. */\n position?: ToastPosition;\n}\n\n/**\n * Renders a portalled toast container and exposes the imperative {@link useToast} API.\n */\nexport function ToastProvider({\n children,\n defaultDuration = 4000,\n position = \"top-right\",\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const counter = useRef<number>(0);\n\n const dismiss = useCallback((id: string): void => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const show = useCallback(\n (options: ToastOptions): string => {\n const id = options.id ?? `toast-${++counter.current}`;\n const entry: ToastEntry = {\n id,\n title: options.title,\n description: options.description,\n variant: options.variant ?? \"info\",\n duration: options.duration ?? defaultDuration,\n };\n setToasts((current) => [...current, entry]);\n return id;\n },\n [defaultDuration],\n );\n\n const api = useMemo<ToastApi>(\n () => ({\n show,\n dismiss,\n success: (description, options) =>\n show({ ...options, description, variant: \"success\" }),\n error: (description, options) => show({ ...options, description, variant: \"error\" }),\n warning: (description, options) =>\n show({ ...options, description, variant: \"warning\" }),\n info: (description, options) => show({ ...options, description, variant: \"info\" }),\n }),\n [show, dismiss],\n );\n\n return (\n <ToastContext.Provider value={api}>\n {children}\n <ToastContainer toasts={toasts} onDismiss={dismiss} position={position} />\n </ToastContext.Provider>\n );\n}\n\ninterface ContainerProps {\n toasts: ToastEntry[];\n onDismiss: (id: string) => void;\n position: ToastPosition;\n}\n\nfunction positionClass(position: ToastPosition): string {\n switch (position) {\n case \"top-left\":\n return styles.positionTopLeft;\n case \"top-center\":\n return styles.positionTopCenter;\n case \"bottom-right\":\n return styles.positionBottomRight;\n case \"bottom-left\":\n return styles.positionBottomLeft;\n case \"bottom-center\":\n return styles.positionBottomCenter;\n case \"top-right\":\n default:\n return styles.positionTopRight;\n }\n}\n\n/**\n * The portalled stack, and the page's live region for toasts.\n *\n * `aria-atomic=\"false\"` matters: with `\"true\"` a screen reader re-reads the\n * **entire** stack on every change, so the third toast of a batch is announced as\n * all three, and dismissing one re-announces the survivors. `\"false\"` announces only\n * the node that was added, which is what the user needs.\n *\n * The stack stays the live region rather than delegating to `useAnnounce`, because\n * routing it through the shared announcer would put the same text in the document\n * twice — once visible, once hidden — and every `getByText(\"Salvo\")` in a consuming\n * app's test suite would start matching two nodes. The announcer is for messages\n * that have no on-screen home; a toast has one.\n */\nfunction ToastContainer({ toasts, onDismiss, position }: ContainerProps) {\n const portalHost = usePortalHost();\n\n if (!portalHost) return null;\n return createPortal(\n <div\n className={cn(styles.container, positionClass(position))}\n aria-live=\"polite\"\n aria-atomic=\"false\"\n >\n {toasts.map((toast) => (\n <ToastItem key={toast.id} toast={toast} onDismiss={onDismiss} />\n ))}\n </div>,\n portalHost,\n );\n}\n\ninterface ItemProps {\n toast: ToastEntry;\n onDismiss: (id: string) => void;\n}\n\n/**\n * One toast.\n *\n * No `role=\"status\"` of its own: it already lives inside the container's live\n * region, and a live region nested in a live region is announced twice by some\n * screen readers.\n */\nfunction ToastItem({ toast, onDismiss }: ItemProps) {\n useEffect(() => {\n if (!toast.duration) return;\n const timer = setTimeout(() => onDismiss(toast.id), toast.duration);\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onDismiss]);\n\n return (\n <div className={cn(styles.toast, styles[toast.variant])}>\n <div>\n {toast.title && <p className={styles.title}>{toast.title}</p>}\n {toast.description && <p className={styles.description}>{toast.description}</p>}\n </div>\n <button\n type=\"button\"\n className={styles.close}\n aria-label=\"Fechar notificação\"\n onClick={() => onDismiss(toast.id)}\n >\n <CloseIcon />\n </button>\n </div>\n );\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 6l12 12M6 18L18 6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":"0LAqDA,IAAM,GAAA,EAAe,EAAA,cAAA,CAA+B,IAAI,EAOxD,SAAgB,GAAqB,CACjC,IAAM,GAAA,EAAM,EAAA,WAAA,CAAW,CAAY,EACnC,GAAI,CAAC,EAAK,MAAU,MAAM,gDAAgD,EAC1E,OAAO,CACX,CAgBA,SAAgB,EAAc,CAC1B,WACA,kBAAkB,IAClB,WAAW,aACQ,CACnB,GAAM,CAAC,EAAQ,IAAA,EAAa,EAAA,SAAA,CAAuB,CAAC,CAAC,EAC/C,GAAA,EAAU,EAAA,OAAA,CAAe,CAAC,EAE1B,GAAA,EAAU,EAAA,YAAA,CAAa,GAAqB,CAC9C,EAAW,GAAY,EAAQ,OAAQ,GAAU,EAAM,KAAO,CAAE,CAAC,CACrE,EAAG,CAAC,CAAC,EAEC,GAAA,EAAO,EAAA,YAAA,CACR,GAAkC,CAC/B,IAAM,EAAK,EAAQ,IAAM,SAAS,EAAE,EAAQ,UACtC,EAAoB,CACtB,KACA,MAAO,EAAQ,MACf,YAAa,EAAQ,YACrB,QAAS,EAAQ,SAAW,OAC5B,SAAU,EAAQ,UAAY,CAClC,EAEA,OADA,EAAW,GAAY,CAAC,GAAG,EAAS,CAAK,CAAC,EACnC,CACX,EACA,CAAC,CAAe,CACpB,EAEM,GAAA,EAAM,EAAA,QAAA,MACD,CACH,OACA,UACA,SAAU,EAAa,IACnB,EAAK,CAAE,GAAG,EAAS,cAAa,QAAS,SAAU,CAAC,EACxD,OAAQ,EAAa,IAAY,EAAK,CAAE,GAAG,EAAS,cAAa,QAAS,OAAQ,CAAC,E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pC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,MAAO,EAAA,QAAO,EAAM,QAAQ,EAAtD,SAAA,EACI,EAAA,EAAA,KAAA,CAAC,MAAD,CAAA,SAAA,CACK,EAAM,QAAS,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAW,EAAA,QAAO,MAAQ,SAAA,EAAM,KAAS,CAAA,EAC3D,EAAM,cAAe,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAW,EAAA,QAAO,YAAc,SAAA,EAAM,WAAe,CAAA,CAC7E,CAAA,CAAA,GACL,EAAA,EAAA,IAAA,CAAC,SAAD,CACI,KAAK,SACL,UAAW,EAAA,QAAO,MAClB,aAAW,qBACX,YAAe,EAAU,EAAM,EAAE,EAEjC,UAAA,EAAA,EAAA,IAAA,CAAC,EAAD,CAAY,CAAA,CACR,CAAA,CACP,GAEb,CAEA,SAAS,GAAY,CACjB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACjD,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CACI,EAAE,uBACF,OAAO,eACP,YAAY,IACZ,cAAc,OACjB,CAAA,CACA,CAAA,CAEb"}
1
+ {"version":3,"file":"ToastProvider.cjs","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines — the provider is the queue: enqueue, dedupe, auto-\n * dismiss timers, pause on hover and the portal that renders them. Splitting the\n * queue from the renderer would put a timer in one file and the element it dismisses\n * in another.\n */\nimport {\n Children,\n Fragment,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Toast.module.css\";\nimport { usePortalHost } from \"../Portal/portal-host\";\n\nexport type ToastVariant = \"success\" | \"warning\" | \"error\" | \"info\";\n\n/**\n * Horizontal alignment of a toast's title and description.\n *\n * `\"start\"` is the default because a toast is read as a sentence beside a close\n * button: left-aligned lines share one edge with the icon and the stack, so a\n * two-line description stays scannable. `\"center\"` exists for the short\n * celebratory toast (an achievement with a badge) where the text is one line.\n */\nexport type ToastAlign = \"start\" | \"center\";\n\nexport interface ToastOptions {\n id?: string;\n title?: string;\n description?: string;\n variant?: ToastVariant;\n /** Auto-dismiss timeout in ms. Pass `0` to keep the toast until dismissed manually. */\n duration?: number;\n /**\n * Leading slot rendered before the text, e.g. `<img src=\"/badge.svg\" alt=\"\" />`.\n *\n * It is an app asset, so it takes any `ReactNode` — but it is a slot for an\n * **icon**, not for a control. The wrapper is `inert`, so a button or link put\n * here is neither focusable nor clickable; actions belong outside the toast.\n *\n * The slot is decorative (`aria-hidden`) unless {@link ToastOptions.iconLabel}\n * is given: most icons repeat what the title already says, and an unlabelled\n * image inside the live region would otherwise be announced as \"image\" or by\n * its file name. An `<img>` or `<svg>` anywhere inside it is capped at 32px and\n * keeps its aspect ratio. A node that renders nothing (`null`, a boolean, `\"\"`,\n * `[]`, an empty fragment) counts as no icon, so the toast keeps two columns.\n */\n icon?: ReactNode;\n /**\n * Accessible name for {@link ToastOptions.icon} when the icon carries meaning\n * the text does not. With it the slot becomes `role=\"img\"` with this label and\n * is announced together with the toast; without it the slot is hidden from\n * assistive technology.\n */\n iconLabel?: string;\n /** Text alignment of title and description. Default `\"start\"`; see {@link ToastAlign}. */\n align?: ToastAlign;\n}\n\ninterface ToastEntry extends Required<\n Omit<ToastOptions, \"id\" | \"title\" | \"description\" | \"icon\" | \"iconLabel\">\n> {\n id: string;\n title?: string;\n description?: string;\n icon?: ReactNode;\n iconLabel?: string;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => string;\n dismiss: (id: string) => void;\n success: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n error: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n warning: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n info: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/**\n * Access the toast API. Must be used inside a {@link ToastProvider}.\n *\n * @returns Methods to show and dismiss toasts.\n */\nexport function useToast(): ToastApi {\n const ctx = useContext(ToastContext);\n if (!ctx) throw new Error(\"useToast must be used inside a <ToastProvider>\");\n return ctx;\n}\n\nexport type ToastPosition =\n \"top-right\" | \"top-left\" | \"top-center\" | \"bottom-right\" | \"bottom-left\" | \"bottom-center\";\n\nexport interface ToastProviderProps {\n children: ReactNode;\n /** Default auto-dismiss duration (ms). Default 4000. */\n defaultDuration?: number;\n /** Stack position on screen. Default `\"top-right\"`. */\n position?: ToastPosition;\n}\n\n/**\n * Renders a portalled toast container and exposes the imperative {@link useToast} API.\n */\nexport function ToastProvider({\n children,\n defaultDuration = 4000,\n position = \"top-right\",\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const counter = useRef<number>(0);\n\n const dismiss = useCallback((id: string): void => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const show = useCallback(\n (options: ToastOptions): string => {\n const id = options.id ?? `toast-${++counter.current}`;\n const entry: ToastEntry = {\n id,\n title: options.title,\n description: options.description,\n variant: options.variant ?? \"info\",\n duration: options.duration ?? defaultDuration,\n icon: options.icon,\n iconLabel: options.iconLabel,\n align: options.align ?? \"start\",\n };\n setToasts((current) => [...current, entry]);\n return id;\n },\n [defaultDuration],\n );\n\n const api = useMemo<ToastApi>(\n () => ({\n show,\n dismiss,\n success: (description, options) =>\n show({ ...options, description, variant: \"success\" }),\n error: (description, options) => show({ ...options, description, variant: \"error\" }),\n warning: (description, options) =>\n show({ ...options, description, variant: \"warning\" }),\n info: (description, options) => show({ ...options, description, variant: \"info\" }),\n }),\n [show, dismiss],\n );\n\n return (\n <ToastContext.Provider value={api}>\n {children}\n <ToastContainer toasts={toasts} onDismiss={dismiss} position={position} />\n </ToastContext.Provider>\n );\n}\n\ninterface ContainerProps {\n toasts: ToastEntry[];\n onDismiss: (id: string) => void;\n position: ToastPosition;\n}\n\nfunction positionClass(position: ToastPosition): string {\n switch (position) {\n case \"top-left\":\n return styles.positionTopLeft;\n case \"top-center\":\n return styles.positionTopCenter;\n case \"bottom-right\":\n return styles.positionBottomRight;\n case \"bottom-left\":\n return styles.positionBottomLeft;\n case \"bottom-center\":\n return styles.positionBottomCenter;\n case \"top-right\":\n default:\n return styles.positionTopRight;\n }\n}\n\n/**\n * The portalled stack, and the page's live region for toasts.\n *\n * `aria-atomic=\"false\"` matters: with `\"true\"` a screen reader re-reads the\n * **entire** stack on every change, so the third toast of a batch is announced as\n * all three, and dismissing one re-announces the survivors. `\"false\"` announces only\n * the node that was added, which is what the user needs.\n *\n * The stack stays the live region rather than delegating to `useAnnounce`, because\n * routing it through the shared announcer would put the same text in the document\n * twice — once visible, once hidden — and every `getByText(\"Salvo\")` in a consuming\n * app's test suite would start matching two nodes. The announcer is for messages\n * that have no on-screen home; a toast has one.\n */\nfunction ToastContainer({ toasts, onDismiss, position }: ContainerProps) {\n const portalHost = usePortalHost();\n\n if (!portalHost) return null;\n return createPortal(\n <div\n className={cn(styles.container, positionClass(position))}\n aria-live=\"polite\"\n aria-atomic=\"false\"\n >\n {toasts.map((toast) => (\n <ToastItem key={toast.id} toast={toast} onDismiss={onDismiss} />\n ))}\n </div>,\n portalHost,\n );\n}\n\ninterface ItemProps {\n toast: ToastEntry;\n onDismiss: (id: string) => void;\n}\n\n/**\n * One toast.\n *\n * No `role=\"status\"` of its own: it already lives inside the container's live\n * region, and a live region nested in a live region is announced twice by some\n * screen readers.\n *\n * With an icon the toast becomes three columns (leading, content, close) and the\n * icon and text are centred vertically against each other, so a 32px badge sits\n * level with a one-line title. Toasts without an icon keep the top-aligned layout\n * and the same size for short text; what changed for them is long text: the text\n * column now wraps a long word (`overflow-wrap: anywhere`) and the close button no\n * longer shrinks (it used to drop from 22px to 16–17px beside a two-line\n * description).\n *\n * The leading wrapper gets `inert` through a callback ref instead of a prop,\n * because no prop value works on both supported Reacts: React 18 drops\n * `inert={true}` with a warning and renders `inert=\"\"`, while React 19 renders\n * `inert={true}` and drops `inert=\"\"`.\n */\nfunction ToastItem({ toast, onDismiss }: ItemProps) {\n useEffect(() => {\n if (!toast.duration) return;\n const timer = setTimeout(() => onDismiss(toast.id), toast.duration);\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onDismiss]);\n\n const hasIcon = rendersSomething(toast.icon);\n\n return (\n <div\n className={cn(\n styles.toast,\n styles[toast.variant],\n hasIcon && styles.withIcon,\n toast.align === \"center\" && styles.alignCenter,\n )}\n >\n {hasIcon && (\n <div\n ref={makeInert}\n className={styles.leading}\n {...(toast.iconLabel\n ? { role: \"img\", \"aria-label\": toast.iconLabel }\n : { \"aria-hidden\": true })}\n >\n {toast.icon}\n </div>\n )}\n <div className={styles.content}>\n {toast.title && <p className={styles.title}>{toast.title}</p>}\n {toast.description && <p className={styles.description}>{toast.description}</p>}\n </div>\n <button\n type=\"button\"\n className={styles.close}\n aria-label=\"Fechar notificação\"\n onClick={() => onDismiss(toast.id)}\n >\n <CloseIcon />\n </button>\n </div>\n );\n}\n\n/**\n * Whether a node renders anything at all.\n *\n * `Children.toArray` drops `null`, `undefined` and booleans and flattens arrays,\n * but keeps a fragment as one element — so a fragment is unwrapped and checked\n * by its children. `\"\"` renders no text node worth a column either.\n *\n * @param node - The icon slot content.\n * @returns `true` when at least one child would produce output.\n */\nfunction rendersSomething(node: ReactNode): boolean {\n return Children.toArray(node).some((child) => {\n if (child === \"\") return false;\n if (isValidElement<{ children?: ReactNode }>(child) && child.type === Fragment) {\n return rendersSomething(child.props.children);\n }\n return true;\n });\n}\n\n/**\n * Callback ref that marks the icon wrapper `inert`, on React 18 and 19 alike.\n *\n * @param node - The wrapper element, or `null` on unmount.\n */\nfunction makeInert(node: HTMLDivElement | null): void {\n node?.setAttribute(\"inert\", \"\");\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 6l12 12M6 18L18 6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":"0LA8FA,IAAM,GAAA,EAAe,EAAA,cAAA,CAA+B,IAAI,EAOxD,SAAgB,GAAqB,CACjC,IAAM,GAAA,EAAM,EAAA,WAAA,CAAW,CAAY,EACnC,GAAI,CAAC,EAAK,MAAU,MAAM,gDAAgD,EAC1E,OAAO,CACX,CAgBA,SAAgB,EAAc,CAC1B,WACA,kBAAkB,IAClB,WAAW,aACQ,CACnB,GAAM,CAAC,EAAQ,IAAA,EAAa,EAAA,SAAA,CAAuB,CAAC,CAAC,EAC/C,GAAA,EAAU,EAAA,OAAA,CAAe,CAAC,EAE1B,GAAA,EAAU,EAAA,YAAA,CAAa,GAAqB,CAC9C,EAAW,GAAY,EAAQ,OAAQ,GAAU,EAAM,KAAO,CAAE,CAAC,CACrE,EAAG,CAAC,CAAC,EAEC,GAAA,EAAO,EAAA,YAAA,CACR,GAAkC,CAC/B,IAAM,EAAK,EAAQ,IAAM,SAAS,EAAE,EAAQ,UACtC,EAAoB,CACtB,KACA,MAAO,EAAQ,MACf,YAAa,EAAQ,YACrB,QAAS,EAAQ,SAAW,OAC5B,SAAU,EAAQ,UAAY,EAC9B,KAAM,EAAQ,KACd,UAAW,EAAQ,UACnB,MAAO,EAAQ,OAAS,OAC5B,EAEA,OADA,EAAW,GAAY,CAAC,GAAG,EAAS,CAAK,CAAC,EACnC,CACX,EACA,CAAC,CAAe,CACpB,EAEM,GAAA,EAAM,EAAA,QAAA,MACD,CACH,OACA,UACA,SAAU,EAAa,IACnB,EAAK,CAAE,GAAG,EAAS,cAAa,QAAS,SAAU,CAAC,EACxD,OAAQ,E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AAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACjD,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CACI,EAAE,uBACF,OAAO,eACP,YAAY,IACZ,cAAc,OACjB,CAAA,CACA,CAAA,CAEb"}
@@ -1,62 +1,65 @@
1
1
  import { cn as e } from "../../utils/cn.js";
2
2
  import { usePortalHost as t } from "../Portal/portal-host.js";
3
3
  import n from "./Toast.module.js";
4
- import { createContext as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
5
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
6
- import { createPortal as f } from "react-dom";
4
+ import { Children as r, Fragment as i, createContext as a, isValidElement as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
5
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
+ import { createPortal as h } from "react-dom";
7
7
  //#region src/components/Toast/ToastProvider.tsx
8
- var p = r(null);
9
- function m() {
10
- let e = a(p);
8
+ var g = a(null);
9
+ function _() {
10
+ let e = c(g);
11
11
  if (!e) throw Error("useToast must be used inside a <ToastProvider>");
12
12
  return e;
13
13
  }
14
- function h({ children: e, defaultDuration: t = 4e3, position: n = "top-right" }) {
15
- let [r, a] = l([]), o = c(0), f = i((e) => {
16
- a((t) => t.filter((t) => t.id !== e));
17
- }, []), m = i((e) => {
18
- let n = e.id ?? `toast-${++o.current}`, r = {
14
+ function v({ children: e, defaultDuration: t = 4e3, position: n = "top-right" }) {
15
+ let [r, i] = f([]), a = d(0), o = s((e) => {
16
+ i((t) => t.filter((t) => t.id !== e));
17
+ }, []), c = s((e) => {
18
+ let n = e.id ?? `toast-${++a.current}`, r = {
19
19
  id: n,
20
20
  title: e.title,
21
21
  description: e.description,
22
22
  variant: e.variant ?? "info",
23
- duration: e.duration ?? t
23
+ duration: e.duration ?? t,
24
+ icon: e.icon,
25
+ iconLabel: e.iconLabel,
26
+ align: e.align ?? "start"
24
27
  };
25
- return a((e) => [...e, r]), n;
26
- }, [t]), h = s(() => ({
27
- show: m,
28
- dismiss: f,
29
- success: (e, t) => m({
28
+ return i((e) => [...e, r]), n;
29
+ }, [t]), l = u(() => ({
30
+ show: c,
31
+ dismiss: o,
32
+ success: (e, t) => c({
30
33
  ...t,
31
34
  description: e,
32
35
  variant: "success"
33
36
  }),
34
- error: (e, t) => m({
37
+ error: (e, t) => c({
35
38
  ...t,
36
39
  description: e,
37
40
  variant: "error"
38
41
  }),
39
- warning: (e, t) => m({
42
+ warning: (e, t) => c({
40
43
  ...t,
41
44
  description: e,
42
45
  variant: "warning"
43
46
  }),
44
- info: (e, t) => m({
47
+ info: (e, t) => c({
45
48
  ...t,
46
49
  description: e,
47
50
  variant: "info"
48
51
  })
49
- }), [m, f]);
50
- return /* @__PURE__ */ d(p.Provider, {
51
- value: h,
52
- children: [e, /* @__PURE__ */ u(_, {
52
+ }), [c, o]);
53
+ return /* @__PURE__ */ m(g.Provider, {
54
+ value: l,
55
+ children: [e, /* @__PURE__ */ p(b, {
53
56
  toasts: r,
54
- onDismiss: f,
57
+ onDismiss: o,
55
58
  position: n
56
59
  })]
57
60
  });
58
61
  }
59
- function g(e) {
62
+ function y(e) {
60
63
  switch (e) {
61
64
  case "top-left": return n.positionTopLeft;
62
65
  case "top-center": return n.positionTopCenter;
@@ -66,20 +69,20 @@ function g(e) {
66
69
  default: return n.positionTopRight;
67
70
  }
68
71
  }
69
- function _({ toasts: r, onDismiss: i, position: a }) {
72
+ function b({ toasts: r, onDismiss: i, position: a }) {
70
73
  let o = t();
71
- return o ? f(/* @__PURE__ */ u("div", {
72
- className: e(n.container, g(a)),
74
+ return o ? h(/* @__PURE__ */ p("div", {
75
+ className: e(n.container, y(a)),
73
76
  "aria-live": "polite",
74
77
  "aria-atomic": "false",
75
- children: r.map((e) => /* @__PURE__ */ u(v, {
78
+ children: r.map((e) => /* @__PURE__ */ p(x, {
76
79
  toast: e,
77
80
  onDismiss: i
78
81
  }, e.id))
79
82
  }), o) : null;
80
83
  }
81
- function v({ toast: t, onDismiss: r }) {
82
- return o(() => {
84
+ function x({ toast: t, onDismiss: r }) {
85
+ l(() => {
83
86
  if (!t.duration) return;
84
87
  let e = setTimeout(() => r(t.id), t.duration);
85
88
  return () => clearTimeout(e);
@@ -87,30 +90,53 @@ function v({ toast: t, onDismiss: r }) {
87
90
  t.id,
88
91
  t.duration,
89
92
  r
90
- ]), /* @__PURE__ */ d("div", {
91
- className: e(n.toast, n[t.variant]),
92
- children: [/* @__PURE__ */ d("div", { children: [t.title && /* @__PURE__ */ u("p", {
93
- className: n.title,
94
- children: t.title
95
- }), t.description && /* @__PURE__ */ u("p", {
96
- className: n.description,
97
- children: t.description
98
- })] }), /* @__PURE__ */ u("button", {
99
- type: "button",
100
- className: n.close,
101
- "aria-label": "Fechar notificação",
102
- onClick: () => r(t.id),
103
- children: /* @__PURE__ */ u(y, {})
104
- })]
93
+ ]);
94
+ let i = S(t.icon);
95
+ return /* @__PURE__ */ m("div", {
96
+ className: e(n.toast, n[t.variant], i && n.withIcon, t.align === "center" && n.alignCenter),
97
+ children: [
98
+ i && /* @__PURE__ */ p("div", {
99
+ ref: C,
100
+ className: n.leading,
101
+ ...t.iconLabel ? {
102
+ role: "img",
103
+ "aria-label": t.iconLabel
104
+ } : { "aria-hidden": !0 },
105
+ children: t.icon
106
+ }),
107
+ /* @__PURE__ */ m("div", {
108
+ className: n.content,
109
+ children: [t.title && /* @__PURE__ */ p("p", {
110
+ className: n.title,
111
+ children: t.title
112
+ }), t.description && /* @__PURE__ */ p("p", {
113
+ className: n.description,
114
+ children: t.description
115
+ })]
116
+ }),
117
+ /* @__PURE__ */ p("button", {
118
+ type: "button",
119
+ className: n.close,
120
+ "aria-label": "Fechar notificação",
121
+ onClick: () => r(t.id),
122
+ children: /* @__PURE__ */ p(w, {})
123
+ })
124
+ ]
105
125
  });
106
126
  }
107
- function y() {
108
- return /* @__PURE__ */ u("svg", {
127
+ function S(e) {
128
+ return r.toArray(e).some((e) => e === "" ? !1 : o(e) && e.type === i ? S(e.props.children) : !0);
129
+ }
130
+ function C(e) {
131
+ e?.setAttribute("inert", "");
132
+ }
133
+ function w() {
134
+ return /* @__PURE__ */ p("svg", {
109
135
  width: "14",
110
136
  height: "14",
111
137
  viewBox: "0 0 24 24",
112
138
  fill: "none",
113
- children: /* @__PURE__ */ u("path", {
139
+ children: /* @__PURE__ */ p("path", {
114
140
  d: "M6 6l12 12M6 18L18 6",
115
141
  stroke: "currentColor",
116
142
  strokeWidth: "2",
@@ -119,6 +145,6 @@ function y() {
119
145
  });
120
146
  }
121
147
  //#endregion
122
- export { h as ToastProvider, m as useToast };
148
+ export { v as ToastProvider, _ as useToast };
123
149
 
124
150
  //# sourceMappingURL=ToastProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToastProvider.js","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines — the provider is the queue: enqueue, dedupe, auto-\n * dismiss timers, pause on hover and the portal that renders them. Splitting the\n * queue from the renderer would put a timer in one file and the element it dismisses\n * in another.\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Toast.module.css\";\nimport { usePortalHost } from \"../Portal/portal-host\";\n\nexport type ToastVariant = \"success\" | \"warning\" | \"error\" | \"info\";\n\nexport interface ToastOptions {\n id?: string;\n title?: string;\n description?: string;\n variant?: ToastVariant;\n /** Auto-dismiss timeout in ms. Pass `0` to keep the toast until dismissed manually. */\n duration?: number;\n}\n\ninterface ToastEntry extends Required<Omit<ToastOptions, \"id\" | \"title\" | \"description\">> {\n id: string;\n title?: string;\n description?: string;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => string;\n dismiss: (id: string) => void;\n success: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n error: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n warning: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n info: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/**\n * Access the toast API. Must be used inside a {@link ToastProvider}.\n *\n * @returns Methods to show and dismiss toasts.\n */\nexport function useToast(): ToastApi {\n const ctx = useContext(ToastContext);\n if (!ctx) throw new Error(\"useToast must be used inside a <ToastProvider>\");\n return ctx;\n}\n\nexport type ToastPosition =\n \"top-right\" | \"top-left\" | \"top-center\" | \"bottom-right\" | \"bottom-left\" | \"bottom-center\";\n\nexport interface ToastProviderProps {\n children: ReactNode;\n /** Default auto-dismiss duration (ms). Default 4000. */\n defaultDuration?: number;\n /** Stack position on screen. Default `\"top-right\"`. */\n position?: ToastPosition;\n}\n\n/**\n * Renders a portalled toast container and exposes the imperative {@link useToast} API.\n */\nexport function ToastProvider({\n children,\n defaultDuration = 4000,\n position = \"top-right\",\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const counter = useRef<number>(0);\n\n const dismiss = useCallback((id: string): void => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const show = useCallback(\n (options: ToastOptions): string => {\n const id = options.id ?? `toast-${++counter.current}`;\n const entry: ToastEntry = {\n id,\n title: options.title,\n description: options.description,\n variant: options.variant ?? \"info\",\n duration: options.duration ?? defaultDuration,\n };\n setToasts((current) => [...current, entry]);\n return id;\n },\n [defaultDuration],\n );\n\n const api = useMemo<ToastApi>(\n () => ({\n show,\n dismiss,\n success: (description, options) =>\n show({ ...options, description, variant: \"success\" }),\n error: (description, options) => show({ ...options, description, variant: \"error\" }),\n warning: (description, options) =>\n show({ ...options, description, variant: \"warning\" }),\n info: (description, options) => show({ ...options, description, variant: \"info\" }),\n }),\n [show, dismiss],\n );\n\n return (\n <ToastContext.Provider value={api}>\n {children}\n <ToastContainer toasts={toasts} onDismiss={dismiss} position={position} />\n </ToastContext.Provider>\n );\n}\n\ninterface ContainerProps {\n toasts: ToastEntry[];\n onDismiss: (id: string) => void;\n position: ToastPosition;\n}\n\nfunction positionClass(position: ToastPosition): string {\n switch (position) {\n case \"top-left\":\n return styles.positionTopLeft;\n case \"top-center\":\n return styles.positionTopCenter;\n case \"bottom-right\":\n return styles.positionBottomRight;\n case \"bottom-left\":\n return styles.positionBottomLeft;\n case \"bottom-center\":\n return styles.positionBottomCenter;\n case \"top-right\":\n default:\n return styles.positionTopRight;\n }\n}\n\n/**\n * The portalled stack, and the page's live region for toasts.\n *\n * `aria-atomic=\"false\"` matters: with `\"true\"` a screen reader re-reads the\n * **entire** stack on every change, so the third toast of a batch is announced as\n * all three, and dismissing one re-announces the survivors. `\"false\"` announces only\n * the node that was added, which is what the user needs.\n *\n * The stack stays the live region rather than delegating to `useAnnounce`, because\n * routing it through the shared announcer would put the same text in the document\n * twice — once visible, once hidden — and every `getByText(\"Salvo\")` in a consuming\n * app's test suite would start matching two nodes. The announcer is for messages\n * that have no on-screen home; a toast has one.\n */\nfunction ToastContainer({ toasts, onDismiss, position }: ContainerProps) {\n const portalHost = usePortalHost();\n\n if (!portalHost) return null;\n return createPortal(\n <div\n className={cn(styles.container, positionClass(position))}\n aria-live=\"polite\"\n aria-atomic=\"false\"\n >\n {toasts.map((toast) => (\n <ToastItem key={toast.id} toast={toast} onDismiss={onDismiss} />\n ))}\n </div>,\n portalHost,\n );\n}\n\ninterface ItemProps {\n toast: ToastEntry;\n onDismiss: (id: string) => void;\n}\n\n/**\n * One toast.\n *\n * No `role=\"status\"` of its own: it already lives inside the container's live\n * region, and a live region nested in a live region is announced twice by some\n * screen readers.\n */\nfunction ToastItem({ toast, onDismiss }: ItemProps) {\n useEffect(() => {\n if (!toast.duration) return;\n const timer = setTimeout(() => onDismiss(toast.id), toast.duration);\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onDismiss]);\n\n return (\n <div className={cn(styles.toast, styles[toast.variant])}>\n <div>\n {toast.title && <p className={styles.title}>{toast.title}</p>}\n {toast.description && <p className={styles.description}>{toast.description}</p>}\n </div>\n <button\n type=\"button\"\n className={styles.close}\n aria-label=\"Fechar notificação\"\n onClick={() => onDismiss(toast.id)}\n >\n <CloseIcon />\n </button>\n </div>\n );\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 6l12 12M6 18L18 6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":";;;;;;;AAqDA,IAAM,IAAe,EAA+B,IAAI;AAOxD,SAAgB,IAAqB;CACjC,IAAM,IAAM,EAAW,CAAY;CACnC,IAAI,CAAC,GAAK,MAAU,MAAM,gDAAgD;CAC1E,OAAO;AACX;AAgBA,SAAgB,EAAc,EAC1B,aACA,qBAAkB,KAClB,cAAW,eACQ;CACnB,IAAM,CAAC,GAAQ,KAAa,EAAuB,CAAC,CAAC,GAC/C,IAAU,EAAe,CAAC,GAE1B,IAAU,GAAa,MAAqB;EAC9C,GAAW,MAAY,EAAQ,QAAQ,MAAU,EAAM,OAAO,CAAE,CAAC;CACrE,GAAG,CAAC,CAAC,GAEC,IAAO,GACR,MAAkC;EAC/B,IAAM,IAAK,EAAQ,MAAM,SAAS,EAAE,EAAQ,WACtC,IAAoB;GACtB;GACA,OAAO,EAAQ;GACf,aAAa,EAAQ;GACrB,SAAS,EAAQ,WAAW;GAC5B,UAAU,EAAQ,YAAY;EAClC;EAEA,OADA,GAAW,MAAY,CAAC,GAAG,GAAS,CAAK,CAAC,GACnC;CACX,GACA,CAAC,CAAe,CACpB,GAEM,IAAM,SACD;EACH;EACA;EACA,UAAU,GAAa,MACnB,EAAK;GAAE,GAAG;GAAS;GAAa,SAAS;EAAU,CAAC;EACxD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C,OAAD,EAAA,UAAA,CACK,EAAM,SAAS,kBAAC,KAAD;GAAG,WAAW,EAAO;GAAQ,UAAA,EAAM;EAAS,CAAA,GAC3D,EAAM,eAAe,kBAAC,KAAD;GAAG,WAAW,EAAO;GAAc,UAAA,EAAM;EAAe,CAAA,CAC7E,EAAA,CAAA,GACL,kBAAC,UAAD;GACI,MAAK;GACL,WAAW,EAAO;GAClB,cAAW;GACX,eAAe,EAAU,EAAM,EAAE;GAEjC,UAAA,kBAAC,GAAD,CAAY,CAAA;EACR,CAAA,CACP;;AAEb;AAEA,SAAS,IAAY;CACjB,OACI,kBAAC,OAAD;EAAK,OAAM;EAAK,QAAO;EAAK,SAAQ;EAAY,MAAK;EACjD,UAAA,kBAAC,QAAD;GACI,GAAE;GACF,QAAO;GACP,aAAY;GACZ,eAAc;EACjB,CAAA;CACA,CAAA;AAEb"}
1
+ {"version":3,"file":"ToastProvider.js","names":[],"sources":["../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines — the provider is the queue: enqueue, dedupe, auto-\n * dismiss timers, pause on hover and the portal that renders them. Splitting the\n * queue from the renderer would put a timer in one file and the element it dismisses\n * in another.\n */\nimport {\n Children,\n Fragment,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Toast.module.css\";\nimport { usePortalHost } from \"../Portal/portal-host\";\n\nexport type ToastVariant = \"success\" | \"warning\" | \"error\" | \"info\";\n\n/**\n * Horizontal alignment of a toast's title and description.\n *\n * `\"start\"` is the default because a toast is read as a sentence beside a close\n * button: left-aligned lines share one edge with the icon and the stack, so a\n * two-line description stays scannable. `\"center\"` exists for the short\n * celebratory toast (an achievement with a badge) where the text is one line.\n */\nexport type ToastAlign = \"start\" | \"center\";\n\nexport interface ToastOptions {\n id?: string;\n title?: string;\n description?: string;\n variant?: ToastVariant;\n /** Auto-dismiss timeout in ms. Pass `0` to keep the toast until dismissed manually. */\n duration?: number;\n /**\n * Leading slot rendered before the text, e.g. `<img src=\"/badge.svg\" alt=\"\" />`.\n *\n * It is an app asset, so it takes any `ReactNode` — but it is a slot for an\n * **icon**, not for a control. The wrapper is `inert`, so a button or link put\n * here is neither focusable nor clickable; actions belong outside the toast.\n *\n * The slot is decorative (`aria-hidden`) unless {@link ToastOptions.iconLabel}\n * is given: most icons repeat what the title already says, and an unlabelled\n * image inside the live region would otherwise be announced as \"image\" or by\n * its file name. An `<img>` or `<svg>` anywhere inside it is capped at 32px and\n * keeps its aspect ratio. A node that renders nothing (`null`, a boolean, `\"\"`,\n * `[]`, an empty fragment) counts as no icon, so the toast keeps two columns.\n */\n icon?: ReactNode;\n /**\n * Accessible name for {@link ToastOptions.icon} when the icon carries meaning\n * the text does not. With it the slot becomes `role=\"img\"` with this label and\n * is announced together with the toast; without it the slot is hidden from\n * assistive technology.\n */\n iconLabel?: string;\n /** Text alignment of title and description. Default `\"start\"`; see {@link ToastAlign}. */\n align?: ToastAlign;\n}\n\ninterface ToastEntry extends Required<\n Omit<ToastOptions, \"id\" | \"title\" | \"description\" | \"icon\" | \"iconLabel\">\n> {\n id: string;\n title?: string;\n description?: string;\n icon?: ReactNode;\n iconLabel?: string;\n}\n\nexport interface ToastApi {\n show: (options: ToastOptions) => string;\n dismiss: (id: string) => void;\n success: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n error: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n warning: (\n description: string,\n options?: Omit<ToastOptions, \"variant\" | \"description\">,\n ) => string;\n info: (description: string, options?: Omit<ToastOptions, \"variant\" | \"description\">) => string;\n}\n\nconst ToastContext = createContext<ToastApi | null>(null);\n\n/**\n * Access the toast API. Must be used inside a {@link ToastProvider}.\n *\n * @returns Methods to show and dismiss toasts.\n */\nexport function useToast(): ToastApi {\n const ctx = useContext(ToastContext);\n if (!ctx) throw new Error(\"useToast must be used inside a <ToastProvider>\");\n return ctx;\n}\n\nexport type ToastPosition =\n \"top-right\" | \"top-left\" | \"top-center\" | \"bottom-right\" | \"bottom-left\" | \"bottom-center\";\n\nexport interface ToastProviderProps {\n children: ReactNode;\n /** Default auto-dismiss duration (ms). Default 4000. */\n defaultDuration?: number;\n /** Stack position on screen. Default `\"top-right\"`. */\n position?: ToastPosition;\n}\n\n/**\n * Renders a portalled toast container and exposes the imperative {@link useToast} API.\n */\nexport function ToastProvider({\n children,\n defaultDuration = 4000,\n position = \"top-right\",\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastEntry[]>([]);\n const counter = useRef<number>(0);\n\n const dismiss = useCallback((id: string): void => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const show = useCallback(\n (options: ToastOptions): string => {\n const id = options.id ?? `toast-${++counter.current}`;\n const entry: ToastEntry = {\n id,\n title: options.title,\n description: options.description,\n variant: options.variant ?? \"info\",\n duration: options.duration ?? defaultDuration,\n icon: options.icon,\n iconLabel: options.iconLabel,\n align: options.align ?? \"start\",\n };\n setToasts((current) => [...current, entry]);\n return id;\n },\n [defaultDuration],\n );\n\n const api = useMemo<ToastApi>(\n () => ({\n show,\n dismiss,\n success: (description, options) =>\n show({ ...options, description, variant: \"success\" }),\n error: (description, options) => show({ ...options, description, variant: \"error\" }),\n warning: (description, options) =>\n show({ ...options, description, variant: \"warning\" }),\n info: (description, options) => show({ ...options, description, variant: \"info\" }),\n }),\n [show, dismiss],\n );\n\n return (\n <ToastContext.Provider value={api}>\n {children}\n <ToastContainer toasts={toasts} onDismiss={dismiss} position={position} />\n </ToastContext.Provider>\n );\n}\n\ninterface ContainerProps {\n toasts: ToastEntry[];\n onDismiss: (id: string) => void;\n position: ToastPosition;\n}\n\nfunction positionClass(position: ToastPosition): string {\n switch (position) {\n case \"top-left\":\n return styles.positionTopLeft;\n case \"top-center\":\n return styles.positionTopCenter;\n case \"bottom-right\":\n return styles.positionBottomRight;\n case \"bottom-left\":\n return styles.positionBottomLeft;\n case \"bottom-center\":\n return styles.positionBottomCenter;\n case \"top-right\":\n default:\n return styles.positionTopRight;\n }\n}\n\n/**\n * The portalled stack, and the page's live region for toasts.\n *\n * `aria-atomic=\"false\"` matters: with `\"true\"` a screen reader re-reads the\n * **entire** stack on every change, so the third toast of a batch is announced as\n * all three, and dismissing one re-announces the survivors. `\"false\"` announces only\n * the node that was added, which is what the user needs.\n *\n * The stack stays the live region rather than delegating to `useAnnounce`, because\n * routing it through the shared announcer would put the same text in the document\n * twice — once visible, once hidden — and every `getByText(\"Salvo\")` in a consuming\n * app's test suite would start matching two nodes. The announcer is for messages\n * that have no on-screen home; a toast has one.\n */\nfunction ToastContainer({ toasts, onDismiss, position }: ContainerProps) {\n const portalHost = usePortalHost();\n\n if (!portalHost) return null;\n return createPortal(\n <div\n className={cn(styles.container, positionClass(position))}\n aria-live=\"polite\"\n aria-atomic=\"false\"\n >\n {toasts.map((toast) => (\n <ToastItem key={toast.id} toast={toast} onDismiss={onDismiss} />\n ))}\n </div>,\n portalHost,\n );\n}\n\ninterface ItemProps {\n toast: ToastEntry;\n onDismiss: (id: string) => void;\n}\n\n/**\n * One toast.\n *\n * No `role=\"status\"` of its own: it already lives inside the container's live\n * region, and a live region nested in a live region is announced twice by some\n * screen readers.\n *\n * With an icon the toast becomes three columns (leading, content, close) and the\n * icon and text are centred vertically against each other, so a 32px badge sits\n * level with a one-line title. Toasts without an icon keep the top-aligned layout\n * and the same size for short text; what changed for them is long text: the text\n * column now wraps a long word (`overflow-wrap: anywhere`) and the close button no\n * longer shrinks (it used to drop from 22px to 16–17px beside a two-line\n * description).\n *\n * The leading wrapper gets `inert` through a callback ref instead of a prop,\n * because no prop value works on both supported Reacts: React 18 drops\n * `inert={true}` with a warning and renders `inert=\"\"`, while React 19 renders\n * `inert={true}` and drops `inert=\"\"`.\n */\nfunction ToastItem({ toast, onDismiss }: ItemProps) {\n useEffect(() => {\n if (!toast.duration) return;\n const timer = setTimeout(() => onDismiss(toast.id), toast.duration);\n return () => clearTimeout(timer);\n }, [toast.id, toast.duration, onDismiss]);\n\n const hasIcon = rendersSomething(toast.icon);\n\n return (\n <div\n className={cn(\n styles.toast,\n styles[toast.variant],\n hasIcon && styles.withIcon,\n toast.align === \"center\" && styles.alignCenter,\n )}\n >\n {hasIcon && (\n <div\n ref={makeInert}\n className={styles.leading}\n {...(toast.iconLabel\n ? { role: \"img\", \"aria-label\": toast.iconLabel }\n : { \"aria-hidden\": true })}\n >\n {toast.icon}\n </div>\n )}\n <div className={styles.content}>\n {toast.title && <p className={styles.title}>{toast.title}</p>}\n {toast.description && <p className={styles.description}>{toast.description}</p>}\n </div>\n <button\n type=\"button\"\n className={styles.close}\n aria-label=\"Fechar notificação\"\n onClick={() => onDismiss(toast.id)}\n >\n <CloseIcon />\n </button>\n </div>\n );\n}\n\n/**\n * Whether a node renders anything at all.\n *\n * `Children.toArray` drops `null`, `undefined` and booleans and flattens arrays,\n * but keeps a fragment as one element — so a fragment is unwrapped and checked\n * by its children. `\"\"` renders no text node worth a column either.\n *\n * @param node - The icon slot content.\n * @returns `true` when at least one child would produce output.\n */\nfunction rendersSomething(node: ReactNode): boolean {\n return Children.toArray(node).some((child) => {\n if (child === \"\") return false;\n if (isValidElement<{ children?: ReactNode }>(child) && child.type === Fragment) {\n return rendersSomething(child.props.children);\n }\n return true;\n });\n}\n\n/**\n * Callback ref that marks the icon wrapper `inert`, on React 18 and 19 alike.\n *\n * @param node - The wrapper element, or `null` on unmount.\n */\nfunction makeInert(node: HTMLDivElement | null): void {\n node?.setAttribute(\"inert\", \"\");\n}\n\nfunction CloseIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 6l12 12M6 18L18 6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":";;;;;;;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D;KAAG,WAAW,EAAO;KAAc,UAAA,EAAM;IAAe,CAAA,CAC7E;;GACL,kBAAC,UAAD;IACI,MAAK;IACL,WAAW,EAAO;IAClB,cAAW;IACX,eAAe,EAAU,EAAM,EAAE;IAEjC,UAAA,kBAAC,GAAD,CAAY,CAAA;GACR,CAAA;EACP;;AAEb;AAYA,SAAS,EAAiB,GAA0B;CAChD,OAAO,EAAS,QAAQ,CAAI,CAAC,CAAC,MAAM,MAC5B,MAAU,KAAW,KACrB,EAAyC,CAAK,KAAK,EAAM,SAAS,IAC3D,EAAiB,EAAM,MAAM,QAAQ,IAEzC,EACV;AACL;AAOA,SAAS,EAAU,GAAmC;CAClD,GAAM,aAAa,SAAS,EAAE;AAClC;AAEA,SAAS,IAAY;CACjB,OACI,kBAAC,OAAD;EAAK,OAAM;EAAK,QAAO;EAAK,SAAQ;EAAY,MAAK;EACjD,UAAA,kBAAC,QAAD;GACI,GAAE;GACF,QAAO;GACP,aAAY;GACZ,eAAc;EACjB,CAAA;CACA,CAAA;AAEb"}
@@ -1,2 +1,2 @@
1
- var e=(e,t)=>t==null?`/${e}`:`/${e}/${t}`;function t(t,n={}){let{pageParam:r=`page`,sizeParam:i=`size`,sortFieldParam:a=`order_by`,sortOrderParam:o=`ascending`,sortOrderAsBoolean:s=!0,updateMethod:c=`patch`,buildPath:l=e}=n,u={getList(e,n={}){let{pagination:c,sort:u,filters:d}=n,f={};if(c?.page!=null&&(f[r]=c.page),c?.pageSize!=null&&(f[i]=c.pageSize),u?.field){let e=u.order??`asc`;f[a]=u.field,f[o]=s?e===`asc`:e}if(d)for(let[e,t]of Object.entries(d))f[e]=t;let p={params:f};return t.get(l(e),p)},getOne(e,n){return t.get(l(e,n))},getMany(e,t){return Promise.all(t.map(t=>u.getOne(e,t)))},create(e,n){return t.post(l(e),{body:n})},update(e,n,r){let i=l(e,n);return c===`put`?t.put(i,{body:r}):t.patch(i,{body:r})},deleteOne(e,n){return t.delete(l(e,n))}};return u}exports.createDataProvider=t;
1
+ var e=new Set([``,`.`,`..`]);function t(t){if(t==null)throw TypeError(`Invalid record id ${String(t)}: a record id is required.`);let n=String(t);if(e.has(n))throw TypeError(`Invalid record id ${JSON.stringify(n)}: it would resolve as a path dot-segment.`);return encodeURIComponent(n)}var n=(e,t)=>t==null?`/${e}`:`/${e}/${t}`;function r(e,r={}){let{pageParam:i=`page`,sizeParam:a=`size`,sortFieldParam:o=`order_by`,sortOrderParam:s=`ascending`,sortOrderAsBoolean:c=!0,updateMethod:l=`patch`,buildPath:u=n}=r,d={getList(t,n={}){let{pagination:r,sort:l,filters:d}=n,f={};if(r?.page!=null&&(f[i]=r.page),r?.pageSize!=null&&(f[a]=r.pageSize),l?.field){let e=l.order??`asc`;f[o]=l.field,f[s]=c?e===`asc`:e}if(d)for(let[e,t]of Object.entries(d))f[e]=t;let p={params:f};return e.get(u(t),p)},async getOne(n,r){return e.get(u(n,t(r)))},getMany(e,t){return Promise.all(t.map(t=>d.getOne(e,t)))},create(t,n){return e.post(u(t),{body:n})},async update(n,r,i){let a=u(n,t(r));return l===`put`?e.put(a,{body:i}):e.patch(a,{body:i})},async deleteOne(n,r){return e.delete(u(n,t(r)))}};return d}exports.createDataProvider=r,exports.encodeIdSegment=t;
2
2
  //# sourceMappingURL=create-data-provider.cjs.map