@telus-uds/components-base 1.5.0 → 1.7.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 (125) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/.turbo/turbo-lint.log +13 -0
  3. package/CHANGELOG.json +154 -1
  4. package/CHANGELOG.md +47 -2
  5. package/__tests__/FlexGrid/Row.test.jsx +100 -25
  6. package/__tests__/utils/containUniqueFields.test.js +25 -0
  7. package/component-docs.json +78 -26
  8. package/generate-component-docs.js +20 -7
  9. package/lib/Button/ButtonBase.js +1 -1
  10. package/lib/Button/ButtonGroup.js +20 -12
  11. package/lib/Card/PressableCardBase.js +1 -1
  12. package/lib/Checkbox/Checkbox.js +27 -16
  13. package/lib/Checkbox/CheckboxGroup.js +19 -5
  14. package/lib/ExpandCollapse/Panel.js +10 -10
  15. package/lib/FlexGrid/Col/Col.js +13 -3
  16. package/lib/FlexGrid/Row/Row.js +8 -2
  17. package/lib/InputLabel/InputLabel.js +27 -25
  18. package/lib/Link/LinkBase.js +19 -6
  19. package/lib/Link/TextButton.js +1 -10
  20. package/lib/List/ListItem.js +22 -12
  21. package/lib/Modal/Modal.js +18 -18
  22. package/lib/Radio/Radio.js +23 -12
  23. package/lib/Radio/RadioGroup.js +12 -3
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +11 -2
  26. package/lib/Search/Search.js +27 -19
  27. package/lib/Select/Select.js +2 -3
  28. package/lib/Tags/Tags.js +23 -17
  29. package/lib/TextInput/TextArea.js +2 -2
  30. package/lib/TextInput/TextInput.js +12 -2
  31. package/lib/TextInput/TextInputBase.js +1 -1
  32. package/lib/TextInput/propTypes.js +8 -1
  33. package/lib/ToggleSwitch/ToggleSwitch.js +5 -2
  34. package/lib/ToggleSwitch/ToggleSwitchGroup.js +20 -12
  35. package/lib/Typography/Typography.js +12 -10
  36. package/lib/index.js +22 -1
  37. package/lib/utils/containUniqueFields.js +34 -0
  38. package/lib/utils/index.js +10 -1
  39. package/lib/utils/input.js +5 -6
  40. package/lib/utils/props/handlerProps.js +72 -0
  41. package/lib/utils/props/index.js +32 -0
  42. package/lib/utils/props/inputSupportsProps.js +3 -5
  43. package/lib/utils/props/linkProps.js +3 -7
  44. package/lib/utils/props/textInputProps.js +206 -0
  45. package/lib/utils/props/textProps.js +72 -0
  46. package/lib-module/Button/ButtonBase.js +2 -2
  47. package/lib-module/Button/ButtonGroup.js +15 -6
  48. package/lib-module/Card/PressableCardBase.js +2 -2
  49. package/lib-module/Checkbox/Checkbox.js +28 -17
  50. package/lib-module/Checkbox/CheckboxGroup.js +20 -7
  51. package/lib-module/ExpandCollapse/Panel.js +10 -10
  52. package/lib-module/FlexGrid/Col/Col.js +13 -3
  53. package/lib-module/FlexGrid/Row/Row.js +8 -2
  54. package/lib-module/InputLabel/InputLabel.js +28 -25
  55. package/lib-module/Link/LinkBase.js +19 -6
  56. package/lib-module/Link/TextButton.js +1 -10
  57. package/lib-module/List/ListItem.js +22 -12
  58. package/lib-module/Modal/Modal.js +19 -19
  59. package/lib-module/Radio/Radio.js +24 -13
  60. package/lib-module/Radio/RadioGroup.js +13 -4
  61. package/lib-module/RadioCard/RadioCard.js +2 -2
  62. package/lib-module/RadioCard/RadioCardGroup.js +12 -3
  63. package/lib-module/Search/Search.js +29 -21
  64. package/lib-module/Select/Select.js +2 -3
  65. package/lib-module/Tags/Tags.js +18 -11
  66. package/lib-module/TextInput/TextArea.js +3 -3
  67. package/lib-module/TextInput/TextInput.js +11 -3
  68. package/lib-module/TextInput/TextInputBase.js +2 -2
  69. package/lib-module/TextInput/propTypes.js +7 -1
  70. package/lib-module/ToggleSwitch/ToggleSwitch.js +6 -3
  71. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +15 -6
  72. package/lib-module/Typography/Typography.js +13 -11
  73. package/lib-module/index.js +1 -1
  74. package/lib-module/utils/containUniqueFields.js +26 -0
  75. package/lib-module/utils/index.js +2 -1
  76. package/lib-module/utils/input.js +6 -6
  77. package/lib-module/utils/props/handlerProps.js +59 -0
  78. package/lib-module/utils/props/index.js +3 -0
  79. package/lib-module/utils/props/inputSupportsProps.js +3 -5
  80. package/lib-module/utils/props/linkProps.js +3 -7
  81. package/lib-module/utils/props/textInputProps.js +193 -0
  82. package/lib-module/utils/props/textProps.js +59 -0
  83. package/package.json +5 -5
  84. package/src/Button/ButtonBase.jsx +8 -2
  85. package/src/Button/ButtonGroup.jsx +51 -34
  86. package/src/Card/PressableCardBase.jsx +6 -1
  87. package/src/Checkbox/Checkbox.jsx +35 -23
  88. package/src/Checkbox/CheckboxGroup.jsx +52 -22
  89. package/src/ExpandCollapse/Panel.jsx +9 -9
  90. package/src/FlexGrid/Col/Col.jsx +11 -2
  91. package/src/FlexGrid/Row/Row.jsx +8 -2
  92. package/src/InputLabel/InputLabel.jsx +36 -27
  93. package/src/Link/LinkBase.jsx +20 -4
  94. package/src/Link/TextButton.jsx +1 -19
  95. package/src/List/ListItem.jsx +17 -9
  96. package/src/Modal/Modal.jsx +30 -26
  97. package/src/Radio/Radio.jsx +26 -14
  98. package/src/Radio/RadioGroup.jsx +39 -21
  99. package/src/RadioCard/RadioCard.jsx +6 -1
  100. package/src/RadioCard/RadioCardGroup.jsx +17 -1
  101. package/src/Search/Search.jsx +33 -21
  102. package/src/Select/Select.jsx +2 -2
  103. package/src/Tags/Tags.jsx +23 -9
  104. package/src/TextInput/TextArea.jsx +7 -1
  105. package/src/TextInput/TextInput.jsx +15 -3
  106. package/src/TextInput/TextInputBase.jsx +8 -1
  107. package/src/TextInput/propTypes.js +7 -1
  108. package/src/ToggleSwitch/ToggleSwitch.jsx +11 -2
  109. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +19 -6
  110. package/src/Typography/Typography.jsx +13 -9
  111. package/src/index.js +4 -1
  112. package/src/utils/containUniqueFields.js +32 -0
  113. package/src/utils/index.js +1 -0
  114. package/src/utils/input.js +5 -7
  115. package/src/utils/props/handlerProps.js +47 -0
  116. package/src/utils/props/index.js +3 -0
  117. package/src/utils/props/inputSupportsProps.js +3 -4
  118. package/src/utils/props/linkProps.js +3 -6
  119. package/src/utils/props/textInputProps.js +177 -0
  120. package/src/utils/props/textProps.js +58 -0
  121. package/stories/InputLabel/InputLabel.stories.jsx +25 -28
  122. package/stories/Modal/Modal.stories.jsx +25 -0
  123. package/stories/Search/Search.stories.jsx +53 -3
  124. package/stories/TextInput/TextInput.stories.jsx +40 -2
  125. package/__tests__/Link/LinkBase.test.jsx +0 -22
