@carbon/react 1.16.0-rc.0 → 1.17.0-rc.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/es/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
- package/es/components/Checkbox/Checkbox.Skeleton.js +1 -2
- package/es/components/Checkbox/Checkbox.d.ts +47 -0
- package/es/components/Checkbox/Checkbox.js +6 -7
- package/es/components/Checkbox/index.d.ts +10 -0
- package/es/components/Checkbox/index.js +10 -0
- package/es/components/CodeSnippet/CodeSnippet.js +0 -1
- package/es/components/DataTable/TableToolbarSearch.js +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/Grid/Grid.js +0 -5
- package/es/components/NumberInput/NumberInput.js +45 -1
- package/es/components/ProgressIndicator/ProgressIndicator.Skeleton.js +10 -4
- package/es/components/Search/Search.js +160 -184
- package/es/components/Search/index.js +2 -8
- package/es/components/Tab/index.js +1 -1
- package/es/components/Tabs/Tabs.Skeleton.js +6 -6
- package/es/components/Tabs/Tabs.js +582 -508
- package/es/components/Tabs/index.js +2 -12
- package/es/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
- package/es/components/Text/Text.d.ts +33 -0
- package/es/components/Text/Text.js +8 -5
- package/es/components/Text/TextDirection.d.ts +35 -0
- package/es/components/Text/TextDirectionContext.js +2 -0
- package/es/components/Text/createTextComponent.d.ts +18 -0
- package/es/components/Text/index.d.ts +18 -0
- package/es/components/Text/index.js +2 -0
- package/es/components/TextInput/TextInput.js +1 -1
- package/es/components/Tile/Tile.js +339 -502
- package/es/index.js +6 -6
- package/es/internal/useNormalizedInputProps.js +13 -17
- package/es/internal/usePrefix.d.ts +9 -0
- package/lib/components/Checkbox/Checkbox.Skeleton.d.ts +18 -0
- package/lib/components/Checkbox/Checkbox.Skeleton.js +1 -2
- package/lib/components/Checkbox/Checkbox.d.ts +47 -0
- package/lib/components/Checkbox/Checkbox.js +6 -7
- package/lib/components/Checkbox/index.d.ts +10 -0
- package/lib/components/Checkbox/index.js +18 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +0 -1
- package/lib/components/DataTable/TableToolbarSearch.js +2 -2
- package/lib/components/ExpandableSearch/ExpandableSearch.js +3 -3
- package/lib/components/Grid/Grid.js +0 -5
- package/lib/components/NumberInput/NumberInput.js +45 -1
- package/lib/components/ProgressIndicator/ProgressIndicator.Skeleton.js +9 -3
- package/lib/components/Search/Search.js +159 -183
- package/lib/components/Search/index.js +2 -25
- package/lib/components/Tab/index.js +1 -1
- package/lib/components/Tabs/Tabs.Skeleton.js +6 -6
- package/lib/components/Tabs/Tabs.js +586 -507
- package/lib/components/Tabs/index.js +7 -33
- package/lib/components/Tabs/{next/usePressable.js → usePressable.js} +1 -1
- package/lib/components/Text/Text.d.ts +33 -0
- package/lib/components/Text/Text.js +8 -5
- package/lib/components/Text/TextDirection.d.ts +35 -0
- package/lib/components/Text/TextDirectionContext.js +2 -0
- package/lib/components/Text/createTextComponent.d.ts +18 -0
- package/lib/components/Text/index.d.ts +18 -0
- package/lib/components/Text/index.js +4 -0
- package/lib/components/TextInput/TextInput.js +1 -1
- package/lib/components/Tile/Tile.js +336 -499
- package/lib/index.js +71 -71
- package/lib/internal/useNormalizedInputProps.js +12 -16
- package/lib/internal/usePrefix.d.ts +9 -0
- package/package.json +8 -4
- package/es/components/Search/next/Search.js +0 -265
- package/es/components/Tabs/next/Tabs.Skeleton.js +0 -53
- package/es/components/Tabs/next/Tabs.js +0 -692
- package/es/components/Tile/index.js +0 -19
- package/es/components/Tile/next/Tile.js +0 -604
- package/lib/components/Search/next/Search.js +0 -275
- package/lib/components/Tabs/next/Tabs.Skeleton.js +0 -63
- package/lib/components/Tabs/next/Tabs.js +0 -708
- package/lib/components/Tile/index.js +0 -48
- package/lib/components/Tile/next/Tile.js +0 -619
|
@@ -5,57 +5,42 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import React__default, {
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends, slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { useState, useRef, useEffect } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
|
-
import Link from '../Link/Link.js';
|
|
13
12
|
import { CheckboxCheckedFilled, Checkbox, ChevronDown } from '@carbon/icons-react';
|
|
13
|
+
import Link from '../Link/Link.js';
|
|
14
14
|
import deprecate from '../../prop-types/deprecate.js';
|
|
15
15
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
16
|
-
import {
|
|
16
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
18
|
+
import { getInteractiveContent } from '../../internal/useNoInteractiveChildren.js';
|
|
17
19
|
import { matches } from '../../internal/keyboard/match.js';
|
|
18
20
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
19
21
|
|
|
20
|
-
var _CheckboxCheckedFille, _Checkbox, _ChevronDown;
|
|
22
|
+
var _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
|
|
21
23
|
|
|
22
24
|
var _excluded = ["children", "className", "light"],
|
|
23
|
-
_excluded2 = ["children", "
|
|
24
|
-
_excluded3 = ["children", "
|
|
25
|
-
_excluded4 = ["tabIndex", "className", "expanded", "tileMaxHeight", "tilePadding", "
|
|
26
|
-
var Tile = /*#__PURE__*/function (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _this$props = this.props,
|
|
43
|
-
children = _this$props.children,
|
|
44
|
-
className = _this$props.className,
|
|
45
|
-
light = _this$props.light,
|
|
46
|
-
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
47
|
-
|
|
48
|
-
var tileClasses = cx("".concat(prefix, "--tile"), _defineProperty({}, "".concat(prefix, "--tile--light"), light), className);
|
|
49
|
-
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
50
|
-
className: tileClasses
|
|
51
|
-
}, rest), children);
|
|
52
|
-
}
|
|
53
|
-
}]);
|
|
54
|
-
|
|
55
|
-
return Tile;
|
|
56
|
-
}(Component);
|
|
57
|
-
|
|
58
|
-
_defineProperty(Tile, "propTypes", {
|
|
25
|
+
_excluded2 = ["children", "className", "clicked", "href", "light", "onClick", "onKeyDown"],
|
|
26
|
+
_excluded3 = ["children", "className", "disabled", "id", "light", "name", "onClick", "onChange", "onKeyDown", "selected", "tabIndex", "title", "value"],
|
|
27
|
+
_excluded4 = ["tabIndex", "className", "children", "expanded", "tileMaxHeight", "tilePadding", "onClick", "onKeyUp", "tileCollapsedIconText", "tileExpandedIconText", "tileCollapsedLabel", "tileExpandedLabel", "light"];
|
|
28
|
+
var Tile = /*#__PURE__*/React__default.forwardRef(function Tile(_ref, ref) {
|
|
29
|
+
var children = _ref.children,
|
|
30
|
+
className = _ref.className,
|
|
31
|
+
_ref$light = _ref.light,
|
|
32
|
+
light = _ref$light === void 0 ? false : _ref$light,
|
|
33
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
|
|
35
|
+
var prefix = usePrefix();
|
|
36
|
+
var tileClasses = cx("".concat(prefix, "--tile"), _defineProperty({}, "".concat(prefix, "--tile--light"), light), className);
|
|
37
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
38
|
+
className: tileClasses,
|
|
39
|
+
ref: ref
|
|
40
|
+
}, rest), children);
|
|
41
|
+
});
|
|
42
|
+
Tile.displayName = 'Tile';
|
|
43
|
+
Tile.propTypes = {
|
|
59
44
|
/**
|
|
60
45
|
* The child nodes.
|
|
61
46
|
*/
|
|
@@ -70,114 +55,59 @@ _defineProperty(Tile, "propTypes", {
|
|
|
70
55
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
71
56
|
* Don't use this to make tile background color same as container background color.
|
|
72
57
|
*/
|
|
73
|
-
light: PropTypes.bool
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
58
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `Tile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.')
|
|
59
|
+
};
|
|
60
|
+
var ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableTile(_ref2, ref) {
|
|
61
|
+
var _cx2;
|
|
62
|
+
|
|
63
|
+
var children = _ref2.children,
|
|
64
|
+
className = _ref2.className,
|
|
65
|
+
_ref2$clicked = _ref2.clicked,
|
|
66
|
+
clicked = _ref2$clicked === void 0 ? false : _ref2$clicked,
|
|
67
|
+
href = _ref2.href,
|
|
68
|
+
light = _ref2.light,
|
|
69
|
+
_ref2$onClick = _ref2.onClick,
|
|
70
|
+
onClick = _ref2$onClick === void 0 ? function () {} : _ref2$onClick,
|
|
71
|
+
_ref2$onKeyDown = _ref2.onKeyDown,
|
|
72
|
+
onKeyDown = _ref2$onKeyDown === void 0 ? function () {} : _ref2$onKeyDown,
|
|
73
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
74
|
+
|
|
75
|
+
var prefix = usePrefix();
|
|
76
|
+
var classes = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--clickable"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--tile--is-clicked"), clicked), _defineProperty(_cx2, "".concat(prefix, "--tile--light"), light), _cx2), className);
|
|
77
|
+
|
|
78
|
+
var _useState = useState(clicked),
|
|
79
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
80
|
+
isSelected = _useState2[0],
|
|
81
|
+
setIsSelected = _useState2[1];
|
|
86
82
|
|
|
87
|
-
function
|
|
88
|
-
|
|
83
|
+
function handleOnClick(evt) {
|
|
84
|
+
evt.persist();
|
|
85
|
+
setIsSelected(!isSelected);
|
|
86
|
+
onClick(evt);
|
|
87
|
+
}
|
|
89
88
|
|
|
90
|
-
|
|
89
|
+
function handleOnKeyDown(evt) {
|
|
90
|
+
evt.persist();
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (matches(evt, [Enter, Space])) {
|
|
93
|
+
evt.preventDefault();
|
|
94
|
+
setIsSelected(!isSelected);
|
|
95
|
+
onKeyDown(evt);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_defineProperty(_assertThisInitialized(_this), "state", {});
|
|
99
|
-
|
|
100
|
-
_defineProperty(_assertThisInitialized(_this), "handleClick", function (evt) {
|
|
101
|
-
evt.persist();
|
|
102
|
-
|
|
103
|
-
_this.setState({
|
|
104
|
-
clicked: !_this.state.clicked
|
|
105
|
-
}, function () {
|
|
106
|
-
var _this$props$handleCli, _this$props2, _this$props$onClick, _this$props3;
|
|
107
|
-
|
|
108
|
-
// TODO: Remove handleClick prop when handleClick is deprecated
|
|
109
|
-
((_this$props$handleCli = (_this$props2 = _this.props).handleClick) === null || _this$props$handleCli === void 0 ? void 0 : _this$props$handleCli.call(_this$props2, evt)) || ((_this$props$onClick = (_this$props3 = _this.props).onClick) === null || _this$props$onClick === void 0 ? void 0 : _this$props$onClick.call(_this$props3, evt));
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (evt) {
|
|
114
|
-
evt.persist();
|
|
115
|
-
|
|
116
|
-
if (matches(evt, [Enter, Space])) {
|
|
117
|
-
_this.setState({
|
|
118
|
-
clicked: !_this.state.clicked
|
|
119
|
-
}, function () {
|
|
120
|
-
var _this$props$handleKey, _this$props4;
|
|
121
|
-
|
|
122
|
-
// TODO: Remove handleKeyDown prop when handleKeyDown is deprecated
|
|
123
|
-
((_this$props$handleKey = (_this$props4 = _this.props).handleKeyDown) === null || _this$props$handleKey === void 0 ? void 0 : _this$props$handleKey.call(_this$props4, evt)) || _this.props.onKeyDown(evt);
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
var _this$props$handleKey2, _this$props5;
|
|
127
|
-
|
|
128
|
-
// TODO: Remove handleKeyDown prop when handleKeyDown is deprecated
|
|
129
|
-
((_this$props$handleKey2 = (_this$props5 = _this.props).handleKeyDown) === null || _this$props$handleKey2 === void 0 ? void 0 : _this$props$handleKey2.call(_this$props5, evt)) || _this.props.onKeyDown(evt);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return _this;
|
|
98
|
+
onKeyDown(evt);
|
|
134
99
|
}
|
|
135
100
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
className = _this$props6.className;
|
|
147
|
-
_this$props6.handleClick;
|
|
148
|
-
_this$props6.handleKeyDown;
|
|
149
|
-
_this$props6.onClick;
|
|
150
|
-
_this$props6.onKeyDown;
|
|
151
|
-
_this$props6.clicked;
|
|
152
|
-
var light = _this$props6.light,
|
|
153
|
-
rest = _objectWithoutProperties(_this$props6, _excluded2);
|
|
154
|
-
|
|
155
|
-
var classes = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--clickable"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--tile--is-clicked"), this.state.clicked), _defineProperty(_cx2, "".concat(prefix, "--tile--light"), light), _cx2), className);
|
|
156
|
-
return /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
157
|
-
href: href,
|
|
158
|
-
className: classes
|
|
159
|
-
}, rest, {
|
|
160
|
-
onClick: this.handleClick,
|
|
161
|
-
onKeyDown: this.handleKeyDown
|
|
162
|
-
}), children);
|
|
163
|
-
}
|
|
164
|
-
}], [{
|
|
165
|
-
key: "getDerivedStateFromProps",
|
|
166
|
-
value: // eslint-disable-next-line react/prop-types
|
|
167
|
-
function getDerivedStateFromProps(_ref, state) {
|
|
168
|
-
var clicked = _ref.clicked;
|
|
169
|
-
var prevClicked = state.prevClicked;
|
|
170
|
-
return prevClicked === clicked ? null : {
|
|
171
|
-
clicked: clicked,
|
|
172
|
-
prevClicked: clicked
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}]);
|
|
176
|
-
|
|
177
|
-
return ClickableTile;
|
|
178
|
-
}(Component);
|
|
179
|
-
|
|
180
|
-
_defineProperty(ClickableTile, "propTypes", {
|
|
101
|
+
return /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
102
|
+
className: classes,
|
|
103
|
+
href: href,
|
|
104
|
+
onClick: handleOnClick,
|
|
105
|
+
onKeyDown: handleOnKeyDown,
|
|
106
|
+
ref: ref
|
|
107
|
+
}, rest), children);
|
|
108
|
+
});
|
|
109
|
+
ClickableTile.displayName = 'ClickableTile';
|
|
110
|
+
ClickableTile.propTypes = {
|
|
181
111
|
/**
|
|
182
112
|
* The child nodes.
|
|
183
113
|
*/
|
|
@@ -189,14 +119,9 @@ _defineProperty(ClickableTile, "propTypes", {
|
|
|
189
119
|
className: PropTypes.string,
|
|
190
120
|
|
|
191
121
|
/**
|
|
192
|
-
*
|
|
193
|
-
*/
|
|
194
|
-
handleClick: deprecate(PropTypes.func, 'The handleClick prop for ClickableTile has been deprecated in favor of onClick. It will be removed in the next major release.'),
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Specify the function to run when the ClickableTile is interacted with via a keyboard
|
|
122
|
+
* Boolean for whether a tile has been clicked.
|
|
198
123
|
*/
|
|
199
|
-
|
|
124
|
+
clicked: PropTypes.bool,
|
|
200
125
|
|
|
201
126
|
/**
|
|
202
127
|
* The href for the link.
|
|
@@ -207,7 +132,7 @@ _defineProperty(ClickableTile, "propTypes", {
|
|
|
207
132
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
208
133
|
* Don't use this to make tile background color same as container background color.
|
|
209
134
|
*/
|
|
210
|
-
light: PropTypes.bool,
|
|
135
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `ClickableTile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
211
136
|
|
|
212
137
|
/**
|
|
213
138
|
* Specify the function to run when the ClickableTile is clicked
|
|
@@ -223,52 +148,47 @@ _defineProperty(ClickableTile, "propTypes", {
|
|
|
223
148
|
* The rel property for the link.
|
|
224
149
|
*/
|
|
225
150
|
rel: PropTypes.string
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
_defineProperty(ClickableTile, "contextType", PrefixContext);
|
|
229
|
-
|
|
230
|
-
_defineProperty(ClickableTile, "defaultProps", {
|
|
231
|
-
clicked: false,
|
|
232
|
-
onClick: function onClick() {},
|
|
233
|
-
onKeyDown: function onKeyDown() {},
|
|
234
|
-
light: false
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
function SelectableTile(props) {
|
|
151
|
+
};
|
|
152
|
+
var SelectableTile = /*#__PURE__*/React__default.forwardRef(function SelectableTile(_ref3, ref) {
|
|
238
153
|
var _cx3;
|
|
239
154
|
|
|
240
|
-
var children =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
var
|
|
263
|
-
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var
|
|
155
|
+
var children = _ref3.children,
|
|
156
|
+
className = _ref3.className,
|
|
157
|
+
disabled = _ref3.disabled,
|
|
158
|
+
id = _ref3.id,
|
|
159
|
+
light = _ref3.light,
|
|
160
|
+
name = _ref3.name,
|
|
161
|
+
_ref3$onClick = _ref3.onClick,
|
|
162
|
+
onClick = _ref3$onClick === void 0 ? function () {} : _ref3$onClick,
|
|
163
|
+
_ref3$onChange = _ref3.onChange,
|
|
164
|
+
onChange = _ref3$onChange === void 0 ? function () {} : _ref3$onChange,
|
|
165
|
+
_ref3$onKeyDown = _ref3.onKeyDown,
|
|
166
|
+
onKeyDown = _ref3$onKeyDown === void 0 ? function () {} : _ref3$onKeyDown,
|
|
167
|
+
_ref3$selected = _ref3.selected,
|
|
168
|
+
selected = _ref3$selected === void 0 ? false : _ref3$selected,
|
|
169
|
+
_ref3$tabIndex = _ref3.tabIndex,
|
|
170
|
+
tabIndex = _ref3$tabIndex === void 0 ? 0 : _ref3$tabIndex,
|
|
171
|
+
_ref3$title = _ref3.title,
|
|
172
|
+
title = _ref3$title === void 0 ? 'title' : _ref3$title,
|
|
173
|
+
_ref3$value = _ref3.value,
|
|
174
|
+
value = _ref3$value === void 0 ? 'value' : _ref3$value,
|
|
175
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
176
|
+
|
|
177
|
+
var prefix = usePrefix();
|
|
178
|
+
var clickHandler = onClick;
|
|
179
|
+
var keyDownHandler = onKeyDown;
|
|
180
|
+
|
|
181
|
+
var _useState3 = useState(selected),
|
|
182
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
183
|
+
isSelected = _useState4[0],
|
|
184
|
+
setIsSelected = _useState4[1];
|
|
185
|
+
|
|
186
|
+
var _useState5 = useState(selected),
|
|
187
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
188
|
+
prevSelected = _useState6[0],
|
|
189
|
+
setPrevSelected = _useState6[1];
|
|
190
|
+
|
|
191
|
+
var classes = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--selectable"), (_cx3 = {}, _defineProperty(_cx3, "".concat(prefix, "--tile--is-selected"), isSelected), _defineProperty(_cx3, "".concat(prefix, "--tile--light"), light), _defineProperty(_cx3, "".concat(prefix, "--tile--disabled"), disabled), _cx3), className); // TODO: rename to handleClick when handleClick prop is deprecated
|
|
272
192
|
|
|
273
193
|
function handleOnClick(evt) {
|
|
274
194
|
evt.preventDefault();
|
|
@@ -296,45 +216,34 @@ function SelectableTile(props) {
|
|
|
296
216
|
onChange(event);
|
|
297
217
|
}
|
|
298
218
|
|
|
299
|
-
|
|
219
|
+
if (selected !== prevSelected) {
|
|
300
220
|
setIsSelected(selected);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
type: "checkbox",
|
|
221
|
+
setPrevSelected(selected);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
225
|
+
className: classes,
|
|
226
|
+
onClick: !disabled ? handleOnClick : null,
|
|
227
|
+
role: "checkbox",
|
|
228
|
+
"aria-checked": isSelected,
|
|
310
229
|
disabled: disabled,
|
|
311
|
-
|
|
312
|
-
title: title,
|
|
313
|
-
checked: isSelected
|
|
314
|
-
}), /*#__PURE__*/React__default.createElement("label", _extends({
|
|
315
|
-
htmlFor: id,
|
|
316
|
-
className: classes // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
230
|
+
onKeyDown: !disabled ? handleOnKeyDown : null // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
317
231
|
,
|
|
318
|
-
tabIndex: !disabled ? tabIndex : null
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
232
|
+
tabIndex: !disabled ? tabIndex : null,
|
|
233
|
+
value: value,
|
|
234
|
+
name: name,
|
|
235
|
+
ref: ref,
|
|
236
|
+
id: id,
|
|
237
|
+
onChange: !disabled ? handleChange : null,
|
|
238
|
+
title: title
|
|
239
|
+
}, rest), /*#__PURE__*/React__default.createElement("span", {
|
|
323
240
|
className: "".concat(prefix, "--tile__checkmark ").concat(prefix, "--tile__checkmark--persistent")
|
|
324
|
-
}, isSelected ? _CheckboxCheckedFille || (_CheckboxCheckedFille = /*#__PURE__*/React__default.createElement(CheckboxCheckedFilled, null)) : _Checkbox || (_Checkbox = /*#__PURE__*/React__default.createElement(Checkbox, null))), /*#__PURE__*/React__default.createElement("
|
|
241
|
+
}, isSelected ? _CheckboxCheckedFille || (_CheckboxCheckedFille = /*#__PURE__*/React__default.createElement(CheckboxCheckedFilled, null)) : _Checkbox || (_Checkbox = /*#__PURE__*/React__default.createElement(Checkbox, null))), /*#__PURE__*/React__default.createElement("label", {
|
|
242
|
+
htmlFor: id,
|
|
325
243
|
className: "".concat(prefix, "--tile-content")
|
|
326
|
-
}, children))
|
|
327
|
-
}
|
|
328
|
-
SelectableTile.
|
|
329
|
-
value: 'value',
|
|
330
|
-
title: 'title',
|
|
331
|
-
selected: false,
|
|
332
|
-
tabIndex: 0,
|
|
333
|
-
light: false,
|
|
334
|
-
onClick: function onClick() {},
|
|
335
|
-
onChange: function onChange() {},
|
|
336
|
-
onKeyDown: function onKeyDown() {}
|
|
337
|
-
};
|
|
244
|
+
}, children));
|
|
245
|
+
});
|
|
246
|
+
SelectableTile.displayName = 'SelectableTile';
|
|
338
247
|
SelectableTile.propTypes = {
|
|
339
248
|
/**
|
|
340
249
|
* The child nodes.
|
|
@@ -351,21 +260,6 @@ SelectableTile.propTypes = {
|
|
|
351
260
|
*/
|
|
352
261
|
disabled: PropTypes.bool,
|
|
353
262
|
|
|
354
|
-
/**
|
|
355
|
-
* Specify the function to run when the SelectableTile is clicked
|
|
356
|
-
*/
|
|
357
|
-
handleClick: deprecate(PropTypes.func, 'The `handleClick` prop for `SelectableTile` has been deprecated in favor of `onClick`. It will be removed in the next major release.'),
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Specify the function to run when the SelectableTile is interacted with via a keyboard
|
|
361
|
-
*/
|
|
362
|
-
handleKeyDown: deprecate(PropTypes.func, 'The `handleKeyDown` prop for `SelectableTile` has been deprecated in favor of `onKeyDown`. It will be removed in the next major release.'),
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* The description of the checkmark icon.
|
|
366
|
-
*/
|
|
367
|
-
iconDescription: deprecate(PropTypes.string, 'The `iconDescription` prop for `SelectableTile` is no longer needed and has ' + 'been deprecated. It will be removed in the next major release.'),
|
|
368
|
-
|
|
369
263
|
/**
|
|
370
264
|
* The ID of the `<input>`.
|
|
371
265
|
*/
|
|
@@ -375,7 +269,7 @@ SelectableTile.propTypes = {
|
|
|
375
269
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
376
270
|
* Don't use this to make tile background color same as container background color.
|
|
377
271
|
*/
|
|
378
|
-
light: PropTypes.bool,
|
|
272
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `SelectableTile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
379
273
|
|
|
380
274
|
/**
|
|
381
275
|
* The `name` of the `<input>`.
|
|
@@ -417,197 +311,194 @@ SelectableTile.propTypes = {
|
|
|
417
311
|
*/
|
|
418
312
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
419
313
|
};
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
var
|
|
314
|
+
function ExpandableTile(_ref4) {
|
|
315
|
+
var _cx4, _cx5;
|
|
316
|
+
|
|
317
|
+
var tabIndex = _ref4.tabIndex,
|
|
318
|
+
className = _ref4.className,
|
|
319
|
+
children = _ref4.children,
|
|
320
|
+
expanded = _ref4.expanded,
|
|
321
|
+
tileMaxHeight = _ref4.tileMaxHeight,
|
|
322
|
+
tilePadding = _ref4.tilePadding,
|
|
323
|
+
onClick = _ref4.onClick,
|
|
324
|
+
onKeyUp = _ref4.onKeyUp,
|
|
325
|
+
tileCollapsedIconText = _ref4.tileCollapsedIconText,
|
|
326
|
+
tileExpandedIconText = _ref4.tileExpandedIconText,
|
|
327
|
+
tileCollapsedLabel = _ref4.tileCollapsedLabel,
|
|
328
|
+
tileExpandedLabel = _ref4.tileExpandedLabel,
|
|
329
|
+
light = _ref4.light,
|
|
330
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
|
331
|
+
|
|
332
|
+
var _useState7 = useState(tileMaxHeight),
|
|
333
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
334
|
+
isTileMaxHeight = _useState8[0],
|
|
335
|
+
setIsTileMaxHeight = _useState8[1];
|
|
336
|
+
|
|
337
|
+
var _useState9 = useState(tilePadding),
|
|
338
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
339
|
+
isTilePadding = _useState10[0],
|
|
340
|
+
setIsTilePadding = _useState10[1];
|
|
341
|
+
|
|
342
|
+
var _useState11 = useState(expanded),
|
|
343
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
344
|
+
prevExpanded = _useState12[0],
|
|
345
|
+
setPrevExpanded = _useState12[1];
|
|
346
|
+
|
|
347
|
+
var _useState13 = useState(tileMaxHeight),
|
|
348
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
349
|
+
prevTileMaxHeight = _useState14[0],
|
|
350
|
+
setPrevTileMaxHeight = _useState14[1];
|
|
351
|
+
|
|
352
|
+
var _useState15 = useState(tilePadding),
|
|
353
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
354
|
+
prevTilePadding = _useState16[0],
|
|
355
|
+
setPrevTilePadding = _useState16[1];
|
|
356
|
+
|
|
357
|
+
var _useState17 = useState(expanded),
|
|
358
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
359
|
+
isExpanded = _useState18[0],
|
|
360
|
+
setIsExpanded = _useState18[1];
|
|
361
|
+
|
|
362
|
+
var _useState19 = useState(false),
|
|
363
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
364
|
+
interactive = _useState20[0],
|
|
365
|
+
setInteractive = _useState20[1];
|
|
366
|
+
|
|
367
|
+
var aboveTheFold = useRef(null);
|
|
368
|
+
var belowTheFold = useRef(null);
|
|
369
|
+
var tileContent = useRef(null);
|
|
370
|
+
var tile = useRef(null);
|
|
371
|
+
var prefix = usePrefix();
|
|
372
|
+
|
|
373
|
+
if (expanded !== prevExpanded) {
|
|
374
|
+
setIsExpanded(expanded);
|
|
375
|
+
setPrevExpanded(expanded);
|
|
376
|
+
setMaxHeight();
|
|
377
|
+
}
|
|
424
378
|
|
|
425
|
-
|
|
426
|
-
|
|
379
|
+
if (tileMaxHeight !== prevTileMaxHeight) {
|
|
380
|
+
setIsTileMaxHeight(tileMaxHeight);
|
|
381
|
+
setPrevTileMaxHeight(tileMaxHeight);
|
|
382
|
+
}
|
|
427
383
|
|
|
428
|
-
|
|
384
|
+
if (tilePadding !== prevTilePadding) {
|
|
385
|
+
setIsTilePadding(tilePadding);
|
|
386
|
+
setPrevTilePadding(tilePadding);
|
|
387
|
+
}
|
|
429
388
|
|
|
430
|
-
|
|
431
|
-
|
|
389
|
+
function setMaxHeight() {
|
|
390
|
+
if (isExpanded) {
|
|
391
|
+
setIsTileMaxHeight(tileContent.current.getBoundingClientRect().height);
|
|
432
392
|
}
|
|
433
393
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
_defineProperty(_assertThisInitialized(_this2), "state", {});
|
|
437
|
-
|
|
438
|
-
_defineProperty(_assertThisInitialized(_this2), "resizeObserver", null);
|
|
439
|
-
|
|
440
|
-
_defineProperty(_assertThisInitialized(_this2), "componentDidMount", function () {
|
|
441
|
-
_this2.resizeObserver = new ResizeObserver(function (entries) {
|
|
442
|
-
var _entries = _slicedToArray(entries, 1),
|
|
443
|
-
aboveTheFold = _entries[0];
|
|
444
|
-
|
|
445
|
-
_this2.setState({
|
|
446
|
-
tileMaxHeight: aboveTheFold.contentRect.height
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
if (_this2.tile) {
|
|
451
|
-
var getStyle = window.getComputedStyle(_this2.tile, null);
|
|
452
|
-
|
|
453
|
-
if (_this2.aboveTheFold) {
|
|
454
|
-
_this2.resizeObserver.observe(_this2.aboveTheFold);
|
|
455
|
-
|
|
456
|
-
_this2.setState({
|
|
457
|
-
tileMaxHeight: _this2.aboveTheFold.getBoundingClientRect().height,
|
|
458
|
-
tilePadding: parseInt(getStyle.getPropertyValue('padding-top'), 10) + parseInt(getStyle.getPropertyValue('padding-bottom'), 10)
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
_defineProperty(_assertThisInitialized(_this2), "componentDidUpdate", function (prevProps) {
|
|
465
|
-
if (prevProps.expanded !== _this2.props.expanded) {
|
|
466
|
-
_this2.setMaxHeight();
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
_defineProperty(_assertThisInitialized(_this2), "setMaxHeight", function () {
|
|
471
|
-
if (_this2.state.expanded ? _this2.tileContent : _this2.aboveTheFold) {
|
|
472
|
-
_this2.setState({
|
|
473
|
-
tileMaxHeight: _this2.state.expanded ? _this2.tileContent.getBoundingClientRect().height : _this2.aboveTheFold.getBoundingClientRect().height
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
_defineProperty(_assertThisInitialized(_this2), "handleClick", function (evt) {
|
|
479
|
-
if (!_this2.props.onBeforeClick(evt) || evt.target.tagName === 'INPUT') {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
evt.persist();
|
|
484
|
-
|
|
485
|
-
_this2.setState({
|
|
486
|
-
expanded: !_this2.state.expanded
|
|
487
|
-
}, function () {
|
|
488
|
-
var _this2$props$handleCl, _this2$props, _this2$props$onClick, _this2$props2;
|
|
489
|
-
|
|
490
|
-
_this2.setMaxHeight(); // TODO: Remove handleClick prop when handleClick is deprecated
|
|
394
|
+
setIsTileMaxHeight(aboveTheFold.current.getBoundingClientRect().height);
|
|
395
|
+
}
|
|
491
396
|
|
|
397
|
+
function handleClick(evt) {
|
|
398
|
+
evt.persist();
|
|
399
|
+
setIsExpanded(!isExpanded);
|
|
400
|
+
setMaxHeight();
|
|
492
401
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
402
|
+
if (onClick) {
|
|
403
|
+
onClick(evt);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
496
406
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
407
|
+
function handleKeyUp(evt) {
|
|
408
|
+
if (evt.target !== tile.current) {
|
|
409
|
+
if (matches(evt, [Enter, Space])) {
|
|
410
|
+
evt.preventDefault();
|
|
502
411
|
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
_defineProperty(_assertThisInitialized(_this2), "getChildren", function () {
|
|
506
|
-
return React__default.Children.toArray(_this2.props.children);
|
|
507
|
-
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
508
414
|
|
|
509
|
-
|
|
415
|
+
function getChildren() {
|
|
416
|
+
return React__default.Children.toArray(children);
|
|
510
417
|
}
|
|
511
418
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
_this$props7.onBeforeClick;
|
|
538
|
-
var light = _this$props7.light,
|
|
539
|
-
rest = _objectWithoutProperties(_this$props7, _excluded4);
|
|
540
|
-
|
|
541
|
-
var prefix = this.context;
|
|
542
|
-
var isExpanded = this.state.expanded;
|
|
543
|
-
var classes = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--expandable"), (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--tile--is-expanded"), isExpanded), _defineProperty(_cx5, "".concat(prefix, "--tile--light"), light), _cx5), className);
|
|
544
|
-
var tileStyle = {
|
|
545
|
-
maxHeight: isExpanded ? null : this.state.tileMaxHeight + this.state.tilePadding
|
|
546
|
-
};
|
|
547
|
-
var childrenAsArray = this.getChildren();
|
|
548
|
-
return (
|
|
549
|
-
/*#__PURE__*/
|
|
550
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
551
|
-
React__default.createElement("button", _extends({
|
|
552
|
-
type: "button",
|
|
553
|
-
ref: function ref(tile) {
|
|
554
|
-
_this3.tile = tile;
|
|
555
|
-
},
|
|
556
|
-
style: tileStyle,
|
|
557
|
-
className: classes,
|
|
558
|
-
"aria-expanded": isExpanded,
|
|
559
|
-
title: isExpanded ? tileExpandedIconText : tileCollapsedIconText
|
|
560
|
-
}, rest, {
|
|
561
|
-
onKeyUp: composeEventHandlers([onKeyUp, this.handleKeyUp]),
|
|
562
|
-
onClick: this.handleClick,
|
|
563
|
-
tabIndex: tabIndex
|
|
564
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
565
|
-
ref: function ref(tileContent) {
|
|
566
|
-
_this3.tileContent = tileContent;
|
|
567
|
-
}
|
|
568
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
569
|
-
ref: function ref(aboveTheFold) {
|
|
570
|
-
_this3.aboveTheFold = aboveTheFold;
|
|
571
|
-
},
|
|
572
|
-
className: "".concat(prefix, "--tile-content")
|
|
573
|
-
}, childrenAsArray[0]), /*#__PURE__*/React__default.createElement("div", {
|
|
574
|
-
className: "".concat(prefix, "--tile__chevron")
|
|
575
|
-
}, /*#__PURE__*/React__default.createElement("span", null, isExpanded ? tileExpandedLabel : tileCollapsedLabel), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null))), /*#__PURE__*/React__default.createElement("div", {
|
|
576
|
-
className: "".concat(prefix, "--tile-content")
|
|
577
|
-
}, childrenAsArray[1])))
|
|
578
|
-
);
|
|
419
|
+
var classNames = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--expandable"), (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--tile--is-expanded"), isExpanded), _defineProperty(_cx4, "".concat(prefix, "--tile--light"), light), _cx4), className);
|
|
420
|
+
var interactiveClassNames = cx("".concat(prefix, "--tile"), "".concat(prefix, "--tile--expandable"), "".concat(prefix, "--tile--expandable--interactive"), (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--tile--is-expanded"), isExpanded), _defineProperty(_cx5, "".concat(prefix, "--tile--light"), light), _cx5), className);
|
|
421
|
+
var chevronInteractiveClassNames = cx("".concat(prefix, "--tile__chevron"), "".concat(prefix, "--tile__chevron--interactive"));
|
|
422
|
+
var tileStyle = {
|
|
423
|
+
maxHeight: isExpanded ? null : isTileMaxHeight + isTilePadding
|
|
424
|
+
};
|
|
425
|
+
var childrenAsArray = getChildren();
|
|
426
|
+
useIsomorphicEffect(function () {
|
|
427
|
+
var getStyle = window.getComputedStyle(tile.current, null);
|
|
428
|
+
var node = aboveTheFold.current;
|
|
429
|
+
|
|
430
|
+
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
431
|
+
height = _node$getBoundingClie.height;
|
|
432
|
+
|
|
433
|
+
var paddingTop = parseInt(getStyle.getPropertyValue('padding-top'), 10);
|
|
434
|
+
var paddingBottom = parseInt(getStyle.getPropertyValue('padding-bottom'), 10);
|
|
435
|
+
setIsTileMaxHeight(height);
|
|
436
|
+
setIsTilePadding(paddingTop + paddingBottom);
|
|
437
|
+
}, []);
|
|
438
|
+
useIsomorphicEffect(function () {
|
|
439
|
+
if (getInteractiveContent(belowTheFold.current)) {
|
|
440
|
+
setInteractive(true);
|
|
441
|
+
return;
|
|
442
|
+
} else if (getInteractiveContent(aboveTheFold.current)) {
|
|
443
|
+
setInteractive(true);
|
|
579
444
|
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
tileMaxHeight = _ref2.tileMaxHeight,
|
|
586
|
-
tilePadding = _ref2.tilePadding;
|
|
587
|
-
var prevExpanded = state.prevExpanded,
|
|
588
|
-
prevTileMaxHeight = state.prevTileMaxHeight,
|
|
589
|
-
prevTilePadding = state.prevTilePadding,
|
|
590
|
-
currentExpanded = state.expanded,
|
|
591
|
-
currentTileMaxHeight = state.tileMaxHeight,
|
|
592
|
-
currentTilePadding = state.tilePadding;
|
|
593
|
-
var expandedChanged = prevExpanded !== expanded;
|
|
594
|
-
var tileMaxHeightChanged = prevTileMaxHeight !== tileMaxHeight;
|
|
595
|
-
var tilePaddingChanged = prevTilePadding !== tilePadding;
|
|
596
|
-
return !expandedChanged && !tileMaxHeightChanged && !tilePaddingChanged ? null : {
|
|
597
|
-
expanded: !expandedChanged ? currentExpanded : expanded,
|
|
598
|
-
tileMaxHeight: !tileMaxHeightChanged ? currentTileMaxHeight : tileMaxHeight,
|
|
599
|
-
tilePadding: !tilePaddingChanged ? currentTilePadding : tilePadding,
|
|
600
|
-
prevExpanded: expanded,
|
|
601
|
-
prevTileMaxHeight: tileMaxHeight,
|
|
602
|
-
prevTilePadding: tilePadding
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
}]);
|
|
606
|
-
|
|
607
|
-
return ExpandableTile;
|
|
608
|
-
}(Component);
|
|
445
|
+
}, []);
|
|
446
|
+
useEffect(function () {
|
|
447
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
448
|
+
var _entries = _slicedToArray(entries, 1),
|
|
449
|
+
aboveTheFold = _entries[0];
|
|
609
450
|
|
|
610
|
-
|
|
451
|
+
setIsTileMaxHeight(aboveTheFold.contentRect.height);
|
|
452
|
+
});
|
|
453
|
+
resizeObserver.observe(aboveTheFold.current);
|
|
454
|
+
return function () {
|
|
455
|
+
return resizeObserver.disconnect();
|
|
456
|
+
};
|
|
457
|
+
}, []);
|
|
458
|
+
return interactive ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
459
|
+
ref: tile,
|
|
460
|
+
style: tileStyle,
|
|
461
|
+
className: interactiveClassNames,
|
|
462
|
+
"aria-expanded": isExpanded
|
|
463
|
+
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
464
|
+
ref: tileContent
|
|
465
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
466
|
+
ref: aboveTheFold,
|
|
467
|
+
className: "".concat(prefix, "--tile-content")
|
|
468
|
+
}, childrenAsArray[0]), /*#__PURE__*/React__default.createElement("button", {
|
|
469
|
+
type: "button",
|
|
470
|
+
"aria-expanded": isExpanded,
|
|
471
|
+
onKeyUp: composeEventHandlers([onKeyUp, handleKeyUp]),
|
|
472
|
+
onClick: composeEventHandlers([onClick, handleClick]),
|
|
473
|
+
"aria-label": isExpanded ? tileExpandedIconText : tileCollapsedIconText,
|
|
474
|
+
className: chevronInteractiveClassNames
|
|
475
|
+
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null))), /*#__PURE__*/React__default.createElement("div", {
|
|
476
|
+
ref: belowTheFold,
|
|
477
|
+
className: "".concat(prefix, "--tile-content")
|
|
478
|
+
}, childrenAsArray[1]))) : /*#__PURE__*/React__default.createElement("button", _extends({
|
|
479
|
+
type: "button",
|
|
480
|
+
ref: tile,
|
|
481
|
+
style: tileStyle,
|
|
482
|
+
className: classNames,
|
|
483
|
+
"aria-expanded": isExpanded,
|
|
484
|
+
title: isExpanded ? tileExpandedIconText : tileCollapsedIconText
|
|
485
|
+
}, rest, {
|
|
486
|
+
onKeyUp: composeEventHandlers([onKeyUp, handleKeyUp]),
|
|
487
|
+
onClick: composeEventHandlers([onClick, handleClick]),
|
|
488
|
+
tabIndex: tabIndex
|
|
489
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
490
|
+
ref: tileContent
|
|
491
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
492
|
+
ref: aboveTheFold,
|
|
493
|
+
className: "".concat(prefix, "--tile-content")
|
|
494
|
+
}, childrenAsArray[0]), /*#__PURE__*/React__default.createElement("div", {
|
|
495
|
+
className: "".concat(prefix, "--tile__chevron")
|
|
496
|
+
}, /*#__PURE__*/React__default.createElement("span", null, isExpanded ? tileExpandedLabel : tileCollapsedLabel), _ChevronDown2 || (_ChevronDown2 = /*#__PURE__*/React__default.createElement(ChevronDown, null))), /*#__PURE__*/React__default.createElement("div", {
|
|
497
|
+
ref: belowTheFold,
|
|
498
|
+
className: "".concat(prefix, "--tile-content")
|
|
499
|
+
}, childrenAsArray[1])));
|
|
500
|
+
}
|
|
501
|
+
ExpandableTile.propTypes = {
|
|
611
502
|
/**
|
|
612
503
|
* The child nodes.
|
|
613
504
|
*/
|
|
@@ -623,11 +514,6 @@ _defineProperty(ExpandableTile, "propTypes", {
|
|
|
623
514
|
*/
|
|
624
515
|
expanded: PropTypes.bool,
|
|
625
516
|
|
|
626
|
-
/**
|
|
627
|
-
* Deprecated in v11. Use 'onClick' instead.
|
|
628
|
-
*/
|
|
629
|
-
handleClick: deprecate(PropTypes.func, 'The handleClick prop for ExpandableTile has been deprecated in favor of onClick. It will be removed in the next major release.'),
|
|
630
|
-
|
|
631
517
|
/**
|
|
632
518
|
* An ID that can be provided to aria-labelledby
|
|
633
519
|
*/
|
|
@@ -637,16 +523,11 @@ _defineProperty(ExpandableTile, "propTypes", {
|
|
|
637
523
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
638
524
|
* Don't use this to make tile background color same as container background color.
|
|
639
525
|
*/
|
|
640
|
-
light: PropTypes.bool,
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* optional handler to decide whether to ignore a click. returns false if click should be ignored
|
|
644
|
-
*/
|
|
645
|
-
onBeforeClick: PropTypes.func,
|
|
526
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `ExpandableTile` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
646
527
|
|
|
647
528
|
/**
|
|
648
529
|
* Specify the function to run when the ExpandableTile is clicked
|
|
649
|
-
|
|
530
|
+
*/
|
|
650
531
|
onClick: PropTypes.func,
|
|
651
532
|
|
|
652
533
|
/**
|
|
@@ -678,90 +559,46 @@ _defineProperty(ExpandableTile, "propTypes", {
|
|
|
678
559
|
* When "expanded", a label to appear next to the chevron (e.g., "View less").
|
|
679
560
|
*/
|
|
680
561
|
tileExpandedLabel: PropTypes.string
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
_defineProperty(ExpandableTile, "contextType", PrefixContext);
|
|
684
|
-
|
|
685
|
-
_defineProperty(ExpandableTile, "defaultProps", {
|
|
562
|
+
};
|
|
563
|
+
ExpandableTile.defaultProps = {
|
|
686
564
|
tabIndex: 0,
|
|
687
565
|
expanded: false,
|
|
688
566
|
tileMaxHeight: 0,
|
|
689
567
|
tilePadding: 0,
|
|
690
|
-
onBeforeClick: function onBeforeClick() {
|
|
691
|
-
return true;
|
|
692
|
-
},
|
|
693
568
|
onClick: function onClick() {},
|
|
694
569
|
tileCollapsedIconText: 'Interact to expand Tile',
|
|
695
|
-
tileExpandedIconText: 'Interact to collapse Tile'
|
|
696
|
-
|
|
570
|
+
tileExpandedIconText: 'Interact to collapse Tile'
|
|
571
|
+
};
|
|
572
|
+
ExpandableTile.displayName = 'ExpandableTile';
|
|
573
|
+
var TileAboveTheFoldContent = /*#__PURE__*/React__default.forwardRef(function TilAboveTheFoldContent(_ref5, ref) {
|
|
574
|
+
var children = _ref5.children;
|
|
575
|
+
var prefix = usePrefix();
|
|
576
|
+
return /*#__PURE__*/React__default.createElement("span", {
|
|
577
|
+
ref: ref,
|
|
578
|
+
className: "".concat(prefix, "--tile-content__above-the-fold")
|
|
579
|
+
}, children);
|
|
697
580
|
});
|
|
698
|
-
|
|
699
|
-
var TileAboveTheFoldContent = /*#__PURE__*/function (_Component4) {
|
|
700
|
-
_inherits(TileAboveTheFoldContent, _Component4);
|
|
701
|
-
|
|
702
|
-
var _super4 = _createSuper(TileAboveTheFoldContent);
|
|
703
|
-
|
|
704
|
-
function TileAboveTheFoldContent() {
|
|
705
|
-
_classCallCheck(this, TileAboveTheFoldContent);
|
|
706
|
-
|
|
707
|
-
return _super4.apply(this, arguments);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
_createClass(TileAboveTheFoldContent, [{
|
|
711
|
-
key: "render",
|
|
712
|
-
value: function render() {
|
|
713
|
-
var prefix = this.context;
|
|
714
|
-
var children = this.props.children;
|
|
715
|
-
return /*#__PURE__*/React__default.createElement("span", {
|
|
716
|
-
className: "".concat(prefix, "--tile-content__above-the-fold")
|
|
717
|
-
}, children);
|
|
718
|
-
}
|
|
719
|
-
}]);
|
|
720
|
-
|
|
721
|
-
return TileAboveTheFoldContent;
|
|
722
|
-
}(Component);
|
|
723
|
-
|
|
724
|
-
_defineProperty(TileAboveTheFoldContent, "propTypes", {
|
|
581
|
+
TileAboveTheFoldContent.propTypes = {
|
|
725
582
|
/**
|
|
726
583
|
* The child nodes.
|
|
727
584
|
*/
|
|
728
585
|
children: PropTypes.node
|
|
586
|
+
};
|
|
587
|
+
TileAboveTheFoldContent.displayName = 'TileAboveTheFoldContent';
|
|
588
|
+
var TileBelowTheFoldContent = /*#__PURE__*/React__default.forwardRef(function TileBelowTheFoldContent(_ref6, ref) {
|
|
589
|
+
var children = _ref6.children;
|
|
590
|
+
var prefix = usePrefix();
|
|
591
|
+
return /*#__PURE__*/React__default.createElement("span", {
|
|
592
|
+
ref: ref,
|
|
593
|
+
className: "".concat(prefix, "--tile-content__below-the-fold")
|
|
594
|
+
}, children);
|
|
729
595
|
});
|
|
730
|
-
|
|
731
|
-
_defineProperty(TileAboveTheFoldContent, "contextType", PrefixContext);
|
|
732
|
-
|
|
733
|
-
var TileBelowTheFoldContent = /*#__PURE__*/function (_Component5) {
|
|
734
|
-
_inherits(TileBelowTheFoldContent, _Component5);
|
|
735
|
-
|
|
736
|
-
var _super5 = _createSuper(TileBelowTheFoldContent);
|
|
737
|
-
|
|
738
|
-
function TileBelowTheFoldContent() {
|
|
739
|
-
_classCallCheck(this, TileBelowTheFoldContent);
|
|
740
|
-
|
|
741
|
-
return _super5.apply(this, arguments);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
_createClass(TileBelowTheFoldContent, [{
|
|
745
|
-
key: "render",
|
|
746
|
-
value: function render() {
|
|
747
|
-
var children = this.props.children;
|
|
748
|
-
var prefix = this.context;
|
|
749
|
-
return /*#__PURE__*/React__default.createElement("span", {
|
|
750
|
-
className: "".concat(prefix, "--tile-content__below-the-fold")
|
|
751
|
-
}, children);
|
|
752
|
-
}
|
|
753
|
-
}]);
|
|
754
|
-
|
|
755
|
-
return TileBelowTheFoldContent;
|
|
756
|
-
}(Component);
|
|
757
|
-
|
|
758
|
-
_defineProperty(TileBelowTheFoldContent, "propTypes", {
|
|
596
|
+
TileBelowTheFoldContent.propTypes = {
|
|
759
597
|
/**
|
|
760
598
|
* The child nodes.
|
|
761
599
|
*/
|
|
762
600
|
children: PropTypes.node
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
_defineProperty(TileBelowTheFoldContent, "contextType", PrefixContext);
|
|
601
|
+
};
|
|
602
|
+
TileBelowTheFoldContent.displayName = 'TileBelowTheFoldContent';
|
|
766
603
|
|
|
767
604
|
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent };
|