@telus-uds/components-base 1.3.1 → 1.6.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.
Files changed (105) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/.turbo/turbo-lint.log +13 -0
  3. package/CHANGELOG.json +142 -1
  4. package/CHANGELOG.md +51 -2
  5. package/__tests__/FlexGrid/Row.test.jsx +100 -25
  6. package/__tests__/utils/containUniqueFields.test.js +25 -0
  7. package/component-docs.json +50 -15
  8. package/lib/Button/ButtonBase.js +1 -1
  9. package/lib/Button/ButtonGroup.js +20 -12
  10. package/lib/Card/PressableCardBase.js +1 -1
  11. package/lib/Checkbox/Checkbox.js +27 -16
  12. package/lib/Checkbox/CheckboxGroup.js +19 -5
  13. package/lib/ExpandCollapse/Panel.js +10 -10
  14. package/lib/FlexGrid/Col/Col.js +13 -3
  15. package/lib/FlexGrid/Row/Row.js +8 -2
  16. package/lib/HorizontalScroll/HorizontalScroll.js +0 -1
  17. package/lib/HorizontalScroll/HorizontalScrollButton.js +23 -49
  18. package/lib/InputLabel/InputLabel.js +27 -25
  19. package/lib/Link/LinkBase.js +19 -6
  20. package/lib/Modal/Modal.js +18 -18
  21. package/lib/Notification/Notification.js +5 -6
  22. package/lib/Radio/Radio.js +23 -12
  23. package/lib/Radio/RadioGroup.js +12 -3
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +11 -2
  26. package/lib/Select/Select.js +2 -3
  27. package/lib/Tags/Tags.js +23 -17
  28. package/lib/TextInput/TextArea.js +2 -2
  29. package/lib/TextInput/TextInput.js +12 -2
  30. package/lib/TextInput/TextInputBase.js +1 -1
  31. package/lib/TextInput/propTypes.js +8 -1
  32. package/lib/ToggleSwitch/ToggleSwitch.js +5 -2
  33. package/lib/ToggleSwitch/ToggleSwitchGroup.js +20 -12
  34. package/lib/utils/containUniqueFields.js +34 -0
  35. package/lib/utils/index.js +10 -1
  36. package/lib/utils/props/handlerProps.js +72 -0
  37. package/lib/utils/props/index.js +14 -0
  38. package/lib/utils/props/inputSupportsProps.js +3 -5
  39. package/lib-module/Button/ButtonBase.js +2 -2
  40. package/lib-module/Button/ButtonGroup.js +15 -6
  41. package/lib-module/Card/PressableCardBase.js +2 -2
  42. package/lib-module/Checkbox/Checkbox.js +28 -17
  43. package/lib-module/Checkbox/CheckboxGroup.js +20 -7
  44. package/lib-module/ExpandCollapse/Panel.js +10 -10
  45. package/lib-module/FlexGrid/Col/Col.js +13 -3
  46. package/lib-module/FlexGrid/Row/Row.js +8 -2
  47. package/lib-module/HorizontalScroll/HorizontalScroll.js +0 -1
  48. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +24 -49
  49. package/lib-module/InputLabel/InputLabel.js +28 -25
  50. package/lib-module/Link/LinkBase.js +19 -6
  51. package/lib-module/Modal/Modal.js +19 -19
  52. package/lib-module/Notification/Notification.js +6 -6
  53. package/lib-module/Radio/Radio.js +24 -13
  54. package/lib-module/Radio/RadioGroup.js +13 -4
  55. package/lib-module/RadioCard/RadioCard.js +2 -2
  56. package/lib-module/RadioCard/RadioCardGroup.js +12 -3
  57. package/lib-module/Select/Select.js +2 -3
  58. package/lib-module/Tags/Tags.js +18 -11
  59. package/lib-module/TextInput/TextArea.js +3 -3
  60. package/lib-module/TextInput/TextInput.js +11 -3
  61. package/lib-module/TextInput/TextInputBase.js +2 -2
  62. package/lib-module/TextInput/propTypes.js +7 -1
  63. package/lib-module/ToggleSwitch/ToggleSwitch.js +6 -3
  64. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +15 -6
  65. package/lib-module/utils/containUniqueFields.js +26 -0
  66. package/lib-module/utils/index.js +2 -1
  67. package/lib-module/utils/props/handlerProps.js +59 -0
  68. package/lib-module/utils/props/index.js +1 -0
  69. package/lib-module/utils/props/inputSupportsProps.js +3 -5
  70. package/package.json +5 -5
  71. package/src/Button/ButtonBase.jsx +8 -2
  72. package/src/Button/ButtonGroup.jsx +51 -34
  73. package/src/Card/PressableCardBase.jsx +6 -1
  74. package/src/Checkbox/Checkbox.jsx +35 -23
  75. package/src/Checkbox/CheckboxGroup.jsx +52 -22
  76. package/src/ExpandCollapse/Panel.jsx +9 -9
  77. package/src/FlexGrid/Col/Col.jsx +11 -2
  78. package/src/FlexGrid/Row/Row.jsx +8 -2
  79. package/src/HorizontalScroll/HorizontalScroll.jsx +1 -1
  80. package/src/HorizontalScroll/HorizontalScrollButton.jsx +21 -58
  81. package/src/InputLabel/InputLabel.jsx +36 -27
  82. package/src/Link/LinkBase.jsx +20 -4
  83. package/src/Modal/Modal.jsx +30 -26
  84. package/src/Notification/Notification.jsx +7 -4
  85. package/src/Radio/Radio.jsx +26 -14
  86. package/src/Radio/RadioGroup.jsx +39 -21
  87. package/src/RadioCard/RadioCard.jsx +6 -1
  88. package/src/RadioCard/RadioCardGroup.jsx +17 -1
  89. package/src/Select/Select.jsx +2 -2
  90. package/src/Tags/Tags.jsx +23 -9
  91. package/src/TextInput/TextArea.jsx +5 -1
  92. package/src/TextInput/TextInput.jsx +13 -3
  93. package/src/TextInput/TextInputBase.jsx +6 -1
  94. package/src/TextInput/propTypes.js +7 -1
  95. package/src/ToggleSwitch/ToggleSwitch.jsx +11 -2
  96. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +19 -6
  97. package/src/utils/containUniqueFields.js +32 -0
  98. package/src/utils/index.js +1 -0
  99. package/src/utils/props/handlerProps.js +47 -0
  100. package/src/utils/props/index.js +1 -0
  101. package/src/utils/props/inputSupportsProps.js +3 -4
  102. package/stories/InputLabel/InputLabel.stories.jsx +25 -28
  103. package/stories/Modal/Modal.stories.jsx +25 -0
  104. package/stories/Search/Search.stories.jsx +4 -1
  105. package/stories/TextInput/TextInput.stories.jsx +40 -2
