@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,56 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import View from "react-native-web/dist/exports/View";
5
+ import PropTypes from 'prop-types';
6
+ import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
9
+ /**
10
+ * A11yText is a zero-size invisible element that adds text to be read by screen readers.
11
+ *
12
+ * It should be used to add selectable screen-reader-only text to the main document flow,
13
+ * as a sibling to blocks of text like paragraphs and interactive elements like buttons.
14
+ */
15
+
16
+ const A11yText = /*#__PURE__*/forwardRef((_ref, ref) => {
17
+ let {
18
+ text,
19
+ heading,
20
+ ...rest
21
+ } = _ref;
22
+ const selectedProps = selectProps({
23
+ // On iOS, needs `accessible` to be true to be focusable without non-a11y content.
24
+ // On Web, `accessible` causes RNW to set attributes that may make the element be treated as a group.
25
+ // On Android, may cause this to be skipped when with `<Text>` siblings in an `accessible` View,
26
+ // see https://github.com/facebook/react-native/issues/30851#issuecomment-790165489
27
+ accessible: Platform.OS === 'ios',
28
+ accessibilityLabel: text,
29
+ accessibilityRole: heading ? 'header' : 'text',
30
+ ...rest
31
+ });
32
+ return /*#__PURE__*/_jsx(View, {
33
+ style: styles.invisible,
34
+ ref: ref,
35
+ ...selectedProps
36
+ });
37
+ });
38
+ A11yText.displayName = 'A11yText';
39
+ A11yText.propTypes = { ...selectedSystemPropTypes,
40
+ text: PropTypes.string.isRequired,
41
+ heading: PropTypes.bool
42
+ };
43
+ const styles = StyleSheet.create({
44
+ invisible: {
45
+ // Without width or height it is not shown
46
+ minHeight: 1,
47
+ minWidth: 1,
48
+ // Ensures it doesn't occupy space
49
+ // position: 'absolute' causes it to be read first in its container
50
+ marginEnd: -1,
51
+ marginBottom: -1,
52
+ // Ensures it is in the correct position on Native
53
+ top: -1
54
+ }
55
+ });
56
+ export default A11yText;
@@ -0,0 +1,77 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { DURATION, MIN_EMPTY_ANGLE, MIN_STROKE_ANGLE, BEZIER, propTypes } from './shared';
3
+ import { useA11yInfo } from '../A11yInfoProvider';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ const SVG_RADIUS = 20;
8
+ const SVG_CIRCUMFERENCE = SVG_RADIUS * 2 * Math.PI;
9
+ const MIN_SVG_LENGTH = MIN_STROKE_ANGLE / 360 * SVG_CIRCUMFERENCE;
10
+ const MAX_SVG_LENGTH = (1 - MIN_EMPTY_ANGLE / 360) * SVG_CIRCUMFERENCE;
11
+ const animationProps = {
12
+ begin: '0s',
13
+ dur: "".concat(DURATION, "ms"),
14
+ fill: 'freeze',
15
+ repeatCount: 'indefinite'
16
+ };
17
+ const bezierProps = {
18
+ calcMode: 'spline',
19
+ keyTimes: '0; 0.5; 1',
20
+ keySplines: "".concat(BEZIER.join(', '), " ; ").concat(BEZIER.join(', '))
21
+ }; // We're using svg rather than css here to define the animation to avoid needing to introduce css injection mechanism
22
+ // It's possible to replicate this functionality with RNW animations, but it snags on chrome at least, see https://github.com/telus/universal-design-system/pull/477 for details.
23
+
24
+ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
25
+ let {
26
+ size,
27
+ color,
28
+ thickness,
29
+ label
30
+ } = _ref;
31
+ const {
32
+ reduceMotionEnabled
33
+ } = useA11yInfo();
34
+ return /*#__PURE__*/_jsx("svg", {
35
+ ref: ref,
36
+ width: "".concat(size, "px"),
37
+ height: "".concat(size, "px"),
38
+ viewBox: "0 0 48 48",
39
+ "aria-valuetext": label,
40
+ role: "progressbar",
41
+ "aria-busy": true,
42
+ children: /*#__PURE__*/_jsxs("g", {
43
+ children: [reduceMotionEnabled ? null : /*#__PURE__*/_jsx("animateTransform", {
44
+ attributeName: "transform",
45
+ type: "rotate",
46
+ values: "-180 24 24;".concat(360 + MIN_STROKE_ANGLE - 180, " 24 24"),
47
+ ...animationProps
48
+ }), /*#__PURE__*/_jsx("circle", {
49
+ fill: "none",
50
+ stroke: color,
51
+ strokeWidth: thickness * 48 / size,
52
+ strokeLinecap: "round",
53
+ cx: "24",
54
+ cy: "24",
55
+ r: "20",
56
+ strokeDasharray: reduceMotionEnabled ? MAX_SVG_LENGTH : [MIN_SVG_LENGTH, SVG_CIRCUMFERENCE],
57
+ strokeDashoffset: 0,
58
+ children: reduceMotionEnabled ? null : /*#__PURE__*/_jsxs(_Fragment, {
59
+ children: [/*#__PURE__*/_jsx("animate", {
60
+ attributeName: "stroke-dashoffset",
61
+ values: "0;-10;".concat(MIN_SVG_LENGTH - SVG_CIRCUMFERENCE),
62
+ ...animationProps,
63
+ ...bezierProps
64
+ }), /*#__PURE__*/_jsx("animate", {
65
+ attributeName: "stroke-dasharray",
66
+ values: "".concat(MIN_SVG_LENGTH, ", 200;").concat(MAX_SVG_LENGTH, ", 200;").concat(MIN_SVG_LENGTH, ", 200"),
67
+ ...animationProps,
68
+ ...bezierProps
69
+ })]
70
+ })
71
+ })]
72
+ })
73
+ });
74
+ });
75
+ Spinner.displayName = 'Spinner';
76
+ Spinner.propTypes = propTypes;
77
+ export default Spinner;
@@ -0,0 +1,144 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Animated from "react-native-web/dist/exports/Animated";
3
+ import Easing from "react-native-web/dist/exports/Easing";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import { DURATION, MIN_EMPTY_ANGLE, MIN_STROKE_ANGLE, BEZIER, propTypes } from './shared';
7
+ import { useA11yInfo } from '../A11yInfoProvider';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const ea = MIN_EMPTY_ANGLE / 2;
10
+ const sa = MIN_STROKE_ANGLE / 2;
11
+ const Spinner = /*#__PURE__*/forwardRef((_ref, ref) => {
12
+ let {
13
+ size,
14
+ color,
15
+ thickness,
16
+ label
17
+ } = _ref;
18
+ const {
19
+ current: timer
20
+ } = React.useRef(new Animated.Value(0));
21
+ const {
22
+ reduceMotionEnabled
23
+ } = useA11yInfo();
24
+ React.useLayoutEffect(() => {
25
+ const loop = Animated.timing(timer, {
26
+ duration: DURATION,
27
+ easing: Easing.linear,
28
+ // Animated.loop does not work if useNativeDriver is true on web
29
+ useNativeDriver: true,
30
+ toValue: 1,
31
+ isInteraction: false
32
+ });
33
+ if (!reduceMotionEnabled) Animated.loop(loop).start();else loop.stop();
34
+ }, [timer, reduceMotionEnabled]);
35
+ const frames = 60 * DURATION / 1000;
36
+ const easing = Easing.bezier(...BEZIER);
37
+ const containerStyle = {
38
+ width: size,
39
+ height: size / (reduceMotionEnabled ? 1.5 : 2),
40
+ overflow: 'hidden'
41
+ };
42
+ const animationFrequency = reduceMotionEnabled ? [0] : [0, 1]; // Credit to https://github.com/n4kz/react-native-indicators and https://github.com/callstack/react-native-paper for this
43
+
44
+ return /*#__PURE__*/_jsx(View, {
45
+ ref: ref,
46
+ style: [styles.container],
47
+ accessible: true,
48
+ accessibilityLabel: label,
49
+ accessibilityRole: "progressbar",
50
+ accessibilityState: {
51
+ busy: true
52
+ },
53
+ children: /*#__PURE__*/_jsx(Animated.View, {
54
+ style: [{
55
+ width: size,
56
+ height: size
57
+ }],
58
+ collapsable: false,
59
+ children: animationFrequency.map(index => {
60
+ const inputRange = Array.from(new Array(frames), (_, frameIndex) => frameIndex / (frames - 1));
61
+ const outputRange = Array.from(new Array(frames), (_, frameIndex) => {
62
+ let progress = 2 * frameIndex / (frames - 1);
63
+ const rotation = index ? +(360 - sa) : -(180 - sa);
64
+
65
+ if (progress > 1.0) {
66
+ progress = 2.0 - progress;
67
+ }
68
+
69
+ const direction = index ? -1 : +1;
70
+ return "".concat(direction * (180 - (sa + ea)) * easing(progress) + rotation, "deg");
71
+ });
72
+ const layerStyle = {
73
+ width: size,
74
+ height: size
75
+ };
76
+ const viewportStyle = {
77
+ width: size,
78
+ height: size
79
+ };
80
+
81
+ if (!reduceMotionEnabled) {
82
+ layerStyle.transform = [{
83
+ rotate: timer.interpolate({
84
+ inputRange: [0, 1],
85
+ outputRange: ["".concat(0 + ea + sa, "deg"), "".concat(2 * 360 + ea + sa, "deg")]
86
+ })
87
+ }];
88
+ viewportStyle.transform = [{
89
+ translateY: index ? -size / 2 : 0
90
+ }, {
91
+ rotate: timer.interpolate({
92
+ inputRange,
93
+ outputRange
94
+ })
95
+ }];
96
+ }
97
+
98
+ const offsetStyle = index ? {
99
+ top: size / 2
100
+ } : null;
101
+ const lineStyle = {
102
+ width: size,
103
+ height: size,
104
+ borderColor: color,
105
+ borderWidth: thickness,
106
+ borderRadius: size / 2
107
+ };
108
+ return /*#__PURE__*/_jsx(Animated.View, {
109
+ style: [styles.layer],
110
+ children: /*#__PURE__*/_jsx(Animated.View, {
111
+ style: layerStyle,
112
+ children: /*#__PURE__*/_jsx(Animated.View, {
113
+ style: [containerStyle, offsetStyle],
114
+ collapsable: false,
115
+ children: /*#__PURE__*/_jsx(Animated.View, {
116
+ style: viewportStyle,
117
+ children: /*#__PURE__*/_jsx(Animated.View, {
118
+ style: containerStyle,
119
+ collapsable: false,
120
+ children: /*#__PURE__*/_jsx(Animated.View, {
121
+ style: lineStyle
122
+ })
123
+ })
124
+ })
125
+ })
126
+ })
127
+ }, index);
128
+ })
129
+ })
130
+ });
131
+ });
132
+ Spinner.displayName = 'Spinner';
133
+ Spinner.propTypes = propTypes;
134
+ const styles = StyleSheet.create({
135
+ container: {
136
+ flexGrow: 0,
137
+ flexShrink: 0
138
+ },
139
+ layer: { ...StyleSheet.absoluteFillObject,
140
+ justifyContent: 'center',
141
+ alignItems: 'center'
142
+ }
143
+ });
144
+ export default Spinner;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useThemeTokens } from '../ThemeProvider';
4
+ import { getTokensPropType, variantProp } from '../utils/props';
5
+ import Spinner from './Spinner';
6
+ /**
7
+ * `ActivityIndicator` renders a visual loading state.
8
+ * It does not handle positioning or layout of that visual loader.
9
+ */
10
+
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+
13
+ const ActivityIndicator = _ref => {
14
+ let {
15
+ variant,
16
+ tokens,
17
+ label
18
+ } = _ref;
19
+ const {
20
+ size,
21
+ color,
22
+ thickness
23
+ } = useThemeTokens('ActivityIndicator', tokens, variant);
24
+ return /*#__PURE__*/_jsx(Spinner, {
25
+ size: size,
26
+ color: color,
27
+ thickness: thickness,
28
+ label: label
29
+ });
30
+ };
31
+
32
+ ActivityIndicator.propTypes = {
33
+ variant: variantProp.propType,
34
+ tokens: getTokensPropType('ActivityIndicator'),
35
+
36
+ /**
37
+ * A visually hidden accessible label describing the action taking place
38
+ */
39
+ label: PropTypes.string.isRequired
40
+ };
41
+ export default ActivityIndicator;
@@ -0,0 +1,12 @@
1
+ import PropTypes from 'prop-types'; // these could be specified by the theme
2
+
3
+ export const DURATION = 1800;
4
+ export const MIN_EMPTY_ANGLE = 60;
5
+ export const MIN_STROKE_ANGLE = 30;
6
+ export const BEZIER = [0.42, 0.0, 0.58, 1.0];
7
+ export const propTypes = {
8
+ color: PropTypes.string.isRequired,
9
+ label: PropTypes.string.isRequired,
10
+ size: PropTypes.number.isRequired,
11
+ thickness: PropTypes.number.isRequired
12
+ };
@@ -0,0 +1,29 @@
1
+ var _ThemeProvider$propTy;
2
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import A11yInfoProvider from '../A11yInfoProvider';
6
+ import ViewportProvider from '../ViewportProvider';
7
+ import ThemeProvider from '../ThemeProvider';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+
10
+ const BaseProvider = _ref => {
11
+ let {
12
+ defaultTheme,
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/_jsx(A11yInfoProvider, {
16
+ children: /*#__PURE__*/_jsx(ViewportProvider, {
17
+ children: /*#__PURE__*/_jsx(ThemeProvider, {
18
+ defaultTheme: defaultTheme,
19
+ children: children
20
+ })
21
+ })
22
+ });
23
+ };
24
+
25
+ BaseProvider.propTypes = {
26
+ defaultTheme: (_ThemeProvider$propTy = ThemeProvider.propTypes) === null || _ThemeProvider$propTy === void 0 ? void 0 : _ThemeProvider$propTy.defaultTheme,
27
+ children: PropTypes.node.isRequired
28
+ };
29
+ export default BaseProvider;
@@ -0,0 +1,244 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import ScrollView from "react-native-web/dist/exports/ScrollView";
5
+ import { useThemeTokens } from '../ThemeProvider';
6
+ import { a11yProps, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, selectSystemProps, spacingProps, useSpacingScale, variantProp, viewProps } from '../utils';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
9
+ /**
10
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
11
+ * @typedef {import('../utils/props/spacingProps.js').SpacingIndex} SpacingIndex
12
+ * @typedef {import('../utils/props/spacingProps.js').SpacingObject} SpacingObject
13
+ * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
14
+ */
15
+
16
+ const selectBoxStyles = tokens => {
17
+ const styles = {
18
+ backgroundColor: tokens.backgroundColor
19
+ };
20
+ const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']; // Only set on styles if token provided because we spread this object after the spacing scale values
21
+
22
+ paddings.forEach(side => {
23
+ if (tokens[side]) {
24
+ styles[side] = tokens[side];
25
+ }
26
+ });
27
+ return styles;
28
+ };
29
+ /**
30
+ * A layout utility component. Use Box to create space (padding) around content.
31
+ *
32
+ * ## Spacing
33
+ *
34
+ * For most simple uses, pass a number to Box's `space` prop referring to an index in the theme's
35
+ * spacing scale. For example, for a box with the theme's smallest non-zero amount of padding on all sides:
36
+ *
37
+ * ```jsx
38
+ * <Box space={1}>
39
+ * ```
40
+ *
41
+ * #### Targetting specific sides
42
+ *
43
+ * Box allows spacing value props to be assigned to any side or all sides using the following props:
44
+ *
45
+ * - `space` sets the default for all sides, which is overridden by other props below
46
+ * - `horizontal` sets defaults for `left` and `right` (overriding `space` there if it is set)
47
+ * - `vertical` sets defaults for `top` and `bottom` (overriding `space` there if it is set)
48
+ * - `left` sets the left side padding, inside the box's bounds
49
+ * - `right` sets the right side padding, inside the box's bounds
50
+ * - `top` sets the top side padding, inside the box's bounds
51
+ * - `bottom` sets the bottom side padding, inside the box's bounds
52
+ *
53
+ * Box only controls spacing within its bounds. If space is needed around a box outside of its bounds,
54
+ * use `Spacer`, `StackView` or wrap the `Box` inside another `Box`.
55
+ *
56
+ * #### Viewport-specific spacing
57
+ *
58
+ * Responsive behaviours may be set by passing any of the above props an object keyed by viewports.
59
+ *
60
+ * For example, if a theme's spacing scale is [0, 4, 8...], this below will have padding of 4px on top,
61
+ * bottom, and right, and its left padding will be 0px on xs, sm and md viewports and 8px on lg and xl viewports:
62
+ *
63
+ * ```jsx
64
+ * <Box space={1} left={{ xs: 0, lg: 2 }} />`
65
+ * ```
66
+ *
67
+ * #### Subtracting from spacing
68
+ *
69
+ * A parent may sometimes need to reduce the spacing size on one or more sides of a `Box` by some variable.
70
+ * For example, the parent may have a border on one side and want to reduce the spacing of a child box
71
+ * by the width of that border on that side. This can be achieved using the `subtract` option of the
72
+ * spacing object, for example:
73
+ *
74
+ * ```jsx
75
+ * <Box space={2} left={{ space: 2, options: { subtract: themeTokens.borderWidthLeft } }} />`
76
+ * ```
77
+ *
78
+ * See `useSpacingScale` hook for other spacing value options and documentation.
79
+ *
80
+ * ## Theming
81
+ *
82
+ * Box is intended for layout, so minimal theming is supported. Use components like `Card` for
83
+ * more sophisticated theming.
84
+ *
85
+ * ## Scroll
86
+ *
87
+ * If passed, the box will be scrollable. If an object is passed, it will be passed to React Native's
88
+ * `ScrollView` component as props.
89
+ *
90
+ * When building native iOS and Android apps, it is important to remember to ensure any screen containing
91
+ * text content is inside a scrollable box, as screens are not scrollable by default and even very
92
+ * short text will require scrolling on small devices at the highest accessibility text scaling settings.
93
+ */
94
+
95
+
96
+ const Box = /*#__PURE__*/forwardRef((_ref, ref) => {
97
+ let {
98
+ space,
99
+ horizontal = space,
100
+ vertical = space,
101
+ top = vertical,
102
+ bottom = vertical,
103
+ left = horizontal,
104
+ right = horizontal,
105
+ flex,
106
+ children,
107
+ variant,
108
+ tokens,
109
+ scroll,
110
+ tag,
111
+ accessibilityRole,
112
+ testID,
113
+ dataSet,
114
+ ...rest
115
+ } = _ref;
116
+ const props = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
117
+ ...selectProps(rest)
118
+ };
119
+ const themeTokens = useThemeTokens('Box', tokens, variant);
120
+ const styles = {
121
+ flex,
122
+ paddingLeft: useSpacingScale(left),
123
+ paddingRight: useSpacingScale(right),
124
+ paddingTop: useSpacingScale(top),
125
+ paddingBottom: useSpacingScale(bottom),
126
+ ...selectBoxStyles(themeTokens)
127
+ };
128
+
129
+ if (scroll) {
130
+ const scrollProps = typeof scroll === 'object' ? scroll : {};
131
+ scrollProps.contentContainerStyle = [styles, scrollProps.contentContainerStyle];
132
+ return /*#__PURE__*/_jsx(ScrollView, { ...scrollProps,
133
+ ...props,
134
+ testID: testID,
135
+ dataSet: dataSet,
136
+ ref: ref,
137
+ children: children
138
+ });
139
+ }
140
+
141
+ return /*#__PURE__*/_jsx(View, { ...props,
142
+ style: styles,
143
+ testID: testID,
144
+ dataSet: dataSet,
145
+ ref: ref,
146
+ children: children
147
+ });
148
+ });
149
+ Box.displayName = 'Box';
150
+ Box.propTypes = { ...selectedSystemPropTypes,
151
+ variant: variantProp.propType,
152
+ tokens: getTokensPropType('Box'),
153
+
154
+ /**
155
+ * Sets default padding on all sides of the box using the theme's spacing scale.
156
+ *
157
+ * @see {@link SpacingValue}
158
+ */
159
+ space: spacingProps.types.spacingValue,
160
+
161
+ /**
162
+ * Sets top and bottom padding using the theme's spacing scale.
163
+ *
164
+ * @see {@link SpacingValue}
165
+ */
166
+ vertical: spacingProps.types.spacingValue,
167
+
168
+ /**
169
+ * Sets left and right padding using the theme's spacing scale.
170
+ *
171
+ * @see {@link SpacingValue}
172
+ */
173
+ horizontal: spacingProps.types.spacingValue,
174
+
175
+ /**
176
+ * Sets bottom padding using the theme's spacing scale.
177
+ *
178
+ * @see {@link SpacingValue}
179
+ */
180
+ bottom: spacingProps.types.spacingValue,
181
+
182
+ /**
183
+ * Sets left padding using the theme's spacing scale.
184
+ *
185
+ * @see {@link SpacingValue}
186
+ */
187
+ left: spacingProps.types.spacingValue,
188
+
189
+ /**
190
+ * Sets right padding using the theme's spacing scale.
191
+ *
192
+ * @see {@link SpacingValue}
193
+ */
194
+ right: spacingProps.types.spacingValue,
195
+
196
+ /**
197
+ * Sets top padding using the theme's spacing scale.
198
+ *
199
+ * @see {@link SpacingValue}
200
+ */
201
+ top: spacingProps.types.spacingValue,
202
+
203
+ /**
204
+ * Sets the `flex` style, which controls `flexGrow`, `flexShrink` and `flexBasis` styles.
205
+ *
206
+ * Set as 1 for the box to stretch and grow to fit in the available space, or another number to share
207
+ * space disproportionately with siblings. See https://reactnative.dev/docs/flexbox#flex for details.
208
+ *
209
+ * With the default `0`, the box takes its minimum width from its content.
210
+ */
211
+ flex: PropTypes.number,
212
+
213
+ /**
214
+ * Renders a scrollable ScrollView instead of an unscrollable View.
215
+ *
216
+ * May take an object of ScrollView props which are passed to the rendered ScrollView.
217
+ */
218
+ scroll: PropTypes.oneOfType([PropTypes.bool, ScrollView.propTypes ? PropTypes.shape(ScrollView.propTypes) : PropTypes.object]),
219
+
220
+ /**
221
+ * Optional semantic HTML tag, to apply to the container on web. Does not change styling.
222
+ *
223
+ * In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
224
+ * is not defined, the accessibilityRole will default to "heading".
225
+ */
226
+ tag: PropTypes.oneOf(layoutTags),
227
+
228
+ /**
229
+ * Use in tests if the box itself needs to be targetted and no other way of selecting the
230
+ * box is available (e.g. it cannot be targetted using an appropriate `accessibilityRole`).
231
+ */
232
+ testID: PropTypes.string,
233
+
234
+ /**
235
+ * @ignore
236
+ */
237
+ dataSet: PropTypes.object,
238
+
239
+ /**
240
+ * Box accepts any content as children.
241
+ */
242
+ children: PropTypes.node.isRequired
243
+ };
244
+ export default Box;
@@ -0,0 +1,2 @@
1
+ import Box from './Box';
2
+ export default Box;
@@ -0,0 +1,26 @@
1
+ import React, { forwardRef } from 'react';
2
+ import ButtonBase from './ButtonBase';
3
+ import buttonPropTypes, { textAndA11yText } from './propTypes';
4
+ import { useThemeTokensCallback } from '../ThemeProvider';
5
+ import { a11yProps } from '../utils/props';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const Button = /*#__PURE__*/forwardRef((_ref, ref) => {
8
+ let {
9
+ accessibilityRole = 'button',
10
+ tokens,
11
+ variant,
12
+ ...props
13
+ } = _ref;
14
+ const getTokens = useThemeTokensCallback('Button', tokens, variant);
15
+ return /*#__PURE__*/_jsx(ButtonBase, { ...props,
16
+ tokens: getTokens,
17
+ accessibilityRole: accessibilityRole,
18
+ ref: ref
19
+ });
20
+ });
21
+ Button.displayName = 'Button';
22
+ Button.propTypes = { ...a11yProps.types,
23
+ ...buttonPropTypes,
24
+ children: textAndA11yText
25
+ };
26
+ export default Button;