@dxc-technology/halstack-react 0.0.0-13e0035 → 0.0.0-1418b62

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 (74) hide show
  1. package/dist/ThemeContext.js +130 -98
  2. package/dist/accordion/Accordion.js +44 -39
  3. package/dist/accordion-group/AccordionGroup.js +1 -3
  4. package/dist/alert/Alert.js +124 -113
  5. package/dist/alert/index.d.ts +51 -0
  6. package/dist/button/Button.js +31 -25
  7. package/dist/checkbox/Checkbox.js +19 -13
  8. package/dist/common/variables.js +507 -344
  9. package/dist/date/Date.js +5 -7
  10. package/dist/dialog/Dialog.js +8 -30
  11. package/dist/dropdown/Dropdown.js +108 -68
  12. package/dist/file-input/FileInput.js +644 -0
  13. package/dist/file-input/FileItem.js +280 -0
  14. package/dist/file-input/index.d.ts +81 -0
  15. package/dist/header/Header.js +3 -23
  16. package/dist/layout/ApplicationLayout.js +1 -1
  17. package/dist/link/Link.js +4 -8
  18. package/dist/main.d.ts +8 -0
  19. package/dist/main.js +16 -0
  20. package/dist/new-date/NewDate.js +68 -67
  21. package/dist/new-date/index.d.ts +95 -0
  22. package/dist/new-input-text/NewInputText.js +169 -159
  23. package/dist/new-input-text/index.d.ts +135 -0
  24. package/dist/new-select/NewSelect.js +836 -0
  25. package/dist/new-select/index.d.ts +53 -0
  26. package/dist/new-textarea/NewTextarea.js +60 -37
  27. package/dist/new-textarea/index.d.ts +117 -0
  28. package/dist/number/Number.js +5 -3
  29. package/dist/number/index.d.ts +113 -0
  30. package/dist/password/Password.js +7 -3
  31. package/dist/password/index.d.ts +94 -0
  32. package/dist/progress-bar/ProgressBar.js +62 -26
  33. package/dist/select/Select.js +122 -158
  34. package/dist/sidenav/Sidenav.js +6 -4
  35. package/dist/slider/Slider.js +56 -52
  36. package/dist/spinner/Spinner.js +217 -54
  37. package/dist/tag/Tag.js +26 -32
  38. package/dist/toggle-group/ToggleGroup.js +21 -39
  39. package/dist/upload/transaction/Transaction.js +2 -2
  40. package/package.json +2 -1
  41. package/test/FileInput.test.js +201 -0
  42. package/test/NewDate.test.js +41 -12
  43. package/test/NewInputText.test.js +106 -189
  44. package/test/NewTextarea.test.js +96 -102
  45. package/test/Number.test.js +46 -30
  46. package/test/Paginator.test.js +1 -1
  47. package/test/Password.test.js +17 -10
  48. package/test/ResultsetTable.test.js +1 -2
  49. package/test/Select.test.js +40 -17
  50. package/test/Spinner.test.js +5 -0
  51. package/dist/accordion/Accordion.stories.js +0 -207
  52. package/dist/accordion/readme.md +0 -96
  53. package/dist/accordion-group/AccordionGroup.stories.js +0 -207
  54. package/dist/accordion-group/readme.md +0 -70
  55. package/dist/alert/Alert.stories.js +0 -158
  56. package/dist/alert/close.svg +0 -4
  57. package/dist/alert/error.svg +0 -4
  58. package/dist/alert/info.svg +0 -4
  59. package/dist/alert/readme.md +0 -43
  60. package/dist/alert/success.svg +0 -4
  61. package/dist/alert/warning.svg +0 -4
  62. package/dist/button/Button.stories.js +0 -224
  63. package/dist/button/readme.md +0 -93
  64. package/dist/dialog/Dialog.stories.js +0 -217
  65. package/dist/dialog/readme.md +0 -32
  66. package/dist/dropdown/Dropdown.stories.js +0 -249
  67. package/dist/dropdown/baseline-arrow_drop_down.svg +0 -1
  68. package/dist/dropdown/baseline-arrow_drop_down_wh.svg +0 -4
  69. package/dist/dropdown/baseline-arrow_drop_up.svg +0 -1
  70. package/dist/dropdown/baseline-arrow_drop_up_wh.svg +0 -4
  71. package/dist/dropdown/readme.md +0 -69
  72. package/dist/select/Select.stories.js +0 -235
  73. package/dist/select/readme.md +0 -72
  74. package/dist/toggle-group/readme.md +0 -82
