@utilitywarehouse/hearth-react-native 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +3 -1
- package/CHANGELOG.md +34 -0
- package/build/components/Alert/AlertCloseButton.js +25 -3
- package/build/components/Alert/AlertIcon.js +17 -1
- package/build/components/Alert/AlertIconButton.js +27 -1
- package/build/components/Alert/AlertLink.js +47 -1
- package/build/components/Alert/AlertText.d.ts +1 -1
- package/build/components/Alert/AlertText.js +26 -2
- package/build/components/Alert/AlertTitle.d.ts +1 -1
- package/build/components/Alert/AlertTitle.js +26 -2
- package/build/components/Badge/Badge.js +101 -14
- package/build/components/Badge/Badge.props.d.ts +2 -2
- package/build/components/Badge/BadgeIcon.js +27 -29
- package/build/components/Badge/BadgeText.js +29 -31
- package/build/components/Button/Button.d.ts +2 -2
- package/build/components/Button/ButtonGroupRoot.d.ts +3 -2
- package/build/components/Button/ButtonGroupRoot.js +9 -0
- package/build/components/Button/ButtonRoot.js +1 -0
- package/build/components/Card/Card.props.d.ts +2 -2
- package/build/components/Checkbox/Checkbox.d.ts +2 -2
- package/build/components/Checkbox/Checkbox.js +11 -10
- package/build/components/Checkbox/Checkbox.props.d.ts +3 -1
- package/build/components/Checkbox/CheckboxIcon.js +1 -1
- package/build/components/Checkbox/CheckboxImage.d.ts +6 -0
- package/build/components/Checkbox/CheckboxImage.js +5 -0
- package/build/components/Checkbox/CheckboxTileRoot.js +1 -1
- package/build/components/Checkbox/index.d.ts +3 -2
- package/build/components/Checkbox/index.js +2 -1
- package/build/components/CurrencyInput/CurrencyInput.d.ts +6 -0
- package/build/components/CurrencyInput/CurrencyInput.js +47 -0
- package/build/components/CurrencyInput/CurrencyInput.props.d.ts +14 -0
- package/build/components/CurrencyInput/CurrencyInput.props.js +1 -0
- package/build/components/CurrencyInput/index.d.ts +1 -0
- package/build/components/CurrencyInput/index.js +1 -0
- package/build/components/DescriptionList/DescriptionList.context.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionList.context.js +9 -0
- package/build/components/DescriptionList/DescriptionList.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionList.js +25 -0
- package/build/components/DescriptionList/DescriptionList.props.d.ts +18 -0
- package/build/components/DescriptionList/DescriptionList.props.js +1 -0
- package/build/components/DescriptionList/DescriptionListItem.d.ts +6 -0
- package/build/components/DescriptionList/DescriptionListItem.js +49 -0
- package/build/components/DescriptionList/DescriptionListItem.props.d.ts +17 -0
- package/build/components/DescriptionList/DescriptionListItem.props.js +1 -0
- package/build/components/DescriptionList/index.d.ts +4 -0
- package/build/components/DescriptionList/index.js +2 -0
- package/build/components/Divider/Divider.js +46 -0
- package/build/components/Divider/Divider.props.d.ts +2 -2
- package/build/components/Flex/Flex.props.d.ts +3 -2
- package/build/components/Grid/Grid.props.d.ts +2 -2
- package/build/components/IconContainer/IconContainer.d.ts +5 -0
- package/build/components/IconContainer/IconContainer.js +161 -0
- package/build/components/IconContainer/IconContainer.props.d.ts +15 -0
- package/build/components/IconContainer/IconContainer.props.js +1 -0
- package/build/components/IconContainer/index.d.ts +2 -0
- package/build/components/IconContainer/index.js +1 -0
- package/build/components/Icons/CircleIcon.js +3 -3
- package/build/components/Input/Input.js +2 -34
- package/build/components/Input/Input.props.d.ts +1 -17
- package/build/components/Input/InputField.js +0 -7
- package/build/components/Link/Link.d.ts +1 -1
- package/build/components/Link/Link.js +4 -4
- package/build/components/Link/Link.props.d.ts +3 -0
- package/build/components/Modal/Modal.js +17 -1
- package/build/components/Radio/Radio.d.ts +2 -2
- package/build/components/Radio/Radio.js +9 -8
- package/build/components/Radio/Radio.props.d.ts +3 -1
- package/build/components/Radio/RadioImage.d.ts +6 -0
- package/build/components/Radio/RadioImage.js +5 -0
- package/build/components/Radio/RadioTileRoot.js +1 -1
- package/build/components/Radio/index.d.ts +3 -2
- package/build/components/Radio/index.js +2 -1
- package/build/components/SectionHeader/SectionHeader.js +1 -0
- package/build/components/Select/SelectOption.js +1 -7
- package/build/components/Tabs/Tab.d.ts +18 -0
- package/build/components/Tabs/Tab.js +74 -0
- package/build/components/Tabs/Tab.props.d.ts +14 -0
- package/build/components/Tabs/Tab.props.js +1 -0
- package/build/components/Tabs/TabPanel.d.ts +3 -0
- package/build/components/Tabs/TabPanel.js +34 -0
- package/build/components/Tabs/TabPanel.props.d.ts +8 -0
- package/build/components/Tabs/TabPanel.props.js +1 -0
- package/build/components/Tabs/Tabs.context.d.ts +23 -0
- package/build/components/Tabs/Tabs.context.js +8 -0
- package/build/components/Tabs/Tabs.d.ts +6 -0
- package/build/components/Tabs/Tabs.js +114 -0
- package/build/components/Tabs/Tabs.props.d.ts +19 -0
- package/build/components/Tabs/Tabs.props.js +1 -0
- package/build/components/Tabs/TabsList.d.ts +6 -0
- package/build/components/Tabs/TabsList.js +112 -0
- package/build/components/Tabs/TabsList.props.d.ts +6 -0
- package/build/components/Tabs/TabsList.props.js +1 -0
- package/build/components/Tabs/index.d.ts +8 -0
- package/build/components/Tabs/index.js +4 -0
- package/build/components/UnstyledIconButton/UnstyledIconButton.d.ts +1 -1
- package/build/components/UnstyledIconButton/UnstyledIconButton.js +4 -4
- package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +2 -1
- package/build/components/index.d.ts +4 -0
- package/build/components/index.js +4 -0
- package/build/core/themes.d.ts +428 -160
- package/build/core/themes.js +57 -1
- package/build/tokens/color.d.ts +88 -80
- package/build/tokens/color.js +44 -40
- package/build/tokens/components/dark/alert.d.ts +13 -0
- package/build/tokens/components/dark/alert.js +13 -0
- package/build/tokens/components/dark/button.d.ts +1 -0
- package/build/tokens/components/dark/button.js +1 -0
- package/build/tokens/components/dark/checkbox.d.ts +4 -1
- package/build/tokens/components/dark/checkbox.js +4 -1
- package/build/tokens/components/dark/icon-button.d.ts +10 -3
- package/build/tokens/components/dark/icon-button.js +10 -3
- package/build/tokens/components/dark/index.d.ts +1 -0
- package/build/tokens/components/dark/index.js +1 -0
- package/build/tokens/components/dark/link.d.ts +5 -0
- package/build/tokens/components/dark/link.js +5 -0
- package/build/tokens/components/dark/progress-bar.d.ts +41 -0
- package/build/tokens/components/dark/progress-bar.js +40 -0
- package/build/tokens/components/dark/radio.d.ts +1 -1
- package/build/tokens/components/dark/radio.js +1 -1
- package/build/tokens/components/dark/tabs.d.ts +2 -0
- package/build/tokens/components/dark/tabs.js +2 -0
- package/build/tokens/components/light/alert.d.ts +13 -0
- package/build/tokens/components/light/alert.js +13 -0
- package/build/tokens/components/light/badge.d.ts +1 -1
- package/build/tokens/components/light/badge.js +1 -1
- package/build/tokens/components/light/button.d.ts +1 -0
- package/build/tokens/components/light/button.js +1 -0
- package/build/tokens/components/light/checkbox.d.ts +6 -3
- package/build/tokens/components/light/checkbox.js +6 -3
- package/build/tokens/components/light/icon-button.d.ts +8 -1
- package/build/tokens/components/light/icon-button.js +8 -1
- package/build/tokens/components/light/index.d.ts +1 -0
- package/build/tokens/components/light/index.js +1 -0
- package/build/tokens/components/light/link.d.ts +5 -0
- package/build/tokens/components/light/link.js +5 -0
- package/build/tokens/components/light/progress-bar.d.ts +41 -0
- package/build/tokens/components/light/progress-bar.js +40 -0
- package/build/tokens/components/light/radio.d.ts +3 -3
- package/build/tokens/components/light/radio.js +3 -3
- package/build/tokens/components/light/tabs.d.ts +2 -0
- package/build/tokens/components/light/tabs.js +2 -0
- package/build/tokens/index.d.ts +1 -0
- package/build/tokens/index.js +1 -0
- package/build/tokens/layout.d.ts +48 -30
- package/build/tokens/layout.js +24 -15
- package/build/tokens/motion.d.ts +23 -0
- package/build/tokens/motion.js +22 -0
- package/build/tokens/primitive.d.ts +19 -0
- package/build/tokens/primitive.js +19 -0
- package/build/tokens/semantic-dark.d.ts +26 -24
- package/build/tokens/semantic-dark.js +26 -24
- package/build/tokens/semantic-light.d.ts +18 -16
- package/build/tokens/semantic-light.js +18 -16
- package/build/types/values.d.ts +2 -1
- package/build/utils/formatThousands.d.ts +2 -0
- package/build/utils/formatThousands.js +16 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/docs/assets/bank-logo.png +0 -0
- package/docs/assets/bank-logo1.png +0 -0
- package/docs/components/AllComponents.web.tsx +97 -8
- package/docs/components/NextPrevPage.tsx +11 -3
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/components/index.ts +6 -7
- package/docs/heplers/addReactNativePrefix.ts +8 -0
- package/docs/heplers/index.ts +1 -0
- package/docs/introduction.mdx +3 -3
- package/docs/theme-tokens.mdx +42 -0
- package/package.json +13 -13
- package/src/components/Alert/AlertCloseButton.tsx +33 -5
- package/src/components/Alert/AlertIcon.tsx +17 -1
- package/src/components/Alert/AlertIconButton.tsx +37 -4
- package/src/components/Alert/AlertLink.tsx +52 -1
- package/src/components/Alert/AlertText.tsx +28 -3
- package/src/components/Alert/AlertTitle.tsx +28 -3
- package/src/components/Badge/Badge.docs.mdx +7 -7
- package/src/components/Badge/Badge.props.ts +3 -2
- package/src/components/Badge/Badge.stories.tsx +81 -92
- package/src/components/Badge/Badge.tsx +101 -14
- package/src/components/Badge/BadgeIcon.tsx +27 -29
- package/src/components/Badge/BadgeText.tsx +29 -31
- package/src/components/Button/ButtonGroupRoot.tsx +12 -2
- package/src/components/Button/ButtonRoot.tsx +1 -0
- package/src/components/Card/Card.docs.mdx +1 -1
- package/src/components/Card/Card.props.ts +2 -2
- package/src/components/Checkbox/Checkbox.docs.mdx +45 -7
- package/src/components/Checkbox/Checkbox.props.ts +3 -1
- package/src/components/Checkbox/Checkbox.stories.tsx +37 -1
- package/src/components/Checkbox/Checkbox.tsx +12 -9
- package/src/components/Checkbox/CheckboxIcon.tsx +1 -1
- package/src/components/Checkbox/CheckboxImage.tsx +9 -0
- package/src/components/Checkbox/CheckboxTileRoot.tsx +1 -1
- package/src/components/Checkbox/index.ts +3 -2
- package/src/components/CurrencyInput/CurrencyInput.docs.mdx +120 -0
- package/src/components/CurrencyInput/CurrencyInput.props.ts +19 -0
- package/src/components/CurrencyInput/CurrencyInput.stories.tsx +116 -0
- package/src/components/CurrencyInput/CurrencyInput.tsx +91 -0
- package/src/components/CurrencyInput/index.ts +1 -0
- package/src/components/DescriptionList/DescriptionList.context.ts +18 -0
- package/src/components/DescriptionList/DescriptionList.docs.mdx +98 -0
- package/src/components/DescriptionList/DescriptionList.props.ts +20 -0
- package/src/components/DescriptionList/DescriptionList.stories.tsx +154 -0
- package/src/components/DescriptionList/DescriptionList.tsx +64 -0
- package/src/components/DescriptionList/DescriptionListItem.props.ts +19 -0
- package/src/components/DescriptionList/DescriptionListItem.tsx +101 -0
- package/src/components/DescriptionList/index.ts +4 -0
- package/src/components/Divider/Divider.props.ts +2 -2
- package/src/components/Divider/Divider.stories.tsx +3 -3
- package/src/components/Divider/Divider.tsx +46 -0
- package/src/components/Flex/Flex.docs.mdx +4 -4
- package/src/components/Flex/Flex.props.ts +3 -2
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Grid/Grid.docs.mdx +12 -12
- package/src/components/Grid/Grid.props.ts +2 -2
- package/src/components/Grid/Grid.stories.tsx +2 -2
- package/src/components/IconContainer/IconContainer.docs.mdx +90 -0
- package/src/components/IconContainer/IconContainer.props.ts +17 -0
- package/src/components/IconContainer/IconContainer.stories.tsx +130 -0
- package/src/components/IconContainer/IconContainer.tsx +180 -0
- package/src/components/IconContainer/index.tsx +2 -0
- package/src/components/Icons/CircleIcon.tsx +9 -11
- package/src/components/Input/Input.docs.mdx +3 -3
- package/src/components/Input/Input.props.ts +0 -20
- package/src/components/Input/Input.stories.tsx +0 -6
- package/src/components/Input/Input.tsx +2 -49
- package/src/components/Input/InputField.tsx +0 -7
- package/src/components/Link/Link.props.ts +3 -0
- package/src/components/Link/Link.tsx +12 -6
- package/src/components/List/List.docs.mdx +24 -23
- package/src/components/Modal/Modal.tsx +18 -0
- package/src/components/Radio/Radio.docs.mdx +96 -124
- package/src/components/Radio/Radio.props.ts +3 -1
- package/src/components/Radio/Radio.stories.tsx +47 -0
- package/src/components/Radio/Radio.tsx +10 -7
- package/src/components/Radio/RadioImage.tsx +9 -0
- package/src/components/Radio/RadioTileRoot.tsx +1 -1
- package/src/components/Radio/index.ts +3 -2
- package/src/components/SectionHeader/SectionHeader.tsx +1 -0
- package/src/components/Select/Select.docs.mdx +6 -6
- package/src/components/Select/Select.stories.tsx +7 -7
- package/src/components/Select/SelectOption.tsx +4 -10
- package/src/components/Tabs/Tab.props.ts +16 -0
- package/src/components/Tabs/Tab.tsx +113 -0
- package/src/components/Tabs/TabPanel.props.ts +10 -0
- package/src/components/Tabs/TabPanel.tsx +46 -0
- package/src/components/Tabs/Tabs.context.ts +26 -0
- package/src/components/Tabs/Tabs.docs.mdx +214 -0
- package/src/components/Tabs/Tabs.props.ts +21 -0
- package/src/components/Tabs/Tabs.stories.tsx +270 -0
- package/src/components/Tabs/Tabs.tsx +139 -0
- package/src/components/Tabs/TabsList.props.ts +8 -0
- package/src/components/Tabs/TabsList.tsx +194 -0
- package/src/components/Tabs/index.ts +8 -0
- package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
- package/src/components/UnstyledIconButton/UnstyledIconButton.tsx +9 -3
- package/src/components/index.ts +4 -0
- package/src/core/themes.ts +57 -1
- package/src/tokens/color.ts +44 -40
- package/src/tokens/components/dark/alert.ts +13 -0
- package/src/tokens/components/dark/button.ts +1 -0
- package/src/tokens/components/dark/checkbox.ts +4 -1
- package/src/tokens/components/dark/icon-button.ts +10 -3
- package/src/tokens/components/dark/index.ts +1 -0
- package/src/tokens/components/dark/link.ts +5 -0
- package/src/tokens/components/dark/progress-bar.ts +41 -0
- package/src/tokens/components/dark/radio.ts +1 -1
- package/src/tokens/components/dark/tabs.ts +2 -0
- package/src/tokens/components/light/alert.ts +13 -0
- package/src/tokens/components/light/badge.ts +1 -1
- package/src/tokens/components/light/button.ts +1 -0
- package/src/tokens/components/light/checkbox.ts +6 -3
- package/src/tokens/components/light/icon-button.ts +8 -1
- package/src/tokens/components/light/index.ts +1 -0
- package/src/tokens/components/light/link.ts +5 -0
- package/src/tokens/components/light/progress-bar.ts +41 -0
- package/src/tokens/components/light/radio.ts +3 -3
- package/src/tokens/components/light/tabs.ts +2 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/layout.ts +24 -15
- package/src/tokens/motion.ts +23 -0
- package/src/tokens/primitive.ts +19 -0
- package/src/tokens/semantic-dark.ts +26 -24
- package/src/tokens/semantic-light.ts +18 -16
- package/src/types/values.ts +3 -1
- package/src/utils/formatThousands.ts +14 -0
- package/src/utils/index.ts +1 -0
- package/docs/assets/react-native-pig.png +0 -0
- package/docs/components/AdvancedRadioExample.tsx +0 -126
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
3
|
import {
|
|
4
|
+
Box,
|
|
5
|
+
Center,
|
|
4
6
|
Radio,
|
|
5
7
|
RadioGroup,
|
|
6
|
-
RadioIndicator,
|
|
7
8
|
RadioIcon,
|
|
9
|
+
RadioImage,
|
|
10
|
+
RadioIndicator,
|
|
8
11
|
RadioLabel,
|
|
9
|
-
Center,
|
|
10
|
-
Box,
|
|
11
12
|
RadioTile,
|
|
12
13
|
} from '../../';
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
UsageWrap,
|
|
18
|
-
AdvancedRadioExample,
|
|
19
|
-
} from '../../../docs/components';
|
|
14
|
+
import mastercardLogo from '../../../docs/assets/bank-logo.png';
|
|
15
|
+
import visaLogo from '../../../docs/assets/bank-logo1.png';
|
|
16
|
+
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
17
|
+
import * as Stories from './Radio.stories';
|
|
20
18
|
|
|
21
19
|
<Meta title="Forms / Radio" />
|
|
22
20
|
|
|
@@ -38,10 +36,12 @@ The Radio component presents users with predefined choices and enables them to s
|
|
|
38
36
|
- [`RadioIcon`](#radioicon)
|
|
39
37
|
- [`RadioLabel`](#radiolabel)
|
|
40
38
|
- [`RadioGroup`](#radiogroup)
|
|
39
|
+
- [`RadioImage`](#radioimage)
|
|
41
40
|
- [Variants](#variants)
|
|
42
41
|
- [Advanced Usage](#advanced-usage)
|
|
43
42
|
- [Examples](#examples)
|
|
44
43
|
- [`RadioTile` component](#radiotile-component)
|
|
44
|
+
- [`RadioImage` component](#radioimage-component)
|
|
45
45
|
- [`RadioGroup` component](#radiogroup-component)
|
|
46
46
|
|
|
47
47
|
## Playground
|
|
@@ -104,6 +104,7 @@ const MyComponent = () => {
|
|
|
104
104
|
| `validText` | `string` | - | The valid text to be displayed below the radio. |
|
|
105
105
|
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
106
106
|
| `type` | `'default' \| 'tile'` | `default` | The type of the radio. |
|
|
107
|
+
| `image` | `ImageProps` | - | The image to be displayed next to the label. |
|
|
107
108
|
|
|
108
109
|
## Components
|
|
109
110
|
|
|
@@ -147,6 +148,10 @@ Contains all Group related layout style props and actions. It inherits all the p
|
|
|
147
148
|
| `direction` | `'row' \| 'column'` | `column` | The direction of the radio group. |
|
|
148
149
|
| `gap` | `string` | - | The gap between the radio group items. |
|
|
149
150
|
|
|
151
|
+
### `RadioImage`
|
|
152
|
+
|
|
153
|
+
Contains all Image related layout style props and actions. It inherits all the properties of React Native's [Image component](https://reactnative.dev/docs/image).
|
|
154
|
+
|
|
150
155
|
## Variants
|
|
151
156
|
|
|
152
157
|
<Canvas of={Stories.Variants} />
|
|
@@ -158,133 +163,65 @@ In this example, we will create a custom Radio component with a badge and bullet
|
|
|
158
163
|
|
|
159
164
|
<UsageWrap>
|
|
160
165
|
<Center>
|
|
161
|
-
<
|
|
166
|
+
<RadioGroup type="tile" aria-label="Radio Group" nativeID="Radio-group">
|
|
167
|
+
<Radio value="option-1" aria-label="Label 1">
|
|
168
|
+
<RadioIndicator>
|
|
169
|
+
<RadioIcon />
|
|
170
|
+
</RadioIndicator>
|
|
171
|
+
<RadioImage source={visaLogo} style={{ width: 40, height: 24, resizeMode: 'contain' }} />
|
|
172
|
+
<RadioLabel>Visa</RadioLabel>
|
|
173
|
+
</Radio>
|
|
174
|
+
<Radio value="option-2" aria-label="Label 2">
|
|
175
|
+
<RadioIndicator>
|
|
176
|
+
<RadioIcon />
|
|
177
|
+
</RadioIndicator>
|
|
178
|
+
<RadioImage
|
|
179
|
+
source={mastercardLogo}
|
|
180
|
+
style={{ width: 40, height: 24, resizeMode: 'contain' }}
|
|
181
|
+
/>
|
|
182
|
+
<RadioLabel>Mastercard</RadioLabel>
|
|
183
|
+
</Radio>
|
|
184
|
+
</RadioGroup>
|
|
162
185
|
</Center>
|
|
163
186
|
</UsageWrap>
|
|
164
187
|
|
|
165
188
|
```tsx
|
|
166
189
|
import {
|
|
167
|
-
Badge,
|
|
168
|
-
Heading,
|
|
169
190
|
Radio,
|
|
170
191
|
RadioGroup,
|
|
171
|
-
|
|
192
|
+
RadioLabel,
|
|
172
193
|
RadioIndicator,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} from '../../src';
|
|
194
|
+
RadioIcon,
|
|
195
|
+
RadioImage,
|
|
196
|
+
} from '@utilitywarehouse/native-ui';
|
|
177
197
|
import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
198
|
+
import visaLogo from '../../assets/bank-logo1.png';
|
|
199
|
+
import mastercardLogo from '../../assets/bank-logo.png';
|
|
178
200
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
interface RadioProps {
|
|
182
|
-
currentValue: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const styles = StyleSheet.create(({ colorMode, color, borderRadius, borderWidth, space }) => ({
|
|
186
|
-
radio: {
|
|
187
|
-
borderWidth: borderWidth[2],
|
|
188
|
-
borderColor: colorMode === 'light' ? color.grey[500] : color.grey[700],
|
|
189
|
-
borderRadius: borderRadius.xl,
|
|
190
|
-
padding: space[200],
|
|
191
|
-
variants: {
|
|
192
|
-
checked: {
|
|
193
|
-
true: {
|
|
194
|
-
borderColor: colorMode === 'light' ? color.green[500] : color.green[700],
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
indicator: {
|
|
200
|
-
variants: {
|
|
201
|
-
checked: {
|
|
202
|
-
true: {
|
|
203
|
-
backgroundColor: colorMode === 'light' ? color.green[500] : color.green[700],
|
|
204
|
-
borderColor: colorMode === 'light' ? color.green[500] : color.green[700],
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
heading: {
|
|
210
|
-
marginBottom: space[100],
|
|
211
|
-
},
|
|
212
|
-
badge: {
|
|
213
|
-
marginRight: space[200],
|
|
214
|
-
alignSelf: 'flex-end',
|
|
215
|
-
},
|
|
216
|
-
}));
|
|
217
|
-
|
|
218
|
-
const CustomRadio: React.FC<
|
|
219
|
-
RadioProps &
|
|
220
|
-
Omit<
|
|
221
|
-
NativeUIRadioProps,
|
|
222
|
-
'label' | 'helperText' | 'helperIcon' | 'invalidText' | 'validText' | 'showValidationIcon'
|
|
223
|
-
>
|
|
224
|
-
> = ({ children, currentValue, ...props }) => {
|
|
225
|
-
styles.useVariants({ checked: currentValue === props.value });
|
|
201
|
+
const AdvancedExample = () => {
|
|
202
|
+
const [value, setValue] = React.useState('option-1');
|
|
226
203
|
return (
|
|
227
|
-
<
|
|
228
|
-
<
|
|
229
|
-
<
|
|
230
|
-
|
|
231
|
-
</Box>
|
|
232
|
-
<RadioIndicator style={styles.indicator}>
|
|
233
|
-
<RadioIcon as={TickSmallIcon} color="white" />
|
|
204
|
+
<RadioGroup value={value} onChange={setValue} aria-label="Card type" type="tile">
|
|
205
|
+
<Radio value="option-1" aria-label="Visa">
|
|
206
|
+
<RadioIndicator>
|
|
207
|
+
<RadioIcon />
|
|
234
208
|
</RadioIndicator>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
{children}
|
|
249
|
-
</Box>
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
const AdvancedRadioExample: React.FC = () => {
|
|
253
|
-
const [value, setValue] = React.useState('Option 1');
|
|
254
|
-
|
|
255
|
-
const handleChange = (val: string) => setValue(val);
|
|
256
|
-
|
|
257
|
-
return (
|
|
258
|
-
<RadioGroup onChange={handleChange} value={value} gap="200">
|
|
259
|
-
<Box>
|
|
260
|
-
<Badge colorScheme={value === 'Option 1' ? 'green' : 'grey'} flatBase style={styles.badge}>
|
|
261
|
-
Recommended
|
|
262
|
-
</Badge>
|
|
263
|
-
<CustomRadio value="Option 1" currentValue={value}>
|
|
264
|
-
<Heading size="md" style={styles.heading}>
|
|
265
|
-
Instant bank transfer
|
|
266
|
-
</Heading>
|
|
267
|
-
<BulletList>
|
|
268
|
-
<BulletListItem>Receive your money instantly</BulletListItem>
|
|
269
|
-
<BulletListItem>No fees</BulletListItem>
|
|
270
|
-
<BulletListItem>Available 24/7</BulletListItem>
|
|
271
|
-
</BulletList>
|
|
272
|
-
</CustomRadio>
|
|
273
|
-
</Box>
|
|
274
|
-
<CustomRadio value="Option 2" currentValue={value}>
|
|
275
|
-
<Heading size="md" style={styles.heading}>
|
|
276
|
-
Debit card payment
|
|
277
|
-
</Heading>
|
|
278
|
-
<BulletList>
|
|
279
|
-
<BulletListItem>£0.35 fee</BulletListItem>
|
|
280
|
-
<BulletListItem>Available 24/7</BulletListItem>
|
|
281
|
-
</BulletList>
|
|
282
|
-
</CustomRadio>
|
|
209
|
+
<RadioImage source={visaLogo} style={{ width: 40, height: 24, resizeMode: 'contain' }} />
|
|
210
|
+
<RadioLabel>Visa</RadioLabel>
|
|
211
|
+
</Radio>
|
|
212
|
+
<Radio value="option-2" aria-label="Mastercard">
|
|
213
|
+
<RadioIndicator>
|
|
214
|
+
<RadioIcon />
|
|
215
|
+
</RadioIndicator>
|
|
216
|
+
<RadioImage
|
|
217
|
+
source={mastercardLogo}
|
|
218
|
+
style={{ width: 40, height: 24, resizeMode: 'contain' }}
|
|
219
|
+
/>
|
|
220
|
+
<RadioLabel>Mastercard</RadioLabel>
|
|
221
|
+
</Radio>
|
|
283
222
|
</RadioGroup>
|
|
284
223
|
);
|
|
285
224
|
};
|
|
286
|
-
|
|
287
|
-
export default AdvancedRadioExample;
|
|
288
225
|
```
|
|
289
226
|
|
|
290
227
|
## Examples
|
|
@@ -317,6 +254,41 @@ const MyComponent = () => {
|
|
|
317
254
|
};
|
|
318
255
|
```
|
|
319
256
|
|
|
257
|
+
### `RadioImage` component
|
|
258
|
+
|
|
259
|
+
The `RadioImage` component is used to display an image next to the radio button.
|
|
260
|
+
|
|
261
|
+
<Canvas of={Stories.WithImage} />
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
import { Radio, RadioGroup } from '@utilitywarehouse/native-ui';
|
|
265
|
+
import visaLogo from './visa-logo.png';
|
|
266
|
+
import mastarcardLogo from './mastercard-logo.png';
|
|
267
|
+
|
|
268
|
+
const MyComponent = () => {
|
|
269
|
+
const [value, setValue] = React.useState('Option 1');
|
|
270
|
+
return (
|
|
271
|
+
<RadioGroup value={value} onChange={setValue} aria-label="Radio Group" nativeID="Radio-group">
|
|
272
|
+
<Radio
|
|
273
|
+
value="visa"
|
|
274
|
+
aria-label="Visa"
|
|
275
|
+
label="Visa"
|
|
276
|
+
image={{ source: visaLogo, style: { width: 40, height: 24, resizeMode: 'contain' } }}
|
|
277
|
+
/>
|
|
278
|
+
<Radio
|
|
279
|
+
value="mastercard"
|
|
280
|
+
aria-label="Mastercard"
|
|
281
|
+
label="Mastercard"
|
|
282
|
+
image={{
|
|
283
|
+
source: mastarcardLogo,
|
|
284
|
+
style: { width: 40, height: 24, resizeMode: 'contain' },
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
</RadioGroup>
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
```
|
|
291
|
+
|
|
320
292
|
### `RadioGroup` component
|
|
321
293
|
|
|
322
294
|
The `RadioGroup` component is used to group multiple `Radio` components together.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type { PressableProps, ViewProps } from 'react-native';
|
|
2
|
+
import type { ImageProps, PressableProps, ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
4
|
interface RadioBaseProps extends Omit<PressableProps, 'children'> {
|
|
5
5
|
value: string;
|
|
@@ -17,6 +17,7 @@ interface RadioWithChildrenProps extends RadioBaseProps {
|
|
|
17
17
|
invalidText?: never;
|
|
18
18
|
validText?: never;
|
|
19
19
|
showValidationIcon?: never;
|
|
20
|
+
image?: never;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
interface RadioWithoutChildrenProps extends RadioBaseProps {
|
|
@@ -27,6 +28,7 @@ interface RadioWithoutChildrenProps extends RadioBaseProps {
|
|
|
27
28
|
invalidText?: string;
|
|
28
29
|
validText?: string;
|
|
29
30
|
showValidationIcon?: boolean;
|
|
31
|
+
image?: ImageProps;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
type RadioProps = RadioWithChildrenProps | RadioWithoutChildrenProps;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
+
import { ImageSourcePropType } from 'react-native';
|
|
3
4
|
import { Radio, RadioGroup } from '.';
|
|
5
|
+
import bankLogo from '../../../docs/assets/bank-logo.png';
|
|
6
|
+
import bankLogo1 from '../../../docs/assets/bank-logo1.png';
|
|
4
7
|
import { VariantTitle } from '../../../docs/components';
|
|
5
8
|
import { Flex } from '../Flex';
|
|
6
9
|
|
|
@@ -84,6 +87,50 @@ export const Playground: Story = {
|
|
|
84
87
|
),
|
|
85
88
|
};
|
|
86
89
|
|
|
90
|
+
export const WithImage: Story = {
|
|
91
|
+
parameters: {
|
|
92
|
+
controls: { exclude: ['image'] },
|
|
93
|
+
},
|
|
94
|
+
args: {
|
|
95
|
+
value: 'Option 1',
|
|
96
|
+
label: 'Label',
|
|
97
|
+
},
|
|
98
|
+
render: ({ children, ...args }) => (
|
|
99
|
+
<RadioGroup>
|
|
100
|
+
<Radio
|
|
101
|
+
aria-label="Label 1"
|
|
102
|
+
onChange={(checked: boolean) => {
|
|
103
|
+
console.log(checked, '###');
|
|
104
|
+
}}
|
|
105
|
+
nativeID="Radio-1"
|
|
106
|
+
{...args}
|
|
107
|
+
label="Visa"
|
|
108
|
+
value="Option 1"
|
|
109
|
+
image={{
|
|
110
|
+
source: bankLogo1 as ImageSourcePropType,
|
|
111
|
+
style: { width: 48, height: 32 },
|
|
112
|
+
resizeMode: 'cover',
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
<Radio
|
|
116
|
+
aria-label="Label 2"
|
|
117
|
+
onChange={(checked: boolean) => {
|
|
118
|
+
console.log(checked, '###');
|
|
119
|
+
}}
|
|
120
|
+
nativeID="Radio-2"
|
|
121
|
+
{...args}
|
|
122
|
+
label="Mastercard"
|
|
123
|
+
value="Option 2"
|
|
124
|
+
image={{
|
|
125
|
+
source: bankLogo as ImageSourcePropType,
|
|
126
|
+
style: { width: 48, height: 32 },
|
|
127
|
+
resizeMode: 'cover',
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
</RadioGroup>
|
|
131
|
+
),
|
|
132
|
+
};
|
|
133
|
+
|
|
87
134
|
export const Variants: Story = {
|
|
88
135
|
parameters: {
|
|
89
136
|
controls: { exclude: ['value', 'label', 'disabled'] },
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { createRadio } from '@gluestack-ui/radio';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import RadioProps from './Radio.props';
|
|
3
|
+
import StyledRadioGroup from './RadioGroupRoot';
|
|
4
4
|
import StyledRadioIcon from './RadioIcon';
|
|
5
|
+
import StyledRadioIndicator from './RadioIndicator';
|
|
5
6
|
import StyledRadioLabel from './RadioLabel';
|
|
6
|
-
import
|
|
7
|
-
import RadioProps from './Radio.props';
|
|
7
|
+
import StyledRadio from './RadioRoot';
|
|
8
8
|
|
|
9
|
+
import { useFormFieldContext } from '../FormField';
|
|
9
10
|
import { Helper } from '../Helper';
|
|
10
11
|
import { useRadioGroupContext } from './RadioGroup.context';
|
|
11
|
-
import
|
|
12
|
-
import RadioTileRoot from './RadioTileRoot';
|
|
12
|
+
import RadioImage from './RadioImage';
|
|
13
13
|
import RadioTextContent from './RadioTextContent';
|
|
14
|
+
import RadioTileRoot from './RadioTileRoot';
|
|
14
15
|
|
|
15
16
|
const RadioComponent = createRadio({
|
|
16
17
|
Root: StyledRadio,
|
|
@@ -41,6 +42,7 @@ const Radio = ({
|
|
|
41
42
|
validationStatus: validation,
|
|
42
43
|
showValidationIcon,
|
|
43
44
|
type = 'default',
|
|
45
|
+
image,
|
|
44
46
|
...props
|
|
45
47
|
}: RadioProps) => {
|
|
46
48
|
const { validationStatus: fieldValidationStatus } = useFormFieldContext();
|
|
@@ -55,6 +57,7 @@ const Radio = ({
|
|
|
55
57
|
<RadioIndicator>
|
|
56
58
|
<RadioIcon />
|
|
57
59
|
</RadioIndicator>
|
|
60
|
+
{image ? <RadioImage {...image} /> : null}
|
|
58
61
|
<RadioTextContent>
|
|
59
62
|
{!!label && <RadioLabel>{label}</RadioLabel>}
|
|
60
63
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
@@ -89,6 +92,6 @@ const RadioTile = ({ type = 'tile', ...props }: RadioProps) => <Radio {...props}
|
|
|
89
92
|
RadioTile.displayName = 'RadioTile';
|
|
90
93
|
Radio.displayName = 'Radio';
|
|
91
94
|
|
|
92
|
-
export { Radio, RadioGroup,
|
|
95
|
+
export { Radio, RadioGroup, RadioIcon, RadioIndicator, RadioLabel, RadioTile };
|
|
93
96
|
|
|
94
97
|
export default Radio;
|
|
@@ -19,7 +19,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
19
19
|
gap: theme.components.radio.gap,
|
|
20
20
|
padding: theme.components.radio.tile.padding,
|
|
21
21
|
borderWidth: theme.components.radio.tile.borderWidth,
|
|
22
|
-
borderColor: theme.color.border.
|
|
22
|
+
borderColor: theme.color.border.strong,
|
|
23
23
|
borderRadius: theme.components.radio.tile.borderRadius,
|
|
24
24
|
backgroundColor: theme.color.surface.neutral.strong,
|
|
25
25
|
variants: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { default as Radio, RadioIndicator, RadioLabel,
|
|
1
|
+
export { default as Radio, RadioIcon, RadioIndicator, RadioLabel, RadioTile } from './Radio';
|
|
2
|
+
export type { default as RadioProps } from './Radio.props';
|
|
2
3
|
export { default as RadioGroup } from './RadioGroup';
|
|
3
4
|
export { default as RadioGroupTextContent } from './RadioGroupTextContent';
|
|
5
|
+
export { default as RadioImage } from './RadioImage';
|
|
4
6
|
export { default as RadioTextContent } from './RadioTextContent';
|
|
5
|
-
export type { default as RadioProps } from './Radio.props';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as Stories from './Select.stories';
|
|
3
|
-
import { Select, SelectOption, FormField, Center } from '../../';
|
|
1
|
+
import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
|
|
4
2
|
import { UserSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
5
|
-
import {
|
|
3
|
+
import { Center, FormField, Select, SelectOption } from '../../';
|
|
4
|
+
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
5
|
+
import * as Stories from './Select.stories';
|
|
6
6
|
|
|
7
7
|
<Meta title="Forms / Select" />
|
|
8
8
|
|
|
@@ -195,7 +195,7 @@ import { Select, SelectOption } from '@utilitywarehouse/hearth-react-native';
|
|
|
195
195
|
import {
|
|
196
196
|
UserSmallIcon,
|
|
197
197
|
HeartSmallIcon,
|
|
198
|
-
|
|
198
|
+
EyeSmallIcon,
|
|
199
199
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
200
200
|
import { useState } from 'react';
|
|
201
201
|
|
|
@@ -211,7 +211,7 @@ const MyComponent = () => {
|
|
|
211
211
|
>
|
|
212
212
|
<SelectOption label="Home option" value="home" leadingIcon={UserSmallIcon} />
|
|
213
213
|
<SelectOption label="Car option" value="car" leadingIcon={HeartSmallIcon} />
|
|
214
|
-
<SelectOption label="World option" value="world" leadingIcon={
|
|
214
|
+
<SelectOption label="World option" value="world" leadingIcon={EyeSmallIcon} />
|
|
215
215
|
</Select>
|
|
216
216
|
);
|
|
217
217
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Meta } from '@storybook/react-vite';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
4
|
-
import SelectOption from './SelectOption';
|
|
5
|
-
import { FormField } from '../FormField';
|
|
6
2
|
import {
|
|
7
|
-
|
|
3
|
+
EyeSmallIcon,
|
|
8
4
|
HeartSmallIcon,
|
|
9
|
-
|
|
5
|
+
UserSmallIcon,
|
|
10
6
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
7
|
+
import { useState } from 'react';
|
|
11
8
|
import { Box } from '../Box';
|
|
12
9
|
import { Button } from '../Button';
|
|
10
|
+
import { FormField } from '../FormField';
|
|
11
|
+
import Select from './Select';
|
|
12
|
+
import SelectOption from './SelectOption';
|
|
13
13
|
|
|
14
14
|
const meta = {
|
|
15
15
|
title: 'Stories / Select',
|
|
@@ -269,7 +269,7 @@ export const WithInlineOptions = () => {
|
|
|
269
269
|
>
|
|
270
270
|
<SelectOption label="Home option" value="home" leadingIcon={UserSmallIcon} />
|
|
271
271
|
<SelectOption label="Car option" value="car" leadingIcon={HeartSmallIcon} />
|
|
272
|
-
<SelectOption label="World option" value="world" leadingIcon={
|
|
272
|
+
<SelectOption label="World option" value="world" leadingIcon={EyeSmallIcon} />
|
|
273
273
|
</Select>
|
|
274
274
|
);
|
|
275
275
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
2
|
-
import { Pressable, View
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
import { BodyText } from '../BodyText';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
@@ -42,10 +42,7 @@ const SelectOption = ({
|
|
|
42
42
|
>
|
|
43
43
|
{!!LeftIcon && (
|
|
44
44
|
<View>
|
|
45
|
-
{
|
|
46
|
-
const IconAny = Icon as any;
|
|
47
|
-
return <IconAny style={styles.icon as ViewStyle} as={LeftIcon} />;
|
|
48
|
-
})()}
|
|
45
|
+
<Icon as={LeftIcon} style={styles.icon} />
|
|
49
46
|
</View>
|
|
50
47
|
)}
|
|
51
48
|
|
|
@@ -55,15 +52,12 @@ const SelectOption = ({
|
|
|
55
52
|
|
|
56
53
|
{isSelected && (
|
|
57
54
|
<View>
|
|
58
|
-
<TickSmallIcon style={styles.icon
|
|
55
|
+
<Icon as={TickSmallIcon} style={styles.icon} />
|
|
59
56
|
</View>
|
|
60
57
|
)}
|
|
61
58
|
{!!RightIcon && !isSelected && (
|
|
62
59
|
<View>
|
|
63
|
-
{
|
|
64
|
-
const IconAny = Icon as any;
|
|
65
|
-
return <IconAny style={styles.icon as ViewStyle} as={RightIcon} />;
|
|
66
|
-
})()}
|
|
60
|
+
<Icon as={RightIcon} style={styles.icon} />
|
|
67
61
|
</View>
|
|
68
62
|
)}
|
|
69
63
|
</Pressable>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface TabProps extends PressableProps {
|
|
5
|
+
/** Unique value for the tab */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Tab label */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Optional leading icon */
|
|
10
|
+
icon?: ComponentType<any>;
|
|
11
|
+
/** Whether the tab is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
style?: ViewProps['style'];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TabProps;
|