@dxc-technology/halstack-react 0.0.0-e081e21 → 0.0.0-e1a279c

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 (137) hide show
  1. package/accordion/Accordion.d.ts +4 -0
  2. package/accordion/Accordion.js +12 -43
  3. package/accordion/types.d.ts +68 -0
  4. package/accordion/types.js +5 -0
  5. package/accordion-group/AccordionGroup.d.ts +7 -0
  6. package/accordion-group/AccordionGroup.js +58 -72
  7. package/accordion-group/types.d.ts +72 -0
  8. package/accordion-group/types.js +5 -0
  9. package/alert/Alert.stories.tsx +170 -0
  10. package/box/Box.d.ts +4 -0
  11. package/box/Box.js +9 -32
  12. package/box/Box.stories.tsx +132 -0
  13. package/box/types.d.ts +47 -0
  14. package/box/types.js +5 -0
  15. package/button/Button.d.ts +1 -1
  16. package/button/Button.js +7 -12
  17. package/button/Button.stories.tsx +244 -274
  18. package/button/types.d.ts +10 -10
  19. package/card/Card.d.ts +4 -0
  20. package/card/Card.js +13 -48
  21. package/card/types.d.ts +69 -0
  22. package/card/types.js +5 -0
  23. package/checkbox/Checkbox.stories.tsx +192 -0
  24. package/checkbox/types.d.ts +2 -3
  25. package/chip/Chip.stories.tsx +121 -0
  26. package/common/variables.js +30 -22
  27. package/date-input/DateInput.d.ts +4 -0
  28. package/date-input/DateInput.js +3 -38
  29. package/date-input/DateInput.stories.tsx +138 -0
  30. package/date-input/types.d.ts +100 -0
  31. package/date-input/types.js +5 -0
  32. package/dialog/Dialog.d.ts +4 -0
  33. package/dialog/Dialog.js +4 -23
  34. package/dialog/Dialog.stories.tsx +212 -0
  35. package/dialog/types.d.ts +43 -0
  36. package/dialog/types.js +5 -0
  37. package/dropdown/Dropdown.d.ts +4 -0
  38. package/dropdown/Dropdown.js +7 -40
  39. package/dropdown/types.d.ts +89 -0
  40. package/dropdown/types.js +5 -0
  41. package/footer/Footer.d.ts +4 -0
  42. package/footer/Footer.js +4 -35
  43. package/footer/Footer.stories.jsx +151 -0
  44. package/footer/types.d.ts +61 -0
  45. package/footer/types.js +5 -0
  46. package/header/Header.d.ts +7 -0
  47. package/header/Header.js +26 -28
  48. package/header/Icons.js +2 -27
  49. package/header/types.d.ts +45 -0
  50. package/header/types.js +5 -0
  51. package/link/Link.d.ts +3 -0
  52. package/link/Link.js +1 -23
  53. package/link/Link.stories.tsx +70 -0
  54. package/link/types.d.ts +74 -0
  55. package/link/types.js +5 -0
  56. package/number-input/NumberInput.d.ts +4 -0
  57. package/number-input/NumberInput.js +2 -44
  58. package/number-input/NumberInput.stories.tsx +115 -0
  59. package/number-input/types.d.ts +117 -0
  60. package/number-input/types.js +5 -0
  61. package/package.json +3 -3
  62. package/paginator/Paginator.stories.tsx +63 -0
  63. package/password-input/PasswordInput.d.ts +4 -0
  64. package/password-input/PasswordInput.js +2 -39
  65. package/password-input/PasswordInput.stories.tsx +131 -0
  66. package/password-input/types.d.ts +100 -0
  67. package/password-input/types.js +5 -0
  68. package/progress-bar/ProgressBar.d.ts +4 -0
  69. package/progress-bar/ProgressBar.js +3 -21
  70. package/progress-bar/ProgressBar.stories.jsx +58 -0
  71. package/progress-bar/types.d.ts +37 -0
  72. package/progress-bar/types.js +5 -0
  73. package/radio/Radio.d.ts +4 -0
  74. package/radio/Radio.js +3 -24
  75. package/radio/Radio.stories.tsx +192 -0
  76. package/radio/types.d.ts +54 -0
  77. package/radio/types.js +5 -0
  78. package/select/Select.stories.tsx +572 -0
  79. package/select/index.d.ts +4 -4
  80. package/sidenav/Sidenav.d.ts +9 -0
  81. package/sidenav/Sidenav.js +4 -13
  82. package/sidenav/types.d.ts +50 -0
  83. package/sidenav/types.js +5 -0
  84. package/slider/Slider.d.ts +4 -0
  85. package/slider/Slider.js +59 -82
  86. package/slider/Slider.stories.tsx +177 -0
  87. package/slider/types.d.ts +78 -0
  88. package/slider/types.js +5 -0
  89. package/spinner/Spinner.d.ts +4 -0
  90. package/spinner/Spinner.js +6 -23
  91. package/spinner/Spinner.stories.jsx +102 -0
  92. package/spinner/types.d.ts +32 -0
  93. package/spinner/types.js +5 -0
  94. package/switch/Switch.js +2 -2
  95. package/switch/Switch.stories.tsx +160 -0
  96. package/table/Table.d.ts +4 -0
  97. package/table/Table.stories.jsx +276 -0
  98. package/table/types.d.ts +21 -0
  99. package/table/types.js +5 -0
  100. package/tabs/Tabs.d.ts +4 -0
  101. package/tabs/Tabs.js +5 -53
  102. package/tabs/types.d.ts +71 -0
  103. package/tabs/types.js +5 -0
  104. package/tag/Tag.d.ts +4 -0
  105. package/tag/Tag.js +20 -35
  106. package/tag/Tag.stories.tsx +145 -0
  107. package/tag/types.d.ts +60 -0
  108. package/tag/types.js +5 -0
  109. package/text-input/index.d.ts +2 -2
  110. package/textarea/Textarea.stories.jsx +135 -0
  111. package/toggle-group/ToggleGroup.stories.tsx +178 -0
  112. package/wizard/Wizard.d.ts +4 -0
  113. package/wizard/Wizard.js +11 -51
  114. package/wizard/Wizard.stories.jsx +224 -0
  115. package/wizard/types.d.ts +64 -0
  116. package/wizard/types.js +5 -0
  117. package/accordion/index.d.ts +0 -28
  118. package/accordion-group/index.d.ts +0 -16
  119. package/box/index.d.ts +0 -25
  120. package/card/index.d.ts +0 -22
  121. package/date-input/index.d.ts +0 -95
  122. package/dialog/index.d.ts +0 -18
  123. package/dropdown/index.d.ts +0 -26
  124. package/footer/index.d.ts +0 -25
  125. package/header/index.d.ts +0 -25
  126. package/link/index.d.ts +0 -23
  127. package/number-input/index.d.ts +0 -113
  128. package/password-input/index.d.ts +0 -94
  129. package/progress-bar/index.d.ts +0 -18
  130. package/radio/index.d.ts +0 -23
  131. package/sidenav/index.d.ts +0 -13
  132. package/slider/index.d.ts +0 -29
  133. package/spinner/index.d.ts +0 -17
  134. package/table/index.d.ts +0 -13
  135. package/tabs/index.d.ts +0 -19
  136. package/tag/index.d.ts +0 -24
  137. package/wizard/index.d.ts +0 -18
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
13
 