@@ -50,8 +50,6 @@ function _templateObject() {
50
50
  }
51
51
 
52
52
  var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
53
- var _colorsTheme$date, _colorsTheme$date2;
54
-
55
53
  var _ref$label = _ref.label,
56
54
  label = _ref$label === void 0 ? "" : _ref$label,
57
55
  _ref$name = _ref.name,
@@ -73,6 +71,8 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
73
71
  onBlur = _ref.onBlur,
74
72
  _ref$error = _ref.error,
75
73
  error = _ref$error === void 0 ? "" : _ref$error,
74
+ _ref$autocomplete = _ref.autocomplete,
75
+ autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
76
76
  margin = _ref.margin,
77
77
  _ref$size = _ref.size,
78
78
  size = _ref$size === void 0 ? "medium" : _ref$size,
@@ -84,20 +84,15 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
84
84
  innerValue = _useState2[0],
85
85
  setInnerValue = _useState2[1];
86
86
 
87
- var _useState3 = (0, _react.useState)(""),
87
+ var _useState3 = (0, _react.useState)(false),
88
88
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
89
- validationError = _useState4[0],
90
- setValidationError = _useState4[1];
89
+ isOpen = _useState4[0],
90
+ setIsOpen = _useState4[1];
91
91
 
92
- var _useState5 = (0, _react.useState)(false),
92
+ var _useState5 = (0, _react.useState)(null),
93
93
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
94
- isOpen = _useState6[0],
95
- setIsOpen = _useState6[1];
96
-
97
- var _useState7 = (0, _react.useState)(null),
98
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
99
- anchorEl = _useState8[0],
100
- setAnchorEl = _useState8[1];
94
+ anchorEl = _useState6[0],
95
+ setAnchorEl = _useState6[1];
101
96
 
102
97
  var colorsTheme = (0, _useTheme["default"])();
103
98
 
@@ -112,31 +107,36 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
112
107
  };
113
108
 
