@telus-uds/components-base 1.14.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/__tests17__/A11yText/A11yText.test.jsx +34 -0
  3. package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +68 -0
  4. package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +299 -0
  5. package/__tests17__/Box/Box.test.jsx +111 -0
  6. package/__tests17__/Button/Button.test.jsx +86 -0
  7. package/__tests17__/Button/ButtonBase.test.jsx +82 -0
  8. package/__tests17__/Button/ButtonGroup.test.jsx +347 -0
  9. package/__tests17__/Button/ButtonLink.test.jsx +61 -0
  10. package/__tests17__/Card/Card.test.jsx +63 -0
  11. package/__tests17__/Carousel/Carousel.test.jsx +128 -0
  12. package/__tests17__/Carousel/CarouselTabs.test.jsx +142 -0
  13. package/__tests17__/Checkbox/Checkbox.test.jsx +94 -0
  14. package/__tests17__/Checkbox/CheckboxGroup.test.jsx +246 -0
  15. package/__tests17__/Divider/Divider.test.jsx +91 -0
  16. package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +109 -0
  17. package/__tests17__/Feedback/Feedback.test.jsx +42 -0
  18. package/__tests17__/FlexGrid/Col.test.jsx +261 -0
  19. package/__tests17__/FlexGrid/FlexGrid.test.jsx +136 -0
  20. package/__tests17__/FlexGrid/Row.test.jsx +273 -0
  21. package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +165 -0
  22. package/__tests17__/Icon/Icon.test.jsx +61 -0
  23. package/__tests17__/IconButton/IconButton.test.jsx +52 -0
  24. package/__tests17__/InputLabel/InputLabel.test.jsx +28 -0
  25. package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
  26. package/__tests17__/InputSupports/InputSupports.test.jsx +60 -0
  27. package/__tests17__/Link/Link.test.jsx +63 -0
  28. package/__tests17__/Link/TextButton.test.jsx +35 -0
  29. package/__tests17__/List/List.test.jsx +82 -0
  30. package/__tests17__/Modal/Modal.test.jsx +47 -0
  31. package/__tests17__/Notification/Notification.test.jsx +20 -0
  32. package/__tests17__/Pagination/Pagination.test.jsx +160 -0
  33. package/__tests17__/Progress/Progress.test.jsx +79 -0
  34. package/__tests17__/Radio/Radio.test.jsx +87 -0
  35. package/__tests17__/Radio/RadioGroup.test.jsx +220 -0
  36. package/__tests17__/RadioCard/RadioCard.test.jsx +87 -0
  37. package/__tests17__/RadioCard/RadioCardGroup.test.jsx +246 -0
  38. package/__tests17__/Search/Search.test.jsx +87 -0
  39. package/__tests17__/Select/Select.test.jsx +94 -0
  40. package/__tests17__/SideNav/SideNav.test.jsx +110 -0
  41. package/__tests17__/Skeleton/Skeleton.test.jsx +61 -0
  42. package/__tests17__/SkipLink/SkipLink.test.jsx +61 -0
  43. package/__tests17__/Spacer/Spacer.test.jsx +63 -0
  44. package/__tests17__/StackView/StackView.test.jsx +211 -0
  45. package/__tests17__/StackView/StackWrap.test.jsx +47 -0
  46. package/__tests17__/StackView/getStackedContent.test.jsx +295 -0
  47. package/__tests17__/StepTracker/StepTracker.test.jsx +108 -0
  48. package/__tests17__/Tabs/Tabs.test.jsx +49 -0
  49. package/__tests17__/Tags/Tags.test.jsx +327 -0
  50. package/__tests17__/TextInput/TextArea.test.jsx +35 -0
  51. package/__tests17__/TextInput/TextInputBase.test.jsx +125 -0
  52. package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +80 -0
  53. package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +514 -0
  54. package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +41 -0
  55. package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +82 -0
  56. package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  57. package/__tests17__/Tooltip/Tooltip.test.jsx +65 -0
  58. package/__tests17__/Tooltip/getTooltipPosition.test.js +79 -0
  59. package/__tests17__/Typography/typography.test.jsx +90 -0
  60. package/__tests17__/utils/children.test.jsx +128 -0
  61. package/__tests17__/utils/containUniqueFields.test.js +25 -0
  62. package/__tests17__/utils/input.test.js +375 -0
  63. package/__tests17__/utils/props.test.js +36 -0
  64. package/__tests17__/utils/semantics.test.jsx +34 -0
  65. package/__tests17__/utils/useCopy.test.js +42 -0
  66. package/__tests17__/utils/useResponsiveProp.test.jsx +202 -0
  67. package/__tests17__/utils/useSpacingScale.test.jsx +273 -0
  68. package/__tests17__/utils/useUniqueId.test.js +31 -0
  69. package/component-docs.json +95 -438
  70. package/lib/A11yInfoProvider/index.js +14 -5
  71. package/lib/Button/ButtonGroup.js +3 -2
  72. package/lib/Checkbox/Checkbox.js +9 -6
  73. package/lib/ExpandCollapse/Control.js +6 -5
  74. package/lib/ExpandCollapse/Panel.js +5 -4
  75. package/lib/List/ListItem.js +10 -236
  76. package/lib/List/ListItemBase.js +162 -0
  77. package/lib/List/ListItemContent.js +85 -0
  78. package/lib/List/ListItemMark.js +158 -0
  79. package/lib/List/PressableListItemBase.js +147 -0
  80. package/lib/Notification/Notification.js +2 -1
  81. package/lib/Pagination/Pagination.js +4 -3
  82. package/lib/Pagination/SideButton.js +17 -7
  83. package/lib/Radio/Radio.js +9 -6
  84. package/lib/RadioCard/RadioCard.js +9 -6
  85. package/lib/Select/Select.js +1 -0
  86. package/lib/Tabs/Tabs.js +12 -3
  87. package/lib/Tags/Tags.js +3 -3
  88. package/lib/TextInput/TextInput.js +5 -4
  89. package/lib/ViewportProvider/useViewportListener.js +11 -5
  90. package/lib/utils/hasOwnProperty.js +18 -0
  91. package/lib/utils/props/a11yProps.js +212 -45
  92. package/lib/utils/props/getPropSelector.js +47 -5
  93. package/lib/utils/ssr.js +116 -1
  94. package/lib/utils/useResponsiveProp.js +5 -3
  95. package/lib/utils/withLinkRouter.js +3 -5
  96. package/lib-module/A11yInfoProvider/index.js +14 -4
  97. package/lib-module/Button/ButtonGroup.js +3 -2
  98. package/lib-module/Checkbox/Checkbox.js +9 -6
  99. package/lib-module/ExpandCollapse/Control.js +6 -5
  100. package/lib-module/ExpandCollapse/Panel.js +5 -4
  101. package/lib-module/List/ListItem.js +13 -235
  102. package/lib-module/List/ListItemBase.js +139 -0
  103. package/lib-module/List/ListItemContent.js +66 -0
  104. package/lib-module/List/ListItemMark.js +143 -0
  105. package/lib-module/List/PressableListItemBase.js +117 -0
  106. package/lib-module/Notification/Notification.js +2 -1
  107. package/lib-module/Pagination/Pagination.js +5 -3
  108. package/lib-module/Pagination/SideButton.js +18 -8
  109. package/lib-module/Radio/Radio.js +9 -6
  110. package/lib-module/RadioCard/RadioCard.js +9 -6
  111. package/lib-module/Select/Select.js +1 -0
  112. package/lib-module/Tabs/Tabs.js +13 -4
  113. package/lib-module/Tags/Tags.js +3 -3
  114. package/lib-module/TextInput/TextInput.js +5 -4
  115. package/lib-module/ViewportProvider/useViewportListener.js +10 -4
  116. package/lib-module/utils/hasOwnProperty.js +11 -0
  117. package/lib-module/utils/props/a11yProps.js +210 -45
  118. package/lib-module/utils/props/getPropSelector.js +44 -5
  119. package/lib-module/utils/ssr.js +106 -0
  120. package/lib-module/utils/useResponsiveProp.js +3 -4
  121. package/lib-module/utils/withLinkRouter.js +3 -5
  122. package/package.json +12 -17
  123. package/src/A11yInfoProvider/index.jsx +20 -4
  124. package/src/Button/ButtonGroup.jsx +4 -2
  125. package/src/Checkbox/Checkbox.jsx +7 -3
  126. package/src/ExpandCollapse/Control.jsx +8 -5
  127. package/src/ExpandCollapse/Panel.jsx +7 -5
  128. package/src/List/ListItem.jsx +12 -191
  129. package/src/List/ListItemBase.jsx +118 -0
  130. package/src/List/ListItemContent.jsx +52 -0
  131. package/src/List/ListItemMark.jsx +99 -0
  132. package/src/List/PressableListItemBase.jsx +102 -0
  133. package/src/Notification/Notification.jsx +1 -1
  134. package/src/Pagination/Pagination.jsx +6 -1
  135. package/src/Pagination/SideButton.jsx +4 -1
  136. package/src/Radio/Radio.jsx +7 -3
  137. package/src/RadioCard/RadioCard.jsx +7 -3
  138. package/src/Select/Select.jsx +1 -1
  139. package/src/Tabs/Tabs.jsx +19 -2
  140. package/src/Tags/Tags.jsx +3 -3
  141. package/src/TextInput/TextInput.jsx +4 -4
  142. package/src/ViewportProvider/useViewportListener.js +10 -5
  143. package/src/utils/hasOwnProperty.js +11 -0
  144. package/src/utils/props/a11yProps.js +168 -55
  145. package/src/utils/props/getPropSelector.js +45 -4
  146. package/src/utils/ssr.jsx +124 -0
  147. package/src/utils/useResponsiveProp.js +3 -3
  148. package/src/utils/withLinkRouter.jsx +1 -3
  149. package/src/utils/ssr.js +0 -35
