@telus-uds/components-base 1.63.0 → 1.65.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 CHANGED
@@ -1,12 +1,30 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Wed, 04 Oct 2023 18:37:04 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 26 Oct 2023 19:24:58 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.65.0
8
+
9
+ Thu, 26 Oct 2023 19:24:58 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Add `equalWidth` variant in `Tabs` (shahzaibkhalidmalik@outlook.com)
14
+ - new CheckboxCard component (mauricio.batresmontejo@telus.com)
15
+ - Bump @telus-uds/system-theme-tokens to v2.42.0
16
+
17
+ ## 1.64.0
18
+
19
+ Thu, 19 Oct 2023 00:28:36 GMT
20
+
21
+ ### Minor changes
22
+
23
+ - added new styles for public mobile premium theme button, typography, radio button, checkbox, progress, progress bar (luis.florescarpinteyro@telus.com)
24
+
7
25
  ## 1.63.0
8
26
 
9
- Wed, 04 Oct 2023 18:37:04 GMT
27
+ Wed, 04 Oct 2023 18:39:58 GMT
10
28
 
11
29
  ### Minor changes
12
30
 
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectCheckboxTokens = exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
+
14
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
+
16
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
17
+
18
+ var _CheckboxInput = _interopRequireDefault(require("./CheckboxInput"));
19
+
20
+ var _ThemeProvider = require("../ThemeProvider");
21
+
22
+ var _utils = require("../utils");
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
32
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
33
+
34
+ const selectInputStyles = (_ref, isChecked) => {
35
+ let {
36
+ iconBackgroundColor,
37
+ inputBorderColor,
38
+ inputBorderRadius,
39
+ inputBorderWidth,
40
+ inputBackgroundColor,
41
+ inputHeight,
42
+ inputOutlineColor,
43
+ inputOutlineWidth,
44
+ inputOutlineOffset,
45
+ inputShadow,
46
+ inputWidth
47
+ } = _ref;
48
+ return {
49
+ borderColor: inputBorderColor,
50
+ borderWidth: inputBorderWidth,
51
+ borderRadius: inputBorderRadius,
52
+ backgroundColor: isChecked ? iconBackgroundColor : inputBackgroundColor,
53
+ height: inputHeight,
54
+ width: inputWidth,
55
+ ...(0, _ThemeProvider.applyShadowToken)(inputShadow),
56
+ ..._Platform.default.select({
57
+ web: {
58
+ outlineStyle: 'solid',
59
+ outlineColor: inputOutlineColor,
60
+ outlineWidth: inputOutlineWidth,
61
+ outlineOffset: inputOutlineOffset
62
+ }
63
+ })
64
+ };
65
+ };
66
+
67
+ const selectIconTokens = _ref2 => {
68
+ let {
69
+ icon,
70
+ iconColor,
71
+ iconSize
72
+ } = _ref2;
73
+ return {
74
+ icon,
75
+ color: iconColor,
76
+ size: iconSize
77
+ };
78
+ };
79
+
80
+ const tokenKeys = ['checkedBackgroundColor', 'checkedSize', 'inputBackgroundColor', 'inputBorderColor', 'inputBorderWidth', 'inputOutlineColor', 'inputOutlineWidth', 'inputSize', 'outerBorderColor', 'outerBorderWidth', 'outerBorderGap', 'inputSize'];
81
+
82
+ const selectCheckboxTokens = (themeTokens, prefix) => (0, _utils.selectTokens)(tokenKeys, themeTokens, prefix);
83
+ /**
84
+ * The visual toggle of a checkbox input. Is not interactive on its own, should be used inside
85
+ * an interactive parent that passes down props when interacted with. Used in CheckboxCard
86
+ */
87
+
88
+
89
+ exports.selectCheckboxTokens = selectCheckboxTokens;
90
+ const CheckboxButton = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
91
+ let {
92
+ isChecked,
93
+ tokens,
94
+ inactive,
95
+ defaultChecked,
96
+ inputId,
97
+ iconId,
98
+ isControlled,
99
+ handleChange,
100
+ name: inputName,
101
+ value,
102
+ ...rest
103
+ } = _ref3;
104
+ const {
105
+ icon: IconComponent,
106
+ ...stateTokens
107
+ } = (0, _ThemeProvider.useThemeTokens)('Checkbox', {}, {
108
+ checked: isChecked
109
+ });
110
+ const iconTokens = selectIconTokens(stateTokens);
111
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, { ...selectProps(rest),
112
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
113
+ style: [staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)],
114
+ testID: inputId,
115
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckboxInput.default, {
116
+ ref: ref,
117
+ checked: isChecked,
118
+ defaultChecked: defaultChecked,
119
+ disabled: inactive,
120
+ id: inputId,
121
+ isControlled: isControlled,
122
+ onChange: handleChange,
123
+ name: inputName,
124
+ value: value
125
+ }), isChecked && IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
126
+ testID: iconId,
127
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, { ...iconTokens
128
+ })
129
+ })]
130
+ })
131
+ });
132
+ });
133
+ CheckboxButton.displayName = 'CheckboxButton';
134
+ CheckboxButton.propTypes = { ...selectedSystemPropTypes,
135
+
136
+ /**
137
+ * Use `checked` for controlled Checkbox. For uncontrolled Checkbox, use the `defaultChecked` prop.
138
+ */
139
+ isChecked: _propTypes.default.bool,
140
+
141
+ /**
142
+ * Checkbox tokens.
143
+ */
144
+ tokens: (0, _utils.getTokensSetPropType)(tokenKeys, {
145
+ allowFunction: true
146
+ }),
147
+
148
+ /**
149
+ * Whether the corresponding input is disabled or active.
150
+ */
151
+ inactive: _propTypes.default.bool,
152
+
153
+ /**
154
+ * Use `defaultChecked` to provide the initial value for an uncontrolled Checkbox.
155
+ */
156
+ defaultChecked: _propTypes.default.bool,
157
+
158
+ /**
159
+ * Checkbox input ID.
160
+ */
161
+ inputId: _propTypes.default.string,
162
+
163
+ /**
164
+ * Checkbox icon ID.
165
+ */
166
+ iconId: _propTypes.default.string,
167
+
168
+ /**
169
+ * Can control the checkbox on the card.
170
+ */
171
+ isControlled: _propTypes.default.bool,
172
+
173
+ /**
174
+ * Callback called when a controlled checkbox gets interacted with.
175
+ */
176
+ handleChange: _propTypes.default.func,
177
+
178
+ /**
179
+ * Associate this checkbox with a group (set as the name attribute).
180
+ */
181
+ name: _propTypes.default.string,
182
+
183
+ /**
184
+ * The value of the checkbox: true or false
185
+ */
186
+ value: _propTypes.default.bool
187
+ };
188
+ var _default = CheckboxButton;
189
+ exports.default = _default;
190
+
191
+ const staticStyles = _StyleSheet.default.create({
192
+ container: {
193
+ flexDirection: 'row',
194
+ alignItems: 'center'
195
+ },
196
+ defaultInputStyles: {
197
+ alignItems: 'center',
198
+ justifyContent: 'center'
199
+ }
200
+ });
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
13
+
14
+ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
15
+
16
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
17
+
18
+ var _ThemeProvider = require("../ThemeProvider");
19
+
20
+ var _utils = require("../utils");
21
+
22
+ var _Card = require("../Card");
23
+
24
+ var _StackView = _interopRequireDefault(require("../StackView"));
25
+
26
+ var _CheckboxButton = _interopRequireWildcard(require("../Checkbox/CheckboxButton"));
27
+
28
+ var _jsxRuntime = require("react/jsx-runtime");
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ 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); }
33
+
34
+ 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; }
35
+
36
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
37
+ const CheckboxCard = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
38
+ let {
39
+ tokens,
40
+ variant,
41
+ title,
42
+ children,
43
+ inactive,
44
+ defaultChecked,
45
+ checked,
46
+ name: inputName,
47
+ value,
48
+ id,
49
+ iconId,
50
+ onChange,
51
+ ...rest
52
+ } = _ref;
53
+ const {
54
+ currentValue: isChecked,
55
+ setValue: setIsChecked,
56
+ isControlled
57
+ } = (0, _utils.useInputValue)({
58
+ value: checked,
59
+ initialValue: defaultChecked,
60
+ onChange
61
+ });
62
+
63
+ const handleChange = event => {
64
+ if (!inactive) {
65
+ setIsChecked(!isChecked, event);
66
+ }
67
+ };
68
+
69
+ const uniqueId = (0, _utils.useUniqueId)('CheckboxCard');
70
+ const inputId = id ?? uniqueId;
71
+ const uniqueIconId = (0, _utils.useUniqueId)('CheckboxIcon');
72
+ const iconCheckboxId = iconId ?? uniqueIconId;
73
+ const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('CheckboxCard', tokens, variant);
74
+
75
+ const getCardTokens = cardState => (0, _Card.selectPressableCardTokens)(getTokens(cardState));
76
+
77
+ const {
78
+ themeOptions
79
+ } = (0, _ThemeProvider.useTheme)();
80
+ const selectedProps = selectProps({
81
+ accessibilityRole: 'checkbox',
82
+ accessibilityState: {
83
+ checked: isChecked,
84
+ disabled: inactive
85
+ },
86
+ ...rest
87
+ });
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.PressableCardBase, {
89
+ ref: ref,
90
+ inactive: inactive,
91
+ checked: isChecked,
92
+ tokens: getCardTokens,
93
+ onPress: handleChange,
94
+ ...selectedProps,
95
+ children: cardState => {
96
+ const {
97
+ checkboxSpace,
98
+ contentSpace,
99
+ ...themeTokens
100
+ } = getTokens(cardState);
101
+ const checkboxTokens = (0, _CheckboxButton.selectCheckboxTokens)(themeTokens, 'checkbox');
102
+ const titleTokens = (0, _utils.selectTokens)('Typography', themeTokens);
103
+ const textStyle = (0, _ThemeProvider.applyTextStyles)({ ...titleTokens,
104
+ themeOptions
105
+ });
106
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
107
+ direction: "row",
108
+ space: checkboxSpace,
109
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
110
+ style: [staticStyles.alignWithText, {
111
+ height: textStyle.lineHeight
112
+ }],
113
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckboxButton.default, {
114
+ tokens: checkboxTokens,
115
+ isControlled: isControlled,
116
+ isChecked: isChecked,
117
+ inactive: inactive,
118
+ defaultChecked: defaultChecked,
119
+ inputId: inputId,
120
+ iconId: iconCheckboxId,
121
+ handleChange: handleChange,
122
+ name: inputName,
123
+ value: value
124
+ })
125
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
126
+ direction: "column",
127
+ space: contentSpace,
128
+ tokens: {
129
+ flexShrink: 1
130
+ },
131
+ children: [title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
132
+ style: textStyle,
133
+ children: title
134
+ }) : null, typeof children === 'function' ? children(cardState, textStyle) : children]
135
+ })]
136
+ });
137
+ }
138
+ });
139
+ });
140
+ CheckboxCard.displayName = 'CheckboxCard';
141
+ CheckboxCard.propTypes = { ...selectedSystemPropTypes,
142
+
143
+ /**
144
+ * Content to be displayed at the top of the card alongside the checkbox
145
+ */
146
+ title: _propTypes.default.string,
147
+
148
+ /**
149
+ * Additional content to be displayed below the checkbox.
150
+ */
151
+ children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
152
+
153
+ /**
154
+ * Use `checked` for controlled checkbox. For uncontrolled checkbox, use the `defaultChecked` prop.
155
+ */
156
+ checked: _propTypes.default.bool,
157
+
158
+ /**
159
+ * Use `defaultChecked` to provide the initial value for an uncontrolled checkbox.
160
+ */
161
+ defaultChecked: _propTypes.default.bool,
162
+
163
+ /**
164
+ * An optional checkboxdescription.
165
+ */
166
+ description: _propTypes.default.string,
167
+
168
+ /**
169
+ * Checkbox card ID.
170
+ */
171
+ id: _propTypes.default.string,
172
+
173
+ /**
174
+ * Checkbox icon ID.
175
+ */
176
+ iconId: _propTypes.default.string,
177
+
178
+ /**
179
+ * Whether the corresponding input is disabled or active.
180
+ */
181
+ inactive: _propTypes.default.bool,
182
+
183
+ /**
184
+ * The label.
185
+ */
186
+ label: _propTypes.default.string,
187
+
188
+ /**
189
+ * Associate this checkbox card with a group (set as the name attribute).
190
+ */
191
+ name: _propTypes.default.string,
192
+
193
+ /**
194
+ * Whether the underlying input triggered a validation error or not.
195
+ */
196
+ error: _propTypes.default.bool,
197
+
198
+ /**
199
+ * The value. Must be unique within the group.
200
+ */
201
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool]),
202
+
203
+ /**
204
+ * Callback called when a controlled checkbox card gets interacted with.
205
+ */
206
+ onChange: _propTypes.default.func,
207
+
208
+ /**
209
+ * checkbox card tokens.
210
+ */
211
+ tokens: (0, _utils.getTokensPropType)('CheckboxCard'),
212
+
213
+ /**
214
+ * checkbox variant.
215
+ */
216
+ variant: _utils.variantProp.propType
217
+ };
218
+ var _default = CheckboxCard;
219
+ exports.default = _default;
220
+
221
+ const staticStyles = _StyleSheet.default.create({
222
+ alignWithText: {
223
+ justifyContent: 'center'
224
+ }
225
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _CheckboxCard = _interopRequireDefault(require("./CheckboxCard"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _CheckboxCard.default;
13
+ exports.default = _default;
@@ -103,10 +103,13 @@ const StackView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
103
103
  viewport
104
104
  });
105
105
  const flexStyles = (0, _common.selectFlexStyles)(themeTokens);
106
+ const size = {
107
+ width: themeTokens.width
108
+ };
106
109
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
107
110
  ref: ref,
108
111
  ...selectedProps,
109
- style: [flexStyles, _common.staticStyles[direction]],
112
+ style: [flexStyles, _common.staticStyles[direction], size],
110
113
  children: content
111
114
  });