16
14
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
@@ -31,10 +29,6 @@ var _dateFns = _interopRequireDefault(require("@date-io/date-fns"));
31
29
 
32
30
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
33
31
 
34
- var _propTypes = _interopRequireDefault(require("prop-types"));
35
-
36
- var _variables = require("../common/variables.js");
37
-
38
32
  var _useTheme = _interopRequireDefault(require("../useTheme.js"));
39
33
 
40
34
  var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
@@ -108,7 +102,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
108
102
  onChange === null || onChange === void 0 ? void 0 : onChange({
109
103
  value: newValue,
110
104
  error: null,
111
- date: newDate && newDate.toJSON() ? newDate : null
105
+ date: newDate !== null && newDate !== void 0 && newDate.toJSON() ? newDate : null
112
106
  });
113
107
  };
114
108
 
@@ -121,7 +115,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
121
115
  onChange === null || onChange === void 0 ? void 0 : onChange({
122
116
  value: newValue,
123
117
  error: inputError || invalidDateMessage,
124
- date: momentDate.isValid() ? momentDate._d : null
118
+ date: momentDate.isValid() ? momentDate.toDate() : null
125
119
  });
126
120
  };
127
121
 
@@ -133,7 +127,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
133
127
  onBlur === null || onBlur === void 0 ? void 0 : onBlur({
134
128
  value: value,
135
129
  error: inputError || invalidDateMessage,
136
- date: momentDate.isValid() ? momentDate._d : null
130
+ date: momentDate.isValid() ? momentDate.toDate() : null
137
131
  });
