@metamask-previews/design-system-react-native 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.
Files changed (166) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/dist/components/AvatarBase/AvatarBase.types.d.cts +0 -1
  3. package/dist/components/AvatarBase/AvatarBase.types.d.cts.map +1 -1
  4. package/dist/components/AvatarBase/AvatarBase.types.d.mts +0 -1
  5. package/dist/components/AvatarBase/AvatarBase.types.d.mts.map +1 -1
  6. package/dist/components/AvatarFavicon/AvatarFavicon.cjs.map +1 -1
  7. package/dist/components/AvatarFavicon/AvatarFavicon.mjs.map +1 -1
  8. package/dist/components/AvatarGroup/AvatarGroup.cjs +2 -2
  9. package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
  10. package/dist/components/AvatarGroup/AvatarGroup.mjs +3 -3
  11. package/dist/components/AvatarGroup/AvatarGroup.mjs.map +1 -1
  12. package/dist/components/AvatarNetwork/AvatarNetwork.cjs.map +1 -1
  13. package/dist/components/AvatarNetwork/AvatarNetwork.mjs.map +1 -1
  14. package/dist/components/AvatarToken/AvatarToken.cjs.map +1 -1
  15. package/dist/components/AvatarToken/AvatarToken.mjs.map +1 -1
  16. package/dist/components/BadgeWrapper/BadgeWrapper.cjs +1 -1
  17. package/dist/components/BadgeWrapper/BadgeWrapper.cjs.map +1 -1
  18. package/dist/components/BadgeWrapper/BadgeWrapper.mjs +1 -1
  19. package/dist/components/BadgeWrapper/BadgeWrapper.mjs.map +1 -1
  20. package/dist/components/BadgeWrapper/BadgeWrapper.types.d.cts +0 -1
  21. package/dist/components/BadgeWrapper/BadgeWrapper.types.d.cts.map +1 -1
  22. package/dist/components/BadgeWrapper/BadgeWrapper.types.d.mts +0 -1
  23. package/dist/components/BadgeWrapper/BadgeWrapper.types.d.mts.map +1 -1
  24. package/dist/components/Box/Box.cjs +22 -5
  25. package/dist/components/Box/Box.cjs.map +1 -1
  26. package/dist/components/Box/Box.constants.cjs +218 -1
  27. package/dist/components/Box/Box.constants.cjs.map +1 -1
  28. package/dist/components/Box/Box.constants.d.cts +16 -1
  29. package/dist/components/Box/Box.constants.d.cts.map +1 -1
  30. package/dist/components/Box/Box.constants.d.mts +16 -1
  31. package/dist/components/Box/Box.constants.d.mts.map +1 -1
  32. package/dist/components/Box/Box.constants.mjs +217 -0
  33. package/dist/components/Box/Box.constants.mjs.map +1 -1
  34. package/dist/components/Box/Box.d.cts +1 -1
  35. package/dist/components/Box/Box.d.cts.map +1 -1
  36. package/dist/components/Box/Box.d.mts +1 -1
  37. package/dist/components/Box/Box.d.mts.map +1 -1
  38. package/dist/components/Box/Box.mjs +23 -6
  39. package/dist/components/Box/Box.mjs.map +1 -1
  40. package/dist/components/Box/Box.types.cjs.map +1 -1
  41. package/dist/components/Box/Box.types.d.cts +84 -1
  42. package/dist/components/Box/Box.types.d.cts.map +1 -1
  43. package/dist/components/Box/Box.types.d.mts +84 -1
  44. package/dist/components/Box/Box.types.d.mts.map +1 -1
  45. package/dist/components/Box/Box.types.mjs.map +1 -1
  46. package/dist/components/Box/index.cjs.map +1 -1
  47. package/dist/components/Box/index.d.cts +1 -1
  48. package/dist/components/Box/index.d.cts.map +1 -1
  49. package/dist/components/Box/index.d.mts +1 -1
  50. package/dist/components/Box/index.d.mts.map +1 -1
  51. package/dist/components/Box/index.mjs.map +1 -1
  52. package/dist/components/Button/Button.cjs +1 -1
  53. package/dist/components/Button/Button.cjs.map +1 -1
  54. package/dist/components/Button/Button.mjs +1 -1
  55. package/dist/components/Button/Button.mjs.map +1 -1
  56. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs +29 -57
  57. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.cjs.map +1 -1
  58. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.cts +1 -1
  59. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.cts.map +1 -1
  60. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.mts +1 -1
  61. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.mts.map +1 -1
  62. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs +30 -58
  63. package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.mjs.map +1 -1
  64. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs +46 -53
  65. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.cjs.map +1 -1
  66. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.cts +1 -1
  67. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.cts.map +1 -1
  68. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.mts +1 -1
  69. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.mts.map +1 -1
  70. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs +47 -54
  71. package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.mjs.map +1 -1
  72. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs +53 -59
  73. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.cjs.map +1 -1
  74. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.cts +1 -1
  75. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.cts.map +1 -1
  76. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.mts +1 -1
  77. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.mts.map +1 -1
  78. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs +54 -60
  79. package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.mjs.map +1 -1
  80. package/dist/components/ButtonBase/ButtonBase.cjs +110 -28
  81. package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
  82. package/dist/components/ButtonBase/ButtonBase.constants.cjs +10 -0
  83. package/dist/components/ButtonBase/ButtonBase.constants.cjs.map +1 -0
  84. package/dist/components/ButtonBase/ButtonBase.constants.d.cts +3 -0
  85. package/dist/components/ButtonBase/ButtonBase.constants.d.cts.map +1 -0
  86. package/dist/components/ButtonBase/ButtonBase.constants.d.mts +3 -0
  87. package/dist/components/ButtonBase/ButtonBase.constants.d.mts.map +1 -0
  88. package/dist/components/ButtonBase/ButtonBase.constants.mjs +7 -0
  89. package/dist/components/ButtonBase/ButtonBase.constants.mjs.map +1 -0
  90. package/dist/components/ButtonBase/ButtonBase.d.cts +1 -1
  91. package/dist/components/ButtonBase/ButtonBase.d.cts.map +1 -1
  92. package/dist/components/ButtonBase/ButtonBase.d.mts +1 -1
  93. package/dist/components/ButtonBase/ButtonBase.d.mts.map +1 -1
  94. package/dist/components/ButtonBase/ButtonBase.mjs +88 -26
  95. package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
  96. package/dist/components/ButtonBase/ButtonBase.types.cjs.map +1 -1
  97. package/dist/components/ButtonBase/ButtonBase.types.d.cts +42 -3
  98. package/dist/components/ButtonBase/ButtonBase.types.d.cts.map +1 -1
  99. package/dist/components/ButtonBase/ButtonBase.types.d.mts +42 -3
  100. package/dist/components/ButtonBase/ButtonBase.types.d.mts.map +1 -1
  101. package/dist/components/ButtonBase/ButtonBase.types.mjs.map +1 -1
  102. package/dist/components/ButtonBase/index.cjs +3 -1
  103. package/dist/components/ButtonBase/index.cjs.map +1 -1
  104. package/dist/components/ButtonBase/index.d.cts +1 -0
  105. package/dist/components/ButtonBase/index.d.cts.map +1 -1
  106. package/dist/components/ButtonBase/index.d.mts +1 -0
  107. package/dist/components/ButtonBase/index.d.mts.map +1 -1
  108. package/dist/components/ButtonBase/index.mjs +1 -0
  109. package/dist/components/ButtonBase/index.mjs.map +1 -1
  110. package/dist/components/ButtonIcon/ButtonIcon.cjs +9 -1
  111. package/dist/components/ButtonIcon/ButtonIcon.cjs.map +1 -1
  112. package/dist/components/ButtonIcon/ButtonIcon.d.cts.map +1 -1
  113. package/dist/components/ButtonIcon/ButtonIcon.d.mts.map +1 -1
  114. package/dist/components/ButtonIcon/ButtonIcon.mjs +9 -1
  115. package/dist/components/ButtonIcon/ButtonIcon.mjs.map +1 -1
  116. package/dist/components/Checkbox/Checkbox.cjs +1 -1
  117. package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
  118. package/dist/components/Checkbox/Checkbox.mjs +1 -1
  119. package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
  120. package/dist/components/Checkbox/Checkbox.types.d.cts +0 -1
  121. package/dist/components/Checkbox/Checkbox.types.d.cts.map +1 -1
  122. package/dist/components/Checkbox/Checkbox.types.d.mts +0 -1
  123. package/dist/components/Checkbox/Checkbox.types.d.mts.map +1 -1
  124. package/dist/components/Icon/Icon.assets.cjs +2 -3
  125. package/dist/components/Icon/Icon.assets.cjs.map +1 -1
  126. package/dist/components/Icon/Icon.assets.mjs +2 -3
  127. package/dist/components/Icon/Icon.assets.mjs.map +1 -1
  128. package/dist/components/Text/Text.constants.cjs +9 -0
  129. package/dist/components/Text/Text.constants.cjs.map +1 -1
  130. package/dist/components/Text/Text.constants.d.cts.map +1 -1
  131. package/dist/components/Text/Text.constants.d.mts.map +1 -1
  132. package/dist/components/Text/Text.constants.mjs +9 -0
  133. package/dist/components/Text/Text.constants.mjs.map +1 -1
  134. package/dist/components/Text/Text.types.cjs.map +1 -1
  135. package/dist/components/Text/Text.types.d.cts +1 -2
  136. package/dist/components/Text/Text.types.d.cts.map +1 -1
  137. package/dist/components/Text/Text.types.d.mts +1 -2
  138. package/dist/components/Text/Text.types.d.mts.map +1 -1
  139. package/dist/components/Text/Text.types.mjs.map +1 -1
  140. package/dist/components/TextButton/TextButton.cjs +1 -0
  141. package/dist/components/TextButton/TextButton.cjs.map +1 -1
  142. package/dist/components/TextButton/TextButton.d.cts.map +1 -1
  143. package/dist/components/TextButton/TextButton.d.mts.map +1 -1
  144. package/dist/components/TextButton/TextButton.mjs +1 -0
  145. package/dist/components/TextButton/TextButton.mjs.map +1 -1
  146. package/dist/components/TextButton/TextButton.types.d.cts +0 -1
  147. package/dist/components/TextButton/TextButton.types.d.cts.map +1 -1
  148. package/dist/components/TextButton/TextButton.types.d.mts +0 -1
  149. package/dist/components/TextButton/TextButton.types.d.mts.map +1 -1
  150. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.cts +0 -1
  151. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.cts.map +1 -1
  152. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.mts +0 -1
  153. package/dist/components/temp-components/ImageOrSvg/ImageOrSvg.types.d.mts.map +1 -1
  154. package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.cts +0 -1
  155. package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.cts.map +1 -1
  156. package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.mts +0 -1
  157. package/dist/components/temp-components/TextOrChildren/TextOrChildren.types.d.mts.map +1 -1
  158. package/dist/types/index.cjs +143 -4
  159. package/dist/types/index.cjs.map +1 -1
  160. package/dist/types/index.d.cts +141 -4
  161. package/dist/types/index.d.cts.map +1 -1
  162. package/dist/types/index.d.mts +141 -4
  163. package/dist/types/index.d.mts.map +1 -1
  164. package/dist/types/index.mjs +142 -3
  165. package/dist/types/index.mjs.map +1 -1
  166. package/package.json +13 -13
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { ButtonTertiaryProps } from "./ButtonTertiary.types.mjs";
3
- export declare const ButtonTertiary: ({ children, textProps, spinnerProps, startIconProps, endIconProps, isDanger, isInverse, isLoading, onPressIn, onPressOut, twClassName, style, ...props }: ButtonTertiaryProps) => React.JSX.Element;
3
+ export declare const ButtonTertiary: ({ children, textProps, spinnerProps, startIconProps, endIconProps, isDanger, isInverse, isLoading, twClassName, style, ...props }: ButtonTertiaryProps) => React.JSX.Element;
4
4
  //# sourceMappingURL=ButtonTertiary.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonTertiary.d.mts","sourceRoot":"","sources":["../../../../../src/components/Button/variants/ButtonTertiary/ButtonTertiary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,cAAc;AAQxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAA+B;AAElE,eAAO,MAAM,cAAc,6JAcxB,mBAAmB,sBA+FrB,CAAC"}
