slick-table 1.0.18 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +31 -31
- package/dist/index.es.js +162 -157
- package/dist/types/shared/lib/slickgrid/lib/sorting/ColumnSorter.d.ts +1 -0
- package/dist/types/shared/lib/slickgrid/lib/sorting/ColumnSorter.d.ts.map +1 -1
- package/dist/types/shared/lib/sorting/Sort.d.ts +1 -0
- package/dist/types/shared/lib/sorting/Sort.d.ts.map +1 -1
- package/dist/types/shared/model/enums/ESortType.d.ts +3 -1
- package/dist/types/shared/model/enums/ESortType.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/App.tsx +9 -0
- package/src/app/styles/global.scss +31 -0
- package/src/app/styles/slickgrid.scss +13 -0
- package/src/app/types/index.d.ts +9 -0
- package/src/entities/popup/index.ts +2 -0
- package/src/entities/popup/lib/index.ts +1 -0
- package/src/entities/popup/lib/visibility/index.ts +1 -0
- package/src/entities/popup/lib/visibility/makeVisible.ts +9 -0
- package/src/entities/popup/ui/Overlay/Overlay.style.ts +14 -0
- package/src/entities/popup/ui/Overlay/Overlay.test.tsx +19 -0
- package/src/entities/popup/ui/Overlay/Overlay.tsx +20 -0
- package/src/entities/popup/ui/Overlay/index.ts +1 -0
- package/src/entities/popup/ui/Popup.style.ts +17 -0
- package/src/entities/popup/ui/Popup.tsx +12 -0
- package/src/entities/popup/ui/index.ts +2 -0
- package/src/entities/skeleton/Skeleton.style.ts +10 -0
- package/src/entities/skeleton/Skeleton.tsx +11 -0
- package/src/entities/skeleton/index.ts +1 -0
- package/src/features/column-filters/index.ts +1 -0
- package/src/features/column-filters/lib/filter/applyFilter.ts +25 -0
- package/src/features/column-filters/lib/filter/index.ts +1 -0
- package/src/features/column-filters/lib/hooks/index.ts +2 -0
- package/src/features/column-filters/lib/hooks/useOpenMenu.ts +43 -0
- package/src/features/column-filters/lib/hooks/useSubscribeToEvent.ts +17 -0
- package/src/features/column-filters/lib/index.ts +4 -0
- package/src/features/column-filters/lib/props/datePickerProps.tsx +11 -0
- package/src/features/column-filters/lib/props/index.ts +1 -0
- package/src/features/column-filters/lib/select/firstIn.ts +22 -0
- package/src/features/column-filters/lib/select/index.ts +1 -0
- package/src/features/column-filters/model/consts/defaultValue.ts +6 -0
- package/src/features/column-filters/model/consts/id.ts +1 -0
- package/src/features/column-filters/model/consts/index.ts +3 -0
- package/src/features/column-filters/model/consts/label.ts +5 -0
- package/src/features/column-filters/model/index.ts +2 -0
- package/src/features/column-filters/model/types/IProps.ts +9 -0
- package/src/features/column-filters/model/types/index.ts +1 -0
- package/src/features/column-filters/ui/BooleanInput/BooleanInput.style.ts +10 -0
- package/src/features/column-filters/ui/BooleanInput/BooleanInput.tsx +53 -0
- package/src/features/column-filters/ui/BooleanInput/index.ts +1 -0
- package/src/features/column-filters/ui/ButtonReset/ButtonReset.style.ts +10 -0
- package/src/features/column-filters/ui/ButtonReset/ButtonReset.tsx +39 -0
- package/src/features/column-filters/ui/ButtonReset/index.ts +1 -0
- package/src/features/column-filters/ui/ColumnFilters.style.ts +12 -0
- package/src/features/column-filters/ui/ColumnFilters.tsx +44 -0
- package/src/features/column-filters/ui/DateBetween/DateBetween.tsx +52 -0
- package/src/features/column-filters/ui/DateBetween/index.ts +1 -0
- package/src/features/column-filters/ui/DateInput/DateInput.tsx +36 -0
- package/src/features/column-filters/ui/DateInput/index.ts +1 -0
- package/src/features/column-filters/ui/InputArea/InputArea.tsx +63 -0
- package/src/features/column-filters/ui/InputArea/index.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/index.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/lib/index.ts +2 -0
- package/src/features/column-filters/ui/MultipleSelect/lib/props/index.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/lib/props/props.ts +36 -0
- package/src/features/column-filters/ui/MultipleSelect/lib/sorting/ascending.ts +17 -0
- package/src/features/column-filters/ui/MultipleSelect/lib/sorting/index.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/model/IValue.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/model/index.ts +1 -0
- package/src/features/column-filters/ui/MultipleSelect/ui/MultipleSelect.style.ts +9 -0
- package/src/features/column-filters/ui/MultipleSelect/ui/MultipleSelect.tsx +72 -0
- package/src/features/column-filters/ui/MultipleSelect/ui/index.ts +1 -0
- package/src/features/column-filters/ui/NumberBetween/NumberBetween.tsx +42 -0
- package/src/features/column-filters/ui/NumberBetween/index.ts +1 -0
- package/src/features/column-filters/ui/NumberInput/NumberInput.tsx +24 -0
- package/src/features/column-filters/ui/NumberInput/index.ts +1 -0
- package/src/features/column-filters/ui/SelectFilter/index.ts +1 -0
- package/src/features/column-filters/ui/SelectFilter/model/index.ts +1 -0
- package/src/features/column-filters/ui/SelectFilter/model/options/index.ts +1 -0
- package/src/features/column-filters/ui/SelectFilter/model/options/options.ts +66 -0
- package/src/features/column-filters/ui/SelectFilter/ui/SelectFilter.tsx +50 -0
- package/src/features/column-filters/ui/SelectFilter/ui/index.ts +1 -0
- package/src/features/column-filters/ui/TextInput/TextInput.tsx +23 -0
- package/src/features/column-filters/ui/TextInput/index.ts +1 -0
- package/src/features/column-filters/ui/index.ts +1 -0
- package/src/features/context-menu/index.ts +1 -0
- package/src/features/context-menu/lib/hooks/index.ts +1 -0
- package/src/features/context-menu/lib/hooks/useSubscribeToEvent.ts +27 -0
- package/src/features/context-menu/lib/index.ts +1 -0
- package/src/features/context-menu/model/consts/id.ts +1 -0
- package/src/features/context-menu/model/consts/index.ts +1 -0
- package/src/features/context-menu/model/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonDownloadCSV/ButtonDownloadCSV.tsx +34 -0
- package/src/features/context-menu/ui/ButtonDownloadCSV/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonGroup/ButtonGroup.tsx +28 -0
- package/src/features/context-menu/ui/ButtonGroup/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonResetFilters/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonResetFilters/lib/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonResetFilters/lib/visibility/hasFiltersApplied.ts +8 -0
- package/src/features/context-menu/ui/ButtonResetFilters/lib/visibility/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonResetFilters/ui/ButtonResetFilters.tsx +39 -0
- package/src/features/context-menu/ui/ButtonResetFilters/ui/index.ts +1 -0
- package/src/features/context-menu/ui/ButtonUngroup/ButtonUngroup.tsx +28 -0
- package/src/features/context-menu/ui/ButtonUngroup/index.ts +1 -0
- package/src/features/context-menu/ui/CollapseAll/CollapseAll.tsx +31 -0
- package/src/features/context-menu/ui/CollapseAll/index.ts +1 -0
- package/src/features/context-menu/ui/ContextMenu.style.ts +29 -0
- package/src/features/context-menu/ui/ContextMenu.tsx +55 -0
- package/src/features/context-menu/ui/CopyToClipboard/CopyToClipboard.tsx +42 -0
- package/src/features/context-menu/ui/CopyToClipboard/index.ts +1 -0
- package/src/features/context-menu/ui/ExpandAll/ExpandAll.tsx +30 -0
- package/src/features/context-menu/ui/ExpandAll/index.ts +1 -0
- package/src/features/context-menu/ui/Print/index.ts +1 -0
- package/src/features/context-menu/ui/Print/ui/Print.tsx +25 -0
- package/src/features/context-menu/ui/Print/ui/index.ts +1 -0
- package/src/features/context-menu/ui/index.ts +1 -0
- package/src/index.scss +2 -0
- package/src/index.ts +40 -0
- package/src/main.tsx +15 -0
- package/src/setupTests.ts +5 -0
- package/src/shared/lib/an-event/index.ts +31 -0
- package/src/shared/lib/datetime/dateToString.spec.ts +11 -0
- package/src/shared/lib/datetime/dateToString.ts +8 -0
- package/src/shared/lib/datetime/getTime.spec.ts +10 -0
- package/src/shared/lib/datetime/getTime.ts +3 -0
- package/src/shared/lib/datetime/index.ts +2 -0
- package/src/shared/lib/debounce/index.ts +11 -0
- package/src/shared/lib/dom/elementNotVisible.spec.ts +72 -0
- package/src/shared/lib/dom/elementNotVisible.ts +9 -0
- package/src/shared/lib/dom/index.ts +1 -0
- package/src/shared/lib/format/IOptions.ts +11 -0
- package/src/shared/lib/format/addParentheses.spec.ts +9 -0
- package/src/shared/lib/format/addParentheses.ts +7 -0
- package/src/shared/lib/format/formatNumber.spec.ts +50 -0
- package/src/shared/lib/format/formatNumber.ts +62 -0
- package/src/shared/lib/format/index.ts +2 -0
- package/src/shared/lib/localStrore/index.ts +1 -0
- package/src/shared/lib/localStrore/lib/getSlickTable.ts +5 -0
- package/src/shared/lib/localStrore/lib/getSorting.ts +5 -0
- package/src/shared/lib/localStrore/lib/index.ts +3 -0
- package/src/shared/lib/localStrore/lib/setSorting.ts +8 -0
- package/src/shared/lib/localStrore/model/enums/EStorageKey.ts +4 -0
- package/src/shared/lib/localStrore/model/enums/index.ts +1 -0
- package/src/shared/lib/localStrore/model/index.ts +3 -0
- package/src/shared/lib/localStrore/model/localStore.ts +28 -0
- package/src/shared/lib/localStrore/model/types/ILastSorting.ts +4 -0
- package/src/shared/lib/localStrore/model/types/ISlickTable.ts +1 -0
- package/src/shared/lib/localStrore/model/types/ISorting.ts +3 -0
- package/src/shared/lib/localStrore/model/types/index.ts +3 -0
- package/src/shared/lib/numbers/index.ts +1 -0
- package/src/shared/lib/numbers/toNumber.spec.ts +25 -0
- package/src/shared/lib/numbers/toNumber.ts +11 -0
- package/src/shared/lib/regexp/dates.spec.ts +23 -0
- package/src/shared/lib/regexp/dates.ts +6 -0
- package/src/shared/lib/regexp/escapeSpecialChar.spec.ts +24 -0
- package/src/shared/lib/regexp/escapeSpecialChar.ts +4 -0
- package/src/shared/lib/regexp/index.ts +2 -0
- package/src/shared/lib/slickgrid/index.ts +70 -0
- package/src/shared/lib/slickgrid/lib/callbacks/getOnKeyDownCallback.ts +12 -0
- package/src/shared/lib/slickgrid/lib/callbacks/index.ts +4 -0
- package/src/shared/lib/slickgrid/lib/callbacks/onCellChange.ts +13 -0
- package/src/shared/lib/slickgrid/lib/callbacks/onRowCountChanged.ts +12 -0
- package/src/shared/lib/slickgrid/lib/callbacks/onRowsChanged.ts +8 -0
- package/src/shared/lib/slickgrid/lib/contextMenu/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/contextMenu/openContextMenu.ts +17 -0
- package/src/shared/lib/slickgrid/lib/editors/Autocomplete/Autocomplete.ts +155 -0
- package/src/shared/lib/slickgrid/lib/editors/Autocomplete/EditorAutocomplete.ts +66 -0
- package/src/shared/lib/slickgrid/lib/editors/Autocomplete/EditorSelectWithSearch.ts +79 -0
- package/src/shared/lib/slickgrid/lib/editors/Autocomplete/index.ts +3 -0
- package/src/shared/lib/slickgrid/lib/editors/EditorAmount.ts +82 -0
- package/src/shared/lib/slickgrid/lib/editors/EditorDate.ts +127 -0
- package/src/shared/lib/slickgrid/lib/editors/EditorSelectNumber.ts +16 -0
- package/src/shared/lib/slickgrid/lib/editors/EditorSelectString.ts +95 -0
- package/src/shared/lib/slickgrid/lib/editors/index.ts +9 -0
- package/src/shared/lib/slickgrid/lib/formatters/DateFormatter.ts +9 -0
- package/src/shared/lib/slickgrid/lib/formatters/FormatterCheck.ts +11 -0
- package/src/shared/lib/slickgrid/lib/formatters/PercentFormatter.spec.ts +11 -0
- package/src/shared/lib/slickgrid/lib/formatters/PercentFormatter.ts +8 -0
- package/src/shared/lib/slickgrid/lib/formatters/StringFormatter.ts +2 -0
- package/src/shared/lib/slickgrid/lib/formatters/getFormatterNumber.ts +17 -0
- package/src/shared/lib/slickgrid/lib/formatters/index.ts +5 -0
- package/src/shared/lib/slickgrid/lib/functions/addNewRow.ts +22 -0
- package/src/shared/lib/slickgrid/lib/functions/commitCurrentEdit.ts +6 -0
- package/src/shared/lib/slickgrid/lib/functions/copySelectedRows.ts +34 -0
- package/src/shared/lib/slickgrid/lib/functions/deleteRows.ts +20 -0
- package/src/shared/lib/slickgrid/lib/functions/getActiveRowId.ts +16 -0
- package/src/shared/lib/slickgrid/lib/functions/getDisplayedRows.ts +13 -0
- package/src/shared/lib/slickgrid/lib/functions/getLastRow.ts +6 -0
- package/src/shared/lib/slickgrid/lib/functions/getNextId.ts +18 -0
- package/src/shared/lib/slickgrid/lib/functions/index.ts +10 -0
- package/src/shared/lib/slickgrid/lib/functions/isDeletionDangerous.ts +21 -0
- package/src/shared/lib/slickgrid/lib/functions/wereEdited.ts +12 -0
- package/src/shared/lib/slickgrid/lib/grouping/formatterGroupTotals.test.ts +59 -0
- package/src/shared/lib/slickgrid/lib/grouping/formatterGroupTotals.ts +21 -0
- package/src/shared/lib/slickgrid/lib/grouping/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/highlighting/getColumnsHash.ts +8 -0
- package/src/shared/lib/slickgrid/lib/highlighting/highlightCell.ts +21 -0
- package/src/shared/lib/slickgrid/lib/highlighting/highlightColumns.ts +24 -0
- package/src/shared/lib/slickgrid/lib/highlighting/index.ts +2 -0
- package/src/shared/lib/slickgrid/lib/hooks/eventClickOnTable.ts +17 -0
- package/src/shared/lib/slickgrid/lib/hooks/index.ts +4 -0
- package/src/shared/lib/slickgrid/lib/hooks/useHotKeys.ts +39 -0
- package/src/shared/lib/slickgrid/lib/hooks/useListenIfTablesWereEdited.ts +36 -0
- package/src/shared/lib/slickgrid/lib/hooks/useResizeCanvas.ts +18 -0
- package/src/shared/lib/slickgrid/lib/hooks/useUpdateTotal.ts +17 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysCopy.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysDelete.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysRedo.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysReverse.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/hotKeysUndo.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/index.ts +7 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/nothingToCopy.ts +14 -0
- package/src/shared/lib/slickgrid/lib/hotKeys/positionToPaste.ts +12 -0
- package/src/shared/lib/slickgrid/lib/index.ts +61 -0
- package/src/shared/lib/slickgrid/lib/selection/getUpdates.ts +41 -0
- package/src/shared/lib/slickgrid/lib/selection/index.ts +2 -0
- package/src/shared/lib/slickgrid/lib/selection/selectedRows.ts +17 -0
- package/src/shared/lib/slickgrid/lib/sorting/ColumnSorter.ts +166 -0
- package/src/shared/lib/slickgrid/lib/sorting/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/total-calculator/TotalCalculator.ts +71 -0
- package/src/shared/lib/slickgrid/lib/total-calculator/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/validators/DateValidator.ts +12 -0
- package/src/shared/lib/slickgrid/lib/validators/EmptyStringValidator.ts +5 -0
- package/src/shared/lib/slickgrid/lib/validators/LengthValidator.ts +7 -0
- package/src/shared/lib/slickgrid/lib/validators/index.ts +3 -0
- package/src/shared/lib/slickgrid/model/SlickTable/csvDownloadManager/DownloadManager.ts +110 -0
- package/src/shared/lib/slickgrid/model/SlickTable/csvDownloadManager/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/DeletedRowsFilter.test.ts +36 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/DeletedRowsFilter.ts +12 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/Filter.test.ts +80 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/Filter.ts +52 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/WithoutFilter.ts +30 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/DecoratorColumnFilter.test.ts +216 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/DecoratorColumnFilter.ts +53 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/Filter.test.ts +264 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/Filter.ts +108 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/ColumnFilter/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/DecoratorEndingDate.ts +16 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/DecoratorFilter.test.ts +139 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/DecoratorFilter.ts +55 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/DecoratorPeriod.ts +24 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/decorators/index.ts +4 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/index.ts +9 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/DefaultHotKeys.ts +116 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/WithoutHotKeys.ts +20 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/HotKeysDecorator.ts +32 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/PreventCopying.ts +18 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/RedoUndoOnly.ts +18 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/WithConfirmationOfDeletion.ts +33 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/index.ts +4 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/index.ts +8 -0
- package/src/shared/lib/slickgrid/model/SlickTable/index.ts +19 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/DefaultPrinter.test.ts +226 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/DefaultPrinter.ts +179 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/model/consts/cssStyles.ts +46 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/model/consts/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/printer/model/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.test.ts +72 -0
- package/src/shared/lib/slickgrid/model/SlickTable/table/SlickTable.ts +168 -0
- package/src/shared/lib/slickgrid/model/SlickTable/table/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/events/eventContextMenu.ts +10 -0
- package/src/shared/lib/slickgrid/model/events/index.ts +1 -0
- package/src/shared/lib/slickgrid/model/index.ts +18 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/handleClick/handleHeaderButtons.ts +27 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/handleClick/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/highlighting/headerButtons.ts +45 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/highlighting/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/lib/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/model/buttons/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/model/buttons/openColumnFilter.ts +10 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/model/event/eventOpenColumnFilters.ts +13 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/model/event/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/HeaderButtons/model/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/callbacks/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/callbacks/onAddNewRow.ts +34 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/hooks/useGrid.ts +142 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/lib/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/model/defaultOptions.ts +8 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/model/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/model/types/Props.ts +46 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/model/types/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/ui/SlickgridTable.tsx +57 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/ui/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/columns/columnCheckboxSelector/columnCheckboxSelector.ts +7 -0
- package/src/shared/lib/slickgrid/ui/columns/columnCheckboxSelector/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/lib/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/lib/setEditedMark.spec.ts +11 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/lib/setEditedMark.ts +7 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/ui/columnIsEdited.ts +16 -0
- package/src/shared/lib/slickgrid/ui/columns/columnIsEdited/ui/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/columns/index.ts +2 -0
- package/src/shared/lib/slickgrid/ui/index.ts +9 -0
- package/src/shared/lib/slickgrid/ui/styles/WithTableStyles/WithTableStyles.style.ts +157 -0
- package/src/shared/lib/slickgrid/ui/styles/WithTableStyles/WithTableStyles.tsx +11 -0
- package/src/shared/lib/slickgrid/ui/styles/WithTableStyles/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/styles/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/styles/keyframes/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/styles/keyframes/wink.ts +7 -0
- package/src/shared/lib/sorting/Sort.ts +37 -0
- package/src/shared/lib/sorting/index.ts +1 -0
- package/src/shared/lib/stringCalculator/index.ts +2 -0
- package/src/shared/lib/stringCalculator/stringCalculator.js +834 -0
- package/src/shared/lib/stringCalculator/stringCalculator.spec.ts +16 -0
- package/src/shared/lib/strings/deleteDoubleQuotes.spec.ts +11 -0
- package/src/shared/lib/strings/deleteDoubleQuotes.ts +5 -0
- package/src/shared/lib/strings/index.ts +3 -0
- package/src/shared/lib/strings/removeHtml.spec.ts +29 -0
- package/src/shared/lib/strings/removeHtml.ts +5 -0
- package/src/shared/lib/strings/toStringWithCommas.spec.ts +16 -0
- package/src/shared/lib/strings/toStringWithCommas.ts +15 -0
- package/src/shared/model/consts/columnId.ts +1 -0
- package/src/shared/model/consts/dateFormats.ts +5 -0
- package/src/shared/model/consts/index.ts +4 -0
- package/src/shared/model/consts/invalidDate.ts +1 -0
- package/src/shared/model/consts/noPrivilegesMessage.ts +1 -0
- package/src/shared/model/enums/EColumnFilter.ts +16 -0
- package/src/shared/model/enums/EColumnFiltersGroup.ts +10 -0
- package/src/shared/model/enums/EDateFormat.ts +11 -0
- package/src/shared/model/enums/EKey.ts +9 -0
- package/src/shared/model/enums/EKeyCode.ts +8 -0
- package/src/shared/model/enums/ESortType.ts +17 -0
- package/src/shared/model/enums/index.ts +6 -0
- package/src/shared/model/types/IColumn.ts +11 -0
- package/src/shared/model/types/IColumnFilterValue.ts +4 -0
- package/src/shared/model/types/IDownloadManager.ts +6 -0
- package/src/shared/model/types/IEditedRow.ts +5 -0
- package/src/shared/model/types/IExternalVariables.ts +1 -0
- package/src/shared/model/types/IFilter.ts +17 -0
- package/src/shared/model/types/IFilterArguments.ts +14 -0
- package/src/shared/model/types/IGrouping.ts +12 -0
- package/src/shared/model/types/IHotKeysBehavior.ts +15 -0
- package/src/shared/model/types/IObserver.ts +3 -0
- package/src/shared/model/types/IPrinter.ts +24 -0
- package/src/shared/model/types/ISlickRow.ts +1 -0
- package/src/shared/model/types/ISlickTable.ts +41 -0
- package/src/shared/model/types/ITotalCalculator.ts +5 -0
- package/src/shared/model/types/TGridRow.ts +6 -0
- package/src/shared/model/types/index.ts +15 -0
- package/src/shared/ui/ContextSelect/ContextSelect.style.ts +9 -0
- package/src/shared/ui/ContextSelect/ContextSelect.tsx +87 -0
- package/src/shared/ui/ContextSelect/index.ts +2 -0
- package/src/shared/ui/notification/index.ts +1 -0
- package/src/shared/ui/notification/model/index.ts +1 -0
- package/src/shared/ui/notification/ui/index.style.ts +13 -0
- package/src/shared/ui/notification/ui/index.tsx +41 -0
- package/src/shared/ui/styles/WithDatePickerStyles.ts +11 -0
- package/src/shared/ui/styles/index.ts +1 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type GroupingComparerItem,
|
|
3
|
+
MultiColumnSort,
|
|
4
|
+
SingleColumnSort,
|
|
5
|
+
SlickDataView,
|
|
6
|
+
SlickEventData,
|
|
7
|
+
type SortDirectionNumber,
|
|
8
|
+
} from "slickgrid";
|
|
9
|
+
|
|
10
|
+
import { localStore } from "shared/lib/localStrore";
|
|
11
|
+
import { sort } from "shared/lib/sorting";
|
|
12
|
+
import { ESortType } from "shared/model/enums";
|
|
13
|
+
import { IColumn, ISlickTable } from "shared/model/types";
|
|
14
|
+
|
|
15
|
+
export class ColumnSorter implements IColumnSorter {
|
|
16
|
+
protected sort = sort;
|
|
17
|
+
private withFormatter = [ESortType.TEXT, ESortType.NUMBER_FORMATTED];
|
|
18
|
+
|
|
19
|
+
public getSortFunction(tableId: string) {
|
|
20
|
+
let sortedColumnId = "";
|
|
21
|
+
let resetSorting = false;
|
|
22
|
+
let initialGroupComparers: (IComparer | undefined)[];
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
_e: SlickEventData<SingleColumnSort | MultiColumnSort>,
|
|
26
|
+
args: SingleColumnSort | MultiColumnSort,
|
|
27
|
+
): void => {
|
|
28
|
+
const { grid, sortAsc, columnId } = args as SingleColumnSort;
|
|
29
|
+
const sortCol = (args as SingleColumnSort).sortCol as IColumn;
|
|
30
|
+
if (!grid) return;
|
|
31
|
+
if (!sortCol) return;
|
|
32
|
+
const field = sortCol.field;
|
|
33
|
+
if (!field) return;
|
|
34
|
+
const sortAs = sortCol.sortAs;
|
|
35
|
+
if (!sortAs) return;
|
|
36
|
+
|
|
37
|
+
const { formatter } = sortCol;
|
|
38
|
+
const dataView: SlickDataView = grid.getData();
|
|
39
|
+
if (sortAsc && sortedColumnId === sortCol?.id) {
|
|
40
|
+
resetSorting = true;
|
|
41
|
+
localStore.resetTableSorting(tableId);
|
|
42
|
+
grid.setSortColumns([]);
|
|
43
|
+
sortedColumnId = "";
|
|
44
|
+
} else {
|
|
45
|
+
resetSorting = false;
|
|
46
|
+
sortedColumnId = columnId as string;
|
|
47
|
+
localStore.setTableSorting(tableId, columnId, sortAsc);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const sign = sortAsc ? -1 : 1;
|
|
51
|
+
const grouping = dataView.getGrouping();
|
|
52
|
+
const group = grouping.find(({ getter }) => getter === sortCol.id);
|
|
53
|
+
|
|
54
|
+
if (group) {
|
|
55
|
+
if (!initialGroupComparers) {
|
|
56
|
+
initialGroupComparers = grouping.map(({ comparer }) => comparer);
|
|
57
|
+
}
|
|
58
|
+
if (resetSorting) {
|
|
59
|
+
const grouping = dataView.getGrouping();
|
|
60
|
+
const index = grouping.findIndex(
|
|
61
|
+
({ getter }) => getter === sortCol.id,
|
|
62
|
+
);
|
|
63
|
+
grouping[index].comparer = initialGroupComparers[index];
|
|
64
|
+
dataView.refresh();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
group.comparer = (a, b): number => {
|
|
68
|
+
let valueA = a.value;
|
|
69
|
+
let valueB = b.value;
|
|
70
|
+
if (formatter && this.withFormatter.includes(sortAs)) {
|
|
71
|
+
valueA = formatter(0, 0, valueA, sortCol, null, grid);
|
|
72
|
+
valueB = formatter(0, 0, valueB, sortCol, null, grid);
|
|
73
|
+
}
|
|
74
|
+
return (
|
|
75
|
+
this.priority(a, b) || this.compare(valueA, valueB, sign, sortAs)
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
} else {
|
|
79
|
+
const rows = dataView.getItems();
|
|
80
|
+
const idPropertyName = dataView.getIdPropertyName();
|
|
81
|
+
rows.sort((a, b): number => {
|
|
82
|
+
if (resetSorting) {
|
|
83
|
+
return a[idPropertyName] - b[idPropertyName];
|
|
84
|
+
}
|
|
85
|
+
let valueA = a[field];
|
|
86
|
+
let valueB = b[field];
|
|
87
|
+
if (formatter && this.withFormatter.includes(sortAs)) {
|
|
88
|
+
valueA = formatter(0, 0, valueA, sortCol, a, grid);
|
|
89
|
+
valueB = formatter(0, 0, valueB, sortCol, b, grid);
|
|
90
|
+
}
|
|
91
|
+
return (
|
|
92
|
+
this.priority(a, b) || this.compare(valueA, valueB, sign, sortAs)
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
dataView.refresh();
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected priority(_a: Record<string, any>, _b: Record<string, any>): number {
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public restoreSorting(table: ISlickTable): void {
|
|
106
|
+
const grid = table.grid;
|
|
107
|
+
if (!grid) return;
|
|
108
|
+
const params = localStore.getTableSorting(table.id);
|
|
109
|
+
if (params) {
|
|
110
|
+
const { columnId, isAscending } = params;
|
|
111
|
+
const sortFunction = this.getSortFunction(table.id);
|
|
112
|
+
const sortCol = grid.getColumns().find(({ id }) => id === columnId);
|
|
113
|
+
if (sortCol) {
|
|
114
|
+
//@ts-expect-error: The event param is not needed as it is not used
|
|
115
|
+
sortFunction(null, {
|
|
116
|
+
grid,
|
|
117
|
+
columnId,
|
|
118
|
+
sortAsc: isAscending,
|
|
119
|
+
sortCol,
|
|
120
|
+
sortCols: [],
|
|
121
|
+
});
|
|
122
|
+
document
|
|
123
|
+
.querySelector(
|
|
124
|
+
`#${table.id} [data-id="${columnId}"] .slick-sort-indicator`,
|
|
125
|
+
)
|
|
126
|
+
?.classList.add(
|
|
127
|
+
`slick-sort-indicator-${isAscending ? "asc" : "desc"}`,
|
|
128
|
+
);
|
|
129
|
+
grid.invalidate();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
compare(a: any, b: any, sign: -1 | 1, sortAs?: ESortType): number {
|
|
135
|
+
switch (sortAs) {
|
|
136
|
+
case ESortType.DATE: {
|
|
137
|
+
return this.sort.dates(a, b) * sign;
|
|
138
|
+
}
|
|
139
|
+
case ESortType.NUMBER:
|
|
140
|
+
case ESortType.NUMBER_FORMATTED: {
|
|
141
|
+
return this.sort.numbers(a, b) * sign;
|
|
142
|
+
}
|
|
143
|
+
case ESortType.TEXT_NUMERIC: {
|
|
144
|
+
return this.sort.stringsNumeric(a, b) * sign;
|
|
145
|
+
}
|
|
146
|
+
case ESortType.TEXT: {
|
|
147
|
+
return this.sort.strings(a, b) * sign;
|
|
148
|
+
}
|
|
149
|
+
default: {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export const columnSorter = new ColumnSorter();
|
|
157
|
+
|
|
158
|
+
interface IColumnSorter {
|
|
159
|
+
getSortFunction(tableId: string): void;
|
|
160
|
+
restoreSorting(table: ISlickTable): void;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
type IComparer = (
|
|
164
|
+
a: GroupingComparerItem,
|
|
165
|
+
b: GroupingComparerItem,
|
|
166
|
+
) => SortDirectionNumber;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColumnSorter, columnSorter } from "./ColumnSorter";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IColumn,
|
|
5
|
+
IEditedRow,
|
|
6
|
+
ISlickRow,
|
|
7
|
+
ITotalCalculator,
|
|
8
|
+
} from "shared/model/types";
|
|
9
|
+
|
|
10
|
+
export class TotalCalculator implements ITotalCalculator {
|
|
11
|
+
private readonly columnsWithTitle: string[];
|
|
12
|
+
private readonly columnsWithValue: string[];
|
|
13
|
+
|
|
14
|
+
constructor(columnsWithTitle: string[], columnsWithTotal: string[]) {
|
|
15
|
+
this.columnsWithTitle = columnsWithTitle;
|
|
16
|
+
this.columnsWithValue = columnsWithTotal;
|
|
17
|
+
}
|
|
18
|
+
calculate(grid: SlickGrid): void {
|
|
19
|
+
let columnIdx = grid.getColumns().length;
|
|
20
|
+
while (columnIdx--) {
|
|
21
|
+
this.calculateColumn(columnIdx, grid);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
calculateColumn(
|
|
25
|
+
columnIdx: number,
|
|
26
|
+
grid: SlickGrid<ISlickRow, IColumn>,
|
|
27
|
+
): void {
|
|
28
|
+
const column = grid.getColumns()[columnIdx];
|
|
29
|
+
const field = column.field;
|
|
30
|
+
if (this.columnsWithTitle.includes(field)) {
|
|
31
|
+
this.addTitle(grid, columnIdx);
|
|
32
|
+
} else if (this.columnsWithValue.includes(field)) {
|
|
33
|
+
this.addTotal(grid, columnIdx);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
addTitle(grid: SlickGrid, cell: number): void {
|
|
37
|
+
const column = grid.getColumns()[cell];
|
|
38
|
+
const columnId = column.id;
|
|
39
|
+
const footerCell = grid.getFooterRowColumn(columnId);
|
|
40
|
+
footerCell.textContent = "TOTAL:";
|
|
41
|
+
}
|
|
42
|
+
addTotal(grid: SlickGrid, columnIdx: number): void {
|
|
43
|
+
const column = grid.getColumns()[columnIdx];
|
|
44
|
+
const field = column.field;
|
|
45
|
+
const dataView: SlickDataView = grid.getData();
|
|
46
|
+
const items = this.displayedRows(dataView);
|
|
47
|
+
const total = this.totalAmountOf(items, field);
|
|
48
|
+
const footerCell = grid.getFooterRowColumn(field);
|
|
49
|
+
const formatter = column.formatter;
|
|
50
|
+
footerCell.textContent = `${
|
|
51
|
+
formatter ? formatter(0, 0, total, column, null, grid) : total
|
|
52
|
+
}`;
|
|
53
|
+
}
|
|
54
|
+
displayedRows(dataView: SlickDataView): (ISlickRow & IEditedRow)[] {
|
|
55
|
+
const result: (ISlickRow & IEditedRow)[] = [];
|
|
56
|
+
const length = dataView.getLength();
|
|
57
|
+
if (!length) return result;
|
|
58
|
+
for (let i = 0; i < length; i++) {
|
|
59
|
+
result.push(dataView.getItem(i));
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
totalAmountOf(rows: (ISlickRow & IEditedRow)[], field: string): number {
|
|
64
|
+
return rows.reduce((acc, row) => {
|
|
65
|
+
if (!row.isDeleted) {
|
|
66
|
+
acc += Number(row[field]) || 0;
|
|
67
|
+
}
|
|
68
|
+
return acc;
|
|
69
|
+
}, 0);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TotalCalculator } from "./TotalCalculator";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
import { EditorValidationResult } from "slickgrid";
|
|
3
|
+
|
|
4
|
+
import { Dates } from "shared/lib/regexp";
|
|
5
|
+
import { EDateFormat } from "shared/model/enums";
|
|
6
|
+
|
|
7
|
+
export const DateValidator = (value: string): EditorValidationResult => {
|
|
8
|
+
const isDateValid = moment(value, EDateFormat.ui).isValid();
|
|
9
|
+
return {
|
|
10
|
+
valid: isDateValid && Dates.MDY.test(value),
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid, SlickGroupTotals } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { deleteDoubleQuotes, removeHtml } from "shared/lib/strings";
|
|
4
|
+
import {
|
|
5
|
+
IColumn,
|
|
6
|
+
IDownloadManager,
|
|
7
|
+
ISlickRow,
|
|
8
|
+
ISlickTable,
|
|
9
|
+
} from "shared/model/types";
|
|
10
|
+
|
|
11
|
+
import { selectedRows } from "../../../lib";
|
|
12
|
+
|
|
13
|
+
/** Causes the circular dependencies issue */
|
|
14
|
+
const ignore = ["FormatterStatus", "FormatterNumber"]; // todo Use FORMATTER_NUMBER, FORMATTER_STATUS
|
|
15
|
+
|
|
16
|
+
export class DownloadManager implements IDownloadManager {
|
|
17
|
+
table: ISlickTable | null = null;
|
|
18
|
+
|
|
19
|
+
download(table: ISlickTable, clientId: number, name: string) {
|
|
20
|
+
if (!this.table) this.table = table;
|
|
21
|
+
this.table = table;
|
|
22
|
+
const grid = table.grid;
|
|
23
|
+
if (!grid) return;
|
|
24
|
+
const output = this.createCSV(table);
|
|
25
|
+
|
|
26
|
+
const a = document.createElement("a");
|
|
27
|
+
a.href = "data:text/csv;charset=utf-8," + encodeURIComponent(output);
|
|
28
|
+
a.target = "_blank";
|
|
29
|
+
a.download = `${clientId}-${name}-${table.id}.csv`;
|
|
30
|
+
a.click();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
createCSV(table: ISlickTable): string {
|
|
34
|
+
if (!this.table) this.table = table;
|
|
35
|
+
const grid = table.grid;
|
|
36
|
+
if (!grid) return "";
|
|
37
|
+
const title = this.getTitle();
|
|
38
|
+
const header = this.getCSVHeader(grid);
|
|
39
|
+
const body = this.getCSVBody(grid);
|
|
40
|
+
return `${title}${header}${body}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getTitle(): string {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getCSVHeader(grid: SlickGrid): string {
|
|
48
|
+
const columns: IColumn[] = grid.getColumns();
|
|
49
|
+
const columnsForPrinting = columns.filter((el) => el.forPrint);
|
|
50
|
+
|
|
51
|
+
const header = columnsForPrinting.reduce((acc: string, column) => {
|
|
52
|
+
if (typeof column.name === "string") {
|
|
53
|
+
const name = deleteDoubleQuotes(column.name);
|
|
54
|
+
return acc.concat(`"${name}",`);
|
|
55
|
+
} else {
|
|
56
|
+
return acc.concat('" ",');
|
|
57
|
+
}
|
|
58
|
+
}, "");
|
|
59
|
+
|
|
60
|
+
return this.addRowSeparator(header);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getCSVBody(grid: SlickGrid): string {
|
|
64
|
+
const dataView: SlickDataView<ISlickRow> = grid.getData();
|
|
65
|
+
const columns: IColumn[] = grid.getColumns();
|
|
66
|
+
const columnsForPrinting = columns.filter((el) => el.forPrint);
|
|
67
|
+
|
|
68
|
+
return selectedRows(grid).reduce((acc: string, rowIndex) => {
|
|
69
|
+
const metaData = dataView.getItemMetadata(rowIndex);
|
|
70
|
+
const row = dataView.getItem(rowIndex);
|
|
71
|
+
const isGroupTitle = row.__group;
|
|
72
|
+
const isGroupTotal = row.__groupTotals;
|
|
73
|
+
let csvRow = "";
|
|
74
|
+
if (isGroupTitle) {
|
|
75
|
+
const valueWithoutQuotes = deleteDoubleQuotes(removeHtml(row.title));
|
|
76
|
+
csvRow += `"${valueWithoutQuotes}",`;
|
|
77
|
+
} else {
|
|
78
|
+
for (let i = 0; i < columnsForPrinting.length; ++i) {
|
|
79
|
+
const column = columnsForPrinting[i];
|
|
80
|
+
const field = column.field;
|
|
81
|
+
const formatterSpecific = metaData?.columns?.[field]?.formatter;
|
|
82
|
+
const formatter =
|
|
83
|
+
column.printer || formatterSpecific || column.formatter;
|
|
84
|
+
let value = row[field];
|
|
85
|
+
if (isGroupTotal) {
|
|
86
|
+
const totalsFormatter = column.groupTotalsFormatter;
|
|
87
|
+
value = totalsFormatter
|
|
88
|
+
? totalsFormatter(
|
|
89
|
+
row as unknown as SlickGroupTotals,
|
|
90
|
+
column,
|
|
91
|
+
grid,
|
|
92
|
+
)
|
|
93
|
+
: "";
|
|
94
|
+
} else {
|
|
95
|
+
if (formatter && !ignore.includes(formatter.name)) {
|
|
96
|
+
value = formatter(0, 0, value, column, row, grid);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const valueWithoutQuotes = deleteDoubleQuotes(value);
|
|
100
|
+
csvRow += `"${valueWithoutQuotes}",`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return this.addRowSeparator(`${acc}${csvRow}`);
|
|
104
|
+
}, "");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
addRowSeparator(str: string): string {
|
|
108
|
+
return `${str}\n`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DownloadManager } from "./DownloadManager";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DeletedRowsFilter } from "./DeletedRowsFilter";
|
|
2
|
+
|
|
3
|
+
describe("shared | lib | slickgrid | DeletedRowsFilter", () => {
|
|
4
|
+
let filter: DeletedRowsFilter;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
filter = new DeletedRowsFilter();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should return a function when getFilterFn is called", () => {
|
|
11
|
+
const filterFn = filter.getFilterFn();
|
|
12
|
+
|
|
13
|
+
expect(typeof filterFn).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should filter out items with isDeleted property set to true", () => {
|
|
17
|
+
const filterFn = filter.getFilterFn();
|
|
18
|
+
|
|
19
|
+
const items = [
|
|
20
|
+
{ id: 1, isDeleted: false },
|
|
21
|
+
{ id: 2, isDeleted: true },
|
|
22
|
+
{ id: 3, isDeleted: false },
|
|
23
|
+
{ id: 4, isDeleted: true },
|
|
24
|
+
{ id: 5 },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const filteredItems = items.filter(filterFn);
|
|
28
|
+
|
|
29
|
+
expect(filteredItems).toHaveLength(3);
|
|
30
|
+
expect(filteredItems).toEqual([
|
|
31
|
+
{ id: 1, isDeleted: false },
|
|
32
|
+
{ id: 3, isDeleted: false },
|
|
33
|
+
{ id: 5 },
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FilterFn } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { Filter } from "./Filter";
|
|
4
|
+
|
|
5
|
+
export class DeletedRowsFilter extends Filter {
|
|
6
|
+
public getFilterFn(): FilterFn<IRow> {
|
|
7
|
+
// item is undefined until dataView.setItems() method is called
|
|
8
|
+
return (item) => !item?.isDeleted;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type IRow = Record<string, any>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { Filter } from "./Filter";
|
|
4
|
+
|
|
5
|
+
describe("shared | lib | slickgrid | Filter", () => {
|
|
6
|
+
it("should initialize with empty arguments and null grid", () => {
|
|
7
|
+
const filter = new Filter();
|
|
8
|
+
expect(filter.args).toEqual({});
|
|
9
|
+
expect(filter.grid).toBeNull();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should register the filter with the provided grid and table ID", () => {
|
|
13
|
+
const filter = new Filter();
|
|
14
|
+
const mockGrid = {
|
|
15
|
+
getData: jest.fn().mockReturnValue({
|
|
16
|
+
setFilter: jest.fn(),
|
|
17
|
+
setFilterArgs: jest.fn(),
|
|
18
|
+
refresh: jest.fn(),
|
|
19
|
+
}),
|
|
20
|
+
} as unknown as SlickGrid;
|
|
21
|
+
const tableId = "testTable";
|
|
22
|
+
|
|
23
|
+
filter.register(mockGrid, tableId);
|
|
24
|
+
|
|
25
|
+
expect(filter.grid).toBe(mockGrid);
|
|
26
|
+
expect(filter.tableId).toBe(tableId);
|
|
27
|
+
expect(mockGrid.getData().setFilter).toHaveBeenCalledWith(
|
|
28
|
+
expect.any(Function),
|
|
29
|
+
);
|
|
30
|
+
expect(mockGrid.getData().setFilterArgs).toHaveBeenCalledWith(filter.args);
|
|
31
|
+
expect(mockGrid.getData().refresh).toHaveBeenCalled();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should reset arguments to an empty object when reset is called", () => {
|
|
35
|
+
const filter = new Filter();
|
|
36
|
+
const mockGrid = {
|
|
37
|
+
getData: jest.fn().mockReturnValue({
|
|
38
|
+
setFilterArgs: jest.fn(),
|
|
39
|
+
refresh: jest.fn(),
|
|
40
|
+
}),
|
|
41
|
+
} as unknown as SlickGrid;
|
|
42
|
+
const initialArgs = { key: "value" };
|
|
43
|
+
|
|
44
|
+
filter.grid = mockGrid;
|
|
45
|
+
filter.args = initialArgs;
|
|
46
|
+
|
|
47
|
+
filter.reset();
|
|
48
|
+
|
|
49
|
+
expect(filter.args).toEqual({});
|
|
50
|
+
expect(mockGrid.getData().setFilterArgs).toHaveBeenCalledWith({});
|
|
51
|
+
expect(mockGrid.getData().refresh).toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should return an empty array from the print method", () => {
|
|
55
|
+
const filter = new Filter();
|
|
56
|
+
const result = filter.print();
|
|
57
|
+
expect(Array.isArray(result)).toBe(true);
|
|
58
|
+
expect(result).toEqual([]);
|
|
59
|
+
expect(result.length).toBe(0);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should not attempt to reset if grid is null", () => {
|
|
63
|
+
const filter = new Filter();
|
|
64
|
+
filter.grid = null;
|
|
65
|
+
|
|
66
|
+
filter.reset();
|
|
67
|
+
|
|
68
|
+
expect(filter.args).toEqual({});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should not attempt to update data view if grid is null when setting args", () => {
|
|
72
|
+
const filter = new Filter();
|
|
73
|
+
const newArgs = { key: "value" };
|
|
74
|
+
|
|
75
|
+
filter.grid = null;
|
|
76
|
+
filter.args = newArgs;
|
|
77
|
+
|
|
78
|
+
expect(filter.args).toEqual(newArgs);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FilterFn, SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { IFilter, IFilterArguments } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export class Filter implements IFilter {
|
|
6
|
+
private _args: IFilterArguments = {};
|
|
7
|
+
private _grid: SlickGrid | null = null;
|
|
8
|
+
private _tableId = "";
|
|
9
|
+
public getFilterFn(): FilterFn<Record<string, any>> {
|
|
10
|
+
return (): boolean => true;
|
|
11
|
+
}
|
|
12
|
+
public register(grid: SlickGrid, tableId: string): void {
|
|
13
|
+
this.tableId = tableId;
|
|
14
|
+
this.grid = grid;
|
|
15
|
+
const dataView: SlickDataView = grid.getData();
|
|
16
|
+
dataView.setFilter(this.getFilterFn());
|
|
17
|
+
dataView.setFilterArgs(this.args);
|
|
18
|
+
dataView.refresh();
|
|
19
|
+
}
|
|
20
|
+
public reset() {
|
|
21
|
+
if (!this.grid) return;
|
|
22
|
+
this.args = {};
|
|
23
|
+
const dataView: SlickDataView = this.grid.getData();
|
|
24
|
+
dataView.setFilterArgs(this.args);
|
|
25
|
+
dataView.refresh();
|
|
26
|
+
}
|
|
27
|
+
public print(): HTMLTableRowElement[] {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
set grid(grid) {
|
|
31
|
+
this._grid = grid;
|
|
32
|
+
}
|
|
33
|
+
get grid() {
|
|
34
|
+
return this._grid;
|
|
35
|
+
}
|
|
36
|
+
set args(args) {
|
|
37
|
+
this._args = args;
|
|
38
|
+
if (!this.grid) return;
|
|
39
|
+
const dataView: SlickDataView = this.grid.getData();
|
|
40
|
+
dataView.setFilterArgs(args);
|
|
41
|
+
dataView.refresh();
|
|
42
|
+
}
|
|
43
|
+
get args() {
|
|
44
|
+
return this._args;
|
|
45
|
+
}
|
|
46
|
+
set tableId(tableId: string) {
|
|
47
|
+
this._tableId = tableId;
|
|
48
|
+
}
|
|
49
|
+
get tableId() {
|
|
50
|
+
return this._tableId;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FilterFn, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { IFilter, IFilterArguments } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export class WithoutFilter implements IFilter {
|
|
6
|
+
private _args: IFilterArguments = {};
|
|
7
|
+
private _grid: SlickGrid | null = null;
|
|
8
|
+
private _tableId = "";
|
|
9
|
+
public getFilterFn(): FilterFn<Record<string, any>> {
|
|
10
|
+
return (): boolean => true;
|
|
11
|
+
}
|
|
12
|
+
public register(): void {}
|
|
13
|
+
public print(): HTMLTableRowElement[] {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
public reset() {}
|
|
17
|
+
|
|
18
|
+
get args() {
|
|
19
|
+
return this._args;
|
|
20
|
+
}
|
|
21
|
+
get grid() {
|
|
22
|
+
return this._grid;
|
|
23
|
+
}
|
|
24
|
+
get tableId() {
|
|
25
|
+
return this._tableId;
|
|
26
|
+
}
|
|
27
|
+
set args(_args) {}
|
|
28
|
+
set grid(_grid) {}
|
|
29
|
+
set tableId(_tableId) {}
|
|
30
|
+
}
|