slick-table 1.0.18 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +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 +163 -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 +31 -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 +15 -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,18 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
/** Returns unique id for a new row
|
|
4
|
+
* @param { SlickGrid } grid - the SlickGrid instance
|
|
5
|
+
* @returns { number } unique ID value (highest existing `id` + 1).
|
|
6
|
+
* */
|
|
7
|
+
export const getNextId = (grid: SlickGrid): number => {
|
|
8
|
+
const dataView: SlickDataView = grid.getData();
|
|
9
|
+
const idPropertyName = dataView.getIdPropertyName();
|
|
10
|
+
const items = dataView.getItems();
|
|
11
|
+
let result = 0;
|
|
12
|
+
items.forEach((item) => {
|
|
13
|
+
if (item[idPropertyName] > result) {
|
|
14
|
+
result = item[idPropertyName];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return result + 1;
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { addNewRow } from "./addNewRow";
|
|
2
|
+
export { commitCurrentEdit } from "./commitCurrentEdit";
|
|
3
|
+
export { copySelectedRows } from "./copySelectedRows";
|
|
4
|
+
export { deleteRows } from "./deleteRows";
|
|
5
|
+
export { getActiveRowId } from "./getActiveRowId";
|
|
6
|
+
export { getDisplayedRows } from "./getDisplayedRows";
|
|
7
|
+
export { getNextId } from "./getNextId";
|
|
8
|
+
export { getLastRow } from "./getLastRow";
|
|
9
|
+
export { isDeletionDangerous } from "./isDeletionDangerous";
|
|
10
|
+
export { wereEdited } from "./wereEdited";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SlickDataView } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { TGridRow } from "shared/model/types";
|
|
4
|
+
import { ISlickTable } from "shared/model/types";
|
|
5
|
+
|
|
6
|
+
export function isDeletionDangerous(table: ISlickTable): boolean {
|
|
7
|
+
const grid = table.grid;
|
|
8
|
+
if (!grid) return false;
|
|
9
|
+
const dataView: SlickDataView<TGridRow> = grid.getData();
|
|
10
|
+
const selectedRows = grid.getSelectedRows();
|
|
11
|
+
if (!selectedRows.length) return false;
|
|
12
|
+
let isDangerous = false;
|
|
13
|
+
for (const rowNumber of selectedRows) {
|
|
14
|
+
const row = dataView.getItem(rowNumber);
|
|
15
|
+
if (!row.isNew) {
|
|
16
|
+
isDangerous = true;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return isDangerous;
|
|
21
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SlickGroup } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { IColumn } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { formatterGroupTotals } from "./formatterGroupTotals";
|
|
6
|
+
|
|
7
|
+
describe("sumTotalsFormatter", () => {
|
|
8
|
+
it("should return an empty string when totals.sum is undefined", () => {
|
|
9
|
+
const totals = {
|
|
10
|
+
group: { level: 0 } as SlickGroup,
|
|
11
|
+
initialized: true,
|
|
12
|
+
sum: undefined,
|
|
13
|
+
};
|
|
14
|
+
const columnDef: IColumn = { field: "someField" };
|
|
15
|
+
|
|
16
|
+
const result = formatterGroupTotals(totals as any, columnDef);
|
|
17
|
+
|
|
18
|
+
expect(result).toBe("TOTAL: ");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should return 'TOTAL: 1,000.00' for group level 0", () => {
|
|
22
|
+
const totals = {
|
|
23
|
+
group: { level: 0 } as SlickGroup,
|
|
24
|
+
initialized: true,
|
|
25
|
+
sum: { someField: 1000 },
|
|
26
|
+
};
|
|
27
|
+
const columnDef: IColumn = { field: "someField" };
|
|
28
|
+
|
|
29
|
+
const result = formatterGroupTotals(totals as any, columnDef);
|
|
30
|
+
|
|
31
|
+
expect(result).toBe("TOTAL: 1,000.00");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should return 'total: 1,000.00' for group levels greater than 0", () => {
|
|
35
|
+
const totals = {
|
|
36
|
+
group: { level: 1 } as SlickGroup,
|
|
37
|
+
initialized: true,
|
|
38
|
+
sum: { someField: 1000 },
|
|
39
|
+
};
|
|
40
|
+
const columnDef: IColumn = { field: "someField" };
|
|
41
|
+
|
|
42
|
+
const result = formatterGroupTotals(totals as any, columnDef);
|
|
43
|
+
|
|
44
|
+
expect(result).toBe("total: 1,000.00");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should return an empty string when totals.sum[columnDef.field] is null", () => {
|
|
48
|
+
const totals = {
|
|
49
|
+
group: { level: 0 } as SlickGroup,
|
|
50
|
+
initialized: true,
|
|
51
|
+
sum: { someField: null },
|
|
52
|
+
};
|
|
53
|
+
const columnDef: IColumn = { field: "someField" };
|
|
54
|
+
|
|
55
|
+
const result = formatterGroupTotals(totals as any, columnDef);
|
|
56
|
+
|
|
57
|
+
expect(result).toBe("");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SlickGroup } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { formatNumber } from "shared/lib/format";
|
|
4
|
+
import { IColumn } from "shared/model/types";
|
|
5
|
+
|
|
6
|
+
export const formatterGroupTotals = (
|
|
7
|
+
totals: {
|
|
8
|
+
group: SlickGroup;
|
|
9
|
+
initialized: boolean;
|
|
10
|
+
sum: Record<string, number>;
|
|
11
|
+
},
|
|
12
|
+
columnDef: IColumn,
|
|
13
|
+
): string => {
|
|
14
|
+
const val = totals.sum && totals.sum[columnDef.field];
|
|
15
|
+
if (val !== null) {
|
|
16
|
+
const groupLevel = totals.group.level; // level can be 0, 1, ...
|
|
17
|
+
const title = groupLevel ? "total" : "TOTAL";
|
|
18
|
+
return `${title}: ${formatNumber(val)}`;
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatterGroupTotals } from "./formatterGroupTotals";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
export const highlightCell = (
|
|
4
|
+
grid: SlickGrid,
|
|
5
|
+
rowId: number,
|
|
6
|
+
columnId: string,
|
|
7
|
+
): void => {
|
|
8
|
+
const dataView: SlickDataView = grid.getData();
|
|
9
|
+
const rowNumber = dataView.getRowById(rowId);
|
|
10
|
+
if (rowNumber === undefined) return;
|
|
11
|
+
const columnIndex = grid.getColumnIndex(columnId);
|
|
12
|
+
grid.gotoCell(rowNumber, columnIndex);
|
|
13
|
+
grid.setCellCssStyles(`${rowNumber}`, {
|
|
14
|
+
[rowNumber]: {
|
|
15
|
+
[columnId]: "wink",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
grid.removeCellCssStyles(`${rowNumber}`);
|
|
20
|
+
}, 1500);
|
|
21
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CssStyleHash, SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { getColumnsHash } from "./getColumnsHash";
|
|
4
|
+
|
|
5
|
+
export function highlightColumns(grid: SlickGrid, columnIds: string[]): void {
|
|
6
|
+
const dataView: SlickDataView = grid.getData();
|
|
7
|
+
const rowsNumber = dataView.getLength();
|
|
8
|
+
const hash = getHash(rowsNumber, columnIds);
|
|
9
|
+
grid.setCellCssStyles("wink", hash);
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
grid.removeCellCssStyles("wink");
|
|
12
|
+
}, 1500);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getHash(rowsNumber: number, columnIds: string[]): CssStyleHash {
|
|
16
|
+
const hashValue = getColumnsHash(columnIds);
|
|
17
|
+
const hash: CssStyleHash = {};
|
|
18
|
+
let i = 0;
|
|
19
|
+
while (i < rowsNumber) {
|
|
20
|
+
hash[i] = hashValue;
|
|
21
|
+
i++;
|
|
22
|
+
}
|
|
23
|
+
return hash;
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnEvent } from "shared/lib/an-event";
|
|
2
|
+
import { ISlickTable } from "shared/model/types";
|
|
3
|
+
|
|
4
|
+
/** If there are several tables on a page we want to use hotkeys in one table only.
|
|
5
|
+
* The event helps us to make all tables on the page inactive. */
|
|
6
|
+
class EventClickOnTable extends AnEvent {
|
|
7
|
+
private _activeTable: ISlickTable | null = null;
|
|
8
|
+
|
|
9
|
+
get activeTable() {
|
|
10
|
+
return this._activeTable;
|
|
11
|
+
}
|
|
12
|
+
set activeTable(table: ISlickTable | null) {
|
|
13
|
+
this._activeTable = table;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const eventClickOnTable = new EventClickOnTable();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { eventClickOnTable } from "./eventClickOnTable";
|
|
6
|
+
|
|
7
|
+
export const useHotKeys = (table: ISlickTable): void => {
|
|
8
|
+
function makeNotActive() {
|
|
9
|
+
if (table.id !== eventClickOnTable.activeTable?.id) {
|
|
10
|
+
table.isActive = false;
|
|
11
|
+
const grid = table.grid;
|
|
12
|
+
grid?.resetActiveCell();
|
|
13
|
+
grid?.setSelectedRows([]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function makeActive() {
|
|
17
|
+
table.isActive = true;
|
|
18
|
+
eventClickOnTable.activeTable = table;
|
|
19
|
+
eventClickOnTable.notify();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
eventClickOnTable.subscribe(makeNotActive);
|
|
24
|
+
//@ts-ignore
|
|
25
|
+
document.addEventListener("keydown", table.handleKeyboardEvent.bind(table));
|
|
26
|
+
const tableContainer = document.getElementById(table.id);
|
|
27
|
+
if (!tableContainer) return;
|
|
28
|
+
tableContainer.addEventListener("click", makeActive, true);
|
|
29
|
+
return () => {
|
|
30
|
+
eventClickOnTable.unsubscribe(makeNotActive);
|
|
31
|
+
document.removeEventListener(
|
|
32
|
+
"keydown",
|
|
33
|
+
//@ts-ignore
|
|
34
|
+
table.handleKeyboardEvent.bind(table),
|
|
35
|
+
);
|
|
36
|
+
tableContainer.removeEventListener("click", makeActive, true);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export const useListenIfTablesWereEdited = (tables: ISlickTable[]): boolean => {
|
|
6
|
+
const [editedTables, setEditedTables] = useState<Record<string, boolean>>(
|
|
7
|
+
getTablesIsEditedInfo(tables),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const callback = (table: ISlickTable): void => {
|
|
12
|
+
setEditedTables((prev) => ({
|
|
13
|
+
...prev,
|
|
14
|
+
[table.id]: table.isEdited,
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
tables.forEach((table) => {
|
|
18
|
+
table.registerObservers(callback);
|
|
19
|
+
});
|
|
20
|
+
return () => {
|
|
21
|
+
tables.forEach((table) => {
|
|
22
|
+
table.deleteObserver(callback);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return Object.values(editedTables).some((isEdited) => isEdited);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function getTablesIsEditedInfo(tables: ISlickTable[]): Record<string, boolean> {
|
|
31
|
+
const result: Record<string, boolean> = {};
|
|
32
|
+
for (const table of tables) {
|
|
33
|
+
result[table.id] = table.isEdited;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { debounce } from "shared/lib/debounce";
|
|
4
|
+
import { ISlickTable } from "shared/model/types";
|
|
5
|
+
|
|
6
|
+
export function useResizeCanvas(table: ISlickTable) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
function resizeCanvas() {
|
|
9
|
+
table.grid?.resizeCanvas();
|
|
10
|
+
}
|
|
11
|
+
const callback = debounce(resizeCanvas);
|
|
12
|
+
|
|
13
|
+
window.addEventListener("resize", callback);
|
|
14
|
+
return () => {
|
|
15
|
+
window.removeEventListener("resize", callback);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export const useUpdateTotal = (table: ISlickTable): void => {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
function callback(table: ISlickTable): void {
|
|
8
|
+
const grid = table.grid;
|
|
9
|
+
if (!grid) return;
|
|
10
|
+
table.totalCalculator?.calculate(grid);
|
|
11
|
+
}
|
|
12
|
+
table.registerObservers(callback);
|
|
13
|
+
return () => {
|
|
14
|
+
table.deleteObserver(callback);
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { hotKeysCopy } from "./hotKeysCopy";
|
|
2
|
+
export { hotKeysDelete } from "./hotKeysDelete";
|
|
3
|
+
export { hotKeysRedo } from "./hotKeysRedo";
|
|
4
|
+
export { hotKeysReverse } from "./hotKeysReverse";
|
|
5
|
+
export { hotKeysUndo } from "./hotKeysUndo";
|
|
6
|
+
export { nothingToCopy } from "./nothingToCopy";
|
|
7
|
+
export { positionToPaste } from "./positionToPaste";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { showNotification } from "shared/ui/notification";
|
|
4
|
+
|
|
5
|
+
/** Check if the user has selected rows or clicked on a row to make it active */
|
|
6
|
+
export function nothingToCopy(grid: SlickGrid): boolean {
|
|
7
|
+
const activeCell = grid.getActiveCell();
|
|
8
|
+
const selectedRows = grid.getSelectedRows();
|
|
9
|
+
const result = !selectedRows.length && !activeCell;
|
|
10
|
+
if (result) {
|
|
11
|
+
showNotification("Select a row to copy", "info");
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { getActiveRowId } from "../functions";
|
|
4
|
+
|
|
5
|
+
export function positionToPaste(grid: SlickGrid) {
|
|
6
|
+
const activeRowId = getActiveRowId(grid);
|
|
7
|
+
const dataView: SlickDataView = grid.getData();
|
|
8
|
+
const rows = dataView.getItems();
|
|
9
|
+
const activeRow = rows.findIndex((row) => row.id === activeRowId) + 1;
|
|
10
|
+
const lastRow = rows.length;
|
|
11
|
+
return activeRow ? activeRow : lastRow;
|
|
12
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export { openContextMenu } from "./contextMenu";
|
|
2
|
+
export {
|
|
3
|
+
useHotKeys,
|
|
4
|
+
useListenIfTablesWereEdited,
|
|
5
|
+
useResizeCanvas,
|
|
6
|
+
useUpdateTotal,
|
|
7
|
+
} from "./hooks";
|
|
8
|
+
export {
|
|
9
|
+
hotKeysCopy,
|
|
10
|
+
hotKeysDelete,
|
|
11
|
+
hotKeysRedo,
|
|
12
|
+
hotKeysReverse,
|
|
13
|
+
hotKeysUndo,
|
|
14
|
+
nothingToCopy,
|
|
15
|
+
positionToPaste,
|
|
16
|
+
} from "./hotKeys";
|
|
17
|
+
export {
|
|
18
|
+
getOnKeyDownCallback,
|
|
19
|
+
onCellChange,
|
|
20
|
+
onRowCountChanged,
|
|
21
|
+
onRowsChanged,
|
|
22
|
+
} from "./callbacks";
|
|
23
|
+
export {
|
|
24
|
+
Autocomplete,
|
|
25
|
+
EditorAmount,
|
|
26
|
+
EditorAutocomplete,
|
|
27
|
+
EditorDate,
|
|
28
|
+
EditorSelectString,
|
|
29
|
+
EditorSelectNumber,
|
|
30
|
+
EditorSelectWithSearch,
|
|
31
|
+
} from "./editors";
|
|
32
|
+
export {
|
|
33
|
+
FORMATTER_NUMBER,
|
|
34
|
+
DateFormatter,
|
|
35
|
+
FormatterCheck,
|
|
36
|
+
getFormatterNumber,
|
|
37
|
+
PercentFormatter,
|
|
38
|
+
FormatterCheckPrinter,
|
|
39
|
+
StringFormatter,
|
|
40
|
+
} from "./formatters";
|
|
41
|
+
export {
|
|
42
|
+
commitCurrentEdit,
|
|
43
|
+
copySelectedRows,
|
|
44
|
+
deleteRows,
|
|
45
|
+
getActiveRowId,
|
|
46
|
+
getDisplayedRows,
|
|
47
|
+
getLastRow,
|
|
48
|
+
getNextId,
|
|
49
|
+
isDeletionDangerous,
|
|
50
|
+
wereEdited,
|
|
51
|
+
} from "./functions";
|
|
52
|
+
export { formatterGroupTotals } from "./grouping";
|
|
53
|
+
export { highlightCell, highlightColumns } from "./highlighting";
|
|
54
|
+
export { selectedRows, getUpdates } from "./selection";
|
|
55
|
+
export { ColumnSorter, columnSorter } from "./sorting";
|
|
56
|
+
export { TotalCalculator } from "./total-calculator";
|
|
57
|
+
export {
|
|
58
|
+
DateValidator,
|
|
59
|
+
EmptyStringValidator,
|
|
60
|
+
LengthValidator,
|
|
61
|
+
} from "./validators";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SlickDataView } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export function getUpdates<T = TRow>(table: ISlickTable): IUpdates<T> {
|
|
6
|
+
const result: IUpdates<T> = {
|
|
7
|
+
deleted: [],
|
|
8
|
+
updated: [],
|
|
9
|
+
};
|
|
10
|
+
const grid = table.grid;
|
|
11
|
+
if (!grid) return result;
|
|
12
|
+
const dataView: SlickDataView = grid.getData();
|
|
13
|
+
const rows = dataView.getItems();
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < rows.length; i++) {
|
|
16
|
+
const { id, isDeleted, isEdited, isNew } = rows[i];
|
|
17
|
+
if (isDeleted) {
|
|
18
|
+
if (isNew) continue;
|
|
19
|
+
result.deleted.push(id);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (isEdited) {
|
|
23
|
+
result.updated.push({
|
|
24
|
+
...rows[i],
|
|
25
|
+
id: isNew ? undefined : id,
|
|
26
|
+
isEdited: undefined,
|
|
27
|
+
isDeleted: undefined,
|
|
28
|
+
isNew: undefined,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface IUpdates<T> {
|
|
37
|
+
updated: T[];
|
|
38
|
+
deleted: number[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type TRow = Record<string, number | string | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
export function selectedRows(grid: SlickGrid): number[] {
|
|
4
|
+
if (!grid.getSelectionModel()) return getAll(grid);
|
|
5
|
+
|
|
6
|
+
let rows = grid.getSelectedRows();
|
|
7
|
+
rows.sort((a, b) => a - b);
|
|
8
|
+
if (rows.length === 0) {
|
|
9
|
+
rows = getAll(grid);
|
|
10
|
+
}
|
|
11
|
+
return rows;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getAll(grid: SlickGrid): number[] {
|
|
15
|
+
const dataView: SlickDataView = grid.getData();
|
|
16
|
+
return Array.from({ length: dataView.getLength() }, (_, i) => i);
|
|
17
|
+
}
|