@telus-uds/components-base 1.16.0 → 1.18.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 +32 -2
- package/component-docs.json +708 -120
- package/lib/BaseProvider/HydrationContext.js +74 -0
- package/lib/BaseProvider/index.js +14 -6
- package/lib/Button/ButtonBase.js +2 -1
- package/lib/List/List.js +11 -8
- package/lib/List/PressableListItemBase.js +5 -9
- package/lib/QuickLinks/QuickLinks.js +91 -0
- package/lib/QuickLinks/QuickLinksCard.js +47 -0
- package/lib/QuickLinks/QuickLinksItem.js +73 -0
- package/lib/QuickLinks/index.js +16 -0
- package/lib/StackView/StackWrap.js +16 -12
- package/lib/Timeline/Timeline.js +193 -0
- package/lib/Timeline/index.js +13 -0
- package/lib/ViewportProvider/useViewportListener.js +5 -18
- package/lib/index.js +28 -1
- package/lib/utils/animation/useVerticalExpandAnimation.js +3 -1
- package/lib/utils/index.js +9 -0
- package/lib/utils/useSafeLayoutEffect.js +40 -0
- package/lib-module/BaseProvider/HydrationContext.js +51 -0
- package/lib-module/BaseProvider/index.js +12 -6
- package/lib-module/Button/ButtonBase.js +2 -1
- package/lib-module/List/List.js +12 -8
- package/lib-module/List/PressableListItemBase.js +6 -10
- package/lib-module/QuickLinks/QuickLinks.js +71 -0
- package/lib-module/QuickLinks/QuickLinksCard.js +33 -0
- package/lib-module/QuickLinks/QuickLinksItem.js +50 -0
- package/lib-module/QuickLinks/index.js +4 -0
- package/lib-module/StackView/StackWrap.js +16 -13
- package/lib-module/Timeline/Timeline.js +174 -0
- package/lib-module/Timeline/index.js +2 -0
- package/lib-module/ViewportProvider/useViewportListener.js +5 -18
- package/lib-module/index.js +4 -1
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +4 -3
- package/lib-module/utils/index.js +1 -0
- package/lib-module/utils/useSafeLayoutEffect.js +30 -0
- package/package.json +6 -5
- package/src/BaseProvider/HydrationContext.jsx +44 -0
- package/src/BaseProvider/index.jsx +11 -7
- package/src/Button/ButtonBase.jsx +2 -2
- package/src/List/List.jsx +9 -13
- package/src/List/PressableListItemBase.jsx +7 -9
- package/src/QuickLinks/QuickLinks.jsx +61 -0
- package/src/QuickLinks/QuickLinksCard.jsx +26 -0
- package/src/QuickLinks/QuickLinksItem.jsx +46 -0
- package/src/QuickLinks/index.js +6 -0
- package/src/StackView/StackWrap.jsx +20 -13
- package/src/Timeline/Timeline.jsx +148 -0
- package/src/Timeline/index.js +3 -0
- package/src/ViewportProvider/useViewportListener.js +4 -16
- package/src/index.js +3 -0
- package/src/utils/animation/useVerticalExpandAnimation.js +4 -2
- package/src/utils/index.js +1 -0
- package/src/utils/useSafeLayoutEffect.js +31 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useHydrationContext = exports.default = exports.HydrationProvider = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
const HydrationContext = /*#__PURE__*/(0, _react.createContext)();
|
|
23
|
+
const isSSR = typeof window === 'undefined';
|
|
24
|
+
|
|
25
|
+
const hasWebStyleTag = () => {
|
|
26
|
+
var _document;
|
|
27
|
+
|
|
28
|
+
if (isSSR || _Platform.default.OS !== 'web' || typeof document !== 'object') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return Boolean((_document = document) === null || _document === void 0 ? void 0 : _document.getElementById('react-native-stylesheet'));
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if this render cycle is the hydration of existing SSR content.
|
|
36
|
+
*
|
|
37
|
+
* Use this when changing how content renders based on data that is instantly available
|
|
38
|
+
* during the very first client-side render or hydration, but not available on the server,
|
|
39
|
+
* to ensure no changes happen until the original SSR DOM has been hydrated.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const useHydrationContext = () => (0, _react.useContext)(HydrationContext);
|
|
44
|
+
/**
|
|
45
|
+
* Allows components and hooks to observe if SSR hydration is currently in progress
|
|
46
|
+
* and if so, to re-render with content that differs to the server when it is complete.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.useHydrationContext = useHydrationContext;
|
|
51
|
+
|
|
52
|
+
const HydrationProvider = _ref => {
|
|
53
|
+
let {
|
|
54
|
+
children
|
|
55
|
+
} = _ref;
|
|
56
|
+
const [hasMounted, setHasMounted] = (0, _react.useState)(false);
|
|
57
|
+
(0, _react.useEffect)(() => {
|
|
58
|
+
setHasMounted(true);
|
|
59
|
+
}, []); // If we've got a HydrationProvider inside a HydrationProvider somehow, defer to the top one
|
|
60
|
+
|
|
61
|
+
const valueFromAncestor = useHydrationContext();
|
|
62
|
+
const isHydrating = valueFromAncestor !== null && valueFromAncestor !== void 0 ? valueFromAncestor : Boolean(!hasMounted && hasWebStyleTag());
|
|
63
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HydrationContext.Provider, {
|
|
64
|
+
value: isHydrating,
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.HydrationProvider = HydrationProvider;
|
|
70
|
+
HydrationProvider.propTypes = {
|
|
71
|
+
children: _propTypes.default.node
|
|
72
|
+
};
|
|
73
|
+
var _default = HydrationProvider;
|
|
74
|
+
exports.default = _default;
|
|
@@ -9,12 +9,16 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _portal = require("@gorhom/portal");
|
|
13
|
+
|
|
12
14
|
var _A11yInfoProvider = _interopRequireDefault(require("../A11yInfoProvider"));
|
|
13
15
|
|
|
14
16
|
var _ViewportProvider = _interopRequireDefault(require("../ViewportProvider"));
|
|
15
17
|
|
|
16
18
|
var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
|
|
17
19
|
|
|
20
|
+
var _HydrationContext = require("./HydrationContext");
|
|
21
|
+
|
|
18
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
23
|
|
|
20
24
|
var _ThemeProvider$propTy;
|
|
@@ -27,12 +31,16 @@ const BaseProvider = _ref => {
|
|
|
27
31
|
children,
|
|
28
32
|
themeOptions
|
|
29
33
|
} = _ref;
|
|
30
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
31
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
32
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HydrationContext.HydrationProvider, {
|
|
35
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_A11yInfoProvider.default, {
|
|
36
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ViewportProvider.default, {
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
|
|
38
|
+
defaultTheme: defaultTheme,
|
|
39
|
+
themeOptions: themeOptions,
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_portal.PortalProvider, {
|
|
41
|
+
children: children
|
|
42
|
+
})
|
|
43
|
+
})
|
|
36
44
|
})
|
|
37
45
|
})
|
|
38
46
|
});
|
package/lib/Button/ButtonBase.js
CHANGED
|
@@ -195,11 +195,12 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref7) => {
|
|
|
195
195
|
const selectItemIconTokens = _ref8 => {
|
|
196
196
|
let {
|
|
197
197
|
color,
|
|
198
|
+
iconColor,
|
|
198
199
|
iconSize
|
|
199
200
|
} = _ref8;
|
|
200
201
|
return {
|
|
201
202
|
size: iconSize,
|
|
202
|
-
color
|
|
203
|
+
color: iconColor || color
|
|
203
204
|
};
|
|
204
205
|
};
|
|
205
206
|
|
package/lib/List/List.js
CHANGED
|
@@ -15,8 +15,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
-
var _ListItem = _interopRequireDefault(require("./ListItem"));
|
|
19
|
-
|
|
20
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -26,11 +24,20 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
26
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
25
|
|
|
28
26
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
27
|
+
|
|
28
|
+
const isListItem = element => {
|
|
29
|
+
var _element$type, _element$type2;
|
|
30
|
+
|
|
31
|
+
const elementName = (element === null || element === void 0 ? void 0 : (_element$type = element.type) === null || _element$type === void 0 ? void 0 : _element$type.displayName) || (element === null || element === void 0 ? void 0 : (_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name); // Match our own ListItem, and also, custom list items
|
|
32
|
+
|
|
33
|
+
return Boolean(elementName.match(/Item/));
|
|
34
|
+
};
|
|
29
35
|
/**
|
|
30
36
|
* An unordered List component has a child a ListItem that
|
|
31
37
|
* allows icon, dividers and customized typography
|
|
32
38
|
*/
|
|
33
39
|
|
|
40
|
+
|
|
34
41
|
const List = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
35
42
|
let {
|
|
36
43
|
children,
|
|
@@ -45,12 +52,8 @@ const List = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
45
52
|
} = _ref;
|
|
46
53
|
|
|
47
54
|
const items = _react.Children.map(children, (child, index) => {
|
|
48
|
-
var _child$type, _child$type2;
|
|
49
|
-
|
|
50
55
|
// Pass ListItem-specific props to children (by name so teams can add their own ListItems)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (isListItem(child === null || child === void 0 ? void 0 : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) || isListItem(child === null || child === void 0 ? void 0 : (_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.name)) {
|
|
56
|
+
if (isListItem(child)) {
|
|
54
57
|
return /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
55
58
|
showDivider,
|
|
56
59
|
isLastItem: index + 1 === _react.Children.count(children),
|
|
@@ -74,7 +77,7 @@ List.displayName = 'List';
|
|
|
74
77
|
List.propTypes = { ...selectedSystemPropTypes,
|
|
75
78
|
tokens: (0, _utils.getTokensPropType)('List'),
|
|
76
79
|
variant: _utils.variantProp.propType,
|
|
77
|
-
children:
|
|
80
|
+
children: _propTypes.default.node,
|
|
78
81
|
|
|
79
82
|
/**
|
|
80
83
|
* In case it is not the last item allow display divider
|
|
@@ -21,9 +21,9 @@ var _utils = require("../utils");
|
|
|
21
21
|
|
|
22
22
|
var _ListItemBase = _interopRequireDefault(require("./ListItemBase"));
|
|
23
23
|
|
|
24
|
-
var _ListItemContent =
|
|
24
|
+
var _ListItemContent = _interopRequireDefault(require("./ListItemContent"));
|
|
25
25
|
|
|
26
|
-
var _ListItemMark =
|
|
26
|
+
var _ListItemMark = _interopRequireDefault(require("./ListItemMark"));
|
|
27
27
|
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
|
|
@@ -82,9 +82,10 @@ const PressableListItemBase = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =
|
|
|
82
82
|
onPress
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
const listItemTokens = (0, _utils.selectTokens)('List', typeof tokens === 'function' ? tokens() : tokens);
|
|
85
86
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemBase.default, {
|
|
86
87
|
ref: listItemRef,
|
|
87
|
-
tokens:
|
|
88
|
+
tokens: listItemTokens,
|
|
88
89
|
...listItemProps,
|
|
89
90
|
children: _ref3 => {
|
|
90
91
|
let {
|
|
@@ -125,17 +126,12 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
125
126
|
itemContainer: {
|
|
126
127
|
flexDirection: 'row',
|
|
127
128
|
flex: 1
|
|
128
|
-
},
|
|
129
|
-
tokens: { ..._ListItemContent.tokenTypes,
|
|
130
|
-
..._ListItemMark.tokenTypes
|
|
131
129
|
}
|
|
132
130
|
});
|
|
133
131
|
|
|
134
|
-
PressableListItemBase.propTypes = {
|
|
132
|
+
PressableListItemBase.propTypes = { ..._utils.withLinkRouter.propTypes,
|
|
135
133
|
href: _propTypes.default.string,
|
|
136
134
|
onPress: _propTypes.default.func,
|
|
137
|
-
// TODO - type this better, maybe import the subcomponent token types and run it through util
|
|
138
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
139
135
|
tokens: _propTypes.default.any,
|
|
140
136
|
icon: _propTypes.default.elementType,
|
|
141
137
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
13
|
+
|
|
14
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _List = _interopRequireDefault(require("../List"));
|
|
19
|
+
|
|
20
|
+
var _StackWrap = _interopRequireDefault(require("../StackView/StackWrap"));
|
|
21
|
+
|
|
22
|
+
var _QuickLinksCard = _interopRequireDefault(require("./QuickLinksCard"));
|
|
23
|
+
|
|
24
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* QuickLinks renders a list of interactive items. How it renders these items depends on theme options:
|
|
34
|
+
* - If the theme returns `list` token as true, it renders an ordered list based on List
|
|
35
|
+
* - If the theme returns `button` token as true and `list` as false, it renders a wrapping horizontal bar of buttons
|
|
36
|
+
* - If the theme returns `card` token as true, it wraps the above with a `Card`.
|
|
37
|
+
*/
|
|
38
|
+
const QuickLinks = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
39
|
+
let {
|
|
40
|
+
tokens,
|
|
41
|
+
variant,
|
|
42
|
+
listTokens,
|
|
43
|
+
cardTokens,
|
|
44
|
+
children,
|
|
45
|
+
tag = 'ul',
|
|
46
|
+
...rest
|
|
47
|
+
} = _ref;
|
|
48
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
49
|
+
const {
|
|
50
|
+
dividers,
|
|
51
|
+
list,
|
|
52
|
+
card,
|
|
53
|
+
stackSpace,
|
|
54
|
+
stackGap,
|
|
55
|
+
stackJustify
|
|
56
|
+
} = (0, _ThemeProvider.useThemeTokens)('QuickLinks', tokens, variant, {
|
|
57
|
+
viewport
|
|
58
|
+
});
|
|
59
|
+
const content = list && /*#__PURE__*/(0, _jsxRuntime.jsx)(_List.default, {
|
|
60
|
+
ref: ref,
|
|
61
|
+
tokens: listTokens,
|
|
62
|
+
showDivider: dividers,
|
|
63
|
+
tag: tag,
|
|
64
|
+
...rest,
|
|
65
|
+
children: children
|
|
66
|
+
}) || /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackWrap.default, {
|
|
67
|
+
space: stackSpace,
|
|
68
|
+
gap: stackGap,
|
|
69
|
+
tokens: {
|
|
70
|
+
justifyContent: stackJustify
|
|
71
|
+
},
|
|
72
|
+
tag: tag,
|
|
73
|
+
...rest,
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
76
|
+
return card ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_QuickLinksCard.default, {
|
|
77
|
+
tokens: cardTokens,
|
|
78
|
+
children: content
|
|
79
|
+
}) : content;
|
|
80
|
+
});
|
|
81
|
+
QuickLinks.displayName = 'QuickLinks';
|
|
82
|
+
QuickLinks.propTypes = {
|
|
83
|
+
tokens: (0, _utils.getTokensPropType)('QuickLinks'),
|
|
84
|
+
cardTokens: (0, _utils.getTokensPropType)('Card'),
|
|
85
|
+
listTokens: (0, _utils.getTokensPropType)('QuickLinksList'),
|
|
86
|
+
tag: _propTypes.default.string,
|
|
87
|
+
variant: _utils.variantProp.propType,
|
|
88
|
+
children: _propTypes.default.node
|
|
89
|
+
};
|
|
90
|
+
var _default = QuickLinks;
|
|
91
|
+
exports.default = _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
13
|
+
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
|
|
16
|
+
var _CardBase = _interopRequireDefault(require("../Card/CardBase"));
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Private subcomponent for use within QuickLinks.
|
|
24
|
+
*
|
|
25
|
+
* Restyled Card with identical behaviour to Card, but themed according to the
|
|
26
|
+
* QuickLinksCard theme rather than the Card theme.
|
|
27
|
+
*/
|
|
28
|
+
const QuickLinksList = _ref => {
|
|
29
|
+
let {
|
|
30
|
+
tokens,
|
|
31
|
+
variant,
|
|
32
|
+
children
|
|
33
|
+
} = _ref;
|
|
34
|
+
const themeTokens = (0, _ThemeProvider.useThemeTokens)('QuickLinksCard', tokens, variant);
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
36
|
+
tokens: themeTokens,
|
|
37
|
+
children: children
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
QuickLinksList.propTypes = {
|
|
42
|
+
tokens: (0, _utils.getTokensPropType)('QuickLinksCard'),
|
|
43
|
+
variant: _utils.variantProp.propType,
|
|
44
|
+
children: _propTypes.default.node
|
|
45
|
+
};
|
|
46
|
+
var _default = QuickLinksList;
|
|
47
|
+
exports.default = _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
|
|
14
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
15
|
+
|
|
16
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
17
|
+
|
|
18
|
+
var _PressableListItemBase = _interopRequireDefault(require("../List/PressableListItemBase"));
|
|
19
|
+
|
|
20
|
+
var _ButtonBase = _interopRequireDefault(require("../Button/ButtonBase"));
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Public component exported as QuickLinks.Item, for use as children of QuickLinks.
|
|
32
|
+
*
|
|
33
|
+
* Receives props injected by QuickLinks and renders the appropriate child component.
|
|
34
|
+
*/
|
|
35
|
+
const QuickLinksItem = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
36
|
+
let {
|
|
37
|
+
tokens,
|
|
38
|
+
variant,
|
|
39
|
+
children,
|
|
40
|
+
...rest
|
|
41
|
+
} = _ref;
|
|
42
|
+
const viewport = (0, _ViewportProvider.useViewport)();
|
|
43
|
+
const {
|
|
44
|
+
list
|
|
45
|
+
} = (0, _ThemeProvider.useThemeTokens)('QuickLinks', tokens, variant, {
|
|
46
|
+
viewport
|
|
47
|
+
});
|
|
48
|
+
const themeName = list ? 'QuickLinksList' : 'QuickLinksButton';
|
|
49
|
+
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)(themeName, tokens, variant);
|
|
50
|
+
return list ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableListItemBase.default, {
|
|
51
|
+
ref: ref,
|
|
52
|
+
tokens: getTokens,
|
|
53
|
+
...rest,
|
|
54
|
+
children: children
|
|
55
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
|
|
56
|
+
ref: ref,
|
|
57
|
+
tokens: getTokens,
|
|
58
|
+
...rest,
|
|
59
|
+
children: children
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
QuickLinksItem.displayName = 'QuickLinksItem';
|
|
63
|
+
QuickLinksItem.propTypes = { ..._utils.withLinkRouter.propTypes,
|
|
64
|
+
..._PressableListItemBase.default.propTypes,
|
|
65
|
+
..._ButtonBase.default.propTypes,
|
|
66
|
+
tokens: (0, _utils.getTokensPropType)('QuickLinksList', 'QuickLinksButton'),
|
|
67
|
+
variant: _utils.variantProp.propType,
|
|
68
|
+
children: _propTypes.default.node
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var _default = (0, _utils.withLinkRouter)(QuickLinksItem);
|
|
72
|
+
|
|
73
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _QuickLinks = _interopRequireDefault(require("./QuickLinks"));
|
|
9
|
+
|
|
10
|
+
var _QuickLinksItem = _interopRequireDefault(require("./QuickLinksItem"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
_QuickLinks.default.Item = _QuickLinksItem.default;
|
|
15
|
+
var _default = _QuickLinks.default;
|
|
16
|
+
exports.default = _default;
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
11
11
|
|
|
12
|
+
var _useSafeLayoutEffect = _interopRequireDefault(require("../utils/useSafeLayoutEffect"));
|
|
13
|
+
|
|
12
14
|
var _StackWrapBox = _interopRequireDefault(require("./StackWrapBox"));
|
|
13
15
|
|
|
14
16
|
var _StackWrapGap = _interopRequireDefault(require("./StackWrapGap"));
|
|
@@ -22,10 +24,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
22
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
25
|
|
|
24
26
|
// In Jest/CI/SSR, global CSS isn't always available and doesn't always have .supports method
|
|
25
|
-
const cssSupports =
|
|
27
|
+
const cssSupports = (property, value) => {
|
|
26
28
|
var _window$CSS;
|
|
27
29
|
|
|
28
|
-
return typeof window !== 'undefined' && typeof ((_window$CSS = window.CSS) === null || _window$CSS === void 0 ? void 0 : _window$CSS.supports) === 'function' && window.CSS.supports(
|
|
30
|
+
return _Platform.default.OS === 'web' && typeof window !== 'undefined' && typeof ((_window$CSS = window.CSS) === null || _window$CSS === void 0 ? void 0 : _window$CSS.supports) === 'function' && window.CSS.supports(property, value);
|
|
29
31
|
}; // CSS.supports needs an example of the type of value you intend to use.
|
|
30
32
|
// Will be an integer appended `px` after hooks and JSX styles are resolved.
|
|
31
33
|
|
|
@@ -42,22 +44,24 @@ const exampleGapValue = '1px';
|
|
|
42
44
|
const StackWrap = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
43
45
|
var _props$gap;
|
|
44
46
|
|
|
47
|
+
const [canUseCSSGap, setCanUseCSSGap] = (0, _react.useState)(false);
|
|
45
48
|
const {
|
|
46
49
|
space
|
|
47
50
|
} = props; // Don't apply separate gap if `null` or `undefined`, so can be unset in Storybook etc
|
|
48
51
|
|
|
49
52
|
const gap = (_props$gap = props.gap) !== null && _props$gap !== void 0 ? _props$gap : space;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// If possible, use the cleaner implementation that applies CSS `gap` styles to the container.
|
|
54
|
-
(0, _jsxRuntime.jsx)(_StackWrapGap.default, {
|
|
55
|
-
ref: ref,
|
|
56
|
-
...props
|
|
57
|
-
}) :
|
|
58
|
-
/*#__PURE__*/
|
|
53
|
+
const gapEqualsSpace = gap === space; // If possible, use the cleaner implementation that applies CSS `gap` styles to the container,
|
|
54
|
+
// preserving direct parent-child relationships between the container and each item, which
|
|
55
|
+
// can result in clearer descriptions on some screen readers (e.g. radio "X of Y" on MacOS).
|
|
59
56
|
// Else, use the fallback implementation which renders a `Box` component around each child.
|
|
60
|
-
|
|
57
|
+
|
|
58
|
+
const Component = canUseCSSGap ? _StackWrapGap.default : _StackWrapBox.default; // In SSR, the type of implementation must match the server during hydration, but
|
|
59
|
+
// the server can't know if gap is supported, so never use it until after hydration.
|
|
60
|
+
|
|
61
|
+
(0, _useSafeLayoutEffect.default)(() => {
|
|
62
|
+
setCanUseCSSGap(gapEqualsSpace && cssSupports('gap', exampleGapValue));
|
|
63
|
+
}, [gapEqualsSpace]);
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
61
65
|
ref: ref,
|
|
62
66
|
...props
|
|
63
67
|
});
|