@carbon/react 1.16.0 → 1.17.0-rc.1
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/ComposedModal/ComposedModal.js +4 -3
- 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/Modal/Modal.js +5 -4
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -2
- 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/TextArea/TextArea.js +19 -2
- package/es/components/Tile/Tile.js +339 -502
- package/es/index.js +9 -9
- 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/ComposedModal/ComposedModal.js +4 -3
- 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/Modal/Modal.js +5 -4
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +8 -2
- 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/TextArea/TextArea.js +18 -1
- package/lib/components/Tile/Tile.js +336 -499
- package/lib/index.js +76 -76
- 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
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
9
|
-
import { Tile as Tile$1, ClickableTile as ClickableTile$1, SelectableTile as SelectableTile$1, ExpandableTile as ExpandableTile$1, TileAboveTheFoldContent as TileAboveTheFoldContent$1, TileBelowTheFoldContent as TileBelowTheFoldContent$1 } from './next/Tile.js';
|
|
10
|
-
import { Tile as Tile$2, ClickableTile as ClickableTile$2, SelectableTile as SelectableTile$2, ExpandableTile as ExpandableTile$2, TileAboveTheFoldContent as TileAboveTheFoldContent$2, TileBelowTheFoldContent as TileBelowTheFoldContent$2 } from './Tile.js';
|
|
11
|
-
|
|
12
|
-
var Tile = FeatureFlags.enabled('enable-v11-release') ? Tile$1 : Tile$2;
|
|
13
|
-
var ClickableTile = FeatureFlags.enabled('enable-v11-release') ? ClickableTile$1 : ClickableTile$2;
|
|
14
|
-
var SelectableTile = FeatureFlags.enabled('enable-v11-release') ? SelectableTile$1 : SelectableTile$2;
|
|
15
|
-
var ExpandableTile = FeatureFlags.enabled('enable-v11-release') ? ExpandableTile$1 : ExpandableTile$2;
|
|
16
|
-
var TileAboveTheFoldContent = FeatureFlags.enabled('enable-v11-release') ? TileAboveTheFoldContent$1 : TileAboveTheFoldContent$2;
|
|
17
|
-
var TileBelowTheFoldContent = FeatureFlags.enabled('enable-v11-release') ? TileBelowTheFoldContent$1 : TileBelowTheFoldContent$2;
|
|
18
|
-
|
|
19
|
-
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent };
|
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
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
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import cx from 'classnames';
|
|
12
|
-
import { CheckboxCheckedFilled, Checkbox, ChevronDown } from '@carbon/icons-react';
|
|
13
|
-
import Link from '../../Link/Link.js';
|
|
14
|
-
import deprecate from '../../../prop-types/deprecate.js';
|
|
15
|
-
import { composeEventHandlers } from '../../../tools/events.js';
|
|
16
|
-
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
17
|
-
import useIsomorphicEffect from '../../../internal/useIsomorphicEffect.js';
|
|
18
|
-
import { getInteractiveContent } from '../../../internal/useNoInteractiveChildren.js';
|
|
19
|
-
import { matches } from '../../../internal/keyboard/match.js';
|
|
20
|
-
import { Enter, Space } from '../../../internal/keyboard/keys.js';
|
|
21
|
-
|
|
22
|
-
var _CheckboxCheckedFille, _Checkbox, _ChevronDown, _ChevronDown2;
|
|
23
|
-
|
|
24
|
-
var _excluded = ["children", "className", "light"],
|
|
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 = {
|
|
44
|
-
/**
|
|
45
|
-
* The child nodes.
|
|
46
|
-
*/
|
|
47
|
-
children: PropTypes.node,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The CSS class names.
|
|
51
|
-
*/
|
|
52
|
-
className: PropTypes.string,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
56
|
-
* Don't use this to make tile background color same as container background color.
|
|
57
|
-
*/
|
|
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];
|
|
82
|
-
|
|
83
|
-
function handleOnClick(evt) {
|
|
84
|
-
evt.persist();
|
|
85
|
-
setIsSelected(!isSelected);
|
|
86
|
-
onClick(evt);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function handleOnKeyDown(evt) {
|
|
90
|
-
evt.persist();
|
|
91
|
-
|
|
92
|
-
if (matches(evt, [Enter, Space])) {
|
|
93
|
-
evt.preventDefault();
|
|
94
|
-
setIsSelected(!isSelected);
|
|
95
|
-
onKeyDown(evt);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
onKeyDown(evt);
|
|
99
|
-
}
|
|
100
|
-
|
|
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 = {
|
|
111
|
-
/**
|
|
112
|
-
* The child nodes.
|
|
113
|
-
*/
|
|
114
|
-
children: PropTypes.node,
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The CSS class names.
|
|
118
|
-
*/
|
|
119
|
-
className: PropTypes.string,
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Boolean for whether a tile has been clicked.
|
|
123
|
-
*/
|
|
124
|
-
clicked: PropTypes.bool,
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The href for the link.
|
|
128
|
-
*/
|
|
129
|
-
href: PropTypes.string,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
133
|
-
* Don't use this to make tile background color same as container background color.
|
|
134
|
-
*/
|
|
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.'),
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Specify the function to run when the ClickableTile is clicked
|
|
139
|
-
*/
|
|
140
|
-
onClick: PropTypes.func,
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Specify the function to run when the ClickableTile is interacted with via a keyboard
|
|
144
|
-
*/
|
|
145
|
-
onKeyDown: PropTypes.func,
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* The rel property for the link.
|
|
149
|
-
*/
|
|
150
|
-
rel: PropTypes.string
|
|
151
|
-
};
|
|
152
|
-
var SelectableTile = /*#__PURE__*/React__default.forwardRef(function SelectableTile(_ref3, ref) {
|
|
153
|
-
var _cx3;
|
|
154
|
-
|
|
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
|
|
192
|
-
|
|
193
|
-
function handleOnClick(evt) {
|
|
194
|
-
evt.preventDefault();
|
|
195
|
-
evt.persist();
|
|
196
|
-
setIsSelected(!isSelected);
|
|
197
|
-
clickHandler(evt);
|
|
198
|
-
onChange(evt);
|
|
199
|
-
} // TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function handleOnKeyDown(evt) {
|
|
203
|
-
evt.persist();
|
|
204
|
-
|
|
205
|
-
if (matches(evt, [Enter, Space])) {
|
|
206
|
-
evt.preventDefault();
|
|
207
|
-
setIsSelected(!isSelected);
|
|
208
|
-
onChange(evt);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
keyDownHandler(evt);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function handleChange(event) {
|
|
215
|
-
setIsSelected(event.target.checked);
|
|
216
|
-
onChange(event);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (selected !== prevSelected) {
|
|
220
|
-
setIsSelected(selected);
|
|
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,
|
|
229
|
-
disabled: disabled,
|
|
230
|
-
onKeyDown: !disabled ? handleOnKeyDown : null // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
231
|
-
,
|
|
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", {
|
|
240
|
-
className: "".concat(prefix, "--tile__checkmark ").concat(prefix, "--tile__checkmark--persistent")
|
|
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,
|
|
243
|
-
className: "".concat(prefix, "--tile-content")
|
|
244
|
-
}, children));
|
|
245
|
-
});
|
|
246
|
-
SelectableTile.displayName = 'SelectableTile';
|
|
247
|
-
SelectableTile.propTypes = {
|
|
248
|
-
/**
|
|
249
|
-
* The child nodes.
|
|
250
|
-
*/
|
|
251
|
-
children: PropTypes.node,
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* The CSS class names.
|
|
255
|
-
*/
|
|
256
|
-
className: PropTypes.string,
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Specify whether the SelectableTile should be disabled
|
|
260
|
-
*/
|
|
261
|
-
disabled: PropTypes.bool,
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* The ID of the `<input>`.
|
|
265
|
-
*/
|
|
266
|
-
id: PropTypes.string,
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
270
|
-
* Don't use this to make tile background color same as container background color.
|
|
271
|
-
*/
|
|
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.'),
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* The `name` of the `<input>`.
|
|
276
|
-
*/
|
|
277
|
-
name: PropTypes.string,
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* The empty handler of the `<input>`.
|
|
281
|
-
*/
|
|
282
|
-
onChange: PropTypes.func,
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Specify the function to run when the SelectableTile is clicked
|
|
286
|
-
*/
|
|
287
|
-
onClick: PropTypes.func,
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Specify the function to run when the SelectableTile is interacted with via a keyboard
|
|
291
|
-
*/
|
|
292
|
-
onKeyDown: PropTypes.func,
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* `true` to select this tile.
|
|
296
|
-
*/
|
|
297
|
-
selected: PropTypes.bool,
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Specify the tab index of the wrapper element
|
|
301
|
-
*/
|
|
302
|
-
tabIndex: PropTypes.number,
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* The `title` of the `<input>`.
|
|
306
|
-
*/
|
|
307
|
-
title: PropTypes.string,
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* The value of the `<input>`.
|
|
311
|
-
*/
|
|
312
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
313
|
-
};
|
|
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
|
-
}
|
|
378
|
-
|
|
379
|
-
if (tileMaxHeight !== prevTileMaxHeight) {
|
|
380
|
-
setIsTileMaxHeight(tileMaxHeight);
|
|
381
|
-
setPrevTileMaxHeight(tileMaxHeight);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (tilePadding !== prevTilePadding) {
|
|
385
|
-
setIsTilePadding(tilePadding);
|
|
386
|
-
setPrevTilePadding(tilePadding);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function setMaxHeight() {
|
|
390
|
-
if (isExpanded) {
|
|
391
|
-
setIsTileMaxHeight(tileContent.current.getBoundingClientRect().height);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
setIsTileMaxHeight(aboveTheFold.current.getBoundingClientRect().height);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function handleClick(evt) {
|
|
398
|
-
evt.persist();
|
|
399
|
-
setIsExpanded(!isExpanded);
|
|
400
|
-
setMaxHeight();
|
|
401
|
-
|
|
402
|
-
if (onClick) {
|
|
403
|
-
onClick(evt);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function handleKeyUp(evt) {
|
|
408
|
-
if (evt.target !== tile.current) {
|
|
409
|
-
if (matches(evt, [Enter, Space])) {
|
|
410
|
-
evt.preventDefault();
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
function getChildren() {
|
|
416
|
-
return React__default.Children.toArray(children);
|
|
417
|
-
}
|
|
418
|
-
|
|
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);
|
|
444
|
-
}
|
|
445
|
-
}, []);
|
|
446
|
-
useEffect(function () {
|
|
447
|
-
var resizeObserver = new ResizeObserver(function (entries) {
|
|
448
|
-
var _entries = _slicedToArray(entries, 1),
|
|
449
|
-
aboveTheFold = _entries[0];
|
|
450
|
-
|
|
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 = {
|
|
502
|
-
/**
|
|
503
|
-
* The child nodes.
|
|
504
|
-
*/
|
|
505
|
-
children: PropTypes.node,
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* The CSS class names.
|
|
509
|
-
*/
|
|
510
|
-
className: PropTypes.string,
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* `true` if the tile is expanded.
|
|
514
|
-
*/
|
|
515
|
-
expanded: PropTypes.bool,
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* An ID that can be provided to aria-labelledby
|
|
519
|
-
*/
|
|
520
|
-
id: PropTypes.string,
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
524
|
-
* Don't use this to make tile background color same as container background color.
|
|
525
|
-
*/
|
|
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.'),
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Specify the function to run when the ExpandableTile is clicked
|
|
530
|
-
*/
|
|
531
|
-
onClick: PropTypes.func,
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* optional handler to trigger a function when a key is pressed
|
|
535
|
-
*/
|
|
536
|
-
onKeyUp: PropTypes.func,
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* The `tabindex` attribute.
|
|
540
|
-
*/
|
|
541
|
-
tabIndex: PropTypes.number,
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* The description of the "collapsed" icon that can be read by screen readers.
|
|
545
|
-
*/
|
|
546
|
-
tileCollapsedIconText: PropTypes.string,
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* When "collapsed", a label to appear next to the chevron (e.g., "View more").
|
|
550
|
-
*/
|
|
551
|
-
tileCollapsedLabel: PropTypes.string,
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* The description of the "expanded" icon that can be read by screen readers.
|
|
555
|
-
*/
|
|
556
|
-
tileExpandedIconText: PropTypes.string,
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* When "expanded", a label to appear next to the chevron (e.g., "View less").
|
|
560
|
-
*/
|
|
561
|
-
tileExpandedLabel: PropTypes.string
|
|
562
|
-
};
|
|
563
|
-
ExpandableTile.defaultProps = {
|
|
564
|
-
tabIndex: 0,
|
|
565
|
-
expanded: false,
|
|
566
|
-
tileMaxHeight: 0,
|
|
567
|
-
tilePadding: 0,
|
|
568
|
-
onClick: function onClick() {},
|
|
569
|
-
tileCollapsedIconText: 'Interact to expand Tile',
|
|
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);
|
|
580
|
-
});
|
|
581
|
-
TileAboveTheFoldContent.propTypes = {
|
|
582
|
-
/**
|
|
583
|
-
* The child nodes.
|
|
584
|
-
*/
|
|
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);
|
|
595
|
-
});
|
|
596
|
-
TileBelowTheFoldContent.propTypes = {
|
|
597
|
-
/**
|
|
598
|
-
* The child nodes.
|
|
599
|
-
*/
|
|
600
|
-
children: PropTypes.node
|
|
601
|
-
};
|
|
602
|
-
TileBelowTheFoldContent.displayName = 'TileBelowTheFoldContent';
|
|
603
|
-
|
|
604
|
-
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent };
|