@telus-uds/components-base 1.14.2 → 1.16.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 (161) hide show
  1. package/CHANGELOG.md +40 -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 +120 -85
  70. package/lib/A11yInfoProvider/index.js +14 -5
  71. package/lib/Button/ButtonGroup.js +3 -2
  72. package/lib/Carousel/Carousel.js +18 -2
  73. package/lib/Carousel/CarouselTabs/CarouselTabs.js +6 -7
  74. package/lib/Checkbox/Checkbox.js +9 -6
  75. package/lib/ExpandCollapse/Control.js +6 -5
  76. package/lib/ExpandCollapse/Panel.js +5 -4
  77. package/lib/List/ListItem.js +10 -236
  78. package/lib/List/ListItemBase.js +162 -0
  79. package/lib/List/ListItemContent.js +85 -0
  80. package/lib/List/ListItemMark.js +158 -0
  81. package/lib/List/PressableListItemBase.js +147 -0
  82. package/lib/Notification/Notification.js +2 -1
  83. package/lib/Pagination/Pagination.js +4 -3
  84. package/lib/Radio/Radio.js +9 -6
  85. package/lib/RadioCard/RadioCard.js +9 -6
  86. package/lib/Select/Select.js +1 -0
  87. package/lib/Skeleton/Skeleton.js +18 -13
  88. package/lib/Skeleton/useSkeletonNativeAnimation.js +4 -2
  89. package/lib/Tabs/Tabs.js +12 -3
  90. package/lib/Tags/Tags.js +3 -3
  91. package/lib/TextInput/TextInput.js +5 -4
  92. package/lib/ToggleSwitch/ToggleSwitch.js +24 -19
  93. package/lib/ViewportProvider/useViewportListener.js +11 -5
  94. package/lib/utils/hasOwnProperty.js +18 -0
  95. package/lib/utils/props/a11yProps.js +171 -1
  96. package/lib/utils/props/getPropSelector.js +47 -5
  97. package/lib/utils/ssr.js +116 -1
  98. package/lib/utils/useResponsiveProp.js +5 -3
  99. package/lib/utils/withLinkRouter.js +3 -5
  100. package/lib-module/A11yInfoProvider/index.js +14 -4
  101. package/lib-module/Button/ButtonGroup.js +3 -2
  102. package/lib-module/Carousel/Carousel.js +16 -2
  103. package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +7 -6
  104. package/lib-module/Checkbox/Checkbox.js +9 -6
  105. package/lib-module/ExpandCollapse/Control.js +6 -5
  106. package/lib-module/ExpandCollapse/Panel.js +5 -4
  107. package/lib-module/List/ListItem.js +13 -235
  108. package/lib-module/List/ListItemBase.js +139 -0
  109. package/lib-module/List/ListItemContent.js +66 -0
  110. package/lib-module/List/ListItemMark.js +143 -0
  111. package/lib-module/List/PressableListItemBase.js +117 -0
  112. package/lib-module/Notification/Notification.js +2 -1
  113. package/lib-module/Pagination/Pagination.js +5 -3
  114. package/lib-module/Radio/Radio.js +9 -6
  115. package/lib-module/RadioCard/RadioCard.js +9 -6
  116. package/lib-module/Select/Select.js +1 -0
  117. package/lib-module/Skeleton/Skeleton.js +15 -13
  118. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +3 -2
  119. package/lib-module/Tabs/Tabs.js +13 -4
  120. package/lib-module/Tags/Tags.js +3 -3
  121. package/lib-module/TextInput/TextInput.js +5 -4
  122. package/lib-module/ToggleSwitch/ToggleSwitch.js +24 -19
  123. package/lib-module/ViewportProvider/useViewportListener.js +10 -4
  124. package/lib-module/utils/hasOwnProperty.js +11 -0
  125. package/lib-module/utils/props/a11yProps.js +169 -1
  126. package/lib-module/utils/props/getPropSelector.js +44 -5
  127. package/lib-module/utils/ssr.js +106 -0
  128. package/lib-module/utils/useResponsiveProp.js +3 -4
  129. package/lib-module/utils/withLinkRouter.js +3 -5
  130. package/package.json +12 -17
  131. package/src/A11yInfoProvider/index.jsx +20 -4
  132. package/src/Button/ButtonGroup.jsx +4 -2
  133. package/src/Carousel/Carousel.jsx +15 -2
  134. package/src/Carousel/CarouselTabs/CarouselTabs.jsx +5 -3
  135. package/src/Checkbox/Checkbox.jsx +7 -3
  136. package/src/ExpandCollapse/Control.jsx +8 -5
  137. package/src/ExpandCollapse/Panel.jsx +7 -5
  138. package/src/List/ListItem.jsx +12 -191
  139. package/src/List/ListItemBase.jsx +118 -0
  140. package/src/List/ListItemContent.jsx +52 -0
  141. package/src/List/ListItemMark.jsx +99 -0
  142. package/src/List/PressableListItemBase.jsx +102 -0
  143. package/src/Notification/Notification.jsx +1 -1
  144. package/src/Pagination/Pagination.jsx +6 -1
  145. package/src/Radio/Radio.jsx +7 -3
  146. package/src/RadioCard/RadioCard.jsx +7 -3
  147. package/src/Select/Select.jsx +1 -1
  148. package/src/Skeleton/Skeleton.jsx +25 -19
  149. package/src/Skeleton/useSkeletonNativeAnimation.js +3 -3
  150. package/src/Tabs/Tabs.jsx +19 -2
  151. package/src/Tags/Tags.jsx +3 -3
  152. package/src/TextInput/TextInput.jsx +4 -4
  153. package/src/ToggleSwitch/ToggleSwitch.jsx +3 -3
  154. package/src/ViewportProvider/useViewportListener.js +10 -5
  155. package/src/utils/hasOwnProperty.js +11 -0
  156. package/src/utils/props/a11yProps.js +107 -1
  157. package/src/utils/props/getPropSelector.js +45 -4
  158. package/src/utils/ssr.jsx +124 -0
  159. package/src/utils/useResponsiveProp.js +3 -3
  160. package/src/utils/withLinkRouter.jsx +1 -3
  161. package/src/utils/ssr.js +0 -35
