@turnit-ou/shared 0.0.0-stage → 2.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/@mui/index.d.ts +125 -0
- package/@types/axios/index.d.ts +7 -0
- package/@types/openapi-client-axios/index.d.ts +5 -0
- package/@types/openapi-typescript/index.d.ts +71 -0
- package/@types/react-final-form-arrays/index.d.ts +75 -0
- package/@types/react-table/index.d.ts +292 -0
- package/components/Alert/AlertTemplate.d.ts +3 -0
- package/components/Alert/AlertTemplate.js +66 -0
- package/components/Alert/index.d.ts +4 -0
- package/components/Alert/index.js +17 -0
- package/components/ConfirmButton.d.ts +15 -0
- package/components/ConfirmButton.js +47 -0
- package/components/Drawer.d.ts +4 -0
- package/components/Drawer.js +24 -0
- package/components/DrawerForm/DrawerFormCardActions.d.ts +5 -0
- package/components/DrawerForm/DrawerFormCardActions.js +21 -0
- package/components/DrawerForm/DrawerFormCloseButton.d.ts +3 -0
- package/components/DrawerForm/DrawerFormCloseButton.js +5 -0
- package/components/DrawerForm/DrawerFormContext.d.ts +7 -0
- package/components/DrawerForm/DrawerFormContext.js +4 -0
- package/components/DrawerForm.d.ts +10 -0
- package/components/DrawerForm.js +89 -0
- package/components/Editor/Editor.d.ts +9 -0
- package/components/Editor/Editor.js +36 -0
- package/components/Editor/Toolbar.d.ts +7 -0
- package/components/Editor/Toolbar.js +31 -0
- package/components/Editor/buttons/FormatLinkButton.d.ts +5 -0
- package/components/Editor/buttons/FormatLinkButton.js +64 -0
- package/components/Editor/buttons/InsertImageButton.d.ts +5 -0
- package/components/Editor/buttons/InsertImageButton.js +59 -0
- package/components/Editor/buttons.d.ts +15 -0
- package/components/Editor/buttons.js +70 -0
- package/components/Editor/createButton.d.ts +28 -0
- package/components/Editor/createButton.js +68 -0
- package/components/Editor/editor.scss +45 -0
- package/components/Ellipsis.d.ts +9 -0
- package/components/Ellipsis.js +22 -0
- package/components/EllipsisText.d.ts +8 -0
- package/components/EllipsisText.js +25 -0
- package/components/EnvironmentBanner.d.ts +8 -0
- package/components/EnvironmentBanner.js +25 -0
- package/components/Header/AccessibilityModal.d.ts +5 -0
- package/components/Header/AccessibilityModal.js +28 -0
- package/components/Header/AllowedBusinessEntityModal.d.ts +9 -0
- package/components/Header/AllowedBusinessEntityModal.js +24 -0
- package/components/Header/LanguageSelect.d.ts +2 -0
- package/components/Header/LanguageSelect.js +80 -0
- package/components/Header/MenuItems.d.ts +9 -0
- package/components/Header/MenuItems.js +55 -0
- package/components/Header/ModuleIcon.d.ts +7 -0
- package/components/Header/ModuleIcon.js +119 -0
- package/components/Header/index.d.ts +44 -0
- package/components/Header/index.js +89 -0
- package/components/Layout/LayoutCol.d.ts +8 -0
- package/components/Layout/LayoutCol.js +26 -0
- package/components/Layout/index.d.ts +32 -0
- package/components/Layout/index.js +56 -0
- package/components/Loadable.d.ts +11 -0
- package/components/Loadable.js +3 -0
- package/components/SearchCard.d.ts +8 -0
- package/components/SearchCard.js +81 -0
- package/components/SearchForm.d.ts +14 -0
- package/components/SearchForm.js +51 -0
- package/components/SearchFormTable.d.ts +8 -0
- package/components/SearchFormTable.js +32 -0
- package/components/SearchResult.d.ts +13 -0
- package/components/SearchResult.js +67 -0
- package/components/Table/TableCaption.d.ts +6 -0
- package/components/Table/TableCaption.js +25 -0
- package/components/Table/TableCell.d.ts +17 -0
- package/components/Table/TableCell.js +45 -0
- package/components/Table/TableCellEditable.d.ts +28 -0
- package/components/Table/TableCellEditable.js +151 -0
- package/components/Table/TableCellEditableAction.d.ts +13 -0
- package/components/Table/TableCellEditableAction.js +70 -0
- package/components/Table/TableCellEditableField.d.ts +17 -0
- package/components/Table/TableCellEditableField.js +1 -0
- package/components/Table/TableCellEditableTimeDuration.d.ts +13 -0
- package/components/Table/TableCellEditableTimeDuration.js +12 -0
- package/components/Table/TableContext.d.ts +11 -0
- package/components/Table/TableContext.js +4 -0
- package/components/Table/TablePagination.d.ts +5 -0
- package/components/Table/TablePagination.js +84 -0
- package/components/Table.d.ts +53 -0
- package/components/Table.js +389 -0
- package/components/Version.d.ts +5 -0
- package/components/Version.js +23 -0
- package/dto/businessEntity.d.ts +15 -0
- package/dto/businessEntity.js +1 -0
- package/dto/classification.d.ts +9 -0
- package/dto/classification.js +1 -0
- package/dto/classifier.d.ts +13 -0
- package/dto/classifier.js +4 -0
- package/dto/common.d.ts +5 -0
- package/dto/common.js +1 -0
- package/dto/fare.d.ts +11 -0
- package/dto/fare.js +1 -0
- package/dto/line-network.d.ts +23 -0
- package/dto/line-network.js +1 -0
- package/dto/option.d.ts +7 -0
- package/dto/option.js +1 -0
- package/dto/pagination.d.ts +10 -0
- package/dto/pagination.js +1 -0
- package/fields/FormCheckbox.d.ts +11 -0
- package/fields/FormCheckbox.js +5 -0
- package/fields/FormCheckboxGroup.d.ts +6 -0
- package/fields/FormCheckboxGroup.js +20 -0
- package/fields/FormController.d.ts +7 -0
- package/fields/FormController.js +16 -0
- package/fields/FormDatepicker.d.ts +8 -0
- package/fields/FormDatepicker.js +7 -0
- package/fields/FormInput.d.ts +8 -0
- package/fields/FormInput.js +4 -0
- package/fields/FormRadioGroup.d.ts +10 -0
- package/fields/FormRadioGroup.js +6 -0
- package/fields/FormSelect.d.ts +11 -0
- package/fields/FormSelect.js +9 -0
- package/fields/FormSwitch.d.ts +11 -0
- package/fields/FormSwitch.js +5 -0
- package/fields/FormTimeZoneSelect.d.ts +4 -0
- package/fields/FormTimeZoneSelect.js +8 -0
- package/fields/index.d.ts +9 -0
- package/fields/index.js +9 -0
- package/form/ArrayField.d.ts +27 -0
- package/form/ArrayField.js +69 -0
- package/form/CheckboxField.d.ts +8 -0
- package/form/CheckboxField.js +14 -0
- package/form/CheckboxGroupField.d.ts +6 -0
- package/form/CheckboxGroupField.js +15 -0
- package/form/ConditionField.d.ts +7 -0
- package/form/ConditionField.js +20 -0
- package/form/ContentField.d.ts +7 -0
- package/form/ContentField.js +15 -0
- package/form/CounterField.d.ts +5 -0
- package/form/CounterField.js +7 -0
- package/form/DateField.d.ts +8 -0
- package/form/DateField.js +52 -0
- package/form/DatesArrayField.d.ts +8 -0
- package/form/DatesArrayField.js +79 -0
- package/form/DependSelectField.d.ts +8 -0
- package/form/DependSelectField.js +12 -0
- package/form/EditorField.d.ts +5 -0
- package/form/EditorField.js +7 -0
- package/form/FileField.d.ts +12 -0
- package/form/FileField.js +9 -0
- package/form/FormField.d.ts +15 -0
- package/form/FormField.js +22 -0
- package/form/ModalFieldArray.d.ts +13 -0
- package/form/ModalFieldArray.js +62 -0
- package/form/PeriodField.d.ts +24 -0
- package/form/PeriodField.js +111 -0
- package/form/RadioGroupField.d.ts +10 -0
- package/form/RadioGroupField.js +21 -0
- package/form/SearchField.d.ts +19 -0
- package/form/SearchField.js +51 -0
- package/form/SelectField.d.ts +8 -0
- package/form/SelectField.js +13 -0
- package/form/SelectOwnerField.d.ts +11 -0
- package/form/SelectOwnerField.js +11 -0
- package/form/StopsSelect/StopSelectWithSearch.d.ts +28 -0
- package/form/StopsSelect/StopSelectWithSearch.js +181 -0
- package/form/StopsSelect/StopsSelect.d.ts +19 -0
- package/form/StopsSelect/StopsSelect.js +65 -0
- package/form/StopsSelect/StopsSelectModal.d.ts +26 -0
- package/form/StopsSelect/StopsSelectModal.js +280 -0
- package/form/StopsSelect/StopsSelectSearchForm.d.ts +22 -0
- package/form/StopsSelect/StopsSelectSearchForm.js +43 -0
- package/form/SwitchField.d.ts +9 -0
- package/form/SwitchField.js +16 -0
- package/form/TextField.d.ts +6 -0
- package/form/TextField.js +21 -0
- package/form/TimeDurationField.d.ts +6 -0
- package/form/TimeDurationField.js +54 -0
- package/form/TimeZoneField.d.ts +6 -0
- package/form/TimeZoneField.js +8 -0
- package/form/ToggleButtonGroupField.d.ts +12 -0
- package/form/ToggleButtonGroupField.js +16 -0
- package/form/hooks/addLazyFieldMetaState.d.ts +3 -0
- package/form/hooks/addLazyFieldMetaState.js +55 -0
- package/form/hooks/getValue.d.ts +3 -0
- package/form/hooks/getValue.js +60 -0
- package/form/hooks/useConstant.d.ts +13 -0
- package/form/hooks/useConstant.js +20 -0
- package/form/hooks/useConstantCallback.d.ts +7 -0
- package/form/hooks/useConstantCallback.js +14 -0
- package/form/hooks/useField.d.ts +3 -0
- package/form/hooks/useField.js +175 -0
- package/form/hooks/useFieldArray.d.ts +6 -0
- package/form/hooks/useFieldArray.js +87 -0
- package/form/hooks/useLatest.d.ts +3 -0
- package/form/hooks/useLatest.js +8 -0
- package/form/hooks/useModalTableSelectedRows.d.ts +12 -0
- package/form/hooks/useModalTableSelectedRows.js +66 -0
- package/form/hooks/useWatch.d.ts +12 -0
- package/form/hooks/useWatch.js +16 -0
- package/form/index.d.ts +45 -0
- package/form/index.js +58 -0
- package/form/mutators/change.d.ts +2 -0
- package/form/mutators/change.js +9 -0
- package/form/validate.d.ts +14 -0
- package/form/validate.js +39 -0
- package/helpers/capitalize.d.ts +1 -0
- package/helpers/capitalize.js +1 -0
- package/helpers/filter.d.ts +4 -0
- package/helpers/filter.js +21 -0
- package/helpers/formSubmit.d.ts +5 -0
- package/helpers/formSubmit.js +21 -0
- package/helpers/index.d.ts +7 -0
- package/helpers/index.js +7 -0
- package/helpers/makeClassificationOptions.d.ts +30 -0
- package/helpers/makeClassificationOptions.js +29 -0
- package/helpers/map.d.ts +1 -0
- package/helpers/map.js +1 -0
- package/helpers/openapi.d.ts +10 -0
- package/helpers/openapi.js +10 -0
- package/helpers/renderRangeError.d.ts +1 -0
- package/helpers/renderRangeError.js +20 -0
- package/helpers/sentry/assertEnvVariable.d.ts +1 -0
- package/helpers/sentry/assertEnvVariable.js +7 -0
- package/helpers/sentry/sentryConfig.d.ts +2 -0
- package/helpers/sentry/sentryConfig.js +18 -0
- package/helpers/serializeErrors.d.ts +2 -0
- package/helpers/serializeErrors.js +13 -0
- package/hooks/index.d.ts +26 -0
- package/hooks/index.js +26 -0
- package/hooks/useAllowedBusinessEntities.d.ts +4 -0
- package/hooks/useAllowedBusinessEntities.js +9 -0
- package/hooks/useBusinessEntitiesByType.d.ts +8 -0
- package/hooks/useBusinessEntitiesByType.js +17 -0
- package/hooks/useChangePassword.d.ts +14 -0
- package/hooks/useChangePassword.js +48 -0
- package/hooks/useClassification.d.ts +9 -0
- package/hooks/useClassification.js +16 -0
- package/hooks/useDraggable.d.ts +5 -0
- package/hooks/useDraggable.js +11 -0
- package/hooks/useEllipsis.d.ts +10 -0
- package/hooks/useEllipsis.js +79 -0
- package/hooks/useFavicon.d.ts +1 -0
- package/hooks/useFavicon.js +13 -0
- package/hooks/useFormTable.d.ts +24 -0
- package/hooks/useFormTable.js +105 -0
- package/hooks/useFormTableControls.d.ts +31 -0
- package/hooks/useFormTableControls.js +34 -0
- package/hooks/useInertBackground.d.ts +20 -0
- package/hooks/useInertBackground.js +57 -0
- package/hooks/useIsMounted.d.ts +2 -0
- package/hooks/useIsMounted.js +11 -0
- package/hooks/useLanguage.d.ts +1 -0
- package/hooks/useLanguage.js +2 -0
- package/hooks/useLoaded.d.ts +1 -0
- package/hooks/useLoaded.js +19 -0
- package/hooks/useLocale.d.ts +1 -0
- package/hooks/useLocale.js +7 -0
- package/hooks/useModal.d.ts +307 -0
- package/hooks/useModal.js +12 -0
- package/hooks/useOptions.d.ts +13 -0
- package/hooks/useOptions.js +24 -0
- package/hooks/usePrevious.d.ts +1 -0
- package/hooks/usePrevious.js +12 -0
- package/hooks/usePrompt.d.ts +8 -0
- package/hooks/usePrompt.js +17 -0
- package/hooks/useRowActive.d.ts +6 -0
- package/hooks/useRowActive.js +104 -0
- package/hooks/useRowEditActions.d.ts +5 -0
- package/hooks/useRowEditActions.js +12 -0
- package/hooks/useRowExpandToggle.d.ts +5 -0
- package/hooks/useRowExpandToggle.js +13 -0
- package/hooks/useRowHidden.d.ts +4 -0
- package/hooks/useRowHidden.js +6 -0
- package/hooks/useRowSelectCheckbox.d.ts +27 -0
- package/hooks/useRowSelectCheckbox.js +48 -0
- package/hooks/useTable.d.ts +4 -0
- package/hooks/useTable.js +38 -0
- package/hooks/useTableRowHighlight.d.ts +4 -0
- package/hooks/useTableRowHighlight.js +16 -0
- package/hooks/useTranslation.d.ts +3 -0
- package/hooks/useTranslation.js +3 -0
- package/hooks/useWeekdayOptions.d.ts +40 -0
- package/hooks/useWeekdayOptions.js +66 -0
- package/i18n/index.d.ts +13 -0
- package/i18n/index.js +82 -0
- package/i18n/resources/de.json +115 -0
- package/i18n/resources/el.json +116 -0
- package/i18n/resources/en-AE.json +115 -0
- package/i18n/resources/en.json +118 -0
- package/i18n/resources/es.json +115 -0
- package/i18n/resources/fr.json +115 -0
- package/i18n/resources/index.d.ts +1295 -0
- package/i18n/resources/index.js +24 -0
- package/i18n/resources/it.json +115 -0
- package/i18n/resources/lt.json +115 -0
- package/i18n/resources/pt.json +115 -0
- package/i18n/resources/sk.json +115 -0
- package/i18n/resources/sv.json +116 -0
- package/i18n/trans/alert.d.ts +8 -0
- package/i18n/trans/alert.js +10 -0
- package/i18n/trans/button.d.ts +24 -0
- package/i18n/trans/button.js +26 -0
- package/i18n/trans/error.d.ts +10 -0
- package/i18n/trans/error.js +12 -0
- package/i18n/trans/field.d.ts +19 -0
- package/i18n/trans/field.js +21 -0
- package/i18n/trans/index.d.ts +13 -0
- package/i18n/trans/index.js +20 -0
- package/i18n/trans/label.d.ts +18 -0
- package/i18n/trans/label.js +20 -0
- package/i18n/trans/option.d.ts +6 -0
- package/i18n/trans/option.js +8 -0
- package/i18n/trans/qty.d.ts +5 -0
- package/i18n/trans/qty.js +7 -0
- package/i18n/trans/table.d.ts +8 -0
- package/i18n/trans/table.js +10 -0
- package/i18n/trans/title.d.ts +6 -0
- package/i18n/trans/title.js +8 -0
- package/i18n/trans/tooltip.d.ts +8 -0
- package/i18n/trans/tooltip.js +10 -0
- package/icons/1-class.svg +4 -0
- package/icons/2-class-calm.svg +5 -0
- package/icons/2-class-crossed.svg +5 -0
- package/icons/2-class.svg +4 -0
- package/icons/3-class.svg +4 -0
- package/icons/4-class.svg +4 -0
- package/icons/ac-crossed.svg +6 -0
- package/icons/ac.svg +9 -0
- package/icons/accessibility.svg +5 -0
- package/icons/add-journey-segment.svg +9 -0
- package/icons/add-person.svg +6 -0
- package/icons/add.svg +4 -0
- package/icons/air-condition.svg +11 -0
- package/icons/airport.svg +4 -0
- package/icons/alert-circle.svg +5 -0
- package/icons/arrow-down.svg +4 -0
- package/icons/arrow-left-circle.svg +5 -0
- package/icons/arrow-left.svg +4 -0
- package/icons/arrow-right.svg +4 -0
- package/icons/arrow-up.svg +4 -0
- package/icons/baby-care.svg +7 -0
- package/icons/bar.svg +6 -0
- package/icons/bed.svg +3 -0
- package/icons/bicycle-crossed.svg +6 -0
- package/icons/bicycle.svg +8 -0
- package/icons/bin.svg +6 -0
- package/icons/break.svg +5 -0
- package/icons/breakfast-1-class.svg +5 -0
- package/icons/breakfast-2-class.svg +5 -0
- package/icons/breakfast.svg +3 -0
- package/icons/bus.svg +7 -0
- package/icons/business-area.svg +6 -0
- package/icons/by-aisle.svg +8 -0
- package/icons/by-window.svg +6 -0
- package/icons/cafe-1-class.svg +5 -0
- package/icons/calendar.svg +6 -0
- package/icons/cancel.svg +5 -0
- package/icons/cargo.svg +4 -0
- package/icons/carriage-bot.svg +6 -0
- package/icons/carriage-mid.svg +4 -0
- package/icons/carriage-top.svg +12 -0
- package/icons/carriage.svg +3 -0
- package/icons/cart.svg +3 -0
- package/icons/cd.svg +4 -0
- package/icons/check-circle.svg +4 -0
- package/icons/check.svg +3 -0
- package/icons/checkbox-checked.svg +4 -0
- package/icons/checkbox-indeterminate.svg +5 -0
- package/icons/checkbox-mark.svg +3 -0
- package/icons/checkbox.svg +3 -0
- package/icons/chevron-down.svg +3 -0
- package/icons/chevron-left.svg +3 -0
- package/icons/chevron-right.svg +3 -0
- package/icons/chevron-up.svg +3 -0
- package/icons/circle.svg +3 -0
- package/icons/clock.svg +5 -0
- package/icons/clone.svg +4 -0
- package/icons/close-bold.svg +4 -0
- package/icons/close.svg +4 -0
- package/icons/coffee-machine-crossed.svg +6 -0
- package/icons/coffee-machine.svg +7 -0
- package/icons/coin.svg +4 -0
- package/icons/comment.svg +3 -0
- package/icons/compartment.svg +6 -0
- package/icons/couchette.svg +6 -0
- package/icons/cube.svg +1 -0
- package/icons/currency.svg +4 -0
- package/icons/deactivate.svg +4 -0
- package/icons/delete.svg +4 -0
- package/icons/dining.svg +7 -0
- package/icons/direction-bottom.svg +4 -0
- package/icons/direction-forward-v.svg +4 -0
- package/icons/direction-forward.svg +4 -0
- package/icons/direction-left.svg +4 -0
- package/icons/direction-reverse-v.svg +4 -0
- package/icons/direction-reverse.svg +4 -0
- package/icons/direction-right.svg +4 -0
- package/icons/direction-top.svg +4 -0
- package/icons/dots.svg +5 -0
- package/icons/download.svg +5 -0
- package/icons/drag-n-drop.svg +3 -0
- package/icons/draggable.svg +5 -0
- package/icons/duplicate.svg +4 -0
- package/icons/dvd.svg +5 -0
- package/icons/edit.svg +3 -0
- package/icons/empty-search.svg +9 -0
- package/icons/empty-state.svg +13 -0
- package/icons/empty.svg +9 -0
- package/icons/empty_search_purple.svg +6 -0
- package/icons/error-circle.svg +4 -0
- package/icons/eu-law.svg +5 -0
- package/icons/external_link.svg +5 -0
- package/icons/family-area.svg +7 -0
- package/icons/file-settings.svg +3 -0
- package/icons/file.svg +11 -0
- package/icons/filter.svg +3 -0
- package/icons/flip.svg +11 -0
- package/icons/food-1-class.svg +5 -0
- package/icons/food-plus.svg +5 -0
- package/icons/food.svg +7 -0
- package/icons/grid-cell.svg +1 -0
- package/icons/grid.svg +6 -0
- package/icons/headphones.svg +5 -0
- package/icons/helping-hand-crossed.svg +12 -0
- package/icons/helping-hand.svg +3 -0
- package/icons/hide.svg +4 -0
- package/icons/home.svg +4 -0
- package/icons/index.json +228 -0
- package/icons/info-circle.svg +5 -0
- package/icons/insurance.svg +6 -0
- package/icons/journey-changeover.svg +5 -0
- package/icons/journey-light.svg +5 -0
- package/icons/journey.svg +5 -0
- package/icons/key.svg +4 -0
- package/icons/language.svg +3 -0
- package/icons/link.svg +4 -0
- package/icons/list.svg +8 -0
- package/icons/locker.svg +8 -0
- package/icons/logout.svg +5 -0
- package/icons/luggage.svg +9 -0
- package/icons/mail.svg +4 -0
- package/icons/meeting-lounge.svg +10 -0
- package/icons/metro.svg +3 -0
- package/icons/middle-seat.svg +7 -0
- package/icons/minus.svg +3 -0
- package/icons/minus24.svg +3 -0
- package/icons/mobile-crossed.svg +7 -0
- package/icons/mobile.svg +6 -0
- package/icons/movingo.svg +3 -0
- package/icons/multimedia.svg +9 -0
- package/icons/near-bicycle.svg +5 -0
- package/icons/near-pet.svg +5 -0
- package/icons/near-wheelchair.svg +8 -0
- package/icons/night-train.svg +4 -0
- package/icons/nonstop.svg +3 -0
- package/icons/occupancy-seat-hover.svg +11 -0
- package/icons/occupancy-seat-selected.svg +11 -0
- package/icons/occupancy-seat.svg +4 -0
- package/icons/oneway.svg +4 -0
- package/icons/pet-crossed.svg +5 -0
- package/icons/pet.svg +7 -0
- package/icons/pic.svg +5 -0
- package/icons/playground.svg +7 -0
- package/icons/plus.svg +4 -0
- package/icons/plus24.svg +4 -0
- package/icons/popup-controls.svg +15 -0
- package/icons/power-socket.svg +6 -0
- package/icons/preview.svg +3 -0
- package/icons/print.svg +5 -0
- package/icons/priority-seat-elderly.svg +6 -0
- package/icons/priority-seat-pregnant.svg +5 -0
- package/icons/profile.svg +4 -0
- package/icons/question.svg +5 -0
- package/icons/radio-filled.svg +4 -0
- package/icons/radio.svg +3 -0
- package/icons/reclining-seat.svg +9 -0
- package/icons/refresh.svg +6 -0
- package/icons/reload.svg +4 -0
- package/icons/remove-circle.svg +3 -0
- package/icons/replace.svg +6 -0
- package/icons/reservation-crossed.svg +4 -0
- package/icons/reservation-mandatory.svg +4 -0
- package/icons/reservation-optional.svg +5 -0
- package/icons/resplus-horizontal.svg +1 -0
- package/icons/resplus.svg +3 -0
- package/icons/restaurant.svg +3 -0
- package/icons/roundtrip.svg +6 -0
- package/icons/save.svg +5 -0
- package/icons/search.svg +4 -0
- package/icons/seat-compartment.svg +8 -0
- package/icons/seat-selected.svg +3 -0
- package/icons/seat.svg +5 -0
- package/icons/sent.svg +34 -0
- package/icons/service-dog.svg +4 -0
- package/icons/settings.svg +4 -0
- package/icons/shift.svg +3 -0
- package/icons/ship.svg +3 -0
- package/icons/show.svg +4 -0
- package/icons/shower.svg +9 -0
- package/icons/silence.svg +6 -0
- package/icons/sink.svg +5 -0
- package/icons/skis.svg +8 -0
- package/icons/sleeper-car-bedding.svg +6 -0
- package/icons/sleeper-car.svg +5 -0
- package/icons/smoking-crossed.svg +6 -0
- package/icons/sort.svg +6 -0
- package/icons/stairs-down.svg +5 -0
- package/icons/stairs-up.svg +5 -0
- package/icons/star-filled.svg +3 -0
- package/icons/star.svg +3 -0
- package/icons/stroller.svg +6 -0
- package/icons/sw-law.svg +5 -0
- package/icons/switch.svg +3 -0
- package/icons/table.svg +6 -0
- package/icons/tag.svg +4 -0
- package/icons/taxi.svg +3 -0
- package/icons/tick.svg +3 -0
- package/icons/ticket-cancel.svg +8 -0
- package/icons/ticket-change.svg +3 -0
- package/icons/ticket-manage.svg +7 -0
- package/icons/ticket-refund.svg +8 -0
- package/icons/ticket-travel-pass.svg +4 -0
- package/icons/ticket.svg +6 -0
- package/icons/tickets.svg +4 -0
- package/icons/train.svg +3 -0
- package/icons/transfer.svg +3 -0
- package/icons/trash.svg +6 -0
- package/icons/triange.svg +17 -0
- package/icons/tv.svg +5 -0
- package/icons/unaccompanied-minor.svg +8 -0
- package/icons/upload.svg +5 -0
- package/icons/usb.svg +9 -0
- package/icons/visibility-off.svg +4 -0
- package/icons/visibility-on.svg +4 -0
- package/icons/voucher.svg +5 -0
- package/icons/wardrobe.svg +4 -0
- package/icons/warning.svg +3 -0
- package/icons/water.svg +5 -0
- package/icons/wc.svg +4 -0
- package/icons/wheelchair-lift-reservation.svg +8 -0
- package/icons/wheelchair-lift.svg +6 -0
- package/icons/wheelchair-ramp.svg +8 -0
- package/icons/wheelchair-space-reservation.svg +13 -0
- package/icons/wheelchair-space.svg +4 -0
- package/icons/wheelchair.svg +5 -0
- package/icons/wifi-crossed.svg +9 -0
- package/icons/wifi.svg +6 -0
- package/index.css +327 -0
- package/index.d.ts +31 -0
- package/index.js +32 -0
- package/mui/Accordion.d.ts +17 -0
- package/mui/Accordion.js +46 -0
- package/mui/Button/index.d.ts +16 -0
- package/mui/Button/index.js +35 -0
- package/mui/Card/CardHeader.d.ts +7 -0
- package/mui/Card/CardHeader.js +43 -0
- package/mui/Card/index.d.ts +4 -0
- package/mui/Card/index.js +4 -0
- package/mui/Checkbox/CheckboxGroup.d.ts +26 -0
- package/mui/Checkbox/CheckboxGroup.js +81 -0
- package/mui/Checkbox/index.d.ts +18 -0
- package/mui/Checkbox/index.js +40 -0
- package/mui/Chip/ChipSecondarySmall.d.ts +10 -0
- package/mui/Chip/ChipSecondarySmall.js +40 -0
- package/mui/CircularProgress/index.d.ts +3 -0
- package/mui/CircularProgress/index.js +36 -0
- package/mui/Collapsible/index.d.ts +9 -0
- package/mui/Collapsible/index.js +66 -0
- package/mui/Counter/index.d.ts +9 -0
- package/mui/Counter/index.js +37 -0
- package/mui/DatePicker/DatePicker.scss +276 -0
- package/mui/DatePicker/DatePickerContext.d.ts +8 -0
- package/mui/DatePicker/DatePickerContext.js +2 -0
- package/mui/DatePicker/DatePickerHeader.d.ts +3 -0
- package/mui/DatePicker/DatePickerHeader.js +63 -0
- package/mui/DatePicker/DatePickerHeaderSelect.d.ts +10 -0
- package/mui/DatePicker/DatePickerHeaderSelect.js +72 -0
- package/mui/DatePicker/DatePickerInput.d.ts +6 -0
- package/mui/DatePicker/DatePickerInput.js +28 -0
- package/mui/DatePicker/TimeInput.d.ts +10 -0
- package/mui/DatePicker/TimeInput.js +63 -0
- package/mui/DatePicker/index.d.ts +52 -0
- package/mui/DatePicker/index.js +187 -0
- package/mui/Dropdown/index.d.ts +22 -0
- package/mui/Dropdown/index.js +90 -0
- package/mui/EditableLabel/index.d.ts +7 -0
- package/mui/EditableLabel/index.js +81 -0
- package/mui/ExternalLink/index.d.ts +8 -0
- package/mui/ExternalLink/index.js +11 -0
- package/mui/FileInput/index.d.ts +27 -0
- package/mui/FileInput/index.js +66 -0
- package/mui/FormControl/index.d.ts +23 -0
- package/mui/FormControl/index.js +36 -0
- package/mui/FormField/index.d.ts +8 -0
- package/mui/FormField/index.js +12 -0
- package/mui/Icon/index.d.ts +21 -0
- package/mui/Icon/index.js +47 -0
- package/mui/Input/index.d.ts +28 -0
- package/mui/Input/index.js +102 -0
- package/mui/Loader/index.d.ts +9 -0
- package/mui/Loader/index.js +47 -0
- package/mui/Modal/index.d.ts +16 -0
- package/mui/Modal/index.js +64 -0
- package/mui/Pagination/index.d.ts +6 -0
- package/mui/Pagination/index.js +23 -0
- package/mui/Paper/index.d.ts +4 -0
- package/mui/Paper/index.js +3 -0
- package/mui/Popper/index.d.ts +13 -0
- package/mui/Popper/index.js +139 -0
- package/mui/RadioGroup/index.d.ts +26 -0
- package/mui/RadioGroup/index.js +41 -0
- package/mui/ReadOnlyField/index.d.ts +8 -0
- package/mui/ReadOnlyField/index.js +35 -0
- package/mui/Select/index.d.ts +47 -0
- package/mui/Select/index.js +164 -0
- package/mui/Stepper/StepIconComponent.d.ts +6 -0
- package/mui/Stepper/StepIconComponent.js +93 -0
- package/mui/Stepper/index.d.ts +6 -0
- package/mui/Stepper/index.js +13 -0
- package/mui/Switch/index.d.ts +3 -0
- package/mui/Switch/index.js +2 -0
- package/mui/Tab/index.d.ts +60 -0
- package/mui/Tab/index.js +12 -0
- package/mui/Tabs/index.d.ts +22 -0
- package/mui/Tabs/index.js +70 -0
- package/mui/TimeDurationLabel/index.d.ts +7 -0
- package/mui/TimeDurationLabel/index.js +13 -0
- package/mui/ToggleButton/index.d.ts +4 -0
- package/mui/ToggleButton/index.js +57 -0
- package/mui/ToggleButtonGroup/index.d.ts +25 -0
- package/mui/ToggleButtonGroup/index.js +61 -0
- package/mui/ToggleList/index.d.ts +11 -0
- package/mui/ToggleList/index.js +54 -0
- package/mui/Tooltip/index.d.ts +11 -0
- package/mui/Tooltip/index.js +36 -0
- package/mui/index.d.ts +36 -0
- package/mui/index.js +36 -0
- package/mui/provider.d.ts +9 -0
- package/mui/provider.js +22 -0
- package/mui/theme.d.ts +17 -0
- package/mui/theme.js +1228 -0
- package/package.json +197 -4
- package/services/api.d.ts +28 -0
- package/services/api.js +141 -0
- package/services/index.d.ts +2 -0
- package/services/index.js +2 -0
- package/services/openapi.d.ts +6 -0
- package/services/openapi.js +112 -0
- package/store/index.d.ts +6 -0
- package/store/index.js +1 -0
- package/store/useClassificationOptions.d.ts +3 -0
- package/store/useClassificationOptions.js +2 -0
- package/types.d.ts +2423 -0
- package/utils/array.d.ts +2 -0
- package/utils/array.js +21 -0
- package/utils/auth.d.ts +2 -0
- package/utils/auth.js +31 -0
- package/utils/color.d.ts +29 -0
- package/utils/color.js +132 -0
- package/utils/date.d.ts +40 -0
- package/utils/date.js +51 -0
- package/utils/filter.d.ts +3 -0
- package/utils/filter.js +11 -0
- package/utils/getScrollbarSize.d.ts +1 -0
- package/utils/getScrollbarSize.js +8 -0
- package/utils/index.d.ts +12 -0
- package/utils/index.js +12 -0
- package/utils/input.d.ts +2 -0
- package/utils/input.js +2 -0
- package/utils/knowledge-owl-script.d.ts +64 -0
- package/utils/knowledge-owl-script.js +226 -0
- package/utils/locales.d.ts +3 -0
- package/utils/locales.js +24 -0
- package/utils/noop.d.ts +1 -0
- package/utils/noop.js +1 -0
- package/utils/percentage.d.ts +6 -0
- package/utils/percentage.js +43 -0
- package/utils/redirect.d.ts +1 -0
- package/utils/redirect.js +6 -0
- package/utils/sort.d.ts +21 -0
- package/utils/sort.js +32 -0
- package/utils/storage.d.ts +2 -0
- package/utils/storage.js +2 -0
- package/utils/timeDuration.d.ts +26 -0
- package/utils/timeDuration.js +78 -0
- package/utils/wallClock.d.ts +17 -0
- package/utils/wallClock.js +178 -0
- package/wrappers/ApiInitializer.d.ts +9 -0
- package/wrappers/ApiInitializer.js +21 -0
- package/wrappers/AuthWrapper.d.ts +6 -0
- package/wrappers/AuthWrapper.js +38 -0
- package/wrappers/AxiosErrorsInterceptorWrapper.d.ts +2 -0
- package/wrappers/AxiosErrorsInterceptorWrapper.js +30 -0
- package/README.md +0 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { FormField, metaError, } from "../FormField";
|
|
4
|
+
import { IconButton, Stack, } from '@mui/material';
|
|
5
|
+
import { TransButton } from "../../i18n/trans/button";
|
|
6
|
+
import { makeStyles } from '@mui/styles';
|
|
7
|
+
import { TransQty } from "../../i18n/trans/qty";
|
|
8
|
+
import { useModal } from "../../hooks";
|
|
9
|
+
import { Button, FormControl, Icon } from "../../mui";
|
|
10
|
+
import isEmpty from 'lodash/isEmpty';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import { getAccessabilityValue } from "../../utils";
|
|
13
|
+
import _kebabCase from 'lodash/kebabCase';
|
|
14
|
+
import { StopsSelectModal } from "./StopsSelectModal";
|
|
15
|
+
const useStyles = makeStyles((theme) => ({
|
|
16
|
+
value: {
|
|
17
|
+
whiteSpace: 'nowrap',
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
textOverflow: 'ellipsis',
|
|
20
|
+
lineHeight: 1.75,
|
|
21
|
+
marginRight: theme.spacing(),
|
|
22
|
+
},
|
|
23
|
+
more: {
|
|
24
|
+
whiteSpace: 'nowrap',
|
|
25
|
+
lineHeight: 1.75,
|
|
26
|
+
marginRight: theme.spacing(),
|
|
27
|
+
},
|
|
28
|
+
accessibilityButton: {
|
|
29
|
+
border: 'none !important',
|
|
30
|
+
textDecoration: 'underline',
|
|
31
|
+
},
|
|
32
|
+
}), {
|
|
33
|
+
name: 'StopsSelect',
|
|
34
|
+
});
|
|
35
|
+
function StopsSelectAdapter({ input, meta, label, onConfirm, unselectableStops, staticSelectedStops, hasDisabledRows = false, showOnlySelectedView = false, required, disableAddEdit, className, getAllRowId, getSelectedRowId, }) {
|
|
36
|
+
const classes = useStyles();
|
|
37
|
+
const { value, name, multiple, onChange } = input;
|
|
38
|
+
const accessibility = useMemo(getAccessabilityValue, []);
|
|
39
|
+
const { open: isOpen, onOpen, onClose } = useModal();
|
|
40
|
+
const stopsArray = useMemo(() => {
|
|
41
|
+
if (!value || isEmpty(value))
|
|
42
|
+
return [];
|
|
43
|
+
if (Array.isArray(value))
|
|
44
|
+
return value;
|
|
45
|
+
if (value instanceof Map)
|
|
46
|
+
return Array.from(value.values());
|
|
47
|
+
return [value];
|
|
48
|
+
}, [value]);
|
|
49
|
+
const firstStop = stopsArray[0] || null;
|
|
50
|
+
const stopsLength = stopsArray.length;
|
|
51
|
+
const handleModalConfirm = useCallback((selectedStops) => {
|
|
52
|
+
const result = multiple ? selectedStops : selectedStops[0] || null;
|
|
53
|
+
onChange(result);
|
|
54
|
+
onConfirm?.(name, selectedStops);
|
|
55
|
+
}, [multiple, name, onChange, onConfirm]);
|
|
56
|
+
const dataTestId = useMemo(() => `stops-select-${_kebabCase(name)}`, [name]);
|
|
57
|
+
const error = useMemo(() => metaError(meta), [meta]);
|
|
58
|
+
return (_jsxs(_Fragment, { children: [_jsx(FormControl, { label: label, required: required, error: error, className: className, children: _jsxs(Stack, { direction: "row", alignItems: "center", className: classNames({ error }), children: [firstStop && _jsx("span", { className: classes.value, children: firstStop.name }), Boolean(stopsLength > 1) && (_jsx("span", { className: classes.more, children: _jsx(TransQty, { i18nKey: "plusMore", values: { num: stopsLength - 1 } }) })), !disableAddEdit &&
|
|
59
|
+
(firstStop && !multiple ? (_jsx(IconButton, { onClick: () => onChange(multiple ? [] : null), "data-testid": dataTestId, children: _jsx(Icon, { name: "close" }) })) : (_jsx(Button, { variant: "text", size: "small", onClick: onOpen, sx: { px: 0, minWidth: 'unset' }, className: classNames({
|
|
60
|
+
[classes.accessibilityButton]: accessibility,
|
|
61
|
+
}), "data-testid": dataTestId, children: _jsx(TransButton, { i18nKey: "addEdit" }) })))] }) }), _jsx(StopsSelectModal, { open: isOpen, onClose: onClose, multiple: multiple, showOnlySelectedView: showOnlySelectedView, onConfirm: handleModalConfirm, initialSelectedStops: stopsArray, staticSelectedStops: staticSelectedStops, getSelectedRowId: getSelectedRowId, getAllRowId: getAllRowId, unselectableStops: unselectableStops, hasDisabledRows: hasDisabledRows })] }));
|
|
62
|
+
}
|
|
63
|
+
export const StopsSelect = (props) => {
|
|
64
|
+
return (_jsx(FormField, { component: StopsSelectAdapter, ...props, allowNull: true }));
|
|
65
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ModalProps } from "../../mui";
|
|
3
|
+
import { StopsSearchParams } from "./StopsSelectSearchForm";
|
|
4
|
+
import type { PaginationParams } from "../../dto/pagination";
|
|
5
|
+
import { LineNetworkStop } from "../../dto/line-network";
|
|
6
|
+
export interface StopsSearchQueryParams extends Partial<StopsSearchParams>, Partial<PaginationParams> {
|
|
7
|
+
}
|
|
8
|
+
export declare type StopsSelectTableRow<T = LineNetworkStop['id']> = Omit<Partial<LineNetworkStop>, 'id' | 'name'> & {
|
|
9
|
+
id: T;
|
|
10
|
+
name: LineNetworkStop['name'];
|
|
11
|
+
hidden?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface StopsSelectModalProps<StopId extends string | number = string | number> extends Omit<ModalProps, 'title' | 'children'> {
|
|
14
|
+
showOnlySelectedView?: boolean;
|
|
15
|
+
multiple?: boolean;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
onConfirm: (stops: Array<StopsSelectTableRow<StopId>>) => void;
|
|
18
|
+
initialSelectedStops?: Array<StopsSelectTableRow<StopId>>;
|
|
19
|
+
staticSelectedStops?: Array<StopsSelectTableRow<StopId>>;
|
|
20
|
+
getSelectedRowId?: (row: StopsSelectTableRow<StopId>) => string;
|
|
21
|
+
getAllRowId?: (row: StopsSelectTableRow<StopId>) => string;
|
|
22
|
+
unselectableStops?: Array<StopsSelectTableRow<StopId>>;
|
|
23
|
+
hasDisabledRows?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const StopsSelectModal: <StopId extends string | number>({ open, onClose, multiple, showOnlySelectedView, onConfirm, initialSelectedStops, staticSelectedStops, getSelectedRowId, getAllRowId, unselectableStops, hasDisabledRows, ...modalProps }: StopsSelectModalProps<StopId>) => JSX.Element;
|
|
26
|
+
export default StopsSelectModal;
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TransTitle } from "../../i18n/trans/title";
|
|
3
|
+
import { TransButton } from "../../i18n/trans/button";
|
|
4
|
+
import { Icon, Modal } from "../../mui";
|
|
5
|
+
import { Loadable } from "../../components/Loadable";
|
|
6
|
+
import { StopsSelectSearchForm, } from "./StopsSelectSearchForm";
|
|
7
|
+
import { Divider, FormControlLabel, Switch } from '@mui/material';
|
|
8
|
+
import { Table } from "../../components/Table";
|
|
9
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
10
|
+
import { TransField } from "../../i18n/trans/field";
|
|
11
|
+
import { useIndeterminateRowSelectCheckbox, useRowHidden, useRowSelectCheckbox, useRowSelectRadio, useTable, } from "../../hooks";
|
|
12
|
+
import { usePagination, useRowSelect } from 'react-table';
|
|
13
|
+
import _xor from 'lodash/xor';
|
|
14
|
+
import _isEmpty from 'lodash/isEmpty';
|
|
15
|
+
import _filter from 'lodash/filter';
|
|
16
|
+
import _pick from 'lodash/pick';
|
|
17
|
+
import { TransAlert } from "../../i18n/trans/alert";
|
|
18
|
+
import { formSubmit } from "../../helpers";
|
|
19
|
+
import { filterByKeyword } from "../../helpers/filter";
|
|
20
|
+
import { TransTableHead } from "../../i18n/trans/table";
|
|
21
|
+
import { api } from "../../services";
|
|
22
|
+
import qs from 'qs';
|
|
23
|
+
import { makeStyles } from '@mui/styles';
|
|
24
|
+
const useStyles = makeStyles((theme) => ({
|
|
25
|
+
modal: {
|
|
26
|
+
padding: theme.spacing(3),
|
|
27
|
+
width: '100%',
|
|
28
|
+
'& .MuiDialog-container': {
|
|
29
|
+
width: '100%',
|
|
30
|
+
},
|
|
31
|
+
'& .MuiDialog-paper': {
|
|
32
|
+
width: '100%',
|
|
33
|
+
maxWidth: theme.breakpoints.values.lg,
|
|
34
|
+
minHeight: '100%',
|
|
35
|
+
'& .MuiDialogContent-root': {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
minHeight: 0,
|
|
38
|
+
overflow: 'unset',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
'& .MuiTablePagination-root': {
|
|
41
|
+
overflow: 'unset',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
export const StopsSelectModal = ({ open, onClose, multiple = false, showOnlySelectedView = false, onConfirm, initialSelectedStops = [], staticSelectedStops, getSelectedRowId, getAllRowId, unselectableStops, hasDisabledRows = false, ...modalProps }) => {
|
|
48
|
+
const classes = useStyles();
|
|
49
|
+
const [loading, setLoading] = useState(false);
|
|
50
|
+
const [view, setView] = useState(() => showOnlySelectedView ? 'selected' : 'search');
|
|
51
|
+
const [stops, setStops] = useState();
|
|
52
|
+
const [regularStopsSearchFilter, setRegularStopsSearchFilter] = useState({});
|
|
53
|
+
const [selectedStopsSearchFilter, setSelectedStopsSearchFilter] = useState({ offset: 0, limit: 10 });
|
|
54
|
+
// Use guid as key when available (for matching across different data sources)
|
|
55
|
+
const getStopKey = useCallback((stop) => stop.guid || String(stop.id), []);
|
|
56
|
+
// Combine initial and static selected stops
|
|
57
|
+
// When showOnlySelectedView is true, only use initialSelectedStops (not staticSelectedStops)
|
|
58
|
+
// to avoid pre-selecting all static stops when the modal opens
|
|
59
|
+
const allInitialStops = useMemo(() => {
|
|
60
|
+
const stopsMap = new Map();
|
|
61
|
+
initialSelectedStops.forEach((stop) => {
|
|
62
|
+
stopsMap.set(getStopKey(stop), stop);
|
|
63
|
+
});
|
|
64
|
+
// Only include staticSelectedStops in initial selection when NOT in showOnlySelectedView mode
|
|
65
|
+
if (staticSelectedStops && !showOnlySelectedView) {
|
|
66
|
+
staticSelectedStops.forEach((stop) => {
|
|
67
|
+
const key = getStopKey(stop);
|
|
68
|
+
if (!stopsMap.has(key)) {
|
|
69
|
+
stopsMap.set(key, stop);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return stopsMap;
|
|
74
|
+
}, [initialSelectedStops, staticSelectedStops, getStopKey, showOnlySelectedView]);
|
|
75
|
+
// Internal draft selection state for the modal
|
|
76
|
+
const [draftSelection, setDraftSelection] = useState(() => new Map(allInitialStops));
|
|
77
|
+
// Reset draft selection when modal opens with new initial values
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (open) {
|
|
80
|
+
setDraftSelection(new Map(allInitialStops));
|
|
81
|
+
}
|
|
82
|
+
}, [open, allInitialStops]);
|
|
83
|
+
const selectedRowIds = useMemo(() => Object.fromEntries(Array.from(draftSelection.keys()).map((id) => [id, true])), [draftSelection]);
|
|
84
|
+
const regularStopsTableData = useMemo(() => {
|
|
85
|
+
const unselectableStopsMap = new Map((unselectableStops ?? []).map((stop) => [stop.id, stop]));
|
|
86
|
+
return (stops?.items ?? []).map((item) => ({
|
|
87
|
+
...item,
|
|
88
|
+
...(unselectableStops && {
|
|
89
|
+
hidden: Boolean(unselectableStopsMap.get(item.id)),
|
|
90
|
+
}),
|
|
91
|
+
}));
|
|
92
|
+
}, [stops?.items, unselectableStops]);
|
|
93
|
+
const selectedStopsTableFilteredData = useMemo(() => {
|
|
94
|
+
// When showOnlySelectedView is true, show staticSelectedStops for searching,
|
|
95
|
+
// but the selection state (checkboxes) will be controlled by draftSelection
|
|
96
|
+
// When showOnlySelectedView is false, show only what's in draftSelection
|
|
97
|
+
const selectedStopsTableInitialData = showOnlySelectedView
|
|
98
|
+
? staticSelectedStops ?? Array.from(draftSelection.values())
|
|
99
|
+
: Array.from(draftSelection.values());
|
|
100
|
+
const { name, countryId, countyName, cityName, streetAddress } = selectedStopsSearchFilter;
|
|
101
|
+
return selectedStopsTableInitialData.filter((stop) => (name ? filterByKeyword(name)(stop.name) : true) &&
|
|
102
|
+
(countryId ? stop.countryId === countryId : true) &&
|
|
103
|
+
(countyName ? filterByKeyword(countyName)(stop.countyName) : true) &&
|
|
104
|
+
(cityName ? filterByKeyword(cityName)(stop.cityName) : true) &&
|
|
105
|
+
(streetAddress
|
|
106
|
+
? filterByKeyword(streetAddress)(stop.streetAddress)
|
|
107
|
+
: true));
|
|
108
|
+
}, [draftSelection, selectedStopsSearchFilter, staticSelectedStops, showOnlySelectedView]);
|
|
109
|
+
const selectedStopsTableSlicedData = useMemo(() => {
|
|
110
|
+
const { offset, limit } = selectedStopsSearchFilter;
|
|
111
|
+
return selectedStopsTableFilteredData.slice(offset, offset + limit);
|
|
112
|
+
}, [selectedStopsSearchFilter, selectedStopsTableFilteredData]);
|
|
113
|
+
const stateReducer = useCallback((newState, action) => {
|
|
114
|
+
if (action.type === 'toggleRowSelected') {
|
|
115
|
+
const rowId = action.id;
|
|
116
|
+
const isSelected = action.value;
|
|
117
|
+
setDraftSelection((prev) => {
|
|
118
|
+
const next = new Map(prev);
|
|
119
|
+
if (isSelected) {
|
|
120
|
+
const row = regularStopsTableData.find((r) => getStopKey(r) === rowId) ||
|
|
121
|
+
selectedStopsTableFilteredData.find((r) => getStopKey(r) === rowId);
|
|
122
|
+
if (row)
|
|
123
|
+
next.set(rowId, row);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
next.delete(rowId);
|
|
127
|
+
}
|
|
128
|
+
return next;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else if (action.type === 'toggleAllRowsSelected') {
|
|
132
|
+
const isSelected = action.value;
|
|
133
|
+
// Determine which data source to use based on current view
|
|
134
|
+
const dataSource = view === 'selected' ? selectedStopsTableFilteredData : regularStopsTableData;
|
|
135
|
+
setDraftSelection((prev) => {
|
|
136
|
+
const next = new Map(prev);
|
|
137
|
+
if (isSelected) {
|
|
138
|
+
dataSource.forEach((row) => {
|
|
139
|
+
if (!row.hidden)
|
|
140
|
+
next.set(getStopKey(row), row);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
dataSource.forEach((row) => {
|
|
145
|
+
next.delete(getStopKey(row));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return next;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return newState;
|
|
152
|
+
}, [regularStopsTableData, selectedStopsTableFilteredData, getStopKey, view]);
|
|
153
|
+
const handleConfirm = useCallback(() => {
|
|
154
|
+
const selectedStops = Array.from(draftSelection.values());
|
|
155
|
+
onConfirm(selectedStops);
|
|
156
|
+
onClose();
|
|
157
|
+
}, [draftSelection, onConfirm, onClose]);
|
|
158
|
+
const fetchStops = useCallback(async (params) => {
|
|
159
|
+
setLoading(true);
|
|
160
|
+
setRegularStopsSearchFilter((prev) => ({ ...prev, ...params }));
|
|
161
|
+
const { data } = await api.get(`/stops${qs.stringify(params, { addQueryPrefix: true })}`, {
|
|
162
|
+
baseURL: process.env.REACT_APP_API_LM || import.meta.env?.VITE_APP_API_LM,
|
|
163
|
+
});
|
|
164
|
+
// Map address fields to flat properties for table display
|
|
165
|
+
const mappedItems = data.items?.map((stop) => ({
|
|
166
|
+
...stop,
|
|
167
|
+
countryName: stop.countryName ?? stop.address?.countryName,
|
|
168
|
+
countyName: stop.countyName ?? stop.address?.countyName,
|
|
169
|
+
cityName: stop.cityName ?? stop.address?.cityName,
|
|
170
|
+
streetAddress: stop.streetAddress ?? stop.address?.streetName,
|
|
171
|
+
}));
|
|
172
|
+
setStops({ ...data, items: mappedItems });
|
|
173
|
+
setLoading(false);
|
|
174
|
+
setView('search');
|
|
175
|
+
}, [setStops]);
|
|
176
|
+
const isSelectedView = useMemo(() => view === 'selected', [view]);
|
|
177
|
+
const handleChangeView = useCallback((_, checked) => {
|
|
178
|
+
setView(checked ? 'selected' : 'search');
|
|
179
|
+
}, []);
|
|
180
|
+
const renderSwitch = useCallback(() => {
|
|
181
|
+
if (!multiple) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return (_jsxs(_Fragment, { children: [_jsx(FormControlLabel, { label: _jsx(TransField, { i18nKey: "displaySelectedStops" }), control: _jsx(Switch, { sx: { mr: 1 }, checked: isSelectedView, onChange: handleChangeView }) }), _jsx(Divider, { sx: { mt: 3, mb: 2 } })] }));
|
|
185
|
+
}, [isSelectedView, handleChangeView, multiple]);
|
|
186
|
+
const handleRegularSearchSubmit = useCallback((values, form) => {
|
|
187
|
+
const required = _xor(form.getRegisteredFields(), [
|
|
188
|
+
'countryId',
|
|
189
|
+
'nameSearchBehaviour',
|
|
190
|
+
]);
|
|
191
|
+
if (_isEmpty(_filter(_pick(values, required), Boolean)))
|
|
192
|
+
return required.reduce((acc, name) => ({
|
|
193
|
+
...acc,
|
|
194
|
+
[name]: _jsx(TransAlert, { i18nKey: "fillAtLeastOne" }),
|
|
195
|
+
}), {});
|
|
196
|
+
return formSubmit(async () => await fetchStops(values));
|
|
197
|
+
}, [fetchStops]);
|
|
198
|
+
const handleSelectedSearchSubmit = useCallback((values) => formSubmit(async () => setSelectedStopsSearchFilter({
|
|
199
|
+
...values,
|
|
200
|
+
offset: 0,
|
|
201
|
+
limit: selectedStopsSearchFilter.limit,
|
|
202
|
+
})), [selectedStopsSearchFilter.limit]);
|
|
203
|
+
const columns = useMemo(() => [
|
|
204
|
+
{
|
|
205
|
+
accessor: 'name',
|
|
206
|
+
Header: _jsx(TransTableHead, { i18nKey: "name" }),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
accessor: 'countryName',
|
|
210
|
+
Header: _jsx(TransTableHead, { i18nKey: "country" }),
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
accessor: 'countyName',
|
|
214
|
+
Header: _jsx(TransTableHead, { i18nKey: "county" }),
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
accessor: 'cityName',
|
|
218
|
+
Header: _jsx(TransTableHead, { i18nKey: "city" }),
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
accessor: 'streetAddress',
|
|
222
|
+
Header: _jsx(TransTableHead, { i18nKey: "streetAndHouseNumber" }),
|
|
223
|
+
},
|
|
224
|
+
], []);
|
|
225
|
+
const getRowId = useCallback((row) => row.guid || `${row.id}`, []);
|
|
226
|
+
const handleRegularTablePageChange = useCallback(async (paginationParams) => {
|
|
227
|
+
await fetchStops({ ...regularStopsSearchFilter, ...paginationParams });
|
|
228
|
+
}, [regularStopsSearchFilter, fetchStops]);
|
|
229
|
+
const table = useTable({
|
|
230
|
+
data: regularStopsTableData,
|
|
231
|
+
columns,
|
|
232
|
+
getRowId,
|
|
233
|
+
total: stops?.totalCount,
|
|
234
|
+
offset: stops?.offset,
|
|
235
|
+
onPageChange: handleRegularTablePageChange,
|
|
236
|
+
stateReducer,
|
|
237
|
+
}, usePagination, useRowSelect, ...(unselectableStops ? [useRowHidden] : []), multiple ? useIndeterminateRowSelectCheckbox : useRowSelectRadio);
|
|
238
|
+
// Sync table selection with draft selection — runs both when search data
|
|
239
|
+
// loads and when the parent clears initialSelectedStops (e.g. form reset),
|
|
240
|
+
// so rows can also be deselected, not only selected.
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (regularStopsTableData.length > 0) {
|
|
243
|
+
table.rows.forEach((row) => {
|
|
244
|
+
const shouldBeSelected = selectedRowIds[row.id] === true;
|
|
245
|
+
if (row.isSelected !== shouldBeSelected) {
|
|
246
|
+
table.toggleRowSelected(row.id, shouldBeSelected);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
251
|
+
}, [regularStopsTableData, selectedRowIds]);
|
|
252
|
+
const handleSelectedTablePageChange = useCallback(async (paginationParams) => {
|
|
253
|
+
setSelectedStopsSearchFilter((prev) => ({
|
|
254
|
+
...prev,
|
|
255
|
+
...paginationParams,
|
|
256
|
+
}));
|
|
257
|
+
}, []);
|
|
258
|
+
const selectedStopsTable = useTable({
|
|
259
|
+
data: selectedStopsTableSlicedData,
|
|
260
|
+
columns,
|
|
261
|
+
getRowId: getSelectedRowId ?? getRowId,
|
|
262
|
+
total: selectedStopsTableFilteredData.length,
|
|
263
|
+
offset: selectedStopsSearchFilter.offset,
|
|
264
|
+
onPageChange: handleSelectedTablePageChange,
|
|
265
|
+
useControlledState: (state) => ({
|
|
266
|
+
...state,
|
|
267
|
+
selectedRowIds,
|
|
268
|
+
}),
|
|
269
|
+
stateReducer,
|
|
270
|
+
}, usePagination, useRowSelect, ...(hasDisabledRows
|
|
271
|
+
? [useRowSelectCheckbox, useRowHidden]
|
|
272
|
+
: [useIndeterminateRowSelectCheckbox]));
|
|
273
|
+
return (_jsx(Modal, { open: open, onClose: onClose, classes: { root: classes.modal }, "data-testid": "select-stops-modal", title: _jsx(TransTitle, { i18nKey: "selectStops" }), actionButton: {
|
|
274
|
+
label: _jsx(TransButton, { i18nKey: "confirm" }),
|
|
275
|
+
startIcon: _jsx(Icon, { name: "check" }),
|
|
276
|
+
'data-testid': 'stops-select-confirm-button',
|
|
277
|
+
onClick: handleConfirm,
|
|
278
|
+
}, fullWidth: true, ...modalProps, children: _jsxs(Loadable, { loading: loading, children: [renderSwitch(), view === 'search' && (_jsxs(_Fragment, { children: [_jsx(StopsSelectSearchForm, { onSubmit: handleRegularSearchSubmit, view: view, initialValues: regularStopsSearchFilter }), _jsx(Divider, { sx: { mt: 3, mb: 2 } }), _jsx(Table, { table: table })] })), view === 'selected' && (_jsxs(_Fragment, { children: [_jsx(StopsSelectSearchForm, { onSubmit: handleSelectedSearchSubmit, view: view, initialValues: selectedStopsSearchFilter }), _jsx(Divider, { sx: { mt: 3, mb: 2 } }), _jsx(Table, { table: selectedStopsTable })] }))] }) }));
|
|
279
|
+
};
|
|
280
|
+
export default StopsSelectModal;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { Config as FormConfig } from 'final-form';
|
|
3
|
+
export declare enum NameSearchBehaviourType {
|
|
4
|
+
CONTAINS = "contains",
|
|
5
|
+
STARTS_WITH = "startsWith",
|
|
6
|
+
EXACT = "exact"
|
|
7
|
+
}
|
|
8
|
+
export interface StopsSearchParams {
|
|
9
|
+
name: string;
|
|
10
|
+
externalReference: string;
|
|
11
|
+
countryId: number;
|
|
12
|
+
countyName: string;
|
|
13
|
+
cityName: string;
|
|
14
|
+
streetAddress: string;
|
|
15
|
+
nameSearchBehaviour: NameSearchBehaviourType;
|
|
16
|
+
}
|
|
17
|
+
export interface StopsSelectSearchFormProps {
|
|
18
|
+
onSubmit: FormConfig<StopsSearchParams>['onSubmit'];
|
|
19
|
+
view: 'search' | 'selected';
|
|
20
|
+
initialValues?: Partial<StopsSearchParams>;
|
|
21
|
+
}
|
|
22
|
+
export declare const StopsSelectSearchForm: FC<StopsSelectSearchFormProps>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { useClassificationOptions } from "../../store/useClassificationOptions";
|
|
4
|
+
import { TransButton } from "../../i18n/trans/button";
|
|
5
|
+
import { TransField } from "../../i18n/trans/field";
|
|
6
|
+
import { Grid, Stack } from '@mui/material';
|
|
7
|
+
import { FormProvider, SelectField, TextField, useForm } from "../index";
|
|
8
|
+
import { Button, FormControl, Icon } from "../../mui";
|
|
9
|
+
export var NameSearchBehaviourType;
|
|
10
|
+
(function (NameSearchBehaviourType) {
|
|
11
|
+
NameSearchBehaviourType["CONTAINS"] = "contains";
|
|
12
|
+
NameSearchBehaviourType["STARTS_WITH"] = "startsWith";
|
|
13
|
+
NameSearchBehaviourType["EXACT"] = "exact";
|
|
14
|
+
})(NameSearchBehaviourType || (NameSearchBehaviourType = {}));
|
|
15
|
+
export const StopsSelectSearchForm = ({ onSubmit, view, initialValues, }) => {
|
|
16
|
+
const { form, handleSubmit, submitting } = useForm({
|
|
17
|
+
initialValues: {
|
|
18
|
+
...initialValues,
|
|
19
|
+
nameSearchBehaviour: NameSearchBehaviourType.CONTAINS,
|
|
20
|
+
},
|
|
21
|
+
onSubmit,
|
|
22
|
+
subscription: { submitting: true },
|
|
23
|
+
});
|
|
24
|
+
const handleReset = useCallback(() => {
|
|
25
|
+
form.reset();
|
|
26
|
+
}, [form]);
|
|
27
|
+
const countryOptions = useClassificationOptions('COUNTRY');
|
|
28
|
+
const nameSearchBehaviourOptions = useMemo(() => [
|
|
29
|
+
{
|
|
30
|
+
value: NameSearchBehaviourType.CONTAINS,
|
|
31
|
+
label: _jsx(TransField, { i18nKey: "nameSearchBehaviour.CONTAINS" }),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: NameSearchBehaviourType.STARTS_WITH,
|
|
35
|
+
label: _jsx(TransField, { i18nKey: "nameSearchBehaviour.STARTS_WITH" }),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: NameSearchBehaviourType.EXACT,
|
|
39
|
+
label: _jsx(TransField, { i18nKey: "nameSearchBehaviour.EXACT" }),
|
|
40
|
+
},
|
|
41
|
+
], []);
|
|
42
|
+
return (_jsx(FormProvider, { form: form, children: _jsxs(Grid, { container: true, columns: 3, spacing: 2, component: "form", onSubmit: handleSubmit, children: [_jsx(Grid, { item: true, xs: 1, children: _jsx(TextField, { label: _jsx(TransField, { i18nKey: "name" }), name: "name" }) }), view === 'search' && (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 1, children: _jsx(SelectField, { label: _jsx(TransField, { i18nKey: "filteringMethod" }), name: "nameSearchBehaviour", options: nameSearchBehaviourOptions }) }), _jsx(Grid, { item: true, xs: 1, children: _jsx(TextField, { label: _jsx(TransField, { i18nKey: "externalReference" }), name: "externalReference" }) })] })), _jsx(Grid, { item: true, xs: 1, children: _jsx(SelectField, { label: _jsx(TransField, { i18nKey: "country" }), name: "countryId", options: countryOptions, showEmptyOption: true }) }), _jsx(Grid, { item: true, xs: 1, children: _jsx(TextField, { label: _jsx(TransField, { i18nKey: "county" }), name: "countyName" }) }), _jsx(Grid, { item: true, xs: 1, children: _jsx(TextField, { label: _jsx(TransField, { i18nKey: "city" }), name: "cityName" }) }), _jsx(Grid, { item: true, xs: 1, children: _jsx(TextField, { label: _jsx(TransField, { i18nKey: "streetAndHouseNumber" }), name: "streetAddress" }) }), _jsx(Grid, { item: true, xs: "auto", sx: { ml: 'auto' }, children: _jsxs(Stack, { direction: "row", spacing: 2, children: [_jsx(FormControl, { label: "\u00A0", children: _jsx(Button, { sx: { whiteSpace: 'nowrap' }, variant: "text", onClick: handleReset, children: _jsx(TransButton, { i18nKey: "resetFilters" }) }) }), _jsx(FormControl, { label: "\u00A0", children: _jsx(Button, { variant: "contained", type: "submit", startIcon: _jsx(Icon, { name: view === 'search' ? 'search' : 'filter' }), disabled: submitting, "data-testid": "stops-select-search-button", children: _jsx(TransButton, { i18nKey: view === 'search' ? 'search' : 'filter' }) }) })] }) })] }) }));
|
|
43
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FinalFieldAdapterProps, FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { SwitchProps } from "../mui/Switch";
|
|
4
|
+
import { FormControlProps } from "../mui/FormControl";
|
|
5
|
+
export interface SwitchFieldAdapterProps<TValue> extends FinalFieldAdapterProps<TValue, HTMLButtonElement>, Pick<FormControlProps, 'label' | 'labelPosition' | 'helper'>, SwitchProps {
|
|
6
|
+
}
|
|
7
|
+
export interface SwitchFieldProps<TValue> extends FormFieldAdapterProps<TValue>, SwitchProps {
|
|
8
|
+
}
|
|
9
|
+
export declare function SwitchField<TValue>({ name, ...props }: SwitchFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormField, metaError, } from "./FormField";
|
|
3
|
+
import { Switch } from "../mui/Switch";
|
|
4
|
+
import { FormControl } from "../mui/FormControl";
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
function SwitchFieldAdapter(props) {
|
|
7
|
+
const { input, meta, label, labelPosition, helper, onChange, ...field } = props;
|
|
8
|
+
const handleChange = useCallback((event, checked) => {
|
|
9
|
+
onChange?.(event, checked);
|
|
10
|
+
input.onChange(checked);
|
|
11
|
+
}, [input, onChange]);
|
|
12
|
+
return (_jsx(FormControl, { label: label, labelPosition: labelPosition, helper: helper, error: metaError(meta), children: _jsx(Switch, { ...input, ...field, onChange: handleChange }) }));
|
|
13
|
+
}
|
|
14
|
+
export function SwitchField({ name, ...props }) {
|
|
15
|
+
return (_jsx(FormField, { type: "checkbox", name: name, component: SwitchFieldAdapter, ...props }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InputProps } from "../mui/Input";
|
|
3
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
4
|
+
export interface TextFieldProps<TValue> extends FormFieldAdapterProps<TValue>, InputProps {
|
|
5
|
+
}
|
|
6
|
+
export declare function TextField<TValue>({ name, parse: propsParse, format: propsFormat, onChange, ...props }: TextFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { Input } from "../mui/Input";
|
|
4
|
+
import { FormField, metaError } from "./FormField";
|
|
5
|
+
import flow from 'lodash/fp/flow';
|
|
6
|
+
import { trimStart, trimEnd } from "../utils/input";
|
|
7
|
+
import isEmpty from 'is-empty';
|
|
8
|
+
const defaultParseFormat = (value) => value;
|
|
9
|
+
const parseEmpty = (value) => (isEmpty(value) ? undefined : value);
|
|
10
|
+
export function TextField({ name, parse: propsParse = defaultParseFormat, format: propsFormat = defaultParseFormat, onChange, ...props }) {
|
|
11
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
+
const parse = useCallback(flow(trimStart, parseEmpty, propsParse), [
|
|
13
|
+
propsParse,
|
|
14
|
+
]);
|
|
15
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
|
+
const format = useCallback(flow(trimEnd, propsFormat), [propsFormat]);
|
|
17
|
+
return (_jsx(FormField, { name: name, render: ({ input, meta, ...field }) => (_jsx(Input, { ...input, ...field, "data-testid": props['data-testid'], error: metaError(meta), onChange: (value) => {
|
|
18
|
+
onChange?.(value);
|
|
19
|
+
input.onChange(value);
|
|
20
|
+
} })), parse: parse, format: format, formatOnBlur: true, ...props }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { TimeDurationExcludedUnits } from "../utils/timeDuration";
|
|
4
|
+
export interface TimeDurationFieldProps<TValue extends object> extends FormFieldAdapterProps<TValue>, TimeDurationExcludedUnits {
|
|
5
|
+
}
|
|
6
|
+
export declare function TimeDurationField<TValue extends object>({ excludedUnits, name, label, required, disabled, ...props }: TimeDurationFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Grid, Typography } from '@mui/material';
|
|
3
|
+
import { FormField, metaError } from "./FormField";
|
|
4
|
+
import { TIME_UNIT_CONFIGURATION, getTimeDurationUnits, } from "../utils/timeDuration";
|
|
5
|
+
import { TransField } from "../i18n/trans/field";
|
|
6
|
+
import { FormControl } from "../mui";
|
|
7
|
+
import { useCallback, useMemo } from 'react';
|
|
8
|
+
import { Input } from "../mui/Input";
|
|
9
|
+
import { TransError } from "../i18n/trans/error";
|
|
10
|
+
import { useFormContext } from "./";
|
|
11
|
+
import { renderRangeError } from "../helpers";
|
|
12
|
+
import { renderToString } from 'react-dom/server';
|
|
13
|
+
import _isNil from 'lodash/isNil';
|
|
14
|
+
import _kebabCase from 'lodash/kebabCase';
|
|
15
|
+
export function TimeDurationField({ excludedUnits, name, label, required, disabled, ...props }) {
|
|
16
|
+
const units = useMemo(() => getTimeDurationUnits(excludedUnits), [excludedUnits]);
|
|
17
|
+
const { change } = useFormContext();
|
|
18
|
+
const handleValidateUnit = useCallback((value, unit) => {
|
|
19
|
+
const errors = [];
|
|
20
|
+
if (required && (_isNil(value) || value === '')) {
|
|
21
|
+
errors.push(renderToString(_jsx(TransError, { i18nKey: "required" })));
|
|
22
|
+
}
|
|
23
|
+
const { validateRange } = TIME_UNIT_CONFIGURATION[unit];
|
|
24
|
+
const validateRangeError = validateRange &&
|
|
25
|
+
renderRangeError(value, validateRange.min, validateRange.max, unit);
|
|
26
|
+
if (validateRangeError) {
|
|
27
|
+
errors.push(validateRangeError);
|
|
28
|
+
}
|
|
29
|
+
return errors;
|
|
30
|
+
}, [required]);
|
|
31
|
+
const handleValidate = useCallback((value) => {
|
|
32
|
+
const errors = [];
|
|
33
|
+
for (const unit of units) {
|
|
34
|
+
const unitErrors = handleValidateUnit(value?.[unit], unit);
|
|
35
|
+
if (unitErrors) {
|
|
36
|
+
errors.push(...unitErrors);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return errors.length ? [...new Set(errors)] : undefined;
|
|
40
|
+
}, [handleValidateUnit, units]);
|
|
41
|
+
const renderError = useCallback((error) => {
|
|
42
|
+
if (!error) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (!Array.isArray(error)) {
|
|
46
|
+
return error;
|
|
47
|
+
}
|
|
48
|
+
return error.map((item) => (_jsx(Typography, { component: "span", variant: "body2", sx: { display: 'block' }, children: item }, item)));
|
|
49
|
+
}, []);
|
|
50
|
+
return (_jsx(FormField, { name: name, validate: handleValidate, render: ({ input: { value, onBlur }, meta, ...field }) => {
|
|
51
|
+
const error = metaError(meta);
|
|
52
|
+
return (_jsx(FormControl, { ...field, label: label, required: required, error: renderError(error), children: _jsx(Grid, { container: true, columns: units.length, spacing: 2, alignItems: "flex-start", children: units.map((unit) => (_jsx(Grid, { item: true, xs: 1, children: _jsx(Input, { name: `${name}.${unit}`, value: value?.[unit], type: "number", onBlur: onBlur, onChange: (event) => change(`${name}.${unit}`, event.target.value), error: Boolean(error && handleValidateUnit(value?.[unit], unit).length), endAdornment: _jsx(TransField, { i18nKey: TIME_UNIT_CONFIGURATION[unit].i18nKey }), disabled: disabled, "data-testid": _kebabCase(`${name}.${unit}`) }) }, `${name}.${unit}`))) }) }));
|
|
53
|
+
}, ...props }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectFieldProps } from "./SelectField";
|
|
3
|
+
export interface TimeZoneFieldProps extends Omit<SelectFieldProps<string, false>, 'options'> {
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const TimeZoneField: (props: TimeZoneFieldProps) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SelectField } from "./SelectField";
|
|
3
|
+
import { timeZonesNames } from '@vvo/tzdb';
|
|
4
|
+
const options = [...timeZonesNames, 'UTC'].map((name) => ({
|
|
5
|
+
value: name,
|
|
6
|
+
label: name.replace(/_/g, ' '),
|
|
7
|
+
}));
|
|
8
|
+
export const TimeZoneField = (props) => (_jsx(SelectField, { options: options, ...props }));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FinalFieldAdapterProps, FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { FormControlProps, ToggleButtonGroupProps } from "../mui";
|
|
4
|
+
export interface ToggleButtonGroupFieldAdapterProps<TValue> extends FinalFieldAdapterProps<TValue, HTMLButtonElement>, Pick<FormControlProps, 'label' | 'labelPosition' | 'helper'>, ToggleButtonGroupProps<TValue> {
|
|
5
|
+
radio?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ToggleButtonGroupFieldProps<TValue> extends FormFieldAdapterProps<TValue>, ToggleButtonGroupProps<TValue> {
|
|
8
|
+
name: string;
|
|
9
|
+
radio?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function ToggleButtonGroupFieldAdapter<TValue>(props: ToggleButtonGroupFieldAdapterProps<TValue>): JSX.Element;
|
|
12
|
+
export declare function ToggleButtonGroupField<TValue>({ name, ...props }: ToggleButtonGroupFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { FormField, metaError, } from "./FormField";
|
|
4
|
+
import { FormControl, ToggleButtonGroup, } from "../mui";
|
|
5
|
+
export function ToggleButtonGroupFieldAdapter(props) {
|
|
6
|
+
const { input, meta, options, fullWidth, selectAllButton, onChange, radio, ...field } = props;
|
|
7
|
+
const handleChange = useCallback((val) => {
|
|
8
|
+
const value = !val && radio ? input.value : val;
|
|
9
|
+
onChange?.(value);
|
|
10
|
+
input.onChange(value);
|
|
11
|
+
}, [input, onChange, radio]);
|
|
12
|
+
return (_jsx(FormControl, { error: metaError(meta), name: input.name, ...field, children: _jsx(ToggleButtonGroup, { color: "secondary", options: options, fullWidth: fullWidth, selectAllButton: selectAllButton, ...input, onChange: handleChange }) }));
|
|
13
|
+
}
|
|
14
|
+
export function ToggleButtonGroupField({ name, ...props }) {
|
|
15
|
+
return (_jsx(FormField, { name: name, component: ToggleButtonGroupFieldAdapter, ...props }));
|
|
16
|
+
}
|