@centreon/ui 23.10.121 → 24.4.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +59 -41
- package/public/mockServiceWorker.js +2 -2
- package/src/ActionsList/ActionsList.styles.ts +40 -71
- package/src/Button/Icon/index.stories.tsx +1 -1
- package/src/Button/Icon/index.tsx +2 -2
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +9 -5
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Checkbox/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/Dashboard/Dashboard.styles.ts +6 -5
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dashboard/utils.ts +1 -1
- package/src/Dialog/Confirm/index.tsx +10 -2
- package/src/Dialog/UnsavedChanges/index.tsx +21 -20
- package/src/Dialog/UnsavedChanges/translatedLabels.ts +4 -6
- package/src/Dialog/index.tsx +9 -2
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +3 -1
- package/src/Form/Form.cypress.spec.tsx +133 -0
- package/src/Form/Inputs/Grid.tsx +8 -4
- package/src/Form/Inputs/List/Content.tsx +62 -0
- package/src/Form/Inputs/List/List.styles.ts +29 -0
- package/src/Form/Inputs/List/List.tsx +58 -0
- package/src/Form/Inputs/List/useList.ts +81 -0
- package/src/Form/Inputs/Text.tsx +3 -1
- package/src/Form/Inputs/index.tsx +3 -1
- package/src/Form/Inputs/models.ts +23 -13
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +139 -0
- package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
- package/src/Graph/BarStack/BarStack.styles.ts +37 -0
- package/src/Graph/BarStack/BarStack.tsx +14 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +211 -0
- package/src/Graph/BarStack/index.ts +1 -0
- package/src/Graph/BarStack/models.ts +20 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +131 -0
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
- package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
- package/src/Graph/HeatMap/HeatMap.styles.tsx +1 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +20 -10
- package/src/Graph/HeatMap/model.ts +1 -0
- package/src/Graph/Legend/Legend.tsx +21 -0
- package/src/Graph/Legend/index.ts +1 -0
- package/src/Graph/Legend/models.ts +11 -0
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -4
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +3 -1
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +3 -5
- package/src/Graph/LineChart/Header/index.tsx +3 -31
- package/src/Graph/LineChart/Icons/Downtime.tsx +3 -3
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTickGraph.ts +9 -11
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +68 -0
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +27 -0
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +31 -0
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/index.tsx +2 -1
- package/src/Graph/LineChart/InteractiveComponents/index.tsx +132 -17
- package/src/Graph/LineChart/InteractiveComponents/interactionWithGraphAtoms.ts +7 -27
- package/src/Graph/LineChart/Legend/Legend.styles.ts +75 -33
- package/src/Graph/LineChart/Legend/LegendContent.tsx +12 -6
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +66 -27
- package/src/Graph/LineChart/Legend/index.tsx +35 -45
- package/src/Graph/LineChart/Legend/models.ts +5 -0
- package/src/Graph/LineChart/Legend/useLegend.ts +12 -13
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +144 -0
- package/src/Graph/LineChart/LineChart.styles.ts +8 -0
- package/src/Graph/LineChart/LineChart.tsx +118 -117
- package/src/Graph/LineChart/LoadingSkeleton.tsx +2 -2
- package/src/Graph/LineChart/helpers/doc.ts +16 -13
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +17 -2
- package/src/Graph/LineChart/index.tsx +6 -7
- package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +252 -0
- package/src/Graph/LineChart/mockedData/lastDayWithIncompleteValues.json +1320 -0
- package/src/Graph/LineChart/mockedData/lastDayWithNullValues.json +1314 -0
- package/src/Graph/LineChart/models.ts +12 -1
- package/src/Graph/LineChart/useLineChartData.ts +57 -18
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +154 -0
- package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
- package/src/Graph/PieChart/PieChart.styles.ts +39 -0
- package/src/Graph/PieChart/PieChart.tsx +14 -0
- package/src/Graph/PieChart/ResponsivePie.tsx +245 -0
- package/src/Graph/PieChart/index.ts +1 -0
- package/src/Graph/PieChart/models.ts +20 -0
- package/src/Graph/PieChart/useResponsivePie.ts +81 -0
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/Text/Text.styles.ts +12 -1
- package/src/Graph/Text/Text.tsx +17 -12
- package/src/Graph/Tree/DescendantNodes.tsx +88 -0
- package/src/Graph/Tree/Links.tsx +64 -0
- package/src/Graph/Tree/StandaloneTree.tsx +32 -0
- package/src/Graph/Tree/Tree.cypress.spec.tsx +171 -0
- package/src/Graph/Tree/Tree.stories.tsx +144 -0
- package/src/Graph/Tree/Tree.tsx +116 -0
- package/src/Graph/Tree/constants.ts +2 -0
- package/src/Graph/Tree/index.ts +4 -0
- package/src/Graph/Tree/models.ts +52 -0
- package/src/Graph/Tree/stories/contents.tsx +164 -0
- package/src/Graph/Tree/stories/datas.ts +305 -0
- package/src/Graph/Tree/utils.ts +49 -0
- package/src/Graph/common/testUtils.ts +71 -0
- package/src/Graph/common/timeSeries/index.ts +53 -15
- package/src/Graph/common/utils.ts +68 -1
- package/src/Graph/index.ts +4 -0
- package/src/Icon/BaseIcon.tsx +32 -0
- package/src/Icon/DowntimeIcon.tsx +14 -0
- package/src/InputField/Number/Number.cypress.spec.tsx +85 -0
- package/src/InputField/Number/Number.stories.tsx +66 -0
- package/src/InputField/Number/Number.tsx +74 -0
- package/src/InputField/Search/index.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +1 -0
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +1 -0
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +25 -10
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +4 -2
- package/src/InputField/Select/Autocomplete/index.tsx +129 -116
- package/src/InputField/Select/IconPopover/index.tsx +3 -3
- package/src/InputField/Select/index.tsx +15 -2
- package/src/InputField/Text/index.tsx +46 -41
- package/src/Listing/ActionBar/index.tsx +11 -10
- package/src/Listing/Cell/DataCell.styles.ts +3 -0
- package/src/Listing/Cell/DataCell.tsx +23 -5
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +218 -33
- package/src/Listing/Listing.styles.ts +4 -7
- package/src/Listing/Row/Row.tsx +7 -3
- package/src/Listing/index.stories.tsx +39 -5
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +207 -149
- package/src/Listing/models.ts +1 -0
- package/src/Listing/useStyleTable.ts +1 -0
- package/src/Module/LicensedModule/LicenseCheck/index.tsx +24 -9
- package/src/Module/LicensedModule/index.tsx +7 -1
- package/src/Module/Module.cypress.spec.tsx +129 -0
- package/src/Module/index.tsx +2 -4
- package/src/Panel/index.tsx +1 -1
- package/src/PopoverMenu/index.tsx +9 -8
- package/src/RichTextEditor/ContentEditable.tsx +195 -195
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +100 -52
- package/src/RichTextEditor/RichTextEditor.tsx +21 -4
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +21 -20
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +35 -77
- package/src/RichTextEditor/plugins/ToolbarPlugin/FormatButtons.tsx +29 -83
- package/src/RichTextEditor/plugins/ToolbarPlugin/LinkButton.tsx +106 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +155 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +23 -39
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +24 -14
- package/src/RichTextEditor/plugins/ToolbarPlugin/UndoRedoButtons.tsx +6 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +5 -10
- package/src/RichTextEditor/translatedLabels.ts +3 -0
- package/src/SortableItems/index.tsx +2 -7
- package/src/StoryBookThemeProvider/index.tsx +35 -36
- package/src/ThemeProvider/index.tsx +39 -12
- package/src/ThemeProvider/palettes.ts +15 -12
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -3
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
- package/src/TimePeriods/DateTimePickerInput.tsx +56 -19
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/TimePeriods/index.tsx +2 -2
- package/src/TopCounterElements/TopCounterLayout.tsx +3 -0
- package/src/TopCounterElements/useCloseOnLegacyPage.tsx +42 -0
- package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +27 -0
- package/src/Typography/FluidTypography/index.stories.tsx +2 -2
- package/src/Typography/FluidTypography/index.tsx +21 -28
- package/src/Typography/Subtitle.tsx +55 -0
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/buildListingEndpoint/models.ts +2 -1
- package/src/api/customFetch.ts +12 -3
- package/src/api/index.ts +3 -3
- package/src/api/useFetchQuery/index.ts +49 -28
- package/src/api/useGraphQuery/index.ts +26 -5
- package/src/api/useGraphQuery/models.ts +5 -0
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +65 -20
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +76 -0
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +26 -0
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +43 -14
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +24 -1
- package/src/components/DataTable/DataListing.tsx +6 -0
- package/src/components/DataTable/DataTable.cypress.spec.tsx +174 -0
- package/src/components/DataTable/DataTable.stories.tsx +40 -0
- package/src/components/DataTable/DataTable.styles.ts +3 -0
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -60
- package/src/components/DataTable/index.ts +3 -1
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +373 -0
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +119 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +10 -0
- package/src/components/Form/AccessRights/AccessRights.tsx +60 -0
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +14 -0
- package/src/components/Form/AccessRights/Actions/Actions.tsx +81 -0
- package/src/components/Form/AccessRights/Actions/useActions.ts +79 -0
- package/src/components/Form/AccessRights/List/Item.tsx +90 -0
- package/src/components/Form/AccessRights/List/List.styles.tsx +45 -0
- package/src/components/Form/AccessRights/List/List.tsx +52 -0
- package/src/components/Form/AccessRights/List/ListItemSkeleton.tsx +18 -0
- package/src/components/Form/AccessRights/List/ListSkeleton.tsx +22 -0
- package/src/components/Form/AccessRights/List/RemoveAccessRight.tsx +38 -0
- package/src/components/Form/AccessRights/List/StateChip.tsx +28 -0
- package/src/components/Form/AccessRights/List/useItem.ts +64 -0
- package/src/components/Form/AccessRights/Provider.tsx +15 -0
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +50 -0
- package/src/components/Form/AccessRights/ShareInput/ShareInput.styles.ts +17 -0
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +78 -0
- package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +113 -0
- package/src/components/Form/AccessRights/Stats/Stats.tsx +36 -0
- package/src/components/Form/AccessRights/atoms.ts +97 -0
- package/src/components/Form/AccessRights/common/RoleSelectField.styles.tsx +7 -0
- package/src/components/Form/AccessRights/common/RoleSelectField.tsx +45 -0
- package/src/components/Form/AccessRights/models.ts +55 -0
- package/src/components/Form/AccessRights/storiesData.ts +222 -0
- package/src/components/Form/AccessRights/useAccessRightsInitValues.ts +51 -0
- package/src/components/Form/Dashboard/DashboardDuplicationForm.tsx +85 -0
- package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/Form/Dashboard/index.ts +1 -0
- package/src/components/Form/FormActions.tsx +7 -2
- package/src/components/Form/index.ts +2 -1
- package/src/components/ItemComposition/Item.tsx +1 -1
- package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +113 -0
- package/src/components/ItemComposition/ItemComposition.stories.tsx +14 -0
- package/src/components/ItemComposition/ItemComposition.styles.ts +36 -3
- package/src/components/ItemComposition/ItemComposition.tsx +41 -17
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
- package/src/components/Layout/PageLayout/index.ts +3 -1
- package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
- package/src/components/List/Item/ListItem.styles.ts +6 -0
- package/src/components/List/Item/ListItem.tsx +6 -4
- package/src/components/List/Item/Text.tsx +5 -3
- package/src/components/Menu/Button/MenuButton.tsx +4 -2
- package/src/components/Menu/MenuItem.tsx +5 -3
- package/src/components/Menu/MenuItems.tsx +4 -3
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +168 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.stories.tsx +62 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.tsx +87 -0
- package/src/components/Modal/Modal.styles.ts +10 -2
- package/src/components/Modal/ModalActions.tsx +4 -2
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/components/Zoom/Minimap.tsx +127 -0
- package/src/components/Zoom/Zoom.cypress.spec.tsx +246 -0
- package/src/components/Zoom/Zoom.stories.tsx +115 -0
- package/src/components/Zoom/Zoom.styles.tsx +68 -0
- package/src/components/Zoom/Zoom.tsx +61 -0
- package/src/components/Zoom/ZoomContent.tsx +167 -0
- package/src/components/Zoom/constants.ts +2 -0
- package/src/components/Zoom/localPoint.ts +51 -0
- package/src/components/Zoom/models.ts +25 -0
- package/src/components/Zoom/useMinimap.ts +156 -0
- package/src/components/Zoom/useZoom.ts +70 -0
- package/src/components/Zoom/utils.ts +55 -0
- package/src/components/index.ts +1 -0
- package/src/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/fonts/roboto-bold-webfont.woff +0 -0
- package/src/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/fonts/roboto-light-webfont.ttf +0 -0
- package/src/fonts/roboto-light-webfont.woff +0 -0
- package/src/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/fonts/roboto-medium-webfont.woff +0 -0
- package/src/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/fonts/roboto-regular-webfont.woff +0 -0
- package/src/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/index.ts +6 -0
- package/src/queryParameters/url/index.ts +5 -1
- package/src/utils/index.ts +3 -1
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +130 -0
- package/src/utils/useFullscreen/atoms.ts +3 -0
- package/src/utils/useFullscreen/index.ts +2 -0
- package/src/utils/useFullscreen/translatedLabels.ts +1 -0
- package/src/utils/useFullscreen/useFullscreen.ts +73 -0
- package/src/utils/useFullscreen/useFullscreenListener.ts +62 -0
- package/src/utils/useInfiniteScrollListing.ts +31 -8
- package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/utils/useLocaleDateTimeFormat/index.ts +3 -0
- package/src/utils/usePluralizedTranslation.ts +21 -0
- package/src/@assets/icons/downtime.icon.svg +0 -1
- package/src/Graph/LineChart/BasicComponents/LoadingProgress.tsx +0 -46
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/TooltipAnchorPoint.tsx +0 -96
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTooltipAnchorPoint.ts +0 -107
- package/src/Graph/LineChart/Legend/InteractiveValue.tsx +0 -22
- package/src/Graph/LineChart/Legend/Marker.tsx +0 -43
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +0 -99
- package/src/Typography/FluidTypography/useFluidResizeObserver.ts +0 -56
- package/src/components/Form/AccessRights/AccessRights.resource.ts +0 -45
- package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +0 -59
- package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +0 -21
- package/src/components/Form/AccessRights/AccessRightsForm.tsx +0 -67
- package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +0 -80
- package/src/components/Form/AccessRights/Input/AddAction.tsx +0 -31
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +0 -54
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +0 -72
- package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +0 -22
- package/src/components/Form/AccessRights/Input/ContactInputField.tsx +0 -105
- package/src/components/Form/AccessRights/Input/RoleInputField.tsx +0 -29
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +0 -97
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +0 -71
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +0 -51
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +0 -116
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +0 -118
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +0 -26
- package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +0 -28
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +0 -18
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +0 -41
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -52
- package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +0 -18
- package/src/components/Form/AccessRights/common/GroupLabel.tsx +0 -15
- package/src/components/Form/AccessRights/common/Input.styles.ts +0 -48
- package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +0 -11
- package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +0 -57
- package/src/components/Form/AccessRights/index.ts +0 -3
- package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +0 -531
- package/src/components/Form/AccessRights/useAccessRightsForm.tsx +0 -282
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +0 -41
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
- /package/{public → src/Button}/fonts/roboto-bold-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff2 +0 -0
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { not } from 'ramda';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Modal } from '../../components/Modal';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
labelDiscard,
|
|
8
8
|
labelDoYouWantToQuitWithoutResolving,
|
|
9
|
-
labelDoYouWantToQuitWithoutSaving,
|
|
10
9
|
labelDoYouWantToResolveErrors,
|
|
11
10
|
labelDoYouWantToSaveChanges,
|
|
12
11
|
labelResolve,
|
|
13
12
|
labelSave,
|
|
14
13
|
labelThereAreErrorsInTheForm,
|
|
15
|
-
|
|
14
|
+
labelIfYouClickOnDiscard
|
|
16
15
|
} from './translatedLabels';
|
|
17
16
|
|
|
18
17
|
interface Props {
|
|
@@ -40,30 +39,32 @@ const UnsavedChangesDialog = ({
|
|
|
40
39
|
const labelConfirm = isValidForm ? labelSave : labelResolve;
|
|
41
40
|
|
|
42
41
|
const labelMessage = `${
|
|
43
|
-
isValidForm ?
|
|
44
|
-
}. ${
|
|
45
|
-
isValidForm
|
|
46
|
-
? labelDoYouWantToQuitWithoutSaving
|
|
47
|
-
: labelDoYouWantToQuitWithoutResolving
|
|
48
|
-
}`;
|
|
42
|
+
isValidForm ? labelIfYouClickOnDiscard : labelThereAreErrorsInTheForm
|
|
43
|
+
}. ${isValidForm ? '' : labelDoYouWantToQuitWithoutResolving}`;
|
|
49
44
|
|
|
50
45
|
if (not(dialogOpened)) {
|
|
51
46
|
return null;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
labelCancel={t(labelDiscard)}
|
|
58
|
-
labelConfirm={t(labelConfirm)}
|
|
59
|
-
labelMessage={t(labelMessage)}
|
|
60
|
-
labelTitle={t(labelTitle)}
|
|
50
|
+
<Modal
|
|
51
|
+
hasCloseButton
|
|
61
52
|
open={dialogOpened}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
size="medium"
|
|
54
|
+
onClose={closeDialog}
|
|
55
|
+
>
|
|
56
|
+
<Modal.Header>{t(labelTitle)}</Modal.Header>
|
|
57
|
+
<Modal.Body>{t(labelMessage)}</Modal.Body>
|
|
58
|
+
<Modal.Actions
|
|
59
|
+
disabled={isSubmitting}
|
|
60
|
+
labels={{
|
|
61
|
+
cancel: t(labelDiscard),
|
|
62
|
+
confirm: t(labelConfirm)
|
|
63
|
+
}}
|
|
64
|
+
onCancel={discardChanges}
|
|
65
|
+
onConfirm={isValidForm ? saveChanges : closeDialog}
|
|
66
|
+
/>
|
|
67
|
+
</Modal>
|
|
67
68
|
);
|
|
68
69
|
};
|
|
69
70
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export const labelDiscard = 'Discard';
|
|
2
2
|
export const labelResolve = 'Resolve';
|
|
3
|
-
export const
|
|
3
|
+
export const labelIfYouClickOnDiscard =
|
|
4
|
+
'If you click on Discard, your changes will not be saved.';
|
|
4
5
|
export const labelThereAreErrorsInTheForm = 'There are errors in the form';
|
|
5
|
-
export const labelDoYouWantToQuitWithoutSaving =
|
|
6
|
-
'Do you want to quit the form without saving the changes?';
|
|
7
6
|
export const labelDoYouWantToQuitWithoutResolving =
|
|
8
7
|
'Do you want to quit the form without resolving the errors?';
|
|
9
8
|
export const labelDoYouWantToSaveChanges = 'Do you want to save the changes?';
|
|
@@ -14,11 +13,10 @@ export const labelSave = 'Save';
|
|
|
14
13
|
export default {
|
|
15
14
|
labelDiscard,
|
|
16
15
|
labelDoYouWantToQuitWithoutResolving,
|
|
17
|
-
labelDoYouWantToQuitWithoutSaving,
|
|
18
16
|
labelDoYouWantToResolveErrors,
|
|
19
17
|
labelDoYouWantToSaveChanges,
|
|
18
|
+
labelIfYouClickOnDiscard,
|
|
20
19
|
labelResolve,
|
|
21
20
|
labelSave,
|
|
22
|
-
labelThereAreErrorsInTheForm
|
|
23
|
-
labelYourFormHasUnsavedChanges
|
|
21
|
+
labelThereAreErrorsInTheForm
|
|
24
22
|
};
|
package/src/Dialog/index.tsx
CHANGED
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
DialogContent,
|
|
10
10
|
DialogActions,
|
|
11
11
|
DialogProps,
|
|
12
|
-
CircularProgress
|
|
12
|
+
CircularProgress,
|
|
13
|
+
ButtonProps
|
|
13
14
|
} from '@mui/material';
|
|
14
15
|
|
|
15
16
|
import { DataTestAttributes } from '../@types/data-attributes';
|
|
@@ -43,11 +44,13 @@ export type Props = {
|
|
|
43
44
|
dialogTitleClassName?: string;
|
|
44
45
|
labelCancel?: string | null;
|
|
45
46
|
labelConfirm?: string | null;
|
|
46
|
-
labelTitle?:
|
|
47
|
+
labelTitle?: ReactNode;
|
|
47
48
|
onCancel?: () => void;
|
|
48
49
|
onClose?: () => void;
|
|
49
50
|
onConfirm: (event, value?) => void;
|
|
50
51
|
open: boolean;
|
|
52
|
+
restCancelButtonProps?: ButtonProps;
|
|
53
|
+
restConfirmButtonProps?: ButtonProps;
|
|
51
54
|
submitting?: boolean;
|
|
52
55
|
} & DialogProps &
|
|
53
56
|
DataTestAttributes;
|
|
@@ -70,6 +73,8 @@ const Dialog = ({
|
|
|
70
73
|
dialogContentClassName,
|
|
71
74
|
dialogActionsClassName,
|
|
72
75
|
dialogConfirmButtonClassName,
|
|
76
|
+
restCancelButtonProps,
|
|
77
|
+
restConfirmButtonProps,
|
|
73
78
|
...rest
|
|
74
79
|
}: Props): JSX.Element => {
|
|
75
80
|
const { classes, cx } = useStyles({ contentWidth });
|
|
@@ -101,6 +106,7 @@ const Dialog = ({
|
|
|
101
106
|
data-testid="Cancel"
|
|
102
107
|
disabled={cancelDisabled}
|
|
103
108
|
onClick={onCancel}
|
|
109
|
+
{...restCancelButtonProps}
|
|
104
110
|
>
|
|
105
111
|
{labelCancel}
|
|
106
112
|
</Button>
|
|
@@ -113,6 +119,7 @@ const Dialog = ({
|
|
|
113
119
|
disabled={confirmDisabled}
|
|
114
120
|
endIcon={submitting && <CircularProgress size={15} />}
|
|
115
121
|
onClick={onConfirm}
|
|
122
|
+
{...restConfirmButtonProps}
|
|
116
123
|
>
|
|
117
124
|
{labelConfirm}
|
|
118
125
|
</Button>
|
|
@@ -17,7 +17,7 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
17
17
|
logo: {
|
|
18
18
|
alignSelf: 'flex-end',
|
|
19
19
|
height: theme.spacing(11),
|
|
20
|
-
width: '
|
|
20
|
+
width: '239px'
|
|
21
21
|
},
|
|
22
22
|
message: {
|
|
23
23
|
color: theme.palette.text.primary
|
|
@@ -66,9 +66,9 @@ export const FallbackPage: FC<FallbackPageProps> = typedMemo(
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<div className={classes.notAuthorizedContainer}>
|
|
69
|
-
<
|
|
69
|
+
<div className={classes.logo}>
|
|
70
70
|
<CentreonLogo />
|
|
71
|
-
</
|
|
71
|
+
</div>
|
|
72
72
|
<section className={classes.messageBlock}>
|
|
73
73
|
<header>
|
|
74
74
|
<Typography color="primary" fontWeight="bold" variant="h3">
|
|
@@ -98,7 +98,9 @@ const getExtensions = cond([
|
|
|
98
98
|
[T, identity]
|
|
99
99
|
]) as (accept: string) => Array<string>;
|
|
100
100
|
|
|
101
|
-
export const transformFileListToArray = (
|
|
101
|
+
export const transformFileListToArray = (
|
|
102
|
+
files: FileList | null
|
|
103
|
+
): Array<File> =>
|
|
102
104
|
isNil(files)
|
|
103
105
|
? []
|
|
104
106
|
: (Array(files.length)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { object } from 'yup';
|
|
2
|
+
import { faker } from '@faker-js/faker';
|
|
3
|
+
import { useFormikContext } from 'formik';
|
|
4
|
+
|
|
5
|
+
import { Typography } from '@mui/material';
|
|
6
|
+
|
|
7
|
+
import { Button } from '../components';
|
|
8
|
+
|
|
9
|
+
import { Form } from './Form';
|
|
10
|
+
import { InputType } from './Inputs/models';
|
|
11
|
+
|
|
12
|
+
faker.seed(42);
|
|
13
|
+
|
|
14
|
+
const AddItem = ({ addItem }: { addItem: (item) => void }): JSX.Element => {
|
|
15
|
+
const { values } = useFormikContext();
|
|
16
|
+
const add = (): void => {
|
|
17
|
+
addItem({
|
|
18
|
+
alias: faker.company.name(),
|
|
19
|
+
id: values.list.length,
|
|
20
|
+
name: faker.person.firstName()
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Button variant="ghost" onClick={add}>
|
|
26
|
+
Add item
|
|
27
|
+
</Button>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const SortContent = ({
|
|
32
|
+
name,
|
|
33
|
+
alias
|
|
34
|
+
}: {
|
|
35
|
+
alias: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}): JSX.Element => (
|
|
38
|
+
<Typography>
|
|
39
|
+
{name} ({alias})
|
|
40
|
+
</Typography>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const initializeFormList = (): void => {
|
|
44
|
+
cy.mount({
|
|
45
|
+
Component: (
|
|
46
|
+
<Form
|
|
47
|
+
initialValues={{
|
|
48
|
+
list: []
|
|
49
|
+
}}
|
|
50
|
+
inputs={[
|
|
51
|
+
{
|
|
52
|
+
fieldName: 'list',
|
|
53
|
+
group: '',
|
|
54
|
+
label: '',
|
|
55
|
+
list: {
|
|
56
|
+
AddItem,
|
|
57
|
+
SortContent,
|
|
58
|
+
addItemLabel: 'Add an item to the list',
|
|
59
|
+
itemProps: ['id', 'name', 'alias'],
|
|
60
|
+
sortLabel: 'Sort items'
|
|
61
|
+
},
|
|
62
|
+
type: InputType.List
|
|
63
|
+
}
|
|
64
|
+
]}
|
|
65
|
+
submit={cy.stub()}
|
|
66
|
+
validationSchema={object()}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe('Form list', () => {
|
|
73
|
+
beforeEach(initializeFormList);
|
|
74
|
+
|
|
75
|
+
it('adds an element to the list', () => {
|
|
76
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
77
|
+
cy.contains('Sort items').should('be.visible');
|
|
78
|
+
|
|
79
|
+
cy.contains('Add item').click();
|
|
80
|
+
|
|
81
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
82
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
83
|
+
cy.contains('Christelle (Schinner - Wiegand)').should('be.visible');
|
|
84
|
+
|
|
85
|
+
cy.makeSnapshot();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('sorts elements in the list', () => {
|
|
89
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
90
|
+
cy.contains('Sort items').should('be.visible');
|
|
91
|
+
|
|
92
|
+
cy.contains('Add item').click();
|
|
93
|
+
cy.contains('Add item').click();
|
|
94
|
+
|
|
95
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
96
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
97
|
+
cy.contains('Carley (Satterfield, Miller and Metz)').should('be.visible');
|
|
98
|
+
cy.findByLabelText('sort-1').should('be.visible');
|
|
99
|
+
cy.findByLabelText('delete-1').should('be.visible');
|
|
100
|
+
cy.contains('Anderson (Crist - Bradtke)').should('be.visible');
|
|
101
|
+
|
|
102
|
+
cy.moveSortableElementUsingAriaLabel({
|
|
103
|
+
ariaLabel: 'sort-0',
|
|
104
|
+
direction: 'down'
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
cy.contains('Carley (Satterfield, Miller and Metz)').should('be.visible');
|
|
108
|
+
cy.contains('Anderson (Crist - Bradtke)').should('be.visible');
|
|
109
|
+
|
|
110
|
+
cy.makeSnapshot();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('removes an element from the list', () => {
|
|
114
|
+
cy.contains('Add an item to the list').should('be.visible');
|
|
115
|
+
cy.contains('Sort items').should('be.visible');
|
|
116
|
+
|
|
117
|
+
cy.contains('Add item').click();
|
|
118
|
+
cy.contains('Add item').click();
|
|
119
|
+
|
|
120
|
+
cy.findByLabelText('sort-0').should('be.visible');
|
|
121
|
+
cy.findByLabelText('delete-0').should('be.visible');
|
|
122
|
+
cy.contains('Lea (Streich - Hartmann)').should('be.visible');
|
|
123
|
+
cy.findByLabelText('sort-1').should('be.visible');
|
|
124
|
+
cy.findByLabelText('delete-1').should('be.visible');
|
|
125
|
+
cy.contains('Akeem (Quigley LLC)').should('be.visible');
|
|
126
|
+
|
|
127
|
+
cy.findByLabelText('delete-0').click();
|
|
128
|
+
|
|
129
|
+
cy.contains('Lea (Streich - Hartmann)').should('not.exist');
|
|
130
|
+
|
|
131
|
+
cy.makeSnapshot();
|
|
132
|
+
});
|
|
133
|
+
});
|
package/src/Form/Inputs/Grid.tsx
CHANGED
|
@@ -8,15 +8,18 @@ interface StylesProps {
|
|
|
8
8
|
alignItems?: string;
|
|
9
9
|
columns?: number;
|
|
10
10
|
gridTemplateColumns?: string;
|
|
11
|
+
isColumnDirection?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const useStyles = makeStyles<StylesProps>()(
|
|
14
|
-
(theme, { columns, gridTemplateColumns, alignItems }) => ({
|
|
15
|
+
(theme, { columns, gridTemplateColumns, alignItems, isColumnDirection }) => ({
|
|
15
16
|
gridFields: {
|
|
16
17
|
alignItems: alignItems || 'flex-start',
|
|
17
18
|
columnGap: theme.spacing(4),
|
|
18
|
-
display: 'grid',
|
|
19
|
-
gridTemplateColumns:
|
|
19
|
+
display: isColumnDirection ? 'flex' : 'grid',
|
|
20
|
+
gridTemplateColumns: isColumnDirection
|
|
21
|
+
? undefined
|
|
22
|
+
: gridTemplateColumns || `repeat(${columns}, 1fr)`,
|
|
20
23
|
rowGap: theme.spacing(2)
|
|
21
24
|
}
|
|
22
25
|
})
|
|
@@ -26,7 +29,8 @@ const Grid = ({ grid }: InputPropsWithoutGroup): JSX.Element => {
|
|
|
26
29
|
const { classes, cx } = useStyles({
|
|
27
30
|
alignItems: grid?.alignItems,
|
|
28
31
|
columns: grid?.columns.length,
|
|
29
|
-
gridTemplateColumns: grid?.gridTemplateColumns
|
|
32
|
+
gridTemplateColumns: grid?.gridTemplateColumns,
|
|
33
|
+
isColumnDirection: grid?.isColumnDirection
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
const className = grid?.className || '';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { DraggableSyntheticListeners } from '@dnd-kit/core';
|
|
4
|
+
|
|
5
|
+
import KrilinIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
6
|
+
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
7
|
+
|
|
8
|
+
import { IconButton } from '../../../components';
|
|
9
|
+
|
|
10
|
+
import { useListStyles } from './List.styles';
|
|
11
|
+
|
|
12
|
+
export interface ContentProps {
|
|
13
|
+
attributes;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
deleteItem: (id: string) => () => void;
|
|
16
|
+
id: string;
|
|
17
|
+
isDragging: boolean;
|
|
18
|
+
isInDragOverlay?: boolean;
|
|
19
|
+
itemRef: React.RefObject<HTMLDivElement>;
|
|
20
|
+
listeners: DraggableSyntheticListeners;
|
|
21
|
+
name: string;
|
|
22
|
+
style;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Content = ({
|
|
26
|
+
listeners,
|
|
27
|
+
itemRef,
|
|
28
|
+
attributes,
|
|
29
|
+
style,
|
|
30
|
+
isDragging,
|
|
31
|
+
id,
|
|
32
|
+
children,
|
|
33
|
+
deleteItem
|
|
34
|
+
}: ContentProps): JSX.Element => {
|
|
35
|
+
const { classes } = useListStyles();
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classes.content}
|
|
40
|
+
ref={itemRef}
|
|
41
|
+
{...attributes}
|
|
42
|
+
style={style}
|
|
43
|
+
>
|
|
44
|
+
<IconButton
|
|
45
|
+
data-dragging={isDragging}
|
|
46
|
+
size="small"
|
|
47
|
+
{...listeners}
|
|
48
|
+
aria-label={`sort-${id}`}
|
|
49
|
+
icon={<KrilinIndicatorIcon fontSize="small" />}
|
|
50
|
+
/>
|
|
51
|
+
<div className={classes.innerContent}>{children}</div>
|
|
52
|
+
<IconButton
|
|
53
|
+
aria-label={`delete-${id}`}
|
|
54
|
+
icon={<DeleteOutlineIcon color="error" fontSize="small" />}
|
|
55
|
+
size="small"
|
|
56
|
+
onClick={deleteItem(id)}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default Content;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
export const useListStyles = makeStyles()((theme) => ({
|
|
4
|
+
content: {
|
|
5
|
+
'& [data-dragging="false"]': {
|
|
6
|
+
cursor: 'grab'
|
|
7
|
+
},
|
|
8
|
+
'& [data-dragging="true"]': {
|
|
9
|
+
cursor: 'grabbing'
|
|
10
|
+
},
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
borderBottom: `1px dashed ${theme.palette.action.disabledBackground}`,
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
padding: theme.spacing(1, 0)
|
|
16
|
+
},
|
|
17
|
+
innerContent: {
|
|
18
|
+
flexGrow: 1
|
|
19
|
+
},
|
|
20
|
+
items: {
|
|
21
|
+
maxHeight: theme.spacing(16),
|
|
22
|
+
overflowY: 'auto'
|
|
23
|
+
},
|
|
24
|
+
list: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
27
|
+
gap: theme.spacing(1)
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
import { closestCenter } from '@dnd-kit/core';
|
|
4
|
+
import { verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { InputPropsWithoutGroup } from '../models';
|
|
8
|
+
import { SortableItems, Subtitle } from '../../..';
|
|
9
|
+
|
|
10
|
+
import { useList } from './useList';
|
|
11
|
+
import { useListStyles } from './List.styles';
|
|
12
|
+
import Content, { ContentProps } from './Content';
|
|
13
|
+
|
|
14
|
+
const List = ({
|
|
15
|
+
list,
|
|
16
|
+
fieldName
|
|
17
|
+
}: InputPropsWithoutGroup): JSX.Element | null => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { classes } = useListStyles();
|
|
20
|
+
|
|
21
|
+
const { addItem, sortList, sortedList, deleteItem } = useList({ fieldName });
|
|
22
|
+
|
|
23
|
+
const { AddItem, addItemLabel, sortLabel, SortContent, itemProps } = list as {
|
|
24
|
+
AddItem: ComponentType<{ addItem }>;
|
|
25
|
+
SortContent: ComponentType;
|
|
26
|
+
addItemLabel?: string;
|
|
27
|
+
itemProps: Array<string>;
|
|
28
|
+
sortLabel?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={classes.list}>
|
|
33
|
+
{addItemLabel && <Subtitle>{t(addItemLabel)}</Subtitle>}
|
|
34
|
+
<AddItem addItem={addItem} />
|
|
35
|
+
{sortLabel && <Subtitle>{t(sortLabel)}</Subtitle>}
|
|
36
|
+
<div className={classes.items}>
|
|
37
|
+
<SortableItems
|
|
38
|
+
updateSortableItemsOnItemsChange
|
|
39
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
40
|
+
Content={(props: Omit<ContentProps, 'children' | 'deleteItem'>) => (
|
|
41
|
+
<Content {...props} deleteItem={deleteItem}>
|
|
42
|
+
<SortContent {...props} />
|
|
43
|
+
</Content>
|
|
44
|
+
)}
|
|
45
|
+
collisionDetection={closestCenter}
|
|
46
|
+
itemProps={itemProps}
|
|
47
|
+
items={sortedList}
|
|
48
|
+
sortingStrategy={verticalListSortingStrategy}
|
|
49
|
+
onDragEnd={({ items }): void => {
|
|
50
|
+
sortList(items);
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default List;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FormikValues, useFormikContext } from 'formik';
|
|
4
|
+
import {
|
|
5
|
+
append,
|
|
6
|
+
equals,
|
|
7
|
+
inc,
|
|
8
|
+
isEmpty,
|
|
9
|
+
pluck,
|
|
10
|
+
prop,
|
|
11
|
+
reject,
|
|
12
|
+
sortBy
|
|
13
|
+
} from 'ramda';
|
|
14
|
+
|
|
15
|
+
import { SelectEntry } from '../../..';
|
|
16
|
+
|
|
17
|
+
interface UseListState {
|
|
18
|
+
addItem: (newItem: SelectEntry) => void;
|
|
19
|
+
deleteItem: (id: string) => () => void;
|
|
20
|
+
sortList: (items: Array<string>) => void;
|
|
21
|
+
sortedList: Array<unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const useList = ({ fieldName }): UseListState => {
|
|
25
|
+
const { values, setFieldValue } = useFormikContext<FormikValues>();
|
|
26
|
+
const maxOrder = useRef(0);
|
|
27
|
+
|
|
28
|
+
const list = values[fieldName];
|
|
29
|
+
|
|
30
|
+
const sortedList = useMemo(
|
|
31
|
+
() =>
|
|
32
|
+
sortBy(prop('order'), list).map(({ id, ...props }) => ({
|
|
33
|
+
id: `${id}`,
|
|
34
|
+
...props
|
|
35
|
+
})),
|
|
36
|
+
[list]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const addItem = (newItem: SelectEntry): void => {
|
|
40
|
+
setFieldValue(
|
|
41
|
+
fieldName,
|
|
42
|
+
append(
|
|
43
|
+
{
|
|
44
|
+
...newItem,
|
|
45
|
+
id: (newItem as SelectEntry).id as number,
|
|
46
|
+
order: inc(maxOrder.current)
|
|
47
|
+
},
|
|
48
|
+
list
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const deleteItem = (id: string) => (): void => {
|
|
54
|
+
const newItems = reject((item) => equals(Number(id), item.id))(list);
|
|
55
|
+
|
|
56
|
+
setFieldValue(fieldName, newItems);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const sortList = (items: Array<string>): void => {
|
|
60
|
+
const newOrderedList = items.map((itemId, idx) => {
|
|
61
|
+
const item = sortedList.find(({ id }) => equals(id, itemId));
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
...item,
|
|
65
|
+
id: Number(item?.id),
|
|
66
|
+
order: inc(idx)
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
setFieldValue(fieldName, newOrderedList);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
maxOrder.current = isEmpty(list) ? 0 : Math.max(...pluck('order', list));
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
addItem,
|
|
77
|
+
deleteItem,
|
|
78
|
+
sortList,
|
|
79
|
+
sortedList
|
|
80
|
+
};
|
|
81
|
+
};
|
package/src/Form/Inputs/Text.tsx
CHANGED
|
@@ -29,7 +29,8 @@ const Text = ({
|
|
|
29
29
|
getRequired,
|
|
30
30
|
change,
|
|
31
31
|
additionalMemoProps,
|
|
32
|
-
text
|
|
32
|
+
text,
|
|
33
|
+
autoFocus
|
|
33
34
|
}: InputPropsWithoutGroup): JSX.Element => {
|
|
34
35
|
const { t } = useTranslation();
|
|
35
36
|
|
|
@@ -109,6 +110,7 @@ const Text = ({
|
|
|
109
110
|
fullWidth
|
|
110
111
|
EndAdornment={EndAdornment}
|
|
111
112
|
ariaLabel={t(label) || ''}
|
|
113
|
+
autoFocus={autoFocus}
|
|
112
114
|
dataTestId={dataTestId || ''}
|
|
113
115
|
disabled={disabled}
|
|
114
116
|
error={error as string | undefined}
|
|
@@ -21,6 +21,7 @@ import CheckboxGroup from './CheckboxGroup';
|
|
|
21
21
|
import Checkbox from './Checkbox';
|
|
22
22
|
import Custom from './Custom';
|
|
23
23
|
import LoadingSkeleton from './LoadingSkeleton';
|
|
24
|
+
import List from './List/List';
|
|
24
25
|
|
|
25
26
|
export const getInput = R.cond<
|
|
26
27
|
Array<InputType>,
|
|
@@ -66,6 +67,7 @@ export const getInput = R.cond<
|
|
|
66
67
|
R.equals(InputType.CheckboxGroup) as (b: InputType) => boolean,
|
|
67
68
|
R.always(CheckboxGroup)
|
|
68
69
|
],
|
|
70
|
+
[R.equals(InputType.List) as (b: InputType) => boolean, R.always(List)],
|
|
69
71
|
[R.T, R.always(TextInput)]
|
|
70
72
|
]);
|
|
71
73
|
|
|
@@ -185,7 +187,7 @@ const Inputs = ({
|
|
|
185
187
|
const hasGroupTitle = R.not(R.isNil(groupName));
|
|
186
188
|
|
|
187
189
|
const groupProps = hasGroupTitle
|
|
188
|
-
? R.find(R.propEq('name'
|
|
190
|
+
? R.find(R.propEq(groupName, 'name'), groups)
|
|
189
191
|
: ({} as Group);
|
|
190
192
|
|
|
191
193
|
const isFirstElement = areGroupsOpen || R.equals(index, 0);
|
|
@@ -6,19 +6,20 @@ import { SelectEntry } from '../../InputField/Select';
|
|
|
6
6
|
import { ConditionsSearchParameter } from '../../api/buildListingEndpoint/models';
|
|
7
7
|
|
|
8
8
|
export enum InputType {
|
|
9
|
-
Switch,
|
|
10
|
-
Radio,
|
|
11
|
-
Text,
|
|
12
|
-
SingleAutocomplete,
|
|
13
|
-
MultiAutocomplete,
|
|
14
|
-
Password,
|
|
15
|
-
SingleConnectedAutocomplete,
|
|
16
|
-
MultiConnectedAutocomplete,
|
|
17
|
-
FieldsTable,
|
|
18
|
-
Grid,
|
|
19
|
-
Custom,
|
|
20
|
-
Checkbox,
|
|
21
|
-
CheckboxGroup
|
|
9
|
+
Switch = 0,
|
|
10
|
+
Radio = 1,
|
|
11
|
+
Text = 2,
|
|
12
|
+
SingleAutocomplete = 3,
|
|
13
|
+
MultiAutocomplete = 4,
|
|
14
|
+
Password = 5,
|
|
15
|
+
SingleConnectedAutocomplete = 6,
|
|
16
|
+
MultiConnectedAutocomplete = 7,
|
|
17
|
+
FieldsTable = 8,
|
|
18
|
+
Grid = 9,
|
|
19
|
+
Custom = 10,
|
|
20
|
+
Checkbox = 11,
|
|
21
|
+
CheckboxGroup = 12,
|
|
22
|
+
List = 13
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface FieldsTableGetRequiredProps {
|
|
@@ -32,6 +33,7 @@ export interface InputProps {
|
|
|
32
33
|
additionalLabel?: string | JSX.Element;
|
|
33
34
|
additionalLabelClassName?: string;
|
|
34
35
|
additionalMemoProps?: Array<unknown>;
|
|
36
|
+
autoFocus?: boolean;
|
|
35
37
|
autocomplete?: {
|
|
36
38
|
creatable?: boolean;
|
|
37
39
|
options: Array<SelectEntry>;
|
|
@@ -71,11 +73,19 @@ export interface InputProps {
|
|
|
71
73
|
className?: string;
|
|
72
74
|
columns: Array<Omit<InputProps, 'group'>>;
|
|
73
75
|
gridTemplateColumns?: string;
|
|
76
|
+
isColumnDirection?: boolean;
|
|
74
77
|
};
|
|
75
78
|
group: string;
|
|
76
79
|
hideInput?: (values: FormikValues) => boolean;
|
|
77
80
|
inputClassName?: string;
|
|
78
81
|
label: string;
|
|
82
|
+
list?: {
|
|
83
|
+
AddItem: React.ComponentType<{ addItem }>;
|
|
84
|
+
SortContent: React.ComponentType<object>;
|
|
85
|
+
addItemLabel?: string;
|
|
86
|
+
itemProps: Array<string>;
|
|
87
|
+
sortLabel?: string;
|
|
88
|
+
};
|
|
79
89
|
radio?: {
|
|
80
90
|
options?: Array<{
|
|
81
91
|
label: string | JSX.Element;
|