@telus-uds/components-base 1.18.1 → 1.20.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/__tests17__/ThemeProvider/ThemeProvider.test.jsx +2 -1
- package/component-docs.json +1035 -231
- package/jest.config-android.js +17 -0
- package/jest.config-ios.js +18 -0
- package/jest.config-web.js +31 -0
- package/lib/BaseProvider/index.js +2 -1
- package/lib/Box/Box.js +14 -1
- package/lib/Button/ButtonBase.js +6 -2
- package/lib/Button/ButtonDropdown.js +207 -0
- package/lib/Button/index.js +8 -0
- package/lib/Carousel/Carousel.js +34 -6
- package/lib/Carousel/CarouselItem/CarouselItem.js +7 -1
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +22 -14
- package/lib/FlexGrid/Col/Col.js +1 -3
- package/lib/FlexGrid/FlexGrid.js +3 -5
- package/lib/FlexGrid/Row/Row.js +3 -3
- package/lib/IconButton/IconButton.js +12 -4
- package/lib/MultiSelectFilter/MultiSelectFilter.js +276 -0
- package/lib/MultiSelectFilter/dictionary.js +19 -0
- package/lib/MultiSelectFilter/index.js +13 -0
- package/lib/Pagination/SideButton.js +6 -4
- package/lib/Responsive/Responsive.js +58 -0
- package/lib/Responsive/index.js +13 -0
- package/lib/Search/Search.js +33 -63
- package/lib/Select/Picker.native.js +16 -13
- package/lib/Select/Select.js +7 -1
- package/lib/Select/constants.js +15 -0
- package/lib/StepTracker/Step.js +2 -1
- package/lib/Tags/Tags.js +10 -4
- package/lib/TextInput/TextInput.js +9 -2
- package/lib/TextInput/TextInputBase.js +98 -20
- package/lib/TextInput/dictionary.js +15 -0
- package/lib/ThemeProvider/ThemeProvider.js +6 -1
- package/lib/index.js +18 -0
- package/lib/utils/BaseView/BaseView.js +64 -0
- package/lib/utils/BaseView/BaseView.native.js +16 -0
- package/lib/utils/BaseView/index.js +13 -0
- package/lib/utils/index.js +10 -1
- package/lib/utils/input.js +11 -3
- package/lib/utils/props/handlerProps.js +5 -0
- package/lib-module/BaseProvider/index.js +2 -1
- package/lib-module/Box/Box.js +14 -1
- package/lib-module/Button/ButtonBase.js +6 -2
- package/lib-module/Button/ButtonDropdown.js +181 -0
- package/lib-module/Button/index.js +2 -1
- package/lib-module/Carousel/Carousel.js +34 -6
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +8 -2
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +24 -16
- package/lib-module/FlexGrid/Col/Col.js +2 -3
- package/lib-module/FlexGrid/FlexGrid.js +2 -3
- package/lib-module/FlexGrid/Row/Row.js +2 -2
- package/lib-module/IconButton/IconButton.js +14 -4
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +248 -0
- package/lib-module/MultiSelectFilter/dictionary.js +12 -0
- package/lib-module/MultiSelectFilter/index.js +2 -0
- package/lib-module/Pagination/SideButton.js +6 -4
- package/lib-module/Responsive/Responsive.js +45 -0
- package/lib-module/Responsive/index.js +2 -0
- package/lib-module/Search/Search.js +33 -61
- package/lib-module/Select/Picker.native.js +15 -13
- package/lib-module/Select/Select.js +6 -1
- package/lib-module/Select/constants.js +5 -0
- package/lib-module/StepTracker/Step.js +2 -1
- package/lib-module/Tags/Tags.js +10 -4
- package/lib-module/TextInput/TextInput.js +6 -0
- package/lib-module/TextInput/TextInputBase.js +96 -21
- package/lib-module/TextInput/dictionary.js +8 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +6 -1
- package/lib-module/index.js +2 -0
- package/lib-module/utils/BaseView/BaseView.js +43 -0
- package/lib-module/utils/BaseView/BaseView.native.js +6 -0
- package/lib-module/utils/BaseView/index.js +2 -0
- package/lib-module/utils/index.js +2 -1
- package/lib-module/utils/input.js +11 -3
- package/lib-module/utils/props/handlerProps.js +5 -0
- package/package.json +6 -3
- package/src/BaseProvider/index.jsx +4 -1
- package/src/Box/Box.jsx +14 -1
- package/src/Button/ButtonBase.jsx +4 -2
- package/src/Button/ButtonDropdown.jsx +179 -0
- package/src/Button/index.js +2 -1
- package/src/Carousel/Carousel.jsx +48 -13
- package/src/Carousel/CarouselItem/CarouselItem.jsx +9 -2
- package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +19 -15
- package/src/FlexGrid/Col/Col.jsx +4 -4
- package/src/FlexGrid/FlexGrid.jsx +11 -10
- package/src/FlexGrid/Row/Row.jsx +4 -3
- package/src/IconButton/IconButton.jsx +3 -1
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +227 -0
- package/src/MultiSelectFilter/dictionary.js +12 -0
- package/src/MultiSelectFilter/index.js +3 -0
- package/src/Pagination/SideButton.jsx +5 -5
- package/src/Responsive/Responsive.jsx +33 -0
- package/src/Responsive/index.js +3 -0
- package/src/Search/Search.jsx +19 -33
- package/src/Select/Picker.native.jsx +29 -14
- package/src/Select/Select.jsx +7 -1
- package/src/Select/constants.js +5 -0
- package/src/StepTracker/Step.jsx +5 -1
- package/src/Tags/Tags.jsx +46 -33
- package/src/TextInput/TextInput.jsx +5 -0
- package/src/TextInput/TextInputBase.jsx +85 -20
- package/src/TextInput/dictionary.js +8 -0
- package/src/ThemeProvider/ThemeProvider.jsx +5 -1
- package/src/index.js +2 -0
- package/src/utils/BaseView/BaseView.jsx +38 -0
- package/src/utils/BaseView/BaseView.native.jsx +6 -0
- package/src/utils/BaseView/index.js +3 -0
- package/src/utils/index.js +1 -0
- package/src/utils/input.js +9 -4
- package/src/utils/props/handlerProps.js +4 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import View from "react-native-web/dist/exports/View";
|
|
6
|
+
import buttonPropTypes, { textAndA11yText } from './propTypes';
|
|
7
|
+
import ButtonBase from './ButtonBase';
|
|
8
|
+
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
9
|
+
import { a11yProps, focusHandlerProps, resolvePressableState, selectTokens, useInputValue } from '../utils';
|
|
10
|
+
import Icon from '../Icon';
|
|
11
|
+
import { getStackedContent } from '../StackView';
|
|
12
|
+
import { getPressHandlersWithArgs } from '../utils/pressability';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
const selectIconTokens = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
icon,
|
|
18
|
+
iconPosition,
|
|
19
|
+
iconSpace,
|
|
20
|
+
iconSize,
|
|
21
|
+
iconColor,
|
|
22
|
+
iconBackground,
|
|
23
|
+
iconBorderRadius,
|
|
24
|
+
iconAlignSelf,
|
|
25
|
+
iconPadding,
|
|
26
|
+
iconTranslateX,
|
|
27
|
+
iconTranslateY
|
|
28
|
+
} = _ref;
|
|
29
|
+
return {
|
|
30
|
+
icon,
|
|
31
|
+
iconPosition,
|
|
32
|
+
iconSpace,
|
|
33
|
+
iconWrapperStyle: {
|
|
34
|
+
backgroundColor: iconBackground,
|
|
35
|
+
borderRadius: iconBorderRadius,
|
|
36
|
+
alignSelf: iconAlignSelf,
|
|
37
|
+
padding: iconPadding,
|
|
38
|
+
...Platform.select({
|
|
39
|
+
// TODO: https://github.com/telus/universal-design-system/issues/487
|
|
40
|
+
web: {
|
|
41
|
+
transition: 'color 200ms, background 200ms'
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
iconTokens: {
|
|
46
|
+
size: iconSize,
|
|
47
|
+
color: iconColor,
|
|
48
|
+
translateX: iconTranslateX,
|
|
49
|
+
translateY: iconTranslateY
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const ButtonDropdown = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
55
|
+
let {
|
|
56
|
+
value,
|
|
57
|
+
initialValue,
|
|
58
|
+
onChange,
|
|
59
|
+
label,
|
|
60
|
+
tokens,
|
|
61
|
+
variant,
|
|
62
|
+
inactive = false,
|
|
63
|
+
readOnly = false,
|
|
64
|
+
children = null,
|
|
65
|
+
accessibilityRole = 'radio',
|
|
66
|
+
...props
|
|
67
|
+
} = _ref2;
|
|
68
|
+
const {
|
|
69
|
+
currentValue: isOpen,
|
|
70
|
+
setValue: setIsOpen
|
|
71
|
+
} = useInputValue({
|
|
72
|
+
value,
|
|
73
|
+
initialValue,
|
|
74
|
+
onChange,
|
|
75
|
+
readOnly
|
|
76
|
+
}, 'useButtonDropdownValues');
|
|
77
|
+
const extraState = {
|
|
78
|
+
open: isOpen,
|
|
79
|
+
inactive,
|
|
80
|
+
...variant
|
|
81
|
+
};
|
|
82
|
+
const getTokens = useThemeTokensCallback('ButtonDropdown', tokens, extraState);
|
|
83
|
+
|
|
84
|
+
const getButtonTokens = buttonState => selectTokens('Button', getTokens(buttonState)); // Pass an object of relevant component state as first argument for any passed-in press handlers
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const pressHandlers = getPressHandlersWithArgs(props, [{
|
|
88
|
+
label,
|
|
89
|
+
open: isOpen
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
const handlePress = event => {
|
|
93
|
+
if (!inactive) {
|
|
94
|
+
if (pressHandlers.onPress) pressHandlers === null || pressHandlers === void 0 ? void 0 : pressHandlers.onPress(event);
|
|
95
|
+
setIsOpen(!isOpen, event);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return /*#__PURE__*/_jsx(ButtonBase, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
...pressHandlers,
|
|
102
|
+
onPress: handlePress,
|
|
103
|
+
tokens: getButtonTokens,
|
|
104
|
+
inactive: inactive,
|
|
105
|
+
icon: () => null,
|
|
106
|
+
accessibilityRole: accessibilityRole,
|
|
107
|
+
...props,
|
|
108
|
+
children: _ref3 => {
|
|
109
|
+
let {
|
|
110
|
+
textStyles,
|
|
111
|
+
...buttonState
|
|
112
|
+
} = _ref3;
|
|
113
|
+
// TODO: once Icon/IconButton designs are stable, see if this sort of styling around
|
|
114
|
+
// an icon should go in Icon itself, or possibly via an IconText token set. Related issues:
|
|
115
|
+
// - Icon: https://github.com/telus/universal-design-system/issues/327
|
|
116
|
+
// - IconButton: https://github.com/telus/universal-design-system/issues/281
|
|
117
|
+
// - Token sets: https://github.com/telus/universal-design-system/issues/782
|
|
118
|
+
const itemTokens = getTokens(buttonState);
|
|
119
|
+
const {
|
|
120
|
+
iconTokens,
|
|
121
|
+
iconPosition,
|
|
122
|
+
iconSpace,
|
|
123
|
+
iconWrapperStyle,
|
|
124
|
+
icon: IconComponent
|
|
125
|
+
} = selectIconTokens(itemTokens);
|
|
126
|
+
const iconContent = IconComponent ? /*#__PURE__*/_jsx(View, {
|
|
127
|
+
style: iconWrapperStyle,
|
|
128
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
129
|
+
icon: IconComponent,
|
|
130
|
+
tokens: iconTokens
|
|
131
|
+
})
|
|
132
|
+
}) : null;
|
|
133
|
+
|
|
134
|
+
const childrenContent = () => typeof children === 'function' ? children({ ...resolvePressableState(buttonState, extraState),
|
|
135
|
+
textStyles
|
|
136
|
+
}) : children;
|
|
137
|
+
|
|
138
|
+
const content = children ? childrenContent() : /*#__PURE__*/_jsx(Text, {
|
|
139
|
+
style: textStyles,
|
|
140
|
+
children: label
|
|
141
|
+
});
|
|
142
|
+
return getStackedContent(iconPosition === 'left' ? [iconContent, content] : [content, iconContent], {
|
|
143
|
+
space: iconSpace,
|
|
144
|
+
direction: 'row'
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
ButtonDropdown.displayName = 'ButtonDropdown';
|
|
150
|
+
ButtonDropdown.propTypes = { ...a11yProps.types,
|
|
151
|
+
...focusHandlerProps.types,
|
|
152
|
+
...buttonPropTypes,
|
|
153
|
+
children: textAndA11yText,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Callback called when a controlled ButtonDropdown gets interacted with.
|
|
157
|
+
*/
|
|
158
|
+
onChange: PropTypes.func,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `value` prop is being used to set the 'open' state of ButtonDropdown. Use it for
|
|
162
|
+
* controlled ButtonDropdown. For uncontrolled ButtonDropdown, use `initialValue`.
|
|
163
|
+
*/
|
|
164
|
+
value: PropTypes.bool,
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Use `initialValue` to provide the initial value for an uncontrolled version.
|
|
168
|
+
*/
|
|
169
|
+
initialValue: PropTypes.bool,
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The label of ButtonDropdown.
|
|
173
|
+
*/
|
|
174
|
+
label: PropTypes.string,
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* By default, `ButtonDropdown` is treated by accessibility tools as a radio button.
|
|
178
|
+
*/
|
|
179
|
+
accessibilityRole: PropTypes.string
|
|
180
|
+
};
|
|
181
|
+
export default ButtonDropdown;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Button from './Button';
|
|
2
2
|
import ButtonLink from './ButtonLink';
|
|
3
3
|
import ButtonGroup from './ButtonGroup';
|
|
4
|
-
|
|
4
|
+
import ButtonDropdown from './ButtonDropdown';
|
|
5
|
+
export { Button, ButtonDropdown, ButtonGroup, ButtonLink };
|
|
@@ -127,6 +127,8 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
127
127
|
*/
|
|
128
128
|
|
|
129
129
|
const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
130
|
+
var _systemProps$accessib;
|
|
131
|
+
|
|
130
132
|
let {
|
|
131
133
|
tokens,
|
|
132
134
|
variant,
|
|
@@ -150,7 +152,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
150
152
|
}) : /*#__PURE__*/_jsx(CarouselStepTracker, {}),
|
|
151
153
|
tag = 'ul',
|
|
152
154
|
accessibilityRole,
|
|
153
|
-
accessibilityLabel
|
|
155
|
+
accessibilityLabel,
|
|
154
156
|
accessibilityLiveRegion = 'polite',
|
|
155
157
|
copy,
|
|
156
158
|
...rest
|
|
@@ -296,7 +298,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
296
298
|
setActiveIndex(index);
|
|
297
299
|
toValue.x = containerLayout.width * -1 * calcDelta;
|
|
298
300
|
animate(toValue, index);
|
|
299
|
-
if (onIndexChanged) onIndexChanged(calcDelta);
|
|
301
|
+
if (onIndexChanged) onIndexChanged(calcDelta, index);
|
|
300
302
|
return calcDelta;
|
|
301
303
|
}, [containerLayout.width, activeIndex, animate, children.length, onIndexChanged]);
|
|
302
304
|
const fixOffsetAndGo = React.useCallback(delta => {
|
|
@@ -396,6 +398,33 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
396
398
|
const activePanelNavigation = tabs && showPanelTabs ? /*#__PURE__*/_jsx(CarouselTabsPanel, {
|
|
397
399
|
items: tabs
|
|
398
400
|
}) : panelNavigation;
|
|
401
|
+
const isFirstFocusContainer = Boolean(refocus && !skipLinkHref);
|
|
402
|
+
|
|
403
|
+
const containerRef = element => {
|
|
404
|
+
// Apply both firstFocusRef to the container
|
|
405
|
+
firstFocusRef.current = element; // Also apply forwarded ref if there is one (which could be a function ref)
|
|
406
|
+
|
|
407
|
+
if (ref) {
|
|
408
|
+
if (typeof ref === 'object') {
|
|
409
|
+
// eslint-disable-next-line no-param-reassign
|
|
410
|
+
ref.current = element;
|
|
411
|
+
} else if (typeof ref === 'function') {
|
|
412
|
+
ref(element);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}; // If container isn't used for focus, give it a label of title if none is passed in,
|
|
416
|
+
// otherwise read the current position on focus
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
const containerAccessibilityLabel = ((_systemProps$accessib = systemProps.accessibilityLabel) !== null && _systemProps$accessib !== void 0 ? _systemProps$accessib : isFirstFocusContainer) ? "".concat(title ? "".concat(title, " ") : '').concat(getCopyWithPlaceholders('stepTrackerLabel')) : title;
|
|
420
|
+
const containerProps = {
|
|
421
|
+
accessibilityLabel: containerAccessibilityLabel,
|
|
422
|
+
// If used for focus, attach the ref and draw a focus box around the whole carousel
|
|
423
|
+
...(isFirstFocusContainer && {
|
|
424
|
+
ref: containerRef,
|
|
425
|
+
focusable: true
|
|
426
|
+
})
|
|
427
|
+
};
|
|
399
428
|
return /*#__PURE__*/_jsxs(CarouselProvider, {
|
|
400
429
|
activeIndex: activeIndex,
|
|
401
430
|
goTo: goTo,
|
|
@@ -411,6 +440,7 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
411
440
|
onLayout: onContainerLayout,
|
|
412
441
|
ref: ref,
|
|
413
442
|
...systemProps,
|
|
443
|
+
...containerProps,
|
|
414
444
|
children: [showPreviousNextNavigation && /*#__PURE__*/_jsx(View, {
|
|
415
445
|
style: selectPreviousNextNavigationButtonStyles(previousNextNavigationButtonWidth, previousNextNavigationPosition, spaceBetweenSlideAndPreviousNextNavigation, isFirstSlide, isLastSlide, true),
|
|
416
446
|
testID: "previous-button-container",
|
|
@@ -425,12 +455,10 @@ const Carousel = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
425
455
|
ref: firstFocusRef,
|
|
426
456
|
href: skipLinkHref,
|
|
427
457
|
children: getCopyWithPlaceholders('skipLink')
|
|
428
|
-
}), /*#__PURE__*/_jsx(A11yText // Read the current slide position to screen readers on slide.
|
|
458
|
+
}), !isFirstFocusContainer && /*#__PURE__*/_jsx(A11yText // Read the current slide position to screen readers on slide.
|
|
429
459
|
// If it's set to refocus and doesn't have a SkipLink to focus to, focus this.
|
|
430
460
|
, {
|
|
431
|
-
ref: !skipLinkHref && refocus ? firstFocusRef : null,
|
|
432
461
|
accessibilityLiveRegion: !skipLinkHref && refocus ? undefined : 'polite',
|
|
433
|
-
focusable: !skipLinkHref && refocus,
|
|
434
462
|
text: getCopyWithPlaceholders('stepTrackerLabel')
|
|
435
463
|
}), /*#__PURE__*/_jsx(View, {
|
|
436
464
|
style: selectContainerStyles(containerLayout.width),
|
|
@@ -531,7 +559,7 @@ Carousel.propTypes = { ...selectedSystemPropTypes,
|
|
|
531
559
|
* This function is also provided with a parameter indicating changed index (either 1, or -1)
|
|
532
560
|
* Use it as follows:
|
|
533
561
|
* ```js
|
|
534
|
-
* const onIndexChangedCallback = React.useCallback((changedIndex) => {
|
|
562
|
+
* const onIndexChangedCallback = React.useCallback((changedIndex, currentActiveIndex) => {
|
|
535
563
|
* console.log(changedIndex)
|
|
536
564
|
* }, []) // pass local dependencies as per your component
|
|
537
565
|
* <Carousel
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
|
-
import { layoutTags, getA11yPropsFromHtmlTag, selectSystemProps, a11yProps, viewProps } from '../../utils';
|
|
5
|
+
import { layoutTags, getA11yPropsFromHtmlTag, selectSystemProps, a11yProps, viewProps, variantProp } from '../../utils';
|
|
6
6
|
import { useCarousel } from '../CarouselContext';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
@@ -45,6 +45,7 @@ const CarouselItem = _ref => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
CarouselItem.propTypes = { ...selectedSystemPropTypes,
|
|
48
|
+
variant: variantProp.propType,
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* Index of the current slide
|
|
@@ -69,7 +70,12 @@ CarouselItem.propTypes = { ...selectedSystemPropTypes,
|
|
|
69
70
|
* Carousel's innermost container defaults to `'ul'` which can be overridden. If the tag of either
|
|
70
71
|
* `Carousel` or `Carousel.Item` is overriden, the other should be too, to avoid producing invalid HTML.
|
|
71
72
|
*/
|
|
72
|
-
tag: PropTypes.oneOf(layoutTags)
|
|
73
|
+
tag: PropTypes.oneOf(layoutTags),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Function to set carousel content background color when slide is being display
|
|
77
|
+
*/
|
|
78
|
+
setContentBackgroundColor: PropTypes.func
|
|
73
79
|
};
|
|
74
80
|
CarouselItem.displayName = 'Carousel.Item';
|
|
75
81
|
export default CarouselItem;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import React, { forwardRef, useRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import View from "react-native-web/dist/exports/View";
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import StackView from '../../StackView';
|
|
5
5
|
import { useCarousel } from '../CarouselContext';
|
|
6
6
|
import CarouselTabsPanelItem from './CarouselTabsPanelItem';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
const selectTabPanelStyle = () => ({
|
|
11
|
+
backgroundColor: 'transparent'
|
|
12
|
+
});
|
|
13
|
+
|
|
10
14
|
const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
11
15
|
let {
|
|
12
16
|
items
|
|
@@ -16,25 +20,23 @@ const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
16
20
|
goTo
|
|
17
21
|
} = useCarousel();
|
|
18
22
|
const nextFocusRef = useRef();
|
|
19
|
-
const firstTabRef = useRef();
|
|
23
|
+
const firstTabRef = useRef();
|
|
24
|
+
const [isInverse, setIsInverse] = useState(false); // TODO: figure out a better cross-brand way to specify subcomponent variants.
|
|
20
25
|
// For now, this picks an Allium variant, and does nothing in brands that lack it.
|
|
21
26
|
// See similar comment in Carousel and https://github.com/telus/universal-design-system/issues/1549
|
|
22
27
|
|
|
23
28
|
const dividerVariant = {
|
|
24
29
|
decorative: true
|
|
25
30
|
};
|
|
26
|
-
const lastTabSelected = activeIndex === items.length - 1;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (previousWebFocus !== firstTabRef.current) nextFocusRef.current.focus();
|
|
36
|
-
}
|
|
37
|
-
}), /*#__PURE__*/_jsx(StackView, {
|
|
31
|
+
const lastTabSelected = activeIndex === items.length - 1; // Get current select tab style
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const [selectedVariantIsInverse] = items.filter((_, index) => index === activeIndex);
|
|
35
|
+
setIsInverse(selectedVariantIsInverse === null || selectedVariantIsInverse === void 0 ? void 0 : selectedVariantIsInverse.inverse);
|
|
36
|
+
}, [items, activeIndex]);
|
|
37
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
38
|
+
style: selectTabPanelStyle(),
|
|
39
|
+
children: [/*#__PURE__*/_jsx(StackView, {
|
|
38
40
|
direction: "row",
|
|
39
41
|
space: 3,
|
|
40
42
|
divider: {
|
|
@@ -45,6 +47,7 @@ const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
45
47
|
let {
|
|
46
48
|
title,
|
|
47
49
|
onPress,
|
|
50
|
+
inverse,
|
|
48
51
|
...panelItemProps
|
|
49
52
|
} = _ref2;
|
|
50
53
|
const selected = index === activeIndex;
|
|
@@ -59,6 +62,9 @@ const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
59
62
|
title: title,
|
|
60
63
|
selected: selected,
|
|
61
64
|
onPress: handlePress,
|
|
65
|
+
variant: {
|
|
66
|
+
inverse: isInverse
|
|
67
|
+
},
|
|
62
68
|
...panelItemProps
|
|
63
69
|
}, title);
|
|
64
70
|
})
|
|
@@ -71,6 +77,8 @@ const CarouselTabsPanel = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
71
77
|
});
|
|
72
78
|
CarouselTabsPanel.displayName = 'CarouselTabsPanel';
|
|
73
79
|
CarouselTabsPanel.propTypes = {
|
|
74
|
-
items: PropTypes.arrayOf(PropTypes.shape(CarouselTabsPanelItem.propTypes || {}))
|
|
80
|
+
items: PropTypes.arrayOf(PropTypes.shape(CarouselTabsPanelItem.propTypes || {})),
|
|
81
|
+
// Color defined by `Carousel.item` variant otherwise fallback to transparent
|
|
82
|
+
contentBackgroundColor: PropTypes.string
|
|
75
83
|
};
|
|
76
84
|
export default CarouselTabsPanel;
|
|
@@ -2,12 +2,11 @@ import React, { forwardRef, useContext } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
4
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
|
-
import View from "react-native-web/dist/exports/View";
|
|
6
5
|
import { viewports } from '@telus-uds/system-constants';
|
|
7
6
|
import GutterContext from '../providers/GutterContext';
|
|
8
7
|
import { useViewport } from '../../ViewportProvider';
|
|
9
8
|
import applyInheritance from '../helpers';
|
|
10
|
-
import { responsiveProps } from '../../utils';
|
|
9
|
+
import { responsiveProps, BaseView } from '../../utils';
|
|
11
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
11
|
const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
13
12
|
let {
|
|
@@ -156,7 +155,7 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
156
155
|
lg: offsetsWithIheritance[3],
|
|
157
156
|
xl: offsetsWithIheritance[4]
|
|
158
157
|
};
|
|
159
|
-
return /*#__PURE__*/_jsx(
|
|
158
|
+
return /*#__PURE__*/_jsx(BaseView, {
|
|
160
159
|
ref: ref,
|
|
161
160
|
...viewProps,
|
|
162
161
|
style: [styles.col, gutterPadding, offsetStyles(offsets), sizeStyles(sizes), { ...hidingStyles
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import View from "react-native-web/dist/exports/View";
|
|
4
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
4
|
import { viewports } from '@telus-uds/system-constants';
|
|
5
|
+
import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps, BaseView } from '../utils';
|
|
6
6
|
import Row from './Row';
|
|
7
7
|
import Col from './Col';
|
|
8
8
|
import { useViewport } from '../ViewportProvider';
|
|
9
9
|
import GutterContext from './providers/GutterContext';
|
|
10
10
|
import applyInheritance from './helpers';
|
|
11
|
-
import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps } from '../utils';
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
14
13
|
/**
|
|
@@ -68,7 +67,7 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
68
67
|
};
|
|
69
68
|
return /*#__PURE__*/_jsx(GutterContext.Provider, {
|
|
70
69
|
value: gutter,
|
|
71
|
-
children: /*#__PURE__*/_jsx(
|
|
70
|
+
children: /*#__PURE__*/_jsx(BaseView, {
|
|
72
71
|
ref: ref,
|
|
73
72
|
...props,
|
|
74
73
|
style: [styles.grid, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import View from "react-native-web/dist/exports/View";
|
|
4
3
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
4
|
import { viewports } from '@telus-uds/system-constants';
|
|
6
5
|
import { useViewport } from '../../ViewportProvider';
|
|
7
6
|
import applyInheritance from '../helpers';
|
|
7
|
+
import { BaseView } from '../../utils';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
const horizontalAlignStyles = horizontalAlign => {
|
|
@@ -114,7 +114,7 @@ const Row = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
114
114
|
flexWrap = reverseLevel[4] ? 'wrap-reverse' : 'wrap';
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
return /*#__PURE__*/_jsx(
|
|
117
|
+
return /*#__PURE__*/_jsx(BaseView, {
|
|
118
118
|
ref: ref,
|
|
119
119
|
...rest,
|
|
120
120
|
style: [styles.row, {
|
|
@@ -77,10 +77,20 @@ const IconButton = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
77
77
|
const selectedProps = selectProps({ ...rest,
|
|
78
78
|
accessibilityRole
|
|
79
79
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
|
|
81
|
+
const handlePress = () => {
|
|
82
|
+
var _ref$current;
|
|
83
|
+
|
|
84
|
+
linkProps.handleHref({
|
|
85
|
+
href,
|
|
86
|
+
onPress
|
|
87
|
+
})({
|
|
88
|
+
nativeEvent: {
|
|
89
|
+
target: ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.id
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
84
94
|
const getTokens = useThemeTokensCallback('IconButton', tokens, variant);
|
|
85
95
|
|
|
86
96
|
const getOuterStyle = pressableState => selectOuterStyle(getTokens(resolvePressableState(pressableState)));
|