114
109
  var handleCalendarOnClick = function handleCalendarOnClick(newDate) {
115
- var string = (0, _moment["default"])(newDate).format(format.toUpperCase());
116
- value !== null && value !== void 0 ? value : setInnerValue(string);
117
- typeof onChange === "function" && onChange({
118
- value: string,
110
+ var newValue = (0, _moment["default"])(newDate).format(format.toUpperCase());
111
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
112
+ onChange === null || onChange === void 0 ? void 0 : onChange({
113
+ value: newValue,
114
+ error: null,
119
115
  date: newDate && newDate.toJSON() ? newDate : null
120
116
  });
121
117
  };
122
118
 
123
- var handleIOnChange = function handleIOnChange(string) {
124
- var momentDate = (0, _moment["default"])(string, format.toUpperCase(), true);
125
- value !== null && value !== void 0 ? value : setInnerValue(string);
126
- typeof onChange === "function" && onChange({
127
- value: string,
119
+ var handleIOnChange = function handleIOnChange(_ref2) {
120
+ var newValue = _ref2.value,
121
+ inputError = _ref2.error;
122
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
123
+ var momentDate = (0, _moment["default"])(newValue, format.toUpperCase(), true);
124
+ var invalidDateMessage = newValue !== "" && !momentDate.isValid() ? "Invalid date." : null;
125
+ onChange === null || onChange === void 0 ? void 0 : onChange({
126
+ value: newValue,
127
+ error: inputError || invalidDateMessage,
128
128
  date: momentDate.isValid() ? momentDate._d : null
129
129
  });
130
130
  };
131
131
 
132
- var handleIOnBlur = function handleIOnBlur(_ref2) {
133
- var value = _ref2.value;
132
+ var handleIOnBlur = function handleIOnBlur(_ref3) {
133
+ var value = _ref3.value,
134
+ inputError = _ref3.error;
134
135
  var momentDate = (0, _moment["default"])(value, format.toUpperCase(), true);
135
136
  var invalidDateMessage = value !== "" && !momentDate.isValid() ? "Invalid date." : null;
136
- setValidationError(invalidDateMessage);
137
- typeof onBlur === "function" && onBlur({
137
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur({
138
138
  value: value,
139
- error: invalidDateMessage,
139
+ error: inputError || invalidDateMessage,
140
140
  date: momentDate.isValid() ? momentDate._d : null
141
141
  });
142
142
  };
@@ -160,44 +160,44 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
160
160
  onClick: openCalendar,
161
161
  icon: _react["default"].createElement("svg", {
162
162
  xmlns: "http://www.w3.org/2000/svg",
163
- height: "24px",
163
+ height: "24",
164
164
  viewBox: "0 0 24 24",
165
- width: "24px",
165
+ width: "24",
166
166
  fill: "currentColor"
167
167
  }, _react["default"].createElement("path", {
168
- d: "M0 0h24v24H0V0z",
168
+ d: "M0 0h24v24H0z",
169
169
  fill: "none"
170
170
  }), _react["default"].createElement("path", {
171
- d: "M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2zm-7 5h5v5h-5z"
171
+ d: "M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"
172
172
  }))
173
173
  };
174
174
  var dateTheme = (0, _core.createMuiTheme)({
175
175
  overrides: {
176
176
  MuiTypography: {
177
177
  root: {
178
- fontFamily: "".concat(colorsTheme.date.fontFamily, " !important")
178
+ fontFamily: "".concat(colorsTheme.newDate.pickerFontFamily, " !important")
179
179
  }
180
180
  },
181
181
  MuiPickersYearSelection: {
182
182
  container: {
183
- color: colorsTheme.date.pickerYearColor,
183
+ color: colorsTheme.newDate.pickerYearFontColor,
184
184
  "&::-webkit-scrollbar": {
185
185
  width: "3px"
186
186
  },
187
187
  "&::-webkit-scrollbar-track": {
188
- backgroundColor: colorsTheme.date.scrollBarTrackColor,
188
+ backgroundColor: "#D9D9D9",
189
189
  borderRadius: "3px"
190
190
  },
191
191
  "&::-webkit-scrollbar-thumb": {
192
- backgroundColor: colorsTheme.date.scrollBarThumbColor,
192
+ backgroundColor: "#666666",
193
193
  borderRadius: "3px"
194
194
  }
195
195
  }
196
196
  },
197
197
  MuiPickersToolbar: {
198
198
  toolbar: {
199
- backgroundColor: colorsTheme.date.pickerBackgroundColor,
200
- color: colorsTheme.date.pickerFontColor
199
+ backgroundColor: colorsTheme.newDate.pickerBackgroundColor,
200
+ color: colorsTheme.newDate.pickerDayFontColor
201
201
  }
202
202
  },
203
203
  MuiIconButton: {
@@ -215,7 +215,7 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
215
215
  MuiButtonBase: {
216
216
  root: {
217
217
  "&:focus": {
218
- outline: colorsTheme.date.focusColor + " 2px solid"
218
+ outline: colorsTheme.newDate.pickerFocusColor + " solid 2px"
219
219
  }
220
220
  }
221
221
  },
@@ -225,38 +225,38 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
225
225
  maxWidth: "unset",
226
226
  minHeight: "unset",
227
227
  padding: "0px 10px",
228
- height: colorsTheme.date.pickerHeight,
229
- width: colorsTheme.date.pickerWidth,
230
- backgroundColor: colorsTheme.date.pickerBackgroundColor,
231
- fontFamily: colorsTheme.date.fontFamily
228
+ height: colorsTheme.newDate.pickerHeight,
229
+ width: colorsTheme.newDate.pickerWidth,
230
+ backgroundColor: colorsTheme.newDate.pickerBackgroundColor,
231
+ fontFamily: colorsTheme.newDate.pickerFontFamily
232
232
  }
233
233
  },
234
234
  MuiPickersToolbarText: {
235
235
  toolbarTxt: {
236
- color: colorsTheme === null || colorsTheme === void 0 ? void 0 : (_colorsTheme$date = colorsTheme.date) === null || _colorsTheme$date === void 0 ? void 0 : _colorsTheme$date.pickerActualDate,
237
- fontFamily: colorsTheme === null || colorsTheme === void 0 ? void 0 : (_colorsTheme$date2 = colorsTheme.date) === null || _colorsTheme$date2 === void 0 ? void 0 : _colorsTheme$date2.fontFamily,
236
+ color: colorsTheme.newDate.pickerActualDateFontColor,
237
+ fontFamily: colorsTheme.newDate.pickerFontFamily,
238
238
  fontSize: "2rem"
239
239
  },
240
240
  toolbarBtnSelected: {
241
- color: colorsTheme.date.pickerActualDate
241
+ color: colorsTheme.newDate.pickerActualDateFontColor
242
242
  }
243
243
  },
244
244
  MuiPickersCalendarHeader: {
245
245
  transitionContainer: {
246
- color: colorsTheme.date.pickerMonthColor
246
+ color: colorsTheme.newDate.pickerMonthFontColor
247
247
  },
248
248
  dayLabel: {
249
- color: colorsTheme.date.pickerWeekLabelColor,
250
- fontFamily: colorsTheme.date.fontFamily
249
+ color: colorsTheme.newDate.pickerWeekFontColor,
250
+ fontFamily: colorsTheme.newDate.pickerFontFamily
251
251
  },
252
252
  switchHeader: {
253
- backgroundColor: colorsTheme.white,
254
- color: colorsTheme.date.pickerFontColor
253
+ backgroundColor: "#ffffff",
254
+ color: colorsTheme.newDate.pickerDayFontColor
255
255
  },
256
256
  iconButton: {
257
- backgroundColor: colorsTheme.date.pickerBackgroundColorMonthArrows,
257
+ backgroundColor: colorsTheme.newDate.pickerMonthArrowsBackgroundColor,
258
258
  "&:hover": {
259
- backgroundColor: colorsTheme.date.pickerBackgroundColorMonthArrows
259
+ backgroundColor: colorsTheme.newDate.pickerMonthArrowsBackgroundColor
260
260
  }
261
261
  }
262
262
  },
@@ -267,38 +267,37 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
267
267
  },
268
268
  MuiPickersDay: {
269
269
  current: {
270
- border: colorsTheme.date.pickerActualDate + " 2px solid",
271
- color: colorsTheme.date.pickerFontColor
270
+ color: colorsTheme.newDate.pickerDayFontColor
272
271
  },
273
272
  day: {
274
- fontFamily: colorsTheme.date.fontFamily,
275
- color: colorsTheme.date.pickerFontColor,
273
+ fontFamily: colorsTheme.newDate.pickerFontFamily,
274
+ color: colorsTheme.newDate.pickerDayFontColor,
276
275
  "&:hover": {
277
- backgroundColor: colorsTheme.date.pickerHoverDateBackgroundColor,
278
- color: colorsTheme.date.pickerHoverDateFontColor
276
+ backgroundColor: colorsTheme.newDate.pickerHoverDateBackgroundColor,
277
+ color: colorsTheme.newDate.pickerHoverDateFontColor
279
278
  }
280
279
  },
281
280
  daySelected: {
282
- backgroundColor: colorsTheme.date.pickerSelectedDateBackgroundColor,
283
- color: colorsTheme.date.pickerSelectedDateColor,
281
+ backgroundColor: colorsTheme.newDate.pickerSelectedDateBackgroundColor,
282
+ color: colorsTheme.newDate.pickerSelectedDateColor,
284
283
  "&:hover": {
285
- backgroundColor: colorsTheme.date.pickerSelectedDateBackgroundColor,
286
- color: colorsTheme.date.pickerSelectedDateColor,
284
+ backgroundColor: colorsTheme.newDate.pickerSelectedDateBackgroundColor,
285
+ color: colorsTheme.newDate.pickerSelectedDateColor,
287
286
  opacity: "1"
288
287
  }
289
288
  }
290
289
  },
291
290
  MuiPickersYear: {
292
291
  yearSelected: {
293
- color: colorsTheme.date.pickerSelectedDateColor,
294
- backgroundColor: colorsTheme.date.pickerSelectedDateBackgroundColor,
292
+ color: colorsTheme.newDate.pickerSelectedDateColor,
293
+ backgroundColor: colorsTheme.newDate.pickerSelectedDateBackgroundColor,
295
294
  margin: "0px 100px",
296
295
  borderRadius: "20px"
297
296
  },
298
297
  root: {
299
298
  "&:focus": {
300
- color: colorsTheme.date.pickerHoverDateFontColor,
301
- backgroundColor: colorsTheme.date.pickerHoverDateBackgroundColor
299
+ color: colorsTheme.newDate.pickerHoverDateFontColor,
300
+ backgroundColor: colorsTheme.newDate.pickerHoverDateBackgroundColor
302
301
  }
303
302
  }
304
303
  },
@@ -327,7 +326,8 @@ var DxcNewDate = _react["default"].forwardRef(function (_ref, ref) {
327
326
  optional: optional,
328
327
  onChange: handleIOnChange,
329
328
  onBlur: handleIOnBlur,
330
- error: error || validationError,
329
+ error: error,
330
+ autocomplete: autocomplete,
331
331
  margin: margin,
332
332
  size: size,
333
333
  tabIndex: tabIndex,
@@ -386,6 +386,7 @@ DxcNewDate.propTypes = {
386
386
  onChange: _propTypes["default"].func,
387
387
  onBlur: _propTypes["default"].func,
388
388
  error: _propTypes["default"].string,
389
+ autocomplete: _propTypes["default"].string,
389
390
  size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
390
391
  margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
391
392
  top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
@@ -0,0 +1,95 @@
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
+
10
+ type Props = {
11
+ /**
12
+ * Text to be placed above the date.
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Name attribute of the input element.
17
+ */
18
+ name?: string;
19
+ /**
20
+ * Value of the input element. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
21
+ */
22
+ value?: string;
23
+ /**
24
+ * 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.
25
+ */
26
+ format?: string;
27
+ /**
28
+ * Helper text to be placed above the date.
29
+ */
30
+ helperText?: string;
31
+ /**
32
+ * If true, the date format will appear as placeholder in the field.
33
+ */
34
+ placeholder?: boolean;
35
+ /**
36
+ * If true, the date will have an action to clear the entered value.
37
+ */
38
+ clearable?: boolean;
39
+ /**
40
+ * If true, the component will be disabled.
41
+ */
42
+ disabled?: boolean;
43
+ /**
44
+ * If true, the date will be optional, showing '(Optional)'
45
+ * next to the label. Otherwise, the field will be considered required and an error will be
46
+ * passed as a parameter to the OnBlur and onChange functions when it has
47
+ * not been filled.
48
+ */
49
+ optional?: boolean;
50
+ /**
51
+ * This function will be called when the user types within the input
52
+ * element of the component. An object including the string value, the
53
+ * error and the date value will be passed to this function.
54
+ * If the string value is a valid date, error will
55
+ * be null. Also, if the string value is not a valid date, date will be null.
56
+ */
57
+ onChange?: (val: { value: string; error: string; date: Date }) => void;
58
+ /**
59
+ * This function will be called when the input element loses the focus.
60
+ * An object including the string value, the error and the date value
61
+ * will be passed to this function. If the string value is a valid date, error will
62
+ * be null. Also, if the string value is not a valid date, date will be null.
63
+ */
64
+ onBlur?: (val: { value: string; error: string; date: Date }) => void;
65
+ /**
66
+ * If it is defined, the component will change its appearance, showing
67
+ * the error below the date component. If it is not defined, the error
68
+ * messages will be managed internally, but never displayed on its own.
69
+ */
70
+ error?: string;
71
+ /**
72
+ * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the input value.
73
+ * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
74
+ */
75
+ autocomplete?: string;
76
+ /**
77
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
78
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
79
+ */
80
+ margin?: Space | Margin;
81
+ /**
82
+ * Size of the component ('medium' | 'large' | 'fillParent').
83
+ */
84
+ size?: Size;
85
+ /**
86
+ * Value of the tabindex attribute.
87
+ */
88
+ tabIndex?: number;
89
+ /**
90
+ * Reference to the component.
91
+ */
92
+ ref?: React.RefObject<HTMLDivElement>;
93
+ };
94
+
95
+ export default function DxcNewDate(props: Props): JSX.Element;