@ledgerhq/lumen-ui-rnative 0.1.56 → 0.1.57
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/module/lib/Components/core/Button/Button.js +1 -1
- package/dist/module/lib/Components/core/Button/Button.js.map +1 -1
- package/dist/module/lib/Components/core/IconButton/IconButton.js +1 -1
- package/dist/module/lib/Components/core/IconButton/IconButton.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.js +91 -66
- package/dist/module/lib/Components/core/Link/Link.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.mdx +23 -2
- package/dist/module/lib/Components/core/Link/Link.test.js +34 -7
- package/dist/module/lib/Components/core/Link/Link.test.js.map +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.js.map +1 -1
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.test.js +29 -0
- package/dist/module/lib/Components/core/MediaBanner/MediaBanner.test.js.map +1 -1
- package/dist/module/lib/Components/{core/Button → internal/BaseButton}/BaseButton.js +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.js.map +1 -0
- package/dist/module/lib/Components/{core/Button → internal/BaseButton}/BaseButton.test.js +1 -1
- package/dist/module/lib/Components/internal/BaseButton/BaseButton.test.js.map +1 -0
- package/dist/module/lib/Components/internal/BaseButton/index.js +5 -0
- package/dist/module/lib/Components/internal/BaseButton/index.js.map +1 -0
- package/dist/module/lib/Components/internal/BaseButton/types.js +4 -0
- package/dist/module/lib/Components/internal/BaseButton/types.js.map +1 -0
- package/dist/typescript/src/lib/Components/core/Button/types.d.ts +7 -38
- package/dist/typescript/src/lib/Components/core/Button/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/IconButton/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/IconButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts +4 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts +11 -4
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MediaButton/types.d.ts +2 -6
- package/dist/typescript/src/lib/Components/core/MediaButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/internal/BaseButton/BaseButton.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/internal/BaseButton/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/internal/BaseButton/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/internal/BaseButton/types.d.ts +39 -0
- package/dist/typescript/src/lib/Components/internal/BaseButton/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/lib/Components/core/Button/Button.tsx +1 -1
- package/src/lib/Components/core/Button/types.ts +7 -42
- package/src/lib/Components/core/IconButton/IconButton.tsx +1 -1
- package/src/lib/Components/core/IconButton/types.ts +1 -1
- package/src/lib/Components/core/Link/Link.mdx +23 -2
- package/src/lib/Components/core/Link/Link.test.tsx +64 -17
- package/src/lib/Components/core/Link/Link.tsx +92 -87
- package/src/lib/Components/core/Link/types.ts +11 -4
- package/src/lib/Components/core/MediaBanner/MediaBanner.test.tsx +31 -0
- package/src/lib/Components/core/MediaBanner/MediaBanner.tsx +1 -1
- package/src/lib/Components/core/MediaButton/types.ts +3 -6
- package/src/lib/Components/{core/Button → internal/BaseButton}/BaseButton.test.tsx +1 -1
- package/src/lib/Components/{core/Button → internal/BaseButton}/BaseButton.tsx +1 -1
- package/src/lib/Components/internal/BaseButton/index.ts +2 -0
- package/src/lib/Components/internal/BaseButton/types.ts +42 -0
- package/dist/module/lib/Components/core/Button/BaseButton.js.map +0 -1
- package/dist/module/lib/Components/core/Button/BaseButton.test.js.map +0 -1
- package/dist/typescript/src/lib/Components/core/Button/BaseButton.d.ts.map +0 -1
- /package/dist/typescript/src/lib/Components/{core/Button → internal/BaseButton}/BaseButton.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../../src","sources":["lib/Components/internal/BaseButton/index.ts"],"mappings":";;AAAA,cAAc,iBAAc;AAC5B,cAAc,YAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../../src","sources":["lib/Components/internal/BaseButton/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import type { IconSize } from '../../symbols/Icon';
|
|
5
|
-
export type BaseButtonProps = {
|
|
6
|
-
/**
|
|
7
|
-
* The visual style of the button.
|
|
8
|
-
*/
|
|
9
|
-
appearance?: 'base' | 'gray' | 'accent' | 'transparent' | 'no-background' | 'red';
|
|
10
|
-
/**
|
|
11
|
-
* The size variant of the button.
|
|
12
|
-
* @default md
|
|
13
|
-
*/
|
|
14
|
-
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
15
|
-
/**
|
|
16
|
-
* If true, the button expands to full width of its container.
|
|
17
|
-
*/
|
|
18
|
-
isFull?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* If true, shows a loading spinner and disables the button.
|
|
21
|
-
*/
|
|
22
|
-
loading?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* An optional icon component to render inside the button.
|
|
25
|
-
*/
|
|
26
|
-
icon?: ComponentType<{
|
|
27
|
-
size?: IconSize;
|
|
28
|
-
style?: StyleProp<ViewStyle>;
|
|
29
|
-
}>;
|
|
30
|
-
/**
|
|
31
|
-
* Whether the button is disabled.
|
|
32
|
-
*/
|
|
33
|
-
disabled?: boolean;
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BaseButtonProps } from '../../internal/BaseButton';
|
|
3
|
+
export type ButtonProps = {
|
|
34
4
|
/**
|
|
35
|
-
* The content to
|
|
5
|
+
* The content of the button. This is required to ensure buttons always have a label.
|
|
6
|
+
* @required
|
|
36
7
|
*/
|
|
37
|
-
children
|
|
38
|
-
} & Omit<StyledPressableProps, 'children'>;
|
|
39
|
-
export type ButtonProps = {
|
|
8
|
+
children: ReactNode;
|
|
40
9
|
/**
|
|
41
10
|
* The size variant of the button.
|
|
42
11
|
* @default md
|
|
43
12
|
*/
|
|
44
13
|
size?: 'sm' | 'md' | 'lg';
|
|
45
|
-
} & Omit<BaseButtonProps, 'size'>;
|
|
14
|
+
} & Omit<BaseButtonProps, 'children' | 'size'>;
|
|
46
15
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3B,GAAG,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,MAAM,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/IconButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/IconButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;CAC5C,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -3,6 +3,9 @@ import type { LinkProps } from './types';
|
|
|
3
3
|
* A customizable link component that supports base and accent color appearances, optional underline, sizes, icons, and external link handling.
|
|
4
4
|
* Opens URLs using React Native's Linking API.
|
|
5
5
|
*
|
|
6
|
+
* Rendered as a `Text`, so it can be nested inside a paragraph of text and flows
|
|
7
|
+
* with it (no extra line height) as well as used on its own.
|
|
8
|
+
*
|
|
6
9
|
* @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-link--docs Guidelines}
|
|
7
10
|
*
|
|
8
11
|
* @warning The `lx` prop should only be used for layout adjustments like margins or positioning.
|
|
@@ -33,5 +36,5 @@ import type { LinkProps } from './types';
|
|
|
33
36
|
* Dashboard
|
|
34
37
|
* </Link>
|
|
35
38
|
*/
|
|
36
|
-
export declare const Link: ({ lx, style, children, appearance, size, underline, icon, isExternal, href, onPress, ref, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const Link: ({ lx, style, children, appearance, size, underline, icon, isExternal, href, onPress, onPressIn, onPressOut, hapticFeedback, numberOfLines, suppressHighlighting, ref, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
40
|
//# sourceMappingURL=Link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Link/Link.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Link/Link.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA8EzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,IAAI,GAAI,kLAkBlB,SAAS,4CA6DX,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import type { StyleProp,
|
|
3
|
-
import type {
|
|
2
|
+
import type { StyleProp, TextStyle } from 'react-native';
|
|
3
|
+
import type { StyledTextProps } from '../../../../styles';
|
|
4
|
+
import type { ImpactFeedbackStyle } from '../../../Haptics';
|
|
4
5
|
import type { IconSize } from '../../symbols/Icon';
|
|
5
6
|
export type LinkProps = {
|
|
6
7
|
/**
|
|
@@ -24,7 +25,7 @@ export type LinkProps = {
|
|
|
24
25
|
*/
|
|
25
26
|
icon?: React.ComponentType<{
|
|
26
27
|
size?: IconSize;
|
|
27
|
-
style?: StyleProp<
|
|
28
|
+
style?: StyleProp<TextStyle>;
|
|
28
29
|
}>;
|
|
29
30
|
/**
|
|
30
31
|
* If true, displays an external link icon next to the link text.
|
|
@@ -39,5 +40,11 @@ export type LinkProps = {
|
|
|
39
40
|
* Custom press handler (overrides default href navigation)
|
|
40
41
|
*/
|
|
41
42
|
onPress?: () => void;
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Triggers haptic feedback on press-in.
|
|
45
|
+
* - `true` — default medium intensity.
|
|
46
|
+
* - Impact style: `"light"` | `"medium"` | `"heavy"` | `"soft"` | `"rigid"`.
|
|
47
|
+
*/
|
|
48
|
+
hapticFeedback?: ImpactFeedbackStyle | true;
|
|
49
|
+
} & PropsWithChildren & Omit<StyledTextProps, 'onPress' | 'children'>;
|
|
43
50
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Link/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/Link/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QACzB,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;KAC9B,CAAC,CAAC;IACH;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,cAAc,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC7C,GAAG,iBAAiB,GACnB,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { StyledPressableProps } from '../../../../styles';
|
|
3
|
+
import type { BaseButtonProps } from '../../internal/BaseButton';
|
|
3
4
|
export type MediaButtonProps = {
|
|
4
5
|
/**
|
|
5
6
|
* The visual style of the media button.
|
|
@@ -30,14 +31,9 @@ export type MediaButtonProps = {
|
|
|
30
31
|
* @default false
|
|
31
32
|
*/
|
|
32
33
|
hideChevron?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the media button is disabled.
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
disabled?: boolean;
|
|
38
34
|
/**
|
|
39
35
|
* The label content of the media button.
|
|
40
36
|
*/
|
|
41
37
|
children: ReactNode;
|
|
42
|
-
} & Omit<StyledPressableProps, 'children'>;
|
|
38
|
+
} & Pick<BaseButtonProps, 'disabled'> & Omit<StyledPressableProps, 'children'>;
|
|
43
39
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/MediaButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/core/MediaButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,eAAe,CAAC;IACtD;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GACnC,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/internal/BaseButton/BaseButton.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAmI/C;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,mHAYxB,eAAe,4CAgCjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/internal/BaseButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { StyledPressableProps } from '../../../../styles';
|
|
4
|
+
import type { IconSize } from '../../symbols/Icon';
|
|
5
|
+
export type BaseButtonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The visual style of the button.
|
|
8
|
+
*/
|
|
9
|
+
appearance?: 'base' | 'gray' | 'accent' | 'transparent' | 'no-background' | 'red';
|
|
10
|
+
/**
|
|
11
|
+
* The size variant of the button.
|
|
12
|
+
* @default md
|
|
13
|
+
*/
|
|
14
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
15
|
+
/**
|
|
16
|
+
* If true, the button expands to full width of its container.
|
|
17
|
+
*/
|
|
18
|
+
isFull?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* If true, shows a loading spinner and disables the button.
|
|
21
|
+
*/
|
|
22
|
+
loading?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* An optional icon component to render inside the button.
|
|
25
|
+
*/
|
|
26
|
+
icon?: ComponentType<{
|
|
27
|
+
size?: IconSize;
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the button is disabled.
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The content to display inside the button.
|
|
36
|
+
*/
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
} & Omit<StyledPressableProps, 'children'>;
|
|
39
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../src/lib/Components/internal/BaseButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,UAAU,CAAC,EACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,aAAa,GACb,eAAe,GACf,KAAK,CAAC;IACV;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;KAAE,CAAC,CAAC;IACxE;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,50 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { StyledPressableProps } from '../../../../styles';
|
|
4
|
-
import type { IconSize } from '../../symbols/Icon';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BaseButtonProps } from '../../internal/BaseButton';
|
|
5
3
|
|
|
6
|
-
export type
|
|
7
|
-
/**
|
|
8
|
-
* The visual style of the button.
|
|
9
|
-
*/
|
|
10
|
-
appearance?:
|
|
11
|
-
| 'base'
|
|
12
|
-
| 'gray'
|
|
13
|
-
| 'accent'
|
|
14
|
-
| 'transparent'
|
|
15
|
-
| 'no-background'
|
|
16
|
-
| 'red';
|
|
17
|
-
/**
|
|
18
|
-
* The size variant of the button.
|
|
19
|
-
* @default md
|
|
20
|
-
*/
|
|
21
|
-
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
22
|
-
/**
|
|
23
|
-
* If true, the button expands to full width of its container.
|
|
24
|
-
*/
|
|
25
|
-
isFull?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* If true, shows a loading spinner and disables the button.
|
|
28
|
-
*/
|
|
29
|
-
loading?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* An optional icon component to render inside the button.
|
|
32
|
-
*/
|
|
33
|
-
icon?: ComponentType<{ size?: IconSize; style?: StyleProp<ViewStyle> }>;
|
|
34
|
-
/**
|
|
35
|
-
* Whether the button is disabled.
|
|
36
|
-
*/
|
|
37
|
-
disabled?: boolean;
|
|
4
|
+
export type ButtonProps = {
|
|
38
5
|
/**
|
|
39
|
-
* The content to
|
|
6
|
+
* The content of the button. This is required to ensure buttons always have a label.
|
|
7
|
+
* @required
|
|
40
8
|
*/
|
|
41
|
-
children
|
|
42
|
-
} & Omit<StyledPressableProps, 'children'>;
|
|
43
|
-
|
|
44
|
-
export type ButtonProps = {
|
|
9
|
+
children: ReactNode;
|
|
45
10
|
/**
|
|
46
11
|
* The size variant of the button.
|
|
47
12
|
* @default md
|
|
48
13
|
*/
|
|
49
14
|
size?: 'sm' | 'md' | 'lg';
|
|
50
|
-
} & Omit<BaseButtonProps, 'size'>;
|
|
15
|
+
} & Omit<BaseButtonProps, 'children' | 'size'>;
|
|
@@ -68,6 +68,12 @@ Links adapt to their container, truncating long text on a single line to prevent
|
|
|
68
68
|
|
|
69
69
|
<Canvas of={LinkStories.ResponsiveLayout} />
|
|
70
70
|
|
|
71
|
+
## Inline within text
|
|
72
|
+
|
|
73
|
+
Links render as text, so they can be nested inside a sentence and flow with it without affecting the line height:
|
|
74
|
+
|
|
75
|
+
<Canvas of={LinkStories.InTextUsage} />
|
|
76
|
+
|
|
71
77
|
## Accessibility
|
|
72
78
|
|
|
73
79
|
To be implemented:
|
|
@@ -173,13 +179,28 @@ function MyComponent() {
|
|
|
173
179
|
}
|
|
174
180
|
```
|
|
175
181
|
|
|
176
|
-
###
|
|
182
|
+
### Inline Within Text
|
|
183
|
+
|
|
184
|
+
The Link component is built on React Native's `Text`, so it can be nested inside a sentence without breaking the line height:
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
<Text typography='body2' lx={{ color: 'base' }}>
|
|
188
|
+
By continuing, you agree to our{' '}
|
|
189
|
+
<Link size='sm' href='https://example.com/terms'>
|
|
190
|
+
Terms & Conditions
|
|
191
|
+
</Link>
|
|
192
|
+
.
|
|
193
|
+
</Text>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Text Integration
|
|
177
197
|
|
|
178
|
-
The Link component
|
|
198
|
+
The Link component accepts all `Text` props, e.g. press callbacks or line clamping:
|
|
179
199
|
|
|
180
200
|
```tsx
|
|
181
201
|
<Link
|
|
182
202
|
href='https://example.com'
|
|
203
|
+
numberOfLines={2}
|
|
183
204
|
onPressIn={() => console.log('Press started')}
|
|
184
205
|
onPressOut={() => console.log('Press ended')}
|
|
185
206
|
>
|
|
@@ -21,6 +21,25 @@ const renderWithProvider = (component: React.ReactElement) => {
|
|
|
21
21
|
);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
type LinkElement = ReturnType<typeof screen.getByText>;
|
|
25
|
+
type IconWrapperStyle = {
|
|
26
|
+
paddingLeft?: number;
|
|
27
|
+
paddingRight?: number;
|
|
28
|
+
transform?: { translateY: number }[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Icons are rendered inline as children of the link Text, so they are read from
|
|
32
|
+
// the element tree rather than queried by testID.
|
|
33
|
+
const getLinkChildren = (link: LinkElement): React.ReactNode[] =>
|
|
34
|
+
Children.toArray(link.props.children as React.ReactNode);
|
|
35
|
+
|
|
36
|
+
const getIconWrapperStyle = (link: LinkElement): IconWrapperStyle => {
|
|
37
|
+
const [iconWrapper] = getLinkChildren(link) as React.ReactElement<{
|
|
38
|
+
style: IconWrapperStyle;
|
|
39
|
+
}>[];
|
|
40
|
+
return iconWrapper.props.style;
|
|
41
|
+
};
|
|
42
|
+
|
|
24
43
|
const typographyTokens = ledgerLiveThemes.dark.typographies.sm;
|
|
25
44
|
const typographies = {
|
|
26
45
|
...typographyTokens.heading,
|
|
@@ -41,7 +60,7 @@ describe('Link Component', () => {
|
|
|
41
60
|
</Link>,
|
|
42
61
|
);
|
|
43
62
|
|
|
44
|
-
expect(screen.getByText('Click me')
|
|
63
|
+
expect(screen.getByText('Click me')).toBe(screen.getByTestId('link'));
|
|
45
64
|
expect(screen.getByTestId('link').props.accessibilityRole).toBe('link');
|
|
46
65
|
});
|
|
47
66
|
|
|
@@ -73,13 +92,17 @@ describe('Link Component', () => {
|
|
|
73
92
|
|
|
74
93
|
describe('Sizes', () => {
|
|
75
94
|
it.each([
|
|
76
|
-
['sm', typographies.body2SemiBold, spacings.s4],
|
|
77
|
-
['md', typographies.body1SemiBold, spacings.s8],
|
|
95
|
+
['sm', typographies.body2SemiBold, spacings.s4, 3],
|
|
96
|
+
['md', typographies.body1SemiBold, spacings.s8, 4],
|
|
78
97
|
])(
|
|
79
|
-
'should apply %s size with correct typography and
|
|
80
|
-
(size, typography, expectedGap) => {
|
|
98
|
+
'should apply %s size with correct typography and icon spacing',
|
|
99
|
+
(size, typography, expectedGap, expectedOffset) => {
|
|
81
100
|
renderWithProvider(
|
|
82
|
-
<Link
|
|
101
|
+
<Link
|
|
102
|
+
href='https://example.com'
|
|
103
|
+
size={size as LinkProps['size']}
|
|
104
|
+
icon={Information}
|
|
105
|
+
>
|
|
83
106
|
Link
|
|
84
107
|
</Link>,
|
|
85
108
|
);
|
|
@@ -87,9 +110,11 @@ describe('Link Component', () => {
|
|
|
87
110
|
const textStyle = screen.getByText('Link').props.style;
|
|
88
111
|
expect(textStyle.fontSize).toBe(typography.fontSize);
|
|
89
112
|
expect(textStyle.fontWeight).toBe(typography.fontWeight);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
113
|
+
|
|
114
|
+
const iconStyle = getIconWrapperStyle(screen.getByText('Link'));
|
|
115
|
+
expect(iconStyle.paddingRight).toBe(expectedGap);
|
|
116
|
+
// Keeps the inline icons optically centred on the text baseline.
|
|
117
|
+
expect(iconStyle.transform).toEqual([{ translateY: expectedOffset }]);
|
|
93
118
|
},
|
|
94
119
|
);
|
|
95
120
|
});
|
|
@@ -113,6 +138,31 @@ describe('Link Component', () => {
|
|
|
113
138
|
);
|
|
114
139
|
});
|
|
115
140
|
|
|
141
|
+
describe('States', () => {
|
|
142
|
+
it.each([
|
|
143
|
+
['base', colors.text.base, colors.text.basePressed],
|
|
144
|
+
['accent', colors.text.interactive, colors.text.interactivePressed],
|
|
145
|
+
])(
|
|
146
|
+
'should apply the %s pressed color while pressed',
|
|
147
|
+
(appearance, restingColor, pressedColor) => {
|
|
148
|
+
renderWithProvider(
|
|
149
|
+
<Link
|
|
150
|
+
href='https://example.com'
|
|
151
|
+
appearance={appearance as LinkProps['appearance']}
|
|
152
|
+
>
|
|
153
|
+
Link
|
|
154
|
+
</Link>,
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
fireEvent(screen.getByText('Link'), 'onPressIn');
|
|
158
|
+
expect(screen.getByText('Link').props.style.color).toBe(pressedColor);
|
|
159
|
+
|
|
160
|
+
fireEvent(screen.getByText('Link'), 'onPressOut');
|
|
161
|
+
expect(screen.getByText('Link').props.style.color).toBe(restingColor);
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
|
|
116
166
|
describe('Icons', () => {
|
|
117
167
|
it('should render leading icon when provided', () => {
|
|
118
168
|
renderWithProvider(
|
|
@@ -121,10 +171,9 @@ describe('Link Component', () => {
|
|
|
121
171
|
</Link>,
|
|
122
172
|
);
|
|
123
173
|
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
expect(children.length).toBe(2); // icon + text wrapper
|
|
174
|
+
const link = screen.getByText('With Icon');
|
|
175
|
+
expect(getLinkChildren(link).length).toBe(2); // icon + label
|
|
176
|
+
expect(getIconWrapperStyle(link).paddingRight).toBe(spacings.s8);
|
|
128
177
|
});
|
|
129
178
|
|
|
130
179
|
it('should render external link icon when isExternal is true', () => {
|
|
@@ -134,10 +183,8 @@ describe('Link Component', () => {
|
|
|
134
183
|
</Link>,
|
|
135
184
|
);
|
|
136
185
|
|
|
137
|
-
const children =
|
|
138
|
-
|
|
139
|
-
);
|
|
140
|
-
expect(children.length).toBe(2); // text wrapper + external icon
|
|
186
|
+
const children = getLinkChildren(screen.getByText('External'));
|
|
187
|
+
expect(children.length).toBe(2); // label + external icon
|
|
141
188
|
});
|
|
142
189
|
});
|
|
143
190
|
|