1
+ {"version":3,"file":"ButtonTertiary.d.mts","sourceRoot":"","sources":["../../../../../src/components/Button/variants/ButtonTertiary/ButtonTertiary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,cAAc;AAM3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,mCAA+B;AAElE,eAAO,MAAM,cAAc,sIAYxB,mBAAmB,sBA6FrB,CAAC"}
@@ -4,85 +4,79 @@ function $importDefault(module) {
4
4
  }
5
5
  return module;
6
6
  }
7
- import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
8
- import $React, { useState } from "react";
7
+ import $React, { useCallback } from "react";
9
8
  const React = $importDefault($React);
10
9
  import { ButtonBase } from "../../../ButtonBase/index.mjs";
11
10
  import { IconSize } from "../../../Icon/index.mjs";
12
11
  import { TextVariant, FontWeight } from "../../../Text/index.mjs";
13
- export const ButtonTertiary = ({ children, textProps, spinnerProps, startIconProps, endIconProps, isDanger = false, isInverse = false, isLoading = false, onPressIn, onPressOut, twClassName = '', style, ...props }) => {
14
- const [isPressed, setIsPressed] = useState(false);
15
- const tw = useTailwind();
16
- const twContainerClassNames = `
17
- ${isInverse && isDanger
18
- ? isPressed || isLoading
19
- ? 'bg-default-pressed'
20
- : 'bg-default'
21
- : isDanger
22
- ? isPressed || isLoading
23
- ? 'bg-error-muted-pressed'
24
- : 'bg-transparent'
25
- : isInverse
26
- ? isPressed || isLoading
27
- ? 'bg-pressed'
28
- : 'bg-transparent'
29
- : isPressed || isLoading
30
- ? 'bg-pressed'
31
- : 'bg-transparent'}
32
- ${isInverse && !isDanger ? 'border-[1.5px]' : 'border-0'}
33
- ${isInverse && isDanger
34
- ? isPressed || isLoading
35
- ? 'border-background-default-pressed'
36
- : 'border-background-default'
37
- : isDanger
38
- ? isPressed || isLoading
39
- ? 'border-error-muted-pressed'
40
- : 'border-transparent'
41
- : isInverse
42
- ? 'border-primary-inverse'
43
- : isPressed || isLoading
12
+ export const ButtonTertiary = ({ children, textProps, spinnerProps, startIconProps, endIconProps, isDanger = false, isInverse = false, isLoading = false, twClassName = '', style, ...props }) => {
13
+ const getContainerClassName = useCallback((pressed) => {
14
+ const classNameStr = typeof twClassName === 'function' ? twClassName(pressed) : twClassName;
15
+ const baseClasses = `
16
+ ${isInverse && !isDanger ? 'border-[1.5px]' : 'border-0'}
17
+ ${classNameStr}
18
+ `;
19
+ let backgroundClass = '';
20
+ let borderClass = '';
21
+ if (isInverse && isDanger) {
22
+ backgroundClass =
23
+ pressed || isLoading ? 'bg-default-pressed' : 'bg-default';
24
+ borderClass =
25
+ pressed || isLoading
26
+ ? 'border-background-default-pressed'
27
+ : 'border-background-default';
28
+ }
29
+ else if (isDanger) {
30
+ backgroundClass =
31
+ pressed || isLoading ? 'bg-error-muted-pressed' : 'bg-transparent';
32
+ borderClass =
33
+ pressed || isLoading
34
+ ? 'border-error-muted-pressed'
35
+ : 'border-transparent';
36
+ }
37
+ else if (isInverse) {
38
+ backgroundClass =
39
+ pressed || isLoading ? 'bg-pressed' : 'bg-transparent';
40
+ borderClass = 'border-primary-inverse';
41
+ }
42
+ else {
43
+ backgroundClass =
44
+ pressed || isLoading ? 'bg-pressed' : 'bg-transparent';
45
+ borderClass =
46
+ pressed || isLoading
44
47
  ? 'border-background-pressed'
45
- : 'border-transparent'}
46
- `;
47
- const twTextClassNames = isDanger
48
- ? isPressed || isLoading
49
- ? 'text-error-default-pressed'
50
- : 'text-error-default'
51
- : isInverse
52
- ? 'text-primary-inverse'
53
- : isPressed || isLoading
54
- ? 'text-primary-default-pressed'
55
- : 'text-primary-default';
56
- const onPressInHandler = (event) => {
57
- setIsPressed(true);
58
- onPressIn?.(event);
59
- };
60
- const onPressOutHandler = (event) => {
61
- setIsPressed(false);
62
- onPressOut?.(event);
63
- };
48
+ : 'border-transparent';
49
+ }
50
+ return `${backgroundClass} ${borderClass} ${baseClasses}`;
51
+ }, [isInverse, isDanger, isLoading, twClassName]);
52
+ const getTextClassName = useCallback((pressed) => {
53
+ if (isDanger) {
54
+ return pressed || isLoading
55
+ ? 'text-error-default-pressed'
56
+ : 'text-error-default';
57
+ }
58
+ if (isInverse) {
59
+ return 'text-primary-inverse';
60
+ }
61
+ return pressed || isLoading
62
+ ? 'text-primary-default-pressed'
63
+ : 'text-primary-default';
64
+ }, [isDanger, isInverse, isLoading]);
64
65
  return (<ButtonBase textProps={{
65
66
  variant: TextVariant.BodyMd,
66
67
  fontWeight: FontWeight.Medium,
67
68
  numberOfLines: 1,
68
69
  ellipsizeMode: 'clip',
69
70
  ...textProps,
70
- twClassName: `${twTextClassNames} ${textProps?.twClassName ?? ''}`,
71
71
  }} spinnerProps={{
72
- color: twTextClassNames,
73
- loadingTextProps: {
74
- twClassName: twTextClassNames,
75
- },
76
72
  ...spinnerProps,
77
73
  }} startIconProps={{
78
74
  size: IconSize.Sm,
79
75
  ...startIconProps,
80
- twClassName: `${twTextClassNames} ${startIconProps?.twClassName ?? ''}`,
81
76
  }} endIconProps={{
82
77
  size: IconSize.Sm,
83
78
  ...endIconProps,
84
- twClassName: `${twTextClassNames} ${endIconProps?.twClassName ?? ''}`,
85
- }} isLoading={isLoading} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} style={[tw `${twContainerClassNames}`, style]} {...props}>
79
+ }} isLoading={isLoading} twClassName={getContainerClassName} textClassName={getTextClassName} iconClassName={getTextClassName} style={style} {...props}>
86
80
  {children}
