@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.
- package/CHANGELOG.md +33 -2
- package/__tests17__/A11yText/A11yText.test.jsx +34 -0
- package/__tests17__/ActivityIndicator/ActivityIndicator.test.jsx +68 -0
- package/__tests17__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +299 -0
- package/__tests17__/Box/Box.test.jsx +111 -0
- package/__tests17__/Button/Button.test.jsx +86 -0
- package/__tests17__/Button/ButtonBase.test.jsx +82 -0
- package/__tests17__/Button/ButtonGroup.test.jsx +347 -0
- package/__tests17__/Button/ButtonLink.test.jsx +61 -0
- package/__tests17__/Card/Card.test.jsx +63 -0
- package/__tests17__/Carousel/Carousel.test.jsx +128 -0
- package/__tests17__/Carousel/CarouselTabs.test.jsx +142 -0
- package/__tests17__/Checkbox/Checkbox.test.jsx +94 -0
- package/__tests17__/Checkbox/CheckboxGroup.test.jsx +246 -0
- package/__tests17__/Divider/Divider.test.jsx +91 -0
- package/__tests17__/ExpandCollapse/ExpandCollapse.test.jsx +109 -0
- package/__tests17__/Feedback/Feedback.test.jsx +42 -0
- package/__tests17__/FlexGrid/Col.test.jsx +261 -0
- package/__tests17__/FlexGrid/FlexGrid.test.jsx +136 -0
- package/__tests17__/FlexGrid/Row.test.jsx +273 -0
- package/__tests17__/HorizontalScroll/HorizontalScroll.test.jsx +165 -0
- package/__tests17__/Icon/Icon.test.jsx +61 -0
- package/__tests17__/IconButton/IconButton.test.jsx +52 -0
- package/__tests17__/InputLabel/InputLabel.test.jsx +28 -0
- package/__tests17__/InputLabel/__snapshots__/InputLabel.test.jsx.snap +3 -0
- package/__tests17__/InputSupports/InputSupports.test.jsx +60 -0
- package/__tests17__/Link/Link.test.jsx +63 -0
- package/__tests17__/Link/TextButton.test.jsx +35 -0
- package/__tests17__/List/List.test.jsx +82 -0
- package/__tests17__/Modal/Modal.test.jsx +47 -0
- package/__tests17__/Notification/Notification.test.jsx +20 -0
- package/__tests17__/Pagination/Pagination.test.jsx +160 -0
- package/__tests17__/Progress/Progress.test.jsx +79 -0
- package/__tests17__/Radio/Radio.test.jsx +87 -0
- package/__tests17__/Radio/RadioGroup.test.jsx +220 -0
- package/__tests17__/RadioCard/RadioCard.test.jsx +87 -0
- package/__tests17__/RadioCard/RadioCardGroup.test.jsx +246 -0
- package/__tests17__/Search/Search.test.jsx +87 -0
- package/__tests17__/Select/Select.test.jsx +94 -0
- package/__tests17__/SideNav/SideNav.test.jsx +110 -0
- package/__tests17__/Skeleton/Skeleton.test.jsx +61 -0
- package/__tests17__/SkipLink/SkipLink.test.jsx +61 -0
- package/__tests17__/Spacer/Spacer.test.jsx +63 -0
- package/__tests17__/StackView/StackView.test.jsx +211 -0
- package/__tests17__/StackView/StackWrap.test.jsx +47 -0
- package/__tests17__/StackView/getStackedContent.test.jsx +295 -0
- package/__tests17__/StepTracker/StepTracker.test.jsx +108 -0
- package/__tests17__/Tabs/Tabs.test.jsx +49 -0
- package/__tests17__/Tags/Tags.test.jsx +327 -0
- package/__tests17__/TextInput/TextArea.test.jsx +35 -0
- package/__tests17__/TextInput/TextInputBase.test.jsx +125 -0
- package/__tests17__/ThemeProvider/ThemeProvider.test.jsx +80 -0
- package/__tests17__/ThemeProvider/useThemeTokens.test.jsx +514 -0
- package/__tests17__/ThemeProvider/utils/theme-tokens.test.js +41 -0
- package/__tests17__/ToggleSwitch/ToggleSwitch.test.jsx +82 -0
- package/__tests17__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
- package/__tests17__/Tooltip/Tooltip.test.jsx +65 -0
- package/__tests17__/Tooltip/getTooltipPosition.test.js +79 -0
- package/__tests17__/Typography/typography.test.jsx +90 -0
- package/__tests17__/utils/children.test.jsx +128 -0
- package/__tests17__/utils/containUniqueFields.test.js +25 -0
- package/__tests17__/utils/input.test.js +375 -0
- package/__tests17__/utils/props.test.js +36 -0
- package/__tests17__/utils/semantics.test.jsx +34 -0
- package/__tests17__/utils/useCopy.test.js +42 -0
- package/__tests17__/utils/useResponsiveProp.test.jsx +202 -0
- package/__tests17__/utils/useSpacingScale.test.jsx +273 -0
- package/__tests17__/utils/useUniqueId.test.js +31 -0
- package/component-docs.json +95 -438
- package/lib/A11yInfoProvider/index.js +14 -5
- package/lib/Button/ButtonGroup.js +3 -2
- package/lib/Checkbox/Checkbox.js +9 -6
- package/lib/ExpandCollapse/Control.js +6 -5
- package/lib/ExpandCollapse/Panel.js +5 -4
- package/lib/List/ListItem.js +10 -236
- package/lib/List/ListItemBase.js +162 -0
- package/lib/List/ListItemContent.js +85 -0
- package/lib/List/ListItemMark.js +158 -0
- package/lib/List/PressableListItemBase.js +147 -0
- package/lib/Notification/Notification.js +2 -1
- package/lib/Pagination/Pagination.js +4 -3
- package/lib/Pagination/SideButton.js +17 -7
- package/lib/Radio/Radio.js +9 -6
- package/lib/RadioCard/RadioCard.js +9 -6
- package/lib/Select/Select.js +1 -0
- package/lib/Tabs/Tabs.js +12 -3
- package/lib/Tags/Tags.js +3 -3
- package/lib/TextInput/TextInput.js +5 -4
- package/lib/ViewportProvider/useViewportListener.js +11 -5
- package/lib/utils/hasOwnProperty.js +18 -0
- package/lib/utils/props/a11yProps.js +212 -45
- package/lib/utils/props/getPropSelector.js +47 -5
- package/lib/utils/ssr.js +116 -1
- package/lib/utils/useResponsiveProp.js +5 -3
- package/lib/utils/withLinkRouter.js +3 -5
- package/lib-module/A11yInfoProvider/index.js +14 -4
- package/lib-module/Button/ButtonGroup.js +3 -2
- package/lib-module/Checkbox/Checkbox.js +9 -6
- package/lib-module/ExpandCollapse/Control.js +6 -5
- package/lib-module/ExpandCollapse/Panel.js +5 -4
- package/lib-module/List/ListItem.js +13 -235
- package/lib-module/List/ListItemBase.js +139 -0
- package/lib-module/List/ListItemContent.js +66 -0
- package/lib-module/List/ListItemMark.js +143 -0
- package/lib-module/List/PressableListItemBase.js +117 -0
- package/lib-module/Notification/Notification.js +2 -1
- package/lib-module/Pagination/Pagination.js +5 -3
- package/lib-module/Pagination/SideButton.js +18 -8
- package/lib-module/Radio/Radio.js +9 -6
- package/lib-module/RadioCard/RadioCard.js +9 -6
- package/lib-module/Select/Select.js +1 -0
- package/lib-module/Tabs/Tabs.js +13 -4
- package/lib-module/Tags/Tags.js +3 -3
- package/lib-module/TextInput/TextInput.js +5 -4
- package/lib-module/ViewportProvider/useViewportListener.js +10 -4
- package/lib-module/utils/hasOwnProperty.js +11 -0
- package/lib-module/utils/props/a11yProps.js +210 -45
- package/lib-module/utils/props/getPropSelector.js +44 -5
- package/lib-module/utils/ssr.js +106 -0
- package/lib-module/utils/useResponsiveProp.js +3 -4
- package/lib-module/utils/withLinkRouter.js +3 -5
- package/package.json +12 -17
- package/src/A11yInfoProvider/index.jsx +20 -4
- package/src/Button/ButtonGroup.jsx +4 -2
- package/src/Checkbox/Checkbox.jsx +7 -3
- package/src/ExpandCollapse/Control.jsx +8 -5
- package/src/ExpandCollapse/Panel.jsx +7 -5
- package/src/List/ListItem.jsx +12 -191
- package/src/List/ListItemBase.jsx +118 -0
- package/src/List/ListItemContent.jsx +52 -0
- package/src/List/ListItemMark.jsx +99 -0
- package/src/List/PressableListItemBase.jsx +102 -0
- package/src/Notification/Notification.jsx +1 -1
- package/src/Pagination/Pagination.jsx +6 -1
- package/src/Pagination/SideButton.jsx +4 -1
- package/src/Radio/Radio.jsx +7 -3
- package/src/RadioCard/RadioCard.jsx +7 -3
- package/src/Select/Select.jsx +1 -1
- package/src/Tabs/Tabs.jsx +19 -2
- package/src/Tags/Tags.jsx +3 -3
- package/src/TextInput/TextInput.jsx +4 -4
- package/src/ViewportProvider/useViewportListener.js +10 -5
- package/src/utils/hasOwnProperty.js +11 -0
- package/src/utils/props/a11yProps.js +168 -55
- package/src/utils/props/getPropSelector.js +45 -4
- package/src/utils/ssr.jsx +124 -0
- package/src/utils/useResponsiveProp.js +3 -3
- package/src/utils/withLinkRouter.jsx +1 -3
- package/src/utils/ssr.js +0 -35
|
@@ -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({
|
|
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
|
-
|
|
82
|
-
|
|
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
|
});
|
package/lib/List/ListItem.js
CHANGED
|
@@ -7,13 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
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
|
-
|
|
143
|
-
|
|
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
|
-
|
|
151
|
-
|
|
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
|
-
|
|
221
|
-
|
|
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
|
-
|
|
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;
|