carbon-react 111.3.2 → 111.4.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/esm/components/dialog/dialog.component.d.ts +3 -2
- package/esm/components/dialog/dialog.component.js +2 -1
- package/esm/components/dialog/dialog.config.d.ts +2 -1
- package/esm/components/dialog/dialog.config.js +1 -1
- package/esm/components/dialog/dialog.style.d.ts +2 -11
- package/esm/components/dialog/index.d.ts +1 -0
- package/esm/components/tabs/tab/tab.component.js +2 -1
- package/esm/components/tabs/tab/tab.d.ts +1 -1
- package/esm/components/tabs/tabs.component.js +5 -21
- package/lib/components/dialog/dialog.component.d.ts +3 -2
- package/lib/components/dialog/dialog.component.js +4 -2
- package/lib/components/dialog/dialog.config.d.ts +2 -1
- package/lib/components/dialog/dialog.config.js +1 -1
- package/lib/components/dialog/dialog.style.d.ts +2 -11
- package/lib/components/dialog/index.d.ts +1 -0
- package/lib/components/tabs/tab/tab.component.js +2 -1
- package/lib/components/tabs/tab/tab.d.ts +1 -1
- package/lib/components/tabs/tabs.component.js +4 -20
- package/package.json +1 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ModalProps } from "../modal";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
|
-
|
|
4
|
+
import { DialogSizes } from "./dialog.config";
|
|
5
|
+
declare const PADDING_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
6
|
+
declare type PaddingValues = typeof PADDING_VALUES[number];
|
|
5
7
|
export interface ContentPaddingInterface {
|
|
6
8
|
p?: PaddingValues;
|
|
7
9
|
py?: PaddingValues;
|
|
8
10
|
px?: PaddingValues;
|
|
9
11
|
}
|
|
10
|
-
declare type DialogSizes = "auto" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
|
|
11
12
|
export interface DialogProps extends ModalProps, TagProps {
|
|
12
13
|
/** Custom class name */
|
|
13
14
|
className?: string;
|
|
@@ -7,12 +7,13 @@ import Modal from "../modal";
|
|
|
7
7
|
import Heading from "../heading";
|
|
8
8
|
import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
|
|
9
9
|
import { StyledDialog, StyledDialogTitle, StyledDialogContent, StyledDialogInnerContent } from "./dialog.style";
|
|
10
|
+
import { TOP_MARGIN } from "./dialog.config";
|
|
10
11
|
import FocusTrap from "../../__internal__/focus-trap";
|
|
11
12
|
import IconButton from "../icon-button";
|
|
12
13
|
import Icon from "../icon";
|
|
13
|
-
import { TOP_MARGIN } from "./dialog.config";
|
|
14
14
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
15
15
|
import useIsStickyFooterForm from "../../hooks/__internal__/useIsStickyFooterForm";
|
|
16
|
+
const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
16
17
|
|
|
17
18
|
const Dialog = ({
|
|
18
19
|
className,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare const DIALOG_SIZES:
|
|
1
|
+
export declare const DIALOG_SIZES: readonly ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
2
2
|
export declare const TOP_MARGIN = 20;
|
|
3
3
|
export declare const CONTENT_TOP_PADDING = 24;
|
|
4
4
|
export declare const HORIZONTAL_PADDING = 32;
|
|
5
5
|
export declare const CONTENT_BOTTOM_PADDING = 30;
|
|
6
|
+
export declare type DialogSizes = typeof DIALOG_SIZES[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const DIALOG_SIZES = ["extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
1
|
+
export const DIALOG_SIZES = ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
2
2
|
export const TOP_MARGIN = 20;
|
|
3
3
|
export const CONTENT_TOP_PADDING = 24;
|
|
4
4
|
export const HORIZONTAL_PADDING = 32;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
+
import { DialogSizes } from "./dialog.config";
|
|
1
2
|
import { ContentPaddingInterface } from "./dialog.component";
|
|
2
|
-
declare const dialogSizes: {
|
|
3
|
-
auto: string;
|
|
4
|
-
"extra-small": string;
|
|
5
|
-
small: string;
|
|
6
|
-
"medium-small": string;
|
|
7
|
-
medium: string;
|
|
8
|
-
"medium-large": string;
|
|
9
|
-
large: string;
|
|
10
|
-
"extra-large": string;
|
|
11
|
-
};
|
|
12
3
|
declare type StyledDialogProps = {
|
|
13
4
|
topMargin: number;
|
|
14
|
-
size?:
|
|
5
|
+
size?: DialogSizes;
|
|
15
6
|
dialogHeight?: string;
|
|
16
7
|
};
|
|
17
8
|
declare const StyledDialog: import("styled-components").StyledComponent<"div", any, StyledDialogProps & ContentPaddingInterface, never>;
|
|
@@ -21,6 +21,7 @@ const Tab = ({
|
|
|
21
21
|
updateWarnings,
|
|
22
22
|
updateInfos,
|
|
23
23
|
href,
|
|
24
|
+
title,
|
|
24
25
|
...rest
|
|
25
26
|
}) => {
|
|
26
27
|
const [tabErrors, setTabErrors] = useState({});
|
|
@@ -92,7 +93,7 @@ Tab.propTypes = { ...paddingPropTypes,
|
|
|
92
93
|
/** Overrides Title default layout with a one defined in this prop */
|
|
93
94
|
customLayout: PropTypes.node,
|
|
94
95
|
|
|
95
|
-
/** Boolean indicating selected state of Tab. */
|
|
96
|
+
/** @ignore @private Boolean indicating selected state of Tab. */
|
|
96
97
|
isTabSelected: PropTypes.bool,
|
|
97
98
|
|
|
98
99
|
/** The position of the Tab. */
|
|
@@ -14,7 +14,7 @@ export interface TabProps extends PaddingProps {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
/** The child elements of Tab component. */
|
|
16
16
|
children?: React.ReactNode;
|
|
17
|
-
/** Boolean indicating selected state of Tab. */
|
|
17
|
+
/** @ignore @private Boolean indicating selected state of Tab. */
|
|
18
18
|
isTabSelected?: boolean;
|
|
19
19
|
/** The position of the Tab. */
|
|
20
20
|
position?: "top" | "left";
|
|
@@ -1,6 +1,6 @@
|
|
|
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, { useCallback, useContext, useEffect,
|
|
3
|
+
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState, createRef, cloneElement, Children } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
6
|
import Tab from "./tab";
|
|
@@ -40,7 +40,7 @@ const Tabs = ({
|
|
|
40
40
|
length: filteredChildren.length
|
|
41
41
|
}).map(() => /*#__PURE__*/createRef()), [filteredChildren.length]);
|
|
42
42
|
const previousSelectedTabId = useRef(selectedTabId);
|
|
43
|
-
const [selectedTabIdState, setSelectedTabIdState] = useState();
|
|
43
|
+
const [selectedTabIdState, setSelectedTabIdState] = useState(selectedTabId || filteredChildren[0].props.tabId);
|
|
44
44
|
const [tabStopId, setTabStopId] = useState();
|
|
45
45
|
const {
|
|
46
46
|
isInSidebar
|
|
@@ -48,17 +48,6 @@ const Tabs = ({
|
|
|
48
48
|
const [tabsErrors, setTabsErrors] = useState({});
|
|
49
49
|
const [tabsWarnings, setTabsWarnings] = useState({});
|
|
50
50
|
const [tabsInfos, setTabsInfos] = useState({});
|
|
51
|
-
useLayoutEffect(() => {
|
|
52
|
-
const selectedTab = selectedTabId || Children.toArray(children)[0].props.tabId;
|
|
53
|
-
|
|
54
|
-
if (!tabIds.includes(selectedTabId)) {
|
|
55
|
-
setTabStopId(React.Children.toArray(children)[0].props.tabId);
|
|
56
|
-
} else {
|
|
57
|
-
setTabStopId(selectedTab);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
setSelectedTabIdState(selectedTab);
|
|
61
|
-
}, [children, selectedTabId, tabIds]);
|
|
62
51
|
const updateErrors = useCallback((id, hasError) => {
|
|
63
52
|
if (tabsErrors[id] !== hasError) {
|
|
64
53
|
setTabsErrors({ ...tabsErrors,
|
|
@@ -249,13 +238,8 @@ const Tabs = ({
|
|
|
249
238
|
|
|
250
239
|
|
|
251
240
|
const visibleTab = () => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (isTabSelected(child.props.tabId)) {
|
|
255
|
-
tab = child;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
return tab ? /*#__PURE__*/cloneElement(tab, { ...tab.props,
|
|
241
|
+
const tab = filteredChildren.find(child => isTabSelected(child.props.tabId));
|
|
242
|
+
return tab && /*#__PURE__*/cloneElement(tab, { ...tab.props,
|
|
259
243
|
role: "tabpanel",
|
|
260
244
|
position,
|
|
261
245
|
isTabSelected: isTabSelected(tab.props.tabId),
|
|
@@ -264,7 +248,7 @@ const Tabs = ({
|
|
|
264
248
|
updateErrors,
|
|
265
249
|
updateWarnings,
|
|
266
250
|
updateInfos
|
|
267
|
-
})
|
|
251
|
+
});
|
|
268
252
|
};
|
|
269
253
|
/** Builds all tabs where non selected tabs have class of hidden */
|
|
270
254
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ModalProps } from "../modal";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
|
-
|
|
4
|
+
import { DialogSizes } from "./dialog.config";
|
|
5
|
+
declare const PADDING_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
6
|
+
declare type PaddingValues = typeof PADDING_VALUES[number];
|
|
5
7
|
export interface ContentPaddingInterface {
|
|
6
8
|
p?: PaddingValues;
|
|
7
9
|
py?: PaddingValues;
|
|
8
10
|
px?: PaddingValues;
|
|
9
11
|
}
|
|
10
|
-
declare type DialogSizes = "auto" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
|
|
11
12
|
export interface DialogProps extends ModalProps, TagProps {
|
|
12
13
|
/** Custom class name */
|
|
13
14
|
className?: string;
|
|
@@ -19,14 +19,14 @@ var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal_
|
|
|
19
19
|
|
|
20
20
|
var _dialog = require("./dialog.style");
|
|
21
21
|
|
|
22
|
+
var _dialog2 = require("./dialog.config");
|
|
23
|
+
|
|
22
24
|
var _focusTrap = _interopRequireDefault(require("../../__internal__/focus-trap"));
|
|
23
25
|
|
|
24
26
|
var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
25
27
|
|
|
26
28
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
27
29
|
|
|
28
|
-
var _dialog2 = require("./dialog.config");
|
|
29
|
-
|
|
30
30
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
31
31
|
|
|
32
32
|
var _useIsStickyFooterForm = _interopRequireDefault(require("../../hooks/__internal__/useIsStickyFooterForm"));
|
|
@@ -39,6 +39,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
39
39
|
|
|
40
40
|
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); }
|
|
41
41
|
|
|
42
|
+
const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
43
|
+
|
|
42
44
|
const Dialog = ({
|
|
43
45
|
className,
|
|
44
46
|
children,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare const DIALOG_SIZES:
|
|
1
|
+
export declare const DIALOG_SIZES: readonly ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
2
2
|
export declare const TOP_MARGIN = 20;
|
|
3
3
|
export declare const CONTENT_TOP_PADDING = 24;
|
|
4
4
|
export declare const HORIZONTAL_PADDING = 32;
|
|
5
5
|
export declare const CONTENT_BOTTOM_PADDING = 30;
|
|
6
|
+
export declare type DialogSizes = typeof DIALOG_SIZES[number];
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CONTENT_BOTTOM_PADDING = exports.HORIZONTAL_PADDING = exports.CONTENT_TOP_PADDING = exports.TOP_MARGIN = exports.DIALOG_SIZES = void 0;
|
|
7
|
-
const DIALOG_SIZES = ["extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
7
|
+
const DIALOG_SIZES = ["auto", "extra-small", "small", "medium-small", "medium", "medium-large", "large", "extra-large"];
|
|
8
8
|
exports.DIALOG_SIZES = DIALOG_SIZES;
|
|
9
9
|
const TOP_MARGIN = 20;
|
|
10
10
|
exports.TOP_MARGIN = TOP_MARGIN;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
+
import { DialogSizes } from "./dialog.config";
|
|
1
2
|
import { ContentPaddingInterface } from "./dialog.component";
|
|
2
|
-
declare const dialogSizes: {
|
|
3
|
-
auto: string;
|
|
4
|
-
"extra-small": string;
|
|
5
|
-
small: string;
|
|
6
|
-
"medium-small": string;
|
|
7
|
-
medium: string;
|
|
8
|
-
"medium-large": string;
|
|
9
|
-
large: string;
|
|
10
|
-
"extra-large": string;
|
|
11
|
-
};
|
|
12
3
|
declare type StyledDialogProps = {
|
|
13
4
|
topMargin: number;
|
|
14
|
-
size?:
|
|
5
|
+
size?: DialogSizes;
|
|
15
6
|
dialogHeight?: string;
|
|
16
7
|
};
|
|
17
8
|
declare const StyledDialog: import("styled-components").StyledComponent<"div", any, StyledDialogProps & ContentPaddingInterface, never>;
|
|
@@ -42,6 +42,7 @@ const Tab = ({
|
|
|
42
42
|
updateWarnings,
|
|
43
43
|
updateInfos,
|
|
44
44
|
href,
|
|
45
|
+
title,
|
|
45
46
|
...rest
|
|
46
47
|
}) => {
|
|
47
48
|
const [tabErrors, setTabErrors] = (0, _react.useState)({});
|
|
@@ -113,7 +114,7 @@ Tab.propTypes = { ...paddingPropTypes,
|
|
|
113
114
|
/** Overrides Title default layout with a one defined in this prop */
|
|
114
115
|
customLayout: _propTypes.default.node,
|
|
115
116
|
|
|
116
|
-
/** Boolean indicating selected state of Tab. */
|
|
117
|
+
/** @ignore @private Boolean indicating selected state of Tab. */
|
|
117
118
|
isTabSelected: _propTypes.default.bool,
|
|
118
119
|
|
|
119
120
|
/** The position of the Tab. */
|
|
@@ -14,7 +14,7 @@ export interface TabProps extends PaddingProps {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
/** The child elements of Tab component. */
|
|
16
16
|
children?: React.ReactNode;
|
|
17
|
-
/** Boolean indicating selected state of Tab. */
|
|
17
|
+
/** @ignore @private Boolean indicating selected state of Tab. */
|
|
18
18
|
isTabSelected?: boolean;
|
|
19
19
|
/** The position of the Tab. */
|
|
20
20
|
position?: "top" | "left";
|
|
@@ -70,7 +70,7 @@ const Tabs = ({
|
|
|
70
70
|
length: filteredChildren.length
|
|
71
71
|
}).map(() => /*#__PURE__*/(0, _react.createRef)()), [filteredChildren.length]);
|
|
72
72
|
const previousSelectedTabId = (0, _react.useRef)(selectedTabId);
|
|
73
|
-
const [selectedTabIdState, setSelectedTabIdState] = (0, _react.useState)();
|
|
73
|
+
const [selectedTabIdState, setSelectedTabIdState] = (0, _react.useState)(selectedTabId || filteredChildren[0].props.tabId);
|
|
74
74
|
const [tabStopId, setTabStopId] = (0, _react.useState)();
|
|
75
75
|
const {
|
|
76
76
|
isInSidebar
|
|
@@ -78,17 +78,6 @@ const Tabs = ({
|
|
|
78
78
|
const [tabsErrors, setTabsErrors] = (0, _react.useState)({});
|
|
79
79
|
const [tabsWarnings, setTabsWarnings] = (0, _react.useState)({});
|
|
80
80
|
const [tabsInfos, setTabsInfos] = (0, _react.useState)({});
|
|
81
|
-
(0, _react.useLayoutEffect)(() => {
|
|
82
|
-
const selectedTab = selectedTabId || _react.Children.toArray(children)[0].props.tabId;
|
|
83
|
-
|
|
84
|
-
if (!tabIds.includes(selectedTabId)) {
|
|
85
|
-
setTabStopId(_react.default.Children.toArray(children)[0].props.tabId);
|
|
86
|
-
} else {
|
|
87
|
-
setTabStopId(selectedTab);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setSelectedTabIdState(selectedTab);
|
|
91
|
-
}, [children, selectedTabId, tabIds]);
|
|
92
81
|
const updateErrors = (0, _react.useCallback)((id, hasError) => {
|
|
93
82
|
if (tabsErrors[id] !== hasError) {
|
|
94
83
|
setTabsErrors({ ...tabsErrors,
|
|
@@ -285,13 +274,8 @@ const Tabs = ({
|
|
|
285
274
|
|
|
286
275
|
|
|
287
276
|
const visibleTab = () => {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (isTabSelected(child.props.tabId)) {
|
|
291
|
-
tab = child;
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
return tab ? /*#__PURE__*/(0, _react.cloneElement)(tab, { ...tab.props,
|
|
277
|
+
const tab = filteredChildren.find(child => isTabSelected(child.props.tabId));
|
|
278
|
+
return tab && /*#__PURE__*/(0, _react.cloneElement)(tab, { ...tab.props,
|
|
295
279
|
role: "tabpanel",
|
|
296
280
|
position,
|
|
297
281
|
isTabSelected: isTabSelected(tab.props.tabId),
|
|
@@ -300,7 +284,7 @@ const Tabs = ({
|
|
|
300
284
|
updateErrors,
|
|
301
285
|
updateWarnings,
|
|
302
286
|
updateInfos
|
|
303
|
-
})
|
|
287
|
+
});
|
|
304
288
|
};
|
|
305
289
|
/** Builds all tabs where non selected tabs have class of hidden */
|
|
306
290
|
|