@@ -21,9 +21,7 @@ var _ViewportProvider = require("../ViewportProvider");
21
21
 
22
22
  var _ThemeProvider = require("../ThemeProvider");
23
23
 
24
- var _props = require("../utils/props");
25
-
26
- var _input = require("../utils/input");
24
+ var _utils = require("../utils");
27
25
 
28
26
  var _pressability = require("../utils/pressability");
29
27
 
@@ -35,7 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
33
 
36
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; }
37
35
 
38
- const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.pressProps, _props.viewProps]);
36
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
37
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
39
38
  const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
40
39
  variant,
41
40
  tokens,
@@ -57,7 +56,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
57
56
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('ButtonGroup', tokens, variant, {
58
57
  viewport
59
58
  });
60
- const stackTokens = (0, _props.selectTokens)('StackView', themeTokens);
59
+ const stackTokens = (0, _utils.selectTokens)('StackView', themeTokens);
61
60
  const {
62
61
  direction,
63
62
  space
@@ -66,7 +65,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
66
65
  const {
67
66
  currentValues,
68
67
  toggleOneValue
69
- } = (0, _input.useMultipleInputValues)({
68
+ } = (0, _utils.useMultipleInputValues)({
70
69
  initialValues,
71
70
  values,
72
71
  maxValues,
@@ -78,6 +77,12 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
78
77
  ...rest
79
78
  });
80
79
  const itemA11yRole = systemProps.accessibilityRole === 'radiogroup' ? 'radio' : 'checkbox';
80
+ const uniqueFields = ['id', 'label'];
81
+
82
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
83
+ throw new Error(`ButtonGroup items must have unique ${uniqueFields.join(', ')}`);
84
+ }
85
+
81
86
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, { ...systemProps,
82
87
  space: space,
83
88
  direction: direction,
@@ -87,7 +92,8 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
87
92
  label,
88
93
  id = label,
89
94
  accessibilityLabel,
90
- ref: itemRef
95
+ ref: itemRef,
96
+ ...itemRest
91
97
  }, index) => {
92
98
  const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
93
99
 
@@ -98,7 +104,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
98
104
  }]);
