@dxc-technology/halstack-react 0.0.0-c24450b → 0.0.0-c6243ef

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 (129) hide show
  1. package/babel.config.js +6 -2
  2. package/dist/BackgroundColorContext.js +46 -0
  3. package/dist/ThemeContext.js +235 -2
  4. package/dist/accordion/Accordion.js +170 -81
  5. package/dist/accordion-group/AccordionGroup.js +186 -0
  6. package/dist/alert/Alert.js +184 -83
  7. package/dist/alert/index.d.ts +51 -0
  8. package/dist/badge/Badge.js +63 -0
  9. package/dist/box/Box.js +31 -23
  10. package/dist/button/Button.js +82 -27
  11. package/dist/card/Card.js +72 -35
  12. package/dist/checkbox/Checkbox.js +108 -32
  13. package/dist/chip/Chip.js +129 -35
  14. package/dist/common/RequiredComponent.js +2 -8
  15. package/dist/common/utils.js +2 -22
  16. package/dist/common/variables.js +1457 -210
  17. package/dist/date/Date.js +81 -59
  18. package/dist/dialog/Dialog.js +58 -37
  19. package/dist/dropdown/Dropdown.js +229 -68
  20. package/dist/file-input/FileInput.js +644 -0
  21. package/dist/file-input/FileItem.js +280 -0
  22. package/dist/file-input/index.d.ts +81 -0
  23. package/dist/footer/Footer.js +87 -38
  24. package/dist/footer/dxc_logo.svg +15 -0
  25. package/dist/footer/readme.md +1 -1
  26. package/dist/header/Header.js +121 -72
  27. package/dist/header/dxc_logo_black.svg +8 -0
  28. package/dist/header/readme.md +1 -1
  29. package/dist/heading/Heading.js +81 -22
  30. package/dist/input-text/InputText.js +289 -101
  31. package/dist/layout/ApplicationLayout.js +331 -0
  32. package/dist/layout/facebook.svg +45 -0
  33. package/dist/layout/linkedin.svg +50 -0
  34. package/dist/layout/twitter.svg +53 -0
  35. package/dist/link/Link.js +136 -35
  36. package/dist/main.d.ts +8 -0
  37. package/dist/main.js +105 -1
  38. package/dist/new-date/NewDate.js +400 -0
  39. package/dist/new-date/index.d.ts +95 -0
  40. package/dist/new-select/NewSelect.js +836 -0
  41. package/dist/new-select/index.d.ts +53 -0
  42. package/dist/new-textarea/NewTextarea.js +369 -0
  43. package/dist/new-textarea/index.d.ts +117 -0
  44. package/dist/number/Number.js +136 -0
  45. package/dist/number/NumberContext.js +16 -0
  46. package/dist/number/index.d.ts +113 -0
  47. package/dist/paginator/Paginator.js +160 -49
  48. package/dist/password-input/PasswordInput.js +198 -0
  49. package/dist/password-input/index.d.ts +94 -0
  50. package/dist/progress-bar/ProgressBar.js +97 -44
  51. package/dist/radio/Radio.js +39 -21
  52. package/dist/resultsetTable/ResultsetTable.js +93 -69
  53. package/dist/select/Select.js +250 -143
  54. package/dist/sidenav/Sidenav.js +85 -143
  55. package/dist/slider/Slider.js +206 -70
  56. package/dist/spinner/Spinner.js +249 -64
  57. package/dist/switch/Switch.js +51 -26
  58. package/dist/table/Table.js +63 -15
  59. package/dist/tabs/Tabs.js +208 -35
  60. package/dist/tabs-for-sections/TabsForSections.js +1 -16
  61. package/dist/tag/Tag.js +100 -35
  62. package/dist/text-input/TextInput.js +971 -0
  63. package/dist/text-input/index.d.ts +135 -0
  64. package/dist/textarea/Textarea.js +81 -43
  65. package/dist/toggle/Toggle.js +16 -19
  66. package/dist/toggle-group/ToggleGroup.js +327 -0
  67. package/dist/upload/Upload.js +13 -8
  68. package/dist/upload/buttons-upload/ButtonsUpload.js +34 -20
  69. package/dist/upload/dragAndDropArea/DragAndDropArea.js +78 -31
  70. package/dist/upload/file-upload/FileToUpload.js +50 -24
  71. package/dist/upload/files-upload/FilesToUpload.js +16 -16
  72. package/dist/upload/transaction/Transaction.js +44 -24
  73. package/dist/upload/transactions/Transactions.js +38 -20
  74. package/dist/useTheme.js +22 -0
  75. package/dist/wizard/Wizard.js +142 -51
  76. package/dist/wizard/invalid_icon.svg +4 -5
  77. package/dist/wizard/valid_icon.svg +4 -5
  78. package/package.json +14 -6
  79. package/test/AccordionGroup.test.js +125 -0
  80. package/test/Date.test.js +13 -13
  81. package/test/Dropdown.test.js +19 -4
  82. package/test/FileInput.test.js +201 -0
  83. package/test/InputText.test.js +30 -26
  84. package/test/Link.test.js +25 -7
  85. package/test/NewDate.test.js +232 -0
  86. package/test/NewTextarea.test.js +195 -0
  87. package/test/Number.test.js +257 -0
  88. package/test/Paginator.test.js +72 -60
  89. package/test/PasswordInput.test.js +83 -0
  90. package/test/ResultsetTable.test.js +66 -19
  91. package/test/Select.test.js +55 -34
  92. package/test/Sidenav.test.js +22 -64
  93. package/test/Slider.test.js +17 -0
  94. package/test/Spinner.test.js +5 -0
  95. package/test/Tabs.test.js +21 -0
  96. package/test/TextInput.test.js +732 -0
  97. package/test/ToggleGroup.test.js +85 -0
  98. package/dist/accordion/Accordion.stories.js +0 -207
  99. package/dist/accordion/readme.md +0 -96
  100. package/dist/alert/Alert.stories.js +0 -158
  101. package/dist/alert/close.svg +0 -4
  102. package/dist/alert/error.svg +0 -4
  103. package/dist/alert/info.svg +0 -4
  104. package/dist/alert/readme.md +0 -43
  105. package/dist/alert/success.svg +0 -4
  106. package/dist/alert/warning.svg +0 -4
  107. package/dist/button/Button.stories.js +0 -224
  108. package/dist/button/readme.md +0 -93
  109. package/dist/common/services/example-service.js +0 -10
  110. package/dist/common/services/example-service.test.js +0 -12
  111. package/dist/date/calendar.svg +0 -1
  112. package/dist/date/calendar_dark.svg +0 -1
  113. package/dist/dialog/Dialog.stories.js +0 -217
  114. package/dist/dialog/readme.md +0 -32
  115. package/dist/dropdown/Dropdown.stories.js +0 -249
  116. package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
  117. package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
  118. package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
  119. package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
  120. package/dist/dropdown/readme.md +0 -69
  121. package/dist/footer/Footer.stories.js +0 -94
  122. package/dist/footer/dxc_logo_wht.png +0 -0
  123. package/dist/header/dxc_logo_black.png +0 -0
  124. package/dist/header/dxc_logo_white.png +0 -0
  125. package/dist/input-text/InputText.stories.js +0 -209
  126. package/dist/select/Select.stories.js +0 -235
  127. package/dist/select/readme.md +0 -72
  128. package/dist/sidenav/arrow_icon.svg +0 -3
  129. package/test/Toggle.test.js +0 -43
