@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.
Files changed (121) hide show
  1. package/.storybook/main.js +4 -0
  2. package/.storybook/preview.js +37 -0
  3. package/.ultra.cache.json +1 -1
  4. package/CHANGELOG.md +26 -0
  5. package/README.md +1 -1
  6. package/__fixtures__/Accessible.js +4 -2
  7. package/__fixtures__/Accessible.native.js +5 -2
  8. package/__fixtures__/testTheme.js +9 -0
  9. package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
  10. package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
  11. package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  12. package/babel.config.js +9 -16
  13. package/component-docs.json +10131 -0
  14. package/generate-component-docs.js +56 -0
  15. package/lib/Box/Box.js +1 -0
  16. package/lib/Button/ButtonBase.js +20 -6
  17. package/lib/Card/CardBase.js +1 -0
  18. package/lib/Card/PressableCardBase.js +9 -3
  19. package/lib/Checkbox/Checkbox.js +0 -2
  20. package/lib/FlexGrid/FlexGrid.js +1 -1
  21. package/lib/IconButton/IconButton.js +8 -3
  22. package/lib/Link/LinkBase.js +10 -3
  23. package/lib/List/List.js +1 -2
  24. package/lib/List/ListItem.js +14 -27
  25. package/lib/List/index.js +15 -0
  26. package/lib/Pagination/PageButton.js +4 -8
  27. package/lib/Pagination/Pagination.js +16 -4
  28. package/lib/Pagination/SideButton.js +3 -1
  29. package/lib/Radio/Radio.js +0 -2
  30. package/lib/StackView/StackView.js +1 -0
  31. package/lib/StackView/StackWrap.js +9 -5
  32. package/lib/StackView/StackWrapBox.js +1 -0
  33. package/lib/Tabs/Tabs.js +12 -4
  34. package/lib/Tabs/TabsItem.js +12 -6
  35. package/lib/ToggleSwitch/ToggleSwitch.js +99 -37
  36. package/lib/ToggleSwitch/ToggleSwitchGroup.js +230 -0
  37. package/lib/ToggleSwitch/index.js +14 -4
  38. package/lib/index.js +28 -9
  39. package/lib/utils/a11y/propTypes.js +61 -0
  40. package/lib/utils/a11y/propTypes.native.js +47 -0
  41. package/lib/utils/index.js +10 -1
  42. package/lib/utils/propTypes.js +35 -91
  43. package/lib/utils/withLinkRouter.js +98 -0
  44. package/package.json +10 -6
  45. package/release-context.json +4 -4
  46. package/src/Box/Box.jsx +1 -0
  47. package/src/Button/ButtonBase.jsx +11 -4
  48. package/src/Card/CardBase.jsx +1 -0
  49. package/src/Card/PressableCardBase.jsx +6 -4
  50. package/src/Checkbox/Checkbox.jsx +0 -2
  51. package/src/FlexGrid/FlexGrid.jsx +1 -1
  52. package/src/IconButton/IconButton.jsx +6 -4
  53. package/src/Link/LinkBase.jsx +6 -4
  54. package/src/List/List.jsx +1 -3
  55. package/src/List/ListItem.jsx +11 -26
  56. package/src/List/index.js +5 -0
  57. package/src/Pagination/PageButton.jsx +5 -8
  58. package/src/Pagination/Pagination.jsx +29 -2
  59. package/src/Pagination/SideButton.jsx +2 -2
  60. package/src/Radio/Radio.jsx +0 -2
  61. package/src/StackView/StackView.jsx +1 -0
  62. package/src/StackView/StackWrap.jsx +7 -6
  63. package/src/StackView/StackWrapBox.jsx +1 -0
  64. package/src/Tabs/Tabs.jsx +49 -22
  65. package/src/Tabs/TabsItem.jsx +11 -7
  66. package/src/ToggleSwitch/ToggleSwitch.jsx +92 -34
  67. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +203 -0
  68. package/src/ToggleSwitch/index.js +2 -1
  69. package/src/index.js +2 -2
  70. package/src/utils/a11y/propTypes.js +61 -0
  71. package/src/utils/a11y/propTypes.native.js +39 -0
  72. package/src/utils/index.js +1 -0
  73. package/src/utils/propTypes.js +33 -111
  74. package/src/utils/withLinkRouter.jsx +68 -0
  75. package/stories/A11yText/A11yText.stories.jsx +1 -1
  76. package/stories/ActivityIndicator/ActivityIndicator.stories.jsx +1 -1
  77. package/stories/Box/Box.stories.jsx +1 -1
  78. package/stories/Button/Button.stories.jsx +1 -1
  79. package/stories/Button/ButtonGroup.stories.jsx +1 -1
  80. package/stories/Button/ButtonLink.stories.jsx +1 -1
  81. package/stories/Card/Card.stories.jsx +1 -1
  82. package/stories/Checkbox/Checkbox.stories.jsx +1 -1
  83. package/stories/Divider/Divider.stories.jsx +1 -1
  84. package/stories/ExpandCollapse/ExpandCollapse.stories.jsx +1 -1
  85. package/stories/Feedback/Feedback.stories.jsx +1 -1
  86. package/stories/FlexGrid/01 FlexGrid.stories.jsx +1 -1
  87. package/stories/FlexGrid/02 Row.stories.jsx +1 -1
  88. package/stories/FlexGrid/03 Col.stories.jsx +1 -1
  89. package/stories/Icon/Icon.stories.jsx +1 -1
  90. package/stories/IconButton/IconButton.stories.jsx +1 -1
  91. package/stories/InputLabel/InputLabel.stories.jsx +1 -1
  92. package/stories/Link/ChevronLink.stories.jsx +1 -1
  93. package/stories/Link/Link.stories.jsx +1 -1
  94. package/stories/Link/TextButton.stories.jsx +1 -1
  95. package/stories/List/List.stories.jsx +1 -1
  96. package/stories/Modal/Modal.stories.jsx +1 -1
  97. package/stories/Notification/Notification.stories.jsx +1 -1
  98. package/stories/Pagination/Pagination.stories.jsx +1 -1
  99. package/stories/Progress/Progress.stories.jsx +1 -1
  100. package/stories/Radio/Radio.stories.jsx +1 -1
  101. package/stories/RadioCard/RadioCard.stories.jsx +1 -1
  102. package/stories/Search/Search.stories.jsx +1 -1
  103. package/stories/Select/Select.stories.jsx +1 -1
  104. package/stories/SideNav/SideNav.stories.jsx +1 -1
  105. package/stories/SideNav/SideNavItem.stories.jsx +1 -1
  106. package/stories/SideNav/SideNavItemsGroup.stories.jsx +1 -1
  107. package/stories/Skeleton/Skeleton.stories.jsx +1 -1
  108. package/stories/Spacer/Spacer.stories.jsx +1 -1
  109. package/stories/StackView/StackView.stories.jsx +1 -1
  110. package/stories/StackView/StackWrap.stories.jsx +1 -1
  111. package/stories/StepTracker/StepTracker.stories.jsx +1 -1
  112. package/stories/Tabs/Tabs.stories.jsx +1 -1
  113. package/stories/Tags/Tags.stories.jsx +1 -1
  114. package/stories/TextInput/TextArea.stories.jsx +2 -1
  115. package/stories/TextInput/TextInput.stories.jsx +1 -1
  116. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +6 -2
  117. package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
  118. package/stories/Tooltip/Tooltip.stories.jsx +1 -1
  119. package/stories/TooltipButton/TooltipButton.stories.jsx +1 -1
  120. package/stories/Typography/Typography.stories.jsx +1 -1
  121. package/stories/supports.jsx +2 -3
