@telus-uds/components-base 1.8.2 → 1.8.5

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 (278) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/component-docs.json +36 -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 +5 -3
  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/Link/InlinePressable.js +5 -1
  14. package/lib/Link/LinkBase.js +5 -2
  15. package/lib/List/List.js +12 -7
  16. package/lib/List/ListItem.js +4 -5
  17. package/lib/Modal/Modal.js +2 -1
  18. package/lib/Pagination/PageButton.js +2 -2
  19. package/lib/Pagination/Pagination.js +5 -3
  20. package/lib/Pagination/usePagination.js +2 -2
  21. package/lib/Progress/ProgressBar.js +3 -3
  22. package/lib/Progress/ProgressBarBackground.js +3 -3
  23. package/lib/Radio/Radio.js +2 -2
  24. package/lib/Radio/RadioGroup.js +2 -2
  25. package/lib/RadioCard/RadioCard.js +1 -1
  26. package/lib/RadioCard/RadioCardGroup.js +2 -2
  27. package/lib/Search/Search.js +1 -1
  28. package/lib/SideNav/SideNav.js +2 -2
  29. package/lib/Skeleton/Skeleton.js +1 -1
  30. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  31. package/lib/StackView/StackWrap.js +3 -1
  32. package/lib/StackView/getStackedContent.js +2 -2
  33. package/lib/Tabs/Tabs.js +28 -3
  34. package/lib/Tabs/TabsItem.js +5 -6
  35. package/lib/Tags/Tags.js +1 -1
  36. package/lib/ThemeProvider/utils/styles.js +2 -2
  37. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  38. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  39. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  40. package/lib/Tooltip/Backdrop.js +2 -10
  41. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  42. package/lib/utils/children.js +2 -2
  43. package/lib/utils/input.js +6 -12
  44. package/lib/utils/props/componentPropType.js +3 -3
  45. package/lib/utils/props/selectSystemProps.js +2 -2
  46. package/lib/utils/props/tokens.js +2 -2
  47. package/lib/utils/useSpacingScale.js +3 -1
  48. package/lib/utils/useUniqueId.js +1 -1
  49. package/lib-module/A11yInfoProvider/index.js +63 -0
  50. package/lib-module/A11yText/index.js +56 -0
  51. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  52. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  53. package/lib-module/ActivityIndicator/index.js +41 -0
  54. package/lib-module/ActivityIndicator/shared.js +12 -0
  55. package/lib-module/BaseProvider/index.js +29 -0
  56. package/lib-module/Box/Box.js +244 -0
  57. package/lib-module/Box/index.js +2 -0
  58. package/lib-module/Button/Button.js +26 -0
  59. package/lib-module/Button/ButtonBase.js +271 -0
  60. package/lib-module/Button/ButtonGroup.js +247 -0
  61. package/lib-module/Button/ButtonLink.js +40 -0
  62. package/lib-module/Button/index.js +4 -0
  63. package/lib-module/Button/propTypes.js +36 -0
  64. package/lib-module/Card/Card.js +84 -0
  65. package/lib-module/Card/CardBase.js +66 -0
  66. package/lib-module/Card/PressableCardBase.js +114 -0
  67. package/lib-module/Card/index.js +4 -0
  68. package/lib-module/Checkbox/Checkbox.js +348 -0
  69. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  70. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  71. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  72. package/lib-module/Checkbox/index.js +3 -0
  73. package/lib-module/Divider/Divider.js +124 -0
  74. package/lib-module/Divider/index.js +2 -0
  75. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  76. package/lib-module/ExpandCollapse/Control.js +136 -0
  77. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  78. package/lib-module/ExpandCollapse/Panel.js +151 -0
  79. package/lib-module/ExpandCollapse/index.js +7 -0
  80. package/lib-module/Feedback/Feedback.js +157 -0
  81. package/lib-module/Feedback/index.js +2 -0
  82. package/lib-module/Fieldset/Fieldset.js +153 -0
  83. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  84. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  85. package/lib-module/Fieldset/Legend.js +24 -0
  86. package/lib-module/Fieldset/Legend.native.js +31 -0
  87. package/lib-module/Fieldset/cssReset.js +14 -0
  88. package/lib-module/Fieldset/index.js +2 -0
  89. package/lib-module/FlexGrid/Col/Col.js +276 -0
  90. package/lib-module/FlexGrid/Col/index.js +2 -0
  91. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  92. package/lib-module/FlexGrid/Row/Row.js +184 -0
  93. package/lib-module/FlexGrid/Row/index.js +2 -0
  94. package/lib-module/FlexGrid/helpers/index.js +18 -0
  95. package/lib-module/FlexGrid/index.js +2 -0
  96. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  97. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  98. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  99. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  100. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  101. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  102. package/lib-module/HorizontalScroll/index.js +11 -0
  103. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  104. package/lib-module/Icon/Icon.js +62 -0
  105. package/lib-module/Icon/IconText.js +83 -0
  106. package/lib-module/Icon/index.js +4 -0
  107. package/lib-module/IconButton/IconButton.js +122 -0
  108. package/lib-module/IconButton/index.js +2 -0
  109. package/lib-module/InputLabel/InputLabel.js +148 -0
  110. package/lib-module/InputLabel/LabelContent.js +27 -0
  111. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  112. package/lib-module/InputLabel/index.js +2 -0
  113. package/lib-module/InputSupports/InputSupports.js +96 -0
  114. package/lib-module/InputSupports/index.js +2 -0
  115. package/lib-module/InputSupports/useInputSupports.js +32 -0
  116. package/lib-module/Link/ChevronLink.js +52 -0
  117. package/lib-module/Link/InlinePressable.js +44 -0
  118. package/lib-module/Link/InlinePressable.native.js +89 -0
  119. package/lib-module/Link/Link.js +28 -0
  120. package/lib-module/Link/LinkBase.js +243 -0
  121. package/lib-module/Link/TextButton.js +35 -0
  122. package/lib-module/Link/index.js +5 -0
  123. package/lib-module/List/List.js +62 -0
  124. package/lib-module/List/ListItem.js +248 -0
  125. package/lib-module/List/index.js +5 -0
  126. package/lib-module/Modal/Modal.js +222 -0
  127. package/lib-module/Modal/dictionary.js +9 -0
  128. package/lib-module/Modal/index.js +2 -0
  129. package/lib-module/Notification/Notification.js +209 -0
  130. package/lib-module/Notification/dictionary.js +8 -0
  131. package/lib-module/Notification/index.js +2 -0
  132. package/lib-module/Pagination/PageButton.js +66 -0
  133. package/lib-module/Pagination/Pagination.js +153 -0
  134. package/lib-module/Pagination/SideButton.js +106 -0
  135. package/lib-module/Pagination/dictionary.js +18 -0
  136. package/lib-module/Pagination/index.js +2 -0
  137. package/lib-module/Pagination/usePagination.js +73 -0
  138. package/lib-module/Progress/Progress.js +89 -0
  139. package/lib-module/Progress/ProgressBar.js +138 -0
  140. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  141. package/lib-module/Progress/index.js +4 -0
  142. package/lib-module/Radio/Radio.js +285 -0
  143. package/lib-module/Radio/RadioButton.js +138 -0
  144. package/lib-module/Radio/RadioGroup.js +243 -0
  145. package/lib-module/Radio/RadioInput.js +62 -0
  146. package/lib-module/Radio/RadioInput.native.js +6 -0
  147. package/lib-module/Radio/index.js +3 -0
  148. package/lib-module/RadioCard/RadioCard.js +219 -0
  149. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  150. package/lib-module/RadioCard/index.js +3 -0
  151. package/lib-module/Search/Search.js +261 -0
  152. package/lib-module/Search/dictionary.js +12 -0
  153. package/lib-module/Search/index.js +2 -0
  154. package/lib-module/Select/Group.js +21 -0
  155. package/lib-module/Select/Group.native.js +15 -0
  156. package/lib-module/Select/Item.js +20 -0
  157. package/lib-module/Select/Item.native.js +3 -0
  158. package/lib-module/Select/Picker.js +68 -0
  159. package/lib-module/Select/Picker.native.js +120 -0
  160. package/lib-module/Select/Select.js +337 -0
  161. package/lib-module/Select/index.js +6 -0
  162. package/lib-module/SideNav/Item.js +145 -0
  163. package/lib-module/SideNav/ItemContent.js +48 -0
  164. package/lib-module/SideNav/ItemsGroup.js +117 -0
  165. package/lib-module/SideNav/SideNav.js +136 -0
  166. package/lib-module/SideNav/index.js +1 -0
  167. package/lib-module/Skeleton/Skeleton.js +179 -0
  168. package/lib-module/Skeleton/index.js +2 -0
  169. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  170. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  171. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  172. package/lib-module/Spacer/Spacer.js +98 -0
  173. package/lib-module/Spacer/index.js +2 -0
  174. package/lib-module/StackView/StackView.js +125 -0
  175. package/lib-module/StackView/StackWrap.js +50 -0
  176. package/lib-module/StackView/StackWrap.native.js +3 -0
  177. package/lib-module/StackView/StackWrapBox.js +115 -0
  178. package/lib-module/StackView/StackWrapGap.js +59 -0
  179. package/lib-module/StackView/common.js +35 -0
  180. package/lib-module/StackView/getStackedContent.js +124 -0
  181. package/lib-module/StackView/index.js +5 -0
  182. package/lib-module/StepTracker/Step.js +248 -0
  183. package/lib-module/StepTracker/StepTracker.js +185 -0
  184. package/lib-module/StepTracker/dictionary.js +10 -0
  185. package/lib-module/StepTracker/index.js +2 -0
  186. package/lib-module/Tabs/Tabs.js +143 -0
  187. package/lib-module/Tabs/TabsItem.js +224 -0
  188. package/lib-module/Tabs/index.js +2 -0
  189. package/lib-module/Tags/Tags.js +251 -0
  190. package/lib-module/Tags/index.js +2 -0
  191. package/lib-module/TextInput/TextArea.js +94 -0
  192. package/lib-module/TextInput/TextInput.js +72 -0
  193. package/lib-module/TextInput/TextInputBase.js +245 -0
  194. package/lib-module/TextInput/index.js +3 -0
  195. package/lib-module/TextInput/propTypes.js +37 -0
  196. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  197. package/lib-module/ThemeProvider/index.js +6 -0
  198. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  199. package/lib-module/ThemeProvider/useTheme.js +14 -0
  200. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  201. package/lib-module/ThemeProvider/utils/index.js +2 -0
  202. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  203. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  204. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  205. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  206. package/lib-module/ToggleSwitch/index.js +3 -0
  207. package/lib-module/Tooltip/Backdrop.js +45 -0
  208. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  209. package/lib-module/Tooltip/Tooltip.js +348 -0
  210. package/lib-module/Tooltip/dictionary.js +8 -0
  211. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  212. package/lib-module/Tooltip/index.js +2 -0
  213. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  214. package/lib-module/TooltipButton/index.js +2 -0
  215. package/lib-module/Typography/Typography.js +124 -0
  216. package/lib-module/Typography/index.js +2 -0
  217. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  218. package/lib-module/ViewportProvider/index.js +3 -0
  219. package/lib-module/ViewportProvider/useViewport.js +3 -0
  220. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  221. package/lib-module/index.js +48 -0
  222. package/lib-module/utils/a11y/index.js +2 -0
  223. package/lib-module/utils/a11y/semantics.js +157 -0
  224. package/lib-module/utils/a11y/textSize.js +36 -0
  225. package/lib-module/utils/animation/index.js +2 -0
  226. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  227. package/lib-module/utils/children.js +119 -0
  228. package/lib-module/utils/containUniqueFields.js +26 -0
  229. package/lib-module/utils/index.js +16 -0
  230. package/lib-module/utils/info/index.js +7 -0
  231. package/lib-module/utils/info/platform/index.js +11 -0
  232. package/lib-module/utils/info/platform/platform.android.js +1 -0
  233. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  234. package/lib-module/utils/info/platform/platform.js +1 -0
  235. package/lib-module/utils/info/platform/platform.native.js +4 -0
  236. package/lib-module/utils/info/versions.js +5 -0
  237. package/lib-module/utils/input.js +179 -0
  238. package/lib-module/utils/pressability.js +111 -0
  239. package/lib-module/utils/props/a11yProps.js +140 -0
  240. package/lib-module/utils/props/clickProps.js +26 -0
  241. package/lib-module/utils/props/componentPropType.js +63 -0
  242. package/lib-module/utils/props/copyPropTypes.js +2 -0
  243. package/lib-module/utils/props/getPropSelector.js +9 -0
  244. package/lib-module/utils/props/handlerProps.js +65 -0
  245. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  246. package/lib-module/utils/props/index.js +19 -0
  247. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  248. package/lib-module/utils/props/linkProps.js +44 -0
  249. package/lib-module/utils/props/paddingProp.js +9 -0
  250. package/lib-module/utils/props/pressProps.js +42 -0
  251. package/lib-module/utils/props/rectProp.js +9 -0
  252. package/lib-module/utils/props/responsiveProps.js +30 -0
  253. package/lib-module/utils/props/selectSystemProps.js +24 -0
  254. package/lib-module/utils/props/spacingProps.js +56 -0
  255. package/lib-module/utils/props/textInputProps.js +194 -0
  256. package/lib-module/utils/props/textProps.js +59 -0
  257. package/lib-module/utils/props/tokens.js +133 -0
  258. package/lib-module/utils/props/variantProp.js +18 -0
  259. package/lib-module/utils/props/viewProps.js +22 -0
  260. package/lib-module/utils/ssr.js +38 -0
  261. package/lib-module/utils/useCopy.js +44 -0
  262. package/lib-module/utils/useHash.js +45 -0
  263. package/lib-module/utils/useHash.native.js +7 -0
  264. package/lib-module/utils/useResponsiveProp.js +47 -0
  265. package/lib-module/utils/useSpacingScale.js +125 -0
  266. package/lib-module/utils/useUniqueId.js +13 -0
  267. package/lib-module/utils/withLinkRouter.js +83 -0
  268. package/package.json +3 -2
  269. package/src/Checkbox/Checkbox.jsx +3 -1
  270. package/src/ExpandCollapse/Panel.jsx +2 -19
  271. package/src/Link/InlinePressable.jsx +5 -2
  272. package/src/Link/LinkBase.jsx +4 -1
  273. package/src/List/List.jsx +34 -19
  274. package/src/List/ListItem.jsx +12 -2
  275. package/src/Modal/Modal.jsx +2 -1
  276. package/src/Tabs/Tabs.jsx +24 -2
  277. package/src/Tabs/TabsItem.jsx +6 -5
  278. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -0,0 +1,106 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Text from "react-native-web/dist/exports/Text";
