@utilitywarehouse/hearth-react-native 0.19.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/.storybook/manager.ts +1 -0
  2. package/.storybook/preview.tsx +1 -0
  3. package/.turbo/turbo-build.log +1 -1
  4. package/.turbo/turbo-lint.log +13 -13
  5. package/CHANGELOG.md +299 -4
  6. package/build/components/BodyText/BodyText.js +12 -5
  7. package/build/components/BodyText/BodyText.props.d.ts +5 -19
  8. package/build/components/Box/Box.js +23 -3
  9. package/build/components/Box/Box.props.d.ts +3 -95
  10. package/build/components/Card/Card.props.d.ts +2 -5
  11. package/build/components/Container/Container.props.d.ts +2 -78
  12. package/build/components/DateInput/DateInput.d.ts +1 -1
  13. package/build/components/DateInput/DateInput.js +2 -2
  14. package/build/components/DateInput/DateInput.props.d.ts +15 -1
  15. package/build/components/DateInput/DateInputSegment.d.ts +1 -1
  16. package/build/components/DateInput/DateInputSegment.js +2 -2
  17. package/build/components/DetailText/DetailText.js +14 -13
  18. package/build/components/DetailText/DetailText.props.d.ts +4 -17
  19. package/build/components/Flex/Flex.js +3 -1
  20. package/build/components/Flex/Flex.props.d.ts +2 -2
  21. package/build/components/Heading/Heading.js +34 -13
  22. package/build/components/Heading/Heading.props.d.ts +4 -18
  23. package/build/components/Select/Select.d.ts +1 -1
  24. package/build/components/Select/Select.js +9 -10
  25. package/build/components/Select/Select.props.d.ts +16 -0
  26. package/build/core/themes.d.ts +188 -8
  27. package/build/core/themes.js +18 -2
  28. package/build/hooks/useStyleProps.js +22 -5
  29. package/build/tokens/color.d.ts +4 -0
  30. package/build/tokens/color.js +2 -0
  31. package/build/tokens/components/dark/modal.d.ts +6 -0
  32. package/build/tokens/components/dark/modal.js +6 -0
  33. package/build/tokens/components/dark/navigation.d.ts +1 -0
  34. package/build/tokens/components/dark/navigation.js +1 -0
  35. package/build/tokens/components/light/modal.d.ts +6 -0
  36. package/build/tokens/components/light/modal.js +6 -0
  37. package/build/tokens/components/light/navigation.d.ts +1 -0
  38. package/build/tokens/components/light/navigation.js +1 -0
  39. package/build/tokens/components/light/skeleton.d.ts +1 -1
  40. package/build/tokens/components/light/skeleton.js +1 -1
  41. package/build/tokens/font.d.ts +2 -0
  42. package/build/tokens/font.js +2 -0
  43. package/build/tokens/line-height.d.ts +2 -0
  44. package/build/tokens/line-height.js +2 -0
  45. package/build/tokens/primitive.d.ts +4 -0
  46. package/build/tokens/primitive.js +4 -0
  47. package/build/tokens/semantic-dark.d.ts +1 -0
  48. package/build/tokens/semantic-dark.js +1 -0
  49. package/build/tokens/semantic-light.d.ts +1 -0
  50. package/build/tokens/semantic-light.js +1 -0
  51. package/build/tokens/typography.d.ts +30 -0
  52. package/build/tokens/typography.js +15 -0
  53. package/build/types/index.d.ts +4 -2
  54. package/build/types/index.js +4 -2
  55. package/build/types/semanticColorValues.d.ts +22 -0
  56. package/build/types/semanticColorValues.js +1 -0
  57. package/build/types/utilityProps.d.ts +326 -0
  58. package/build/types/utilityProps.js +1 -0
  59. package/build/types/values.d.ts +4 -3
  60. package/build/utils/coloursAsArray.d.ts +4 -0
  61. package/build/utils/coloursAsArray.js +5 -0
  62. package/build/utils/index.d.ts +1 -1
  63. package/build/utils/index.js +1 -1
  64. package/build/utils/styleUtils.d.ts +26 -2
  65. package/build/utils/styleUtils.js +42 -13
  66. package/build/utils/themeValueHelpers.d.ts +13 -0
  67. package/build/utils/themeValueHelpers.js +29 -0
  68. package/docs/changelog.mdx +74 -2
  69. package/docs/components/AllComponents.web.tsx +23 -24
  70. package/docs/components/UsageWrap.tsx +2 -2
  71. package/docs/introduction.mdx +0 -7
  72. package/package.json +5 -3
  73. package/src/components/BodyText/BodyText.props.ts +5 -19
  74. package/src/components/BodyText/BodyText.stories.tsx +2 -1
  75. package/src/components/BodyText/BodyText.tsx +17 -6
  76. package/src/components/Box/Box.docs.mdx +5 -4
  77. package/src/components/Box/Box.props.ts +3 -231
  78. package/src/components/Box/Box.stories.tsx +2 -2
  79. package/src/components/Box/Box.tsx +38 -9
  80. package/src/components/Button/Button.docs.mdx +46 -1
  81. package/src/components/Card/Card.docs.mdx +1 -1
  82. package/src/components/Card/Card.props.ts +2 -5
  83. package/src/components/Card/Card.stories.tsx +54 -23
  84. package/src/components/Carousel/Carousel.docs.mdx +49 -44
  85. package/src/components/Center/Center.docs.mdx +6 -4
  86. package/src/components/Checkbox/CheckboxGroup.figma.tsx +21 -1
  87. package/src/components/Container/Container.docs.mdx +13 -8
  88. package/src/components/Container/Container.props.ts +9 -80
  89. package/src/components/Container/Container.stories.tsx +81 -65
  90. package/src/components/DateInput/DateInput.docs.mdx +43 -0
  91. package/src/components/DateInput/DateInput.props.ts +15 -1
  92. package/src/components/DateInput/DateInput.stories.tsx +37 -2
  93. package/src/components/DateInput/DateInput.tsx +6 -0
  94. package/src/components/DateInput/DateInputSegment.tsx +2 -0
  95. package/src/components/DetailText/DetailText.props.ts +4 -17
  96. package/src/components/DetailText/DetailText.stories.tsx +2 -3
  97. package/src/components/DetailText/DetailText.tsx +16 -17
  98. package/src/components/Flex/Flex.props.ts +2 -2
  99. package/src/components/Flex/Flex.stories.tsx +1 -1
  100. package/src/components/Flex/Flex.tsx +4 -1
  101. package/src/components/Grid/Grid.docs.mdx +53 -49
  102. package/src/components/Heading/Heading.props.ts +4 -18
  103. package/src/components/Heading/Heading.stories.tsx +2 -1
  104. package/src/components/Heading/Heading.tsx +40 -18
  105. package/src/components/PillGroup/Pill.figma.tsx +4 -17
  106. package/src/components/PillGroup/PillGroup.figma.tsx +8 -9
  107. package/src/components/ProgressStepper/ProgressStep.figma.tsx +4 -15
  108. package/src/components/ProgressStepper/ProgressStepper.figma.tsx +9 -16
  109. package/src/components/Radio/Radio.figma.tsx +35 -22
  110. package/src/components/Radio/RadioGroup.figma.tsx +69 -41
  111. package/src/components/Radio/RadioTile.figma.tsx +34 -0
  112. package/src/components/RadioCard/RadioCard.figma.tsx +24 -0
  113. package/src/components/SectionHeader/SectionHeader.figma.tsx +31 -25
  114. package/src/components/Select/Select.docs.mdx +76 -28
  115. package/src/components/Select/Select.figma.tsx +44 -43
  116. package/src/components/Select/Select.props.ts +16 -0
  117. package/src/components/Select/Select.tsx +42 -35
  118. package/src/components/Select/SelectOption.figma.tsx +3 -21
  119. package/src/components/Spinner/Spinner.figma.tsx +12 -25
  120. package/src/components/Switch/Switch.figma.tsx +2 -23
  121. package/src/components/Tabs/Tab.figma.tsx +21 -0
  122. package/src/components/Tabs/Tabs.figma.tsx +18 -27
  123. package/src/components/Textarea/Textarea.figma.tsx +64 -0
  124. package/src/components/Toast/ToastItem.figma.tsx +1 -8
  125. package/src/components/ToggleButtonCard/ToggleButtonCard.figma.tsx +24 -0
  126. package/src/components/VerificationInput/VerificationInput.figma.tsx +53 -0
  127. package/src/core/themes.ts +19 -2
  128. package/src/hooks/useStyleProps.ts +40 -5
  129. package/src/tokens/color.ts +2 -0
  130. package/src/tokens/components/dark/modal.ts +6 -0
  131. package/src/tokens/components/dark/navigation.ts +1 -0
  132. package/src/tokens/components/light/modal.ts +6 -0
  133. package/src/tokens/components/light/navigation.ts +1 -0
  134. package/src/tokens/components/light/skeleton.ts +1 -1
  135. package/src/tokens/font.ts +2 -0
  136. package/src/tokens/line-height.ts +2 -0
  137. package/src/tokens/primitive.ts +4 -0
  138. package/src/tokens/semantic-dark.ts +1 -0
  139. package/src/tokens/semantic-light.ts +1 -0
  140. package/src/tokens/typography.ts +15 -0
  141. package/src/types/index.ts +4 -2
  142. package/src/types/semanticColorValues.ts +26 -0
  143. package/src/types/utilityProps.ts +410 -0
  144. package/src/types/values.ts +4 -7
  145. package/src/utils/coloursAsArray.ts +6 -0
  146. package/src/utils/index.ts +8 -1
  147. package/src/utils/styleUtils.ts +45 -14
  148. package/src/utils/themeValueHelpers.ts +38 -0
  149. package/src/components/Radio/RadioTileRoot.figma.tsx +0 -31