@@ -0,0 +1,135 @@
1
+ type Size = "small" | "medium" | "large" | "fillParent";
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ type SVG = string | (HTMLElement & SVGElement);
10
+ type Action = {
11
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
12
+ icon: SVG;
13
+ };
14
+
15
+ type Props = {
16
+ /**
17
+ * Text to be placed above the input. This label will be used as the aria-label attribute of the list of suggestions.
18
+ */
19
+ label?: string;
20
+ /**
21
+ * Name attribute of the input element.
22
+ */
23
+ name?: string;
24
+ /**
25
+ * Value of the input. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
26
+ */
27
+ value?: string;
28
+ /**
29
+ * Helper text to be placed above the input.
30
+ */
31
+ helperText?: string;
32
+ /**
33
+ * Text to be put as placeholder of the input.
34
+ */
35
+ placeholder?: string;
36
+ /**
37
+ * Action to be shown in the input. This is an object composed of an onClick function and an icon,
38
+ * being the latter either an inline svg or a URL to the image.
39
+ */
40
+ action?: Action;
41
+ /**
42
+ * If true, the input will have an action to clear the entered value.
43
+ */
44
+ clearable?: boolean;
45
+ /**
46
+ * If true, the component will be disabled.
47
+ */
48
+ disabled?: boolean;
49
+ /**
50
+ * If true, the input will be optional, showing '(Optional)'
51
+ * next to the label. Otherwise, the field will be considered required and an error will be
52
+ * passed as a parameter to the OnBlur and onChange functions when it has
53
+ * not been filled.
54
+ */
55
+ optional?: boolean;
56
+ /**
57
+ * Prefix to be placed before the input value.
58
+ */
59
+ prefix?: string;
60
+ /**
61
+ * Suffix to be placed after the input value.
62
+ */
63
+ suffix?: string;
64
+ /**
65
+ * This function will be called when the user types within the input
66
+ * element of the component. An object including the current value and
67
+ * the error (if the value entered is not valid) will be passed to this
68
+ * function. If there is no error, error will be null.
69
+ */
70
+ onChange?: (val: { value: string; error: string }) => void;
71
+ /**
72
+ * This function will be called when the input element loses the focus.
73
+ * An object including the input value and the error (if the value
74
+ * entered is not valid) will be passed to this function. If there is no error,
75
+ * error will be null.
76
+ */
77
+ onBlur?: (obj: { value: string; error: string }) => void;
78
+ /**
79
+ * If it is defined, the component will change its appearance, showing
80
+ * the error below the input component. If it is not defined, the error
81
+ * messages will be managed internally, but never displayed on its own.
82
+ */
83
+ error?: string;
84
+ /**
85
+ * These are the options to be displayed as suggestions. It can be either an array or a function:
86
+ * - Array: Array of options that will be filtered by the component.
87
+ * - Function: This function will be called when the user changes the value, we will send as a parameter the new value;
88
+ * apart from that this function should return one promise on which we should make 'then' to get the suggestions filtered.
89
+ */
90
+ suggestions?: string[] | (() => void);
91
+ /**
92
+ * Regular expression that defines the valid format allowed by the input.
93
+ * This will be checked both when the input element loses the focus and
94
+ * while typing within it. If the string entered does not match the
95
+ * pattern, the onBlur and onChange functions will be called with the
96
+ * current value and an internal error informing that this value does not
97
+ * match the pattern. If the pattern is met, the error parameter of both
98
+ * events will be null.
99
+ */
100
+ pattern?: string;
101
+ /**
102
+ * Specifies the minimun and maximum length allowed by the input.
103
+ * This will be checked both when the input element loses the
104
+ * focus and while typing within it. If the string entered does not
105
+ * comply the length, the onBlur and onChange functions will be called
106
+ * with the current value and an internal error informing that the value
107
+ * length does not comply the specified range. If a valid length is
108
+ * reached, the error parameter of both events will be null.
109
+ */
110
+ length?: { min?: number; max?: number };
111
+ /**
112
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
113
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
114
+ */
115
+ autocomplete?: string;
116
+ /**
117
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
118
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
119
+ */
120
+ margin?: Space | Margin;
121
+ /**
122
+ * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
123
+ */
124
+ size?: Size;
125
+ /**
126
+ * Value of the tabindex attribute.
127
+ */
128
+ tabIndex?: number;
129
+ /**
130
+ * Reference to the component.
131
+ */
132
+ ref?: React.RefObject<HTMLDivElement>;
133
+ };
134
+
135
+ export default function DxcTextInput(props: Props): JSX.Element;
@@ -25,16 +25,18 @@ var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
25
25
 
