@madie/madie-design-system 1.2.62 → 2.0.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.
Files changed (118) hide show
  1. package/.eslintrc.js +1 -1
  2. package/.storybook/.babelrc +2 -1
  3. package/.storybook/main.js +3 -11
  4. package/components/AutoComplete/AutoComplete.jsx +1 -1
  5. package/components/Button/Button.stories.js +0 -2
  6. package/components/DateField/DateField.jsx +1 -1
  7. package/components/DateField/DateField.stories.jsx +23 -10
  8. package/components/DateTimeField/DateTimeField.jsx +6 -2
  9. package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
  10. package/components/Instant/Instant.stories.js +14 -6
  11. package/components/MadieAlert/MadieAlert.stories.js +35 -29
  12. package/components/MadieAlert/index.jsx +5 -5
  13. package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -27
  14. package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -18
  15. package/components/MadieDialog/MadieDialog.stories.js +45 -116
  16. package/components/MadieDialog/index.jsx +4 -2
  17. package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -7
  18. package/components/MadieSpinner/MadieSpinner.stories.js +1 -3
  19. package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
  20. package/components/Modal/Modal.stories.js +18 -89
  21. package/components/NotificationBanner/NotificationBanner.stories.js +17 -11
  22. package/components/NotificationBanner/index.js +3 -3
  23. package/components/NumberInput/NumberInput.stories.js +51 -63
  24. package/components/Popover/Popover.stories.js +6 -14
  25. package/components/Popover/index.js +2 -2
  26. package/components/RadioButton/RadioButton.jsx +4 -2
  27. package/components/RadioButton/RadioButton.stories.jsx +6 -2
  28. package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +4 -3
  29. package/components/ReadOnlyTextField/index.jsx +1 -1
  30. package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
  31. package/components/RichTextEditor/index.jsx +14 -15
  32. package/components/Search/Search.stories.js +2 -4
  33. package/components/Select/Select.stories.js +59 -160
  34. package/components/Select/index.jsx +1 -1
  35. package/components/Tabs/Tabs.stories.js +78 -210
  36. package/components/TextArea/TextArea.stories.js +88 -108
  37. package/components/TextArea/index.jsx +1 -1
  38. package/components/TextField/TextField.stories.js +101 -124
  39. package/components/TextField/index.jsx +1 -1
  40. package/components/TimeField/TimeField.stories.js +18 -8
  41. package/components/Toast/Toast.stories.js +42 -102
  42. package/components/TruncateText/TruncateText.stories.js +22 -17
  43. package/components/hooks/useGetConfig.js +2 -2
  44. package/components/index.js +0 -24
  45. package/dist/browser.js +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/react/index.js +182 -51
  48. package/dist/react/index.js.LICENSE.txt +27 -24
  49. package/dist/react/index.js.map +1 -1
  50. package/eslint.config.js +56 -0
  51. package/index.js +7 -9
  52. package/package.json +43 -75
  53. package/test/components/Accordion.test.js +1 -1
  54. package/test/components/AutoComplete.test.js +11 -6
  55. package/test/components/Button.test.js +7 -3
  56. package/test/components/DateField.test.js +25 -29
  57. package/test/components/DateTimeField.test.js +21 -25
  58. package/test/components/Instant.test.js +1 -1
  59. package/test/components/MadieAlert.test.js +22 -22
  60. package/test/components/MadieConfirmDialog.test.js +42 -64
  61. package/test/components/MadieDeleteDialog.test.js +51 -69
  62. package/test/components/MadieDialog.test.js +13 -13
  63. package/test/components/MadieDiscardDialog.test.js +28 -45
  64. package/test/components/MadieSpinner.test.js +12 -17
  65. package/test/components/Modal.test.js +115 -0
  66. package/test/components/Pagination.test.js +2 -2
  67. package/test/components/RadioButton.test.js +7 -7
  68. package/test/components/ReadOnlyTextField.test.js +4 -2
  69. package/test/components/RichTextEditor.test.js +90 -6
  70. package/test/components/Search.test.js +75 -0
  71. package/test/components/Select.test.js +97 -107
  72. package/test/components/Tabs.test.js +22 -24
  73. package/test/components/TextArea.test.js +78 -92
  74. package/test/components/TextField.test.js +128 -147
  75. package/test/components/Toast.test.js +67 -78
  76. package/test/components/TruncateText.test.js +75 -0
  77. package/test/components/index.test.js +23 -0
  78. package/webpack.config.js +0 -1
  79. package/.eslintignore +0 -5
  80. package/components/Alert/Alert.stories.js +0 -70
  81. package/components/Alert/index.js +0 -55
  82. package/components/Breadcrumb/Breadcrumb.md +0 -28
  83. package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
  84. package/components/Breadcrumb/index.js +0 -92
  85. package/components/CalloutBox/CalloutBox.stories.js +0 -94
  86. package/components/CalloutBox/index.js +0 -109
  87. package/components/Card/Card.stories.js +0 -163
  88. package/components/Card/index.js +0 -144
  89. package/components/Dropdown/Dropdown.stories.js +0 -94
  90. package/components/Dropdown/index.js +0 -85
  91. package/components/Error/Collapsible.jsx +0 -93
  92. package/components/Error/ErrorUI.jsx +0 -31
  93. package/components/Error/error.js +0 -26
  94. package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
  95. package/components/FlashNotification/index.js +0 -30
  96. package/components/Footer/Footer.stories.js +0 -20
  97. package/components/Footer/FooterUI.jsx +0 -137
  98. package/components/Footer/LegacyFooterUI.jsx +0 -204
  99. package/components/Footer/SocialLinks.jsx +0 -63
  100. package/components/Footer/Subscribe.jsx +0 -34
  101. package/components/Footer/footer.js +0 -30
  102. package/components/Infotip/Infotip.jsx +0 -75
  103. package/components/Infotip/Infotip.stories.js +0 -52
  104. package/components/Infotip/InfotipIcon.jsx +0 -41
  105. package/components/Infotip/index.js +0 -3
  106. package/components/Link/Link.stories.js +0 -82
  107. package/components/Link/index.js +0 -61
  108. package/components/Spinner/index.js +0 -9
  109. package/components/TextInput/TextInput.stories.js +0 -118
  110. package/components/TextInput/index.js +0 -137
  111. package/components/Tooltip/Tooltip.jsx +0 -88
  112. package/components/Tooltip/Tooltip.stories.js +0 -80
  113. package/components/Tooltip/index.js +0 -3
  114. package/components/Tooltip/position.js +0 -76
  115. package/test/components/ErrorUI.test.js +0 -32
  116. package/test/components/FooterUI.test.js +0 -122
  117. package/test/components/Infotip.test.js +0 -76
  118. package/test/components/Tooltip.test.js +0 -147
@@ -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
- });