@telus-uds/components-base 1.10.0 → 1.12.1
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 +37 -3
- package/component-docs.json +413 -62
- package/lib/BaseProvider/index.js +7 -2
- package/lib/Button/ButtonBase.js +18 -14
- package/lib/Carousel/Carousel.js +92 -71
- package/lib/Carousel/CarouselContext.js +12 -4
- package/lib/Carousel/CarouselItem/CarouselItem.js +24 -9
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +56 -0
- package/lib/Carousel/CarouselStepTracker/index.js +13 -0
- package/lib/Carousel/dictionary.js +23 -0
- package/lib/Checkbox/Checkbox.js +7 -3
- package/lib/Checkbox/CheckboxGroup.js +1 -1
- package/lib/Feedback/Feedback.js +18 -10
- package/lib/Icon/IconText.js +5 -0
- package/lib/InputLabel/InputLabel.js +11 -5
- package/lib/InputSupports/InputSupports.js +10 -3
- package/lib/InputSupports/useInputSupports.js +3 -2
- package/lib/Link/LinkBase.js +7 -3
- package/lib/List/ListItem.js +7 -3
- package/lib/Modal/Modal.js +4 -0
- package/lib/Notification/Notification.js +7 -2
- package/lib/Pagination/Pagination.js +7 -3
- package/lib/RadioCard/RadioCard.js +6 -1
- package/lib/Select/Select.js +7 -3
- package/lib/Skeleton/Skeleton.js +1 -0
- package/lib/StepTracker/Step.js +8 -4
- package/lib/StepTracker/StepTracker.js +17 -13
- package/lib/Tabs/TabsItem.js +4 -0
- package/lib/TextInput/TextInput.js +3 -1
- package/lib/TextInput/TextInputBase.js +7 -3
- package/lib/ThemeProvider/ThemeProvider.js +20 -3
- package/lib/ThemeProvider/utils/styles.js +8 -1
- package/lib/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib/Typography/Typography.js +6 -2
- package/lib/index.js +9 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/props/clickProps.js +2 -2
- package/lib/utils/props/handlerProps.js +77 -31
- package/lib/utils/useScrollBlocking.js +66 -0
- package/lib/utils/useScrollBlocking.native.js +11 -0
- package/lib-module/BaseProvider/index.js +7 -2
- package/lib-module/Button/ButtonBase.js +7 -3
- package/lib-module/Carousel/Carousel.js +85 -70
- package/lib-module/Carousel/CarouselContext.js +11 -4
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +25 -10
- package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +42 -0
- package/lib-module/Carousel/CarouselStepTracker/index.js +2 -0
- package/lib-module/Carousel/dictionary.js +16 -0
- package/lib-module/Checkbox/Checkbox.js +8 -4
- package/lib-module/Checkbox/CheckboxGroup.js +1 -1
- package/lib-module/Feedback/Feedback.js +19 -11
- package/lib-module/Icon/IconText.js +5 -0
- package/lib-module/InputLabel/InputLabel.js +12 -6
- package/lib-module/InputSupports/InputSupports.js +10 -3
- package/lib-module/InputSupports/useInputSupports.js +3 -2
- package/lib-module/Link/LinkBase.js +8 -4
- package/lib-module/List/ListItem.js +8 -4
- package/lib-module/Modal/Modal.js +3 -0
- package/lib-module/Notification/Notification.js +8 -3
- package/lib-module/Pagination/Pagination.js +8 -4
- package/lib-module/RadioCard/RadioCard.js +7 -2
- package/lib-module/Select/Select.js +8 -4
- package/lib-module/Skeleton/Skeleton.js +1 -0
- package/lib-module/StepTracker/Step.js +9 -5
- package/lib-module/StepTracker/StepTracker.js +17 -14
- package/lib-module/Tabs/TabsItem.js +5 -1
- package/lib-module/TextInput/TextInput.js +3 -1
- package/lib-module/TextInput/TextInputBase.js +8 -4
- package/lib-module/ThemeProvider/ThemeProvider.js +20 -3
- package/lib-module/ThemeProvider/utils/styles.js +8 -1
- package/lib-module/ThemeProvider/utils/theme-tokens.js +1 -1
- package/lib-module/Typography/Typography.js +7 -3
- package/lib-module/index.js +1 -0
- package/lib-module/utils/index.js +1 -0
- package/lib-module/utils/props/clickProps.js +2 -2
- package/lib-module/utils/props/handlerProps.js +78 -31
- package/lib-module/utils/useScrollBlocking.js +58 -0
- package/lib-module/utils/useScrollBlocking.native.js +2 -0
- package/package.json +3 -3
- package/src/BaseProvider/index.jsx +6 -3
- package/src/Button/ButtonBase.jsx +8 -3
- package/src/Carousel/Carousel.jsx +106 -74
- package/src/Carousel/CarouselContext.jsx +15 -4
- package/src/Carousel/CarouselItem/CarouselItem.jsx +26 -8
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +36 -0
- package/src/Carousel/CarouselStepTracker/index.js +3 -0
- package/src/Carousel/dictionary.js +16 -0
- package/src/Checkbox/Checkbox.jsx +14 -11
- package/src/Checkbox/CheckboxGroup.jsx +1 -1
- package/src/Feedback/Feedback.jsx +14 -7
- package/src/Icon/IconText.jsx +2 -0
- package/src/InputLabel/InputLabel.jsx +13 -12
- package/src/InputSupports/InputSupports.jsx +18 -3
- package/src/InputSupports/useInputSupports.js +2 -2
- package/src/Link/LinkBase.jsx +10 -4
- package/src/List/ListItem.jsx +9 -4
- package/src/Modal/Modal.jsx +3 -1
- package/src/Notification/Notification.jsx +5 -3
- package/src/Pagination/Pagination.jsx +6 -4
- package/src/RadioCard/RadioCard.jsx +3 -2
- package/src/Select/Select.jsx +12 -3
- package/src/Skeleton/Skeleton.jsx +1 -0
- package/src/StepTracker/Step.jsx +12 -4
- package/src/StepTracker/StepTracker.jsx +20 -13
- package/src/Tabs/TabsItem.jsx +3 -2
- package/src/TextInput/TextInput.jsx +1 -1
- package/src/TextInput/TextInputBase.jsx +11 -3
- package/src/ThemeProvider/ThemeProvider.jsx +16 -3
- package/src/ThemeProvider/utils/styles.js +9 -1
- package/src/ThemeProvider/utils/theme-tokens.js +1 -1
- package/src/Typography/Typography.jsx +11 -12
- package/src/index.js +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/props/clickProps.js +2 -2
- package/src/utils/props/handlerProps.js +64 -16
- package/src/utils/useScrollBlocking.js +57 -0
- package/src/utils/useScrollBlocking.native.js +2 -0
|
@@ -28,14 +28,21 @@ function applyTextStyles(_ref) {
|
|
|
28
28
|
fontWeight = '400',
|
|
29
29
|
fontName,
|
|
30
30
|
fontStyle = 'normal',
|
|
31
|
+
themeOptions = {
|
|
32
|
+
// TODO: switch `forceAbsoluteFontSizing` to be false by default in the next major version
|
|
33
|
+
forceAbsoluteFontSizing: true
|
|
34
|
+
},
|
|
31
35
|
...rest
|
|
32
36
|
} = _ref;
|
|
33
37
|
const styles = { ...rest
|
|
34
38
|
};
|
|
39
|
+
const {
|
|
40
|
+
forceAbsoluteFontSizing
|
|
41
|
+
} = themeOptions;
|
|
35
42
|
|
|
36
43
|
if (fontSize) {
|
|
37
44
|
// If relative font sizes are needed, catch and calculate them here
|
|
38
|
-
styles.fontSize = fontSize;
|
|
45
|
+
styles.fontSize = _Platform.default.OS === 'web' && !forceAbsoluteFontSizing ? "".concat(fontSize / _systemConstants.fontBasePixels, "rem") : fontSize;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
if (typeof lineHeight === 'number') {
|
|
@@ -194,7 +194,7 @@ const validateThemeTokensVersion = theme => {
|
|
|
194
194
|
const actualThemeTokensVersion = theme === null || theme === void 0 ? void 0 : (_theme$metadata2 = theme.metadata) === null || _theme$metadata2 === void 0 ? void 0 : _theme$metadata2.themeTokensVersion;
|
|
195
195
|
|
|
196
196
|
if (!(0, _satisfies.default)(actualThemeTokensVersion, expectedThemeTokensVersion)) {
|
|
197
|
-
throw new Error("Invalid UDS token schema version detected.\n\nThe UDS base components ".concat(_package.default.name, " v").concat(_package.default.version, " are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ").concat(expectedThemeTokensVersion, ". The current theme was built with @telus-uds/system-theme-tokens v").concat(actualThemeTokensVersion, ".\n\nIf you see this error than most likely you have attempted to install ").concat(_package.default.name, " and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/
|
|
197
|
+
throw new Error("Invalid UDS token schema version detected.\n\nThe UDS base components ".concat(_package.default.name, " v").concat(_package.default.version, " are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ").concat(expectedThemeTokensVersion, ". The current theme was built with @telus-uds/system-theme-tokens v").concat(actualThemeTokensVersion, ".\n\nIf you see this error than most likely you have attempted to install ").concat(_package.default.name, " and a UDS theme manually because you are building a multi-brand application. If you are building a single brand application, consider installing the brand specific design system package such as @telus-uds/ds-allium. For more information, see https://github.com/telus/universal-design-system/blob/main/docs/docs/multi-brand-usage.md"));
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
|
|
@@ -35,7 +35,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
35
35
|
const [selectContainerProps, selectedContainerPropTypes] = (0, _utils2.selectSystemProps)([_utils2.a11yProps, _utils2.viewProps]);
|
|
36
36
|
const [selectTextProps, selectedTextPropTypes] = (0, _utils2.selectSystemProps)([_utils2.textProps]);
|
|
37
37
|
|
|
38
|
-
const selectTextStyles = _ref => {
|
|
38
|
+
const selectTextStyles = (_ref, themeOptions) => {
|
|
39
39
|
let {
|
|
40
40
|
fontWeight,
|
|
41
41
|
fontSize,
|
|
@@ -52,6 +52,7 @@ const selectTextStyles = _ref => {
|
|
|
52
52
|
color,
|
|
53
53
|
lineHeight,
|
|
54
54
|
fontName,
|
|
55
|
+
themeOptions,
|
|
55
56
|
textAlign,
|
|
56
57
|
textTransform,
|
|
57
58
|
letterSpacing
|
|
@@ -76,10 +77,13 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
76
77
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Typography', tokens, variant, {
|
|
77
78
|
viewport
|
|
78
79
|
});
|
|
80
|
+
const {
|
|
81
|
+
themeOptions
|
|
82
|
+
} = (0, _ThemeProvider.useTheme)();
|
|
79
83
|
const resolvedTextProps = { ...selectTextProps(rest),
|
|
80
84
|
style: selectTextStyles(align ? { ...themeTokens,
|
|
81
85
|
textAlign: align
|
|
82
|
-
} : themeTokens),
|
|
86
|
+
} : themeTokens, themeOptions),
|
|
83
87
|
dataSet,
|
|
84
88
|
maxFontSizeMultiplier: (0, _utils2.getMaxFontMultiplier)(themeTokens)
|
|
85
89
|
};
|
package/lib/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var _exportNames = {
|
|
|
20
20
|
Icon: true,
|
|
21
21
|
IconButton: true,
|
|
22
22
|
InputLabel: true,
|
|
23
|
+
InputSupports: true,
|
|
23
24
|
List: true,
|
|
24
25
|
ListItem: true,
|
|
25
26
|
ListBase: true,
|
|
@@ -158,6 +159,12 @@ Object.defineProperty(exports, "InputLabel", {
|
|
|
158
159
|
return _InputLabel.default;
|
|
159
160
|
}
|
|
160
161
|
});
|
|
162
|
+
Object.defineProperty(exports, "InputSupports", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return _InputSupports.default;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
161
168
|
Object.defineProperty(exports, "List", {
|
|
162
169
|
enumerable: true,
|
|
163
170
|
get: function () {
|
|
@@ -455,6 +462,8 @@ var _IconButton = _interopRequireDefault(require("./IconButton"));
|
|
|
455
462
|
|
|
456
463
|
var _InputLabel = _interopRequireDefault(require("./InputLabel"));
|
|
457
464
|
|
|
465
|
+
var _InputSupports = _interopRequireDefault(require("./InputSupports"));
|
|
466
|
+
|
|
458
467
|
var _Link = require("./Link");
|
|
459
468
|
|
|
460
469
|
Object.keys(_Link).forEach(function (key) {
|
package/lib/utils/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var _exportNames = {
|
|
|
9
9
|
useHash: true,
|
|
10
10
|
useSpacingScale: true,
|
|
11
11
|
useResponsiveProp: true,
|
|
12
|
+
useScrollBlocking: true,
|
|
12
13
|
useUniqueId: true,
|
|
13
14
|
withLinkRouter: true,
|
|
14
15
|
containUniqueFields: true
|
|
@@ -43,6 +44,12 @@ Object.defineProperty(exports, "useResponsiveProp", {
|
|
|
43
44
|
return _useResponsiveProp.default;
|
|
44
45
|
}
|
|
45
46
|
});
|
|
47
|
+
Object.defineProperty(exports, "useScrollBlocking", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return _useScrollBlocking.default;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
46
53
|
Object.defineProperty(exports, "useSpacingScale", {
|
|
47
54
|
enumerable: true,
|
|
48
55
|
get: function () {
|
|
@@ -168,6 +175,8 @@ Object.keys(_useResponsiveProp).forEach(function (key) {
|
|
|
168
175
|
});
|
|
169
176
|
});
|
|
170
177
|
|
|
178
|
+
var _useScrollBlocking = _interopRequireDefault(require("./useScrollBlocking"));
|
|
179
|
+
|
|
171
180
|
var _useUniqueId = _interopRequireDefault(require("./useUniqueId"));
|
|
172
181
|
|
|
173
182
|
var _withLinkRouter = _interopRequireDefault(require("./withLinkRouter"));
|
|
@@ -11,8 +11,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
|
|
12
12
|
const clickHandlerMapping = {
|
|
13
13
|
onClick: 'onPress',
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
onMouseDown: 'onPressIn',
|
|
15
|
+
onMouseUp: 'onPressOut'
|
|
16
16
|
};
|
|
17
17
|
var _default = {
|
|
18
18
|
/**
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.textInputHandlerProps = exports.focusHandlerProps =
|
|
6
|
+
exports.textInputHandlerProps = exports.focusHandlerProps = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
|
+
|
|
12
|
+
var _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
16
|
const focusHandlerProps = {
|
|
@@ -20,19 +24,10 @@ const focusHandlerProps = {
|
|
|
20
24
|
* onFocus handler
|
|
21
25
|
*/
|
|
22
26
|
onFocus: _propTypes.default.func
|
|
23
|
-
},
|
|
24
|
-
select: _ref => {
|
|
25
|
-
let {
|
|
26
|
-
onBlur,
|
|
27
|
-
onFocus
|
|
28
|
-
} = _ref;
|
|
29
|
-
return {
|
|
30
|
-
onBlur,
|
|
31
|
-
onFocus
|
|
32
|
-
};
|
|
33
27
|
}
|
|
34
28
|
};
|
|
35
29
|
exports.focusHandlerProps = focusHandlerProps;
|
|
30
|
+
focusHandlerProps.select = (0, _getPropSelector.default)(focusHandlerProps.types);
|
|
36
31
|
const textInputHandlerProps = {
|
|
37
32
|
types: {
|
|
38
33
|
/**
|
|
@@ -53,26 +48,77 @@ const textInputHandlerProps = {
|
|
|
53
48
|
/**
|
|
54
49
|
* onSubmitEditing handler
|
|
55
50
|
*/
|
|
56
|
-
onSubmitEditing: _propTypes.default.func
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
onSubmitEditing: _propTypes.default.func,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* onContentSizeChange handler
|
|
55
|
+
*/
|
|
56
|
+
onContentSizeChange: _propTypes.default.func,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* onEndEditing handler
|
|
60
|
+
*/
|
|
61
|
+
onEndEditing: _propTypes.default.func,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* onScroll handler
|
|
65
|
+
*/
|
|
66
|
+
onScroll: _propTypes.default.func,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* onSelectionChange handler
|
|
70
|
+
*/
|
|
71
|
+
onSelectionChange: _propTypes.default.func,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* onKeyPress handler
|
|
75
|
+
*/
|
|
76
|
+
onKeyPress: _propTypes.default.func,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* onKeyUp handler (only supported on Web)
|
|
80
|
+
*/
|
|
81
|
+
onKeyUp: _propTypes.default.func,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* onKeyDown handler (only supported on Web)
|
|
85
|
+
*/
|
|
86
|
+
onKeyDown: _propTypes.default.func
|
|
71
87
|
}
|
|
72
88
|
};
|
|
73
89
|
exports.textInputHandlerProps = textInputHandlerProps;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
const selectTextInputHandlers = (0, _getPropSelector.default)(textInputHandlerProps.types);
|
|
91
|
+
|
|
92
|
+
textInputHandlerProps.select = props => {
|
|
93
|
+
// Support for onKeyPress/onKeyUp/onKeyDown is inconsistent between React Native and React Native Web
|
|
94
|
+
const {
|
|
95
|
+
onKeyPress,
|
|
96
|
+
onKeyUp,
|
|
97
|
+
onKeyDown,
|
|
98
|
+
...resolvedProps
|
|
99
|
+
} = selectTextInputHandlers(props);
|
|
100
|
+
|
|
101
|
+
if (onKeyPress || onKeyUp || onKeyDown) {
|
|
102
|
+
if (_Platform.default.OS !== 'web') {
|
|
103
|
+
// React Native only supports onKeyPress. Call any key handlers supplied in expected order.
|
|
104
|
+
resolvedProps.onKeyPress = event => {
|
|
105
|
+
if (typeof onKeyDown === 'function') onKeyDown(event);
|
|
106
|
+
if (typeof onKeyPress === 'function') onKeyPress(event);
|
|
107
|
+
if (typeof onKeyUp === 'function') onKeyUp(event);
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
// React Native Web supports onKeyUp the normal way.
|
|
111
|
+
if (onKeyUp) resolvedProps.onKeyUp = onKeyUp; // React Native Web doesn't support the `onKeyDown` prop name, but maps a supplied onKeyPress handler
|
|
112
|
+
// to the onKeyDown event and calls it with a keydown event. Make React Native Web call either or both.
|
|
113
|
+
|
|
114
|
+
if (onKeyPress || onKeyDown) {
|
|
115
|
+
resolvedProps.onKeyPress = event => {
|
|
116
|
+
if (typeof onKeyDown === 'function') onKeyDown(event);
|
|
117
|
+
if (typeof onKeyPress === 'function') onKeyPress(event);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return resolvedProps;
|
|
124
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
const addScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
11
|
+
var _ref$current;
|
|
12
|
+
|
|
13
|
+
document.body.addEventListener('touchmove', preventScrolling, {
|
|
14
|
+
passive: false
|
|
15
|
+
});
|
|
16
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addEventListener('touchmove', stopPropagation);
|
|
17
|
+
document.body.style.overflow = 'hidden';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const removeScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
21
|
+
var _ref$current2;
|
|
22
|
+
|
|
23
|
+
document.body.removeEventListener('touchmove', preventScrolling);
|
|
24
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.removeEventListener('touchmove', stopPropagation);
|
|
25
|
+
document.body.style.overflow = 'inherit';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Disables scrolling when passed `true` or an array where all items are `true`.
|
|
29
|
+
*
|
|
30
|
+
* Returns an optional callback ref. Pass this to an element if it or its children
|
|
31
|
+
* should allow touch-based scrolling within that element's bounds.
|
|
32
|
+
*
|
|
33
|
+
* @param {boolean | boolean[]} conditionProps
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const useScrollBlocking = conditionProps => {
|
|
39
|
+
// useRef refs are null on first render and don't trigger a re-render when they get their
|
|
40
|
+
// element. Force re-run when ref mounts to ensure the stopPropagation listener is attached.
|
|
41
|
+
const ref = (0, _react.useRef)();
|
|
42
|
+
const [refIsMounted, setRefIsMounted] = (0, _react.useState)(false);
|
|
43
|
+
const callbackRef = (0, _react.useCallback)(element => {
|
|
44
|
+
ref.current = element;
|
|
45
|
+
setRefIsMounted(Boolean(element));
|
|
46
|
+
}, []);
|
|
47
|
+
const conditionsMet = Array.isArray(conditionProps) ? conditionProps.every(condition => condition) : Boolean(conditionProps);
|
|
48
|
+
const preventScrolling = (0, _react.useCallback)(event => event.preventDefault(), []);
|
|
49
|
+
const stopPropagation = (0, _react.useCallback)(event => event.stopPropagation(), []);
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
const cleanup = () => removeScrollBlocking(preventScrolling, stopPropagation, ref);
|
|
52
|
+
|
|
53
|
+
if (conditionsMet) {
|
|
54
|
+
addScrollBlocking(preventScrolling, stopPropagation, ref);
|
|
55
|
+
} else {
|
|
56
|
+
cleanup();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return cleanup; // preventScrolling and stopPropagation are stable callbacks with no deps, so this
|
|
60
|
+
// will re-run when conditionsMet or refIsMounted flip between true and false.
|
|
61
|
+
}, [preventScrolling, conditionsMet, stopPropagation, refIsMounted]);
|
|
62
|
+
return callbackRef;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var _default = useScrollBlocking;
|
|
66
|
+
exports.default = _default;
|
|
@@ -10,12 +10,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
10
10
|
const BaseProvider = _ref => {
|
|
11
11
|
let {
|
|
12
12
|
defaultTheme,
|
|
13
|
-
children
|
|
13
|
+
children,
|
|
14
|
+
themeOptions
|
|
14
15
|
} = _ref;
|
|
15
16
|
return /*#__PURE__*/_jsx(A11yInfoProvider, {
|
|
16
17
|
children: /*#__PURE__*/_jsx(ViewportProvider, {
|
|
17
18
|
children: /*#__PURE__*/_jsx(ThemeProvider, {
|
|
18
19
|
defaultTheme: defaultTheme,
|
|
20
|
+
themeOptions: themeOptions,
|
|
19
21
|
children: children
|
|
20
22
|
})
|
|
21
23
|
})
|
|
@@ -23,7 +25,10 @@ const BaseProvider = _ref => {
|
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
BaseProvider.propTypes = {
|
|
28
|
+
children: PropTypes.node.isRequired,
|
|
26
29
|
defaultTheme: (_ThemeProvider$propTy = ThemeProvider.propTypes) === null || _ThemeProvider$propTy === void 0 ? void 0 : _ThemeProvider$propTy.defaultTheme,
|
|
27
|
-
|
|
30
|
+
themeOptions: PropTypes.shape({
|
|
31
|
+
forceAbsoluteFontSizing: PropTypes.bool
|
|
32
|
+
})
|
|
28
33
|
};
|
|
29
34
|
export default BaseProvider;
|
|
@@ -4,7 +4,7 @@ import Pressable from "react-native-web/dist/exports/Pressable";
|
|
|
4
4
|
import View from "react-native-web/dist/exports/View";
|
|
5
5
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
6
6
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
7
|
-
import { applyTextStyles, applyShadowToken, applyOuterBorder } from '../ThemeProvider
|
|
7
|
+
import { applyTextStyles, applyShadowToken, applyOuterBorder, useTheme } from '../ThemeProvider';
|
|
8
8
|
import buttonPropTypes from './propTypes';
|
|
9
9
|
import { a11yProps, clickProps, focusHandlerProps, getCursorStyle, linkProps, resolvePressableState, resolvePressableTokens, selectSystemProps, viewProps, wrapStringsInText, withLinkRouter } from '../utils';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -131,7 +131,7 @@ const selectBorderStyles = _ref5 => {
|
|
|
131
131
|
};
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
const selectTextStyles = _ref6 => {
|
|
134
|
+
const selectTextStyles = (_ref6, themeOptions) => {
|
|
135
135
|
let {
|
|
136
136
|
fontSize,
|
|
137
137
|
color,
|
|
@@ -146,6 +146,7 @@ const selectTextStyles = _ref6 => {
|
|
|
146
146
|
lineHeight,
|
|
147
147
|
fontName,
|
|
148
148
|
fontWeight,
|
|
149
|
+
themeOptions,
|
|
149
150
|
textAlign
|
|
150
151
|
});
|
|
151
152
|
};
|
|
@@ -197,6 +198,9 @@ const ButtonBase = /*#__PURE__*/forwardRef((_ref8, ref) => {
|
|
|
197
198
|
return [staticStyles.row, selectWebOnlyStyles(inactive, themeTokens, systemProps), selectOuterContainerStyles(themeTokens), selectOuterWidthStyles(themeTokens)];
|
|
198
199
|
};
|
|
199
200
|
|
|
201
|
+
const {
|
|
202
|
+
themeOptions
|
|
203
|
+
} = useTheme();
|
|
200
204
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
201
205
|
ref: ref,
|
|
202
206
|
href: href,
|
|
@@ -212,7 +216,7 @@ const ButtonBase = /*#__PURE__*/forwardRef((_ref8, ref) => {
|
|
|
212
216
|
const themeTokens = resolveButtonTokens(pressableState);
|
|
213
217
|
const containerStyles = selectInnerContainerStyles(themeTokens);
|
|
214
218
|
const borderStyles = selectBorderStyles(themeTokens);
|
|
215
|
-
const textStyles = [selectTextStyles(themeTokens), staticStyles.text]; // If the container has a width set, fill it instead of sizing from content.
|
|
219
|
+
const textStyles = [selectTextStyles(themeTokens, themeOptions), staticStyles.text]; // If the container has a width set, fill it instead of sizing from content.
|
|
216
220
|
// If in future we support text alignments other than center, add here.
|
|
217
221
|
|
|
218
222
|
const stretchStyles = themeTokens.width ? staticStyles.stretch : staticStyles.align;
|