@@ -0,0 +1,34 @@
1
+ import figma from '@figma/code-connect';
2
+ import { RadioTile } from '../';
3
+
4
+ figma.connect(
5
+ RadioTile,
6
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3138-13222&t=Uq6QfQcygdNGv5lM-4',
7
+ {
8
+ props: {
9
+ helperText: figma.boolean('Helper text?', {
10
+ true: figma.string('Helper text'),
11
+ }),
12
+ label: figma.string('Label'),
13
+ image: figma.boolean('Image?', {
14
+ true: figma.instance('Radio Image'),
15
+ }),
16
+ checked: figma.boolean('Checked?'),
17
+ indicator: figma.nestedProps('Radio Item', {
18
+ disabled: figma.enum('State', {
19
+ Disabled: true,
20
+ }),
21
+ }),
22
+ },
23
+ example: props => (
24
+ <RadioTile
25
+ label={props.label}
26
+ helperText={props.helperText}
27
+ image={props.image}
28
+ checked={props.checked}
29
+ disabled={props.indicator.disabled}
30
+ value="someValue"
31
+ />
32
+ ),
33
+ }
34
+ );
@@ -0,0 +1,24 @@
1
+ import figma from '@figma/code-connect';
2
+ import { RadioCard } from '../';
3
+
4
+ figma.connect(
5
+ RadioCard,
6
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=2164-727&t=Uq6QfQcygdNGv5lM-4',
7
+ {
8
+ variant: {
9
+ Variant: 'Radio',
10
+ },
11
+ props: {
12
+ radio: figma.nestedProps('Radio', {
13
+ label: figma.string('Label'),
14
+ }),
15
+ content: figma.instance('Content'),
16
+ },
17
+ example: props => (
18
+ // This should be wrapped in a RadioCardGroup, see docs
19
+ <RadioCard label={props.radio.label} value="someValue">
20
+ {props.content}
21
+ </RadioCard>
22
+ ),
23
+ }
24
+ );
@@ -1,31 +1,37 @@
1
- import React from "react"
2
- import SectionHeader from "./SectionHeader"
3
- import figma from "@figma/code-connect"
4
-
5
- /**
6
- * -- This file was auto-generated by Code Connect --
7
- * None of your props could be automatically mapped to Figma properties.
8
- * You should update the `props` object to include a mapping from your
9
- * code props to Figma properties, and update the `example` function to
10
- * return the code example you'd like to see in Figma
11
- */
1
+ import figma from '@figma/code-connect';
2
+ import { SectionHeader } from '../';
12
3
 