@@ -8,35 +8,32 @@ export default {
8
8
  component: InputLabel
9
9
  }
10
10
 
11
- export const Default = () => <InputLabel label="Test label" />
11
+ export const Default = (args) => <InputLabel {...args} />
12
+ Default.args = { label: 'Test label' }
12
13
 
13
- export const HintInline = () => (
14
- <InputLabel label="Test label" hint="Short hint" hintPosition="inline" />
15
- )
14
+ export const HintInline = (args) => <InputLabel {...args} />
15
+ HintInline.args = { label: 'Test label', hint: 'Short hint', hintPosition: 'inline' }
16
16
 
17
- export const HintAndTooltip = () => (
18
- <InputLabel
19
- label="Test label"
20
- hint="Short hint"
21
- hintPosition="inline"
22
- tooltip="This is the tooltip's content"
23
- />
24
- )
17
+ export const HintAndTooltip = (args) => <InputLabel {...args} />
18
+ HintAndTooltip.args = {
19
+ label: 'Test label',
20
+ hint: 'Short hint',
21
+ hintPosition: 'inline',
22
+ tooltip: "This is the tooltip's content"
23
+ }
25
24
 
26
- export const HintInlineLong = () => (
27
- <InputLabel
28
- label="Test label"
29
- hint="A rather long hint that won't actually fit"
30
- hintPosition="inline"
31
- tooltip="This is the tooltip's content"
32
- />
33
- )
25
+ export const HintInlineLong = (args) => <InputLabel {...args} />
26
+ HintInlineLong.args = {
27
+ label: 'Test label',
28
+ hint: "A rather long hint that won't actually fit",
29
+ hintPosition: 'inline',
30
+ tooltip: "This is the tooltip's content"
31
+ }
34
32
 
