@clickhouse/click-ui 0.10.0 → 0.11.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.
- 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
package/dist/cjs/click-ui.css
CHANGED
|
@@ -972,6 +972,26 @@
|
|
|
972
972
|
width: 100%;
|
|
973
973
|
}
|
|
974
974
|
|
|
975
|
+
.text_wrap_wrap__RR--m {
|
|
976
|
+
white-space: normal;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
.text_wrap_nowrap__DCK82 {
|
|
980
|
+
white-space: nowrap;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
.text_wrap_break-word__Oc5qD {
|
|
984
|
+
white-space: normal;
|
|
985
|
+
/* `anywhere` rather than `break-word` so long words also shrink the
|
|
986
|
+
min-content width, which is what flex and table layouts measure. */
|
|
987
|
+
overflow-wrap: anywhere;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
.text_wrap_break-all__EdYJs {
|
|
991
|
+
white-space: normal;
|
|
992
|
+
word-break: break-all;
|
|
993
|
+
}
|
|
994
|
+
|
|
975
995
|
/* font shorthand depends on both size and weight; one class per pairing
|
|
976
996
|
emits a single `font:` declaration. */
|
|
977
997
|
|
|
@@ -1356,6 +1376,11 @@
|
|
|
1356
1376
|
cursor: pointer;
|
|
1357
1377
|
}
|
|
1358
1378
|
|
|
1379
|
+
.iconbutton__G-cEu:focus-visible {
|
|
1380
|
+
outline: 2px solid var(--click-global-color-outline-default);
|
|
1381
|
+
outline-offset: 2px;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1359
1384
|
.iconbutton_size_sm__tT3BV {
|
|
1360
1385
|
padding: var(--click-button-iconButton-sm-space-y)
|
|
1361
1386
|
var(--click-button-iconButton-sm-space-x);
|
|
@@ -4208,9 +4233,12 @@ div:active + .topbadge__E79OZ {
|
|
|
4208
4233
|
colors are set inline per state via --codeblock-button, matching the
|
|
4209
4234
|
--codeblock-numbers pattern so both track the ThemeProvider runtime. */
|
|
4210
4235
|
--codeblock-button: initial;
|
|
4236
|
+
/* assign context to be above pseudo-element
|
|
4237
|
+
can be cleaned up when background is a regular color variable with alpha */
|
|
4238
|
+
z-index: 1;
|
|
4211
4239
|
padding: 0;
|
|
4212
4240
|
border: 0;
|
|
4213
|
-
color: var(--codeblock-button, inherit);
|
|
4241
|
+
color: var(--codeblock-button, inherit);
|
|
4214
4242
|
}
|
|
4215
4243
|
|
|
4216
4244
|
.codeblock__highlighter__t4Xol {
|
|
@@ -4226,13 +4254,42 @@ div:active + .topbadge__E79OZ {
|
|
|
4226
4254
|
|
|
4227
4255
|
.codeblock__button-container__D6yob {
|
|
4228
4256
|
display: flex;
|
|
4257
|
+
opacity: 0;
|
|
4229
4258
|
position: absolute;
|
|
4230
4259
|
top: var(--click-codeblock-space-y);
|
|
4231
4260
|
right: var(--click-codeblock-space-x);
|
|
4232
|
-
|
|
4261
|
+
padding: var(--spaces-1);
|
|
4262
|
+
gap: var(--spaces-1);
|
|
4263
|
+
pointer-events: none;
|
|
4264
|
+
transition: opacity 200ms ease-in-out;
|
|
4233
4265
|
}
|
|
4266
|
+
|
|
4267
|
+
.codeblock__pRWOC:hover .codeblock__button-container__D6yob,
|
|
4268
|
+
.codeblock__pRWOC:focus-within .codeblock__button-container__D6yob {
|
|
4269
|
+
opacity: 1;
|
|
4270
|
+
pointer-events: auto;
|
|
4271
|
+
transition-duration: 150ms;
|
|
4234
4272
|
}
|
|
4235
|
-
|
|
4273
|
+
|
|
4274
|
+
/* this element can be refactored to a color var with alpha when available */
|
|
4275
|
+
.codeblock__button-container__D6yob::before {
|
|
4276
|
+
content: "";
|
|
4277
|
+
opacity: 0.85;
|
|
4278
|
+
position: absolute;
|
|
4279
|
+
z-index: 0;
|
|
4280
|
+
inset: 0;
|
|
4281
|
+
border-radius: var(--spaces-1);
|
|
4282
|
+
}
|
|
4283
|
+
|
|
4284
|
+
/* custom conditional theming can be later replaced with semantic color tokens */
|
|
4285
|
+
[data-cui-theme="light"] .codeblock__button-container__D6yob::before {
|
|
4286
|
+
background: var(--palette-indigo-100);
|
|
4287
|
+
}
|
|
4288
|
+
|
|
4289
|
+
[data-cui-theme="dark"] .codeblock__button-container__D6yob::before {
|
|
4290
|
+
background: var(--palette-neutral-900);
|
|
4291
|
+
}
|
|
4292
|
+
}@layer clickui {.content__fI-1- {
|
|
4236
4293
|
display: flex;
|
|
4237
4294
|
overflow: hidden;
|
|
4238
4295
|
flex-direction: column;
|
|
@@ -4772,7 +4829,9 @@ div:active + .topbadge__E79OZ {
|
|
|
4772
4829
|
}
|
|
4773
4830
|
}
|
|
4774
4831
|
}
|
|
4775
|
-
@layer clickui {
|
|
4832
|
+
@layer clickui {/* stylelint-disable custom-property-pattern -- design tokens use camelCase (e.g. iconButton) */
|
|
4833
|
+
|
|
4834
|
+
.menu-panel__-IeVm {
|
|
4776
4835
|
display: block;
|
|
4777
4836
|
padding: var(--click-popover-space-y) var(--click-popover-space-x);
|
|
4778
4837
|
border: 1px solid var(--click-popover-color-panel-stroke-default);
|
|
@@ -4797,18 +4856,16 @@ div:active + .topbadge__E79OZ {
|
|
|
4797
4856
|
cursor: pointer;
|
|
4798
4857
|
}
|
|
4799
4858
|
|
|
4800
|
-
.close-button__fpjhc {
|
|
4859
|
+
.menu-panel__-IeVm .close-button__fpjhc {
|
|
4860
|
+
/* Offset by the button's own padding so the cross sits at the panel inset */
|
|
4801
4861
|
position: absolute;
|
|
4802
|
-
top: var(--click-popover-space-y);
|
|
4803
|
-
right: var(--click-popover-space-x);
|
|
4804
|
-
width: var(--click-popover-icon-size-width);
|
|
4805
|
-
height: var(--click-popover-icon-size-height);
|
|
4862
|
+
top: calc(var(--click-popover-space-y) - var(--click-button-iconButton-sm-space-y));
|
|
4863
|
+
right: calc(var(--click-popover-space-x) - var(--click-button-iconButton-sm-space-x));
|
|
4806
4864
|
}
|
|
4807
4865
|
}
|
|
4808
4866
|
@layer clickui {.link__Ly-e3 {
|
|
4809
4867
|
display: inline-flex;
|
|
4810
4868
|
margin: 0;
|
|
4811
|
-
margin-right: var(--link-gap);
|
|
4812
4869
|
align-items: center;
|
|
4813
4870
|
gap: var(--link-gap);
|
|
4814
4871
|
color: var(--click-global-color-text-link-default);
|
|
@@ -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
|
+
}
|
|
@@ -36,6 +36,7 @@ const CodeBlock = ({
|
|
|
36
36
|
showLineNumbers,
|
|
37
37
|
showWrapButton = false,
|
|
38
38
|
wrapLines = false,
|
|
39
|
+
ariaLabel,
|
|
39
40
|
onCopy,
|
|
40
41
|
onCopyError,
|
|
41
42
|
className,
|
|
@@ -68,6 +69,7 @@ const CodeBlock = ({
|
|
|
68
69
|
setTimeout(() => setErrorCopy(false), 2e3);
|
|
69
70
|
}
|
|
70
71
|
};
|
|
72
|
+
const codeRegionLabel = ariaLabel ?? (language ? `${language} code block` : "Code block");
|
|
71
73
|
const wrapElement = () => {
|
|
72
74
|
setWrap((wrap2) => !wrap2);
|
|
73
75
|
};
|
|
@@ -85,30 +87,12 @@ const CodeBlock = ({
|
|
|
85
87
|
style: { "--codeblock-numbers": numbersColor, ...style },
|
|
86
88
|
className: cva.cn(CodeBlock_module.default.codeblock, className),
|
|
87
89
|
children: [
|
|
88
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: CodeBlock_module.default["codeblock__button-container"], children: [
|
|
89
|
-
showWrapButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
-
IconButton.IconButton,
|
|
91
|
-
{
|
|
92
|
-
className: CodeBlock_module.default["codeblock__button"],
|
|
93
|
-
icon: "document",
|
|
94
|
-
onClick: wrapElement
|
|
95
|
-
}
|
|
96
|
-
),
|
|
97
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
-
IconButton.IconButton,
|
|
99
|
-
{
|
|
100
|
-
className: CodeBlock_module.default["codeblock__button"],
|
|
101
|
-
style: {
|
|
102
|
-
"--codeblock-button": copied ? buttonStateColors.success : errorCopy ? buttonStateColors.danger : void 0
|
|
103
|
-
},
|
|
104
|
-
icon: copied ? "check" : errorCopy ? "warning" : "copy",
|
|
105
|
-
onClick: copyCodeToClipboard
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
] }),
|
|
109
90
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
110
91
|
reactSyntaxHighlighter.Light,
|
|
111
92
|
{
|
|
93
|
+
tabIndex: 0,
|
|
94
|
+
role: "group",
|
|
95
|
+
"aria-label": codeRegionLabel,
|
|
112
96
|
language,
|
|
113
97
|
style: customStyle,
|
|
114
98
|
CodeTag: CodeWithRef,
|
|
@@ -143,7 +127,28 @@ const CodeBlock = ({
|
|
|
143
127
|
wrapLongLines: wrap || wrapLines,
|
|
144
128
|
children
|
|
145
129
|
}
|
|
146
|
-
)
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: CodeBlock_module.default["codeblock__button-container"], children: [
|
|
132
|
+
showWrapButton && /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
IconButton.IconButton,
|
|
134
|
+
{
|
|
135
|
+
className: CodeBlock_module.default["codeblock__button"],
|
|
136
|
+
icon: "document",
|
|
137
|
+
onClick: wrapElement
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
141
|
+
IconButton.IconButton,
|
|
142
|
+
{
|
|
143
|
+
className: CodeBlock_module.default["codeblock__button"],
|
|
144
|
+
style: {
|
|
145
|
+
"--codeblock-button": copied ? buttonStateColors.success : errorCopy ? buttonStateColors.danger : void 0
|
|
146
|
+
},
|
|
147
|
+
icon: copied ? "check" : errorCopy ? "warning" : "copy",
|
|
148
|
+
onClick: copyCodeToClipboard
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] })
|
|
147
152
|
]
|
|
148
153
|
}
|
|
149
154
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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 <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 <SyntaxHighlighter\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>\n );\n};\n"],"names":["SyntaxHighlighter","sql","bash","json","tsx","plaintext","useState","useColorStyle","useNumbersColor","useButtonStateColors","wrap","props","jsx","cn","styles","jsxs","IconButton","children","createElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBAA,4BAAA,CAAkB,gBAAA,CAAiB,KAAA,EAAOC,oBAAA,CAAI,OAAA,IAAWA,oBAAG,CAAA;AAC5DD,4BAAA,CAAkB,gBAAA,CAAiB,MAAA,EAAQE,qBAAA,CAAK,OAAA,IAAWA,qBAAI,CAAA;AAC/DF,4BAAA,CAAkB,gBAAA,CAAiB,MAAA,EAAQG,qBAAA,CAAK,OAAA,IAAWA,qBAAI,CAAA;AAC/DH,4BAAA,CAAkB,gBAAA,CAAiB,KAAA,EAAOI,oBAAA,CAAI,OAAA,IAAWA,oBAAG,CAAA;AAC5DJ,4BAAA,CAAkB,gBAAA,CAAiB,WAAA,EAAaK,0BAAA,CAAU,OAAA,IAAWA,0BAAS,CAAA;AAevE,MAAM,YAAY,CAAC;AAAA,EACxB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA,GAAiB,KAAA;AAAA,EACj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A;AAAA,YACC,QAAA;AAAA,YACA,KAAA,EAAO,WAAA;AAAA,YACP,OAAA,EAAS,WAAA;AAAA,YACT,SAAA,EAAWc,yBAAO,wBAAwB,CAAA;AAAA,YAC1C,UAAU,CAAC,EAAE,IAAA,EAAM,UAAA,EAAY,iBAAgB,KAA2B;AACxE,cAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,EAAK,KAAA,KAAU;AAC9B,gBAAA,MAAMG,YAAW,GAAA,CAAI,QAAA;AACrB,gBAAA,MAAM,iBAAA,GAAoBA,WAAU,KAAA,EAAM;AAM1C,gBAAA,IAAI,iBAAA,EAAmB;AACrB,kBAAA,GAAA,CAAI,QAAA,GAAW;AAAA,oBACb,iBAAA;AAAA,oBACA;AAAA,sBACE,QAAA,EAAAA,SAAAA;AAAA,sBACA,UAAA,EAAY;AAAA,wBACV,WAAW;AAAC,uBACd;AAAA,sBACA,OAAA,EAAS,MAAA;AAAA,sBACT,IAAA,EAAM;AAAA;AACR,mBACF;AAAA,gBACF;AAEA,gBAAA,OAAOC,oCAAA,CAAc;AAAA,kBACnB,IAAA,EAAM,GAAA;AAAA,kBACN,UAAA;AAAA,kBACA,eAAA;AAAA,kBACA,GAAA,EAAK;AAAA,iBACN,CAAA;AAAA,cACH,CAAC,CAAA;AAAA,YACH,CAAA;AAAA,YACA,eAAA;AAAA,YACA,WAAW,IAAA,IAAQ,SAAA;AAAA,YACnB,eAAe,IAAA,IAAQ,SAAA;AAAA,YAEtB;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","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","sql","bash","json","tsx","plaintext","useState","useColorStyle","useNumbersColor","useButtonStateColors","wrap","props","jsx","cn","styles","jsxs","children","createElement","IconButton"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBAA,4BAAA,CAAkB,gBAAA,CAAiB,KAAA,EAAOC,oBAAA,CAAI,OAAA,IAAWA,oBAAG,CAAA;AAC5DD,4BAAA,CAAkB,gBAAA,CAAiB,MAAA,EAAQE,qBAAA,CAAK,OAAA,IAAWA,qBAAI,CAAA;AAC/DF,4BAAA,CAAkB,gBAAA,CAAiB,MAAA,EAAQG,qBAAA,CAAK,OAAA,IAAWA,qBAAI,CAAA;AAC/DH,4BAAA,CAAkB,gBAAA,CAAiB,KAAA,EAAOI,oBAAA,CAAI,OAAA,IAAWA,oBAAG,CAAA;AAC5DJ,4BAAA,CAAkB,gBAAA,CAAiB,WAAA,EAAaK,0BAAA,CAAU,OAAA,IAAWA,0BAAS,CAAA;AAevE,MAAM,YAAY,CAAC;AAAA,EACxB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA,GAAiB,KAAA;AAAA,EACjB,SAAA,GAAY,KAAA;AAAA,EACZ,SAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAsB;AACpB,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIC,eAAS,KAAK,CAAA;AAC1C,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIA,eAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA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AAK;AAAA,iBACN,CAAA;AAAA,cACH,CAAC,CAAA;AAAA,YACH,CAAA;AAAA,YACA,eAAA;AAAA,YACA,WAAW,IAAA,IAAQ,SAAA;AAAA,YACnB,eAAe,IAAA,IAAQ,SAAA;AAAA,YAEtB;AAAA;AAAA,SACH;AAAA,wBACAF,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAWD,wBAAA,CAAO,6BAA6B,CAAA,EACjD,QAAA,EAAA;AAAA,UAAA,cAAA,oBACCF,cAAA;AAAA,YAACM,qBAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAWJ,yBAAO,mBAAmB,CAAA;AAAA,cACrC,IAAA,EAAK,UAAA;AAAA,cACL,OAAA,EAAS;AAAA;AAAA,WACX;AAAA,0BAEFF,cAAA;AAAA,YAACM,qBAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAWJ,yBAAO,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;;;;"}
|
|
@@ -32,6 +32,7 @@ const formatDateDetails = (date, timezone) => {
|
|
|
32
32
|
}
|
|
33
33
|
return date.format(formatForPastYear).replace("am", "a.m.").replace("pm", "p.m.");
|
|
34
34
|
};
|
|
35
|
+
const fallbackSystemTimeZone = "America/New_York";
|
|
35
36
|
const DateDetails = ({
|
|
36
37
|
date: date$1,
|
|
37
38
|
side = "top",
|
|
@@ -41,11 +42,13 @@ const DateDetails = ({
|
|
|
41
42
|
}) => {
|
|
42
43
|
const dayjsDate = dayjs__default.default(date$1);
|
|
43
44
|
let systemTime;
|
|
44
|
-
|
|
45
|
+
let resolvedSystemTimeZone = systemTimeZone;
|
|
46
|
+
if (resolvedSystemTimeZone) {
|
|
45
47
|
try {
|
|
46
|
-
systemTime = dayjsDate.tz(
|
|
48
|
+
systemTime = dayjsDate.tz(resolvedSystemTimeZone);
|
|
47
49
|
} catch {
|
|
48
|
-
|
|
50
|
+
resolvedSystemTimeZone = fallbackSystemTimeZone;
|
|
51
|
+
systemTime = dayjsDate.tz(resolvedSystemTimeZone);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
return /* @__PURE__ */ jsxRuntime.jsxs(Popover.Popover, { children: [
|
|
@@ -105,11 +108,11 @@ const DateDetails = ({
|
|
|
105
108
|
}
|
|
106
109
|
),
|
|
107
110
|
/* @__PURE__ */ jsxRuntime.jsx(Container.Container, { justifyContent: "end", children: /* @__PURE__ */ jsxRuntime.jsxs(Text.Text, { size: "sm", children: [
|
|
108
|
-
formatDateDetails(systemTime,
|
|
111
|
+
formatDateDetails(systemTime, resolvedSystemTimeZone),
|
|
109
112
|
" (",
|
|
110
113
|
date.formatTimezone({
|
|
111
114
|
date: systemTime,
|
|
112
|
-
timezone:
|
|
115
|
+
timezone: resolvedSystemTimeZone
|
|
113
116
|
}),
|
|
114
117
|
")"
|
|
115
118
|
] }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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.cjs","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":["dayjs","date","Popover","jsx","Link","Text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BACAF,cAAA,CAACK,mBAAA,EAAA,EAAU,cAAA,EAAe,KAAA,EACxB,yCAACH,SAAA,EAAA,EAAK,IAAA,EAAK,IAAA,EAAM,QAAA,EAAA,iBAAA,CAAkB,SAAA,CAAU,GAAA,EAAI,EAAG,KAAK,GAAE,CAAA,EAC7D,CAAA;AAAA,8BAEAF,cAAA;AAAA,gBAACE,SAAA;AAAA,gBAAA;AAAA,kBACC,KAAA,EAAM,OAAA;AAAA,kBACN,IAAA,EAAK,IAAA;AAAA,kBACN,QAAA,EAAA;AAAA;AAAA,eAED;AAAA,8BACAF,cAAA,CAACK,mBAAA,EAAA,EAAU,cAAA,EAAe,KAAA,EACxB,yCAACH,SAAA,EAAA,EAAK,IAAA,EAAK,IAAA,EAAM,QAAA,EAAA,IAAA,CAAK,MAAM,SAAA,CAAU,OAAA,EAAQ,GAAI,GAAI,GAAE,CAAA,EAC1D;AAAA;AAAA;AAAA;AACF;AAAA;AACF,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -51,7 +51,7 @@ const DropdownTrigger = ({
|
|
|
51
51
|
...props
|
|
52
52
|
}) => {
|
|
53
53
|
if (sub) {
|
|
54
|
-
const { icon, iconDir, ...menuProps } = props;
|
|
54
|
+
const { icon, iconDir, tooltipProps, ...menuProps } = props;
|
|
55
55
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
56
56
|
DropdownMenuItem,
|
|
57
57
|
{
|
|
@@ -63,6 +63,7 @@ const DropdownTrigger = ({
|
|
|
63
63
|
{
|
|
64
64
|
icon,
|
|
65
65
|
iconDir,
|
|
66
|
+
tooltipProps: { side: "right", ...tooltipProps },
|
|
66
67
|
children
|
|
67
68
|
}
|
|
68
69
|
),
|
|
@@ -154,6 +155,7 @@ const DropdownItem = ({
|
|
|
154
155
|
icon,
|
|
155
156
|
iconDir,
|
|
156
157
|
type = "default",
|
|
158
|
+
tooltipProps,
|
|
157
159
|
children,
|
|
158
160
|
...props
|
|
159
161
|
}) => {
|
|
@@ -168,6 +170,7 @@ const DropdownItem = ({
|
|
|
168
170
|
{
|
|
169
171
|
icon,
|
|
170
172
|
iconDir,
|
|
173
|
+
tooltipProps: { side: "right", ...tooltipProps },
|
|
171
174
|
children
|
|
172
175
|
}
|
|
173
176
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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":["jsx","DropdownMenu","GenericMenuItem","cn","styles","forwardRef","jsxs","IconWrapper","Icon","GenericMenuPanel","useInputModality","useResolvedPortalContainer","Arrow","Popover_Arrow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,MAAM,QAAA,GAAW,CAAC,KAAA,qBACvBA,cAAA,CAACC,wBAAa,IAAA,EAAb,EAAmB,GAAG,KAAA,EAAO;AAOhC,MAAM,oBAAoB,CACxB,EAAE,WAAW,GAAG,KAAA,IAChB,GAAA,qBAEAD,cAAA;AAAA,EAACE,2BAAA;AAAA,EAAA;AAAA,IACC,GAAA;AAAA,IACC,GAAI,KAAA;AAAA,IACL,SAAA,EAAWC,MAAA,CAAGC,uBAAA,CAAO,oBAAoB,GAAG,SAAS;AAAA;AACvD,CAAA;AAGF,MAAM,gBAAA,GAA8CC,iBAAW,iBAAiB,CAAA;AAgBhF,MAAM,kBAAkB,CAAC;AAAA,EACvB,GAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,KAAsD;AACpD,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,GAAG,WAAU,GAAI,KAAA;AACxC,IAAA,uBACEC,eAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,IAAIL,uBAAA,CAAa,UAAA;AAAA,QAChB,GAAG,SAAA;AAAA,QAEJ,QAAA,EAAA;AAAA,0BAAAD,cAAA;AAAA,YAACO,uBAAA;AAAA,YAAA;AAAA,cACC,IAAA;AAAA,cACA,OAAA;AAAA,cAEC;AAAA;AAAA,WAC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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,uBACED,cAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,IAAIC,uBAAA,CAAa,IAAA;AAAA,MACjB,IAAA;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,QAAA,kBAAAD,cAAA;AAAA,QAACO,uBAAA;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.cjs","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;\n"],"names":["jsx","DropdownMenu","GenericMenuItem","cn","styles","forwardRef","jsxs","IconWrapper","Icon","GenericMenuPanel","useInputModality","useResolvedPortalContainer","Arrow","Popover_Arrow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAM,QAAA,GAAW,CAAC,KAAA,qBACvBA,cAAA,CAACC,wBAAa,IAAA,EAAb,EAAmB,GAAG,KAAA,EAAO;AAOhC,MAAM,oBAAoB,CACxB,EAAE,WAAW,GAAG,KAAA,IAChB,GAAA,qBAEAD,cAAA;AAAA,EAACE,2BAAA;AAAA,EAAA;AAAA,IACC,GAAA;AAAA,IACC,GAAI,KAAA;AAAA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AA;AACH;AAAA,GACF;AAEJ,CAAA;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA;AAC3B,QAAA,CAAS,IAAA,GAAO,YAAA;;;;;"}
|
|
@@ -13,6 +13,7 @@ const EllipsisContent_module = require('./EllipsisContent.module.css.cjs');
|
|
|
13
13
|
const EllipsisContentComponent = ({
|
|
14
14
|
component,
|
|
15
15
|
className,
|
|
16
|
+
tooltipProps,
|
|
16
17
|
...props
|
|
17
18
|
}, ref) => {
|
|
18
19
|
const Component = component ?? "div";
|
|
@@ -37,9 +38,9 @@ const EllipsisContentComponent = ({
|
|
|
37
38
|
if (!tooltipContent) {
|
|
38
39
|
return content;
|
|
39
40
|
}
|
|
40
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip.Tooltip, { children: [
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip.Tooltip, { disableHoverableContent: true, children: [
|
|
41
42
|
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.Tooltip.Trigger, { asChild: true, children: content }),
|
|
42
|
-
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.Tooltip.Content, { children: tooltipContent })
|
|
43
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.Tooltip.Content, { ...tooltipProps, children: tooltipContent })
|
|
43
44
|
] });
|
|
44
45
|
};
|
|
45
46
|
const EllipsisContent = react.forwardRef(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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.cjs","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":["useState","jsx","mergeRefs","cn","styles","jsxs","Tooltip","forwardRef"],"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,GAAIA,eAAwB,IAAI,CAAA;AAExE,EAAA,MAAM,OAAA,mBACJC,cAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,KAAKC,mBAAA,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,EAAWC,MAAA,CAAGC,8BAAA,CAAO,kBAAkB,GAAG,SAAS;AAAA;AAAA,GACrD;AAGF,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,uBACEC,eAAA,CAACC,eAAA,EAAA,EAAQ,uBAAA,EAAuB,IAAA,EAC9B,QAAA,EAAA;AAAA,oBAAAL,cAAA,CAACK,eAAA,CAAQ,OAAA,EAAR,EAAgB,OAAA,EAAO,MAAE,QAAA,EAAA,OAAA,EAAQ,CAAA;AAAA,mCACjCA,eAAA,CAAQ,OAAA,EAAR,EAAiB,GAAG,cAAe,QAAA,EAAA,cAAA,EAAe;AAAA,GAAA,EACrD,CAAA;AAEJ,CAAA;AAEO,MAAM,eAAA,GAAgDC,gBAAA;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);
|
|
@@ -31,22 +31,32 @@ const iconButtonVariants = classVarianceAuthority.cva(IconButton_module.default.
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
const IconButton = react.forwardRef(
|
|
34
|
-
({
|
|
34
|
+
({
|
|
35
|
+
type = "primary",
|
|
36
|
+
htmlType = "button",
|
|
37
|
+
icon,
|
|
38
|
+
size,
|
|
39
|
+
disabled,
|
|
40
|
+
className,
|
|
41
|
+
"aria-label": ariaLabel,
|
|
42
|
+
...props
|
|
43
|
+
}, ref) => {
|
|
35
44
|
const iconName = icon ? icon.toString() : "unknown icon";
|
|
36
45
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
37
46
|
"button",
|
|
38
47
|
{
|
|
48
|
+
"aria-label": ariaLabel || iconName,
|
|
39
49
|
...props,
|
|
40
50
|
type: htmlType,
|
|
41
51
|
className: cva.cn(iconButtonVariants({ type, size }), className),
|
|
42
52
|
disabled,
|
|
43
53
|
ref,
|
|
44
54
|
role: "button",
|
|
45
|
-
"aria-label": iconName,
|
|
46
55
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
56
|
Icon.Icon,
|
|
48
57
|
{
|
|
49
58
|
name: icon,
|
|
59
|
+
"aria-hidden": true,
|
|
50
60
|
size: "sm"
|
|
51
61
|
}
|
|
52
62
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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.cjs","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":["cva","styles","forwardRef","jsx","cn","Icon"],"mappings":";;;;;;;;;;;AAMA,MAAM,kBAAA,GAAqBA,0BAAA,CAAIC,yBAAA,CAAO,UAAA,EAAY;AAAA,EAChD,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,MACJ,OAAA,EAASA,0BAAO,yBAAyB,CAAA;AAAA,MACzC,SAAA,EAAWA,0BAAO,2BAA2B,CAAA;AAAA,MAC7C,KAAA,EAAOA,0BAAO,uBAAuB,CAAA;AAAA,MACrC,MAAA,EA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
15
|
height,
|
|
16
16
|
children,
|
|
17
17
|
ellipsisContent = true,
|
|
18
|
+
tooltipProps,
|
|
18
19
|
gap = "sm",
|
|
19
20
|
isResponsive = true,
|
|
20
21
|
...props
|
|
21
22
|
}) => {
|
|
22
|
-
const TextWrapper = ellipsisContent ? EllipsisContent.EllipsisContent : "div";
|
|
23
23
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
24
24
|
Container.Container,
|
|
25
25
|
{
|
|
@@ -38,13 +38,14 @@ const IconWrapper = ({
|
|
|
38
38
|
height
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
-
|
|
41
|
+
ellipsisContent ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
EllipsisContent.EllipsisContent,
|
|
43
43
|
{
|
|
44
|
-
"data-testid":
|
|
44
|
+
"data-testid": "ellipsed-icon-wrapper-text",
|
|
45
|
+
tooltipProps,
|
|
45
46
|
children
|
|
46
47
|
}
|
|
47
|
-
),
|
|
48
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "normal-icon-wrapper-text", children }),
|
|
48
49
|
icon && iconDir === "end" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
49
50
|
Icon.Icon,
|
|
50
51
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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.cjs","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":["jsxs","Container","jsx","Icon","EllipsisContent"],"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,uBACEA,eAAA;AAAA,IAACC,mBAAA;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,oBACnBC,cAAA;AAAA,UAACC,SAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,IAAA;AAAA,YACN,IAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA,SACF;AAAA,QAED,eAAA,mBACCD,cAAA;AAAA,UAACE,+BAAA;AAAA,UAAA;AAAA,YACC,aAAA,EAAY,4BAAA;AAAA,YACZ,YAAA;AAAA,YAEC;AAAA;AAAA,SACH,mBAEAF,cAAA,CAAC,KAAA,EAAA,EAAI,aAAA,EAAY,4BAA4B,QAAA,EAAS,CAAA;AAAA,QAEvD,IAAA,IAAQ,YAAY,KAAA,oBACnBA,cAAA;AAAA,UAACC,SAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,IAAA;AAAA,YACN,IAAA;AAAA,YACA,KAAA;AAAA,YACA;AAAA;AAAA;AACF;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|