@telus-uds/components-base 1.0.0 → 1.2.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.
- package/.storybook/main.js +4 -0
- package/.storybook/preview.js +37 -0
- package/.ultra.cache.json +1 -1
- package/CHANGELOG.md +26 -0
- package/README.md +1 -1
- package/__fixtures__/Accessible.js +4 -2
- package/__fixtures__/Accessible.native.js +5 -2
- package/__fixtures__/testTheme.js +9 -0
- package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
- package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
- package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/babel.config.js +9 -16
- package/component-docs.json +10131 -0
- package/generate-component-docs.js +56 -0
- package/lib/Box/Box.js +1 -0
- package/lib/Button/ButtonBase.js +20 -6
- package/lib/Card/CardBase.js +1 -0
- package/lib/Card/PressableCardBase.js +9 -3
- package/lib/Checkbox/Checkbox.js +0 -2
- package/lib/FlexGrid/FlexGrid.js +1 -1
- package/lib/IconButton/IconButton.js +8 -3
- package/lib/Link/LinkBase.js +10 -3
- package/lib/List/List.js +1 -2
- package/lib/List/ListItem.js +14 -27
- package/lib/List/index.js +15 -0
- package/lib/Pagination/PageButton.js +4 -8
- package/lib/Pagination/Pagination.js +16 -4
- package/lib/Pagination/SideButton.js +3 -1
- package/lib/Radio/Radio.js +0 -2
- package/lib/StackView/StackView.js +1 -0
- package/lib/StackView/StackWrap.js +9 -5
- package/lib/StackView/StackWrapBox.js +1 -0
- package/lib/Tabs/Tabs.js +12 -4
- package/lib/Tabs/TabsItem.js +12 -6
- package/lib/ToggleSwitch/ToggleSwitch.js +99 -37
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
- package/lib/ToggleSwitch/index.js +14 -4
- package/lib/index.js +28 -9
- package/lib/utils/a11y/propTypes.js +61 -0
- package/lib/utils/a11y/propTypes.native.js +47 -0
- package/lib/utils/index.js +10 -1
- package/lib/utils/propTypes.js +35 -91
- package/lib/utils/withLinkRouter.js +98 -0
- package/package.json +10 -6
- package/release-context.json +4 -4
- package/src/Box/Box.jsx +1 -0
- package/src/Button/ButtonBase.jsx +11 -4
- package/src/Card/CardBase.jsx +1 -0
- package/src/Card/PressableCardBase.jsx +6 -4
- package/src/Checkbox/Checkbox.jsx +0 -2
- package/src/FlexGrid/FlexGrid.jsx +1 -1
- package/src/IconButton/IconButton.jsx +6 -4
- package/src/Link/LinkBase.jsx +6 -4
- package/src/List/List.jsx +1 -3
- package/src/List/ListItem.jsx +11 -26
- package/src/List/index.js +5 -0
- package/src/Pagination/PageButton.jsx +5 -8
- package/src/Pagination/Pagination.jsx +29 -2
- package/src/Pagination/SideButton.jsx +2 -2
- package/src/Radio/Radio.jsx +0 -2
- package/src/StackView/StackView.jsx +1 -0
- package/src/StackView/StackWrap.jsx +7 -6
- package/src/StackView/StackWrapBox.jsx +1 -0
- package/src/Tabs/Tabs.jsx +49 -22
- package/src/Tabs/TabsItem.jsx +11 -7
- package/src/ToggleSwitch/ToggleSwitch.jsx +92 -34
- package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
- package/src/ToggleSwitch/index.js +2 -1
- package/src/index.js +2 -2
- package/src/utils/a11y/propTypes.js +61 -0
- package/src/utils/a11y/propTypes.native.js +39 -0
- package/src/utils/index.js +1 -0
- package/src/utils/propTypes.js +33 -111
- package/src/utils/withLinkRouter.jsx +68 -0
- package/stories/A11yText/A11yText.stories.jsx +1 -1
- package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
- package/stories/Box/Box.stories.jsx +1 -1
- package/stories/Button/Button.stories.jsx +1 -1
- package/stories/Button/ButtonGroup.stories.jsx +1 -1
- package/stories/Button/ButtonLink.stories.jsx +1 -1
- package/stories/Card/Card.stories.jsx +1 -1
- package/stories/Checkbox/Checkbox.stories.jsx +1 -1
- package/stories/Divider/Divider.stories.jsx +1 -1
- package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
- package/stories/Feedback/Feedback.stories.jsx +1 -1
- package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
- package/stories/FlexGrid/02 Row.stories.jsx +1 -1
- package/stories/FlexGrid/03 Col.stories.jsx +1 -1
- package/stories/Icon/Icon.stories.jsx +1 -1
- package/stories/IconButton/IconButton.stories.jsx +1 -1
- package/stories/InputLabel/InputLabel.stories.jsx +1 -1
- package/stories/Link/ChevronLink.stories.jsx +1 -1
- package/stories/Link/Link.stories.jsx +1 -1
- package/stories/Link/TextButton.stories.jsx +1 -1
- package/stories/List/List.stories.jsx +1 -1
- package/stories/Modal/Modal.stories.jsx +1 -1
- package/stories/Notification/Notification.stories.jsx +1 -1
- package/stories/Pagination/Pagination.stories.jsx +1 -1
- package/stories/Progress/Progress.stories.jsx +1 -1
- package/stories/Radio/Radio.stories.jsx +1 -1
- package/stories/RadioCard/RadioCard.stories.jsx +1 -1
- package/stories/Search/Search.stories.jsx +1 -1
- package/stories/Select/Select.stories.jsx +1 -1
- package/stories/SideNav/SideNav.stories.jsx +1 -1
- package/stories/SideNav/SideNavItem.stories.jsx +1 -1
- package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
- package/stories/Skeleton/Skeleton.stories.jsx +1 -1
- package/stories/Spacer/Spacer.stories.jsx +1 -1
- package/stories/StackView/StackView.stories.jsx +1 -1
- package/stories/StackView/StackWrap.stories.jsx +1 -1
- package/stories/StepTracker/StepTracker.stories.jsx +1 -1
- package/stories/Tabs/Tabs.stories.jsx +1 -1
- package/stories/Tags/Tags.stories.jsx +1 -1
- package/stories/TextInput/TextArea.stories.jsx +2 -1
- package/stories/TextInput/TextInput.stories.jsx +1 -1
- package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
- package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
- package/stories/Tooltip/Tooltip.stories.jsx +1 -1
- package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
- package/stories/Typography/Typography.stories.jsx +1 -1
- package/stories/supports.jsx +2 -3
|
@@ -5,7 +5,7 @@ import { ChevronLink } from '../../src'
|
|
|
5
5
|
import { Container, EachParentType, parentTypesParams, useVariants } from '../supports'
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
|
-
title: '
|
|
8
|
+
title: 'ChevronLink',
|
|
9
9
|
component: ChevronLink,
|
|
10
10
|
args: {
|
|
11
11
|
href: 'https://example.com'
|
|
@@ -8,7 +8,7 @@ import { Link, Typography, variantProp } from '../../src'
|
|
|
8
8
|
import { Container, EachIcon, EachParentType, parentTypesParams, useVariants } from '../supports'
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
title: '
|
|
11
|
+
title: 'Link',
|
|
12
12
|
component: Link,
|
|
13
13
|
args: {
|
|
14
14
|
href: `https://telus.com/?unvisited:${Date.now()}`,
|
|
@@ -10,7 +10,7 @@ import { TextButton, variantProp } from '../../src'
|
|
|
10
10
|
import { Container, EachParentType, useVariants, parentTypesParams } from '../supports'
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
|
-
title: '
|
|
13
|
+
title: 'TextButton',
|
|
14
14
|
component: TextButton,
|
|
15
15
|
args: {
|
|
16
16
|
// eslint-disable-next-line no-console
|
|
@@ -5,7 +5,7 @@ import { Progress, StackView, Typography } from '../../src'
|
|
|
5
5
|
import { Container, EachParentType, parentTypesParams } from '../supports'
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
|
-
title: '
|
|
8
|
+
title: 'Progress',
|
|
9
9
|
component: Progress.Bar,
|
|
10
10
|
args: { accessibilityLabel: 'Progress Bar' }
|
|
11
11
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
1
2
|
import React, { useEffect, useState } from 'react'
|
|
2
3
|
|
|
3
4
|
import { TextArea } from '../../src'
|
|
4
5
|
import { Container } from '../supports'
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
|
-
title: '
|
|
8
|
+
title: 'TextArea',
|
|
8
9
|
component: TextArea
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -8,8 +8,12 @@ export const Default = (args) => <ToggleSwitch {...args} />
|
|
|
8
8
|
Default.storyName = 'ToggleSwitch'
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
title: '
|
|
12
|
-
component: ToggleSwitch
|
|
11
|
+
title: 'ToggleSwitch',
|
|
12
|
+
component: ToggleSwitch,
|
|
13
|
+
args: {
|
|
14
|
+
label: 'Enable data',
|
|
15
|
+
tooltip: 'Toggle this on to enable data'
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export const ToggleSwitchControlled = (args) => {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
import React, { useState } from 'react'
|
|
3
|
+
import { View } from 'react-native'
|
|
4
|
+
import { ToggleSwitchGroup, Typography } from '../../src'
|
|
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: 'ToggleSwitchGroup',
|
|
26
|
+
component: ToggleSwitchGroup,
|
|
27
|
+
args: {
|
|
28
|
+
...defaultArgs
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const UncontrolledTemplate = (args) => <ToggleSwitchGroup {...args} />
|
|
33
|
+
UncontrolledTemplate.propTypes = ToggleSwitchGroup.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 IDs: "${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
|
+
<ToggleSwitchGroup {...args} values={currentValues} onChange={handleChange} />
|
|
55
|
+
</Container>
|
|
56
|
+
</View>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ControlledTemplate.propTypes = ToggleSwitchGroup.propTypes
|
|
61
|
+
|
|
62
|
+
export const Default = UncontrolledTemplate.bind({})
|
|
63
|
+
Default.storyName = 'ToggleSwitchGroup'
|
|
64
|
+
|
|
65
|
+
export const ToggleSwitchGroupMaxThree = UncontrolledTemplate.bind({})
|
|
66
|
+
ToggleSwitchGroupMaxThree.args = { maxValues: 3 }
|
|
67
|
+
|
|
68
|
+
export const ToggleSwitchGroupMaxUnlimited = UncontrolledTemplate.bind({})
|
|
69
|
+
ToggleSwitchGroupMaxUnlimited.args = { maxValues: null }
|
|
70
|
+
|
|
71
|
+
export const ToggleSwitchGroupControlled = ControlledTemplate.bind({})
|
|
72
|
+
ToggleSwitchGroupControlled.args = { ...defaultControlledArgs }
|
|
73
|
+
|
|
74
|
+
export const ToggleSwitchGroupControlledMaxThree = ControlledTemplate.bind({})
|
|
75
|
+
ToggleSwitchGroupControlledMaxThree.args = { ...defaultControlledArgs, maxValues: 3 }
|
|
76
|
+
|
|
77
|
+
export const ToggleSwitchGroupControlledMaxUnlimited = ControlledTemplate.bind({})
|
|
78
|
+
ToggleSwitchGroupControlledMaxUnlimited.args = { ...defaultControlledArgs, maxValues: null }
|
|
79
|
+
|
|
80
|
+
export const ToggleSwitchGroupInactive = UncontrolledTemplate.bind({})
|
|
81
|
+
ToggleSwitchGroupInactive.args = { inactive: true }
|
package/stories/supports.jsx
CHANGED
|
@@ -3,12 +3,11 @@ import React from 'react'
|
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import { Platform, ScrollView, Text, View, StyleSheet } from 'react-native'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
7
7
|
import * as alliumIcons from '@telus-uds/palette-allium/build/rn/icons'
|
|
8
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
8
|
import * as koodoIcons from '@telus-uds/palette-koodo/build/rn/icons'
|
|
10
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
11
9
|
import * as pmIcons from '@telus-uds/palette-public-mobile/build/rn/icons'
|
|
10
|
+
/* eslint-enable import/no-extraneous-dependencies */
|
|
12
11
|
|
|
13
12
|
import { useTheme, getComponentTheme } from '../src/ThemeProvider'
|
|
14
13
|
import { Typography } from '../src'
|