@onewelcome/react-lib-components 8.6.0 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button/BaseButton.cjs.js +1 -1
- package/dist/cjs/Button/BaseButton.cjs.js.map +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js.map +1 -0
- package/dist/cjs/DatePicker/DatePicker.cjs.js +1 -1
- package/dist/cjs/DatePicker/DatePicker.cjs.js.map +1 -1
- package/dist/cjs/DatePicker/DatePicker.module.scss.cjs.js +1 -1
- package/dist/cjs/Form/FormGroup/FormGroup.cjs.js +1 -1
- package/dist/cjs/Form/FormGroup/FormGroup.cjs.js.map +1 -1
- package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js +1 -1
- package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/useSelectPositionList.cjs.js +1 -1
- package/dist/cjs/Form/Select/useSelectPositionList.cjs.js.map +1 -1
- package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js +1 -1
- package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js.map +1 -1
- package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js +1 -1
- package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/testUtils.d.ts +7 -1
- package/dist/cjs/src/components/DatePicker/DatePicker.d.ts +4 -1
- package/dist/cjs/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
- package/dist/cjs/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
- package/dist/cjs/src/hooks/useClickOutside.cjs.js +2 -0
- package/dist/cjs/src/hooks/useClickOutside.cjs.js.map +1 -0
- package/dist/cjs/src/hooks/useClickOutside.d.ts +2 -0
- package/dist/cjs/src/index.cjs.js +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/Button/BaseButton.esm.js +5 -2
- package/dist/esm/Button/BaseButton.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenu.esm.js +6 -8
- package/dist/esm/ContextMenu/ContextMenu.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenuItem.esm.js +3 -3
- package/dist/esm/ContextMenu/ContextMenuItem.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenuItem.module.scss.esm.js +2 -2
- package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js +35 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js +16 -7
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilters.interfaces.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js +15 -12
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js +138 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js +8 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js +54 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js +51 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js +29 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js +26 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js.map +1 -0
- package/dist/esm/DatePicker/DatePicker.esm.js +3 -1
- package/dist/esm/DatePicker/DatePicker.esm.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.module.scss.esm.js +2 -2
- package/dist/esm/Form/FormGroup/FormGroup.esm.js +2 -2
- package/dist/esm/Form/FormGroup/FormGroup.esm.js.map +1 -1
- package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js +1 -1
- package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js.map +1 -1
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js +9 -5
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js.map +1 -1
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js +9 -5
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js.map +1 -1
- package/dist/esm/Form/Select/useSelectPositionList.esm.js +8 -11
- package/dist/esm/Form/Select/useSelectPositionList.esm.js.map +1 -1
- package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js +2 -2
- package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js.map +1 -1
- package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js +2 -2
- package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js.map +1 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/testUtils.d.ts +7 -1
- package/dist/esm/src/components/DatePicker/DatePicker.d.ts +4 -1
- package/dist/esm/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
- package/dist/esm/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
- package/dist/esm/src/hooks/useClickOutside.d.ts +2 -0
- package/dist/esm/src/hooks/useClickOutside.esm.js +38 -0
- package/dist/esm/src/hooks/useClickOutside.esm.js.map +1 -0
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.esm.js +1 -0
- package/dist/esm/src/index.esm.js.map +1 -1
- package/package.json +7 -3
- package/src/components/Button/BaseButton.tsx +7 -4
- package/src/components/ContextMenu/ContextMenu.tsx +5 -13
- package/src/components/DataGrid/DataGridBody/__snapshots__/DataGridBody.test.tsx.snap +4 -4
- package/src/components/DataGrid/DataGridFilters/DataGridDateFilter.tsx +65 -0
- package/src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx +25 -5
- package/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts +18 -1
- package/src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx +53 -33
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss +134 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.tsx +267 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.tsx +103 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.tsx +121 -0
- package/{dist/esm/src/hooks/useBodyClick.esm.js → src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.ts} +14 -17
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.tsx +50 -0
- package/src/components/DataGrid/testUtils.ts +48 -15
- package/src/components/DatePicker/DatePicker.module.scss +32 -9
- package/src/components/DatePicker/DatePicker.tsx +15 -1
- package/src/components/Form/FormGroup/FormGroup.tsx +6 -1
- package/src/components/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +2 -2
- package/src/components/Form/Select/MultiSelect/MultiSelect.tsx +13 -13
- package/src/components/Form/Select/SingleSelect/Select.tsx +13 -13
- package/src/components/Form/Select/useSelectPositionList.ts +8 -12
- package/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
- package/src/components/Form/Wrapper/Wrapper/Wrapper.tsx +3 -0
- package/src/hooks/{useBodyClick.ts → useClickOutside.ts} +17 -11
- package/src/index.ts +1 -0
- package/dist/cjs/src/hooks/useBodyClick.cjs.js +0 -2
- package/dist/cjs/src/hooks/useBodyClick.cjs.js.map +0 -1
- package/dist/cjs/src/hooks/useBodyClick.d.ts +0 -1
- package/dist/esm/src/hooks/useBodyClick.d.ts +0 -1
- package/dist/esm/src/hooks/useBodyClick.esm.js.map +0 -1
- /package/dist/cjs/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
- /package/dist/esm/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useRef, useState, Fragment } from 'react';
|
|
2
|
+
import { DataGridFilterTag } from './DataGridFilterTag.esm.js';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { DateTimePicker } from './DateTimePicker/DateTimePicker.esm.js';
|
|
5
|
+
import { useGetDomRoot } from '../../src/hooks/useGetDomRoot.esm.js';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2022 OneWelcome B.V.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
const DataGridDateFilter = ({ domRoot, dateFilterValue, onDateFilterValueChange }) => {
|
|
23
|
+
const triggerRef = useRef(null);
|
|
24
|
+
const popoverRef = useRef(null);
|
|
25
|
+
const wrappingDivRef = useRef(null);
|
|
26
|
+
const { root } = useGetDomRoot(domRoot, wrappingDivRef);
|
|
27
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
28
|
+
const [tagCaption, setTagCaption] = useState("Last 30 seconds");
|
|
29
|
+
return (React.createElement(Fragment, null,
|
|
30
|
+
React.createElement(DataGridFilterTag, { triggerRef: triggerRef, ref: wrappingDivRef, dateTagCaption: tagCaption, mode: "ADD_DATE", onFilterOpen: () => setIsOpen(true) }),
|
|
31
|
+
createPortal(React.createElement(DateTimePicker, { popoverRef: popoverRef, onTagCaptionChange: setTagCaption, anchorRef: wrappingDivRef, isOpen: isOpen, setPickerOpen: setIsOpen, dateFilterValue: dateFilterValue, onDateFilterValueChange: onDateFilterValueChange }), root)));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { DataGridDateFilter };
|
|
35
|
+
//# sourceMappingURL=DataGridDateFilter.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataGridDateFilter.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridDateFilter.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment, useRef, useState } from \"react\";\nimport { DataGridFilterTag } from \"./DataGridFilterTag\";\nimport { createPortal } from \"react-dom\";\nimport { DateTimePicker } from \"./DateTimePicker/DateTimePicker\";\nimport { useGetDomRoot } from \"../../../hooks/useGetDomRoot\";\nimport { DateTimeFilter } from \"./DataGridFilters.interfaces\";\n\ntype Props = {\n domRoot?: HTMLElement;\n dateFilterValue?: DateTimeFilter;\n onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;\n};\n\nexport const DataGridDateFilter = ({\n domRoot,\n dateFilterValue,\n onDateFilterValueChange\n}: Props) => {\n const triggerRef = useRef<HTMLButtonElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const wrappingDivRef = useRef<HTMLDivElement>(null);\n const { root } = useGetDomRoot(domRoot, wrappingDivRef);\n const [isOpen, setIsOpen] = useState(false);\n const [tagCaption, setTagCaption] = useState(\"Last 30 seconds\");\n\n return (\n <Fragment>\n <DataGridFilterTag\n triggerRef={triggerRef}\n ref={wrappingDivRef}\n dateTagCaption={tagCaption}\n mode={\"ADD_DATE\"}\n onFilterOpen={() => setIsOpen(true)}\n />\n {createPortal(\n <DateTimePicker\n popoverRef={popoverRef}\n onTagCaptionChange={setTagCaption}\n anchorRef={wrappingDivRef}\n isOpen={isOpen}\n setPickerOpen={setIsOpen}\n dateFilterValue={dateFilterValue}\n onDateFilterValueChange={onDateFilterValueChange}\n />,\n root\n )}\n </Fragment>\n );\n};\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAeI,MAAM,kBAAkB,GAAG,CAAC,EACjC,OAAO,EACP,eAAe,EACf,uBAAuB,EACjB,KAAI;AACV,IAAA,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;AACnD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,cAAc,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACpD,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAEhE,QACE,oBAAC,QAAQ,EAAA,IAAA;QACP,KAAC,CAAA,aAAA,CAAA,iBAAiB,EAChB,EAAA,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,UAAU,EAC1B,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,EACnC,CAAA;AACD,QAAA,YAAY,CACX,KAAC,CAAA,aAAA,CAAA,cAAc,EACb,EAAA,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAAE,aAAa,EACjC,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,SAAS,EACxB,eAAe,EAAE,eAAe,EAChC,uBAAuB,EAAE,uBAAuB,EAChD,CAAA,EACF,IAAI,CACL,CACQ,EACX;AACJ;;;;"}
|
|
@@ -19,7 +19,7 @@ import classes from './DataGridFilter.module.scss.esm.js';
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
const EditTagContent = ({ filter }) => {
|
|
22
|
+
const EditTagContent = ({ filter, or, other }) => {
|
|
23
23
|
const { column, operator, value } = filter;
|
|
24
24
|
return (React.createElement(Fragment, null,
|
|
25
25
|
column,
|
|
@@ -28,22 +28,31 @@ const EditTagContent = ({ filter }) => {
|
|
|
28
28
|
" ",
|
|
29
29
|
value.length > 0 && React.createElement("b", null, value[0]),
|
|
30
30
|
value.length >= 2 && (React.createElement(React.Fragment, null,
|
|
31
|
-
"
|
|
31
|
+
" ",
|
|
32
|
+
or,
|
|
33
|
+
" ",
|
|
32
34
|
React.createElement("b", null,
|
|
33
|
-
" ",
|
|
34
35
|
value.length - 1,
|
|
35
|
-
"
|
|
36
|
+
" ",
|
|
37
|
+
other)))));
|
|
36
38
|
};
|
|
37
|
-
const DataGridFilterTagComponent = ({ triggerRef, filter, mode, onFilterRemove, onFilterOpen, translations, customEditTagContent, ...rest }, ref) => {
|
|
38
|
-
const { addButtonCaption = "Add filter" } = translations || {};
|
|
39
|
+
const DataGridFilterTagComponent = ({ triggerRef, filter, mode, onFilterRemove, onFilterOpen, translations, dateTagCaption, customEditTagContent, ...rest }, ref) => {
|
|
40
|
+
const { addButtonCaption = "Add filter", or = "or", other = "other", dateIs = "Date is" } = translations || {};
|
|
39
41
|
const shouldRenderAddTag = mode === "ADD";
|
|
40
42
|
const shouldRenderEditTag = mode === "EDIT" && filter;
|
|
43
|
+
const shouldRenderAddDateTag = mode === "ADD_DATE";
|
|
41
44
|
return (React.createElement("div", { ...rest, ref: ref, className: classes["filter-wrapper"] },
|
|
42
45
|
React.createElement("button", { ref: triggerRef, type: "button", className: classes["filter-button"], onClick: onFilterOpen },
|
|
43
46
|
shouldRenderAddTag && (React.createElement(Fragment, null,
|
|
44
47
|
React.createElement(Icon, { icon: Icons.AddCircle }),
|
|
45
48
|
React.createElement(Typography, { variant: "body", className: classes["caption"] }, addButtonCaption))),
|
|
46
|
-
shouldRenderEditTag && (React.createElement(Typography, { variant: "body", className: classes["caption"] }, customEditTagContent ? (React.cloneElement(customEditTagContent, { filter })) : (React.createElement(EditTagContent, { filter: filter }))))
|
|
49
|
+
shouldRenderEditTag && (React.createElement(Typography, { variant: "body", className: classes["caption"] }, customEditTagContent ? (React.cloneElement(customEditTagContent, { filter })) : (React.createElement(EditTagContent, { filter: filter, or: or, other: other })))),
|
|
50
|
+
shouldRenderAddDateTag && (React.createElement(Fragment, null,
|
|
51
|
+
React.createElement(Icon, { icon: Icons.Calendar }),
|
|
52
|
+
React.createElement(Typography, { variant: "body", className: classes["caption"] },
|
|
53
|
+
dateIs,
|
|
54
|
+
" ",
|
|
55
|
+
React.createElement("b", null, dateTagCaption))))),
|
|
47
56
|
shouldRenderEditTag && (React.createElement(RemoveButton, { className: classes["remove-button"], onRemove: onFilterRemove }))));
|
|
48
57
|
};
|
|
49
58
|
const DataGridFilterTag = React.forwardRef(DataGridFilterTagComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridFilterTag.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, ForwardRefRenderFunction, Fragment } from \"react\";\nimport { Icon, Icons } from \"../../Icon/Icon\";\nimport { RemoveButton } from \"../../Tag/RemoveButton\";\nimport { Typography } from \"../../Typography/Typography\";\nimport classes from \"./DataGridFilter.module.scss\";\nimport { Filter, FilterEditorMode, TagTranslations } from \"./DataGridFilters.interfaces\";\n\nexport interface DataGridFilterTagProps extends ComponentPropsWithRef<\"div\"> {\n customEditTagContent?: React.ReactElement;\n triggerRef: React.Ref<HTMLButtonElement>;\n filter?: Filter;\n mode: FilterEditorMode;\n onFilterRemove
|
|
1
|
+
{"version":3,"file":"DataGridFilterTag.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, ForwardRefRenderFunction, Fragment } from \"react\";\nimport { Icon, Icons } from \"../../Icon/Icon\";\nimport { RemoveButton } from \"../../Tag/RemoveButton\";\nimport { Typography } from \"../../Typography/Typography\";\nimport classes from \"./DataGridFilter.module.scss\";\nimport { Filter, FilterEditorMode, TagTranslations } from \"./DataGridFilters.interfaces\";\n\nexport interface DataGridFilterTagProps extends ComponentPropsWithRef<\"div\"> {\n customEditTagContent?: React.ReactElement;\n triggerRef: React.Ref<HTMLButtonElement>;\n filter?: Filter;\n mode: FilterEditorMode;\n onFilterRemove?: () => void;\n onFilterOpen: () => void;\n translations?: TagTranslations;\n dateTagCaption?: string;\n}\n\nconst EditTagContent = ({ filter, or, other }: { filter: Filter; or: string; other: string }) => {\n const { column, operator, value } = filter;\n\n return (\n <Fragment>\n {column} {operator} {value.length > 0 && <b>{value[0]}</b>}\n {value.length >= 2 && (\n <>\n {\" \"}\n {or}{\" \"}\n <b>\n {value.length - 1} {other}\n </b>\n </>\n )}\n </Fragment>\n );\n};\n\nexport const DataGridFilterTagComponent: ForwardRefRenderFunction<\n HTMLDivElement,\n DataGridFilterTagProps\n> = (\n {\n triggerRef,\n filter,\n mode,\n onFilterRemove,\n onFilterOpen,\n translations,\n dateTagCaption,\n customEditTagContent,\n ...rest\n }: DataGridFilterTagProps,\n ref\n) => {\n const {\n addButtonCaption = \"Add filter\",\n or = \"or\",\n other = \"other\",\n dateIs = \"Date is\"\n } = translations || {};\n const shouldRenderAddTag = mode === \"ADD\";\n const shouldRenderEditTag = mode === \"EDIT\" && filter;\n const shouldRenderAddDateTag = mode === \"ADD_DATE\";\n\n return (\n <div {...rest} ref={ref} className={classes[\"filter-wrapper\"]}>\n <button\n ref={triggerRef}\n type=\"button\"\n className={classes[\"filter-button\"]}\n onClick={onFilterOpen}\n >\n {shouldRenderAddTag && (\n <Fragment>\n <Icon icon={Icons.AddCircle} />\n <Typography variant=\"body\" className={classes[\"caption\"]}>\n {addButtonCaption}\n </Typography>\n </Fragment>\n )}\n {shouldRenderEditTag && (\n <Typography variant=\"body\" className={classes[\"caption\"]}>\n {customEditTagContent ? (\n React.cloneElement(customEditTagContent, { filter })\n ) : (\n <EditTagContent filter={filter} or={or} other={other} />\n )}\n </Typography>\n )}\n {shouldRenderAddDateTag && (\n <Fragment>\n <Icon icon={Icons.Calendar} />\n <Typography variant=\"body\" className={classes[\"caption\"]}>\n {dateIs} <b>{dateTagCaption}</b>\n </Typography>\n </Fragment>\n )}\n </button>\n {shouldRenderEditTag && (\n <RemoveButton className={classes[\"remove-button\"]} onRemove={onFilterRemove} />\n )}\n </div>\n );\n};\n\nexport const DataGridFilterTag = React.forwardRef(DataGridFilterTagComponent);\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAoBH,MAAM,cAAc,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAiD,KAAI;IAC9F,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAE3C,QACE,oBAAC,QAAQ,EAAA,IAAA;QACN,MAAM;;QAAG,QAAQ;;QAAG,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,+BAAI,KAAK,CAAC,CAAC,CAAC,CAAK;AACzD,QAAA,KAAK,CAAC,MAAM,IAAI,CAAC,KAChB,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;YACG,GAAG;YACH,EAAE;YAAE,GAAG;AACR,YAAA,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA;gBACG,KAAK,CAAC,MAAM,GAAG,CAAC;;AAAG,gBAAA,KAAK,CACvB,CACH,CACJ,CACQ,EACX;AACJ,CAAC,CAAC;AAEK,MAAM,0BAA0B,GAGnC,CACF,EACE,UAAU,EACV,MAAM,EACN,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,GAAG,IAAI,EACgB,EACzB,GAAG,KACD;IACF,MAAM,EACJ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AAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAA,CAAI,CACzD,CACU,CACd;YACA,sBAAsB,KACrB,KAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,IAAA;AACP,gBAAA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAC,EAAA,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAI,CAAA;gBAC9B,KAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,OAAO,EAAC,MAAM,EAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,EAAA;oBACrD,MAAM;;AAAE,oBAAA,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA,EAAI,cAAc,CAAK,CACrB,CACJ,CACZ,CACM;AACR,QAAA,mBAAmB,KAClB,KAAA,CAAA,aAAA,CAAC,YAAY,EAAC,EAAA,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,cAAc,GAAI,CAChF,CACG,EACN;AACJ,EAAE;AAEW,MAAA,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAAC,0BAA0B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridFilters.interfaces.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Filter {\n id: string;\n column: string;\n operator: string;\n value: string[];\n}\n\nexport type FiltersAction =\n | {\n type: \"add\";\n payload: Filter;\n }\n | {\n type: \"edit\";\n payload: Filter;\n }\n | {\n type: \"remove\";\n payload: { id: string };\n }\n | {\n type: \"clear\";\n };\n\nexport type FiltersState = {\n filters: Filter[];\n};\n\nexport type FilterEditorMode = \"ADD\" | \"EDIT\";\n\nexport enum DefaultOperators {\n is = \"is\",\n isNot = \"is not\",\n contains = \"contains\",\n doesNotContain = \"does not contain\",\n isEmpty = \"is empty\"\n}\n\nexport interface DataGridColumnMetadata {\n name: string;\n headline: string;\n operators?: string[];\n defaultValues?: string[];\n disableAddNew?: boolean;\n}\n\nexport interface PopoverTranslations {\n columnSelectLabel?: string;\n operatorSelectLabel?: string;\n valueSelectLabel?: string;\n addNewValueLabel?: string;\n addNewValueButtonTitle?: string;\n submitButtonTitle?: string;\n cancelButtonTitle?: string;\n}\n\nexport interface TagTranslations {\n addButtonCaption?: string;\n}\n\nexport interface ToolbarTranslations {\n clearButtonCaption?: string;\n}\n\nexport interface FiltersTranslations {\n toolbar?: ToolbarTranslations;\n tag?: TagTranslations;\n popover?: PopoverTranslations;\n}\n\nexport interface KeyValuePair<TKey = string, TValue = string> {\n key: TKey;\n value: TValue;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;IAgCS,iBAMX;AAND,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACT,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,QAAgB,CAAA;AAChB,IAAA,gBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,gBAAA,CAAA,gBAAA,CAAA,GAAA,kBAAmC,CAAA;AACnC,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,UAAoB,CAAA;AACtB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,GAM3B,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"DataGridFilters.interfaces.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Filter {\n id: string;\n column: string;\n operator: string;\n value: string[];\n}\n\nexport type FiltersAction =\n | {\n type: \"add\";\n payload: Filter;\n }\n | {\n type: \"edit\";\n payload: Filter;\n }\n | {\n type: \"remove\";\n payload: { id: string };\n }\n | {\n type: \"clear\";\n };\n\nexport type FiltersState = {\n filters: Filter[];\n};\n\nexport type FilterEditorMode = \"ADD\" | \"EDIT\" | \"ADD_DATE\";\n\nexport enum DefaultOperators {\n is = \"is\",\n isNot = \"is not\",\n contains = \"contains\",\n doesNotContain = \"does not contain\",\n isEmpty = \"is empty\"\n}\n\nexport interface DataGridColumnMetadata {\n name: string;\n headline: string;\n operators?: string[];\n defaultValues?: string[];\n disableAddNew?: boolean;\n}\n\nexport interface PopoverTranslations {\n columnSelectLabel?: string;\n operatorSelectLabel?: string;\n valueSelectLabel?: string;\n addNewValueLabel?: string;\n addNewValueButtonTitle?: string;\n submitButtonTitle?: string;\n cancelButtonTitle?: string;\n}\n\nexport interface TagTranslations {\n addButtonCaption?: string;\n or?: string;\n other?: string;\n dateIs?: string;\n}\n\nexport interface ToolbarTranslations {\n clearButtonCaption?: string;\n}\n\nexport interface FiltersTranslations {\n toolbar?: ToolbarTranslations;\n tag?: TagTranslations;\n popover?: PopoverTranslations;\n}\n\nexport interface KeyValuePair<TKey = string, TValue = string> {\n key: TKey;\n value: TValue;\n}\n\nexport type DateTimeFilterType =\n | \"THIRTY_SECONDS\"\n | \"ONE_MINUTE\"\n | \"FIVE_MINUTES\"\n | \"ONE_HOUR\"\n | \"TWENTY_FOUR_HOURS\"\n | \"CUSTOM\";\n\nexport interface DateTimeFilter {\n fromDate: string;\n toDate: string;\n type: DateTimeFilterType;\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;AAcG;IAgCS,iBAMX;AAND,CAAA,UAAY,gBAAgB,EAAA;AAC1B,IAAA,gBAAA,CAAA,IAAA,CAAA,GAAA,IAAS,CAAA;AACT,IAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,QAAgB,CAAA;AAChB,IAAA,gBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,gBAAA,CAAA,gBAAA,CAAA,GAAA,kBAAmC,CAAA;AACnC,IAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,UAAoB,CAAA;AACtB,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,GAM3B,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -3,6 +3,7 @@ import { DataGridFilter } from './DataGridFilter.esm.js';
|
|
|
3
3
|
import classes from './DataGridToolbar.module.scss.esm.js';
|
|
4
4
|
import { Typography } from '../../Typography/Typography.esm.js';
|
|
5
5
|
import { useFiltersReducer } from './useFiltersReducer.esm.js';
|
|
6
|
+
import { DataGridDateFilter } from './DataGridDateFilter.esm.js';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
* Copyright 2022 OneWelcome B.V.
|
|
@@ -19,27 +20,29 @@ import { useFiltersReducer } from './useFiltersReducer.esm.js';
|
|
|
19
20
|
* See the License for the specific language governing permissions and
|
|
20
21
|
* limitations under the License.
|
|
21
22
|
*/
|
|
22
|
-
const DataGridToolbar = ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, onFiltersClear, customEditTagContent }) => {
|
|
23
|
+
const DataGridToolbar = ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, dateFilterValue, onDateFilterValueChange, onFiltersClear, customEditTagContent }) => {
|
|
23
24
|
const { state, addFilter, editFilter, deleteFilter, clearFilters } = useFiltersReducer(filterValues);
|
|
24
25
|
const { clearButtonCaption = "Clear all filters" } = (translations === null || translations === void 0 ? void 0 : translations.toolbar) || {};
|
|
25
26
|
return (React.createElement(Fragment, null,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
columnsMetadata &&
|
|
28
|
+
state.filters.map(filter => (React.createElement(DataGridFilter, { mode: "EDIT", key: filter.id, filter: filter, columnsMetadata: columnsMetadata, onFilterEdit: filter => {
|
|
29
|
+
editFilter(filter);
|
|
30
|
+
onFilterEdit && onFilterEdit(filter);
|
|
31
|
+
}, onFilterDelete: id => {
|
|
32
|
+
deleteFilter(id);
|
|
33
|
+
onFilterDelete && onFilterDelete(id);
|
|
34
|
+
}, tagTranslations: translations === null || translations === void 0 ? void 0 : translations.tag, popoverTranslations: translations === null || translations === void 0 ? void 0 : translations.popover, customEditTagContent: customEditTagContent }))),
|
|
33
35
|
React.createElement("div", { className: classes["actions-wrapper"] },
|
|
34
|
-
React.createElement(DataGridFilter, { mode: "ADD", customEditTagContent: customEditTagContent, columnsMetadata: columnsMetadata, onFilterAdd: filter => {
|
|
36
|
+
columnsMetadata && (React.createElement(DataGridFilter, { mode: "ADD", customEditTagContent: customEditTagContent, columnsMetadata: columnsMetadata, onFilterAdd: filter => {
|
|
35
37
|
addFilter(filter);
|
|
36
38
|
onFilterAdd && onFilterAdd(filter);
|
|
37
|
-
}, tagTranslations: translations === null || translations === void 0 ? void 0 : translations.tag, popoverTranslations: translations === null || translations === void 0 ? void 0 : translations.popover }),
|
|
38
|
-
state.filters.length >= 1 && (React.createElement("button", { type: "button", className: classes["clear-button"], onClick: () => {
|
|
39
|
+
}, tagTranslations: translations === null || translations === void 0 ? void 0 : translations.tag, popoverTranslations: translations === null || translations === void 0 ? void 0 : translations.popover })),
|
|
40
|
+
columnsMetadata && state.filters.length >= 1 && (React.createElement("button", { type: "button", className: classes["clear-button"], onClick: () => {
|
|
39
41
|
clearFilters();
|
|
40
42
|
onFiltersClear && onFiltersClear();
|
|
41
43
|
} },
|
|
42
|
-
React.createElement(Typography, { variant: "body", className: classes["caption"] }, clearButtonCaption)))
|
|
44
|
+
React.createElement(Typography, { variant: "body", className: classes["caption"] }, clearButtonCaption))),
|
|
45
|
+
dateFilterValue && (React.createElement(DataGridDateFilter, { dateFilterValue: dateFilterValue, onDateFilterValueChange: onDateFilterValueChange })))));
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
export { DataGridToolbar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridToolbar.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment } from \"react\";\nimport { DataGridFilter } from \"./DataGridFilter\";\nimport classes from \"./DataGridToolbar.module.scss\";\nimport {
|
|
1
|
+
{"version":3,"file":"DataGridToolbar.esm.js","sources":["../../../../../../src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment } from \"react\";\nimport { DataGridFilter } from \"./DataGridFilter\";\nimport classes from \"./DataGridToolbar.module.scss\";\nimport {\n DataGridColumnMetadata,\n DateTimeFilter,\n Filter,\n FiltersTranslations\n} from \"./DataGridFilters.interfaces\";\nimport { Typography } from \"../../Typography/Typography\";\nimport { useFiltersReducer } from \"./useFiltersReducer\";\nimport { DataGridDateFilter } from \"./DataGridDateFilter\";\n\nexport interface DataGridToolbarProps {\n columnsMetadata?: DataGridColumnMetadata[];\n customEditTagContent?: React.ReactElement;\n dateFilterValue?: DateTimeFilter;\n onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;\n filterValues?: Filter[];\n translations?: FiltersTranslations;\n onFilterAdd?: (filter: Filter) => void;\n onFilterEdit?: (filter: Filter) => void;\n onFilterDelete?: (id: string) => void;\n onFiltersClear?: () => void;\n}\n\nexport const DataGridToolbar = ({\n columnsMetadata,\n filterValues,\n translations,\n onFilterAdd,\n onFilterEdit,\n onFilterDelete,\n dateFilterValue,\n onDateFilterValueChange,\n onFiltersClear,\n customEditTagContent\n}: DataGridToolbarProps) => {\n const { state, addFilter, editFilter, deleteFilter, clearFilters } =\n useFiltersReducer(filterValues);\n const { clearButtonCaption = \"Clear all filters\" } = translations?.toolbar || {};\n return (\n <Fragment>\n {columnsMetadata &&\n state.filters.map(filter => (\n <DataGridFilter\n mode=\"EDIT\"\n key={filter.id}\n filter={filter}\n columnsMetadata={columnsMetadata}\n onFilterEdit={filter => {\n editFilter(filter);\n onFilterEdit && onFilterEdit(filter);\n }}\n onFilterDelete={id => {\n deleteFilter(id);\n onFilterDelete && onFilterDelete(id);\n }}\n tagTranslations={translations?.tag}\n popoverTranslations={translations?.popover}\n customEditTagContent={customEditTagContent}\n />\n ))}\n <div className={classes[\"actions-wrapper\"]}>\n {columnsMetadata && (\n <DataGridFilter\n mode=\"ADD\"\n customEditTagContent={customEditTagContent}\n columnsMetadata={columnsMetadata}\n onFilterAdd={filter => {\n addFilter(filter);\n onFilterAdd && onFilterAdd(filter);\n }}\n tagTranslations={translations?.tag}\n popoverTranslations={translations?.popover}\n />\n )}\n {columnsMetadata && state.filters.length >= 1 && (\n <button\n type=\"button\"\n className={classes[\"clear-button\"]}\n onClick={() => {\n clearFilters();\n onFiltersClear && onFiltersClear();\n }}\n >\n <Typography variant=\"body\" className={classes[\"caption\"]}>\n {clearButtonCaption}\n </Typography>\n </button>\n )}\n\n {dateFilterValue && (\n <DataGridDateFilter\n dateFilterValue={dateFilterValue}\n onDateFilterValueChange={onDateFilterValueChange}\n />\n )}\n </div>\n </Fragment>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AA4BU,MAAA,eAAe,GAAG,CAAC,EAC9B,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACC,KAAI;AACzB,IAAA,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,GAChE,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAClC,IAAA,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,EAAE,GAAG,CAAA,YAAY,KAAZ,IAAA,IAAA,YAAY,uBAAZ,YAAY,CAAE,OAAO,KAAI,EAAE,CAAC;IACjF,QACE,oBAAC,QAAQ,EAAA,IAAA;QACN,eAAe;AACd,YAAA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,KACtB,KAAC,CAAA,aAAA,CAAA,cAAc,EACb,EAAA,IAAI,EAAC,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,MAAM,IAAG;oBACrB,UAAU,CAAC,MAAM,CAAC,CAAC;AACnB,oBAAA,YAAY,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AACvC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AED,gBAAA,KAAA,CAAA,aAAA,CAAC,UAAU,EAAC,EAAA,OAAO,EAAC,MAAM,EAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,EAAA,EACrD,kBAAkB,CACR,CACN,CACV;AAEA,YAAA,eAAe,KACd,KAAA,CAAA,aAAA,CAAC,kBAAkB,EAAA,EACjB,eAAe,EAAE,eAAe,EAChC,uBAAuB,EAAE,uBAAuB,EAAA,CAChD,CACH,CACG,CACG,EACX;AACJ;;;;"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Popover } from '../../../Popover/Popover.esm.js';
|
|
3
|
+
import classes from './DateTimePicker.module.scss.esm.js';
|
|
4
|
+
import { Button } from '../../../Button/Button.esm.js';
|
|
5
|
+
import { CUSTOM_DATE_RANGE, formatInputDate, THIRTY_SECONDS, ONE_MINUTE, FIVE_MINUTES, ONE_HOUR, TWENTY_FOUR_HOURS } from './DateTimeService.esm.js';
|
|
6
|
+
import { SideMenu } from './SideMenu.esm.js';
|
|
7
|
+
import { addSeconds } from 'date-fns';
|
|
8
|
+
import { DateTimePickerInputSection } from './DateTimePickerInputSection.esm.js';
|
|
9
|
+
import { DateTimePickerCalendarSection } from './DateTimePickerCalendarSection.esm.js';
|
|
10
|
+
import { useRepeatFocus } from '../../../src/hooks/useRepeatFocus.esm.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Copyright 2022 OneWelcome B.V.
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
const dateFormat = "yyyy-mm-dd hh:mm:ss";
|
|
28
|
+
const sideMenuItems = [
|
|
29
|
+
{ id: THIRTY_SECONDS, name: "Last 30 seconds", rangeSeconds: 30 },
|
|
30
|
+
{ id: ONE_MINUTE, name: "Last 1 minute", rangeSeconds: 60 },
|
|
31
|
+
{ id: FIVE_MINUTES, name: "Last 5 minutes", rangeSeconds: 300 },
|
|
32
|
+
{ id: ONE_HOUR, name: "Last 1 hour", rangeSeconds: 3600 },
|
|
33
|
+
{ id: TWENTY_FOUR_HOURS, name: "Last 24 hours", rangeSeconds: 86400 },
|
|
34
|
+
{ id: CUSTOM_DATE_RANGE, name: "Custom" }
|
|
35
|
+
];
|
|
36
|
+
const DateTimePicker = ({ anchorRef, popoverRef, isOpen, setPickerOpen, onTagCaptionChange, translations = {
|
|
37
|
+
errors: {
|
|
38
|
+
dateFormatError: `The format must be ${dateFormat}`
|
|
39
|
+
},
|
|
40
|
+
previousMonth: "Previous month",
|
|
41
|
+
nextMonth: "Next month",
|
|
42
|
+
from: "From",
|
|
43
|
+
to: "To",
|
|
44
|
+
cancel: "Cancel",
|
|
45
|
+
apply: "Apply",
|
|
46
|
+
dateInputPlaceholder: dateFormat
|
|
47
|
+
}, dateFilterValue, onDateFilterValueChange }) => {
|
|
48
|
+
const { errors: { dateFormatError }, previousMonth, nextMonth, cancel, from, to, apply, dateInputPlaceholder } = translations;
|
|
49
|
+
const [selectedDate, setSelectedDate] = useState({
|
|
50
|
+
from: (dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.fromDate) ? new Date(dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.fromDate) : undefined,
|
|
51
|
+
to: (dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.toDate) ? new Date(dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.toDate) : undefined
|
|
52
|
+
});
|
|
53
|
+
const [selectedPredefinedRange, setSelectedPredefinedRange] = useState(sideMenuItems[0].id);
|
|
54
|
+
const [fromDateText, setFromDateText] = useState("");
|
|
55
|
+
const [toDateText, setToDateText] = useState("");
|
|
56
|
+
const [fromDateError, setFromDateError] = useState("");
|
|
57
|
+
const [toDateError, setToDateError] = useState("");
|
|
58
|
+
useRepeatFocus(popoverRef);
|
|
59
|
+
const disableDateRangePickers = selectedPredefinedRange !== CUSTOM_DATE_RANGE;
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
var _a;
|
|
62
|
+
if (isOpen) {
|
|
63
|
+
(_a = popoverRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
64
|
+
}
|
|
65
|
+
}, [isOpen]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (dateFilterValue) {
|
|
68
|
+
const foundItem = sideMenuItems.find(item => item.id === dateFilterValue.type);
|
|
69
|
+
foundItem && onTagCaptionChange(foundItem.name);
|
|
70
|
+
setSelectedPredefinedRange(dateFilterValue.type);
|
|
71
|
+
if ((foundItem === null || foundItem === void 0 ? void 0 : foundItem.rangeSeconds) && dateFilterValue.type !== CUSTOM_DATE_RANGE) {
|
|
72
|
+
const fromDate = addSeconds(new Date(), -foundItem.rangeSeconds);
|
|
73
|
+
const toDate = new Date();
|
|
74
|
+
setFromDateText(formatInputDate(fromDate));
|
|
75
|
+
setToDateText(formatInputDate(toDate));
|
|
76
|
+
setSelectedDate({ from: fromDate, to: toDate });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
dateFilterValue.fromDate &&
|
|
80
|
+
setFromDateText(formatInputDate(new Date(dateFilterValue.fromDate)));
|
|
81
|
+
dateFilterValue.toDate && setToDateText(formatInputDate(new Date(dateFilterValue.toDate)));
|
|
82
|
+
setSelectedDate({
|
|
83
|
+
from: (dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.fromDate) ? new Date(dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.fromDate) : undefined,
|
|
84
|
+
to: (dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.toDate) ? new Date(dateFilterValue === null || dateFilterValue === void 0 ? void 0 : dateFilterValue.toDate) : undefined
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [dateFilterValue]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!dateFilterValue) {
|
|
90
|
+
isOpen && onSideMenuItemSelect(selectedPredefinedRange);
|
|
91
|
+
}
|
|
92
|
+
}, [isOpen, dateFilterValue]);
|
|
93
|
+
const onSideMenuItemSelect = (itemId) => {
|
|
94
|
+
setSelectedPredefinedRange(itemId);
|
|
95
|
+
const foundItem = sideMenuItems.find(item => item.id === itemId);
|
|
96
|
+
foundItem && onTagCaptionChange(foundItem.name);
|
|
97
|
+
if (itemId !== CUSTOM_DATE_RANGE) {
|
|
98
|
+
if (!foundItem) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (foundItem.rangeSeconds) {
|
|
102
|
+
const fromDate = addSeconds(new Date(), -foundItem.rangeSeconds);
|
|
103
|
+
const toDate = new Date();
|
|
104
|
+
setSelectedDate({ from: fromDate, to: toDate });
|
|
105
|
+
setFromDateText(formatInputDate(fromDate));
|
|
106
|
+
setToDateText(formatInputDate(toDate));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const closeDateTimePicker = () => {
|
|
111
|
+
setPickerOpen(false);
|
|
112
|
+
};
|
|
113
|
+
const saveDateTimePicker = () => {
|
|
114
|
+
var _a, _b, _c, _d;
|
|
115
|
+
onDateFilterValueChange &&
|
|
116
|
+
onDateFilterValueChange({
|
|
117
|
+
toDate: (_b = (_a = selectedDate.to) === null || _a === void 0 ? void 0 : _a.toISOString()) !== null && _b !== void 0 ? _b : "",
|
|
118
|
+
fromDate: (_d = (_c = selectedDate.from) === null || _c === void 0 ? void 0 : _c.toISOString()) !== null && _d !== void 0 ? _d : "",
|
|
119
|
+
type: selectedPredefinedRange
|
|
120
|
+
});
|
|
121
|
+
setPickerOpen(false);
|
|
122
|
+
};
|
|
123
|
+
return (React.createElement(Popover, { tabIndex: -1, anchorEl: anchorRef, ref: popoverRef, show: isOpen, placement: { horizontal: "left", vertical: "bottom" }, transformOrigin: { horizontal: "left", vertical: "top" } }, isOpen && (React.createElement("div", { className: classes["popover"] },
|
|
124
|
+
React.createElement("div", { className: classes["content-wrapper"] },
|
|
125
|
+
React.createElement("div", { className: classes["aside"] },
|
|
126
|
+
React.createElement(SideMenu, { sideMenuItems: sideMenuItems, selectedItemId: selectedPredefinedRange, onItemSelect: onSideMenuItemSelect })),
|
|
127
|
+
React.createElement("div", { className: `${classes["controls"]} ${toDateError || fromDateError ? classes["has-error"] : ""}` },
|
|
128
|
+
React.createElement("div", { className: classes["controls-panel"] },
|
|
129
|
+
React.createElement(DateTimePickerInputSection, { from: from, to: to, dateInputPlaceholder: dateInputPlaceholder, dateFormatError: dateFormatError, fromDateText: fromDateText, toDateText: toDateText, fromDateError: fromDateError, toDateError: toDateError, setSelectedDate: setSelectedDate, setFromDateText: setFromDateText, setToDateText: setToDateText, setFromDateError: setFromDateError, setToDateError: setToDateError })),
|
|
130
|
+
React.createElement("div", { className: `${classes["controls-panel"]} ${classes["set-height"]}` },
|
|
131
|
+
React.createElement(DateTimePickerCalendarSection, { previousMonth: previousMonth, nextMonth: nextMonth, selectedDate: selectedDate, disableDateRangePickers: disableDateRangePickers, setSelectedDate: setSelectedDate, setFromDateText: setFromDateText, setFromDateError: setFromDateError, setToDateText: setToDateText, setToDateError: setToDateError })))),
|
|
132
|
+
React.createElement("div", { className: classes["actions"] },
|
|
133
|
+
React.createElement(Button, { variant: "text", onClick: closeDateTimePicker }, cancel),
|
|
134
|
+
React.createElement(Button, { onClick: saveDateTimePicker }, apply))))));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export { DateTimePicker, dateFormat };
|
|
138
|
+
//# sourceMappingURL=DateTimePicker.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePicker.esm.js","sources":["../../../../../../../src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState } from \"react\";\nimport { Popover } from \"../../../Popover/Popover\";\nimport classes from \"./DateTimePicker.module.scss\";\nimport { Button } from \"../../../Button/Button\";\nimport { DateRange } from \"react-day-picker\";\nimport {\n CUSTOM_DATE_RANGE,\n FIVE_MINUTES,\n ONE_HOUR,\n ONE_MINUTE,\n THIRTY_SECONDS,\n TWENTY_FOUR_HOURS,\n formatInputDate\n} from \"./DateTimeService\";\nimport { SideMenu } from \"./SideMenu\";\nimport { addSeconds } from \"date-fns\";\nimport { DateTimePickerInputSection } from \"./DateTimePickerInputSection\";\nimport { DateTimePickerCalendarSection } from \"./DateTimePickerCalendarSection\";\nimport { DateTimeFilter, DateTimeFilterType } from \"../DataGridFilters.interfaces\";\nimport { useRepeatFocus } from \"../../../../hooks/useRepeatFocus\";\n\nexport type DateTimePickerTranslations = {\n errors: {\n dateFormatError: string;\n };\n previousMonth: string;\n nextMonth: string;\n from: string;\n to: string;\n cancel: string;\n apply: string;\n dateInputPlaceholder: string;\n};\n\nexport type Props = {\n popoverRef: React.RefObject<HTMLDivElement>;\n anchorRef?: React.RefObject<HTMLDivElement>;\n isOpen: boolean;\n onTagCaptionChange: (value: string) => void;\n setPickerOpen: (open: boolean) => void;\n translations?: DateTimePickerTranslations;\n dateFilterValue?: DateTimeFilter;\n onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;\n};\n\nexport type SideMenuItem = {\n id: DateTimeFilterType;\n name: string;\n rangeSeconds?: number;\n};\n\nexport const dateFormat = \"yyyy-mm-dd hh:mm:ss\";\n\nconst sideMenuItems: SideMenuItem[] = [\n { id: THIRTY_SECONDS, name: \"Last 30 seconds\", rangeSeconds: 30 },\n { id: ONE_MINUTE, name: \"Last 1 minute\", rangeSeconds: 60 },\n { id: FIVE_MINUTES, name: \"Last 5 minutes\", rangeSeconds: 300 },\n { id: ONE_HOUR, name: \"Last 1 hour\", rangeSeconds: 3600 },\n { id: TWENTY_FOUR_HOURS, name: \"Last 24 hours\", rangeSeconds: 86400 },\n { id: CUSTOM_DATE_RANGE, name: \"Custom\" }\n];\n\nexport const DateTimePicker = ({\n anchorRef,\n popoverRef,\n isOpen,\n setPickerOpen,\n onTagCaptionChange,\n translations = {\n errors: {\n dateFormatError: `The format must be ${dateFormat}`\n },\n previousMonth: \"Previous month\",\n nextMonth: \"Next month\",\n from: \"From\",\n to: \"To\",\n cancel: \"Cancel\",\n apply: \"Apply\",\n dateInputPlaceholder: dateFormat\n },\n dateFilterValue,\n onDateFilterValueChange\n}: Props) => {\n const {\n errors: { dateFormatError },\n previousMonth,\n nextMonth,\n cancel,\n from,\n to,\n apply,\n dateInputPlaceholder\n } = translations;\n const [selectedDate, setSelectedDate] = useState<DateRange>({\n from: dateFilterValue?.fromDate ? new Date(dateFilterValue?.fromDate) : undefined,\n to: dateFilterValue?.toDate ? new Date(dateFilterValue?.toDate) : undefined\n });\n const [selectedPredefinedRange, setSelectedPredefinedRange] = useState<DateTimeFilterType>(\n sideMenuItems[0].id\n );\n const [fromDateText, setFromDateText] = useState(\"\");\n const [toDateText, setToDateText] = useState(\"\");\n const [fromDateError, setFromDateError] = useState(\"\");\n const [toDateError, setToDateError] = useState(\"\");\n useRepeatFocus(popoverRef);\n\n const disableDateRangePickers = selectedPredefinedRange !== CUSTOM_DATE_RANGE;\n\n useEffect(() => {\n if (isOpen) {\n popoverRef.current?.focus();\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (dateFilterValue) {\n const foundItem = sideMenuItems.find(item => item.id === dateFilterValue.type);\n\n foundItem && onTagCaptionChange(foundItem.name);\n\n setSelectedPredefinedRange(dateFilterValue.type);\n\n if (foundItem?.rangeSeconds && dateFilterValue.type !== CUSTOM_DATE_RANGE) {\n const fromDate = addSeconds(new Date(), -foundItem.rangeSeconds);\n const toDate = new Date();\n\n setFromDateText(formatInputDate(fromDate));\n setToDateText(formatInputDate(toDate));\n setSelectedDate({ from: fromDate, to: toDate });\n\n return;\n }\n\n dateFilterValue.fromDate &&\n setFromDateText(formatInputDate(new Date(dateFilterValue.fromDate)));\n\n dateFilterValue.toDate && setToDateText(formatInputDate(new Date(dateFilterValue.toDate)));\n\n setSelectedDate({\n from: dateFilterValue?.fromDate ? new Date(dateFilterValue?.fromDate) : undefined,\n to: dateFilterValue?.toDate ? new Date(dateFilterValue?.toDate) : undefined\n });\n }\n }, [dateFilterValue]);\n\n useEffect(() => {\n if (!dateFilterValue) {\n isOpen && onSideMenuItemSelect(selectedPredefinedRange);\n }\n }, [isOpen, dateFilterValue]);\n\n const onSideMenuItemSelect = (itemId: DateTimeFilterType) => {\n setSelectedPredefinedRange(itemId);\n const foundItem = sideMenuItems.find(item => item.id === itemId);\n foundItem && onTagCaptionChange(foundItem.name);\n\n if (itemId !== CUSTOM_DATE_RANGE) {\n if (!foundItem) {\n return;\n }\n\n if (foundItem.rangeSeconds) {\n const fromDate = addSeconds(new Date(), -foundItem.rangeSeconds);\n const toDate = new Date();\n\n setSelectedDate({ from: fromDate, to: toDate });\n setFromDateText(formatInputDate(fromDate));\n setToDateText(formatInputDate(toDate));\n }\n }\n };\n\n const closeDateTimePicker = () => {\n setPickerOpen(false);\n };\n\n const saveDateTimePicker = () => {\n onDateFilterValueChange &&\n onDateFilterValueChange({\n toDate: selectedDate.to?.toISOString() ?? \"\",\n fromDate: selectedDate.from?.toISOString() ?? \"\",\n type: selectedPredefinedRange\n });\n setPickerOpen(false);\n };\n\n return (\n <Popover\n tabIndex={-1}\n anchorEl={anchorRef}\n ref={popoverRef}\n show={isOpen}\n placement={{ horizontal: \"left\", vertical: \"bottom\" }}\n transformOrigin={{ horizontal: \"left\", vertical: \"top\" }}\n >\n {isOpen && (\n <div className={classes[\"popover\"]}>\n <div className={classes[\"content-wrapper\"]}>\n <div className={classes[\"aside\"]}>\n <SideMenu\n sideMenuItems={sideMenuItems}\n selectedItemId={selectedPredefinedRange}\n onItemSelect={onSideMenuItemSelect}\n />\n </div>\n <div\n className={`${classes[\"controls\"]} ${toDateError || fromDateError ? classes[\"has-error\"] : \"\"}`}\n >\n <div className={classes[\"controls-panel\"]}>\n <DateTimePickerInputSection\n from={from}\n to={to}\n dateInputPlaceholder={dateInputPlaceholder}\n dateFormatError={dateFormatError}\n fromDateText={fromDateText}\n toDateText={toDateText}\n fromDateError={fromDateError}\n toDateError={toDateError}\n setSelectedDate={setSelectedDate}\n setFromDateText={setFromDateText}\n setToDateText={setToDateText}\n setFromDateError={setFromDateError}\n setToDateError={setToDateError}\n />\n </div>\n <div className={`${classes[\"controls-panel\"]} ${classes[\"set-height\"]}`}>\n <DateTimePickerCalendarSection\n previousMonth={previousMonth}\n nextMonth={nextMonth}\n selectedDate={selectedDate}\n disableDateRangePickers={disableDateRangePickers}\n setSelectedDate={setSelectedDate}\n setFromDateText={setFromDateText}\n setFromDateError={setFromDateError}\n setToDateText={setToDateText}\n setToDateError={setToDateError}\n />\n </div>\n </div>\n </div>\n <div className={classes[\"actions\"]}>\n <Button variant=\"text\" onClick={closeDateTimePicker}>\n {cancel}\n </Button>\n <Button onClick={saveDateTimePicker}>{apply}</Button>\n </div>\n </div>\n )}\n </Popover>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAqDI,MAAM,UAAU,GAAG,sB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AS,EAAE,CAAG,EAAA,OAAO,CAAC,gBAAgB,CAAC,CAAA,CAAA,EAAI,OAAO,CAAC,YAAY,CAAC,CAAE,CAAA,EAAA;AACrE,oBAAA,KAAA,CAAA,aAAA,CAAC,6BAA6B,EAC5B,EAAA,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,uBAAuB,EAAE,uBAAuB,EAChD,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,CAAA,CACE,CACF,CACF;AACN,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,EAAA;YAChC,KAAC,CAAA,aAAA,CAAA,MAAM,EAAC,EAAA,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,mBAAmB,EAChD,EAAA,MAAM,CACA;AACT,YAAA,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,OAAO,EAAE,kBAAkB,EAAA,EAAG,KAAK,CAAU,CACjD,CACF,CACP,CACO,EACV;AACJ;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.esm.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".DateTimePicker-module_popover__2CRRN{align-items:flex-start;display:flex;flex-direction:column;min-width:40rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_content-wrapper__yOk2t{display:flex}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_aside__0STn4{border-right:1px solid var(--color-blue-grey100);display:flex;flex-direction:column;width:9.25rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_aside-menu__RVU3-{list-style:none;margin:.5rem 0;padding:0;white-space:nowrap}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_aside-menu-item__sf9Y-{height:2rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_aside-menu-item__sf9Y- button{font-size:.75rem;line-height:1rem;padding:.5rem .75rem;text-align:start}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_controls__mnsPX{display:flex;flex-direction:column;flex-grow:1;gap:2rem;padding:2rem 2rem 0}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_controls__mnsPX.DateTimePicker-module_has-error__l5Ioq{gap:calc(2rem - 15.5681px)}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_controls-panel__XZHbs{display:flex;gap:2rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_controls-panel__XZHbs>*{flex-grow:1}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_controls-panel__XZHbs.DateTimePicker-module_set-height__3vtzW{min-height:17.5rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_actions__oxWZF{border-top:1px solid var(--color-blue-grey100);display:flex;flex-grow:1;gap:1rem;justify-content:space-between;padding:1rem 1.5rem;width:calc(100% - 3rem)}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_input__Dkca1{margin-top:0;max-width:14rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_input__Dkca1 label{font-size:.75rem}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_nav__-gi49{position:absolute}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_next-button__3-CLV{left:27.3125rem;position:absolute;top:0}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_prev-button__653ui{position:absolute;top:0}.DateTimePicker-module_popover__2CRRN .DateTimePicker-module_month-caption__1a8KN{font-size:.75rem;font-weight:500;height:2.5rem;line-height:1rem;margin:0;padding:.75rem 0;text-align:center;width:100%}.DateTimePicker-module_error-message__N-e9F{font-size:.625rem}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkRhdGVUaW1lUGlja2VyLm1vZHVsZS5zY3NzIl0sIm5hbWV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-module_popover__2CRRN","content-wrapper":"DateTimePicker-module_content-wrapper__yOk2t","aside":"DateTimePicker-module_aside__0STn4","aside-menu":"DateTimePicker-module_aside-menu__RVU3-","aside-menu-item":"DateTimePicker-module_aside-menu-item__sf9Y-","controls":"DateTimePicker-module_controls__mnsPX","has-error":"DateTimePicker-module_has-error__l5Ioq","controls-panel":"DateTimePicker-module_controls-panel__XZHbs","set-height":"DateTimePicker-module_set-height__3vtzW","actions":"DateTimePicker-module_actions__oxWZF","input":"DateTimePicker-module_input__Dkca1","nav":"DateTimePicker-module_nav__-gi49","next-button":"DateTimePicker-module_next-button__3-CLV","prev-button":"DateTimePicker-module_prev-button__653ui","month-caption":"DateTimePicker-module_month-caption__1a8KN","error-message":"DateTimePicker-module_error-message__N-e9F"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { classes as default };
|
|
8
|
+
//# sourceMappingURL=DateTimePicker.module.scss.esm.js.map
|
package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePicker.module.scss.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classes from './DateTimePicker.module.scss.esm.js';
|
|
3
|
+
import { DatePicker } from '../../../DatePicker/DatePicker.esm.js';
|
|
4
|
+
import { IconButton } from '../../../Button/IconButton.esm.js';
|
|
5
|
+
import { getMonthName, getYearFromDate, formatInputDate } from './DateTimeService.esm.js';
|
|
6
|
+
import { Icon, Icons } from '../../../Icon/Icon.esm.js';
|
|
7
|
+
import { Typography } from '../../../Typography/Typography.esm.js';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2022 OneWelcome B.V.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const DateTimePickerCalendarSection = ({ previousMonth, nextMonth, selectedDate, disableDateRangePickers, setSelectedDate, setFromDateText, setFromDateError, setToDateError, setToDateText }) => {
|
|
25
|
+
const onDatePickerSelect = (date) => {
|
|
26
|
+
if (date) {
|
|
27
|
+
setSelectedDate(date);
|
|
28
|
+
const fromDate = date.from;
|
|
29
|
+
const toDate = date.to;
|
|
30
|
+
if (fromDate) {
|
|
31
|
+
setFromDateText(formatInputDate(fromDate));
|
|
32
|
+
setFromDateError("");
|
|
33
|
+
}
|
|
34
|
+
if (toDate) {
|
|
35
|
+
setToDateText(formatInputDate(toDate));
|
|
36
|
+
setToDateError("");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (React.createElement(DatePicker, { onSelect: onDatePickerSelect, value: selectedDate, disabled: disableDateRangePickers, mode: "range", components: {
|
|
41
|
+
Nav: ({ onNextClick, onPreviousClick }) => (React.createElement("div", { className: classes["nav"] },
|
|
42
|
+
React.createElement(IconButton, { title: previousMonth, onClick: onPreviousClick, className: classes["prev-button"], disabled: disableDateRangePickers },
|
|
43
|
+
React.createElement(Icon, { size: "0.75rem", icon: Icons.ChevronLeft })),
|
|
44
|
+
React.createElement(IconButton, { title: nextMonth, onClick: onNextClick, className: classes["next-button"], disabled: disableDateRangePickers },
|
|
45
|
+
React.createElement(Icon, { size: "0.75rem", icon: Icons.ChevronRight })))),
|
|
46
|
+
MonthCaption: ({ calendarMonth }) => (React.createElement(Typography, { className: classes["month-caption"], variant: "body" },
|
|
47
|
+
getMonthName(calendarMonth.date),
|
|
48
|
+
" ",
|
|
49
|
+
getYearFromDate(calendarMonth.date)))
|
|
50
|
+
}, numberOfMonths: 2 }));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { DateTimePickerCalendarSection };
|
|
54
|
+
//# sourceMappingURL=DateTimePickerCalendarSection.esm.js.map
|
package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePickerCalendarSection.esm.js","sources":["../../../../../../../src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport classes from \"./DateTimePicker.module.scss\";\nimport { DatePicker } from \"../../../DatePicker/DatePicker\";\nimport { IconButton } from \"../../../Button/IconButton\";\nimport { DateRange } from \"react-day-picker\";\nimport { formatInputDate, getMonthName, getYearFromDate } from \"./DateTimeService\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Typography } from \"../../../Typography/Typography\";\n\ntype Props = {\n previousMonth: string;\n nextMonth: string;\n selectedDate: DateRange | undefined;\n disableDateRangePickers: boolean;\n setSelectedDate: React.Dispatch<React.SetStateAction<DateRange>>;\n setFromDateText: React.Dispatch<React.SetStateAction<string>>;\n setToDateText: React.Dispatch<React.SetStateAction<string>>;\n setFromDateError: React.Dispatch<React.SetStateAction<string>>;\n setToDateError: React.Dispatch<React.SetStateAction<string>>;\n};\n\nexport const DateTimePickerCalendarSection = ({\n previousMonth,\n nextMonth,\n selectedDate,\n disableDateRangePickers,\n setSelectedDate,\n setFromDateText,\n setFromDateError,\n setToDateError,\n setToDateText\n}: Props) => {\n const onDatePickerSelect = (date: Date | DateRange | undefined): void => {\n if (date) {\n setSelectedDate(date as DateRange);\n\n const fromDate = (date as DateRange).from;\n const toDate = (date as DateRange).to;\n\n if (fromDate) {\n setFromDateText(formatInputDate(fromDate));\n setFromDateError(\"\");\n }\n\n if (toDate) {\n setToDateText(formatInputDate(toDate));\n setToDateError(\"\");\n }\n }\n };\n return (\n <DatePicker\n onSelect={onDatePickerSelect}\n value={selectedDate}\n disabled={disableDateRangePickers}\n mode={\"range\"}\n components={{\n Nav: ({ onNextClick, onPreviousClick }) => (\n <div className={classes[\"nav\"]}>\n <IconButton\n title={previousMonth}\n onClick={onPreviousClick}\n className={classes[\"prev-button\"]}\n disabled={disableDateRangePickers}\n >\n <Icon size=\"0.75rem\" icon={Icons.ChevronLeft} />\n </IconButton>\n <IconButton\n title={nextMonth}\n onClick={onNextClick}\n className={classes[\"next-button\"]}\n disabled={disableDateRangePickers}\n >\n <Icon size=\"0.75rem\" icon={Icons.ChevronRight} />\n </IconButton>\n </div>\n ),\n MonthCaption: ({ calendarMonth }) => (\n <Typography className={classes[\"month-caption\"]} variant=\"body\">\n {getMonthName(calendarMonth.date)} {getYearFromDate(calendarMonth.date)}\n </Typography>\n )\n }}\n numberOfMonths={2}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAuBU,MAAA,6BAA6B,GAAG,CAAC,EAC5C,aAAa,EACb,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,aAAa,EACP,KAAI;AACV,IAAA,MAAM,kBAAkB,GAAG,CAAC,IAAkC,KAAU;QACtE,IA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AA,KAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAC,SAAS,EAAC,IAAI,EAAE,KAAK,CAAC,YAAY,EAAI,CAAA,CACtC,CACT,CACP;YACD,YAAY,EAAE,CAAC,EAAE,aAAa,EAAE,MAC9B,KAAA,CAAA,aAAA,CAAC,UAAU,EAAC,EAAA,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,EAAC,MAAM,EAAA;AAC5D,gBAAA,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC;;AAAG,gBAAA,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,CAC5D,CACd;AACF,SAAA,EACD,cAAc,EAAE,CAAC,EAAA,CACjB,EACF;AACJ;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { InputWrapper } from '../../../Form/Wrapper/InputWrapper/InputWrapper.esm.js';
|
|
3
|
+
import classes from './DateTimePicker.module.scss.esm.js';
|
|
4
|
+
import { parse } from 'date-fns';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright 2022 OneWelcome B.V.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const DateTimePickerInputSection = ({ from, to, dateInputPlaceholder, dateFormatError, toDateText, fromDateText, fromDateError, toDateError, setSelectedDate, setFromDateText, setToDateText, setFromDateError, setToDateError }) => {
|
|
22
|
+
const dateParseTemplate = "yyyy-MM-dd HH:mm:ss";
|
|
23
|
+
const parseDate = (date) => {
|
|
24
|
+
const dateText = parse(date, dateParseTemplate, new Date());
|
|
25
|
+
return dateText;
|
|
26
|
+
};
|
|
27
|
+
const validationRegex = /^(\d{4})-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01]) ([0-1]\d|2[0-3]):([0-5]\d):([0-5]\d)$/;
|
|
28
|
+
const validateInput = (text) => validationRegex.test(text);
|
|
29
|
+
const onInputBlur = (setError, setDate) => (e) => {
|
|
30
|
+
if (!validateInput(e.target.value)) {
|
|
31
|
+
setError(dateFormatError);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
setDate(e.target.value);
|
|
35
|
+
setError("");
|
|
36
|
+
};
|
|
37
|
+
const setFromDate = (value) => setSelectedDate(prev => ({ ...prev, from: parseDate(value) }));
|
|
38
|
+
const setToDate = (value) => setSelectedDate(prev => ({ from: prev === null || prev === void 0 ? void 0 : prev.from, to: parseDate(value) }));
|
|
39
|
+
const onFromInputBlur = onInputBlur(setFromDateError, setFromDate);
|
|
40
|
+
const onToInputBlur = onInputBlur(setToDateError, setToDate);
|
|
41
|
+
return (React.createElement(Fragment, null,
|
|
42
|
+
React.createElement(InputWrapper, { label: from, name: "fromDate", error: !!fromDateError, errorMessage: fromDateError, errorMessageProps: { className: classes["error-message"] }, helperProps: {
|
|
43
|
+
style: { fontSize: "0.625rem" }
|
|
44
|
+
}, type: "text", value: fromDateText, onBlur: onFromInputBlur, onChange: e => setFromDateText(e.target.value), inputProps: { style: { height: "2rem" }, placeholder: dateInputPlaceholder }, className: classes["input"] }),
|
|
45
|
+
React.createElement(InputWrapper, { className: classes["input"], inputProps: { style: { height: "2rem" }, placeholder: dateInputPlaceholder }, label: to, value: toDateText, error: !!toDateError, errorMessage: toDateError, errorMessageProps: { className: classes["error-message"] }, helperProps: {
|
|
46
|
+
style: { fontSize: "0.625rem" }
|
|
47
|
+
}, onChange: e => setToDateText(e.target.value), onBlur: onToInputBlur, name: "toDate", type: "text" })));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { DateTimePickerInputSection };
|
|
51
|
+
//# sourceMappingURL=DateTimePickerInputSection.esm.js.map
|
package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimePickerInputSection.esm.js","sources":["../../../../../../../src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment } from \"react\";\nimport { InputWrapper } from \"../../../Form/Wrapper/InputWrapper/InputWrapper\";\nimport classes from \"./DateTimePicker.module.scss\";\nimport { parse } from \"date-fns\";\nimport { DateRange } from \"react-day-picker\";\n\nexport type Props = {\n from: string;\n to: string;\n dateInputPlaceholder: string;\n dateFormatError: string;\n fromDateText: string;\n toDateText: string;\n fromDateError: string;\n toDateError: string;\n setSelectedDate: React.Dispatch<React.SetStateAction<DateRange>>;\n setFromDateText: React.Dispatch<React.SetStateAction<string>>;\n setToDateText: React.Dispatch<React.SetStateAction<string>>;\n setFromDateError: React.Dispatch<React.SetStateAction<string>>;\n setToDateError: React.Dispatch<React.SetStateAction<string>>;\n};\n\nexport const DateTimePickerInputSection = ({\n from,\n to,\n dateInputPlaceholder,\n dateFormatError,\n toDateText,\n fromDateText,\n fromDateError,\n toDateError,\n setSelectedDate,\n setFromDateText,\n setToDateText,\n setFromDateError,\n setToDateError\n}: Props) => {\n const dateParseTemplate = \"yyyy-MM-dd HH:mm:ss\";\n const parseDate = (date: string) => {\n const dateText = parse(date, dateParseTemplate, new Date());\n return dateText;\n };\n\n const validationRegex =\n /^(\\d{4})-(0[1-9]|1[012])-(0[1-9]|[12]\\d|3[01]) ([0-1]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)$/;\n const validateInput = (text: string) => validationRegex.test(text);\n\n const onInputBlur =\n (setError: (value: React.SetStateAction<string>) => void, setDate: (value: string) => void) =>\n (e: React.FocusEvent<HTMLInputElement, Element>) => {\n if (!validateInput(e.target.value)) {\n setError(dateFormatError);\n return;\n }\n\n setDate(e.target.value);\n setError(\"\");\n };\n\n const setFromDate = (value: string) =>\n setSelectedDate(prev => ({ ...prev, from: parseDate(value) }));\n\n const setToDate = (value: string) =>\n setSelectedDate(prev => ({ from: prev?.from, to: parseDate(value) }));\n\n const onFromInputBlur = onInputBlur(setFromDateError, setFromDate);\n const onToInputBlur = onInputBlur(setToDateError, setToDate);\n\n return (\n <Fragment>\n <InputWrapper\n label={from}\n name=\"fromDate\"\n error={!!fromDateError}\n errorMessage={fromDateError}\n errorMessageProps={{ className: classes[\"error-message\"] }}\n helperProps={{\n style: { fontSize: \"0.625rem\" }\n }}\n type=\"text\"\n value={fromDateText}\n onBlur={onFromInputBlur}\n onChange={e => setFromDateText(e.target.value)}\n inputProps={{ style: { height: \"2rem\" }, placeholder: dateInputPlaceholder }}\n className={classes[\"input\"]}\n />\n <InputWrapper\n className={classes[\"input\"]}\n inputProps={{ style: { height: \"2rem\" }, placeholder: dateInputPlaceholder }}\n label={to}\n value={toDateText}\n error={!!toDateError}\n errorMessage={toDateError}\n errorMessageProps={{ className: classes[\"error-message\"] }}\n helperProps={{\n style: { fontSize: \"0.625rem\" }\n }}\n onChange={e => setToDateText(e.target.value)}\n onBlur={onToInputBlur}\n name=\"toDate\"\n type=\"text\"\n />\n </Fragment>\n );\n};\n"],"names":[],"mappings":";;;;;AAAA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