carbon-react 120.2.1 → 120.3.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/definition-list/__internal__/dl.context.d.ts +7 -1
- package/esm/components/definition-list/dd.component.js +9 -1
- package/esm/components/definition-list/definition-list.style.d.ts +4 -22
- package/esm/components/definition-list/definition-list.style.js +19 -17
- package/esm/components/definition-list/dl.component.d.ts +6 -2
- package/esm/components/definition-list/dl.component.js +12 -53
- package/esm/components/definition-list/dt.component.js +5 -2
- package/lib/components/definition-list/__internal__/dl.context.d.ts +7 -1
- package/lib/components/definition-list/dd.component.js +11 -1
- package/lib/components/definition-list/definition-list.style.d.ts +4 -22
- package/lib/components/definition-list/definition-list.style.js +20 -20
- package/lib/components/definition-list/dl.component.d.ts +6 -2
- package/lib/components/definition-list/dl.component.js +11 -52
- package/lib/components/definition-list/dt.component.js +5 -2
- package/package.json +1 -1
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
export declare type ElementAlignment = "left" | "center" | "right";
|
|
3
|
+
export interface DlContextProps {
|
|
4
|
+
/** Render the DefinitionList as a single column */
|
|
3
5
|
asSingleColumn?: boolean;
|
|
6
|
+
/** This string will specify the text align styling of the `<dt></dt>`. */
|
|
7
|
+
dtTextAlign?: ElementAlignment;
|
|
8
|
+
/** This string will specify the text align styling of the `<dd></dd>`. */
|
|
9
|
+
ddTextAlign?: ElementAlignment;
|
|
4
10
|
}
|
|
5
11
|
declare const _default: React.Context<DlContextProps>;
|
|
6
12
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
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 from "react";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { StyledDd } from "./definition-list.style";
|
|
5
|
+
import DlContext from "./__internal__/dl.context";
|
|
5
6
|
const Dd = ({
|
|
6
7
|
children,
|
|
7
8
|
...rest
|
|
@@ -9,7 +10,14 @@ const Dd = ({
|
|
|
9
10
|
const {
|
|
10
11
|
mb
|
|
11
12
|
} = rest;
|
|
13
|
+
const {
|
|
14
|
+
asSingleColumn,
|
|
15
|
+
ddTextAlign
|
|
16
|
+
} = useContext(DlContext);
|
|
12
17
|
return /*#__PURE__*/React.createElement(StyledDd, _extends({
|
|
18
|
+
"data-element": "dd",
|
|
19
|
+
asSingleColumn: asSingleColumn,
|
|
20
|
+
ddTextAlign: ddTextAlign,
|
|
13
21
|
mb: mb || 2
|
|
14
22
|
}, rest), children);
|
|
15
23
|
};
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
by the `StyledDdDiv`. This prop has no effect when `asSingleColumn` is set.
|
|
6
|
-
*/
|
|
7
|
-
w?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare type ElementAlignment = "left" | "center" | "right";
|
|
10
|
-
export declare const StyledDl: import("styled-components").StyledComponent<"dl", any, StyledDlProps, never>;
|
|
11
|
-
export interface StyledDtDivProps {
|
|
12
|
-
/** This string will specify the text align styling of the `<dt></dt>`. */
|
|
13
|
-
dtTextAlign?: ElementAlignment;
|
|
14
|
-
}
|
|
15
|
-
export declare const StyledDtDiv: import("styled-components").StyledComponent<"div", any, StyledDtDivProps, never>;
|
|
16
|
-
export interface StyledDdDivProps {
|
|
17
|
-
/** This string will specify the text align styling of the `<dd></dd>`. */
|
|
18
|
-
ddTextAlign?: ElementAlignment;
|
|
19
|
-
}
|
|
20
|
-
export declare const StyledDdDiv: import("styled-components").StyledComponent<"div", any, StyledDdDivProps, never>;
|
|
21
|
-
export declare const StyledDt: import("styled-components").StyledComponent<"dt", any, {}, never>;
|
|
22
|
-
export declare const StyledDd: import("styled-components").StyledComponent<"dd", any, {}, never>;
|
|
1
|
+
import { DlProps } from "./dl.component";
|
|
2
|
+
export declare const StyledDl: import("styled-components").StyledComponent<"dl", any, Omit<DlProps, "dtTextAlign" | "ddTextAlign">, never>;
|
|
3
|
+
export declare const StyledDt: import("styled-components").StyledComponent<"dt", any, Pick<DlProps, "dtTextAlign" | "asSingleColumn">, never>;
|
|
4
|
+
export declare const StyledDd: import("styled-components").StyledComponent<"dd", any, Pick<DlProps, "ddTextAlign" | "asSingleColumn">, never>;
|
|
@@ -26,30 +26,22 @@ export const StyledDl = styled.dl`
|
|
|
26
26
|
StyledDl.defaultProps = {
|
|
27
27
|
theme: baseTheme
|
|
28
28
|
};
|
|
29
|
-
export const
|
|
29
|
+
export const StyledDt = styled.dt`
|
|
30
30
|
${space}
|
|
31
|
+
font-size: var(--fontSizes100);
|
|
32
|
+
font-weight: 700;
|
|
33
|
+
color: var(--colorsUtilityYin090);
|
|
34
|
+
${({
|
|
35
|
+
asSingleColumn
|
|
36
|
+
}) => !asSingleColumn && css`
|
|
37
|
+
grid-column: 1;
|
|
38
|
+
`}
|
|
31
39
|
${({
|
|
32
40
|
dtTextAlign
|
|
33
41
|
}) => css`
|
|
34
42
|
text-align: ${dtTextAlign};
|
|
35
43
|
`}
|
|
36
44
|
`;
|
|
37
|
-
StyledDtDiv.defaultProps = {
|
|
38
|
-
theme: baseTheme
|
|
39
|
-
};
|
|
40
|
-
export const StyledDdDiv = styled.div`
|
|
41
|
-
${({
|
|
42
|
-
ddTextAlign
|
|
43
|
-
}) => css`
|
|
44
|
-
text-align: ${ddTextAlign};
|
|
45
|
-
`}
|
|
46
|
-
`;
|
|
47
|
-
export const StyledDt = styled.dt`
|
|
48
|
-
${space}
|
|
49
|
-
font-size: var(--fontSizes100);
|
|
50
|
-
font-weight: 700;
|
|
51
|
-
color: var(--colorsUtilityYin090);
|
|
52
|
-
`;
|
|
53
45
|
StyledDt.defaultProps = {
|
|
54
46
|
theme: baseTheme
|
|
55
47
|
};
|
|
@@ -58,6 +50,16 @@ export const StyledDd = styled.dd`
|
|
|
58
50
|
font-weight: var(--fontWeights400);
|
|
59
51
|
color: var(--colorsUtilityYin065);
|
|
60
52
|
margin-left: 0px;
|
|
53
|
+
${({
|
|
54
|
+
asSingleColumn
|
|
55
|
+
}) => !asSingleColumn && css`
|
|
56
|
+
grid-column: 2;
|
|
57
|
+
`}
|
|
58
|
+
${({
|
|
59
|
+
ddTextAlign
|
|
60
|
+
}) => css`
|
|
61
|
+
text-align: ${ddTextAlign};
|
|
62
|
+
`}
|
|
61
63
|
|
|
62
64
|
${StyledButton} {
|
|
63
65
|
padding: 0;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
|
-
import {
|
|
4
|
-
export interface DlProps extends SpaceProps,
|
|
3
|
+
import { DlContextProps } from "./__internal__/dl.context";
|
|
4
|
+
export interface DlProps extends SpaceProps, DlContextProps {
|
|
5
5
|
/** HTML id attribute of the input */
|
|
6
6
|
id?: string;
|
|
7
7
|
/** prop to render children. */
|
|
8
8
|
children: React.ReactNode;
|
|
9
|
+
/** This value will specify the width of the `StyledDtDiv` as a percentage. The remaining space will be taken up
|
|
10
|
+
by the `StyledDdDiv`. This prop has no effect when `asSingleColumn` is set.
|
|
11
|
+
*/
|
|
12
|
+
w?: number;
|
|
9
13
|
}
|
|
10
14
|
declare const Dl: {
|
|
11
15
|
({ children, w, dtTextAlign, ddTextAlign, asSingleColumn, ...rest }: DlProps): React.JSX.Element;
|
|
@@ -1,10 +1,7 @@
|
|
|
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
2
|
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import {
|
|
5
|
-
import { StyledDl, StyledDtDiv, StyledDdDiv } from "./definition-list.style";
|
|
6
|
-
import Dt from "./dt.component";
|
|
7
|
-
import Dd from "./dd.component";
|
|
4
|
+
import { StyledDl } from "./definition-list.style";
|
|
8
5
|
import DlContext from "./__internal__/dl.context";
|
|
9
6
|
const Dl = ({
|
|
10
7
|
children,
|
|
@@ -13,54 +10,16 @@ const Dl = ({
|
|
|
13
10
|
ddTextAlign = "left",
|
|
14
11
|
asSingleColumn = false,
|
|
15
12
|
...rest
|
|
16
|
-
}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
composeDlComponent(child.props.children);
|
|
28
|
-
} else {
|
|
29
|
-
if (isElement(child) && child.type === Dt) {
|
|
30
|
-
dtLabel = child;
|
|
31
|
-
}
|
|
32
|
-
if (isElement(child) && child.type === Dd) {
|
|
33
|
-
ddContent.push(child);
|
|
34
|
-
}
|
|
35
|
-
isLastChild = index === childrenArray.length - 1;
|
|
36
|
-
const originalKey = isElement(child) && child.props.key;
|
|
37
|
-
const nextItem = childrenArray[index + 1];
|
|
38
|
-
const isNextItemDt = isElement(nextItem) && nextItem.type === Dt;
|
|
39
|
-
nextItemIsNotDd = !isLastChild && (isNextItemDt || isFragment(nextItem));
|
|
40
|
-
if (dtLabel && (nextItemIsNotDd || isLastChild)) {
|
|
41
|
-
key = `${key + 1}`;
|
|
42
|
-
dlComponent.push( /*#__PURE__*/React.createElement(React.Fragment, {
|
|
43
|
-
key: originalKey || key
|
|
44
|
-
}, /*#__PURE__*/React.createElement(StyledDtDiv, {
|
|
45
|
-
dtTextAlign: dtTextAlign
|
|
46
|
-
}, dtLabel), /*#__PURE__*/React.createElement(StyledDdDiv, {
|
|
47
|
-
ddTextAlign: ddTextAlign
|
|
48
|
-
}, ddContent)));
|
|
49
|
-
ddContent = [];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return dlComponent;
|
|
54
|
-
};
|
|
55
|
-
return /*#__PURE__*/React.createElement(StyledDl, _extends({
|
|
56
|
-
w: w,
|
|
57
|
-
"data-component": "dl",
|
|
58
|
-
asSingleColumn: asSingleColumn
|
|
59
|
-
}, rest), /*#__PURE__*/React.createElement(DlContext.Provider, {
|
|
60
|
-
value: {
|
|
61
|
-
asSingleColumn
|
|
62
|
-
}
|
|
63
|
-
}, composeDlComponent(listChildren)));
|
|
64
|
-
};
|
|
13
|
+
}) => /*#__PURE__*/React.createElement(StyledDl, _extends({
|
|
14
|
+
w: w,
|
|
15
|
+
"data-component": "dl",
|
|
16
|
+
asSingleColumn: asSingleColumn
|
|
17
|
+
}, rest), /*#__PURE__*/React.createElement(DlContext.Provider, {
|
|
18
|
+
value: {
|
|
19
|
+
asSingleColumn,
|
|
20
|
+
dtTextAlign,
|
|
21
|
+
ddTextAlign
|
|
22
|
+
}
|
|
23
|
+
}, children));
|
|
65
24
|
Dl.displayName = "Dl";
|
|
66
25
|
export default Dl;
|
|
@@ -8,7 +8,8 @@ const Dt = ({
|
|
|
8
8
|
...rest
|
|
9
9
|
}) => {
|
|
10
10
|
const {
|
|
11
|
-
asSingleColumn
|
|
11
|
+
asSingleColumn,
|
|
12
|
+
dtTextAlign
|
|
12
13
|
} = useContext(DlContext);
|
|
13
14
|
const {
|
|
14
15
|
mb,
|
|
@@ -17,7 +18,9 @@ const Dt = ({
|
|
|
17
18
|
return /*#__PURE__*/React.createElement(StyledDt, _extends({
|
|
18
19
|
"data-element": "dt",
|
|
19
20
|
mb: mb || asSingleColumn ? undefined : 2,
|
|
20
|
-
pr: pr || asSingleColumn ? undefined : 3
|
|
21
|
+
pr: pr || asSingleColumn ? undefined : 3,
|
|
22
|
+
dtTextAlign: dtTextAlign,
|
|
23
|
+
asSingleColumn: asSingleColumn
|
|
21
24
|
}, rest), children);
|
|
22
25
|
};
|
|
23
26
|
Dt.displayName = "Dt";
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
export declare type ElementAlignment = "left" | "center" | "right";
|
|
3
|
+
export interface DlContextProps {
|
|
4
|
+
/** Render the DefinitionList as a single column */
|
|
3
5
|
asSingleColumn?: boolean;
|
|
6
|
+
/** This string will specify the text align styling of the `<dt></dt>`. */
|
|
7
|
+
dtTextAlign?: ElementAlignment;
|
|
8
|
+
/** This string will specify the text align styling of the `<dd></dd>`. */
|
|
9
|
+
ddTextAlign?: ElementAlignment;
|
|
4
10
|
}
|
|
5
11
|
declare const _default: React.Context<DlContextProps>;
|
|
6
12
|
export default _default;
|
|
@@ -4,10 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _definitionList = require("./definition-list.style");
|
|
10
|
+
var _dl = _interopRequireDefault(require("./__internal__/dl.context"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
14
|
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); }
|
|
12
15
|
const Dd = ({
|
|
13
16
|
children,
|
|
@@ -16,7 +19,14 @@ const Dd = ({
|
|
|
16
19
|
const {
|
|
17
20
|
mb
|
|
18
21
|
} = rest;
|
|
22
|
+
const {
|
|
23
|
+
asSingleColumn,
|
|
24
|
+
ddTextAlign
|
|
25
|
+
} = (0, _react.useContext)(_dl.default);
|
|
19
26
|
return /*#__PURE__*/_react.default.createElement(_definitionList.StyledDd, _extends({
|
|
27
|
+
"data-element": "dd",
|
|
28
|
+
asSingleColumn: asSingleColumn,
|
|
29
|
+
ddTextAlign: ddTextAlign,
|
|
20
30
|
mb: mb || 2
|
|
21
31
|
}, rest), children);
|
|
22
32
|
};
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
by the `StyledDdDiv`. This prop has no effect when `asSingleColumn` is set.
|
|
6
|
-
*/
|
|
7
|
-
w?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare type ElementAlignment = "left" | "center" | "right";
|
|
10
|
-
export declare const StyledDl: import("styled-components").StyledComponent<"dl", any, StyledDlProps, never>;
|
|
11
|
-
export interface StyledDtDivProps {
|
|
12
|
-
/** This string will specify the text align styling of the `<dt></dt>`. */
|
|
13
|
-
dtTextAlign?: ElementAlignment;
|
|
14
|
-
}
|
|
15
|
-
export declare const StyledDtDiv: import("styled-components").StyledComponent<"div", any, StyledDtDivProps, never>;
|
|
16
|
-
export interface StyledDdDivProps {
|
|
17
|
-
/** This string will specify the text align styling of the `<dd></dd>`. */
|
|
18
|
-
ddTextAlign?: ElementAlignment;
|
|
19
|
-
}
|
|
20
|
-
export declare const StyledDdDiv: import("styled-components").StyledComponent<"div", any, StyledDdDivProps, never>;
|
|
21
|
-
export declare const StyledDt: import("styled-components").StyledComponent<"dt", any, {}, never>;
|
|
22
|
-
export declare const StyledDd: import("styled-components").StyledComponent<"dd", any, {}, never>;
|
|
1
|
+
import { DlProps } from "./dl.component";
|
|
2
|
+
export declare const StyledDl: import("styled-components").StyledComponent<"dl", any, Omit<DlProps, "dtTextAlign" | "ddTextAlign">, never>;
|
|
3
|
+
export declare const StyledDt: import("styled-components").StyledComponent<"dt", any, Pick<DlProps, "dtTextAlign" | "asSingleColumn">, never>;
|
|
4
|
+
export declare const StyledDd: import("styled-components").StyledComponent<"dd", any, Pick<DlProps, "ddTextAlign" | "asSingleColumn">, never>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.StyledDt = exports.StyledDl = exports.StyledDd = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _button = _interopRequireDefault(require("../button/button.style"));
|
|
@@ -36,32 +36,22 @@ exports.StyledDl = StyledDl;
|
|
|
36
36
|
StyledDl.defaultProps = {
|
|
37
37
|
theme: _themes.baseTheme
|
|
38
38
|
};
|
|
39
|
-
const
|
|
39
|
+
const StyledDt = _styledComponents.default.dt`
|
|
40
40
|
${_styledSystem.space}
|
|
41
|
+
font-size: var(--fontSizes100);
|
|
42
|
+
font-weight: 700;
|
|
43
|
+
color: var(--colorsUtilityYin090);
|
|
44
|
+
${({
|
|
45
|
+
asSingleColumn
|
|
46
|
+
}) => !asSingleColumn && (0, _styledComponents.css)`
|
|
47
|
+
grid-column: 1;
|
|
48
|
+
`}
|
|
41
49
|
${({
|
|
42
50
|
dtTextAlign
|
|
43
51
|
}) => (0, _styledComponents.css)`
|
|
44
52
|
text-align: ${dtTextAlign};
|
|
45
53
|
`}
|
|
46
54
|
`;
|
|
47
|
-
exports.StyledDtDiv = StyledDtDiv;
|
|
48
|
-
StyledDtDiv.defaultProps = {
|
|
49
|
-
theme: _themes.baseTheme
|
|
50
|
-
};
|
|
51
|
-
const StyledDdDiv = _styledComponents.default.div`
|
|
52
|
-
${({
|
|
53
|
-
ddTextAlign
|
|
54
|
-
}) => (0, _styledComponents.css)`
|
|
55
|
-
text-align: ${ddTextAlign};
|
|
56
|
-
`}
|
|
57
|
-
`;
|
|
58
|
-
exports.StyledDdDiv = StyledDdDiv;
|
|
59
|
-
const StyledDt = _styledComponents.default.dt`
|
|
60
|
-
${_styledSystem.space}
|
|
61
|
-
font-size: var(--fontSizes100);
|
|
62
|
-
font-weight: 700;
|
|
63
|
-
color: var(--colorsUtilityYin090);
|
|
64
|
-
`;
|
|
65
55
|
exports.StyledDt = StyledDt;
|
|
66
56
|
StyledDt.defaultProps = {
|
|
67
57
|
theme: _themes.baseTheme
|
|
@@ -71,6 +61,16 @@ const StyledDd = _styledComponents.default.dd`
|
|
|
71
61
|
font-weight: var(--fontWeights400);
|
|
72
62
|
color: var(--colorsUtilityYin065);
|
|
73
63
|
margin-left: 0px;
|
|
64
|
+
${({
|
|
65
|
+
asSingleColumn
|
|
66
|
+
}) => !asSingleColumn && (0, _styledComponents.css)`
|
|
67
|
+
grid-column: 2;
|
|
68
|
+
`}
|
|
69
|
+
${({
|
|
70
|
+
ddTextAlign
|
|
71
|
+
}) => (0, _styledComponents.css)`
|
|
72
|
+
text-align: ${ddTextAlign};
|
|
73
|
+
`}
|
|
74
74
|
|
|
75
75
|
${_button.default} {
|
|
76
76
|
padding: 0;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
|
-
import {
|
|
4
|
-
export interface DlProps extends SpaceProps,
|
|
3
|
+
import { DlContextProps } from "./__internal__/dl.context";
|
|
4
|
+
export interface DlProps extends SpaceProps, DlContextProps {
|
|
5
5
|
/** HTML id attribute of the input */
|
|
6
6
|
id?: string;
|
|
7
7
|
/** prop to render children. */
|
|
8
8
|
children: React.ReactNode;
|
|
9
|
+
/** This value will specify the width of the `StyledDtDiv` as a percentage. The remaining space will be taken up
|
|
10
|
+
by the `StyledDdDiv`. This prop has no effect when `asSingleColumn` is set.
|
|
11
|
+
*/
|
|
12
|
+
w?: number;
|
|
9
13
|
}
|
|
10
14
|
declare const Dl: {
|
|
11
15
|
({ children, w, dtTextAlign, ddTextAlign, asSingleColumn, ...rest }: DlProps): React.JSX.Element;
|
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _reactIs = require("react-is");
|
|
10
9
|
var _definitionList = require("./definition-list.style");
|
|
11
|
-
var _dt = _interopRequireDefault(require("./dt.component"));
|
|
12
|
-
var _dd = _interopRequireDefault(require("./dd.component"));
|
|
13
10
|
var _dl = _interopRequireDefault(require("./__internal__/dl.context"));
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
12
|
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); }
|
|
@@ -20,55 +17,17 @@ const Dl = ({
|
|
|
20
17
|
ddTextAlign = "left",
|
|
21
18
|
asSingleColumn = false,
|
|
22
19
|
...rest
|
|
23
|
-
}) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
composeDlComponent(child.props.children);
|
|
35
|
-
} else {
|
|
36
|
-
if ((0, _reactIs.isElement)(child) && child.type === _dt.default) {
|
|
37
|
-
dtLabel = child;
|
|
38
|
-
}
|
|
39
|
-
if ((0, _reactIs.isElement)(child) && child.type === _dd.default) {
|
|
40
|
-
ddContent.push(child);
|
|
41
|
-
}
|
|
42
|
-
isLastChild = index === childrenArray.length - 1;
|
|
43
|
-
const originalKey = (0, _reactIs.isElement)(child) && child.props.key;
|
|
44
|
-
const nextItem = childrenArray[index + 1];
|
|
45
|
-
const isNextItemDt = (0, _reactIs.isElement)(nextItem) && nextItem.type === _dt.default;
|
|
46
|
-
nextItemIsNotDd = !isLastChild && (isNextItemDt || (0, _reactIs.isFragment)(nextItem));
|
|
47
|
-
if (dtLabel && (nextItemIsNotDd || isLastChild)) {
|
|
48
|
-
key = `${key + 1}`;
|
|
49
|
-
dlComponent.push( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
50
|
-
key: originalKey || key
|
|
51
|
-
}, /*#__PURE__*/_react.default.createElement(_definitionList.StyledDtDiv, {
|
|
52
|
-
dtTextAlign: dtTextAlign
|
|
53
|
-
}, dtLabel), /*#__PURE__*/_react.default.createElement(_definitionList.StyledDdDiv, {
|
|
54
|
-
ddTextAlign: ddTextAlign
|
|
55
|
-
}, ddContent)));
|
|
56
|
-
ddContent = [];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return dlComponent;
|
|
61
|
-
};
|
|
62
|
-
return /*#__PURE__*/_react.default.createElement(_definitionList.StyledDl, _extends({
|
|
63
|
-
w: w,
|
|
64
|
-
"data-component": "dl",
|
|
65
|
-
asSingleColumn: asSingleColumn
|
|
66
|
-
}, rest), /*#__PURE__*/_react.default.createElement(_dl.default.Provider, {
|
|
67
|
-
value: {
|
|
68
|
-
asSingleColumn
|
|
69
|
-
}
|
|
70
|
-
}, composeDlComponent(listChildren)));
|
|
71
|
-
};
|
|
20
|
+
}) => /*#__PURE__*/_react.default.createElement(_definitionList.StyledDl, _extends({
|
|
21
|
+
w: w,
|
|
22
|
+
"data-component": "dl",
|
|
23
|
+
asSingleColumn: asSingleColumn
|
|
24
|
+
}, rest), /*#__PURE__*/_react.default.createElement(_dl.default.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
asSingleColumn,
|
|
27
|
+
dtTextAlign,
|
|
28
|
+
ddTextAlign
|
|
29
|
+
}
|
|
30
|
+
}, children));
|
|
72
31
|
Dl.displayName = "Dl";
|
|
73
32
|
var _default = Dl;
|
|
74
33
|
exports.default = _default;
|
|
@@ -17,7 +17,8 @@ const Dt = ({
|
|
|
17
17
|
...rest
|
|
18
18
|
}) => {
|
|
19
19
|
const {
|
|
20
|
-
asSingleColumn
|
|
20
|
+
asSingleColumn,
|
|
21
|
+
dtTextAlign
|
|
21
22
|
} = (0, _react.useContext)(_dl.default);
|
|
22
23
|
const {
|
|
23
24
|
mb,
|
|
@@ -26,7 +27,9 @@ const Dt = ({
|
|
|
26
27
|
return /*#__PURE__*/_react.default.createElement(_definitionList.StyledDt, _extends({
|
|
27
28
|
"data-element": "dt",
|
|
28
29
|
mb: mb || asSingleColumn ? undefined : 2,
|
|
29
|
-
pr: pr || asSingleColumn ? undefined : 3
|
|
30
|
+
pr: pr || asSingleColumn ? undefined : 3,
|
|
31
|
+
dtTextAlign: dtTextAlign,
|
|
32
|
+
asSingleColumn: asSingleColumn
|
|
30
33
|
}, rest), children);
|
|
31
34
|
};
|
|
32
35
|
Dt.displayName = "Dt";
|