@neo4j-ndl/react 4.0.19 → 4.1.1
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 +11 -3
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/date-picker/stories/date-picker-with-timezone-both-mode.story.js +57 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone-both-mode.story.js.map +1 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone.story.js +52 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone.story.js.map +1 -0
- package/lib/cjs/date-picker/stories/date-picker.stories.js +27 -1
- package/lib/cjs/date-picker/stories/date-picker.stories.js.map +1 -1
- package/lib/cjs/date-picker/stories/index.js +9 -1
- package/lib/cjs/date-picker/stories/index.js.map +1 -1
- package/lib/cjs/dropzone/Dropzone.js +1 -1
- package/lib/cjs/dropzone/Dropzone.js.map +1 -1
- package/lib/cjs/index.js +4 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/timezone-picker/TimeZonePicker.js +330 -0
- package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -0
- package/lib/cjs/timezone-picker/generate-timezone-options.js +256 -0
- package/lib/cjs/timezone-picker/generate-timezone-options.js.map +1 -0
- package/lib/cjs/timezone-picker/index.js +39 -0
- package/lib/cjs/timezone-picker/index.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/index.js +60 -0
- package/lib/cjs/timezone-picker/stories/index.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-both-mode.story.js +41 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-both-mode.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-default.story.js +35 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-default.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-disabled.story.js +30 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-disabled.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +54 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js +30 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-in-dialog.story.js +47 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-in-dialog.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-sizes.story.js +32 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-sizes.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-utc-only.story.js +49 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-utc-only.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js +145 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js.map +1 -0
- package/lib/cjs/timezone-picker/timezone-picker-hooks.js +52 -0
- package/lib/cjs/timezone-picker/timezone-picker-hooks.js.map +1 -0
- package/lib/esm/date-picker/DatePicker.js +11 -3
- package/lib/esm/date-picker/DatePicker.js.map +1 -1
- package/lib/esm/date-picker/stories/date-picker-with-timezone-both-mode.story.js +53 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone-both-mode.story.js.map +1 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone.story.js +50 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone.story.js.map +1 -0
- package/lib/esm/date-picker/stories/date-picker.stories.js +27 -1
- package/lib/esm/date-picker/stories/date-picker.stories.js.map +1 -1
- package/lib/esm/date-picker/stories/index.js +6 -0
- package/lib/esm/date-picker/stories/index.js.map +1 -1
- package/lib/esm/dropzone/Dropzone.js +1 -1
- package/lib/esm/dropzone/Dropzone.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/timezone-picker/TimeZonePicker.js +323 -0
- package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -0
- package/lib/esm/timezone-picker/generate-timezone-options.js +247 -0
- package/lib/esm/timezone-picker/generate-timezone-options.js.map +1 -0
- package/lib/esm/timezone-picker/index.js +23 -0
- package/lib/esm/timezone-picker/index.js.map +1 -0
- package/lib/esm/timezone-picker/stories/index.js +46 -0
- package/lib/esm/timezone-picker/stories/index.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-both-mode.story.js +37 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-both-mode.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-default.story.js +33 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-default.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-disabled.story.js +28 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-disabled.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +52 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js +28 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-in-dialog.story.js +45 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-in-dialog.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-sizes.story.js +30 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-sizes.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-utc-only.story.js +47 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-utc-only.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker.stories.js +142 -0
- package/lib/esm/timezone-picker/stories/timezone-picker.stories.js.map +1 -0
- package/lib/esm/timezone-picker/timezone-picker-hooks.js +47 -0
- package/lib/esm/timezone-picker/timezone-picker-hooks.js.map +1 -0
- package/lib/types/date-picker/DatePicker.d.ts +4 -1
- package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
- package/lib/types/date-picker/stories/date-picker-with-timezone-both-mode.story.d.ts +23 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone-both-mode.story.d.ts.map +1 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone.story.d.ts +24 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone.story.d.ts.map +1 -0
- package/lib/types/date-picker/stories/date-picker.stories.d.ts +2 -0
- package/lib/types/date-picker/stories/date-picker.stories.d.ts.map +1 -1
- package/lib/types/date-picker/stories/index.d.ts +4 -0
- package/lib/types/date-picker/stories/index.d.ts.map +1 -1
- package/lib/types/dropzone/Dropzone.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/timezone-picker/TimeZonePicker.d.ts +68 -0
- package/lib/types/timezone-picker/TimeZonePicker.d.ts.map +1 -0
- package/lib/types/timezone-picker/generate-timezone-options.d.ts +61 -0
- package/lib/types/timezone-picker/generate-timezone-options.d.ts.map +1 -0
- package/lib/types/timezone-picker/index.d.ts +23 -0
- package/lib/types/timezone-picker/index.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/index.d.ts +37 -0
- package/lib/types/timezone-picker/stories/index.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-both-mode.story.d.ts +23 -0
- package/lib/types/timezone-picker/stories/timezone-picker-both-mode.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-default.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-default.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-disabled.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-disabled.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-fluid.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-fluid.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-in-dialog.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-in-dialog.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-sizes.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-sizes.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-utc-only.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-utc-only.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker.stories.d.ts +34 -0
- package/lib/types/timezone-picker/stories/timezone-picker.stories.d.ts.map +1 -0
- package/lib/types/timezone-picker/timezone-picker-hooks.d.ts +31 -0
- package/lib/types/timezone-picker/timezone-picker-hooks.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const Component = () => {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { width: '100%', maxWidth: '400px' }, children: (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Select Timezone", isFluid: true }) }));
|
|
28
|
+
};
|
|
29
|
+
exports.default = Component;
|
|
30
|
+
//# sourceMappingURL=timezone-picker-fluid.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-fluid.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-fluid.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAElD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,gCAAK,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,YAC9C,uBAAC,sBAAc,IAAC,KAAK,EAAC,iBAAiB,EAAC,OAAO,SAAG,GAC9C,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <div style={{ width: '100%', maxWidth: '400px' }}>\n <TimeZonePicker label=\"Select Timezone\" isFluid />\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const react_2 = require("react");
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [isOpen, setIsOpen] = (0, react_2.useState)(false);
|
|
29
|
+
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('UTC');
|
|
30
|
+
const [tempTimeZone, setTempTimeZone] = (0, react_2.useState)('UTC');
|
|
31
|
+
const ref = (0, react_2.useRef)(null);
|
|
32
|
+
const handleOpen = () => {
|
|
33
|
+
setTempTimeZone(selectedTimeZone);
|
|
34
|
+
setIsOpen(true);
|
|
35
|
+
};
|
|
36
|
+
const handleClose = () => setIsOpen(false);
|
|
37
|
+
const handleSave = () => {
|
|
38
|
+
setSelectedTimeZone(tempTimeZone);
|
|
39
|
+
setIsOpen(false);
|
|
40
|
+
};
|
|
41
|
+
const handleTimeZoneChange = (timezone) => {
|
|
42
|
+
setTempTimeZone(timezone);
|
|
43
|
+
};
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: "n-flex n-flex-col n-items-center n-justify-center n-relative n-h-[500px] n-w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: "n-flex n-flex-col n-items-center n-gap-4", children: [(0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: handleOpen, children: "Select Timezone" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("p", { children: ["Selected Timezone: ", selectedTimeZone] }) })] }), (0, jsx_runtime_1.jsxs)(react_1.Dialog, { onClose: handleClose, isOpen: isOpen, container: (ref === null || ref === void 0 ? void 0 : ref.current) || undefined, size: "medium", children: [(0, jsx_runtime_1.jsx)(react_1.Dialog.Header, { children: "Select Timezone" }), (0, jsx_runtime_1.jsx)(react_1.Dialog.Description, { children: "Choose a timezone from the list below" }), (0, jsx_runtime_1.jsx)(react_1.Dialog.Content, { children: (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Timezone", value: tempTimeZone, onChange: handleTimeZoneChange, isFluid: true }) }), (0, jsx_runtime_1.jsxs)(react_1.Dialog.Actions, { children: [(0, jsx_runtime_1.jsx)(react_1.OutlinedButton, { onClick: handleClose, variant: "neutral", size: "medium", children: "Cancel" }), (0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: handleSave, size: "medium", children: "Save" })] })] })] }));
|
|
45
|
+
};
|
|
46
|
+
exports.default = Component;
|
|
47
|
+
//# sourceMappingURL=timezone-picker-in-dialog.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-in-dialog.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-in-dialog.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAK0B;AAC1B,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IACrD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAS,KAAK,CAAC,CAAC;IACxE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAS,KAAK,CAAC,CAAC;IAChE,MAAM,GAAG,GAAG,IAAA,cAAM,EAAwB,IAAI,CAAC,CAAC;IAEhD,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAClC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAClC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE;QAChD,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO,CACL,iCACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAC,mFAAmF,aAE7F,iCAAK,SAAS,EAAC,0CAA0C,aACvD,uBAAC,oBAAY,IAAC,OAAO,EAAE,UAAU,gCAAgC,EACjE,0CACE,iEAAuB,gBAAgB,IAAK,GACxC,IACF,EACN,wBAAC,cAAM,IACL,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,KAAI,SAAS,EACpC,IAAI,EAAC,QAAQ,aAEb,uBAAC,cAAM,CAAC,MAAM,kCAAgC,EAC9C,uBAAC,cAAM,CAAC,WAAW,wDAEE,EACrB,uBAAC,cAAM,CAAC,OAAO,cACb,uBAAC,sBAAc,IACb,KAAK,EAAC,UAAU,EAChB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,SACP,GACa,EACjB,wBAAC,cAAM,CAAC,OAAO,eACb,uBAAC,sBAAc,IAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,uBAEpD,EACjB,uBAAC,oBAAY,IAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAC,QAAQ,qBAEjC,IACA,IACV,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport {\n Dialog,\n FilledButton,\n OutlinedButton,\n TimeZonePicker,\n} from '@neo4j-ndl/react';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isOpen, setIsOpen] = useState<boolean>(false);\n const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');\n const [tempTimeZone, setTempTimeZone] = useState<string>('UTC');\n const ref = useRef<HTMLDivElement | null>(null);\n\n const handleOpen = () => {\n setTempTimeZone(selectedTimeZone);\n setIsOpen(true);\n };\n\n const handleClose = () => setIsOpen(false);\n\n const handleSave = () => {\n setSelectedTimeZone(tempTimeZone);\n setIsOpen(false);\n };\n\n const handleTimeZoneChange = (timezone: string) => {\n setTempTimeZone(timezone);\n };\n\n return (\n <div\n ref={ref}\n className=\"n-flex n-flex-col n-items-center n-justify-center n-relative n-h-[500px] n-w-full\"\n >\n <div className=\"n-flex n-flex-col n-items-center n-gap-4\">\n <FilledButton onClick={handleOpen}>Select Timezone</FilledButton>\n <div>\n <p>Selected Timezone: {selectedTimeZone}</p>\n </div>\n </div>\n <Dialog\n onClose={handleClose}\n isOpen={isOpen}\n container={ref?.current || undefined}\n size=\"medium\"\n >\n <Dialog.Header>Select Timezone</Dialog.Header>\n <Dialog.Description>\n Choose a timezone from the list below\n </Dialog.Description>\n <Dialog.Content>\n <TimeZonePicker\n label=\"Timezone\"\n value={tempTimeZone}\n onChange={handleTimeZoneChange}\n isFluid\n />\n </Dialog.Content>\n <Dialog.Actions>\n <OutlinedButton onClick={handleClose} variant=\"neutral\" size=\"medium\">\n Cancel\n </OutlinedButton>\n <FilledButton onClick={handleSave} size=\"medium\">\n Save\n </FilledButton>\n </Dialog.Actions>\n </Dialog>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const react_2 = require("react");
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('Europe/Stockholm');
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [(0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Small", value: selectedTimeZone, onChange: setSelectedTimeZone, size: "small" }), (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Medium (default)", value: selectedTimeZone, onChange: setSelectedTimeZone, size: "medium" }), (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Large", value: selectedTimeZone, onChange: setSelectedTimeZone, size: "large" })] }));
|
|
30
|
+
};
|
|
31
|
+
exports.default = Component;
|
|
32
|
+
//# sourceMappingURL=timezone-picker-sizes.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-sizes.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-sizes.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,IAAA,gBAAQ,EAAS,kBAAkB,CAAC,CAAC;IAEvC,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,aACnE,uBAAC,sBAAc,IACb,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,OAAO,GACZ,EACF,uBAAC,sBAAc,IACb,KAAK,EAAC,kBAAkB,EACxB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,QAAQ,GACb,EACF,uBAAC,sBAAc,IACb,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,OAAO,GACZ,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] =\n useState<string>('Europe/Stockholm');\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>\n <TimeZonePicker\n label=\"Small\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n size=\"small\"\n />\n <TimeZonePicker\n label=\"Medium (default)\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n size=\"medium\"\n />\n <TimeZonePicker\n label=\"Large\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n size=\"large\"\n />\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const react_2 = require("react");
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('UTC');
|
|
29
|
+
const handleTimeZoneChange = (timezone) => {
|
|
30
|
+
setSelectedTimeZone(timezone);
|
|
31
|
+
};
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Select UTC Timezone", value: selectedTimeZone, onChange: handleTimeZoneChange, mode: "utc" }), (0, jsx_runtime_1.jsxs)("div", { style: { marginTop: '1rem' }, children: [(0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Selected Timezone:" }), " ", selectedTimeZone] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
33
|
+
backgroundColor: '#f5f5f5',
|
|
34
|
+
borderRadius: '4px',
|
|
35
|
+
marginTop: '1rem',
|
|
36
|
+
padding: '1rem',
|
|
37
|
+
}, children: [(0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsx)("strong", { children: "Features:" }) }), (0, jsx_runtime_1.jsxs)("ul", { style: {
|
|
38
|
+
fontSize: '0.9em',
|
|
39
|
+
margin: 0,
|
|
40
|
+
paddingLeft: '1.5rem',
|
|
41
|
+
}, children: [(0, jsx_runtime_1.jsx)("li", { children: "Select from common UTC offsets (UTC-12 to UTC+14)" }), (0, jsx_runtime_1.jsx)("li", { children: "Includes fractional offsets (UTC+5:30, UTC+9:30, etc.)" }), (0, jsx_runtime_1.jsx)("li", { children: "Type custom offsets: UTC+1:05, UTC-3:45, etc." }), (0, jsx_runtime_1.jsx)("li", { children: "Ideal for database entries and technical applications" })] }), (0, jsx_runtime_1.jsx)("p", { style: {
|
|
42
|
+
color: '#999',
|
|
43
|
+
fontSize: '0.85em',
|
|
44
|
+
marginBottom: 0,
|
|
45
|
+
marginTop: '0.5rem',
|
|
46
|
+
}, children: "Try typing: UTC+5:30, UTC-7:15, or UTC+12:45" })] })] })] }));
|
|
47
|
+
};
|
|
48
|
+
exports.default = Component;
|
|
49
|
+
//# sourceMappingURL=timezone-picker-utc-only.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-utc-only.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-utc-only.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAS,KAAK,CAAC,CAAC;IAExE,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE;QAChD,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,CACL,4CACE,uBAAC,sBAAc,IACb,KAAK,EAAC,qBAAqB,EAC3B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,KAAK,GACV,EACF,iCAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,aAC/B,0CACE,oEAAmC,OAAE,gBAAgB,IACnD,EACJ,iCACE,KAAK,EAAE;4BACL,eAAe,EAAE,SAAS;4BAC1B,YAAY,EAAE,KAAK;4BAEnB,SAAS,EAAE,MAAM;4BACjB,OAAO,EAAE,MAAM;yBAChB,aAED,wCACE,2DAA0B,GACxB,EACJ,gCACE,KAAK,EAAE;oCACL,QAAQ,EAAE,OAAO;oCACjB,MAAM,EAAE,CAAC;oCACT,WAAW,EAAE,QAAQ;iCACtB,aAED,+FAA0D,EAC1D,oGAA+D,EAC/D,2FAAsD,EACtD,mGAA8D,IAC3D,EACL,8BACE,KAAK,EAAE;oCACL,KAAK,EAAE,MAAM;oCACb,QAAQ,EAAE,QAAQ;oCAClB,YAAY,EAAE,CAAC;oCACf,SAAS,EAAE,QAAQ;iCACpB,6DAGC,IACA,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');\n\n const handleTimeZoneChange = (timezone: string) => {\n setSelectedTimeZone(timezone);\n };\n\n return (\n <div>\n <TimeZonePicker\n label=\"Select UTC Timezone\"\n value={selectedTimeZone}\n onChange={handleTimeZoneChange}\n mode=\"utc\"\n />\n <div style={{ marginTop: '1rem' }}>\n <p>\n <strong>Selected Timezone:</strong> {selectedTimeZone}\n </p>\n <div\n style={{\n backgroundColor: '#f5f5f5',\n borderRadius: '4px',\n\n marginTop: '1rem',\n padding: '1rem',\n }}\n >\n <p>\n <strong>Features:</strong>\n </p>\n <ul\n style={{\n fontSize: '0.9em',\n margin: 0,\n paddingLeft: '1.5rem',\n }}\n >\n <li>Select from common UTC offsets (UTC-12 to UTC+14)</li>\n <li>Includes fractional offsets (UTC+5:30, UTC+9:30, etc.)</li>\n <li>Type custom offsets: UTC+1:05, UTC-3:45, etc.</li>\n <li>Ideal for database entries and technical applications</li>\n </ul>\n <p\n style={{\n color: '#999',\n fontSize: '0.85em',\n marginBottom: 0,\n marginTop: '0.5rem',\n }}\n >\n Try typing: UTC+5:30, UTC-7:15, or UTC+12:45\n </p>\n </div>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
"use strict";
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.InDialog = exports.BothMode = exports.UTCOnly = exports.DSTAware = exports.Disabled = exports.Sizes = exports.Fluid = exports.Default = void 0;
|
|
25
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
+
const TimeZonePicker_1 = require("../TimeZonePicker");
|
|
27
|
+
const _1 = require("./");
|
|
28
|
+
const componentMeta = {
|
|
29
|
+
component: TimeZonePicker_1.TimeZonePicker,
|
|
30
|
+
decorators: [
|
|
31
|
+
(Story) => ((0, jsx_runtime_1.jsx)("div", { className: "n-flex n-justify-center", children: (0, jsx_runtime_1.jsx)(Story, {}) })),
|
|
32
|
+
],
|
|
33
|
+
id: 'components-timezone-picker',
|
|
34
|
+
parameters: {
|
|
35
|
+
controls: { disable: true },
|
|
36
|
+
},
|
|
37
|
+
tags: ['docsPage'],
|
|
38
|
+
title: 'Components/TimeZonePicker',
|
|
39
|
+
};
|
|
40
|
+
exports.default = componentMeta;
|
|
41
|
+
exports.Default = {
|
|
42
|
+
args: {},
|
|
43
|
+
parameters: {
|
|
44
|
+
docs: {
|
|
45
|
+
source: {
|
|
46
|
+
code: _1.TimeZonePickerDefaultSource,
|
|
47
|
+
language: 'tsx',
|
|
48
|
+
type: 'code',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
render: _1.TimeZonePickerDefault,
|
|
53
|
+
};
|
|
54
|
+
exports.Fluid = {
|
|
55
|
+
args: {},
|
|
56
|
+
parameters: {
|
|
57
|
+
docs: {
|
|
58
|
+
source: {
|
|
59
|
+
code: _1.TimeZonePickerFluidSource,
|
|
60
|
+
language: 'tsx',
|
|
61
|
+
type: 'code',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
render: _1.TimeZonePickerFluid,
|
|
66
|
+
};
|
|
67
|
+
exports.Sizes = {
|
|
68
|
+
args: {},
|
|
69
|
+
parameters: {
|
|
70
|
+
docs: {
|
|
71
|
+
source: {
|
|
72
|
+
code: _1.TimeZonePickerSizesSource,
|
|
73
|
+
language: 'tsx',
|
|
74
|
+
type: 'code',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
render: _1.TimeZonePickerSizes,
|
|
79
|
+
};
|
|
80
|
+
exports.Disabled = {
|
|
81
|
+
args: {},
|
|
82
|
+
parameters: {
|
|
83
|
+
docs: {
|
|
84
|
+
source: {
|
|
85
|
+
code: _1.TimeZonePickerDisabledSource,
|
|
86
|
+
language: 'tsx',
|
|
87
|
+
type: 'code',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
render: _1.TimeZonePickerDisabled,
|
|
92
|
+
};
|
|
93
|
+
exports.DSTAware = {
|
|
94
|
+
args: {},
|
|
95
|
+
parameters: {
|
|
96
|
+
docs: {
|
|
97
|
+
source: {
|
|
98
|
+
code: _1.TimeZonePickerDSTAwareSource,
|
|
99
|
+
language: 'tsx',
|
|
100
|
+
type: 'code',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
render: _1.TimeZonePickerDSTAware,
|
|
105
|
+
};
|
|
106
|
+
exports.UTCOnly = {
|
|
107
|
+
args: {},
|
|
108
|
+
parameters: {
|
|
109
|
+
docs: {
|
|
110
|
+
source: {
|
|
111
|
+
code: _1.TimeZonePickerUTCOnlySource,
|
|
112
|
+
language: 'tsx',
|
|
113
|
+
type: 'code',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
render: _1.TimeZonePickerUTCOnly,
|
|
118
|
+
};
|
|
119
|
+
exports.BothMode = {
|
|
120
|
+
args: {},
|
|
121
|
+
parameters: {
|
|
122
|
+
docs: {
|
|
123
|
+
source: {
|
|
124
|
+
code: _1.TimeZonePickerBothModeSource,
|
|
125
|
+
language: 'tsx',
|
|
126
|
+
type: 'code',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
render: _1.TimeZonePickerBothMode,
|
|
131
|
+
};
|
|
132
|
+
exports.InDialog = {
|
|
133
|
+
args: {},
|
|
134
|
+
parameters: {
|
|
135
|
+
docs: {
|
|
136
|
+
source: {
|
|
137
|
+
code: _1.TimeZonePickerInDialogSource,
|
|
138
|
+
language: 'tsx',
|
|
139
|
+
type: 'code',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
render: _1.TimeZonePickerInDialog,
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=timezone-picker.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker.stories.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker.stories.tsx"],"names":[],"mappings":";;;;AAsBA,s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Q,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,yBAAsB;CAC/B,CAAC;AAEW,QAAA,QAAQ,GAAU;IAC7B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,+BAA4B;gBAClC,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,yBAAsB;CAC/B,CAAC;AAEW,QAAA,OAAO,GAAU;IAC5B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,8BAA2B;gBACjC,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,wBAAqB;CAC9B,CAAC;AAEW,QAAA,QAAQ,GAAU;IAC7B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,+BAA4B;gBAClC,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,yBAAsB;CAC/B,CAAC;AAEW,QAAA,QAAQ,GAAU;IAC7B,IAAI,EAAE,EAAE;IACR,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,+BAA4B;gBAClC,QAAQ,EAAE,KAAK;gBACf,IAAI,EAAE,MAAM;aACb;SACF;KACF;IACD,MAAM,EAAE,yBAAsB;CAC/B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type Meta, type StoryObj } from '@storybook/react-vite';\n\nimport { TimeZonePicker } from '../TimeZonePicker';\nimport {\n TimeZonePickerBothMode,\n TimeZonePickerBothModeSource,\n TimeZonePickerDefault,\n TimeZonePickerDefaultSource,\n TimeZonePickerDisabled,\n TimeZonePickerDisabledSource,\n TimeZonePickerDSTAware,\n TimeZonePickerDSTAwareSource,\n TimeZonePickerFluid,\n TimeZonePickerFluidSource,\n TimeZonePickerInDialog,\n TimeZonePickerInDialogSource,\n TimeZonePickerSizes,\n TimeZonePickerSizesSource,\n TimeZonePickerUTCOnly,\n TimeZonePickerUTCOnlySource,\n} from './';\n\nconst componentMeta: Meta<typeof TimeZonePicker> = {\n component: TimeZonePicker,\n decorators: [\n (Story) => (\n <div className=\"n-flex n-justify-center\">\n <Story />\n </div>\n ),\n ],\n id: 'components-timezone-picker',\n parameters: {\n controls: { disable: true },\n },\n tags: ['docsPage'],\n title: 'Components/TimeZonePicker',\n};\n\nexport default componentMeta;\ntype Story = StoryObj<typeof componentMeta>;\n\nexport const Default: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerDefaultSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerDefault,\n};\n\nexport const Fluid: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerFluidSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerFluid,\n};\n\nexport const Sizes: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerSizesSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerSizes,\n};\n\nexport const Disabled: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerDisabledSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerDisabled,\n};\n\nexport const DSTAware: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerDSTAwareSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerDSTAware,\n};\n\nexport const UTCOnly: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerUTCOnlySource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerUTCOnly,\n};\n\nexport const BothMode: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerBothModeSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerBothMode,\n};\n\nexport const InDialog: Story = {\n args: {},\n parameters: {\n docs: {\n source: {\n code: TimeZonePickerInDialogSource,\n language: 'tsx',\n type: 'code',\n },\n },\n },\n render: TimeZonePickerInDialog,\n};\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useKeyboardNavigation = exports.useTimeZonePickerPopover = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
const react_1 = require("react");
|
|
25
|
+
const useTimeZonePickerPopover = (initialState) => {
|
|
26
|
+
const [isPopoverOpen, setIsPopoverOpen] = (0, react_1.useState)(initialState);
|
|
27
|
+
return { isPopoverOpen, setIsPopoverOpen };
|
|
28
|
+
};
|
|
29
|
+
exports.useTimeZonePickerPopover = useTimeZonePickerPopover;
|
|
30
|
+
const useKeyboardNavigation = (optionsLength) => {
|
|
31
|
+
const [focusedIndex, setFocusedIndex] = (0, react_1.useState)(0);
|
|
32
|
+
(0, react_1.useEffect)(() => {
|
|
33
|
+
setFocusedIndex(0);
|
|
34
|
+
}, [optionsLength]);
|
|
35
|
+
const handleArrowNavigation = (0, react_1.useCallback)((key) => {
|
|
36
|
+
if (key === 'ArrowDown') {
|
|
37
|
+
setFocusedIndex((prevIndex) => {
|
|
38
|
+
const newIndex = (prevIndex + 1) % optionsLength;
|
|
39
|
+
return newIndex;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (key === 'ArrowUp') {
|
|
43
|
+
setFocusedIndex((prevIndex) => {
|
|
44
|
+
const newIndex = (prevIndex - 1 + optionsLength) % optionsLength;
|
|
45
|
+
return newIndex;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, [optionsLength]);
|
|
49
|
+
return { focusedIndex, handleArrowNavigation, setFocusedIndex };
|
|
50
|
+
};
|
|
51
|
+
exports.useKeyboardNavigation = useKeyboardNavigation;
|
|
52
|
+
//# sourceMappingURL=timezone-picker-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-hooks.js","sourceRoot":"","sources":["../../../src/timezone-picker/timezone-picker-hooks.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iCAAyD;AAElD,MAAM,wBAAwB,GA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\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\nexport const useTimeZonePickerPopover = (initialState: boolean) => {\n const [isPopoverOpen, setIsPopoverOpen] = useState(initialState);\n return { isPopoverOpen, setIsPopoverOpen };\n};\n\nexport const useKeyboardNavigation = (optionsLength: number) => {\n const [focusedIndex, setFocusedIndex] = useState(0);\n\n useEffect(() => {\n setFocusedIndex(0);\n }, [optionsLength]);\n\n const handleArrowNavigation = useCallback(\n (key: string) => {\n if (key === 'ArrowDown') {\n setFocusedIndex((prevIndex) => {\n const newIndex = (prevIndex + 1) % optionsLength;\n return newIndex;\n });\n } else if (key === 'ArrowUp') {\n setFocusedIndex((prevIndex) => {\n const newIndex = (prevIndex - 1 + optionsLength) % optionsLength;\n return newIndex;\n });\n }\n },\n [optionsLength],\n );\n\n return { focusedIndex, handleArrowNavigation, setFocusedIndex };\n};\n"]}
|
|
@@ -42,6 +42,7 @@ import { Divider } from '../divider';
|
|
|
42
42
|
import { ArrowLeftIconOutline, ArrowRightIconOutline, CalendarDaysIconOutline, ChevronDownIconOutline, } from '../icons';
|
|
43
43
|
import { TextInput } from '../text-input';
|
|
44
44
|
import { NeedleTime, TimePicker } from '../time-picker';
|
|
45
|
+
import { TimeZonePicker } from '../timezone-picker';
|
|
45
46
|
import { Typography } from '../typography';
|
|
46
47
|
import { daysInMonth, getYearsPeriodString } from './utils';
|
|
47
48
|
// This wrapper is needed due to react-datepicker injecting html attributes
|
|
@@ -57,12 +58,13 @@ const DatePickerTextInputWrapper = (_a) => {
|
|
|
57
58
|
};
|
|
58
59
|
export const DatePicker = (_a) => {
|
|
59
60
|
var _b;
|
|
60
|
-
var { reactDatePickerProps, textInputProps, timePickerProps, isDisabled, ref, className, style, htmlAttributes } = _a, restProps = __rest(_a, ["reactDatePickerProps", "textInputProps", "timePickerProps", "isDisabled", "ref", "className", "style", "htmlAttributes"]);
|
|
61
|
+
var { reactDatePickerProps, textInputProps, timePickerProps, timeZonePickerProps, isDisabled, ref, className, style, htmlAttributes } = _a, restProps = __rest(_a, ["reactDatePickerProps", "textInputProps", "timePickerProps", "timeZonePickerProps", "isDisabled", "ref", "className", "style", "htmlAttributes"]);
|
|
61
62
|
const classes = classNames(`ndl-datepicker`, className, {});
|
|
62
63
|
const datetimeRef = useRef(null);
|
|
63
64
|
const [picker, setPicker] = useState('day');
|
|
64
65
|
const [preSelectedDate, setPreSelectedDate] = useState(reactDatePickerProps.selected ||
|
|
65
66
|
reactDatePickerProps.startDate);
|
|
67
|
+
const [selectedTimeZone, setSelectedTimeZone] = useState(timeZonePickerProps === null || timeZonePickerProps === void 0 ? void 0 : timeZonePickerProps.value);
|
|
66
68
|
const isInsideDialog = useIsInsideDialog();
|
|
67
69
|
const headerAction = useCallback((action) => {
|
|
68
70
|
setPicker(picker === action ? 'day' : action);
|
|
@@ -97,6 +99,12 @@ export const DatePicker = (_a) => {
|
|
|
97
99
|
reactDatePickerProps.onChange(newDate, undefined);
|
|
98
100
|
}
|
|
99
101
|
};
|
|
102
|
+
const handleTimeZoneChange = (timezone) => {
|
|
103
|
+
setSelectedTimeZone(timezone);
|
|
104
|
+
if (timeZonePickerProps === null || timeZonePickerProps === void 0 ? void 0 : timeZonePickerProps.onChange) {
|
|
105
|
+
timeZonePickerProps.onChange(timezone);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
100
108
|
/**
|
|
101
109
|
* Intercept onChange so we can work with
|
|
102
110
|
* Month and Year pickers
|
|
@@ -170,8 +178,8 @@ export const DatePicker = (_a) => {
|
|
|
170
178
|
(_a = reactDatePickerProps === null || reactDatePickerProps === void 0 ? void 0 : reactDatePickerProps.onChangeRaw) === null || _a === void 0 ? void 0 : _a.call(reactDatePickerProps, event);
|
|
171
179
|
}, [reactDatePickerProps]);
|
|
172
180
|
const datePickerProps = Object.assign(Object.assign({}, reactDatePickerProps), { onCalendarClose: interceptedOnCalendarClose, onChange: interceptedChange, onChangeRaw: interceptedOnChangeRaw, onMonthChange: handleMonthChange });
|
|
173
|
-
return (_jsx("div", Object.assign({ className: classes, ref: ref, style: style }, restProps, htmlAttributes, { children: _jsx(ReactDatePicker, Object.assign({ ref: datetimeRef, customInput: _jsx(DatePickerTextInputWrapper, { isDisabled: isDisabled, textInputProps: textInputProps }), customTimeInput: _jsxs("span", { children: [_jsx(Divider, {
|
|
181
|
+
return (_jsx("div", Object.assign({ className: classes, ref: ref, style: style }, restProps, htmlAttributes, { children: _jsx(ReactDatePicker, Object.assign({ ref: datetimeRef, customInput: _jsx(DatePickerTextInputWrapper, { isDisabled: isDisabled, textInputProps: textInputProps }), customTimeInput: _jsxs("span", { className: "ndl-time-picker-wrapper", children: [_jsx(Divider, {}), _jsx(TimePicker, Object.assign({ isFluid: true, value: preSelectedDate
|
|
174
182
|
? new NeedleTime(preSelectedDate.getHours(), preSelectedDate.getMinutes())
|
|
175
|
-
: undefined, onChange: handleTimeChange }, timePickerProps, { floatingStrategy: "absolute", isPortaled: false }))] }), disabled: isDisabled, showPopperArrow: false, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day' && !((_b = reactDatePickerProps.showTimeInput) !== null && _b !== void 0 ? _b : false), dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, datePickerProps, { popperClassName: classNames('ndl-datepicker-popper', reactDatePickerProps.popperClassName), popperProps: Object.assign({ strategy: isInsideDialog ? 'fixed' : 'absolute' }, reactDatePickerProps.popperProps) })) })));
|
|
183
|
+
: undefined, onChange: handleTimeChange }, timePickerProps, { floatingStrategy: "absolute", isPortaled: false })), timeZonePickerProps && (_jsx(TimeZonePicker, Object.assign({ isFluid: true, value: selectedTimeZone, onChange: handleTimeZoneChange, referenceDate: preSelectedDate || undefined }, timeZonePickerProps, { floatingStrategy: "absolute", isPortaled: false })))] }), disabled: isDisabled, showPopperArrow: false, showMonthYearPicker: picker === 'month', showYearPicker: picker === 'year', shouldCloseOnSelect: picker === 'day' && !((_b = reactDatePickerProps.showTimeInput) !== null && _b !== void 0 ? _b : false), dayClassName: () => 'ndl-datepicker-day', renderCustomHeader: CustomHeader }, datePickerProps, { popperClassName: classNames('ndl-datepicker-popper', reactDatePickerProps.popperClassName), popperProps: Object.assign({ strategy: isInsideDialog ? 'fixed' : 'absolute' }, reactDatePickerProps.popperProps) })) })));
|
|
176
184
|
};
|
|
177
185
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA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AC5B,eAAe,IACnB,eAAe,EAAE,UAAU,CACzB,uBAAuB,EACvB,oBAAoB,CAAC,eAAe,CACrC,EACD,WAAW,kBACT,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,IAC5C,oBAAoB,CAAC,WAAW,KAErC,IACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// TODO: try to fix as some point\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { format } from 'date-fns';\nimport { useCallback, useRef, useState } from 'react';\nimport ReactDatePicker, {\n type ReactDatePickerCustomHeaderProps,\n} from 'react-datepicker';\n\nimport type { CommonProps } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport {\n ArrowLeftIconOutline,\n ArrowRightIconOutline,\n CalendarDaysIconOutline,\n ChevronDownIconOutline,\n} from '../icons';\nimport { TextInput } from '../text-input';\nimport { NeedleTime, TimePicker, type TimePickerProps } from '../time-picker';\nimport { Typography } from '../typography';\nimport { daysInMonth, getYearsPeriodString } from './utils';\n\ntype DatePickerTextInputWrapperProps = React.ComponentProps<'input'> & {\n textInputProps?: React.ComponentProps<typeof TextInput>;\n isDisabled?: boolean;\n value?: string;\n};\n\n// This wrapper is needed due to react-datepicker injecting html attributes\n// into the custom input component on root level, since we use htmlAttributes\n// we need to help spread them there instead of the root level\nconst DatePickerTextInputWrapper = ({\n textInputProps,\n isDisabled,\n value,\n placeholder,\n ...restProps\n}: DatePickerTextInputWrapperProps) => {\n // deconstruct textInputProps to avoid bugs with react-datepicker injecting props\n const {\n placeholder: textInputPlaceholder,\n htmlAttributes: textInputHtmlAttributes,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n\n return (\n <TextInput\n ref={ref}\n aria-label=\"Date picker input\"\n trailingElement={\n <CalendarDaysIconOutline className=\"ndl-datepicker-icon\" />\n }\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restProps,\n }}\n {...restTextInputProps}\n />\n );\n};\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype PickerType = 'day' | 'month' | 'year';\n\n// Define a more flexible type for onChange\ntype DatePickerChangeHandler = (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent | undefined,\n) => void;\n\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /** Props for the embedded `TimePicker` component. */\n timePickerProps?: TimePickerProps;\n /** Props forwarded to underlying `react-datepicker` component. */\n reactDatePickerProps: React.ComponentProps<typeof ReactDatePicker>;\n}\n\nexport const DatePicker = ({\n reactDatePickerProps,\n textInputProps,\n timePickerProps,\n isDisabled,\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', DatePickerProps>) => {\n const classes = classNames(`ndl-datepicker`, className, {});\n const datetimeRef = useRef<ReactDatePicker>(null);\n const [picker, setPicker] = useState<PickerType>('day');\n const [preSelectedDate, setPreSelectedDate] = useState<Date | null>(\n (reactDatePickerProps.selected as Date | null) ||\n (reactDatePickerProps.startDate as Date | null),\n );\n\n const isInsideDialog = useIsInsideDialog();\n\n const headerAction = useCallback(\n (action: PickerType) => {\n setPicker(picker === action ? 'day' : action);\n },\n [picker],\n );\n\n const CustomHeader = useCallback(\n (props: ReactDatePickerCustomHeaderProps) => {\n const {\n decreaseMonth,\n increaseMonth,\n increaseYear,\n decreaseYear,\n nextMonthButtonDisabled,\n nextYearButtonDisabled,\n prevMonthButtonDisabled,\n prevYearButtonDisabled,\n } = props;\n\n const prevCallback = picker === 'year' ? decreaseYear : decreaseMonth;\n const nextCallback = picker === 'year' ? increaseYear : increaseMonth;\n const prevDisabled =\n picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;\n const nextDisabled =\n picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;\n\n return (\n <div className=\"ndl-datepicker-header\">\n <div className=\"ndl-datepicker-selects\">\n {picker !== 'year' && (\n <button\n aria-label={`${picker === 'month' ? 'Close' : 'Open'} month picker`}\n aria-pressed={picker === 'month'}\n onClick={() => headerAction('month')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {format(props.date, 'MMM')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'month',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n {picker !== 'month' && (\n <button\n aria-label={`${picker === 'year' ? 'Close' : 'Open'} year picker`}\n onClick={() => headerAction('year')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {picker === 'year'\n ? getYearsPeriodString(\n props.date,\n reactDatePickerProps?.yearItemNumber,\n )\n : format(props.date, 'yyyy')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'year',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n </div>\n {picker !== 'month' && (\n <div className=\"n-flex n-justify-center n-gap-token-16\">\n <CleanIconButton\n description={\n picker === 'year' ? 'Previous period' : 'Previous month'\n }\n onClick={prevCallback}\n isDisabled={prevDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowLeftIconOutline />\n </CleanIconButton>\n <CleanIconButton\n description={picker === 'year' ? 'Next period' : 'Next month'}\n onClick={nextCallback}\n isDisabled={nextDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowRightIconOutline />\n </CleanIconButton>\n </div>\n )}\n </div>\n );\n },\n [picker, headerAction, reactDatePickerProps?.yearItemNumber],\n );\n\n const handleTimeChange = (newTime: NeedleTime) => {\n if (\n reactDatePickerProps.selectsRange ||\n reactDatePickerProps.selectsMultiple\n ) {\n // this is consistent with the behavior of react-datepicker\n return;\n }\n\n if (!preSelectedDate) return;\n\n const newDate = new Date(preSelectedDate);\n newDate.setHours(newTime.hour, newTime.minute, 0, 0);\n setPreSelectedDate(newDate);\n\n if (reactDatePickerProps.onChange) {\n // For single date selection\n reactDatePickerProps.onChange(newDate, undefined);\n }\n };\n\n /**\n * Intercept onChange so we can work with\n * Month and Year pickers\n */\n const interceptedChange: DatePickerChangeHandler = useCallback(\n (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent,\n ) => {\n if (picker !== 'day') {\n // setTimeout to prevent picker change before the handleMonthChange logic\n setTimeout(() => {\n setPicker('day');\n });\n } else if (picker === 'day') {\n if (date instanceof Date) {\n setPreSelectedDate(date);\n } else if (\n Array.isArray(date) &&\n date.length > 0 &&\n date[0] instanceof Date\n ) {\n setPreSelectedDate(date[0]);\n } else if (date === null) {\n setPreSelectedDate(null);\n }\n\n if (reactDatePickerProps.onChange && date !== null) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n date,\n event,\n );\n }\n }\n },\n [picker, reactDatePickerProps],\n );\n\n /**\n * Intercept onCalendarClose so we can\n * switch to \"day\" picker if we close on \"month\" or \"year\"\n * view\n */\n const interceptedOnCalendarClose = useCallback(() => {\n if (picker !== 'day') {\n setPicker('day');\n }\n reactDatePickerProps?.onCalendarClose?.();\n }, [picker, reactDatePickerProps]);\n\n const handleMonthChange = useCallback(\n (date: Date) => {\n if (picker === 'month') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());\n date.setDate(Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n } else if (picker === 'year') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const selectedMonth = preSelectedDate?.getMonth() ?? 0;\n const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());\n date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n }\n setPreSelectedDate(date);\n },\n [picker, preSelectedDate, reactDatePickerProps],\n );\n\n /**\n * Intercept onChangeRaw to handle clearing the input\n * When the user clears the text input, set the date to null\n */\n const interceptedOnChangeRaw = useCallback(\n (\n event?:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement, MouseEvent>,\n ) => {\n const target = event?.target as HTMLInputElement | undefined;\n if (target?.value === '') {\n setPreSelectedDate(null);\n if (reactDatePickerProps.onChange) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n null,\n event,\n );\n }\n }\n reactDatePickerProps?.onChangeRaw?.(event);\n },\n [reactDatePickerProps],\n );\n\n const datePickerProps = {\n ...reactDatePickerProps,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onMonthChange: handleMonthChange,\n };\n\n return (\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <ReactDatePicker\n ref={datetimeRef}\n customInput={\n <DatePickerTextInputWrapper\n isDisabled={isDisabled}\n textInputProps={textInputProps}\n />\n }\n customTimeInput={\n <span>\n <Divider className=\"n-my-4\" />\n <TimePicker\n isFluid\n value={\n preSelectedDate\n ? new NeedleTime(\n preSelectedDate.getHours(),\n preSelectedDate.getMinutes(),\n )\n : undefined\n }\n onChange={handleTimeChange}\n {...timePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n </span>\n }\n disabled={isDisabled}\n showPopperArrow={false}\n showMonthYearPicker={picker === 'month'}\n showYearPicker={picker === 'year'}\n shouldCloseOnSelect={\n picker === 'day' && !(reactDatePickerProps.showTimeInput ?? false)\n }\n dayClassName={() => 'ndl-datepicker-day'}\n renderCustomHeader={CustomHeader}\n {...datePickerProps}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperProps={{\n strategy: isInsideDialog ? 'fixed' : 'absolute',\n ...reactDatePickerProps.popperProps,\n }}\n />\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date-picker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,yDAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,eAEN,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAwB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAA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AAgB,IACtB,eAAe,IACnB,gBAAgB,EAAC,UAAU,EAC3B,UAAU,EAAE,KAAK,IACjB,EACD,mBAAmB,IAAI,CACtB,KAAC,cAAc,kBACb,OAAO,QACP,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,aAAa,EAAE,eAAe,IAAI,SAAS,IACvC,mBAAmB,IACvB,gBAAgB,EAAC,UAAU,EAC3B,UAAU,EAAE,KAAK,IACjB,CACH,IACI,EAET,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,KAAK,EACtB,mBAAmB,EAAE,MAAM,KAAK,OAAO,EACvC,cAAc,EAAE,MAAM,KAAK,MAAM,EACjC,mBAAmB,EACjB,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC,MAAA,oBAAoB,CAAC,aAAa,mCAAI,KAAK,CAAC,EAEpE,YAAY,EAAE,GAAG,EAAE,CAAC,oBAAoB,EACxC,kBAAkB,EAAE,YAAY,IAC5B,eAAe,IACnB,eAAe,EAAE,UAAU,CACzB,uBAAuB,EACvB,oBAAoB,CAAC,eAAe,CACrC,EACD,WAAW,kBACT,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,IAC5C,oBAAoB,CAAC,WAAW,KAErC,IACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// TODO: try to fix as some point\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport { format } from 'date-fns';\nimport { useCallback, useRef, useState } from 'react';\nimport ReactDatePicker, {\n type ReactDatePickerCustomHeaderProps,\n} from 'react-datepicker';\n\nimport type { CommonProps } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport {\n ArrowLeftIconOutline,\n ArrowRightIconOutline,\n CalendarDaysIconOutline,\n ChevronDownIconOutline,\n} from '../icons';\nimport { TextInput } from '../text-input';\nimport { NeedleTime, TimePicker, type TimePickerProps } from '../time-picker';\nimport { TimeZonePicker } from '../timezone-picker';\nimport { Typography } from '../typography';\nimport { daysInMonth, getYearsPeriodString } from './utils';\n\ntype DatePickerTextInputWrapperProps = React.ComponentProps<'input'> & {\n textInputProps?: React.ComponentProps<typeof TextInput>;\n isDisabled?: boolean;\n value?: string;\n};\n\n// This wrapper is needed due to react-datepicker injecting html attributes\n// into the custom input component on root level, since we use htmlAttributes\n// we need to help spread them there instead of the root level\nconst DatePickerTextInputWrapper = ({\n textInputProps,\n isDisabled,\n value,\n placeholder,\n ...restProps\n}: DatePickerTextInputWrapperProps) => {\n // deconstruct textInputProps to avoid bugs with react-datepicker injecting props\n const {\n placeholder: textInputPlaceholder,\n htmlAttributes: textInputHtmlAttributes,\n ref,\n ...restTextInputProps\n } = textInputProps ?? {};\n\n return (\n <TextInput\n ref={ref}\n aria-label=\"Date picker input\"\n trailingElement={\n <CalendarDaysIconOutline className=\"ndl-datepicker-icon\" />\n }\n value={value}\n placeholder={placeholder ?? textInputPlaceholder}\n isDisabled={isDisabled}\n // react-datepicker injects html attributes into the custom input\n htmlAttributes={{\n ...textInputHtmlAttributes,\n ...restProps,\n }}\n {...restTextInputProps}\n />\n );\n};\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype PickerType = 'day' | 'month' | 'year';\n\n// Define a more flexible type for onChange\ntype DatePickerChangeHandler = (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent | undefined,\n) => void;\n\ninterface DatePickerProps {\n /** Props for the embedded `TextInput` component. */\n textInputProps?: React.ComponentProps<typeof TextInput>;\n /** Whether the date picker is disabled. */\n isDisabled?: boolean;\n /** Props for the embedded `TimePicker` component. */\n timePickerProps?: TimePickerProps;\n /** Props for the embedded `TimeZonePicker` component. */\n timeZonePickerProps?: React.ComponentProps<typeof TimeZonePicker>;\n /** Props forwarded to underlying `react-datepicker` component. */\n reactDatePickerProps: React.ComponentProps<typeof ReactDatePicker>;\n}\n\nexport const DatePicker = ({\n reactDatePickerProps,\n textInputProps,\n timePickerProps,\n timeZonePickerProps,\n isDisabled,\n ref,\n className,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', DatePickerProps>) => {\n const classes = classNames(`ndl-datepicker`, className, {});\n const datetimeRef = useRef<ReactDatePicker>(null);\n const [picker, setPicker] = useState<PickerType>('day');\n const [preSelectedDate, setPreSelectedDate] = useState<Date | null>(\n (reactDatePickerProps.selected as Date | null) ||\n (reactDatePickerProps.startDate as Date | null),\n );\n const [selectedTimeZone, setSelectedTimeZone] = useState<string | undefined>(\n timeZonePickerProps?.value,\n );\n\n const isInsideDialog = useIsInsideDialog();\n\n const headerAction = useCallback(\n (action: PickerType) => {\n setPicker(picker === action ? 'day' : action);\n },\n [picker],\n );\n\n const CustomHeader = useCallback(\n (props: ReactDatePickerCustomHeaderProps) => {\n const {\n decreaseMonth,\n increaseMonth,\n increaseYear,\n decreaseYear,\n nextMonthButtonDisabled,\n nextYearButtonDisabled,\n prevMonthButtonDisabled,\n prevYearButtonDisabled,\n } = props;\n\n const prevCallback = picker === 'year' ? decreaseYear : decreaseMonth;\n const nextCallback = picker === 'year' ? increaseYear : increaseMonth;\n const prevDisabled =\n picker === 'year' ? prevYearButtonDisabled : prevMonthButtonDisabled;\n const nextDisabled =\n picker === 'year' ? nextYearButtonDisabled : nextMonthButtonDisabled;\n\n return (\n <div className=\"ndl-datepicker-header\">\n <div className=\"ndl-datepicker-selects\">\n {picker !== 'year' && (\n <button\n aria-label={`${picker === 'month' ? 'Close' : 'Open'} month picker`}\n aria-pressed={picker === 'month'}\n onClick={() => headerAction('month')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {format(props.date, 'MMM')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'month',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n {picker !== 'month' && (\n <button\n aria-label={`${picker === 'year' ? 'Close' : 'Open'} year picker`}\n onClick={() => headerAction('year')}\n >\n <div className=\"n-flex n-items-center n-gap-token-4\">\n <Typography variant=\"subheading-small\">\n {picker === 'year'\n ? getYearsPeriodString(\n props.date,\n reactDatePickerProps?.yearItemNumber,\n )\n : format(props.date, 'yyyy')}\n </Typography>\n <ChevronDownIconOutline\n className={classNames('ndl-datepicker-chevron', {\n 'n-rotate-180': picker === 'year',\n })}\n aria-label=\"Chevron icon\"\n />\n </div>\n </button>\n )}\n </div>\n {picker !== 'month' && (\n <div className=\"n-flex n-justify-center n-gap-token-16\">\n <CleanIconButton\n description={\n picker === 'year' ? 'Previous period' : 'Previous month'\n }\n onClick={prevCallback}\n isDisabled={prevDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowLeftIconOutline />\n </CleanIconButton>\n <CleanIconButton\n description={picker === 'year' ? 'Next period' : 'Next month'}\n onClick={nextCallback}\n isDisabled={nextDisabled}\n className=\"n-text-neutral-text-weak\"\n size=\"small\"\n >\n <ArrowRightIconOutline />\n </CleanIconButton>\n </div>\n )}\n </div>\n );\n },\n [picker, headerAction, reactDatePickerProps?.yearItemNumber],\n );\n\n const handleTimeChange = (newTime: NeedleTime) => {\n if (\n reactDatePickerProps.selectsRange ||\n reactDatePickerProps.selectsMultiple\n ) {\n // this is consistent with the behavior of react-datepicker\n return;\n }\n\n if (!preSelectedDate) return;\n\n const newDate = new Date(preSelectedDate);\n newDate.setHours(newTime.hour, newTime.minute, 0, 0);\n setPreSelectedDate(newDate);\n\n if (reactDatePickerProps.onChange) {\n // For single date selection\n reactDatePickerProps.onChange(newDate, undefined);\n }\n };\n\n const handleTimeZoneChange = (timezone: string) => {\n setSelectedTimeZone(timezone);\n if (timeZonePickerProps?.onChange) {\n timeZonePickerProps.onChange(timezone);\n }\n };\n\n /**\n * Intercept onChange so we can work with\n * Month and Year pickers\n */\n const interceptedChange: DatePickerChangeHandler = useCallback(\n (\n date: Date | null | [Date | null, Date | null] | Date[],\n event?: React.SyntheticEvent,\n ) => {\n if (picker !== 'day') {\n // setTimeout to prevent picker change before the handleMonthChange logic\n setTimeout(() => {\n setPicker('day');\n });\n } else if (picker === 'day') {\n if (date instanceof Date) {\n setPreSelectedDate(date);\n } else if (\n Array.isArray(date) &&\n date.length > 0 &&\n date[0] instanceof Date\n ) {\n setPreSelectedDate(date[0]);\n } else if (date === null) {\n setPreSelectedDate(null);\n }\n\n if (reactDatePickerProps.onChange && date !== null) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n date,\n event,\n );\n }\n }\n },\n [picker, reactDatePickerProps],\n );\n\n /**\n * Intercept onCalendarClose so we can\n * switch to \"day\" picker if we close on \"month\" or \"year\"\n * view\n */\n const interceptedOnCalendarClose = useCallback(() => {\n if (picker !== 'day') {\n setPicker('day');\n }\n reactDatePickerProps?.onCalendarClose?.();\n }, [picker, reactDatePickerProps]);\n\n const handleMonthChange = useCallback(\n (date: Date) => {\n if (picker === 'month') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());\n date.setDate(Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n } else if (picker === 'year') {\n const selectedDay = preSelectedDate?.getDate() ?? 1;\n const selectedMonth = preSelectedDate?.getMonth() ?? 0;\n const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());\n date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));\n reactDatePickerProps?.onMonthChange?.(date);\n }\n setPreSelectedDate(date);\n },\n [picker, preSelectedDate, reactDatePickerProps],\n );\n\n /**\n * Intercept onChangeRaw to handle clearing the input\n * When the user clears the text input, set the date to null\n */\n const interceptedOnChangeRaw = useCallback(\n (\n event?:\n | React.KeyboardEvent<HTMLElement>\n | React.MouseEvent<HTMLElement, MouseEvent>,\n ) => {\n const target = event?.target as HTMLInputElement | undefined;\n if (target?.value === '') {\n setPreSelectedDate(null);\n if (reactDatePickerProps.onChange) {\n (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n null,\n event,\n );\n }\n }\n reactDatePickerProps?.onChangeRaw?.(event);\n },\n [reactDatePickerProps],\n );\n\n const datePickerProps = {\n ...reactDatePickerProps,\n onCalendarClose: interceptedOnCalendarClose,\n onChange: interceptedChange,\n onChangeRaw: interceptedOnChangeRaw,\n onMonthChange: handleMonthChange,\n };\n\n return (\n <div\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <ReactDatePicker\n ref={datetimeRef}\n customInput={\n <DatePickerTextInputWrapper\n isDisabled={isDisabled}\n textInputProps={textInputProps}\n />\n }\n customTimeInput={\n <span className=\"ndl-time-picker-wrapper\">\n <Divider />\n <TimePicker\n isFluid\n value={\n preSelectedDate\n ? new NeedleTime(\n preSelectedDate.getHours(),\n preSelectedDate.getMinutes(),\n )\n : undefined\n }\n onChange={handleTimeChange}\n {...timePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n {timeZonePickerProps && (\n <TimeZonePicker\n isFluid\n value={selectedTimeZone}\n onChange={handleTimeZoneChange}\n referenceDate={preSelectedDate || undefined}\n {...timeZonePickerProps}\n floatingStrategy=\"absolute\"\n isPortaled={false}\n />\n )}\n </span>\n }\n disabled={isDisabled}\n showPopperArrow={false}\n showMonthYearPicker={picker === 'month'}\n showYearPicker={picker === 'year'}\n shouldCloseOnSelect={\n picker === 'day' && !(reactDatePickerProps.showTimeInput ?? false)\n }\n dayClassName={() => 'ndl-datepicker-day'}\n renderCustomHeader={CustomHeader}\n {...datePickerProps}\n popperClassName={classNames(\n 'ndl-datepicker-popper',\n reactDatePickerProps.popperClassName,\n )}\n popperProps={{\n strategy: isInsideDialog ? 'fixed' : 'absolute',\n ...reactDatePickerProps.popperProps,\n }}\n />\n </div>\n );\n};\n"]}
|