@telus-uds/components-base 3.5.1 → 3.6.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 +27 -2
- package/lib/cjs/Box/Box.js +53 -7
- package/lib/cjs/Carousel/Carousel.js +34 -47
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +4 -6
- package/lib/cjs/Carousel/Constants.js +5 -2
- package/lib/cjs/ExpandCollapseMini/ExpandCollapseMini.js +5 -0
- package/lib/cjs/ExpandCollapseMini/ExpandCollapseMiniControl.js +17 -26
- package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +8 -2
- package/lib/cjs/Notification/Notification.js +26 -16
- package/lib/cjs/utils/getSpacingScale.js +66 -0
- package/lib/cjs/utils/index.js +9 -1
- package/lib/cjs/utils/useResponsiveProp.js +1 -1
- package/lib/esm/Box/Box.js +55 -9
- package/lib/esm/Carousel/Carousel.js +35 -48
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +4 -6
- package/lib/esm/Carousel/Constants.js +4 -1
- package/lib/esm/ExpandCollapseMini/ExpandCollapseMini.js +5 -0
- package/lib/esm/ExpandCollapseMini/ExpandCollapseMiniControl.js +17 -26
- package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +8 -2
- package/lib/esm/Notification/Notification.js +27 -17
- package/lib/esm/utils/getSpacingScale.js +61 -0
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/useResponsiveProp.js +1 -1
- package/lib/package.json +4 -4
- package/package.json +4 -4
- package/src/Box/Box.jsx +61 -8
- package/src/Carousel/Carousel.jsx +47 -58
- package/src/Carousel/CarouselItem/CarouselItem.jsx +4 -6
- package/src/Carousel/Constants.js +3 -0
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +5 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +17 -21
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +8 -2
- package/src/Notification/Notification.jsx +29 -12
- package/src/utils/getSpacingScale.js +50 -0
- package/src/utils/index.js +1 -0
- package/src/utils/useResponsiveProp.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 24 Apr 2025 18:52:13 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.6.0
|
|
8
|
+
|
|
9
|
+
Thu, 24 Apr 2025 18:52:13 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `MultiSelectFilter`: add new tokens (sergio.ramirez@telus.com)
|
|
14
|
+
- `Box`: add RNMQ support (guillermo.peitzner@telus.com)
|
|
15
|
+
- Bump @telus-uds/system-theme-tokens to v4.4.0
|
|
16
|
+
|
|
17
|
+
### Patches
|
|
18
|
+
|
|
19
|
+
- `ExpandCollapseMini`: allow support for style variants (Mauricio.BatresMontejo@telus.com)
|
|
20
|
+
- Update react dependencies to match valid versions (sergio.ramirez@telus.com)
|
|
21
|
+
|
|
22
|
+
## 3.5.2
|
|
23
|
+
|
|
24
|
+
Tue, 08 Apr 2025 19:36:14 GMT
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- `Carousel`: peeking mode optimizations (guillermo.peitzner@telus.com)
|
|
29
|
+
- `Notification`: fix system alignment variant when using RNMQ (guillermo.peitzner@telus.com)
|
|
30
|
+
- `MultiSelectFilter`: allow scrolling to viewport beyond xs (Mauricio.BatresMontejo@telus.com)
|
|
31
|
+
|
|
7
32
|
## 3.5.1
|
|
8
33
|
|
|
9
|
-
Fri, 28 Mar 2025 01:
|
|
34
|
+
Fri, 28 Mar 2025 01:02:45 GMT
|
|
10
35
|
|
|
11
36
|
### Patches
|
|
12
37
|
|
package/lib/cjs/Box/Box.js
CHANGED
|
@@ -15,6 +15,7 @@ var _Image = _interopRequireDefault(require("react-native-web/dist/cjs/exports/I
|
|
|
15
15
|
var _ThemeProvider = require("../ThemeProvider");
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
var _backgroundImageStylesMap = _interopRequireDefault(require("./backgroundImageStylesMap"));
|
|
18
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
@@ -203,8 +204,19 @@ const Box = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
203
204
|
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
204
205
|
...selectProps(rest)
|
|
205
206
|
};
|
|
206
|
-
const
|
|
207
|
-
const
|
|
207
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
208
|
+
const {
|
|
209
|
+
themeOptions
|
|
210
|
+
} = (0, _ThemeProvider.useTheme)();
|
|
211
|
+
const {
|
|
212
|
+
enableMediaQueryStyleSheet
|
|
213
|
+
} = themeOptions;
|
|
214
|
+
const useTokens = enableMediaQueryStyleSheet ? _ThemeProvider.useResponsiveThemeTokens : _ThemeProvider.useThemeTokens;
|
|
215
|
+
const themeTokens = useTokens('Box', tokens, variant, !enableMediaQueryStyleSheet && {
|
|
216
|
+
viewport
|
|
217
|
+
});
|
|
218
|
+
const getSpacingTokens = (0, _ThemeProvider.useThemeTokensCallback)('spacingScale');
|
|
219
|
+
let boxStyles = {
|
|
208
220
|
flex,
|
|
209
221
|
paddingLeft: (0, _utils.useSpacingScale)(left),
|
|
210
222
|
paddingRight: (0, _utils.useSpacingScale)(right),
|
|
@@ -212,8 +224,38 @@ const Box = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
212
224
|
paddingBottom: (0, _utils.useSpacingScale)(bottom),
|
|
213
225
|
...selectBoxStyles(themeTokens, customGradient)
|
|
214
226
|
};
|
|
227
|
+
let boxMediaIds;
|
|
228
|
+
if (enableMediaQueryStyleSheet) {
|
|
229
|
+
const {
|
|
230
|
+
transformedThemeTokens
|
|
231
|
+
} = Object.entries(themeTokens).reduce((acc, _ref4) => {
|
|
232
|
+
let [vp] = _ref4;
|
|
233
|
+
acc.transformedThemeTokens[vp] = {
|
|
234
|
+
paddingLeft: (0, _utils.getSpacingScale)(left, vp, getSpacingTokens),
|
|
235
|
+
paddingRight: (0, _utils.getSpacingScale)(right, vp, getSpacingTokens),
|
|
236
|
+
paddingTop: (0, _utils.getSpacingScale)(top, vp, getSpacingTokens),
|
|
237
|
+
paddingBottom: (0, _utils.getSpacingScale)(bottom, vp, getSpacingTokens)
|
|
238
|
+
};
|
|
239
|
+
return acc;
|
|
240
|
+
}, {
|
|
241
|
+
transformedThemeTokens: {}
|
|
242
|
+
});
|
|
243
|
+
const mediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedThemeTokens);
|
|
244
|
+
const {
|
|
245
|
+
ids
|
|
246
|
+
} = _utils.StyleSheet.create({
|
|
247
|
+
box: {
|
|
248
|
+
...mediaQueryStyles
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
boxStyles = {
|
|
252
|
+
flex,
|
|
253
|
+
...selectBoxStyles(themeTokens[viewport], customGradient)
|
|
254
|
+
};
|
|
255
|
+
boxMediaIds = ids.box;
|
|
256
|
+
}
|
|
215
257
|
let content = children;
|
|
216
|
-
if (typeof customGradient === 'function') content = customGradient(
|
|
258
|
+
if (typeof customGradient === 'function') content = customGradient(boxStyles.colors, boxStyles)(children);
|
|
217
259
|
const {
|
|
218
260
|
src = '',
|
|
219
261
|
alt = '',
|
|
@@ -247,23 +289,27 @@ const Box = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
247
289
|
});
|
|
248
290
|
}
|
|
249
291
|
}, [backgroundImage, backgroundImageWidth, backgroundImageHeight, src]);
|
|
292
|
+
const dataSetValue = boxMediaIds ? {
|
|
293
|
+
media: boxMediaIds,
|
|
294
|
+
...dataSet
|
|
295
|
+
} : dataSet;
|
|
250
296
|
if (scroll) {
|
|
251
297
|
const scrollProps = typeof scroll === 'object' ? scroll : {};
|
|
252
|
-
scrollProps.contentContainerStyle = [
|
|
298
|
+
scrollProps.contentContainerStyle = [boxStyles, scrollProps.contentContainerStyle];
|
|
253
299
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollView.default, {
|
|
254
300
|
...scrollProps,
|
|
255
301
|
...props,
|
|
256
302
|
testID: testID,
|
|
257
|
-
dataSet:
|
|
303
|
+
dataSet: dataSetValue,
|
|
258
304
|
ref: ref,
|
|
259
305
|
children: content
|
|
260
306
|
});
|
|
261
307
|
}
|
|
262
308
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
263
309
|
...props,
|
|
264
|
-
style:
|
|
310
|
+
style: boxStyles,
|
|
265
311
|
testID: testID,
|
|
266
|
-
dataSet:
|
|
312
|
+
dataSet: dataSetValue,
|
|
267
313
|
ref: ref,
|
|
268
314
|
children: content
|
|
269
315
|
});
|
|
@@ -205,56 +205,27 @@ const selectNavigationStyles = (tabs, enableHero, viewport) => {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
* Calculates the final width of
|
|
208
|
+
* Calculates the final width of a carousel container based on the provided parameters.
|
|
209
209
|
*
|
|
210
|
-
* @param {number} containerWidth - The
|
|
211
|
-
* @param {boolean} enablePeeking - Flag indicating
|
|
212
|
-
* @param {
|
|
213
|
-
* @param {
|
|
214
|
-
* @
|
|
215
|
-
* @param {number} calcDelta - The delta value used for calculations.
|
|
216
|
-
* @returns {number} - The final calculated width of the container.
|
|
217
|
-
*
|
|
218
|
-
* The function adjusts the container width for displacement purposes based on the peeking properties and the position
|
|
219
|
-
* of the active item (first, middle, or last). It considers different peeking spaces and gaps
|
|
220
|
-
* to ensure the correct width is calculated for the carousel to display properly.
|
|
210
|
+
* @param {number} containerWidth - The width of the carousel container.
|
|
211
|
+
* @param {boolean} enablePeeking - Flag indicating whether peeking is enabled.
|
|
212
|
+
* @param {Object} viewport - The viewport configuration object used to determine peeking properties.
|
|
213
|
+
* @param {React.MutableRefObject<number>} activeIndexRef - A ref object holding the current active index of the carousel.
|
|
214
|
+
* @returns {number} The calculated final width of the carousel container.
|
|
221
215
|
*/
|
|
222
|
-
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef
|
|
216
|
+
const calculateFinalWidth = (containerWidth, enablePeeking, viewport, activeIndexRef) => {
|
|
223
217
|
let finalWidth = containerWidth;
|
|
224
218
|
if (enablePeeking) {
|
|
225
219
|
const {
|
|
226
|
-
peekingFirstSpace,
|
|
227
220
|
peekingGap,
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
peekingMiddleSpace,
|
|
222
|
+
peekingMarginLeft
|
|
230
223
|
} = getPeekingProps(viewport);
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (isFirst) {
|
|
237
|
-
finalWidth -= basePeekingSpace;
|
|
238
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
239
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
240
|
-
}
|
|
241
|
-
} else if (isMiddle) {
|
|
242
|
-
if (calcDelta > 0) {
|
|
243
|
-
finalWidth -= basePeekingSpace + middlePeekingSpace * activeIndexRef.current;
|
|
244
|
-
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
245
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
246
|
-
}
|
|
247
|
-
} else {
|
|
248
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
249
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
250
|
-
finalWidth -= peekingFirstSpace - peekingMiddleSpace;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
} else if (isLast) {
|
|
254
|
-
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2);
|
|
255
|
-
if (activeIndexRef.current - 1 === 0) {
|
|
256
|
-
finalWidth -= peekingLastSpace - peekingMiddleSpace;
|
|
257
|
-
}
|
|
224
|
+
const slideWide = containerWidth - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
|
|
225
|
+
if (activeIndexRef.current === 0) {
|
|
226
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace;
|
|
227
|
+
} else {
|
|
228
|
+
finalWidth = slideWide + peekingGap;
|
|
258
229
|
}
|
|
259
230
|
}
|
|
260
231
|
return finalWidth;
|
|
@@ -441,7 +412,23 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
441
412
|
setIsAnimating(false);
|
|
442
413
|
}, [onAnimationEnd]);
|
|
443
414
|
const updateOffset = _react.default.useCallback(() => {
|
|
444
|
-
|
|
415
|
+
if (enablePeeking) {
|
|
416
|
+
const {
|
|
417
|
+
peekingGap,
|
|
418
|
+
peekingMiddleSpace,
|
|
419
|
+
peekingMarginLeft
|
|
420
|
+
} = getPeekingProps(viewport);
|
|
421
|
+
let finalWidth;
|
|
422
|
+
const slideWide = containerLayoutRef.current.width - (peekingMiddleSpace * _Constants.PEEKING_MULTIPLIER + peekingGap * _Constants.PEEKING_MULTIPLIER);
|
|
423
|
+
if (activeIndexRef.current === 0) {
|
|
424
|
+
finalWidth = 0;
|
|
425
|
+
} else {
|
|
426
|
+
finalWidth = slideWide + peekingMarginLeft - peekingMiddleSpace + (slideWide + peekingGap) * (activeIndexRef.current - _Constants.ACTIVE_INDEX_OFFSET_MULTIPLIER);
|
|
427
|
+
}
|
|
428
|
+
animatedX.current = finalWidth * _Constants.NEGATIVE_MULTIPLIER;
|
|
429
|
+
} else {
|
|
430
|
+
animatedX.current = containerLayoutRef.current.width * activeIndexRef.current * _Constants.NEGATIVE_MULTIPLIER;
|
|
431
|
+
}
|
|
445
432
|
animatedY.current = 0;
|
|
446
433
|
pan.setOffset({
|
|
447
434
|
x: animatedX.current,
|
|
@@ -452,7 +439,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
452
439
|
y: 0
|
|
453
440
|
});
|
|
454
441
|
if (enableHero) {
|
|
455
|
-
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current *
|
|
442
|
+
heroAnimatedX.current = heroContainerLayoutRef.current.width * activeIndexRef.current * _Constants.NEGATIVE_MULTIPLIER;
|
|
456
443
|
heroAnimatedY.current = 0;
|
|
457
444
|
heroPan.setOffset({
|
|
458
445
|
x: heroAnimatedX.current,
|
|
@@ -463,7 +450,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
463
450
|
y: 0
|
|
464
451
|
});
|
|
465
452
|
}
|
|
466
|
-
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero]);
|
|
453
|
+
}, [pan, animatedX, heroPan, heroAnimatedX, enableHero, viewport, enablePeeking]);
|
|
467
454
|
const animate = _react.default.useCallback((panToAnimate, toValue, toIndex) => {
|
|
468
455
|
const handleAnimationEndToIndex = function () {
|
|
469
456
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -538,7 +525,7 @@ const Carousel = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
538
525
|
}
|
|
539
526
|
stopAutoplay();
|
|
540
527
|
setActiveIndex(index);
|
|
541
|
-
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef
|
|
528
|
+
const finalWidth = calculateFinalWidth(containerLayoutRef.current.width, enablePeeking, viewport, activeIndexRef);
|
|
542
529
|
toValue.x = finalWidth * -1 * calcDelta;
|
|
543
530
|
const heroToValue = {
|
|
544
531
|
x: 0,
|
|
@@ -20,18 +20,17 @@ const selectContainerStyle = _ref => {
|
|
|
20
20
|
elementIndex,
|
|
21
21
|
enablePeeking,
|
|
22
22
|
peekingMarginLeft,
|
|
23
|
-
peekingFirstSpace,
|
|
24
23
|
peekingGap,
|
|
25
24
|
hidden,
|
|
26
25
|
enableDisplayMultipleItemsPerSlide,
|
|
27
|
-
viewport
|
|
26
|
+
viewport,
|
|
27
|
+
peekingMiddleSpace
|
|
28
28
|
} = _ref;
|
|
29
29
|
let adjustedWidth = width;
|
|
30
30
|
let marginLeft = 0;
|
|
31
|
-
const marginRight = 0;
|
|
32
31
|
if (enablePeeking) {
|
|
33
32
|
const isFirst = elementIndex === 0;
|
|
34
|
-
adjustedWidth = width - (
|
|
33
|
+
adjustedWidth = width - (peekingMiddleSpace * 2 + peekingGap * 2);
|
|
35
34
|
if (isFirst) {
|
|
36
35
|
marginLeft = peekingMarginLeft;
|
|
37
36
|
} else {
|
|
@@ -68,8 +67,7 @@ const selectContainerStyle = _ref => {
|
|
|
68
67
|
}
|
|
69
68
|
const style = {
|
|
70
69
|
width: adjustedWidth,
|
|
71
|
-
marginLeft
|
|
72
|
-
marginRight
|
|
70
|
+
marginLeft
|
|
73
71
|
};
|
|
74
72
|
if (hidden && _Platform.default.OS === 'web') {
|
|
75
73
|
style.visibility = 'hidden';
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_POSITION_OFFSET = void 0;
|
|
6
|
+
exports.PEEKING_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = exports.LARGE_VIEWPORT_MARGIN = exports.ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_LG_XL = exports.HERO_POSITION_OFFSET = exports.GAP_BETWEEN_ITEMS = exports.DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_POSITION_OFFSET = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = void 0;
|
|
7
7
|
const ITEMS_PER_VIEWPORT_MD = exports.ITEMS_PER_VIEWPORT_MD = 2;
|
|
8
8
|
const ITEMS_PER_VIEWPORT_LG_XL = exports.ITEMS_PER_VIEWPORT_LG_XL = 3;
|
|
9
9
|
const GAP_BETWEEN_ITEMS = exports.GAP_BETWEEN_ITEMS = 16;
|
|
10
10
|
const HERO_POSITION_OFFSET = exports.HERO_POSITION_OFFSET = 20;
|
|
11
11
|
const DEFAULT_POSITION_OFFSET = exports.DEFAULT_POSITION_OFFSET = 0;
|
|
12
12
|
const LARGE_VIEWPORT_MARGIN = exports.LARGE_VIEWPORT_MARGIN = 40;
|
|
13
|
-
const DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_VIEWPORT_MARGIN = 10;
|
|
13
|
+
const DEFAULT_VIEWPORT_MARGIN = exports.DEFAULT_VIEWPORT_MARGIN = 10;
|
|
14
|
+
const PEEKING_MULTIPLIER = exports.PEEKING_MULTIPLIER = 2;
|
|
15
|
+
const ACTIVE_INDEX_OFFSET_MULTIPLIER = exports.ACTIVE_INDEX_OFFSET_MULTIPLIER = 1;
|
|
16
|
+
const NEGATIVE_MULTIPLIER = exports.NEGATIVE_MULTIPLIER = -1;
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _ExpandCollapse = _interopRequireDefault(require("../ExpandCollapse"));
|
|
10
10
|
var _utils = require("../utils");
|
|
11
|
+
var _props = require("../utils/props");
|
|
11
12
|
var _ExpandCollapseMiniControl = _interopRequireDefault(require("./ExpandCollapseMiniControl"));
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -85,6 +86,10 @@ ExpandCollapseMini.propTypes = {
|
|
|
85
86
|
* Optional variant object to override the default theme tokens
|
|
86
87
|
*/
|
|
87
88
|
tokens: (0, _utils.getTokensPropType)('ExpandCollapseMini'),
|
|
89
|
+
/**
|
|
90
|
+
* ExpandCollapseMini variant.
|
|
91
|
+
*/
|
|
92
|
+
variant: _props.variantProp.propType,
|
|
88
93
|
/**
|
|
89
94
|
* The dataSet prop allows to pass data-* attributes element to the component.
|
|
90
95
|
*/
|
|
@@ -23,21 +23,7 @@ const presentationOnly = {
|
|
|
23
23
|
// Stop RNW from stopping clicks from bubbling to Control
|
|
24
24
|
focusable: false // Stop RNW from setting tabIndex={0}: focus goes to Control only
|
|
25
25
|
};
|
|
26
|
-
const
|
|
27
|
-
let {
|
|
28
|
-
color,
|
|
29
|
-
textLine,
|
|
30
|
-
lineHeight,
|
|
31
|
-
fontSize
|
|
32
|
-
} = _ref;
|
|
33
|
-
return {
|
|
34
|
-
color,
|
|
35
|
-
textLine,
|
|
36
|
-
blockLineHeight: lineHeight,
|
|
37
|
-
blockFontSize: fontSize
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const ExpandCollapseMiniControl = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
26
|
+
const ExpandCollapseMiniControl = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
41
27
|
let {
|
|
42
28
|
pressableState,
|
|
43
29
|
collapseTitle,
|
|
@@ -46,22 +32,28 @@ const ExpandCollapseMiniControl = /*#__PURE__*/_react.default.forwardRef((_ref2,
|
|
|
46
32
|
tokens,
|
|
47
33
|
variant = {},
|
|
48
34
|
...rest
|
|
49
|
-
} =
|
|
35
|
+
} = _ref;
|
|
50
36
|
const {
|
|
51
37
|
expanded,
|
|
52
38
|
hover,
|
|
53
|
-
focus
|
|
39
|
+
focus,
|
|
40
|
+
pressed
|
|
54
41
|
} = pressableState || {};
|
|
55
|
-
// we only want focus outline when focusing, if user is pressing we don't want the border.
|
|
56
42
|
const {
|
|
57
|
-
|
|
58
|
-
} =
|
|
59
|
-
|
|
43
|
+
quiet
|
|
44
|
+
} = variant;
|
|
45
|
+
const isFocusVisible = _Platform.default.OS === 'web' ? focus && !pressed && !hover : expanded;
|
|
46
|
+
const linkTokens = (0, _ThemeProvider.useThemeTokens)('Link', {}, {
|
|
47
|
+
...variant,
|
|
48
|
+
quiet: expanded ?? quiet
|
|
49
|
+
}, {
|
|
50
|
+
focus: isFocusVisible,
|
|
51
|
+
hover,
|
|
52
|
+
pressed
|
|
60
53
|
});
|
|
61
54
|
const {
|
|
62
55
|
size,
|
|
63
|
-
icon
|
|
64
|
-
...themeTokens
|
|
56
|
+
icon
|
|
65
57
|
} = (0, _ThemeProvider.useThemeTokens)('ExpandCollapseMiniControl', tokens, variant, {
|
|
66
58
|
expanded,
|
|
67
59
|
focus
|
|
@@ -95,9 +87,8 @@ const ExpandCollapseMiniControl = /*#__PURE__*/_react.default.forwardRef((_ref2,
|
|
|
95
87
|
icon: icon,
|
|
96
88
|
iconPosition: iconPosition,
|
|
97
89
|
tokens: linkState => ({
|
|
98
|
-
...
|
|
99
|
-
...
|
|
100
|
-
outerBorderColor
|
|
90
|
+
...linkTokens,
|
|
91
|
+
...getTokens(linkState)
|
|
101
92
|
}),
|
|
102
93
|
ref: ref,
|
|
103
94
|
...presentationOnly,
|
|
@@ -137,6 +137,10 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
|
|
|
137
137
|
buttonIconPadding,
|
|
138
138
|
subtitleColor,
|
|
139
139
|
dividerColor,
|
|
140
|
+
iconColor,
|
|
141
|
+
buttonBackgroundColor,
|
|
142
|
+
iconColorSelected,
|
|
143
|
+
buttonBackgroundColorSelected,
|
|
140
144
|
...restTokens
|
|
141
145
|
} = (0, _ThemeProvider.useThemeTokens)('MultiSelectFilter', tokens, {
|
|
142
146
|
...variant,
|
|
@@ -159,7 +163,9 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
|
|
|
159
163
|
paddingBottom: labelPaddingBottom,
|
|
160
164
|
paddingLeft: labelPaddingLeft,
|
|
161
165
|
paddingRight: labelPaddingRight,
|
|
162
|
-
iconBackground: buttonIconBackgroundColor
|
|
166
|
+
iconBackground: buttonIconBackgroundColor,
|
|
167
|
+
iconColor: isSelected ? iconColorSelected : iconColor,
|
|
168
|
+
backgroundColor: isSelected ? buttonBackgroundColorSelected : buttonBackgroundColor
|
|
163
169
|
};
|
|
164
170
|
const getButtonDropdownTokens = (0, _ThemeProvider.useThemeTokensCallback)('ButtonDropdown', dropdownTokens, variant);
|
|
165
171
|
const getButtonTokens = buttonState => (0, _utils.selectTokens)('ButtonDropdown', getButtonDropdownTokens(buttonState));
|
|
@@ -249,7 +255,7 @@ const MultiSelectFilter = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) =>
|
|
|
249
255
|
const [isScrolling, setIsScrolling] = _react.default.useState(false);
|
|
250
256
|
const [scrollViewHeight, setScrollViewHeight] = _react.default.useState(0);
|
|
251
257
|
const [rowHeight, setRowHeight] = _react.default.useState(0);
|
|
252
|
-
const modalRef = (0, _utils.useScrollBlocking)(isOpen);
|
|
258
|
+
const modalRef = (0, _utils.useScrollBlocking)(isOpen && viewport === 'xs');
|
|
253
259
|
const windowWidth = _Dimensions.default.get('window').width;
|
|
254
260
|
const windowHeight = _Dimensions.default.get('window').height;
|
|
255
261
|
_react.default.useEffect(() => {
|
|
@@ -70,8 +70,8 @@ const selectDismissButtonContainerStyles = _ref4 => {
|
|
|
70
70
|
placeContent: 'start'
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
const selectContentContainerStyle = (themeTokens, maxWidth,
|
|
74
|
-
maxWidth: viewport === 'xl'
|
|
73
|
+
const selectContentContainerStyle = (themeTokens, maxWidth, system, viewport) => ({
|
|
74
|
+
maxWidth: system && viewport === 'xl' ? maxWidth : '100%',
|
|
75
75
|
width: '100%',
|
|
76
76
|
paddingRight: themeTokens?.containerPaddingRight,
|
|
77
77
|
paddingLeft: themeTokens?.containerPaddingLeft
|
|
@@ -79,9 +79,12 @@ const selectContentContainerStyle = (themeTokens, maxWidth, viewport, system) =>
|
|
|
79
79
|
const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, dismissible, viewport, system) => {
|
|
80
80
|
const transformedSelectContainerStyles = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
81
81
|
let [vp, viewportTokens] = _ref5;
|
|
82
|
-
acc[vp] =
|
|
83
|
-
...
|
|
84
|
-
|
|
82
|
+
acc[vp] = {
|
|
83
|
+
...selectContainerStyles({
|
|
84
|
+
...viewportTokens
|
|
85
|
+
}),
|
|
86
|
+
flexDirection: 'column'
|
|
87
|
+
};
|
|
85
88
|
return acc;
|
|
86
89
|
}, {});
|
|
87
90
|
const selectContainerMediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedSelectContainerStyles);
|
|
@@ -90,22 +93,29 @@ const getMediaQueryStyles = (themeTokens, themeOptions, maxWidth, mediaIdsRef, d
|
|
|
90
93
|
styles: containerStyles
|
|
91
94
|
} = _utils.StyleSheet.create({
|
|
92
95
|
container: {
|
|
93
|
-
flexDirection: 'column',
|
|
94
96
|
...selectContainerMediaQueryStyles
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
|
-
const {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
contentContainer: {
|
|
99
|
+
const transformedSelectContentContainerStyles = Object.entries(themeTokens).reduce((acc, _ref6) => {
|
|
100
|
+
let [vp, viewportTokens] = _ref6;
|
|
101
|
+
acc[vp] = {
|
|
102
|
+
...selectContentContainerStyle(viewportTokens, maxWidth, system, vp),
|
|
102
103
|
flexDirection: 'row',
|
|
103
104
|
flexShrink: 1,
|
|
104
105
|
justifyContent: 'space-between',
|
|
105
|
-
...selectContentContainerStyle(themeTokens, maxWidth, viewport, system),
|
|
106
106
|
...(system && {
|
|
107
107
|
alignSelf: 'center'
|
|
108
108
|
})
|
|
109
|
+
};
|
|
110
|
+
return acc;
|
|
111
|
+
}, {});
|
|
112
|
+
const selectContentContainerMediaQueryStyles = (0, _utils.createMediaQueryStyles)(transformedSelectContentContainerStyles);
|
|
113
|
+
const {
|
|
114
|
+
ids: contentContainerIds,
|
|
115
|
+
styles: contentContainerStyles
|
|
116
|
+
} = _utils.StyleSheet.create({
|
|
117
|
+
contentContainer: {
|
|
118
|
+
...selectContentContainerMediaQueryStyles
|
|
109
119
|
}
|
|
110
120
|
});
|
|
111
121
|
const {
|
|
@@ -178,7 +188,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
178
188
|
flexDirection: 'row',
|
|
179
189
|
flexShrink: 1,
|
|
180
190
|
justifyContent: 'space-between',
|
|
181
|
-
...selectContentContainerStyle(themeTokens, maxWidth,
|
|
191
|
+
...selectContentContainerStyle(themeTokens, maxWidth, system, viewport),
|
|
182
192
|
...(system && {
|
|
183
193
|
alignSelf: 'center'
|
|
184
194
|
})
|
|
@@ -268,7 +278,7 @@ const getDefaultStyles = (themeTokens, themeOptions, maxWidth, dismissible, view
|
|
|
268
278
|
* Use full-width `Notifications` to show system-based messages coming from the application, not in response to user action.
|
|
269
279
|
* Show system notifications at the top of the page, below the navigation, and expands the full-width of the viewport
|
|
270
280
|
*/
|
|
271
|
-
const Notification = /*#__PURE__*/_react.default.forwardRef((
|
|
281
|
+
const Notification = /*#__PURE__*/_react.default.forwardRef((_ref7, ref) => {
|
|
272
282
|
let {
|
|
273
283
|
children,
|
|
274
284
|
system,
|
|
@@ -278,7 +288,7 @@ const Notification = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
|
|
|
278
288
|
variant,
|
|
279
289
|
onDismiss,
|
|
280
290
|
...rest
|
|
281
|
-
} =
|
|
291
|
+
} = _ref7;
|
|
282
292
|
const [isDismissed, setIsDismissed] = _react.default.useState(false);
|
|
283
293
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
284
294
|
const getCopy = (0, _useCopy.default)({
|
|
@@ -299,7 +309,7 @@ const Notification = /*#__PURE__*/_react.default.forwardRef((_ref6, ref) => {
|
|
|
299
309
|
system: isSystemEnabled,
|
|
300
310
|
viewport
|
|
301
311
|
});
|
|
302
|
-
const maxWidth = _systemConstants.viewports.map.get(_systemConstants.viewports.xl);
|
|
312
|
+
const maxWidth = (0, _utils.useResponsiveProp)(themeOptions?.contentMaxWidth, _systemConstants.viewports.map.get(_systemConstants.viewports.xl));
|
|
303
313
|
const notificationComponentRef = _react.default.useRef({
|
|
304
314
|
containerStyles: {},
|
|
305
315
|
contentContainerStyles: {},
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _useResponsiveProp = require("./useResponsiveProp");
|
|
8
|
+
/**
|
|
9
|
+
* Resolves spacing options from the provided space object.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} space - The space configuration object.
|
|
12
|
+
* @param {Object} [space.options] - The options for spacing.
|
|
13
|
+
* @param {number|string} [space.options.size] - The size of the spacing. Can be a number or a string.
|
|
14
|
+
* @param {string} [space.options.variant] - The variant of the spacing.
|
|
15
|
+
* @param {number} [space.options.subtract=0] - A value to subtract from the spacing size.
|
|
16
|
+
* @returns {Object} An object containing resolved spacing tokens, variant, overridden flag, and subtract value.
|
|
17
|
+
* @property {Object} tokens - The resolved spacing tokens.
|
|
18
|
+
* @property {number|string} tokens.size - The size of the spacing.
|
|
19
|
+
* @property {string} [variant] - The variant of the spacing.
|
|
20
|
+
* @property {boolean} overridden - Indicates if the size is explicitly overridden as a number.
|
|
21
|
+
* @property {number} subtract - The value to subtract from the spacing size.
|
|
22
|
+
*/
|
|
23
|
+
const resolveSpacingOptions = space => {
|
|
24
|
+
if (!space?.options) return {};
|
|
25
|
+
const {
|
|
26
|
+
size,
|
|
27
|
+
variant,
|
|
28
|
+
subtract = 0
|
|
29
|
+
} = space.options;
|
|
30
|
+
const overridden = typeof size === 'number';
|
|
31
|
+
return {
|
|
32
|
+
tokens: {
|
|
33
|
+
size
|
|
34
|
+
},
|
|
35
|
+
variant,
|
|
36
|
+
overridden,
|
|
37
|
+
subtract
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Calculates the spacing scale based on the provided space value, viewport, and spacing tokens.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} spaceValue - The space value configuration, which may include responsive properties.
|
|
45
|
+
* @param {Object} viewport - The current viewport dimensions or configuration.
|
|
46
|
+
* @param {Function} getSpacingTokens - A function that retrieves spacing tokens based on the provided options.
|
|
47
|
+
* @returns {number} The calculated spacing scale, ensuring it is non-negative.
|
|
48
|
+
*/
|
|
49
|
+
const getSpacingScale = (spaceValue, viewport, getSpacingTokens) => {
|
|
50
|
+
const {
|
|
51
|
+
tokens,
|
|
52
|
+
variant,
|
|
53
|
+
overridden,
|
|
54
|
+
subtract = 0
|
|
55
|
+
} = resolveSpacingOptions(spaceValue);
|
|
56
|
+
const space = !overridden && (spaceValue?.space ?? (0, _useResponsiveProp.resolveResponsiveProp)(spaceValue, viewport, 0));
|
|
57
|
+
const {
|
|
58
|
+
size
|
|
59
|
+
} = getSpacingTokens({
|
|
60
|
+
...variant,
|
|
61
|
+
space: typeof space === 'number' ? space : 0,
|
|
62
|
+
viewport
|
|
63
|
+
}, tokens);
|
|
64
|
+
return Math.max(size - subtract, 0);
|
|
65
|
+
};
|
|
66
|
+
var _default = exports.default = getSpacingScale;
|
package/lib/cjs/utils/index.js
CHANGED
|
@@ -19,7 +19,8 @@ var _exportNames = {
|
|
|
19
19
|
htmlAttrs: true,
|
|
20
20
|
transformGradient: true,
|
|
21
21
|
convertFromMegaByteToByte: true,
|
|
22
|
-
formatImageSource: true
|
|
22
|
+
formatImageSource: true,
|
|
23
|
+
getSpacingScale: true
|
|
23
24
|
};
|
|
24
25
|
Object.defineProperty(exports, "BaseView", {
|
|
25
26
|
enumerable: true,
|
|
@@ -45,6 +46,12 @@ Object.defineProperty(exports, "formatImageSource", {
|
|
|
45
46
|
return _formatImageSource.default;
|
|
46
47
|
}
|
|
47
48
|
});
|
|
49
|
+
Object.defineProperty(exports, "getSpacingScale", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _getSpacingScale.default;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
48
55
|
Object.defineProperty(exports, "htmlAttrs", {
|
|
49
56
|
enumerable: true,
|
|
50
57
|
get: function () {
|
|
@@ -240,6 +247,7 @@ var _htmlAttrs = _interopRequireDefault(require("./htmlAttrs"));
|
|
|
240
247
|
var _transformGradient = require("./transformGradient");
|
|
241
248
|
var _convertFromMegaByteToByte = _interopRequireDefault(require("./convertFromMegaByteToByte"));
|
|
242
249
|
var _formatImageSource = _interopRequireDefault(require("./formatImageSource"));
|
|
250
|
+
var _getSpacingScale = _interopRequireDefault(require("./getSpacingScale"));
|
|
243
251
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
244
252
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
245
253
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -28,7 +28,7 @@ const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
|
28
28
|
_systemConstants.viewports.inherit(prop)[viewport] :
|
|
29
29
|
// If no current viewport is available, default to smallest viewport
|
|
30
30
|
prop[_systemConstants.viewports.keys.find(key => (0, _hasOwnProperty.default)(prop, key))];
|
|
31
|
-
return value === undefined ? defaultValue : value;
|
|
31
|
+
return value === undefined || value === null ? defaultValue : value;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
/**
|