@slickgrid-universal/empty-warning-component
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -6,2 +6,20 @@ # Change Log | ||
# [0.10.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.9.0...v0.10.0) (2021-01-28) | ||
### Bug Fixes | ||
* **comp:** empty data warning should work with autoheight grid ([#240](https://github.com/ghiscoding/slickgrid-universal/issues/240)) ([8c9cb84](https://github.com/ghiscoding/slickgrid-universal/commit/8c9cb84847bfd08a678d333a8555ae6fc9295670)) | ||
* **components:** empty data warning should work with autoheight grid ([#234](https://github.com/ghiscoding/slickgrid-universal/issues/234)) ([16daa36](https://github.com/ghiscoding/slickgrid-universal/commit/16daa368f0e46112fc1d1dd0b1a944ec2b60ced0)) | ||
* **core:** fix types index.d.ts url ([a76b3a3](https://github.com/ghiscoding/slickgrid-universal/commit/a76b3a3d97a6d211ec2e7e8d9060fd8dd0719f58)) | ||
### Features | ||
* **editors:** add Clone functionality to Composite Editor ([#236](https://github.com/ghiscoding/slickgrid-universal/issues/236)) ([df545e4](https://github.com/ghiscoding/slickgrid-universal/commit/df545e4ec64271307b1979feb5e786f449433639)) | ||
# [0.9.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.8.0...v0.9.0) (2021-01-06) | ||
@@ -8,0 +26,0 @@ |
@@ -6,2 +6,3 @@ import { ContainerService, EmptyWarning, ExternalResource, GridOption, SlickGrid } from '@slickgrid-universal/common'; | ||
private grid; | ||
private isPreviouslyShown; | ||
private translaterService?; | ||
@@ -8,0 +9,0 @@ /** Getter for the Grid Options pulled through the Grid Object */ |
@@ -6,3 +6,5 @@ "use strict"; | ||
class SlickEmptyWarningComponent { | ||
constructor() { } | ||
constructor() { | ||
this.isPreviouslyShown = false; | ||
} | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
@@ -17,5 +19,4 @@ get gridOptions() { | ||
dispose() { | ||
var _a, _b; | ||
(_a = this._warningLeftElement) === null || _a === void 0 ? void 0 : _a.remove(); | ||
(_b = this._warningRightElement) === null || _b === void 0 ? void 0 : _b.remove(); | ||
this._warningLeftElement?.remove(); | ||
this._warningRightElement?.remove(); | ||
this._warningLeftElement = null; | ||
@@ -31,26 +32,45 @@ this._warningRightElement = null; | ||
showEmptyDataMessage(isShowing = true, options) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!this.grid || !this.gridOptions) { | ||
if (!this.grid || !this.gridOptions || this.isPreviouslyShown === isShowing) { | ||
return false; | ||
} | ||
// keep reference so that we won't re-render the warning if the status is the same | ||
this.isPreviouslyShown = isShowing; | ||
const gridUid = this.grid.getUID(); | ||
const defaultMessage = 'No data to display.'; | ||
const mergedOptions = Object.assign(Object.assign({ message: defaultMessage }, this.gridOptions.emptyDataWarning), options); | ||
const emptyDataClassName = (_a = mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.className) !== null && _a !== void 0 ? _a : 'slick-empty-data-warning'; | ||
const mergedOptions = { message: defaultMessage, ...this.gridOptions.emptyDataWarning, ...options }; | ||
const emptyDataClassName = mergedOptions?.className ?? 'slick-empty-data-warning'; | ||
this._warningLeftElement = document.querySelector(`.${gridUid} .${emptyDataClassName}`); | ||
const gridCanvasLeftElm = document.querySelector(`.${gridUid} .grid-canvas.grid-canvas-left`); | ||
const gridCanvasRightElm = document.querySelector(`.${gridUid} .grid-canvas.grid-canvas-right`); | ||
const leftElementMarginLeft = (_b = mergedOptions.leftViewportMarginLeft) !== null && _b !== void 0 ? _b : 0; | ||
const rightElementMarginLeft = (_c = mergedOptions.rightViewportMarginLeft) !== null && _c !== void 0 ? _c : 0; | ||
const leftElementFrozenMarginLeft = (_d = mergedOptions.frozenLeftViewportMarginLeft) !== null && _d !== void 0 ? _d : 0; | ||
const rightElementFrozenMarginLeft = (_e = mergedOptions.frozenRightViewportMarginLeft) !== null && _e !== void 0 ? _e : 0; | ||
const isFrozenGrid = (((_f = this.gridOptions) === null || _f === void 0 ? void 0 : _f.frozenColumn) !== undefined && this.gridOptions.frozenColumn >= 0); | ||
const leftElementMarginLeft = mergedOptions.leftViewportMarginLeft ?? 0; | ||
const rightElementMarginLeft = mergedOptions.rightViewportMarginLeft ?? 0; | ||
const leftElementFrozenMarginLeft = mergedOptions.frozenLeftViewportMarginLeft ?? 0; | ||
const rightElementFrozenMarginLeft = mergedOptions.frozenRightViewportMarginLeft ?? 0; | ||
const isFrozenGrid = (this.gridOptions?.frozenColumn !== undefined && this.gridOptions.frozenColumn >= 0); | ||
const leftViewportMarginLeft = typeof leftElementMarginLeft === 'string' ? leftElementMarginLeft : `${leftElementMarginLeft}px`; | ||
const rightViewportMarginLeft = typeof rightElementMarginLeft === 'string' ? rightElementMarginLeft : `${rightElementMarginLeft}px`; | ||
if (!this._warningLeftElement && !isShowing) { | ||
return false; | ||
// when dealing with a grid that has "autoHeight" option, we need to override 2 height that get miscalculated | ||
// that is because it is not aware that we are adding this slick empty element in this grid DOM | ||
if (this.gridOptions.autoHeight) { | ||
const leftPaneElm = document.querySelector('.slick-pane.slick-pane-top.slick-pane-left'); | ||
if (leftPaneElm && leftPaneElm.style && gridCanvasLeftElm && gridCanvasLeftElm.style) { | ||
const leftPaneHeight = parseInt(leftPaneElm.style.height, 10) || 0; // this field auto calc by row height | ||
// get row height of each feature when enabled (rowHeight will always be defined because that is the cell height) | ||
const cellRowHeight = this.gridOptions?.rowHeight ?? 0; | ||
const filterRowHeight = this.gridOptions.enableFiltering ? (this.gridOptions?.headerRowHeight ?? 0) : 0; | ||
const preHeaderRowHeight = this.gridOptions.createPreHeaderPanel ? (this.gridOptions?.preHeaderPanelHeight ?? 0) : 0; | ||
if (isShowing) { | ||
// use when height with rows more that 100px | ||
// AutoHeight option collapse dataview to 100px when show message without data in huge grid | ||
// (default autoHeight for message - 100px you can add as param if needed) | ||
let leftPaneMinHeight = (leftPaneHeight !== null && leftPaneHeight < 100) ? leftPaneHeight : 100; | ||
leftPaneMinHeight += filterRowHeight + preHeaderRowHeight; // add preHeader & filter height when enabled | ||
leftPaneElm.style.minHeight = `${leftPaneMinHeight}px`; | ||
gridCanvasLeftElm.style.minHeight = `${cellRowHeight}px`; | ||
} | ||
} | ||
} | ||
// warning message could come from a translation key or by the warning options | ||
let warningMessage = mergedOptions.message; | ||
if (this.gridOptions.enableTranslate && this.translaterService && (mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.messageKey)) { | ||
if (this.gridOptions.enableTranslate && this.translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this.translaterService.translate(mergedOptions.messageKey); | ||
@@ -57,0 +77,0 @@ } |
{ | ||
"name": "@slickgrid-universal/empty-warning-component", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Slick Empty Warning Component - Vanilla Implementation of an Empty Dataset Warning Component", | ||
"main": "dist/commonjs/index.js", | ||
"module": "dist/es2015/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/commonjs/index.d.ts", | ||
"typings": "dist/commonjs/index.d.ts", | ||
@@ -20,5 +20,5 @@ "publishConfig": { | ||
"dev:watch": "run-p build:watch", | ||
"bundle": "run-p bundle:commonjs bundle:es2015", | ||
"bundle": "run-p bundle:commonjs bundle:esm", | ||
"bundle:commonjs": "tsc --project tsconfig.build.json --outDir dist/commonjs --module commonjs", | ||
"bundle:es2015": "cross-env tsc --project tsconfig.build.json --outDir dist/es2015 --module es2020 --target es2015", | ||
"bundle:esm": "cross-env tsc --project tsconfig.build.json --outDir dist/esm --module esnext --target es2020", | ||
"prebundle": "npm-run-all delete:dist", | ||
@@ -32,4 +32,4 @@ "delete:dist": "cross-env rimraf --maxBusyTries=10 dist", | ||
"engines": { | ||
"node": ">=12.0.0", | ||
"npm": ">=6.14.0" | ||
"node": ">=14.15.0", | ||
"npm": ">=6.14.8" | ||
}, | ||
@@ -39,11 +39,10 @@ "browserslist": [ | ||
"> 1%", | ||
"maintained node versions", | ||
"not dead" | ||
], | ||
"dependencies": { | ||
"@slickgrid-universal/common": "^0.9.0", | ||
"@slickgrid-universal/common": "^0.10.0", | ||
"dompurify": "^2.2.6" | ||
}, | ||
"devDependencies": { | ||
"@types/webpack": "^4.41.25", | ||
"@types/webpack": "^4.41.26", | ||
"cross-env": "^7.0.3", | ||
@@ -53,3 +52,3 @@ "npm-run-all": "^4.1.5", | ||
}, | ||
"gitHead": "fa6ed1500fcd464072b60840f161a7c6c3eae845" | ||
"gitHead": "34baf2cd602f7c478422aa6bcfb2dfdeb572c490" | ||
} |
@@ -15,3 +15,3 @@ [](https://opensource.org/licenses/MIT) | ||
Vanilla Implementation of an Empty Dataset Warning Component when no data showing in the grid. This is in summary a very simplified `div` showing a warning message when there are no data to show in the grid. | ||
Vanilla Implementation of an Empty Dataset Warning Component when there is no data available in the grid. This is in summary a very simplified `div` showing a warning message (that can be translated as well) when there are no data to show in the grid. | ||
@@ -18,0 +18,0 @@ ### External Dependencies |
{ | ||
"compilerOptions": { | ||
"module": "es2020", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"target": "es2015", | ||
"target": "es2020", | ||
"lib": [ | ||
@@ -14,3 +14,3 @@ "es2020", | ||
], | ||
"outDir": "dist/2015", | ||
"outDir": "dist/commonjs", | ||
"noImplicitAny": true, | ||
@@ -41,2 +41,2 @@ "suppressImplicitAnyIndexErrors": true, | ||
] | ||
} | ||
} |
@@ -6,6 +6,6 @@ { | ||
"rootDir": "src", | ||
"declarationDir": "dist/es2015", | ||
"outDir": "dist/es2015", | ||
"target": "es2017", | ||
"module": "es2015", | ||
"declarationDir": "dist/esm", | ||
"outDir": "dist/esm", | ||
"target": "es2020", | ||
"module": "esnext", | ||
"sourceMap": true, | ||
@@ -42,2 +42,2 @@ "noImplicitReturns": true, | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
39914
363
+ Added@slickgrid-universal/common@0.10.2(transitive)
- Removed@slickgrid-universal/common@0.9.0(transitive)