carbon-react 142.11.4 → 142.11.6
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/__internal__/form-field/form-field.component.js +1 -0
- package/esm/components/date/date.component.js +36 -17
- package/esm/components/navigation-bar/navigation-bar.component.js +7 -7
- package/lib/__internal__/form-field/form-field.component.js +1 -0
- package/lib/components/date/date.component.js +36 -17
- package/lib/components/navigation-bar/navigation-bar.component.js +7 -7
- package/package.json +1 -1
|
@@ -87,6 +87,7 @@ const FormField = ({
|
|
|
87
87
|
id: fieldHelpId
|
|
88
88
|
}, fieldHelpContent) : null;
|
|
89
89
|
return /*#__PURE__*/React.createElement(FormFieldStyle, _extends({}, tagComponent(dataComponent, rest), marginProps), /*#__PURE__*/React.createElement(FieldLineStyle, {
|
|
90
|
+
"data-role": "field-line",
|
|
90
91
|
inline: inlineLabel
|
|
91
92
|
}, reverse && children, label && /*#__PURE__*/React.createElement(Label, {
|
|
92
93
|
labelId: labelId,
|
|
@@ -10,7 +10,6 @@ import StyledDateInput from "./date.style";
|
|
|
10
10
|
import Textbox from "../textbox";
|
|
11
11
|
import DatePicker from "./__internal__/date-picker";
|
|
12
12
|
import DateRangeContext from "../date-range/__internal__/date-range.context";
|
|
13
|
-
import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
|
|
14
13
|
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
15
14
|
import guid from "../../__internal__/utils/helpers/guid";
|
|
16
15
|
const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
@@ -48,6 +47,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
48
47
|
const alreadyFocused = useRef(false);
|
|
49
48
|
const isBlurBlocked = useRef(false);
|
|
50
49
|
const focusedViaPicker = useRef(false);
|
|
50
|
+
const blockClose = useRef(false);
|
|
51
51
|
const locale = useLocale();
|
|
52
52
|
const {
|
|
53
53
|
dateFnsLocale
|
|
@@ -89,17 +89,30 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
89
89
|
};
|
|
90
90
|
return customEvent;
|
|
91
91
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
|
|
93
|
+
// Add custom listener to prevent issues with regards to double calls within the Date component
|
|
94
|
+
// This is a temporary fix until the Date component is refactored more info can be found:
|
|
95
|
+
// TODO: FE-6757
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const handleClick = () => {
|
|
98
|
+
if (!blockClose.current) {
|
|
99
|
+
if (open) {
|
|
100
|
+
alreadyFocused.current = true;
|
|
101
|
+
internalInputRef.current?.focus();
|
|
102
|
+
isBlurBlocked.current = false;
|
|
103
|
+
internalInputRef.current?.blur();
|
|
104
|
+
setOpen(false);
|
|
105
|
+
alreadyFocused.current = false;
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
blockClose.current = false;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
document.addEventListener("mousedown", handleClick);
|
|
112
|
+
return function cleanup() {
|
|
113
|
+
document.removeEventListener("mousedown", handleClick);
|
|
114
|
+
};
|
|
115
|
+
}, [open]);
|
|
103
116
|
const handleChange = ev => {
|
|
104
117
|
isInitialValue.current = false;
|
|
105
118
|
onChange(buildCustomEvent(ev));
|
|
@@ -165,7 +178,9 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
165
178
|
}
|
|
166
179
|
isBlurBlocked.current = false;
|
|
167
180
|
if (!open && !alreadyFocused.current) {
|
|
168
|
-
|
|
181
|
+
setTimeout(() => {
|
|
182
|
+
setOpen(true);
|
|
183
|
+
}, 0);
|
|
169
184
|
} else {
|
|
170
185
|
alreadyFocused.current = false;
|
|
171
186
|
}
|
|
@@ -200,7 +215,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
200
215
|
}
|
|
201
216
|
};
|
|
202
217
|
const handleMouseDown = ev => {
|
|
203
|
-
|
|
218
|
+
blockClose.current = true;
|
|
204
219
|
if (setInputRefMap) {
|
|
205
220
|
isBlurBlocked.current = true;
|
|
206
221
|
}
|
|
@@ -209,9 +224,13 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
209
224
|
} = ev.target;
|
|
210
225
|
if (type !== "text") {
|
|
211
226
|
alreadyFocused.current = true;
|
|
212
|
-
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
setOpen(prev => !prev);
|
|
229
|
+
}, 0);
|
|
213
230
|
} else if (!open) {
|
|
214
|
-
|
|
231
|
+
setTimeout(() => {
|
|
232
|
+
setOpen(true);
|
|
233
|
+
}, 0);
|
|
215
234
|
}
|
|
216
235
|
};
|
|
217
236
|
const handleIconMouseDown = ev => {
|
|
@@ -220,7 +239,7 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
|
|
|
220
239
|
};
|
|
221
240
|
const handlePickerMouseDown = () => {
|
|
222
241
|
isBlurBlocked.current = true;
|
|
223
|
-
|
|
242
|
+
blockClose.current = true;
|
|
224
243
|
};
|
|
225
244
|
const assignInput = useCallback(inputElement => {
|
|
226
245
|
internalInputRef.current = inputElement;
|
|
@@ -15,12 +15,7 @@ const NavigationBar = ({
|
|
|
15
15
|
...props
|
|
16
16
|
}) => {
|
|
17
17
|
const navbarRef = useRef(null);
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
orientation: isGlobal ? "top" : orientation,
|
|
20
|
-
offset: isGlobal ? "0px" : offset,
|
|
21
|
-
position: isGlobal ? "fixed" : position,
|
|
22
|
-
navbarRef: navbarRef
|
|
23
|
-
}, /*#__PURE__*/React.createElement(StyledNavigationBar, _extends({
|
|
18
|
+
return /*#__PURE__*/React.createElement(StyledNavigationBar, _extends({
|
|
24
19
|
role: "navigation",
|
|
25
20
|
"data-component": isGlobal ? "global-header" : "navigation-bar",
|
|
26
21
|
"aria-label": isGlobal ? "Global Header" : ariaLabel,
|
|
@@ -31,7 +26,12 @@ const NavigationBar = ({
|
|
|
31
26
|
}, props, {
|
|
32
27
|
isGlobal: isGlobal,
|
|
33
28
|
ref: navbarRef
|
|
34
|
-
}),
|
|
29
|
+
}), /*#__PURE__*/React.createElement(FixedNavigationBarContextProvider, {
|
|
30
|
+
orientation: isGlobal ? "top" : orientation,
|
|
31
|
+
offset: isGlobal ? "0px" : offset,
|
|
32
|
+
position: isGlobal ? "fixed" : position,
|
|
33
|
+
navbarRef: navbarRef
|
|
34
|
+
}, !isLoading && children));
|
|
35
35
|
};
|
|
36
36
|
if (process.env.NODE_ENV !== "production") {
|
|
37
37
|
NavigationBar.propTypes = {
|
|
@@ -96,6 +96,7 @@ const FormField = ({
|
|
|
96
96
|
id: fieldHelpId
|
|
97
97
|
}, fieldHelpContent) : null;
|
|
98
98
|
return /*#__PURE__*/_react.default.createElement(_formField.default, _extends({}, (0, _tags.default)(dataComponent, rest), marginProps), /*#__PURE__*/_react.default.createElement(_formField.FieldLineStyle, {
|
|
99
|
+
"data-role": "field-line",
|
|
99
100
|
inline: inlineLabel
|
|
100
101
|
}, reverse && children, label && /*#__PURE__*/_react.default.createElement(_label.default, {
|
|
101
102
|
labelId: labelId,
|
|
@@ -15,7 +15,6 @@ var _date = _interopRequireDefault(require("./date.style"));
|
|
|
15
15
|
var _textbox = _interopRequireDefault(require("../textbox"));
|
|
16
16
|
var _datePicker = _interopRequireDefault(require("./__internal__/date-picker"));
|
|
17
17
|
var _dateRange = _interopRequireDefault(require("../date-range/__internal__/date-range.context"));
|
|
18
|
-
var _useClickAwayListener = _interopRequireDefault(require("../../hooks/__internal__/useClickAwayListener"));
|
|
19
18
|
var _useFormSpacing = _interopRequireDefault(require("../../hooks/__internal__/useFormSpacing"));
|
|
20
19
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
21
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -57,6 +56,7 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
57
56
|
const alreadyFocused = (0, _react.useRef)(false);
|
|
58
57
|
const isBlurBlocked = (0, _react.useRef)(false);
|
|
59
58
|
const focusedViaPicker = (0, _react.useRef)(false);
|
|
59
|
+
const blockClose = (0, _react.useRef)(false);
|
|
60
60
|
const locale = (0, _useLocale.default)();
|
|
61
61
|
const {
|
|
62
62
|
dateFnsLocale
|
|
@@ -98,17 +98,30 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
98
98
|
};
|
|
99
99
|
return customEvent;
|
|
100
100
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
|
|
102
|
+
// Add custom listener to prevent issues with regards to double calls within the Date component
|
|
103
|
+
// This is a temporary fix until the Date component is refactored more info can be found:
|
|
104
|
+
// TODO: FE-6757
|
|
105
|
+
(0, _react.useEffect)(() => {
|
|
106
|
+
const handleClick = () => {
|
|
107
|
+
if (!blockClose.current) {
|
|
108
|
+
if (open) {
|
|
109
|
+
alreadyFocused.current = true;
|
|
110
|
+
internalInputRef.current?.focus();
|
|
111
|
+
isBlurBlocked.current = false;
|
|
112
|
+
internalInputRef.current?.blur();
|
|
113
|
+
setOpen(false);
|
|
114
|
+
alreadyFocused.current = false;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
blockClose.current = false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
document.addEventListener("mousedown", handleClick);
|
|
121
|
+
return function cleanup() {
|
|
122
|
+
document.removeEventListener("mousedown", handleClick);
|
|
123
|
+
};
|
|
124
|
+
}, [open]);
|
|
112
125
|
const handleChange = ev => {
|
|
113
126
|
isInitialValue.current = false;
|
|
114
127
|
onChange(buildCustomEvent(ev));
|
|
@@ -174,7 +187,9 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
174
187
|
}
|
|
175
188
|
isBlurBlocked.current = false;
|
|
176
189
|
if (!open && !alreadyFocused.current) {
|
|
177
|
-
|
|
190
|
+
setTimeout(() => {
|
|
191
|
+
setOpen(true);
|
|
192
|
+
}, 0);
|
|
178
193
|
} else {
|
|
179
194
|
alreadyFocused.current = false;
|
|
180
195
|
}
|
|
@@ -209,7 +224,7 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
209
224
|
}
|
|
210
225
|
};
|
|
211
226
|
const handleMouseDown = ev => {
|
|
212
|
-
|
|
227
|
+
blockClose.current = true;
|
|
213
228
|
if (setInputRefMap) {
|
|
214
229
|
isBlurBlocked.current = true;
|
|
215
230
|
}
|
|
@@ -218,9 +233,13 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
218
233
|
} = ev.target;
|
|
219
234
|
if (type !== "text") {
|
|
220
235
|
alreadyFocused.current = true;
|
|
221
|
-
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
setOpen(prev => !prev);
|
|
238
|
+
}, 0);
|
|
222
239
|
} else if (!open) {
|
|
223
|
-
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
setOpen(true);
|
|
242
|
+
}, 0);
|
|
224
243
|
}
|
|
225
244
|
};
|
|
226
245
|
const handleIconMouseDown = ev => {
|
|
@@ -229,7 +248,7 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
229
248
|
};
|
|
230
249
|
const handlePickerMouseDown = () => {
|
|
231
250
|
isBlurBlocked.current = true;
|
|
232
|
-
|
|
251
|
+
blockClose.current = true;
|
|
233
252
|
};
|
|
234
253
|
const assignInput = (0, _react.useCallback)(inputElement => {
|
|
235
254
|
internalInputRef.current = inputElement;
|
|
@@ -24,12 +24,7 @@ const NavigationBar = ({
|
|
|
24
24
|
...props
|
|
25
25
|
}) => {
|
|
26
26
|
const navbarRef = (0, _react.useRef)(null);
|
|
27
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
28
|
-
orientation: isGlobal ? "top" : orientation,
|
|
29
|
-
offset: isGlobal ? "0px" : offset,
|
|
30
|
-
position: isGlobal ? "fixed" : position,
|
|
31
|
-
navbarRef: navbarRef
|
|
32
|
-
}, /*#__PURE__*/_react.default.createElement(_navigationBar.default, _extends({
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_navigationBar.default, _extends({
|
|
33
28
|
role: "navigation",
|
|
34
29
|
"data-component": isGlobal ? "global-header" : "navigation-bar",
|
|
35
30
|
"aria-label": isGlobal ? "Global Header" : ariaLabel,
|
|
@@ -40,7 +35,12 @@ const NavigationBar = ({
|
|
|
40
35
|
}, props, {
|
|
41
36
|
isGlobal: isGlobal,
|
|
42
37
|
ref: navbarRef
|
|
43
|
-
}),
|
|
38
|
+
}), /*#__PURE__*/_react.default.createElement(_fixedNavigationBar.FixedNavigationBarContextProvider, {
|
|
39
|
+
orientation: isGlobal ? "top" : orientation,
|
|
40
|
+
offset: isGlobal ? "0px" : offset,
|
|
41
|
+
position: isGlobal ? "fixed" : position,
|
|
42
|
+
navbarRef: navbarRef
|
|
43
|
+
}, !isLoading && children));
|
|
44
44
|
};
|
|
45
45
|
exports.NavigationBar = NavigationBar;
|
|
46
46
|
if (process.env.NODE_ENV !== "production") {
|