@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.
Files changed (156) hide show
  1. package/.babelrc +14 -2
  2. package/.eslintrc.js +1 -1
  3. package/.storybook/.babelrc +2 -1
  4. package/.storybook/main.js +3 -11
  5. package/.storybook/preview.js +1 -1
  6. package/components/Accordion/index.jsx +32 -36
  7. package/components/AutoComplete/AutoComplete.jsx +2 -17
  8. package/components/Button/Button.stories.js +0 -7
  9. package/components/Button/index.js +34 -44
  10. package/components/DateField/DateField.jsx +2 -15
  11. package/components/DateField/DateField.stories.jsx +23 -10
  12. package/components/DateTimeField/DateTimeField.jsx +7 -11
  13. package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
  14. package/components/InputLabel/index.jsx +1 -6
  15. package/components/Instant/Instant.stories.js +14 -6
  16. package/components/Instant/index.jsx +0 -16
  17. package/components/Link/index.js +14 -33
  18. package/components/MadieAlert/MadieAlert.stories.js +35 -29
  19. package/components/MadieAlert/index.jsx +5 -44
  20. package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -32
  21. package/components/MadieConfirmDialog/index.jsx +0 -8
  22. package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -24
  23. package/components/MadieDeleteDialog/index.jsx +0 -7
  24. package/components/MadieDialog/MadieDialog.stories.js +45 -121
  25. package/components/MadieDialog/index.jsx +4 -23
  26. package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -12
  27. package/components/MadieDiscardDialog/index.jsx +0 -7
  28. package/components/MadieSpinner/MadieSpinner.stories.js +1 -9
  29. package/components/MadieSpinner/index.jsx +0 -5
  30. package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
  31. package/components/MadieTooltip/index.jsx +0 -6
  32. package/components/MadieTooltipIcon/index.jsx +0 -5
  33. package/components/Modal/Modal.jsx +31 -43
  34. package/components/Modal/Modal.stories.js +18 -89
  35. package/components/Modal/index.jsx +6 -8
  36. package/components/NumberInput/NumberInput.stories.js +50 -67
  37. package/components/NumberInput/index.jsx +0 -13
  38. package/components/Pagination/index.jsx +0 -17
  39. package/components/Popover/Popover.stories.js +6 -14
  40. package/components/Popover/index.js +0 -23
  41. package/components/RadioButton/RadioButton.jsx +5 -15
  42. package/components/RadioButton/RadioButton.stories.jsx +6 -2
  43. package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +3 -8
  44. package/components/ReadOnlyTextField/index.jsx +1 -9
  45. package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
  46. package/components/RichTextEditor/index.jsx +14 -30
  47. package/components/SanitizedContent/index.jsx +0 -8
  48. package/components/Search/Search.stories.js +2 -4
  49. package/components/Search/index.js +26 -40
  50. package/components/Select/Select.stories.js +59 -164
  51. package/components/Select/index.jsx +2 -17
  52. package/components/Tabs/Tab.js +29 -25
  53. package/components/Tabs/TabPanel.js +15 -19
  54. package/components/Tabs/Tabs.stories.js +43 -211
  55. package/components/Tabs/index.js +10 -28
  56. package/components/TextArea/TextArea.stories.js +87 -113
  57. package/components/TextArea/index.jsx +2 -14
  58. package/components/TextField/TextField.stories.js +100 -129
  59. package/components/TextField/index.jsx +2 -17
  60. package/components/TimeField/TimeField.jsx +0 -10
  61. package/components/TimeField/TimeField.stories.js +18 -8
  62. package/components/Toast/Toast.stories.js +42 -102
  63. package/components/Toast/index.jsx +0 -14
  64. package/components/TruncateText/TruncateText.stories.js +22 -17
  65. package/components/TruncateText/index.js +0 -8
  66. package/components/hooks/useGetConfig.js +2 -2
  67. package/components/{index.js → index.mjs} +37 -57
  68. package/dist/index.js +3 -1
  69. package/dist/index.js.LICENSE.txt +16 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/react/index.html +1 -1
  72. package/dist/react/index.mjs +103 -0
  73. package/dist/react/{index.js.LICENSE.txt → index.mjs.LICENSE.txt} +3 -52
  74. package/dist/react/index.mjs.map +1 -0
  75. package/dist/react/package.json +1 -0
  76. package/eslint.config.cjs +59 -0
  77. package/index.js +7 -9
  78. package/jest.config.mjs +10 -0
  79. package/lib/Chevron.jsx +2 -10
  80. package/package.json +57 -82
  81. package/styles/_main.scss +4 -3
  82. package/test/components/Accordion.test.js +1 -1
  83. package/test/components/AutoComplete.test.js +11 -6
  84. package/test/components/Button.test.js +13 -19
  85. package/test/components/DateField.test.js +25 -29
  86. package/test/components/DateTimeField.test.js +21 -25
  87. package/test/components/Instant.test.js +1 -1
  88. package/test/components/MadieAlert.test.js +22 -22
  89. package/test/components/MadieConfirmDialog.test.js +42 -64
  90. package/test/components/MadieDeleteDialog.test.js +51 -69
  91. package/test/components/MadieDialog.test.js +13 -13
  92. package/test/components/MadieDiscardDialog.test.js +28 -45
  93. package/test/components/MadieSpinner.test.js +12 -17
  94. package/test/components/Modal.test.js +115 -0
  95. package/test/components/Pagination.test.js +2 -2
  96. package/test/components/RadioButton.test.js +7 -7
  97. package/test/components/ReadOnlyTextField.test.js +4 -2
  98. package/test/components/RichTextEditor.test.js +90 -6
  99. package/test/components/Search.test.js +75 -0
  100. package/test/components/Select.test.js +97 -107
  101. package/test/components/Tabs.test.js +22 -24
  102. package/test/components/TextArea.test.js +78 -92
  103. package/test/components/TextField.test.js +128 -147
  104. package/test/components/Toast.test.js +67 -78
  105. package/test/components/TruncateText.test.js +75 -0
  106. package/test/components/index.test.js +23 -0
  107. package/webpack.config.mjs +79 -0
  108. package/webpack.config.react.mjs +72 -0
  109. package/.eslintignore +0 -5
  110. package/components/Alert/Alert.stories.js +0 -70
  111. package/components/Alert/index.js +0 -55
  112. package/components/Breadcrumb/Breadcrumb.md +0 -28
  113. package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
  114. package/components/Breadcrumb/index.js +0 -92
  115. package/components/CalloutBox/CalloutBox.stories.js +0 -94
  116. package/components/CalloutBox/index.js +0 -109
  117. package/components/Card/Card.stories.js +0 -163
  118. package/components/Card/index.js +0 -144
  119. package/components/Dropdown/Dropdown.stories.js +0 -94
  120. package/components/Dropdown/index.js +0 -85
  121. package/components/Error/Collapsible.jsx +0 -93
  122. package/components/Error/ErrorUI.jsx +0 -31
  123. package/components/Error/error.js +0 -26
  124. package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
  125. package/components/FlashNotification/index.js +0 -30
  126. package/components/Footer/Footer.stories.js +0 -20
  127. package/components/Footer/FooterUI.jsx +0 -137
  128. package/components/Footer/LegacyFooterUI.jsx +0 -204
  129. package/components/Footer/SocialLinks.jsx +0 -63
  130. package/components/Footer/Subscribe.jsx +0 -34
  131. package/components/Footer/footer.js +0 -30
  132. package/components/Infotip/Infotip.jsx +0 -75
  133. package/components/Infotip/Infotip.stories.js +0 -52
  134. package/components/Infotip/InfotipIcon.jsx +0 -41
  135. package/components/Infotip/index.js +0 -3
  136. package/components/Link/Link.stories.js +0 -82
  137. package/components/NotificationBanner/NotificationBanner.stories.js +0 -23
  138. package/components/NotificationBanner/index.js +0 -279
  139. package/components/Spinner/index.js +0 -9
  140. package/components/TextInput/TextInput.stories.js +0 -118
  141. package/components/TextInput/index.js +0 -137
  142. package/components/Tooltip/Tooltip.jsx +0 -88
  143. package/components/Tooltip/Tooltip.stories.js +0 -80
  144. package/components/Tooltip/index.js +0 -3
  145. package/components/Tooltip/position.js +0 -76
  146. package/components/UnwrappedSpinner/index.js +0 -8
  147. package/dist/browser.js +0 -1
  148. package/dist/react/index.js +0 -185
  149. package/dist/react/index.js.map +0 -1
  150. package/jest.config.js +0 -17
  151. package/test/components/ErrorUI.test.js +0 -32
  152. package/test/components/FooterUI.test.js +0 -122
  153. package/test/components/Infotip.test.js +0 -76
  154. package/test/components/Tooltip.test.js +0 -147
  155. package/webpack.config.js +0 -124
  156. package/webpack.config.react.js +0 -104
