carbon-react 120.4.0 → 120.6.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/__spec_helper__/test-utils.d.ts +4 -1
- package/esm/__spec_helper__/test-utils.js +18 -2
- package/esm/components/advanced-color-picker/advanced-color-picker.style.d.ts +1 -1
- package/esm/components/dialog/dialog.component.d.ts +5 -1
- package/esm/components/dialog/dialog.component.js +76 -12
- package/esm/components/dialog/index.d.ts +1 -0
- package/esm/components/multi-action-button/multi-action-button.style.js +2 -2
- package/esm/components/sidebar/sidebar.style.js +2 -2
- package/esm/components/tile/tile.component.d.ts +5 -1
- package/esm/components/tile/tile.component.js +5 -1
- package/esm/components/tile/tile.style.d.ts +3 -2
- package/esm/components/tile/tile.style.js +12 -12
- package/esm/style/utils/element-sizing.d.ts +6 -0
- package/esm/style/utils/{width.js → element-sizing.js} +5 -4
- package/lib/__spec_helper__/test-utils.d.ts +4 -1
- package/lib/__spec_helper__/test-utils.js +19 -2
- package/lib/components/advanced-color-picker/advanced-color-picker.style.d.ts +1 -1
- package/lib/components/dialog/dialog.component.d.ts +5 -1
- package/lib/components/dialog/dialog.component.js +75 -12
- package/lib/components/dialog/index.d.ts +1 -0
- package/lib/components/multi-action-button/multi-action-button.style.js +2 -2
- package/lib/components/sidebar/sidebar.style.js +2 -2
- package/lib/components/tile/tile.component.d.ts +5 -1
- package/lib/components/tile/tile.component.js +5 -1
- package/lib/components/tile/tile.style.d.ts +3 -2
- package/lib/components/tile/tile.style.js +12 -12
- package/lib/style/utils/element-sizing.d.ts +6 -0
- package/lib/style/utils/{width.js → element-sizing.js} +5 -4
- package/package.json +1 -1
- package/esm/style/utils/width.d.ts +0 -3
- package/lib/style/utils/width.d.ts +0 -3
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -83,7 +83,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
83
83
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
84
84
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
85
85
|
const widthProps = ["width", "width", "200px"];
|
|
86
|
-
const
|
|
86
|
+
const heightProps = ["height", "height", "200px"];
|
|
87
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
87
88
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
88
89
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
89
90
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -241,6 +242,21 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
241
242
|
});
|
|
242
243
|
});
|
|
243
244
|
};
|
|
245
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
246
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
247
|
+
it("then height should have been set correctly", () => {
|
|
248
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
249
|
+
const props = {
|
|
250
|
+
[styledSystemProp]: value
|
|
251
|
+
};
|
|
252
|
+
const wrapper = mount(component({
|
|
253
|
+
...props
|
|
254
|
+
}));
|
|
255
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
256
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
244
260
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
245
261
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
246
262
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -339,4 +355,4 @@ const expectConsoleOutput = (message, type = "error") => {
|
|
|
339
355
|
global.console[type] = consoleType;
|
|
340
356
|
};
|
|
341
357
|
};
|
|
342
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
358
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput };
|
|
@@ -7,5 +7,5 @@ declare const HiddenCurrentColorList: import("styled-components").StyledComponen
|
|
|
7
7
|
displayName: string;
|
|
8
8
|
}, any, {}, never>;
|
|
9
9
|
declare const StyledAdvancedColorPickerPreview: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
-
declare const DialogStyle: import("styled-components").StyledComponent<(
|
|
10
|
+
declare const DialogStyle: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../dialog/dialog.component").DialogProps & import("react").RefAttributes<import("../dialog/dialog.component").DialogHandle>>, any, {}, never>;
|
|
11
11
|
export { StyledAdvancedColorPickerWrapper, HiddenCurrentColorList, StyledAdvancedColorPickerCell, StyledAdvancedColorPickerPreview, DialogStyle, };
|
|
@@ -59,5 +59,9 @@ export interface DialogProps extends ModalProps, TagProps {
|
|
|
59
59
|
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
60
60
|
focusableContainers?: CustomRefObject<HTMLElement>[];
|
|
61
61
|
}
|
|
62
|
-
export declare
|
|
62
|
+
export declare type DialogHandle = {
|
|
63
|
+
/** Programmatically focus on root container of Dialog. */
|
|
64
|
+
focus: () => void;
|
|
65
|
+
} | null;
|
|
66
|
+
export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<DialogHandle>>;
|
|
63
67
|
export default Dialog;
|
|
@@ -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, { useRef, useEffect, useLayoutEffect, useCallback } from "react";
|
|
2
|
+
import React, { useRef, useEffect, useLayoutEffect, useCallback, useImperativeHandle, forwardRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
5
5
|
import Modal from "../modal";
|
|
@@ -14,7 +14,7 @@ import useLocale from "../../hooks/__internal__/useLocale";
|
|
|
14
14
|
import useIsStickyFooterForm from "../../hooks/__internal__/useIsStickyFooterForm";
|
|
15
15
|
import useModalAria from "../../hooks/__internal__/useModalAria/useModalAria";
|
|
16
16
|
const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
17
|
-
|
|
17
|
+
const Dialog = /*#__PURE__*/forwardRef(({
|
|
18
18
|
className,
|
|
19
19
|
children,
|
|
20
20
|
open,
|
|
@@ -35,9 +35,9 @@ export const Dialog = ({
|
|
|
35
35
|
contentPadding = {},
|
|
36
36
|
focusableContainers,
|
|
37
37
|
...rest
|
|
38
|
-
}) => {
|
|
38
|
+
}, ref) => {
|
|
39
39
|
const locale = useLocale();
|
|
40
|
-
const
|
|
40
|
+
const containerRef = useRef(null);
|
|
41
41
|
const innerContentRef = useRef(null);
|
|
42
42
|
const titleRef = useRef(null);
|
|
43
43
|
const listenersAdded = useRef(false);
|
|
@@ -48,16 +48,21 @@ export const Dialog = ({
|
|
|
48
48
|
current: subtitleId
|
|
49
49
|
} = useRef(createGuid());
|
|
50
50
|
const hasStickyFooter = useIsStickyFooterForm(children);
|
|
51
|
-
const isTopModal = useModalAria(
|
|
51
|
+
const isTopModal = useModalAria(containerRef);
|
|
52
|
+
useImperativeHandle(ref, () => ({
|
|
53
|
+
focus() {
|
|
54
|
+
containerRef.current?.focus();
|
|
55
|
+
}
|
|
56
|
+
}), []);
|
|
52
57
|
const centerDialog = useCallback(() => {
|
|
53
58
|
/* istanbul ignore if */
|
|
54
|
-
if (!
|
|
59
|
+
if (!containerRef.current) {
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
62
|
const {
|
|
58
63
|
width: dialogWidth,
|
|
59
64
|
height: dialogHeight
|
|
60
|
-
} =
|
|
65
|
+
} = containerRef.current.getBoundingClientRect();
|
|
61
66
|
let midPointY = window.innerHeight / 2;
|
|
62
67
|
let midPointX = window.innerWidth / 2;
|
|
63
68
|
midPointY -= dialogHeight / 2;
|
|
@@ -68,8 +73,8 @@ export const Dialog = ({
|
|
|
68
73
|
if (midPointX < 0) {
|
|
69
74
|
midPointX = 0;
|
|
70
75
|
}
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
containerRef.current.style.top = `${midPointY}px`;
|
|
77
|
+
containerRef.current.style.left = `${midPointX}px`;
|
|
73
78
|
}, []);
|
|
74
79
|
useResizeObserver(innerContentRef, centerDialog, !open);
|
|
75
80
|
const addListeners = useCallback(() => {
|
|
@@ -155,22 +160,81 @@ export const Dialog = ({
|
|
|
155
160
|
focusFirstElement: focusFirstElement,
|
|
156
161
|
bespokeTrap: bespokeFocusTrap,
|
|
157
162
|
focusableSelectors: focusableSelectors,
|
|
158
|
-
wrapperRef:
|
|
163
|
+
wrapperRef: containerRef,
|
|
159
164
|
isOpen: open,
|
|
160
165
|
additionalWrapperRefs: focusableContainers
|
|
161
166
|
}, /*#__PURE__*/React.createElement(StyledDialog, _extends({
|
|
162
167
|
"aria-modal": isTopModal ? true : undefined,
|
|
163
|
-
ref:
|
|
168
|
+
ref: containerRef,
|
|
164
169
|
topMargin: TOP_MARGIN
|
|
165
170
|
}, dialogProps, {
|
|
166
171
|
"data-component": "dialog",
|
|
167
172
|
"data-element": "dialog",
|
|
168
173
|
"data-role": rest["data-role"],
|
|
169
|
-
role: role
|
|
174
|
+
role: role,
|
|
175
|
+
tabIndex: -1
|
|
170
176
|
}, contentPadding), dialogTitle(), closeIcon(), /*#__PURE__*/React.createElement(StyledDialogContent, _extends({}, contentPadding, {
|
|
171
177
|
hasStickyFooter: hasStickyFooter
|
|
172
178
|
}), /*#__PURE__*/React.createElement(StyledDialogInnerContent, _extends({
|
|
173
179
|
ref: innerContentRef
|
|
174
180
|
}, contentPadding), children)))));
|
|
181
|
+
});
|
|
182
|
+
Dialog.propTypes = {
|
|
183
|
+
"aria-describedby": PropTypes.string,
|
|
184
|
+
"aria-label": PropTypes.string,
|
|
185
|
+
"aria-labelledby": PropTypes.string,
|
|
186
|
+
"ariaRole": PropTypes.string,
|
|
187
|
+
"bespokeFocusTrap": PropTypes.func,
|
|
188
|
+
"children": PropTypes.node,
|
|
189
|
+
"className": PropTypes.string,
|
|
190
|
+
"contentPadding": PropTypes.shape({
|
|
191
|
+
"p": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
192
|
+
"px": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
193
|
+
"py": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
194
|
+
}),
|
|
195
|
+
"data-component": PropTypes.string,
|
|
196
|
+
"data-element": PropTypes.string,
|
|
197
|
+
"data-role": PropTypes.string,
|
|
198
|
+
"disableAutoFocus": PropTypes.bool,
|
|
199
|
+
"disableClose": PropTypes.bool,
|
|
200
|
+
"disableEscKey": PropTypes.bool,
|
|
201
|
+
"disableFocusTrap": PropTypes.bool,
|
|
202
|
+
"enableBackgroundUI": PropTypes.bool,
|
|
203
|
+
"focusableContainers": PropTypes.arrayOf(PropTypes.shape({
|
|
204
|
+
"current": function (props, propName) {
|
|
205
|
+
if (props[propName] == null) {
|
|
206
|
+
return null;
|
|
207
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
208
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
})),
|
|
212
|
+
"focusableSelectors": PropTypes.string,
|
|
213
|
+
"focusFirstElement": PropTypes.oneOfType([function (props, propName) {
|
|
214
|
+
if (props[propName] == null) {
|
|
215
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
216
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
217
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
218
|
+
}
|
|
219
|
+
}, PropTypes.shape({
|
|
220
|
+
"current": function (props, propName) {
|
|
221
|
+
if (props[propName] == null) {
|
|
222
|
+
return null;
|
|
223
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
224
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
})]),
|
|
228
|
+
"height": PropTypes.string,
|
|
229
|
+
"help": PropTypes.string,
|
|
230
|
+
"onCancel": PropTypes.func,
|
|
231
|
+
"open": PropTypes.bool.isRequired,
|
|
232
|
+
"role": PropTypes.string,
|
|
233
|
+
"showCloseIcon": PropTypes.bool,
|
|
234
|
+
"size": PropTypes.oneOf(["auto", "extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
|
|
235
|
+
"subtitle": PropTypes.string,
|
|
236
|
+
"timeout": PropTypes.number,
|
|
237
|
+
"title": PropTypes.node
|
|
175
238
|
};
|
|
239
|
+
export { Dialog };
|
|
176
240
|
export default Dialog;
|
|
@@ -3,7 +3,7 @@ import { margin } from "styled-system";
|
|
|
3
3
|
import StyledButton from "../button/button.style";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
5
|
import StyledIcon from "../icon/icon.style";
|
|
6
|
-
import
|
|
6
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
7
7
|
import { borderRadiusStyling } from "../split-button/split-button-children.style";
|
|
8
8
|
const StyledMultiActionButton = styled.div`
|
|
9
9
|
${margin}
|
|
@@ -14,7 +14,7 @@ const StyledMultiActionButton = styled.div`
|
|
|
14
14
|
${({
|
|
15
15
|
width
|
|
16
16
|
}) => width && css`
|
|
17
|
-
${
|
|
17
|
+
${computeSizing({
|
|
18
18
|
width
|
|
19
19
|
})}
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
5
5
|
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
@@ -39,7 +39,7 @@ const StyledSidebar = styled.div`
|
|
|
39
39
|
${!width && size && css`
|
|
40
40
|
width: ${SIDEBAR_SIZES_CSS[size]};
|
|
41
41
|
`}
|
|
42
|
-
${width &&
|
|
42
|
+
${width && computeSizing({
|
|
43
43
|
width
|
|
44
44
|
})}
|
|
45
45
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -7,8 +7,9 @@ export const Tile = ({
|
|
|
7
7
|
p = 3,
|
|
8
8
|
children,
|
|
9
9
|
orientation = "horizontal",
|
|
10
|
-
width,
|
|
10
|
+
width = "100%",
|
|
11
11
|
roundness = "default",
|
|
12
|
+
height,
|
|
12
13
|
...props
|
|
13
14
|
}) => {
|
|
14
15
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -24,12 +25,14 @@ export const Tile = ({
|
|
|
24
25
|
}
|
|
25
26
|
const {
|
|
26
27
|
width: contentWidth,
|
|
28
|
+
height: contentHeight,
|
|
27
29
|
...childProps
|
|
28
30
|
} = child.props;
|
|
29
31
|
const key = child.key || `tile-content-${index + 1}`;
|
|
30
32
|
return /*#__PURE__*/React.createElement(TileContent, _extends({
|
|
31
33
|
key: key,
|
|
32
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
33
36
|
isHorizontal: isHorizontal,
|
|
34
37
|
isVertical: isVertical
|
|
35
38
|
}, isVertical && {
|
|
@@ -43,6 +46,7 @@ export const Tile = ({
|
|
|
43
46
|
return /*#__PURE__*/React.createElement(StyledTile, _extends({
|
|
44
47
|
variant: variant,
|
|
45
48
|
width: width,
|
|
49
|
+
height: height,
|
|
46
50
|
"data-component": "tile",
|
|
47
51
|
isHorizontal: isHorizontal,
|
|
48
52
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { space } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
-
import
|
|
4
|
+
import computeSizing from "../../style/utils/element-sizing";
|
|
5
5
|
const getBorderColor = borderVariant => {
|
|
6
6
|
switch (borderVariant) {
|
|
7
7
|
case "selected":
|
|
@@ -22,7 +22,8 @@ const TileContent = styled.div`
|
|
|
22
22
|
${({
|
|
23
23
|
isHorizontal,
|
|
24
24
|
isVertical,
|
|
25
|
-
width
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
26
27
|
}) => css`
|
|
27
28
|
${space}
|
|
28
29
|
|
|
@@ -64,10 +65,11 @@ const TileContent = styled.div`
|
|
|
64
65
|
}
|
|
65
66
|
`}
|
|
66
67
|
|
|
67
|
-
${width && css`
|
|
68
|
+
${(width || height) && css`
|
|
68
69
|
flex-grow: 0;
|
|
69
|
-
${
|
|
70
|
-
width
|
|
70
|
+
${computeSizing({
|
|
71
|
+
width: width || /* istanbul ignore next */undefined,
|
|
72
|
+
height: height || undefined
|
|
71
73
|
})}
|
|
72
74
|
`}
|
|
73
75
|
`}
|
|
@@ -79,7 +81,8 @@ const StyledTile = styled.div`
|
|
|
79
81
|
isHorizontal,
|
|
80
82
|
variant,
|
|
81
83
|
width,
|
|
82
|
-
roundness
|
|
84
|
+
roundness,
|
|
85
|
+
height
|
|
83
86
|
}) => css`
|
|
84
87
|
${space}
|
|
85
88
|
|
|
@@ -104,13 +107,10 @@ const StyledTile = styled.div`
|
|
|
104
107
|
display: flex;
|
|
105
108
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
106
109
|
position: relative;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
${computeWidth({
|
|
111
|
-
width
|
|
110
|
+
${computeSizing({
|
|
111
|
+
width: width || /* istanbul ignore next */undefined,
|
|
112
|
+
height: height || undefined
|
|
112
113
|
})}
|
|
113
|
-
`}
|
|
114
114
|
`}
|
|
115
115
|
`;
|
|
116
116
|
TileContent.defaultProps = {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports
|
|
2
1
|
import { layout } from "styled-system";
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
6
5
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
7
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
6
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
export default (({
|
|
11
|
-
width
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
12
|
}) => layout({
|
|
13
|
-
width
|
|
13
|
+
width,
|
|
14
|
+
height
|
|
14
15
|
}));
|
|
@@ -44,10 +44,13 @@ declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.
|
|
|
44
44
|
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
45
45
|
width: string;
|
|
46
46
|
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
|
+
declare const testStyledSystemHeight: (component: (heightProperties?: {
|
|
48
|
+
height: string;
|
|
49
|
+
}) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
47
50
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
51
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
52
|
declare const testStyledSystemGrid: (component: (gridProperties?: GridProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
53
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
51
54
|
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
52
55
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
53
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
56
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemHeight, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemGrid, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
|
|
|
10
10
|
return _mockMatchMedia.mockMatchMedia;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
13
|
+
exports.toCSSCase = exports.testStyledSystemWidth = exports.testStyledSystemSpacing = exports.testStyledSystemPosition = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemLayout = exports.testStyledSystemHeight = exports.testStyledSystemGrid = exports.testStyledSystemFlexBox = exports.testStyledSystemColor = exports.testStyledSystemBackground = exports.simulate = exports.selectedItemOf = void 0;
|
|
14
14
|
var _enzyme = require("enzyme");
|
|
15
15
|
var _sprintfJs = require("sprintf-js");
|
|
16
16
|
var _baseTheme = require("../style/themes/base/base-theme.config");
|
|
@@ -110,7 +110,8 @@ const marginProps = [["m", "margin"], ["ml", "marginLeft"], ["mr", "marginRight"
|
|
|
110
110
|
const paddingProps = [["p", "padding"], ["pl", "paddingLeft"], ["pr", "paddingRight"], ["pt", "paddingTop"], ["pb", "paddingBottom"], ["px", "paddingLeft"], ["px", "paddingRight"], ["py", "paddingTop"], ["py", "paddingBottom"]];
|
|
111
111
|
const colorProps = [["color", "color", "#CCCCCC"], ["bg", "background-color", "#FFFFFF"], ["opacity", "opacity", "0.5"]];
|
|
112
112
|
const widthProps = ["width", "width", "200px"];
|
|
113
|
-
const
|
|
113
|
+
const heightProps = ["height", "height", "200px"];
|
|
114
|
+
const layoutProps = [widthProps, heightProps, ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
114
115
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
115
116
|
const gridProps = [["gridColumn", "gridColumn", "1 / span 2"], ["gridRow", "gridRow", "1 / span 2"], ["gridArea", "gridArea", "myArea"], ["gridAutoFlow", "gridAutoFlow", "column"], ["gridAutoRows", "gridAutoRows", "150px"], ["gridAutoColumns", "gridAutoColumns", "50px"], ["gridTemplateRows", "gridTemplateRows", "100px 300px"], ["gridTemplateColumns", "gridTemplateColumns", "auto auto auto auto"], ["gridTemplateAreas", "gridTemplateAreas", "myArea myArea . . ."]];
|
|
116
117
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
@@ -274,6 +275,22 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
274
275
|
});
|
|
275
276
|
};
|
|
276
277
|
exports.testStyledSystemWidth = testStyledSystemWidth;
|
|
278
|
+
const testStyledSystemHeight = (component, styleContainer) => {
|
|
279
|
+
describe("when a height prop is specified using styled system props", () => {
|
|
280
|
+
it("then height should have been set correctly", () => {
|
|
281
|
+
const [styledSystemProp, propName, value] = heightProps;
|
|
282
|
+
const props = {
|
|
283
|
+
[styledSystemProp]: value
|
|
284
|
+
};
|
|
285
|
+
const wrapper = (0, _enzyme.mount)(component({
|
|
286
|
+
...props
|
|
287
|
+
}));
|
|
288
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
289
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
exports.testStyledSystemHeight = testStyledSystemHeight;
|
|
277
294
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
278
295
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
279
296
|
it(`then ${propName} should have been set correctly`, () => {
|
|
@@ -7,5 +7,5 @@ declare const HiddenCurrentColorList: import("styled-components").StyledComponen
|
|
|
7
7
|
displayName: string;
|
|
8
8
|
}, any, {}, never>;
|
|
9
9
|
declare const StyledAdvancedColorPickerPreview: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
-
declare const DialogStyle: import("styled-components").StyledComponent<(
|
|
10
|
+
declare const DialogStyle: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../dialog/dialog.component").DialogProps & import("react").RefAttributes<import("../dialog/dialog.component").DialogHandle>>, any, {}, never>;
|
|
11
11
|
export { StyledAdvancedColorPickerWrapper, HiddenCurrentColorList, StyledAdvancedColorPickerCell, StyledAdvancedColorPickerPreview, DialogStyle, };
|
|
@@ -59,5 +59,9 @@ export interface DialogProps extends ModalProps, TagProps {
|
|
|
59
59
|
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
60
60
|
focusableContainers?: CustomRefObject<HTMLElement>[];
|
|
61
61
|
}
|
|
62
|
-
export declare
|
|
62
|
+
export declare type DialogHandle = {
|
|
63
|
+
/** Programmatically focus on root container of Dialog. */
|
|
64
|
+
focus: () => void;
|
|
65
|
+
} | null;
|
|
66
|
+
export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<DialogHandle>>;
|
|
63
67
|
export default Dialog;
|
|
@@ -23,7 +23,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
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; }
|
|
24
24
|
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); }
|
|
25
25
|
const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
26
|
-
const Dialog = ({
|
|
26
|
+
const Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
27
27
|
className,
|
|
28
28
|
children,
|
|
29
29
|
open,
|
|
@@ -44,9 +44,9 @@ const Dialog = ({
|
|
|
44
44
|
contentPadding = {},
|
|
45
45
|
focusableContainers,
|
|
46
46
|
...rest
|
|
47
|
-
}) => {
|
|
47
|
+
}, ref) => {
|
|
48
48
|
const locale = (0, _useLocale.default)();
|
|
49
|
-
const
|
|
49
|
+
const containerRef = (0, _react.useRef)(null);
|
|
50
50
|
const innerContentRef = (0, _react.useRef)(null);
|
|
51
51
|
const titleRef = (0, _react.useRef)(null);
|
|
52
52
|
const listenersAdded = (0, _react.useRef)(false);
|
|
@@ -57,16 +57,21 @@ const Dialog = ({
|
|
|
57
57
|
current: subtitleId
|
|
58
58
|
} = (0, _react.useRef)((0, _guid.default)());
|
|
59
59
|
const hasStickyFooter = (0, _useIsStickyFooterForm.default)(children);
|
|
60
|
-
const isTopModal = (0, _useModalAria.default)(
|
|
60
|
+
const isTopModal = (0, _useModalAria.default)(containerRef);
|
|
61
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
62
|
+
focus() {
|
|
63
|
+
containerRef.current?.focus();
|
|
64
|
+
}
|
|
65
|
+
}), []);
|
|
61
66
|
const centerDialog = (0, _react.useCallback)(() => {
|
|
62
67
|
/* istanbul ignore if */
|
|
63
|
-
if (!
|
|
68
|
+
if (!containerRef.current) {
|
|
64
69
|
return;
|
|
65
70
|
}
|
|
66
71
|
const {
|
|
67
72
|
width: dialogWidth,
|
|
68
73
|
height: dialogHeight
|
|
69
|
-
} =
|
|
74
|
+
} = containerRef.current.getBoundingClientRect();
|
|
70
75
|
let midPointY = window.innerHeight / 2;
|
|
71
76
|
let midPointX = window.innerWidth / 2;
|
|
72
77
|
midPointY -= dialogHeight / 2;
|
|
@@ -77,8 +82,8 @@ const Dialog = ({
|
|
|
77
82
|
if (midPointX < 0) {
|
|
78
83
|
midPointX = 0;
|
|
79
84
|
}
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
containerRef.current.style.top = `${midPointY}px`;
|
|
86
|
+
containerRef.current.style.left = `${midPointX}px`;
|
|
82
87
|
}, []);
|
|
83
88
|
(0, _useResizeObserver.default)(innerContentRef, centerDialog, !open);
|
|
84
89
|
const addListeners = (0, _react.useCallback)(() => {
|
|
@@ -164,24 +169,82 @@ const Dialog = ({
|
|
|
164
169
|
focusFirstElement: focusFirstElement,
|
|
165
170
|
bespokeTrap: bespokeFocusTrap,
|
|
166
171
|
focusableSelectors: focusableSelectors,
|
|
167
|
-
wrapperRef:
|
|
172
|
+
wrapperRef: containerRef,
|
|
168
173
|
isOpen: open,
|
|
169
174
|
additionalWrapperRefs: focusableContainers
|
|
170
175
|
}, /*#__PURE__*/_react.default.createElement(_dialog.StyledDialog, _extends({
|
|
171
176
|
"aria-modal": isTopModal ? true : undefined,
|
|
172
|
-
ref:
|
|
177
|
+
ref: containerRef,
|
|
173
178
|
topMargin: _dialog2.TOP_MARGIN
|
|
174
179
|
}, dialogProps, {
|
|
175
180
|
"data-component": "dialog",
|
|
176
181
|
"data-element": "dialog",
|
|
177
182
|
"data-role": rest["data-role"],
|
|
178
|
-
role: role
|
|
183
|
+
role: role,
|
|
184
|
+
tabIndex: -1
|
|
179
185
|
}, contentPadding), dialogTitle(), closeIcon(), /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogContent, _extends({}, contentPadding, {
|
|
180
186
|
hasStickyFooter: hasStickyFooter
|
|
181
187
|
}), /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogInnerContent, _extends({
|
|
182
188
|
ref: innerContentRef
|
|
183
189
|
}, contentPadding), children)))));
|
|
184
|
-
};
|
|
190
|
+
});
|
|
185
191
|
exports.Dialog = Dialog;
|
|
192
|
+
Dialog.propTypes = {
|
|
193
|
+
"aria-describedby": _propTypes.default.string,
|
|
194
|
+
"aria-label": _propTypes.default.string,
|
|
195
|
+
"aria-labelledby": _propTypes.default.string,
|
|
196
|
+
"ariaRole": _propTypes.default.string,
|
|
197
|
+
"bespokeFocusTrap": _propTypes.default.func,
|
|
198
|
+
"children": _propTypes.default.node,
|
|
199
|
+
"className": _propTypes.default.string,
|
|
200
|
+
"contentPadding": _propTypes.default.shape({
|
|
201
|
+
"p": _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
202
|
+
"px": _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
203
|
+
"py": _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
204
|
+
}),
|
|
205
|
+
"data-component": _propTypes.default.string,
|
|
206
|
+
"data-element": _propTypes.default.string,
|
|
207
|
+
"data-role": _propTypes.default.string,
|
|
208
|
+
"disableAutoFocus": _propTypes.default.bool,
|
|
209
|
+
"disableClose": _propTypes.default.bool,
|
|
210
|
+
"disableEscKey": _propTypes.default.bool,
|
|
211
|
+
"disableFocusTrap": _propTypes.default.bool,
|
|
212
|
+
"enableBackgroundUI": _propTypes.default.bool,
|
|
213
|
+
"focusableContainers": _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
214
|
+
"current": function (props, propName) {
|
|
215
|
+
if (props[propName] == null) {
|
|
216
|
+
return null;
|
|
217
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
218
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
})),
|
|
222
|
+
"focusableSelectors": _propTypes.default.string,
|
|
223
|
+
"focusFirstElement": _propTypes.default.oneOfType([function (props, propName) {
|
|
224
|
+
if (props[propName] == null) {
|
|
225
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
226
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
227
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
228
|
+
}
|
|
229
|
+
}, _propTypes.default.shape({
|
|
230
|
+
"current": function (props, propName) {
|
|
231
|
+
if (props[propName] == null) {
|
|
232
|
+
return null;
|
|
233
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
234
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
})]),
|
|
238
|
+
"height": _propTypes.default.string,
|
|
239
|
+
"help": _propTypes.default.string,
|
|
240
|
+
"onCancel": _propTypes.default.func,
|
|
241
|
+
"open": _propTypes.default.bool.isRequired,
|
|
242
|
+
"role": _propTypes.default.string,
|
|
243
|
+
"showCloseIcon": _propTypes.default.bool,
|
|
244
|
+
"size": _propTypes.default.oneOf(["auto", "extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
|
|
245
|
+
"subtitle": _propTypes.default.string,
|
|
246
|
+
"timeout": _propTypes.default.number,
|
|
247
|
+
"title": _propTypes.default.node
|
|
248
|
+
};
|
|
186
249
|
var _default = Dialog;
|
|
187
250
|
exports.default = _default;
|
|
@@ -9,7 +9,7 @@ var _styledSystem = require("styled-system");
|
|
|
9
9
|
var _button = _interopRequireDefault(require("../button/button.style"));
|
|
10
10
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
11
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
12
|
-
var
|
|
12
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
13
13
|
var _splitButtonChildren = require("../split-button/split-button-children.style");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
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); }
|
|
@@ -23,7 +23,7 @@ const StyledMultiActionButton = _styledComponents.default.div`
|
|
|
23
23
|
${({
|
|
24
24
|
width
|
|
25
25
|
}) => width && (0, _styledComponents.css)`
|
|
26
|
-
${(0,
|
|
26
|
+
${(0, _elementSizing.default)({
|
|
27
27
|
width
|
|
28
28
|
})}
|
|
29
29
|
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
-
var
|
|
8
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
10
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
11
11
|
var _formStyleUtils = require("../../style/utils/form-style-utils");
|
|
@@ -48,7 +48,7 @@ const StyledSidebar = _styledComponents.default.div`
|
|
|
48
48
|
${!width && size && (0, _styledComponents.css)`
|
|
49
49
|
width: ${_sidebar.SIDEBAR_SIZES_CSS[size]};
|
|
50
50
|
`}
|
|
51
|
-
${width && (0,
|
|
51
|
+
${width && (0, _elementSizing.default)({
|
|
52
52
|
width
|
|
53
53
|
})}
|
|
54
54
|
|
|
@@ -26,6 +26,10 @@ export interface TileProps extends SpaceProps, WidthProps {
|
|
|
26
26
|
borderVariant?: "default" | "selected" | "positive" | "negative" | "caution" | "info";
|
|
27
27
|
/** Sets the level of roundness of the corners, "default" is 8px and "large" is 16px */
|
|
28
28
|
roundness?: "default" | "large";
|
|
29
|
+
/**
|
|
30
|
+
* Set a percentage-based height for the whole Tile component, relative to its parent.
|
|
31
|
+
*/
|
|
32
|
+
height?: string | number;
|
|
29
33
|
}
|
|
30
|
-
export declare const Tile: ({ variant, p, children, orientation, width, roundness, ...props }: TileProps) => React.JSX.Element;
|
|
34
|
+
export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, ...props }: TileProps) => React.JSX.Element;
|
|
31
35
|
export default Tile;
|
|
@@ -14,8 +14,9 @@ const Tile = ({
|
|
|
14
14
|
p = 3,
|
|
15
15
|
children,
|
|
16
16
|
orientation = "horizontal",
|
|
17
|
-
width,
|
|
17
|
+
width = "100%",
|
|
18
18
|
roundness = "default",
|
|
19
|
+
height,
|
|
19
20
|
...props
|
|
20
21
|
}) => {
|
|
21
22
|
const isHorizontal = orientation === "horizontal";
|
|
@@ -31,12 +32,14 @@ const Tile = ({
|
|
|
31
32
|
}
|
|
32
33
|
const {
|
|
33
34
|
width: contentWidth,
|
|
35
|
+
height: contentHeight,
|
|
34
36
|
...childProps
|
|
35
37
|
} = child.props;
|
|
36
38
|
const key = child.key || `tile-content-${index + 1}`;
|
|
37
39
|
return /*#__PURE__*/_react.default.createElement(_tile.TileContent, _extends({
|
|
38
40
|
key: key,
|
|
39
41
|
width: contentWidth,
|
|
42
|
+
height: contentHeight,
|
|
40
43
|
isHorizontal: isHorizontal,
|
|
41
44
|
isVertical: isVertical
|
|
42
45
|
}, isVertical && {
|
|
@@ -50,6 +53,7 @@ const Tile = ({
|
|
|
50
53
|
return /*#__PURE__*/_react.default.createElement(_tile.StyledTile, _extends({
|
|
51
54
|
variant: variant,
|
|
52
55
|
width: width,
|
|
56
|
+
height: height,
|
|
53
57
|
"data-component": "tile",
|
|
54
58
|
isHorizontal: isHorizontal,
|
|
55
59
|
p: p,
|
|
@@ -3,10 +3,11 @@ import { TileProps } from "./tile.component";
|
|
|
3
3
|
interface TileContentProps {
|
|
4
4
|
isHorizontal?: boolean;
|
|
5
5
|
isVertical?: boolean;
|
|
6
|
-
width?:
|
|
6
|
+
width?: TileProps["width"];
|
|
7
|
+
height?: TileProps["height"];
|
|
7
8
|
}
|
|
8
9
|
declare const TileContent: import("styled-components").StyledComponent<"div", any, TileContentProps, never>;
|
|
9
|
-
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
|
+
declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
|
|
10
11
|
isHorizontal?: boolean | undefined;
|
|
11
12
|
} & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
12
13
|
export { StyledTile, TileContent };
|
|
@@ -7,7 +7,7 @@ exports.TileContent = exports.StyledTile = void 0;
|
|
|
7
7
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
|
-
var
|
|
10
|
+
var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
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
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; }
|
|
@@ -31,7 +31,8 @@ const TileContent = _styledComponents.default.div`
|
|
|
31
31
|
${({
|
|
32
32
|
isHorizontal,
|
|
33
33
|
isVertical,
|
|
34
|
-
width
|
|
34
|
+
width,
|
|
35
|
+
height
|
|
35
36
|
}) => (0, _styledComponents.css)`
|
|
36
37
|
${_styledSystem.space}
|
|
37
38
|
|
|
@@ -73,10 +74,11 @@ const TileContent = _styledComponents.default.div`
|
|
|
73
74
|
}
|
|
74
75
|
`}
|
|
75
76
|
|
|
76
|
-
${width && (0, _styledComponents.css)`
|
|
77
|
+
${(width || height) && (0, _styledComponents.css)`
|
|
77
78
|
flex-grow: 0;
|
|
78
|
-
${(0,
|
|
79
|
-
width
|
|
79
|
+
${(0, _elementSizing.default)({
|
|
80
|
+
width: width || /* istanbul ignore next */undefined,
|
|
81
|
+
height: height || undefined
|
|
80
82
|
})}
|
|
81
83
|
`}
|
|
82
84
|
`}
|
|
@@ -89,7 +91,8 @@ const StyledTile = _styledComponents.default.div`
|
|
|
89
91
|
isHorizontal,
|
|
90
92
|
variant,
|
|
91
93
|
width,
|
|
92
|
-
roundness
|
|
94
|
+
roundness,
|
|
95
|
+
height
|
|
93
96
|
}) => (0, _styledComponents.css)`
|
|
94
97
|
${_styledSystem.space}
|
|
95
98
|
|
|
@@ -114,13 +117,10 @@ const StyledTile = _styledComponents.default.div`
|
|
|
114
117
|
display: flex;
|
|
115
118
|
flex-direction: ${isHorizontal ? "row" : "column"};
|
|
116
119
|
position: relative;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
${(0, _width.default)({
|
|
121
|
-
width
|
|
120
|
+
${(0, _elementSizing.default)({
|
|
121
|
+
width: width || /* istanbul ignore next */undefined,
|
|
122
|
+
height: height || undefined
|
|
122
123
|
})}
|
|
123
|
-
`}
|
|
124
124
|
`}
|
|
125
125
|
`;
|
|
126
126
|
exports.StyledTile = StyledTile;
|
|
@@ -5,15 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _styledSystem = require("styled-system");
|
|
8
|
-
// eslint-disable-next-line no-restricted-imports
|
|
9
8
|
/*
|
|
10
9
|
* styled-system/layout allows users to use a width, height, minWidth, maxWidth, minHeight, maxHeight,
|
|
11
10
|
* size, display, verticalAlign, overflow, overflowX and overflowY props most of which are usually not needed.
|
|
12
|
-
* That's why the purpose of this function is to pass only the`width`
|
|
11
|
+
* That's why the purpose of this function is to pass only the `width` and `height` props to the `layout` function.
|
|
13
12
|
*/
|
|
14
13
|
var _default = ({
|
|
15
|
-
width
|
|
14
|
+
width,
|
|
15
|
+
height
|
|
16
16
|
}) => (0, _styledSystem.layout)({
|
|
17
|
-
width
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
18
19
|
});
|
|
19
20
|
exports.default = _default;
|
package/package.json
CHANGED