@telus-uds/components-base 1.70.0 → 1.72.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 +30 -2
- package/jest.setup.js +7 -0
- package/lib/Autocomplete/Autocomplete.js +3 -13
- package/lib/Card/Card.js +68 -7
- package/lib/Card/PressableCardBase.js +2 -0
- package/lib/ColourToggle/ColourBubble.js +135 -0
- package/lib/ColourToggle/ColourToggle.js +101 -0
- package/lib/ColourToggle/index.js +10 -0
- package/lib/FlexGrid/Col/Col.js +50 -64
- package/lib/FlexGrid/FlexGrid.js +37 -40
- package/lib/FlexGrid/Row/Row.js +43 -44
- package/lib/Icon/IconText.js +9 -2
- package/lib/Link/LinkBase.js +10 -3
- package/lib/Modal/ModalContent.js +4 -6
- package/lib/OrderedList/Item.js +180 -0
- package/lib/OrderedList/ItemBase.js +48 -0
- package/lib/OrderedList/OrderedList.js +71 -0
- package/lib/OrderedList/OrderedListBase.js +47 -0
- package/lib/OrderedList/index.js +10 -0
- package/lib/index.js +16 -0
- package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +56 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.android.js +10 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.ios.js +10 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +44 -0
- package/lib/utils/ssr-media-query/utils/inject.js +13 -0
- package/lib-module/Autocomplete/Autocomplete.js +3 -13
- package/lib-module/Card/Card.js +71 -8
- package/lib-module/Card/PressableCardBase.js +2 -0
- package/lib-module/ColourToggle/ColourBubble.js +125 -0
- package/lib-module/ColourToggle/ColourToggle.js +92 -0
- package/lib-module/ColourToggle/index.js +2 -0
- package/lib-module/FlexGrid/Col/Col.js +51 -65
- package/lib-module/FlexGrid/FlexGrid.js +38 -41
- package/lib-module/FlexGrid/Row/Row.js +44 -45
- package/lib-module/Icon/IconText.js +9 -2
- package/lib-module/Link/LinkBase.js +10 -3
- package/lib-module/Modal/ModalContent.js +4 -6
- package/lib-module/OrderedList/Item.js +171 -0
- package/lib-module/OrderedList/ItemBase.js +37 -0
- package/lib-module/OrderedList/OrderedList.js +61 -0
- package/lib-module/OrderedList/OrderedListBase.js +36 -0
- package/lib-module/OrderedList/index.js +2 -0
- package/lib-module/index.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +48 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.android.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.ios.js +2 -0
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +36 -0
- package/lib-module/utils/ssr-media-query/utils/inject.js +13 -0
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +14 -21
- package/src/Card/Card.jsx +73 -11
- package/src/Card/PressableCardBase.jsx +2 -0
- package/src/ColourToggle/ColourBubble.jsx +111 -0
- package/src/ColourToggle/ColourToggle.jsx +83 -0
- package/src/ColourToggle/index.js +3 -0
- package/src/FlexGrid/Col/Col.jsx +48 -80
- package/src/FlexGrid/FlexGrid.jsx +36 -44
- package/src/FlexGrid/Row/Row.jsx +38 -56
- package/src/Icon/IconText.jsx +11 -1
- package/src/Link/ChevronLink.jsx +1 -0
- package/src/Link/LinkBase.jsx +16 -6
- package/src/Modal/ModalContent.jsx +4 -6
- package/src/OrderedList/Item.jsx +152 -0
- package/src/OrderedList/ItemBase.jsx +31 -0
- package/src/OrderedList/OrderedList.jsx +61 -0
- package/src/OrderedList/OrderedListBase.jsx +33 -0
- package/src/OrderedList/index.js +3 -0
- package/src/index.js +2 -0
- package/src/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +41 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.android.js +3 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.ios.js +3 -0
- package/src/utils/ssr-media-query/create-stylesheet/index.js +33 -0
- package/src/utils/ssr-media-query/utils/inject.js +13 -0
- package/types/Badge.d.ts +28 -0
- package/types/Box.d.ts +52 -0
- package/types/ChevronLink.d.ts +47 -0
- package/types/Common.d.ts +106 -0
- package/types/Divider.d.ts +19 -0
- package/types/ExpandCollapse.d.ts +65 -0
- package/types/HorizontalScrollButton.d.ts +16 -0
- package/types/Icon.d.ts +21 -0
- package/types/Link.d.ts +48 -0
- package/types/List.d.ts +48 -0
- package/types/Search.d.ts +38 -0
- package/types/Select.d.ts +57 -0
- package/types/Spacer.d.ts +5 -0
- package/types/StackView.d.ts +28 -0
- package/types/Tabs.d.ts +46 -0
- package/types/TextButton.d.ts +11 -0
- package/types/ToggleSwitch.d.ts +54 -0
- package/types/ToolTip.d.ts +40 -0
- package/types/Typography.d.ts +39 -0
- package/types/index.d.ts +62 -0
- package/lib/utils/ssr-media-query/create-stylesheet.js +0 -76
- package/lib-module/utils/ssr-media-query/create-stylesheet.js +0 -68
- package/src/utils/ssr-media-query/create-stylesheet.js +0 -61
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var _exportNames = {
|
|
|
15
15
|
Checkbox: true,
|
|
16
16
|
CheckboxCard: true,
|
|
17
17
|
CheckboxCardGroup: true,
|
|
18
|
+
ColourToggle: true,
|
|
18
19
|
Divider: true,
|
|
19
20
|
ExpandCollapse: true,
|
|
20
21
|
Accordion: true,
|
|
@@ -32,6 +33,7 @@ var _exportNames = {
|
|
|
32
33
|
Modal: true,
|
|
33
34
|
MultiSelectFilter: true,
|
|
34
35
|
Notification: true,
|
|
36
|
+
OrderedList: true,
|
|
35
37
|
Pagination: true,
|
|
36
38
|
Progress: true,
|
|
37
39
|
QuickLinks: true,
|
|
@@ -144,6 +146,12 @@ Object.defineProperty(exports, "CheckboxCardGroup", {
|
|
|
144
146
|
return _CheckboxCardGroup.default;
|
|
145
147
|
}
|
|
146
148
|
});
|
|
149
|
+
Object.defineProperty(exports, "ColourToggle", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () {
|
|
152
|
+
return _ColourToggle.default;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
147
155
|
Object.defineProperty(exports, "Divider", {
|
|
148
156
|
enumerable: true,
|
|
149
157
|
get: function () {
|
|
@@ -246,6 +254,12 @@ Object.defineProperty(exports, "Notification", {
|
|
|
246
254
|
return _Notification.default;
|
|
247
255
|
}
|
|
248
256
|
});
|
|
257
|
+
Object.defineProperty(exports, "OrderedList", {
|
|
258
|
+
enumerable: true,
|
|
259
|
+
get: function () {
|
|
260
|
+
return _OrderedList.default;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
249
263
|
Object.defineProperty(exports, "Pagination", {
|
|
250
264
|
enumerable: true,
|
|
251
265
|
get: function () {
|
|
@@ -519,6 +533,7 @@ Object.keys(_Checkbox).forEach(function (key) {
|
|
|
519
533
|
});
|
|
520
534
|
var _CheckboxCard = _interopRequireDefault(require("./CheckboxCard"));
|
|
521
535
|
var _CheckboxCardGroup = _interopRequireDefault(require("./CheckboxCardGroup"));
|
|
536
|
+
var _ColourToggle = _interopRequireDefault(require("./ColourToggle"));
|
|
522
537
|
var _Divider = _interopRequireDefault(require("./Divider"));
|
|
523
538
|
var _ExpandCollapse = _interopRequireWildcard(require("./ExpandCollapse"));
|
|
524
539
|
var _Feedback = _interopRequireDefault(require("./Feedback"));
|
|
@@ -567,6 +582,7 @@ var _List = _interopRequireWildcard(require("./List"));
|
|
|
567
582
|
var _Modal = _interopRequireDefault(require("./Modal"));
|
|
568
583
|
var _MultiSelectFilter = _interopRequireDefault(require("./MultiSelectFilter"));
|
|
569
584
|
var _Notification = _interopRequireDefault(require("./Notification"));
|
|
585
|
+
var _OrderedList = _interopRequireDefault(require("./OrderedList"));
|
|
570
586
|
var _Pagination = _interopRequireDefault(require("./Pagination"));
|
|
571
587
|
var _Progress = _interopRequireDefault(require("./Progress"));
|
|
572
588
|
var _QuickLinks = _interopRequireDefault(require("./QuickLinks"));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _cssMediaquery = _interopRequireDefault(require("css-mediaquery"));
|
|
8
|
+
var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
|
|
9
|
+
var _common = require("../utils/common");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const createStyleSheet = stylesWithQuery => {
|
|
12
|
+
if (!stylesWithQuery) return {
|
|
13
|
+
ids: {},
|
|
14
|
+
styles: {},
|
|
15
|
+
fullStyles: {}
|
|
16
|
+
};
|
|
17
|
+
let cleanStyles;
|
|
18
|
+
const ids = {};
|
|
19
|
+
Object.keys(stylesWithQuery).forEach(key => {
|
|
20
|
+
if (!(stylesWithQuery !== null && stylesWithQuery !== void 0 && stylesWithQuery[key])) return;
|
|
21
|
+
const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(_common.isMediaOrPseudo);
|
|
22
|
+
cleanStyles = JSON.parse(JSON.stringify(stylesWithQuery));
|
|
23
|
+
mediaQueriesAndPseudoClasses.forEach(str => {
|
|
24
|
+
if ((0, _common.isMedia)(str)) {
|
|
25
|
+
const mqStr = str.replace('@media', '');
|
|
26
|
+
const {
|
|
27
|
+
width,
|
|
28
|
+
height
|
|
29
|
+
} = _Dimensions.default.get('window');
|
|
30
|
+
const isMatchingMediaQuery = _cssMediaquery.default.match(mqStr, {
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
orientation: width > height ? 'landscape' : 'portrait',
|
|
34
|
+
'aspect-ratio': width / height
|
|
35
|
+
});
|
|
36
|
+
if (isMatchingMediaQuery) {
|
|
37
|
+
cleanStyles = {
|
|
38
|
+
...cleanStyles,
|
|
39
|
+
[key]: {
|
|
40
|
+
...cleanStyles[key],
|
|
41
|
+
...stylesWithQuery[key][str]
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
delete cleanStyles[key][str];
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
ids,
|
|
51
|
+
styles: cleanStyles,
|
|
52
|
+
fullStyles: stylesWithQuery
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
var _default = createStyleSheet;
|
|
56
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _createStylesheetMobile = _interopRequireDefault(require("./create-stylesheet-mobile"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _createStylesheetMobile.default;
|
|
10
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _createStylesheetMobile = _interopRequireDefault(require("./create-stylesheet-mobile"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _createStylesheetMobile.default;
|
|
10
|
+
exports.default = _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _inject = require("../utils/inject");
|
|
8
|
+
var _createDeclarationBlock = _interopRequireDefault(require("../utils/create-declaration-block"));
|
|
9
|
+
var _hash = _interopRequireDefault(require("../hash"));
|
|
10
|
+
var _common = require("../utils/common");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const createStyleSheet = stylesWithQuery => {
|
|
13
|
+
if (!stylesWithQuery) return {
|
|
14
|
+
ids: {},
|
|
15
|
+
styles: {},
|
|
16
|
+
fullStyles: {}
|
|
17
|
+
};
|
|
18
|
+
let cleanStyles;
|
|
19
|
+
let ids = {};
|
|
20
|
+
Object.keys(stylesWithQuery).forEach(key => {
|
|
21
|
+
if (!(stylesWithQuery !== null && stylesWithQuery !== void 0 && stylesWithQuery[key])) return;
|
|
22
|
+
const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(_common.isMediaOrPseudo);
|
|
23
|
+
cleanStyles = (0, _common.deepClone)(stylesWithQuery);
|
|
24
|
+
mediaQueriesAndPseudoClasses.forEach(query => {
|
|
25
|
+
var _ids;
|
|
26
|
+
const css = (0, _createDeclarationBlock.default)(stylesWithQuery[key][query]);
|
|
27
|
+
const stringHash = `rnmq-${(0, _hash.default)(`${key}${query}${css}`)}`;
|
|
28
|
+
const rule = (0, _common.createCssRule)(query, stringHash, css);
|
|
29
|
+
(0, _inject.addCss)(`${stringHash}`, rule);
|
|
30
|
+
delete cleanStyles[key][query];
|
|
31
|
+
ids = {
|
|
32
|
+
...ids,
|
|
33
|
+
[key]: `${(_ids = ids) !== null && _ids !== void 0 && _ids[key] ? `${ids[key]} ` : ''}${stringHash}`
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
ids,
|
|
39
|
+
styles: cleanStyles,
|
|
40
|
+
fullStyles: stylesWithQuery
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var _default = createStyleSheet;
|
|
44
|
+
exports.default = _default;
|
|
@@ -8,6 +8,16 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
const rules = {};
|
|
11
|
+
let styleSheet;
|
|
12
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
13
|
+
styleSheet = (() => {
|
|
14
|
+
const style = document.createElement('style');
|
|
15
|
+
style.id = 'RNMQCSS';
|
|
16
|
+
style.appendChild(document.createTextNode(''));
|
|
17
|
+
document.head.appendChild(style);
|
|
18
|
+
return style.sheet;
|
|
19
|
+
})();
|
|
20
|
+
}
|
|
11
21
|
const hasCss = (id, text) => {
|
|
12
22
|
var _rules$id$text, _rules$id$text$includ;
|
|
13
23
|
return !!rules[id] && !!((_rules$id$text = rules[id].text) !== null && _rules$id$text !== void 0 && (_rules$id$text$includ = _rules$id$text.includes) !== null && _rules$id$text$includ !== void 0 && _rules$id$text$includ.call(_rules$id$text, text));
|
|
@@ -18,6 +28,9 @@ const addCss = (id, text) => {
|
|
|
18
28
|
var _rules$id;
|
|
19
29
|
rules[id] = (rules === null || rules === void 0 ? void 0 : rules[id]) || {};
|
|
20
30
|
rules[id].text = (((_rules$id = rules[id]) === null || _rules$id === void 0 ? void 0 : _rules$id.text) || '') + text;
|
|
31
|
+
if (styleSheet) {
|
|
32
|
+
styleSheet.insertRule(text, Object.keys(rules).length - 1);
|
|
33
|
+
}
|
|
21
34
|
}
|
|
22
35
|
};
|
|
23
36
|
exports.addCss = addCss;
|
|
@@ -265,21 +265,11 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
265
265
|
}, [nestedSelectedValue, items]);
|
|
266
266
|
const handleClose = event => {
|
|
267
267
|
var _openOverlayRef$curre, _openOverlayRef$curre2;
|
|
268
|
-
if (event.type === 'keydown') {
|
|
269
|
-
if (event.key === 'Escape' || event.key === 27) {
|
|
270
|
-
setIsExpanded(false);
|
|
271
|
-
setNestedSelectedValue(null);
|
|
272
|
-
} else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
273
|
-
targetRef.current.focus();
|
|
274
|
-
}
|
|
275
|
-
} else if (event.type === 'click' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target))) {
|
|
276
|
-
setIsExpanded(false);
|
|
277
|
-
} else if (event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
278
|
-
setIsExpanded(false);
|
|
279
|
-
} else if (Platform.OS === 'web') {
|
|
280
|
-
// needed for dropdown to be collapsed when clicking outside on web
|
|
268
|
+
if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target)) || event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
281
269
|
setIsExpanded(false);
|
|
282
270
|
setNestedSelectedValue(null);
|
|
271
|
+
} else if (event.type === 'keydown' && event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
272
|
+
targetRef.current.focus();
|
|
283
273
|
}
|
|
284
274
|
};
|
|
285
275
|
const itemsToShow = currentValue ? itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)) : [];
|
package/lib-module/Card/Card.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
4
5
|
import { getTokensPropType, variantProp } from '../utils';
|
|
5
6
|
import { useViewport } from '../ViewportProvider';
|
|
6
7
|
import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
|
|
7
8
|
import CardBase from './CardBase';
|
|
9
|
+
import PressableCardBase from './PressableCardBase';
|
|
8
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
13
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -62,25 +66,84 @@ const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
62
66
|
tokens,
|
|
63
67
|
variant,
|
|
64
68
|
dataSet,
|
|
69
|
+
onPress,
|
|
70
|
+
interactiveCard,
|
|
65
71
|
...rest
|
|
66
72
|
} = _ref;
|
|
67
73
|
const viewport = useViewport();
|
|
68
74
|
const themeTokens = useThemeTokens('Card', tokens, variant, {
|
|
69
75
|
viewport
|
|
70
76
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
const getThemeTokens = useThemeTokensCallback('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
|
|
78
|
+
interactive: true,
|
|
79
|
+
...((interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.variant) || {})
|
|
80
|
+
});
|
|
81
|
+
// When interactive area is present, spacing tokens should only be applied
|
|
82
|
+
// to individual Card sections, not Card as a whole
|
|
83
|
+
const {
|
|
84
|
+
paddingTop,
|
|
85
|
+
paddingBottom,
|
|
86
|
+
paddingLeft,
|
|
87
|
+
paddingRight,
|
|
88
|
+
...restOfTokens
|
|
89
|
+
} = themeTokens;
|
|
90
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
91
|
+
children: /*#__PURE__*/_jsx(CardBase, {
|
|
92
|
+
ref: ref,
|
|
93
|
+
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : themeTokens,
|
|
94
|
+
dataSet: dataSet,
|
|
95
|
+
...selectProps(rest),
|
|
96
|
+
children: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
97
|
+
children: [/*#__PURE__*/_jsx(PressableCardBase, {
|
|
98
|
+
ref: ref,
|
|
99
|
+
tokens: getThemeTokens,
|
|
100
|
+
dataSet: dataSet,
|
|
101
|
+
onPress: onPress,
|
|
102
|
+
...selectProps(rest),
|
|
103
|
+
children: interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body
|
|
104
|
+
}), children ? /*#__PURE__*/_jsx(View, {
|
|
105
|
+
style: {
|
|
106
|
+
paddingTop,
|
|
107
|
+
paddingBottom,
|
|
108
|
+
paddingLeft,
|
|
109
|
+
paddingRight
|
|
110
|
+
},
|
|
111
|
+
children: children
|
|
112
|
+
}) : null]
|
|
113
|
+
}) : children
|
|
114
|
+
})
|
|
77
115
|
});
|
|
78
116
|
});
|
|
79
117
|
Card.displayName = 'Card';
|
|
80
118
|
Card.propTypes = {
|
|
81
119
|
...selectedSystemPropTypes,
|
|
120
|
+
/**
|
|
121
|
+
* Card content.
|
|
122
|
+
*/
|
|
82
123
|
children: PropTypes.node,
|
|
124
|
+
/**
|
|
125
|
+
* Card tokens.
|
|
126
|
+
*/
|
|
83
127
|
tokens: getTokensPropType('Card'),
|
|
84
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Card variant.
|
|
130
|
+
*/
|
|
131
|
+
variant: variantProp.propType,
|
|
132
|
+
/**
|
|
133
|
+
* Function to call on pressing the card.
|
|
134
|
+
* Note: This is only available when `interactiveCard` prop is used.
|
|
135
|
+
*/
|
|
136
|
+
onPress: PropTypes.func,
|
|
137
|
+
/**
|
|
138
|
+
* Object to set interactive card's properties
|
|
139
|
+
* - body: The body of the interactive card, can be any renderable node
|
|
140
|
+
* - tokens: The tokens to be used for the interactive card
|
|
141
|
+
* - variant: The variant to be used for the interactive card
|
|
142
|
+
*/
|
|
143
|
+
interactiveCard: PropTypes.shape({
|
|
144
|
+
body: PropTypes.node,
|
|
145
|
+
tokens: getTokensPropType('Card'),
|
|
146
|
+
variant: variantProp.propType
|
|
147
|
+
})
|
|
85
148
|
};
|
|
86
149
|
export default Card;
|
|
@@ -28,6 +28,7 @@ const PressableCardBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
28
28
|
inactive,
|
|
29
29
|
href,
|
|
30
30
|
hrefAttrs,
|
|
31
|
+
dataSet,
|
|
31
32
|
accessibilityRole = href ? 'link' : undefined,
|
|
32
33
|
...rawRest
|
|
33
34
|
} = _ref;
|
|
@@ -87,6 +88,7 @@ const PressableCardBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
88
|
onKeyDown: handleKeyDown,
|
|
88
89
|
hrefAttrs: hrefAttrs,
|
|
89
90
|
style: getOuterBorderStyle,
|
|
91
|
+
dataSet: dataSet,
|
|
90
92
|
...selectProps({
|
|
91
93
|
...rest,
|
|
92
94
|
accessibilityRole
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
|
+
import { resolvePressableTokens } from '../utils/pressability';
|
|
7
|
+
import { applyShadowToken } from '../ThemeProvider';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const selectGeneralBubbleTokens = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
outerBubbleHeight,
|
|
12
|
+
outerBubbleWidth,
|
|
13
|
+
outerBubbleContentAlignItems,
|
|
14
|
+
outerBubbleJustifyContent,
|
|
15
|
+
bubbleBorderColor,
|
|
16
|
+
bubbleBorderWidth,
|
|
17
|
+
bubbleBorderRadius
|
|
18
|
+
} = _ref;
|
|
19
|
+
return {
|
|
20
|
+
height: outerBubbleHeight,
|
|
21
|
+
width: outerBubbleWidth,
|
|
22
|
+
justifyContent: outerBubbleContentAlignItems,
|
|
23
|
+
alignItems: outerBubbleJustifyContent,
|
|
24
|
+
borderColor: bubbleBorderColor,
|
|
25
|
+
borderWidth: bubbleBorderWidth,
|
|
26
|
+
borderRadius: bubbleBorderRadius,
|
|
27
|
+
...Platform.select({
|
|
28
|
+
web: {
|
|
29
|
+
outline: 'none'
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const selectInnerBubbleTokens = _ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
innerBubbleHeight,
|
|
37
|
+
innerBubbleWidth,
|
|
38
|
+
innerBubbleBorderRadius,
|
|
39
|
+
borderColor,
|
|
40
|
+
borderWidth,
|
|
41
|
+
shadow
|
|
42
|
+
} = _ref2;
|
|
43
|
+
return {
|
|
44
|
+
height: innerBubbleHeight,
|
|
45
|
+
width: innerBubbleWidth,
|
|
46
|
+
borderRadius: innerBubbleBorderRadius,
|
|
47
|
+
borderColor,
|
|
48
|
+
borderWidth,
|
|
49
|
+
...applyShadowToken(shadow)
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const selectBorderBubbleTokens = _ref3 => {
|
|
53
|
+
let {
|
|
54
|
+
bubbleBorderColor,
|
|
55
|
+
bubbleBorderWidth,
|
|
56
|
+
bubbleBorderRadius
|
|
57
|
+
} = _ref3;
|
|
58
|
+
return {
|
|
59
|
+
borderColor: bubbleBorderColor,
|
|
60
|
+
borderWidth: bubbleBorderWidth,
|
|
61
|
+
borderRadius: bubbleBorderRadius
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const ColourBubble = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
65
|
+
let {
|
|
66
|
+
tokens = {},
|
|
67
|
+
id,
|
|
68
|
+
colourHexCode,
|
|
69
|
+
colourName,
|
|
70
|
+
isSelected,
|
|
71
|
+
onPress
|
|
72
|
+
} = _ref4;
|
|
73
|
+
const defaultTokens = tokens({
|
|
74
|
+
selected: isSelected
|
|
75
|
+
});
|
|
76
|
+
const resolveColourBubbleTokens = pressState => resolvePressableTokens(tokens, pressState, {});
|
|
77
|
+
const themeTokens = useMemo(() => tokens(), [tokens]);
|
|
78
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
79
|
+
style: state => [selectGeneralBubbleTokens(resolveColourBubbleTokens(state)), isSelected && selectBorderBubbleTokens(defaultTokens)],
|
|
80
|
+
onPress: onPress,
|
|
81
|
+
accessible: true,
|
|
82
|
+
accessibilityRole: "radio",
|
|
83
|
+
accessibilityLabel: colourName,
|
|
84
|
+
accessibilityState: {
|
|
85
|
+
checked: isSelected
|
|
86
|
+
},
|
|
87
|
+
ref: ref,
|
|
88
|
+
testID: id,
|
|
89
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
90
|
+
style: [selectInnerBubbleTokens(themeTokens), {
|
|
91
|
+
backgroundColor: colourHexCode
|
|
92
|
+
}]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
ColourBubble.displayName = 'ColourBubble';
|
|
97
|
+
ColourBubble.propTypes = {
|
|
98
|
+
/**
|
|
99
|
+
* Colour toggle tokens callback.
|
|
100
|
+
*/
|
|
101
|
+
tokens: PropTypes.func,
|
|
102
|
+
/**
|
|
103
|
+
* ID of each colour bubble
|
|
104
|
+
*/
|
|
105
|
+
id: PropTypes.string,
|
|
106
|
+
/**
|
|
107
|
+
* Hexadecimal code for the background of the colour bubble
|
|
108
|
+
*/
|
|
109
|
+
colourHexCode: PropTypes.string,
|
|
110
|
+
/**
|
|
111
|
+
* Name of the colour bubble
|
|
112
|
+
*/
|
|
113
|
+
colourName: PropTypes.string,
|
|
114
|
+
/**
|
|
115
|
+
* If the current colour bubble is selected
|
|
116
|
+
*/
|
|
117
|
+
isSelected: PropTypes.bool,
|
|
118
|
+
/**
|
|
119
|
+
* If provided, this function is called when the current selection
|
|
120
|
+
* of the color is changed of all currently `items`.
|
|
121
|
+
* Receives two parameters: item object selected and the event
|
|
122
|
+
*/
|
|
123
|
+
onPress: PropTypes.func
|
|
124
|
+
};
|
|
125
|
+
export default ColourBubble;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { forwardRef, useState } from 'react';
|
|
2
|
+
import View from "react-native-web/dist/exports/View";
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
5
|
+
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
|
|
6
|
+
import { StackWrap } from '../StackView';
|
|
7
|
+
import Typography from '../Typography';
|
|
8
|
+
import ColourBubble from './ColourBubble';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
12
|
+
const ColourToggle = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
13
|
+
let {
|
|
14
|
+
tokens,
|
|
15
|
+
variant,
|
|
16
|
+
defaultColourId,
|
|
17
|
+
items,
|
|
18
|
+
onChange,
|
|
19
|
+
...rest
|
|
20
|
+
} = _ref;
|
|
21
|
+
const [currentColourId, setCurrentColourId] = useState(defaultColourId);
|
|
22
|
+
const getTokens = useThemeTokensCallback('ColourToggle', tokens, variant);
|
|
23
|
+
const {
|
|
24
|
+
space
|
|
25
|
+
} = getTokens();
|
|
26
|
+
const {
|
|
27
|
+
colourName: currentColourName = ''
|
|
28
|
+
} = items.find(item => item.id === currentColourId) || '';
|
|
29
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
30
|
+
ref: ref,
|
|
31
|
+
...selectProps(rest),
|
|
32
|
+
children: [/*#__PURE__*/_jsx(Typography, {
|
|
33
|
+
children: currentColourName
|
|
34
|
+
}), /*#__PURE__*/_jsx(StackWrap, {
|
|
35
|
+
space: space,
|
|
36
|
+
accessibilityRole: "radiogroup",
|
|
37
|
+
children: items.map((_ref2, index) => {
|
|
38
|
+
let {
|
|
39
|
+
id,
|
|
40
|
+
colourHexCode,
|
|
41
|
+
colourName
|
|
42
|
+
} = _ref2;
|
|
43
|
+
const colourBubbleId = id || `ColourBubble[${index}]`;
|
|
44
|
+
const handleChangeColour = event => {
|
|
45
|
+
setCurrentColourId(id);
|
|
46
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, {
|
|
47
|
+
id,
|
|
48
|
+
colourHexCode,
|
|
49
|
+
colourName
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/_jsx(ColourBubble, {
|
|
53
|
+
id: colourBubbleId,
|
|
54
|
+
tokens: getTokens,
|
|
55
|
+
isSelected: id === currentColourId,
|
|
56
|
+
colourHexCode: colourHexCode,
|
|
57
|
+
colourName: colourName,
|
|
58
|
+
onPress: handleChangeColour
|
|
59
|
+
}, colourBubbleId);
|
|
60
|
+
})
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
ColourToggle.displayName = 'ColourToggle';
|
|
65
|
+
ColourToggle.propTypes = {
|
|
66
|
+
...selectedSystemPropTypes,
|
|
67
|
+
/**
|
|
68
|
+
* Optional theme token overrides for the outer ColourToggle component
|
|
69
|
+
*/
|
|
70
|
+
tokens: getTokensPropType('ColourToggle'),
|
|
71
|
+
/**
|
|
72
|
+
* Colour toggle variant.
|
|
73
|
+
*/
|
|
74
|
+
variant: variantProp.propType,
|
|
75
|
+
/**
|
|
76
|
+
* Id of the selected color when component mounts
|
|
77
|
+
*/
|
|
78
|
+
defaultColourId: PropTypes.string,
|
|
79
|
+
/**
|
|
80
|
+
* Array of objects containing specifics for each ColourBubble to be rendered in the group.
|
|
81
|
+
*/
|
|
82
|
+
items: PropTypes.arrayOf(PropTypes.exact({
|
|
83
|
+
colourHexCode: PropTypes.string,
|
|
84
|
+
colourName: PropTypes.string,
|
|
85
|
+
id: PropTypes.string
|
|
86
|
+
})),
|
|
87
|
+
/**
|
|
88
|
+
* If provided, this function is called when the current selection of the color is changed of all currently `items`. Receives two parameters: item object selected and the event
|
|
89
|
+
*/
|
|
90
|
+
onChange: PropTypes.func
|
|
91
|
+
};
|
|
92
|
+
export default ColourToggle;
|