@@ -41,6 +41,10 @@ var _CarouselStepTracker = _interopRequireDefault(require("./CarouselStepTracker
41
41
 
42
42
  var _CarouselThumbnailNavigation = _interopRequireDefault(require("./CarouselThumbnailNavigation"));
43
43
 
44
+ var _CarouselTabsPanel = _interopRequireDefault(require("./CarouselTabs/CarouselTabsPanel"));
45
+
46
+ var _CarouselTabsPanelItem = _interopRequireDefault(require("./CarouselTabs/CarouselTabsPanelItem"));
47
+
44
48
  var _dictionary = _interopRequireDefault(require("./dictionary"));
45
49
 
46
50
  var _jsxRuntime = require("react/jsx-runtime");
@@ -166,7 +170,8 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
166
170
  onAnimationEnd,
167
171
  onIndexChanged,
168
172
  skipLinkHref,
169
- refocus,
173
+ tabs,
174
+ refocus = Boolean(tabs),
170
175
  title = 'carousel',
171
176
  springConfig = undefined,
172
177
  thumbnails = undefined,
@@ -189,6 +194,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
189
194
  nextIcon,
190
195
  showPreviousNextNavigation,
191
196
  showPanelNavigation,
197
+ showPanelTabs,
192
198
  spaceBetweenSlideAndPreviousNextNavigation
193
199
  } = themeTokens;
194
200
 
@@ -442,6 +448,9 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
442
448
  return "".concat(copyText[0].toUpperCase()).concat(copyText.slice(1));
443
449
  }, [activeIndex, childrenArray.length, itemLabel, getCopy, title]);
