@dhis2-ui/calendar 10.16.3-alpha.1 → 10.16.4
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/build/cjs/calendar/calendar-container.js +20 -22
- package/build/cjs/calendar/calendar-table-cell.js +5 -6
- package/build/cjs/calendar/calendar-table-days-header.js +3 -4
- package/build/cjs/calendar/calendar-table.js +27 -30
- package/build/cjs/calendar/calendar.js +14 -16
- package/build/cjs/calendar/navigation-container.js +13 -14
- package/build/cjs/calendar-input/__tests__/calendar-input.test.js +6 -8
- package/build/cjs/calendar-input/calendar-input.js +25 -27
- package/build/cjs/locales/index.js +6 -1
- package/build/cjs/stories/calendar-input.prod.stories.js +27 -34
- package/build/cjs/stories/calendar-story-wrapper.js +26 -32
- package/build/es/calendar/calendar-container.js +19 -20
- package/build/es/calendar/calendar-table-cell.js +5 -6
- package/build/es/calendar/calendar-table-days-header.js +3 -4
- package/build/es/calendar/calendar-table.js +27 -30
- package/build/es/calendar/calendar.js +13 -14
- package/build/es/calendar/navigation-container.js +13 -14
- package/build/es/calendar-input/__tests__/calendar-input.test.js +5 -6
- package/build/es/calendar-input/calendar-input.js +24 -25
- package/build/es/locales/index.js +6 -1
- package/build/es/stories/calendar-input.prod.stories.js +26 -32
- package/build/es/stories/calendar-story-wrapper.js +25 -30
- package/package.json +8 -8
- package/src/locales/index.js +6 -1
|
@@ -10,30 +10,28 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _calendarTable = require("./calendar-table.js");
|
|
12
12
|
var _navigationContainer = require("./navigation-container.js");
|
|
13
|
-
function
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
const backgroundColor = _uiConstants.colors.white;
|
|
17
|
-
const CalendarContainer = exports.CalendarContainer = /*#__PURE__*/_react.default.memo(function CalendarContainer(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} = _ref;
|
|
16
|
+
const CalendarContainer = exports.CalendarContainer = /*#__PURE__*/_react.default.memo(function CalendarContainer({
|
|
17
|
+
date,
|
|
18
|
+
width = '240px',
|
|
19
|
+
cellSize = '32px',
|
|
20
|
+
calendarWeekDays,
|
|
21
|
+
weekDayLabels,
|
|
22
|
+
currMonth,
|
|
23
|
+
currYear,
|
|
24
|
+
nextMonth,
|
|
25
|
+
nextYear,
|
|
26
|
+
prevMonth,
|
|
27
|
+
prevYear,
|
|
28
|
+
navigateToYear,
|
|
29
|
+
navigateToMonth,
|
|
30
|
+
months,
|
|
31
|
+
years,
|
|
32
|
+
languageDirection,
|
|
33
|
+
calendarRef
|
|
34
|
+
}) {
|
|
37
35
|
const navigationProps = (0, _react.useMemo)(() => {
|
|
38
36
|
return {
|
|
39
37
|
currMonth,
|
|
@@ -10,12 +10,11 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
const CalendarTableCell =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
13
|
+
const CalendarTableCell = ({
|
|
14
|
+
day,
|
|
15
|
+
cellSize,
|
|
16
|
+
selectedDate
|
|
17
|
+
}) => {
|
|
19
18
|
const dayHoverBackgroundColor = _uiConstants.colors.grey200;
|
|
20
19
|
const selectedDayBackgroundColor = _uiConstants.colors.teal700;
|
|
21
20
|
return /*#__PURE__*/_react.default.createElement("td", {
|
|
@@ -9,10 +9,9 @@ var _uiConstants = require("@dhis2/ui-constants");
|
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const CalendarTableDaysHeader =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} = _ref;
|
|
12
|
+
const CalendarTableDaysHeader = ({
|
|
13
|
+
weekDayLabels
|
|
14
|
+
}) => {
|
|
16
15
|
const dayNamesColor = _uiConstants.colors.grey700;
|
|
17
16
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("thead", {
|
|
18
17
|
className: _style.default.dynamic([["1577512909", [dayNamesColor]]])
|
|
@@ -11,36 +11,33 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
var _calendarTableCell = require("./calendar-table-cell.js");
|
|
12
12
|
var _calendarTableDaysHeader = require("./calendar-table-days-header.js");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
const CalendarTable =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
dynamic: [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]
|
|
42
|
-
}, [`.calendar-table.__jsx-style-dynamic-selector{border:none;border-collapse:collapse;width:100%;margin-block:0 ${_uiConstants.spacers.dp4};}`, ".calendar-table.__jsx-style-dynamic-selector tr.__jsx-style-dynamic-selector,.calendar-table.__jsx-style-dynamic-selector td.__jsx-style-dynamic-selector{border:none;}", `.calendar-table-wrapper.__jsx-style-dynamic-selector{padding-inline:${_uiConstants.spacers.dp4};}`]));
|
|
43
|
-
};
|
|
14
|
+
const CalendarTable = ({
|
|
15
|
+
weekDayLabels,
|
|
16
|
+
calendarWeekDays,
|
|
17
|
+
width,
|
|
18
|
+
cellSize,
|
|
19
|
+
selectedDate
|
|
20
|
+
}) => /*#__PURE__*/_react.default.createElement("div", {
|
|
21
|
+
className: _style.default.dynamic([["890354150", [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]]]) + " " + "calendar-table-wrapper"
|
|
22
|
+
}, /*#__PURE__*/_react.default.createElement("table", {
|
|
23
|
+
className: _style.default.dynamic([["890354150", [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]]]) + " " + "calendar-table"
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(_calendarTableDaysHeader.CalendarTableDaysHeader, {
|
|
25
|
+
weekDayLabels: weekDayLabels
|
|
26
|
+
}), /*#__PURE__*/_react.default.createElement("tbody", {
|
|
27
|
+
className: _style.default.dynamic([["890354150", [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]]])
|
|
28
|
+
}, calendarWeekDays.map((week, weekIndex) => /*#__PURE__*/_react.default.createElement("tr", {
|
|
29
|
+
key: `week-${weekIndex + 1}`,
|
|
30
|
+
className: _style.default.dynamic([["890354150", [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]]])
|
|
31
|
+
}, week.map(day => /*#__PURE__*/_react.default.createElement(_calendarTableCell.CalendarTableCell, {
|
|
32
|
+
selectedDate: selectedDate,
|
|
33
|
+
day: day,
|
|
34
|
+
key: day === null || day === void 0 ? void 0 : day.dateValue,
|
|
35
|
+
cellSize: cellSize,
|
|
36
|
+
width: width
|
|
37
|
+
})))))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
38
|
+
id: "890354150",
|
|
39
|
+
dynamic: [_uiConstants.spacers.dp4, _uiConstants.spacers.dp4]
|
|
40
|
+
}, [`.calendar-table.__jsx-style-dynamic-selector{border:none;border-collapse:collapse;width:100%;margin-block:0 ${_uiConstants.spacers.dp4};}`, ".calendar-table.__jsx-style-dynamic-selector tr.__jsx-style-dynamic-selector,.calendar-table.__jsx-style-dynamic-selector td.__jsx-style-dynamic-selector{border:none;}", `.calendar-table-wrapper.__jsx-style-dynamic-selector{padding-inline:${_uiConstants.spacers.dp4};}`]));
|
|
44
41
|
exports.CalendarTable = CalendarTable;
|
|
45
42
|
const CalendarTableProps = exports.CalendarTableProps = {
|
|
46
43
|
calendarWeekDays: _propTypes.default.arrayOf(_propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -8,23 +8,21 @@ var _multiCalendarDates = require("@dhis2/multi-calendar-dates");
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _calendarContainer = require("./calendar-container.js");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
const Calendar =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref;
|
|
13
|
+
const Calendar = ({
|
|
14
|
+
onDateSelect,
|
|
15
|
+
calendar,
|
|
16
|
+
date,
|
|
17
|
+
dir,
|
|
18
|
+
locale,
|
|
19
|
+
numberingSystem,
|
|
20
|
+
weekDayFormat = 'narrow',
|
|
21
|
+
timeZone,
|
|
22
|
+
width = '240px',
|
|
23
|
+
cellSize = '32px',
|
|
24
|
+
pastOnly
|
|
25
|
+
}) => {
|
|
28
26
|
const [selectedDateString, setSelectedDateString] = (0, _react.useState)(date);
|
|
29
27
|
const languageDirection = (0, _multiCalendarDates.useResolvedDirection)(dir, locale);
|
|
30
28
|
const options = {
|
|
@@ -13,20 +13,19 @@ var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
const wrapperBorderColor = _uiConstants.colors.grey300;
|
|
15
15
|
const headerBackground = _uiConstants.colors.grey100;
|
|
16
|
-
const NavigationContainer =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} = _ref;
|
|
16
|
+
const NavigationContainer = ({
|
|
17
|
+
languageDirection,
|
|
18
|
+
currMonth,
|
|
19
|
+
currYear,
|
|
20
|
+
nextMonth,
|
|
21
|
+
nextYear,
|
|
22
|
+
prevMonth,
|
|
23
|
+
prevYear,
|
|
24
|
+
navigateToYear,
|
|
25
|
+
navigateToMonth,
|
|
26
|
+
months,
|
|
27
|
+
years
|
|
28
|
+
}) => {
|
|
30
29
|
const PreviousIcon = languageDirection === 'ltr' ? _uiIcons.IconChevronLeft16 : _uiIcons.IconChevronRight16;
|
|
31
30
|
const NextIcon = languageDirection === 'ltr' ? _uiIcons.IconChevronRight16 : _uiIcons.IconChevronLeft16;
|
|
32
31
|
const handleYearChange = e => {
|
|
@@ -5,8 +5,7 @@ var _react = require("@testing-library/react");
|
|
|
5
5
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
6
6
|
var _reactFinalForm = require("react-final-form");
|
|
7
7
|
var _calendarInput = require("../calendar-input.js");
|
|
8
|
-
function
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
9
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
11
10
|
describe('Calendar Input', () => {
|
|
12
11
|
it('allow selection of a date through the calendar widget', async () => {
|
|
@@ -271,11 +270,10 @@ const CalendarWithValidation = propsFromParent => {
|
|
|
271
270
|
return /*#__PURE__*/_react2.default.createElement(_reactFinalForm.Form, {
|
|
272
271
|
onSubmit: () => {},
|
|
273
272
|
validate: errored
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
} = _ref;
|
|
273
|
+
}, ({
|
|
274
|
+
handleSubmit,
|
|
275
|
+
invalid
|
|
276
|
+
}) => {
|
|
279
277
|
return /*#__PURE__*/_react2.default.createElement("form", null, /*#__PURE__*/_react2.default.createElement(_reactFinalForm.Field, {
|
|
280
278
|
name: "calendar"
|
|
281
279
|
}, props => /*#__PURE__*/_react2.default.createElement(_calendarInput.CalendarInput, _extends({}, props, {
|
|
@@ -288,7 +286,7 @@ const CalendarWithValidation = propsFromParent => {
|
|
|
288
286
|
var _propsFromParent$onDa;
|
|
289
287
|
setDate(date === null || date === void 0 ? void 0 : date.calendarDateString);
|
|
290
288
|
setValidation(date === null || date === void 0 ? void 0 : date.validation);
|
|
291
|
-
(_propsFromParent$onDa = propsFromParent.onDateSelect) === null || _propsFromParent$onDa === void 0
|
|
289
|
+
(_propsFromParent$onDa = propsFromParent.onDateSelect) === null || _propsFromParent$onDa === void 0 || _propsFromParent$onDa.call(propsFromParent, date);
|
|
292
290
|
}
|
|
293
291
|
}))), /*#__PURE__*/_react2.default.createElement(_button.Button, {
|
|
294
292
|
type: "submit",
|
|
@@ -15,8 +15,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
var _calendarContainer = require("../calendar/calendar-container.js");
|
|
17
17
|
var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
18
|
-
function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
20
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
22
21
|
const offsetModifier = {
|
|
@@ -25,27 +24,26 @@ const offsetModifier = {
|
|
|
25
24
|
offset: [0, 2]
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
|
-
const CalendarInput =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
|
+
const CalendarInput = ({
|
|
28
|
+
onDateSelect: parentOnDateSelect,
|
|
29
|
+
calendar,
|
|
30
|
+
date,
|
|
31
|
+
dir,
|
|
32
|
+
locale,
|
|
33
|
+
numberingSystem,
|
|
34
|
+
weekDayFormat = 'narrow',
|
|
35
|
+
width = '300px',
|
|
36
|
+
cellSize = '32px',
|
|
37
|
+
clearable,
|
|
38
|
+
minDate,
|
|
39
|
+
maxDate,
|
|
40
|
+
format,
|
|
41
|
+
strictValidation,
|
|
42
|
+
inputWidth,
|
|
43
|
+
dataTest = 'dhis2-uiwidgets-calendar-inputfield',
|
|
44
|
+
pastOnly,
|
|
45
|
+
...rest
|
|
46
|
+
} = {}) => {
|
|
49
47
|
const ref = (0, _react.useRef)();
|
|
50
48
|
const calendarRef = (0, _react.useRef)();
|
|
51
49
|
const popperRef = (0, _react.useRef)();
|
|
@@ -61,7 +59,7 @@ const CalendarInput = function () {
|
|
|
61
59
|
}), [calendar, locale, numberingSystem, weekDayFormat, pastOnly]);
|
|
62
60
|
const onChooseDate = (date, validationOptions) => {
|
|
63
61
|
if (!date) {
|
|
64
|
-
parentOnDateSelect === null || parentOnDateSelect === void 0
|
|
62
|
+
parentOnDateSelect === null || parentOnDateSelect === void 0 || parentOnDateSelect({
|
|
65
63
|
calendarDateString: null,
|
|
66
64
|
validation: {
|
|
67
65
|
valid: true
|
|
@@ -70,7 +68,7 @@ const CalendarInput = function () {
|
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
72
70
|
const validation = (0, _multiCalendarDates.validateDateString)(date, validationOptions);
|
|
73
|
-
parentOnDateSelect === null || parentOnDateSelect === void 0
|
|
71
|
+
parentOnDateSelect === null || parentOnDateSelect === void 0 || parentOnDateSelect({
|
|
74
72
|
calendarDateString: date,
|
|
75
73
|
validation
|
|
76
74
|
});
|
|
@@ -106,7 +104,7 @@ const CalendarInput = function () {
|
|
|
106
104
|
const onFocus = () => {
|
|
107
105
|
var _rest$onFocus;
|
|
108
106
|
setOpen(true);
|
|
109
|
-
rest === null || rest === void 0
|
|
107
|
+
rest === null || rest === void 0 || (_rest$onFocus = rest.onFocus) === null || _rest$onFocus === void 0 || _rest$onFocus.call(rest);
|
|
110
108
|
};
|
|
111
109
|
const languageDirection = (0, _multiCalendarDates.useResolvedDirection)(dir, locale);
|
|
112
110
|
const calendarProps = (0, _react.useMemo)(() => ({
|
|
@@ -160,7 +158,7 @@ const CalendarInput = function () {
|
|
|
160
158
|
modifiers: [offsetModifier],
|
|
161
159
|
onFirstUpdate: component => {
|
|
162
160
|
var _component$elements;
|
|
163
|
-
popperRef.current = component === null || component === void 0
|
|
161
|
+
popperRef.current = component === null || component === void 0 || (_component$elements = component.elements) === null || _component$elements === void 0 ? void 0 : _component$elements.popper;
|
|
164
162
|
}
|
|
165
163
|
}, /*#__PURE__*/_react.default.createElement(_calendarContainer.CalendarContainer, _extends({}, calendarProps, {
|
|
166
164
|
calendarRef: calendarRef
|
|
@@ -17,5 +17,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
17
17
|
//------------------------------------------------------------------------------
|
|
18
18
|
|
|
19
19
|
const namespace = 'default';
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
// Use 'deep' = true and 'overwrite' = false to add to, but not overwrite,
|
|
22
|
+
// custom translations from the datastore (added by the app adapter)
|
|
23
|
+
|
|
24
|
+
_d2I18n.default.addResourceBundle('en', namespace, _translations.default, true, false);
|
|
25
|
+
_d2I18n.default.addResourceBundle('en', namespace, _translations.default, true, false);
|
|
21
26
|
var _default = exports.default = _d2I18n.default;
|
|
@@ -12,8 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _reactFinalForm = require("react-final-form");
|
|
13
13
|
var _calendarInput = require("../calendar-input/calendar-input.js");
|
|
14
14
|
var _calendarStoryWrapper = require("./calendar-story-wrapper.js");
|
|
15
|
-
function
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
16
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
17
|
const subtitle = `[Experimental] Calendar Input is a wrapper around Calendar displaying an input that triggers the calendar`;
|
|
19
18
|
const description = `
|
|
@@ -37,23 +36,20 @@ var _default = exports.default = {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
|
-
const buildCalendar =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onDateSelect: () => {}
|
|
55
|
-
});
|
|
56
|
-
};
|
|
39
|
+
const buildCalendar = ({
|
|
40
|
+
date,
|
|
41
|
+
locale,
|
|
42
|
+
calendar
|
|
43
|
+
}) => () => /*#__PURE__*/_react.default.createElement(_calendarStoryWrapper.CalendarStoryWrapper, {
|
|
44
|
+
component: _calendarInput.CalendarInput,
|
|
45
|
+
dir: "ltr",
|
|
46
|
+
timeZone: "Africa/Khartoum",
|
|
47
|
+
weekDayFormat: "short",
|
|
48
|
+
date: date,
|
|
49
|
+
locale: locale,
|
|
50
|
+
calendar: calendar,
|
|
51
|
+
onDateSelect: () => {}
|
|
52
|
+
});
|
|
57
53
|
const EthiopicWithAmharic = exports.EthiopicWithAmharic = buildCalendar({
|
|
58
54
|
calendar: 'ethiopic',
|
|
59
55
|
locale: 'am-ET',
|
|
@@ -103,11 +99,10 @@ const IslamicWithArabic = () => {
|
|
|
103
99
|
}));
|
|
104
100
|
};
|
|
105
101
|
exports.IslamicWithArabic = IslamicWithArabic;
|
|
106
|
-
const CalendarWithClearButton =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} = _ref2;
|
|
102
|
+
const CalendarWithClearButton = ({
|
|
103
|
+
calendar = 'gregory',
|
|
104
|
+
date: initialDate = null
|
|
105
|
+
}) => {
|
|
111
106
|
const [date, setDate] = (0, _react.useState)(initialDate);
|
|
112
107
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_calendarInput.CalendarInput, {
|
|
113
108
|
calendar: calendar,
|
|
@@ -141,11 +136,10 @@ function CalendarWithStrictValidation() {
|
|
|
141
136
|
calendar: '2022-10-12'
|
|
142
137
|
},
|
|
143
138
|
validate: errored
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
} = _ref3;
|
|
139
|
+
}, ({
|
|
140
|
+
handleSubmit,
|
|
141
|
+
invalid
|
|
142
|
+
}) => {
|
|
149
143
|
return /*#__PURE__*/_react.default.createElement("form", {
|
|
150
144
|
onSubmit: handleSubmit
|
|
151
145
|
}, /*#__PURE__*/_react.default.createElement(_reactFinalForm.Field, {
|
|
@@ -195,11 +189,10 @@ function CalendarWithNonStrictValidation() {
|
|
|
195
189
|
calendar: '2022-10-12'
|
|
196
190
|
},
|
|
197
191
|
validate: errored
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
} = _ref4;
|
|
192
|
+
}, ({
|
|
193
|
+
handleSubmit,
|
|
194
|
+
invalid
|
|
195
|
+
}) => {
|
|
203
196
|
return /*#__PURE__*/_react.default.createElement("form", {
|
|
204
197
|
onSubmit: handleSubmit
|
|
205
198
|
}, /*#__PURE__*/_react.default.createElement(_reactFinalForm.Field, {
|
|
@@ -8,8 +8,7 @@ var _multiCalendarDates = require("@dhis2/multi-calendar-dates");
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _calendar = require("../calendar/calendar.js");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
14
|
const {
|
|
@@ -34,48 +33,43 @@ const CalendarStoryWrapper = props => {
|
|
|
34
33
|
const [selectedDate, setSelectedDate] = (0, _react.useState)({
|
|
35
34
|
calendarDateString: date
|
|
36
35
|
});
|
|
37
|
-
const changeCalendar =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} = _ref;
|
|
36
|
+
const changeCalendar = ({
|
|
37
|
+
target: {
|
|
38
|
+
value
|
|
39
|
+
}
|
|
40
|
+
}) => {
|
|
43
41
|
setSelectedCalendar(value);
|
|
44
42
|
};
|
|
45
|
-
const changeNumberingSystem =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} = _ref2;
|
|
43
|
+
const changeNumberingSystem = ({
|
|
44
|
+
target: {
|
|
45
|
+
value
|
|
46
|
+
}
|
|
47
|
+
}) => {
|
|
51
48
|
if (value === '-1') {
|
|
52
49
|
setSelectedNumberingSystem(null);
|
|
53
50
|
} else {
|
|
54
51
|
setSelectedNumberingSystem(value);
|
|
55
52
|
}
|
|
56
53
|
};
|
|
57
|
-
const changeDirection =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} = _ref3;
|
|
54
|
+
const changeDirection = ({
|
|
55
|
+
target: {
|
|
56
|
+
value
|
|
57
|
+
}
|
|
58
|
+
}) => {
|
|
63
59
|
setSelectedDirection(value);
|
|
64
60
|
};
|
|
65
|
-
const changeWeekFormat =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} = _ref4;
|
|
61
|
+
const changeWeekFormat = ({
|
|
62
|
+
target: {
|
|
63
|
+
value
|
|
64
|
+
}
|
|
65
|
+
}) => {
|
|
71
66
|
setWeekDayFormat(value);
|
|
72
67
|
};
|
|
73
|
-
const onLocaleChanged =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} = _ref5;
|
|
68
|
+
const onLocaleChanged = ({
|
|
69
|
+
target: {
|
|
70
|
+
value
|
|
71
|
+
}
|
|
72
|
+
}) => {
|
|
79
73
|
setLocale(value);
|
|
80
74
|
};
|
|
81
75
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -5,26 +5,25 @@ import React, { useMemo } from 'react';
|
|
|
5
5
|
import { CalendarTable, CalendarTableProps } from './calendar-table.js';
|
|
6
6
|
import { NavigationContainer, NavigationContainerProps } from './navigation-container.js';
|
|
7
7
|
const backgroundColor = colors.white;
|
|
8
|
-
export const CalendarContainer = /*#__PURE__*/React.memo(function CalendarContainer(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref;
|
|
8
|
+
export const CalendarContainer = /*#__PURE__*/React.memo(function CalendarContainer({
|
|
9
|
+
date,
|
|
10
|
+
width = '240px',
|
|
11
|
+
cellSize = '32px',
|
|
12
|
+
calendarWeekDays,
|
|
13
|
+
weekDayLabels,
|
|
14
|
+
currMonth,
|
|
15
|
+
currYear,
|
|
16
|
+
nextMonth,
|
|
17
|
+
nextYear,
|
|
18
|
+
prevMonth,
|
|
19
|
+
prevYear,
|
|
20
|
+
navigateToYear,
|
|
21
|
+
navigateToMonth,
|
|
22
|
+
months,
|
|
23
|
+
years,
|
|
24
|
+
languageDirection,
|
|
25
|
+
calendarRef
|
|
26
|
+
}) {
|
|
28
27
|
const navigationProps = useMemo(() => {
|
|
29
28
|
return {
|
|
30
29
|
currMonth,
|
|
@@ -3,12 +3,11 @@ 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
|
-
export const CalendarTableCell =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = _ref;
|
|
6
|
+
export const CalendarTableCell = ({
|
|
7
|
+
day,
|
|
8
|
+
cellSize,
|
|
9
|
+
selectedDate
|
|
10
|
+
}) => {
|
|
12
11
|
const dayHoverBackgroundColor = colors.grey200;
|
|
13
12
|
const selectedDayBackgroundColor = colors.teal700;
|
|
14
13
|
return /*#__PURE__*/React.createElement("td", {
|
|
@@ -2,10 +2,9 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const CalendarTableDaysHeader =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} = _ref;
|
|
5
|
+
export const CalendarTableDaysHeader = ({
|
|
6
|
+
weekDayLabels
|
|
7
|
+
}) => {
|
|
9
8
|
const dayNamesColor = colors.grey700;
|
|
10
9
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("thead", {
|
|
11
10
|
className: _JSXStyle.dynamic([["1577512909", [dayNamesColor]]])
|
|
@@ -4,36 +4,33 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { CalendarTableCell } from './calendar-table-cell.js';
|
|
6
6
|
import { CalendarTableDaysHeader } from './calendar-table-days-header.js';
|
|
7
|
-
export const CalendarTable =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
dynamic: [spacers.dp4, spacers.dp4]
|
|
35
|
-
}, [`.calendar-table.__jsx-style-dynamic-selector{border:none;border-collapse:collapse;width:100%;margin-block:0 ${spacers.dp4};}`, ".calendar-table.__jsx-style-dynamic-selector tr.__jsx-style-dynamic-selector,.calendar-table.__jsx-style-dynamic-selector td.__jsx-style-dynamic-selector{border:none;}", `.calendar-table-wrapper.__jsx-style-dynamic-selector{padding-inline:${spacers.dp4};}`]));
|
|
36
|
-
};
|
|
7
|
+
export const CalendarTable = ({
|
|
8
|
+
weekDayLabels,
|
|
9
|
+
calendarWeekDays,
|
|
10
|
+
width,
|
|
11
|
+
cellSize,
|
|
12
|
+
selectedDate
|
|
13
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: _JSXStyle.dynamic([["890354150", [spacers.dp4, spacers.dp4]]]) + " " + "calendar-table-wrapper"
|
|
15
|
+
}, /*#__PURE__*/React.createElement("table", {
|
|
16
|
+
className: _JSXStyle.dynamic([["890354150", [spacers.dp4, spacers.dp4]]]) + " " + "calendar-table"
|
|
17
|
+
}, /*#__PURE__*/React.createElement(CalendarTableDaysHeader, {
|
|
18
|
+
weekDayLabels: weekDayLabels
|
|
19
|
+
}), /*#__PURE__*/React.createElement("tbody", {
|
|
20
|
+
className: _JSXStyle.dynamic([["890354150", [spacers.dp4, spacers.dp4]]])
|
|
21
|
+
}, calendarWeekDays.map((week, weekIndex) => /*#__PURE__*/React.createElement("tr", {
|
|
22
|
+
key: `week-${weekIndex + 1}`,
|
|
23
|
+
className: _JSXStyle.dynamic([["890354150", [spacers.dp4, spacers.dp4]]])
|
|
24
|
+
}, week.map(day => /*#__PURE__*/React.createElement(CalendarTableCell, {
|
|
25
|
+
selectedDate: selectedDate,
|
|
26
|
+
day: day,
|
|
27
|
+
key: day === null || day === void 0 ? void 0 : day.dateValue,
|
|
28
|
+
cellSize: cellSize,
|
|
29
|
+
width: width
|
|
30
|
+
})))))), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
31
|
+
id: "890354150",
|
|
32
|
+
dynamic: [spacers.dp4, spacers.dp4]
|
|
33
|
+
}, [`.calendar-table.__jsx-style-dynamic-selector{border:none;border-collapse:collapse;width:100%;margin-block:0 ${spacers.dp4};}`, ".calendar-table.__jsx-style-dynamic-selector tr.__jsx-style-dynamic-selector,.calendar-table.__jsx-style-dynamic-selector td.__jsx-style-dynamic-selector{border:none;}", `.calendar-table-wrapper.__jsx-style-dynamic-selector{padding-inline:${spacers.dp4};}`]));
|
|
37
34
|
export const CalendarTableProps = {
|
|
38
35
|
calendarWeekDays: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.shape({
|
|
39
36
|
calendarDate: PropTypes.string,
|
|
@@ -2,20 +2,19 @@ import { useDatePicker, useResolvedDirection } from '@dhis2/multi-calendar-dates
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useMemo, useState } from 'react';
|
|
4
4
|
import { CalendarContainer } from './calendar-container.js';
|
|
5
|
-
export const Calendar =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
5
|
+
export const Calendar = ({
|
|
6
|
+
onDateSelect,
|
|
7
|
+
calendar,
|
|
8
|
+
date,
|
|
9
|
+
dir,
|
|
10
|
+
locale,
|
|
11
|
+
numberingSystem,
|
|
12
|
+
weekDayFormat = 'narrow',
|
|
13
|
+
timeZone,
|
|
14
|
+
width = '240px',
|
|
15
|
+
cellSize = '32px',
|
|
16
|
+
pastOnly
|
|
17
|
+
}) => {
|
|
19
18
|
const [selectedDateString, setSelectedDateString] = useState(date);
|
|
20
19
|
const languageDirection = useResolvedDirection(dir, locale);
|
|
21
20
|
const options = {
|
|
@@ -6,20 +6,19 @@ import React from 'react';
|
|
|
6
6
|
import i18n from '../locales/index.js';
|
|
7
7
|
const wrapperBorderColor = colors.grey300;
|
|
8
8
|
const headerBackground = colors.grey100;
|
|
9
|
-
export const NavigationContainer =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref;
|
|
9
|
+
export const NavigationContainer = ({
|
|
10
|
+
languageDirection,
|
|
11
|
+
currMonth,
|
|
12
|
+
currYear,
|
|
13
|
+
nextMonth,
|
|
14
|
+
nextYear,
|
|
15
|
+
prevMonth,
|
|
16
|
+
prevYear,
|
|
17
|
+
navigateToYear,
|
|
18
|
+
navigateToMonth,
|
|
19
|
+
months,
|
|
20
|
+
years
|
|
21
|
+
}) => {
|
|
23
22
|
const PreviousIcon = languageDirection === 'ltr' ? IconChevronLeft16 : IconChevronRight16;
|
|
24
23
|
const NextIcon = languageDirection === 'ltr' ? IconChevronRight16 : IconChevronLeft16;
|
|
25
24
|
const handleYearChange = e => {
|
|
@@ -267,11 +267,10 @@ const CalendarWithValidation = propsFromParent => {
|
|
|
267
267
|
return /*#__PURE__*/React.createElement(Form, {
|
|
268
268
|
onSubmit: () => {},
|
|
269
269
|
validate: errored
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
} = _ref;
|
|
270
|
+
}, ({
|
|
271
|
+
handleSubmit,
|
|
272
|
+
invalid
|
|
273
|
+
}) => {
|
|
275
274
|
return /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement(Field, {
|
|
276
275
|
name: "calendar"
|
|
277
276
|
}, props => /*#__PURE__*/React.createElement(CalendarInput, _extends({}, props, {
|
|
@@ -284,7 +283,7 @@ const CalendarWithValidation = propsFromParent => {
|
|
|
284
283
|
var _propsFromParent$onDa;
|
|
285
284
|
setDate(date === null || date === void 0 ? void 0 : date.calendarDateString);
|
|
286
285
|
setValidation(date === null || date === void 0 ? void 0 : date.validation);
|
|
287
|
-
(_propsFromParent$onDa = propsFromParent.onDateSelect) === null || _propsFromParent$onDa === void 0
|
|
286
|
+
(_propsFromParent$onDa = propsFromParent.onDateSelect) === null || _propsFromParent$onDa === void 0 || _propsFromParent$onDa.call(propsFromParent, date);
|
|
288
287
|
}
|
|
289
288
|
}))), /*#__PURE__*/React.createElement(Button, {
|
|
290
289
|
type: "submit",
|
|
@@ -16,27 +16,26 @@ const offsetModifier = {
|
|
|
16
16
|
offset: [0, 2]
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
export const CalendarInput =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
19
|
+
export const CalendarInput = ({
|
|
20
|
+
onDateSelect: parentOnDateSelect,
|
|
21
|
+
calendar,
|
|
22
|
+
date,
|
|
23
|
+
dir,
|
|
24
|
+
locale,
|
|
25
|
+
numberingSystem,
|
|
26
|
+
weekDayFormat = 'narrow',
|
|
27
|
+
width = '300px',
|
|
28
|
+
cellSize = '32px',
|
|
29
|
+
clearable,
|
|
30
|
+
minDate,
|
|
31
|
+
maxDate,
|
|
32
|
+
format,
|
|
33
|
+
strictValidation,
|
|
34
|
+
inputWidth,
|
|
35
|
+
dataTest = 'dhis2-uiwidgets-calendar-inputfield',
|
|
36
|
+
pastOnly,
|
|
37
|
+
...rest
|
|
38
|
+
} = {}) => {
|
|
40
39
|
const ref = useRef();
|
|
41
40
|
const calendarRef = useRef();
|
|
42
41
|
const popperRef = useRef();
|
|
@@ -52,7 +51,7 @@ export const CalendarInput = function () {
|
|
|
52
51
|
}), [calendar, locale, numberingSystem, weekDayFormat, pastOnly]);
|
|
53
52
|
const onChooseDate = (date, validationOptions) => {
|
|
54
53
|
if (!date) {
|
|
55
|
-
parentOnDateSelect === null || parentOnDateSelect === void 0
|
|
54
|
+
parentOnDateSelect === null || parentOnDateSelect === void 0 || parentOnDateSelect({
|
|
56
55
|
calendarDateString: null,
|
|
57
56
|
validation: {
|
|
58
57
|
valid: true
|
|
@@ -61,7 +60,7 @@ export const CalendarInput = function () {
|
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
62
|
const validation = validateDateString(date, validationOptions);
|
|
64
|
-
parentOnDateSelect === null || parentOnDateSelect === void 0
|
|
63
|
+
parentOnDateSelect === null || parentOnDateSelect === void 0 || parentOnDateSelect({
|
|
65
64
|
calendarDateString: date,
|
|
66
65
|
validation
|
|
67
66
|
});
|
|
@@ -97,7 +96,7 @@ export const CalendarInput = function () {
|
|
|
97
96
|
const onFocus = () => {
|
|
98
97
|
var _rest$onFocus;
|
|
99
98
|
setOpen(true);
|
|
100
|
-
rest === null || rest === void 0
|
|
99
|
+
rest === null || rest === void 0 || (_rest$onFocus = rest.onFocus) === null || _rest$onFocus === void 0 || _rest$onFocus.call(rest);
|
|
101
100
|
};
|
|
102
101
|
const languageDirection = useResolvedDirection(dir, locale);
|
|
103
102
|
const calendarProps = useMemo(() => ({
|
|
@@ -151,7 +150,7 @@ export const CalendarInput = function () {
|
|
|
151
150
|
modifiers: [offsetModifier],
|
|
152
151
|
onFirstUpdate: component => {
|
|
153
152
|
var _component$elements;
|
|
154
|
-
popperRef.current = component === null || component === void 0
|
|
153
|
+
popperRef.current = component === null || component === void 0 || (_component$elements = component.elements) === null || _component$elements === void 0 ? void 0 : _component$elements.popper;
|
|
155
154
|
}
|
|
156
155
|
}, /*#__PURE__*/React.createElement(CalendarContainer, _extends({}, calendarProps, {
|
|
157
156
|
calendarRef: calendarRef
|
|
@@ -9,5 +9,10 @@
|
|
|
9
9
|
import i18n from '@dhis2/d2-i18n';
|
|
10
10
|
import enTranslations from './en/translations.json';
|
|
11
11
|
const namespace = 'default';
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
// Use 'deep' = true and 'overwrite' = false to add to, but not overwrite,
|
|
14
|
+
// custom translations from the datastore (added by the app adapter)
|
|
15
|
+
|
|
16
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false);
|
|
17
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false);
|
|
13
18
|
export default i18n;
|
|
@@ -26,23 +26,20 @@ export default {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
const buildCalendar =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
onDateSelect: () => {}
|
|
44
|
-
});
|
|
45
|
-
};
|
|
29
|
+
const buildCalendar = ({
|
|
30
|
+
date,
|
|
31
|
+
locale,
|
|
32
|
+
calendar
|
|
33
|
+
}) => () => /*#__PURE__*/React.createElement(CalendarStoryWrapper, {
|
|
34
|
+
component: CalendarInput,
|
|
35
|
+
dir: "ltr",
|
|
36
|
+
timeZone: "Africa/Khartoum",
|
|
37
|
+
weekDayFormat: "short",
|
|
38
|
+
date: date,
|
|
39
|
+
locale: locale,
|
|
40
|
+
calendar: calendar,
|
|
41
|
+
onDateSelect: () => {}
|
|
42
|
+
});
|
|
46
43
|
export const EthiopicWithAmharic = buildCalendar({
|
|
47
44
|
calendar: 'ethiopic',
|
|
48
45
|
locale: 'am-ET',
|
|
@@ -91,11 +88,10 @@ export const IslamicWithArabic = () => {
|
|
|
91
88
|
onDateSelect: () => {}
|
|
92
89
|
}));
|
|
93
90
|
};
|
|
94
|
-
export const CalendarWithClearButton =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
} = _ref2;
|
|
91
|
+
export const CalendarWithClearButton = ({
|
|
92
|
+
calendar = 'gregory',
|
|
93
|
+
date: initialDate = null
|
|
94
|
+
}) => {
|
|
99
95
|
const [date, setDate] = useState(initialDate);
|
|
100
96
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CalendarInput, {
|
|
101
97
|
calendar: calendar,
|
|
@@ -128,11 +124,10 @@ export function CalendarWithStrictValidation() {
|
|
|
128
124
|
calendar: '2022-10-12'
|
|
129
125
|
},
|
|
130
126
|
validate: errored
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} = _ref3;
|
|
127
|
+
}, ({
|
|
128
|
+
handleSubmit,
|
|
129
|
+
invalid
|
|
130
|
+
}) => {
|
|
136
131
|
return /*#__PURE__*/React.createElement("form", {
|
|
137
132
|
onSubmit: handleSubmit
|
|
138
133
|
}, /*#__PURE__*/React.createElement(Field, {
|
|
@@ -182,11 +177,10 @@ export function CalendarWithNonStrictValidation() {
|
|
|
182
177
|
calendar: '2022-10-12'
|
|
183
178
|
},
|
|
184
179
|
validate: errored
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
} = _ref4;
|
|
180
|
+
}, ({
|
|
181
|
+
handleSubmit,
|
|
182
|
+
invalid
|
|
183
|
+
}) => {
|
|
190
184
|
return /*#__PURE__*/React.createElement("form", {
|
|
191
185
|
onSubmit: handleSubmit
|
|
192
186
|
}, /*#__PURE__*/React.createElement(Field, {
|
|
@@ -25,48 +25,43 @@ export const CalendarStoryWrapper = props => {
|
|
|
25
25
|
const [selectedDate, setSelectedDate] = useState({
|
|
26
26
|
calendarDateString: date
|
|
27
27
|
});
|
|
28
|
-
const changeCalendar =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = _ref;
|
|
28
|
+
const changeCalendar = ({
|
|
29
|
+
target: {
|
|
30
|
+
value
|
|
31
|
+
}
|
|
32
|
+
}) => {
|
|
34
33
|
setSelectedCalendar(value);
|
|
35
34
|
};
|
|
36
|
-
const changeNumberingSystem =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = _ref2;
|
|
35
|
+
const changeNumberingSystem = ({
|
|
36
|
+
target: {
|
|
37
|
+
value
|
|
38
|
+
}
|
|
39
|
+
}) => {
|
|
42
40
|
if (value === '-1') {
|
|
43
41
|
setSelectedNumberingSystem(null);
|
|
44
42
|
} else {
|
|
45
43
|
setSelectedNumberingSystem(value);
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
|
-
const changeDirection =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} = _ref3;
|
|
46
|
+
const changeDirection = ({
|
|
47
|
+
target: {
|
|
48
|
+
value
|
|
49
|
+
}
|
|
50
|
+
}) => {
|
|
54
51
|
setSelectedDirection(value);
|
|
55
52
|
};
|
|
56
|
-
const changeWeekFormat =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} = _ref4;
|
|
53
|
+
const changeWeekFormat = ({
|
|
54
|
+
target: {
|
|
55
|
+
value
|
|
56
|
+
}
|
|
57
|
+
}) => {
|
|
62
58
|
setWeekDayFormat(value);
|
|
63
59
|
};
|
|
64
|
-
const onLocaleChanged =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} = _ref5;
|
|
60
|
+
const onLocaleChanged = ({
|
|
61
|
+
target: {
|
|
62
|
+
value
|
|
63
|
+
}
|
|
64
|
+
}) => {
|
|
70
65
|
setLocale(value);
|
|
71
66
|
};
|
|
72
67
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/calendar",
|
|
3
|
-
"version": "10.16.
|
|
3
|
+
"version": "10.16.4",
|
|
4
4
|
"description": "UI Calendar",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dhis2-ui/button": "10.16.
|
|
37
|
-
"@dhis2-ui/card": "10.16.
|
|
38
|
-
"@dhis2-ui/input": "10.16.
|
|
39
|
-
"@dhis2-ui/layer": "10.16.
|
|
40
|
-
"@dhis2-ui/popper": "10.16.
|
|
36
|
+
"@dhis2-ui/button": "10.16.4",
|
|
37
|
+
"@dhis2-ui/card": "10.16.4",
|
|
38
|
+
"@dhis2-ui/input": "10.16.4",
|
|
39
|
+
"@dhis2-ui/layer": "10.16.4",
|
|
40
|
+
"@dhis2-ui/popper": "10.16.4",
|
|
41
41
|
"@dhis2/multi-calendar-dates": "2.1.2",
|
|
42
42
|
"@dhis2/prop-types": "^3.1.2",
|
|
43
|
-
"@dhis2/ui-constants": "10.16.
|
|
44
|
-
"@dhis2/ui-icons": "10.16.
|
|
43
|
+
"@dhis2/ui-constants": "10.16.4",
|
|
44
|
+
"@dhis2/ui-icons": "10.16.4",
|
|
45
45
|
"classnames": "^2.3.1",
|
|
46
46
|
"prop-types": "^15.7.2"
|
|
47
47
|
},
|
package/src/locales/index.js
CHANGED
|
@@ -11,6 +11,11 @@ import i18n from '@dhis2/d2-i18n'
|
|
|
11
11
|
import enTranslations from './en/translations.json'
|
|
12
12
|
|
|
13
13
|
const namespace = 'default'
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
// Use 'deep' = true and 'overwrite' = false to add to, but not overwrite,
|
|
16
|
+
// custom translations from the datastore (added by the app adapter)
|
|
17
|
+
|
|
18
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false)
|
|
19
|
+
i18n.addResourceBundle('en', namespace, enTranslations, true, false)
|
|
15
20
|
|
|
16
21
|
export default i18n
|