@telus-uds/components-base 1.8.1 → 1.8.4
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 +35 -2
- package/component-docs.json +711 -669
- package/lib/A11yInfoProvider/index.js +4 -3
- package/lib/A11yText/index.js +6 -5
- package/lib/ActivityIndicator/Spinner.js +14 -13
- package/lib/ActivityIndicator/Spinner.native.js +10 -8
- package/lib/ActivityIndicator/index.js +6 -5
- package/lib/ActivityIndicator/shared.js +1 -1
- package/lib/BaseProvider/index.js +13 -10
- package/lib/Box/Box.js +20 -19
- package/lib/Button/Button.js +7 -6
- package/lib/Button/ButtonBase.js +97 -79
- package/lib/Button/ButtonGroup.js +34 -32
- package/lib/Button/ButtonLink.js +9 -7
- package/lib/Button/index.js +4 -4
- package/lib/Button/propTypes.js +1 -1
- package/lib/Card/Card.js +8 -7
- package/lib/Card/CardBase.js +35 -31
- package/lib/Card/PressableCardBase.js +14 -12
- package/lib/Checkbox/Checkbox.js +97 -83
- package/lib/Checkbox/CheckboxGroup.js +29 -27
- package/lib/Checkbox/CheckboxInput.js +12 -10
- package/lib/Divider/Divider.js +10 -9
- package/lib/ExpandCollapse/Control.js +42 -36
- package/lib/ExpandCollapse/ExpandCollapse.js +11 -10
- package/lib/ExpandCollapse/Panel.js +29 -40
- package/lib/Feedback/Feedback.js +48 -35
- package/lib/Fieldset/Fieldset.js +16 -15
- package/lib/Fieldset/FieldsetContainer.js +16 -13
- package/lib/Fieldset/FieldsetContainer.native.js +11 -8
- package/lib/Fieldset/Legend.js +10 -7
- package/lib/Fieldset/Legend.native.js +10 -7
- package/lib/FlexGrid/Col/Col.js +18 -17
- package/lib/FlexGrid/FlexGrid.js +15 -14
- package/lib/FlexGrid/Row/Row.js +13 -12
- package/lib/HorizontalScroll/HorizontalScroll.js +25 -20
- package/lib/HorizontalScroll/HorizontalScrollButton.js +18 -14
- package/lib/HorizontalScroll/ScrollViewEnd.js +6 -5
- package/lib/HorizontalScroll/ScrollViewEnd.native.js +12 -9
- package/lib/HorizontalScroll/itemPositions.js +19 -13
- package/lib/Icon/Icon.js +11 -10
- package/lib/Icon/IconText.js +8 -7
- package/lib/Icon/index.js +5 -5
- package/lib/IconButton/IconButton.js +50 -42
- package/lib/InputLabel/InputLabel.js +37 -30
- package/lib/InputLabel/LabelContent.js +12 -9
- package/lib/InputLabel/LabelContent.native.js +9 -6
- package/lib/InputSupports/InputSupports.js +11 -10
- package/lib/InputSupports/useInputSupports.js +7 -6
- package/lib/Link/ChevronLink.js +9 -8
- package/lib/Link/InlinePressable.js +13 -10
- package/lib/Link/InlinePressable.native.js +20 -16
- package/lib/Link/Link.js +10 -9
- package/lib/Link/LinkBase.js +96 -78
- package/lib/Link/TextButton.js +9 -8
- package/lib/List/List.js +20 -13
- package/lib/List/ListItem.js +103 -79
- package/lib/Modal/Modal.js +74 -60
- package/lib/Notification/Notification.js +46 -33
- package/lib/Pagination/PageButton.js +13 -12
- package/lib/Pagination/Pagination.js +43 -30
- package/lib/Pagination/SideButton.js +21 -18
- package/lib/Pagination/usePagination.js +7 -6
- package/lib/Progress/Progress.js +23 -19
- package/lib/Progress/ProgressBar.js +25 -21
- package/lib/Progress/ProgressBarBackground.js +7 -6
- package/lib/Radio/Radio.js +80 -69
- package/lib/Radio/RadioButton.js +63 -53
- package/lib/Radio/RadioGroup.js +30 -28
- package/lib/Radio/RadioInput.js +12 -10
- package/lib/RadioCard/RadioCard.js +16 -15
- package/lib/RadioCard/RadioCardGroup.js +30 -28
- package/lib/Search/Search.js +52 -32
- package/lib/Select/Group.js +5 -4
- package/lib/Select/Group.native.js +4 -3
- package/lib/Select/Item.js +10 -7
- package/lib/Select/Item.native.js +1 -9
- package/lib/Select/Picker.js +16 -15
- package/lib/Select/Picker.native.js +49 -38
- package/lib/Select/Select.js +134 -113
- package/lib/SideNav/Item.js +39 -33
- package/lib/SideNav/ItemContent.js +15 -12
- package/lib/SideNav/ItemsGroup.js +13 -11
- package/lib/SideNav/SideNav.js +21 -18
- package/lib/Skeleton/Skeleton.js +60 -44
- package/lib/Skeleton/skeleton.constant.js +1 -1
- package/lib/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib/Spacer/Spacer.js +6 -5
- package/lib/StackView/StackView.js +12 -11
- package/lib/StackView/StackWrap.js +5 -3
- package/lib/StackView/StackWrapBox.js +12 -11
- package/lib/StackView/StackWrapGap.js +11 -10
- package/lib/StackView/common.js +14 -11
- package/lib/StackView/getStackedContent.js +10 -9
- package/lib/StackView/index.js +1 -1
- package/lib/StepTracker/Step.js +122 -103
- package/lib/StepTracker/StepTracker.js +48 -38
- package/lib/Tabs/Tabs.js +57 -27
- package/lib/Tabs/TabsItem.js +78 -68
- package/lib/Tags/Tags.js +68 -62
- package/lib/TextInput/TextArea.js +26 -20
- package/lib/TextInput/TextInput.js +20 -15
- package/lib/TextInput/TextInputBase.js +74 -62
- package/lib/TextInput/index.js +4 -4
- package/lib/ThemeProvider/ThemeProvider.js +6 -5
- package/lib/ThemeProvider/index.js +5 -5
- package/lib/ThemeProvider/useSetTheme.js +6 -3
- package/lib/ThemeProvider/useThemeTokens.js +7 -2
- package/lib/ThemeProvider/utils/styles.js +50 -43
- package/lib/ThemeProvider/utils/theme-tokens.js +33 -21
- package/lib/ToggleSwitch/ToggleSwitch.js +90 -74
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +37 -35
- package/lib/Tooltip/Backdrop.js +6 -13
- package/lib/Tooltip/Backdrop.native.js +5 -4
- package/lib/Tooltip/Tooltip.js +81 -65
- package/lib/Tooltip/getTooltipPosition.js +29 -18
- package/lib/TooltipButton/TooltipButton.js +28 -21
- package/lib/Typography/Typography.js +37 -33
- package/lib/ViewportProvider/ViewportProvider.js +4 -3
- package/lib/ViewportProvider/useViewportListener.js +6 -3
- package/lib/index.js +54 -54
- package/lib/utils/a11y/semantics.js +5 -2
- package/lib/utils/a11y/textSize.js +8 -6
- package/lib/utils/animation/useVerticalExpandAnimation.js +46 -19
- package/lib/utils/children.js +4 -3
- package/lib/utils/index.js +10 -10
- package/lib/utils/input.js +28 -29
- package/lib/utils/pressability.js +36 -22
- package/lib/utils/props/clickProps.js +2 -1
- package/lib/utils/props/componentPropType.js +3 -3
- package/lib/utils/props/getPropSelector.js +6 -3
- package/lib/utils/props/handlerProps.js +25 -19
- package/lib/utils/props/hrefAttrsProp.js +14 -11
- package/lib/utils/props/index.js +12 -12
- package/lib/utils/props/inputSupportsProps.js +15 -12
- package/lib/utils/props/linkProps.js +7 -6
- package/lib/utils/props/pressProps.js +1 -1
- package/lib/utils/props/selectSystemProps.js +2 -2
- package/lib/utils/props/tokens.js +29 -15
- package/lib/utils/ssr.js +6 -2
- package/lib/utils/useCopy.js +6 -4
- package/lib/utils/useHash.js +2 -1
- package/lib/utils/useResponsiveProp.js +1 -1
- package/lib/utils/useSpacingScale.js +3 -1
- package/lib/utils/useUniqueId.js +3 -2
- package/lib/utils/withLinkRouter.js +6 -5
- package/lib-module/A11yInfoProvider/index.js +4 -3
- package/lib-module/A11yText/index.js +6 -5
- package/lib-module/ActivityIndicator/Spinner.js +14 -13
- package/lib-module/ActivityIndicator/Spinner.native.js +9 -8
- package/lib-module/ActivityIndicator/index.js +6 -5
- package/lib-module/BaseProvider/index.js +13 -10
- package/lib-module/Box/Box.js +20 -19
- package/lib-module/Button/Button.js +7 -6
- package/lib-module/Button/ButtonBase.js +96 -79
- package/lib-module/Button/ButtonGroup.js +34 -32
- package/lib-module/Button/ButtonLink.js +8 -7
- package/lib-module/Card/Card.js +8 -7
- package/lib-module/Card/CardBase.js +35 -31
- package/lib-module/Card/PressableCardBase.js +12 -11
- package/lib-module/Checkbox/Checkbox.js +97 -83
- package/lib-module/Checkbox/CheckboxGroup.js +29 -27
- package/lib-module/Checkbox/CheckboxInput.js +12 -10
- package/lib-module/Divider/Divider.js +10 -9
- package/lib-module/ExpandCollapse/Control.js +42 -36
- package/lib-module/ExpandCollapse/ExpandCollapse.js +11 -10
- package/lib-module/ExpandCollapse/Panel.js +29 -37
- package/lib-module/Feedback/Feedback.js +46 -33
- package/lib-module/Fieldset/Fieldset.js +16 -15
- package/lib-module/Fieldset/FieldsetContainer.js +16 -13
- package/lib-module/Fieldset/FieldsetContainer.native.js +11 -8
- package/lib-module/Fieldset/Legend.js +10 -7
- package/lib-module/Fieldset/Legend.native.js +10 -7
- package/lib-module/FlexGrid/Col/Col.js +18 -17
- package/lib-module/FlexGrid/FlexGrid.js +15 -14
- package/lib-module/FlexGrid/Row/Row.js +13 -12
- package/lib-module/HorizontalScroll/HorizontalScroll.js +24 -19
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +18 -14
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +6 -5
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +12 -9
- package/lib-module/HorizontalScroll/itemPositions.js +18 -12
- package/lib-module/Icon/Icon.js +10 -9
- package/lib-module/Icon/IconText.js +9 -7
- package/lib-module/IconButton/IconButton.js +48 -41
- package/lib-module/InputLabel/InputLabel.js +37 -30
- package/lib-module/InputLabel/LabelContent.js +12 -9
- package/lib-module/InputLabel/LabelContent.native.js +9 -6
- package/lib-module/InputSupports/InputSupports.js +11 -10
- package/lib-module/InputSupports/useInputSupports.js +7 -6
- package/lib-module/Link/ChevronLink.js +9 -8
- package/lib-module/Link/InlinePressable.js +13 -10
- package/lib-module/Link/InlinePressable.native.js +20 -16
- package/lib-module/Link/Link.js +10 -9
- package/lib-module/Link/LinkBase.js +94 -77
- package/lib-module/Link/TextButton.js +9 -8
- package/lib-module/List/List.js +20 -13
- package/lib-module/List/ListItem.js +103 -78
- package/lib-module/Modal/Modal.js +74 -60
- package/lib-module/Notification/Notification.js +46 -33
- package/lib-module/Pagination/PageButton.js +13 -12
- package/lib-module/Pagination/Pagination.js +43 -30
- package/lib-module/Pagination/SideButton.js +21 -18
- package/lib-module/Pagination/usePagination.js +7 -6
- package/lib-module/Progress/Progress.js +23 -19
- package/lib-module/Progress/ProgressBar.js +25 -21
- package/lib-module/Progress/ProgressBarBackground.js +7 -6
- package/lib-module/Radio/Radio.js +80 -69
- package/lib-module/Radio/RadioButton.js +62 -52
- package/lib-module/Radio/RadioGroup.js +30 -28
- package/lib-module/Radio/RadioInput.js +12 -10
- package/lib-module/RadioCard/RadioCard.js +16 -15
- package/lib-module/RadioCard/RadioCardGroup.js +30 -28
- package/lib-module/Search/Search.js +52 -32
- package/lib-module/Select/Group.js +5 -4
- package/lib-module/Select/Group.native.js +4 -3
- package/lib-module/Select/Item.js +10 -7
- package/lib-module/Select/Item.native.js +1 -7
- package/lib-module/Select/Picker.js +16 -15
- package/lib-module/Select/Picker.native.js +46 -36
- package/lib-module/Select/Select.js +134 -113
- package/lib-module/SideNav/Item.js +39 -33
- package/lib-module/SideNav/ItemContent.js +14 -11
- package/lib-module/SideNav/ItemsGroup.js +13 -11
- package/lib-module/SideNav/SideNav.js +21 -18
- package/lib-module/Skeleton/Skeleton.js +60 -44
- package/lib-module/Skeleton/skeletonWebAnimation.js +1 -1
- package/lib-module/Spacer/Spacer.js +6 -5
- package/lib-module/StackView/StackView.js +12 -11
- package/lib-module/StackView/StackWrap.js +5 -3
- package/lib-module/StackView/StackWrapBox.js +12 -11
- package/lib-module/StackView/StackWrapGap.js +11 -10
- package/lib-module/StackView/common.js +14 -11
- package/lib-module/StackView/getStackedContent.js +10 -9
- package/lib-module/StepTracker/Step.js +122 -103
- package/lib-module/StepTracker/StepTracker.js +48 -38
- package/lib-module/Tabs/Tabs.js +57 -27
- package/lib-module/Tabs/TabsItem.js +77 -68
- package/lib-module/Tags/Tags.js +68 -62
- package/lib-module/TextInput/TextArea.js +26 -20
- package/lib-module/TextInput/TextInput.js +19 -15
- package/lib-module/TextInput/TextInputBase.js +74 -62
- package/lib-module/ThemeProvider/ThemeProvider.js +5 -4
- package/lib-module/ThemeProvider/useSetTheme.js +6 -3
- package/lib-module/ThemeProvider/useThemeTokens.js +7 -2
- package/lib-module/ThemeProvider/utils/styles.js +48 -41
- package/lib-module/ThemeProvider/utils/theme-tokens.js +32 -20
- package/lib-module/ToggleSwitch/ToggleSwitch.js +90 -74
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +37 -35
- package/lib-module/Tooltip/Backdrop.js +6 -13
- package/lib-module/Tooltip/Backdrop.native.js +5 -4
- package/lib-module/Tooltip/Tooltip.js +81 -65
- package/lib-module/Tooltip/getTooltipPosition.js +29 -18
- package/lib-module/TooltipButton/TooltipButton.js +28 -21
- package/lib-module/Typography/Typography.js +35 -31
- package/lib-module/ViewportProvider/ViewportProvider.js +4 -3
- package/lib-module/ViewportProvider/useViewportListener.js +6 -3
- package/lib-module/utils/a11y/semantics.js +4 -1
- package/lib-module/utils/a11y/textSize.js +7 -5
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +47 -20
- package/lib-module/utils/children.js +4 -3
- package/lib-module/utils/input.js +28 -29
- package/lib-module/utils/pressability.js +35 -21
- package/lib-module/utils/props/clickProps.js +2 -1
- package/lib-module/utils/props/componentPropType.js +3 -3
- package/lib-module/utils/props/getPropSelector.js +6 -3
- package/lib-module/utils/props/handlerProps.js +24 -18
- package/lib-module/utils/props/hrefAttrsProp.js +14 -11
- package/lib-module/utils/props/inputSupportsProps.js +15 -12
- package/lib-module/utils/props/linkProps.js +7 -6
- package/lib-module/utils/props/selectSystemProps.js +2 -2
- package/lib-module/utils/props/tokens.js +27 -14
- package/lib-module/utils/ssr.js +5 -2
- package/lib-module/utils/useCopy.js +6 -4
- package/lib-module/utils/useHash.js +2 -1
- package/lib-module/utils/useSpacingScale.js +3 -1
- package/lib-module/utils/useUniqueId.js +3 -2
- package/lib-module/utils/withLinkRouter.js +6 -5
- package/package.json +13 -11
- package/src/ExpandCollapse/Panel.jsx +2 -19
- package/src/List/List.jsx +34 -19
- package/src/List/ListItem.jsx +12 -2
- package/src/Modal/Modal.jsx +2 -1
- package/src/Pagination/Pagination.jsx +3 -0
- package/src/Search/Search.jsx +11 -0
- package/src/Select/Item.native.jsx +0 -7
- package/src/Tabs/Tabs.jsx +24 -2
- package/src/Tabs/TabsItem.jsx +6 -5
- package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
|
@@ -17,35 +17,42 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
18
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
19
19
|
|
|
20
|
-
const selectTooltipStyles =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const selectTooltipStyles = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
backgroundColor,
|
|
23
|
+
paddingTop,
|
|
24
|
+
paddingBottom,
|
|
25
|
+
paddingLeft,
|
|
26
|
+
paddingRight,
|
|
27
|
+
borderRadius
|
|
28
|
+
} = _ref;
|
|
29
|
+
return {
|
|
30
|
+
backgroundColor,
|
|
31
|
+
paddingTop,
|
|
32
|
+
paddingBottom,
|
|
33
|
+
paddingLeft,
|
|
34
|
+
paddingRight,
|
|
35
|
+
borderRadius
|
|
36
|
+
};
|
|
37
|
+
};
|
|
35
38
|
|
|
36
|
-
const selectTooltipShadowStyles =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const selectTooltipShadowStyles = _ref2 => {
|
|
40
|
+
let {
|
|
41
|
+
shadow,
|
|
42
|
+
borderRadius
|
|
43
|
+
} = _ref2;
|
|
44
|
+
return {
|
|
45
|
+
borderRadius,
|
|
46
|
+
...applyShadowToken(shadow)
|
|
47
|
+
};
|
|
48
|
+
};
|
|
43
49
|
|
|
44
|
-
const selectTooltipPositionStyles =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const selectTooltipPositionStyles = _ref3 => {
|
|
51
|
+
let {
|
|
52
|
+
top,
|
|
53
|
+
left,
|
|
54
|
+
width
|
|
55
|
+
} = _ref3;
|
|
49
56
|
return {
|
|
50
57
|
top,
|
|
51
58
|
left,
|
|
@@ -53,16 +60,18 @@ const selectTooltipPositionStyles = ({
|
|
|
53
60
|
};
|
|
54
61
|
};
|
|
55
62
|
|
|
56
|
-
const selectArrowStyles = ({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const selectArrowStyles = (_ref4, _ref5) => {
|
|
64
|
+
let {
|
|
65
|
+
backgroundColor,
|
|
66
|
+
arrowWidth,
|
|
67
|
+
arrowBorderRadius,
|
|
68
|
+
shadow
|
|
69
|
+
} = _ref4;
|
|
70
|
+
let {
|
|
71
|
+
position,
|
|
72
|
+
width: tooltipWidth,
|
|
73
|
+
height: tooltipHeight
|
|
74
|
+
} = _ref5;
|
|
66
75
|
// the arrow width is actually a diagonal of the rectangle that we'll use as a tip
|
|
67
76
|
const rectangleSide = Math.sqrt(arrowWidth * arrowWidth / 2); // position the arrow at the side and center of the tooltip - this happens before rotation
|
|
68
77
|
// so we use the rectangle size as basis
|
|
@@ -135,15 +144,16 @@ const defaultControl = (pressableState, variant) => /*#__PURE__*/_jsx(TooltipBut
|
|
|
135
144
|
*/
|
|
136
145
|
|
|
137
146
|
|
|
138
|
-
const Tooltip = /*#__PURE__*/forwardRef(({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
const Tooltip = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
148
|
+
let {
|
|
149
|
+
children,
|
|
150
|
+
content,
|
|
151
|
+
position = 'auto',
|
|
152
|
+
copy = 'en',
|
|
153
|
+
tokens,
|
|
154
|
+
variant,
|
|
155
|
+
...rest
|
|
156
|
+
} = _ref6;
|
|
147
157
|
const [isOpen, setIsOpen] = useState(false);
|
|
148
158
|
const controlRef = useRef();
|
|
149
159
|
const [controlLayout, setControlLayout] = useState(null);
|
|
@@ -160,9 +170,10 @@ const Tooltip = /*#__PURE__*/forwardRef(({
|
|
|
160
170
|
arrowOffset
|
|
161
171
|
} = themeTokens;
|
|
162
172
|
useEffect(() => {
|
|
163
|
-
const subscription = Dimensions.addEventListener('change',
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
const subscription = Dimensions.addEventListener('change', _ref7 => {
|
|
174
|
+
let {
|
|
175
|
+
window
|
|
176
|
+
} = _ref7;
|
|
166
177
|
setWindowDimensions(window);
|
|
167
178
|
});
|
|
168
179
|
return () => subscription === null || subscription === void 0 ? void 0 : subscription.remove();
|
|
@@ -172,24 +183,29 @@ const Tooltip = /*#__PURE__*/forwardRef(({
|
|
|
172
183
|
|
|
173
184
|
const close = () => setIsOpen(false);
|
|
174
185
|
|
|
175
|
-
const getPressableState =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
const getPressableState = _ref8 => {
|
|
187
|
+
let {
|
|
188
|
+
pressed,
|
|
189
|
+
hovered,
|
|
190
|
+
focused
|
|
191
|
+
} = _ref8;
|
|
192
|
+
return {
|
|
193
|
+
pressed,
|
|
194
|
+
hover: hovered,
|
|
195
|
+
focus: focused
|
|
196
|
+
};
|
|
197
|
+
};
|
|
184
198
|
|
|
185
|
-
const onTooltipLayout =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
const onTooltipLayout = _ref9 => {
|
|
200
|
+
let {
|
|
201
|
+
nativeEvent: {
|
|
202
|
+
layout: {
|
|
203
|
+
width,
|
|
204
|
+
height
|
|
205
|
+
}
|
|
190
206
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
207
|
+
} = _ref9;
|
|
208
|
+
|
|
193
209
|
if (tooltipDimensions === null || tooltipDimensions.width !== width || tooltipDimensions.height !== height) {
|
|
194
210
|
setTooltipDimensions({
|
|
195
211
|
width: Platform.select({
|
|
@@ -49,9 +49,12 @@ function invertPosition(position) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function findRectByPosition(position, rectsArray) {
|
|
52
|
-
return rectsArray.find(
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
return rectsArray.find(_ref => {
|
|
53
|
+
let {
|
|
54
|
+
position: rectPosition
|
|
55
|
+
} = _ref;
|
|
56
|
+
return rectPosition === position;
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
/**
|
|
57
60
|
* Used for absolute positioning of the tooltip. Since the tooltip is always centered relatively
|
|
@@ -63,13 +66,14 @@ function findRectByPosition(position, rectsArray) {
|
|
|
63
66
|
*/
|
|
64
67
|
|
|
65
68
|
|
|
66
|
-
function getTooltipPosition(position, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
function getTooltipPosition(position, _ref2) {
|
|
70
|
+
let {
|
|
71
|
+
controlLayout,
|
|
72
|
+
tooltipDimensions,
|
|
73
|
+
windowDimensions,
|
|
74
|
+
arrowWidth = 0,
|
|
75
|
+
arrowOffset = 0
|
|
76
|
+
} = _ref2;
|
|
73
77
|
const {
|
|
74
78
|
width: controlWidth,
|
|
75
79
|
height: controlHeight,
|
|
@@ -139,9 +143,12 @@ function getTooltipPosition(position, {
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
const inWindow = boundingRects.filter(
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
const inWindow = boundingRects.filter(_ref3 => {
|
|
147
|
+
let {
|
|
148
|
+
overflow
|
|
149
|
+
} = _ref3;
|
|
150
|
+
return overflow === 0;
|
|
151
|
+
}); // pick the first position that fits in window
|
|
145
152
|
// (these are sorted clockwise which makes them show where one would expect them to be)
|
|
146
153
|
|
|
147
154
|
if (inWindow.length > 0) {
|
|
@@ -150,11 +157,15 @@ function getTooltipPosition(position, {
|
|
|
150
157
|
// the least overflowing and normalize its position to fit within window bounds
|
|
151
158
|
|
|
152
159
|
|
|
153
|
-
boundingRects.sort(({
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
boundingRects.sort((_ref4, _ref5) => {
|
|
161
|
+
let {
|
|
162
|
+
overflow: overflowA
|
|
163
|
+
} = _ref4;
|
|
164
|
+
let {
|
|
165
|
+
overflow: overflowB
|
|
166
|
+
} = _ref5;
|
|
167
|
+
return overflowA - overflowB;
|
|
168
|
+
});
|
|
158
169
|
const leastOverflowing = boundingRects[0]; // prefer 'below' over 'above', since we can always expand the document downwards,
|
|
159
170
|
// and 'above' might cause issues on small viewports with large tooltips
|
|
160
171
|
|
|
@@ -7,24 +7,30 @@ import Icon from '../Icon';
|
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
9
9
|
|
|
10
|
-
const selectInnerContainerStyles =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const selectInnerContainerStyles = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
borderRadius,
|
|
13
|
+
width
|
|
14
|
+
} = _ref;
|
|
15
|
+
return {
|
|
16
|
+
borderRadius,
|
|
17
|
+
width
|
|
18
|
+
};
|
|
19
|
+
};
|
|
17
20
|
|
|
18
|
-
const selectIconTokens =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const selectIconTokens = _ref2 => {
|
|
22
|
+
let {
|
|
23
|
+
iconSize,
|
|
24
|
+
iconColor
|
|
25
|
+
/* iconScale = 1 */
|
|
22
26
|
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return {
|
|
29
|
+
size: iconSize,
|
|
30
|
+
color: iconColor // scale: iconScale TODO re-enable with icon component
|
|
26
31
|
|
|
27
|
-
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
28
34
|
/**
|
|
29
35
|
* `TooltipButton` is a helper component used as a default control for the `Tooltip` component.
|
|
30
36
|
* In fact though, it isn't actually a pressable - it's meant to be used as pressable's content.
|
|
@@ -32,12 +38,13 @@ const selectIconTokens = ({
|
|
|
32
38
|
*/
|
|
33
39
|
|
|
34
40
|
|
|
35
|
-
const TooltipButton =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const TooltipButton = _ref3 => {
|
|
42
|
+
let {
|
|
43
|
+
pressableState,
|
|
44
|
+
tokens,
|
|
45
|
+
variant,
|
|
46
|
+
...rest
|
|
47
|
+
} = _ref3;
|
|
41
48
|
const themeTokens = useThemeTokens('TooltipButton', tokens, variant, pressableState);
|
|
42
49
|
const {
|
|
43
50
|
icon: IconComponent
|
|
@@ -14,39 +14,43 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
15
15
|
const [selectTextProps, selectedTextPropTypes] = selectSystemProps([textProps]);
|
|
16
16
|
|
|
17
|
-
const selectTextStyles =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
const selectTextStyles = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
fontWeight,
|
|
20
|
+
fontSize,
|
|
21
|
+
color,
|
|
22
|
+
lineHeight,
|
|
23
|
+
fontName,
|
|
24
|
+
textAlign,
|
|
25
|
+
textTransform,
|
|
26
|
+
letterSpacing
|
|
27
|
+
} = _ref;
|
|
28
|
+
return applyTextStyles({
|
|
29
|
+
fontWeight,
|
|
30
|
+
fontSize,
|
|
31
|
+
color,
|
|
32
|
+
lineHeight,
|
|
33
|
+
fontName,
|
|
34
|
+
textAlign,
|
|
35
|
+
textTransform,
|
|
36
|
+
letterSpacing
|
|
37
|
+
});
|
|
38
|
+
}; // General-purpose flexible theme-neutral base component for text
|
|
36
39
|
|
|
37
40
|
|
|
38
|
-
const Typography = /*#__PURE__*/forwardRef(({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
42
|
+
let {
|
|
43
|
+
children,
|
|
44
|
+
variant,
|
|
45
|
+
heading,
|
|
46
|
+
tag = typeof heading === 'string' ? heading : undefined,
|
|
47
|
+
accessibilityRole = heading === true ? 'header' : undefined,
|
|
48
|
+
block = false,
|
|
49
|
+
align = undefined,
|
|
50
|
+
tokens,
|
|
51
|
+
dataSet,
|
|
52
|
+
...rest
|
|
53
|
+
} = _ref2;
|
|
50
54
|
const viewport = useViewport();
|
|
51
55
|
const themeTokens = useThemeTokens('Typography', tokens, variant, {
|
|
52
56
|
viewport
|
|
@@ -9,9 +9,10 @@ import useViewportListener from './useViewportListener';
|
|
|
9
9
|
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
|
-
const ViewportProvider =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const ViewportProvider = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
children
|
|
15
|
+
} = _ref;
|
|
15
16
|
// Default to the smallest viewport for mobile-first SSR. On client side, this is updated
|
|
16
17
|
// by useViewportListener in a layout effect before anything is shown to the user.
|
|
17
18
|
const [viewport, setViewport] = useState(viewports.keys[0]);
|
|
@@ -26,9 +26,12 @@ const useViewportListenerCSR = setViewport => {
|
|
|
26
26
|
useLayoutEffect(() => {
|
|
27
27
|
setViewport(lookupViewport());
|
|
28
28
|
|
|
29
|
-
const onChange =
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const onChange = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
window
|
|
32
|
+
} = _ref;
|
|
33
|
+
return setViewport(viewports.select(window.width));
|
|
34
|
+
};
|
|
32
35
|
|
|
33
36
|
const listener = Dimensions.addEventListener('change', onChange); // From RN 0.65.0, Dimensions.removeEventListener is deprecated for `remove` on addEventListener return value;
|
|
34
37
|
// however, that is not available in RN <=0.64.X, therefore not in any Expo release as of 2021 (Expo SDK 43).
|
|
@@ -49,7 +49,10 @@ const rolesToTags =
|
|
|
49
49
|
|
|
50
50
|
}; // Invert React Native Web's mapping, so a tag gets the role that gets that tag
|
|
51
51
|
|
|
52
|
-
export const tagsToRoles = Object.fromEntries(Object.entries(rolesToTags).map(
|
|
52
|
+
export const tagsToRoles = Object.fromEntries(Object.entries(rolesToTags).map(_ref => {
|
|
53
|
+
let [key, value] = _ref;
|
|
54
|
+
return [value, key];
|
|
55
|
+
}));
|
|
53
56
|
/**
|
|
54
57
|
* Heading HTML tags map to the "heading" accessibilityRole in native apps, which is similar
|
|
55
58
|
* to headings on web but without the expectation of a hierarchy of headings within one screen.
|
|
@@ -8,7 +8,8 @@ import Platform from "react-native-web/dist/exports/Platform";
|
|
|
8
8
|
* @param {number} [maxScale] - the maximum multiplier to apply; defaults to no maximum
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export const scaleWithText = (value
|
|
11
|
+
export const scaleWithText = function (value) {
|
|
12
|
+
let maxScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
|
12
13
|
if (!value) return value;
|
|
13
14
|
const scale = Math.min(PixelRatio.getFontScale(), maxScale) || 1;
|
|
14
15
|
return value * scale;
|
|
@@ -24,10 +25,11 @@ export const scaleWithText = (value, maxScale = Infinity) => {
|
|
|
24
25
|
* `maxFontSizeMultiplier` prop value.
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
|
-
export const getMaxFontMultiplier =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export const getMaxFontMultiplier = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
fontSize,
|
|
31
|
+
fontScaleCap
|
|
32
|
+
} = _ref;
|
|
31
33
|
if (Platform.OS === 'web' || !fontScaleCap || !fontSize) return undefined;
|
|
32
34
|
if (fontScaleCap <= fontSize) return 1;
|
|
33
35
|
return fontScaleCap / fontSize;
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import Animated from "react-native-web/dist/exports/Animated";
|
|
3
3
|
import Easing from "react-native-web/dist/exports/Easing";
|
|
4
4
|
import Platform from "react-native-web/dist/exports/Platform"; // TODO: systematise animations
|
|
5
5
|
// https://github.com/telus/universal-design-system/issues/487
|
|
6
6
|
|
|
7
|
-
function useVerticalExpandAnimation({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function useVerticalExpandAnimation(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
containerHeight,
|
|
10
|
+
isExpanded,
|
|
11
|
+
tokens
|
|
12
|
+
} = _ref;
|
|
12
13
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
14
|
+
const [wasExpanded, setWasExpanded] = useState(isExpanded);
|
|
15
|
+
const expandStateChanged = isExpanded !== wasExpanded;
|
|
13
16
|
const expandAnimatedValue = useRef(new Animated.Value(0)).current;
|
|
14
17
|
const elementRef = useRef(null);
|
|
15
18
|
const {
|
|
16
19
|
expandDuration,
|
|
17
20
|
collapseDuration
|
|
18
|
-
} = tokens;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
} = tokens;
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
if (expandStateChanged) {
|
|
24
|
+
setIsAnimating(true);
|
|
25
|
+
setWasExpanded(isExpanded);
|
|
26
|
+
}
|
|
27
|
+
}, [expandStateChanged, isExpanded]);
|
|
21
28
|
useEffect(() => {
|
|
22
|
-
const onComplete = () =>
|
|
29
|
+
const onComplete = () => setIsAnimating(false);
|
|
23
30
|
|
|
24
31
|
if (Platform.OS === 'web') {
|
|
25
32
|
if (!elementRef.current) return () => {}; // React Native Web does not pass `onTransitionEnd` through, must attach manually.
|
|
@@ -39,20 +46,40 @@ function useVerticalExpandAnimation({
|
|
|
39
46
|
const animation = Animated.timing(expandAnimatedValue, animationConfig);
|
|
40
47
|
animation.start(onComplete);
|
|
41
48
|
return () => animation.stop();
|
|
42
|
-
}, [isExpanded, expandAnimatedValue, containerHeight, expandDuration, collapseDuration]);
|
|
49
|
+
}, [isExpanded, expandAnimatedValue, containerHeight, expandDuration, collapseDuration]);
|
|
50
|
+
const containerStyles = {};
|
|
51
|
+
if (isAnimating || expandStateChanged) containerStyles.overflow = 'hidden';
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
visibility: 'hidden'
|
|
46
|
-
} : {}; // don't visually collapse the container until we have it measured
|
|
47
|
-
|
|
48
|
-
if (containerHeight !== null) {
|
|
53
|
+
if (!isExpanded && !isAnimating && !expandStateChanged) {
|
|
49
54
|
if (Platform.OS === 'web') {
|
|
50
|
-
|
|
51
|
-
containerStyles.
|
|
52
|
-
containerStyles.height = isExpanded ? containerHeight : 0;
|
|
55
|
+
// Without `visibility: 'hidden', descendents are focusable on web even when collapsed.
|
|
56
|
+
containerStyles.visibility = 'hidden';
|
|
53
57
|
} else {
|
|
54
|
-
|
|
58
|
+
// There's no `visibility: hidden` in React Native, and display: none causes a flicker on expand.
|
|
59
|
+
// Without some form of hiding, some children leak through even when closed e.g. `List.Item` bullets.
|
|
60
|
+
containerStyles.opacity = 0;
|
|
61
|
+
}
|
|
62
|
+
} // don't visually collapse the container until we have it measured
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (containerHeight === null) {
|
|
66
|
+
if (Platform.OS === 'web') {
|
|
67
|
+
// on web we can hide the contents until we have the container measured and avoid occasional jitter
|
|
68
|
+
// this won't work on native platforms
|
|
69
|
+
containerStyles.height = 0;
|
|
70
|
+
containerStyles.visibility = 'hidden';
|
|
55
71
|
}
|
|
72
|
+
} else if (Platform.OS === 'web') {
|
|
73
|
+
const transitionDuration = isExpanded ? expandDuration : collapseDuration;
|
|
74
|
+
containerStyles.transition = "height ".concat(transitionDuration, "ms ease-in-out");
|
|
75
|
+
containerStyles.height = isExpanded ? containerHeight : 0;
|
|
76
|
+
} else if (Platform.OS === 'ios' && isExpanded && !isAnimating && !expandStateChanged && typeof containerHeight === 'number') {
|
|
77
|
+
// iOS reflows text while the height animation is in progress. Sometimes, it hits a timing bug where
|
|
78
|
+
// it fails to reflow properly after the last animation frame, leaving the last line of text not visible.
|
|
79
|
+
// Force reflow after animation completes with a static height non-identical to the last animated height.
|
|
80
|
+
containerStyles.height = containerHeight + 1;
|
|
81
|
+
} else {
|
|
82
|
+
containerStyles.height = expandAnimatedValue;
|
|
56
83
|
}
|
|
57
84
|
|
|
58
85
|
return [containerStyles, elementRef];
|
|
@@ -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) => "".concat(newKey).concat(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] = "".concat(wrappedText[lastIndex]).concat(child);
|
|
68
68
|
} else {
|
|
69
69
|
wrappedText.push(child);
|
|
70
70
|
}
|
|
@@ -86,7 +86,8 @@ const wrapChild = (child, wrappedText) => {
|
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
export const wrapStringsInText = (children
|
|
89
|
+
export const wrapStringsInText = function (children) {
|
|
90
|
+
let textProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
90
91
|
const childrenArray = unpackFragment(Children.toArray(children)); // Group adjacent wrapable children together in one Text element to create as few Text elements
|
|
91
92
|
// as possible, e.g. give <X>Text {someString}</X> one Text, same as <X>{`Text ${someString}`}</X>
|
|
92
93
|
|