@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,243 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Text from "react-native-web/dist/exports/Text";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import { a11yProps, clickProps, getTokensPropType, hrefAttrsProp, linkProps, selectSystemProps, variantProp, viewProps } from '../utils/props';
7
+ import { resolvePressableTokens } from '../utils/pressability';
8
+ import { withLinkRouter } from '../utils';
9
+ import InlinePressable from './InlinePressable';
10
+ import { applyTextStyles, applyOuterBorder } from '../ThemeProvider';
11
+ import { IconText, iconComponentPropTypes } from '../Icon';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
14
+
15
+ const selectOuterBorderStyles = _ref => {
16
+ let {
17
+ outerBorderColor,
18
+ outerBorderWidth,
19
+ outerBorderGap,
20
+ borderRadius,
21
+ outerBorderOutline
22
+ } = _ref;
23
+ return (// A view wrapper with a border on native messes up inline text alignment
24
+ // so for now make focus styles strictly web-only
25
+ Platform.OS === 'web' ? {
26
+ // Allow theme to define outline, or, turn off outline and use border if rounded corners required
27
+ outline: outerBorderOutline,
28
+ ...applyOuterBorder({
29
+ outerBorderColor,
30
+ outerBorderWidth,
31
+ outerBorderGap,
32
+ borderRadius
33
+ }),
34
+ // Stops focus ring stretching horizontally if parent has display: block
35
+ // width: fit-content isn't supported on Firefox; can't cascade props like CSS `width: fit-content; width: --moz-fit-content;`
36
+ display: 'inline-flex'
37
+ } : {}
38
+ );
39
+ };
40
+
41
+ const selectTextStyles = _ref2 => {
42
+ let {
43
+ color
44
+ } = _ref2;
45
+ return {
46
+ color,
47
+ ...Platform.select({
48
+ web: {
49
+ // TODO: https://github.com/telus/universal-design-system/issues/487
50
+ transition: 'color 200ms'
51
+ }
52
+ })
53
+ };
54
+ };
55
+
56
+ const selectBlockStyles = _ref3 => {
57
+ let {
58
+ blockFontWeight,
59
+ blockFontSize,
60
+ blockLineHeight,
61
+ blockFontName
62
+ } = _ref3;
63
+ return applyTextStyles({
64
+ fontWeight: blockFontWeight,
65
+ fontSize: blockFontSize,
66
+ lineHeight: blockLineHeight,
67
+ fontName: blockFontName
68
+ });
69
+ };
70
+
71
+ const selectDecorationStyles = _ref4 => {
72
+ let {
73
+ color,
74
+ textLine,
75
+ textLineStyle
76
+ } = _ref4;
77
+ return {
78
+ color,
79
+ textDecorationLine: textLine,
80
+ textDecorationStyle: textLineStyle,
81
+ ...Platform.select({
82
+ web: {
83
+ // TODO: https://github.com/telus/universal-design-system/issues/487
84
+ transition: 'color 200ms'
85
+ }
86
+ })
87
+ };
88
+ };
89
+
90
+ const selectIconTokens = _ref5 => {
91
+ let {
92
+ color,
93
+ iconSize,
94
+ iconTranslateX,
95
+ iconTranslateY
96
+ } = _ref5;
97
+ return {
98
+ color,
99
+ translateX: iconTranslateX,
100
+ translateY: iconTranslateY,
101
+ size: iconSize
102
+ };
103
+ };
104
+ /**
105
+ * Renders a pressable text link, with optional icon. This is rendered as a block element
106
+ * only (see 'Current Limitations'). On Web, renders an `<a>` anchor tag if `href` is provided.
107
+ *
108
+ * ## Current limitations
109
+ *
110
+ * - Not yet integrated with widely-used Telus navigation packages. This will probably
111
+ * require adding a `navigate` prop that aliases onPress so this can be passed to
112
+ * router's Link components' `Component` or `as` props but this needs testing
113
+ * as part of https://github.com/telus/universal-design-system/issues/24
114
+ *
115
+ * - Doesn't work inline e.g. in paragraphs. Support for inline links in native and
116
+ * web was implemented in https://github.com/telus/universal-design-system/pull/233
117
+ * but removed and will need to be restored at some point. When inline link support
118
+ * is restored, icons in inline links on Android will be slightly off-centre
119
+ * vertically (see )
120
+ *
121
+ * - Doesn't support :visited styles on web. Support for :visited styles was
122
+ * implemented in https://github.com/telus/universal-design-system/pull/234 but
123
+ * dropped in favour of investigating if a full-featured CSS-in-JS package could or
124
+ * should be used more widely (e.g. styled components)
125
+ */
126
+
127
+
128
+ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
129
+ let {
130
+ href,
131
+ icon,
132
+ iconPosition = icon ? 'left' : undefined,
133
+ iconProps,
134
+ variant,
135
+ tokens = {},
136
+ children,
137
+ accessibilityRole = 'link',
138
+ ...rawRest
139
+ } = _ref6;
140
+ const {
141
+ onPress,
142
+ ...props
143
+ } = clickProps.toPressProps(rawRest);
144
+ const {
145
+ hrefAttrs,
146
+ rest
147
+ } = hrefAttrsProp.bundle(props);
148
+ const selectedProps = selectProps({
149
+ accessibilityRole,
150
+ href,
151
+ onPress: linkProps.handleHref({
152
+ href,
153
+ onPress
154
+ }),
155
+ hrefAttrs,
156
+ ...rest
157
+ });
158
+
159
+ const resolveLinkTokens = pressState => resolvePressableTokens(tokens, pressState, {
160
+ iconPosition
161
+ });
162
+
163
+ const defaultThemeTokens = resolveLinkTokens({});
164
+ const hasIcon = Boolean(icon || defaultThemeTokens.icon); // On web, this makes focus rings wrap only the link, not the entire block
165
+
166
+ const blockLeftStyle = Platform.OS === 'web' && staticStyles.blockLeft;
167
+ return /*#__PURE__*/_jsx(InlinePressable, { ...selectedProps,
168
+ inline: hasIcon // assuming links without icons should be inline (even if they are long)
169
+ ,
170
+ ref: ref,
171
+ style: linkState => {
172
+ const themeTokens = resolveLinkTokens(linkState);
173
+ const outerBorderStyles = selectOuterBorderStyles(themeTokens);
174
+ const decorationStyles = selectDecorationStyles(themeTokens);
175
+ return [outerBorderStyles, blockLeftStyle, decorationStyles, hasIcon && staticStyles.rowContainer];
176
+ },
177
+ children: linkState => {
178
+ const themeTokens = resolveLinkTokens(linkState);
179
+ const textStyles = selectTextStyles(themeTokens);
180
+ const iconTokens = selectIconTokens(themeTokens); // TODO: may need to apply some smarter text inheritance here if inline to avoid native
181
+ // issues like double-application of line heights breaking align-items: baseline
182
+
183
+ const blockTextStyles = selectBlockStyles(themeTokens);
184
+ const IconComponent = icon || themeTokens.icon;
185
+ const {
186
+ iconSpace
187
+ } = themeTokens;
188
+ return /*#__PURE__*/_jsx(IconText, {
189
+ icon: IconComponent,
190
+ iconPosition: iconPosition,
191
+ space: iconSpace,
192
+ iconProps: { ...iconProps,
193
+ tokens: iconTokens
194
+ },
195
+ children: /*#__PURE__*/_jsx(Text, {
196
+ style: [textStyles, blockTextStyles, staticStyles.baseline],
197
+ children: children
198
+ })
199
+ });
200
+ }
201
+ });
202
+ });
203
+ LinkBase.displayName = 'LinkBase';
204
+ LinkBase.propTypes = { ...selectedSystemPropTypes,
205
+ tokens: getTokensPropType('Link'),
206
+ variant: variantProp.propType,
207
+
208
+ /**
209
+ * Optional variant that may be passed down to the link's icon if there is one
210
+ */
211
+ iconProps: PropTypes.exact(iconComponentPropTypes),
212
+
213
+ /**
214
+ * A function component for an SVG icon to render inside the link. Inherits size and color from
215
+ * the link and any Typography the link is nested inside.
216
+ */
217
+ icon: PropTypes.func,
218
+
219
+ /**
220
+ * When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of Link.
221
+ */
222
+ iconPosition: PropTypes.oneOf(['left', 'right']),
223
+
224
+ /**
225
+ * On Web if href is passed, React Native Web maps this object's props to
226
+ * `rel`, `target` and `download` attrs.
227
+ */
228
+ hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
229
+ };
230
+ const staticStyles = StyleSheet.create({
231
+ blockLeft: {
232
+ alignSelf: 'flex-start'
233
+ },
234
+ rowContainer: {
235
+ flexDirection: 'row',
236
+ alignItems: 'center',
237
+ justifyContent: 'flex-start'
238
+ },
239
+ baseline: {
240
+ alignSelf: 'baseline'
241
+ }
242
+ });
243
+ export default withLinkRouter(LinkBase);
@@ -0,0 +1,35 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useThemeTokensCallback } from '../ThemeProvider';
4
+ import LinkBase from './LinkBase';
5
+ /**
6
+ * `TextButton` is a button that looks like a Link. It uses the same theming and variants as
7
+ * Link but has the accessibility role of a `Button`. It should be used for actions that
8
+ * take place on the current page, or for navigation within an app.
9
+ */
10
+
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const TextButton = /*#__PURE__*/forwardRef((_ref, ref) => {
13
+ let {
14
+ onPress,
15
+ children,
16
+ variant,
17
+ tokens,
18
+ accessibilityRole = 'button',
19
+ ...linkProps
20
+ } = _ref;
21
+ const getTokens = useThemeTokensCallback('Link', tokens, variant);
22
+ return /*#__PURE__*/_jsx(LinkBase, {
23
+ onPress: onPress,
24
+ accessibilityRole: accessibilityRole,
25
+ tokens: getTokens,
26
+ ref: ref,
27
+ ...linkProps,
28
+ children: children
29
+ });
30
+ });
31
+ TextButton.displayName = 'TextButton';
32
+ TextButton.propTypes = { ...LinkBase.propTypes,
33
+ onPress: PropTypes.func.isRequired
34
+ };
35
+ export default TextButton;
@@ -0,0 +1,5 @@
1
+ import ChevronLink from './ChevronLink';
2
+ import Link from './Link';
3
+ import LinkBase from './LinkBase';
4
+ import TextButton from './TextButton';
5
+ export { ChevronLink, Link, LinkBase, TextButton };
@@ -0,0 +1,62 @@
1
+ import React, { cloneElement, forwardRef, Children } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import PropTypes from 'prop-types';
5
+ import { a11yProps, componentPropType, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
6
+ import ListItem from './ListItem';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
9
+ /**
10
+ * An unordered List component has a child a ListItem that
11
+ * allows icon, dividers and customized typography
12
+ */
13
+
14
+ const List = /*#__PURE__*/forwardRef((_ref, ref) => {
15
+ let {
16
+ children,
17
+ showDivider,
18
+ tokens,
19
+ variant,
20
+ accessibilityRole = Platform.select({
21
+ web: 'list',
22
+ default: undefined
23
+ }),
24
+ ...rest
25
+ } = _ref;
26
+ const items = Children.map(children, (child, index) => {
27
+ var _child$type, _child$type2;
28
+
29
+ // Pass ListItem-specific props to children (by name so teams can add their own ListItems)
30
+ const isListItem = componentName => Boolean(componentName === ListItem.displayName);
31
+
32
+ if (isListItem(child === null || child === void 0 ? void 0 : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) || isListItem(child === null || child === void 0 ? void 0 : (_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.name)) {
33
+ return /*#__PURE__*/cloneElement(child, {
34
+ showDivider,
35
+ isLastItem: index + 1 === Children.count(children),
36
+ tokens,
37
+ variant,
38
+ ...child.props
39
+ });
40
+ }
41
+
42
+ return child;
43
+ });
44
+ return /*#__PURE__*/_jsx(View, {
45
+ ref: ref,
46
+ accessibilityRole: accessibilityRole,
47
+ ...selectProps(rest),
48
+ children: items
49
+ });
50
+ });
51
+ List.displayName = 'List';
52
+ List.propTypes = { ...selectedSystemPropTypes,
53
+ tokens: getTokensPropType('List'),
54
+ variant: variantProp.propType,
55
+ children: componentPropType('ListItem'),
56
+
57
+ /**
58
+ * In case it is not the last item allow display divider
59
+ */
60
+ showDivider: PropTypes.bool
61
+ };
62
+ export default List;
@@ -0,0 +1,248 @@
1
+ import React, { forwardRef } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import PropTypes from 'prop-types';
6
+ import { useThemeTokens, applyTextStyles } from '../ThemeProvider';
7
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps, wrapStringsInText } from '../utils';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { Fragment as _Fragment } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+
13
+ const selectBulletStyles = _ref => {
14
+ let {
15
+ itemBulletWidth,
16
+ itemBulletHeight,
17
+ itemBulletColor
18
+ } = _ref;
19
+ return {
20
+ width: itemBulletWidth,
21
+ height: itemBulletHeight,
22
+ borderRadius: itemBulletHeight / 2,
23
+ backgroundColor: itemBulletColor
24
+ };
25
+ };
26
+
27
+ const selectBulletContainerStyles = _ref2 => {
28
+ let {
29
+ itemBulletContainerWidth,
30
+ itemBulletContainerAlign
31
+ } = _ref2;
32
+ return {
33
+ width: itemBulletContainerWidth,
34
+ alignItems: itemBulletContainerAlign
35
+ };
36
+ };
37
+
38
+ const selectItemIconTokens = _ref3 => {
39
+ let {
40
+ itemIconSize,
41
+ itemIconColor
42
+ } = _ref3;
43
+ return {
44
+ size: itemIconSize,
45
+ color: itemIconColor
46
+ };
47
+ };
48
+
49
+ const selectSideItemContainerStyles = _ref4 => {
50
+ let {
51
+ listGutter,
52
+ iconMarginTop
53
+ } = _ref4;
54
+ return {
55
+ marginTop: iconMarginTop,
56
+ marginRight: listGutter
57
+ };
58
+ }; // Align bullets with the top line of text the same way icons are aligned
59
+
60
+
61
+ const selectBulletPositioningStyles = _ref5 => {
62
+ let {
63
+ itemIconSize
64
+ } = _ref5;
65
+ return {
66
+ width: itemIconSize,
67
+ height: itemIconSize
68
+ };
69
+ };
70
+
71
+ const selectItemStyles = _ref6 => {
72
+ let {
73
+ itemFontWeight,
74
+ itemFontSize,
75
+ itemLineHeight,
76
+ itemFontName
77
+ } = _ref6;
78
+ return applyTextStyles({
79
+ fontWeight: itemFontWeight,
80
+ fontSize: itemFontSize,
81
+ lineHeight: itemLineHeight,
82
+ fontName: itemFontName
83
+ });
84
+ };
85
+
86
+ const selectItemBlockStyles = _ref7 => {
87
+ let {
88
+ interItemMargin
89
+ } = _ref7;
90
+ return {
91
+ marginBottom: interItemMargin
92
+ };
93
+ };
94
+
95
+ const selectDividerStyles = _ref8 => {
96
+ let {
97
+ dividerColor,
98
+ dividerSize,
99
+ interItemMarginWithDivider
100
+ } = _ref8;
101
+ return {
102
+ borderBottomWidth: dividerSize,
103
+ borderColor: dividerColor,
104
+ marginBottom: interItemMarginWithDivider,
105
+ paddingBottom: interItemMarginWithDivider
106
+ };
107
+ };
108
+ /**
109
+ * ListItem is responsible for rendering icon or a bullet as side item
110
+ */
111
+
112
+
113
+ const ListItem = /*#__PURE__*/forwardRef((_ref9, ref) => {
114
+ let {
115
+ tokens,
116
+ variant,
117
+ icon,
118
+ iconColor,
119
+ iconSize,
120
+ showDivider,
121
+ children,
122
+ isLastItem,
123
+ accessibilityRole = Platform.select({
124
+ web: 'listitem',
125
+ default: undefined
126
+ }),
127
+ ...rest
128
+ } = _ref9;
129
+ const themeTokens = useThemeTokens('List', tokens, variant);
130
+ const itemStyles = selectItemStyles(themeTokens);
131
+ const itemBlockStyles = selectItemBlockStyles(themeTokens);
132
+ const dividerStyles = selectDividerStyles(themeTokens);
133
+ const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
134
+ const itemBulletStyles = selectBulletStyles(themeTokens);
135
+ const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
136
+ const iconTokens = selectItemIconTokens(themeTokens);
137
+ const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
138
+
139
+ const renderItem = () => /*#__PURE__*/_jsx(View, {
140
+ style: staticStyles.wrap,
141
+ children: wrapStringsInText(children, {
142
+ style: itemStyles
143
+ })
144
+ });
145
+ /**
146
+ * Function responsible returning styling, in case the item is the last shouldn't
147
+ * add extra margin on the bottom, if "showDivider" is true it should add a divider
148
+ * and custom margin and padding, otherwise just adds a margin to the bottom
149
+ */
150
+
151
+
152
+ const getContainerStyle = () => {
153
+ if (isLastItem) {
154
+ return undefined;
155
+ }
156
+
157
+ if (showDivider) {
158
+ return dividerStyles;
159
+ }
160
+
161
+ return itemBlockStyles;
162
+ };
163
+ /**
164
+ * Renders item bullet or Icon in case it's defined
165
+ * in case children are string the icon is centered otherwise
166
+ * it will align itself at start of the container
167
+ */
168
+
169
+
170
+ const renderMarker = () => {
171
+ const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
172
+
173
+ if (icon) {
174
+ return /*#__PURE__*/_jsx(View, {
175
+ style: sideItemContainerStyles,
176
+ children: /*#__PURE__*/_jsx(IconComponent, {
177
+ size: iconSize || iconTokens.size,
178
+ color: iconColor || iconTokens.color
179
+ })
180
+ });
181
+ }
182
+
183
+ return /*#__PURE__*/_jsx(View, {
184
+ style: [sideItemContainerStyles, itemBulletContainerStyles],
185
+ children: /*#__PURE__*/_jsx(View, {
186
+ style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
187
+ children: /*#__PURE__*/_jsx(View, {
188
+ style: itemBulletStyles,
189
+ testID: "unordered-item-bullet"
190
+ })
191
+ })
192
+ });
193
+ };
194
+
195
+ return /*#__PURE__*/_jsxs(View, {
196
+ ref: ref,
197
+ style: [staticStyles.itemContainer, getContainerStyle()],
198
+ accessibilityRole: accessibilityRole,
199
+ ...selectProps(rest),
200
+ children: [renderMarker(), renderItem()]
201
+ });
202
+ });
203
+ ListItem.displayName = 'ListItem';
204
+ const staticStyles = StyleSheet.create({
205
+ itemContainer: {
206
+ flexDirection: 'row'
207
+ },
208
+ wrap: {
209
+ flex: 1
210
+ },
211
+ bulletPositioning: {
212
+ alignItems: 'center',
213
+ justifyContent: 'center'
214
+ }
215
+ });
216
+ ListItem.propTypes = { ...selectedSystemPropTypes,
217
+ tokens: getTokensPropType('List'),
218
+ variant: variantProp.propType,
219
+ children: PropTypes.node.isRequired,
220
+
221
+ /**
222
+ * Renders side item icon
223
+ */
224
+ icon: PropTypes.func,
225
+
226
+ /**
227
+ * Will set display icon color
228
+ */
229
+ iconColor: PropTypes.string,
230
+
231
+ /**
232
+ * Allow the user define the icon size if not defined the theme's file
233
+ */
234
+ iconSize: PropTypes.number,
235
+
236
+ /**
237
+ * @ignore
238
+ * Defined by parent if it's last item on the list
239
+ */
240
+ isLastItem: PropTypes.bool,
241
+
242
+ /**
243
+ * @ignore
244
+ * In case it is not the last item allow display divider
245
+ */
246
+ showDivider: PropTypes.bool
247
+ };
248
+ export default ListItem;
@@ -0,0 +1,5 @@
1
+ import List from './List';
2
+ import ListItem from './ListItem';
3
+ List.Item = ListItem;
4
+ export { List as ListBase, ListItem };
5
+ export default List;