@telus-uds/components-base 1.95.0 → 1.97.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 +42 -2
- package/lib/Autocomplete/Autocomplete.js +36 -2
- package/lib/Card/CardBase.js +4 -0
- package/lib/Carousel/Carousel.js +1 -1
- package/lib/Carousel/CarouselItem/CarouselItem.js +15 -19
- package/lib/InputLabel/InputLabel.js +2 -3
- package/lib/List/ListItemBase.js +3 -1
- package/lib/Listbox/GroupControl.js +4 -0
- package/lib/Modal/Modal.js +34 -13
- package/lib/Modal/ModalContent.js +4 -3
- package/lib/Modal/WebModal.js +1 -0
- package/lib/Notification/Notification.js +5 -5
- package/lib/Pagination/Pagination.js +9 -2
- package/lib/Pagination/constants.js +12 -0
- package/lib/Pagination/usePagination.js +13 -3
- package/lib/PriceLockup/PriceLockup.js +11 -3
- package/lib/Progress/Progress.js +5 -2
- package/lib/Progress/ProgressBar.js +4 -1
- package/lib/Tooltip/Tooltip.native.js +31 -3
- package/lib/Tooltip/shared.js +5 -0
- package/lib/Typography/Typography.js +42 -19
- package/lib/index.js +7 -0
- package/lib-module/Autocomplete/Autocomplete.js +36 -2
- package/lib-module/Card/CardBase.js +4 -0
- package/lib-module/Carousel/Carousel.js +1 -1
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +15 -19
- package/lib-module/InputLabel/InputLabel.js +2 -3
- package/lib-module/List/ListItemBase.js +3 -1
- package/lib-module/Listbox/GroupControl.js +4 -0
- package/lib-module/Modal/Modal.js +34 -13
- package/lib-module/Modal/ModalContent.js +4 -3
- package/lib-module/Modal/WebModal.js +1 -0
- package/lib-module/Notification/Notification.js +5 -5
- package/lib-module/Pagination/Pagination.js +9 -2
- package/lib-module/Pagination/constants.js +3 -0
- package/lib-module/Pagination/usePagination.js +13 -3
- package/lib-module/PriceLockup/PriceLockup.js +11 -3
- package/lib-module/Progress/Progress.js +6 -3
- package/lib-module/Progress/ProgressBar.js +5 -2
- package/lib-module/Tooltip/Tooltip.native.js +31 -3
- package/lib-module/Tooltip/shared.js +5 -0
- package/lib-module/Typography/Typography.js +42 -19
- package/lib-module/index.js +1 -1
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +41 -2
- package/src/Card/CardBase.jsx +6 -0
- package/src/Carousel/Carousel.jsx +1 -1
- package/src/Carousel/CarouselItem/CarouselItem.jsx +16 -22
- package/src/InputLabel/InputLabel.jsx +2 -3
- package/src/List/ListItemBase.jsx +6 -1
- package/src/Listbox/GroupControl.jsx +6 -1
- package/src/Modal/Modal.jsx +40 -14
- package/src/Modal/ModalContent.jsx +4 -3
- package/src/Modal/WebModal.jsx +1 -1
- package/src/Notification/Notification.jsx +5 -5
- package/src/Pagination/Pagination.jsx +9 -2
- package/src/Pagination/constants.js +3 -0
- package/src/Pagination/usePagination.js +14 -3
- package/src/PriceLockup/PriceLockup.jsx +9 -1
- package/src/Progress/Progress.jsx +6 -3
- package/src/Progress/ProgressBar.jsx +4 -2
- package/src/Tooltip/Tooltip.native.jsx +31 -3
- package/src/Tooltip/shared.js +5 -0
- package/src/Typography/Typography.jsx +37 -13
- package/src/index.js +2 -1
- package/types/FileUpload.d.ts +40 -0
- package/types/index.d.ts +3 -0
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
10
10
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
12
|
var _ThemeProvider = require("../ThemeProvider");
|
|
12
13
|
var _utils = require("../ThemeProvider/utils");
|
|
13
14
|
var _utils2 = require("../utils");
|
|
@@ -45,9 +46,22 @@ const selectTextStyles = (_ref, themeOptions) => {
|
|
|
45
46
|
gradient
|
|
46
47
|
});
|
|
47
48
|
};
|
|
49
|
+
const HALF_FONT_SIZE = 2;
|
|
50
|
+
const QUARTER_FONT_SIZE = 4;
|
|
51
|
+
const selectMobileSubSupStyles = (_ref2, type) => {
|
|
52
|
+
let {
|
|
53
|
+
fontSize
|
|
54
|
+
} = _ref2;
|
|
55
|
+
return {
|
|
56
|
+
fontSize: fontSize / HALF_FONT_SIZE,
|
|
57
|
+
lineHeight: fontSize,
|
|
58
|
+
position: 'relative',
|
|
59
|
+
top: type === 'sub' ? fontSize / QUARTER_FONT_SIZE : -fontSize / QUARTER_FONT_SIZE
|
|
60
|
+
};
|
|
61
|
+
};
|
|
48
62
|
|
|
49
63
|
// General-purpose flexible theme-neutral base component for text
|
|
50
|
-
const Typography = /*#__PURE__*/_react.default.forwardRef((
|
|
64
|
+
const Typography = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
51
65
|
let {
|
|
52
66
|
children,
|
|
53
67
|
variant,
|
|
@@ -60,7 +74,7 @@ const Typography = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
60
74
|
dataSet,
|
|
61
75
|
strikeThrough = false,
|
|
62
76
|
...rest
|
|
63
|
-
} =
|
|
77
|
+
} = _ref3;
|
|
64
78
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
65
79
|
const {
|
|
66
80
|
themeOptions
|
|
@@ -107,8 +121,8 @@ const Typography = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
107
121
|
let textStyles;
|
|
108
122
|
let mediaIds;
|
|
109
123
|
if (enableMediaQueryStyleSheet) {
|
|
110
|
-
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc,
|
|
111
|
-
let [vp, viewportTokens] =
|
|
124
|
+
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref4) => {
|
|
125
|
+
let [vp, viewportTokens] = _ref4;
|
|
112
126
|
acc[vp] = selectTextStyles({
|
|
113
127
|
textAlign: align,
|
|
114
128
|
textDecorationLine,
|
|
@@ -142,22 +156,31 @@ const Typography = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
142
156
|
...selectContainerProps(rest)
|
|
143
157
|
};
|
|
144
158
|
const resetTagStyling = child => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const supFontSize = childStyles.fontSize ?? themeTokens.superScriptFontSize;
|
|
149
|
-
const sanitizedChild = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
150
|
-
style: {
|
|
151
|
-
...childStyles,
|
|
152
|
-
...(supFontSize ? {
|
|
153
|
-
fontSize: supFontSize
|
|
154
|
-
} : {}),
|
|
155
|
-
lineHeight: 0
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return sanitizedChild;
|
|
159
|
+
var _child$props;
|
|
160
|
+
if (typeof child !== 'object' || !((child === null || child === void 0 ? void 0 : child.type) === 'sub' || (child === null || child === void 0 ? void 0 : child.type) === 'sup')) {
|
|
161
|
+
return child;
|
|
159
162
|
}
|
|
160
|
-
|
|
163
|
+
const childStyles = (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.style) || {};
|
|
164
|
+
const supFontSize = childStyles.fontSize ?? themeTokens.superScriptFontSize;
|
|
165
|
+
const isMobile = _Platform.default.OS === 'ios' || _Platform.default.OS === 'android';
|
|
166
|
+
const isSubSup = (child === null || child === void 0 ? void 0 : child.type) === 'sub' || (child === null || child === void 0 ? void 0 : child.type) === 'sup';
|
|
167
|
+
const mobileStyles = isMobile && isSubSup ? selectMobileSubSupStyles(themeTokens, child === null || child === void 0 ? void 0 : child.type) : {};
|
|
168
|
+
const defaultStyles = !isMobile && isSubSup ? {
|
|
169
|
+
fontSize: supFontSize,
|
|
170
|
+
lineHeight: 0
|
|
171
|
+
} : {};
|
|
172
|
+
const sanitizedChild = /*#__PURE__*/_react.default.cloneElement(isMobile && isSubSup ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
173
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
174
|
+
style: [childStyles, mobileStyles],
|
|
175
|
+
children: child.props.children
|
|
176
|
+
})
|
|
177
|
+
}) : child, {
|
|
178
|
+
style: {
|
|
179
|
+
...childStyles,
|
|
180
|
+
...defaultStyles
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return sanitizedChild;
|
|
161
184
|
};
|
|
162
185
|
const sanitizeChildren = () => {
|
|
163
186
|
if (Array.isArray(children)) {
|
package/lib/index.js
CHANGED
|
@@ -82,6 +82,7 @@ var _exportNames = {
|
|
|
82
82
|
applyOuterBorder: true,
|
|
83
83
|
applyTextStyles: true,
|
|
84
84
|
applyShadowToken: true,
|
|
85
|
+
useResponsiveThemeTokens: true,
|
|
85
86
|
Portal: true
|
|
86
87
|
};
|
|
87
88
|
Object.defineProperty(exports, "A11yInfoProvider", {
|
|
@@ -528,6 +529,12 @@ Object.defineProperty(exports, "useHydrationContext", {
|
|
|
528
529
|
return _HydrationContext.useHydrationContext;
|
|
529
530
|
}
|
|
530
531
|
});
|
|
532
|
+
Object.defineProperty(exports, "useResponsiveThemeTokens", {
|
|
533
|
+
enumerable: true,
|
|
534
|
+
get: function () {
|
|
535
|
+
return _ThemeProvider.useResponsiveThemeTokens;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
531
538
|
Object.defineProperty(exports, "useSetTheme", {
|
|
532
539
|
enumerable: true,
|
|
533
540
|
get: function () {
|
|
@@ -139,6 +139,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
139
139
|
|
|
140
140
|
// When it's nested, selected value
|
|
141
141
|
const [nestedSelectedValue, setNestedSelectedValue] = React.useState(null);
|
|
142
|
+
const [isInputVisible, setIsInputVisible] = React.useState(true);
|
|
142
143
|
const {
|
|
143
144
|
supportsProps,
|
|
144
145
|
...selectedProps
|
|
@@ -264,6 +265,27 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
264
265
|
}));
|
|
265
266
|
}
|
|
266
267
|
}, [nestedSelectedValue, items]);
|
|
268
|
+
React.useEffect(() => {
|
|
269
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
const observer = new IntersectionObserver(entries => {
|
|
273
|
+
const [entry] = entries;
|
|
274
|
+
setIsInputVisible(entry.isIntersecting);
|
|
275
|
+
if (!entry.isIntersecting) {
|
|
276
|
+
setIsExpanded(false);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const currentInputRef = inputRef.current;
|
|
280
|
+
if (currentInputRef) {
|
|
281
|
+
observer.observe(currentInputRef);
|
|
282
|
+
}
|
|
283
|
+
return () => {
|
|
284
|
+
if (currentInputRef) {
|
|
285
|
+
observer.unobserve(currentInputRef);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}, [inputRef]);
|
|
267
289
|
const handleClose = event => {
|
|
268
290
|
var _openOverlayRef$curre, _openOverlayRef$curre2;
|
|
269
291
|
if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target)) || event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
@@ -320,7 +342,19 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
320
342
|
readOnly: readOnly,
|
|
321
343
|
ref: inputRef,
|
|
322
344
|
...(Platform.OS !== 'web' ? {
|
|
323
|
-
onLayout: event =>
|
|
345
|
+
onLayout: event => {
|
|
346
|
+
setSourceLayout(event.nativeEvent.layout);
|
|
347
|
+
const {
|
|
348
|
+
y,
|
|
349
|
+
height
|
|
350
|
+
} = event.nativeEvent.layout;
|
|
351
|
+
if (y >= 0 && height > 0) {
|
|
352
|
+
setIsInputVisible(true);
|
|
353
|
+
} else {
|
|
354
|
+
setIsInputVisible(false);
|
|
355
|
+
setIsExpanded(false);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
324
358
|
} : {}),
|
|
325
359
|
tokens: inputTokens,
|
|
326
360
|
validation: validation,
|
|
@@ -333,7 +367,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
333
367
|
})
|
|
334
368
|
});
|
|
335
369
|
}
|
|
336
|
-
}), (isExpanded || hintExpansionEnabled) && /*#__PURE__*/_jsxs(_Fragment, {
|
|
370
|
+
}), (isExpanded || hintExpansionEnabled) && isInputVisible && /*#__PURE__*/_jsxs(_Fragment, {
|
|
337
371
|
children: [/*#__PURE__*/_jsx(Listbox.Overlay, {
|
|
338
372
|
overlaidPosition: overlaidPosition,
|
|
339
373
|
isReady: isReady,
|
|
@@ -24,6 +24,7 @@ const selectStyles = _ref => {
|
|
|
24
24
|
paddingTop,
|
|
25
25
|
minWidth,
|
|
26
26
|
shadow,
|
|
27
|
+
backgroundGradient,
|
|
27
28
|
gradient
|
|
28
29
|
} = _ref;
|
|
29
30
|
return {
|
|
@@ -43,6 +44,9 @@ const selectStyles = _ref => {
|
|
|
43
44
|
backgroundOrigin: `border-box`,
|
|
44
45
|
boxShadow: `inset 0 1000px white`,
|
|
45
46
|
border: `${borderWidth}px solid transparent`
|
|
47
|
+
} : {}),
|
|
48
|
+
...(backgroundGradient && Platform.OS === 'web' ? {
|
|
49
|
+
backgroundImage: `linear-gradient(${backgroundGradient.angle}deg, ${backgroundGradient.stops[0].color}, ${backgroundGradient.stops[1].color})`
|
|
46
50
|
} : {})
|
|
47
51
|
};
|
|
48
52
|
};
|
|
@@ -100,7 +100,7 @@ const selectPreviousNextNavigationButtonStyles = (previousNextNavigationButtonWi
|
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
const getPeekingProps = viewport => {
|
|
103
|
-
if (viewport === 'xs' || viewport === 'sm') {
|
|
103
|
+
if (viewport === 'xs' || viewport === 'sm' || viewport === 'md') {
|
|
104
104
|
return {
|
|
105
105
|
peekingFirstSpace: 48,
|
|
106
106
|
peekingGap: 16,
|
|
@@ -14,39 +14,35 @@ const selectContainerStyle = _ref => {
|
|
|
14
14
|
totalItems,
|
|
15
15
|
enablePeeking,
|
|
16
16
|
peekingMarginLeft,
|
|
17
|
-
peekingMarginRight,
|
|
18
17
|
peekingFirstSpace,
|
|
19
18
|
peekingLastSpace,
|
|
20
19
|
peekingMiddleSpace,
|
|
21
20
|
peekingGap,
|
|
22
21
|
hidden
|
|
23
22
|
} = _ref;
|
|
24
|
-
const isFirst = elementIndex === 0;
|
|
25
|
-
const isLast = elementIndex === totalItems - 1;
|
|
26
|
-
const isMiddle = !isFirst && !isLast;
|
|
27
|
-
const isActive = activeIndex === elementIndex;
|
|
28
23
|
let adjustedWidth = width;
|
|
29
24
|
let marginLeft = 0;
|
|
30
|
-
|
|
25
|
+
const marginRight = 0;
|
|
31
26
|
if (enablePeeking) {
|
|
27
|
+
adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace);
|
|
28
|
+
const isFirst = elementIndex === 0;
|
|
29
|
+
const isActive = activeIndex === elementIndex;
|
|
32
30
|
if (isActive) {
|
|
33
|
-
|
|
34
|
-
} else if (isMiddle) {
|
|
35
|
-
adjustedWidth = width - peekingGap;
|
|
36
|
-
}
|
|
37
|
-
if (isFirst) {
|
|
38
|
-
if (isActive) {
|
|
31
|
+
if (isFirst) {
|
|
39
32
|
marginLeft = peekingMarginLeft;
|
|
40
|
-
} else if (activeIndex === totalItems - 1) {
|
|
41
|
-
marginLeft = peekingLastSpace;
|
|
42
33
|
} else {
|
|
43
|
-
marginLeft =
|
|
34
|
+
marginLeft = peekingGap;
|
|
35
|
+
}
|
|
36
|
+
} else if (isFirst) {
|
|
37
|
+
marginLeft = peekingMarginLeft + peekingGap + peekingFirstSpace + peekingMiddleSpace;
|
|
38
|
+
if (activeIndex > 1) {
|
|
39
|
+
marginLeft += (peekingGap + peekingMiddleSpace * 2) * (activeIndex - 1);
|
|
40
|
+
}
|
|
41
|
+
if (activeIndex === totalItems - 1) {
|
|
42
|
+
marginLeft += peekingLastSpace - peekingMiddleSpace;
|
|
44
43
|
}
|
|
45
|
-
}
|
|
46
|
-
if (isLast && isActive) {
|
|
47
|
-
marginRight = peekingMarginRight;
|
|
48
44
|
} else {
|
|
49
|
-
|
|
45
|
+
marginLeft = peekingGap;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
const style = {
|
|
@@ -129,8 +129,7 @@ export default InputLabel;
|
|
|
129
129
|
const staticStyles = StyleSheet.create({
|
|
130
130
|
container: {
|
|
131
131
|
flexShrink: 1,
|
|
132
|
-
flexDirection: 'row'
|
|
133
|
-
alignItems: 'baseline'
|
|
132
|
+
flexDirection: 'row'
|
|
134
133
|
},
|
|
135
134
|
label: {
|
|
136
135
|
flexShrink: 1
|
|
@@ -140,7 +139,7 @@ const staticStyles = StyleSheet.create({
|
|
|
140
139
|
flexShrink: 0
|
|
141
140
|
},
|
|
142
141
|
tooltipAlign: {
|
|
143
|
-
alignSelf: '
|
|
142
|
+
alignSelf: 'center',
|
|
144
143
|
justifyContent: 'center'
|
|
145
144
|
}
|
|
146
145
|
});
|
|
@@ -56,6 +56,9 @@ const GroupControl = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
56
56
|
itemOutline,
|
|
57
57
|
groupHeight
|
|
58
58
|
} = tokens;
|
|
59
|
+
const getTextStyles = () => ({
|
|
60
|
+
color: groupColor
|
|
61
|
+
});
|
|
59
62
|
return /*#__PURE__*/_jsxs(View, {
|
|
60
63
|
onPress: () => setSelectedId(id),
|
|
61
64
|
style: [styles.controlWrapper, {
|
|
@@ -75,6 +78,7 @@ const GroupControl = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
75
78
|
}],
|
|
76
79
|
ref: ref,
|
|
77
80
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
81
|
+
style: getTextStyles(),
|
|
78
82
|
children: label
|
|
79
83
|
}), /*#__PURE__*/_jsx(Spacer, {
|
|
80
84
|
space: 1,
|
|
@@ -99,6 +99,7 @@ const selectScrollViewStyles = () => ({
|
|
|
99
99
|
* - Don’t use modals consecutively
|
|
100
100
|
*/
|
|
101
101
|
const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
102
|
+
var _modalContentRef$curr2;
|
|
102
103
|
let {
|
|
103
104
|
children,
|
|
104
105
|
isOpen,
|
|
@@ -127,6 +128,8 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
127
128
|
maxWidth
|
|
128
129
|
});
|
|
129
130
|
const modalRef = useScrollBlocking(isOpen);
|
|
131
|
+
const modalBodyRef = React.useRef(ref);
|
|
132
|
+
const modalContentRef = React.useRef(null);
|
|
130
133
|
const {
|
|
131
134
|
closeIcon: CloseIconComponent
|
|
132
135
|
} = themeTokens;
|
|
@@ -141,6 +144,25 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
141
144
|
const handleKeyUp = event => {
|
|
142
145
|
if (event.key === 'Escape') onClose();
|
|
143
146
|
};
|
|
147
|
+
const manageFocus = React.useCallback(event => {
|
|
148
|
+
if (event.key === 'Tab') {
|
|
149
|
+
var _modalBodyRef$current;
|
|
150
|
+
const focusableElements = Array.from(modalBodyRef === null || modalBodyRef === void 0 ? void 0 : (_modalBodyRef$current = modalBodyRef.current) === null || _modalBodyRef$current === void 0 ? void 0 : _modalBodyRef$current.querySelectorAll(`
|
|
151
|
+
a[href], button, textarea, input, select,
|
|
152
|
+
[tabindex]:not([tabindex="-1"]),
|
|
153
|
+
[contenteditable="true"]
|
|
154
|
+
`));
|
|
155
|
+
const firstElement = focusableElements[0];
|
|
156
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
157
|
+
if (event.shiftKey && document.activeElement === firstElement) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
lastElement.focus();
|
|
160
|
+
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
firstElement.focus();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, [modalBodyRef]);
|
|
144
166
|
|
|
145
167
|
// Show the custom react node passed to `closedButton` or the default close button if `closeButton` is `undefined`.
|
|
146
168
|
// Hide the close button if `closeButton` is `null`.
|
|
@@ -151,22 +173,20 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
151
173
|
const closeButtonRef = React.useRef(null);
|
|
152
174
|
React.useEffect(() => {
|
|
153
175
|
if (Platform.OS === 'web') {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (document.activeElement === focusTrapRef.current && closeButtonRef.current) {
|
|
157
|
-
closeButtonRef.current.focus();
|
|
158
|
-
}
|
|
159
|
-
return undefined;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// Add an event listener to manage focus in the web modal container
|
|
163
|
-
document.addEventListener('focusin', handleFocus);
|
|
176
|
+
// Add an event listener to manage keydown and focus in the web modal container
|
|
177
|
+
document.addEventListener('keydown', manageFocus);
|
|
164
178
|
|
|
165
179
|
// Clean up the event listener
|
|
166
|
-
return () => document.removeEventListener('
|
|
180
|
+
return () => document.removeEventListener('keydown', manageFocus);
|
|
167
181
|
}
|
|
168
182
|
return undefined;
|
|
169
|
-
}, []);
|
|
183
|
+
}, [manageFocus]);
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
if (isOpen) {
|
|
186
|
+
var _modalContentRef$curr;
|
|
187
|
+
modalContentRef === null || modalContentRef === void 0 ? void 0 : (_modalContentRef$curr = modalContentRef.current) === null || _modalContentRef$curr === void 0 ? void 0 : _modalContentRef$curr.focus();
|
|
188
|
+
}
|
|
189
|
+
}, [isOpen, modalContentRef === null || modalContentRef === void 0 ? void 0 : (_modalContentRef$curr2 = modalContentRef.current) === null || _modalContentRef$curr2 === void 0 ? void 0 : _modalContentRef$curr2.focus]);
|
|
170
190
|
if (!isOpen) {
|
|
171
191
|
return null;
|
|
172
192
|
}
|
|
@@ -179,7 +199,7 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
179
199
|
pointerEvents: "box-none" // don't capture backdrop press events
|
|
180
200
|
,
|
|
181
201
|
children: /*#__PURE__*/_jsxs(View, {
|
|
182
|
-
ref:
|
|
202
|
+
ref: modalBodyRef,
|
|
183
203
|
style: [staticStyles.modal, selectModalStyles(themeTokens)],
|
|
184
204
|
onKeyUp: handleKeyUp,
|
|
185
205
|
children: [showCloseButton && /*#__PURE__*/_jsx(View, {
|
|
@@ -224,6 +244,7 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
224
244
|
if (Platform.OS === 'web') {
|
|
225
245
|
return /*#__PURE__*/_jsxs(WebModal, {
|
|
226
246
|
...selectProps(rest),
|
|
247
|
+
ref: modalContentRef,
|
|
227
248
|
children: [content, /*#__PURE__*/_jsx(View, {
|
|
228
249
|
accessibilityRole: "button",
|
|
229
250
|
ref: focusTrapRef
|
|
@@ -66,6 +66,7 @@ const ModalContent = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
66
66
|
borderColor,
|
|
67
67
|
gap,
|
|
68
68
|
direction,
|
|
69
|
+
footerTopWidth,
|
|
69
70
|
hasBorder
|
|
70
71
|
} = _ref3;
|
|
71
72
|
return {
|
|
@@ -77,8 +78,8 @@ const ModalContent = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
77
78
|
paddingLeft,
|
|
78
79
|
paddingRight,
|
|
79
80
|
paddingTop,
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
borderTopWidth: footerTopWidth > 0 ? footerTopWidth : hasBorder && 1 || 0,
|
|
82
|
+
borderTopColor: borderColor
|
|
82
83
|
};
|
|
83
84
|
};
|
|
84
85
|
const headingStyles = {
|
|
@@ -156,7 +157,7 @@ const styles = StyleSheet.create({
|
|
|
156
157
|
minHeight: Platform.OS === 'web' ? '100%' : 'auto'
|
|
157
158
|
},
|
|
158
159
|
cancelButton: {
|
|
159
|
-
|
|
160
|
+
display: 'flex'
|
|
160
161
|
}
|
|
161
162
|
});
|
|
162
163
|
ModalContent.propTypes = {
|
|
@@ -24,6 +24,7 @@ const WebModal = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
24
24
|
children: /*#__PURE__*/_jsx(View, {
|
|
25
25
|
style: staticStyles.container,
|
|
26
26
|
...selectProps(rest),
|
|
27
|
+
focusable: true,
|
|
27
28
|
ref: ref,
|
|
28
29
|
children: /*#__PURE__*/_jsx("div", {
|
|
29
30
|
style: staticStyles.content,
|
|
@@ -99,19 +99,19 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
|
|
|
99
99
|
justifyContent: 'space-between',
|
|
100
100
|
...createMediaQueryStyles({
|
|
101
101
|
xs: {
|
|
102
|
-
|
|
102
|
+
maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content = themeOptions.contentMaxWidth) === null || _themeOptions$content === void 0 ? void 0 : _themeOptions$content.xs) || '100%'
|
|
103
103
|
},
|
|
104
104
|
md: {
|
|
105
|
-
|
|
105
|
+
maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content2 = themeOptions.contentMaxWidth) === null || _themeOptions$content2 === void 0 ? void 0 : _themeOptions$content2.md) || '100%'
|
|
106
106
|
},
|
|
107
107
|
lg: {
|
|
108
|
-
|
|
108
|
+
maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content3 = themeOptions.contentMaxWidth) === null || _themeOptions$content3 === void 0 ? void 0 : _themeOptions$content3.lg) || '100%'
|
|
109
109
|
},
|
|
110
110
|
sm: {
|
|
111
|
-
|
|
111
|
+
maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content4 = themeOptions.contentMaxWidth) === null || _themeOptions$content4 === void 0 ? void 0 : _themeOptions$content4.sm) || '100%'
|
|
112
112
|
},
|
|
113
113
|
xl: {
|
|
114
|
-
|
|
114
|
+
maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content5 = themeOptions.contentMaxWidth) === null || _themeOptions$content5 === void 0 ? void 0 : _themeOptions$content5.xl) || '100%'
|
|
115
115
|
}
|
|
116
116
|
})
|
|
117
117
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import View from "react-native-web/dist/exports/View";
|
|
3
4
|
import Text from "react-native-web/dist/exports/Text";
|
|
4
5
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
@@ -39,6 +40,7 @@ const Pagination = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
39
40
|
sideButtonTokens,
|
|
40
41
|
LinkRouter,
|
|
41
42
|
linkRouterProps,
|
|
43
|
+
numberOfPagesBeforeEllipsis = 4,
|
|
42
44
|
...rest
|
|
43
45
|
} = _ref2;
|
|
44
46
|
const viewport = useViewport();
|
|
@@ -78,7 +80,8 @@ const Pagination = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
78
80
|
shouldRenderEllipsis
|
|
79
81
|
} = usePagination({
|
|
80
82
|
items,
|
|
81
|
-
truncateAbove
|
|
83
|
+
truncateAbove,
|
|
84
|
+
numberOfPagesBeforeEllipsis
|
|
82
85
|
});
|
|
83
86
|
const ellipsisTextStyles = selectTextStyles(themeTokens, themeOptions);
|
|
84
87
|
const ellipisContainerStyles = StyleSheet.create({
|
|
@@ -199,7 +202,11 @@ Pagination.propTypes = {
|
|
|
199
202
|
/**
|
|
200
203
|
* Custom tokens for `PaginationSideButton`
|
|
201
204
|
*/
|
|
202
|
-
sideButtonTokens: getTokensPropType('PaginationSideButton')
|
|
205
|
+
sideButtonTokens: getTokensPropType('PaginationSideButton'),
|
|
206
|
+
/**
|
|
207
|
+
* The number of pages before the ellipsis is shown
|
|
208
|
+
*/
|
|
209
|
+
numberOfPagesBeforeEllipsis: PropTypes.number
|
|
203
210
|
};
|
|
204
211
|
const staticStyles = StyleSheet.create({
|
|
205
212
|
container: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { DEFAULT_PAGE_TO_SHOW_VALUE, MIN_PAGES_TO_SHOW, TRUNCATE_ABOVE_VALUE } from './constants';
|
|
1
2
|
/**
|
|
2
3
|
* Handles configurable truncating of pagination items.
|
|
3
4
|
*
|
|
4
5
|
* @param {object} props
|
|
5
6
|
* @param {React.Element[]} items
|
|
6
7
|
* @param {number} truncateAbove
|
|
8
|
+
* @param {number} numberOfPagesBeforeEllipsis
|
|
7
9
|
*/
|
|
8
10
|
function usePagination(_ref) {
|
|
9
11
|
let {
|
|
10
12
|
items,
|
|
11
|
-
truncateAbove
|
|
13
|
+
truncateAbove,
|
|
14
|
+
numberOfPagesBeforeEllipsis
|
|
12
15
|
} = _ref;
|
|
13
16
|
const activeItemIndex = Math.max(items.findIndex(item => item.props.isActive), 0 // default to the first item if none is marked as active
|
|
14
17
|
);
|
|
@@ -30,8 +33,15 @@ function usePagination(_ref) {
|
|
|
30
33
|
tokens
|
|
31
34
|
};
|
|
32
35
|
};
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
let windowSize;
|
|
37
|
+
if (numberOfPagesBeforeEllipsis >= 1 && numberOfPagesBeforeEllipsis < items.length) {
|
|
38
|
+
windowSize = numberOfPagesBeforeEllipsis;
|
|
39
|
+
} else if (truncateAbove > TRUNCATE_ABOVE_VALUE) {
|
|
40
|
+
windowSize = MIN_PAGES_TO_SHOW;
|
|
41
|
+
} else {
|
|
42
|
+
windowSize = DEFAULT_PAGE_TO_SHOW_VALUE;
|
|
43
|
+
}
|
|
44
|
+
const truncateEnabled = items.length > windowSize;
|
|
35
45
|
const truncateWindowStart = windowSize;
|
|
36
46
|
const truncateWindowEnd = items.length - 1 - windowSize;
|
|
37
47
|
|
|
@@ -87,7 +87,15 @@ const selectBottomTextTypographyTokens = _ref6 => {
|
|
|
87
87
|
lineHeight: bottomTextLineHeight
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
|
-
const
|
|
90
|
+
const selectContainertokens = _ref7 => {
|
|
91
|
+
let {
|
|
92
|
+
alignItemsText
|
|
93
|
+
} = _ref7;
|
|
94
|
+
return {
|
|
95
|
+
alignItems: alignItemsText
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const PriceLockup = /*#__PURE__*/React.forwardRef((_ref8, ref) => {
|
|
91
99
|
let {
|
|
92
100
|
size = 'medium',
|
|
93
101
|
signDirection = 'left',
|
|
@@ -104,7 +112,7 @@ const PriceLockup = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
|
104
112
|
tokens: priceLockupTokens,
|
|
105
113
|
variant = {},
|
|
106
114
|
...rest
|
|
107
|
-
} =
|
|
115
|
+
} = _ref8;
|
|
108
116
|
const viewport = useViewport();
|
|
109
117
|
const {
|
|
110
118
|
footnoteMarginTop,
|
|
@@ -129,7 +137,7 @@ const PriceLockup = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
|
129
137
|
const topTextTypographyTokens = selectTopTextTypographyTokens(themeTokens);
|
|
130
138
|
const bottomTextTypographyTokens = selectBottomTextTypographyTokens(themeTokens);
|
|
131
139
|
return /*#__PURE__*/_jsxs(View, {
|
|
132
|
-
style: [staticStyles.priceLockupContainer],
|
|
140
|
+
style: [staticStyles.priceLockupContainer, selectContainertokens(themeTokens)],
|
|
133
141
|
ref: ref,
|
|
134
142
|
...selectProps(rest),
|
|
135
143
|
children: [topText ? /*#__PURE__*/_jsx(View, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
|
-
import { useThemeTokens } from '../ThemeProvider';
|
|
4
|
+
import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
|
|
5
5
|
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
@@ -11,14 +11,16 @@ const selectProgressStyles = _ref => {
|
|
|
11
11
|
borderWidth,
|
|
12
12
|
borderColor,
|
|
13
13
|
borderRadius,
|
|
14
|
-
height
|
|
14
|
+
height,
|
|
15
|
+
shadow
|
|
15
16
|
} = _ref;
|
|
16
17
|
return {
|
|
17
18
|
backgroundColor,
|
|
18
19
|
borderWidth,
|
|
19
20
|
borderColor,
|
|
20
21
|
borderRadius,
|
|
21
|
-
height
|
|
22
|
+
height,
|
|
23
|
+
...applyShadowToken(shadow)
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -38,6 +40,7 @@ const selectProgressStyles = _ref => {
|
|
|
38
40
|
* - `borderRadius` for the rounded corners,
|
|
39
41
|
* - `borderWidth` to change the border width.
|
|
40
42
|
* - `height` to control the height of the progress bars displayed within the progress bar container.
|
|
43
|
+
* - `shadow` to apply a box shadow to the progress bar container.
|
|
41
44
|
*
|
|
42
45
|
* ## Variants
|
|
43
46
|
*
|
|
@@ -4,7 +4,7 @@ import Platform from "react-native-web/dist/exports/Platform";
|
|
|
4
4
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
5
|
import View from "react-native-web/dist/exports/View";
|
|
6
6
|
import ProgressBarBackground from './ProgressBarBackground';
|
|
7
|
-
import { useThemeTokens } from '../ThemeProvider';
|
|
7
|
+
import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
|
|
8
8
|
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
@@ -13,13 +13,15 @@ const selectBarStyles = (_ref, percentage) => {
|
|
|
13
13
|
backgroundColor,
|
|
14
14
|
borderRadius,
|
|
15
15
|
outlineWidth,
|
|
16
|
-
outlineColor
|
|
16
|
+
outlineColor,
|
|
17
|
+
shadow
|
|
17
18
|
} = _ref;
|
|
18
19
|
return {
|
|
19
20
|
backgroundColor,
|
|
20
21
|
borderRadius,
|
|
21
22
|
outlineWidth,
|
|
22
23
|
outlineColor,
|
|
24
|
+
...applyShadowToken(shadow),
|
|
23
25
|
width: `${percentage}%`
|
|
24
26
|
};
|
|
25
27
|
};
|
|
@@ -39,6 +41,7 @@ const selectBarStyles = (_ref, percentage) => {
|
|
|
39
41
|
* - `borderRadius` for the rounded corners,
|
|
40
42
|
* - `outlineColor` to control the color of the border (outline),
|
|
41
43
|
* - `outlineWidth` to change the outline width.
|
|
44
|
+
* - `shadow` to apply a box shadow to the progress bar.
|
|
42
45
|
*
|
|
43
46
|
* ## Variants
|
|
44
47
|
*
|