@metamask/design-system-react 0.22.0 → 0.23.1
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 +25 -1
- package/dist/components/BannerAlert/BannerAlert.d.cts +2 -4
- package/dist/components/BannerAlert/BannerAlert.d.cts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.d.mts +2 -4
- package/dist/components/BannerAlert/BannerAlert.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.cjs +3 -3
- package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.cts +2 -4
- package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.mts +2 -4
- package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.mjs +3 -3
- package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.d.cts +1 -5
- package/dist/components/BannerBase/BannerBase.types.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.d.mts +1 -5
- package/dist/components/BannerBase/BannerBase.types.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.cjs +26 -18
- package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.cjs +31 -1
- package/dist/components/ButtonBase/ButtonBase.constants.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts +6 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts +6 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.mjs +29 -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 +28 -20
- package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
- package/dist/components/HelpText/HelpText.cjs +13 -0
- package/dist/components/HelpText/HelpText.cjs.map +1 -0
- package/dist/components/HelpText/HelpText.constants.cjs +11 -0
- package/dist/components/HelpText/HelpText.constants.cjs.map +1 -0
- package/dist/components/HelpText/HelpText.constants.d.cts +3 -0
- package/dist/components/HelpText/HelpText.constants.d.cts.map +1 -0
- package/dist/components/HelpText/HelpText.constants.d.mts +3 -0
- package/dist/components/HelpText/HelpText.constants.d.mts.map +1 -0
- package/dist/components/HelpText/HelpText.constants.mjs +8 -0
- package/dist/components/HelpText/HelpText.constants.mjs.map +1 -0
- package/dist/components/HelpText/HelpText.d.cts +4 -0
- package/dist/components/HelpText/HelpText.d.cts.map +1 -0
- package/dist/components/HelpText/HelpText.d.mts +4 -0
- package/dist/components/HelpText/HelpText.d.mts.map +1 -0
- package/dist/components/HelpText/HelpText.mjs +13 -0
- package/dist/components/HelpText/HelpText.mjs.map +1 -0
- package/dist/components/HelpText/HelpText.types.cjs +3 -0
- package/dist/components/HelpText/HelpText.types.cjs.map +1 -0
- package/dist/components/HelpText/HelpText.types.d.cts +9 -0
- package/dist/components/HelpText/HelpText.types.d.cts.map +1 -0
- package/dist/components/HelpText/HelpText.types.d.mts +9 -0
- package/dist/components/HelpText/HelpText.types.d.mts.map +1 -0
- package/dist/components/HelpText/HelpText.types.mjs +2 -0
- package/dist/components/HelpText/HelpText.types.mjs.map +1 -0
- package/dist/components/HelpText/index.cjs +8 -0
- package/dist/components/HelpText/index.cjs.map +1 -0
- package/dist/components/HelpText/index.d.cts +4 -0
- package/dist/components/HelpText/index.d.cts.map +1 -0
- package/dist/components/HelpText/index.d.mts +4 -0
- package/dist/components/HelpText/index.d.mts.map +1 -0
- package/dist/components/HelpText/index.mjs +3 -0
- package/dist/components/HelpText/index.mjs.map +1 -0
- package/dist/components/Icon/icons/Telegram.cjs +1 -1
- package/dist/components/Icon/icons/Telegram.cjs.map +1 -1
- package/dist/components/Icon/icons/Telegram.mjs +1 -1
- package/dist/components/Icon/icons/Telegram.mjs.map +1 -1
- package/dist/components/Label/Label.cjs +38 -0
- package/dist/components/Label/Label.cjs.map +1 -0
- package/dist/components/Label/Label.d.cts +4 -0
- package/dist/components/Label/Label.d.cts.map +1 -0
- package/dist/components/Label/Label.d.mts +4 -0
- package/dist/components/Label/Label.d.mts.map +1 -0
- package/dist/components/Label/Label.mjs +19 -0
- package/dist/components/Label/Label.mjs.map +1 -0
- package/dist/components/Label/Label.types.cjs +3 -0
- package/dist/components/Label/Label.types.cjs.map +1 -0
- package/dist/components/Label/Label.types.d.cts +27 -0
- package/dist/components/Label/Label.types.d.cts.map +1 -0
- package/dist/components/Label/Label.types.d.mts +27 -0
- package/dist/components/Label/Label.types.d.mts.map +1 -0
- package/dist/components/Label/Label.types.mjs +2 -0
- package/dist/components/Label/Label.types.mjs.map +1 -0
- package/dist/components/Label/index.cjs +6 -0
- package/dist/components/Label/index.cjs.map +1 -0
- package/dist/components/Label/index.d.cts +3 -0
- package/dist/components/Label/index.d.cts.map +1 -0
- package/dist/components/Label/index.d.mts +3 -0
- package/dist/components/Label/index.d.mts.map +1 -0
- package/dist/components/Label/index.mjs +2 -0
- package/dist/components/Label/index.mjs.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.cjs +55 -0
- package/dist/components/ModalHeader/ModalHeader.cjs.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.d.cts +55 -0
- package/dist/components/ModalHeader/ModalHeader.d.cts.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.d.mts +55 -0
- package/dist/components/ModalHeader/ModalHeader.d.mts.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.mjs +36 -0
- package/dist/components/ModalHeader/ModalHeader.mjs.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.types.cjs +3 -0
- package/dist/components/ModalHeader/ModalHeader.types.cjs.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.types.d.cts +69 -0
- package/dist/components/ModalHeader/ModalHeader.types.d.cts.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.types.d.mts +69 -0
- package/dist/components/ModalHeader/ModalHeader.types.d.mts.map +1 -0
- package/dist/components/ModalHeader/ModalHeader.types.mjs +2 -0
- package/dist/components/ModalHeader/ModalHeader.types.mjs.map +1 -0
- package/dist/components/ModalHeader/index.cjs +6 -0
- package/dist/components/ModalHeader/index.cjs.map +1 -0
- package/dist/components/ModalHeader/index.d.cts +3 -0
- package/dist/components/ModalHeader/index.d.cts.map +1 -0
- package/dist/components/ModalHeader/index.d.mts +3 -0
- package/dist/components/ModalHeader/index.d.mts.map +1 -0
- package/dist/components/ModalHeader/index.mjs +2 -0
- package/dist/components/ModalHeader/index.mjs.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.cjs +60 -0
- package/dist/components/PopoverHeader/PopoverHeader.cjs.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.d.cts +55 -0
- package/dist/components/PopoverHeader/PopoverHeader.d.cts.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.d.mts +55 -0
- package/dist/components/PopoverHeader/PopoverHeader.d.mts.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.mjs +41 -0
- package/dist/components/PopoverHeader/PopoverHeader.mjs.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.cjs +3 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.cjs.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.d.cts +70 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.d.cts.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.d.mts +70 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.d.mts.map +1 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.mjs +2 -0
- package/dist/components/PopoverHeader/PopoverHeader.types.mjs.map +1 -0
- package/dist/components/PopoverHeader/index.cjs +6 -0
- package/dist/components/PopoverHeader/index.cjs.map +1 -0
- package/dist/components/PopoverHeader/index.d.cts +3 -0
- package/dist/components/PopoverHeader/index.d.cts.map +1 -0
- package/dist/components/PopoverHeader/index.d.mts +3 -0
- package/dist/components/PopoverHeader/index.d.mts.map +1 -0
- package/dist/components/PopoverHeader/index.mjs +2 -0
- package/dist/components/PopoverHeader/index.mjs.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.cjs +47 -0
- package/dist/components/SensitiveText/SensitiveText.cjs.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.d.cts +4 -0
- package/dist/components/SensitiveText/SensitiveText.d.cts.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.d.mts +4 -0
- package/dist/components/SensitiveText/SensitiveText.d.mts.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.mjs +27 -0
- package/dist/components/SensitiveText/SensitiveText.mjs.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.types.cjs +3 -0
- package/dist/components/SensitiveText/SensitiveText.types.cjs.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.types.d.cts +11 -0
- package/dist/components/SensitiveText/SensitiveText.types.d.cts.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.types.d.mts +11 -0
- package/dist/components/SensitiveText/SensitiveText.types.d.mts.map +1 -0
- package/dist/components/SensitiveText/SensitiveText.types.mjs +2 -0
- package/dist/components/SensitiveText/SensitiveText.types.mjs.map +1 -0
- package/dist/components/SensitiveText/index.cjs +8 -0
- package/dist/components/SensitiveText/index.cjs.map +1 -0
- package/dist/components/SensitiveText/index.d.cts +4 -0
- package/dist/components/SensitiveText/index.d.cts.map +1 -0
- package/dist/components/SensitiveText/index.d.mts +4 -0
- package/dist/components/SensitiveText/index.d.mts.map +1 -0
- package/dist/components/SensitiveText/index.mjs +3 -0
- package/dist/components/SensitiveText/index.mjs.map +1 -0
- package/dist/components/index.cjs +14 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +10 -0
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +10 -0
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +5 -0
- package/dist/components/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.23.1]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Updated the `Telegram` icon asset to match the official Telegram logo ([#1176](https://github.com/MetaMask/metamask-design-system/pull/1176))
|
|
15
|
+
|
|
16
|
+
## [0.23.0]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Added `PopoverHeader` for popover title rows and trailing actions, aligned with MetaMask extension screen patterns ([#1158](https://github.com/MetaMask/metamask-design-system/pull/1158))
|
|
21
|
+
- Added `ModalHeader` for modal title rows and accessory slots, aligned with MetaMask extension screen patterns ([#1144](https://github.com/MetaMask/metamask-design-system/pull/1144))
|
|
22
|
+
- Added `Label` for accessible captions paired with form controls ([#1152](https://github.com/MetaMask/metamask-design-system/pull/1152))
|
|
23
|
+
- Added `SensitiveText` for masking and revealing sensitive strings (addresses, secrets, recovery phrases) with configurable visible length ([#1164](https://github.com/MetaMask/metamask-design-system/pull/1164))
|
|
24
|
+
- Added `HelpText` for helper, success, warning, and error copy beneath inputs and other controls ([#1169](https://github.com/MetaMask/metamask-design-system/pull/1169))
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- `ButtonBase` now derives label typography, start and end icon sizes, and internal spacing from the `size` prop for every supported `ButtonBaseSize`, keeping defaults aligned without manual per-size tuning ([#1150](https://github.com/MetaMask/metamask-design-system/pull/1150))
|
|
29
|
+
- If you wrap **`ButtonBase`** and override label, icon, or spacing, see [Migration guide](./MIGRATION.md#buttonbase-size-defaults).
|
|
30
|
+
- `BannerBase` close control behavior is simplified and aligned with the shared dismiss contract ([#1166](https://github.com/MetaMask/metamask-design-system/pull/1166))
|
|
31
|
+
|
|
10
32
|
## [0.22.0]
|
|
11
33
|
|
|
12
34
|
### Added
|
|
@@ -304,7 +326,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
304
326
|
- Full TypeScript support with type definitions and enums
|
|
305
327
|
- Tailwind CSS integration with design token support
|
|
306
328
|
|
|
307
|
-
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.
|
|
329
|
+
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.23.1...HEAD
|
|
330
|
+
[0.23.1]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.23.0...@metamask/design-system-react@0.23.1
|
|
331
|
+
[0.23.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.22.0...@metamask/design-system-react@0.23.0
|
|
308
332
|
[0.22.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.21.0...@metamask/design-system-react@0.22.0
|
|
309
333
|
[0.21.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.20.0...@metamask/design-system-react@0.21.0
|
|
310
334
|
[0.20.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.19.0...@metamask/design-system-react@0.20.0
|
|
@@ -9,7 +9,6 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
9
9
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
10
10
|
closeButtonProps?: (Omit<Partial<import("../index.cjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
11
11
|
'data-testid'?: string | undefined;
|
|
12
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
13
12
|
}) | undefined;
|
|
14
13
|
} & {
|
|
15
14
|
actionButtonOnClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
@@ -291,11 +290,11 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
291
290
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
292
291
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
293
292
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
293
|
+
isDisabled?: boolean | undefined;
|
|
294
294
|
asChild?: boolean | undefined;
|
|
295
295
|
textProps?: Partial<import("../index.cjs").TextProps> | undefined;
|
|
296
296
|
isLoading?: boolean | undefined;
|
|
297
297
|
loadingText?: string | undefined;
|
|
298
|
-
isDisabled?: boolean | undefined;
|
|
299
298
|
isFullWidth?: boolean | undefined;
|
|
300
299
|
loadingTextProps?: Partial<import("../index.cjs").TextProps> | undefined;
|
|
301
300
|
startIconName?: import("@metamask/design-system-shared").IconName | undefined;
|
|
@@ -319,7 +318,6 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
319
318
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
320
319
|
closeButtonProps?: (Omit<Partial<import("../index.cjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
321
320
|
'data-testid'?: string | undefined;
|
|
322
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
323
321
|
}) | undefined;
|
|
324
322
|
} & {
|
|
325
323
|
actionButtonOnClick?: undefined;
|
|
@@ -601,11 +599,11 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
601
599
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
602
600
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
603
601
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
602
|
+
isDisabled?: boolean | undefined;
|
|
604
603
|
asChild?: boolean | undefined;
|
|
605
604
|
textProps?: Partial<import("../index.cjs").TextProps> | undefined;
|
|
606
605
|
isLoading?: boolean | undefined;
|
|
607
606
|
loadingText?: string | undefined;
|
|
608
|
-
isDisabled?: boolean | undefined;
|
|
609
607
|
isFullWidth?: boolean | undefined;
|
|
610
608
|
loadingTextProps?: Partial<import("../index.cjs").TextProps> | undefined;
|
|
611
609
|
startIconName?: import("@metamask/design-system-shared").IconName | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerAlert.d.cts","sourceRoot":"","sources":["../../../src/components/BannerAlert/BannerAlert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uCAAuC;AACrE,OAAO,KAAqB,cAAc;AAe1C,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"BannerAlert.d.cts","sourceRoot":"","sources":["../../../src/components/BannerAlert/BannerAlert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uCAAuC;AACrE,OAAO,KAAqB,cAAc;AAe1C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDA8BvB,CAAC"}
|
|
@@ -9,7 +9,6 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
9
9
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
10
10
|
closeButtonProps?: (Omit<Partial<import("../index.mjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
11
11
|
'data-testid'?: string | undefined;
|
|
12
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
13
12
|
}) | undefined;
|
|
14
13
|
} & {
|
|
15
14
|
actionButtonOnClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
@@ -291,11 +290,11 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
291
290
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
292
291
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
293
292
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
293
|
+
isDisabled?: boolean | undefined;
|
|
294
294
|
asChild?: boolean | undefined;
|
|
295
295
|
textProps?: Partial<import("../index.mjs").TextProps> | undefined;
|
|
296
296
|
isLoading?: boolean | undefined;
|
|
297
297
|
loadingText?: string | undefined;
|
|
298
|
-
isDisabled?: boolean | undefined;
|
|
299
298
|
isFullWidth?: boolean | undefined;
|
|
300
299
|
loadingTextProps?: Partial<import("../index.mjs").TextProps> | undefined;
|
|
301
300
|
startIconName?: import("@metamask/design-system-shared").IconName | undefined;
|
|
@@ -319,7 +318,6 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
319
318
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
320
319
|
closeButtonProps?: (Omit<Partial<import("../index.mjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
321
320
|
'data-testid'?: string | undefined;
|
|
322
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
323
321
|
}) | undefined;
|
|
324
322
|
} & {
|
|
325
323
|
actionButtonOnClick?: undefined;
|
|
@@ -601,11 +599,11 @@ export declare const BannerAlert: React.ForwardRefExoticComponent<(Omit<import("
|
|
|
601
599
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
602
600
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
603
601
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
602
|
+
isDisabled?: boolean | undefined;
|
|
604
603
|
asChild?: boolean | undefined;
|
|
605
604
|
textProps?: Partial<import("../index.mjs").TextProps> | undefined;
|
|
606
605
|
isLoading?: boolean | undefined;
|
|
607
606
|
loadingText?: string | undefined;
|
|
608
|
-
isDisabled?: boolean | undefined;
|
|
609
607
|
isFullWidth?: boolean | undefined;
|
|
610
608
|
loadingTextProps?: Partial<import("../index.mjs").TextProps> | undefined;
|
|
611
609
|
startIconName?: import("@metamask/design-system-shared").IconName | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerAlert.d.mts","sourceRoot":"","sources":["../../../src/components/BannerAlert/BannerAlert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uCAAuC;AACrE,OAAO,KAAqB,cAAc;AAe1C,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"BannerAlert.d.mts","sourceRoot":"","sources":["../../../src/components/BannerAlert/BannerAlert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uCAAuC;AACrE,OAAO,KAAqB,cAAc;AAe1C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDA8BvB,CAAC"}
|
|
@@ -35,8 +35,8 @@ const isTextContent = (content) => typeof content === 'string' || typeof content
|
|
|
35
35
|
const hasContent = (content) => content !== null && content !== undefined;
|
|
36
36
|
exports.BannerBase = (0, react_1.forwardRef)(({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnClick, actionButtonProps, startAccessory, onClose, closeButtonProps, className, ...props }, ref) => {
|
|
37
37
|
const resolvedActionButtonProps = actionButtonProps ?? {};
|
|
38
|
-
const { ariaLabel: closeButtonAriaLabel = 'Close banner',
|
|
39
|
-
const shouldShowCloseButton = Boolean(onClose
|
|
38
|
+
const { ariaLabel: closeButtonAriaLabel = 'Close banner', className: closeButtonClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
|
|
39
|
+
const shouldShowCloseButton = Boolean(onClose);
|
|
40
40
|
const shouldShowActionButton = Boolean(actionButtonOnClick);
|
|
41
41
|
return (react_1.default.createElement(Box_1.Box, { ref: ref, flexDirection: design_system_shared_1.BoxFlexDirection.Row, alignItems: design_system_shared_1.BoxAlignItems.Start, gap: 2, backgroundColor: design_system_shared_1.BoxBackgroundColor.BackgroundDefault, padding: 3, className: (0, tw_merge_1.twMerge)('rounded-sm', className), ...props },
|
|
42
42
|
startAccessory,
|
|
@@ -48,7 +48,7 @@ exports.BannerBase = (0, react_1.forwardRef)(({ title, titleProps, description,
|
|
|
48
48
|
(isTextContent(children) ? (react_1.default.createElement(Text_1.Text, { variant: design_system_shared_1.TextVariant.BodyMd, ...childrenWrapperProps }, children)) : (children)),
|
|
49
49
|
shouldShowActionButton && (react_1.default.createElement(Box_1.Box, { className: "mt-4" },
|
|
50
50
|
react_1.default.createElement(Button_1.Button, { size: design_system_shared_1.ButtonSize.Md, onClick: actionButtonOnClick, ...resolvedActionButtonProps }, actionButtonLabel)))),
|
|
51
|
-
shouldShowCloseButton && (react_1.default.createElement(ButtonIcon_1.ButtonIcon, { className: (0, tw_merge_1.twMerge)('ml-3 self-start', closeButtonClassName), iconName: design_system_shared_1.IconName.Close, size: design_system_shared_1.ButtonIconSize.Sm, ariaLabel: closeButtonAriaLabel, onClick: onClose
|
|
51
|
+
shouldShowCloseButton && (react_1.default.createElement(ButtonIcon_1.ButtonIcon, { className: (0, tw_merge_1.twMerge)('ml-3 self-start', closeButtonClassName), iconName: design_system_shared_1.IconName.Close, size: design_system_shared_1.ButtonIconSize.Sm, ariaLabel: closeButtonAriaLabel, onClick: onClose, ...resolvedCloseButtonProps }))));
|
|
52
52
|
});
|
|
53
53
|
exports.BannerBase.displayName = 'BannerBase';
|
|
54
54
|
//# sourceMappingURL=BannerBase.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEASwC;AACxC,+CAA0C;AAE1C,uDAA+C;AAC/C,0CAA6B;AAC7B,gDAAmC;AACnC,wDAA2C;AAC3C,4CAA+B;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAE/B,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,KAAK,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,yBAAyB,GAAG,iBAAiB,IAAI,EAAE,CAAC;IAE1D,MAAM,EACJ,SAAS,EAAE,oBAAoB,GAAG,cAAc,EAChD,
|
|
1
|
+
{"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEASwC;AACxC,+CAA0C;AAE1C,uDAA+C;AAC/C,0CAA6B;AAC7B,gDAAmC;AACnC,wDAA2C;AAC3C,4CAA+B;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CA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AAC,WAAW,CAAC,IAAI,CAC1B,8BAAC,SAAG,IAAC,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IACnD,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAC5B,8BAAC,WAAI,IAAC,OAAO,EAAE,kCAAW,CAAC,MAAM,KAAM,gBAAgB,IACpD,WAAW,CACP,CACR,CAAC,CAAC,CAAC,CACF,WAAW,CACZ,CACG,CACP;YAEA,UAAU,CAAC,QAAQ,CAAC;gBACnB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACzB,8BAAC,WAAI,IAAC,OAAO,EAAE,kCAAW,CAAC,MAAM,KAAM,oBAAoB,IACxD,QAAQ,CACJ,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC;YAEH,sBAAsB,IAAI,CACzB,8BAAC,SAAG,IAAC,SAAS,EAAC,MAAM;gBACnB,8BAAC,eAAM,IACL,IAAI,EAAE,iCAAU,CAAC,EAAE,EACnB,OAAO,EAAE,mBAAmB,KACxB,yBAAyB,IAE5B,iBAAiB,CACX,CACL,CACP,CACG;QAEL,qBAAqB,IAAI,CACxB,8BAAC,uBAAU,IACT,SAAS,EAAE,IAAA,kBAAO,EAAC,iBAAiB,EAAE,oBAAoB,CAAC,EAC3D,QAAQ,EAAE,+BAAQ,CAAC,KAAK,EACxB,IAAI,EAAE,qCAAc,CAAC,EAAE,EACvB,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,OAAO,KACZ,wBAAwB,GAC5B,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import {\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n FontWeight,\n IconName,\n TextVariant,\n} from '@metamask/design-system-shared';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(\n (\n {\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps,\n startAccessory,\n onClose,\n closeButtonProps,\n className,\n ...props\n },\n ref,\n ) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n ariaLabel: closeButtonAriaLabel = 'Close banner',\n className: closeButtonClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnClick);\n\n return (\n <Box\n ref={ref}\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={2}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n padding={3}\n className={twMerge('rounded-sm', className)}\n {...props}\n >\n {startAccessory}\n\n <Box className=\"min-w-0 flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box className={hasContent(title) ? 'mt-1' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {shouldShowActionButton && (\n <Box className=\"mt-4\">\n <Button\n size={ButtonSize.Md}\n onClick={actionButtonOnClick}\n {...resolvedActionButtonProps}\n >\n {actionButtonLabel}\n </Button>\n </Box>\n )}\n </Box>\n\n {shouldShowCloseButton && (\n <ButtonIcon\n className={twMerge('ml-3 self-start', closeButtonClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Sm}\n ariaLabel={closeButtonAriaLabel}\n onClick={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n },\n);\n\nBannerBase.displayName = 'BannerBase';\n"]}
|
|
@@ -7,7 +7,6 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
7
7
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
8
8
|
closeButtonProps?: (Omit<Partial<import("../ButtonIcon/index.cjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
9
9
|
'data-testid'?: string | undefined;
|
|
10
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
11
10
|
}) | undefined;
|
|
12
11
|
} & {
|
|
13
12
|
actionButtonOnClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
@@ -289,11 +288,11 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
289
288
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
290
289
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
291
290
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
291
|
+
isDisabled?: boolean | undefined;
|
|
292
292
|
asChild?: boolean | undefined;
|
|
293
293
|
textProps?: Partial<import("../Text/index.cjs").TextProps> | undefined;
|
|
294
294
|
isLoading?: boolean | undefined;
|
|
295
295
|
loadingText?: string | undefined;
|
|
296
|
-
isDisabled?: boolean | undefined;
|
|
297
296
|
isFullWidth?: boolean | undefined;
|
|
298
297
|
loadingTextProps?: Partial<import("../Text/index.cjs").TextProps> | undefined;
|
|
299
298
|
startIconName?: IconName | undefined;
|
|
@@ -313,7 +312,6 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
313
312
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
314
313
|
closeButtonProps?: (Omit<Partial<import("../ButtonIcon/index.cjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
315
314
|
'data-testid'?: string | undefined;
|
|
316
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
317
315
|
}) | undefined;
|
|
318
316
|
} & {
|
|
319
317
|
actionButtonOnClick?: undefined;
|
|
@@ -595,11 +593,11 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
595
593
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
596
594
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
597
595
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
596
|
+
isDisabled?: boolean | undefined;
|
|
598
597
|
asChild?: boolean | undefined;
|
|
599
598
|
textProps?: Partial<import("../Text/index.cjs").TextProps> | undefined;
|
|
600
599
|
isLoading?: boolean | undefined;
|
|
601
600
|
loadingText?: string | undefined;
|
|
602
|
-
isDisabled?: boolean | undefined;
|
|
603
601
|
isFullWidth?: boolean | undefined;
|
|
604
602
|
loadingTextProps?: Partial<import("../Text/index.cjs").TextProps> | undefined;
|
|
605
603
|
startIconName?: IconName | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EAET,uCAAuC;AACxC,OAAO,KAAqB,cAAc;AAgB1C,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EAET,uCAAuC;AACxC,OAAO,KAAqB,cAAc;AAgB1C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAyGtB,CAAC"}
|
|
@@ -7,7 +7,6 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
7
7
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
8
8
|
closeButtonProps?: (Omit<Partial<import("../ButtonIcon/index.mjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
9
9
|
'data-testid'?: string | undefined;
|
|
10
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
11
10
|
}) | undefined;
|
|
12
11
|
} & {
|
|
13
12
|
actionButtonOnClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
@@ -289,11 +288,11 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
289
288
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
290
289
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
291
290
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
291
|
+
isDisabled?: boolean | undefined;
|
|
292
292
|
asChild?: boolean | undefined;
|
|
293
293
|
textProps?: Partial<import("../Text/index.mjs").TextProps> | undefined;
|
|
294
294
|
isLoading?: boolean | undefined;
|
|
295
295
|
loadingText?: string | undefined;
|
|
296
|
-
isDisabled?: boolean | undefined;
|
|
297
296
|
isFullWidth?: boolean | undefined;
|
|
298
297
|
loadingTextProps?: Partial<import("../Text/index.mjs").TextProps> | undefined;
|
|
299
298
|
startIconName?: IconName | undefined;
|
|
@@ -313,7 +312,6 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
313
312
|
onClose?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
314
313
|
closeButtonProps?: (Omit<Partial<import("../ButtonIcon/index.mjs").ButtonIconProps>, "onClick" | "iconName"> & {
|
|
315
314
|
'data-testid'?: string | undefined;
|
|
316
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
317
315
|
}) | undefined;
|
|
318
316
|
} & {
|
|
319
317
|
actionButtonOnClick?: undefined;
|
|
@@ -595,11 +593,11 @@ export declare const BannerBase: React.ForwardRefExoticComponent<(Omit<import("@
|
|
|
595
593
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
596
594
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
597
595
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
596
|
+
isDisabled?: boolean | undefined;
|
|
598
597
|
asChild?: boolean | undefined;
|
|
599
598
|
textProps?: Partial<import("../Text/index.mjs").TextProps> | undefined;
|
|
600
599
|
isLoading?: boolean | undefined;
|
|
601
600
|
loadingText?: string | undefined;
|
|
602
|
-
isDisabled?: boolean | undefined;
|
|
603
601
|
isFullWidth?: boolean | undefined;
|
|
604
602
|
loadingTextProps?: Partial<import("../Text/index.mjs").TextProps> | undefined;
|
|
605
603
|
startIconName?: IconName | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EAET,uCAAuC;AACxC,OAAO,KAAqB,cAAc;AAgB1C,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,QAAQ,EAET,uCAAuC;AACxC,OAAO,KAAqB,cAAc;AAgB1C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAyGtB,CAAC"}
|
|
@@ -16,8 +16,8 @@ const isTextContent = (content) => typeof content === 'string' || typeof content
|
|
|
16
16
|
const hasContent = (content) => content !== null && content !== undefined;
|
|
17
17
|
export const BannerBase = forwardRef(({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnClick, actionButtonProps, startAccessory, onClose, closeButtonProps, className, ...props }, ref) => {
|
|
18
18
|
const resolvedActionButtonProps = actionButtonProps ?? {};
|
|
19
|
-
const { ariaLabel: closeButtonAriaLabel = 'Close banner',
|
|
20
|
-
const shouldShowCloseButton = Boolean(onClose
|
|
19
|
+
const { ariaLabel: closeButtonAriaLabel = 'Close banner', className: closeButtonClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
|
|
20
|
+
const shouldShowCloseButton = Boolean(onClose);
|
|
21
21
|
const shouldShowActionButton = Boolean(actionButtonOnClick);
|
|
22
22
|
return (React.createElement(Box, { ref: ref, flexDirection: BoxFlexDirection.Row, alignItems: BoxAlignItems.Start, gap: 2, backgroundColor: BoxBackgroundColor.BackgroundDefault, padding: 3, className: twMerge('rounded-sm', className), ...props },
|
|
23
23
|
startAccessory,
|
|
@@ -29,7 +29,7 @@ export const BannerBase = forwardRef(({ title, titleProps, description, descript
|
|
|
29
29
|
(isTextContent(children) ? (React.createElement(Text, { variant: TextVariant.BodyMd, ...childrenWrapperProps }, children)) : (children)),
|
|
30
30
|
shouldShowActionButton && (React.createElement(Box, { className: "mt-4" },
|
|
31
31
|
React.createElement(Button, { size: ButtonSize.Md, onClick: actionButtonOnClick, ...resolvedActionButtonProps }, actionButtonLabel)))),
|
|
32
|
-
shouldShowCloseButton && (React.createElement(ButtonIcon, { className: twMerge('ml-3 self-start', closeButtonClassName), iconName: IconName.Close, size: ButtonIconSize.Sm, ariaLabel: closeButtonAriaLabel, onClick: onClose
|
|
32
|
+
shouldShowCloseButton && (React.createElement(ButtonIcon, { className: twMerge('ml-3 self-start', closeButtonClassName), iconName: IconName.Close, size: ButtonIconSize.Sm, ariaLabel: closeButtonAriaLabel, onClick: onClose, ...resolvedCloseButtonProps }))));
|
|
33
33
|
});
|
|
34
34
|
BannerBase.displayName = 'BannerBase';
|
|
35
35
|
//# sourceMappingURL=BannerBase.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,uCAAuC;AACxC,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,KAAK,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,yBAAyB,GAAG,iBAAiB,IAAI,EAAE,CAAC;IAE1D,MAAM,EACJ,SAAS,EAAE,oBAAoB,GAAG,cAAc,EAChD,
|
|
1
|
+
{"version":3,"file":"BannerBase.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACZ,uCAAuC;AACxC,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC;AAE7D,MAAM,UAAU,GAAG,CAAC,OAAwB,EAAE,EAAE,CAC9C,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,KAAK,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,yBAAyB,GAAG,iBAAiB,IAAI,EAAE,CAAC;IAE1D,MAAM,EACJ,SAAS,EAAE,oBAAoB,GAAG,cAAc,EAChD,SAAS,EAAE,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E,WAAW,CAAC,MAAM,KAAM,oBAAoB,IACxD,QAAQ,CACJ,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC;YAEH,sBAAsB,IAAI,CACzB,oBAAC,GAAG,IAAC,SAAS,EAAC,MAAM;gBACnB,oBAAC,MAAM,IACL,IAAI,EAAE,UAAU,CAAC,EAAE,EACnB,OAAO,EAAE,mBAAmB,KACxB,yBAAyB,IAE5B,iBAAiB,CACX,CACL,CACP,CACG;QAEL,qBAAqB,IAAI,CACxB,oBAAC,UAAU,IACT,SAAS,EAAE,OAAO,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EAC3D,QAAQ,EAAE,QAAQ,CAAC,KAAK,EACxB,IAAI,EAAE,cAAc,CAAC,EAAE,EACvB,SAAS,EAAE,oBAAoB,EAC/B,OAAO,EAAE,OAAO,KACZ,wBAAwB,GAC5B,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import {\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n FontWeight,\n IconName,\n TextVariant,\n} from '@metamask/design-system-shared';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(\n (\n {\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps,\n startAccessory,\n onClose,\n closeButtonProps,\n className,\n ...props\n },\n ref,\n ) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n ariaLabel: closeButtonAriaLabel = 'Close banner',\n className: closeButtonClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnClick);\n\n return (\n <Box\n ref={ref}\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={2}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n padding={3}\n className={twMerge('rounded-sm', className)}\n {...props}\n >\n {startAccessory}\n\n <Box className=\"min-w-0 flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box className={hasContent(title) ? 'mt-1' : undefined}>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {shouldShowActionButton && (\n <Box className=\"mt-4\">\n <Button\n size={ButtonSize.Md}\n onClick={actionButtonOnClick}\n {...resolvedActionButtonProps}\n >\n {actionButtonLabel}\n </Button>\n </Box>\n )}\n </Box>\n\n {shouldShowCloseButton && (\n <ButtonIcon\n className={twMerge('ml-3 self-start', closeButtonClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Sm}\n ariaLabel={closeButtonAriaLabel}\n onClick={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n },\n);\n\nBannerBase.displayName = 'BannerBase';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.types.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BannerBasePropsShared } from '@metamask/design-system-shared';\nimport type { MouseEventHandler } from 'react';\n\nimport type { BoxProps } from '../Box';\nimport type { ButtonProps } from '../Button';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { TextProps } from '../Text';\n\ntype BannerBaseActionButtonProps = Omit<\n Partial<ButtonProps>,\n 'children' | 'onClick' | 'variant'\n>;\n\ntype BannerBaseCloseButtonProps = Omit<\n Partial<ButtonIconProps>,\n 'iconName' | 'onClick'\n> & {\n /**\n * Optional test id for the close button element.\n */\n 'data-testid'?: string;\n
|
|
1
|
+
{"version":3,"file":"BannerBase.types.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BannerBasePropsShared } from '@metamask/design-system-shared';\nimport type { MouseEventHandler } from 'react';\n\nimport type { BoxProps } from '../Box';\nimport type { ButtonProps } from '../Button';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { TextProps } from '../Text';\n\ntype BannerBaseActionButtonProps = Omit<\n Partial<ButtonProps>,\n 'children' | 'onClick' | 'variant'\n>;\n\ntype BannerBaseCloseButtonProps = Omit<\n Partial<ButtonIconProps>,\n 'iconName' | 'onClick'\n> & {\n /**\n * Optional test id for the close button element.\n */\n 'data-testid'?: string;\n};\n\ntype BannerBasePropsBase = BannerBasePropsShared &\n Omit<BoxProps, 'children'> & {\n /**\n * Optional props for the title `Text` when the title is a string.\n */\n titleProps?: Partial<TextProps>;\n /**\n * Optional props for the description `Text` when description is a string.\n */\n descriptionProps?: Partial<TextProps>;\n /**\n * Optional props for the children wrapper `Text` when children is a string.\n */\n childrenWrapperProps?: Partial<TextProps>;\n /**\n * Optional click handler for the close button.\n * If provided, a close button is shown.\n */\n onClose?: MouseEventHandler<HTMLButtonElement>;\n /**\n * Optional props for the close `ButtonIcon`.\n * Only used when `onClose` is provided.\n */\n closeButtonProps?: BannerBaseCloseButtonProps;\n };\n\ntype BannerBaseActionPropsWithHandler = {\n actionButtonOnClick: MouseEventHandler<HTMLButtonElement>;\n actionButtonLabel: string;\n actionButtonProps?: BannerBaseActionButtonProps;\n};\n\ntype BannerBaseActionPropsWithoutHandler = {\n actionButtonOnClick?: undefined;\n actionButtonLabel?: string;\n actionButtonProps?: BannerBaseActionButtonProps;\n};\n\nexport type BannerBaseProps = BannerBasePropsBase &\n (BannerBaseActionPropsWithHandler | BannerBaseActionPropsWithoutHandler);\n"]}
|
|
@@ -10,10 +10,6 @@ type BannerBaseCloseButtonProps = Omit<Partial<ButtonIconProps>, 'iconName' | 'o
|
|
|
10
10
|
* Optional test id for the close button element.
|
|
11
11
|
*/
|
|
12
12
|
'data-testid'?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Optional click handler for the close button.
|
|
15
|
-
*/
|
|
16
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
17
13
|
};
|
|
18
14
|
type BannerBasePropsBase = BannerBasePropsShared & Omit<BoxProps, 'children'> & {
|
|
19
15
|
/**
|
|
@@ -35,7 +31,7 @@ type BannerBasePropsBase = BannerBasePropsShared & Omit<BoxProps, 'children'> &
|
|
|
35
31
|
onClose?: MouseEventHandler<HTMLButtonElement>;
|
|
36
32
|
/**
|
|
37
33
|
* Optional props for the close `ButtonIcon`.
|
|
38
|
-
*
|
|
34
|
+
* Only used when `onClose` is provided.
|
|
39
35
|
*/
|
|
40
36
|
closeButtonProps?: BannerBaseCloseButtonProps;
|
|
41
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAkB;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,2BAA2B,GAAG,IAAI,CACrC,OAAO,CAAC,WAAW,CAAC,EACpB,UAAU,GAAG,SAAS,GAAG,SAAS,CACnC,CAAC;AAEF,KAAK,0BAA0B,GAAG,IAAI,CACpC,OAAO,CAAC,eAAe,CAAC,EACxB,UAAU,GAAG,SAAS,CACvB,GAAG;IACF;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BannerBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAkB;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,2BAA2B,GAAG,IAAI,CACrC,OAAO,CAAC,WAAW,CAAC,EACpB,UAAU,GAAG,SAAS,GAAG,SAAS,CACnC,CAAC;AAEF,KAAK,0BAA0B,GAAG,IAAI,CACpC,OAAO,CAAC,eAAe,CAAC,EACxB,UAAU,GAAG,SAAS,CACvB,GAAG;IACF;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,mBAAmB,GAAG,qBAAqB,GAC9C,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AAEJ,KAAK,gCAAgC,GAAG;IACtC,mBAAmB,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;CACjD,CAAC;AAEF,KAAK,mCAAmC,GAAG;IACzC,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAC/C,CAAC,gCAAgC,GAAG,mCAAmC,CAAC,CAAC"}
|
|
@@ -10,10 +10,6 @@ type BannerBaseCloseButtonProps = Omit<Partial<ButtonIconProps>, 'iconName' | 'o
|
|
|
10
10
|
* Optional test id for the close button element.
|
|
11
11
|
*/
|
|
12
12
|
'data-testid'?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Optional click handler for the close button.
|
|
15
|
-
*/
|
|
16
|
-
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
17
13
|
};
|
|
18
14
|
type BannerBasePropsBase = BannerBasePropsShared & Omit<BoxProps, 'children'> & {
|
|
19
15
|
/**
|
|
@@ -35,7 +31,7 @@ type BannerBasePropsBase = BannerBasePropsShared & Omit<BoxProps, 'children'> &
|
|
|
35
31
|
onClose?: MouseEventHandler<HTMLButtonElement>;
|
|
36
32
|
/**
|
|
37
33
|
* Optional props for the close `ButtonIcon`.
|
|
38
|
-
*
|
|
34
|
+
* Only used when `onClose` is provided.
|
|
39
35
|
*/
|
|
40
36
|
closeButtonProps?: BannerBaseCloseButtonProps;
|
|
41
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.types.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAkB;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,2BAA2B,GAAG,IAAI,CACrC,OAAO,CAAC,WAAW,CAAC,EACpB,UAAU,GAAG,SAAS,GAAG,SAAS,CACnC,CAAC;AAEF,KAAK,0BAA0B,GAAG,IAAI,CACpC,OAAO,CAAC,eAAe,CAAC,EACxB,UAAU,GAAG,SAAS,CACvB,GAAG;IACF;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BannerBase.types.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAAkB;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,2BAA2B,GAAG,IAAI,CACrC,OAAO,CAAC,WAAW,CAAC,EACpB,UAAU,GAAG,SAAS,GAAG,SAAS,CACnC,CAAC;AAEF,KAAK,0BAA0B,GAAG,IAAI,CACpC,OAAO,CAAC,eAAe,CAAC,EACxB,UAAU,GAAG,SAAS,CACvB,GAAG;IACF;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,mBAAmB,GAAG,qBAAqB,GAC9C,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;CAC/C,CAAC;AAEJ,KAAK,gCAAgC,GAAG;IACtC,mBAAmB,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC1D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;CACjD,CAAC;AAEF,KAAK,mCAAmC,GAAG;IACzC,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,2BAA2B,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAC/C,CAAC,gCAAgC,GAAG,mCAAmC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.types.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BannerBasePropsShared } from '@metamask/design-system-shared';\nimport type { MouseEventHandler } from 'react';\n\nimport type { BoxProps } from '../Box';\nimport type { ButtonProps } from '../Button';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { TextProps } from '../Text';\n\ntype BannerBaseActionButtonProps = Omit<\n Partial<ButtonProps>,\n 'children' | 'onClick' | 'variant'\n>;\n\ntype BannerBaseCloseButtonProps = Omit<\n Partial<ButtonIconProps>,\n 'iconName' | 'onClick'\n> & {\n /**\n * Optional test id for the close button element.\n */\n 'data-testid'?: string;\n
|
|
1
|
+
{"version":3,"file":"BannerBase.types.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { BannerBasePropsShared } from '@metamask/design-system-shared';\nimport type { MouseEventHandler } from 'react';\n\nimport type { BoxProps } from '../Box';\nimport type { ButtonProps } from '../Button';\nimport type { ButtonIconProps } from '../ButtonIcon';\nimport type { TextProps } from '../Text';\n\ntype BannerBaseActionButtonProps = Omit<\n Partial<ButtonProps>,\n 'children' | 'onClick' | 'variant'\n>;\n\ntype BannerBaseCloseButtonProps = Omit<\n Partial<ButtonIconProps>,\n 'iconName' | 'onClick'\n> & {\n /**\n * Optional test id for the close button element.\n */\n 'data-testid'?: string;\n};\n\ntype BannerBasePropsBase = BannerBasePropsShared &\n Omit<BoxProps, 'children'> & {\n /**\n * Optional props for the title `Text` when the title is a string.\n */\n titleProps?: Partial<TextProps>;\n /**\n * Optional props for the description `Text` when description is a string.\n */\n descriptionProps?: Partial<TextProps>;\n /**\n * Optional props for the children wrapper `Text` when children is a string.\n */\n childrenWrapperProps?: Partial<TextProps>;\n /**\n * Optional click handler for the close button.\n * If provided, a close button is shown.\n */\n onClose?: MouseEventHandler<HTMLButtonElement>;\n /**\n * Optional props for the close `ButtonIcon`.\n * Only used when `onClose` is provided.\n */\n closeButtonProps?: BannerBaseCloseButtonProps;\n };\n\ntype BannerBaseActionPropsWithHandler = {\n actionButtonOnClick: MouseEventHandler<HTMLButtonElement>;\n actionButtonLabel: string;\n actionButtonProps?: BannerBaseActionButtonProps;\n};\n\ntype BannerBaseActionPropsWithoutHandler = {\n actionButtonOnClick?: undefined;\n actionButtonLabel?: string;\n actionButtonProps?: BannerBaseActionButtonProps;\n};\n\nexport type BannerBaseProps = BannerBasePropsBase &\n (BannerBaseActionPropsWithHandler | BannerBaseActionPropsWithoutHandler);\n"]}
|
|
@@ -34,6 +34,13 @@ const ButtonBase_constants_1 = require("./ButtonBase.constants.cjs");
|
|
|
34
34
|
exports.ButtonBase = (0, react_1.forwardRef)(({ children, className, size = design_system_shared_1.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) => {
|
|
35
35
|
const Component = asChild ? react_slot_1.Slot : 'button';
|
|
36
36
|
const isInteractive = !(isDisabled ?? isLoading);
|
|
37
|
+
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
38
|
+
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
39
|
+
const hasStart = Boolean(finalStartIconName || startAccessory);
|
|
40
|
+
const hasEnd = Boolean(finalEndIconName || endAccessory);
|
|
41
|
+
const hasAccessories = hasStart || hasEnd;
|
|
42
|
+
const iconSize = ButtonBase_constants_1.MAP_BUTTONBASE_SIZE_ICONSIZE[size];
|
|
43
|
+
const labelTextVariant = ButtonBase_constants_1.MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];
|
|
37
44
|
// Calculate tabIndex based on asChild and disabled state
|
|
38
45
|
const getTabIndex = () => {
|
|
39
46
|
if (asChild) {
|
|
@@ -41,41 +48,42 @@ exports.ButtonBase = (0, react_1.forwardRef)(({ children, className, size = desi
|
|
|
41
48
|
}
|
|
42
49
|
return isDisabled ? -1 : undefined;
|
|
43
50
|
};
|
|
51
|
+
const renderLabel = () => {
|
|
52
|
+
if (children && typeof children === 'string') {
|
|
53
|
+
return (react_1.default.createElement(Text_1.Text, { variant: labelTextVariant, fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...textProps },
|
|
54
|
+
react_1.default.createElement("span", null, children)));
|
|
55
|
+
}
|
|
56
|
+
return children;
|
|
57
|
+
};
|
|
44
58
|
const renderLoadingState = () => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
45
|
-
react_1.default.createElement("span", { className: "absolute inline-flex items-center", "aria-hidden": "true" },
|
|
46
|
-
react_1.default.createElement(Icon_1.Icon, { name: design_system_shared_1.IconName.Loading, size:
|
|
47
|
-
react_1.default.createElement(Text_1.Text, { fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
59
|
+
react_1.default.createElement("span", { className: "absolute inline-flex items-center gap-x-1", "aria-hidden": "true" },
|
|
60
|
+
react_1.default.createElement(Icon_1.Icon, { name: design_system_shared_1.IconName.Loading, size: iconSize, className: (0, tw_merge_1.twMerge)('animate-spin text-inherit', loadingIconProps?.className), ...loadingIconProps }),
|
|
61
|
+
react_1.default.createElement(Text_1.Text, { variant: labelTextVariant, fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
48
62
|
react_1.default.createElement("span", null, loadingText))),
|
|
49
|
-
react_1.default.createElement("span", { className: "invisible inline-flex items-center" },
|
|
63
|
+
react_1.default.createElement("span", { className: "invisible inline-flex items-center", "aria-hidden": "true" }, renderLabel()),
|
|
50
64
|
react_1.default.createElement("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true" }, loadingText || 'Loading')));
|
|
51
65
|
const renderStartContent = () => {
|
|
52
|
-
if (
|
|
53
|
-
return (react_1.default.createElement(Icon_1.Icon, { name:
|
|
66
|
+
if (finalStartIconName) {
|
|
67
|
+
return (react_1.default.createElement(Icon_1.Icon, { name: finalStartIconName, size: iconSize, className: (0, tw_merge_1.twMerge)('shrink-0 text-inherit', startIconProps?.className), "aria-hidden": "true", ...startIconProps }));
|
|
54
68
|
}
|
|
55
69
|
if (startAccessory) {
|
|
56
|
-
return
|
|
70
|
+
return react_1.default.createElement("span", { "aria-hidden": "true" }, startAccessory);
|
|
57
71
|
}
|
|
58
72
|
return null;
|
|
59
73
|
};
|
|
60
74
|
const renderEndContent = () => {
|
|
61
|
-
if (
|
|
62
|
-
return (react_1.default.createElement(Icon_1.Icon, { name:
|
|
75
|
+
if (finalEndIconName) {
|
|
76
|
+
return (react_1.default.createElement(Icon_1.Icon, { name: finalEndIconName, size: iconSize, className: (0, tw_merge_1.twMerge)('shrink-0 text-inherit', endIconProps?.className), "aria-hidden": "true", ...endIconProps }));
|
|
63
77
|
}
|
|
64
78
|
if (endAccessory) {
|
|
65
|
-
return
|
|
79
|
+
return react_1.default.createElement("span", { "aria-hidden": "true" }, endAccessory);
|
|
66
80
|
}
|
|
67
81
|
return null;
|
|
68
82
|
};
|
|
69
|
-
const renderContent = () =>
|
|
70
|
-
if (children && typeof children === 'string') {
|
|
71
|
-
return (react_1.default.createElement(Text_1.Text, { fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...textProps },
|
|
72
|
-
react_1.default.createElement("span", null, children)));
|
|
73
|
-
}
|
|
74
|
-
return children;
|
|
75
|
-
};
|
|
83
|
+
const renderContent = () => renderLabel();
|
|
76
84
|
const mergedClassName = (0, tw_merge_1.twMerge)(
|
|
77
85
|
// Base styles
|
|
78
|
-
'inline-flex items-center justify-center', '
|
|
86
|
+
'inline-flex items-center justify-center', (0, ButtonBase_constants_1.getButtonBaseBorderRadiusTwClass)(size), (0, ButtonBase_constants_1.getButtonBaseHorizontalPaddingTwClasses)(size, hasStart, hasEnd), hasAccessories && 'gap-x-1', 'font-medium text-default', 'bg-muted', 'overflow-hidden',
|
|
79
87
|
// Add relative positioning for loading state
|
|
80
88
|
'relative',
|
|
81
89
|
// Size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.t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C,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,8BAAC,sBAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, 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
|
+
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAA0E;AAC1E,qDAAuD;AACvD,+CAA0C;AAE1C,uDAA+C;AAC/C,4CAA+B;AAC/B,4CAAsD;AAEtD,qEAMgC;AAGnB,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,qCAAc,CAAC,EAAE,EACxB,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,YAAY,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C,SAAS,CAAC,CAAC,CAAC,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,8BAAC,sBAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\n\nimport {\n MAP_BUTTONBASE_SIZE_ICONSIZE,\n MAP_BUTTONBASE_SIZE_TEXT_VARIANT,\n getButtonBaseBorderRadiusTwClass,\n getButtonBaseHorizontalPaddingTwClasses,\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION,\n} 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 const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\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 renderLabel = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n variant={labelTextVariant}\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 renderLoadingState = () => (\n <>\n <span\n className=\"absolute inline-flex items-center gap-x-1\"\n aria-hidden=\"true\"\n >\n <Icon\n name={IconName.Loading}\n size={iconSize}\n className={twMerge(\n 'animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n variant={labelTextVariant}\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\" aria-hidden=\"true\">\n {renderLabel()}\n </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 (finalStartIconName) {\n return (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return <span aria-hidden=\"true\">{startAccessory}</span>;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (finalEndIconName) {\n return (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return <span aria-hidden=\"true\">{endAccessory}</span>;\n }\n return null;\n };\n\n const renderContent = () => renderLabel();\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\n hasAccessories && 'gap-x-1',\n 'font-medium text-default',\n 'bg-muted',\n '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"]}
|