@dxc-technology/halstack-react 6.2.2 → 8.0.0
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.
- package/HalstackContext.js +7 -8
- package/accordion/types.d.ts +1 -0
- package/accordion-group/types.d.ts +1 -0
- package/box/types.d.ts +1 -0
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +16 -15
- package/checkbox/Checkbox.stories.tsx +79 -59
- package/checkbox/types.d.ts +4 -0
- package/common/variables.js +19 -15
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +77 -222
- package/date-input/DateInput.stories.tsx +30 -17
- package/date-input/DateInput.test.js +411 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +160 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +115 -0
- package/date-input/types.d.ts +53 -0
- package/dialog/types.d.ts +1 -0
- package/dropdown/Dropdown.js +35 -31
- package/dropdown/Dropdown.test.js +18 -24
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +177 -219
- package/file-input/FileInput.stories.tsx +38 -10
- package/file-input/FileInput.test.js +53 -12
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +38 -63
- package/file-input/types.d.ts +17 -0
- package/flex/Flex.d.ts +1 -1
- package/flex/Flex.js +31 -19
- package/flex/types.d.ts +14 -3
- package/footer/types.d.ts +1 -0
- package/header/types.d.ts +1 -0
- package/link/Link.js +1 -1
- package/number-input/NumberInput.test.js +43 -7
- package/package.json +7 -12
- package/paginator/Paginator.js +2 -2
- package/paginator/Paginator.test.js +1 -1
- package/password-input/PasswordInput.test.js +13 -12
- package/quick-nav/QuickNav.js +11 -12
- package/quick-nav/QuickNav.stories.tsx +97 -19
- package/radio-group/RadioGroup.js +9 -5
- package/radio-group/RadioGroup.test.js +116 -59
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +48 -107
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +23 -41
- package/resultsetTable/types.d.ts +2 -2
- package/select/Select.js +3 -1
- package/select/Select.stories.tsx +2 -5
- package/select/Select.test.js +267 -209
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +5 -4
- package/slider/types.d.ts +4 -0
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +4 -3
- package/switch/types.d.ts +6 -1
- package/table/Table.js +1 -1
- package/table/Table.test.js +1 -1
- package/text-input/TextInput.js +165 -151
- package/text-input/TextInput.test.js +560 -649
- package/text-input/types.d.ts +5 -0
- package/common/RequiredComponent.js +0 -32
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
21
|
+
|
|
22
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
23
|
+
|
|
24
|
+
var _main = require("../main");
|
|
25
|
+
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
31
|
+
|
|
32
|
+
var getDays = function getDays(innerDate) {
|
|
33
|
+
var monthDayCells = [];
|
|
34
|
+
var lastMonthNumberOfDays = innerDate.set("month", innerDate.get("month") - 1).endOf("month");
|
|
35
|
+
var firstDayOfMonth = innerDate.startOf("month").day() === 0 ? 6 : innerDate.startOf("month").day() - 1;
|
|
36
|
+
var daysInMonth = firstDayOfMonth + innerDate.daysInMonth();
|
|
37
|
+
|
|
38
|
+
for (var i = 0; i < 42; i++) {
|
|
39
|
+
if (i < firstDayOfMonth) {
|
|
40
|
+
monthDayCells.push({
|
|
41
|
+
day: lastMonthNumberOfDays.get("date") - firstDayOfMonth + i + 1,
|
|
42
|
+
month: innerDate.get("month") ? innerDate.get("month") - 1 : 11,
|
|
43
|
+
year: innerDate.set("month", innerDate.get("month") - 1).get("year")
|
|
44
|
+
});
|
|
45
|
+
} else if (i < daysInMonth) {
|
|
46
|
+
monthDayCells.push({
|
|
47
|
+
day: i - firstDayOfMonth + 1,
|
|
48
|
+
month: innerDate.get("month"),
|
|
49
|
+
year: innerDate.get("year")
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
monthDayCells.push({
|
|
53
|
+
day: i - daysInMonth + 1,
|
|
54
|
+
month: innerDate.get("month") === 11 ? 0 : innerDate.get("month") + 1,
|
|
55
|
+
year: innerDate.set("month", innerDate.get("month") + 1).get("year")
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return monthDayCells;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var isDaySelected = function isDaySelected(date, selectedDate) {
|
|
64
|
+
return (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("month")) === date.month && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("year")) === date.year && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("date")) === date.day;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var Calendar = function Calendar(_ref) {
|
|
68
|
+
var selectedDate = _ref.selectedDate,
|
|
69
|
+
innerDate = _ref.innerDate,
|
|
70
|
+
onInnerDateChange = _ref.onInnerDateChange,
|
|
71
|
+
onDaySelect = _ref.onDaySelect;
|
|
72
|
+
|
|
73
|
+
var _useState = (0, _react.useState)((selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("month")) === innerDate.get("month") && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("year")) === innerDate.get("year") ? selectedDate : (0, _dayjs["default"])()),
|
|
74
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
75
|
+
dateToFocus = _useState2[0],
|
|
76
|
+
setDateToFocus = _useState2[1];
|
|
77
|
+
|
|
78
|
+
var _useState3 = (0, _react.useState)(false),
|
|
79
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
80
|
+
toFocus = _useState4[0],
|
|
81
|
+
setToFocus = _useState4[1];
|
|
82
|
+
|
|
83
|
+
var today = (0, _dayjs["default"])();
|
|
84
|
+
var dayCells = (0, _react.useMemo)(function () {
|
|
85
|
+
return getDays(innerDate);
|
|
86
|
+
}, [innerDate]);
|
|
87
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
88
|
+
var weekDays = translatedLabels.calendar.daysShort;
|
|
89
|
+
|
|
90
|
+
var onDateClickHandler = function onDateClickHandler(date) {
|
|
91
|
+
var newDate = innerDate.set("month", date.month).set("date", date.day);
|
|
92
|
+
onDaySelect(newDate);
|
|
93
|
+
setDateToFocus(newDate);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var handleOnBlur = function handleOnBlur(event) {
|
|
97
|
+
if (!(event !== null && event !== void 0 && event.currentTarget.contains(event.relatedTarget))) {
|
|
98
|
+
updateDateToFocus();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var updateDateToFocus = function updateDateToFocus() {
|
|
103
|
+
if ((selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("month")) === innerDate.get("month") && (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.get("year")) === innerDate.get("year")) {
|
|
104
|
+
setDateToFocus(selectedDate);
|
|
105
|
+
} else if (today.get("month") === innerDate.get("month") && today.get("year") === innerDate.get("year")) {
|
|
106
|
+
setDateToFocus(today);
|
|
107
|
+
} else {
|
|
108
|
+
setDateToFocus(innerDate.set("date", 1));
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
var focusDate = function focusDate(date) {
|
|
113
|
+
if (innerDate.get("month") !== date.get("month") || innerDate.get("year") !== date.get("year")) {
|
|
114
|
+
onInnerDateChange(date);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setDateToFocus(date);
|
|
118
|
+
setToFocus(true);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
(0, _react.useEffect)(function () {
|
|
122
|
+
if (toFocus) {
|
|
123
|
+
var _document$getElementB;
|
|
124
|
+
|
|
125
|
+
(_document$getElementB = document.getElementById("day_".concat(dateToFocus.get("date"), "_month").concat(dateToFocus.get("month")))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.focus();
|
|
126
|
+
setToFocus(false);
|
|
127
|
+
}
|
|
128
|
+
}, [dateToFocus, toFocus]);
|
|
129
|
+
(0, _react.useEffect)(function () {
|
|
130
|
+
if (dateToFocus.get("month") !== innerDate.get("month") || dateToFocus.get("year") !== innerDate.get("year")) {
|
|
131
|
+
updateDateToFocus();
|
|
132
|
+
}
|
|
133
|
+
}, [innerDate, dateToFocus, selectedDate]);
|
|
134
|
+
|
|
135
|
+
var handleDayKeyboardEvent = function handleDayKeyboardEvent(event, date) {
|
|
136
|
+
var dateToFocusTemp = date.month === innerDate.get("month") ? innerDate.set("date", date.day) : innerDate.set("date", date.day).set("month", date.month);
|
|
137
|
+
|
|
138
|
+
switch (event.key) {
|
|
139
|
+
case "PageUp":
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
event.shiftKey ? dateToFocusTemp = dateToFocusTemp.set("year", dateToFocusTemp.get("year") - 1) : dateToFocusTemp = dateToFocusTemp.set("month", dateToFocusTemp.get("month") - 1);
|
|
142
|
+
focusDate(dateToFocusTemp);
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case "PageDown":
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
event.shiftKey ? dateToFocusTemp = dateToFocusTemp.set("year", dateToFocusTemp.get("year") + 1) : dateToFocusTemp = dateToFocusTemp.set("month", dateToFocusTemp.get("month") + 1);
|
|
148
|
+
focusDate(dateToFocusTemp);
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case "ArrowLeft":
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
dateToFocusTemp = dateToFocusTemp.set("date", dateToFocusTemp.get("date") - 1);
|
|
154
|
+
focusDate(dateToFocusTemp);
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
case "ArrowRight":
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
dateToFocusTemp = dateToFocusTemp.set("date", dateToFocusTemp.get("date") + 1);
|
|
160
|
+
focusDate(dateToFocusTemp);
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case "ArrowUp":
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
dateToFocusTemp = dateToFocusTemp.set("date", dateToFocusTemp.get("date") - 7);
|
|
166
|
+
focusDate(dateToFocusTemp);
|
|
167
|
+
break;
|
|
168
|
+
|
|
169
|
+
case "ArrowDown":
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
dateToFocusTemp = dateToFocusTemp.set("date", dateToFocusTemp.get("date") + 7);
|
|
172
|
+
focusDate(dateToFocusTemp);
|
|
173
|
+
break;
|
|
174
|
+
|
|
175
|
+
case "Home":
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
dateToFocus.get("day") !== 0 ? dateToFocusTemp = dateToFocusTemp.day(1) : dateToFocusTemp = innerDate.date(date.day - 1).day(1);
|
|
178
|
+
focusDate(dateToFocusTemp);
|
|
179
|
+
break;
|
|
180
|
+
|
|
181
|
+
case "End":
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
dateToFocusTemp.get("day") !== 0 && (dateToFocusTemp = dateToFocusTemp.day(7));
|
|
184
|
+
focusDate(dateToFocusTemp);
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
case " ":
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
onDaySelect(dateToFocusTemp);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return /*#__PURE__*/_react["default"].createElement(CalendarContainer, null, /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
|
|
195
|
+
alignItems: "center",
|
|
196
|
+
justifyContent: "space-between"
|
|
197
|
+
}, weekDays.map(function (weekDay) {
|
|
198
|
+
return /*#__PURE__*/_react["default"].createElement(WeekHeaderCell, {
|
|
199
|
+
key: weekDay
|
|
200
|
+
}, weekDay);
|
|
201
|
+
})), /*#__PURE__*/_react["default"].createElement(DayCellsContainer, {
|
|
202
|
+
onBlur: handleOnBlur
|
|
203
|
+
}, dayCells.map(function (date, index) {
|
|
204
|
+
return date !== 0 ? /*#__PURE__*/_react["default"].createElement(DayCell, {
|
|
205
|
+
onKeyDown: function onKeyDown(event) {
|
|
206
|
+
return handleDayKeyboardEvent(event, date);
|
|
207
|
+
},
|
|
208
|
+
"aria-label": date.day,
|
|
209
|
+
id: "day_".concat(date.day, "_month").concat(date.month),
|
|
210
|
+
key: "day_".concat(index),
|
|
211
|
+
onClick: function onClick() {
|
|
212
|
+
return onDateClickHandler(date);
|
|
213
|
+
},
|
|
214
|
+
selected: isDaySelected(date, selectedDate),
|
|
215
|
+
actualMonth: date.month === innerDate.get("month"),
|
|
216
|
+
autoFocus: date.day === dateToFocus.get("date") && date.month === dateToFocus.get("month"),
|
|
217
|
+
"aria-selected": isDaySelected(date, selectedDate),
|
|
218
|
+
tabIndex: date.day === dateToFocus.get("date") && date.month === dateToFocus.get("month") ? 0 : -1,
|
|
219
|
+
isCurrentDay: today.get("date") === date.day && today.get("month") === innerDate.get("month") && today.get("month") === date.month && today.get("year") === innerDate.get("year")
|
|
220
|
+
}, date.day) : /*#__PURE__*/_react["default"].createElement(EmptyDayCell, {
|
|
221
|
+
key: "empty_".concat(index)
|
|
222
|
+
});
|
|
223
|
+
})));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
var CalendarContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n justify-content: center;\n padding: 0px 8px 8px 8px;\n width: ", ";\n"])), function (props) {
|
|
227
|
+
return props.theme.dateInput.pickerWidth;
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
var WeekHeaderCell = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n font-family: ", ";\n font-size: 14px;\n line-height: 19px;\n color: ", ";\n"])), function (props) {
|
|
231
|
+
return props.theme.dateInput.pickerFontFamily;
|
|
232
|
+
}, function (props) {
|
|
233
|
+
return props.theme.dateInput.pickerWeekFontColor;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
var DayCellsContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n gap: 4px;\n flex-wrap: wrap;\n justify-content: space-between;\n"])));
|
|
237
|
+
|
|
238
|
+
var DayCell = _styledComponents["default"].button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n width: 36px;\n height: 36px;\n padding: 0;\n font-size: 0.875rem;\n font-family: ", ";\n font-weight: 400;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n\n &:focus {\n outline: ", " solid 2px;\n }\n &:hover {\n background-color: ", ";\n color: ", ";\n }\n &:active {\n background-color: #4b1c7d;\n color: #ffffff;\n }\n\n ", "\n background-color: ", ";\n color: ", ";\n"])), function (props) {
|
|
239
|
+
return props.theme.dateInput.pickerFontFamily;
|
|
240
|
+
}, function (props) {
|
|
241
|
+
return props.theme.dateInput.pickerFocusColor;
|
|
242
|
+
}, function (props) {
|
|
243
|
+
return props.selected ? props.theme.dateInput.pickerSelectedDateBackgroundColor : props.theme.dateInput.pickerHoverDateBackgroundColor;
|
|
244
|
+
}, function (props) {
|
|
245
|
+
return props.selected ? props.theme.dateInput.pickerSelectedDateColor : props.theme.dateInput.pickerHoverDateFontColor;
|
|
246
|
+
}, function (props) {
|
|
247
|
+
return props.isCurrentDay && !props.selected && "border: 1px solid #cbacec;";
|
|
248
|
+
}, function (props) {
|
|
249
|
+
return props.selected ? props.theme.dateInput.pickerSelectedDateBackgroundColor : "transparent";
|
|
250
|
+
}, function (props) {
|
|
251
|
+
return props.selected ? props.theme.dateInput.pickerSelectedDateColor : props.isCurrentDay ? props.theme.dateInput.pickerActualDateFontColor : !props.actualMonth ? "#999999" : props.theme.dateInput.pickerDayFontColor;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
var EmptyDayCell = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-block;\n width: 40px;\n height: 36px;\n"])));
|
|
255
|
+
|
|
256
|
+
var _default = /*#__PURE__*/_react["default"].memo(Calendar);
|
|
257
|
+
|
|
258
|
+
exports["default"] = _default;
|
package/date-input/DateInput.js
CHANGED
|
@@ -17,18 +17,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
17
17
|
|
|
18
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
19
|
|
|
20
|
-
var _pickers = require("@material-ui/pickers");
|
|
21
|
-
|
|
22
|
-
var _core = require("@material-ui/core");
|
|
23
|
-
|
|
24
|
-
var _ClickAwayListener = _interopRequireDefault(require("@material-ui/core/ClickAwayListener"));
|
|
25
|
-
|
|
26
|
-
var _Popover = _interopRequireDefault(require("@material-ui/core/Popover"));
|
|
27
|
-
|
|
28
20
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
29
21
|
|
|
30
|
-
var _dayjs2 = _interopRequireDefault(require("@date-io/dayjs"));
|
|
31
|
-
|
|
32
22
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
33
23
|
|
|
34
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
@@ -37,6 +27,14 @@ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabel
|
|
|
37
27
|
|
|
38
28
|
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
39
29
|
|
|
30
|
+
var _DatePicker = _interopRequireDefault(require("./DatePicker"));
|
|
31
|
+
|
|
32
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
33
|
+
|
|
34
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
35
|
+
|
|
36
|
+
var _uuid = require("uuid");
|
|
37
|
+
|
|
40
38
|
var _templateObject;
|
|
41
39
|
|
|
42
40
|
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); }
|
|
@@ -47,8 +45,23 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
47
45
|
|
|
48
46
|
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; }
|
|
49
47
|
|
|
48
|
+
_dayjs["default"].extend(_customParseFormat["default"]);
|
|
49
|
+
|
|
50
|
+
var calendarIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
51
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
+
height: "24",
|
|
53
|
+
viewBox: "0 0 24 24",
|
|
54
|
+
width: "24",
|
|
55
|
+
fill: "currentColor"
|
|
56
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
57
|
+
d: "M0 0h24v24H0z",
|
|
58
|
+
fill: "none"
|
|
59
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
60
|
+
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"
|
|
61
|
+
}));
|
|
62
|
+
|
|
50
63
|
var getValueForPicker = function getValueForPicker(value, format) {
|
|
51
|
-
return (0, _dayjs["default"])(value, format.toUpperCase(), true)
|
|
64
|
+
return (0, _dayjs["default"])(value, format.toUpperCase(), true);
|
|
52
65
|
};
|
|
53
66
|
|
|
54
67
|
var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
@@ -83,29 +96,28 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
83
96
|
isOpen = _useState4[0],
|
|
84
97
|
setIsOpen = _useState4[1];
|
|
85
98
|
|
|
86
|
-
var _useState5 = (0, _react.useState)(
|
|
87
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5,
|
|
88
|
-
|
|
89
|
-
setAnchorEl = _useState6[1];
|
|
99
|
+
var _useState5 = (0, _react.useState)("date-picker-".concat((0, _uuid.v4)())),
|
|
100
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 1),
|
|
101
|
+
calendarId = _useState6[0];
|
|
90
102
|
|
|
91
103
|
var colorsTheme = (0, _useTheme["default"])();
|
|
92
104
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
var dateRef = (0, _react.useRef)(null);
|
|
106
|
+
(0, _react.useLayoutEffect)(function () {
|
|
107
|
+
if (!disabled) {
|
|
108
|
+
var actionButtonRef = dateRef === null || dateRef === void 0 ? void 0 : dateRef.current.querySelector("[title='Open calendar']");
|
|
109
|
+
actionButtonRef === null || actionButtonRef === void 0 ? void 0 : actionButtonRef.setAttribute("aria-haspopup", true);
|
|
110
|
+
actionButtonRef === null || actionButtonRef === void 0 ? void 0 : actionButtonRef.setAttribute("role", "combobox");
|
|
111
|
+
actionButtonRef === null || actionButtonRef === void 0 ? void 0 : actionButtonRef.setAttribute("aria-expanded", isOpen);
|
|
112
|
+
actionButtonRef === null || actionButtonRef === void 0 ? void 0 : actionButtonRef.setAttribute("aria-controls", calendarId);
|
|
113
|
+
actionButtonRef === null || actionButtonRef === void 0 ? void 0 : actionButtonRef.setAttribute("aria-describedby", calendarId);
|
|
102
114
|
}
|
|
103
|
-
};
|
|
115
|
+
}, [isOpen, disabled, calendarId]);
|
|
104
116
|
|
|
105
117
|
var handleCalendarOnClick = function handleCalendarOnClick(newDate) {
|
|
106
|
-
var newValue =
|
|
118
|
+
var newValue = newDate.format(format.toUpperCase());
|
|
107
119
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
108
|
-
newDate !== null && newDate !== void 0 && newDate.toJSON() ? onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
120
|
+
newDate !== null && newDate !== void 0 && newDate.set("day", newDate.get("date")).toJSON() ? onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
109
121
|
value: newValue,
|
|
110
122
|
date: newDate
|
|
111
123
|
}) : onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
@@ -117,7 +129,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
117
129
|
var newValue = _ref2.value,
|
|
118
130
|
inputError = _ref2.error;
|
|
119
131
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
120
|
-
var dayjsDate = (
|
|
132
|
+
var dayjsDate = getValueForPicker(newValue, format);
|
|
121
133
|
var invalidDateMessage = newValue !== "" && !dayjsDate.isValid() && translatedLabels.dateInput.invalidDateErrorMessage;
|
|
122
134
|
var callbackParams = inputError || invalidDateMessage ? {
|
|
123
135
|
value: newValue,
|
|
@@ -133,7 +145,7 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
133
145
|
var handleIOnBlur = function handleIOnBlur(_ref3) {
|
|
134
146
|
var value = _ref3.value,
|
|
135
147
|
inputError = _ref3.error;
|
|
136
|
-
var dayjsDate = (
|
|
148
|
+
var dayjsDate = getValueForPicker(value, format);
|
|
137
149
|
var invalidDateMessage = value !== "" && !dayjsDate.isValid() && translatedLabels.dateInput.invalidDateErrorMessage;
|
|
138
150
|
var callbackParams = inputError || invalidDateMessage ? {
|
|
139
151
|
value: value,
|
|
@@ -147,181 +159,44 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
147
159
|
};
|
|
148
160
|
|
|
149
161
|
var openCalendar = function openCalendar() {
|
|
150
|
-
var dateBtn = refDate.current.getElementsByTagName("button")[0];
|
|
151
162
|
setIsOpen(!isOpen);
|
|
152
|
-
setAnchorEl(dateBtn);
|
|
153
163
|
};
|
|
154
164
|
|
|
155
165
|
var closeCalendar = function closeCalendar() {
|
|
156
166
|
setIsOpen(false);
|
|
157
167
|
};
|
|
158
168
|
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
height: "24",
|
|
164
|
-
viewBox: "0 0 24 24",
|
|
165
|
-
width: "24",
|
|
166
|
-
fill: "currentColor"
|
|
167
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
168
|
-
d: "M0 0h24v24H0z",
|
|
169
|
-
fill: "none"
|
|
170
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
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
|
-
}))
|
|
169
|
+
var handleDatePickerEscKeydown = function handleDatePickerEscKeydown(event) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
closeCalendar();
|
|
172
|
+
dateRef === null || dateRef === void 0 ? void 0 : dateRef.current.getElementsByTagName("input")[0].focus();
|
|
173
173
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
MuiPickersYearSelection: {
|
|
182
|
-
container: {
|
|
183
|
-
color: colorsTheme.dateInput.pickerYearFontColor,
|
|
184
|
-
"&::-webkit-scrollbar": {
|
|
185
|
-
width: "3px"
|
|
186
|
-
},
|
|
187
|
-
"&::-webkit-scrollbar-track": {
|
|
188
|
-
backgroundColor: "#D9D9D9",
|
|
189
|
-
borderRadius: "3px"
|
|
190
|
-
},
|
|
191
|
-
"&::-webkit-scrollbar-thumb": {
|
|
192
|
-
backgroundColor: "#666666",
|
|
193
|
-
borderRadius: "3px"
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
MuiPickersToolbar: {
|
|
198
|
-
toolbar: {
|
|
199
|
-
backgroundColor: colorsTheme.dateInput.pickerBackgroundColor,
|
|
200
|
-
color: colorsTheme.dateInput.pickerDayFontColor
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
MuiIconButton: {
|
|
204
|
-
root: {
|
|
205
|
-
height: "36px",
|
|
206
|
-
width: "36px",
|
|
207
|
-
padding: "0px"
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
MuiTouchRipple: {
|
|
211
|
-
child: {
|
|
212
|
-
opacity: "0"
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
MuiButtonBase: {
|
|
216
|
-
root: {
|
|
217
|
-
"&:focus": {
|
|
218
|
-
outline: colorsTheme.dateInput.pickerFocusColor + " solid 2px"
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
MuiPickersBasePicker: {
|
|
223
|
-
pickerView: {
|
|
224
|
-
minWidth: "unset",
|
|
225
|
-
maxWidth: "unset",
|
|
226
|
-
minHeight: "unset",
|
|
227
|
-
padding: "0px 10px",
|
|
228
|
-
height: colorsTheme.dateInput.pickerHeight,
|
|
229
|
-
width: colorsTheme.dateInput.pickerWidth,
|
|
230
|
-
backgroundColor: colorsTheme.dateInput.pickerBackgroundColor,
|
|
231
|
-
fontFamily: colorsTheme.dateInput.pickerFontFamily
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
MuiPickersToolbarText: {
|
|
235
|
-
toolbarTxt: {
|
|
236
|
-
color: colorsTheme.dateInput.pickerActualDateFontColor,
|
|
237
|
-
fontFamily: colorsTheme.dateInput.pickerFontFamily,
|
|
238
|
-
fontSize: "2rem"
|
|
239
|
-
},
|
|
240
|
-
toolbarBtnSelected: {
|
|
241
|
-
color: colorsTheme.dateInput.pickerActualDateFontColor
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
MuiPickersCalendarHeader: {
|
|
245
|
-
transitionContainer: {
|
|
246
|
-
color: colorsTheme.dateInput.pickerMonthFontColor
|
|
247
|
-
},
|
|
248
|
-
dayLabel: {
|
|
249
|
-
color: colorsTheme.dateInput.pickerWeekFontColor,
|
|
250
|
-
fontFamily: colorsTheme.dateInput.pickerFontFamily
|
|
251
|
-
},
|
|
252
|
-
switchHeader: {
|
|
253
|
-
backgroundColor: "#ffffff",
|
|
254
|
-
color: colorsTheme.dateInput.pickerDayFontColor
|
|
255
|
-
},
|
|
256
|
-
iconButton: {
|
|
257
|
-
backgroundColor: colorsTheme.dateInput.pickerMonthArrowsBackgroundColor,
|
|
258
|
-
"&:hover": {
|
|
259
|
-
backgroundColor: colorsTheme.dateInput.pickerMonthArrowsBackgroundColor
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
MuiPickersCalendar: {
|
|
264
|
-
week: {
|
|
265
|
-
marginBottom: "2px"
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
MuiPickersDay: {
|
|
269
|
-
current: {
|
|
270
|
-
color: colorsTheme.dateInput.pickerDayFontColor
|
|
271
|
-
},
|
|
272
|
-
day: {
|
|
273
|
-
fontFamily: colorsTheme.dateInput.pickerFontFamily,
|
|
274
|
-
color: colorsTheme.dateInput.pickerDayFontColor,
|
|
275
|
-
"&:hover": {
|
|
276
|
-
backgroundColor: colorsTheme.dateInput.pickerHoverDateBackgroundColor,
|
|
277
|
-
color: colorsTheme.dateInput.pickerHoverDateFontColor
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
daySelected: {
|
|
281
|
-
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
282
|
-
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
283
|
-
"&:hover": {
|
|
284
|
-
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
285
|
-
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
286
|
-
opacity: "1"
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
MuiPickersYear: {
|
|
291
|
-
yearSelected: {
|
|
292
|
-
color: colorsTheme.dateInput.pickerSelectedDateColor,
|
|
293
|
-
backgroundColor: colorsTheme.dateInput.pickerSelectedDateBackgroundColor,
|
|
294
|
-
margin: "0px 100px",
|
|
295
|
-
borderRadius: "20px"
|
|
296
|
-
},
|
|
297
|
-
root: {
|
|
298
|
-
"&:focus": {
|
|
299
|
-
color: colorsTheme.dateInput.pickerHoverDateFontColor,
|
|
300
|
-
backgroundColor: colorsTheme.dateInput.pickerHoverDateBackgroundColor
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
MuiPickersModal: {
|
|
305
|
-
dialogAction: {
|
|
306
|
-
color: "pink"
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
});
|
|
174
|
+
|
|
175
|
+
var handleDatePickerOnBlur = function handleDatePickerOnBlur(event) {
|
|
176
|
+
if (!(event !== null && event !== void 0 && event.currentTarget.contains(event.relatedTarget))) closeCalendar();
|
|
177
|
+
};
|
|
178
|
+
|
|
311
179
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
312
180
|
theme: colorsTheme
|
|
313
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
314
|
-
|
|
315
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
316
|
-
|
|
317
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
181
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
182
|
+
ref: ref
|
|
183
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
184
|
+
open: isOpen
|
|
185
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
186
|
+
asChild: true,
|
|
187
|
+
"aria-controls": undefined
|
|
188
|
+
}, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
318
189
|
label: label,
|
|
319
190
|
name: name,
|
|
320
191
|
defaultValue: defaultValue,
|
|
321
192
|
value: value !== null && value !== void 0 ? value : innerValue,
|
|
322
193
|
helperText: helperText,
|
|
323
194
|
placeholder: placeholder ? format.toUpperCase() : null,
|
|
324
|
-
action:
|
|
195
|
+
action: {
|
|
196
|
+
onClick: openCalendar,
|
|
197
|
+
icon: calendarIcon,
|
|
198
|
+
title: "Open calendar"
|
|
199
|
+
},
|
|
325
200
|
clearable: clearable,
|
|
326
201
|
disabled: disabled,
|
|
327
202
|
optional: optional,
|
|
@@ -332,41 +207,21 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
332
207
|
margin: margin,
|
|
333
208
|
size: size,
|
|
334
209
|
tabIndex: tabIndex,
|
|
335
|
-
ref:
|
|
336
|
-
}), /*#__PURE__*/_react["default"].createElement(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
PaperProps: {
|
|
349
|
-
style: {
|
|
350
|
-
marginTop: "10px"
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}, /*#__PURE__*/_react["default"].createElement(_ClickAwayListener["default"], {
|
|
354
|
-
onClickAway: closeCalendar
|
|
355
|
-
}, /*#__PURE__*/_react["default"].createElement(_core.Paper, {
|
|
356
|
-
role: "dialog",
|
|
357
|
-
"aria-modal": "true"
|
|
358
|
-
}, /*#__PURE__*/_react["default"].createElement(_pickers.DatePicker, {
|
|
359
|
-
variant: "static",
|
|
360
|
-
value: getValueForPicker(value !== null && value !== void 0 ? value : innerValue, format),
|
|
361
|
-
onChange: function onChange(date) {
|
|
362
|
-
return handleCalendarOnClick(date);
|
|
363
|
-
},
|
|
364
|
-
format: format,
|
|
365
|
-
disabled: disabled
|
|
366
|
-
}))))))));
|
|
210
|
+
ref: dateRef
|
|
211
|
+
})), /*#__PURE__*/_react["default"].createElement(StyledContent, {
|
|
212
|
+
sideOffset: error ? -18 : 2,
|
|
213
|
+
align: "end",
|
|
214
|
+
"aria-modal": true,
|
|
215
|
+
onBlur: handleDatePickerOnBlur,
|
|
216
|
+
onEscapeKeyDown: handleDatePickerEscKeydown,
|
|
217
|
+
avoidCollisions: false
|
|
218
|
+
}, /*#__PURE__*/_react["default"].createElement(_DatePicker["default"], {
|
|
219
|
+
id: calendarId,
|
|
220
|
+
onDateSelect: handleCalendarOnClick,
|
|
221
|
+
date: getValueForPicker(value !== null && value !== void 0 ? value : innerValue, format.toUpperCase())
|
|
222
|
+
})))));
|
|
367
223
|
});
|
|
368
224
|
|
|
369
|
-
var
|
|
370
|
-
|
|
225
|
+
var StyledContent = (0, _styledComponents["default"])(Popover.Content)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n &:focus-visible {\n outline: none;\n }\n"])));
|
|
371
226
|
var _default = DxcDateInput;
|
|
372
227
|
exports["default"] = _default;
|