@deviceinsight/ng-ui-components 6.18.0 → 6.19.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/lib/cjs/__mocks__/i18n.d.ts +12 -4
- package/lib/cjs/__mocks__/i18n.d.ts.map +1 -1
- package/lib/cjs/__mocks__/i18n.js +20 -7
- package/lib/cjs/components/chart/Chart.d.ts +1 -1
- package/lib/cjs/components/colorpicker/ColorPickerPopper.d.ts +1 -1
- package/lib/cjs/components/colorpicker/GradientColorPicker.d.ts +2 -2
- package/lib/cjs/components/colorpicker/GridColorPicker.d.ts +2 -2
- package/lib/cjs/components/contentHeader/ContentHeader.d.ts +1 -1
- package/lib/cjs/components/contentHeader/ContentHeader.d.ts.map +1 -1
- package/lib/cjs/components/infobox/InfoBox.d.ts +1 -1
- package/lib/cjs/components/infobox/InfoBox.d.ts.map +1 -1
- package/lib/cjs/components/input/DateInput.d.ts +2 -2
- package/lib/cjs/components/input/DateInput.d.ts.map +1 -1
- package/lib/cjs/components/input/DateTimeInput.d.ts +2 -2
- package/lib/cjs/components/input/DateTimeInput.d.ts.map +1 -1
- package/lib/cjs/components/input/SelectWithSearch.d.ts +4 -1
- package/lib/cjs/components/input/SelectWithSearch.d.ts.map +1 -1
- package/lib/cjs/components/input/SelectWithSearch.js +25 -4
- package/lib/cjs/components/input/SelectWithSearchAsync.d.ts +1 -1
- package/lib/cjs/components/input/UrnInput.d.ts +1 -1
- package/lib/cjs/components/input/ValidatedTextInput.d.ts +1 -1
- package/lib/cjs/components/input/__tests__/DateInput.spec.js +24 -24
- package/lib/cjs/components/input/__tests__/DateTimeInput.spec.js +5 -4
- package/lib/cjs/components/input/__tests__/SelectWithSearchAsync.spec.js +12 -11
- package/lib/cjs/components/link/RouteLink.d.ts +2 -2
- package/lib/cjs/components/link/RouteLink.d.ts.map +1 -1
- package/lib/cjs/components/multiMenu/MultiMenu.d.ts +1 -1
- package/lib/cjs/components/multiMenu/components/MultiMenuItem.d.ts +1 -1
- package/lib/cjs/components/pagination/Pagination.d.ts +1 -1
- package/lib/cjs/components/pagination/__tests__/Pagination.spec.js +70 -70
- package/lib/cjs/components/periodpicker/PeriodPicker.d.ts +2 -2
- package/lib/cjs/components/periodpicker/PeriodPicker.d.ts.map +1 -1
- package/lib/cjs/components/periodpicker/components/Inputs.d.ts +2 -2
- package/lib/cjs/components/periodpicker/components/Inputs.d.ts.map +1 -1
- package/lib/cjs/components/periodpicker/components/Menu.d.ts +2 -2
- package/lib/cjs/components/periodpicker/components/Menu.d.ts.map +1 -1
- package/lib/cjs/components/periodpicker/components/MonthPicker.d.ts +2 -2
- package/lib/cjs/components/periodpicker/components/MonthPicker.d.ts.map +1 -1
- package/lib/cjs/components/periodpicker/usePeriodName.d.ts +1 -1
- package/lib/cjs/components/periodpicker/usePeriodName.d.ts.map +1 -1
- package/lib/cjs/components/periodpicker/usePeriodName.js +2 -2
- package/lib/cjs/components/prompt/Prompt.d.ts +2 -2
- package/lib/cjs/components/prompt/Prompt.d.ts.map +1 -1
- package/lib/cjs/components/reactable/Reactable.d.ts +1 -1
- package/lib/cjs/components/reactable/helpers/ReactableTable.d.ts +1 -1
- package/lib/cjs/components/reactable/helpers/ReactableTableHeader.d.ts +2 -2
- package/lib/cjs/components/reactable/helpers/ReactableTableHeader.d.ts.map +1 -1
- package/lib/cjs/components/reactable/helpers/ReactableTableRow.d.ts +1 -1
- package/lib/cjs/components/reactableWithClientSidePagination/ReactableWithClientSidePagination.d.ts +1 -1
- package/lib/cjs/components/reactableWithClientSidePagination/__tests__/ReactableWithClientSidePagination.spec.js +64 -72
- package/lib/cjs/components/slider/Slider.d.ts +2 -2
- package/lib/cjs/components/slider/Slider.d.ts.map +1 -1
- package/lib/cjs/components/svg/SvgImage.d.ts +2 -2
- package/lib/cjs/components/svg/SvgImage.d.ts.map +1 -1
- package/lib/cjs/components/svg/utils/__tests__/getMutableNodeList.spec.js +11 -10
- package/lib/cjs/components/tabs/RouteTabs.d.ts +1 -1
- package/lib/cjs/components/tabs/RouteTabs.d.ts.map +1 -1
- package/lib/cjs/components/tabs/RouteTabs.js +2 -2
- package/lib/cjs/components/treeview/TreeView.d.ts +1 -1
- package/lib/cjs/components/treeview/components/Node.d.ts +1 -1
- package/lib/cjs/components/treeview/components/NodeInfo.d.ts +1 -1
- package/lib/cjs/components/upload/FileUpload.d.ts +1 -1
- package/lib/cjs/components/upload/ImageUpload.d.ts +1 -1
- package/lib/cjs/modules/messageBox/messageBox.d.ts +2 -2
- package/lib/cjs/modules/messageBox/messageBox.d.ts.map +1 -1
- package/lib/esm/__mocks__/i18n.d.ts +12 -4
- package/lib/esm/__mocks__/i18n.d.ts.map +1 -1
- package/lib/esm/__mocks__/i18n.js +20 -5
- package/lib/esm/components/chart/Chart.d.ts +1 -1
- package/lib/esm/components/colorpicker/ColorPickerPopper.d.ts +1 -1
- package/lib/esm/components/colorpicker/GradientColorPicker.d.ts +2 -2
- package/lib/esm/components/colorpicker/GridColorPicker.d.ts +2 -2
- package/lib/esm/components/contentHeader/ContentHeader.d.ts +1 -1
- package/lib/esm/components/contentHeader/ContentHeader.d.ts.map +1 -1
- package/lib/esm/components/infobox/InfoBox.d.ts +1 -1
- package/lib/esm/components/infobox/InfoBox.d.ts.map +1 -1
- package/lib/esm/components/input/DateInput.d.ts +2 -2
- package/lib/esm/components/input/DateInput.d.ts.map +1 -1
- package/lib/esm/components/input/DateTimeInput.d.ts +2 -2
- package/lib/esm/components/input/DateTimeInput.d.ts.map +1 -1
- package/lib/esm/components/input/SelectWithSearch.d.ts +4 -1
- package/lib/esm/components/input/SelectWithSearch.d.ts.map +1 -1
- package/lib/esm/components/input/SelectWithSearch.js +25 -4
- package/lib/esm/components/input/SelectWithSearchAsync.d.ts +1 -1
- package/lib/esm/components/input/UrnInput.d.ts +1 -1
- package/lib/esm/components/input/ValidatedTextInput.d.ts +1 -1
- package/lib/esm/components/input/__tests__/DateInput.spec.js +4 -4
- package/lib/esm/components/input/__tests__/DateTimeInput.spec.js +1 -0
- package/lib/esm/components/input/__tests__/SelectWithSearchAsync.spec.js +3 -2
- package/lib/esm/components/link/RouteLink.d.ts +2 -2
- package/lib/esm/components/link/RouteLink.d.ts.map +1 -1
- package/lib/esm/components/multiMenu/MultiMenu.d.ts +1 -1
- package/lib/esm/components/multiMenu/components/MultiMenuItem.d.ts +1 -1
- package/lib/esm/components/pagination/Pagination.d.ts +1 -1
- package/lib/esm/components/pagination/__tests__/Pagination.spec.js +53 -53
- package/lib/esm/components/periodpicker/PeriodPicker.d.ts +2 -2
- package/lib/esm/components/periodpicker/PeriodPicker.d.ts.map +1 -1
- package/lib/esm/components/periodpicker/components/Inputs.d.ts +2 -2
- package/lib/esm/components/periodpicker/components/Inputs.d.ts.map +1 -1
- package/lib/esm/components/periodpicker/components/Menu.d.ts +2 -2
- package/lib/esm/components/periodpicker/components/Menu.d.ts.map +1 -1
- package/lib/esm/components/periodpicker/components/MonthPicker.d.ts +2 -2
- package/lib/esm/components/periodpicker/components/MonthPicker.d.ts.map +1 -1
- package/lib/esm/components/periodpicker/usePeriodName.d.ts +1 -1
- package/lib/esm/components/periodpicker/usePeriodName.d.ts.map +1 -1
- package/lib/esm/components/periodpicker/usePeriodName.js +1 -1
- package/lib/esm/components/prompt/Prompt.d.ts +2 -2
- package/lib/esm/components/prompt/Prompt.d.ts.map +1 -1
- package/lib/esm/components/reactable/Reactable.d.ts +1 -1
- package/lib/esm/components/reactable/helpers/ReactableTable.d.ts +1 -1
- package/lib/esm/components/reactable/helpers/ReactableTableHeader.d.ts +2 -2
- package/lib/esm/components/reactable/helpers/ReactableTableHeader.d.ts.map +1 -1
- package/lib/esm/components/reactable/helpers/ReactableTableRow.d.ts +1 -1
- package/lib/esm/components/reactableWithClientSidePagination/ReactableWithClientSidePagination.d.ts +1 -1
- package/lib/esm/components/reactableWithClientSidePagination/__tests__/ReactableWithClientSidePagination.spec.js +55 -63
- package/lib/esm/components/slider/Slider.d.ts +2 -2
- package/lib/esm/components/slider/Slider.d.ts.map +1 -1
- package/lib/esm/components/svg/SvgImage.d.ts +2 -2
- package/lib/esm/components/svg/SvgImage.d.ts.map +1 -1
- package/lib/esm/components/svg/utils/__tests__/getMutableNodeList.spec.js +1 -0
- package/lib/esm/components/tabs/RouteTabs.d.ts +1 -1
- package/lib/esm/components/tabs/RouteTabs.d.ts.map +1 -1
- package/lib/esm/components/tabs/RouteTabs.js +2 -2
- package/lib/esm/components/treeview/TreeView.d.ts +1 -1
- package/lib/esm/components/treeview/components/Node.d.ts +1 -1
- package/lib/esm/components/treeview/components/NodeInfo.d.ts +1 -1
- package/lib/esm/components/upload/FileUpload.d.ts +1 -1
- package/lib/esm/components/upload/ImageUpload.d.ts +1 -1
- package/lib/esm/modules/messageBox/messageBox.d.ts +2 -2
- package/lib/esm/modules/messageBox/messageBox.d.ts.map +1 -1
- package/lib/esm/src/__mocks__/i18n.d.ts +13 -0
- package/lib/esm/src/__mocks__/i18n.d.ts.map +1 -0
- package/lib/esm/src/__mocks__/i18n.js +20 -0
- package/lib/esm/src/components/chart/Chart.d.ts +38 -0
- package/lib/esm/src/components/chart/Chart.d.ts.map +1 -0
- package/lib/esm/src/components/chart/Chart.js +202 -0
- package/lib/esm/src/components/colorpicker/ColorPickerPopper.d.ts +24 -0
- package/lib/esm/src/components/colorpicker/ColorPickerPopper.d.ts.map +1 -0
- package/lib/esm/src/components/colorpicker/ColorPickerPopper.js +46 -0
- package/lib/esm/src/components/colorpicker/GradientColorPicker.d.ts +63 -0
- package/lib/esm/src/components/colorpicker/GradientColorPicker.d.ts.map +1 -0
- package/lib/esm/src/components/colorpicker/GradientColorPicker.js +125 -0
- package/lib/esm/src/components/colorpicker/GridColorPicker.d.ts +41 -0
- package/lib/esm/src/components/colorpicker/GridColorPicker.d.ts.map +1 -0
- package/lib/esm/src/components/colorpicker/GridColorPicker.js +30 -0
- package/lib/esm/src/components/contentHeader/ContentHeader.d.ts +25 -0
- package/lib/esm/src/components/contentHeader/ContentHeader.d.ts.map +1 -0
- package/lib/esm/src/components/contentHeader/ContentHeader.js +53 -0
- package/lib/esm/src/components/infobox/InfoBox.d.ts +22 -0
- package/lib/esm/src/components/infobox/InfoBox.d.ts.map +1 -0
- package/lib/esm/src/components/infobox/InfoBox.js +36 -0
- package/lib/esm/src/components/input/DateInput.d.ts +28 -0
- package/lib/esm/src/components/input/DateInput.d.ts.map +1 -0
- package/lib/esm/src/components/input/DateInput.js +157 -0
- package/lib/esm/src/components/input/DateTimeInput.d.ts +27 -0
- package/lib/esm/src/components/input/DateTimeInput.d.ts.map +1 -0
- package/lib/esm/src/components/input/DateTimeInput.js +50 -0
- package/lib/esm/src/components/input/SelectWithSearch.d.ts +65 -0
- package/lib/esm/src/components/input/SelectWithSearch.d.ts.map +1 -0
- package/lib/esm/src/components/input/SelectWithSearch.js +111 -0
- package/lib/esm/src/components/input/SelectWithSearchAsync.d.ts +58 -0
- package/lib/esm/src/components/input/SelectWithSearchAsync.d.ts.map +1 -0
- package/lib/esm/src/components/input/SelectWithSearchAsync.js +100 -0
- package/lib/esm/src/components/input/UrnInput.d.ts +22 -0
- package/lib/esm/src/components/input/UrnInput.d.ts.map +1 -0
- package/lib/esm/src/components/input/UrnInput.js +33 -0
- package/lib/esm/src/components/input/ValidatedTextInput.d.ts +35 -0
- package/lib/esm/src/components/input/ValidatedTextInput.d.ts.map +1 -0
- package/lib/esm/src/components/input/ValidatedTextInput.js +30 -0
- package/lib/esm/src/components/input/__tests__/DateInput.spec.d.ts +2 -0
- package/lib/esm/src/components/input/__tests__/DateInput.spec.d.ts.map +1 -0
- package/lib/esm/src/components/input/__tests__/DateInput.spec.js +85 -0
- package/lib/esm/src/components/input/__tests__/DateTimeInput.spec.d.ts +2 -0
- package/lib/esm/src/components/input/__tests__/DateTimeInput.spec.d.ts.map +1 -0
- package/lib/esm/src/components/input/__tests__/DateTimeInput.spec.js +13 -0
- package/lib/esm/src/components/input/__tests__/SelectWithSearchAsync.spec.d.ts +2 -0
- package/lib/esm/src/components/input/__tests__/SelectWithSearchAsync.spec.d.ts.map +1 -0
- package/lib/esm/src/components/input/__tests__/SelectWithSearchAsync.spec.js +44 -0
- package/lib/esm/src/components/link/RouteLink.d.ts +31 -0
- package/lib/esm/src/components/link/RouteLink.d.ts.map +1 -0
- package/lib/esm/src/components/link/RouteLink.js +55 -0
- package/lib/esm/src/components/multiMenu/MultiMenu.d.ts +27 -0
- package/lib/esm/src/components/multiMenu/MultiMenu.d.ts.map +1 -0
- package/lib/esm/src/components/multiMenu/MultiMenu.js +30 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuContext.d.ts +7 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuContext.d.ts.map +1 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuContext.js +5 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuItem.d.ts +14 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuItem.d.ts.map +1 -0
- package/lib/esm/src/components/multiMenu/components/MultiMenuItem.js +24 -0
- package/lib/esm/src/components/pagination/Pagination.d.ts +37 -0
- package/lib/esm/src/components/pagination/Pagination.d.ts.map +1 -0
- package/lib/esm/src/components/pagination/Pagination.js +114 -0
- package/lib/esm/src/components/pagination/__tests__/Pagination.spec.d.ts +2 -0
- package/lib/esm/src/components/pagination/__tests__/Pagination.spec.d.ts.map +1 -0
- package/lib/esm/src/components/pagination/__tests__/Pagination.spec.js +87 -0
- package/lib/esm/src/components/periodpicker/PeriodPicker.d.ts +23 -0
- package/lib/esm/src/components/periodpicker/PeriodPicker.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/PeriodPicker.js +11 -0
- package/lib/esm/src/components/periodpicker/components/Inputs.d.ts +12 -0
- package/lib/esm/src/components/periodpicker/components/Inputs.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/components/Inputs.js +59 -0
- package/lib/esm/src/components/periodpicker/components/Menu.d.ts +11 -0
- package/lib/esm/src/components/periodpicker/components/Menu.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/components/Menu.js +96 -0
- package/lib/esm/src/components/periodpicker/components/MonthPicker.d.ts +19 -0
- package/lib/esm/src/components/periodpicker/components/MonthPicker.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/components/MonthPicker.js +62 -0
- package/lib/esm/src/components/periodpicker/periods.d.ts +33 -0
- package/lib/esm/src/components/periodpicker/periods.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/periods.js +56 -0
- package/lib/esm/src/components/periodpicker/types.d.ts +5 -0
- package/lib/esm/src/components/periodpicker/types.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/types.js +1 -0
- package/lib/esm/src/components/periodpicker/usePeriodName.d.ts +7 -0
- package/lib/esm/src/components/periodpicker/usePeriodName.d.ts.map +1 -0
- package/lib/esm/src/components/periodpicker/usePeriodName.js +38 -0
- package/lib/esm/src/components/prompt/Prompt.d.ts +23 -0
- package/lib/esm/src/components/prompt/Prompt.d.ts.map +1 -0
- package/lib/esm/src/components/prompt/Prompt.js +31 -0
- package/lib/esm/src/components/prompt/withPrompt.d.ts +7 -0
- package/lib/esm/src/components/prompt/withPrompt.d.ts.map +1 -0
- package/lib/esm/src/components/prompt/withPrompt.js +33 -0
- package/lib/esm/src/components/reactable/Reactable.d.ts +38 -0
- package/lib/esm/src/components/reactable/Reactable.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/Reactable.js +18 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTable.d.ts +21 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTable.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTable.js +33 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableFilterRow.d.ts +9 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableFilterRow.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableFilterRow.js +57 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableHeader.d.ts +16 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableHeader.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableHeader.js +52 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableRow.d.ts +16 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableRow.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTableRow.js +56 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTextFilter.d.ts +9 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTextFilter.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/ReactableTextFilter.js +18 -0
- package/lib/esm/src/components/reactable/helpers/helper.d.ts +7 -0
- package/lib/esm/src/components/reactable/helpers/helper.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/helpers/helper.js +90 -0
- package/lib/esm/src/components/reactable/types.d.ts +38 -0
- package/lib/esm/src/components/reactable/types.d.ts.map +1 -0
- package/lib/esm/src/components/reactable/types.js +1 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/ReactableWithClientSidePagination.d.ts +69 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/ReactableWithClientSidePagination.d.ts.map +1 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/ReactableWithClientSidePagination.js +155 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/__tests__/ReactableWithClientSidePagination.spec.d.ts +2 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/__tests__/ReactableWithClientSidePagination.spec.d.ts.map +1 -0
- package/lib/esm/src/components/reactableWithClientSidePagination/__tests__/ReactableWithClientSidePagination.spec.js +130 -0
- package/lib/esm/src/components/slider/Slider.d.ts +30 -0
- package/lib/esm/src/components/slider/Slider.d.ts.map +1 -0
- package/lib/esm/src/components/slider/Slider.js +35 -0
- package/lib/esm/src/components/slider/useLimitStyling.d.ts +3 -0
- package/lib/esm/src/components/slider/useLimitStyling.d.ts.map +1 -0
- package/lib/esm/src/components/slider/useLimitStyling.js +49 -0
- package/lib/esm/src/components/svg/SvgImage.d.ts +12 -0
- package/lib/esm/src/components/svg/SvgImage.d.ts.map +1 -0
- package/lib/esm/src/components/svg/SvgImage.js +37 -0
- package/lib/esm/src/components/svg/storybookHelper.d.ts +7 -0
- package/lib/esm/src/components/svg/storybookHelper.d.ts.map +1 -0
- package/lib/esm/src/components/svg/storybookHelper.js +53 -0
- package/lib/esm/src/components/svg/types.d.ts +58 -0
- package/lib/esm/src/components/svg/types.d.ts.map +1 -0
- package/lib/esm/src/components/svg/types.js +1 -0
- package/lib/esm/src/components/svg/utils/__tests__/getMutableNodeList.spec.d.ts +2 -0
- package/lib/esm/src/components/svg/utils/__tests__/getMutableNodeList.spec.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/__tests__/getMutableNodeList.spec.js +24 -0
- package/lib/esm/src/components/svg/utils/createHyperlinkModification.d.ts +4 -0
- package/lib/esm/src/components/svg/utils/createHyperlinkModification.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/createHyperlinkModification.js +35 -0
- package/lib/esm/src/components/svg/utils/createPositionModification.d.ts +3 -0
- package/lib/esm/src/components/svg/utils/createPositionModification.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/createPositionModification.js +19 -0
- package/lib/esm/src/components/svg/utils/findConflicts.d.ts +2 -0
- package/lib/esm/src/components/svg/utils/findConflicts.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/findConflicts.js +23 -0
- package/lib/esm/src/components/svg/utils/getMutableNodeList.d.ts +3 -0
- package/lib/esm/src/components/svg/utils/getMutableNodeList.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/getMutableNodeList.js +12 -0
- package/lib/esm/src/components/svg/utils/getSvgElement.d.ts +3 -0
- package/lib/esm/src/components/svg/utils/getSvgElement.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/getSvgElement.js +10 -0
- package/lib/esm/src/components/svg/utils/renderSvg.d.ts +3 -0
- package/lib/esm/src/components/svg/utils/renderSvg.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/renderSvg.js +88 -0
- package/lib/esm/src/components/svg/utils/transformPositionModifications.d.ts +4 -0
- package/lib/esm/src/components/svg/utils/transformPositionModifications.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/transformPositionModifications.js +42 -0
- package/lib/esm/src/components/svg/utils/validateSvg.d.ts +3 -0
- package/lib/esm/src/components/svg/utils/validateSvg.d.ts.map +1 -0
- package/lib/esm/src/components/svg/utils/validateSvg.js +5 -0
- package/lib/esm/src/components/tabs/RouteTabs.d.ts +24 -0
- package/lib/esm/src/components/tabs/RouteTabs.d.ts.map +1 -0
- package/lib/esm/src/components/tabs/RouteTabs.js +67 -0
- package/lib/esm/src/components/treeview/TreeView.d.ts +50 -0
- package/lib/esm/src/components/treeview/TreeView.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/TreeView.js +104 -0
- package/lib/esm/src/components/treeview/components/Node.d.ts +37 -0
- package/lib/esm/src/components/treeview/components/Node.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/components/Node.js +111 -0
- package/lib/esm/src/components/treeview/components/NodeInfo.d.ts +25 -0
- package/lib/esm/src/components/treeview/components/NodeInfo.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/components/NodeInfo.js +64 -0
- package/lib/esm/src/components/treeview/constants.d.ts +6 -0
- package/lib/esm/src/components/treeview/constants.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/constants.js +6 -0
- package/lib/esm/src/components/treeview/treeutils.d.ts +59 -0
- package/lib/esm/src/components/treeview/treeutils.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/treeutils.js +158 -0
- package/lib/esm/src/components/treeview/types.d.ts +37 -0
- package/lib/esm/src/components/treeview/types.d.ts.map +1 -0
- package/lib/esm/src/components/treeview/types.js +1 -0
- package/lib/esm/src/components/upload/FileUpload.d.ts +67 -0
- package/lib/esm/src/components/upload/FileUpload.d.ts.map +1 -0
- package/lib/esm/src/components/upload/FileUpload.js +95 -0
- package/lib/esm/src/components/upload/ImageUpload.d.ts +21 -0
- package/lib/esm/src/components/upload/ImageUpload.d.ts.map +1 -0
- package/lib/esm/src/components/upload/ImageUpload.js +45 -0
- package/lib/esm/src/hoc/outsideClick.d.ts +4 -0
- package/lib/esm/src/hoc/outsideClick.d.ts.map +1 -0
- package/lib/esm/src/hoc/outsideClick.js +73 -0
- package/lib/esm/src/i18n/index.d.ts +16 -0
- package/lib/esm/src/i18n/index.d.ts.map +1 -0
- package/lib/esm/src/i18n/index.js +6 -0
- package/lib/esm/src/index.d.ts +52 -0
- package/lib/esm/src/index.d.ts.map +1 -0
- package/lib/esm/src/index.js +39 -0
- package/lib/esm/src/modules/messageBox/messageBox.d.ts +14 -0
- package/lib/esm/src/modules/messageBox/messageBox.d.ts.map +1 -0
- package/lib/esm/src/modules/messageBox/messageBox.js +56 -0
- package/lib/esm/src/modules/utils/nanoidGen.d.ts +2 -0
- package/lib/esm/src/modules/utils/nanoidGen.d.ts.map +1 -0
- package/lib/esm/src/modules/utils/nanoidGen.js +3 -0
- package/lib/esm/src/modules/utils/uuidGen.d.ts +2 -0
- package/lib/esm/src/modules/utils/uuidGen.d.ts.map +1 -0
- package/lib/esm/src/modules/utils/uuidGen.js +13 -0
- package/lib/esm/src/types/i18n.d.ts +5 -0
- package/lib/esm/src/types/i18n.d.ts.map +1 -0
- package/lib/esm/src/types/i18n.js +1 -0
- package/lib/esm/src/types/pagination.d.ts +19 -0
- package/lib/esm/src/types/pagination.d.ts.map +1 -0
- package/lib/esm/src/types/pagination.js +1 -0
- package/lib/esm/src/utils/dayjsLocales.d.ts +10 -0
- package/lib/esm/src/utils/dayjsLocales.d.ts.map +1 -0
- package/lib/esm/src/utils/dayjsLocales.js +12 -0
- package/lib/esm/src/utils/resolvePath.d.ts +2 -0
- package/lib/esm/src/utils/resolvePath.d.ts.map +1 -0
- package/lib/esm/src/utils/resolvePath.js +4 -0
- package/lib/esm/vite.config.d.mts +3 -0
- package/lib/esm/vite.config.d.mts.map +1 -0
- package/lib/esm/vite.config.mjs +9 -0
- package/lib/esm/vitest.setup.d.ts +3 -0
- package/lib/esm/vitest.setup.d.ts.map +1 -0
- package/lib/esm/vitest.setup.js +10 -0
- package/package.json +24 -54
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import ColorPickerPopper from './ColorPickerPopper';
|
|
4
|
+
/**
|
|
5
|
+
* Unlike the GradientColorPicker, the GridColorPicker uses a predefined set of colors.
|
|
6
|
+
* The colors can be defined individually for each GridColorPicker and passed in as prop.
|
|
7
|
+
* Each line can take up to five cells.
|
|
8
|
+
* The cell width within the grid is then calculated automatically via the `styles` prop.
|
|
9
|
+
*/
|
|
10
|
+
export default class GridColorPicker extends React.Component {
|
|
11
|
+
renderColorPicker() {
|
|
12
|
+
const { value, colors, onPick, pickerStyle, pickerClassName } = this.props;
|
|
13
|
+
return (React.createElement("div", { className: classNames('di color-picker grid-color-picker clearfix', pickerClassName), style: pickerStyle }, colors.map((color) => (React.createElement("div", { key: color, onClick: () => {
|
|
14
|
+
onPick(color);
|
|
15
|
+
}, className: `color ${color === value ? 'selected' : ''}`, style: {
|
|
16
|
+
background: color
|
|
17
|
+
} })))));
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const { style, className, value, inline, isOpen, onOpenStateChange, direction } = this.props;
|
|
21
|
+
if (inline) {
|
|
22
|
+
return this.renderColorPicker();
|
|
23
|
+
}
|
|
24
|
+
return (React.createElement(ColorPickerPopper, { className: className, style: style, value: value, colorPicker: this.renderColorPicker(), isOpen: isOpen, onOpenStateChange: onOpenStateChange, direction: direction }));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
GridColorPicker.defaultProps = {
|
|
28
|
+
inline: true,
|
|
29
|
+
popperAlignment: 'top'
|
|
30
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TranslationDescriptor } from '../../types/i18n';
|
|
3
|
+
export declare type Props = {
|
|
4
|
+
/** title which is going to be displayed */
|
|
5
|
+
title: string | TranslationDescriptor;
|
|
6
|
+
/** (optional) subtitle which is going to be displayed */
|
|
7
|
+
subtitle?: string | TranslationDescriptor;
|
|
8
|
+
/** (optional) if set to true, enables back button */
|
|
9
|
+
parentPageLink?: boolean;
|
|
10
|
+
/** (optional) if set, navigates back got certain parent page */
|
|
11
|
+
subPagePathPrefix?: string;
|
|
12
|
+
/** @ignore */
|
|
13
|
+
subPagePathPrefixArray?: Array<string>;
|
|
14
|
+
/** (optional) renders additional components as children */
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* `parentPageLink` set to true shows a back button to go to the parent page.
|
|
19
|
+
* `subPagePathPrefix` needs to be used with `parentPageLink` set to true. It allows to customize what is considered the parent page.
|
|
20
|
+
* With only the `parentPageLink` set to true the parent page is the direct parent, e.g. of `/assets/1234/conditions/5678` the parent is `/assets/1234/conditions`
|
|
21
|
+
* To make the parent of e.g. `/assets/1234/conditions/edit/5678` the page `/assets/1234/conditions`, `subPagePathPrefix="/edit"` needs to be used.
|
|
22
|
+
*/
|
|
23
|
+
declare const ContentHeader: ({ parentPageLink, title, subPagePathPrefixArray, subPagePathPrefix, subtitle, children }: Props) => React.JSX.Element;
|
|
24
|
+
export default ContentHeader;
|
|
25
|
+
//# sourceMappingURL=ContentHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentHeader.d.ts","sourceRoot":"","sources":["../../../../../src/components/contentHeader/ContentHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAC,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AAEvD,oBAAY,KAAK,GAAG;IACnB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAEtC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;IAE1C,qDAAqD;IACrD,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,cAAc;IACd,sBAAsB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvC,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,aAAa,6FAOhB,KAAK,sBAoDP,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
import { useTranslation } from '../../i18n';
|
|
4
|
+
import { Button } from '@deviceinsight/ng-ui-basic-components';
|
|
5
|
+
import arrowBackIcon from '../../assets/img/icon-arrow-back.png';
|
|
6
|
+
/**
|
|
7
|
+
* `parentPageLink` set to true shows a back button to go to the parent page.
|
|
8
|
+
* `subPagePathPrefix` needs to be used with `parentPageLink` set to true. It allows to customize what is considered the parent page.
|
|
9
|
+
* With only the `parentPageLink` set to true the parent page is the direct parent, e.g. of `/assets/1234/conditions/5678` the parent is `/assets/1234/conditions`
|
|
10
|
+
* To make the parent of e.g. `/assets/1234/conditions/edit/5678` the page `/assets/1234/conditions`, `subPagePathPrefix="/edit"` needs to be used.
|
|
11
|
+
*/
|
|
12
|
+
const ContentHeader = ({ parentPageLink, title, subPagePathPrefixArray, subPagePathPrefix, subtitle, children }) => {
|
|
13
|
+
const { push } = useHistory();
|
|
14
|
+
const { pathname } = useLocation();
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const goToParentPage = () => {
|
|
17
|
+
if (subPagePathPrefix) {
|
|
18
|
+
push(pathname.substring(0, pathname.lastIndexOf(subPagePathPrefix)));
|
|
19
|
+
}
|
|
20
|
+
else if (subPagePathPrefixArray) {
|
|
21
|
+
subPagePathPrefixArray.forEach((pathPrefix) => {
|
|
22
|
+
if (pathname.includes(pathPrefix)) {
|
|
23
|
+
push(pathname.substring(0, pathname.lastIndexOf(pathPrefix)));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
push(pathname.substring(0, pathname.lastIndexOf('/')));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const printStringOrMessage = (stringOrMessage) => {
|
|
32
|
+
if (typeof stringOrMessage === 'string') {
|
|
33
|
+
return stringOrMessage;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const { id, defaultValue } = stringOrMessage;
|
|
37
|
+
return t(id, {
|
|
38
|
+
defaultValue
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return (React.createElement("h1", { className: "di header" },
|
|
43
|
+
parentPageLink && (React.createElement(Button, { onClick: goToParentPage, style: {
|
|
44
|
+
marginRight: '15px'
|
|
45
|
+
} },
|
|
46
|
+
React.createElement("img", { src: arrowBackIcon, alt: t('general.navigation.goBack', {
|
|
47
|
+
defaultValue: 'Go Back'
|
|
48
|
+
}) }))),
|
|
49
|
+
React.createElement("span", null, printStringOrMessage(title)),
|
|
50
|
+
subtitle && React.createElement("span", { className: "search-result-count" }, printStringOrMessage(subtitle)),
|
|
51
|
+
children));
|
|
52
|
+
};
|
|
53
|
+
export default ContentHeader;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TranslationDescriptor } from '../../types/i18n';
|
|
3
|
+
export declare type Props = {
|
|
4
|
+
/** Color scheme type based on InfoBox purpose */
|
|
5
|
+
type?: 'info' | 'success' | 'warning' | 'error';
|
|
6
|
+
/** The message to display in the InfoBox */
|
|
7
|
+
message: TranslationDescriptor | string;
|
|
8
|
+
/** Optional icon of the InfoBox */
|
|
9
|
+
icon?: string;
|
|
10
|
+
/** Optional flag whether the InfoBox should be hideable */
|
|
11
|
+
hideable?: boolean;
|
|
12
|
+
/** Optional additional classnames for the parent div container */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Optional additional information to display under the info header */
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* InfoBox is best used for highlighting information, especially if a warning and/or an error shall be displayed.
|
|
19
|
+
*/
|
|
20
|
+
declare function InfoBox({ type, hideable, className, icon, message: inputMessage, children }: Props): React.JSX.Element | null;
|
|
21
|
+
export default InfoBox;
|
|
22
|
+
//# sourceMappingURL=InfoBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBox.d.ts","sourceRoot":"","sources":["../../../../../src/components/infobox/InfoBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,OAAO,EAAC,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AAQvD,oBAAY,KAAK,GAAG;IACnB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAEhD,4CAA4C;IAC5C,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAAC;IAExC,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,iBAAS,OAAO,CAAC,EAAC,IAAa,EAAE,QAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAC,EAAE,KAAK,4BAwC1G;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useTranslation } from '../../i18n';
|
|
3
|
+
import { Icon } from '@deviceinsight/ng-ui-basic-components';
|
|
4
|
+
const colors = {
|
|
5
|
+
info: '#ffffff',
|
|
6
|
+
success: '#cce0cc',
|
|
7
|
+
warning: '#fed254',
|
|
8
|
+
error: '#d66961'
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* InfoBox is best used for highlighting information, especially if a warning and/or an error shall be displayed.
|
|
12
|
+
*/
|
|
13
|
+
function InfoBox({ type = 'info', hideable = false, className, icon, message: inputMessage, children }) {
|
|
14
|
+
const [visible, setVisible] = useState(true);
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
function getMessage() {
|
|
17
|
+
if (typeof inputMessage !== 'string') {
|
|
18
|
+
const { id, defaultValue, ...rest } = inputMessage;
|
|
19
|
+
return t(id, { ...rest, defaultValue });
|
|
20
|
+
}
|
|
21
|
+
return inputMessage;
|
|
22
|
+
}
|
|
23
|
+
const message = getMessage();
|
|
24
|
+
return visible ? (React.createElement("div", { className: `infobox ${className ? className : ''}` },
|
|
25
|
+
React.createElement("div", { className: "infobox-header", style: {
|
|
26
|
+
backgroundColor: colors[type]
|
|
27
|
+
} },
|
|
28
|
+
React.createElement("div", { className: "infobox-header-content" },
|
|
29
|
+
icon && (React.createElement("div", { className: "infobox-iconcontainer" },
|
|
30
|
+
React.createElement("img", { src: icon, alt: "info-icon", style: { width: 16, height: 16 } }))),
|
|
31
|
+
React.createElement("div", { className: "infobox-message" }, message)),
|
|
32
|
+
hideable && (React.createElement("button", { className: "infobox-closebutton", onClick: () => setVisible(false) },
|
|
33
|
+
React.createElement(Icon, { del: true, large: true })))),
|
|
34
|
+
children)) : null;
|
|
35
|
+
}
|
|
36
|
+
export default InfoBox;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactDatePickerProps } from 'react-datepicker';
|
|
3
|
+
import 'react-datepicker/dist/react-datepicker.css';
|
|
4
|
+
import '../../assets/react-datepicker-custom.css';
|
|
5
|
+
declare type DateInputProps = {
|
|
6
|
+
/** the current value (millis since 1970-01-01 or formatted string) */
|
|
7
|
+
value: number | string | null | undefined;
|
|
8
|
+
/** callback function that is executed when the user picks a date */
|
|
9
|
+
onChange: (date: number | null | undefined, fromTextField?: boolean) => void;
|
|
10
|
+
/** makes the input field clearable */
|
|
11
|
+
clearable?: boolean;
|
|
12
|
+
/** displays the date picker inline */
|
|
13
|
+
inline?: boolean;
|
|
14
|
+
/** displays the DateInput read only */
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
/** (optional) class name for the wrapping elements */
|
|
17
|
+
wrapperClassName?: string;
|
|
18
|
+
/** (optional) locale, if not set, the i18next.language is taken */
|
|
19
|
+
locale?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare type Props = Omit<ReactDatePickerProps, keyof DateInputProps> & DateInputProps;
|
|
22
|
+
/**
|
|
23
|
+
* DateInput is used to let users set a date conveniently.
|
|
24
|
+
* Usually the user's locale is used for displaying the correct date format.
|
|
25
|
+
*/
|
|
26
|
+
export default function DateInput({ value, clearable, inline, readOnly, wrapperClassName, onChange, locale, ...otherProps }: Props): React.JSX.Element;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=DateInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAmB,EAAC,oBAAoB,EAAiB,MAAM,kBAAkB,CAAC;AAalF,OAAO,4CAA4C,CAAC;AACpD,OAAO,0CAA0C,CAAC;AAwClD,aAAK,cAAc,GAAG;IACrB,sEAAsE;IACtE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE1C,oEAAoE;IACpE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7E,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,KAAK,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,cAAc,CAAC,GAAG,cAAc,CAAC;AAqBtF;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,KAAK,EACL,SAAS,EACT,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,GAAG,UAAU,EACb,EAAE,KAAK,qBAmKP"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import DatePicker, { registerLocale } from 'react-datepicker';
|
|
3
|
+
import { debounce } from 'lodash';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import localeData from 'dayjs/plugin/localeData';
|
|
6
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
7
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
8
|
+
import i18n from 'i18next';
|
|
9
|
+
import cx from 'classnames';
|
|
10
|
+
import { useTranslation } from '../../i18n';
|
|
11
|
+
import * as Locales from 'date-fns/locale';
|
|
12
|
+
import { Button, Icon, Popup } from '@deviceinsight/ng-ui-basic-components';
|
|
13
|
+
import 'react-datepicker/dist/react-datepicker.css';
|
|
14
|
+
import '../../assets/react-datepicker-custom.css';
|
|
15
|
+
import { isLocaleSupported } from '../../utils/dayjsLocales';
|
|
16
|
+
dayjs.extend(localeData);
|
|
17
|
+
dayjs.extend(localizedFormat);
|
|
18
|
+
dayjs.extend(customParseFormat);
|
|
19
|
+
function registerLanguage(locale) {
|
|
20
|
+
const [localeSegment1, localeSegment2] = locale.split('-');
|
|
21
|
+
let module;
|
|
22
|
+
if (localeSegment1 && localeSegment2) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
module = Locales[`${localeSegment1}${localeSegment2}`] ?? Locales[localeSegment1];
|
|
25
|
+
}
|
|
26
|
+
else if (localeSegment1) {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
module = Locales[localeSegment1];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
module = null;
|
|
32
|
+
}
|
|
33
|
+
if (module) {
|
|
34
|
+
registerLocale(locale, module);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function changeDayjsLocale(locale) {
|
|
38
|
+
let dayjsLocale = null;
|
|
39
|
+
const [localeSegment1] = locale.split('-');
|
|
40
|
+
if (isLocaleSupported(locale.toLowerCase())) {
|
|
41
|
+
dayjsLocale = locale.toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
else if (isLocaleSupported(localeSegment1.toLowerCase())) {
|
|
44
|
+
dayjsLocale = localeSegment1.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
if (dayjsLocale) {
|
|
47
|
+
dayjs.locale(dayjsLocale);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function isInputValid(value, pattern) {
|
|
51
|
+
if (value == null || (typeof value === 'number' && !isNaN(value)) || value == '') {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (typeof value === 'string') {
|
|
55
|
+
return dayjs(value, pattern, true).isValid();
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
function inputToDate(value, pattern) {
|
|
60
|
+
if (value == null || value === '' || !isInputValid(value, pattern))
|
|
61
|
+
return null;
|
|
62
|
+
if (typeof value === 'number') {
|
|
63
|
+
return new Date(value);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return dayjs(value, pattern, true).toDate();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* DateInput is used to let users set a date conveniently.
|
|
71
|
+
* Usually the user's locale is used for displaying the correct date format.
|
|
72
|
+
*/
|
|
73
|
+
export default function DateInput({ value, clearable, inline, readOnly, wrapperClassName, onChange, locale, ...otherProps }) {
|
|
74
|
+
const [pattern, setPattern] = useState(dayjs.localeData().longDateFormat('L'));
|
|
75
|
+
const { t } = useTranslation();
|
|
76
|
+
const [valid, setValid] = useState(false);
|
|
77
|
+
const [popupActive, setPopupActive] = useState(false);
|
|
78
|
+
const [inputText, setInputText] = useState('');
|
|
79
|
+
const debouncedSetPopupActive = useMemo(() => debounce(setPopupActive, 30), []);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const language = locale ?? i18n.language;
|
|
82
|
+
if (language) {
|
|
83
|
+
registerLanguage(language);
|
|
84
|
+
changeDayjsLocale(language).then(() => setPattern(dayjs.localeData().longDateFormat('L')));
|
|
85
|
+
}
|
|
86
|
+
}, [locale]);
|
|
87
|
+
const formattedDate = useCallback((value) => {
|
|
88
|
+
if (value == null || value == '') {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
else if (!isInputValid(value, pattern)) {
|
|
92
|
+
return t('dateInput.invalidDate', {
|
|
93
|
+
defaultValue: 'invalid date'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const date = typeof value === 'number' ? dayjs(value) : dayjs(value, pattern, true);
|
|
98
|
+
return date.format(pattern);
|
|
99
|
+
}
|
|
100
|
+
}, [pattern, t]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (value == null) {
|
|
103
|
+
setInputText('');
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
setInputText(formattedDate(value));
|
|
107
|
+
}
|
|
108
|
+
}, [formattedDate, value]);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
setValid(isInputValid(value, pattern));
|
|
111
|
+
}, [pattern, value]);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
dayjs.locale(locale ?? i18n.language);
|
|
114
|
+
setPattern(dayjs.localeData().longDateFormat('L'));
|
|
115
|
+
}, [locale]);
|
|
116
|
+
const handleInputTextChange = (text) => {
|
|
117
|
+
setInputText(text);
|
|
118
|
+
if (text) {
|
|
119
|
+
const date = dayjs(text, pattern, true);
|
|
120
|
+
const valid = date.isValid();
|
|
121
|
+
if (valid) {
|
|
122
|
+
onChange(date.valueOf(), true);
|
|
123
|
+
}
|
|
124
|
+
setValid(valid);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
onChange(null, true);
|
|
128
|
+
setValid(true);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const handlePickerChange = (date) => {
|
|
132
|
+
onChange(date ? date.valueOf() : null);
|
|
133
|
+
setInputText(formattedDate(date ? date.getTime() : null));
|
|
134
|
+
handlePopupHide();
|
|
135
|
+
};
|
|
136
|
+
const handlePopupShow = () => setPopupActive(true);
|
|
137
|
+
const handlePopupHide = () => setPopupActive(false);
|
|
138
|
+
const handleClear = () => handleInputTextChange('');
|
|
139
|
+
if (inline) {
|
|
140
|
+
return (React.createElement(DatePicker, { ...otherProps, onChange: handlePickerChange, selected: inputToDate(value, pattern), locale: locale ?? i18n.language, isClearable: clearable, placeholderText: pattern, className: cx('date', { invalid: !valid }), inline: true }));
|
|
141
|
+
}
|
|
142
|
+
if (readOnly) {
|
|
143
|
+
return (React.createElement(DatePicker, { ...otherProps, onChange: () => { }, selected: inputToDate(value, pattern), locale: locale ?? i18n.language, customInput: React.createElement("span", null,
|
|
144
|
+
React.createElement("input", { type: "text", value: formattedDate(value), readOnly: true })), placeholderText: pattern, readOnly: true }));
|
|
145
|
+
}
|
|
146
|
+
return (React.createElement(Popup, { handler: React.createElement("span", { className: "di date-input-wrapper" },
|
|
147
|
+
React.createElement("input", { "data-testid": "date-input", className: cx('date', { invalid: !valid }), onChange: (e) => handleInputTextChange(e.target.value), value: inputText, placeholder: pattern, onClick: handlePopupShow, onFocus: handlePopupShow, onBlur: () => {
|
|
148
|
+
handleInputTextChange(formattedDate(value));
|
|
149
|
+
debouncedSetPopupActive(false);
|
|
150
|
+
} }),
|
|
151
|
+
clearable && (React.createElement(Button, { naked: true, small: true, onClick: handleClear },
|
|
152
|
+
React.createElement(Icon, { del: true })))), className: "date-input", handlerWrapperClassName: wrapperClassName, active: popupActive, onHide: handlePopupHide },
|
|
153
|
+
React.createElement("div", { className: "di date-picker-popup-wrapper", tabIndex: 0, onFocus: () => {
|
|
154
|
+
debouncedSetPopupActive(true);
|
|
155
|
+
} },
|
|
156
|
+
React.createElement(DatePicker, { ...otherProps, selected: inputToDate(value, pattern), onChange: handlePickerChange, locale: locale ?? i18n.language, isClearable: clearable, placeholderText: pattern, className: cx('date', { invalid: !valid }), inline: true }))));
|
|
157
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type Props = {
|
|
3
|
+
/** the current value (millis since 1970-01-01) */
|
|
4
|
+
timestamp: number;
|
|
5
|
+
/** callback function that is executed when the user picks a date */
|
|
6
|
+
onChange: (date: number | null | undefined, fromTextField?: boolean) => void;
|
|
7
|
+
/** (optional) if set to true, displays warning styles */
|
|
8
|
+
warning?: boolean;
|
|
9
|
+
/** (optional) forces the input field to display the `Popup` */
|
|
10
|
+
forceOpen?: boolean;
|
|
11
|
+
/** displays the DateTimeInput read-only */
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
selectsStart?: boolean;
|
|
14
|
+
selectsEnd?: boolean;
|
|
15
|
+
startDate?: Date;
|
|
16
|
+
endDate?: Date;
|
|
17
|
+
/** (optional) locale, if not set, the i18next.language is taken */
|
|
18
|
+
locale?: string;
|
|
19
|
+
/** (optional) timezone */
|
|
20
|
+
timezone?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Extends DateInput but also displaying the current time.
|
|
24
|
+
* Usually the user's locale is used for displaying the correct date format.
|
|
25
|
+
*/
|
|
26
|
+
export default function DateTimeInput({ timestamp, timezone, warning, readOnly, onChange, ...otherProps }: Props): React.JSX.Element;
|
|
27
|
+
//# sourceMappingURL=DateTimeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/DateTimeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAejD,oBAAY,KAAK,GAAG;IACnB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAElB,oEAAoE;IACpE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE7E,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,IAAI,CAAC;IAEf,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACrC,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAgB,EAChB,QAAQ,EACR,GAAG,UAAU,EACb,EAAE,KAAK,qBAwDP"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { dayjsTz } from '../periodpicker/periods';
|
|
3
|
+
import DateInput from './DateInput';
|
|
4
|
+
import ValidatedTextInput from './ValidatedTextInput';
|
|
5
|
+
const extractTime = (timezone, date) => {
|
|
6
|
+
try {
|
|
7
|
+
return dayjsTz(timezone, date).format('HH:mm');
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
console.error('DateTimeInput: Error while extracting time from date', error);
|
|
11
|
+
return '00:00';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Extends DateInput but also displaying the current time.
|
|
16
|
+
* Usually the user's locale is used for displaying the correct date format.
|
|
17
|
+
*/
|
|
18
|
+
export default function DateTimeInput({ timestamp, timezone, warning, readOnly = false, onChange, ...otherProps }) {
|
|
19
|
+
const [time, setTime] = useState(extractTime(timezone, timestamp));
|
|
20
|
+
const timeValue = time == null ? extractTime(timezone, timestamp) : time;
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setTime(extractTime(timezone, timestamp));
|
|
23
|
+
}, [timezone, timestamp]);
|
|
24
|
+
function handleChangeDate(date, fromTextField) {
|
|
25
|
+
const oldDate = dayjsTz(timezone, timestamp);
|
|
26
|
+
onChange(dayjsTz(timezone, date).set('hour', oldDate.get('hour')).set('minute', oldDate.get('minute')).valueOf(), fromTextField);
|
|
27
|
+
}
|
|
28
|
+
function handleChangeTime(time, valid) {
|
|
29
|
+
if (valid) {
|
|
30
|
+
const [hours, minutes] = time.split(':');
|
|
31
|
+
onChange(dayjsTz(timezone, timestamp)
|
|
32
|
+
.set('hour', parseInt(hours, 10))
|
|
33
|
+
.set('minute', parseInt(minutes, 10))
|
|
34
|
+
.set('second', 0)
|
|
35
|
+
.set('millisecond', 0)
|
|
36
|
+
.valueOf());
|
|
37
|
+
}
|
|
38
|
+
setTime(time);
|
|
39
|
+
}
|
|
40
|
+
function tryFixTime() {
|
|
41
|
+
if (time && /^[0-9]:[0-5][0-9]$/.test(time)) {
|
|
42
|
+
handleChangeTime(time.padStart(5, '0'), true);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return (React.createElement("span", { className: `di date-time-input ${warning ? 'with-warning' : ''}` },
|
|
46
|
+
React.createElement(DateInput, { ...otherProps, value: timestamp, onChange: handleChangeDate, readOnly: readOnly }),
|
|
47
|
+
React.createElement(ValidatedTextInput, { "data-testid": "time-input", value: timeValue, onChange: handleChangeTime, pattern: /^(([01][0-9])|2[0-3]):[0-5][0-9]$/, required: true, invalidStyle: {
|
|
48
|
+
borderColor: 'red'
|
|
49
|
+
}, placeholder: "00:00", className: "time", onBlur: tryFixTime, disabled: readOnly })));
|
|
50
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '../../assets/react-select.css';
|
|
3
|
+
import '../../assets/react-select-custom.css';
|
|
4
|
+
export declare type Item = {
|
|
5
|
+
type: 'item';
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type Group = {
|
|
10
|
+
type: 'group';
|
|
11
|
+
label: string;
|
|
12
|
+
options: Array<Item>;
|
|
13
|
+
};
|
|
14
|
+
export declare type Props = {
|
|
15
|
+
/** Flag to preselect the status of the checkbox */
|
|
16
|
+
value: Item | null | undefined;
|
|
17
|
+
/** Function, executed when selecting value */
|
|
18
|
+
onChange: (arg0: Item | null | undefined) => void;
|
|
19
|
+
/** Array of select options values */
|
|
20
|
+
options: Array<Item> | Array<Group>;
|
|
21
|
+
/** Array of special select options values */
|
|
22
|
+
specialOptions?: Array<Item> | null | undefined;
|
|
23
|
+
/** Message displayed when no results found by search feature */
|
|
24
|
+
noResultsMessage?: string;
|
|
25
|
+
/** Placeholder */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** Clearable */
|
|
28
|
+
clearable?: boolean;
|
|
29
|
+
/** Loading */
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
/** Function comparing two options - used for sorting */
|
|
32
|
+
compareOptions?: (value1: Item, value2: Item) => number;
|
|
33
|
+
/** (Optional) Whether the menu should use a portal, and where it should attach */
|
|
34
|
+
menuPortalTarget?: HTMLElement;
|
|
35
|
+
/** (Optional) indicates if the component is disabled or not */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** Enables free-form input mode */
|
|
38
|
+
freeForm?: boolean;
|
|
39
|
+
/** @ignore */
|
|
40
|
+
'data-testid'?: string;
|
|
41
|
+
};
|
|
42
|
+
declare type State = {
|
|
43
|
+
options: Array<Item> | Array<Group>;
|
|
44
|
+
inputValue: string | null;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* SelectWithSearch enhances a native select list by applying a search functionality to it.
|
|
48
|
+
* Additional entries can be added by setting and adjusting `specialOptions`
|
|
49
|
+
*/
|
|
50
|
+
export default class SelectWithSearch extends React.Component<Props, State> {
|
|
51
|
+
state: State;
|
|
52
|
+
selectRef: {
|
|
53
|
+
current: any | null;
|
|
54
|
+
};
|
|
55
|
+
portalRoot: HTMLElement | null;
|
|
56
|
+
componentDidMount(): void;
|
|
57
|
+
componentDidUpdate(prevProps: Props): void;
|
|
58
|
+
componentWillUnmount(): void;
|
|
59
|
+
updateOptions: () => void;
|
|
60
|
+
filterOption: (option: Item, inputValue: string) => boolean;
|
|
61
|
+
getContainerClasses: () => string[];
|
|
62
|
+
render(): React.JSX.Element;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=SelectWithSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectWithSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/input/SelectWithSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,+BAA+B,CAAC;AACvC,OAAO,sCAAsC,CAAC;AAE9C,oBAAY,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CACrB,CAAC;AAEF,oBAAY,KAAK,GAAG;IACnB,mDAAmD;IACnD,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IAE/B,8CAA8C;IAC9C,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IAElD,qCAAqC;IACrC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAEpC,6CAA6C;IAC7C,cAAc,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAEhD,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,gBAAgB;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wDAAwD;IACxD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,MAAM,CAAC;IAExD,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAE/B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,cAAc;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,aAAK,KAAK,GAAG;IACZ,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AA0BF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;IAC1E,KAAK,EAAE,KAAK,CAGV;IACF,SAAS,EAAE;QACV,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;KACpB,CAAoC;IAErC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAQ;IAEtC,iBAAiB;IAejB,kBAAkB,CAAC,SAAS,EAAE,KAAK;IAMnC,oBAAoB;IAMpB,aAAa,EAAE,MAAM,IAAI,CAcvB;IAEF,YAAY,WAAY,IAAI,cAAc,MAAM,KAAG,OAAO,CAExD;IAEF,mBAAmB,iBAMjB;IAEF,MAAM;CAiDN"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Select from 'react-select';
|
|
3
|
+
import { orderBy, isEqual } from 'lodash';
|
|
4
|
+
import '../../assets/react-select.css';
|
|
5
|
+
import '../../assets/react-select-custom.css';
|
|
6
|
+
function getSortedOptions(options, compareOptions) {
|
|
7
|
+
if (!compareOptions) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
return orderBy(options, 'label', 'asc');
|
|
10
|
+
}
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
if (options.every((option) => !option.options)) {
|
|
13
|
+
const singleOptions = options;
|
|
14
|
+
return [...singleOptions].sort(compareOptions);
|
|
15
|
+
}
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
if (options.every((option) => option.options)) {
|
|
18
|
+
const groupOptions = options;
|
|
19
|
+
return groupOptions.map((option) => ({ ...option, options: [...option.options].sort(compareOptions) }));
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Mixing groups with single options not allowed');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* SelectWithSearch enhances a native select list by applying a search functionality to it.
|
|
25
|
+
* Additional entries can be added by setting and adjusting `specialOptions`
|
|
26
|
+
*/
|
|
27
|
+
export default class SelectWithSearch extends React.Component {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.state = {
|
|
31
|
+
options: [],
|
|
32
|
+
inputValue: null
|
|
33
|
+
};
|
|
34
|
+
this.selectRef = React.createRef();
|
|
35
|
+
this.portalRoot = null;
|
|
36
|
+
this.updateOptions = () => {
|
|
37
|
+
const { options, specialOptions, compareOptions } = this.props;
|
|
38
|
+
const sortedOptions = getSortedOptions(options, compareOptions);
|
|
39
|
+
if (specialOptions) {
|
|
40
|
+
this.setState({
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
options: [...sortedOptions, ...specialOptions]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.setState({
|
|
47
|
+
options: sortedOptions
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
this.filterOption = (option, inputValue) => {
|
|
52
|
+
return option.label.toString().toLowerCase().startsWith(inputValue.toLowerCase());
|
|
53
|
+
};
|
|
54
|
+
this.getContainerClasses = () => {
|
|
55
|
+
const { specialOptions } = this.props;
|
|
56
|
+
if (specialOptions) {
|
|
57
|
+
return ['select-search-container', 'special'];
|
|
58
|
+
}
|
|
59
|
+
return ['select-search-container'];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
componentDidMount() {
|
|
63
|
+
this.updateOptions();
|
|
64
|
+
if (this.props['data-testid'] && this.selectRef && this.selectRef.current) {
|
|
65
|
+
this.selectRef.current.controlRef.setAttribute('data-testid', this.props['data-testid']);
|
|
66
|
+
}
|
|
67
|
+
if (this.props.menuPortalTarget) {
|
|
68
|
+
this.portalRoot = document.createElement('div');
|
|
69
|
+
const classes = this.getContainerClasses();
|
|
70
|
+
this.portalRoot.classList.add(...classes);
|
|
71
|
+
this.props.menuPortalTarget.appendChild(this.portalRoot);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
componentDidUpdate(prevProps) {
|
|
75
|
+
if (!isEqual(prevProps.options, this.props.options) || prevProps.freeForm !== this.props.freeForm) {
|
|
76
|
+
this.updateOptions();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
componentWillUnmount() {
|
|
80
|
+
if (this.props.menuPortalTarget && this.portalRoot) {
|
|
81
|
+
this.props.menuPortalTarget.removeChild(this.portalRoot);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
const { noResultsMessage, placeholder, value, onChange, clearable, loading, disabled } = this.props;
|
|
86
|
+
const { options } = this.state;
|
|
87
|
+
return (React.createElement(Select, { ref: this.selectRef, joinValues: true, name: "form-field-name", className: this.getContainerClasses().join(' '), classNamePrefix: "select-search", isClearable: clearable, noOptionsMessage: noResultsMessage ? () => noResultsMessage : undefined, options: options, value: value || null, onChange: onChange, onInputChange: (newValue) => {
|
|
88
|
+
if (this.props.freeForm && newValue) {
|
|
89
|
+
this.setState({ inputValue: newValue });
|
|
90
|
+
}
|
|
91
|
+
}, placeholder: placeholder,
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
filterOption: this.filterOption, isLoading: loading, menuPortalTarget: this.portalRoot, isDisabled: disabled, onBlur: () => {
|
|
94
|
+
if (this.props.freeForm && this.state.inputValue !== null) {
|
|
95
|
+
this.setState({ options: this.props.options });
|
|
96
|
+
this.setState({ inputValue: this.state.inputValue }, () => {
|
|
97
|
+
const newItem = {
|
|
98
|
+
type: 'item',
|
|
99
|
+
value: this.state.inputValue,
|
|
100
|
+
label: this.state.inputValue
|
|
101
|
+
};
|
|
102
|
+
this.setState((prevState) => ({
|
|
103
|
+
options: [newItem, ...prevState.options]
|
|
104
|
+
}));
|
|
105
|
+
this.state.inputValue = null;
|
|
106
|
+
onChange(newItem);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
} }));
|
|
110
|
+
}
|
|
111
|
+
}
|