@metamask-previews/design-system-react 0.0.0-preview.ff8ed96 → 0.2.0-preview.a7d80d5
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/CHANGELOG.md +39 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.cjs +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.cjs.map +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.mjs +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.mjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.cjs +1 -1
- package/dist/components/AvatarToken/AvatarToken.cjs.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.mjs +1 -1
- package/dist/components/AvatarToken/AvatarToken.mjs.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.cjs +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.cjs.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.mjs +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.mjs.map +1 -1
- package/dist/components/Box/Box.cjs +16 -2
- package/dist/components/Box/Box.cjs.map +1 -1
- package/dist/components/Box/Box.constants.cjs +218 -1
- package/dist/components/Box/Box.constants.cjs.map +1 -1
- package/dist/components/Box/Box.constants.d.cts +16 -1
- package/dist/components/Box/Box.constants.d.cts.map +1 -1
- package/dist/components/Box/Box.constants.d.mts +16 -1
- package/dist/components/Box/Box.constants.d.mts.map +1 -1
- package/dist/components/Box/Box.constants.mjs +217 -0
- package/dist/components/Box/Box.constants.mjs.map +1 -1
- package/dist/components/Box/Box.d.cts +1 -1
- package/dist/components/Box/Box.d.cts.map +1 -1
- package/dist/components/Box/Box.d.mts +1 -1
- package/dist/components/Box/Box.d.mts.map +1 -1
- package/dist/components/Box/Box.mjs +17 -3
- package/dist/components/Box/Box.mjs.map +1 -1
- package/dist/components/Box/Box.types.cjs.map +1 -1
- package/dist/components/Box/Box.types.d.cts +84 -1
- package/dist/components/Box/Box.types.d.cts.map +1 -1
- package/dist/components/Box/Box.types.d.mts +84 -1
- package/dist/components/Box/Box.types.d.mts.map +1 -1
- package/dist/components/Box/Box.types.mjs.map +1 -1
- package/dist/components/Box/index.cjs +3 -1
- package/dist/components/Box/index.cjs.map +1 -1
- package/dist/components/Box/index.d.cts +1 -1
- package/dist/components/Box/index.d.cts.map +1 -1
- package/dist/components/Box/index.d.mts +1 -1
- package/dist/components/Box/index.d.mts.map +1 -1
- package/dist/components/Box/index.mjs +1 -1
- package/dist/components/Box/index.mjs.map +1 -1
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs +8 -6
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs.map +1 -1
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.cts.map +1 -1
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.mts.map +1 -1
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs +8 -6
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs.map +1 -1
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs +12 -12
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs.map +1 -1
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.cts.map +1 -1
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.mts.map +1 -1
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs +12 -12
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs.map +1 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs +3 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs.map +1 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.cts.map +1 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.mts.map +1 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs +3 -1
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.cjs +20 -12
- package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.cjs +2 -2
- package/dist/components/ButtonBase/ButtonBase.constants.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.mjs +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.mjs +21 -13
- package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.types.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.types.d.cts +35 -0
- package/dist/components/ButtonBase/ButtonBase.types.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.types.d.mts +35 -0
- package/dist/components/ButtonBase/ButtonBase.types.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.types.mjs.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.cjs +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.cjs.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.mjs +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.mjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +2 -2
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.mjs +2 -2
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/components/Icon/Icon.cjs +1 -1
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.constants.cjs +2 -2
- package/dist/components/Icon/Icon.constants.cjs.map +1 -1
- package/dist/components/Icon/Icon.constants.d.cts +1 -1
- package/dist/components/Icon/Icon.constants.d.cts.map +1 -1
- package/dist/components/Icon/Icon.constants.d.mts +1 -1
- package/dist/components/Icon/Icon.constants.d.mts.map +1 -1
- package/dist/components/Icon/Icon.constants.mjs +1 -1
- package/dist/components/Icon/Icon.constants.mjs.map +1 -1
- package/dist/components/Icon/Icon.mjs +2 -2
- package/dist/components/Icon/Icon.mjs.map +1 -1
- package/dist/components/Text/Text.constants.cjs +15 -0
- package/dist/components/Text/Text.constants.cjs.map +1 -1
- package/dist/components/Text/Text.constants.d.cts.map +1 -1
- package/dist/components/Text/Text.constants.d.mts.map +1 -1
- package/dist/components/Text/Text.constants.mjs +15 -0
- package/dist/components/Text/Text.constants.mjs.map +1 -1
- package/dist/components/Text/Text.types.cjs.map +1 -1
- package/dist/components/Text/Text.types.d.cts +1 -1
- package/dist/components/Text/Text.types.d.mts +1 -1
- package/dist/components/Text/Text.types.mjs.map +1 -1
- package/dist/components/TextButton/TextButton.cjs +1 -1
- package/dist/components/TextButton/TextButton.cjs.map +1 -1
- package/dist/components/TextButton/TextButton.mjs +1 -1
- package/dist/components/TextButton/TextButton.mjs.map +1 -1
- package/dist/components/index.cjs +4 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +1 -1
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs +5 -2
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.cts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.mts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs +5 -2
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs +6 -3
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts +6 -3
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts +6 -3
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs +6 -3
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +143 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +138 -1
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +138 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +142 -0
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/index.cjs +6 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +2 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +2 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/tw-merge.cjs +1 -5
- package/dist/utils/tw-merge.cjs.map +1 -1
- package/dist/utils/tw-merge.d.cts.map +1 -1
- package/dist/utils/tw-merge.d.mts.map +1 -1
- package/dist/utils/tw-merge.mjs +1 -5
- package/dist/utils/tw-merge.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,cAAc;AAQ1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,cAAc;AAQ1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,wGAiMtB,CAAC"}
|
|
@@ -11,31 +11,39 @@ import { ButtonBaseSize } from "../../types/index.mjs";
|
|
|
11
11
|
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
12
12
|
import { Icon, IconName, IconSize } from "../Icon/index.mjs";
|
|
13
13
|
import { Text, FontWeight, TextColor } from "../Text/index.mjs";
|
|
14
|
-
import {
|
|
15
|
-
export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSize.Lg, isFullWidth, asChild, isDisabled, isLoading, loadingText, loadingIconProps, loadingTextProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, textProps, style, ...props }, ref) => {
|
|
14
|
+
import { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from "./ButtonBase.constants.mjs";
|
|
15
|
+
export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSize.Lg, isFullWidth, asChild, isDisabled, isLoading, loadingText, loadingIconProps, loadingTextProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, textProps, style, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, 'aria-pressed': ariaPressed, 'aria-expanded': ariaExpanded, 'aria-controls': ariaControls, 'aria-haspopup': ariaHaspopup, ...props }, ref) => {
|
|
16
16
|
const Component = asChild ? Slot : 'button';
|
|
17
17
|
const isInteractive = !(isDisabled ?? isLoading);
|
|
18
|
+
// Calculate tabIndex based on asChild and disabled state
|
|
19
|
+
const getTabIndex = () => {
|
|
20
|
+
if (asChild) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return isDisabled ? -1 : undefined;
|
|
24
|
+
};
|
|
18
25
|
const renderLoadingState = () => (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement("span", { className: "absolute inline-flex items-center" },
|
|
20
|
-
React.createElement(Icon, { name: IconName.Loading, size: IconSize.Sm, className: twMerge('
|
|
26
|
+
React.createElement("span", { className: "absolute inline-flex items-center", "aria-hidden": "true" },
|
|
27
|
+
React.createElement(Icon, { name: IconName.Loading, size: IconSize.Sm, className: twMerge('mr-2 animate-spin text-inherit', loadingIconProps?.className), ...loadingIconProps }),
|
|
21
28
|
React.createElement(Text, { fontWeight: FontWeight.Medium, color: TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
22
29
|
React.createElement("span", null, loadingText))),
|
|
23
|
-
React.createElement("span", { className: "invisible inline-flex items-center" }, children)
|
|
30
|
+
React.createElement("span", { className: "invisible inline-flex items-center" }, children),
|
|
31
|
+
React.createElement("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true" }, loadingText || 'Loading')));
|
|
24
32
|
const renderStartContent = () => {
|
|
25
33
|
if (startIconName) {
|
|
26
|
-
return (React.createElement(Icon, { name: startIconName, size: IconSize.Sm, className: twMerge('
|
|
34
|
+
return (React.createElement(Icon, { name: startIconName, size: IconSize.Sm, className: twMerge('mr-2 shrink-0 text-inherit', startIconProps?.className), "aria-hidden": "true", ...startIconProps }));
|
|
27
35
|
}
|
|
28
36
|
if (startAccessory) {
|
|
29
|
-
return React.createElement("span", { className: "mr-2" }, startAccessory);
|
|
37
|
+
return (React.createElement("span", { className: "mr-2", "aria-hidden": "true" }, startAccessory));
|
|
30
38
|
}
|
|
31
39
|
return null;
|
|
32
40
|
};
|
|
33
41
|
const renderEndContent = () => {
|
|
34
42
|
if (endIconName) {
|
|
35
|
-
return (React.createElement(Icon, { name: endIconName, size: IconSize.Sm, className: twMerge('
|
|
43
|
+
return (React.createElement(Icon, { name: endIconName, size: IconSize.Sm, className: twMerge('ml-2 shrink-0 text-inherit', endIconProps?.className), "aria-hidden": "true", ...endIconProps }));
|
|
36
44
|
}
|
|
37
45
|
if (endAccessory) {
|
|
38
|
-
return React.createElement("span", { className: "ml-2" }, endAccessory);
|
|
46
|
+
return (React.createElement("span", { className: "ml-2", "aria-hidden": "true" }, endAccessory));
|
|
39
47
|
}
|
|
40
48
|
return null;
|
|
41
49
|
};
|
|
@@ -48,16 +56,16 @@ export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSi
|
|
|
48
56
|
};
|
|
49
57
|
const mergedClassName = twMerge(
|
|
50
58
|
// Base styles
|
|
51
|
-
'inline-flex items-center justify-center', 'rounded-
|
|
59
|
+
'inline-flex items-center justify-center', 'rounded-xl px-4', 'font-medium text-default', 'bg-muted', 'min-w-20 overflow-hidden',
|
|
52
60
|
// Add relative positioning for loading state
|
|
53
61
|
'relative',
|
|
54
62
|
// Size
|
|
55
|
-
|
|
63
|
+
TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],
|
|
56
64
|
// Full width
|
|
57
65
|
isFullWidth && 'w-full',
|
|
58
66
|
// Animation classes - only applied when interactive
|
|
59
67
|
isInteractive && [
|
|
60
|
-
'transition-
|
|
68
|
+
'transition-all',
|
|
61
69
|
'duration-100',
|
|
62
70
|
'ease-linear',
|
|
63
71
|
'active:scale-[0.97]',
|
|
@@ -67,7 +75,7 @@ export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSi
|
|
|
67
75
|
(isDisabled || isLoading) && 'cursor-not-allowed', isDisabled && 'opacity-50',
|
|
68
76
|
// Custom classes
|
|
69
77
|
className);
|
|
70
|
-
return (React.createElement(Component, { ref: ref, className: mergedClassName, disabled: asChild ? undefined : (isDisabled ?? isLoading), style: style, ...props },
|
|
78
|
+
return (React.createElement(Component, { ref: ref, className: mergedClassName, disabled: asChild ? undefined : (isDisabled ?? isLoading), "aria-disabled": isDisabled ? 'true' : undefined, "aria-busy": isLoading ? 'true' : undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-pressed": ariaPressed, "aria-expanded": ariaExpanded, "aria-controls": ariaControls, "aria-haspopup": ariaHaspopup, role: asChild ? undefined : 'button', tabIndex: getTabIndex(), style: style, ...props },
|
|
71
79
|
renderStartContent(),
|
|
72
80
|
React.createElement(Slottable, null, isLoading ? renderLoadingState() : renderContent()),
|
|
73
81
|
renderEndContent()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,6BAA6B;AACvD,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAC7C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,0BAAgB;AACnD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,0BAAgB;AAEtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,6BAA6B;AACvD,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,cAA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,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,oBAAC,SAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { ButtonBaseSize } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, IconName, IconSize } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n (\n {\n children,\n className,\n size = ButtonBaseSize.Lg,\n isFullWidth,\n asChild,\n isDisabled,\n isLoading,\n loadingText,\n loadingIconProps,\n loadingTextProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n textProps,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n 'aria-haspopup': ariaHaspopup,\n ...props\n },\n ref,\n ) => {\n const Component = asChild ? Slot : 'button';\n const isInteractive = !(isDisabled ?? isLoading);\n\n // Calculate tabIndex based on asChild and disabled state\n const getTabIndex = () => {\n if (asChild) {\n return undefined;\n }\n return isDisabled ? -1 : undefined;\n };\n\n const renderLoadingState = () => (\n <>\n <span className=\"absolute inline-flex items-center\" aria-hidden=\"true\">\n <Icon\n name={IconName.Loading}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...loadingTextProps}\n >\n <span>{loadingText}</span>\n </Text>\n </span>\n <span className=\"invisible inline-flex items-center\">{children}</span>\n {/* Screen reader announcement for loading */}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {loadingText || 'Loading'}\n </span>\n </>\n );\n\n const renderStartContent = () => {\n if (startIconName) {\n return (\n <Icon\n name={startIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return (\n <span className=\"mr-2\" aria-hidden=\"true\">\n {startAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endIconName) {\n return (\n <Icon\n name={endIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'ml-2 shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return (\n <span className=\"ml-2\" aria-hidden=\"true\">\n {endAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderContent = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...textProps}\n >\n <span>{children}</span>\n </Text>\n );\n }\n return children;\n };\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n 'rounded-xl px-4',\n 'font-medium text-default',\n 'bg-muted',\n 'min-w-20 overflow-hidden',\n // Add relative positioning for loading state\n 'relative',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // Full width\n isFullWidth && 'w-full',\n // Animation classes - only applied when interactive\n isInteractive && [\n 'transition-all',\n 'duration-100',\n 'ease-linear',\n 'active:scale-[0.97]',\n 'active:ease-[cubic-bezier(0.3,0.8,0.3,1)]',\n ],\n // Disabled state - apply to both isDisabled and isLoading\n (isDisabled || isLoading) && 'cursor-not-allowed',\n isDisabled && 'opacity-50',\n // Custom classes\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={mergedClassName}\n disabled={asChild ? undefined : (isDisabled ?? isLoading)}\n aria-disabled={isDisabled ? 'true' : undefined}\n aria-busy={isLoading ? 'true' : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n aria-pressed={ariaPressed}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={ariaHaspopup}\n role={asChild ? undefined : 'button'}\n tabIndex={getTabIndex()}\n style={style}\n {...props}\n >\n {renderStartContent()}\n <Slottable>\n {isLoading ? renderLoadingState() : renderContent()}\n </Slottable>\n {renderEndContent()}\n </Component>\n );\n },\n);\n\nButtonBase.displayName = 'ButtonBase';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.types.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\nimport type { ButtonBaseSize } from '../../types';\nimport type { IconName, IconProps } from '../Icon';\nimport type { TextProps } from '../Text';\n\nexport type ButtonBaseProps = ComponentProps<'button'> & {\n /**\n * Required prop for the content to be rendered within the ButtonBase\n */\n children: React.ReactNode;\n /**\n * Optional prop for additional CSS classes to be applied to the ButtonBase component.\n * These classes will be merged with the component's default classes using twMerge.\n */\n className?: string;\n /**\n * Optional prop to control the size of the ButtonBase\n *\n * @default ButtonBaseSize.Lg\n */\n size?: ButtonBaseSize;\n /**\n * Optional props to be passed to the Text component when children is a string\n */\n textProps?: Partial<TextProps>;\n /**\n * Optional prop that when true, makes the button take up the full width of its container\n *\n * @default false\n */\n isFullWidth?: boolean;\n /**\n * Optional boolean that determines if the component should merge its props onto its immediate child\n * instead of rendering a button element\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Optional prop that when true, shows a loading spinner\n *\n * @default false\n */\n isLoading?: boolean;\n /**\n * Optional prop for text to display when button is in loading state\n */\n loadingText?: string;\n /**\n * Optional props to be passed to the loading Text component\n */\n loadingTextProps?: Partial<TextProps>;\n /**\n * Optional prop to specify an icon to show at the start of the button\n */\n startIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the start icon\n */\n startIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the start of the button\n */\n startAccessory?: React.ReactNode;\n /**\n * Optional prop to specify an icon to show at the end of the button\n */\n endIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the end icon\n */\n endIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the end of the button\n */\n endAccessory?: React.ReactNode;\n /**\n * Optional prop that when true, disables the button\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Optional prop to pass additional properties to the loading icon\n */\n loadingIconProps?: Partial<IconProps>;\n /**\n * Optional CSS styles to be applied to the component.\n * Should be used sparingly and only for dynamic styles that can't be achieved with className.\n */\n style?: React.CSSProperties;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.types.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\nimport type { ButtonBaseSize } from '../../types';\nimport type { IconName, IconProps } from '../Icon';\nimport type { TextProps } from '../Text';\n\nexport type ButtonBaseProps = ComponentProps<'button'> & {\n /**\n * Required prop for the content to be rendered within the ButtonBase\n */\n children: React.ReactNode;\n /**\n * Optional prop for additional CSS classes to be applied to the ButtonBase component.\n * These classes will be merged with the component's default classes using twMerge.\n */\n className?: string;\n /**\n * Optional prop to control the size of the ButtonBase\n *\n * @default ButtonBaseSize.Lg\n */\n size?: ButtonBaseSize;\n /**\n * Optional props to be passed to the Text component when children is a string\n */\n textProps?: Partial<TextProps>;\n /**\n * Optional prop that when true, makes the button take up the full width of its container\n *\n * @default false\n */\n isFullWidth?: boolean;\n /**\n * Optional boolean that determines if the component should merge its props onto its immediate child\n * instead of rendering a button element\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Optional prop that when true, shows a loading spinner\n *\n * @default false\n */\n isLoading?: boolean;\n /**\n * Optional prop for text to display when button is in loading state\n */\n loadingText?: string;\n /**\n * Optional props to be passed to the loading Text component\n */\n loadingTextProps?: Partial<TextProps>;\n /**\n * Optional prop to specify an icon to show at the start of the button\n */\n startIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the start icon\n */\n startIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the start of the button\n */\n startAccessory?: React.ReactNode;\n /**\n * Optional prop to specify an icon to show at the end of the button\n */\n endIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the end icon\n */\n endIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the end of the button\n */\n endAccessory?: React.ReactNode;\n /**\n * Optional prop that when true, disables the button\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Optional prop to pass additional properties to the loading icon\n */\n loadingIconProps?: Partial<IconProps>;\n /**\n * Optional CSS styles to be applied to the component.\n * Should be used sparingly and only for dynamic styles that can't be achieved with className.\n */\n style?: React.CSSProperties;\n\n // Accessibility props\n /**\n * Optional accessible label for the button. Use when the button text doesn't fully describe its purpose.\n * This will be used as the aria-label attribute.\n */\n 'aria-label'?: string;\n /**\n * Optional ID of an element that labels the button.\n * This will be used as the aria-labelledby attribute.\n */\n 'aria-labelledby'?: string;\n /**\n * Optional ID of an element that describes the button.\n * This will be used as the aria-describedby attribute.\n */\n 'aria-describedby'?: string;\n /**\n * Optional prop to indicate if the button is pressed (for toggle buttons).\n * This will be used as the aria-pressed attribute.\n */\n 'aria-pressed'?: boolean | 'mixed';\n /**\n * Optional prop to indicate if the button controls a collapsible element.\n * This will be used as the aria-expanded attribute.\n */\n 'aria-expanded'?: boolean;\n /**\n * Optional prop to indicate if the button controls another element.\n * This will be used as the aria-controls attribute.\n */\n 'aria-controls'?: string;\n /**\n * Optional prop to indicate if the button has a popup (menu, listbox, tree, grid, or dialog).\n * This will be used as the aria-haspopup attribute.\n */\n 'aria-haspopup'?:\n | boolean\n | 'false'\n | 'true'\n | 'menu'\n | 'listbox'\n | 'tree'\n | 'grid'\n | 'dialog';\n};\n"]}
|
|
@@ -88,5 +88,40 @@ export type ButtonBaseProps = ComponentProps<'button'> & {
|
|
|
88
88
|
* Should be used sparingly and only for dynamic styles that can't be achieved with className.
|
|
89
89
|
*/
|
|
90
90
|
style?: React.CSSProperties;
|
|
91
|
+
/**
|
|
92
|
+
* Optional accessible label for the button. Use when the button text doesn't fully describe its purpose.
|
|
93
|
+
* This will be used as the aria-label attribute.
|
|
94
|
+
*/
|
|
95
|
+
'aria-label'?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Optional ID of an element that labels the button.
|
|
98
|
+
* This will be used as the aria-labelledby attribute.
|
|
99
|
+
*/
|
|
100
|
+
'aria-labelledby'?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Optional ID of an element that describes the button.
|
|
103
|
+
* This will be used as the aria-describedby attribute.
|
|
104
|
+
*/
|
|
105
|
+
'aria-describedby'?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional prop to indicate if the button is pressed (for toggle buttons).
|
|
108
|
+
* This will be used as the aria-pressed attribute.
|
|
109
|
+
*/
|
|
110
|
+
'aria-pressed'?: boolean | 'mixed';
|
|
111
|
+
/**
|
|
112
|
+
* Optional prop to indicate if the button controls a collapsible element.
|
|
113
|
+
* This will be used as the aria-expanded attribute.
|
|
114
|
+
*/
|
|
115
|
+
'aria-expanded'?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Optional prop to indicate if the button controls another element.
|
|
118
|
+
* This will be used as the aria-controls attribute.
|
|
119
|
+
*/
|
|
120
|
+
'aria-controls'?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional prop to indicate if the button has a popup (menu, listbox, tree, grid, or dialog).
|
|
123
|
+
* This will be used as the aria-haspopup attribute.
|
|
124
|
+
*/
|
|
125
|
+
'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
91
126
|
};
|
|
92
127
|
//# sourceMappingURL=ButtonBase.types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,8BAAoB;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,0BAAgB;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG;IACvD;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,8BAAoB;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,0BAAgB;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG;IACvD;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAG5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EACZ,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,MAAM,GACN,MAAM,GACN,QAAQ,CAAC;CACd,CAAC"}
|
|
@@ -88,5 +88,40 @@ export type ButtonBaseProps = ComponentProps<'button'> & {
|
|
|
88
88
|
* Should be used sparingly and only for dynamic styles that can't be achieved with className.
|
|
89
89
|
*/
|
|
90
90
|
style?: React.CSSProperties;
|
|
91
|
+
/**
|
|
92
|
+
* Optional accessible label for the button. Use when the button text doesn't fully describe its purpose.
|
|
93
|
+
* This will be used as the aria-label attribute.
|
|
94
|
+
*/
|
|
95
|
+
'aria-label'?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Optional ID of an element that labels the button.
|
|
98
|
+
* This will be used as the aria-labelledby attribute.
|
|
99
|
+
*/
|
|
100
|
+
'aria-labelledby'?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Optional ID of an element that describes the button.
|
|
103
|
+
* This will be used as the aria-describedby attribute.
|
|
104
|
+
*/
|
|
105
|
+
'aria-describedby'?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional prop to indicate if the button is pressed (for toggle buttons).
|
|
108
|
+
* This will be used as the aria-pressed attribute.
|
|
109
|
+
*/
|
|
110
|
+
'aria-pressed'?: boolean | 'mixed';
|
|
111
|
+
/**
|
|
112
|
+
* Optional prop to indicate if the button controls a collapsible element.
|
|
113
|
+
* This will be used as the aria-expanded attribute.
|
|
114
|
+
*/
|
|
115
|
+
'aria-expanded'?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Optional prop to indicate if the button controls another element.
|
|
118
|
+
* This will be used as the aria-controls attribute.
|
|
119
|
+
*/
|
|
120
|
+
'aria-controls'?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Optional prop to indicate if the button has a popup (menu, listbox, tree, grid, or dialog).
|
|
123
|
+
* This will be used as the aria-haspopup attribute.
|
|
124
|
+
*/
|
|
125
|
+
'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
91
126
|
};
|
|
92
127
|
//# sourceMappingURL=ButtonBase.types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.types.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,8BAAoB;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,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AAC,CAAC;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAG5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EACZ,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,MAAM,GACN,MAAM,GACN,QAAQ,CAAC;CACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.types.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\nimport type { ButtonBaseSize } from '../../types';\nimport type { IconName, IconProps } from '../Icon';\nimport type { TextProps } from '../Text';\n\nexport type ButtonBaseProps = ComponentProps<'button'> & {\n /**\n * Required prop for the content to be rendered within the ButtonBase\n */\n children: React.ReactNode;\n /**\n * Optional prop for additional CSS classes to be applied to the ButtonBase component.\n * These classes will be merged with the component's default classes using twMerge.\n */\n className?: string;\n /**\n * Optional prop to control the size of the ButtonBase\n *\n * @default ButtonBaseSize.Lg\n */\n size?: ButtonBaseSize;\n /**\n * Optional props to be passed to the Text component when children is a string\n */\n textProps?: Partial<TextProps>;\n /**\n * Optional prop that when true, makes the button take up the full width of its container\n *\n * @default false\n */\n isFullWidth?: boolean;\n /**\n * Optional boolean that determines if the component should merge its props onto its immediate child\n * instead of rendering a button element\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Optional prop that when true, shows a loading spinner\n *\n * @default false\n */\n isLoading?: boolean;\n /**\n * Optional prop for text to display when button is in loading state\n */\n loadingText?: string;\n /**\n * Optional props to be passed to the loading Text component\n */\n loadingTextProps?: Partial<TextProps>;\n /**\n * Optional prop to specify an icon to show at the start of the button\n */\n startIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the start icon\n */\n startIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the start of the button\n */\n startAccessory?: React.ReactNode;\n /**\n * Optional prop to specify an icon to show at the end of the button\n */\n endIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the end icon\n */\n endIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the end of the button\n */\n endAccessory?: React.ReactNode;\n /**\n * Optional prop that when true, disables the button\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Optional prop to pass additional properties to the loading icon\n */\n loadingIconProps?: Partial<IconProps>;\n /**\n * Optional CSS styles to be applied to the component.\n * Should be used sparingly and only for dynamic styles that can't be achieved with className.\n */\n style?: React.CSSProperties;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.types.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\nimport type { ButtonBaseSize } from '../../types';\nimport type { IconName, IconProps } from '../Icon';\nimport type { TextProps } from '../Text';\n\nexport type ButtonBaseProps = ComponentProps<'button'> & {\n /**\n * Required prop for the content to be rendered within the ButtonBase\n */\n children: React.ReactNode;\n /**\n * Optional prop for additional CSS classes to be applied to the ButtonBase component.\n * These classes will be merged with the component's default classes using twMerge.\n */\n className?: string;\n /**\n * Optional prop to control the size of the ButtonBase\n *\n * @default ButtonBaseSize.Lg\n */\n size?: ButtonBaseSize;\n /**\n * Optional props to be passed to the Text component when children is a string\n */\n textProps?: Partial<TextProps>;\n /**\n * Optional prop that when true, makes the button take up the full width of its container\n *\n * @default false\n */\n isFullWidth?: boolean;\n /**\n * Optional boolean that determines if the component should merge its props onto its immediate child\n * instead of rendering a button element\n *\n * @default false\n */\n asChild?: boolean;\n /**\n * Optional prop that when true, shows a loading spinner\n *\n * @default false\n */\n isLoading?: boolean;\n /**\n * Optional prop for text to display when button is in loading state\n */\n loadingText?: string;\n /**\n * Optional props to be passed to the loading Text component\n */\n loadingTextProps?: Partial<TextProps>;\n /**\n * Optional prop to specify an icon to show at the start of the button\n */\n startIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the start icon\n */\n startIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the start of the button\n */\n startAccessory?: React.ReactNode;\n /**\n * Optional prop to specify an icon to show at the end of the button\n */\n endIconName?: IconName;\n /**\n * Optional prop to pass additional properties to the end icon\n */\n endIconProps?: Partial<IconProps>;\n /**\n * Optional prop for a custom element to show at the end of the button\n */\n endAccessory?: React.ReactNode;\n /**\n * Optional prop that when true, disables the button\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Optional prop to pass additional properties to the loading icon\n */\n loadingIconProps?: Partial<IconProps>;\n /**\n * Optional CSS styles to be applied to the component.\n * Should be used sparingly and only for dynamic styles that can't be achieved with className.\n */\n style?: React.CSSProperties;\n\n // Accessibility props\n /**\n * Optional accessible label for the button. Use when the button text doesn't fully describe its purpose.\n * This will be used as the aria-label attribute.\n */\n 'aria-label'?: string;\n /**\n * Optional ID of an element that labels the button.\n * This will be used as the aria-labelledby attribute.\n */\n 'aria-labelledby'?: string;\n /**\n * Optional ID of an element that describes the button.\n * This will be used as the aria-describedby attribute.\n */\n 'aria-describedby'?: string;\n /**\n * Optional prop to indicate if the button is pressed (for toggle buttons).\n * This will be used as the aria-pressed attribute.\n */\n 'aria-pressed'?: boolean | 'mixed';\n /**\n * Optional prop to indicate if the button controls a collapsible element.\n * This will be used as the aria-expanded attribute.\n */\n 'aria-expanded'?: boolean;\n /**\n * Optional prop to indicate if the button controls another element.\n * This will be used as the aria-controls attribute.\n */\n 'aria-controls'?: string;\n /**\n * Optional prop to indicate if the button has a popup (menu, listbox, tree, grid, or dialog).\n * This will be used as the aria-haspopup attribute.\n */\n 'aria-haspopup'?:\n | boolean\n | 'false'\n | 'true'\n | 'menu'\n | 'listbox'\n | 'tree'\n | 'grid'\n | 'dialog';\n};\n"]}
|
|
@@ -44,7 +44,7 @@ exports.ButtonIcon = (0, react_1.forwardRef)(({ className, iconName, iconProps,
|
|
|
44
44
|
],
|
|
45
45
|
// Non-floating styles
|
|
46
46
|
!isFloating && [
|
|
47
|
-
'bg-transparent
|
|
47
|
+
'rounded bg-transparent',
|
|
48
48
|
// Only apply hover/active styles when interactive
|
|
49
49
|
isInteractive && 'hover:bg-hover active:bg-pressed',
|
|
50
50
|
!isInverse && 'text-icon-default',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.cjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAE1C,iDAA6C;AAC7C,uDAA+C;AAC/C,4CAA+B;AAE/B,qEAGgC;AAGnB,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,sBAAc,CAAC,EAAE,EACxB,KAAK,EACL,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,aAAa,GAAG,CAAC,UAAU,CAAC;IAElC,MAAM,eAAe,GAAG,IAAA,kBAAO;IAC7B,cAAc;IACd,6CAA6C;IAC7C,cAAc;IACd,2DAAoC,CAAC,IAAI,CAAC;IAC1C,kBAAkB;IAClB,UAAU,IAAI;QACZ,cAAc;QACd,CAAC,SAAS,IAAI,yCAAyC;QACvD,SAAS,IAAI,yCAAyC;KACvD;IACD,sBAAsB;IACtB,CAAC,UAAU,IAAI;QACb,wBAAwB;QACxB,kDAAkD;QAClD,aAAa,IAAI,kCAAkC;QACnD,CAAC,SAAS,IAAI,mBAAmB;QACjC,SAAS,IAAI,yBAAyB;KACvC;IACD,iBAAiB;IACjB,UAAU,IAAI,+BAA+B,EAC7C,SAAS,CACV,CAAC;IAEF,OAAO,CACL,0CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,UAAU,gBACR,SAAS,EACrB,KAAK,EAAE,KAAK,KACR,KAAK;QAET,8BAAC,WAAI,IACH,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,mDAA4B,CAAC,IAAI,CAAC,EACxC,SAAS,EAAE,IAAA,kBAAO,EAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,KACpD,SAAS,GACb,CACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { ButtonIconSize } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\n\nimport {\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n MAP_BUTTONICON_SIZE_ICONSIZE,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(\n (\n {\n className,\n iconName,\n iconProps,\n ariaLabel,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n size = ButtonIconSize.Md,\n style,\n ...props\n },\n ref,\n ) => {\n const isInteractive = !isDisabled;\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center p-0',\n // Size styles\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n // Floating styles\n isFloating && [\n 'rounded-full',\n !isInverse && 'bg-icon-default text-background-default',\n isInverse && 'bg-icon-default text-background-default',\n ],\n // Non-floating styles\n !isFloating && [\n 'bg-transparent
|
|
1
|
+
{"version":3,"file":"ButtonIcon.cjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAE1C,iDAA6C;AAC7C,uDAA+C;AAC/C,4CAA+B;AAE/B,qEAGgC;AAGnB,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,sBAAc,CAAC,EAAE,EACxB,KAAK,EACL,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,aAAa,GAAG,CAAC,UAAU,CAAC;IAElC,MAAM,eAAe,GAAG,IAAA,kBAAO;IAC7B,cAAc;IACd,6CAA6C;IAC7C,cAAc;IACd,2DAAoC,CAAC,IAAI,CAAC;IAC1C,kBAAkB;IAClB,UAAU,IAAI;QACZ,cAAc;QACd,CAAC,SAAS,IAAI,yCAAyC;QACvD,SAAS,IAAI,yCAAyC;KACvD;IACD,sBAAsB;IACtB,CAAC,UAAU,IAAI;QACb,wBAAwB;QACxB,kDAAkD;QAClD,aAAa,IAAI,kCAAkC;QACnD,CAAC,SAAS,IAAI,mBAAmB;QACjC,SAAS,IAAI,yBAAyB;KACvC;IACD,iBAAiB;IACjB,UAAU,IAAI,+BAA+B,EAC7C,SAAS,CACV,CAAC;IAEF,OAAO,CACL,0CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,UAAU,gBACR,SAAS,EACrB,KAAK,EAAE,KAAK,KACR,KAAK;QAET,8BAAC,WAAI,IACH,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,mDAA4B,CAAC,IAAI,CAAC,EACxC,SAAS,EAAE,IAAA,kBAAO,EAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,KACpD,SAAS,GACb,CACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { ButtonIconSize } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\n\nimport {\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n MAP_BUTTONICON_SIZE_ICONSIZE,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(\n (\n {\n className,\n iconName,\n iconProps,\n ariaLabel,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n size = ButtonIconSize.Md,\n style,\n ...props\n },\n ref,\n ) => {\n const isInteractive = !isDisabled;\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center p-0',\n // Size styles\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n // Floating styles\n isFloating && [\n 'rounded-full',\n !isInverse && 'bg-icon-default text-background-default',\n isInverse && 'bg-icon-default text-background-default',\n ],\n // Non-floating styles\n !isFloating && [\n 'rounded bg-transparent',\n // Only apply hover/active styles when interactive\n isInteractive && 'hover:bg-hover active:bg-pressed',\n !isInverse && 'text-icon-default',\n isInverse && 'text-background-default',\n ],\n // Disabled state\n isDisabled && 'cursor-not-allowed opacity-50',\n className,\n );\n\n return (\n <button\n ref={ref}\n className={mergedClassName}\n disabled={isDisabled}\n aria-label={ariaLabel}\n style={style}\n {...props}\n >\n <Icon\n name={iconName}\n size={MAP_BUTTONICON_SIZE_ICONSIZE[size]}\n className={twMerge('text-inherit', iconProps?.className)}\n {...iconProps}\n />\n </button>\n );\n },\n);\n\nButtonIcon.displayName = 'ButtonIcon';\n"]}
|
|
@@ -25,7 +25,7 @@ export const ButtonIcon = forwardRef(({ className, iconName, iconProps, ariaLabe
|
|
|
25
25
|
],
|
|
26
26
|
// Non-floating styles
|
|
27
27
|
!isFloating && [
|
|
28
|
-
'bg-transparent
|
|
28
|
+
'rounded bg-transparent',
|
|
29
29
|
// Only apply hover/active styles when interactive
|
|
30
30
|
isInteractive && 'hover:bg-hover active:bg-pressed',
|
|
31
31
|
!isInverse && 'text-icon-default',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.mjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAC7C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAE/B,OAAO,EACL,oCAAoC,EACpC,4BAA4B,EAC7B,mCAA+B;AAGhC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,KAAK,EACL,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,aAAa,GAAG,CAAC,UAAU,CAAC;IAElC,MAAM,eAAe,GAAG,OAAO;IAC7B,cAAc;IACd,6CAA6C;IAC7C,cAAc;IACd,oCAAoC,CAAC,IAAI,CAAC;IAC1C,kBAAkB;IAClB,UAAU,IAAI;QACZ,cAAc;QACd,CAAC,SAAS,IAAI,yCAAyC;QACvD,SAAS,IAAI,yCAAyC;KACvD;IACD,sBAAsB;IACtB,CAAC,UAAU,IAAI;QACb,wBAAwB;QACxB,kDAAkD;QAClD,aAAa,IAAI,kCAAkC;QACnD,CAAC,SAAS,IAAI,mBAAmB;QACjC,SAAS,IAAI,yBAAyB;KACvC;IACD,iBAAiB;IACjB,UAAU,IAAI,+BAA+B,EAC7C,SAAS,CACV,CAAC;IAEF,OAAO,CACL,gCACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,UAAU,gBACR,SAAS,EACrB,KAAK,EAAE,KAAK,KACR,KAAK;QAET,oBAAC,IAAI,IACH,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,4BAA4B,CAAC,IAAI,CAAC,EACxC,SAAS,EAAE,OAAO,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,KACpD,SAAS,GACb,CACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { ButtonIconSize } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\n\nimport {\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n MAP_BUTTONICON_SIZE_ICONSIZE,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(\n (\n {\n className,\n iconName,\n iconProps,\n ariaLabel,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n size = ButtonIconSize.Md,\n style,\n ...props\n },\n ref,\n ) => {\n const isInteractive = !isDisabled;\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center p-0',\n // Size styles\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n // Floating styles\n isFloating && [\n 'rounded-full',\n !isInverse && 'bg-icon-default text-background-default',\n isInverse && 'bg-icon-default text-background-default',\n ],\n // Non-floating styles\n !isFloating && [\n 'bg-transparent
|
|
1
|
+
{"version":3,"file":"ButtonIcon.mjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,O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,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { ButtonIconSize } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\n\nimport {\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n MAP_BUTTONICON_SIZE_ICONSIZE,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = forwardRef<HTMLButtonElement, ButtonIconProps>(\n (\n {\n className,\n iconName,\n iconProps,\n ariaLabel,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n size = ButtonIconSize.Md,\n style,\n ...props\n },\n ref,\n ) => {\n const isInteractive = !isDisabled;\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center p-0',\n // Size styles\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n // Floating styles\n isFloating && [\n 'rounded-full',\n !isInverse && 'bg-icon-default text-background-default',\n isInverse && 'bg-icon-default text-background-default',\n ],\n // Non-floating styles\n !isFloating && [\n 'rounded bg-transparent',\n // Only apply hover/active styles when interactive\n isInteractive && 'hover:bg-hover active:bg-pressed',\n !isInverse && 'text-icon-default',\n isInverse && 'text-background-default',\n ],\n // Disabled state\n isDisabled && 'cursor-not-allowed opacity-50',\n className,\n );\n\n return (\n <button\n ref={ref}\n className={mergedClassName}\n disabled={isDisabled}\n aria-label={ariaLabel}\n style={style}\n {...props}\n >\n <Icon\n name={iconName}\n size={MAP_BUTTONICON_SIZE_ICONSIZE[size]}\n className={twMerge('text-inherit', iconProps?.className)}\n {...iconProps}\n />\n </button>\n );\n },\n);\n\nButtonIcon.displayName = 'ButtonIcon';\n"]}
|
|
@@ -59,11 +59,11 @@ exports.Checkbox = (0, react_1.forwardRef)(({ id, isSelected, isDisabled = false
|
|
|
59
59
|
else if (isInvalid) {
|
|
60
60
|
baseBorder = 'border-error-default';
|
|
61
61
|
}
|
|
62
|
-
const checkboxClasses = (0, tw_merge_1.twMerge)('relative flex
|
|
62
|
+
const checkboxClasses = (0, tw_merge_1.twMerge)('relative flex size-6 items-center justify-center rounded border-2 p-0 transition-transform active:scale-95', baseBg, baseBorder, checkboxContainerProps?.className);
|
|
63
63
|
const iconClasses = (0, tw_merge_1.twMerge)('pointer-events-none transition-opacity', isSelected ? 'opacity-100' : 'opacity-0', checkedIconProps?.className);
|
|
64
64
|
return (react_1.default.createElement("label", { htmlFor: id, className: outerClassName, style: style, ...props },
|
|
65
65
|
react_1.default.createElement("div", { className: "relative" },
|
|
66
|
-
react_1.default.createElement("input", { type: "checkbox", id: id, checked: isSelected, disabled: isDisabled, "aria-invalid": isInvalid, onChange: handleChange, onKeyDown: handleKeyDown, className: "absolute inset-0
|
|
66
|
+
react_1.default.createElement("input", { type: "checkbox", id: id, checked: isSelected, disabled: isDisabled, "aria-invalid": isInvalid, onChange: handleChange, onKeyDown: handleKeyDown, className: "absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed", ...inputProps }),
|
|
67
67
|
react_1.default.createElement("div", { className: checkboxClasses, ...checkboxContainerProps },
|
|
68
68
|
react_1.default.createElement(Icon_1.Icon, { name: Icon_1.IconName.Check, color: Icon_1.IconColor.PrimaryInverse, size: Icon_1.IconSize.Sm, ...checkedIconProps, className: iconClasses }))),
|
|
69
69
|
label ? (react_1.default.createElement(Text_1.Text, { asChild: true, ...labelProps, className: (0, tw_merge_1.twMerge)('ml-3', labelProps?.className) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.cjs","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA+D;AAE/D,uDAA+C;AAC/C,4CAA8D;AAC9D,4CAA+B;AAIlB,QAAA,QAAQ,GAAG,IAAA,kBAAU,EAChC,CACE,EACE,EAAE,EACF,UAAU,EACV,UAAU,GAAG,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C,CACF,CAAC;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import type { ChangeEvent, KeyboardEvent } from 'react';\nimport React, { forwardRef, useImperativeHandle } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, IconName, IconColor, IconSize } from '../Icon';\nimport { Text } from '../Text';\n\nimport type { CheckboxProps } from './Checkbox.types';\n\nexport const Checkbox = forwardRef<{ toggle: () => void }, CheckboxProps>(\n (\n {\n id,\n isSelected,\n isDisabled = false,\n isInvalid = false,\n label,\n labelProps,\n onChange,\n inputProps,\n checkboxContainerProps,\n checkedIconProps,\n className,\n style,\n ...props\n },\n ref,\n ) => {\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (isDisabled) {\n return;\n }\n onChange?.(event.target.checked);\n };\n\n const handleClick = () => {\n if (isDisabled) {\n return;\n }\n onChange?.(!isSelected);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n handleClick();\n }\n };\n\n useImperativeHandle(ref, () => ({ toggle: handleClick }), [handleClick]);\n\n const outerClassName = twMerge(\n 'inline-flex items-center',\n isDisabled && 'cursor-not-allowed opacity-50',\n className,\n );\n\n const baseBg = isSelected\n ? 'bg-primary-default hover:bg-primary-default-hover active:bg-primary-default-pressed'\n : 'bg-default hover:bg-default-hover active:bg-default-pressed';\n let baseBorder = 'border-default';\n if (isSelected) {\n baseBorder = 'border-primary-default';\n } else if (isInvalid) {\n baseBorder = 'border-error-default';\n }\n\n const checkboxClasses = twMerge(\n 'relative flex size-6 items-center justify-center rounded border-2 p-0 transition-transform active:scale-95',\n baseBg,\n baseBorder,\n checkboxContainerProps?.className,\n );\n\n const iconClasses = twMerge(\n 'pointer-events-none transition-opacity',\n isSelected ? 'opacity-100' : 'opacity-0',\n checkedIconProps?.className,\n );\n\n return (\n <label htmlFor={id} className={outerClassName} style={style} {...props}>\n <div className=\"relative\">\n <input\n type=\"checkbox\"\n id={id}\n checked={isSelected}\n disabled={isDisabled}\n aria-invalid={isInvalid}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed\"\n {...inputProps}\n />\n <div className={checkboxClasses} {...checkboxContainerProps}>\n <Icon\n name={IconName.Check}\n color={IconColor.PrimaryInverse}\n size={IconSize.Sm}\n {...checkedIconProps}\n className={iconClasses}\n />\n </div>\n </div>\n {label ? (\n <Text\n asChild\n {...labelProps}\n className={twMerge('ml-3', labelProps?.className)}\n >\n <span>{label}</span>\n </Text>\n ) : null}\n </label>\n );\n },\n);\n\nCheckbox.displayName = 'Checkbox';\n"]}
|
|
@@ -40,11 +40,11 @@ export const Checkbox = forwardRef(({ id, isSelected, isDisabled = false, isInva
|
|
|
40
40
|
else if (isInvalid) {
|
|
41
41
|
baseBorder = 'border-error-default';
|
|
42
42
|
}
|
|
43
|
-
const checkboxClasses = twMerge('relative flex
|
|
43
|
+
const checkboxClasses = twMerge('relative flex size-6 items-center justify-center rounded border-2 p-0 transition-transform active:scale-95', baseBg, baseBorder, checkboxContainerProps?.className);
|
|
44
44
|
const iconClasses = twMerge('pointer-events-none transition-opacity', isSelected ? 'opacity-100' : 'opacity-0', checkedIconProps?.className);
|
|
45
45
|
return (React.createElement("label", { htmlFor: id, className: outerClassName, style: style, ...props },
|
|
46
46
|
React.createElement("div", { className: "relative" },
|
|
47
|
-
React.createElement("input", { type: "checkbox", id: id, checked: isSelected, disabled: isDisabled, "aria-invalid": isInvalid, onChange: handleChange, onKeyDown: handleKeyDown, className: "absolute inset-0
|
|
47
|
+
React.createElement("input", { type: "checkbox", id: id, checked: isSelected, disabled: isDisabled, "aria-invalid": isInvalid, onChange: handleChange, onKeyDown: handleKeyDown, className: "absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed", ...inputProps }),
|
|
48
48
|
React.createElement("div", { className: checkboxClasses, ...checkboxContainerProps },
|
|
49
49
|
React.createElement(Icon, { name: IconName.Check, color: IconColor.PrimaryInverse, size: IconSize.Sm, ...checkedIconProps, className: iconClasses }))),
|
|
50
50
|
label ? (React.createElement(Text, { asChild: true, ...labelProps, className: twMerge('ml-3', labelProps?.className) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.mjs","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";;;;;;AACA,OAAO,QAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,cAAc;;AAE/D,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,0BAAgB;AAC9D,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,EAAE,EACF,UAAU,EACV,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,KAAK,EACL,UAAU,EACV,QAAQ,EACR,UAAU,EACV,sBAAsB,EACtB,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,EAAE;QAC5D,IAAI,UAAU,EAAE;YACd,OAAO;SACR;QACD,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,UAAU,EAAE;YACd,OAAO;SACR;QACD,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAsC,EAAE,EAAE;QAC/D,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;YACzB,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,WAAW,EAAE,CAAC;SACf;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UAAU;YACvB,+BACE,IAAI,EAAC,UAAU,EACf,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,UAAU,kBACN,SAAS,EACvB,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAC,iFAAiF,KACvF,UAAU,GACd;YACF,6BAAK,SAAS,EAAE,eAAe,KAAM,sBAAsB;gBACzD,oBAAC,IAAI,IACH,IAAI,EAAE,QAAQ,CAAC,KAAK,EACpB,KAAK,EAAE,SAAS,CAAC,cAAc,EAC/B,IAAI,EAAE,QAAQ,CAAC,EAAE,KACb,gBAAgB,EACpB,SAAS,EAAE,WAAW,GACtB,CACE,CACF;QACL,KAAK,CAAC,CAAC,CAAC,CACP,oBAAC,IAAI,IACH,OAAO,WACH,UAAU,EACd,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC;YAEjD,kCAAO,KAAK,CAAQ,CACf,CACR,CAAC,CAAC,CAAC,IAAI,CACF,CACT,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import type { ChangeEvent, KeyboardEvent } from 'react';\nimport React, { forwardRef, useImperativeHandle } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, IconName, IconColor, IconSize } from '../Icon';\nimport { Text } from '../Text';\n\nimport type { CheckboxProps } from './Checkbox.types';\n\nexport const Checkbox = forwardRef<{ toggle: () => void }, CheckboxProps>(\n (\n {\n id,\n isSelected,\n isDisabled = false,\n isInvalid = false,\n label,\n labelProps,\n onChange,\n inputProps,\n checkboxContainerProps,\n checkedIconProps,\n className,\n style,\n ...props\n },\n ref,\n ) => {\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (isDisabled) {\n return;\n }\n onChange?.(event.target.checked);\n };\n\n const handleClick = () => {\n if (isDisabled) {\n return;\n }\n onChange?.(!isSelected);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n handleClick();\n }\n };\n\n useImperativeHandle(ref, () => ({ toggle: handleClick }), [handleClick]);\n\n const outerClassName = twMerge(\n 'inline-flex items-center',\n isDisabled && 'cursor-not-allowed opacity-50',\n className,\n );\n\n const baseBg = isSelected\n ? 'bg-primary-default hover:bg-primary-default-hover active:bg-primary-default-pressed'\n : 'bg-default hover:bg-default-hover active:bg-default-pressed';\n let baseBorder = 'border-default';\n if (isSelected) {\n baseBorder = 'border-primary-default';\n } else if (isInvalid) {\n baseBorder = 'border-error-default';\n }\n\n const checkboxClasses = twMerge(\n 'relative flex size-6 items-center justify-center rounded border-2 p-0 transition-transform active:scale-95',\n baseBg,\n baseBorder,\n checkboxContainerProps?.className,\n );\n\n const iconClasses = twMerge(\n 'pointer-events-none transition-opacity',\n isSelected ? 'opacity-100' : 'opacity-0',\n checkedIconProps?.className,\n );\n\n return (\n <label htmlFor={id} className={outerClassName} style={style} {...props}>\n <div className=\"relative\">\n <input\n type=\"checkbox\"\n id={id}\n checked={isSelected}\n disabled={isDisabled}\n aria-invalid={isInvalid}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n className=\"absolute inset-0 size-full cursor-pointer opacity-0 disabled:cursor-not-allowed\"\n {...inputProps}\n />\n <div className={checkboxClasses} {...checkboxContainerProps}>\n <Icon\n name={IconName.Check}\n color={IconColor.PrimaryInverse}\n size={IconSize.Sm}\n {...checkedIconProps}\n className={iconClasses}\n />\n </div>\n </div>\n {label ? (\n <Text\n asChild\n {...labelProps}\n className={twMerge('ml-3', labelProps?.className)}\n >\n <span>{label}</span>\n </Text>\n ) : null}\n </label>\n );\n },\n);\n\nCheckbox.displayName = 'Checkbox';\n"]}
|
|
@@ -19,7 +19,7 @@ const Icon = ({ name, size = types_1.IconSize.Md, color = types_1.IconColor.Icon
|
|
|
19
19
|
console.warn(`Icon "${name}" not found`);
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
const mergedClassName = (0, tw_merge_1.twMerge)('inline-block', Icon_constants_1.
|
|
22
|
+
const mergedClassName = (0, tw_merge_1.twMerge)('inline-block', Icon_constants_1.TWCLASSMAP_ICON_SIZE_DIMENSION[size], color, className);
|
|
23
23
|
return (react_1.default.createElement(IconComponent, { className: mergedClassName, ...props, style: style }));
|
|
24
24
|
};
|
|
25
25
|
exports.Icon = Icon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.cjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAAkD;AAClD,uDAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"Icon.cjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAAkD;AAClD,uDAA+C;AAE/C,yDAAkE;AAElE,6CAAgC;AAEzB,MAAM,IAAI,GAAwB,CAAC,EACxC,IAAI,EACJ,IAAI,GAAG,gBAAQ,CAAC,EAAE,EAClB,KAAK,GAAG,iBAAS,CAAC,WAAW,EAC7B,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,EAAE;IACH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,aAAa,GAAG,aAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,aAAa,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,eAAe,GAAG,IAAA,kBAAO,EAC7B,cAAc,EACd,+CAA8B,CAAC,IAAI,CAAC,EACpC,KAAK,EACL,SAAS,CACV,CAAC;IAEF,OAAO,CACL,8BAAC,aAAa,IACZ,SAAS,EAAE,eAAe,KACrB,KAAuC,EAC5C,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,IAAI,QAkCf","sourcesContent":["import React from 'react';\n\nimport { IconSize, IconColor } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\n\nimport { TWCLASSMAP_ICON_SIZE_DIMENSION } from './Icon.constants';\nimport type { IconProps } from './Icon.types';\nimport { Icons } from './icons';\n\nexport const Icon: React.FC<IconProps> = ({\n name,\n size = IconSize.Md,\n color = IconColor.IconDefault,\n className,\n style,\n ...props\n}) => {\n if (!name) {\n console.warn('Icon name is required');\n return null;\n }\n\n const IconComponent = Icons[name];\n\n if (!IconComponent) {\n console.warn(`Icon \"${name}\" not found`);\n return null;\n }\n\n const mergedClassName = twMerge(\n 'inline-block',\n TWCLASSMAP_ICON_SIZE_DIMENSION[size],\n color,\n className,\n );\n\n return (\n <IconComponent\n className={mergedClassName}\n {...(props as React.SVGProps<SVGSVGElement>)}\n style={style}\n />\n );\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TWCLASSMAP_ICON_SIZE_DIMENSION = void 0;
|
|
4
4
|
const types_1 = require("../../types/index.cjs");
|
|
5
|
-
exports.
|
|
5
|
+
exports.TWCLASSMAP_ICON_SIZE_DIMENSION = {
|
|
6
6
|
[types_1.IconSize.Xs]: 'w-3 h-3',
|
|
7
7
|
[types_1.IconSize.Sm]: 'w-4 h-4',
|
|
8
8
|
[types_1.IconSize.Md]: 'w-5 h-5',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.constants.cjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AAE1B,QAAA,
|
|
1
|
+
{"version":3,"file":"Icon.constants.cjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AAE1B,QAAA,8BAA8B,GAA6B;IACtE,CAAC,gBAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,gBAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,gBAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,gBAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,gBAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO;CAClC,CAAC","sourcesContent":["import { IconSize } from '../../types';\n\nexport const TWCLASSMAP_ICON_SIZE_DIMENSION: Record<IconSize, string> = {\n [IconSize.Xs]: 'w-3 h-3', // 12px\n [IconSize.Sm]: 'w-4 h-4', // 16px\n [IconSize.Md]: 'w-5 h-5', // 20px\n [IconSize.Lg]: 'w-6 h-6', // 24px\n [IconSize.Xl]: 'w-8 h-8', // 32px\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Icon.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Icon.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.constants.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Icon.constants.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,8BAAoB;AAEvC,MAAM,CAAC,MAAM,8BAA8B,GAA6B;IACtE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS;IACxB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO;CAClC,CAAC","sourcesContent":["import { IconSize } from '../../types';\n\nexport const TWCLASSMAP_ICON_SIZE_DIMENSION: Record<IconSize, string> = {\n [IconSize.Xs]: 'w-3 h-3', // 12px\n [IconSize.Sm]: 'w-4 h-4', // 16px\n [IconSize.Md]: 'w-5 h-5', // 20px\n [IconSize.Lg]: 'w-6 h-6', // 24px\n [IconSize.Xl]: 'w-8 h-8', // 32px\n};\n"]}
|
|
@@ -8,7 +8,7 @@ import $React from "react";
|
|
|
8
8
|
const React = $importDefault($React);
|
|
9
9
|
import { IconSize, IconColor } from "../../types/index.mjs";
|
|
10
10
|
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { TWCLASSMAP_ICON_SIZE_DIMENSION } from "./Icon.constants.mjs";
|
|
12
12
|
import { Icons } from "./icons/index.mjs";
|
|
13
13
|
export const Icon = ({ name, size = IconSize.Md, color = IconColor.IconDefault, className, style, ...props }) => {
|
|
14
14
|
if (!name) {
|
|
@@ -20,7 +20,7 @@ export const Icon = ({ name, size = IconSize.Md, color = IconColor.IconDefault,
|
|
|
20
20
|
console.warn(`Icon "${name}" not found`);
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
-
const mergedClassName = twMerge('inline-block',
|
|
23
|
+
const mergedClassName = twMerge('inline-block', TWCLASSMAP_ICON_SIZE_DIMENSION[size], color, className);
|
|
24
24
|
return (React.createElement(IconComponent, { className: mergedClassName, ...props, style: style }));
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=Icon.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,8BAAoB;AAClD,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAE/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Icon.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,8BAAoB;AAClD,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAE/C,OAAO,EAAE,8BAA8B,EAAE,6BAAyB;AAElE,OAAO,EAAE,KAAK,EAAE,0BAAgB;AAEhC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,EACxC,IAAI,EACJ,IAAI,GAAG,QAAQ,CAAC,EAAE,EAClB,KAAK,GAAG,SAAS,CAAC,WAAW,EAC7B,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,EAAE;IACH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,aAAa,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,eAAe,GAAG,OAAO,CAC7B,cAAc,EACd,8BAA8B,CAAC,IAAI,CAAC,EACpC,KAAK,EACL,SAAS,CACV,CAAC;IAEF,OAAO,CACL,oBAAC,aAAa,IACZ,SAAS,EAAE,eAAe,KACrB,KAAuC,EAC5C,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { IconSize, IconColor } from '../../types';\nimport { twMerge } from '../../utils/tw-merge';\n\nimport { TWCLASSMAP_ICON_SIZE_DIMENSION } from './Icon.constants';\nimport type { IconProps } from './Icon.types';\nimport { Icons } from './icons';\n\nexport const Icon: React.FC<IconProps> = ({\n name,\n size = IconSize.Md,\n color = IconColor.IconDefault,\n className,\n style,\n ...props\n}) => {\n if (!name) {\n console.warn('Icon name is required');\n return null;\n }\n\n const IconComponent = Icons[name];\n\n if (!IconComponent) {\n console.warn(`Icon \"${name}\" not found`);\n return null;\n }\n\n const mergedClassName = twMerge(\n 'inline-block',\n TWCLASSMAP_ICON_SIZE_DIMENSION[size],\n color,\n className,\n );\n\n return (\n <IconComponent\n className={mergedClassName}\n {...(props as React.SVGProps<SVGSVGElement>)}\n style={style}\n />\n );\n};\n"]}
|