@telus-uds/components-base 0.0.2-prerelease.6 → 0.0.2-prerelease.7

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 (155) hide show
  1. package/.ultra.cache.json +1 -1
  2. package/CHANGELOG.md +20 -0
  3. package/__fixtures__/testTheme.js +424 -37
  4. package/__tests__/Button/ButtonBase.test.jsx +2 -31
  5. package/__tests__/Checkbox/Checkbox.test.jsx +94 -0
  6. package/__tests__/InputSupports/InputSupports.test.jsx +50 -0
  7. package/__tests__/List/List.test.jsx +60 -0
  8. package/__tests__/Radio/Radio.test.jsx +87 -0
  9. package/__tests__/Select/Select.test.jsx +93 -0
  10. package/__tests__/Skeleton/Skeleton.test.jsx +61 -0
  11. package/__tests__/Tags/Tags.test.jsx +328 -0
  12. package/__tests__/TextInput/TextArea.test.jsx +34 -0
  13. package/__tests__/TextInput/{TextInput.test.jsx → TextInputBase.test.jsx} +20 -46
  14. package/jest.config.js +3 -1
  15. package/lib/Button/Button.js +10 -3
  16. package/lib/Button/ButtonBase.js +73 -59
  17. package/lib/Button/ButtonGroup.js +11 -27
  18. package/lib/Button/ButtonLink.js +5 -0
  19. package/lib/Checkbox/Checkbox.js +308 -0
  20. package/lib/Checkbox/CheckboxInput.native.js +6 -0
  21. package/lib/Checkbox/CheckboxInput.web.js +57 -0
  22. package/lib/Checkbox/index.js +2 -0
  23. package/lib/Feedback/Feedback.js +20 -3
  24. package/lib/Icon/Icon.js +8 -5
  25. package/lib/Icon/IconText.js +72 -0
  26. package/lib/Icon/index.js +2 -1
  27. package/lib/InputSupports/InputSupports.js +90 -0
  28. package/lib/InputSupports/index.js +2 -0
  29. package/lib/InputSupports/propTypes.js +55 -0
  30. package/lib/Link/ChevronLink.js +23 -20
  31. package/lib/Link/InlinePressable.native.js +78 -0
  32. package/lib/Link/InlinePressable.web.js +32 -0
  33. package/lib/Link/Link.js +11 -10
  34. package/lib/Link/LinkBase.js +62 -123
  35. package/lib/Link/TextButton.js +20 -9
  36. package/lib/Link/index.js +2 -1
  37. package/lib/List/List.js +52 -0
  38. package/lib/List/ListItem.js +207 -0
  39. package/lib/List/index.js +2 -0
  40. package/lib/Pagination/PageButton.js +2 -25
  41. package/lib/Pagination/SideButton.js +27 -37
  42. package/lib/Radio/Radio.js +291 -0
  43. package/lib/Radio/RadioInput.native.js +6 -0
  44. package/lib/Radio/RadioInput.web.js +59 -0
  45. package/lib/Radio/index.js +2 -0
  46. package/lib/Select/Group.native.js +14 -0
  47. package/lib/Select/Group.web.js +18 -0
  48. package/lib/Select/Item.native.js +9 -0
  49. package/lib/Select/Item.web.js +15 -0
  50. package/lib/Select/Picker.native.js +87 -0
  51. package/lib/Select/Picker.web.js +63 -0
  52. package/lib/Select/Select.js +272 -0
  53. package/lib/Select/index.js +6 -0
  54. package/lib/Skeleton/Skeleton.js +119 -0
  55. package/lib/Skeleton/index.js +2 -0
  56. package/lib/Tags/Tags.js +217 -0
  57. package/lib/Tags/index.js +2 -0
  58. package/lib/TextInput/TextArea.js +82 -0
  59. package/lib/TextInput/TextInput.js +23 -304
  60. package/lib/TextInput/TextInputBase.js +229 -0
  61. package/lib/TextInput/index.js +2 -1
  62. package/lib/TextInput/propTypes.js +31 -0
  63. package/lib/ThemeProvider/useThemeTokens.js +54 -3
  64. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  65. package/lib/Typography/Typography.js +4 -19
  66. package/lib/index.js +8 -1
  67. package/lib/utils/a11y/index.js +1 -0
  68. package/lib/utils/a11y/textSize.js +33 -0
  69. package/lib/utils/index.js +3 -0
  70. package/lib/utils/info/index.js +7 -0
  71. package/lib/utils/info/platform/index.js +11 -0
  72. package/lib/utils/info/platform/platform.android.js +1 -0
  73. package/lib/utils/info/platform/platform.ios.js +1 -0
  74. package/lib/utils/info/platform/platform.native.js +4 -0
  75. package/lib/utils/info/platform/platform.web.js +1 -0
  76. package/lib/utils/info/versions.js +5 -0
  77. package/lib/utils/pressability.js +92 -0
  78. package/lib/utils/propTypes.js +78 -17
  79. package/package.json +5 -4
  80. package/release-context.json +4 -4
  81. package/src/Button/Button.jsx +6 -3
  82. package/src/Button/ButtonBase.jsx +66 -57
  83. package/src/Button/ButtonGroup.jsx +9 -22
  84. package/src/Button/ButtonLink.jsx +11 -2
  85. package/src/Checkbox/Checkbox.jsx +275 -0
  86. package/src/Checkbox/CheckboxInput.native.jsx +6 -0
  87. package/src/Checkbox/CheckboxInput.web.jsx +55 -0
  88. package/src/Checkbox/index.js +3 -0
  89. package/src/Feedback/Feedback.jsx +13 -4
  90. package/src/Icon/Icon.jsx +9 -5
  91. package/src/Icon/IconText.jsx +63 -0
  92. package/src/Icon/index.js +2 -1
  93. package/src/InputSupports/InputSupports.jsx +86 -0
  94. package/src/InputSupports/index.js +3 -0
  95. package/src/InputSupports/propTypes.js +44 -0
  96. package/src/Link/ChevronLink.jsx +20 -17
  97. package/src/Link/InlinePressable.native.jsx +73 -0
  98. package/src/Link/InlinePressable.web.jsx +37 -0
  99. package/src/Link/Link.jsx +17 -13
  100. package/src/Link/LinkBase.jsx +57 -140
  101. package/src/Link/TextButton.jsx +25 -11
  102. package/src/Link/index.js +2 -1
  103. package/src/List/List.jsx +47 -0
  104. package/src/List/ListItem.jsx +187 -0
  105. package/src/List/index.js +3 -0
  106. package/src/Pagination/PageButton.jsx +2 -16
  107. package/src/Pagination/SideButton.jsx +23 -34
  108. package/src/Radio/Radio.jsx +270 -0
  109. package/src/Radio/RadioInput.native.jsx +6 -0
  110. package/src/Radio/RadioInput.web.jsx +57 -0
  111. package/src/Radio/index.js +3 -0
  112. package/src/Select/Group.native.jsx +14 -0
  113. package/src/Select/Group.web.jsx +15 -0
  114. package/src/Select/Item.native.jsx +10 -0
  115. package/src/Select/Item.web.jsx +11 -0
  116. package/src/Select/Picker.native.jsx +95 -0
  117. package/src/Select/Picker.web.jsx +67 -0
  118. package/src/Select/Select.jsx +265 -0
  119. package/src/Select/index.js +8 -0
  120. package/src/Skeleton/Skeleton.jsx +101 -0
  121. package/src/Skeleton/index.js +3 -0
  122. package/src/Tags/Tags.jsx +206 -0
  123. package/src/Tags/index.js +3 -0
  124. package/src/TextInput/TextArea.jsx +78 -0
  125. package/src/TextInput/TextInput.jsx +17 -284
  126. package/src/TextInput/TextInputBase.jsx +220 -0
  127. package/src/TextInput/index.js +2 -1
  128. package/src/TextInput/propTypes.js +29 -0
  129. package/src/ThemeProvider/useThemeTokens.js +54 -3
  130. package/src/ToggleSwitch/ToggleSwitch.jsx +1 -1
  131. package/src/Typography/Typography.jsx +4 -15
  132. package/src/index.js +8 -1
  133. package/src/utils/a11y/index.js +1 -0
  134. package/src/utils/a11y/textSize.js +30 -0
  135. package/src/utils/index.js +3 -0
  136. package/src/utils/info/index.js +8 -0
  137. package/src/utils/info/platform/index.js +11 -0
  138. package/src/utils/info/platform/platform.android.js +1 -0
  139. package/src/utils/info/platform/platform.ios.js +1 -0
  140. package/src/utils/info/platform/platform.native.js +4 -0
  141. package/src/utils/info/platform/platform.web.js +1 -0
  142. package/src/utils/info/versions.js +6 -0
  143. package/src/utils/pressability.js +92 -0
  144. package/src/utils/propTypes.js +97 -22
  145. package/stories/Button/Button.stories.jsx +5 -0
  146. package/stories/Checkbox/Checkbox.stories.jsx +71 -0
  147. package/stories/Feedback/Feedback.stories.jsx +5 -6
  148. package/stories/Link/Link.stories.jsx +15 -1
  149. package/stories/List/List.stories.jsx +117 -0
  150. package/stories/Radio/Radio.stories.jsx +113 -0
  151. package/stories/Select/Select.stories.jsx +55 -0
  152. package/stories/Skeleton/Skeleton.stories.jsx +36 -0
  153. package/stories/Tags/Tags.stories.jsx +69 -0
  154. package/stories/TextInput/TextArea.stories.jsx +100 -0
  155. package/stories/supports.jsx +1 -1