138
132
  };
139
133
 
@@ -361,36 +355,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
361
355
  }))))))));
362
356
  });
363
357
 
364
- var sizes = {
365
- medium: "360px",
366
- large: "480px",
367
- fillParent: "100%"
368
- };
369
-
370
358
  var StyledDPicker = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])([""])));
371
359
 
372
- DxcDateInput.propTypes = {
373
- label: _propTypes["default"].string,
374
- name: _propTypes["default"].string,
375
- value: _propTypes["default"].string,
376
- format: _propTypes["default"].string,
377
- helperText: _propTypes["default"].string,
378
- placeholder: _propTypes["default"].bool,
379
- clearable: _propTypes["default"].bool,
380
- disabled: _propTypes["default"].bool,
381
- optional: _propTypes["default"].bool,
382
- onChange: _propTypes["default"].func,
383
- onBlur: _propTypes["default"].func,
384
- error: _propTypes["default"].string,
385
- autocomplete: _propTypes["default"].string,
386
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
387
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
388
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
389
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
390
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
391
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
392
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
393
- tabIndex: _propTypes["default"].number
394
- };
395
360
  var _default = DxcDateInput;
396
361
  exports["default"] = _default;
@@ -0,0 +1,138 @@
1
+ import React from "react";
2
+ import { userEvent, within, fireEvent, screen } from "@storybook/testing-library";
3
+ import DxcDateInput from "./DateInput";
4
+ import Title from "../../.storybook/components/Title";
5
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
+ import { BackgroundColorProvider } from "../BackgroundColorContext";
7
+ import DarkContainer from "../../.storybook/components/DarkSection";
8
+
9
+ export default {
10
+ title: "Date input",
11
+ component: DxcDateInput,
12
+ };
13
+
14
+ export const Chromatic = () => (
15
+ <>
16
+ <ExampleContainer>
17
+ <Title title="Complete date input" theme="light" level={4} />
18
+ <DxcDateInput label="Date input" helperText="Help message" format="dd/mm/yy" placeholder optional />
19
+ </ExampleContainer>
20
+ <ExampleContainer>
21
+ <Title title="Disabled" theme="light" level={4} />
22
+ <DxcDateInput label="Disabled date input" helperText="Help message" value="06-04-2027" clearable disabled />
23
+ </ExampleContainer>
24
+ <ExampleContainer>
25
+ <Title title="Invalid" theme="light" level={4} />
26
+ <DxcDateInput label="Error date input" error="Error message." placeholder />
27
+ </ExampleContainer>
28
+ <ExampleContainer>
29
+ <Title title="Relation between icons" theme="light" level={4} />
30
+ <DxcDateInput label="Error date input" error="Error message." value="06-04-2027" clearable />
31
+ </ExampleContainer>
32
+ <BackgroundColorProvider color="#333333">
33
+ <DarkContainer>
34
+ <Title title="Dark" theme="dark" level={2} />
35
+ <ExampleContainer>
36
+ <Title title="Complete date input" theme="dark" level={4} />
37
+ <DxcDateInput label="Date input" helperText="Help message" format="yyyy/dd/mm" placeholder optional />
38
+ </ExampleContainer>
39
+ <ExampleContainer>
40
+ <Title title="Disabled" theme="dark" level={4} />
41
+ <DxcDateInput label="Disabled Date input" helperText="Help message" value="06-04-2027" clearable disabled />
42
+ </ExampleContainer>
43
+ <ExampleContainer>
44
+ <Title title="Invalid" theme="dark" level={4} />
45
+ <DxcDateInput label="Error date input" error="Error message." placeholder />
46
+ </ExampleContainer>
47
+ <ExampleContainer>
48
+ <Title title="Relation between icons" theme="dark" level={4} />
49
+ <DxcDateInput label="Error date input" value="06-04-2027" error="Error message." clearable />
50
+ </ExampleContainer>
51
+ </DarkContainer>
52
+ </BackgroundColorProvider>
53
+ <Title title="Margins" theme="light" level={2} />
54
+ <ExampleContainer>
55
+ <Title title="Xxsmall" theme="light" level={4} />
56
+ <DxcDateInput label="Xxsmall" margin="xxsmall" />
57
+ </ExampleContainer>
58
+ <ExampleContainer>
59
+ <Title title="Xsmall" theme="light" level={4} />
60
+ <DxcDateInput label="Xsmall" margin="xsmall" />
61
+ </ExampleContainer>
62
+ <ExampleContainer>
63
+ <Title title="Small" theme="light" level={4} />
64
+ <DxcDateInput label="Small" margin="small" />
65
+ </ExampleContainer>
66
+ <ExampleContainer>
67
+ <Title title="Medium" theme="light" level={4} />
68
+ <DxcDateInput label="Medium" margin="medium" />
69
+ </ExampleContainer>
70
+ <ExampleContainer>
71
+ <Title title="Large" theme="light" level={4} />
72
+ <DxcDateInput label="Large" margin="large" />
73
+ </ExampleContainer>
74
+ <ExampleContainer>
75
+ <Title title="Xlarge" theme="light" level={4} />
76
+ <DxcDateInput label="Xlarge" margin="xlarge" />
77
+ </ExampleContainer>
78
+ <ExampleContainer>
79
+ <Title title="Xxlarge" theme="light" level={4} />
80
+ <DxcDateInput label="Xxlarge" margin="xxlarge" />
81
+ </ExampleContainer>
82
+ <Title title="Sizes" theme="light" level={2} />
83
+ <ExampleContainer>
84
+ <Title title="Medium size" theme="light" level={4} />
85
+ <DxcDateInput label="Medium" size="medium" />
86
+ </ExampleContainer>
87
+ <ExampleContainer>
88
+ <Title title="Large size" theme="light" level={4} />
89
+ <DxcDateInput label="Large" size="large" />
90
+ </ExampleContainer>
91
+ <ExampleContainer>
92
+ <Title title="FillParent size" theme="light" level={4} />
93
+ <DxcDateInput label="FillParent" size="fillParent" />
94
+ </ExampleContainer>
95
+ </>
96
+ );
97
+
98
+ const DatePicker = () => (
99
+ <ExampleContainer expanded>
100
+ <Title title="Show date input" theme="light" level={4} />
101
+ <DxcDateInput label="Date input" value="10-06-2023" />
102
+ </ExampleContainer>
103
+ );
104
+
105
+ export const ShowDatePicker = DatePicker.bind({});
106
+ ShowDatePicker.play = async ({ canvasElement }) => {
107
+ const canvas = within(canvasElement);
108
+ const dateBtn = canvas.getByRole("button");
109
+ await userEvent.click(dateBtn);
110
+ await userEvent.tab();
111
+ };
112
+
113
+ const YearPicker = () => (
114
+ <ExampleContainer expanded>
115
+ <Title title="Show date input" theme="light" level={4} />
116
+ <DxcDateInput label="Date input" value="10-06-2023" />
117
+ </ExampleContainer>
118
+ );
119
+
120
+ export const ShowYearPicker = YearPicker.bind({});
121
+ ShowYearPicker.play = async () => {
122
+ await fireEvent.click(screen.getByRole("button"));
123
+ await fireEvent.click(screen.getByText("2023"));
124
+ };
125
+
126
+ const YearPickerFocus = () => (
127
+ <ExampleContainer expanded>
128
+ <Title title="Show date input" theme="light" level={4} />
129
+ <DxcDateInput label="Date input" value="10-06-2023" />
130
+ </ExampleContainer>
131
+ );
132
+
133
+ export const ShowYearPickerFocus = YearPickerFocus.bind({});
134
+ ShowYearPickerFocus.play = async () => {
135
+ await fireEvent.click(screen.getByRole("button"));
136
+ await fireEvent.click(screen.getByText("2023"));
137
+ await screen.getByText("2021").focus();
138
+ };
@@ -0,0 +1,100 @@
1
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
+ declare type Margin = {
3
+ top?: Space;
4
+ bottom?: Space;
5
+ left?: Space;
6
+ right?: Space;
7
+ };
8
+ declare type Props = {
9
+ /**
10
+ * Text to be placed above the date.
11
+ */
12
+ label?: string;
13
+ /**
14
+ * Name attribute of the input element.
15
+ */
16
+ name?: string;
17
+ /**
18
+ * Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
19
+ */
20
+ value?: string;
21
+ /**
22
+ * The format in which the date value will be displayed. User must use this format when editing the value or it will be considered as an invalid date.
23
+ */
24
+ format?: string;
25
+ /**
26
+ * Helper text to be placed above the date.
27
+ */
28
+ helperText?: string;
29
+ /**
30
+ * If true, the date format will appear as placeholder in the field.
31
+ */
32
+ placeholder?: boolean;
33
+ /**
34
+ * If true, the date input will have an action to clear the entered value.
35
+ */
36
+ clearable?: boolean;
37
+ /**
38
+ * If true, the component will be disabled.
39
+ */
40
+ disabled?: boolean;
41
+ /**
42
+ * If true, the date will be optional, showing '(Optional)'
43
+ * next to the label. Otherwise, the field will be considered required and an error will be
44
+ * passed as a parameter to the OnBlur and onChange functions when it has
45
+ * not been filled.
46
+ */
47
+ optional?: boolean;
48
+ /**
49
+ * This function will be called when the user types within the input
50
+ * element of the component. An object including the string value, the
51
+ * error and the date value will be passed to this function.
52
+ * If the string value is a valid date, error will
53
+ * be null. Also, if the string value is not a valid date, date will be null.
54
+ */
55
+ onChange?: (val: {
56
+ value: string;
57
+ error: string | null;
58
+ date: Date | null;
59
+ }) => void;
60
+ /**
61
+ * This function will be called when the input element loses the focus.
62
+ * An object including the string value, the error and the date value
63
+ * will be passed to this function. If the string value is a valid date, error will
64
+ * be null. Also, if the string value is not a valid date, date will be null.
65
+ */
66
+ onBlur?: (val: {
67
+ value: string;
68
+ error: string | null;
69
+ date: Date | null;
70
+ }) => void;
71
+ /**
72
+ * If it is defined, the component will change its appearance, showing
73
+ * the error below the date input component. If it is not defined, the error
74
+ * messages will be managed internally, but never displayed on its own.
75
+ */
76
+ error?: string;
77
+ /**
78
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
79
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
80
+ */
81
+ autocomplete?: string;
82
+ /**
83
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
84
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
85
+ */
86
+ margin?: Space | Margin;
87
+ /**
88
+ * Size of the component.
89
+ */
90
+ size?: "medium" | "large" | "fillParent";
91
+ /**
92
+ * Value of the tabindex attribute.
93
+ */
94
+ tabIndex?: number;
95
+ };
96
+ /**
97
+ * Reference to the component.
98
+ */
99
+ export declare type RefType = HTMLDivElement;
100
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import DialogPropsType from "./types";
3
+ declare const DxcDialog: ({ isCloseVisible, onCloseClick, children, overlay, onBackgroundClick, padding, tabIndex, }: DialogPropsType) => JSX.Element;
4
+ export default DxcDialog;
package/dialog/Dialog.js CHANGED
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports["default"] = void 0;
11
11
 
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
13
 
