@telus-uds/components-base 1.30.1 → 1.32.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 +31 -2
- package/component-docs.json +25 -0
- package/lib/ActivityIndicator/Spinner.js +7 -7
- package/lib/ActivityIndicator/Spinner.native.js +2 -2
- package/lib/BaseProvider/HydrationContext.js +1 -1
- package/lib/Box/Box.js +1 -1
- package/lib/Button/ButtonBase.js +2 -2
- package/lib/Button/ButtonGroup.js +1 -1
- package/lib/Carousel/Carousel.js +2 -4
- package/lib/Carousel/CarouselContext.js +1 -1
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib/Carousel/CarouselThumbnail.js +2 -2
- package/lib/Checkbox/Checkbox.js +1 -1
- package/lib/Checkbox/CheckboxGroup.js +2 -2
- package/lib/Divider/Divider.js +2 -2
- package/lib/Fieldset/Fieldset.js +1 -5
- package/lib/Fieldset/FieldsetContainer.js +1 -1
- package/lib/FlexGrid/Col/Col.js +1 -1
- package/lib/Icon/Icon.js +1 -1
- package/lib/List/ListItemContent.js +5 -2
- package/lib/List/PressableListItemBase.js +2 -0
- package/lib/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib/Pagination/PageButton.js +2 -2
- package/lib/Pagination/Pagination.js +3 -5
- package/lib/Pagination/usePagination.js +2 -2
- package/lib/Progress/ProgressBar.js +3 -3
- package/lib/Progress/ProgressBarBackground.js +3 -3
- package/lib/Radio/Radio.js +2 -2
- package/lib/Radio/RadioGroup.js +2 -2
- package/lib/RadioCard/RadioCard.js +1 -1
- package/lib/RadioCard/RadioCardGroup.js +2 -2
- package/lib/Search/Search.js +1 -1
- package/lib/SideNav/SideNav.js +2 -2
- package/lib/Skeleton/Skeleton.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/StackView/StackWrap.js +1 -3
- package/lib/StackView/getStackedContent.js +2 -2
- package/lib/Tabs/Tabs.js +2 -4
- package/lib/Tags/Tags.js +1 -1
- package/lib/TextInput/TextInputBase.js +1 -1
- package/lib/ThemeProvider/utils/styles.js +8 -3
- package/lib/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib/Timeline/Timeline.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib/Tooltip/Backdrop.js +10 -2
- package/lib/Tooltip/Tooltip.js +2 -2
- package/lib/Validator/Validator.js +14 -15
- package/lib/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib/utils/children.js +2 -2
- package/lib/utils/input.js +13 -7
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +2 -2
- package/lib/utils/useSpacingScale.js +1 -3
- package/lib/utils/useUniqueId.js +1 -1
- package/lib-module/ActivityIndicator/Spinner.js +7 -7
- package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
- package/lib-module/BaseProvider/HydrationContext.js +1 -1
- package/lib-module/Box/Box.js +1 -1
- package/lib-module/Button/ButtonBase.js +2 -2
- package/lib-module/Button/ButtonGroup.js +1 -1
- package/lib-module/Carousel/Carousel.js +2 -4
- package/lib-module/Carousel/CarouselContext.js +1 -1
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +1 -1
- package/lib-module/Carousel/CarouselThumbnail.js +2 -2
- package/lib-module/Checkbox/Checkbox.js +1 -1
- package/lib-module/Checkbox/CheckboxGroup.js +2 -2
- package/lib-module/Divider/Divider.js +2 -2
- package/lib-module/Fieldset/Fieldset.js +1 -5
- package/lib-module/Fieldset/FieldsetContainer.js +1 -1
- package/lib-module/FlexGrid/Col/Col.js +1 -1
- package/lib-module/Icon/Icon.js +1 -1
- package/lib-module/List/ListItemContent.js +5 -2
- package/lib-module/List/PressableListItemBase.js +2 -0
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +2 -2
- package/lib-module/Pagination/PageButton.js +2 -2
- package/lib-module/Pagination/Pagination.js +3 -5
- package/lib-module/Pagination/usePagination.js +2 -2
- package/lib-module/Progress/ProgressBar.js +3 -3
- package/lib-module/Progress/ProgressBarBackground.js +3 -3
- package/lib-module/Radio/Radio.js +2 -2
- package/lib-module/Radio/RadioGroup.js +2 -2
- package/lib-module/RadioCard/RadioCard.js +1 -1
- package/lib-module/RadioCard/RadioCardGroup.js +2 -2
- package/lib-module/Search/Search.js +1 -1
- package/lib-module/SideNav/SideNav.js +2 -2
- package/lib-module/Skeleton/Skeleton.js +1 -1
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/StackView/StackWrap.js +1 -3
- package/lib-module/StackView/getStackedContent.js +2 -2
- package/lib-module/Tabs/Tabs.js +2 -4
- package/lib-module/Tags/Tags.js +1 -1
- package/lib-module/TextInput/TextInputBase.js +1 -1
- package/lib-module/ThemeProvider/utils/styles.js +8 -3
- package/lib-module/ThemeProvider/utils/theme-tokens.js +9 -7
- package/lib-module/Timeline/Timeline.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitch.js +1 -1
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +1 -1
- package/lib-module/Tooltip/Backdrop.js +10 -2
- package/lib-module/Tooltip/Tooltip.js +2 -2
- package/lib-module/Validator/Validator.js +14 -15
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +1 -1
- package/lib-module/utils/children.js +2 -2
- package/lib-module/utils/input.js +13 -7
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +2 -2
- package/lib-module/utils/useSpacingScale.js +1 -3
- package/lib-module/utils/useUniqueId.js +1 -1
- package/package.json +2 -2
- package/src/Fieldset/Fieldset.jsx +1 -7
- package/src/Fieldset/FieldsetContainer.jsx +1 -1
- package/src/List/ListItemContent.jsx +4 -2
- package/src/List/PressableListItemBase.jsx +2 -0
- package/src/ThemeProvider/utils/styles.js +5 -0
- package/src/Validator/Validator.jsx +2 -1
|
@@ -17,29 +17,27 @@ export const getComponentTheme = (theme, componentName) => {
|
|
|
17
17
|
// Give clear and understandable error messages for common dev errors, for example,
|
|
18
18
|
// typo in component name, missing export or accessing old version of theme
|
|
19
19
|
if (!theme) {
|
|
20
|
-
throw new Error(
|
|
20
|
+
throw new Error(`Called useTheme's getStyle on "${componentName}" with no theme provided`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const themeName = ((_theme$metadata = theme.metadata) === null || _theme$metadata === void 0 ? void 0 : _theme$metadata.name) || '';
|
|
24
24
|
|
|
25
25
|
if (!theme.components) {
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(`Theme "${themeName}" has no components defined (looking for "${componentName}")`);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const componentTheme = theme.components[componentName];
|
|
30
30
|
|
|
31
31
|
if (!componentTheme) {
|
|
32
|
-
throw new Error(
|
|
32
|
+
throw new Error(`Theme "${themeName}" does not have styles for component "${componentName}"`);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return componentTheme;
|
|
36
36
|
};
|
|
37
37
|
export const doesThemeConditionApply = (_ref, appearances) => {
|
|
38
|
-
var _appearances$key;
|
|
39
|
-
|
|
40
38
|
let [key, value] = _ref;
|
|
41
39
|
// use null rather than undefined so we can serialise the value in themes
|
|
42
|
-
const appearanceValue =
|
|
40
|
+
const appearanceValue = appearances[key] ?? null;
|
|
43
41
|
return Array.isArray(value) ? value.includes(appearanceValue) : value === appearanceValue;
|
|
44
42
|
};
|
|
45
43
|
export const doesThemeRuleApply = (rule, appearances) => Object.entries(rule.if).every(condition => doesThemeConditionApply(condition, appearances));
|
|
@@ -158,6 +156,10 @@ export const validateThemeTokensVersion = theme => {
|
|
|
158
156
|
const actualThemeTokensVersion = theme === null || theme === void 0 ? void 0 : (_theme$metadata2 = theme.metadata) === null || _theme$metadata2 === void 0 ? void 0 : _theme$metadata2.themeTokensVersion;
|
|
159
157
|
|
|
160
158
|
if (!semVerSatisfies(actualThemeTokensVersion, expectedThemeTokensVersion)) {
|
|
161
|
-
throw new Error(
|
|
159
|
+
throw new Error(`Invalid UDS token schema version detected.
|
|
160
|
+
|
|
161
|
+
The UDS base components ${pkg.name} v${pkg.version} are only compatible with UDS themes that are built with @telus-uds/system-theme-tokens version that is semver compatible with ${expectedThemeTokensVersion}. The current theme was built with @telus-uds/system-theme-tokens v${actualThemeTokensVersion}.
|
|
162
|
+
|
|
163
|
+
If you see this error than most likely you have attempted to install ${pkg.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`);
|
|
162
164
|
}
|
|
163
165
|
};
|
|
@@ -141,7 +141,7 @@ const Timeline = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
|
141
141
|
style: selectItemContentStyles(themeTokens, index + 1 === children.length),
|
|
142
142
|
children: child
|
|
143
143
|
})]
|
|
144
|
-
},
|
|
144
|
+
}, `timeline-${index}-${child.displayName}`);
|
|
145
145
|
})
|
|
146
146
|
});
|
|
147
147
|
});
|
|
@@ -136,7 +136,7 @@ const ToggleSwitch = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
|
136
136
|
const getButtonTokens = buttonState => selectButtonTokens(getTokens(buttonState));
|
|
137
137
|
|
|
138
138
|
const uniqueId = useUniqueId('toggleSwitch');
|
|
139
|
-
const inputId = id
|
|
139
|
+
const inputId = id ?? uniqueId;
|
|
140
140
|
return /*#__PURE__*/_jsxs(StackView, {
|
|
141
141
|
space: 2,
|
|
142
142
|
direction: "row",
|
|
@@ -63,7 +63,7 @@ const ToggleSwitchGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
63
63
|
const uniqueFields = ['id', 'label'];
|
|
64
64
|
|
|
65
65
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
66
|
-
throw new Error(
|
|
66
|
+
throw new Error(`ToggleSwitchGroup items must have unique ${uniqueFields.join(', ')}`);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const toggleSwitches = items.map((_ref2, index) => {
|
|
@@ -8,7 +8,15 @@ function createPortalNode(nodeId) {
|
|
|
8
8
|
// this way the backdrop stays in place when scrolling the window - that's why we need to
|
|
9
9
|
// position it at the scroll position when rendering
|
|
10
10
|
|
|
11
|
-
node.style.cssText =
|
|
11
|
+
node.style.cssText = `
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: ${window.scrollY}px;
|
|
14
|
+
left: ${window.scrollX}px;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
z-index: 9999;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
`;
|
|
12
20
|
document.body.appendChild(node);
|
|
13
21
|
return node;
|
|
14
22
|
}
|
|
@@ -29,7 +37,7 @@ function Backdrop(_ref) {
|
|
|
29
37
|
} = _ref;
|
|
30
38
|
const [portalNode, setPortalNode] = useState();
|
|
31
39
|
useEffect(() => {
|
|
32
|
-
const nodeId =
|
|
40
|
+
const nodeId = `tooltip-backdrop-${Date.now()}`;
|
|
33
41
|
const node = createPortalNode(nodeId);
|
|
34
42
|
setPortalNode(node);
|
|
35
43
|
return () => {
|
|
@@ -236,8 +236,8 @@ const Tooltip = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
236
236
|
style: [selectTooltipShadowStyles(themeTokens), staticStyles.tooltip, // applied separately so that it doesn't cover the arrow
|
|
237
237
|
selectMobileTooltipPositionStyles({
|
|
238
238
|
position: strategy,
|
|
239
|
-
top: y
|
|
240
|
-
left: x
|
|
239
|
+
top: y ?? 0,
|
|
240
|
+
left: x ?? 0
|
|
241
241
|
})],
|
|
242
242
|
onLayout: onTooltipLayout,
|
|
243
243
|
accessibilityRole: "alert",
|
|
@@ -33,7 +33,7 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
33
33
|
...rest
|
|
34
34
|
} = _ref2;
|
|
35
35
|
const defaultRef = useRef();
|
|
36
|
-
const codeRef = ref
|
|
36
|
+
const codeRef = ref ?? defaultRef;
|
|
37
37
|
const {
|
|
38
38
|
supportsProps
|
|
39
39
|
} = selectProps(rest);
|
|
@@ -88,15 +88,13 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const handleChangeCodeValues = (event, codeId, nextIndex) => {
|
|
91
|
-
var _codeReferences$codeI, _event$nativeEvent, _event$target, _codeElement$value, _codeElement$value2
|
|
91
|
+
var _codeReferences$codeI, _event$nativeEvent, _event$target, _codeElement$value, _codeElement$value2;
|
|
92
92
|
|
|
93
93
|
const codeElement = (_codeReferences$codeI = codeReferences[codeId]) === null || _codeReferences$codeI === void 0 ? void 0 : _codeReferences$codeI.current;
|
|
94
94
|
const val = ((_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.value) || ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
|
|
95
95
|
|
|
96
96
|
if (Number(val).toString() === 'NaN') {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
codeElement.value = (_singleCodes$codeId = singleCodes[codeId]) !== null && _singleCodes$codeId !== void 0 ? _singleCodes$codeId : '';
|
|
97
|
+
codeElement.value = singleCodes[codeId] ?? '';
|
|
100
98
|
return;
|
|
101
99
|
}
|
|
102
100
|
|
|
@@ -107,7 +105,7 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
107
105
|
handleSingleCodes(codeId, codeElement.value, 'success');
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
handleSingleCodes(codeId, (
|
|
108
|
+
handleSingleCodes(codeId, (codeElement === null || codeElement === void 0 ? void 0 : codeElement.value) ?? singleCodes[codeId], 'success');
|
|
111
109
|
handleChangeCode();
|
|
112
110
|
|
|
113
111
|
if (nextIndex === validatorsLength) {
|
|
@@ -115,7 +113,7 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
115
113
|
return;
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
if ((codeElement === null || codeElement === void 0 ? void 0 : (_codeElement$
|
|
116
|
+
if ((codeElement === null || codeElement === void 0 ? void 0 : (_codeElement$value2 = codeElement.value) === null || _codeElement$value2 === void 0 ? void 0 : _codeElement$value2.length) > 0) codeReferences[prefix + nextIndex].current.focus();
|
|
119
117
|
};
|
|
120
118
|
|
|
121
119
|
const handleKeyPress = (event, currentIndex, previousIndex) => {
|
|
@@ -134,15 +132,18 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
134
132
|
const components = [];
|
|
135
133
|
|
|
136
134
|
for (let i = 0; validatorsLength && i < validatorsLength; i += 1) {
|
|
137
|
-
var _codeReferences$codeI2;
|
|
138
|
-
|
|
139
135
|
const codeId = prefix + i;
|
|
140
136
|
const codeInputProps = {
|
|
141
137
|
nativeID: codeId,
|
|
142
|
-
|
|
138
|
+
keyboardType: 'numeric',
|
|
139
|
+
ref: codeReferences[codeId] ?? null,
|
|
143
140
|
validation: strValidation || singleCodes[codeId + sufixValidation],
|
|
144
141
|
tokens: selectCodeTextInputTokens(themeTokens),
|
|
145
|
-
onFocus: () =>
|
|
142
|
+
onFocus: () => {
|
|
143
|
+
var _codeReferences$codeI2, _codeReferences$codeI3;
|
|
144
|
+
|
|
145
|
+
return ((_codeReferences$codeI2 = codeReferences[codeId]) === null || _codeReferences$codeI2 === void 0 ? void 0 : (_codeReferences$codeI3 = _codeReferences$codeI2.current) === null || _codeReferences$codeI3 === void 0 ? void 0 : _codeReferences$codeI3.select()) ?? null;
|
|
146
|
+
},
|
|
146
147
|
onKeyPress: event => handleKeyPress(event, i, i - 1),
|
|
147
148
|
onMouseOver: handleMouseOver,
|
|
148
149
|
onMouseOut: handleMouseOut,
|
|
@@ -167,10 +168,8 @@ const Validator = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
167
168
|
|
|
168
169
|
useEffect(() => {
|
|
169
170
|
for (let i = 0; i < validatorsLength; i += 1) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
codeReferences[prefix + i].current.value = (_text$i = text[i]) !== null && _text$i !== void 0 ? _text$i : '';
|
|
173
|
-
handleSingleCodes(prefix + i, (_text$i2 = text[i]) !== null && _text$i2 !== void 0 ? _text$i2 : '', text[i] ? 'success' : '');
|
|
171
|
+
codeReferences[prefix + i].current.value = text[i] ?? '';
|
|
172
|
+
handleSingleCodes(prefix + i, text[i] ?? '', text[i] ? 'success' : '');
|
|
174
173
|
}
|
|
175
174
|
}, [text]);
|
|
176
175
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
@@ -72,7 +72,7 @@ function useVerticalExpandAnimation(_ref) {
|
|
|
72
72
|
}
|
|
73
73
|
} else if (Platform.OS === 'web') {
|
|
74
74
|
const transitionDuration = isExpanded ? expandDuration : collapseDuration;
|
|
75
|
-
containerStyles.transition =
|
|
75
|
+
containerStyles.transition = `height ${transitionDuration}ms ease-in-out`;
|
|
76
76
|
containerStyles.height = isExpanded ? containerHeight : 0;
|
|
77
77
|
} else if (Platform.OS === 'ios' && isExpanded && !isAnimating && !expandStateChanged && typeof containerHeight === 'number') {
|
|
78
78
|
// iOS reflows text while the height animation is in progress. Sometimes, it hits a timing bug where
|
|
@@ -55,7 +55,7 @@ const isWrapable = child => {
|
|
|
55
55
|
return isStringOrNumber(child) || child.type === A11yText || ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) === 'FootnoteLink';
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
const combineKeys = childrenArray => childrenArray.reduce((newKey, child) =>
|
|
58
|
+
const combineKeys = childrenArray => childrenArray.reduce((newKey, child) => `${newKey}${child.key || ''}`, ''); // Group wrappable children for one `<Text>` parent, merging adjacent text nodes
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
const wrapChild = (child, wrappedText) => {
|
|
@@ -64,7 +64,7 @@ const wrapChild = (child, wrappedText) => {
|
|
|
64
64
|
|
|
65
65
|
if (lastIndex >= 0 && isStringOrNumber(child) && isStringOrNumber(wrappedText[lastIndex])) {
|
|
66
66
|
/* eslint-disable-next-line no-param-reassign */
|
|
67
|
-
wrappedText[lastIndex] =
|
|
67
|
+
wrappedText[lastIndex] = `${wrappedText[lastIndex]}${child}`;
|
|
68
68
|
} else {
|
|
69
69
|
wrappedText.push(child);
|
|
70
70
|
}
|
|
@@ -21,23 +21,29 @@ const validateProps = (_ref, _ref2, hookName) => {
|
|
|
21
21
|
const usageError = error => {
|
|
22
22
|
// Errors inside hooks in React Native get incomplete stack traces pointing at parent component only.
|
|
23
23
|
// Help devs out by telling them exactly which hook threw the error as well as why.
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error(`${hookName} ${error}.
|
|
25
|
+
|
|
26
|
+
Consumers of this hook must be one of:
|
|
27
|
+
1. An "uncontrolled" component responding directly to user actions, with an optional \`initialValue${s}\` but no \`value${s}\` prop,
|
|
28
|
+
2. A "controlled" component where an always-defined \`value${s}\` prop is managed by an \`onChange\` handler, with no \`initialValue${s}\`,
|
|
29
|
+
3. A "read-only" component, with \`readOnly\` prop set as \`true\`.
|
|
30
|
+
`);
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
if (value && !onChange && !readOnly) {
|
|
28
|
-
usageError(
|
|
34
|
+
usageError(`has \`value${s}\` prop without \`onChange\` or \`readOnly\``);
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
if (initialValue && value) {
|
|
32
|
-
usageError(
|
|
38
|
+
usageError(`has both \`initialValue${s}\` and \`value${s}\``);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
if (isControlled && !isCurrentlyControlled) {
|
|
36
|
-
usageError(
|
|
42
|
+
usageError(`stopped receiving \`value${s}\` from parent after delegating state management`);
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
if (!isControlled && isCurrentlyControlled) {
|
|
40
|
-
usageError(
|
|
46
|
+
usageError(`started receiving \`value${s}\` from parent after starting managing own state`);
|
|
41
47
|
}
|
|
42
48
|
};
|
|
43
49
|
/**
|
|
@@ -98,7 +104,7 @@ export const useInputValue = function () {
|
|
|
98
104
|
|
|
99
105
|
if (!isControlled) {
|
|
100
106
|
setOwnValue(newValue);
|
|
101
|
-
if (inputRef !== null && inputRef !== void 0 && inputRef.current) inputRef.current.value = newValue
|
|
107
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current) inputRef.current.value = newValue ?? '';
|
|
102
108
|
} // Call onChange handler if there's something for it to handle (event or a changed value)
|
|
103
109
|
|
|
104
110
|
|
|
@@ -156,7 +162,7 @@ export const useMultipleInputValues = function () {
|
|
|
156
162
|
onChange,
|
|
157
163
|
value: values,
|
|
158
164
|
// if we're controlling our own state, always start with an array
|
|
159
|
-
initialValue: initialValues
|
|
165
|
+
initialValue: initialValues ?? (values === undefined ? [] : undefined)
|
|
160
166
|
}, 'useMultipleInputValues');
|
|
161
167
|
const enforceMaxValues = useCallback(newValues => {
|
|
162
168
|
if (!maxValues) return newValues;
|
|
@@ -26,8 +26,8 @@ export default function componentPropType(passedName) {
|
|
|
26
26
|
const nameInProp = ((_props$propName$type = props[propName].type) === null || _props$propName$type === void 0 ? void 0 : _props$propName$type.displayName) || ((_props$propName$type2 = props[propName].type) === null || _props$propName$type2 === void 0 ? void 0 : _props$propName$type2.name);
|
|
27
27
|
|
|
28
28
|
if (!nameInProp || !passedNames.includes(nameInProp)) {
|
|
29
|
-
const propDescription = nameInProp ?
|
|
30
|
-
return new Error(
|
|
29
|
+
const propDescription = nameInProp ? `Component ${nameInProp}` : typeof props[propName];
|
|
30
|
+
return new Error(`${componentName}: ${propDescription} was passed to \`${propName}\` prop; should be ${passedNames.join(' or ')}`);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return undefined;
|
|
@@ -35,7 +35,7 @@ export default function componentPropType(passedName) {
|
|
|
35
35
|
|
|
36
36
|
const checkRequired = (props, propName, componentName) => {
|
|
37
37
|
if (props[propName] === undefined) {
|
|
38
|
-
return new Error(
|
|
38
|
+
return new Error(`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is ${props[propName]}.`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return undefined;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export default function selectSystemProps(systemPropHelpers) {
|
|
4
4
|
const selectProps = props => systemPropHelpers.reduce((acc, propHelper) => {
|
|
5
5
|
if (typeof (propHelper === null || propHelper === void 0 ? void 0 : propHelper.select) !== 'function') {
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': prop selector ('.select') is missing in ${propHelper}`);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
return { ...acc,
|
|
@@ -13,7 +13,7 @@ export default function selectSystemProps(systemPropHelpers) {
|
|
|
13
13
|
|
|
14
14
|
const selectedPropTypes = systemPropHelpers.reduce((acc, propHelper) => {
|
|
15
15
|
if (!(propHelper !== null && propHelper !== void 0 && propHelper.types)) {
|
|
16
|
-
throw new Error(
|
|
16
|
+
throw new Error(`An invalid system prop helper has been passed to 'selectSystemProps': types selector ('.types') is missing in ${propHelper}`);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return { ...acc,
|
|
@@ -9,7 +9,7 @@ export const getTokenNames = componentName => {
|
|
|
9
9
|
const componentTokenSchema = tokenKeys[componentName];
|
|
10
10
|
|
|
11
11
|
if (!componentTokenSchema) {
|
|
12
|
-
throw new Error(
|
|
12
|
+
throw new Error(`No "${componentName}" tokenKeys in @telus-uds/system-theme-tokens`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return Object.keys(componentTokenSchema);
|
|
@@ -47,7 +47,7 @@ export const getTokenNames = componentName => {
|
|
|
47
47
|
export const selectTokens = (specifier, tokens, prefix) => {
|
|
48
48
|
const tokenNames = typeof specifier === 'string' ? getTokenNames(specifier) : specifier;
|
|
49
49
|
const filteredTokens = tokenNames.reduce((validTokens, key) => {
|
|
50
|
-
const prefixedKey = prefix ?
|
|
50
|
+
const prefixedKey = prefix ? `${prefix}${key[0].toUpperCase()}${key.slice(1)}` : key;
|
|
51
51
|
const token = tokens[prefixedKey];
|
|
52
52
|
return token !== undefined ? { ...validTokens,
|
|
53
53
|
[key]: token
|
|
@@ -101,8 +101,6 @@ const resolveSpacingOptions = space => {
|
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
const useSpacingScale = spaceValue => {
|
|
104
|
-
var _spaceValue$space;
|
|
105
|
-
|
|
106
104
|
// In future, may need to consider window height as well as width, particularly for native apps,
|
|
107
105
|
// e.g. to ensure designs don't look lost on large, tall, not-so-wide portrait screens.
|
|
108
106
|
const viewport = useViewport();
|
|
@@ -112,7 +110,7 @@ const useSpacingScale = spaceValue => {
|
|
|
112
110
|
overridden,
|
|
113
111
|
subtract = 0
|
|
114
112
|
} = resolveSpacingOptions(spaceValue);
|
|
115
|
-
const space = !overridden && ((
|
|
113
|
+
const space = !overridden && ((spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) ?? resolveResponsiveProp(spaceValue, viewport, 0));
|
|
116
114
|
const {
|
|
117
115
|
size
|
|
118
116
|
} = useThemeTokens('spacingScale', tokens, variant, {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@floating-ui/react-native": "^0.8.1",
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@telus-uds/system-constants": "^1.2.0",
|
|
14
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
14
|
+
"@telus-uds/system-theme-tokens": "^2.16.0",
|
|
15
15
|
"airbnb-prop-types": "^2.16.0",
|
|
16
16
|
"lodash.debounce": "^4.0.8",
|
|
17
17
|
"lodash.merge": "^4.6.2",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"standard-engine": {
|
|
73
73
|
"skip": true
|
|
74
74
|
},
|
|
75
|
-
"version": "1.
|
|
75
|
+
"version": "1.32.0"
|
|
76
76
|
}
|
|
@@ -73,9 +73,7 @@ const Fieldset = forwardRef(
|
|
|
73
73
|
? [legendContent, feedbackContent, childContent]
|
|
74
74
|
: [legendContent, childContent, feedbackContent]
|
|
75
75
|
const stackedContent = getStackedContent(orderedContent, { space, preserveFragments: true })
|
|
76
|
-
const borderStyle =
|
|
77
|
-
(validation === 'error' && showErrorBorder && staticStyles.errorBorder) ||
|
|
78
|
-
staticStyles.noBorder
|
|
76
|
+
const borderStyle = validation === 'error' && showErrorBorder ? staticStyles.errorBorder : null
|
|
79
77
|
|
|
80
78
|
return (
|
|
81
79
|
<FieldsetContainer
|
|
@@ -98,10 +96,6 @@ const staticStyles = StyleSheet.create({
|
|
|
98
96
|
borderColor: 'red',
|
|
99
97
|
borderRadius: 10,
|
|
100
98
|
padding: 8
|
|
101
|
-
},
|
|
102
|
-
noBorder: {
|
|
103
|
-
padding: 9,
|
|
104
|
-
border: 'unset'
|
|
105
99
|
}
|
|
106
100
|
})
|
|
107
101
|
|
|
@@ -19,7 +19,7 @@ const FieldsetContainer = forwardRef(
|
|
|
19
19
|
ref
|
|
20
20
|
) => {
|
|
21
21
|
// If needs border for error design or reset the component style
|
|
22
|
-
const styleContainer = showBorderStyle ? borderStyle : cssReset
|
|
22
|
+
const styleContainer = showBorderStyle && borderStyle ? borderStyle : cssReset
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<fieldset
|
|
@@ -9,14 +9,16 @@ export const tokenTypes = {
|
|
|
9
9
|
itemFontWeight: PropTypes.string.isRequired,
|
|
10
10
|
itemFontSize: PropTypes.number.isRequired,
|
|
11
11
|
itemLineHeight: PropTypes.number.isRequired,
|
|
12
|
-
itemFontName: PropTypes.string.isRequired
|
|
12
|
+
itemFontName: PropTypes.string.isRequired,
|
|
13
|
+
itemFontColor: PropTypes.string
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const selectItemTextStyles = (
|
|
16
|
-
{ itemFontWeight, itemFontSize, itemLineHeight, itemFontName },
|
|
17
|
+
{ itemFontWeight, itemFontSize, itemLineHeight, itemFontName, itemFontColor },
|
|
17
18
|
themeOptions
|
|
18
19
|
) =>
|
|
19
20
|
applyTextStyles({
|
|
21
|
+
fontColor: itemFontColor,
|
|
20
22
|
fontWeight: itemFontWeight,
|
|
21
23
|
fontSize: itemFontSize,
|
|
22
24
|
lineHeight: itemLineHeight,
|
|
@@ -19,6 +19,7 @@ import ListItemMark from './ListItemMark'
|
|
|
19
19
|
|
|
20
20
|
const selectPressableStyles = ({
|
|
21
21
|
backgroundColor,
|
|
22
|
+
itemFontColor,
|
|
22
23
|
paddingLeft,
|
|
23
24
|
paddingRight,
|
|
24
25
|
paddingTop,
|
|
@@ -26,6 +27,7 @@ const selectPressableStyles = ({
|
|
|
26
27
|
interItemMargin
|
|
27
28
|
}) => ({
|
|
28
29
|
backgroundColor,
|
|
30
|
+
itemFontColor,
|
|
29
31
|
paddingLeft,
|
|
30
32
|
paddingRight,
|
|
31
33
|
paddingTop,
|
|
@@ -8,6 +8,7 @@ import { fontBasePixels } from '@telus-uds/system-constants'
|
|
|
8
8
|
|
|
9
9
|
// Make design tokens fit React Native's text styles' specific requirements and quirks
|
|
10
10
|
export function applyTextStyles({
|
|
11
|
+
fontColor,
|
|
11
12
|
fontSize,
|
|
12
13
|
fontScaleCap,
|
|
13
14
|
lineHeight,
|
|
@@ -51,6 +52,10 @@ export function applyTextStyles({
|
|
|
51
52
|
styles.fontWeight = Platform.OS === 'android' && Number(fontWeight) > 400 ? 'bold' : fontWeight
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
if (fontColor) {
|
|
56
|
+
styles.color = fontColor
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
// TODO: look into calculating typographic spacing with PixelRatio.getFontScale()
|
|
55
60
|
// Do while implementing advanced typography e.g. paragraph etc
|
|
56
61
|
// https://github.com/telus/universal-design-system/issues/89
|
|
@@ -109,10 +109,11 @@ const Validator = forwardRef(
|
|
|
109
109
|
const codeId = prefix + i
|
|
110
110
|
const codeInputProps = {
|
|
111
111
|
nativeID: codeId,
|
|
112
|
+
keyboardType: 'numeric',
|
|
112
113
|
ref: codeReferences[codeId] ?? null,
|
|
113
114
|
validation: strValidation || singleCodes[codeId + sufixValidation],
|
|
114
115
|
tokens: selectCodeTextInputTokens(themeTokens),
|
|
115
|
-
onFocus: () => codeReferences[codeId]
|
|
116
|
+
onFocus: () => codeReferences[codeId]?.current?.select() ?? null,
|
|
116
117
|
onKeyPress: (event) => handleKeyPress(event, i, i - 1),
|
|
117
118
|
onMouseOver: handleMouseOver,
|
|
118
119
|
onMouseOut: handleMouseOut,
|