@@ -5,7 +5,7 @@ import { Feedback, Typography, TextInput } from '../../src'
5
5
  import { Container } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Feedback',
8
+ title: 'Feedback',
9
9
  component: Feedback
10
10
  }
11
11
 
@@ -7,7 +7,7 @@ import { Placeholder, EachParentType, parentTypesParams } from '../supports'
7
7
  const { Row, Col } = FlexGrid
8
8
 
9
9
  export default {
10
- title: 'Base/FlexGrid/FlexGrid',
10
+ title: 'FlexGrid/FlexGrid',
11
11
  component: FlexGrid
12
12
  }
13
13
 
@@ -6,7 +6,7 @@ import { Placeholder } from '../supports'
6
6
  const { Row, Col } = FlexGrid
7
7
 
8
8
  export default {
9
- title: 'Base/FlexGrid/Row',
9
+ title: 'FlexGrid/Row',
10
10
  component: Row
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Placeholder } from '../supports'
6
6
  const { Row, Col } = FlexGrid
7
7
 
8
8
  export default {
9
- title: 'Base/FlexGrid/Col',
9
+ title: 'FlexGrid/Col',
10
10
  component: Col,
11
11
  argTypes: {
12
12
  xs: {
@@ -7,7 +7,7 @@ import { Container, useVariants, EachIcon, EachParentType, parentTypesParams } f
7
7
  import { Icon, StackWrap, Tooltip } from '../../src'
8
8
 
9
9
  export default {
10
- title: 'Base/Icon',
10
+ title: 'Icon',
11
11
  component: Icon,
12
12
  argTypes: {
13
13
  label: {
@@ -8,7 +8,7 @@ import { Box, IconButton, StackView } from '../../src'
8
8
  import { useVariants, EachParentType, parentTypesParams } from '../supports'
9
9
 
10
10
  export default {
11
- title: 'Base/IconButton',
11
+ title: 'IconButton',
12
12
  component: IconButton
13
13
  }
14
14
 
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import InputLabel from '../../src/InputLabel/InputLabel'
5
5
 
6
6
  export default {
7
- title: 'Base/InputLabel',
7
+ title: 'InputLabel',
8
8
  component: InputLabel
9
9
  }
10
10
 
@@ -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: 'Base/ChevronLink',
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: 'Base/Link',
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: 'Base/TextButton',
13
+ title: 'TextButton',
14
14
  component: TextButton,
15
15
  args: {
16
16
  // eslint-disable-next-line no-console
@@ -9,7 +9,7 @@ import { useVariants, Container } from '../supports'
9
9
  import { List, Typography } from '../../src'
10
10
 
11
11
  export default {
12
- title: 'Base/List',
12
+ title: 'List',
13
13
  component: List
14
14
  }
15
15
 
@@ -3,7 +3,7 @@ import React, { useState } from 'react'
3
3
  import { Button, Modal, Spacer, Typography } from '../../src'
4
4
 
5
5
  export default {
6
- title: 'Base/Modal',
6
+ title: 'Modal',
7
7
  component: Modal
8
8
  }
9
9
 
@@ -6,7 +6,7 @@ import { Link, Notification, Typography } from '../../src'
6
6
  import { Container } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Notification',
9
+ title: 'Notification',
10
10
  component: Notification
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Pagination, Typography } from '../../src'
6
6
  import { Container, EachParentType, parentTypesParams } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Pagination',
9
+ title: 'Pagination',
10
10
  component: Pagination
11
11
  }
12
12
 
@@ -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: 'Base/Progress',
8
+ title: 'Progress',
9
9
  component: Progress.Bar,
10
10
  args: { accessibilityLabel: 'Progress Bar' }
11
11
  }
@@ -5,7 +5,7 @@ import { Radio, RadioGroup, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/Radio',
8
+ title: 'Radio',
9
9
  component: Radio,
10
10
  argTypes: {
11
11
  checked: {
@@ -5,7 +5,7 @@ import { RadioCard, RadioCardGroup, Typography } from '../../src'
5
5
  import { Container, EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/RadioCard',
8
+ title: 'RadioCard',
9
9
  component: RadioCard
10
10
  }
11
11
 
@@ -3,7 +3,7 @@ import React from 'react'
3
3
  import { Search } from '../../src'
4
4
 
5
5
  export default {
6
- title: 'Base/Search',
6
+ title: 'Search',
7
7
  component: Search
8
8
  }
9
9
 
@@ -4,7 +4,7 @@ import { Text } from 'react-native'
4
4
  import { Select } from '../../src'
5
5
 
6
6
  export default {
7
- title: 'Base/Select',
7
+ title: 'Select',
8
8
  component: Select
9
9
  }
10
10
 
@@ -5,7 +5,7 @@ import { SideNav } from '../../src'
5
5
  import { EachParentType, parentTypesParams } from '../supports'
6
6
 
7
7
  export default {
8
- title: 'Base/SideNav',
8
+ title: 'SideNav',
9
9
  component: SideNav
10
10
  }
11
11
 
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { SideNav } from '../../src'
3
3
 
4
4
  export default {
5
- title: 'Base/SideNav/Item',
5
+ title: 'SideNav/Item',
6
6
  component: SideNav.Item
7
7
  }
8
8
 
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import { SideNav } from '../../src'
3
3
 
4
4
  export default {
5
- title: 'Base/SideNav/Items Group',
5
+ title: 'SideNav/Items Group',
6
6
  component: SideNav.ItemsGroup
7
7
  }
8
8
 
@@ -6,7 +6,7 @@ import StackView from '../../src/StackView'
6
6
  import { Skeleton } from '../../src'
7
7
 
8
8
  export default {
9
- title: 'Base/Skeleton',
9
+ title: 'Skeleton',
10
10
  component: Skeleton
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { Spacer, Typography } from '../../src'
6
6
  import { Container } from '../supports'
7
7
 
8
8
  export default {
9
- title: 'Base/Spacer',
9
+ title: 'Spacer',
10
10
  component: Spacer
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ import { View } from 'react-native'
6
6
  import { StackView, Card, Typography, Button } from '../../src'
7
7
 
8
8
  export default {
9
- title: 'Base/StackView',
9
+ title: 'StackView',
10
10
  component: StackView
11
11
  }
12
12
 
@@ -5,7 +5,7 @@ import { StyleSheet, View } from 'react-native'
5
5
  import { StackWrap, Button } from '../../src'
6
6
 
7
7
  export default {
8
- title: 'Base/StackWrap',
8
+ title: 'StackWrap',
9
9
  component: StackWrap
10
10
  }
11
11
 
@@ -14,7 +14,7 @@ const steps = [
14
14
  const longTitle = 'Example of a really long step title that wraps'
15
15
 
16
16
  export default {
17
- title: 'Base/StepTracker',
17
+ title: 'StepTracker',
18
18
  component: StepTracker,
19
19
  args: {
20
20
  steps
@@ -5,7 +5,7 @@ import { Platform } from 'react-native'
5
5
  import { Link, StackView, Tabs, Typography } from '../../src'
6
6
 
7
7
  export default {
8
- title: 'Base/Tabs',
8
+ title: 'Tabs',
9
9
  component: Tabs
10
10
  }
11
11
 
@@ -22,7 +22,7 @@ const defaultControlledArgs = {
22
22
  }
23
23
 
24
24
  export default {
25
- title: 'Base/Tags',
25
+ title: 'Tags',
26
26
  component: Tags,
27
27
  args: {
28
28
  ...defaultArgs
@@ -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: 'Base/TextArea',
8
+ title: 'TextArea',
8
9
  component: TextArea
9
10
  }
10
11
 
@@ -4,7 +4,7 @@ import { TextInput } from '../../src'
4
4
  import { Container } from '../supports'
5
5
 
6
6
  export default {
7
- title: 'Base/TextInput',
7
+ title: 'TextInput',
8
8
  component: TextInput
9
9
  }
10
10
 
@@ -8,8 +8,12 @@ export const Default = (args) => <ToggleSwitch {...args} />
8
8
  Default.storyName = 'ToggleSwitch'
9
9
 
10
10
  export default {
11
- title: 'Base/ToggleSwitch',
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 }
@@ -7,7 +7,7 @@ import { Tooltip, Typography } from '../../src'
7
7
  import { Container } from '../supports'
8
8
 
9
9
  export default {
10
- title: 'Base/Tooltip',
10
+ title: 'Tooltip',
11
11
  component: Tooltip
12
12
  }
13
13
 
@@ -3,7 +3,7 @@ import React from 'react'
3
3
  import { TooltipButton } from '../../src'
4
4
 
5
5
  export default {
6
- title: 'Base/TooltipButton',
6
+ title: 'TooltipButton',
7
7
  component: TooltipButton
8
8
  }
9
9
 
@@ -10,7 +10,7 @@ Default.storyName = 'Typography'
10
10
  const defaultChildren = 'The quick brown fox jumps over the lazy dog'
11
11
 
12
12
  export default {
13
- title: 'Base/Typography',
13
+ title: 'Typography',
14
14
  component: Typography,
15
15
  args: {
16
16
  children: defaultChildren
@@ -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
- // eslint-disable-next-line import/no-extraneous-dependencies
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'