grommet 2.40.2 → 2.42.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/components/AccordionPanel/AccordionPanel.js +1 -7
- package/components/Box/Box.js +1 -1
- package/components/Box/StyledBox.js +1 -6
- package/components/Box/index.d.ts +1 -0
- package/components/Box/propTypes.js +1 -0
- package/components/Button/Button.js +1 -0
- package/components/Button/StyledButton.js +3 -2
- package/components/Button/StyledButtonKind.js +12 -6
- package/components/Calendar/Calendar.js +90 -56
- package/components/Calendar/StyledCalendar.js +89 -7
- package/components/Calendar/utils.js +16 -2
- package/components/Carousel/Carousel.js +1 -1
- package/components/Chart/Chart.js +3 -3
- package/components/CheckBox/CheckBox.js +3 -2
- package/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
- package/components/Clock/Digital.js +1 -1
- package/components/Data/stories/Infinite.js +2 -2
- package/components/Data/stories/OnSelect.js +2 -2
- package/components/Data/stories/SpaceX.js +2 -2
- package/components/Data/stories/StarWars.js +1 -1
- package/components/DataChart/Detail.js +19 -4
- package/components/DataFilter/DataFilter.js +6 -1
- package/components/DataSort/DataSort.js +46 -14
- package/components/DataSort/stories/Simple.js +10 -1
- package/components/DataTable/Body.js +14 -8
- package/components/DataTable/GroupedBody.js +3 -3
- package/components/DataTable/buildState.js +5 -1
- package/components/DataTable/stories/SpaceX.js +2 -2
- package/components/DataTable/stories/SpaceXUngrouped.js +1 -1
- package/components/Drop/DropContainer.js +51 -3
- package/components/FileInput/index.d.ts +2 -3
- package/components/FocusedContainer.js +134 -17
- package/components/Grommet/Grommet.js +11 -5
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/index.d.ts +2 -0
- package/components/List/List.js +18 -12
- package/components/MaskedInput/MaskedInput.js +3 -0
- package/components/Menu/Menu.js +3 -3
- package/components/Meter/Circle.js +2 -2
- package/components/Notification/Notification.js +18 -6
- package/components/Notification/index.d.ts +1 -0
- package/components/Notification/propTypes.js +1 -0
- package/components/Pagination/Pagination.js +4 -2
- package/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/components/Select/Select.js +29 -18
- package/components/Select/SelectContainer.js +41 -34
- package/components/Select/index.d.ts +1 -1
- package/components/Select/stories/ChildrenRender.js +7 -8
- package/components/Select/utils.js +13 -2
- package/components/SelectMultiple/SelectMultiple.js +18 -6
- package/components/SelectMultiple/SelectMultipleContainer.js +28 -2
- package/components/SelectMultiple/SelectMultipleValue.js +14 -1
- package/components/SkipLinks/index.d.ts +1 -0
- package/components/SkipLinks/propTypes.js +1 -0
- package/components/Tab/Tab.js +1 -1
- package/components/Tag/Tag.js +11 -7
- package/components/TextInput/TextInput.js +3 -0
- package/components/ToggleGroup/StyledToggleGroup.js +12 -5
- package/components/ToggleGroup/ToggleGroup.js +21 -10
- package/components/WorldMap/WorldMap.js +1 -1
- package/contexts/RootsContext.js +23 -5
- package/es6/components/AccordionPanel/AccordionPanel.js +2 -9
- package/es6/components/Box/Box.js +1 -1
- package/es6/components/Box/StyledBox.js +1 -6
- package/es6/components/Box/index.d.ts +1 -0
- package/es6/components/Box/propTypes.js +1 -0
- package/es6/components/Button/Button.js +1 -0
- package/es6/components/Button/StyledButton.js +4 -3
- package/es6/components/Button/StyledButtonKind.js +12 -6
- package/es6/components/Calendar/Calendar.js +89 -56
- package/es6/components/Calendar/StyledCalendar.js +90 -8
- package/es6/components/Calendar/utils.js +15 -1
- package/es6/components/Carousel/Carousel.js +1 -1
- package/es6/components/Chart/Chart.js +3 -3
- package/es6/components/CheckBox/CheckBox.js +3 -2
- package/es6/components/CheckBoxGroup/CheckBoxGroup.js +1 -1
- package/es6/components/Clock/Digital.js +1 -1
- package/es6/components/Data/stories/Infinite.js +2 -2
- package/es6/components/Data/stories/OnSelect.js +2 -2
- package/es6/components/Data/stories/SpaceX.js +2 -2
- package/es6/components/Data/stories/StarWars.js +1 -1
- package/es6/components/DataChart/Detail.js +20 -5
- package/es6/components/DataFilter/DataFilter.js +6 -1
- package/es6/components/DataSort/DataSort.js +46 -14
- package/es6/components/DataSort/stories/Simple.js +10 -1
- package/es6/components/DataTable/Body.js +14 -8
- package/es6/components/DataTable/GroupedBody.js +3 -3
- package/es6/components/DataTable/buildState.js +5 -1
- package/es6/components/DataTable/stories/SpaceX.js +2 -2
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +1 -1
- package/es6/components/Drop/DropContainer.js +51 -3
- package/es6/components/FileInput/index.d.ts +2 -3
- package/es6/components/FocusedContainer.js +136 -19
- package/es6/components/Grommet/Grommet.js +12 -6
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/index.d.ts +2 -0
- package/es6/components/List/List.js +18 -12
- package/es6/components/MaskedInput/MaskedInput.js +3 -0
- package/es6/components/Menu/Menu.js +3 -3
- package/es6/components/Meter/Circle.js +2 -2
- package/es6/components/Notification/Notification.js +18 -6
- package/es6/components/Notification/index.d.ts +1 -0
- package/es6/components/Notification/propTypes.js +1 -0
- package/es6/components/Pagination/Pagination.js +4 -2
- package/es6/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es6/components/Select/Select.js +30 -19
- package/es6/components/Select/SelectContainer.js +41 -34
- package/es6/components/Select/index.d.ts +1 -1
- package/es6/components/Select/stories/ChildrenRender.js +7 -8
- package/es6/components/Select/utils.js +15 -3
- package/es6/components/SelectMultiple/SelectMultiple.js +18 -6
- package/es6/components/SelectMultiple/SelectMultipleContainer.js +28 -2
- package/es6/components/SelectMultiple/SelectMultipleValue.js +14 -1
- package/es6/components/SkipLinks/index.d.ts +1 -0
- package/es6/components/SkipLinks/propTypes.js +1 -0
- package/es6/components/Tab/Tab.js +1 -1
- package/es6/components/Tag/Tag.js +11 -7
- package/es6/components/TextInput/TextInput.js +3 -0
- package/es6/components/ToggleGroup/StyledToggleGroup.js +12 -5
- package/es6/components/ToggleGroup/ToggleGroup.js +22 -11
- package/es6/components/WorldMap/WorldMap.js +1 -1
- package/es6/contexts/RootsContext.js +20 -3
- package/es6/themes/base.d.ts +205 -6
- package/es6/themes/base.js +166 -1
- package/es6/utils/DOM.js +2 -1
- package/es6/utils/background.js +1 -1
- package/es6/utils/index.js +2 -1
- package/es6/utils/styles.js +8 -0
- package/es6/utils/useId.js +16 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +40 -40
- package/themes/base.d.ts +205 -6
- package/themes/base.js +166 -1
- package/utils/DOM.js +2 -1
- package/utils/background.js +1 -1
- package/utils/index.js +6 -0
- package/utils/styles.js +9 -1
- package/utils/useId.js +19 -0
|
@@ -10,6 +10,25 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
11
11
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
12
12
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
13
|
+
var isFocusable = function isFocusable(element) {
|
|
14
|
+
if ((element == null ? void 0 : element.tabIndex) < 0 || element != null && element.disabled) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
switch (element == null ? void 0 : element.nodeName) {
|
|
18
|
+
case 'A':
|
|
19
|
+
return !!element.href && element.rel !== 'ignore';
|
|
20
|
+
case 'INPUT':
|
|
21
|
+
return element.type !== 'hidden';
|
|
22
|
+
case 'BUTTON':
|
|
23
|
+
case 'SELECT':
|
|
24
|
+
case 'TEXTAREA':
|
|
25
|
+
return true;
|
|
26
|
+
case 'DIV':
|
|
27
|
+
return element.tabIndex >= 0;
|
|
28
|
+
default:
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
13
32
|
var FocusedContainer = exports.FocusedContainer = function FocusedContainer(_ref) {
|
|
14
33
|
var _ref$hidden = _ref.hidden,
|
|
15
34
|
hidden = _ref$hidden === void 0 ? false : _ref$hidden,
|
|
@@ -22,14 +41,103 @@ var FocusedContainer = exports.FocusedContainer = function FocusedContainer(_ref
|
|
|
22
41
|
bodyOverflowStyle = _useState[0],
|
|
23
42
|
setBodyOverflowStyle = _useState[1];
|
|
24
43
|
var ref = (0, _react.useRef)(null);
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
var preNodeRef = (0, _react.useRef)(null);
|
|
45
|
+
var postNodeRef = (0, _react.useRef)(null);
|
|
46
|
+
var _useRoots = (0, _RootsContext.useRoots)(),
|
|
47
|
+
contextValue = _useRoots.contextValue,
|
|
48
|
+
hasRoots = _useRoots.hasRoots;
|
|
49
|
+
var contextRoots = contextValue.roots;
|
|
50
|
+
// When attemptFocus moves focus around to find the focusable element,
|
|
51
|
+
// set this to true so handleTrapFocus doesn't focus the element.
|
|
52
|
+
var ignoreUtilFocusRef = (0, _react.useRef)(false);
|
|
53
|
+
var lastFocusRef = (0, _react.useRef)(null);
|
|
29
54
|
(0, _react.useEffect)(function () {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
var container = ref.current;
|
|
56
|
+
var roots = contextRoots.current;
|
|
57
|
+
var attemptFocus = function attemptFocus(element) {
|
|
58
|
+
// Check if the element is focusable; if not, return false
|
|
59
|
+
if (!isFocusable(element)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
ignoreUtilFocusRef.current = true;
|
|
63
|
+
try {
|
|
64
|
+
element.focus();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
// continue regardless of error
|
|
67
|
+
}
|
|
68
|
+
ignoreUtilFocusRef.current = false;
|
|
69
|
+
// Return true if the element is currently the active element or has focus
|
|
70
|
+
return document.activeElement === element;
|
|
71
|
+
};
|
|
72
|
+
var _focusFirstDescendant = function focusFirstDescendant(element) {
|
|
73
|
+
// Iterate through all child nodes of the provided element
|
|
74
|
+
for (var i = 0; i < element.childNodes.length; i += 1) {
|
|
75
|
+
var child = element.childNodes[i];
|
|
76
|
+
if (attemptFocus(child) || _focusFirstDescendant(child)) return true;
|
|
77
|
+
}
|
|
78
|
+
// If no focusable child or descendant was found, return false
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
81
|
+
var _focusLastDescendant = function focusLastDescendant(element) {
|
|
82
|
+
for (var i = element.childNodes.length - 1; i >= 0; i -= 1) {
|
|
83
|
+
var child = element.childNodes[i];
|
|
84
|
+
if (attemptFocus(child) || _focusLastDescendant(child)) return true;
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
var handleTrapFocus = function handleTrapFocus(e) {
|
|
89
|
+
if (!hidden && trapFocus && ignoreUtilFocusRef.current === false && container &&
|
|
90
|
+
// only perform focus if this is the most recently opened drop
|
|
91
|
+
roots[roots.length - 1] === container) {
|
|
92
|
+
if (container.contains(e.target)) {
|
|
93
|
+
lastFocusRef.current = e.target;
|
|
94
|
+
} else {
|
|
95
|
+
_focusFirstDescendant(container);
|
|
96
|
+
if (lastFocusRef.current === document.activeElement) {
|
|
97
|
+
_focusLastDescendant(container);
|
|
98
|
+
}
|
|
99
|
+
lastFocusRef.current = document.activeElement;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// add container to the global roots
|
|
105
|
+
if (container) roots.push(container);
|
|
106
|
+
|
|
107
|
+
// Create and insert focusable nodes to help track when focus
|
|
108
|
+
// has left this container but without letting focus be noticeably
|
|
109
|
+
// placed on anything outside the container
|
|
110
|
+
if (!hidden && trapFocus) {
|
|
111
|
+
var preDiv = document.createElement('div');
|
|
112
|
+
var postDiv = document.createElement('div');
|
|
113
|
+
var commonStyles = {
|
|
114
|
+
position: 'absolute',
|
|
115
|
+
height: '1px',
|
|
116
|
+
left: '0',
|
|
117
|
+
right: '0'
|
|
118
|
+
};
|
|
119
|
+
Object.assign(preDiv.style, _extends({}, commonStyles, {
|
|
120
|
+
top: '0'
|
|
121
|
+
}));
|
|
122
|
+
Object.assign(postDiv.style, _extends({}, commonStyles, {
|
|
123
|
+
bottom: '0'
|
|
124
|
+
}));
|
|
125
|
+
preNodeRef.current = container.parentNode.insertBefore(preDiv, container);
|
|
126
|
+
postNodeRef.current = container.parentNode.insertBefore(postDiv, container.nextSibling);
|
|
127
|
+
preNodeRef.current.tabIndex = 0;
|
|
128
|
+
postNodeRef.current.tabIndex = 0;
|
|
129
|
+
}
|
|
130
|
+
document.addEventListener('focus', handleTrapFocus, true);
|
|
131
|
+
return function () {
|
|
132
|
+
var _preNodeRef$current, _postNodeRef$current;
|
|
133
|
+
// remove from global roots array
|
|
134
|
+
if (roots.includes(container)) roots.splice(roots.indexOf(container), 1);
|
|
135
|
+
document.removeEventListener('focus', handleTrapFocus, true);
|
|
136
|
+
if (roots != null && roots[roots.length - 1]) (0, _utils.makeNodeFocusable)(roots[roots.length - 1]);
|
|
137
|
+
preNodeRef == null || (_preNodeRef$current = preNodeRef.current) == null || _preNodeRef$current.remove();
|
|
138
|
+
postNodeRef == null || (_postNodeRef$current = postNodeRef.current) == null || _postNodeRef$current.remove();
|
|
139
|
+
};
|
|
140
|
+
}, [hidden, contextRoots, trapFocus]);
|
|
33
141
|
(0, _react.useEffect)(function () {
|
|
34
142
|
if (bodyOverflowStyle !== 'hidden' && !hidden && restrictScroll && trapFocus) {
|
|
35
143
|
setBodyOverflowStyle(document.body.style.overflow);
|
|
@@ -42,21 +150,30 @@ var FocusedContainer = exports.FocusedContainer = function FocusedContainer(_ref
|
|
|
42
150
|
};
|
|
43
151
|
}, [bodyOverflowStyle, hidden, trapFocus, restrictScroll]);
|
|
44
152
|
(0, _react.useEffect)(function () {
|
|
153
|
+
var roots = contextRoots.current;
|
|
45
154
|
var timer = setTimeout(function () {
|
|
46
|
-
if (!hidden && trapFocus
|
|
47
|
-
|
|
155
|
+
if (!hidden && trapFocus) {
|
|
156
|
+
// make every root before this one unfocusable
|
|
157
|
+
roots == null || roots.forEach(function (root, index) {
|
|
158
|
+
if (index < roots.length - 1) (0, _utils.makeNodeUnfocusable)(root);
|
|
159
|
+
});
|
|
48
160
|
}
|
|
49
161
|
}, 0);
|
|
50
162
|
return function () {
|
|
51
|
-
|
|
52
|
-
if (roots && roots[0]) (0, _utils.makeNodeFocusable)(roots[roots.length - 1]);
|
|
53
|
-
clearTimeout(timer);
|
|
163
|
+
return clearTimeout(timer);
|
|
54
164
|
};
|
|
55
|
-
}, [hidden,
|
|
56
|
-
|
|
57
|
-
value: nextRoots
|
|
58
|
-
}, /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
165
|
+
}, [hidden, contextRoots, trapFocus]);
|
|
166
|
+
var focusedContainer = /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
59
167
|
ref: ref,
|
|
60
168
|
"aria-hidden": hidden
|
|
61
|
-
}, rest), children)
|
|
169
|
+
}, rest), children);
|
|
170
|
+
if (hasRoots) return focusedContainer;
|
|
171
|
+
return (
|
|
172
|
+
/*#__PURE__*/
|
|
173
|
+
// for cases outside of Grommet React tree, manage trapFocus when
|
|
174
|
+
// Drop/Layer opens another Drop/Layer
|
|
175
|
+
_react["default"].createElement(_RootsContext.RootsContext.Provider, {
|
|
176
|
+
value: contextValue
|
|
177
|
+
}, focusedContainer)
|
|
178
|
+
);
|
|
62
179
|
};
|
|
@@ -60,9 +60,6 @@ var Grommet = exports.Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
|
60
60
|
var _useState = (0, _react.useState)(),
|
|
61
61
|
stateResponsive = _useState[0],
|
|
62
62
|
setResponsive = _useState[1];
|
|
63
|
-
var _useState2 = (0, _react.useState)([]),
|
|
64
|
-
roots = _useState2[0],
|
|
65
|
-
setRoots = _useState2[1];
|
|
66
63
|
var theme = (0, _react.useMemo)(function () {
|
|
67
64
|
var nextTheme = (0, _utils.deepMerge)(_themes.base, themeProp || {});
|
|
68
65
|
|
|
@@ -113,15 +110,24 @@ var Grommet = exports.Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
|
113
110
|
}, [theme]);
|
|
114
111
|
var responsive = stateResponsive || deviceResponsive(userAgent, theme) || theme.global.deviceBreakpoints.tablet;
|
|
115
112
|
var grommetRef = (0, _utils.useForwardedRef)(ref);
|
|
113
|
+
|
|
114
|
+
// track open FocusedContainers in a global array to manage
|
|
115
|
+
// focus event listeners for trapFocus
|
|
116
|
+
var roots = (0, _react.useRef)([]);
|
|
116
117
|
(0, _react.useEffect)(function () {
|
|
117
|
-
if (grommetRef.current)
|
|
118
|
+
if (grommetRef.current) roots.current.push(grommetRef.current);
|
|
118
119
|
}, [grommetRef]);
|
|
120
|
+
var rootsContextValue = (0, _react.useMemo)(function () {
|
|
121
|
+
return {
|
|
122
|
+
roots: roots
|
|
123
|
+
};
|
|
124
|
+
}, []);
|
|
119
125
|
return /*#__PURE__*/_react["default"].createElement(_contexts.ThemeContext.Provider, {
|
|
120
126
|
value: theme
|
|
121
127
|
}, /*#__PURE__*/_react["default"].createElement(_contexts.ResponsiveContext.Provider, {
|
|
122
128
|
value: responsive
|
|
123
129
|
}, /*#__PURE__*/_react["default"].createElement(_RootsContext.RootsContext.Provider, {
|
|
124
|
-
value:
|
|
130
|
+
value: rootsContextValue
|
|
125
131
|
}, /*#__PURE__*/_react["default"].createElement(_contexts.ContainerTargetContext.Provider, {
|
|
126
132
|
value: containerTarget
|
|
127
133
|
}, /*#__PURE__*/_react["default"].createElement(_OptionsContext.OptionsContext.Provider, {
|
|
@@ -74,7 +74,7 @@ var Layer = exports.Layer = /*#__PURE__*/(0, _react.forwardRef)(function (props,
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
}, [animate, animation, containerTarget, layerContainer, originalFocusedElement]);
|
|
77
|
-
return layerContainer ? /*#__PURE__*/(0, _reactDom.createPortal)(
|
|
77
|
+
return layerContainer ? /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react["default"].createElement(_LayerContainer.LayerContainer, _extends({
|
|
78
78
|
ref: ref
|
|
79
79
|
}, props)), layerContainer) : null;
|
|
80
80
|
});
|
package/components/List/List.js
CHANGED
|
@@ -265,22 +265,28 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
|
|
|
265
265
|
return /*#__PURE__*/_react["default"].createElement(Container, containterProps, /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
|
|
266
266
|
onEnter: onSelectOption,
|
|
267
267
|
onSpace: function onSpace(event) {
|
|
268
|
-
|
|
268
|
+
if (onClickItem || onOrder) {
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
}
|
|
269
271
|
onSelectOption(event);
|
|
270
272
|
},
|
|
271
273
|
onUp: function onUp(event) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
if (onClickItem || onOrder) {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
if (active) {
|
|
277
|
+
var min = onOrder ? 1 : 0;
|
|
278
|
+
updateActive(Math.max(active - 1, min));
|
|
279
|
+
}
|
|
276
280
|
}
|
|
277
281
|
},
|
|
278
282
|
onDown: function onDown(event) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
if (onClickItem || onOrder) {
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
if (orderableData && orderableData.length) {
|
|
286
|
+
var min = onOrder ? 1 : 0;
|
|
287
|
+
var max = onOrder ? orderableData.length * 2 - 2 : data.length - 1;
|
|
288
|
+
updateActive(active >= min ? Math.min(active + 1, max) : min);
|
|
289
|
+
}
|
|
284
290
|
}
|
|
285
291
|
},
|
|
286
292
|
onKeyDown: onKeyDown
|
|
@@ -322,7 +328,7 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
|
|
|
322
328
|
var isPinned;
|
|
323
329
|
if (Array.isArray(pinned) && pinned.length > 0 || Array.isArray(pinned == null ? void 0 : pinned.items) && (pinned == null || (_pinned$items2 = pinned.items) == null ? void 0 : _pinned$items2.length) > 0) {
|
|
324
330
|
if (typeof item === 'object' && !itemKey) {
|
|
325
|
-
console.error(
|
|
331
|
+
console.error(// eslint-disable-next-line max-len
|
|
326
332
|
"Warning: Missing prop itemKey. Prop pin requires itemKey to be specified when data is of type 'object'.");
|
|
327
333
|
}
|
|
328
334
|
isPinned = Array.isArray(pinned) ? pinned == null ? void 0 : pinned.includes(key) : pinned.items.some(function (pinnedItem) {
|
|
@@ -374,7 +380,7 @@ var List = exports.List = /*#__PURE__*/_react["default"].forwardRef(function (_r
|
|
|
374
380
|
var isDisabled;
|
|
375
381
|
if (disabledItems) {
|
|
376
382
|
if (typeof item === 'object' && !itemKey) {
|
|
377
|
-
console.error(
|
|
383
|
+
console.error(// eslint-disable-next-line max-len
|
|
378
384
|
"Warning: Missing prop itemKey. Prop disabled requires itemKey to be specified when data is of type 'object'.");
|
|
379
385
|
}
|
|
380
386
|
isDisabled = disabledItems == null ? void 0 : disabledItems.includes(key);
|
|
@@ -387,6 +387,9 @@ var MaskedInput = exports.MaskedInput = /*#__PURE__*/(0, _react.forwardRef)(func
|
|
|
387
387
|
target: inputRef.current,
|
|
388
388
|
onClickOutside: onHideDrop,
|
|
389
389
|
onEsc: onHideDrop
|
|
390
|
+
// MaskedInput manages its own keyboard behavior via Keyboard
|
|
391
|
+
,
|
|
392
|
+
trapFocus: false
|
|
390
393
|
}, dropProps), /*#__PURE__*/_react["default"].createElement(ContainerBox, _extends({
|
|
391
394
|
ref: dropRef,
|
|
392
395
|
overflow: "auto",
|
package/components/Menu/Menu.js
CHANGED
|
@@ -397,14 +397,14 @@ var Menu = exports.Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, r
|
|
|
397
397
|
ref: dropContainerRef,
|
|
398
398
|
tabIndex: -1,
|
|
399
399
|
background: dropBackground || theme.menu.background
|
|
400
|
-
}, passThemeFlag), alignControlMirror === 'top' && align.
|
|
400
|
+
}, passThemeFlag), alignControlMirror === 'top' && align.bottom !== 'top' && align.top !== 'bottom' ? controlMirror : undefined, /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
401
401
|
overflow: "auto",
|
|
402
402
|
role: "menu",
|
|
403
403
|
a11yTitle: a11y
|
|
404
|
-
}, menuContent), !initialAlignTop &&
|
|
404
|
+
}, menuContent), !initialAlignTop &&
|
|
405
405
|
// don't show controlMirror if caller is using
|
|
406
406
|
// align.bottom === 'top'
|
|
407
|
-
alignControlMirror === 'bottom' &&
|
|
407
|
+
alignControlMirror === 'bottom' && align.bottom !== 'top' && align.top !== 'bottom' ? controlMirror : undefined))
|
|
408
408
|
}), content));
|
|
409
409
|
});
|
|
410
410
|
Menu.displayName = 'Menu';
|
|
@@ -75,7 +75,7 @@ var Circle = exports.Circle = /*#__PURE__*/(0, _react.forwardRef)(function (prop
|
|
|
75
75
|
var stroke = (0, _utils2.strokeProps)(someHighlight && !highlight ? background : colorName, theme);
|
|
76
76
|
if (round) {
|
|
77
77
|
var d1 = (0, _utils.arcCommands)(centerX, centerY, radius, startAngle, endAngle);
|
|
78
|
-
paths.unshift(
|
|
78
|
+
paths.unshift(/*#__PURE__*/_react["default"].createElement("path", _extends({
|
|
79
79
|
key: key,
|
|
80
80
|
d: d1,
|
|
81
81
|
fill: "none"
|
|
@@ -104,7 +104,7 @@ var Circle = exports.Circle = /*#__PURE__*/(0, _react.forwardRef)(function (prop
|
|
|
104
104
|
pathCaps.unshift(pathCap);
|
|
105
105
|
} else {
|
|
106
106
|
var d = (0, _utils.arcCommands)(centerX, centerY, radius, startAngle, endAngle);
|
|
107
|
-
paths.push(
|
|
107
|
+
paths.push(/*#__PURE__*/_react["default"].createElement("path", _extends({
|
|
108
108
|
key: key,
|
|
109
109
|
d: d,
|
|
110
110
|
fill: "none"
|
|
@@ -52,12 +52,18 @@ var adaptThemeStyle = function adaptThemeStyle(value, theme) {
|
|
|
52
52
|
}
|
|
53
53
|
return [textStyle, closeButtonStyle];
|
|
54
54
|
};
|
|
55
|
+
var getTextColor = function getTextColor(part, status, kind, theme) {
|
|
56
|
+
var _theme$notification, _theme$notification2, _theme$notification3, _theme$notification4, _theme$notification5;
|
|
57
|
+
var color;
|
|
58
|
+
if ((_theme$notification = theme.notification) != null && (_theme$notification = _theme$notification[status]) != null && (_theme$notification = _theme$notification[kind]) != null && (_theme$notification = _theme$notification[part]) != null && _theme$notification.color) color = (_theme$notification2 = theme.notification) == null || (_theme$notification2 = _theme$notification2[status]) == null || (_theme$notification2 = _theme$notification2[kind]) == null || (_theme$notification2 = _theme$notification2[part]) == null ? void 0 : _theme$notification2.color;else if ((_theme$notification3 = theme.notification) != null && (_theme$notification3 = _theme$notification3[status]) != null && (_theme$notification3 = _theme$notification3[part]) != null && _theme$notification3.color) color = (_theme$notification4 = theme.notification) == null || (_theme$notification4 = _theme$notification4[status]) == null || (_theme$notification4 = _theme$notification4[part]) == null ? void 0 : _theme$notification4.color;else color = (_theme$notification5 = theme.notification) == null || (_theme$notification5 = _theme$notification5[part]) == null ? void 0 : _theme$notification5.color;
|
|
59
|
+
return color;
|
|
60
|
+
};
|
|
55
61
|
var NotificationAnchor = (0, _styledComponents["default"])(_Anchor.Anchor).withConfig({
|
|
56
62
|
displayName: "Notification__NotificationAnchor",
|
|
57
63
|
componentId: "sc-1yq09yz-0"
|
|
58
64
|
})(["white-space:nowrap;"]);
|
|
59
65
|
var Notification = exports.Notification = function Notification(_ref) {
|
|
60
|
-
var _theme$
|
|
66
|
+
var _theme$notification6, _theme$notification7, _theme$notification8, _theme$notification9, _theme$notification10;
|
|
61
67
|
var actionsProp = _ref.actions,
|
|
62
68
|
messageProp = _ref.message,
|
|
63
69
|
onClose = _ref.onClose,
|
|
@@ -94,7 +100,7 @@ var Notification = exports.Notification = function Notification(_ref) {
|
|
|
94
100
|
return undefined;
|
|
95
101
|
}, [autoClose, close, theme.notification.toast.time, theme.notification.time, time]);
|
|
96
102
|
var CloseIcon = theme.notification.close.icon;
|
|
97
|
-
var _ref2 = ((_theme$
|
|
103
|
+
var _ref2 = ((_theme$notification6 = theme.notification) == null ? void 0 : _theme$notification6[status]) || theme.notification.unknown,
|
|
98
104
|
StatusIcon = _ref2.icon,
|
|
99
105
|
color = _ref2.color;
|
|
100
106
|
var closeIconColor = theme.notification.close.color;
|
|
@@ -106,7 +112,7 @@ var Notification = exports.Notification = function Notification(_ref) {
|
|
|
106
112
|
var direction;
|
|
107
113
|
if (kind && theme.notification[kind].direction) direction = theme.notification[kind].direction;else direction = theme.notification.direction;
|
|
108
114
|
var background;
|
|
109
|
-
if (kind && (_theme$
|
|
115
|
+
if (kind && (_theme$notification7 = theme.notification) != null && (_theme$notification7 = _theme$notification7[status]) != null && (_theme$notification7 = _theme$notification7[kind]) != null && _theme$notification7.background) background = theme.notification[status][kind].background;else if ((_theme$notification8 = theme.notification) != null && (_theme$notification8 = _theme$notification8[status]) != null && _theme$notification8.background) background = theme.notification[status].background;else background = ((_theme$notification9 = theme.notification) == null || (_theme$notification9 = _theme$notification9[kind]) == null || (_theme$notification9 = _theme$notification9.container) == null ? void 0 : _theme$notification9.background) || theme.notification.container.background;
|
|
110
116
|
var TextWrapper = direction === 'row' ? _Text.Text : _react.Fragment;
|
|
111
117
|
|
|
112
118
|
// notification is built with two child boxes that contain:
|
|
@@ -125,6 +131,8 @@ var Notification = exports.Notification = function Notification(_ref) {
|
|
|
125
131
|
} else textPad = pad;
|
|
126
132
|
var actions;
|
|
127
133
|
var message = messageProp;
|
|
134
|
+
var messageColor = getTextColor('message', status, kind, theme);
|
|
135
|
+
var titleColor = getTextColor('title', status, kind, theme);
|
|
128
136
|
if (actionsProp) actions = actionsProp.map(function (action) {
|
|
129
137
|
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, {
|
|
130
138
|
key: action.label
|
|
@@ -138,12 +146,14 @@ var Notification = exports.Notification = function Notification(_ref) {
|
|
|
138
146
|
}, action, theme.notification.actions)), ' ');
|
|
139
147
|
});
|
|
140
148
|
var Message = direction !== 'row' ? _Paragraph.Paragraph : _Text.Text;
|
|
141
|
-
if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/_react["default"].createElement(Message, theme.notification.message,
|
|
149
|
+
if (message || actions) message = typeof message === 'string' ? /*#__PURE__*/_react["default"].createElement(Message, _extends({}, theme.notification.message, {
|
|
150
|
+
color: messageColor
|
|
151
|
+
}), /*#__PURE__*/_react["default"].createElement(_Text.Text, {
|
|
142
152
|
margin: {
|
|
143
153
|
right: 'xsmall'
|
|
144
154
|
}
|
|
145
155
|
}, message), actions) : message;
|
|
146
|
-
var iconDimension = ((_theme$
|
|
156
|
+
var iconDimension = ((_theme$notification10 = theme.notification) == null || (_theme$notification10 = _theme$notification10.message) == null ? void 0 : _theme$notification10.size) || 'medium';
|
|
147
157
|
var content = /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({}, theme.notification.container, global ? _extends({}, theme.notification.global.container) : {}, toast ? _extends({}, theme.notification.toast.container) : {}, {
|
|
148
158
|
background: background
|
|
149
159
|
// let internal box control pad
|
|
@@ -159,7 +169,9 @@ var Notification = exports.Notification = function Notification(_ref) {
|
|
|
159
169
|
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.iconContainer, icon || /*#__PURE__*/_react["default"].createElement(StatusIcon, {
|
|
160
170
|
color: color,
|
|
161
171
|
height: iconDimension
|
|
162
|
-
})), /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.textContainer, /*#__PURE__*/_react["default"].createElement(TextWrapper, null, title && /*#__PURE__*/_react["default"].createElement(_Text.Text, theme.notification.title,
|
|
172
|
+
})), /*#__PURE__*/_react["default"].createElement(_Box.Box, theme.notification.textContainer, /*#__PURE__*/_react["default"].createElement(TextWrapper, null, title && /*#__PURE__*/_react["default"].createElement(_Text.Text, _extends({}, theme.notification.title, {
|
|
173
|
+
color: titleColor
|
|
174
|
+
}), title), message && title && direction === 'row' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "\xA0"), message))), onClose &&
|
|
163
175
|
/*#__PURE__*/
|
|
164
176
|
// theme.notification.container and textContainer may both have pad,
|
|
165
177
|
// account for both
|
|
@@ -8,6 +8,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
|
8
8
|
var PropType = {};
|
|
9
9
|
if (process.env.NODE_ENV !== 'production') {
|
|
10
10
|
PropType = {
|
|
11
|
+
id: _propTypes["default"].string,
|
|
11
12
|
actions: _propTypes["default"].arrayOf(_propTypes["default"].shape(_propTypes2.AnchorPropTypes)),
|
|
12
13
|
global: _propTypes["default"].bool,
|
|
13
14
|
title: _propTypes["default"].string,
|
|
@@ -89,7 +89,7 @@ var Pagination = exports.Pagination = /*#__PURE__*/(0, _react.forwardRef)(functi
|
|
|
89
89
|
var numberMiddlePages;
|
|
90
90
|
if (numberMiddlePagesProp < 1) {
|
|
91
91
|
numberMiddlePages = 1;
|
|
92
|
-
console.warn(
|
|
92
|
+
console.warn(// eslint-disable-next-line max-len
|
|
93
93
|
"Property \"numberMiddlePages\" should not be < 1. One middle page button will be shown. Set \"numberMiddlePages\" >= 1 to remove this warning.");
|
|
94
94
|
} else numberMiddlePages = numberMiddlePagesProp;
|
|
95
95
|
var startingMiddlePages;
|
|
@@ -188,7 +188,9 @@ var Pagination = exports.Pagination = /*#__PURE__*/(0, _react.forwardRef)(functi
|
|
|
188
188
|
ref: ref
|
|
189
189
|
}, /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
|
|
190
190
|
as: "ul"
|
|
191
|
-
}, theme.pagination.controls
|
|
191
|
+
}, theme.pagination.controls, {
|
|
192
|
+
cssGap: true
|
|
193
|
+
}), controls.map(function (control, index) {
|
|
192
194
|
return (
|
|
193
195
|
/*#__PURE__*/
|
|
194
196
|
/* Using index as key (as opposed to a unique id) seems to
|
|
@@ -128,7 +128,7 @@ var RadioButtonGroup = exports.RadioButtonGroup = /*#__PURE__*/(0, _react.forwar
|
|
|
128
128
|
// on the first radiobutton
|
|
129
129
|
value === '' && index === 0;
|
|
130
130
|
if (optionRest.checked) {
|
|
131
|
-
console.warn(
|
|
131
|
+
console.warn(// eslint-disable-next-line max-len
|
|
132
132
|
"'checked' prop of an individual RadioButton shouldn't be used in a RadioButtonGroup component. Use the RadioButtonGroup 'value' prop instead.");
|
|
133
133
|
}
|
|
134
134
|
return /*#__PURE__*/_react["default"].createElement(_RadioButton.RadioButton, _extends({
|
|
@@ -132,23 +132,30 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
132
132
|
// the option indexes present in the value
|
|
133
133
|
var optionIndexesInValue = (0, _react.useMemo)(function () {
|
|
134
134
|
var result = [];
|
|
135
|
-
|
|
136
|
-
if (selected
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
135
|
+
if (selected !== undefined) {
|
|
136
|
+
if (Array.isArray(selected)) {
|
|
137
|
+
var validSelections = selected.filter(function (i) {
|
|
138
|
+
return i in allOptions;
|
|
139
|
+
});
|
|
140
|
+
result.push.apply(result, validSelections);
|
|
141
|
+
} else if (selected in allOptions) {
|
|
142
|
+
result.push(selected);
|
|
143
|
+
}
|
|
144
|
+
} else if (Array.isArray(normalizedValue)) {
|
|
145
|
+
normalizedValue.forEach(function (v) {
|
|
146
|
+
var index = allOptions.map(function (option) {
|
|
147
|
+
return (0, _utils2.applyKey)(option, valueKey);
|
|
148
|
+
}).indexOf(v);
|
|
149
|
+
if (index !== -1) result.push(index);
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
var index = allOptions.map(function (option) {
|
|
153
|
+
return (0, _utils2.applyKey)(option, valueKey);
|
|
154
|
+
}).indexOf(normalizedValue);
|
|
155
|
+
if (index !== -1) {
|
|
149
156
|
result.push(index);
|
|
150
157
|
}
|
|
151
|
-
}
|
|
158
|
+
}
|
|
152
159
|
return result;
|
|
153
160
|
}, [allOptions, selected, valueKey, normalizedValue]);
|
|
154
161
|
var _useState3 = (0, _react.useState)(propOpen),
|
|
@@ -222,7 +229,7 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
222
229
|
var selectValue = (0, _react.useMemo)(function () {
|
|
223
230
|
if (valueLabel instanceof Function) {
|
|
224
231
|
if (value || value === 0 || value === false) return valueLabel(value);
|
|
225
|
-
} else if (valueLabel) return valueLabel;else if (
|
|
232
|
+
} else if (valueLabel) return valueLabel;else if (/*#__PURE__*/_react["default"].isValidElement(value)) return value; // deprecated
|
|
226
233
|
return undefined;
|
|
227
234
|
}, [value, valueLabel]);
|
|
228
235
|
var displayLabelKey = (0, _react.useMemo)(function () {
|
|
@@ -259,7 +266,7 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
259
266
|
id: 'select.selected',
|
|
260
267
|
messages: messages,
|
|
261
268
|
values: {
|
|
262
|
-
currentSelectedValue: value
|
|
269
|
+
currentSelectedValue: (0, _utils2.formatValueForA11y)(value, labelKey)
|
|
263
270
|
}
|
|
264
271
|
}) : ''),
|
|
265
272
|
"aria-expanded": Boolean(open),
|
|
@@ -270,7 +277,7 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
270
277
|
dropTarget: dropTarget,
|
|
271
278
|
open: open,
|
|
272
279
|
alignSelf: alignSelf,
|
|
273
|
-
focusIndicator: focusIndicator,
|
|
280
|
+
focusIndicator: plain ? focusIndicator : true,
|
|
274
281
|
onFocus: onFocus,
|
|
275
282
|
onBlur: onBlur,
|
|
276
283
|
gridArea: gridArea,
|
|
@@ -324,6 +331,8 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
324
331
|
type: "text",
|
|
325
332
|
name: name,
|
|
326
333
|
id: id ? id + "__input" : undefined,
|
|
334
|
+
inert: "" // revisit for React 19
|
|
335
|
+
,
|
|
327
336
|
value: inputValue,
|
|
328
337
|
ref: inputRef,
|
|
329
338
|
readOnly: true
|
|
@@ -331,6 +340,8 @@ var Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
331
340
|
a11yTitle: (ariaLabel || a11yTitle) && "" + (ariaLabel || a11yTitle) + (value && typeof value === 'string' ? ", " + value : ''),
|
|
332
341
|
disabled: disabled,
|
|
333
342
|
id: id,
|
|
343
|
+
inert: "" // revisit for React 19
|
|
344
|
+
,
|
|
334
345
|
name: name,
|
|
335
346
|
ref: inputRef,
|
|
336
347
|
placeholder: placeholder,
|