99
105
 
100
106
  const handlePress = event => {
101
- if (pressHandlers.onPress) pressHandlers.onPress();
107
+ if (pressHandlers.onPress) pressHandlers.onPress(event);
102
108
  toggleOneValue(id, event);
103
109
  };
104
110
 
@@ -108,7 +114,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
108
114
  },
109
115
  accessibilityRole: itemA11yRole,
110
116
  accessibilityLabel,
111
- ..._props.a11yProps.getPositionInSet(items.length, index)
117
+ ..._utils.a11yProps.getPositionInSet(items.length, index)
112
118
  }; // Ensure button is direct child of group as MacOS voiceover only applies "X of Y" to
113
119
  // "radio" if it's a direct child of "radiogroup", even if aria-posinset etc exists
114
120
 
@@ -120,6 +126,7 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
120
126
  selected: isSelected,
121
127
  inactive: inactive,
122
128
  ...itemA11y,
129
+ ...selectItemProps(itemRest),
123
130
  children: label
124
131
  }, id);
125
132
  })
@@ -127,8 +134,8 @@ const ButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
127
134
  });
128
135
  ButtonGroup.displayName = 'ButtonGroup';
129
136
  ButtonGroup.propTypes = { ...selectedSystemPropTypes,
130
- tokens: (0, _props.getTokensPropType)('ButtonGroup'),
131
- variant: _props.variantProp.propType,
137
+ tokens: (0, _utils.getTokensPropType)('ButtonGroup'),
138
+ variant: _utils.variantProp.propType,
132
139
 
133
140
  /**
134
141
  * The maximum number of items a user may select at once. Defaults to 1 and behaves
@@ -139,7 +146,8 @@ ButtonGroup.propTypes = { ...selectedSystemPropTypes,
139
146
  /**
140
147
  * The options a user may select
141
148
  */
142
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
149
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
150
+
143
151
  /**
144
152
  * The text displayed to the user in the button, describing this option,
145
153
  * passed to the button as its child.
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
29
 
30
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
31
 
32
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
32
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
33
33
  const tokenKeys = [...(0, _utils.getTokenNames)('Card'), // Outer border tokens. TODO: centralise common token sets like these as part of
34
34
  // https://github.com/telus/universal-design-system/issues/782
35
35
  'outerBorderColor', 'outerBorderWidth', 'outerBorderGap'];
@@ -41,7 +41,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
41
41
 
42
42
  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; }
43
43
 
44
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
44
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
45
45
 
46
46
  const selectInputStyles = ({
47
47
  iconBackgroundColor,
@@ -232,24 +232,31 @@ const Checkbox = /*#__PURE__*/(0, _react.forwardRef)(({
232
232
  pressed
233
233
  });
234
234
  const iconTokens = selectIconTokens(stateTokens);
235
+ const labelStyles = selectLabelStyles(stateTokens);
236
+ const alignWithLabel = label ? [staticStyles.alignWithLabel, {
237
+ height: labelStyles.lineHeight
238
+ }] : null;
235
239
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
236
240
  style: staticStyles.container,
237
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
238
- style: _StyleSheet.default.flatten([staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)]),
239
- testID: "Checkbox-Input",
240
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckboxInput.default, {
241
- checked: isChecked,
242
- defaultChecked: defaultChecked,
243
- disabled: inactive,
244
- id: inputId,
245
- isControlled: isControlled,
246
- name: name,
247
- value: value
248
- }), isChecked && IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, { ...iconTokens,
249
- testID: "Checkbox-Icon"
250
- })]
241
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
242
+ style: alignWithLabel,
243
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
244
+ style: [staticStyles.defaultInputStyles, selectInputStyles(stateTokens, isChecked)],
245
+ testID: "Checkbox-Input",
246
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckboxInput.default, {
247
+ checked: isChecked,
248
+ defaultChecked: defaultChecked,
249
+ disabled: inactive,
250
+ id: inputId,
251
+ isControlled: isControlled,
252
+ name: name,
253
+ value: value
254
+ }), isChecked && IconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(IconComponent, { ...iconTokens,
255
+ testID: "Checkbox-Icon"
256
+ })]
257
+ })
251
258
  }), Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
