@carbon/react 1.4.0 → 1.6.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/_virtual/_rollupPluginBabelHelpers.js +3 -5
- package/es/components/Button/Button.Skeleton.js +1 -1
- package/es/components/Checkbox/Checkbox.js +5 -5
- package/es/components/ComposedModal/ComposedModal.js +2 -1
- package/es/components/ComposedModal/next/ComposedModal.js +2 -1
- package/es/components/DataTable/TableActionList.js +3 -1
- package/es/components/DataTable/TableToolbarContent.js +3 -1
- package/es/components/DatePicker/DatePicker.js +14 -5
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/Filename.js +1 -1
- package/es/components/Link/Link.js +6 -3
- package/es/components/ListBox/ListBoxPropTypes.js +1 -2
- package/es/components/ListBox/ListBoxSelection.js +3 -4
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/ProgressIndicator/ProgressIndicator.js +1 -3
- package/es/components/RadioButton/next/RadioButton.js +2 -1
- package/es/components/Search/next/Search.js +1 -0
- package/es/components/Tabs/next/Tabs.js +42 -4
- package/es/components/Toggle/Toggle.js +147 -109
- package/es/components/TreeView/TreeNode.js +8 -0
- package/es/components/TreeView/TreeView.js +6 -4
- package/es/components/UIShell/HeaderGlobalBar.js +3 -1
- package/es/components/UIShell/SideNav.js +3 -3
- package/es/index.js +3 -2
- package/es/tools/wrapComponent.js +6 -4
- package/lib/_virtual/_rollupPluginBabelHelpers.js +3 -5
- package/lib/components/Button/Button.Skeleton.js +1 -1
- package/lib/components/Checkbox/Checkbox.js +5 -5
- package/lib/components/ComposedModal/ComposedModal.js +2 -1
- package/lib/components/ComposedModal/next/ComposedModal.js +2 -1
- package/lib/components/DataTable/TableActionList.js +3 -1
- package/lib/components/DataTable/TableToolbarContent.js +3 -1
- package/lib/components/DatePicker/DatePicker.js +14 -5
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/Filename.js +1 -1
- package/lib/components/Link/Link.js +6 -3
- package/lib/components/ListBox/ListBoxPropTypes.js +1 -21
- package/lib/components/ListBox/ListBoxSelection.js +3 -4
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -3
- package/lib/components/RadioButton/next/RadioButton.js +2 -1
- package/lib/components/Search/next/Search.js +1 -0
- package/lib/components/Tabs/next/Tabs.js +42 -4
- package/lib/components/Toggle/Toggle.js +146 -107
- package/lib/components/TreeView/TreeNode.js +8 -0
- package/lib/components/TreeView/TreeView.js +6 -4
- package/lib/components/UIShell/HeaderGlobalBar.js +3 -1
- package/lib/components/UIShell/SideNav.js +3 -3
- package/lib/index.js +70 -68
- package/lib/tools/wrapComponent.js +6 -4
- package/package.json +26 -26
- package/es/components/Toggle/index.js +0 -19
- package/es/components/Toggle/next/Toggle.js +0 -158
- package/lib/components/Toggle/index.js +0 -23
- package/lib/components/Toggle/next/Toggle.js +0 -169
|
@@ -82,7 +82,7 @@ function _defineProperty(obj, key, value) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function _extends() {
|
|
85
|
-
_extends = Object.assign
|
|
85
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
86
86
|
for (var i = 1; i < arguments.length; i++) {
|
|
87
87
|
var source = arguments[i];
|
|
88
88
|
|
|
@@ -95,7 +95,6 @@ function _extends() {
|
|
|
95
95
|
|
|
96
96
|
return target;
|
|
97
97
|
};
|
|
98
|
-
|
|
99
98
|
return _extends.apply(this, arguments);
|
|
100
99
|
}
|
|
101
100
|
|
|
@@ -118,18 +117,17 @@ function _inherits(subClass, superClass) {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
function _getPrototypeOf(o) {
|
|
121
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
120
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
122
121
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
123
122
|
};
|
|
124
123
|
return _getPrototypeOf(o);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
function _setPrototypeOf(o, p) {
|
|
128
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
127
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
129
128
|
o.__proto__ = p;
|
|
130
129
|
return o;
|
|
131
130
|
};
|
|
132
|
-
|
|
133
131
|
return _setPrototypeOf(o, p);
|
|
134
132
|
}
|
|
135
133
|
|
|
@@ -26,7 +26,7 @@ var ButtonSkeleton = function ButtonSkeleton(_ref) {
|
|
|
26
26
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
27
|
|
|
28
28
|
var prefix = usePrefix();
|
|
29
|
-
var buttonClasses = cx(className, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--skeleton"), true), _defineProperty(_cx, "".concat(prefix, "--btn"), true), _defineProperty(_cx, "".concat(prefix, "--btn--sm"), small || size === 'sm'), _defineProperty(_cx, "".concat(prefix, "--btn--md"), size === 'field' || size === 'md'), _defineProperty(_cx, "".concat(prefix, "--btn--xl"), size === 'xl'), _defineProperty(_cx, "".concat(prefix, "--btn--2xl"), size === '2xl'), _cx));
|
|
29
|
+
var buttonClasses = cx(className, (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--skeleton"), true), _defineProperty(_cx, "".concat(prefix, "--btn"), true), _defineProperty(_cx, "".concat(prefix, "--btn--sm"), small || size === 'sm'), _defineProperty(_cx, "".concat(prefix, "--btn--md"), size === 'field' || size === 'md'), _defineProperty(_cx, "".concat(prefix, "--btn--lg"), size === 'lg'), _defineProperty(_cx, "".concat(prefix, "--btn--xl"), size === 'xl'), _defineProperty(_cx, "".concat(prefix, "--btn--2xl"), size === '2xl'), _cx));
|
|
30
30
|
|
|
31
31
|
var commonProps = _objectSpread2({
|
|
32
32
|
className: buttonClasses
|
|
@@ -26,9 +26,8 @@ var Checkbox = /*#__PURE__*/React__default.forwardRef(function Checkbox(_ref, _r
|
|
|
26
26
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
27
27
|
|
|
28
28
|
var prefix = usePrefix();
|
|
29
|
-
var labelClasses = cx("".concat(prefix, "--checkbox-label"), [className]);
|
|
30
|
-
var innerLabelClasses = cx("".concat(prefix, "--checkbox-label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
31
29
|
var wrapperClasses = cx("".concat(prefix, "--form-item"), "".concat(prefix, "--checkbox-wrapper"), [className]);
|
|
30
|
+
var innerLabelClasses = cx("".concat(prefix, "--checkbox-label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
32
31
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
33
32
|
className: wrapperClasses
|
|
34
33
|
}, /*#__PURE__*/React__default.createElement("input", _extends({}, other, {
|
|
@@ -54,7 +53,7 @@ var Checkbox = /*#__PURE__*/React__default.forwardRef(function Checkbox(_ref, _r
|
|
|
54
53
|
}
|
|
55
54
|
})), /*#__PURE__*/React__default.createElement("label", {
|
|
56
55
|
htmlFor: id,
|
|
57
|
-
className:
|
|
56
|
+
className: "".concat(prefix, "--checkbox-label"),
|
|
58
57
|
title: title || null
|
|
59
58
|
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
60
59
|
className: innerLabelClasses
|
|
@@ -103,8 +102,9 @@ Checkbox.propTypes = {
|
|
|
103
102
|
labelText: PropTypes.node.isRequired,
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* Provide an optional handler that is called when the internal state of
|
|
106
|
+
* Checkbox changes. This handler is called with event and state info.
|
|
107
|
+
* `(event, { checked, id }) => void`
|
|
108
108
|
*/
|
|
109
109
|
onChange: PropTypes.func,
|
|
110
110
|
|
|
@@ -223,7 +223,8 @@ var ComposedModal = /*#__PURE__*/function (_Component) {
|
|
|
223
223
|
onClick: this.handleClick,
|
|
224
224
|
onKeyDown: this.handleKeyDown,
|
|
225
225
|
onTransitionEnd: open ? this.handleTransitionEnd : undefined,
|
|
226
|
-
className: modalClass
|
|
226
|
+
className: modalClass,
|
|
227
|
+
tabIndex: "-1"
|
|
227
228
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
228
229
|
ref: this.startSentinel,
|
|
229
230
|
tabIndex: "0",
|
|
@@ -194,7 +194,8 @@ var ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedModa
|
|
|
194
194
|
onBlur: handleBlur,
|
|
195
195
|
onClick: handleClick,
|
|
196
196
|
onKeyDown: handleKeyDown,
|
|
197
|
-
className: modalClass
|
|
197
|
+
className: modalClass,
|
|
198
|
+
tabIndex: "-1"
|
|
198
199
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
199
200
|
className: containerClass,
|
|
200
201
|
role: "dialog",
|
|
@@ -10,7 +10,9 @@ import wrapComponent from '../../tools/wrapComponent.js';
|
|
|
10
10
|
var TableActionList = wrapComponent({
|
|
11
11
|
name: 'TableActionList',
|
|
12
12
|
type: 'div',
|
|
13
|
-
className:
|
|
13
|
+
className: function className(prefix) {
|
|
14
|
+
return "".concat(prefix, "--action-list");
|
|
15
|
+
}
|
|
14
16
|
});
|
|
15
17
|
var TableActionList$1 = TableActionList;
|
|
16
18
|
|
|
@@ -10,7 +10,9 @@ import wrapComponent from '../../tools/wrapComponent.js';
|
|
|
10
10
|
var TableToolbarContent = wrapComponent({
|
|
11
11
|
name: 'TableToolbarContent',
|
|
12
12
|
type: 'div',
|
|
13
|
-
className:
|
|
13
|
+
className: function className(prefix) {
|
|
14
|
+
return "".concat(prefix, "--toolbar-content");
|
|
15
|
+
}
|
|
14
16
|
});
|
|
15
17
|
var TableToolbarContent$1 = TableToolbarContent;
|
|
16
18
|
|
|
@@ -20,7 +20,7 @@ import { useSavedCallback } from '../../internal/useSavedCallback.js';
|
|
|
20
20
|
import { match } from '../../internal/keyboard/match.js';
|
|
21
21
|
import { ArrowDown } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["allowInput", "appendTo", "children", "className", "dateFormat", "datePickerType", "disable", "enable", "inline", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "short", "value"];
|
|
23
|
+
var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "short", "value"];
|
|
24
24
|
|
|
25
25
|
l10n.en.weekdays.shorthand.forEach(function (_day, index) {
|
|
26
26
|
var currentDay = l10n.en.weekdays.shorthand;
|
|
@@ -152,6 +152,8 @@ function DatePicker(_ref) {
|
|
|
152
152
|
appendTo = _ref.appendTo,
|
|
153
153
|
children = _ref.children,
|
|
154
154
|
className = _ref.className,
|
|
155
|
+
_ref$closeOnSelect = _ref.closeOnSelect,
|
|
156
|
+
closeOnSelect = _ref$closeOnSelect === void 0 ? true : _ref$closeOnSelect,
|
|
155
157
|
_ref$dateFormat = _ref.dateFormat,
|
|
156
158
|
dateFormat = _ref$dateFormat === void 0 ? 'm/d/Y' : _ref$dateFormat,
|
|
157
159
|
datePickerType = _ref.datePickerType,
|
|
@@ -251,6 +253,7 @@ function DatePicker(_ref) {
|
|
|
251
253
|
inline: inline !== null && inline !== void 0 ? inline : false,
|
|
252
254
|
disableMobile: true,
|
|
253
255
|
defaultDate: value,
|
|
256
|
+
closeOnSelect: closeOnSelect,
|
|
254
257
|
mode: datePickerType,
|
|
255
258
|
allowInput: allowInput !== null && allowInput !== void 0 ? allowInput : true,
|
|
256
259
|
dateFormat: dateFormat,
|
|
@@ -311,7 +314,7 @@ function DatePicker(_ref) {
|
|
|
311
314
|
// error with IBM Equal Access Accessibility Checker so we add an aria
|
|
312
315
|
// role to the container div.
|
|
313
316
|
|
|
314
|
-
calendar.calendarContainer.setAttribute('role', '
|
|
317
|
+
calendar.calendarContainer.setAttribute('role', 'application'); // IBM EAAC requires an aria-label on a role='region'
|
|
315
318
|
|
|
316
319
|
calendar.calendarContainer.setAttribute('aria-label', 'calendar-container');
|
|
317
320
|
}
|
|
@@ -375,9 +378,10 @@ function DatePicker(_ref) {
|
|
|
375
378
|
}, [inline]);
|
|
376
379
|
useEffect(function () {
|
|
377
380
|
if (calendarRef.current) {
|
|
378
|
-
|
|
379
|
-
value
|
|
380
|
-
}
|
|
381
|
+
if (value !== undefined) {
|
|
382
|
+
calendarRef.current.setDate(value);
|
|
383
|
+
}
|
|
384
|
+
|
|
381
385
|
updateClassNames(calendarRef.current, prefix); //for simple date picker w/o calendar; initial mount may not have value
|
|
382
386
|
} else if (!calendarRef.current && value) {
|
|
383
387
|
startInputField.current.value = value;
|
|
@@ -412,6 +416,11 @@ DatePicker.propTypes = {
|
|
|
412
416
|
*/
|
|
413
417
|
className: PropTypes.string,
|
|
414
418
|
|
|
419
|
+
/**
|
|
420
|
+
* flatpickr prop passthrough. Controls whether the calendar dropdown closes upon selection.
|
|
421
|
+
*/
|
|
422
|
+
closeOnSelect: PropTypes.bool,
|
|
423
|
+
|
|
415
424
|
/**
|
|
416
425
|
* The date format.
|
|
417
426
|
*/
|
|
@@ -224,7 +224,7 @@ _defineProperty(FileUploader, "propTypes", {
|
|
|
224
224
|
iconDescription: FeatureFlags.enabled('enable-v11-release') ? PropTypes.string.isRequired : PropTypes.string,
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
* Specify the description text of this
|
|
227
|
+
* Specify the description text of this `<FileUploader>`
|
|
228
228
|
*/
|
|
229
229
|
labelDescription: PropTypes.string,
|
|
230
230
|
|
|
@@ -18,9 +18,12 @@ var Link = /*#__PURE__*/React__default.forwardRef(function Link(_ref, ref) {
|
|
|
18
18
|
var children = _ref.children,
|
|
19
19
|
customClassName = _ref.className,
|
|
20
20
|
href = _ref.href,
|
|
21
|
-
disabled = _ref.disabled,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
_ref$disabled = _ref.disabled,
|
|
22
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
23
|
+
_ref$inline = _ref.inline,
|
|
24
|
+
inline = _ref$inline === void 0 ? false : _ref$inline,
|
|
25
|
+
_ref$visited = _ref.visited,
|
|
26
|
+
visited = _ref$visited === void 0 ? false : _ref$visited,
|
|
24
27
|
Icon = _ref.renderIcon,
|
|
25
28
|
size = _ref.size,
|
|
26
29
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
10
9
|
|
|
11
10
|
var ListBoxType = PropTypes.oneOf(['default', 'inline']);
|
|
12
|
-
var ListBoxSize =
|
|
11
|
+
var ListBoxSize = PropTypes.oneOf(['sm', 'md', 'lg']);
|
|
13
12
|
|
|
14
13
|
export { ListBoxSize, ListBoxType };
|
|
@@ -21,7 +21,7 @@ var _Close, _Close2, _defaultTranslations;
|
|
|
21
21
|
* selection.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
function ListBoxSelection(_ref) {
|
|
25
25
|
var _cx;
|
|
26
26
|
|
|
27
27
|
var clearSelection = _ref.clearSelection,
|
|
@@ -88,7 +88,7 @@ var ListBoxSelection = function ListBoxSelection(_ref) {
|
|
|
88
88
|
"aria-label": description,
|
|
89
89
|
title: description
|
|
90
90
|
}, selectionCount, _Close2 || (_Close2 = /*#__PURE__*/React__default.createElement(Close, null)));
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
|
|
93
93
|
var translationIds = {
|
|
94
94
|
'clear.all': 'clear.all',
|
|
@@ -143,6 +143,5 @@ ListBoxSelection.defaultProps = {
|
|
|
143
143
|
return defaultTranslations[id];
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
|
-
var ListBoxSelection$1 = ListBoxSelection;
|
|
147
146
|
|
|
148
|
-
export { ListBoxSelection
|
|
147
|
+
export { ListBoxSelection as default, translationIds };
|
|
@@ -356,7 +356,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
356
356
|
"aria-label": ariaLabel,
|
|
357
357
|
id: id,
|
|
358
358
|
ref: mergeRefs(this._triggerRef, ref)
|
|
359
|
-
}), /*#__PURE__*/React__default.createElement(IconElement, iconProps
|
|
359
|
+
}), /*#__PURE__*/React__default.createElement(IconElement, iconProps), open && wrappedMenuBody));
|
|
360
360
|
}
|
|
361
361
|
}], [{
|
|
362
362
|
key: "getDerivedStateFromProps",
|
|
@@ -53,8 +53,6 @@ function ProgressStep(_ref) {
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
var SVGIcon = function SVGIcon(_ref2) {
|
|
56
|
-
var _title;
|
|
57
|
-
|
|
58
56
|
var complete = _ref2.complete,
|
|
59
57
|
current = _ref2.current,
|
|
60
58
|
description = _ref2.description,
|
|
@@ -64,7 +62,7 @@ function ProgressStep(_ref) {
|
|
|
64
62
|
if (invalid) {
|
|
65
63
|
return /*#__PURE__*/React__default.createElement(Warning, {
|
|
66
64
|
className: "".concat(prefix, "--progress__warning")
|
|
67
|
-
},
|
|
65
|
+
}, /*#__PURE__*/React__default.createElement("title", null, description));
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
if (current) {
|
|
@@ -50,7 +50,8 @@ var RadioButton = /*#__PURE__*/React__default.forwardRef(function RadioButton(_r
|
|
|
50
50
|
id: uniqueId,
|
|
51
51
|
ref: ref,
|
|
52
52
|
disabled: disabled,
|
|
53
|
-
value: value
|
|
53
|
+
value: value,
|
|
54
|
+
name: name
|
|
54
55
|
})), /*#__PURE__*/React__default.createElement("label", {
|
|
55
56
|
htmlFor: uniqueId,
|
|
56
57
|
className: "".concat(prefix, "--radio-button__label")
|
|
@@ -143,6 +143,7 @@ var Search = /*#__PURE__*/React__default.forwardRef(function Search(_ref, forwar
|
|
|
143
143
|
className: clearClasses,
|
|
144
144
|
disabled: disabled,
|
|
145
145
|
onClick: clearInput,
|
|
146
|
+
title: closeButtonLabelText,
|
|
146
147
|
type: "button"
|
|
147
148
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null))));
|
|
148
149
|
});
|
|
@@ -597,6 +597,11 @@ var TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7, f
|
|
|
597
597
|
tabIndex = _useState8[0],
|
|
598
598
|
setTabIndex = _useState8[1];
|
|
599
599
|
|
|
600
|
+
var _useState9 = useState(false),
|
|
601
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
602
|
+
interactiveContent = _useState10[0],
|
|
603
|
+
setInteractiveContent = _useState10[1];
|
|
604
|
+
|
|
600
605
|
var _React$useContext3 = React__default.useContext(TabsContext),
|
|
601
606
|
selectedIndex = _React$useContext3.selectedIndex,
|
|
602
607
|
baseId = _React$useContext3.baseId;
|
|
@@ -604,14 +609,47 @@ var TabPanel = /*#__PURE__*/React__default.forwardRef(function TabPanel(_ref7, f
|
|
|
604
609
|
var index = React__default.useContext(TabPanelContext);
|
|
605
610
|
var id = "".concat(baseId, "-tabpanel-").concat(index);
|
|
606
611
|
var tabId = "".concat(baseId, "-tab-").concat(index);
|
|
607
|
-
var className = cx("".concat(prefix, "--tab-content"), customClassName
|
|
612
|
+
var className = cx("".concat(prefix, "--tab-content"), customClassName, _defineProperty({}, "".concat(prefix, "--tab-content--interactive"), interactiveContent));
|
|
613
|
+
useEffectOnce(function () {
|
|
614
|
+
if (!panel.current) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
608
617
|
|
|
609
|
-
|
|
610
|
-
var interactiveContent = getInteractiveContent(panel.current);
|
|
618
|
+
var content = getInteractiveContent(panel.current);
|
|
611
619
|
|
|
612
|
-
if (
|
|
620
|
+
if (content) {
|
|
621
|
+
setInteractiveContent(true);
|
|
613
622
|
setTabIndex('-1');
|
|
614
623
|
}
|
|
624
|
+
}); // tabindex should only be 0 if no interactive content in children
|
|
625
|
+
|
|
626
|
+
useEffect(function () {
|
|
627
|
+
if (!panel.current) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
var node = panel.current;
|
|
632
|
+
|
|
633
|
+
function callback() {
|
|
634
|
+
var content = getInteractiveContent(node);
|
|
635
|
+
|
|
636
|
+
if (content) {
|
|
637
|
+
setInteractiveContent(true);
|
|
638
|
+
setTabIndex('-1');
|
|
639
|
+
} else {
|
|
640
|
+
setInteractiveContent(false);
|
|
641
|
+
setTabIndex('0');
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
var observer = new MutationObserver(callback);
|
|
646
|
+
observer.observe(node, {
|
|
647
|
+
childList: true,
|
|
648
|
+
subtree: true
|
|
649
|
+
});
|
|
650
|
+
return function () {
|
|
651
|
+
observer.disconnect(node);
|
|
652
|
+
};
|
|
615
653
|
}, []);
|
|
616
654
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
617
655
|
"aria-labelledby": tabId,
|
|
@@ -5,116 +5,154 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
10
9
|
import React__default from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var checkedProps = {};
|
|
56
|
-
|
|
57
|
-
if (typeof toggled !== 'undefined') {
|
|
58
|
-
checkedProps.checked = toggled;
|
|
59
|
-
} else {
|
|
60
|
-
checkedProps.defaultChecked = defaultToggled;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
64
|
-
className: wrapperClasses
|
|
65
|
-
}, /*#__PURE__*/React__default.createElement("input", _extends({}, other, checkedProps, {
|
|
66
|
-
"aria-label": null,
|
|
67
|
-
type: "checkbox",
|
|
68
|
-
id: id,
|
|
69
|
-
className: toggleClasses,
|
|
70
|
-
onChange: function onChange(evt) {
|
|
71
|
-
_onChange && _onChange(evt);
|
|
72
|
-
onToggle(input.checked, id, evt);
|
|
73
|
-
},
|
|
74
|
-
ref: function ref(el) {
|
|
75
|
-
input = el;
|
|
76
|
-
},
|
|
77
|
-
onKeyUp: function onKeyUp(evt) {
|
|
78
|
-
if (match(evt, Enter)) {
|
|
79
|
-
input.checked = !input.checked;
|
|
80
|
-
_onChange && _onChange(evt);
|
|
81
|
-
onToggle(input.checked, id, evt);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})), /*#__PURE__*/React__default.createElement("label", {
|
|
85
|
-
className: "".concat(prefix, "--toggle-input__label"),
|
|
86
|
-
htmlFor: id,
|
|
87
|
-
"aria-label": typeof labelText === 'string' ? null : this.props['aria-label']
|
|
88
|
-
}, labelText, /*#__PURE__*/React__default.createElement("span", {
|
|
89
|
-
className: "".concat(prefix, "--toggle__switch")
|
|
90
|
-
}, size && /*#__PURE__*/React__default.createElement("svg", {
|
|
91
|
-
className: "".concat(prefix, "--toggle__check"),
|
|
92
|
-
width: "6px",
|
|
93
|
-
height: "5px",
|
|
94
|
-
viewBox: "0 0 6 5"
|
|
95
|
-
}, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
96
|
-
d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
|
|
97
|
-
}))), /*#__PURE__*/React__default.createElement("span", {
|
|
98
|
-
className: "".concat(prefix, "--toggle__text--off"),
|
|
99
|
-
"aria-hidden": "true"
|
|
100
|
-
}, labelA), /*#__PURE__*/React__default.createElement("span", {
|
|
101
|
-
className: "".concat(prefix, "--toggle__text--on"),
|
|
102
|
-
"aria-hidden": "true"
|
|
103
|
-
}, labelB))));
|
|
12
|
+
import { useControllableState } from '../../internal/useControllableState.js';
|
|
13
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
|
|
15
|
+
var _path;
|
|
16
|
+
|
|
17
|
+
var _excluded = ["className", "defaultToggled", "disabled", "hideLabel", "id", "labelA", "labelB", "labelText", "onClick", "onToggle", "size", "toggled"];
|
|
18
|
+
function Toggle(_ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
_ref$defaultToggled = _ref.defaultToggled,
|
|
21
|
+
defaultToggled = _ref$defaultToggled === void 0 ? false : _ref$defaultToggled,
|
|
22
|
+
_ref$disabled = _ref.disabled,
|
|
23
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
24
|
+
_ref$hideLabel = _ref.hideLabel,
|
|
25
|
+
hideLabel = _ref$hideLabel === void 0 ? false : _ref$hideLabel,
|
|
26
|
+
id = _ref.id,
|
|
27
|
+
_ref$labelA = _ref.labelA,
|
|
28
|
+
labelA = _ref$labelA === void 0 ? 'Off' : _ref$labelA,
|
|
29
|
+
_ref$labelB = _ref.labelB,
|
|
30
|
+
labelB = _ref$labelB === void 0 ? 'On' : _ref$labelB,
|
|
31
|
+
labelText = _ref.labelText,
|
|
32
|
+
onClick = _ref.onClick,
|
|
33
|
+
onToggle = _ref.onToggle,
|
|
34
|
+
_ref$size = _ref.size,
|
|
35
|
+
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
36
|
+
toggled = _ref.toggled,
|
|
37
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
|
|
39
|
+
var prefix = usePrefix();
|
|
40
|
+
|
|
41
|
+
var _useControllableState = useControllableState({
|
|
42
|
+
value: toggled,
|
|
43
|
+
onChange: onToggle,
|
|
44
|
+
defaultValue: defaultToggled
|
|
45
|
+
}),
|
|
46
|
+
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
|
47
|
+
checked = _useControllableState2[0],
|
|
48
|
+
setChecked = _useControllableState2[1];
|
|
49
|
+
|
|
50
|
+
function handleClick(e) {
|
|
51
|
+
setChecked(!checked);
|
|
52
|
+
|
|
53
|
+
if (onClick) {
|
|
54
|
+
onClick(e);
|
|
104
55
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return Toggle;
|
|
108
|
-
}(React__default.Component);
|
|
109
|
-
|
|
110
|
-
_defineProperty(Toggle, "propTypes", (_defineProperty2 = {}, _defineProperty(_defineProperty2, 'aria-label', PropTypes.string.isRequired), _defineProperty(_defineProperty2, "className", PropTypes.string), _defineProperty(_defineProperty2, "defaultToggled", PropTypes.bool), _defineProperty(_defineProperty2, "id", PropTypes.string.isRequired), _defineProperty(_defineProperty2, "labelA", PropTypes.node.isRequired), _defineProperty(_defineProperty2, "labelB", PropTypes.node.isRequired), _defineProperty(_defineProperty2, "labelText", PropTypes.node), _defineProperty(_defineProperty2, "onChange", PropTypes.func), _defineProperty(_defineProperty2, "onToggle", PropTypes.func), _defineProperty(_defineProperty2, "size", PropTypes.oneOf(['sm', 'md'])), _defineProperty(_defineProperty2, "toggled", PropTypes.bool), _defineProperty2));
|
|
111
|
-
|
|
112
|
-
_defineProperty(Toggle, "contextType", PrefixContext);
|
|
113
|
-
|
|
114
|
-
_defineProperty(Toggle, "defaultProps", (_defineProperty3 = {
|
|
115
|
-
defaultToggled: false
|
|
116
|
-
}, _defineProperty(_defineProperty3, 'aria-label', 'Toggle'), _defineProperty(_defineProperty3, "labelA", 'Off'), _defineProperty(_defineProperty3, "labelB", 'On'), _defineProperty(_defineProperty3, "onToggle", function onToggle() {}), _defineProperty3));
|
|
117
|
-
|
|
118
|
-
var ToggleClassic = Toggle;
|
|
56
|
+
}
|
|
119
57
|
|
|
120
|
-
|
|
58
|
+
var isSm = size === 'sm';
|
|
59
|
+
var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
|
|
60
|
+
var wrapperClasses = cx("".concat(prefix, "--toggle"), _defineProperty({}, "".concat(prefix, "--toggle--disabled"), disabled), className);
|
|
61
|
+
var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
62
|
+
var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
|
|
63
|
+
var switchClasses = cx("".concat(prefix, "--toggle__switch"), _defineProperty({}, "".concat(prefix, "--toggle__switch--checked"), checked));
|
|
64
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
65
|
+
className: wrapperClasses
|
|
66
|
+
}, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
|
|
67
|
+
id: id,
|
|
68
|
+
className: "".concat(prefix, "--toggle__button"),
|
|
69
|
+
role: "switch",
|
|
70
|
+
type: "button",
|
|
71
|
+
"aria-checked": checked,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
onClick: handleClick
|
|
74
|
+
})), /*#__PURE__*/React__default.createElement("label", {
|
|
75
|
+
htmlFor: id,
|
|
76
|
+
className: "".concat(prefix, "--toggle__label")
|
|
77
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
78
|
+
className: labelTextClasses
|
|
79
|
+
}, labelText), /*#__PURE__*/React__default.createElement("div", {
|
|
80
|
+
className: appearanceClasses
|
|
81
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
82
|
+
className: switchClasses
|
|
83
|
+
}, isSm && /*#__PURE__*/React__default.createElement("svg", {
|
|
84
|
+
className: "".concat(prefix, "--toggle__check"),
|
|
85
|
+
width: "6px",
|
|
86
|
+
height: "5px",
|
|
87
|
+
viewBox: "0 0 6 5"
|
|
88
|
+
}, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
89
|
+
d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
|
|
90
|
+
})))), /*#__PURE__*/React__default.createElement("span", {
|
|
91
|
+
className: "".concat(prefix, "--toggle__text"),
|
|
92
|
+
"aria-hidden": "true"
|
|
93
|
+
}, sideLabel))));
|
|
94
|
+
}
|
|
95
|
+
Toggle.propTypes = {
|
|
96
|
+
/**
|
|
97
|
+
* Specify a custom className to apply to the form-item node
|
|
98
|
+
*/
|
|
99
|
+
className: PropTypes.string,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Specify whether the toggle should be on by default
|
|
103
|
+
*/
|
|
104
|
+
defaultToggled: PropTypes.bool,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Whether this control should be disabled
|
|
108
|
+
*/
|
|
109
|
+
disabled: PropTypes.bool,
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Specify whether the label should be hidden, or not
|
|
113
|
+
*/
|
|
114
|
+
hideLabel: PropTypes.bool,
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Provide an id that unique represents the underlying `<button>`
|
|
118
|
+
*/
|
|
119
|
+
id: PropTypes.string.isRequired,
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Specify the label for the "off" position
|
|
123
|
+
*/
|
|
124
|
+
labelA: PropTypes.node,
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Specify the label for the "on" position
|
|
128
|
+
*/
|
|
129
|
+
labelB: PropTypes.node,
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
133
|
+
* control
|
|
134
|
+
*/
|
|
135
|
+
labelText: PropTypes.node.isRequired,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Provide an event listener that is called when the control is clicked
|
|
139
|
+
*/
|
|
140
|
+
onClick: PropTypes.func,
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Provide an event listener that is called when the control is toggled
|
|
144
|
+
*/
|
|
145
|
+
onToggle: PropTypes.func,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Specify the size of the Toggle. Currently only supports 'sm' or 'md' (default)
|
|
149
|
+
*/
|
|
150
|
+
size: PropTypes.oneOf(['sm', 'md']),
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Specify whether the control is toggled
|
|
154
|
+
*/
|
|
155
|
+
toggled: PropTypes.bool
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export { Toggle, Toggle as default };
|