@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
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import AccordionPropsType from "./types";
3
+ declare const DxcAccordion: ({ label, isExpanded, iconSrc, icon, assistiveText, disabled, onChange, children, margin, padding, tabIndex, }: AccordionPropsType) => JSX.Element;
4
+ export default DxcAccordion;
@@ -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 _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -29,8 +27,6 @@ var _ExpansionPanelDetails = _interopRequireDefault(require("@material-ui/core/E
29
27
 
30
28
  var _ExpandMore = _interopRequireDefault(require("@material-ui/icons/ExpandMore"));
31
29
 
32
- var _propTypes = _interopRequireDefault(require("prop-types"));
33
-
34
30
  var _utils = require("../common/utils.js");
35
31
 
36
32
  var _variables = require("../common/variables.js");
@@ -48,38 +44,34 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
48
44
  var DxcAccordion = function DxcAccordion(_ref) {
49
45
  var _ref$label = _ref.label,
50
46
  label = _ref$label === void 0 ? "" : _ref$label,
51
- _ref$iconSrc = _ref.iconSrc,
52
- iconSrc = _ref$iconSrc === void 0 ? "" : _ref$iconSrc,
47
+ isExpanded = _ref.isExpanded,
48
+ iconSrc = _ref.iconSrc,
53
49
  icon = _ref.icon,
54
50
  _ref$assistiveText = _ref.assistiveText,
55
51
  assistiveText = _ref$assistiveText === void 0 ? "" : _ref$assistiveText,
56
52
  _ref$disabled = _ref.disabled,
57
53
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
58
- _ref$onChange = _ref.onChange,
59
- onChange = _ref$onChange === void 0 ? "" : _ref$onChange,
60
- isExpanded = _ref.isExpanded,
54
+ onChange = _ref.onChange,
61
55
  children = _ref.children,
62
56
  margin = _ref.margin,
63
57
  padding = _ref.padding,
64
58
  _ref$tabIndex = _ref.tabIndex,
65
59
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
66
60
 
67
- var _React$useState = _react["default"].useState(false),
68
- _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
69
- innerIsExpanded = _React$useState2[0],
70
- setInnerIsExpanded = _React$useState2[1];
71
-
72
- var _useState = (0, _react.useState)(),
61
+ var _useState = (0, _react.useState)(false),
73
62
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
74
- isResponsive = _useState2[0],
75
- setIsResponsive = _useState2[1];
63
+ innerIsExpanded = _useState2[0],
64
+ setInnerIsExpanded = _useState2[1];
65
+
66
+ var _useState3 = (0, _react.useState)(false),
67
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
68
+ isResponsive = _useState4[0],
69
+ setIsResponsive = _useState4[1];
76
70
 
77
71
  var colorsTheme = (0, _useTheme["default"])();
78
72
 
79
73
  var handleResize = function handleResize(width) {
80
- if (width) {
81
- if (width <= _variables.responsiveSizes.tablet ? setIsResponsive(true) : setIsResponsive(false)) ;
82
- }
74
+ width && width <= _variables.responsiveSizes.tablet ? setIsResponsive(true) : setIsResponsive(false);
83
75
  };
84
76
 
85
77
  var handleEventListener = function handleEventListener() {
@@ -262,28 +254,5 @@ var AccordionIcon = _styledComponents["default"].img(_templateObject7 || (_templ
262
254
  return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
263
255
  });
264
256
 
265
- DxcAccordion.propTypes = {
266
- label: _propTypes["default"].string,
267
- iconSrc: _propTypes["default"].string,
268
- icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
269
- assistiveText: _propTypes["default"].string,
270
- disabled: _propTypes["default"].bool,
271
- onChange: _propTypes["default"].func,
272
- isExpanded: _propTypes["default"].bool,
273
- children: _propTypes["default"].element,
274
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
275
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
276
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
277
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
278
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
279
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
280
- padding: _propTypes["default"].oneOfType([_propTypes["default"].shape({
281
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
282
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
283
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
284
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
285
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
286
- tabIndex: _propTypes["default"].number
287
- };
288
257
  var _default = DxcAccordion;
289
258
  exports["default"] = _default;
@@ -0,0 +1,68 @@
1
+ /// <reference types="react" />
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ declare type Padding = {
10
+ top?: Space;
11
+ bottom?: Space;
12
+ left?: Space;
13
+ right?: Space;
14
+ };
15
+ declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
16
+ declare type Props = {
17
+ /**
18
+ * The panel label.
19
+ */
20
+ label?: string;
21
+ /**
22
+ * Represents the state of the panel. When true, the component will be
23
+ * expanded. If undefined, the component will be uncontrolled and its
24
+ * value will be managed internally by the component.
25
+ */
26
+ isExpanded?: boolean;
27
+ /**
28
+ * Element used as the icon that will be placed next to panel label.
29
+ */
30
+ icon?: SVG;
31
+ /**
32
+ * @deprecated URL of the icon that will be placed next to panel label.
33
+ */
34
+ iconSrc?: string;
35
+ /**
36
+ * Assistive text to be placed on the right side of the panel.
37
+ */
38
+ assistiveText?: string;
39
+ /**
40
+ * If true, the component will be disabled.
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * This function will be called when the user clicks the accordion to expand or collapse
45
+ * the panel. The new state of the panel will be passed as a parameter.
46
+ */
47
+ onChange?: (isExpanded: boolean) => void;
48
+ /**
49
+ * The expanded panel of the accordion. This area can be used to render
50
+ * custom content.
51
+ */
52
+ children: React.ReactNode;
53
+ /**
54
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
55
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
56
+ */
57
+ margin?: Space | Margin;
58
+ /**
59
+ * Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
60
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
61
+ */
62
+ padding?: Space | Padding;
63
+ /**
64
+ * Value of the tabindex.
65
+ */
66
+ tabIndex?: number;
67
+ };
68
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import AccordionGroupPropsType, { AccordionPropsType } from "./types";
3
+ declare const DxcAccordionGroup: {
4
+ ({ indexActive, disabled, onActiveChange, margin, children, }: AccordionGroupPropsType): JSX.Element;
5
+ Accordion: ({ ...childProps }: AccordionPropsType) => JSX.Element;
6
+ };
7
+ export default DxcAccordionGroup;
@@ -9,22 +9,20 @@ 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"));
17
15
 
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+
18
18
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
19
 
20
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
20
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
21
21
 
22
22
  var _react = _interopRequireWildcard(require("react"));
23
23
 
24
24
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
25
25
 
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
26
  var _Accordion = _interopRequireDefault(require("../accordion/Accordion"));
29
27
 
30
28
  var _utils = require("../common/utils.js");
@@ -35,46 +33,61 @@ var _useTheme = _interopRequireDefault(require("../useTheme.js"));
35
33
 
36
34
  var _templateObject;
37
35
 
38
- var _excluded = ["margin"];
39
-
40
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
37
 
42
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
39
 
44
- var Accordion = function Accordion(_ref) {
45
- var margin = _ref.margin,
46
- childProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
47
- return /*#__PURE__*/_react["default"].createElement(_Accordion["default"], childProps, childProps.children);
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
+
44
+ var AccordionGroupAccordionContext = /*#__PURE__*/(0, _react.createContext)(null);
45
+
46
+ var AccordionGroupAccordion = function AccordionGroupAccordion(_ref) {
47
+ var childProps = (0, _extends2["default"])({}, _ref);
48
+
49
+ var _useContext = (0, _react.useContext)(AccordionGroupAccordionContext),
50
+ innerIsExpanded = _useContext.innerIsExpanded,
51
+ handlerActiveChange = _useContext.handlerActiveChange,
52
+ disabled = _useContext.disabled,
53
+ index = _useContext.index;
54
+
55
+ return /*#__PURE__*/_react["default"].createElement(_Accordion["default"], (0, _extends2["default"])({
56
+ isExpanded: innerIsExpanded === index,
57
+ onChange: function onChange() {
58
+ handlerActiveChange(index);
59
+ },
60
+ disabled: disabled
61
+ }, childProps), childProps.children);
48
62
  };
49
63
 
50
64
  var DxcAccordionGroup = function DxcAccordionGroup(_ref2) {
51
- var _ref2$disabled = _ref2.disabled,
65
+ var indexActive = _ref2.indexActive,
66
+ _ref2$disabled = _ref2.disabled,
52
67
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
53
68
  onActiveChange = _ref2.onActiveChange,
54
- _ref2$indexActive = _ref2.indexActive,
55
- indexActive = _ref2$indexActive === void 0 ? undefined : _ref2$indexActive,
56
69
  margin = _ref2.margin,
57
- _ref2$children = _ref2.children,
58
- children = _ref2$children === void 0 ? [] : _ref2$children;
70
+ children = _ref2.children;
59
71
  var colorsTheme = (0, _useTheme["default"])();
60
72
 
61
- var _React$useState = _react["default"].useState(indexActive),
62
- _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
63
- innerIsExpanded = _React$useState2[0],
64
- setInnerIsExpanded = _React$useState2[1];
65
-
66
- var handlerActiveChange = function handlerActiveChange(index) {
67
- if (indexActive === undefined) {
68
- setInnerIsExpanded(index === innerIsExpanded ? -1 : index);
69
- } else {
70
- setInnerIsExpanded(indexActive);
71
- }
72
-
73
- if (typeof onActiveChange === "function" && !disabled) {
74
- onActiveChange(index);
75
- }
76
- };
77
-
73
+ var _useState = (0, _react.useState)(0),
74
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
75
+ innerIsExpanded = _useState2[0],
76
+ setInnerIsExpanded = _useState2[1];
77
+
78
+ var handlerActiveChange = (0, _react.useCallback)(function (index) {
79
+ indexActive === undefined ? setInnerIsExpanded(function (prev) {
80
+ return index === prev ? -1 : index;
81
+ }) : setInnerIsExpanded(indexActive);
82
+ !disabled && (onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(index));
83
+ }, [disabled, indexActive, onActiveChange]);
84
+ var value = (0, _react.useMemo)(function () {
85
+ return {
86
+ innerIsExpanded: innerIsExpanded,
87
+ handlerActiveChange: handlerActiveChange,
88
+ disabled: disabled
89
+ };
90
+ }, [innerIsExpanded, disabled]);
78
91
  (0, _react.useEffect)(function () {
79
92
  setInnerIsExpanded(indexActive);
80
93
  }, [indexActive]);
@@ -83,24 +96,24 @@ var DxcAccordionGroup = function DxcAccordionGroup(_ref2) {
83
96
  }, /*#__PURE__*/_react["default"].createElement(AccordionGroupContainer, {
84
97
  margin: margin,
85
98
  disabled: disabled
86
- }, (Array.isArray(children) ? children : [children]).filter(function (el) {
87
- return el.type === Accordion;
88
- }).map(function (el, index) {
89
- return /*#__PURE__*/_react["default"].cloneElement(el, {
90
- onChange: function onChange() {
91
- handlerActiveChange(index);
92
- },
93
- isExpanded: index === innerIsExpanded,
94
- disabled: disabled || el.props.disabled
95
- });
99
+ }, (Array.isArray(children) ? children : [children]).filter(function (child) {
100
+ return child.type === AccordionGroupAccordion;
101
+ }).map(function (accordion, index) {
102
+ return /*#__PURE__*/_react["default"].createElement(AccordionGroupAccordionContext.Provider, {
103
+ value: _objectSpread({
104
+ index: index
105
+ }, value)
106
+ }, accordion);
96
107
  })));
97
108
  };
98
109
 
110
+ DxcAccordionGroup.Accordion = AccordionGroupAccordion;
111
+
99
112
  var calculateWidth = function calculateWidth(margin) {
100
113
  return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
101
114
  };
102
115
 
103
- var AccordionGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n cursor: ", ";\n\n & > :not(div:last-child) {\n & > div:first-child {\n border-radius: 0;\n border-bottom: ", ";\n border-color: ", ";\n\n & > .Mui-expanded {\n border-radius: 0;\n }\n\n & > .MuiButtonBase-root {\n border-radius: 0;\n }\n }\n }\n\n & > div:first-child {\n & > div:first-child {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom: ", ";\n border-color: ", ";\n\n & > .Mui-expanded {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n }\n\n & > .MuiButtonBase-root {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n }\n }\n }\n\n & > div:last-child {\n & > div:first-child {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n\n & > .Mui-expanded {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n\n & > .MuiButtonBase-root {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n }\n }\n"])), function (props) {
116
+ var AccordionGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n cursor: ", ";\n\n & > :not(div:last-child) {\n & > div:first-child {\n border-radius: 0;\n border-bottom: ", ";\n border-color: ", ";\n\n & > .Mui-expanded {\n border-radius: 0;\n }\n & > .MuiButtonBase-root {\n border-radius: 0;\n }\n }\n }\n\n & > div:first-child {\n & > div:first-child {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom: ", ";\n border-color: ", ";\n\n & > .Mui-expanded {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n }\n & > .MuiButtonBase-root {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n border-top-left-radius: ", ";\n border-top-right-radius: ", ";\n }\n }\n }\n\n & > div:last-child {\n & > div:first-child {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n\n & > .Mui-expanded {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n & > .MuiButtonBase-root {\n border-bottom-left-radius: ", ";\n border-bottom-right-radius: ", ";\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n }\n }\n"])), function (props) {
104
117
  return calculateWidth(props.margin);
105
118
  }, function (_ref3) {
106
119
  var margin = _ref3.margin;
@@ -118,7 +131,7 @@ var AccordionGroupContainer = _styledComponents["default"].div(_templateObject |
118
131
  var margin = _ref7.margin;
119
132
  return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
120
133
  }, function (props) {
121
- return props.disabled && "not-allowed" || "pointer";
134
+ return props.disabled ? "not-allowed" : "pointer";
122
135
  }, function (props) {
123
136
  return "".concat(props.theme.accordionGroupSeparatorBorderThickness, " ").concat(props.theme.accordionGroupSeparatorBorderStyle);
124
137
  }, function (props) {
@@ -153,32 +166,5 @@ var AccordionGroupContainer = _styledComponents["default"].div(_templateObject |
153
166
  return props.theme.borderRadius;
154
167
  });
155
168
 
156
- DxcAccordionGroup.propTypes = {
157
- disabled: _propTypes["default"].bool,
158
- onActiveChange: _propTypes["default"].func,
159
- indexActive: _propTypes["default"].number,
160
- children: _propTypes["default"].arrayOf(_propTypes["default"].shape({
161
- label: _propTypes["default"].string,
162
- icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
163
- iconSrc: _propTypes["default"].string,
164
- iconPosition: _propTypes["default"].oneOf(["before", "after"]),
165
- assistiveText: _propTypes["default"].string,
166
- disabled: _propTypes["default"].bool,
167
- children: _propTypes["default"].element,
168
- padding: _propTypes["default"].oneOfType([_propTypes["default"].shape({
169
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
170
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
171
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
172
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
173
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))])
174
- })),
175
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
176
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
177
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
178
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
179
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
180
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))])
181
- };
182
- DxcAccordionGroup.Accordion = Accordion;
183
169
  var _default = DxcAccordionGroup;
184
170
  exports["default"] = _default;
@@ -0,0 +1,72 @@
1
+ /// <reference types="react" />
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ declare type Padding = {
10
+ top?: Space;
11
+ bottom?: Space;
12
+ left?: Space;
13
+ right?: Space;
14
+ };
15
+ declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
16
+ export declare type AccordionPropsType = {
17
+ /**
18
+ * The panel label.
19
+ */
20
+ label?: string;
21
+ /**
22
+ * Element used as the icon that will be placed next to panel label.
23
+ */
24
+ icon?: SVG;
25
+ /**
26
+ * @deprecated URL of the icon that will be placed next to panel label.
27
+ */
28
+ iconSrc?: string;
29
+ /**
30
+ * Assistive text to be placed on the right side of the panel.
31
+ */
32
+ assistiveText?: string;
33
+ /**
34
+ * If true, the component will be disabled.
35
+ */
36
+ disabled?: boolean;
37
+ /**
38
+ * Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
39
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
40
+ */
41
+ padding?: Space | Padding;
42
+ /**
43
+ * The expanded panel of the accordion. This area can be used to render
44
+ * custom content.
45
+ */
46
+ children: React.ReactNode;
47
+ };
48
+ declare type Props = {
49
+ /**
50
+ * The index of the active accordion. If undefined, the component will be uncontrolled and the active accordion will be managed internally by the component.
51
+ * If null, the component will be controlled and all accordions will be closed.
52
+ */
53
+ indexActive?: number;
54
+ /**
55
+ * If true, the component will be disabled.
56
+ */
57
+ disabled?: boolean;
58
+ /**
59
+ * This function will be called when the user clicks on an accordion. The index of the clicked accordion will be passed as a parameter.
60
+ */
61
+ onActiveChange?: (indexActive: number) => void;
62
+ /**
63
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
64
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
65
+ */
66
+ margin?: Space | Margin;
67
+ /**
68
+ * Customized accordion(s) that are allowed inside an Accordion Group.
69
+ */
70
+ children: React.ReactElement<AccordionPropsType>[] | React.ReactElement<AccordionPropsType>;
71
+ };
72
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,170 @@
1
+ import React from "react";
2
+ import DxcAlert from "./Alert";
3
+ import Title from "../../.storybook/components/Title";
4
+ import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+
6
+ export default {
7
+ title: "Alert",
8
+ component: DxcAlert,
9
+ };
10
+
11
+ export const Chromatic = () => (
12
+ <>
13
+ <ExampleContainer>
14
+ <Title title="Info" theme="light" level={4} />
15
+ <DxcAlert inlineText="Info type alert with inline text." />
16
+ </ExampleContainer>
17
+ <ExampleContainer>
18
+ <Title title="Confirm" theme="light" level={4} />
19
+ <DxcAlert type="confirm" inlineText="Confirm type alert with inline text." />
20
+ </ExampleContainer>
21
+ <ExampleContainer>
22
+ <Title title="Warning" theme="light" level={4} />
23
+ <DxcAlert type="warning" inlineText="Warning type alert with inline text." />
24
+ </ExampleContainer>
25
+ <ExampleContainer>
26
+ <Title title="Error" theme="light" level={4} />
27
+ <DxcAlert type="error" inlineText="Error type alert with inline text." />
28
+ </ExampleContainer>
29
+ <ExampleContainer>
30
+ <Title title="With close button" theme="light" level={4} />
31
+ <DxcAlert inlineText="Info type alert with inline text and close button." onClose={() => {}} />
32
+ </ExampleContainer>
33
+ <ExampleContainer pseudoState="pseudo-hover">
34
+ <Title title="With hovered close button" theme="light" level={4} />
35
+ <DxcAlert inlineText="Info type alert with inline text and close button." onClose={() => {}} />
36
+ </ExampleContainer>
37
+ <ExampleContainer pseudoState="pseudo-focus">
38
+ <Title title="With focused close button" theme="light" level={4} />
39
+ <DxcAlert inlineText="Info type alert with inline text and close button." onClose={() => {}} />
40
+ </ExampleContainer>
41
+ <ExampleContainer pseudoState="pseudo-active">
42
+ <Title title="With actived close button" theme="light" level={4} />
43
+ <DxcAlert inlineText="Info type alert with inline text and close button." onClose={() => {}} />
44
+ </ExampleContainer>
45
+ <ExampleContainer>
46
+ <Title title="With children" theme="light" level={4} />
47
+ <DxcAlert>
48
+ <div>
49
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
50
+ lobortis eget.
51
+ </div>
52
+ </DxcAlert>
53
+ </ExampleContainer>
54
+ <ExampleContainer>
55
+ <Title title="With inline text and children" theme="light" level={4} />
56
+ <DxcAlert inlineText="Info type alert with inline text.">
57
+ <div>
58
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
59
+ lobortis eget.
60
+ </div>
61
+ </DxcAlert>
62
+ </ExampleContainer>
63
+ <Title title="Margins" theme="light" level={2} />
64
+ <ExampleContainer>
65
+ <Title title="Xxsmall" theme="light" level={4} />
66
+ <DxcAlert margin="xxsmall" inlineText="Info type alert with inline text and xxsmall margin." />
67
+ </ExampleContainer>
68
+ <ExampleContainer>
69
+ <Title title="Xsmall" theme="light" level={4} />
70
+ <DxcAlert margin="xsmall" inlineText="Info type alert with inline text and xsmall margin." />
71
+ </ExampleContainer>
72
+ <ExampleContainer>
73
+ <Title title="Small" theme="light" level={4} />
74
+ <DxcAlert margin="small" inlineText="Info type alert with inline text and small margin." />
75
+ </ExampleContainer>
76
+ <ExampleContainer>
77
+ <Title title="Medium" theme="light" level={4} />
78
+ <DxcAlert margin="medium" inlineText="Info type alert with inline text and medium margin." />
79
+ </ExampleContainer>
80
+ <ExampleContainer>
81
+ <Title title="Large" theme="light" level={4} />
82
+ <DxcAlert margin="large" inlineText="Info type alert with inline text and large margin." />
83
+ </ExampleContainer>
84
+ <ExampleContainer>
85
+ <Title title="Xlarge" theme="light" level={4} />
86
+ <DxcAlert margin="xlarge" inlineText="Info type alert with inline text and xlarge margin." />
87
+ </ExampleContainer>
88
+ <ExampleContainer>
89
+ <Title title="Xxlarge" theme="light" level={4} />
90
+ <DxcAlert margin="xxlarge" inlineText="Info type alert with inline text and xxlarge margin." />
91
+ </ExampleContainer>
92
+ <Title title="Sizes" theme="light" level={2} />
93
+ <ExampleContainer>
94
+ <Title title="FitContent" theme="light" level={4} />
95
+ <DxcAlert
96
+ size="fitContent"
97
+ inlineText="Info type alert with inline text, children, close button and fitContent size."
98
+ onClose={() => {}}
99
+ >
100
+ <div>
101
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
102
+ lobortis eget.
103
+ </div>
104
+ </DxcAlert>
105
+ </ExampleContainer>
106
+ <ExampleContainer>
107
+ <Title title="Small" theme="light" level={4} />
108
+ <DxcAlert
109
+ size="small"
110
+ inlineText="Info type alert with inline text, children, close button and small size."
111
+ onClose={() => {}}
112
+ >
113
+ <div>
114
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
115
+ lobortis eget.
116
+ </div>
117
+ </DxcAlert>
118
+ </ExampleContainer>
119
+ <ExampleContainer>
120
+ <Title title="Medium" theme="light" level={4} />
121
+ <DxcAlert
122
+ size="medium"
123
+ inlineText="Info type alert with inline text, children, close button and medium size."
124
+ onClose={() => {}}
125
+ >
126
+ <div>
127
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
128
+ lobortis eget.
129
+ </div>
130
+ </DxcAlert>
131
+ </ExampleContainer>
132
+ <ExampleContainer>
133
+ <Title title="Large" theme="light" level={4} />
134
+ <DxcAlert
135
+ size="large"
136
+ inlineText="Info type alert with inline text, children, close button and large size."
137
+ onClose={() => {}}
138
+ >
139
+ <div>
140
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
141
+ lobortis eget.
142
+ </div>
143
+ </DxcAlert>
144
+ </ExampleContainer>
145
+ <ExampleContainer>
146
+ <Title title="FillParent" theme="light" level={4} />
147
+ <DxcAlert
148
+ size="fillParent"
149
+ inlineText="Info type alert with inline text, children, close button and fillParent size."
150
+ onClose={() => {}}
151
+ >
152
+ <div>
153
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
154
+ lobortis eget.
155
+ </div>
156
+ </DxcAlert>
157
+ </ExampleContainer>
158
+ </>
159
+ );
160
+
161
+ export const ModalAlert = () => (
162
+ <ExampleContainer>
163
+ <DxcAlert inlineText="Modal alert." mode="modal" onClose={() => {}}>
164
+ <div>
165
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
166
+ lobortis eget.
167
+ </div>
168
+ </DxcAlert>
169
+ </ExampleContainer>
170
+ );
package/box/Box.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import BoxPropsType from "./types";
3
+ declare const DxcBox: ({ shadowDepth, display, children, margin, padding, size, tabIndex, }: BoxPropsType) => JSX.Element;
4
+ export default DxcBox;