funda-ui 4.7.615 → 4.7.624
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/.gitattributes +2 -0
- package/README.md +116 -2
- package/README_PUBLISH.md +328 -0
- package/lib/cjs/Date/index.js +39 -2
- package/lib/cjs/DynamicFields/index.js +11 -3
- package/lib/esm/Date/index.tsx +47 -2
- package/lib/esm/DynamicFields/index.tsx +9 -4
- package/logo.png +0 -0
- package/package.json +589 -43
- package/preview.png +0 -0
- package/{Date → publish/Date}/index.js +39 -2
- package/{DynamicFields → publish/DynamicFields}/index.js +11 -3
- package/publish/LICENSE +21 -0
- package/publish/README.md +328 -0
- package/publish/lib/cjs/Accordion/index.d.ts +2 -0
- package/publish/lib/cjs/Accordion/index.js +667 -0
- package/publish/lib/cjs/BackToTop/index.d.ts +17 -0
- package/publish/lib/cjs/BackToTop/index.js +904 -0
- package/publish/lib/cjs/CascadingSelect/index.d.ts +80 -0
- package/publish/lib/cjs/CascadingSelect/index.js +3383 -0
- package/publish/lib/cjs/CascadingSelectE2E/index.d.ts +91 -0
- package/publish/lib/cjs/CascadingSelectE2E/index.js +3988 -0
- package/publish/lib/cjs/Chatbox/index.d.ts +101 -0
- package/publish/lib/cjs/Chatbox/index.js +7037 -0
- package/publish/lib/cjs/Checkbox/index.d.ts +28 -0
- package/publish/lib/cjs/Checkbox/index.js +673 -0
- package/publish/lib/cjs/ColorPicker/index.d.ts +27 -0
- package/publish/lib/cjs/ColorPicker/index.js +662 -0
- package/publish/lib/cjs/Date/index.d.ts +70 -0
- package/publish/lib/cjs/Date/index.js +6368 -0
- package/publish/lib/cjs/DigitalClock/index.d.ts +7 -0
- package/publish/lib/cjs/DigitalClock/index.js +402 -0
- package/publish/lib/cjs/DragDropList/index.d.ts +45 -0
- package/publish/lib/cjs/DragDropList/index.js +1586 -0
- package/publish/lib/cjs/DropdownMenu/index.d.ts +38 -0
- package/publish/lib/cjs/DropdownMenu/index.js +1507 -0
- package/publish/lib/cjs/DynamicFields/index.d.ts +40 -0
- package/publish/lib/cjs/DynamicFields/index.js +818 -0
- package/publish/lib/cjs/EventCalendar/index.d.ts +61 -0
- package/publish/lib/cjs/EventCalendar/index.js +3789 -0
- package/publish/lib/cjs/EventCalendarTimeline/index.d.ts +100 -0
- package/publish/lib/cjs/EventCalendarTimeline/index.js +6141 -0
- package/publish/lib/cjs/File/index.d.ts +40 -0
- package/publish/lib/cjs/File/index.js +1751 -0
- package/publish/lib/cjs/HorizontalScrollContent/index.d.ts +14 -0
- package/publish/lib/cjs/HorizontalScrollContent/index.js +426 -0
- package/publish/lib/cjs/Input/index.d.ts +59 -0
- package/publish/lib/cjs/Input/index.js +1486 -0
- package/publish/lib/cjs/LiveSearch/index.d.ts +70 -0
- package/publish/lib/cjs/LiveSearch/index.js +4180 -0
- package/publish/lib/cjs/MasonryLayout/index.d.ts +14 -0
- package/publish/lib/cjs/MasonryLayout/index.js +689 -0
- package/publish/lib/cjs/ModalDialog/index.d.ts +83 -0
- package/publish/lib/cjs/ModalDialog/index.js +1719 -0
- package/publish/lib/cjs/ModeSwitch/index.d.ts +17 -0
- package/publish/lib/cjs/ModeSwitch/index.js +202 -0
- package/publish/lib/cjs/MultilevelDropdownMenu/index.d.ts +20 -0
- package/publish/lib/cjs/MultilevelDropdownMenu/index.js +930 -0
- package/publish/lib/cjs/MultipleCheckboxes/index.d.ts +66 -0
- package/publish/lib/cjs/MultipleCheckboxes/index.js +2337 -0
- package/publish/lib/cjs/MultipleSelect/index.d.ts +65 -0
- package/publish/lib/cjs/MultipleSelect/index.js +4197 -0
- package/publish/lib/cjs/NativeSelect/index.d.ts +37 -0
- package/publish/lib/cjs/NativeSelect/index.js +2052 -0
- package/publish/lib/cjs/NumberInput/index.d.ts +40 -0
- package/publish/lib/cjs/NumberInput/index.js +1191 -0
- package/publish/lib/cjs/Pagination/index.d.ts +51 -0
- package/publish/lib/cjs/Pagination/index.js +612 -0
- package/publish/lib/cjs/Radio/index.d.ts +45 -0
- package/publish/lib/cjs/Radio/index.js +1838 -0
- package/publish/lib/cjs/RangeSlider/index.d.ts +22 -0
- package/publish/lib/cjs/RangeSlider/index.js +2696 -0
- package/publish/lib/cjs/Refresher/index.d.ts +22 -0
- package/publish/lib/cjs/Refresher/index.js +564 -0
- package/publish/lib/cjs/RootPortal/index.d.ts +9 -0
- package/publish/lib/cjs/RootPortal/index.js +148 -0
- package/publish/lib/cjs/ScrollReveal/index.d.ts +21 -0
- package/publish/lib/cjs/ScrollReveal/index.js +401 -0
- package/publish/lib/cjs/Scrollbar/index.d.ts +17 -0
- package/publish/lib/cjs/Scrollbar/index.js +1107 -0
- package/publish/lib/cjs/SearchBar/index.d.ts +41 -0
- package/publish/lib/cjs/SearchBar/index.js +701 -0
- package/publish/lib/cjs/Select/index.d.ts +107 -0
- package/publish/lib/cjs/Select/index.js +6540 -0
- package/publish/lib/cjs/ShowMoreLess/index.d.ts +36 -0
- package/publish/lib/cjs/ShowMoreLess/index.js +387 -0
- package/publish/lib/cjs/SplitterPanel/index.d.ts +20 -0
- package/publish/lib/cjs/SplitterPanel/index.js +800 -0
- package/publish/lib/cjs/Stepper/index.d.ts +26 -0
- package/publish/lib/cjs/Stepper/index.js +568 -0
- package/publish/lib/cjs/Switch/index.d.ts +25 -0
- package/publish/lib/cjs/Switch/index.js +630 -0
- package/publish/lib/cjs/Table/index.d.ts +12 -0
- package/publish/lib/cjs/Table/index.js +2311 -0
- package/publish/lib/cjs/Tabs/index.d.ts +3 -0
- package/publish/lib/cjs/Tabs/index.js +771 -0
- package/publish/lib/cjs/TagInput/index.d.ts +37 -0
- package/publish/lib/cjs/TagInput/index.js +1227 -0
- package/publish/lib/cjs/Textarea/index.d.ts +50 -0
- package/publish/lib/cjs/Textarea/index.js +1795 -0
- package/publish/lib/cjs/Toast/index.d.ts +3 -0
- package/publish/lib/cjs/Toast/index.js +1345 -0
- package/publish/lib/cjs/Tooltip/index.d.ts +38 -0
- package/publish/lib/cjs/Tooltip/index.js +1778 -0
- package/publish/lib/cjs/Tree/index.d.ts +78 -0
- package/publish/lib/cjs/Tree/index.js +2330 -0
- package/publish/lib/cjs/Utils/anim.d.ts +11 -0
- package/publish/lib/cjs/Utils/anim.js +846 -0
- package/publish/lib/cjs/Utils/bodyScrollLock.d.ts +8 -0
- package/publish/lib/cjs/Utils/bodyScrollLock.js +311 -0
- package/publish/lib/cjs/Utils/buffer.d.ts +67 -0
- package/publish/lib/cjs/Utils/buffer.js +343 -0
- package/publish/lib/cjs/Utils/cls.d.ts +15 -0
- package/publish/lib/cjs/Utils/cls.js +124 -0
- package/publish/lib/cjs/Utils/convert.d.ts +25 -0
- package/publish/lib/cjs/Utils/convert.js +109 -0
- package/publish/lib/cjs/Utils/date.d.ts +227 -0
- package/publish/lib/cjs/Utils/date.js +587 -0
- package/publish/lib/cjs/Utils/dom.d.ts +13 -0
- package/publish/lib/cjs/Utils/dom.js +215 -0
- package/publish/lib/cjs/Utils/easing.d.ts +29 -0
- package/publish/lib/cjs/Utils/easing.js +221 -0
- package/publish/lib/cjs/Utils/extract.d.ts +66 -0
- package/publish/lib/cjs/Utils/extract.js +195 -0
- package/publish/lib/cjs/Utils/format-string.d.ts +65 -0
- package/publish/lib/cjs/Utils/format-string.js +167 -0
- package/publish/lib/cjs/Utils/formdata.d.ts +13 -0
- package/publish/lib/cjs/Utils/formdata.js +131 -0
- package/publish/lib/cjs/Utils/getElementProperty.d.ts +52 -0
- package/publish/lib/cjs/Utils/getElementProperty.js +189 -0
- package/publish/lib/cjs/Utils/guid.d.ts +7 -0
- package/publish/lib/cjs/Utils/guid.js +67 -0
- package/publish/lib/cjs/Utils/initDefaultOptions.d.ts +10 -0
- package/publish/lib/cjs/Utils/initDefaultOptions.js +607 -0
- package/publish/lib/cjs/Utils/inputsCalculation.d.ts +28 -0
- package/publish/lib/cjs/Utils/inputsCalculation.js +188 -0
- package/publish/lib/cjs/Utils/math.d.ts +77 -0
- package/publish/lib/cjs/Utils/math.js +305 -0
- package/publish/lib/cjs/Utils/object.d.ts +18 -0
- package/publish/lib/cjs/Utils/object.js +120 -0
- package/publish/lib/cjs/Utils/os.d.ts +2 -0
- package/publish/lib/cjs/Utils/os.js +104 -0
- package/publish/lib/cjs/Utils/performance.d.ts +3 -0
- package/publish/lib/cjs/Utils/performance.js +94 -0
- package/publish/lib/cjs/Utils/sanitize.d.ts +14 -0
- package/publish/lib/cjs/Utils/sanitize.js +87 -0
- package/publish/lib/cjs/Utils/time.d.ts +40 -0
- package/publish/lib/cjs/Utils/time.js +177 -0
- package/publish/lib/cjs/Utils/tree.d.ts +40 -0
- package/publish/lib/cjs/Utils/tree.js +195 -0
- package/publish/lib/cjs/Utils/useAutosizeTextArea.d.ts +10 -0
- package/publish/lib/cjs/Utils/useAutosizeTextArea.js +231 -0
- package/publish/lib/cjs/Utils/useBoundedDrag.d.ts +125 -0
- package/publish/lib/cjs/Utils/useBoundedDrag.js +380 -0
- package/publish/lib/cjs/Utils/useClickOutside.d.ts +33 -0
- package/publish/lib/cjs/Utils/useClickOutside.js +166 -0
- package/publish/lib/cjs/Utils/useComId.d.ts +6 -0
- package/publish/lib/cjs/Utils/useComId.js +114 -0
- package/publish/lib/cjs/Utils/useDebounce.d.ts +20 -0
- package/publish/lib/cjs/Utils/useDebounce.js +138 -0
- package/publish/lib/cjs/Utils/useDragDropPosition.d.ts +166 -0
- package/publish/lib/cjs/Utils/useDragDropPosition.js +453 -0
- package/publish/lib/cjs/Utils/useDraggable.d.ts +62 -0
- package/publish/lib/cjs/Utils/useDraggable.js +348 -0
- package/publish/lib/cjs/Utils/useHistoryTracker.d.ts +166 -0
- package/publish/lib/cjs/Utils/useHistoryTracker.js +649 -0
- package/publish/lib/cjs/Utils/useInterval.d.ts +5 -0
- package/publish/lib/cjs/Utils/useInterval.js +168 -0
- package/publish/lib/cjs/Utils/useIsMobile.d.ts +2 -0
- package/publish/lib/cjs/Utils/useIsMobile.js +232 -0
- package/publish/lib/cjs/Utils/useKeyPress.d.ts +44 -0
- package/publish/lib/cjs/Utils/useKeyPress.js +200 -0
- package/publish/lib/cjs/Utils/useSessionStorageListener.d.ts +2 -0
- package/publish/lib/cjs/Utils/useSessionStorageListener.js +157 -0
- package/publish/lib/cjs/Utils/useStreamController.d.ts +71 -0
- package/publish/lib/cjs/Utils/useStreamController.js +494 -0
- package/publish/lib/cjs/Utils/useThrottle.d.ts +2 -0
- package/publish/lib/cjs/Utils/useThrottle.js +136 -0
- package/publish/lib/cjs/Utils/useWindowScroll.d.ts +12 -0
- package/publish/lib/cjs/Utils/useWindowScroll.js +217 -0
- package/publish/lib/cjs/Utils/validate.d.ts +53 -0
- package/publish/lib/cjs/Utils/validate.js +536 -0
- package/publish/lib/cjs/Utils/viewport.d.ts +7 -0
- package/publish/lib/cjs/Utils/viewport.js +64 -0
- package/publish/lib/cjs/index.d.ts +49 -0
- package/publish/lib/cjs/index.js +50 -0
- package/publish/lib/css/BackToTop/index.css +34 -0
- package/publish/lib/css/CascadingSelect/index.css +245 -0
- package/publish/lib/css/CascadingSelectE2E/index.css +245 -0
- package/publish/lib/css/Chatbox/index.css +774 -0
- package/publish/lib/css/ColorPicker/index.css +58 -0
- package/publish/lib/css/Date/index.css +434 -0
- package/publish/lib/css/DragDropList/index.css +188 -0
- package/publish/lib/css/DropdownMenu/index.css +151 -0
- package/publish/lib/css/EventCalendar/index.css +300 -0
- package/publish/lib/css/EventCalendarTimeline/index.css +694 -0
- package/publish/lib/css/HorizontalScrollContent/index.css +70 -0
- package/publish/lib/css/LiveSearch/index.css +88 -0
- package/publish/lib/css/MultilevelDropdownMenu/index.css +38 -0
- package/publish/lib/css/MultipleSelect/index.css +313 -0
- package/publish/lib/css/RangeSlider/index.css +150 -0
- package/publish/lib/css/Scrollbar/index.css +176 -0
- package/publish/lib/css/Select/index.css +434 -0
- package/publish/lib/css/ShowMoreLess/index.css +23 -0
- package/publish/lib/css/SplitterPanel/index.css +63 -0
- package/publish/lib/css/Stepper/index.css +250 -0
- package/publish/lib/css/Table/index.css +584 -0
- package/publish/lib/css/TagInput/index.css +91 -0
- package/publish/lib/css/Toast/index.css +149 -0
- package/publish/lib/css/Tooltip/index.css +198 -0
- package/publish/lib/css/Tree/index.css +237 -0
- package/publish/lib/esm/Accordion/Accordion.tsx +185 -0
- package/publish/lib/esm/Accordion/AccordionItem.tsx +248 -0
- package/publish/lib/esm/Accordion/index.tsx +2 -0
- package/publish/lib/esm/BackToTop/index.scss +47 -0
- package/publish/lib/esm/BackToTop/index.tsx +177 -0
- package/publish/lib/esm/CascadingSelect/Group.tsx +83 -0
- package/publish/lib/esm/CascadingSelect/index.scss +330 -0
- package/publish/lib/esm/CascadingSelect/index.tsx +1397 -0
- package/publish/lib/esm/CascadingSelectE2E/Group.tsx +87 -0
- package/publish/lib/esm/CascadingSelectE2E/index.scss +333 -0
- package/publish/lib/esm/CascadingSelectE2E/index.tsx +1684 -0
- package/publish/lib/esm/Chatbox/PureLoader.tsx +47 -0
- package/publish/lib/esm/Chatbox/TypingEffect.tsx +56 -0
- package/publish/lib/esm/Chatbox/index.scss +966 -0
- package/publish/lib/esm/Chatbox/index.tsx +1742 -0
- package/publish/lib/esm/Chatbox/utils/func.ts +180 -0
- package/publish/lib/esm/Checkbox/index.tsx +206 -0
- package/publish/lib/esm/ColorPicker/index.scss +91 -0
- package/publish/lib/esm/ColorPicker/index.tsx +204 -0
- package/publish/lib/esm/Date/Calendar.tsx +723 -0
- package/publish/lib/esm/Date/index.scss +567 -0
- package/publish/lib/esm/Date/index.tsx +1797 -0
- package/publish/lib/esm/Date/localization/en_US.js +13 -0
- package/publish/lib/esm/Date/localization/zh_CN.js +12 -0
- package/publish/lib/esm/DigitalClock/index.tsx +74 -0
- package/publish/lib/esm/DragDropList/index.scss +245 -0
- package/publish/lib/esm/DragDropList/index.tsx +504 -0
- package/publish/lib/esm/DropdownMenu/Option.tsx +55 -0
- package/publish/lib/esm/DropdownMenu/index.scss +205 -0
- package/publish/lib/esm/DropdownMenu/index.tsx +378 -0
- package/publish/lib/esm/DynamicFields/index.tsx +409 -0
- package/publish/lib/esm/EventCalendar/index.scss +407 -0
- package/publish/lib/esm/EventCalendar/index.tsx +1005 -0
- package/publish/lib/esm/EventCalendarTimeline/index.scss +926 -0
- package/publish/lib/esm/EventCalendarTimeline/index.tsx +2686 -0
- package/publish/lib/esm/File/index.tsx +477 -0
- package/publish/lib/esm/HorizontalScrollContent/index.scss +87 -0
- package/publish/lib/esm/HorizontalScrollContent/index.tsx +171 -0
- package/publish/lib/esm/Input/index.tsx +641 -0
- package/publish/lib/esm/LiveSearch/index.scss +129 -0
- package/publish/lib/esm/LiveSearch/index.tsx +1058 -0
- package/publish/lib/esm/MasonryLayout/index.tsx +326 -0
- package/publish/lib/esm/ModalDialog/index.tsx +572 -0
- package/publish/lib/esm/ModeSwitch/index.tsx +82 -0
- package/publish/lib/esm/MultilevelDropdownMenu/ItemList.tsx +265 -0
- package/publish/lib/esm/MultilevelDropdownMenu/index.scss +79 -0
- package/publish/lib/esm/MultilevelDropdownMenu/index.tsx +77 -0
- package/publish/lib/esm/MultipleCheckboxes/index.tsx +849 -0
- package/publish/lib/esm/MultipleSelect/index.scss +398 -0
- package/publish/lib/esm/MultipleSelect/index.tsx +769 -0
- package/publish/lib/esm/MultipleSelect/utils/func.ts +63 -0
- package/publish/lib/esm/NativeSelect/index.tsx +396 -0
- package/publish/lib/esm/NativeSelect/utils/func.ts +51 -0
- package/publish/lib/esm/NumberInput/index.tsx +425 -0
- package/publish/lib/esm/Pagination/index.tsx +286 -0
- package/publish/lib/esm/Pagination/pagination-navigators.tsx +60 -0
- package/publish/lib/esm/Radio/index.tsx +694 -0
- package/publish/lib/esm/RangeSlider/index.scss +186 -0
- package/publish/lib/esm/RangeSlider/index.tsx +241 -0
- package/publish/lib/esm/Refresher/index.tsx +121 -0
- package/publish/lib/esm/RootPortal/index.tsx +59 -0
- package/publish/lib/esm/ScrollReveal/index.tsx +148 -0
- package/publish/lib/esm/Scrollbar/index.scss +221 -0
- package/publish/lib/esm/Scrollbar/index.tsx +561 -0
- package/publish/lib/esm/SearchBar/index.tsx +252 -0
- package/publish/lib/esm/Select/index.scss +639 -0
- package/publish/lib/esm/Select/index.tsx +3104 -0
- package/publish/lib/esm/Select/utils/func.ts +98 -0
- package/publish/lib/esm/ShowMoreLess/index.scss +27 -0
- package/publish/lib/esm/ShowMoreLess/index.tsx +145 -0
- package/publish/lib/esm/SplitterPanel/index.scss +82 -0
- package/publish/lib/esm/SplitterPanel/index.tsx +174 -0
- package/publish/lib/esm/Stepper/index.scss +315 -0
- package/publish/lib/esm/Stepper/index.tsx +325 -0
- package/publish/lib/esm/Switch/index.tsx +149 -0
- package/publish/lib/esm/Table/Table.tsx +351 -0
- package/publish/lib/esm/Table/TableBody.tsx +41 -0
- package/publish/lib/esm/Table/TableCaption.tsx +34 -0
- package/publish/lib/esm/Table/TableCell.tsx +126 -0
- package/publish/lib/esm/Table/TableColgroup.tsx +38 -0
- package/publish/lib/esm/Table/TableContext.tsx +26 -0
- package/publish/lib/esm/Table/TableFoot.tsx +28 -0
- package/publish/lib/esm/Table/TableHead.tsx +28 -0
- package/publish/lib/esm/Table/TableRow.tsx +76 -0
- package/publish/lib/esm/Table/index.scss +418 -0
- package/publish/lib/esm/Table/index.tsx +14 -0
- package/publish/lib/esm/Table/utils/DragHandleSprite.tsx +46 -0
- package/publish/lib/esm/Table/utils/SortSprite.tsx +63 -0
- package/publish/lib/esm/Table/utils/TableFilter.tsx +56 -0
- package/publish/lib/esm/Table/utils/ToggleSelection.tsx +255 -0
- package/publish/lib/esm/Table/utils/func.ts +182 -0
- package/publish/lib/esm/Table/utils/hooks/useTableDraggable.tsx +342 -0
- package/publish/lib/esm/Table/utils/hooks/useTableKeyPress.tsx +255 -0
- package/publish/lib/esm/Table/utils/hooks/useTableResponsive.tsx +92 -0
- package/publish/lib/esm/Table/utils/hooks/useTableSort.tsx +187 -0
- package/publish/lib/esm/Tabs/TabList.tsx +50 -0
- package/publish/lib/esm/Tabs/TabPanel.tsx +44 -0
- package/publish/lib/esm/Tabs/Tabs.tsx +282 -0
- package/publish/lib/esm/Tabs/index.tsx +3 -0
- package/publish/lib/esm/TagInput/index.scss +126 -0
- package/publish/lib/esm/TagInput/index.tsx +379 -0
- package/publish/lib/esm/Textarea/index.tsx +621 -0
- package/publish/lib/esm/Toast/Item.tsx +165 -0
- package/publish/lib/esm/Toast/Toast.tsx +391 -0
- package/publish/lib/esm/Toast/ToastContext.tsx +104 -0
- package/publish/lib/esm/Toast/__toast.vanilla.js +422 -0
- package/publish/lib/esm/Toast/index.scss +197 -0
- package/publish/lib/esm/Toast/index.tsx +3 -0
- package/publish/lib/esm/Toast/types.ts +60 -0
- package/publish/lib/esm/Toast/useToast.tsx +72 -0
- package/publish/lib/esm/Tooltip/index.scss +272 -0
- package/publish/lib/esm/Tooltip/index.tsx +416 -0
- package/publish/lib/esm/Tree/TreeList.tsx +600 -0
- package/publish/lib/esm/Tree/index.scss +384 -0
- package/publish/lib/esm/Tree/index.tsx +661 -0
- package/publish/lib/esm/Tree/init-height.tsx +40 -0
- package/publish/lib/esm/Tree/utils/func.ts +15 -0
- package/publish/lib/esm/Utils/hooks/useAutosizeTextArea.tsx +131 -0
- package/publish/lib/esm/Utils/hooks/useBoundedDrag.tsx +301 -0
- package/publish/lib/esm/Utils/hooks/useClickOutside.tsx +69 -0
- package/publish/lib/esm/Utils/hooks/useComId.tsx +13 -0
- package/publish/lib/esm/Utils/hooks/useDebounce.tsx +40 -0
- package/publish/lib/esm/Utils/hooks/useDragDropPosition.tsx +417 -0
- package/publish/lib/esm/Utils/hooks/useDraggable.tsx +265 -0
- package/publish/lib/esm/Utils/hooks/useHistoryTracker.tsx +554 -0
- package/publish/lib/esm/Utils/hooks/useInterval.tsx +74 -0
- package/publish/lib/esm/Utils/hooks/useIsMobile.tsx +139 -0
- package/publish/lib/esm/Utils/hooks/useKeyPress.tsx +104 -0
- package/publish/lib/esm/Utils/hooks/useSessionStorageListener.tsx +45 -0
- package/publish/lib/esm/Utils/hooks/useStreamController.tsx +277 -0
- package/publish/lib/esm/Utils/hooks/useThrottle.tsx +39 -0
- package/publish/lib/esm/Utils/hooks/useWindowScroll.tsx +83 -0
- package/publish/lib/esm/Utils/libs/anim.ts +96 -0
- package/publish/lib/esm/Utils/libs/buffer.ts +262 -0
- package/publish/lib/esm/Utils/libs/cls.ts +64 -0
- package/publish/lib/esm/Utils/libs/convert.ts +59 -0
- package/publish/lib/esm/Utils/libs/date.ts +598 -0
- package/publish/lib/esm/Utils/libs/dom.ts +150 -0
- package/publish/lib/esm/Utils/libs/easing.ts +201 -0
- package/publish/lib/esm/Utils/libs/extract.ts +160 -0
- package/publish/lib/esm/Utils/libs/format-string.ts +116 -0
- package/publish/lib/esm/Utils/libs/formdata.ts +93 -0
- package/publish/lib/esm/Utils/libs/getElementProperty.ts +150 -0
- package/publish/lib/esm/Utils/libs/guid.ts +16 -0
- package/publish/lib/esm/Utils/libs/initDefaultOptions.ts +43 -0
- package/publish/lib/esm/Utils/libs/inputsCalculation.ts +160 -0
- package/publish/lib/esm/Utils/libs/math.ts +276 -0
- package/publish/lib/esm/Utils/libs/object.ts +68 -0
- package/publish/lib/esm/Utils/libs/os.ts +63 -0
- package/publish/lib/esm/Utils/libs/performance.ts +47 -0
- package/publish/lib/esm/Utils/libs/sanitize.ts +55 -0
- package/publish/lib/esm/Utils/libs/time.ts +139 -0
- package/publish/lib/esm/Utils/libs/tree.ts +119 -0
- package/publish/lib/esm/Utils/libs/validate.ts +434 -0
- package/publish/lib/esm/Utils/libs/viewport.ts +20 -0
- package/publish/lib/esm/Utils/plugins/bodyScrollLock.ts +286 -0
- package/publish/lib/esm/index.js +47 -0
- package/publish/package.json +1 -0
- /package/{Accordion → publish/Accordion}/index.d.ts +0 -0
- /package/{Accordion → publish/Accordion}/index.js +0 -0
- /package/{BackToTop → publish/BackToTop}/index.css +0 -0
- /package/{BackToTop → publish/BackToTop}/index.d.ts +0 -0
- /package/{BackToTop → publish/BackToTop}/index.js +0 -0
- /package/{CascadingSelect → publish/CascadingSelect}/index.css +0 -0
- /package/{CascadingSelect → publish/CascadingSelect}/index.d.ts +0 -0
- /package/{CascadingSelect → publish/CascadingSelect}/index.js +0 -0
- /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.css +0 -0
- /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.d.ts +0 -0
- /package/{CascadingSelectE2E → publish/CascadingSelectE2E}/index.js +0 -0
- /package/{Chatbox → publish/Chatbox}/index.css +0 -0
- /package/{Chatbox → publish/Chatbox}/index.d.ts +0 -0
- /package/{Chatbox → publish/Chatbox}/index.js +0 -0
- /package/{Checkbox → publish/Checkbox}/index.d.ts +0 -0
- /package/{Checkbox → publish/Checkbox}/index.js +0 -0
- /package/{ColorPicker → publish/ColorPicker}/index.css +0 -0
- /package/{ColorPicker → publish/ColorPicker}/index.d.ts +0 -0
- /package/{ColorPicker → publish/ColorPicker}/index.js +0 -0
- /package/{Date → publish/Date}/index.css +0 -0
- /package/{Date → publish/Date}/index.d.ts +0 -0
- /package/{DigitalClock → publish/DigitalClock}/index.d.ts +0 -0
- /package/{DigitalClock → publish/DigitalClock}/index.js +0 -0
- /package/{DragDropList → publish/DragDropList}/index.css +0 -0
- /package/{DragDropList → publish/DragDropList}/index.d.ts +0 -0
- /package/{DragDropList → publish/DragDropList}/index.js +0 -0
- /package/{DropdownMenu → publish/DropdownMenu}/index.css +0 -0
- /package/{DropdownMenu → publish/DropdownMenu}/index.d.ts +0 -0
- /package/{DropdownMenu → publish/DropdownMenu}/index.js +0 -0
- /package/{DynamicFields → publish/DynamicFields}/index.d.ts +0 -0
- /package/{EventCalendar → publish/EventCalendar}/index.css +0 -0
- /package/{EventCalendar → publish/EventCalendar}/index.d.ts +0 -0
- /package/{EventCalendar → publish/EventCalendar}/index.js +0 -0
- /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.css +0 -0
- /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.d.ts +0 -0
- /package/{EventCalendarTimeline → publish/EventCalendarTimeline}/index.js +0 -0
- /package/{File → publish/File}/index.d.ts +0 -0
- /package/{File → publish/File}/index.js +0 -0
- /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.css +0 -0
- /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.d.ts +0 -0
- /package/{HorizontalScrollContent → publish/HorizontalScrollContent}/index.js +0 -0
- /package/{Input → publish/Input}/index.d.ts +0 -0
- /package/{Input → publish/Input}/index.js +0 -0
- /package/{LiveSearch → publish/LiveSearch}/index.css +0 -0
- /package/{LiveSearch → publish/LiveSearch}/index.d.ts +0 -0
- /package/{LiveSearch → publish/LiveSearch}/index.js +0 -0
- /package/{MasonryLayout → publish/MasonryLayout}/index.d.ts +0 -0
- /package/{MasonryLayout → publish/MasonryLayout}/index.js +0 -0
- /package/{ModalDialog → publish/ModalDialog}/index.d.ts +0 -0
- /package/{ModalDialog → publish/ModalDialog}/index.js +0 -0
- /package/{ModeSwitch → publish/ModeSwitch}/index.d.ts +0 -0
- /package/{ModeSwitch → publish/ModeSwitch}/index.js +0 -0
- /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.css +0 -0
- /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.d.ts +0 -0
- /package/{MultilevelDropdownMenu → publish/MultilevelDropdownMenu}/index.js +0 -0
- /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.d.ts +0 -0
- /package/{MultipleCheckboxes → publish/MultipleCheckboxes}/index.js +0 -0
- /package/{MultipleSelect → publish/MultipleSelect}/index.css +0 -0
- /package/{MultipleSelect → publish/MultipleSelect}/index.d.ts +0 -0
- /package/{MultipleSelect → publish/MultipleSelect}/index.js +0 -0
- /package/{NativeSelect → publish/NativeSelect}/index.d.ts +0 -0
- /package/{NativeSelect → publish/NativeSelect}/index.js +0 -0
- /package/{NumberInput → publish/NumberInput}/index.d.ts +0 -0
- /package/{NumberInput → publish/NumberInput}/index.js +0 -0
- /package/{Pagination → publish/Pagination}/index.d.ts +0 -0
- /package/{Pagination → publish/Pagination}/index.js +0 -0
- /package/{Radio → publish/Radio}/index.d.ts +0 -0
- /package/{Radio → publish/Radio}/index.js +0 -0
- /package/{RangeSlider → publish/RangeSlider}/index.css +0 -0
- /package/{RangeSlider → publish/RangeSlider}/index.d.ts +0 -0
- /package/{RangeSlider → publish/RangeSlider}/index.js +0 -0
- /package/{Refresher → publish/Refresher}/index.d.ts +0 -0
- /package/{Refresher → publish/Refresher}/index.js +0 -0
- /package/{RootPortal → publish/RootPortal}/index.d.ts +0 -0
- /package/{RootPortal → publish/RootPortal}/index.js +0 -0
- /package/{ScrollReveal → publish/ScrollReveal}/index.d.ts +0 -0
- /package/{ScrollReveal → publish/ScrollReveal}/index.js +0 -0
- /package/{Scrollbar → publish/Scrollbar}/index.css +0 -0
- /package/{Scrollbar → publish/Scrollbar}/index.d.ts +0 -0
- /package/{Scrollbar → publish/Scrollbar}/index.js +0 -0
- /package/{SearchBar → publish/SearchBar}/index.d.ts +0 -0
- /package/{SearchBar → publish/SearchBar}/index.js +0 -0
- /package/{Select → publish/Select}/index.css +0 -0
- /package/{Select → publish/Select}/index.d.ts +0 -0
- /package/{Select → publish/Select}/index.js +0 -0
- /package/{ShowMoreLess → publish/ShowMoreLess}/index.css +0 -0
- /package/{ShowMoreLess → publish/ShowMoreLess}/index.d.ts +0 -0
- /package/{ShowMoreLess → publish/ShowMoreLess}/index.js +0 -0
- /package/{SplitterPanel → publish/SplitterPanel}/index.css +0 -0
- /package/{SplitterPanel → publish/SplitterPanel}/index.d.ts +0 -0
- /package/{SplitterPanel → publish/SplitterPanel}/index.js +0 -0
- /package/{Stepper → publish/Stepper}/index.css +0 -0
- /package/{Stepper → publish/Stepper}/index.d.ts +0 -0
- /package/{Stepper → publish/Stepper}/index.js +0 -0
- /package/{Switch → publish/Switch}/index.d.ts +0 -0
- /package/{Switch → publish/Switch}/index.js +0 -0
- /package/{Table → publish/Table}/index.css +0 -0
- /package/{Table → publish/Table}/index.d.ts +0 -0
- /package/{Table → publish/Table}/index.js +0 -0
- /package/{Tabs → publish/Tabs}/index.d.ts +0 -0
- /package/{Tabs → publish/Tabs}/index.js +0 -0
- /package/{TagInput → publish/TagInput}/index.css +0 -0
- /package/{TagInput → publish/TagInput}/index.d.ts +0 -0
- /package/{TagInput → publish/TagInput}/index.js +0 -0
- /package/{Textarea → publish/Textarea}/index.d.ts +0 -0
- /package/{Textarea → publish/Textarea}/index.js +0 -0
- /package/{Toast → publish/Toast}/index.css +0 -0
- /package/{Toast → publish/Toast}/index.d.ts +0 -0
- /package/{Toast → publish/Toast}/index.js +0 -0
- /package/{Tooltip → publish/Tooltip}/index.css +0 -0
- /package/{Tooltip → publish/Tooltip}/index.d.ts +0 -0
- /package/{Tooltip → publish/Tooltip}/index.js +0 -0
- /package/{Tree → publish/Tree}/index.css +0 -0
- /package/{Tree → publish/Tree}/index.d.ts +0 -0
- /package/{Tree → publish/Tree}/index.js +0 -0
- /package/{Utils → publish/Utils}/anim.d.ts +0 -0
- /package/{Utils → publish/Utils}/anim.js +0 -0
- /package/{Utils → publish/Utils}/bodyScrollLock.d.ts +0 -0
- /package/{Utils → publish/Utils}/bodyScrollLock.js +0 -0
- /package/{Utils → publish/Utils}/buffer.d.ts +0 -0
- /package/{Utils → publish/Utils}/buffer.js +0 -0
- /package/{Utils → publish/Utils}/cls.d.ts +0 -0
- /package/{Utils → publish/Utils}/cls.js +0 -0
- /package/{Utils → publish/Utils}/convert.d.ts +0 -0
- /package/{Utils → publish/Utils}/convert.js +0 -0
- /package/{Utils → publish/Utils}/date.d.ts +0 -0
- /package/{Utils → publish/Utils}/date.js +0 -0
- /package/{Utils → publish/Utils}/dom.d.ts +0 -0
- /package/{Utils → publish/Utils}/dom.js +0 -0
- /package/{Utils → publish/Utils}/easing.d.ts +0 -0
- /package/{Utils → publish/Utils}/easing.js +0 -0
- /package/{Utils → publish/Utils}/extract.d.ts +0 -0
- /package/{Utils → publish/Utils}/extract.js +0 -0
- /package/{Utils → publish/Utils}/format-string.d.ts +0 -0
- /package/{Utils → publish/Utils}/format-string.js +0 -0
- /package/{Utils → publish/Utils}/formdata.d.ts +0 -0
- /package/{Utils → publish/Utils}/formdata.js +0 -0
- /package/{Utils → publish/Utils}/getElementProperty.d.ts +0 -0
- /package/{Utils → publish/Utils}/getElementProperty.js +0 -0
- /package/{Utils → publish/Utils}/guid.d.ts +0 -0
- /package/{Utils → publish/Utils}/guid.js +0 -0
- /package/{Utils → publish/Utils}/initDefaultOptions.d.ts +0 -0
- /package/{Utils → publish/Utils}/initDefaultOptions.js +0 -0
- /package/{Utils → publish/Utils}/inputsCalculation.d.ts +0 -0
- /package/{Utils → publish/Utils}/inputsCalculation.js +0 -0
- /package/{Utils → publish/Utils}/math.d.ts +0 -0
- /package/{Utils → publish/Utils}/math.js +0 -0
- /package/{Utils → publish/Utils}/object.d.ts +0 -0
- /package/{Utils → publish/Utils}/object.js +0 -0
- /package/{Utils → publish/Utils}/os.d.ts +0 -0
- /package/{Utils → publish/Utils}/os.js +0 -0
- /package/{Utils → publish/Utils}/performance.d.ts +0 -0
- /package/{Utils → publish/Utils}/performance.js +0 -0
- /package/{Utils → publish/Utils}/sanitize.d.ts +0 -0
- /package/{Utils → publish/Utils}/sanitize.js +0 -0
- /package/{Utils → publish/Utils}/time.d.ts +0 -0
- /package/{Utils → publish/Utils}/time.js +0 -0
- /package/{Utils → publish/Utils}/tree.d.ts +0 -0
- /package/{Utils → publish/Utils}/tree.js +0 -0
- /package/{Utils → publish/Utils}/useAutosizeTextArea.d.ts +0 -0
- /package/{Utils → publish/Utils}/useAutosizeTextArea.js +0 -0
- /package/{Utils → publish/Utils}/useBoundedDrag.d.ts +0 -0
- /package/{Utils → publish/Utils}/useBoundedDrag.js +0 -0
- /package/{Utils → publish/Utils}/useClickOutside.d.ts +0 -0
- /package/{Utils → publish/Utils}/useClickOutside.js +0 -0
- /package/{Utils → publish/Utils}/useComId.d.ts +0 -0
- /package/{Utils → publish/Utils}/useComId.js +0 -0
- /package/{Utils → publish/Utils}/useDebounce.d.ts +0 -0
- /package/{Utils → publish/Utils}/useDebounce.js +0 -0
- /package/{Utils → publish/Utils}/useDragDropPosition.d.ts +0 -0
- /package/{Utils → publish/Utils}/useDragDropPosition.js +0 -0
- /package/{Utils → publish/Utils}/useDraggable.d.ts +0 -0
- /package/{Utils → publish/Utils}/useDraggable.js +0 -0
- /package/{Utils → publish/Utils}/useHistoryTracker.d.ts +0 -0
- /package/{Utils → publish/Utils}/useHistoryTracker.js +0 -0
- /package/{Utils → publish/Utils}/useInterval.d.ts +0 -0
- /package/{Utils → publish/Utils}/useInterval.js +0 -0
- /package/{Utils → publish/Utils}/useIsMobile.d.ts +0 -0
- /package/{Utils → publish/Utils}/useIsMobile.js +0 -0
- /package/{Utils → publish/Utils}/useKeyPress.d.ts +0 -0
- /package/{Utils → publish/Utils}/useKeyPress.js +0 -0
- /package/{Utils → publish/Utils}/useSessionStorageListener.d.ts +0 -0
- /package/{Utils → publish/Utils}/useSessionStorageListener.js +0 -0
- /package/{Utils → publish/Utils}/useStreamController.d.ts +0 -0
- /package/{Utils → publish/Utils}/useStreamController.js +0 -0
- /package/{Utils → publish/Utils}/useThrottle.d.ts +0 -0
- /package/{Utils → publish/Utils}/useThrottle.js +0 -0
- /package/{Utils → publish/Utils}/useWindowScroll.d.ts +0 -0
- /package/{Utils → publish/Utils}/useWindowScroll.js +0 -0
- /package/{Utils → publish/Utils}/validate.d.ts +0 -0
- /package/{Utils → publish/Utils}/validate.js +0 -0
- /package/{Utils → publish/Utils}/viewport.d.ts +0 -0
- /package/{Utils → publish/Utils}/viewport.js +0 -0
- /package/{all.d.ts → publish/all.d.ts} +0 -0
- /package/{all.js → publish/all.js} +0 -0
|
@@ -0,0 +1,1797 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, forwardRef, KeyboardEvent, ChangeEvent, FocusEvent, useImperativeHandle } from 'react';
|
|
2
|
+
|
|
3
|
+
import Input from 'funda-input';
|
|
4
|
+
import RootPortal from 'funda-root-portal';
|
|
5
|
+
|
|
6
|
+
import useComId from 'funda-utils/dist/cjs/useComId';
|
|
7
|
+
import {
|
|
8
|
+
padZero,
|
|
9
|
+
dateFormat,
|
|
10
|
+
isTimeString,
|
|
11
|
+
getNow,
|
|
12
|
+
isValidDate,
|
|
13
|
+
isValidHours,
|
|
14
|
+
isValidMinutesAndSeconds,
|
|
15
|
+
isValidYear,
|
|
16
|
+
isValidMonth,
|
|
17
|
+
isValidDay,
|
|
18
|
+
getCurrentYear,
|
|
19
|
+
getCurrentMonth,
|
|
20
|
+
getCurrentDay,
|
|
21
|
+
getLastDayInMonth
|
|
22
|
+
} from 'funda-utils/dist/cjs/date';
|
|
23
|
+
import useWindowScroll from 'funda-utils/dist/cjs/useWindowScroll';
|
|
24
|
+
import useClickOutside from 'funda-utils/dist/cjs/useClickOutside';
|
|
25
|
+
import {
|
|
26
|
+
getAbsolutePositionOfStage
|
|
27
|
+
} from 'funda-utils/dist/cjs/getElementProperty';
|
|
28
|
+
import { isNumeric } from 'funda-utils/dist/cjs/math';
|
|
29
|
+
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
import Calendar from './Calendar';
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// Localization
|
|
37
|
+
import i18n__en_US from './localization/en_US';
|
|
38
|
+
import i18n__zh_CN from './localization/zh_CN';
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export type DateProps = {
|
|
45
|
+
contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
|
|
46
|
+
popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
|
|
47
|
+
depth?: number;
|
|
48
|
+
popupClassName?: string;
|
|
49
|
+
triggerClassName?: string;
|
|
50
|
+
wrapperClassName?: string;
|
|
51
|
+
controlClassName?: string;
|
|
52
|
+
controlGroupWrapperClassName?: string;
|
|
53
|
+
controlGroupTextClassName?: string;
|
|
54
|
+
enableEntireAreaPopup?: boolean;
|
|
55
|
+
delimiter?: string;
|
|
56
|
+
hideClearButton?: boolean;
|
|
57
|
+
showToolsWhenHover?: boolean;
|
|
58
|
+
offset?: number;
|
|
59
|
+
exceededSidePosOffset?: number;
|
|
60
|
+
localization?: 'en_US' | 'zh_CN';
|
|
61
|
+
type?: 'date' | 'datetime-local' | 'time';
|
|
62
|
+
onlyTime?: boolean;
|
|
63
|
+
truncateSeconds?: boolean;
|
|
64
|
+
valueUseSlash?: boolean;
|
|
65
|
+
defaultValue?: string;
|
|
66
|
+
value?: string;
|
|
67
|
+
clickInitValue?: string;
|
|
68
|
+
min?: string;
|
|
69
|
+
max?: string;
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
label?: React.ReactNode | string;
|
|
72
|
+
units?: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
alt?: any;
|
|
75
|
+
disabled?: any;
|
|
76
|
+
requiredLabel?: React.ReactNode | string;
|
|
77
|
+
required?: any;
|
|
78
|
+
readOnly?: any;
|
|
79
|
+
iconLeft?: React.ReactNode | string;
|
|
80
|
+
iconRight?: React.ReactNode | string;
|
|
81
|
+
|
|
82
|
+
/** -- */
|
|
83
|
+
id?: string;
|
|
84
|
+
style?: React.CSSProperties;
|
|
85
|
+
autoComplete?: string;
|
|
86
|
+
tabIndex?: number;
|
|
87
|
+
[key: `data-${string}`]: string | undefined;
|
|
88
|
+
onLoad?: (e: any, data: any, allSplittingInputs: any[]) => void;
|
|
89
|
+
onChange?: (e: any, data: any, isValidDate: boolean, allSplittingInputs: any[]) => void;
|
|
90
|
+
onBlur?: (e: any, allSplittingInputs: any[]) => void;
|
|
91
|
+
onFocus?: (e: any, allSplittingInputs: any[]) => void;
|
|
92
|
+
onPressEnter?: (e: any, allSplittingInputs: any[]) => void;
|
|
93
|
+
onOpenPopup?: (allSplittingInputs: any[]) => void;
|
|
94
|
+
onClosePopup?: (allSplittingInputs: any[]) => void;
|
|
95
|
+
//
|
|
96
|
+
onChangeDate?: (currentData: any) => void;
|
|
97
|
+
onChangeMonth?: (currentData: any) => void;
|
|
98
|
+
onChangeYear?: (currentData: any) => void;
|
|
99
|
+
onChangeToday?: (currentData: any) => void;
|
|
100
|
+
onChangeHours?: (currentData: any) => void;
|
|
101
|
+
onChangeMinutes?: (currentData: any) => void;
|
|
102
|
+
onChangeSeconds?: (currentData: any) => void;
|
|
103
|
+
onClear?: (currentData: any) => void;
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
// calendar
|
|
108
|
+
langHoursTitle?: string;
|
|
109
|
+
langMinutesTitle?: string;
|
|
110
|
+
langSecondsTitle?: string;
|
|
111
|
+
langWeek?: string[];
|
|
112
|
+
langWeekFull?: string[];
|
|
113
|
+
langMonths?: string[];
|
|
114
|
+
langMonthsFull?: string[];
|
|
115
|
+
langToday?: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const Date = forwardRef((props: DateProps, externalRef: any) => {
|
|
120
|
+
const {
|
|
121
|
+
contentRef,
|
|
122
|
+
popupRef,
|
|
123
|
+
depth,
|
|
124
|
+
triggerClassName,
|
|
125
|
+
popupClassName,
|
|
126
|
+
wrapperClassName,
|
|
127
|
+
controlClassName,
|
|
128
|
+
controlGroupWrapperClassName,
|
|
129
|
+
controlGroupTextClassName,
|
|
130
|
+
enableEntireAreaPopup,
|
|
131
|
+
delimiter,
|
|
132
|
+
hideClearButton,
|
|
133
|
+
showToolsWhenHover,
|
|
134
|
+
offset,
|
|
135
|
+
exceededSidePosOffset,
|
|
136
|
+
localization,
|
|
137
|
+
type,
|
|
138
|
+
onlyTime,
|
|
139
|
+
truncateSeconds,
|
|
140
|
+
valueUseSlash,
|
|
141
|
+
disabled,
|
|
142
|
+
requiredLabel,
|
|
143
|
+
required,
|
|
144
|
+
readOnly,
|
|
145
|
+
defaultValue,
|
|
146
|
+
value,
|
|
147
|
+
clickInitValue,
|
|
148
|
+
min,
|
|
149
|
+
max,
|
|
150
|
+
placeholder,
|
|
151
|
+
label,
|
|
152
|
+
units,
|
|
153
|
+
name,
|
|
154
|
+
alt,
|
|
155
|
+
id,
|
|
156
|
+
iconLeft,
|
|
157
|
+
iconRight,
|
|
158
|
+
autoComplete,
|
|
159
|
+
style,
|
|
160
|
+
tabIndex,
|
|
161
|
+
onLoad,
|
|
162
|
+
onChange,
|
|
163
|
+
onBlur,
|
|
164
|
+
onFocus,
|
|
165
|
+
onPressEnter,
|
|
166
|
+
onOpenPopup,
|
|
167
|
+
onClosePopup,
|
|
168
|
+
|
|
169
|
+
//
|
|
170
|
+
onChangeDate,
|
|
171
|
+
onChangeMonth,
|
|
172
|
+
onChangeYear,
|
|
173
|
+
onChangeToday,
|
|
174
|
+
onChangeHours,
|
|
175
|
+
onChangeMinutes,
|
|
176
|
+
onChangeSeconds,
|
|
177
|
+
onClear,
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
//calendar
|
|
181
|
+
langHoursTitle,
|
|
182
|
+
langMinutesTitle,
|
|
183
|
+
langSecondsTitle,
|
|
184
|
+
langWeek,
|
|
185
|
+
langWeekFull,
|
|
186
|
+
langMonths,
|
|
187
|
+
langMonthsFull,
|
|
188
|
+
langToday,
|
|
189
|
+
|
|
190
|
+
//
|
|
191
|
+
...attributes
|
|
192
|
+
} = props;
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
const DEPTH = depth || 1055; // the default value same as bootstrap
|
|
196
|
+
const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
const defaultValueIsEmpty = (s: any) => {
|
|
200
|
+
return typeof s === 'undefined' || s === null || s === 'null' || s === '';
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const propExist = (p: any) => {
|
|
204
|
+
return typeof p !== 'undefined' && p !== null && p !== '';
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
// Localization
|
|
210
|
+
let _langHoursTitle = langHoursTitle || 'Hours';
|
|
211
|
+
let _langMinutesTitle = langMinutesTitle || 'Minutes';
|
|
212
|
+
let _langSecondsTitle= langSecondsTitle || 'Seconds';
|
|
213
|
+
let _langWeek = langWeek;
|
|
214
|
+
let _langWeekFull = langWeekFull;
|
|
215
|
+
let _langMonths = langMonths;
|
|
216
|
+
let _langMonthsFull = langMonthsFull;
|
|
217
|
+
let _langToday = langToday;
|
|
218
|
+
|
|
219
|
+
//
|
|
220
|
+
const DELIMITER_DATE = delimiter || '/';
|
|
221
|
+
const DELIMITER_TIME = ':';
|
|
222
|
+
const SHOW_TOOLS_ENABLED = !(typeof showToolsWhenHover === 'undefined' || showToolsWhenHover === false);
|
|
223
|
+
const HIDE_CLEAR_BTN_ENABLED = !(typeof hideClearButton === 'undefined' || hideClearButton === false);
|
|
224
|
+
|
|
225
|
+
//
|
|
226
|
+
const COM_HAS_DATE = typeof onlyTime === 'undefined' || onlyTime === false;
|
|
227
|
+
const COM_HAS_TIME = type === 'datetime-local' || type === 'time';
|
|
228
|
+
const COM_NO_SECONDS = typeof truncateSeconds === 'undefined' || truncateSeconds === false;
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
// placeholder
|
|
233
|
+
let datePlaceholder = placeholder || placeholder === '' ? placeholder : 'yyyy/MM/dd HH:mm:ss';
|
|
234
|
+
|
|
235
|
+
if (typeof placeholder === 'undefined') {
|
|
236
|
+
datePlaceholder = `${COM_HAS_DATE ? 'yyyy/MM/dd ' : ''}${COM_HAS_TIME ? `HH:mm${COM_NO_SECONDS ? ':ss' : ''}` : ''}`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (typeof localization === 'string') {
|
|
240
|
+
|
|
241
|
+
switch (localization) {
|
|
242
|
+
case 'en_US':
|
|
243
|
+
_langHoursTitle = i18n__en_US.hoursTitle;
|
|
244
|
+
_langMinutesTitle = i18n__en_US.minutesTitle;
|
|
245
|
+
_langSecondsTitle = i18n__en_US.secondsTitle;
|
|
246
|
+
_langWeek = i18n__en_US.week;
|
|
247
|
+
_langWeekFull = i18n__en_US.weekFull;
|
|
248
|
+
_langMonths = i18n__en_US.months;
|
|
249
|
+
_langMonthsFull = i18n__en_US.monthsFull;
|
|
250
|
+
_langToday = i18n__en_US.today;
|
|
251
|
+
break;
|
|
252
|
+
|
|
253
|
+
case 'zh_CN':
|
|
254
|
+
_langHoursTitle = i18n__zh_CN.hoursTitle;
|
|
255
|
+
_langMinutesTitle = i18n__zh_CN.minutesTitle;
|
|
256
|
+
_langSecondsTitle = i18n__zh_CN.secondsTitle;
|
|
257
|
+
_langWeek = i18n__zh_CN.week;
|
|
258
|
+
_langWeekFull = i18n__zh_CN.weekFull;
|
|
259
|
+
_langMonths = i18n__zh_CN.months;
|
|
260
|
+
_langMonthsFull = i18n__zh_CN.monthsFull;
|
|
261
|
+
_langToday = i18n__zh_CN.today;
|
|
262
|
+
break;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
//
|
|
271
|
+
const POS_OFFSET = Number(offset) || 10;
|
|
272
|
+
const EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
|
|
273
|
+
const uniqueID = useComId();
|
|
274
|
+
const idRes = id || uniqueID;
|
|
275
|
+
const rootRef = useRef<any>(null);
|
|
276
|
+
const modalRef = useRef<any>(null);
|
|
277
|
+
const inputRef = useRef<any>(null);
|
|
278
|
+
const listContentRef = useRef<any>(null);
|
|
279
|
+
|
|
280
|
+
const partedInputYear = useRef<HTMLInputElement | null>(null);
|
|
281
|
+
const partedInputMonth = useRef<HTMLInputElement | null>(null);
|
|
282
|
+
const partedInputDay = useRef<HTMLInputElement | null>(null);
|
|
283
|
+
const partedInputHours = useRef<HTMLInputElement | null>(null);
|
|
284
|
+
const partedInputMinutes = useRef<HTMLInputElement | null>(null);
|
|
285
|
+
const partedInputSeconds = useRef<HTMLInputElement | null>(null);
|
|
286
|
+
|
|
287
|
+
const [dateDefaultValueExist, setDateDefaultValueExist] = useState<boolean>(false);
|
|
288
|
+
const [initSplitClickEvOk, setInitSplitClickEvOk] = useState<boolean>(false);
|
|
289
|
+
const [splitVals, setSplitVals] = useState<any[]>(['0000','00','00','00','00','00']);
|
|
290
|
+
const [changedVal, setChangedVal] = useState<string>(value || '');
|
|
291
|
+
const [isShow, setIsShow] = useState<boolean>(false);
|
|
292
|
+
const [dateVal, setDateVal] = useState<string>('');
|
|
293
|
+
const [timeVal, setTimeVal] = useState<string[]>(['00', '00', '00']);
|
|
294
|
+
|
|
295
|
+
const hoursArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
|
|
296
|
+
const msArr = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'];
|
|
297
|
+
|
|
298
|
+
// blur for popup window
|
|
299
|
+
const popupBlurEnabled = useRef<boolean>(false); // DO NOT USE 'useState()'
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
// effective element movement on keystroke
|
|
303
|
+
const [focusableSplitInputId, setFocusableSplitInputId] = useState<string>(COM_HAS_DATE ? 'el-year' : 'el-hours');
|
|
304
|
+
const [splitInputsIds] = useState<string[]>(['el-year', 'el-month', 'el-day', 'el-hours', 'el-minutes', 'el-seconds']);
|
|
305
|
+
const splitInputs = useRef(new Map<string, HTMLElement>());
|
|
306
|
+
const splitInputsTabIndex = tabIndex || 0;
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
//
|
|
311
|
+
const getAllSplittingInputs = () => {
|
|
312
|
+
return [
|
|
313
|
+
partedInputYear.current,
|
|
314
|
+
partedInputMonth.current,
|
|
315
|
+
partedInputDay.current,
|
|
316
|
+
partedInputHours.current,
|
|
317
|
+
partedInputMinutes.current,
|
|
318
|
+
partedInputSeconds.current
|
|
319
|
+
];
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
const onlyHHmm = (str: string) => {
|
|
323
|
+
// match HH:mm
|
|
324
|
+
const timePattern = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
|
325
|
+
return timePattern.test(str);
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
// exposes the following methods
|
|
330
|
+
useImperativeHandle(
|
|
331
|
+
popupRef,
|
|
332
|
+
() => ({
|
|
333
|
+
close: () => {
|
|
334
|
+
popwinPosHide();
|
|
335
|
+
handleBlur(null);
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
[popupRef],
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
useImperativeHandle(
|
|
342
|
+
contentRef,
|
|
343
|
+
() => ({
|
|
344
|
+
control: () => {
|
|
345
|
+
return getAllSplittingInputs();
|
|
346
|
+
},
|
|
347
|
+
getLatestVal: () => {
|
|
348
|
+
return !dateDefaultValueExist ? `` : valueResConverter(changedVal);
|
|
349
|
+
},
|
|
350
|
+
clear: (cb?: any) => {
|
|
351
|
+
clearAll();
|
|
352
|
+
cb?.();
|
|
353
|
+
|
|
354
|
+
onChange?.(inputRef.current, '', false, getAllSplittingInputs());
|
|
355
|
+
},
|
|
356
|
+
blur: (cb?: any) => {
|
|
357
|
+
getAllSplittingInputs().forEach((el: any) => {
|
|
358
|
+
if (el !== null) el.blur();
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
handleBlur(null);
|
|
362
|
+
cb?.();
|
|
363
|
+
},
|
|
364
|
+
/*
|
|
365
|
+
set('2024-04-18 21:54:09', () => { console.log('callback') }])
|
|
366
|
+
*/
|
|
367
|
+
set: (value: any, cb?: any) => {
|
|
368
|
+
|
|
369
|
+
const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(value, true);
|
|
370
|
+
setDateDefaultValueExist(defaultValueIsEmpty(value) ? false : true);
|
|
371
|
+
initValue(curTargetVal);
|
|
372
|
+
|
|
373
|
+
cb?.();
|
|
374
|
+
|
|
375
|
+
onChange?.(inputRef.current, value, isValidDate(value), getAllSplittingInputs());
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
[contentRef, dateDefaultValueExist, changedVal],
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
// click outside
|
|
383
|
+
useClickOutside({
|
|
384
|
+
enabled: isShow && rootRef.current,
|
|
385
|
+
isOutside: (event: any) => {
|
|
386
|
+
return event.target.closest(`.date2d__wrapper`) === null && event.target.closest(`.date2d-cal__wrapper`) === null;
|
|
387
|
+
},
|
|
388
|
+
handle: (event: any) => {
|
|
389
|
+
popwinPosHide();
|
|
390
|
+
|
|
391
|
+
//remove focus style
|
|
392
|
+
rootRef.current?.classList.remove('focus');
|
|
393
|
+
|
|
394
|
+
// move out the popup window
|
|
395
|
+
if (popupBlurEnabled.current) {
|
|
396
|
+
onBlur?.(inputRef.current, getAllSplittingInputs());
|
|
397
|
+
popupBlurEnabled.current = false;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}, [isShow, rootRef]);
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
// Add function to the element that should be used as the scrollable area.
|
|
406
|
+
// const [scrollData, windowScrollUpdate] = useWindowScroll({
|
|
407
|
+
// performance: ['debounce', 50], // "['debounce', 500]" or "['throttle', 500]"
|
|
408
|
+
// handle: (scrollData: any) => {
|
|
409
|
+
// popwinPosHide();
|
|
410
|
+
// }
|
|
411
|
+
// });
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
const getFullTimeData = (v: Date | String, padZeroEnabled: boolean = true) => {
|
|
416
|
+
|
|
417
|
+
if (typeof v === 'string' && !isValidDate(v)) {
|
|
418
|
+
return {
|
|
419
|
+
res: '0000-00-00 00:00:00',
|
|
420
|
+
resNoSeconds: '0000-00-00 00:00',
|
|
421
|
+
date: `0000-00-00`,
|
|
422
|
+
year: `0000`,
|
|
423
|
+
month: `00`,
|
|
424
|
+
day: `00`,
|
|
425
|
+
hours: `00`,
|
|
426
|
+
minutes: `00`,
|
|
427
|
+
seconds: `00`
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const date: any = dateFormat(v as any);
|
|
432
|
+
|
|
433
|
+
const year = date.getFullYear();
|
|
434
|
+
const month = padZero(date.getMonth() + 1, padZeroEnabled);
|
|
435
|
+
const day = padZero(date.getDate(), padZeroEnabled);
|
|
436
|
+
const hours = padZero(date.getHours(), padZeroEnabled);
|
|
437
|
+
const minutes = padZero(date.getMinutes(), padZeroEnabled);
|
|
438
|
+
const seconds = padZero(date.getSeconds(), padZeroEnabled);
|
|
439
|
+
const res = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
440
|
+
const res2 = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
441
|
+
|
|
442
|
+
return {
|
|
443
|
+
res: res,
|
|
444
|
+
resNoSeconds: res2,
|
|
445
|
+
date: `${year}-${month}-${day}`,
|
|
446
|
+
year: `${year}`,
|
|
447
|
+
month: `${month}`,
|
|
448
|
+
day: `${day}`,
|
|
449
|
+
hours: `${hours}`,
|
|
450
|
+
minutes: `${minutes}`,
|
|
451
|
+
seconds: `${seconds}`
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
//
|
|
457
|
+
const MIN: any = typeof min !== 'undefined' && min !== '' && min !== null && isValidDate(min) ? getFullTimeData(min) : '';
|
|
458
|
+
const MAX: any = typeof max !== 'undefined' && max !== '' && max !== null && isValidDate(max) ? getFullTimeData(max) : '';
|
|
459
|
+
|
|
460
|
+
const getActualDefaultValue = (v?: any, init: boolean = false) => {
|
|
461
|
+
const _v = getFullTimeData(getNow());
|
|
462
|
+
const _nowVal: any = `${_v.date} ${_v.hours}:${_v.minutes}:${_v.seconds}`;
|
|
463
|
+
|
|
464
|
+
// expected default value (only HH:mm:ss)
|
|
465
|
+
const _expectedValue = isTimeString(v) || onlyHHmm(v) ? `${_v.date} ${onlyHHmm(v) ? v + ':00' : v}` : v;
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
if (!init) setInitSplitClickEvOk(true);
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
if (!initSplitClickEvOk) {
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
let noTargetVal = typeof clickInitValue === 'undefined' || clickInitValue === null || clickInitValue === 'null' || clickInitValue === '';
|
|
475
|
+
if (!defaultValueIsEmpty(v)) {
|
|
476
|
+
noTargetVal = true;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
//
|
|
480
|
+
let targetVal: any = noTargetVal ? (defaultValueIsEmpty(v) ? _nowVal : _expectedValue) : clickInitValue;
|
|
481
|
+
|
|
482
|
+
if (typeof v === 'undefined') {
|
|
483
|
+
targetVal = noTargetVal ? _nowVal : clickInitValue;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
//
|
|
487
|
+
return [false, noTargetVal, targetVal];
|
|
488
|
+
} else {
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
let targetVal: any = defaultValueIsEmpty(v) ? _nowVal : _expectedValue;
|
|
492
|
+
|
|
493
|
+
if (typeof v === 'undefined') {
|
|
494
|
+
targetVal = _nowVal;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return [true, true, targetVal];
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
function popwinPosInit() {
|
|
507
|
+
|
|
508
|
+
if (modalRef.current === null || listContentRef.current === null || inputRef.current === null) return;
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
// update modal position
|
|
512
|
+
const _modalRef: any = modalRef.current;
|
|
513
|
+
const _triggerRef: any = inputRef.current;
|
|
514
|
+
|
|
515
|
+
// console.log(getAbsolutePositionOfStage(_triggerRef));
|
|
516
|
+
|
|
517
|
+
if (_modalRef === null) return;
|
|
518
|
+
|
|
519
|
+
const { x, y, width, height } = getAbsolutePositionOfStage(_triggerRef);
|
|
520
|
+
const _triggerBox = _triggerRef.getBoundingClientRect();
|
|
521
|
+
let targetPos = '';
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
// STEP 1:
|
|
525
|
+
//-----------
|
|
526
|
+
// Detect position
|
|
527
|
+
if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
|
|
528
|
+
targetPos = 'bottom';
|
|
529
|
+
} else {
|
|
530
|
+
targetPos = 'top';
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// STEP 2:
|
|
534
|
+
//-----------
|
|
535
|
+
// Adjust position
|
|
536
|
+
if (targetPos === 'top') {
|
|
537
|
+
_modalRef.style.left = x + 'px';
|
|
538
|
+
//_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
|
|
539
|
+
_modalRef.style.marginTop = 0;
|
|
540
|
+
_modalRef.style.top = 'auto';
|
|
541
|
+
_modalRef.style.bottom = (window.innerHeight - _triggerBox.top) + POS_OFFSET + 2 + 'px';
|
|
542
|
+
_modalRef.style.setProperty('position', 'fixed', 'important');
|
|
543
|
+
_modalRef.classList.add('pos-top');
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (targetPos === 'bottom') {
|
|
547
|
+
_modalRef.style.marginTop = 0;
|
|
548
|
+
_modalRef.style.left = x + 'px';
|
|
549
|
+
_modalRef.style.bottom = 'auto';
|
|
550
|
+
_modalRef.style.top = y + height + POS_OFFSET + 'px';
|
|
551
|
+
_modalRef.style.setProperty('position', 'absolute', 'important');
|
|
552
|
+
_modalRef.classList.remove('pos-top');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// STEP 3:
|
|
556
|
+
//-----------
|
|
557
|
+
// Determine whether it exceeds the far right or left side of the screen
|
|
558
|
+
// Determine whether it exceeds the max height of the popup
|
|
559
|
+
const _modalContent = _modalRef;
|
|
560
|
+
const _modalBox = _modalContent.getBoundingClientRect();
|
|
561
|
+
if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
|
|
562
|
+
|
|
563
|
+
// 10 pixels is used to account for some bias in mobile devices
|
|
564
|
+
if ((_modalBox.right + 10) > window.innerWidth) {
|
|
565
|
+
const _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
|
|
566
|
+
_modalContent.dataset.offset = _modalOffsetPosition;
|
|
567
|
+
_modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
|
|
568
|
+
// console.log('_modalPosition: ', _modalOffsetPosition)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
if ((_modalBox.left - 10) < 0) {
|
|
573
|
+
const _modalOffsetPosition = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
|
|
574
|
+
_modalContent.dataset.offset = _modalOffsetPosition;
|
|
575
|
+
_modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
|
|
576
|
+
// console.log('_modalPosition: ', _modalOffsetPosition)
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (window.innerHeight - _modalBox.bottom < 0) {
|
|
580
|
+
_modalRef.style.marginTop = `${window.innerHeight - _modalBox.bottom}px`;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function popwinPosHide() {
|
|
588
|
+
setIsShow(false);
|
|
589
|
+
onClosePopup?.(getAllSplittingInputs());
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
function handleShow() {
|
|
596
|
+
setIsShow(true);
|
|
597
|
+
|
|
598
|
+
setTimeout(() => {
|
|
599
|
+
popwinPosInit();
|
|
600
|
+
|
|
601
|
+
onOpenPopup?.(getAllSplittingInputs());
|
|
602
|
+
|
|
603
|
+
}, 0);
|
|
604
|
+
|
|
605
|
+
// focus
|
|
606
|
+
handleFocus(null);
|
|
607
|
+
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
function handleFocus(event: FocusEvent<HTMLElement> | null) {
|
|
612
|
+
rootRef.current?.classList.add('focus');
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
//
|
|
616
|
+
onFocus?.(inputRef.current, getAllSplittingInputs());
|
|
617
|
+
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function handleChange(e: React.ChangeEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement> | null, isComposition: boolean, el: HTMLInputElement, value: string) {
|
|
621
|
+
|
|
622
|
+
onChange?.(inputRef.current, value, isValidDate(value), getAllSplittingInputs());
|
|
623
|
+
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
function handleBlur(event: FocusEvent<HTMLElement> | null) {
|
|
628
|
+
|
|
629
|
+
//remove focus style
|
|
630
|
+
rootRef.current?.classList.remove('focus');
|
|
631
|
+
|
|
632
|
+
//
|
|
633
|
+
onBlur?.(inputRef.current, getAllSplittingInputs());
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
function handleInitSplitClickEv(e: any) {
|
|
638
|
+
e.preventDefault();
|
|
639
|
+
e.stopPropagation(); // Avoid triggering other inputs
|
|
640
|
+
|
|
641
|
+
// If disabled or readOnly, the operations are not performed
|
|
642
|
+
if (disabled || readOnly) {
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
e.target.select();
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
resetDefauleValueExist();
|
|
650
|
+
|
|
651
|
+
// Automatically pop up a pop-up window
|
|
652
|
+
if (enableEntireAreaPopup) {
|
|
653
|
+
handleShow();
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// If there is no valid default value in the input field,
|
|
657
|
+
// onChange should be triggered only after the resetDefauleValueExist() function is processed
|
|
658
|
+
if (!dateDefaultValueExist) {
|
|
659
|
+
const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
|
|
660
|
+
const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
|
|
661
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async function handleKeyPressed(event: KeyboardEvent<HTMLDivElement>) {
|
|
668
|
+
const key = event.code;
|
|
669
|
+
|
|
670
|
+
if (key === 'Enter' || key === 'NumpadEnter') {
|
|
671
|
+
event.preventDefault();
|
|
672
|
+
|
|
673
|
+
getAllSplittingInputs().forEach((el: any) => {
|
|
674
|
+
if (el !== null) el.blur();
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
handleBlur(null);
|
|
678
|
+
|
|
679
|
+
//
|
|
680
|
+
onPressEnter?.(inputRef.current, getAllSplittingInputs());
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
async function handleKeyPressedForSplitInputs(event: KeyboardEvent<HTMLDivElement>) {
|
|
685
|
+
const key = event.code;
|
|
686
|
+
const btnMark = (event.target as any).dataset.mark;
|
|
687
|
+
const isNumLockOn = event.getModifierState && event.getModifierState('NumLock');
|
|
688
|
+
|
|
689
|
+
// Check for both regular arrow keys and numpad arrow keys
|
|
690
|
+
// Numpad2/4/6/8 trigger direction is allowed only when NumLock is off
|
|
691
|
+
const isLeftArrow = key === 'ArrowLeft' || (key === 'Numpad4' && !isNumLockOn);
|
|
692
|
+
const isRightArrow = key === 'ArrowRight' || (key === 'Numpad6' && !isNumLockOn);
|
|
693
|
+
|
|
694
|
+
const move = (direction: 'left' | 'right') => {
|
|
695
|
+
const currentIndex = splitInputsIds.findIndex((s: string) => s === btnMark);
|
|
696
|
+
const nextIndex = direction === 'left'
|
|
697
|
+
? currentIndex === 0 ? splitInputsIds.length - 1 : currentIndex - 1
|
|
698
|
+
: currentIndex === splitInputsIds.length - 1 ? 0 : currentIndex + 1;
|
|
699
|
+
|
|
700
|
+
const nextOption = splitInputsIds.at(nextIndex);
|
|
701
|
+
if (nextOption) {
|
|
702
|
+
setTimeout(() => {
|
|
703
|
+
(splitInputs.current.get(nextOption) as HTMLInputElement)?.select();
|
|
704
|
+
}, 0);
|
|
705
|
+
setFocusableSplitInputId(nextOption);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
if (isLeftArrow) {
|
|
710
|
+
move('left');
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (isRightArrow) {
|
|
714
|
+
move('right');
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
function clearAll() {
|
|
720
|
+
setDateDefaultValueExist(false);
|
|
721
|
+
onChange?.(inputRef.current, '', false, getAllSplittingInputs());
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
function resetDefauleValueExist() {
|
|
727
|
+
// Does the current input box have a "valid default value"?
|
|
728
|
+
if (!dateDefaultValueExist) setDateDefaultValueExist(true);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
function resetPopupBlurStatus() {
|
|
732
|
+
if (!popupBlurEnabled.current) popupBlurEnabled.current = true;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
function valueResConverter(inputData: any) {
|
|
737
|
+
const v = isValidDate(inputData) ? inputData : `${getFullTimeData(getNow()).date} ${inputData}`;
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
const _onlyTime = `${getFullTimeData(v).hours}:${getFullTimeData(v).minutes}${truncateSeconds ? `` : `:${getFullTimeData(v).seconds}`}`;
|
|
741
|
+
const _date = `${getFullTimeData(v).year}${valueUseSlash ? `/` : '-'}${getFullTimeData(v).month}${valueUseSlash ? `/` : '-'}${getFullTimeData(v).day}`;
|
|
742
|
+
const _time = COM_HAS_TIME ? ` ${getFullTimeData(v).hours}:${getFullTimeData(v).minutes}${truncateSeconds ? `` : `:${getFullTimeData(v).seconds}`}` : '';
|
|
743
|
+
|
|
744
|
+
return onlyTime ? _onlyTime : `${_date}${_time}`;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
function checkDisabledSeconds(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string, curMinutes: number | string, curSeconds: number | string) {
|
|
750
|
+
let res: boolean = false;
|
|
751
|
+
|
|
752
|
+
// maximum
|
|
753
|
+
if (MAX !== '') {
|
|
754
|
+
if (Number(curYear) > Number(MAX.year)) {
|
|
755
|
+
res = true;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
|
|
759
|
+
res = true;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
|
|
763
|
+
res = true;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
|
|
768
|
+
res = true;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) > Number(MAX.minutes) ) {
|
|
772
|
+
res = true;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) === Number(MAX.minutes) && Number(curSeconds) > Number(MAX.seconds) ) {
|
|
776
|
+
res = true;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// minimum
|
|
781
|
+
if (MIN !== '') {
|
|
782
|
+
if (Number(curYear) < Number(MIN.year)) {
|
|
783
|
+
res = true;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
|
|
787
|
+
res = true;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
|
|
791
|
+
res = true;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
|
|
796
|
+
res = true;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) < Number(MIN.minutes) ) {
|
|
800
|
+
res = true;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) === Number(MIN.minutes) && Number(curSeconds) < Number(MIN.seconds) ) {
|
|
804
|
+
res = true;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
return res;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
function checkDisabledMinutes(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string, curMinutes: number | string) {
|
|
814
|
+
let res: boolean = false;
|
|
815
|
+
|
|
816
|
+
// maximum
|
|
817
|
+
if (MAX !== '') {
|
|
818
|
+
if (Number(curYear) > Number(MAX.year)) {
|
|
819
|
+
res = true;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
|
|
823
|
+
res = true;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
|
|
827
|
+
res = true;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
|
|
832
|
+
res = true;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) === Number(MAX.hours) && Number(curMinutes) > Number(MAX.minutes) ) {
|
|
836
|
+
res = true;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// minimum
|
|
841
|
+
if (MIN !== '') {
|
|
842
|
+
if (Number(curYear) < Number(MIN.year)) {
|
|
843
|
+
res = true;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
|
|
847
|
+
res = true;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
|
|
851
|
+
res = true;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
|
|
856
|
+
res = true;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) === Number(MIN.hours) && Number(curMinutes) < Number(MIN.minutes) ) {
|
|
860
|
+
res = true;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
return res;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
function checkDisabledHours(curYear: number | string, curMonth: number, curDay: number | string, curHours: number | string) {
|
|
870
|
+
let res: boolean = false;
|
|
871
|
+
|
|
872
|
+
// maximum
|
|
873
|
+
if (MAX !== '') {
|
|
874
|
+
if (Number(curYear) > Number(MAX.year)) {
|
|
875
|
+
res = true;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) > Number(MAX.month)) {
|
|
879
|
+
res = true;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) > Number(MAX.day)) {
|
|
883
|
+
res = true;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
if (Number(curYear) === Number(MAX.year) && Number(curMonth+1) === Number(MAX.month) && Number(curDay) === Number(MAX.day) && Number(curHours) > Number(MAX.hours) ) {
|
|
888
|
+
res = true;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// minimum
|
|
893
|
+
if (MIN !== '') {
|
|
894
|
+
if (Number(curYear) < Number(MIN.year)) {
|
|
895
|
+
res = true;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) < Number(MIN.month)) {
|
|
899
|
+
res = true;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) < Number(MIN.day)) {
|
|
903
|
+
res = true;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
if (Number(curYear) === Number(MIN.year) && Number(curMonth+1) === Number(MIN.month) && Number(curDay) === Number(MIN.day) && Number(curHours) < Number(MIN.hours) ) {
|
|
908
|
+
res = true;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
return res;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function initValue(v: any) {
|
|
916
|
+
const _res = valueResConverter(v);
|
|
917
|
+
|
|
918
|
+
setChangedVal(_res);
|
|
919
|
+
|
|
920
|
+
if (isValidDate(v)) {
|
|
921
|
+
|
|
922
|
+
const {
|
|
923
|
+
date,
|
|
924
|
+
year,
|
|
925
|
+
month,
|
|
926
|
+
day,
|
|
927
|
+
hours,
|
|
928
|
+
minutes,
|
|
929
|
+
seconds
|
|
930
|
+
} = getFullTimeData(v);
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
setDateVal(date);
|
|
934
|
+
setTimeVal([hours, minutes, seconds]);
|
|
935
|
+
setSplitVals([year, month, day, hours, minutes, seconds]);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
return [_res, v]
|
|
939
|
+
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function tools() {
|
|
943
|
+
return <span className={combinedCls(
|
|
944
|
+
'date2d__control-tools',
|
|
945
|
+
{
|
|
946
|
+
'date2d__control-tools--hover-show-tools': SHOW_TOOLS_ENABLED
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
)}>
|
|
950
|
+
|
|
951
|
+
<a
|
|
952
|
+
tabIndex={-1}
|
|
953
|
+
href="#"
|
|
954
|
+
className={combinedCls(
|
|
955
|
+
'date2d__control-tools__close',
|
|
956
|
+
{
|
|
957
|
+
'd-none': HIDE_CLEAR_BTN_ENABLED || !dateDefaultValueExist || disabled || readOnly
|
|
958
|
+
}
|
|
959
|
+
)} onClick={(e: React.MouseEvent) => {
|
|
960
|
+
e.preventDefault();
|
|
961
|
+
e.stopPropagation(); // Avoid triggering pop-ups
|
|
962
|
+
|
|
963
|
+
// If disabled or readOnly, the operations are not performed
|
|
964
|
+
if (disabled || readOnly) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
clearAll();
|
|
969
|
+
onClear?.(getFullTimeData(''));
|
|
970
|
+
}}
|
|
971
|
+
><svg width="12px" height="12px" viewBox="0 0 1024 1024"><path fill="#000" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z" /></svg></a>
|
|
972
|
+
|
|
973
|
+
<a
|
|
974
|
+
tabIndex={-1}
|
|
975
|
+
href="#"
|
|
976
|
+
className="date2d__control-tools__trigger"
|
|
977
|
+
onClick={(e: React.MouseEvent) => {
|
|
978
|
+
e.preventDefault();
|
|
979
|
+
e.stopPropagation(); // Avoid triggering pop-ups
|
|
980
|
+
|
|
981
|
+
// If disabled or readOnly, the operations are not performed
|
|
982
|
+
if (disabled || readOnly) {
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
handleShow();
|
|
987
|
+
}}
|
|
988
|
+
>
|
|
989
|
+
<svg width="14px" height="14px" viewBox="0 0 24 24" fill="none">
|
|
990
|
+
<path d="M3 9H21M9 15L11 17L15 13M7 3V5M17 3V5M6.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V8.2C21 7.07989 21 6.51984 20.782 6.09202C20.5903 5.71569 20.2843 5.40973 19.908 5.21799C19.4802 5 18.9201 5 17.8 5H6.2C5.0799 5 4.51984 5 4.09202 5.21799C3.71569 5.40973 3.40973 5.71569 3.21799 6.09202C3 6.51984 3 7.07989 3 8.2V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.07989 21 6.2 21Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
991
|
+
</svg>
|
|
992
|
+
</a>
|
|
993
|
+
|
|
994
|
+
</span>;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
useEffect(() => {
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
// update default value
|
|
1002
|
+
//--------------
|
|
1003
|
+
const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(value, true);
|
|
1004
|
+
setDateDefaultValueExist(defaultValueIsEmpty(value) ? false : true);
|
|
1005
|
+
const [a, b] = initValue(curTargetVal);
|
|
1006
|
+
onLoad?.(a, getFullTimeData(b), getAllSplittingInputs());
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
}, [value]);
|
|
1010
|
+
|
|
1011
|
+
useEffect(() => {
|
|
1012
|
+
|
|
1013
|
+
// update default value (It does not re-render the component because the incoming value changes.)
|
|
1014
|
+
//--------------
|
|
1015
|
+
if (typeof defaultValue !== 'undefined') { //REQUIRED
|
|
1016
|
+
const [curInitSplitClickEvOk, curNoTargetVal, curTargetVal] = getActualDefaultValue(defaultValue, true);
|
|
1017
|
+
setDateDefaultValueExist(defaultValueIsEmpty(defaultValue) ? false : true);
|
|
1018
|
+
const [a, b] = initValue(curTargetVal);
|
|
1019
|
+
onLoad?.(a, getFullTimeData(b), getAllSplittingInputs());
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
}, []);
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
return (
|
|
1026
|
+
<>
|
|
1027
|
+
|
|
1028
|
+
{label ? <>{typeof label === 'string' ? <div className="date2d__label"><label htmlFor={idRes} className="form-label" dangerouslySetInnerHTML={{ __html: `${label}` }}></label></div> : <div className="date2d__label"><label htmlFor={idRes} className="form-label">{label}</label></div>}</> : null}
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
<div
|
|
1032
|
+
ref={rootRef}
|
|
1033
|
+
data-overlay-id={`date2d__wrapper-${idRes}`}
|
|
1034
|
+
className={combinedCls(
|
|
1035
|
+
'date2d__trigger d-inline-block',
|
|
1036
|
+
`is-${type}`,
|
|
1037
|
+
triggerClassName,
|
|
1038
|
+
{
|
|
1039
|
+
'date2d__trigger--hover-show-tools': SHOW_TOOLS_ENABLED
|
|
1040
|
+
}
|
|
1041
|
+
)}
|
|
1042
|
+
onFocus={handleFocus}
|
|
1043
|
+
onBlur={handleBlur}
|
|
1044
|
+
onKeyDown={handleKeyPressed}
|
|
1045
|
+
onClick={enableEntireAreaPopup && !disabled && !readOnly ? handleShow : () => {}}
|
|
1046
|
+
|
|
1047
|
+
>
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
<div className="date2d__control">
|
|
1051
|
+
<Input
|
|
1052
|
+
ref={(node) => {
|
|
1053
|
+
inputRef.current = node;
|
|
1054
|
+
if (typeof externalRef === 'function') {
|
|
1055
|
+
externalRef(node);
|
|
1056
|
+
} else if (externalRef) {
|
|
1057
|
+
externalRef.current = node;
|
|
1058
|
+
}
|
|
1059
|
+
}}
|
|
1060
|
+
disabled={disabled}
|
|
1061
|
+
readOnly={readOnly}
|
|
1062
|
+
tabIndex={-1}
|
|
1063
|
+
type="text"
|
|
1064
|
+
inputMode="none"
|
|
1065
|
+
data-date-info={JSON.stringify(getFullTimeData(changedVal))}
|
|
1066
|
+
wrapperClassName={wrapperClassName}
|
|
1067
|
+
controlClassName={controlClassName}
|
|
1068
|
+
controlExClassName=""
|
|
1069
|
+
controlGroupWrapperClassName={controlGroupWrapperClassName}
|
|
1070
|
+
controlGroupTextClassName={controlGroupTextClassName}
|
|
1071
|
+
id={idRes}
|
|
1072
|
+
name={name}
|
|
1073
|
+
alt={alt}
|
|
1074
|
+
placeholder={datePlaceholder}
|
|
1075
|
+
value={!dateDefaultValueExist ? `` : valueResConverter(changedVal)}
|
|
1076
|
+
autoComplete="off"
|
|
1077
|
+
onChange={handleChange}
|
|
1078
|
+
label=""
|
|
1079
|
+
units={units}
|
|
1080
|
+
iconLeft={iconLeft}
|
|
1081
|
+
iconRight={iconRight}
|
|
1082
|
+
requiredLabel={requiredLabel}
|
|
1083
|
+
required={required}
|
|
1084
|
+
appendControl={<>
|
|
1085
|
+
<div className="date2d__control__inputplaceholder">
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
{/*
|
|
1089
|
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1090
|
+
+++++++++++++++++++ Split Inputs +++++++++++++++++++++++++++++
|
|
1091
|
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1092
|
+
*/}
|
|
1093
|
+
{COM_HAS_DATE ? <>
|
|
1094
|
+
<input
|
|
1095
|
+
ref={(node) => {
|
|
1096
|
+
partedInputYear.current = node;
|
|
1097
|
+
if (node) {
|
|
1098
|
+
splitInputs.current.set(splitInputsIds[0], node);
|
|
1099
|
+
} else {
|
|
1100
|
+
splitInputs.current.delete(splitInputsIds[0]);
|
|
1101
|
+
}
|
|
1102
|
+
}}
|
|
1103
|
+
tabIndex={splitInputsTabIndex}
|
|
1104
|
+
data-mark={`${splitInputsIds[0]}`}
|
|
1105
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1106
|
+
inputMode="numeric"
|
|
1107
|
+
className="date2d__control__inputplaceholder--year"
|
|
1108
|
+
value={!dateDefaultValueExist ? `` : splitVals[0]}
|
|
1109
|
+
maxLength={4}
|
|
1110
|
+
autoComplete="off"
|
|
1111
|
+
disabled={disabled || null}
|
|
1112
|
+
readOnly={readOnly || null}
|
|
1113
|
+
onClick={handleInitSplitClickEv}
|
|
1114
|
+
onChange={(e: any) => {
|
|
1115
|
+
let _val = e.target.value;
|
|
1116
|
+
if (_val !== '' && !isValidYear(_val) && isNumeric(_val) && Number(_val) > 9999) _val = '9999';
|
|
1117
|
+
if (_val !== '' && !isValidYear(_val) && !isNumeric(_val)) _val = `${getCurrentYear()}`;
|
|
1118
|
+
|
|
1119
|
+
const _date = `${_val}-${splitVals[1]}-${splitVals[2]}`;
|
|
1120
|
+
const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
|
|
1121
|
+
|
|
1122
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1123
|
+
setSplitVals((prevState: string[]) => {
|
|
1124
|
+
return [_val, prevState[1], prevState[2], prevState[3], prevState[4], prevState[5]];
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
// update other data
|
|
1128
|
+
setDateVal(_date);
|
|
1129
|
+
setChangedVal(_full);
|
|
1130
|
+
setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
|
|
1131
|
+
|
|
1132
|
+
// Auto focus to next input if year is 4 digits
|
|
1133
|
+
if (_val.length === 4) {
|
|
1134
|
+
const nextInput = splitInputs.current.get(splitInputsIds[1]);
|
|
1135
|
+
if (nextInput) {
|
|
1136
|
+
(nextInput as HTMLInputElement).focus();
|
|
1137
|
+
(nextInput as HTMLInputElement).select();
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}}
|
|
1141
|
+
{...attributes}
|
|
1142
|
+
/>
|
|
1143
|
+
{dateDefaultValueExist ? DELIMITER_DATE : null}
|
|
1144
|
+
<input
|
|
1145
|
+
ref={(node) => {
|
|
1146
|
+
partedInputMonth.current = node;
|
|
1147
|
+
if (node) {
|
|
1148
|
+
splitInputs.current.set(splitInputsIds[1], node);
|
|
1149
|
+
} else {
|
|
1150
|
+
splitInputs.current.delete(splitInputsIds[1]);
|
|
1151
|
+
}
|
|
1152
|
+
}}
|
|
1153
|
+
tabIndex={splitInputsTabIndex}
|
|
1154
|
+
data-mark={`${splitInputsIds[1]}`}
|
|
1155
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1156
|
+
inputMode="numeric"
|
|
1157
|
+
className="date2d__control__inputplaceholder--month"
|
|
1158
|
+
value={!dateDefaultValueExist ? `` : splitVals[1]}
|
|
1159
|
+
maxLength={2}
|
|
1160
|
+
autoComplete="off"
|
|
1161
|
+
disabled={disabled || null}
|
|
1162
|
+
readOnly={readOnly || null}
|
|
1163
|
+
onClick={handleInitSplitClickEv}
|
|
1164
|
+
onChange={(e: any) => {
|
|
1165
|
+
let _val = e.target.value;
|
|
1166
|
+
if (_val !== '' && !isValidMonth(_val) && isNumeric(_val)) {
|
|
1167
|
+
if (Number(_val) > 12) _val = '12';
|
|
1168
|
+
if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
|
|
1169
|
+
}
|
|
1170
|
+
if (_val !== '' && !isValidMonth(_val) && !isNumeric(_val)) _val = `${getCurrentMonth()}`;
|
|
1171
|
+
|
|
1172
|
+
const _date = `${splitVals[0]}-${_val}-${splitVals[2]}`;
|
|
1173
|
+
const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
|
|
1174
|
+
|
|
1175
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1176
|
+
setSplitVals((prevState: string[]) => {
|
|
1177
|
+
return [prevState[0], _val, prevState[2], prevState[3], prevState[4], prevState[5]];
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
// update other data
|
|
1181
|
+
setDateVal(_date);
|
|
1182
|
+
setChangedVal(_full);
|
|
1183
|
+
setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
|
|
1184
|
+
|
|
1185
|
+
// Auto focus to next input if month is 2 digits
|
|
1186
|
+
if (_val.length === 2) {
|
|
1187
|
+
const nextInput = splitInputs.current.get(splitInputsIds[2]);
|
|
1188
|
+
if (nextInput) {
|
|
1189
|
+
(nextInput as HTMLInputElement).focus();
|
|
1190
|
+
(nextInput as HTMLInputElement).select();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}}
|
|
1194
|
+
{...attributes}
|
|
1195
|
+
/>
|
|
1196
|
+
{dateDefaultValueExist ? DELIMITER_DATE : null}
|
|
1197
|
+
<input
|
|
1198
|
+
ref={(node) => {
|
|
1199
|
+
partedInputDay.current = node;
|
|
1200
|
+
if (node) {
|
|
1201
|
+
splitInputs.current.set(splitInputsIds[2], node);
|
|
1202
|
+
} else {
|
|
1203
|
+
splitInputs.current.delete(splitInputsIds[2]);
|
|
1204
|
+
}
|
|
1205
|
+
}}
|
|
1206
|
+
tabIndex={splitInputsTabIndex}
|
|
1207
|
+
data-mark={`${splitInputsIds[2]}`}
|
|
1208
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1209
|
+
inputMode="numeric"
|
|
1210
|
+
className="date2d__control__inputplaceholder--day"
|
|
1211
|
+
value={!dateDefaultValueExist ? `` : splitVals[2]}
|
|
1212
|
+
maxLength={2}
|
|
1213
|
+
autoComplete="off"
|
|
1214
|
+
disabled={disabled || null}
|
|
1215
|
+
readOnly={readOnly || null}
|
|
1216
|
+
onClick={handleInitSplitClickEv}
|
|
1217
|
+
onChange={(e: any) => {
|
|
1218
|
+
let _val = e.target.value;
|
|
1219
|
+
|
|
1220
|
+
const _day = `${splitVals[0]}-${splitVals[1]}-01`;
|
|
1221
|
+
const d = getLastDayInMonth(_day, new window.Date(_day).getMonth() + 1);
|
|
1222
|
+
|
|
1223
|
+
if (_val !== '' && isValidDay(_val) && isNumeric(_val)) {
|
|
1224
|
+
if (Number(_val) > Number(d)) _val = `${d}`;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
if (_val !== '' && !isValidDay(_val) && isNumeric(_val)) {
|
|
1228
|
+
if (Number(_val) > Number(d)) _val = `${d}`;
|
|
1229
|
+
if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
|
|
1230
|
+
}
|
|
1231
|
+
if (_val !== '' && !isValidDay(_val) && !isNumeric(_val)) _val = `${getCurrentDay()}`;
|
|
1232
|
+
|
|
1233
|
+
const _date = `${splitVals[0]}-${splitVals[1]}-${_val}`;
|
|
1234
|
+
const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${splitVals[5]}`;
|
|
1235
|
+
|
|
1236
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1237
|
+
setSplitVals((prevState: string[]) => {
|
|
1238
|
+
return [prevState[0], prevState[1], _val, prevState[3], prevState[4], prevState[5]];
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1241
|
+
// update other data
|
|
1242
|
+
setDateVal(_date);
|
|
1243
|
+
setChangedVal(_full);
|
|
1244
|
+
setTimeVal([splitVals[3], splitVals[4], splitVals[5]]);
|
|
1245
|
+
|
|
1246
|
+
// Auto focus to next input if day is 2 digits
|
|
1247
|
+
if (_val.length === 2) {
|
|
1248
|
+
const nextInput = splitInputs.current.get(splitInputsIds[3]);
|
|
1249
|
+
if (nextInput) {
|
|
1250
|
+
(nextInput as HTMLInputElement).focus();
|
|
1251
|
+
(nextInput as HTMLInputElement).select();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}}
|
|
1255
|
+
{...attributes}
|
|
1256
|
+
/>
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
</> : null}
|
|
1260
|
+
|
|
1261
|
+
{COM_HAS_TIME ? <>
|
|
1262
|
+
{/* TIME CONTROL */}
|
|
1263
|
+
<input
|
|
1264
|
+
ref={(node) => {
|
|
1265
|
+
partedInputHours.current = node;
|
|
1266
|
+
if (node) {
|
|
1267
|
+
splitInputs.current.set(splitInputsIds[3], node);
|
|
1268
|
+
} else {
|
|
1269
|
+
splitInputs.current.delete(splitInputsIds[3]);
|
|
1270
|
+
}
|
|
1271
|
+
}}
|
|
1272
|
+
tabIndex={splitInputsTabIndex}
|
|
1273
|
+
data-mark={`${splitInputsIds[3]}`}
|
|
1274
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1275
|
+
inputMode="numeric"
|
|
1276
|
+
className="date2d__control__inputplaceholder--hours"
|
|
1277
|
+
value={!dateDefaultValueExist ? `` : splitVals[3]}
|
|
1278
|
+
maxLength={2}
|
|
1279
|
+
autoComplete="off"
|
|
1280
|
+
disabled={disabled || null}
|
|
1281
|
+
readOnly={readOnly || null}
|
|
1282
|
+
onClick={handleInitSplitClickEv}
|
|
1283
|
+
onChange={(e: any) => {
|
|
1284
|
+
let _val = e.target.value;
|
|
1285
|
+
if (_val !== '' && !isValidHours(_val) && isNumeric(_val) && Number(_val) > 23) _val = '23';
|
|
1286
|
+
if (_val !== '' && !isValidHours(_val) && !isNumeric(_val)) _val = '00';
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
|
|
1290
|
+
const _full = `${_date} ${_val}:${splitVals[4]}:${splitVals[5]}`;
|
|
1291
|
+
|
|
1292
|
+
|
|
1293
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1294
|
+
setSplitVals((prevState: string[]) => {
|
|
1295
|
+
return [prevState[0], prevState[1], prevState[2], _val, prevState[4], prevState[5]];
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
// update other data
|
|
1299
|
+
setDateVal(_date);
|
|
1300
|
+
setChangedVal(_full);
|
|
1301
|
+
setTimeVal([_val, splitVals[4], splitVals[5]]);
|
|
1302
|
+
|
|
1303
|
+
// Auto focus to next input if hour is 2 digits
|
|
1304
|
+
if (_val.length === 2) {
|
|
1305
|
+
const nextInput = splitInputs.current.get(splitInputsIds[4]);
|
|
1306
|
+
if (nextInput) {
|
|
1307
|
+
(nextInput as HTMLInputElement).focus();
|
|
1308
|
+
(nextInput as HTMLInputElement).select();
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}}
|
|
1312
|
+
{...attributes}
|
|
1313
|
+
/>
|
|
1314
|
+
{/* TIME CONTROL */}
|
|
1315
|
+
|
|
1316
|
+
{/* TIME CONTROL */}
|
|
1317
|
+
{dateDefaultValueExist ? DELIMITER_TIME : null}
|
|
1318
|
+
<input
|
|
1319
|
+
ref={(node) => {
|
|
1320
|
+
partedInputMinutes.current = node;
|
|
1321
|
+
if (node) {
|
|
1322
|
+
splitInputs.current.set(splitInputsIds[4], node);
|
|
1323
|
+
} else {
|
|
1324
|
+
splitInputs.current.delete(splitInputsIds[4]);
|
|
1325
|
+
}
|
|
1326
|
+
}}
|
|
1327
|
+
tabIndex={splitInputsTabIndex}
|
|
1328
|
+
data-mark={`${splitInputsIds[4]}`}
|
|
1329
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1330
|
+
inputMode="numeric"
|
|
1331
|
+
className="date2d__control__inputplaceholder--minutes"
|
|
1332
|
+
value={!dateDefaultValueExist ? `` : splitVals[4]}
|
|
1333
|
+
maxLength={2}
|
|
1334
|
+
autoComplete="off"
|
|
1335
|
+
disabled={disabled || null}
|
|
1336
|
+
readOnly={readOnly || null}
|
|
1337
|
+
onClick={handleInitSplitClickEv}
|
|
1338
|
+
onChange={(e: any) => {
|
|
1339
|
+
let _val = e.target.value;
|
|
1340
|
+
if (_val !== '' && !isValidMinutesAndSeconds(_val) && isNumeric(_val) && Number(_val) > 59) _val = '59';
|
|
1341
|
+
if (_val !== '' && !isValidMinutesAndSeconds(_val) && !isNumeric(_val)) _val = '00';
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
|
|
1345
|
+
const _full = `${_date} ${splitVals[3]}:${_val}:${splitVals[5]}`;
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1349
|
+
setSplitVals((prevState: string[]) => {
|
|
1350
|
+
return [prevState[0], prevState[1], prevState[2], prevState[3], _val, prevState[5]];
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
// update other data
|
|
1354
|
+
setDateVal(_date);
|
|
1355
|
+
setChangedVal(_full);
|
|
1356
|
+
setTimeVal([splitVals[3], _val, splitVals[5]]);
|
|
1357
|
+
|
|
1358
|
+
// Auto focus to next input if minute is 2 digits
|
|
1359
|
+
if (_val.length === 2) {
|
|
1360
|
+
const nextInput = splitInputs.current.get(splitInputsIds[5]);
|
|
1361
|
+
if (nextInput) {
|
|
1362
|
+
(nextInput as HTMLInputElement).focus();
|
|
1363
|
+
(nextInput as HTMLInputElement).select();
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}}
|
|
1367
|
+
{...attributes}
|
|
1368
|
+
/>
|
|
1369
|
+
{/* TIME CONTROL */}
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
{/* TIME CONTROL */}
|
|
1373
|
+
{(COM_NO_SECONDS) ? <>
|
|
1374
|
+
{dateDefaultValueExist ? DELIMITER_TIME : null}
|
|
1375
|
+
<input
|
|
1376
|
+
ref={(node) => {
|
|
1377
|
+
partedInputSeconds.current = node;
|
|
1378
|
+
if (node) {
|
|
1379
|
+
splitInputs.current.set(splitInputsIds[5], node);
|
|
1380
|
+
} else {
|
|
1381
|
+
splitInputs.current.delete(splitInputsIds[5]);
|
|
1382
|
+
}
|
|
1383
|
+
}}
|
|
1384
|
+
tabIndex={splitInputsTabIndex}
|
|
1385
|
+
data-mark={`${splitInputsIds[5]}`}
|
|
1386
|
+
onKeyDown={handleKeyPressedForSplitInputs}
|
|
1387
|
+
inputMode="numeric"
|
|
1388
|
+
className="date2d__control__inputplaceholder--seconds"
|
|
1389
|
+
value={!dateDefaultValueExist ? `` : splitVals[5]}
|
|
1390
|
+
maxLength={2}
|
|
1391
|
+
autoComplete="off"
|
|
1392
|
+
disabled={disabled || null}
|
|
1393
|
+
readOnly={readOnly || null}
|
|
1394
|
+
onClick={handleInitSplitClickEv}
|
|
1395
|
+
onChange={(e: any) => {
|
|
1396
|
+
let _val = e.target.value;
|
|
1397
|
+
if (_val !== '' && !isValidMinutesAndSeconds(_val) && isNumeric(_val) && Number(_val) > 59) _val = '59';
|
|
1398
|
+
if (_val !== '' && !isValidMinutesAndSeconds(_val) && !isNumeric(_val)) _val = '00';
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
const _date = `${splitVals[0]}-${splitVals[1]}-${splitVals[2]}`;
|
|
1402
|
+
const _full = `${_date} ${splitVals[3]}:${splitVals[4]}:${_val}`;
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
onChange?.(inputRef.current, valueResConverter(_full), isValidDate(_full), getAllSplittingInputs());
|
|
1406
|
+
setSplitVals((prevState: string[]) => {
|
|
1407
|
+
return [prevState[0], prevState[1], prevState[2], prevState[3], prevState[4], _val];
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
// update other data
|
|
1412
|
+
setDateVal(_date);
|
|
1413
|
+
setChangedVal(_full);
|
|
1414
|
+
setTimeVal([splitVals[3], splitVals[4], _val]);
|
|
1415
|
+
// No auto focus for the last input (seconds)
|
|
1416
|
+
}}
|
|
1417
|
+
{...attributes}
|
|
1418
|
+
/>
|
|
1419
|
+
</> : null}
|
|
1420
|
+
{/* TIME CONTROL */}
|
|
1421
|
+
</> : null}
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
{/*
|
|
1425
|
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1426
|
+
+++++++++++++++++++ /Split Inputs +++++++++++++++++++++++++++++
|
|
1427
|
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1428
|
+
*/}
|
|
1429
|
+
|
|
1430
|
+
</div>
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
{/* TOOLS */}
|
|
1435
|
+
{propExist(iconRight) ? tools() : null}
|
|
1436
|
+
{/* /TOOLS */}
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
</>}
|
|
1440
|
+
style={style}
|
|
1441
|
+
{...attributes}
|
|
1442
|
+
/>
|
|
1443
|
+
|
|
1444
|
+
{/* TOOLS */}
|
|
1445
|
+
{!propExist(iconRight) ? tools() : null}
|
|
1446
|
+
{/* /TOOLS */}
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
</div>
|
|
1450
|
+
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
</div>
|
|
1454
|
+
|
|
1455
|
+
|
|
1456
|
+
<RootPortal show={isShow} containerClassName={combinedCls(
|
|
1457
|
+
'Date',
|
|
1458
|
+
`Date--${type}`
|
|
1459
|
+
)}>
|
|
1460
|
+
<div
|
|
1461
|
+
ref={modalRef}
|
|
1462
|
+
id={`date2d__wrapper-${idRes}`}
|
|
1463
|
+
className={combinedCls(
|
|
1464
|
+
'date2d__wrapper',
|
|
1465
|
+
`is-${type}`,
|
|
1466
|
+
popupClassName,
|
|
1467
|
+
'active'
|
|
1468
|
+
)}
|
|
1469
|
+
style={{
|
|
1470
|
+
display: 'none',
|
|
1471
|
+
zIndex: DEPTH
|
|
1472
|
+
}}
|
|
1473
|
+
{...attributes}
|
|
1474
|
+
>
|
|
1475
|
+
|
|
1476
|
+
|
|
1477
|
+
<div
|
|
1478
|
+
ref={listContentRef}
|
|
1479
|
+
className="date2d__tools-container d-flex flex-row"
|
|
1480
|
+
>
|
|
1481
|
+
{/* CALENDAR */}
|
|
1482
|
+
{COM_HAS_DATE ? <>
|
|
1483
|
+
<div className="date2d__calendar">
|
|
1484
|
+
<Calendar
|
|
1485
|
+
min={min}
|
|
1486
|
+
max={max}
|
|
1487
|
+
customTodayDate={changedVal}
|
|
1488
|
+
langWeek={_langWeek}
|
|
1489
|
+
langWeekFull={_langWeekFull}
|
|
1490
|
+
langMonths={_langMonths}
|
|
1491
|
+
langMonthsFull={_langMonthsFull}
|
|
1492
|
+
langToday={_langToday}
|
|
1493
|
+
onChangeDate={(e: any, currentData: any) => {
|
|
1494
|
+
// If disabled or readOnly, the operations are not performed
|
|
1495
|
+
if (disabled || readOnly) {
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
resetDefauleValueExist();
|
|
1500
|
+
|
|
1501
|
+
//
|
|
1502
|
+
const _v = getFullTimeData(`${currentData.date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1503
|
+
setDateVal(currentData.date);
|
|
1504
|
+
setChangedVal(`${currentData.date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1505
|
+
setSplitVals((prevState: string[]) => {
|
|
1506
|
+
return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
|
|
1507
|
+
});
|
|
1508
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1509
|
+
|
|
1510
|
+
//
|
|
1511
|
+
onChangeDate?.(_v);
|
|
1512
|
+
|
|
1513
|
+
//
|
|
1514
|
+
resetPopupBlurStatus();
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
}}
|
|
1518
|
+
onChangeToday={(currentData: any) => {
|
|
1519
|
+
// If disabled or readOnly, the operations are not performed
|
|
1520
|
+
if (disabled || readOnly) {
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
resetDefauleValueExist();
|
|
1525
|
+
|
|
1526
|
+
//
|
|
1527
|
+
const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
|
|
1528
|
+
const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1529
|
+
setDateVal(`${_date}`);
|
|
1530
|
+
setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1531
|
+
setSplitVals((prevState: string[]) => {
|
|
1532
|
+
return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
|
|
1533
|
+
});
|
|
1534
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1535
|
+
|
|
1536
|
+
//
|
|
1537
|
+
onChangeToday?.(_v);
|
|
1538
|
+
|
|
1539
|
+
//
|
|
1540
|
+
resetPopupBlurStatus();
|
|
1541
|
+
|
|
1542
|
+
}}
|
|
1543
|
+
onChangeMonth={(currentData: any) => {
|
|
1544
|
+
resetDefauleValueExist();
|
|
1545
|
+
|
|
1546
|
+
//
|
|
1547
|
+
const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
|
|
1548
|
+
const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1549
|
+
setDateVal(_date);
|
|
1550
|
+
setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1551
|
+
setSplitVals((prevState: string[]) => {
|
|
1552
|
+
return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
|
|
1553
|
+
});
|
|
1554
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1555
|
+
|
|
1556
|
+
//
|
|
1557
|
+
onChangeMonth?.(_v);
|
|
1558
|
+
|
|
1559
|
+
//
|
|
1560
|
+
resetPopupBlurStatus();
|
|
1561
|
+
|
|
1562
|
+
}}
|
|
1563
|
+
onChangeYear={(currentData: any) => {
|
|
1564
|
+
resetDefauleValueExist();
|
|
1565
|
+
|
|
1566
|
+
//
|
|
1567
|
+
const _date = `${currentData.year}-${currentData.month}-${currentData.day}`;
|
|
1568
|
+
const _v = getFullTimeData(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1569
|
+
setDateVal(_date);
|
|
1570
|
+
setChangedVal(`${_date} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1571
|
+
setSplitVals((prevState: string[]) => {
|
|
1572
|
+
return [_v.year, _v.month, _v.day, prevState[3], prevState[4], prevState[5]];
|
|
1573
|
+
});
|
|
1574
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1575
|
+
|
|
1576
|
+
//
|
|
1577
|
+
onChangeYear?.(_v);
|
|
1578
|
+
|
|
1579
|
+
//
|
|
1580
|
+
resetPopupBlurStatus();
|
|
1581
|
+
|
|
1582
|
+
|
|
1583
|
+
}}
|
|
1584
|
+
/>
|
|
1585
|
+
</div>
|
|
1586
|
+
</> : null}
|
|
1587
|
+
|
|
1588
|
+
{/* /CALENDAR */}
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
{COM_HAS_TIME ? <>
|
|
1592
|
+
|
|
1593
|
+
{/* TIME CONTROL */}
|
|
1594
|
+
<div className="date2d__hourslist border-end">
|
|
1595
|
+
<h3>{_langHoursTitle}</h3>
|
|
1596
|
+
|
|
1597
|
+
<ul>
|
|
1598
|
+
{hoursArr.map((hour: string, i: number) => {
|
|
1599
|
+
|
|
1600
|
+
const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1601
|
+
|
|
1602
|
+
return <li key={i}>
|
|
1603
|
+
<a
|
|
1604
|
+
data-value={hour}
|
|
1605
|
+
href="#"
|
|
1606
|
+
tabIndex={-1}
|
|
1607
|
+
onClick={(e: React.MouseEvent) => {
|
|
1608
|
+
e.preventDefault();
|
|
1609
|
+
|
|
1610
|
+
// If disabled or readOnly, the operations are not performed
|
|
1611
|
+
if (disabled || readOnly) {
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
resetDefauleValueExist();
|
|
1616
|
+
|
|
1617
|
+
//
|
|
1618
|
+
const _val = (e.currentTarget as any).dataset.value;
|
|
1619
|
+
const _v = getFullTimeData(`${dateVal} ${_val}:${timeVal[1]}:${timeVal[2]}`);
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
setChangedVal(`${dateVal} ${_val}:${timeVal[1]}:${timeVal[2]}`);
|
|
1623
|
+
setTimeVal((prevState: string[]) => {
|
|
1624
|
+
return [_val, prevState[1], prevState[2]];
|
|
1625
|
+
});
|
|
1626
|
+
setSplitVals((prevState: string[]) => {
|
|
1627
|
+
return [prevState[0], prevState[1], prevState[2], _v.hours, prevState[4], prevState[5]];
|
|
1628
|
+
});
|
|
1629
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1630
|
+
|
|
1631
|
+
//
|
|
1632
|
+
onChangeHours?.(_v);
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
//
|
|
1636
|
+
resetPopupBlurStatus();
|
|
1637
|
+
|
|
1638
|
+
}}
|
|
1639
|
+
className={combinedCls(
|
|
1640
|
+
{
|
|
1641
|
+
'selected': timeVal[0] == hour,
|
|
1642
|
+
'disabled': checkDisabledHours(_curVal.year, Number(_curVal.month)-1, _curVal.day, hour)
|
|
1643
|
+
}
|
|
1644
|
+
)}
|
|
1645
|
+
>
|
|
1646
|
+
{hour}
|
|
1647
|
+
</a>
|
|
1648
|
+
</li>
|
|
1649
|
+
})}
|
|
1650
|
+
|
|
1651
|
+
</ul>
|
|
1652
|
+
</div>
|
|
1653
|
+
{/* TIME CONTROL */}
|
|
1654
|
+
|
|
1655
|
+
{/* TIME CONTROL */}
|
|
1656
|
+
<div className="date2d__minuteslist border-end">
|
|
1657
|
+
<h3>{_langMinutesTitle}</h3>
|
|
1658
|
+
|
|
1659
|
+
<ul>
|
|
1660
|
+
{msArr.map((v: string, i: number) => {
|
|
1661
|
+
const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1662
|
+
|
|
1663
|
+
return <li key={i}>
|
|
1664
|
+
<a
|
|
1665
|
+
data-value={v}
|
|
1666
|
+
href="#"
|
|
1667
|
+
tabIndex={-1}
|
|
1668
|
+
onClick={(e: React.MouseEvent) => {
|
|
1669
|
+
e.preventDefault();
|
|
1670
|
+
|
|
1671
|
+
// If disabled or readOnly, the operations are not performed
|
|
1672
|
+
if (disabled || readOnly) {
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
resetDefauleValueExist();
|
|
1677
|
+
|
|
1678
|
+
//
|
|
1679
|
+
const _val = (e.currentTarget as any).dataset.value;
|
|
1680
|
+
const _v = getFullTimeData(`${dateVal} ${timeVal[0]}:${_val}:${timeVal[2]}`);
|
|
1681
|
+
|
|
1682
|
+
setChangedVal(`${dateVal} ${timeVal[0]}:${_val}:${timeVal[2]}`);
|
|
1683
|
+
setTimeVal((prevState: string[]) => {
|
|
1684
|
+
return [prevState[0], _val, prevState[2]];
|
|
1685
|
+
});
|
|
1686
|
+
setSplitVals((prevState: string[]) => {
|
|
1687
|
+
return [prevState[0], prevState[1], prevState[2], prevState[3], _v.minutes, prevState[5]];
|
|
1688
|
+
});
|
|
1689
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1690
|
+
|
|
1691
|
+
//
|
|
1692
|
+
onChangeMinutes?.(_v);
|
|
1693
|
+
|
|
1694
|
+
|
|
1695
|
+
//
|
|
1696
|
+
resetPopupBlurStatus();
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
}}
|
|
1700
|
+
className={combinedCls(
|
|
1701
|
+
{
|
|
1702
|
+
'selected': timeVal[1] == v,
|
|
1703
|
+
'disabled': checkDisabledMinutes(_curVal.year, Number(_curVal.month)-1, _curVal.day, _curVal.hours, v)
|
|
1704
|
+
}
|
|
1705
|
+
)}
|
|
1706
|
+
>
|
|
1707
|
+
|
|
1708
|
+
{v}
|
|
1709
|
+
</a>
|
|
1710
|
+
</li>
|
|
1711
|
+
})}
|
|
1712
|
+
|
|
1713
|
+
</ul>
|
|
1714
|
+
</div>
|
|
1715
|
+
{/* TIME CONTROL */}
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
{/* TIME CONTROL */}
|
|
1719
|
+
{(COM_NO_SECONDS) ? <>
|
|
1720
|
+
<div className="date2d__secondslist border-end">
|
|
1721
|
+
<h3>{_langSecondsTitle}</h3>
|
|
1722
|
+
|
|
1723
|
+
<ul>
|
|
1724
|
+
{msArr.map((v: string, i: number) => {
|
|
1725
|
+
const _curVal = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${timeVal[2]}`);
|
|
1726
|
+
|
|
1727
|
+
return <li key={i}>
|
|
1728
|
+
<a
|
|
1729
|
+
data-value={v}
|
|
1730
|
+
href="#"
|
|
1731
|
+
tabIndex={-1}
|
|
1732
|
+
onClick={(e: React.MouseEvent) => {
|
|
1733
|
+
e.preventDefault();
|
|
1734
|
+
|
|
1735
|
+
// If disabled or readOnly, the operations are not performed
|
|
1736
|
+
if (disabled || readOnly) {
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
resetDefauleValueExist();
|
|
1741
|
+
|
|
1742
|
+
//
|
|
1743
|
+
const _val = (e.currentTarget as any).dataset.value;
|
|
1744
|
+
const _v = getFullTimeData(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${_val}`);
|
|
1745
|
+
setChangedVal(`${dateVal} ${timeVal[0]}:${timeVal[1]}:${_val}`);
|
|
1746
|
+
setTimeVal((prevState: string[]) => {
|
|
1747
|
+
return [prevState[0], prevState[1], _val];
|
|
1748
|
+
});
|
|
1749
|
+
setSplitVals((prevState: string[]) => {
|
|
1750
|
+
return [prevState[0], prevState[1], prevState[2], prevState[3], prevState[5], _v.seconds ];
|
|
1751
|
+
});
|
|
1752
|
+
onChange?.(inputRef.current, _v, true, getAllSplittingInputs());
|
|
1753
|
+
|
|
1754
|
+
//
|
|
1755
|
+
onChangeSeconds?.(_v);
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
//
|
|
1759
|
+
resetPopupBlurStatus();
|
|
1760
|
+
|
|
1761
|
+
}}
|
|
1762
|
+
className={combinedCls(
|
|
1763
|
+
{
|
|
1764
|
+
'selected': timeVal[2] == v,
|
|
1765
|
+
'disabled': checkDisabledSeconds(_curVal.year, Number(_curVal.month)-1, _curVal.day, _curVal.hours, _curVal.minutes, v)
|
|
1766
|
+
}
|
|
1767
|
+
)}
|
|
1768
|
+
>
|
|
1769
|
+
|
|
1770
|
+
{v}
|
|
1771
|
+
</a>
|
|
1772
|
+
</li>
|
|
1773
|
+
})}
|
|
1774
|
+
|
|
1775
|
+
</ul>
|
|
1776
|
+
</div>
|
|
1777
|
+
</> : null}
|
|
1778
|
+
{/* TIME CONTROL */}
|
|
1779
|
+
</> : null}
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
</div>
|
|
1784
|
+
|
|
1785
|
+
</div>
|
|
1786
|
+
</RootPortal>
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
</>
|
|
1793
|
+
)
|
|
1794
|
+
});
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
export default Date;
|