@cognite/aura 1.46715.0 → 1.46766.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.
@@ -41,8 +41,8 @@ export function plainPreMarkup(code) {
41
41
  return `<pre><code>${escapeHtml(code)}</code></pre>`;
42
42
  }
43
43
  const CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS = 'min(60vh, 32rem)';
44
- const codeHtmlInnerClassName = 'dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';
45
- const codeHtmlInnerDarkClassName = 'hidden dark:block [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';
44
+ const codeHtmlInnerClassName = 'dark:hidden [&>pre]:m-0 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';
45
+ const codeHtmlInnerDarkClassName = 'hidden dark:block [&>pre]:m-0 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';
46
46
  const CodeBlock = /*#__PURE__*/ forwardRef(({ code, copyText, language, showLineNumbers = false, collapsed = false, className, children, style: styleFromProps, ...props }, ref)=>{
47
47
  const [html, setHtml] = useState('');
48
48
  const [darkHtml, setDarkHtml] = useState('');
@@ -121,17 +121,18 @@ const CodeBlock = /*#__PURE__*/ forwardRef(({ code, copyText, language, showLine
121
121
  isCollapsed,
122
122
  lineCount
123
123
  ]);
124
+ const preMinHeightClassName = children != null ? '[&>pre]:min-h-17' : '[&>pre]:min-h-10';
124
125
  const codeBody = /*#__PURE__*/ _jsxs("div", {
125
126
  className: "relative",
126
127
  children: [
127
128
  /*#__PURE__*/ _jsx("div", {
128
- className: cn(codeHtmlInnerClassName, showCollapsedChrome && 'max-h-26 overflow-y-hidden'),
129
+ className: cn(codeHtmlInnerClassName, preMinHeightClassName, showCollapsedChrome && 'max-h-26 overflow-y-hidden'),
129
130
  dangerouslySetInnerHTML: {
130
131
  __html: isStorybookTestEnv ? storybookMarkup : html
131
132
  }
132
133
  }),
133
134
  /*#__PURE__*/ _jsx("div", {
134
- className: cn(codeHtmlInnerDarkClassName, showCollapsedChrome && 'max-h-26 overflow-y-hidden'),
135
+ className: cn(codeHtmlInnerDarkClassName, preMinHeightClassName, showCollapsedChrome && 'max-h-26 overflow-y-hidden'),
135
136
  dangerouslySetInnerHTML: {
136
137
  __html: isStorybookTestEnv ? storybookMarkup : darkHtml
137
138
  }
@@ -143,7 +144,7 @@ const CodeBlock = /*#__PURE__*/ forwardRef(({ code, copyText, language, showLine
143
144
  });
144
145
  const actions = children != null ? /*#__PURE__*/ _jsx("div", {
145
146
  "data-slot": "code-block-actions",
146
- className: cn(/* Sibling of scroll inner: pinned while code scrolls; even inset from top/right (scrollbar gutter on inner) */ 'pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none', 'opacity-0 transition-opacity', 'group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100', 'group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100', isStorybookTestEnv && 'pointer-events-auto opacity-100'),
147
+ className: cn(/* Sibling of scroll inner: pinned while code scrolls; right inset clears the scrollbar gutter on inner. Inner pre min-h-17 (68px) keeps top-5 + size-7 buttons (48px) plus a 20px bottom inset inside the root overflow-hidden on single-line blocks */ 'pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none', 'opacity-0 transition-opacity', 'group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100', 'group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100', isStorybookTestEnv && 'pointer-events-auto opacity-100'),
147
148
  children: children
148
149
  }) : null;
149
150
  return /*#__PURE__*/ _jsx(CodeBlockContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/ui/core/code-block/code-block.tsx"],"sourcesContent":["/* eslint-disable @eslint-react/dom/no-dangerously-set-innerhtml */\nimport {\n type ComponentProps,\n type ComponentRef,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type RefAttributes,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n IconCheck,\n IconCopy,\n IconDownload,\n IconSelector,\n} from '@tabler/icons-react';\n\nimport {\n highlightCode,\n type CodeLanguage,\n} from '../../../../lib/highlight-code';\nimport { cn, isStorybookTestEnv } from '../../../../lib/utils';\nimport { Button } from '../button/button';\n\ntype CodeBlockProps = HTMLAttributes<HTMLDivElement> & {\n code: string;\n copyText?: string;\n collapsed?: boolean;\n language: CodeLanguage;\n showLineNumbers?: boolean;\n};\n\ntype CodeBlockContextType = {\n code: string;\n copyText: string;\n isCollapsed: boolean;\n setIsCollapsed: (collapsed: boolean) => void;\n lineCount: number;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n code: '',\n copyText: '',\n isCollapsed: false,\n setIsCollapsed: () => undefined,\n lineCount: 0,\n});\n\nconst escapeHtml = (value: string): string =>\n value\n .replaceAll('&', '&amp;')\n .replaceAll('<', '&lt;')\n .replaceAll('>', '&gt;')\n .replaceAll('\"', '&quot;')\n .replaceAll(\"'\", '&#39;');\n\n/** Collapsed \"large\" preview: only this much is committed to the DOM (plain text, no Shiki spans). */\nconst PREVIEW_MAX_LINES = 14;\nconst PREVIEW_MAX_CHARS = 8_000;\n\n/** Beyond this size we do not run Shiki in expanded mode (plain &lt;pre&gt; only). */\nconst MAX_LINES_FULL_SHIKI = 400;\nconst MAX_CHARS_FULL_SHIKI = 16_384;\n\nconst CODE_BLOCK_COLLAPSIBLE_MIN_LINES = 1;\n\nexport function getCollapsedPreviewDisplay(code: string): string {\n const lines = code.split('\\n');\n let truncated = false;\n let slice = lines.slice(0, PREVIEW_MAX_LINES).join('\\n');\n if (lines.length > PREVIEW_MAX_LINES) {\n truncated = true;\n }\n if (slice.length > PREVIEW_MAX_CHARS) {\n slice = slice.slice(0, PREVIEW_MAX_CHARS);\n truncated = true;\n }\n const body = slice.length === 0 ? ' ' : slice;\n return truncated ? `${body}\\n…` : body;\n}\n\nexport function isContentLargerThanPreview(code: string): boolean {\n return (\n code.split('\\n').length > PREVIEW_MAX_LINES ||\n code.length > PREVIEW_MAX_CHARS\n );\n}\n\nexport function shouldUsePlainTextInsteadOfShiki(\n code: string,\n lineCount: number\n): boolean {\n return lineCount > MAX_LINES_FULL_SHIKI || code.length > MAX_CHARS_FULL_SHIKI;\n}\n\nexport function plainPreMarkup(code: string): string {\n return `<pre><code>${escapeHtml(code)}</code></pre>`;\n}\n\nconst CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS = 'min(60vh, 32rem)';\n\nconst codeHtmlInnerClassName =\n 'dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';\n\nconst codeHtmlInnerDarkClassName =\n 'hidden dark:block [&>pre]:m-0 [&>pre]:min-h-10 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';\n\nconst CodeBlock: ForwardRefExoticComponent<\n HTMLAttributes<HTMLDivElement> & {\n code: string;\n copyText?: string;\n collapsed?: boolean;\n language: CodeLanguage;\n showLineNumbers?: boolean;\n } & RefAttributes<HTMLDivElement>\n> = forwardRef<ComponentRef<'div'>, CodeBlockProps>(\n (\n {\n code,\n copyText,\n language,\n showLineNumbers = false,\n collapsed = false,\n className,\n children,\n style: styleFromProps,\n ...props\n },\n ref\n ) => {\n const [html, setHtml] = useState<string>('');\n const [darkHtml, setDarkHtml] = useState<string>('');\n const [isCollapsed, setIsCollapsed] = useState(collapsed);\n\n const codeForRender = code.length === 0 ? ' ' : code;\n const lineCount = code.split('\\n').length;\n const isCollapsible = lineCount > CODE_BLOCK_COLLAPSIBLE_MIN_LINES;\n const showCollapsedChrome = isCollapsed && isCollapsible;\n const textToCopy = copyText ?? code;\n\n const storybookMarkup = useMemo(\n () =>\n isStorybookTestEnv\n ? `<pre><code>${escapeHtml(codeForRender)}</code></pre>`\n : '',\n [codeForRender]\n );\n\n useEffect(() => {\n if (isStorybookTestEnv) return;\n\n let isCancelled = false;\n\n const applyPlain = (source: string) => {\n if (!isCancelled) {\n const markup = plainPreMarkup(source);\n setHtml(markup);\n setDarkHtml(markup);\n }\n };\n\n // Collapsed + large: Shiki only on the truncated preview source (not the full blob).\n if (isCollapsed && isContentLargerThanPreview(codeForRender)) {\n const previewSource = getCollapsedPreviewDisplay(codeForRender);\n highlightCode(previewSource, language, showLineNumbers)\n .then(([light, dark]) => {\n if (!isCancelled) {\n setHtml(light);\n setDarkHtml(dark);\n }\n })\n .catch((error: unknown) => {\n console.error('Failed to highlight code:', error);\n applyPlain(previewSource);\n });\n return () => {\n isCancelled = true;\n };\n }\n\n // Expanded + very large: full plain text (no tokenized spans).\n if (\n !isCollapsed &&\n shouldUsePlainTextInsteadOfShiki(codeForRender, lineCount)\n ) {\n queueMicrotask(() => {\n applyPlain(codeForRender);\n });\n return () => {\n isCancelled = true;\n };\n }\n\n highlightCode(codeForRender, language, showLineNumbers)\n .then(([light, dark]) => {\n if (!isCancelled) {\n setHtml(light);\n setDarkHtml(dark);\n }\n })\n .catch((error: unknown) => {\n console.error('Failed to highlight code:', error);\n applyPlain(codeForRender);\n });\n\n return () => {\n isCancelled = true;\n };\n }, [codeForRender, language, showLineNumbers, isCollapsed, lineCount]);\n\n const contextValue = useMemo(\n () => ({\n code,\n copyText: textToCopy,\n isCollapsed,\n setIsCollapsed,\n lineCount,\n }),\n [code, textToCopy, isCollapsed, lineCount]\n );\n\n const codeBody = (\n <div className=\"relative\">\n <div\n className={cn(\n codeHtmlInnerClassName,\n showCollapsedChrome && 'max-h-26 overflow-y-hidden'\n )}\n dangerouslySetInnerHTML={{\n __html: isStorybookTestEnv ? storybookMarkup : html,\n }}\n />\n <div\n className={cn(\n codeHtmlInnerDarkClassName,\n showCollapsedChrome && 'max-h-26 overflow-y-hidden'\n )}\n dangerouslySetInnerHTML={{\n __html: isStorybookTestEnv ? storybookMarkup : darkHtml,\n }}\n />\n {showCollapsedChrome && (\n <div className=\"pointer-events-none absolute bottom-0 left-0 right-0 h-3/4 bg-linear-to-b from-transparent via-card-background/70 to-card-background\" />\n )}\n </div>\n );\n\n const actions =\n children != null ? (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n /* Sibling of scroll inner: pinned while code scrolls; even inset from top/right (scrollbar gutter on inner) */\n 'pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none',\n 'opacity-0 transition-opacity',\n 'group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100',\n 'group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100',\n isStorybookTestEnv && 'pointer-events-auto opacity-100'\n )}\n >\n {children}\n </div>\n ) : null;\n\n return (\n <CodeBlockContext.Provider value={contextValue}>\n <div\n ref={ref}\n data-slot=\"code-block\"\n className={cn(\n 'group/code-block relative w-full rounded-xl bg-card-background text-medium-foreground',\n showCollapsedChrome\n ? 'overflow-hidden'\n : /* Expanded: flex + clip so actions overlay without a reserved top row */\n 'flex min-h-0 max-h-[min(60vh,_32rem)] flex-col overflow-hidden',\n className\n )}\n style={{\n ...(!showCollapsedChrome\n ? {\n maxHeight: CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS,\n minHeight: 0,\n }\n : {}),\n ...styleFromProps,\n }}\n {...props}\n >\n <div\n className={cn(\n /* Match <pre> card tone so transparent actions are not over root bg-background */\n 'relative min-h-0 bg-card-background',\n !showCollapsedChrome &&\n 'min-h-0 flex-1 overflow-x-auto overflow-y-auto [scrollbar-gutter:stable]'\n )}\n >\n {codeBody}\n </div>\n {actions}\n </div>\n </CodeBlockContext.Provider>\n );\n }\n);\nCodeBlock.displayName = 'CodeBlock';\n\ntype CodeBlockCopyButtonProps = ComponentProps<typeof Button> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nconst CodeBlockCopyButton: ForwardRefExoticComponent<\n Omit<CodeBlockCopyButtonProps, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockCopyButtonProps>(\n ({ onCopy, onError, timeout = 2000, children, className, ...props }, ref) => {\n const [isCopied, setIsCopied] = useState(false);\n const { copyText } = useContext(CodeBlockContext);\n\n const copyToClipboard = async () => {\n if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {\n onError?.(new Error('Clipboard API not available'));\n return;\n }\n\n try {\n await navigator.clipboard.writeText(copyText);\n setIsCopied(true);\n onCopy?.();\n setTimeout(() => setIsCopied(false), timeout);\n } catch (error: unknown) {\n console.warn('Clipboard write failed:', error);\n onError?.(\n error instanceof Error ? error : new Error('Clipboard write failed')\n );\n }\n };\n\n const Icon = isCopied ? IconCheck : IconCopy;\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-copy-button\"\n className={cn('shrink-0', className)}\n onClick={copyToClipboard}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <Icon size={14} />}\n </Button>\n );\n }\n);\nCodeBlockCopyButton.displayName = 'CodeBlockCopyButton';\n\ntype CodeBlockCollapseButtonProps = ComponentProps<typeof Button>;\n\nconst CodeBlockCollapseButton: ForwardRefExoticComponent<\n Omit<ComponentProps<typeof Button>, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockCollapseButtonProps>(\n ({ children, className, ...props }, ref) => {\n const { isCollapsed, setIsCollapsed, lineCount } =\n useContext(CodeBlockContext);\n\n if (lineCount <= CODE_BLOCK_COLLAPSIBLE_MIN_LINES) {\n return null;\n }\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-collapse-button\"\n className={cn('shrink-0', className)}\n onClick={() => setIsCollapsed(!isCollapsed)}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <IconSelector size={14} />}\n </Button>\n );\n }\n);\nCodeBlockCollapseButton.displayName = 'CodeBlockCollapseButton';\n\ntype CodeBlockDownloadButtonProps = ComponentProps<typeof Button> & {\n fileName?: string;\n mimeType?: string;\n onDownload?: () => void;\n onError?: (error: Error) => void;\n};\n\nconst CodeBlockDownloadButton: ForwardRefExoticComponent<\n Omit<CodeBlockDownloadButtonProps, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockDownloadButtonProps>(\n (\n {\n fileName = 'code.txt',\n mimeType = 'text/plain;charset=utf-8',\n onDownload,\n onError,\n children,\n className,\n ...props\n },\n ref\n ) => {\n const { code } = useContext(CodeBlockContext);\n\n const download = () => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n onError?.(new Error('Download not available'));\n return;\n }\n\n try {\n const blob = new Blob([code], { type: mimeType });\n const url = URL.createObjectURL(blob);\n\n const a = document.createElement('a');\n a.href = url;\n a.download = fileName;\n a.rel = 'noopener';\n a.click();\n\n URL.revokeObjectURL(url);\n onDownload?.();\n } catch (error: unknown) {\n onError?.(\n error instanceof Error ? error : new Error('Download failed')\n );\n }\n };\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-download-button\"\n className={cn('shrink-0', className)}\n onClick={download}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <IconDownload size={14} />}\n </Button>\n );\n }\n);\nCodeBlockDownloadButton.displayName = 'CodeBlockDownloadButton';\n\nexport {\n CodeBlock,\n CodeBlockCollapseButton,\n CodeBlockCopyButton,\n CodeBlockDownloadButton,\n};\n"],"names":["createContext","forwardRef","useContext","useEffect","useMemo","useState","IconCheck","IconCopy","IconDownload","IconSelector","highlightCode","cn","isStorybookTestEnv","Button","CodeBlockContext","code","copyText","isCollapsed","setIsCollapsed","undefined","lineCount","escapeHtml","value","replaceAll","PREVIEW_MAX_LINES","PREVIEW_MAX_CHARS","MAX_LINES_FULL_SHIKI","MAX_CHARS_FULL_SHIKI","CODE_BLOCK_COLLAPSIBLE_MIN_LINES","getCollapsedPreviewDisplay","lines","split","truncated","slice","join","length","body","isContentLargerThanPreview","shouldUsePlainTextInsteadOfShiki","plainPreMarkup","CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS","codeHtmlInnerClassName","codeHtmlInnerDarkClassName","CodeBlock","language","showLineNumbers","collapsed","className","children","style","styleFromProps","props","ref","html","setHtml","darkHtml","setDarkHtml","codeForRender","isCollapsible","showCollapsedChrome","textToCopy","storybookMarkup","isCancelled","applyPlain","source","markup","previewSource","then","light","dark","catch","error","console","queueMicrotask","contextValue","codeBody","div","dangerouslySetInnerHTML","__html","actions","data-slot","Provider","maxHeight","minHeight","displayName","CodeBlockCopyButton","onCopy","onError","timeout","isCopied","setIsCopied","copyToClipboard","window","navigator","clipboard","writeText","Error","setTimeout","warn","Icon","onClick","size","variant","CodeBlockCollapseButton","CodeBlockDownloadButton","fileName","mimeType","onDownload","download","document","blob","Blob","type","url","URL","createObjectURL","a","createElement","href","rel","click","revokeObjectURL"],"mappings":";AAAA,iEAAiE,GACjE,SAMEA,aAAa,EACbC,UAAU,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4B,aAAU;QACVjC,WAAWpC,GAAG,YAAYoC;QAC1BqD,SAASQ;QACTP,MAAK;QACLC,SAAQ;QACP,GAAGnD,KAAK;kBAERH,0BAAY,KAACxC;YAAa6F,MAAM;;;AAGvC;AAEFG,wBAAwBpB,WAAW,GAAG;AAEtC,SACEzC,SAAS,EACT4D,uBAAuB,EACvBlB,mBAAmB,EACnBmB,uBAAuB,GACvB"}
1
+ {"version":3,"sources":["../../../../../src/components/ui/core/code-block/code-block.tsx"],"sourcesContent":["/* eslint-disable @eslint-react/dom/no-dangerously-set-innerhtml */\nimport {\n type ComponentProps,\n type ComponentRef,\n type ForwardRefExoticComponent,\n type HTMLAttributes,\n type RefAttributes,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nimport {\n IconCheck,\n IconCopy,\n IconDownload,\n IconSelector,\n} from '@tabler/icons-react';\n\nimport {\n highlightCode,\n type CodeLanguage,\n} from '../../../../lib/highlight-code';\nimport { cn, isStorybookTestEnv } from '../../../../lib/utils';\nimport { Button } from '../button/button';\n\ntype CodeBlockProps = HTMLAttributes<HTMLDivElement> & {\n code: string;\n copyText?: string;\n collapsed?: boolean;\n language: CodeLanguage;\n showLineNumbers?: boolean;\n};\n\ntype CodeBlockContextType = {\n code: string;\n copyText: string;\n isCollapsed: boolean;\n setIsCollapsed: (collapsed: boolean) => void;\n lineCount: number;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n code: '',\n copyText: '',\n isCollapsed: false,\n setIsCollapsed: () => undefined,\n lineCount: 0,\n});\n\nconst escapeHtml = (value: string): string =>\n value\n .replaceAll('&', '&amp;')\n .replaceAll('<', '&lt;')\n .replaceAll('>', '&gt;')\n .replaceAll('\"', '&quot;')\n .replaceAll(\"'\", '&#39;');\n\n/** Collapsed \"large\" preview: only this much is committed to the DOM (plain text, no Shiki spans). */\nconst PREVIEW_MAX_LINES = 14;\nconst PREVIEW_MAX_CHARS = 8_000;\n\n/** Beyond this size we do not run Shiki in expanded mode (plain &lt;pre&gt; only). */\nconst MAX_LINES_FULL_SHIKI = 400;\nconst MAX_CHARS_FULL_SHIKI = 16_384;\n\nconst CODE_BLOCK_COLLAPSIBLE_MIN_LINES = 1;\n\nexport function getCollapsedPreviewDisplay(code: string): string {\n const lines = code.split('\\n');\n let truncated = false;\n let slice = lines.slice(0, PREVIEW_MAX_LINES).join('\\n');\n if (lines.length > PREVIEW_MAX_LINES) {\n truncated = true;\n }\n if (slice.length > PREVIEW_MAX_CHARS) {\n slice = slice.slice(0, PREVIEW_MAX_CHARS);\n truncated = true;\n }\n const body = slice.length === 0 ? ' ' : slice;\n return truncated ? `${body}\\n…` : body;\n}\n\nexport function isContentLargerThanPreview(code: string): boolean {\n return (\n code.split('\\n').length > PREVIEW_MAX_LINES ||\n code.length > PREVIEW_MAX_CHARS\n );\n}\n\nexport function shouldUsePlainTextInsteadOfShiki(\n code: string,\n lineCount: number\n): boolean {\n return lineCount > MAX_LINES_FULL_SHIKI || code.length > MAX_CHARS_FULL_SHIKI;\n}\n\nexport function plainPreMarkup(code: string): string {\n return `<pre><code>${escapeHtml(code)}</code></pre>`;\n}\n\nconst CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS = 'min(60vh, 32rem)';\n\nconst codeHtmlInnerClassName =\n 'dark:hidden [&>pre]:m-0 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';\n\nconst codeHtmlInnerDarkClassName =\n 'hidden dark:block [&>pre]:m-0 [&>pre]:bg-card-background [&>pre]:p-2 [&>pre]:text-medium-foreground [&>pre]:leading-[18px] [&>pre]:tracking-[-0.08px] [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm [&>pre]:overflow-x-auto';\n\nconst CodeBlock: ForwardRefExoticComponent<\n HTMLAttributes<HTMLDivElement> & {\n code: string;\n copyText?: string;\n collapsed?: boolean;\n language: CodeLanguage;\n showLineNumbers?: boolean;\n } & RefAttributes<HTMLDivElement>\n> = forwardRef<ComponentRef<'div'>, CodeBlockProps>(\n (\n {\n code,\n copyText,\n language,\n showLineNumbers = false,\n collapsed = false,\n className,\n children,\n style: styleFromProps,\n ...props\n },\n ref\n ) => {\n const [html, setHtml] = useState<string>('');\n const [darkHtml, setDarkHtml] = useState<string>('');\n const [isCollapsed, setIsCollapsed] = useState(collapsed);\n\n const codeForRender = code.length === 0 ? ' ' : code;\n const lineCount = code.split('\\n').length;\n const isCollapsible = lineCount > CODE_BLOCK_COLLAPSIBLE_MIN_LINES;\n const showCollapsedChrome = isCollapsed && isCollapsible;\n const textToCopy = copyText ?? code;\n\n const storybookMarkup = useMemo(\n () =>\n isStorybookTestEnv\n ? `<pre><code>${escapeHtml(codeForRender)}</code></pre>`\n : '',\n [codeForRender]\n );\n\n useEffect(() => {\n if (isStorybookTestEnv) return;\n\n let isCancelled = false;\n\n const applyPlain = (source: string) => {\n if (!isCancelled) {\n const markup = plainPreMarkup(source);\n setHtml(markup);\n setDarkHtml(markup);\n }\n };\n\n // Collapsed + large: Shiki only on the truncated preview source (not the full blob).\n if (isCollapsed && isContentLargerThanPreview(codeForRender)) {\n const previewSource = getCollapsedPreviewDisplay(codeForRender);\n highlightCode(previewSource, language, showLineNumbers)\n .then(([light, dark]) => {\n if (!isCancelled) {\n setHtml(light);\n setDarkHtml(dark);\n }\n })\n .catch((error: unknown) => {\n console.error('Failed to highlight code:', error);\n applyPlain(previewSource);\n });\n return () => {\n isCancelled = true;\n };\n }\n\n // Expanded + very large: full plain text (no tokenized spans).\n if (\n !isCollapsed &&\n shouldUsePlainTextInsteadOfShiki(codeForRender, lineCount)\n ) {\n queueMicrotask(() => {\n applyPlain(codeForRender);\n });\n return () => {\n isCancelled = true;\n };\n }\n\n highlightCode(codeForRender, language, showLineNumbers)\n .then(([light, dark]) => {\n if (!isCancelled) {\n setHtml(light);\n setDarkHtml(dark);\n }\n })\n .catch((error: unknown) => {\n console.error('Failed to highlight code:', error);\n applyPlain(codeForRender);\n });\n\n return () => {\n isCancelled = true;\n };\n }, [codeForRender, language, showLineNumbers, isCollapsed, lineCount]);\n\n const contextValue = useMemo(\n () => ({\n code,\n copyText: textToCopy,\n isCollapsed,\n setIsCollapsed,\n lineCount,\n }),\n [code, textToCopy, isCollapsed, lineCount]\n );\n\n const preMinHeightClassName =\n children != null ? '[&>pre]:min-h-17' : '[&>pre]:min-h-10';\n\n const codeBody = (\n <div className=\"relative\">\n <div\n className={cn(\n codeHtmlInnerClassName,\n preMinHeightClassName,\n showCollapsedChrome && 'max-h-26 overflow-y-hidden'\n )}\n dangerouslySetInnerHTML={{\n __html: isStorybookTestEnv ? storybookMarkup : html,\n }}\n />\n <div\n className={cn(\n codeHtmlInnerDarkClassName,\n preMinHeightClassName,\n showCollapsedChrome && 'max-h-26 overflow-y-hidden'\n )}\n dangerouslySetInnerHTML={{\n __html: isStorybookTestEnv ? storybookMarkup : darkHtml,\n }}\n />\n {showCollapsedChrome && (\n <div className=\"pointer-events-none absolute bottom-0 left-0 right-0 h-3/4 bg-linear-to-b from-transparent via-card-background/70 to-card-background\" />\n )}\n </div>\n );\n\n const actions =\n children != null ? (\n <div\n data-slot=\"code-block-actions\"\n className={cn(\n /* Sibling of scroll inner: pinned while code scrolls; right inset clears the scrollbar gutter on inner. Inner pre min-h-17 (68px) keeps top-5 + size-7 buttons (48px) plus a 20px bottom inset inside the root overflow-hidden on single-line blocks */\n 'pointer-events-none absolute top-5 right-5 z-20 flex items-center gap-1 bg-transparent p-0 shadow-none ring-0 outline-none',\n 'opacity-0 transition-opacity',\n 'group-hover/code-block:pointer-events-auto group-hover/code-block:opacity-100',\n 'group-focus-within/code-block:pointer-events-auto group-focus-within/code-block:opacity-100',\n isStorybookTestEnv && 'pointer-events-auto opacity-100'\n )}\n >\n {children}\n </div>\n ) : null;\n\n return (\n <CodeBlockContext.Provider value={contextValue}>\n <div\n ref={ref}\n data-slot=\"code-block\"\n className={cn(\n 'group/code-block relative w-full rounded-xl bg-card-background text-medium-foreground',\n showCollapsedChrome\n ? 'overflow-hidden'\n : /* Expanded: flex + clip so actions overlay without a reserved top row */\n 'flex min-h-0 max-h-[min(60vh,_32rem)] flex-col overflow-hidden',\n className\n )}\n style={{\n ...(!showCollapsedChrome\n ? {\n maxHeight: CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS,\n minHeight: 0,\n }\n : {}),\n ...styleFromProps,\n }}\n {...props}\n >\n <div\n className={cn(\n /* Match <pre> card tone so transparent actions are not over root bg-background */\n 'relative min-h-0 bg-card-background',\n !showCollapsedChrome &&\n 'min-h-0 flex-1 overflow-x-auto overflow-y-auto [scrollbar-gutter:stable]'\n )}\n >\n {codeBody}\n </div>\n {actions}\n </div>\n </CodeBlockContext.Provider>\n );\n }\n);\nCodeBlock.displayName = 'CodeBlock';\n\ntype CodeBlockCopyButtonProps = ComponentProps<typeof Button> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nconst CodeBlockCopyButton: ForwardRefExoticComponent<\n Omit<CodeBlockCopyButtonProps, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockCopyButtonProps>(\n ({ onCopy, onError, timeout = 2000, children, className, ...props }, ref) => {\n const [isCopied, setIsCopied] = useState(false);\n const { copyText } = useContext(CodeBlockContext);\n\n const copyToClipboard = async () => {\n if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {\n onError?.(new Error('Clipboard API not available'));\n return;\n }\n\n try {\n await navigator.clipboard.writeText(copyText);\n setIsCopied(true);\n onCopy?.();\n setTimeout(() => setIsCopied(false), timeout);\n } catch (error: unknown) {\n console.warn('Clipboard write failed:', error);\n onError?.(\n error instanceof Error ? error : new Error('Clipboard write failed')\n );\n }\n };\n\n const Icon = isCopied ? IconCheck : IconCopy;\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-copy-button\"\n className={cn('shrink-0', className)}\n onClick={copyToClipboard}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <Icon size={14} />}\n </Button>\n );\n }\n);\nCodeBlockCopyButton.displayName = 'CodeBlockCopyButton';\n\ntype CodeBlockCollapseButtonProps = ComponentProps<typeof Button>;\n\nconst CodeBlockCollapseButton: ForwardRefExoticComponent<\n Omit<ComponentProps<typeof Button>, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockCollapseButtonProps>(\n ({ children, className, ...props }, ref) => {\n const { isCollapsed, setIsCollapsed, lineCount } =\n useContext(CodeBlockContext);\n\n if (lineCount <= CODE_BLOCK_COLLAPSIBLE_MIN_LINES) {\n return null;\n }\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-collapse-button\"\n className={cn('shrink-0', className)}\n onClick={() => setIsCollapsed(!isCollapsed)}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <IconSelector size={14} />}\n </Button>\n );\n }\n);\nCodeBlockCollapseButton.displayName = 'CodeBlockCollapseButton';\n\ntype CodeBlockDownloadButtonProps = ComponentProps<typeof Button> & {\n fileName?: string;\n mimeType?: string;\n onDownload?: () => void;\n onError?: (error: Error) => void;\n};\n\nconst CodeBlockDownloadButton: ForwardRefExoticComponent<\n Omit<CodeBlockDownloadButtonProps, 'ref'> & RefAttributes<HTMLElement>\n> = forwardRef<ComponentRef<typeof Button>, CodeBlockDownloadButtonProps>(\n (\n {\n fileName = 'code.txt',\n mimeType = 'text/plain;charset=utf-8',\n onDownload,\n onError,\n children,\n className,\n ...props\n },\n ref\n ) => {\n const { code } = useContext(CodeBlockContext);\n\n const download = () => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n onError?.(new Error('Download not available'));\n return;\n }\n\n try {\n const blob = new Blob([code], { type: mimeType });\n const url = URL.createObjectURL(blob);\n\n const a = document.createElement('a');\n a.href = url;\n a.download = fileName;\n a.rel = 'noopener';\n a.click();\n\n URL.revokeObjectURL(url);\n onDownload?.();\n } catch (error: unknown) {\n onError?.(\n error instanceof Error ? error : new Error('Download failed')\n );\n }\n };\n\n return (\n <Button\n ref={ref}\n data-slot=\"code-block-download-button\"\n className={cn('shrink-0', className)}\n onClick={download}\n size=\"icon-sm\"\n variant=\"secondary\"\n {...props}\n >\n {children ?? <IconDownload size={14} />}\n </Button>\n );\n }\n);\nCodeBlockDownloadButton.displayName = 'CodeBlockDownloadButton';\n\nexport {\n CodeBlock,\n CodeBlockCollapseButton,\n CodeBlockCopyButton,\n CodeBlockDownloadButton,\n};\n"],"names":["createContext","forwardRef","useContext","useEffect","useMemo","useState","IconCheck","IconCopy","IconDownload","IconSelector","highlightCode","cn","isStorybookTestEnv","Button","CodeBlockContext","code","copyText","isCollapsed","setIsCollapsed","undefined","lineCount","escapeHtml","value","replaceAll","PREVIEW_MAX_LINES","PREVIEW_MAX_CHARS","MAX_LINES_FULL_SHIKI","MAX_CHARS_FULL_SHIKI","CODE_BLOCK_COLLAPSIBLE_MIN_LINES","getCollapsedPreviewDisplay","lines","split","truncated","slice","join","length","body","isContentLargerThanPreview","shouldUsePlainTextInsteadOfShiki","plainPreMarkup","CODE_BLOCK_EXPANDED_MAX_HEIGHT_CSS","codeHtmlInnerClassName","codeHtmlInnerDarkClassName","CodeBlock","language","showLineNumbers","collapsed","className","children","style","styleFromProps","props","ref","html","setHtml","darkHtml","setDarkHtml","codeForRender","isCollapsible","showCollapsedChrome","textToCopy","storybookMarkup","isCancelled","applyPlain","source","markup","previewSource","then","light","dark","catch","error","console","queueMicrotask","contextValue","preMinHeightClassName","codeBody","div","dangerouslySetInnerHTML","__html","actions","data-slot","Provider","maxHeight","minHeight","displayName","CodeBlockCopyButton","onCopy","onError","timeout","isCopied","setIsCopied","copyToClipboard","window","navigator","clipboard","writeText","Error","setTimeout","warn","Icon","onClick","size","variant","CodeBlockCollapseButton","CodeBlockDownloadButton","fileName","mimeType","onDownload","download","document","blob","Blob","type","url","UR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AIO,eAAe,CAACR;YACpBN;QACF,EAAE,OAAOrC,OAAgB;YACvBiB,UACEjB,iBAAiB0B,QAAQ1B,QAAQ,IAAI0B,MAAM;QAE/C;IACF;IAEA,qBACE,KAACpF;QACCuC,KAAKA;QACL6B,aAAU;QACVlC,WAAWpC,GAAG,YAAYoC;QAC1BsD,SAASQ;QACTP,MAAK;QACLC,SAAQ;QACP,GAAGpD,KAAK;kBAERH,0BAAY,KAACxC;YAAa8F,MAAM;;;AAGvC;AAEFG,wBAAwBpB,WAAW,GAAG;AAEtC,SACE1C,SAAS,EACT6D,uBAAuB,EACvBlB,mBAAmB,EACnBmB,uBAAuB,GACvB"}
@@ -9,7 +9,8 @@ function DataGridColumnResizer({ header, columnLabel }) {
9
9
  "aria-label": `Resize ${columnLabel}`,
10
10
  "data-slot": "data-grid-column-resizer",
11
11
  "data-resizing": isResizing ? '' : undefined,
12
- className: cn('absolute top-0 right-0 z-20 h-full w-2', 'cursor-col-resize touch-none select-none', 'opacity-0', 'group-hover/header:opacity-100 data-resizing:opacity-100', 'before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border'),
12
+ className: cn(// z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the handle.
13
+ 'absolute top-0 right-0 z-[20] h-full w-2', 'cursor-col-resize touch-none select-none', 'opacity-0', 'group-hover/header:opacity-100 data-resizing:opacity-100', 'before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border'),
13
14
  onMouseDown: resizeHandler,
14
15
  onTouchStart: resizeHandler,
15
16
  onClick: (event)=>event.stopPropagation(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-column-resizer.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport type { Header } from '@tanstack/react-table';\n\nimport { cn } from '../../../../lib/utils';\n\ntype DataGridColumnResizerProps<TData> = {\n header: Header<TData, unknown>;\n columnLabel: string;\n};\n\nfunction DataGridColumnResizer<TData>({\n header,\n columnLabel,\n}: DataGridColumnResizerProps<TData>): ReactElement {\n const isResizing = header.column.getIsResizing();\n const resizeHandler = header.getResizeHandler();\n\n return (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={`Resize ${columnLabel}`}\n data-slot=\"data-grid-column-resizer\"\n data-resizing={isResizing ? '' : undefined}\n className={cn(\n 'absolute top-0 right-0 z-20 h-full w-2',\n 'cursor-col-resize touch-none select-none',\n 'opacity-0',\n 'group-hover/header:opacity-100 data-resizing:opacity-100',\n 'before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border'\n )}\n onMouseDown={resizeHandler}\n onTouchStart={resizeHandler}\n onClick={(event) => event.stopPropagation()}\n onDoubleClick={(event) => {\n event.stopPropagation();\n header.column.resetSize();\n }}\n />\n );\n}\n\nexport { DataGridColumnResizer, type DataGridColumnResizerProps };\n"],"names":["cn","DataGridColumnResizer","header","columnLabel","isResizing","column","getIsResizing","resizeHandler","getResizeHandler","div","role","aria-orientation","aria-label","data-slot","data-resizing","undefined","className","onMouseDown","onTouchStart","onClick","event","stopPropagation","onDoubleClick","resetSize"],"mappings":";AAIA,SAASA,EAAE,QAAQ,2BAAwB;AAO3C,SAASC,sBAA6B,EACpCC,MAAM,EACNC,WAAW,EACuB;IAClC,MAAMC,aAAaF,OAAOG,MAAM,CAACC,aAAa;IAC9C,MAAMC,gBAAgBL,OAAOM,gBAAgB;IAE7C,qBACE,KAACC;QACCC,MAAK;QACLC,oBAAiB;QACjBC,cAAY,CAAC,OAAO,EAAET,aAAa;QACnCU,aAAU;QACVC,iBAAeV,aAAa,KAAKW;QACjCC,WAAWhB,GACT,0CACA,4CACA,aACA,4DACA;QAEFiB,aAAaV;QACbW,cAAcX;QACdY,SAAS,CAACC,QAAUA,MAAMC,eAAe;QACzCC,eAAe,CAACF;YACdA,MAAMC,eAAe;YACrBnB,OAAOG,MAAM,CAACkB,SAAS;QACzB;;AAGN;AAEA,SAAStB,qBAAqB,GAAoC"}
1
+ {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-column-resizer.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\n\nimport type { Header } from '@tanstack/react-table';\n\nimport { cn } from '../../../../lib/utils';\n\ntype DataGridColumnResizerProps<TData> = {\n header: Header<TData, unknown>;\n columnLabel: string;\n};\n\nfunction DataGridColumnResizer<TData>({\n header,\n columnLabel,\n}: DataGridColumnResizerProps<TData>): ReactElement {\n const isResizing = header.column.getIsResizing();\n const resizeHandler = header.getResizeHandler();\n\n return (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={`Resize ${columnLabel}`}\n data-slot=\"data-grid-column-resizer\"\n data-resizing={isResizing ? '' : undefined}\n className={cn(\n // z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the handle.\n 'absolute top-0 right-0 z-[20] h-full w-2',\n 'cursor-col-resize touch-none select-none',\n 'opacity-0',\n 'group-hover/header:opacity-100 data-resizing:opacity-100',\n 'before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border'\n )}\n onMouseDown={resizeHandler}\n onTouchStart={resizeHandler}\n onClick={(event) => event.stopPropagation()}\n onDoubleClick={(event) => {\n event.stopPropagation();\n header.column.resetSize();\n }}\n />\n );\n}\n\nexport { DataGridColumnResizer, type DataGridColumnResizerProps };\n"],"names":["cn","DataGridColumnResizer","header","columnLabel","isResizing","column","getIsResizing","resizeHandler","getResizeHandler","div","role","aria-orientation","aria-label","data-slot","data-resizing","undefined","className","onMouseDown","onTouchStart","onClick","event","stopPropagation","onDoubleClick","resetSize"],"mappings":";AAIA,SAASA,EAAE,QAAQ,2BAAwB;AAO3C,SAASC,sBAA6B,EACpCC,MAAM,EACNC,WAAW,EACuB;IAClC,MAAMC,aAAaF,OAAOG,MAAM,CAACC,aAAa;IAC9C,MAAMC,gBAAgBL,OAAOM,gBAAgB;IAE7C,qBACE,KAACC;QACCC,MAAK;QACLC,oBAAiB;QACjBC,cAAY,CAAC,OAAO,EAAET,aAAa;QACnCU,aAAU;QACVC,iBAAeV,aAAa,KAAKW;QACjCC,WAAWhB,GACT,wFAAwF;QACxF,4CACA,4CACA,aACA,4DACA;QAEFiB,aAAaV;QACbW,cAAcX;QACdY,SAAS,CAACC,QAAUA,MAAMC,eAAe;QACzCC,eAAe,CAACF;YACdA,MAAMC,eAAe;YACrBnB,OAAOG,MAAM,CAACkB,SAAS;QACzB;;AAGN;AAEA,SAAStB,qBAAqB,GAAoC"}
@@ -11,7 +11,8 @@ function DataGridHeaderRow({ headerGroup, headerRowIndex, resolvedHeaderHeight,
11
11
  "data-slot": "data-grid-header-row",
12
12
  role: "row",
13
13
  "aria-rowindex": headerRowIndex + 1,
14
- className: cn('sticky z-20 grid bg-background', headerRowIndex === 0 ? 'border-y' : 'border-b'),
14
+ className: cn(// z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the header row.
15
+ 'sticky z-[20] grid bg-background', headerRowIndex === 0 ? 'border-y' : 'border-b'),
15
16
  style: {
16
17
  top: headerRowIndex * resolvedHeaderHeight,
17
18
  gridTemplateColumns: 'var(--data-grid-template-columns)',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-header-row.tsx"],"sourcesContent":["import { type ReactElement, useId } from 'react';\n\nimport { IconArrowDown, IconSelector } from '@tabler/icons-react';\nimport { type HeaderGroup, flexRender } from '@tanstack/react-table';\n\nimport { cn, focusState } from '../../../../lib/utils';\n\nimport { DataGridColumnResizer } from './data-grid-column-resizer';\nimport { PINNED_COLUMN_Z_INDEX, getAriaSort } from './data-grid.utils';\n\ntype DataGridHeaderRowProps<TData> = {\n headerGroup: HeaderGroup<TData>;\n headerRowIndex: number;\n resolvedHeaderHeight: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n isResizingColumn: boolean;\n};\n\nfunction DataGridHeaderRow<TData>({\n headerGroup,\n headerRowIndex,\n resolvedHeaderHeight,\n pinnedColumnIds,\n lastPinnedColumnId,\n isResizingColumn,\n}: DataGridHeaderRowProps<TData>): ReactElement {\n const headerRowInstanceId = useId();\n\n return (\n <div\n data-slot=\"data-grid-header-row\"\n role=\"row\"\n aria-rowindex={headerRowIndex + 1}\n className={cn(\n 'sticky z-20 grid bg-background',\n headerRowIndex === 0 ? 'border-y' : 'border-b'\n )}\n style={{\n top: headerRowIndex * resolvedHeaderHeight,\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n minHeight: resolvedHeaderHeight,\n }}\n >\n {headerGroup.headers.map((header) => {\n const isLeafHeader = header.colSpan === 1;\n const isPinned = isLeafHeader && pinnedColumnIds.has(header.column.id);\n const isLastPinned =\n isPinned && lastPinnedColumnId === header.column.id;\n const sortDirection = header.column.getIsSorted();\n const canSort = isLeafHeader && header.column.getCanSort();\n const isGroupedHeader = header.colSpan > 1;\n const renderedHeader = header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext());\n const isPlainTextHeader =\n typeof renderedHeader === 'string' ||\n typeof renderedHeader === 'number';\n const showResizer = isLeafHeader && header.column.getCanResize();\n const isResizing = showResizer && header.column.getIsResizing();\n const headerTitleId = `${headerRowInstanceId}-${header.id}-title`;\n\n return (\n <div\n key={header.id}\n data-slot=\"data-grid-column-header\"\n role=\"columnheader\"\n aria-colindex={header.index + 1}\n aria-colspan={header.colSpan > 1 ? header.colSpan : undefined}\n aria-sort={getAriaSort(sortDirection, canSort)}\n aria-labelledby={showResizer ? headerTitleId : undefined}\n className={cn(\n 'group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm font-medium text-muted-foreground',\n header.index === 0 ? 'pl-4' : 'pl-3',\n isGroupedHeader &&\n 'justify-center text-base font-semibold text-foreground/70',\n header.isPlaceholder && 'pointer-events-none',\n isPinned && 'sticky left-0 z-10 bg-background',\n isLastPinned && 'shadow-pinned-column',\n (canSort || showResizer) &&\n !isResizingColumn &&\n 'hover:bg-medium-background-hover',\n isResizing && 'bg-medium-background-hover'\n )}\n style={{\n gridColumn: `span ${header.colSpan} / span ${header.colSpan}`,\n ...(isPinned\n ? {\n position: 'sticky',\n left: header.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : {}),\n }}\n >\n <div\n id={showResizer ? headerTitleId : undefined}\n className=\"flex min-w-0 items-center\"\n >\n {canSort ? (\n <button\n type=\"button\"\n className={cn(\n 'group/sort inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm select-none',\n focusState\n )}\n onClick={header.column.getToggleSortingHandler()}\n >\n {isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">\n {renderedHeader}\n </span>\n ) : (\n renderedHeader\n )}\n {sortDirection ? (\n <IconArrowDown\n aria-hidden=\"true\"\n className={cn(\n 'size-3.5 shrink-0',\n sortDirection === 'asc' && 'rotate-180'\n )}\n />\n ) : (\n <IconSelector\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 opacity-30 group-hover/header:opacity-100 group-focus-visible/sort:opacity-100\"\n />\n )}\n </button>\n ) : isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">{renderedHeader}</span>\n ) : (\n renderedHeader\n )}\n </div>\n {showResizer && (\n <DataGridColumnResizer\n header={header}\n columnLabel={\n isPlainTextHeader ? String(renderedHeader) : header.column.id\n }\n />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridHeaderRow, type DataGridHeaderRowProps };\n"],"names":["useId","IconArrowDown","IconSelector","flexRender","cn","focusState","DataGridColumnResizer","PINNED_COLUMN_Z_INDEX","getAriaSort","DataGridHeaderRow","headerGroup","headerRowIndex","resolvedHeaderHeight","pinnedColumnIds","lastPinnedColumnId","isResizingColumn","headerRowInstanceId","div","data-slot","role","aria-rowindex","className","style","top","gridTemplateColumns","minHeight","headers","map","header","isLeafHeader","colSpan","isPinned","has","column","id","isLastPinned","sortDirection","getIsSorted","canSort","getCanSort","isGroupedHeader","renderedHeader","isPlaceholder","columnDef","getContext","isPlainTextHeader","showResizer","getCanResize","isResizing","getIsResizing","headerTitleId","aria-colindex","index","aria-colspan","undefined","aria-sort","aria-labelledby","gridColumn","position","left","getStart","zIndex","button","type","onClick","getToggleSortingHandler","span","aria-hidden","columnLabel","String"],"mappings":";AAAA,SAA4BA,KAAK,QAAQ,QAAQ;AAEjD,SAASC,aAAa,EAAEC,YAAY,QAAQ,sBAAsB;AAClE,SAA2BC,UAAU,QAAQ,wBAAwB;AAErE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AAEvD,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SAASC,qBAAqB,EAAEC,WAAW,QAAQ,uBAAoB;AAWvE,SAASC,kBAAyB,EAChCC,WAAW,EACXC,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,kBAAkB,EAClBC,gBAAgB,EACc;IAC9B,MAAMC,sBAAsBhB;IAE5B,qBACE,KAACiB;QACCC,aAAU;QACVC,MAAK;QACLC,iBAAeT,iBAAiB;QAChCU,WAAWjB,GACT,kCACAO,mBAAmB,IAAI,aAAa;QAEtCW,OAAO;YACLC,KAAKZ,iBAAiBC;YACtBY,qBAAqB;YACrBC,WAAWb;QACb;kBAECF,YAAYgB,OAAO,CAACC,GAAG,CAAC,CAACC;YACxB,MAAMC,eAAeD,OAAOE,OAAO,KAAK;YACxC,MAAMC,WAAWF,gBAAgBhB,gBAAgBmB,GAAG,CAACJ,OAAOK,MAAM,CAACC,EAAE;YACrE,MAAMC,eACJJ,YAAYjB,uBAAuBc,OAAOK,MAAM,CAACC,EAAE;YACrD,MAAME,gBAAgBR,OAAOK,MAAM,CAACI,WAAW;YAC/C,MAAMC,UAAUT,gBAAgBD,OAAOK,MAAM,CAACM,UAAU;YACxD,MAAMC,kBAAkBZ,OAAOE,OAAO,GAAG;YACzC,MAAMW,iBAAiBb,OAAOc,aAAa,GACvC,OACAvC,WAAWyB,OAAOK,MAAM,CAACU,SAAS,CAACf,MAAM,EAA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gC,kBAAkB,SAAS;mDAI/B,KAAClC;oCACCiE,eAAY;oCACZ9C,WAAU;;;6BAIdwB,kCACF,KAACqB;4BAAK7C,WAAU;sCAA0BoB;6BAE1CA;;oBAGHK,6BACC,KAACxC;wBACCsB,QAAQA;wBACRwC,aACEvB,oBAAoBwB,OAAO5B,kBAAkBb,OAAOK,MAAM,CAACC,EAAE;;;eA5E9DN,OAAOM,EAAE;QAkFpB;;AAGN;AAEA,SAASzB,iBAAiB,GAAgC"}
1
+ {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-header-row.tsx"],"sourcesContent":["import { type ReactElement, useId } from 'react';\n\nimport { IconArrowDown, IconSelector } from '@tabler/icons-react';\nimport { type HeaderGroup, flexRender } from '@tanstack/react-table';\n\nimport { cn, focusState } from '../../../../lib/utils';\n\nimport { DataGridColumnResizer } from './data-grid-column-resizer';\nimport { PINNED_COLUMN_Z_INDEX, getAriaSort } from './data-grid.utils';\n\ntype DataGridHeaderRowProps<TData> = {\n headerGroup: HeaderGroup<TData>;\n headerRowIndex: number;\n resolvedHeaderHeight: number;\n pinnedColumnIds: Set<string>;\n lastPinnedColumnId: string | undefined;\n isResizingColumn: boolean;\n};\n\nfunction DataGridHeaderRow<TData>({\n headerGroup,\n headerRowIndex,\n resolvedHeaderHeight,\n pinnedColumnIds,\n lastPinnedColumnId,\n isResizingColumn,\n}: DataGridHeaderRowProps<TData>): ReactElement {\n const headerRowInstanceId = useId();\n\n return (\n <div\n data-slot=\"data-grid-header-row\"\n role=\"row\"\n aria-rowindex={headerRowIndex + 1}\n className={cn(\n // z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the header row.\n 'sticky z-[20] grid bg-background',\n headerRowIndex === 0 ? 'border-y' : 'border-b'\n )}\n style={{\n top: headerRowIndex * resolvedHeaderHeight,\n gridTemplateColumns: 'var(--data-grid-template-columns)',\n minHeight: resolvedHeaderHeight,\n }}\n >\n {headerGroup.headers.map((header) => {\n const isLeafHeader = header.colSpan === 1;\n const isPinned = isLeafHeader && pinnedColumnIds.has(header.column.id);\n const isLastPinned =\n isPinned && lastPinnedColumnId === header.column.id;\n const sortDirection = header.column.getIsSorted();\n const canSort = isLeafHeader && header.column.getCanSort();\n const isGroupedHeader = header.colSpan > 1;\n const renderedHeader = header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext());\n const isPlainTextHeader =\n typeof renderedHeader === 'string' ||\n typeof renderedHeader === 'number';\n const showResizer = isLeafHeader && header.column.getCanResize();\n const isResizing = showResizer && header.column.getIsResizing();\n const headerTitleId = `${headerRowInstanceId}-${header.id}-title`;\n\n return (\n <div\n key={header.id}\n data-slot=\"data-grid-column-header\"\n role=\"columnheader\"\n aria-colindex={header.index + 1}\n aria-colspan={header.colSpan > 1 ? header.colSpan : undefined}\n aria-sort={getAriaSort(sortDirection, canSort)}\n aria-labelledby={showResizer ? headerTitleId : undefined}\n className={cn(\n 'group/header relative flex min-w-0 items-center overflow-hidden pr-3 text-left text-sm font-medium text-muted-foreground',\n header.index === 0 ? 'pl-4' : 'pl-3',\n isGroupedHeader &&\n 'justify-center text-base font-semibold text-foreground/70',\n header.isPlaceholder && 'pointer-events-none',\n isPinned && 'sticky left-0 z-10 bg-background',\n isLastPinned && 'shadow-pinned-column',\n (canSort || showResizer) &&\n !isResizingColumn &&\n 'hover:bg-medium-background-hover',\n isResizing && 'bg-medium-background-hover'\n )}\n style={{\n gridColumn: `span ${header.colSpan} / span ${header.colSpan}`,\n ...(isPinned\n ? {\n position: 'sticky',\n left: header.column.getStart('left'),\n zIndex: PINNED_COLUMN_Z_INDEX,\n }\n : {}),\n }}\n >\n <div\n id={showResizer ? headerTitleId : undefined}\n className=\"flex min-w-0 items-center\"\n >\n {canSort ? (\n <button\n type=\"button\"\n className={cn(\n 'group/sort inline-flex min-w-0 max-w-full cursor-pointer items-center gap-1 rounded-sm select-none',\n focusState\n )}\n onClick={header.column.getToggleSortingHandler()}\n >\n {isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">\n {renderedHeader}\n </span>\n ) : (\n renderedHeader\n )}\n {sortDirection ? (\n <IconArrowDown\n aria-hidden=\"true\"\n className={cn(\n 'size-3.5 shrink-0',\n sortDirection === 'asc' && 'rotate-180'\n )}\n />\n ) : (\n <IconSelector\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 opacity-30 group-hover/header:opacity-100 group-focus-visible/sort:opacity-100\"\n />\n )}\n </button>\n ) : isPlainTextHeader ? (\n <span className=\"block min-w-0 truncate\">{renderedHeader}</span>\n ) : (\n renderedHeader\n )}\n </div>\n {showResizer && (\n <DataGridColumnResizer\n header={header}\n columnLabel={\n isPlainTextHeader ? String(renderedHeader) : header.column.id\n }\n />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\nexport { DataGridHeaderRow, type DataGridHeaderRowProps };\n"],"names":["useId","IconArrowDown","IconSelector","flexRender","cn","focusState","DataGridColumnResizer","PINNED_COLUMN_Z_INDEX","getAriaSort","DataGridHeaderRow","headerGroup","headerRowIndex","resolvedHeaderHeight","pinnedColumnIds","lastPinnedColumnId","isResizingColumn","headerRowInstanceId","div","data-slot","role","aria-rowindex","className","style","top","gridTemplateColumns","minHeight","headers","map","header","isLeafHeader","colSpan","isPinned","has","column","id","isLastPinned","sortDirection","getIsSorted","canSort","getCanSort","isGroupedHeader","renderedHeader","isPlaceholder","columnDef","getContext","isPlainTextHeader","showResizer","getCanResize","isResizing","getIsResizing","headerTitleId","aria-colindex","index","aria-colspan","undefined","aria-sort","aria-labelledby","gridColumn","position","left","getStart","zIndex","button","type","onClick","getToggleSortingHandler","span","aria-hidden","columnLabel","String"],"mappings":";AAAA,SAA4BA,KAAK,QAAQ,QAAQ;AAEjD,SAASC,aAAa,EAAEC,YAAY,QAAQ,sBAAsB;AAClE,SAA2BC,UAAU,QAAQ,wBAAwB;AAErE,SAASC,EAAE,EAAEC,UAAU,QAAQ,2BAAwB;AAEvD,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SAASC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AAOE,OAAO,GAAG,IAAIF,OAAOE,OAAO,GAAGwB;gBACpDC,aAAW/C,YAAY4B,eAAeE;gBACtCkB,mBAAiBV,cAAcI,gBAAgBI;gBAC/CjC,WAAWjB,GACT,4HACAwB,OAAOwB,KAAK,KAAK,IAAI,SAAS,QAC9BZ,mBACE,6DACFZ,OAAOc,aAAa,IAAI,uBACxBX,YAAY,oCACZI,gBAAgB,wBAChB,AAACG,CAAAA,WAAWQ,WAAU,KACpB,CAAC/B,oBACD,oCACFiC,cAAc;gBAEhB1B,OAAO;oBACLmC,YAAY,CAAC,KAAK,EAAE7B,OAAOE,OAAO,CAAC,QAAQ,EAAEF,OAAOE,OAAO,EAAE;oBAC7D,GAAIC,WACA;wBACE2B,UAAU;wBACVC,MAAM/B,OAAOK,MAAM,CAAC2B,QAAQ,CAAC;wBAC7BC,QAAQtD;oBACV,IACA,CAAC,CAAC;gBACR;;kCAEA,KAACU;wBACCiB,IAAIY,cAAcI,gBAAgBI;wBAClCjC,WAAU;kCAETiB,wBACC,MAACwB;4BACCC,MAAK;4BACL1C,WAAWjB,GACT,sGACAC;4BAEF2D,SAASpC,OAAOK,MAAM,CAACgC,uBAAuB;;gCAE7CpB,kCACC,KAACqB;oCAAK7C,WAAU;8CACboB;qCAGHA;gCAEDL,8BACC,KAACnC;oCACCkE,eAAY;oCACZ9C,WAAWjB,GACT,qBACAgC,kBAAkB,SAAS;mDAI/B,KAAClC;oCACCiE,eAAY;oCACZ9C,WAAU;;;6BAIdwB,kCACF,KAACqB;4BAAK7C,WAAU;sCAA0BoB;6BAE1CA;;oBAGHK,6BACC,KAACxC;wBACCsB,QAAQA;wBACRwC,aACEvB,oBAAoBwB,OAAO5B,kBAAkBb,OAAOK,MAAM,CAACC,EAAE;;;eA5E9DN,OAAOM,EAAE;QAkFpB;;AAGN;AAEA,SAASzB,iBAAiB,GAAgC"}
@@ -17,8 +17,9 @@ function DataGridSelectionToolbar({ selectedCount, rowSelection, selectionAction
17
17
  }, [
18
18
  secondaryActionCount
19
19
  ]);
20
- return /*#__PURE__*/ _jsx("div", {
21
- className: "pointer-events-none sticky bottom-4 z-20 flex justify-center px-4",
20
+ return(// z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the toolbar.
21
+ /*#__PURE__*/ _jsx("div", {
22
+ className: "pointer-events-none sticky bottom-4 z-[20] flex justify-center px-4",
22
23
  children: /*#__PURE__*/ _jsxs(ActionToolbar, {
23
24
  selectedCount: selectedCount,
24
25
  width: "full",
@@ -59,7 +60,7 @@ function DataGridSelectionToolbar({ selectedCount, rowSelection, selectionAction
59
60
  })
60
61
  ]
61
62
  })
62
- });
63
+ }));
63
64
  }
64
65
  function DataGridSecondaryToolbarAction({ action, rowSelection }) {
65
66
  if (action.label != null) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection-toolbar.tsx"],"sourcesContent":["import { useEffect, type ReactElement } from 'react';\n\nimport { IconDotsVertical } from '@tabler/icons-react';\nimport type { RowSelectionState } from '@tanstack/react-table';\n\nimport {\n ActionToolbar,\n ActionToolbarAction,\n ActionToolbarActionClear,\n ActionToolbarActions,\n ActionToolbarPrimaryAction,\n ActionToolbarSelection,\n ActionToolbarSelectionSummary,\n} from '../action-toolbar/action-toolbar';\nimport { Button } from '../button/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../dropdown-menu/dropdown-menu';\n\nimport type {\n DataGridSecondaryAction,\n DataGridSelectionAction,\n DataGridSelectionActions,\n} from './data-grid-selection.types';\n\ntype DataGridSelectionToolbarProps = {\n selectedCount: number;\n rowSelection: RowSelectionState;\n selectionActions?: DataGridSelectionActions;\n onClear: () => void;\n};\n\nconst MAX_SECONDARY_ACTIONS = 5;\n\nfunction DataGridSelectionToolbar({\n selectedCount,\n rowSelection,\n selectionActions,\n onClear,\n}: DataGridSelectionToolbarProps): ReactElement {\n const primaryAction = selectionActions?.primaryAction;\n const requestedSecondaryActions = selectionActions?.secondaryActions ?? [];\n const secondaryActions = limitSecondaryActions(requestedSecondaryActions);\n const menuActions = selectionActions?.menuActions ?? [];\n\n const secondaryActionCount = requestedSecondaryActions.length;\n\n useEffect(() => {\n if (secondaryActionCount <= MAX_SECONDARY_ACTIONS) return;\n console.warn(\n `[Aura DataGrid] The selection toolbar shows at most ${MAX_SECONDARY_ACTIONS} secondary actions. ` +\n 'Move the rest to menuActions.'\n );\n }, [secondaryActionCount]);\n\n return (\n <div className=\"pointer-events-none sticky bottom-4 z-20 flex justify-center px-4\">\n <ActionToolbar\n selectedCount={selectedCount}\n width=\"full\"\n aria-label=\"Selection actions\"\n className=\"pointer-events-auto\"\n >\n <ActionToolbarSelection aria-label=\"Selected rows\">\n <ActionToolbarSelectionSummary />\n <ActionToolbarActionClear onClick={onClear} />\n </ActionToolbarSelection>\n <ActionToolbarActions aria-label=\"Actions\">\n {menuActions.length > 0 ? (\n <DataGridSelectionMenu\n actions={menuActions}\n rowSelection={rowSelection}\n />\n ) : null}\n {secondaryActions.map((action: DataGridSecondaryAction) => (\n <DataGridSecondaryToolbarAction\n key={actionListKey(secondaryActions, action)}\n action={action}\n rowSelection={rowSelection}\n />\n ))}\n {primaryAction ? (\n <ActionToolbarPrimaryAction\n onClick={() => primaryAction.onClick(rowSelection)}\n >\n {primaryAction.icon ? (\n <span aria-hidden=\"true\">{primaryAction.icon}</span>\n ) : null}\n {primaryAction.label}\n </ActionToolbarPrimaryAction>\n ) : null}\n </ActionToolbarActions>\n </ActionToolbar>\n </div>\n );\n}\n\nfunction DataGridSecondaryToolbarAction({\n action,\n rowSelection,\n}: {\n action: DataGridSecondaryAction;\n rowSelection: RowSelectionState;\n}): ReactElement {\n if (action.label != null) {\n return (\n <ActionToolbarAction onClick={() => action.onClick(rowSelection)}>\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </ActionToolbarAction>\n );\n }\n\n return (\n <ActionToolbarAction\n iconOnly\n aria-label={action['aria-label']}\n onClick={() => action.onClick(rowSelection)}\n >\n <span aria-hidden=\"true\">{action.icon}</span>\n </ActionToolbarAction>\n );\n}\n\nfunction DataGridSelectionMenu({\n actions,\n rowSelection,\n}: {\n actions: readonly DataGridSelectionAction[];\n rowSelection: RowSelectionState;\n}): ReactElement {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button variant=\"ghostOnDark\" size=\"icon\" aria-label=\"More actions\">\n <IconDotsVertical aria-hidden=\"true\" />\n </Button>\n }\n />\n <DropdownMenuContent side=\"top\" align=\"end\">\n {actions.map((action: DataGridSelectionAction) => (\n <DropdownMenuItem\n key={actionListKey(actions, action)}\n onClick={() => action.onClick(rowSelection)}\n >\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nfunction actionListKey<T extends { label?: string; 'aria-label'?: string }>(\n actions: readonly T[],\n action: T\n): string {\n const name = action.label ?? action['aria-label'] ?? '';\n const earlierDuplicates = actions\n .slice(0, actions.indexOf(action))\n .filter(\n (candidate) => (candidate.label ?? candidate['aria-label']) === name\n ).length;\n if (earlierDuplicates === 0) return name;\n return `${name}-${earlierDuplicates + 1}`;\n}\n\nfunction limitSecondaryActions(\n actions: readonly DataGridSecondaryAction[]\n): readonly DataGridSecondaryAction[] {\n return actions.slice(0, MAX_SECONDARY_ACTIONS);\n}\n\nexport { DataGridSelectionToolbar };\n"],"names":["useEffect","IconDotsVertical","ActionToolbar","ActionToolbarAction","ActionToolbarActionClear","ActionToolbarActions","ActionToolbarPrimaryAction","ActionToolbarSelection","ActionToolbarSelectionSummary","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","MAX_SECONDARY_ACTIONS","DataGridSelectionToolbar","selectedCount","rowSelection","selectionActions","onClear","primaryAction","requestedSecondaryActions","secondaryActions","limitSecondaryActions","menuActions","secondaryActionCount","length","console","warn","div","className","width","aria-label","onClick","DataGridSelectionMenu","actions","map","action","DataGridSecondaryToolbarAction","actionListKey","icon","span","aria-hidden","label","iconOnly","render","variant","size","side","align","name","earlierDuplicates","slice","indexOf","filter","candidate"],"mappings":";AAAA,SAASA,SAAS,QAA2B,QAAQ;AAErD,SAASC,gBAAgB,QAAQ,sBAAsB;AAGvD,SACEC,aAAa,EACbC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,sBAAsB,EACtBC,6BAA6B,QACxB,sCAAmC;AAC1C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SACEC,YAAY,EACZC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,QACd,oCAAiC;AAexC,MAAMC,wBAAwB;AAE9B,SAASC,yBAAyB,EAChCC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,OAAO,EACuB;IAC9B,MAAMC,gBAAgBF,kBAAkBE;IACxC,MAAMC,4BAA4BH,kBAAkBI,oBAAoB,EAAE;IAC1E,MAAMA,mBAAmBC,sBAAsBF;IAC/C,MAAMG,cAAcN,kBAAkBM,eAAe,EAAE;IAEvD,MAAMC,uBAAuBJ,0BAA0BK,MAAM;IAE7D1B,UAAU;QACR,IAAIyB,wBAAwBX,uBAAuB;QACnDa,QAAQC,IAAI,CACV,CAAC,oDAAoD,EAAEd,sBAAsB,oBAAoB,CAAC,GAChG;IAEN,GAAG;QAACW;KAAqB;IAEzB,qBACE,KAACI;QAAIC,WAAU;kBACb,cAAA,MAAC5B;YACCc,eAAeA;YACfe,OAAM;YACNC,cAAW;YACXF,WAAU;;8BAEV,MAACvB;oBAAuByB,cAAW;;sCACjC,KAACxB;sCACD,KAACJ;4BAAyB6B,SAASd;;;;8BAErC,MAACd;oBAAqB2B,cAAW;;wBAC9BR,YAAYE,MAAM,GAAG,kBACpB,KAACQ;4BACCC,SAASX;4BACTP,cAAcA;6BAEd;wBACHK,iBAAiBc,GAAG,CAAC,CAACC,uBACr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Ob,OAAOM,KAAK,IAAIN,MAAM,CAAC,aAAa,IAAI;IACrD,MAAMc,oBAAoBhB,QACvBiB,KAAK,CAAC,GAAGjB,QAAQkB,OAAO,CAAChB,SACzBiB,MAAM,CACL,CAACC,YAAc,AAACA,CAAAA,UAAUZ,KAAK,IAAIY,SAAS,CAAC,aAAa,AAAD,MAAOL,MAChExB,MAAM;IACV,IAAIyB,sBAAsB,GAAG,OAAOD;IACpC,OAAO,GAAGA,KAAK,CAAC,EAAEC,oBAAoB,GAAG;AAC3C;AAEA,SAAS5B,sBACPY,OAA2C;IAE3C,OAAOA,QAAQiB,KAAK,CAAC,GAAGtC;AAC1B;AAEA,SAASC,wBAAwB,GAAG"}
1
+ {"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection-toolbar.tsx"],"sourcesContent":["import { useEffect, type ReactElement } from 'react';\n\nimport { IconDotsVertical } from '@tabler/icons-react';\nimport type { RowSelectionState } from '@tanstack/react-table';\n\nimport {\n ActionToolbar,\n ActionToolbarAction,\n ActionToolbarActionClear,\n ActionToolbarActions,\n ActionToolbarPrimaryAction,\n ActionToolbarSelection,\n ActionToolbarSelectionSummary,\n} from '../action-toolbar/action-toolbar';\nimport { Button } from '../button/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../dropdown-menu/dropdown-menu';\n\nimport type {\n DataGridSecondaryAction,\n DataGridSelectionAction,\n DataGridSelectionActions,\n} from './data-grid-selection.types';\n\ntype DataGridSelectionToolbarProps = {\n selectedCount: number;\n rowSelection: RowSelectionState;\n selectionActions?: DataGridSelectionActions;\n onClear: () => void;\n};\n\nconst MAX_SECONDARY_ACTIONS = 5;\n\nfunction DataGridSelectionToolbar({\n selectedCount,\n rowSelection,\n selectionActions,\n onClear,\n}: DataGridSelectionToolbarProps): ReactElement {\n const primaryAction = selectionActions?.primaryAction;\n const requestedSecondaryActions = selectionActions?.secondaryActions ?? [];\n const secondaryActions = limitSecondaryActions(requestedSecondaryActions);\n const menuActions = selectionActions?.menuActions ?? [];\n\n const secondaryActionCount = requestedSecondaryActions.length;\n\n useEffect(() => {\n if (secondaryActionCount <= MAX_SECONDARY_ACTIONS) return;\n console.warn(\n `[Aura DataGrid] The selection toolbar shows at most ${MAX_SECONDARY_ACTIONS} secondary actions. ` +\n 'Move the rest to menuActions.'\n );\n }, [secondaryActionCount]);\n\n return (\n // z-[20]: cogs defines `.z-20` as box-shadow; EOS loads it and would shadow the toolbar.\n <div className=\"pointer-events-none sticky bottom-4 z-[20] flex justify-center px-4\">\n <ActionToolbar\n selectedCount={selectedCount}\n width=\"full\"\n aria-label=\"Selection actions\"\n className=\"pointer-events-auto\"\n >\n <ActionToolbarSelection aria-label=\"Selected rows\">\n <ActionToolbarSelectionSummary />\n <ActionToolbarActionClear onClick={onClear} />\n </ActionToolbarSelection>\n <ActionToolbarActions aria-label=\"Actions\">\n {menuActions.length > 0 ? (\n <DataGridSelectionMenu\n actions={menuActions}\n rowSelection={rowSelection}\n />\n ) : null}\n {secondaryActions.map((action: DataGridSecondaryAction) => (\n <DataGridSecondaryToolbarAction\n key={actionListKey(secondaryActions, action)}\n action={action}\n rowSelection={rowSelection}\n />\n ))}\n {primaryAction ? (\n <ActionToolbarPrimaryAction\n onClick={() => primaryAction.onClick(rowSelection)}\n >\n {primaryAction.icon ? (\n <span aria-hidden=\"true\">{primaryAction.icon}</span>\n ) : null}\n {primaryAction.label}\n </ActionToolbarPrimaryAction>\n ) : null}\n </ActionToolbarActions>\n </ActionToolbar>\n </div>\n );\n}\n\nfunction DataGridSecondaryToolbarAction({\n action,\n rowSelection,\n}: {\n action: DataGridSecondaryAction;\n rowSelection: RowSelectionState;\n}): ReactElement {\n if (action.label != null) {\n return (\n <ActionToolbarAction onClick={() => action.onClick(rowSelection)}>\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </ActionToolbarAction>\n );\n }\n\n return (\n <ActionToolbarAction\n iconOnly\n aria-label={action['aria-label']}\n onClick={() => action.onClick(rowSelection)}\n >\n <span aria-hidden=\"true\">{action.icon}</span>\n </ActionToolbarAction>\n );\n}\n\nfunction DataGridSelectionMenu({\n actions,\n rowSelection,\n}: {\n actions: readonly DataGridSelectionAction[];\n rowSelection: RowSelectionState;\n}): ReactElement {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button variant=\"ghostOnDark\" size=\"icon\" aria-label=\"More actions\">\n <IconDotsVertical aria-hidden=\"true\" />\n </Button>\n }\n />\n <DropdownMenuContent side=\"top\" align=\"end\">\n {actions.map((action: DataGridSelectionAction) => (\n <DropdownMenuItem\n key={actionListKey(actions, action)}\n onClick={() => action.onClick(rowSelection)}\n >\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nfunction actionListKey<T extends { label?: string; 'aria-label'?: string }>(\n actions: readonly T[],\n action: T\n): string {\n const name = action.label ?? action['aria-label'] ?? '';\n const earlierDuplicates = actions\n .slice(0, actions.indexOf(action))\n .filter(\n (candidate) => (candidate.label ?? candidate['aria-label']) === name\n ).length;\n if (earlierDuplicates === 0) return name;\n return `${name}-${earlierDuplicates + 1}`;\n}\n\nfunction limitSecondaryActions(\n actions: readonly DataGridSecondaryAction[]\n): readonly DataGridSecondaryAction[] {\n return actions.slice(0, MAX_SECONDARY_ACTIONS);\n}\n\nexport { DataGridSelectionToolbar };\n"],"names":["useEffect","IconDotsVertical","ActionToolbar","ActionToolbarAction","ActionToolbarActionClear","ActionToolbarActions","ActionToolbarPrimaryAction","ActionToolbarSelection","ActionToolbarSelectionSummary","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","MAX_SECONDARY_ACTIONS","DataGridSelectionToolbar","selectedCount","rowSelection","selectionActions","onClear","primaryAction","requestedSecondaryActions","secondaryActions","limitSecondaryActions","menuActions","secondaryActionCount","length","console","warn","div","className","width","aria-label","onClick","DataGridSelectionMenu","actions","map","action","DataGridSecondaryToolbarAction","actionListKey","icon","span","aria-hidden","label","iconOnly","render","variant","size","side","align","name","earlierDuplicates","slice","indexOf","filter","candidate"],"mappings":";AAAA,SAASA,SAAS,QAA2B,QAAQ;AAErD,SAASC,gBAAgB,QAAQ,sBAAsB;AAGvD,SACEC,aAAa,EACbC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,sBAAsB,EACtBC,6BAA6B,QACxB,sCAAmC;AAC1C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SACEC,YAAY,EACZC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,QACd,oCAAiC;AAexC,MAAMC,wBAAwB;AAE9B,SAASC,yBAAyB,EAChCC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,OAAO,EACuB;IAC9B,MAAMC,gBAAgBF,kBAAkBE;IACxC,MAAMC,4BAA4BH,kBAAkBI,oBAAoB,EAAE;IAC1E,MAAMA,mBAAmBC,sBAAsBF;IAC/C,MAAMG,cAAcN,kBAAkBM,eAAe,EAAE;IAEvD,MAAMC,uBAAuBJ,0BAA0BK,MAAM;IAE7D1B,UAAU;QACR,IAAIyB,wBAAwBX,uBAAuB;QACnDa,QAAQC,IAAI,CACV,CAAC,oDAAoD,EAAEd,sBAAsB,oBAAoB,CAAC,GAChG;IAEN,GAAG;QAACW;KAAqB;IAEzB,OACE,yFAAyF;kBACzF,KAACI;QAAIC,WAAU;kBACb,cAAA,MAAC5B;YACCc,eAAeA;YACfe,OAAM;YACNC,cAAW;YACXF,WAAU;;8BAEV,MAACvB;oBAAuByB,cAAW;;sCACjC,KAACxB;sCACD,KAACJ;4BAAyB6B,SAASd;;;;8BAErC,MAACd;oBAAqB2B,cAAW;;wBAC9BR,YAAYE,MAAM,GAAG,kBACpB,KAACQ;4BACCC,SAASX;4BACTP,cAAcA;6BAEd;wBACHK,iBAAiBc,GAAG,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