@ledgerhq/lumen-ui-rnative 0.1.49 → 0.1.50
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/BaseInput/BaseInput.js +84 -25
- package/dist/module/lib/Components/BaseInput/BaseInput.js.map +1 -1
- package/dist/module/lib/Components/Button/ButtonGroup.figma.js +19 -0
- package/dist/module/lib/Components/Button/ButtonGroup.figma.js.map +1 -0
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js +31 -9
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js.map +1 -1
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js +29 -40
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js.map +1 -1
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js +22 -0
- package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.figma.js +11 -0
- package/dist/module/lib/Components/ListItem/ListItem.figma.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.js +78 -20
- package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.mdx +17 -0
- package/dist/module/lib/Components/ListItem/ListItem.stories.js +132 -0
- package/dist/module/lib/Components/ListItem/ListItem.stories.js.map +1 -1
- package/dist/module/lib/Components/ListItem/ListItem.test.js +80 -0
- package/dist/module/lib/Components/ListItem/ListItem.test.js.map +1 -1
- package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js +22 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.js +99 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js +104 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js +108 -0
- package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/index.js +5 -0
- package/dist/module/lib/Components/SectionHeader/index.js.map +1 -0
- package/dist/module/lib/Components/SectionHeader/types.js +4 -0
- package/dist/module/lib/Components/SectionHeader/types.js.map +1 -0
- package/dist/module/lib/Components/TextInput/TextInput.figma.js +5 -0
- package/dist/module/lib/Components/TextInput/TextInput.figma.js.map +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.mdx +43 -73
- package/dist/module/lib/Components/TextInput/TextInput.stories.js +58 -1
- package/dist/module/lib/Components/TextInput/TextInput.stories.js.map +1 -1
- package/dist/module/lib/Components/TextInput/TextInput.test.js +45 -1
- package/dist/module/lib/Components/TextInput/TextInput.test.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.figma.js +5 -0
- package/dist/module/lib/Components/TileButton/TileButton.figma.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.js +39 -27
- package/dist/module/lib/Components/TileButton/TileButton.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.mdx +10 -1
- package/dist/module/lib/Components/TileButton/TileButton.stories.js +33 -2
- package/dist/module/lib/Components/TileButton/TileButton.stories.js.map +1 -1
- package/dist/module/lib/Components/TileButton/TileButton.test.js +26 -0
- package/dist/module/lib/Components/TileButton/TileButton.test.js.map +1 -1
- package/dist/module/lib/Components/index.js +1 -0
- package/dist/module/lib/Components/index.js.map +1 -1
- package/dist/module/lib/Symbols/Icons/Upload.js +50 -0
- package/dist/module/lib/Symbols/Icons/Upload.js.map +1 -0
- package/dist/module/lib/Symbols/index.js +1 -0
- package/dist/module/lib/Symbols/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/BaseInput/types.d.ts +16 -0
- package/dist/typescript/src/lib/Components/BaseInput/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts +6 -0
- package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts +1 -1
- package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/ListItem/types.d.ts +11 -1
- package/dist/typescript/src/lib/Components/ListItem/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts +20 -0
- package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts +27 -0
- package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts +1 -1
- package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/TileButton/types.d.ts +5 -0
- package/dist/typescript/src/lib/Components/TileButton/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/index.d.ts +1 -0
- package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
- package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts +35 -0
- package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts.map +1 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts +1 -0
- package/dist/typescript/src/lib/Symbols/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/BaseInput/BaseInput.tsx +93 -22
- package/src/lib/Components/BaseInput/types.ts +18 -0
- package/src/lib/Components/Button/ButtonGroup.figma.tsx +15 -0
- package/src/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
- package/src/lib/Components/DescriptionItem/DescriptionItem.stories.tsx +21 -41
- package/src/lib/Components/DescriptionItem/DescriptionItem.test.tsx +24 -0
- package/src/lib/Components/DescriptionItem/DescriptionItem.tsx +31 -8
- package/src/lib/Components/DescriptionItem/types.ts +6 -0
- package/src/lib/Components/ListItem/ListItem.figma.tsx +43 -8
- package/src/lib/Components/ListItem/ListItem.mdx +17 -0
- package/src/lib/Components/ListItem/ListItem.stories.tsx +92 -0
- package/src/lib/Components/ListItem/ListItem.test.tsx +78 -0
- package/src/lib/Components/ListItem/ListItem.tsx +64 -19
- package/src/lib/Components/ListItem/types.ts +11 -1
- package/src/lib/Components/SectionHeader/SectionHeader.figma.tsx +24 -0
- package/src/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
- package/src/lib/Components/SectionHeader/SectionHeader.stories.tsx +95 -0
- package/src/lib/Components/SectionHeader/SectionHeader.test.tsx +103 -0
- package/src/lib/Components/SectionHeader/SectionHeader.tsx +125 -0
- package/src/lib/Components/SectionHeader/index.ts +6 -0
- package/src/lib/Components/SectionHeader/types.ts +30 -0
- package/src/lib/Components/TextInput/TextInput.figma.tsx +6 -1
- package/src/lib/Components/TextInput/TextInput.mdx +43 -73
- package/src/lib/Components/TextInput/TextInput.stories.tsx +57 -1
- package/src/lib/Components/TextInput/TextInput.test.tsx +60 -1
- package/src/lib/Components/TileButton/TileButton.figma.tsx +5 -0
- package/src/lib/Components/TileButton/TileButton.mdx +10 -1
- package/src/lib/Components/TileButton/TileButton.stories.tsx +28 -4
- package/src/lib/Components/TileButton/TileButton.test.tsx +35 -1
- package/src/lib/Components/TileButton/TileButton.tsx +47 -28
- package/src/lib/Components/TileButton/types.ts +5 -0
- package/src/lib/Components/index.ts +1 -0
- package/src/lib/Symbols/Icons/Upload.tsx +45 -0
- package/src/lib/Symbols/index.ts +1 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Meta, Canvas, Controls, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as SectionHeaderStories from './SectionHeader.stories';
|
|
3
|
+
import { SectionHeader } from './SectionHeader';
|
|
4
|
+
import { CustomTabs, Tab, SetupNote } from '../../../../.storybook/components';
|
|
5
|
+
|
|
6
|
+
<Meta title='Core/SectionHeader' of={SectionHeaderStories} />
|
|
7
|
+
|
|
8
|
+
# SectionHeader
|
|
9
|
+
|
|
10
|
+
<CustomTabs>
|
|
11
|
+
<Tab label="Overview">
|
|
12
|
+
|
|
13
|
+
## Introduction
|
|
14
|
+
|
|
15
|
+
SectionHeader is a compact, muted label used to title grouped content areas. It is smaller and more subdued than Subheader, making it suitable for category labels, list group headers, and inline section markers.
|
|
16
|
+
|
|
17
|
+
> View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=18640-48457&m=dev).
|
|
18
|
+
|
|
19
|
+
## Anatomy
|
|
20
|
+
|
|
21
|
+
<Canvas of={SectionHeaderStories.Base} />
|
|
22
|
+
|
|
23
|
+
The SectionHeader uses a composite structure with the following components:
|
|
24
|
+
|
|
25
|
+
- **SectionHeader** (container): The root component with optional `appearance` variant
|
|
26
|
+
- **SectionHeaderLeading** (optional): Slot for a leading icon or other content
|
|
27
|
+
- **SectionHeaderTitle** (required): The muted label text
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### Overview
|
|
32
|
+
|
|
33
|
+
<Canvas of={SectionHeaderStories.Base} />
|
|
34
|
+
<Controls of={SectionHeaderStories.Base} />
|
|
35
|
+
|
|
36
|
+
### Appearance
|
|
37
|
+
|
|
38
|
+
There are two appearances: `no-background` (default) renders plain muted text with no container styling, and `plain` wraps the label in a subtle surface chip.
|
|
39
|
+
|
|
40
|
+
<Canvas of={SectionHeaderStories.AppearanceShowcase} />
|
|
41
|
+
|
|
42
|
+
### With leading icon
|
|
43
|
+
|
|
44
|
+
Use `SectionHeaderLeading` to add an optional icon before the title.
|
|
45
|
+
|
|
46
|
+
<Canvas of={SectionHeaderStories.WithLeadingIcon} />
|
|
47
|
+
|
|
48
|
+
### Truncation
|
|
49
|
+
|
|
50
|
+
Long titles truncate with an ellipsis while keeping leading content visible.
|
|
51
|
+
|
|
52
|
+
<Canvas of={SectionHeaderStories.ResponsiveShowcase} />
|
|
53
|
+
|
|
54
|
+
</Tab>
|
|
55
|
+
|
|
56
|
+
<Tab label="Implementation">
|
|
57
|
+
|
|
58
|
+
<SetupNote />
|
|
59
|
+
|
|
60
|
+
`SectionHeader` is a compound component. Compose it with `SectionHeaderTitle` (required) and, optionally, `SectionHeaderLeading` for a leading icon.
|
|
61
|
+
|
|
62
|
+
### Basic Usage
|
|
63
|
+
|
|
64
|
+
<Source of={SectionHeaderStories.Base} />
|
|
65
|
+
|
|
66
|
+
### With leading icon
|
|
67
|
+
|
|
68
|
+
Add `SectionHeaderLeading` before the title to render a leading icon.
|
|
69
|
+
|
|
70
|
+
<Source of={SectionHeaderStories.WithLeadingIcon} />
|
|
71
|
+
|
|
72
|
+
### Truncation
|
|
73
|
+
|
|
74
|
+
Titles truncate with an ellipsis when they exceed the available width, while leading content stays visible.
|
|
75
|
+
|
|
76
|
+
<Source of={SectionHeaderStories.TruncateShowcase} />
|
|
77
|
+
|
|
78
|
+
</Tab>
|
|
79
|
+
</CustomTabs>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
|
|
2
|
+
import { Settings } from '../../Symbols';
|
|
3
|
+
import { Box } from '../Utility';
|
|
4
|
+
import {
|
|
5
|
+
SectionHeader,
|
|
6
|
+
SectionHeaderLeading,
|
|
7
|
+
SectionHeaderTitle,
|
|
8
|
+
} from './SectionHeader';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof SectionHeader> = {
|
|
11
|
+
component: SectionHeader,
|
|
12
|
+
id: 'rnative-sectionheader',
|
|
13
|
+
title: 'Core/SectionHeader',
|
|
14
|
+
subcomponents: {
|
|
15
|
+
SectionHeaderLeading,
|
|
16
|
+
SectionHeaderTitle,
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'centered',
|
|
20
|
+
backgrounds: { default: 'light' },
|
|
21
|
+
docs: {
|
|
22
|
+
source: {
|
|
23
|
+
language: 'tsx',
|
|
24
|
+
format: true,
|
|
25
|
+
type: 'dynamic',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
appearance: {
|
|
31
|
+
control: 'radio',
|
|
32
|
+
options: ['no-background', 'plain'],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
decorators: [
|
|
36
|
+
(Story) => (
|
|
37
|
+
<Box lx={{ padding: 's8', width: 's400' }}>
|
|
38
|
+
<Story />
|
|
39
|
+
</Box>
|
|
40
|
+
),
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default meta;
|
|
45
|
+
type Story = StoryObj<typeof SectionHeader>;
|
|
46
|
+
|
|
47
|
+
export const Base: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
appearance: 'no-background',
|
|
50
|
+
},
|
|
51
|
+
render: ({ appearance }) => (
|
|
52
|
+
<SectionHeader appearance={appearance}>
|
|
53
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
54
|
+
</SectionHeader>
|
|
55
|
+
),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const AppearanceShowcase: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<Box lx={{ gap: 's8' }}>
|
|
61
|
+
<SectionHeader>
|
|
62
|
+
<SectionHeaderTitle>No background</SectionHeaderTitle>
|
|
63
|
+
</SectionHeader>
|
|
64
|
+
<SectionHeader appearance='plain'>
|
|
65
|
+
<SectionHeaderTitle>Plain</SectionHeaderTitle>
|
|
66
|
+
</SectionHeader>
|
|
67
|
+
</Box>
|
|
68
|
+
),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const WithLeadingIcon: Story = {
|
|
72
|
+
render: () => (
|
|
73
|
+
<SectionHeader appearance='plain'>
|
|
74
|
+
<SectionHeaderLeading>
|
|
75
|
+
<Settings size={16} color='muted' />
|
|
76
|
+
</SectionHeaderLeading>
|
|
77
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
78
|
+
</SectionHeader>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ResponsiveShowcase: Story = {
|
|
83
|
+
render: () => (
|
|
84
|
+
<Box lx={{ width: 's144' }}>
|
|
85
|
+
<SectionHeader appearance='plain'>
|
|
86
|
+
<SectionHeaderLeading>
|
|
87
|
+
<Settings size={16} color='muted' />
|
|
88
|
+
</SectionHeaderLeading>
|
|
89
|
+
<SectionHeaderTitle>
|
|
90
|
+
Very long section header label that should truncate
|
|
91
|
+
</SectionHeaderTitle>
|
|
92
|
+
</SectionHeader>
|
|
93
|
+
</Box>
|
|
94
|
+
),
|
|
95
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
|
|
3
|
+
import { render, screen } from '@testing-library/react-native';
|
|
4
|
+
import { Text } from 'react-native';
|
|
5
|
+
import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
|
|
6
|
+
import {
|
|
7
|
+
SectionHeader,
|
|
8
|
+
SectionHeaderLeading,
|
|
9
|
+
SectionHeaderTitle,
|
|
10
|
+
} from './SectionHeader';
|
|
11
|
+
|
|
12
|
+
const TestWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
13
|
+
<ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
|
|
14
|
+
{children}
|
|
15
|
+
</ThemeProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
describe('SectionHeader', () => {
|
|
19
|
+
it('renders the title', () => {
|
|
20
|
+
render(
|
|
21
|
+
<TestWrapper>
|
|
22
|
+
<SectionHeader>
|
|
23
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
24
|
+
</SectionHeader>
|
|
25
|
+
</TestWrapper>,
|
|
26
|
+
);
|
|
27
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders with plain appearance', () => {
|
|
31
|
+
render(
|
|
32
|
+
<TestWrapper>
|
|
33
|
+
<SectionHeader appearance='plain' testID='section-header'>
|
|
34
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
35
|
+
</SectionHeader>
|
|
36
|
+
</TestWrapper>,
|
|
37
|
+
);
|
|
38
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
39
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders with no-background appearance by default', () => {
|
|
43
|
+
render(
|
|
44
|
+
<TestWrapper>
|
|
45
|
+
<SectionHeader testID='section-header'>
|
|
46
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
47
|
+
</SectionHeader>
|
|
48
|
+
</TestWrapper>,
|
|
49
|
+
);
|
|
50
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('renders leading content when provided', () => {
|
|
54
|
+
render(
|
|
55
|
+
<TestWrapper>
|
|
56
|
+
<SectionHeader>
|
|
57
|
+
<SectionHeaderLeading testID='leading'>
|
|
58
|
+
<Text>icon</Text>
|
|
59
|
+
</SectionHeaderLeading>
|
|
60
|
+
<SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
61
|
+
</SectionHeader>
|
|
62
|
+
</TestWrapper>,
|
|
63
|
+
);
|
|
64
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
65
|
+
expect(screen.getByText('Label')).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('renders all subcomponents together with plain appearance', () => {
|
|
69
|
+
render(
|
|
70
|
+
<TestWrapper>
|
|
71
|
+
<SectionHeader appearance='plain' testID='section-header'>
|
|
72
|
+
<SectionHeaderLeading testID='leading'>
|
|
73
|
+
<Text>icon</Text>
|
|
74
|
+
</SectionHeaderLeading>
|
|
75
|
+
<SectionHeaderTitle>Accounts</SectionHeaderTitle>
|
|
76
|
+
</SectionHeader>
|
|
77
|
+
</TestWrapper>,
|
|
78
|
+
);
|
|
79
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
80
|
+
expect(screen.getByText('Accounts')).toBeTruthy();
|
|
81
|
+
expect(screen.getByTestId('section-header')).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('keeps leading content visible with a long title', () => {
|
|
85
|
+
render(
|
|
86
|
+
<TestWrapper>
|
|
87
|
+
<SectionHeader lx={{ maxWidth: 's80' }}>
|
|
88
|
+
<SectionHeaderLeading testID='leading'>
|
|
89
|
+
<Text>icon</Text>
|
|
90
|
+
</SectionHeaderLeading>
|
|
91
|
+
<SectionHeaderTitle>
|
|
92
|
+
Very long section header label that should truncate
|
|
93
|
+
</SectionHeaderTitle>
|
|
94
|
+
</SectionHeader>
|
|
95
|
+
</TestWrapper>,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(screen.getByTestId('leading')).toBeTruthy();
|
|
99
|
+
expect(
|
|
100
|
+
screen.getByText('Very long section header label that should truncate'),
|
|
101
|
+
).toBeTruthy();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ViewStyle } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { useStyleSheet } from '../../../styles';
|
|
4
|
+
import { Box, Text } from '../Utility';
|
|
5
|
+
import type {
|
|
6
|
+
SectionHeaderAppearance,
|
|
7
|
+
SectionHeaderLeadingProps,
|
|
8
|
+
SectionHeaderProps,
|
|
9
|
+
SectionHeaderTitleProps,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Leading slot for the SectionHeader. Use for optional icons or other leading content.
|
|
14
|
+
*/
|
|
15
|
+
export const SectionHeaderLeading = ({
|
|
16
|
+
children,
|
|
17
|
+
lx,
|
|
18
|
+
style,
|
|
19
|
+
...props
|
|
20
|
+
}: SectionHeaderLeadingProps) => {
|
|
21
|
+
const styles = useStyleSheet(
|
|
22
|
+
() => ({
|
|
23
|
+
leading: StyleSheet.flatten([
|
|
24
|
+
{
|
|
25
|
+
flexShrink: 0,
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
},
|
|
29
|
+
]),
|
|
30
|
+
}),
|
|
31
|
+
[],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Box lx={lx} style={[styles.leading, style]} {...props}>
|
|
36
|
+
{children}
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Title component for the SectionHeader. Displays the muted label text.
|
|
43
|
+
*/
|
|
44
|
+
export const SectionHeaderTitle = ({
|
|
45
|
+
children,
|
|
46
|
+
lx,
|
|
47
|
+
style,
|
|
48
|
+
...props
|
|
49
|
+
}: SectionHeaderTitleProps) => {
|
|
50
|
+
const styles = useStyleSheet(
|
|
51
|
+
(t) => ({
|
|
52
|
+
title: StyleSheet.flatten([
|
|
53
|
+
t.typographies.body2SemiBold,
|
|
54
|
+
{
|
|
55
|
+
flexShrink: 1,
|
|
56
|
+
minWidth: 0,
|
|
57
|
+
color: t.colors.text.muted,
|
|
58
|
+
},
|
|
59
|
+
]),
|
|
60
|
+
}),
|
|
61
|
+
[],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Text
|
|
66
|
+
lx={lx}
|
|
67
|
+
style={[styles.title, style]}
|
|
68
|
+
numberOfLines={1}
|
|
69
|
+
ellipsizeMode='tail'
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</Text>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A compact section label used to title grouped content areas.
|
|
79
|
+
* Uses a composable API where you explicitly nest sub-components to define the layout.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* <SectionHeader>
|
|
83
|
+
* <SectionHeaderTitle>Label</SectionHeaderTitle>
|
|
84
|
+
* </SectionHeader>
|
|
85
|
+
*/
|
|
86
|
+
export const SectionHeader = ({
|
|
87
|
+
appearance = 'no-background',
|
|
88
|
+
lx,
|
|
89
|
+
style,
|
|
90
|
+
children,
|
|
91
|
+
...props
|
|
92
|
+
}: SectionHeaderProps) => {
|
|
93
|
+
const styles = useStyleSheet(
|
|
94
|
+
(t) => {
|
|
95
|
+
const appearanceStyles = {
|
|
96
|
+
'no-background': {},
|
|
97
|
+
plain: {
|
|
98
|
+
backgroundColor: t.colors.bg.surface,
|
|
99
|
+
paddingHorizontal: t.spacings.s8,
|
|
100
|
+
paddingVertical: t.spacings.s1,
|
|
101
|
+
borderRadius: t.borderRadius.xs,
|
|
102
|
+
},
|
|
103
|
+
} satisfies Record<SectionHeaderAppearance, ViewStyle>;
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
container: StyleSheet.flatten([
|
|
107
|
+
{
|
|
108
|
+
flexDirection: 'row',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
gap: t.spacings.s4,
|
|
111
|
+
minWidth: 0,
|
|
112
|
+
},
|
|
113
|
+
appearanceStyles[appearance],
|
|
114
|
+
]),
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
[appearance],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Box lx={lx} style={[styles.container, style]} {...props}>
|
|
122
|
+
{children}
|
|
123
|
+
</Box>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StyledTextProps, StyledViewProps } from '../../../styles';
|
|
3
|
+
|
|
4
|
+
export type SectionHeaderAppearance = 'no-background' | 'plain';
|
|
5
|
+
|
|
6
|
+
export type SectionHeaderProps = {
|
|
7
|
+
/**
|
|
8
|
+
* The visual style of the section header container.
|
|
9
|
+
* @default 'no-background'
|
|
10
|
+
*/
|
|
11
|
+
appearance?: SectionHeaderAppearance;
|
|
12
|
+
/**
|
|
13
|
+
* The children of the section header: SectionHeaderLeading and SectionHeaderTitle.
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
} & Omit<StyledViewProps, 'children'>;
|
|
17
|
+
|
|
18
|
+
export type SectionHeaderLeadingProps = {
|
|
19
|
+
/**
|
|
20
|
+
* Optional leading content such as an icon.
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
} & Omit<StyledViewProps, 'children'>;
|
|
24
|
+
|
|
25
|
+
export type SectionHeaderTitleProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The label text of the section header.
|
|
28
|
+
*/
|
|
29
|
+
children: string;
|
|
30
|
+
} & Omit<StyledTextProps, 'children'>;
|
|
@@ -24,8 +24,12 @@ figma.connect(
|
|
|
24
24
|
helperText: figma.nestedProps('.status', {
|
|
25
25
|
label: figma.string('label'),
|
|
26
26
|
}),
|
|
27
|
+
maxCount: figma.boolean('show-counter', {
|
|
28
|
+
true: figma.string('counter'),
|
|
29
|
+
false: undefined,
|
|
30
|
+
}),
|
|
27
31
|
},
|
|
28
|
-
example: (props) => (
|
|
32
|
+
example: (props: any) => (
|
|
29
33
|
<TextInput
|
|
30
34
|
disabled={props.disabled}
|
|
31
35
|
label={props.label}
|
|
@@ -33,6 +37,7 @@ figma.connect(
|
|
|
33
37
|
value={props.value}
|
|
34
38
|
helperText={props.helperText.label}
|
|
35
39
|
status={props.status}
|
|
40
|
+
maxCount={props.maxCount}
|
|
36
41
|
onChangeText={() => {}}
|
|
37
42
|
/>
|
|
38
43
|
),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
1
|
+
import { Meta, Canvas, Controls, Source } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import * as TextInputStories from './TextInput.stories';
|
|
3
3
|
import { TextInput } from './TextInput';
|
|
4
4
|
import { CustomTabs, Tab } from '../../../../.storybook/components';
|
|
@@ -60,6 +60,26 @@ The input supports error handling through `helperText` and `status` (`'error'` \
|
|
|
60
60
|
|
|
61
61
|
<Canvas of={TextInputStories.WithError} />
|
|
62
62
|
|
|
63
|
+
### Character Counter
|
|
64
|
+
|
|
65
|
+
Set `maxCount` to show a character counter below the input. The counter displays as `count/maxCount` on the bottom-right, sharing the row with helper text on the left.
|
|
66
|
+
|
|
67
|
+
Exceeding `maxCount` does not truncate input — this is a soft limit for visual feedback only. For hard truncation, use the native `maxLength` prop. The component does not change status on its own; handle validation in your app.
|
|
68
|
+
|
|
69
|
+
<Canvas of={TextInputStories.WithCounter} />
|
|
70
|
+
|
|
71
|
+
#### **Validation**
|
|
72
|
+
|
|
73
|
+
When the count exceeds `maxCount`, handle validation in your app — pass `status` and `helperText` yourself:
|
|
74
|
+
|
|
75
|
+
<Canvas of={TextInputStories.WithCounterExceeded} />
|
|
76
|
+
|
|
77
|
+
#### **Hard Limit with Native `maxLength`**
|
|
78
|
+
|
|
79
|
+
Pair `maxCount` with the native `maxLength` prop to hard-cap input at the same limit. The platform prevents typing beyond `maxLength`, so the counter never exceeds `maxCount`.
|
|
80
|
+
|
|
81
|
+
<Canvas of={TextInputStories.WithNativeMaxLength} />
|
|
82
|
+
|
|
63
83
|
### Disabled State
|
|
64
84
|
|
|
65
85
|
The input can be fully disabled using the `disabled` prop, which prevents interaction and applies a muted visual style.
|
|
@@ -133,16 +153,7 @@ Install and set up the library with our [Setup Guide →](?path=/docs/getting-st
|
|
|
133
153
|
|
|
134
154
|
### Basic Usage
|
|
135
155
|
|
|
136
|
-
|
|
137
|
-
import { TextInput } from '@ledgerhq/lumen-ui-rnative';
|
|
138
|
-
import { useState } from 'react';
|
|
139
|
-
|
|
140
|
-
function MyComponent() {
|
|
141
|
-
const [value, setValue] = useState('');
|
|
142
|
-
|
|
143
|
-
return <TextInput label='Username' value={value} onChangeText={setValue} />;
|
|
144
|
-
}
|
|
145
|
-
```
|
|
156
|
+
<Source of={TextInputStories.Base} />
|
|
146
157
|
|
|
147
158
|
> **Note:** Clear button appears automatically when input has content. Use `hideClearButton` to hide it.
|
|
148
159
|
|
|
@@ -150,81 +161,40 @@ function MyComponent() {
|
|
|
150
161
|
|
|
151
162
|
Use `hideClearButton` to prevent the clear button from appearing:
|
|
152
163
|
|
|
153
|
-
|
|
154
|
-
import { TextInput } from '@ledgerhq/lumen-ui-rnative';
|
|
155
|
-
import { useState } from 'react';
|
|
156
|
-
|
|
157
|
-
function MyComponent() {
|
|
158
|
-
const [value, setValue] = useState('');
|
|
159
|
-
|
|
160
|
-
return (
|
|
161
|
-
<TextInput
|
|
162
|
-
label='Username'
|
|
163
|
-
value={value}
|
|
164
|
-
onChangeText={setValue}
|
|
165
|
-
hideClearButton // Clear button will not appear
|
|
166
|
-
/>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
```
|
|
164
|
+
<Source of={TextInputStories.WithHiddenClearButton} />
|
|
170
165
|
|
|
171
166
|
#### **Extending the Clear Behavior**
|
|
172
167
|
|
|
173
168
|
Provide `onClear` to extend the default clear behavior with additional logic:
|
|
174
169
|
|
|
175
|
-
|
|
176
|
-
import { TextInput } from '@ledgerhq/lumen-ui-rnative';
|
|
177
|
-
import { useState } from 'react';
|
|
178
|
-
|
|
179
|
-
function MyComponent() {
|
|
180
|
-
const [value, setValue] = useState('');
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<TextInput
|
|
184
|
-
label='Search'
|
|
185
|
-
value={value}
|
|
186
|
-
onChangeText={setValue}
|
|
187
|
-
onClear={() => {
|
|
188
|
-
// Default clearing happens automatically
|
|
189
|
-
// Add your custom logic here
|
|
190
|
-
analytics.track('search_cleared');
|
|
191
|
-
}}
|
|
192
|
-
/>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
```
|
|
170
|
+
<Source of={TextInputStories.WithClearCallback} />
|
|
196
171
|
|
|
197
172
|
### With Error State
|
|
198
173
|
|
|
199
174
|
The Input component supports error states and messages:
|
|
200
175
|
|
|
201
|
-
|
|
202
|
-
import { TextInput } from '@ledgerhq/lumen-ui-rnative';
|
|
203
|
-
import { useState } from 'react';
|
|
204
|
-
|
|
205
|
-
function MyComponent() {
|
|
206
|
-
const [value, setValue] = useState('');
|
|
207
|
-
const [error, setError] = useState('');
|
|
208
|
-
|
|
209
|
-
const handleChange = (text: string) => {
|
|
210
|
-
setValue(text);
|
|
211
|
-
setError(text.length < 3 ? 'Must be at least 3 characters' : '');
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<TextInput
|
|
216
|
-
label='Username'
|
|
217
|
-
value={value}
|
|
218
|
-
onChangeText={handleChange}
|
|
219
|
-
helperText={error || undefined}
|
|
220
|
-
status={error ? 'error' : undefined}
|
|
221
|
-
/>
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
```
|
|
176
|
+
<Source of={TextInputStories.WithError} />
|
|
225
177
|
|
|
226
178
|
> **Note:** Helper text is optional. Use `helperText` with `status="error"` to show validation feedback below the input.
|
|
227
179
|
|
|
180
|
+
### With Character Counter
|
|
181
|
+
|
|
182
|
+
Set `maxCount` to enable the character counter. Exceeding the limit does not truncate input.
|
|
183
|
+
|
|
184
|
+
<Source of={TextInputStories.WithCounter} />
|
|
185
|
+
|
|
186
|
+
### With Character Counter Validation
|
|
187
|
+
|
|
188
|
+
When the count exceeds `maxCount`, handle validation in your app — pass `status` and `helperText` yourself:
|
|
189
|
+
|
|
190
|
+
<Source of={TextInputStories.WithCounterExceeded} />
|
|
191
|
+
|
|
192
|
+
### With Native `maxLength` Hard Limit
|
|
193
|
+
|
|
194
|
+
Combine `maxCount` with the native `maxLength` prop to hard-cap the input. The platform blocks input beyond `maxLength`, keeping the counter within bounds:
|
|
195
|
+
|
|
196
|
+
<Source of={TextInputStories.WithNativeMaxLength} />
|
|
197
|
+
|
|
228
198
|
### With Custom Styling
|
|
229
199
|
|
|
230
200
|
While the component comes with predefined styles, you can extend them using the `style` prop:
|
|
@@ -13,7 +13,7 @@ const meta: Meta<typeof TextInput> = {
|
|
|
13
13
|
source: {
|
|
14
14
|
language: 'tsx',
|
|
15
15
|
format: true,
|
|
16
|
-
type: '
|
|
16
|
+
type: 'dynamic',
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
},
|
|
@@ -90,6 +90,62 @@ export const WithError: Story = {
|
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
export const WithCounter: Story = {
|
|
94
|
+
render: (args) => <TextInputStory {...args} />,
|
|
95
|
+
args: {
|
|
96
|
+
label: 'Label',
|
|
97
|
+
helperText: 'Info text',
|
|
98
|
+
maxCount: 32,
|
|
99
|
+
editable: true,
|
|
100
|
+
hideClearButton: false,
|
|
101
|
+
keyboardType: 'default',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const WithCounterExceeded: Story = {
|
|
106
|
+
render: () => {
|
|
107
|
+
const [value, setValue] = useState('This text exceeds the character limit');
|
|
108
|
+
const maxCount = 32;
|
|
109
|
+
const isOverLimit = value.length > maxCount;
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<View
|
|
113
|
+
style={{
|
|
114
|
+
flex: 1,
|
|
115
|
+
minHeight: 96,
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
justifyContent: 'center',
|
|
118
|
+
padding: 24,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
<View style={{ width: '100%', maxWidth: 400 }}>
|
|
122
|
+
<TextInput
|
|
123
|
+
label='Label'
|
|
124
|
+
value={value}
|
|
125
|
+
onChangeText={setValue}
|
|
126
|
+
helperText={isOverLimit ? 'Character limit exceeded' : 'Info text'}
|
|
127
|
+
status={isOverLimit ? 'error' : undefined}
|
|
128
|
+
maxCount={maxCount}
|
|
129
|
+
/>
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const WithNativeMaxLength: Story = {
|
|
137
|
+
render: (args) => <TextInputStory {...args} />,
|
|
138
|
+
args: {
|
|
139
|
+
label: 'Label',
|
|
140
|
+
helperText: 'Input is capped at 8 characters',
|
|
141
|
+
maxLength: 8,
|
|
142
|
+
maxCount: 8,
|
|
143
|
+
editable: true,
|
|
144
|
+
hideClearButton: false,
|
|
145
|
+
keyboardType: 'default',
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
93
149
|
export const WithSuccess: Story = {
|
|
94
150
|
render: (args) => (
|
|
95
151
|
<TextInputStory
|