26
26
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
27
 
28
- require("../common/OpenSans.css");
29
-
30
28
  var _variables = require("../common/variables.js");
31
29
 
32
30
  var _utils = require("../common/utils.js");
33
31
 
34
- var _ThemeContext = _interopRequireDefault(require("../ThemeContext.js"));
32
+ var _useTheme = _interopRequireDefault(require("../useTheme.js"));
33
+
34
+ var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
35
+
36
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
35
37
 
36
38
  function _templateObject() {
37
- var data = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n \n display: inline-block;\n position: relative;\n height: auto;\n width: ", ";\n .MuiTextField-root {\n width: 100%;\n font-family: \"Open Sans\", sans-serif;\n .MuiFormHelperText-root {\n font-family: \"Open Sans\", sans-serif;\n margin-top: 6px;\n }\n .MuiFormLabel-root {\n font-size: 16px;\n color: ", ";\n &::before {\n content:'", "';\n color: ", ";\n font-size: 16px; \n }\n &.Mui-disabled{\n opacity:0.5;\n }\n padding-left: \"inherit\";\n &.Mui-focused {\n color: ", ";\n &.MuiInputLabel-shrink {\n transform: \n \"translate(0, 1.5px) scale(0.75);\";\n }\n }\n &.Mui-disabled {\n color: ", ";\n cursor: not-allowed;\n }\n &.MuiInputLabel-shrink {\n font-family: \"Open Sans\", sans-serif;\n transform: \"translate(0, 1.5px) scale(0.75)\";\n }\n &.Mui-error {\n color: ", ";\n }\n\n &:not(.MuiInputLabel-shrink) {\n font-family: \"Open Sans\", sans-serif;\n color: ", ";\n & + div, & + div + p {\n color: ", ";\n }\n }\n\n &.MuiInputLabel-shrink {\n & + div::before {\n border-color: ", ";\n }\n & + div + p {\n color: ", ";\n }\n \n }\n }\n .MuiInputBase-root.MuiInput-root.MuiInput-underline {\n font-family: \"Open Sans\", sans-serif;\n &::before{\n border-bottom: ", ";\n }\n &:not(.Mui-error)::before, &:not(&.Mui-focused)::before {\n border-bottom: ", ";\n }\n &::after{\n border-bottom: ", ";\n }\n\n .MuiInputBase-inputMultiline {\n overflow: auto !important;\n\n ::-webkit-scrollbar {\n width: 3px;\n }\n\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n }\n\n &.Mui-error {\n &::before {\n border-width: 1px;\n border-color: ", ";\n }\n &::after {\n transform: scaleX(0);\n }\n }\n\n &.Mui-focused {\n &::after {\n border-width: 2px;\n border-color: ", ";\n transform: scaleX(1);\n }\n \n &.Mui-error::after {\n border-color: ", ";\n }\n }\n\n &.Mui-disabled {\n color: ", ";\n opacity:0.5;\n cursor: not-allowed;\n \n &::before {\n border-bottom: ", ";\n border-bottom-style: solid;\n }\n }\n .MuiInputBase-input {\n padding-left: \"inherit\";\n color: ", ";\n text-overflow: ellipsis;\n &.Mui-disabled {\n cursor: not-allowed;\n };\n }\n\n &:hover:not(.Mui-disabled):before &:hover:not(.Mui-error):before{\n border-bottom: ", ";\n }\n \n }\n\n & > p {\n &.Mui-error {\n color: ", ";\n }\n &.Mui-disabled{\n opacity:0.5;\n cursor:not-allowed;\n }\n }\n \n }\n"]);
39
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-block;\n position: relative;\n height: auto;\n width: ", ";\n\n .MuiTextField-root {\n width: 100%;\n\n .MuiFormHelperText-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n margin-top: 6px;\n }\n .MuiFormLabel-root {\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n color: ", ";\n padding-left: \"inherit\";\n\n &.Mui-disabled {\n color: ", " !important;\n cursor: not-allowed;\n }\n\n &.Mui-focused {\n color: ", ";\n &.MuiInputLabel-shrink {\n transform: \"translate(0, 1.5px) scale(0.75);\";\n }\n }\n\n &.MuiInputLabel-shrink {\n font-family: ", ";\n transform: \"translate(0, 1.5px) scale(0.75)\";\n }\n\n &.Mui-error {\n color: ", ";\n }\n\n &:not(.MuiInputLabel-shrink) {\n font-family: ", ";\n color: ", ";\n & + div,\n & + div + p {\n color: ", ";\n }\n }\n\n &.MuiInputLabel-shrink {\n & + div::before {\n border-color: ", ";\n }\n & + div + p {\n color: ", ";\n }\n }\n }\n .MuiInputBase-root.MuiInput-root.MuiInput-underline {\n &::before {\n border-bottom: ", ";\n }\n\n &:not(.Mui-error)::before,\n &:not(&.Mui-focused)::before {\n border-bottom: ", ";\n }\n\n &::after {\n border-bottom: ", ";\n }\n\n .MuiInputBase-inputMultiline {\n overflow: auto !important;\n\n ::-webkit-scrollbar {\n width: 3px;\n }\n\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n }\n\n &.Mui-error {\n &::before {\n border-width: ", ";\n border-color: ", ";\n }\n &::after {\n transform: scaleX(0);\n }\n }\n\n &.Mui-focused {\n &::after {\n border-width: calc(", " + 1px);\n border-color: ", ";\n }\n &.Mui-error::after {\n border-color: ", ";\n }\n }\n\n &.Mui-disabled {\n cursor: not-allowed;\n\n &::before {\n border-bottom: ", ";\n border-bottom-style: solid;\n }\n }\n\n .MuiInputBase-input {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n color: ", ";\n line-height: ", ";\n padding-left: \"inherit\";\n text-overflow: ellipsis;\n\n &.Mui-disabled {\n cursor: not-allowed;\n color: ", ";\n }\n }\n\n &:hover:not(.Mui-disabled):before &:hover:not(.Mui-error):before {\n border-bottom-color: ", ";\n }\n }\n\n & > p {\n &.Mui-error {\n color: ", ";\n }\n &.Mui-disabled {\n color: ", " !important;\n cursor: not-allowed;\n }\n }\n }\n"]);
38
40
 