@@ -1,137 +0,0 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
-
4
- const TextInput = ({
5
- id,
6
- name,
7
- placeholder,
8
- disabled,
9
- required,
10
- size,
11
- className,
12
- label,
13
- minLength,
14
- maxLength,
15
- hint,
16
- errorLabel,
17
- error,
18
- autoComplete,
19
- onChange,
20
- onKeyPress,
21
- style,
22
- dataTestId,
23
- type,
24
- innerRef,
25
- number,
26
- variant,
27
- parentElement,
28
- ...props
29
- }) => {
30
- const ContainerElement = parentElement || "span";
31
- const numberProps = {
32
- pattern: "[0-9]*",
33
- };
34
-
35
- const textInputClass = [
36
- "qpp-c-text-input",
37
- variant === "success" && !error && "qpp-c-text-input--success",
38
- error && "qpp-c-text-input--error",
39
- size === "big" && "qpp-c-text-input--big",
40
- className,
41
- ]
42
- .filter(Boolean)
43
- .join(" ");
44
-
45
- return (
46
- <ContainerElement className="qppds ds-text-input-container">
47
- {label && (
48
- <label className="qpp-u-margin-bottom--8" htmlFor={id}>
49
- {label}
50
- </label>
51
- )}
52
- <input
53
- {...(number ? numberProps : {})}
54
- style={style}
55
- data-testid={dataTestId}
56
- type={type}
57
- className={textInputClass || ""}
58
- id={id}
59
- name={name}
60
- placeholder={placeholder}
61
- disabled={disabled}
62
- minLength={minLength}
63
- maxLength={maxLength}
64
- required={required}
65
- autoComplete={autoComplete}
66
- onChange={onChange}
67
- onKeyPress={onKeyPress}
68
- ref={innerRef}
69
- {...props}
70
- />
71
- {hint && <span className="qpp-hint-message">{hint}</span>}
72
- {error && (
73
- <span
74
- aria-label={errorLabel}
75
- role="alert"
76
- className="qpp-error-message"
77
- >
78
- {error}
79
- </span>
80
- )}
81
- </ContainerElement>
82
- );
83
- };
84
-
85
- TextInput.propTypes = {
86
- id: PropTypes.string,
87
- name: PropTypes.string,
88
- placeholder: PropTypes.string,
89
- disabled: PropTypes.bool,
90
- required: PropTypes.bool,
91
- className: PropTypes.string,
92
- minLength: PropTypes.string,
93
- maxLength: PropTypes.string,
94
- hint: PropTypes.string,
95
- errorLabel: PropTypes.string,
96
- error: PropTypes.string,
97
- autoComplete: PropTypes.string,
98
- onChange: PropTypes.func,
99
- onKeyPress: PropTypes.func,
100
- style: PropTypes.object,
101
- dataTestId: PropTypes.string,
102
- type: PropTypes.string,
103
- innerRef: PropTypes.string,
104
- number: PropTypes.bool,
105
- variant: PropTypes.oneOf(["success"]),
106
- parentElement: PropTypes.string,
107
- label: PropTypes.string,
108
- size: PropTypes.oneOf(["big"]),
109
- };
110
-
111
- TextInput.defaultProps = {
112
- id: "",
113
- name: "",
114
- placeholder: null,
115
- disabled: false,
116
- required: false,
117
- className: "",
118
- minLength: "",
119
- maxLength: "",
120
- error: null,
121
- errorLabel: null,
122
- hint: null,
123
- autoComplete: "on",
124
- onChange: () => null,
125
- onKeyPress: () => null,
126
- style: null,
127
- dataTestId: "",
128
- type: "text",
129
- innerRef: null,
130
- number: false,
131
- variant: null,
132
- parentElement: "span",
133
- label: null,
134
- size: null,
135
- };
136
-
137
- export default TextInput;
@@ -1,88 +0,0 @@
1
- import React, { cloneElement, useLayoutEffect, useRef } from "react";
2
- import PropTypes from "prop-types";
3
- import positionTip, { positionTriangle } from "./position";
4
- import { useTooltip, TooltipPopup } from "@reach/tooltip";
5
- import Portal from "@reach/portal";
6
-
7
- // TODO: investigate ways to allow more styling via css? the triangle
8
- // positioning effect issue may need to be resolved to allow for this.
9
- const TEXT_COLOR = "#FFF";
10
- const BACKGROUND_COLOR = "#333";
11
-
12
- /**
13
- * Generic styled tooltip component.
14
- * Corresponding styles: /styles/components/_tooltip.scss
15
- *
16
- * Extends implementation from @reach/tooltip:
17
- * https://reacttraining.com/reach-ui/tooltip
18
- */
19
- const Tooltip = ({ children, label, ariaLabel, DEBUG_STYLE }) => {
20
- const [trigger, tooltip] = useTooltip({ DEBUG_STYLE });
21
- const { isVisible, triggerRect } = tooltip;
22
- const tooltipPopupRef = useRef();
23
- const triangleRef = useRef();
24
-
25
- useLayoutEffect(() => {
26
- // For some reason, the forwardRef for the tooltipPopup points to an undefined
27
- // dom element when we first render the portal containing the triangle. Using
28
- // an effect here will ensure that the ref is available when applying styles.
29
- // TODO: investigate and make issue for @reach-ui/tooltip?
30
- if (isVisible && tooltipPopupRef.current && triggerRect) {
31
- const tooltipRect = tooltipPopupRef.current.getBoundingClientRect();
32
- const positionCssText = positionTriangle(triggerRect, tooltipRect);
33
- const cssText = `
34
- position: absolute;
35
- width: 0;
36
- height: 0;
37
- ${positionCssText}
38
- border-top-color: ${BACKGROUND_COLOR};
39
- border-bottom-color: ${BACKGROUND_COLOR};
40
- z-index: 1;
41
- `;
42
- triangleRef.current.style.cssText = cssText;
43
- }
44
- });
45
-
46
- return (
47
- <>
48
- {cloneElement(children, trigger)}
49
- <TooltipPopup
50
- {...tooltip}
51
- label={label}
52
- ariaLabel={ariaLabel}
53
- style={{
54
- background: BACKGROUND_COLOR,
55
- color: TEXT_COLOR,
56
- }}
57
- ref={tooltipPopupRef}
58
- position={positionTip}
59
- />
60
- {isVisible && (
61
- <Portal>
62
- <div
63
- ref={triangleRef}
64
- style={{
65
- position: "absolute",
66
- width: 0,
67
- height: 0,
68
- }}
69
- />
70
- </Portal>
71
- )}
72
- </>
73
- );
74
- };
75
-
76
- Tooltip.propTypes = {
77
- children: PropTypes.node.isRequired,
78
- label: PropTypes.node.isRequired,
79
- ariaLabel: PropTypes.string,
80
- DEBUG_STYLE: PropTypes.bool,
81
- };
82
-
83
- Tooltip.defaultProps = {
84
- ariaLabel: undefined,
85
- DEBUG_STYLE: undefined,
86
- };
87
-
88
- export default Tooltip;
@@ -1,80 +0,0 @@
1
- import React from "react";
2
- import Tooltip from "./index";
3
-
4
- const offsetDecorator = (storyFn) => (
5
- <div style={{ margin: "80px" }}>{storyFn()}</div>
6
- );
7
-
8
- export default {
9
- title: "Tooltip",
10
- component: Tooltip,
11
- };
12
-
13
- export const ExampleTooltip = () => (
14
- <Tooltip label="FOOBAR">
15
- <button>
16
- <span>Tooltip Trigger</span>
17
- </button>
18
- </Tooltip>
19
- );
20
-
21
- ExampleTooltip.storyName = "example Tooltip";
22
- ExampleTooltip.decorators = [offsetDecorator];
23
-
24
- export const AriaLabelTooltip = () => (
25
- <Tooltip label="FOOBAR" ariaLabel="foobar">
26
- <button>
27
- <span>Tooltip Trigger</span>
28
- </button>
29
- </Tooltip>
30
- );
31
-
32
- AriaLabelTooltip.storyName = "using ariaLabel";
33
- AriaLabelTooltip.decorators = [offsetDecorator];
34
-
35
- export const MultipleTooltip = () => (
36
- <>
37
- <Tooltip label="Tooltip 1">
38
- <button>
39
- <span>Tooltip 1 Trigger</span>
40
- </button>
41
- </Tooltip>
42
- <Tooltip label="Tooltip 2">
43
- <button>
44
- <span>Tooltip 2 Trigger</span>
45
- </button>
46
- </Tooltip>
47
- <Tooltip label="Tooltip 3">
48
- <button>
49
- <span>Tooltip 3 Trigger</span>
50
- </button>
51
- </Tooltip>
52
- </>
53
- );
54
-
55
- MultipleTooltip.storyName = "multiple Tooltips";
56
- MultipleTooltip.decorators = [offsetDecorator];
57
-
58
- export const InputElementTooltip = () => (
59
- <form>
60
- <label htmlFor="foobar" style={{ marginRight: "5px " }}>
61
- Text Input
62
- </label>
63
- <Tooltip label="example input label tooltip">
64
- <input type="text" name="foobar" />
65
- </Tooltip>
66
- </form>
67
- );
68
-
69
- InputElementTooltip.storyName = "on text input";
70
- InputElementTooltip.decorators = [offsetDecorator];
71
-
72
- export const PositionedBelowTargetTooltip = () => (
73
- <Tooltip label="FOOBAR">
74
- <button>
75
- <span>Tooltip Trigger</span>
76
- </button>
77
- </Tooltip>
78
- );
79
-
80
- PositionedBelowTargetTooltip.storyName = "positioned below trigger";
@@ -1,3 +0,0 @@
1
- import Tooltip from "./Tooltip";
2
-
3
- export default Tooltip;
@@ -1,76 +0,0 @@
1
- const OFFSET = 12; // modified from reach-ui/tooltip OFFSET value
2
- const TRIANGLE_SCALE_X = 6;
3
- const TRIANGLE_SCALE_Y = 8;
4
-
5
- const isDirectionUp = (triggerRect, tooltipRect) => {
6
- const collisions = {
7
- top: triggerRect.top - tooltipRect.height < 0,
8
- bottom:
9
- window.innerHeight <
10
- triggerRect.bottom + tooltipRect.height + OFFSET,
11
- };
12
-
13
- return !collisions.top || collisions.bottom;
14
- };
15
-
16
- // modified from @reach/tooltip default positioning function
17
- // positions Tooltip relative to trigger
18
- // https://github.com/reach/reach-ui/blob/master/packages/tooltip/src/index.tsx#L532
19
- const positionTip = (triggerRect, tooltipRect) => {
20
- if (!triggerRect || !tooltipRect) {
21
- return {};
22
- }
23
-
24
- const triggerCenter = triggerRect.left + triggerRect.width / 2;
25
- const left = triggerCenter - tooltipRect.width / 2;
26
- const maxLeft = window.innerWidth - tooltipRect.width - 2;
27
- const centerLeft =
28
- Math.min(Math.max(2, left), maxLeft) + window.pageXOffset;
29
-
30
- const directionUp = isDirectionUp(triggerRect, tooltipRect);
31
-
32
- return {
33
- left: `${centerLeft}px`,
34
- top: directionUp
35
- ? `${
36
- triggerRect.top -
37
- OFFSET -
38
- tooltipRect.height +
39
- window.pageYOffset
40
- }px`
41
- : `${
42
- triggerRect.top +
43
- OFFSET +
44
- triggerRect.height +
45
- window.pageYOffset
46
- }px`,
47
- };
48
- };
49
-
50
- export default positionTip;
51
-
52
- // position triangle relative to tooltip position
53
- // TODO: figure out a better way to render these updates from within react
54
- // rendering. This method causes an additional repaint after the Tooltip
55
- // has been rendered. may require changes to @reach/tooltip.
56
- export const positionTriangle = (triggerRect, tooltipRect) => {
57
- const directionUp = isDirectionUp(triggerRect, tooltipRect);
58
- const triangleTop = directionUp
59
- ? triggerRect.top + window.pageYOffset - OFFSET
60
- : triggerRect.bottom + window.pageYOffset + OFFSET - TRIANGLE_SCALE_Y;
61
-
62
- const triangleLeft =
63
- triggerRect.left - TRIANGLE_SCALE_X + triggerRect.width / 2;
64
-
65
- const triangleBorder = directionUp
66
- ? `border-top: ${TRIANGLE_SCALE_Y}px solid;`
67
- : `border-bottom: ${TRIANGLE_SCALE_Y}px solid;`;
68
-
69
- return `
70
- border-left: ${TRIANGLE_SCALE_X}px solid transparent;
71
- border-right: ${TRIANGLE_SCALE_X}px solid transparent;
72
- left: ${triangleLeft}px;
73
- top: ${triangleTop}px;
74
- ${triangleBorder}
75
- `;
76
- };
@@ -1,8 +0,0 @@
1
- import React, { Component } from "react";
2
- import DSSpinner from "@cmsgov/design-system/dist/components/Spinner/Spinner";
3
-
4
- export default class SpinnerUI extends Component {
5
- render() {
6
- return <DSSpinner />;
7
- }
8
- }