slick-table 1.0.17 → 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/dist/index.cjs.js +26 -26
- package/dist/index.es.js +1385 -1385
- package/dist/types/shared/lib/slickgrid/lib/editors/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/types/shared/model/enums/EKey.d.ts +2 -1
- package/dist/types/shared/model/enums/EKey.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 +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,226 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { injectStore } from "shared/model/redux";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
6
|
+
import * as getDisplayedRowsModule from "../../../lib/functions/getDisplayedRows";
|
|
7
|
+
import { SlickTable } from "../table";
|
|
8
|
+
import { DefaultPrinter } from "./DefaultPrinter";
|
|
9
|
+
import { Printer } from "./model";
|
|
10
|
+
|
|
11
|
+
jest.mock("app/store/store");
|
|
12
|
+
|
|
13
|
+
describe("shared | slickgrid | DefaultPrinter", () => {
|
|
14
|
+
let defaultPrinter: Printer;
|
|
15
|
+
let mockTable: SlickTable;
|
|
16
|
+
let mockStore: any;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
defaultPrinter = new DefaultPrinter();
|
|
20
|
+
mockTable = {
|
|
21
|
+
id: "mock_table",
|
|
22
|
+
name: "Mock Table",
|
|
23
|
+
grid: {
|
|
24
|
+
getColumns: jest.fn().mockReturnValue([]),
|
|
25
|
+
getData: jest.fn().mockReturnValue({
|
|
26
|
+
getItem: jest.fn(),
|
|
27
|
+
getItemMetadata: jest.fn(),
|
|
28
|
+
}),
|
|
29
|
+
} as unknown as SlickGrid,
|
|
30
|
+
} as unknown as SlickTable;
|
|
31
|
+
|
|
32
|
+
mockStore = {
|
|
33
|
+
getState: jest.fn().mockReturnValue({
|
|
34
|
+
client: {
|
|
35
|
+
clientInfo: {
|
|
36
|
+
value: "Test Client",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
injectStore(mockStore);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should create a client name row with correct colspan when client name is provided", () => {
|
|
45
|
+
const instance = new DefaultPrinter();
|
|
46
|
+
const result = instance.clientName();
|
|
47
|
+
|
|
48
|
+
expect(result.tagName).toBe("TR");
|
|
49
|
+
expect(result.children.length).toBe(1);
|
|
50
|
+
expect(result.children[0].tagName).toBe("TH");
|
|
51
|
+
expect(result.children[0].classList.contains("client")).toBe(true);
|
|
52
|
+
expect(result.children[0].getAttribute("colspan")).toBe("4");
|
|
53
|
+
expect(result.children[0].innerText).toBe("Test Client");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should generate column names row with correct number of columns based on 'forPrint' property", () => {
|
|
57
|
+
const mockColumns = [
|
|
58
|
+
{ name: "Column 1", forPrint: true },
|
|
59
|
+
{ name: "Column 2", forPrint: false },
|
|
60
|
+
{ name: "Column 3", forPrint: true },
|
|
61
|
+
{ name: "Column 4", forPrint: true },
|
|
62
|
+
];
|
|
63
|
+
jest.spyOn(mockTable.grid, "getColumns").mockReturnValue(mockColumns);
|
|
64
|
+
const result = defaultPrinter.columnNames(mockTable);
|
|
65
|
+
|
|
66
|
+
expect(result.tagName).toBe("TR");
|
|
67
|
+
expect(result.children.length).toBe(3);
|
|
68
|
+
expect(
|
|
69
|
+
Array.from(result.children).every((child) => child.tagName === "TH"),
|
|
70
|
+
).toBe(true);
|
|
71
|
+
expect(
|
|
72
|
+
Array.from(result.children).every((child) =>
|
|
73
|
+
child.classList.contains("column_name"),
|
|
74
|
+
),
|
|
75
|
+
).toBe(true);
|
|
76
|
+
expect(result.children[0].innerText).toBe("Column 1");
|
|
77
|
+
expect(result.children[1].innerText).toBe("Column 3");
|
|
78
|
+
expect(result.children[2].innerText).toBe("Column 4");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("should create table name and time row with current date in correct format", () => {
|
|
82
|
+
mockTable.name = "Test Table";
|
|
83
|
+
|
|
84
|
+
const result = defaultPrinter.tableNameAndTime(mockTable);
|
|
85
|
+
|
|
86
|
+
expect(result.tagName).toBe("TR");
|
|
87
|
+
expect(result.classList.contains("heading")).toBe(true);
|
|
88
|
+
expect(result.children.length).toBe(2);
|
|
89
|
+
|
|
90
|
+
const tableName = result.children[0] as HTMLTableCellElement;
|
|
91
|
+
expect(tableName.tagName).toBe("TH");
|
|
92
|
+
expect(tableName.getAttribute("colspan")).toBe("2");
|
|
93
|
+
expect(tableName.classList.contains("table_name")).toBe(true);
|
|
94
|
+
expect(tableName.innerText).toBe(mockTable.name);
|
|
95
|
+
|
|
96
|
+
const dateStamp = result.children[1] as HTMLTableCellElement;
|
|
97
|
+
expect(dateStamp.tagName).toBe("TH");
|
|
98
|
+
expect(dateStamp.getAttribute("colspan")).toBe("100%");
|
|
99
|
+
expect(dateStamp.classList.contains("date_stamp")).toBe(true);
|
|
100
|
+
|
|
101
|
+
const dateRegex = /^\d{2}\/\d{2}\/\d{4} \d{1,2}:\d{2} (AM|PM)$/;
|
|
102
|
+
expect(dateRegex.test(dateStamp.innerText)).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should create table body with correct number of rows and columns based on displayed data", () => {
|
|
106
|
+
const mockColumns = [
|
|
107
|
+
{ name: "Column 1", forPrint: true },
|
|
108
|
+
{ name: "Column 2", forPrint: false },
|
|
109
|
+
{ name: "Column 3", forPrint: true },
|
|
110
|
+
];
|
|
111
|
+
const mockDisplayedRows = [
|
|
112
|
+
{ id: 1, col1: "Value 1", col3: "Value 3" },
|
|
113
|
+
{ id: 2, col1: "Value 4", col3: "Value 6" },
|
|
114
|
+
];
|
|
115
|
+
const mockDataView = {
|
|
116
|
+
getItem: jest.fn((index) => mockDisplayedRows[index]),
|
|
117
|
+
getItemMetadata: jest.fn(),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
jest.spyOn(mockTable.grid, "getColumns").mockReturnValue(mockColumns);
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
jest.spyOn(mockTable.grid, "getData").mockReturnValue(mockDataView);
|
|
124
|
+
|
|
125
|
+
jest.spyOn(defaultPrinter, "createTr").mockImplementation(() => {
|
|
126
|
+
const tr = document.createElement("tr");
|
|
127
|
+
tr.innerHTML = "<td></td><td></td>";
|
|
128
|
+
return tr;
|
|
129
|
+
});
|
|
130
|
+
jest.spyOn(defaultPrinter, "totals").mockReturnValue([]);
|
|
131
|
+
|
|
132
|
+
jest
|
|
133
|
+
.spyOn(getDisplayedRowsModule, "getDisplayedRows")
|
|
134
|
+
.mockImplementation(jest.fn())
|
|
135
|
+
.mockReturnValue(mockDisplayedRows);
|
|
136
|
+
|
|
137
|
+
const result = defaultPrinter.createTbody(mockTable);
|
|
138
|
+
|
|
139
|
+
expect(result.tagName).toBe("TBODY");
|
|
140
|
+
expect(result.children.length).toBe(2);
|
|
141
|
+
expect(result.children[0].children.length).toBe(2);
|
|
142
|
+
expect(result.children[1].children.length).toBe(2);
|
|
143
|
+
expect(defaultPrinter.totals).toHaveBeenCalledWith(mockTable);
|
|
144
|
+
expect(getDisplayedRowsModule.getDisplayedRows).toHaveBeenCalledWith(
|
|
145
|
+
mockDataView,
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should create filters row when table has filters", () => {
|
|
150
|
+
const mockTable: SlickTable = {
|
|
151
|
+
filter: {
|
|
152
|
+
print: jest
|
|
153
|
+
.fn()
|
|
154
|
+
.mockReturnValue([
|
|
155
|
+
document.createElement("tr"),
|
|
156
|
+
document.createElement("tr"),
|
|
157
|
+
]),
|
|
158
|
+
},
|
|
159
|
+
} as unknown as SlickTable;
|
|
160
|
+
|
|
161
|
+
const result = defaultPrinter.filters(mockTable);
|
|
162
|
+
|
|
163
|
+
expect(result.length).toBe(3);
|
|
164
|
+
expect(result[0].tagName).toBe("TR");
|
|
165
|
+
expect(result[0].children[0].tagName).toBe("TH");
|
|
166
|
+
expect(result[0].children[0].getAttribute("colspan")).toBe("100%");
|
|
167
|
+
expect(result[0].children[0].classList.contains("client")).toBe(true);
|
|
168
|
+
expect(result[0].children[0].innerText).toBe("Applied filters");
|
|
169
|
+
expect(result[1].tagName).toBe("TR");
|
|
170
|
+
expect(result[2].tagName).toBe("TR");
|
|
171
|
+
expect(mockTable.filter.print).toHaveBeenCalledWith(mockTable);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should create a table element with correct structure and content", () => {
|
|
175
|
+
jest
|
|
176
|
+
.spyOn(defaultPrinter, "createThead")
|
|
177
|
+
.mockReturnValue(document.createElement("thead"));
|
|
178
|
+
jest
|
|
179
|
+
.spyOn(defaultPrinter, "createTbody")
|
|
180
|
+
.mockReturnValue(document.createElement("tbody"));
|
|
181
|
+
|
|
182
|
+
const result = defaultPrinter.createTableElement(mockTable);
|
|
183
|
+
|
|
184
|
+
expect(result.tagName).toBe("TABLE");
|
|
185
|
+
expect(result.children.length).toBe(2);
|
|
186
|
+
expect(result.children[0].tagName).toBe("THEAD");
|
|
187
|
+
expect(result.children[1].tagName).toBe("TBODY");
|
|
188
|
+
expect(defaultPrinter.createThead).toHaveBeenCalledWith(mockTable);
|
|
189
|
+
expect(defaultPrinter.createTbody).toHaveBeenCalledWith(mockTable);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("should handle group titles in createTr method", () => {
|
|
193
|
+
const mockColumns = [
|
|
194
|
+
{ name: "Column 1", field: "col1", forPrint: true },
|
|
195
|
+
{ name: "Column 2", field: "col2", forPrint: true },
|
|
196
|
+
];
|
|
197
|
+
const mockRowIndex = 0;
|
|
198
|
+
const mockGrid = {
|
|
199
|
+
getData: jest.fn().mockReturnValue({
|
|
200
|
+
getItem: jest.fn().mockReturnValue({
|
|
201
|
+
__group: true,
|
|
202
|
+
title: "Group Title <span>with HTML</span>",
|
|
203
|
+
}),
|
|
204
|
+
getItemMetadata: jest.fn(),
|
|
205
|
+
}),
|
|
206
|
+
} as unknown as SlickGrid;
|
|
207
|
+
|
|
208
|
+
const result = defaultPrinter.createTr(mockColumns, mockRowIndex, mockGrid);
|
|
209
|
+
|
|
210
|
+
expect(result.tagName).toBe("TR");
|
|
211
|
+
expect(result.children.length).toBe(1);
|
|
212
|
+
expect(result.children[0].tagName).toBe("TD");
|
|
213
|
+
expect(result.children[0].getAttribute("colspan")).toBe("100%");
|
|
214
|
+
expect(result.children[0].innerText).toBe("Group Title with HTML");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("should return an empty array for totals method in DefaultPrinter", () => {
|
|
218
|
+
mockTable = {} as SlickTable;
|
|
219
|
+
|
|
220
|
+
const result = defaultPrinter.totals(mockTable);
|
|
221
|
+
|
|
222
|
+
expect(result).toEqual([]);
|
|
223
|
+
expect(Array.isArray(result)).toBe(true);
|
|
224
|
+
expect(result.length).toBe(0);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
import { SlickDataView, SlickGrid } from "slickgrid";
|
|
3
|
+
|
|
4
|
+
import { removeHtml } from "shared/lib/strings";
|
|
5
|
+
import { IColumn, IPrinter, ISlickRow, ISlickTable } from "shared/model/types";
|
|
6
|
+
|
|
7
|
+
import { getDisplayedRows } from "../../../lib";
|
|
8
|
+
import { cssStyles } from "./model";
|
|
9
|
+
|
|
10
|
+
export class DefaultPrinter implements IPrinter {
|
|
11
|
+
clientId = 0;
|
|
12
|
+
clientName = "";
|
|
13
|
+
cssStyles = cssStyles;
|
|
14
|
+
|
|
15
|
+
getClientName(): HTMLTableRowElement {
|
|
16
|
+
const result = document.createElement("tr");
|
|
17
|
+
|
|
18
|
+
const name = document.createElement("th");
|
|
19
|
+
name.classList.add("align_left");
|
|
20
|
+
name.setAttribute("colspan", "100%");
|
|
21
|
+
name.innerText = `${this.clientName} [${this.clientId}]`;
|
|
22
|
+
result.append(name);
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
columnNames(table: ISlickTable): HTMLTableRowElement {
|
|
27
|
+
const result = document.createElement("tr");
|
|
28
|
+
|
|
29
|
+
const grid = table.grid;
|
|
30
|
+
const columns: IColumn[] = grid?.getColumns() || [];
|
|
31
|
+
const columnsFiltered = columns.filter((el) => el.forPrint);
|
|
32
|
+
|
|
33
|
+
columnsFiltered.forEach(({ name }) => {
|
|
34
|
+
const th = document.createElement("th");
|
|
35
|
+
th.classList.add("column_name");
|
|
36
|
+
if (typeof name === "string") {
|
|
37
|
+
th.innerText = name;
|
|
38
|
+
} else {
|
|
39
|
+
th.innerText = " ";
|
|
40
|
+
}
|
|
41
|
+
result.append(th);
|
|
42
|
+
});
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
tableNameAndTime(table: ISlickTable): HTMLTableRowElement {
|
|
46
|
+
const result = document.createElement("tr");
|
|
47
|
+
result.classList.add("heading");
|
|
48
|
+
|
|
49
|
+
const tableName = document.createElement("th");
|
|
50
|
+
tableName.setAttribute("colspan", "2");
|
|
51
|
+
tableName.classList.add("table_name");
|
|
52
|
+
tableName.innerText = table.name || table.id;
|
|
53
|
+
result.append(tableName);
|
|
54
|
+
|
|
55
|
+
const dateStamp = document.createElement("th");
|
|
56
|
+
dateStamp.setAttribute("colspan", "100%");
|
|
57
|
+
dateStamp.classList.add("date_stamp");
|
|
58
|
+
dateStamp.innerText = moment().format("MM/DD/YYYY h:mm A");
|
|
59
|
+
result.append(dateStamp);
|
|
60
|
+
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
createStyleElement(): HTMLStyleElement {
|
|
64
|
+
const result = document.createElement("style");
|
|
65
|
+
result.innerHTML = this.cssStyles;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
createTableElement(table: ISlickTable): HTMLTableElement {
|
|
69
|
+
const result = document.createElement("table");
|
|
70
|
+
result.append(this.createThead(table));
|
|
71
|
+
result.append(this.createTbody(table));
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
createTbody(table: ISlickTable): HTMLTableSectionElement {
|
|
75
|
+
const result = document.createElement("tbody");
|
|
76
|
+
|
|
77
|
+
const grid = table.grid;
|
|
78
|
+
if (!grid) return result;
|
|
79
|
+
|
|
80
|
+
const columns: IColumn[] = grid.getColumns();
|
|
81
|
+
const columnsFiltered = columns.filter((el) => el.forPrint);
|
|
82
|
+
const dataView: SlickDataView = grid.getData();
|
|
83
|
+
const displayedRows = getDisplayedRows(dataView);
|
|
84
|
+
displayedRows.forEach((_row, rowIndex) => {
|
|
85
|
+
const tr = this.createTr(columnsFiltered, rowIndex, grid);
|
|
86
|
+
result.append(tr);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
result.append(...this.totals(table));
|
|
90
|
+
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
filters(table: ISlickTable): HTMLTableRowElement[] {
|
|
94
|
+
const result: HTMLTableRowElement[] = [];
|
|
95
|
+
if (table.filter) {
|
|
96
|
+
const appliedFilters = table.filter.print(table);
|
|
97
|
+
if (appliedFilters.length) {
|
|
98
|
+
const tr = document.createElement("tr");
|
|
99
|
+
const th = document.createElement("th");
|
|
100
|
+
th.setAttribute("colspan", "100%");
|
|
101
|
+
th.classList.add("align_left");
|
|
102
|
+
th.innerText = "Applied filters";
|
|
103
|
+
tr.append(th);
|
|
104
|
+
result.push(tr);
|
|
105
|
+
}
|
|
106
|
+
appliedFilters.forEach((filter) => {
|
|
107
|
+
result.push(filter);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
/** for tables with total calculations */
|
|
113
|
+
totals(_table: ISlickTable): HTMLTableRowElement[] {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
createThead(table: ISlickTable): HTMLTableSectionElement {
|
|
117
|
+
const result = document.createElement("thead");
|
|
118
|
+
result.append(this.getClientName());
|
|
119
|
+
result.append(this.tableNameAndTime(table));
|
|
120
|
+
result.append(...this.filters(table));
|
|
121
|
+
result.append(this.columnNames(table));
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
createTr(
|
|
125
|
+
columns: IColumn[],
|
|
126
|
+
rowIndex: number,
|
|
127
|
+
grid: SlickGrid,
|
|
128
|
+
): HTMLTableRowElement {
|
|
129
|
+
const result = document.createElement("tr");
|
|
130
|
+
const dataView: SlickDataView<ISlickRow> = grid.getData();
|
|
131
|
+
const row = dataView.getItem(rowIndex);
|
|
132
|
+
const isGroupTitle = row.__group;
|
|
133
|
+
const isGroupTotal = row.__groupTotals;
|
|
134
|
+
if (isGroupTitle) {
|
|
135
|
+
const td = document.createElement("td");
|
|
136
|
+
td.setAttribute("colspan", "100%");
|
|
137
|
+
td.innerText = removeHtml(row.title);
|
|
138
|
+
result.append(td);
|
|
139
|
+
} else {
|
|
140
|
+
columns.forEach((column) => {
|
|
141
|
+
const td = document.createElement("td");
|
|
142
|
+
column.cssClass && td.classList.add(column.cssClass);
|
|
143
|
+
const field = column.field;
|
|
144
|
+
const metaData = dataView.getItemMetadata(rowIndex);
|
|
145
|
+
const formatterSpecific = metaData?.columns?.[field]?.formatter;
|
|
146
|
+
const formatter =
|
|
147
|
+
column.printer || formatterSpecific || column.formatter;
|
|
148
|
+
let value = row[field];
|
|
149
|
+
if (isGroupTotal) {
|
|
150
|
+
const totalsFormatter = column.groupTotalsFormatter;
|
|
151
|
+
value = totalsFormatter ? totalsFormatter(row, column, grid) : "";
|
|
152
|
+
} else if (formatter) {
|
|
153
|
+
value = formatter(0, 0, value, column, row, grid);
|
|
154
|
+
}
|
|
155
|
+
td.innerText = value || "";
|
|
156
|
+
|
|
157
|
+
result.append(td);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
print(table: ISlickTable, clientId: number, clientName: string): void {
|
|
163
|
+
this.clientId = clientId;
|
|
164
|
+
this.clientName = clientName;
|
|
165
|
+
const newTab = window.open() as Window;
|
|
166
|
+
|
|
167
|
+
const title = document.createElement("title");
|
|
168
|
+
title.innerText = table.name || table.id;
|
|
169
|
+
|
|
170
|
+
const head = newTab.document.querySelector("head") as HTMLHeadElement;
|
|
171
|
+
head.append(title);
|
|
172
|
+
head.append(this.createStyleElement());
|
|
173
|
+
|
|
174
|
+
const body = newTab.document.querySelector("body") as HTMLBodyElement;
|
|
175
|
+
|
|
176
|
+
body.append(this.createTableElement(table));
|
|
177
|
+
newTab.print();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultPrinter } from "./DefaultPrinter";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const cssStyles = `
|
|
2
|
+
html body {
|
|
3
|
+
font-family: "Courier", "sans-serif";
|
|
4
|
+
font-size: 12px;
|
|
5
|
+
}
|
|
6
|
+
body table {
|
|
7
|
+
margin: 0 auto;
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
}
|
|
11
|
+
table thead {
|
|
12
|
+
border-bottom: 2px solid gray;
|
|
13
|
+
}
|
|
14
|
+
table th,
|
|
15
|
+
table td {
|
|
16
|
+
padding: 0 10px;
|
|
17
|
+
font-weight: normal;
|
|
18
|
+
}
|
|
19
|
+
table td.text-center {
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
table td.text-right {
|
|
23
|
+
text-align: right;
|
|
24
|
+
}
|
|
25
|
+
.heading {
|
|
26
|
+
height: 30px;
|
|
27
|
+
}
|
|
28
|
+
.heading .table_name {
|
|
29
|
+
text-align: left;
|
|
30
|
+
padding-bottom: 20px;
|
|
31
|
+
}
|
|
32
|
+
.heading .date_stamp {
|
|
33
|
+
text-align: right;
|
|
34
|
+
padding-bottom: 20px;
|
|
35
|
+
}
|
|
36
|
+
.column_name {
|
|
37
|
+
padding-top: 1em;
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
}
|
|
40
|
+
.align_right {
|
|
41
|
+
text-align: right;
|
|
42
|
+
}
|
|
43
|
+
.align_left {
|
|
44
|
+
text-align: left;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cssStyles } from "./cssStyles";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cssStyles } from "./consts";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { IFilter, WithoutFilter } from "../filters";
|
|
4
|
+
import { DefaultPrinter, Printer } from "../printer";
|
|
5
|
+
import { SlickTable } from "./SlickTable";
|
|
6
|
+
|
|
7
|
+
jest.mock("app/store/store");
|
|
8
|
+
|
|
9
|
+
describe("SlickTable", () => {
|
|
10
|
+
let slickTable: SlickTable;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
slickTable = new SlickTable({ id: "test-table" });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should create a SlickTable instance with default values when only 'id' is provided", () => {
|
|
17
|
+
expect(slickTable.id).toBe("test-table");
|
|
18
|
+
expect(slickTable.name).toBe("");
|
|
19
|
+
expect(slickTable.printer).toBeInstanceOf(DefaultPrinter);
|
|
20
|
+
expect(slickTable.filter).toBeInstanceOf(WithoutFilter);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should return null for grid property before createGrid is called", () => {
|
|
24
|
+
expect(slickTable.grid).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return false for isReady property before createGrid is called", () => {
|
|
28
|
+
expect(slickTable.isReady).toBeFalsy();
|
|
29
|
+
expect(slickTable.isReady).toEqual(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should return false for isEdited property before createGrid is called", () => {
|
|
33
|
+
expect(slickTable.isEdited).toBeFalsy();
|
|
34
|
+
expect(slickTable.isEdited).toEqual(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should correctly set custom name, filter, and printer when provided in constructor", () => {
|
|
38
|
+
const mockFilter = {} as IFilter;
|
|
39
|
+
const mockPrinter = {} as Printer;
|
|
40
|
+
const slickTable = new SlickTable({
|
|
41
|
+
id: "custom-table",
|
|
42
|
+
name: "Custom Table",
|
|
43
|
+
filter: mockFilter,
|
|
44
|
+
printer: mockPrinter,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(slickTable.id).toBe("custom-table");
|
|
48
|
+
expect(slickTable.name).toBe("Custom Table");
|
|
49
|
+
expect(slickTable.filter).toBe(mockFilter);
|
|
50
|
+
expect(slickTable.printer).toBe(mockPrinter);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should clear selected rows when reset() is called if a selection model exists", () => {
|
|
54
|
+
const mockGrid = {
|
|
55
|
+
onKeyDown: { unsubscribe: jest.fn() },
|
|
56
|
+
getSelectionModel: jest.fn().mockReturnValue(true),
|
|
57
|
+
setSelectedRows: jest.fn(),
|
|
58
|
+
} as unknown as SlickGrid;
|
|
59
|
+
|
|
60
|
+
slickTable.grid = mockGrid;
|
|
61
|
+
slickTable.isEdited = true;
|
|
62
|
+
|
|
63
|
+
expect(slickTable.isEdited).toBeTruthy();
|
|
64
|
+
expect(slickTable.grid).toEqual(mockGrid);
|
|
65
|
+
|
|
66
|
+
slickTable.reset();
|
|
67
|
+
|
|
68
|
+
expect(mockGrid.setSelectedRows).toHaveBeenCalledWith([]);
|
|
69
|
+
expect(slickTable.isEdited).toBeFalsy();
|
|
70
|
+
expect(slickTable.grid).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Column,
|
|
3
|
+
GridOption,
|
|
4
|
+
OnKeyDownEventArgs,
|
|
5
|
+
SlickDataView,
|
|
6
|
+
SlickEventData,
|
|
7
|
+
SlickGrid,
|
|
8
|
+
} from "slickgrid";
|
|
9
|
+
|
|
10
|
+
import { elementNotVisible } from "shared/lib/dom";
|
|
11
|
+
import {
|
|
12
|
+
IDownloadManager,
|
|
13
|
+
IFilter,
|
|
14
|
+
IGrouping,
|
|
15
|
+
IHotKeysBehavior,
|
|
16
|
+
IObserver,
|
|
17
|
+
IPrinter,
|
|
18
|
+
ISlickTable,
|
|
19
|
+
ITotalCalculator,
|
|
20
|
+
} from "shared/model/types";
|
|
21
|
+
|
|
22
|
+
import { getOnKeyDownCallback } from "../../../lib";
|
|
23
|
+
import { DownloadManager } from "../csvDownloadManager";
|
|
24
|
+
import { WithoutFilter } from "../filters";
|
|
25
|
+
import { WithoutHotKeys } from "../hotKeys";
|
|
26
|
+
import { DefaultPrinter } from "../printer";
|
|
27
|
+
|
|
28
|
+
export class SlickTable implements ISlickTable {
|
|
29
|
+
public downloadManager: IDownloadManager = new DownloadManager();
|
|
30
|
+
public filter: IFilter = new WithoutFilter();
|
|
31
|
+
public readonly hotKeysBehavior: IHotKeysBehavior = new WithoutHotKeys();
|
|
32
|
+
public readonly id: string;
|
|
33
|
+
public readonly name: string;
|
|
34
|
+
public totalCalculator?: ITotalCalculator;
|
|
35
|
+
|
|
36
|
+
private _grid: SlickGrid | null = null;
|
|
37
|
+
private _grouping: IGrouping = {};
|
|
38
|
+
private _isActive = false;
|
|
39
|
+
private _isEdited = false;
|
|
40
|
+
private _lastActiveCell = { row: 0, cell: 0 }; // to return to the last active cell after saving
|
|
41
|
+
private readonly _observers: IObserver[] = [];
|
|
42
|
+
private _printer: IPrinter = new DefaultPrinter();
|
|
43
|
+
|
|
44
|
+
constructor(args: {
|
|
45
|
+
downloadManager?: IDownloadManager;
|
|
46
|
+
filter?: IFilter;
|
|
47
|
+
hotKeys?: IHotKeysBehavior;
|
|
48
|
+
id: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
printer?: IPrinter;
|
|
51
|
+
totalCalculator?: ITotalCalculator;
|
|
52
|
+
}) {
|
|
53
|
+
const {
|
|
54
|
+
downloadManager,
|
|
55
|
+
filter,
|
|
56
|
+
hotKeys,
|
|
57
|
+
id,
|
|
58
|
+
name,
|
|
59
|
+
printer,
|
|
60
|
+
totalCalculator,
|
|
61
|
+
} = args;
|
|
62
|
+
this.id = id;
|
|
63
|
+
this.name = name || "";
|
|
64
|
+
if (downloadManager) this.downloadManager = downloadManager;
|
|
65
|
+
if (filter) this.filter = filter;
|
|
66
|
+
if (hotKeys) this.hotKeysBehavior = hotKeys;
|
|
67
|
+
if (printer) this.printer = printer;
|
|
68
|
+
if (totalCalculator) this.totalCalculator = totalCalculator;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public createGrid(
|
|
72
|
+
dataView: SlickDataView,
|
|
73
|
+
columns: Column[],
|
|
74
|
+
options: GridOption,
|
|
75
|
+
): SlickGrid {
|
|
76
|
+
this.reset();
|
|
77
|
+
const grid = new SlickGrid(`#${this.id}`, dataView, columns, options);
|
|
78
|
+
this.grid = grid;
|
|
79
|
+
grid.onKeyDown.subscribe(getOnKeyDownCallback(grid));
|
|
80
|
+
this.filter.register(grid, this.id);
|
|
81
|
+
return this.grid;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public handleKeyboardEvent(event: SlickEventData<OnKeyDownEventArgs>): void {
|
|
85
|
+
if (elementNotVisible(`#${this.id}`)) return;
|
|
86
|
+
this.hotKeysBehavior.handleKeyboardEvent(event, this);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public get grid(): SlickGrid | null {
|
|
90
|
+
return this._grid;
|
|
91
|
+
}
|
|
92
|
+
public get grouping(): IGrouping {
|
|
93
|
+
return this._grouping;
|
|
94
|
+
}
|
|
95
|
+
public get isEdited(): boolean {
|
|
96
|
+
return this._isEdited;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private set grid(grid: SlickGrid | null) {
|
|
100
|
+
this._grid = grid;
|
|
101
|
+
}
|
|
102
|
+
public set grouping(grouping: IGrouping) {
|
|
103
|
+
this._grouping = { ...this._grouping, ...grouping };
|
|
104
|
+
if (!this.grid) return;
|
|
105
|
+
const dataView = this.grid.getData<SlickDataView>();
|
|
106
|
+
if (this.grouping.isGrouped) {
|
|
107
|
+
dataView.setGrouping(this.grouping.groups || []);
|
|
108
|
+
} else {
|
|
109
|
+
dataView.setGrouping([]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
public set isEdited(isEdited: boolean) {
|
|
113
|
+
this._isEdited = isEdited;
|
|
114
|
+
this.notifyObservers();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public set printer(printer: IPrinter) {
|
|
118
|
+
this._printer = printer;
|
|
119
|
+
}
|
|
120
|
+
public get printer(): IPrinter {
|
|
121
|
+
return this._printer;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public get isActive(): boolean {
|
|
125
|
+
return this._isActive;
|
|
126
|
+
}
|
|
127
|
+
public set isActive(isActive: boolean) {
|
|
128
|
+
this._isActive = isActive;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public get lastActiveSell() {
|
|
132
|
+
return this._lastActiveCell;
|
|
133
|
+
}
|
|
134
|
+
public set lastActiveSell(cell: { row: number; cell: number }) {
|
|
135
|
+
this._lastActiveCell = cell;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public resizeCanvas(): void {
|
|
139
|
+
console.log(""); // doesn't resize without this code line O_o
|
|
140
|
+
this.grid?.resizeCanvas();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public registerObservers(observer: IObserver): void {
|
|
144
|
+
if (!~this._observers.indexOf(observer)) {
|
|
145
|
+
this._observers.push(observer);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
public notifyObservers(): void {
|
|
149
|
+
for (const observer of this._observers) {
|
|
150
|
+
observer(this);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
public deleteObserver(observer: IObserver): void {
|
|
154
|
+
const index = this._observers.indexOf(observer);
|
|
155
|
+
this._observers.splice(index, 1);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public reset(): void {
|
|
159
|
+
this.grid?.onKeyDown.unsubscribe(getOnKeyDownCallback(this.grid));
|
|
160
|
+
if (this.grid?.getSelectionModel()) {
|
|
161
|
+
this.grid.setSelectedRows([]);
|
|
162
|
+
}
|
|
163
|
+
this.hotKeysBehavior.resetQueue();
|
|
164
|
+
this.isEdited = false;
|
|
165
|
+
this.isActive = false;
|
|
166
|
+
this.grid = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SlickTable } from "./SlickTable";
|