@telus-uds/components-base 1.8.3 → 1.9.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 (284) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/component-docs.json +17 -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/Card/Card.js +9 -4
  8. package/lib/Checkbox/Checkbox.js +5 -3
  9. package/lib/Checkbox/CheckboxGroup.js +2 -2
  10. package/lib/Divider/Divider.js +2 -2
  11. package/lib/ExpandCollapse/Panel.js +12 -18
  12. package/lib/FlexGrid/Col/Col.js +1 -1
  13. package/lib/Icon/Icon.js +1 -1
  14. package/lib/Link/InlinePressable.js +5 -1
  15. package/lib/Link/LinkBase.js +5 -2
  16. package/lib/List/List.js +8 -2
  17. package/lib/Pagination/PageButton.js +2 -2
  18. package/lib/Pagination/Pagination.js +5 -3
  19. package/lib/Pagination/usePagination.js +2 -2
  20. package/lib/Progress/ProgressBar.js +3 -3
  21. package/lib/Progress/ProgressBarBackground.js +3 -3
  22. package/lib/Radio/Radio.js +2 -2
  23. package/lib/Radio/RadioGroup.js +2 -2
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +2 -2
  26. package/lib/Search/Search.js +1 -1
  27. package/lib/SideNav/SideNav.js +2 -2
  28. package/lib/Skeleton/Skeleton.js +1 -1
  29. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  30. package/lib/StackView/StackWrap.js +3 -1
  31. package/lib/StackView/getStackedContent.js +2 -2
  32. package/lib/Tabs/Tabs.js +28 -3
  33. package/lib/Tabs/TabsItem.js +5 -6
  34. package/lib/Tags/Tags.js +1 -1
  35. package/lib/TextInput/TextInput.js +0 -11
  36. package/lib/TextInput/TextInputBase.js +9 -0
  37. package/lib/TextInput/propTypes.js +3 -8
  38. package/lib/ThemeProvider/utils/styles.js +2 -2
  39. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  40. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  41. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  42. package/lib/Tooltip/Backdrop.js +2 -10
  43. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  44. package/lib/utils/children.js +2 -2
  45. package/lib/utils/input.js +6 -12
  46. package/lib/utils/props/componentPropType.js +3 -3
  47. package/lib/utils/props/selectSystemProps.js +2 -2
  48. package/lib/utils/props/textInputProps.js +8 -1
  49. package/lib/utils/props/tokens.js +2 -2
  50. package/lib/utils/useSpacingScale.js +3 -1
  51. package/lib/utils/useUniqueId.js +1 -1
  52. package/lib-module/A11yInfoProvider/index.js +63 -0
  53. package/lib-module/A11yText/index.js +56 -0
  54. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  55. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  56. package/lib-module/ActivityIndicator/index.js +41 -0
  57. package/lib-module/ActivityIndicator/shared.js +12 -0
  58. package/lib-module/BaseProvider/index.js +29 -0
  59. package/lib-module/Box/Box.js +244 -0
  60. package/lib-module/Box/index.js +2 -0
  61. package/lib-module/Button/Button.js +26 -0
  62. package/lib-module/Button/ButtonBase.js +271 -0
  63. package/lib-module/Button/ButtonGroup.js +247 -0
  64. package/lib-module/Button/ButtonLink.js +40 -0
  65. package/lib-module/Button/index.js +4 -0
  66. package/lib-module/Button/propTypes.js +36 -0
  67. package/lib-module/Card/Card.js +85 -0
  68. package/lib-module/Card/CardBase.js +66 -0
  69. package/lib-module/Card/PressableCardBase.js +114 -0
  70. package/lib-module/Card/index.js +4 -0
  71. package/lib-module/Checkbox/Checkbox.js +348 -0
  72. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  73. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  74. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  75. package/lib-module/Checkbox/index.js +3 -0
  76. package/lib-module/Divider/Divider.js +124 -0
  77. package/lib-module/Divider/index.js +2 -0
  78. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  79. package/lib-module/ExpandCollapse/Control.js +136 -0
  80. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  81. package/lib-module/ExpandCollapse/Panel.js +159 -0
  82. package/lib-module/ExpandCollapse/index.js +7 -0
  83. package/lib-module/Feedback/Feedback.js +157 -0
  84. package/lib-module/Feedback/index.js +2 -0
  85. package/lib-module/Fieldset/Fieldset.js +153 -0
  86. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  87. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  88. package/lib-module/Fieldset/Legend.js +24 -0
  89. package/lib-module/Fieldset/Legend.native.js +31 -0
  90. package/lib-module/Fieldset/cssReset.js +14 -0
  91. package/lib-module/Fieldset/index.js +2 -0
  92. package/lib-module/FlexGrid/Col/Col.js +276 -0
  93. package/lib-module/FlexGrid/Col/index.js +2 -0
  94. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  95. package/lib-module/FlexGrid/Row/Row.js +184 -0
  96. package/lib-module/FlexGrid/Row/index.js +2 -0
  97. package/lib-module/FlexGrid/helpers/index.js +18 -0
  98. package/lib-module/FlexGrid/index.js +2 -0
  99. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  100. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  101. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  102. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  103. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  104. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  105. package/lib-module/HorizontalScroll/index.js +11 -0
  106. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  107. package/lib-module/Icon/Icon.js +62 -0
  108. package/lib-module/Icon/IconText.js +83 -0
  109. package/lib-module/Icon/index.js +4 -0
  110. package/lib-module/IconButton/IconButton.js +122 -0
  111. package/lib-module/IconButton/index.js +2 -0
  112. package/lib-module/InputLabel/InputLabel.js +148 -0
  113. package/lib-module/InputLabel/LabelContent.js +27 -0
  114. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  115. package/lib-module/InputLabel/index.js +2 -0
  116. package/lib-module/InputSupports/InputSupports.js +96 -0
  117. package/lib-module/InputSupports/index.js +2 -0
  118. package/lib-module/InputSupports/useInputSupports.js +32 -0
  119. package/lib-module/Link/ChevronLink.js +52 -0
  120. package/lib-module/Link/InlinePressable.js +44 -0
  121. package/lib-module/Link/InlinePressable.native.js +89 -0
  122. package/lib-module/Link/Link.js +28 -0
  123. package/lib-module/Link/LinkBase.js +243 -0
  124. package/lib-module/Link/TextButton.js +35 -0
  125. package/lib-module/Link/index.js +5 -0
  126. package/lib-module/List/List.js +62 -0
  127. package/lib-module/List/ListItem.js +248 -0
  128. package/lib-module/List/index.js +5 -0
  129. package/lib-module/Modal/Modal.js +222 -0
  130. package/lib-module/Modal/dictionary.js +9 -0
  131. package/lib-module/Modal/index.js +2 -0
  132. package/lib-module/Notification/Notification.js +209 -0
  133. package/lib-module/Notification/dictionary.js +8 -0
  134. package/lib-module/Notification/index.js +2 -0
  135. package/lib-module/Pagination/PageButton.js +66 -0
  136. package/lib-module/Pagination/Pagination.js +153 -0
  137. package/lib-module/Pagination/SideButton.js +106 -0
  138. package/lib-module/Pagination/dictionary.js +18 -0
  139. package/lib-module/Pagination/index.js +2 -0
  140. package/lib-module/Pagination/usePagination.js +73 -0
  141. package/lib-module/Progress/Progress.js +89 -0
  142. package/lib-module/Progress/ProgressBar.js +138 -0
  143. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  144. package/lib-module/Progress/index.js +4 -0
  145. package/lib-module/Radio/Radio.js +285 -0
  146. package/lib-module/Radio/RadioButton.js +138 -0
  147. package/lib-module/Radio/RadioGroup.js +243 -0
  148. package/lib-module/Radio/RadioInput.js +62 -0
  149. package/lib-module/Radio/RadioInput.native.js +6 -0
  150. package/lib-module/Radio/index.js +3 -0
  151. package/lib-module/RadioCard/RadioCard.js +219 -0
  152. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  153. package/lib-module/RadioCard/index.js +3 -0
  154. package/lib-module/Search/Search.js +261 -0
  155. package/lib-module/Search/dictionary.js +12 -0
  156. package/lib-module/Search/index.js +2 -0
  157. package/lib-module/Select/Group.js +21 -0
  158. package/lib-module/Select/Group.native.js +15 -0
  159. package/lib-module/Select/Item.js +20 -0
  160. package/lib-module/Select/Item.native.js +3 -0
  161. package/lib-module/Select/Picker.js +68 -0
  162. package/lib-module/Select/Picker.native.js +120 -0
  163. package/lib-module/Select/Select.js +337 -0
  164. package/lib-module/Select/index.js +6 -0
  165. package/lib-module/SideNav/Item.js +145 -0
  166. package/lib-module/SideNav/ItemContent.js +48 -0
  167. package/lib-module/SideNav/ItemsGroup.js +117 -0
  168. package/lib-module/SideNav/SideNav.js +136 -0
  169. package/lib-module/SideNav/index.js +1 -0
  170. package/lib-module/Skeleton/Skeleton.js +179 -0
  171. package/lib-module/Skeleton/index.js +2 -0
  172. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  173. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  174. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  175. package/lib-module/Spacer/Spacer.js +98 -0
  176. package/lib-module/Spacer/index.js +2 -0
  177. package/lib-module/StackView/StackView.js +125 -0
  178. package/lib-module/StackView/StackWrap.js +50 -0
  179. package/lib-module/StackView/StackWrap.native.js +3 -0
  180. package/lib-module/StackView/StackWrapBox.js +115 -0
  181. package/lib-module/StackView/StackWrapGap.js +59 -0
  182. package/lib-module/StackView/common.js +35 -0
  183. package/lib-module/StackView/getStackedContent.js +124 -0
  184. package/lib-module/StackView/index.js +5 -0
  185. package/lib-module/StepTracker/Step.js +248 -0
  186. package/lib-module/StepTracker/StepTracker.js +185 -0
  187. package/lib-module/StepTracker/dictionary.js +10 -0
  188. package/lib-module/StepTracker/index.js +2 -0
  189. package/lib-module/Tabs/Tabs.js +143 -0
  190. package/lib-module/Tabs/TabsItem.js +224 -0
  191. package/lib-module/Tabs/index.js +2 -0
  192. package/lib-module/Tags/Tags.js +251 -0
  193. package/lib-module/Tags/index.js +2 -0
  194. package/lib-module/TextInput/TextArea.js +94 -0
  195. package/lib-module/TextInput/TextInput.js +64 -0
  196. package/lib-module/TextInput/TextInputBase.js +254 -0
  197. package/lib-module/TextInput/index.js +3 -0
  198. package/lib-module/TextInput/propTypes.js +33 -0
  199. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  200. package/lib-module/ThemeProvider/index.js +6 -0
  201. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  202. package/lib-module/ThemeProvider/useTheme.js +14 -0
  203. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  204. package/lib-module/ThemeProvider/utils/index.js +2 -0
  205. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  206. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  207. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  208. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  209. package/lib-module/ToggleSwitch/index.js +3 -0
  210. package/lib-module/Tooltip/Backdrop.js +45 -0
  211. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  212. package/lib-module/Tooltip/Tooltip.js +348 -0
  213. package/lib-module/Tooltip/dictionary.js +8 -0
  214. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  215. package/lib-module/Tooltip/index.js +2 -0
  216. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  217. package/lib-module/TooltipButton/index.js +2 -0
  218. package/lib-module/Typography/Typography.js +124 -0
  219. package/lib-module/Typography/index.js +2 -0
  220. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  221. package/lib-module/ViewportProvider/index.js +3 -0
  222. package/lib-module/ViewportProvider/useViewport.js +3 -0
  223. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  224. package/lib-module/index.js +48 -0
  225. package/lib-module/utils/a11y/index.js +2 -0
  226. package/lib-module/utils/a11y/semantics.js +157 -0
  227. package/lib-module/utils/a11y/textSize.js +36 -0
  228. package/lib-module/utils/animation/index.js +2 -0
  229. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  230. package/lib-module/utils/children.js +119 -0
  231. package/lib-module/utils/containUniqueFields.js +26 -0
  232. package/lib-module/utils/index.js +16 -0
  233. package/lib-module/utils/info/index.js +7 -0
  234. package/lib-module/utils/info/platform/index.js +11 -0
  235. package/lib-module/utils/info/platform/platform.android.js +1 -0
  236. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  237. package/lib-module/utils/info/platform/platform.js +1 -0
  238. package/lib-module/utils/info/platform/platform.native.js +4 -0
  239. package/lib-module/utils/info/versions.js +5 -0
  240. package/lib-module/utils/input.js +179 -0
  241. package/lib-module/utils/pressability.js +111 -0
  242. package/lib-module/utils/props/a11yProps.js +140 -0
  243. package/lib-module/utils/props/clickProps.js +26 -0
  244. package/lib-module/utils/props/componentPropType.js +63 -0
  245. package/lib-module/utils/props/copyPropTypes.js +2 -0
  246. package/lib-module/utils/props/getPropSelector.js +9 -0
  247. package/lib-module/utils/props/handlerProps.js +65 -0
  248. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  249. package/lib-module/utils/props/index.js +19 -0
  250. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  251. package/lib-module/utils/props/linkProps.js +44 -0
  252. package/lib-module/utils/props/paddingProp.js +9 -0
  253. package/lib-module/utils/props/pressProps.js +42 -0
  254. package/lib-module/utils/props/rectProp.js +9 -0
  255. package/lib-module/utils/props/responsiveProps.js +30 -0
  256. package/lib-module/utils/props/selectSystemProps.js +24 -0
  257. package/lib-module/utils/props/spacingProps.js +56 -0
  258. package/lib-module/utils/props/textInputProps.js +201 -0
  259. package/lib-module/utils/props/textProps.js +59 -0
  260. package/lib-module/utils/props/tokens.js +133 -0
  261. package/lib-module/utils/props/variantProp.js +18 -0
  262. package/lib-module/utils/props/viewProps.js +22 -0
  263. package/lib-module/utils/ssr.js +38 -0
  264. package/lib-module/utils/useCopy.js +44 -0
  265. package/lib-module/utils/useHash.js +45 -0
  266. package/lib-module/utils/useHash.native.js +7 -0
  267. package/lib-module/utils/useResponsiveProp.js +47 -0
  268. package/lib-module/utils/useSpacingScale.js +125 -0
  269. package/lib-module/utils/useUniqueId.js +13 -0
  270. package/lib-module/utils/withLinkRouter.js +83 -0
  271. package/package.json +3 -3
  272. package/src/Card/Card.jsx +6 -4
  273. package/src/Checkbox/Checkbox.jsx +3 -1
  274. package/src/ExpandCollapse/Panel.jsx +10 -20
  275. package/src/Link/InlinePressable.jsx +5 -2
  276. package/src/Link/LinkBase.jsx +4 -1
  277. package/src/List/List.jsx +6 -2
  278. package/src/Tabs/Tabs.jsx +24 -2
  279. package/src/Tabs/TabsItem.jsx +6 -5
  280. package/src/TextInput/TextInput.jsx +1 -8
  281. package/src/TextInput/TextInputBase.jsx +11 -1
  282. package/src/TextInput/propTypes.js +3 -7
  283. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
  284. package/src/utils/props/textInputProps.js +7 -1
