slick-table 0.0.14 → 0.0.16
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/.prettierignore +2 -0
- package/.prettierrc +22 -0
- package/dist/tsconfig.build-types.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/eslint.config.js +23 -0
- package/index.html +13 -0
- package/package.json +1 -2
- 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/portal/index.ts +3 -0
- package/src/entities/portal/lib/index.ts +1 -0
- package/src/entities/portal/lib/visibility/index.ts +1 -0
- package/src/entities/portal/lib/visibility/makeVisible.ts +9 -0
- package/src/entities/portal/model/index.ts +1 -0
- package/src/entities/portal/model/portalId.ts +1 -0
- package/src/entities/portal/ui/Overlay/Overlay.style.ts +14 -0
- package/src/entities/portal/ui/Overlay/Overlay.test.tsx +19 -0
- package/src/entities/portal/ui/Overlay/Overlay.tsx +20 -0
- package/src/entities/portal/ui/Overlay/index.ts +1 -0
- package/src/entities/portal/ui/Portal.style.ts +20 -0
- package/src/entities/portal/ui/Portal.test.tsx +48 -0
- package/src/entities/portal/ui/Portal.tsx +26 -0
- package/src/entities/portal/ui/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/index.ts +2 -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 +41 -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 +25 -0
- package/src/features/context-menu/lib/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 +51 -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 +2 -0
- package/src/main.tsx +15 -0
- package/src/pages/main/index.ts +1 -0
- package/src/pages/main/lib/columns.ts +33 -0
- package/src/pages/main/lib/index.ts +3 -0
- package/src/pages/main/lib/options.ts +6 -0
- package/src/pages/main/lib/table.ts +11 -0
- package/src/pages/main/ui/Main.style.ts +18 -0
- package/src/pages/main/ui/Main.tsx +30 -0
- package/src/pages/main/ui/index.ts +1 -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/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 +68 -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 +14 -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 +152 -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 +23 -0
- package/src/shared/lib/slickgrid/lib/functions/commitCurrentEdit.ts +6 -0
- package/src/shared/lib/slickgrid/lib/functions/copySelectedRows.ts +35 -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/getMaxId.ts +13 -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/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/grouping/sumTotalsFormatter.ts +21 -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 +3 -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/useUpdateTotal.ts +19 -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 +59 -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 +89 -0
- package/src/shared/lib/slickgrid/lib/sorting/index.ts +1 -0
- package/src/shared/lib/slickgrid/lib/totals-row/addTitle.ts +8 -0
- package/src/shared/lib/slickgrid/lib/totals-row/addTotalSum.ts +16 -0
- package/src/shared/lib/slickgrid/lib/totals-row/index.ts +2 -0
- package/src/shared/lib/slickgrid/lib/totals-row/totalAmountOf.ts +13 -0
- package/src/shared/lib/slickgrid/lib/totals-row/updateTotal.ts +25 -0
- package/src/shared/lib/slickgrid/lib/totals-row/updateTotals.ts +10 -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.ts +54 -0
- package/src/shared/lib/slickgrid/model/SlickTable/filters/WithoutFilter.ts +30 -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.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.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 +118 -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 +21 -0
- package/src/shared/lib/slickgrid/model/SlickTable/hotKeys/decorators/RedoUndoOnly.ts +25 -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 +9 -0
- package/src/shared/lib/slickgrid/model/SlickTable/index.ts +18 -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.ts +148 -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 +17 -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 +140 -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 +42 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/model/types/index.ts +1 -0
- package/src/shared/lib/slickgrid/ui/SlickgridTable/ui/SlickgridTable.tsx +51 -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 +156 -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 +26 -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 +8 -0
- package/src/shared/model/enums/EKeyCode.ts +8 -0
- package/src/shared/model/enums/ESortType.ts +6 -0
- package/src/shared/model/enums/index.ts +6 -0
- package/src/shared/model/types/IArguments.ts +14 -0
- package/src/shared/model/types/IColumn.ts +13 -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 +30 -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 +38 -0
- package/src/shared/model/types/TGridRow.ts +6 -0
- package/src/shared/model/types/index.ts +14 -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
- package/tsconfig.build-types.json +21 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +23 -0
- package/vite.config.ts +34 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
export const getMaxId = (grid: SlickGrid): number => {
|
|
4
|
+
const dataView: SlickDataView<{ id: number }> = grid.getData();
|
|
5
|
+
const items = dataView.getItems();
|
|
6
|
+
let result = 0;
|
|
7
|
+
items.forEach((item) => {
|
|
8
|
+
if (item.id > result) {
|
|
9
|
+
result = item.id;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
@@ -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 { getMaxId } from "./getMaxId";
|
|
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 @@
|
|
|
1
|
+
export { sumTotalsFormatter } from "./sumTotalsFormatter";
|
|
@@ -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 sumTotalsFormatter = (
|
|
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,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 tablesIsEditedInfo: Record<string, boolean> = {};
|
|
32
|
+
for (const table of tables) {
|
|
33
|
+
tablesIsEditedInfo[table.id] = table.isEdited;
|
|
34
|
+
}
|
|
35
|
+
return tablesIsEditedInfo;
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { updateTotals } from "../totals-row";
|
|
6
|
+
|
|
7
|
+
export const useUpdateTotal = (table: ISlickTable): void => {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
function callback(table: ISlickTable): void {
|
|
10
|
+
const grid = table.grid;
|
|
11
|
+
if (!grid) return;
|
|
12
|
+
updateTotals(grid);
|
|
13
|
+
}
|
|
14
|
+
table.registerObservers(callback);
|
|
15
|
+
return () => {
|
|
16
|
+
table.deleteObserver(callback);
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
};
|
|
@@ -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,59 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useHotKeys,
|
|
3
|
+
useListenIfTablesWereEdited,
|
|
4
|
+
useUpdateTotal,
|
|
5
|
+
} from "./hooks";
|
|
6
|
+
export {
|
|
7
|
+
hotKeysCopy,
|
|
8
|
+
hotKeysDelete,
|
|
9
|
+
hotKeysRedo,
|
|
10
|
+
hotKeysReverse,
|
|
11
|
+
hotKeysUndo,
|
|
12
|
+
nothingToCopy,
|
|
13
|
+
positionToPaste,
|
|
14
|
+
} from "./hotKeys";
|
|
15
|
+
export {
|
|
16
|
+
getOnKeyDownCallback,
|
|
17
|
+
onCellChange,
|
|
18
|
+
onRowCountChanged,
|
|
19
|
+
onRowsChanged,
|
|
20
|
+
} from "./callbacks";
|
|
21
|
+
export {
|
|
22
|
+
Autocomplete,
|
|
23
|
+
EditorAmount,
|
|
24
|
+
EditorAutocomplete,
|
|
25
|
+
EditorDate,
|
|
26
|
+
EditorSelectString,
|
|
27
|
+
EditorSelectNumber,
|
|
28
|
+
EditorSelectWithSearch,
|
|
29
|
+
} from "./editors";
|
|
30
|
+
export {
|
|
31
|
+
FORMATTER_NUMBER,
|
|
32
|
+
DateFormatter,
|
|
33
|
+
FormatterCheck,
|
|
34
|
+
getFormatterNumber,
|
|
35
|
+
PercentFormatter,
|
|
36
|
+
FormatterCheckPrinter,
|
|
37
|
+
StringFormatter,
|
|
38
|
+
} from "./formatters";
|
|
39
|
+
export {
|
|
40
|
+
commitCurrentEdit,
|
|
41
|
+
copySelectedRows,
|
|
42
|
+
deleteRows,
|
|
43
|
+
getActiveRowId,
|
|
44
|
+
getDisplayedRows,
|
|
45
|
+
getLastRow,
|
|
46
|
+
getMaxId,
|
|
47
|
+
isDeletionDangerous,
|
|
48
|
+
wereEdited,
|
|
49
|
+
} from "./functions";
|
|
50
|
+
export { sumTotalsFormatter } from "./grouping";
|
|
51
|
+
export { highlightCell, highlightColumns } from "./highlighting";
|
|
52
|
+
export { selectedRows, getUpdates } from "./selection";
|
|
53
|
+
export { ColumnSorter, columnSorter } from "./sorting";
|
|
54
|
+
export { totalAmountOf, updateTotals } from "./totals-row";
|
|
55
|
+
export {
|
|
56
|
+
DateValidator,
|
|
57
|
+
EmptyStringValidator,
|
|
58
|
+
LengthValidator,
|
|
59
|
+
} 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
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MultiColumnSort,
|
|
3
|
+
SingleColumnSort,
|
|
4
|
+
SlickDataView,
|
|
5
|
+
SlickEventData,
|
|
6
|
+
} from "slickgrid";
|
|
7
|
+
|
|
8
|
+
import { sort } from "shared/lib/sorting";
|
|
9
|
+
import { ESortType } from "shared/model/enums";
|
|
10
|
+
import { IColumn } from "shared/model/types";
|
|
11
|
+
|
|
12
|
+
export class ColumnSorter implements IColumnSorter {
|
|
13
|
+
private resetSorting = false;
|
|
14
|
+
protected sort = sort;
|
|
15
|
+
private sortedColumnId = "";
|
|
16
|
+
private withFormatter = [ESortType.TEXT, ESortType.NUMBER_FORMATTED];
|
|
17
|
+
public onSort() {
|
|
18
|
+
return (
|
|
19
|
+
_e: SlickEventData<SingleColumnSort | MultiColumnSort>,
|
|
20
|
+
args: SingleColumnSort | MultiColumnSort,
|
|
21
|
+
): void => {
|
|
22
|
+
const { grid, sortCol, sortAsc } = args as SingleColumnSort;
|
|
23
|
+
if (!grid) return;
|
|
24
|
+
const { formatter } = sortCol as IColumn;
|
|
25
|
+
|
|
26
|
+
this.reset(args);
|
|
27
|
+
|
|
28
|
+
const dataView: SlickDataView = grid.getData();
|
|
29
|
+
//@ts-ignore
|
|
30
|
+
const sortAs = sortCol?.sortAs as ESortType;
|
|
31
|
+
const rows = dataView.getItems();
|
|
32
|
+
rows.sort((a, b) => {
|
|
33
|
+
if (this.resetSorting) {
|
|
34
|
+
return a.id - b.id;
|
|
35
|
+
}
|
|
36
|
+
const field = sortCol?.field;
|
|
37
|
+
if (!field) return 0;
|
|
38
|
+
const sign = sortAsc ? 1 : -1;
|
|
39
|
+
let valueA = a[field];
|
|
40
|
+
let valueB = b[field];
|
|
41
|
+
if (formatter && this.withFormatter.includes(sortAs)) {
|
|
42
|
+
valueA = formatter(0, 0, valueA, sortCol, a, grid);
|
|
43
|
+
valueB = formatter(0, 0, valueB, sortCol, b, grid);
|
|
44
|
+
}
|
|
45
|
+
switch (sortAs) {
|
|
46
|
+
case ESortType.DATE: {
|
|
47
|
+
return (
|
|
48
|
+
this.priority(a, b) || this.sort.dates(valueA, valueB) * sign
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
case ESortType.NUMBER:
|
|
52
|
+
case ESortType.NUMBER_FORMATTED: {
|
|
53
|
+
return (
|
|
54
|
+
this.priority(a, b) || this.sort.numbers(valueA, valueB) * sign
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
case ESortType.TEXT: {
|
|
58
|
+
return (
|
|
59
|
+
this.priority(a, b) || this.sort.strings(valueA, valueB) * sign
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
dataView.refresh();
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
protected priority(_a: Record<string, any>, _b: Record<string, any>): number {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
private reset(args: SingleColumnSort | MultiColumnSort): void {
|
|
71
|
+
const { grid, sortCol, sortAsc } = args as SingleColumnSort;
|
|
72
|
+
if (!grid) return;
|
|
73
|
+
if (sortAsc && this.sortedColumnId === sortCol?.id) {
|
|
74
|
+
this.resetSorting = true;
|
|
75
|
+
grid.setSortColumns([]);
|
|
76
|
+
this.sortedColumnId = "";
|
|
77
|
+
} else {
|
|
78
|
+
this.resetSorting = false;
|
|
79
|
+
const sortedColumns = grid.getSortColumns();
|
|
80
|
+
this.sortedColumnId = sortedColumns[0]?.columnId as string;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const columnSorter = new ColumnSorter();
|
|
86
|
+
|
|
87
|
+
interface IColumnSorter {
|
|
88
|
+
onSort(_e: SlickEventData<SingleColumnSort>, args: SingleColumnSort): void;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColumnSorter, columnSorter } from "./ColumnSorter";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
export function addTitle(grid: SlickGrid, cell: number): void {
|
|
4
|
+
const column = grid.getColumns()[cell];
|
|
5
|
+
const columnId = column.id;
|
|
6
|
+
const footerCell = grid.getFooterRowColumn(columnId);
|
|
7
|
+
footerCell.textContent = "TOTAL:";
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { totalAmountOf } from "./totalAmountOf";
|
|
4
|
+
|
|
5
|
+
export function addTotalSum(grid: SlickGrid, columnIdx: number): void {
|
|
6
|
+
const column = grid.getColumns()[columnIdx];
|
|
7
|
+
const field = column.field;
|
|
8
|
+
const dataView: SlickDataView = grid.getData();
|
|
9
|
+
const data = dataView.getItems();
|
|
10
|
+
const total = totalAmountOf(data, field);
|
|
11
|
+
const footerCell = grid.getFooterRowColumn(field);
|
|
12
|
+
const formatter = column.formatter;
|
|
13
|
+
footerCell.textContent = `${
|
|
14
|
+
formatter ? formatter(0, 0, total, column, null, grid) : total
|
|
15
|
+
}`;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IEditedRow, ISlickRow } from "shared/model/types";
|
|
2
|
+
|
|
3
|
+
export function totalAmountOf(
|
|
4
|
+
rows: (ISlickRow & IEditedRow)[],
|
|
5
|
+
field: string,
|
|
6
|
+
): number {
|
|
7
|
+
return rows.reduce((acc, row) => {
|
|
8
|
+
if (!row.isDeleted) {
|
|
9
|
+
acc += row[field] || 0;
|
|
10
|
+
}
|
|
11
|
+
return acc;
|
|
12
|
+
}, 0);
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { IColumn, ISlickRow } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { addTitle } from "./addTitle";
|
|
6
|
+
import { addTotalSum } from "./addTotalSum";
|
|
7
|
+
|
|
8
|
+
export function updateTotal(
|
|
9
|
+
columnIdx: number,
|
|
10
|
+
grid: SlickGrid<ISlickRow, IColumn>,
|
|
11
|
+
): void {
|
|
12
|
+
const column = grid.getColumns()[columnIdx];
|
|
13
|
+
const totalRowType = column.totalCellContent;
|
|
14
|
+
if (!totalRowType) return;
|
|
15
|
+
|
|
16
|
+
switch (totalRowType) {
|
|
17
|
+
case "title": {
|
|
18
|
+
addTitle(grid, columnIdx);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case "sum":
|
|
22
|
+
addTotalSum(grid, columnIdx);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -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
|
+
};
|