@dhis2-ui/calendar 8.11.2 → 8.12.1
Sign up to get free protection for your applications and to get access to all the features.
- package/build/cjs/__e2e__/{calendarInput.stories.e2e.js → calendar-input.stories.e2e.js} +21 -3
- package/build/cjs/calendar/calendar-table-cell.js +11 -9
- package/build/cjs/calendar/calendar-table-days-header.js +5 -5
- package/build/cjs/calendar/calendar-table.js +5 -2
- package/build/cjs/calendar/{index.js → calendar.js} +37 -4
- package/build/cjs/calendar/navigation-container.js +28 -33
- package/build/cjs/calendar-input/{index.js → calendar-input.js} +34 -22
- package/build/cjs/features/supports_calendar_clear_button/supports_calendar_clear_button.js +34 -0
- package/build/cjs/features/supports_calendar_clear_button.feature +23 -0
- package/build/cjs/index.js +4 -4
- package/build/cjs/locales/en/translations.json +2 -1
- package/build/cjs/stories/calendar-input.stories.js +129 -0
- package/build/cjs/stories/{calendarStoryWrapper.js → calendar-story-wrapper.js} +9 -5
- package/build/cjs/stories/calendar.stories.js +3 -3
- package/build/es/__e2e__/calendar-input.stories.e2e.js +19 -0
- package/build/es/calendar/calendar-table-cell.js +12 -10
- package/build/es/calendar/calendar-table-days-header.js +5 -5
- package/build/es/calendar/calendar-table.js +5 -2
- package/build/es/calendar/{index.js → calendar.js} +33 -1
- package/build/es/calendar/navigation-container.js +28 -33
- package/build/es/calendar-input/{index.js → calendar-input.js} +29 -21
- package/build/es/features/supports_calendar_clear_button/supports_calendar_clear_button.js +31 -0
- package/build/es/features/supports_calendar_clear_button.feature +23 -0
- package/build/es/index.js +2 -2
- package/build/es/locales/en/translations.json +2 -1
- package/build/es/stories/{calendarInput.stories.js → calendar-input.stories.js} +34 -16
- package/build/es/stories/{calendarStoryWrapper.js → calendar-story-wrapper.js} +8 -4
- package/build/es/stories/calendar.stories.js +2 -2
- package/package.json +8 -7
- package/build/cjs/calendar/calendar-prop-types.js +0 -24
- package/build/cjs/stories/calendarInput.stories.js +0 -107
- package/build/es/__e2e__/calendarInput.stories.e2e.js +0 -6
- package/build/es/calendar/calendar-prop-types.js +0 -13
@@ -0,0 +1,129 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = exports.NepaliWithNepali = exports.NepaliWithEnglish = exports.IslamicWithArabic = exports.GregorianWithEnglish = exports.GregorianWithArabic = exports.EthiopicWithEnglish = exports.EthiopicWithAmharic = exports.CalendarWithClearButton = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _calendarInput = require("../calendar-input/calendar-input.js");
|
11
|
+
|
12
|
+
var _calendarStoryWrapper = require("./calendar-story-wrapper.js");
|
13
|
+
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
+
|
16
|
+
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; }
|
17
|
+
|
18
|
+
const subtitle = "[Experimental] Calendar Input is a wrapper around Calendar displaying an input that triggers the calendar";
|
19
|
+
const description = "\nUse a CalendarInput where there is a need to let the user input a date.\n\nNote that it requires a parent, like [Box](../?path=/docs/layout-box--default), to define its size.\n\n```js\nimport { CalendarInput } from '@dhis2/ui'\n```\n";
|
20
|
+
var _default = {
|
21
|
+
title: 'CalendarInput',
|
22
|
+
component: _calendarInput.CalendarInput,
|
23
|
+
parameters: {
|
24
|
+
componentSubtitle: subtitle,
|
25
|
+
docs: {
|
26
|
+
description: {
|
27
|
+
component: description
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
};
|
32
|
+
exports.default = _default;
|
33
|
+
|
34
|
+
const buildCalendar = _ref => {
|
35
|
+
let {
|
36
|
+
date,
|
37
|
+
locale,
|
38
|
+
calendar
|
39
|
+
} = _ref;
|
40
|
+
return () => /*#__PURE__*/_react.default.createElement(_calendarStoryWrapper.CalendarStoryWrapper, {
|
41
|
+
component: _calendarInput.CalendarInput,
|
42
|
+
dir: "ltr",
|
43
|
+
timeZone: "Africa/Khartoum",
|
44
|
+
weekDayFormat: "short",
|
45
|
+
date: date,
|
46
|
+
locale: locale,
|
47
|
+
calendar: calendar
|
48
|
+
});
|
49
|
+
};
|
50
|
+
|
51
|
+
const EthiopicWithAmharic = buildCalendar({
|
52
|
+
calendar: 'ethiopic',
|
53
|
+
locale: 'am-ET',
|
54
|
+
date: '2014-02-03' // 13 Oct 2021
|
55
|
+
|
56
|
+
});
|
57
|
+
exports.EthiopicWithAmharic = EthiopicWithAmharic;
|
58
|
+
const EthiopicWithEnglish = buildCalendar({
|
59
|
+
calendar: 'ethiopic',
|
60
|
+
locale: 'en-ET',
|
61
|
+
date: '2014-02-03' // 13 Oct 2021
|
62
|
+
|
63
|
+
});
|
64
|
+
exports.EthiopicWithEnglish = EthiopicWithEnglish;
|
65
|
+
const NepaliWithNepali = buildCalendar({
|
66
|
+
calendar: 'nepali',
|
67
|
+
locale: 'ne-NP',
|
68
|
+
date: '2078-06-27' // 13 Oct 2021
|
69
|
+
|
70
|
+
});
|
71
|
+
exports.NepaliWithNepali = NepaliWithNepali;
|
72
|
+
const NepaliWithEnglish = buildCalendar({
|
73
|
+
calendar: 'nepali',
|
74
|
+
locale: 'en-NP',
|
75
|
+
date: '2078-06-27' // 13 Oct 2021
|
76
|
+
|
77
|
+
});
|
78
|
+
exports.NepaliWithEnglish = NepaliWithEnglish;
|
79
|
+
const GregorianWithEnglish = buildCalendar({
|
80
|
+
calendar: 'gregorian',
|
81
|
+
locale: 'en-CA',
|
82
|
+
date: '2021-10-13'
|
83
|
+
});
|
84
|
+
exports.GregorianWithEnglish = GregorianWithEnglish;
|
85
|
+
const GregorianWithArabic = buildCalendar({
|
86
|
+
calendar: 'gregorian',
|
87
|
+
locale: 'ar-SD',
|
88
|
+
date: '2021-10-13'
|
89
|
+
});
|
90
|
+
exports.GregorianWithArabic = GregorianWithArabic;
|
91
|
+
|
92
|
+
const IslamicWithArabic = () => {
|
93
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
94
|
+
style: {
|
95
|
+
direction: 'rtl'
|
96
|
+
}
|
97
|
+
}, /*#__PURE__*/_react.default.createElement(_calendarStoryWrapper.CalendarStoryWrapper, {
|
98
|
+
component: _calendarInput.CalendarInput,
|
99
|
+
dir: "rtl",
|
100
|
+
timeZone: "Africa/Khartoum",
|
101
|
+
weekDayFormat: "short",
|
102
|
+
date: "1477-01-13",
|
103
|
+
locale: "ar-SD",
|
104
|
+
calendar: "islamic-civil",
|
105
|
+
clearable: true
|
106
|
+
}));
|
107
|
+
};
|
108
|
+
|
109
|
+
exports.IslamicWithArabic = IslamicWithArabic;
|
110
|
+
|
111
|
+
const CalendarWithClearButton = _ref2 => {
|
112
|
+
let {
|
113
|
+
calendar = 'gregory',
|
114
|
+
date: initialDate = null
|
115
|
+
} = _ref2;
|
116
|
+
const [date, setDate] = (0, _react.useState)(initialDate);
|
117
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_calendarInput.CalendarInput, {
|
118
|
+
calendar: calendar,
|
119
|
+
date: date,
|
120
|
+
onDateSelect: date => {
|
121
|
+
setDate(date === null || date === void 0 ? void 0 : date.calendarDateString);
|
122
|
+
},
|
123
|
+
clearable: true
|
124
|
+
}), /*#__PURE__*/_react.default.createElement("div", null, "value:", /*#__PURE__*/_react.default.createElement("span", {
|
125
|
+
"data-test": "storybook-calendar-date-value"
|
126
|
+
}, date !== null && date !== void 0 ? date : 'undefined')));
|
127
|
+
};
|
128
|
+
|
129
|
+
exports.CalendarWithClearButton = CalendarWithClearButton;
|
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
13
13
|
|
14
|
-
var
|
14
|
+
var _calendar = require("../calendar/calendar.js");
|
15
15
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
17
17
|
|
@@ -27,6 +27,8 @@ const {
|
|
27
27
|
} = _multiCalendarDates.constants;
|
28
28
|
|
29
29
|
const CalendarStoryWrapper = props => {
|
30
|
+
var _selectedDate$calenda;
|
31
|
+
|
30
32
|
const {
|
31
33
|
calendar,
|
32
34
|
locale,
|
@@ -41,7 +43,9 @@ const CalendarStoryWrapper = props => {
|
|
41
43
|
const [selectedDirection, setSelectedDirection] = (0, _react.useState)(dir);
|
42
44
|
const [selectedWeekFormat, setWeekDayFormat] = (0, _react.useState)(weekDayFormat);
|
43
45
|
const [selectedLocale, setLocale] = (0, _react.useState)(locale);
|
44
|
-
const [selectedDate, setSelectedDate] = (0, _react.useState)(
|
46
|
+
const [selectedDate, setSelectedDate] = (0, _react.useState)({
|
47
|
+
calendarDateString: date
|
48
|
+
});
|
45
49
|
|
46
50
|
const changeCalendar = _ref => {
|
47
51
|
let {
|
@@ -155,7 +159,7 @@ const CalendarStoryWrapper = props => {
|
|
155
159
|
calendar: selectedCalendar,
|
156
160
|
dir: selectedDirection,
|
157
161
|
locale: selectedLocale,
|
158
|
-
date:
|
162
|
+
date: selectedDate.calendarDateString,
|
159
163
|
onDateSelect: date => {
|
160
164
|
setSelectedDate(date);
|
161
165
|
},
|
@@ -174,7 +178,7 @@ const CalendarStoryWrapper = props => {
|
|
174
178
|
"data-test": "storybook-calendar-result"
|
175
179
|
}, selectedDate.calendarDateString)), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("label", null, "iso date: "), /*#__PURE__*/_react.default.createElement("span", {
|
176
180
|
"data-test": "storybook-calendar-result-iso"
|
177
|
-
}, selectedDate.calendarDate.withCalendar('iso8601').toLocaleString('en-GB', {
|
181
|
+
}, (_selectedDate$calenda = selectedDate.calendarDate) === null || _selectedDate$calenda === void 0 ? void 0 : _selectedDate$calenda.withCalendar('iso8601').toLocaleString('en-GB', {
|
178
182
|
dateStyle: 'long'
|
179
183
|
}))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("label", null, "callback:"), JSON.stringify(selectedDate, null, 2))))));
|
180
184
|
};
|
@@ -182,7 +186,7 @@ const CalendarStoryWrapper = props => {
|
|
182
186
|
exports.CalendarStoryWrapper = CalendarStoryWrapper;
|
183
187
|
CalendarStoryWrapper.defaultProps = {
|
184
188
|
calendar: 'gregorian',
|
185
|
-
component:
|
189
|
+
component: _calendar.Calendar,
|
186
190
|
weekDayFormat: 'narrow'
|
187
191
|
};
|
188
192
|
CalendarStoryWrapper.propTypes = {
|
@@ -7,9 +7,9 @@ exports.default = exports.WithAnyCalendar = exports.Nepali = exports.Ethiopic =
|
|
7
7
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _calendar = require("../calendar/calendar.js");
|
11
11
|
|
12
|
-
var _calendarStoryWrapper = require("./
|
12
|
+
var _calendarStoryWrapper = require("./calendar-story-wrapper.js");
|
13
13
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
|
@@ -19,7 +19,7 @@ const subtitle = "[Experimental] Calendar component is useful for creating a var
|
|
19
19
|
const description = "\nUse a Calendar where there is a need to let the user select a date.\n\nNote that it requires a parent, like [Box](../?path=/docs/layout-box--default), to define its size.\n\n```js\nimport { Calendar } from '@dhis2/ui'\n```\n";
|
20
20
|
var _default = {
|
21
21
|
title: 'Calendar',
|
22
|
-
component:
|
22
|
+
component: _calendar.Calendar,
|
23
23
|
parameters: {
|
24
24
|
componentSubtitle: subtitle,
|
25
25
|
docs: {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { CalendarInput as component } from '../index.js';
|
3
|
+
import { CalendarWithClearButton } from '../stories/calendar-input.stories.js';
|
4
|
+
export default {
|
5
|
+
title: 'CalendarInputTesting',
|
6
|
+
component
|
7
|
+
};
|
8
|
+
export { EthiopicWithAmharic, EthiopicWithEnglish, NepaliWithEnglish, NepaliWithNepali, GregorianWithArabic, GregorianWithEnglish, IslamicWithArabic } from '../stories/calendar-input.stories.js';
|
9
|
+
export const TestCalendarWithClearButton = () => {
|
10
|
+
var _params$get, _params$get2;
|
11
|
+
|
12
|
+
const params = new URLSearchParams(location.search);
|
13
|
+
const calendar = (_params$get = params.get('calendar')) !== null && _params$get !== void 0 ? _params$get : 'gregory';
|
14
|
+
const initialDate = (_params$get2 = params.get('initialDate')) !== null && _params$get2 !== void 0 ? _params$get2 : null;
|
15
|
+
return /*#__PURE__*/React.createElement(CalendarWithClearButton, {
|
16
|
+
calendar: calendar,
|
17
|
+
date: initialDate
|
18
|
+
});
|
19
|
+
};
|
@@ -1,30 +1,31 @@
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
2
|
-
import { colors
|
2
|
+
import { colors } from '@dhis2/ui-constants';
|
3
3
|
import cx from 'classnames';
|
4
4
|
import PropTypes from 'prop-types';
|
5
5
|
import React from 'react';
|
6
6
|
export const CalendarTableCell = _ref => {
|
7
7
|
let {
|
8
8
|
day,
|
9
|
-
cellSize
|
9
|
+
cellSize,
|
10
|
+
selectedDate
|
10
11
|
} = _ref;
|
11
12
|
const dayHoverBackgroundColor = colors.grey200;
|
12
13
|
const selectedDayBackgroundColor = colors.teal700;
|
13
14
|
return /*#__PURE__*/React.createElement("td", {
|
14
15
|
"data-test": day === null || day === void 0 ? void 0 : day.calendarDate,
|
15
16
|
onClick: day.onClick,
|
16
|
-
className: _JSXStyle.dynamic([["
|
17
|
+
className: _JSXStyle.dynamic([["2052411850", [cellSize, cellSize, cellSize, cellSize, colors.grey900, dayHoverBackgroundColor, colors.grey300, selectedDayBackgroundColor, colors.teal600, colors.teal200, colors.grey600]]])
|
17
18
|
}, /*#__PURE__*/React.createElement("button", {
|
18
19
|
name: "day",
|
19
|
-
className: _JSXStyle.dynamic([["
|
20
|
-
isSelected: day.
|
20
|
+
className: _JSXStyle.dynamic([["2052411850", [cellSize, cellSize, cellSize, cellSize, colors.grey900, dayHoverBackgroundColor, colors.grey300, selectedDayBackgroundColor, colors.teal600, colors.teal200, colors.grey600]]]) + " " + (cx('day', {
|
21
|
+
isSelected: selectedDate === (day === null || day === void 0 ? void 0 : day.calendarDate),
|
21
22
|
isToday: day.isToday,
|
22
23
|
otherMonth: !day.isInCurrentMonth
|
23
24
|
}) || "")
|
24
25
|
}, day.label), /*#__PURE__*/React.createElement(_JSXStyle, {
|
25
|
-
id: "
|
26
|
-
dynamic: [cellSize, cellSize, cellSize, cellSize,
|
27
|
-
}, ["td.__jsx-style-dynamic-selector{width:".concat(cellSize, ";height:100%;height:").concat(cellSize, ";text-align:center;border:2px solid transparent;}"), "td.__jsx-style-dynamic-selector span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;padding:2px 2px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:2px solid transparent;min-width:16px;}", "button.__jsx-style-dynamic-selector{border:0;overflow:hidden;width:".concat(cellSize, ";height:").concat(cellSize, ";border:2px solid transparent;border-radius:3px;background:none;
|
26
|
+
id: "2052411850",
|
27
|
+
dynamic: [cellSize, cellSize, cellSize, cellSize, colors.grey900, dayHoverBackgroundColor, colors.grey300, selectedDayBackgroundColor, colors.teal600, colors.teal200, colors.grey600]
|
28
|
+
}, ["td.__jsx-style-dynamic-selector{width:".concat(cellSize, ";height:100%;height:").concat(cellSize, ";text-align:center;border:2px solid transparent;padding:0;}"), "td.__jsx-style-dynamic-selector span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;padding:2px 2px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:2px solid transparent;min-width:16px;}", "button.__jsx-style-dynamic-selector{border:0;overflow:hidden;width:".concat(cellSize, ";height:").concat(cellSize, ";border:2px solid transparent;border-radius:3px;background:none;color:").concat(colors.grey900, ";}"), "button.__jsx-style-dynamic-selector:hover{background-color:".concat(dayHoverBackgroundColor, ";-webkit-text-decoration:underline;text-decoration:underline;cursor:pointer;}"), "button.__jsx-style-dynamic-selector:active{background-color:".concat(colors.grey300, ";}"), "button.isSelected.__jsx-style-dynamic-selector,button.otherMonth.isSelected.__jsx-style-dynamic-selector{background-color:".concat(selectedDayBackgroundColor, ";color:white;}"), "button.isToday.__jsx-style-dynamic-selector{position:relative;}", "button.isToday.__jsx-style-dynamic-selector::after{content:'';position:absolute;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);height:4px;width:4px;bottom:2px;left:50%;border-radius:100%;background-color:".concat(colors.teal600, ";}"), "button.isSelected.isToday.__jsx-style-dynamic-selector::after{background-color:".concat(colors.teal200, ";}"), "button.otherMonth.__jsx-style-dynamic-selector{color:".concat(colors.grey600, ";}")]));
|
28
29
|
};
|
29
30
|
CalendarTableCell.propTypes = {
|
30
31
|
cellSize: PropTypes.string,
|
@@ -33,7 +34,8 @@ CalendarTableCell.propTypes = {
|
|
33
34
|
isInCurrentMonth: PropTypes.bool,
|
34
35
|
isSelected: PropTypes.bool,
|
35
36
|
isToday: PropTypes.bool,
|
36
|
-
label: PropTypes.string,
|
37
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
37
38
|
onClick: PropTypes.func
|
38
|
-
})
|
39
|
+
}),
|
40
|
+
selectedDate: PropTypes.string
|
39
41
|
};
|
@@ -8,17 +8,17 @@ export const CalendarTableDaysHeader = _ref => {
|
|
8
8
|
} = _ref;
|
9
9
|
const dayNamesColor = colors.grey700;
|
10
10
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("thead", {
|
11
|
-
className: _JSXStyle.dynamic([["
|
11
|
+
className: _JSXStyle.dynamic([["1577512909", [dayNamesColor]]])
|
12
12
|
}, /*#__PURE__*/React.createElement("tr", {
|
13
|
-
className: _JSXStyle.dynamic([["
|
13
|
+
className: _JSXStyle.dynamic([["1577512909", [dayNamesColor]]])
|
14
14
|
}, weekDayLabels.map((label, i) => /*#__PURE__*/React.createElement("th", {
|
15
15
|
scope: "col",
|
16
16
|
key: "weekday-".concat(i),
|
17
|
-
className: _JSXStyle.dynamic([["
|
17
|
+
className: _JSXStyle.dynamic([["1577512909", [dayNamesColor]]])
|
18
18
|
}, label)))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
19
|
-
id: "
|
19
|
+
id: "1577512909",
|
20
20
|
dynamic: [dayNamesColor]
|
21
|
-
}, ["th.__jsx-style-dynamic-selector{color:".concat(dayNamesColor, ";font-weight:300;font-style:normal;padding:8px 8px;background:none;font-size:0.85em;border:none;}"), "tr.__jsx-style-dynamic-selector{border:none;}"]));
|
21
|
+
}, ["th.__jsx-style-dynamic-selector{color:".concat(dayNamesColor, ";font-weight:300;font-style:normal;padding:8px 8px;background:none;font-size:0.85em;border:none;cursor:default;}"), "tr.__jsx-style-dynamic-selector{border:none;}"]));
|
22
22
|
};
|
23
23
|
CalendarTableDaysHeader.propTypes = {
|
24
24
|
weekDayLabels: PropTypes.arrayOf(PropTypes.string)
|
@@ -9,7 +9,8 @@ export const CalendarTable = _ref => {
|
|
9
9
|
weekDayLabels,
|
10
10
|
calendarWeekDays,
|
11
11
|
width,
|
12
|
-
cellSize
|
12
|
+
cellSize,
|
13
|
+
selectedDate
|
13
14
|
} = _ref;
|
14
15
|
return /*#__PURE__*/React.createElement("div", {
|
15
16
|
className: _JSXStyle.dynamic([["452536960", [spacers.dp4, spacers.dp4]]]) + " " + "calendar-table-wrapper"
|
@@ -23,6 +24,7 @@ export const CalendarTable = _ref => {
|
|
23
24
|
key: "week-".concat(weekIndex + 1),
|
24
25
|
className: _JSXStyle.dynamic([["452536960", [spacers.dp4, spacers.dp4]]])
|
25
26
|
}, week.map(day => /*#__PURE__*/React.createElement(CalendarTableCell, {
|
27
|
+
selectedDate: selectedDate,
|
26
28
|
day: day,
|
27
29
|
key: day === null || day === void 0 ? void 0 : day.calendarDate,
|
28
30
|
cellSize: cellSize,
|
@@ -38,11 +40,12 @@ CalendarTable.propTypes = {
|
|
38
40
|
isInCurrentMonth: PropTypes.bool,
|
39
41
|
isSelected: PropTypes.bool,
|
40
42
|
isToday: PropTypes.bool,
|
41
|
-
label: PropTypes.string,
|
43
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
42
44
|
zdt: PropTypes.object,
|
43
45
|
onClick: PropTypes.func
|
44
46
|
}).isRequired).isRequired).isRequired,
|
45
47
|
cellSize: PropTypes.string,
|
48
|
+
selectedDate: PropTypes.string,
|
46
49
|
weekDayLabels: PropTypes.arrayOf(PropTypes.string),
|
47
50
|
width: PropTypes.string
|
48
51
|
};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
2
2
|
import { useDatePicker, useResolvedDirection } from '@dhis2/multi-calendar-dates';
|
3
3
|
import { colors } from '@dhis2/ui-constants';
|
4
|
+
import PropTypes from 'prop-types';
|
4
5
|
import React, { useState } from 'react';
|
5
|
-
import { CalendarProps } from './calendar-prop-types.js';
|
6
6
|
import { CalendarTable } from './calendar-table.js';
|
7
7
|
import { NavigationContainer } from './navigation-container.js';
|
8
8
|
export const Calendar = _ref => {
|
@@ -54,6 +54,7 @@ export const Calendar = _ref => {
|
|
54
54
|
pickerOptions: pickerOptions,
|
55
55
|
languageDirection: languageDirection
|
56
56
|
}), /*#__PURE__*/React.createElement(CalendarTable, {
|
57
|
+
selectedDate: selectedDateString,
|
57
58
|
calendarWeekDays: calendarWeekDays,
|
58
59
|
weekDayLabels: weekDayLabels,
|
59
60
|
cellSize: cellSize,
|
@@ -68,4 +69,35 @@ Calendar.defaultProps = {
|
|
68
69
|
width: '240px',
|
69
70
|
weekDayFormat: 'narrow'
|
70
71
|
};
|
72
|
+
export const CalendarProps = {
|
73
|
+
/** the calendar to use such gregory, ethiopic, nepali - full supported list here: https://github.com/dhis2/multi-calendar-dates/blob/main/src/constants/calendars.ts */
|
74
|
+
calendar: PropTypes.any.isRequired,
|
75
|
+
|
76
|
+
/** Called with signature `(null)` \|\| `({ dateCalendarString: string, dateCalendar: Temporal.ZonedDateTime })` with `dateCalendarString` being the stringified date in the specified calendar in the format `yyyy-MM-dd` */
|
77
|
+
onDateSelect: PropTypes.func.isRequired,
|
78
|
+
|
79
|
+
/** the size of a single cell in the table forming the calendar */
|
80
|
+
cellSize: PropTypes.string,
|
81
|
+
|
82
|
+
/** the currently selected date using an iso-like format YYYY-MM-DD, in the calendar system provided (not iso8601) */
|
83
|
+
date: PropTypes.string,
|
84
|
+
|
85
|
+
/** the direction of the library - internally the library will use rtl for rtl-languages but this can be overridden here for more control */
|
86
|
+
dir: PropTypes.oneOf(['ltr', 'rtl']),
|
87
|
+
|
88
|
+
/** any valid locale - if none provided, the internal library will fallback to the user locale (more info here: https://github.com/dhis2/multi-calendar-dates/blob/main/src/hooks/internal/useResolvedLocaleOptions.ts#L15) */
|
89
|
+
locale: PropTypes.string,
|
90
|
+
|
91
|
+
/** numbering system to use - full list here https://github.com/dhis2/multi-calendar-dates/blob/main/src/constants/numberingSystems.ts */
|
92
|
+
numberingSystem: PropTypes.string,
|
93
|
+
|
94
|
+
/** the timeZone to use */
|
95
|
+
timeZone: PropTypes.string,
|
96
|
+
|
97
|
+
/** the format to display for the week day, i.e. Monday (long), Mon (short), M (narrow) */
|
98
|
+
weekDayFormat: PropTypes.oneOf(['narrow', 'short', 'long']),
|
99
|
+
|
100
|
+
/** the width of the calendar component */
|
101
|
+
width: PropTypes.string
|
102
|
+
};
|
71
103
|
Calendar.propTypes = CalendarProps;
|
@@ -4,7 +4,6 @@ import { IconChevronLeft16, IconChevronRight16 } from '@dhis2/ui-icons';
|
|
4
4
|
import PropTypes from 'prop-types';
|
5
5
|
import React from 'react';
|
6
6
|
import i18n from '../locales/index.js';
|
7
|
-
const chevronColor = colors.grey600;
|
8
7
|
const wrapperBorderColor = colors.grey300;
|
9
8
|
const headerBackground = colors.grey050;
|
10
9
|
export const NavigationContainer = _ref => {
|
@@ -23,93 +22,89 @@ export const NavigationContainer = _ref => {
|
|
23
22
|
prevYear
|
24
23
|
} = pickerOptions;
|
25
24
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
26
|
-
className: _JSXStyle.dynamic([["
|
25
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "navigation-container"
|
27
26
|
}, /*#__PURE__*/React.createElement("div", {
|
28
|
-
className: _JSXStyle.dynamic([["
|
27
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "month"
|
29
28
|
}, /*#__PURE__*/React.createElement("div", {
|
30
|
-
className: _JSXStyle.dynamic([["
|
29
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "prev"
|
31
30
|
}, /*#__PURE__*/React.createElement("button", {
|
32
31
|
onClick: prevMonth.navigateTo,
|
33
32
|
name: "previous-month",
|
34
33
|
"data-test": "calendar-previous-month",
|
35
34
|
"aria-label": "".concat(i18n.t("Go to ".concat(prevMonth.label))),
|
36
35
|
type: "button",
|
37
|
-
className: _JSXStyle.dynamic([["
|
36
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
38
37
|
}, /*#__PURE__*/React.createElement(PreviousIcon, {
|
39
|
-
|
40
|
-
className: _JSXStyle.dynamic([["4112940194", [spacers.dp4, colors.grey200, spacers.dp36, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
38
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
41
39
|
}))), /*#__PURE__*/React.createElement("div", {
|
42
|
-
className: _JSXStyle.dynamic([["
|
40
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "curr"
|
43
41
|
}, /*#__PURE__*/React.createElement("span", {
|
44
|
-
className: _JSXStyle.dynamic([["
|
42
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "label"
|
45
43
|
}, currMonth.label)), /*#__PURE__*/React.createElement("div", {
|
46
|
-
className: _JSXStyle.dynamic([["
|
44
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "next"
|
47
45
|
}, /*#__PURE__*/React.createElement("button", {
|
48
46
|
onClick: nextMonth.navigateTo,
|
49
47
|
"data-test": "calendar-next-month",
|
50
48
|
name: "next-month",
|
51
49
|
"aria-label": "".concat(i18n.t("Go to ".concat(nextMonth.label))),
|
52
50
|
type: "button",
|
53
|
-
className: _JSXStyle.dynamic([["
|
51
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
54
52
|
}, /*#__PURE__*/React.createElement(NextIcon, {
|
55
|
-
|
56
|
-
className: _JSXStyle.dynamic([["4112940194", [spacers.dp4, colors.grey200, spacers.dp36, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
53
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
57
54
|
})))), /*#__PURE__*/React.createElement("div", {
|
58
|
-
className: _JSXStyle.dynamic([["
|
55
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "year"
|
59
56
|
}, /*#__PURE__*/React.createElement("div", {
|
60
|
-
className: _JSXStyle.dynamic([["
|
57
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "prev"
|
61
58
|
}, /*#__PURE__*/React.createElement("button", {
|
62
59
|
onClick: prevYear.navigateTo,
|
63
60
|
name: "previous-year",
|
64
61
|
"aria-label": "".concat(i18n.t('Go to previous year')),
|
65
62
|
type: "button",
|
66
|
-
className: _JSXStyle.dynamic([["
|
63
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
67
64
|
}, /*#__PURE__*/React.createElement(PreviousIcon, {
|
68
|
-
|
69
|
-
className: _JSXStyle.dynamic([["4112940194", [spacers.dp4, colors.grey200, spacers.dp36, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
65
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
70
66
|
}))), /*#__PURE__*/React.createElement("div", {
|
71
|
-
className: _JSXStyle.dynamic([["
|
67
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "curr"
|
72
68
|
}, /*#__PURE__*/React.createElement("span", {
|
73
|
-
className: _JSXStyle.dynamic([["
|
69
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "label"
|
74
70
|
}, currYear.label)), /*#__PURE__*/React.createElement("div", {
|
75
|
-
className: _JSXStyle.dynamic([["
|
71
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]]) + " " + "next"
|
76
72
|
}, /*#__PURE__*/React.createElement("button", {
|
77
73
|
onClick: nextYear.navigateTo,
|
78
74
|
name: "next-year",
|
79
75
|
"aria-label": "".concat(i18n.t('Go to next year')),
|
80
76
|
type: "button",
|
81
|
-
className: _JSXStyle.dynamic([["
|
77
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
82
78
|
}, /*#__PURE__*/React.createElement(NextIcon, {
|
83
|
-
|
84
|
-
className: _JSXStyle.dynamic([["4112940194", [spacers.dp4, colors.grey200, spacers.dp36, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
79
|
+
className: _JSXStyle.dynamic([["3883083596", [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]]])
|
85
80
|
}))))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
86
|
-
id: "
|
87
|
-
dynamic: [spacers.dp4, colors.grey200,
|
88
|
-
}, ["button.__jsx-style-dynamic-selector{background:none;border:0;}", ".month.__jsx-style-dynamic-selector,.year.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".month.__jsx-style-dynamic-selector .curr.__jsx-style-dynamic-selector,.year.__jsx-style-dynamic-selector .curr.__jsx-style-dynamic-selector{-webkit-flex:2;-ms-flex:2;flex:2;white-space:nowrap;}", ".prev.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;text-align:center;}", ".prev.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector{padding:".concat(spacers.dp4, ";}"), ".prev.__jsx-style-dynamic-selector:hover button.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector:hover button.__jsx-style-dynamic-selector{background-color:".concat(colors.grey200, ";cursor:pointer;}"), ".label.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:4px 8px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;min-height:16px;}", ".navigation-container.__jsx-style-dynamic-selector{
|
81
|
+
id: "3883083596",
|
82
|
+
dynamic: [spacers.dp4, colors.grey600, colors.grey200, colors.grey900, colors.grey300, spacers.dp8, spacers.dp4, wrapperBorderColor, headerBackground]
|
83
|
+
}, ["button.__jsx-style-dynamic-selector{background:none;border:0;}", ".month.__jsx-style-dynamic-selector,.year.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;cursor:default;}", ".month.__jsx-style-dynamic-selector .curr.__jsx-style-dynamic-selector,.year.__jsx-style-dynamic-selector .curr.__jsx-style-dynamic-selector{-webkit-flex:2;-ms-flex:2;flex:2;white-space:nowrap;}", ".prev.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector{-webkit-flex:1;-ms-flex:1;flex:1;text-align:center;}", ".prev.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector{padding:".concat(spacers.dp4, ";height:24px;width:24px;color:").concat(colors.grey600, ";border-radius:3px;}"), ".prev.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector svg.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector svg.__jsx-style-dynamic-selector{width:16px;height:16px;}", ".prev.__jsx-style-dynamic-selector:hover button.__jsx-style-dynamic-selector,.next.__jsx-style-dynamic-selector:hover button.__jsx-style-dynamic-selector{background-color:".concat(colors.grey200, ";color:").concat(colors.grey900, ";cursor:pointer;}"), ".prev.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector:active,.next.__jsx-style-dynamic-selector button.__jsx-style-dynamic-selector:active{background-color:".concat(colors.grey300, ";}"), ".label.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:4px 8px;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;min-height:16px;}", ".navigation-container.__jsx-style-dynamic-selector{gap:".concat(spacers.dp8, ";padding:").concat(spacers.dp4, ";display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;border-bottom:1px solid ").concat(wrapperBorderColor, ";background-color:").concat(headerBackground, ";font-size:1.08em;}")]));
|
89
84
|
};
|
90
85
|
NavigationContainer.propTypes = {
|
91
86
|
languageDirection: PropTypes.oneOf(['ltr', 'rtl']),
|
92
87
|
pickerOptions: PropTypes.shape({
|
93
88
|
currMonth: PropTypes.shape({
|
94
|
-
label: PropTypes.string
|
89
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
95
90
|
}),
|
96
91
|
currYear: PropTypes.shape({
|
97
|
-
label: PropTypes.string
|
92
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
98
93
|
}),
|
99
94
|
nextMonth: PropTypes.shape({
|
100
|
-
label: PropTypes.string,
|
95
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
101
96
|
navigateTo: PropTypes.func
|
102
97
|
}),
|
103
98
|
nextYear: PropTypes.shape({
|
104
|
-
label: PropTypes.string,
|
99
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
105
100
|
navigateTo: PropTypes.func
|
106
101
|
}),
|
107
102
|
prevMonth: PropTypes.shape({
|
108
|
-
label: PropTypes.string,
|
103
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
109
104
|
navigateTo: PropTypes.func
|
110
105
|
}),
|
111
106
|
prevYear: PropTypes.shape({
|
112
|
-
label: PropTypes.string,
|
107
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
113
108
|
navigateTo: PropTypes.func
|
114
109
|
})
|
115
110
|
})
|
@@ -1,19 +1,16 @@
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
2
|
+
|
1
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
4
|
|
5
|
+
import { Button } from '@dhis2-ui/button';
|
3
6
|
import { Card } from '@dhis2-ui/card';
|
4
7
|
import { InputField, InputFieldProps } from '@dhis2-ui/input';
|
5
8
|
import { Layer } from '@dhis2-ui/layer';
|
6
9
|
import { Popper } from '@dhis2-ui/popper';
|
7
|
-
import
|
10
|
+
import cx from 'classnames';
|
8
11
|
import React, { useRef, useState } from 'react';
|
9
|
-
import { CalendarProps } from '../calendar/calendar
|
10
|
-
import
|
11
|
-
|
12
|
-
const padWithZeroes = function (number) {
|
13
|
-
let count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
14
|
-
return String(number).padStart(count, '0');
|
15
|
-
};
|
16
|
-
|
12
|
+
import { Calendar, CalendarProps } from '../calendar/calendar.js';
|
13
|
+
import i18n from '../locales/index.js';
|
17
14
|
const offsetModifier = {
|
18
15
|
name: 'offset',
|
19
16
|
options: {
|
@@ -32,19 +29,13 @@ export const CalendarInput = function () {
|
|
32
29
|
timeZone,
|
33
30
|
width,
|
34
31
|
cellSize,
|
32
|
+
clearable,
|
35
33
|
...rest
|
36
34
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
37
35
|
const ref = useRef();
|
38
36
|
const [open, setOpen] = useState(false);
|
39
|
-
const currentDate = getNowInCalendar(calendar, timeZone);
|
40
|
-
const initialDate = date || "".concat(currentDate.eraYear || currentDate.year, "-").concat(padWithZeroes(currentDate.month), "-").concat(padWithZeroes(currentDate.day));
|
41
|
-
const [value, setValue] = useState(initialDate);
|
42
37
|
const calendarProps = React.useMemo(() => {
|
43
38
|
const onDateSelectWrapper = selectedDate => {
|
44
|
-
const {
|
45
|
-
calendarDateString
|
46
|
-
} = selectedDate;
|
47
|
-
setValue(calendarDateString);
|
48
39
|
setOpen(false);
|
49
40
|
onDateSelect === null || onDateSelect === void 0 ? void 0 : onDateSelect(selectedDate);
|
50
41
|
};
|
@@ -68,14 +59,29 @@ export const CalendarInput = function () {
|
|
68
59
|
};
|
69
60
|
|
70
61
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
71
|
-
ref: ref
|
62
|
+
ref: ref,
|
63
|
+
className: "jsx-862452676" + " " + "calendar-input-wrapper"
|
72
64
|
}, /*#__PURE__*/React.createElement(InputField, _extends({
|
73
65
|
label: "Pick a date"
|
74
66
|
}, rest, {
|
75
67
|
type: "text",
|
76
68
|
onFocus: onFocus,
|
77
|
-
value:
|
78
|
-
}))
|
69
|
+
value: date
|
70
|
+
})), clearable && /*#__PURE__*/React.createElement("div", {
|
71
|
+
className: "jsx-862452676" + " " + (cx('calendar-clear-button', {
|
72
|
+
// ToDo: this is a workaround to show the clear button in the correct place when an icon is shown.
|
73
|
+
// Long-term, we should abstract and share the logic multi-select uses for the input-wrapper
|
74
|
+
// https://dhis2.atlassian.net/browse/DHIS2-14848
|
75
|
+
'with-icon': rest.valid || rest.error || rest.warning || rest.loading,
|
76
|
+
'with-dense-wrapper': rest.dense
|
77
|
+
}) || "")
|
78
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
79
|
+
dataTest: "calendar-clear-button",
|
80
|
+
secondary: true,
|
81
|
+
small: true,
|
82
|
+
onClick: () => calendarProps.onDateSelect(null),
|
83
|
+
type: "button"
|
84
|
+
}, i18n.t('Clear')))), open && /*#__PURE__*/React.createElement(Layer, {
|
79
85
|
onBackdropClick: () => {
|
80
86
|
setOpen(false);
|
81
87
|
}
|
@@ -84,8 +90,10 @@ export const CalendarInput = function () {
|
|
84
90
|
placement: "bottom-start",
|
85
91
|
modifiers: [offsetModifier]
|
86
92
|
}, /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(Calendar, _extends({}, calendarProps, {
|
87
|
-
date:
|
88
|
-
})))))
|
93
|
+
date: date
|
94
|
+
}))))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
95
|
+
id: "862452676"
|
96
|
+
}, [".calendar-input-wrapper.jsx-862452676{position:relative;}", ".calendar-clear-button.jsx-862452676{position:absolute;inset-inline-end:6px;-webkit-inset-block-start:27px;-ms-intb-rlock-start:27px;inset-block-start:27px;}", ".calendar-clear-button.with-icon.jsx-862452676{inset-inline-end:36px;}", ".calendar-clear-button.with-dense-wrapper.jsx-862452676{-webkit-inset-block-start:23px;-ms-intb-rlock-start:23px;inset-block-start:23px;}"]));
|
89
97
|
};
|
90
98
|
CalendarInput.defaultProps = {
|
91
99
|
dataTest: 'dhis2-uiwidgets-calendar-inputfield'
|