444
450
 
451
+ const activePanelNavigation = tabs && showPanelTabs ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselTabsPanel.default, {
452
+ items: tabs
453
+ }) : panelNavigation;
445
454
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CarouselContext.CarouselProvider, {
446
455
  activeIndex: activeIndex,
447
456
  goTo: goTo,
@@ -517,7 +526,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
517
526
  accessibilityLabel: getCopyWithPlaceholders('iconButtonLabel').replace('%{targetStep}', activeIndex + 2)
518
527
  })
519
528
  })]
520
- }), showPanelNavigation ? panelNavigation : null]
529
+ }), showPanelNavigation ? activePanelNavigation : null]
521
530
  });
522
531
  });
523
532
 
@@ -599,6 +608,13 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
599
608
  */
600
609
  skipLinkHref: _propTypes.default.string,
601
610
 
611
+ /**
612
+ * If provided, defaults the navigation panel to a CarouselTabsPanel element passing each item as props for one tab.
613
+ *
614
+ * Be careful to ensure that the order of each element in the items array matches the order of each child in the Carousel.
615
+ */
616
+ tabs: _propTypes.default.arrayOf(_propTypes.default.shape(_CarouselTabsPanelItem.default.propTypes || {})),
617
+
602
618
  /**
603
619
  * If true, whenever a new slide comes into view, the focus of the Carousel switches to the start.
604
620
  *
@@ -13,8 +13,6 @@ var _utils = require("../../utils");
13
13
 
14
14
  var _Carousel = _interopRequireDefault(require("../Carousel"));
15
15
 
16
- var _CarouselTabsPanel = _interopRequireDefault(require("./CarouselTabsPanel"));
17
-
18
16
  var _jsxRuntime = require("react/jsx-runtime");
19
17
 
20
18
  var _CarouselTabs$propTyp, _CarouselTabs$propTyp2;
@@ -25,22 +23,23 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
25
23
 
26
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
25
 
26
+ /**
27
+ * @deprecated Please use Carousel and pass the `tabs` prop.
28
+ */
28
29
  const CarouselTabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
29
30
  let {
30
31
  items,
31
32
  refocus = true,
32
33
  ...carouselProps
33
34
  } = _ref;