16
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
@@ -23,8 +21,6 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
21
 
24
22
  var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
25
23
 
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
24
  var _variables = require("../common/variables.js");
29
25
 
30
26
  var _useTheme = _interopRequireDefault(require("../useTheme.js"));
@@ -49,7 +45,7 @@ var DxcDialog = function DxcDialog(_ref) {
49
45
  _ref$tabIndex = _ref.tabIndex,
50
46
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
51
47
 
52
- var _useState = (0, _react.useState)(),
48
+ var _useState = (0, _react.useState)(false),
53
49
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
54
50
  isResponsive = _useState2[0],
55
51
  setIsResponsive = _useState2[1];
@@ -57,15 +53,15 @@ var DxcDialog = function DxcDialog(_ref) {
57
53
  var colorsTheme = (0, _useTheme["default"])();
58
54
 
59
55
  var handleClose = function handleClose() {
60
- typeof onCloseClick === "function" && onCloseClick();
56
+ onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
61
57
  };
62
58
 
63
59
  var handleOverlayClick = function handleOverlayClick() {
64
- typeof onBackgroundClick === "function" && onBackgroundClick();
60
+ onBackgroundClick === null || onBackgroundClick === void 0 ? void 0 : onBackgroundClick();
65
61
  };
66
62
 
67
63
  var handleResize = function handleResize(width) {
68
- width && width <= _variables.responsiveSizes.tablet ? setIsResponsive(true) : setIsResponsive(false);
64
+ setIsResponsive(width && width <= _variables.responsiveSizes.tablet);
69
65
  };
70
66
 
71
67
  var handleEventListener = function handleEventListener() {
@@ -165,20 +161,5 @@ var CloseIcon = _styledComponents["default"].svg(_templateObject4 || (_templateO
165
161
  return props.theme.closeIconBorderColor;
166
162
  });
167
163
 
168
- DxcDialog.propTypes = {
169
- padding: _propTypes["default"].oneOfType([_propTypes["default"].shape({
170
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
171
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
172
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
173
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
174
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
175
- isVisible: _propTypes["default"].bool,
176
- isCloseVisible: _propTypes["default"].bool,
177
- onClose: _propTypes["default"].func,
178
- onCloseClick: _propTypes["default"].func,
179
- onBackgroundClick: _propTypes["default"].func,
180
- overlay: _propTypes["default"].bool,
181
- tabIndex: _propTypes["default"].number
182
- };
183
164
  var _default = DxcDialog;
184
165
  exports["default"] = _default;
@@ -0,0 +1,212 @@
1
+ import React from "react";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
+ import DxcDialog from "./Dialog";
4
+ import Title from "../../.storybook/components/Title";
5
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
+
7
+ export default {
8
+ title: "Dialog ",
9
+ component: DxcDialog,
10
+ };
11
+
12
+ export const DefaultDialog = () => (
13
+ <>
14
+ <ExampleContainer expanded={true}>
15
+ <Title title="Default dialog" theme="light" level={4} />
16
+ <DxcDialog>
17
+ {" "}
18
+ <p>
19
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
20
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
21
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
22
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
23
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
24
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
25
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
26
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
27
+ dignissim, pharetra neque molestie, molestie lectus.
28
+ </p>{" "}
29
+ </DxcDialog>
30
+ </ExampleContainer>
31
+ </>
32
+ );
33
+
34
+ export const DialogWithoutOverlay = () => (
35
+ <ExampleContainer expanded={true}>
36
+ <Title title="Dialog Without Overlay" theme="light" level={4} />
37
+ <DxcDialog overlay={false}>
38
+ {" "}
39
+ <p>
40
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
41
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
42
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
43
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
44
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
45
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
46
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
47
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
48
+ dignissim, pharetra neque molestie, molestie lectus.
49
+ </p>{" "}
50
+ </DxcDialog>
51
+ </ExampleContainer>
52
+ );
53
+
54
+ export const DialogCloseVisibleFalse = () => (
55
+ <ExampleContainer expanded={true}>
56
+ <Title title="Dialog Close Visible" theme="dark" level={4} />
57
+ <DxcDialog isCloseVisible={false}>
58
+ {" "}
59
+ <p>
60
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
61
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
62
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
63
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
64
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
65
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
66
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
67
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
68
+ dignissim, pharetra neque molestie, molestie lectus.
69
+ </p>{" "}
70
+ </DxcDialog>
71
+ </ExampleContainer>
72
+ );
73
+
74
+ export const DialogWithXxsmallPadding = () => (
75
+ <ExampleContainer expanded={true}>
76
+ <Title title="Dialog With Xxsmall Padding" theme="light" level={4} />
77
+ <DxcDialog padding={"xxsmall"}>
78
+ {" "}
79
+ <p>
80
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
81
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
82
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
83
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
84
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
85
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
86
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
87
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
88
+ dignissim, pharetra neque molestie, molestie lectus.
89
+ </p>{" "}
90
+ </DxcDialog>
91
+ </ExampleContainer>
92
+ );
93
+
94
+ export const DialogWithXsmallPadding = () => (
95
+ <ExampleContainer expanded={true}>
96
+ <Title title="Dialog With Xsmall Padding" theme="light" level={4} />
97
+ <DxcDialog padding={"xsmall"}>
98
+ {" "}
99
+ <p>
100
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
101
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
102
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
103
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
104
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
105
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
106
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
107
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
108
+ dignissim, pharetra neque molestie, molestie lectus.
109
+ </p>{" "}
110
+ </DxcDialog>
111
+ </ExampleContainer>
112
+ );
113
+
114
+ export const DialogWithSmallPadding = () => (
115
+ <ExampleContainer expanded={true}>
116
+ <Title title="Dialog With Small Padding" theme="light" level={4} />
117
+ <DxcDialog padding={"small"}>
118
+ {" "}
119
+ <p>
120
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
121
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
122
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
123
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
124
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
125
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
126
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
127
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
128
+ dignissim, pharetra neque molestie, molestie lectus.
129
+ </p>{" "}
130
+ </DxcDialog>
131
+ </ExampleContainer>
132
+ );
133
+
134
+ export const DialogWithMediumPadding = () => (
135
+ <ExampleContainer expanded={true}>
136
+ <Title title="Dialog With Medium Padding" theme="light" level={4} />
137
+ <DxcDialog padding={"medium"}>
138
+ {" "}
139
+ <p>
140
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
141
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
142
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
143
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
144
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
145
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
146
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
147
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
148
+ dignissim, pharetra neque molestie, molestie lectus.
149
+ </p>{" "}
150
+ </DxcDialog>
151
+ </ExampleContainer>
152
+ );
153
+
154
+ export const DialogWithLargePadding = () => (
155
+ <ExampleContainer expanded={true}>
156
+ <Title title="Dialog With Large Padding" theme="light" level={4} />
157
+ <DxcDialog padding={"large"}>
158
+ {" "}
159
+ <p>
160
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
161
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
162
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
163
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
164
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
165
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
166
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
167
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
168
+ dignissim, pharetra neque molestie, molestie lectus.
169
+ </p>{" "}
170
+ </DxcDialog>
171
+ </ExampleContainer>
172
+ );
173
+
174
+ export const DialogWithXlargePadding = () => (
175
+ <ExampleContainer expanded={true}>
176
+ <Title title="Dialog With Xlarge Padding" theme="light" level={4} />
177
+ <DxcDialog padding={"xlarge"}>
178
+ {" "}
179
+ <p>
180
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
181
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
182
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
183
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
184
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
185
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
186
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
187
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
188
+ dignissim, pharetra neque molestie, molestie lectus.
189
+ </p>{" "}
190
+ </DxcDialog>
191
+ </ExampleContainer>
192
+ );
193
+
194
+ export const DialogWithXxlargePadding = () => (
195
+ <ExampleContainer expanded={true}>
196
+ <Title title="Dialog With Xxlarge Padding" theme="light" level={4} />
197
+ <DxcDialog padding={"xxlarge"}>
198
+ {" "}
199
+ <p>
200
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
201
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
202
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
203
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
204
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida
205
+ enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu,
206
+ fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
207
+ augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
208
+ dignissim, pharetra neque molestie, molestie lectus.
209
+ </p>{" "}
210
+ </DxcDialog>
211
+ </ExampleContainer>
212
+ );
@@ -0,0 +1,43 @@
1
+ /// <reference types="react" />
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Padding = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ declare type Props = {
10
+ /**
11
+ * If true, the close 'x' button will be visible.
12
+ */
13
+ isCloseVisible?: boolean;
14
+ /**
15
+ * This function will be called when the user clicks the close 'x' button.
16
+ * The responsibility of hiding the modal lies with the user.
17
+ */
18
+ onCloseClick?: () => void;
19
+ /**
20
+ * If true, the dialog will be displayed over a darker background that covers the content behind.
21
+ */
22
+ overlay?: boolean;
23
+ /**
24
+ * This function will be called when the user clicks background of the modal.
25
+ * The responsibility of hiding the modal lies with the user.
26
+ */
27
+ onBackgroundClick?: () => void;
28
+ /**
29
+ * Size of the padding to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
30
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
31
+ */
32
+ padding?: Padding | Space;
33
+ /**
34
+ * Value of the tabindex given to the close 'x' button.
35
+ */
36
+ tabIndex?: number;
37
+ /**
38
+ * The area inside the dialog. This area can be used to render
39
+ * custom content.
40
+ */
41
+ children: React.ReactNode;
42
+ };
43
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });