@oneplatformdev/ui 0.1.99-beta.2 → 0.1.99-beta.20
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/Badge/badgeVariants.d.ts +1 -1
- package/Button/Button.d.ts +12 -6
- package/Button/Button.d.ts.map +1 -1
- package/Button/Button.js +44 -42
- package/Button/Button.js.map +1 -1
- package/Button/Button.stories.js +45 -53
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.types.d.ts +24 -1
- package/Button/Button.types.d.ts.map +1 -1
- package/Button/ButtonCounterBadge.d.ts +7 -0
- package/Button/ButtonCounterBadge.d.ts.map +1 -0
- package/Button/ButtonCounterBadge.js +20 -0
- package/Button/ButtonCounterBadge.js.map +1 -0
- package/Button/buttonVariants.d.ts +11 -20
- package/Button/buttonVariants.d.ts.map +1 -1
- package/Button/buttonVariants.js +74 -11
- package/Button/buttonVariants.js.map +1 -1
- package/Button/index.js +6 -5
- package/ButtonIcon/ButtonIcon.d.ts +55 -0
- package/ButtonIcon/ButtonIcon.d.ts.map +1 -1
- package/ButtonIcon/ButtonIcon.js +70 -46
- package/ButtonIcon/ButtonIcon.js.map +1 -1
- package/ButtonIcon/ButtonIcon.stories.js +121 -78
- package/ButtonIcon/ButtonIcon.stories.js.map +1 -1
- package/ButtonIcon/ButtonIcon.types.d.ts +2 -1
- package/ButtonIcon/ButtonIcon.types.d.ts.map +1 -1
- package/ButtonIcon/buttonIconVariants.d.ts +1 -1
- package/ButtonIcon/buttonIconVariants.js +4 -4
- package/ButtonIcon/buttonIconVariants.js.map +1 -1
- package/CHANGELOG.md +275 -0
- package/Input/Input.d.ts.map +1 -1
- package/Input/Input.js +51 -38
- package/Input/Input.js.map +1 -1
- package/Input/Input.types.d.ts +1 -0
- package/Input/Input.types.d.ts.map +1 -1
- package/LoadedIcon/LoadedIcon.d.ts.map +1 -1
- package/LoadedIcon/LoadedIcon.js +3 -1
- package/LoadedIcon/LoadedIcon.js.map +1 -1
- package/Resizable/Resizable.d.ts +5 -20
- package/Resizable/Resizable.d.ts.map +1 -1
- package/Resizable/Resizable.js +48 -31
- package/Resizable/Resizable.js.map +1 -1
- package/Resizable/Resizable.stories.js +140 -0
- package/Resizable/Resizable.stories.js.map +1 -0
- package/Textarea/Textarea.js +6 -6
- package/Textarea/Textarea.js.map +1 -1
- package/Textarea/Textarea.stories.js +12 -0
- package/Textarea/Textarea.stories.js.map +1 -0
- package/Textarea/useAutosizeTextArea.d.ts +1 -1
- package/Textarea/useAutosizeTextArea.d.ts.map +1 -1
- package/Textarea/useAutosizeTextArea.js.map +1 -1
- package/Tooltip/Tooltip.d.ts.map +1 -1
- package/Tooltip/Tooltip.js.map +1 -1
- package/index.js +326 -325
- package/package.json +7 -4
- package/Button/Button.s.d.ts +0 -83
- package/Button/Button.s.d.ts.map +0 -1
- package/Button/Button.s.js +0 -163
- package/Button/Button.s.js.map +0 -1
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
export declare const buttonVariants: (props?: ({
|
|
3
|
-
variant?: "none" | "
|
|
4
|
-
color?: "
|
|
3
|
+
variant?: "none" | "contained" | "outlined" | "ghost" | null | undefined;
|
|
4
|
+
color?: "primary" | "secondary" | "error" | null | undefined;
|
|
5
5
|
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
6
6
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
/** @deprecated use "variant=contained color=secondary" instead */
|
|
17
|
-
type LegacySecondaryVariant = 'secondary';
|
|
18
|
-
/** @deprecated use "variant=contained color=error" instead */
|
|
19
|
-
type LegacyDestructiveVariant = 'destructive';
|
|
20
|
-
type ModernVariant = Exclude<ButtonCVAVariants, 'default' | 'outline' | 'ghost' | 'secondary' | 'destructive'> | LegacyDefaultVariant | LegacyOutlineVariant | LegacyGhostVariant | LegacySecondaryVariant | LegacyDestructiveVariant;
|
|
21
|
-
export interface ButtonVarianceProps extends ButtonCVANoVariantProps {
|
|
22
|
-
variant?: ModernVariant;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
7
|
+
export type ButtonVarianceProps = VariantProps<typeof buttonVariants>;
|
|
8
|
+
export declare const buttonBadgeVariants: (props?: ({
|
|
9
|
+
variant?: "none" | "contained" | "outlined" | "ghost" | null | undefined;
|
|
10
|
+
color?: "primary" | "secondary" | "error" | null | undefined;
|
|
11
|
+
size?: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
12
|
+
rounded?: boolean | null | undefined;
|
|
13
|
+
disabled?: boolean | null | undefined;
|
|
14
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
15
|
+
export type ButtonBadgeCVAProps = VariantProps<typeof buttonBadgeVariants>;
|
|
25
16
|
//# sourceMappingURL=buttonVariants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttonVariants.d.ts","sourceRoot":"","sources":["../../src/Button/buttonVariants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,eAAO,MAAM,cAAc;;;;
|
|
1
|
+
{"version":3,"file":"buttonVariants.d.ts","sourceRoot":"","sources":["../../src/Button/buttonVariants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,eAAO,MAAM,cAAc;;;;8EA8I1B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtE,eAAO,MAAM,mBAAmB;;;;;;8EAoE/B,CAAA;AACD,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/Button/buttonVariants.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { cva as
|
|
1
|
+
import { cva as r } from "class-variance-authority";
|
|
2
2
|
import { cn as e } from "@oneplatformdev/utils";
|
|
3
|
-
const
|
|
3
|
+
const s = r(
|
|
4
4
|
[
|
|
5
|
-
"inline-flex items-center justify-center",
|
|
5
|
+
"inline-flex items-center justify-center box-border",
|
|
6
6
|
"whitespace-nowrap font-medium",
|
|
7
|
-
"cursor-pointer
|
|
7
|
+
"cursor-pointer",
|
|
8
8
|
"transition-colors focus-visible:outline-hidden focus-visible:ring-none focus-visible:ring-transparent",
|
|
9
9
|
"disabled:pointer-events-none disabled:cursor-default",
|
|
10
10
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
@@ -12,11 +12,6 @@ const o = t(
|
|
|
12
12
|
{
|
|
13
13
|
variants: {
|
|
14
14
|
variant: {
|
|
15
|
-
default: "deprecated.do_not_use",
|
|
16
|
-
outline: "deprecated.do_not_use",
|
|
17
|
-
secondary: "deprecated.do_not_use",
|
|
18
|
-
destructive: "deprecated.do_not_use",
|
|
19
|
-
//
|
|
20
15
|
none: "",
|
|
21
16
|
contained: "",
|
|
22
17
|
outlined: "",
|
|
@@ -35,7 +30,7 @@ const o = t(
|
|
|
35
30
|
"text-sm leading-[1.12] [&_svg]:size-6"
|
|
36
31
|
),
|
|
37
32
|
lg: e(
|
|
38
|
-
"min-h-10 min-w-35 rounded-lg gap-1 px-
|
|
33
|
+
"min-h-10 min-w-35 rounded-lg gap-1 px-2.5 py-1.5",
|
|
39
34
|
"text-base leading-normal [&_svg]:size-6"
|
|
40
35
|
)
|
|
41
36
|
}
|
|
@@ -147,8 +142,76 @@ const o = t(
|
|
|
147
142
|
size: "lg"
|
|
148
143
|
}
|
|
149
144
|
}
|
|
145
|
+
), o = r(
|
|
146
|
+
[
|
|
147
|
+
"absolute z-0",
|
|
148
|
+
"flex items-center justify-center text-center p-0",
|
|
149
|
+
"font-medium leading-none tracking-tighter",
|
|
150
|
+
"rounded-full w-fit min-w-4 h-4 text-[10px] px-0.5 box-border"
|
|
151
|
+
],
|
|
152
|
+
{
|
|
153
|
+
variants: {
|
|
154
|
+
variant: {
|
|
155
|
+
none: "",
|
|
156
|
+
contained: "",
|
|
157
|
+
outlined: "",
|
|
158
|
+
ghost: ""
|
|
159
|
+
},
|
|
160
|
+
color: {
|
|
161
|
+
primary: "",
|
|
162
|
+
secondary: "",
|
|
163
|
+
error: ""
|
|
164
|
+
},
|
|
165
|
+
size: {
|
|
166
|
+
xs: "",
|
|
167
|
+
sm: "",
|
|
168
|
+
md: "",
|
|
169
|
+
lg: "-top-[2px] left-[14px]"
|
|
170
|
+
},
|
|
171
|
+
rounded: {
|
|
172
|
+
true: "left-1/2 -translate-x-1/2 -translate-y-1/2",
|
|
173
|
+
false: ""
|
|
174
|
+
},
|
|
175
|
+
disabled: {
|
|
176
|
+
true: "",
|
|
177
|
+
false: ""
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
compoundVariants: [
|
|
181
|
+
// SIZE XS
|
|
182
|
+
{ size: "xs", rounded: !1, className: "-top-px -right-px translate-x-1/2 -translate-y-1/2" },
|
|
183
|
+
{ size: "xs", rounded: !0, className: "-top-px" },
|
|
184
|
+
// SIZE SM
|
|
185
|
+
{ size: "sm", rounded: !1, className: "top-0 right-0 translate-x-1/2 -translate-y-1/2" },
|
|
186
|
+
{ size: "sm", rounded: !0, className: "-top-[3px]" },
|
|
187
|
+
// SIZE MD
|
|
188
|
+
{ size: "md", rounded: !1, className: "-top-[4px] left-[12px]" },
|
|
189
|
+
{ size: "md", rounded: !0, className: "-top-[6px]" },
|
|
190
|
+
// SIZE LG
|
|
191
|
+
{ size: "lg", rounded: !1, className: "-top-[4px] left-[12px]" },
|
|
192
|
+
{ size: "lg", rounded: !0, className: "-top-2" },
|
|
193
|
+
// COLORS
|
|
194
|
+
{
|
|
195
|
+
color: ["primary", "secondary", "error"],
|
|
196
|
+
className: "bg-[#9368FF] text-[#FCFCFC]"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
color: ["primary", "secondary", "error"],
|
|
200
|
+
disabled: !0,
|
|
201
|
+
className: "bg-[#666A78] text-[#FCFCFC]"
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
defaultVariants: {
|
|
205
|
+
color: "primary",
|
|
206
|
+
variant: "contained",
|
|
207
|
+
size: "lg",
|
|
208
|
+
disabled: !1,
|
|
209
|
+
rounded: !1
|
|
210
|
+
}
|
|
211
|
+
}
|
|
150
212
|
);
|
|
151
213
|
export {
|
|
152
|
-
o as
|
|
214
|
+
o as buttonBadgeVariants,
|
|
215
|
+
s as buttonVariants
|
|
153
216
|
};
|
|
154
217
|
//# sourceMappingURL=buttonVariants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttonVariants.js","sources":["../../src/Button/buttonVariants.ts"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from \"@oneplatformdev/utils\";\n\nexport const buttonVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n 'whitespace-nowrap font-medium',\n 'cursor-pointer box-border',\n \"transition-colors focus-visible:outline-hidden focus-visible:ring-none focus-visible:ring-transparent\",\n \"disabled:pointer-events-none disabled:cursor-default\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n ],\n {\n variants: {\n variant: {\n default: \"deprecated.do_not_use\",\n outline: \"deprecated.do_not_use\",\n secondary: \"deprecated.do_not_use\",\n destructive: \"deprecated.do_not_use\",\n //\n none: \"\",\n contained: \"\",\n outlined: \"\",\n ghost: '',\n },\n color: {\n primary: '',\n secondary: '',\n error: '',\n },\n size: {\n xs: 'rounded-sm p-1 gap-1 text-xs min-h-4 min-w-14',\n sm: 'rounded-md p-1 gap-1 text-sm min-h-6 min-w-20',\n md: cn(\n 'min-h-8 min-w-[102px] rounded-lg gap-1 px-2 py-1',\n 'text-sm leading-[1.12] [&_svg]:size-6',\n ),\n lg: cn(\n \"min-h-10 min-w-35 rounded-lg gap-1 px-3 py-2\",\n 'text-base leading-normal [&_svg]:size-6',\n )\n }\n },\n compoundVariants: [\n // PRIMARY BUTTON VARIANTS\n {\n color: 'primary',\n variant: 'contained',\n className: cn(\n 'bg-[#9368FF] border border-[#9368FF] text-[#FCFCFC] [&_svg]:text-[#FCFCFC]',\n 'hover:bg-[#7F4EEB]',\n 'focus:bg-[#7F4EEB] focus:border-[#6B3DD9]',\n 'active:bg-[#6B3DD9]',\n 'disabled:bg-[#E8E9EB] disabled:border-[#E8E9EB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'primary',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#9368FF] text-[#9368FF] [&_svg]:text-[#9368FF]',\n 'hover:bg-[#9368FF0F]',\n 'active:bg-[#9368FF0F] active:border-[#6B3DD9]',\n 'disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'primary',\n variant: 'ghost',\n className: cn(\n 'bg-transparent border border-transparent text-[#9368FF] [&_svg]:text-[#9368FF]',\n 'hover:text-[#6B3DD9] hover:[&_svg]:text-[#6B3DD9]',\n 'focus:text-[#6B3DD9] focus:[&_svg]:text-[#6B3DD9]',\n 'active:bg-[#9368FF0F]',\n 'disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n // SECONDARY BUTTON VARIANTS\n {\n color: 'secondary',\n variant: 'contained',\n className: cn(\n 'bg-[#FCFCFC] border border-[#E1E1E5] text-[#06080D] [&_svg]:text-[#06080D]',\n 'hover:bg-[#F9FAFB] hover:border-[#E1E1E5]',\n 'focus:bg-[#FCFCFC] focus:border-[#C5C7CD]',\n 'active:bg-[#F9FAFB] active:border-[#C5C7CD]',\n 'disabled:bg-[#FCFCFC] disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'secondary',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#E1E1E5] text-[#06080D] [&_svg]:text-[#06080D]',\n 'hover:bg-[#F9FAFB] hover:border-[#E1E1E5]',\n 'focus:bg-[#FCFCFC] focus:border-[#C5C7CD]',\n 'active:bg-[#F9FAFB] active:border-[#C5C7CD]',\n 'disabled:bg-[#FCFCFC] disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'secondary',\n variant: 'ghost',\n className: cn(\n 'text-[#06080D] [&_svg]:text-[#06080D] bg-transparent border border-transparent',\n 'hover:bg-[#F9FAFB]',\n 'focus:bg-[#FCFCFC]',\n 'active:bg-[#F9FAFB]',\n 'disabled:bg-[#FCFCFC] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n // ERROR BUTTON VARIANTS\n {\n color: 'error',\n variant: 'contained',\n className: cn(\n 'bg-[#EF4444] border border-[#EF4444] text-[#FCFCFC] [&_svg]:text-[#FCFCFC]',\n 'hover:bg-[#DC2626]',\n 'focus:bg-[#DC2626]',\n 'active:bg-[#DC2626]',\n 'disabled:bg-[#E8E9EB] disabled:border-[#E8E9EB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'error',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#EF4444] text-[#EF4444] [&_svg]:text-[#EF4444]',\n 'hover:bg-[#EF44440F]',\n 'active:bg-[#DC26260F] active:border-[#DC2626]',\n 'disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'error',\n variant: 'ghost',\n className: cn(\n 'bg-transparent border border-transparent text-[#EF4444] [&_svg]:text-[#EF4444]',\n 'hover:bg-[#EF44440F] hover:text-[#DC2626] hover:[&_svg]:text-[#DC2626]',\n 'active:bg-[#DC26260F] active:border-[#DC2626]',\n 'disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n ],\n defaultVariants: {\n variant: 'contained',\n color: 'primary',\n size: 'lg',\n },\n }\n)\n\nexport type ButtonCVAProps = VariantProps<typeof buttonVariants>;\n\ntype ButtonCVANoVariantProps = Omit<VariantProps<typeof buttonVariants>, 'variant'>\n\ntype ButtonCVAVariants = ButtonCVAProps['variant'];\n\n/** @deprecated use \"variant=contained color=primary\" instead */\ntype LegacyDefaultVariant = 'default';\n/** @deprecated use \"variant=outlined color=primary\" instead */\ntype LegacyOutlineVariant = 'outline';\n/** @deprecated use \"variant=text color=primary\" instead */\ntype LegacyGhostVariant = 'ghost';\n/** @deprecated use \"variant=contained color=secondary\" instead */\ntype LegacySecondaryVariant = 'secondary';\n/** @deprecated use \"variant=contained color=error\" instead */\ntype LegacyDestructiveVariant = 'destructive';\n\ntype ModernVariant =\n | Exclude<ButtonCVAVariants, 'default' | 'outline' | 'ghost' | 'secondary' | 'destructive'>\n | LegacyDefaultVariant\n | LegacyOutlineVariant\n | LegacyGhostVariant\n | LegacySecondaryVariant\n | LegacyDestructiveVariant;\n\nexport interface ButtonVarianceProps extends ButtonCVANoVariantProps {\n variant?: ModernVariant;\n}\n"],"names":["buttonVariants","cva","cn"],"mappings":";;AAGO,MAAMA,IAAiBC;AAAA,EAC5B;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,QACT,WAAW;AAAA,QACX,aAAa;AAAA;AAAA,QAEb,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA,QACV,OAAO;AAAA,MAAA;AAAA,MAET,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW;AAAA,QACX,OAAO;AAAA,MAAA;AAAA,MAET,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAIC;AAAA,UACF;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,IAAI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AAA,QACP,SAAS;AAAA,QACT,WAAWA;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"buttonVariants.js","sources":["../../src/Button/buttonVariants.ts"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport { cn } from \"@oneplatformdev/utils\";\n\nexport const buttonVariants = cva(\n [\n \"inline-flex items-center justify-center box-border\",\n 'whitespace-nowrap font-medium',\n 'cursor-pointer',\n \"transition-colors focus-visible:outline-hidden focus-visible:ring-none focus-visible:ring-transparent\",\n \"disabled:pointer-events-none disabled:cursor-default\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n ],\n {\n variants: {\n variant: {\n none: \"\",\n contained: \"\",\n outlined: \"\",\n ghost: '',\n },\n color: {\n primary: '',\n secondary: '',\n error: '',\n },\n size: {\n xs: 'rounded-sm p-1 gap-1 text-xs min-h-4 min-w-14',\n sm: 'rounded-md p-1 gap-1 text-sm min-h-6 min-w-20',\n md: cn(\n 'min-h-8 min-w-[102px] rounded-lg gap-1 px-2 py-1',\n 'text-sm leading-[1.12] [&_svg]:size-6',\n ),\n lg: cn(\n \"min-h-10 min-w-35 rounded-lg gap-1 px-2.5 py-1.5\",\n 'text-base leading-normal [&_svg]:size-6',\n )\n }\n },\n compoundVariants: [\n // PRIMARY BUTTON VARIANTS\n {\n color: 'primary',\n variant: 'contained',\n className: cn(\n 'bg-[#9368FF] border border-[#9368FF] text-[#FCFCFC] [&_svg]:text-[#FCFCFC]',\n 'hover:bg-[#7F4EEB]',\n 'focus:bg-[#7F4EEB] focus:border-[#6B3DD9]',\n 'active:bg-[#6B3DD9]',\n 'disabled:bg-[#E8E9EB] disabled:border-[#E8E9EB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'primary',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#9368FF] text-[#9368FF] [&_svg]:text-[#9368FF]',\n 'hover:bg-[#9368FF0F]',\n 'active:bg-[#9368FF0F] active:border-[#6B3DD9]',\n 'disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'primary',\n variant: 'ghost',\n className: cn(\n 'bg-transparent border border-transparent text-[#9368FF] [&_svg]:text-[#9368FF]',\n 'hover:text-[#6B3DD9] hover:[&_svg]:text-[#6B3DD9]',\n 'focus:text-[#6B3DD9] focus:[&_svg]:text-[#6B3DD9]',\n 'active:bg-[#9368FF0F]',\n 'disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n // SECONDARY BUTTON VARIANTS\n {\n color: 'secondary',\n variant: 'contained',\n className: cn(\n 'bg-[#FCFCFC] border border-[#E1E1E5] text-[#06080D] [&_svg]:text-[#06080D]',\n 'hover:bg-[#F9FAFB] hover:border-[#E1E1E5]',\n 'focus:bg-[#FCFCFC] focus:border-[#C5C7CD]',\n 'active:bg-[#F9FAFB] active:border-[#C5C7CD]',\n 'disabled:bg-[#FCFCFC] disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'secondary',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#E1E1E5] text-[#06080D] [&_svg]:text-[#06080D]',\n 'hover:bg-[#F9FAFB] hover:border-[#E1E1E5]',\n 'focus:bg-[#FCFCFC] focus:border-[#C5C7CD]',\n 'active:bg-[#F9FAFB] active:border-[#C5C7CD]',\n 'disabled:bg-[#FCFCFC] disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'secondary',\n variant: 'ghost',\n className: cn(\n 'text-[#06080D] [&_svg]:text-[#06080D] bg-transparent border border-transparent',\n 'hover:bg-[#F9FAFB]',\n 'focus:bg-[#FCFCFC]',\n 'active:bg-[#F9FAFB]',\n 'disabled:bg-[#FCFCFC] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n // ERROR BUTTON VARIANTS\n {\n color: 'error',\n variant: 'contained',\n className: cn(\n 'bg-[#EF4444] border border-[#EF4444] text-[#FCFCFC] [&_svg]:text-[#FCFCFC]',\n 'hover:bg-[#DC2626]',\n 'focus:bg-[#DC2626]',\n 'active:bg-[#DC2626]',\n 'disabled:bg-[#E8E9EB] disabled:border-[#E8E9EB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'error',\n variant: 'outlined',\n className: cn(\n 'bg-transparent border border-[#EF4444] text-[#EF4444] [&_svg]:text-[#EF4444]',\n 'hover:bg-[#EF44440F]',\n 'active:bg-[#DC26260F] active:border-[#DC2626]',\n 'disabled:border-[#EBEBEB] disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n {\n color: 'error',\n variant: 'ghost',\n className: cn(\n 'bg-transparent border border-transparent text-[#EF4444] [&_svg]:text-[#EF4444]',\n 'hover:bg-[#EF44440F] hover:text-[#DC2626] hover:[&_svg]:text-[#DC2626]',\n 'active:bg-[#DC26260F] active:border-[#DC2626]',\n 'disabled:text-[#666A78] disabled:[&_svg]:text-[#666A78]',\n ),\n },\n ],\n defaultVariants: {\n variant: 'contained',\n color: 'primary',\n size: 'lg',\n },\n }\n)\n\nexport type ButtonVarianceProps = VariantProps<typeof buttonVariants>;\n\nexport const buttonBadgeVariants = cva(\n [\n 'absolute z-0',\n 'flex items-center justify-center text-center p-0',\n 'font-medium leading-none tracking-tighter',\n 'rounded-full w-fit min-w-4 h-4 text-[10px] px-0.5 box-border',\n ],\n {\n variants: {\n variant: {\n none: '',\n contained: '',\n outlined: '',\n ghost: \"\",\n },\n color: {\n primary: \"\",\n secondary: \"\",\n error: \"\"\n },\n size: {\n xs: '',\n sm: '',\n md: '',\n lg: '-top-[2px] left-[14px]',\n },\n rounded: {\n true: 'left-1/2 -translate-x-1/2 -translate-y-1/2',\n false: '',\n },\n disabled: {\n true: '',\n false: '',\n }\n },\n compoundVariants: [\n // SIZE XS\n { size: 'xs', rounded: false, className: '-top-px -right-px translate-x-1/2 -translate-y-1/2' },\n { size: 'xs', rounded: true, className: '-top-px' },\n // SIZE SM\n { size: 'sm', rounded: false, className: 'top-0 right-0 translate-x-1/2 -translate-y-1/2' },\n { size: 'sm', rounded: true, className: '-top-[3px]' },\n // SIZE MD\n { size: 'md', rounded: false, className: '-top-[4px] left-[12px]' },\n { size: 'md', rounded: true, className: '-top-[6px]' },\n // SIZE LG\n { size: 'lg', rounded: false, className: '-top-[4px] left-[12px]' },\n { size: 'lg', rounded: true, className: '-top-2' },\n\n // COLORS\n {\n color: ['primary', 'secondary', 'error'],\n className: 'bg-[#9368FF] text-[#FCFCFC]',\n },\n {\n color: ['primary', 'secondary', 'error'],\n disabled: true,\n className: 'bg-[#666A78] text-[#FCFCFC]'\n },\n ],\n defaultVariants: {\n color: \"primary\",\n variant: \"contained\",\n size: \"lg\",\n disabled: false,\n rounded: false,\n },\n }\n)\nexport type ButtonBadgeCVAProps = VariantProps<typeof buttonBadgeVariants>;\n"],"names":["buttonVariants","cva","cn","buttonBadgeVariants"],"mappings":";;AAGO,MAAMA,IAAiBC;AAAA,EAC5B;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,MAAM;AAAA,QACN,WAAW;AAAA,QACX,UAAU;AAAA,QACV,OAAO;AAAA,MAAA;AAAA,MAET,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW;AAAA,QACX,OAAO;AAAA,MAAA;AAAA,MAET,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAIC;AAAA,UACF;AAAA,UACA;A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AAM,WAAW,SAAA;AAAA;AAAA,MAGxC;AAAA,QACE,OAAO,CAAC,WAAW,aAAa,OAAO;AAAA,QACvC,WAAW;AAAA,MAAA;AAAA,MAEb;AAAA,QACE,OAAO,CAAC,WAAW,aAAa,OAAO;AAAA,QACvC,UAAU;AAAA,QACV,WAAW;AAAA,MAAA;AAAA,IACb;AAAA,IAEF,iBAAiB;AAAA,MACf,OAAO;AAAA,MACP,SAAS;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ;"}
|
package/Button/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Button as
|
|
2
|
-
import {
|
|
1
|
+
import { Button as a, Button as n } from "./Button.js";
|
|
2
|
+
import { buttonBadgeVariants as u, buttonVariants as e } from "./buttonVariants.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
u as
|
|
6
|
-
|
|
4
|
+
a as Button,
|
|
5
|
+
u as buttonBadgeVariants,
|
|
6
|
+
e as buttonVariants,
|
|
7
|
+
n as default
|
|
7
8
|
};
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
import { ButtonIconProps } from './ButtonIcon.types';
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Icon-only version of the Button component.
|
|
5
|
+
*
|
|
6
|
+
* `ButtonIcon` is used for compact actions represented by an icon instead of text.
|
|
7
|
+
* Supports all core features of Button: variants, sizes, tooltips, disabled and loading state.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @see [Documentation](#) // TODO: add link to docs
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* > Import:
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { ButtonIcon } from '@oneplatformdev/ui/ButtonIcon';
|
|
16
|
+
* ```
|
|
17
|
+
* > Basic usage by icon:
|
|
18
|
+
* ```tsx
|
|
19
|
+
*<ButtonIcon icon={<PlusIcon />}/>
|
|
20
|
+
*<ButtonIcon icon={PlusIcon}/>
|
|
21
|
+
* ```
|
|
22
|
+
* > Basic usage by children:
|
|
23
|
+
* ```tsx
|
|
24
|
+
*<ButtonIcon>
|
|
25
|
+
* <PlusIcon />
|
|
26
|
+
*</ButtonIcon>
|
|
27
|
+
* ```
|
|
28
|
+
* > With variant & color:
|
|
29
|
+
* ```tsx
|
|
30
|
+
*<ButtonIcon variant="outline" color="primary">
|
|
31
|
+
* <Search />
|
|
32
|
+
*</ButtonIcon>
|
|
33
|
+
* ```
|
|
34
|
+
* > With tooltip message:
|
|
35
|
+
* ```tsx
|
|
36
|
+
*<ButtonIcon message="Edit item">
|
|
37
|
+
* <PencilLine />
|
|
38
|
+
*</ButtonIcon>
|
|
39
|
+
* ```
|
|
40
|
+
* > Loading state:
|
|
41
|
+
* ```tsx
|
|
42
|
+
*<ButtonIcon loading>
|
|
43
|
+
* <Trash2 />
|
|
44
|
+
*</ButtonIcon>
|
|
45
|
+
* ```
|
|
46
|
+
* > Badge counter:
|
|
47
|
+
* ```tsx
|
|
48
|
+
*<ButtonIcon counter={5} icon={MessageCircleMoreIcon}/>
|
|
49
|
+
*<ButtonIcon counter={{ count: 8 }} icon={MessageCircleMoreIcon}/>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* - Designed for icon-only usage. If you need text, use `Button`.
|
|
54
|
+
* - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link Button} for regular text buttons
|
|
57
|
+
*/
|
|
3
58
|
export declare const ButtonIcon: React.ForwardRefExoticComponent<ButtonIconProps & React.RefAttributes<HTMLButtonElement>>;
|
|
4
59
|
export default ButtonIcon;
|
|
5
60
|
//# sourceMappingURL=ButtonIcon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAerD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,UAAU,2FAgFtB,CAAA;AAED,eAAe,UAAU,CAAC"}
|
package/ButtonIcon/ButtonIcon.js
CHANGED
|
@@ -1,61 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { jsxs as g, Fragment as R, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as j from "react";
|
|
3
|
+
import { isValidElement as E, createElement as I } from "react";
|
|
4
|
+
import { cn as V } from "@oneplatformdev/utils";
|
|
5
|
+
import { buttonIconVariants as w } from "./buttonIconVariants.js";
|
|
6
|
+
import { Slot as z } from "@radix-ui/react-slot";
|
|
6
7
|
import "@radix-ui/react-tooltip";
|
|
7
|
-
import { Tooltip as
|
|
8
|
-
import { LoadedIcon as
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { Tooltip as F } from "../Tooltip/Tooltip.js";
|
|
9
|
+
import { LoadedIcon as L } from "../LoadedIcon/LoadedIcon.js";
|
|
10
|
+
import { ButtonCounterBadge as P } from "../Button/ButtonCounterBadge.js";
|
|
11
|
+
const S = (t) => t ? E(t) ? t : I(t) : null, T = j.forwardRef(
|
|
12
|
+
(t, h) => {
|
|
11
13
|
const {
|
|
12
|
-
asChild:
|
|
13
|
-
children:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
asChild: a,
|
|
15
|
+
children: m,
|
|
16
|
+
icon: b,
|
|
17
|
+
disabled: e = !1,
|
|
18
|
+
loading: n = !1,
|
|
19
|
+
message: y,
|
|
20
|
+
title: x = "",
|
|
21
|
+
tooltipProps: l = {},
|
|
22
|
+
className: B,
|
|
23
|
+
variant: c,
|
|
24
|
+
color: p,
|
|
25
|
+
size: s,
|
|
26
|
+
rounded: u,
|
|
27
|
+
screenReader: o,
|
|
28
|
+
counter: N,
|
|
29
|
+
...v
|
|
30
|
+
} = t, C = a ? z : "button", i = y || x, d = a ? m : /* @__PURE__ */ g(R, { children: [
|
|
31
|
+
/* @__PURE__ */ g(L, { loading: n, size: s, children: [
|
|
32
|
+
S(b) ?? m,
|
|
33
|
+
/* @__PURE__ */ r(
|
|
34
|
+
P,
|
|
35
|
+
{
|
|
36
|
+
counter: N,
|
|
37
|
+
variant: c,
|
|
38
|
+
color: p,
|
|
39
|
+
size: s,
|
|
40
|
+
disabled: e,
|
|
41
|
+
rounded: u
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] }),
|
|
45
|
+
!!o && /* @__PURE__ */ r("span", { className: "sr-only", children: typeof o == "string" ? o : o.text })
|
|
46
|
+
] });
|
|
47
|
+
if (!d) return null;
|
|
48
|
+
const f = /* @__PURE__ */ r(
|
|
49
|
+
C,
|
|
27
50
|
{
|
|
28
51
|
type: "button",
|
|
29
|
-
ref:
|
|
30
|
-
disabled:
|
|
31
|
-
className:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
ref: h,
|
|
53
|
+
disabled: e,
|
|
54
|
+
className: V(
|
|
55
|
+
"group group/button group/button-icon",
|
|
56
|
+
w({
|
|
57
|
+
variant: c,
|
|
58
|
+
size: s,
|
|
59
|
+
color: p,
|
|
60
|
+
rounded: u,
|
|
61
|
+
className: B
|
|
38
62
|
}),
|
|
39
|
-
|
|
63
|
+
n && "pointer-events-none opacity-80"
|
|
40
64
|
),
|
|
41
|
-
...
|
|
42
|
-
children:
|
|
65
|
+
...v,
|
|
66
|
+
children: d
|
|
43
67
|
}
|
|
44
68
|
);
|
|
45
|
-
return
|
|
46
|
-
|
|
69
|
+
return i ? /* @__PURE__ */ r(
|
|
70
|
+
F,
|
|
47
71
|
{
|
|
48
|
-
...
|
|
49
|
-
open:
|
|
50
|
-
message:
|
|
51
|
-
children:
|
|
72
|
+
...l || {},
|
|
73
|
+
open: l.open ?? (e || n || !i) ? !1 : void 0,
|
|
74
|
+
message: i,
|
|
75
|
+
children: f
|
|
52
76
|
}
|
|
53
|
-
) :
|
|
77
|
+
) : f;
|
|
54
78
|
}
|
|
55
79
|
);
|
|
56
|
-
|
|
80
|
+
T.displayName = "Button";
|
|
57
81
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
T as ButtonIcon,
|
|
83
|
+
T as default
|
|
60
84
|
};
|
|
61
85
|
//# sourceMappingURL=ButtonIcon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.js","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonIconVariants } from './buttonIconVariants';\nimport { ButtonIconProps } from './ButtonIcon.types';\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\n\nexport const ButtonIcon = React.forwardRef<HTMLButtonElement, ButtonIconProps>(\n (props, ref) => {\n const {\n asChild,\n children,\n disabled = false,\n loading = false,\n message,\n title = '',\n tooltipProps = {},\n className,\n variant,\n color,\n size,\n rounded,\n ...rest\n } = props;\n\n const Comp = asChild ? Slot : \"button\"\n const msg = message || title;\n\n const content = asChild\n ? children\n :
|
|
1
|
+
{"version":3,"file":"ButtonIcon.js","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonIconVariants } from './buttonIconVariants';\nimport { ButtonIconProps } from './ButtonIcon.types';\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\nimport { ButtonIconType } from \"../Button\";\nimport { createElement, isValidElement } from \"react\";\nimport { ButtonCounterBadge } from \"../Button/ButtonCounterBadge\";\n\nconst renderInnerIcon = (Icon?: ButtonIconType) => {\n if (!Icon) return null;\n if (isValidElement(Icon)) return Icon;\n return createElement(Icon);\n};\n\n/**\n * Icon-only version of the Button component.\n *\n * `ButtonIcon` is used for compact actions represented by an icon instead of text.\n * Supports all core features of Button: variants, sizes, tooltips, disabled and loading state.\n *\n * @public\n * @see [Documentation](#) // TODO: add link to docs\n *\n * @example\n * > Import:\n * ```tsx\n * import { ButtonIcon } from '@oneplatformdev/ui/ButtonIcon';\n * ```\n * > Basic usage by icon:\n * ```tsx\n *<ButtonIcon icon={<PlusIcon />}/>\n *<ButtonIcon icon={PlusIcon}/>\n * ```\n * > Basic usage by children:\n * ```tsx\n *<ButtonIcon>\n * <PlusIcon />\n *</ButtonIcon>\n * ```\n * > With variant & color:\n * ```tsx\n *<ButtonIcon variant=\"outline\" color=\"primary\">\n * <Search />\n *</ButtonIcon>\n * ```\n * > With tooltip message:\n * ```tsx\n *<ButtonIcon message=\"Edit item\">\n * <PencilLine />\n *</ButtonIcon>\n * ```\n * > Loading state:\n * ```tsx\n *<ButtonIcon loading>\n * <Trash2 />\n *</ButtonIcon>\n * ```\n * > Badge counter:\n * ```tsx\n *<ButtonIcon counter={5} icon={MessageCircleMoreIcon}/>\n *<ButtonIcon counter={{ count: 8 }} icon={MessageCircleMoreIcon}/>\n * ```\n *\n * @remarks\n * - Designed for icon-only usage. If you need text, use `Button`.\n * - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.\n *\n * @see {@link Button} for regular text buttons\n */\nexport const ButtonIcon = React.forwardRef<HTMLButtonElement, ButtonIconProps>(\n (props, ref) => {\n const {\n asChild,\n children,\n icon,\n disabled = false,\n loading = false,\n message,\n title = '',\n tooltipProps = {},\n className,\n variant,\n color,\n size,\n rounded,\n screenReader,\n counter,\n ...rest\n } = props;\n\n const Comp = asChild ? Slot : \"button\"\n const msg = message || title;\n\n const content = asChild\n ? children\n : (\n <>\n <LoadedIcon loading={loading} size={size}>\n {renderInnerIcon(icon) ?? children}\n <ButtonCounterBadge\n counter={counter}\n variant={variant}\n color={color}\n size={size}\n disabled={disabled}\n rounded={rounded}\n />\n </LoadedIcon>\n\n {!!screenReader && (\n <span className=\"sr-only\">\n {typeof screenReader === 'string' ? screenReader : screenReader.text}\n </span>\n )}\n </>\n )\n\n if (!content) return null;\n\n const cmp = (\n <Comp\n type='button'\n ref={ref}\n disabled={disabled}\n className={cn(\n 'group group/button group/button-icon',\n buttonIconVariants({\n variant, size, color, rounded,\n className\n }),\n loading && 'pointer-events-none opacity-80',\n )}\n {...rest}\n >\n {content}\n </Comp>\n )\n\n if (!msg) return cmp\n return (\n <Tooltip\n {...(tooltipProps || {})}\n open={tooltipProps.open ?? (disabled || loading || !msg) ? false : undefined}\n message={msg}\n >\n {cmp}\n </Tooltip>\n )\n }\n)\nButtonIcon.displayName = \"Button\"\nexport default ButtonIcon;\n"],"names":["renderInnerIcon","Icon","isValidElement","createElement","ButtonIcon","React","props","ref","asChild","children","icon","disabled","loading","message","title","tooltipProps","className","variant","color","size","rounded","screenReader","counter","rest","Comp","Slot","msg","content","jsxs","Fragment","LoadedIcon","jsx","ButtonCounterBadge","cmp","cn","buttonIconVariants","Tooltip"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAAkB,CAACC,M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