carbon-react 109.7.0 → 110.0.1
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__/checkable-input/checkable-input-svg-wrapper.style.d.ts +2 -0
- package/esm/__internal__/checkable-input/checkable-input.style.d.ts +2 -0
- package/esm/__internal__/checkable-input/hidden-checkable-input.style.d.ts +2 -0
- package/esm/components/checkbox/checkbox.style.d.ts +3 -0
- package/esm/components/date/date.component.js +17 -15
- package/esm/components/dismissible-box/dismissible-box.component.d.ts +1 -1
- package/esm/components/dismissible-box/dismissible-box.component.js +1 -0
- package/esm/components/fieldset/fieldset.component.d.ts +11 -0
- package/esm/components/fieldset/fieldset.component.js +158 -17
- package/esm/components/fieldset/fieldset.style.d.ts +8 -0
- package/esm/components/fieldset/index.d.ts +2 -1
- package/esm/components/grid/grid-container/grid-container.component.js +4 -23
- package/esm/components/link/link.component.d.ts +0 -2
- package/esm/components/link/link.component.js +0 -4
- package/esm/components/menu/__internal__/submenu/submenu.component.js +6 -8
- package/esm/components/multi-action-button/multi-action-button.component.js +2 -1
- package/esm/components/popover-container/popover-container.component.js +2 -3
- package/esm/components/split-button/split-button.component.js +2 -1
- package/esm/components/text-editor/__internal__/editor-link/editor-link.component.js +3 -4
- package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +1 -2
- package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +20 -18
- package/lib/__internal__/checkable-input/checkable-input-svg-wrapper.style.d.ts +2 -0
- package/lib/__internal__/checkable-input/checkable-input.style.d.ts +2 -0
- package/lib/__internal__/checkable-input/hidden-checkable-input.style.d.ts +2 -0
- package/lib/components/checkbox/checkbox.style.d.ts +3 -0
- package/lib/components/date/date.component.js +17 -15
- package/lib/components/dismissible-box/dismissible-box.component.d.ts +1 -1
- package/lib/components/dismissible-box/dismissible-box.component.js +2 -1
- package/lib/components/fieldset/fieldset.component.d.ts +11 -0
- package/lib/components/fieldset/fieldset.component.js +158 -19
- package/lib/components/fieldset/fieldset.style.d.ts +8 -0
- package/lib/components/fieldset/index.d.ts +2 -1
- package/lib/components/grid/grid-container/grid-container.component.js +4 -30
- package/lib/components/link/link.component.d.ts +0 -2
- package/lib/components/link/link.component.js +0 -4
- package/lib/components/menu/__internal__/submenu/submenu.component.js +6 -8
- package/lib/components/multi-action-button/multi-action-button.component.js +2 -1
- package/lib/components/popover-container/popover-container.component.js +2 -3
- package/lib/components/split-button/split-button.component.js +2 -1
- package/lib/components/text-editor/__internal__/editor-link/editor-link.component.js +3 -4
- package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +1 -2
- package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +20 -18
- package/package.json +1 -1
- package/esm/components/fieldset/fieldset.d.ts +0 -15
- package/lib/components/fieldset/fieldset.d.ts +0 -15
|
@@ -43,7 +43,6 @@ const DateInput = ({
|
|
|
43
43
|
const wrapperRef = useRef();
|
|
44
44
|
const parentRef = useRef();
|
|
45
45
|
const inputRef = useRef();
|
|
46
|
-
const pickerRef = useRef();
|
|
47
46
|
const alreadyFocused = useRef(false);
|
|
48
47
|
const isBlurBlocked = useRef(false);
|
|
49
48
|
const focusedViaPicker = useRef(false);
|
|
@@ -88,6 +87,19 @@ const DateInput = ({
|
|
|
88
87
|
return ev;
|
|
89
88
|
};
|
|
90
89
|
|
|
90
|
+
const handleClickAway = () => {
|
|
91
|
+
if (open) {
|
|
92
|
+
alreadyFocused.current = true;
|
|
93
|
+
inputRef.current.focus();
|
|
94
|
+
isBlurBlocked.current = false;
|
|
95
|
+
inputRef.current.blur();
|
|
96
|
+
setOpen(false);
|
|
97
|
+
alreadyFocused.current = false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleClickInside = useClickAwayListener(handleClickAway, "mousedown");
|
|
102
|
+
|
|
91
103
|
const handleChange = ev => {
|
|
92
104
|
isInitialValue.current = false;
|
|
93
105
|
onChange(buildCustomEvent(ev));
|
|
@@ -194,6 +206,8 @@ const DateInput = ({
|
|
|
194
206
|
};
|
|
195
207
|
|
|
196
208
|
const handleMouseDown = ev => {
|
|
209
|
+
handleClickInside(ev);
|
|
210
|
+
|
|
197
211
|
if (disabled || readOnly) {
|
|
198
212
|
return;
|
|
199
213
|
}
|
|
@@ -215,8 +229,9 @@ const DateInput = ({
|
|
|
215
229
|
handleMouseDown(e);
|
|
216
230
|
};
|
|
217
231
|
|
|
218
|
-
const handlePickerMouseDown =
|
|
232
|
+
const handlePickerMouseDown = ev => {
|
|
219
233
|
isBlurBlocked.current = true;
|
|
234
|
+
handleClickInside(ev);
|
|
220
235
|
};
|
|
221
236
|
|
|
222
237
|
const assignInput = input => {
|
|
@@ -266,18 +281,6 @@ const DateInput = ({
|
|
|
266
281
|
return value;
|
|
267
282
|
};
|
|
268
283
|
|
|
269
|
-
const handleClickAway = () => {
|
|
270
|
-
if (open) {
|
|
271
|
-
alreadyFocused.current = true;
|
|
272
|
-
inputRef.current.focus();
|
|
273
|
-
isBlurBlocked.current = false;
|
|
274
|
-
inputRef.current.blur();
|
|
275
|
-
setOpen(false);
|
|
276
|
-
alreadyFocused.current = false;
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
useClickAwayListener([parentRef, pickerRef], handleClickAway, "mousedown");
|
|
281
284
|
return /*#__PURE__*/React.createElement(StyledDateInput, _extends({
|
|
282
285
|
ref: wrapperRef,
|
|
283
286
|
role: "presentation",
|
|
@@ -315,7 +318,6 @@ const DateInput = ({
|
|
|
315
318
|
onDayClick: handleDayClick,
|
|
316
319
|
minDate: minDate,
|
|
317
320
|
maxDate: maxDate,
|
|
318
|
-
ref: pickerRef,
|
|
319
321
|
pickerMouseDown: handlePickerMouseDown,
|
|
320
322
|
open: open
|
|
321
323
|
}));
|
|
@@ -13,5 +13,5 @@ export interface DismissibleBoxProps extends SpaceProps, StyledDismissibleBoxPro
|
|
|
13
13
|
* Please note this component has a minWidth of 600px */
|
|
14
14
|
width?: number | string;
|
|
15
15
|
}
|
|
16
|
-
declare const DismissibleBox: ({ children, onClose, ...rest }: DismissibleBoxProps) => JSX.Element;
|
|
16
|
+
export declare const DismissibleBox: ({ children, onClose, ...rest }: DismissibleBoxProps) => JSX.Element;
|
|
17
17
|
export default DismissibleBox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { StyledFieldsetProps } from "./fieldset.style";
|
|
4
|
+
export interface FieldsetProps extends StyledFieldsetProps, MarginProps {
|
|
5
|
+
/** Child elements */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** The text for the fieldsets legend element. */
|
|
8
|
+
legend?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const Fieldset: ({ children, inline, legend, ...rest }: FieldsetProps) => JSX.Element;
|
|
11
|
+
export default Fieldset;
|
|
@@ -2,16 +2,14 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
7
6
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
8
7
|
import { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle } from "./fieldset.style";
|
|
9
8
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
10
|
-
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
11
9
|
|
|
12
10
|
const Fieldset = ({
|
|
13
11
|
children,
|
|
14
|
-
inline,
|
|
12
|
+
inline = false,
|
|
15
13
|
legend,
|
|
16
14
|
...rest
|
|
17
15
|
}) => {
|
|
@@ -38,19 +36,162 @@ const Fieldset = ({
|
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
Fieldset.propTypes = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
"children": PropTypes.node,
|
|
40
|
+
"inline": PropTypes.bool,
|
|
41
|
+
"legend": PropTypes.string,
|
|
42
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
43
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
44
|
+
"description": PropTypes.string,
|
|
45
|
+
"toString": PropTypes.func.isRequired,
|
|
46
|
+
"valueOf": PropTypes.func.isRequired
|
|
47
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
48
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
49
|
+
"description": PropTypes.string,
|
|
50
|
+
"toString": PropTypes.func.isRequired,
|
|
51
|
+
"valueOf": PropTypes.func.isRequired
|
|
52
|
+
}), PropTypes.string]),
|
|
53
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
54
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
55
|
+
"description": PropTypes.string,
|
|
56
|
+
"toString": PropTypes.func.isRequired,
|
|
57
|
+
"valueOf": PropTypes.func.isRequired
|
|
58
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
59
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
60
|
+
"description": PropTypes.string,
|
|
61
|
+
"toString": PropTypes.func.isRequired,
|
|
62
|
+
"valueOf": PropTypes.func.isRequired
|
|
63
|
+
}), PropTypes.string]),
|
|
64
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
65
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
66
|
+
"description": PropTypes.string,
|
|
67
|
+
"toString": PropTypes.func.isRequired,
|
|
68
|
+
"valueOf": PropTypes.func.isRequired
|
|
69
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
70
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
71
|
+
"description": PropTypes.string,
|
|
72
|
+
"toString": PropTypes.func.isRequired,
|
|
73
|
+
"valueOf": PropTypes.func.isRequired
|
|
74
|
+
}), PropTypes.string]),
|
|
75
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
76
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
77
|
+
"description": PropTypes.string,
|
|
78
|
+
"toString": PropTypes.func.isRequired,
|
|
79
|
+
"valueOf": PropTypes.func.isRequired
|
|
80
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
81
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
82
|
+
"description": PropTypes.string,
|
|
83
|
+
"toString": PropTypes.func.isRequired,
|
|
84
|
+
"valueOf": PropTypes.func.isRequired
|
|
85
|
+
}), PropTypes.string]),
|
|
86
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
87
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
88
|
+
"description": PropTypes.string,
|
|
89
|
+
"toString": PropTypes.func.isRequired,
|
|
90
|
+
"valueOf": PropTypes.func.isRequired
|
|
91
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
92
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
93
|
+
"description": PropTypes.string,
|
|
94
|
+
"toString": PropTypes.func.isRequired,
|
|
95
|
+
"valueOf": PropTypes.func.isRequired
|
|
96
|
+
}), PropTypes.string]),
|
|
97
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
98
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
99
|
+
"description": PropTypes.string,
|
|
100
|
+
"toString": PropTypes.func.isRequired,
|
|
101
|
+
"valueOf": PropTypes.func.isRequired
|
|
102
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
103
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
104
|
+
"description": PropTypes.string,
|
|
105
|
+
"toString": PropTypes.func.isRequired,
|
|
106
|
+
"valueOf": PropTypes.func.isRequired
|
|
107
|
+
}), PropTypes.string]),
|
|
108
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
109
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
110
|
+
"description": PropTypes.string,
|
|
111
|
+
"toString": PropTypes.func.isRequired,
|
|
112
|
+
"valueOf": PropTypes.func.isRequired
|
|
113
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
114
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
115
|
+
"description": PropTypes.string,
|
|
116
|
+
"toString": PropTypes.func.isRequired,
|
|
117
|
+
"valueOf": PropTypes.func.isRequired
|
|
118
|
+
}), PropTypes.string]),
|
|
119
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
120
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
121
|
+
"description": PropTypes.string,
|
|
122
|
+
"toString": PropTypes.func.isRequired,
|
|
123
|
+
"valueOf": PropTypes.func.isRequired
|
|
124
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
125
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
126
|
+
"description": PropTypes.string,
|
|
127
|
+
"toString": PropTypes.func.isRequired,
|
|
128
|
+
"valueOf": PropTypes.func.isRequired
|
|
129
|
+
}), PropTypes.string]),
|
|
130
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
131
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
132
|
+
"description": PropTypes.string,
|
|
133
|
+
"toString": PropTypes.func.isRequired,
|
|
134
|
+
"valueOf": PropTypes.func.isRequired
|
|
135
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
136
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
137
|
+
"description": PropTypes.string,
|
|
138
|
+
"toString": PropTypes.func.isRequired,
|
|
139
|
+
"valueOf": PropTypes.func.isRequired
|
|
140
|
+
}), PropTypes.string]),
|
|
141
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
142
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
143
|
+
"description": PropTypes.string,
|
|
144
|
+
"toString": PropTypes.func.isRequired,
|
|
145
|
+
"valueOf": PropTypes.func.isRequired
|
|
146
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
147
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
148
|
+
"description": PropTypes.string,
|
|
149
|
+
"toString": PropTypes.func.isRequired,
|
|
150
|
+
"valueOf": PropTypes.func.isRequired
|
|
151
|
+
}), PropTypes.string]),
|
|
152
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
153
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
154
|
+
"description": PropTypes.string,
|
|
155
|
+
"toString": PropTypes.func.isRequired,
|
|
156
|
+
"valueOf": PropTypes.func.isRequired
|
|
157
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
158
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
159
|
+
"description": PropTypes.string,
|
|
160
|
+
"toString": PropTypes.func.isRequired,
|
|
161
|
+
"valueOf": PropTypes.func.isRequired
|
|
162
|
+
}), PropTypes.string]),
|
|
163
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
164
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
165
|
+
"description": PropTypes.string,
|
|
166
|
+
"toString": PropTypes.func.isRequired,
|
|
167
|
+
"valueOf": PropTypes.func.isRequired
|
|
168
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
169
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
170
|
+
"description": PropTypes.string,
|
|
171
|
+
"toString": PropTypes.func.isRequired,
|
|
172
|
+
"valueOf": PropTypes.func.isRequired
|
|
173
|
+
}), PropTypes.string]),
|
|
174
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
175
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
176
|
+
"description": PropTypes.string,
|
|
177
|
+
"toString": PropTypes.func.isRequired,
|
|
178
|
+
"valueOf": PropTypes.func.isRequired
|
|
179
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
180
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
181
|
+
"description": PropTypes.string,
|
|
182
|
+
"toString": PropTypes.func.isRequired,
|
|
183
|
+
"valueOf": PropTypes.func.isRequired
|
|
184
|
+
}), PropTypes.string]),
|
|
185
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
186
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
187
|
+
"description": PropTypes.string,
|
|
188
|
+
"toString": PropTypes.func.isRequired,
|
|
189
|
+
"valueOf": PropTypes.func.isRequired
|
|
190
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
191
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
192
|
+
"description": PropTypes.string,
|
|
193
|
+
"toString": PropTypes.func.isRequired,
|
|
194
|
+
"valueOf": PropTypes.func.isRequired
|
|
195
|
+
}), PropTypes.string])
|
|
55
196
|
};
|
|
56
197
|
export default Fieldset;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface StyledFieldsetProps {
|
|
2
|
+
/** When true, legend is placed in line with the children */
|
|
3
|
+
inline?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const FieldsetStyle: import("styled-components").StyledComponent<"fieldset", any, {}, never>;
|
|
6
|
+
declare const LegendContainerStyle: import("styled-components").StyledComponent<"div", any, StyledFieldsetProps, never>;
|
|
7
|
+
declare const FieldsetContentStyle: import("styled-components").StyledComponent<"div", any, StyledFieldsetProps, never>;
|
|
8
|
+
export { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./fieldset";
|
|
1
|
+
export { default } from "./fieldset.component";
|
|
2
|
+
export type { FieldsetProps } from "./fieldset.component";
|
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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
2
|
|
|
3
|
-
import React
|
|
3
|
+
import React from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import invariant from "invariant";
|
|
6
5
|
import StyledGridContainer from "./grid-container.style";
|
|
7
|
-
import GridItem from "../grid-item";
|
|
8
6
|
|
|
9
|
-
const GridContainer = props => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...rest
|
|
13
|
-
} = props;
|
|
14
|
-
const hasProperChildren = useMemo(() => {
|
|
15
|
-
const incorrectChild = React.Children.toArray(children).find(child => {
|
|
16
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return child.type.displayName !== GridItem.displayName;
|
|
21
|
-
});
|
|
22
|
-
return !incorrectChild;
|
|
23
|
-
}, [children]);
|
|
24
|
-
!hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `GridContainer only accepts children of type ${GridItem.displayName}.`) : invariant(false) : void 0;
|
|
25
|
-
return /*#__PURE__*/React.createElement(StyledGridContainer, _extends({
|
|
26
|
-
"data-component": "grid"
|
|
27
|
-
}, rest), children);
|
|
28
|
-
};
|
|
7
|
+
const GridContainer = props => /*#__PURE__*/React.createElement(StyledGridContainer, _extends({
|
|
8
|
+
"data-component": "grid"
|
|
9
|
+
}, props));
|
|
29
10
|
|
|
30
11
|
GridContainer.propTypes = {
|
|
31
12
|
"about": PropTypes.string,
|
|
@@ -15,8 +15,6 @@ export interface LinkProps extends React.AriaAttributes {
|
|
|
15
15
|
onKeyDown?: (ev: React.KeyboardEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
16
16
|
/** Function called when a mouse down event triggers. */
|
|
17
17
|
onMouseDown?: (ev: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
18
|
-
/** Whether to include the link in the tab order of the page */
|
|
19
|
-
tabbable?: boolean;
|
|
20
18
|
/** A message to display as a tooltip to the link. */
|
|
21
19
|
tooltipMessage?: string;
|
|
22
20
|
/** Positions the tooltip with the link. */
|
|
@@ -22,12 +22,10 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
22
22
|
rel,
|
|
23
23
|
tooltipMessage,
|
|
24
24
|
tooltipPosition,
|
|
25
|
-
tabbable = true,
|
|
26
25
|
target,
|
|
27
26
|
...rest
|
|
28
27
|
}, ref) => {
|
|
29
28
|
const l = useLocale();
|
|
30
|
-
const tabIndex = tabbable && !disabled ? "0" : "-1";
|
|
31
29
|
|
|
32
30
|
const handleOnKeyDown = ev => {
|
|
33
31
|
if (onKeyDown) {
|
|
@@ -70,7 +68,6 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
70
68
|
onMouseDown,
|
|
71
69
|
onClick,
|
|
72
70
|
disabled,
|
|
73
|
-
tabIndex,
|
|
74
71
|
target,
|
|
75
72
|
ref,
|
|
76
73
|
href,
|
|
@@ -160,7 +157,6 @@ Link.propTypes = {
|
|
|
160
157
|
"onKeyDown": PropTypes.func,
|
|
161
158
|
"onMouseDown": PropTypes.func,
|
|
162
159
|
"rel": PropTypes.string,
|
|
163
|
-
"tabbable": PropTypes.bool,
|
|
164
160
|
"target": PropTypes.string,
|
|
165
161
|
"tooltipMessage": PropTypes.string,
|
|
166
162
|
"tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"])
|
|
@@ -39,7 +39,6 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
39
39
|
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
40
40
|
const [submenuFocusIndex, setSubmenuFocusIndex] = useState(undefined);
|
|
41
41
|
const [characterString, setCharacterString] = useState("");
|
|
42
|
-
const submenuRef = useRef();
|
|
43
42
|
const formattedChildren = React.Children.map(children, child => {
|
|
44
43
|
if (child.type === ScrollableBlock) {
|
|
45
44
|
return [...child.props.children];
|
|
@@ -205,24 +204,23 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
205
204
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
206
205
|
|
|
207
206
|
}, [characterString]);
|
|
208
|
-
useClickAwayListener(
|
|
207
|
+
const handleClickInside = useClickAwayListener(handleClickAway);
|
|
209
208
|
|
|
210
209
|
if (inFullscreenView) {
|
|
211
210
|
return /*#__PURE__*/React.createElement(StyledSubmenuWrapper, {
|
|
212
211
|
"data-component": "submenu-wrapper",
|
|
213
|
-
ref: submenuRef,
|
|
214
212
|
inFullscreenView: inFullscreenView,
|
|
215
213
|
menuType: menuContext.menuType,
|
|
216
|
-
asPassiveItem: asPassiveItem
|
|
214
|
+
asPassiveItem: asPassiveItem,
|
|
215
|
+
onClick: handleClickInside
|
|
217
216
|
}, /*#__PURE__*/React.createElement(StyledMenuItemWrapper, _extends({}, rest, {
|
|
218
217
|
onClick: onClick,
|
|
219
218
|
className: className,
|
|
220
219
|
menuType: menuContext.menuType,
|
|
221
220
|
ref: ref,
|
|
222
221
|
as: asPassiveItem ? "div" : Link,
|
|
223
|
-
href:
|
|
222
|
+
href: href,
|
|
224
223
|
icon: icon,
|
|
225
|
-
tabIndex: asPassiveItem ? -1 : 0,
|
|
226
224
|
variant: variant,
|
|
227
225
|
inFullscreenView: inFullscreenView
|
|
228
226
|
}), title), /*#__PURE__*/React.createElement(StyledSubmenu, {
|
|
@@ -244,8 +242,8 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
244
242
|
"data-component": "submenu-wrapper",
|
|
245
243
|
onMouseOver: !clickToOpen ? () => openSubmenu() : undefined,
|
|
246
244
|
onMouseLeave: () => closeSubmenu(),
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
isSubmenuOpen: submenuOpen,
|
|
246
|
+
onClick: handleClickInside
|
|
249
247
|
}, /*#__PURE__*/React.createElement(StyledMenuItemWrapper, _extends({}, rest, {
|
|
250
248
|
className: className,
|
|
251
249
|
menuType: menuContext.menuType,
|
|
@@ -115,10 +115,11 @@ const MultiActionButton = ({
|
|
|
115
115
|
onKeyDown: handleKeyDown
|
|
116
116
|
}, childrenWithProps()));
|
|
117
117
|
|
|
118
|
-
useClickAwayListener(
|
|
118
|
+
const handleClick = useClickAwayListener(hideButtons);
|
|
119
119
|
return /*#__PURE__*/React.createElement(StyledMultiActionButton, _extends({
|
|
120
120
|
"aria-haspopup": "true",
|
|
121
121
|
onMouseLeave: hideButtons,
|
|
122
|
+
onClick: handleClick,
|
|
122
123
|
ref: ref,
|
|
123
124
|
"data-component": "multi-action-button",
|
|
124
125
|
"data-element": dataElement,
|
|
@@ -92,7 +92,6 @@ const PopoverContainer = ({
|
|
|
92
92
|
}) => {
|
|
93
93
|
const isControlled = open !== undefined;
|
|
94
94
|
const [isOpenInternal, setIsOpenInternal] = useState(false);
|
|
95
|
-
const ref = useRef(null);
|
|
96
95
|
const closeButtonRef = useRef(null);
|
|
97
96
|
const openButtonRef = useRef(null);
|
|
98
97
|
const guid = useRef(createGuid());
|
|
@@ -143,12 +142,12 @@ const PopoverContainer = ({
|
|
|
143
142
|
if (onClose) onClose(e);
|
|
144
143
|
};
|
|
145
144
|
|
|
146
|
-
useClickAwayListener(
|
|
145
|
+
const handleClick = useClickAwayListener(handleClickAway, "mousedown");
|
|
147
146
|
return /*#__PURE__*/React.createElement(PopoverContainerWrapperStyle, {
|
|
148
147
|
"data-component": "popover-container",
|
|
149
148
|
role: "region",
|
|
150
149
|
"aria-labelledby": popoverContainerId,
|
|
151
|
-
|
|
150
|
+
onMouseDown: handleClick
|
|
152
151
|
}, renderOpenComponent(renderOpenComponentProps), /*#__PURE__*/React.createElement(Transition, {
|
|
153
152
|
in: isOpen,
|
|
154
153
|
timeout: {
|
|
@@ -172,10 +172,11 @@ const SplitButton = ({
|
|
|
172
172
|
}, childrenWithProps()));
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
useClickAwayListener(
|
|
175
|
+
const handleClick = useClickAwayListener(hideButtons);
|
|
176
176
|
return /*#__PURE__*/React.createElement(StyledSplitButton, _extends({
|
|
177
177
|
"aria-haspopup": "true",
|
|
178
178
|
onMouseLeave: hideButtons,
|
|
179
|
+
onClick: handleClick,
|
|
179
180
|
ref: splitButtonNode
|
|
180
181
|
}, componentTags(), filterStyledSystemMarginProps(rest)), renderMainButton(), renderAdditionalButtons());
|
|
181
182
|
};
|
|
@@ -31,12 +31,11 @@ const EditorLink = ({
|
|
|
31
31
|
|
|
32
32
|
}, [validUrl]);
|
|
33
33
|
return /*#__PURE__*/React.createElement(StyledLink, _extends({
|
|
34
|
-
href: validUrl,
|
|
34
|
+
href: !editMode ? validUrl : undefined,
|
|
35
35
|
title: validUrl,
|
|
36
|
-
"aria-label": validUrl,
|
|
36
|
+
"aria-label": !editMode ? validUrl : undefined,
|
|
37
37
|
target: "_blank",
|
|
38
|
-
rel: "noopener noreferrer"
|
|
39
|
-
tabbable: !editMode
|
|
38
|
+
rel: "noopener noreferrer"
|
|
40
39
|
}, rest), children);
|
|
41
40
|
};
|
|
42
41
|
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: (targets: React.RefObject<HTMLElement>[], handleClickAway: (ev: Event) => void, eventTypeId?: "mousedown" | "click") => void;
|
|
1
|
+
declare const _default: (handleClickAway: (ev: Event) => void, eventTypeId?: "mousedown" | "click") => () => void;
|
|
3
2
|
export default _default;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
targetsRef.current = targets;
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const fnClickAway = ev => {
|
|
7
|
-
const clickedElements = targetsRef.current.filter(targetRef => {
|
|
8
|
-
var _targetRef$current;
|
|
9
|
-
|
|
10
|
-
return (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(ev === null || ev === void 0 ? void 0 : ev.target);
|
|
11
|
-
});
|
|
1
|
+
import { useEffect, useRef, useCallback } from "react"; // Needs to also take Portals into account (so can't just check DOM containment), but ideally without using
|
|
2
|
+
// event.stopPropagation() which could have unexpected and frustrating consequences for consumers.
|
|
3
|
+
// Simple approach taken from https://github.com/facebook/react/issues/10962#issuecomment-444622208
|
|
12
4
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
export default ((handleClickAway, eventTypeId = "click") => {
|
|
6
|
+
const clickIsInside = useRef(false);
|
|
7
|
+
const onDocumentClick = useCallback(ev => {
|
|
8
|
+
if (clickIsInside.current) {
|
|
9
|
+
clickIsInside.current = false;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
handleClickAway(ev);
|
|
14
|
+
}, [handleClickAway]);
|
|
15
|
+
const onInsideClick = useCallback(() => {
|
|
16
|
+
clickIsInside.current = true;
|
|
17
|
+
}, []);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
document.addEventListener(eventTypeId, onDocumentClick);
|
|
19
20
|
return function cleanup() {
|
|
20
|
-
document.removeEventListener(eventTypeId,
|
|
21
|
+
document.removeEventListener(eventTypeId, onDocumentClick);
|
|
21
22
|
};
|
|
22
|
-
}, [
|
|
23
|
+
}, [onDocumentClick, eventTypeId]);
|
|
24
|
+
return onInsideClick;
|
|
23
25
|
});
|