@cwellt_software/cwellt-reactjs-lib 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content/icons/new-cw-icons/NewCwIcons.html +13 -3
- package/dist/content/icons/new-cw-icons/NewCwIcons.json +10 -1
- package/dist/content/icons/new-cw-icons/css/new-cw-icons.css +39 -2
- package/dist/content/icons/new-cw-icons/fonts/NewCwIcons.woff +0 -0
- package/dist/index.cjs.js +2169 -1653
- package/dist/index.css +1 -7
- package/dist/index.d.ts +446 -327
- package/dist/index.es.js +2167 -1607
- package/dist/src/common/classes/CwSelectList.js +12 -0
- package/dist/src/common/classes/CwSelectListItems.js +14 -0
- package/dist/src/common/functions/collections.js +18 -0
- package/dist/src/common/functions/colorManipulation.js +76 -0
- package/dist/src/common/functions/dsl/UiEventDSL.js +20 -0
- package/dist/src/common/functions/useSingleAndDoubleClicks.js +28 -0
- package/dist/src/components/control/action/button/CwButton.d.ts +5 -2
- package/dist/src/components/control/action/button/CwButton.d.ts.map +1 -1
- package/dist/src/components/control/action/button/CwButton.js +13 -0
- package/dist/src/components/control/action/buttons/CwButtons.d.ts +24 -54
- package/dist/src/components/control/action/buttons/CwButtons.d.ts.map +1 -1
- package/dist/src/components/control/action/buttons/CwButtons.js +188 -0
- package/dist/src/components/control/action/contextmenu/CwAnchoredMenu.d.ts +80 -0
- package/dist/src/components/control/action/contextmenu/CwAnchoredMenu.d.ts.map +1 -0
- package/dist/src/components/control/action/contextmenu/CwContextMenu.d.ts +0 -11
- package/dist/src/components/control/action/contextmenu/CwContextMenu.d.ts.map +1 -1
- package/dist/src/components/control/action/contextmenu/CwContextMenu.js +43 -0
- package/dist/src/components/control/action/contextual-menu/CwContextualMenu.js +55 -0
- package/dist/src/components/control/action/search/CwSearch.d.ts +6 -2
- package/dist/src/components/control/action/search/CwSearch.d.ts.map +1 -1
- package/dist/src/components/control/action/search/CwSearch.js +67 -0
- package/dist/src/components/control/action/tooltip-dialog/CwTooltipDialog.js +11 -0
- package/dist/src/components/control/choice/checkbox/CwCheckbox.js +15 -0
- package/dist/src/components/control/choice/deprecated/MultiSelect_deprecated_.js +99 -0
- package/dist/src/components/control/choice/dropdown/CwDropdown.js +27 -0
- package/dist/src/components/control/choice/dropdown/CwDropdownContainer.js +30 -0
- package/dist/src/components/control/choice/dropdown/CwDropdownFilter.js +10 -0
- package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts +1 -5
- package/dist/src/components/control/choice/multi-filter/CwMultiFilter.d.ts.map +1 -1
- package/dist/src/components/control/choice/multi-filter/CwMultiFilter.js +298 -0
- package/dist/src/components/control/choice/multi-filter/components/tag/CwMultiFilterTag.d.ts +2 -2
- package/dist/src/components/control/choice/multi-filter/components/tag/CwMultiFilterTag.d.ts.map +1 -1
- package/dist/src/components/control/choice/multi-filter/components/tag/CwMultiFilterTag.js +17 -0
- package/dist/src/components/control/choice/multiselect/CwHeadFilter.js +80 -0
- package/dist/src/components/control/choice/multiselect/CwMultiselect.js +393 -0
- package/dist/src/components/control/choice/multiselect/CwOptionList.js +36 -0
- package/dist/src/components/control/choice/option/CwOption.js +16 -0
- package/dist/src/components/control/choice/select/CwSelect.js +36 -0
- package/dist/src/components/control/choice/toggle/CwToggle.d.ts.map +1 -1
- package/dist/src/components/control/choice/toggle/CwToggle.js +9 -0
- package/dist/src/components/control/input/any/CwInput.js +16 -0
- package/dist/src/components/control/input/color/CwColorPicker.js +210 -0
- package/dist/src/components/control/input/color/CwInputColor.js +142 -0
- package/dist/src/components/control/input/date/CwInputDate.js +29 -0
- package/dist/src/components/control/input/date-picker/CwInputDatePicker.js +109 -0
- package/dist/src/components/control/input/date-text/CwInputDateText.js +90 -0
- package/dist/src/components/control/input/datetime/CwInputDatetime.js +29 -0
- package/dist/src/components/control/input/digit/CwDigit.js +28 -0
- package/dist/src/components/control/input/file/CwFileUpload.js +52 -0
- package/dist/src/components/control/input/file/CwFileUploadMultiple.d.ts +1 -0
- package/dist/src/components/control/input/file/CwFileUploadMultiple.d.ts.map +1 -1
- package/dist/src/components/control/input/file/CwFileUploadMultiple.js +148 -0
- package/dist/src/components/control/input/image/CwInputImage.js +52 -0
- package/dist/src/components/control/input/image-area/CwImageArea.js +113 -0
- package/dist/src/components/control/input/new-dates/CwDatePicker.d.ts +44 -0
- package/dist/src/components/control/input/new-dates/CwDatePicker.d.ts.map +1 -0
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.d.ts +65 -0
- package/dist/src/components/control/input/new-dates/CwDateRangePicker.d.ts.map +1 -0
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.d.ts +47 -0
- package/dist/src/components/control/input/new-dates/CwDateTimePicker.d.ts.map +1 -0
- package/dist/src/components/control/input/new-dates/CwDateTimePickerCompact.d.ts +46 -0
- package/dist/src/components/control/input/new-dates/CwDateTimePickerCompact.d.ts.map +1 -0
- package/dist/src/components/control/input/new-dates/CwTimePicker.d.ts +38 -0
- package/dist/src/components/control/input/new-dates/CwTimePicker.d.ts.map +1 -0
- package/dist/src/components/control/input/new-dates/dateRangePresets.d.ts +19 -0
- package/dist/src/components/control/input/new-dates/dateRangePresets.d.ts.map +1 -0
- package/dist/src/components/control/input/number/CwInputNumber.js +11 -0
- package/dist/src/components/control/input/phone/CwInputPhone.js +24 -0
- package/dist/src/components/control/input/text/CwInputText.d.ts.map +1 -1
- package/dist/src/components/control/input/text/CwInputText.js +31 -0
- package/dist/src/components/control/input/text-area/CwTextArea.js +9 -0
- package/dist/src/components/control/input/time/CwTime.js +29 -0
- package/dist/src/components/control/input/weekday/CwWeekdaySelector.js +143 -0
- package/dist/src/components/custom/find-airport/CwFindAirportComp.d.ts +4 -1
- package/dist/src/components/custom/find-airport/CwFindAirportComp.d.ts.map +1 -1
- package/dist/src/components/custom/find-airport/CwFindAirportComp.js +240 -0
- package/dist/src/components/custom/scheduler/CwSchedulerComp.js +211 -0
- package/dist/src/components/custom/scheduler/CwSuperSchedulerComp.js +269 -0
- package/dist/src/components/custom/scheduler/components/EventRender.js +142 -0
- package/dist/src/components/custom/scheduler/components/ResourceListRender.d.ts +1 -1
- package/dist/src/components/custom/scheduler/components/ResourceListRender.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler/components/ResourceListRender.js +12 -0
- package/dist/src/components/custom/scheduler/components/ResourceRender.js +26 -0
- package/dist/src/components/custom/scheduler/components/day_headers/DayHeader.js +13 -0
- package/dist/src/components/custom/scheduler/components/day_headers/MonthHeader.js +12 -0
- package/dist/src/components/custom/scheduler/components/day_headers/MyDaysHeader.js +62 -0
- package/dist/src/components/custom/scheduler/components/day_headers/WeekHeader.js +13 -0
- package/dist/src/components/custom/scheduler/components/resources_title_list/ResourcesTitleList.js +24 -0
- package/dist/src/components/custom/scheduler/components/scheduler_content_area/SchedulerContentArea.js +17 -0
- package/dist/src/components/custom/scheduler/components/scheduler_header/SchedulerHeader.js +26 -0
- package/dist/src/components/custom/scheduler/components/scheduler_timeline/SchedulerTimeLine.js +23 -0
- package/dist/src/components/custom/scheduler/components/time_headers/TimeHeader.js +31 -0
- package/dist/src/components/custom/scheduler/components/time_headers/TimeHeaderRow.js +16 -0
- package/dist/src/components/custom/scheduler/components/time_line/TimeLine.js +12 -0
- package/dist/src/components/custom/scheduler/logic/dates/addMinutesToDateFromPx.js +5 -0
- package/dist/src/components/custom/scheduler/logic/dates/daysBetweenTwoDates.js +15 -0
- package/dist/src/components/custom/scheduler/logic/dates/daysBetweenTwoDatesWithoutCeil.js +5 -0
- package/dist/src/components/custom/scheduler/logic/dates/getFormatedTimeForHeader.js +43 -0
- package/dist/src/components/custom/scheduler/logic/dates/getMonthHeaderData.js +35 -0
- package/dist/src/components/custom/scheduler/logic/dates/getUtcToday.js +6 -0
- package/dist/src/components/custom/scheduler/logic/dates/getWeekHeaderDataFromWeekRange.js +20 -0
- package/dist/src/components/custom/scheduler/logic/dates/listOfDatesToWeeks.js +55 -0
- package/dist/src/components/custom/scheduler/logic/divisions/calculateDivisionType.js +13 -0
- package/dist/src/components/custom/scheduler/logic/divisions/calculateDivisions.js +16 -0
- package/dist/src/components/custom/scheduler/logic/filtering/filterEvents.js +33 -0
- package/dist/src/components/custom/scheduler/logic/filtering/filterResources.js +14 -0
- package/dist/src/components/custom/scheduler/logic/filtering/hasSameProperties.js +10 -0
- package/dist/src/components/custom/scheduler/logic/onDrop/OnDrop.js +45 -0
- package/dist/src/components/custom/scheduler/logic/pixels/getHeightLineScheduler.js +14 -0
- package/dist/src/components/custom/scheduler/logic/pixels/getPixelsForEvent.js +32 -0
- package/dist/src/components/custom/scheduler/logic/pixels/heightScheduler.js +14 -0
- package/dist/src/components/custom/scheduler/logic/pixels/heightSchedulerPinned.js +9 -0
- package/dist/src/components/custom/scheduler/logic/state_handle/doubleClickOnResource.js +5 -0
- package/dist/src/components/custom/scheduler/logic/state_handle/handleResourceChange.js +11 -0
- package/dist/src/components/custom/scheduler/logic/state_handle/onDragOver.js +9 -0
- package/dist/src/components/custom/scheduler/logic/state_handle/onDropEventToResource.js +3 -0
- package/dist/src/components/custom/scheduler/logic/strings/compareStrings.js +7 -0
- package/dist/src/components/custom/scheduler/logic/strings/getGUID.js +7 -0
- package/dist/src/components/custom/scheduler/logic/ui/checkIfSlotAvailable.js +8 -0
- package/dist/src/components/custom/scheduler/logic/ui/getEventsOfResource.js +45 -0
- package/dist/src/components/custom/scheduler/logic/ui/getTimeHeaders.js +35 -0
- package/dist/src/components/custom/scheduler/logic/ui/isAllowedToMove.js +19 -0
- package/dist/src/components/custom/scheduler/logic/ui/updateResourceVisibility.js +15 -0
- package/dist/src/components/custom/scheduler/state/CblDragAndDrop.js +18 -0
- package/dist/src/components/custom/scheduler/state/CwSchedulerProps.js +1 -0
- package/dist/src/components/custom/scheduler/state/Resource.js +18 -0
- package/dist/src/components/custom/scheduler/state/State.js +1 -0
- package/dist/src/components/custom/scheduler/state/cblEvent.js +28 -0
- package/dist/src/components/custom/scheduler/state/cblEventCompProps.js +1 -0
- package/dist/src/components/custom/scheduler/state/resourceCompProps2.js +1 -0
- package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.d.ts +3 -4
- package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/NewScheduler.js +123 -0
- package/dist/src/components/custom/scheduler-new/presentation/NewSchedulerUiEvents.d.ts +2 -1
- package/dist/src/components/custom/scheduler-new/presentation/NewSchedulerUiEvents.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/NewSchedulerUiEvents.js +118 -0
- package/dist/src/components/custom/scheduler-new/presentation/SchedulerPresenter.js +166 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/header/HeaderDivision.js +26 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/header/HeaderTitle.js +8 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/header/SchedulerHeader.js +86 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/row/BackgroundEvent.js +60 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/row/DefaultRowHeader.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/DefaultRowHeader.js +24 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.d.ts +2 -2
- package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/Event.js +150 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/row/EventSideDrag.js +11 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/row/SchedulerRow.d.ts +2 -2
- package/dist/src/components/custom/scheduler-new/presentation/components/row/SchedulerRow.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/SchedulerRow.js +176 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/DivisionLine.js +8 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/TimeLine.js +39 -0
- package/dist/src/components/custom/scheduler-new/presentation/components/timeline/WeekEndLine.js +8 -0
- package/dist/src/components/custom/scheduler-new/presentation/helpers.js +43 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/WeekendCalc.js +24 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/dateFromPercentage.js +7 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/eventIsVisible.js +7 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getDefaultDivisions.js +113 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getDivisions.js +21 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getEventSizes.js +30 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getLinesByDivisions.js +13 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getPercentageFromMouseEvent.d.ts +1 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/getPercentageFromMouseEvent.d.ts.map +1 -1
- package/dist/src/components/custom/scheduler-new/presentation/logic/getPercentageFromMouseEvent.js +7 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/separateEventsToInnerRows.js +32 -0
- package/dist/src/components/custom/scheduler-new/presentation/logic/sortByCategoryAndTitle.js +12 -0
- package/dist/src/components/custom/scheduler-temporal/CwSchedulerComp2.js +267 -0
- package/dist/src/components/custom/scheduler-temporal/CwSuperSchedulerComp.js +269 -0
- package/dist/src/components/custom/scheduler-temporal/components/EventRender.js +142 -0
- package/dist/src/components/custom/scheduler-temporal/components/ResourceListRender.js +12 -0
- package/dist/src/components/custom/scheduler-temporal/components/ResourceRender.js +26 -0
- package/dist/src/components/custom/scheduler-temporal/components/day_headers/DayHeader.js +13 -0
- package/dist/src/components/custom/scheduler-temporal/components/day_headers/MonthHeader.js +12 -0
- package/dist/src/components/custom/scheduler-temporal/components/day_headers/MyDaysHeader.js +62 -0
- package/dist/src/components/custom/scheduler-temporal/components/day_headers/WeekHeader.js +13 -0
- package/dist/src/components/custom/scheduler-temporal/components/resources_title_list/ResourcesTitleList.js +22 -0
- package/dist/src/components/custom/scheduler-temporal/components/scheduler_content_area/SchedulerContentArea.js +17 -0
- package/dist/src/components/custom/scheduler-temporal/components/scheduler_header/SchedulerHeader.js +26 -0
- package/dist/src/components/custom/scheduler-temporal/components/scheduler_timeline/SchedulerTimeLine.js +23 -0
- package/dist/src/components/custom/scheduler-temporal/components/time_headers/TimeHeader.js +31 -0
- package/dist/src/components/custom/scheduler-temporal/components/time_headers/TimeHeaderRow.js +16 -0
- package/dist/src/components/custom/scheduler-temporal/components/time_line/TimeLine.js +12 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/addMinutesToDateFromPx.js +5 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/daysBetweenTwoDates.js +15 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/daysBetweenTwoDatesWithoutCeil.js +5 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/getFormatedTimeForHeader.js +43 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/getMonthHeaderData.js +35 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/getUtcToday.js +6 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/getWeekHeaderDataFromWeekRange.js +20 -0
- package/dist/src/components/custom/scheduler-temporal/logic/dates/listOfDatesToWeeks.js +55 -0
- package/dist/src/components/custom/scheduler-temporal/logic/divisions/calculateDivisionType.js +13 -0
- package/dist/src/components/custom/scheduler-temporal/logic/divisions/calculateDivisions.js +16 -0
- package/dist/src/components/custom/scheduler-temporal/logic/filtering/filterAndProcessResources.js +10 -0
- package/dist/src/components/custom/scheduler-temporal/logic/filtering/filterEvents.js +34 -0
- package/dist/src/components/custom/scheduler-temporal/logic/filtering/filterResources.js +14 -0
- package/dist/src/components/custom/scheduler-temporal/logic/filtering/hasSameProperties.js +10 -0
- package/dist/src/components/custom/scheduler-temporal/logic/onDrop/OnDrop.js +36 -0
- package/dist/src/components/custom/scheduler-temporal/logic/pixels/getHeightLineScheduler.js +14 -0
- package/dist/src/components/custom/scheduler-temporal/logic/pixels/getPixelsForEvent.js +32 -0
- package/dist/src/components/custom/scheduler-temporal/logic/pixels/heightScheduler.js +14 -0
- package/dist/src/components/custom/scheduler-temporal/logic/pixels/heightSchedulerPinned.js +9 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/doubleClickOnResource.js +5 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/handlePropChanges.js +178 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/handleResourceChange.js +11 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/onDragOver.js +9 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/onDropEventToResource.js +3 -0
- package/dist/src/components/custom/scheduler-temporal/logic/state_handle/onResizeEvent.js +3 -0
- package/dist/src/components/custom/scheduler-temporal/logic/strings/compareStrings.js +7 -0
- package/dist/src/components/custom/scheduler-temporal/logic/strings/getGUID.js +7 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/checkIfSlotAvailable.js +9 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/getEventsOfResource.js +92 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/getHasPropsChanged.js +242 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/getTimeHeaders.js +35 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/isAllowedToMove.js +19 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/shouldTriggerScroll.js +241 -0
- package/dist/src/components/custom/scheduler-temporal/logic/ui/updateResourceVisibility.js +15 -0
- package/dist/src/components/custom/scheduler-temporal/state/CblDragAndDrop.js +18 -0
- package/dist/src/components/custom/scheduler-temporal/state/Resource.js +18 -0
- package/dist/src/components/custom/scheduler-temporal/state/cblEvent.js +28 -0
- package/dist/src/components/custom/scheduler-temporal/state/cblEventCompProps.js +1 -0
- package/dist/src/components/custom/scheduler-temporal/state/resourceCompProps2.js +1 -0
- package/dist/src/components/custom/super-scheduler/PinRowHeader.d.ts +2 -2
- package/dist/src/components/custom/super-scheduler/PinRowHeader.d.ts.map +1 -1
- package/dist/src/components/custom/super-scheduler/PinRowHeader.js +53 -0
- package/dist/src/components/custom/super-scheduler/SuperScheduler.d.ts +2 -2
- package/dist/src/components/custom/super-scheduler/SuperScheduler.d.ts.map +1 -1
- package/dist/src/components/custom/super-scheduler/SuperScheduler.js +23 -0
- package/dist/src/components/custom/super-scheduler/SuperSchedulerEvents.js +15 -0
- package/dist/src/components/custom/super-scheduler/SuperSchedulerPresenter.js +45 -0
- package/dist/src/components/display/data/accordion/CwAccordionContainer.js +20 -0
- package/dist/src/components/display/data/generic_tooltip/CwGenericTooltip.d.ts +1 -0
- package/dist/src/components/display/data/generic_tooltip/CwGenericTooltip.d.ts.map +1 -1
- package/dist/src/components/display/data/generic_tooltip/CwGenericTooltip.js +138 -0
- package/dist/src/components/display/data/table/CwTable.d.ts +25 -20
- package/dist/src/components/display/data/table/CwTable.d.ts.map +1 -1
- package/dist/src/components/display/data/table/CwTable.js +203 -0
- package/dist/src/components/display/graphics/icon/CwIcon.d.ts.map +1 -1
- package/dist/src/components/display/graphics/icon/CwIcon.js +23 -0
- package/dist/src/components/display/graphics/icon/svg-icons.d.ts +6 -0
- package/dist/src/components/display/graphics/icon/svg-icons.d.ts.map +1 -0
- package/dist/src/components/display/graphics/loading/CwLoading.js +27 -0
- package/dist/src/components/display/graphics/loading-small/CwLoadingSmall.js +20 -0
- package/dist/src/components/display/text/heading/CwHeadingMain.js +5 -0
- package/dist/src/components/display/text/heading/CwHeadingSecond.js +5 -0
- package/dist/src/components/display/text/label/CwLabel.d.ts +1 -4
- package/dist/src/components/display/text/label/CwLabel.d.ts.map +1 -1
- package/dist/src/components/display/text/label/CwLabel.js +13 -0
- package/dist/src/components/display/text/message/CwMessage.js +75 -0
- package/dist/src/components/display/text/note/CwNote.js +78 -0
- package/dist/src/components/display/text/tag/CwChip.d.ts.map +1 -1
- package/dist/src/components/display/text/tag/CwChip.js +57 -0
- package/dist/src/components/display/text/tag/CwTag.js +21 -0
- package/dist/src/components/display/text/tooltip/CwTooltip.js +4 -0
- package/dist/src/components/layout/align/CwAlign.js +54 -0
- package/dist/src/components/layout/card/CwCard.js +55 -0
- package/dist/src/components/layout/card/CwCardList.js +38 -0
- package/dist/src/components/layout/dialog/CwDialog.d.ts.map +1 -1
- package/dist/src/components/layout/dialog/CwDialog.js +255 -0
- package/dist/src/components/layout/dialog/CwDialogManager.js +44 -0
- package/dist/src/components/layout/list/details/CwExpandable.js +28 -0
- package/dist/src/components/layout/list/key-value/CwKeyValueList.d.ts +2 -3
- package/dist/src/components/layout/list/key-value/CwKeyValueList.d.ts.map +1 -1
- package/dist/src/components/layout/list/key-value/CwKeyValueList.js +23 -0
- package/dist/src/components/layout/list/sortable/CwSortableList.js +73 -0
- package/dist/src/components/layout/list/sortable/useSortableList.js +53 -0
- package/dist/src/components/layout/modal/CwModalReportFunctional.d.ts.map +1 -1
- package/dist/src/components/layout/modal/CwModalReportFunctional.js +23 -0
- package/dist/src/components/layout/modal/hover/CwModalHover.js +61 -0
- package/dist/src/components/layout/modal/legacy/cw_modal.d.ts +4 -0
- package/dist/src/components/layout/modal/legacy/cw_modal.d.ts.map +1 -1
- package/dist/src/components/layout/modal/legacy/cw_modal.js +44 -0
- package/dist/src/components/layout/modal/legacy/cw_modal_confirm.js +39 -0
- package/dist/src/components/layout/modal/legacy/cw_modal_iframe.js +44 -0
- package/dist/src/components/layout/modal/legacy/cw_modal_report.js +26 -0
- package/dist/src/components/layout/table/grouped/CwTableGrouped.js +70 -0
- package/dist/src/components/layout/tabs/CwTabs.d.ts +2 -0
- package/dist/src/components/layout/tabs/CwTabs.d.ts.map +1 -1
- package/dist/src/components/layout/tabs/CwTabs.js +53 -0
- package/dist/src/dev/palette.d.ts +1 -1
- package/dist/src/dev/palette.d.ts.map +1 -1
- package/dist/src/index.d.ts +8 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +187 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/getDefaultDivisions.test.js +48 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/hoursBetween.test.js +15 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/monthDivisions.test.js +42 -0
- package/dist/test/components/custom/new-scheduler/presentation/logic/weekendCalc.test.js +30 -0
- package/dist/test/components/custom/scheduler/addMinutesToDateFromPx.test.js +43 -0
- package/dist/test/components/custom/scheduler/checkIfSlotAvailable.test.js +30 -0
- package/dist/test/components/custom/scheduler/daysBetweenTwoDates.test.js +61 -0
- package/dist/test/components/custom/scheduler/daysBetweenTwoDatesWithoutCeilForEvent.test.js +27 -0
- package/dist/test/components/custom/scheduler/getGUID.test.js +30 -0
- package/dist/test/components/custom/scheduler/getPixelsForEvent.test.js +38 -0
- package/dist/test/components/custom/scheduler/getTimeHeaders.test.js +35 -0
- package/dist/test/components/custom/scheduler/hasSameProperties.test.js +51 -0
- package/dist/test/components/custom/scheduler/isAllowedToMove.test.js +28 -0
- package/dist/test/components/custom/scheduler/listOfDatesToWeeks.test.js +72 -0
- package/dist/test/jest.setup.js +1 -0
- package/package.json +11 -12
- package/dist/assets/asset-DnHaq7m- +0 -50
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-full-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-grad-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-opsz-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-slnt-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-standard-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-wdth-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-xopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-xtra-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-yopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-ytas-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-ytde-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-ytfi-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-ytlc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ext-ytuc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-full-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-grad-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-opsz-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-slnt-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-standard-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-wdth-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-wght-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-xopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-xtra-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-yopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ytas-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ytde-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ytfi-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ytlc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-cyrillic-ytuc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-full-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-grad-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-opsz-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-slnt-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-standard-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-wdth-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-wght-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-xopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-xtra-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-yopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-ytas-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-ytde-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-ytfi-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-ytlc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-greek-ytuc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-full-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-grad-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-opsz-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-slnt-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-standard-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-wdth-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-wght-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-xopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-xtra-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-yopq-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-ytas-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-ytde-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-ytfi-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-ytlc-normal.woff2 +0 -0
- package/dist/content/fonts/roboto-flex/files/roboto-flex-vietnamese-ytuc-normal.woff2 +0 -0
- package/dist/content/icons/cw-icons/css/cw-icons.css +0 -2784
- package/dist/content/icons/cw-icons/fonts/cwAvinodeFont/CblAvinodeIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwAvinodeFont/CblAvinodeIcon.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwAvinodeFont/CblAvinodeIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwAvinodeFont/CblAvinodeIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/CblCrewControl.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/CblCrewControl.svg +0 -38
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/CblCrewControl.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/CblCrewControl.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/CblCrewControl.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/Crew Control.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/Crew Control.svg +0 -29
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/Crew Control.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/Crew Control.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlFont/Crew Control.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblCrewControlReact.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblCrewControlReact.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblCrewControlReact.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblCrewControlReact.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblDutyIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblDutyIcon.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblDutyIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/CblDutyIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/SessionWarning.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/SessionWarning.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/SessionWarning.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/SessionWarning.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblDuty.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblDuty.svg +0 -26
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblDuty.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblDuty.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblDuty.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrol.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrol.svg +0 -13
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrol.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrol.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrolfont.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrolfont.svg +0 -29
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrolfont.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrolfont.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewControlNewIcon/cblcrewcontrolfont.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewFont/Crew.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewFont/Crew.svg +0 -29
- package/dist/content/icons/cw-icons/fonts/cwCrewFont/Crew.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewFont/Crew.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewFont/Crew.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/Crew Planning.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/Crew Planning.svg +0 -17
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/Crew Planning.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/Crew Planning.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/Crew Planning.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewPlanningFont.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewPlanningFont.svg +0 -20
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewPlanningFont.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewPlanningFont.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewPlanningFont.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewSchedulingFont.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewSchedulingFont.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewSchedulingFont.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwCrewPlanningFont/CrewSchedulingFont.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwDispatchFont/Dispatch.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwDispatchFont/Dispatch.svg +0 -20
- package/dist/content/icons/cw-icons/fonts/cwDispatchFont/Dispatch.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwDispatchFont/Dispatch.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwDispatchFont/Dispatch.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/ArchiveEmanual.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/ArchiveEmanual.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/ArchiveEmanual.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/ArchiveEmanual.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/CblEmanualNewIcons.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/CblEmanualNewIcons.svg +0 -14
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/CblEmanualNewIcons.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/CblEmanualNewIcons.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/Emanual.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/Emanual.svg +0 -38
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/Emanual.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/Emanual.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/Emanual.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualApprovedFile.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualApprovedFile.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualApprovedFile.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualApprovedFile.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMark.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMark.svg +0 -17
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMark.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMark.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMark.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMarkLink.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMarkLink.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMarkLink.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualBookMarkLink.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFolder.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFolder.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFolder.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFolder.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFont.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFont.svg +0 -13
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFont.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFont.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFontNew.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFontNew.svg +0 -32
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFontNew.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFontNew.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualFontNew.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPendingIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPendingIcon.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPendingIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPendingIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishFile.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishFile.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishFile.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishFile.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishIconFile.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishIconFile.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishIconFile.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualPublishIconFile.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrash.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrash.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrash.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrash.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrashRight.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrashRight.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrashRight.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/EmanualRestoreTrashRight.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/LibraryIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/LibraryIcon.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/LibraryIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwEmanualFont/LibraryIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/Favorites.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/Favorites.svg +0 -158
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/Favorites.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/Favorites.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/Favorites.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/cwellt_icon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/cwellt_icon.svg +0 -18
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/cwellt_icon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesElement/cwellt_icon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesFont/Favorites.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesFont/Favorites.svg +0 -62
- package/dist/content/icons/cw-icons/fonts/cwFavoritesFont/Favorites.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesFont/Favorites.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesFont/Favorites.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesIcons/CblFavoritesIcons.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesIcons/CblFavoritesIcons.svg +0 -43
- package/dist/content/icons/cw-icons/fonts/cwFavoritesIcons/CblFavoritesIcons.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFavoritesIcons/CblFavoritesIcons.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFgIconsFonts/CblFigIcons.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFgIconsFonts/CblFigIcons.svg +0 -49
- package/dist/content/icons/cw-icons/fonts/cwFgIconsFonts/CblFigIcons.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFgIconsFonts/CblFigIcons.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFlightOpsFont/FlightOps.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFlightOpsFont/FlightOps.svg +0 -41
- package/dist/content/icons/cw-icons/fonts/cwFlightOpsFont/FlightOps.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFlightOpsFont/FlightOps.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwFlightOpsFont/FlightOps.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/CblUndoIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/CblUndoIcon.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/CblUndoIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/CblUndoIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/FlightWatchOnTimeIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/FlightWatchOnTimeIcon.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/FlightWatchOnTimeIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/FlightWatchOnTimeIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/General.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/General.svg +0 -41
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/General.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/General.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/General.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/IDCardStatusIcon.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/IDCardStatusIcon.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/IDCardStatusIcon.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwGeneralFont/IDCardStatusIcon.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/Favorites.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/Favorites.svg +0 -17
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/Favorites.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/Favorites.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/Favorites.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/calculator.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/calculator.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/calculator.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/calculator.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/icons_cwellt.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/icons_cwellt.svg +0 -11
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/icons_cwellt.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwNewGeneralFontIcon/icons_cwellt.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwOpstoolReactFont/opstoolReactIcons.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwOpstoolReactFont/opstoolReactIcons.svg +0 -12
- package/dist/content/icons/cw-icons/fonts/cwOpstoolReactFont/opstoolReactIcons.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwOpstoolReactFont/opstoolReactIcons.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwPaxRelationsFont/Pax Relations.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwPaxRelationsFont/Pax Relations.svg +0 -17
- package/dist/content/icons/cw-icons/fonts/cwPaxRelationsFont/Pax Relations.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwPaxRelationsFont/Pax Relations.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwPaxRelationsFont/Pax Relations.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwSalesFont/Sales.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwSalesFont/Sales.svg +0 -50
- package/dist/content/icons/cw-icons/fonts/cwSalesFont/Sales.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwSalesFont/Sales.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwSalesFont/Sales.woff2 +0 -0
- package/dist/content/icons/cw-icons/fonts/cwTrainingFont/Training.eot +0 -0
- package/dist/content/icons/cw-icons/fonts/cwTrainingFont/Training.svg +0 -17
- package/dist/content/icons/cw-icons/fonts/cwTrainingFont/Training.ttf +0 -0
- package/dist/content/icons/cw-icons/fonts/cwTrainingFont/Training.woff +0 -0
- package/dist/content/icons/cw-icons/fonts/cwTrainingFont/Training.woff2 +0 -0
- package/dist/content/icons/font-awesome/webfonts/fa-brands-400.ttf +0 -0
- package/dist/content/icons/font-awesome/webfonts/fa-regular-400.ttf +0 -0
- package/dist/content/icons/font-awesome/webfonts/fa-solid-900.ttf +0 -0
- package/dist/content/icons/font-awesome/webfonts/fa-v4compatibility.ttf +0 -0
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.js +0 -4836
- package/dist/src/common/functions/reactor.d.ts +0 -2
- package/dist/src/common/functions/reactor.d.ts.map +0 -1
- package/dist/src/components/control/input/chipper/CwChip.d.ts +0 -12
- package/dist/src/components/control/input/chipper/CwChip.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/components/ClearSchedulerButton.d.ts +0 -8
- package/dist/src/components/custom/scheduler/components/ClearSchedulerButton.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/filtering/filterAndProcessResources.d.ts +0 -14
- package/dist/src/components/custom/scheduler/logic/filtering/filterAndProcessResources.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/pixels/calculateMaxPxFromDateRange.d.ts +0 -2
- package/dist/src/components/custom/scheduler/logic/pixels/calculateMaxPxFromDateRange.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/state_handle/handleDateChange.d.ts +0 -5
- package/dist/src/components/custom/scheduler/logic/state_handle/handleDateChange.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/state_handle/handlePropChanges.d.ts +0 -5
- package/dist/src/components/custom/scheduler/logic/state_handle/handlePropChanges.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/state_handle/onResizeEvent.d.ts +0 -3
- package/dist/src/components/custom/scheduler/logic/state_handle/onResizeEvent.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/ui/getHasPropsChanged.d.ts +0 -3
- package/dist/src/components/custom/scheduler/logic/ui/getHasPropsChanged.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/logic/ui/shouldTriggerScroll.d.ts +0 -3
- package/dist/src/components/custom/scheduler/logic/ui/shouldTriggerScroll.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler/state/EventProps.d.ts +0 -7
- package/dist/src/components/custom/scheduler/state/EventProps.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/BackgrounEvent.d.ts +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/BackgrounEvent.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/cancellablePromise.d.ts +0 -7
- package/dist/src/components/custom/scheduler-new/presentation/components/row/cancellablePromise.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/components/row/useCancellablePromise.d.ts +0 -7
- package/dist/src/components/custom/scheduler-new/presentation/components/row/useCancellablePromise.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/logic/separateEventsByResource.d.ts +0 -5
- package/dist/src/components/custom/scheduler-new/presentation/logic/separateEventsByResource.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/external/Event.d.ts +0 -9
- package/dist/src/components/custom/scheduler-new/presentation/state/external/Event.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/external/Row.d.ts +0 -5
- package/dist/src/components/custom/scheduler-new/presentation/state/external/Row.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/EventSideDragState.d.ts +0 -6
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/EventSideDragState.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/HeaderDivision.d.ts +0 -5
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/HeaderDivision.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerEventState.d.ts +0 -14
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerEventState.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerHeaderState.d.ts +0 -11
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerHeaderState.d.ts.map +0 -1
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerRow.d.ts +0 -8
- package/dist/src/components/custom/scheduler-new/presentation/state/ui/SchedulerRow.d.ts.map +0 -1
- package/dist/test/components/custom/newScheduler/presentation/logic/getDefaultDivisions.test.d.ts.map +0 -1
- package/dist/test/components/custom/scheduler/calculateMaxPxFromDateRange.test.d.ts +0 -2
- package/dist/test/components/custom/scheduler/calculateMaxPxFromDateRange.test.d.ts.map +0 -1
- package/dist/test/components/custom/scheduler/filterEvents.test.d.ts.map +0 -1
- package/dist/test/components/custom/scheduler/shouldTriggerScroll.test.d.ts.map +0 -1
- package/dist/test/example.test.d.ts +0 -1
- package/dist/test/example.test.d.ts.map +0 -1
- /package/dist/src/{components/custom/scheduler-new/presentation/TestScheduler.d.ts → common/interfaces/CwSelectListProps.js} +0 -0
- /package/dist/{test/components/custom/newScheduler/presentation/logic/getDefaultDivisions.test.d.ts → src/components/custom/scheduler-new/presentation/components/header/SchedulerHeaderState.js} +0 -0
- /package/dist/{test/components/custom/newScheduler/presentation/logic/hoursBetween.test.d.ts → src/components/custom/scheduler-new/presentation/state/ui/SchedulerState.js} +0 -0
- /package/dist/{test/components/custom/newScheduler/presentation/logic/weekendCalc.test.d.ts → src/components/custom/scheduler-new/presentation/state/ui/WeekRange.js} +0 -0
- /package/dist/{test/components/custom/scheduler/filterEvents.test.d.ts → src/components/custom/scheduler-temporal/state/CwSchedulerProps.js} +0 -0
- /package/dist/{test/components/custom/scheduler/shouldTriggerScroll.test.d.ts → src/components/custom/scheduler-temporal/state/State.js} +0 -0
package/dist/index.es.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { useEffect, useState, useCallback, useRef, useMemo, forwardRef, useLayoutEffect, useImperativeHandle, createElement, memo, Fragment as Fragment$1, Component } from 'react';
|
|
3
|
+
import React__default, { cloneElement, useEffect, useState, useCallback, useRef, useMemo, forwardRef, useLayoutEffect, useImperativeHandle, createElement, memo, Fragment as Fragment$1, Component } from 'react';
|
|
4
4
|
import { createRoot } from 'react-dom/client';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
|
-
import { Tooltip,
|
|
6
|
+
import { Tooltip, Dropdown, Menu } from 'antd';
|
|
7
7
|
import Draggable from 'react-draggable';
|
|
8
8
|
import moment from 'moment';
|
|
9
|
-
import
|
|
9
|
+
import { format } from 'date-fns';
|
|
10
|
+
import { enGB } from 'date-fns/locale';
|
|
11
|
+
import { DayPicker, useNavigation } from 'react-day-picker';
|
|
12
|
+
import 'react-day-picker/dist/style.css';
|
|
13
|
+
import { cloneDeep } from 'lodash-es';
|
|
10
14
|
import { VariableSizeList } from 'react-window';
|
|
11
|
-
import { Palette, Category, Component as Component$1, Variant } from '@react-buddy/ide-toolbox';
|
|
12
15
|
|
|
13
16
|
class CwSelectList {
|
|
14
17
|
type;
|
|
@@ -48,70 +51,16 @@ function CwHeadingSecond(props) {
|
|
|
48
51
|
return (jsx("div", { className: "cw-heading", children: jsx("h3", { className: "cwHeading_desc", ...headingProps, children: children }) }));
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
/**
|
|
52
|
-
* General purpose aligner flex container, useful for column or row view.
|
|
53
|
-
* @remarks
|
|
54
|
-
* ```txt
|
|
55
|
-
* flexDirection="row" (default):
|
|
56
|
-
*
|
|
57
|
-
* <Row A> | - item 1 - item 2 - item 3 |
|
|
58
|
-
* <Row B> | - item 1 - item 2 - item 3 |
|
|
59
|
-
*
|
|
60
|
-
* flexDirection="column":
|
|
61
|
-
*
|
|
62
|
-
* <Col A> <Col B>
|
|
63
|
-
* | - item 1 | - item 1 |
|
|
64
|
-
* | - item 2 | - item 2 |
|
|
65
|
-
* | - item 3 | - item 3 |
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
68
|
-
* @example
|
|
69
|
-
* <CwAlign flexDirection="column">
|
|
70
|
-
* <div>
|
|
71
|
-
* <h2>ColumnA</h2>
|
|
72
|
-
* </div>
|
|
73
|
-
* <div>
|
|
74
|
-
* <h2>ColumnB</h2>
|
|
75
|
-
* </div>
|
|
76
|
-
* </CwAlign>
|
|
77
|
-
*/
|
|
78
|
-
function CwAlign(props) {
|
|
79
|
-
const { alignContent, alignItems, alignSelf, bottom, display, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, cssHeight, justifyContent, left, margin, order, padding, position, right, top, cssWidth, gap, ...divProps } = props;
|
|
80
|
-
return (jsx("div", { className: "cw-align", ...divProps, style: {
|
|
81
|
-
alignContent: alignContent,
|
|
82
|
-
alignItems: alignItems,
|
|
83
|
-
alignSelf: alignSelf,
|
|
84
|
-
bottom: bottom,
|
|
85
|
-
display: display ?? "flex",
|
|
86
|
-
flexBasis: flexBasis,
|
|
87
|
-
flexDirection: flexDirection,
|
|
88
|
-
flexGrow: flexGrow,
|
|
89
|
-
flexShrink: flexShrink,
|
|
90
|
-
flexWrap: flexWrap,
|
|
91
|
-
height: cssHeight,
|
|
92
|
-
justifyContent: justifyContent,
|
|
93
|
-
left: left,
|
|
94
|
-
margin: margin,
|
|
95
|
-
order: order,
|
|
96
|
-
padding: padding,
|
|
97
|
-
position: position,
|
|
98
|
-
right: right,
|
|
99
|
-
top: top,
|
|
100
|
-
width: cssWidth,
|
|
101
|
-
gap: gap
|
|
102
|
-
}, children: props.children }));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
54
|
/**
|
|
106
55
|
* Label for form controls.
|
|
107
56
|
* @example
|
|
108
57
|
* ```tsx
|
|
109
|
-
* <
|
|
58
|
+
* <CwLabel justify="right" >Username:</CwLabel>
|
|
110
59
|
* ```
|
|
111
60
|
*/
|
|
112
61
|
function CwLabel(props) {
|
|
113
|
-
const { justify, text, labelHeight, labelWidth,
|
|
114
|
-
return (jsx("
|
|
62
|
+
const { justify, text, labelHeight, labelWidth, margin, ...labelProps } = props;
|
|
63
|
+
return (jsx("label", { className: "cw-label", style: { textAlign: justify, width: labelWidth, height: labelHeight, margin: margin ?? "1px 0 0 0" }, ...labelProps, children: labelProps.children ?? text }));
|
|
115
64
|
}
|
|
116
65
|
|
|
117
66
|
function CwTooltip(CwelltTooltipProps) {
|
|
@@ -195,6 +144,11 @@ function getContrastColor(color) {
|
|
|
195
144
|
return `hsl(${hsl.h}, ${contrastS}%, ${contrastL}%)`;
|
|
196
145
|
}
|
|
197
146
|
|
|
147
|
+
const SVG_ICONS = {
|
|
148
|
+
'sortable-asc': (jsxs("svg", { width: "16", height: "16", viewBox: "0 0 128 128", fill: "currentColor", children: [jsx("path", { d: "M93.1675 73.1739C94.5691 74.5758 94.7323 76.7924 93.5515 78.3846L93.1675 78.8326L63.6741 108.326L34.1755 78.8326C32.6908 77.3518 32.6014 74.9761 33.9708 73.3881C35.3401 71.8001 37.7033 71.5391 39.3861 72.7899L39.8341 73.1739L63.6741 97.0137L87.5088 73.1739C88.9104 71.7726 91.1274 71.6092 92.7194 72.7899L93.1674 73.1739H93.1675Z", opacity: "0.3" }), jsx("path", { d: "M34.1714 55.1518C32.7697 53.7499 32.6066 51.5333 33.7874 49.9411L34.1714 49.4931L63.6647 20L93.1634 49.4931C94.6481 50.9739 94.7375 53.3496 93.3681 54.9376C91.9987 56.5256 89.6356 56.7866 87.9527 55.5358L87.5047 55.1517L63.6647 31.312L39.8301 55.1518C38.4285 56.5531 36.2115 56.7165 34.6195 55.5358L34.1715 55.1518L34.1714 55.1518Z", opacity: "1" })] })),
|
|
149
|
+
'sortable-desc': (jsxs("svg", { width: "16", height: "16", viewBox: "0 0 128 128", fill: "currentColor", children: [jsx("path", { d: "M93.1675 73.1739C94.5691 74.5758 94.7323 76.7924 93.5515 78.3846L93.1675 78.8326L63.6741 108.326L34.1755 78.8326C32.6908 77.3518 32.6014 74.9761 33.9708 73.3881C35.3401 71.8001 37.7033 71.5391 39.3861 72.7899L39.8341 73.1739L63.6741 97.0137L87.5088 73.1739C88.9104 71.7726 91.1274 71.6092 92.7194 72.7899L93.1674 73.1739H93.1675Z", opacity: "1" }), jsx("path", { d: "M34.1714 55.1518C32.7697 53.7499 32.6066 51.5333 33.7874 49.9411L34.1714 49.4931L63.6647 20L93.1634 49.4931C94.6481 50.9739 94.7375 53.3496 93.3681 54.9376C91.9987 56.5256 89.6356 56.7866 87.9527 55.5358L87.5047 55.1517L63.6647 31.312L39.8301 55.1518C38.4285 56.5531 36.2115 56.7165 34.6195 55.5358L34.1715 55.1518L34.1714 55.1518Z", opacity: "0.3" })] })),
|
|
150
|
+
};
|
|
151
|
+
|
|
198
152
|
/**
|
|
199
153
|
* Icon component that supports both FontAwesome 4 and cwellt icon font
|
|
200
154
|
* @example
|
|
@@ -210,6 +164,12 @@ function CwIcon(props) {
|
|
|
210
164
|
size && `cw-font-size-${size}`
|
|
211
165
|
].filter(Boolean).join(' ');
|
|
212
166
|
};
|
|
167
|
+
// Check if it's a special SVG icon
|
|
168
|
+
if (iconId in SVG_ICONS) {
|
|
169
|
+
const svgElement = SVG_ICONS[iconId];
|
|
170
|
+
const className = getClassName('cw-icon-svg');
|
|
171
|
+
return cloneElement(svgElement, { className });
|
|
172
|
+
}
|
|
213
173
|
// Return appropriate icon based on source
|
|
214
174
|
if (source === 'fontawesome') {
|
|
215
175
|
return jsx("span", { ...iconProps, className: getClassName(`fa fa-${iconId}`) });
|
|
@@ -236,25 +196,15 @@ const CwChip = ({ label, colorScheme = 'info', customColor, variant = 'soft', cl
|
|
|
236
196
|
// Calculate styles based on colorScheme, customColor and variant
|
|
237
197
|
const chipStyle = React__default.useMemo(() => {
|
|
238
198
|
if (customColor) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
// For soft/solid, customColor is used for background and we calculate contrast
|
|
249
|
-
return {
|
|
250
|
-
backgroundColor: customColor,
|
|
251
|
-
color: getContrastColor(customColor),
|
|
252
|
-
...style
|
|
253
|
-
};
|
|
254
|
-
}
|
|
199
|
+
// Simply set the CSS custom properties, CSS handles the rest
|
|
200
|
+
return {
|
|
201
|
+
'--chip-accent': customColor,
|
|
202
|
+
'--chip-text': getContrastColor(customColor),
|
|
203
|
+
...style
|
|
204
|
+
};
|
|
255
205
|
}
|
|
256
206
|
return style;
|
|
257
|
-
}, [
|
|
207
|
+
}, [customColor, style]);
|
|
258
208
|
// Handle click on close icon
|
|
259
209
|
const handleClose = (e) => {
|
|
260
210
|
e.stopPropagation();
|
|
@@ -268,29 +218,9 @@ const CwChip = ({ label, colorScheme = 'info', customColor, variant = 'soft', cl
|
|
|
268
218
|
className,
|
|
269
219
|
closable ? 'cw-chip-closable' : '',
|
|
270
220
|
].filter(Boolean).join(' ');
|
|
271
|
-
return (jsxs("span", { className: chipClassNames, "data-color-scheme": colorScheme, "data-variant": variant, style: chipStyle, children: [icon && jsx(CwIcon, { iconId: icon }), label, closable && (jsx("button", { className: "cw-chip-close-button", onClick: handleClose, "aria-label": "Remove", type: "button", children: jsx("span", { className: "cwi-icons cwi-close" }) }))] }));
|
|
221
|
+
return (jsxs("span", { className: chipClassNames, "data-color-scheme": colorScheme, "data-variant": variant, style: chipStyle, children: [icon && jsx(CwIcon, { iconId: icon }), jsx("span", { children: label }), closable && (jsx("button", { className: "cw-chip-close-button", onClick: handleClose, "aria-label": "Remove", type: "button", children: jsx("span", { className: "cwi-icons cwi-close" }) }))] }));
|
|
272
222
|
};
|
|
273
223
|
|
|
274
|
-
function CwTag(tagProps) {
|
|
275
|
-
const hideTag = (event_clickTag) => {
|
|
276
|
-
const tag = event_clickTag.currentTarget.parentElement;
|
|
277
|
-
tag?.classList.add("tag-hidden");
|
|
278
|
-
};
|
|
279
|
-
const onClickClosableCustomTag = (event_clickClosableT) => {
|
|
280
|
-
hideTag(event_clickClosableT);
|
|
281
|
-
if (tagProps.onClickClosableTag != undefined) {
|
|
282
|
-
tagProps.onClickClosableTag(event_clickClosableT);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
const onClickCustomTag = (event_clickTag) => {
|
|
286
|
-
// click option interface
|
|
287
|
-
if (tagProps.onClickTag !== undefined) {
|
|
288
|
-
tagProps.onClickTag(event_clickTag);
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
return (jsxs("div", { className: "cw-tag", style: tagProps.styleTag, onClick: event_clickTag => onClickCustomTag(event_clickTag), id: tagProps.idTag, ref: tagProps.ref, children: [jsx("strong", { style: tagProps.styleTag_description, children: tagProps.children }), tagProps.closableTag && (jsx(CwIcon, { iconId: "close", onClick: event_clickClosableT => onClickClosableCustomTag(event_clickClosableT) }))] }));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
224
|
const CW_DEFAULT_MESSAGE_DURATION = 2000;
|
|
295
225
|
var CwMessageType;
|
|
296
226
|
(function (CwMessageType) {
|
|
@@ -689,7 +619,7 @@ function CwLoadingSmall(CwelltLoadingAppointements) {
|
|
|
689
619
|
jsx("div", {})) }));
|
|
690
620
|
}
|
|
691
621
|
|
|
692
|
-
var styles$
|
|
622
|
+
var styles$k = {"cw-generic-tooltip-content":"cw-generic-tooltip-module_cw-generic-tooltip-content__la-Si","cw-generic-tooltip":"cw-generic-tooltip-module_cw-generic-tooltip__Ij76M"};
|
|
693
623
|
|
|
694
624
|
// Constants moved outside to prevent recreation
|
|
695
625
|
const margin = 16;
|
|
@@ -794,18 +724,18 @@ const useTooltipPosition = (isVisible, containerRef, preferredPosition, tooltipC
|
|
|
794
724
|
return tooltipState;
|
|
795
725
|
};
|
|
796
726
|
// Main component with optimizations
|
|
797
|
-
const CwGenericTooltip = ({ children, content = null, position = defaultPosition, dissapearsWhenHover = false, hide = false, overlayStyle = {}, showDelay = 0, }) => {
|
|
727
|
+
const CwGenericTooltip = ({ children, content = null, position = defaultPosition, dissapearsWhenHover = false, hide = false, overlayStyle = {}, showDelay = 0, displayInline = false, }) => {
|
|
798
728
|
const [isVisible, setIsVisible] = useState(false);
|
|
799
729
|
const containerRef = useRef(null);
|
|
800
730
|
const { setTooltipTimeout, clearTooltipTimeout } = useTooltipDelay(() => {
|
|
801
731
|
setIsVisible(true);
|
|
802
732
|
}, showDelay);
|
|
803
|
-
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$
|
|
733
|
+
const { position: tooltipPosition, actualPosition } = useTooltipPosition(isVisible, containerRef, position, styles$k["cw-generic-tooltip-content"]);
|
|
804
734
|
// Memoize tooltip content creation
|
|
805
735
|
const tooltipContent = useMemo(() => {
|
|
806
736
|
if (hide || !isVisible || !content)
|
|
807
737
|
return null;
|
|
808
|
-
return createPortal(jsx("div", { className: styles$
|
|
738
|
+
return createPortal(jsx("div", { className: styles$k["cw-generic-tooltip-content"], "data-position": actualPosition, "data-visible": isVisible, "data-inline": displayInline, style: {
|
|
809
739
|
position: 'fixed',
|
|
810
740
|
top: `${tooltipPosition.top}px`,
|
|
811
741
|
left: `${tooltipPosition.left}px`,
|
|
@@ -820,10 +750,14 @@ const CwGenericTooltip = ({ children, content = null, position = defaultPosition
|
|
|
820
750
|
clearTooltipTimeout();
|
|
821
751
|
setIsVisible(false);
|
|
822
752
|
}, [clearTooltipTimeout]);
|
|
823
|
-
return (jsxs("div", { ref: containerRef, className: styles$
|
|
753
|
+
return (jsxs("div", { ref: containerRef, className: styles$k["cw-generic-tooltip"], onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: overlayStyle, "data-inline": displayInline, children: [tooltipContent, children] }));
|
|
824
754
|
};
|
|
825
755
|
|
|
826
756
|
// Reference for draggable modal
|
|
757
|
+
/**
|
|
758
|
+
* **Note:** For new development, we recommend using {@link CwDialog} instead. CwModal remains supported for existing code.
|
|
759
|
+
* @see {@link CwDialog}
|
|
760
|
+
*/
|
|
827
761
|
function CwModal(custModalProps) {
|
|
828
762
|
const draggableRef = useRef(null);
|
|
829
763
|
// Hooks [ modal draggable ]
|
|
@@ -857,13 +791,13 @@ function CwModal(custModalProps) {
|
|
|
857
791
|
};
|
|
858
792
|
return (jsx("div", { children: custModalProps.modalState && (jsxs("div", { className: custModalProps.classNameModalOverlay + " cwelltModalOverlay", children: [jsx("div", { className: "cwelltModalOverlayBg", onClick: custModalProps.onCloseModal }), jsx(Draggable, { disabled: isModalDisabled, axis: "both", nodeRef: draggableRef, children: jsxs("div", { className: custModalProps.classNameModal + " cwelltContainerModal", ref: draggableRef, style: widthModalDef !== "40em" ? modalStyle.widthCustomStyle : modalStyle.widthDefStyle, children: [jsxs("div", { className: "cwelltModalHeader", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsx("div", { className: "cwelltModalTitle", children: custModalProps.titleModal }), jsx("button", { className: "cwelltBtnCloseModal", onClick: custModalProps.onCloseModal, children: jsx("span", { className: "cwelltCloseIcon" }) })] }), jsx("div", { className: "cwelltModalBody", children: jsx("div", { className: "cwelltContainerModalBody", style: { position: "relative" }, children: custModalProps.children }) }), isHide === false ? (
|
|
859
793
|
// [ false : show modal ]
|
|
860
|
-
jsxs("div", { className: "cwelltModalFooter", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsx(Tooltip, { placement: "bottom", title: "Save", color: "#368ee0", children: jsx("div", { className: "cwellt_flex cwellt_justify_center
|
|
794
|
+
jsxs("div", { className: "cwelltModalFooter", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsx(Tooltip, { placement: "bottom", title: "Save", color: "#368ee0", children: jsx("div", { className: "cwellt_flex cwellt_justify_center ", style: { width: "2em" }, children: jsx("button", { className: "cw-button-icon cwi-save", onClick: custModalProps.onSaveModal, form: custModalProps.formSaveModal, hidden: custModalProps.HideBtnModal, type: custModalProps.HtmlSubmitModal }) }) }), isShowcustButton === true ? (jsx(Tooltip, { placement: "bottom", title: custModalProps.custButtonTitle, color: custModalProps.custColorButtonTooltip, children: jsx("div", { className: "cwellt_flex cwellt_justify_center", style: { width: "2em" }, children: jsx("button", { className: "cw-button-icon " +
|
|
861
795
|
custModalProps.custButtonClassName, onClick: custModalProps.custButtonClick }) }) })) : (jsx("div", {}))] })) : (
|
|
862
796
|
// true [ do not show the modal ]
|
|
863
797
|
jsx("div", { style: { display: "none" } }))] }) })] })) }));
|
|
864
798
|
}
|
|
865
799
|
|
|
866
|
-
var styles$
|
|
800
|
+
var styles$j = {"overlayPositioned":"CwConfirmationPopup-module_overlayPositioned__11qYB","popup":"CwConfirmationPopup-module_popup__ahPjM","message":"CwConfirmationPopup-module_message__MnNL4","buttons":"CwConfirmationPopup-module_buttons__fGYYE","button":"CwConfirmationPopup-module_button__ugYQE","confirmButton":"CwConfirmationPopup-module_confirmButton__rTP4S","cancelButton":"CwConfirmationPopup-module_cancelButton__Ry694"};
|
|
867
801
|
|
|
868
802
|
function CwConfirmationPopup(props) {
|
|
869
803
|
const { isOpen, onConfirm, onCancel, message = "Are you sure you want to proceed?", confirmText = "Confirm", cancelText = "Cancel", placement = 'bottom', children } = props;
|
|
@@ -927,91 +861,30 @@ function CwConfirmationPopup(props) {
|
|
|
927
861
|
onCancel();
|
|
928
862
|
}
|
|
929
863
|
};
|
|
930
|
-
return (jsxs(Fragment, { children: [renderChildren(), isOpen && (jsx("div", { className: styles$
|
|
864
|
+
return (jsxs(Fragment, { children: [renderChildren(), isOpen && (jsx("div", { className: styles$j.overlayPositioned, onClick: handleOverlayClick, children: jsxs("div", { ref: popupRef, className: styles$j.popup, style: {
|
|
931
865
|
position: 'absolute',
|
|
932
866
|
top: `${position.top}px`,
|
|
933
867
|
left: `${position.left}px`,
|
|
934
868
|
transform: 'none'
|
|
935
|
-
}, children: [jsx("p", { className: styles$
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
// Reference for draggable modal
|
|
939
|
-
const draggableRef = React__default.createRef();
|
|
940
|
-
function CwModalConfirm(custModalProps) {
|
|
941
|
-
const classNameOverlay = custModalProps.classNameModalOverlay !== null || custModalProps.classNameModalOverlay !== undefined
|
|
942
|
-
? ""
|
|
943
|
-
: custModalProps.classNameModalOverlay;
|
|
944
|
-
// Default size of modal
|
|
945
|
-
const widthModalDef = custModalProps.widthModalConfirm !== null && custModalProps.widthModalConfirm !== undefined
|
|
946
|
-
? custModalProps.widthModalConfirm
|
|
947
|
-
: "17em";
|
|
948
|
-
const modalStyle = {
|
|
949
|
-
// width default
|
|
950
|
-
widthDefStyle: {
|
|
951
|
-
width: "17em"
|
|
952
|
-
},
|
|
953
|
-
// width customizable
|
|
954
|
-
widthCustomStyle: {
|
|
955
|
-
width: custModalProps.widthModalConfirm
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
// Hooks [ modal draggable ]
|
|
959
|
-
const [ismodalDisabled, setModalDisabled] = useState(true);
|
|
960
|
-
// [ onMouseOver ]
|
|
961
|
-
const cwelltOnMouseOverModal = () => {
|
|
962
|
-
setModalDisabled(false);
|
|
963
|
-
};
|
|
964
|
-
// [ OnMouseOut ]
|
|
965
|
-
const cwelltOnMouseOutModal = () => {
|
|
966
|
-
setModalDisabled(true);
|
|
967
|
-
// finding parent element
|
|
968
|
-
};
|
|
969
|
-
return (jsx("div", { children: custModalProps.modalStateConfirm && (jsx("div", { className: classNameOverlay !== undefined ? custModalProps.classNameModalOverlay + " cwelltModalOverlay" : "", children: jsx(Draggable, { disabled: ismodalDisabled, children: jsxs("div", { className: " cwelltContainerModal", ref: draggableRef, style: widthModalDef !== "17em" ? modalStyle.widthCustomStyle : modalStyle.widthDefStyle, children: [jsxs("div", { className: "cwelltModalHeader", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: [jsx("div", { className: "cwelltModalTitle", children: custModalProps.headerTextConfirm }), jsx("button", { className: "cwelltBtnCloseModal", onClick: custModalProps.onCloseModalConfirm, children: jsx("span", { className: "cwelltCloseIcon" }) })] }), jsx("div", { className: "cwelltModalBody", children: jsxs("div", { className: "cwelltContainerModalBody", children: [jsx("div", { className: "cwellt_content_r_df_align", children: jsx("label", { className: "cwellt_modalConfirmDesc", children: custModalProps.descriptionModalConfirm }) }), jsx("div", { style: { display: "none" }, children: custModalProps.children })] }) }), jsx("div", { className: "cwelltModalFooter", onMouseOver: cwelltOnMouseOverModal, onMouseOut: cwelltOnMouseOutModal, children: jsx(Tooltip, { placement: "bottom", title: custModalProps.confirmText, color: "#368ee0", children: jsx("div", { className: "cwellt_flex cwellt_justify_center", style: { width: "2em" }, children: jsx("button", { className: "btnModalFooterAction cwellt_btn_act cwellt_btn_act_df cwellt_btn_Nbg " +
|
|
970
|
-
custModalProps.confirmClassName, onClick: custModalProps.onClickActionModalConfirm }) }) }) })] }) }) })) }));
|
|
869
|
+
}, children: [jsx("p", { className: styles$j.message, children: message }), jsxs("div", { className: styles$j.buttons, children: [jsx("button", { className: `${styles$j.button} ${styles$j.confirmButton}`, onClick: onConfirm, children: confirmText }), jsx("button", { className: `${styles$j.button} ${styles$j.cancelButton}`, onClick: onCancel, children: cancelText })] })] }) }))] }));
|
|
971
870
|
}
|
|
972
871
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
}
|
|
872
|
+
function CwButton({ text, variant = 'solid', color = 'primary', className = '', icon = "", title, tooltipPosition = "bottom", children, ...buttonProps }) {
|
|
873
|
+
// Build CSS classes based on variant and props
|
|
874
|
+
let buttonClass = `cw-button-${variant}`;
|
|
875
|
+
// Add icon class only for icon variant without children
|
|
876
|
+
if (variant === 'icon' && icon && !children) {
|
|
877
|
+
buttonClass += ` cwi-${icon}`;
|
|
979
878
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
handleCancel = () => {
|
|
983
|
-
this.props.SET_IFRAME_VISIBLE(false);
|
|
984
|
-
};
|
|
985
|
-
render() {
|
|
986
|
-
const { disabled } = this.state;
|
|
987
|
-
return (jsx(Modal
|
|
988
|
-
// title={this.props.title}
|
|
989
|
-
, {
|
|
990
|
-
// title={this.props.title}
|
|
991
|
-
title: jsx("div", { style: {
|
|
992
|
-
width: "100%",
|
|
993
|
-
cursor: "move"
|
|
994
|
-
}, onMouseOver: () => {
|
|
995
|
-
if (this.state.disabled) {
|
|
996
|
-
this.setState({
|
|
997
|
-
disabled: false
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
}, onMouseOut: () => {
|
|
1001
|
-
this.setState({
|
|
1002
|
-
disabled: true
|
|
1003
|
-
});
|
|
1004
|
-
}, children: this.props.title }), visible: this.props.visible, width: this.props.width, footer: null, bodyStyle: {
|
|
1005
|
-
padding: 0,
|
|
1006
|
-
width: this.props.width + "px",
|
|
1007
|
-
height: this.props.height + "px"
|
|
1008
|
-
}, onCancel: () => {
|
|
1009
|
-
this.handleCancel();
|
|
1010
|
-
}, destroyOnClose: true, modalRender: modal => (jsx(Draggable, { disabled: disabled, children: jsxs("div", { ref: this.draggableRef, children: [" ", modal] }) })), children: jsx("div", { className: "videoWrapper", children: jsx("iframe", { id: "iframeAspx", title: this.props.title, src: this.props.cblConfig + "/SSO/SSORedirect?url=" + encodeURIComponent(this.props.url) }) }) }));
|
|
879
|
+
if (className) {
|
|
880
|
+
buttonClass += ` ${className}`;
|
|
1011
881
|
}
|
|
882
|
+
const tooltipContent = title || (variant === 'icon' && text ? text : undefined);
|
|
883
|
+
const buttonElement = (jsx("button", { type: "button", className: buttonClass, ...buttonProps, "data-color": color, "aria-label": tooltipContent, children: variant === 'icon' ? null : (children ?? (jsxs(Fragment, { children: [icon && jsx(CwIcon, { iconId: icon }), text && jsx("strong", { children: text })] }))) }));
|
|
884
|
+
return tooltipContent ? (jsx(CwGenericTooltip, { content: tooltipContent, position: tooltipPosition, displayInline: true, children: buttonElement })) : (buttonElement);
|
|
1012
885
|
}
|
|
1013
886
|
|
|
1014
|
-
var styles$
|
|
887
|
+
var styles$i = {"cw-dialog-main":"cw-dialog-module_cw-dialog-main__cHxHt","cw-dialog-button-close":"cw-dialog-module_cw-dialog-button-close__9GRd8"};
|
|
1015
888
|
|
|
1016
889
|
// Helper function to parse size values
|
|
1017
890
|
const parseSize = (size) => {
|
|
@@ -1052,6 +925,8 @@ const convertFromPx = (px, unit) => {
|
|
|
1052
925
|
const CwDialog = props => {
|
|
1053
926
|
const { customFooter, customHeader, headline, width, height, dialogSize, scrim, onSave, onClose, hideFooter, children, open, autoReposition = false, ...domProps } = props;
|
|
1054
927
|
const dialogRef = useRef(null);
|
|
928
|
+
const [isPressingScrim, setIsPressingScrim] = useState(false);
|
|
929
|
+
const pressTimerRef = useRef(0);
|
|
1055
930
|
const initialSetup = useMemo(() => {
|
|
1056
931
|
// Default width and height with units
|
|
1057
932
|
const defaultWidth = 800;
|
|
@@ -1222,14 +1097,34 @@ const CwDialog = props => {
|
|
|
1222
1097
|
e.stopPropagation();
|
|
1223
1098
|
setResizeDirection(direction);
|
|
1224
1099
|
}, []);
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1100
|
+
// Click on scrim
|
|
1101
|
+
const handleScrimMouseDown = useCallback((e) => {
|
|
1102
|
+
if (e.target !== e.currentTarget)
|
|
1103
|
+
return;
|
|
1104
|
+
setIsPressingScrim(true);
|
|
1105
|
+
pressTimerRef.current = window.setTimeout(() => {
|
|
1106
|
+
if (onClose) {
|
|
1107
|
+
onClose();
|
|
1108
|
+
}
|
|
1109
|
+
}, 500);
|
|
1229
1110
|
}, [onClose]);
|
|
1230
|
-
const
|
|
1111
|
+
const handleScrimMouseUpOrLeave = useCallback(() => {
|
|
1112
|
+
if (pressTimerRef.current) {
|
|
1113
|
+
window.clearTimeout(pressTimerRef.current);
|
|
1114
|
+
}
|
|
1115
|
+
setIsPressingScrim(false);
|
|
1116
|
+
}, []);
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
if (!open) {
|
|
1119
|
+
setIsPressingScrim(false);
|
|
1120
|
+
if (pressTimerRef.current) {
|
|
1121
|
+
window.clearTimeout(pressTimerRef.current);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}, [open]);
|
|
1125
|
+
const header = useMemo(() => (jsxs("header", { onMouseDown: handleMouseDown, children: [jsx("span", { children: headline }), customHeader || (jsx("button", { className: styles$i["cw-dialog-button-close"], onClick: onClose }))] })), [handleMouseDown, headline, customHeader, onClose]);
|
|
1231
1126
|
const content = useMemo(() => (jsx("section", { children: children })), [children]);
|
|
1232
|
-
const footer = useMemo(() => (jsx("footer", { children: customFooter || (jsx(
|
|
1127
|
+
const footer = useMemo(() => (jsx("footer", { children: customFooter || (jsx(CwButton, { variant: "icon", icon: "save", title: "Save", onClick: onSave, tooltipPosition: "top" })) })), [customFooter, onSave]);
|
|
1233
1128
|
const resizeHandles = useMemo(() => size.autoHeight
|
|
1234
1129
|
? [
|
|
1235
1130
|
// Only horizontal handles if autoHeight is true
|
|
@@ -1256,7 +1151,7 @@ const CwDialog = props => {
|
|
|
1256
1151
|
: `${convertFromPx(size.height, size.heightUnit)}${size.heightUnit}`;
|
|
1257
1152
|
return { displayWidth, displayHeight };
|
|
1258
1153
|
}, [size.width, size.height, size.widthUnit, size.heightUnit, size.autoHeight]);
|
|
1259
|
-
const dialogContent = (jsx("div", { "data-has-scrim": hasScrim, className: styles$
|
|
1154
|
+
const dialogContent = (jsx("div", { "data-has-scrim": hasScrim, className: styles$i["cw-dialog-main"], onMouseDown: handleScrimMouseDown, onMouseUp: handleScrimMouseUpOrLeave, onMouseLeave: handleScrimMouseUpOrLeave, "data-pressing": isPressingScrim, children: jsxs("dialog", { ...domProps, ref: dialogRef, style: {
|
|
1260
1155
|
left: `${position.x}px`,
|
|
1261
1156
|
top: `${position.y}px`,
|
|
1262
1157
|
width: displayDimensions.displayWidth,
|
|
@@ -1283,7 +1178,7 @@ const CwModalReportFunctional = (props) => {
|
|
|
1283
1178
|
return (jsxs("div", { children: ["Please add a(n) ", props.reportName, " report in ", props.moduleSettings, " Settings"] }));
|
|
1284
1179
|
}
|
|
1285
1180
|
};
|
|
1286
|
-
return (jsx("div", { id: "
|
|
1181
|
+
return (jsx("div", { id: "modal-report-content", children: isModal ? (jsx(CwDialog, { open: props.visible, width: props.width, height: props.height, headline: props.title, onClose: props.onCloseModal, hideFooter: true, className: "modal-report-content", children: renderContentModal() })) : (jsx("div", { children: renderContentNotModal() })) }));
|
|
1287
1182
|
};
|
|
1288
1183
|
|
|
1289
1184
|
class CwReportModal extends React.Component {
|
|
@@ -1303,10 +1198,10 @@ class CwReportModal extends React.Component {
|
|
|
1303
1198
|
};
|
|
1304
1199
|
}
|
|
1305
1200
|
render() {
|
|
1306
|
-
return (jsx("div", { id: "
|
|
1201
|
+
return (jsx("div", { id: "modal-report-content", children: this.state.isModal === true ? (jsxs(CwDialog, { open: this.props.visible, width: this.props.width, height: this.props.height, headline: this.props.title, onClose: () => {
|
|
1307
1202
|
this.formRef?.current?.resetFields();
|
|
1308
1203
|
this.props.SET_MODAL_REPORT_VISIBLE(false);
|
|
1309
|
-
}, hideFooter: true, children: [this.props.name !== "Empty.pdf" && (jsx("div", { style: { width: "100%", height: "100%", overflowX: "auto", overflowY: "auto" }, children: jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", style: { width: "100%", height: "100%", display: "block" } }) })), this.props.name === "Empty.pdf" && (jsx("div", { children: jsxs("h1", { style: { marginLeft: "2em" }, children: [" ", "Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }) }))] })) : (jsxs("div", { children: [this.props.name !== "Empty.pdf" && (jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", width: "100%", height: "
|
|
1204
|
+
}, hideFooter: true, className: "modal-report-content", children: [this.props.name !== "Empty.pdf" && (jsx("div", { style: { width: "100%", height: "100%", overflowX: "auto", overflowY: "auto" }, children: jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", style: { width: "100%", height: "100%", display: "block" } }) })), this.props.name === "Empty.pdf" && (jsx("div", { children: jsxs("h1", { style: { marginLeft: "2em" }, children: [" ", "Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }) }))] })) : (jsxs("div", { children: [this.props.name !== "Empty.pdf" && (jsx("embed", { src: "data:application/pdf;base64," + this.props.content, type: "application/pdf", width: "100%", height: "800px" })), this.props.name === "Empty.pdf" && (jsxs("div", { children: ["Please add a(n) ", this.props.reportName, " report in ", this.props.moduleSettings, " Settings"] }))] })) }));
|
|
1310
1205
|
}
|
|
1311
1206
|
}
|
|
1312
1207
|
|
|
@@ -1407,20 +1302,61 @@ class CwDialogManager {
|
|
|
1407
1302
|
}
|
|
1408
1303
|
}
|
|
1409
1304
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1305
|
+
/**
|
|
1306
|
+
* General purpose aligner flex container, useful for column or row view.
|
|
1307
|
+
* @remarks
|
|
1308
|
+
* ```txt
|
|
1309
|
+
* flexDirection="row" (default):
|
|
1310
|
+
*
|
|
1311
|
+
* <Row A> | - item 1 - item 2 - item 3 |
|
|
1312
|
+
* <Row B> | - item 1 - item 2 - item 3 |
|
|
1313
|
+
*
|
|
1314
|
+
* flexDirection="column":
|
|
1315
|
+
*
|
|
1316
|
+
* <Col A> <Col B>
|
|
1317
|
+
* | - item 1 | - item 1 |
|
|
1318
|
+
* | - item 2 | - item 2 |
|
|
1319
|
+
* | - item 3 | - item 3 |
|
|
1320
|
+
*
|
|
1321
|
+
* ```
|
|
1322
|
+
* @example
|
|
1323
|
+
* <CwAlign flexDirection="column">
|
|
1324
|
+
* <div>
|
|
1325
|
+
* <h2>ColumnA</h2>
|
|
1326
|
+
* </div>
|
|
1327
|
+
* <div>
|
|
1328
|
+
* <h2>ColumnB</h2>
|
|
1329
|
+
* </div>
|
|
1330
|
+
* </CwAlign>
|
|
1331
|
+
*/
|
|
1332
|
+
function CwAlign(props) {
|
|
1333
|
+
const { alignContent, alignItems, alignSelf, bottom, display, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, cssHeight, justifyContent, left, margin, order, padding, position, right, top, cssWidth, gap, ...divProps } = props;
|
|
1334
|
+
return (jsx("div", { className: "cw-align", ...divProps, style: {
|
|
1335
|
+
alignContent: alignContent,
|
|
1336
|
+
alignItems: alignItems,
|
|
1337
|
+
alignSelf: alignSelf,
|
|
1338
|
+
bottom: bottom,
|
|
1339
|
+
display: display ?? "flex",
|
|
1340
|
+
flexBasis: flexBasis,
|
|
1341
|
+
flexDirection: flexDirection,
|
|
1342
|
+
flexGrow: flexGrow,
|
|
1343
|
+
flexShrink: flexShrink,
|
|
1344
|
+
flexWrap: flexWrap,
|
|
1345
|
+
height: cssHeight,
|
|
1346
|
+
justifyContent: justifyContent,
|
|
1347
|
+
left: left,
|
|
1348
|
+
margin: margin,
|
|
1349
|
+
order: order,
|
|
1350
|
+
padding: padding,
|
|
1351
|
+
position: position,
|
|
1352
|
+
right: right,
|
|
1353
|
+
top: top,
|
|
1354
|
+
width: cssWidth,
|
|
1355
|
+
gap: gap
|
|
1356
|
+
}, children: props.children }));
|
|
1421
1357
|
}
|
|
1422
1358
|
|
|
1423
|
-
var styles$
|
|
1359
|
+
var styles$h = {"card":"cw-card-module_card__HJUT0","clickable":"cw-card-module_clickable__Y-V3X","disabled":"cw-card-module_disabled__0wHh1","loading":"cw-card-module_loading__-fzlx","content":"cw-card-module_content__ma9qy","headerContent":"cw-card-module_headerContent__x4Jfl","footerTags":"cw-card-module_footerTags__80sSW","loadingOverlay":"cw-card-module_loadingOverlay__8-zVV"};
|
|
1424
1360
|
|
|
1425
1361
|
/**
|
|
1426
1362
|
* CwCard - A simple card component for displaying content in a contained format
|
|
@@ -1444,11 +1380,11 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1444
1380
|
// Construct class names using CSS modules
|
|
1445
1381
|
const cardClassNames = [
|
|
1446
1382
|
'cw-card',
|
|
1447
|
-
styles$
|
|
1383
|
+
styles$h.card,
|
|
1448
1384
|
className,
|
|
1449
|
-
clickable ? styles$
|
|
1450
|
-
disabled ? styles$
|
|
1451
|
-
isLoading ? styles$
|
|
1385
|
+
clickable ? styles$h.clickable : '',
|
|
1386
|
+
disabled ? styles$h.disabled : '',
|
|
1387
|
+
isLoading ? styles$h.loading : '',
|
|
1452
1388
|
].filter(Boolean).join(' ');
|
|
1453
1389
|
// Handle click event when card is clickable
|
|
1454
1390
|
const handleClick = () => {
|
|
@@ -1465,15 +1401,15 @@ const CwCard = ({ id, title, subtitle, alignment = 'center', children, footer, o
|
|
|
1465
1401
|
// Determine if footer should be rendered
|
|
1466
1402
|
const hasFooter = hasChips || footer || (hasActions && direction === "row");
|
|
1467
1403
|
// Actions component to reuse
|
|
1468
|
-
const ActionsComponent = hasActions && !disabled ? (jsxs("div", { className: styles$
|
|
1404
|
+
const ActionsComponent = hasActions && !disabled ? (jsxs("div", { className: styles$h.actions, children: [extraActions ?? null, onEdit && jsx(CwButton, { variant: "icon", icon: "edit", onClick: onEdit }), onDelete && jsx(CwButton, { variant: "icon", icon: "delete", color: "danger", onClick: onDelete })] })) : null;
|
|
1469
1405
|
return (jsxs("div", { ...(id && { id }), className: cardClassNames, ...(style && { style }), ...(clickable && {
|
|
1470
1406
|
role: 'button',
|
|
1471
1407
|
tabIndex: 0,
|
|
1472
1408
|
onClick: handleClick,
|
|
1473
|
-
}), "data-variant": variant, "data-direction": direction, children: [hasHeader && (jsxs("header", { children: [(title || subtitle) && (jsxs("div", { className: styles$
|
|
1409
|
+
}), "data-variant": variant, "data-direction": direction, children: [hasHeader && (jsxs("header", { children: [(title || subtitle) && (jsxs("div", { className: styles$h.headerContent, "data-alignment": alignment, children: [title && jsx("h5", { children: title }), subtitle && jsx("strong", { children: subtitle })] })), direction === "column" && ActionsComponent] })), jsx("div", { className: styles$h.content, children: children }), hasFooter && (jsxs("footer", { children: [hasChips && (jsx("div", { className: styles$h.footerTags, children: chips.map((chip, index) => (jsx(CwChip, { label: chip.label, colorScheme: chip.colorScheme, className: styles$h.chip, ...(chip.customColor && { customColor: chip.customColor }), ...(chip.variant && { variant: chip.variant }), ...(chip.icon && { icon: chip.icon }) }, index))) })), footer && (jsx("div", { className: styles$h.footerContent, children: footer }))] })), direction === "row" && ActionsComponent, isLoading && (jsx("div", { className: styles$h.loadingOverlay, children: jsx(CwLoading, { isLoading: isLoading, size: "small" }) }))] }));
|
|
1474
1410
|
};
|
|
1475
1411
|
|
|
1476
|
-
var styles$
|
|
1412
|
+
var styles$g = {"cardContainer":"cw-card-list-module_cardContainer__l3YEh","pagination":"cw-card-list-module_pagination__5Ay78","pageInfo":"cw-card-list-module_pageInfo__uiMel","loading":"cw-card-list-module_loading__cYpND","emptyState":"cw-card-list-module_emptyState__RlqiS","sortControls":"cw-card-list-module_sortControls__mWgZA"};
|
|
1477
1413
|
|
|
1478
1414
|
function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', defaultCardWidth = 320, cardGap = 16, isLoading = false, emptyState, sortOptions = [], defaultSortKey, ...htmlProps }) {
|
|
1479
1415
|
const [currentPage, setCurrentPage] = useState(1);
|
|
@@ -1507,10 +1443,10 @@ function CwCardList({ items, renderCard, pageSize = 10, layout = 'grid', default
|
|
|
1507
1443
|
'--card-width': `${defaultCardWidth}px`,
|
|
1508
1444
|
'--card-gap': `${cardGap}px`
|
|
1509
1445
|
};
|
|
1510
|
-
return (jsxs("div", { ...htmlProps, children: [sortOptions.length > 0 && (jsxs("div", { className: styles$
|
|
1446
|
+
return (jsxs("div", { ...htmlProps, children: [sortOptions.length > 0 && (jsxs("div", { className: styles$g.sortControls, children: [jsx("label", { htmlFor: "cardlist-sort-select", children: "Sort by:" }), jsx("select", { id: "cardlist-sort-select", value: sortKey, onChange: (e) => handleSortChange(e.target.value), className: styles$g.sortSelect, children: sortOptions.map(option => (jsx("option", { value: option.key, children: option.label }, option.key))) }), jsx("button", { onClick: () => setSortDirection(prev => prev === 'asc' ? 'desc' : 'asc'), className: `cw-button-icon ${sortDirection === 'asc' ? 'cwi-arrow-up' : 'cwi-arrow-down'}`, title: `Sort ${sortDirection === 'asc' ? 'descending' : 'ascending'}` })] })), isLoading ? (jsx("div", { className: styles$g.loading, children: jsx(CwLoading, { isLoading: isLoading }) })) : sortedItems.length === 0 ? (jsx("div", { className: styles$g.emptyState, children: emptyState || jsx("p", { children: "No items to display" }) })) : (jsxs(Fragment, { children: [jsx("div", { className: `${styles$g.cardContainer}`, "data-layout": layout, style: gridStyle, children: visibleItems.map((item, index) => (jsx("div", { className: styles$g.cardWrapper, children: renderCard(item, index) }, index))) }), totalPages > 1 && (jsxs("div", { className: styles$g.pagination, children: [jsx("button", { disabled: currentPage === 1, onClick: () => setCurrentPage(p => Math.max(1, p - 1)), className: "cw-button-icon cwi-chevron-left" }), jsxs("span", { className: styles$g.pageInfo, children: [currentPage, " of ", totalPages] }), jsx("button", { disabled: currentPage === totalPages, onClick: () => setCurrentPage(p => Math.min(totalPages, p + 1)), className: "cw-button-icon cwi-chevron-right" })] }))] }))] }));
|
|
1511
1447
|
}
|
|
1512
1448
|
|
|
1513
|
-
var styles$
|
|
1449
|
+
var styles$f = {"cw-accordion":"cw-accordion-module_cw-accordion__ErvlW","cw-accordion-body":"cw-accordion-module_cw-accordion-body__xlI8b"};
|
|
1514
1450
|
|
|
1515
1451
|
/**
|
|
1516
1452
|
*
|
|
@@ -1527,7 +1463,7 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
1527
1463
|
setVisible_accordionBody(!isVisible_accordionBody);
|
|
1528
1464
|
};
|
|
1529
1465
|
// #endregion
|
|
1530
|
-
return (jsxs("div", { className: styles$
|
|
1466
|
+
return (jsxs("div", { className: styles$f["cw-accordion"], style: CwelltAccordionContainerProps.style, "data-open": isVisible_accordionBody, children: [jsxs("header", { onClick: () => showAccordionBody(), children: [jsx("div", { children: CwelltAccordionContainerProps.desc_text }), jsx("button", { className: "cw-button-icon" })] }), jsx("div", { className: styles$f["cw-accordion-body"], children: CwelltAccordionContainerProps.children })] }));
|
|
1531
1467
|
}
|
|
1532
1468
|
|
|
1533
1469
|
/**
|
|
@@ -1538,23 +1474,23 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
1538
1474
|
* @example
|
|
1539
1475
|
* const columns: Column<User>[] = [
|
|
1540
1476
|
* {
|
|
1541
|
-
* title:
|
|
1542
|
-
* dataIndex:
|
|
1543
|
-
* key:
|
|
1477
|
+
* title: "Name",
|
|
1478
|
+
* dataIndex: "name",
|
|
1479
|
+
* key: "name",
|
|
1544
1480
|
* sortable: true, // Column is sortable
|
|
1545
1481
|
* width: 100 // You can define the width of the column
|
|
1546
1482
|
* },
|
|
1547
1483
|
* {
|
|
1548
|
-
* title:
|
|
1549
|
-
* dataIndex:
|
|
1550
|
-
* key:
|
|
1484
|
+
* title: "Age",
|
|
1485
|
+
* dataIndex: "age",
|
|
1486
|
+
* key: "age",
|
|
1551
1487
|
* sortable: true,
|
|
1552
1488
|
* render: (item) => <span>{item.age} years</span> // Custom rendering
|
|
1553
1489
|
* },
|
|
1554
1490
|
* {
|
|
1555
|
-
* title:
|
|
1556
|
-
* dataIndex:
|
|
1557
|
-
* key:
|
|
1491
|
+
* title: "Address",
|
|
1492
|
+
* dataIndex: "address",
|
|
1493
|
+
* key: "address",
|
|
1558
1494
|
* render: (item) => (
|
|
1559
1495
|
* <a href={`https://maps.google.com/?q=${encodeURIComponent(item.address)}`} target="_blank" rel="noreferrer">
|
|
1560
1496
|
* {item.address}
|
|
@@ -1564,12 +1500,12 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
1564
1500
|
* ];
|
|
1565
1501
|
*
|
|
1566
1502
|
* const data:User[] = [
|
|
1567
|
-
* { key:
|
|
1568
|
-
* { key:
|
|
1569
|
-
* { key:
|
|
1570
|
-
* { key:
|
|
1571
|
-
* { key:
|
|
1572
|
-
* { key:
|
|
1503
|
+
* { key: "1", name: "Mike", age: 32, address: "10 Downing Street" },
|
|
1504
|
+
* { key: "2", name: "John", age: 42, address: "11 Downing Street" },
|
|
1505
|
+
* { key: "3", name: "Andres", age: 33, address: "12 Downing Street" },
|
|
1506
|
+
* { key: "4", name: "Gabriel", age: 22, address: "13 Downing Street" },
|
|
1507
|
+
* { key: "5", name: "Sergio", age: 47, address: "14 Downing Street" },
|
|
1508
|
+
* { key: "6", name: "Zacarias", age: 61, address: "15 Downing Street" }
|
|
1573
1509
|
* ];
|
|
1574
1510
|
*
|
|
1575
1511
|
* const generateExpandedContent = (record) => (
|
|
@@ -1584,8 +1520,8 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
1584
1520
|
* pagination={true}
|
|
1585
1521
|
* pageSizeOptions={[3, 5, 10]} // Optional, defaults to [5, 10, 20, 50]
|
|
1586
1522
|
* expandedRowRender={generateExpandedContent}
|
|
1587
|
-
* onExpand={(item) => console.log(
|
|
1588
|
-
* rowKey="key" // Optional, defaults to
|
|
1523
|
+
* onExpand={(item) => console.log("Expanded:", item)}
|
|
1524
|
+
* rowKey="key" // Optional, defaults to "key"
|
|
1589
1525
|
* textNoData="No data available" // Optional message when no data
|
|
1590
1526
|
* loading={false} // Optional, shows loading indicator
|
|
1591
1527
|
* scrollHeight={300} // Optional scroll height, defaults to 300
|
|
@@ -1594,12 +1530,12 @@ function CwAccordionContainer(CwelltAccordionContainerProps) {
|
|
|
1594
1530
|
* className="my-table" // Optional table class
|
|
1595
1531
|
* classNameRow="my-table-row" // Optional class for each row
|
|
1596
1532
|
* id="custom-table-id" // Optional ID for the container
|
|
1597
|
-
* style={{ border:
|
|
1533
|
+
* style={{ border: "1px solid #ccc" }} // Optional inline styles
|
|
1598
1534
|
* />
|
|
1599
1535
|
*
|
|
1600
1536
|
* @returns React component
|
|
1601
1537
|
*/
|
|
1602
|
-
function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10, 20, 50], expandedRowRender, onExpand, className, classNameRow, style, classNameContainer, id, textNoData = "No data available at the moment", rowKey = "key", loading = false, scrollHeight, stickyHeader = false, }) {
|
|
1538
|
+
function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10, 20, 50], expandedRowRender, onExpand, className, classNameRow, style, classNameContainer, id, textNoData = "No data available at the moment", rowKey = "key", loading = false, scrollHeight, stickyHeader = false, rowSelection }) {
|
|
1603
1539
|
const [currentPage, setCurrentPage] = useState(1);
|
|
1604
1540
|
const [expandedRowKey, setExpandedRowKey] = useState(null);
|
|
1605
1541
|
const [sortConfig, setSortConfig] = useState({
|
|
@@ -1612,6 +1548,13 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1612
1548
|
acc[col.key] = col.width;
|
|
1613
1549
|
return acc;
|
|
1614
1550
|
}, {}));
|
|
1551
|
+
const [selectedKeys, setSelectedKeys] = useState(new Set(rowSelection?.selectedRowKeys || []));
|
|
1552
|
+
useEffect(() => {
|
|
1553
|
+
setCurrentPage(1);
|
|
1554
|
+
}, [data]);
|
|
1555
|
+
useEffect(() => {
|
|
1556
|
+
setSelectedKeys(new Set(rowSelection?.selectedRowKeys || []));
|
|
1557
|
+
}, [rowSelection?.selectedRowKeys]);
|
|
1615
1558
|
const handleItemsPerPageChange = useCallback((e) => {
|
|
1616
1559
|
setLocalItemsPerPage(parseInt(e.target.value, 10));
|
|
1617
1560
|
setCurrentPage(1);
|
|
@@ -1638,11 +1581,62 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1638
1581
|
dataCopy.sort((a, b) => {
|
|
1639
1582
|
const aVal = a[sortConfig.key];
|
|
1640
1583
|
const bVal = b[sortConfig.key];
|
|
1584
|
+
// Handle null/undefined
|
|
1585
|
+
if (aVal == null && bVal == null)
|
|
1586
|
+
return 0;
|
|
1587
|
+
if (aVal == null)
|
|
1588
|
+
return 1;
|
|
1589
|
+
if (bVal == null)
|
|
1590
|
+
return -1;
|
|
1591
|
+
// Handle strings (case-insensitive)
|
|
1592
|
+
if (typeof aVal === "string" && typeof bVal === "string") {
|
|
1593
|
+
const comparison = aVal.localeCompare(bVal, undefined, {
|
|
1594
|
+
sensitivity: "base",
|
|
1595
|
+
numeric: true
|
|
1596
|
+
});
|
|
1597
|
+
return comparison * (sortConfig.direction === "asc" ? 1 : -1);
|
|
1598
|
+
}
|
|
1599
|
+
// Handle numbers and other types
|
|
1641
1600
|
return (aVal < bVal ? -1 : aVal > bVal ? 1 : 0) * (sortConfig.direction === "asc" ? 1 : -1);
|
|
1642
1601
|
});
|
|
1643
1602
|
}
|
|
1644
1603
|
return dataCopy;
|
|
1645
1604
|
}, [data, sortConfig]);
|
|
1605
|
+
const handleRowClick = useCallback((item, e) => {
|
|
1606
|
+
// Prevent selection if the expand button is clicked
|
|
1607
|
+
if (e.target.closest(".cw-table-col-expand")) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
const itemKey = item[rowKey];
|
|
1611
|
+
setSelectedKeys(prev => {
|
|
1612
|
+
const newSet = new Set(prev);
|
|
1613
|
+
if (rowSelection?.type === "single") {
|
|
1614
|
+
// Single mode: only one row selected
|
|
1615
|
+
if (newSet.has(itemKey)) {
|
|
1616
|
+
newSet.clear(); // Deselect if already selected
|
|
1617
|
+
}
|
|
1618
|
+
else {
|
|
1619
|
+
newSet.clear();
|
|
1620
|
+
newSet.add(itemKey);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
// Multiple mode: several rows
|
|
1625
|
+
if (newSet.has(itemKey)) {
|
|
1626
|
+
newSet.delete(itemKey);
|
|
1627
|
+
}
|
|
1628
|
+
else {
|
|
1629
|
+
newSet.add(itemKey);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
const selectedRows = sortedData.filter(item => newSet.has(item[rowKey]));
|
|
1633
|
+
// Run after render to avoid "Cannot update a component while rendering another component"
|
|
1634
|
+
setTimeout(() => {
|
|
1635
|
+
rowSelection?.onChange?.(Array.from(newSet), selectedRows);
|
|
1636
|
+
}, 0);
|
|
1637
|
+
return newSet;
|
|
1638
|
+
});
|
|
1639
|
+
}, [rowSelection, rowKey, sortedData]);
|
|
1646
1640
|
const paginatedData = useMemo(() => {
|
|
1647
1641
|
if (!sortedData)
|
|
1648
1642
|
return [];
|
|
@@ -1684,7 +1678,7 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1684
1678
|
}, [stickyHeader, scrollHeight]);
|
|
1685
1679
|
const getColSpan = () => columns.length + (expandedRowRender ? 1 : 0);
|
|
1686
1680
|
const hasClassNameRow = (item) => {
|
|
1687
|
-
return typeof item ===
|
|
1681
|
+
return typeof item === "object" && item !== null && "classNameRow" in item;
|
|
1688
1682
|
};
|
|
1689
1683
|
const renderTableBody = () => {
|
|
1690
1684
|
if (loading) {
|
|
@@ -1697,7 +1691,15 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1697
1691
|
const itemKey = item[rowKey];
|
|
1698
1692
|
if (!itemKey)
|
|
1699
1693
|
console.warn("Missing row key for item", item);
|
|
1700
|
-
|
|
1694
|
+
const isSelected = selectedKeys.has(itemKey);
|
|
1695
|
+
const dynamicClassName = typeof classNameRow === "function"
|
|
1696
|
+
? classNameRow(item)
|
|
1697
|
+
: classNameRow ?? "";
|
|
1698
|
+
return (jsxs(React__default.Fragment, { children: [jsxs("tr", { className: `${dynamicClassName} ${hasClassNameRow(item) ? item.classNameRow : ""} ${isSelected ? "cw-table-row-selected" : ""}`, onClick: (e) => rowSelection && handleRowClick(item, e), style: {
|
|
1699
|
+
cursor: rowSelection ? "pointer" : "default",
|
|
1700
|
+
backgroundColor: isSelected ? "var(--cw-color-info-container)" : undefined,
|
|
1701
|
+
transition: "background-color 0.2s ease",
|
|
1702
|
+
}, children: [expandedRowRender && (jsx("td", { className: "cw-table-col-action cw-table-col-expand", children: jsx("button", { onClick: () => handleRowExpand(item), className: `cw-button-icon ${expandedRowKey === itemKey
|
|
1701
1703
|
? "cwi-chevron-down"
|
|
1702
1704
|
: "cwi-chevron-right"}` }) })), columns.map(col => (jsx("td", { className: col.className ?? "", children: col.render ? col.render(item) : col.dataIndex ? String(item[col.dataIndex]) : "" }, `${itemKey}_${col.key}`)))] }), expandedRowRender && expandedRowKey === itemKey && (jsx("tr", { className: "cw-table-row-expanded", children: jsx("td", { colSpan: getColSpan(), children: expandedRowRender(item) }) }))] }, String(itemKey)));
|
|
1703
1705
|
});
|
|
@@ -1714,9 +1716,11 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1714
1716
|
minWidth: 50,
|
|
1715
1717
|
maxWidth: columnWidths[col.key] ?? col.width
|
|
1716
1718
|
}),
|
|
1717
|
-
}, children: [jsxs("div", {
|
|
1718
|
-
? "
|
|
1719
|
-
:
|
|
1719
|
+
}, children: [jsxs("div", { className: "cw-flex-row cw-align-between-center", children: [jsx("span", { children: col.title }), col.sortable && col.dataIndex && (jsx(CwIcon, { size: "large", iconId: sortConfig.key !== col.dataIndex
|
|
1720
|
+
? "sortable"
|
|
1721
|
+
: sortConfig.direction === "asc"
|
|
1722
|
+
? "sortable-asc"
|
|
1723
|
+
: "sortable-desc" }))] }), jsx("span", { onMouseDown: (e) => startResize(e, col.key), className: "th-column-resizer" })] }, col.key)))] }) }), jsx("tbody", { children: renderTableBody() })] }) }), pagination && totalPages > 1 && (jsxs("footer", { className: "cw-table-pagination", children: [jsx("button", { onClick: () => handlePageChange(1), disabled: currentPage === 1 || totalPages === 1, className: "cw-button-icon cwi-chevron-left-double", title: "First" }), jsx("button", { onClick: () => handlePageChange(currentPage - 1), disabled: currentPage === 1 || totalPages === 1, className: "cw-button-icon cwi-chevron-left", title: "Previous" }), jsx("input", { type: "text", inputMode: "numeric", value: currentPage, onChange: (e) => {
|
|
1720
1724
|
const value = parseInt(e.target.value, 10);
|
|
1721
1725
|
if (!isNaN(value))
|
|
1722
1726
|
handlePageChange(value);
|
|
@@ -1728,7 +1732,7 @@ function CwTable({ columns, data, pagination = false, pageSizeOptions = [5, 10,
|
|
|
1728
1732
|
}, min: 1, max: totalPages }), jsxs("span", { children: ["of ", totalPages] }), jsx("button", { onClick: () => handlePageChange(currentPage + 1), disabled: currentPage === totalPages || totalPages === 1, className: "cw-button-icon cwi-chevron-right", title: "Next" }), jsx("button", { onClick: () => handlePageChange(totalPages), disabled: currentPage === totalPages || totalPages === 1, className: "cw-button-icon cwi-chevron-right-double", title: "Last" }), jsx("select", { value: localItemsPerPage, onChange: handleItemsPerPageChange, children: pageSizeOptions.map(size => (jsxs("option", { value: size, children: [size, " / page"] }, size))) })] }))] }));
|
|
1729
1733
|
}
|
|
1730
1734
|
|
|
1731
|
-
var styles$
|
|
1735
|
+
var styles$e = {"cw-tabs":"cw-tabs-module_cw-tabs__1pmji","badge":"cw-tabs-module_badge__AmVxW","cw-tabs-content":"cw-tabs-module_cw-tabs-content__HTp8d"};
|
|
1732
1736
|
|
|
1733
1737
|
const TabIcon = ({ icon }) => {
|
|
1734
1738
|
if (!icon)
|
|
@@ -1778,7 +1782,7 @@ function CwTabs(CwTabsProps) {
|
|
|
1778
1782
|
const tabsListStyle = position === 'left' && CwTabsProps.tabsListWidth
|
|
1779
1783
|
? { minWidth: CwTabsProps.tabsListWidth }
|
|
1780
1784
|
: undefined;
|
|
1781
|
-
return (jsxs("div", { id: CwTabsProps.id, className: styles$
|
|
1785
|
+
return (jsxs("div", { id: CwTabsProps.id, className: styles$e['cw-tabs'], style: CwTabsProps.style, "data-tabs-position": position, children: [jsx("ul", { style: tabsListStyle, children: CwTabsProps.tabs.map(tab => (jsxs("li", { className: `${tab.key === activeTab ? "cw-tab-active" : ""}`, onClick: () => handleTabClick(tab), "data-active": tab.key === activeTab, children: [jsx(TabIcon, { icon: tab.icon }), tab.title, tab.badge !== undefined && (jsx("span", { className: styles$e['badge'], style: tab.badgeColor ? { backgroundColor: tab.badgeColor, color: getContrastColor(tab.badgeColor) } : undefined, children: tab.badge }))] }, tab.key))) }), jsx("div", { className: styles$e['cw-tabs-content'], children: activeTab !== null && CwTabsProps.tabs.find(tab => tab.key === activeTab)?.content })] }));
|
|
1782
1786
|
}
|
|
1783
1787
|
|
|
1784
1788
|
/**
|
|
@@ -1818,15 +1822,15 @@ const CwExpandable = ({ briefing, onToggle, onOpen, onClose, children, ...detail
|
|
|
1818
1822
|
* emptyValue="N/A"
|
|
1819
1823
|
* />
|
|
1820
1824
|
*/
|
|
1821
|
-
const CwKeyValueList = ({ items, className = "", emptyValue = "-", direction = "row" }) => {
|
|
1822
|
-
return (jsx("dl", { className: `cw-keyvalue-list ${className}`, children: items.map(item => (jsxs("div", { className: `cw-keyvalue-list-item cw-flex-${direction}`, children: [jsx("dt", { children: item.label }), jsx("dd", { children: item.value !== undefined && item.value !== null && item.value !== ""
|
|
1825
|
+
const CwKeyValueList = ({ items, className = "", emptyValue = "-", direction = "row", ...htmlProps }) => {
|
|
1826
|
+
return (jsx("dl", { className: `cw-keyvalue-list ${className}`, ...htmlProps, children: items.map(item => (jsxs("div", { className: `cw-keyvalue-list-item cw-flex-${direction}`, children: [jsx("dt", { children: item.label }), jsx("dd", { children: item.value !== undefined && item.value !== null && item.value !== ""
|
|
1823
1827
|
? (React__default.isValidElement(item.value)
|
|
1824
1828
|
? item.value
|
|
1825
1829
|
: `${item.value}${item.suffix ? ` ${item.suffix}` : ''}`)
|
|
1826
1830
|
: emptyValue })] }, item.key))) }));
|
|
1827
1831
|
};
|
|
1828
1832
|
|
|
1829
|
-
var styles$
|
|
1833
|
+
var styles$d = {"sortableList":"cw-sortable-list-module_sortableList__PyLO-","sortableItem":"cw-sortable-list-module_sortableItem__FAnn2","readOnly":"cw-sortable-list-module_readOnly__r7GcH","dragging":"cw-sortable-list-module_dragging__MD715","moved":"cw-sortable-list-module_moved__sE6-N","expandedContent":"cw-sortable-list-module_expandedContent__Kocna","sortableHandle":"cw-sortable-list-module_sortableHandle__HvYBK","sortableContent":"cw-sortable-list-module_sortableContent__C6JhR","sortableTitle":"cw-sortable-list-module_sortableTitle__EgWXr","sortableExtraContent":"cw-sortable-list-module_sortableExtraContent__s4LSv","sortableActions":"cw-sortable-list-module_sortableActions__gwQOU","dropIndicator":"cw-sortable-list-module_dropIndicator__MNSF-","emptyMessage":"cw-sortable-list-module_emptyMessage__gMpaL"};
|
|
1830
1834
|
|
|
1831
1835
|
function CwSortableList({ items, onReorder, renderItem, className = '', movedItems = new Set(), emptyMessage = "No elements to show", readOnly = false, }) {
|
|
1832
1836
|
const [draggedItem, setDraggedItem] = useState(null);
|
|
@@ -1889,15 +1893,15 @@ function CwSortableList({ items, onReorder, renderItem, className = '', movedIte
|
|
|
1889
1893
|
}
|
|
1890
1894
|
};
|
|
1891
1895
|
if (items.length === 0) {
|
|
1892
|
-
return (jsx("div", { className: `${styles$
|
|
1896
|
+
return (jsx("div", { className: `${styles$d.sortableList} ${styles$d.emptyState} ${className}`, children: jsx("div", { className: styles$d.emptyMessage, children: emptyMessage }) }));
|
|
1893
1897
|
}
|
|
1894
|
-
return (jsx("div", { className: `${styles$
|
|
1898
|
+
return (jsx("div", { className: `${styles$d.sortableList} ${className}`, children: items.map((item, index) => {
|
|
1895
1899
|
const { title, extraContent, actions, showHandle = true, expandedContent } = renderItem(item);
|
|
1896
1900
|
const isDragging = draggedItem?.id === item.id;
|
|
1897
1901
|
const isMoved = movedItems.has(item.id);
|
|
1898
1902
|
const canExpand = Boolean(expandedContent);
|
|
1899
1903
|
const isExpanded = expandedItems.has(item.id);
|
|
1900
|
-
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && jsx("div", { className: styles$
|
|
1904
|
+
return (jsxs(React__default.Fragment, { children: [dropIndicatorIndex === index && jsx("div", { className: styles$d.dropIndicator }), jsxs("div", { className: `${styles$d.sortableItem} ${isDragging ? styles$d.dragging : ''} ${isMoved ? styles$d.moved : ''} ${readOnly ? styles$d.readOnly : ''}`, draggable: !readOnly, onDragStart: (e) => handleDragStart(e, item), onDragOver: (e) => handleDragOver(e, index), onDragEnd: handleDragEnd, children: [jsxs("header", { children: [canExpand ? (jsx(CwButton, { variant: "icon", onClick: () => toggleExpanded(item.id), type: "button", title: isExpanded ? "Collapse" : "Expand", icon: isExpanded ? "chevron-up" : "chevron-down" })) : showHandle ? (jsx("div", { className: styles$d.sortableHandle, children: jsx(CwIcon, { iconId: "grip-dots" }) })) : null, jsxs("div", { className: styles$d.sortableContent, children: [jsx("div", { className: styles$d.sortableTitle, children: title }), extraContent && jsx("div", { className: styles$d.sortableExtraContent, children: extraContent })] }), jsx("div", { className: styles$d.sortableActions, children: actions })] }), isExpanded && expandedContent && (jsx("div", { className: styles$d.expandedContent, children: expandedContent }))] }), !readOnly && dropIndicatorIndex === items.length && index === items.length - 1 && (jsx("div", { className: styles$d.dropIndicator }))] }, item.id));
|
|
1901
1905
|
}) }));
|
|
1902
1906
|
}
|
|
1903
1907
|
|
|
@@ -2074,11 +2078,15 @@ function CwFileUpload(fileUploadProps) {
|
|
|
2074
2078
|
return (jsxs("div", { children: [jsxs("div", { className: "row", children: [jsx("input", { className: "cw-button", type: "file", accept: fileUploadProps.accept, readOnly: true, placeholder: "No file selected...", onChange: handleFileChange }), previewURL && (jsx("div", { className: "row", children: jsx("img", { src: previewURL, alt: "Preview", style: { maxWidth: "200px", maxHeight: "200px" } }) }))] }), error && jsx("div", { className: "row error", children: error }), jsx("div", { className: "row", children: jsxs("label", { children: ["Please note: File/image has to be in ", fileUploadProps.acceptString, " format", fileUploadProps.sizeString && `, ${fileUploadProps.sizeString}`] }) })] }));
|
|
2075
2079
|
}
|
|
2076
2080
|
|
|
2077
|
-
var styles$
|
|
2081
|
+
var styles$c = {"fileUploadContainer":"cw-file-upload-multiple-module_fileUploadContainer__liEc1","hiddenInput":"cw-file-upload-multiple-module_hiddenInput__TZBBI","uploadArea":"cw-file-upload-multiple-module_uploadArea__DdOhs","uploadAreaDisabled":"cw-file-upload-multiple-module_uploadAreaDisabled__VWeFX","uploadTitle":"cw-file-upload-multiple-module_uploadTitle__gjRk8","uploadSubtitle":"cw-file-upload-multiple-module_uploadSubtitle__Z0S5t","filesContainer":"cw-file-upload-multiple-module_filesContainer__g44PY","fileItem":"cw-file-upload-multiple-module_fileItem__w27Dg","fileIcon":"cw-file-upload-multiple-module_fileIcon__iJJUX","fileExtension":"cw-file-upload-multiple-module_fileExtension__vOuHv","fileInfo":"cw-file-upload-multiple-module_fileInfo__R5ZTv","fileName":"cw-file-upload-multiple-module_fileName__DjepK","fileSize":"cw-file-upload-multiple-module_fileSize__b8GSm","smallButton":"cw-file-upload-multiple-module_smallButton__siUAh"};
|
|
2078
2082
|
|
|
2079
2083
|
function CwFileUploadMultiple(fileUploadProps) {
|
|
2080
2084
|
const fileInputRef = useRef(null);
|
|
2081
2085
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
2086
|
+
const [existingFile, setExistingFile] = useState(fileUploadProps.initialFileName);
|
|
2087
|
+
React__default.useEffect(() => {
|
|
2088
|
+
setExistingFile(fileUploadProps.initialFileName);
|
|
2089
|
+
}, [fileUploadProps.initialFileName]);
|
|
2082
2090
|
const getFileExtension = (filename) => {
|
|
2083
2091
|
return filename.split('.').pop()?.toUpperCase() || '';
|
|
2084
2092
|
};
|
|
@@ -2183,6 +2191,10 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
2183
2191
|
}
|
|
2184
2192
|
}
|
|
2185
2193
|
};
|
|
2194
|
+
const handleFileSelectInternal = (event) => {
|
|
2195
|
+
setExistingFile(undefined);
|
|
2196
|
+
handleFileSelect(event);
|
|
2197
|
+
};
|
|
2186
2198
|
const removeFile = (indexToRemove) => {
|
|
2187
2199
|
const newFiles = selectedFiles.filter((_, index) => index !== indexToRemove);
|
|
2188
2200
|
setSelectedFiles(newFiles);
|
|
@@ -2209,6 +2221,7 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
2209
2221
|
event.stopPropagation();
|
|
2210
2222
|
const files = event.dataTransfer.files;
|
|
2211
2223
|
if (files && files.length > 0) {
|
|
2224
|
+
setExistingFile(undefined);
|
|
2212
2225
|
const updatedFiles = processFiles(files, selectedFiles);
|
|
2213
2226
|
if (updatedFiles.length > selectedFiles.length || !fileUploadProps.multiple) {
|
|
2214
2227
|
setSelectedFiles(updatedFiles);
|
|
@@ -2216,7 +2229,12 @@ function CwFileUploadMultiple(fileUploadProps) {
|
|
|
2216
2229
|
}
|
|
2217
2230
|
}
|
|
2218
2231
|
};
|
|
2219
|
-
return (jsxs("div", { className: `${styles$
|
|
2232
|
+
return (jsxs("div", { className: `${styles$c.fileUploadContainer} ${fileUploadProps.className}`, children: [jsx("input", { ref: fileInputRef, type: "file", name: fileUploadProps.name, accept: fileUploadProps.accept, multiple: fileUploadProps.multiple, onChange: handleFileSelectInternal, disabled: fileUploadProps.disabled, "aria-label": "files", className: styles$c.hiddenInput }), selectedFiles.length === 0 && !existingFile ? (jsxs("div", { className: `${styles$c.uploadArea} ${fileUploadProps.disabled ? styles$c.uploadAreaDisabled : ''}`, onDragOver: handleDragOver, onDrop: handleDrop, onClick: !fileUploadProps.disabled ? handleButtonClick : undefined, children: [jsx(CwIcon, { iconId: "upload" }), jsx("p", { className: `${styles$c.uploadTitle}`, children: fileUploadProps.disabled ? 'Upload disabled' : 'Click to upload or drag and drop' }), jsxs("p", { className: `${styles$c.uploadSubtitle}`, children: [fileUploadProps.accept ? `Accepted files: ${fileUploadProps.accept}` : 'All file types accepted', !fileUploadProps.multiple && ' (Single file only)'] })] })) : selectedFiles.length === 0 && existingFile ? (jsxs("div", { className: styles$c.filesContainer, children: [jsxs("div", { className: styles$c.fileItem, children: [jsxs("div", { className: styles$c.fileIcon, children: [jsx(CwIcon, { iconId: "page" }), jsx("span", { className: styles$c.fileExtension, children: getFileExtension(existingFile) })] }), jsx("div", { className: styles$c.fileInfo, children: jsx("p", { className: styles$c.fileName, children: existingFile }) }), jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => {
|
|
2233
|
+
setExistingFile(undefined);
|
|
2234
|
+
if (fileUploadProps.onSelect) {
|
|
2235
|
+
fileUploadProps.onSelect(null);
|
|
2236
|
+
}
|
|
2237
|
+
}, disabled: fileUploadProps.disabled, className: styles$c.smallButton })] }), jsx(CwButton, { text: "Change File", icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled })] })) : (jsxs("div", { className: styles$c.filesContainer, children: [jsxs("div", { className: "cw-flex-row cw-align-between-center", children: [jsxs("small", { className: styles$c.filesCount, children: [selectedFiles.length, " file", selectedFiles.length !== 1 ? 's' : '', " selected"] }), jsx(CwButton, { onClick: removeAllFiles, disabled: fileUploadProps.disabled, color: "danger", variant: "outline", icon: "delete", text: "Clear all" })] }), selectedFiles.map((file, index) => (jsxs("div", { className: styles$c.fileItem, children: [jsxs("div", { className: styles$c.fileIcon, children: [jsx(CwIcon, { iconId: "page" }), jsx("span", { className: styles$c.fileExtension, children: getFileExtension(file.name) })] }), jsxs("div", { className: styles$c.fileInfo, children: [jsx("p", { className: styles$c.fileName, children: file.name }), jsxs("p", { className: styles$c.fileSize, children: [(file.size / 1024).toFixed(1), " KB"] })] }), jsx(CwButton, { variant: "icon", icon: "close", color: "neutral", onClick: () => removeFile(index), className: styles$c.smallButton })] }, index))), fileUploadProps.multiple && (jsx(CwButton, { text: "Add More Files", icon: "plus", variant: "outline", onClick: handleButtonClick, disabled: fileUploadProps.disabled })), !fileUploadProps.multiple && (jsx(CwButton, { text: "Change File", icon: "refresh", onClick: handleButtonClick, disabled: fileUploadProps.disabled }))] }))] }));
|
|
2220
2238
|
}
|
|
2221
2239
|
|
|
2222
2240
|
function CwInput(CwInputProps) {
|
|
@@ -2259,7 +2277,7 @@ function CwDigit(props) {
|
|
|
2259
2277
|
return (jsx("div", { className: "cw-input-text", children: jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { type: "number", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
|
|
2260
2278
|
}
|
|
2261
2279
|
|
|
2262
|
-
var styles$
|
|
2280
|
+
var styles$b = {"colorPreview":"cw-color-picker-module_colorPreview__ylJcD","hueBar":"cw-color-picker-module_hueBar__bFhyC","hueBarSlider":"cw-color-picker-module_hueBarSlider__D53IV","colorPickerInteractiveArea":"cw-color-picker-module_colorPickerInteractiveArea__KZFR1","colorArea":"cw-color-picker-module_colorArea__xgpSE","colorAreaOverlay":"cw-color-picker-module_colorAreaOverlay__pmgOc","hueBackground":"cw-color-picker-module_hueBackground__Mks78","whiteGradient":"cw-color-picker-module_whiteGradient__Bt-fU","blackGradient":"cw-color-picker-module_blackGradient__VnEKJ","colorAreaCursor":"cw-color-picker-module_colorAreaCursor__lotg3"};
|
|
2263
2281
|
|
|
2264
2282
|
const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }) => {
|
|
2265
2283
|
const [rgb, setRgb] = useState({ r: 255, g: 255, b: 255 });
|
|
@@ -2462,13 +2480,13 @@ const CwColorPicker = ({ initialColor, onChange, previewText = "Color preview" }
|
|
|
2462
2480
|
// Calculate background color for the main area based on current hue
|
|
2463
2481
|
const hueColor = hsvToRgb(hsv.h, 100, 100);
|
|
2464
2482
|
const hueHex = rgbToHex(hueColor.r, hueColor.g, hueColor.b);
|
|
2465
|
-
return (jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsx("div", { className: styles$
|
|
2483
|
+
return (jsxs("div", { className: "cw-flex-column cw-gap-small", children: [jsxs("div", { className: "cw-flex-row cw-align-between-center cw-gap-small", children: [jsx("div", { className: styles$b.colorPreview, style: { backgroundColor: hexColor, color: getContrastColor(hexColor) }, children: previewText }), jsx("button", { type: "button", className: "cw-button", onClick: toggleInputMode, style: { minWidth: "3ch" }, children: inputMode === 'hex' ? 'RGB' : 'HEX' })] }), jsx("div", { className: "color-inputs-row", children: inputMode === 'hex' ? (jsx("input", { type: "text", value: hexColor, onChange: handleHexChange })) : (jsxs("div", { className: "cw-grid-base-3 cw-gap-small", children: [jsxs("div", { children: [jsx("label", { children: "R:" }), jsx("input", { type: "number", name: "r", min: "0", max: "255", value: rgb.r, onChange: handleRgbChange })] }), jsxs("div", { children: [jsx("label", { children: "G:" }), jsx("input", { type: "number", name: "g", min: "0", max: "255", value: rgb.g, onChange: handleRgbChange })] }), jsxs("div", { children: [jsx("label", { children: "B:" }), jsx("input", { type: "number", name: "b", min: "0", max: "255", value: rgb.b, onChange: handleRgbChange })] })] })) }), jsxs("div", { className: styles$b.colorPickerInteractiveArea, children: [jsx("div", { className: styles$b.hueBar, ref: hueBarRef, onClick: handleHueBarClick, children: jsx("div", { className: styles$b.hueBarSlider, style: { top: `${(360 - hsv.h) / 360 * 100}%` } }) }), jsxs("div", { className: styles$b.colorArea, ref: colorAreaRef, onClick: handleColorAreaClick, children: [jsxs("div", { className: styles$b.colorAreaOverlay, children: [jsx("div", { className: styles$b.hueBackground, style: { backgroundColor: hueHex } }), jsx("div", { className: styles$b.whiteGradient }), jsx("div", { className: styles$b.blackGradient })] }), jsx("div", { className: styles$b.colorAreaCursor, style: {
|
|
2466
2484
|
left: `${hsv.s}%`,
|
|
2467
2485
|
top: `${100 - hsv.v}%`
|
|
2468
2486
|
} })] })] })] }));
|
|
2469
2487
|
};
|
|
2470
2488
|
|
|
2471
|
-
var styles$
|
|
2489
|
+
var styles$a = {"selectColor":"cw-input-color-module_selectColor__DTo3V","disabled":"cw-input-color-module_disabled__O1fK5","colorDropdown":"cw-input-color-module_colorDropdown__pX2bc"};
|
|
2472
2490
|
|
|
2473
2491
|
const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled = false, width = '4rem', height = '2rem' }) => {
|
|
2474
2492
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -2601,11 +2619,11 @@ const CwInputColor = ({ value, onChange, previewText = "Color preview", disabled
|
|
|
2601
2619
|
break;
|
|
2602
2620
|
}
|
|
2603
2621
|
};
|
|
2604
|
-
return (jsxs(Fragment, { children: [jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$
|
|
2622
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: containerRef, onClick: handleToggle, className: `${styles$a.selectColor} ${disabled ? styles$a.disabled : ''}`, style: {
|
|
2605
2623
|
width,
|
|
2606
2624
|
height,
|
|
2607
2625
|
backgroundColor: value,
|
|
2608
|
-
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && createPortal(jsx("div", { ref: dropdownRef, className: styles$
|
|
2626
|
+
}, "aria-label": "Open color picker", "aria-expanded": isOpen, "aria-haspopup": "dialog", role: "button", tabIndex: disabled ? -1 : 0, onKeyDown: handleKeyDown }), isOpen && createPortal(jsx("div", { ref: dropdownRef, className: styles$a.colorDropdown, style: dropdownStyle, role: "dialog", "aria-modal": "true", "aria-label": "Color picker", children: jsx(CwColorPicker, { initialColor: value, onChange: handleColorChange, previewText: previewText }) }), document.body)] }));
|
|
2609
2627
|
};
|
|
2610
2628
|
|
|
2611
2629
|
/**
|
|
@@ -2632,7 +2650,7 @@ function CwInputText(props) {
|
|
|
2632
2650
|
const containerClassName = className
|
|
2633
2651
|
? `cw-input-text ${className}`
|
|
2634
2652
|
: "cw-input-text";
|
|
2635
|
-
return (jsx("div", { className: containerClassName, children: jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsx("input", { type: props.type ?? "text", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
|
|
2653
|
+
return (jsx("div", { className: containerClassName, children: jsxs(CwAlign, { ...alignProps, itemProp: inputProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("div", { className: "cw-input-button", children: [jsx("input", { type: props.type ?? "text", ...inputProps }), buttonProps && jsx(CwButton, { ...buttonProps })] })] }) }));
|
|
2636
2654
|
}
|
|
2637
2655
|
|
|
2638
2656
|
/**
|
|
@@ -3098,7 +3116,7 @@ const CwImageArea = forwardRef((props, ref) => {
|
|
|
3098
3116
|
});
|
|
3099
3117
|
CwImageArea.displayName = "CwImageArea";
|
|
3100
3118
|
|
|
3101
|
-
var styles$
|
|
3119
|
+
var styles$9 = {"cw-weekday-selector":"cw-weekday-selector-module_cw-weekday-selector__Iz4GZ"};
|
|
3102
3120
|
|
|
3103
3121
|
/**
|
|
3104
3122
|
* This class represents a week where days can be selected or unselected
|
|
@@ -3238,7 +3256,7 @@ const CwWeekdaySelector = ({ value = "", onChange, disabled = false }) => {
|
|
|
3238
3256
|
setSelectedDays(newWeekdays);
|
|
3239
3257
|
onChange?.(newWeekdays.toString());
|
|
3240
3258
|
};
|
|
3241
|
-
return (jsx("div", { className: styles$
|
|
3259
|
+
return (jsx("div", { className: styles$9["cw-weekday-selector"], children: Weekdays.getFullWeek().map(day => (jsx("input", { type: "checkbox", "data-day": day, checked: selectedDays.toArray().includes(day), onChange: (e) => handleChange(day, e.target.checked), disabled: disabled }, day))) }));
|
|
3242
3260
|
};
|
|
3243
3261
|
|
|
3244
3262
|
function CwCheckbox(CwCheckboxProps) {
|
|
@@ -3257,9 +3275,9 @@ function CwCheckbox(CwCheckboxProps) {
|
|
|
3257
3275
|
}
|
|
3258
3276
|
|
|
3259
3277
|
function CwToggle(props) {
|
|
3260
|
-
const { labelProps, labelText, iconProps, alignment = "row", className, ...inputProps } = props;
|
|
3278
|
+
const { labelProps, labelText, iconProps, alignment = "row", className, style, ...inputProps } = props;
|
|
3261
3279
|
const displayText = labelText || labelProps?.text;
|
|
3262
|
-
return (jsx("div", { className: `cw-toggle${className ? ` ${className}` : ''}`, children: jsxs("label", { className: "cw-toggle-label", "data-direction": alignment, children: [displayText && (jsxs("span", { className: "cw-icon-text", children: [iconProps && jsx(CwIcon, { ...iconProps }), displayText] })), jsx("input", {
|
|
3280
|
+
return (jsx("div", { className: `cw-toggle ${className ? ` ${className}` : ''}`, style: style, children: jsxs("label", { className: "cw-toggle-label", "data-direction": alignment, children: [displayText && (jsxs("span", { className: "cw-icon-text", children: [iconProps && jsx(CwIcon, { ...iconProps }), displayText] })), jsx("input", {
|
|
3263
3281
|
//data-color={color}
|
|
3264
3282
|
type: "checkbox", ...inputProps })] }) }));
|
|
3265
3283
|
}
|
|
@@ -3305,64 +3323,10 @@ function CwOption(props) {
|
|
|
3305
3323
|
* </CwSelect>
|
|
3306
3324
|
*/
|
|
3307
3325
|
function CwSelect(props) {
|
|
3308
|
-
const { alignProps, labelProps, buttonProps, iconProps, placeholder, children, ...selectProps } = props;
|
|
3326
|
+
const { alignProps, labelProps, buttonProps, iconProps, placeholder, children, style, ...selectProps } = props;
|
|
3309
3327
|
const flexDirection = alignProps?.flexDirection;
|
|
3310
3328
|
const dataDirection = flexDirection ? { 'data-direction': flexDirection } : {};
|
|
3311
|
-
return (jsx("div", { className: "cw-select", ...dataDirection, children: jsxs(CwAlign, { ...alignProps, itemProp: selectProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("select", { ...selectProps, children: [placeholder && jsx(CwOption, { value: "", children: placeholder }), children] }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
|
-
function CwDropdown(optionsProps) {
|
|
3315
|
-
const [selectedOption, setSelectedOption] = useState(optionsProps.defaultSelected || "");
|
|
3316
|
-
useEffect(() => {
|
|
3317
|
-
if (optionsProps.defaultSelected !== undefined && optionsProps.defaultSelected !== selectedOption) {
|
|
3318
|
-
setSelectedOption(optionsProps.defaultSelected);
|
|
3319
|
-
if (optionsProps.handleChange) {
|
|
3320
|
-
optionsProps.handleChange(optionsProps.defaultSelected);
|
|
3321
|
-
}
|
|
3322
|
-
}
|
|
3323
|
-
}, [optionsProps.defaultSelected, selectedOption, optionsProps.handleChange]);
|
|
3324
|
-
const handleOptionSelect = (event) => {
|
|
3325
|
-
const selectedValue = event.target.value;
|
|
3326
|
-
setSelectedOption(selectedValue);
|
|
3327
|
-
if (optionsProps.handleChange) {
|
|
3328
|
-
optionsProps.handleChange(selectedValue);
|
|
3329
|
-
}
|
|
3330
|
-
};
|
|
3331
|
-
return (jsxs("div", { className: optionsProps.labelPosition === "inline"
|
|
3332
|
-
? "cwellt_flex cwellt_flex_row cwellt_align_items_center cwDropDownComp" + " " + optionsProps.className
|
|
3333
|
-
: optionsProps.labelPosition === "column"
|
|
3334
|
-
? "cwellt_flex cwellt_flex_column cwellt_align-items_baseline cwDropDownComp" + " " + optionsProps.className
|
|
3335
|
-
: "cwellt_flex cwellt_flex_row cwellt_align_items_center cwDropDownComp" + " " + optionsProps.className, style: optionsProps.style, id: optionsProps.id, children: [jsx("label", { className: optionsProps.disabled === true
|
|
3336
|
-
? "cw_label_text cw_label_text_disabled" + " " + optionsProps.labelClassName
|
|
3337
|
-
: "cw_label_text" + " " + optionsProps.labelClassName, children: optionsProps.labelName }), jsx("select", { value: selectedOption, onChange: handleOptionSelect, className: "cw_select", style: optionsProps.styleSelect, disabled: optionsProps.disabled || optionsProps.selectList.length === 0, children: optionsProps.selectList.length === 0 ? (jsx("option", { value: "", className: "cw_option", disabled: true, children: "No data" })) : (jsxs(Fragment, { children: [jsx("option", { value: "", className: "cw_option", children: optionsProps.placeholder }), optionsProps.selectList.map(option => (jsx("option", { value: option.id, className: "cw_option", style: optionsProps.styleOption, children: option.description }, option.id)))] })) })] }));
|
|
3338
|
-
}
|
|
3339
|
-
|
|
3340
|
-
function CwDropdownContainer(dropDownContainerProps) {
|
|
3341
|
-
// #region
|
|
3342
|
-
// - Ref dropDownContainer
|
|
3343
|
-
const dropDownContainer_ref = React.createRef();
|
|
3344
|
-
// - Ref list container
|
|
3345
|
-
const dropDown_listContainer = React.createRef();
|
|
3346
|
-
// #endregion
|
|
3347
|
-
// #region Functions
|
|
3348
|
-
const onKeyPressDropDownContainer = (event_keyDown) => {
|
|
3349
|
-
dropDownContainerProps.onKeyDownDropDownContainer(event_keyDown);
|
|
3350
|
-
};
|
|
3351
|
-
const onMouseLeaveDropDownContainer = (event_onMouseLeave) => {
|
|
3352
|
-
if (typeof dropDownContainerProps.onMouseLeaveDropDownContainer === "function") {
|
|
3353
|
-
dropDownContainerProps.onMouseLeaveDropDownContainer(event_onMouseLeave);
|
|
3354
|
-
}
|
|
3355
|
-
};
|
|
3356
|
-
// #endregion
|
|
3357
|
-
// #region UseEffect
|
|
3358
|
-
useEffect(() => {
|
|
3359
|
-
window.addEventListener("keydown", onKeyPressDropDownContainer);
|
|
3360
|
-
return () => {
|
|
3361
|
-
window.removeEventListener("keydown", onKeyPressDropDownContainer);
|
|
3362
|
-
};
|
|
3363
|
-
}, []);
|
|
3364
|
-
// #endregion
|
|
3365
|
-
return (jsx("div", { className: `cw-dropdown-container ${dropDownContainerProps.className || ''}`, onKeyDown: onKeyPressDropDownContainer, onMouseLeave: onMouseLeaveDropDownContainer, tabIndex: 0, hidden: !dropDownContainerProps.dropDownState, children: jsx("div", { className: "cw-dropdown-list", id: dropDownContainerProps.idDropDownContainer, ref: dropDownContainer_ref, children: jsx("div", { ref: dropDown_listContainer, children: dropDownContainerProps.children }) }) }));
|
|
3329
|
+
return (jsx("div", { className: "cw-select", ...dataDirection, style: style, children: jsxs(CwAlign, { ...alignProps, itemProp: selectProps.required === true ? "required" : "", children: [labelProps && (jsxs(CwLabel, { ...labelProps, children: [iconProps && jsx(CwIcon, { ...iconProps }), labelProps.text] })), jsxs("select", { ...selectProps, children: [placeholder && jsx(CwOption, { value: "", children: placeholder }), children] }), buttonProps && jsx(CwButton, { ...buttonProps })] }) }));
|
|
3366
3330
|
}
|
|
3367
3331
|
|
|
3368
3332
|
function CwDropdownFilter(props) {
|
|
@@ -3375,634 +3339,38 @@ function CwDropdownFilter(props) {
|
|
|
3375
3339
|
return (jsxs("div", { id: props.IdContent, className: containerClassName, children: [props.children, isVisible && (jsx("nav", { className: "cw-dropdown-menu", style: inlineStyles, onMouseLeave: props.onMouseLeave, id: props.idDropDownFilter, role: "menu", children: jsx("ul", { role: "none", children: props.DataSourceDropDownItem?.map((item) => (jsx("li", { id: item.IdDropDown_filter, role: "menuitem", children: item.dropDownFilter_desc }, item.IdDropDown_filter))) }) }))] }));
|
|
3376
3340
|
}
|
|
3377
3341
|
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
componentDidMount() {
|
|
3389
|
-
this.setState({
|
|
3390
|
-
selected: this.props.selectedItems?.map((s) => ({
|
|
3391
|
-
type: s.type,
|
|
3392
|
-
id: s.id,
|
|
3393
|
-
despription: s.despription,
|
|
3394
|
-
color: s.color
|
|
3395
|
-
}))
|
|
3396
|
-
});
|
|
3397
|
-
this.onClickSelect = this.onClickSelect.bind(this);
|
|
3398
|
-
}
|
|
3399
|
-
onClickSelect = () => {
|
|
3400
|
-
this.setState({
|
|
3401
|
-
isVisibleDropDown: !this.state.isVisibleDropDown
|
|
3402
|
-
});
|
|
3403
|
-
this.setState({
|
|
3404
|
-
activeClassName: "cwelltSelectDropDown_active"
|
|
3405
|
-
});
|
|
3406
|
-
};
|
|
3407
|
-
handleOnDropDownVisibleChange = () => {
|
|
3408
|
-
const dropDown_content = document.getElementsByClassName("cwelltSelectDropDown");
|
|
3409
|
-
for (let i = 0; i <= dropDown_content.length; i++) {
|
|
3410
|
-
dropDown_content[i]?.addEventListener("mouseleave", () => {
|
|
3411
|
-
this.setState({
|
|
3412
|
-
isVisibleDropDown: false
|
|
3413
|
-
});
|
|
3414
|
-
});
|
|
3415
|
-
}
|
|
3416
|
-
};
|
|
3417
|
-
onKeyUpSelect = (e_KeyUp_select) => {
|
|
3418
|
-
if (e_KeyUp_select.key === "Enter" || e_KeyUp_select.key === "Escape") {
|
|
3419
|
-
this.setState({
|
|
3420
|
-
isVisibleDropDown: false
|
|
3421
|
-
});
|
|
3422
|
-
}
|
|
3423
|
-
else {
|
|
3424
|
-
this.setState({
|
|
3425
|
-
isVisibleDropDown: true
|
|
3426
|
-
});
|
|
3427
|
-
}
|
|
3428
|
-
};
|
|
3429
|
-
// mouseHover dropDown active
|
|
3430
|
-
onMouseHoverDropDownActive = () => {
|
|
3431
|
-
const dropDown_active = document.getElementsByClassName("cwelltSelectDropDown_active");
|
|
3432
|
-
const itemArray = () => {
|
|
3433
|
-
Array.from(dropDown_active).forEach(index => {
|
|
3434
|
-
const dropDown = index;
|
|
3435
|
-
dropDown.addEventListener("mouseover", () => { });
|
|
3436
|
-
});
|
|
3437
|
-
return true;
|
|
3438
|
-
};
|
|
3439
|
-
if (dropDown_active.length > 0 && itemArray()) {
|
|
3440
|
-
return true;
|
|
3441
|
-
}
|
|
3442
|
-
else {
|
|
3443
|
-
return false;
|
|
3444
|
-
}
|
|
3445
|
-
};
|
|
3446
|
-
// clicl cwelltDropDown
|
|
3447
|
-
onMouseLeaveMultiSelect = (event_mouseLeave) => {
|
|
3448
|
-
const post = event_mouseLeave.currentTarget.getBoundingClientRect();
|
|
3449
|
-
const posCursorY = event_mouseLeave.clientY;
|
|
3450
|
-
if (posCursorY > post.bottom && this.state.isVisibleDropDown === true) {
|
|
3451
|
-
this.setState({
|
|
3452
|
-
isVisibleDropDown: true
|
|
3453
|
-
});
|
|
3454
|
-
}
|
|
3455
|
-
else {
|
|
3456
|
-
this.setState({
|
|
3457
|
-
isVisibleDropDown: false
|
|
3458
|
-
});
|
|
3459
|
-
}
|
|
3460
|
-
};
|
|
3461
|
-
render() {
|
|
3462
|
-
return (jsx("div", { style: {
|
|
3463
|
-
display: "flex",
|
|
3464
|
-
flexDirection: "row",
|
|
3465
|
-
alignItems: "flexStart",
|
|
3466
|
-
width: "100%"
|
|
3467
|
-
}, id: "contentMultiSelect", onMouseLeave: e => this.onMouseLeaveMultiSelect(e), children: jsx("div", { style: { flex: 1 }, children: jsx(Select, { autoClearSearchValue: true, mode: "multiple", allowClear: true, style: { width: "100%" }, onChange: this.props.handleChange, optionFilterProp: "description", virtual: true, showArrow: true, size: "middle", className: this.props.selectedItems?.length === 0
|
|
3468
|
-
? "cwelltMultiSelect cwelltSelect cwelltSelectSimple cwelltMultiSelect_searchIcon"
|
|
3469
|
-
: "cwelltMultiSelect cwelltSelect cwelltSelectSimple", placeholder: "Search or filter...", dropdownClassName: this.state.isVisibleDropDown
|
|
3470
|
-
? " cwelltSelectDropDown cwelltSelectDropDown_active"
|
|
3471
|
-
: "cwelltSelectDropDown", value: this.props.selectedItems?.map(s => s.type + "_" + s.id), onClick: () => this.onClickSelect(), open: this.state.isVisibleDropDown, onDropdownVisibleChange: () => this.handleOnDropDownVisibleChange(), onKeyUp: e_KeyUp_select => this.onKeyUpSelect(e_KeyUp_select), children: this.props.selectLists.map((slArray, i) => (jsx(OptGroup, { label: slArray.length > 0 ? slArray[0]?.type : "", children: slArray.map(sl => (jsx(Option, { value: sl.type + "_" + sl.id, type: sl.type, description: sl.description, val: sl.id, children: jsx(Tag, { color: sl.color, children: sl.description }) }, sl.type + "_" + sl.id))) }, "_" + i))) }) }) }));
|
|
3472
|
-
}
|
|
3473
|
-
}
|
|
3474
|
-
|
|
3475
|
-
function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor, onPrimaryColor) {
|
|
3476
|
-
const result = new Set();
|
|
3477
|
-
items.forEach((item, index) => {
|
|
3478
|
-
result.add({
|
|
3479
|
-
ID: `${category}_${index}`,
|
|
3480
|
-
Name: item[nameKey] || index,
|
|
3481
|
-
Value: item[valueKey] || index,
|
|
3482
|
-
Category: category || "Missing Category",
|
|
3483
|
-
PrimaryColor: primaryColor || { r: 0, g: 0, b: 0 },
|
|
3484
|
-
OnPrimaryColor: onPrimaryColor || { r: 255, g: 255, b: 255 }
|
|
3342
|
+
function itemsToMultiFilterTags(items, nameKey, valueKey, category, primaryColor, onPrimaryColor) {
|
|
3343
|
+
const result = new Set();
|
|
3344
|
+
items.forEach((item, index) => {
|
|
3345
|
+
result.add({
|
|
3346
|
+
ID: `${category}_${index}`,
|
|
3347
|
+
Name: item[nameKey] || index,
|
|
3348
|
+
Value: item[valueKey] || index,
|
|
3349
|
+
Category: category || "Missing Category",
|
|
3350
|
+
PrimaryColor: primaryColor || { r: 0, g: 0, b: 0 },
|
|
3351
|
+
OnPrimaryColor: onPrimaryColor || { r: 255, g: 255, b: 255 }
|
|
3485
3352
|
});
|
|
3486
3353
|
});
|
|
3487
3354
|
return result;
|
|
3488
3355
|
}
|
|
3489
3356
|
|
|
3490
|
-
|
|
3491
|
-
// - Reference div content input search
|
|
3492
|
-
const headContent_ref = React.createRef();
|
|
3493
|
-
const optionList = document.getElementsByClassName("cw-multiselect-option-list");
|
|
3494
|
-
const refContent = useRef(null);
|
|
3495
|
-
// - Hooks show clear button
|
|
3496
|
-
const [_isShowClearButton, setShowClearButton] = useState(false);
|
|
3497
|
-
// - Hooks value of input search
|
|
3498
|
-
const [inputValue, setInputValue] = useState("");
|
|
3499
|
-
// Ref [ input ] ( cwellt_headFilterTab )
|
|
3500
|
-
const headInputFitlerTab_ref = useRef(null);
|
|
3501
|
-
const headFilter_content_tags_ref = useRef(null);
|
|
3502
|
-
// cwellt_headFilterTab [ onclick ( show dropDown and enable input .focus() )]
|
|
3503
|
-
const onClickHeaderFilterTab = () => {
|
|
3504
|
-
// Show and hide dropDownContainer - onShowDropDown [ interface ]
|
|
3505
|
-
cwelltFilterTabMultiSelectProps.onShowDropDown();
|
|
3506
|
-
// Click on dropDown enable input - [ ref : headFitlerTab_ref ] and evaluating not null
|
|
3507
|
-
if (headInputFitlerTab_ref.current) {
|
|
3508
|
-
headInputFitlerTab_ref.current.focus();
|
|
3509
|
-
}
|
|
3510
|
-
};
|
|
3511
|
-
// - on change input search
|
|
3512
|
-
const onChangeInputSearch = (event_onChangeInput) => {
|
|
3513
|
-
// let searchInput_length = event_onChangeInput.currentTarget.value.length;
|
|
3514
|
-
// if (searchInput_length > 0) {
|
|
3515
|
-
// setShowClearButton(true);
|
|
3516
|
-
// } else {
|
|
3517
|
-
// setShowClearButton(false);
|
|
3518
|
-
// }
|
|
3519
|
-
setInputValue(event_onChangeInput.currentTarget.value);
|
|
3520
|
-
// - onChangeSearch
|
|
3521
|
-
cwelltFilterTabMultiSelectProps.onChangeSearch(event_onChangeInput);
|
|
3522
|
-
};
|
|
3523
|
-
// - clear input value
|
|
3524
|
-
const onClearInputValue = (e) => {
|
|
3525
|
-
setInputValue("");
|
|
3526
|
-
setShowClearButton(false);
|
|
3527
|
-
// onClearValue
|
|
3528
|
-
cwelltFilterTabMultiSelectProps.onClearValue(e);
|
|
3529
|
-
};
|
|
3530
|
-
// - onKeyPress
|
|
3531
|
-
const onKeyPressInput = (event_keyPress) => {
|
|
3532
|
-
if (typeof cwelltFilterTabMultiSelectProps.onKeypressInput === "function") {
|
|
3533
|
-
cwelltFilterTabMultiSelectProps.onKeypressInput(event_keyPress);
|
|
3534
|
-
// clear input field
|
|
3535
|
-
if (event_keyPress.key === "Enter") {
|
|
3536
|
-
setInputValue("");
|
|
3537
|
-
}
|
|
3538
|
-
}
|
|
3539
|
-
};
|
|
3540
|
-
const handleBlur = (event) => {
|
|
3541
|
-
if (typeof cwelltFilterTabMultiSelectProps.onBlur === "function") {
|
|
3542
|
-
cwelltFilterTabMultiSelectProps.onBlur(event);
|
|
3543
|
-
}
|
|
3544
|
-
};
|
|
3545
|
-
const clickOptionList = () => {
|
|
3546
|
-
if (optionList.length > 0) {
|
|
3547
|
-
Array.from(optionList).forEach(index => {
|
|
3548
|
-
const optionListItem = index;
|
|
3549
|
-
optionListItem.addEventListener("click", () => {
|
|
3550
|
-
setInputValue("");
|
|
3551
|
-
});
|
|
3552
|
-
});
|
|
3553
|
-
}
|
|
3554
|
-
};
|
|
3555
|
-
//#region useEffect
|
|
3556
|
-
useEffect(() => {
|
|
3557
|
-
window.addEventListener("keypress", onKeyPressInput);
|
|
3558
|
-
clickOptionList();
|
|
3559
|
-
return () => {
|
|
3560
|
-
window.removeEventListener("keypress", onKeyPressInput);
|
|
3561
|
-
};
|
|
3562
|
-
});
|
|
3563
|
-
//#endregion
|
|
3564
|
-
return (jsxs("div", { className: cwelltFilterTabMultiSelectProps.className + " cw-headfilter", style: cwelltFilterTabMultiSelectProps.style, id: cwelltFilterTabMultiSelectProps.Id, onMouseLeave: cwelltFilterTabMultiSelectProps.onMouseLeave, ref: refContent, children: [jsxs("div", { className: "cw-headfilter-wrapper", onClick: () => onClickHeaderFilterTab(), children: [jsx(CwIcon, { iconId: "search", size: "large" }), jsxs("div", { className: "cw-headfilter-content", children: [jsx("div", { className: "cw-flex-row cw-gap-small cw-align-left-center cw-flex-wrap", ref: headFilter_content_tags_ref, children: cwelltFilterTabMultiSelectProps.tagValueContent }), jsx("div", { className: "headFilter_search_content", ref: headContent_ref, children: jsx("input", { id: "headFilter_inputSearch", value: inputValue, onKeyPress: event_keyPress => onKeyPressInput(event_keyPress), onBlur: handleBlur, type: "search", onChange: event_onChangeInput => onChangeInputSearch(event_onChangeInput), placeholder: cwelltFilterTabMultiSelectProps.placeholder_desc, ref: headInputFitlerTab_ref }) })] }), jsx(CwIcon, { iconId: "close-circle", onClick: (e) => onClearInputValue(e) })] }), cwelltFilterTabMultiSelectProps.children] }));
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
function CwOptionList(optionListProps) {
|
|
3568
|
-
//#region References
|
|
3569
|
-
// - Ref : optionList
|
|
3570
|
-
const optionListSelected_ref = React.createRef();
|
|
3571
|
-
const optionListSelected_input_ref = React.createRef();
|
|
3572
|
-
//#endregion
|
|
3573
|
-
//#region Hooks
|
|
3574
|
-
// - Hooks : selected optionList
|
|
3575
|
-
// const [isSelectedOptionList, setIsSelectedOptionList] = useState(optionListProps.isSelected || false);
|
|
3576
|
-
//#endregion
|
|
3577
|
-
//#region Functions
|
|
3578
|
-
const onClickSelectOptionList = (event_click) => {
|
|
3579
|
-
// - click of custom component
|
|
3580
|
-
// onSelectedOptionList();
|
|
3581
|
-
// - click of property interface
|
|
3582
|
-
optionListProps.onClick(event_click);
|
|
3583
|
-
};
|
|
3584
|
-
const onKeyPressOptionList = (event_onKeyPress) => {
|
|
3585
|
-
if (typeof optionListProps.onKeyPress === "function") {
|
|
3586
|
-
optionListProps.onKeyPress(event_onKeyPress);
|
|
3587
|
-
}
|
|
3588
|
-
};
|
|
3589
|
-
//#endregion
|
|
3590
|
-
//#region Useffect
|
|
3591
|
-
useEffect(() => {
|
|
3592
|
-
window.addEventListener("keypress", onKeyPressOptionList);
|
|
3593
|
-
return () => {
|
|
3594
|
-
window.removeEventListener("keypress", onKeyPressOptionList);
|
|
3595
|
-
};
|
|
3596
|
-
}, []);
|
|
3597
|
-
//#endregion
|
|
3598
|
-
return (jsxs("div", { className: `cw-multiselect-option-list${optionListProps.isSelected ? ' option-active' : ''}`, onClick: event_click => onClickSelectOptionList(event_click), id: optionListProps.idOptionList, ref: optionListSelected_ref, "aria-value-text": optionListProps.value, onKeyPress: event_onKeyPress => onKeyPressOptionList(event_onKeyPress), style: optionListProps.style, children: [jsx("label", { htmlFor: optionListProps.idOptionList, children: optionListProps.children }), jsx("input", { type: "checkbox", value: optionListProps.value, ref: optionListSelected_input_ref, id: optionListProps.idOptionList, onClick: optionListProps.onChangeOptionList })] }));
|
|
3599
|
-
}
|
|
3600
|
-
|
|
3601
|
-
//#endregion
|
|
3602
|
-
function CwMultiselect(CwelltCustomFilterTabProps) {
|
|
3603
|
-
//#region Reference
|
|
3604
|
-
const refOptionListContent = useRef(null);
|
|
3605
|
-
const containerRef = useRef(null);
|
|
3606
|
-
//#endregion
|
|
3607
|
-
//#region Hooks
|
|
3608
|
-
const [isShowDropDownfiltered, setShowDropDownfiltered] = useState(false);
|
|
3609
|
-
// const [tagValue, setTagValue] = useState<{
|
|
3610
|
-
// tagDesc: string;
|
|
3611
|
-
// bgContent: string;
|
|
3612
|
-
// bgTag: string;
|
|
3613
|
-
// color: string;
|
|
3614
|
-
// }[]>([]);
|
|
3615
|
-
// Hook active label filter item tab [ All ]
|
|
3616
|
-
const [isActive_filter_item_all, setActive_filter_item_all] = useState(true);
|
|
3617
|
-
// Hook active laberl fitler item tab [ e.g.: Duty ]
|
|
3618
|
-
const [isActive_filter_item, setActive_filter_item] = useState(null);
|
|
3619
|
-
// Hook isSelected option list
|
|
3620
|
-
//const [isSelected_optionList, setSelected_optionList] = useState<{ [key: string]: boolean }>({});
|
|
3621
|
-
//#endregion
|
|
3622
|
-
//#region Functions
|
|
3623
|
-
//#region CwelltFilterTabMultiSelect [ properties functions ]
|
|
3624
|
-
//#region onClearValue
|
|
3625
|
-
const clearValue = (e_clear) => {
|
|
3626
|
-
// List items to remove class and be visible
|
|
3627
|
-
// Item searched
|
|
3628
|
-
const itemSearched = document.getElementsByClassName("item-search");
|
|
3629
|
-
// Item hidden
|
|
3630
|
-
const itemHidden = document.getElementsByClassName("hidden-item");
|
|
3631
|
-
// Item searcched
|
|
3632
|
-
if (itemSearched.length > 0) {
|
|
3633
|
-
for (let i = 0; i <= itemSearched.length; i++) {
|
|
3634
|
-
itemSearched[i]?.classList.remove("item-search");
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
// Item hidden
|
|
3638
|
-
if (itemHidden.length > 0) {
|
|
3639
|
-
for (let i = 0; i <= itemHidden.length; i++) {
|
|
3640
|
-
itemHidden[i]?.classList.remove("hidden-item");
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
|
-
// optionList [ disbaled active className according their text ]
|
|
3644
|
-
const parent = e_clear.currentTarget.parentElement.parentElement;
|
|
3645
|
-
const optionActive = parent.getElementsByClassName("option-active");
|
|
3646
|
-
const valueIds = [];
|
|
3647
|
-
const resultList = [];
|
|
3648
|
-
if (optionActive.length > 0) {
|
|
3649
|
-
CwelltCustomFilterTabProps.onclickHandleChange(valueIds, resultList);
|
|
3650
|
-
Array.from(optionActive).forEach(index => {
|
|
3651
|
-
const optionActive_array = index;
|
|
3652
|
-
optionActive_array.classList.remove("option-active");
|
|
3653
|
-
});
|
|
3654
|
-
}
|
|
3655
|
-
};
|
|
3656
|
-
//#endregion
|
|
3657
|
-
//#region onChangeSearch
|
|
3658
|
-
const onChangeSearch = (e_onchange) => {
|
|
3659
|
-
const filterText_lowerCase = e_onchange.currentTarget.value.toLowerCase();
|
|
3660
|
-
// Tags for filtering
|
|
3661
|
-
const listTag = document.getElementsByClassName("cw-multiselect-option-list");
|
|
3662
|
-
for (let i = 0; i <= listTag.length; i++) {
|
|
3663
|
-
if (listTag[i] !== undefined) {
|
|
3664
|
-
const textTagValue = listTag[i].textContent;
|
|
3665
|
-
// Writting
|
|
3666
|
-
if (textTagValue?.toLowerCase().includes(filterText_lowerCase)) {
|
|
3667
|
-
listTag[i].classList.add("item-search");
|
|
3668
|
-
}
|
|
3669
|
-
else {
|
|
3670
|
-
listTag[i].classList.add("hidden-item");
|
|
3671
|
-
}
|
|
3672
|
-
// remove written
|
|
3673
|
-
if (!textTagValue?.toLowerCase().includes(filterText_lowerCase)) {
|
|
3674
|
-
listTag[i].classList.remove("item-search");
|
|
3675
|
-
}
|
|
3676
|
-
else {
|
|
3677
|
-
listTag[i].classList.remove("hidden-item");
|
|
3678
|
-
}
|
|
3679
|
-
if (filterText_lowerCase === "") {
|
|
3680
|
-
listTag[i].classList.remove("item-search");
|
|
3681
|
-
}
|
|
3682
|
-
}
|
|
3683
|
-
}
|
|
3684
|
-
// Length of string > 0 show dropDownContainerComp
|
|
3685
|
-
if (e_onchange.currentTarget.value.length > 0) {
|
|
3686
|
-
setShowDropDownfiltered(true);
|
|
3687
|
-
}
|
|
3688
|
-
};
|
|
3689
|
-
//#endregion
|
|
3690
|
-
//#region onKeyPressInput
|
|
3691
|
-
const onKeyPressSearch = (event_onKeypress) => {
|
|
3692
|
-
//#region Variables
|
|
3693
|
-
const keyPressed = event_onKeypress.key;
|
|
3694
|
-
const optionSearched = document.getElementsByClassName("item-search");
|
|
3695
|
-
//#endregion
|
|
3696
|
-
// first item selected or same text
|
|
3697
|
-
const optionArray = Array.from(optionSearched);
|
|
3698
|
-
if (optionArray.length > 0 && keyPressed === "Enter" && event_onKeypress.currentTarget.value !== "") {
|
|
3699
|
-
const firstElement_optionList = optionArray[0];
|
|
3700
|
-
const textContent = firstElement_optionList.textContent;
|
|
3701
|
-
const elementList = CwelltCustomFilterTabProps.selectListsItems?.find(e => e.find(el => el.description === textContent));
|
|
3702
|
-
const element = elementList?.find(el => el.description === textContent);
|
|
3703
|
-
if (element !== undefined) {
|
|
3704
|
-
const exist = CwelltCustomFilterTabProps.selectedListsItems?.some(s => s.description === textContent);
|
|
3705
|
-
if (exist === false) {
|
|
3706
|
-
handleClickTag(element);
|
|
3707
|
-
}
|
|
3708
|
-
}
|
|
3709
|
-
const optionList_item_hidden = document.getElementsByClassName("hidden-item");
|
|
3710
|
-
if (optionList_item_hidden.length > 0) {
|
|
3711
|
-
Array.from(optionList_item_hidden).forEach(index => {
|
|
3712
|
-
const optionList_hidden_array = index;
|
|
3713
|
-
if (optionList_hidden_array.classList.contains("hidden-item")) {
|
|
3714
|
-
optionList_hidden_array.classList.remove("hidden-item");
|
|
3715
|
-
}
|
|
3716
|
-
});
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
};
|
|
3720
|
-
//#endregion
|
|
3721
|
-
//#region ShowDropDownFilter
|
|
3722
|
-
const showDropDownfiltered = () => {
|
|
3723
|
-
setShowDropDownfiltered(!isShowDropDownfiltered);
|
|
3724
|
-
};
|
|
3725
|
-
//#endregion
|
|
3726
|
-
class SelectListTest {
|
|
3727
|
-
description;
|
|
3728
|
-
key;
|
|
3729
|
-
type;
|
|
3730
|
-
typeName;
|
|
3731
|
-
val;
|
|
3732
|
-
value;
|
|
3733
|
-
active;
|
|
3734
|
-
}
|
|
3735
|
-
const handleClickTag = (e) => {
|
|
3736
|
-
const preList = CwelltCustomFilterTabProps.selectedListsItems || [];
|
|
3737
|
-
const valueIds = [];
|
|
3738
|
-
const resultList = preList?.map(s => {
|
|
3739
|
-
const item = new SelectListTest();
|
|
3740
|
-
item.description = s.description;
|
|
3741
|
-
item.key = s.type + "_" + s.id;
|
|
3742
|
-
item.type = s.type;
|
|
3743
|
-
item.val = s.id;
|
|
3744
|
-
item.value = item.key;
|
|
3745
|
-
item.active = s.active ?? false;
|
|
3746
|
-
valueIds.push(item.key);
|
|
3747
|
-
return item;
|
|
3748
|
-
});
|
|
3749
|
-
const a = new SelectListTest();
|
|
3750
|
-
a.description = e.description;
|
|
3751
|
-
a.key = e.type + "_" + e.id;
|
|
3752
|
-
a.type = e.type;
|
|
3753
|
-
a.val = e.id;
|
|
3754
|
-
a.value = a.key;
|
|
3755
|
-
a.active = e.active;
|
|
3756
|
-
const exist = resultList?.some(item => item.key === a.key);
|
|
3757
|
-
if (exist) {
|
|
3758
|
-
a.active = false;
|
|
3759
|
-
const list = resultList?.filter(item => item.key !== a.key);
|
|
3760
|
-
const values = valueIds.filter(v => v !== a.key);
|
|
3761
|
-
CwelltCustomFilterTabProps.onclickHandleChange(values, list);
|
|
3762
|
-
}
|
|
3763
|
-
else {
|
|
3764
|
-
a.active = true;
|
|
3765
|
-
resultList?.push(a);
|
|
3766
|
-
valueIds.push(a.key);
|
|
3767
|
-
CwelltCustomFilterTabProps.onclickHandleChange(valueIds, resultList);
|
|
3768
|
-
}
|
|
3769
|
-
// // Selected item option list
|
|
3770
|
-
// setSelected_optionList((prevSelectedStates) => ({
|
|
3771
|
-
// ...prevSelectedStates,
|
|
3772
|
-
// [a.key]: !prevSelectedStates[a.key],
|
|
3773
|
-
// }));
|
|
3774
|
-
// clear filter by text after clicked in option list
|
|
3775
|
-
const optionList_item_hidden = document.getElementsByClassName("hidden-item");
|
|
3776
|
-
if (optionList_item_hidden.length > 0) {
|
|
3777
|
-
Array.from(optionList_item_hidden).forEach(index => {
|
|
3778
|
-
const optionList_hidden_array = index;
|
|
3779
|
-
if (optionList_hidden_array.classList.contains("hidden-item")) {
|
|
3780
|
-
optionList_hidden_array.classList.remove("hidden-item");
|
|
3781
|
-
}
|
|
3782
|
-
});
|
|
3783
|
-
}
|
|
3784
|
-
// Check click from option list has custom tag header of custom filter tab
|
|
3785
|
-
const tagActive = document.getElementsByClassName("multiselect-active-tag");
|
|
3786
|
-
const optionList = document.getElementsByClassName("cw-multiselect-option-list");
|
|
3787
|
-
if (tagActive.length > 0 && optionList.length > 0) {
|
|
3788
|
-
Array.from(tagActive).forEach(_index => {
|
|
3789
|
-
Array.from(optionList).forEach(index => {
|
|
3790
|
-
const optionList_array = index;
|
|
3791
|
-
const optionId = optionList_array.getAttribute('data-id');
|
|
3792
|
-
if (optionId === (e.type + "_" + e.id)) {
|
|
3793
|
-
optionList_array.classList.remove("option-active");
|
|
3794
|
-
}
|
|
3795
|
-
});
|
|
3796
|
-
});
|
|
3797
|
-
}
|
|
3798
|
-
const optionList_desc = document.getElementsByClassName("option-active");
|
|
3799
|
-
if (optionList_desc.length > 0) {
|
|
3800
|
-
Array.from(optionList_desc).forEach(index => {
|
|
3801
|
-
const optionList_desc_array = index;
|
|
3802
|
-
if (optionList_desc_array.innerText === a.description) {
|
|
3803
|
-
optionList_desc_array.classList.remove("option-active");
|
|
3804
|
-
}
|
|
3805
|
-
});
|
|
3806
|
-
}
|
|
3807
|
-
// Click to hide dropDownContainer
|
|
3808
|
-
setShowDropDownfiltered(false);
|
|
3809
|
-
};
|
|
3810
|
-
// [ click custom tag ]
|
|
3811
|
-
const closeTagHandle = (e) => {
|
|
3812
|
-
const preList = CwelltCustomFilterTabProps.selectedListsItems;
|
|
3813
|
-
const valueIds = [];
|
|
3814
|
-
const resultList = preList?.map(s => {
|
|
3815
|
-
const item = new SelectListTest();
|
|
3816
|
-
item.description = s.description;
|
|
3817
|
-
item.key = s.type + "_" + s.id;
|
|
3818
|
-
item.type = s.type;
|
|
3819
|
-
item.val = s.id;
|
|
3820
|
-
item.value = item.key;
|
|
3821
|
-
valueIds.push(item.key);
|
|
3822
|
-
return item;
|
|
3823
|
-
});
|
|
3824
|
-
const a = new SelectListTest();
|
|
3825
|
-
a.description = e.description;
|
|
3826
|
-
a.key = e.type + "_" + e.id;
|
|
3827
|
-
a.type = e.type;
|
|
3828
|
-
a.val = e.id;
|
|
3829
|
-
a.value = a.key;
|
|
3830
|
-
const resultListFilter = resultList?.filter(item => item.key !== a.key);
|
|
3831
|
-
const valueIdsFilter = valueIds.filter(item => item !== a.key);
|
|
3832
|
-
CwelltCustomFilterTabProps.onclickHandleChange(valueIdsFilter, resultListFilter);
|
|
3833
|
-
// // Selected item option list - remove active option list
|
|
3834
|
-
// setSelected_optionList((prevSelectedStates) => ({
|
|
3835
|
-
// ...prevSelectedStates,
|
|
3836
|
-
// [a.key]: false[a.key],
|
|
3837
|
-
// }));
|
|
3838
|
-
const optionList_active = document.getElementsByClassName("option-active");
|
|
3839
|
-
if (optionList_active.length > 0) {
|
|
3840
|
-
Array.from(optionList_active).forEach(index => {
|
|
3841
|
-
const optionList_active_array = index;
|
|
3842
|
-
const optionId = optionList_active_array.getAttribute('data-id');
|
|
3843
|
-
if (optionId === (e.type + "_" + e.id)) {
|
|
3844
|
-
optionList_active_array.classList.remove("option-active");
|
|
3845
|
-
}
|
|
3846
|
-
});
|
|
3847
|
-
}
|
|
3848
|
-
};
|
|
3849
|
-
//#endregion
|
|
3850
|
-
//#region DropDownContainer [ properties functions ]
|
|
3851
|
-
//#region onKeyDownDropDownContainer [ press ESC dropDownContainer dissapear - ArrowUp && ArrowDown ]
|
|
3852
|
-
const onKeyDownDropDownContent = (event_onKeyDown) => {
|
|
3853
|
-
const items = document.querySelectorAll(".cw-multiselect-option-list");
|
|
3854
|
-
let optionIndex = Array.from(items).findIndex(item => item.classList.contains("keyboard-focus"));
|
|
3855
|
-
if (event_onKeyDown.key === "Escape") {
|
|
3856
|
-
// DropDown disappear
|
|
3857
|
-
setShowDropDownfiltered(false);
|
|
3858
|
-
}
|
|
3859
|
-
// KeyDown
|
|
3860
|
-
if (event_onKeyDown.key === "ArrowDown") {
|
|
3861
|
-
event_onKeyDown.preventDefault();
|
|
3862
|
-
removeHighlight();
|
|
3863
|
-
optionIndex = getNextIndex(optionIndex, items.length);
|
|
3864
|
-
highlightOption(optionIndex);
|
|
3865
|
-
}
|
|
3866
|
-
// KeyUp
|
|
3867
|
-
if (event_onKeyDown.key === "ArrowUp") {
|
|
3868
|
-
event_onKeyDown.preventDefault();
|
|
3869
|
-
removeHighlight();
|
|
3870
|
-
optionIndex = getPreviousIndex(optionIndex, items.length);
|
|
3871
|
-
highlightOption(optionIndex);
|
|
3872
|
-
}
|
|
3873
|
-
};
|
|
3874
|
-
const removeHighlight = () => {
|
|
3875
|
-
const highlightedItem = document.querySelector(".keyboard-focus");
|
|
3876
|
-
if (highlightedItem) {
|
|
3877
|
-
highlightedItem.classList.remove("keyboard-focus");
|
|
3878
|
-
}
|
|
3879
|
-
};
|
|
3880
|
-
const getNextIndex = (currentIndex, length) => {
|
|
3881
|
-
return (currentIndex + 1) % length;
|
|
3882
|
-
};
|
|
3883
|
-
const getPreviousIndex = (currentIndex, length) => {
|
|
3884
|
-
return (currentIndex - 1 + length) % length;
|
|
3885
|
-
};
|
|
3886
|
-
const highlightOption = (index) => {
|
|
3887
|
-
const items = document.querySelectorAll(".cw-multiselect-option-list");
|
|
3888
|
-
const item = items[index];
|
|
3889
|
-
item.classList.add("keyboard-focus");
|
|
3890
|
-
};
|
|
3891
|
-
//#endregion
|
|
3892
|
-
//#region onMouseLeave
|
|
3893
|
-
const handleInputBlur = () => {
|
|
3894
|
-
setTimeout(() => {
|
|
3895
|
-
if (!containerRef.current?.contains(document.activeElement)) {
|
|
3896
|
-
setShowDropDownfiltered(false);
|
|
3897
|
-
}
|
|
3898
|
-
}, 150);
|
|
3899
|
-
};
|
|
3900
|
-
useEffect(() => {
|
|
3901
|
-
const handleClickOutside = (event) => {
|
|
3902
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
3903
|
-
setShowDropDownfiltered(false);
|
|
3904
|
-
}
|
|
3905
|
-
};
|
|
3906
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
3907
|
-
return () => {
|
|
3908
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
3909
|
-
};
|
|
3910
|
-
}, []);
|
|
3911
|
-
//#endregion
|
|
3912
|
-
// Click filter item button
|
|
3913
|
-
const clickFilter_item = (id) => {
|
|
3914
|
-
// content items - looking for className by it - corresponded by their current group
|
|
3915
|
-
const contentItems = document.getElementsByClassName(id);
|
|
3916
|
-
const contentAll = document.getElementsByClassName("multiselect-tag-group");
|
|
3917
|
-
if (contentAll.length > 0) {
|
|
3918
|
-
Array.from(contentAll).forEach(index => {
|
|
3919
|
-
const contentAll_array = index;
|
|
3920
|
-
contentAll_array.classList.add("hidden-group");
|
|
3921
|
-
});
|
|
3922
|
-
}
|
|
3923
|
-
if (contentItems.length > 0) {
|
|
3924
|
-
Array.from(contentItems).forEach(index => {
|
|
3925
|
-
const contentItems_array = index;
|
|
3926
|
-
contentItems_array.classList.remove("hidden-group");
|
|
3927
|
-
});
|
|
3928
|
-
}
|
|
3929
|
-
// Adding custom className acitive
|
|
3930
|
-
setActive_filter_item(id);
|
|
3931
|
-
// Remove active className [ label tab : ( ALL ) ]
|
|
3932
|
-
setActive_filter_item_all(false);
|
|
3933
|
-
};
|
|
3934
|
-
const showAllItem = () => {
|
|
3935
|
-
//let currentBtn = e.currentTarget;
|
|
3936
|
-
const contentAll = document.getElementsByClassName("multiselect-tag-group");
|
|
3937
|
-
if (contentAll.length > 0) {
|
|
3938
|
-
Array.from(contentAll).forEach(index => {
|
|
3939
|
-
const contentAll_array = index;
|
|
3940
|
-
contentAll_array.classList.remove("hidden-group");
|
|
3941
|
-
// active className - all
|
|
3942
|
-
setActive_filter_item_all(true);
|
|
3943
|
-
setActive_filter_item("");
|
|
3944
|
-
});
|
|
3945
|
-
}
|
|
3946
|
-
};
|
|
3947
|
-
//#endregion
|
|
3948
|
-
useEffect(() => {
|
|
3949
|
-
if (CwelltCustomFilterTabProps.selectedListsItems) {
|
|
3950
|
-
const allOptions = document.getElementsByClassName("cw-multiselect-option-list");
|
|
3951
|
-
Array.from(allOptions).forEach(option => {
|
|
3952
|
-
option.classList.remove("option-active");
|
|
3953
|
-
});
|
|
3954
|
-
CwelltCustomFilterTabProps.selectedListsItems.forEach(selectedItem => {
|
|
3955
|
-
Array.from(allOptions).forEach(option => {
|
|
3956
|
-
const optionElement = option;
|
|
3957
|
-
if (optionElement.innerText === selectedItem.description) {
|
|
3958
|
-
optionElement.classList.add("option-active");
|
|
3959
|
-
}
|
|
3960
|
-
});
|
|
3961
|
-
});
|
|
3962
|
-
}
|
|
3963
|
-
}, [CwelltCustomFilterTabProps.selectedListsItems]);
|
|
3964
|
-
return (jsx("div", { ref: containerRef, children: jsx(CwHeadFilter, { Id: CwelltCustomFilterTabProps.id, onChangeSearch: (e_onchange) => onChangeSearch(e_onchange), onClearValue: (e_clear) => clearValue(e_clear), onKeypressInput: onKeyPressSearch, onShowDropDown: showDropDownfiltered, placeholder_desc: CwelltCustomFilterTabProps.placeholder, style: CwelltCustomFilterTabProps.style, onBlur: handleInputBlur,
|
|
3965
|
-
// onMouseLeave={onMouseLeave_dropDownContainer}
|
|
3966
|
-
className: CwelltCustomFilterTabProps.selectedListsItems?.length === 0
|
|
3967
|
-
? "cw-filter-tab-multi-select-show-icon"
|
|
3968
|
-
: "cw-filter-tab-multi-select-hidden-icon", tagValueContent: jsx("div", { className: "cw-flex-row cw-gap-small", children: CwelltCustomFilterTabProps.selectedListsItems?.map((s, index) => {
|
|
3969
|
-
return s.type !== undefined ? (jsx(CwTag, { styleTag: {
|
|
3970
|
-
background: s.color,
|
|
3971
|
-
color: getContrastColor(s.color),
|
|
3972
|
-
}, idTag: s.type + "_" + s.id, closableTag: true, onClickClosableTag: () => closeTagHandle(s), "data-id": s.type + "_" + s.id, className: "multiselect-active-tag", children: s.description }, index)) : (jsx("div", {}));
|
|
3973
|
-
}) }), children: jsx(CwDropdownContainer, { dropDownState: isShowDropDownfiltered, idDropDownContainer: CwelltCustomFilterTabProps.idDropDownContainer, onKeyDownDropDownContainer: (event_onKeyDown) => onKeyDownDropDownContent(event_onKeyDown), children: jsxs("div", { className: "cw-multiselect-dropdown", children: [jsxs("header", { children: [jsx("label", { "data-active": isActive_filter_item_all, onClick: showAllItem, children: "ALL" }), CwelltCustomFilterTabProps.selectListsItems?.map((slArray, i) => (jsx("label", { "data-active": isActive_filter_item === 'content_' + i,
|
|
3974
|
-
// todo : giving parameter by id to search by their corresponding group it list options and className content with their id in this case key ( i ) by .map function
|
|
3975
|
-
onClick: () => clickFilter_item("content_" + i), id: "content_" + i, children: slArray.length > 0 && slArray[0].typeName !== undefined
|
|
3976
|
-
? slArray[0].typeName
|
|
3977
|
-
: slArray.length > 0
|
|
3978
|
-
? slArray[0].type
|
|
3979
|
-
: "" }, i)))] }), jsx("div", { className: "cw-multiselect-tags-container", children: CwelltCustomFilterTabProps.selectListsItems?.map((slArray, i) => (jsx("div", { id: "content_" + i, className: `multiselect-tag-group content_${i}`, ref: refOptionListContent, children: slArray.map(sl => {
|
|
3980
|
-
const isSelected = CwelltCustomFilterTabProps.selectedListsItems?.some(selected => selected.type === sl.type && selected.id === sl.id) || false;
|
|
3981
|
-
return (jsx(CwOptionList, { idOptionList: sl.type + "_" + sl.id, value: sl.type + "_" + sl.id, title: sl.description, onClick: () => handleClickTag(sl), isSelected: sl.active, "data-id": sl.type + "_" + sl.id, children: jsx(CwTag, { styleTag: {
|
|
3982
|
-
background: sl.color,
|
|
3983
|
-
color: getContrastColor(sl.color),
|
|
3984
|
-
}, closableTag: isSelected, children: sl.description }) }, sl.type + "_" + sl.id));
|
|
3985
|
-
}) }, "group" + i))) })] }) }) }) }));
|
|
3986
|
-
}
|
|
3987
|
-
|
|
3988
|
-
var styles$7 = {"cw-multifilter-tag":"cw-multi-filter-tag-module_cw-multifilter-tag__Epda-"};
|
|
3357
|
+
var styles$8 = {"cw-multifilter-tag":"cw-multi-filter-tag-module_cw-multifilter-tag__Epda-"};
|
|
3989
3358
|
|
|
3990
3359
|
const CwMultiFilterTag = props => {
|
|
3991
|
-
const { ID, Name, Value, Category, Removable, PrimaryColor,
|
|
3992
|
-
const
|
|
3993
|
-
const
|
|
3994
|
-
return (
|
|
3995
|
-
color: TextColor,
|
|
3996
|
-
backgroundColor: BackgroundColor,
|
|
3997
|
-
opacity: Selected && !Removable ? "0.5" : "1",
|
|
3998
|
-
outlineColor: TextColor
|
|
3999
|
-
}, onClick: () => {
|
|
3360
|
+
const { ID, Name, Value, Category, Removable, PrimaryColor, Selectable, Selected } = props;
|
|
3361
|
+
const backgroundColor = `rgb(${PrimaryColor.r},${PrimaryColor.g},${PrimaryColor.b})`;
|
|
3362
|
+
const isOutlineMode = Selected && !Removable;
|
|
3363
|
+
return (jsx("li", { className: styles$8["cw-multifilter-tag"], id: ID, "data-value": Value, "data-category": Category, "data-selected": !!Selected, title: Name, onClick: () => {
|
|
4000
3364
|
if (Selectable)
|
|
4001
|
-
OnSelect?.(props);
|
|
4002
|
-
}, children:
|
|
3365
|
+
props.OnSelect?.(props);
|
|
3366
|
+
}, children: jsx(CwChip, { label: Name, colorScheme: "custom", customColor: backgroundColor, variant: isOutlineMode ? "outline" : "soft", closable: Removable, onClose: () => props.OnRemove?.(props),
|
|
3367
|
+
// This style ensures the chip color is accessible over white background
|
|
3368
|
+
style: isOutlineMode ? {
|
|
3369
|
+
'--chip-accent': `hsl(from ${backgroundColor} h s 40)`
|
|
3370
|
+
} : undefined }) }));
|
|
4003
3371
|
};
|
|
4004
3372
|
|
|
4005
|
-
var styles$
|
|
3373
|
+
var styles$7 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-multi-filter-catalog-container__S3nsq","cw-multi-filter":"cw-multi-filter-module_cw-multi-filter__zipBK","cw-multi-filter-search":"cw-multi-filter-module_cw-multi-filter-search__eyHr0"};
|
|
4006
3374
|
|
|
4007
3375
|
/**
|
|
4008
3376
|
* A multiple filter selector, a MULTI-SELECT even. Allows users to select and filter items based on tags.
|
|
@@ -4017,7 +3385,7 @@ var styles$6 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
|
|
|
4017
3385
|
* - `Category`: Group the filter belongs to
|
|
4018
3386
|
* - `ID`: Unique identifier for the filter
|
|
4019
3387
|
* - `PrimaryColor`: Background color of the tag
|
|
4020
|
-
* - `OnPrimaryColor`: Text color of the tag
|
|
3388
|
+
* - `OnPrimaryColor`: (Optional, deprecated) Text color of the tag - contrast is now calculated automatically
|
|
4021
3389
|
*
|
|
4022
3390
|
* ```
|
|
4023
3391
|
* ╭───────────────────────────────────────────────────────────────╮
|
|
@@ -4059,7 +3427,6 @@ var styles$6 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
|
|
|
4059
3427
|
* Value: "admin",
|
|
4060
3428
|
* Category: "Roles",
|
|
4061
3429
|
* ID: "Roles_admin",
|
|
4062
|
-
* OnPrimaryColor: hexToRGB("#2050a8"),
|
|
4063
3430
|
* PrimaryColor: hexToRGB("#cedcff")
|
|
4064
3431
|
* },
|
|
4065
3432
|
* {
|
|
@@ -4067,7 +3434,6 @@ var styles$6 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
|
|
|
4067
3434
|
* Value: "user",
|
|
4068
3435
|
* Category: "Roles",
|
|
4069
3436
|
* ID: "Roles_user",
|
|
4070
|
-
* OnPrimaryColor: hexToRGB("#2050a8"),
|
|
4071
3437
|
* PrimaryColor: hexToRGB("#cedcff")
|
|
4072
3438
|
* },
|
|
4073
3439
|
* {
|
|
@@ -4075,7 +3441,6 @@ var styles$6 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
|
|
|
4075
3441
|
* Value: "IT",
|
|
4076
3442
|
* Category: "Departments",
|
|
4077
3443
|
* ID: "Departments_IT",
|
|
4078
|
-
* OnPrimaryColor: hexToRGB("#a82037"),
|
|
4079
3444
|
* PrimaryColor: hexToRGB("#ffceda")
|
|
4080
3445
|
* },
|
|
4081
3446
|
* {
|
|
@@ -4083,7 +3448,6 @@ var styles$6 = {"cw-multi-filter-catalog-container":"cw-multi-filter-module_cw-m
|
|
|
4083
3448
|
* Value: "HR",
|
|
4084
3449
|
* Category: "Departments",
|
|
4085
3450
|
* ID: "Departments_HR",
|
|
4086
|
-
* OnPrimaryColor: hexToRGB("#a82037"),
|
|
4087
3451
|
* PrimaryColor: hexToRGB("#ffceda")
|
|
4088
3452
|
* }
|
|
4089
3453
|
* ]);
|
|
@@ -4187,9 +3551,10 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
|
|
|
4187
3551
|
const getColor = (category) => {
|
|
4188
3552
|
const test = categoriesMappedToTags().get(category)?.values().next().value;
|
|
4189
3553
|
if (test !== undefined) {
|
|
3554
|
+
const primaryColor = rgbAString(test.PrimaryColor.r, test.PrimaryColor.g, test.PrimaryColor.b);
|
|
4190
3555
|
return {
|
|
4191
|
-
onPrimary:
|
|
4192
|
-
primary:
|
|
3556
|
+
onPrimary: getContrastColor(primaryColor),
|
|
3557
|
+
primary: primaryColor,
|
|
4193
3558
|
};
|
|
4194
3559
|
}
|
|
4195
3560
|
else {
|
|
@@ -4248,9 +3613,9 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
|
|
|
4248
3613
|
inputRef.current?.focus();
|
|
4249
3614
|
}
|
|
4250
3615
|
};
|
|
4251
|
-
return (jsxs("form", { ref: componentRef, id: id, className: styles$
|
|
3616
|
+
return (jsxs("form", { ref: componentRef, id: id, className: styles$7["cw-multi-filter"], style: style, onSubmit: (e) => {
|
|
4252
3617
|
e.preventDefault();
|
|
4253
|
-
}, children: [jsxs("div", { onClick: handleDivClick, className: styles$
|
|
3618
|
+
}, children: [jsxs("div", { onClick: handleDivClick, className: styles$7["cw-multi-filter-search"], style: isPanelOpen ? { outline: "1px solid var(--cw-color-primary)", outlineOffset: "-2px" } : {}, children: [jsxs("ul", { id: id + "_selected_filters", children: [Array.from(selectedTags).map(tag => (createElement(CwMultiFilterTag, { ...tag, key: tag.ID, Selectable: false, Removable: true, OnRemove: () => removeTag(tag.ID) }))), jsx("input", { type: "text", id: id + "_input", ref: inputRef, value: inputTextValue, spellCheck: false, onFocus: () => setIsPanelOpen(true), onChange: e => handleInputText(e.target.value), autoComplete: "off", placeholder: "Write to filter", onKeyDown: e => {
|
|
4254
3619
|
switch (e.key) {
|
|
4255
3620
|
case "Enter":
|
|
4256
3621
|
case "Tab":
|
|
@@ -4271,7 +3636,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
|
|
|
4271
3636
|
} })] }), selectedTags.size > 0 ? (jsx("input", { type: "reset", value: "\u00D7", onClick: e => {
|
|
4272
3637
|
e.preventDefault();
|
|
4273
3638
|
onChangeSelectedTags(new Set());
|
|
4274
|
-
} })) : null] }), jsxs("section", { className: styles$
|
|
3639
|
+
} })) : null] }), jsxs("section", { className: styles$7["cw-multi-filter-catalog-container"], "data-display-none": !isPanelOpen, children: [jsxs("nav", { children: [jsx("button", { style: selectedCategory === "All"
|
|
4275
3640
|
? {
|
|
4276
3641
|
backgroundColor: "var(--cw-color-primary-container)",
|
|
4277
3642
|
color: "var(--cw-color-primary)",
|
|
@@ -4298,7 +3663,7 @@ const CwMultiFilter = ({ allTags, id, onChangeSelectedTags, selectedTags, style
|
|
|
4298
3663
|
} }, props.ID))) })] })] }));
|
|
4299
3664
|
};
|
|
4300
3665
|
|
|
4301
|
-
var styles$
|
|
3666
|
+
var styles$6 = {"tree-container":"cw-tree-view-module_tree-container__NN-HJ","tree-wrapper":"cw-tree-view-module_tree-wrapper__keBZI","tree-item":"cw-tree-view-module_tree-item__prE9N","tree-node":"cw-tree-view-module_tree-node__wfro9","selected":"cw-tree-view-module_selected__XJQ0w","non-selectable":"cw-tree-view-module_non-selectable__YuPSx","tree-children":"cw-tree-view-module_tree-children__ji8CZ","empty-state":"cw-tree-view-module_empty-state__yvRjo","tree-label":"cw-tree-view-module_tree-label__ss3Nf","tree-spacer":"cw-tree-view-module_tree-spacer__E9Ud2"};
|
|
4302
3667
|
|
|
4303
3668
|
function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId: initialSelectedId = null }) {
|
|
4304
3669
|
const [expanded, setExpanded] = useState(new Set());
|
|
@@ -4365,10 +3730,10 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
4365
3730
|
const isLeaf = !hasChildren;
|
|
4366
3731
|
const isSelected = selectedId?.toString().toLowerCase() === node.id.toString().toLowerCase();
|
|
4367
3732
|
const selectable = allowParentSelection || isLeaf;
|
|
4368
|
-
return (jsxs("div", { className: styles$
|
|
4369
|
-
styles$
|
|
4370
|
-
isSelected && styles$
|
|
4371
|
-
!selectable && styles$
|
|
3733
|
+
return (jsxs("div", { className: styles$6["tree-item"], children: [jsxs("div", { className: [
|
|
3734
|
+
styles$6["tree-node"],
|
|
3735
|
+
isSelected && styles$6["selected"],
|
|
3736
|
+
!selectable && styles$6["non-selectable"]
|
|
4372
3737
|
].filter(Boolean).join(' '), style: { paddingLeft: `${depth * 24 + 8}px` }, onClick: () => {
|
|
4373
3738
|
if (selectable) {
|
|
4374
3739
|
setSelectedId(node.id);
|
|
@@ -4377,7 +3742,7 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
4377
3742
|
else {
|
|
4378
3743
|
toggleExpand(node.id);
|
|
4379
3744
|
}
|
|
4380
|
-
}, children: [hasChildren && (jsx(CwIcon, { size: "large", iconId: isExpanded ? "chevron-down" : "chevron-right" })), jsx("div", { className: `${styles$
|
|
3745
|
+
}, children: [hasChildren && (jsx(CwIcon, { size: "large", iconId: isExpanded ? "chevron-down" : "chevron-right" })), jsx("div", { className: `${styles$6["tree-label"]} ${!hasChildren ? styles$6["tree-spacer"] : ''}`, children: node.label })] }), hasChildren && isExpanded && (jsx("div", { className: styles$6["tree-children"], children: node.children.map((child) => renderNode(child, depth + 1)) }))] }, node.id));
|
|
4381
3746
|
};
|
|
4382
3747
|
// Function to search for nodes that match the search term
|
|
4383
3748
|
const searchInTree = (nodes, searchTerm) => {
|
|
@@ -4401,7 +3766,7 @@ function CwTreeView({ data, onSelect, allowParentSelection = false, selectedId:
|
|
|
4401
3766
|
return results;
|
|
4402
3767
|
};
|
|
4403
3768
|
const filteredData = searchInTree(data, search);
|
|
4404
|
-
return (jsxs("div", { className: `cw-tree-view ${styles$
|
|
3769
|
+
return (jsxs("div", { className: `cw-tree-view ${styles$6["tree-container"]}`, children: [jsxs("header", { children: [jsx("input", { type: "text", placeholder: "Search in tree...", value: search, onChange: (e) => setSearch(e.target.value) }), search && (jsx(CwButton, { onClick: () => setSearch(""), type: "button", icon: "close", variant: "icon", color: "neutral" }))] }), jsx("div", { className: styles$6["tree-wrapper"], children: filteredData.length > 0 ? (filteredData.map((node) => renderNode(node))) : (jsxs("div", { className: styles$6["empty-state"], children: [jsx(CwIcon, { iconId: "comment" }), search ? "No results found" : "There are no items"] })) })] }));
|
|
4405
3770
|
}
|
|
4406
3771
|
|
|
4407
3772
|
function CwSearchInput(optionsProps) {
|
|
@@ -4409,363 +3774,1810 @@ function CwSearchInput(optionsProps) {
|
|
|
4409
3774
|
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
4410
3775
|
const [_selectedOption, setSelectedOption] = useState(null);
|
|
4411
3776
|
const [showDropdown, setShowDropdown] = useState(false);
|
|
3777
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3778
|
+
// Extract props
|
|
3779
|
+
const { labelProps, iconProps, alignProps, selectList, handleChange, placeholder = "Search…", disabled, renderOption, style, id, className, defaultValue, ...otherProps } = optionsProps;
|
|
3780
|
+
// Get direction for data attribute
|
|
3781
|
+
const direction = alignProps?.flexDirection || "row";
|
|
4412
3782
|
// Make default value selection when loading the component
|
|
4413
3783
|
useEffect(() => {
|
|
4414
|
-
if (
|
|
4415
|
-
|
|
3784
|
+
if (defaultValue && selectList && selectList.length > 0) {
|
|
3785
|
+
setIsLoading(true);
|
|
3786
|
+
const defaultOption = selectList.find(option => option.id === defaultValue?.toString());
|
|
4416
3787
|
if (defaultOption) {
|
|
4417
3788
|
setSearchText(defaultOption.description);
|
|
4418
3789
|
setSelectedOption(defaultOption);
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
optionsProps.handleChange(defaultOption.id);
|
|
3790
|
+
if (handleChange) {
|
|
3791
|
+
handleChange(defaultOption.id);
|
|
4422
3792
|
}
|
|
4423
3793
|
}
|
|
3794
|
+
setIsLoading(false);
|
|
4424
3795
|
}
|
|
4425
|
-
}, [
|
|
3796
|
+
}, [defaultValue, selectList]);
|
|
4426
3797
|
const handleInputChange = (event) => {
|
|
4427
3798
|
const text = event.target.value;
|
|
4428
3799
|
setSearchText(text);
|
|
4429
3800
|
setShowDropdown(true);
|
|
4430
3801
|
if (text === "") {
|
|
4431
|
-
setFilteredOptions(
|
|
3802
|
+
setFilteredOptions(selectList);
|
|
4432
3803
|
setSelectedOption(null);
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
3804
|
+
if (handleChange) {
|
|
3805
|
+
handleChange("");
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
else {
|
|
3809
|
+
setIsLoading(true);
|
|
3810
|
+
const filtered = selectList.filter((option) => {
|
|
3811
|
+
return Object.keys(option).some(key => {
|
|
3812
|
+
const value = option[key];
|
|
3813
|
+
return (typeof value === 'string' || typeof value === 'number') &&
|
|
3814
|
+
String(value).toLowerCase().includes(text.toLowerCase());
|
|
3815
|
+
});
|
|
3816
|
+
});
|
|
3817
|
+
setFilteredOptions(filtered);
|
|
3818
|
+
setIsLoading(false);
|
|
3819
|
+
}
|
|
3820
|
+
};
|
|
3821
|
+
const handleInputFocus = () => {
|
|
3822
|
+
setShowDropdown(true);
|
|
3823
|
+
if (searchText === "") {
|
|
3824
|
+
setFilteredOptions(selectList);
|
|
3825
|
+
}
|
|
3826
|
+
};
|
|
3827
|
+
const handleInputBlur = () => {
|
|
3828
|
+
setTimeout(() => {
|
|
3829
|
+
setShowDropdown(false);
|
|
3830
|
+
}, 150);
|
|
3831
|
+
};
|
|
3832
|
+
const handleOptionSelect = (option) => {
|
|
3833
|
+
setSearchText(option.description);
|
|
3834
|
+
setSelectedOption(option);
|
|
3835
|
+
if (handleChange) {
|
|
3836
|
+
handleChange(option.id);
|
|
3837
|
+
}
|
|
3838
|
+
setFilteredOptions([]);
|
|
3839
|
+
};
|
|
3840
|
+
const handleClearClick = () => {
|
|
3841
|
+
setSearchText("");
|
|
3842
|
+
setFilteredOptions([]);
|
|
3843
|
+
setSelectedOption(null);
|
|
3844
|
+
if (handleChange) {
|
|
3845
|
+
handleChange("");
|
|
3846
|
+
}
|
|
3847
|
+
};
|
|
3848
|
+
return (jsxs("div", { className: `cw-search-input ${className || ""}`, style: style, id: id, ...otherProps, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-search-input-wrapper", children: [jsx("input", { type: "text", value: searchText, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, placeholder: placeholder, className: "cw-input-search", disabled: disabled }), isLoading && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: searchText && !disabled && !isLoading ? (jsx(CwButton, { type: "button", onClick: handleClearClick, "aria-label": "Clear search", variant: "icon", icon: "close", color: "neutral" })) : (iconProps ? jsx(CwIcon, { ...iconProps }) : jsx(CwIcon, { iconId: "search" })) })] })] }), showDropdown && filteredOptions.length > 0 && (jsx("div", { className: "cw-input-search-dropdown", children: jsx("ul", { children: filteredOptions.map((option) => (jsx("li", { onClick: () => handleOptionSelect(option), onMouseDown: (e) => e.preventDefault(), children: renderOption ? renderOption(option) : option.description }, option.id))) }) }))] }));
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3851
|
+
var styles$5 = {"menu":"cw-context-menu-module_menu__tXmun","item":"cw-context-menu-module_item__-ko8L","arrow":"cw-context-menu-module_arrow__LHZmQ"};
|
|
3852
|
+
|
|
3853
|
+
const ARROW_SIZE = 8;
|
|
3854
|
+
const SAFETY_MARGIN = 8;
|
|
3855
|
+
const VIEWPORT_PADDING = 10;
|
|
3856
|
+
const CwAnchoredMenu = ({ children, options, onSelect, placement = 'bottom', open: controlledOpen, onOpenChange, onContextMenu: onContextMenuCallback }) => {
|
|
3857
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
3858
|
+
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
3859
|
+
const menuRef = useRef(null);
|
|
3860
|
+
const triggerRef = useRef(null);
|
|
3861
|
+
const arrowRef = useRef(null);
|
|
3862
|
+
const isControlled = controlledOpen !== undefined;
|
|
3863
|
+
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
3864
|
+
const setIsOpen = (value) => {
|
|
3865
|
+
isControlled ? onOpenChange?.(value) : setInternalOpen(value);
|
|
3866
|
+
};
|
|
3867
|
+
const normalizedOptions = options.map(opt => typeof opt === 'string' ? { key: opt, label: opt } : opt);
|
|
3868
|
+
const getActualTriggerElement = () => {
|
|
3869
|
+
let element = triggerRef.current;
|
|
3870
|
+
if (element.offsetHeight === 0 && element.children.length > 0) {
|
|
3871
|
+
element = element.children[0];
|
|
3872
|
+
}
|
|
3873
|
+
return element;
|
|
3874
|
+
};
|
|
3875
|
+
const calculateInitialPosition = (event, rect) => {
|
|
3876
|
+
const totalOffset = ARROW_SIZE + SAFETY_MARGIN;
|
|
3877
|
+
switch (placement) {
|
|
3878
|
+
case 'bottom':
|
|
3879
|
+
return { x: event.clientX, y: rect.bottom + totalOffset };
|
|
3880
|
+
case 'top':
|
|
3881
|
+
return { x: event.clientX, y: rect.top - totalOffset };
|
|
3882
|
+
case 'right':
|
|
3883
|
+
return { x: rect.right + totalOffset, y: event.clientY };
|
|
3884
|
+
case 'left':
|
|
3885
|
+
return { x: rect.left - totalOffset, y: event.clientY };
|
|
3886
|
+
}
|
|
3887
|
+
};
|
|
3888
|
+
const shouldFlipVertical = (currentPlacement, rect, menuHeight) => {
|
|
3889
|
+
const totalOffset = ARROW_SIZE + SAFETY_MARGIN;
|
|
3890
|
+
if (currentPlacement === 'bottom') {
|
|
3891
|
+
const spaceBelow = window.innerHeight - rect.bottom - totalOffset;
|
|
3892
|
+
const spaceAbove = rect.top - totalOffset;
|
|
3893
|
+
return spaceBelow < menuHeight && spaceAbove > spaceBelow ? 'top' : 'bottom';
|
|
3894
|
+
}
|
|
3895
|
+
else {
|
|
3896
|
+
const spaceAbove = rect.top - totalOffset;
|
|
3897
|
+
const spaceBelow = window.innerHeight - rect.bottom - totalOffset;
|
|
3898
|
+
return spaceAbove < menuHeight && spaceBelow > spaceAbove ? 'bottom' : 'top';
|
|
3899
|
+
}
|
|
3900
|
+
};
|
|
3901
|
+
const shouldFlipHorizontal = (currentPlacement, rect, menuWidth) => {
|
|
3902
|
+
const totalOffset = ARROW_SIZE + SAFETY_MARGIN;
|
|
3903
|
+
if (currentPlacement === 'right') {
|
|
3904
|
+
const spaceRight = window.innerWidth - rect.right - totalOffset;
|
|
3905
|
+
const spaceLeft = rect.left - totalOffset;
|
|
3906
|
+
return spaceRight < menuWidth && spaceLeft > spaceRight ? 'left' : 'right';
|
|
3907
|
+
}
|
|
3908
|
+
else {
|
|
3909
|
+
const spaceLeft = rect.left - totalOffset;
|
|
3910
|
+
const spaceRight = window.innerWidth - rect.right - totalOffset;
|
|
3911
|
+
return spaceLeft < menuWidth && spaceRight > spaceLeft ? 'right' : 'left';
|
|
3912
|
+
}
|
|
3913
|
+
};
|
|
3914
|
+
const handleContextMenu = (event) => {
|
|
3915
|
+
event.preventDefault();
|
|
3916
|
+
event.stopPropagation();
|
|
3917
|
+
onContextMenuCallback?.(event);
|
|
3918
|
+
setIsOpen(true);
|
|
3919
|
+
const actualElement = getActualTriggerElement();
|
|
3920
|
+
const rect = actualElement.getBoundingClientRect();
|
|
3921
|
+
const pos = calculateInitialPosition(event, rect);
|
|
3922
|
+
setPosition(pos);
|
|
3923
|
+
};
|
|
3924
|
+
const handleOptionClick = (option) => {
|
|
3925
|
+
if (option.disabled)
|
|
3926
|
+
return;
|
|
3927
|
+
onSelect(option.key);
|
|
3928
|
+
setIsOpen(false);
|
|
3929
|
+
};
|
|
3930
|
+
// Calculate position before the browser paints the element
|
|
3931
|
+
useLayoutEffect(() => {
|
|
3932
|
+
if (!isOpen || !menuRef.current || !triggerRef.current)
|
|
3933
|
+
return;
|
|
3934
|
+
const actualElement = getActualTriggerElement();
|
|
3935
|
+
const rect = actualElement.getBoundingClientRect();
|
|
3936
|
+
const menuRect = menuRef.current.getBoundingClientRect();
|
|
3937
|
+
let { x, y } = position;
|
|
3938
|
+
let finalPlacement = placement;
|
|
3939
|
+
const totalOffset = ARROW_SIZE + SAFETY_MARGIN;
|
|
3940
|
+
// Calculate position based on placement and check for flips
|
|
3941
|
+
if (placement === 'bottom' || placement === 'top') {
|
|
3942
|
+
x = x - (menuRect.width / 2); // Center on click
|
|
3943
|
+
finalPlacement = shouldFlipVertical(placement, rect, menuRect.height);
|
|
3944
|
+
if (finalPlacement === 'top') {
|
|
3945
|
+
y = rect.top - totalOffset - menuRect.height;
|
|
3946
|
+
}
|
|
3947
|
+
else {
|
|
3948
|
+
y = rect.bottom + totalOffset;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
else { // left or right
|
|
3952
|
+
y = y - (menuRect.height / 2); // Center on click
|
|
3953
|
+
finalPlacement = shouldFlipHorizontal(placement, rect, menuRect.width);
|
|
3954
|
+
if (finalPlacement === 'left') {
|
|
3955
|
+
x = rect.left - totalOffset - menuRect.width;
|
|
3956
|
+
}
|
|
3957
|
+
else {
|
|
3958
|
+
x = rect.right + totalOffset;
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
// Keep in viewport (fallback)
|
|
3962
|
+
x = Math.max(VIEWPORT_PADDING, Math.min(x, window.innerWidth - menuRect.width - VIEWPORT_PADDING));
|
|
3963
|
+
y = Math.max(VIEWPORT_PADDING, Math.min(y, window.innerHeight - menuRect.height - VIEWPORT_PADDING));
|
|
3964
|
+
// Position arrow
|
|
3965
|
+
if (arrowRef.current) {
|
|
3966
|
+
arrowRef.current.setAttribute('data-placement', finalPlacement);
|
|
3967
|
+
}
|
|
3968
|
+
if (x !== position.x || y !== position.y) {
|
|
3969
|
+
setPosition({ x, y });
|
|
3970
|
+
}
|
|
3971
|
+
}, [isOpen]);
|
|
3972
|
+
// Close handlers
|
|
3973
|
+
useEffect(() => {
|
|
3974
|
+
if (!isOpen)
|
|
3975
|
+
return;
|
|
3976
|
+
const handleOutsideClick = (event) => {
|
|
3977
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
3978
|
+
setIsOpen(false);
|
|
3979
|
+
}
|
|
3980
|
+
};
|
|
3981
|
+
const handleEscape = (event) => {
|
|
3982
|
+
if (event.key === "Escape")
|
|
3983
|
+
setIsOpen(false);
|
|
3984
|
+
};
|
|
3985
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
3986
|
+
document.addEventListener("keydown", handleEscape);
|
|
3987
|
+
return () => {
|
|
3988
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
3989
|
+
document.removeEventListener("keydown", handleEscape);
|
|
3990
|
+
};
|
|
3991
|
+
}, [isOpen]);
|
|
3992
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: triggerRef, onContextMenu: handleContextMenu, style: { display: "contents" }, children: children }), isOpen && normalizedOptions.length > 0 && createPortal(jsxs("div", { ref: menuRef, className: styles$5["menu"], style: {
|
|
3993
|
+
top: `${position.y}px`,
|
|
3994
|
+
left: `${position.x}px`,
|
|
3995
|
+
}, "data-has-arrow": "true", children: [jsx("div", { ref: arrowRef, className: styles$5["arrow"], "data-placement": placement }), normalizedOptions.map(option => (jsxs("div", { onClick: (e) => {
|
|
3996
|
+
e.stopPropagation();
|
|
3997
|
+
e.preventDefault();
|
|
3998
|
+
handleOptionClick(option);
|
|
3999
|
+
}, className: `${styles$5["item"]} ${option.disabled ? styles$5["disabled"] : ""}`, "data-disabled": option.disabled, children: [option.icon && jsx("span", { className: styles$5["icon"], children: option.icon }), option.label] }, option.key)))] }), document.body)] }));
|
|
4000
|
+
};
|
|
4001
|
+
|
|
4002
|
+
/**
|
|
4003
|
+
* A context menu that is rendered when the user clicks on a button.
|
|
4004
|
+
* @author NVS
|
|
4005
|
+
* @example
|
|
4006
|
+
* <ContextMenu
|
|
4007
|
+
* options={['Option 1', 'Option 2', 'Option 3']}
|
|
4008
|
+
* onSelect={(option) => console.log(`Selected: ${option}`)}
|
|
4009
|
+
* >
|
|
4010
|
+
* <div>Right-click me!</div>
|
|
4011
|
+
* </ContextMenu>
|
|
4012
|
+
*/
|
|
4013
|
+
const DEFAULT_OFFSET = { x: 4, y: 4 };
|
|
4014
|
+
const CwContextMenu = ({ children, options, offset = DEFAULT_OFFSET, onSelect }) => {
|
|
4015
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4016
|
+
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
4017
|
+
const menuRef = useRef(null);
|
|
4018
|
+
const handleContextMenu = (event) => {
|
|
4019
|
+
event.preventDefault();
|
|
4020
|
+
setIsOpen(true);
|
|
4021
|
+
const x = event.clientX + offset.x;
|
|
4022
|
+
const y = event.clientY + offset.y;
|
|
4023
|
+
setPosition({ x, y });
|
|
4024
|
+
};
|
|
4025
|
+
const handleOptionClick = (option) => {
|
|
4026
|
+
onSelect(option);
|
|
4027
|
+
setIsOpen(false);
|
|
4028
|
+
};
|
|
4029
|
+
// Position handler for when is too close to window edges
|
|
4030
|
+
useEffect(() => {
|
|
4031
|
+
if (isOpen && menuRef.current) {
|
|
4032
|
+
const rect = menuRef.current.getBoundingClientRect();
|
|
4033
|
+
const padding = 16;
|
|
4034
|
+
let { x, y } = position;
|
|
4035
|
+
if (rect.right > window.innerWidth) {
|
|
4036
|
+
x = window.innerWidth - rect.width - padding;
|
|
4037
|
+
}
|
|
4038
|
+
if (rect.bottom > window.innerHeight) {
|
|
4039
|
+
y = window.innerHeight - rect.height - padding;
|
|
4040
|
+
}
|
|
4041
|
+
if (x < padding) {
|
|
4042
|
+
x = padding;
|
|
4043
|
+
}
|
|
4044
|
+
if (y < padding) {
|
|
4045
|
+
y = padding;
|
|
4046
|
+
}
|
|
4047
|
+
if (x !== position.x || y !== position.y) {
|
|
4048
|
+
setPosition({ x, y });
|
|
4049
|
+
}
|
|
4050
|
+
}
|
|
4051
|
+
}, [isOpen, position.x, position.y]);
|
|
4052
|
+
useEffect(() => {
|
|
4053
|
+
const handleOutsideClick = (event) => {
|
|
4054
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
4055
|
+
setIsOpen(false);
|
|
4056
|
+
}
|
|
4057
|
+
};
|
|
4058
|
+
const handleEscape = (event) => {
|
|
4059
|
+
if (event.key === "Escape") {
|
|
4060
|
+
setIsOpen(false);
|
|
4061
|
+
}
|
|
4062
|
+
};
|
|
4063
|
+
if (isOpen) {
|
|
4064
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
4065
|
+
document.addEventListener("keydown", handleEscape);
|
|
4066
|
+
}
|
|
4067
|
+
return () => {
|
|
4068
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
4069
|
+
document.removeEventListener("keydown", handleEscape);
|
|
4070
|
+
};
|
|
4071
|
+
}, [isOpen]);
|
|
4072
|
+
return (jsxs(Fragment, { children: [jsx("div", { onContextMenu: handleContextMenu, children: children }), isOpen && createPortal(jsx("div", { ref: menuRef, className: styles$5["menu"], style: {
|
|
4073
|
+
top: `${position.y}px`,
|
|
4074
|
+
left: `${position.x}px`,
|
|
4075
|
+
}, children: options.map(option => (jsx("div", { onClick: () => handleOptionClick(option), className: styles$5["item"], children: option }, option))) }), document.body)] }));
|
|
4076
|
+
};
|
|
4077
|
+
|
|
4078
|
+
/**
|
|
4079
|
+
* Save button wrapper
|
|
4080
|
+
* @deprecated Use <CwButton variant="icon" icon="save" onClick={...} /> instead
|
|
4081
|
+
*/
|
|
4082
|
+
function CwBtnSave({ cw_btnOnclick, cw_btn_disabled, onClick, disabled, ...rest }) {
|
|
4083
|
+
return (jsx(CwButton, { ...rest, variant: "icon", icon: "save", onClick: onClick ?? cw_btnOnclick, disabled: disabled ?? cw_btn_disabled }));
|
|
4084
|
+
}
|
|
4085
|
+
/**
|
|
4086
|
+
* Edit button wrapper
|
|
4087
|
+
* @deprecated Use <CwButton variant="icon" icon="edit" onClick={...} /> instead
|
|
4088
|
+
*/
|
|
4089
|
+
function CwBtnEdit({ cw_btnOnclick, cw_btn_disabled, onClick, disabled, ...rest }) {
|
|
4090
|
+
return (jsx(CwButton, { ...rest, variant: "icon", icon: "edit", onClick: onClick ?? cw_btnOnclick, disabled: disabled ?? cw_btn_disabled }));
|
|
4091
|
+
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Delete button wrapper
|
|
4094
|
+
* @deprecated Use <CwButton variant="icon" icon="delete" color="danger" onClick={...} /> instead
|
|
4095
|
+
*/
|
|
4096
|
+
function CwBtnDelete({ cw_btnOnclick, cw_btn_disabled, onClick, disabled, ...rest }) {
|
|
4097
|
+
return (jsx(CwButton, { ...rest, variant: "icon", icon: "delete", color: "danger", onClick: onClick ?? cw_btnOnclick, disabled: disabled ?? cw_btn_disabled }));
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
var styles$4 = {"pickerWrapper":"cw-pickers-base-module_pickerWrapper__Fb9Zo","pickerIcons":"cw-pickers-base-module_pickerIcons__dyd2-","pickerPopup":"cw-pickers-base-module_pickerPopup__dkxJo","title":"cw-pickers-base-module_title__cE7qI"};
|
|
4101
|
+
|
|
4102
|
+
function CustomCaption$2({ displayMonth }) {
|
|
4103
|
+
const { goToMonth, nextMonth, previousMonth } = useNavigation();
|
|
4104
|
+
return (jsxs("header", { children: [jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-left", onClick: () => previousMonth && goToMonth(previousMonth), disabled: !previousMonth, "aria-label": "Previous month" }), jsx("div", { className: styles$4.title, children: format(displayMonth, "MMMM yyyy", { locale: enGB }) }), jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-right", onClick: () => nextMonth && goToMonth(nextMonth), disabled: !nextMonth, "aria-label": "Next month" })] }));
|
|
4105
|
+
}
|
|
4106
|
+
function CwDatePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, defaultMonth, labelProps, alignProps, placeholder = "Select a date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, }) {
|
|
4107
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4108
|
+
const [inputValue, setInputValue] = useState("");
|
|
4109
|
+
const containerRef = useRef(null);
|
|
4110
|
+
const inputRef = useRef(null);
|
|
4111
|
+
const prevValueRef = useRef(undefined);
|
|
4112
|
+
// Parse date from string based on format
|
|
4113
|
+
const parseDate = useCallback((dateString, formatStr) => {
|
|
4114
|
+
try {
|
|
4115
|
+
const cleanString = dateString.trim();
|
|
4116
|
+
const parts = cleanString.split(/[\/\-\.]/);
|
|
4117
|
+
if (parts.length !== 3)
|
|
4118
|
+
return undefined;
|
|
4119
|
+
let day;
|
|
4120
|
+
let month;
|
|
4121
|
+
let year;
|
|
4122
|
+
const formatLower = formatStr.toLowerCase();
|
|
4123
|
+
const dayIndex = formatLower.indexOf('dd');
|
|
4124
|
+
const monthIndex = formatLower.indexOf('mm');
|
|
4125
|
+
const yearIndex = formatLower.indexOf('yyyy') !== -1
|
|
4126
|
+
? formatLower.indexOf('yyyy')
|
|
4127
|
+
: formatLower.indexOf('yy');
|
|
4128
|
+
const positions = [
|
|
4129
|
+
{ type: 'day', index: dayIndex },
|
|
4130
|
+
{ type: 'month', index: monthIndex },
|
|
4131
|
+
{ type: 'year', index: yearIndex }
|
|
4132
|
+
].sort((a, b) => a.index - b.index);
|
|
4133
|
+
positions.forEach((pos, idx) => {
|
|
4134
|
+
const value = parseInt(parts[idx], 10);
|
|
4135
|
+
if (pos.type === 'day')
|
|
4136
|
+
day = value;
|
|
4137
|
+
else if (pos.type === 'month')
|
|
4138
|
+
month = value - 1;
|
|
4139
|
+
else if (pos.type === 'year')
|
|
4140
|
+
year = value;
|
|
4141
|
+
});
|
|
4142
|
+
if (day === undefined || month === undefined || year === undefined)
|
|
4143
|
+
return undefined;
|
|
4144
|
+
if (isNaN(day) || isNaN(month) || isNaN(year))
|
|
4145
|
+
return undefined;
|
|
4146
|
+
if (year < 100) {
|
|
4147
|
+
year = year < 50 ? 2000 + year : 1900 + year;
|
|
4148
|
+
}
|
|
4149
|
+
const parsed = new Date(year, month, day);
|
|
4150
|
+
if (parsed.getDate() === day &&
|
|
4151
|
+
parsed.getMonth() === month &&
|
|
4152
|
+
parsed.getFullYear() === year) {
|
|
4153
|
+
return parsed;
|
|
4154
|
+
}
|
|
4155
|
+
return undefined;
|
|
4156
|
+
}
|
|
4157
|
+
catch {
|
|
4158
|
+
return undefined;
|
|
4159
|
+
}
|
|
4160
|
+
}, []);
|
|
4161
|
+
const normalizeDateForComparison = useCallback((date) => {
|
|
4162
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
4163
|
+
}, []);
|
|
4164
|
+
// Validate and set date - shared logic
|
|
4165
|
+
const validateAndSetDate = useCallback((dateString) => {
|
|
4166
|
+
const parsed = parseDate(dateString, displayFormat);
|
|
4167
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
4168
|
+
const normalizedParsed = normalizeDateForComparison(parsed);
|
|
4169
|
+
const normalizedMin = minDate ? normalizeDateForComparison(minDate) : undefined;
|
|
4170
|
+
const normalizedMax = maxDate ? normalizeDateForComparison(maxDate) : undefined;
|
|
4171
|
+
const isValid = (!normalizedMin || normalizedParsed >= normalizedMin) &&
|
|
4172
|
+
(!normalizedMax || normalizedParsed <= normalizedMax);
|
|
4173
|
+
if (isValid) {
|
|
4174
|
+
onChange(parsed);
|
|
4175
|
+
return true;
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
return false;
|
|
4179
|
+
}, [parseDate, displayFormat, minDate, maxDate, onChange, normalizeDateForComparison]);
|
|
4180
|
+
// Sync input value with prop value - only when changed externally
|
|
4181
|
+
useEffect(() => {
|
|
4182
|
+
const currentTime = value?.getTime();
|
|
4183
|
+
const prevTime = prevValueRef.current?.getTime();
|
|
4184
|
+
if (currentTime !== prevTime) {
|
|
4185
|
+
prevValueRef.current = value;
|
|
4186
|
+
if (value) {
|
|
4187
|
+
setInputValue(format(value, displayFormat, { locale: enGB }));
|
|
4188
|
+
}
|
|
4189
|
+
else {
|
|
4190
|
+
setInputValue("");
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
}, [value, displayFormat]);
|
|
4194
|
+
// Close calendar when clicking outside
|
|
4195
|
+
useEffect(() => {
|
|
4196
|
+
const handleClickOutside = (event) => {
|
|
4197
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
4198
|
+
setIsOpen(false);
|
|
4199
|
+
}
|
|
4200
|
+
};
|
|
4201
|
+
if (isOpen) {
|
|
4202
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
4203
|
+
}
|
|
4204
|
+
return () => {
|
|
4205
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
4206
|
+
};
|
|
4207
|
+
}, [isOpen]);
|
|
4208
|
+
const handleDaySelect = useCallback((date) => {
|
|
4209
|
+
onChange(date);
|
|
4210
|
+
setIsOpen(false);
|
|
4211
|
+
inputRef.current?.blur();
|
|
4212
|
+
}, [onChange]);
|
|
4213
|
+
const handleClear = useCallback((e) => {
|
|
4214
|
+
e.stopPropagation();
|
|
4215
|
+
onChange(undefined);
|
|
4216
|
+
setInputValue("");
|
|
4217
|
+
}, [onChange]);
|
|
4218
|
+
const handleInputClick = useCallback(() => {
|
|
4219
|
+
if (!disabled) {
|
|
4220
|
+
setIsOpen(true);
|
|
4221
|
+
}
|
|
4222
|
+
}, [disabled]);
|
|
4223
|
+
const handleInputChange = useCallback((e) => {
|
|
4224
|
+
const newValue = e.target.value;
|
|
4225
|
+
setInputValue(newValue);
|
|
4226
|
+
if (newValue.length >= 10) {
|
|
4227
|
+
validateAndSetDate(newValue);
|
|
4228
|
+
}
|
|
4229
|
+
else if (newValue === "") {
|
|
4230
|
+
onChange(undefined);
|
|
4231
|
+
}
|
|
4232
|
+
}, [validateAndSetDate, onChange]);
|
|
4233
|
+
const handleInputBlur = useCallback(() => {
|
|
4234
|
+
if (inputValue && inputValue.trim() !== "") {
|
|
4235
|
+
const parsed = parseDate(inputValue, displayFormat);
|
|
4236
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
4237
|
+
const normalizedParsed = normalizeDateForComparison(parsed);
|
|
4238
|
+
const normalizedMin = minDate ? normalizeDateForComparison(minDate) : undefined;
|
|
4239
|
+
const normalizedMax = maxDate ? normalizeDateForComparison(maxDate) : undefined;
|
|
4240
|
+
const isValid = (!normalizedMin || normalizedParsed >= normalizedMin) &&
|
|
4241
|
+
(!normalizedMax || normalizedParsed <= normalizedMax);
|
|
4242
|
+
if (isValid) {
|
|
4243
|
+
onChange(parsed);
|
|
4244
|
+
setInputValue(format(parsed, displayFormat, { locale: enGB }));
|
|
4245
|
+
return;
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
if (!value) {
|
|
4250
|
+
setInputValue("");
|
|
4251
|
+
}
|
|
4252
|
+
else {
|
|
4253
|
+
setInputValue(format(value, displayFormat, { locale: enGB }));
|
|
4254
|
+
}
|
|
4255
|
+
}, [inputValue, parseDate, displayFormat, minDate, maxDate, onChange, value, normalizeDateForComparison]);
|
|
4256
|
+
const handleInputKeyDown = useCallback((e) => {
|
|
4257
|
+
if (e.key === "Enter") {
|
|
4258
|
+
e.preventDefault();
|
|
4259
|
+
inputRef.current?.blur();
|
|
4260
|
+
setIsOpen(false);
|
|
4261
|
+
}
|
|
4262
|
+
else if (e.key === "Escape") {
|
|
4263
|
+
setIsOpen(false);
|
|
4264
|
+
inputRef.current?.blur();
|
|
4265
|
+
}
|
|
4266
|
+
}, []);
|
|
4267
|
+
const handleTodayClick = useCallback(() => {
|
|
4268
|
+
const today = new Date();
|
|
4269
|
+
const isTodayValid = (!minDate || today >= minDate) &&
|
|
4270
|
+
(!maxDate || today <= maxDate);
|
|
4271
|
+
if (isTodayValid) {
|
|
4272
|
+
onChange(today);
|
|
4273
|
+
setIsOpen(false);
|
|
4274
|
+
}
|
|
4275
|
+
}, [minDate, maxDate, onChange]);
|
|
4276
|
+
// Memoize formatters
|
|
4277
|
+
const formatters = useMemo(() => ({
|
|
4278
|
+
formatCaption: (date) => format(date, "MMMM yyyy", { locale: enGB }),
|
|
4279
|
+
formatWeekdayName: (date) => format(date, "EEEEEE", { locale: enGB })
|
|
4280
|
+
}), []);
|
|
4281
|
+
// Memoize disabled days
|
|
4282
|
+
const disabledDays = useMemo(() => [
|
|
4283
|
+
...(disabledDates || []),
|
|
4284
|
+
...(minDate ? [{ before: minDate }] : []),
|
|
4285
|
+
...(maxDate ? [{ after: maxDate }] : []),
|
|
4286
|
+
...(disabledMatcher ? [disabledMatcher] : []),
|
|
4287
|
+
], [disabledDates, minDate, maxDate, disabledMatcher]);
|
|
4288
|
+
return (jsx("div", { ref: containerRef, className: `cw-datepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear date" })) : (jsx(CwIcon, { iconId: "calendar" })) }), isOpen && (jsxs("div", { className: styles$4.pickerPopup, "data-position": popupPosition, children: [jsx(DayPicker, { mode: "single", selected: value || undefined, defaultMonth: defaultMonth || value || undefined, onSelect: handleDaySelect, disabled: disabledDays, locale: enGB, numberOfMonths: numberOfMonths, formatters: formatters, components: {
|
|
4289
|
+
Caption: (props) => (jsx(CustomCaption$2, { ...props })),
|
|
4290
|
+
}, modifiers: {
|
|
4291
|
+
today: new Date(),
|
|
4292
|
+
}, modifiersClassNames: {
|
|
4293
|
+
today: "rdp-day_today",
|
|
4294
|
+
} }), showTodayButton && (jsx("footer", { className: "cw-flex-row cw-align-right-center", children: jsx(CwButton, { type: "button", variant: "outline", onClick: handleTodayClick, text: "Today" }) }))] }))] })] }) }));
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
var rangeStyles = {"rangeWrapper":"cw-range-picker-module_rangeWrapper__1nIVs","rangePopup":"cw-range-picker-module_rangePopup__E5jd1","presetList":"cw-range-picker-module_presetList__INiLo"};
|
|
4298
|
+
|
|
4299
|
+
const PRESET_LIBRARY = {
|
|
4300
|
+
// === PAST DAYS ===
|
|
4301
|
+
today: {
|
|
4302
|
+
key: 'today',
|
|
4303
|
+
label: 'Today',
|
|
4304
|
+
getValue: () => {
|
|
4305
|
+
const from = new Date();
|
|
4306
|
+
from.setHours(0, 0, 0, 0);
|
|
4307
|
+
const to = new Date();
|
|
4308
|
+
to.setHours(23, 59, 59, 999);
|
|
4309
|
+
return { from, to };
|
|
4310
|
+
}
|
|
4311
|
+
},
|
|
4312
|
+
yesterday: {
|
|
4313
|
+
key: 'yesterday',
|
|
4314
|
+
label: 'Yesterday',
|
|
4315
|
+
getValue: () => {
|
|
4316
|
+
const from = new Date();
|
|
4317
|
+
from.setDate(from.getDate() - 1);
|
|
4318
|
+
from.setHours(0, 0, 0, 0);
|
|
4319
|
+
const to = new Date();
|
|
4320
|
+
to.setDate(to.getDate() - 1);
|
|
4321
|
+
to.setHours(23, 59, 59, 999);
|
|
4322
|
+
return { from, to };
|
|
4323
|
+
}
|
|
4324
|
+
},
|
|
4325
|
+
past2Days: {
|
|
4326
|
+
key: 'past2Days',
|
|
4327
|
+
label: 'Past 2 Days',
|
|
4328
|
+
getValue: () => {
|
|
4329
|
+
const today = new Date();
|
|
4330
|
+
today.setHours(23, 59, 59, 999);
|
|
4331
|
+
const twoDaysAgo = new Date();
|
|
4332
|
+
twoDaysAgo.setDate(today.getDate() - 2);
|
|
4333
|
+
twoDaysAgo.setHours(0, 0, 0, 0);
|
|
4334
|
+
return { from: twoDaysAgo, to: today };
|
|
4335
|
+
}
|
|
4336
|
+
},
|
|
4337
|
+
past3Days: {
|
|
4338
|
+
key: 'past3Days',
|
|
4339
|
+
label: 'Past 3 Days',
|
|
4340
|
+
getValue: () => {
|
|
4341
|
+
const today = new Date();
|
|
4342
|
+
today.setHours(23, 59, 59, 999);
|
|
4343
|
+
const threeDaysAgo = new Date();
|
|
4344
|
+
threeDaysAgo.setDate(today.getDate() - 3);
|
|
4345
|
+
threeDaysAgo.setHours(0, 0, 0, 0);
|
|
4346
|
+
return { from: threeDaysAgo, to: today };
|
|
4347
|
+
}
|
|
4348
|
+
},
|
|
4349
|
+
past7Days: {
|
|
4350
|
+
key: 'past7Days',
|
|
4351
|
+
label: 'Past 7 days',
|
|
4352
|
+
getValue: () => {
|
|
4353
|
+
const today = new Date();
|
|
4354
|
+
const past = new Date(today);
|
|
4355
|
+
past.setDate(today.getDate() - 7);
|
|
4356
|
+
return { from: past, to: today };
|
|
4357
|
+
}
|
|
4358
|
+
},
|
|
4359
|
+
past14Days: {
|
|
4360
|
+
key: 'past14Days',
|
|
4361
|
+
label: 'Past 14 days',
|
|
4362
|
+
getValue: () => {
|
|
4363
|
+
const today = new Date();
|
|
4364
|
+
const past = new Date(today);
|
|
4365
|
+
past.setDate(today.getDate() - 14);
|
|
4366
|
+
return { from: past, to: today };
|
|
4367
|
+
}
|
|
4368
|
+
},
|
|
4369
|
+
past30Days: {
|
|
4370
|
+
key: 'past30Days',
|
|
4371
|
+
label: 'Past 30 days',
|
|
4372
|
+
getValue: () => {
|
|
4373
|
+
const today = new Date();
|
|
4374
|
+
const past = new Date(today);
|
|
4375
|
+
past.setDate(today.getDate() - 30);
|
|
4376
|
+
return { from: past, to: today };
|
|
4377
|
+
}
|
|
4378
|
+
},
|
|
4379
|
+
past90Days: {
|
|
4380
|
+
key: 'past90Days',
|
|
4381
|
+
label: 'Past 90 days',
|
|
4382
|
+
getValue: () => {
|
|
4383
|
+
const today = new Date();
|
|
4384
|
+
const past = new Date(today);
|
|
4385
|
+
past.setDate(today.getDate() - 90);
|
|
4386
|
+
return { from: past, to: today };
|
|
4387
|
+
}
|
|
4388
|
+
},
|
|
4389
|
+
// === NEXT DAYS ===
|
|
4390
|
+
next7Days: {
|
|
4391
|
+
key: 'next7Days',
|
|
4392
|
+
label: 'Next 7 days',
|
|
4393
|
+
getValue: () => {
|
|
4394
|
+
const today = new Date();
|
|
4395
|
+
const next = new Date(today);
|
|
4396
|
+
next.setDate(today.getDate() + 7);
|
|
4397
|
+
return { from: today, to: next };
|
|
4398
|
+
}
|
|
4399
|
+
},
|
|
4400
|
+
next14Days: {
|
|
4401
|
+
key: 'next14Days',
|
|
4402
|
+
label: 'Next 14 days',
|
|
4403
|
+
getValue: () => {
|
|
4404
|
+
const today = new Date();
|
|
4405
|
+
const next = new Date(today);
|
|
4406
|
+
next.setDate(today.getDate() + 14);
|
|
4407
|
+
return { from: today, to: next };
|
|
4408
|
+
}
|
|
4409
|
+
},
|
|
4410
|
+
next30Days: {
|
|
4411
|
+
key: 'next30Days',
|
|
4412
|
+
label: 'Next 30 days',
|
|
4413
|
+
getValue: () => {
|
|
4414
|
+
const today = new Date();
|
|
4415
|
+
const next = new Date(today);
|
|
4416
|
+
next.setDate(today.getDate() + 30);
|
|
4417
|
+
return { from: today, to: next };
|
|
4418
|
+
}
|
|
4419
|
+
},
|
|
4420
|
+
// === WEEKS ===
|
|
4421
|
+
thisWeek: {
|
|
4422
|
+
key: 'thisWeek',
|
|
4423
|
+
label: 'This week',
|
|
4424
|
+
getValue: () => {
|
|
4425
|
+
const today = new Date();
|
|
4426
|
+
const firstDay = new Date(today);
|
|
4427
|
+
const lastDay = new Date(today);
|
|
4428
|
+
const day = today.getDay();
|
|
4429
|
+
const diff = day === 0 ? -6 : 1 - day; // Monday as first day
|
|
4430
|
+
firstDay.setDate(today.getDate() + diff);
|
|
4431
|
+
lastDay.setDate(firstDay.getDate() + 6); // Sunday
|
|
4432
|
+
return { from: firstDay, to: lastDay };
|
|
4433
|
+
}
|
|
4434
|
+
},
|
|
4435
|
+
lastWeek: {
|
|
4436
|
+
key: 'lastWeek',
|
|
4437
|
+
label: 'Last week',
|
|
4438
|
+
getValue: () => {
|
|
4439
|
+
const today = new Date();
|
|
4440
|
+
const lastWeekEnd = new Date(today);
|
|
4441
|
+
const day = today.getDay();
|
|
4442
|
+
const diff = day === 0 ? -6 : 1 - day;
|
|
4443
|
+
lastWeekEnd.setDate(today.getDate() + diff - 1);
|
|
4444
|
+
const lastWeekStart = new Date(lastWeekEnd);
|
|
4445
|
+
lastWeekStart.setDate(lastWeekEnd.getDate() - 6);
|
|
4446
|
+
return { from: lastWeekStart, to: lastWeekEnd };
|
|
4447
|
+
}
|
|
4448
|
+
},
|
|
4449
|
+
nextWeek: {
|
|
4450
|
+
key: 'nextWeek',
|
|
4451
|
+
label: 'Next week',
|
|
4452
|
+
getValue: () => {
|
|
4453
|
+
const today = new Date();
|
|
4454
|
+
const nextWeekStart = new Date(today);
|
|
4455
|
+
const day = today.getDay();
|
|
4456
|
+
const diff = day === 0 ? 1 : 8 - day;
|
|
4457
|
+
nextWeekStart.setDate(today.getDate() + diff);
|
|
4458
|
+
const nextWeekEnd = new Date(nextWeekStart);
|
|
4459
|
+
nextWeekEnd.setDate(nextWeekStart.getDate() + 6);
|
|
4460
|
+
return { from: nextWeekStart, to: nextWeekEnd };
|
|
4461
|
+
}
|
|
4462
|
+
},
|
|
4463
|
+
// === MONTHS ===
|
|
4464
|
+
thisMonth: {
|
|
4465
|
+
key: 'thisMonth',
|
|
4466
|
+
label: 'This month',
|
|
4467
|
+
getValue: () => {
|
|
4468
|
+
const today = new Date();
|
|
4469
|
+
const firstDay = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
4470
|
+
const lastDay = new Date(today.getFullYear(), today.getMonth() + 1, 0);
|
|
4471
|
+
return { from: firstDay, to: lastDay };
|
|
4472
|
+
}
|
|
4473
|
+
},
|
|
4474
|
+
lastMonth: {
|
|
4475
|
+
key: 'lastMonth',
|
|
4476
|
+
label: 'Last month',
|
|
4477
|
+
getValue: () => {
|
|
4478
|
+
const today = new Date();
|
|
4479
|
+
const firstDay = new Date(today.getFullYear(), today.getMonth() - 1, 1);
|
|
4480
|
+
const lastDay = new Date(today.getFullYear(), today.getMonth(), 0);
|
|
4481
|
+
return { from: firstDay, to: lastDay };
|
|
4482
|
+
}
|
|
4483
|
+
},
|
|
4484
|
+
nextMonth: {
|
|
4485
|
+
key: 'nextMonth',
|
|
4486
|
+
label: 'Next month',
|
|
4487
|
+
getValue: () => {
|
|
4488
|
+
const today = new Date();
|
|
4489
|
+
const firstDay = new Date(today.getFullYear(), today.getMonth() + 1, 1);
|
|
4490
|
+
const lastDay = new Date(today.getFullYear(), today.getMonth() + 2, 0);
|
|
4491
|
+
return { from: firstDay, to: lastDay };
|
|
4492
|
+
}
|
|
4493
|
+
},
|
|
4494
|
+
// === QUARTERS ===
|
|
4495
|
+
thisQuarter: {
|
|
4496
|
+
key: 'thisQuarter',
|
|
4497
|
+
label: 'This quarter',
|
|
4498
|
+
getValue: () => {
|
|
4499
|
+
const today = new Date();
|
|
4500
|
+
const quarter = Math.floor(today.getMonth() / 3);
|
|
4501
|
+
const firstDay = new Date(today.getFullYear(), quarter * 3, 1);
|
|
4502
|
+
const lastDay = new Date(today.getFullYear(), quarter * 3 + 3, 0);
|
|
4503
|
+
return { from: firstDay, to: lastDay };
|
|
4504
|
+
}
|
|
4505
|
+
},
|
|
4506
|
+
lastQuarter: {
|
|
4507
|
+
key: 'lastQuarter',
|
|
4508
|
+
label: 'Last quarter',
|
|
4509
|
+
getValue: () => {
|
|
4510
|
+
const today = new Date();
|
|
4511
|
+
const currentQuarter = Math.floor(today.getMonth() / 3);
|
|
4512
|
+
const lastQuarter = currentQuarter === 0 ? 3 : currentQuarter - 1;
|
|
4513
|
+
const year = currentQuarter === 0 ? today.getFullYear() - 1 : today.getFullYear();
|
|
4514
|
+
const firstDay = new Date(year, lastQuarter * 3, 1);
|
|
4515
|
+
const lastDay = new Date(year, lastQuarter * 3 + 3, 0);
|
|
4516
|
+
return { from: firstDay, to: lastDay };
|
|
4517
|
+
}
|
|
4518
|
+
},
|
|
4519
|
+
nextQuarter: {
|
|
4520
|
+
key: 'nextQuarter',
|
|
4521
|
+
label: 'Next quarter',
|
|
4522
|
+
getValue: () => {
|
|
4523
|
+
const today = new Date();
|
|
4524
|
+
const currentQuarter = Math.floor(today.getMonth() / 3);
|
|
4525
|
+
const nextQuarter = (currentQuarter + 1) % 4;
|
|
4526
|
+
const year = nextQuarter === 0 ? today.getFullYear() + 1 : today.getFullYear();
|
|
4527
|
+
const firstDay = new Date(year, nextQuarter * 3, 1);
|
|
4528
|
+
const lastDay = new Date(year, nextQuarter * 3 + 3, 0);
|
|
4529
|
+
return { from: firstDay, to: lastDay };
|
|
4530
|
+
}
|
|
4531
|
+
},
|
|
4532
|
+
// === YEAR ===
|
|
4533
|
+
thisYear: {
|
|
4534
|
+
key: 'thisYear',
|
|
4535
|
+
label: 'This year',
|
|
4536
|
+
getValue: () => {
|
|
4537
|
+
const today = new Date();
|
|
4538
|
+
const firstDay = new Date(today.getFullYear(), 0, 1);
|
|
4539
|
+
const lastDay = new Date(today.getFullYear(), 11, 31);
|
|
4540
|
+
return { from: firstDay, to: lastDay };
|
|
4541
|
+
}
|
|
4542
|
+
},
|
|
4543
|
+
lastYear: {
|
|
4544
|
+
key: 'lastYear',
|
|
4545
|
+
label: 'Last year',
|
|
4546
|
+
getValue: () => {
|
|
4547
|
+
const today = new Date();
|
|
4548
|
+
const firstDay = new Date(today.getFullYear() - 1, 0, 1);
|
|
4549
|
+
const lastDay = new Date(today.getFullYear() - 1, 11, 31);
|
|
4550
|
+
return { from: firstDay, to: lastDay };
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
};
|
|
4554
|
+
/**
|
|
4555
|
+
* Helper function to get presets by their keys
|
|
4556
|
+
* @param keys - Array of preset keys from PRESET_LIBRARY
|
|
4557
|
+
* @returns Array of DateRangePreset objects
|
|
4558
|
+
*
|
|
4559
|
+
* @example
|
|
4560
|
+
* const presets = getPresetsByKeys(['thisWeek', 'past7Days', 'past30Days']);
|
|
4561
|
+
*/
|
|
4562
|
+
const getPresetsByKeys = (keys) => {
|
|
4563
|
+
return keys
|
|
4564
|
+
.map(key => PRESET_LIBRARY[key])
|
|
4565
|
+
.filter(preset => preset !== undefined);
|
|
4566
|
+
};
|
|
4567
|
+
|
|
4568
|
+
function CustomCaption$1({ displayMonth }) {
|
|
4569
|
+
const { goToMonth, nextMonth, previousMonth } = useNavigation();
|
|
4570
|
+
return (jsxs("header", { children: [jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-left", onClick: () => previousMonth && goToMonth(previousMonth), disabled: !previousMonth, "aria-label": "Previous month" }), jsx("div", { className: styles$4.title, children: format(displayMonth, "MMMM yyyy", { locale: enGB }) }), jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-right", onClick: () => nextMonth && goToMonth(nextMonth), disabled: !nextMonth, "aria-label": "Next month" })] }));
|
|
4571
|
+
}
|
|
4572
|
+
function CwDateRangePicker({ value, onChange, minDate, maxDate, disabledDates, disabledMatcher, maxRangeDays, defaultMonth, labelProps, alignProps, placeholderFrom = "From date", placeholderTo = "To date", displayFormat = "dd.MM.yyyy", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 2, showPresets = false, presetKeys, customPresets, }) {
|
|
4573
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4574
|
+
const [inputFromValue, setInputFromValue] = useState("");
|
|
4575
|
+
const [inputToValue, setInputToValue] = useState("");
|
|
4576
|
+
const [focusedInput, setFocusedInput] = useState();
|
|
4577
|
+
const containerRef = useRef(null);
|
|
4578
|
+
const inputFromRef = useRef(null);
|
|
4579
|
+
const inputToRef = useRef(null);
|
|
4580
|
+
const prevValueRef = useRef(undefined);
|
|
4581
|
+
// Calculate presets to render
|
|
4582
|
+
const presetsToRender = useMemo(() => {
|
|
4583
|
+
let presets = [];
|
|
4584
|
+
// If presetKeys provided, use those from library
|
|
4585
|
+
if (presetKeys && presetKeys.length > 0) {
|
|
4586
|
+
presets = getPresetsByKeys(presetKeys);
|
|
4587
|
+
}
|
|
4588
|
+
// Add custom presets if provided
|
|
4589
|
+
if (customPresets && customPresets.length > 0) {
|
|
4590
|
+
presets = [...presets, ...customPresets];
|
|
4591
|
+
}
|
|
4592
|
+
return presets;
|
|
4593
|
+
}, [presetKeys, customPresets]);
|
|
4594
|
+
// Parse date from string based on format
|
|
4595
|
+
const parseDate = useCallback((dateString, formatStr) => {
|
|
4596
|
+
try {
|
|
4597
|
+
const cleanString = dateString.trim();
|
|
4598
|
+
const parts = cleanString.split(/[\/\-\.]/);
|
|
4599
|
+
if (parts.length !== 3)
|
|
4600
|
+
return undefined;
|
|
4601
|
+
let day;
|
|
4602
|
+
let month;
|
|
4603
|
+
let year;
|
|
4604
|
+
const formatLower = formatStr.toLowerCase();
|
|
4605
|
+
const dayIndex = formatLower.indexOf('dd');
|
|
4606
|
+
const monthIndex = formatLower.indexOf('mm');
|
|
4607
|
+
const yearIndex = formatLower.indexOf('yyyy') !== -1
|
|
4608
|
+
? formatLower.indexOf('yyyy')
|
|
4609
|
+
: formatLower.indexOf('yy');
|
|
4610
|
+
const positions = [
|
|
4611
|
+
{ type: 'day', index: dayIndex },
|
|
4612
|
+
{ type: 'month', index: monthIndex },
|
|
4613
|
+
{ type: 'year', index: yearIndex }
|
|
4614
|
+
].sort((a, b) => a.index - b.index);
|
|
4615
|
+
positions.forEach((pos, idx) => {
|
|
4616
|
+
const value = parseInt(parts[idx], 10);
|
|
4617
|
+
if (pos.type === 'day')
|
|
4618
|
+
day = value;
|
|
4619
|
+
else if (pos.type === 'month')
|
|
4620
|
+
month = value - 1;
|
|
4621
|
+
else if (pos.type === 'year')
|
|
4622
|
+
year = value;
|
|
4623
|
+
});
|
|
4624
|
+
if (day === undefined || month === undefined || year === undefined)
|
|
4625
|
+
return undefined;
|
|
4626
|
+
if (isNaN(day) || isNaN(month) || isNaN(year))
|
|
4627
|
+
return undefined;
|
|
4628
|
+
if (year < 100) {
|
|
4629
|
+
year = year < 50 ? 2000 + year : 1900 + year;
|
|
4630
|
+
}
|
|
4631
|
+
const parsed = new Date(year, month, day);
|
|
4632
|
+
if (parsed.getDate() === day &&
|
|
4633
|
+
parsed.getMonth() === month &&
|
|
4634
|
+
parsed.getFullYear() === year) {
|
|
4635
|
+
return parsed;
|
|
4636
|
+
}
|
|
4637
|
+
return undefined;
|
|
4638
|
+
}
|
|
4639
|
+
catch {
|
|
4640
|
+
return undefined;
|
|
4641
|
+
}
|
|
4642
|
+
}, []);
|
|
4643
|
+
const normalizeDateForComparison = useCallback((date) => {
|
|
4644
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
4645
|
+
}, []);
|
|
4646
|
+
// Validate date range
|
|
4647
|
+
const validateRange = useCallback((from, to) => {
|
|
4648
|
+
if (!from || !to)
|
|
4649
|
+
return true; // Partial ranges are OK during selection
|
|
4650
|
+
// Check if "from" is before "to"
|
|
4651
|
+
if (from > to)
|
|
4652
|
+
return false;
|
|
4653
|
+
// Check max range days
|
|
4654
|
+
if (maxRangeDays) {
|
|
4655
|
+
const daysDiff = Math.floor((to.getTime() - from.getTime()) / (1000 * 60 * 60 * 24));
|
|
4656
|
+
if (daysDiff > maxRangeDays)
|
|
4657
|
+
return false;
|
|
4658
|
+
}
|
|
4659
|
+
return true;
|
|
4660
|
+
}, [maxRangeDays]);
|
|
4661
|
+
// Sync input values with prop value
|
|
4662
|
+
useEffect(() => {
|
|
4663
|
+
const currentFromTime = value?.from?.getTime();
|
|
4664
|
+
const currentToTime = value?.to?.getTime();
|
|
4665
|
+
const prevFromTime = prevValueRef.current?.fromTime;
|
|
4666
|
+
const prevToTime = prevValueRef.current?.toTime;
|
|
4667
|
+
// Only update if times have actually changed
|
|
4668
|
+
if (currentFromTime !== prevFromTime || currentToTime !== prevToTime) {
|
|
4669
|
+
prevValueRef.current = {
|
|
4670
|
+
fromTime: currentFromTime,
|
|
4671
|
+
toTime: currentToTime
|
|
4672
|
+
};
|
|
4673
|
+
// Update "from" input
|
|
4674
|
+
if (value?.from) {
|
|
4675
|
+
setInputFromValue(format(value.from, displayFormat, { locale: enGB }));
|
|
4676
|
+
}
|
|
4677
|
+
else {
|
|
4678
|
+
setInputFromValue("");
|
|
4679
|
+
}
|
|
4680
|
+
// Update "to" input
|
|
4681
|
+
if (value?.to) {
|
|
4682
|
+
setInputToValue(format(value.to, displayFormat, { locale: enGB }));
|
|
4683
|
+
}
|
|
4684
|
+
else {
|
|
4685
|
+
setInputToValue("");
|
|
4686
|
+
}
|
|
4687
|
+
}
|
|
4688
|
+
}, [value, displayFormat]);
|
|
4689
|
+
// Close calendar when clicking outside
|
|
4690
|
+
useEffect(() => {
|
|
4691
|
+
const handleClickOutside = (event) => {
|
|
4692
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
4693
|
+
setIsOpen(false);
|
|
4694
|
+
setFocusedInput(undefined);
|
|
4695
|
+
}
|
|
4696
|
+
};
|
|
4697
|
+
if (isOpen) {
|
|
4698
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
4699
|
+
}
|
|
4700
|
+
return () => {
|
|
4701
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
4702
|
+
};
|
|
4703
|
+
}, [isOpen]);
|
|
4704
|
+
const handleRangeSelect = useCallback((range, // El rango sugerido por react-day-picker
|
|
4705
|
+
selectedDay) => {
|
|
4706
|
+
let newRange;
|
|
4707
|
+
if (focusedInput === 'from') {
|
|
4708
|
+
newRange = { from: selectedDay, to: value?.to };
|
|
4709
|
+
if (newRange.to && selectedDay > newRange.to) {
|
|
4710
|
+
newRange.to = undefined;
|
|
4711
|
+
setFocusedInput('to');
|
|
4712
|
+
}
|
|
4713
|
+
else if (newRange.to) {
|
|
4714
|
+
setIsOpen(false);
|
|
4715
|
+
setFocusedInput(undefined);
|
|
4716
|
+
}
|
|
4717
|
+
else {
|
|
4718
|
+
setFocusedInput('to');
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4721
|
+
else if (focusedInput === 'to') {
|
|
4722
|
+
newRange = { from: value?.from, to: selectedDay };
|
|
4723
|
+
if (newRange.from && selectedDay < newRange.from) {
|
|
4724
|
+
newRange.from = undefined;
|
|
4725
|
+
setFocusedInput('from');
|
|
4726
|
+
}
|
|
4727
|
+
else if (newRange.from) {
|
|
4728
|
+
setIsOpen(false);
|
|
4729
|
+
setFocusedInput(undefined);
|
|
4730
|
+
}
|
|
4731
|
+
else {
|
|
4732
|
+
setFocusedInput('from');
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
else {
|
|
4736
|
+
if (!range) {
|
|
4737
|
+
onChange(undefined);
|
|
4738
|
+
return;
|
|
4739
|
+
}
|
|
4740
|
+
newRange = { from: range.from, to: range.to };
|
|
4741
|
+
if (range.from && range.to) {
|
|
4742
|
+
setIsOpen(false);
|
|
4743
|
+
setFocusedInput(undefined);
|
|
4744
|
+
}
|
|
4745
|
+
else if (range.from) {
|
|
4746
|
+
setFocusedInput('to');
|
|
4747
|
+
}
|
|
4748
|
+
else {
|
|
4749
|
+
setFocusedInput('from');
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
// Validate range before sending
|
|
4753
|
+
if (newRange.from && newRange.to && !validateRange(newRange.from, newRange.to)) {
|
|
4754
|
+
return;
|
|
4755
|
+
}
|
|
4756
|
+
onChange(newRange);
|
|
4757
|
+
}, [onChange, validateRange, value, focusedInput]);
|
|
4758
|
+
const handleClearFrom = useCallback((e) => {
|
|
4759
|
+
e.stopPropagation();
|
|
4760
|
+
onChange({ from: undefined, to: value?.to });
|
|
4761
|
+
setInputFromValue("");
|
|
4762
|
+
}, [onChange, value]);
|
|
4763
|
+
const handleClearTo = useCallback((e) => {
|
|
4764
|
+
e.stopPropagation();
|
|
4765
|
+
onChange({ from: value?.from, to: undefined });
|
|
4766
|
+
setInputToValue("");
|
|
4767
|
+
}, [onChange, value]);
|
|
4768
|
+
const handleInputFromClick = useCallback(() => {
|
|
4769
|
+
if (!disabled) {
|
|
4770
|
+
setIsOpen(true);
|
|
4771
|
+
setFocusedInput('from');
|
|
4772
|
+
}
|
|
4773
|
+
}, [disabled]);
|
|
4774
|
+
const handleInputToClick = useCallback(() => {
|
|
4775
|
+
if (!disabled) {
|
|
4776
|
+
setIsOpen(true);
|
|
4777
|
+
setFocusedInput('to');
|
|
4778
|
+
}
|
|
4779
|
+
}, [disabled]);
|
|
4780
|
+
const handleInputFromChange = useCallback((e) => {
|
|
4781
|
+
const newValue = e.target.value;
|
|
4782
|
+
setInputFromValue(newValue);
|
|
4783
|
+
if (newValue.length >= 10) {
|
|
4784
|
+
const parsed = parseDate(newValue, displayFormat);
|
|
4785
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
4786
|
+
const normalizedParsed = normalizeDateForComparison(parsed);
|
|
4787
|
+
const normalizedMin = minDate ? normalizeDateForComparison(minDate) : undefined;
|
|
4788
|
+
const normalizedMax = maxDate ? normalizeDateForComparison(maxDate) : undefined;
|
|
4789
|
+
const isValid = (!normalizedMin || normalizedParsed >= normalizedMin) &&
|
|
4790
|
+
(!normalizedMax || normalizedParsed <= normalizedMax);
|
|
4791
|
+
if (isValid) {
|
|
4792
|
+
onChange({ from: parsed, to: value?.to });
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4796
|
+
else if (newValue === "") {
|
|
4797
|
+
onChange({ from: undefined, to: value?.to });
|
|
4798
|
+
}
|
|
4799
|
+
}, [parseDate, displayFormat, minDate, maxDate, normalizeDateForComparison, onChange, value]);
|
|
4800
|
+
const handleInputToChange = useCallback((e) => {
|
|
4801
|
+
const newValue = e.target.value;
|
|
4802
|
+
setInputToValue(newValue);
|
|
4803
|
+
if (newValue.length >= 10) {
|
|
4804
|
+
const parsed = parseDate(newValue, displayFormat);
|
|
4805
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
4806
|
+
const normalizedParsed = normalizeDateForComparison(parsed);
|
|
4807
|
+
const normalizedMin = minDate ? normalizeDateForComparison(minDate) : undefined;
|
|
4808
|
+
const normalizedMax = maxDate ? normalizeDateForComparison(maxDate) : undefined;
|
|
4809
|
+
const isValid = (!normalizedMin || normalizedParsed >= normalizedMin) &&
|
|
4810
|
+
(!normalizedMax || normalizedParsed <= normalizedMax);
|
|
4811
|
+
if (isValid && validateRange(value?.from, parsed)) {
|
|
4812
|
+
onChange({ from: value?.from, to: parsed });
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
else if (newValue === "") {
|
|
4817
|
+
onChange({ from: value?.from, to: undefined });
|
|
4818
|
+
}
|
|
4819
|
+
}, [parseDate, displayFormat, minDate, maxDate, normalizeDateForComparison, validateRange, onChange, value]);
|
|
4820
|
+
const handleInputBlur = useCallback((type) => {
|
|
4821
|
+
const inputValue = type === 'from' ? inputFromValue : inputToValue;
|
|
4822
|
+
const currentValue = type === 'from' ? value?.from : value?.to;
|
|
4823
|
+
if (inputValue && inputValue.trim() !== "") {
|
|
4824
|
+
const parsed = parseDate(inputValue, displayFormat);
|
|
4825
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
4826
|
+
const normalizedParsed = normalizeDateForComparison(parsed);
|
|
4827
|
+
const normalizedMin = minDate ? normalizeDateForComparison(minDate) : undefined;
|
|
4828
|
+
const normalizedMax = maxDate ? normalizeDateForComparison(maxDate) : undefined;
|
|
4829
|
+
const isValid = (!normalizedMin || normalizedParsed >= normalizedMin) &&
|
|
4830
|
+
(!normalizedMax || normalizedParsed <= normalizedMax);
|
|
4831
|
+
if (isValid) {
|
|
4832
|
+
const newRange = type === 'from'
|
|
4833
|
+
? { from: parsed, to: value?.to }
|
|
4834
|
+
: { from: value?.from, to: parsed };
|
|
4835
|
+
if (validateRange(newRange.from, newRange.to)) {
|
|
4836
|
+
onChange(newRange);
|
|
4837
|
+
if (type === 'from') {
|
|
4838
|
+
setInputFromValue(format(parsed, displayFormat, { locale: enGB }));
|
|
4839
|
+
}
|
|
4840
|
+
else {
|
|
4841
|
+
setInputToValue(format(parsed, displayFormat, { locale: enGB }));
|
|
4842
|
+
}
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
// Reset to current value if invalid
|
|
4849
|
+
if (type === 'from') {
|
|
4850
|
+
setInputFromValue(currentValue ? format(currentValue, displayFormat, { locale: enGB }) : "");
|
|
4851
|
+
}
|
|
4852
|
+
else {
|
|
4853
|
+
setInputToValue(currentValue ? format(currentValue, displayFormat, { locale: enGB }) : "");
|
|
4854
|
+
}
|
|
4855
|
+
}, [inputFromValue, inputToValue, value, parseDate, displayFormat, minDate, maxDate, normalizeDateForComparison, validateRange, onChange]);
|
|
4856
|
+
const handleInputKeyDown = useCallback((e, type) => {
|
|
4857
|
+
if (e.key === "Enter") {
|
|
4858
|
+
e.preventDefault();
|
|
4859
|
+
if (type === 'from') {
|
|
4860
|
+
inputFromRef.current?.blur();
|
|
4861
|
+
inputToRef.current?.focus();
|
|
4862
|
+
}
|
|
4863
|
+
else {
|
|
4864
|
+
inputToRef.current?.blur();
|
|
4865
|
+
setIsOpen(false);
|
|
4866
|
+
}
|
|
4867
|
+
}
|
|
4868
|
+
else if (e.key === "Escape") {
|
|
4869
|
+
setIsOpen(false);
|
|
4870
|
+
if (type === 'from') {
|
|
4871
|
+
inputFromRef.current?.blur();
|
|
4872
|
+
}
|
|
4873
|
+
else {
|
|
4874
|
+
inputToRef.current?.blur();
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
}, []);
|
|
4878
|
+
// Handle preset click
|
|
4879
|
+
const handlePresetClick = useCallback((preset, e) => {
|
|
4880
|
+
e.preventDefault();
|
|
4881
|
+
e.stopPropagation();
|
|
4882
|
+
onChange(preset.getValue());
|
|
4883
|
+
setIsOpen(false);
|
|
4884
|
+
}, [onChange]);
|
|
4885
|
+
// Memoize formatters
|
|
4886
|
+
const formatters = useMemo(() => ({
|
|
4887
|
+
formatCaption: (date) => format(date, "MMMM yyyy", { locale: enGB }),
|
|
4888
|
+
formatWeekdayName: (date) => format(date, "EEEEEE", { locale: enGB })
|
|
4889
|
+
}), []);
|
|
4890
|
+
// Memoize disabled days
|
|
4891
|
+
const disabledDays = useMemo(() => {
|
|
4892
|
+
const baseDisabled = [
|
|
4893
|
+
...(disabledDates || []),
|
|
4894
|
+
...(minDate ? [{ before: minDate }] : []),
|
|
4895
|
+
...(maxDate ? [{ after: maxDate }] : []),
|
|
4896
|
+
...(disabledMatcher ? [disabledMatcher] : []),
|
|
4897
|
+
];
|
|
4898
|
+
// If maxRangeDays is set and we have a "from" date, disable dates beyond the range
|
|
4899
|
+
if (maxRangeDays) {
|
|
4900
|
+
if (value?.from) {
|
|
4901
|
+
const maxAllowedDate = new Date(value.from);
|
|
4902
|
+
maxAllowedDate.setDate(maxAllowedDate.getDate() + maxRangeDays);
|
|
4903
|
+
if (focusedInput !== 'from') {
|
|
4904
|
+
baseDisabled.push({ after: maxAllowedDate });
|
|
4905
|
+
}
|
|
4906
|
+
if (focusedInput === 'to' && !value?.to) {
|
|
4907
|
+
const minAllowedDate = new Date(value.from);
|
|
4908
|
+
minAllowedDate.setDate(minAllowedDate.getDate() - maxRangeDays);
|
|
4909
|
+
baseDisabled.push({ before: minAllowedDate });
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
if (value?.to && !value?.from && focusedInput === 'from') {
|
|
4913
|
+
const minAllowedDate = new Date(value.to);
|
|
4914
|
+
minAllowedDate.setDate(minAllowedDate.getDate() - maxRangeDays);
|
|
4915
|
+
baseDisabled.push({ before: minAllowedDate });
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
return baseDisabled;
|
|
4919
|
+
}, [disabledDates, minDate, maxDate, disabledMatcher, maxRangeDays, value]);
|
|
4920
|
+
const selectedRange = useMemo(() => {
|
|
4921
|
+
if (value?.from || value?.to) {
|
|
4922
|
+
return {
|
|
4923
|
+
from: value?.from || undefined,
|
|
4924
|
+
to: value?.to || undefined
|
|
4925
|
+
};
|
|
4926
|
+
}
|
|
4927
|
+
return undefined;
|
|
4928
|
+
}, [value]);
|
|
4929
|
+
return (jsx("div", { ref: containerRef, className: `cw-rangepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: rangeStyles.rangeWrapper, children: [jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputFromRef, type: "text", value: inputFromValue, placeholder: placeholderFrom, onChange: handleInputFromChange, onBlur: () => handleInputBlur('from'), onClick: handleInputFromClick, onKeyDown: (e) => handleInputKeyDown(e, 'from'), disabled: disabled, required: required, "data-focused": focusedInput === 'from' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.from && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearFrom, tabIndex: -1, "aria-label": "Clear from date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), jsx(CwIcon, { iconId: "arrow-right", size: "medium" }), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputToRef, type: "text", value: inputToValue, placeholder: placeholderTo, onChange: handleInputToChange, onBlur: () => handleInputBlur('to'), onClick: handleInputToClick, onKeyDown: (e) => handleInputKeyDown(e, 'to'), disabled: disabled, required: required, "data-focused": focusedInput === 'to' }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value?.to && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClearTo, tabIndex: -1, "aria-label": "Clear to date" })) : (jsx(CwIcon, { iconId: "calendar" })) })] }), isOpen && (jsxs("div", { className: `${styles$4.pickerPopup} ${rangeStyles.rangePopup}`, "data-position": popupPosition, children: [showPresets && presetsToRender.length > 0 && (jsx("div", { className: rangeStyles.presetList, children: presetsToRender.map((preset) => (jsx("button", { type: "button", onClick: (e) => handlePresetClick(preset, e), children: preset.label }, preset.key))) })), jsx(DayPicker, { mode: "range", selected: selectedRange, onSelect: handleRangeSelect, disabled: disabledDays, locale: enGB, numberOfMonths: numberOfMonths, defaultMonth: defaultMonth || value?.from || undefined, formatters: formatters, components: {
|
|
4930
|
+
Caption: (props) => jsx(CustomCaption$1, { ...props }),
|
|
4931
|
+
}, modifiers: {
|
|
4932
|
+
today: new Date(),
|
|
4933
|
+
}, modifiersClassNames: {
|
|
4934
|
+
today: "rdp-day_today",
|
|
4935
|
+
} })] }))] })] }) }));
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
var timeStyles = {"timePickerPopup":"cw-time-picker-module_timePickerPopup__BN63t","timePickerList":"cw-time-picker-module_timePickerList__E88pr","selected":"cw-time-picker-module_selected__qVnfL","hasIcons":"cw-time-picker-module_hasIcons__ZiGUf","notIcons":"cw-time-picker-module_notIcons__3icu1"};
|
|
4939
|
+
|
|
4940
|
+
const isMobileDevice = () => {
|
|
4941
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
4942
|
+
};
|
|
4943
|
+
function CwTimePicker({ value, onChange, interval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", useNative = isMobileDevice(), }) {
|
|
4944
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
4945
|
+
const [inputValue, setInputValue] = useState("");
|
|
4946
|
+
const containerRef = useRef(null);
|
|
4947
|
+
const inputRef = useRef(null);
|
|
4948
|
+
const selectedItemRef = useRef(null);
|
|
4949
|
+
// Sync input value with prop value
|
|
4950
|
+
useEffect(() => {
|
|
4951
|
+
if (value) {
|
|
4952
|
+
setInputValue(value);
|
|
4953
|
+
}
|
|
4954
|
+
else {
|
|
4955
|
+
setInputValue("");
|
|
4956
|
+
}
|
|
4957
|
+
}, [value]);
|
|
4958
|
+
// Generate time options based on interval
|
|
4959
|
+
const generateTimeOptions = () => {
|
|
4960
|
+
const options = [];
|
|
4961
|
+
const totalMinutes = 24 * 60; // Total minutes in a day
|
|
4962
|
+
for (let minutes = 0; minutes < totalMinutes; minutes += interval) {
|
|
4963
|
+
const hours = Math.floor(minutes / 60);
|
|
4964
|
+
const mins = minutes % 60;
|
|
4965
|
+
const timeString = `${hours.toString().padStart(2, "0")}:${mins.toString().padStart(2, "0")}`;
|
|
4966
|
+
// Filter by min/max time if provided
|
|
4967
|
+
if (minTime && timeString < minTime)
|
|
4968
|
+
continue;
|
|
4969
|
+
if (maxTime && timeString > maxTime)
|
|
4970
|
+
continue;
|
|
4971
|
+
options.push(timeString);
|
|
4972
|
+
}
|
|
4973
|
+
return options;
|
|
4974
|
+
};
|
|
4975
|
+
const timeOptions = generateTimeOptions();
|
|
4976
|
+
// Close dropdown when clicking outside
|
|
4977
|
+
useEffect(() => {
|
|
4978
|
+
const handleClickOutside = (event) => {
|
|
4979
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
4980
|
+
setIsOpen(false);
|
|
4981
|
+
}
|
|
4982
|
+
};
|
|
4983
|
+
if (isOpen) {
|
|
4984
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
4985
|
+
}
|
|
4986
|
+
return () => {
|
|
4987
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
4988
|
+
};
|
|
4989
|
+
}, [isOpen]);
|
|
4990
|
+
// Scroll to selected time when opening dropdown
|
|
4991
|
+
useEffect(() => {
|
|
4992
|
+
if (isOpen && selectedItemRef.current) {
|
|
4993
|
+
selectedItemRef.current.scrollIntoView({
|
|
4994
|
+
block: "center",
|
|
4995
|
+
behavior: "smooth",
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
}, [isOpen]);
|
|
4999
|
+
const handleTimeSelect = (time) => {
|
|
5000
|
+
onChange(time);
|
|
5001
|
+
setInputValue(time);
|
|
5002
|
+
setIsOpen(false);
|
|
5003
|
+
inputRef.current?.blur();
|
|
5004
|
+
};
|
|
5005
|
+
const handleClear = (e) => {
|
|
5006
|
+
e.stopPropagation();
|
|
5007
|
+
onChange(undefined);
|
|
5008
|
+
setInputValue("");
|
|
5009
|
+
};
|
|
5010
|
+
const handleInputClick = () => {
|
|
5011
|
+
if (!disabled) {
|
|
5012
|
+
setIsOpen(true);
|
|
5013
|
+
}
|
|
5014
|
+
};
|
|
5015
|
+
const handleInputChange = (e) => {
|
|
5016
|
+
let newValue = e.target.value;
|
|
5017
|
+
setInputValue(newValue);
|
|
5018
|
+
// Auto-format as user types
|
|
5019
|
+
// Remove non-numeric characters except colon
|
|
5020
|
+
newValue = newValue.replace(/[^\d:]/g, "");
|
|
5021
|
+
// Auto-add colon after 2 digits
|
|
5022
|
+
if (newValue.length === 2 && !newValue.includes(":")) {
|
|
5023
|
+
newValue = newValue + ":";
|
|
5024
|
+
setInputValue(newValue);
|
|
5025
|
+
}
|
|
5026
|
+
// Limit to HH:mm format
|
|
5027
|
+
if (newValue.length > 5) {
|
|
5028
|
+
newValue = newValue.slice(0, 5);
|
|
5029
|
+
setInputValue(newValue);
|
|
5030
|
+
}
|
|
5031
|
+
// Validate and set time when complete
|
|
5032
|
+
if (newValue.length === 5 && newValue.includes(":")) {
|
|
5033
|
+
const [hours, minutes] = newValue.split(":");
|
|
5034
|
+
const h = parseInt(hours, 10);
|
|
5035
|
+
const m = parseInt(minutes, 10);
|
|
5036
|
+
if (h >= 0 && h <= 23 && m >= 0 && m <= 59) {
|
|
5037
|
+
const formattedTime = `${hours.padStart(2, "0")}:${minutes.padStart(2, "0")}`;
|
|
5038
|
+
// Check min/max time restrictions
|
|
5039
|
+
const isValid = (!minTime || formattedTime >= minTime) &&
|
|
5040
|
+
(!maxTime || formattedTime <= maxTime);
|
|
5041
|
+
if (isValid) {
|
|
5042
|
+
onChange(formattedTime);
|
|
5043
|
+
setInputValue(formattedTime);
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
else if (newValue === "") {
|
|
5048
|
+
onChange(undefined);
|
|
5049
|
+
}
|
|
5050
|
+
};
|
|
5051
|
+
const handleInputBlur = () => {
|
|
5052
|
+
// On blur, sync input with actual value or clear if invalid
|
|
5053
|
+
if (value) {
|
|
5054
|
+
setInputValue(value);
|
|
5055
|
+
}
|
|
5056
|
+
else if (inputValue && inputValue.length === 5) {
|
|
5057
|
+
// Try to validate one more time
|
|
5058
|
+
const [hours, minutes] = inputValue.split(":");
|
|
5059
|
+
const h = parseInt(hours, 10);
|
|
5060
|
+
const m = parseInt(minutes, 10);
|
|
5061
|
+
if (h >= 0 && h <= 23 && m >= 0 && m <= 59) {
|
|
5062
|
+
const formattedTime = `${hours.padStart(2, "0")}:${minutes.padStart(2, "0")}`;
|
|
5063
|
+
onChange(formattedTime);
|
|
5064
|
+
setInputValue(formattedTime);
|
|
5065
|
+
}
|
|
5066
|
+
else {
|
|
5067
|
+
setInputValue("");
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
else {
|
|
5071
|
+
setInputValue("");
|
|
5072
|
+
}
|
|
5073
|
+
};
|
|
5074
|
+
const handleInputKeyDown = (e) => {
|
|
5075
|
+
if (e.key === "Enter") {
|
|
5076
|
+
setIsOpen(!isOpen);
|
|
5077
|
+
}
|
|
5078
|
+
else if (e.key === "Escape") {
|
|
5079
|
+
setIsOpen(false);
|
|
5080
|
+
}
|
|
5081
|
+
else if (e.key === "ArrowDown" && isOpen && timeOptions.length > 0) {
|
|
5082
|
+
e.preventDefault();
|
|
5083
|
+
// Focus first option in dropdown
|
|
5084
|
+
const firstOption = document.querySelector(".cw-timepicker-option");
|
|
5085
|
+
firstOption?.focus();
|
|
5086
|
+
}
|
|
5087
|
+
};
|
|
5088
|
+
const handleNativeChange = (e) => {
|
|
5089
|
+
const newValue = e.target.value;
|
|
5090
|
+
onChange(newValue);
|
|
5091
|
+
setInputValue(newValue);
|
|
5092
|
+
};
|
|
5093
|
+
// Format time for display (optional: could add 12h format here)
|
|
5094
|
+
const displayValue = inputValue;
|
|
5095
|
+
// If using native time input
|
|
5096
|
+
if (useNative) {
|
|
5097
|
+
return (jsx("div", { className: `cw-timepicker cw-timepicker-native ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsx("div", { className: styles$4.pickerWrapper, children: jsx("input", { type: "time", value: displayValue, onChange: handleNativeChange, min: minTime, max: maxTime, step: interval * 60, disabled: disabled, required: required, placeholder: placeholder, className: "cw-timepicker-native" }) })] }) }));
|
|
5098
|
+
}
|
|
5099
|
+
// Custom time picker
|
|
5100
|
+
return (jsx("div", { ref: containerRef, className: `cw-timepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required, maxLength: 5, className: showClear ? timeStyles.hasIcons : timeStyles.notIcons }), showClear && (jsx("div", { className: styles$4.pickerIcons, children: value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", icon: "close", color: "neutral", onClick: handleClear, tabIndex: -1, "aria-label": "Clear time" })) : (jsx(CwIcon, { iconId: "clock" })) })), isOpen && (jsx("div", { className: `${styles$4.pickerPopup} ${timeStyles.timePickerPopup}`, "data-position": popupPosition, children: jsx("div", { className: timeStyles.timePickerList, children: timeOptions.map((time) => {
|
|
5101
|
+
const isSelected = time === value;
|
|
5102
|
+
return (jsx("button", { ref: isSelected ? selectedItemRef : null, type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
5103
|
+
}) }) }))] })] }) }));
|
|
5104
|
+
}
|
|
5105
|
+
|
|
5106
|
+
function CwDateTimePicker({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, datePlaceholder = "dd.MM.yyyy", timePlaceholder = "HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showNowButton = false, }) {
|
|
5107
|
+
// ========================================
|
|
5108
|
+
// PROPS NORMALIZATION
|
|
5109
|
+
// ========================================
|
|
5110
|
+
/**
|
|
5111
|
+
* Normalize datetime prop to valid Date object
|
|
5112
|
+
* @returns Valid Date object or undefined if invalid
|
|
5113
|
+
*/
|
|
5114
|
+
const normalizeDateTime = useCallback((dateTime, propName) => {
|
|
5115
|
+
if (!dateTime)
|
|
5116
|
+
return undefined;
|
|
5117
|
+
try {
|
|
5118
|
+
// Convert to Date object if not already
|
|
5119
|
+
const date = dateTime instanceof Date
|
|
5120
|
+
? dateTime
|
|
5121
|
+
: new Date(dateTime);
|
|
5122
|
+
// Validate the Date object is valid
|
|
5123
|
+
if (isNaN(date.getTime())) {
|
|
5124
|
+
console.warn(`[CwDateTimePicker] Invalid ${propName} provided:`, dateTime);
|
|
5125
|
+
return undefined;
|
|
5126
|
+
}
|
|
5127
|
+
return date;
|
|
5128
|
+
}
|
|
5129
|
+
catch (error) {
|
|
5130
|
+
console.warn(`[CwDateTimePicker] Error parsing ${propName}:`, dateTime, error);
|
|
5131
|
+
return undefined;
|
|
5132
|
+
}
|
|
5133
|
+
}, []);
|
|
5134
|
+
// Normalize min/max datetime props using the helper
|
|
5135
|
+
const normalizedMinDateTime = useMemo(() => normalizeDateTime(minDateTime, 'minDateTime'), [minDateTime, normalizeDateTime]);
|
|
5136
|
+
const normalizedMaxDateTime = useMemo(() => normalizeDateTime(maxDateTime, 'maxDateTime'), [maxDateTime, normalizeDateTime]);
|
|
5137
|
+
// ========================================
|
|
5138
|
+
// INTERNAL STATE
|
|
5139
|
+
// ========================================
|
|
5140
|
+
const [selectedDate, setSelectedDate] = useState(value);
|
|
5141
|
+
const [selectedTime, setSelectedTime] = useState(value ? `${value.getHours().toString().padStart(2, "0")}:${value.getMinutes().toString().padStart(2, "0")}` : undefined);
|
|
5142
|
+
// Track previous value to detect external changes
|
|
5143
|
+
const prevValueRef = useRef(undefined);
|
|
5144
|
+
// ========================================
|
|
5145
|
+
// COMBINATION AND VALIDATION LOGIC
|
|
5146
|
+
// ========================================
|
|
5147
|
+
/**
|
|
5148
|
+
* Combine date and time into a single Date object
|
|
5149
|
+
* Validates the combined datetime against min/max constraints
|
|
5150
|
+
*
|
|
5151
|
+
* @returns Combined Date object or undefined if invalid
|
|
5152
|
+
*/
|
|
5153
|
+
const combineDateTime = useCallback((date, time) => {
|
|
5154
|
+
if (!date)
|
|
5155
|
+
return undefined;
|
|
5156
|
+
// If no time is selected, use 00:00
|
|
5157
|
+
if (!time) {
|
|
5158
|
+
const combined = new Date(date);
|
|
5159
|
+
combined.setHours(0, 0, 0, 0);
|
|
5160
|
+
// Validate against min/max datetime
|
|
5161
|
+
if (normalizedMinDateTime && combined < normalizedMinDateTime)
|
|
5162
|
+
return undefined;
|
|
5163
|
+
if (normalizedMaxDateTime && combined > normalizedMaxDateTime)
|
|
5164
|
+
return undefined;
|
|
5165
|
+
return combined;
|
|
5166
|
+
}
|
|
5167
|
+
// Parse time and combine with date
|
|
5168
|
+
const [hours, minutes] = time.split(':').map(Number);
|
|
5169
|
+
const combined = new Date(date);
|
|
5170
|
+
combined.setHours(hours, minutes, 0, 0);
|
|
5171
|
+
// Validate against min/max datetime
|
|
5172
|
+
if (normalizedMinDateTime && combined < normalizedMinDateTime)
|
|
5173
|
+
return undefined;
|
|
5174
|
+
if (normalizedMaxDateTime && combined > normalizedMaxDateTime)
|
|
5175
|
+
return undefined;
|
|
5176
|
+
return combined;
|
|
5177
|
+
}, [normalizedMinDateTime, normalizedMaxDateTime]);
|
|
5178
|
+
/**
|
|
5179
|
+
* Calculate dynamic time restrictions based on selected date
|
|
5180
|
+
*
|
|
5181
|
+
* If the selected date matches the min/max date boundary, restrict times accordingly.
|
|
5182
|
+
* Allows users to manually type any valid time, not just interval-aligned times.
|
|
5183
|
+
* The timeInterval prop only affects the dropdown options, not manual input validation.
|
|
5184
|
+
*
|
|
5185
|
+
* @param selectedDate - Currently selected date
|
|
5186
|
+
* @returns Object with minTime and maxTime strings in "HH:mm" format
|
|
5187
|
+
*/
|
|
5188
|
+
const calculateTimeRestrictions = useCallback((selectedDate) => {
|
|
5189
|
+
if (!selectedDate)
|
|
5190
|
+
return { minTime, maxTime };
|
|
5191
|
+
// Normalize selected date to date-only (ignore time component)
|
|
5192
|
+
const selectedDateOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate());
|
|
5193
|
+
let calculatedMinTime = minTime;
|
|
5194
|
+
let calculatedMaxTime = maxTime;
|
|
5195
|
+
// If selected date matches minDateTime date, restrict minimum time
|
|
5196
|
+
if (normalizedMinDateTime) {
|
|
5197
|
+
const minDateOnly = new Date(normalizedMinDateTime.getFullYear(), normalizedMinDateTime.getMonth(), normalizedMinDateTime.getDate());
|
|
5198
|
+
if (selectedDateOnly.getTime() === minDateOnly.getTime()) {
|
|
5199
|
+
const hours = normalizedMinDateTime.getHours().toString().padStart(2, "0");
|
|
5200
|
+
const minutes = normalizedMinDateTime.getMinutes().toString().padStart(2, "0");
|
|
5201
|
+
calculatedMinTime = `${hours}:${minutes}`;
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
// If selected date matches maxDateTime date, restrict maximum time
|
|
5205
|
+
if (normalizedMaxDateTime) {
|
|
5206
|
+
const maxDateOnly = new Date(normalizedMaxDateTime.getFullYear(), normalizedMaxDateTime.getMonth(), normalizedMaxDateTime.getDate());
|
|
5207
|
+
if (selectedDateOnly.getTime() === maxDateOnly.getTime()) {
|
|
5208
|
+
const hours = normalizedMaxDateTime.getHours().toString().padStart(2, "0");
|
|
5209
|
+
const minutes = normalizedMaxDateTime.getMinutes().toString().padStart(2, "0");
|
|
5210
|
+
calculatedMaxTime = `${hours}:${minutes}`;
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
return {
|
|
5214
|
+
minTime: calculatedMinTime,
|
|
5215
|
+
maxTime: calculatedMaxTime
|
|
5216
|
+
};
|
|
5217
|
+
}, [normalizedMinDateTime, normalizedMaxDateTime, minTime, maxTime]);
|
|
5218
|
+
// Calculate current time restrictions based on selected date
|
|
5219
|
+
// Recalculates whenever selectedDate or the calculation function changes
|
|
5220
|
+
const timeRestrictions = useMemo(() => calculateTimeRestrictions(selectedDate), [selectedDate, calculateTimeRestrictions]);
|
|
5221
|
+
// ========================================
|
|
5222
|
+
// SYNC WITH EXTERNAL VALUE PROP
|
|
5223
|
+
// ========================================
|
|
5224
|
+
/**
|
|
5225
|
+
* Sync internal state with prop value - only when changed externally
|
|
5226
|
+
* Uses prevValueRef to detect if the change came from outside
|
|
5227
|
+
* (e.g., parent component updated the value programmatically)
|
|
5228
|
+
* vs. internal changes (user interaction)
|
|
5229
|
+
*/
|
|
5230
|
+
useEffect(() => {
|
|
5231
|
+
const currentTime = value?.getTime();
|
|
5232
|
+
const prevTime = prevValueRef.current?.getTime();
|
|
5233
|
+
// Only update if value actually changed
|
|
5234
|
+
if (currentTime !== prevTime) {
|
|
5235
|
+
prevValueRef.current = value;
|
|
5236
|
+
if (value) {
|
|
5237
|
+
setSelectedDate(value);
|
|
5238
|
+
setSelectedTime(`${value.getHours().toString().padStart(2, "0")}:${value.getMinutes().toString().padStart(2, "0")}`);
|
|
5239
|
+
}
|
|
5240
|
+
else {
|
|
5241
|
+
setSelectedDate(undefined);
|
|
5242
|
+
setSelectedTime(undefined);
|
|
5243
|
+
}
|
|
5244
|
+
}
|
|
5245
|
+
}, [value]);
|
|
5246
|
+
// ========================================
|
|
5247
|
+
// EVENT HANDLERS
|
|
5248
|
+
// ========================================
|
|
5249
|
+
/**
|
|
5250
|
+
* Handle date selection change
|
|
5251
|
+
*
|
|
5252
|
+
* When date changes, validates if the currently selected time is still valid.
|
|
5253
|
+
* If time becomes invalid (e.g., user switched from Mar 14 to Mar 15 with maxTime=16:27,
|
|
5254
|
+
* and had 18:00 selected), it resets the time to undefined.
|
|
5255
|
+
*/
|
|
5256
|
+
const handleDateChange = useCallback((date) => {
|
|
5257
|
+
setSelectedDate(date);
|
|
5258
|
+
if (date && selectedTime) {
|
|
5259
|
+
const combined = combineDateTime(date, selectedTime);
|
|
5260
|
+
if (!combined) {
|
|
5261
|
+
// Time is no longer valid for this date
|
|
5262
|
+
// Auto-set to first valid time (minTime)
|
|
5263
|
+
const restrictions = calculateTimeRestrictions(date);
|
|
5264
|
+
const newTime = restrictions.minTime || undefined;
|
|
5265
|
+
setSelectedTime(newTime);
|
|
5266
|
+
onChange(combineDateTime(date, newTime));
|
|
5267
|
+
return;
|
|
5268
|
+
}
|
|
5269
|
+
onChange(combined);
|
|
5270
|
+
}
|
|
5271
|
+
else if (date) {
|
|
5272
|
+
// Just date selected, no time yet
|
|
5273
|
+
// Auto-set to minTime if available for better UX
|
|
5274
|
+
const restrictions = calculateTimeRestrictions(date);
|
|
5275
|
+
if (restrictions.minTime) {
|
|
5276
|
+
setSelectedTime(restrictions.minTime);
|
|
5277
|
+
onChange(combineDateTime(date, restrictions.minTime));
|
|
5278
|
+
}
|
|
5279
|
+
else {
|
|
5280
|
+
onChange(undefined);
|
|
5281
|
+
}
|
|
5282
|
+
}
|
|
5283
|
+
else {
|
|
5284
|
+
onChange(undefined);
|
|
5285
|
+
}
|
|
5286
|
+
}, [selectedTime, combineDateTime, onChange, calculateTimeRestrictions]);
|
|
5287
|
+
/**
|
|
5288
|
+
* Handle time selection change
|
|
5289
|
+
*
|
|
5290
|
+
* Combines the new time with the selected date and validates.
|
|
5291
|
+
* Only calls onChange if the combination is valid.
|
|
5292
|
+
*/
|
|
5293
|
+
const handleTimeChange = useCallback((time) => {
|
|
5294
|
+
setSelectedTime(time);
|
|
5295
|
+
const combined = combineDateTime(selectedDate, time);
|
|
5296
|
+
// Only update if the combination is valid
|
|
5297
|
+
if (combined !== undefined || !time) {
|
|
5298
|
+
onChange(combined);
|
|
5299
|
+
}
|
|
5300
|
+
}, [selectedDate, combineDateTime, onChange]);
|
|
5301
|
+
/**
|
|
5302
|
+
* Handle "Now" button click
|
|
5303
|
+
* Sets the datetime to the current moment, if it's within the allowed min/max datetime range.
|
|
5304
|
+
*/
|
|
5305
|
+
const handleNowClick = useCallback(() => {
|
|
5306
|
+
const now = new Date();
|
|
5307
|
+
// Check if now is within allowed range
|
|
5308
|
+
const isNowValid = (!normalizedMinDateTime || now >= normalizedMinDateTime) &&
|
|
5309
|
+
(!normalizedMaxDateTime || now <= normalizedMaxDateTime);
|
|
5310
|
+
if (isNowValid) {
|
|
5311
|
+
onChange(now);
|
|
5312
|
+
}
|
|
5313
|
+
}, [normalizedMinDateTime, normalizedMaxDateTime, onChange]);
|
|
5314
|
+
// Extract min/max date from normalized datetime for DatePicker
|
|
5315
|
+
const minDate = normalizedMinDateTime;
|
|
5316
|
+
const maxDate = normalizedMaxDateTime;
|
|
5317
|
+
// ========================================
|
|
5318
|
+
// RENDER
|
|
5319
|
+
// ========================================
|
|
5320
|
+
return (jsx("div", { className: `cw-datetimepicker cw-datetimepicker-separate ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-flex-row cw-align-left-center cw-gap-small", children: [jsx(CwDatePicker, { value: selectedDate, onChange: handleDateChange, minDate: minDate, maxDate: maxDate, disabledDates: disabledDates, disabledMatcher: disabledMatcher, placeholder: datePlaceholder, disabled: disabled, required: required, showClear: showClear, numberOfMonths: numberOfMonths, popupPosition: popupPosition }), jsx(CwTimePicker, { value: selectedTime, onChange: handleTimeChange, interval: timeInterval, minTime: timeRestrictions.minTime, maxTime: timeRestrictions.maxTime, placeholder: timePlaceholder, disabled: disabled, required: required, showClear: showClear, popupPosition: popupPosition }), showNowButton && (jsx(CwButton, { type: "button", variant: "outline", onClick: handleNowClick, disabled: disabled, title: "Set to current date and time", text: "Now" }))] })] }) }));
|
|
5321
|
+
}
|
|
5322
|
+
|
|
5323
|
+
var compactStyles = {"compactPopup":"cw-datetime-compact-module_compactPopup__GiuNY","calendarWrapper":"cw-datetime-compact-module_calendarWrapper__P4Nlq","timeWrapper":"cw-datetime-compact-module_timeWrapper__uMe-A","compactTimeList":"cw-datetime-compact-module_compactTimeList__MzSQT"};
|
|
5324
|
+
|
|
5325
|
+
function CustomCaption({ displayMonth }) {
|
|
5326
|
+
const { goToMonth, nextMonth, previousMonth } = useNavigation();
|
|
5327
|
+
return (jsxs("header", { children: [jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-left", onClick: () => previousMonth && goToMonth(previousMonth), disabled: !previousMonth, "aria-label": "Previous month" }), jsx("div", { className: styles$4.title, children: format(displayMonth, "MMMM yyyy", { locale: enGB }) }), jsx(CwButton, { type: "button", variant: "icon", icon: "chevron-right", onClick: () => nextMonth && goToMonth(nextMonth), disabled: !nextMonth, "aria-label": "Next month" })] }));
|
|
5328
|
+
}
|
|
5329
|
+
function CwDateTimePickerCompact({ value, onChange, minDateTime, maxDateTime, disabledDates, disabledMatcher, timeInterval = 15, minTime, maxTime, labelProps, alignProps, placeholder = "dd.mm.yyyy HH:mm", disabled, required, className, showClear = true, popupPosition = "left-bottom", numberOfMonths = 1, showTodayButton = false, }) {
|
|
5330
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
5331
|
+
const [inputValue, setInputValue] = useState("");
|
|
5332
|
+
const [selectedDate, setSelectedDate] = useState(value);
|
|
5333
|
+
const [selectedTime, setSelectedTime] = useState("");
|
|
5334
|
+
const containerRef = useRef(null);
|
|
5335
|
+
const inputRef = useRef(null);
|
|
5336
|
+
const timeListRef = useRef(null);
|
|
5337
|
+
const prevValueRef = useRef(value);
|
|
5338
|
+
// Generate time options based on interval - memoized
|
|
5339
|
+
const timeOptions = useMemo(() => {
|
|
5340
|
+
const options = [];
|
|
5341
|
+
const totalMinutes = 24 * 60;
|
|
5342
|
+
for (let minutes = 0; minutes < totalMinutes; minutes += timeInterval) {
|
|
5343
|
+
const hours = Math.floor(minutes / 60);
|
|
5344
|
+
const mins = minutes % 60;
|
|
5345
|
+
const timeString = `${hours.toString().padStart(2, "0")}:${mins.toString().padStart(2, "0")}`;
|
|
5346
|
+
if (minTime && timeString < minTime)
|
|
5347
|
+
continue;
|
|
5348
|
+
if (maxTime && timeString > maxTime)
|
|
5349
|
+
continue;
|
|
5350
|
+
options.push(timeString);
|
|
5351
|
+
}
|
|
5352
|
+
return options;
|
|
5353
|
+
}, [timeInterval, minTime, maxTime]);
|
|
5354
|
+
// Parse datetime from string: dd.MM.yyyy HH:mm
|
|
5355
|
+
const parseDateTime = useCallback((dateTimeString) => {
|
|
5356
|
+
try {
|
|
5357
|
+
const parts = dateTimeString.trim().split(' ');
|
|
5358
|
+
if (parts.length !== 2)
|
|
5359
|
+
return undefined;
|
|
5360
|
+
const [dateStr, timeStr] = parts;
|
|
5361
|
+
// Parse date part
|
|
5362
|
+
const dateParts = dateStr.split(/[\/\-\.]/);
|
|
5363
|
+
if (dateParts.length !== 3)
|
|
5364
|
+
return undefined;
|
|
5365
|
+
const day = parseInt(dateParts[0], 10);
|
|
5366
|
+
const month = parseInt(dateParts[1], 10) - 1;
|
|
5367
|
+
const year = parseInt(dateParts[2], 10);
|
|
5368
|
+
// Parse time part
|
|
5369
|
+
const timeParts = timeStr.split(':');
|
|
5370
|
+
if (timeParts.length !== 2)
|
|
5371
|
+
return undefined;
|
|
5372
|
+
const hours = parseInt(timeParts[0], 10);
|
|
5373
|
+
const minutes = parseInt(timeParts[1], 10);
|
|
5374
|
+
// Validate ranges
|
|
5375
|
+
if (isNaN(day) || isNaN(month) || isNaN(year) ||
|
|
5376
|
+
isNaN(hours) || isNaN(minutes) ||
|
|
5377
|
+
hours < 0 || hours > 23 ||
|
|
5378
|
+
minutes < 0 || minutes > 59) {
|
|
5379
|
+
return undefined;
|
|
5380
|
+
}
|
|
5381
|
+
const parsed = new Date(year, month, day, hours, minutes, 0, 0);
|
|
5382
|
+
// Validate the date is real
|
|
5383
|
+
if (parsed.getDate() === day &&
|
|
5384
|
+
parsed.getMonth() === month &&
|
|
5385
|
+
parsed.getFullYear() === year &&
|
|
5386
|
+
parsed.getHours() === hours &&
|
|
5387
|
+
parsed.getMinutes() === minutes) {
|
|
5388
|
+
return parsed;
|
|
4436
5389
|
}
|
|
5390
|
+
return undefined;
|
|
4437
5391
|
}
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
const filtered = optionsProps.selectList.filter((option) => {
|
|
4441
|
-
// Search all properties of the object
|
|
4442
|
-
return Object.keys(option).some(key => {
|
|
4443
|
-
const value = option[key];
|
|
4444
|
-
// Verify that the value is a string or number and contains the search text
|
|
4445
|
-
return (typeof value === 'string' || typeof value === 'number') &&
|
|
4446
|
-
String(value).toLowerCase().includes(text.toLowerCase());
|
|
4447
|
-
});
|
|
4448
|
-
});
|
|
4449
|
-
setFilteredOptions(filtered);
|
|
5392
|
+
catch {
|
|
5393
|
+
return undefined;
|
|
4450
5394
|
}
|
|
4451
|
-
};
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
5395
|
+
}, []);
|
|
5396
|
+
// Validate and set datetime - with proper datetime comparison
|
|
5397
|
+
const validateAndSetDateTime = useCallback((dateTimeString) => {
|
|
5398
|
+
const parsed = parseDateTime(dateTimeString);
|
|
5399
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
5400
|
+
const isValid = (!minDateTime || parsed >= minDateTime) &&
|
|
5401
|
+
(!maxDateTime || parsed <= maxDateTime);
|
|
5402
|
+
if (isValid) {
|
|
5403
|
+
onChange(parsed);
|
|
5404
|
+
setSelectedDate(parsed);
|
|
5405
|
+
setSelectedTime(format(parsed, "HH:mm"));
|
|
5406
|
+
return true;
|
|
5407
|
+
}
|
|
4456
5408
|
}
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
5409
|
+
return false;
|
|
5410
|
+
}, [parseDateTime, minDateTime, maxDateTime, onChange]);
|
|
5411
|
+
// Sync input value with prop value - only when changed externally
|
|
5412
|
+
useEffect(() => {
|
|
5413
|
+
const currentValue = value;
|
|
5414
|
+
if (currentValue !== prevValueRef.current) {
|
|
5415
|
+
prevValueRef.current = currentValue;
|
|
5416
|
+
if (currentValue) {
|
|
5417
|
+
const dateStr = format(currentValue, "dd.MM.yyyy", { locale: enGB });
|
|
5418
|
+
const timeStr = format(currentValue, "HH:mm", { locale: enGB });
|
|
5419
|
+
setInputValue(`${dateStr} ${timeStr}`);
|
|
5420
|
+
setSelectedDate(currentValue);
|
|
5421
|
+
setSelectedTime(timeStr);
|
|
5422
|
+
}
|
|
5423
|
+
else {
|
|
5424
|
+
setInputValue("");
|
|
5425
|
+
setSelectedDate(undefined);
|
|
5426
|
+
setSelectedTime("");
|
|
5427
|
+
}
|
|
4468
5428
|
}
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
};
|
|
4472
|
-
const handleClearClick = () => {
|
|
4473
|
-
setSearchText("");
|
|
4474
|
-
setFilteredOptions([]);
|
|
4475
|
-
setSelectedOption(null);
|
|
4476
|
-
};
|
|
4477
|
-
return (jsxs("div", { className: "cwSearchInputComp", style: optionsProps.style, id: optionsProps.id, children: [jsxs("div", { className: optionsProps.labelPosition === "inline"
|
|
4478
|
-
? "cw-flex-row cw-align-left-center"
|
|
4479
|
-
: optionsProps.labelPosition === "column"
|
|
4480
|
-
? "cw-label-input-column"
|
|
4481
|
-
: "cw-flex-row cw-align-left-center", children: [optionsProps.labelName && (jsx("label", { children: optionsProps.labelName })), jsx("input", { type: "text", value: searchText, onChange: handleInputChange, onFocus: handleInputFocus, onBlur: handleInputBlur, placeholder: "Search...", className: "cw_input_search", disabled: optionsProps.disabled }), searchText && (jsx("button", { className: "cw-button-icon cwi-close cw-input-search-clear", onClick: handleClearClick }))] }), showDropdown && filteredOptions.length > 0 && (jsx("div", { className: "cw-input-search-dropdown", children: jsx("ul", { children: filteredOptions.map((option) => (jsx("li", { onClick: () => handleOptionSelect(option), onMouseDown: (e) => e.preventDefault(), children: optionsProps.renderOption
|
|
4482
|
-
? optionsProps.renderOption(option)
|
|
4483
|
-
: option.description }, option.id))) }) }))] }));
|
|
4484
|
-
}
|
|
4485
|
-
|
|
4486
|
-
var styles$4 = {"context-menu":"cw-context-menu-module_context-menu__dbxnO","context-menu-item":"cw-context-menu-module_context-menu-item__B2W-Q"};
|
|
4487
|
-
|
|
4488
|
-
/**
|
|
4489
|
-
* A context menu that is rendered when the user clicks on a button.
|
|
4490
|
-
* @author NVS
|
|
4491
|
-
* @example
|
|
4492
|
-
* <ContextMenu
|
|
4493
|
-
* options={['Option 1', 'Option 2', 'Option 3']}
|
|
4494
|
-
* onSelect={(option) => console.log(`Selected: ${option}`)}
|
|
4495
|
-
* >
|
|
4496
|
-
* <div>Right-click me!</div>
|
|
4497
|
-
* </ContextMenu>
|
|
4498
|
-
*/
|
|
4499
|
-
const CwContextMenu = ({ children, options, offset, onSelect }) => {
|
|
4500
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
4501
|
-
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
4502
|
-
const menuRef = useRef(null);
|
|
4503
|
-
const handleContextMenu = (event) => {
|
|
4504
|
-
event.preventDefault();
|
|
4505
|
-
setIsOpen(true);
|
|
4506
|
-
setPosition({ x: event.clientX, y: event.clientY });
|
|
4507
|
-
};
|
|
4508
|
-
const handleOptionClick = (option) => {
|
|
4509
|
-
onSelect(option);
|
|
4510
|
-
setIsOpen(false);
|
|
4511
|
-
};
|
|
5429
|
+
}, [value]);
|
|
5430
|
+
// Close popup when clicking outside
|
|
4512
5431
|
useEffect(() => {
|
|
4513
|
-
const
|
|
4514
|
-
if (
|
|
5432
|
+
const handleClickOutside = (event) => {
|
|
5433
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
4515
5434
|
setIsOpen(false);
|
|
4516
5435
|
}
|
|
4517
5436
|
};
|
|
4518
|
-
|
|
5437
|
+
if (isOpen) {
|
|
5438
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
5439
|
+
}
|
|
4519
5440
|
return () => {
|
|
4520
|
-
document.removeEventListener("mousedown",
|
|
5441
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
4521
5442
|
};
|
|
5443
|
+
}, [isOpen]);
|
|
5444
|
+
// Scroll to selected time when opening
|
|
5445
|
+
useEffect(() => {
|
|
5446
|
+
if (isOpen && selectedTime && timeListRef.current) {
|
|
5447
|
+
const selectedElement = timeListRef.current.querySelector('.selected');
|
|
5448
|
+
if (selectedElement) {
|
|
5449
|
+
selectedElement.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
}, [isOpen, selectedTime]);
|
|
5453
|
+
const combineDateTime = useCallback((date, time) => {
|
|
5454
|
+
if (!date || !time)
|
|
5455
|
+
return undefined;
|
|
5456
|
+
const [hours, minutes] = time.split(':').map(Number);
|
|
5457
|
+
const combined = new Date(date);
|
|
5458
|
+
combined.setHours(hours, minutes, 0, 0);
|
|
5459
|
+
return combined;
|
|
4522
5460
|
}, []);
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
const
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
}
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
5461
|
+
const handleDaySelect = useCallback((date) => {
|
|
5462
|
+
if (!date)
|
|
5463
|
+
return;
|
|
5464
|
+
setSelectedDate(date);
|
|
5465
|
+
// If time is already selected, combine and update
|
|
5466
|
+
if (selectedTime) {
|
|
5467
|
+
const combined = combineDateTime(date, selectedTime);
|
|
5468
|
+
if (combined) {
|
|
5469
|
+
onChange(combined);
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
}, [selectedTime, combineDateTime, onChange]);
|
|
5473
|
+
const handleTimeSelect = useCallback((time) => {
|
|
5474
|
+
setSelectedTime(time);
|
|
5475
|
+
// If date is already selected, combine and update
|
|
5476
|
+
if (selectedDate) {
|
|
5477
|
+
const combined = combineDateTime(selectedDate, time);
|
|
5478
|
+
if (combined) {
|
|
5479
|
+
onChange(combined);
|
|
5480
|
+
setIsOpen(false);
|
|
5481
|
+
inputRef.current?.blur();
|
|
5482
|
+
}
|
|
5483
|
+
}
|
|
5484
|
+
}, [selectedDate, combineDateTime, onChange]);
|
|
5485
|
+
const handleClear = useCallback((e) => {
|
|
5486
|
+
e.stopPropagation();
|
|
5487
|
+
onChange(undefined);
|
|
5488
|
+
setInputValue("");
|
|
5489
|
+
setSelectedDate(undefined);
|
|
5490
|
+
setSelectedTime("");
|
|
5491
|
+
}, [onChange]);
|
|
5492
|
+
const handleInputClick = useCallback(() => {
|
|
5493
|
+
if (!disabled) {
|
|
5494
|
+
setIsOpen(true);
|
|
5495
|
+
}
|
|
5496
|
+
}, [disabled]);
|
|
5497
|
+
const handleInputChange = useCallback((e) => {
|
|
5498
|
+
const newValue = e.target.value;
|
|
5499
|
+
setInputValue(newValue);
|
|
5500
|
+
// Try to parse the full datetime string: dd.MM.yyyy HH:mm
|
|
5501
|
+
if (newValue.length >= 16) {
|
|
5502
|
+
validateAndSetDateTime(newValue);
|
|
5503
|
+
}
|
|
5504
|
+
else if (newValue === "") {
|
|
5505
|
+
onChange(undefined);
|
|
5506
|
+
setSelectedDate(undefined);
|
|
5507
|
+
setSelectedTime("");
|
|
5508
|
+
}
|
|
5509
|
+
}, [validateAndSetDateTime, onChange]);
|
|
5510
|
+
const handleInputBlur = useCallback(() => {
|
|
5511
|
+
// Try to parse if there's text
|
|
5512
|
+
if (inputValue && inputValue.trim() !== "") {
|
|
5513
|
+
const parsed = parseDateTime(inputValue);
|
|
5514
|
+
if (parsed && !isNaN(parsed.getTime())) {
|
|
5515
|
+
const isValid = (!minDateTime || parsed >= minDateTime) &&
|
|
5516
|
+
(!maxDateTime || parsed <= maxDateTime);
|
|
5517
|
+
if (isValid) {
|
|
5518
|
+
onChange(parsed);
|
|
5519
|
+
const dateStr = format(parsed, "dd.MM.yyyy", { locale: enGB });
|
|
5520
|
+
const timeStr = format(parsed, "HH:mm", { locale: enGB });
|
|
5521
|
+
setInputValue(`${dateStr} ${timeStr}`);
|
|
5522
|
+
setSelectedDate(parsed);
|
|
5523
|
+
setSelectedTime(timeStr);
|
|
5524
|
+
return;
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
}
|
|
5528
|
+
// Sync with current value
|
|
5529
|
+
if (value) {
|
|
5530
|
+
const dateStr = format(value, "dd.MM.yyyy", { locale: enGB });
|
|
5531
|
+
const timeStr = format(value, "HH:mm", { locale: enGB });
|
|
5532
|
+
setInputValue(`${dateStr} ${timeStr}`);
|
|
4568
5533
|
}
|
|
5534
|
+
else {
|
|
5535
|
+
setInputValue("");
|
|
5536
|
+
}
|
|
5537
|
+
}, [inputValue, parseDateTime, minDateTime, maxDateTime, onChange, value]);
|
|
5538
|
+
const handleInputKeyDown = useCallback((e) => {
|
|
4569
5539
|
if (e.key === "Enter") {
|
|
4570
|
-
|
|
4571
|
-
|
|
5540
|
+
e.preventDefault();
|
|
5541
|
+
inputRef.current?.blur();
|
|
5542
|
+
setIsOpen(false);
|
|
4572
5543
|
}
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
}
|
|
4610
|
-
// Cw add button
|
|
4611
|
-
function CwBtnAdd({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4612
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-plus", disabled: cw_btn_disabled });
|
|
4613
|
-
}
|
|
4614
|
-
// Cw Save button
|
|
4615
|
-
function CwBtnSave({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4616
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-save", disabled: cw_btn_disabled });
|
|
4617
|
-
}
|
|
4618
|
-
// Cw edit button
|
|
4619
|
-
function CwBtnEdit({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4620
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-edit", disabled: cw_btn_disabled });
|
|
4621
|
-
}
|
|
4622
|
-
// Cw search button
|
|
4623
|
-
function CwBtnSearch({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4624
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-search", disabled: cw_btn_disabled });
|
|
4625
|
-
}
|
|
4626
|
-
// Cw download button
|
|
4627
|
-
function CwBtnDownload({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4628
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-download", disabled: cw_btn_disabled });
|
|
4629
|
-
}
|
|
4630
|
-
// Cw view button
|
|
4631
|
-
function CwBtnView({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4632
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-eye-show", disabled: cw_btn_disabled });
|
|
4633
|
-
}
|
|
4634
|
-
// Cw Print button
|
|
4635
|
-
function CwBtnPrint({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4636
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-print", disabled: cw_btn_disabled });
|
|
4637
|
-
}
|
|
4638
|
-
// Cw cancel button
|
|
4639
|
-
function CwBtnCancel({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4640
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-cancel", disabled: cw_btn_disabled, "data-color": "danger" });
|
|
4641
|
-
}
|
|
4642
|
-
// Cw Delete button
|
|
4643
|
-
function CwBtnDelete({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4644
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-delete", disabled: cw_btn_disabled, "data-color": "danger" });
|
|
4645
|
-
}
|
|
4646
|
-
// CwRefresh
|
|
4647
|
-
function CwBtnRefresh({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4648
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-refresh", disabled: cw_btn_disabled });
|
|
4649
|
-
}
|
|
4650
|
-
// Cw hide
|
|
4651
|
-
function CwBtnHide({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4652
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-eye-hide", disabled: cw_btn_disabled });
|
|
4653
|
-
}
|
|
4654
|
-
// Cw Select
|
|
4655
|
-
function CwBtnSelect({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4656
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_select", disabled: cw_btn_disabled });
|
|
4657
|
-
}
|
|
4658
|
-
// Cw Share
|
|
4659
|
-
function CwBtnShare({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4660
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-share", disabled: cw_btn_disabled });
|
|
4661
|
-
}
|
|
4662
|
-
// Cw Files
|
|
4663
|
-
function CwBtnFiles({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4664
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_files", disabled: cw_btn_disabled });
|
|
4665
|
-
}
|
|
4666
|
-
// Cw Airport
|
|
4667
|
-
function CwBtnAirport({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4668
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btn_airport", disabled: cw_btn_disabled });
|
|
4669
|
-
}
|
|
4670
|
-
// DownLoadAllInfo
|
|
4671
|
-
function CwBtnDownLoadAllInfo({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4672
|
-
return (jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-download", disabled: cw_btn_disabled }));
|
|
4673
|
-
}
|
|
4674
|
-
// PropertyFolder
|
|
4675
|
-
function CwBtnPropertyFolder({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4676
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-directory", disabled: cw_btn_disabled });
|
|
4677
|
-
}
|
|
4678
|
-
// AddFolder
|
|
4679
|
-
function CwBtnAddFolder({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4680
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-add", disabled: cw_btn_disabled });
|
|
4681
|
-
}
|
|
4682
|
-
// EditFolder
|
|
4683
|
-
function CwBtnEditFolder({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4684
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-folder-edit", disabled: cw_btn_disabled });
|
|
4685
|
-
}
|
|
4686
|
-
// UploadFiles
|
|
4687
|
-
function CwBtnUploadFiles({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4688
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-upload", disabled: cw_btn_disabled });
|
|
4689
|
-
}
|
|
4690
|
-
// GoBackSection [ Emanual ]
|
|
4691
|
-
function CwBtnGoBackFolder({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4692
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cwBtnGoBackFolder", disabled: cw_btn_disabled });
|
|
4693
|
-
}
|
|
4694
|
-
// BookMark [ Emanual ]
|
|
4695
|
-
function CwBtnBookMark({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4696
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-star", disabled: cw_btn_disabled });
|
|
4697
|
-
}
|
|
4698
|
-
// Publish
|
|
4699
|
-
function CwBtnPublish({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4700
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnPublish", disabled: cw_btn_disabled });
|
|
4701
|
-
}
|
|
4702
|
-
// Approve
|
|
4703
|
-
function CwBtnApprove({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4704
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnApprove", disabled: cw_btn_disabled });
|
|
4705
|
-
}
|
|
4706
|
-
// Bulk duty
|
|
4707
|
-
function CwBtnBulkDuty({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4708
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnBulkDuty", disabled: cw_btn_disabled });
|
|
4709
|
-
}
|
|
4710
|
-
// DropDownButtonCrewControl
|
|
4711
|
-
function CwBtnDropDownMenu({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4712
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnDropDownMenu", disabled: cw_btn_disabled });
|
|
4713
|
-
}
|
|
4714
|
-
// DropDownButtonCrewControl
|
|
4715
|
-
function CwBtnAlert({ cw_btnOnclick, cw_btn_disabled, cw_name }) {
|
|
4716
|
-
return (jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-alert", disabled: cw_btn_disabled, id: cw_name }));
|
|
4717
|
-
}
|
|
4718
|
-
// BtnNavFirstItemView
|
|
4719
|
-
function CwBtnNavFirstItemView({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4720
|
-
return (jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnNavFirstItemView", disabled: cw_btn_disabled }));
|
|
4721
|
-
}
|
|
4722
|
-
// BtnNavLastItemView
|
|
4723
|
-
function CwBtnNavLastItemView({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4724
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnNavLastItemView", disabled: cw_btn_disabled });
|
|
4725
|
-
}
|
|
4726
|
-
// BtnNavbreviewItem
|
|
4727
|
-
function CwBtnNavPreviewItem({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4728
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnNavPreviewItem", disabled: cw_btn_disabled });
|
|
4729
|
-
}
|
|
4730
|
-
// BtnNavNextDay
|
|
4731
|
-
function CwBtnNavNextDay({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4732
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnNavNextDay", disabled: cw_btn_disabled });
|
|
4733
|
-
}
|
|
4734
|
-
// BtnNavNextDay
|
|
4735
|
-
function CwBtnStatistic({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4736
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-file-report", disabled: cw_btn_disabled });
|
|
4737
|
-
}
|
|
4738
|
-
// BtnNavNextDay
|
|
4739
|
-
function CwBtnCrewPlanning({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4740
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-calendar-view", disabled: cw_btn_disabled });
|
|
4741
|
-
}
|
|
4742
|
-
// BtnReleasePeriod
|
|
4743
|
-
function CwBtnReleasePeriod({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4744
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnReleasePeriod", disabled: cw_btn_disabled });
|
|
4745
|
-
}
|
|
4746
|
-
// BtnReleasePeriod
|
|
4747
|
-
function CwBtnGeneratePairing({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4748
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-plane-pairing", disabled: cw_btn_disabled });
|
|
4749
|
-
}
|
|
4750
|
-
// BtnImportRequests
|
|
4751
|
-
function CwBtnImportRequests({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4752
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cw_btnImportRequests", disabled: cw_btn_disabled });
|
|
4753
|
-
}
|
|
4754
|
-
// BtnPairing
|
|
4755
|
-
function CwBtnPairing({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4756
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-calendar-plane", disabled: cw_btn_disabled });
|
|
4757
|
-
}
|
|
4758
|
-
// BtnVacations
|
|
4759
|
-
function CwBtnVacations({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4760
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-luggage", disabled: cw_btn_disabled });
|
|
4761
|
-
}
|
|
4762
|
-
// BtnMVT
|
|
4763
|
-
function CwBtnMVT({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4764
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-plane-movement", disabled: cw_btn_disabled });
|
|
4765
|
-
}
|
|
4766
|
-
// BtnDelay
|
|
4767
|
-
function CwBtnDelay({ cw_btnOnclick, cw_btn_disabled }) {
|
|
4768
|
-
return jsx("button", { onClick: cw_btnOnclick, className: "cw-button-icon cwi-icons cwi-plane-delay", disabled: cw_btn_disabled });
|
|
5544
|
+
else if (e.key === "Escape") {
|
|
5545
|
+
setIsOpen(false);
|
|
5546
|
+
inputRef.current?.blur();
|
|
5547
|
+
}
|
|
5548
|
+
}, []);
|
|
5549
|
+
const handleNowClick = useCallback(() => {
|
|
5550
|
+
const now = new Date();
|
|
5551
|
+
// Check if now is within allowed range
|
|
5552
|
+
const isNowValid = (!minDateTime || now >= minDateTime) &&
|
|
5553
|
+
(!maxDateTime || now <= maxDateTime);
|
|
5554
|
+
if (isNowValid) {
|
|
5555
|
+
onChange(now);
|
|
5556
|
+
setIsOpen(false);
|
|
5557
|
+
}
|
|
5558
|
+
}, [minDateTime, maxDateTime, onChange]);
|
|
5559
|
+
// Memoize formatters
|
|
5560
|
+
const formatters = useMemo(() => ({
|
|
5561
|
+
formatCaption: (date) => format(date, "MMMM yyyy", { locale: enGB }),
|
|
5562
|
+
formatWeekdayName: (date) => format(date, "EEEEEE", { locale: enGB })
|
|
5563
|
+
}), []);
|
|
5564
|
+
// Memoize disabled days
|
|
5565
|
+
const disabledDays = useMemo(() => [
|
|
5566
|
+
...(disabledDates || []),
|
|
5567
|
+
...(minDateTime ? [{ before: minDateTime }] : []),
|
|
5568
|
+
...(maxDateTime ? [{ after: maxDateTime }] : []),
|
|
5569
|
+
...(disabledMatcher ? [disabledMatcher] : []),
|
|
5570
|
+
], [disabledDates, minDateTime, maxDateTime, disabledMatcher]);
|
|
5571
|
+
return (jsx("div", { ref: containerRef, className: `cw-datetimepicker ${className || ""}`, children: jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: styles$4.pickerWrapper, children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, placeholder: placeholder, onChange: handleInputChange, onBlur: handleInputBlur, onClick: handleInputClick, onKeyDown: handleInputKeyDown, disabled: disabled, required: required, maxLength: 16, style: { width: "24ch" } }), jsx("div", { className: styles$4.pickerIcons, children: showClear && value && !disabled ? (jsx(CwButton, { type: "button", variant: "icon", color: "neutral", icon: "close", onClick: handleClear, tabIndex: -1, "aria-label": "Clear datetime" })) : (jsx(CwIcon, { iconId: "calendar-time" })) }), isOpen && (jsxs("div", { className: `${styles$4.pickerPopup} ${compactStyles.compactPopup}`, "data-position": popupPosition, children: [jsxs("div", { className: compactStyles.calendarWrapper, children: [jsx(DayPicker, { mode: "single", selected: selectedDate, onSelect: handleDaySelect, defaultMonth: selectedDate, disabled: disabledDays, locale: enGB, numberOfMonths: numberOfMonths, formatters: formatters, components: {
|
|
5572
|
+
Caption: (props) => jsx(CustomCaption, { ...props }),
|
|
5573
|
+
}, modifiers: {
|
|
5574
|
+
today: new Date(),
|
|
5575
|
+
}, modifiersClassNames: {
|
|
5576
|
+
today: "rdp-day_today",
|
|
5577
|
+
} }), showTodayButton && (jsx("footer", { className: "cw-flex-row cw-align-center-center", children: jsx(CwButton, { type: "button", variant: "outline", icon: "check-big", onClick: handleNowClick, text: "Now" }) }))] }), jsxs("div", { className: compactStyles.timeWrapper, children: [jsxs("header", { children: [jsx(CwIcon, { iconId: "clock", size: "medium" }), jsx("span", { children: "Time" })] }), jsx("div", { ref: timeListRef, className: `${timeStyles.timePickerList} ${compactStyles.compactTimeList}`, children: timeOptions.map((time) => {
|
|
5578
|
+
const isSelected = time === selectedTime;
|
|
5579
|
+
return (jsx("button", { type: "button", className: isSelected ? timeStyles.selected : "", onClick: () => handleTimeSelect(time), children: time }, time));
|
|
5580
|
+
}) })] })] }))] })] }) }));
|
|
4769
5581
|
}
|
|
4770
5582
|
|
|
4771
5583
|
const ResourcesTitleList$1 = ({ resources, canBePinned, includesPinned, onCrewPinning, onClickResourceContextMenu, ResourceTitleComponent }) => {
|
|
@@ -5810,8 +6622,8 @@ class CwScheduler2 extends Component {
|
|
|
5810
6622
|
this.handleResize();
|
|
5811
6623
|
}
|
|
5812
6624
|
if (dateChange) {
|
|
5813
|
-
const events =
|
|
5814
|
-
const resources =
|
|
6625
|
+
const events = cloneDeep(this.props.events);
|
|
6626
|
+
const resources = cloneDeep(this.props.resources);
|
|
5815
6627
|
this.initOutside(events, resources, _nextProps, _nextProps.startDate, _nextProps.endDate);
|
|
5816
6628
|
if (this.state.showConsoleLogs) {
|
|
5817
6629
|
console.log("Schedule - componentWillReceiveProps - print on schedule, end: ", moment(new Date()).toString());
|
|
@@ -5934,6 +6746,12 @@ const PinButton = ({ canBePinned, resource, onCrewPinning }) => {
|
|
|
5934
6746
|
return jsx("button", { className: "cw-button-icon cw-icon-pin", ...buttonProps });
|
|
5935
6747
|
};
|
|
5936
6748
|
|
|
6749
|
+
const addMinutesToDateFromPx = (originalDate, leftPx, minutesPerPx) => {
|
|
6750
|
+
const minutes = leftPx / minutesPerPx;
|
|
6751
|
+
const datePlusMinutes = new Date(originalDate.getTime() + minutes * 60000);
|
|
6752
|
+
return datePlusMinutes;
|
|
6753
|
+
};
|
|
6754
|
+
|
|
5937
6755
|
const doubleClickOnResource = (props, resource) => {
|
|
5938
6756
|
if (props.scheduler_handleDblClickOnResourceInScheduler) {
|
|
5939
6757
|
props.scheduler_handleDblClickOnResourceInScheduler(resource);
|
|
@@ -6100,12 +6918,6 @@ const EventRender = ({ event, schedulerProps }) => {
|
|
|
6100
6918
|
return render;
|
|
6101
6919
|
};
|
|
6102
6920
|
|
|
6103
|
-
const addMinutesToDateFromPx = (originalDate, leftPx, minutesPerPx) => {
|
|
6104
|
-
const minutes = leftPx / minutesPerPx;
|
|
6105
|
-
const datePlusMinutes = new Date(originalDate.getTime() + minutes * 60000);
|
|
6106
|
-
return datePlusMinutes;
|
|
6107
|
-
};
|
|
6108
|
-
|
|
6109
6921
|
const onDropEventToResource = (props, cblDragNDrop, resource) => {
|
|
6110
6922
|
props.scheduler_handleOnDropCblEventsOnResource.call(props.parent, cblDragNDrop, resource);
|
|
6111
6923
|
};
|
|
@@ -6205,12 +7017,25 @@ const ResourceRender = memo(({ res, schedulerProps, contentArea, state }) => {
|
|
|
6205
7017
|
}, className: "cwellt_divRow_schContent", children: res.events.map((evnt) => (jsx(EventRender, { event: evnt, schedulerProps: schedulerProps }, evnt.id))) }, res.id));
|
|
6206
7018
|
}, arePropsEqual);
|
|
6207
7019
|
|
|
6208
|
-
const ResourceListRender = ({ resources, schedulerProps, state, contentArea,
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
7020
|
+
const ResourceListRender = ({ resources, schedulerProps, state, contentArea,
|
|
7021
|
+
// onClickContextMenu,
|
|
7022
|
+
crewAssignmentSchedulerContextMenu, }) => {
|
|
7023
|
+
return (jsx(Fragment$1, { children: resources.map((r, _i) => (jsx(CwAnchoredMenu, { placement: "bottom", onContextMenu: (e) => {
|
|
7024
|
+
// Dirty temporal solution to remove ANT design, this can be killed when this scheduler is deprecated
|
|
7025
|
+
const leftPos = e.currentTarget.getBoundingClientRect().left -
|
|
7026
|
+
(contentArea?.getBoundingClientRect()?.left ?? 0) -
|
|
7027
|
+
window.scrollX;
|
|
7028
|
+
const calculatedDatetime = addMinutesToDateFromPx(schedulerProps.startDate, leftPos, state.minutePx);
|
|
7029
|
+
r.__contextMenuDatetime = calculatedDatetime;
|
|
7030
|
+
}, options: crewAssignmentSchedulerContextMenu?.map(m => ({
|
|
7031
|
+
key: m.key,
|
|
7032
|
+
label: (jsxs(Fragment, { children: [jsx("span", { className: m.icon, style: { color: m.color } }), jsx("span", { children: m.text })] }))
|
|
7033
|
+
})) ?? [], onSelect: (key) => {
|
|
7034
|
+
const datetime = r.__contextMenuDatetime ?? new Date();
|
|
7035
|
+
if (schedulerProps.scheduler_handleOnClickContextMenuResource) {
|
|
7036
|
+
schedulerProps.scheduler_handleOnClickContextMenuResource(datetime, r, key, schedulerProps.id);
|
|
7037
|
+
}
|
|
7038
|
+
}, children: jsx("span", { onDoubleClick: () => doubleClickOnResource(schedulerProps, r), id: schedulerProps.id + "_" + r.id, children: jsx(ResourceRender, { res: r, schedulerProps: schedulerProps, contentArea: contentArea, state: state, isInViewport: r.isInViewport }, r.id) }) }, r.id))) }));
|
|
6214
7039
|
};
|
|
6215
7040
|
|
|
6216
7041
|
const TimeLine$1 = ({ id, toolTipTitle, marginLeft, color = "rgba(255,0,0,.6)", pixels = 2, height = "100%", zIndex = 1, }) => {
|
|
@@ -6965,6 +7790,13 @@ function getPercentageFromMouseEvent(event) {
|
|
|
6965
7790
|
const clickPercentage = x / totalWidth;
|
|
6966
7791
|
return clickPercentage;
|
|
6967
7792
|
}
|
|
7793
|
+
function getPercentageFromElement(clientX, element) {
|
|
7794
|
+
const rect = element.getBoundingClientRect();
|
|
7795
|
+
const x = clientX - rect.left;
|
|
7796
|
+
const totalWidth = rect.width;
|
|
7797
|
+
const clickPercentage = x / totalWidth;
|
|
7798
|
+
return clickPercentage;
|
|
7799
|
+
}
|
|
6968
7800
|
|
|
6969
7801
|
class OnClickEvent {
|
|
6970
7802
|
id;
|
|
@@ -6992,8 +7824,10 @@ class OnDoubleClickEvent {
|
|
|
6992
7824
|
}
|
|
6993
7825
|
class OnDragEvent {
|
|
6994
7826
|
id;
|
|
6995
|
-
|
|
7827
|
+
crewId;
|
|
7828
|
+
constructor(id, crewId) {
|
|
6996
7829
|
this.id = id;
|
|
7830
|
+
this.crewId = crewId;
|
|
6997
7831
|
}
|
|
6998
7832
|
}
|
|
6999
7833
|
class OnDropEvent {
|
|
@@ -7068,10 +7902,6 @@ class OnClickRowHeader {
|
|
|
7068
7902
|
this.id = id;
|
|
7069
7903
|
}
|
|
7070
7904
|
}
|
|
7071
|
-
class UpdateApi {
|
|
7072
|
-
constructor() {
|
|
7073
|
-
}
|
|
7074
|
-
}
|
|
7075
7905
|
class OnClickUtc {
|
|
7076
7906
|
constructor() {
|
|
7077
7907
|
}
|
|
@@ -7203,15 +8033,13 @@ const BackgroundEvent = ({ value, heightRem }) => {
|
|
|
7203
8033
|
|
|
7204
8034
|
var styles$1 = {"scheduler-row-header":"scheduler-row-module_scheduler-row-header__S-iv4"};
|
|
7205
8035
|
|
|
7206
|
-
var styles = {"super-scheduler-row-header":"super-scheduler-module_super-scheduler-row-header__TTs4e","indicators":"super-scheduler-module_indicators__f4lIT","scheduler-crewmember-functions":"super-scheduler-module_scheduler-crewmember-functions__BS2hs"};
|
|
7207
|
-
|
|
7208
8036
|
const DefaultRowHeader = ({ value, width, onEvent }) => {
|
|
7209
8037
|
return (jsxs("div", { style: {
|
|
7210
8038
|
width: width,
|
|
7211
8039
|
// background: color,
|
|
7212
8040
|
}, onClick: (_) => {
|
|
7213
8041
|
onEvent(new OnClickRowHeader(value.rowId));
|
|
7214
|
-
}, className: styles$1["scheduler-row-header"], children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), " ", jsx("strong", { children: value.subtitle })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [value.title3 && jsxs("span", { className: styles["scheduler-crewmember-functions"], children: ["(", value.title3, ")"] }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }));
|
|
8042
|
+
}, className: styles$1["scheduler-row-header"], children: [jsxs("div", { children: [jsx("strong", { children: value.title }), value.title2 && jsxs("span", { children: ["-", value.title2] }), " ", jsx("strong", { children: value.subtitle })] }), value.subtitle && jsxs("div", { style: { opacity: 0.5 }, children: [value.title3 && jsxs("span", { className: styles$1["scheduler-crewmember-functions"], children: ["(", value.title3, ")"] }), value.subtitle2 && jsxs("span", { children: ["-", value.subtitle2] })] })] }));
|
|
7215
8043
|
};
|
|
7216
8044
|
|
|
7217
8045
|
function useSingleAndDoubleClicks(onClick, onDoubleClick) {
|
|
@@ -7256,7 +8084,7 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
|
|
|
7256
8084
|
const [isOnDrag, setIsOnDrag] = useState(false);
|
|
7257
8085
|
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
|
7258
8086
|
// Calculate colors of the event
|
|
7259
|
-
const backColor = getHSLColor(value.color, value.alpha ??
|
|
8087
|
+
const backColor = getHSLColor(value.color, value.alpha ?? 1);
|
|
7260
8088
|
const textColor = getContrastColor(value.color);
|
|
7261
8089
|
const eventTransparent = value.alpha ? value.alpha < 0.7 : false;
|
|
7262
8090
|
const canClick = value.isDraggable || value.isClickable === true;
|
|
@@ -7284,18 +8112,12 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
|
|
|
7284
8112
|
e.preventDefault();
|
|
7285
8113
|
onEvent(new OnDoubleClickEvent(value.id));
|
|
7286
8114
|
});
|
|
7287
|
-
return (jsx(
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
e.domEvent.preventDefault();
|
|
7294
|
-
e.domEvent.stopPropagation();
|
|
7295
|
-
onEvent(new OnClickContextMenu(value.id, e.key));
|
|
7296
|
-
},
|
|
7297
|
-
onMouseLeave: () => setIsContextMenuOpen(false),
|
|
7298
|
-
}, trigger: ["contextMenu"], overlayStyle: { animationDuration: "0" }, arrow: (value.contextMenuItems?.length ?? 0) > 0, children: jsx("div", { style: {
|
|
8115
|
+
return (jsx(CwAnchoredMenu, { open: isContextMenuOpen, onOpenChange: setIsContextMenuOpen, onContextMenu: (e) => {
|
|
8116
|
+
e.stopPropagation();
|
|
8117
|
+
// onEvent(new OnRightClickEvent(value.id));
|
|
8118
|
+
}, placement: "bottom", options: value.contextMenuItems ?? [], onSelect: (key) => {
|
|
8119
|
+
onEvent(new OnClickContextMenu(value.id, key));
|
|
8120
|
+
}, children: jsx("div", { style: {
|
|
7299
8121
|
top: "2px",
|
|
7300
8122
|
left: `${value.left}%`,
|
|
7301
8123
|
width: `${value.width}%`,
|
|
@@ -7311,14 +8133,10 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
|
|
|
7311
8133
|
setIsOnDrag(false);
|
|
7312
8134
|
}, onDragStart: (_) => {
|
|
7313
8135
|
if (value.isDraggable)
|
|
7314
|
-
onEvent(new OnDragEvent(value.id));
|
|
8136
|
+
onEvent(new OnDragEvent(value.id, value.rowId));
|
|
7315
8137
|
}, onDragEnd: (_) => {
|
|
7316
8138
|
if (value.isDraggable)
|
|
7317
8139
|
setIsOnDrag(false);
|
|
7318
|
-
}, onContextMenu: (e) => {
|
|
7319
|
-
e.stopPropagation();
|
|
7320
|
-
e.preventDefault();
|
|
7321
|
-
onEvent(new OnRightClickEvent(value.id));
|
|
7322
8140
|
}, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "bottom", hide: isOnDrag, dissapearsWhenHover: true, showDelay: 200, children: jsxs("div", { style: {
|
|
7323
8141
|
border: value.selected ? "2px solid black" : "none",
|
|
7324
8142
|
backgroundColor: backColor,
|
|
@@ -7361,7 +8179,7 @@ const SchedulerEvent = ({ value, heightRem, onEvent }) => {
|
|
|
7361
8179
|
backgroundColor: value.primaryTimeMarkerColor,
|
|
7362
8180
|
} })), value.secondaryTimeMarkerColor && (jsx("div", { className: styles$2["time-marker"], style: {
|
|
7363
8181
|
backgroundColor: value.secondaryTimeMarkerColor,
|
|
7364
|
-
} }))] }) }) }, value.id) }
|
|
8182
|
+
} }))] }) }) }, value.id) }));
|
|
7365
8183
|
};
|
|
7366
8184
|
|
|
7367
8185
|
const eventsCollide = (event1, event2) => {
|
|
@@ -7405,18 +8223,11 @@ const WeekEndLine = ({ left, top = "0px", height, widthPercentage }) => {
|
|
|
7405
8223
|
return (jsx(TimeLine, { color: "rgba(0,0,0,0.05)", left: left + "%", height: height, width: widthPercentage + "%", top: top }));
|
|
7406
8224
|
};
|
|
7407
8225
|
|
|
7408
|
-
const onClickMenuItem$1 = (e, event) => {
|
|
7409
|
-
e.domEvent.nativeEvent.preventDefault();
|
|
7410
|
-
e.domEvent.nativeEvent.stopPropagation();
|
|
7411
|
-
e.domEvent.nativeEvent.stopImmediatePropagation();
|
|
7412
|
-
e.domEvent.preventDefault();
|
|
7413
|
-
e.domEvent.stopPropagation();
|
|
7414
|
-
event();
|
|
7415
|
-
};
|
|
7416
8226
|
const SchedulerRow = memo((props) => {
|
|
7417
8227
|
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
|
7418
8228
|
const { events, backgroundEvents, rowHeader, contextMenuItems, RowTitleComp, EventComp, BackgroundEventComp, weekendLines, divisionLines, timeLinePercentage, selectedDate, visibleDays, onEvent, } = props;
|
|
7419
8229
|
const internalRows = separateEventsToInnerRows(events);
|
|
8230
|
+
const schedulerDivRef = useRef(null);
|
|
7420
8231
|
const { handleClick, handleDoubleClick } = useSingleAndDoubleClicks((e) => {
|
|
7421
8232
|
e.stopPropagation();
|
|
7422
8233
|
e.preventDefault();
|
|
@@ -7429,15 +8240,17 @@ const SchedulerRow = memo((props) => {
|
|
|
7429
8240
|
return (jsxs("div", { style: {
|
|
7430
8241
|
display: "flex",
|
|
7431
8242
|
minHeight: props.rowHeightInRem + "rem",
|
|
7432
|
-
}, children: [jsx(RowTitleComp, { ...rowHeader }), jsx(
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
8243
|
+
}, "data-name": "scheduler-row", children: [jsx(RowTitleComp, { ...rowHeader }), jsx(CwAnchoredMenu, { open: isContextMenuOpen, onOpenChange: setIsContextMenuOpen, placement: "bottom", options: contextMenuItems ?? [], onSelect: (key) => {
|
|
8244
|
+
onEvent(new OnClickContextMenu(rowHeader.value.rowId, key));
|
|
8245
|
+
}, onContextMenu: (e) => {
|
|
8246
|
+
// e.preventDefault();
|
|
8247
|
+
e.stopPropagation();
|
|
8248
|
+
if (!schedulerDivRef.current)
|
|
8249
|
+
return;
|
|
8250
|
+
const percentage = getPercentageFromElement(e.clientX, schedulerDivRef.current);
|
|
8251
|
+
const date = dateFromPercentage(selectedDate, visibleDays, percentage);
|
|
8252
|
+
onEvent(new OnRightClickRow(rowHeader.value.rowId, date));
|
|
8253
|
+
}, children: jsxs("div", { ref: schedulerDivRef, style: {
|
|
7441
8254
|
flex: 1,
|
|
7442
8255
|
display: "flex",
|
|
7443
8256
|
flexDirection: "column",
|
|
@@ -7446,8 +8259,6 @@ const SchedulerRow = memo((props) => {
|
|
|
7446
8259
|
e.preventDefault();
|
|
7447
8260
|
const percentage = getPercentageFromMouseEvent(e);
|
|
7448
8261
|
const date = dateFromPercentage(selectedDate, visibleDays, percentage);
|
|
7449
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/platform
|
|
7450
|
-
// change for navigator.userAgentData.platform when acepted in all browsers
|
|
7451
8262
|
const isMac = navigator.platform.toUpperCase().includes("MAC");
|
|
7452
8263
|
const isCtrlOrAltPressed = isMac ? e.altKey : e.ctrlKey;
|
|
7453
8264
|
if (isCtrlOrAltPressed) {
|
|
@@ -7458,13 +8269,7 @@ const SchedulerRow = memo((props) => {
|
|
|
7458
8269
|
}
|
|
7459
8270
|
}, onDragOver: (e) => {
|
|
7460
8271
|
e.preventDefault();
|
|
7461
|
-
}, onClick: handleClick, onDoubleClick: handleDoubleClick,
|
|
7462
|
-
e.preventDefault();
|
|
7463
|
-
e.stopPropagation();
|
|
7464
|
-
const percentage = getPercentageFromMouseEvent(e);
|
|
7465
|
-
const date = dateFromPercentage(selectedDate, visibleDays, percentage);
|
|
7466
|
-
onEvent(new OnRightClickRow(rowHeader.value.rowId, date));
|
|
7467
|
-
}, children: [weekendLines.map((weekend) => (jsx(WeekEndLine, { height: "100%", left: weekend.left, widthPercentage: weekend.width }, weekend.left))), divisionLines.map((division) => (jsx(DivisionLine, { height: "100%", left: division.left }, division.left))), backgroundEvents.length > 0 && backgroundEvents.some((e) => e.isVisible) && (jsx("div", { style: {
|
|
8272
|
+
}, onClick: handleClick, onDoubleClick: handleDoubleClick, children: [weekendLines.map((weekend) => (jsx(WeekEndLine, { height: "100%", left: weekend.left, widthPercentage: weekend.width }, weekend.left))), divisionLines.map((division) => (jsx(DivisionLine, { height: "100%", left: division.left }, division.left))), backgroundEvents.length > 0 && backgroundEvents.some((e) => e.isVisible) && (jsx("div", { style: {
|
|
7468
8273
|
height: "100%",
|
|
7469
8274
|
position: internalRows.length > 0 ? "absolute" : "relative",
|
|
7470
8275
|
width: "100%",
|
|
@@ -7477,7 +8282,7 @@ const SchedulerRow = memo((props) => {
|
|
|
7477
8282
|
height: props.rowHeightInRem + "rem",
|
|
7478
8283
|
pointerEvents: "none"
|
|
7479
8284
|
}, children: internalRow.map((event) => (jsx(EventComp, { value: event, heightRem: props.rowHeightInRem, onEvent: onEvent }, event.id))) }, index));
|
|
7480
|
-
}), !(timeLinePercentage < 0 || timeLinePercentage > 100) && (jsx(TimeLine, { color: "red", left: `${timeLinePercentage}%`, top: "0px", height: `100%` }))] }) }
|
|
8285
|
+
}), !(timeLinePercentage < 0 || timeLinePercentage > 100) && (jsx(TimeLine, { color: "red", left: `${timeLinePercentage}%`, top: "0px", height: `100%` }))] }) })] }));
|
|
7481
8286
|
}, (prevProps, nextProps) => {
|
|
7482
8287
|
// This memo is necessary to prevent re-render all the rows when a user makes drag and drop
|
|
7483
8288
|
const getEventKey = (event) => {
|
|
@@ -7728,205 +8533,6 @@ const getWeekendsDaysInDateRange = (initialDate, visibleDays) => {
|
|
|
7728
8533
|
|
|
7729
8534
|
class UiEvent {
|
|
7730
8535
|
}
|
|
7731
|
-
function when(event) {
|
|
7732
|
-
let found = false;
|
|
7733
|
-
const actions = {
|
|
7734
|
-
case(eventType, action) {
|
|
7735
|
-
if (!found && event instanceof eventType) {
|
|
7736
|
-
action(event);
|
|
7737
|
-
found = true;
|
|
7738
|
-
}
|
|
7739
|
-
return actions;
|
|
7740
|
-
},
|
|
7741
|
-
else(action) {
|
|
7742
|
-
if (!found) {
|
|
7743
|
-
action(event);
|
|
7744
|
-
}
|
|
7745
|
-
}
|
|
7746
|
-
};
|
|
7747
|
-
return actions;
|
|
7748
|
-
}
|
|
7749
|
-
|
|
7750
|
-
const getListOfNumbers = (len) => Array(len)
|
|
7751
|
-
.fill(0)
|
|
7752
|
-
.map((_, idx) => idx);
|
|
7753
|
-
const getRandomColor = () => {
|
|
7754
|
-
return "#" + (0x1000000 + Math.random() * 0xffffff).toString(16).substr(1, 6);
|
|
7755
|
-
};
|
|
7756
|
-
const getRandomEvents = (date, visibleDays, resourceId) => {
|
|
7757
|
-
return getListOfNumbers(visibleDays).map((e) => {
|
|
7758
|
-
const len1 = Math.floor(Math.random() * 24) + 1;
|
|
7759
|
-
const moment1 = moment(date).add(e, "days").add(e, "minutes");
|
|
7760
|
-
const len2 = Math.floor(Math.random() * 25) + 1;
|
|
7761
|
-
return {
|
|
7762
|
-
id: crypto.randomUUID(),
|
|
7763
|
-
rowId: resourceId.toString(),
|
|
7764
|
-
name: "API Design",
|
|
7765
|
-
color: getRandomColor(),
|
|
7766
|
-
startDate: moment1.add(-len1, "hour").toDate(),
|
|
7767
|
-
endDate: moment1.add(len2, "hour").toDate(),
|
|
7768
|
-
};
|
|
7769
|
-
});
|
|
7770
|
-
};
|
|
7771
|
-
|
|
7772
|
-
const eventToUiState = (it, selectedDate, visibleDays, tooltip) => {
|
|
7773
|
-
const { left, width } = getEventSizes(selectedDate, visibleDays, it.startDate, it.endDate);
|
|
7774
|
-
const eventState = {
|
|
7775
|
-
...it,
|
|
7776
|
-
left,
|
|
7777
|
-
width,
|
|
7778
|
-
tooltip: tooltip,
|
|
7779
|
-
selected: false,
|
|
7780
|
-
isResizable: false,
|
|
7781
|
-
isDraggable: false,
|
|
7782
|
-
};
|
|
7783
|
-
return eventState;
|
|
7784
|
-
};
|
|
7785
|
-
const SchedulerPresenter = () => {
|
|
7786
|
-
const [events, setEvents] = useState([]);
|
|
7787
|
-
const [backgroundEvents, setBackgroundEvents] = useState([]);
|
|
7788
|
-
const [uiState, setUiState] = useState(() => {
|
|
7789
|
-
const visibleDays = 1;
|
|
7790
|
-
const selectedDate = new Date("2024-12-03");
|
|
7791
|
-
const isHeaderVisible = true;
|
|
7792
|
-
return {
|
|
7793
|
-
isUtc: false,
|
|
7794
|
-
selectedDate: selectedDate,
|
|
7795
|
-
isHeaderVisible: isHeaderVisible,
|
|
7796
|
-
visibleDays: visibleDays,
|
|
7797
|
-
rowsHeight: 2,
|
|
7798
|
-
visibleRows: 8,
|
|
7799
|
-
};
|
|
7800
|
-
});
|
|
7801
|
-
const [resources, setResources] = useState([]);
|
|
7802
|
-
const selectedEventRef = useRef("");
|
|
7803
|
-
useEffect(() => {
|
|
7804
|
-
updateDataFromApi();
|
|
7805
|
-
}, []);
|
|
7806
|
-
const updateDataFromApi = () => {
|
|
7807
|
-
const rows = 1;
|
|
7808
|
-
// api call here to events
|
|
7809
|
-
const apiEvents = getListOfNumbers(rows).flatMap((e) => {
|
|
7810
|
-
return getRandomEvents(uiState.selectedDate, uiState.visibleDays * 3, e);
|
|
7811
|
-
});
|
|
7812
|
-
const eventsWithSizes = apiEvents.map((it) => {
|
|
7813
|
-
return eventToUiState(it, uiState.selectedDate, uiState.visibleDays, jsxs("div", { children: [it.startDate.getHours() + ":" + it.startDate.getMinutes(), " -", it.endDate.getHours() + ":" + it.endDate.getMinutes()] }));
|
|
7814
|
-
});
|
|
7815
|
-
const visibleEvents = eventsWithSizes.filter((event) => {
|
|
7816
|
-
return eventIsVisible(event.startDate, event.endDate, uiState.selectedDate, uiState.visibleDays);
|
|
7817
|
-
});
|
|
7818
|
-
setEvents(visibleEvents);
|
|
7819
|
-
const apiBackgroundEvents = getListOfNumbers(1).map((e) => {
|
|
7820
|
-
const backgroundEvent = {
|
|
7821
|
-
id: e.toString(),
|
|
7822
|
-
rowId: e.toString(),
|
|
7823
|
-
color: "orange",
|
|
7824
|
-
isResizable: false,
|
|
7825
|
-
isDraggable: false,
|
|
7826
|
-
width: 100 / uiState.visibleDays,
|
|
7827
|
-
name: "Birthday",
|
|
7828
|
-
icons: jsx(CwIcon, { iconId: "house", style: { padding: "0.5rem" } }, "cosa"),
|
|
7829
|
-
startDate: new Date(),
|
|
7830
|
-
left: 0,
|
|
7831
|
-
endDate: new Date(),
|
|
7832
|
-
isVisible: true,
|
|
7833
|
-
selected: false,
|
|
7834
|
-
};
|
|
7835
|
-
return backgroundEvent;
|
|
7836
|
-
});
|
|
7837
|
-
setBackgroundEvents(apiBackgroundEvents);
|
|
7838
|
-
// api call here to rows
|
|
7839
|
-
const apiRows = getListOfNumbers(rows).map((e) => {
|
|
7840
|
-
return {
|
|
7841
|
-
resourceId: e.toString(),
|
|
7842
|
-
title: "JAC" + e,
|
|
7843
|
-
};
|
|
7844
|
-
});
|
|
7845
|
-
const headerProps = apiRows.map((row) => {
|
|
7846
|
-
return {
|
|
7847
|
-
rowId: row.resourceId,
|
|
7848
|
-
title: row.title,
|
|
7849
|
-
};
|
|
7850
|
-
});
|
|
7851
|
-
setResources(headerProps);
|
|
7852
|
-
};
|
|
7853
|
-
const onEvent = (event) => {
|
|
7854
|
-
when(event)
|
|
7855
|
-
.case(OnClickEvent, (event) => {
|
|
7856
|
-
console.log("onClick event: " + event.id);
|
|
7857
|
-
})
|
|
7858
|
-
.case(OnDoubleClickEvent, (event) => {
|
|
7859
|
-
const eventData = resources
|
|
7860
|
-
.map((resource) => {
|
|
7861
|
-
const element = events
|
|
7862
|
-
.filter((it) => {
|
|
7863
|
-
return it.rowId === resource.rowId;
|
|
7864
|
-
})
|
|
7865
|
-
.find((it) => it.id == event.id);
|
|
7866
|
-
return element;
|
|
7867
|
-
})
|
|
7868
|
-
.filter((it) => it !== undefined)[0];
|
|
7869
|
-
console.log("found", eventData?.startDate, eventData?.endDate);
|
|
7870
|
-
})
|
|
7871
|
-
.case(OnDragEvent, (event) => {
|
|
7872
|
-
console.log("onDrag event: " + event.id);
|
|
7873
|
-
selectedEventRef.current = event.id;
|
|
7874
|
-
console.log("selectedEvent set to: " + selectedEventRef.current);
|
|
7875
|
-
})
|
|
7876
|
-
.case(OnDropEvent, (event) => {
|
|
7877
|
-
console.log("onDrop event: " + selectedEventRef.current + " to row: " + event.id);
|
|
7878
|
-
setEvents((prevEvents) => {
|
|
7879
|
-
// Find the index of the event to be updated
|
|
7880
|
-
const eventIndex = prevEvents.findIndex((e) => e.id === selectedEventRef.current);
|
|
7881
|
-
// If event is found, create a new array with the updated event
|
|
7882
|
-
const updatedEvents = [...prevEvents];
|
|
7883
|
-
updatedEvents[eventIndex] = {
|
|
7884
|
-
...updatedEvents[eventIndex],
|
|
7885
|
-
rowId: event.id,
|
|
7886
|
-
};
|
|
7887
|
-
return updatedEvents;
|
|
7888
|
-
});
|
|
7889
|
-
console.log("drop on");
|
|
7890
|
-
selectedEventRef.current = ""; // Reset the selected event ref
|
|
7891
|
-
})
|
|
7892
|
-
.case(OnDropCtrlEvent, (event) => {
|
|
7893
|
-
alert(`Clicked row is ${event.id}`);
|
|
7894
|
-
})
|
|
7895
|
-
.case(OnClickRowEvent, (event) => {
|
|
7896
|
-
alert(`Clicked row is ${event.id}`);
|
|
7897
|
-
})
|
|
7898
|
-
.case(OnRightClickEvent, (event) => {
|
|
7899
|
-
alert(`RightClick event ${event.id}`);
|
|
7900
|
-
})
|
|
7901
|
-
.case(OnRightClickRow, (event) => {
|
|
7902
|
-
alert(`RightClick row ${event.id}`);
|
|
7903
|
-
})
|
|
7904
|
-
.case(OnLeftDragStart, (event) => {
|
|
7905
|
-
alert(`Start left Drag ${event.id}`);
|
|
7906
|
-
})
|
|
7907
|
-
.case(OnRightDragStart, (event) => {
|
|
7908
|
-
alert(`Start Right Drag ${event.id}`);
|
|
7909
|
-
})
|
|
7910
|
-
.case(UpdateApi, () => {
|
|
7911
|
-
updateDataFromApi();
|
|
7912
|
-
})
|
|
7913
|
-
.case(OnClickRowHeader, (event) => {
|
|
7914
|
-
console.log(`Clicked row ${event.id}`);
|
|
7915
|
-
})
|
|
7916
|
-
.case(OnClickUtc, () => {
|
|
7917
|
-
setUiState((old) => {
|
|
7918
|
-
return { ...old, isUtc: !old.isUtc };
|
|
7919
|
-
});
|
|
7920
|
-
});
|
|
7921
|
-
};
|
|
7922
|
-
return {
|
|
7923
|
-
state: uiState,
|
|
7924
|
-
resources: resources,
|
|
7925
|
-
events,
|
|
7926
|
-
backgroundEvents,
|
|
7927
|
-
onEvent: onEvent,
|
|
7928
|
-
};
|
|
7929
|
-
};
|
|
7930
8536
|
|
|
7931
8537
|
const getNow = (isUtc) => {
|
|
7932
8538
|
let now = new Date();
|
|
@@ -7936,6 +8542,8 @@ const getNow = (isUtc) => {
|
|
|
7936
8542
|
return now;
|
|
7937
8543
|
};
|
|
7938
8544
|
const rowsHeight = 1.75; // rem
|
|
8545
|
+
const milliSecondsInSecond = 1000;
|
|
8546
|
+
const refreshMilliSeconds = 45 * milliSecondsInSecond;
|
|
7939
8547
|
const Scheduler = (props) => {
|
|
7940
8548
|
const { header: headerContent, id, events: eventsState, backgroundEvents, contextMenuItems, EventComp, RowTitleComp, orderCategories = ["title"], useOrderCategory, onEvent, groupRowColors, rowHeaderWidth = 180, } = props;
|
|
7941
8549
|
const BackgroundEventComp = props.BackgroundEventComp ?? BackgroundEvent;
|
|
@@ -7979,7 +8587,7 @@ const Scheduler = (props) => {
|
|
|
7979
8587
|
setTimeLinePercentage(percentage);
|
|
7980
8588
|
};
|
|
7981
8589
|
updateTimeLinePercentage();
|
|
7982
|
-
const interval = setInterval(updateTimeLinePercentage,
|
|
8590
|
+
const interval = setInterval(updateTimeLinePercentage, refreshMilliSeconds);
|
|
7983
8591
|
return () => clearInterval(interval);
|
|
7984
8592
|
}, [selectedDate, isUtc, totalHours]);
|
|
7985
8593
|
// Memoized Row Component
|
|
@@ -8027,10 +8635,6 @@ const height = (events, rows, rowsNumber) => {
|
|
|
8027
8635
|
});
|
|
8028
8636
|
return flatMapped.length;
|
|
8029
8637
|
};
|
|
8030
|
-
const SchedulerPreview = () => {
|
|
8031
|
-
const { state, resources, events, backgroundEvents, onEvent } = SchedulerPresenter();
|
|
8032
|
-
return (jsxs("div", { children: [jsx("button", { onClick: (_) => onEvent(new UpdateApi()), children: "update" }), jsx("button", { onClick: (_) => onEvent(new OnClickUtc()), children: state.isUtc ? "set Local" : "set UTC" }), jsx(Scheduler, { id: "test", state: state, header: { title: "Flights", classification: "ACFT" }, rows: resources, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: DefaultRowHeader, events: events, backgroundEvents: backgroundEvents, contextMenuItems: [] })] }));
|
|
8033
|
-
};
|
|
8034
8638
|
|
|
8035
8639
|
let topsCounter = 0;
|
|
8036
8640
|
class CwSuperScheduler extends React.Component {
|
|
@@ -8351,6 +8955,8 @@ class Resource {
|
|
|
8351
8955
|
}
|
|
8352
8956
|
}
|
|
8353
8957
|
|
|
8958
|
+
var styles = {"super-scheduler-row-header":"super-scheduler-module_super-scheduler-row-header__TTs4e","indicators":"super-scheduler-module_indicators__f4lIT","scheduler-crewmember-functions":"super-scheduler-module_scheduler-crewmember-functions__BS2hs"};
|
|
8959
|
+
|
|
8354
8960
|
class OnPinRow {
|
|
8355
8961
|
id;
|
|
8356
8962
|
constructor(id) {
|
|
@@ -8367,26 +8973,12 @@ class OnClearPinned {
|
|
|
8367
8973
|
constructor() { }
|
|
8368
8974
|
}
|
|
8369
8975
|
|
|
8370
|
-
const onClickMenuItem = (e, event) => {
|
|
8371
|
-
e.domEvent.nativeEvent.preventDefault();
|
|
8372
|
-
e.domEvent.nativeEvent.stopPropagation();
|
|
8373
|
-
e.domEvent.nativeEvent.stopImmediatePropagation();
|
|
8374
|
-
e.domEvent.preventDefault();
|
|
8375
|
-
e.domEvent.stopPropagation();
|
|
8376
|
-
event();
|
|
8377
|
-
};
|
|
8378
8976
|
const PinRowHeader = ({ value, width, onEvent }) => {
|
|
8379
8977
|
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
|
8380
8978
|
const { highlightColor, isLoading } = value;
|
|
8381
|
-
return (jsx(
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
onClickMenuItem(e, () => {
|
|
8385
|
-
onEvent(new OnClickContextMenu(value.rowId, e.key));
|
|
8386
|
-
});
|
|
8387
|
-
},
|
|
8388
|
-
onMouseLeave: () => setIsContextMenuOpen(false),
|
|
8389
|
-
}, trigger: ["contextMenu"], overlayStyle: { animationDuration: "0" }, arrow: (value.contextMenuItems?.length ?? 0) > 0, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "right", dissapearsWhenHover: true, overlayStyle: value.overlayTooltipStyle, children: jsxs("div", { style: {
|
|
8979
|
+
return (jsx(CwAnchoredMenu, { open: isContextMenuOpen, onOpenChange: setIsContextMenuOpen, placement: "right", options: value.contextMenuItems ?? [], onSelect: (key) => {
|
|
8980
|
+
onEvent(new OnClickContextMenu(value.rowId, key));
|
|
8981
|
+
}, children: jsx(CwGenericTooltip, { content: value.tooltip, position: "right", dissapearsWhenHover: true, overlayStyle: value.overlayTooltipStyle, children: jsxs("div", { style: {
|
|
8390
8982
|
width: width,
|
|
8391
8983
|
background: highlightColor,
|
|
8392
8984
|
}, className: styles["super-scheduler-row-header"], children: [jsx("button", { className: "cw-button-icon cwi-pin", "data-pinned": value.isPinned, onClick: (_) => {
|
|
@@ -8409,7 +9001,7 @@ const SuperScheduler = ({ id, state, header, rows, events, pinnedOrderCategory,
|
|
|
8409
9001
|
}, children: "Clear pinned" }) })] })), jsx(Scheduler, { id: `${id}-notPinned`, state: { ...state, isHeaderVisible: !isFirstVisible }, header: header, rows: notPinnedRows, events: events, backgroundEvents: backgroundEvents, contextMenuItems: contextMenuItems, orderCategories: unPinnedOrderCategory, onEvent: onEvent, EventComp: SchedulerEvent, RowTitleComp: PinRowHeader })] }));
|
|
8410
9002
|
};
|
|
8411
9003
|
|
|
8412
|
-
const CwFindAirport = ({ handleChange, searchType = "OnlyDatabase", placeHolder = "Search airport…", required = false, cblConfig, className = "", value, disabled = false, displayMode, width }) => {
|
|
9004
|
+
const CwFindAirport = ({ handleChange, searchType = "OnlyDatabase", placeHolder = "Search airport…", required = false, cblConfig, className = "", value, disabled = false, displayMode, labelProps, alignProps, width }) => {
|
|
8413
9005
|
// State
|
|
8414
9006
|
const [inputValue, setInputValue] = useState("");
|
|
8415
9007
|
const [options, setOptions] = useState([]);
|
|
@@ -8642,44 +9234,12 @@ const CwFindAirport = ({ handleChange, searchType = "OnlyDatabase", placeHolder
|
|
|
8642
9234
|
handleChange(0); // or -1, depending on API expectations
|
|
8643
9235
|
inputRef.current?.focus();
|
|
8644
9236
|
};
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
subtitle: "ICAO",
|
|
8655
|
-
subtitle2: "IATA"
|
|
8656
|
-
},
|
|
8657
|
-
// color={"red"}
|
|
8658
|
-
width: 180, onEvent: () => {
|
|
8659
|
-
} }) }) }), jsxs(Component$1, { name: "PinRowHeader", children: [jsx(Variant, { children: jsx(PinRowHeader, { value: {
|
|
8660
|
-
rowId: "1",
|
|
8661
|
-
title: "JAC",
|
|
8662
|
-
title2: "CMD",
|
|
8663
|
-
subtitle: "ICAO",
|
|
8664
|
-
subtitle2: "IATA",
|
|
8665
|
-
isPinned: true,
|
|
8666
|
-
contextMenuItems: [],
|
|
8667
|
-
isLoading: false,
|
|
8668
|
-
},
|
|
8669
|
-
// color={"red"}
|
|
8670
|
-
width: 180, onEvent: () => {
|
|
8671
|
-
} }) }), jsx(Variant, { name: "pinned", children: jsx(PinRowHeader, { value: {
|
|
8672
|
-
rowId: "1",
|
|
8673
|
-
title: "JAC",
|
|
8674
|
-
title2: "CMD",
|
|
8675
|
-
subtitle: "ICAO",
|
|
8676
|
-
subtitle2: "IATA",
|
|
8677
|
-
isPinned: true,
|
|
8678
|
-
contextMenuItems: [],
|
|
8679
|
-
isLoading: false,
|
|
8680
|
-
},
|
|
8681
|
-
// color={"red"}
|
|
8682
|
-
width: 180, onEvent: () => {
|
|
8683
|
-
} }) })] })] }), jsx(Category, { name: "Scheduler", children: jsx(Component$1, { name: "Scheduler", children: jsx(Variant, { children: jsx(SchedulerPreview, {}) }) }) })] }));
|
|
8684
|
-
|
|
8685
|
-
export { CblDragAndDrop, CwAccordionContainer, CwAlign, CwBtnAdd, CwBtnAddFolder, CwBtnAirport, CwBtnAlert, CwBtnApprove, CwBtnBookMark, CwBtnBulkDuty, CwBtnCancel, CwBtnCrewPlanning, CwBtnDelay, CwBtnDelete, CwBtnDownLoadAllInfo, CwBtnDownload, CwBtnDropDownMenu, CwBtnEdit, CwBtnEditFolder, CwBtnFiles, CwBtnGeneratePairing, CwBtnGoBackFolder, CwBtnHide, CwBtnImportRequests, CwBtnMVT, CwBtnNavFirstItemView, CwBtnNavLastItemView, CwBtnNavNextDay, CwBtnNavPreviewItem, CwBtnPairing, CwBtnPrint, CwBtnPropertyFolder, CwBtnPublish, CwBtnRefresh, CwBtnReleasePeriod, CwBtnSave, CwBtnSearch, CwBtnSelect, CwBtnShare, CwBtnStatistic, CwBtnUploadFiles, CwBtnVacations, CwBtnView, CwButton, CwButtonDef, CwCard, CwCardList, CwCheckbox, CwChip, CwColorPicker, CwConfirmationPopup, CwContextMenu, CwContextualMenu, CwDialog, CwDialogManager, CwDigit, CwDisplayMessage, CwDropdown, CwDropdownContainer, CwDropdownFilter, CwExpandable, CwFileUpload, CwFileUploadMultiple, CwFindAirport, CwFloatingButton, CwGenericTooltip, CwHeadFilter, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwImageGallery, CwImageZoom, CwInput, CwInputColor, CwInputDate, CwInputDatePicker, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwKeyValueList, CwLabel, CwLoading, CwLoadingSmall, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalConfirm, CwModalHover, CwModalIframe, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwMultiselect, CwNote, CwOption, CwOptionList, CwPaletteTree, CwReportModal, CwScheduler, CwScheduler2, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSortableList, CwSuperScheduler, CwTable, CwTableGrouped, CwTabs, CwTag, CwTextArea, CwTime, CwToggle, CwTooltip, CwTreeView, CwWeekdaySelector, DefaultRowHeader, MultiSelect, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PinRowHeader, Resource, Scheduler, SchedulerEvent, SuperScheduler, UiEvent, Weekdays, cblEvent, eventIsVisible, getDefaultDivisions, getEventSizes, itemsToMultiFilterTags, useCwMessage, useSortableList };
|
|
9237
|
+
// Get direction for data attribute
|
|
9238
|
+
const direction = alignProps?.flexDirection || "row";
|
|
9239
|
+
return (jsxs("div", { className: `cw-search-input ${className}`, style: {
|
|
9240
|
+
...(width ? { width } : {}),
|
|
9241
|
+
...(labelProps?.labelWidth ? { '--label-width': labelProps.labelWidth } : {})
|
|
9242
|
+
}, "data-direction": direction, children: [jsxs(CwAlign, { ...alignProps, itemProp: required ? "required" : "", children: [labelProps && (jsx(CwLabel, { ...labelProps, children: labelProps.text })), jsxs("div", { className: "cw-search-input-wrapper", children: [jsx("input", { ref: inputRef, type: "text", value: inputValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onFocus: handleInputFocus, placeholder: isInitialLoading ? "Loading…" : placeHolder, disabled: disabled, required: required, autoComplete: "off", "aria-expanded": showDropdown, "aria-haspopup": "listbox", role: "combobox", title: tooltipText }), (isLoading || isInitialLoading) && (jsx("div", { className: "cw-search-input-loading", children: jsx(CwIcon, { iconId: "spinner" }) })), jsx("div", { className: "cw-search-input-icons", children: inputValue && !disabled && !isInitialLoading ? (jsx(CwButton, { type: "button", onClick: handleClear, "aria-label": "Clear selected airport", variant: "icon", icon: "close", color: "neutral" })) : (jsx(CwIcon, { iconId: "control-tower" })) })] })] }), showDropdown && options.length > 0 && (jsx("div", { ref: dropdownRef, className: "cw-input-search-dropdown", role: "listbox", children: jsx("ul", { children: options.map((option, index) => (jsx("li", { className: index === highlightedIndex ? "highlighted" : "", onClick: () => handleOptionSelect(option.value), onMouseDown: (e) => e.preventDefault(), role: "option", "aria-selected": index === highlightedIndex, children: option.text }, option.value))) }) }))] }));
|
|
9243
|
+
};
|
|
9244
|
+
|
|
9245
|
+
export { CblDragAndDrop, CwAccordionContainer, CwAlign, CwAnchoredMenu, CwBtnDelete, CwBtnEdit, CwBtnSave, CwButton, CwCard, CwCardList, CwCheckbox, CwChip, CwColorPicker, CwConfirmationPopup, CwContextMenu, CwDatePicker, CwDateRangePicker, CwDateTimePicker, CwDateTimePickerCompact, CwDialog, CwDialogManager, CwDigit, CwDisplayMessage, CwDropdownFilter, CwExpandable, CwFileUpload, CwFileUploadMultiple, CwFindAirport, CwGenericTooltip, CwHeadingMain, CwHeadingSecond, CwIcon, CwImageArea, CwImageGallery, CwImageZoom, CwInput, CwInputColor, CwInputDate, CwInputDatePicker, CwInputDateText, CwInputDatetime, CwInputImage, CwInputNumber, CwInputPhone, CwInputText, CwKeyValueList, CwLabel, CwLoading, CwLoadingSmall, CwMessage, CwMessageManager, CwMessageType, CwModal, CwModalHover, CwModalReportFunctional, CwMultiFilter, CwMultiFilterTag, CwNote, CwOption, CwReportModal, CwScheduler, CwScheduler2, CwSearchInput, CwSelect, CwSelectList, CwSelectListItems, CwSortableList, CwSuperScheduler, CwTable, CwTableGrouped, CwTabs, CwTextArea, CwTime, CwTimePicker, CwToggle, CwTooltip, CwTreeView, CwWeekdaySelector, DefaultRowHeader, OnClearPinned, OnClickContextMenu, OnClickEvent, OnClickRowEvent, OnClickRowHeader, OnClickUtc, OnDoubleClickEvent, OnDoubleClickRowEvent, OnDragEvent, OnDropCtrlEvent, OnDropEvent, OnEndClickHeaderEvent, OnLeftDragStart, OnMultiClickEvent, OnPinRow, OnRangeClickEvent, OnRightClickEvent, OnRightClickRow, OnRightDragStart, OnStartClickHeaderEvent, OnUnpinRow, PinRowHeader, Resource, Scheduler, SchedulerEvent, SuperScheduler, UiEvent, Weekdays, cblEvent, eventIsVisible, getDefaultDivisions, getEventSizes, itemsToMultiFilterTags, useCwMessage, useSortableList };
|