@telus-uds/components-base 1.72.0 → 1.74.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 +35 -2
- package/lib/Box/Box.js +17 -6
- package/lib/ExpandCollapse/Panel.js +1 -1
- package/lib/FlexGrid/Col/Col.js +42 -19
- package/lib/FlexGrid/FlexGrid.js +40 -17
- package/lib/FlexGrid/Row/Row.js +45 -22
- package/lib/Footnote/Footnote.js +328 -0
- package/lib/Footnote/FootnoteLink.js +108 -0
- package/lib/Footnote/dictionary.js +19 -0
- package/lib/Footnote/index.js +12 -0
- package/lib/Listbox/ListboxGroup.js +7 -1
- package/lib/MultiSelectFilter/MultiSelectFilter.js +1 -0
- package/lib/Notification/Notification.js +13 -5
- package/lib/OrderedList/ItemBase.js +7 -1
- package/lib/Responsive/Responsive.js +32 -14
- package/lib/Responsive/ResponsiveProp.js +46 -0
- package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +75 -0
- package/lib/ThemeProvider/ThemeProvider.js +5 -2
- package/lib/ThemeProvider/index.js +9 -1
- package/lib/ThemeProvider/useResponsiveThemeTokens.js +89 -0
- package/lib/Typography/Typography.js +50 -22
- package/lib/index.js +8 -0
- package/lib/server.js +40 -0
- package/lib/utils/ssr-media-query/utils/create-media-query-styles.js +39 -6
- package/lib-module/Box/Box.js +17 -6
- package/lib-module/ExpandCollapse/Panel.js +1 -1
- package/lib-module/FlexGrid/Col/Col.js +42 -19
- package/lib-module/FlexGrid/FlexGrid.js +40 -17
- package/lib-module/FlexGrid/Row/Row.js +45 -22
- package/lib-module/Footnote/Footnote.js +319 -0
- package/lib-module/Footnote/FootnoteLink.js +101 -0
- package/lib-module/Footnote/dictionary.js +12 -0
- package/lib-module/Footnote/index.js +4 -0
- package/lib-module/Listbox/ListboxGroup.js +7 -1
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +1 -0
- package/lib-module/Notification/Notification.js +13 -5
- package/lib-module/OrderedList/ItemBase.js +7 -1
- package/lib-module/Responsive/Responsive.js +32 -15
- package/lib-module/Responsive/ResponsiveProp.js +39 -0
- package/lib-module/Responsive/ResponsiveWithMediaQueryStyleSheet.js +67 -0
- package/lib-module/ThemeProvider/ThemeProvider.js +5 -2
- package/lib-module/ThemeProvider/index.js +1 -0
- package/lib-module/ThemeProvider/useResponsiveThemeTokens.js +81 -0
- package/lib-module/Typography/Typography.js +52 -24
- package/lib-module/index.js +1 -0
- package/lib-module/server.js +4 -0
- package/lib-module/utils/ssr-media-query/utils/create-media-query-styles.js +36 -6
- package/package.json +13 -2
- package/src/Box/Box.jsx +35 -17
- package/src/ExpandCollapse/Panel.jsx +1 -1
- package/src/FlexGrid/Col/Col.jsx +42 -13
- package/src/FlexGrid/FlexGrid.jsx +40 -11
- package/src/FlexGrid/Row/Row.jsx +40 -16
- package/src/Footnote/Footnote.jsx +316 -0
- package/src/Footnote/FootnoteLink.jsx +95 -0
- package/src/Footnote/dictionary.js +12 -0
- package/src/Footnote/index.js +6 -0
- package/src/Listbox/ListboxGroup.jsx +9 -2
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +2 -0
- package/src/Notification/Notification.jsx +15 -3
- package/src/OrderedList/ItemBase.jsx +14 -2
- package/src/Responsive/Responsive.jsx +31 -12
- package/src/Responsive/ResponsiveProp.jsx +33 -0
- package/src/Responsive/ResponsiveWithMediaQueryStyleSheet.jsx +60 -0
- package/src/ThemeProvider/ThemeProvider.jsx +5 -2
- package/src/ThemeProvider/index.js +1 -0
- package/src/ThemeProvider/useResponsiveThemeTokens.js +85 -0
- package/src/Typography/Typography.jsx +77 -24
- package/src/index.js +1 -0
- package/src/server.js +4 -0
- package/src/utils/ssr-media-query/utils/create-media-query-styles.js +21 -6
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const ResponsiveProp = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
min = 'xs',
|
|
16
|
+
max,
|
|
17
|
+
children
|
|
18
|
+
} = _ref;
|
|
19
|
+
const byViewports = {
|
|
20
|
+
[min]: children
|
|
21
|
+
};
|
|
22
|
+
if (max && max !== 'xl') {
|
|
23
|
+
// Stop returning children at the viewport one above 'max' or greater
|
|
24
|
+
const maxIndex = _systemConstants.viewports.keys.indexOf(max);
|
|
25
|
+
const maxPlusOne = maxIndex >= 0 ? _systemConstants.viewports.keys[maxIndex + 1] : null;
|
|
26
|
+
if (maxPlusOne) byViewports[maxPlusOne] = null;
|
|
27
|
+
}
|
|
28
|
+
const responsiveProp = (0, _utils.useResponsiveProp)(byViewports, null);
|
|
29
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
30
|
+
children: responsiveProp
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
ResponsiveProp.displayName = 'Responsive';
|
|
34
|
+
ResponsiveProp.propTypes = {
|
|
35
|
+
/**
|
|
36
|
+
* To hide children of `Responsive` if the current viewport is smaller than `min`
|
|
37
|
+
*/
|
|
38
|
+
min: _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
39
|
+
/**
|
|
40
|
+
* To hide children of `Responsive` if the current viewport is larger than `max`
|
|
41
|
+
*/
|
|
42
|
+
max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
43
|
+
children: _propTypes.default.node.isRequired
|
|
44
|
+
};
|
|
45
|
+
var _default = ResponsiveProp;
|
|
46
|
+
exports.default = _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function generateResponsiveStyles(min, max) {
|
|
14
|
+
const viewportsArray = _systemConstants.viewports.keys;
|
|
15
|
+
const minIndex = viewportsArray.indexOf(min);
|
|
16
|
+
const maxIndex = viewportsArray.indexOf(max);
|
|
17
|
+
let hiddenViewports = [];
|
|
18
|
+
if (minIndex !== -1) {
|
|
19
|
+
hiddenViewports = viewportsArray.slice(0, minIndex);
|
|
20
|
+
}
|
|
21
|
+
if (maxIndex !== -1) {
|
|
22
|
+
hiddenViewports = hiddenViewports.concat(viewportsArray.slice(maxIndex + 1));
|
|
23
|
+
}
|
|
24
|
+
const styles = {};
|
|
25
|
+
viewportsArray.forEach(viewport => {
|
|
26
|
+
if (hiddenViewports.includes(viewport)) {
|
|
27
|
+
styles[viewport] = {
|
|
28
|
+
display: 'none'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return (0, _utils.createMediaQueryStyles)(styles, false);
|
|
33
|
+
}
|
|
34
|
+
const ResponsiveWithMediaQueryStyleSheet = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
min,
|
|
37
|
+
max,
|
|
38
|
+
inheritedStyles = [],
|
|
39
|
+
children
|
|
40
|
+
} = _ref;
|
|
41
|
+
const {
|
|
42
|
+
ids,
|
|
43
|
+
styles
|
|
44
|
+
} = _utils.StyleSheet.create({
|
|
45
|
+
responsive: {
|
|
46
|
+
...inheritedStyles.reduce((acc, prop) => {
|
|
47
|
+
acc[prop] = 'inherit';
|
|
48
|
+
return acc;
|
|
49
|
+
}, {}),
|
|
50
|
+
...generateResponsiveStyles(min, max)
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.BaseView, {
|
|
54
|
+
style: styles.responsive,
|
|
55
|
+
dataSet: ids.responsive && {
|
|
56
|
+
media: ids.responsive
|
|
57
|
+
},
|
|
58
|
+
children: children
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
ResponsiveWithMediaQueryStyleSheet.displayName = 'Responsive';
|
|
62
|
+
ResponsiveWithMediaQueryStyleSheet.propTypes = {
|
|
63
|
+
/**
|
|
64
|
+
* To hide children of `Responsive` if the current viewport is smaller than `min`
|
|
65
|
+
*/
|
|
66
|
+
min: _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl']),
|
|
67
|
+
/**
|
|
68
|
+
* To hide children of `Responsive` if the current viewport is larger than `max`
|
|
69
|
+
*/
|
|
70
|
+
max: _propTypes.default.oneOf(['sm', 'md', 'lg', 'xl']),
|
|
71
|
+
inheritedStyles: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
72
|
+
children: _propTypes.default.node.isRequired
|
|
73
|
+
};
|
|
74
|
+
var _default = ResponsiveWithMediaQueryStyleSheet;
|
|
75
|
+
exports.default = _default;
|
|
@@ -27,7 +27,8 @@ const defaultThemeOptions = {
|
|
|
27
27
|
// TODO: switch `forceZIndex` to be false by default in the next major version
|
|
28
28
|
forceZIndex: true,
|
|
29
29
|
// TODO: switch `enableHelmetSSR` to be false by default in the next major version
|
|
30
|
-
enableHelmetSSR: true
|
|
30
|
+
enableHelmetSSR: true,
|
|
31
|
+
enableMediaQueryStyleSheet: false
|
|
31
32
|
};
|
|
32
33
|
const ThemeProvider = _ref => {
|
|
33
34
|
let {
|
|
@@ -82,12 +83,14 @@ ThemeProvider.propTypes = {
|
|
|
82
83
|
* - `enableHelmetSSR`: on Web SSR, allows React Helmet to run during server-side rendering. This should be
|
|
83
84
|
* disabled unless a web app has been specifically configured to stop React Helmet accumulating
|
|
84
85
|
* instances (which may cause a memory leak). See React Helmet's docs: https://github.com/nfl/react-helmet
|
|
86
|
+
* - `enableMediaQueryStyleSheet`: enables the use of Media Query StyleSheet.
|
|
85
87
|
*/
|
|
86
88
|
themeOptions: _propTypes.default.shape({
|
|
87
89
|
forceAbsoluteFontSizing: _propTypes.default.bool,
|
|
88
90
|
forceZIndex: _propTypes.default.bool,
|
|
89
91
|
enableHelmetSSR: _propTypes.default.bool,
|
|
90
|
-
contentMaxWidth: _responsiveProps.default.getTypeOptionallyByViewport(_propTypes.default.number)
|
|
92
|
+
contentMaxWidth: _responsiveProps.default.getTypeOptionallyByViewport(_propTypes.default.number),
|
|
93
|
+
enableMediaQueryStyleSheet: _propTypes.default.bool
|
|
91
94
|
})
|
|
92
95
|
};
|
|
93
96
|
var _default = ThemeProvider;
|
|
@@ -5,9 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
useTheme: true,
|
|
8
|
-
useSetTheme: true
|
|
8
|
+
useSetTheme: true,
|
|
9
|
+
useResponsiveThemeTokens: true
|
|
9
10
|
};
|
|
10
11
|
exports.default = void 0;
|
|
12
|
+
Object.defineProperty(exports, "useResponsiveThemeTokens", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useResponsiveThemeTokens.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
11
18
|
Object.defineProperty(exports, "useSetTheme", {
|
|
12
19
|
enumerable: true,
|
|
13
20
|
get: function () {
|
|
@@ -23,6 +30,7 @@ Object.defineProperty(exports, "useTheme", {
|
|
|
23
30
|
var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
|
|
24
31
|
var _useTheme = _interopRequireDefault(require("./useTheme"));
|
|
25
32
|
var _useSetTheme = _interopRequireDefault(require("./useSetTheme"));
|
|
33
|
+
var _useResponsiveThemeTokens = _interopRequireDefault(require("./useResponsiveThemeTokens"));
|
|
26
34
|
var _useThemeTokens = require("./useThemeTokens");
|
|
27
35
|
Object.keys(_useThemeTokens).forEach(function (key) {
|
|
28
36
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _systemConstants = require("@telus-uds/system-constants");
|
|
8
|
+
var _useTheme = _interopRequireDefault(require("./useTheme"));
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const getResponsiveThemeTokens = function (_ref, tokensProp) {
|
|
12
|
+
let {
|
|
13
|
+
rules = [],
|
|
14
|
+
tokens: defaultThemeTokens = {}
|
|
15
|
+
} = _ref;
|
|
16
|
+
let variants = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
17
|
+
let states = arguments.length > 3 ? arguments[3] : undefined;
|
|
18
|
+
const appearances = (0, _utils.mergeAppearances)(variants, states);
|
|
19
|
+
const tokensByViewport = Object.fromEntries(_systemConstants.viewports.keys.map(viewport => [viewport, {
|
|
20
|
+
...defaultThemeTokens
|
|
21
|
+
}]));
|
|
22
|
+
|
|
23
|
+
// Go through each rule and collect them for the corresponding viewport if they apply
|
|
24
|
+
rules.forEach(rule => {
|
|
25
|
+
if (doesRuleApply(rule, appearances)) {
|
|
26
|
+
// If the rule does not have a viewport specified, we collect it in all viewports
|
|
27
|
+
let targetViewports = rule.if.viewport || _systemConstants.viewports.keys;
|
|
28
|
+
if (!Array.isArray(targetViewports)) {
|
|
29
|
+
targetViewports = [targetViewports];
|
|
30
|
+
}
|
|
31
|
+
targetViewports.forEach(viewport => {
|
|
32
|
+
tokensByViewport[viewport] = {
|
|
33
|
+
...tokensByViewport[viewport],
|
|
34
|
+
...rule.tokens
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.keys(tokensByViewport).forEach(viewport => {
|
|
40
|
+
tokensByViewport[viewport] = (0, _utils.resolveThemeTokens)(tokensByViewport[viewport], appearances, tokensProp);
|
|
41
|
+
});
|
|
42
|
+
return tokensByViewport;
|
|
43
|
+
};
|
|
44
|
+
const doesRuleApply = (rule, appearances) => Object.entries(rule.if).every(condition => doesConditionApply(condition, appearances));
|
|
45
|
+
const doesConditionApply = (_ref2, appearances) => {
|
|
46
|
+
let [key, value] = _ref2;
|
|
47
|
+
if (key === 'viewport') {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// use null rather than undefined so we can serialise the value in themes
|
|
51
|
+
const appearanceValue = appearances[key] ?? null;
|
|
52
|
+
return Array.isArray(value) ? value.includes(appearanceValue) : value === appearanceValue;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {import('../utils/props/tokens.js').TokensSet} TokensSet
|
|
57
|
+
* @typedef {import('../utils/props/tokens.js').TokensProp} TokensProp
|
|
58
|
+
* @typedef {import('../utils/props/variantProp').AppearanceSet} AppearanceSet
|
|
59
|
+
*
|
|
60
|
+
* Returns a complete set of tokens for a component for each viewport based on which of the
|
|
61
|
+
* component's theme rules apply to the current set of theme appearances.
|
|
62
|
+
* Pass the returned output to createMediaQueryStyles to generate media query styles for use inside
|
|
63
|
+
* the media query stylesheet from './utils/ssr-media-query'.
|
|
64
|
+
*
|
|
65
|
+
* @typedef {Object} ResponsiveObject
|
|
66
|
+
* @property {TokensSet} xs
|
|
67
|
+
* @property {TokensSet} sm
|
|
68
|
+
* @property {TokensSet} md
|
|
69
|
+
* @property {TokensSet} lg
|
|
70
|
+
* @property {TokensSet} xl
|
|
71
|
+
*
|
|
72
|
+
* @param { string } componentName
|
|
73
|
+
* @param { TokensProp } tokens
|
|
74
|
+
* @param { AppearanceSet } variants
|
|
75
|
+
* @param { AppearanceSet } states
|
|
76
|
+
* @returns { ResponsiveObject }
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
const useResponsiveThemeTokens = function (componentName) {
|
|
80
|
+
let tokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
81
|
+
let variants = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
|
+
let states = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
83
|
+
const theme = (0, _useTheme.default)();
|
|
84
|
+
const componentTheme = (0, _utils.getComponentTheme)(theme, componentName);
|
|
85
|
+
const themeTokens = getResponsiveThemeTokens(componentTheme, tokens, variants, states);
|
|
86
|
+
return themeTokens;
|
|
87
|
+
};
|
|
88
|
+
var _default = useResponsiveThemeTokens;
|
|
89
|
+
exports.default = _default;
|
|
@@ -9,9 +9,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
|
|
10
10
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
11
11
|
var _ThemeProvider = require("../ThemeProvider");
|
|
12
|
-
var _ViewportProvider = require("../ViewportProvider");
|
|
13
12
|
var _utils = require("../ThemeProvider/utils");
|
|
14
13
|
var _utils2 = require("../utils");
|
|
14
|
+
var _ViewportProvider = require("../ViewportProvider");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
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,7 +29,8 @@ const selectTextStyles = (_ref, themeOptions) => {
|
|
|
29
29
|
fontName,
|
|
30
30
|
textAlign,
|
|
31
31
|
textTransform,
|
|
32
|
-
letterSpacing
|
|
32
|
+
letterSpacing,
|
|
33
|
+
textDecorationLine
|
|
33
34
|
} = _ref;
|
|
34
35
|
return (0, _utils.applyTextStyles)({
|
|
35
36
|
fontWeight,
|
|
@@ -40,7 +41,8 @@ const selectTextStyles = (_ref, themeOptions) => {
|
|
|
40
41
|
themeOptions,
|
|
41
42
|
textAlign,
|
|
42
43
|
textTransform,
|
|
43
|
-
letterSpacing
|
|
44
|
+
letterSpacing,
|
|
45
|
+
textDecorationLine
|
|
44
46
|
});
|
|
45
47
|
};
|
|
46
48
|
|
|
@@ -60,23 +62,50 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
60
62
|
...rest
|
|
61
63
|
} = _ref2;
|
|
62
64
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
63
|
-
const {
|
|
64
|
-
superScriptFontSize,
|
|
65
|
-
...themeTokens
|
|
66
|
-
} = (0, _ThemeProvider.useThemeTokens)('Typography', tokens, variant, {
|
|
67
|
-
viewport
|
|
68
|
-
});
|
|
69
65
|
const {
|
|
70
66
|
themeOptions
|
|
71
67
|
} = (0, _ThemeProvider.useTheme)();
|
|
68
|
+
const {
|
|
69
|
+
enableMediaQueryStyleSheet
|
|
70
|
+
} = themeOptions;
|
|
71
|
+
const useTokens = enableMediaQueryStyleSheet ? _ThemeProvider.useResponsiveThemeTokens : _ThemeProvider.useThemeTokens;
|
|
72
|
+
const themeTokens = useTokens('Typography', tokens, variant, !enableMediaQueryStyleSheet && {
|
|
73
|
+
viewport
|
|
74
|
+
});
|
|
75
|
+
const maxFontSizeMultiplier = enableMediaQueryStyleSheet ? (0, _utils2.getMaxFontMultiplier)(themeTokens[viewport]) : (0, _utils2.getMaxFontMultiplier)(themeTokens);
|
|
76
|
+
const textDecorationLine = strikeThrough ? 'line-through' : 'none';
|
|
77
|
+
let textStyles;
|
|
78
|
+
let mediaIds;
|
|
79
|
+
if (enableMediaQueryStyleSheet) {
|
|
80
|
+
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref3) => {
|
|
81
|
+
let [vp, viewportTokens] = _ref3;
|
|
82
|
+
acc[vp] = selectTextStyles({
|
|
83
|
+
textAlign: align,
|
|
84
|
+
textDecorationLine,
|
|
85
|
+
...viewportTokens
|
|
86
|
+
}, themeOptions);
|
|
87
|
+
return acc;
|
|
88
|
+
}, {});
|
|
89
|
+
const mediaQueryStyles = (0, _utils2.createMediaQueryStyles)(transformedThemeTokens);
|
|
90
|
+
const {
|
|
91
|
+
ids,
|
|
92
|
+
styles
|
|
93
|
+
} = _utils2.StyleSheet.create({
|
|
94
|
+
text: mediaQueryStyles
|
|
95
|
+
});
|
|
96
|
+
textStyles = styles.text;
|
|
97
|
+
mediaIds = ids.text;
|
|
98
|
+
} else {
|
|
99
|
+
textStyles = selectTextStyles({
|
|
100
|
+
textAlign: align,
|
|
101
|
+
textDecorationLine,
|
|
102
|
+
...themeTokens
|
|
103
|
+
}, themeOptions);
|
|
104
|
+
}
|
|
72
105
|
const resolvedTextProps = {
|
|
73
106
|
...selectTextProps(rest),
|
|
74
|
-
style: selectTextStyles(align ? {
|
|
75
|
-
...themeTokens,
|
|
76
|
-
textAlign: align
|
|
77
|
-
} : themeTokens, themeOptions),
|
|
78
107
|
dataSet,
|
|
79
|
-
maxFontSizeMultiplier
|
|
108
|
+
maxFontSizeMultiplier
|
|
80
109
|
};
|
|
81
110
|
const containerProps = {
|
|
82
111
|
accessibilityRole,
|
|
@@ -87,7 +116,7 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
87
116
|
if (typeof child === 'object' && ((child === null || child === void 0 ? void 0 : child.type) === 'sub' || (child === null || child === void 0 ? void 0 : child.type) === 'sup')) {
|
|
88
117
|
var _child$props;
|
|
89
118
|
const childStyles = (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.style) || {};
|
|
90
|
-
const supFontSize = childStyles.fontSize ?? superScriptFontSize;
|
|
119
|
+
const supFontSize = childStyles.fontSize ?? themeTokens.superScriptFontSize;
|
|
91
120
|
const sanitizedChild = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
92
121
|
style: {
|
|
93
122
|
...childStyles,
|
|
@@ -107,19 +136,15 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
107
136
|
}
|
|
108
137
|
return resetTagStyling(children);
|
|
109
138
|
};
|
|
110
|
-
const textDecorationLine = strikeThrough ? 'line-through' : 'none';
|
|
111
|
-
const textStyles = resolvedTextProps.style ? {
|
|
112
|
-
...resolvedTextProps.style,
|
|
113
|
-
textDecorationLine
|
|
114
|
-
} : {
|
|
115
|
-
textDecorationLine
|
|
116
|
-
};
|
|
117
139
|
return block ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
118
140
|
ref: ref,
|
|
119
141
|
...containerProps,
|
|
120
142
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
121
143
|
...resolvedTextProps,
|
|
122
144
|
style: textStyles,
|
|
145
|
+
dataSet: mediaIds && {
|
|
146
|
+
media: mediaIds
|
|
147
|
+
},
|
|
123
148
|
children: sanitizeChildren(children)
|
|
124
149
|
})
|
|
125
150
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
@@ -127,6 +152,9 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
127
152
|
...containerProps,
|
|
128
153
|
...resolvedTextProps,
|
|
129
154
|
style: textStyles,
|
|
155
|
+
dataSet: mediaIds && {
|
|
156
|
+
media: mediaIds
|
|
157
|
+
},
|
|
130
158
|
children: sanitizeChildren(children)
|
|
131
159
|
});
|
|
132
160
|
});
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var _exportNames = {
|
|
|
22
22
|
Feedback: true,
|
|
23
23
|
Fieldset: true,
|
|
24
24
|
FlexGrid: true,
|
|
25
|
+
Footnote: true,
|
|
25
26
|
HorizontalScroll: true,
|
|
26
27
|
Icon: true,
|
|
27
28
|
IconButton: true,
|
|
@@ -182,6 +183,12 @@ Object.defineProperty(exports, "FlexGrid", {
|
|
|
182
183
|
return _FlexGrid.default;
|
|
183
184
|
}
|
|
184
185
|
});
|
|
186
|
+
Object.defineProperty(exports, "Footnote", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return _Footnote.default;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
185
192
|
Object.defineProperty(exports, "HorizontalScroll", {
|
|
186
193
|
enumerable: true,
|
|
187
194
|
get: function () {
|
|
@@ -539,6 +546,7 @@ var _ExpandCollapse = _interopRequireWildcard(require("./ExpandCollapse"));
|
|
|
539
546
|
var _Feedback = _interopRequireDefault(require("./Feedback"));
|
|
540
547
|
var _Fieldset = _interopRequireDefault(require("./Fieldset"));
|
|
541
548
|
var _FlexGrid = _interopRequireDefault(require("./FlexGrid"));
|
|
549
|
+
var _Footnote = _interopRequireDefault(require("./Footnote"));
|
|
542
550
|
var _HorizontalScroll = _interopRequireWildcard(require("./HorizontalScroll"));
|
|
543
551
|
Object.keys(_HorizontalScroll).forEach(function (key) {
|
|
544
552
|
if (key === "default" || key === "__esModule") return;
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getComponentTheme", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _themeTokens.getComponentTheme;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getThemeTokens", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _themeTokens.getThemeTokens;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "getTokensPropType", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _tokens.getTokensPropType;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "htmlAttrs", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _htmlAttrs.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "selectSystemProps", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _selectSystemProps.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _selectSystemProps = _interopRequireDefault(require("./utils/props/selectSystemProps"));
|
|
37
|
+
var _tokens = require("./utils/props/tokens");
|
|
38
|
+
var _htmlAttrs = _interopRequireDefault(require("./utils/htmlAttrs"));
|
|
39
|
+
var _themeTokens = require("./ThemeProvider/utils/theme-tokens");
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -5,20 +5,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _systemConstants = require("@telus-uds/system-constants");
|
|
8
|
+
const inherit = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
xs,
|
|
11
|
+
sm = xs,
|
|
12
|
+
md = sm,
|
|
13
|
+
lg = md,
|
|
14
|
+
xl = lg
|
|
15
|
+
} = _ref;
|
|
16
|
+
return {
|
|
17
|
+
xs,
|
|
18
|
+
sm,
|
|
19
|
+
md,
|
|
20
|
+
lg,
|
|
21
|
+
xl
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
8
25
|
/**
|
|
9
26
|
* @typedef { Object } CssStyles
|
|
10
|
-
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef { Object } ViewportStyles
|
|
31
|
+
* @property { CssStyles } xs - The CSS styles for the "xs" viewport (required).
|
|
32
|
+
* @property { CssStyles } [sm] - Optional styles for the "sm" viewport. Inherits from "xs" if not specified.
|
|
33
|
+
* @property { CssStyles } [md] - Optional styles for the "md" viewport. Inherits from "sm" if not specified.
|
|
34
|
+
* @property { CssStyles } [lg] - Optional styles for the "lg" viewport. Inherits from "md" if not specified.
|
|
35
|
+
* @property { CssStyles } [xl] - Optional styles for the "xl" viewport. Inherits from "lg" if not specified.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
11
39
|
* @typedef { Record<String, CssStyles> } MediaQueryStyles
|
|
12
40
|
*/
|
|
41
|
+
|
|
13
42
|
/**
|
|
14
43
|
* Generates media query styles based on specified viewport styles.
|
|
15
|
-
* @param {
|
|
16
|
-
* @
|
|
44
|
+
* @param { Object } viewportStyles - The styles for different viewports.
|
|
45
|
+
* @param { boolean } [shouldInherit=true] - Flag indicating whether to inherit styles.
|
|
46
|
+
* @returns { Object } - The media query styles.
|
|
17
47
|
*/
|
|
48
|
+
|
|
18
49
|
function createMediaQueryStyles(viewportStyles) {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
50
|
+
let shouldInherit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
51
|
+
const effectiveStyles = shouldInherit ? inherit(viewportStyles) : viewportStyles;
|
|
52
|
+
const viewportsArray = _systemConstants.viewports.keys;
|
|
53
|
+
const mediaQueries = Object.entries(effectiveStyles).reduce((acc, _ref2) => {
|
|
54
|
+
let [viewport, styles] = _ref2;
|
|
22
55
|
const minWidth = _systemConstants.viewports.map.get(viewport);
|
|
23
56
|
const nextViewport = viewportsArray[viewportsArray.indexOf(viewport) + 1];
|
|
24
57
|
const maxWidth = _systemConstants.viewports.map.get(nextViewport);
|
package/lib-module/Box/Box.js
CHANGED
|
@@ -2,6 +2,7 @@ import React, { forwardRef } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
4
|
import ScrollView from "react-native-web/dist/exports/ScrollView";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
5
6
|
import { useThemeTokens } from '../ThemeProvider';
|
|
6
7
|
import { a11yProps, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, selectSystemProps, spacingProps, useSpacingScale, variantProp, viewProps } from '../utils';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -14,7 +15,7 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
|
|
|
14
15
|
* @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
const selectBoxStyles = _ref => {
|
|
18
|
+
const selectBoxStyles = (_ref, customGradient) => {
|
|
18
19
|
let {
|
|
19
20
|
backgroundColor,
|
|
20
21
|
gradient,
|
|
@@ -40,7 +41,11 @@ const selectBoxStyles = _ref => {
|
|
|
40
41
|
angle,
|
|
41
42
|
stops: [stopOne, stopTwo]
|
|
42
43
|
} = gradient;
|
|
43
|
-
|
|
44
|
+
if (Platform.OS === 'web') {
|
|
45
|
+
styles.backgroundImage = `linear-gradient(${angle}deg, ${stopOne.color}, 75%, ${stopTwo.color})`;
|
|
46
|
+
} else if (customGradient && Platform.OS !== 'web') {
|
|
47
|
+
styles.colors = [stopOne.color, stopTwo.color];
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'];
|
|
46
51
|
// Only set on styles if token provided because we spread this object after the spacing scale values
|
|
@@ -135,6 +140,7 @@ const Box = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
135
140
|
accessibilityRole,
|
|
136
141
|
testID,
|
|
137
142
|
dataSet,
|
|
143
|
+
customGradient,
|
|
138
144
|
...rest
|
|
139
145
|
} = _ref2;
|
|
140
146
|
const props = {
|
|
@@ -149,8 +155,9 @@ const Box = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
149
155
|
paddingRight: useSpacingScale(right),
|
|
150
156
|
paddingTop: useSpacingScale(top),
|
|
151
157
|
paddingBottom: useSpacingScale(bottom),
|
|
152
|
-
...selectBoxStyles(themeTokens)
|
|
158
|
+
...selectBoxStyles(themeTokens, customGradient)
|
|
153
159
|
};
|
|
160
|
+
const childrenToRender = typeof customGradient === 'function' ? customGradient(styles.colors, styles)(children) : children;
|
|
154
161
|
if (scroll) {
|
|
155
162
|
const scrollProps = typeof scroll === 'object' ? scroll : {};
|
|
156
163
|
scrollProps.contentContainerStyle = [styles, scrollProps.contentContainerStyle];
|
|
@@ -160,7 +167,7 @@ const Box = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
160
167
|
testID: testID,
|
|
161
168
|
dataSet: dataSet,
|
|
162
169
|
ref: ref,
|
|
163
|
-
children:
|
|
170
|
+
children: childrenToRender
|
|
164
171
|
});
|
|
165
172
|
}
|
|
166
173
|
return /*#__PURE__*/_jsx(View, {
|
|
@@ -169,7 +176,7 @@ const Box = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
169
176
|
testID: testID,
|
|
170
177
|
dataSet: dataSet,
|
|
171
178
|
ref: ref,
|
|
172
|
-
children:
|
|
179
|
+
children: childrenToRender
|
|
173
180
|
});
|
|
174
181
|
});
|
|
175
182
|
Box.displayName = 'Box';
|
|
@@ -253,6 +260,10 @@ Box.propTypes = {
|
|
|
253
260
|
/**
|
|
254
261
|
* Box accepts any content as children.
|
|
255
262
|
*/
|
|
256
|
-
children: PropTypes.node.isRequired
|
|
263
|
+
children: PropTypes.node.isRequired,
|
|
264
|
+
/**
|
|
265
|
+
Use this prop if need to add a custom gradient for mobile
|
|
266
|
+
*/
|
|
267
|
+
customGradient: PropTypes.func
|
|
257
268
|
};
|
|
258
269
|
export default Box;
|