@telus-uds/components-base 1.8.3 → 1.8.4

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 (269) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/component-docs.json +1 -1
  3. package/lib/ActivityIndicator/Spinner.js +7 -7
  4. package/lib/ActivityIndicator/Spinner.native.js +2 -2
  5. package/lib/Button/ButtonBase.js +2 -2
  6. package/lib/Button/ButtonGroup.js +1 -1
  7. package/lib/Checkbox/Checkbox.js +1 -1
  8. package/lib/Checkbox/CheckboxGroup.js +2 -2
  9. package/lib/Divider/Divider.js +2 -2
  10. package/lib/ExpandCollapse/Panel.js +2 -17
  11. package/lib/FlexGrid/Col/Col.js +1 -1
  12. package/lib/Icon/Icon.js +1 -1
  13. package/lib/List/List.js +8 -2
  14. package/lib/Pagination/PageButton.js +2 -2
  15. package/lib/Pagination/Pagination.js +5 -3
  16. package/lib/Pagination/usePagination.js +2 -2
  17. package/lib/Progress/ProgressBar.js +3 -3
  18. package/lib/Progress/ProgressBarBackground.js +3 -3
  19. package/lib/Radio/Radio.js +2 -2
  20. package/lib/Radio/RadioGroup.js +2 -2
  21. package/lib/RadioCard/RadioCard.js +1 -1
  22. package/lib/RadioCard/RadioCardGroup.js +2 -2
  23. package/lib/Search/Search.js +1 -1
  24. package/lib/SideNav/SideNav.js +2 -2
  25. package/lib/Skeleton/Skeleton.js +1 -1
  26. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  27. package/lib/StackView/StackWrap.js +3 -1
  28. package/lib/StackView/getStackedContent.js +2 -2
  29. package/lib/Tabs/Tabs.js +28 -3
  30. package/lib/Tabs/TabsItem.js +5 -6
  31. package/lib/Tags/Tags.js +1 -1
  32. package/lib/ThemeProvider/utils/styles.js +2 -2
  33. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  34. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  35. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  36. package/lib/Tooltip/Backdrop.js +2 -10
  37. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  38. package/lib/utils/children.js +2 -2
  39. package/lib/utils/input.js +6 -12
  40. package/lib/utils/props/componentPropType.js +3 -3
  41. package/lib/utils/props/selectSystemProps.js +2 -2
  42. package/lib/utils/props/tokens.js +2 -2
  43. package/lib/utils/useSpacingScale.js +3 -1
  44. package/lib/utils/useUniqueId.js +1 -1
  45. package/lib-module/A11yInfoProvider/index.js +63 -0
  46. package/lib-module/A11yText/index.js +56 -0
  47. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  48. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  49. package/lib-module/ActivityIndicator/index.js +41 -0
  50. package/lib-module/ActivityIndicator/shared.js +12 -0
  51. package/lib-module/BaseProvider/index.js +29 -0
  52. package/lib-module/Box/Box.js +244 -0
  53. package/lib-module/Box/index.js +2 -0
  54. package/lib-module/Button/Button.js +26 -0
  55. package/lib-module/Button/ButtonBase.js +271 -0
  56. package/lib-module/Button/ButtonGroup.js +247 -0
  57. package/lib-module/Button/ButtonLink.js +40 -0
  58. package/lib-module/Button/index.js +4 -0
  59. package/lib-module/Button/propTypes.js +36 -0
  60. package/lib-module/Card/Card.js +84 -0
  61. package/lib-module/Card/CardBase.js +66 -0
  62. package/lib-module/Card/PressableCardBase.js +114 -0
  63. package/lib-module/Card/index.js +4 -0
  64. package/lib-module/Checkbox/Checkbox.js +346 -0
  65. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  66. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  67. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  68. package/lib-module/Checkbox/index.js +3 -0
  69. package/lib-module/Divider/Divider.js +124 -0
  70. package/lib-module/Divider/index.js +2 -0
  71. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  72. package/lib-module/ExpandCollapse/Control.js +136 -0
  73. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  74. package/lib-module/ExpandCollapse/Panel.js +151 -0
  75. package/lib-module/ExpandCollapse/index.js +7 -0
  76. package/lib-module/Feedback/Feedback.js +157 -0
  77. package/lib-module/Feedback/index.js +2 -0
  78. package/lib-module/Fieldset/Fieldset.js +153 -0
  79. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  80. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  81. package/lib-module/Fieldset/Legend.js +24 -0
  82. package/lib-module/Fieldset/Legend.native.js +31 -0
  83. package/lib-module/Fieldset/cssReset.js +14 -0
  84. package/lib-module/Fieldset/index.js +2 -0
  85. package/lib-module/FlexGrid/Col/Col.js +276 -0
  86. package/lib-module/FlexGrid/Col/index.js +2 -0
  87. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  88. package/lib-module/FlexGrid/Row/Row.js +184 -0
  89. package/lib-module/FlexGrid/Row/index.js +2 -0
  90. package/lib-module/FlexGrid/helpers/index.js +18 -0
  91. package/lib-module/FlexGrid/index.js +2 -0
  92. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  93. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  94. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  95. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  96. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  97. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  98. package/lib-module/HorizontalScroll/index.js +11 -0
  99. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  100. package/lib-module/Icon/Icon.js +62 -0
  101. package/lib-module/Icon/IconText.js +83 -0
  102. package/lib-module/Icon/index.js +4 -0
  103. package/lib-module/IconButton/IconButton.js +122 -0
  104. package/lib-module/IconButton/index.js +2 -0
  105. package/lib-module/InputLabel/InputLabel.js +148 -0
  106. package/lib-module/InputLabel/LabelContent.js +27 -0
  107. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  108. package/lib-module/InputLabel/index.js +2 -0
  109. package/lib-module/InputSupports/InputSupports.js +96 -0
  110. package/lib-module/InputSupports/index.js +2 -0
  111. package/lib-module/InputSupports/useInputSupports.js +32 -0
  112. package/lib-module/Link/ChevronLink.js +52 -0
  113. package/lib-module/Link/InlinePressable.js +40 -0
  114. package/lib-module/Link/InlinePressable.native.js +89 -0
  115. package/lib-module/Link/Link.js +28 -0
  116. package/lib-module/Link/LinkBase.js +240 -0
  117. package/lib-module/Link/TextButton.js +35 -0
  118. package/lib-module/Link/index.js +5 -0
  119. package/lib-module/List/List.js +62 -0
  120. package/lib-module/List/ListItem.js +248 -0
  121. package/lib-module/List/index.js +5 -0
  122. package/lib-module/Modal/Modal.js +222 -0
  123. package/lib-module/Modal/dictionary.js +9 -0
  124. package/lib-module/Modal/index.js +2 -0
  125. package/lib-module/Notification/Notification.js +209 -0
  126. package/lib-module/Notification/dictionary.js +8 -0
  127. package/lib-module/Notification/index.js +2 -0
  128. package/lib-module/Pagination/PageButton.js +66 -0
  129. package/lib-module/Pagination/Pagination.js +153 -0
  130. package/lib-module/Pagination/SideButton.js +106 -0
  131. package/lib-module/Pagination/dictionary.js +18 -0
  132. package/lib-module/Pagination/index.js +2 -0
  133. package/lib-module/Pagination/usePagination.js +73 -0
  134. package/lib-module/Progress/Progress.js +89 -0
  135. package/lib-module/Progress/ProgressBar.js +138 -0
  136. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  137. package/lib-module/Progress/index.js +4 -0
  138. package/lib-module/Radio/Radio.js +285 -0
  139. package/lib-module/Radio/RadioButton.js +138 -0
  140. package/lib-module/Radio/RadioGroup.js +243 -0
  141. package/lib-module/Radio/RadioInput.js +62 -0
  142. package/lib-module/Radio/RadioInput.native.js +6 -0
  143. package/lib-module/Radio/index.js +3 -0
  144. package/lib-module/RadioCard/RadioCard.js +219 -0
  145. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  146. package/lib-module/RadioCard/index.js +3 -0
  147. package/lib-module/Search/Search.js +261 -0
  148. package/lib-module/Search/dictionary.js +12 -0
  149. package/lib-module/Search/index.js +2 -0
  150. package/lib-module/Select/Group.js +21 -0
  151. package/lib-module/Select/Group.native.js +15 -0
  152. package/lib-module/Select/Item.js +20 -0
  153. package/lib-module/Select/Item.native.js +3 -0
  154. package/lib-module/Select/Picker.js +68 -0
  155. package/lib-module/Select/Picker.native.js +120 -0
  156. package/lib-module/Select/Select.js +337 -0
  157. package/lib-module/Select/index.js +6 -0
  158. package/lib-module/SideNav/Item.js +145 -0
  159. package/lib-module/SideNav/ItemContent.js +48 -0
  160. package/lib-module/SideNav/ItemsGroup.js +117 -0
  161. package/lib-module/SideNav/SideNav.js +136 -0
  162. package/lib-module/SideNav/index.js +1 -0
  163. package/lib-module/Skeleton/Skeleton.js +179 -0
  164. package/lib-module/Skeleton/index.js +2 -0
  165. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  166. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  167. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  168. package/lib-module/Spacer/Spacer.js +98 -0
  169. package/lib-module/Spacer/index.js +2 -0
  170. package/lib-module/StackView/StackView.js +125 -0
  171. package/lib-module/StackView/StackWrap.js +50 -0
  172. package/lib-module/StackView/StackWrap.native.js +3 -0
  173. package/lib-module/StackView/StackWrapBox.js +115 -0
  174. package/lib-module/StackView/StackWrapGap.js +59 -0
  175. package/lib-module/StackView/common.js +35 -0
  176. package/lib-module/StackView/getStackedContent.js +124 -0
  177. package/lib-module/StackView/index.js +5 -0
  178. package/lib-module/StepTracker/Step.js +248 -0
  179. package/lib-module/StepTracker/StepTracker.js +185 -0
  180. package/lib-module/StepTracker/dictionary.js +10 -0
  181. package/lib-module/StepTracker/index.js +2 -0
  182. package/lib-module/Tabs/Tabs.js +143 -0
  183. package/lib-module/Tabs/TabsItem.js +224 -0
  184. package/lib-module/Tabs/index.js +2 -0
  185. package/lib-module/Tags/Tags.js +251 -0
  186. package/lib-module/Tags/index.js +2 -0
  187. package/lib-module/TextInput/TextArea.js +94 -0
  188. package/lib-module/TextInput/TextInput.js +72 -0
  189. package/lib-module/TextInput/TextInputBase.js +245 -0
  190. package/lib-module/TextInput/index.js +3 -0
  191. package/lib-module/TextInput/propTypes.js +37 -0
  192. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  193. package/lib-module/ThemeProvider/index.js +6 -0
  194. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  195. package/lib-module/ThemeProvider/useTheme.js +14 -0
  196. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  197. package/lib-module/ThemeProvider/utils/index.js +2 -0
  198. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  199. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  200. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  201. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  202. package/lib-module/ToggleSwitch/index.js +3 -0
  203. package/lib-module/Tooltip/Backdrop.js +45 -0
  204. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  205. package/lib-module/Tooltip/Tooltip.js +348 -0
  206. package/lib-module/Tooltip/dictionary.js +8 -0
  207. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  208. package/lib-module/Tooltip/index.js +2 -0
  209. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  210. package/lib-module/TooltipButton/index.js +2 -0
  211. package/lib-module/Typography/Typography.js +124 -0
  212. package/lib-module/Typography/index.js +2 -0
  213. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  214. package/lib-module/ViewportProvider/index.js +3 -0
  215. package/lib-module/ViewportProvider/useViewport.js +3 -0
  216. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  217. package/lib-module/index.js +48 -0
  218. package/lib-module/utils/a11y/index.js +2 -0
  219. package/lib-module/utils/a11y/semantics.js +157 -0
  220. package/lib-module/utils/a11y/textSize.js +36 -0
  221. package/lib-module/utils/animation/index.js +2 -0
  222. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  223. package/lib-module/utils/children.js +119 -0
  224. package/lib-module/utils/containUniqueFields.js +26 -0
  225. package/lib-module/utils/index.js +16 -0
  226. package/lib-module/utils/info/index.js +7 -0
  227. package/lib-module/utils/info/platform/index.js +11 -0
  228. package/lib-module/utils/info/platform/platform.android.js +1 -0
  229. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  230. package/lib-module/utils/info/platform/platform.js +1 -0
  231. package/lib-module/utils/info/platform/platform.native.js +4 -0
  232. package/lib-module/utils/info/versions.js +5 -0
  233. package/lib-module/utils/input.js +179 -0
  234. package/lib-module/utils/pressability.js +111 -0
  235. package/lib-module/utils/props/a11yProps.js +140 -0
  236. package/lib-module/utils/props/clickProps.js +26 -0
  237. package/lib-module/utils/props/componentPropType.js +63 -0
  238. package/lib-module/utils/props/copyPropTypes.js +2 -0
  239. package/lib-module/utils/props/getPropSelector.js +9 -0
  240. package/lib-module/utils/props/handlerProps.js +65 -0
  241. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  242. package/lib-module/utils/props/index.js +19 -0
  243. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  244. package/lib-module/utils/props/linkProps.js +44 -0
  245. package/lib-module/utils/props/paddingProp.js +9 -0
  246. package/lib-module/utils/props/pressProps.js +42 -0
  247. package/lib-module/utils/props/rectProp.js +9 -0
  248. package/lib-module/utils/props/responsiveProps.js +30 -0
  249. package/lib-module/utils/props/selectSystemProps.js +24 -0
  250. package/lib-module/utils/props/spacingProps.js +56 -0
  251. package/lib-module/utils/props/textInputProps.js +194 -0
  252. package/lib-module/utils/props/textProps.js +59 -0
  253. package/lib-module/utils/props/tokens.js +133 -0
  254. package/lib-module/utils/props/variantProp.js +18 -0
  255. package/lib-module/utils/props/viewProps.js +22 -0
  256. package/lib-module/utils/ssr.js +38 -0
  257. package/lib-module/utils/useCopy.js +44 -0
  258. package/lib-module/utils/useHash.js +45 -0
  259. package/lib-module/utils/useHash.native.js +7 -0
  260. package/lib-module/utils/useResponsiveProp.js +47 -0
  261. package/lib-module/utils/useSpacingScale.js +125 -0
  262. package/lib-module/utils/useUniqueId.js +13 -0
  263. package/lib-module/utils/withLinkRouter.js +83 -0
  264. package/package.json +2 -2
  265. package/src/ExpandCollapse/Panel.jsx +2 -19
  266. package/src/List/List.jsx +6 -2
  267. package/src/Tabs/Tabs.jsx +24 -2
  268. package/src/Tabs/TabsItem.jsx +6 -5
  269. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -0,0 +1,276 @@