34
- const panelNavigation = (0, _utils.useResponsiveProp)({
35
- md: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CarouselTabsPanel.default, {
36
- items: items
37
- })
35
+ const tabs = (0, _utils.useResponsiveProp)({
36
+ md: items
38
37
  });
39
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Carousel.default, {
40
39
  refocus: refocus,
41
40
  ...carouselProps,
42
41
  ref: ref,
43
- panelNavigation: panelNavigation,
42
+ tabs: tabs,
44
43
  children: items.map(_ref2 => {
45
44
  let {
46
45
  title,
@@ -219,6 +219,14 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
219
219
  const {
220
220
  themeOptions
221
221
  } = (0, _ThemeProvider.useTheme)();
222
+ const selectedProps = selectProps({
223
+ accessibilityRole: 'checkbox',
224
+ accessibilityState: {
225
+ checked: isChecked,
226
+ disabled: inactive
227
+ },
228
+ ...rest
229
+ });
222
230
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
223
231
  style: staticStyles.wrapper,
224
232
  ref: ref,
@@ -229,12 +237,7 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
229
237
  disabled: inactive,
230
238
  onKeyDown: handleKeyDown,
231
239
  onPress: handleChange,
232
- accessibilityRole: "checkbox",
233
- accessibilityState: {
234
- checked: isChecked,
235
- disabled: inactive
236
- },
237
- ...selectProps(rest),
240
+ ...selectedProps,
238
241
  children: _ref6 => {
239
242
  let {
240
243
  focused: focus,
@@ -85,12 +85,13 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
85
85
  ...rest
86
86
  } = _ref3;
87
87
  const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ExpandCollapseControl', tokens, variant);
88
- const selectedProps = selectProps({ ...rest,
89
- accessibilityRole
88
+ const selectedProps = selectProps({
89
+ accessibilityRole,
90
+ ...rest,
91
+ accessibilityState: { ...(rest.accessibilityState || {}),
92
+ expanded: isExpanded
93
+ }
90
94
  });
91
- selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
92
- expanded: isExpanded
93
- };
94
95
 
95
96
  const getControlState = _ref4 => {
96
97
  let {
@@ -77,10 +77,11 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
77
77
  } = _ref2;
78
78
  const [containerHeight, setContainerHeight] = (0, _react.useState)(null);
79
79
  const isExpanded = openIds.includes(panelId);
80
- const selectedProps = selectProps(rest);
81
- selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
82
- expanded: isExpanded
83
- };
80
+ const selectedProps = selectProps({ ...rest,
81
+ accessibilityState: { ...(rest.accessibilityState || {}),
82
+ expanded: isExpanded
83
+ }
84
+ });
84
85
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('ExpandCollapsePanel', tokens, variant, {
85
86
  expanded: isExpanded
86
87
  });
@@ -7,13 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
11
-
12
- var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
-
14
- var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
-
16
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _ListItemBase = _interopRequireDefault(require("./ListItemBase"));
17
11
 
18
12
  var _ThemeProvider = require("../ThemeProvider");
19
13
 
@@ -27,248 +21,28 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
21
 
28
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
23
 
30
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
31
-
32
- const selectBulletStyles = _ref => {
33
- let {
34
- itemBulletWidth,
35
- itemBulletHeight,
36
- itemBulletColor
37
- } = _ref;
38
- return {
39
- width: itemBulletWidth,
40
- height: itemBulletHeight,
41
- borderRadius: itemBulletHeight / 2,
42
- backgroundColor: itemBulletColor
43
- };
44
- };
45
-
46
- const selectBulletContainerStyles = _ref2 => {
47
- let {
48
- itemBulletContainerWidth,
49
- itemBulletContainerAlign
50
- } = _ref2;
51
- return {
52
- width: itemBulletContainerWidth,
53
- alignItems: itemBulletContainerAlign
54
- };
55
- };
56
-
57
- const selectItemIconTokens = _ref3 => {
58
- let {
59
- itemIconSize,
60
- itemIconColor
61
- } = _ref3;
62
- return {
63
- size: itemIconSize,
64
- color: itemIconColor
65
- };
66
- };
67
-
68
- const selectSideItemContainerStyles = _ref4 => {
69
- let {
70
- listGutter,
71
- iconMarginTop
72
- } = _ref4;
73
- return {
74
- marginTop: iconMarginTop,
75
- marginRight: listGutter
76
- };
77
- }; // Align bullets with the top line of text the same way icons are aligned
78
-
79
-
80
- const selectBulletPositioningStyles = _ref5 => {
81
- let {
82
- itemIconSize
83
- } = _ref5;
84
- return {
85
- width: itemIconSize,
86
- height: itemIconSize
87
- };
88
- };
89
-
90
- const selectItemStyles = (_ref6, themeOptions) => {
91
- let {
92
- itemFontWeight,
93
- itemFontSize,
94
- itemLineHeight,
95
- itemFontName
96
- } = _ref6;
97
- return (0, _ThemeProvider.applyTextStyles)({
98
- fontWeight: itemFontWeight,
99
- fontSize: itemFontSize,
100
- lineHeight: itemLineHeight,
101
- fontName: itemFontName,
102
- themeOptions
103
- });
104
- };
105
-
106
- const selectItemBlockStyles = _ref7 => {
107
- let {
108
- interItemMargin
109
- } = _ref7;
110
- return {
111
- marginBottom: interItemMargin
112
- };
113
- };
114
-
115
- const selectDividerStyles = _ref8 => {
116
- let {
117
- dividerColor,
118
- dividerSize,
119
- interItemMarginWithDivider
120
- } = _ref8;
121
- return {
122
- borderBottomWidth: dividerSize,
123
- borderColor: dividerColor,
124
- marginBottom: interItemMarginWithDivider,
125
- paddingBottom: interItemMarginWithDivider
126
- };
127
- };
128
24
  /**
129
25
  * ListItem is responsible for rendering icon or a bullet as side item
130
26
  */
131
-
132
-
133
- const ListItem = /*#__PURE__*/(0, _react.forwardRef)((_ref9, ref) => {
27
+ const ListItem = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
134
28
  let {
135
29
  tokens,
136
30
  variant,
137
- icon,
138
- iconColor,
139
- iconSize,
140
- showDivider,
141
31
  children,
142
- isLastItem,
143
- accessibilityRole = _Platform.default.select({
144
- web: 'listitem',
145
- default: undefined
146
- }),
147
- ...rest
148
- } = _ref9;
32
+ ...listItemProps
33
+ } = _ref;
149
34
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('List', tokens, variant);
150
- const {
151
- themeOptions
152
- } = (0, _ThemeProvider.useTheme)();
153
- const itemStyles = selectItemStyles(themeTokens, themeOptions);
154
- const itemBlockStyles = selectItemBlockStyles(themeTokens);
155
- const dividerStyles = selectDividerStyles(themeTokens);
156
- const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
157
- const itemBulletStyles = selectBulletStyles(themeTokens);
158
- const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
159
- const iconTokens = selectItemIconTokens(themeTokens);
160
- const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
161
-
162
- const renderItem = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
163
- style: staticStyles.wrap,
164
- children: (0, _utils.wrapStringsInText)(children, {
165
- style: itemStyles
166
- })
167
- });
168
- /**
169
- * Function responsible returning styling, in case the item is the last shouldn't
170
- * add extra margin on the bottom, if "showDivider" is true it should add a divider
171
- * and custom margin and padding, otherwise just adds a margin to the bottom
172
- */
173
-
174
-
175
- const getContainerStyle = () => {
176
- if (isLastItem) {
177
- return undefined;
178
- }
179
-
180
- if (showDivider) {
181
- return dividerStyles;
182
- }
183
-
184
- return itemBlockStyles;
185
- };
186
- /**
187
- * Renders item bullet or Icon in case it's defined
188
- * in case children are string the icon is centered otherwise
189
- * it will align itself at start of the container
190
- */
191
-
192
-
193
- const renderMarker = () => {
194
- const IconComponent = icon || /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
195
-
196
- if (icon) {
197
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
198
- style: sideItemContainerStyles,
199
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, {
200
- size: iconSize || iconTokens.size,
201
- color: iconColor || iconTokens.color
202
- })
203
- });
204
- }
205
-
206
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
207
- style: [sideItemContainerStyles, itemBulletContainerStyles],
208
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
209
- style: [staticStyles.bulletPositioning, itemBulletPositioningStyles],
210
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
211
- style: itemBulletStyles,
212
- testID: "unordered-item-bullet"
213
- })
214
- })
215
- });
216
- };
217
-
218
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemBase.default, {
36
+ tokens: themeTokens,
219
37
  ref: ref,
220
- style: [staticStyles.itemContainer, getContainerStyle()],
221
- accessibilityRole: accessibilityRole,
222
- ...selectProps(rest),
223
- children: [renderMarker(), renderItem()]
38
+ ...listItemProps,
39
+ children: children
224
40
  });
