@neo4j-ndl/react 2.16.17 → 2.16.18
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/lib/cjs/date-picker/DatePicker.js +39 -9
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/date-picker/utils.js +36 -0
- package/lib/cjs/date-picker/utils.js.map +1 -0
- package/lib/esm/date-picker/DatePicker.js +40 -10
- package/lib/esm/date-picker/DatePicker.js.map +1 -1
- package/lib/esm/date-picker/utils.js +31 -0
- package/lib/esm/date-picker/utils.js.map +1 -0
- package/lib/types/date-picker/utils.d.ts +25 -0
- package/package.json +2 -2
|
@@ -35,11 +35,14 @@ const helpers_1 = require("../helpers");
|
|
|
35
35
|
const icons_1 = require("../icons");
|
|
36
36
|
const text_input_1 = require("../text-input");
|
|
37
37
|
const typography_1 = require("../typography");
|
|
38
|
+
const utils_1 = require("./utils");
|
|
38
39
|
exports.DatePicker = (0, helpers_1.forwardRef)(function DatePicker(props, ref) {
|
|
40
|
+
var _a;
|
|
39
41
|
const { reactDatePickerProps, textInputProps, disabled, className } = props;
|
|
40
42
|
const classes = (0, defaultImports_1.classNames)(`ndl-datepicker`, className, {});
|
|
41
43
|
const datetimeRef = (0, react_1.useRef)(null);
|
|
42
44
|
const [picker, setPicker] = (0, react_1.useState)('day');
|
|
45
|
+
const [preSelectedDate, setPreSelectedDate] = (0, react_1.useState)((_a = reactDatePickerProps.selected) !== null && _a !== void 0 ? _a : reactDatePickerProps.startDate);
|
|
43
46
|
const headerAction = (0, react_1.useCallback)((action) => {
|
|
44
47
|
picker === action ? setPicker('day') : setPicker(action);
|
|
45
48
|
}, [picker]);
|
|
@@ -49,22 +52,32 @@ exports.DatePicker = (0, helpers_1.forwardRef)(function DatePicker(props, ref) {
|
|
|
49
52
|
const nextCallback = picker === 'year' ? increaseYear : increaseMonth;
|
|
50
53
|
const prevDisabled = picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;
|
|
51
54
|
const nextDisabled = picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-datepicker-header", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ndl-datepicker-selects", children: [(0, jsx_runtime_1.jsx)("button", {
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "ndl-datepicker-header", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ndl-datepicker-selects", children: [picker !== 'year' && ((0, jsx_runtime_1.jsx)("button", { "aria-label": `${picker === 'month' ? 'Close' : 'Open'} month picker`, "aria-pressed": picker === 'month', onClick: () => headerAction('month'), children: (0, jsx_runtime_1.jsxs)("div", { className: "n-flex n-items-center n-gap-token-3", children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "subheading-small", children: (0, date_fns_1.format)(props.date, 'MMM') }), (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: (0, defaultImports_1.classNames)('ndl-datepicker-chevron', {
|
|
53
56
|
'n-rotate-180': picker === 'month',
|
|
54
|
-
}), "aria-label": "Chevron icon" })] }) }), (0, jsx_runtime_1.jsx)("button", {
|
|
57
|
+
}), "aria-label": "Chevron icon" })] }) })), picker !== 'month' && ((0, jsx_runtime_1.jsx)("button", { "aria-label": `${picker === 'year' ? 'Close' : 'Open'} year picker`, onClick: () => headerAction('year'), children: (0, jsx_runtime_1.jsxs)("div", { className: "n-flex n-items-center n-gap-token-3", children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "subheading-small", children: picker === 'year'
|
|
58
|
+
? (0, utils_1.getYearsPeriodString)(props.date, reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.yearItemNumber)
|
|
59
|
+
: (0, date_fns_1.format)(props.date, 'yyyy') }), (0, jsx_runtime_1.jsx)(icons_1.ChevronDownIconOutline, { className: (0, defaultImports_1.classNames)('ndl-datepicker-chevron', {
|
|
55
60
|
'n-rotate-180': picker === 'year',
|
|
56
|
-
}), "aria-label": "Chevron icon" })] }) })] }), picker !== 'month' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(button_1.IconButton, { "aria-label": "Previous period", clean: true, onClick: prevCallback, disabled: prevDisabled, children: (0, jsx_runtime_1.jsx)(icons_1.ArrowLeftIconOutline, {}) }), (0, jsx_runtime_1.jsx)(button_1.IconButton, { "aria-label": "Next period", clean: true, onClick: nextCallback, disabled: nextDisabled, children: (0, jsx_runtime_1.jsx)(icons_1.ArrowRightIconOutline, {}) })] }))] }));
|
|
57
|
-
}, [picker, headerAction]);
|
|
61
|
+
}), "aria-label": "Chevron icon" })] }) }))] }), picker !== 'month' && ((0, jsx_runtime_1.jsxs)("div", { className: "n-flex n-justify-center n-gap-token-6", children: [(0, jsx_runtime_1.jsx)(button_1.IconButton, { "aria-label": "Previous period", clean: true, onClick: prevCallback, disabled: prevDisabled, className: "n-text-palette-neutral-text-default;", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.ArrowLeftIconOutline, {}) }), (0, jsx_runtime_1.jsx)(button_1.IconButton, { "aria-label": "Next period", clean: true, onClick: nextCallback, disabled: nextDisabled, className: "n-text-palette-neutral-text-default;", size: "small", children: (0, jsx_runtime_1.jsx)(icons_1.ArrowRightIconOutline, {}) })] }))] }));
|
|
62
|
+
}, [picker, headerAction, reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.yearItemNumber]);
|
|
58
63
|
/**
|
|
59
64
|
* Intercept onChange so we can work with
|
|
60
65
|
* Month and Year pickers
|
|
61
66
|
*/
|
|
62
67
|
const interceptedChange = (0, react_1.useCallback)((...args) => {
|
|
63
68
|
if (picker !== 'day') {
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
// setTimeout to prevent picker change before the handleMonthChange logic
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
setPicker('day');
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
|
-
else {
|
|
74
|
+
else if (picker === 'day') {
|
|
75
|
+
if (args[0] instanceof Date) {
|
|
76
|
+
setPreSelectedDate(args[0]);
|
|
77
|
+
}
|
|
78
|
+
else if (args[0] !== null) {
|
|
79
|
+
setPreSelectedDate(args[0][0]);
|
|
80
|
+
}
|
|
68
81
|
reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onChange(...args);
|
|
69
82
|
}
|
|
70
83
|
}, [picker, reactDatePickerProps]);
|
|
@@ -80,13 +93,30 @@ exports.DatePicker = (0, helpers_1.forwardRef)(function DatePicker(props, ref) {
|
|
|
80
93
|
}
|
|
81
94
|
(_a = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onCalendarClose) === null || _a === void 0 ? void 0 : _a.call(reactDatePickerProps);
|
|
82
95
|
}, [picker, reactDatePickerProps]);
|
|
83
|
-
|
|
96
|
+
const handleMonthChange = (0, react_1.useCallback)((date) => {
|
|
97
|
+
var _a, _b, _c, _d, _e;
|
|
98
|
+
if (picker === 'month') {
|
|
99
|
+
const selectedDay = (_a = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getDate()) !== null && _a !== void 0 ? _a : 1;
|
|
100
|
+
const daysInNewMonth = (0, utils_1.daysInMonth)(date.getMonth(), date.getFullYear());
|
|
101
|
+
date.setDate(Math.min(selectedDay, daysInNewMonth));
|
|
102
|
+
(_b = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onMonthChange) === null || _b === void 0 ? void 0 : _b.call(reactDatePickerProps, date);
|
|
103
|
+
}
|
|
104
|
+
else if (picker === 'year') {
|
|
105
|
+
const selectedDay = (_c = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getDate()) !== null && _c !== void 0 ? _c : 1;
|
|
106
|
+
const selectedMonth = (_d = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getMonth()) !== null && _d !== void 0 ? _d : 0;
|
|
107
|
+
const daysInNewMonth = (0, utils_1.daysInMonth)(selectedMonth, date.getFullYear());
|
|
108
|
+
date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));
|
|
109
|
+
(_e = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onMonthChange) === null || _e === void 0 ? void 0 : _e.call(reactDatePickerProps, date);
|
|
110
|
+
}
|
|
111
|
+
setPreSelectedDate(date);
|
|
112
|
+
}, [picker, preSelectedDate, reactDatePickerProps]);
|
|
113
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: classes, children: (0, jsx_runtime_1.jsx)(react_datepicker_1.default, Object.assign({ ref: datetimeRef, customInput: (0, jsx_runtime_1.jsx)(text_input_1.TextInput, Object.assign({ ref: ref, "aria-label": "Date picker input", rightIcon: (0, jsx_runtime_1.jsx)(icons_1.CalendarDaysIconOutline, { onClick: (e) => {
|
|
84
114
|
var _a;
|
|
85
115
|
if ((_a = datetimeRef.current) === null || _a === void 0 ? void 0 : _a.isCalendarOpen()) {
|
|
86
116
|
datetimeRef.current.setOpen(false);
|
|
87
117
|
e.preventDefault();
|
|
88
118
|
e.stopPropagation();
|
|
89
119
|
}
|
|
90
|
-
}, "aria-label": "Calender Icon" }) }, textInputProps, { disabled: disabled })), disabled: disabled, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day', dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, reactDatePickerProps, { onChange: interceptedChange, onCalendarClose: interceptedOnCalendarClose })) }));
|
|
120
|
+
}, "aria-label": "Calender Icon" }) }, textInputProps, { disabled: disabled })), disabled: disabled, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day', dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, reactDatePickerProps, { onChange: interceptedChange, onMonthChange: handleMonthChange, onCalendarClose: interceptedOnCalendarClose })) }));
|
|
91
121
|
});
|
|
92
122
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;AAAA,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uCAAkC;AAClC,iCAAyE;AACzE,wEAG0B;AAE1B,8DAAuD;AACvD,sCAAuC;AACvC,wCAA0D;AAC1D,oCAKkB;AAClB,8CAA0C;AAE1C,8CAA2C;
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;AAAA,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uCAAkC;AAClC,iCAAyE;AACzE,wEAG0B;AAE1B,8DAAuD;AACvD,sCAAuC;AACvC,wCAA0D;AAC1D,oCAKkB;AAClB,8CAA0C;AAE1C,8CAA2C;AAC3C,mCAA4D;AAwB/C,QAAA,UAAU,GAAG,IAAA,oBAAU,EAAC,SAAS,UAAU,CACtD,KAAyB,EACzB,GAAmC;;IAEnC,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAE5E,MAAM,OAAO,GAAG,IAAA,2BAAU,EAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,WAAW,GAAG,IAAA,cAAM,EAAkB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAa,KAAK,CAAC,CAAC;IACxD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EACpD,MAAA,oBAAoB,CAAC,QAAQ,mCAAI,oBAAoB,CAAC,SAAS,CAChE,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,CAAC,MAA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IAAI,MAAA,WAAW,CAAC,OAAO,0CAAE,cAAc,EAAE,EAAE;4BACzC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;4BACnC,CAAC,CAAC,cAAc,EAAE,CAAC;4BACnB,CAAC,CAAC,eAAe,EAAE,CAAC;yBACrB;oBACH,CAAC,gBACU,eAAe,GAC1B,IAEA,cAAc,IAClB,QAAQ,EAAE,QAAQ,IAClB,EAEJ,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,MAAM,KAAK,OAAO,EACvC,cAAc,EAAE,MAAM,KAAK,MAAM,EACjC,mBAAmB,EAAE,MAAM,KAAK,KAAK,EACrC,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,EACxC,kBAAkB,EAAE,YAAY,IAC5B,oBAAoB,IACxB,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,iBAAiB,EAChC,eAAe,EAAE,0BAA0B,IAC3C,GACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.daysInMonth = exports.getYearsPeriodString = void 0;
|
|
24
|
+
const date_fns_1 = require("date-fns");
|
|
25
|
+
/**
|
|
26
|
+
* A version of getYearsPeriod copied from https://github.com/Hacker0x01/react-datepicker/blob/main/src/date_utils.ts
|
|
27
|
+
*/
|
|
28
|
+
function getYearsPeriodString(date, yearItemNumber = 12) {
|
|
29
|
+
const endPeriod = Math.ceil(+(0, date_fns_1.format)(date, 'yyyy') / yearItemNumber) * yearItemNumber;
|
|
30
|
+
const startPeriod = endPeriod - (yearItemNumber - 1);
|
|
31
|
+
return `${startPeriod}-${endPeriod}`;
|
|
32
|
+
}
|
|
33
|
+
exports.getYearsPeriodString = getYearsPeriodString;
|
|
34
|
+
const daysInMonth = (month, year) => new Date(year, month + 1, 0).getDate();
|
|
35
|
+
exports.daysInMonth = daysInMonth;
|
|
36
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/date-picker/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,uCAAkC;AAElC;;GAEG;AACH,SAAgB,oBAAoB,CAClC,IAAU,EACV,iBAAyB,EAAE;IAE3B,MAAM,SAAS,GACb,IAAI,CAAC,IAAI,CAAC,CAAC,IAAA,iBAAM,EAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IACrE,MAAM,WAAW,GAAG,SAAS,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,GAAG,WAAW,IAAI,SAAS,EAAE,CAAC;AACvC,CAAC;AARD,oDAQC;AAEM,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE,CACzD,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAD5B,QAAA,WAAW,eACiB"}
|
|
@@ -26,14 +26,17 @@ import ReactDatePicker from 'react-datepicker';
|
|
|
26
26
|
import { classNames } from '../_common/defaultImports';
|
|
27
27
|
import { IconButton } from '../button';
|
|
28
28
|
import { forwardRef } from '../helpers';
|
|
29
|
-
import { ArrowLeftIconOutline, ArrowRightIconOutline,
|
|
29
|
+
import { ArrowLeftIconOutline, ArrowRightIconOutline, CalendarDaysIconOutline, ChevronDownIconOutline, } from '../icons';
|
|
30
30
|
import { TextInput } from '../text-input';
|
|
31
31
|
import { Typography } from '../typography';
|
|
32
|
+
import { daysInMonth, getYearsPeriodString } from './utils';
|
|
32
33
|
export const DatePicker = forwardRef(function DatePicker(props, ref) {
|
|
34
|
+
var _a;
|
|
33
35
|
const { reactDatePickerProps, textInputProps, disabled, className } = props;
|
|
34
36
|
const classes = classNames(`ndl-datepicker`, className, {});
|
|
35
37
|
const datetimeRef = useRef(null);
|
|
36
38
|
const [picker, setPicker] = useState('day');
|
|
39
|
+
const [preSelectedDate, setPreSelectedDate] = useState((_a = reactDatePickerProps.selected) !== null && _a !== void 0 ? _a : reactDatePickerProps.startDate);
|
|
37
40
|
const headerAction = useCallback((action) => {
|
|
38
41
|
picker === action ? setPicker('day') : setPicker(action);
|
|
39
42
|
}, [picker]);
|
|
@@ -43,22 +46,32 @@ export const DatePicker = forwardRef(function DatePicker(props, ref) {
|
|
|
43
46
|
const nextCallback = picker === 'year' ? increaseYear : increaseMonth;
|
|
44
47
|
const prevDisabled = picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;
|
|
45
48
|
const nextDisabled = picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;
|
|
46
|
-
return (_jsxs("div", { className: "ndl-datepicker-header", children: [_jsxs("div", { className: "ndl-datepicker-selects", children: [_jsx("button", {
|
|
49
|
+
return (_jsxs("div", { className: "ndl-datepicker-header", children: [_jsxs("div", { className: "ndl-datepicker-selects", children: [picker !== 'year' && (_jsx("button", { "aria-label": `${picker === 'month' ? 'Close' : 'Open'} month picker`, "aria-pressed": picker === 'month', onClick: () => headerAction('month'), children: _jsxs("div", { className: "n-flex n-items-center n-gap-token-3", children: [_jsx(Typography, { variant: "subheading-small", children: format(props.date, 'MMM') }), _jsx(ChevronDownIconOutline, { className: classNames('ndl-datepicker-chevron', {
|
|
47
50
|
'n-rotate-180': picker === 'month',
|
|
48
|
-
}), "aria-label": "Chevron icon" })] }) }), _jsx("button", {
|
|
51
|
+
}), "aria-label": "Chevron icon" })] }) })), picker !== 'month' && (_jsx("button", { "aria-label": `${picker === 'year' ? 'Close' : 'Open'} year picker`, onClick: () => headerAction('year'), children: _jsxs("div", { className: "n-flex n-items-center n-gap-token-3", children: [_jsx(Typography, { variant: "subheading-small", children: picker === 'year'
|
|
52
|
+
? getYearsPeriodString(props.date, reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.yearItemNumber)
|
|
53
|
+
: format(props.date, 'yyyy') }), _jsx(ChevronDownIconOutline, { className: classNames('ndl-datepicker-chevron', {
|
|
49
54
|
'n-rotate-180': picker === 'year',
|
|
50
|
-
}), "aria-label": "Chevron icon" })] }) })] }), picker !== 'month' && (_jsxs("div", { children: [_jsx(IconButton, { "aria-label": "Previous period", clean: true, onClick: prevCallback, disabled: prevDisabled, children: _jsx(ArrowLeftIconOutline, {}) }), _jsx(IconButton, { "aria-label": "Next period", clean: true, onClick: nextCallback, disabled: nextDisabled, children: _jsx(ArrowRightIconOutline, {}) })] }))] }));
|
|
51
|
-
}, [picker, headerAction]);
|
|
55
|
+
}), "aria-label": "Chevron icon" })] }) }))] }), picker !== 'month' && (_jsxs("div", { className: "n-flex n-justify-center n-gap-token-6", children: [_jsx(IconButton, { "aria-label": "Previous period", clean: true, onClick: prevCallback, disabled: prevDisabled, className: "n-text-palette-neutral-text-default;", size: "small", children: _jsx(ArrowLeftIconOutline, {}) }), _jsx(IconButton, { "aria-label": "Next period", clean: true, onClick: nextCallback, disabled: nextDisabled, className: "n-text-palette-neutral-text-default;", size: "small", children: _jsx(ArrowRightIconOutline, {}) })] }))] }));
|
|
56
|
+
}, [picker, headerAction, reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.yearItemNumber]);
|
|
52
57
|
/**
|
|
53
58
|
* Intercept onChange so we can work with
|
|
54
59
|
* Month and Year pickers
|
|
55
60
|
*/
|
|
56
61
|
const interceptedChange = useCallback((...args) => {
|
|
57
62
|
if (picker !== 'day') {
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
// setTimeout to prevent picker change before the handleMonthChange logic
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
setPicker('day');
|
|
66
|
+
});
|
|
60
67
|
}
|
|
61
|
-
else {
|
|
68
|
+
else if (picker === 'day') {
|
|
69
|
+
if (args[0] instanceof Date) {
|
|
70
|
+
setPreSelectedDate(args[0]);
|
|
71
|
+
}
|
|
72
|
+
else if (args[0] !== null) {
|
|
73
|
+
setPreSelectedDate(args[0][0]);
|
|
74
|
+
}
|
|
62
75
|
reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onChange(...args);
|
|
63
76
|
}
|
|
64
77
|
}, [picker, reactDatePickerProps]);
|
|
@@ -74,13 +87,30 @@ export const DatePicker = forwardRef(function DatePicker(props, ref) {
|
|
|
74
87
|
}
|
|
75
88
|
(_a = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onCalendarClose) === null || _a === void 0 ? void 0 : _a.call(reactDatePickerProps);
|
|
76
89
|
}, [picker, reactDatePickerProps]);
|
|
77
|
-
|
|
90
|
+
const handleMonthChange = useCallback((date) => {
|
|
91
|
+
var _a, _b, _c, _d, _e;
|
|
92
|
+
if (picker === 'month') {
|
|
93
|
+
const selectedDay = (_a = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getDate()) !== null && _a !== void 0 ? _a : 1;
|
|
94
|
+
const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());
|
|
95
|
+
date.setDate(Math.min(selectedDay, daysInNewMonth));
|
|
96
|
+
(_b = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onMonthChange) === null || _b === void 0 ? void 0 : _b.call(reactDatePickerProps, date);
|
|
97
|
+
}
|
|
98
|
+
else if (picker === 'year') {
|
|
99
|
+
const selectedDay = (_c = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getDate()) !== null && _c !== void 0 ? _c : 1;
|
|
100
|
+
const selectedMonth = (_d = preSelectedDate === null || preSelectedDate === void 0 ? void 0 : preSelectedDate.getMonth()) !== null && _d !== void 0 ? _d : 0;
|
|
101
|
+
const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());
|
|
102
|
+
date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));
|
|
103
|
+
(_e = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onMonthChange) === null || _e === void 0 ? void 0 : _e.call(reactDatePickerProps, date);
|
|
104
|
+
}
|
|
105
|
+
setPreSelectedDate(date);
|
|
106
|
+
}, [picker, preSelectedDate, reactDatePickerProps]);
|
|
107
|
+
return (_jsx("div", { className: classes, children: _jsx(ReactDatePicker, Object.assign({ ref: datetimeRef, customInput: _jsx(TextInput, Object.assign({ ref: ref, "aria-label": "Date picker input", rightIcon: _jsx(CalendarDaysIconOutline, { onClick: (e) => {
|
|
78
108
|
var _a;
|
|
79
109
|
if ((_a = datetimeRef.current) === null || _a === void 0 ? void 0 : _a.isCalendarOpen()) {
|
|
80
110
|
datetimeRef.current.setOpen(false);
|
|
81
111
|
e.preventDefault();
|
|
82
112
|
e.stopPropagation();
|
|
83
113
|
}
|
|
84
|
-
}, "aria-label": "Calender Icon" }) }, textInputProps, { disabled: disabled })), disabled: disabled, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day', dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, reactDatePickerProps, { onChange: interceptedChange, onCalendarClose: interceptedOnCalendarClose })) }));
|
|
114
|
+
}, "aria-label": "Calender Icon" }) }, textInputProps, { disabled: disabled })), disabled: disabled, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day', dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, reactDatePickerProps, { onChange: interceptedChange, onMonthChange: handleMonthChange, onCalendarClose: interceptedOnCalendarClose })) }));
|
|
85
115
|
});
|
|
86
116
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAqB,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,eAGN,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAqB,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,eAGN,MAAM,kBAAkB,CA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AE,MAAM,KAAK,MAAM,EACjC,mBAAmB,EAAE,MAAM,KAAK,KAAK,EACrC,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,EACxC,kBAAkB,EAAE,YAAY,IAC5B,oBAAoB,IACxB,QAAQ,EAAE,iBAAiB,EAC3B,aAAa,EAAE,iBAAiB,EAChC,eAAe,EAAE,0BAA0B,IAC3C,GACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { format } from 'date-fns';
|
|
22
|
+
/**
|
|
23
|
+
* A version of getYearsPeriod copied from https://github.com/Hacker0x01/react-datepicker/blob/main/src/date_utils.ts
|
|
24
|
+
*/
|
|
25
|
+
export function getYearsPeriodString(date, yearItemNumber = 12) {
|
|
26
|
+
const endPeriod = Math.ceil(+format(date, 'yyyy') / yearItemNumber) * yearItemNumber;
|
|
27
|
+
const startPeriod = endPeriod - (yearItemNumber - 1);
|
|
28
|
+
return `${startPeriod}-${endPeriod}`;
|
|
29
|
+
}
|
|
30
|
+
export const daysInMonth = (month, year) => new Date(year, month + 1, 0).getDate();
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/date-picker/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAU,EACV,iBAAyB,EAAE;IAE3B,MAAM,SAAS,GACb,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;IACrE,MAAM,WAAW,GAAG,SAAS,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,GAAG,WAAW,IAAI,SAAS,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE,CACzD,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* A version of getYearsPeriod copied from https://github.com/Hacker0x01/react-datepicker/blob/main/src/date_utils.ts
|
|
23
|
+
*/
|
|
24
|
+
export declare function getYearsPeriodString(date: Date, yearItemNumber?: number): string;
|
|
25
|
+
export declare const daysInMonth: (month: number, year: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.18",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React implementation of Neo4j Design System",
|
|
6
6
|
"keywords": [
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"sonner": "1.4.41",
|
|
93
93
|
"tinycolor2": "^1.4.2",
|
|
94
94
|
"usehooks-ts": "2.9.1",
|
|
95
|
-
"@neo4j-ndl/base": "^2.12.
|
|
95
|
+
"@neo4j-ndl/base": "^2.12.12"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"generate-component": "node ./scripts/component-generator.js",
|