@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
package/.babelrc CHANGED
@@ -1,4 +1,16 @@
1
1
  {
2
- "presets": ["@babel/preset-react", "@babel/preset-env"],
3
- "plugins": ["@babel/plugin-transform-modules-umd", "@babel/plugin-transform-class-properties"]
2
+ "presets": [
3
+ ["@babel/preset-react", { "runtime": "automatic" }],
4
+ ["@babel/preset-env", { "modules": false }]
5
+ ],
6
+ "plugins": [
7
+ "@babel/plugin-proposal-class-properties"
8
+ ],
9
+ "env": {
10
+ "test": {
11
+ "presets": [
12
+ ["@babel/preset-env", { "targets": { "node": "current" } }]
13
+ ]
14
+ }
15
+ }
4
16
  }
package/.eslintrc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  extends: ["eslint:recommended", "plugin:react/recommended"],
3
- parser: "babel-eslint",
3
+ parser: "@babel/eslint-parser",
4
4
  parserOptions: {
5
5
  sourceType: "module",
6
6
  ecmaFeatures: {
@@ -1,4 +1,5 @@
1
1
  {
2
- "presets": ["@babel/preset-react", "@babel/preset-env"],
2
+ "presets": ["@babel/preset-react"],
3
+ // "presets": ["@babel/preset-react", "@babel/preset-env"],
3
4
  "plugins": ["@babel/plugin-transform-class-properties"]
4
5
  }
@@ -5,17 +5,9 @@ module.exports = {
5
5
  ],
6
6
 
7
7
  addons: [
8
- "@storybook/addon-actions",
9
- "@storybook/addon-links",
10
- "@storybook/addon-storysource",
11
- "@storybook/addon-knobs",
12
- "@storybook/addon-a11y",
13
- "@storybook/addon-docs",
14
- "@storybook/addon-backgrounds",
15
- "@storybook/addon-viewport",
16
- "@storybook/addon-postcss",
17
- "@storybook/addon-webpack5-compiler-babel"
18
- ],
8
+ "@storybook/addon-links",
9
+ "@storybook/addon-webpack5-compiler-babel",
10
+ "@storybook/addon-docs"],
19
11
 
20
12
  webpackFinal: async (config) => {
21
13
  // do mutation to the config
@@ -3,4 +3,4 @@ import "../../react/styles/_main.scss";
3
3
  export const parameters = {
4
4
  layout: "fullscreen",
5
5
  };
6
- export const tags = ["autodocs"];
6
+ export const tags = ["autodocs"];
@@ -1,17 +1,29 @@
1
1
  import React, { useState, useRef, useEffect } from "react";
2
- import PropTypes from "prop-types";
3
2
  import { Chevron } from "../../lib/Chevron.jsx";
4
3
 
5
- const Accordion = (props) => {
4
+ /**
5
+ * @param {{
6
+ * title?: string,
7
+ * subTitle?: string,
8
+ * children: React.ReactNode,
9
+ * centerItem?: string,
10
+ * rightItem?: string,
11
+ * isOpen?: boolean
12
+ * }} props
13
+ */
14
+ const Accordion = ({
15
+ title = "",
16
+ subTitle,
17
+ children,
18
+ centerItem,
19
+ rightItem,
20
+ isOpen = false,
21
+ }) => {
6
22
  const content = useRef(null);
7
- const [setActive, setActiveState] = useState(props.isOpen ? "active" : "");
23
+ const [setActive, setActiveState] = useState(isOpen ? "active" : "");
8
24
  const ariaPressed = setActive ? "true" : "false";
9
- const getHeight = (node) => {
10
- if (node) {
11
- return `${node.scrollHeight}px`;
12
- }
13
- return "auto";
14
- };
25
+
26
+ const getHeight = (node) => (node ? `${node.scrollHeight}px` : "auto");
15
27
  const height = setActive ? getHeight(content.current) : "0px";
16
28
  const rotate = setActive ? "accordion-icon rotate" : "accordion-icon";
17
29
 
@@ -28,37 +40,37 @@ const Accordion = (props) => {
28
40
  }
29
41
 
30
42
  useEffect(() => {
31
- if (props.isOpen) {
43
+ if (isOpen) {
32
44
  openAccordion();
33
45
  } else {
34
46
  closeAccordion();
35
47
  }
36
- }, [props.isOpen]);
48
+ }, [isOpen]);
37
49
 
38
50
  return (
39
51
  <div className="accordion-section" data-testid="accordion">
40
52
  <button
41
53
  className={`accordion ${setActive}`}
42
- aria-label={props.title}
54
+ aria-label={title}
43
55
  aria-pressed={ariaPressed}
44
56
  aria-expanded={ariaPressed}
45
57
  tabIndex="0"
46
58
  onClick={toggleAccordion}
47
59
  >
48
60
  <div className="accordion-left-title">
49
- <p className="accordion-title">{props.title}</p>
50
- {props.subTitle && (
51
- <p className="accordion-subtitle">{props.subTitle}</p>
61
+ <p className="accordion-title">{title}</p>
62
+ {subTitle && (
63
+ <p className="accordion-subtitle">{subTitle}</p>
52
64
  )}
53
65
  </div>
54
- {props.centerItem && (
66
+ {centerItem && (
55
67
  <div className="accordion-center">
56
- <p>{props.centerItem}</p>
68
+ <p>{centerItem}</p>
57
69
  </div>
58
70
  )}
59
- {props.rightItem && (
71
+ {rightItem && (
60
72
  <div className="accordion-right">
61
- <p>{props.rightItem}</p>
73
+ <p>{rightItem}</p>
62
74
  </div>
63
75
  )}
64
76
  <div className="chevron-container">
@@ -70,26 +82,10 @@ const Accordion = (props) => {
70
82
  style={{ maxHeight: height }}
71
83
  className="accordion-content"
72
84
  >
73
- <div className="accordion-text dashed-border">
74
- {props.children}
75
- </div>
85
+ <div className="accordion-text dashed-border">{children}</div>
76
86
  </div>
77
87
  </div>
78
88
  );
79
89
  };
80
90
 
81
- Accordion.propTypes = {
82
- title: PropTypes.string.isRequired,
83
- subTitle: PropTypes.string,
84
- children: PropTypes.any.isRequired,
85
- centerItem: PropTypes.string,
86
- rightItem: PropTypes.string,
87
- isOpen: PropTypes.bool,
88
- };
89
-
90
- Accordion.defaultProps = {
91
- title: "",
92
- isOpen: false,
93
- };
94
-
95
91
  export default Accordion;
@@ -6,11 +6,10 @@ import {
6
6
  TextField,
7
7
  Checkbox,
8
8
  } from "@mui/material";
9
- import PropTypes from "prop-types";
10
9
  import InputLabel from "../InputLabel";
11
10
  import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
12
11
  import CheckBoxIcon from "@mui/icons-material/CheckBox";
13
- import { ReadOnlyTextField } from "../index";
12
+ import ReadOnlyTextField from "../ReadOnlyTextField";
14
13
  import _ from "lodash";
15
14
 
16
15
  const autoCompleteStyles = {
@@ -95,7 +94,7 @@ const AutoComplete = ({
95
94
  {...rest}
96
95
  value={_.isEmpty(rest.value) ? "-" : rest.value}
97
96
  />
98
- )
97
+ );
99
98
  }
100
99
 
101
100
  return (
@@ -244,18 +243,4 @@ const AutoComplete = ({
244
243
  );
245
244
  };
246
245
 
247
- AutoComplete.propTypes = {
248
- id: PropTypes.string,
249
- dataTestId: PropTypes.string,
250
- placeholder: PropTypes.string,
251
- required: PropTypes.bool,
252
- disabled: PropTypes.bool,
253
- multiple: PropTypes.bool,
254
- error: PropTypes.bool,
255
- label: PropTypes.string,
256
- helperText: PropTypes.string,
257
- options: PropTypes.arrayOf(PropTypes.element),
258
- onChange: PropTypes.any,
259
- };
260
-
261
246
  export default AutoComplete;
@@ -1,6 +1,4 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
- import { withKnobs } from "@storybook/addon-knobs";
4
2
  import FeatherIcon from "feather-icons-react";
5
3
 
6
4
  import Button, { TextButton } from "./index";
@@ -8,16 +6,11 @@ import Button, { TextButton } from "./index";
8
6
  export default {
9
7
  title: "Button",
10
8
  component: Button,
11
- decorators: [withKnobs],
12
9
  };
13
10
 
14
11
  const Container = ({ className = "", children }) => (
15
12
  <div className={`qppds qpp-u-padding--16 ${className}`}>{children}</div>
16
13
  );
17
- Container.propTypes = {
18
- className: PropTypes.string,
19
- children: PropTypes.node,
20
- };
21
14
 
22
15
  export const Primary = () => (
23
16
  <div>
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
2
 
4
3
  const VARIANTS = [
5
4
  "secondary",
@@ -14,27 +13,42 @@ const VARIANTS = [
14
13
  ];
15
14
  const SIZES = ["big"];
16
15
 
16
+ /**
17
+ * @param {{
18
+ * children?: React.ReactNode,
19
+ * className?: string,
20
+ * href?: string,
21
+ * loading?: boolean,
22
+ * onClick?: () => void,
23
+ * size?: string | null,
24
+ * type?: string,
25
+ * variant?: string | null,
26
+ * [key: string]: any
27
+ * }} props
28
+ */
17
29
  const Button = ({
18
- children,
19
- className,
20
- href,
21
- loading,
22
- onClick,
23
- size,
24
- variant,
25
- type,
30
+ children = null,
31
+ className = "",
32
+ href = "",
33
+ loading = false,
34
+ onClick = () => null,
35
+ size = null,
36
+ type = "button",
37
+ variant = null,
26
38
  ...rest
27
39
  }) => {
28
40
  let btnClass = "qpp-c-button";
29
41
 
30
42
  if (VARIANTS.includes(variant)) {
31
- btnClass = btnClass.concat(" ", `qpp-c-button--${variant}`);
43
+ btnClass += ` qpp-c-button--${variant}`;
32
44
  }
45
+
33
46
  if (SIZES.includes(size)) {
34
- btnClass = btnClass.concat(" ", `qpp-c-button--${size}`);
47
+ btnClass += ` qpp-c-button--${size}`;
35
48
  }
49
+
36
50
  if (className) {
37
- btnClass = btnClass.concat(" ", className);
51
+ btnClass += ` ${className}`;
38
52
  }
39
53
 
40
54
  if (href) {
@@ -42,17 +56,18 @@ const Button = ({
42
56
  <a
43
57
  href={href}
44
58
  data-testid="ds-btn"
45
- className={btnClass || ""}
59
+ className={btnClass}
46
60
  onClick={onClick}
47
61
  >
48
62
  {children}
49
63
  </a>
50
64
  );
51
65
  }
66
+
52
67
  return (
53
68
  <button
54
69
  data-testid="ds-btn"
55
- className={btnClass || ""}
70
+ className={btnClass}
56
71
  onClick={onClick}
57
72
  disabled={loading}
58
73
  type={type}
@@ -63,38 +78,13 @@ const Button = ({
63
78
  );
64
79
  };
65
80
 
66
- Button.propTypes = {
67
- children: PropTypes.node,
68
- className: PropTypes.string,
69
- href: PropTypes.string,
70
- loading: PropTypes.bool,
71
- onClick: PropTypes.func,
72
- size: PropTypes.oneOf(SIZES),
73
- type: PropTypes.string,
74
- variant: PropTypes.oneOf(VARIANTS),
75
- };
76
-
77
- Button.defaultProps = {
78
- children: false,
79
- className: "",
80
- href: "",
81
- loading: false,
82
- onClick: () => null,
83
- size: null,
84
- type: "button",
85
- variant: null,
86
- };
87
-
81
+ /**
82
+ * @param {{
83
+ * className?: string
84
+ * } & React.ComponentProps<typeof Button>} props
85
+ */
88
86
  export const TextButton = ({ className = "", ...props }) => (
89
87
  <Button className={`qpp-c-button--text ${className}`} {...props} />
90
88
  );
91
89
 
92
- TextButton.propTypes = {
93
- className: PropTypes.string,
94
- };
95
-
96
- TextButton.defaultProps = {
97
- className: "",
98
- };
99
-
100
90
  export default Button;
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
2
  import TextField from "../TextField";
4
3
  import { Box } from "@mui/material";
5
4
  import { DatePicker } from "@mui/x-date-pickers/DatePicker";
@@ -7,7 +6,7 @@ import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
7
6
  import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
8
7
  import dayjs from "dayjs";
9
8
  import utc from "dayjs/plugin/utc";
10
- import { ReadOnlyTextField } from "../index";
9
+ import ReadOnlyTextField from "../ReadOnlyTextField";
11
10
 
12
11
  dayjs.extend(utc);
13
12
  dayjs.utc();
@@ -66,7 +65,7 @@ const DateField = ({
66
65
  {...rest}
67
66
  value={value ? dayjs.utc(value).format("MM/DD/YYYY") : "-"}
68
67
  />
69
- )
68
+ );
70
69
  }
71
70
 
72
71
  if (containerSx === undefined || containerSx === null) {
@@ -112,17 +111,5 @@ const DateField = ({
112
111
  </LocalizationProvider>
113
112
  );
114
113
  };
115
- DateField.propTypes = {
116
- label: PropTypes.string.isRequired,
117
- value: PropTypes.object,
118
- handleDateChange: PropTypes.func.isRequired,
119
- disabled: PropTypes.bool,
120
- id: PropTypes.string,
121
- error: PropTypes.bool,
122
- helperText: PropTypes.string,
123
- required: PropTypes.bool,
124
- containerSx: PropTypes.object,
125
- textFieldSx: PropTypes.object,
126
- };
127
114
 
128
115
  export default DateField;
@@ -1,41 +1,54 @@
1
1
  import React, { useState } from "react";
2
2
  import DateField from "./DateField";
3
- import { withKnobs } from "@storybook/addon-knobs";
4
3
 
5
4
  export default {
6
5
  title: "DateField",
7
6
  component: DateField,
8
- decorators: [withKnobs],
7
+ argTypes: {
8
+ label: { control: "text" },
9
+ disabled: { control: "boolean" },
10
+ value: { control: "text" },
11
+ },
9
12
  };
13
+
10
14
  export const DateFieldComponent = (args) => {
11
15
  const [value, setValue] = useState("");
16
+
12
17
  const handleDateChange = (e) => {
13
18
  console.log("Handle change triggered", e.target.value);
14
19
  setValue(e.target.value);
15
20
  };
21
+
16
22
  return (
17
23
  <div className="qpp-u-padding--16">
18
24
  <DateField
19
- label="Status Date"
20
- handleDateChange={handleDateChange}
25
+ {...args}
21
26
  value={value}
27
+ handleDateChange={handleDateChange}
22
28
  />
23
29
  </div>
24
30
  );
25
31
  };
26
32
 
33
+ DateFieldComponent.args = {
34
+ label: "Status Date",
35
+ disabled: false,
36
+ };
37
+
27
38
  export const DateFieldComponentDisabled = (args) => {
28
39
  const handleDateChange = (e) => {
29
40
  console.log("Handle change triggered", e.target.value);
30
41
  };
42
+
31
43
  return (
32
44
  <div className="qpp-u-padding--16">
33
- <DateField
34
- disabled
35
- label="Status Date"
36
- handleDateChange={handleDateChange}
37
- value="2023-10-01"
38
- />
45
+ <DateField {...args} handleDateChange={handleDateChange} />
39
46
  </div>
40
47
  );
41
48
  };
49
+
50
+ DateFieldComponentDisabled.args = {
51
+ label: "Status Date",
52
+ disabled: true,
53
+ value: "2023-10-01",
54
+ };
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
2
  import TextField from "../TextField";
4
3
  import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
5
4
  import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
@@ -8,7 +7,7 @@ import dayjs from "dayjs";
8
7
  import utc from "dayjs/plugin/utc";
9
8
 
10
9
  import { FormControl } from "@mui/material";
11
- import { ReadOnlyTextField } from "../index";
10
+ import ReadOnlyTextField from "../ReadOnlyTextField";
12
11
 
13
12
  dayjs.extend(utc);
14
13
  dayjs.utc();
@@ -58,11 +57,15 @@ const DateTimeField = ({
58
57
  return (
59
58
  <ReadOnlyTextField
60
59
  label={label}
61
- value={dateTimeValue ? dayjs.utc(dateTimeValue).format("MM/DD/YYYY hh:mm A") : "-"}
60
+ value={
61
+ dateTimeValue
62
+ ? dayjs.utc(dateTimeValue).format("MM/DD/YYYY hh:mm A")
63
+ : "-"
64
+ }
62
65
  id={id}
63
66
  size="small"
64
67
  />
65
- )
68
+ );
66
69
  }
67
70
  return (
68
71
  <FormControl>
@@ -89,12 +92,5 @@ const DateTimeField = ({
89
92
  </FormControl>
90
93
  );
91
94
  };
92
- DateTimeField.propTypes = {
93
- id: PropTypes.string,
94
- dateTimeValue: PropTypes.object,
95
- handleDateTimeChange: PropTypes.func.isRequired,
96
- label: PropTypes.string.isRequired,
97
- disabled: PropTypes.bool,
98
- };
99
95
 
100
96
  export default DateTimeField;
@@ -1,41 +1,51 @@
1
1
  import React, { useState } from "react";
2
2
  import DateTimeField from "./DateTimeField";
3
- import { withKnobs } from "@storybook/addon-knobs";
4
3
 
5
4
  export default {
6
5
  title: "DateTimeField",
7
6
  component: DateTimeField,
8
- decorators: [withKnobs],
7
+ argTypes: {
8
+ label: { control: "text" },
9
+ disabled: { control: "boolean" },
10
+ dateTimeValue: { control: "text" },
11
+ id: { control: "text" },
12
+ },
9
13
  };
10
14
 
11
15
  export const TimeDateFieldComponent = (args) => {
12
- const [value, setValue] = useState("");
16
+ const [value, setValue] = useState(args.dateTimeValue || "");
17
+
13
18
  const handleDateTimeChange = (e) => {
14
19
  setValue(e.target.value);
15
20
  };
21
+
16
22
  return (
17
23
  <div className="qpp-u-padding--16">
18
24
  <DateTimeField
19
- // disabled={true}
20
- id="status_date_time"
21
- label="Status Date/Time"
22
- handleDateTimeChange={handleDateTimeChange}
25
+ {...args}
23
26
  dateTimeValue={value}
27
+ handleDateTimeChange={handleDateTimeChange}
24
28
  />
25
29
  </div>
26
30
  );
27
31
  };
28
32
 
29
- export const TimeDateFieldComponentDisabled = (args) => {
30
- return (
31
- <div className="qpp-u-padding--16">
32
- <DateTimeField
33
- disabled={true}
34
- id="status_date_time"
35
- label="Status Date/Time"
36
- handleDateTimeChange={(e) => {}}
37
- dateTimeValue="2023-10-01T12:00:00Z"
38
- />
39
- </div>
40
- );
33
+ TimeDateFieldComponent.args = {
34
+ label: "Status Date/Time",
35
+ disabled: false,
36
+ id: "status_date_time",
37
+ dateTimeValue: "",
38
+ };
39
+
40
+ export const TimeDateFieldComponentDisabled = (args) => (
41
+ <div className="qpp-u-padding--16">
42
+ <DateTimeField {...args} handleDateTimeChange={() => {}} />
43
+ </div>
44
+ );
45
+
46
+ TimeDateFieldComponentDisabled.args = {
47
+ label: "Status Date/Time",
48
+ disabled: true,
49
+ id: "status_date_time",
50
+ dateTimeValue: "2023-10-01T12:00:00Z",
41
51
  };
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { InputLabel as MUIInputLabel } from "@mui/material";
3
- import PropTypes from "prop-types";
4
3
 
5
4
  const Label = ({ required, disabled, error, ...rest }) => {
6
5
  return (
@@ -45,9 +44,5 @@ const Label = ({ required, disabled, error, ...rest }) => {
45
44
  />
46
45
  );
47
46
  };
48
- Label.propTypes = {
49
- required: PropTypes.bool.isRequired,
50
- disabled: PropTypes.bool.isRequired,
51
- error: PropTypes.bool,
52
- };
47
+
53
48
  export default Label;
@@ -1,11 +1,14 @@
1
1
  import React, { useState } from "react";
2
2
  import Instant from "./index";
3
- import { withKnobs } from "@storybook/addon-knobs";
4
3
 
5
4
  export default {
6
5
  title: "Instant",
7
6
  component: Instant,
8
- decorators: [withKnobs],
7
+ argTypes: {
8
+ disabled: { control: "boolean" },
9
+ id: { control: "text" },
10
+ label: { control: "text" },
11
+ },
9
12
  };
10
13
 
11
14
  export const InstantComponent = (args) => {
@@ -13,16 +16,21 @@ export const InstantComponent = (args) => {
13
16
  const handleDateTimeChange = (v) => {
14
17
  setValue(v);
15
18
  };
19
+
16
20
  return (
17
21
  <div className="qpp-u-padding--16">
18
- <div> Date string: {value} </div>
22
+ <div>Date string: {value}</div>
19
23
  <Instant
20
- disabled={false}
21
- id="status_date_time"
22
- label="Status Date/Time"
24
+ {...args}
23
25
  handleDateTimeChange={handleDateTimeChange}
24
26
  dateTimeValue={value}
25
27
  />
26
28
  </div>
27
29
  );
28
30
  };
31
+
32
+ InstantComponent.args = {
33
+ disabled: false,
34
+ id: "status_date_time",
35
+ label: "Status Date/Time",
36
+ };
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
2
  import TextField from "../TextField";
4
3
  import { DatePicker } from "@mui/x-date-pickers/DatePicker";
5
4
  import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
@@ -249,19 +248,4 @@ const Instant = ({
249
248
  );
250
249
  };
251
250
 
252
- Instant.propTypes = {
253
- id: PropTypes.string,
254
- placeholder: PropTypes.string,
255
- disabled: PropTypes.bool,
256
- required: PropTypes.bool,
257
- dateTimeValue: PropTypes.any,
258
- handleDateTimeChange: PropTypes.function,
259
- textFieldSx: PropTypes.any,
260
- dateFieldSx: PropTypes.any,
261
- error: PropTypes.bool,
262
- helperText: PropTypes.string,
263
- datePickerProps: PropTypes.any,
264
- onBlur: PropTypes.any,
265
- };
266
-
267
251
  export default Instant;