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,50 @@
|
|
|
1
|
+
import { formatNumber } from "./formatNumber";
|
|
2
|
+
|
|
3
|
+
describe("formatMoney", () => {
|
|
4
|
+
test("must return empty string", () => {
|
|
5
|
+
expect(formatNumber(0, { zeroAsBlank: true })).toBe("");
|
|
6
|
+
expect(formatNumber("0", { zeroAsBlank: true })).toBe("");
|
|
7
|
+
expect(formatNumber(null)).toBe("");
|
|
8
|
+
expect(formatNumber(undefined)).toBe("");
|
|
9
|
+
expect(formatNumber("")).toBe("");
|
|
10
|
+
});
|
|
11
|
+
test("must return zero", () => {
|
|
12
|
+
expect(formatNumber(0)).toBe("0.00");
|
|
13
|
+
expect(formatNumber("0", { decimalSeparator: "," })).toBe("0,00");
|
|
14
|
+
});
|
|
15
|
+
test("must return correct values", () => {
|
|
16
|
+
expect(formatNumber(0.1)).toBe("0.10");
|
|
17
|
+
expect(formatNumber(1000222.1, { decimalPlaces: 4 })).toBe(
|
|
18
|
+
"1,000,222.1000",
|
|
19
|
+
);
|
|
20
|
+
expect(formatNumber(-1000222.1, { currencySymbol: "$" })).toBe(
|
|
21
|
+
"($1,000,222.10)",
|
|
22
|
+
);
|
|
23
|
+
expect(
|
|
24
|
+
formatNumber(-1000222.1, {
|
|
25
|
+
decimalSeparator: ",",
|
|
26
|
+
decimalPlaces: 3,
|
|
27
|
+
thousandsSeparator: ".",
|
|
28
|
+
currencySymbol: "$",
|
|
29
|
+
}),
|
|
30
|
+
).toBe("($1.000.222,100)");
|
|
31
|
+
expect(formatNumber("1500.02")).toBe("1,500.02");
|
|
32
|
+
expect(formatNumber("1700500.02")).toBe("1,700,500.02");
|
|
33
|
+
expect(formatNumber("-1700500.02")).toBe("(1,700,500.02)");
|
|
34
|
+
});
|
|
35
|
+
test("must return add class name", () => {
|
|
36
|
+
expect(
|
|
37
|
+
formatNumber(5, { negativeClass: "neg", positiveClass: "pos" }),
|
|
38
|
+
).toBe('<span class="pos">5.00</span>');
|
|
39
|
+
expect(
|
|
40
|
+
formatNumber(-5, { negativeClass: "neg", positiveClass: "pos" }),
|
|
41
|
+
).toBe('<span class="neg">(5.00)</span>');
|
|
42
|
+
expect(
|
|
43
|
+
formatNumber(-5, {
|
|
44
|
+
negativeClass: "neg",
|
|
45
|
+
noHTML: true,
|
|
46
|
+
positiveClass: "pos",
|
|
47
|
+
}),
|
|
48
|
+
).toBe("(5.00)");
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { IOptions } from "./IOptions";
|
|
2
|
+
import { addParentheses } from "./addParentheses";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {(number | null | undefined)} value Money amount to be formatted.
|
|
6
|
+
* @param {Object} [options] Formatting options.
|
|
7
|
+
* @param {boolean} [options.currencySymbol = ""] Currency symbol.
|
|
8
|
+
* @param {number} [options.decimalPlaces = 2] Number of decimal places.
|
|
9
|
+
* @param {string} [options.decimalSeparator = "."] Decimal separator.
|
|
10
|
+
* @param {boolean} options.negativeClass Style class name for negative numbers.
|
|
11
|
+
* @param {boolean} [options.negativeInParentheses = true] Enclose negative numbers in parentheses.
|
|
12
|
+
* @param {boolean} [options.noHTML = false] Return plain text without HTML.
|
|
13
|
+
* @param {boolean} options.positiveClass Style class name for positive numbers.
|
|
14
|
+
* @param {string} [options.thousandsSeparator = ","] Thousands separator.
|
|
15
|
+
* @param {boolean} [options.zeroAsBlank = false] Display zero as en empty string.
|
|
16
|
+
* */
|
|
17
|
+
export function formatNumber(
|
|
18
|
+
value: number | string | null | undefined,
|
|
19
|
+
options: IOptions = {},
|
|
20
|
+
): string {
|
|
21
|
+
const {
|
|
22
|
+
currencySymbol = "",
|
|
23
|
+
decimalPlaces = 2,
|
|
24
|
+
decimalSeparator = ".",
|
|
25
|
+
negativeClass,
|
|
26
|
+
negativeInParentheses = true,
|
|
27
|
+
noHTML = false,
|
|
28
|
+
positiveClass,
|
|
29
|
+
thousandsSeparator = ",",
|
|
30
|
+
zeroAsBlank = false,
|
|
31
|
+
} = options;
|
|
32
|
+
if (value === undefined || value === null || value === "") {
|
|
33
|
+
return "";
|
|
34
|
+
} else if (!Number(value) && zeroAsBlank) return "";
|
|
35
|
+
const isNegative = (Number(value) || 0) < 0;
|
|
36
|
+
const valueFixed = Math.abs(Number(value) || 0).toFixed(decimalPlaces);
|
|
37
|
+
const integerPart = parseInt(valueFixed).toString();
|
|
38
|
+
const remainder = integerPart.length > 3 ? integerPart.length % 3 : 0;
|
|
39
|
+
const withThousandsSeparator =
|
|
40
|
+
(remainder ? integerPart.slice(0, remainder) + thousandsSeparator : "") +
|
|
41
|
+
integerPart
|
|
42
|
+
.slice(remainder)
|
|
43
|
+
.replace(/(\d{3})(?=\d)/g, `$1${thousandsSeparator}`);
|
|
44
|
+
const withDecimalPlaces =
|
|
45
|
+
withThousandsSeparator +
|
|
46
|
+
(decimalPlaces ? decimalSeparator + valueFixed.slice(-decimalPlaces) : "");
|
|
47
|
+
const withCurrency = `${currencySymbol}${withDecimalPlaces}`;
|
|
48
|
+
const withMinus = isNegative ? `-${withCurrency}` : withCurrency;
|
|
49
|
+
const withParentheses =
|
|
50
|
+
isNegative && negativeInParentheses ? addParentheses(withMinus) : withMinus;
|
|
51
|
+
if (noHTML) {
|
|
52
|
+
return withParentheses;
|
|
53
|
+
} else if (isNegative) {
|
|
54
|
+
return negativeClass
|
|
55
|
+
? `<span class="${negativeClass}">${withParentheses}</span>`
|
|
56
|
+
: withParentheses;
|
|
57
|
+
} else {
|
|
58
|
+
return positiveClass
|
|
59
|
+
? `<span class="${positiveClass}">${withParentheses}</span>`
|
|
60
|
+
: withParentheses;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { localStore } from "./model";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EStorageKey } from "./EStorageKey";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getSlickTable, getSorting, setSorting } from "../lib";
|
|
2
|
+
import { ILastSorting, ISlickTable } from "./types";
|
|
3
|
+
|
|
4
|
+
class LocalStore {
|
|
5
|
+
getTableSorting(tableId: string): ILastSorting | undefined {
|
|
6
|
+
const slickTable: ISlickTable = getSlickTable();
|
|
7
|
+
const sorting = getSorting(slickTable);
|
|
8
|
+
return sorting[tableId];
|
|
9
|
+
}
|
|
10
|
+
resetTableSorting(tableId: string): void {
|
|
11
|
+
const slickTable = getSlickTable();
|
|
12
|
+
const sorting = getSorting(slickTable);
|
|
13
|
+
delete sorting[tableId];
|
|
14
|
+
setSorting(slickTable, sorting);
|
|
15
|
+
}
|
|
16
|
+
setTableSorting(
|
|
17
|
+
tableId: string,
|
|
18
|
+
columnId: string | number,
|
|
19
|
+
isAscending: boolean,
|
|
20
|
+
): void {
|
|
21
|
+
const slickTable = getSlickTable();
|
|
22
|
+
const sorting = getSorting(slickTable);
|
|
23
|
+
sorting[tableId] = { columnId, isAscending };
|
|
24
|
+
setSorting(slickTable, sorting);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const localStore = new LocalStore();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ISlickTable = Record<string, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { toNumber } from "./toNumber";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { toNumber } from "./toNumber";
|
|
2
|
+
|
|
3
|
+
test("Return expected values", () => {
|
|
4
|
+
expect(toNumber()).toBe(0);
|
|
5
|
+
expect(toNumber(null)).toBe(0);
|
|
6
|
+
expect(toNumber(NaN)).toBe(0);
|
|
7
|
+
expect(toNumber("")).toBe(0);
|
|
8
|
+
expect(toNumber(0)).toBe(0);
|
|
9
|
+
expect(toNumber("0")).toBe(0);
|
|
10
|
+
expect(toNumber("0.00")).toBe(0);
|
|
11
|
+
expect(toNumber("0a")).toBe(0);
|
|
12
|
+
expect(toNumber(50)).toBe(50);
|
|
13
|
+
expect(toNumber(-50.035)).toBe(-50.035);
|
|
14
|
+
expect(toNumber("$50.035")).toBe(50.035);
|
|
15
|
+
expect(toNumber("-50.035")).toBe(-50.035);
|
|
16
|
+
expect(toNumber("-$50.035")).toBe(-50.035);
|
|
17
|
+
expect(toNumber("($50.035)")).toBe(-50.035);
|
|
18
|
+
expect(toNumber("103613.10")).toBe(103613.1);
|
|
19
|
+
expect(toNumber("-103613.10")).toBe(-103613.1);
|
|
20
|
+
expect(toNumber("50")).toBe(50);
|
|
21
|
+
expect(toNumber("50,000,000.00")).toBe(50000000);
|
|
22
|
+
expect(toNumber("50,000,000.12345")).toBe(50000000.12345);
|
|
23
|
+
expect(toNumber("-sdf,ffg,g,h,,hfg,")).toBe(0);
|
|
24
|
+
expect(toNumber(".")).toBe(0);
|
|
25
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const toNumber = (value?: string | number | null): number => {
|
|
2
|
+
if (!value) return 0;
|
|
3
|
+
if (typeof value === "number") return value;
|
|
4
|
+
const stringWithoutCommas = value.replace(/\$|,|\s/g, "");
|
|
5
|
+
const absValueString = stringWithoutCommas.replace(/\(|\)/g, "");
|
|
6
|
+
if (isNaN(Number(absValueString))) return 0;
|
|
7
|
+
return stringWithoutCommas.startsWith("(") &&
|
|
8
|
+
stringWithoutCommas.endsWith(")")
|
|
9
|
+
? 0 - Number(absValueString)
|
|
10
|
+
: Number(stringWithoutCommas);
|
|
11
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Dates } from "./dates";
|
|
2
|
+
|
|
3
|
+
describe("Dates regexps", () => {
|
|
4
|
+
it("MMDDYYYY", () => {
|
|
5
|
+
expect(Dates.MMDDYYYY.test("01/05/2024")).toBeTruthy();
|
|
6
|
+
expect(Dates.MMDDYYYY.test("01/05/24")).toBeFalsy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("MMDDYY", () => {
|
|
10
|
+
expect(Dates.MMDDYY.test("01/05/24")).toBeTruthy();
|
|
11
|
+
expect(Dates.MMDDYY.test("01/05/2024")).toBeFalsy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("MDY", () => {
|
|
15
|
+
expect(Dates.MDY.test("01/05/24")).toBeTruthy();
|
|
16
|
+
expect(Dates.MDY.test("01/05/2024")).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("MD", () => {
|
|
20
|
+
expect(Dates.MD.test("01/24")).toBeTruthy();
|
|
21
|
+
expect(Dates.MD.test("1/4")).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { escapeSpecialChar } from "./escapeSpecialChar";
|
|
2
|
+
|
|
3
|
+
describe("Escape special characters", () => {
|
|
4
|
+
test("handles an empty string", () => {
|
|
5
|
+
const input = "";
|
|
6
|
+
const expectedOutput = "";
|
|
7
|
+
expect(escapeSpecialChar(input)).toBe(expectedOutput);
|
|
8
|
+
});
|
|
9
|
+
test("returns the same string if no special characters are present", () => {
|
|
10
|
+
const input = "HelloWorld";
|
|
11
|
+
const expectedOutput = "HelloWorld";
|
|
12
|
+
expect(escapeSpecialChar(input)).toBe(expectedOutput);
|
|
13
|
+
});
|
|
14
|
+
test("escapes special characters in a string", () => {
|
|
15
|
+
const input = "Hello. How are you?";
|
|
16
|
+
const expectedOutput = "Hello\\. How are you\\?";
|
|
17
|
+
expect(escapeSpecialChar(input)).toBe(expectedOutput);
|
|
18
|
+
});
|
|
19
|
+
test("handles strings with only special characters", () => {
|
|
20
|
+
const input = ".*+?^${}()|[]\\";
|
|
21
|
+
const expectedOutput = "\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\";
|
|
22
|
+
expect(escapeSpecialChar(input)).toBe(expectedOutput);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Autocomplete,
|
|
3
|
+
ColumnSorter,
|
|
4
|
+
DateFormatter,
|
|
5
|
+
DateValidator,
|
|
6
|
+
EditorAmount,
|
|
7
|
+
EditorAutocomplete,
|
|
8
|
+
EditorDate,
|
|
9
|
+
EditorSelectString,
|
|
10
|
+
EditorSelectNumber,
|
|
11
|
+
EditorSelectWithSearch,
|
|
12
|
+
EmptyStringValidator,
|
|
13
|
+
FORMATTER_NUMBER,
|
|
14
|
+
FormatterCheck,
|
|
15
|
+
getFormatterNumber,
|
|
16
|
+
LengthValidator,
|
|
17
|
+
PercentFormatter,
|
|
18
|
+
FormatterCheckPrinter,
|
|
19
|
+
StringFormatter,
|
|
20
|
+
TotalCalculator,
|
|
21
|
+
columnSorter,
|
|
22
|
+
commitCurrentEdit,
|
|
23
|
+
copySelectedRows,
|
|
24
|
+
deleteRows,
|
|
25
|
+
getDisplayedRows,
|
|
26
|
+
getLastRow,
|
|
27
|
+
getNextId,
|
|
28
|
+
highlightCell,
|
|
29
|
+
highlightColumns,
|
|
30
|
+
isDeletionDangerous,
|
|
31
|
+
onCellChange,
|
|
32
|
+
onRowCountChanged,
|
|
33
|
+
onRowsChanged,
|
|
34
|
+
openContextMenu,
|
|
35
|
+
selectedRows,
|
|
36
|
+
formatterGroupTotals,
|
|
37
|
+
useHotKeys,
|
|
38
|
+
getUpdates,
|
|
39
|
+
useListenIfTablesWereEdited,
|
|
40
|
+
useUpdateTotal,
|
|
41
|
+
wereEdited,
|
|
42
|
+
} from "./lib";
|
|
43
|
+
export {
|
|
44
|
+
DownloadManager,
|
|
45
|
+
DecoratorEndingDate,
|
|
46
|
+
DecoratorFilter,
|
|
47
|
+
DecoratorColumnFilter,
|
|
48
|
+
DecoratorPeriod,
|
|
49
|
+
DefaultHotKeys,
|
|
50
|
+
DefaultPrinter,
|
|
51
|
+
DeletedRowsFilter,
|
|
52
|
+
Filter,
|
|
53
|
+
HotKeysDecorator,
|
|
54
|
+
PreventCopying,
|
|
55
|
+
RedoUndoOnly,
|
|
56
|
+
SlickTable,
|
|
57
|
+
WithConfirmationOfDeletion,
|
|
58
|
+
WithoutHotKeys,
|
|
59
|
+
eventContextMenu,
|
|
60
|
+
} from "./model";
|
|
61
|
+
export {
|
|
62
|
+
SlickgridTable,
|
|
63
|
+
WithTableStyles,
|
|
64
|
+
columnCheckboxSelector,
|
|
65
|
+
columnIsEdited,
|
|
66
|
+
eventOpenColumnFilters,
|
|
67
|
+
handleHeaderButtons,
|
|
68
|
+
headerButtons,
|
|
69
|
+
openColumnFilter,
|
|
70
|
+
} from "./ui";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Handler, OnKeyDownEventArgs, SlickGrid } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { EKeyCode } from "shared/model/enums";
|
|
4
|
+
|
|
5
|
+
export const getOnKeyDownCallback =
|
|
6
|
+
(grid: SlickGrid): Handler<OnKeyDownEventArgs> =>
|
|
7
|
+
(event): void => {
|
|
8
|
+
if (event.keyCode === EKeyCode.KeyEnter) {
|
|
9
|
+
event.stopImmediatePropagation();
|
|
10
|
+
grid.navigateNext();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Handler, OnCellChangeEventArgs } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export const onCellChange =
|
|
6
|
+
(table: ISlickTable): Handler<OnCellChangeEventArgs> =>
|
|
7
|
+
(_e, args) => {
|
|
8
|
+
const { grid, item } = args;
|
|
9
|
+
item.isEdited = true;
|
|
10
|
+
grid.invalidate();
|
|
11
|
+
table.isEdited = true;
|
|
12
|
+
table.hotKeysBehavior.pushToCommandQueue(grid);
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Handler, OnRowCountChangedEventArgs } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
export const onRowCountChanged =
|
|
6
|
+
(table: ISlickTable): Handler<OnRowCountChangedEventArgs> =>
|
|
7
|
+
() => {
|
|
8
|
+
const grid = table.grid;
|
|
9
|
+
if (!grid) return;
|
|
10
|
+
grid.updateRowCount();
|
|
11
|
+
grid.render();
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { openContextMenu } from "./openContextMenu";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MenuCommandItemCallbackArgs, SlickEventData } from "slickgrid";
|
|
2
|
+
|
|
3
|
+
import { ISlickTable } from "shared/model/types";
|
|
4
|
+
|
|
5
|
+
import { eventContextMenu } from "../../model";
|
|
6
|
+
import { commitCurrentEdit } from "../functions";
|
|
7
|
+
|
|
8
|
+
export function openContextMenu(table: ISlickTable) {
|
|
9
|
+
return function (e: SlickEventData<MenuCommandItemCallbackArgs>): void {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
commitCurrentEdit();
|
|
12
|
+
eventContextMenu.table = table;
|
|
13
|
+
eventContextMenu.x = e.pageX || 0;
|
|
14
|
+
eventContextMenu.y = e.pageY || 0;
|
|
15
|
+
eventContextMenu.notify();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Editor,
|
|
3
|
+
EditorArguments,
|
|
4
|
+
EditorValidationResult,
|
|
5
|
+
keyCode,
|
|
6
|
+
} from "slickgrid";
|
|
7
|
+
|
|
8
|
+
import { EKey } from "shared/model/enums";
|
|
9
|
+
import { ISlickRow } from "shared/model/types";
|
|
10
|
+
|
|
11
|
+
export abstract class Autocomplete implements Editor {
|
|
12
|
+
abstract args: EditorArguments<any, any, any>;
|
|
13
|
+
protected currentFocus = -1;
|
|
14
|
+
protected defaultValue = "";
|
|
15
|
+
protected id = "autocomplete";
|
|
16
|
+
protected input: HTMLInputElement = document.createElement("input");
|
|
17
|
+
public keyCaptureList: number[] = [keyCode.UP, keyCode.DOWN, keyCode.ENTER];
|
|
18
|
+
protected list?: HTMLDivElement;
|
|
19
|
+
protected navOnLR?: boolean;
|
|
20
|
+
|
|
21
|
+
applyValue(item: any, state: any): void {
|
|
22
|
+
item[this.args.column.field] = state;
|
|
23
|
+
}
|
|
24
|
+
closeAllList(): void {
|
|
25
|
+
this.list?.remove();
|
|
26
|
+
this.list = undefined;
|
|
27
|
+
this.currentFocus = -1;
|
|
28
|
+
}
|
|
29
|
+
destroy(): void {
|
|
30
|
+
this.input.removeEventListener("input", this.onInput.bind(this));
|
|
31
|
+
this.input.removeEventListener("keydown", this.onKeydown.bind(this));
|
|
32
|
+
this.closeAllList();
|
|
33
|
+
this.input.remove();
|
|
34
|
+
}
|
|
35
|
+
focus(): void {
|
|
36
|
+
this.input.focus();
|
|
37
|
+
}
|
|
38
|
+
init(): void {
|
|
39
|
+
this.navOnLR = this.args.grid.getOptions().editorCellNavOnLRKeys;
|
|
40
|
+
this.input.setAttribute("type", "text");
|
|
41
|
+
this.input.classList.add("editor-text");
|
|
42
|
+
this.args.container.append(this.input);
|
|
43
|
+
|
|
44
|
+
this.input.addEventListener("input", this.onInput.bind(this));
|
|
45
|
+
this.input.addEventListener("keydown", this.onKeydown.bind(this));
|
|
46
|
+
this.input.focus();
|
|
47
|
+
this.input.select();
|
|
48
|
+
}
|
|
49
|
+
isValueChanged(): boolean {
|
|
50
|
+
return (
|
|
51
|
+
!(this.input.value == "" && this.defaultValue == null) &&
|
|
52
|
+
this.input.value != this.defaultValue
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
loadValue(item: ISlickRow): void {
|
|
56
|
+
this.defaultValue = item[this.args.column.field] || "";
|
|
57
|
+
this.input.value = this.defaultValue;
|
|
58
|
+
this.input.defaultValue = this.defaultValue;
|
|
59
|
+
this.input.focus();
|
|
60
|
+
this.input.select();
|
|
61
|
+
}
|
|
62
|
+
makeVisible(list: HTMLDivElement): void {
|
|
63
|
+
const canvas = list.closest(".grid-canvas");
|
|
64
|
+
if (!canvas) return;
|
|
65
|
+
const { bottom: listBottom, right: listRight } =
|
|
66
|
+
list.getBoundingClientRect();
|
|
67
|
+
const { bottom: canvasBottom, right: canvasRight } =
|
|
68
|
+
canvas.getBoundingClientRect();
|
|
69
|
+
if (listBottom >= canvasBottom) {
|
|
70
|
+
const rowHeight = this.args.grid.getOptions().rowHeight;
|
|
71
|
+
list.style.position = "absolute";
|
|
72
|
+
list.style.bottom = `${rowHeight}px`;
|
|
73
|
+
}
|
|
74
|
+
if (listRight >= canvasRight) {
|
|
75
|
+
list.style.position = "absolute";
|
|
76
|
+
list.style.right = "0";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
abstract onClick(event: MouseEvent): void;
|
|
80
|
+
abstract onInput(event: Event): void;
|
|
81
|
+
onKeydown(event: KeyboardEvent): void {
|
|
82
|
+
if (event.key === EKey.ArrowLeft) {
|
|
83
|
+
this.navOnLR && this.args.grid.navigatePrev();
|
|
84
|
+
event.stopImmediatePropagation();
|
|
85
|
+
return;
|
|
86
|
+
} else if (event.key === EKey.ArrowRight) {
|
|
87
|
+
this.navOnLR && this.args.grid.navigateNext();
|
|
88
|
+
event.stopImmediatePropagation();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!this.list) return;
|
|
92
|
+
const items: HTMLCollectionOf<HTMLDivElement> =
|
|
93
|
+
this.list.getElementsByTagName("div");
|
|
94
|
+
if (event.key === EKey.ArrowDown) {
|
|
95
|
+
this.currentFocus++;
|
|
96
|
+
this.setActive(items);
|
|
97
|
+
} else if (event.key === EKey.ArrowUp) {
|
|
98
|
+
this.currentFocus--;
|
|
99
|
+
this.setActive(items);
|
|
100
|
+
} else if (event.key === EKey.Enter || event.key === EKey.Tab) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
if (items.length === 1) {
|
|
103
|
+
this.currentFocus = 0;
|
|
104
|
+
}
|
|
105
|
+
if (this.currentFocus > -1) {
|
|
106
|
+
/* simulate click on the "active" item */
|
|
107
|
+
if (items) items[this.currentFocus].click();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
removeActive(x: HTMLCollectionOf<HTMLDivElement>): void {
|
|
112
|
+
for (let i = 0; i < x.length; i++) {
|
|
113
|
+
x[i].classList.remove("active");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
scrollToElement(child: HTMLDivElement): void {
|
|
117
|
+
const parent = child.parentElement;
|
|
118
|
+
if (!parent) return;
|
|
119
|
+
const { clientHeight: childClientHeight, offsetTop } = child;
|
|
120
|
+
const { clientHeight: parentClientHeight, scrollTop } = parent;
|
|
121
|
+
if (offsetTop >= scrollTop + parentClientHeight) {
|
|
122
|
+
parent.scrollTop = offsetTop - childClientHeight * 1.5;
|
|
123
|
+
} else if (offsetTop - childClientHeight <= scrollTop) {
|
|
124
|
+
parent.scrollTop = offsetTop - parentClientHeight;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
serializeValue(): string {
|
|
128
|
+
return this.input.value;
|
|
129
|
+
}
|
|
130
|
+
setActive(list: HTMLCollectionOf<HTMLDivElement>): void {
|
|
131
|
+
if (!list.length) return;
|
|
132
|
+
this.removeActive(list);
|
|
133
|
+
if (this.currentFocus >= list.length) this.currentFocus = 0;
|
|
134
|
+
if (this.currentFocus < 0) this.currentFocus = list.length - 1;
|
|
135
|
+
const activeElement = list[this.currentFocus];
|
|
136
|
+
activeElement.classList.add("active");
|
|
137
|
+
this.scrollToElement(activeElement);
|
|
138
|
+
}
|
|
139
|
+
abstract showOptions(search: string): void;
|
|
140
|
+
validate(): EditorValidationResult {
|
|
141
|
+
if (this.args.column.validator) {
|
|
142
|
+
const validationResults = this.args.column.validator(
|
|
143
|
+
this.input.value,
|
|
144
|
+
this.args,
|
|
145
|
+
);
|
|
146
|
+
if (!validationResults.valid) {
|
|
147
|
+
return validationResults;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
valid: true,
|
|
152
|
+
msg: null,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|