87
81
  </ButtonBase>);
88
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonTertiary.mjs","sourceRoot":"","sources":["../../../../../src/components/Button/variants/ButtonTertiary/ButtonTertiary.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,sDAAs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ChB,CAAC,CACF,cAAc,CAAC,CAAC;YACd,IAAI,EAAE,QAAQ,CAAC,EAAE;YACjB,GAAG,cAAc;YACjB,WAAW,EAAE,GAAG,gBAAgB,IAAI,cAAc,EAAE,WAAW,IAAI,EAAE,EAAE;SACxE,CAAC,CACF,YAAY,CAAC,CAAC;YACZ,IAAI,EAAE,QAAQ,CAAC,EAAE;YACjB,GAAG,YAAY;YACf,WAAW,EAAE,GAAG,gBAAgB,IAAI,YAAY,EAAE,WAAW,IAAI,EAAE,EAAE;SACtE,CAAC,CACF,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAC5B,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAC9B,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA,GAAG,qBAAqB,EAAE,EAAE,KAAK,CAAC,CAAC,CAC7C,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useState } from 'react';\nimport type { GestureResponderEvent } from 'react-native';\n\nimport { ButtonBase } from '../../../ButtonBase';\nimport type { IconColor } from '../../../Icon';\nimport { IconSize } from '../../../Icon';\nimport { TextVariant, FontWeight } from '../../../Text';\n\nimport type { ButtonTertiaryProps } from './ButtonTertiary.types';\n\nexport const ButtonTertiary = ({\n children,\n textProps,\n spinnerProps,\n startIconProps,\n endIconProps,\n isDanger = false,\n isInverse = false,\n isLoading = false,\n onPressIn,\n onPressOut,\n twClassName = '',\n style,\n ...props\n}: ButtonTertiaryProps) => {\n const [isPressed, setIsPressed] = useState(false);\n const tw = useTailwind();\n const twContainerClassNames = `\n ${\n isInverse && isDanger\n ? isPressed || isLoading\n ? 'bg-default-pressed'\n : 'bg-default'\n : isDanger\n ? isPressed || isLoading\n ? 'bg-error-muted-pressed'\n : 'bg-transparent'\n : isInverse\n ? isPressed || isLoading\n ? 'bg-pressed'\n : 'bg-transparent'\n : isPressed || isLoading\n ? 'bg-pressed'\n : 'bg-transparent'\n }\n ${isInverse && !isDanger ? 'border-[1.5px]' : 'border-0'}\n ${\n isInverse && isDanger\n ? isPressed || isLoading\n ? 'border-background-default-pressed'\n : 'border-background-default'\n : isDanger\n ? isPressed || isLoading\n ? 'border-error-muted-pressed'\n : 'border-transparent'\n : isInverse\n ? 'border-primary-inverse'\n : isPressed || isLoading\n ? 'border-background-pressed'\n : 'border-transparent'\n }\n `;\n\n const twTextClassNames = isDanger\n ? isPressed || isLoading\n ? 'text-error-default-pressed'\n : 'text-error-default'\n : isInverse\n ? 'text-primary-inverse'\n : isPressed || isLoading\n ? 'text-primary-default-pressed'\n : 'text-primary-default';\n\n const onPressInHandler = (event: GestureResponderEvent) => {\n setIsPressed(true);\n onPressIn?.(event);\n };\n\n const onPressOutHandler = (event: GestureResponderEvent) => {\n setIsPressed(false);\n onPressOut?.(event);\n };\n\n return (\n <ButtonBase\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n twClassName: `${twTextClassNames} ${textProps?.twClassName ?? ''}`,\n }}\n spinnerProps={{\n color: twTextClassNames as IconColor,\n loadingTextProps: {\n twClassName: twTextClassNames,\n },\n ...spinnerProps,\n }}\n startIconProps={{\n size: IconSize.Sm,\n ...startIconProps,\n twClassName: `${twTextClassNames} ${startIconProps?.twClassName ?? ''}`,\n }}\n endIconProps={{\n size: IconSize.Sm,\n ...endIconProps,\n twClassName: `${twTextClassNames} ${endIconProps?.twClassName ?? ''}`,\n }}\n isLoading={isLoading}\n onPressIn={onPressInHandler}\n onPressOut={onPressOutHandler}\n style={[tw`${twContainerClassNames}`, style]}\n {...props}\n >\n {children}\n </ButtonBase>\n );\n};\n"]}
1
+ {"version":3,"file":"ButtonTertiary.mjs","sourceRoot":"","sources":["../../../../../src/components/Button/variants/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Y;SAChB,CAAC,CACF,cAAc,CAAC,CAAC;YACd,IAAI,EAAE,QAAQ,CAAC,EAAE;YACjB,GAAG,cAAc;SAClB,CAAC,CACF,YAAY,CAAC,CAAC;YACZ,IAAI,EAAE,QAAQ,CAAC,EAAE;YACjB,GAAG,YAAY;SAChB,CAAC,CACF,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,WAAW,CAAC,CAAC,qBAAqB,CAAC,CACnC,aAAa,CAAC,CAAC,gBAAgB,CAAC,CAChC,aAAa,CAAC,CAAC,gBAAgB,CAAC,CAChC,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,UAAU,CAAC,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useCallback } from 'react';\n\nimport { ButtonBase } from '../../../ButtonBase';\nimport { IconSize } from '../../../Icon';\nimport { TextVariant, FontWeight } from '../../../Text';\n\nimport type { ButtonTertiaryProps } from './ButtonTertiary.types';\n\nexport const ButtonTertiary = ({\n children,\n textProps,\n spinnerProps,\n startIconProps,\n endIconProps,\n isDanger = false,\n isInverse = false,\n isLoading = false,\n twClassName = '',\n style,\n ...props\n}: ButtonTertiaryProps) => {\n const getContainerClassName = useCallback(\n (pressed: boolean): string => {\n const classNameStr =\n typeof twClassName === 'function' ? twClassName(pressed) : twClassName;\n\n const baseClasses = `\n ${isInverse && !isDanger ? 'border-[1.5px]' : 'border-0'}\n ${classNameStr}\n `;\n\n let backgroundClass = '';\n let borderClass = '';\n\n if (isInverse && isDanger) {\n backgroundClass =\n pressed || isLoading ? 'bg-default-pressed' : 'bg-default';\n borderClass =\n pressed || isLoading\n ? 'border-background-default-pressed'\n : 'border-background-default';\n } else if (isDanger) {\n backgroundClass =\n pressed || isLoading ? 'bg-error-muted-pressed' : 'bg-transparent';\n borderClass =\n pressed || isLoading\n ? 'border-error-muted-pressed'\n : 'border-transparent';\n } else if (isInverse) {\n backgroundClass =\n pressed || isLoading ? 'bg-pressed' : 'bg-transparent';\n borderClass = 'border-primary-inverse';\n } else {\n backgroundClass =\n pressed || isLoading ? 'bg-pressed' : 'bg-transparent';\n borderClass =\n pressed || isLoading\n ? 'border-background-pressed'\n : 'border-transparent';\n }\n\n return `${backgroundClass} ${borderClass} ${baseClasses}`;\n },\n [isInverse, isDanger, isLoading, twClassName],\n );\n\n const getTextClassName = useCallback(\n (pressed: boolean): string => {\n if (isDanger) {\n return pressed || isLoading\n ? 'text-error-default-pressed'\n : 'text-error-default';\n }\n if (isInverse) {\n return 'text-primary-inverse';\n }\n return pressed || isLoading\n ? 'text-primary-default-pressed'\n : 'text-primary-default';\n },\n [isDanger, isInverse, isLoading],\n );\n\n return (\n <ButtonBase\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n }}\n spinnerProps={{\n ...spinnerProps,\n }}\n startIconProps={{\n size: IconSize.Sm,\n ...startIconProps,\n }}\n endIconProps={{\n size: IconSize.Sm,\n ...endIconProps,\n }}\n isLoading={isLoading}\n twClassName={getContainerClassName}\n textClassName={getTextClassName}\n iconClassName={getTextClassName}\n style={style}\n {...props}\n >\n {children}\n </ButtonBase>\n );\n};\n"]}
@@ -1,11 +1,31 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.ButtonBase = void 0;
7
27
  const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