3
+ import PropTypes from 'prop-types';
4
+ import ButtonBase from '../Button/ButtonBase';
5
+ import { IconText } from '../Icon';
6
+ import { useThemeTokensCallback } from '../ThemeProvider';
7
+ import { useViewport } from '../ViewportProvider';
8
+ import { copyPropTypes, hrefAttrsProp, linkProps, selectTokens, withLinkRouter } from '../utils';
9
+ import dictionary from './dictionary';
10
+ import useCopy from '../utils/useCopy';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+
13
+ const selectIconTokens = (_ref, direction) => {
14
+ let {
15
+ color,
16
+ iconSize,
17
+ iconDisplace
18
+ } = _ref;
19
+ return {
20
+ color,
21
+ size: iconSize,
22
+ translateX: iconDisplace * (direction === 'previous' ? -1 : 1)
23
+ };
24
+ };
25
+
26
+ const directionToSide = {
27
+ previous: 'left',
28
+ next: 'right'
29
+ };
30
+ const SideButton = /*#__PURE__*/forwardRef((_ref2, ref) => {
31
+ let {
32
+ direction = 'previous',
33
+ onPress,
34
+ href,
35
+ copy,
36
+ variant,
37
+ tokens,
38
+ ...props
39
+ } = _ref2;
40
+ const viewport = useViewport();
41
+ const buttonVariant = {
42
+ direction,
43
+ viewport,
44
+ ...variant
45
+ };
46
+ const getTokens = useThemeTokensCallback('PaginationSideButton', tokens, buttonVariant);
47
+ const getCopy = useCopy({
48
+ dictionary,
49
+ copy
50
+ });
51
+ const {
52
+ icon
53
+ } = getTokens(tokens, buttonVariant);
54
+
55
+ const getButtonTokens = buttonState => selectTokens('Button', getTokens(buttonState));
56
+
57
+ const getIconTokens = buttonState => selectIconTokens(getTokens(buttonState), direction);
58
+
59
+ const label = direction === 'previous' ? getCopy('previousText') : getCopy('nextText');
60
+ const showLabel = viewport !== 'sm' && viewport !== 'xs';
61
+ const accessibilityLabel = direction === 'previous' ? getCopy('previousLabel') : getCopy('nextLabel');
62
+ const accessibilityRole = href !== undefined ? 'link' : 'button';
63
+ const {
64
+ hrefAttrs,
65
+ rest
66
+ } = hrefAttrsProp.bundle(props);
67
+ const buttonProps = {
68
+ accessibilityRole,
69
+ accessibilityLabel,
70
+ onPress,
71
+ href,
72
+ hrefAttrs,
73
+ ...rest
74
+ };
75
+ return /*#__PURE__*/_jsx(ButtonBase, {
76
+ ref: ref,
77
+ ...buttonProps,
78
+ tokens: getButtonTokens,
79
+ children: _ref3 => {
80
+ let {
81
+ textStyles,
82
+ ...buttonState
83
+ } = _ref3;
84
+ const iconProps = {
85
+ tokens: getIconTokens(buttonState)
86
+ };
87
+ return /*#__PURE__*/_jsx(IconText, {
88
+ icon: icon,
89
+ space: 1,
90
+ iconPosition: directionToSide[direction],
91
+ iconProps: iconProps,
92
+ children: showLabel && /*#__PURE__*/_jsx(Text, {
93
+ style: textStyles,
94
+ children: label
95
+ })
96
+ });
97
+ }
98
+ });
99
+ });
100
+ SideButton.displayName = 'SideButton';
101
+ SideButton.propTypes = {
102
+ direction: PropTypes.oneOf(['previous', 'next']),
103
+ copy: copyPropTypes,
104
+ ...linkProps.types
105
+ };
106
+ export default withLinkRouter(SideButton);
@@ -0,0 +1,18 @@
1
+ export default {
2
+ en: {
3
+ goToLabel: 'Go to page number',
4
+ currentLabel: '(current)',
5
+ previousLabel: 'Go to previous page',
6
+ previousText: 'Previous',
7
+ nextLabel: 'Go to next page',
8
+ nextText: 'Next'
9
+ },
10
+ fr: {
11
+ goToLabel: 'Aller au page n°',
12
+ currentLabel: '(page actuelle)',
13
+ previousLabel: 'Aller au page précédent',
14
+ previousText: 'Précédent',
15
+ nextLabel: 'Aller au prochain page',
16
+ nextText: 'Suivant'
17
+ }
18
+ };
@@ -0,0 +1,2 @@
1
+ import Pagination from './Pagination';
2
+ export default Pagination;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Handles configurable truncating of pagination items.
3
+ *
4
+ * @param {object} props
5
+ * @param {React.Element[]} items
6
+ * @param {number} truncateAbove
7
+ */
8
+ function usePagination(_ref) {
9
+ let {
10
+ items,
11
+ truncateAbove
12
+ } = _ref;
13
+ const activeItemIndex = Math.max(items.findIndex(item => item.props.isActive), 0 // default to the first item if none is marked as active
14
+ );
15
+
16
+ const getItemProps = index => {
17
+ var _items$index$props, _items$index;
18
+
19
+ const {
20
+ onPress,
21
+ href,
22
+ hrefAttrs,
23
+ variant,
24
+ tokens
25
+ } = (_items$index$props = (_items$index = items[index]) === null || _items$index === void 0 ? void 0 : _items$index.props) !== null && _items$index$props !== void 0 ? _items$index$props : {};
26
+ return {
27
+ onPress,
28
+ href,
29
+ hrefAttrs,
30
+ variant,
31
+ tokens
32
+ };
33
+ };
34
+
35
+ const windowSize = truncateAbove > 4 ? 3 : 1;
36
+ const truncateEnabled = items.length > truncateAbove;
37
+ const truncateWindowStart = windowSize;
38
+ const truncateWindowEnd = items.length - 1 - windowSize; // basically how many items next to the currently active one do we want to render
39
+
40
+ const activeWindowStart = activeItemIndex - (windowSize - 1) / 2;
41
+ const activeWindowEnd = activeItemIndex + (windowSize - 1) / 2;
42
+ const isFirstActive = activeItemIndex === 0;
43
+ const isLastActive = activeItemIndex === items.length - 1; // start truncating when the active item is within the truncate window
44
+
45
+ const isLeftTruncated = truncateEnabled && activeItemIndex >= truncateWindowStart;
46
+ const isRightTruncated = truncateEnabled && activeItemIndex <= truncateWindowEnd;
47
+
48
+ function shouldRenderEllipsis(itemIndex) {
49
+ const isNextToFirst = itemIndex === 1;
50
+ const isNextToLast = itemIndex === items.length - 2;
51
+ return isLeftTruncated && isNextToFirst || isRightTruncated && isNextToLast;
52
+ }
53
+
54
+ function shouldRenderButton(itemIndex) {
55
+ const isFirst = itemIndex === 0;
56
+ const isLast = itemIndex === items.length - 1;
57
+ const isInActiveWindow = itemIndex >= activeWindowStart && itemIndex <= activeWindowEnd;
58
+ return isFirst || isLast || isInActiveWindow || !isLeftTruncated && itemIndex <= truncateWindowStart || !isRightTruncated && itemIndex >= truncateWindowEnd;
59
+ }
60
+
61
+ return {
62
+ showPrevious: !isFirstActive,
63
+ showNext: !isLastActive,
64
+ shouldRenderButton,
65
+ shouldRenderEllipsis,
66
+ isItemActive: itemIndex => itemIndex === activeItemIndex,
67
+ getItemProps,
68
+ nextItemProps: getItemProps(activeItemIndex + 1),
69
+ previousItemProps: getItemProps(activeItemIndex - 1)
70
+ };
71
+ }
72
+
73
+ export default usePagination;
@@ -0,0 +1,89 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import { useThemeTokens } from '../ThemeProvider';
5
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
8
+
9
+ const selectProgressStyles = _ref => {
10
+ let {
11
+ backgroundColor,
12
+ borderWidth,
13
+ borderColor,
14
+ borderRadius,
15
+ height
16
+ } = _ref;
17
+ return {
18
+ backgroundColor,
19
+ borderWidth,
20
+ borderColor,
21
+ borderRadius,
22
+ height
23
+ };
24
+ };
25
+ /**
26
+ * The `Progress` is a container for displaying one or several `ProgressBar`s.
27
+ *
28
+ * ## Props
29
+ *
30
+ * - Use `children` prop to pass one or multiple `ProgressBar`s. Note that in case of stacked progress bars
31
+ * each next will be displayed on top of the previous one.
32
+ *
33
+ * ## Tokens
34
+ *
35
+ * - Use the following tokens to customize the appearance:
36
+ * - `backgroundColor` for the background color of the progress container,
37
+ * - `borderColor` to control the color of the border,
38
+ * - `borderRadius` for the rounded corners,
39
+ * - `borderWidth` to change the border width.
40
+ * - `height` to control the height of the progress bars displayed within the progress bar container.
41
+ *
42
+ * ## Variants
43
+ *
44
+ * - Use the `size` variant to control the height of your progress bars: passing `'mini'` will make your
45
+ * progress bar container narrower.
46
+ *
47
+ * ## Usability and A11y guidelines
48
+ *
49
+ * `Progress` component accepts the standard accessibility properties, however it's more important to make sure
50
+ * its children (instances of `ProgressBar`) receive the accessibility properties specific to the `progressbar`
51
+ * role.
52
+ *
53
+ */
54
+
55
+
56
+ const Progress = /*#__PURE__*/forwardRef((_ref2, ref) => {
57
+ let {
58
+ children,
59
+ tokens,
60
+ variant,
61
+ ...rest
62
+ } = _ref2;
63
+ const themeTokens = useThemeTokens('Progress', tokens, variant);
64
+ return /*#__PURE__*/_jsx(View, {
65
+ ref: ref,
66
+ style: selectProgressStyles(themeTokens),
67
+ ...selectProps(rest),
68
+ children: children
69
+ });
70
+ });
71
+ Progress.displayName = 'Progress';
72
+ Progress.propTypes = { ...selectedSystemPropTypes,
73
+
74
+ /**
75
+ * Use the `children` prop to supply one or several `ProgressBar`s.
76
+ */
77
+ children: PropTypes.node.isRequired,
78
+
79
+ /**
80
+ * Progress tokens.
81
+ */
82
+ tokens: getTokensPropType('Progress'),
83
+
84
+ /**
85
+ * Progress variant.
86
+ */
87
+ variant: variantProp.propType
88
+ };
89
+ export default Progress;
@@ -0,0 +1,138 @@
1
+ import React, { forwardRef } 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 ProgressBarBackground from './ProgressBarBackground';
7
+ import { useThemeTokens } from '../ThemeProvider';
8
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
11
+
12
+ const selectBarStyles = (_ref, percentage) => {
13
+ let {
14
+ backgroundColor,
15
+ borderRadius,
16
+ outlineWidth,
17
+ outlineColor
18
+ } = _ref;
19
+ return {
20
+ backgroundColor,
21
+ borderRadius,
22
+ outlineWidth,
23
+ outlineColor,
24
+ width: "".concat(percentage, "%")
25
+ };
26
+ };
27
+ /**
28
+ * The `ProgressBar` is a visual representation of linear progression.
29
+ * It provides simple but important information at a quick glance.
30
+ *
31
+ * ## Props
32
+ *
33
+ * - Use `percentage` prop to indicate completion
34
+ *
35
+ * ## Tokens
36
+ *
37
+ * - Use the following tokens to customize the appearance:
38
+ * - `backgroundColor` for the background color of the progress bar,
39
+ * - `borderRadius` for the rounded corners,
40
+ * - `outlineColor` to control the color of the border (outline),
41
+ * - `outlineWidth` to change the outline width.
42
+ *
43
+ * ## Variants
44
+ *
45
+ * - Use the following variants to render specific types of progress bars:
46
+ * - `negative`: set to `true` if you wish to use the negative theming for progress bar filling,
47
+ * - `inactive`: set to `true` if you wish to style the progress bar as inactive.
48
+ *
49
+ * ## Usability and A11y guidelines
50
+ *
51
+ * `ProgressBar` component accepts all the standard accessibility properties including the ones that
52
+ * are specific to the `progressbar` role. By default the following props are used:
53
+ *
54
+ * - `accessibilityRole` (`role`): `progressbar`,
55
+ * - `accessibilityValue.min` (`aria-valuemin`): `0`,
56
+ * - `accessibilityValue.max` (`aria-valuemax`): `100`,
57
+ * - `accessibilityValue.now` (`aria-valuenow`): `percentage`,
58
+ * - `accessibilityValue.text` (`aria-valuetext`): `%{percentage}%`,
59
+ *
60
+ */
61
+
62
+
63
+ const ProgressBar = /*#__PURE__*/forwardRef((_ref2, ref) => {
64
+ let {
65
+ children = null,
66
+ percentage = 0,
67
+ tokens,
68
+ variant,
69
+ ...rest
70
+ } = _ref2;
71
+ const themeTokens = useThemeTokens('ProgressBar', tokens, variant);
72
+
73
+ if (percentage < 0) {
74
+ throw new Error('ProgressBar: `percentage` must be a positive number');
75
+ } else if (percentage > 100) {
76
+ throw new Error('ProgressBar: `percentage` cannot exceed 100');
77
+ }
78
+
79
+ const selectedProps = selectProps({
80
+ accessibilityRole: 'progressbar',
81
+ accessibilityValue: {
82
+ min: 0,
83
+ max: 100,
84
+ now: percentage,
85
+ text: "".concat(percentage, "%")
86
+ },
87
+ ...rest
88
+ });
89
+ return percentage > 0 ? /*#__PURE__*/_jsx(View, {
90
+ ref: ref,
91
+ style: [staticStyles.bar, selectBarStyles(themeTokens, percentage)],
92
+ ...selectedProps,
93
+ children: children !== null && children !== void 0 ? children : /*#__PURE__*/_jsx(ProgressBarBackground, {
94
+ variant: variant
95
+ })
96
+ }) : null;
97
+ });
98
+ ProgressBar.displayName = 'ProgressBar';
99
+ ProgressBar.propTypes = { ...selectedSystemPropTypes,
100
+
101
+ /**
102
+ * Optional children that can be used to customize the progress bar filling.
103
+ */
104
+ children: PropTypes.node,
105
+
106
+ /**
107
+ * Accessibility label for the progress bar.
108
+ */
109
+ accessibilityLabel: PropTypes.string.isRequired,
110
+
111
+ /**
112
+ * Percentage of completion.
113
+ */
114
+ percentage: PropTypes.number,
115
+
116
+ /**
117
+ * Progress bar tokens.
118
+ */
119
+ tokens: getTokensPropType('ProgressBar'),
120
+
121
+ /**
122
+ * Progress bar variant.
123
+ */
124
+ variant: variantProp.propType
125
+ };
126
+ export default ProgressBar;
127
+ const staticStyles = StyleSheet.create({
128
+ bar: {
129
+ height: '100%',
130
+ overflow: 'hidden',
131
+ position: 'absolute',
132
+ ...Platform.select({
133
+ web: {
134
+ outlineStyle: 'solid'
135
+ }
136
+ })
137
+ }
138
+ });
@@ -0,0 +1,42 @@
1
+ import React, { forwardRef } from 'react';
2
+ import ImageBackground from "react-native-web/dist/exports/ImageBackground";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import { variantProp } from '../utils';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const inactiveBackground = "%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='DisabledProgress7' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23B2B9BF'%3E%3C/rect%3E%3Ccircle cx='4' cy='4' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url(&quot;%23DisabledProgress7&quot;);'%3E%3C/path%3E%3C/svg%3E";
7
+ const negativeBackground = "%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='NegativeProgress6' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23C12335'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='2' shape-rendering='auto' stroke='%23e7adb4' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url(&quot;%23NegativeProgress6&quot;);'%3E%3C/path%3E%3C/svg%3E";
8
+ const ProgressBarBackground = /*#__PURE__*/forwardRef((_ref, ref) => {
9
+ let {
10
+ variant
11
+ } = _ref;
12
+ let source = null;
13
+
14
+ if (variant !== null && variant !== void 0 && variant.inactive) {
15
+ source = inactiveBackground;
16
+ } else if (variant !== null && variant !== void 0 && variant.negative) {
17
+ source = negativeBackground;
18
+ } else {
19
+ return null;
20
+ }
21
+
22
+ return /*#__PURE__*/_jsx(ImageBackground, {
23
+ ref: ref,
24
+ source: {
25
+ uri: "data:image/svg+xml,".concat(source)
26
+ },
27
+ style: staticStyles.imageBackground
28
+ });
29
+ });
30
+ ProgressBarBackground.displayName = 'ProgressBarBackground';
31
+ ProgressBarBackground.propTypes = {
32
+ /**
33
+ * Progress bar variant.
34
+ */
35
+ variant: variantProp.propType
36
+ };
37
+ export default ProgressBarBackground;
38
+ const staticStyles = StyleSheet.create({
39
+ imageBackground: {
40
+ height: '100%'
41
+ }
42
+ });
@@ -0,0 +1,4 @@
1
+ import Progress from './Progress';
2
+ import ProgressBar from './ProgressBar';
3
+ Progress.Bar = ProgressBar;
4
+ export default Progress;