@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/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 13 Dec 2023 21:13:56 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.72.0
|
|
8
|
+
|
|
9
|
+
Wed, 13 Dec 2023 21:13:56 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- refactor ordered-list for multiplatform (guillermo.peitzner@telus.com)
|
|
14
|
+
- copy over mta type files to components base (evander.owusu@telus.com)
|
|
15
|
+
- new Colourtoggle component (mauricio.batresmontejo@telus.com)
|
|
16
|
+
- Bump @telus-uds/system-theme-tokens to v2.48.0
|
|
17
|
+
|
|
18
|
+
### Patches
|
|
19
|
+
|
|
20
|
+
- change to rnmq approach so rnw is not needed as dep for RN (srikanthkhari@gmail.com)
|
|
21
|
+
- adding viewport for consulting tokens (mauricio.batresmontejo@telus.com)
|
|
22
|
+
- fix modal content (mauricio.batresmontejo@telus.com)
|
|
23
|
+
|
|
24
|
+
## 1.71.0
|
|
25
|
+
|
|
26
|
+
Fri, 01 Dec 2023 21:08:36 GMT
|
|
27
|
+
|
|
28
|
+
### Minor changes
|
|
29
|
+
|
|
30
|
+
- `Card`: Add interactive section (shahzaibkhalidmalik@outlook.com)
|
|
31
|
+
- changes in handleClose method in autocomplete to fix the selection of suggestions in mobile browsers (35577399+JoshHC@users.noreply.github.com)
|
|
32
|
+
- add logic to linkbase to allow items to be center aligned (evander.owusu@telus.com)
|
|
33
|
+
- Bump @telus-uds/system-theme-tokens to v2.47.0
|
|
34
|
+
|
|
7
35
|
## 1.70.0
|
|
8
36
|
|
|
9
|
-
Mon, 27 Nov 2023 21:
|
|
37
|
+
Mon, 27 Nov 2023 21:20:44 GMT
|
|
10
38
|
|
|
11
39
|
### Minor changes
|
|
12
40
|
|
package/jest.setup.js
ADDED
|
@@ -273,21 +273,11 @@ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
273
273
|
}, [nestedSelectedValue, items]);
|
|
274
274
|
const handleClose = event => {
|
|
275
275
|
var _openOverlayRef$curre, _openOverlayRef$curre2;
|
|
276
|
-
if (event.type === 'keydown') {
|
|
277
|
-
if (event.key === 'Escape' || event.key === 27) {
|
|
278
|
-
setIsExpanded(false);
|
|
279
|
-
setNestedSelectedValue(null);
|
|
280
|
-
} else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
281
|
-
targetRef.current.focus();
|
|
282
|
-
}
|
|
283
|
-
} 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))) {
|
|
284
|
-
setIsExpanded(false);
|
|
285
|
-
} 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))) {
|
|
286
|
-
setIsExpanded(false);
|
|
287
|
-
} else if (_Platform.default.OS === 'web') {
|
|
288
|
-
// needed for dropdown to be collapsed when clicking outside on web
|
|
276
|
+
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))) {
|
|
289
277
|
setIsExpanded(false);
|
|
290
278
|
setNestedSelectedValue(null);
|
|
279
|
+
} else if (event.type === 'keydown' && event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
|
|
280
|
+
targetRef.current.focus();
|
|
291
281
|
}
|
|
292
282
|
};
|
|
293
283
|
const itemsToShow = currentValue ? itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)) : [];
|
package/lib/Card/Card.js
CHANGED
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
9
10
|
var _ThemeProvider = require("../ThemeProvider");
|
|
10
11
|
var _utils = require("../utils");
|
|
11
12
|
var _ViewportProvider = require("../ViewportProvider");
|
|
12
13
|
var _props = require("../utils/props");
|
|
13
14
|
var _CardBase = _interopRequireDefault(require("./CardBase"));
|
|
15
|
+
var _PressableCardBase = _interopRequireDefault(require("./PressableCardBase"));
|
|
14
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
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); }
|
|
@@ -71,26 +73,85 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
71
73
|
tokens,
|
|
72
74
|
variant,
|
|
73
75
|
dataSet,
|
|
76
|
+
onPress,
|
|
77
|
+
interactiveCard,
|
|
74
78
|
...rest
|
|
75
79
|
} = _ref;
|
|
76
80
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
77
81
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Card', tokens, variant, {
|
|
78
82
|
viewport
|
|
79
83
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
|
|
85
|
+
interactive: true,
|
|
86
|
+
...((interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.variant) || {})
|
|
87
|
+
});
|
|
88
|
+
// When interactive area is present, spacing tokens should only be applied
|
|
89
|
+
// to individual Card sections, not Card as a whole
|
|
90
|
+
const {
|
|
91
|
+
paddingTop,
|
|
92
|
+
paddingBottom,
|
|
93
|
+
paddingLeft,
|
|
94
|
+
paddingRight,
|
|
95
|
+
...restOfTokens
|
|
96
|
+
} = themeTokens;
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
98
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardBase.default, {
|
|
99
|
+
ref: ref,
|
|
100
|
+
tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : themeTokens,
|
|
101
|
+
dataSet: dataSet,
|
|
102
|
+
...selectProps(rest),
|
|
103
|
+
children: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
104
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableCardBase.default, {
|
|
105
|
+
ref: ref,
|
|
106
|
+
tokens: getThemeTokens,
|
|
107
|
+
dataSet: dataSet,
|
|
108
|
+
onPress: onPress,
|
|
109
|
+
...selectProps(rest),
|
|
110
|
+
children: interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body
|
|
111
|
+
}), children ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
112
|
+
style: {
|
|
113
|
+
paddingTop,
|
|
114
|
+
paddingBottom,
|
|
115
|
+
paddingLeft,
|
|
116
|
+
paddingRight
|
|
117
|
+
},
|
|
118
|
+
children: children
|
|
119
|
+
}) : null]
|
|
120
|
+
}) : children
|
|
121
|
+
})
|
|
86
122
|
});
|
|
87
123
|
});
|
|
88
124
|
Card.displayName = 'Card';
|
|
89
125
|
Card.propTypes = {
|
|
90
126
|
...selectedSystemPropTypes,
|
|
127
|
+
/**
|
|
128
|
+
* Card content.
|
|
129
|
+
*/
|
|
91
130
|
children: _propTypes.default.node,
|
|
131
|
+
/**
|
|
132
|
+
* Card tokens.
|
|
133
|
+
*/
|
|
92
134
|
tokens: (0, _utils.getTokensPropType)('Card'),
|
|
93
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Card variant.
|
|
137
|
+
*/
|
|
138
|
+
variant: _utils.variantProp.propType,
|
|
139
|
+
/**
|
|
140
|
+
* Function to call on pressing the card.
|
|
141
|
+
* Note: This is only available when `interactiveCard` prop is used.
|
|
142
|
+
*/
|
|
143
|
+
onPress: _propTypes.default.func,
|
|
144
|
+
/**
|
|
145
|
+
* Object to set interactive card's properties
|
|
146
|
+
* - body: The body of the interactive card, can be any renderable node
|
|
147
|
+
* - tokens: The tokens to be used for the interactive card
|
|
148
|
+
* - variant: The variant to be used for the interactive card
|
|
149
|
+
*/
|
|
150
|
+
interactiveCard: _propTypes.default.shape({
|
|
151
|
+
body: _propTypes.default.node,
|
|
152
|
+
tokens: (0, _utils.getTokensPropType)('Card'),
|
|
153
|
+
variant: _utils.variantProp.propType
|
|
154
|
+
})
|
|
94
155
|
};
|
|
95
156
|
var _default = Card;
|
|
96
157
|
exports.default = _default;
|
|
@@ -38,6 +38,7 @@ const PressableCardBase = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
38
38
|
inactive,
|
|
39
39
|
href,
|
|
40
40
|
hrefAttrs,
|
|
41
|
+
dataSet,
|
|
41
42
|
accessibilityRole = href ? 'link' : undefined,
|
|
42
43
|
...rawRest
|
|
43
44
|
} = _ref;
|
|
@@ -97,6 +98,7 @@ const PressableCardBase = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
97
98
|
onKeyDown: handleKeyDown,
|
|
98
99
|
hrefAttrs: hrefAttrs,
|
|
99
100
|
style: getOuterBorderStyle,
|
|
101
|
+
dataSet: dataSet,
|
|
100
102
|
...selectProps({
|
|
101
103
|
...rest,
|
|
102
104
|
accessibilityRole
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
11
|
+
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
12
|
+
var _pressability = require("../utils/pressability");
|
|
13
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
const selectGeneralBubbleTokens = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
outerBubbleHeight,
|
|
21
|
+
outerBubbleWidth,
|
|
22
|
+
outerBubbleContentAlignItems,
|
|
23
|
+
outerBubbleJustifyContent,
|
|
24
|
+
bubbleBorderColor,
|
|
25
|
+
bubbleBorderWidth,
|
|
26
|
+
bubbleBorderRadius
|
|
27
|
+
} = _ref;
|
|
28
|
+
return {
|
|
29
|
+
height: outerBubbleHeight,
|
|
30
|
+
width: outerBubbleWidth,
|
|
31
|
+
justifyContent: outerBubbleContentAlignItems,
|
|
32
|
+
alignItems: outerBubbleJustifyContent,
|
|
33
|
+
borderColor: bubbleBorderColor,
|
|
34
|
+
borderWidth: bubbleBorderWidth,
|
|
35
|
+
borderRadius: bubbleBorderRadius,
|
|
36
|
+
..._Platform.default.select({
|
|
37
|
+
web: {
|
|
38
|
+
outline: 'none'
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const selectInnerBubbleTokens = _ref2 => {
|
|
44
|
+
let {
|
|
45
|
+
innerBubbleHeight,
|
|
46
|
+
innerBubbleWidth,
|
|
47
|
+
innerBubbleBorderRadius,
|
|
48
|
+
borderColor,
|
|
49
|
+
borderWidth,
|
|
50
|
+
shadow
|
|
51
|
+
} = _ref2;
|
|
52
|
+
return {
|
|
53
|
+
height: innerBubbleHeight,
|
|
54
|
+
width: innerBubbleWidth,
|
|
55
|
+
borderRadius: innerBubbleBorderRadius,
|
|
56
|
+
borderColor,
|
|
57
|
+
borderWidth,
|
|
58
|
+
...(0, _ThemeProvider.applyShadowToken)(shadow)
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const selectBorderBubbleTokens = _ref3 => {
|
|
62
|
+
let {
|
|
63
|
+
bubbleBorderColor,
|
|
64
|
+
bubbleBorderWidth,
|
|
65
|
+
bubbleBorderRadius
|
|
66
|
+
} = _ref3;
|
|
67
|
+
return {
|
|
68
|
+
borderColor: bubbleBorderColor,
|
|
69
|
+
borderWidth: bubbleBorderWidth,
|
|
70
|
+
borderRadius: bubbleBorderRadius
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const ColourBubble = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
74
|
+
let {
|
|
75
|
+
tokens = {},
|
|
76
|
+
id,
|
|
77
|
+
colourHexCode,
|
|
78
|
+
colourName,
|
|
79
|
+
isSelected,
|
|
80
|
+
onPress
|
|
81
|
+
} = _ref4;
|
|
82
|
+
const defaultTokens = tokens({
|
|
83
|
+
selected: isSelected
|
|
84
|
+
});
|
|
85
|
+
const resolveColourBubbleTokens = pressState => (0, _pressability.resolvePressableTokens)(tokens, pressState, {});
|
|
86
|
+
const themeTokens = (0, _react.useMemo)(() => tokens(), [tokens]);
|
|
87
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
88
|
+
style: state => [selectGeneralBubbleTokens(resolveColourBubbleTokens(state)), isSelected && selectBorderBubbleTokens(defaultTokens)],
|
|
89
|
+
onPress: onPress,
|
|
90
|
+
accessible: true,
|
|
91
|
+
accessibilityRole: "radio",
|
|
92
|
+
accessibilityLabel: colourName,
|
|
93
|
+
accessibilityState: {
|
|
94
|
+
checked: isSelected
|
|
95
|
+
},
|
|
96
|
+
ref: ref,
|
|
97
|
+
testID: id,
|
|
98
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
99
|
+
style: [selectInnerBubbleTokens(themeTokens), {
|
|
100
|
+
backgroundColor: colourHexCode
|
|
101
|
+
}]
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
ColourBubble.displayName = 'ColourBubble';
|
|
106
|
+
ColourBubble.propTypes = {
|
|
107
|
+
/**
|
|
108
|
+
* Colour toggle tokens callback.
|
|
109
|
+
*/
|
|
110
|
+
tokens: _propTypes.default.func,
|
|
111
|
+
/**
|
|
112
|
+
* ID of each colour bubble
|
|
113
|
+
*/
|
|
114
|
+
id: _propTypes.default.string,
|
|
115
|
+
/**
|
|
116
|
+
* Hexadecimal code for the background of the colour bubble
|
|
117
|
+
*/
|
|
118
|
+
colourHexCode: _propTypes.default.string,
|
|
119
|
+
/**
|
|
120
|
+
* Name of the colour bubble
|
|
121
|
+
*/
|
|
122
|
+
colourName: _propTypes.default.string,
|
|
123
|
+
/**
|
|
124
|
+
* If the current colour bubble is selected
|
|
125
|
+
*/
|
|
126
|
+
isSelected: _propTypes.default.bool,
|
|
127
|
+
/**
|
|
128
|
+
* If provided, this function is called when the current selection
|
|
129
|
+
* of the color is changed of all currently `items`.
|
|
130
|
+
* Receives two parameters: item object selected and the event
|
|
131
|
+
*/
|
|
132
|
+
onPress: _propTypes.default.func
|
|
133
|
+
};
|
|
134
|
+
var _default = ColourBubble;
|
|
135
|
+
exports.default = _default;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _ThemeProvider = require("../ThemeProvider");
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
var _StackView = require("../StackView");
|
|
13
|
+
var _Typography = _interopRequireDefault(require("../Typography"));
|
|
14
|
+
var _ColourBubble = _interopRequireDefault(require("./ColourBubble"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
18
|
+
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; }
|
|
19
|
+
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
20
|
+
const ColourToggle = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
21
|
+
let {
|
|
22
|
+
tokens,
|
|
23
|
+
variant,
|
|
24
|
+
defaultColourId,
|
|
25
|
+
items,
|
|
26
|
+
onChange,
|
|
27
|
+
...rest
|
|
28
|
+
} = _ref;
|
|
29
|
+
const [currentColourId, setCurrentColourId] = (0, _react.useState)(defaultColourId);
|
|
30
|
+
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ColourToggle', tokens, variant);
|
|
31
|
+
const {
|
|
32
|
+
space
|
|
33
|
+
} = getTokens();
|
|
34
|
+
const {
|
|
35
|
+
colourName: currentColourName = ''
|
|
36
|
+
} = items.find(item => item.id === currentColourId) || '';
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
38
|
+
ref: ref,
|
|
39
|
+
...selectProps(rest),
|
|
40
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
41
|
+
children: currentColourName
|
|
42
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
|
|
43
|
+
space: space,
|
|
44
|
+
accessibilityRole: "radiogroup",
|
|
45
|
+
children: items.map((_ref2, index) => {
|
|
46
|
+
let {
|
|
47
|
+
id,
|
|
48
|
+
colourHexCode,
|
|
49
|
+
colourName
|
|
50
|
+
} = _ref2;
|
|
51
|
+
const colourBubbleId = id || `ColourBubble[${index}]`;
|
|
52
|
+
const handleChangeColour = event => {
|
|
53
|
+
setCurrentColourId(id);
|
|
54
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event, {
|
|
55
|
+
id,
|
|
56
|
+
colourHexCode,
|
|
57
|
+
colourName
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColourBubble.default, {
|
|
61
|
+
id: colourBubbleId,
|
|
62
|
+
tokens: getTokens,
|
|
63
|
+
isSelected: id === currentColourId,
|
|
64
|
+
colourHexCode: colourHexCode,
|
|
65
|
+
colourName: colourName,
|
|
66
|
+
onPress: handleChangeColour
|
|
67
|
+
}, colourBubbleId);
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
ColourToggle.displayName = 'ColourToggle';
|
|
73
|
+
ColourToggle.propTypes = {
|
|
74
|
+
...selectedSystemPropTypes,
|
|
75
|
+
/**
|
|
76
|
+
* Optional theme token overrides for the outer ColourToggle component
|
|
77
|
+
*/
|
|
78
|
+
tokens: (0, _utils.getTokensPropType)('ColourToggle'),
|
|
79
|
+
/**
|
|
80
|
+
* Colour toggle variant.
|
|
81
|
+
*/
|
|
82
|
+
variant: _utils.variantProp.propType,
|
|
83
|
+
/**
|
|
84
|
+
* Id of the selected color when component mounts
|
|
85
|
+
*/
|
|
86
|
+
defaultColourId: _propTypes.default.string,
|
|
87
|
+
/**
|
|
88
|
+
* Array of objects containing specifics for each ColourBubble to be rendered in the group.
|
|
89
|
+
*/
|
|
90
|
+
items: _propTypes.default.arrayOf(_propTypes.default.exact({
|
|
91
|
+
colourHexCode: _propTypes.default.string,
|
|
92
|
+
colourName: _propTypes.default.string,
|
|
93
|
+
id: _propTypes.default.string
|
|
94
|
+
})),
|
|
95
|
+
/**
|
|
96
|
+
* 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
|
|
97
|
+
*/
|
|
98
|
+
onChange: _propTypes.default.func
|
|
99
|
+
};
|
|
100
|
+
var _default = ColourToggle;
|
|
101
|
+
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 _ColourToggle = _interopRequireDefault(require("./ColourToggle"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _ColourToggle.default;
|
|
10
|
+
exports.default = _default;
|
package/lib/FlexGrid/Col/Col.js
CHANGED
|
@@ -7,10 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
10
|
-
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
|
-
var _systemConstants = require("@telus-uds/system-constants");
|
|
12
10
|
var _GutterContext = _interopRequireDefault(require("../providers/GutterContext"));
|
|
13
|
-
var _ViewportProvider = require("../../ViewportProvider");
|
|
14
11
|
var _helpers = _interopRequireDefault(require("../helpers"));
|
|
15
12
|
var _utils = require("../../utils");
|
|
16
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -35,7 +32,6 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
35
32
|
...viewProps
|
|
36
33
|
} = _ref;
|
|
37
34
|
const gutter = (0, _react.useContext)(_GutterContext.default);
|
|
38
|
-
const viewPort = (0, _ViewportProvider.useViewport)();
|
|
39
35
|
const hiddenLevels = (0, _helpers.default)([xs, sm, md, lg, xl]);
|
|
40
36
|
const getHorizontalAlignLevel = () => {
|
|
41
37
|
if (typeof horizontalAlign === 'object') {
|
|
@@ -76,60 +72,11 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
76
72
|
}
|
|
77
73
|
return {};
|
|
78
74
|
};
|
|
79
|
-
const sizeStyles = sizes => {
|
|
80
|
-
const currViewport = Object.keys(sizes).find(key => key.startsWith(viewPort));
|
|
81
|
-
const currSize = sizes[currViewport];
|
|
82
|
-
return {
|
|
83
|
-
...calculateWidth(currSize)
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const offsetStyles = offsets => {
|
|
87
|
-
const currViewport = Object.keys(offsets).find(key => key.startsWith(viewPort));
|
|
88
|
-
const currOffset = offsets[currViewport];
|
|
89
|
-
return {
|
|
90
|
-
...calculateOffset(currOffset)
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
const gutterPadding = {
|
|
94
|
-
paddingLeft: gutter ? 16 : 0,
|
|
95
|
-
paddingRight: gutter ? 16 : 0
|
|
96
|
-
};
|
|
97
|
-
let hidingStyles = {};
|
|
98
75
|
|
|
99
76
|
// TODO: consider setting this to always 'flex' in a major release.
|
|
100
77
|
// `display: block` is invalid in native apps.
|
|
101
78
|
// See https://telusdigital.atlassian.net/browse/UDS1-92
|
|
102
79
|
const shown = !flex && _Platform.default.OS === 'web' ? 'block' : 'flex';
|
|
103
|
-
if (viewPort === _systemConstants.viewports.xs) {
|
|
104
|
-
hidingStyles = {
|
|
105
|
-
display: hiddenLevels[0] === 0 ? 'none' : shown,
|
|
106
|
-
textAlign: horizontalAlignLevel[0]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
if (viewPort === _systemConstants.viewports.sm) {
|
|
110
|
-
hidingStyles = {
|
|
111
|
-
display: hiddenLevels[1] === 0 ? 'none' : shown,
|
|
112
|
-
textAlign: horizontalAlignLevel[1]
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
if (viewPort === _systemConstants.viewports.md) {
|
|
116
|
-
hidingStyles = {
|
|
117
|
-
display: hiddenLevels[2] === 0 ? 'none' : shown,
|
|
118
|
-
textAlign: horizontalAlignLevel[2]
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (viewPort === _systemConstants.viewports.lg) {
|
|
122
|
-
hidingStyles = {
|
|
123
|
-
display: hiddenLevels[3] === 0 ? 'none' : shown,
|
|
124
|
-
textAlign: horizontalAlignLevel[3]
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
if (viewPort === _systemConstants.viewports.xl) {
|
|
128
|
-
hidingStyles = {
|
|
129
|
-
display: hiddenLevels[4] === 0 ? 'none' : shown,
|
|
130
|
-
textAlign: horizontalAlignLevel[4]
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
80
|
const sizesArray = [xs, sm, md, lg, xl];
|
|
134
81
|
const offSetsArray = [xsOffset, smOffset, mdOffset, lgOffset, xlOffset];
|
|
135
82
|
const sizesWithIheritance = (0, _helpers.default)(sizesArray);
|
|
@@ -148,24 +95,63 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
148
95
|
lg: offsetsWithIheritance[3],
|
|
149
96
|
xl: offsetsWithIheritance[4]
|
|
150
97
|
};
|
|
98
|
+
const mediaQueryStyles = (0, _utils.createMediaQueryStyles)({
|
|
99
|
+
xs: {
|
|
100
|
+
display: hiddenLevels[0] === 0 ? 'none' : shown,
|
|
101
|
+
textAlign: horizontalAlignLevel[0],
|
|
102
|
+
...calculateWidth(sizes.xs),
|
|
103
|
+
...calculateOffset(offsets.xs)
|
|
104
|
+
},
|
|
105
|
+
sm: {
|
|
106
|
+
display: hiddenLevels[1] === 0 ? 'none' : shown,
|
|
107
|
+
textAlign: horizontalAlignLevel[1],
|
|
108
|
+
...calculateWidth(sizes.sm),
|
|
109
|
+
...calculateOffset(offsets.sm)
|
|
110
|
+
},
|
|
111
|
+
md: {
|
|
112
|
+
display: hiddenLevels[2] === 0 ? 'none' : shown,
|
|
113
|
+
textAlign: horizontalAlignLevel[2],
|
|
114
|
+
...calculateWidth(sizes.md),
|
|
115
|
+
...calculateOffset(offsets.md)
|
|
116
|
+
},
|
|
117
|
+
lg: {
|
|
118
|
+
display: hiddenLevels[3] === 0 ? 'none' : shown,
|
|
119
|
+
textAlign: horizontalAlignLevel[3],
|
|
120
|
+
...calculateWidth(sizes.lg),
|
|
121
|
+
...calculateOffset(offsets.lg)
|
|
122
|
+
},
|
|
123
|
+
xl: {
|
|
124
|
+
display: hiddenLevels[4] === 0 ? 'none' : shown,
|
|
125
|
+
textAlign: horizontalAlignLevel[4],
|
|
126
|
+
...calculateWidth(sizes.xl),
|
|
127
|
+
...calculateOffset(offsets.xl)
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const {
|
|
131
|
+
ids,
|
|
132
|
+
styles
|
|
133
|
+
} = _utils.StyleSheet.create({
|
|
134
|
+
col: {
|
|
135
|
+
flexGrow: 1,
|
|
136
|
+
flexShrink: 0,
|
|
137
|
+
flexBasis: 'auto',
|
|
138
|
+
maxWidth: '100%',
|
|
139
|
+
paddingLeft: gutter ? 16 : 0,
|
|
140
|
+
paddingRight: gutter ? 16 : 0,
|
|
141
|
+
...mediaQueryStyles
|
|
142
|
+
}
|
|
143
|
+
});
|
|
151
144
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_utils.BaseView, {
|
|
152
145
|
ref: ref,
|
|
153
146
|
...viewProps,
|
|
154
|
-
style: [styles.col,
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
style: [styles.col],
|
|
148
|
+
dataSet: {
|
|
149
|
+
media: ids.col
|
|
150
|
+
},
|
|
157
151
|
children: children
|
|
158
152
|
});
|
|
159
153
|
});
|
|
160
154
|
Col.displayName = 'Col';
|
|
161
|
-
const styles = _StyleSheet.default.create({
|
|
162
|
-
col: {
|
|
163
|
-
flexGrow: 1,
|
|
164
|
-
flexShrink: 0,
|
|
165
|
-
flexBasis: 'auto',
|
|
166
|
-
maxWidth: '100%'
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
155
|
|
|
170
156
|
/*
|
|
171
157
|
* We're disabling default props since passing undefined props to
|