@@ -0,0 +1,136 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ExpandCollapse from '../ExpandCollapse';
4
+ import Item from './Item';
5
+ import ItemsGroup from './ItemsGroup';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import { a11yProps, componentPropType, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
8
+ import { createElement as _createElement } from "react";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+
11
+ function selectBorderStyles(tokens) {
12
+ return {
13
+ borderBottomWidth: tokens.borderWidth,
14
+ borderBottomStyle: tokens.borderStyle,
15
+ borderBottomColor: tokens.borderColor
16
+ };
17
+ }
18
+
19
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
20
+ /**
21
+ ## Usage Criteria
22
+ - Use in conjunction with a large amount of educational / informational content
23
+ - Allow the user to navigate between options frequently and efficiently
24
+ */
25
+
26
+ const SideNav = /*#__PURE__*/forwardRef((_ref, ref) => {
27
+ let {
28
+ children,
29
+ variant = {},
30
+ tokens,
31
+ accordion = true,
32
+ itemTokens,
33
+ groupTokens,
34
+ ...rest
35
+ } = _ref;
36
+ const themeTokens = useThemeTokens('SideNav', tokens, variant);
37
+ const [active, setActive] = useState({
38
+ groupId: undefined,
39
+ itemId: undefined
40
+ });
41
+
42
+ const onItemPress = (itemId, groupId) => {
43
+ setActive({
44
+ itemId,
45
+ groupId
46
+ });
47
+ };
48
+
49
+ const isItemActive = (itemId, groupId) => {
50
+ return active.groupId === groupId && active.itemId === itemId;
51
+ };
52
+
53
+ return /*#__PURE__*/_jsx(ExpandCollapse, {
54
+ ref: ref,
55
+ maxOpen: accordion ? 1 : null,
56
+ style: selectBorderStyles(themeTokens),
57
+ ...selectProps(rest),
58
+ children: _ref2 => {
59
+ let {
60
+ openIds,
61
+ onToggle
62
+ } = _ref2;
63
+
64
+ const renderItem = (item, index, groupId) => {
65
+ const {
66
+ itemId = "item-".concat(index),
67
+ onPress
68
+ } = item.props;
69
+
70
+ const handlePress = function () {
71
+ onItemPress(...arguments);
72
+ if (onPress) onPress(...arguments);
73
+ };
74
+
75
+ return /*#__PURE__*/_createElement(Item, { ...item.props,
76
+ key: itemId,
77
+ itemId: itemId,
78
+ groupId: groupId,
79
+ variant: groupId ? { ...variant,
80
+ type: 'child'
81
+ } : variant,
82
+ tokens: itemTokens,
83
+ isActive: isItemActive(itemId, groupId),
84
+ onPress: handlePress
85
+ });
86
+ };
87
+
88
+ return React.Children.map(children, (child, index) => {
89
+ // iterate over children and identify them internally to later reference expanded groups and active items
90
+ if (child.type === Item) return renderItem(child, index);
91
+
92
+ if (child.type === ItemsGroup) {
93
+ const {
94
+ groupId = "group-".concat(index)
95
+ } = child.props;
96
+ const isGroupActive = active.itemId !== undefined && active.groupId === groupId;
97
+
98
+ const handleToggle = event => onToggle(groupId, event);
99
+
100
+ return /*#__PURE__*/_createElement(ItemsGroup, { ...child.props,
101
+ key: groupId,
102
+ groupId: groupId,
103
+ variant: variant,
104
+ tokens: groupTokens,
105
+ itemTokens: itemTokens,
106
+ openGroups: openIds,
107
+ isActive: isGroupActive,
108
+ onToggle: handleToggle
109
+ }, React.Children.map(child.props.children, (item, itemIndex) => renderItem(item, itemIndex, groupId)));
110
+ }
111
+
112
+ return null;
113
+ });
114
+ }
115
+ });
116
+ });
117
+ SideNav.displayName = 'SideNav';
118
+ SideNav.propTypes = { ...selectedSystemPropTypes,
119
+
120
+ /**
121
+ * Specifies the structure and links of the `SideNav`. It may only consist of `SideNav.Item` and `SideNav.ItemsGroup`.
122
+ */
123
+ children: componentPropType(['Item', 'ItemsGroup']),
124
+
125
+ /**
126
+ * Identifies if only one `SideNav.ItemsGroup` should be open at a time.
127
+ */
128
+ accordion: PropTypes.bool,
129
+ variant: variantProp.propType,
130
+ tokens: getTokensPropType('SideNav'),
131
+ itemTokens: getTokensPropType('SideNavItem'),
132
+ groupTokens: getTokensPropType('SideNavItemsGroup')
133
+ };
134
+ SideNav.Item = Item;
135
+ SideNav.ItemsGroup = ItemsGroup;
136
+ export default SideNav;
@@ -0,0 +1 @@
1
+ export { default } from './SideNav';
@@ -0,0 +1,179 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Animated from "react-native-web/dist/exports/Animated";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import propTypes from 'prop-types';
5
+ import StackView from '../StackView';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import { a11yProps, getTokensPropType, selectSystemProps, responsiveProps, useResponsiveProp, useSpacingScale, spacingProps, variantProp, viewProps } from '../utils';
8
+ import useSkeletonNativeAnimation from './useSkeletonNativeAnimation';
9
+ import skeletonWebAnimation from './skeletonWebAnimation';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+
13
+ const selectSkeletonStyles = _ref => {
14
+ let {
15
+ color,
16
+ radius,
17
+ fadeAnimation
18
+ } = _ref;
19
+ return {
20
+ backgroundColor: color,
21
+ borderRadius: radius,
22
+ ...fadeAnimation
23
+ };
24
+ };
25
+
26
+ const selectLineStyles = _ref2 => {
27
+ let {
28
+ skeletonHeight,
29
+ lineWidth
30
+ } = _ref2;
31
+ return {
32
+ width: lineWidth,
33
+ height: skeletonHeight
34
+ };
35
+ };
36
+
37
+ const selectShapeStyles = _ref3 => {
38
+ let {
39
+ skeletonHeight
40
+ } = _ref3;
41
+ return {
42
+ height: skeletonHeight,
43
+ width: skeletonHeight
44
+ };
45
+ };
46
+
47
+ const selectSquareStyles = _ref4 => {
48
+ let {
49
+ radius
50
+ } = _ref4;
51
+ return {
52
+ borderRadius: radius
53
+ };
54
+ };
55
+
56
+ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
57
+ let {
58
+ tokens,
59
+ variant,
60
+ size,
61
+ sizeIndex = size,
62
+ sizePixels,
63
+ characters,
64
+ lines,
65
+ shape = 'line',
66
+ ...rest
67
+ } = _ref5;
68
+ const themeTokens = useThemeTokens('Skeleton', tokens, variant);
69
+ const pixels = useResponsiveProp(sizePixels);
70
+ const spacingScaleValue = typeof pixels === 'number' ? // Size by an exact number of pixels
71
+ {
72
+ options: {
73
+ size: pixels
74
+ }
75
+ } : // Size by an index on the spacing scale (getting default index from theme if none provided)
76
+ sizeIndex || themeTokens.size;
77
+ const skeletonHeight = useSpacingScale(spacingScaleValue);
78
+ const nativeAnimation = useSkeletonNativeAnimation();
79
+
80
+ const getAnimationBaseOnPlatform = () => {
81
+ if (Platform.OS !== 'web') {
82
+ return nativeAnimation;
83
+ }
84
+
85
+ return skeletonWebAnimation;
86
+ };
87
+
88
+ const getLineWidth = () => {
89
+ if (characters) {
90
+ return characters * themeTokens.baseWidth;
91
+ }
92
+
93
+ return themeTokens.characters * themeTokens.baseWidth;
94
+ };
95
+
96
+ const getStyledBasedOnShape = () => {
97
+ if (shape === 'circle') {
98
+ return selectShapeStyles({
99
+ skeletonHeight
100
+ });
101
+ }
102
+
103
+ if (shape === 'box') {
104
+ return [selectShapeStyles({
105
+ skeletonHeight
106
+ }), selectSquareStyles({
107
+ radius: themeTokens.squareRadius
108
+ })];
109
+ }
110
+
111
+ return selectLineStyles({
112
+ skeletonHeight,
113
+ lineWidth: getLineWidth()
114
+ });
115
+ };
116
+
117
+ const renderSkeleton = function () {
118
+ let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
119
+ return /*#__PURE__*/_jsx(Animated.View, {
120
+ testID: "skeleton",
121
+ style: [selectSkeletonStyles({ ...themeTokens,
122
+ fadeAnimation: getAnimationBaseOnPlatform()
123
+ }), getStyledBasedOnShape()]
124
+ }, "skeleton-".concat(index + 1));
125
+ };
126
+
127
+ return /*#__PURE__*/_jsx(StackView, {
128
+ space: themeTokens.spaceBetweenLines,
129
+ ref: ref,
130
+ ...selectProps(rest),
131
+ children: lines > 1 ? [...Array(lines)].map((_, index) => renderSkeleton(index)) : renderSkeleton()
132
+ });
133
+ });
134
+ Skeleton.displayName = 'Skeleton';
135
+ Skeleton.propTypes = { ...selectedSystemPropTypes,
136
+ tokens: getTokensPropType('Skeleton'),
137
+ variant: variantProp.propType,
138
+
139
+ /**
140
+ * Sets the size of Skeleton lines or shape according to the theme's spacing scale. For example, size={1} gives the smallest non-zero theme-defined spacing size.
141
+ *
142
+ * May also accept an object with responsive viewport keys or spacing scale options - see `useSpacingScale` for details.
143
+ */
144
+ sizeIndex: spacingProps.types.spacingValue,
145
+
146
+ /**
147
+ * @deprecated alias for `sizeIndex`
148
+ */
149
+ size: spacingProps.types.spacingValue,
150
+
151
+ /**
152
+ * Sets the size of Skeleton lines or shape to an exact number of pixels. Use when it's necessary to exactly match sizes of images or other boxes.
153
+ *
154
+ * Accepts a number or an object with responsive viewport keys, e.g. { xs: 32, lg: 64 } would be 32px at xs, sm and md and 64 at lg and xl viewports.
155
+ */
156
+ sizePixels: responsiveProps.getTypeOptionallyByViewport(propTypes.number),
157
+
158
+ /**
159
+ * Determines the width of simulated lines of text if the Skeleton's shape is 'line' (the default shape).
160
+ *
161
+ * Only has any affect if shape is line (the default). If unset, takes a default value from the theme.
162
+ */
163
+ characters: propTypes.number,
164
+
165
+ /**
166
+ * Determines how many Skeleton items are rendered (default 1).
167
+ *
168
+ * Recommended usage is to simulate paragraphs of text when Skeleton's shape is 'line' (the default shape).
169
+ *
170
+ * The amount of spacing between multiple lines is controlled by theme tokens.
171
+ */
172
+ lines: propTypes.number,
173
+
174
+ /**
175
+ * Determines if the skeleton should resemble lines of text (default), a circle, or a square box with themed rounded corners.
176
+ */
177
+ shape: propTypes.oneOf(['line', 'circle', 'box'])
178
+ };
179
+ export default Skeleton;
@@ -0,0 +1,2 @@
1
+ import Skeleton from './Skeleton';
2
+ export default Skeleton;
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_OPACITY = 1;
2
+ export const OPACITY_STOP = 0.4;
3
+ export const ANIMATION_DURATION = 1500;
@@ -0,0 +1,18 @@
1
+ import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
2
+ export default {
3
+ animationDuration: "".concat(ANIMATION_DURATION, "ms"),
4
+ animationTimingFunction: 'ease-in-out',
5
+ animationDelay: '0.5s',
6
+ animationIterationCount: 'infinite',
7
+ animationKeyframes: {
8
+ '0%': {
9
+ opacity: DEFAULT_OPACITY
10
+ },
11
+ '50%': {
12
+ opacity: OPACITY_STOP
13
+ },
14
+ '100%': {
15
+ opacity: DEFAULT_OPACITY
16
+ }
17
+ }
18
+ };
@@ -0,0 +1,24 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import Animated from "react-native-web/dist/exports/Animated";
3
+ import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
4
+
5
+ const useSkeletonNativeAnimation = () => {
6
+ const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current;
7
+ useEffect(() => {
8
+ const fade = Animated.sequence([Animated.timing(fadeAnimation, {
9
+ toValue: OPACITY_STOP,
10
+ duration: ANIMATION_DURATION,
11
+ useNativeDriver: true
12
+ }), Animated.timing(fadeAnimation, {
13
+ toValue: DEFAULT_OPACITY,
14
+ duration: ANIMATION_DURATION,
15
+ useNativeDriver: true
16
+ })]);
17
+ Animated.loop(fade).start();
18
+ }, [fadeAnimation]);
19
+ return {
20
+ opacity: fadeAnimation
21
+ };
22
+ };
23
+
24
+ export default useSkeletonNativeAnimation;
@@ -0,0 +1,98 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import View from "react-native-web/dist/exports/View";
5
+ import { a11yProps, selectSystemProps, spacingProps, useSpacingScale, viewProps } from '../utils';
6
+ /**
7
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
8
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
9
+ */
10
+
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
13
+
14
+ const selectSizeStyle = (size, direction) => ({
15
+ // Only apply space in one direction at a time, else large spacers will increase the
16
+ // 'across' size of the parent and mess up siblings with styles like `alignItems: stretch`.
17
+ [direction === 'row' ? 'width' : 'height']: size
18
+ });
19
+ /**
20
+ * An empty element used to create a gap between components that is sized according to the theme spacing scale,
21
+ * passing its `space` prop ({@link SpacingValue}) to `useSpacingScale`.
22
+ *
23
+ * ## Simple spacing
24
+ *
25
+ * For most simple uses, pass a number to Spacer's `space` prop referring to an index in the theme's
26
+ * spacing scale. For example, for a spacer of the theme's smallest non-zero spacing size:
27
+ *
28
+ * ```jsx
29
+ * <Spacer space={1} />
30
+ * ```
31
+ *
32
+ * ## Responsive spacing
33
+ *
34
+ * Different spacing scale sizes may be chosen for different viewports by passing `space` a {@link SpacingObject}
35
+ * using keys for the viewports at and above which certain spacing indexes should apply.
36
+ *
37
+ * This can be useful when a Spacer is inside a layout with a shape that changes between viewports.
38
+ *
39
+ * For example, a spacer might need no width below 'md' viewport because the items it separates will be on separate lines,
40
+ * but may need a visible size above that viewport, and a wider size at the highest viewport:
41
+ *
42
+ * ```jsx
43
+ * <Spacer space={{ xs: 0, md: 2, xl: 3 }} />
44
+ * ```
45
+ *
46
+ * Note that themes may also define viewport-specific behaviour for indexes on the spacing scale. These viewport
47
+ * props should only be used where necessary to achieve a certain responsive layoutm and shouldn't be used to replace
48
+ * or deviate from responsive spacing behaviour in a theme that is intended to apply universally.
49
+ *
50
+ * ## More options
51
+ *
52
+ * See `useSpacingScale` hook for more options that may be used with the `space` prop.
53
+ *
54
+ * ## Accessibility
55
+ *
56
+ * Spacer has no content and is ignored by tools such as screen readers. Use `Divider` for
57
+ * separations between elements that may be treated as semantically meaningful on web.
58
+ */
59
+
60
+
61
+ const Spacer = /*#__PURE__*/forwardRef((_ref, ref) => {
62
+ let {
63
+ space = 1,
64
+ direction = 'column',
65
+ ...rest
66
+ } = _ref;
67
+ const size = useSpacingScale(space);
68
+ const sizeStyle = selectSizeStyle(size, direction);
69
+ return /*#__PURE__*/_jsx(View, {
70
+ ref: ref,
71
+ style: [staticStyles.stretch, sizeStyle],
72
+ ...selectProps(rest)
73
+ });
74
+ });
75
+ Spacer.displayName = 'Spacer';
76
+ Spacer.propTypes = { ...selectedSystemPropTypes,
77
+
78
+ /**
79
+ * The size of the spacer according to the theme's spacing scale.
80
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
81
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
82
+ */
83
+ space: spacingProps.types.spacingValue,
84
+
85
+ /**
86
+ * The spacer applies space in only one direction, which is controlled by the `direction` prop:
87
+ *
88
+ * - `'column'` (default) applies space vertically; has a fixed height and not width.
89
+ * - `'row'` applies space horizontally; has a fixed width and not height.
90
+ */
91
+ direction: PropTypes.oneOf(['column', 'row'])
92
+ };
93
+ const staticStyles = StyleSheet.create({
94
+ stretch: {
95
+ alignSelf: 'stretch'
96
+ }
97
+ });
98
+ export default Spacer;
@@ -0,0 +1,2 @@
1
+ import Spacer from './Spacer';
2
+ export default Spacer;
@@ -0,0 +1,125 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import Divider from '../Divider';
5
+ import { a11yProps, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, responsiveProps, selectSystemProps, spacingProps, useResponsiveProp, variantProp, viewProps } from '../utils';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import { useViewport } from '../ViewportProvider';
8
+ import getStackedContent from './getStackedContent';
9
+ import { staticStyles, selectFlexStyles } from './common';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+ /**
13
+ * StackView evenly spaces its children, by default placing `Spacer` components between them.
14
+ *
15
+ * ## Spacing
16
+ *
17
+ * StackView takes the same spacing props as `Spacer` and passes them directly to the layout components
18
+ * it uses for spacing.
19
+ *
20
+ * ## Direction
21
+ *
22
+ * Use `direction` to control how the children are stacked:
23
+ *
24
+ * - `'column'` (default) stacks and spaces the children vertically.
25
+ * - `'row'` stacks and spaces the children horizontally.
26
+ * - `'column-reverse'` acts the same as `'column'`, but reverses the direction.
27
+ * - `'row-reverse'` acts the same as `'row'`, but reverses the direction.
28
+ *
29
+ * `direction` is an optionally responsive prop and may be an object keyed by viewports. For example,
30
+ * `{ xs: 'column', md: 'row' } stacks as a column on `xs` and `sm` viewports and a row at 'md' and above.
31
+ *
32
+ * ## Theming, alignment and justification
33
+ *
34
+ * `StackView` is a pure layout component and has no theme styles beyond a small set of layout styles
35
+ * (`alignItems`, `justifyContent`, `flexGrow`) which may be set using the `tokens` prop. If the
36
+ * tokens prop is a function it will recieve the current viewport.
37
+ *
38
+ * All other styling such as borders, background colours, padding etc should be applied by wrapping
39
+ * the `StackView` in other components. For example, a `StackView` may be the child of a `Card`.
40
+ *
41
+ * ## Separator options
42
+ *
43
+ * By default, StackView inserts a `<Spacer>` component between each rendered child.
44
+ *
45
+ * With the `divider` prop, it instead renders a `Divider` instead of a `Spacer`. The gap between
46
+ * items will be double what it would be without this prop plus the width of the divider.
47
+ *
48
+ * ## Accessibility
49
+ *
50
+ * `StackView` may take any React Native accessibility props and applies them to the outer `View`.
51
+ * It applies no accessibility props of its own, unless `divider` prop is passed (`Divider` has a
52
+ * semantic role but only on web, not within native apps).
53
+ */
54
+
55
+ const StackView = /*#__PURE__*/forwardRef((_ref, ref) => {
56
+ let {
57
+ space = 1,
58
+ divider,
59
+ direction: directionProp = 'column',
60
+ children,
61
+ variant,
62
+ tokens,
63
+ tag,
64
+ accessibilityRole,
65
+ ...rest
66
+ } = _ref;
67
+ const viewport = useViewport();
68
+ const direction = useResponsiveProp(directionProp, 'column');
69
+ const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
70
+ ...rest
71
+ });
72
+ const content = getStackedContent(children, {
73
+ direction,
74
+ divider,
75
+ space
76
+ });
77
+ const themeTokens = useThemeTokens('StackView', tokens, variant, {
78
+ viewport
79
+ });
80
+ const flexStyles = selectFlexStyles(themeTokens);
81
+ return /*#__PURE__*/_jsx(View, {
82
+ ref: ref,
83
+ ...selectedProps,
84
+ style: [flexStyles, staticStyles[direction]],
85
+ children: content
86
+ });
87
+ });
88
+ StackView.displayName = 'StackView';
89
+ StackView.propTypes = { ...selectedSystemPropTypes,
90
+ tokens: getTokensPropType('StackView'),
91
+ variant: variantProp.propType,
92
+
93
+ /**
94
+ * Sets the `flexDirection` of the container and, if `divider` is used, gives the Divider the appropriate direction.
95
+ */
96
+ direction: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['column', 'row', 'column-reverse', 'row-reverse'])),
97
+
98
+ /**
99
+ * If true, renders a UDS `Divider` component between each item. If an object is passed,
100
+ * this object is passes as props to each Divider.
101
+ */
102
+ divider: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape(Divider.propTypes)]),
103
+
104
+ /**
105
+ * The size of the spacer according to the theme's spacing scale.
106
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
107
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
108
+ */
109
+ space: spacingProps.types.spacingValue,
110
+
111
+ /**
112
+ * Optional semantic HTML tag, to apply to the container on web. Does not change styling.
113
+ *
114
+ * In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
115
+ * is not defined, the accessibilityRole will default to "heading".
116
+ */
117
+ tag: PropTypes.oneOf(layoutTags),
118
+
119
+ /**
120
+ * A StackView may take any children, but will have no effect if it is only passed one child or is passed children
121
+ * wrapped in a component. If necessary, children may be wrapped in one React Fragment.
122
+ */
123
+ children: PropTypes.node
124
+ };
125
+ export default StackView;
@@ -0,0 +1,50 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import StackWrapBox from './StackWrapBox';
4
+ import StackWrapGap from './StackWrapGap'; // In Jest/CI/SSR, global CSS isn't always available and doesn't always have .supports method
5
+
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+
8
+ const cssSupports = function () {
9
+ var _window$CSS;
10
+
11
+ return typeof window !== 'undefined' && typeof ((_window$CSS = window.CSS) === null || _window$CSS === void 0 ? void 0 : _window$CSS.supports) === 'function' && window.CSS.supports(...arguments);
12
+ }; // CSS.supports needs an example of the type of value you intend to use.
13
+ // Will be an integer appended `px` after hooks and JSX styles are resolved.
14
+
15
+
16
+ const exampleGapValue = '1px';
17
+ /**
18
+ * StackWrap is an alternative to StackView where the spaced items are allowed to wrap.
19
+ *
20
+ * As well as providing space between the items, StackWrap provides `gap` space between
21
+ * wrapped lines of items. By default, this `gap` is the same as the gap between spaced items.
22
+ * If a different spacing is desired between wrapped lines, pass a spacing value to the `gap` prop.
23
+ */
24
+
25
+ const StackWrap = /*#__PURE__*/forwardRef((props, ref) => {
26
+ var _props$gap;
27
+
28
+ const {
29
+ space
30
+ } = props; // Don't apply separate gap if `null` or `undefined`, so can be unset in Storybook etc
31
+
32
+ const gap = (_props$gap = props.gap) !== null && _props$gap !== void 0 ? _props$gap : space;
33
+ const canUseCSSGap = Platform.OS === 'web' && gap === space && cssSupports('gap', exampleGapValue);
34
+ return canUseCSSGap ?
35
+ /*#__PURE__*/
36
+ // If possible, use the cleaner implementation that applies CSS `gap` styles to the container.
37
+ _jsx(StackWrapGap, {
38
+ ref: ref,
39
+ ...props
40
+ }) :
41
+ /*#__PURE__*/
42
+ // Else, use the fallback implementation which renders a `Box` component around each child.
43
+ _jsx(StackWrapBox, {
44
+ ref: ref,
45
+ ...props
46
+ });
47
+ });
48
+ StackWrap.displayName = 'StackWrap';
49
+ StackWrap.propTypes = StackWrapBox.propTypes;
50
+ export default StackWrap;
@@ -0,0 +1,3 @@
1
+ import StackWrapBox from './StackWrapBox'; // No support for CSS `gap` on React Native, so always use the fallback "box" implementation.
2
+
3
+ export default StackWrapBox;