8
- const react_1 = __importDefault(require("react"));
28
+ const react_1 = __importStar(require("react"));
9
29
  const react_native_1 = require("react-native/index.js");
10
30
  const types_1 = require("../../types/index.cjs");
11
31
  const Icon_1 = require("../Icon/index.cjs");
@@ -14,34 +34,96 @@ const ButtonAnimated_1 = require("../temp-components/ButtonAnimated/index.cjs");
14
34
  const Spinner_1 = require("../temp-components/Spinner/index.cjs");
15
35
  const TextOrChildren_1 = require("../temp-components/TextOrChildren/TextOrChildren.cjs");
16
36
  const Text_1 = require("../Text/index.cjs");
17
- const ButtonBase = ({ children, textProps, size = types_1.ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName = '', style, ...props }) => {
37
+ const ButtonBase_constants_1 = require("./ButtonBase.constants.cjs");
38
+ const ButtonBase = ({ children, textProps, size = types_1.ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName = '', textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole = 'button', accessibilityActions, onAccessibilityAction, ...props }) => {
18
39
  const tw = (0, design_system_twrnc_preset_1.useTailwind)();
19
- const twContainerClassNames = `
20
- flex-row items-center justify-center rounded-full bg-muted px-4 min-w-[80px] overflow-hidden
21
- h-[${size}px]
22
- ${isDisabled ? 'opacity-50' : 'opacity-100'}
23
- ${isFullWidth ? 'self-stretch' : 'self-start'}
24
- ${twClassName}
25
- `;
26
40
  const finalStartIconName = startIconName ?? startIconProps?.name;
27
41
  const finalEndIconName = endIconName ?? endIconProps?.name;
28
- return (<ButtonAnimated_1.ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole="button" accessible style={[tw `${twContainerClassNames}`, style]} {...props}>
29
- <react_native_1.View style={tw `absolute inset-0 flex items-center justify-center ${isLoading ? 'opacity-100' : 'opacity-0'}`} testID="spinner-container">
30
- <Spinner_1.Spinner color={Icon_2.IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{ numberOfLines: 1 }} {...spinnerProps}/>
31
- </react_native_1.View>
32
- <react_native_1.View style={tw `flex-row items-center justify-center gap-x-2 ${isLoading ? 'opacity-0' : 'opacity-100'}`} testID="content-container">
33
- {finalStartIconName ? (<Icon_1.Icon name={finalStartIconName} size={Icon_2.IconSize.Sm} twClassName="shrink-0" {...startIconProps}/>) : (startAccessory)}
34
- <TextOrChildren_1.TextOrChildren textProps={{
35
- variant: Text_1.TextVariant.BodyMd,
36
- fontWeight: Text_1.FontWeight.Medium,
37
- color: Text_1.TextColor.TextDefault,
38
- twClassName: 'shrink grow-0 flex-wrap text-center',
39
- ...textProps,
40
- }}>
41
- {children}
42
- </TextOrChildren_1.TextOrChildren>
43
- {finalEndIconName ? (<Icon_1.Icon name={finalEndIconName} size={Icon_2.IconSize.Sm} twClassName="shrink-0" {...endIconProps}/>) : (endAccessory)}
44
- </react_native_1.View>
42
+ // Generate accessibility label if not provided
43
+ const finalAccessibilityLabel = (0, react_1.useMemo)(() => {
44
+ if (accessibilityLabel) {
45
+ return accessibilityLabel;
46
+ }
47
+ // For loading state with loadingText, prioritize loadingText
48
+ if (isLoading && loadingText) {
49
+ return loadingText;
50
+ }
51
+ // If children is a string, use it as the label
52
+ if (typeof children === 'string') {
53
+ return children;
54
+ }
55
+ return undefined;
56
+ }, [accessibilityLabel, children, isLoading, loadingText]);
57
+ // Generate accessibility hint for loading state if not provided
58
+ const finalAccessibilityHint = (0, react_1.useMemo)(() => {
59
+ if (accessibilityHint) {
60
+ return accessibilityHint;
61
+ }
62
+ if (isLoading) {
63
+ return 'Button is currently loading, please wait';
64
+ }
65
+ return undefined;
66
+ }, [accessibilityHint, isLoading]);
67
+ // Create accessibilityState object with only truthy values
68
+ const accessibilityState = (0, react_1.useMemo)(() => {
69
+ const state = {};
70
+ if (isDisabled || isLoading) {
71
+ state.disabled = true;
72
+ }
73
+ if (isLoading) {
74
+ state.busy = true;
75
+ }
76
+ return state;
77
+ }, [isDisabled, isLoading]);
78
+ return (<ButtonAnimated_1.ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole={accessibilityRole} accessibilityLabel={finalAccessibilityLabel} accessibilityHint={finalAccessibilityHint} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} accessibilityState={accessibilityState} accessible style={({ pressed }) => {
79
+ const containerClassName = typeof twClassName === 'function'
80
+ ? twClassName(pressed)
81
+ : twClassName;
82
+ const baseContainerClassNames = `
83
+ flex-row items-center justify-center rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden
84
+ ${ButtonBase_constants_1.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size]}
85
+ ${isDisabled ? 'opacity-50' : 'opacity-100'}
86
+ ${isFullWidth ? 'w-full' : 'w-auto'}
87
+ ${containerClassName}
88
+ `;
89
+ const computedStyle = [
90
+ tw `${baseContainerClassNames}`,
91
+ ];
92
+ if (typeof style === 'function') {
93
+ const additionalStyle = style({ pressed });
94
+ if (additionalStyle) {
95
+ computedStyle.push(additionalStyle);
96
+ }
97
+ }
98
+ else if (style) {
99
+ computedStyle.push(style);
100
+ }
101
+ return computedStyle;
102
+ }} {...props}>
103
+ {({ pressed }) => (<>
104
+ <react_native_1.View style={tw `absolute inset-0 flex items-center justify-center ${isLoading ? 'opacity-100' : 'opacity-0'}`} testID="spinner-container">
105
+ <Spinner_1.Spinner color={textClassName
106
+ ? textClassName(pressed)
107
+ : Icon_2.IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{
108
+ numberOfLines: 1,
109
+ twClassName: textClassName ? textClassName(pressed) : '',
110
+ ...spinnerProps?.loadingTextProps,
111
+ }} {...spinnerProps}/>
112
+ </react_native_1.View>
113
+ <react_native_1.View style={tw `flex-row items-center justify-center gap-x-2 ${isLoading ? 'opacity-0' : 'opacity-100'}`} testID="content-container">
114
+ {finalStartIconName ? (<Icon_1.Icon name={finalStartIconName} size={Icon_2.IconSize.Sm} twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`} {...startIconProps}/>) : (startAccessory)}
115
+ <TextOrChildren_1.TextOrChildren textProps={{
116
+ variant: Text_1.TextVariant.BodyMd,
117
+ fontWeight: Text_1.FontWeight.Medium,
118
+ color: Text_1.TextColor.TextDefault,
119
+ twClassName: `shrink grow-0 flex-wrap text-center ${textClassName ? textClassName(pressed) : ''}`,
120
+ ...textProps,
121
+ }}>
122
+ {children}
123
+ </TextOrChildren_1.TextOrChildren>
124
+ {finalEndIconName ? (<Icon_1.Icon name={finalEndIconName} size={Icon_2.IconSize.Sm} twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`} {...endIconProps}/>) : (endAccessory)}
125
+ </react_native_1.View>
126
+ </>)}
45
127
  </ButtonAnimated_1.ButtonAnimated>);
46
128
  };