252
- style: selectLabelStyles(stateTokens),
259
+ style: labelStyles,
253
260
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelContent.default, {
254
261
  forId: inputId,
255
262
  children: label
@@ -347,5 +354,9 @@ const staticStyles = _StyleSheet.default.create({
347
354
  defaultInputStyles: {
348
355
  alignItems: 'center',
349
356
  justifyContent: 'center'
357
+ },
358
+ alignWithLabel: {
359
+ alignSelf: 'flex-start',
360
+ justifyContent: 'center'
350
361
  }
351
362
  });
@@ -31,6 +31,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
31
31
 
32
32
  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; }
33
33
 
34
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
35
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
34
36
  /**
35
37
  * A group of Checkboxs that behave as a fieldset. Use when users select any number of choices from options.
36
38
  *
@@ -78,6 +80,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
78
80
  * />
79
81
  * ```
80
82
  */
83
+
81
84
  const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
82
85
  tokens,
83
86
  radioTokens,
@@ -93,7 +96,8 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
93
96
  onChange,
94
97
  readOnly,
95
98
  name: inputGroupName,
96
- inactive
99
+ inactive,
100
+ ...rest
97
101
  }, ref) => {
98
102
  const viewport = (0, _ViewportProvider.useViewport)();
99
103
  const {
@@ -111,11 +115,18 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
111
115
  onChange,
112
116
  readOnly: readOnly || inactive
113
117
  });
118
+ const uniqueFields = ['id', 'label'];
119
+
120
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
121
+ throw new Error(`CheckboxGroup items must have unique ${uniqueFields.join(', ')}`);
122
+ }
123
+
114
124
  const checkboxes = items.map(({
115
125
  label,
116
126
  id,
117
127
  onChange: itemOnChange,
118
- ref: itemRef
128
+ ref: itemRef,
129
+ ...itemRest
119
130
  }, index) => {
120
131
  const checkboxId = id || `Checkbox[${index}]`;
121
132
 
@@ -133,7 +144,8 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
133
144
  label: label,
134
145
  name: inputGroupName,
135
146
  tokens: radioTokens,
136
- variant: variant
147
+ variant: variant,
148
+ ...selectItemProps(itemRest)
137
149
  }, checkboxId);
138
150
  });
139
151
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
@@ -146,6 +158,7 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
146
158
  feedback: feedback,
147
159
  inactive: inactive,
148
160
  validation: validation,
