@metamask-previews/design-system-react-native 0.0.0-preview.bf69b6b → 0.0.0-preview.fbd1fe9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/Button.constants.d.ts +2 -0
- package/dist/components/Button/Button.constants.d.ts.map +1 -0
- package/dist/components/Button/Button.constants.js +7 -0
- package/dist/components/Button/Button.constants.js.map +1 -0
- package/dist/components/Button/Button.d.ts +5 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +25 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.types.d.ts +23 -0
- package/dist/components/Button/Button.types.d.ts.map +1 -0
- package/dist/components/Button/Button.types.js +15 -0
- package/dist/components/Button/Button.types.js.map +1 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.d.ts.map +1 -0
- package/dist/components/Button/index.js +12 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.js +97 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.js +3 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.d.ts +78 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.js +122 -0
- package/dist/components/Button/variants/ButtonPrimary/ButtonPrimary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonPrimary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonPrimary/index.js +11 -0
- package/dist/components/Button/variants/ButtonPrimary/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.js +90 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.js +3 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.d.ts +90 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.js +145 -0
- package/dist/components/Button/variants/ButtonSecondary/ButtonSecondary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonSecondary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonSecondary/index.js +11 -0
- package/dist/components/Button/variants/ButtonSecondary/index.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.d.ts +3 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.js +29 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.constants.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.ts +5 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.js +90 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.d.ts +17 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.js +3 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.types.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.d.ts +88 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.js +147 -0
- package/dist/components/Button/variants/ButtonTertiary/ButtonTertiary.utilities.js.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/index.d.ts +4 -0
- package/dist/components/Button/variants/ButtonTertiary/index.d.ts.map +1 -0
- package/dist/components/Button/variants/ButtonTertiary/index.js +11 -0
- package/dist/components/Button/variants/ButtonTertiary/index.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.d.ts +6 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.js +20 -0
- package/dist/components/ButtonIcon/ButtonIcon.constants.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.d.ts +5 -0
- package/dist/components/ButtonIcon/ButtonIcon.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.js +72 -0
- package/dist/components/ButtonIcon/ButtonIcon.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.d.ts +60 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.js +19 -0
- package/dist/components/ButtonIcon/ButtonIcon.types.js.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.d.ts +55 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.d.ts.map +1 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.js +73 -0
- package/dist/components/ButtonIcon/ButtonIcon.utilities.js.map +1 -0
- package/dist/components/ButtonIcon/index.d.ts +4 -0
- package/dist/components/ButtonIcon/index.d.ts.map +1 -0
- package/dist/components/ButtonIcon/index.js +11 -0
- package/dist/components/ButtonIcon/index.js.map +1 -0
- package/dist/components/Icon/Icon.assets.d.ts.map +1 -0
- package/dist/components/Icon/Icon.assets.js.map +1 -0
- package/dist/components/{Icons/Icon → Icon}/Icon.constants.d.ts +0 -2
- package/dist/components/Icon/Icon.constants.d.ts.map +1 -0
- package/dist/components/Icon/Icon.constants.js +15 -0
- package/dist/components/Icon/Icon.constants.js.map +1 -0
- package/dist/components/Icon/Icon.d.ts +5 -0
- package/dist/components/Icon/Icon.d.ts.map +1 -0
- package/dist/components/{Icons/Icon → Icon}/Icon.js +10 -6
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/{Icons/Icon → Icon}/Icon.types.d.ts +42 -30
- package/dist/components/Icon/Icon.types.d.ts.map +1 -0
- package/dist/components/{Icons/Icon → Icon}/Icon.types.js +42 -30
- package/dist/components/Icon/Icon.types.js.map +1 -0
- package/dist/components/Icon/Icon.utilities.d.ts.map +1 -0
- package/dist/components/{Icons/Icon → Icon}/Icon.utilities.js +1 -1
- package/dist/components/Icon/Icon.utilities.js.map +1 -0
- package/dist/components/Icon/index.d.ts.map +1 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/Text/Text.d.ts +3 -10
- package/dist/components/Text/Text.d.ts.map +1 -1
- package/dist/components/Text/Text.js +1 -1
- package/dist/components/Text/Text.js.map +1 -1
- package/dist/components/Text/Text.types.d.ts +39 -29
- package/dist/components/Text/Text.types.d.ts.map +1 -1
- package/dist/components/Text/Text.types.js +39 -29
- package/dist/components/Text/Text.types.js.map +1 -1
- package/dist/components/Text/Text.utilities.js +1 -1
- package/dist/components/Text/Text.utilities.js.map +1 -1
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/Text/index.d.ts.map +1 -1
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/TextButton/TextButton.constants.d.ts +3 -0
- package/dist/components/TextButton/TextButton.constants.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.constants.js +29 -0
- package/dist/components/TextButton/TextButton.constants.js.map +1 -0
- package/dist/components/TextButton/TextButton.d.ts +5 -0
- package/dist/components/TextButton/TextButton.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.js +187 -0
- package/dist/components/TextButton/TextButton.js.map +1 -0
- package/dist/components/TextButton/TextButton.types.d.ts +73 -0
- package/dist/components/TextButton/TextButton.types.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.types.js +3 -0
- package/dist/components/TextButton/TextButton.types.js.map +1 -0
- package/dist/components/TextButton/TextButton.utilities.d.ts +55 -0
- package/dist/components/TextButton/TextButton.utilities.d.ts.map +1 -0
- package/dist/components/TextButton/TextButton.utilities.js +77 -0
- package/dist/components/TextButton/TextButton.utilities.js.map +1 -0
- package/dist/components/TextButton/index.d.ts +3 -0
- package/dist/components/TextButton/index.d.ts.map +1 -0
- package/dist/components/TextButton/index.js +9 -0
- package/dist/components/TextButton/index.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/primitives/ButtonAnimated/ButtonAnimated.d.ts +5 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.js +58 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.js.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.d.ts +6 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.js +3 -0
- package/dist/primitives/ButtonAnimated/ButtonAnimated.types.js.map +1 -0
- package/dist/primitives/ButtonAnimated/index.d.ts +2 -0
- package/dist/primitives/ButtonAnimated/index.d.ts.map +1 -0
- package/dist/primitives/ButtonAnimated/index.js +9 -0
- package/dist/primitives/ButtonAnimated/index.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.d.ts +3 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.js +32 -0
- package/dist/primitives/ButtonBase/ButtonBase.constants.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.d.ts +5 -0
- package/dist/primitives/ButtonBase/ButtonBase.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.js +84 -0
- package/dist/primitives/ButtonBase/ButtonBase.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.d.ts +93 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.js +19 -0
- package/dist/primitives/ButtonBase/ButtonBase.types.js.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.d.ts +28 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.js +41 -0
- package/dist/primitives/ButtonBase/ButtonBase.utilities.js.map +1 -0
- package/dist/primitives/ButtonBase/index.d.ts +4 -0
- package/dist/primitives/ButtonBase/index.d.ts.map +1 -0
- package/dist/primitives/ButtonBase/index.js +11 -0
- package/dist/primitives/ButtonBase/index.js.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.d.ts +5 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.d.ts.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.js +15 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.js.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.d.ts +15 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.d.ts.map +1 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.js +3 -0
- package/dist/primitives/TextOrChildren/TextOrChildren.types.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.constants.d.ts +3 -0
- package/dist/temp-components/Spinner/Spinner.constants.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.constants.js +21 -0
- package/dist/temp-components/Spinner/Spinner.constants.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.d.ts +5 -0
- package/dist/temp-components/Spinner/Spinner.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.js +68 -0
- package/dist/temp-components/Spinner/Spinner.js.map +1 -0
- package/dist/temp-components/Spinner/Spinner.types.d.ts +30 -0
- package/dist/temp-components/Spinner/Spinner.types.d.ts.map +1 -0
- package/dist/temp-components/Spinner/Spinner.types.js +3 -0
- package/dist/temp-components/Spinner/Spinner.types.js.map +1 -0
- package/dist/temp-components/Spinner/index.d.ts +3 -0
- package/dist/temp-components/Spinner/index.d.ts.map +1 -0
- package/dist/temp-components/Spinner/index.js +9 -0
- package/dist/temp-components/Spinner/index.js.map +1 -0
- package/package.json +5 -4
- package/dist/components/Icons/Icon/Icon.assets.d.ts.map +0 -1
- package/dist/components/Icons/Icon/Icon.assets.js.map +0 -1
- package/dist/components/Icons/Icon/Icon.constants.d.ts.map +0 -1
- package/dist/components/Icons/Icon/Icon.constants.js +0 -39
- package/dist/components/Icons/Icon/Icon.constants.js.map +0 -1
- package/dist/components/Icons/Icon/Icon.d.ts +0 -9
- package/dist/components/Icons/Icon/Icon.d.ts.map +0 -1
- package/dist/components/Icons/Icon/Icon.js.map +0 -1
- package/dist/components/Icons/Icon/Icon.types.d.ts.map +0 -1
- package/dist/components/Icons/Icon/Icon.types.js.map +0 -1
- package/dist/components/Icons/Icon/Icon.utilities.d.ts.map +0 -1
- package/dist/components/Icons/Icon/Icon.utilities.js.map +0 -1
- package/dist/components/Icons/Icon/index.d.ts.map +0 -1
- package/dist/components/Icons/Icon/index.js.map +0 -1
- /package/dist/components/{Icons/Icon → Icon}/Icon.assets.d.ts +0 -0
- /package/dist/components/{Icons/Icon → Icon}/Icon.assets.js +0 -0
- /package/dist/components/{Icons/Icon → Icon}/Icon.utilities.d.ts +0 -0
- /package/dist/components/{Icons/Icon → Icon}/index.d.ts +0 -0
- /package/dist/components/{Icons/Icon → Icon}/index.js +0 -0
|
@@ -17,37 +17,47 @@ export declare enum TextVariant {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare enum TextColor {
|
|
19
19
|
/** For default neutral text. */
|
|
20
|
-
TextDefault = "text-default",
|
|
20
|
+
TextDefault = "text-text-default",
|
|
21
21
|
/** For softer contrast neutral text */
|
|
22
|
-
TextAlternative = "text-alternative",
|
|
22
|
+
TextAlternative = "text-text-alternative",
|
|
23
23
|
/** For the softest contrast neutral text (not accessible) */
|
|
24
|
-
TextMuted = "text-muted",
|
|
25
|
-
/** For elements used on top of overlay/alternative.
|
|
26
|
-
OverlayInverse = "overlay-inverse",
|
|
27
|
-
/** For interactive, active, and selected semantics.
|
|
28
|
-
PrimaryDefault = "primary-default",
|
|
29
|
-
/** For
|
|
30
|
-
|
|
31
|
-
/** For
|
|
32
|
-
|
|
33
|
-
/** For
|
|
34
|
-
|
|
35
|
-
/** For
|
|
36
|
-
|
|
37
|
-
/** For
|
|
38
|
-
|
|
39
|
-
/** For elements used on top of
|
|
40
|
-
|
|
41
|
-
/** For
|
|
42
|
-
|
|
43
|
-
/** For
|
|
44
|
-
|
|
45
|
-
/** For
|
|
46
|
-
|
|
47
|
-
/** For
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
|
|
24
|
+
TextMuted = "text-text-muted",
|
|
25
|
+
/** For elements used on top of overlay/alternative. */
|
|
26
|
+
OverlayInverse = "text-overlay-inverse",
|
|
27
|
+
/** For interactive, active, and selected semantics. */
|
|
28
|
+
PrimaryDefault = "text-primary-default",
|
|
29
|
+
/** For softer variants of primary text. */
|
|
30
|
+
PrimaryAlternative = "text-primary-alternative",
|
|
31
|
+
/** For elements used on top of primary/default. */
|
|
32
|
+
PrimaryInverse = "text-primary-inverse",
|
|
33
|
+
/** For primary text in a pressed state. */
|
|
34
|
+
PrimaryDefaultPressed = "text-primary-defaultPressed",
|
|
35
|
+
/** For critical alert text. */
|
|
36
|
+
ErrorDefault = "text-error-default",
|
|
37
|
+
/** For stronger contrast error text. */
|
|
38
|
+
ErrorAlternative = "text-error-alternative",
|
|
39
|
+
/** For elements used on top of error/default. */
|
|
40
|
+
ErrorInverse = "text-error-inverse",
|
|
41
|
+
/** For critical alert text in a pressed state. */
|
|
42
|
+
ErrorDefaultPressed = "text-error-defaultPressed",
|
|
43
|
+
/** For caution alert text. */
|
|
44
|
+
WarningDefault = "text-warning-default",
|
|
45
|
+
/** For elements used on top of warning/default. */
|
|
46
|
+
WarningInverse = "text-warning-inverse",
|
|
47
|
+
/** For caution text in a pressed state. */
|
|
48
|
+
WarningDefaultPressed = "text-warning-defaultPressed",
|
|
49
|
+
/** For positive semantic text. */
|
|
50
|
+
SuccessDefault = "text-success-default",
|
|
51
|
+
/** For elements used on top of success/default. */
|
|
52
|
+
SuccessInverse = "text-success-inverse",
|
|
53
|
+
/** For positive text in a pressed state. */
|
|
54
|
+
SuccessDefaultPressed = "text-success-defaultPressed",
|
|
55
|
+
/** For informational read-only text. */
|
|
56
|
+
InfoDefault = "text-info-default",
|
|
57
|
+
/** For elements used on top of info/default. */
|
|
58
|
+
InfoInverse = "text-info-inverse",
|
|
59
|
+
/** Make the text color transparent. */
|
|
60
|
+
Transparent = "text-transparent"
|
|
51
61
|
}
|
|
52
62
|
export declare enum FontWeight {
|
|
53
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.types.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AACH,oBAAY,WAAW;IAErB,SAAS,eAAe;IAGxB,SAAS,eAAe;IACxB,SAAS,eAAe;IACxB,SAAS,eAAe;IAGxB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;CACnB;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,gCAAgC;IAChC,WAAW,
|
|
1
|
+
{"version":3,"file":"Text.types.d.ts","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D;;GAEG;AACH,oBAAY,WAAW;IAErB,SAAS,eAAe;IAGxB,SAAS,eAAe;IACxB,SAAS,eAAe;IACxB,SAAS,eAAe;IAGxB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;CACnB;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,gCAAgC;IAChC,WAAW,sBAAsB;IACjC,uCAAuC;IACvC,eAAe,0BAA0B;IACzC,6DAA6D;IAC7D,SAAS,oBAAoB;IAC7B,uDAAuD;IACvD,cAAc,yBAAyB;IACvC,uDAAuD;IACvD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,kBAAkB,6BAA6B;IAC/C,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,qBAAqB,gCAAgC;IACrD,+BAA+B;IAC/B,YAAY,uBAAuB;IACnC,wCAAwC;IACxC,gBAAgB,2BAA2B;IAC3C,iDAAiD;IACjD,YAAY,uBAAuB;IACnC,kDAAkD;IAClD,mBAAmB,8BAA8B;IACjD,8BAA8B;IAC9B,cAAc,yBAAyB;IACvC,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,2CAA2C;IAC3C,qBAAqB,gCAAgC;IACrD,kCAAkC;IAClC,cAAc,yBAAyB;IACvC,mDAAmD;IACnD,cAAc,yBAAyB;IACvC,4CAA4C;IAC5C,qBAAqB,gCAAgC;IACrD,wCAAwC;IACxC,WAAW,sBAAsB;IACjC,gDAAgD;IAChD,WAAW,sBAAsB;IACjC,uCAAuC;IACvC,WAAW,qBAAqB;CACjC;AAED,oBAAY,UAAU;IACpB;;OAEG;IACH,IAAI,QAAQ;IACZ;;OAEG;IACH,MAAM,QAAQ;IACd;;OAEG;IACH,MAAM,QAAQ;CACf;AAED,oBAAY,SAAS;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AACD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,CAAC"}
|
|
@@ -24,37 +24,47 @@ var TextVariant;
|
|
|
24
24
|
var TextColor;
|
|
25
25
|
(function (TextColor) {
|
|
26
26
|
/** For default neutral text. */
|
|
27
|
-
TextColor["TextDefault"] = "text-default";
|
|
27
|
+
TextColor["TextDefault"] = "text-text-default";
|
|
28
28
|
/** For softer contrast neutral text */
|
|
29
|
-
TextColor["TextAlternative"] = "text-alternative";
|
|
29
|
+
TextColor["TextAlternative"] = "text-text-alternative";
|
|
30
30
|
/** For the softest contrast neutral text (not accessible) */
|
|
31
|
-
TextColor["TextMuted"] = "text-muted";
|
|
32
|
-
/** For elements used on top of overlay/alternative.
|
|
33
|
-
TextColor["OverlayInverse"] = "overlay-inverse";
|
|
34
|
-
/** For interactive, active, and selected semantics.
|
|
35
|
-
TextColor["PrimaryDefault"] = "primary-default";
|
|
36
|
-
/** For
|
|
37
|
-
TextColor["
|
|
38
|
-
/** For
|
|
39
|
-
TextColor["
|
|
40
|
-
/** For
|
|
41
|
-
TextColor["
|
|
42
|
-
/** For
|
|
43
|
-
TextColor["
|
|
44
|
-
/** For
|
|
45
|
-
TextColor["
|
|
46
|
-
/** For elements used on top of
|
|
47
|
-
TextColor["
|
|
48
|
-
/** For
|
|
49
|
-
TextColor["
|
|
50
|
-
/** For
|
|
51
|
-
TextColor["
|
|
52
|
-
/** For
|
|
53
|
-
TextColor["
|
|
54
|
-
/** For
|
|
55
|
-
TextColor["
|
|
56
|
-
/**
|
|
57
|
-
TextColor["
|
|
31
|
+
TextColor["TextMuted"] = "text-text-muted";
|
|
32
|
+
/** For elements used on top of overlay/alternative. */
|
|
33
|
+
TextColor["OverlayInverse"] = "text-overlay-inverse";
|
|
34
|
+
/** For interactive, active, and selected semantics. */
|
|
35
|
+
TextColor["PrimaryDefault"] = "text-primary-default";
|
|
36
|
+
/** For softer variants of primary text. */
|
|
37
|
+
TextColor["PrimaryAlternative"] = "text-primary-alternative";
|
|
38
|
+
/** For elements used on top of primary/default. */
|
|
39
|
+
TextColor["PrimaryInverse"] = "text-primary-inverse";
|
|
40
|
+
/** For primary text in a pressed state. */
|
|
41
|
+
TextColor["PrimaryDefaultPressed"] = "text-primary-defaultPressed";
|
|
42
|
+
/** For critical alert text. */
|
|
43
|
+
TextColor["ErrorDefault"] = "text-error-default";
|
|
44
|
+
/** For stronger contrast error text. */
|
|
45
|
+
TextColor["ErrorAlternative"] = "text-error-alternative";
|
|
46
|
+
/** For elements used on top of error/default. */
|
|
47
|
+
TextColor["ErrorInverse"] = "text-error-inverse";
|
|
48
|
+
/** For critical alert text in a pressed state. */
|
|
49
|
+
TextColor["ErrorDefaultPressed"] = "text-error-defaultPressed";
|
|
50
|
+
/** For caution alert text. */
|
|
51
|
+
TextColor["WarningDefault"] = "text-warning-default";
|
|
52
|
+
/** For elements used on top of warning/default. */
|
|
53
|
+
TextColor["WarningInverse"] = "text-warning-inverse";
|
|
54
|
+
/** For caution text in a pressed state. */
|
|
55
|
+
TextColor["WarningDefaultPressed"] = "text-warning-defaultPressed";
|
|
56
|
+
/** For positive semantic text. */
|
|
57
|
+
TextColor["SuccessDefault"] = "text-success-default";
|
|
58
|
+
/** For elements used on top of success/default. */
|
|
59
|
+
TextColor["SuccessInverse"] = "text-success-inverse";
|
|
60
|
+
/** For positive text in a pressed state. */
|
|
61
|
+
TextColor["SuccessDefaultPressed"] = "text-success-defaultPressed";
|
|
62
|
+
/** For informational read-only text. */
|
|
63
|
+
TextColor["InfoDefault"] = "text-info-default";
|
|
64
|
+
/** For elements used on top of info/default. */
|
|
65
|
+
TextColor["InfoInverse"] = "text-info-inverse";
|
|
66
|
+
/** Make the text color transparent. */
|
|
67
|
+
TextColor["Transparent"] = "text-transparent";
|
|
58
68
|
})(TextColor || (exports.TextColor = TextColor = {}));
|
|
59
69
|
var FontWeight;
|
|
60
70
|
(function (FontWeight) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.types.js","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,WAcX;AAdD,WAAY,WAAW;IACrB,gBAAgB;IAChB,uCAAwB,CAAA;IAExB,gBAAgB;IAChB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IAExB,aAAa;IACb,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACpB,CAAC,EAdW,WAAW,2BAAX,WAAW,QActB;AAED;;GAEG;AACH,IAAY,
|
|
1
|
+
{"version":3,"file":"Text.types.js","sourceRoot":"","sources":["../../../src/components/Text/Text.types.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,WAcX;AAdD,WAAY,WAAW;IACrB,gBAAgB;IAChB,uCAAwB,CAAA;IAExB,gBAAgB;IAChB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IACxB,uCAAwB,CAAA;IAExB,aAAa;IACb,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACpB,CAAC,EAdW,WAAW,2BAAX,WAAW,QActB;AAED;;GAEG;AACH,IAAY,SA2CX;AA3CD,WAAY,SAAS;IACnB,gCAAgC;IAChC,8CAAiC,CAAA;IACjC,uCAAuC;IACvC,sDAAyC,CAAA;IACzC,6DAA6D;IAC7D,0CAA6B,CAAA;IAC7B,uDAAuD;IACvD,oDAAuC,CAAA;IACvC,uDAAuD;IACvD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,4DAA+C,CAAA;IAC/C,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,kEAAqD,CAAA;IACrD,+BAA+B;IAC/B,gDAAmC,CAAA;IACnC,wCAAwC;IACxC,wDAA2C,CAAA;IAC3C,iDAAiD;IACjD,gDAAmC,CAAA;IACnC,kDAAkD;IAClD,8DAAiD,CAAA;IACjD,8BAA8B;IAC9B,oDAAuC,CAAA;IACvC,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,2CAA2C;IAC3C,kEAAqD,CAAA;IACrD,kCAAkC;IAClC,oDAAuC,CAAA;IACvC,mDAAmD;IACnD,oDAAuC,CAAA;IACvC,4CAA4C;IAC5C,kEAAqD,CAAA;IACrD,wCAAwC;IACxC,8CAAiC,CAAA;IACjC,gDAAgD;IAChD,8CAAiC,CAAA;IACjC,uCAAuC;IACvC,6CAAgC,CAAA;AAClC,CAAC,EA3CW,SAAS,yBAAT,SAAS,QA2CpB;AAED,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB;;OAEG;IACH,0BAAY,CAAA;IACZ;;OAEG;IACH,4BAAc,CAAA;IACd;;OAEG;IACH,4BAAc,CAAA;AAChB,CAAC,EAbW,UAAU,0BAAV,UAAU,QAarB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACnB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB","sourcesContent":["/* eslint-disable @typescript-eslint/no-shadow */\n// Third party dependencies.\nimport type { TextProps as RNTextProps } from 'react-native';\n\n/**\n * Text component variants.\n */\nexport enum TextVariant {\n // Display Sizes\n DisplayMd = 'display-md',\n\n // Heading Sizes\n HeadingLg = 'heading-lg',\n HeadingMd = 'heading-md',\n HeadingSm = 'heading-sm',\n\n // Body Sizes\n BodyLg = 'body-lg',\n BodyMd = 'body-md',\n BodySm = 'body-sm',\n BodyXs = 'body-xs',\n}\n\n/**\n * Text colors\n */\nexport enum TextColor {\n /** For default neutral text. */\n TextDefault = 'text-text-default',\n /** For softer contrast neutral text */\n TextAlternative = 'text-text-alternative',\n /** For the softest contrast neutral text (not accessible) */\n TextMuted = 'text-text-muted',\n /** For elements used on top of overlay/alternative. */\n OverlayInverse = 'text-overlay-inverse',\n /** For interactive, active, and selected semantics. */\n PrimaryDefault = 'text-primary-default',\n /** For softer variants of primary text. */\n PrimaryAlternative = 'text-primary-alternative',\n /** For elements used on top of primary/default. */\n PrimaryInverse = 'text-primary-inverse',\n /** For primary text in a pressed state. */\n PrimaryDefaultPressed = 'text-primary-defaultPressed',\n /** For critical alert text. */\n ErrorDefault = 'text-error-default',\n /** For stronger contrast error text. */\n ErrorAlternative = 'text-error-alternative',\n /** For elements used on top of error/default. */\n ErrorInverse = 'text-error-inverse',\n /** For critical alert text in a pressed state. */\n ErrorDefaultPressed = 'text-error-defaultPressed',\n /** For caution alert text. */\n WarningDefault = 'text-warning-default',\n /** For elements used on top of warning/default. */\n WarningInverse = 'text-warning-inverse',\n /** For caution text in a pressed state. */\n WarningDefaultPressed = 'text-warning-defaultPressed',\n /** For positive semantic text. */\n SuccessDefault = 'text-success-default',\n /** For elements used on top of success/default. */\n SuccessInverse = 'text-success-inverse',\n /** For positive text in a pressed state. */\n SuccessDefaultPressed = 'text-success-defaultPressed',\n /** For informational read-only text. */\n InfoDefault = 'text-info-default',\n /** For elements used on top of info/default. */\n InfoInverse = 'text-info-inverse',\n /** Make the text color transparent. */\n Transparent = 'text-transparent',\n}\n\nexport enum FontWeight {\n /**\n * Weight - 700\n */\n Bold = '700',\n /**\n * Weight - 500\n */\n Medium = '500',\n /**\n * Weight - 400\n */\n Normal = '400',\n}\n\nexport enum FontStyle {\n Italic = 'italic',\n Normal = 'normal',\n}\n/**\n * Text component props.\n */\nexport type TextProps = {\n /**\n * Optional enum to select between Typography variants.\n * @default BodyMD\n */\n variant?: TextVariant;\n /**\n * Text to be displayed.\n */\n children: React.ReactNode;\n /**\n * Optional prop to add color to text.\n */\n color?: TextColor;\n /**\n * Optional prop to adjust the weight of the font.\n */\n fontWeight?: FontWeight;\n /**\n * Optional prop to adjust the style of the font.\n */\n fontStyle?: FontStyle;\n /**\n * Optional prop to add twrnc overriding classNames.\n */\n twClassName?: string;\n} & RNTextProps;\n"]}
|
|
@@ -37,7 +37,7 @@ const generateTextClassNames = ({ variant = Text_constants_1.DEFAULT_TEXT_VARIAN
|
|
|
37
37
|
const isItalic = fontStyle === Text_types_1.FontStyle.Italic;
|
|
38
38
|
const textClassname = `text-${variant}`;
|
|
39
39
|
const fontFamilyClassname = `font-${variant}${fontWeightStyleClassname}${isItalic ? '-italic' : ''}`;
|
|
40
|
-
const textColorClassname =
|
|
40
|
+
const textColorClassname = `${color}`;
|
|
41
41
|
const mergedClassnames = `${textClassname} ${fontFamilyClassname} ${textColorClassname} ${twClassName}`.trim();
|
|
42
42
|
return mergedClassnames;
|
|
43
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.utilities.js","sourceRoot":"","sources":["../../../src/components/Text/Text.utilities.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,wCAAwC;AACxC,qDAI0B;AAE1B,6CAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,OAAO,GAAG,qCAAoB,EAC9B,KAAK,GAAG,mCAAkB,EAC1B,UAAU,GAAG,uBAAU,CAAC,MAAM,EAC9B,SAAS,GAAG,sBAAS,CAAC,MAAM,EAC5B,WAAW,GAAG,EAAE,GACG,EAAU,EAAE;IAC/B,MAAM,wBAAwB,GAC5B,+DAA8C,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,SAAS,KAAK,sBAAS,CAAC,MAAM,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,OAAO,EAAE,CAAC;IACxC,MAAM,mBAAmB,GAAG,QAAQ,OAAO,GAAG,wBAAwB,GACpE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,EAAE,CAAC;IACH,MAAM,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"Text.utilities.js","sourceRoot":"","sources":["../../../src/components/Text/Text.utilities.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,wCAAwC;AACxC,qDAI0B;AAE1B,6CAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACI,MAAM,sBAAsB,GAAG,CAAC,EACrC,OAAO,GAAG,qCAAoB,EAC9B,KAAK,GAAG,mCAAkB,EAC1B,UAAU,GAAG,uBAAU,CAAC,MAAM,EAC9B,SAAS,GAAG,sBAAS,CAAC,MAAM,EAC5B,WAAW,GAAG,EAAE,GACG,EAAU,EAAE;IAC/B,MAAM,wBAAwB,GAC5B,+DAA8C,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,SAAS,KAAK,sBAAS,CAAC,MAAM,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,OAAO,EAAE,CAAC;IACxC,MAAM,mBAAmB,GAAG,QAAQ,OAAO,GAAG,wBAAwB,GACpE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,EAAE,CAAC;IACH,MAAM,kBAAkB,GAAG,GAAG,KAAK,EAAE,CAAC;IACtC,MAAM,gBAAgB,GACpB,GAAG,aAAa,IAAI,mBAAmB,IAAI,kBAAkB,IAAI,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAExF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAnBW,QAAA,sBAAsB,0BAmBjC","sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n/* eslint-disable jsdoc/require-param */\nimport {\n DEFAULT_TEXT_COLOR,\n DEFAULT_TEXT_VARIANT,\n MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME,\n} from './Text.constants';\nimport type { TextProps } from './Text.types';\nimport { FontWeight, FontStyle } from './Text.types';\n\n/**\n * Generates a combined string of Tailwind CSS class names for the Text component\n * based on the provided props. This utility simplifies the process of combining\n * typography, color, font weight, and style classes, ensuring consistency with the\n * design system.\n *\n * @param variant - Specifies the typography variant (e.g., body, heading, display).\n * @param color - Specifies the text color based on the design system's color tokens.\n * @param fontWeight - Specifies the font weight (e.g., normal, bold).\n * @param fontStyle - Specifies the font style (e.g., normal, italic).\n * @param twClassName - Additional custom Tailwind class names to be appended to the generated classes.\n * @returns A string of combined Tailwind CSS class names.\n *\n * Example:\n * ```\n * const classNames = generateTextClassNames({\n * variant: TextVariant.BodyMd,\n * color: TextColor.PrimaryDefault,\n * fontWeight: FontWeight.Bold,\n * fontStyle: FontStyle.Italic,\n * twClassName: 'text-center underline',\n * });\n *\n * console.log(classNames);\n * // Output: \"text-body-md font-body-md-bold-italic text-primary-default text-center underline\"\n * ```\n */\nexport const generateTextClassNames = ({\n variant = DEFAULT_TEXT_VARIANT,\n color = DEFAULT_TEXT_COLOR,\n fontWeight = FontWeight.Normal,\n fontStyle = FontStyle.Normal,\n twClassName = '',\n}: Partial<TextProps>): string => {\n const fontWeightStyleClassname =\n MAPPING_FONTWEIGHT_TO_FONTFAMILYSTYLECLASSNAME[fontWeight];\n const isItalic = fontStyle === FontStyle.Italic;\n const textClassname = `text-${variant}`;\n const fontFamilyClassname = `font-${variant}${fontWeightStyleClassname}${\n isItalic ? '-italic' : ''\n }`;\n const textColorClassname = `${color}`;\n const mergedClassnames =\n `${textClassname} ${fontFamilyClassname} ${textColorClassname} ${twClassName}`.trim();\n\n return mergedClassnames;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AAAxB,gHAAA,OAAO,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Text/index.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAiC;AAAxB,gHAAA,OAAO,OAAA;AAEhB,2CAA6E;AAApE,yGAAA,WAAW,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA","sourcesContent":["export { default } from './Text';\nexport type { TextProps } from './Text.types';\nexport { TextVariant, TextColor, FontWeight, FontStyle } from './Text.types';\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TextButtonProps } from './TextButton.types';
|
|
2
|
+
export declare const DEFAULT_TEXTBUTTON_PROPS: Required<Pick<TextButtonProps, 'textProps' | 'isLoading' | 'loadingText' | 'spinnerProps' | 'startIconProps' | 'endIconProps' | 'isDisabled' | 'isInverse'>>;
|
|
3
|
+
//# sourceMappingURL=TextButton.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.constants.d.ts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAC7C,IAAI,CACF,eAAe,EACb,WAAW,GACX,WAAW,GACX,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,YAAY,GACZ,WAAW,CACd,CAsBF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_TEXTBUTTON_PROPS = void 0;
|
|
4
|
+
const Icon_1 = require("../Icon");
|
|
5
|
+
const Text_1 = require("../Text");
|
|
6
|
+
// Defaults
|
|
7
|
+
exports.DEFAULT_TEXTBUTTON_PROPS = {
|
|
8
|
+
textProps: {
|
|
9
|
+
variant: Text_1.TextVariant.BodyMd,
|
|
10
|
+
fontWeight: Text_1.FontWeight.Medium,
|
|
11
|
+
color: Text_1.TextColor.PrimaryDefault,
|
|
12
|
+
},
|
|
13
|
+
isLoading: false,
|
|
14
|
+
loadingText: 'Loading',
|
|
15
|
+
spinnerProps: {
|
|
16
|
+
color: Icon_1.IconColor.IconDefault,
|
|
17
|
+
},
|
|
18
|
+
startIconProps: {
|
|
19
|
+
size: Icon_1.IconSize.Sm,
|
|
20
|
+
testID: 'start-icon',
|
|
21
|
+
},
|
|
22
|
+
endIconProps: {
|
|
23
|
+
size: Icon_1.IconSize.Sm,
|
|
24
|
+
testID: 'end-icon',
|
|
25
|
+
},
|
|
26
|
+
isDisabled: false,
|
|
27
|
+
isInverse: false,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=TextButton.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.constants.js","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.constants.ts"],"names":[],"mappings":";;;AAAA,kCAA8C;AAC9C,kCAA6D;AAG7D,WAAW;AACE,QAAA,wBAAwB,GAYjC;IACF,SAAS,EAAE;QACT,OAAO,EAAE,kBAAW,CAAC,MAAM;QAC3B,UAAU,EAAE,iBAAU,CAAC,MAAM;QAC7B,KAAK,EAAE,gBAAS,CAAC,cAAc;KAChC;IACD,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE;QACZ,KAAK,EAAE,gBAAS,CAAC,WAAW;KAC7B;IACD,cAAc,EAAE;QACd,IAAI,EAAE,eAAQ,CAAC,EAAE;QACjB,MAAM,EAAE,YAAY;KACrB;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,eAAQ,CAAC,EAAE;QACjB,MAAM,EAAE,UAAU;KACnB;IACD,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;CACjB,CAAC","sourcesContent":["import { IconSize, IconColor } from '../Icon';\nimport { TextColor, TextVariant, FontWeight } from '../Text';\nimport type { TextButtonProps } from './TextButton.types';\n\n// Defaults\nexport const DEFAULT_TEXTBUTTON_PROPS: Required<\n Pick<\n TextButtonProps,\n | 'textProps'\n | 'isLoading'\n | 'loadingText'\n | 'spinnerProps'\n | 'startIconProps'\n | 'endIconProps'\n | 'isDisabled'\n | 'isInverse'\n >\n> = {\n textProps: {\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.PrimaryDefault,\n },\n isLoading: false,\n loadingText: 'Loading',\n spinnerProps: {\n color: IconColor.IconDefault,\n },\n startIconProps: {\n size: IconSize.Sm,\n testID: 'start-icon',\n },\n endIconProps: {\n size: IconSize.Sm,\n testID: 'end-icon',\n },\n isDisabled: false,\n isInverse: false,\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TextButtonProps } from './TextButton.types';
|
|
3
|
+
declare const TextButton: ({ children, textProps, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isInverse, onPress, onPressIn, onPressOut, onLongPress, twClassName, accessibilityRole, accessibilityLabel, style, ...props }: TextButtonProps) => React.JSX.Element;
|
|
4
|
+
export default TextButton;
|
|
5
|
+
//# sourceMappingURL=TextButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.d.ts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAWjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAM1D,QAAA,MAAM,UAAU,mSAuBb,eAAe,sBAsMjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
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;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
30
|
+
const design_system_twrnc_preset_1 = require("@metamask-previews/design-system-twrnc-preset");
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const react_native_1 = require("react-native");
|
|
33
|
+
const Spinner_1 = __importDefault(require("../../temp-components/Spinner"));
|
|
34
|
+
const Icon_1 = __importDefault(require("../Icon"));
|
|
35
|
+
const Text_1 = __importDefault(require("../Text/Text"));
|
|
36
|
+
const TextButton_constants_1 = require("./TextButton.constants");
|
|
37
|
+
const TextButton_utilities_1 = require("./TextButton.utilities");
|
|
38
|
+
const TextButton = ({ children, textProps, isLoading = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isDisabled, isInverse = TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.isInverse, onPress, onPressIn, onPressOut, onLongPress, twClassName, accessibilityRole, accessibilityLabel, style, ...props }) => {
|
|
39
|
+
const [isPressed, setIsPressed] = (0, react_1.useState)(false);
|
|
40
|
+
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
41
|
+
// Styling calculation for state changes
|
|
42
|
+
const twContainerClassNames = (0, react_1.useMemo)(() => {
|
|
43
|
+
return (0, TextButton_utilities_1.generateTextButtonContainerClassNames)({
|
|
44
|
+
isPressed,
|
|
45
|
+
isLoading,
|
|
46
|
+
isDisabled,
|
|
47
|
+
twClassName,
|
|
48
|
+
});
|
|
49
|
+
}, [isPressed, isLoading, isDisabled, twClassName]);
|
|
50
|
+
const twTextClassNames = (0, react_1.useMemo)(() => {
|
|
51
|
+
return (0, TextButton_utilities_1.generateTextButtonTextClassNames)({
|
|
52
|
+
isPressed,
|
|
53
|
+
isInverse,
|
|
54
|
+
isLoading,
|
|
55
|
+
});
|
|
56
|
+
}, [isPressed, isInverse, isLoading]);
|
|
57
|
+
// Merging default settings for Icons with passed in props
|
|
58
|
+
const finalStartIconProps = {
|
|
59
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.startIconProps,
|
|
60
|
+
...startIconProps,
|
|
61
|
+
twClassName: `${twTextClassNames} ${startIconProps?.twClassName ?? ''}`,
|
|
62
|
+
};
|
|
63
|
+
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
64
|
+
const finalEndIconProps = {
|
|
65
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.endIconProps,
|
|
66
|
+
...endIconProps,
|
|
67
|
+
twClassName: `${twTextClassNames} ${endIconProps?.twClassName ?? ''}`,
|
|
68
|
+
};
|
|
69
|
+
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
70
|
+
const finalTextProps = {
|
|
71
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.textProps,
|
|
72
|
+
...textProps,
|
|
73
|
+
twClassName: `${twTextClassNames} ${textProps?.twClassName ?? ''}`,
|
|
74
|
+
};
|
|
75
|
+
// Merging spinner settings for Icons with passed in props
|
|
76
|
+
const finalSpinnerProps = {
|
|
77
|
+
...TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.spinnerProps,
|
|
78
|
+
loadingText,
|
|
79
|
+
color: twTextClassNames,
|
|
80
|
+
loadingTextProps: {
|
|
81
|
+
twClassName: `${twTextClassNames} mt-[2.5px]`,
|
|
82
|
+
},
|
|
83
|
+
...spinnerProps,
|
|
84
|
+
};
|
|
85
|
+
const onPressHandler = (event) => {
|
|
86
|
+
if (!isDisabled && !isLoading) {
|
|
87
|
+
onPress?.(event);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const onPressInHandler = (event) => {
|
|
91
|
+
if (!isDisabled && !isLoading) {
|
|
92
|
+
setIsPressed(true);
|
|
93
|
+
onPressIn?.(event);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const onPressOutHandler = (event) => {
|
|
97
|
+
if (!isDisabled && !isLoading) {
|
|
98
|
+
setIsPressed(false);
|
|
99
|
+
onPressOut?.(event);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const onLongPressHandler = (event) => {
|
|
103
|
+
if (!isDisabled && !isLoading) {
|
|
104
|
+
onLongPress?.(event);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Design Requirements
|
|
109
|
+
* TextButton needs to be able to be placed inline with other Texts along with
|
|
110
|
+
* accompanying icons.
|
|
111
|
+
*
|
|
112
|
+
* Limitations
|
|
113
|
+
* React Native renders Texts and components nested inside Texts very differently.
|
|
114
|
+
* In order to fulfil design requirements
|
|
115
|
+
* - TextButton needs to be built using Text wrapping the component to ensure
|
|
116
|
+
* when placed in line with other Texts, it can be properly displayed inline
|
|
117
|
+
* with other Texts.
|
|
118
|
+
* - Due to React Native Texts calculating the layout of nested components
|
|
119
|
+
* differently, there needs to be a few styling hacks applied below
|
|
120
|
+
*/
|
|
121
|
+
// Get the line height of the text, which is also the height of the component
|
|
122
|
+
const finalVariant = textProps?.variant || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.textProps.variant;
|
|
123
|
+
const { lineHeight } = tw `text-${finalVariant}`;
|
|
124
|
+
const componentHeight = Number(lineHeight);
|
|
125
|
+
// Due to React Native rendering Views slightly above Texts, any non-texts
|
|
126
|
+
// need to be moved down
|
|
127
|
+
const nonTextOffSet = 2.5;
|
|
128
|
+
// Get the final sizes of Icons to help with manual alignments
|
|
129
|
+
const finalStartIconSize = startIconProps?.size || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.startIconProps.size;
|
|
130
|
+
const finalEndIconSize = endIconProps?.size || TextButton_constants_1.DEFAULT_TEXTBUTTON_PROPS.endIconProps.size;
|
|
131
|
+
// Offsets to vertically center the Icon
|
|
132
|
+
const finalStartIconOffset = (Number(lineHeight) - Number(finalStartIconSize)) / 2;
|
|
133
|
+
const finalEndIconOffset = (Number(lineHeight) - Number(finalEndIconSize)) / 2;
|
|
134
|
+
/**
|
|
135
|
+
* Due to Texts restricting nested components to manipulating layout with
|
|
136
|
+
* margins/paddings, we needed to add Nested Views in order to properly add
|
|
137
|
+
* additional margins/paddings. However, this causes the Text component to
|
|
138
|
+
* somehow not include the Icons as part of the calculation for displaying
|
|
139
|
+
* a change in background color onPress. Because of that, we need to mimic
|
|
140
|
+
* the behavior on the Icon wrappers by baking the margins into the Icon
|
|
141
|
+
* wrappers in order to display the background change properly
|
|
142
|
+
*/
|
|
143
|
+
const marginsBetweenIconAndText = 4;
|
|
144
|
+
const startIconWrapperWidth = Number(finalStartIconSize) + marginsBetweenIconAndText;
|
|
145
|
+
const endIconWrapperWidth = Number(finalEndIconSize) + marginsBetweenIconAndText;
|
|
146
|
+
return (<Text_1.default>
|
|
147
|
+
{finalStartIconName && <Text_1.default style={tw `hidden`}> </Text_1.default>}
|
|
148
|
+
{isLoading && (<react_native_1.View style={tw `${twContainerClassNames}`}>
|
|
149
|
+
<Spinner_1.default {...finalSpinnerProps}/>
|
|
150
|
+
</react_native_1.View>)}
|
|
151
|
+
<Text_1.default onPress={onPressHandler} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} onLongPress={onLongPressHandler} accessible accessibilityRole="button" accessibilityLabel={accessibilityLabel} style={[tw `${twContainerClassNames}`, style]} testID="text-button" suppressHighlighting {...props}>
|
|
152
|
+
{!isLoading && (<>
|
|
153
|
+
{finalStartIconName ? (
|
|
154
|
+
// This additional View is needed, otherwise things are rendered
|
|
155
|
+
// VERY funkily
|
|
156
|
+
<react_native_1.View style={tw `h-[${componentHeight}px]`}>
|
|
157
|
+
<react_native_1.View style={tw `
|
|
158
|
+
${twContainerClassNames}
|
|
159
|
+
items-start mt-[${nonTextOffSet}px]
|
|
160
|
+
pt-[${finalStartIconOffset}px]
|
|
161
|
+
h-[${componentHeight}px]
|
|
162
|
+
w-[${startIconWrapperWidth}px]
|
|
163
|
+
`}>
|
|
164
|
+
<Icon_1.default name={finalStartIconName} {...finalStartIconProps}/>
|
|
165
|
+
</react_native_1.View>
|
|
166
|
+
</react_native_1.View>) : (startAccessory)}
|
|
167
|
+
<Text_1.default {...finalTextProps}>{children}</Text_1.default>
|
|
168
|
+
{finalEndIconName ? (
|
|
169
|
+
// This additional View is needed, otherwise things are rendered
|
|
170
|
+
// VERY funkily
|
|
171
|
+
<react_native_1.View style={tw `h-[${componentHeight}px]`}>
|
|
172
|
+
<react_native_1.View style={tw `
|
|
173
|
+
${twContainerClassNames}
|
|
174
|
+
items-end
|
|
175
|
+
mt-[${nonTextOffSet}px]
|
|
176
|
+
pt-[${finalEndIconOffset}px]
|
|
177
|
+
h-[${componentHeight}px] w-[${endIconWrapperWidth}px]`}>
|
|
178
|
+
<Icon_1.default name={finalEndIconName} {...finalEndIconProps}/>
|
|
179
|
+
</react_native_1.View>
|
|
180
|
+
</react_native_1.View>) : (endAccessory)}
|
|
181
|
+
</>)}
|
|
182
|
+
</Text_1.default>
|
|
183
|
+
{finalEndIconName && <Text_1.default style={tw `hidden`}> </Text_1.default>}
|
|
184
|
+
</Text_1.default>);
|
|
185
|
+
};
|
|
186
|
+
exports.default = TextButton;
|
|
187
|
+
//# sourceMappingURL=TextButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.js","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAiE;AACjE,8FAA4E;AAC5E,+CAAiD;AAEjD,+CAAoC;AAGpC,4EAAoD;AAEpD,mDAA2B;AAC3B,wDAAgC;AAEhC,iEAAkE;AAElE,iEAGgC;AAEhC,MAAM,UAAU,GAAG,CAAC,EAClB,QAAQ,EACR,SAAS,EACT,SAAS,GAAG,+CAAwB,CAAC,SAAS,EAC9C,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,GAAG,+CAAwB,CAAC,UAAU,EAChD,SAAS,GAAG,+CAAwB,CAAC,SAAS,EAC9C,OAAO,EACP,SAAS,EACT,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACQ,EAAE,EAAE;IACpB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAClD,MAAM,EAAE,GAAG,IAAA,wCAAW,GAAE,CAAC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B,IAAI,CAAC,cAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA,QAAQ,CAAC,CAAE,CAAA,EAAE,cAAI,CAAC,CACxD;IAAA,EAAE,cAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo, useState } from 'react';\nimport type { GestureResponderEvent } from 'react-native';\nimport { View } from 'react-native';\n\nimport type { SpinnerProps } from '../../temp-components/Spinner';\nimport Spinner from '../../temp-components/Spinner';\nimport type { IconProps, IconColor } from '../Icon';\nimport Icon from '../Icon';\nimport Text from '../Text/Text';\nimport type { TextProps } from '../Text/Text.types';\nimport { DEFAULT_TEXTBUTTON_PROPS } from './TextButton.constants';\nimport type { TextButtonProps } from './TextButton.types';\nimport {\n generateTextButtonContainerClassNames,\n generateTextButtonTextClassNames,\n} from './TextButton.utilities';\n\nconst TextButton = ({\n children,\n textProps,\n isLoading = DEFAULT_TEXTBUTTON_PROPS.isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled = DEFAULT_TEXTBUTTON_PROPS.isDisabled,\n isInverse = DEFAULT_TEXTBUTTON_PROPS.isInverse,\n onPress,\n onPressIn,\n onPressOut,\n onLongPress,\n twClassName,\n accessibilityRole,\n accessibilityLabel,\n style,\n ...props\n}: TextButtonProps) => {\n const [isPressed, setIsPressed] = useState(false);\n const tw = useTailwind();\n\n // Styling calculation for state changes\n const twContainerClassNames = useMemo(() => {\n return generateTextButtonContainerClassNames({\n isPressed,\n isLoading,\n isDisabled,\n twClassName,\n });\n }, [isPressed, isLoading, isDisabled, twClassName]);\n\n const twTextClassNames = useMemo(() => {\n return generateTextButtonTextClassNames({\n isPressed,\n isInverse,\n isLoading,\n });\n }, [isPressed, isInverse, isLoading]);\n\n // Merging default settings for Icons with passed in props\n const finalStartIconProps: Partial<IconProps> = {\n ...DEFAULT_TEXTBUTTON_PROPS.startIconProps,\n ...startIconProps,\n twClassName: `${twTextClassNames} ${startIconProps?.twClassName ?? ''}`,\n };\n const finalStartIconName = startIconName ?? startIconProps?.name;\n\n const finalEndIconProps: Partial<IconProps> = {\n ...DEFAULT_TEXTBUTTON_PROPS.endIconProps,\n ...endIconProps,\n twClassName: `${twTextClassNames} ${endIconProps?.twClassName ?? ''}`,\n };\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n const finalTextProps: Omit<Partial<TextProps>, 'children'> = {\n ...DEFAULT_TEXTBUTTON_PROPS.textProps,\n ...textProps,\n twClassName: `${twTextClassNames} ${textProps?.twClassName ?? ''}`,\n };\n\n // Merging spinner settings for Icons with passed in props\n const finalSpinnerProps: SpinnerProps = {\n ...DEFAULT_TEXTBUTTON_PROPS.spinnerProps,\n loadingText,\n color: twTextClassNames as IconColor,\n loadingTextProps: {\n twClassName: `${twTextClassNames} mt-[2.5px]`,\n },\n ...spinnerProps,\n };\n const onPressHandler = (event: GestureResponderEvent) => {\n if (!isDisabled && !isLoading) {\n onPress?.(event);\n }\n };\n\n const onPressInHandler = (event: GestureResponderEvent) => {\n if (!isDisabled && !isLoading) {\n setIsPressed(true);\n onPressIn?.(event);\n }\n };\n\n const onPressOutHandler = (event: GestureResponderEvent) => {\n if (!isDisabled && !isLoading) {\n setIsPressed(false);\n onPressOut?.(event);\n }\n };\n\n const onLongPressHandler = (event: GestureResponderEvent) => {\n if (!isDisabled && !isLoading) {\n onLongPress?.(event);\n }\n };\n\n /**\n * Design Requirements\n * TextButton needs to be able to be placed inline with other Texts along with\n * accompanying icons.\n *\n * Limitations\n * React Native renders Texts and components nested inside Texts very differently.\n * In order to fulfil design requirements\n * - TextButton needs to be built using Text wrapping the component to ensure\n * when placed in line with other Texts, it can be properly displayed inline\n * with other Texts.\n * - Due to React Native Texts calculating the layout of nested components\n * differently, there needs to be a few styling hacks applied below\n */\n\n // Get the line height of the text, which is also the height of the component\n const finalVariant =\n textProps?.variant || DEFAULT_TEXTBUTTON_PROPS.textProps.variant;\n const { lineHeight } = tw`text-${finalVariant as string}`;\n const componentHeight = Number(lineHeight);\n\n // Due to React Native rendering Views slightly above Texts, any non-texts\n // need to be moved down\n const nonTextOffSet = 2.5;\n\n // Get the final sizes of Icons to help with manual alignments\n const finalStartIconSize =\n startIconProps?.size || DEFAULT_TEXTBUTTON_PROPS.startIconProps.size;\n const finalEndIconSize =\n endIconProps?.size || DEFAULT_TEXTBUTTON_PROPS.endIconProps.size;\n\n // Offsets to vertically center the Icon\n const finalStartIconOffset =\n (Number(lineHeight) - Number(finalStartIconSize)) / 2;\n const finalEndIconOffset =\n (Number(lineHeight) - Number(finalEndIconSize)) / 2;\n\n /**\n * Due to Texts restricting nested components to manipulating layout with\n * margins/paddings, we needed to add Nested Views in order to properly add\n * additional margins/paddings. However, this causes the Text component to\n * somehow not include the Icons as part of the calculation for displaying\n * a change in background color onPress. Because of that, we need to mimic\n * the behavior on the Icon wrappers by baking the margins into the Icon\n * wrappers in order to display the background change properly\n */\n const marginsBetweenIconAndText = 4;\n const startIconWrapperWidth =\n Number(finalStartIconSize) + marginsBetweenIconAndText;\n const endIconWrapperWidth =\n Number(finalEndIconSize) + marginsBetweenIconAndText;\n\n return (\n <Text>\n {finalStartIconName && <Text style={tw`hidden`}> </Text>}\n {isLoading && (\n <View style={tw`${twContainerClassNames}`}>\n <Spinner {...finalSpinnerProps} />\n </View>\n )}\n <Text\n onPress={onPressHandler}\n onPressIn={onPressInHandler}\n onPressOut={onPressOutHandler}\n onLongPress={onLongPressHandler}\n accessible\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n style={[tw`${twContainerClassNames}`, style]}\n testID=\"text-button\"\n suppressHighlighting\n {...props}\n >\n {!isLoading && (\n <>\n {finalStartIconName ? (\n // This additional View is needed, otherwise things are rendered\n // VERY funkily\n <View style={tw`h-[${componentHeight}px]`}>\n <View\n style={tw`\n ${twContainerClassNames} \n items-start mt-[${nonTextOffSet}px] \n pt-[${finalStartIconOffset}px] \n h-[${componentHeight}px] \n w-[${startIconWrapperWidth}px]\n `}\n >\n <Icon name={finalStartIconName} {...finalStartIconProps} />\n </View>\n </View>\n ) : (\n startAccessory\n )}\n <Text {...finalTextProps}>{children}</Text>\n {finalEndIconName ? (\n // This additional View is needed, otherwise things are rendered\n // VERY funkily\n <View style={tw`h-[${componentHeight}px]`}>\n <View\n style={tw`\n ${twContainerClassNames} \n items-end \n mt-[${nonTextOffSet}px] \n pt-[${finalEndIconOffset}px] \n h-[${componentHeight}px] w-[${endIconWrapperWidth}px]`}\n >\n <Icon name={finalEndIconName} {...finalEndIconProps} />\n </View>\n </View>\n ) : (\n endAccessory\n )}\n </>\n )}\n </Text>\n {finalEndIconName && <Text style={tw`hidden`}> </Text>}\n </Text>\n );\n};\n\nexport default TextButton;\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { PressableProps, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import type { TextProps } from 'src/components/Text/Text.types';
|
|
3
|
+
import type { SpinnerProps } from '../../temp-components/Spinner';
|
|
4
|
+
import type { IconProps, IconName } from '../Icon';
|
|
5
|
+
/**
|
|
6
|
+
* TextButton component props.
|
|
7
|
+
*/
|
|
8
|
+
export type TextButtonProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Required prop for the content to be rendered within the TextButton
|
|
11
|
+
*/
|
|
12
|
+
children: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional props to be passed to the Text component when children is a string
|
|
15
|
+
*/
|
|
16
|
+
textProps?: Omit<Partial<TextProps>, 'children'>;
|
|
17
|
+
/**
|
|
18
|
+
* Optional prop that when true, shows a loading spinner
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
isLoading?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Optional prop for text to display when button is in loading state
|
|
24
|
+
*/
|
|
25
|
+
loadingText?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional prop to pass additional properties to the end icon
|
|
28
|
+
*/
|
|
29
|
+
spinnerProps?: Partial<SpinnerProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Optional prop to specify an icon to show at the start of the button
|
|
32
|
+
*/
|
|
33
|
+
startIconName?: IconName;
|
|
34
|
+
/**
|
|
35
|
+
* Optional prop to pass additional properties to the start icon
|
|
36
|
+
*/
|
|
37
|
+
startIconProps?: Partial<IconProps>;
|
|
38
|
+
/**
|
|
39
|
+
* Optional prop for a custom element to show at the start of the button
|
|
40
|
+
*/
|
|
41
|
+
startAccessory?: React.ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Optional prop to specify an icon to show at the end of the button
|
|
44
|
+
*/
|
|
45
|
+
endIconName?: IconName;
|
|
46
|
+
/**
|
|
47
|
+
* Optional prop to pass additional properties to the end icon
|
|
48
|
+
*/
|
|
49
|
+
endIconProps?: Partial<IconProps>;
|
|
50
|
+
/**
|
|
51
|
+
* Optional prop for a custom element to show at the end of the button
|
|
52
|
+
*/
|
|
53
|
+
endAccessory?: React.ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* Optional prop that when true, disables the button
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
isDisabled?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Optional prop to show the inverse state of the button, which is reserved for buttons on colored backgrounds.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
isInverse?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Optional prop to add twrnc overriding classNames.
|
|
66
|
+
*/
|
|
67
|
+
twClassName?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Optional prop to control the style.
|
|
70
|
+
*/
|
|
71
|
+
style?: StyleProp<ViewStyle>;
|
|
72
|
+
} & Omit<PressableProps, 'disabled'>;
|
|
73
|
+
//# sourceMappingURL=TextButton.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextButton.types.d.ts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACrC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,SAA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