35
- export const HintBelow = () => (
36
- <InputLabel
37
- label="Test label"
38
- hint="A rather long hint that won't actually fit"
39
- hintPosition="below"
40
- tooltip="This is the tooltip's content"
41
- />
42
- )
33
+ export const HintBelow = (args) => <InputLabel {...args} />
34
+ HintBelow.args = {
35
+ label: 'Test label',
36
+ hint: "A rather long hint that won't actually fit",
37
+ hintPosition: 'below',
38
+ tooltip: "This is the tooltip's content"
39
+ }
@@ -10,6 +10,8 @@ export default {
10
10
  export const Default = (args) => {
11
11
  const [isOpen, setIsOpen] = useState(false)
12
12
  const [isMaxWidthOpen, setIsMaxWidthOpen] = useState(false)
13
+ const [isCustomCloseOpen, setIsCustomCloseOpen] = useState(false)
14
+ const [isNoCloseOpen, setIsNoCloseOpen] = useState(false)
13
15
 
14
16
  return (
15
17
  <>
@@ -23,6 +25,29 @@ export const Default = (args) => {
23
25
  <Typography variant={{ size: 'h2' }}>Test heading</Typography>
24
26
  <Typography>Test content</Typography>
25
27
  </Modal>
28
+ <Spacer space={3} />
29
+ <Button onPress={() => setIsCustomCloseOpen(true)}>Open custom close button modal</Button>
30
+ <Modal
31
+ {...args}
32
+ isOpen={isCustomCloseOpen}
33
+ onClose={() => setIsCustomCloseOpen(false)}
34
+ closeButton={<Button onPress={() => setIsCustomCloseOpen(false)}>Close</Button>}
35
+ >
36
+ <Typography variant={{ size: 'h2' }}>Test heading</Typography>
37
+ <Typography>Test content</Typography>
38
+ </Modal>
39
+ <Spacer space={3} />
40
+ <Button onPress={() => setIsNoCloseOpen(true)}>Open modal without close button</Button>
41
+ <Modal
42
+ {...args}
43
+ isOpen={isNoCloseOpen}
44
+ onClose={() => setIsNoCloseOpen(false)}
45
+ closeButton={null}
46
+ >
47
+ <Typography variant={{ size: 'h2' }}>Test heading</Typography>
48
+ <Typography>A custom close button is added in the modal content.</Typography>
49
+ <Button onPress={() => setIsNoCloseOpen(false)}>Close</Button>
50
+ </Modal>
26
51
  </>
27
52
  )
28
53
  }
@@ -1,10 +1,14 @@
1
- import React from 'react'
1
+ /* eslint-disable react/no-multi-comp */
2
+ import React, { useRef, useState } from 'react'
2
3
 
3
- import { Search } from '../../src'
4
+ import { Search, StackView, TextButton, Typography, List, ListItem } from '../../src'
4
5
 
5
6
  export default {
6
7
  title: 'Search',
7
- component: Search
8
+ component: Search,
9
+ argTypes: {
10
+ onSubmit: { action: 'submitted' }
11
+ }
8
12
  }
9
13
 
10
14
  const Template = (args) => <Search {...args} />
@@ -14,3 +18,49 @@ Default.args = {}
14
18
 
15
19
  export const Inactive = Template.bind({})
16
20
  Inactive.args = { inactive: true }
21
+
22
+ // Lots of smartphone brands. No need to make the file really long, let them sit on one line.
23
+ // eslint-disable-next-line prettier/prettier
24
+ const options = ['Acer', 'Aermoo', 'AGM', 'Alcatel', 'Allcall', 'Allview', 'Amigoo', 'Amoi', 'Apple', 'Archos', 'Asus', 'Axgio', 'Black Shark', 'BlackBerry', 'Blackview', 'BLU', 'Bluboo', 'BQ', 'Bsimb', 'Cagabi', 'Cat', 'Caterpillar', 'Centric', 'China Mobile', 'Cong', 'Coolpad', 'Cubot', 'Dakele', 'Doogee', 'Doopro', 'E&L', 'Ecoo', 'Elephone', 'Energizer', 'Energy', 'Essential', 'EStar', 'Faea', 'Fairphone', 'Geotel', 'Gigabyte', 'Gigaset', 'Gionee', 'Gome', 'Google', 'Goophone', 'Gretel', 'Hafury', 'Haier', 'Hike', 'HiSense', 'HomTom', 'Honor', 'HP', 'HTC', 'Huawei', 'I Kall', 'iiiF150', 'iLA', 'iMan', 'iNew', 'Infinix', 'InFocus', 'InnJoo', 'Innos', 'Intex', 'iOcean', 'iRULU', 'IUNI', 'iVooMi', 'Jesy', 'Jiake', 'Jiayu', 'Karbonn', 'Kazam', 'Keecoo', 'Kenxinda', 'KingSing', 'KingZone', 'Kodak', 'Kolina', 'Koolnee', 'Landvo', 'Laude', 'Lava', 'Leagoo', 'LeEco (LeTV)', 'Lenovo', 'Leotec', 'LeRee', 'LG', 'Ly', 'Lyf', 'M-Horse', 'M-Net', 'Mann', 'Maze', 'Meiigoo', 'Meitu', 'Meizu', 'Micromax', 'Microsoft', 'Mijue', 'Milai', 'Mlais', 'Morefine', 'Motorola', 'Mpie', 'Mstar', 'MyWigo', 'Neken', 'Neo', 'Newman', 'NO.1', 'Noa', 'Nokia', 'Nomu', 'Nubia', 'Nubia Red Magic', 'NZone', 'OnePlus', 'Oppo', 'Otium', 'Oukitel', 'Palm', 'Panasonic', 'Pantech', 'Pepsi', 'Phicomm', 'Philips', 'Phonemax', 'Plunk', 'POCO', 'Pomp', 'Poptel', 'PPTV', 'Prestigio', 'Qiku', 'Ramos', 'Razer', 'realme', 'Runbo', 'Samsung', 'Sharp', 'Silent Circle', 'Siswoo', 'Smartisan', 'Snopow', 'Sony', 'Sony Ericsson', 'Star', 'Swipe', 'TCL', 'Tengda', 'THL', 'Tianhe', 'Timmy', 'TP-Link', 'Ubro', 'Uhans', 'Uhappy', 'Uimi', 'Ukozi', 'Ulefone', 'UMi', 'UMiDIGI', 'Vargo', 'Vernee', 'ViewSonic', 'Vivo', 'VKworld', 'Voto', 'VPhone', 'Vsmart', 'Weimei', 'Wico', 'Wiko', 'Wileyfox', 'Wolder', 'Woxter', 'Xiaomi', 'Xolo', 'Yota Devices', 'YU', 'Zoji', 'Zopo', 'ZTE', 'Zuk']
25
+
26
+ export const Controlled = (args) => {
27
+ const [value, setValue] = useState('')
28
+ const [searchedValue, setSearchedValue] = useState(null)
29
+ const searchRef = useRef()
30
+ const selectOption = (option) => {
31
+ setValue(option)
32
+ if (searchRef.current?.focus) searchRef.current?.focus()
33
+ }
34
+
35
+ return (
36
+ <StackView space={4}>
37
+ {searchedValue ? (
38
+ <>
39
+ <Typography>Search results page for {searchedValue}.</Typography>
40
+ <Typography>{searchedValue} phones are really good. You should buy one.</Typography>
41
+ <TextButton onPress={() => setSearchedValue(null)}>Go back</TextButton>
42
+ </>
43
+ ) : (
44
+ <>
45
+ <Search
46
+ {...args}
47
+ value={value}
48
+ onChange={setValue}
49
+ ref={searchRef}
50
+ onSubmit={setSearchedValue}
51
+ />
52
+ <List>
53
+ {options
54
+ .filter((option) => !value || option.toLowerCase().match(value.toLowerCase()))
55
+ .map((option) => (
56
+ <ListItem key={option}>
57
+ <TextButton onPress={() => selectOption(option)}>{option}</TextButton>
58
+ </ListItem>
59
+ ))}
60
+ </List>
61
+ </>
62
+ )}
63
+ </StackView>
64
+ )
65
+ }
66
+ Controlled.args = {}
@@ -1,6 +1,7 @@
1
- import React, { useEffect, useState } from 'react'
1
+ import React, { useEffect, useState, useRef } from 'react'
2
+ import { Platform } from 'react-native'
2
3
 
3
- import { TextInput } from '../../src'
4
+ import { TextInput, Typography } from '../../src'
4
5
  import { Container } from '../supports'
5
6
 
6
7
  export default {
@@ -101,3 +102,40 @@ export const Controlled = () => {
101
102
  </>
102
103
  )
103
104
  }
105
+
106
+ export const WithPattern = (args) => {
107
+ const [value, setValue] = useState('')
108
+ const inputRef = useRef(null)
109
+ const isEmpty = value === ''
110
+ const isSuccess = !isEmpty && inputRef.current.checkValidity()
111
+ // eslint-disable-next-line no-nested-ternary
112
+ const validation = isEmpty ? undefined : isSuccess ? 'success' : 'error'
113
+ const { pattern } = args
114
+ // eslint-disable-next-line no-nested-ternary
115
+ const feedback = isEmpty
116
+ ? `Enter value matching pattern: ${pattern}`
117
+ : isSuccess
118
+ ? `Success! Value matches pattern: ${pattern}`
119
+ : `Error! Value must match pattern: ${pattern}`
120
+ if (Platform.OS !== 'web') {
121
+ return <Typography>Pattern prop is only supported on web</Typography>
122
+ }
123
+ return (
124
+ <>
125
+ <Container>
126
+ <TextInput
127
+ {...args}
128
+ ref={inputRef}
129
+ label="Pattern"
130
+ validation={validation}
131
+ feedback={feedback}
132
+ value={value}
133
+ onChange={setValue}
134
+ />
135
+ </Container>
136
+ </>
137
+ )
138
+ }
139
+ WithPattern.args = {
140
+ pattern: '[1-9]{2}'
141
+ }
@@ -1,22 +0,0 @@
1
- /* eslint-disable no-console */
2
- import React from 'react'
3
- import { render } from '@testing-library/react-native'
4
-
5
- import Theme from '../../__fixtures__/Theme'
6
- import LinkBase from '../../src/Link/LinkBase'
7
-
8
- beforeEach(() => jest.clearAllMocks())
9
-
10
- describe('LinkBase', () => {
11
- it('throws if neither href nor onPress are provided', async () => {
12
- jest.spyOn(console, 'error').mockImplementation()
13
- expect(() =>
14
- render(
15
- <Theme>
16
- <LinkBase>click me</LinkBase>
17
- </Theme>
18
- )
19
- ).toThrow()
20
- expect(console.error).toHaveBeenCalledTimes(1)
21
- })
22
- })