@telus-uds/components-base 1.4.0 → 1.6.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 +8 -8
- package/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.json +140 -1
- package/CHANGELOG.md +42 -2
- package/__tests__/FlexGrid/Row.test.jsx +100 -25
- package/__tests__/utils/containUniqueFields.test.js +25 -0
- package/component-docs.json +94 -16
- package/generate-component-docs.js +20 -7
- package/lib/Button/ButtonBase.js +1 -1
- package/lib/Button/ButtonGroup.js +20 -12
- package/lib/Card/PressableCardBase.js +1 -1
- package/lib/Checkbox/Checkbox.js +27 -16
- package/lib/Checkbox/CheckboxGroup.js +19 -5
- package/lib/ExpandCollapse/Panel.js +10 -10
- package/lib/FlexGrid/Col/Col.js +13 -3
- package/lib/FlexGrid/Row/Row.js +8 -2
- package/lib/HorizontalScroll/HorizontalScroll.js +0 -1
- package/lib/HorizontalScroll/HorizontalScrollButton.js +23 -49
- package/lib/InputLabel/InputLabel.js +27 -25
- package/lib/Link/LinkBase.js +19 -6
- package/lib/Link/TextButton.js +1 -10
- package/lib/Modal/Modal.js +18 -18
- package/lib/Radio/Radio.js +23 -12
- package/lib/Radio/RadioGroup.js +12 -3
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +11 -2
- package/lib/Select/Select.js +2 -3
- package/lib/Tags/Tags.js +23 -17
- package/lib/TextInput/TextArea.js +2 -2
- package/lib/TextInput/TextInput.js +12 -2
- package/lib/TextInput/TextInputBase.js +1 -1
- package/lib/TextInput/propTypes.js +8 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +5 -2
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +20 -12
- package/lib/utils/containUniqueFields.js +34 -0
- package/lib/utils/index.js +10 -1
- package/lib/utils/props/handlerProps.js +72 -0
- package/lib/utils/props/index.js +14 -0
- package/lib/utils/props/inputSupportsProps.js +3 -5
- package/lib/utils/props/linkProps.js +3 -7
- package/lib-module/Button/ButtonBase.js +2 -2
- package/lib-module/Button/ButtonGroup.js +15 -6
- package/lib-module/Card/PressableCardBase.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +28 -17
- package/lib-module/Checkbox/CheckboxGroup.js +20 -7
- package/lib-module/ExpandCollapse/Panel.js +10 -10
- package/lib-module/FlexGrid/Col/Col.js +13 -3
- package/lib-module/FlexGrid/Row/Row.js +8 -2
- package/lib-module/HorizontalScroll/HorizontalScroll.js +0 -1
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +24 -49
- package/lib-module/InputLabel/InputLabel.js +28 -25
- package/lib-module/Link/LinkBase.js +19 -6
- package/lib-module/Link/TextButton.js +1 -10
- package/lib-module/Modal/Modal.js +19 -19
- package/lib-module/Radio/Radio.js +24 -13
- package/lib-module/Radio/RadioGroup.js +13 -4
- package/lib-module/RadioCard/RadioCard.js +2 -2
- package/lib-module/RadioCard/RadioCardGroup.js +12 -3
- package/lib-module/Select/Select.js +2 -3
- package/lib-module/Tags/Tags.js +18 -11
- package/lib-module/TextInput/TextArea.js +3 -3
- package/lib-module/TextInput/TextInput.js +11 -3
- package/lib-module/TextInput/TextInputBase.js +2 -2
- package/lib-module/TextInput/propTypes.js +7 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +6 -3
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +15 -6
- package/lib-module/utils/containUniqueFields.js +26 -0
- package/lib-module/utils/index.js +2 -1
- package/lib-module/utils/props/handlerProps.js +59 -0
- package/lib-module/utils/props/index.js +1 -0
- package/lib-module/utils/props/inputSupportsProps.js +3 -5
- package/lib-module/utils/props/linkProps.js +3 -7
- package/package.json +5 -5
- package/src/Button/ButtonBase.jsx +8 -2
- package/src/Button/ButtonGroup.jsx +51 -34
- package/src/Card/PressableCardBase.jsx +6 -1
- package/src/Checkbox/Checkbox.jsx +35 -23
- package/src/Checkbox/CheckboxGroup.jsx +52 -22
- package/src/ExpandCollapse/Panel.jsx +9 -9
- package/src/FlexGrid/Col/Col.jsx +11 -2
- package/src/FlexGrid/Row/Row.jsx +8 -2
- package/src/HorizontalScroll/HorizontalScroll.jsx +1 -1
- package/src/HorizontalScroll/HorizontalScrollButton.jsx +21 -58
- package/src/InputLabel/InputLabel.jsx +36 -27
- package/src/Link/LinkBase.jsx +20 -4
- package/src/Link/TextButton.jsx +1 -19
- package/src/Modal/Modal.jsx +30 -26
- package/src/Radio/Radio.jsx +26 -14
- package/src/Radio/RadioGroup.jsx +39 -21
- package/src/RadioCard/RadioCard.jsx +6 -1
- package/src/RadioCard/RadioCardGroup.jsx +17 -1
- package/src/Select/Select.jsx +2 -2
- package/src/Tags/Tags.jsx +23 -9
- package/src/TextInput/TextArea.jsx +5 -1
- package/src/TextInput/TextInput.jsx +13 -3
- package/src/TextInput/TextInputBase.jsx +6 -1
- package/src/TextInput/propTypes.js +7 -1
- package/src/ToggleSwitch/ToggleSwitch.jsx +11 -2
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +19 -6
- package/src/utils/containUniqueFields.js +32 -0
- package/src/utils/index.js +1 -0
- package/src/utils/props/handlerProps.js +47 -0
- package/src/utils/props/index.js +1 -0
- package/src/utils/props/inputSupportsProps.js +3 -4
- package/src/utils/props/linkProps.js +3 -6
- package/stories/InputLabel/InputLabel.stories.jsx +25 -28
- package/stories/Modal/Modal.stories.jsx +25 -0
- package/stories/Search/Search.stories.jsx +4 -1
- package/stories/TextInput/TextInput.stories.jsx +40 -2
- package/__tests__/Link/LinkBase.test.jsx +0 -22
|
@@ -22,16 +22,13 @@ export default {
|
|
|
22
22
|
*/
|
|
23
23
|
select: getPropSelector(linkPropTypes),
|
|
24
24
|
/**
|
|
25
|
-
* Turn hrefs into press handlers
|
|
25
|
+
* Turn hrefs into press handlers that open links on Native.
|
|
26
26
|
*
|
|
27
27
|
* @param {({ onPress?: () => void, href?: string })}
|
|
28
|
-
* @returns {(() => void)|undefined} Returns a press handler, or undefined on web if
|
|
29
|
-
*
|
|
28
|
+
* @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
|
|
29
|
+
* handler is provided (expects calling component to render as `<a href={href}>` on web).
|
|
30
30
|
*/
|
|
31
31
|
handleHref: ({ onPress, href }) => {
|
|
32
|
-
if (!href && !onPress) {
|
|
33
|
-
throw new Error('handleHref requires either href or onPress')
|
|
34
|
-
}
|
|
35
32
|
return Platform.select({
|
|
36
33
|
web: onPress,
|
|
37
34
|
default: (...args) => {
|
|
@@ -8,35 +8,32 @@ export default {
|
|
|
8
8
|
component: InputLabel
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const Default = () => <InputLabel
|
|
11
|
+
export const Default = (args) => <InputLabel {...args} />
|
|
12
|
+
Default.args = { label: 'Test label' }
|
|
12
13
|
|
|
13
|
-
export const HintInline = () =>
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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,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
|
-
})
|