225
41
  });
226
42
  ListItem.displayName = 'ListItem';
227
-
228
- const staticStyles = _StyleSheet.default.create({
229
- itemContainer: {
230
- flexDirection: 'row'
231
- },
232
- wrap: {
233
- flex: 1
234
- },
235
- bulletPositioning: {
236
- alignItems: 'center',
237
- justifyContent: 'center'
238
- }
239
- });
240
-
241
- ListItem.propTypes = { ...selectedSystemPropTypes,
242
- tokens: (0, _utils.getTokensPropType)('List'),
43
+ ListItem.propTypes = {
243
44
  variant: _utils.variantProp.propType,
244
- children: _propTypes.default.node.isRequired,
245
-
246
- /**
247
- * Renders side item icon
248
- */
249
- icon: _propTypes.default.elementType,
250
-
251
- /**
252
- * Will set display icon color
253
- */
254
- iconColor: _propTypes.default.string,
255
-
256
- /**
257
- * Allow the user define the icon size if not defined the theme's file
258
- */
259
- iconSize: _propTypes.default.number,
260
-
261
- /**
262
- * @ignore
263
- * Defined by parent if it's last item on the list
264
- */
265
- isLastItem: _propTypes.default.bool,
266
-
267
- /**
268
- * @ignore
269
- * In case it is not the last item allow display divider
270
- */
271
- showDivider: _propTypes.default.bool
45
+ ..._ListItemBase.default.propTypes
272
46
  };
273
47
  var _default = ListItem;
274
48
  exports.default = _default;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
11
+
12
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
+
14
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
+
16
+ var _propTypes = _interopRequireDefault(require("prop-types"));
17
+
18
+ var _utils = require("../utils");
19
+
20
+ var _ListItemContent = _interopRequireDefault(require("./ListItemContent"));
21
+
22
+ var _ListItemMark = _interopRequireDefault(require("./ListItemMark"));
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
32
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
33
+
34
+ const selectItemBlockStyles = _ref => {
35
+ let {
36
+ interItemMargin
37
+ } = _ref;
38
+ return {
39
+ marginBottom: interItemMargin
40
+ };
41
+ };
42
+
43
+ const selectDividerStyles = _ref2 => {
44
+ let {
45
+ dividerColor,
46
+ dividerSize,
47
+ interItemMarginWithDivider
48
+ } = _ref2;
49
+ return {
50
+ borderBottomWidth: dividerSize,
51
+ borderColor: dividerColor,
52
+ marginBottom: interItemMarginWithDivider,
53
+ paddingBottom: interItemMarginWithDivider
54
+ };
55
+ };
56
+ /**
57
+ * ListItem is responsible for rendering icon or a bullet as side item
58
+ */
59
+
60
+
61
+ const ListItemBase = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
62
+ let {
63
+ tokens,
64
+ icon,
65
+ iconColor,
66
+ iconSize,
67
+ showDivider,
68
+ children,
69
+ isLastItem,
70
+ accessibilityRole = _Platform.default.select({
71
+ web: 'listitem',
72
+ default: undefined
73
+ }),
74
+ ...rest
75
+ } = _ref3;
76
+ const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
77
+ const itemBlockStyles = selectItemBlockStyles(themeTokens);
78
+ const dividerStyles = selectDividerStyles(themeTokens);
79
+ /**
80
+ * Function responsible returning styling, in case the item is the last shouldn't
81
+ * add extra margin on the bottom, if "showDivider" is true it should add a divider
82
+ * and custom margin and padding, otherwise just adds a margin to the bottom
83
+ */
84
+
85
+ const getContainerStyle = () => {
86
+ if (isLastItem) {
87
+ return undefined;
88
+ }
89
+
90
+ if (showDivider) {
91
+ return dividerStyles;
92
+ }
93
+
94
+ return itemBlockStyles;
95
+ };
96
+
97
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
98
+ ref: ref,
99
+ style: [staticStyles.itemContainer, getContainerStyle()],
100
+ accessibilityRole: accessibilityRole,
101
+ ...selectProps(rest),
102
+ children: typeof children === 'function' ? children({
103
+ tokens,
104
+ icon,
105
+ iconColor,
106
+ iconSize,
107
+ isLastItem
108
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
109
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemMark.default, {
110
+ tokens: tokens,
111
+ icon: icon,
112
+ iconColor: iconColor,
113
+ iconSize: iconSize
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemContent.default, {
115
+ tokens: tokens,
116
+ children: children
117
+ })]
118
+ })
119
+ });
120
+ });
121
+ ListItemBase.displayName = 'ListItem';
122
+
123
+ const staticStyles = _StyleSheet.default.create({
124
+ itemContainer: {
125
+ flexDirection: 'row'
126
+ }
127
+ });
128
+
129
+ ListItemBase.propTypes = { ...selectedSystemPropTypes,
130
+ tokens: (0, _utils.getTokensPropType)('List'),
131
+ variant: _utils.variantProp.propType,
132
+ children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
133
+
134
+ /**
135
+ * Renders side item icon
136
+ */
137
+ icon: _propTypes.default.elementType,
138
+
139
+ /**
140
+ * Will set display icon color
141
+ */
142
+ iconColor: _propTypes.default.string,
143
+
144
+ /**
145
+ * Allow the user define the icon size if not defined the theme's file
146
+ */
147
+ iconSize: _propTypes.default.number,
148
+
149
+ /**
150
+ * @ignore
151
+ * Defined by parent if it's last item on the list
152
+ */
153
+ isLastItem: _propTypes.default.bool,
154
+
155
+ /**
156
+ * @ignore
157
+ * In case it is not the last item allow display divider
158
+ */
159
+ showDivider: _propTypes.default.bool
160
+ };
161
+ var _default = ListItemBase;
162
+ exports.default = _default;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tokenTypes = exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
13
+
14
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
+
16
+ var _utils = require("../utils");
17
+
18
+ var _ThemeProvider = require("../ThemeProvider");
19
+
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ const tokenTypes = {
25
+ itemFontWeight: _propTypes.default.string.isRequired,
26
+ itemFontSize: _propTypes.default.number.isRequired,
27
+ itemLineHeight: _propTypes.default.number.isRequired,
28
+ itemFontName: _propTypes.default.string.isRequired
29
+ };
30
+ exports.tokenTypes = tokenTypes;
31
+
32
+ const selectItemTextStyles = (_ref, themeOptions) => {
33
+ let {
34
+ itemFontWeight,
35
+ itemFontSize,
36
+ itemLineHeight,
37
+ itemFontName
38
+ } = _ref;
39
+ return (0, _ThemeProvider.applyTextStyles)({
40
+ fontWeight: itemFontWeight,
41
+ fontSize: itemFontSize,
42
+ lineHeight: itemLineHeight,
43
+ fontName: itemFontName,
44
+ themeOptions
45
+ });
46
+ };
47
+ /**
48
+ * Subcomponent used within ListItem and similar components for rendering content that fills
49
+ * and wraps available space in a { flexDirection: row } container alongside a ListIconMark,
50
+ * and that applies text styles to strings via supplied tokens.
51
+ *
52
+ * It's the responsibility of themes to make sure that these text tokens align the first line of
53
+ * text nicely against the bullet or icon rendered by ListIconMark.
54
+ */
55
+
56
+
57
+ const ListItemContent = _ref2 => {
58
+ let {
59
+ tokens,
60
+ children
61
+ } = _ref2;
62
+ const {
63
+ themeOptions
64
+ } = (0, _ThemeProvider.useTheme)();
65
+ const textStyles = selectItemTextStyles(tokens, themeOptions);
66
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
67
+ style: staticStyles.wrap,
68
+ children: (0, _utils.wrapStringsInText)(children, {
69
+ style: textStyles
70
+ })
71
+ });
72
+ };
73
+
74
+ const staticStyles = _StyleSheet.default.create({
75
+ wrap: {
76
+ flex: 1
77
+ }
78
+ });
79
+
80
+ ListItemContent.propTypes = {
81
+ tokens: _propTypes.default.shape(tokenTypes).isRequired,
82
+ children: _propTypes.default.node.isRequired
83
+ };
84
+ var _default = ListItemContent;
85
+ exports.default = _default;