112
115
  });
package/lib/Tabs/Tabs.js CHANGED
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+
10
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
13
 
12
14
  var _airbnbPropTypes = _interopRequireDefault(require("airbnb-prop-types"));
@@ -48,6 +50,17 @@ const getDefaultTabItemAccessibilityRole = parentRole => {
48
50
  return undefined;
49
51
  }
50
52
  };
53
+
54
+ const getStackViewTokens = variant => {
55
+ const equalWidth = variant === null || variant === void 0 ? void 0 : variant.equalWidth;
56
+ return _Platform.default.select({
57
+ web: {
58
+ justifyContent: equalWidth ? 'space-evenly' : 'flex-start',
59
+ width: equalWidth ? '100%' : 'auto'
60
+ },
61
+ default: {}
62
+ });
63
+ };
51
64
  /**
52
65
  * Tabs renders a horizontally-scrolling menu of selectable buttons which may link
53
66
  * to a page or control what content is displayed on this page.
@@ -98,6 +111,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
98
111
  const restProps = selectProps(rest);
99
112
  const parentAccessibilityRole = restProps.accessibilityRole ?? 'tablist';
100
113
  const defaultTabItemAccessibiltyRole = getDefaultTabItemAccessibilityRole(parentAccessibilityRole);
114
+ const stackViewTokens = getStackViewTokens(variant);
101
115
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HorizontalScroll.default, {
102
116
  ref: ref,
103
117
  ScrollButton: _HorizontalScroll.HorizontalScrollButton,
@@ -109,6 +123,7 @@ const Tabs = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
109
123
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
110
124
  space: space,
111
125
  direction: "row",
126
+ tokens: stackViewTokens,
112
127
  children: items.map((_ref3, index) => {
113
128
  let {
114
129
  href,
package/lib/index.js CHANGED
@@ -12,6 +12,7 @@ var _exportNames = {
12
12
  PressableCardBase: true,
13
13
  Listbox: true,
14
14
  Checkbox: true,
15
+ CheckboxCard: true,
15
16
  Divider: true,
16
17
  ExpandCollapse: true,
17
18
  Accordion: true,
@@ -123,6 +124,12 @@ Object.defineProperty(exports, "Checkbox", {
123
124
  return _Checkbox.default;
124
125
  }
125
126
  });
127
+ Object.defineProperty(exports, "CheckboxCard", {
128
+ enumerable: true,
129
+ get: function () {
130
+ return _CheckboxCard.default;
131
+ }
132
+ });
126
133
  Object.defineProperty(exports, "Divider", {
127
134
  enumerable: true,
128
135
  get: function () {
@@ -508,6 +515,8 @@ Object.keys(_Checkbox).forEach(function (key) {
508
515
  });
509
516
  });
510
517
 
518
+ var _CheckboxCard = _interopRequireDefault(require("./CheckboxCard"));
519
+
511
520
  var _Divider = _interopRequireDefault(require("./Divider"));
512
521
 
513
522
  var _ExpandCollapse = _interopRequireWildcard(require("./ExpandCollapse"));