1
+ import React, { forwardRef, useContext } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import { viewports } from '@telus-uds/system-constants';
7
+ import GutterContext from '../providers/GutterContext';
8
+ import { useViewport } from '../../ViewportProvider';
9
+ import applyInheritance from '../helpers';
10
+ import { responsiveProps } from '../../utils';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
13
+ let {
14
+ horizontalAlign,
15
+ children,
16
+ xs,
17
+ sm,
18
+ md,
19
+ lg,
20
+ xl,
21
+ xsOffset,
22
+ smOffset,
23
+ mdOffset,
24
+ lgOffset,
25
+ xlOffset,
26
+ flex,
27
+ ...viewProps
28
+ } = _ref;
29
+ const gutter = useContext(GutterContext);
30
+ const viewPort = useViewport();
31
+ const hiddenLevels = applyInheritance([xs, sm, md, lg, xl]);
32
+
33
+ const getHorizontalAlignLevel = () => {
34
+ if (typeof horizontalAlign === 'object') {
35
+ return applyInheritance([horizontalAlign.xs, horizontalAlign.sm, horizontalAlign.md, horizontalAlign.lg, horizontalAlign.xl]);
36
+ }
37
+
38
+ if (typeof horizontalAlign === 'string') {
39
+ return [horizontalAlign, horizontalAlign, horizontalAlign, horizontalAlign, horizontalAlign];
40
+ }
41
+
42
+ return ['inherit', 'inherit', 'inherit', 'inherit', 'inherit'];
43
+ };
44
+
45
+ const horizontalAlignLevel = getHorizontalAlignLevel();
46
+
47
+ const toPercent = num => {
48
+ return "".concat(num / 12 * 100, "%");
49
+ };
50
+
51
+ const calculateWidth = value => {
52
+ if (typeof value === 'undefined') {
53
+ return {};
54
+ }
55
+
56
+ if (typeof value === 'number') {
57
+ const percent = toPercent(value);
58
+ return {
59
+ maxWidth: percent,
60
+ flexBasis: percent
61
+ };
62
+ }
63
+
64
+ return {
65
+ flexGrow: 1,
66
+ flexBasis: 0,
67
+ maxWidth: '100%'
68
+ };
69
+ };
70
+
71
+ const calculateOffset = value => {
72
+ if (typeof value === 'number') {
73
+ const percent = toPercent(value);
74
+ return {
75
+ marginLeft: percent
76
+ };
77
+ }
78
+
79
+ return {};
80
+ };
81
+
82
+ const sizeStyles = sizes => {
83
+ const currViewport = Object.keys(sizes).find(key => key.startsWith(viewPort));
84
+ const currSize = sizes[currViewport];
85
+ return { ...calculateWidth(currSize)
86
+ };
87
+ };
88
+
89
+ const offsetStyles = offsets => {
90
+ const currViewport = Object.keys(offsets).find(key => key.startsWith(viewPort));
91
+ const currOffset = offsets[currViewport];
92
+ return { ...calculateOffset(currOffset)
93
+ };
94
+ };
95
+
96
+ const gutterPadding = {
97
+ paddingLeft: gutter ? 16 : 0,
98
+ paddingRight: gutter ? 16 : 0
99
+ };
100
+ let hidingStyles = {}; // TODO: consider setting this to always 'flex' in a major release.
101
+ // `display: block` is invalid in native apps.
102
+ // See https://telusdigital.atlassian.net/browse/UDS1-92
103
+
104
+ const shown = !flex && Platform.OS === 'web' ? 'block' : 'flex';
105
+
106
+ if (viewPort === viewports.xs) {
107
+ hidingStyles = {
108
+ display: hiddenLevels[0] === 0 ? 'none' : shown,
109
+ textAlign: horizontalAlignLevel[0]
110
+ };
111
+ }
112
+
113
+ if (viewPort === viewports.sm) {
114
+ hidingStyles = {
115
+ display: hiddenLevels[1] === 0 ? 'none' : shown,
116
+ textAlign: horizontalAlignLevel[1]
117
+ };
118
+ }
119
+
120
+ if (viewPort === viewports.md) {
121
+ hidingStyles = {
122
+ display: hiddenLevels[2] === 0 ? 'none' : shown,
123
+ textAlign: horizontalAlignLevel[2]
124
+ };
125
+ }
126
+
127
+ if (viewPort === viewports.lg) {
128
+ hidingStyles = {
129
+ display: hiddenLevels[3] === 0 ? 'none' : shown,
130
+ textAlign: horizontalAlignLevel[3]
131
+ };
132
+ }
133
+
134
+ if (viewPort === viewports.xl) {
135
+ hidingStyles = {
136
+ display: hiddenLevels[4] === 0 ? 'none' : shown,
137
+ textAlign: horizontalAlignLevel[4]
138
+ };
139
+ }
140
+
141
+ const sizesArray = [xs, sm, md, lg, xl];
142
+ const offSetsArray = [xsOffset, smOffset, mdOffset, lgOffset, xlOffset];
143
+ const sizesWithIheritance = applyInheritance(sizesArray);
144
+ const offsetsWithIheritance = applyInheritance(offSetsArray);
145
+ const sizes = {
146
+ xs: sizesWithIheritance[0],
147
+ sm: sizesWithIheritance[1],
148
+ md: sizesWithIheritance[2],
149
+ lg: sizesWithIheritance[3],
150
+ xl: sizesWithIheritance[4]
151
+ };
152
+ const offsets = {
153
+ xs: offsetsWithIheritance[0],
154
+ sm: offsetsWithIheritance[1],
155
+ md: offsetsWithIheritance[2],
156
+ lg: offsetsWithIheritance[3],
157
+ xl: offsetsWithIheritance[4]
158
+ };
159
+ return /*#__PURE__*/_jsx(View, {
160
+ ref: ref,
161
+ ...viewProps,
162
+ style: [styles.col, gutterPadding, offsetStyles(offsets), sizeStyles(sizes), { ...hidingStyles
163
+ }],
164
+ children: children
165
+ });
166
+ });
167
+ Col.displayName = 'Col';
168
+ const styles = StyleSheet.create({
169
+ col: {
170
+ flexGrow: 1,
171
+ flexShrink: 0,
172
+ flexBasis: 'auto',
173
+ maxWidth: '100%'
174
+ }
175
+ });
176
+ /*
177
+ * We're disabling default props since passing undefined props to
178
+ * the react-flexbox-grid component sets up blank classes that may cause
179
+ * styling issues.
180
+ */
181
+
182
+ Col.propTypes = {
183
+ /**
184
+ * Specify number of columns within the 'xs' breakpoint range. `0` hides the column.
185
+ *
186
+ * `true` sets the column width automatically;
187
+ * `false` disables the prop
188
+ *
189
+ */
190
+ xs: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
191
+
192
+ /**
193
+ * Specify number of columns within the 'sm' breakpoint range. `0` hides the column.
194
+ *
195
+ * `true` sets the column width automatically;
196
+ * `false` disables the prop
197
+ *
198
+ */
199
+ sm: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
200
+
201
+ /**
202
+ * Specify number of columns within the 'md' breakpoint range. `0` hides the column.
203
+ *
204
+ * `true` sets the column width automatically;
205
+ * `false` disables the prop
206
+ *
207
+ */
208
+ md: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
209
+
210
+ /**
211
+ * Specify number of columns within the 'lg' breakpoint range. `0` hides the column.
212
+ *
213
+ * `true` sets the column width automatically;
214
+ * `false` disables the prop
215
+ *
216
+ */
217
+ lg: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
218
+
219
+ /**
220
+ * Specify number of columns after the 'xl' breakpoint. `0` hides the column.
221
+ *
222
+ * `true` sets the column width automatically;
223
+ * `false` disables the prop
224
+ *
225
+ */
226
+ xl: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, true, false]),
227
+
228
+ /**
229
+ * Offset the specified number of columns within the 'xs' breakpoint range. `0` hides the column.
230
+ *
231
+ */
232
+ xsOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
233
+
234
+ /**
235
+ * Offset the specified number of columns within the 'sm' breakpoint range.
236
+ *
237
+ */
238
+ smOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
239
+
240
+ /**
241
+ * Offset the specified number of columns within the 'md' breakpoint range.
242
+ *
243
+ */
244
+ mdOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
245
+
246
+ /**
247
+ * Offset the specified number of columns within the 'lg' breakpoint range.
248
+ *
249
+ */
250
+ lgOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
251
+
252
+ /**
253
+ * Offset the specified number of columns within the 'xl' breakpoint range.
254
+ */
255
+ xlOffset: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),
256
+
257
+ /**
258
+ * The columns of the Grid. Will typically be `FlexGrid.Col` components.
259
+ */
260
+ children: PropTypes.node.isRequired,
261
+
262
+ /**
263
+ *
264
+ * Align content horizontally within the column.
265
+ *
266
+ * Accepts a `PropType.string` following the [responsive prop](#/Layout?id=responsive) structure.
267
+ */
268
+ horizontalAlign: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['left', 'center', 'right'])),
269
+
270
+ /**
271
+ * (web only) Stretches the column to fill vertical space using `display: flex`.
272
+ * In native apps, FlexGrid.Col behaves as if this is always true (as do all `View`s).
273
+ */
274
+ flex: PropTypes.bool
275
+ };
276
+ export default Col;
@@ -0,0 +1,2 @@
1
+ import Col from './Col';
2
+ export default Col;
@@ -0,0 +1,148 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import { viewports } from '@telus-uds/system-constants';
6
+ import Row from './Row';
7
+ import Col from './Col';
8
+ import { useViewport } from '../ViewportProvider';
9
+ import GutterContext from './providers/GutterContext';
10
+ import applyInheritance from './helpers';
11
+ import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps } from '../utils';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
14
+ /**
15
+ * A mobile-first flexbox grid.
16
+ */
17
+
18
+ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
19
+ let {
20
+ limitWidth = true,
21
+ gutter = true,
22
+ outsideGutter = true,
23
+ xsReverse,
24
+ smReverse,
25
+ mdReverse,
26
+ lgReverse,
27
+ xlReverse,
28
+ tag,
29
+ accessibilityRole,
30
+ children,
31
+ ...rest
32
+ } = _ref;
33
+ const viewPort = useViewport();
34
+ const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
35
+ const marginVertical = 0;
36
+ const marginHorizontal = outsideGutter ? 'auto' : -16;
37
+ const width = outsideGutter ? '100%' : 'auto';
38
+ let flexDirection;
39
+ let maxWidth;
40
+
41
+ if (viewPort === viewports.xs) {
42
+ // no maxWidth for xs
43
+ flexDirection = reverseLevel[0] ? 'column-reverse' : 'column';
44
+ }
45
+
46
+ if (viewPort === viewports.sm) {
47
+ maxWidth = limitWidth && viewports.map.get(viewports.sm);
48
+ flexDirection = reverseLevel[1] ? 'column-reverse' : 'column';
49
+ }
50
+
51
+ if (viewPort === viewports.md) {
52
+ maxWidth = limitWidth && viewports.map.get(viewports.md);
53
+ flexDirection = reverseLevel[2] ? 'column-reverse' : 'column';
54
+ }
55
+
56
+ if (viewPort === viewports.lg) {
57
+ maxWidth = limitWidth && viewports.map.get(viewports.lg);
58
+ flexDirection = reverseLevel[3] ? 'column-reverse' : 'column';
59
+ }
60
+
61
+ if (viewPort === viewports.xl) {
62
+ maxWidth = limitWidth && viewports.map.get(viewports.xl);
63
+ flexDirection = reverseLevel[4] ? 'column-reverse' : 'column';
64
+ }
65
+
66
+ const props = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
67
+ ...selectProps(rest)
68
+ };
69
+ return /*#__PURE__*/_jsx(GutterContext.Provider, {
70
+ value: gutter,
71
+ children: /*#__PURE__*/_jsx(View, {
72
+ ref: ref,
73
+ ...props,
74
+ style: [styles.grid, {
75
+ marginHorizontal,
76
+ marginVertical,
77
+ width,
78
+ flexDirection,
79
+ maxWidth
80
+ }],
81
+ children: children
82
+ })
83
+ });
84
+ });
85
+ FlexGrid.displayName = 'FlexGrid';
86
+ const styles = StyleSheet.create({
87
+ grid: {
88
+ flexWrap: 'wrap'
89
+ }
90
+ });
91
+ FlexGrid.propTypes = { ...selectedSystemPropTypes,
92
+
93
+ /**
94
+ * Whether or not to give the grid a fixed width. This also centres the grid horizontally.
95
+ */
96
+ limitWidth: PropTypes.bool,
97
+
98
+ /**
99
+ * Whether or not to include gutters in between columns.
100
+ */
101
+ gutter: PropTypes.bool,
102
+
103
+ /**
104
+ * Whether or not to include gutter at the ends to the left and right of the FlexGrid
105
+ */
106
+ outsideGutter: PropTypes.bool,
107
+
108
+ /**
109
+ * Choose if the item order should be reversed from the 'xs' breakpoint. When you pass in false, the order will be normal from the xs breakpoint. By default, it inherits the behaviour set by the preceding prop.
110
+ */
111
+ xsReverse: PropTypes.bool,
112
+
113
+ /**
114
+ * Choose if the item order should be reversed from the 'sm' breakpoint. When you pass in false, the order will be normal from the sm breakpoint. By default, it inherits the behaviour set by the preceding prop.
115
+ */
116
+ smReverse: PropTypes.bool,
117
+
118
+ /**
119
+ * Choose if the item order should be reversed from the 'md' breakpoint. When you pass in false, the order will be normal from the md breakpoint. By default, it inherits the behaviour set by the preceding prop.
120
+ */
121
+ mdReverse: PropTypes.bool,
122
+
123
+ /**
124
+ * Choose if the item order should be reversed from the 'lg' breakpoint. When you pass in false, the order will be normal from the lg breakpoint. By default, it inherits the behaviour set by the preceding prop.
125
+ */
126
+ lgReverse: PropTypes.bool,
127
+
128
+ /**
129
+ * Choose if the item order should be reversed from the 'xl' breakpoint. When you pass in false, the order will be normal from the xl breakpoint. By default, it inherits the behaviour set by the preceding prop.
130
+ */
131
+ xlReverse: PropTypes.bool,
132
+
133
+ /**
134
+ * Optional semantic HTML tag, to apply to the container on web. Does not change styling.
135
+ *
136
+ * In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
137
+ * is not defined, the accessibilityRole will default to "heading".
138
+ */
139
+ tag: PropTypes.oneOf(layoutTags),
140
+
141
+ /**
142
+ * The rows and columns of the Grid. Will typically be `FlexGrid.Row` and `FlexGrid.Col` components.
143
+ */
144
+ children: PropTypes.node.isRequired
145
+ };
146
+ FlexGrid.Row = Row;
147
+ FlexGrid.Col = Col;
148
+ export default FlexGrid;
@@ -0,0 +1,184 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import { viewports } from '@telus-uds/system-constants';
6
+ import { useViewport } from '../../ViewportProvider';
7
+ import applyInheritance from '../helpers';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+
10
+ const horizontalAlignStyles = horizontalAlign => {
11
+ switch (horizontalAlign) {
12
+ case 'start':
13
+ return {
14
+ justifyContent: 'flex-start',
15
+ textAlign: 'left'
16
+ };
17
+
18
+ case 'center':
19
+ return {
20
+ justifyContent: 'center',
21
+ textAlign: 'center'
22
+ };
23
+
24
+ case 'end':
25
+ return {
26
+ justifyContent: 'flex-end',
27
+ textAlign: 'right'
28
+ };
29
+
30
+ default:
31
+ return {};
32
+ }
33
+ };
34
+
35
+ const verticalAlignStyles = verticalAlign => {
36
+ switch (verticalAlign) {
37
+ case 'top':
38
+ return {
39
+ alignItems: 'flex-start'
40
+ };
41
+
42
+ case 'middle':
43
+ return {
44
+ alignItems: 'center'
45
+ };
46
+
47
+ case 'bottom':
48
+ return {
49
+ alignItems: 'flex-end'
50
+ };
51
+
52
+ default:
53
+ return {};
54
+ }
55
+ };
56
+
57
+ const distributeStyles = distribute => {
58
+ switch (distribute) {
59
+ case 'between':
60
+ return {
61
+ justifyContent: 'space-between'
62
+ };
63
+
64
+ case 'around':
65
+ return {
66
+ justifyContent: 'space-around'
67
+ };
68
+
69
+ default:
70
+ return {};
71
+ }
72
+ };
73
+
74
+ const Row = /*#__PURE__*/forwardRef((_ref, ref) => {
75
+ let {
76
+ horizontalAlign,
77
+ verticalAlign,
78
+ distribute,
79
+ xsReverse,
80
+ smReverse,
81
+ mdReverse,
82
+ lgReverse,
83
+ xlReverse,
84
+ children,
85
+ ...rest
86
+ } = _ref;
87
+ const viewPort = useViewport();
88
+ const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
89
+ let flexDirection = '';
90
+ let flexWrap = '';
91
+
92
+ if (viewPort === viewports.xs) {
93
+ flexDirection = reverseLevel[0] ? 'row-reverse' : 'row';
94
+ flexWrap = reverseLevel[0] ? 'wrap-reverse' : 'wrap';
95
+ }
96
+
97
+ if (viewPort === viewports.sm) {
98
+ flexDirection = reverseLevel[1] ? 'row-reverse' : 'row';
99
+ flexWrap = reverseLevel[1] ? 'wrap-reverse' : 'wrap';
100
+ }
101
+
102
+ if (viewPort === viewports.md) {
103
+ flexDirection = reverseLevel[2] ? 'row-reverse' : 'row';
104
+ flexWrap = reverseLevel[2] ? 'wrap-reverse' : 'wrap';
105
+ }
106
+
107
+ if (viewPort === viewports.lg) {
108
+ flexDirection = reverseLevel[3] ? 'row-reverse' : 'row';
109
+ flexWrap = reverseLevel[3] ? 'wrap-reverse' : 'wrap';
110
+ }
111
+
112
+ if (viewPort === viewports.xl) {
113
+ flexDirection = reverseLevel[4] ? 'row-reverse' : 'row';
114
+ flexWrap = reverseLevel[4] ? 'wrap-reverse' : 'wrap';
115
+ }
116
+
117
+ return /*#__PURE__*/_jsx(View, {
118
+ ref: ref,
119
+ ...rest,
120
+ style: [styles.row, {
121
+ flexDirection,
122
+ flexWrap,
123
+ ...horizontalAlignStyles(horizontalAlign),
124
+ ...verticalAlignStyles(verticalAlign),
125
+ ...distributeStyles(distribute)
126
+ }],
127
+ children: children
128
+ });
129
+ });
130
+ Row.displayName = 'Row';
131
+ const styles = StyleSheet.create({
132
+ row: {
133
+ width: '100%',
134
+ marginVertical: 0,
135
+ marginHorizontal: 'auto',
136
+ flexGrow: 0,
137
+ flexShrink: 1,
138
+ flexBasis: 'auto',
139
+ flexDirection: 'row'
140
+ }
141
+ });
142
+ Row.propTypes = {
143
+ /**
144
+ * Align columns horizontally within their row.
145
+ */
146
+ horizontalAlign: PropTypes.oneOf(['start', 'center', 'end']),
147
+
148
+ /**
149
+ * Align columns vertically within their row.
150
+ */
151
+ verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
152
+
153
+ /**
154
+ * Distribute empty space around columns.
155
+ */
156
+ distribute: PropTypes.oneOf(['around', 'between']),
157
+
158
+ /**
159
+ * Choose if the item order should be reversed from the 'xs' breakpoint. When you pass in false, the order will be normal from the xs breakpoint. By default, it inherits the behaviour set by the preceding prop.
160
+ */
161
+ xsReverse: PropTypes.bool,
162
+
163
+ /**
164
+ * Choose if the item order should be reversed from the 'sm' breakpoint. When you pass in false, the order will be normal from the sm breakpoint. By default, it inherits the behaviour set by the preceding prop.
165
+ */
166
+ smReverse: PropTypes.bool,
167
+
168
+ /**
169
+ * Choose if the item order should be reversed from the 'md' breakpoint. When you pass in false, the order will be normal from the md breakpoint. By default, it inherits the behaviour set by the preceding prop.
170
+ */
171
+ mdReverse: PropTypes.bool,
172
+
173
+ /**
174
+ * Choose if the item order should be reversed from the 'lg' breakpoint. When you pass in false, the order will be normal from the lg breakpoint. By default, it inherits the behaviour set by the preceding prop.
175
+ */
176
+ lgReverse: PropTypes.bool,
177
+
178
+ /**
179
+ * Choose if the item order should be reversed from the 'xl' breakpoint. When you pass in false, the order will be normal from the xl breakpoint. By default, it inherits the behaviour set by the preceding prop.
180
+ */
181
+ xlReverse: PropTypes.bool,
182
+ children: PropTypes.node.isRequired
183
+ };
184
+ export default Row;
@@ -0,0 +1,2 @@
1
+ import Row from './Row';
2
+ export default Row;
@@ -0,0 +1,18 @@
1
+ const applyInheritance = sizes => {
2
+ let prevSize;
3
+ return sizes.map((size, index) => {
4
+ if (size !== undefined) {
5
+ prevSize = size;
6
+ return size;
7
+ }
8
+
9
+ if (index) {
10
+ const value = prevSize;
11
+ return value;
12
+ }
13
+
14
+ return undefined;
15
+ });
16
+ };
17
+
18
+ export default applyInheritance;
@@ -0,0 +1,2 @@
1
+ import FlexGrid from './FlexGrid';
2
+ export default FlexGrid;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ const GutterContext = /*#__PURE__*/React.createContext(false);
3
+ export default GutterContext;