@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,66 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import { applyShadowToken } from '../ThemeProvider';
5
+ import { getTokensPropType } from '../utils';
6
+ import { a11yProps, viewProps, selectSystemProps } from '../utils/props';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]); // Ensure explicit selection of tokens
9
+
10
+ const selectStyles = _ref => {
11
+ let {
12
+ flex,
13
+ backgroundColor,
14
+ borderColor,
15
+ borderRadius,
16
+ borderWidth,
17
+ paddingBottom,
18
+ paddingLeft,
19
+ paddingRight,
20
+ paddingTop,
21
+ minWidth,
22
+ shadow
23
+ } = _ref;
24
+ return {
25
+ flex,
26
+ backgroundColor,
27
+ borderColor,
28
+ borderRadius,
29
+ borderWidth,
30
+ paddingBottom,
31
+ paddingLeft,
32
+ paddingRight,
33
+ paddingTop,
34
+ minWidth,
35
+ ...applyShadowToken(shadow)
36
+ };
37
+ };
38
+ /**
39
+ * A themeless base component for Card which components can apply theme tokens to. Not
40
+ * intended to be used in apps or sites directly: build themed components on top of this.
41
+ */
42
+
43
+
44
+ const CardBase = /*#__PURE__*/forwardRef((_ref2, ref) => {
45
+ let {
46
+ children,
47
+ tokens,
48
+ dataSet,
49
+ ...rest
50
+ } = _ref2;
51
+ const cardStyle = selectStyles(typeof tokens === 'function' ? tokens() : tokens);
52
+ const props = selectProps(rest);
53
+ return /*#__PURE__*/_jsx(View, {
54
+ style: cardStyle,
55
+ dataSet: dataSet,
56
+ ref: ref,
57
+ ...props,
58
+ children: children
59
+ });
60
+ });
61
+ CardBase.displayName = 'CardBase';
62
+ CardBase.propTypes = { ...selectedSystemPropTypes,
63
+ children: PropTypes.node,
64
+ tokens: getTokensPropType('Card')
65
+ };
66
+ export default CardBase;
@@ -0,0 +1,114 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Pressable from "react-native-web/dist/exports/Pressable";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import { useViewport } from '../ViewportProvider';
6
+ import { applyOuterBorder, validateThemeTokens } from '../ThemeProvider';
7
+ import { a11yProps, clickProps, focusHandlerProps, getTokenNames, getTokensSetPropType, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
8
+ import CardBase from './CardBase';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
11
+ const tokenKeys = [...getTokenNames('Card'), // Outer border tokens. TODO: centralise common token sets like these as part of
12
+ // https://github.com/telus/universal-design-system/issues/782
13
+ 'outerBorderColor', 'outerBorderWidth', 'outerBorderGap'];
14
+ export const selectPressableCardTokens = tokens => Object.fromEntries(tokenKeys.map(key => [key, tokens[key]]));
15
+ /**
16
+ * A pressable themeless base component that handles pressable states and passes tokens
17
+ * based on these to an outer border and a base Card component. Not intended to be used in
18
+ * apps or sites directly: build themed components on top of this.
19
+ */
20
+
21
+ const PressableCardBase = /*#__PURE__*/forwardRef((_ref, ref) => {
22
+ let {
23
+ children,
24
+ tokens,
25
+ checked,
26
+ validation,
27
+ inactive,
28
+ href,
29
+ hrefAttrs,
30
+ accessibilityRole = href ? 'link' : undefined,
31
+ ...rawRest
32
+ } = _ref;
33
+ const {
34
+ onPress,
35
+ ...rest
36
+ } = clickProps.toPressProps(rawRest);
37
+ const viewport = useViewport();
38
+ const additionalState = {
39
+ checked,
40
+ validation,
41
+ inactive,
42
+ viewport
43
+ };
44
+
45
+ const getCardState = pressableState => resolvePressableState(pressableState, additionalState);
46
+
47
+ const getTokens = pressableState => validateThemeTokens(resolvePressableTokens(tokens, pressableState, additionalState), getTokensSetPropType(tokenKeys, {
48
+ requireAll: true
49
+ }), 'PressableCard');
50
+
51
+ const getCardTokens = pressableState => selectTokens('Card', getTokens(pressableState));
52
+
53
+ const getOuterBorderStyle = pressableState => {
54
+ const {
55
+ flex,
56
+ minWidth,
57
+ outerBorderColor,
58
+ outerBorderGap = 0,
59
+ outerBorderWidth = 0,
60
+ borderRadius
61
+ } = getTokens(pressableState);
62
+ return {
63
+ flex,
64
+ minWidth: minWidth + outerBorderGap + outerBorderWidth,
65
+ ...applyOuterBorder({
66
+ outerBorderColor,
67
+ outerBorderGap,
68
+ outerBorderWidth,
69
+ borderRadius
70
+ }),
71
+ ...Platform.select({
72
+ web: {
73
+ outline: 'none'
74
+ }
75
+ })
76
+ };
77
+ };
78
+
79
+ const handleChange = linkProps.handleHref({
80
+ href,
81
+ onPress
82
+ });
83
+
84
+ const handleKeyDown = event => {
85
+ // The expected keyboard shortcut for selecting a focused item is the Space key
86
+ if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
87
+ };
88
+
89
+ return /*#__PURE__*/_jsx(Pressable, {
90
+ ref: ref,
91
+ href: href,
92
+ onPress: handleChange,
93
+ onKeyDown: handleKeyDown,
94
+ hrefAttrs: hrefAttrs,
95
+ style: getOuterBorderStyle,
96
+ ...selectProps({ ...rest,
97
+ accessibilityRole
98
+ }),
99
+ children: pressableState => /*#__PURE__*/_jsx(CardBase, {
100
+ tokens: getCardTokens(pressableState),
101
+ children: typeof children === 'function' ? children(getCardState(pressableState)) : children
102
+ })
103
+ });
104
+ });
105
+ PressableCardBase.displayName = 'PressableCardBase';
106
+ PressableCardBase.propTypes = { ...selectedSystemPropTypes,
107
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
108
+ tokens: getTokensSetPropType(tokenKeys, {
109
+ requireAll: true,
110
+ allowFunction: true
111
+ }),
112
+ variant: variantProp.propType
113
+ };
114
+ export default withLinkRouter(PressableCardBase);
@@ -0,0 +1,4 @@
1
+ import Card from './Card';
2
+ export default Card;
3
+ export { default as PressableCardBase } from './PressableCardBase';
4
+ export * from './PressableCardBase';
@@ -0,0 +1,348 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import Pressable from "react-native-web/dist/exports/Pressable";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import Text from "react-native-web/dist/exports/Text";
7
+ import View from "react-native-web/dist/exports/View";
8
+ import CheckboxInput from './CheckboxInput';
9
+ import CheckboxLabel from '../InputLabel/LabelContent';
10
+ import Feedback from '../Feedback';
11
+ import StackView from '../StackView';
12
+ import { applyShadowToken, applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
13
+ import { a11yProps, focusHandlerProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
14
+ import useUniqueId from '../utils/useUniqueId';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
18
+
19
+ const selectInputStyles = (_ref, isChecked) => {
20
+ let {
21
+ iconBackgroundColor,
22
+ inputBorderColor,
23
+ inputBorderRadius,
24
+ inputBorderWidth,
25
+ inputBackgroundColor,
26
+ inputHeight,
27
+ inputOutlineColor,
28
+ inputOutlineWidth,
29
+ inputShadow,
30
+ inputWidth
31
+ } = _ref;
32
+ return {
33
+ borderColor: inputBorderColor,
34
+ borderWidth: inputBorderWidth,
35
+ borderRadius: inputBorderRadius,
36
+ backgroundColor: isChecked ? iconBackgroundColor : inputBackgroundColor,
37
+ height: inputHeight,
38
+ width: inputWidth,
39
+ ...applyShadowToken(inputShadow),
40
+ ...Platform.select({
41
+ web: {
42
+ outlineStyle: 'solid',
43
+ outlineColor: inputOutlineColor,
44
+ outlineWidth: inputOutlineWidth
45
+ }
46
+ })
47
+ };
48
+ };
49
+
50
+ const selectLabelStyles = _ref2 => {
51
+ let {
52
+ labelColor,
53
+ labelFontName,
54
+ labelFontSize,
55
+ labelFontWeight,
56
+ labelMarginLeft,
57
+ labelLineHeight
58
+ } = _ref2;
59
+ return {
60
+ marginLeft: labelMarginLeft,
61
+ ...applyTextStyles({
62
+ color: labelColor,
63
+ fontName: labelFontName,
64
+ fontWeight: labelFontWeight,
65
+ fontSize: labelFontSize,
66
+ lineHeight: labelLineHeight
67
+ })
68
+ };
69
+ };
70
+
71
+ const selectIconTokens = _ref3 => {
72
+ let {
73
+ icon,
74
+ iconColor,
75
+ iconSize
76
+ } = _ref3;
77
+ return {
78
+ icon,
79
+ color: iconColor,
80
+ size: iconSize
81
+ };
82
+ };
83
+
84
+ const selectFeedbackTokens = _ref4 => {
85
+ let {
86
+ feedbackMarginBottom,
87
+ feedbackMarginTop,
88
+ feedbackPosition
89
+ } = _ref4;
90
+ return {
91
+ feedbackPosition,
92
+ feedbackMarginBottom,
93
+ feedbackMarginTop
94
+ };
95
+ };
96
+ /**
97
+ * Basic Checkbox component.
98
+ *
99
+ * ## Component API
100
+ *
101
+ * Use `label` prop to provide a label for the checkbox.
102
+ * For a disabled `Checkbox` set the `inactive` prop to `true`.
103
+ *
104
+ * ### Controlled version
105
+ *
106
+ * If the checkbox is controlled from outside, it needs to receive `checked` and `onChange` props.
107
+ *
108
+ * ### Uncontrolled version
109
+ *
110
+ * In case of uncontrolled checkbox you can use `defaultChecked` prop to provide the initial value.
111
+ * Whenever the checkbox gets toggled, it calls the `onChange` callback with the new value (boolean).
112
+ *
113
+ * ### Using within forms
114
+ *
115
+ * You can pass `name` and `value` props if you need a particular checkbox to be a part of a group of
116
+ * checkboxes on a form.
117
+ *
118
+ * ### Validation and feedback
119
+ *
120
+ * You can use the `feedback` prop to provide a comment related to the checkbox element. If the comment
121
+ * is related to a validation error, the checkbox and the feedback can be styled accordingly by setting
122
+ * the `error` prop to `true` (can also be done without feedback).
123
+ *
124
+ * ## A11y guidelines
125
+ *
126
+ * Checkbox component accepts all the common accessibility props, but also sets some defaults, including
127
+ * accessibility role `'checkbox'` and accessibility state that depends on the other props (`checked`, `inactive`)
128
+ * or the internal state in case of uncontrolled checkbox.
129
+ *
130
+ */
131
+
132
+
133
+ const Checkbox = /*#__PURE__*/forwardRef((_ref5, ref) => {
134
+ let {
135
+ checked,
136
+ defaultChecked,
137
+ error = false,
138
+ feedback,
139
+ id,
140
+ inactive,
141
+ label,
142
+ name,
143
+ onChange,
144
+ tokens,
145
+ value,
146
+ variant,
147
+ ...rest
148
+ } = _ref5;
149
+ const {
150
+ currentValue: isChecked,
151
+ setValue: setIsChecked,
152
+ isControlled
153
+ } = useInputValue({
154
+ value: checked,
155
+ initialValue: defaultChecked,
156
+ onChange
157
+ }, 'useCheckboxValue');
158
+ const getTokens = useThemeTokensCallback('Checkbox', tokens, {
159
+ checked: isChecked,
160
+ inactive,
161
+ error,
162
+ ...variant
163
+ });
164
+ const defaultTokens = getTokens();
165
+ const {
166
+ feedbackMarginBottom,
167
+ feedbackMarginTop,
168
+ feedbackPosition
169
+ } = selectFeedbackTokens(defaultTokens);
170
+ const styles = StyleSheet.create({
171
+ feedbackContainer: {
172
+ marginTop: feedbackMarginTop,
173
+ marginBottom: feedbackMarginBottom
174
+ }
175
+ });
176
+
177
+ const handleChange = event => {
178
+ if (!inactive) {
179
+ setIsChecked(!isChecked, event);
180
+ }
181
+ };
182
+
183
+ const handleKeyDown = event => {
184
+ // The expected keyboard shortcut for activating a checkbox is the Space key
185
+ if ((event === null || event === void 0 ? void 0 : event.key) === ' ') handleChange(event);
186
+ };
187
+
188
+ const uniqueId = useUniqueId('checkbox');
189
+ const inputId = id !== null && id !== void 0 ? id : uniqueId;
190
+ return /*#__PURE__*/_jsx(View, {
191
+ style: staticStyles.wrapper,
192
+ ref: ref,
193
+ children: /*#__PURE__*/_jsxs(StackView, {
194
+ direction: feedbackPosition === 'top' ? 'column-reverse' : 'column',
195
+ space: 0,
196
+ children: [/*#__PURE__*/_jsx(Pressable, {
197
+ disabled: inactive,
198
+ onKeyDown: handleKeyDown,
199
+ onPress: handleChange,
200
+ accessibilityRole: "checkbox",
201
+ accessibilityState: {
202
+ checked: isChecked,
203
+ disabled: inactive
204
+ },
205
+ ...selectProps(rest),
206
+ children: _ref6 => {
207
+ let {
208
+ focused: focus,
209
+ hovered: hover,
210
+ pressed
211
+ } = _ref6;
212
+ const {
213
+ icon: IconComponent,
214
+ ...stateTokens
215
+ } = getTokens({
216
+ focus,
217
+ hover,
218
+ pressed
219
+ });
220
+ const iconTokens = selectIconTokens(stateTokens);
221
+ const labelStyles = selectLabelStyles(stateTokens);
222
+ const alignWithLabel = label ? [staticStyles.alignWithLabel, {
223
+ height: labelStyles.lineHeight
224
+ }] : null;
225
+ return /*#__PURE__*/_jsxs(View, {
226
+ style: staticStyles.container,
227
+ children: [/*#__PURE__*/_jsx(View, {
228
+ style: alignWithLabel,
229
+ children: /*#__PURE__*/_jsxs(View, {
230
+ style: [staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)],
231
+ testID: "Checkbox-Input",
232
+ children: [/*#__PURE__*/_jsx(CheckboxInput, {
233
+ checked: isChecked,
234
+ defaultChecked: defaultChecked,
235
+ disabled: inactive,
236
+ id: inputId,
237
+ isControlled: isControlled,
238
+ name: name,
239
+ value: value
240
+ }), isChecked && IconComponent && /*#__PURE__*/_jsx(View, {
241
+ testID: "Checkbox-Icon",
242
+ children: /*#__PURE__*/_jsx(IconComponent, { ...iconTokens
243
+ })
244
+ })]
245
+ })
246
+ }), Boolean(label) && /*#__PURE__*/_jsx(Text, {
247
+ style: labelStyles,
248
+ children: /*#__PURE__*/_jsx(CheckboxLabel, {
249
+ forId: inputId,
250
+ children: label
251
+ })
252
+ })]
253
+ });
254
+ }
255
+ }), Boolean(feedback) && /*#__PURE__*/_jsx(View, {
256
+ style: styles.feedbackContainer,
257
+ children: /*#__PURE__*/_jsx(Feedback, {
258
+ title: feedback,
259
+ variant: {
260
+ icon: error === true
261
+ },
262
+ validation: error === true ? 'error' : undefined
263
+ })
264
+ })]
265
+ })
266
+ });
267
+ });
268
+ Checkbox.displayName = 'Checkbox';
269
+ Checkbox.propTypes = { ...selectedSystemPropTypes,
270
+
271
+ /**
272
+ * Use `checked` for controlled Checkbox. For uncontrolled Checkbox, use the `defaultChecked` prop.
273
+ */
274
+ checked: PropTypes.bool,
275
+
276
+ /**
277
+ * Use `defaultChecked` to provide the initial value for an uncontrolled Checkbox.
278
+ */
279
+ defaultChecked: PropTypes.bool,
280
+
281
+ /**
282
+ * A detailed description of related validation error or additional instructions (depending on the `error` prop).
283
+ */
284
+ feedback: PropTypes.string,
285
+
286
+ /**
287
+ * Checkbox ID.
288
+ */
289
+ id: PropTypes.string,
290
+
291
+ /**
292
+ * Whether the corresponding input is disabled or active.
293
+ */
294
+ inactive: PropTypes.bool,
295
+
296
+ /**
297
+ * The label.
298
+ */
299
+ label: PropTypes.string,
300
+
301
+ /**
302
+ * Associate this checkbox with a group (set as the name attribute).
303
+ */
304
+ name: PropTypes.string,
305
+
306
+ /**
307
+ * Whether the underlying input triggered a validation error or not.
308
+ */
309
+ error: PropTypes.bool,
310
+
311
+ /**
312
+ * The value. Must be unique within the group.
313
+ */
314
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
315
+
316
+ /**
317
+ * Callback called when a controlled checkbox gets interacted with.
318
+ */
319
+ onChange: PropTypes.func,
320
+
321
+ /**
322
+ * Checkbox tokens.
323
+ */
324
+ tokens: getTokensPropType('Checkbox'),
325
+
326
+ /**
327
+ * Checkbox variant.
328
+ */
329
+ variant: variantProp.propType
330
+ };
331
+ export default Checkbox;
332
+ const staticStyles = StyleSheet.create({
333
+ wrapper: {
334
+ backgroundColor: 'transparent'
335
+ },
336
+ container: {
337
+ flexDirection: 'row',
338
+ alignItems: 'center'
339
+ },
340
+ defaultInputStyles: {
341
+ alignItems: 'center',
342
+ justifyContent: 'center'
343
+ },
344
+ alignWithLabel: {
345
+ alignSelf: 'flex-start',
346
+ justifyContent: 'center'
347
+ }
348
+ });