carbon-react 125.12.0 → 125.12.2
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/esm/components/date/__internal__/date-picker/date-picker.component.js +9 -3
- package/esm/components/date/date.component.js +8 -3
- package/esm/components/multi-action-button/multi-action-button.style.js +0 -8
- package/esm/components/split-button/split-button-children.style.js +2 -1
- package/lib/components/date/__internal__/date-picker/date-picker.component.js +8 -2
- package/lib/components/date/date.component.js +8 -3
- package/lib/components/multi-action-button/multi-action-button.style.js +0 -8
- package/lib/components/split-button/split-button-children.style.js +2 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React, { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import DayPicker from "react-day-picker";
|
|
5
5
|
import { flip, offset } from "@floating-ui/dom";
|
|
@@ -98,11 +98,16 @@ export const DatePicker = ({
|
|
|
98
98
|
onDayClick?.(date, ev);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
const
|
|
102
|
-
|
|
101
|
+
const handleKeyUp = useCallback(ev => {
|
|
102
|
+
/* istanbul ignore else */
|
|
103
|
+
if (open && Events.isEscKey(ev)) {
|
|
103
104
|
inputElement.current?.querySelector("input")?.focus();
|
|
104
105
|
setOpen(false);
|
|
106
|
+
ev.stopPropagation();
|
|
105
107
|
}
|
|
108
|
+
}, [inputElement, open, setOpen]);
|
|
109
|
+
const handleOnKeyDown = ev => {
|
|
110
|
+
/* istanbul ignore else */
|
|
106
111
|
if (ref.current?.querySelector(".DayPicker-NavBar button") === document.activeElement && Events.isTabKey(ev) && Events.isShiftKey(ev)) {
|
|
107
112
|
ev.preventDefault();
|
|
108
113
|
setOpen(false);
|
|
@@ -145,6 +150,7 @@ export const DatePicker = ({
|
|
|
145
150
|
}, /*#__PURE__*/React.createElement(StyledDayPicker, {
|
|
146
151
|
ref: ref,
|
|
147
152
|
onMouseDown: pickerMouseDown,
|
|
153
|
+
onKeyUp: handleKeyUp,
|
|
148
154
|
onKeyDown: handleOnKeyDown
|
|
149
155
|
}, /*#__PURE__*/React.createElement("div", {
|
|
150
156
|
id: pickerTabGuardId
|
|
@@ -180,13 +180,17 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
180
180
|
onFocus(ev);
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
+
const handleKeyUp = useCallback(ev => {
|
|
184
|
+
/* istanbul ignore else */
|
|
185
|
+
if (open && Events.isEscKey(ev)) {
|
|
186
|
+
setOpen(false);
|
|
187
|
+
ev.stopPropagation();
|
|
188
|
+
}
|
|
189
|
+
}, [open]);
|
|
183
190
|
const handleKeyDown = ev => {
|
|
184
191
|
if (onKeyDown) {
|
|
185
192
|
onKeyDown(ev);
|
|
186
193
|
}
|
|
187
|
-
if (Events.isEscKey(ev)) {
|
|
188
|
-
setOpen(false);
|
|
189
|
-
}
|
|
190
194
|
if (open && Events.isTabKey(ev)) {
|
|
191
195
|
if (Events.isShiftKey(ev)) {
|
|
192
196
|
setOpen(false);
|
|
@@ -288,6 +292,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
288
292
|
onChange: handleChange,
|
|
289
293
|
onClick: handleClick,
|
|
290
294
|
onFocus: handleFocus,
|
|
295
|
+
onKeyUp: handleKeyUp,
|
|
291
296
|
onKeyDown: handleKeyDown,
|
|
292
297
|
iconOnClick: handleClick,
|
|
293
298
|
onMouseDown: handleMouseDown,
|
|
@@ -93,14 +93,6 @@ const StyledButtonChildrenContainer = styled.div`
|
|
|
93
93
|
text-align: ${align};
|
|
94
94
|
z-index: ${theme.zIndex.overlay};
|
|
95
95
|
|
|
96
|
-
/* Styling for Safari. */
|
|
97
|
-
@media not all and (min-resolution: 0.001dpcm) {
|
|
98
|
-
@supports (-webkit-appearance: none) and (stroke-color: transparent) {
|
|
99
|
-
display: -webkit-box;
|
|
100
|
-
justify-content: ${align === "right" ? `flex-end` : `flex-start`};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
96
|
& + & {
|
|
105
97
|
margin-top: 3px;
|
|
106
98
|
}
|
|
@@ -43,7 +43,8 @@ const StyledSplitButtonChildrenContainer = styled.div`
|
|
|
43
43
|
|
|
44
44
|
${StyledButton} {
|
|
45
45
|
border: 1px solid var(--colorsActionMajorTransparent);
|
|
46
|
-
display:
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: ${align};
|
|
47
48
|
margin-left: 0;
|
|
48
49
|
min-width: 100%;
|
|
49
50
|
text-align: ${align};
|
|
@@ -106,11 +106,16 @@ const DatePicker = ({
|
|
|
106
106
|
onDayClick?.(date, ev);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
const
|
|
110
|
-
|
|
109
|
+
const handleKeyUp = (0, _react.useCallback)(ev => {
|
|
110
|
+
/* istanbul ignore else */
|
|
111
|
+
if (open && _events.default.isEscKey(ev)) {
|
|
111
112
|
inputElement.current?.querySelector("input")?.focus();
|
|
112
113
|
setOpen(false);
|
|
114
|
+
ev.stopPropagation();
|
|
113
115
|
}
|
|
116
|
+
}, [inputElement, open, setOpen]);
|
|
117
|
+
const handleOnKeyDown = ev => {
|
|
118
|
+
/* istanbul ignore else */
|
|
114
119
|
if (ref.current?.querySelector(".DayPicker-NavBar button") === document.activeElement && _events.default.isTabKey(ev) && _events.default.isShiftKey(ev)) {
|
|
115
120
|
ev.preventDefault();
|
|
116
121
|
setOpen(false);
|
|
@@ -153,6 +158,7 @@ const DatePicker = ({
|
|
|
153
158
|
}, /*#__PURE__*/_react.default.createElement(_dayPicker.default, {
|
|
154
159
|
ref: ref,
|
|
155
160
|
onMouseDown: pickerMouseDown,
|
|
161
|
+
onKeyUp: handleKeyUp,
|
|
156
162
|
onKeyDown: handleOnKeyDown
|
|
157
163
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
158
164
|
id: pickerTabGuardId
|
|
@@ -189,13 +189,17 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
189
189
|
onFocus(ev);
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
+
const handleKeyUp = (0, _react.useCallback)(ev => {
|
|
193
|
+
/* istanbul ignore else */
|
|
194
|
+
if (open && _events.default.isEscKey(ev)) {
|
|
195
|
+
setOpen(false);
|
|
196
|
+
ev.stopPropagation();
|
|
197
|
+
}
|
|
198
|
+
}, [open]);
|
|
192
199
|
const handleKeyDown = ev => {
|
|
193
200
|
if (onKeyDown) {
|
|
194
201
|
onKeyDown(ev);
|
|
195
202
|
}
|
|
196
|
-
if (_events.default.isEscKey(ev)) {
|
|
197
|
-
setOpen(false);
|
|
198
|
-
}
|
|
199
203
|
if (open && _events.default.isTabKey(ev)) {
|
|
200
204
|
if (_events.default.isShiftKey(ev)) {
|
|
201
205
|
setOpen(false);
|
|
@@ -297,6 +301,7 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
297
301
|
onChange: handleChange,
|
|
298
302
|
onClick: handleClick,
|
|
299
303
|
onFocus: handleFocus,
|
|
304
|
+
onKeyUp: handleKeyUp,
|
|
300
305
|
onKeyDown: handleKeyDown,
|
|
301
306
|
iconOnClick: handleClick,
|
|
302
307
|
onMouseDown: handleMouseDown,
|
|
@@ -102,14 +102,6 @@ const StyledButtonChildrenContainer = exports.StyledButtonChildrenContainer = _s
|
|
|
102
102
|
text-align: ${align};
|
|
103
103
|
z-index: ${theme.zIndex.overlay};
|
|
104
104
|
|
|
105
|
-
/* Styling for Safari. */
|
|
106
|
-
@media not all and (min-resolution: 0.001dpcm) {
|
|
107
|
-
@supports (-webkit-appearance: none) and (stroke-color: transparent) {
|
|
108
|
-
display: -webkit-box;
|
|
109
|
-
justify-content: ${align === "right" ? `flex-end` : `flex-start`};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
105
|
& + & {
|
|
114
106
|
margin-top: 3px;
|
|
115
107
|
}
|
|
@@ -52,7 +52,8 @@ const StyledSplitButtonChildrenContainer = _styledComponents.default.div`
|
|
|
52
52
|
|
|
53
53
|
${_button.default} {
|
|
54
54
|
border: 1px solid var(--colorsActionMajorTransparent);
|
|
55
|
-
display:
|
|
55
|
+
display: flex;
|
|
56
|
+
justify-content: ${align};
|
|
56
57
|
margin-left: 0;
|
|
57
58
|
min-width: 100%;
|
|
58
59
|
text-align: ${align};
|