39
41
  _templateObject = function _templateObject() {
40
42
  return data;
@@ -49,8 +51,6 @@ var DxcTextarea = function DxcTextarea(_ref) {
49
51
  _ref$name = _ref.name,
50
52
  name = _ref$name === void 0 ? "" : _ref$name,
51
53
  value = _ref.value,
52
- _ref$theme = _ref.theme,
53
- theme = _ref$theme === void 0 ? "light" : _ref$theme,
54
54
  _ref$assistiveText = _ref.assistiveText,
55
55
  assistiveText = _ref$assistiveText === void 0 ? "" : _ref$assistiveText,
56
56
  _ref$disabled = _ref.disabled,
@@ -69,14 +69,17 @@ var DxcTextarea = function DxcTextarea(_ref) {
69
69
  placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
70
70
  margin = _ref.margin,
71
71
  _ref$size = _ref.size,
72
- size = _ref$size === void 0 ? "medium" : _ref$size;
72
+ size = _ref$size === void 0 ? "medium" : _ref$size,
73
+ _ref$tabIndex = _ref.tabIndex,
74
+ tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
73
75
 
74
76
  var _useState = (0, _react.useState)(""),
75
77
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
76
78
  innerValue = _useState2[0],
77
79
  setInnerValue = _useState2[1];
78
80
 
79
- var colorsTheme = (0, _react.useContext)(_ThemeContext["default"]) || _variables.colors;
81
+ var colorsTheme = (0, _useTheme["default"])();
82
+ var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
80
83
 
81
84
  var handlerTextareaChange = function handlerTextareaChange(event) {
82
85
  if (value === null || value === undefined) {
@@ -104,25 +107,28 @@ var DxcTextarea = function DxcTextarea(_ref) {
104
107
  };
105
108
 
106
109
  return _react["default"].createElement(_styledComponents.ThemeProvider, {
107
- theme: colorsTheme
110
+ theme: colorsTheme.textarea
108
111
  }, _react["default"].createElement(TextContainer, {
109
112
  required: required,
110
- brightness: theme,
111
113
  assistiveText: assistiveText,
112
114
  margin: margin,
113
- size: size
115
+ size: size,
116
+ backgroundType: backgroundType
114
117
  }, _react["default"].createElement(_TextField["default"], {
115
118
  error: invalid,
116
119
  value: value !== null ? value : innerValue,
117
120
  name: name,
118
121
  multiline: true,
119
122
  disabled: disabled,
120
- label: label,
123
+ label: required ? _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_RequiredComponent["default"], null), label) : label,
121
124
  helperText: assistiveText,
122
125
  onChange: handlerTextareaChange,
123
126
  onBlur: onBlur && handlerTextareaBlur || null,
124
127
  rows: numRows,
125
- placeholder: placeholder
128
+ placeholder: placeholder,
129
+ inputProps: {
130
+ tabIndex: tabIndex
131
+ }
126
132
  })));
127
133
  };
128
134
 
@@ -134,11 +140,7 @@ var sizes = {
134
140
  };
135
141
 
136
142
  var calculateWidth = function calculateWidth(margin, size) {
137
- if (size === "fillParent") {
138
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
139
- }
140
-
141
- return sizes[size];
143
+ return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
142
144
  };
143
145
 
144
146
  var TextContainer = _styledComponents["default"].div(_templateObject(), function (props) {
@@ -154,58 +156,93 @@ var TextContainer = _styledComponents["default"].div(_templateObject(), function
154
156
  }, function (props) {
155
157
  return calculateWidth(props.margin, props.size);
156
158
  }, function (props) {
157
- return props.brightness === "light" ? props.theme.black : props.theme.lightGrey;
159
+ return props.theme.fontFamily;
160
+ }, function (props) {
161
+ return props.theme.assistiveTextFontSize;
162
+ }, function (props) {
163
+ return props.theme.assistiveTextFontStyle;
164
+ }, function (props) {
165
+ return props.theme.assistiveTextFontWeight;
166
+ }, function (props) {
167
+ return props.theme.assistiveTextLetterSpacing;
168
+ }, function (props) {
169
+ return props.theme.labelFontSize;
170
+ }, function (props) {
171
+ return props.theme.labelFontStyle;
172
+ }, function (props) {
173
+ return props.theme.labelFontWeight;
174
+ }, function (props) {
175
+ return props.theme.labelLetterSpacing;
176
+ }, function (props) {
177
+ return props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
178
+ }, function (props) {
179
+ return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
180
+ }, function (props) {
181
+ return props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
182
+ }, function (props) {
183
+ return props.theme.fontFamily;
184
+ }, function (props) {
185
+ return props.backgroundType === "dark" ? props.theme.errorColorOnDark : props.theme.errorColor;
186
+ }, function (props) {
187
+ return props.theme.fontFamily;
188
+ }, function (props) {
189
+ return props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
190
+ }, function (props) {
191
+ return props.backgroundType === "dark" ? props.theme.assistiveTextFontColorOnDark : props.theme.assistiveTextFontColor;
192
+ }, function (props) {
193
+ return props.backgroundType ? props.theme.underlineColorOnDark : props.theme.underlineColor;
194
+ }, function (props) {
195
+ return props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
158
196
  }, function (props) {
159
- return props.required && "*" || "";
197
+ return "".concat(props.theme.underlineThickness, " solid ").concat(props.backgroundType === "dark" ? props.theme.underlineColorOnDark : props.theme.underlineColor);
160
198
  }, function (props) {
161
- return props.brightness === "light" ? props.theme.darkRed : props.theme.lightRed;
199
+ return "".concat(props.theme.underlineThickness, " solid ").concat(props.backgroundType === "dark" ? props.theme.underlineColorOnDark : props.theme.underlineColor);
162
200
  }, function (props) {
163
- return props.brightness === "light" ? props.theme.black : props.theme.white;
201
+ return "calc(".concat(props.theme.underlineThickness, " + 1px) solid ").concat(props.backgroundType === "dark" ? props.theme.underlineFocusColorOnDark : props.theme.underlineFocusColor);
164
202
  }, function (props) {
165
- return props.brightness === "light" ? props.theme.lightGrey : props.theme.darkGrey;
203
+ return props.backgroundType === "dark" ? props.theme.scrollBarTrackColorOnDark : props.theme.scrollBarTrackColor;
166
204
  }, function (props) {
167
- return props.brightness === "light" ? props.theme.darkRed : props.theme.lightRed;
205
+ return props.backgroundType === "dark" ? props.theme.scrollBarThumbColorOnDark : props.theme.scrollBarThumbColor;
168
206
  }, function (props) {
169
- return props.brightness === "light" ? props.theme.darkGrey : props.theme.lightGrey;
207
+ return props.theme.underlineThickness;
170
208
  }, function (props) {
171
- return props.brightness === "light" ? props.theme.darkGrey : props.theme.lightGrey;
209
+ return props.backgroundType === "dark" ? props.theme.errorColorOnDark : props.theme.errorColor;
172
210
  }, function (props) {
173
- return props.brightness === "light" ? props.theme.black : props.theme.lightGrey;
211
+ return props.theme.underlineThickness;
174
212
  }, function (props) {
175
- return props.brightness === "light" ? props.theme.darkGrey : props.theme.lightGrey;
213
+ return props.backgroundType === "dark" ? props.theme.underlineFocusColorOnDark : props.theme.underlineFocusColor;
176
214
  }, function (props) {
177
- return props.brightness === "light" ? "1px solid ".concat(props.theme.black) : "1px solid ".concat(props.theme.lightGrey);
215
+ return props.backgroundType === "dark" ? props.theme.errorColorOnDark : props.theme.errorColor;
178
216
  }, function (props) {
179
- return props.brightness === "light" ? "1px solid ".concat(props.theme.black) : "1px solid ".concat(props.theme.lightGrey);
217
+ return "".concat(props.theme.underlineThickness, " solid ").concat(props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor, " !important");
180
218
  }, function (props) {
181
- return props.brightness === "light" ? "2px solid #000" : "2px solid #d9d9d9";
219
+ return props.theme.fontFamily;
182
220
  }, function (props) {
183
- return props.theme.lightGrey;
221
+ return props.theme.valueFontSize;
184
222
  }, function (props) {
185
- return props.theme.darkGrey;
223
+ return props.theme.valueFontStyle;
186
224
  }, function (props) {
187
- return props.brightness === "light" ? props.theme.darkRed : props.theme.lightRed;
225
+ return props.theme.valueFontWeight;
188
226
  }, function (props) {
189
- return props.brightness === "light" ? props.theme.black : props.theme.white;
227
+ return props.theme.valueLetterSpacing;
190
228
  }, function (props) {
191
- return props.brightness === "light" ? props.theme.darkRed : props.theme.lightRed;
229
+ return props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
192
230
  }, function (props) {
193
- return props.brightness === "light" ? props.theme.lightGrey : props.theme.darkGrey;
231
+ return props.theme.valueLineHeight;
194
232
  }, function (props) {
195
- return props.brightness === "light" ? "1px solid ".concat(props.theme.lightGrey) : "1px solid ".concat(props.theme.darkGrey);
233
+ return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
196
234
  }, function (props) {
197
- return props.brightness === "light" ? props.theme.black : props.theme.white;
235
+ return props.backgroundType === "dark" ? props.theme.underlineFocusColorOnDark : props.theme.underlineFocusColor;
198
236
  }, function (props) {
199
- return props.brightness === "light" ? "1px solid ".concat(props.theme.black) : "1px solid ".concat(props.theme.white);
237
+ return "".concat(props.backgroundType === "dark" ? props.theme.errorColorOnDark : props.theme.errorColor, " !important");
200
238
  }, function (props) {
201
- return props.brightness === "light" ? props.theme.darkRed + " !important" : props.theme.lightRed + " !important";
239
+ return props.backgroundType === "dark" ? props.theme.disabledColorOnDark : props.theme.disabledColor;
202
240
  });
203
241
 
204
242
  DxcTextarea.propTypes = {
205
243
  label: _propTypes["default"].string,
206
244
  name: _propTypes["default"].string,
207
245
  value: _propTypes["default"].string,
208
- theme: _propTypes["default"].oneOf(["light", "dark", ""]),
209
246
  assistiveText: _propTypes["default"].string,
210
247
  disabled: _propTypes["default"].bool,
211
248
  required: _propTypes["default"].bool,
@@ -220,7 +257,8 @@ DxcTextarea.propTypes = {
220
257
  bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
221
258
  left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
222
259
  right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
223
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))])
260
+ }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
261
+ tabIndex: _propTypes["default"].number
224
262
  };