47
129
  exports.ButtonBase = ButtonBase;
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,8FAA4E;AAC5E,kDAA0B;AAC1B,wDAAoC;AAEpC,iDAA6C;AAC7C,4CAA+B;AAC/B,4CAA8C;AAC9C,gFAAmE;AACnE,kEAAqD;AACrD,yFAAkF;AAClF,4CAA6D;AAItD,MAAM,UAAU,GA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AI,CACN;MAAA,CAAC,mBAAI,CACH,KAAK,CAAC,CAAC,EAAE,CAAA,gDACP,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAC5B,EAAE,CAAC,CACH,MAAM,CAAC,mBAAmB,CAE1B;QAAA,CAAC,kBAAkB,CAAC,CAAC,CAAC,CACpB,CAAC,WAAI,CACH,IAAI,CAAC,CAAC,kBAAkB,CAAC,CACzB,IAAI,CAAC,CAAC,eAAQ,CAAC,EAAE,CAAC,CAClB,WAAW,CAAC,UAAU,CACtB,IAAI,cAAc,CAAC,EACnB,CACH,CAAC,CAAC,CAAC,CACF,cAAc,CACf,CACD;QAAA,CAAC,+BAAc,CACb,SAAS,CAAC,CAAC;YACT,OAAO,EAAE,kBAAW,CAAC,MAAM;YAC3B,UAAU,EAAE,iBAAU,CAAC,MAAM;YAC7B,KAAK,EAAE,gBAAS,CAAC,WAAW;YAC5B,WAAW,EAAE,qCAAqC;YAClD,GAAG,SAAS;SACb,CAAC,CAEF;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,+BAAc,CAChB;QAAA,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAClB,CAAC,WAAI,CACH,IAAI,CAAC,CAAC,gBAAgB,CAAC,CACvB,IAAI,CAAC,CAAC,eAAQ,CAAC,EAAE,CAAC,CAClB,WAAW,CAAC,UAAU,CACtB,IAAI,YAAY,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACH;MAAA,EAAE,mBAAI,CACR;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AA5FW,QAAA,UAAU,cA4FrB","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React from 'react';\nimport { View } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon } from '../Icon';\nimport { IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName = '',\n style,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n const twContainerClassNames = `\n flex-row items-center justify-center rounded-full bg-muted px-4 min-w-[80px] overflow-hidden\n h-[${size}px]\n ${isDisabled ? 'opacity-50' : 'opacity-100'}\n ${isFullWidth ? 'self-stretch' : 'self-start'}\n ${twClassName}\n `;\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole=\"button\"\n accessible\n style={[tw`${twContainerClassNames}`, style]}\n {...props}\n >\n <View\n style={tw`absolute inset-0 flex items-center justify-center ${\n isLoading ? 'opacity-100' : 'opacity-0'\n }`}\n testID=\"spinner-container\"\n >\n <Spinner\n color={IconColor.IconDefault}\n loadingText={loadingText}\n loadingTextProps={{ numberOfLines: 1 }}\n {...spinnerProps}\n />\n </View>\n <View\n style={tw`flex-row items-center justify-center gap-x-2 ${\n isLoading ? 'opacity-0' : 'opacity-100'\n }`}\n testID=\"content-container\"\n >\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName=\"shrink-0\"\n {...startIconProps}\n />\n ) : (\n startAccessory\n )}\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: 'shrink grow-0 flex-wrap text-center',\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName=\"shrink-0\"\n {...endIconProps}\n />\n ) : (\n endAccessory\n )}\n </View>\n </ButtonAnimated>\n );\n};\n"]}
1
+ {"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA4E;AAC5E,+CAAuC;AACvC,wDAAoC;AAGpC,iDAA6C;AAC7C,4CAA+B;AAC/B,4CAA8C;AAC9C,gFAAmE;AACnE,kEAAqD;AACrD,yFAAkF;AAClF,4CAA6D;AAE7D,qEAA8E;AAGvE,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,sBAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GAAG,EAAE,EAChB,aAAa,EACb,aAAa,EACb,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAAG,QAAQ,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,GAAG,KAAK,EACQ,EAAE,EAAE;IACpB,MAAM,EAAE,GAAG,IAAA,wCAAW,GAAE,CAAC;IAEzB,MAAM,kBAAkB,GAAG,aAAa,IAAI,cAAc,EAAE,IAAI,CAAC;IACjE,MAAM,gBAAgB,GAAG,WAAW,IAAI,YAAY,EAAE,IAAI,CAAC;IAE3D,+CAA+C;IAC/C,MAAM,uBAAuB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC3C,IAAI,kBAAkB,EAAE;YACtB,OAAO,kBAAkB,CAAC;SAC3B;QAED,6DAA6D;QAC7D,IAAI,SAAS,IAAI,WAAW,EAAE;YAC5B,OAAO,WAAW,CAAC;SACpB;QAED,+CAA+C;QAC/C,IAAI,OAAO,QAAQ,KAAK,QAAQ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CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACH;UAAA,EAAE,mBAAI,CACR;QAAA,GAAG,CACJ,CACH;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AAvLW,QAAA,UAAU,cAuLrB","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport { View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon } from '../Icon';\nimport { IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName = '',\n textClassName,\n iconClassName,\n style,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n accessibilityActions,\n onAccessibilityAction,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n // Generate accessibility label if not provided\n const finalAccessibilityLabel = useMemo(() => {\n if (accessibilityLabel) {\n return accessibilityLabel;\n }\n\n // For loading state with loadingText, prioritize loadingText\n if (isLoading && loadingText) {\n return loadingText;\n }\n\n // If children is a string, use it as the label\n if (typeof children === 'string') {\n return children;\n }\n\n return undefined;\n }, [accessibilityLabel, children, isLoading, loadingText]);\n\n // Generate accessibility hint for loading state if not provided\n const finalAccessibilityHint = useMemo(() => {\n if (accessibilityHint) {\n return accessibilityHint;\n }\n\n if (isLoading) {\n return 'Button is currently loading, please wait';\n }\n\n return undefined;\n }, [accessibilityHint, isLoading]);\n\n // Create accessibilityState object with only truthy values\n const accessibilityState = useMemo(() => {\n const state: { disabled?: boolean; busy?: boolean } = {};\n\n if (isDisabled || isLoading) {\n state.disabled = true;\n }\n\n if (isLoading) {\n state.busy = true;\n }\n\n return state;\n }, [isDisabled, isLoading]);\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole={accessibilityRole}\n accessibilityLabel={finalAccessibilityLabel}\n accessibilityHint={finalAccessibilityHint}\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={onAccessibilityAction}\n accessibilityState={accessibilityState}\n accessible\n style={({ pressed }) => {\n const containerClassName =\n typeof twClassName === 'function'\n ? twClassName(pressed)\n : twClassName;\n\n const baseContainerClassNames = `\n flex-row items-center justify-center rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden\n ${TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size]}\n ${isDisabled ? 'opacity-50' : 'opacity-100'}\n ${isFullWidth ? 'w-full' : 'w-auto'}\n ${containerClassName}\n `;\n\n const computedStyle: StyleProp<ViewStyle>[] = [\n tw`${baseContainerClassNames}`,\n ];\n if (typeof style === 'function') {\n const additionalStyle = style({ pressed });\n if (additionalStyle) {\n computedStyle.push(additionalStyle);\n }\n } else if (style) {\n computedStyle.push(style);\n }\n\n return computedStyle;\n }}\n {...props}\n >\n {({ pressed }) => (\n <>\n <View\n style={tw`absolute inset-0 flex items-center justify-center ${\n isLoading ? 'opacity-100' : 'opacity-0'\n }`}\n testID=\"spinner-container\"\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n loadingTextProps={{\n numberOfLines: 1,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n {...spinnerProps}\n />\n </View>\n <View\n style={tw`flex-row items-center justify-center gap-x-2 ${\n isLoading ? 'opacity-0' : 'opacity-100'\n }`}\n testID=\"content-container\"\n >\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...startIconProps}\n />\n ) : (\n startAccessory\n )}\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: `shrink grow-0 flex-wrap text-center ${textClassName ? textClassName(pressed) : ''}`,\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...endIconProps}\n />\n ) : (\n endAccessory\n )}\n </View>\n </>\n )}\n </ButtonAnimated>\n );\n};\n"]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = void 0;
4
+ const types_1 = require("../../types/index.cjs");
5
+ exports.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = {
6
+ [types_1.ButtonBaseSize.Sm]: 'h-8',
7
+ [types_1.ButtonBaseSize.Md]: 'h-10',
8
+ [types_1.ButtonBaseSize.Lg]: 'h-12', // size (48px).
9
+ };
10
+ //# sourceMappingURL=ButtonBase.constants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonBase.constants.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAEhC,QAAA,oCAAoC,GAG7C;IACF,CAAC,sBAAc,CAAC,EAAE,CAAC,EAAE,KAAK;IAC1B,CAAC,sBAAc,CAAC,EAAE,CAAC,EAAE,MAAM;IAC3B,CAAC,sBAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe;CAC7C,CAAC","sourcesContent":["import { ButtonBaseSize } from '../../types';\n\nexport const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'h-8', // size (32px).\n [ButtonBaseSize.Md]: 'h-10', // size (40px).\n [ButtonBaseSize.Lg]: 'h-12', // size (48px).\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { ButtonBaseSize } from "../../types/index.cjs";
2
+ export declare const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<ButtonBaseSize, string>;
3
+ //# sourceMappingURL=ButtonBase.constants.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonBase.constants.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAE7C,eAAO,MAAM,oCAAoC,EAAE,MAAM,CACvD,cAAc,EACd,MAAM,CAKP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ButtonBaseSize } from "../../types/index.mjs";
2
+ export declare const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<ButtonBaseSize, string>;
3
+ //# sourceMappingURL=ButtonBase.constants.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonBase.constants.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAE7C,eAAO,MAAM,oCAAoC,EAAE,MAAM,CACvD,cAAc,EACd,MAAM,CAKP,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ButtonBaseSize } from "../../types/index.mjs";
2
+ export const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = {
3
+ [ButtonBaseSize.Sm]: 'h-8',
4
+ [ButtonBaseSize.Md]: 'h-10',
5
+ [ButtonBaseSize.Lg]: 'h-12', // size (48px).
6
+ };
7
+ //# sourceMappingURL=ButtonBase.constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonBase.constants.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAE7C,MAAM,CAAC,MAAM,oCAAoC,GAG7C;IACF,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,KAAK;IAC1B,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM;IAC3B,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe;CAC7C,CAAC","sourcesContent":["import { ButtonBaseSize } from '../../types';\n\nexport const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'h-8', // size (32px).\n [ButtonBaseSize.Md]: 'h-10', // size (40px).\n [ButtonBaseSize.Lg]: 'h-12', // size (48px).\n};\n"]}
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { ButtonBaseProps } from "./ButtonBase.types.cjs";
3
- export declare const ButtonBase: ({ children, textProps, size, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, style, ...props }: ButtonBaseProps) => React.JSX.Element;
3
+ export declare const ButtonBase: ({ children, textProps, size, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityActions, onAccessibilityAction, ...props }: ButtonBaseProps) => React.JSX.Element;
4
4
  //# sourceMappingURL=ButtonBase.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,uNAkBpB,eAAe,sBA0EjB,CAAC"}