161
+ ...selectProps(rest),
149
162
  children: (0, _StackView.getStackedContent)(checkboxes, {
150
163
  space,
151
164
  direction: 'column'
@@ -153,7 +166,8 @@ const CheckboxGroup = /*#__PURE__*/(0, _react.forwardRef)(({
153
166
  });
154
167
  });
155
168
  CheckboxGroup.displayName = 'CheckboxGroup';
156
- CheckboxGroup.propTypes = {
169
+ CheckboxGroup.propTypes = { ...selectedSystemPropTypes,
170
+
157
171
  /**
158
172
  * Optional theme token overrides for the outer CheckboxGroup component
159
173
  */
@@ -172,7 +186,7 @@ CheckboxGroup.propTypes = {
172
186
  /**
173
187
  * Array of objects containing specifics for each Checkbox to be rendered in the group.
174
188
  */
175
- items: _propTypes.default.arrayOf(_propTypes.default.exact({
189
+ items: _propTypes.default.arrayOf(_propTypes.default.exact({ ...selectedItemPropTypes,
176
190
  label: _propTypes.default.string,
177
191
  id: _propTypes.default.string,
178
192
  onChange: _propTypes.default.func,
@@ -86,12 +86,13 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)(({
86
86
  };
87
87
 
88
88
  const onContainerLayout = event => {
89
- if (containerHeight === null) {
90
- const {
91
- layout: {
92
- height = 0
93
- } = {}
94
- } = event.nativeEvent;
89
+ const {
90
+ layout: {
91
+ height = 0
92
+ } = {}
93
+ } = event.nativeEvent;
94
+
95
+ if (_Platform.default.OS === 'web' || _Platform.default.OS !== 'web' && containerHeight === null) {
95
96
  setContainerHeight(height);
96
97
  }
97
98
  };
@@ -116,12 +117,11 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)(({
116
117
  tokens: controlTokens,
117
118
  onPress: handleControlPress,
118
119
  children: control
119
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
120
- style: overflowContainerStyles,
120
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
121
+ style: [overflowContainerStyles, animatedStyles, staticStyles.itemsContainer],
121
122
  ...focusabilityProps,
122
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Animated.default.View, {
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
123
124
  onLayout: onContainerLayout,
124
- style: [staticStyles.itemsContainer, animatedStyles],
125
125
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
126
126
  style: selectContainerStyles(themeTokens),
127
127
  children: children
@@ -46,6 +46,7 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)(({
46
46
  mdOffset,
47
47
  lgOffset,
48
48
  xlOffset,
49
+ flex,
49
50
  ...viewProps
50
51
  }, ref) => {
51
52
  const gutter = (0, _react.useContext)(_GutterContext.default);
@@ -119,8 +120,11 @@ const Col = /*#__PURE__*/(0, _react.forwardRef)(({
119
120
  paddingLeft: gutter ? 16 : 0,
120
121
  paddingRight: gutter ? 16 : 0
121
122
  };
122
- let hidingStyles = {};
123
- const shown = _Platform.default.OS === 'web' ? 'block' : 'flex';
123
+ let hidingStyles = {}; // TODO: consider setting this to always 'flex' in a major release.
124
+ // `display: block` is invalid in native apps.
125
+ // See https://telusdigital.atlassian.net/browse/UDS1-92
126
+
127
+ const shown = !flex && _Platform.default.OS === 'web' ? 'block' : 'flex';
124
128
 
125
129
  if (viewPort === _systemConstants.viewports.xs) {
126
130
  hidingStyles = {
@@ -286,7 +290,13 @@ Col.propTypes = {
286
290
  *
287
291
  * Accepts a `PropType.string` following the [responsive prop](#/Layout?id=responsive) structure.
288
292
  */
289
- horizontalAlign: _utils.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.oneOf(['left', 'center', 'right']))
293
+ horizontalAlign: _utils.responsiveProps.getTypeOptionallyByViewport(_propTypes.default.oneOf(['left', 'center', 'right'])),
294
+
295
+ /**
296
+ * (web only) Stretches the column to fill vertical space using `display: flex`.
297
+ * In native apps, FlexGrid.Col behaves as if this is always true (as do all `View`s).
298
+ */
299
+ flex: _propTypes.default.bool
290
300
  };
291
301
  var _default = Col;
292
302
  exports.default = _default;
@@ -106,25 +106,31 @@ const Row = /*#__PURE__*/(0, _react.forwardRef)(({
106
106
  const viewPort = (0, _ViewportProvider.useViewport)();
107
107
  const reverseLevel = (0, _helpers.default)([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
108
108
  let flexDirection = '';
109
+ let flexWrap = '';
109
110
 
110
111
  if (viewPort === _systemConstants.viewports.xs) {
111
112
  flexDirection = reverseLevel[0] ? 'row-reverse' : 'row';
113
+ flexWrap = reverseLevel[0] ? 'wrap-reverse' : 'wrap';
112
114
  }
113
115
 
114
116
  if (viewPort === _systemConstants.viewports.sm) {
115
117
  flexDirection = reverseLevel[1] ? 'row-reverse' : 'row';
118
+ flexWrap = reverseLevel[1] ? 'wrap-reverse' : 'wrap';
116
119
  }
117
120
 
118
121
  if (viewPort === _systemConstants.viewports.md) {
119
122
  flexDirection = reverseLevel[2] ? 'row-reverse' : 'row';
123
+ flexWrap = reverseLevel[2] ? 'wrap-reverse' : 'wrap';
120
124
  }
121
125
 
122
126
  if (viewPort === _systemConstants.viewports.lg) {
123
127
  flexDirection = reverseLevel[3] ? 'row-reverse' : 'row';
128
+ flexWrap = reverseLevel[3] ? 'wrap-reverse' : 'wrap';
124
129
  }
125
130
 
126
131
  if (viewPort === _systemConstants.viewports.xl) {
127
132
  flexDirection = reverseLevel[4] ? 'row-reverse' : 'row';
133
+ flexWrap = reverseLevel[4] ? 'wrap-reverse' : 'wrap';
128
134
  }
129
135
 
130
136
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
@@ -132,6 +138,7 @@ const Row = /*#__PURE__*/(0, _react.forwardRef)(({
132
138
  ...rest,
133
139
  style: [styles.row, {
134
140
  flexDirection,
141
+ flexWrap,
135
142
  ...horizontalAlignStyles(horizontalAlign),
136
143
  ...verticalAlignStyles(verticalAlign),
137
144
  ...distributeStyles(distribute)
@@ -149,8 +156,7 @@ const styles = _StyleSheet.default.create({
149
156
  flexGrow: 0,
150
157
  flexShrink: 1,
151
158
  flexBasis: 'auto',
152
- flexDirection: 'row',
153
- flexWrap: 'wrap'
159
+ flexDirection: 'row'
154
160
  }
155
161
  });
156
162
 
@@ -154,7 +154,6 @@ const HorizontalScroll = /*#__PURE__*/(0, _react.forwardRef)(({
154
154
  onLayout: handleContainerLayout,
155
155
  showsHorizontalScrollIndicator: false,
156
156
  contentContainerStyle: [staticStyles.scrollContainer, {
157
- marginBottom: gutter,
158
157
  borderBottomWidth,
159
158
  borderBottomColor
160
159
  }],
@@ -9,17 +9,15 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
13
-
14
12
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
15
13
 
16
- var _ThemeProvider = require("../ThemeProvider");
14
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
17
15
 
18
16
  var _utils = require("../utils");
19
17
 
20
- var _Icon = _interopRequireDefault(require("../Icon"));
18
+ var _ThemeProvider = require("../ThemeProvider");
21
19
 
22
- var _Typography = _interopRequireDefault(require("../Typography"));
20
+ var _IconButton = _interopRequireDefault(require("../IconButton"));
23
21
 
24
22
  var _dictionary = _interopRequireDefault(require("./dictionary"));
25
23
 
@@ -31,19 +29,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
31
29
 
32
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; }
33
31
 
34
- const selectButtonStyles = ({
35
- borderRadius,
36
- backgroundColor,
37
- borderColor,
38
- borderWidth,
39
- padding
40
- }, direction) => [staticStyles.absolute, staticStyles[direction], {
41
- borderRadius,
42
- backgroundColor,
43
- borderColor,
44
- borderWidth,
45
- padding
46
- }];
32
+ const selectContainerStyles = ({
33
+ offset
34
+ }) => ({
35
+ marginTop: offset ? -offset : 0
36
+ });
47
37
  /**
48
38
  * Button within a Tabs component showing users that content is available to the left or
49
39
  * right, scrolling a screen's worth of content left or right when pressed.
@@ -57,47 +47,31 @@ const selectButtonStyles = ({
57
47
  const HorizontalScrollButton = /*#__PURE__*/(0, _react.forwardRef)(({
58
48
  direction = 'next',
59
49
  icon,
60
- onPress,
61
50
  offset,
51
+ onPress,
62
52
  variant,
63
53
  tokens,
64
54
  copy
65
55
  }, ref) => {
66
- const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('HorizontalScrollButton', tokens, variant);
67
-
68
- const resolveButtonTokens = pressableState => (0, _utils.resolvePressableTokens)(getTokens, pressableState);
69
-
70
- const getPressableStyle = pressableState => [selectButtonStyles(resolveButtonTokens(pressableState), direction), {
71
- marginTop: -1 * (offset || 0)
72
- }];
73
-
56
+ const themeTokens = (0, _ThemeProvider.useThemeTokens)('HorizontalScrollButton', tokens, variant);
74
57
  const getCopy = (0, _utils.useCopy)({
75
58
  dictionary: _dictionary.default,
76
59
  copy
77
60
  });
78
61
  const label = direction === 'previous' ? getCopy('previousText') : getCopy('nextText');
79
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
80
- ref: ref,
81
- style: getPressableStyle,
82
- onPress: onPress,
83
- accessibilityLabel: label,
84
- accessibilityRole: "button" // For keyboard-tab or screenreader-swipe navigation, users can just go through all items
85
- ,
86
- ..._utils.a11yProps.nonFocusableProps,
87
- children: pressableState => {
88
- const iconTokens = (0, _utils.selectTokens)('Icon', resolveButtonTokens(pressableState), 'icon');
89
- return icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
90
- icon: icon,
91
- tokens: iconTokens
92
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
93
- tokens: {
94
- fontSize: iconTokens.size,
95
- lineHeight: 1,
96
- color: iconTokens.color
97
- },
98
- children: direction === 'next' ? '→' : '←'
99
- });
100
- }
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
63
+ style: [staticStyles.absolute, staticStyles[direction], selectContainerStyles({
64
+ offset
65
+ })],
66
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
67
+ accessibilityLabel: label,
68
+ icon: icon,
69
+ onPress: onPress,
70
+ ref: ref,
71
+ tokens: themeTokens,
72
+ variant: variant,
73
+ ..._utils.a11yProps.nonFocusableProps
74
+ })
101
75
  });
102
76
  });
103
77
  HorizontalScrollButton.displayName = 'HorizontalScrollButton';
@@ -69,25 +69,29 @@ const InputLabel = /*#__PURE__*/(0, _react.forwardRef)(({
69
69
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('InputLabel', tokens, variant);
70
70
  const hasTooltip = tooltip !== undefined;
71
71
  const isHintInline = hintPosition === 'inline';
72
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
73
- ref: ref,
74
- style: [staticStyles.container, !isHintInline && staticStyles.containerWithHintBelow],
75
- ...selectProps(rest),
76
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
77
- style: [selectLabelStyles(themeTokens), selectGapStyles(themeTokens), staticStyles.label],
78
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelContent.default, {
79
- forId: forId,
80
- children: label
81
- })
82
- }), hint && isHintInline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
83
- style: [selectHintStyles(themeTokens), hasTooltip && selectGapStyles(themeTokens)],
84
- nativeID: hintId,
85
- children: hint
86
- }), hasTooltip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
87
- style: staticStyles.tooltipAlign,
88
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
89
- content: tooltip
90
- })
72
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
73
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
74
+ ref: ref,
75
+ style: staticStyles.container,
76
+ ...selectProps(rest),
77
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
78
+ style: [selectLabelStyles(themeTokens), selectGapStyles(themeTokens), staticStyles.label],
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelContent.default, {
80
+ forId: forId,
81
+ children: label
82
+ })
83
+ }), hint && isHintInline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
84
+ style: [selectHintStyles(themeTokens), hasTooltip && selectGapStyles(themeTokens), staticStyles.label],
85
+ nativeID: hintId,
86
+ children: hint
87
+ }), hasTooltip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
88
+ style: [staticStyles.tooltipAlign, {
89
+ height: themeTokens.fontSize * themeTokens.lineHeight
90
+ }],
91
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
92
+ content: tooltip
93
+ })
94
+ })]
91
95
  }), hint && !isHintInline && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
92
96
  style: [selectHintStyles(themeTokens), staticStyles.hintBelow],
93
97
  nativeID: hintId,
@@ -135,21 +139,19 @@ exports.default = _default;
135
139
 
136
140
  const staticStyles = _StyleSheet.default.create({
137
141
  container: {
138
- display: 'flex',
142
+ flexShrink: 1,
139
143
  flexDirection: 'row',
140
144
  alignItems: 'baseline'
141
145
  },
142
- containerWithHintBelow: {
143
- flexWrap: 'wrap'
144
- },
145
146
  label: {
146
- flexShrink: 0
147
+ flexShrink: 1
147
148
  },
148
149
  hintBelow: {
149
150
  flexBasis: '100%',
150
151
  flexShrink: 0
151
152
  },
152
153
  tooltipAlign: {
153
- alignSelf: 'center'
154
+ alignSelf: 'flex-start',
155
+ justifyContent: 'center'
154
156
  }
155
157
  });
@@ -60,13 +60,9 @@ _Platform.default.OS === 'web' ? {
60
60
  } : {};
61
61
 
62
62
  const selectTextStyles = ({
63
- color,
64
- textLine,
65
- textLineStyle
63
+ color
66
64
  }) => ({
67
65
  color,
68
- textDecorationLine: textLine,
69
- textDecorationStyle: textLineStyle,
70
66
  ..._Platform.default.select({
71
67
  web: {
72
68
  // TODO: https://github.com/telus/universal-design-system/issues/487
@@ -87,6 +83,22 @@ const selectBlockStyles = ({
87
83
  fontName: blockFontName
88
84
  });
89
85
 
86
+ const selectDecorationStyles = ({
87
+ color,
88
+ textLine,
89
+ textLineStyle
90
+ }) => ({
91
+ color,
92
+ textDecorationLine: textLine,
93
+ textDecorationStyle: textLineStyle,
94
+ ..._Platform.default.select({
95
+ web: {
96
+ // TODO: https://github.com/telus/universal-design-system/issues/487
97
+ transition: 'color 200ms'
98
+ }
99
+ })
100
+ });
101
+
90
102
  const selectIconTokens = ({
91
103
  color,
92
104
  iconSize,
@@ -165,8 +177,9 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)(({
165
177
  style: linkState => {
166
178
  const themeTokens = resolveLinkTokens(linkState);
167
179
  const outerBorderStyles = selectOuterBorderStyles(themeTokens);
180
+ const decorationStyles = selectDecorationStyles(themeTokens);
168
181
  const hasIcon = Boolean(icon || themeTokens.icon);
169
- return [outerBorderStyles, blockLeftStyle, hasIcon && staticStyles.rowContainer];
182
+ return [outerBorderStyles, blockLeftStyle, decorationStyles, hasIcon && staticStyles.rowContainer];
170
183
  },
171
184
  children: linkState => {
172
185
  const themeTokens = resolveLinkTokens(linkState);