225
263
  var _default = DxcTextarea;
226
264
  exports["default"] = _default;
@@ -15,7 +15,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
15
 
16
16
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
17
17
 
18
- var _react = _interopRequireWildcard(require("react"));
18
+ var _react = _interopRequireDefault(require("react"));
19
19
 
20
20
  var _lab = require("@material-ui/lab");
21
21
 
@@ -23,13 +23,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
23
23
 
24
24
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
25
25
 
26
- require("../common/OpenSans.css");
27
-
28
- var _variables = require("../common/variables.js");
29
-
30
26
  var _utils = require("../common/utils.js");
31
27
 
32
- var _ThemeContext = _interopRequireDefault(require("../ThemeContext.js"));
28
+ var _useTheme = _interopRequireDefault(require("../useTheme.js"));
33
29
 
34
30
  function _templateObject4() {
35
31
  var data = (0, _taggedTemplateLiteral2["default"])([""]);
@@ -62,7 +58,7 @@ function _templateObject2() {
62
58
  }
63
59
 
64
60
  function _templateObject() {
65
- var data = (0, _taggedTemplateLiteral2["default"])(["\n & {\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n opacity: ", ";\n cursor: ", ";\n display: inline-block;\n width: ", ";\n }\n\n .MuiToggleButton-label {\n font-size: 14px;\n font-family: \"Open Sans\", sans-serif;\n color: ", ";\n }\n .MuiButtonBase-root {\n width: ", ";\n min-height: ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root {\n min-width: 42px;\n height: 43px;\n border: ", ";\n\n border-radius: 4px !important;\n }\n\n .MuiToggleButton-root.Mui-selected {\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root:last-child,\n .MuiToggleButton-root:first-child,\n .MuiToggleButton-root:not(:first-child) {\n padding: ", ";\n }\n\n .MuiTouchRipple-child {\n background-color: ", ";\n }\n"]);
61
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n & {\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n opacity: ", ";\n cursor: ", ";\n display: inline-block;\n width: ", ";\n }\n\n .MuiToggleButton-label {\n font-size: 14px;\n font-family: ", ";\n color: ", ";\n }\n .MuiButtonBase-root {\n width: ", ";\n min-height: ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root {\n min-width: 42px;\n height: 43px;\n border: ", ";\n\n border-radius: 4px !important;\n }\n\n .MuiToggleButton-root.Mui-selected {\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root:last-child,\n .MuiToggleButton-root:first-child,\n .MuiToggleButton-root:not(:first-child) {\n padding: ", ";\n }\n\n .MuiTouchRipple-child {\n background-color: ", ";\n }\n"]);
66
62
 
67
63
  _templateObject = function _templateObject() {
68
64
  return data;
@@ -92,8 +88,7 @@ var DxcToggle = function DxcToggle(_ref) {
92
88
  margin = _ref.margin,
93
89
  _ref$size = _ref.size,
94
90
  size = _ref$size === void 0 ? "fitContent" : _ref$size;
95
-
96
- var colorsTheme = (0, _react.useContext)(_ThemeContext["default"]) || _variables.colors;
91
+ var colorsTheme = (0, _useTheme["default"])();
97
92
 
98
93
  var handlerToggleClick = function handlerToggleClick() {
99
94
  if (!disabled && typeof onClick === "function") {
@@ -149,21 +144,23 @@ var calculateWidth = function calculateWidth(margin, size) {
149
144
  };
150
145
 
151
146
  var DxcToggleContainer = _styledComponents["default"].div(_templateObject(), function (props) {
152
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
147
+ return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? spaces[props.margin] : "0px";
153
148
  }, function (props) {
154
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
149
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? spaces[props.margin.top] : "";
155
150
  }, function (props) {
156
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
151
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? spaces[props.margin.right] : "";
157
152
  }, function (props) {
158
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
153
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? spaces[props.margin.bottom] : "";
159
154
  }, function (props) {
160
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
155
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? spaces[props.margin.left] : "";
161
156
  }, function (props) {
162
157
  return props.disabled ? "0.5" : "1";
163
158
  }, function (props) {
164
159
  return props.disabled ? "not-allowed" : "pointer";
165
160
  }, function (props) {
166
161
  return calculateWidth(props.margin, props.size);
162
+ }, function (props) {
163
+ return props.theme.fontFamily;
167
164
  }, function (props) {
168
165
  return props.brightness === "dark" && props.mode === "outlined" ? props.theme.white : props.theme.black;
169
166
  }, function (props) {
@@ -213,11 +210,11 @@ DxcToggle.propTypes = {
213
210
  disableRipple: _propTypes["default"].bool,
214
211
  onClick: _propTypes["default"].func,
215
212
  margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
216
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
217
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
218
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
219
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
220
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))])
213
+ top: _propTypes["default"].oneOf(Object.keys(spaces)),
214
+ bottom: _propTypes["default"].oneOf(Object.keys(spaces)),
215
+ left: _propTypes["default"].oneOf(Object.keys(spaces)),
216
+ right: _propTypes["default"].oneOf(Object.keys(spaces))
217
+ }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(spaces)))])
221
218
  };
222
219
  var _default = DxcToggle;
223
220
  exports["default"] = _default;