@carbon/react 1.17.0-rc.2 → 1.17.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/DatePicker/DatePicker.js +10 -2
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +67 -0
- package/es/components/ListBox/ListBoxSelection.js +11 -4
- package/es/components/MultiSelect/MultiSelect.js +28 -5
- package/es/components/OverflowMenu/index.js +1 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
- package/es/components/SkeletonText/SkeletonText.js +1 -1
- package/es/components/StructuredList/StructuredList.js +89 -54
- package/es/index.js +2 -1
- package/es/internal/FloatingMenu.js +3 -1
- package/lib/components/DatePicker/DatePicker.js +9 -1
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +77 -0
- package/lib/components/ListBox/ListBoxSelection.js +11 -4
- package/lib/components/MultiSelect/MultiSelect.js +28 -5
- package/lib/components/OverflowMenu/index.js +1 -22
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
- package/lib/components/SkeletonText/SkeletonText.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +87 -52
- package/lib/index.js +39 -37
- package/lib/internal/FloatingMenu.js +3 -1
- package/package.json +5 -5
- package/es/components/StructuredList/index.js +0 -43
- package/es/components/StructuredList/next/StructuredList.js +0 -342
- package/es/internal/ComponentToggle.js +0 -42
- package/lib/components/StructuredList/index.js +0 -52
- package/lib/components/StructuredList/next/StructuredList.js +0 -357
- package/lib/internal/ComponentToggle.js +0 -50
|
@@ -21,7 +21,7 @@ import { useSavedCallback } from '../../internal/useSavedCallback.js';
|
|
|
21
21
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
22
22
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
23
23
|
import { match } from '../../internal/keyboard/match.js';
|
|
24
|
-
import { ArrowDown } from '../../internal/keyboard/keys.js';
|
|
24
|
+
import { Escape, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
25
25
|
|
|
26
26
|
var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "invalid", "invalidText", "warn", "warnText", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "short", "value"];
|
|
27
27
|
|
|
@@ -292,6 +292,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
292
292
|
calendarRef.current = calendar;
|
|
293
293
|
|
|
294
294
|
function handleArrowDown(event) {
|
|
295
|
+
if (match(event, Escape)) {
|
|
296
|
+
calendar.calendarContainer.classList.remove('open');
|
|
297
|
+
}
|
|
298
|
+
|
|
295
299
|
if (match(event, ArrowDown)) {
|
|
296
300
|
var calendarContainer = calendar.calendarContainer,
|
|
297
301
|
fpSelectedDateElem = calendar.selectedDateElem,
|
|
@@ -303,6 +307,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
303
307
|
}
|
|
304
308
|
|
|
305
309
|
function handleOnChange() {
|
|
310
|
+
if (datePickerType == 'single') {
|
|
311
|
+
calendar.calendarContainer.classList.remove('open');
|
|
312
|
+
}
|
|
313
|
+
|
|
306
314
|
if (start.value !== '') {
|
|
307
315
|
return;
|
|
308
316
|
}
|
|
@@ -374,7 +382,7 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
374
382
|
}, [maxDate]);
|
|
375
383
|
useEffect(function () {
|
|
376
384
|
if (calendarRef.current && disable) {
|
|
377
|
-
calendarRef.current.set('
|
|
385
|
+
calendarRef.current.set('disable', disable);
|
|
378
386
|
}
|
|
379
387
|
}, [disable]);
|
|
380
388
|
useEffect(function () {
|
|
@@ -0,0 +1,67 @@
|
|
|
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 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
14
|
+
import { Calendar } from '@carbon/icons-react';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["className", "datePickerType"];
|
|
17
|
+
|
|
18
|
+
function FluidDatePickerSkeleton(_ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
_ref$datePickerType = _ref.datePickerType,
|
|
21
|
+
datePickerType = _ref$datePickerType === void 0 ? 'single' : _ref$datePickerType,
|
|
22
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
|
|
24
|
+
var prefix = usePrefix();
|
|
25
|
+
var classNames = cx(className, "".concat(prefix, "--form-item ").concat(prefix, "--date-picker--fluid__skeleton"), _defineProperty({}, "".concat(prefix, "--date-picker--fluid__skeleton--range"), datePickerType === 'range'));
|
|
26
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
isFluid: true
|
|
29
|
+
}
|
|
30
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
31
|
+
className: classNames
|
|
32
|
+
}, other), /*#__PURE__*/React__default.createElement("div", {
|
|
33
|
+
className: "".concat(prefix, "--date-picker--fluid__skeleton--container")
|
|
34
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
35
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
36
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
37
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
38
|
+
}), datePickerType !== 'simple' && /*#__PURE__*/React__default.createElement(Calendar, {
|
|
39
|
+
className: "".concat(prefix, "--date-picker__icon"),
|
|
40
|
+
role: "img",
|
|
41
|
+
"aria-hidden": "true"
|
|
42
|
+
})), datePickerType === 'range' && /*#__PURE__*/React__default.createElement("div", {
|
|
43
|
+
className: "".concat(prefix, "--date-picker--fluid__skeleton--container")
|
|
44
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
45
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
46
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
47
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
48
|
+
}), /*#__PURE__*/React__default.createElement(Calendar, {
|
|
49
|
+
className: "".concat(prefix, "--date-picker__icon"),
|
|
50
|
+
role: "img",
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}))));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
FluidDatePickerSkeleton.propTypes = {
|
|
56
|
+
/**
|
|
57
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
58
|
+
*/
|
|
59
|
+
className: PropTypes.string,
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Specify which variant of the DatePicker the skeleton should mimic
|
|
63
|
+
*/
|
|
64
|
+
datePickerType: PropTypes.oneOf(['simple', 'single', 'range'])
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { FluidDatePickerSkeleton as default };
|
|
@@ -28,14 +28,15 @@ function ListBoxSelection(_ref) {
|
|
|
28
28
|
selectionCount = _ref.selectionCount,
|
|
29
29
|
t = _ref.translateWithId,
|
|
30
30
|
disabled = _ref.disabled,
|
|
31
|
-
onClearSelection = _ref.onClearSelection
|
|
31
|
+
onClearSelection = _ref.onClearSelection,
|
|
32
|
+
readOnly = _ref.readOnly;
|
|
32
33
|
var prefix = usePrefix();
|
|
33
34
|
var className = cx("".concat(prefix, "--list-box__selection"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--tag--filter"), selectionCount), _defineProperty(_cx, "".concat(prefix, "--list-box__selection--multi"), selectionCount), _cx));
|
|
34
35
|
|
|
35
36
|
var handleOnClick = function handleOnClick(event) {
|
|
36
37
|
event.stopPropagation();
|
|
37
38
|
|
|
38
|
-
if (disabled) {
|
|
39
|
+
if (disabled || readOnly) {
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -49,7 +50,7 @@ function ListBoxSelection(_ref) {
|
|
|
49
50
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
50
51
|
event.stopPropagation();
|
|
51
52
|
|
|
52
|
-
if (disabled) {
|
|
53
|
+
if (disabled || readOnly) {
|
|
53
54
|
return;
|
|
54
55
|
} // When a user hits ENTER, we'll clear the selection
|
|
55
56
|
|
|
@@ -78,7 +79,8 @@ function ListBoxSelection(_ref) {
|
|
|
78
79
|
onKeyDown: handleOnKeyDown,
|
|
79
80
|
disabled: disabled,
|
|
80
81
|
"aria-label": t('clear.all'),
|
|
81
|
-
title: description
|
|
82
|
+
title: description,
|
|
83
|
+
"aria-disabled": readOnly ? true : undefined
|
|
82
84
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)))) : /*#__PURE__*/React__default.createElement("div", {
|
|
83
85
|
role: "button",
|
|
84
86
|
className: className,
|
|
@@ -125,6 +127,11 @@ ListBoxSelection.propTypes = {
|
|
|
125
127
|
*/
|
|
126
128
|
onKeyDown: PropTypes.func,
|
|
127
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Whether or not the Dropdown is readonly
|
|
132
|
+
*/
|
|
133
|
+
readOnly: PropTypes.bool,
|
|
134
|
+
|
|
128
135
|
/**
|
|
129
136
|
* Specify an optional `selectionCount` value that will be used to determine
|
|
130
137
|
* whether the selection should display a badge or a single clear icon.
|
|
@@ -73,7 +73,8 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
73
73
|
onChange = _ref.onChange,
|
|
74
74
|
onMenuChange = _ref.onMenuChange,
|
|
75
75
|
direction = _ref.direction,
|
|
76
|
-
selected = _ref.selectedItems
|
|
76
|
+
selected = _ref.selectedItems,
|
|
77
|
+
readOnly = _ref.readOnly;
|
|
77
78
|
var prefix = usePrefix();
|
|
78
79
|
|
|
79
80
|
var _useContext = useContext(FormContext),
|
|
@@ -164,7 +165,7 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
164
165
|
var helperId = !helperText ? undefined : "multiselect-helper-text-".concat(multiSelectInstanceId);
|
|
165
166
|
var fieldLabelId = "multiselect-field-label-".concat(multiSelectInstanceId);
|
|
166
167
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
167
|
-
var className = cx("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx4)); // needs to be capitalized for react to render it correctly
|
|
168
|
+
var className = cx("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx4, "".concat(prefix, "--multi-select--readonly"), readOnly), _cx4)); // needs to be capitalized for react to render it correctly
|
|
168
169
|
|
|
169
170
|
var ItemToElement = itemToElement;
|
|
170
171
|
var sortOptions = {
|
|
@@ -229,6 +230,21 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
229
230
|
evt.target.classList.contains("".concat(prefix, "--tag__close-icon")) ? setIsFocused(false) : setIsFocused(evt.type === 'focus' ? true : false);
|
|
230
231
|
};
|
|
231
232
|
|
|
233
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
234
|
+
onClick: function onClick(evt) {
|
|
235
|
+
// NOTE: does not prevent click
|
|
236
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
237
|
+
|
|
238
|
+
evt.target.focus();
|
|
239
|
+
},
|
|
240
|
+
onKeyDown: function onKeyDown(evt) {
|
|
241
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
242
|
+
|
|
243
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
244
|
+
evt.preventDefault();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} : {};
|
|
232
248
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
233
249
|
className: wrapperClasses
|
|
234
250
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -242,6 +258,7 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
242
258
|
size: size,
|
|
243
259
|
className: className,
|
|
244
260
|
disabled: disabled,
|
|
261
|
+
readOnly: readOnly,
|
|
245
262
|
light: light,
|
|
246
263
|
invalid: invalid,
|
|
247
264
|
invalidText: invalidText,
|
|
@@ -257,12 +274,13 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
257
274
|
type: "button",
|
|
258
275
|
className: "".concat(prefix, "--list-box__field"),
|
|
259
276
|
disabled: disabled,
|
|
260
|
-
"aria-disabled": disabled
|
|
277
|
+
"aria-disabled": disabled || readOnly
|
|
261
278
|
}, toggleButtonProps, {
|
|
262
279
|
ref: mergeRefs(toggleButtonProps.ref, ref),
|
|
263
280
|
onKeyDown: onKeyDown
|
|
264
|
-
}), selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
|
|
265
|
-
|
|
281
|
+
}, readOnlyEventHandlers), selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
|
|
282
|
+
readOnly: readOnly,
|
|
283
|
+
clearSelection: !disabled && !readOnly ? clearSelection : noop,
|
|
266
284
|
selectionCount: selectedItems.length,
|
|
267
285
|
translateWithId: translateWithId,
|
|
268
286
|
disabled: disabled
|
|
@@ -413,6 +431,11 @@ MultiSelect.propTypes = _objectSpread2(_objectSpread2({}, sortingPropTypes), {},
|
|
|
413
431
|
*/
|
|
414
432
|
open: PropTypes.bool,
|
|
415
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Whether or not the Dropdown is readonly
|
|
436
|
+
*/
|
|
437
|
+
readOnly: PropTypes.bool,
|
|
438
|
+
|
|
416
439
|
/**
|
|
417
440
|
* For full control of the selected items
|
|
418
441
|
*/
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
9
8
|
import { OverflowMenu as OverflowMenu$1 } from './OverflowMenu.js';
|
|
10
9
|
import { createClassWrapper } from '../../internal/createClassWrapper.js';
|
|
11
10
|
|
|
12
|
-
var OverflowMenu =
|
|
11
|
+
var OverflowMenu = createClassWrapper(OverflowMenu$1);
|
|
13
12
|
|
|
14
13
|
export { OverflowMenu as default };
|
|
@@ -28,7 +28,8 @@ var SkeletonPlaceholder = function SkeletonPlaceholder(_ref) {
|
|
|
28
28
|
|
|
29
29
|
SkeletonPlaceholder.propTypes = {
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Add a custom class to the component
|
|
32
|
+
* to set the height and width
|
|
32
33
|
*/
|
|
33
34
|
className: PropTypes.string
|
|
34
35
|
};
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { useState } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
|
-
import
|
|
12
|
+
import { useId } from '../../internal/useId.js';
|
|
13
13
|
import deprecate from '../../prop-types/deprecate.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["children", "selection", "className", "ariaLabel", "isCondensed", "isFlush"
|
|
16
|
+
var _excluded = ["children", "selection", "className", "ariaLabel", "isCondensed", "isFlush"],
|
|
17
17
|
_excluded2 = ["children", "className"],
|
|
18
18
|
_excluded3 = ["children", "className"],
|
|
19
|
-
_excluded4 = ["onKeyDown", "
|
|
20
|
-
_excluded5 = ["className", "
|
|
19
|
+
_excluded4 = ["onKeyDown", "children", "className", "head"],
|
|
20
|
+
_excluded5 = ["className", "name", "title", "id"],
|
|
21
21
|
_excluded6 = ["children", "className", "head", "noWrap"];
|
|
22
|
-
var
|
|
22
|
+
var GridSelectedRowStateContext = /*#__PURE__*/React__default.createContext(null);
|
|
23
|
+
var GridSelectedRowDispatchContext = /*#__PURE__*/React__default.createContext(null);
|
|
23
24
|
function StructuredListWrapper(props) {
|
|
24
25
|
var _classNames;
|
|
25
26
|
|
|
@@ -28,18 +29,27 @@ function StructuredListWrapper(props) {
|
|
|
28
29
|
className = props.className,
|
|
29
30
|
ariaLabel = props.ariaLabel,
|
|
30
31
|
isCondensed = props.isCondensed,
|
|
31
|
-
isFlush = props.isFlush
|
|
32
|
-
props
|
|
33
|
-
var other = _objectWithoutProperties(props, _excluded);
|
|
32
|
+
isFlush = props.isFlush,
|
|
33
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
34
34
|
|
|
35
35
|
var prefix = usePrefix();
|
|
36
36
|
var classes = cx("".concat(prefix, "--structured-list"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--structured-list--selection"), selection), _defineProperty(_classNames, "".concat(prefix, "--structured-list--condensed"), isCondensed), _defineProperty(_classNames, "".concat(prefix, "--structured-list--flush"), isFlush), _classNames));
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
var _React$useState = React__default.useState(null),
|
|
39
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
40
|
+
selectedRow = _React$useState2[0],
|
|
41
|
+
setSelectedRow = _React$useState2[1];
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React__default.createElement(GridSelectedRowStateContext.Provider, {
|
|
44
|
+
value: selectedRow
|
|
45
|
+
}, /*#__PURE__*/React__default.createElement(GridSelectedRowDispatchContext.Provider, {
|
|
46
|
+
value: setSelectedRow
|
|
47
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
38
48
|
role: "table",
|
|
39
49
|
className: classes
|
|
40
50
|
}, other, {
|
|
41
51
|
"aria-label": ariaLabel
|
|
42
|
-
}), children);
|
|
52
|
+
}), children)));
|
|
43
53
|
}
|
|
44
54
|
StructuredListWrapper.propTypes = {
|
|
45
55
|
/**
|
|
@@ -47,11 +57,6 @@ StructuredListWrapper.propTypes = {
|
|
|
47
57
|
*/
|
|
48
58
|
ariaLabel: PropTypes.string,
|
|
49
59
|
|
|
50
|
-
/**
|
|
51
|
-
* Specify whether a border should be added to your StructuredListWrapper
|
|
52
|
-
*/
|
|
53
|
-
border: deprecate(PropTypes.bool, "\nThe prop `border` will be removed in the next major version of Carbon."),
|
|
54
|
-
|
|
55
60
|
/**
|
|
56
61
|
* Provide the contents of your StructuredListWrapper
|
|
57
62
|
*/
|
|
@@ -79,9 +84,9 @@ StructuredListWrapper.propTypes = {
|
|
|
79
84
|
};
|
|
80
85
|
StructuredListWrapper.defaultProps = {
|
|
81
86
|
selection: false,
|
|
82
|
-
ariaLabel: 'Structured list section',
|
|
83
87
|
isCondensed: false,
|
|
84
|
-
isFlush: false
|
|
88
|
+
isFlush: false,
|
|
89
|
+
ariaLabel: 'Structured list section'
|
|
85
90
|
};
|
|
86
91
|
function StructuredListHead(props) {
|
|
87
92
|
var children = props.children,
|
|
@@ -138,29 +143,51 @@ StructuredListBody.propTypes = {
|
|
|
138
143
|
StructuredListBody.defaultProps = {
|
|
139
144
|
onKeyDown: function onKeyDown() {}
|
|
140
145
|
};
|
|
146
|
+
var GridRowContext = /*#__PURE__*/React__default.createContext(null);
|
|
141
147
|
function StructuredListRow(props) {
|
|
148
|
+
var _classNames2;
|
|
149
|
+
|
|
142
150
|
var onKeyDown = props.onKeyDown,
|
|
143
|
-
tabIndex = props.tabIndex,
|
|
144
151
|
children = props.children,
|
|
145
152
|
className = props.className,
|
|
146
153
|
head = props.head,
|
|
147
|
-
label = props.label,
|
|
148
154
|
other = _objectWithoutProperties(props, _excluded4);
|
|
149
155
|
|
|
156
|
+
var _useState = useState(false),
|
|
157
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
158
|
+
hasFocusWithin = _useState2[0],
|
|
159
|
+
setHasFocusWithin = _useState2[1];
|
|
160
|
+
|
|
161
|
+
var id = useId('grid-input');
|
|
162
|
+
var setSelectedRow = React__default.useContext(GridSelectedRowDispatchContext);
|
|
150
163
|
var prefix = usePrefix();
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
React__default.createElement("
|
|
156
|
-
tabIndex: tabIndex,
|
|
157
|
-
className: classes,
|
|
158
|
-
onKeyDown: onKeyDown
|
|
159
|
-
}), children) : /*#__PURE__*/React__default.createElement("div", _extends({
|
|
164
|
+
var value = {
|
|
165
|
+
id: id
|
|
166
|
+
};
|
|
167
|
+
var classes = cx("".concat(prefix, "--structured-list-row"), className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--header-row"), head), _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--focused-within"), hasFocusWithin), _classNames2));
|
|
168
|
+
return head ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
160
169
|
role: "row"
|
|
161
170
|
}, other, {
|
|
162
171
|
className: classes
|
|
163
|
-
}), children)
|
|
172
|
+
}), children) :
|
|
173
|
+
/*#__PURE__*/
|
|
174
|
+
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
175
|
+
React__default.createElement("div", _extends({}, other, {
|
|
176
|
+
role: "row",
|
|
177
|
+
className: classes,
|
|
178
|
+
onClick: function onClick() {
|
|
179
|
+
return setSelectedRow(id);
|
|
180
|
+
},
|
|
181
|
+
onFocus: function onFocus() {
|
|
182
|
+
setHasFocusWithin(true);
|
|
183
|
+
},
|
|
184
|
+
onBlur: function onBlur() {
|
|
185
|
+
setHasFocusWithin(false);
|
|
186
|
+
},
|
|
187
|
+
onKeyDown: onKeyDown
|
|
188
|
+
}), /*#__PURE__*/React__default.createElement(GridRowContext.Provider, {
|
|
189
|
+
value: value
|
|
190
|
+
}, children));
|
|
164
191
|
}
|
|
165
192
|
StructuredListRow.propTypes = {
|
|
166
193
|
/**
|
|
@@ -181,42 +208,44 @@ StructuredListRow.propTypes = {
|
|
|
181
208
|
/**
|
|
182
209
|
* Specify whether a `<label>` should be used
|
|
183
210
|
*/
|
|
184
|
-
label: PropTypes.bool,
|
|
211
|
+
label: deprecate(PropTypes.bool, "\nThe `label` prop is no longer needed and will be removed in the next major version of Carbon."),
|
|
185
212
|
|
|
186
213
|
/**
|
|
187
214
|
* Provide a handler that is invoked on the key down event for the control,
|
|
188
|
-
* if `<label>` is in use
|
|
189
|
-
*/
|
|
190
|
-
onKeyDown: PropTypes.func,
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Specify the tab index of the container node, if `<label>` is in use
|
|
194
215
|
*/
|
|
195
|
-
|
|
216
|
+
onKeyDown: PropTypes.func
|
|
196
217
|
};
|
|
197
218
|
StructuredListRow.defaultProps = {
|
|
198
219
|
head: false,
|
|
199
|
-
label: false,
|
|
200
|
-
tabIndex: 0,
|
|
201
220
|
onKeyDown: function onKeyDown() {}
|
|
202
221
|
};
|
|
203
222
|
function StructuredListInput(props) {
|
|
223
|
+
var _row$id;
|
|
224
|
+
|
|
225
|
+
var defaultId = useId('structureListInput');
|
|
226
|
+
|
|
204
227
|
var className = props.className,
|
|
205
|
-
|
|
206
|
-
name =
|
|
228
|
+
_props$name = props.name,
|
|
229
|
+
name = _props$name === void 0 ? "structured-list-input-".concat(defaultId) : _props$name,
|
|
207
230
|
title = props.title,
|
|
208
231
|
id = props.id,
|
|
209
232
|
other = _objectWithoutProperties(props, _excluded5);
|
|
210
233
|
|
|
211
234
|
var prefix = usePrefix();
|
|
212
|
-
var classes = cx("".concat(prefix, "--structured-list-input"), className);
|
|
213
|
-
var
|
|
235
|
+
var classes = cx("".concat(prefix, "--structured-list-input"), "".concat(prefix, "--visually-hidden"), className);
|
|
236
|
+
var row = React__default.useContext(GridRowContext);
|
|
237
|
+
var selectedRow = React__default.useContext(GridSelectedRowStateContext);
|
|
238
|
+
var setSelectedRow = React__default.useContext(GridSelectedRowDispatchContext);
|
|
214
239
|
return /*#__PURE__*/React__default.createElement("input", _extends({}, other, {
|
|
215
240
|
type: "radio",
|
|
216
|
-
tabIndex:
|
|
217
|
-
|
|
241
|
+
tabIndex: 0,
|
|
242
|
+
checked: row && row.id === selectedRow,
|
|
243
|
+
value: (_row$id = row === null || row === void 0 ? void 0 : row.id) !== null && _row$id !== void 0 ? _row$id : '',
|
|
244
|
+
onChange: function onChange(event) {
|
|
245
|
+
setSelectedRow(event.target.value);
|
|
246
|
+
},
|
|
247
|
+
id: id !== null && id !== void 0 ? id : defaultId,
|
|
218
248
|
className: classes,
|
|
219
|
-
value: value,
|
|
220
249
|
name: name,
|
|
221
250
|
title: title
|
|
222
251
|
}));
|
|
@@ -230,7 +259,7 @@ StructuredListInput.propTypes = {
|
|
|
230
259
|
/**
|
|
231
260
|
* Specify whether the underlying input should be checked by default
|
|
232
261
|
*/
|
|
233
|
-
defaultChecked: PropTypes.bool,
|
|
262
|
+
defaultChecked: deprecate(PropTypes.bool, "\nThe prop `defaultChecked` is no longer needed and will be removed in the next major version of Carbon."),
|
|
234
263
|
|
|
235
264
|
/**
|
|
236
265
|
* Specify a custom `id` for the input
|
|
@@ -245,7 +274,7 @@ StructuredListInput.propTypes = {
|
|
|
245
274
|
/**
|
|
246
275
|
* Provide an optional hook that is called each time the input is updated
|
|
247
276
|
*/
|
|
248
|
-
onChange: PropTypes.func,
|
|
277
|
+
onChange: deprecate(PropTypes.func, "\nThe prop `onChange` will be removed in the next major version of Carbon."),
|
|
249
278
|
|
|
250
279
|
/**
|
|
251
280
|
* Provide a `title` for the input
|
|
@@ -255,11 +284,9 @@ StructuredListInput.propTypes = {
|
|
|
255
284
|
/**
|
|
256
285
|
* Specify the value of the input
|
|
257
286
|
*/
|
|
258
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
287
|
+
value: deprecate(PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, "\nThe prop `value` will be removed in the next major version of Carbon.")
|
|
259
288
|
};
|
|
260
289
|
StructuredListInput.defaultProps = {
|
|
261
|
-
onChange: function onChange() {},
|
|
262
|
-
value: 'value',
|
|
263
290
|
title: 'title'
|
|
264
291
|
};
|
|
265
292
|
function StructuredListCell(props) {
|
|
@@ -273,9 +300,17 @@ function StructuredListCell(props) {
|
|
|
273
300
|
|
|
274
301
|
var prefix = usePrefix();
|
|
275
302
|
var classes = cx(className, (_classNames3 = {}, _defineProperty(_classNames3, "".concat(prefix, "--structured-list-th"), head), _defineProperty(_classNames3, "".concat(prefix, "--structured-list-td"), !head), _defineProperty(_classNames3, "".concat(prefix, "--structured-list-content--nowrap"), noWrap), _classNames3));
|
|
303
|
+
|
|
304
|
+
if (head) {
|
|
305
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({
|
|
306
|
+
className: classes,
|
|
307
|
+
role: "columnheader"
|
|
308
|
+
}, other), children);
|
|
309
|
+
}
|
|
310
|
+
|
|
276
311
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
277
312
|
className: classes,
|
|
278
|
-
role:
|
|
313
|
+
role: "cell"
|
|
279
314
|
}, other), children);
|
|
280
315
|
}
|
|
281
316
|
StructuredListCell.propTypes = {
|
package/es/index.js
CHANGED
|
@@ -66,7 +66,6 @@ export { default as SelectItem } from './components/SelectItem/SelectItem.js';
|
|
|
66
66
|
export { default as SelectItemGroup } from './components/SelectItemGroup/SelectItemGroup.js';
|
|
67
67
|
export { default as Switch } from './components/Switch/Switch.js';
|
|
68
68
|
export { default as Slider } from './components/Slider/index.js';
|
|
69
|
-
export { StructuredListBody, StructuredListCell, StructuredListHead, StructuredListInput, StructuredListRow, StructuredListWrapper } from './components/StructuredList/index.js';
|
|
70
69
|
export { default as Tab } from './components/Tab/index.js';
|
|
71
70
|
export { default as TabContent } from './components/TabContent/TabContent.js';
|
|
72
71
|
export { IconTab, TabList, TabPanel, TabPanels, Tabs } from './components/Tabs/Tabs.js';
|
|
@@ -123,6 +122,7 @@ export { default as SideNavIcon } from './components/UIShell/SideNavIcon.js';
|
|
|
123
122
|
export { default as SideNavItem } from './components/UIShell/SideNavItem.js';
|
|
124
123
|
export { default as SideNavLinkText } from './components/UIShell/SideNavLinkText.js';
|
|
125
124
|
export { default as unstable_useContextMenu } from './components/ContextMenu/useContextMenu.js';
|
|
125
|
+
export { default as unstable__FluidDatePickerSkeleton } from './components/FluidDatePicker/FluidDatePicker.Skeleton.js';
|
|
126
126
|
export { default as unstable__FluidTextArea } from './components/FluidTextArea/FluidTextArea.js';
|
|
127
127
|
export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
|
|
128
128
|
export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
|
|
@@ -176,6 +176,7 @@ export { NumberInput } from './components/NumberInput/NumberInput.js';
|
|
|
176
176
|
export { default as ControlledPasswordInput } from './components/TextInput/ControlledPasswordInput.js';
|
|
177
177
|
export { default as PasswordInput } from './components/TextInput/PasswordInput.js';
|
|
178
178
|
export { ProgressIndicator, ProgressStep } from './components/ProgressIndicator/ProgressIndicator.js';
|
|
179
|
+
export { StructuredListBody, StructuredListCell, StructuredListHead, StructuredListInput, StructuredListRow, StructuredListWrapper } from './components/StructuredList/StructuredList.js';
|
|
179
180
|
export { default as StructuredListSkeleton } from './components/StructuredList/StructuredList.Skeleton.js';
|
|
180
181
|
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent } from './components/Tile/Tile.js';
|
|
181
182
|
export { default as Content } from './components/UIShell/Content.js';
|
|
@@ -480,4 +480,6 @@ _defineProperty(FloatingMenu, "defaultProps", {
|
|
|
480
480
|
updateOrientation: null
|
|
481
481
|
});
|
|
482
482
|
|
|
483
|
-
|
|
483
|
+
var FloatingMenu$1 = FloatingMenu;
|
|
484
|
+
|
|
485
|
+
export { DIRECTION_BOTTOM, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_TOP, FloatingMenu$1 as default };
|
|
@@ -303,6 +303,10 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
303
303
|
calendarRef.current = calendar;
|
|
304
304
|
|
|
305
305
|
function handleArrowDown(event) {
|
|
306
|
+
if (match.match(event, keys.Escape)) {
|
|
307
|
+
calendar.calendarContainer.classList.remove('open');
|
|
308
|
+
}
|
|
309
|
+
|
|
306
310
|
if (match.match(event, keys.ArrowDown)) {
|
|
307
311
|
var calendarContainer = calendar.calendarContainer,
|
|
308
312
|
fpSelectedDateElem = calendar.selectedDateElem,
|
|
@@ -314,6 +318,10 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
function handleOnChange() {
|
|
321
|
+
if (datePickerType == 'single') {
|
|
322
|
+
calendar.calendarContainer.classList.remove('open');
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
if (start.value !== '') {
|
|
318
326
|
return;
|
|
319
327
|
}
|
|
@@ -385,7 +393,7 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
385
393
|
}, [maxDate]);
|
|
386
394
|
React.useEffect(function () {
|
|
387
395
|
if (calendarRef.current && disable) {
|
|
388
|
-
calendarRef.current.set('
|
|
396
|
+
calendarRef.current.set('disable', disable);
|
|
389
397
|
}
|
|
390
398
|
}, [disable]);
|
|
391
399
|
React.useEffect(function () {
|