1
+ {"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAavC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,sBA8JjB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { ButtonBaseProps } from "./ButtonBase.types.mjs";
3
- export declare const ButtonBase: ({ children, textProps, size, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, style, ...props }: ButtonBaseProps) => React.JSX.Element;
3
+ export declare const ButtonBase: ({ children, textProps, size, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityActions, onAccessibilityAction, ...props }: ButtonBaseProps) => React.JSX.Element;
4
4
  //# sourceMappingURL=ButtonBase.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,uNAkBpB,eAAe,sBA0EjB,CAAC"}
1
+ {"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAavC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,sBA8JjB,CAAC"}
@@ -5,7 +5,7 @@ function $importDefault(module) {
5
5
  return module;
6
6
  }
7
7
  import { useTailwind } from "@metamask-previews/design-system-twrnc-preset";
8
- import $React from "react";
8
+ import $React, { useMemo } from "react";
9
9
  const React = $importDefault($React);
10
10
  import { View } from "react-native/index.js";
11
11
  import { ButtonBaseSize } from "../../types/index.mjs";
@@ -15,34 +15,96 @@ import { ButtonAnimated } from "../temp-components/ButtonAnimated/index.mjs";
15
15
  import { Spinner } from "../temp-components/Spinner/index.mjs";
16
16
  import { TextOrChildren } from "../temp-components/TextOrChildren/TextOrChildren.mjs";
17
17
  import { TextVariant, FontWeight, TextColor } from "../Text/index.mjs";
18
- export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName = '', style, ...props }) => {
18
+ import { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from "./ButtonBase.constants.mjs";
19
+ export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName = '', textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole = 'button', accessibilityActions, onAccessibilityAction, ...props }) => {
19
20
  const tw = useTailwind();
20
- const twContainerClassNames = `
21
- flex-row items-center justify-center rounded-full bg-muted px-4 min-w-[80px] overflow-hidden
22
- h-[${size}px]
23
- ${isDisabled ? 'opacity-50' : 'opacity-100'}
24
- ${isFullWidth ? 'self-stretch' : 'self-start'}
25
- ${twClassName}
26
- `;
27
21
  const finalStartIconName = startIconName ?? startIconProps?.name;
28
22
  const finalEndIconName = endIconName ?? endIconProps?.name;
29
- return (<ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole="button" accessible style={[tw `${twContainerClassNames}`, style]} {...props}>
30
- <View style={tw `absolute inset-0 flex items-center justify-center ${isLoading ? 'opacity-100' : 'opacity-0'}`} testID="spinner-container">
31
- <Spinner color={IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{ numberOfLines: 1 }} {...spinnerProps}/>
32
- </View>
33
- <View style={tw `flex-row items-center justify-center gap-x-2 ${isLoading ? 'opacity-0' : 'opacity-100'}`} testID="content-container">
34
- {finalStartIconName ? (<Icon name={finalStartIconName} size={IconSize.Sm} twClassName="shrink-0" {...startIconProps}/>) : (startAccessory)}
35
- <TextOrChildren textProps={{
36
- variant: TextVariant.BodyMd,
37
- fontWeight: FontWeight.Medium,
38
- color: TextColor.TextDefault,
39
- twClassName: 'shrink grow-0 flex-wrap text-center',
40
- ...textProps,
41
- }}>
42
- {children}
43
- </TextOrChildren>
44
- {finalEndIconName ? (<Icon name={finalEndIconName} size={IconSize.Sm} twClassName="shrink-0" {...endIconProps}/>) : (endAccessory)}
45
- </View>
23
+ // Generate accessibility label if not provided
24
+ const finalAccessibilityLabel = useMemo(() => {
25
+ if (accessibilityLabel) {
26
+ return accessibilityLabel;
27
+ }
28
+ // For loading state with loadingText, prioritize loadingText
29
+ if (isLoading && loadingText) {
30
+ return loadingText;
31
+ }
32
+ // If children is a string, use it as the label
33
+ if (typeof children === 'string') {
34
+ return children;
35
+ }
36
+ return undefined;
37
+ }, [accessibilityLabel, children, isLoading, loadingText]);
38
+ // Generate accessibility hint for loading state if not provided
39
+ const finalAccessibilityHint = useMemo(() => {
40
+ if (accessibilityHint) {
41
+ return accessibilityHint;
42
+ }
43
+ if (isLoading) {
44
+ return 'Button is currently loading, please wait';
45
+ }
46
+ return undefined;
47
+ }, [accessibilityHint, isLoading]);
48
+ // Create accessibilityState object with only truthy values
49
+ const accessibilityState = useMemo(() => {
50
+ const state = {};
51
+ if (isDisabled || isLoading) {
52
+ state.disabled = true;
53
+ }
54
+ if (isLoading) {
55
+ state.busy = true;
56
+ }
57
+ return state;
58
+ }, [isDisabled, isLoading]);
59
+ return (<ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole={accessibilityRole} accessibilityLabel={finalAccessibilityLabel} accessibilityHint={finalAccessibilityHint} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} accessibilityState={accessibilityState} accessible style={({ pressed }) => {
60
+ const containerClassName = typeof twClassName === 'function'
61
+ ? twClassName(pressed)
62
+ : twClassName;
63
+ const baseContainerClassNames = `
64
+ flex-row items-center justify-center rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden
65
+ ${TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size]}
66
+ ${isDisabled ? 'opacity-50' : 'opacity-100'}
67
+ ${isFullWidth ? 'w-full' : 'w-auto'}
68
+ ${containerClassName}
69
+ `;
70
+ const computedStyle = [
71
+ tw `${baseContainerClassNames}`,
72
+ ];
73
+ if (typeof style === 'function') {
74
+ const additionalStyle = style({ pressed });
75
+ if (additionalStyle) {
76
+ computedStyle.push(additionalStyle);
77
+ }
78
+ }
79
+ else if (style) {
80
+ computedStyle.push(style);
81
+ }
82
+ return computedStyle;
83
+ }} {...props}>
84
+ {({ pressed }) => (<>
85
+ <View style={tw `absolute inset-0 flex items-center justify-center ${isLoading ? 'opacity-100' : 'opacity-0'}`} testID="spinner-container">
86
+ <Spinner color={textClassName
87
+ ? textClassName(pressed)
88
+ : IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{
89
+ numberOfLines: 1,
90
+ twClassName: textClassName ? textClassName(pressed) : '',
91
+ ...spinnerProps?.loadingTextProps,
92
+ }} {...spinnerProps}/>
93
+ </View>
94
+ <View style={tw `flex-row items-center justify-center gap-x-2 ${isLoading ? 'opacity-0' : 'opacity-100'}`} testID="content-container">
95
+ {finalStartIconName ? (<Icon name={finalStartIconName} size={IconSize.Sm} twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`} {...startIconProps}/>) : (startAccessory)}
96
+ <TextOrChildren textProps={{
97
+ variant: TextVariant.BodyMd,
98
+ fontWeight: FontWeight.Medium,
99
+ color: TextColor.TextDefault,
100
+ twClassName: `shrink grow-0 flex-wrap text-center ${textClassName ? textClassName(pressed) : ''}`,
101
+ ...textProps,
102
+ }}>
103
+ {children}
104
+ </TextOrChildren>
105
+ {finalEndIconName ? (<Icon name={finalEndIconName} size={IconSize.Sm} twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`} {...endIconProps}/>) : (endAccessory)}
106
+ </View>
107
+ </>)}
46
108
  </ButtonAnimated>);
47
109
  };
48
110
  //# sourceMappingURL=ButtonBase.mjs.map