carbon-react 106.6.2 → 106.6.5
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__/expect.d.ts +8 -1
- package/esm/__spec_helper__/expect.js +1 -5
- package/esm/__spec_helper__/test-utils.d.ts +71 -33
- package/esm/__spec_helper__/test-utils.js +63 -65
- package/esm/components/action-popover/action-popover-context.d.ts +7 -2
- package/esm/components/action-popover/action-popover-context.js +1 -1
- package/esm/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +99 -118
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +42 -53
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
- package/esm/components/action-popover/action-popover-test.stories.js +76 -0
- package/esm/components/action-popover/action-popover.component.d.ts +30 -53
- package/esm/components/action-popover/action-popover.component.js +205 -67
- package/esm/components/action-popover/action-popover.style.d.ts +17 -11
- package/esm/components/action-popover/action-popover.style.js +20 -26
- package/esm/components/action-popover/index.d.ts +9 -5
- package/esm/components/button-bar/button-bar-test.stories.js +122 -0
- package/esm/components/button-bar/button-bar.component.d.ts +12 -15
- package/esm/components/button-bar/button-bar.component.js +331 -33
- package/esm/components/button-bar/button-bar.config.d.ts +2 -2
- package/esm/components/button-bar/button-bar.style.d.ts +4 -4
- package/esm/components/button-bar/button-bar.style.js +18 -33
- package/esm/components/button-bar/index.d.ts +2 -1
- package/esm/components/heading/heading.component.d.ts +7 -47
- package/esm/components/heading/heading.component.js +1 -48
- package/esm/components/link/link.component.js +1 -5
- package/esm/components/menu/__internal__/spec-helper/index.js +2 -1
- package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/esm/components/menu/menu.component.js +2 -1
- package/esm/components/menu/scrollable-block/scrollable-block.component.js +4 -2
- package/esm/components/modal/modal.component.js +3 -60
- package/esm/components/toast/toast.component.js +3 -13
- package/esm/hooks/__internal__/useModalManager/index.d.ts +1 -0
- package/esm/hooks/__internal__/useModalManager/index.js +1 -0
- package/esm/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
- package/esm/hooks/__internal__/useModalManager/useModalManager.js +66 -0
- package/lib/__spec_helper__/expect.d.ts +8 -1
- package/lib/__spec_helper__/expect.js +2 -4
- package/lib/__spec_helper__/test-utils.d.ts +71 -33
- package/lib/__spec_helper__/test-utils.js +63 -65
- package/lib/components/action-popover/action-popover-context.d.ts +7 -2
- package/lib/components/action-popover/action-popover-context.js +1 -1
- package/lib/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +100 -119
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +44 -55
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
- package/lib/components/action-popover/action-popover-test.stories.js +95 -0
- package/lib/components/action-popover/action-popover.component.d.ts +30 -53
- package/lib/components/action-popover/action-popover.component.js +206 -71
- package/lib/components/action-popover/action-popover.style.d.ts +17 -11
- package/lib/components/action-popover/action-popover.style.js +21 -28
- package/lib/components/action-popover/index.d.ts +9 -5
- package/lib/components/button-bar/button-bar-test.stories.js +145 -0
- package/lib/components/button-bar/button-bar.component.d.ts +12 -15
- package/lib/components/button-bar/button-bar.component.js +336 -35
- package/lib/components/button-bar/button-bar.config.d.ts +2 -2
- package/lib/components/button-bar/button-bar.style.d.ts +4 -4
- package/lib/components/button-bar/button-bar.style.js +18 -35
- package/lib/components/button-bar/index.d.ts +2 -1
- package/lib/components/heading/heading.component.d.ts +7 -47
- package/lib/components/heading/heading.component.js +1 -48
- package/lib/components/link/link.component.js +1 -5
- package/lib/components/menu/__internal__/spec-helper/index.js +2 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/lib/components/menu/menu.component.js +2 -1
- package/lib/components/menu/scrollable-block/scrollable-block.component.js +4 -2
- package/lib/components/modal/modal.component.js +3 -62
- package/lib/components/toast/toast.component.js +4 -17
- package/lib/hooks/__internal__/useModalManager/index.d.ts +1 -0
- package/lib/hooks/__internal__/useModalManager/index.js +15 -0
- package/lib/hooks/__internal__/useModalManager/package.json +6 -0
- package/lib/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
- package/lib/hooks/__internal__/useModalManager/useModalManager.js +79 -0
- package/package.json +5 -1
- package/esm/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
- package/esm/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
- package/esm/components/action-popover/action-popover.d.ts +0 -39
- package/esm/components/button-bar/button-bar.d.ts +0 -24
- package/lib/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
- package/lib/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
- package/lib/components/action-popover/action-popover.d.ts +0 -39
- package/lib/components/button-bar/button-bar.d.ts +0 -24
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import "jest-styled-components";
|
|
2
2
|
import { ReactWrapper } from "enzyme";
|
|
3
|
-
|
|
4
|
-
const {
|
|
5
|
-
diff
|
|
6
|
-
} = require("jest-matcher-utils");
|
|
7
|
-
|
|
3
|
+
import { diff } from "jest-matcher-utils";
|
|
8
4
|
expect.extend({
|
|
9
5
|
toBeFocused(received) {
|
|
10
6
|
const expected = document.activeElement;
|
|
@@ -1,34 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function selectedItemOf(wrapper: any): any;
|
|
6
|
-
export function childrenFrom(node: any): any;
|
|
7
|
-
export function makeArrayKeys(n: any): number[];
|
|
8
|
-
export const keyboard: {};
|
|
9
|
-
export function assertKeyboardTraversal({ num, nonSelectables, }: {
|
|
10
|
-
num: any;
|
|
11
|
-
nonSelectables?: any[] | undefined;
|
|
12
|
-
}): (wrapper: any) => void;
|
|
13
|
-
export function assertHoverTraversal({ num, nonSelectables, }: {
|
|
14
|
-
num: any;
|
|
15
|
-
nonSelectables?: any[] | undefined;
|
|
16
|
-
}): (wrapper: any) => void;
|
|
17
|
-
export function listFrom(wrapper: any): any;
|
|
18
|
-
export function click(wrapper: any): any;
|
|
19
|
-
export namespace simulate {
|
|
20
|
-
export { keydown };
|
|
21
|
-
}
|
|
22
|
-
export const carbonThemesJestTable: (string | Partial<import("style/themes/base/base-theme.config").ThemeObject> | undefined)[][];
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
3
|
+
import { LayoutProps, FlexboxProps, BackgroundProps } from "styled-system";
|
|
4
|
+
import { ReactTestRendererJSON } from "react-test-renderer";
|
|
23
5
|
import { mockMatchMedia } from "./mock-match-media";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
declare const toCSSCase: (str: string) => string;
|
|
7
|
+
declare const assertStyleMatch: <Props>(styleSpec: {
|
|
8
|
+
[key: string]: string | number | undefined;
|
|
9
|
+
}, component: ReactWrapper<Props, {}, import("react").Component<{}, {}, any>> | ShallowWrapper<Props, {}, import("react").Component<{}, {}, any>> | ReactTestRendererJSON | ReactTestRendererJSON[] | null, opts?: jest.Options | undefined) => void;
|
|
10
|
+
declare const makeArrayKeys: (n: number) => number[];
|
|
11
|
+
declare const keyMap: {
|
|
12
|
+
readonly UpArrow: 38;
|
|
13
|
+
readonly DownArrow: 40;
|
|
14
|
+
readonly RightArrow: 39;
|
|
15
|
+
readonly LeftArrow: 37;
|
|
16
|
+
readonly Enter: 13;
|
|
17
|
+
readonly Tab: 9;
|
|
18
|
+
readonly Space: 32;
|
|
19
|
+
readonly Escape: 27;
|
|
20
|
+
readonly End: 35;
|
|
21
|
+
readonly Home: 36;
|
|
22
|
+
readonly D: 68;
|
|
23
|
+
readonly E: 69;
|
|
24
|
+
readonly P: 80;
|
|
25
|
+
readonly Z: 90;
|
|
26
|
+
readonly 1: 49;
|
|
27
|
+
};
|
|
28
|
+
declare type Keys = keyof typeof keyMap;
|
|
29
|
+
declare type MappedKeys = `press${Keys}`;
|
|
30
|
+
declare type KeyboardAccumulatorType = Record<MappedKeys, () => void>;
|
|
31
|
+
declare const keyboard: KeyboardAccumulatorType;
|
|
32
|
+
declare type KeydownAccumulatorType = Record<MappedKeys, (wrapper: ReactWrapper<any>, options?: {
|
|
33
|
+
shiftKey: boolean;
|
|
34
|
+
}) => void>;
|
|
35
|
+
declare const simulate: {
|
|
36
|
+
keydown: KeydownAccumulatorType;
|
|
37
|
+
};
|
|
38
|
+
declare const listFrom: (wrapper: ReactWrapper) => ReactWrapper<import("enzyme").HTMLAttributes, any, import("react").Component<{}, {}, any>>;
|
|
39
|
+
declare const childrenFrom: (node: ReactWrapper) => ReactWrapper<any, any, import("react").Component<{}, {}, any>>;
|
|
40
|
+
declare const hoverList: (wrapper: ReactWrapper) => (item: number) => void;
|
|
41
|
+
declare const click: (wrapper: ReactWrapper) => ReactWrapper<{}, {}, import("react").Component<{}, {}, any>>;
|
|
42
|
+
declare const selectedItemOf: (wrapper: ReactWrapper) => number;
|
|
43
|
+
declare const assertKeyboardTraversal: ({ num, nonSelectables, }: {
|
|
44
|
+
num: number;
|
|
45
|
+
nonSelectables?: number[] | undefined;
|
|
46
|
+
}) => (wrapper: ReactWrapper) => void;
|
|
47
|
+
declare const assertHoverTraversal: ({ num, nonSelectables, }: {
|
|
48
|
+
num: number;
|
|
49
|
+
nonSelectables?: number[] | undefined;
|
|
50
|
+
}) => (wrapper: ReactWrapper) => void;
|
|
51
|
+
declare const carbonThemesJestTable: (string | Partial<import("style/themes/base/base-theme.config").ThemeObject> | undefined)[][];
|
|
52
|
+
declare const marginProps: readonly [readonly ["m", "margin"], readonly ["ml", "marginLeft"], readonly ["mr", "marginRight"], readonly ["mt", "marginTop"], readonly ["mb", "marginBottom"], readonly ["mx", "marginLeft"], readonly ["mx", "marginRight"], readonly ["my", "marginTop"], readonly ["my", "marginBottom"]];
|
|
53
|
+
declare type MarginProps = {
|
|
54
|
+
[K in typeof marginProps[number][0]]?: string | number;
|
|
55
|
+
};
|
|
56
|
+
declare const paddingProps: readonly [readonly ["p", "padding"], readonly ["pl", "paddingLeft"], readonly ["pr", "paddingRight"], readonly ["pt", "paddingTop"], readonly ["pb", "paddingBottom"], readonly ["px", "paddingLeft"], readonly ["px", "paddingRight"], readonly ["py", "paddingTop"], readonly ["py", "paddingBottom"]];
|
|
57
|
+
declare type PaddingProps = {
|
|
58
|
+
[K in typeof paddingProps[number][0]]?: string | number;
|
|
59
|
+
};
|
|
60
|
+
export declare const getDefaultValue: (value?: string | number | undefined) => string | number | undefined;
|
|
61
|
+
declare const testStyledSystemMargin: (component: (spacingProps?: MarginProps | undefined) => JSX.Element, defaults?: MarginProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
|
|
62
|
+
declare const testStyledSystemPadding: (component: (spacingProps?: PaddingProps | undefined) => JSX.Element, defaults?: PaddingProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
|
|
63
|
+
declare const testStyledSystemSpacing: (component: (spacingProps?: MarginProps | PaddingProps | undefined) => JSX.Element, defaults?: MarginProps | PaddingProps | undefined, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined, assertOpts?: jest.Options | undefined) => void;
|
|
64
|
+
declare const testStyledSystemColor: (component: (colorProperties?: any) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => void) | undefined) => void;
|
|
65
|
+
declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
66
|
+
width: string;
|
|
67
|
+
} | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
68
|
+
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
69
|
+
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
70
|
+
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
71
|
+
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
72
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectConsoleOutput, };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/* eslint-disable jest/no-conditional-expect */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable jest/no-identical-title */
|
|
4
|
+
|
|
5
|
+
/* eslint-disable jest/no-export */
|
|
1
6
|
import { mount } from "enzyme";
|
|
2
7
|
import { sprintf } from "sprintf-js";
|
|
3
8
|
import { space } from "style/themes/base/base-theme.config";
|
|
@@ -28,27 +33,24 @@ const dispatchKeyPress = code => {
|
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
const keyMap = {
|
|
31
|
-
UpArrow:
|
|
32
|
-
DownArrow:
|
|
33
|
-
RightArrow:
|
|
34
|
-
LeftArrow:
|
|
35
|
-
Enter:
|
|
36
|
-
Tab:
|
|
37
|
-
Space:
|
|
38
|
-
Escape:
|
|
39
|
-
End:
|
|
40
|
-
Home:
|
|
41
|
-
D:
|
|
42
|
-
E:
|
|
43
|
-
P:
|
|
44
|
-
Z:
|
|
45
|
-
1:
|
|
36
|
+
UpArrow: 38,
|
|
37
|
+
DownArrow: 40,
|
|
38
|
+
RightArrow: 39,
|
|
39
|
+
LeftArrow: 37,
|
|
40
|
+
Enter: 13,
|
|
41
|
+
Tab: 9,
|
|
42
|
+
Space: 32,
|
|
43
|
+
Escape: 27,
|
|
44
|
+
End: 35,
|
|
45
|
+
Home: 36,
|
|
46
|
+
D: 68,
|
|
47
|
+
E: 69,
|
|
48
|
+
P: 80,
|
|
49
|
+
Z: 90,
|
|
50
|
+
1: 49
|
|
46
51
|
};
|
|
47
|
-
|
|
48
|
-
const repeat = action => (n = 1) => makeArrayKeys(n).forEach(() => action());
|
|
49
|
-
|
|
50
52
|
const keyboard = Object.keys(keyMap).reduce((acc, key) => {
|
|
51
|
-
acc[`press${key}`] = () =>
|
|
53
|
+
acc[`press${key}`] = () => dispatchKeyPress(keyMap[key]);
|
|
52
54
|
|
|
53
55
|
return acc;
|
|
54
56
|
}, {}); // Build an object of Enzyme simulate helpers
|
|
@@ -64,7 +66,7 @@ const keydown = Object.keys(keyMap).reduce((acc, key) => {
|
|
|
64
66
|
target.simulate("keydown", {
|
|
65
67
|
shiftKey,
|
|
66
68
|
key,
|
|
67
|
-
which:
|
|
69
|
+
which: keyMap[key]
|
|
68
70
|
});
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -122,18 +124,19 @@ const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "
|
|
|
122
124
|
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"]];
|
|
123
125
|
export const getDefaultValue = value => {
|
|
124
126
|
const spaceArrayLength = space.length - 1;
|
|
127
|
+
if (value === undefined) return value;
|
|
125
128
|
const parsedValue = +value;
|
|
126
129
|
|
|
127
|
-
if (typeof value === "string" &&
|
|
130
|
+
if (typeof value === "string" && parsedValue > spaceArrayLength) {
|
|
128
131
|
return `${value}px`;
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
if (parsedValue <= spaceArrayLength) {
|
|
132
|
-
return space[
|
|
135
|
+
return space[parsedValue];
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
if (parsedValue > spaceArrayLength) {
|
|
136
|
-
return `${
|
|
139
|
+
return `${parsedValue * 8}px`;
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
return value;
|
|
@@ -152,18 +155,18 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
|
|
|
152
155
|
let marginBottom;
|
|
153
156
|
|
|
154
157
|
if (defaults) {
|
|
155
|
-
margin = getDefaultValue(defaults.m
|
|
156
|
-
marginLeft = getDefaultValue(defaults.ml || defaults.mx
|
|
157
|
-
marginRight = getDefaultValue(defaults.mr || defaults.mx
|
|
158
|
-
marginTop = getDefaultValue(defaults.mt || defaults.my
|
|
159
|
-
marginBottom = getDefaultValue(defaults.mb || defaults.my
|
|
160
|
-
|
|
158
|
+
margin = getDefaultValue(defaults.m);
|
|
159
|
+
marginLeft = getDefaultValue(defaults.ml || defaults.mx);
|
|
160
|
+
marginRight = getDefaultValue(defaults.mr || defaults.mx);
|
|
161
|
+
marginTop = getDefaultValue(defaults.mt || defaults.my);
|
|
162
|
+
marginBottom = getDefaultValue(defaults.mb || defaults.my);
|
|
163
|
+
assertStyleMatch({
|
|
161
164
|
margin,
|
|
162
165
|
marginLeft,
|
|
163
166
|
marginRight,
|
|
164
167
|
marginTop,
|
|
165
168
|
marginBottom
|
|
166
|
-
}, StyleElement, assertOpts)
|
|
169
|
+
}, StyleElement, assertOpts);
|
|
167
170
|
} else {
|
|
168
171
|
expect(StyleElement).not.toHaveStyleRule("marginLeft");
|
|
169
172
|
expect(StyleElement).not.toHaveStyleRule("marginRight");
|
|
@@ -175,15 +178,14 @@ const testStyledSystemMargin = (component, defaults, styleContainer, assertOpts)
|
|
|
175
178
|
});
|
|
176
179
|
describe.each(marginProps)('when a custom spacing is specified using the "%s" styled system props', (styledSystemProp, propName) => {
|
|
177
180
|
it(`then that ${propName} should have been set correctly`, () => {
|
|
178
|
-
let wrapper = mount(component());
|
|
179
181
|
const props = {
|
|
180
182
|
[styledSystemProp]: 2
|
|
181
183
|
};
|
|
182
|
-
wrapper = mount(component({ ...props
|
|
184
|
+
const wrapper = mount(component({ ...props
|
|
183
185
|
}));
|
|
184
|
-
|
|
186
|
+
assertStyleMatch({
|
|
185
187
|
[propName]: "var(--spacing200)"
|
|
186
|
-
}, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts)
|
|
188
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts);
|
|
187
189
|
});
|
|
188
190
|
});
|
|
189
191
|
};
|
|
@@ -201,18 +203,18 @@ const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts
|
|
|
201
203
|
let paddingBottom;
|
|
202
204
|
|
|
203
205
|
if (defaults) {
|
|
204
|
-
padding = getDefaultValue(defaults.p
|
|
205
|
-
paddingLeft = getDefaultValue(defaults.pl || defaults.px
|
|
206
|
-
paddingRight = getDefaultValue(defaults.pr || defaults.px
|
|
207
|
-
paddingTop = getDefaultValue(defaults.pt || defaults.py
|
|
208
|
-
paddingBottom = getDefaultValue(defaults.pb || defaults.py
|
|
209
|
-
|
|
206
|
+
padding = getDefaultValue(defaults.p);
|
|
207
|
+
paddingLeft = getDefaultValue(defaults.pl || defaults.px);
|
|
208
|
+
paddingRight = getDefaultValue(defaults.pr || defaults.px);
|
|
209
|
+
paddingTop = getDefaultValue(defaults.pt || defaults.py);
|
|
210
|
+
paddingBottom = getDefaultValue(defaults.pb || defaults.py);
|
|
211
|
+
assertStyleMatch({
|
|
210
212
|
padding,
|
|
211
213
|
paddingLeft,
|
|
212
214
|
paddingRight,
|
|
213
215
|
paddingTop,
|
|
214
216
|
paddingBottom
|
|
215
|
-
}, StyleElement, assertOpts)
|
|
217
|
+
}, StyleElement, assertOpts);
|
|
216
218
|
} else {
|
|
217
219
|
expect(StyleElement).not.toHaveStyleRule("paddingLeft");
|
|
218
220
|
expect(StyleElement).not.toHaveStyleRule("paddingRight");
|
|
@@ -224,15 +226,14 @@ const testStyledSystemPadding = (component, defaults, styleContainer, assertOpts
|
|
|
224
226
|
});
|
|
225
227
|
describe.each(paddingProps)('when a custom spacing is specified using the "%s" styled system props', (styledSystemProp, propName) => {
|
|
226
228
|
it(`then that ${propName} should have been set correctly`, () => {
|
|
227
|
-
let wrapper = mount(component());
|
|
228
229
|
const props = {
|
|
229
230
|
[styledSystemProp]: 2
|
|
230
231
|
};
|
|
231
|
-
wrapper = mount(component({ ...props
|
|
232
|
+
const wrapper = mount(component({ ...props
|
|
232
233
|
}));
|
|
233
|
-
|
|
234
|
+
assertStyleMatch({
|
|
234
235
|
[propName]: "var(--spacing200)"
|
|
235
|
-
}, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts)
|
|
236
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper, assertOpts);
|
|
236
237
|
});
|
|
237
238
|
});
|
|
238
239
|
};
|
|
@@ -245,14 +246,14 @@ const testStyledSystemSpacing = (component, defaults, styleContainer, assertOpts
|
|
|
245
246
|
const testStyledSystemColor = (component, styleContainer) => {
|
|
246
247
|
describe.each(colorProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
247
248
|
it(`then ${propName} should have been set correctly`, () => {
|
|
248
|
-
let wrapper = mount(component());
|
|
249
249
|
const props = {
|
|
250
250
|
[styledSystemProp]: value
|
|
251
251
|
};
|
|
252
|
-
wrapper = mount(component({ ...props
|
|
253
|
-
}));
|
|
252
|
+
const wrapper = mount(component({ ...props
|
|
253
|
+
}));
|
|
254
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper; // Some props need to have camelcase so used toHaveStyleRule rather than assertStyleMatch
|
|
254
255
|
|
|
255
|
-
expect(
|
|
256
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
256
257
|
});
|
|
257
258
|
});
|
|
258
259
|
};
|
|
@@ -261,13 +262,13 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
261
262
|
describe("when a width prop is specified using styled system props", () => {
|
|
262
263
|
it("then width should have been set correctly", () => {
|
|
263
264
|
const [styledSystemProp, propName, value] = widthProps;
|
|
264
|
-
let wrapper = mount(component());
|
|
265
265
|
const props = {
|
|
266
266
|
[styledSystemProp]: value
|
|
267
267
|
};
|
|
268
|
-
wrapper = mount(component({ ...props
|
|
268
|
+
const wrapper = mount(component({ ...props
|
|
269
269
|
}));
|
|
270
|
-
|
|
270
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper;
|
|
271
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
271
272
|
});
|
|
272
273
|
});
|
|
273
274
|
};
|
|
@@ -275,14 +276,14 @@ const testStyledSystemWidth = (component, styleContainer) => {
|
|
|
275
276
|
const testStyledSystemLayout = (component, styleContainer) => {
|
|
276
277
|
describe.each(layoutProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
277
278
|
it(`then ${propName} should have been set correctly`, () => {
|
|
278
|
-
let wrapper = mount(component());
|
|
279
279
|
const props = {
|
|
280
280
|
[styledSystemProp]: value
|
|
281
281
|
};
|
|
282
|
-
wrapper = mount(component({ ...props
|
|
283
|
-
}));
|
|
282
|
+
const wrapper = mount(component({ ...props
|
|
283
|
+
}));
|
|
284
|
+
const StyleElement = styleContainer ? styleContainer(wrapper) : wrapper; // Some props need to have camelcase so used toHaveStyleRule rather than assertStyleMatch
|
|
284
285
|
|
|
285
|
-
expect(
|
|
286
|
+
expect(StyleElement).toHaveStyleRule(propName, value);
|
|
286
287
|
});
|
|
287
288
|
});
|
|
288
289
|
};
|
|
@@ -290,15 +291,13 @@ const testStyledSystemLayout = (component, styleContainer) => {
|
|
|
290
291
|
const testStyledSystemFlexBox = (component, styleContainer) => {
|
|
291
292
|
describe.each(flexBoxProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
292
293
|
it(`then ${propName} should have been set correctly`, () => {
|
|
293
|
-
let wrapper = mount(component());
|
|
294
294
|
const props = {
|
|
295
295
|
[styledSystemProp]: value
|
|
296
296
|
};
|
|
297
|
-
wrapper = mount(component(
|
|
298
|
-
|
|
299
|
-
expect(assertStyleMatch({
|
|
297
|
+
const wrapper = mount(component(props));
|
|
298
|
+
assertStyleMatch({
|
|
300
299
|
[propName]: value
|
|
301
|
-
}, styleContainer ? styleContainer(wrapper) : wrapper)
|
|
300
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper);
|
|
302
301
|
});
|
|
303
302
|
});
|
|
304
303
|
};
|
|
@@ -306,15 +305,14 @@ const testStyledSystemFlexBox = (component, styleContainer) => {
|
|
|
306
305
|
const testStyledSystemBackground = (component, styleContainer) => {
|
|
307
306
|
describe.each(backgroundProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, propName, value) => {
|
|
308
307
|
it(`then ${propName} should have been set correctly`, () => {
|
|
309
|
-
let wrapper = mount(component());
|
|
310
308
|
const props = {
|
|
311
309
|
[styledSystemProp]: value
|
|
312
310
|
};
|
|
313
|
-
wrapper = mount(component({ ...props
|
|
311
|
+
const wrapper = mount(component({ ...props
|
|
314
312
|
}));
|
|
315
|
-
|
|
313
|
+
assertStyleMatch({
|
|
316
314
|
[styledSystemProp]: value
|
|
317
|
-
}, styleContainer ? styleContainer(wrapper) : wrapper)
|
|
315
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper);
|
|
318
316
|
});
|
|
319
317
|
});
|
|
320
318
|
}; // this util will catch that a console output occurred without polluting the output when running the unit tests
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export default ActionPopoverContext;
|
|
2
|
-
declare const ActionPopoverContext: React.Context<{}>;
|
|
3
1
|
import React from "react";
|
|
2
|
+
declare type ActionPopoverContextType = {
|
|
3
|
+
setOpenPopover: (isOpen: boolean) => void;
|
|
4
|
+
focusButton: () => void;
|
|
5
|
+
isOpenPopover: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const ActionPopoverContext: React.Context<ActionPopoverContextType | null>;
|
|
8
|
+
export default ActionPopoverContext;
|
package/esm/components/action-popover/action-popover-item/action-popover-item.component.d.ts
CHANGED
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
export default ActionPopoverItem;
|
|
2
|
-
export function MenuItem({ children, icon, disabled, onClick: onClickProp, submenu, theme, placement, focusItem, download, href, horizontalAlignment, ...rest }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
children: any;
|
|
5
|
-
icon: any;
|
|
6
|
-
disabled?: boolean | undefined;
|
|
7
|
-
onClick: any;
|
|
8
|
-
submenu: any;
|
|
9
|
-
theme: any;
|
|
10
|
-
placement?: string | undefined;
|
|
11
|
-
focusItem: any;
|
|
12
|
-
download: any;
|
|
13
|
-
href: any;
|
|
14
|
-
horizontalAlignment: any;
|
|
15
|
-
}): JSX.Element;
|
|
16
|
-
export namespace MenuItem {
|
|
17
|
-
namespace propTypes {
|
|
18
|
-
const children: PropTypes.Validator<string>;
|
|
19
|
-
const disabled: PropTypes.Requireable<boolean>;
|
|
20
|
-
const icon: PropTypes.Requireable<string>;
|
|
21
|
-
const onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
-
const download: PropTypes.Requireable<boolean>;
|
|
23
|
-
const href: PropTypes.Requireable<string>;
|
|
24
|
-
/** Submenu component for item */
|
|
25
|
-
function submenu(props: any, propName: any, componentName: any): Error | undefined;
|
|
26
|
-
/** Submenu component for item */
|
|
27
|
-
function submenu(props: any, propName: any, componentName: any): Error | undefined;
|
|
28
|
-
const placement: PropTypes.Requireable<string>;
|
|
29
|
-
const focusItem: PropTypes.Requireable<boolean>;
|
|
30
|
-
const horizontalAlignment: PropTypes.Requireable<string>;
|
|
31
|
-
}
|
|
32
|
-
const displayName: string;
|
|
33
|
-
}
|
|
34
|
-
declare const ActionPopoverItem: React.ForwardRefExoticComponent<{
|
|
35
|
-
[x: string]: any;
|
|
36
|
-
[x: number]: any;
|
|
37
|
-
[x: symbol]: any;
|
|
38
|
-
} & {
|
|
39
|
-
theme?: any;
|
|
40
|
-
}>;
|
|
41
|
-
import PropTypes from "prop-types";
|
|
42
1
|
import React from "react";
|
|
2
|
+
import { IconType } from "../../icon";
|
|
3
|
+
export interface ActionPopoverItemProps {
|
|
4
|
+
/** The text label to display for this Item */
|
|
5
|
+
children: string;
|
|
6
|
+
/** Flag to indicate if item is disabled */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** allows to provide download prop that works dependent with href */
|
|
9
|
+
download?: boolean;
|
|
10
|
+
/** allows to provide href prop */
|
|
11
|
+
href?: string;
|
|
12
|
+
/** The name of the icon to display next to the label */
|
|
13
|
+
icon?: IconType;
|
|
14
|
+
/** Callback to run when item is clicked */
|
|
15
|
+
onClick?: (ev: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
16
|
+
/** Submenu component for item */
|
|
17
|
+
submenu?: React.ReactNode;
|
|
18
|
+
/** @ignore @private */
|
|
19
|
+
placement?: "top" | "bottom";
|
|
20
|
+
/** @ignore @private */
|
|
21
|
+
focusItem?: boolean;
|
|
22
|
+
/** @ignore @private */
|
|
23
|
+
horizontalAlignment?: "left" | "right";
|
|
24
|
+
}
|
|
25
|
+
export declare const ActionPopoverItem: {
|
|
26
|
+
({ children, icon, disabled, onClick: onClickProp, submenu, placement, focusItem, download, href, horizontalAlignment, ...rest }: ActionPopoverItemProps): JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
export default ActionPopoverItem;
|