@clickhouse/click-ui 0.10.0 → 0.11.0-rc1
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.
- package/dist/cjs/click-ui.css +67 -10
- package/dist/cjs/components/CodeBlock/CodeBlock.css +35 -2
- package/dist/cjs/components/CodeBlock/index.cjs +27 -22
- package/dist/cjs/components/CodeBlock/index.cjs.map +1 -1
- package/dist/cjs/components/DateDetails/index.cjs +8 -5
- package/dist/cjs/components/DateDetails/index.cjs.map +1 -1
- package/dist/cjs/components/Dropdown/index.cjs +4 -1
- package/dist/cjs/components/Dropdown/index.cjs.map +1 -1
- package/dist/cjs/components/EllipsisContent/index.cjs +3 -2
- package/dist/cjs/components/EllipsisContent/index.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.css +5 -0
- package/dist/cjs/components/IconButton/index.cjs +12 -2
- package/dist/cjs/components/IconButton/index.cjs.map +1 -1
- package/dist/cjs/components/IconWrapper/index.cjs +6 -5
- package/dist/cjs/components/IconWrapper/index.cjs.map +1 -1
- package/dist/cjs/components/Link/Link.css +0 -1
- package/dist/cjs/components/Link/index.cjs.map +1 -1
- package/dist/cjs/components/Pagination/index.cjs +3 -3
- package/dist/cjs/components/Pagination/index.cjs.map +1 -1
- package/dist/cjs/components/Popover/Popover.css +7 -6
- package/dist/cjs/components/Popover/index.cjs +12 -10
- package/dist/cjs/components/Popover/index.cjs.map +1 -1
- package/dist/cjs/components/ProgressBar/index.cjs +6 -3
- package/dist/cjs/components/ProgressBar/index.cjs.map +1 -1
- package/dist/cjs/components/Text/Text.css +20 -0
- package/dist/cjs/components/Text/Text.module.css.cjs +8 -0
- package/dist/cjs/components/Text/Text.module.css.cjs.map +1 -1
- package/dist/cjs/components/Text/index.cjs +11 -1
- package/dist/cjs/components/Text/index.cjs.map +1 -1
- package/dist/cjs/components/Toast/index.cjs +7 -1
- package/dist/cjs/components/Toast/index.cjs.map +1 -1
- package/dist/esm/click-ui.css +67 -10
- package/dist/esm/components/CodeBlock/CodeBlock.css +35 -2
- package/dist/esm/components/CodeBlock/index.js +27 -22
- package/dist/esm/components/CodeBlock/index.js.map +1 -1
- package/dist/esm/components/DateDetails/index.js +8 -5
- package/dist/esm/components/DateDetails/index.js.map +1 -1
- package/dist/esm/components/Dropdown/index.js +4 -1
- package/dist/esm/components/Dropdown/index.js.map +1 -1
- package/dist/esm/components/EllipsisContent/index.js +3 -2
- package/dist/esm/components/EllipsisContent/index.js.map +1 -1
- package/dist/esm/components/IconButton/IconButton.css +5 -0
- package/dist/esm/components/IconButton/index.js +12 -2
- package/dist/esm/components/IconButton/index.js.map +1 -1
- package/dist/esm/components/IconWrapper/index.js +6 -5
- package/dist/esm/components/IconWrapper/index.js.map +1 -1
- package/dist/esm/components/Link/Link.css +0 -1
- package/dist/esm/components/Link/index.js.map +1 -1
- package/dist/esm/components/Pagination/index.js +3 -3
- package/dist/esm/components/Pagination/index.js.map +1 -1
- package/dist/esm/components/Popover/Popover.css +7 -6
- package/dist/esm/components/Popover/index.js +12 -10
- package/dist/esm/components/Popover/index.js.map +1 -1
- package/dist/esm/components/ProgressBar/index.js +6 -3
- package/dist/esm/components/ProgressBar/index.js.map +1 -1
- package/dist/esm/components/Text/Text.css +20 -0
- package/dist/esm/components/Text/Text.module.css.js +7 -1
- package/dist/esm/components/Text/Text.module.css.js.map +1 -1
- package/dist/esm/components/Text/index.js +11 -1
- package/dist/esm/components/Text/index.js.map +1 -1
- package/dist/esm/components/Toast/index.js +7 -1
- package/dist/esm/components/Toast/index.js.map +1 -1
- package/dist/types/components/CodeBlock/CodeBlock.d.ts +1 -1
- package/dist/types/components/CodeBlock/CodeBlock.types.d.ts +8 -0
- package/dist/types/components/Dropdown/Dropdown.d.ts +13 -16
- package/dist/types/components/Dropdown/Dropdown.types.d.ts +10 -0
- package/dist/types/components/EllipsisContent/EllipsisContent.d.ts +1 -3
- package/dist/types/components/EllipsisContent/EllipsisContent.types.d.ts +6 -0
- package/dist/types/components/IconWrapper/IconWrapper.d.ts +1 -1
- package/dist/types/components/IconWrapper/IconWrapper.types.d.ts +3 -0
- package/dist/types/components/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/types/components/Text/Text.d.ts +3 -0
- package/dist/types/components/Tooltip/index.d.ts +1 -1
- package/dist/types/index.d.ts +3 -1
- package/package.json +17 -19
|
@@ -23,9 +23,12 @@
|
|
|
23
23
|
colors are set inline per state via --codeblock-button, matching the
|
|
24
24
|
--codeblock-numbers pattern so both track the ThemeProvider runtime. */
|
|
25
25
|
--codeblock-button: initial;
|
|
26
|
+
/* assign context to be above pseudo-element
|
|
27
|
+
can be cleaned up when background is a regular color variable with alpha */
|
|
28
|
+
z-index: 1;
|
|
26
29
|
padding: 0;
|
|
27
30
|
border: 0;
|
|
28
|
-
color: var(--codeblock-button, inherit);
|
|
31
|
+
color: var(--codeblock-button, inherit);
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
.codeblock__highlighter__t4Xol {
|
|
@@ -41,9 +44,39 @@
|
|
|
41
44
|
|
|
42
45
|
.codeblock__button-container__D6yob {
|
|
43
46
|
display: flex;
|
|
47
|
+
opacity: 0;
|
|
44
48
|
position: absolute;
|
|
45
49
|
top: var(--click-codeblock-space-y);
|
|
46
50
|
right: var(--click-codeblock-space-x);
|
|
47
|
-
|
|
51
|
+
padding: var(--spaces-1);
|
|
52
|
+
gap: var(--spaces-1);
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
transition: opacity 200ms ease-in-out;
|
|
48
55
|
}
|
|
56
|
+
|
|
57
|
+
.codeblock__pRWOC:hover .codeblock__button-container__D6yob,
|
|
58
|
+
.codeblock__pRWOC:focus-within .codeblock__button-container__D6yob {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
pointer-events: auto;
|
|
61
|
+
transition-duration: 150ms;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* this element can be refactored to a color var with alpha when available */
|
|
65
|
+
.codeblock__button-container__D6yob::before {
|
|
66
|
+
content: "";
|
|
67
|
+
opacity: 0.85;
|
|
68
|
+
position: absolute;
|
|
69
|
+
z-index: 0;
|
|
70
|
+
inset: 0;
|
|
71
|
+
border-radius: var(--spaces-1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* custom conditional theming can be later replaced with semantic color tokens */
|
|
75
|
+
[data-cui-theme="light"] .codeblock__button-container__D6yob::before {
|
|
76
|
+
background: var(--palette-indigo-100);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-cui-theme="dark"] .codeblock__button-container__D6yob::before {
|
|
80
|
+
background: var(--palette-neutral-900);
|
|
49
81
|
}
|
|
82
|
+
}
|
|
@@ -24,6 +24,7 @@ const CodeBlock = ({
|
|
|
24
24
|
showLineNumbers,
|
|
25
25
|
showWrapButton = false,
|
|
26
26
|
wrapLines = false,
|
|
27
|
+
ariaLabel,
|
|
27
28
|
onCopy,
|
|
28
29
|
onCopyError,
|
|
29
30
|
className,
|
|
@@ -56,6 +57,7 @@ const CodeBlock = ({
|
|
|
56
57
|
setTimeout(() => setErrorCopy(false), 2e3);
|
|
57
58
|
}
|
|
58
59
|
};
|
|
60
|
+
const codeRegionLabel = ariaLabel ?? (language ? `${language} code block` : "Code block");
|
|
59
61
|
const wrapElement = () => {
|
|
60
62
|
setWrap((wrap2) => !wrap2);
|
|
61
63
|
};
|
|
@@ -73,30 +75,12 @@ const CodeBlock = ({
|
|
|
73
75
|
style: { "--codeblock-numbers": numbersColor, ...style },
|
|
74
76
|
className: cn(styles.codeblock, className),
|
|
75
77
|
children: [
|
|
76
|
-
/* @__PURE__ */ jsxs("div", { className: styles["codeblock__button-container"], children: [
|
|
77
|
-
showWrapButton && /* @__PURE__ */ jsx(
|
|
78
|
-
IconButton,
|
|
79
|
-
{
|
|
80
|
-
className: styles["codeblock__button"],
|
|
81
|
-
icon: "document",
|
|
82
|
-
onClick: wrapElement
|
|
83
|
-
}
|
|
84
|
-
),
|
|
85
|
-
/* @__PURE__ */ jsx(
|
|
86
|
-
IconButton,
|
|
87
|
-
{
|
|
88
|
-
className: styles["codeblock__button"],
|
|
89
|
-
style: {
|
|
90
|
-
"--codeblock-button": copied ? buttonStateColors.success : errorCopy ? buttonStateColors.danger : void 0
|
|
91
|
-
},
|
|
92
|
-
icon: copied ? "check" : errorCopy ? "warning" : "copy",
|
|
93
|
-
onClick: copyCodeToClipboard
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
] }),
|
|
97
78
|
/* @__PURE__ */ jsx(
|
|
98
79
|
Light,
|
|
99
80
|
{
|
|
81
|
+
tabIndex: 0,
|
|
82
|
+
role: "group",
|
|
83
|
+
"aria-label": codeRegionLabel,
|
|
100
84
|
language,
|
|
101
85
|
style: customStyle,
|
|
102
86
|
CodeTag: CodeWithRef,
|
|
@@ -131,7 +115,28 @@ const CodeBlock = ({
|
|
|
131
115
|
wrapLongLines: wrap || wrapLines,
|
|
132
116
|
children
|
|
133
117
|
}
|
|
134
|
-
)
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsxs("div", { className: styles["codeblock__button-container"], children: [
|
|
120
|
+
showWrapButton && /* @__PURE__ */ jsx(
|
|
121
|
+
IconButton,
|
|
122
|
+
{
|
|
123
|
+
className: styles["codeblock__button"],
|
|
124
|
+
icon: "document",
|
|
125
|
+
onClick: wrapElement
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
IconButton,
|
|
130
|
+
{
|
|
131
|
+
className: styles["codeblock__button"],
|
|
132
|
+
style: {
|
|
133
|
+
"--codeblock-button": copied ? buttonStateColors.success : errorCopy ? buttonStateColors.danger : void 0
|
|
134
|
+
},
|
|
135
|
+
icon: copied ? "check" : errorCopy ? "warning" : "copy",
|
|
136
|
+
onClick: copyCodeToClipboard
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] })
|
|
135
140
|
]
|
|
136
141
|
}
|
|
137
142
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import React, { HTMLAttributes, useState } from 'react';\nimport { Light as SyntaxHighlighter, createElement } from 'react-syntax-highlighter';\n\nimport { IconButton } from '@/components/IconButton';\n\nimport { cn } from '@/lib/cva';\nimport useColorStyle, { useButtonStateColors, useNumbersColor } from './useColorStyle';\nimport { CodeBlockProps } from './CodeBlock.types';\nimport styles from './CodeBlock.module.css';\n\n/* eslint-disable import/extensions */\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport tsx from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport plaintext from 'react-syntax-highlighter/dist/cjs/languages/hljs/plaintext.js';\n/* eslint-enable import/extensions */\n\nSyntaxHighlighter.registerLanguage('sql', sql.default || sql);\nSyntaxHighlighter.registerLanguage('bash', bash.default || bash);\nSyntaxHighlighter.registerLanguage('json', json.default || json);\nSyntaxHighlighter.registerLanguage('tsx', tsx.default || tsx);\nSyntaxHighlighter.registerLanguage('plaintext', plaintext.default || plaintext);\n\ninterface RendererNodeType {\n type: 'element' | 'text';\n value?: string | number | undefined;\n tagName?: keyof React.JSX.IntrinsicElements | React.ComponentType | undefined;\n properties?: { className: unknown[]; [key: string]: unknown };\n children?: RendererNodeType[];\n}\ninterface CustomRendererProps {\n rows: RendererNodeType[];\n stylesheet: { [key: string]: React.CSSProperties };\n useInlineStyles: boolean;\n}\n\nexport const CodeBlock = ({\n children,\n language,\n theme,\n showLineNumbers,\n showWrapButton = false,\n wrapLines = false,\n onCopy,\n onCopyError,\n className,\n style,\n ...props\n}: CodeBlockProps) => {\n const [copied, setCopied] = useState(false);\n const [errorCopy, setErrorCopy] = useState(false);\n const [wrap, setWrap] = useState(wrapLines);\n const customStyle = useColorStyle(theme);\n const numbersColor = useNumbersColor(theme);\n const buttonStateColors = useButtonStateColors();\n\n const copyCodeToClipboard = async () => {\n try {\n await navigator.clipboard.writeText(children);\n if (typeof onCopy == 'function') {\n onCopy(children);\n }\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (error) {\n let message = 'Unable to copy code';\n if (error instanceof Error) {\n message = error.message;\n }\n setErrorCopy(true);\n if (typeof onCopyError === 'function') {\n onCopyError(message);\n }\n setTimeout(() => setErrorCopy(false), 2000);\n }\n };\n const wrapElement = () => {\n setWrap(wrap => !wrap);\n };\n\n const CodeWithRef = (props: HTMLAttributes<HTMLElement>) => (\n <code\n {...props}\n className={cn(styles['codeblock__content'], props.className)}\n />\n );\n return (\n <div\n {...props}\n style={{ '--codeblock-numbers': numbersColor, ...style } as React.CSSProperties}\n className={cn(styles.codeblock, className)}\n >\n <
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import React, { HTMLAttributes, useState } from 'react';\nimport { Light as SyntaxHighlighter, createElement } from 'react-syntax-highlighter';\n\nimport { IconButton } from '@/components/IconButton';\n\nimport { cn } from '@/lib/cva';\nimport useColorStyle, { useButtonStateColors, useNumbersColor } from './useColorStyle';\nimport { CodeBlockProps } from './CodeBlock.types';\nimport styles from './CodeBlock.module.css';\n\n/* eslint-disable import/extensions */\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport tsx from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript.js';\n// @ts-expect-error - Importing CJS modules in ESM context requires explicit .js extension\nimport plaintext from 'react-syntax-highlighter/dist/cjs/languages/hljs/plaintext.js';\n/* eslint-enable import/extensions */\n\nSyntaxHighlighter.registerLanguage('sql', sql.default || sql);\nSyntaxHighlighter.registerLanguage('bash', bash.default || bash);\nSyntaxHighlighter.registerLanguage('json', json.default || json);\nSyntaxHighlighter.registerLanguage('tsx', tsx.default || tsx);\nSyntaxHighlighter.registerLanguage('plaintext', plaintext.default || plaintext);\n\ninterface RendererNodeType {\n type: 'element' | 'text';\n value?: string | number | undefined;\n tagName?: keyof React.JSX.IntrinsicElements | React.ComponentType | undefined;\n properties?: { className: unknown[]; [key: string]: unknown };\n children?: RendererNodeType[];\n}\ninterface CustomRendererProps {\n rows: RendererNodeType[];\n stylesheet: { [key: string]: React.CSSProperties };\n useInlineStyles: boolean;\n}\n\nexport const CodeBlock = ({\n children,\n language,\n theme,\n showLineNumbers,\n showWrapButton = false,\n wrapLines = false,\n ariaLabel,\n onCopy,\n onCopyError,\n className,\n style,\n ...props\n}: CodeBlockProps) => {\n const [copied, setCopied] = useState(false);\n const [errorCopy, setErrorCopy] = useState(false);\n const [wrap, setWrap] = useState(wrapLines);\n const customStyle = useColorStyle(theme);\n const numbersColor = useNumbersColor(theme);\n const buttonStateColors = useButtonStateColors();\n\n const copyCodeToClipboard = async () => {\n try {\n await navigator.clipboard.writeText(children);\n if (typeof onCopy == 'function') {\n onCopy(children);\n }\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n } catch (error) {\n let message = 'Unable to copy code';\n if (error instanceof Error) {\n message = error.message;\n }\n setErrorCopy(true);\n if (typeof onCopyError === 'function') {\n onCopyError(message);\n }\n setTimeout(() => setErrorCopy(false), 2000);\n }\n };\n\n const codeRegionLabel =\n ariaLabel ?? (language ? `${language} code block` : 'Code block');\n\n const wrapElement = () => {\n setWrap(wrap => !wrap);\n };\n\n const CodeWithRef = (props: HTMLAttributes<HTMLElement>) => (\n <code\n {...props}\n className={cn(styles['codeblock__content'], props.className)}\n />\n );\n return (\n <div\n {...props}\n style={{ '--codeblock-numbers': numbersColor, ...style } as React.CSSProperties}\n className={cn(styles.codeblock, className)}\n >\n <SyntaxHighlighter\n tabIndex={0}\n role=\"group\"\n aria-label={codeRegionLabel}\n language={language}\n style={customStyle}\n CodeTag={CodeWithRef}\n className={styles['codeblock__highlighter']}\n renderer={({ rows, stylesheet, useInlineStyles }: CustomRendererProps) => {\n return rows.map((row, index) => {\n const children = row.children;\n const lineNumberElement = children?.shift();\n\n /**\n * We will take current structure of the rows and rebuild it\n * according to the suggestion here https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/376#issuecomment-1246115899\n */\n if (lineNumberElement) {\n row.children = [\n lineNumberElement,\n {\n children,\n properties: {\n className: [],\n },\n tagName: 'span',\n type: 'element',\n },\n ];\n }\n\n return createElement({\n node: row,\n stylesheet,\n useInlineStyles,\n key: index,\n });\n });\n }}\n showLineNumbers={showLineNumbers}\n wrapLines={wrap || wrapLines}\n wrapLongLines={wrap || wrapLines}\n >\n {children}\n </SyntaxHighlighter>\n <div className={styles['codeblock__button-container']}>\n {showWrapButton && (\n <IconButton\n className={styles['codeblock__button']}\n icon=\"document\"\n onClick={wrapElement}\n />\n )}\n <IconButton\n className={styles['codeblock__button']}\n style={\n {\n '--codeblock-button': copied\n ? buttonStateColors.success\n : errorCopy\n ? buttonStateColors.danger\n : undefined,\n } as React.CSSProperties\n }\n icon={copied ? 'check' : errorCopy ? 'warning' : 'copy'}\n onClick={copyCodeToClipboard}\n />\n </div>\n </div>\n );\n};\n"],"names":["SyntaxHighlighter","wrap","props","children"],"mappings":";;;;;;;;;;;;;AAuBAA,KAAA,CAAkB,gBAAA,CAAiB,KAA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AAK,UAAA;AAAA,cACL,OAAA,EAAS;AAAA;AAAA,WACX;AAAA,0BAEF,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,OAAO,mBAAmB,CAAA;AAAA,cACrC,KAAA,EACE;AAAA,gBACE,sBAAsB,MAAA,GAClB,iBAAA,CAAkB,OAAA,GAClB,SAAA,GACE,kBAAkB,MAAA,GAClB;AAAA,eACR;AAAA,cAEF,IAAA,EAAM,MAAA,GAAS,OAAA,GAAU,SAAA,GAAY,SAAA,GAAY,MAAA;AAAA,cACjD,OAAA,EAAS;AAAA;AAAA;AACX,SAAA,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -24,6 +24,7 @@ const formatDateDetails = (date, timezone) => {
|
|
|
24
24
|
}
|
|
25
25
|
return date.format(formatForPastYear).replace("am", "a.m.").replace("pm", "p.m.");
|
|
26
26
|
};
|
|
27
|
+
const fallbackSystemTimeZone = "America/New_York";
|
|
27
28
|
const DateDetails = ({
|
|
28
29
|
date,
|
|
29
30
|
side = "top",
|
|
@@ -33,11 +34,13 @@ const DateDetails = ({
|
|
|
33
34
|
}) => {
|
|
34
35
|
const dayjsDate = dayjs(date);
|
|
35
36
|
let systemTime;
|
|
36
|
-
|
|
37
|
+
let resolvedSystemTimeZone = systemTimeZone;
|
|
38
|
+
if (resolvedSystemTimeZone) {
|
|
37
39
|
try {
|
|
38
|
-
systemTime = dayjsDate.tz(
|
|
40
|
+
systemTime = dayjsDate.tz(resolvedSystemTimeZone);
|
|
39
41
|
} catch {
|
|
40
|
-
|
|
42
|
+
resolvedSystemTimeZone = fallbackSystemTimeZone;
|
|
43
|
+
systemTime = dayjsDate.tz(resolvedSystemTimeZone);
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
return /* @__PURE__ */ jsxs(Popover, { children: [
|
|
@@ -97,11 +100,11 @@ const DateDetails = ({
|
|
|
97
100
|
}
|
|
98
101
|
),
|
|
99
102
|
/* @__PURE__ */ jsx(Container, { justifyContent: "end", children: /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
100
|
-
formatDateDetails(systemTime,
|
|
103
|
+
formatDateDetails(systemTime, resolvedSystemTimeZone),
|
|
101
104
|
" (",
|
|
102
105
|
formatTimezone({
|
|
103
106
|
date: systemTime,
|
|
104
|
-
timezone:
|
|
107
|
+
timezone: resolvedSystemTimeZone
|
|
105
108
|
}),
|
|
106
109
|
")"
|
|
107
110
|
] }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/DateDetails/DateDetails.tsx"],"sourcesContent":["import { Popover } from '@/components/Popover';\nimport { Text } from '@/components/Text';\nimport { Link } from '@/components/Link';\nimport { GridContainer } from '@/components/GridContainer';\nimport { Container } from '@/components/Container';\n\nimport { dayjs, Dayjs, formatTimezone } from '@/utils/date';\n\nconst formatDateDetails = (date: Dayjs, timezone?: string): string => {\n const isCurrentYear = dayjs().year() === date.year();\n const formatForCurrentYear = 'MMM D, h:mm a';\n const formatForPastYear = 'MMM D, YYYY, h:mm a';\n\n if (isCurrentYear) {\n if (timezone) {\n const dateWithTimezone = date.tz(timezone);\n return dateWithTimezone\n .format(formatForCurrentYear)\n .replace('am', 'a.m.')\n .replace('pm', 'p.m.');\n }\n\n return date.format(formatForCurrentYear).replace('am', 'a.m.').replace('pm', 'p.m.');\n }\n\n if (timezone) {\n const dateWithTimezone = date.tz(timezone);\n return dateWithTimezone\n .format(formatForPastYear)\n .replace('am', 'a.m.')\n .replace('pm', 'p.m.');\n }\n return date.format(formatForPastYear).replace('am', 'a.m.').replace('pm', 'p.m.');\n};\n\nimport { DateDetailsProps } from './DateDetails.types';\n\nexport const DateDetails = ({\n date,\n side = 'top',\n size = 'sm',\n systemTimeZone,\n weight = 'normal',\n}: DateDetailsProps) => {\n const dayjsDate = dayjs(date);\n\n let systemTime;\n if (
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/DateDetails/DateDetails.tsx"],"sourcesContent":["import { Popover } from '@/components/Popover';\nimport { Text } from '@/components/Text';\nimport { Link } from '@/components/Link';\nimport { GridContainer } from '@/components/GridContainer';\nimport { Container } from '@/components/Container';\n\nimport { dayjs, Dayjs, formatTimezone } from '@/utils/date';\n\nconst formatDateDetails = (date: Dayjs, timezone?: string): string => {\n const isCurrentYear = dayjs().year() === date.year();\n const formatForCurrentYear = 'MMM D, h:mm a';\n const formatForPastYear = 'MMM D, YYYY, h:mm a';\n\n if (isCurrentYear) {\n if (timezone) {\n const dateWithTimezone = date.tz(timezone);\n return dateWithTimezone\n .format(formatForCurrentYear)\n .replace('am', 'a.m.')\n .replace('pm', 'p.m.');\n }\n\n return date.format(formatForCurrentYear).replace('am', 'a.m.').replace('pm', 'p.m.');\n }\n\n if (timezone) {\n const dateWithTimezone = date.tz(timezone);\n return dateWithTimezone\n .format(formatForPastYear)\n .replace('am', 'a.m.')\n .replace('pm', 'p.m.');\n }\n return date.format(formatForPastYear).replace('am', 'a.m.').replace('pm', 'p.m.');\n};\n\nimport { DateDetailsProps } from './DateDetails.types';\n\nconst fallbackSystemTimeZone = 'America/New_York';\n\nexport const DateDetails = ({\n date,\n side = 'top',\n size = 'sm',\n systemTimeZone,\n weight = 'normal',\n}: DateDetailsProps) => {\n const dayjsDate = dayjs(date);\n\n let systemTime;\n let resolvedSystemTimeZone = systemTimeZone;\n if (resolvedSystemTimeZone) {\n try {\n systemTime = dayjsDate.tz(resolvedSystemTimeZone);\n } catch {\n resolvedSystemTimeZone = fallbackSystemTimeZone;\n systemTime = dayjsDate.tz(resolvedSystemTimeZone);\n }\n }\n\n return (\n <Popover>\n <Popover.Trigger>\n <Link\n component=\"span\"\n size=\"sm\"\n weight=\"medium\"\n >\n <Text\n component=\"span\"\n size={size}\n weight={weight}\n >\n {dayjs.utc(date).fromNow()}\n </Text>\n </Link>\n </Popover.Trigger>\n <Popover.Content\n side={side}\n showArrow\n >\n <GridContainer\n columnGap=\"xl\"\n gridTemplateColumns=\"repeat(2, auto)\"\n gap=\"sm\"\n >\n <Text\n color=\"muted\"\n size=\"sm\"\n >\n Local\n </Text>\n <Container justifyContent=\"end\">\n <Text size=\"sm\">\n {formatDateDetails(dayjsDate)} (\n {formatTimezone({\n date: dayjsDate,\n timezone: dayjs.tz.guess(),\n })}\n )\n </Text>\n </Container>\n\n {systemTime && (\n <>\n <Text\n color=\"muted\"\n size=\"sm\"\n >\n System\n </Text>\n\n <Container justifyContent=\"end\">\n <Text size=\"sm\">\n {formatDateDetails(systemTime, resolvedSystemTimeZone)} (\n {formatTimezone({\n date: systemTime,\n timezone: resolvedSystemTimeZone,\n })}\n )\n </Text>\n </Container>\n </>\n )}\n\n <Text\n color=\"muted\"\n size=\"sm\"\n >\n UTC\n </Text>\n <Container justifyContent=\"end\">\n <Text size=\"sm\">{formatDateDetails(dayjsDate.utc(), 'UTC')}</Text>\n </Container>\n\n <Text\n color=\"muted\"\n size=\"sm\"\n >\n Unix\n </Text>\n <Container justifyContent=\"end\">\n <Text size=\"sm\">{Math.round(dayjsDate.valueOf() / 1000)}</Text>\n </Container>\n </GridContainer>\n </Popover.Content>\n </Popover>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,iBAAA,GAAoB,CAAC,IAAA,EAAa,QAAA,KAA8B;AACpE,EAAA,MAAM,gBAAgB,KAAA,EAAM,CAAE,IAAA,EAAK,KAAM,KAAK,IAAA,EAAK;AACnD,EAAA,MAAM,oBAAA,GAAuB,eAAA;AAC7B,EAAA,MAAM,iBAAA,GAAoB,qBAAA;AAE1B,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,MAAM,gBAAA,GAAmB,IAAA,CAAK,EAAA,CAAG,QAAQ,CAAA;AACzC,MAAA,OAAO,gBAAA,CACJ,MAAA,CAAO,oBAAoB,CAAA,CAC3B,OAAA,CAAQ,MAAM,MAAM,CAAA,CACpB,OAAA,CAAQ,IAAA,EAAM,MAAM,CAA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AA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -27,7 +27,7 @@ const DropdownTrigger = ({
|
|
|
27
27
|
...props
|
|
28
28
|
}) => {
|
|
29
29
|
if (sub) {
|
|
30
|
-
const { icon, iconDir, ...menuProps } = props;
|
|
30
|
+
const { icon, iconDir, tooltipProps, ...menuProps } = props;
|
|
31
31
|
return /* @__PURE__ */ jsxs(
|
|
32
32
|
DropdownMenuItem,
|
|
33
33
|
{
|
|
@@ -39,6 +39,7 @@ const DropdownTrigger = ({
|
|
|
39
39
|
{
|
|
40
40
|
icon,
|
|
41
41
|
iconDir,
|
|
42
|
+
tooltipProps: { side: "right", ...tooltipProps },
|
|
42
43
|
children
|
|
43
44
|
}
|
|
44
45
|
),
|
|
@@ -130,6 +131,7 @@ const DropdownItem = ({
|
|
|
130
131
|
icon,
|
|
131
132
|
iconDir,
|
|
132
133
|
type = "default",
|
|
134
|
+
tooltipProps,
|
|
133
135
|
children,
|
|
134
136
|
...props
|
|
135
137
|
}) => {
|
|
@@ -144,6 +146,7 @@ const DropdownItem = ({
|
|
|
144
146
|
{
|
|
145
147
|
icon,
|
|
146
148
|
iconDir,
|
|
149
|
+
tooltipProps: { side: "right", ...tooltipProps },
|
|
147
150
|
children
|
|
148
151
|
}
|
|
149
152
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import * as DropdownMenu from '@radix-ui/react-dropdown-menu';\nimport {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n forwardRef,\n} from 'react';\nimport { Arrow, GenericMenuItem, GenericMenuPanel } from '@/components/GenericMenu';\nimport { cn } from '@/lib/cva';\nimport { useInputModality } from '@/hooks/internal';\nimport Popover_Arrow from '@/components/Assets/Icons/Popover-Arrow';\nimport { IconWrapper } from '@/components/IconWrapper';\nimport { Icon } from '@/components/Icon';\nimport type { IconName } from '@/components/Icon';\nimport type { HorizontalDirection } from '@/types';\nimport { useResolvedPortalContainer } from '@/providers/PortalContext';\nimport styles from './Dropdown.module.css';\n\nexport const Dropdown = (props: DropdownMenu.DropdownMenuProps) => (\n <DropdownMenu.Root {...props} />\n);\n\ntype DropdownMenuItemComponent = <T extends ElementType = 'div'>(\n props: ComponentProps<typeof GenericMenuItem<T>>\n) => ReactNode;\n\nconst _DropdownMenuItem = <T extends ElementType = 'div'>(\n { className, ...props }: ComponentProps<typeof GenericMenuItem<T>>,\n ref: ComponentPropsWithRef<T>['ref']\n) => (\n <GenericMenuItem\n ref={ref}\n {...(props as ComponentProps<typeof GenericMenuItem>)}\n className={cn(styles['dropdown-menu-item'], className)}\n />\n);\n\nconst DropdownMenuItem: DropdownMenuItemComponent = forwardRef(_DropdownMenuItem);\n\ninterface SubDropdownProps {\n sub?: true;\n icon?: IconName;\n iconDir?: HorizontalDirection;\n}\n\ninterface MainDropdownProps {\n sub?: never;\n}\n\ntype DropdownSubTriggerProps = DropdownMenu.DropdownMenuSubTriggerProps &\n SubDropdownProps;\ntype DropdownTriggerProps = DropdownMenu.DropdownMenuTriggerProps & MainDropdownProps;\n\nconst DropdownTrigger = ({\n sub,\n children,\n ...props\n}: DropdownSubTriggerProps | DropdownTriggerProps) => {\n if (sub) {\n const { icon, iconDir, ...menuProps } = props as DropdownSubTriggerProps;\n return (\n <DropdownMenuItem\n as={DropdownMenu.SubTrigger}\n {...menuProps}\n >\n <IconWrapper\n icon={icon}\n iconDir={iconDir}\n >\n {children}\n </IconWrapper>\n <Icon name=\"chevron-right\" />\n </DropdownMenuItem>\n );\n }\n\n const { className, ...triggerProps } = props as DropdownTriggerProps;\n return (\n <DropdownMenu.Trigger\n asChild\n {...triggerProps}\n className={cn(styles['dropdown-trigger'], className)}\n >\n <div>{children}</div>\n </DropdownMenu.Trigger>\n );\n};\n\nDropdownTrigger.displayName = 'DropdownTrigger';\nDropdown.Trigger = DropdownTrigger;\n\nexport type ArrowProps = {\n showArrow?: boolean;\n};\n\ninterface StyledDropdownContentProps extends DropdownMenu.DropdownMenuContentProps {\n children?: ReactNode;\n container?: HTMLElement | null;\n responsivePositioning?: boolean;\n}\n\ninterface StyledDropdownSubContentProps extends DropdownMenu.DropdownMenuSubContentProps {\n children?: ReactNode;\n container?: HTMLElement | null;\n responsivePositioning?: boolean;\n}\n\ntype DropdownContentProps = StyledDropdownContentProps & SubDropdownProps & ArrowProps;\ntype DropdownSubContentProps = StyledDropdownSubContentProps &\n MainDropdownProps &\n ArrowProps;\n\ntype DropdownMenuContentComponent = <T extends ElementType = 'div'>(\n props: ComponentProps<typeof GenericMenuPanel<T>>\n) => ReactNode;\n\nconst _DropdownMenuContent = <T extends ElementType = 'div'>(\n { className, ...props }: ComponentProps<typeof GenericMenuPanel<T>>,\n ref: ComponentPropsWithRef<T>['ref']\n) => (\n <GenericMenuPanel\n ref={ref}\n {...(props as ComponentProps<typeof GenericMenuPanel>)}\n className={cn(styles['dropdown-menu-content'], className)}\n />\n);\n\nconst DropdownMenuContent: DropdownMenuContentComponent =\n forwardRef(_DropdownMenuContent);\n\nconst DropdownContent = ({\n sub,\n children,\n container,\n showArrow,\n responsivePositioning = true,\n ...props\n}: DropdownContentProps | DropdownSubContentProps) => {\n const ContentElement = sub ? DropdownMenu.SubContent : DropdownMenu.Content;\n const inputModalityProps = useInputModality();\n const portalContainer = useResolvedPortalContainer(container);\n\n return (\n <DropdownMenu.Portal container={portalContainer}>\n <DropdownMenuContent\n {...props}\n type=\"dropdown-menu\"\n showArrow={showArrow}\n as={ContentElement}\n sideOffset={4}\n loop\n avoidCollisions={responsivePositioning}\n collisionPadding={responsivePositioning ? 100 : undefined}\n {...inputModalityProps}\n >\n {showArrow && (\n <Arrow\n asChild\n as={DropdownMenu.Arrow}\n width={20}\n height={10}\n >\n <Popover_Arrow />\n </Arrow>\n )}\n {children}\n </DropdownMenuContent>\n </DropdownMenu.Portal>\n );\n};\n\nDropdownContent.displayName = 'DropdownContent';\nDropdown.Content = DropdownContent;\n\nconst DropdownGroup = ({ className, ...props }: DropdownMenu.DropdownMenuGroupProps) => {\n return (\n <DropdownMenu.Group\n {...props}\n className={cn(styles['dropdown-group'], className)}\n />\n );\n};\n\nDropdownGroup.displayName = 'DropdownGroup';\nDropdown.Group = DropdownGroup;\n\n// DropdownMenu.Sub is a context-only Radix primitive that renders no DOM node, so\n// the original styled(DropdownMenu.Sub) border-bottom never applied (the className\n// was dropped). The migration preserves that behavior: no class is forwarded.\nconst DropdownSub = (props: DropdownMenu.DropdownMenuGroupProps) => {\n return <DropdownMenu.Sub {...props} />;\n};\n\nDropdownSub.displayName = 'DropdownSub';\nDropdown.Sub = DropdownSub;\n\ninterface DropdownItemProps extends DropdownMenu.DropdownMenuItemProps {\n /** Icon to display in the menu item */\n icon?: IconName;\n /** The direction of the icon relative to the label */\n iconDir?: HorizontalDirection;\n /** The type of the menu item */\n type?: 'default' | 'danger';\n}\n\nexport type { DropdownItemProps };\n\nconst DropdownItem = ({\n icon,\n iconDir,\n type = 'default',\n children,\n ...props\n}: DropdownItemProps) => {\n return (\n <DropdownMenuItem\n as={DropdownMenu.Item}\n type={type}\n {...props}\n >\n <IconWrapper\n icon={icon}\n iconDir={iconDir}\n >\n {children}\n </IconWrapper>\n </DropdownMenuItem>\n );\n};\n\nDropdownItem.displayName = 'DropdownItem';\nDropdown.Item = DropdownItem;\n\nexport default Dropdown;\n"],"names":["Icon"],"mappings":";;;;;;;;;;;;AAmBO,MAAM,QAAA,GAAW,CAAC,KAAA,qBACvB,GAAA,CAAC,aAAa,IAAA,EAAb,EAAmB,GAAG,KAAA,EAAO;AAOhC,MAAM,oBAAoB,CACxB,EAAE,WAAW,GAAG,KAAA,IAChB,GAAA,qBAEA,GAAA;AAAA,EAAC,eAAA;AAAA,EAAA;AAAA,IACC,GAAA;AAAA,IACC,GAAI,KAAA;AAAA,IACL,SAAA,EAAW,EAAA,CAAG,MAAA,CAAO,oBAAoB,GAAG,SAAS;AAAA;AACvD,CAAA;AAGF,MAAM,gBAAA,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,SAAA,EAAW,GAAG,OAAM,KAA2C;AACtF,EAAA,uBACE,GAAA;AAAA,IAAC,YAAA,CAAa,KAAA;AAAA,IAAb;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,MAAA,CAAO,gBAAgB,GAAG,SAAS;AAAA;AAAA,GACnD;AAEJ,CAAA;AAEA,aAAA,CAAc,WAAA,GAAc,eAAA;AAC5B,QAAA,CAAS,KAAA,GAAQ,aAAA;AAKjB,MAAM,WAAA,GAAc,CAAC,KAAA,KAA+C;AAClE,EAAA,uBAAO,GAAA,CAAC,YAAA,CAAa,GAAA,EAAb,EAAkB,GAAG,KAAA,EAAO,CAAA;AACtC,CAAA;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA;AAC1B,QAAA,CAAS,GAAA,GAAM,WAAA;AAaf,MAAM,eAAe,CAAC;AAAA,EACpB,IAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA,GAAO,SAAA;AAAA,EACP,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAyB;AACvB,EAAA,uBACE,GAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,IAAI,YAAA,CAAa,IAAA;AAAA,MACjB,IAAA;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,QAAA,kBAAA,GAAA;AAAA,QAAC,WAAA;AAAA,QAAA;AAAA,UACC,IAAA;AAAA,UACA,OAAA;AAAA,UAEC;AAAA;AAAA;AACH;AAAA,GACF;AAEJ,CAAA;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA;AAC3B,QAAA,CAAS,IAAA,GAAO,YAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import * as DropdownMenu from '@radix-ui/react-dropdown-menu';\nimport {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n forwardRef,\n} from 'react';\nimport { Arrow, GenericMenuItem, GenericMenuPanel } from '@/components/GenericMenu';\nimport { cn } from '@/lib/cva';\nimport { useInputModality } from '@/hooks/internal';\nimport Popover_Arrow from '@/components/Assets/Icons/Popover-Arrow';\nimport { IconWrapper } from '@/components/IconWrapper';\nimport type { IconWrapperProps } from '@/components/IconWrapper';\nimport { Icon } from '@/components/Icon';\nimport type { IconName } from '@/components/Icon';\nimport type { HorizontalDirection } from '@/types';\nimport { useResolvedPortalContainer } from '@/providers/PortalContext';\nimport type { ArrowProps, DropdownItemProps } from './Dropdown.types';\nimport styles from './Dropdown.module.css';\n\nexport const Dropdown = (props: DropdownMenu.DropdownMenuProps) => (\n <DropdownMenu.Root {...props} />\n);\n\ntype DropdownMenuItemComponent = <T extends ElementType = 'div'>(\n props: ComponentProps<typeof GenericMenuItem<T>>\n) => ReactNode;\n\nconst _DropdownMenuItem = <T extends ElementType = 'div'>(\n { className, ...props }: ComponentProps<typeof GenericMenuItem<T>>,\n ref: ComponentPropsWithRef<T>['ref']\n) => (\n <GenericMenuItem\n ref={ref}\n {...(props as ComponentProps<typeof GenericMenuItem>)}\n className={cn(styles['dropdown-menu-item'], className)}\n />\n);\n\nconst DropdownMenuItem: DropdownMenuItemComponent = forwardRef(_DropdownMenuItem);\n\n// `sub` alone discriminates the two shapes of Trigger and Content. The label\n// fields live separately so only the sub-trigger accepts them — Content spreads\n// what it does not read straight onto the Radix element, i.e. into the DOM.\ninterface SubDiscriminant {\n sub?: true;\n}\n\ninterface SubTriggerFields {\n icon?: IconName;\n iconDir?: HorizontalDirection;\n /**\n * Positions the tooltip shown when the label is truncated. Defaults to\n * `side: 'right'` so the tooltip does not cover the items above it.\n */\n tooltipProps?: IconWrapperProps['tooltipProps'];\n}\n\ninterface MainDropdownProps {\n sub?: never;\n}\n\ntype DropdownSubTriggerProps = DropdownMenu.DropdownMenuSubTriggerProps &\n SubDiscriminant &\n SubTriggerFields;\ntype DropdownTriggerProps = DropdownMenu.DropdownMenuTriggerProps & MainDropdownProps;\n\nconst DropdownTrigger = ({\n sub,\n children,\n ...props\n}: DropdownSubTriggerProps | DropdownTriggerProps) => {\n if (sub) {\n const { icon, iconDir, tooltipProps, ...menuProps } =\n props as DropdownSubTriggerProps;\n return (\n <DropdownMenuItem\n as={DropdownMenu.SubTrigger}\n {...menuProps}\n >\n <IconWrapper\n icon={icon}\n iconDir={iconDir}\n tooltipProps={{ side: 'right', ...tooltipProps }}\n >\n {children}\n </IconWrapper>\n <Icon name=\"chevron-right\" />\n </DropdownMenuItem>\n );\n }\n\n const { className, ...triggerProps } = props as DropdownTriggerProps;\n return (\n <DropdownMenu.Trigger\n asChild\n {...triggerProps}\n className={cn(styles['dropdown-trigger'], className)}\n >\n <div>{children}</div>\n </DropdownMenu.Trigger>\n );\n};\n\nDropdownTrigger.displayName = 'DropdownTrigger';\nDropdown.Trigger = DropdownTrigger;\n\ninterface StyledDropdownContentProps extends DropdownMenu.DropdownMenuContentProps {\n children?: ReactNode;\n container?: HTMLElement | null;\n responsivePositioning?: boolean;\n}\n\ninterface StyledDropdownSubContentProps extends DropdownMenu.DropdownMenuSubContentProps {\n children?: ReactNode;\n container?: HTMLElement | null;\n responsivePositioning?: boolean;\n}\n\ntype DropdownContentProps = StyledDropdownContentProps & SubDiscriminant & ArrowProps;\ntype DropdownSubContentProps = StyledDropdownSubContentProps &\n MainDropdownProps &\n ArrowProps;\n\ntype DropdownMenuContentComponent = <T extends ElementType = 'div'>(\n props: ComponentProps<typeof GenericMenuPanel<T>>\n) => ReactNode;\n\nconst _DropdownMenuContent = <T extends ElementType = 'div'>(\n { className, ...props }: ComponentProps<typeof GenericMenuPanel<T>>,\n ref: ComponentPropsWithRef<T>['ref']\n) => (\n <GenericMenuPanel\n ref={ref}\n {...(props as ComponentProps<typeof GenericMenuPanel>)}\n className={cn(styles['dropdown-menu-content'], className)}\n />\n);\n\nconst DropdownMenuContent: DropdownMenuContentComponent =\n forwardRef(_DropdownMenuContent);\n\nconst DropdownContent = ({\n sub,\n children,\n container,\n showArrow,\n responsivePositioning = true,\n ...props\n}: DropdownContentProps | DropdownSubContentProps) => {\n const ContentElement = sub ? DropdownMenu.SubContent : DropdownMenu.Content;\n const inputModalityProps = useInputModality();\n const portalContainer = useResolvedPortalContainer(container);\n\n return (\n <DropdownMenu.Portal container={portalContainer}>\n <DropdownMenuContent\n {...props}\n type=\"dropdown-menu\"\n showArrow={showArrow}\n as={ContentElement}\n sideOffset={4}\n loop\n avoidCollisions={responsivePositioning}\n collisionPadding={responsivePositioning ? 100 : undefined}\n {...inputModalityProps}\n >\n {showArrow && (\n <Arrow\n asChild\n as={DropdownMenu.Arrow}\n width={20}\n height={10}\n >\n <Popover_Arrow />\n </Arrow>\n )}\n {children}\n </DropdownMenuContent>\n </DropdownMenu.Portal>\n );\n};\n\nDropdownContent.displayName = 'DropdownContent';\nDropdown.Content = DropdownContent;\n\nconst DropdownGroup = ({ className, ...props }: DropdownMenu.DropdownMenuGroupProps) => {\n return (\n <DropdownMenu.Group\n {...props}\n className={cn(styles['dropdown-group'], className)}\n />\n );\n};\n\nDropdownGroup.displayName = 'DropdownGroup';\nDropdown.Group = DropdownGroup;\n\n// DropdownMenu.Sub is a context-only Radix primitive that renders no DOM node, so\n// the original styled(DropdownMenu.Sub) border-bottom never applied (the className\n// was dropped). The migration preserves that behavior: no class is forwarded.\nconst DropdownSub = (props: DropdownMenu.DropdownMenuGroupProps) => {\n return <DropdownMenu.Sub {...props} />;\n};\n\nDropdownSub.displayName = 'DropdownSub';\nDropdown.Sub = DropdownSub;\n\nconst DropdownItem = ({\n icon,\n iconDir,\n type = 'default',\n tooltipProps,\n children,\n ...props\n}: DropdownItemProps) => {\n return (\n <DropdownMenuItem\n as={DropdownMenu.Item}\n type={type}\n {...props}\n >\n <IconWrapper\n icon={icon}\n iconDir={iconDir}\n tooltipProps={{ side: 'right', ...tooltipProps }}\n >\n {children}\n </IconWrapper>\n </DropdownMenuItem>\n );\n};\n\nDropdownItem.displayName = 'DropdownItem';\nDropdown.Item = DropdownItem;\n\nexport default Dropdown;\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A,MACjB,IAAA;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,QAAA,kBAAA,GAAA;AAAA,QAAC,WAAA;AAAA,QAAA;AAAA,UACC,IAAA;AAAA,UACA,OAAA;AAAA,UACA,YAAA,EAAc,EAAE,IAAA,EAAM,OAAA,EAAS,GAAG,YAAA,EAAa;AAAA,UAE9C;AAAA;AAAA;AACH;AAAA,GACF;AAEJ,CAAA;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA;AAC3B,QAAA,CAAS,IAAA,GAAO,YAAA;;;;"}
|
|
@@ -9,6 +9,7 @@ import styles from './EllipsisContent.module.css.js';
|
|
|
9
9
|
const EllipsisContentComponent = ({
|
|
10
10
|
component,
|
|
11
11
|
className,
|
|
12
|
+
tooltipProps,
|
|
12
13
|
...props
|
|
13
14
|
}, ref) => {
|
|
14
15
|
const Component = component ?? "div";
|
|
@@ -33,9 +34,9 @@ const EllipsisContentComponent = ({
|
|
|
33
34
|
if (!tooltipContent) {
|
|
34
35
|
return content;
|
|
35
36
|
}
|
|
36
|
-
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
37
|
+
return /* @__PURE__ */ jsxs(Tooltip, { disableHoverableContent: true, children: [
|
|
37
38
|
/* @__PURE__ */ jsx(Tooltip.Trigger, { asChild: true, children: content }),
|
|
38
|
-
/* @__PURE__ */ jsx(Tooltip.Content, { children: tooltipContent })
|
|
39
|
+
/* @__PURE__ */ jsx(Tooltip.Content, { ...tooltipProps, children: tooltipContent })
|
|
39
40
|
] });
|
|
40
41
|
};
|
|
41
42
|
const EllipsisContent = forwardRef(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/EllipsisContent/EllipsisContent.tsx"],"sourcesContent":["import {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n forwardRef,\n useState,\n} from 'react';\nimport { mergeRefs } from '@/utils/mergeRefs';\nimport { cn } from '@/lib/cva';\nimport { Tooltip } from '@/components/Tooltip';\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/EllipsisContent/EllipsisContent.tsx"],"sourcesContent":["import {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n forwardRef,\n useState,\n} from 'react';\nimport { mergeRefs } from '@/utils/mergeRefs';\nimport { cn } from '@/lib/cva';\nimport { Tooltip } from '@/components/Tooltip';\nimport { EllipsisContentProps } from './EllipsisContent.types';\nimport styles from './EllipsisContent.module.css';\n\ntype EllipsisPolymorphicComponent = <T extends ElementType = 'div'>(\n props: Omit<ComponentProps<T>, keyof EllipsisContentProps<T>> & EllipsisContentProps<T>\n) => ReactNode;\n\nconst EllipsisContentComponent = <T extends ElementType = 'div'>(\n {\n component,\n className,\n tooltipProps,\n ...props\n }: Omit<ComponentProps<T>, keyof EllipsisContentProps<T>> &\n EllipsisContentProps<T> & { className?: string },\n ref: ComponentPropsWithRef<T>['ref']\n) => {\n const Component = component ?? 'div';\n const [tooltipContent, setTooltipContent] = useState<string | null>(null);\n\n const content = (\n <Component\n ref={mergeRefs([\n ref,\n node => {\n if (node) {\n setTooltipContent(\n node.scrollWidth > node.clientWidth ? node.innerText : null\n );\n }\n },\n ])}\n {...props}\n className={cn(styles['ellipsis-content'], className)}\n />\n );\n\n if (!tooltipContent) {\n return content;\n }\n\n return (\n <Tooltip disableHoverableContent>\n <Tooltip.Trigger asChild>{content}</Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps}>{tooltipContent}</Tooltip.Content>\n </Tooltip>\n );\n};\n\nexport const EllipsisContent: EllipsisPolymorphicComponent = forwardRef(\n EllipsisContentComponent\n);\n"],"names":[],"mappings":";;;;;;;AAkBA,MAAM,2BAA2B,CAC/B;AAAA,EACE,SAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEA,GAAA,KACG;AACH,EAAA,MAAM,YAAY,SAAA,IAAa,KAAA;AAC/B,EAAA,MAAM,CAAC,cAAA,EAAgB,iBAAiB,CAAA,GAAI,SAAwB,IAAI,CAAA;AAExE,EAAA,MAAM,OAAA,mBACJ,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,KAAK,SAAA,CAAU;AAAA,QACb,GAAA;AAAA,QACA,CAAA,IAAA,KAAQ;AACN,UAAA,IAAI,IAAA,EAAM;AACR,YAAA,iBAAA;AAAA,cACE,IAAA,CAAK,WAAA,GAAc,IAAA,CAAK,WAAA,GAAc,KAAK,SAAA,GAAY;AAAA,aACzD;AAAA,UACF;AAAA,QACF;AAAA,OACD,CAAA;AAAA,MACA,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,MAAA,CAAO,kBAAkB,GAAG,SAAS;AAAA;AAAA,GACrD;AAGF,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,uBACE,IAAA,CAAC,OAAA,EAAA,EAAQ,uBAAA,EAAuB,IAAA,EAC9B,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,OAAA,CAAQ,OAAA,EAAR,EAAgB,OAAA,EAAO,MAAE,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,wBACjC,OAAA,CAAQ,OAAA,EAAR,EAAiB,GAAG,cAAe,QAAA,EAAA,cAAA,EAAe;AAAA,GAAA,EACrD,CAAA;AAEJ,CAAA;AAEO,MAAM,eAAA,GAAgD,UAAA;AAAA,EAC3D;AACF;;;;"}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
cursor: pointer;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
.iconbutton__G-cEu:focus-visible {
|
|
12
|
+
outline: 2px solid var(--click-global-color-outline-default);
|
|
13
|
+
outline-offset: 2px;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
.iconbutton_size_sm__tT3BV {
|
|
12
17
|
padding: var(--click-button-iconButton-sm-space-y)
|
|
13
18
|
var(--click-button-iconButton-sm-space-x);
|
|
@@ -27,22 +27,32 @@ const iconButtonVariants = cva(styles.iconbutton, {
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
const IconButton = forwardRef(
|
|
30
|
-
({
|
|
30
|
+
({
|
|
31
|
+
type = "primary",
|
|
32
|
+
htmlType = "button",
|
|
33
|
+
icon,
|
|
34
|
+
size,
|
|
35
|
+
disabled,
|
|
36
|
+
className,
|
|
37
|
+
"aria-label": ariaLabel,
|
|
38
|
+
...props
|
|
39
|
+
}, ref) => {
|
|
31
40
|
const iconName = icon ? icon.toString() : "unknown icon";
|
|
32
41
|
return /* @__PURE__ */ jsx(
|
|
33
42
|
"button",
|
|
34
43
|
{
|
|
44
|
+
"aria-label": ariaLabel || iconName,
|
|
35
45
|
...props,
|
|
36
46
|
type: htmlType,
|
|
37
47
|
className: cn(iconButtonVariants({ type, size }), className),
|
|
38
48
|
disabled,
|
|
39
49
|
ref,
|
|
40
50
|
role: "button",
|
|
41
|
-
"aria-label": iconName,
|
|
42
51
|
children: /* @__PURE__ */ jsx(
|
|
43
52
|
SvgImage,
|
|
44
53
|
{
|
|
45
54
|
name: icon,
|
|
55
|
+
"aria-hidden": true,
|
|
46
56
|
size: "sm"
|
|
47
57
|
}
|
|
48
58
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { Icon } from '@/components/Icon';\nimport { cn, cva } from '@/lib/cva';\nimport { IconButtonProps } from './IconButton.types';\nimport styles from './IconButton.module.css';\n\nconst iconButtonVariants = cva(styles.iconbutton, {\n variants: {\n type: {\n primary: styles['iconbutton_type_primary'],\n secondary: styles['iconbutton_type_secondary'],\n ghost: styles['iconbutton_type_ghost'],\n danger: styles['iconbutton_type_danger'],\n info: styles['iconbutton_type_info'],\n },\n size: {\n default: '',\n sm: styles['iconbutton_size_sm'],\n xs: styles['iconbutton_size_xs'],\n },\n },\n defaultVariants: {\n type: 'primary',\n size: 'default',\n },\n});\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n ({
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { Icon } from '@/components/Icon';\nimport { cn, cva } from '@/lib/cva';\nimport { IconButtonProps } from './IconButton.types';\nimport styles from './IconButton.module.css';\n\nconst iconButtonVariants = cva(styles.iconbutton, {\n variants: {\n type: {\n primary: styles['iconbutton_type_primary'],\n secondary: styles['iconbutton_type_secondary'],\n ghost: styles['iconbutton_type_ghost'],\n danger: styles['iconbutton_type_danger'],\n info: styles['iconbutton_type_info'],\n },\n size: {\n default: '',\n sm: styles['iconbutton_size_sm'],\n xs: styles['iconbutton_size_xs'],\n },\n },\n defaultVariants: {\n type: 'primary',\n size: 'default',\n },\n});\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n (\n {\n type = 'primary',\n htmlType = 'button',\n icon,\n size,\n disabled,\n className,\n 'aria-label': ariaLabel,\n ...props\n },\n ref\n ) => {\n const iconName = icon ? icon.toString() : 'unknown icon';\n\n return (\n <button\n aria-label={ariaLabel || iconName}\n {...props}\n type={htmlType}\n className={cn(iconButtonVariants({ type, size }), className)}\n disabled={disabled}\n ref={ref}\n role=\"button\"\n >\n <Icon\n name={icon}\n aria-hidden\n size=\"sm\"\n />\n </button>\n );\n }\n);\n\nIconButton.displayName = 'IconButton';\n"],"names":["Icon"],"mappings":";;;;;;;AAMA,MAAM,kBAAA,GAAqB,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY;AAAA,EAChD,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,OAAA,EAAS,OAAO,yBAAyB,CAAA;AAAA,MACzC,SAAA,EAAW,OAAO,2BAA2B,CAAA;AAAA,MAC7C,KAAA,EAAO,OAAO,uBAAuB,CAAA;AAAA,MACrC,MAAA,EAAQ,OAAO,wBAAwB,CAAA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ellipsisContent = true,
|
|
14
|
+
tooltipProps,
|
|
14
15
|
gap = "sm",
|
|
15
16
|
isResponsive = true,
|
|
16
17
|
...props
|
|
17
18
|
}) => {
|
|
18
|
-
const TextWrapper = ellipsisContent ? EllipsisContent : "div";
|
|
19
19
|
return /* @__PURE__ */ jsxs(
|
|
20
20
|
Container,
|
|
21
21
|
{
|
|
@@ -34,13 +34,14 @@ const IconWrapper = ({
|
|
|
34
34
|
height
|
|
35
35
|
}
|
|
36
36
|
),
|
|
37
|
-
/* @__PURE__ */ jsx(
|
|
38
|
-
|
|
37
|
+
ellipsisContent ? /* @__PURE__ */ jsx(
|
|
38
|
+
EllipsisContent,
|
|
39
39
|
{
|
|
40
|
-
"data-testid":
|
|
40
|
+
"data-testid": "ellipsed-icon-wrapper-text",
|
|
41
|
+
tooltipProps,
|
|
41
42
|
children
|
|
42
43
|
}
|
|
43
|
-
),
|
|
44
|
+
) : /* @__PURE__ */ jsx("div", { "data-testid": "normal-icon-wrapper-text", children }),
|
|
44
45
|
icon && iconDir === "end" && /* @__PURE__ */ jsx(
|
|
45
46
|
SvgImage,
|
|
46
47
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/IconWrapper/IconWrapper.tsx"],"sourcesContent":["import { Container } from '@/components/Container';\nimport { EllipsisContent } from '@/components/EllipsisContent';\nimport { Icon } from '@/components/Icon';\nimport { IconWrapperProps } from './IconWrapper.types';\n\nexport const IconWrapper = ({\n icon,\n iconDir = 'start',\n size = 'sm',\n width,\n height,\n children,\n ellipsisContent = true,\n gap = 'sm',\n isResponsive = true,\n ...props\n}: IconWrapperProps) => {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/IconWrapper/IconWrapper.tsx"],"sourcesContent":["import { Container } from '@/components/Container';\nimport { EllipsisContent } from '@/components/EllipsisContent';\nimport { Icon } from '@/components/Icon';\nimport { IconWrapperProps } from './IconWrapper.types';\n\nexport const IconWrapper = ({\n icon,\n iconDir = 'start',\n size = 'sm',\n width,\n height,\n children,\n ellipsisContent = true,\n tooltipProps,\n gap = 'sm',\n isResponsive = true,\n ...props\n}: IconWrapperProps) => {\n return (\n <Container\n orientation=\"horizontal\"\n gap={gap}\n overflow=\"hidden\"\n isResponsive={isResponsive}\n {...props}\n >\n {icon && iconDir === 'start' && (\n <Icon\n name={icon}\n size={size}\n width={width}\n height={height}\n />\n )}\n {ellipsisContent ? (\n <EllipsisContent\n data-testid=\"ellipsed-icon-wrapper-text\"\n tooltipProps={tooltipProps}\n >\n {children}\n </EllipsisContent>\n ) : (\n <div data-testid=\"normal-icon-wrapper-text\">{children}</div>\n )}\n {icon && iconDir === 'end' && (\n <Icon\n name={icon}\n size={size}\n width={width}\n height={height}\n />\n )}\n </Container>\n );\n};\n"],"names":["Icon"],"mappings":";;;;;AAKO,MAAM,cAAc,CAAC;AAAA,EAC1B,IAAA;AAAA,EACA,OAAA,GAAU,OAAA;AAAA,EACV,IAAA,GAAO,IAAA;AAAA,EACP,KAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA,GAAkB,IAAA;AAAA,EAClB,YAAA;AAAA,EACA,GAAA,GAAM,IAAA;AAAA,EACN,YAAA,GAAe,IAAA;AAAA,EACf,GAAG;AACL,CAAA,KAAwB;AACtB,EAAA,uBACE,IAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAY,YAAA;AAAA,MACZ,GAAA;AAAA,MACA,QAAA,EAAS,QAAA;AAAA,MACT,YAAA;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,IAAA,IAAQ,YAAY,OAAA,oBACnB,GAAA;AAAA,UAACA,QAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,IAAA;AAAA,YACN,IAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA,SACF;AAAA,QAED,eAAA,mBACC,GAAA;AAAA,UAAC,eAAA;AAAA,UAAA;AAAA,YACC,aAAA,EAAY,4BAAA;AAAA,YACZ,YAAA;AAAA,YAEC;AAAA;AAAA,SACH,mBAEA,GAAA,CAAC,KAAA,EAAA,EAAI,aAAA,EAAY,4BAA4B,QAAA,EAAS,CAAA;AAAA,QAEvD,IAAA,IAAQ,YAAY,KAAA,oBACnB,GAAA;AAAA,UAACA,QAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,IAAA;AAAA,YACN,IAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA;AACF;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Link/Link.tsx"],"sourcesContent":["import {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactEventHandler,\n ReactNode,\n forwardRef,\n} from 'react';\nimport { Icon } from '@/components/Icon';\nimport type { IconName } from '@/components/Icon/Icon.types';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Link/Link.tsx"],"sourcesContent":["import {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactEventHandler,\n ReactNode,\n forwardRef,\n} from 'react';\nimport { Icon } from '@/components/Icon';\nimport { cn, cva } from '@/lib/cva';\n\nimport type { IconName } from '@/components/Icon/Icon.types';\nimport type { TextSize, TextWeight } from '@/components/Text';\n\nimport styles from './Link.module.css';\n\nexport interface LinkProps<T extends ElementType = 'a'> {\n /** The font size of the link text */\n size?: TextSize;\n /** The font weight of the link text */\n weight?: TextWeight;\n /** Click event handler */\n onClick?: ReactEventHandler;\n /** The content to display inside the link */\n children?: React.ReactNode;\n /** Optional icon to display after the link text */\n icon?: IconName;\n /** Custom component to render as the link element */\n component?: T;\n}\n\nconst linkVariants = cva(styles.link, {\n variants: {\n size: {\n xs: styles['link_size_xs'],\n sm: styles['link_size_sm'],\n md: styles['link_size_md'],\n lg: styles['link_size_lg'],\n },\n weight: {\n normal: styles['link_weight_normal'],\n medium: styles['link_weight_medium'],\n semibold: styles['link_weight_semibold'],\n bold: styles['link_weight_bold'],\n mono: styles['link_weight_mono'],\n },\n },\n defaultVariants: {\n size: 'md',\n weight: 'normal',\n },\n});\n\nconst iconVariants = cva(styles['link__icon'], {\n variants: {\n size: {\n xs: styles['link__icon_size_xs'],\n sm: styles['link__icon_size_sm'],\n md: styles['link__icon_size_md'],\n lg: styles['link__icon_size_lg'],\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype LinkPolymorphicComponent = <T extends ElementType = 'a'>(\n props: Omit<ComponentProps<T>, keyof LinkProps<T>> & LinkProps<T>\n) => ReactNode;\n\n/** Component for linking to other pages or sections from with body text */\nconst _Link = <T extends ElementType = 'a'>(\n {\n size = 'md',\n weight = 'normal',\n onClick,\n icon,\n children,\n component,\n className,\n ...props\n }: Omit<ComponentProps<T>, keyof LinkProps<T>> & LinkProps<T> & { className?: string },\n ref: ComponentPropsWithRef<T>['ref']\n) => {\n const Component = component ?? 'a';\n return (\n <Component\n ref={ref}\n onClick={onClick}\n {...props}\n className={cn(linkVariants({ size, weight }), className)}\n >\n {children}\n {icon && (\n <span>\n <Icon\n name={icon}\n className={cn(iconVariants({ size }))}\n data-testid={icon}\n />\n </span>\n )}\n </Component>\n );\n};\nexport const Link: LinkPolymorphicComponent = forwardRef(_Link);\n"],"names":["Icon"],"mappings":";;;;;;;AA+BA,MAAM,YAAA,GAAe,GAAA,CAAI,MAAA,CAAO,IAAA,EAAM;AAAA,EACpC,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,EAAA,EAAI,OAAO,cAAc,CAAA;AAAA,MACzB,EAAA,EAAI,OAAO,cAAc,CAAA;AAAA,MACzB,EAAA,EAAI,OAAO,cAAc,CAAA;AAAA,MACzB,EAAA,EAAI,OAAO,cAAc;AAAA,KAC3B;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,MAAA,EAAQ,OAAO,oBAAoB,CAAA;AAAA,MACnC,MAAA,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;AAAA,YACC,IAAA,EAAM,IAAA;AAAA,YACN,WAAW,EAAA,CAAG,YAAA,CAAa,EAAE,IAAA,EAAM,CAAC,CAAA;AAAA,YACpC,aAAA,EAAa;AAAA;AAAA,SACf,EACF;AAAA;AAAA;AAAA,GAEJ;AAEJ,CAAA;AACO,MAAM,IAAA,GAAiC,WAAW,KAAK;;;;"}
|
|
@@ -35,11 +35,11 @@ const Pagination = ({
|
|
|
35
35
|
const leftButtonDisabled = currentPage <= 1;
|
|
36
36
|
const rightButtonDisabled = !!totalPages && currentPage === totalPages || disableNextButton;
|
|
37
37
|
const onChange = (value) => {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
38
|
+
const pageNumber = parseInt(value, 10);
|
|
39
|
+
if (Number.isNaN(pageNumber) || pageNumber < 1 || inputRef.current?.disabled || (typeof totalPages !== "undefined" ? pageNumber > totalPages : false)) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
onChangeProp(
|
|
42
|
+
onChangeProp(pageNumber);
|
|
43
43
|
};
|
|
44
44
|
const onPageSizeChange = (value) => {
|
|
45
45
|
if (typeof onPageSizeChangeProp === "function") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Pagination/Pagination.tsx"],"sourcesContent":["import {\n FocusEventHandler,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useRef,\n} from 'react';\nimport { Container, type ContainerProps } from '@/components/Container';\nimport { IconButton } from '@/components/IconButton';\nimport { NumberField } from '@/components/NumberField';\nimport { Select } from '@/components/Select';\nimport { Text } from '@/components/Text';\nimport styles from './Pagination.module.css';\n\nexport interface PaginationProps extends Omit<\n ContainerProps<'div'>,\n 'children' | 'onChange'\n> {\n /** Total number of pages available */\n totalPages?: number;\n /** The currently selected page number */\n currentPage: number;\n /** List of options for rows per page dropdown */\n maxRowsPerPageList?: number[];\n /** Total row count to display */\n rowCount?: number | string;\n /** Callback when page number changes */\n onChange: (pageNumber: number) => void;\n /** Callback when page size changes */\n onPageSizeChange?: (pageNumber: number) => void;\n /** Current page size/rows per page */\n pageSize?: number;\n /** Callback when next page button is clicked */\n onNextPageClick?: MouseEventHandler<HTMLButtonElement>;\n /** Callback when previous page button is clicked */\n onPrevPageClick?: MouseEventHandler<HTMLButtonElement>;\n /** Callback when page number input receives focus */\n onPageNumberFocus?: FocusEventHandler<HTMLInputElement>;\n /** Callback when page number input loses focus */\n onPageNumberBlur?: FocusEventHandler<HTMLInputElement>;\n /** Whether to disable the next page button */\n disableNextButton?: boolean;\n /** Whether to show \"All rows\" option in the dropdown */\n allowAllRows?: boolean;\n}\n\nexport const Pagination = ({\n totalPages,\n currentPage,\n maxRowsPerPageList = [],\n rowCount,\n onChange: onChangeProp,\n onPageSizeChange: onPageSizeChangeProp,\n pageSize = -1,\n fillWidth = true,\n gap = 'md',\n justifyContent,\n onNextPageClick,\n onPrevPageClick,\n onPageNumberFocus,\n onPageNumberBlur,\n disableNextButton,\n allowAllRows = true,\n ...props\n}: PaginationProps): ReactElement => {\n const hasRowCount = ['number', 'string'].includes(typeof rowCount);\n const inputRef = useRef<HTMLInputElement>(null);\n const formatNumber = (value: number) => {\n return new Intl.NumberFormat('en').format(value);\n };\n const leftButtonDisabled = currentPage <= 1;\n const rightButtonDisabled =\n (!!totalPages && currentPage === totalPages) || disableNextButton;\n\n const onChange = (value: string) => {\n const sanitizedValue = parseInt(value, 10);\n if (\n sanitizedValue < 1 ||\n inputRef.current?.disabled ||\n (typeof totalPages !== 'undefined' ? sanitizedValue > totalPages : false)\n ) {\n return;\n }\n\n onChangeProp(sanitizedValue);\n };\n\n const onPageSizeChange = (value: string) => {\n if (typeof onPageSizeChangeProp === 'function') {\n onPageSizeChangeProp(Number(value));\n }\n };\n\n const onPrevClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n e => {\n if (leftButtonDisabled) {\n return;\n }\n\n onChangeProp(currentPage - 1);\n if (typeof onPrevPageClick === 'function') {\n onPrevPageClick(e);\n }\n },\n [currentPage, leftButtonDisabled, onChangeProp, onPrevPageClick]\n );\n\n const onNextClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n e => {\n if (rightButtonDisabled) {\n return;\n }\n\n onChangeProp(currentPage + 1);\n if (typeof onNextPageClick === 'function') {\n onNextPageClick(e);\n }\n },\n [currentPage, onChangeProp, onNextPageClick, rightButtonDisabled]\n );\n\n // if `allowAllRows` is false we need to switch to the first option in the list\n if (pageSize === -1 && !allowAllRows && maxRowsPerPageList.length > 0) {\n pageSize = maxRowsPerPageList[0];\n }\n\n return (\n <Container\n gap={gap}\n justifyContent={\n justifyContent ??\n (rowCount || maxRowsPerPageList.length > 0 ? 'space-between' : 'center')\n }\n fillWidth={fillWidth}\n {...props}\n >\n {hasRowCount && (\n <Text\n component=\"div\"\n color=\"muted\"\n size=\"sm\"\n >\n {typeof rowCount === 'number' ? formatNumber(rowCount) : rowCount} rows\n </Text>\n )}\n <Container\n gap=\"xxs\"\n fillWidth={false}\n >\n <IconButton\n icon=\"chevron-left\"\n type=\"ghost\"\n disabled={leftButtonDisabled}\n onClick={onPrevClick}\n data-testid=\"prev-btn\"\n />\n <Container\n maxWidth=\"50px\"\n fillWidth={false}\n >\n <NumberField\n ref={inputRef}\n onChange={onChange}\n value={currentPage}\n loading={false}\n aria-label={currentPage.toString()}\n min={1}\n max={totalPages}\n onFocus={onPageNumberFocus}\n hideControls\n onBlur={onPageNumberBlur}\n disabled={leftButtonDisabled && rightButtonDisabled}\n />\n </Container>\n {!!totalPages && (\n <Text\n component=\"div\"\n color=\"muted\"\n size=\"sm\"\n >\n of {formatNumber(totalPages)}\n </Text>\n )}\n <IconButton\n icon=\"chevron-right\"\n type=\"ghost\"\n disabled={rightButtonDisabled}\n onClick={onNextClick}\n data-testid=\"next-btn\"\n />\n </Container>\n {maxRowsPerPageList.length > 0 && (\n <Select\n className={styles['custom-select']}\n onSelect={onPageSizeChange}\n value={pageSize.toString()}\n >\n {allowAllRows && <Select.Item value=\"-1\">All rows</Select.Item>}\n {maxRowsPerPageList.map(option => (\n <Select.Item\n key={option}\n value={option.toString()}\n >\n {option} rows\n </Select.Item>\n ))}\n </Select>\n )}\n </Container>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8CO,MAAM,aAAa,CAAC;AAAA,EACzB,UAAA;AAAA,EACA,WAAA;AAAA,EACA,qBAAqB,EAAC;AAAA,EACtB,QAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,gBAAA,EAAkB,oBAAA;AAAA,EAClB,QAAA,GAAW,EAAA;AAAA,EACX,SAAA,GAAY,IAAA;AAAA,EACZ,GAAA,GAAM,IAAA;AAAA,EACN,cAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,GAAG;AACL,CAAA,KAAqC;AACnC,EAAA,MAAM,cAAc,CAAC,QAAA,EAAU,QAAQ,CAAA,CAAE,QAAA,CAAS,OAAO,QAAQ,CAAA;AACjE,EAAA,MAAM,QAAA,GAAW,OAAyB,IAAI,CAAA;AAC9C,EAAA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAkB;AACtC,IAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,IAAI,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,EACjD,CAAA;AACA,EAAA,MAAM,qBAAqB,WAAA,IAAe,CAAA;AAC1C,EAAA,MAAM,mBAAA,GACH,CAAC,CAAC,UAAA,IAAc,gBAAgB,UAAA,IAAe,iBAAA;AAElD,EAAA,MAAM,QAAA,GAAW,CAAC,KAAA,KAAkB;AAClC,IAAA,MAAM,cAAA,GAAiB,QAAA,CAAS,KAAA,EAAO,EAAE,CAAA;AACzC,IAAA,IACE,cAAA,GAAiB,CAAA,IACjB,QAAA,CAAS,OAAA,EAAS,QAAA,KACjB,OAAO,UAAA,KAAe,WAAA,GAAc,cAAA,GAAiB,UAAA,GAAa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/Pagination/Pagination.tsx"],"sourcesContent":["import {\n FocusEventHandler,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useRef,\n} from 'react';\nimport { Container, type ContainerProps } from '@/components/Container';\nimport { IconButton } from '@/components/IconButton';\nimport { NumberField } from '@/components/NumberField';\nimport { Select } from '@/components/Select';\nimport { Text } from '@/components/Text';\nimport styles from './Pagination.module.css';\n\nexport interface PaginationProps extends Omit<\n ContainerProps<'div'>,\n 'children' | 'onChange'\n> {\n /** Total number of pages available */\n totalPages?: number;\n /** The currently selected page number */\n currentPage: number;\n /** List of options for rows per page dropdown */\n maxRowsPerPageList?: number[];\n /** Total row count to display */\n rowCount?: number | string;\n /** Callback when page number changes */\n onChange: (pageNumber: number) => void;\n /** Callback when page size changes */\n onPageSizeChange?: (pageNumber: number) => void;\n /** Current page size/rows per page */\n pageSize?: number;\n /** Callback when next page button is clicked */\n onNextPageClick?: MouseEventHandler<HTMLButtonElement>;\n /** Callback when previous page button is clicked */\n onPrevPageClick?: MouseEventHandler<HTMLButtonElement>;\n /** Callback when page number input receives focus */\n onPageNumberFocus?: FocusEventHandler<HTMLInputElement>;\n /** Callback when page number input loses focus */\n onPageNumberBlur?: FocusEventHandler<HTMLInputElement>;\n /** Whether to disable the next page button */\n disableNextButton?: boolean;\n /** Whether to show \"All rows\" option in the dropdown */\n allowAllRows?: boolean;\n}\n\nexport const Pagination = ({\n totalPages,\n currentPage,\n maxRowsPerPageList = [],\n rowCount,\n onChange: onChangeProp,\n onPageSizeChange: onPageSizeChangeProp,\n pageSize = -1,\n fillWidth = true,\n gap = 'md',\n justifyContent,\n onNextPageClick,\n onPrevPageClick,\n onPageNumberFocus,\n onPageNumberBlur,\n disableNextButton,\n allowAllRows = true,\n ...props\n}: PaginationProps): ReactElement => {\n const hasRowCount = ['number', 'string'].includes(typeof rowCount);\n const inputRef = useRef<HTMLInputElement>(null);\n const formatNumber = (value: number) => {\n return new Intl.NumberFormat('en').format(value);\n };\n const leftButtonDisabled = currentPage <= 1;\n const rightButtonDisabled =\n (!!totalPages && currentPage === totalPages) || disableNextButton;\n\n const onChange = (value: string) => {\n const pageNumber = parseInt(value, 10);\n if (\n Number.isNaN(pageNumber) ||\n pageNumber < 1 ||\n inputRef.current?.disabled ||\n (typeof totalPages !== 'undefined' ? pageNumber > totalPages : false)\n ) {\n return;\n }\n\n onChangeProp(pageNumber);\n };\n\n const onPageSizeChange = (value: string) => {\n if (typeof onPageSizeChangeProp === 'function') {\n onPageSizeChangeProp(Number(value));\n }\n };\n\n const onPrevClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n e => {\n if (leftButtonDisabled) {\n return;\n }\n\n onChangeProp(currentPage - 1);\n if (typeof onPrevPageClick === 'function') {\n onPrevPageClick(e);\n }\n },\n [currentPage, leftButtonDisabled, onChangeProp, onPrevPageClick]\n );\n\n const onNextClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n e => {\n if (rightButtonDisabled) {\n return;\n }\n\n onChangeProp(currentPage + 1);\n if (typeof onNextPageClick === 'function') {\n onNextPageClick(e);\n }\n },\n [currentPage, onChangeProp, onNextPageClick, rightButtonDisabled]\n );\n\n // if `allowAllRows` is false we need to switch to the first option in the list\n if (pageSize === -1 && !allowAllRows && maxRowsPerPageList.length > 0) {\n pageSize = maxRowsPerPageList[0];\n }\n\n return (\n <Container\n gap={gap}\n justifyContent={\n justifyContent ??\n (rowCount || maxRowsPerPageList.length > 0 ? 'space-between' : 'center')\n }\n fillWidth={fillWidth}\n {...props}\n >\n {hasRowCount && (\n <Text\n component=\"div\"\n color=\"muted\"\n size=\"sm\"\n >\n {typeof rowCount === 'number' ? formatNumber(rowCount) : rowCount} rows\n </Text>\n )}\n <Container\n gap=\"xxs\"\n fillWidth={false}\n >\n <IconButton\n icon=\"chevron-left\"\n type=\"ghost\"\n disabled={leftButtonDisabled}\n onClick={onPrevClick}\n data-testid=\"prev-btn\"\n />\n <Container\n maxWidth=\"50px\"\n fillWidth={false}\n >\n <NumberField\n ref={inputRef}\n onChange={onChange}\n value={currentPage}\n loading={false}\n aria-label={currentPage.toString()}\n min={1}\n max={totalPages}\n onFocus={onPageNumberFocus}\n hideControls\n onBlur={onPageNumberBlur}\n disabled={leftButtonDisabled && rightButtonDisabled}\n />\n </Container>\n {!!totalPages && (\n <Text\n component=\"div\"\n color=\"muted\"\n size=\"sm\"\n >\n of {formatNumber(totalPages)}\n </Text>\n )}\n <IconButton\n icon=\"chevron-right\"\n type=\"ghost\"\n disabled={rightButtonDisabled}\n onClick={onNextClick}\n data-testid=\"next-btn\"\n />\n </Container>\n {maxRowsPerPageList.length > 0 && (\n <Select\n className={styles['custom-select']}\n onSelect={onPageSizeChange}\n value={pageSize.toString()}\n >\n {allowAllRows && <Select.Item value=\"-1\">All rows</Select.Item>}\n {maxRowsPerPageList.map(option => (\n <Select.Item\n key={option}\n value={option.toString()}\n >\n {option} rows\n </Select.Item>\n ))}\n </Select>\n )}\n </Container>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8CO,MAAM,aAAa,CAAC;AAAA,EACzB,UAAA;AAAA,EACA,WAAA;AAAA,EACA,qBAAqB,EAAC;AAAA,EACtB,QAAA;AAAA,EACA,QAAA,EAAU,YAAA;AAAA,EACV,gBAAA,EAAkB,oBAAA;AAAA,EAClB,QAAA,GAAW,EAAA;AAAA,EACX,SAAA,GAAY,IAAA;AAAA,EACZ,GAAA,GAAM,IAAA;AAAA,EACN,cAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,GAAG;AACL,CAAA,KAAqC;AACnC,EAAA,MAAM,cAAc,CAAC,QAAA,EAAU,QAAQ,CAAA,CAAE,QAAA,CAAS,OAAO,QAAQ,CAAA;AACjE,EAAA,MAAM,QAAA,GAAW,OAAyB,IAAI,CAAA;AAC9C,EAAA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAkB;AACtC,IA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