@madie/madie-design-system 1.2.62 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +14 -2
- package/.eslintrc.js +1 -1
- package/.storybook/.babelrc +2 -1
- package/.storybook/main.js +3 -11
- package/.storybook/preview.js +1 -1
- package/components/Accordion/index.jsx +32 -36
- package/components/AutoComplete/AutoComplete.jsx +2 -17
- package/components/Button/Button.stories.js +0 -7
- package/components/Button/index.js +34 -44
- package/components/DateField/DateField.jsx +2 -15
- package/components/DateField/DateField.stories.jsx +23 -10
- package/components/DateTimeField/DateTimeField.jsx +7 -11
- package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
- package/components/InputLabel/index.jsx +1 -6
- package/components/Instant/Instant.stories.js +14 -6
- package/components/Instant/index.jsx +0 -16
- package/components/Link/index.js +14 -33
- package/components/MadieAlert/MadieAlert.stories.js +35 -29
- package/components/MadieAlert/index.jsx +5 -44
- package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -32
- package/components/MadieConfirmDialog/index.jsx +0 -8
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -24
- package/components/MadieDeleteDialog/index.jsx +0 -7
- package/components/MadieDialog/MadieDialog.stories.js +45 -121
- package/components/MadieDialog/index.jsx +4 -23
- package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -12
- package/components/MadieDiscardDialog/index.jsx +0 -7
- package/components/MadieSpinner/MadieSpinner.stories.js +1 -9
- package/components/MadieSpinner/index.jsx +0 -5
- package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
- package/components/MadieTooltip/index.jsx +0 -6
- package/components/MadieTooltipIcon/index.jsx +0 -5
- package/components/Modal/Modal.jsx +31 -43
- package/components/Modal/Modal.stories.js +18 -89
- package/components/Modal/index.jsx +6 -8
- package/components/NumberInput/NumberInput.stories.js +50 -67
- package/components/NumberInput/index.jsx +0 -13
- package/components/Pagination/index.jsx +0 -17
- package/components/Popover/Popover.stories.js +6 -14
- package/components/Popover/index.js +0 -23
- package/components/RadioButton/RadioButton.jsx +5 -15
- package/components/RadioButton/RadioButton.stories.jsx +6 -2
- package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +3 -8
- package/components/ReadOnlyTextField/index.jsx +1 -9
- package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
- package/components/RichTextEditor/index.jsx +14 -30
- package/components/SanitizedContent/index.jsx +0 -8
- package/components/Search/Search.stories.js +2 -4
- package/components/Search/index.js +26 -40
- package/components/Select/Select.stories.js +59 -164
- package/components/Select/index.jsx +2 -17
- package/components/Tabs/Tab.js +29 -25
- package/components/Tabs/TabPanel.js +15 -19
- package/components/Tabs/Tabs.stories.js +43 -211
- package/components/Tabs/index.js +10 -28
- package/components/TextArea/TextArea.stories.js +87 -113
- package/components/TextArea/index.jsx +2 -14
- package/components/TextField/TextField.stories.js +100 -129
- package/components/TextField/index.jsx +2 -17
- package/components/TimeField/TimeField.jsx +0 -10
- package/components/TimeField/TimeField.stories.js +18 -8
- package/components/Toast/Toast.stories.js +42 -102
- package/components/Toast/index.jsx +0 -14
- package/components/TruncateText/TruncateText.stories.js +22 -17
- package/components/TruncateText/index.js +0 -8
- package/components/hooks/useGetConfig.js +2 -2
- package/components/{index.js → index.mjs} +37 -57
- package/dist/index.js +3 -1
- package/dist/index.js.LICENSE.txt +16 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.html +1 -1
- package/dist/react/index.mjs +103 -0
- package/dist/react/{index.js.LICENSE.txt → index.mjs.LICENSE.txt} +3 -52
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/package.json +1 -0
- package/eslint.config.cjs +59 -0
- package/index.js +7 -9
- package/jest.config.mjs +10 -0
- package/lib/Chevron.jsx +2 -10
- package/package.json +57 -82
- package/styles/_main.scss +4 -3
- package/test/components/Accordion.test.js +1 -1
- package/test/components/AutoComplete.test.js +11 -6
- package/test/components/Button.test.js +13 -19
- package/test/components/DateField.test.js +25 -29
- package/test/components/DateTimeField.test.js +21 -25
- package/test/components/Instant.test.js +1 -1
- package/test/components/MadieAlert.test.js +22 -22
- package/test/components/MadieConfirmDialog.test.js +42 -64
- package/test/components/MadieDeleteDialog.test.js +51 -69
- package/test/components/MadieDialog.test.js +13 -13
- package/test/components/MadieDiscardDialog.test.js +28 -45
- package/test/components/MadieSpinner.test.js +12 -17
- package/test/components/Modal.test.js +115 -0
- package/test/components/Pagination.test.js +2 -2
- package/test/components/RadioButton.test.js +7 -7
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +90 -6
- package/test/components/Search.test.js +75 -0
- package/test/components/Select.test.js +97 -107
- package/test/components/Tabs.test.js +22 -24
- package/test/components/TextArea.test.js +78 -92
- package/test/components/TextField.test.js +128 -147
- package/test/components/Toast.test.js +67 -78
- package/test/components/TruncateText.test.js +75 -0
- package/test/components/index.test.js +23 -0
- package/webpack.config.mjs +79 -0
- package/webpack.config.react.mjs +72 -0
- package/.eslintignore +0 -5
- package/components/Alert/Alert.stories.js +0 -70
- package/components/Alert/index.js +0 -55
- package/components/Breadcrumb/Breadcrumb.md +0 -28
- package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
- package/components/Breadcrumb/index.js +0 -92
- package/components/CalloutBox/CalloutBox.stories.js +0 -94
- package/components/CalloutBox/index.js +0 -109
- package/components/Card/Card.stories.js +0 -163
- package/components/Card/index.js +0 -144
- package/components/Dropdown/Dropdown.stories.js +0 -94
- package/components/Dropdown/index.js +0 -85
- package/components/Error/Collapsible.jsx +0 -93
- package/components/Error/ErrorUI.jsx +0 -31
- package/components/Error/error.js +0 -26
- package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
- package/components/FlashNotification/index.js +0 -30
- package/components/Footer/Footer.stories.js +0 -20
- package/components/Footer/FooterUI.jsx +0 -137
- package/components/Footer/LegacyFooterUI.jsx +0 -204
- package/components/Footer/SocialLinks.jsx +0 -63
- package/components/Footer/Subscribe.jsx +0 -34
- package/components/Footer/footer.js +0 -30
- package/components/Infotip/Infotip.jsx +0 -75
- package/components/Infotip/Infotip.stories.js +0 -52
- package/components/Infotip/InfotipIcon.jsx +0 -41
- package/components/Infotip/index.js +0 -3
- package/components/Link/Link.stories.js +0 -82
- package/components/NotificationBanner/NotificationBanner.stories.js +0 -23
- package/components/NotificationBanner/index.js +0 -279
- package/components/Spinner/index.js +0 -9
- package/components/TextInput/TextInput.stories.js +0 -118
- package/components/TextInput/index.js +0 -137
- package/components/Tooltip/Tooltip.jsx +0 -88
- package/components/Tooltip/Tooltip.stories.js +0 -80
- package/components/Tooltip/index.js +0 -3
- package/components/Tooltip/position.js +0 -76
- package/components/UnwrappedSpinner/index.js +0 -8
- package/dist/browser.js +0 -1
- package/dist/react/index.js +0 -185
- package/dist/react/index.js.map +0 -1
- package/jest.config.js +0 -17
- package/test/components/ErrorUI.test.js +0 -32
- package/test/components/FooterUI.test.js +0 -122
- package/test/components/Infotip.test.js +0 -76
- package/test/components/Tooltip.test.js +0 -147
- package/webpack.config.js +0 -124
- package/webpack.config.react.js +0 -104
package/jest.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
roots: ["<rootDir>"],
|
|
3
|
-
modulePathIgnorePatterns: ["<rootDir>/dist/"],
|
|
4
|
-
testEnvironment: "jsdom",
|
|
5
|
-
transform: {
|
|
6
|
-
"^.+\\.(j|t)sx?$": "babel-jest",
|
|
7
|
-
},
|
|
8
|
-
setupFilesAfterEnv: ["@testing-library/jest-dom"],
|
|
9
|
-
globals: {
|
|
10
|
-
"ts-jest": {
|
|
11
|
-
tsconfig: {
|
|
12
|
-
jsx: "react-jsx",
|
|
13
|
-
},
|
|
14
|
-
useEsm: true,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import ErrorUI from "../../components/Error/ErrorUI";
|
|
4
|
-
|
|
5
|
-
describe("ErrorUI", () => {
|
|
6
|
-
it("renders a list of errors in HTML", () => {
|
|
7
|
-
const code = "404";
|
|
8
|
-
const type = "Bad thing happened";
|
|
9
|
-
const message = [
|
|
10
|
-
{ contentTitle: "Not found", content: "test" },
|
|
11
|
-
{ contentTitle: "Image not found", content: "test number 2" },
|
|
12
|
-
];
|
|
13
|
-
const { debug, container } = render(
|
|
14
|
-
<ErrorUI type={type} code={code} message={message} />
|
|
15
|
-
);
|
|
16
|
-
expect(container.querySelector(".page-error")).toBeTruthy();
|
|
17
|
-
expect(container.querySelector(".collapsible-details")).toBeTruthy();
|
|
18
|
-
expect(container.querySelectorAll(".items li").length).toBe(2);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("renders a string instead of an array", () => {
|
|
22
|
-
const code = "404";
|
|
23
|
-
const type = "Bad thing happened";
|
|
24
|
-
const message = "Not found";
|
|
25
|
-
const { getByText, container } = render(
|
|
26
|
-
<ErrorUI type={type} code={code} message={message} />
|
|
27
|
-
);
|
|
28
|
-
expect(container.querySelector(".page-error")).toBeTruthy();
|
|
29
|
-
expect(container.querySelector(".collapsible-details")).toBeTruthy();
|
|
30
|
-
expect(getByText(/not found/i)).toBeTruthy();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import ReactTestUtils from "react-dom/test-utils";
|
|
4
|
-
import { expect } from "chai";
|
|
5
|
-
import FooterUI from "../../components/Footer/FooterUI";
|
|
6
|
-
|
|
7
|
-
class Wrapper extends Component {
|
|
8
|
-
render() {
|
|
9
|
-
return this.props.children;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe("FooterUI", () => {
|
|
14
|
-
it("renders the footer HTML", () => {
|
|
15
|
-
// Native elements and functional stateless react components don't have public instances and
|
|
16
|
-
// cannot be used with renderIntoDocument. React has a separate package install for a shallow
|
|
17
|
-
// renderer that allows this. Otherwise, you need a wrapper when testing presentational components.
|
|
18
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
19
|
-
<Wrapper>
|
|
20
|
-
<FooterUI />
|
|
21
|
-
</Wrapper>
|
|
22
|
-
);
|
|
23
|
-
const footer = ReactTestUtils.findRenderedDOMComponentWithTag(
|
|
24
|
-
component,
|
|
25
|
-
"footer"
|
|
26
|
-
);
|
|
27
|
-
const footerNode = ReactDOM.findDOMNode(footer);
|
|
28
|
-
expect(ReactTestUtils.isDOMComponent(footerNode)).to.be.true;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("renders the footer HTML", () => {
|
|
32
|
-
const version = "1.2.3.4";
|
|
33
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
34
|
-
<Wrapper>
|
|
35
|
-
<FooterUI buildVersion={version} />
|
|
36
|
-
</Wrapper>
|
|
37
|
-
);
|
|
38
|
-
const buildVersion = ReactTestUtils.findRenderedDOMComponentWithClass(
|
|
39
|
-
component,
|
|
40
|
-
"build-version"
|
|
41
|
-
);
|
|
42
|
-
const buildVersionNode = ReactDOM.findDOMNode(buildVersion);
|
|
43
|
-
expect(ReactTestUtils.isDOMComponent(buildVersionNode)).to.be.true;
|
|
44
|
-
expect(buildVersion.textContent).to.equal(version);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("renders the footer properly in the Authenticated experience", () => {
|
|
48
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
49
|
-
<Wrapper>
|
|
50
|
-
<FooterUI isFullWidth={true} />
|
|
51
|
-
</Wrapper>
|
|
52
|
-
);
|
|
53
|
-
const isFullWidth = ReactTestUtils.scryRenderedDOMComponentsWithClass(
|
|
54
|
-
component,
|
|
55
|
-
"container-full-width"
|
|
56
|
-
)[1];
|
|
57
|
-
const isFullWidthNode = ReactDOM.findDOMNode(isFullWidth);
|
|
58
|
-
expect(ReactTestUtils.isDOMComponent(isFullWidthNode)).to.be.true;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("renders optional custom assets if passed", () => {
|
|
62
|
-
// Test render with default assets
|
|
63
|
-
const stockComponent = ReactTestUtils.renderIntoDocument(
|
|
64
|
-
<Wrapper>
|
|
65
|
-
<FooterUI isNewFooter={true} />
|
|
66
|
-
</Wrapper>
|
|
67
|
-
);
|
|
68
|
-
const defaultLogoNode =
|
|
69
|
-
ReactTestUtils.findRenderedDOMComponentWithClass(
|
|
70
|
-
stockComponent,
|
|
71
|
-
"hhs-logo"
|
|
72
|
-
);
|
|
73
|
-
expect(ReactTestUtils.isDOMComponent(defaultLogoNode)).to.be.true;
|
|
74
|
-
|
|
75
|
-
// Test render with custom asset
|
|
76
|
-
const assets = {
|
|
77
|
-
hhsLogo: <img src="/test-image.png" className="hhs-logo-custom" />,
|
|
78
|
-
};
|
|
79
|
-
const customAssetComponent = ReactTestUtils.renderIntoDocument(
|
|
80
|
-
<Wrapper>
|
|
81
|
-
<FooterUI isNewFooter={true} assets={assets} />
|
|
82
|
-
</Wrapper>
|
|
83
|
-
);
|
|
84
|
-
const customLogoNode = ReactTestUtils.findRenderedDOMComponentWithClass(
|
|
85
|
-
customAssetComponent,
|
|
86
|
-
"hhs-logo-custom"
|
|
87
|
-
);
|
|
88
|
-
expect(ReactTestUtils.isDOMComponent(customLogoNode)).to.be.true;
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe("renders the footer properly in the non-authenticated experience", () => {
|
|
93
|
-
it("renders by default the non-authenticated experience", () => {
|
|
94
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
95
|
-
<Wrapper>
|
|
96
|
-
<FooterUI />
|
|
97
|
-
</Wrapper>
|
|
98
|
-
);
|
|
99
|
-
const isNotFullWidth =
|
|
100
|
-
ReactTestUtils.scryRenderedDOMComponentsWithClass(
|
|
101
|
-
component,
|
|
102
|
-
"responsive-container"
|
|
103
|
-
)[1];
|
|
104
|
-
const isNotFullWidthNode = ReactDOM.findDOMNode(isNotFullWidth);
|
|
105
|
-
expect(ReactTestUtils.isDOMComponent(isNotFullWidthNode)).to.be.true;
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("explicitly renders the non-authenticated experience", () => {
|
|
109
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
110
|
-
<Wrapper>
|
|
111
|
-
<FooterUI isFullWidth={false} />
|
|
112
|
-
</Wrapper>
|
|
113
|
-
);
|
|
114
|
-
const isNotFullWidth =
|
|
115
|
-
ReactTestUtils.scryRenderedDOMComponentsWithClass(
|
|
116
|
-
component,
|
|
117
|
-
"responsive-container"
|
|
118
|
-
)[1];
|
|
119
|
-
const isNotFullWidthNode = ReactDOM.findDOMNode(isNotFullWidth);
|
|
120
|
-
expect(ReactTestUtils.isDOMComponent(isNotFullWidthNode)).to.be.true;
|
|
121
|
-
});
|
|
122
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import { act, Simulate } from "react-dom/test-utils";
|
|
4
|
-
import { expect } from "chai";
|
|
5
|
-
import { spy } from "sinon";
|
|
6
|
-
import Infotip from "../../components/Infotip";
|
|
7
|
-
|
|
8
|
-
describe("Infotip", () => {
|
|
9
|
-
let container;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
container = document.createElement("div");
|
|
13
|
-
document.body.appendChild(container);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
document.body.removeChild(container);
|
|
18
|
-
container = null;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("renders an svg icon for tooltip anchor", () => {
|
|
22
|
-
act(() => {
|
|
23
|
-
ReactDOM.render(<Infotip label="tooltip text" />, container);
|
|
24
|
-
});
|
|
25
|
-
const svg = container.querySelector("svg");
|
|
26
|
-
expect(svg).to.be.ok;
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("renders white icon when lightIcon prop is true", () => {
|
|
30
|
-
act(() => {
|
|
31
|
-
ReactDOM.render(
|
|
32
|
-
<Infotip lightIcon label="tooltip text" />,
|
|
33
|
-
container
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
const paths = container.querySelectorAll("path");
|
|
37
|
-
expect(paths[1].getAttribute("fill")).to.equal("#FFF");
|
|
38
|
-
expect(paths[2].getAttribute("fill")).to.equal("#04838A");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('overrides "touchstart" events for button', () => {
|
|
42
|
-
act(() => {
|
|
43
|
-
ReactDOM.render(<Infotip label="tooltip text" />, container);
|
|
44
|
-
});
|
|
45
|
-
const button = container.querySelector("button");
|
|
46
|
-
const stopPropagation = spy();
|
|
47
|
-
Simulate.touchStart(button, { stopPropagation });
|
|
48
|
-
expect(stopPropagation.called).to.be.true;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('uses "touchend" event on button to prevent default and toggle focus', () => {
|
|
52
|
-
act(() => {
|
|
53
|
-
ReactDOM.render(<Infotip label="tooltip text" />, container);
|
|
54
|
-
});
|
|
55
|
-
const button = container.querySelector("button");
|
|
56
|
-
const preventDefault = spy();
|
|
57
|
-
const focus = spy(button, "focus");
|
|
58
|
-
const blur = spy(button, "blur");
|
|
59
|
-
Simulate.touchEnd(button, {
|
|
60
|
-
preventDefault,
|
|
61
|
-
});
|
|
62
|
-
expect(preventDefault.calledOnce).to.be.true;
|
|
63
|
-
expect(button.focus.calledOnce).to.be.true;
|
|
64
|
-
expect(button.blur.calledOnce).to.be.false;
|
|
65
|
-
Simulate.touchEnd(button, {
|
|
66
|
-
preventDefault,
|
|
67
|
-
currentTarget: {
|
|
68
|
-
focus,
|
|
69
|
-
blur,
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
expect(preventDefault.calledTwice).to.be.true;
|
|
73
|
-
expect(focus.calledOnce).to.be.true;
|
|
74
|
-
expect(blur.calledOnce).to.be.true;
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import ReactTestUtils from "react-dom/test-utils";
|
|
4
|
-
import { expect } from "chai";
|
|
5
|
-
import Tooltip from "../../components/Tooltip";
|
|
6
|
-
import positionTip, {
|
|
7
|
-
positionTriangle,
|
|
8
|
-
} from "../../components/Tooltip/position";
|
|
9
|
-
|
|
10
|
-
class Wrapper extends Component {
|
|
11
|
-
render() {
|
|
12
|
-
return this.props.children;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("Tooltip", () => {
|
|
17
|
-
it("renders children into document", () => {
|
|
18
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
19
|
-
<Wrapper>
|
|
20
|
-
<Tooltip label="tooltip text">
|
|
21
|
-
<button>Tooltip Button</button>
|
|
22
|
-
</Tooltip>
|
|
23
|
-
</Wrapper>
|
|
24
|
-
);
|
|
25
|
-
const tooltipButton = ReactTestUtils.findRenderedDOMComponentWithTag(
|
|
26
|
-
component,
|
|
27
|
-
"button"
|
|
28
|
-
);
|
|
29
|
-
const node = ReactDOM.findDOMNode(tooltipButton);
|
|
30
|
-
expect(ReactTestUtils.isDOMComponent(node)).to.be.true;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("tooltip is not rendered until activted", () => {
|
|
34
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
35
|
-
<Wrapper>
|
|
36
|
-
<Tooltip label="tooltip text">
|
|
37
|
-
<button>Tooltip Button</button>
|
|
38
|
-
</Tooltip>
|
|
39
|
-
</Wrapper>
|
|
40
|
-
);
|
|
41
|
-
const tooltip = document.body.querySelector("div[data-reach-tooltip]");
|
|
42
|
-
expect(tooltip).to.equal(null);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("renders a tooltip when activated", () => {
|
|
46
|
-
const component = ReactTestUtils.renderIntoDocument(
|
|
47
|
-
<Wrapper>
|
|
48
|
-
<Tooltip DEBUG_STYLE label="tooltip text">
|
|
49
|
-
<button>Tooltip Button</button>
|
|
50
|
-
</Tooltip>
|
|
51
|
-
</Wrapper>
|
|
52
|
-
);
|
|
53
|
-
const tooltip = document.body.querySelector("div[data-reach-tooltip]");
|
|
54
|
-
expect(tooltip).not.to.equal(null);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("position", () => {
|
|
58
|
-
it("returns empty object if triggerRect or tooltipRect are falsy", () => {
|
|
59
|
-
const position = positionTip();
|
|
60
|
-
expect(position).to.deep.equal({});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("calculates tooltip position above trigger", () => {
|
|
64
|
-
const triggerRect = {
|
|
65
|
-
x: 100,
|
|
66
|
-
y: 100,
|
|
67
|
-
width: 16,
|
|
68
|
-
height: 16,
|
|
69
|
-
top: 100,
|
|
70
|
-
right: 116,
|
|
71
|
-
bottom: 116,
|
|
72
|
-
left: 100,
|
|
73
|
-
};
|
|
74
|
-
const tooltipRect = {
|
|
75
|
-
width: 130,
|
|
76
|
-
height: 50,
|
|
77
|
-
};
|
|
78
|
-
const position = positionTip(triggerRect, tooltipRect);
|
|
79
|
-
expect(position).to.deep.equal({
|
|
80
|
-
left: "43px",
|
|
81
|
-
top: "38px",
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("calculates tooltip position below trigger", () => {
|
|
86
|
-
const triggerRect = {
|
|
87
|
-
x: 100,
|
|
88
|
-
y: 40,
|
|
89
|
-
width: 16,
|
|
90
|
-
height: 16,
|
|
91
|
-
top: 40,
|
|
92
|
-
right: 116,
|
|
93
|
-
bottom: 56,
|
|
94
|
-
left: 100,
|
|
95
|
-
};
|
|
96
|
-
const tooltipRect = {
|
|
97
|
-
width: 130,
|
|
98
|
-
height: 50,
|
|
99
|
-
};
|
|
100
|
-
const position = positionTip(triggerRect, tooltipRect);
|
|
101
|
-
expect(position).to.deep.equal({
|
|
102
|
-
left: "43px",
|
|
103
|
-
top: "68px",
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("calculates triangle tip position above trigger", () => {
|
|
108
|
-
const triggerRect = {
|
|
109
|
-
x: 100,
|
|
110
|
-
y: 100,
|
|
111
|
-
width: 16,
|
|
112
|
-
height: 16,
|
|
113
|
-
top: 100,
|
|
114
|
-
right: 116,
|
|
115
|
-
bottom: 116,
|
|
116
|
-
left: 100,
|
|
117
|
-
};
|
|
118
|
-
const tooltipRect = {
|
|
119
|
-
width: 130,
|
|
120
|
-
height: 50,
|
|
121
|
-
};
|
|
122
|
-
const positionCSS = positionTriangle(triggerRect, tooltipRect);
|
|
123
|
-
expect(positionCSS).to.match(/border-top: 8px solid;/);
|
|
124
|
-
expect(positionCSS).to.match(/top: 88px;/);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("calculates triangle tip position below trigger", () => {
|
|
128
|
-
const triggerRect = {
|
|
129
|
-
x: 100,
|
|
130
|
-
y: 40,
|
|
131
|
-
width: 16,
|
|
132
|
-
height: 16,
|
|
133
|
-
top: 40,
|
|
134
|
-
right: 116,
|
|
135
|
-
bottom: 56,
|
|
136
|
-
left: 100,
|
|
137
|
-
};
|
|
138
|
-
const tooltipRect = {
|
|
139
|
-
width: 130,
|
|
140
|
-
height: 50,
|
|
141
|
-
};
|
|
142
|
-
const positionCSS = positionTriangle(triggerRect, tooltipRect);
|
|
143
|
-
expect(positionCSS).to.match(/border-bottom: 8px solid;/);
|
|
144
|
-
expect(positionCSS).to.match(/top: 60px;/);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
});
|
package/webpack.config.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const webpack = require("webpack");
|
|
3
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
4
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
5
|
-
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
6
|
-
|
|
7
|
-
const pkg = require("./package.json");
|
|
8
|
-
const entry = ["./index.js"];
|
|
9
|
-
|
|
10
|
-
const _module = {
|
|
11
|
-
rules: [
|
|
12
|
-
{
|
|
13
|
-
test: /\.(js|jsx)?$/,
|
|
14
|
-
loader: "babel-loader",
|
|
15
|
-
exclude: /node_modules/,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
test: /\.scss$/,
|
|
19
|
-
use: [
|
|
20
|
-
{
|
|
21
|
-
loader: MiniCssExtractPlugin.loader,
|
|
22
|
-
},
|
|
23
|
-
"css-loader",
|
|
24
|
-
{
|
|
25
|
-
loader: "sass-loader",
|
|
26
|
-
options: {
|
|
27
|
-
sassOptions: {
|
|
28
|
-
includePaths: ["styles"],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
"sass-loader",
|
|
33
|
-
],
|
|
34
|
-
exclude: /node_modules/,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
test: /\.(ttf|eot|woff|otf|woff2)$/,
|
|
38
|
-
loader: "file-loader",
|
|
39
|
-
options: {
|
|
40
|
-
name: "fonts/[name].[ext]",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
test: /\.svg$/,
|
|
45
|
-
use: [
|
|
46
|
-
"raw-loader",
|
|
47
|
-
{
|
|
48
|
-
loader: "svgo-loader",
|
|
49
|
-
options: {
|
|
50
|
-
plugins: [
|
|
51
|
-
{ removeTitle: true },
|
|
52
|
-
{ convertColors: { shorthex: false } },
|
|
53
|
-
{ convertPathData: false },
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const plugins = [
|
|
63
|
-
new MiniCssExtractPlugin({
|
|
64
|
-
filename: "default.css",
|
|
65
|
-
}),
|
|
66
|
-
new webpack.DefinePlugin({
|
|
67
|
-
"process.env": {
|
|
68
|
-
NODE_ENV: JSON.stringify("production"),
|
|
69
|
-
},
|
|
70
|
-
}),
|
|
71
|
-
new webpack.DefinePlugin({
|
|
72
|
-
buildVersion: JSON.stringify(pkg.version),
|
|
73
|
-
}),
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
const resolve = {
|
|
77
|
-
extensions: [".js", ".jsx", ".json", ".svg", "*"],
|
|
78
|
-
alias: {
|
|
79
|
-
react: "preact/compat",
|
|
80
|
-
"react-dom": "preact/compat",
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const optimization = {
|
|
85
|
-
minimizer: [new TerserPlugin()],
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const defaultConfig = (env, argv) => {
|
|
89
|
-
return {
|
|
90
|
-
mode: "production",
|
|
91
|
-
entry,
|
|
92
|
-
output: {
|
|
93
|
-
library: "QPPStyle",
|
|
94
|
-
libraryTarget: "umd",
|
|
95
|
-
filename: "index.js",
|
|
96
|
-
path: path.resolve(__dirname, "dist"),
|
|
97
|
-
},
|
|
98
|
-
devtool: env.production === "true" ? "source-map" : "eval-source-map",
|
|
99
|
-
module: _module, // module is already defined
|
|
100
|
-
plugins,
|
|
101
|
-
resolve,
|
|
102
|
-
optimization,
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const browserConfig = (env, argv) => {
|
|
107
|
-
return {
|
|
108
|
-
mode: "production",
|
|
109
|
-
entry,
|
|
110
|
-
output: {
|
|
111
|
-
libraryTarget: "var",
|
|
112
|
-
library: "QPPStyle",
|
|
113
|
-
filename: "browser.js",
|
|
114
|
-
path: path.resolve(__dirname, "dist"),
|
|
115
|
-
},
|
|
116
|
-
devtool: env.production === "true" ? "source-map" : "eval-source-map",
|
|
117
|
-
module: _module, // module is already defined
|
|
118
|
-
plugins,
|
|
119
|
-
resolve,
|
|
120
|
-
optimization,
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
module.exports = [defaultConfig, browserConfig];
|
package/webpack.config.react.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
3
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
4
|
-
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
5
|
-
|
|
6
|
-
// const ESLintPlugin = require('eslint-webpack-plugin');
|
|
7
|
-
|
|
8
|
-
const _module = {
|
|
9
|
-
rules: [
|
|
10
|
-
{
|
|
11
|
-
test: /\.(js|jsx)?$/,
|
|
12
|
-
exclude: /node_modules/,
|
|
13
|
-
use: {
|
|
14
|
-
loader: "babel-loader",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
test: /\.scss$/,
|
|
19
|
-
use: [
|
|
20
|
-
{
|
|
21
|
-
loader: MiniCssExtractPlugin.loader,
|
|
22
|
-
},
|
|
23
|
-
"css-loader",
|
|
24
|
-
{
|
|
25
|
-
loader: "sass-loader",
|
|
26
|
-
options: {
|
|
27
|
-
sassOptions: {
|
|
28
|
-
includePaths: ["styles"],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
"style-loader",
|
|
33
|
-
],
|
|
34
|
-
exclude: /node_modules/,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
test: /\.(ttf|eot|woff|otf|woff2)$/,
|
|
38
|
-
loader: "file-loader",
|
|
39
|
-
options: {
|
|
40
|
-
name: "fonts/[name].[ext]",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
test: /\.svg$/,
|
|
45
|
-
use: [
|
|
46
|
-
"raw-loader",
|
|
47
|
-
{
|
|
48
|
-
loader: "svgo-loader",
|
|
49
|
-
options: {
|
|
50
|
-
plugins: [
|
|
51
|
-
{ removeTitle: true },
|
|
52
|
-
{ convertColors: { shorthex: false } },
|
|
53
|
-
{ convertPathData: false },
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const optimization = {
|
|
63
|
-
minimizer: [new TerserPlugin()],
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const plugins = [
|
|
67
|
-
new MiniCssExtractPlugin({
|
|
68
|
-
filename: "default.css",
|
|
69
|
-
}),
|
|
70
|
-
new HtmlWebpackPlugin(),
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
module.exports = {
|
|
74
|
-
mode: "production",
|
|
75
|
-
entry: "./components/index.js",
|
|
76
|
-
output: {
|
|
77
|
-
filename: "index.js",
|
|
78
|
-
path: path.resolve(__dirname, "dist/react"),
|
|
79
|
-
library: "$",
|
|
80
|
-
libraryTarget: "umd",
|
|
81
|
-
globalObject: "this",
|
|
82
|
-
},
|
|
83
|
-
// below lines fix hot reload but put CI/CD into a hanging state
|
|
84
|
-
// watch: true,
|
|
85
|
-
// watchOptions: {
|
|
86
|
-
// ignored: /node_modules/, // Don't watch files in node_modules
|
|
87
|
-
// aggregateTimeout: 300,
|
|
88
|
-
// poll: 1000,
|
|
89
|
-
// },
|
|
90
|
-
// devServer: {
|
|
91
|
-
// // static: path.join(__dirname, "dist/react"),
|
|
92
|
-
// // compress: true,
|
|
93
|
-
// hot: true, // Enable hot module replacement
|
|
94
|
-
// watchFiles: ["src/**/*", "components/**/*"], // Watch these files
|
|
95
|
-
// },
|
|
96
|
-
devtool: "source-map",
|
|
97
|
-
module: _module,
|
|
98
|
-
plugins,
|
|
99
|
-
resolve: {
|
|
100
|
-
extensions: [".js", ".jsx", ".json", ".svg", "*"],
|
|
101
|
-
},
|
|
102
|
-
optimization,
|
|
103
|
-
externals: { react: "react" },
|
|
104
|
-
};
|