@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,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ControllerProps } from 'react-hook-form';
|
|
3
|
+
import { InputProps } from "../mui/Input";
|
|
4
|
+
export interface FormInputProps extends Omit<InputProps, 'ref'> {
|
|
5
|
+
name: string;
|
|
6
|
+
rules?: ControllerProps['rules'];
|
|
7
|
+
}
|
|
8
|
+
export declare const FormInput: FC<FormInputProps>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "../mui/Input";
|
|
3
|
+
import { FormController } from "./FormController";
|
|
4
|
+
export const FormInput = ({ name, rules, required, ...props }) => (_jsx(FormController, { name: name, rules: rules, required: required, render: ({ field: { onChange, value }, fieldState: { error } }) => (_jsx(Input, { value: value, labelPosition: "top", error: error?.message, onChange: onChange, required: required, ...props })) }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ControllerProps } from 'react-hook-form';
|
|
3
|
+
import { RadioGroupProps } from "../mui/RadioGroup";
|
|
4
|
+
export interface FormRadioGroupProps extends Omit<RadioGroupProps, 'options'> {
|
|
5
|
+
name: string;
|
|
6
|
+
rules?: ControllerProps['rules'];
|
|
7
|
+
required?: boolean;
|
|
8
|
+
options?: RadioGroupProps['options'];
|
|
9
|
+
}
|
|
10
|
+
export declare const FormRadioGroup: FC<FormRadioGroupProps>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RadioGroup } from "../mui/RadioGroup";
|
|
3
|
+
import { FormController } from "./FormController";
|
|
4
|
+
export const FormRadioGroup = ({ name, options, label, rules, labelPosition = 'top', required, ...props }) => {
|
|
5
|
+
return (_jsx(FormController, { name: name, rules: rules, required: required, render: ({ field: { onChange, value }, fieldState: { error } }) => (_jsx(RadioGroup, { label: label, options: options, defaultValue: value, onChange: (event, value) => onChange(value), inline: true, error: error?.message, labelPosition: labelPosition, required: required, ...props })) }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ControllerProps } from 'react-hook-form';
|
|
3
|
+
import { SelectProps, SelectOption, SelectValue } from "../mui/Select";
|
|
4
|
+
export interface FormSelectProps<TValue extends SelectValue = SelectValue, Multi extends boolean = false> extends Partial<SelectProps<TValue, Multi>> {
|
|
5
|
+
name: string;
|
|
6
|
+
rules?: ControllerProps['rules'];
|
|
7
|
+
options: Array<SelectOption<TValue>>;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
multiple?: Multi;
|
|
10
|
+
}
|
|
11
|
+
export declare function FormSelect<TValue extends SelectValue = SelectValue, Multi extends boolean = false>({ name, label, rules, options, required, ...props }: FormSelectProps<TValue, Multi>): JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Select } from "../mui/Select";
|
|
4
|
+
import { FormController } from "./FormController";
|
|
5
|
+
export function FormSelect({ name, label, rules, options, required, ...props }) {
|
|
6
|
+
const { multiple } = props;
|
|
7
|
+
const defaultValue = useMemo(() => (multiple ? [] : null), [multiple]);
|
|
8
|
+
return (_jsx(FormController, { name: name, rules: rules, required: required, defaultValue: defaultValue, render: ({ field: { onChange, value }, fieldState: { error } }) => (_jsx(Select, { labelPosition: "top", label: label, value: value, options: options, error: error?.message, onChange: onChange, required: required, ...props })) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ControllerProps } from 'react-hook-form';
|
|
3
|
+
import { SwitchProps } from "../mui/Switch";
|
|
4
|
+
export interface FormSwitchProps extends SwitchProps {
|
|
5
|
+
name: string;
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
rules?: ControllerProps['rules'];
|
|
8
|
+
labelPosition?: 'top' | 'left';
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const FormSwitch: FC<FormSwitchProps>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch } from "../mui/Switch";
|
|
3
|
+
import { FormControl } from "../mui/FormControl";
|
|
4
|
+
import { FormController } from "./FormController";
|
|
5
|
+
export const FormSwitch = ({ name, label, rules, className, labelPosition = 'top', ...props }) => (_jsx(FormController, { name: name, rules: rules, render: ({ field: { onChange, value }, fieldState: { error } }) => (_jsx(FormControl, { label: label, labelPosition: labelPosition, error: error?.message, className: className, children: _jsx(Switch, { checked: value, onChange: onChange, ...props }) })) }));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormSelect } from "./FormSelect";
|
|
3
|
+
import { timeZonesNames } from '@vvo/tzdb';
|
|
4
|
+
const options = timeZonesNames.map((name) => ({
|
|
5
|
+
value: name,
|
|
6
|
+
label: name.replace(/_/g, ' '),
|
|
7
|
+
}));
|
|
8
|
+
export const FormTimeZoneSelect = (props) => (_jsx(FormSelect, { ...props, options: options }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./FormController";
|
|
2
|
+
export * from "./FormCheckbox";
|
|
3
|
+
export * from "./FormCheckboxGroup";
|
|
4
|
+
export * from "./FormDatepicker";
|
|
5
|
+
export * from "./FormInput";
|
|
6
|
+
export * from "./FormRadioGroup";
|
|
7
|
+
export * from "./FormSelect";
|
|
8
|
+
export * from "./FormSwitch";
|
|
9
|
+
export * from "./FormTimeZoneSelect";
|
package/fields/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./FormController";
|
|
2
|
+
export * from "./FormCheckbox";
|
|
3
|
+
export * from "./FormCheckboxGroup";
|
|
4
|
+
export * from "./FormDatepicker";
|
|
5
|
+
export * from "./FormInput";
|
|
6
|
+
export * from "./FormRadioGroup";
|
|
7
|
+
export * from "./FormSelect";
|
|
8
|
+
export * from "./FormSwitch";
|
|
9
|
+
export * from "./FormTimeZoneSelect";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import type { FieldArrayRenderProps } from 'react-final-form-arrays';
|
|
4
|
+
export interface ArrayFieldProps<FieldValue = unknown> extends FormFieldAdapterProps<FieldValue> {
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
removeButtonLabel?: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
accessor?: (value: FieldValue) => string;
|
|
9
|
+
appendValue?: Partial<FieldValue>;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
validateRequired?: boolean;
|
|
13
|
+
maxItems?: number;
|
|
14
|
+
render: (fields: {
|
|
15
|
+
name: string;
|
|
16
|
+
index: number;
|
|
17
|
+
removeButton: ReactNode;
|
|
18
|
+
pushButton: ReactNode;
|
|
19
|
+
} & FieldArrayRenderProps<FieldValue, HTMLElement>) => {
|
|
20
|
+
field: ReactNode;
|
|
21
|
+
canRemove?: boolean;
|
|
22
|
+
canPush?: boolean;
|
|
23
|
+
};
|
|
24
|
+
children?: (props: FieldArrayRenderProps<FieldValue, HTMLElement>) => ReactNode;
|
|
25
|
+
onBeforeRemove?: (index: number) => boolean | Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export declare function ArrayField<FieldValue>({ name, label, appendValue, validate: validateProp, required, validateRequired, render, onBeforeRemove, removeButtonLabel, path, maxItems, children, }: ArrayFieldProps<FieldValue>): JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useCallback, useMemo } from 'react';
|
|
3
|
+
import { metaError } from "./FormField";
|
|
4
|
+
import { useFieldArray } from 'react-final-form-arrays';
|
|
5
|
+
import { validate } from "./validate";
|
|
6
|
+
import { Button, Grid, IconButton, Typography } from '@mui/material';
|
|
7
|
+
import { Icon, ReadOnlyField } from "../mui";
|
|
8
|
+
import { TransError } from "../i18n/trans/error";
|
|
9
|
+
import { TransButton } from "../i18n/trans/button";
|
|
10
|
+
import _kebabCase from 'lodash/kebabCase';
|
|
11
|
+
export function ArrayField({ name, label, appendValue = {}, validate: validateProp, required, validateRequired = true, render, onBeforeRemove, removeButtonLabel = true, path, maxItems, children, }) {
|
|
12
|
+
const array = useFieldArray(name, {
|
|
13
|
+
validate: validate.compose(validateProp, required &&
|
|
14
|
+
validateRequired &&
|
|
15
|
+
validate.required(_jsx(TransError, { i18nKey: "required" }))),
|
|
16
|
+
});
|
|
17
|
+
const fields = useMemo(() => (array.fields.length ? array.fields : ['']), [array.fields]);
|
|
18
|
+
const error = metaError(array.meta);
|
|
19
|
+
const { length, remove, push } = array.fields;
|
|
20
|
+
const claimedIds = new Set();
|
|
21
|
+
const rowKeys = fields.map((rowName, index) => {
|
|
22
|
+
const id = array.fields.value?.[index]?.id;
|
|
23
|
+
if (id === undefined || id === null || claimedIds.has(id)) {
|
|
24
|
+
return rowName;
|
|
25
|
+
}
|
|
26
|
+
claimedIds.add(id);
|
|
27
|
+
return `${name}-${id}`;
|
|
28
|
+
});
|
|
29
|
+
const handlePush = useCallback((event) => {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
if (Array.isArray(error))
|
|
32
|
+
return;
|
|
33
|
+
const hasCustomAppend = appendValue !== undefined &&
|
|
34
|
+
(typeof appendValue !== 'object' ||
|
|
35
|
+
(appendValue && Object.keys(appendValue).length > 0));
|
|
36
|
+
const next = hasCustomAppend
|
|
37
|
+
? appendValue
|
|
38
|
+
: path
|
|
39
|
+
? { [path]: '' } // object mode
|
|
40
|
+
: ''; // primitive mode (string)
|
|
41
|
+
push(next);
|
|
42
|
+
}, [appendValue, error, push, path]);
|
|
43
|
+
const handleRemove = useCallback(async (event) => {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
const { index } = event.currentTarget.dataset;
|
|
46
|
+
const shouldRemove = onBeforeRemove
|
|
47
|
+
? await onBeforeRemove(Number(index))
|
|
48
|
+
: true;
|
|
49
|
+
if (shouldRemove) {
|
|
50
|
+
remove(Number(index));
|
|
51
|
+
}
|
|
52
|
+
}, [onBeforeRemove, remove]);
|
|
53
|
+
const pushButton = useMemo(() => (_jsx(Button, { variant: "text", startIcon: _jsx(Icon, { name: "plus" }), onClick: handlePush, sx: { pl: 0, pr: 0 }, "data-testid": `${name ? _kebabCase(name) + '-' : ''}add-new`, children: _jsx(TransButton, { i18nKey: "addNew" }) })), [handlePush, name]);
|
|
54
|
+
return (_jsxs(_Fragment, { children: [label && (_jsx(Typography, { variant: "body2", gutterBottom: true, sx: { fontWeight: 500 }, children: label })), fields.map((name, index) => {
|
|
55
|
+
const removeButton = (_jsx(IconButton, { "data-index": index, onClick: handleRemove, children: _jsx(Icon, { name: "delete" }) }));
|
|
56
|
+
const result = {
|
|
57
|
+
canRemove: true,
|
|
58
|
+
canPush: true,
|
|
59
|
+
removeButton,
|
|
60
|
+
pushButton,
|
|
61
|
+
...render({ name, index, removeButton, pushButton, ...array }),
|
|
62
|
+
};
|
|
63
|
+
return (_jsxs(Fragment, { children: [name && (_jsxs(Grid, { container: true, alignItems: "end", sx: { mb: 2 }, children: [_jsx(Grid, { item: true, xs: "auto", sx: { flex: `1 !important` }, children: result.field }), result.canRemove && (_jsx(Grid, { item: true, sx: { pl: 1, alignSelf: 'flex-start' }, children: _jsx(ReadOnlyField, { children: result.removeButton, ...(removeButtonLabel && {
|
|
64
|
+
label: _jsx(_Fragment, { children: "\u00A0" }),
|
|
65
|
+
}) }) }))] })), (maxItems === undefined || fields.length < maxItems) &&
|
|
66
|
+
(index === length - 1 || !length) &&
|
|
67
|
+
result.canPush && _jsx(Typography, { children: result.pushButton })] }, rowKeys[index]));
|
|
68
|
+
}), children && children(array)] }));
|
|
69
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FinalFieldAdapterProps, FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { CheckboxProps } from "../mui/Checkbox";
|
|
4
|
+
export declare type CheckboxFieldAdapterProps<TValue> = FinalFieldAdapterProps<TValue, HTMLInputElement> & Omit<CheckboxProps, 'ref'>;
|
|
5
|
+
export interface CheckboxFieldProps<TValue> extends FormFieldAdapterProps<TValue>, CheckboxProps {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function CheckboxField<TValue>(props: CheckboxFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { FormField, metaError, } from "./FormField";
|
|
4
|
+
import { Checkbox } from "../mui/Checkbox";
|
|
5
|
+
function CheckboxFieldAdapter({ input, meta, onChange, ...props }) {
|
|
6
|
+
const handleChange = useCallback((event) => {
|
|
7
|
+
onChange?.(event);
|
|
8
|
+
input.onChange(event.target.checked);
|
|
9
|
+
}, [input, onChange]);
|
|
10
|
+
return (_jsx(Checkbox, { ...input, ...props, error: metaError(meta), onChange: handleChange }));
|
|
11
|
+
}
|
|
12
|
+
export function CheckboxField(props) {
|
|
13
|
+
return (_jsx(FormField, { type: "checkbox", component: CheckboxFieldAdapter, ...props }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckboxGroupProps } from "../mui/Checkbox/CheckboxGroup";
|
|
3
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
4
|
+
export interface CheckboxGroupFieldProps<TValue extends object> extends FormFieldAdapterProps<TValue>, CheckboxGroupProps<TValue> {
|
|
5
|
+
}
|
|
6
|
+
export declare function CheckboxGroupField<TValue extends object>({ name, options, ...props }: CheckboxGroupFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useForm } from 'react-final-form';
|
|
4
|
+
import { CheckboxGroup } from "../mui/Checkbox/CheckboxGroup";
|
|
5
|
+
import { FormField, metaError } from "./FormField";
|
|
6
|
+
export function CheckboxGroupField({ name, options, ...props }) {
|
|
7
|
+
const { change } = useForm();
|
|
8
|
+
const handleChangeValue = useCallback(({ name, value }) => {
|
|
9
|
+
change(name, value);
|
|
10
|
+
}, [change]);
|
|
11
|
+
const handleChange = useCallback((event, value) => {
|
|
12
|
+
handleChangeValue(name ? { name, value } : event.target);
|
|
13
|
+
}, [handleChangeValue, name]);
|
|
14
|
+
return (_jsx(FormField, { name: name, render: ({ input, meta, ...field }) => (_jsx(CheckboxGroup, { name: name, ...input, onChange: handleChange, options: options, ...field, error: metaError(meta) })), ...props }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ConditionProps<Value = any> {
|
|
3
|
+
when: string;
|
|
4
|
+
is: Value;
|
|
5
|
+
children: ((condition: boolean) => ReactNode | false) | ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const ConditionField: <Value>({ when, is, children, }: ConditionProps<Value>) => JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from 'react-final-form';
|
|
3
|
+
const conditionIs = (is, value) => {
|
|
4
|
+
if (Array.isArray(is)) {
|
|
5
|
+
return is.includes(value);
|
|
6
|
+
}
|
|
7
|
+
if (typeof is === 'function') {
|
|
8
|
+
return is(value);
|
|
9
|
+
}
|
|
10
|
+
if (typeof is === 'string' && typeof value === 'string') {
|
|
11
|
+
return value.toLowerCase() === is.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
return value === is;
|
|
14
|
+
};
|
|
15
|
+
export const ConditionField = ({ when, is, children, }) => (_jsx(Field, { name: when, subscription: { value: true }, children: ({ input: { value } }) => {
|
|
16
|
+
const conditioned = conditionIs(is, value);
|
|
17
|
+
return typeof children === 'function'
|
|
18
|
+
? children(conditioned) || null
|
|
19
|
+
: conditioned && children;
|
|
20
|
+
} }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { type ReadOnlyFieldProps, type SelectOption } from "../mui";
|
|
4
|
+
export interface ContentFieldProps<TValue> extends FormFieldAdapterProps<TValue>, Omit<ReadOnlyFieldProps, 'component'> {
|
|
5
|
+
options?: Array<SelectOption<TValue>>;
|
|
6
|
+
}
|
|
7
|
+
export declare function ContentField<TValue>({ name, ...props }: ContentFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { FormField, metaError, } from "./FormField";
|
|
4
|
+
import { ReadOnlyField } from "../mui";
|
|
5
|
+
import { Typography } from '@mui/material';
|
|
6
|
+
function ContentFieldAdapter(props) {
|
|
7
|
+
const { options, input, meta, label, labelPosition, helper } = props;
|
|
8
|
+
const value = useMemo(() => options
|
|
9
|
+
? options.find(({ value }) => input.value === value)?.label
|
|
10
|
+
: input.value, [input.value, options]);
|
|
11
|
+
return (_jsx(ReadOnlyField, { label: label, labelPosition: labelPosition, helper: helper, error: metaError(meta), children: _jsx(Typography, { variant: "body1", children: value }) }));
|
|
12
|
+
}
|
|
13
|
+
export function ContentField({ name, ...props }) {
|
|
14
|
+
return _jsx(FormField, { name: name, component: ContentFieldAdapter, ...props });
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormField, metaError } from "./FormField";
|
|
3
|
+
import { FormControl } from "../mui/FormControl";
|
|
4
|
+
import { Counter } from "../mui/Counter";
|
|
5
|
+
export function CounterField({ name, ...props }) {
|
|
6
|
+
return (_jsx(FormField, { name: name, defaultValue: props.min ?? 0, render: ({ input, meta, ...field }) => (_jsx(FormControl, { error: metaError(meta), children: _jsx(Counter, { ...input, ...field }) })), ...props }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { DatePickerProps, DatePickerValue } from "../mui/DatePicker";
|
|
4
|
+
export interface DateFieldProps<TValue extends string, Range extends boolean> extends FormFieldAdapterProps<TValue, DatePickerValue<Range>>, DatePickerProps<Range> {
|
|
5
|
+
maxRange?: number;
|
|
6
|
+
dateFormatFocused?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function DateField<TValue extends string, Range extends boolean>({ name, dateFormat, dateFormatFocused, showTimeInput, minDate, maxDate, withPortal, dateType, selectsRange, maxRange, onCalendarOpen, onCalendarClose, onChange, wallClock, ...props }: DateFieldProps<TValue, Range>): JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { addDays } from 'date-fns';
|
|
3
|
+
import { FormField, metaError } from "./FormField";
|
|
4
|
+
import { DatePicker, isRangeValue, } from "../mui/DatePicker";
|
|
5
|
+
import { useCallback, useState, useMemo } from 'react';
|
|
6
|
+
import { formatDate, getEndOfDate, isoDateTimeFormat, parseDateString, } from "../utils/date";
|
|
7
|
+
import { fromWallClockDate, stringifyWallClock } from "../utils/wallClock";
|
|
8
|
+
export function DateField({ name, dateFormat, dateFormatFocused, showTimeInput, minDate, maxDate, withPortal, dateType, selectsRange, maxRange, onCalendarOpen, onCalendarClose, onChange, wallClock, ...props }) {
|
|
9
|
+
const [isCalendarShown, setIsCalendarShown] = useState(false);
|
|
10
|
+
const preparedDateFormat = useMemo(() => (isCalendarShown ? dateFormatFocused : dateFormat) ?? dateFormat, [dateFormat, dateFormatFocused, isCalendarShown]);
|
|
11
|
+
const getMaxDate = useCallback((value) => {
|
|
12
|
+
if (!maxDate && isRangeValue(selectsRange) && maxRange && value.from) {
|
|
13
|
+
return getEndOfDate(addDays(value.from, maxRange));
|
|
14
|
+
}
|
|
15
|
+
return maxDate;
|
|
16
|
+
}, [maxDate, maxRange, selectsRange]);
|
|
17
|
+
const onParse = useCallback((date) => {
|
|
18
|
+
if (wallClock && !isRangeValue(selectsRange)) {
|
|
19
|
+
const parts = fromWallClockDate(date);
|
|
20
|
+
return (parts ? stringifyWallClock(parts) : undefined);
|
|
21
|
+
}
|
|
22
|
+
return ((isRangeValue(selectsRange)
|
|
23
|
+
? Object.entries(date ?? {}).reduce((acc, [key, date]) => ({
|
|
24
|
+
...acc,
|
|
25
|
+
[key]: formatDate(date, isoDateTimeFormat) || undefined,
|
|
26
|
+
}), {})
|
|
27
|
+
: formatDate(date, isoDateTimeFormat)) || undefined);
|
|
28
|
+
}, [selectsRange, wallClock]);
|
|
29
|
+
const onFormat = useCallback((value) => {
|
|
30
|
+
if (wallClock && !isRangeValue(selectsRange)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
return (isRangeValue(selectsRange)
|
|
34
|
+
? Object.entries(value ?? {}).reduce((acc, [key, value]) => ({
|
|
35
|
+
...acc,
|
|
36
|
+
[key]: parseDateString(value),
|
|
37
|
+
}), {})
|
|
38
|
+
: parseDateString(value));
|
|
39
|
+
}, [selectsRange, wallClock]);
|
|
40
|
+
const handleCalendarOpen = useCallback(() => {
|
|
41
|
+
onCalendarOpen?.();
|
|
42
|
+
setIsCalendarShown(true);
|
|
43
|
+
}, [onCalendarOpen]);
|
|
44
|
+
const handleCalendarClose = useCallback(() => {
|
|
45
|
+
onCalendarClose?.();
|
|
46
|
+
setIsCalendarShown(false);
|
|
47
|
+
}, [onCalendarClose]);
|
|
48
|
+
return (_jsx(FormField, { name: name, parse: onParse, format: onFormat, render: ({ input: { onBlur: _, value, onChange: formOnChange, ...input }, meta, ...field }) => (_jsx(DatePicker, { ...input, ...field, onChange: (value, event) => {
|
|
49
|
+
formOnChange(value);
|
|
50
|
+
onChange?.(value, event);
|
|
51
|
+
}, value: value, withPortal: withPortal, minDate: minDate, maxDate: getMaxDate(value), error: metaError(meta), dateFormat: preparedDateFormat, dateType: dateType, showTimeInput: showTimeInput, selectsRange: selectsRange, wallClock: wallClock, onCalendarOpen: handleCalendarOpen, onCalendarClose: handleCalendarClose })), ...props }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DatePickerProps, ReadOnlyFieldProps } from "../mui";
|
|
3
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
4
|
+
export interface DatesArrayFieldProps<TValue extends string> extends FormFieldAdapterProps<TValue>, Pick<ReadOnlyFieldProps, 'label' | 'className'>, DatePickerProps {
|
|
5
|
+
format?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function DatesArrayField<TValue extends string>({ validate: validateProp, required, disabled, readOnly, name, label, className, format, disablePast, disableFuture, ...props }: DatesArrayFieldProps<TValue>): JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { makeStyles } from '@mui/styles';
|
|
4
|
+
import { ChipSecondarySmall, DatePicker, Icon, ReadOnlyField, theme, } from "../mui";
|
|
5
|
+
import { useFieldArray } from 'react-final-form-arrays';
|
|
6
|
+
import { metaError } from "./FormField";
|
|
7
|
+
import { Grid } from '@mui/material';
|
|
8
|
+
import { formatDate } from "../utils";
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import { validate } from "./validate";
|
|
11
|
+
import { TransError } from "../i18n/trans/error";
|
|
12
|
+
import { useCallback, useMemo } from 'react';
|
|
13
|
+
import { useFormContext } from "./index";
|
|
14
|
+
import IconButton from '@mui/material/IconButton';
|
|
15
|
+
const useStyles = makeStyles(() => ({
|
|
16
|
+
root: {},
|
|
17
|
+
control: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
backgroundColor: theme.palette.common.white,
|
|
20
|
+
borderRadius: 4,
|
|
21
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
22
|
+
'&.Mui-error': {
|
|
23
|
+
borderColor: theme.palette.error.main,
|
|
24
|
+
},
|
|
25
|
+
'&.Mui-focused': {
|
|
26
|
+
borderColor: theme.palette.action.focus,
|
|
27
|
+
boxShadow: `0 0 3px ${theme.palette.action.focus}`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
grid: {
|
|
31
|
+
margin: 0,
|
|
32
|
+
fontSize: 0,
|
|
33
|
+
padding: `2px 0 6px`,
|
|
34
|
+
},
|
|
35
|
+
button: {
|
|
36
|
+
margin: 0,
|
|
37
|
+
borderRadius: 0,
|
|
38
|
+
boxShadow: `inset 1px 0 0 ${theme.palette.divider}`,
|
|
39
|
+
'&:hover': { background: 'unset' },
|
|
40
|
+
},
|
|
41
|
+
}), {
|
|
42
|
+
name: 'DatesArrayField',
|
|
43
|
+
});
|
|
44
|
+
export function DatesArrayField({ validate: validateProp, required, disabled, readOnly, name, label, className, format = 'yyyy-MM-dd', disablePast, disableFuture, ...props }) {
|
|
45
|
+
const defaultValue = useMemo(() => [], []);
|
|
46
|
+
const { fields, meta } = useFieldArray(name, {
|
|
47
|
+
defaultValue,
|
|
48
|
+
validate: validate.compose(validateProp, required && validate.required(_jsx(TransError, { i18nKey: "required" }))),
|
|
49
|
+
});
|
|
50
|
+
const highlightDates = useMemo(() => fields.value?.map((date) => new Date(date)), [fields.value]);
|
|
51
|
+
const error = useMemo(() => metaError(meta), [meta]);
|
|
52
|
+
const [focused, setFocused] = useState(false);
|
|
53
|
+
const { focus, blur } = useFormContext();
|
|
54
|
+
const handleFocus = useCallback(() => {
|
|
55
|
+
setFocused(true);
|
|
56
|
+
focus(name);
|
|
57
|
+
}, [focus, name]);
|
|
58
|
+
const handleBlur = useCallback(() => {
|
|
59
|
+
setFocused(false);
|
|
60
|
+
blur(name);
|
|
61
|
+
}, [blur, name]);
|
|
62
|
+
const handleDelete = useCallback((index) => {
|
|
63
|
+
fields.remove(index);
|
|
64
|
+
handleBlur();
|
|
65
|
+
}, [fields, handleBlur]);
|
|
66
|
+
const handleChange = useCallback((date, event) => {
|
|
67
|
+
if (!event)
|
|
68
|
+
return;
|
|
69
|
+
fields.push(formatDate(date, format));
|
|
70
|
+
handleBlur();
|
|
71
|
+
}, [fields, format, handleBlur]);
|
|
72
|
+
const classes = useStyles();
|
|
73
|
+
return (_jsx(ReadOnlyField, { label: label, className: classNames(classes.root, className), error: error, required: required, children: _jsx(DatePicker, { disabled: disabled, customInput: _jsxs("div", { className: classNames(classes.control, {
|
|
74
|
+
'Mui-error': Boolean(error),
|
|
75
|
+
'Mui-focused': focused,
|
|
76
|
+
}), children: [_jsx(Grid, { className: classes.grid, container: true, spacing: 0.5, children: (fields?.value ?? defaultValue).map((value, index) => (_jsx(Grid, { item: true, children: _jsx(ChipSecondarySmall, { "data-index": index, label: value, variant: "filled", ...(![disabled, readOnly].includes(true) && {
|
|
77
|
+
onDelete: () => handleDelete(index),
|
|
78
|
+
}) }) }, `${name}[${index}]`))) }), !readOnly && (_jsx(IconButton, { className: classes.button, disabled: disabled, edge: "end", "aria-label": "Open calendar", children: _jsx(Icon, { name: "calendar", color: "secondary", disabled: disabled }) }))] }), onCalendarOpen: handleFocus, onCalendarClose: handleBlur, onChange: handleChange, highlightDates: highlightDates, excludeDates: highlightDates, disablePast: disablePast, disableFuture: disableFuture, shouldCloseOnSelect: false, readOnly: readOnly, ...props }) }));
|
|
79
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectFieldProps } from "./";
|
|
3
|
+
import { SelectOption, SelectValue } from "../mui/Select";
|
|
4
|
+
export interface DependSelectFieldProps<D extends SelectValue> extends Omit<SelectFieldProps<D, false>, 'options'> {
|
|
5
|
+
depend: string;
|
|
6
|
+
options: (value: any) => Promise<unknown> | Promise<Array<SelectOption<D>>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const DependSelectField: <D extends SelectValue>({ name, depend, options: fetchOptions, ...props }: DependSelectFieldProps<D>) => JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { SelectField } from "./";
|
|
4
|
+
import { useField } from 'react-final-form';
|
|
5
|
+
export const DependSelectField = ({ name, depend, options: fetchOptions, ...props }) => {
|
|
6
|
+
const [options, setOptions] = useState([]);
|
|
7
|
+
const dependValue = useField(depend).input.value;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
fetchOptions(dependValue).then((options) => options && Array.isArray(options) && setOptions(options));
|
|
10
|
+
}, [dependValue, fetchOptions]);
|
|
11
|
+
return _jsx(SelectField, { name: name, options: options, ...props });
|
|
12
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Editor } from "../components/Editor/Editor";
|
|
3
|
+
import { FormControl } from "../mui";
|
|
4
|
+
import { FormField, metaError } from "./FormField";
|
|
5
|
+
export function EditorField({ name, ...props }) {
|
|
6
|
+
return (_jsx(FormField, { name: name, render: ({ input, meta, ...field }) => (_jsx(FormControl, { error: metaError(meta), ...field, children: _jsx(Editor, { ...input }) })), ...props }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { type FileInputCommonProps, FileInputMultipleProps, FileInputSingleProps, type FileInputValue } from "../mui/FileInput";
|
|
4
|
+
export interface FileFieldMultipleProps<T extends FileInputValue> extends FileInputMultipleProps<T>, FormFieldAdapterProps<T> {
|
|
5
|
+
}
|
|
6
|
+
export interface FileFieldSingleProps<T extends FileInputValue> extends FileInputSingleProps<T>, FormFieldAdapterProps<T> {
|
|
7
|
+
}
|
|
8
|
+
export interface FileFieldCommonProps<T extends FileInputValue> extends FileInputCommonProps<T>, FormFieldAdapterProps<T> {
|
|
9
|
+
onDownload?: (fileName: string, fileId?: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function FileField<T extends FileInputValue>(props: FileFieldMultipleProps<T>): JSX.Element;
|
|
12
|
+
export declare function FileField<T extends FileInputValue>(props: FileFieldSingleProps<T>): JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FormField, metaError } from "./FormField";
|
|
3
|
+
import { FormControl } from "../mui";
|
|
4
|
+
import { FileInput, } from "../mui/FileInput";
|
|
5
|
+
import useId from '@mui/utils/useId';
|
|
6
|
+
export function FileField({ name, onDownload, ...props }) {
|
|
7
|
+
const inputId = useId(name);
|
|
8
|
+
return (_jsx(FormField, { name: name, render: ({ input: { value, multiple, ...input }, meta, accept, ...field }) => (_jsx(FormControl, { error: metaError(meta), ...field, children: _jsx(FileInput, { id: inputId, accept: accept, ...(!multiple && { multiple, value: value }), ...(multiple && { multiple, value: value }), ...input, onDownload: onDownload }) })), ...props }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FieldProps } from 'react-final-form';
|
|
3
|
+
import { FieldRenderProps } from 'react-final-form';
|
|
4
|
+
export interface FormFieldProps<FieldValue, T extends HTMLElement = HTMLElement, InputValue = FieldValue, RP extends FieldRenderProps<FieldValue, T, InputValue> = FieldRenderProps<FieldValue, T, InputValue>> extends FieldProps<FieldValue, RP, T, InputValue> {
|
|
5
|
+
name: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
validateRequired?: boolean;
|
|
8
|
+
positive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare type InputElement = HTMLInputElement | HTMLTextAreaElement;
|
|
11
|
+
export interface FinalFieldAdapterProps<FieldValue, TInput extends HTMLElement = InputElement> extends Pick<FieldRenderProps<FieldValue, TInput>, 'input' | 'meta'> {
|
|
12
|
+
}
|
|
13
|
+
export declare type FormFieldAdapterProps<FieldValue, InputValue = FieldValue> = Omit<FormFieldProps<FieldValue, HTMLElement, InputValue>, 'component'>;
|
|
14
|
+
export declare function FormField<FieldValue, InputValue = FieldValue>(props: FormFieldProps<FieldValue, HTMLElement, InputValue>): JSX.Element;
|
|
15
|
+
export declare function metaError<FieldValue>(meta: FieldRenderProps<FieldValue>['meta']): any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Field } from 'react-final-form';
|
|
4
|
+
import { validate } from "./validate";
|
|
5
|
+
import isFunction from 'lodash/isFunction';
|
|
6
|
+
import { TransError } from "../i18n/trans/error";
|
|
7
|
+
export function FormField(props) {
|
|
8
|
+
const { required } = props;
|
|
9
|
+
const { validate: validateProp, validateRequired = true, positive, email, ...rest } = props;
|
|
10
|
+
const handleValidate = useMemo(() => validate.compose(validateProp, required &&
|
|
11
|
+
validateRequired &&
|
|
12
|
+
validate.required(_jsx(TransError, { i18nKey: "required" })), positive && validate.positive(_jsx(TransError, { i18nKey: "positive" })), email && validate.email(_jsx(TransError, { i18nKey: "email" }))), [email, positive, required, validateProp, validateRequired]);
|
|
13
|
+
return (_jsx(Field, { ...rest, validate: handleValidate }));
|
|
14
|
+
}
|
|
15
|
+
const parseError = (error) => isFunction(error) ? error() : error;
|
|
16
|
+
export function metaError(meta) {
|
|
17
|
+
const { touched, error, dirtySinceLastSubmit, submitError } = meta;
|
|
18
|
+
const errorMessage = (touched && parseError(error)) || (!dirtySinceLastSubmit && submitError);
|
|
19
|
+
return typeof errorMessage === 'boolean' && errorMessage === false
|
|
20
|
+
? null
|
|
21
|
+
: errorMessage;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { FormFieldAdapterProps } from "./FormField";
|
|
3
|
+
import { ButtonProps, ModalProps } from "../mui";
|
|
4
|
+
import { ArrayFieldProps } from "./ArrayField";
|
|
5
|
+
export interface ModalFieldArrayProps<FieldValue = unknown> extends ArrayFieldProps<FieldValue>, FormFieldAdapterProps<FieldValue> {
|
|
6
|
+
modalLabel?: ReactNode;
|
|
7
|
+
onSave?: ButtonProps['onClick'];
|
|
8
|
+
onClose?: ModalProps['onClose'];
|
|
9
|
+
modalProps?: Partial<ModalProps>;
|
|
10
|
+
onBeforeRemove?: (index: number) => boolean | Promise<boolean>;
|
|
11
|
+
showAllItems?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function ModalFieldArray<FieldValue>(props: ModalFieldArrayProps<FieldValue>): JSX.Element;
|