@@ -0,0 +1,117 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React from 'react'
3
+ import { StyleSheet, Text } from 'react-native'
4
+ // TODO: move icon-specific stories to Allium storybook and add generic/default icons
5
+ // eslint-disable-next-line import/no-extraneous-dependencies
6
+ import { Checkmark, ThumbsUp, Baby } from '@telus-uds/palette-allium/build/rn/icons'
7
+ import { useVariants, Container } from '../supports'
8
+
9
+ import { List, Typography } from '../../lib'
10
+
11
+ export default {
12
+ title: 'Base/List',
13
+ component: List
14
+ }
15
+
16
+ const styles = StyleSheet.create({
17
+ variantsTitle: {
18
+ marginBottom: 10,
19
+ fontSize: 20,
20
+ textTransform: 'capitalize'
21
+ }
22
+ })
23
+
24
+ const Template = () => {
25
+ const variants = useVariants('List')
26
+
27
+ return variants.map(([key, value, label]) => (
28
+ <Container key={label} dark={value === 'white'} padding={16}>
29
+ <Text style={styles.variantsTitle}>{label}</Text>
30
+ <List variant={{ [key]: value }}>
31
+ <List.Item>List item, {label}</List.Item>
32
+ <List.Item>List item, {label}</List.Item>
33
+ <List.Item>List item, {label}</List.Item>
34
+ <List.Item>List item, {label}</List.Item>
35
+ <List.Item>List item, {label}</List.Item>
36
+ </List>
37
+ </Container>
38
+ ))
39
+ }
40
+
41
+ export const Default = (args) => {
42
+ const { itemIcon, mixedIcons, iconColor } = args
43
+ return (
44
+ <List {...args}>
45
+ <List.Item iconColor={iconColor} icon={itemIcon}>
46
+ Some Item
47
+ </List.Item>
48
+ <List.Item iconColor={iconColor} icon={!mixedIcons ? itemIcon : null}>
49
+ Some Item
50
+ </List.Item>
51
+ <List.Item iconColor={iconColor} icon={!mixedIcons ? itemIcon : null}>
52
+ Some Item
53
+ </List.Item>
54
+ <List.Item iconColor={iconColor} icon={itemIcon}>
55
+ Some Item
56
+ </List.Item>
57
+ </List>
58
+ )
59
+ }
60
+ Default.storyName = 'Default'
61
+
62
+ export const Variants = Template.bind({})
63
+
64
+ export const WithIcon = (args) => {
65
+ return (
66
+ <List {...args} variant={{ size: 'medium' }}>
67
+ <List.Item iconColor="green" icon={Checkmark}>
68
+ Some Item
69
+ </List.Item>
70
+ <List.Item>No Icon</List.Item>
71
+ <List.Item icon={ThumbsUp}>Different Icon</List.Item>
72
+ </List>
73
+ )
74
+ }
75
+
76
+ export const WithDivider = (args) => {
77
+ return (
78
+ <List {...args} showDivider>
79
+ <List.Item icon={Baby} iconSize={25}>
80
+ <Typography>Change the icon</Typography>
81
+ </List.Item>
82
+ <List.Item icon={Baby} iconSize={25}>
83
+ <Typography>Change the icon</Typography>
84
+ </List.Item>
85
+ <List.Item icon={Baby} iconSize={25}>
86
+ <Typography>Change the icon</Typography>
87
+ </List.Item>
88
+ </List>
89
+ )
90
+ }
91
+
92
+ export const WithHeadingAndDivider = (args) => {
93
+ return (
94
+ <List {...args} showDivider>
95
+ <List.Item icon={Baby} iconSize={25}>
96
+ <Typography variant={{ bold: true }}>Watch in glorious HD TV</Typography>
97
+ <Typography>
98
+ Optik TV puts you in the middle of the action, with the highest picture quality available.
99
+ </Typography>
100
+ </List.Item>
101
+ <List.Item icon={Baby} iconSize={25}>
102
+ <Typography variant={{ bold: true }}>Must use TELUS purple</Typography>
103
+ <Typography>
104
+ With a PVR capacity of 400 hours for HD and 100 hours for 4K, you’ll have lots of time to
105
+ catch up.
106
+ </Typography>
107
+ </List.Item>
108
+ <List.Item icon={Baby} iconSize={25}>
109
+ <Typography variant={{ bold: true }}>Emphasize points</Typography>
110
+ <Typography>
111
+ Did life get in the way of the game? Did you miss it all together? Replay up to 30 hours
112
+ after it’s aired.
113
+ </Typography>
114
+ </List.Item>
115
+ </List>
116
+ )
117
+ }
@@ -0,0 +1,113 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React, { useState } from 'react'
3
+
4
+ import { Radio, StackView, Typography } from '../../lib'
5
+ import { Container, EachParentType, parentTypesParams } from '../supports'
6
+
7
+ export default {
8
+ title: 'Base/Radio',
9
+ component: Radio,
10
+ argTypes: {
11
+ checked: {
12
+ control: { type: 'radio' },
13
+ options: [true, false, undefined]
14
+ }
15
+ },
16
+ args: {
17
+ label: 'Radio',
18
+ checked: undefined
19
+ }
20
+ }
21
+
22
+ const Template = (args) => (
23
+ <Container>
24
+ <Radio {...args} />
25
+ </Container>
26
+ )
27
+
28
+ export const Default = Template.bind({})
29
+ Default.argTypes = {
30
+ checked: { table: { disable: true } }
31
+ }
32
+
33
+ export const Controlled = Template.bind({})
34
+ Controlled.argTypes = {
35
+ defaultChecked: { table: { disable: true } }
36
+ }
37
+ Controlled.args = {
38
+ checked: false,
39
+ defaultChecked: undefined
40
+ }
41
+
42
+ export const Inactive = Template.bind({})
43
+ Inactive.argTypes = {
44
+ inactive: { table: { disable: true } }
45
+ }
46
+ Inactive.args = {
47
+ inactive: true
48
+ }
49
+
50
+ export const WithDescription = Template.bind({})
51
+ WithDescription.argTypes = {
52
+ description: { table: { disable: true } }
53
+ }
54
+ WithDescription.args = {
55
+ description: 'This is a description'
56
+ }
57
+
58
+ export const RadioGroup = (args) => {
59
+ const [value, setValue] = useState(1)
60
+ const handleChange = (val) => () => setValue(val)
61
+
62
+ return (
63
+ <Container>
64
+ <StackView accessibilityRole="radiogroup">
65
+ <Radio
66
+ {...args}
67
+ checked={value === 1}
68
+ label="Radio1"
69
+ onChange={handleChange(1)}
70
+ name="group"
71
+ value={1}
72
+ />
73
+ <Radio
74
+ {...args}
75
+ checked={value === 2}
76
+ label="Radio2"
77
+ onChange={handleChange(2)}
78
+ name="group"
79
+ value={2}
80
+ />
81
+ <Radio
82
+ {...args}
83
+ checked={value === 3}
84
+ label="Radio3"
85
+ onChange={handleChange(3)}
86
+ name="group"
87
+ value={3}
88
+ />
89
+ </StackView>
90
+ </Container>
91
+ )
92
+ }
93
+
94
+ export const ParentTypes = (args) => (
95
+ <EachParentType componentThemeName="Radio" {...args}>
96
+ {({ label, variant }) => (
97
+ <Container key={label}>
98
+ <Typography>{`${label} `}</Typography>
99
+ <Radio
100
+ {...args}
101
+ defaultChecked={false}
102
+ name="parentTypes"
103
+ value={label}
104
+ variant={variant}
105
+ />
106
+ </Container>
107
+ )}
108
+ </EachParentType>
109
+ )
110
+ ParentTypes.parameters = parentTypesParams
111
+ ParentTypes.args = {
112
+ defaultChecked: undefined
113
+ }
@@ -0,0 +1,55 @@
1
+ import React, { useState } from 'react'
2
+ import { Text } from 'react-native'
3
+
4
+ import { Select } from '../../lib'
5
+
6
+ export default {
7
+ title: 'Base/Select',
8
+ component: Select
9
+ }
10
+
11
+ const Template = (args) => (
12
+ <Select {...args}>
13
+ <Select.Item value="root-item-1">Root item 1</Select.Item>
14
+ <Select.Item value="root-item-2">Root item 2</Select.Item>
15
+ <Select.Group label="Group label">
16
+ <Select.Item value="group-item-1">Group item 1</Select.Item>
17
+ <Select.Item value="group-item-2">Group item 2</Select.Item>
18
+ </Select.Group>
19
+ <Select.Item value="root-item-3">Root item 3</Select.Item>
20
+ </Select>
21
+ )
22
+
23
+ export const Default = Template.bind({})
24
+ Default.args = {
25
+ label: 'Label',
26
+ hint: 'This is the hint (below)',
27
+ hintPosition: 'below',
28
+ tooltip: 'This is the tooltip content',
29
+ feedback: 'Some instructional feedback'
30
+ }
31
+
32
+ export const Inactive = Template.bind({})
33
+ Inactive.args = { inactive: true }
34
+
35
+ export const Placeholder = Template.bind({})
36
+ Placeholder.args = { placeholder: 'Please select an item...' }
37
+
38
+ export const Error = Template.bind({})
39
+ Error.args = { validation: 'error' }
40
+ export const Success = Template.bind({})
41
+ Success.args = { validation: 'success' }
42
+
43
+ export const Uncontrolled = Template.bind({})
44
+ Uncontrolled.args = { initialValue: 'root-item-3' }
45
+
46
+ // eslint-disable-next-line react/no-multi-comp
47
+ export const Controlled = () => {
48
+ const [value, setValue] = useState('root-item-3')
49
+ return (
50
+ <>
51
+ <Template value={value} onChange={setValue} />
52
+ <Text>Value is: {value}</Text>
53
+ </>
54
+ )
55
+ }
@@ -0,0 +1,36 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React from 'react'
3
+ import { View, StyleSheet } from 'react-native'
4
+ import StackView from '../../lib/StackView'
5
+
6
+ import { Skeleton } from '../../lib'
7
+
8
+ export default {
9
+ title: 'Base/Skeleton',
10
+ component: Skeleton
11
+ }
12
+
13
+ export const Default = (args) => <Skeleton {...args} lines={8} />
14
+
15
+ export const Circle = (args) => <Skeleton {...args} size={20} shape="circle" />
16
+
17
+ export const Box = (args) => <Skeleton {...args} size={20} shape="box" />
18
+
19
+ export const Component = (args) => (
20
+ <StackView space={2} direction="row">
21
+ <View style={style.cardContainer}>
22
+ <Skeleton {...args} size={10} shape="circle" />
23
+ <Skeleton size={4} characters={3} />
24
+ </View>
25
+ <Skeleton {...args} lines={6} />
26
+ </StackView>
27
+ )
28
+
29
+ const style = StyleSheet.create({
30
+ cardContainer: {
31
+ justifyContent: 'space-between',
32
+ alignItems: 'center'
33
+ }
34
+ })
35
+
36
+ Default.storyName = 'Skeleton'
@@ -0,0 +1,69 @@
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React, { useState } from 'react'
3
+ import { View } from 'react-native'
4
+ import { Tags, Typography } from '../../lib'
5
+ import { Container } from '../supports'
6
+
7
+ const defaultArgs = {
8
+ items: [
9
+ { label: 'First item', id: 'first' },
10
+ { label: 'Second item', id: 'second' },
11
+ { label: 'Third item', id: 'third' },
12
+ { label: 'Fourth item', id: 'fourth' },
13
+ { label: 'Fifth item', id: 'fifth' },
14
+ { label: 'Sixth item', id: 'sixth' }
15
+ ],
16
+ initialValues: ['second', 'fourth']
17
+ }
18
+ const defaultControlledArgs = {
19
+ ...defaultArgs,
20
+ values: defaultArgs.initialValues,
21
+ initialValues: undefined
22
+ }
23
+
24
+ export default {
25
+ title: 'Base/Tags',
26
+ component: Tags,
27
+ args: {
28
+ ...defaultArgs
29
+ }
30
+ }
31
+
32
+ const UncontrolledTemplate = (args) => <Tags {...args} />
33
+ UncontrolledTemplate.propTypes = Tags.propTypes
34
+
35
+ const ControlledTemplate = ({ values, ...args }) => {
36
+ // Simulate saving and retrieving data from a server
37
+ const [isSaving, setIsSaving] = useState(false)
38
+ const [currentValues, setValues] = useState(values)
39
+ const handleChange = (newValue) => {
40
+ setIsSaving(true)
41
+ setTimeout(() => {
42
+ setValues(newValue)
43
+ setIsSaving(false)
44
+ }, 400)
45
+ }
46
+
47
+ const text = isSaving ? 'Saving...' : `Saved selected tags: "${currentValues.join('", "')}".`
48
+ return (
49
+ <View>
50
+ <Container padding={4} margin={0}>
51
+ <Typography variant={{ size: 'small', colour: 'secondary' }}>{text}</Typography>
52
+ </Container>
53
+ <Container padding={4} margin={0}>
54
+ <Tags {...args} values={currentValues} onChange={handleChange} />
55
+ </Container>
56
+ </View>
57
+ )
58
+ }
59
+
60
+ ControlledTemplate.propTypes = Tags.propTypes
61
+
62
+ export const Default = UncontrolledTemplate.bind({})
63
+ Default.storyName = 'Tags'
64
+
65
+ export const TagsControlled = ControlledTemplate.bind({})
66
+ TagsControlled.args = { ...defaultControlledArgs }
67
+
68
+ export const TagsInactive = UncontrolledTemplate.bind({})
69
+ TagsInactive.args = { inactive: true }
@@ -0,0 +1,100 @@
1
+ import React, { useEffect, useState } from 'react'
2
+
3
+ import { TextArea } from '../../lib'
4
+ import { Container } from '../supports'
5
+
6
+ export default {
7
+ title: 'Base/TextArea',
8
+ component: TextArea
9
+ }
10
+
11
+ const Template = (args) => <TextArea {...args} />
12
+
13
+ export const Default = Template.bind({})
14
+ Default.args = {
15
+ label: 'Label',
16
+ hint: 'This is a hint',
17
+ tooltip: 'This is a tooltip',
18
+ feedback: 'This is the feedback'
19
+ }
20
+
21
+ export const WithHint = () => {
22
+ return (
23
+ <>
24
+ <Container>
25
+ <TextArea label="Label" hint="An inline hint" tooltip="Tooltip content" />
26
+ </Container>
27
+ <Container>
28
+ <TextArea
29
+ label="Label"
30
+ hint="A usually much longer hint below"
31
+ hintPosition="below"
32
+ tooltip="Tooltip content"
33
+ />
34
+ </Container>
35
+ </>
36
+ )
37
+ }
38
+
39
+ export const WithFeedback = () => {
40
+ return (
41
+ <>
42
+ <Container>
43
+ <TextArea label="Instructional" feedback="An instructional feedback" />
44
+ </Container>
45
+ <Container>
46
+ <TextArea label="Success" validation="success" feedback="A detailed success message" />
47
+ </Container>
48
+ <Container>
49
+ <TextArea label="Error" validation="error" feedback="A detailed error message" />
50
+ </Container>
51
+ </>
52
+ )
53
+ }
54
+
55
+ export const InactiveAndReadOnly = () => {
56
+ return (
57
+ <>
58
+ <Container>
59
+ <TextArea label="Inactive" inactive initialValue="can't touch this" />
60
+ </Container>
61
+ <Container>
62
+ <TextArea label="Read only" readOnly value="won't change" />
63
+ </Container>
64
+ </>
65
+ )
66
+ }
67
+
68
+ export const Controlled = () => {
69
+ const [value, setValue] = useState('')
70
+ const [validation, setValidation] = useState()
71
+
72
+ useEffect(() => {
73
+ if (value !== undefined && value.length > 0)
74
+ setValidation(value.length < 6 ? 'success' : 'error')
75
+ }, [value])
76
+
77
+ const defaultFeedbackContent =
78
+ 'Will show an error if longer than 6 characters and success otherwise'
79
+
80
+ const feedbackContent = {
81
+ error: 'The value must be shorter than 6 characters',
82
+ success: 'Yay! The value has less than 6 characters'
83
+ }
84
+
85
+ const feedback = validation === undefined ? defaultFeedbackContent : feedbackContent[validation]
86
+
87
+ return (
88
+ <>
89
+ <Container>
90
+ <TextArea
91
+ label="Controlled"
92
+ validation={validation}
93
+ feedback={feedback}
94
+ value={value}
95
+ onChange={setValue}
96
+ />
97
+ </Container>
98
+ </>
99
+ )
100
+ }
@@ -150,7 +150,7 @@ export const useVariants = (componentName) => {
150
150
  }
151
151
 
152
152
  const variants = Object.entries(appearances).reduce(
153
- (pairs, [key, { values, type }]) =>
153
+ (pairs, [key, { values, type } = {}]) =>
154
154
  type === 'variant'
155
155
  ? [...pairs, ...values.map((value) => [key, value, getVariantLabel(key, value)])]
156
156
  : pairs,