13
4
  figma.connect(
14
5
  SectionHeader,
15
- "https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=9092%3A3352",
6
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=9092%3A3352',
16
7
  {
17
8
  props: {
18
- // No matching props could be found for these Figma properties:
19
- // "trailingContent": figma.boolean('Trailing content?'),
20
- // "helperText": figma.boolean('Helper text?'),
21
- // "helperText": figma.string('Helper text'),
22
- // "heading": figma.string('Heading'),
23
- // "badge": figma.boolean('Badge?'),
24
- // "state": figma.enum('State', {
25
- // "Invalid": "invalid",
26
- // "Default": "default"
27
- // })
9
+ trailingContent: figma.boolean('Trailing content?', {
10
+ true: figma.nestedProps('Trailing content', {
11
+ content: figma.children('Link'),
12
+ }),
13
+ }),
14
+ helperText: figma.boolean('Helper text?', {
15
+ true: figma.string('Helper text'),
16
+ }),
17
+ heading: figma.string('Heading'),
18
+ badge: figma.boolean('Badge?', {
19
+ true: figma.children('Badge'),
20
+ }),
21
+ invalidText: figma.enum('State', {
22
+ Invalid: figma.nestedProps('Validation Text', {
23
+ text: figma.string('Text'),
24
+ }),
25
+ }),
28
26
  },
29
- example: (props) => <SectionHeader />,
30
- },
31
- )
27
+ example: props => (
28
+ <SectionHeader
29
+ heading={props.heading}
30
+ helperText={props.helperText}
31
+ badge={props.badge}
32
+ trailingContent={props.trailingContent?.content}
33
+ invalidText={props.invalidText?.text}
34
+ />
35
+ ),
36
+ }
37
+ );
@@ -20,6 +20,7 @@ The `Select` component creates a dropdown menu that allows users to choose from
20
20
  - [`Select`](#select)
21
21
  - [`SelectOption`](#selectoption)
22
22
  - [Examples](#examples)
23
+ - [With label and helper text](#with-label-and-helper-text)
23
24
  - [With `FormField`](#with-formfield)
24
25
  - [Searchable `Select`](#searchable-select)
25
26
  - [Inline `SelectOption`](#inline-selectoption)
@@ -77,42 +78,89 @@ const MyComponent = () => {
77
78
 
78
79
  The `Select` component inherits all of the React Native [`View` props](https://reactnative.dev/docs/view).
79
80
 
80
- | Prop | Type | Default | Description |
81
- | ----------------- | ----------------------------------- | ------------------------ | ---------------------------------------------------------- |
82
- | options | SelectOptionProps[] | `[]` | Array of options to display in the select. |
83
- | value | string \| null | `-` | Currently selected value. |
84
- | onValueChange | (value: string) => void | `-` | Callback when value changes. |
85
- | label | string | `-` | Label for the select. |
86
- | placeholder | string | `'Select an option'` | Placeholder text to show when no value is selected. |
87
- | disabled | boolean | `false` | Whether the select is disabled. |
88
- | readonly | boolean | `false` | Whether the select is readonly. |
89
- | leadingIcon | React.ComponentType | `-` | Icon to display before the select text. |
90
- | validationStatus | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | The validation status of the select. |
91
- | required | boolean | `true` | Indicates that the select is required. |
92
- | menuHeading | string | `-` | Heading to display at the top of the menu. |
93
- | children | ReactNode | `-` | Children to render inside the select (for custom options). |
94
- | bottomSheetProps | `BottomSheetProps` | `-` | Props passed to the BottomSheetModal. |
95
- | emptyText | string | `'No options available'` | Text to display when no options are available. |
96
- | listProps | object | `-` | Props to be passed to the bottom sheet flat list. |
97
- | searchable | boolean | `false` | Optional search functionality for the select. |
98
- | searchPlaceholder | string | `'Search'` | Search placeholder. |
81
+ | Prop | Type | Default | Description |
82
+ | ----------------- | ----------------------------------- | ------------------------ | -------------------------------------------------------------------------- |
83
+ | options | `SelectOptionProps[]` | `[]` | Array of options to display in the select. |
84
+ | value | `string \| null` | `-` | Currently selected value. |
85
+ | onValueChange | `(value: string) => void` | `-` | Callback when value changes. |
86
+ | label | `string` | `-` | Label for the select. |
87
+ | labelVariant | `'body' \| 'heading'` | `'body'` | Variant for the label. 'inline' will display the label next to the select. |
88
+ | helperText | `string` | `-` | Helper text to display below the select. |
89
+ | helperIcon | `React.ComponentType` | `-` | Optional icon to display next to the helper text. |
90
+ | placeholder | `string` | `'Select an option'` | Placeholder text to show when no value is selected. |
91
+ | disabled | `boolean` | `false` | Whether the select is disabled. |
92
+ | readonly | `boolean` | `false` | Whether the select is readonly. |
93
+ | leadingIcon | `React.ComponentType` | `-` | Icon to display before the select text. |
94
+ | validationStatus | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | The validation status of the select. |
95
+ | invalidText | `string` | `-` | Text to display when validationStatus is 'invalid'. |
96
+ | validText | `string` | `-` | Text to display when validationStatus is 'valid'. |
97
+ | required | `boolean` | `true` | Indicates that the select is required. |
98
+ | menuHeading | `string` | `-` | Heading to display at the top of the menu. |
99
+ | children | `ReactNode` | `-` | Children to render inside the select (for custom options). |
100
+ | bottomSheetProps | `BottomSheetProps` | `-` | Props passed to the BottomSheetModal. |
101
+ | emptyText | `string` | `'No options available'` | Text to display when no options are available. |
102
+ | listProps | `object` | `-` | Props to be passed to the bottom sheet flat list. |
103
+ | searchable | `boolean` | `false` | Optional search functionality for the select. |
104
+ | searchPlaceholder | `string` | `'Search'` | Search placeholder. |
99
105
 
100
106
  ### `SelectOption`
101
107
 
102
108
  The `SelectOption` component is used to create individual options within the `Select` component. It can be used inline or as part of the `options` prop.
103
109
 
104
- | Prop | Type | Default | Description |
105
- | ------------ | ----------------------- | ------- | -------------------------------------- |
106
- | label | string | `-` | Label to display for this option. |
107
- | value | string | `-` | Value for this option. |
108
- | leadingIcon | React.ComponentType | `-` | Optional left icon for this option. |
109
- | trailingIcon | React.ComponentType | `-` | Optional right icon for this option. |
110
- | selected | boolean | `-` | Whether this option is selected. |
111
- | disabled | boolean | `false` | Whether this option is disabled. |
112
- | onPress | (value: string) => void | `-` | Callback when this option is selected. |
110
+ | Prop | Type | Default | Description |
111
+ | ------------ | ------------------------- | ------- | -------------------------------------- |
112
+ | label | `string` | `-` | Label to display for this option. |
113
+ | value | `string` | `-` | Value for this option. |
114
+ | leadingIcon | `React.ComponentType` | `-` | Optional left icon for this option. |
115
+ | trailingIcon | `React.ComponentType` | `-` | Optional right icon for this option. |
116
+ | selected | `boolean` | `-` | Whether this option is selected. |
117
+ | disabled | `boolean` | `false` | Whether this option is disabled. |
118
+ | onPress | `(value: string) => void` | `-` | Callback when this option is selected. |
113
119
 
114
120
  ## Examples
115
121
 
122
+ ## With label and helper text
123
+
124
+ <UsageWrap>
125
+ <Center>
126
+ <Select
127
+ label="Select an option"
128
+ helperText="This is some helper text for the select component."
129
+ placeholder="Select an option"
130
+ options={[
131
+ { label: 'Option 1', value: '1' },
132
+ { label: 'Option 2', value: '2' },
133
+ { label: 'Option 3', value: '3' },
134
+ ]}
135
+ value="1"
136
+ onValueChange={value => console.log('Selected:', value)}
137
+ />
138
+ </Center>
139
+ </UsageWrap>
140
+
141
+ ```tsx
142
+ import { Select } from '@utilitywarehouse/hearth-react-native';
143
+
144
+ const MyComponent = () => {
145
+ const [value, setValue] = useState(null);
146
+
147
+ return (
148
+ <Select
149
+ label="Select an option"
150
+ helperText="This is some helper text for the select component."
151
+ placeholder="Select an option"
152
+ options={[
153
+ { label: 'Option 1', value: '1' },
154
+ { label: 'Option 2', value: '2' },
155
+ { label: 'Option 3', value: '3' },
156
+ ]}
157
+ value={value}
158
+ onValueChange={setValue}
159
+ />
160
+ );
161
+ };
162
+ ```
163
+
116
164
  ### With `FormField`
117
165
 
118
166
  The `Select` component can be used with the `FormField` component for additional functionality like validation messages and helper text.
@@ -1,55 +1,56 @@
1
1
  import figma from '@figma/code-connect';
2
- import Select from './Select';
3
-
4
- /**
5
- * -- This file was auto-generated by Code Connect --
6
- * `props` includes a mapping from your code props to Figma properties.
7
- * You should check this is correct, and update the `example` function
8
- * to return the code example you'd like to see in Figma
9
- */
2
+ import { useState } from 'react';
3
+ import { Select } from '../';
10
4
 
11
5
  figma.connect(Select, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3224%3A995', {
12
6
  props: {
13
- // These props were automatically mapped based on your linked code:
14
7
  label: figma.string('Label'),
15
- placeholder: figma.string('Label'),
8
+ placeholder: figma.enum('Value type', {
9
+ Placeholder: figma.string('Value'),
10
+ }),
16
11
  disabled: figma.enum('Variant', {
17
12
  Disabled: true,
18
13
  }),
19
- emptyText: figma.string('Helper text'),
20
- readonly: figma.enum('Variant', {
21
- 'Read-only': true,
14
+ validationStatus: figma.enum('Variant', {
15
+ Invalid: 'invalid',
16
+ Valid: 'valid',
22
17
  }),
23
- collapsable: figma.boolean('Dropdown?'),
24
- focusable: figma.boolean('Focus?'),
25
- hasTVPreferredFocus: figma.boolean('Focus?'),
26
- 'aria-disabled': figma.enum('Variant', {
27
- Disabled: true,
18
+ invalidText: figma.enum('Variant', {
19
+ Invalid: figma.string('Validation'),
20
+ }),
21
+ validText: figma.enum('Variant', {
22
+ Valid: figma.string('Validation'),
28
23
  }),
29
- // No matching props could be found for these Figma properties:
30
- // "helperText": figma.boolean('Helper text?'),
31
- // "label": figma.string('Label'),
32
- // "validation": figma.string('Validation'),
33
- // "helperText": figma.string('Helper text'),
34
- // "value": figma.string('Value'),
35
- // "dropdown": figma.boolean('Dropdown?'),
36
- // "optional": figma.boolean('Optional?'),
37
- // "valueType": figma.enum('Value type', {
38
- // "Empty": "empty",
39
- // "Placeholder": "placeholder",
40
- // "Selected": "selected"
41
- // })
24
+ helperText: figma.boolean('Helper text?', {
25
+ true: figma.string('Helper text'),
26
+ }),
27
+ required: figma.boolean('Optional?', {
28
+ true: false,
29
+ }),
30
+ value: figma.enum('Value type', {
31
+ Selected: figma.string('Value'),
32
+ }),
33
+ },
34
+ example: props => {
35
+ const [value, setValue] = useState(null);
36
+ return (
37
+ <Select
38
+ label={props.label}
39
+ placeholder={props.placeholder}
40
+ disabled={props.disabled}
41
+ validationStatus={props.validationStatus}
42
+ invalidText={props.invalidText}
43
+ validText={props.validText}
44
+ helperText={props.helperText}
45
+ required={props.required}
46
+ options={[
47
+ { label: 'Option 1', value: '1' },
48
+ { label: 'Option 2', value: '2' },
49
+ { label: 'Option 3', value: '3' },
50
+ ]}
51
+ value={value}
52
+ onValueChange={value => setValue(value)}
53
+ />
54
+ );
42
55
  },
43
- example: props => (
44
- <Select
45
- label={props.label}
46
- placeholder={props.placeholder}
47
- disabled={props.disabled}
48
- emptyText={props.emptyText}
49
- readonly={props.readonly}
50
- collapsable={props.collapsable}
51
- focusable={props.focusable}
52
- hasTVPreferredFocus={props.hasTVPreferredFocus}
53
- />
54
- ),
55
56
  });
@@ -53,6 +53,22 @@ interface SelectProps extends ViewProps {
53
53
  * @default 'body'.
54
54
  */
55
55
  labelVariant?: 'heading' | 'body';
56
+ /**
57
+ * Helper text to show below the select
58
+ */
59
+ helperText?: string;
60
+ /**
61
+ * Optional icon to display alongside the helper text
62
+ */
63
+ helperIcon?: React.ComponentType;
64
+ /**
65
+ * Text to display when validationStatus is 'invalid'
66
+ */
67
+ invalidText?: string;
68
+ /**
69
+ * Text to display when validationStatus is 'valid'
70
+ */
71
+ validText?: string;
56
72
  /**
57
73
  * Placeholder text to show when no value is selected
58
74
  */
@@ -10,10 +10,9 @@ import {
10
10
  BottomSheetView,
11
11
  } from '../BottomSheet';
12
12
  import { DetailText } from '../DetailText';
13
- import { useFormFieldContext } from '../FormField';
13
+ import { FormField, useFormFieldContext } from '../FormField';
14
14
  import { Icon } from '../Icon';
15
15
  import { Input } from '../Input';
16
- import { Label } from '../Label';
17
16
  import { SelectContext } from './Select.context';
18
17
  import SelectProps, { SelectOptionItemProps } from './Select.props';
19
18
  import SelectOption from './SelectOption';
@@ -28,6 +27,10 @@ const Select = ({
28
27
  disabled = false,
29
28
  leadingIcon: LeadingIcon,
30
29
  validationStatus = 'initial',
30
+ helperText,
31
+ helperIcon,
32
+ invalidText,
33
+ validText,
31
34
  required = true,
32
35
  children,
33
36
  bottomSheetProps,
@@ -122,42 +125,46 @@ const Select = ({
122
125
 
123
126
  return (
124
127
  <View {...rest} style={[styles.container, rest.style]}>
125
- {!!label && (
126
- <View>
127
- <Label variant={labelVariant}>
128
- {label}
129
- {!isRequired && <Label variant={labelVariant}> (Optional)</Label>}
130
- </Label>
131
- </View>
132
- )}
133
- <Pressable
134
- onPress={openBottomSheet}
135
- disabled={isDisabled || isReadonly}
136
- style={({ pressed }) => [
137
- styles.selectContainer,
138
- styles.pressedContainer(pressed || isOpen),
139
- ]}
128
+ <FormField
129
+ label={label}
130
+ labelVariant={labelVariant}
131
+ helperText={helperText}
132
+ helperIcon={helperIcon}
133
+ validationStatus={validationStatusFromContext}
134
+ required={isRequired}
135
+ disabled={isDisabled}
136
+ readonly={isReadonly}
137
+ invalidText={invalidText}
138
+ validText={validText}
140
139
  >
141
- {!!LeadingIcon && (
142
- <View>
143
- {(() => {
144
- const IconAny = Icon as any;
145
- return <IconAny as={LeadingIcon} style={styles.icon as any} />;
146
- })()}
147
- </View>
148
- )}
149
-
150
- <View style={styles.optionContainer}>
151
- <BodyText numberOfLines={1} style={styles.placeholderText}>
152
- {selectedOption?.label || selectedLabel || placeholder}
153
- </BodyText>
154
- </View>
140
+ <Pressable
141
+ onPress={openBottomSheet}
142
+ disabled={isDisabled || isReadonly}
143
+ style={({ pressed }) => [
144
+ styles.selectContainer,
145
+ styles.pressedContainer(pressed || isOpen),
146
+ ]}
147
+ >
148
+ {!!LeadingIcon && (
149
+ <View>
150
+ {(() => {
151
+ const IconAny = Icon as any;
152
+ return <IconAny as={LeadingIcon} style={styles.icon as any} />;
153
+ })()}
154
+ </View>
155
+ )}
155
156
 
156
- <View>
157
- <Icon as={ExpandSmallIcon} style={styles.icon} />
158
- </View>
159
- </Pressable>
157
+ <View style={styles.optionContainer}>
158
+ <BodyText numberOfLines={1} style={styles.placeholderText}>
159
+ {selectedOption?.label || selectedLabel || placeholder}
160
+ </BodyText>
161
+ </View>
160
162
 
163
+ <View>
164
+ <Icon as={ExpandSmallIcon} style={styles.icon} />
165
+ </View>
166
+ </Pressable>
167
+ </FormField>
161
168
  <BottomSheetModal
162
169
  ref={bottomSheetModalRef}
163
170
  snapPoints={['25%', '40%', '80%']}
@@ -1,36 +1,18 @@
1
1
  import figma from '@figma/code-connect';
2
- import SelectOption from './SelectOption';
3
-
4
- /**
5
- * -- This file was auto-generated by Code Connect --
6
- * `props` includes a mapping from your code props to Figma properties.
7
- * You should check this is correct, and update the `example` function
8
- * to return the code example you'd like to see in Figma
9
- */
2
+ import { SelectOption } from '../';
10
3
 
11
4
  figma.connect(
12
5
  SelectOption,
13
6
  'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=4340%3A1252',
14
7
  {
15
8
  props: {
16
- // These props were automatically mapped based on your linked code:
17
9
  label: figma.string('Label'),
18
- selected: figma.boolean('Selected?'),
19
10
  disabled: figma.enum('State', {
20
- Active: true,
11
+ Disabled: true,
21
12
  }),
22
- // No matching props could be found for these Figma properties:
23
- // "label": figma.string('Label'),
24
- // "icon": figma.boolean('Icon?'),
25
- // "icon20": figma.instance('Icon-20')
26
13
  },
27
14
  example: props => (
28
- <SelectOption
29
- label={props.label}
30
- value={null}
31
- selected={props.selected}
32
- disabled={props.disabled}
33
- />
15
+ <SelectOption label={props.label} value="some value" disabled={props.disabled} />
34
16
  ),
35
17
  }
36
18
  );
@@ -1,27 +1,14 @@
1
- import React from "react"
2
- import Spinner from "./Spinner"
3
- import figma from "@figma/code-connect"
1
+ import figma from '@figma/code-connect';
2
+ import { Spinner } from '../';
4
3
 
5
- /**
6
- * -- This file was auto-generated by Code Connect --
7
- * `props` includes a mapping from your code props to Figma properties.
8
- * You should check this is correct, and update the `example` function
9
- * to return the code example you'd like to see in Figma
10
- */
11
-
12
- figma.connect(
13
- Spinner,
14
- "https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=61%3A195",
15
- {
16
- props: {
17
- // These props were automatically mapped based on your linked code:
18
- size: figma.enum("Size", {
19
- "XS-20": "xs",
20
- "SM-24": "sm",
21
- "MD-32": "md",
22
- "LG-44": "lg",
23
- }),
24
- },
25
- example: (props) => <Spinner size={props.size} />,
4
+ figma.connect(Spinner, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=61%3A195', {
5
+ props: {
6
+ size: figma.enum('Size', {
7
+ 'XS-20': 'xs',
8
+ 'SM-24': 'sm',
9
+ 'MD-32': 'md',
10
+ 'LG-44': 'lg',
11
+ }),
26
12
  },
27
- )
13
+ example: props => <Spinner size={props.size} />,
14
+ });
@@ -1,37 +1,16 @@
1
1
  import figma from '@figma/code-connect';
2
- import Switch from './Switch';
3
-
4
- /**
5
- * -- This file was auto-generated by Code Connect --
6
- * `props` includes a mapping from your code props to Figma properties.
7
- * You should check this is correct, and update the `example` function
8
- * to return the code example you'd like to see in Figma
9
- */
2
+ import { Switch } from '../';
10
3
 
11
4
  figma.connect(Switch, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3044%3A243', {
12
5
  props: {
13
- // These props were automatically mapped based on your linked code:
14
6
  disabled: figma.enum('State', {
15
7
  Disabled: true,
16
8
  }),
17
- 'aria-disabled': figma.enum('State', {
18
- Disabled: true,
19
- }),
20
- focusable: figma.enum('State', {
21
- Focus: true,
22
- }),
23
9
  checked: figma.boolean('Checked?'),
24
10
  size: figma.enum('Size', {
25
11
  'MD-32': 'medium',
26
12
  'SM-24': 'small',
27
13
  }),
28
14
  },
29
- example: props => (
30
- <Switch
31
- value={props.checked}
32
- disabled={props.disabled}
33
- focusable={props.focusable}
34
- size={props.size}
35
- />
36
- ),
15
+ example: props => <Switch value={props.checked} disabled={props.disabled} size={props.size} />,
37
16
  });
@@ -0,0 +1,21 @@
1
+ import figma from '@figma/code-connect';
2
+ import { Tab } from '..';
3
+
4
+ figma.connect(
5
+ Tab,
6
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=6464-2288&m=dev',
7
+ {
8
+ props: {
9
+ label: figma.string('Label'),
10
+ icon: figma.boolean('Icon?', {
11
+ true: figma.instance('Icon-20'),
12
+ }),
13
+ tabs: figma.children('Tab item'),
14
+ },
15
+ example: props => (
16
+ <Tab value={props.label} icon={props.icon}>
17
+ {props.label}
18
+ </Tab>
19
+ ),
20
+ }
21
+ );