@carbon/react 1.5.0 → 1.7.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/ComposedModal/ComposedModal.js +2 -1
- package/es/components/ComposedModal/next/ComposedModal.js +2 -1
- package/es/components/DataTable/TableToolbarSearch.js +10 -2
- 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/Form/Form.js +1 -1
- package/es/components/FormGroup/FormGroup.js +4 -4
- package/es/components/FormItem/FormItem.js +5 -6
- package/es/components/Layer/index.js +13 -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 +0 -1
- package/es/components/Popover/index.js +137 -8
- package/es/components/RadioButton/next/RadioButton.js +2 -1
- package/es/components/Select/Select.js +14 -7
- package/es/components/Tabs/next/Tabs.js +42 -4
- package/es/components/Toggle/Toggle.js +147 -109
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/HeaderMenuButton.js +3 -4
- package/es/components/UIShell/HeaderName.js +3 -4
- package/es/components/UIShell/HeaderNavigation.js +27 -75
- package/es/components/UIShell/SideNav.js +3 -3
- package/es/components/UIShell/SideNavFooter.js +3 -10
- package/es/components/UIShell/SideNavIcon.js +3 -4
- package/es/components/UIShell/SideNavItem.js +4 -5
- package/es/components/UIShell/SideNavLink.js +0 -6
- package/es/components/UIShell/SideNavLinkText.js +3 -4
- package/es/components/UIShell/SideNavMenu.js +93 -131
- package/es/components/UIShell/SideNavSwitcher.js +4 -2
- package/es/components/UIShell/SkipToContent.js +3 -4
- package/es/index.js +13 -11
- package/lib/components/ComposedModal/ComposedModal.js +2 -1
- package/lib/components/ComposedModal/next/ComposedModal.js +2 -1
- package/lib/components/DataTable/TableToolbarSearch.js +10 -2
- 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/Form/Form.js +1 -1
- package/lib/components/FormGroup/FormGroup.js +4 -4
- package/lib/components/FormItem/FormItem.js +5 -6
- package/lib/components/Layer/index.js +13 -0
- 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 +0 -1
- package/lib/components/Popover/index.js +135 -6
- package/lib/components/RadioButton/next/RadioButton.js +2 -1
- package/lib/components/Select/Select.js +14 -7
- package/lib/components/Tabs/next/Tabs.js +42 -4
- package/lib/components/Toggle/Toggle.js +146 -107
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/HeaderMenuButton.js +3 -4
- package/lib/components/UIShell/HeaderName.js +3 -4
- package/lib/components/UIShell/HeaderNavigation.js +25 -73
- package/lib/components/UIShell/SideNav.js +3 -3
- package/lib/components/UIShell/SideNavFooter.js +3 -10
- package/lib/components/UIShell/SideNavIcon.js +3 -4
- package/lib/components/UIShell/SideNavItem.js +4 -5
- package/lib/components/UIShell/SideNavLink.js +0 -6
- package/lib/components/UIShell/SideNavLinkText.js +3 -4
- package/lib/components/UIShell/SideNavMenu.js +89 -128
- package/lib/components/UIShell/SideNavSwitcher.js +4 -2
- package/lib/components/UIShell/SkipToContent.js +3 -4
- package/lib/index.js +86 -82
- package/package.json +3 -3
- package/es/components/Toggle/index.js +0 -19
- package/es/components/Toggle/next/Toggle.js +0 -158
- package/es/components/UIShell/index.js +0 -17
- package/es/components/UIShell/next/HeaderNavigation.js +0 -52
- package/es/components/UIShell/next/SideNavMenu.js +0 -160
- package/lib/components/Toggle/index.js +0 -23
- package/lib/components/Toggle/next/Toggle.js +0 -169
- package/lib/components/UIShell/index.js +0 -42
- package/lib/components/UIShell/next/HeaderNavigation.js +0 -62
- package/lib/components/UIShell/next/SideNavMenu.js +0 -170
|
@@ -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",
|
|
@@ -13,7 +13,7 @@ import Search from '../Search/index.js';
|
|
|
13
13
|
import setupGetInstanceId from './tools/instanceId.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["className", "searchContainerClass", "onChange", "onClear", "translateWithId", "placeholder", "labelText", "expanded", "defaultExpanded", "defaultValue", "disabled", "onExpand", "persistent", "id", "onBlur", "onFocus"];
|
|
16
|
+
var _excluded = ["className", "searchContainerClass", "onChange", "onClear", "translateWithId", "placeholder", "labelText", "expanded", "defaultExpanded", "defaultValue", "disabled", "onExpand", "persistent", "id", "onBlur", "onFocus", "size"];
|
|
17
17
|
var getInstanceId = setupGetInstanceId();
|
|
18
18
|
var translationKeys = {
|
|
19
19
|
'carbon.table.toolbar.search.label': 'Filter table',
|
|
@@ -43,6 +43,8 @@ var TableToolbarSearch = function TableToolbarSearch(_ref) {
|
|
|
43
43
|
id = _ref.id,
|
|
44
44
|
onBlur = _ref.onBlur,
|
|
45
45
|
onFocus = _ref.onFocus,
|
|
46
|
+
_ref$size = _ref.size,
|
|
47
|
+
size = _ref$size === void 0 ? 'lg' : _ref$size,
|
|
46
48
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
47
49
|
|
|
48
50
|
var _useRef = useRef(expandedProp !== undefined),
|
|
@@ -126,7 +128,8 @@ var TableToolbarSearch = function TableToolbarSearch(_ref) {
|
|
|
126
128
|
} : handleOnFocus,
|
|
127
129
|
onBlur: onBlur ? function (event) {
|
|
128
130
|
return onBlur(event, handleExpand);
|
|
129
|
-
} : handleOnBlur
|
|
131
|
+
} : handleOnBlur,
|
|
132
|
+
size: size
|
|
130
133
|
}, rest));
|
|
131
134
|
};
|
|
132
135
|
|
|
@@ -212,6 +215,11 @@ TableToolbarSearch.propTypes = {
|
|
|
212
215
|
*/
|
|
213
216
|
searchContainerClass: PropTypes.string,
|
|
214
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Specify the size of the Search
|
|
220
|
+
*/
|
|
221
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
222
|
+
|
|
215
223
|
/**
|
|
216
224
|
* Optional prop to specify the tabIndex of the <Search> (in expanded state) or the container (in collapsed state)
|
|
217
225
|
*/
|
|
@@ -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
|
|
|
@@ -22,7 +22,7 @@ var Form = function Form(_ref) {
|
|
|
22
22
|
var classNames = cx("".concat(prefix, "--form"), className);
|
|
23
23
|
return /*#__PURE__*/React__default.createElement("form", _extends({
|
|
24
24
|
className: classNames
|
|
25
|
-
}, other),
|
|
25
|
+
}, other), children);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
Form.propTypes = {
|
|
@@ -21,7 +21,7 @@ var FormGroup = function FormGroup(_ref) {
|
|
|
21
21
|
className = _ref.className,
|
|
22
22
|
message = _ref.message,
|
|
23
23
|
messageText = _ref.messageText,
|
|
24
|
-
|
|
24
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
25
|
|
|
26
26
|
var prefix = usePrefix();
|
|
27
27
|
var classNamesFieldset = cx("".concat(prefix, "--fieldset"), className);
|
|
@@ -29,11 +29,11 @@ var FormGroup = function FormGroup(_ref) {
|
|
|
29
29
|
'data-invalid': ''
|
|
30
30
|
}, {
|
|
31
31
|
className: classNamesFieldset
|
|
32
|
-
},
|
|
33
|
-
"aria-labelledby":
|
|
32
|
+
}, rest, {
|
|
33
|
+
"aria-labelledby": rest['aria-labelledby'] || legendId
|
|
34
34
|
}), /*#__PURE__*/React__default.createElement("legend", {
|
|
35
35
|
className: "".concat(prefix, "--label"),
|
|
36
|
-
id: legendId ||
|
|
36
|
+
id: legendId || rest['aria-labelledby']
|
|
37
37
|
}, legendText), children, message ? /*#__PURE__*/React__default.createElement("div", {
|
|
38
38
|
className: "".concat(prefix, "--form__requirements")
|
|
39
39
|
}, messageText) : null);
|
|
@@ -13,17 +13,17 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
13
13
|
|
|
14
14
|
var _excluded = ["className", "children"];
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function FormItem(_ref) {
|
|
17
17
|
var className = _ref.className,
|
|
18
18
|
children = _ref.children,
|
|
19
|
-
|
|
19
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
|
|
21
21
|
var prefix = usePrefix();
|
|
22
22
|
var classNames = cx("".concat(prefix, "--form-item"), className);
|
|
23
23
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
24
24
|
className: classNames
|
|
25
|
-
},
|
|
26
|
-
}
|
|
25
|
+
}, rest), children);
|
|
26
|
+
}
|
|
27
27
|
|
|
28
28
|
FormItem.propTypes = {
|
|
29
29
|
/**
|
|
@@ -36,6 +36,5 @@ FormItem.propTypes = {
|
|
|
36
36
|
*/
|
|
37
37
|
className: PropTypes.string
|
|
38
38
|
};
|
|
39
|
-
var FormItem$1 = FormItem;
|
|
40
39
|
|
|
41
|
-
export { FormItem
|
|
40
|
+
export { FormItem as default };
|
|
@@ -15,6 +15,18 @@ import { LayerContext } from './LayerContext.js';
|
|
|
15
15
|
var _excluded = ["as", "className", "children", "level"];
|
|
16
16
|
var levels = ['one', 'two', 'three'];
|
|
17
17
|
var MAX_LEVEL = levels.length - 1;
|
|
18
|
+
/**
|
|
19
|
+
* A custom hook that will return information about the current layer. A common
|
|
20
|
+
* field to pull from this is the `level` for the layer that the component that
|
|
21
|
+
* calls this hook is currently in
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function useLayer() {
|
|
25
|
+
var level = React__default.useContext(LayerContext);
|
|
26
|
+
return {
|
|
27
|
+
level: level
|
|
28
|
+
};
|
|
29
|
+
}
|
|
18
30
|
function Layer(_ref) {
|
|
19
31
|
var _ref$as = _ref.as,
|
|
20
32
|
BaseComponent = _ref$as === void 0 ? 'div' : _ref$as,
|
|
@@ -59,4 +71,4 @@ Layer.propTypes = {
|
|
|
59
71
|
level: PropTypes.oneOf([0, 1, 2])
|
|
60
72
|
};
|
|
61
73
|
|
|
62
|
-
export { Layer };
|
|
74
|
+
export { Layer, useLayer };
|
|
@@ -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 };
|
|
@@ -5,21 +5,30 @@
|
|
|
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';
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React__default from 'react';
|
|
11
|
+
import React__default, { useRef, useMemo, useState } from 'react';
|
|
12
|
+
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
13
|
+
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
12
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
15
|
|
|
14
|
-
var _excluded = ["align", "as", "caret", "className", "children", "dropShadow", "highContrast", "open"],
|
|
16
|
+
var _excluded = ["align", "as", "autoAlign", "caret", "className", "children", "dropShadow", "highContrast", "open"],
|
|
15
17
|
_excluded2 = ["className", "children"];
|
|
16
|
-
var
|
|
18
|
+
var PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
19
|
+
floating: {
|
|
20
|
+
current: null
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, forwardRef) {
|
|
17
24
|
var _cx;
|
|
18
25
|
|
|
19
26
|
var _props$align = props.align,
|
|
20
27
|
align = _props$align === void 0 ? 'bottom' : _props$align,
|
|
21
28
|
_props$as = props.as,
|
|
22
29
|
BaseComponent = _props$as === void 0 ? 'span' : _props$as,
|
|
30
|
+
_props$autoAlign = props.autoAlign,
|
|
31
|
+
autoAlign = _props$autoAlign === void 0 ? false : _props$autoAlign,
|
|
23
32
|
_props$caret = props.caret,
|
|
24
33
|
caret = _props$caret === void 0 ? true : _props$caret,
|
|
25
34
|
customClassName = props.className,
|
|
@@ -32,11 +41,121 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function Popover(props, ref
|
|
|
32
41
|
rest = _objectWithoutProperties(props, _excluded);
|
|
33
42
|
|
|
34
43
|
var prefix = usePrefix();
|
|
35
|
-
var
|
|
36
|
-
|
|
44
|
+
var floating = useRef();
|
|
45
|
+
var popover = useRef();
|
|
46
|
+
var value = useMemo(function () {
|
|
47
|
+
return {
|
|
48
|
+
floating: floating
|
|
49
|
+
};
|
|
50
|
+
}, []);
|
|
51
|
+
var ref = useMergedRefs([forwardRef, popover]);
|
|
52
|
+
|
|
53
|
+
var _useState = useState(false),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
autoAligned = _useState2[0],
|
|
56
|
+
setAutoAligned = _useState2[1];
|
|
57
|
+
|
|
58
|
+
var _useState3 = useState(align),
|
|
59
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
60
|
+
autoAlignment = _useState4[0],
|
|
61
|
+
setAutoAlignment = _useState4[1];
|
|
62
|
+
|
|
63
|
+
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned), _defineProperty(_cx, customClassName, !!customClassName), _cx));
|
|
64
|
+
useIsomorphicEffect(function () {
|
|
65
|
+
if (!autoAlign) {
|
|
66
|
+
setAutoAligned(false);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!floating.current) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (autoAligned === true) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var rect = floating.current.getBoundingClientRect(); // The conditions, per side, of when the popover is not visible, excluding the popover's internal padding(16)
|
|
79
|
+
|
|
80
|
+
var conditions = {
|
|
81
|
+
left: rect.x < -16,
|
|
82
|
+
top: rect.y < -16,
|
|
83
|
+
right: rect.x + (rect.width - 16) > document.documentElement.clientWidth,
|
|
84
|
+
bottom: rect.y + (rect.height - 16) > document.documentElement.clientHeight
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (!conditions.left && !conditions.top && !conditions.right && !conditions.bottom) {
|
|
88
|
+
setAutoAligned(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var alignments = ['top', 'top-left', 'right-bottom', 'right', 'right-top', 'bottom-left', 'bottom', 'bottom-right', 'left-top', 'left', 'left-bottom', 'top-right']; // Creates the prioritized list of options depending on ideal alignment coming from `align`
|
|
93
|
+
|
|
94
|
+
var options = [align];
|
|
95
|
+
var option = alignments[(alignments.indexOf(align) + 1) % alignments.length];
|
|
96
|
+
|
|
97
|
+
while (option) {
|
|
98
|
+
if (options.includes(option)) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
options.push(option);
|
|
103
|
+
option = alignments[(alignments.indexOf(option) + 1) % alignments.length];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isVisible(alignment) {
|
|
107
|
+
popover.current.classList.add("".concat(prefix, "--popover--").concat(alignment));
|
|
108
|
+
var rect = floating.current.getBoundingClientRect(); // Check if popover is not visible to the left of the screen
|
|
109
|
+
|
|
110
|
+
if (rect.x < -16) {
|
|
111
|
+
popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
|
|
112
|
+
return false;
|
|
113
|
+
} // Check if popover is not visible at the top of the screen
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if (rect.y < -16) {
|
|
117
|
+
popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
|
|
118
|
+
return false;
|
|
119
|
+
} // Check if popover is not visible to right of screen
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if (rect.x + (rect.width - 16) > document.documentElement.clientWidth) {
|
|
123
|
+
popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
|
|
124
|
+
return false;
|
|
125
|
+
} // Check if popover is not visible to bottom of screen
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if (rect.y + (rect.height - 16) > document.documentElement.clientHeight) {
|
|
129
|
+
popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
popover.current.classList.remove("".concat(prefix, "--popover--").concat(alignment));
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var alignment = null;
|
|
138
|
+
|
|
139
|
+
for (var i = 0; i < options.length; i++) {
|
|
140
|
+
var _option = options[i];
|
|
141
|
+
|
|
142
|
+
if (isVisible(_option)) {
|
|
143
|
+
alignment = _option;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (alignment) {
|
|
149
|
+
setAutoAligned(true);
|
|
150
|
+
setAutoAlignment(alignment);
|
|
151
|
+
}
|
|
152
|
+
}, [autoAligned, align, autoAlign, prefix]);
|
|
153
|
+
return /*#__PURE__*/React__default.createElement(PopoverContext.Provider, {
|
|
154
|
+
value: value
|
|
155
|
+
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
37
156
|
className: className,
|
|
38
157
|
ref: ref
|
|
39
|
-
}), children);
|
|
158
|
+
}), children));
|
|
40
159
|
}); // Note: this displayName is temporarily set so that Storybook ArgTable
|
|
41
160
|
// correctly displays the name of this component
|
|
42
161
|
|
|
@@ -56,6 +175,11 @@ Popover.propTypes = {
|
|
|
56
175
|
*/
|
|
57
176
|
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
58
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to futurue changes.
|
|
180
|
+
*/
|
|
181
|
+
autoAlign: PropTypes.bool,
|
|
182
|
+
|
|
59
183
|
/**
|
|
60
184
|
* Specify whether a caret should be rendered
|
|
61
185
|
*/
|
|
@@ -87,12 +211,17 @@ Popover.propTypes = {
|
|
|
87
211
|
*/
|
|
88
212
|
open: PropTypes.bool.isRequired
|
|
89
213
|
};
|
|
90
|
-
var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(_ref,
|
|
214
|
+
var PopoverContent = /*#__PURE__*/React__default.forwardRef(function PopoverContent(_ref, forwardRef) {
|
|
91
215
|
var className = _ref.className,
|
|
92
216
|
children = _ref.children,
|
|
93
217
|
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
94
218
|
|
|
95
219
|
var prefix = usePrefix();
|
|
220
|
+
|
|
221
|
+
var _React$useContext = React__default.useContext(PopoverContext),
|
|
222
|
+
floating = _React$useContext.floating;
|
|
223
|
+
|
|
224
|
+
var ref = useMergedRefs([floating, forwardRef]);
|
|
96
225
|
return /*#__PURE__*/React__default.createElement("span", _extends({}, rest, {
|
|
97
226
|
className: "".concat(prefix, "--popover")
|
|
98
227
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -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")
|
|
@@ -20,18 +20,25 @@ var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
|
|
|
20
20
|
|
|
21
21
|
var className = _ref.className,
|
|
22
22
|
id = _ref.id,
|
|
23
|
-
inline = _ref.inline,
|
|
23
|
+
_ref$inline = _ref.inline,
|
|
24
|
+
inline = _ref$inline === void 0 ? false : _ref$inline,
|
|
24
25
|
labelText = _ref.labelText,
|
|
25
|
-
disabled = _ref.disabled,
|
|
26
|
+
_ref$disabled = _ref.disabled,
|
|
27
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
26
28
|
children = _ref.children,
|
|
27
|
-
noLabel = _ref.noLabel,
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
_ref$noLabel = _ref.noLabel,
|
|
30
|
+
noLabel = _ref$noLabel === void 0 ? false : _ref$noLabel,
|
|
31
|
+
_ref$hideLabel = _ref.hideLabel,
|
|
32
|
+
hideLabel = _ref$hideLabel === void 0 ? false : _ref$hideLabel,
|
|
33
|
+
_ref$invalid = _ref.invalid,
|
|
34
|
+
invalid = _ref$invalid === void 0 ? false : _ref$invalid,
|
|
30
35
|
invalidText = _ref.invalidText,
|
|
31
36
|
helperText = _ref.helperText,
|
|
32
|
-
light = _ref.light,
|
|
37
|
+
_ref$light = _ref.light,
|
|
38
|
+
light = _ref$light === void 0 ? false : _ref$light,
|
|
33
39
|
size = _ref.size,
|
|
34
|
-
warn = _ref.warn,
|
|
40
|
+
_ref$warn = _ref.warn,
|
|
41
|
+
warn = _ref$warn === void 0 ? false : _ref$warn,
|
|
35
42
|
warnText = _ref.warnText,
|
|
36
43
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
37
44
|
|
|
@@ -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,
|