@@ -1,252 +1,30 @@
1
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 { useTheme, 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, themeOptions) => {
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
- themeOptions
84
- });
85
- };
86
-
87
- const selectItemBlockStyles = _ref7 => {
88
- let {
89
- interItemMargin
90
- } = _ref7;
91
- return {
92
- marginBottom: interItemMargin
93
- };
94
- };
95
-
96
- const selectDividerStyles = _ref8 => {
97
- let {
98
- dividerColor,
99
- dividerSize,
100
- interItemMarginWithDivider
101
- } = _ref8;
102
- return {
103
- borderBottomWidth: dividerSize,
104
- borderColor: dividerColor,
105
- marginBottom: interItemMarginWithDivider,
106
- paddingBottom: interItemMarginWithDivider
107
- };
108
- };
2
+ import ListItemBase from './ListItemBase';
3
+ import { useThemeTokens } from '../ThemeProvider';
4
+ import { variantProp } from '../utils';
109
5
  /**
110
6
  * ListItem is responsible for rendering icon or a bullet as side item
111
7
  */
112
8
 
113
-
114
- const ListItem = /*#__PURE__*/forwardRef((_ref9, ref) => {
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const ListItem = /*#__PURE__*/forwardRef((_ref, ref) => {
115
11
  let {
116
12
  tokens,
117
13
  variant,
118
- icon,
119
- iconColor,
120
- iconSize,
121
- showDivider,
122
14
  children,
123
- isLastItem,
124
- accessibilityRole = Platform.select({
125
- web: 'listitem',
126
- default: undefined
127
- }),
128
- ...rest
129
- } = _ref9;
15
+ ...listItemProps
16
+ } = _ref;
130
17
  const themeTokens = useThemeTokens('List', tokens, variant);
131
- const {
132
- themeOptions
133
- } = useTheme();
134
- const itemStyles = selectItemStyles(themeTokens, themeOptions);
135
- const itemBlockStyles = selectItemBlockStyles(themeTokens);
136
- const dividerStyles = selectDividerStyles(themeTokens);
137
- const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
138
- const itemBulletStyles = selectBulletStyles(themeTokens);
139
- const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
140
- const iconTokens = selectItemIconTokens(themeTokens);
141
- const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
142
-
143
- const renderItem = () => /*#__PURE__*/_jsx(View, {
144
- style: staticStyles.wrap,
145
- children: wrapStringsInText(children, {
146
- style: itemStyles
147
- })
148
- });
149
- /**
150
- * Function responsible returning styling, in case the item is the last shouldn't
151
- * add extra margin on the bottom, if "showDivider" is true it should add a divider
152
- * and custom margin and padding, otherwise just adds a margin to the bottom
153
- */
154
-
155
-
156
- const getContainerStyle = () => {
157
- if (isLastItem) {
158
- return undefined;
159
- }
160
-
161
- if (showDivider) {
162
- return dividerStyles;
163
- }
164
-
165
- return itemBlockStyles;
166
- };
167
- /**
168
- * Renders item bullet or Icon in case it's defined
169
- * in case children are string the icon is centered otherwise
170
- * it will align itself at start of the container
171
- */
172
-
173
-
174
- const renderMarker = () => {
175
- const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
176
-
177
- if (icon) {
178
- return /*#__PURE__*/_jsx(View, {
179
- style: sideItemContainerStyles,
180
- children: /*#__PURE__*/_jsx(IconComponent, {
181
- size: iconSize || iconTokens.size,
182
- color: iconColor || iconTokens.color
183
- })
184
- });
185
- }
186
-
187
- return /*#__PURE__*/_jsx(View, {
188
- style: [sideItemContainerStyles, itemBulletContainerStyles],
189
- children: /*#__PURE__*/_jsx(View, {
190
- style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
191
- children: /*#__PURE__*/_jsx(View, {
192
- style: itemBulletStyles,
193
- testID: "unordered-item-bullet"
194
- })
195
- })
196
- });
197
- };
198
-
199
- return /*#__PURE__*/_jsxs(View, {
18
+ return /*#__PURE__*/_jsx(ListItemBase, {
19
+ tokens: themeTokens,
200
20
  ref: ref,
201
- style: [staticStyles.itemContainer, getContainerStyle()],
202
- accessibilityRole: accessibilityRole,
203
- ...selectProps(rest),
204
- children: [renderMarker(), renderItem()]
21
+ ...listItemProps,
22
+ children: children
205
23
  });
206
24
  });
207
25
  ListItem.displayName = 'ListItem';
208
- const staticStyles = StyleSheet.create({
209
- itemContainer: {
210
- flexDirection: 'row'
211
- },
212
- wrap: {
213
- flex: 1
214
- },
215
- bulletPositioning: {
216
- alignItems: 'center',
217
- justifyContent: 'center'
218
- }
219
- });
220
- ListItem.propTypes = { ...selectedSystemPropTypes,
221
- tokens: getTokensPropType('List'),
26
+ ListItem.propTypes = {
222
27
  variant: variantProp.propType,
223
- children: PropTypes.node.isRequired,
224
-
225
- /**
226
- * Renders side item icon
227
- */
228
- icon: PropTypes.elementType,
229
-
230
- /**
231
- * Will set display icon color
232
- */
233
- iconColor: PropTypes.string,
234
-
235
- /**
236
- * Allow the user define the icon size if not defined the theme's file
237
- */
238
- iconSize: PropTypes.number,
239
-
240
- /**
241
- * @ignore
242
- * Defined by parent if it's last item on the list
243
- */
244
- isLastItem: PropTypes.bool,
245
-
246
- /**
247
- * @ignore
248
- * In case it is not the last item allow display divider
249
- */
250
- showDivider: PropTypes.bool
28
+ ...ListItemBase.propTypes
251
29
  };
252
30
  export default ListItem;
@@ -0,0 +1,139 @@
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 { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
7
+ import ListItemContent from './ListItemContent';
8
+ import ListItemMark from './ListItemMark';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
13
+
14
+ const selectItemBlockStyles = _ref => {
15
+ let {
16
+ interItemMargin
17
+ } = _ref;
18
+ return {
19
+ marginBottom: interItemMargin
20
+ };
21
+ };
22
+
23
+ const selectDividerStyles = _ref2 => {
24
+ let {
25
+ dividerColor,
26
+ dividerSize,
27
+ interItemMarginWithDivider
28
+ } = _ref2;
29
+ return {
30
+ borderBottomWidth: dividerSize,
31
+ borderColor: dividerColor,
32
+ marginBottom: interItemMarginWithDivider,
33
+ paddingBottom: interItemMarginWithDivider
34
+ };
35
+ };
36
+ /**
37
+ * ListItem is responsible for rendering icon or a bullet as side item
38
+ */
39
+
40
+
41
+ const ListItemBase = /*#__PURE__*/forwardRef((_ref3, ref) => {
42
+ let {
43
+ tokens,
44
+ icon,
45
+ iconColor,
46
+ iconSize,
47
+ showDivider,
48
+ children,
49
+ isLastItem,
50
+ accessibilityRole = Platform.select({
51
+ web: 'listitem',
52
+ default: undefined
53
+ }),
54
+ ...rest
55
+ } = _ref3;
56
+ const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
57
+ const itemBlockStyles = selectItemBlockStyles(themeTokens);
58
+ const dividerStyles = selectDividerStyles(themeTokens);
59
+ /**
60
+ * Function responsible returning styling, in case the item is the last shouldn't
61
+ * add extra margin on the bottom, if "showDivider" is true it should add a divider
62
+ * and custom margin and padding, otherwise just adds a margin to the bottom
63
+ */
64
+
65
+ const getContainerStyle = () => {
66
+ if (isLastItem) {
67
+ return undefined;
68
+ }
69
+
70
+ if (showDivider) {
71
+ return dividerStyles;
72
+ }
73
+
74
+ return itemBlockStyles;
75
+ };
76
+
77
+ return /*#__PURE__*/_jsx(View, {
78
+ ref: ref,
79
+ style: [staticStyles.itemContainer, getContainerStyle()],
80
+ accessibilityRole: accessibilityRole,
81
+ ...selectProps(rest),
82
+ children: typeof children === 'function' ? children({
83
+ tokens,
84
+ icon,
85
+ iconColor,
86
+ iconSize,
87
+ isLastItem
88
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
89
+ children: [/*#__PURE__*/_jsx(ListItemMark, {
90
+ tokens: tokens,
91
+ icon: icon,
92
+ iconColor: iconColor,
93
+ iconSize: iconSize
94
+ }), /*#__PURE__*/_jsx(ListItemContent, {
95
+ tokens: tokens,
96
+ children: children
97
+ })]
98
+ })
99
+ });
100
+ });
101
+ ListItemBase.displayName = 'ListItem';
102
+ const staticStyles = StyleSheet.create({
103
+ itemContainer: {
104
+ flexDirection: 'row'
105
+ }
106
+ });
107
+ ListItemBase.propTypes = { ...selectedSystemPropTypes,
108
+ tokens: getTokensPropType('List'),
109
+ variant: variantProp.propType,
110
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
111
+
112
+ /**
113
+ * Renders side item icon
114
+ */
115
+ icon: PropTypes.elementType,
116
+
117
+ /**
118
+ * Will set display icon color
119
+ */
120
+ iconColor: PropTypes.string,
121
+
122
+ /**
123
+ * Allow the user define the icon size if not defined the theme's file
124
+ */
125
+ iconSize: PropTypes.number,
126
+
127
+ /**
128
+ * @ignore
129
+ * Defined by parent if it's last item on the list
130
+ */
131
+ isLastItem: PropTypes.bool,
132
+
133
+ /**
134
+ * @ignore
135
+ * In case it is not the last item allow display divider
136
+ */
137
+ showDivider: PropTypes.bool
138
+ };
139
+ export default ListItemBase;
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import { wrapStringsInText } from '../utils';
6
+ import { useTheme, applyTextStyles } from '../ThemeProvider';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export const tokenTypes = {
9
+ itemFontWeight: PropTypes.string.isRequired,
10
+ itemFontSize: PropTypes.number.isRequired,
11
+ itemLineHeight: PropTypes.number.isRequired,
12
+ itemFontName: PropTypes.string.isRequired
13
+ };
14
+
15
+ const selectItemTextStyles = (_ref, themeOptions) => {
16
+ let {
17
+ itemFontWeight,
18
+ itemFontSize,
19
+ itemLineHeight,
20
+ itemFontName
21
+ } = _ref;
22
+ return applyTextStyles({
23
+ fontWeight: itemFontWeight,
24
+ fontSize: itemFontSize,
25
+ lineHeight: itemLineHeight,
26
+ fontName: itemFontName,
27
+ themeOptions
28
+ });
29
+ };
30
+ /**
31
+ * Subcomponent used within ListItem and similar components for rendering content that fills
32
+ * and wraps available space in a { flexDirection: row } container alongside a ListIconMark,
33
+ * and that applies text styles to strings via supplied tokens.
34
+ *
35
+ * It's the responsibility of themes to make sure that these text tokens align the first line of
36
+ * text nicely against the bullet or icon rendered by ListIconMark.
37
+ */
38
+
39
+
40
+ const ListItemContent = _ref2 => {
41
+ let {
42
+ tokens,
43
+ children
44
+ } = _ref2;
45
+ const {
46
+ themeOptions
47
+ } = useTheme();
48
+ const textStyles = selectItemTextStyles(tokens, themeOptions);
49
+ return /*#__PURE__*/_jsx(View, {
50
+ style: staticStyles.wrap,
51
+ children: wrapStringsInText(children, {
52
+ style: textStyles
53
+ })
54
+ });
55
+ };
56
+
57
+ const staticStyles = StyleSheet.create({
58
+ wrap: {
59
+ flex: 1
60
+ }
61
+ });
62
+ ListItemContent.propTypes = {
63
+ tokens: PropTypes.shape(tokenTypes).isRequired,
64
+ children: PropTypes.node.isRequired
65
+ };
66
+ export default ListItemContent;
@@ -0,0 +1,143 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export const tokenTypes = {
8
+ itemIconSize: PropTypes.number.isRequired,
9
+ itemIconColor: PropTypes.string.isRequired,
10
+ listGutter: PropTypes.number.isRequired,
11
+ iconMarginTop: PropTypes.number.isRequired
12
+ };
13
+
14
+ const selectItemIconTokens = _ref => {
15
+ let {
16
+ itemIconSize,
17
+ itemIconColor
18
+ } = _ref;
19
+ return {
20
+ size: itemIconSize,
21
+ color: itemIconColor
22
+ };
23
+ };
24
+
25
+ const selectSideItemContainerStyles = _ref2 => {
26
+ let {
27
+ listGutter,
28
+ iconMarginTop
29
+ } = _ref2;
30
+ return {
31
+ marginTop: iconMarginTop,
32
+ marginRight: listGutter
33
+ };
34
+ }; // Align bullets with the top line of text the same way icons are aligned
35
+
36
+
37
+ const selectBulletPositioningStyles = _ref3 => {
38
+ let {
39
+ itemIconSize
40
+ } = _ref3;
41
+ return {
42
+ width: itemIconSize,
43
+ height: itemIconSize
44
+ };
45
+ };
46
+
47
+ const selectBulletStyles = _ref4 => {
48
+ let {
49
+ itemBulletWidth,
50
+ itemBulletHeight,
51
+ itemBulletColor
52
+ } = _ref4;
53
+ return {
54
+ width: itemBulletWidth,
55
+ height: itemBulletHeight,
56
+ borderRadius: itemBulletHeight / 2,
57
+ backgroundColor: itemBulletColor
58
+ };
59
+ };
60
+
61
+ const selectBulletContainerStyles = _ref5 => {
62
+ let {
63
+ itemBulletContainerWidth,
64
+ itemBulletContainerAlign
65
+ } = _ref5;
66
+ return {
67
+ width: itemBulletContainerWidth,
68
+ alignItems: itemBulletContainerAlign
69
+ };
70
+ };
71
+ /**
72
+ * Subcomponent used within ListItem and similar components for rendering bullets or icons
73
+ * that sit alongside a ListIconContent in a { flexDirection: row } container.
74
+ *
75
+ * It's the responsibility of themes to make sure that the supplied tokens align the
76
+ * icon or bullet nicely against the first line of text in a ListIconContent.
77
+ */
78
+
79
+
80
+ const ListItemMark = _ref6 => {
81
+ let {
82
+ icon,
83
+ iconColor,
84
+ iconSize,
85
+ tokens = {}
86
+ } = _ref6;
87
+
88
+ const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
89
+
90
+ const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
91
+ const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
92
+
93
+ if (icon) {
94
+ const iconTokens = selectItemIconTokens(themeTokens);
95
+ return /*#__PURE__*/_jsx(View, {
96
+ style: sideItemContainerStyles,
97
+ children: /*#__PURE__*/_jsx(IconComponent, {
98
+ size: iconSize || iconTokens.size,
99
+ color: iconColor || iconTokens.color
100
+ })
101
+ });
102
+ }
103
+
104
+ const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
105
+ const itemBulletStyles = selectBulletStyles(themeTokens);
106
+ const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
107
+ return /*#__PURE__*/_jsx(View, {
108
+ style: [sideItemContainerStyles, itemBulletContainerStyles],
109
+ children: /*#__PURE__*/_jsx(View, {
110
+ style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
111
+ children: /*#__PURE__*/_jsx(View, {
112
+ style: itemBulletStyles,
113
+ testID: "unordered-item-bullet"
114
+ })
115
+ })
116
+ });
117
+ };
118
+
119
+ ListItemMark.propTypes = {
120
+ tokens: PropTypes.shape(tokenTypes).isRequired,
121
+
122
+ /**
123
+ * Renders side item icon
124
+ */
125
+ icon: PropTypes.elementType,
126
+
127
+ /**
128
+ * Will set display icon color
129
+ */
130
+ iconColor: PropTypes.string,
131
+
132
+ /**
133
+ * Allow the user define the icon size
134
+ */
135
+ iconSize: PropTypes.number
136
+ };
137
+ const staticStyles = StyleSheet.create({
138
+ bulletPositioning: {
139
+ alignItems: 'center',
140
+ justifyContent: 'center'
141
+ }
142
+ });
143
+ export default ListItemMark;