@slickgrid-universal/empty-warning-component
Advanced tools
Comparing version 4.2.0 to 4.3.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SlickEmptyWarningComponent = void 0; | ||
const common_1 = require("@slickgrid-universal/common"); | ||
class SlickEmptyWarningComponent { | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions() { | ||
return this.grid?.getOptions() ?? {}; | ||
} | ||
constructor() { | ||
this._isPreviouslyShown = false; | ||
this._warningLeftElement = null; | ||
this._warningRightElement = null; | ||
this.isPreviouslyShown = false; | ||
} | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions() { | ||
return this._grid?.getOptions() ?? {}; | ||
} | ||
init(grid, containerService) { | ||
this.grid = grid; | ||
this.translaterService = containerService.get('TranslaterService'); | ||
this._grid = grid; | ||
this._translaterService = containerService.get('TranslaterService'); | ||
} | ||
@@ -31,8 +32,8 @@ dispose() { | ||
showEmptyDataMessage(isShowing = true, options) { | ||
if (!this.grid || !this.gridOptions || this.isPreviouslyShown === isShowing) { | ||
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(); | ||
this._isPreviouslyShown = isShowing; | ||
const gridUid = this._grid.getUID(); | ||
const defaultMessage = 'No data to display.'; | ||
@@ -74,10 +75,10 @@ const mergedOptions = { message: defaultMessage, ...this.gridOptions.emptyDataWarning, ...options }; | ||
let warningMessage = mergedOptions.message; | ||
if (this.gridOptions.enableTranslate && this.translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this.translaterService.translate(mergedOptions.messageKey); | ||
if (this.gridOptions.enableTranslate && this._translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this._translaterService.translate(mergedOptions.messageKey); | ||
} | ||
if (!this._warningLeftElement && gridCanvasLeftElm && gridCanvasRightElm) { | ||
this._warningLeftElement = document.createElement('div'); | ||
this._warningLeftElement.classList.add(emptyDataClassName); | ||
this._warningLeftElement.classList.add(...(0, common_1.classNameToList)(emptyDataClassName)); | ||
this._warningLeftElement.classList.add('left'); | ||
this.grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
this._grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
// clone the warning element and add the "right" class to it so we can distinguish | ||
@@ -84,0 +85,0 @@ this._warningRightElement = this._warningLeftElement.cloneNode(true); |
@@ -0,14 +1,15 @@ | ||
import { classNameToList } from '@slickgrid-universal/common'; | ||
export class SlickEmptyWarningComponent { | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions() { | ||
return this.grid?.getOptions() ?? {}; | ||
} | ||
constructor() { | ||
this._isPreviouslyShown = false; | ||
this._warningLeftElement = null; | ||
this._warningRightElement = null; | ||
this.isPreviouslyShown = false; | ||
} | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions() { | ||
return this._grid?.getOptions() ?? {}; | ||
} | ||
init(grid, containerService) { | ||
this.grid = grid; | ||
this.translaterService = containerService.get('TranslaterService'); | ||
this._grid = grid; | ||
this._translaterService = containerService.get('TranslaterService'); | ||
} | ||
@@ -28,8 +29,8 @@ dispose() { | ||
showEmptyDataMessage(isShowing = true, options) { | ||
if (!this.grid || !this.gridOptions || this.isPreviouslyShown === isShowing) { | ||
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(); | ||
this._isPreviouslyShown = isShowing; | ||
const gridUid = this._grid.getUID(); | ||
const defaultMessage = 'No data to display.'; | ||
@@ -71,10 +72,10 @@ const mergedOptions = { message: defaultMessage, ...this.gridOptions.emptyDataWarning, ...options }; | ||
let warningMessage = mergedOptions.message; | ||
if (this.gridOptions.enableTranslate && this.translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this.translaterService.translate(mergedOptions.messageKey); | ||
if (this.gridOptions.enableTranslate && this._translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this._translaterService.translate(mergedOptions.messageKey); | ||
} | ||
if (!this._warningLeftElement && gridCanvasLeftElm && gridCanvasRightElm) { | ||
this._warningLeftElement = document.createElement('div'); | ||
this._warningLeftElement.classList.add(emptyDataClassName); | ||
this._warningLeftElement.classList.add(...classNameToList(emptyDataClassName)); | ||
this._warningLeftElement.classList.add('left'); | ||
this.grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
this._grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
// clone the warning element and add the "right" class to it so we can distinguish | ||
@@ -81,0 +82,0 @@ this._warningRightElement = this._warningLeftElement.cloneNode(true); |
@@ -1,11 +0,10 @@ | ||
import type { ContainerService, EmptyWarning, ExternalResource, GridOption, SlickGrid, TranslaterService } from '@slickgrid-universal/common'; | ||
import { type ContainerService, type EmptyWarning, type ExternalResource, type GridOption, type SlickGrid, type TranslaterService } from '@slickgrid-universal/common'; | ||
export declare class SlickEmptyWarningComponent implements ExternalResource { | ||
protected _grid: SlickGrid; | ||
protected _isPreviouslyShown: boolean; | ||
protected _translaterService?: TranslaterService | null; | ||
protected _warningLeftElement: HTMLDivElement | null; | ||
protected _warningRightElement: HTMLDivElement | null; | ||
protected grid: SlickGrid; | ||
protected isPreviouslyShown: boolean; | ||
protected translaterService?: TranslaterService | null; | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions(): GridOption; | ||
constructor(); | ||
init(grid: SlickGrid, containerService: ContainerService): void; | ||
@@ -12,0 +11,0 @@ dispose(): void; |
{ | ||
"name": "@slickgrid-universal/empty-warning-component", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "Slick Empty Warning Component - Vanilla Implementation of an Empty Dataset Warning Component", | ||
@@ -48,5 +48,5 @@ "main": "./dist/cjs/index.js", | ||
"dependencies": { | ||
"@slickgrid-universal/common": "~4.2.0" | ||
"@slickgrid-universal/common": "~4.3.0" | ||
}, | ||
"gitHead": "d97d211a6c2d7d2f3ad65a3d5f19b27584e5ae8c" | ||
"gitHead": "42fb4d8bbf9a0199c99658c344c912ac3aaa9772" | ||
} |
@@ -1,28 +0,26 @@ | ||
import type { | ||
ContainerService, | ||
EmptyWarning, | ||
ExternalResource, | ||
GridOption, | ||
SlickGrid, | ||
TranslaterService | ||
import { | ||
classNameToList, | ||
type ContainerService, | ||
type EmptyWarning, | ||
type ExternalResource, | ||
type GridOption, | ||
type SlickGrid, | ||
type TranslaterService | ||
} from '@slickgrid-universal/common'; | ||
export class SlickEmptyWarningComponent implements ExternalResource { | ||
protected _grid!: SlickGrid; | ||
protected _isPreviouslyShown = false; | ||
protected _translaterService?: TranslaterService | null; | ||
protected _warningLeftElement: HTMLDivElement | null = null; | ||
protected _warningRightElement: HTMLDivElement | null = null; | ||
protected grid!: SlickGrid; | ||
protected isPreviouslyShown = false; | ||
protected translaterService?: TranslaterService | null; | ||
/** Getter for the Grid Options pulled through the Grid Object */ | ||
get gridOptions(): GridOption { | ||
return this.grid?.getOptions() ?? {}; | ||
return this._grid?.getOptions() ?? {}; | ||
} | ||
constructor() { } | ||
init(grid: SlickGrid, containerService: ContainerService) { | ||
this.grid = grid; | ||
this.translaterService = containerService.get<TranslaterService>('TranslaterService'); | ||
this._grid = grid; | ||
this._translaterService = containerService.get<TranslaterService>('TranslaterService'); | ||
} | ||
@@ -44,3 +42,3 @@ | ||
showEmptyDataMessage(isShowing = true, options?: EmptyWarning): boolean { | ||
if (!this.grid || !this.gridOptions || this.isPreviouslyShown === isShowing) { | ||
if (!this._grid || !this.gridOptions || this._isPreviouslyShown === isShowing) { | ||
return false; | ||
@@ -50,5 +48,5 @@ } | ||
// keep reference so that we won't re-render the warning if the status is the same | ||
this.isPreviouslyShown = isShowing; | ||
this._isPreviouslyShown = isShowing; | ||
const gridUid = this.grid.getUID(); | ||
const gridUid = this._grid.getUID(); | ||
const defaultMessage = 'No data to display.'; | ||
@@ -94,4 +92,4 @@ const mergedOptions: EmptyWarning = { message: defaultMessage, ...this.gridOptions.emptyDataWarning, ...options }; | ||
let warningMessage = mergedOptions.message; | ||
if (this.gridOptions.enableTranslate && this.translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this.translaterService.translate(mergedOptions.messageKey); | ||
if (this.gridOptions.enableTranslate && this._translaterService && mergedOptions?.messageKey) { | ||
warningMessage = this._translaterService.translate(mergedOptions.messageKey); | ||
} | ||
@@ -101,5 +99,5 @@ | ||
this._warningLeftElement = document.createElement('div'); | ||
this._warningLeftElement.classList.add(emptyDataClassName); | ||
this._warningLeftElement.classList.add(...classNameToList(emptyDataClassName)); | ||
this._warningLeftElement.classList.add('left'); | ||
this.grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
this._grid.applyHtmlCode(this._warningLeftElement, warningMessage); | ||
@@ -106,0 +104,0 @@ // clone the warning element and add the "right" class to it so we can distinguish |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
133034
386
+ Added@slickgrid-universal/common@4.3.1(transitive)
+ Added@slickgrid-universal/event-pub-sub@4.3.0(transitive)
+ Added@slickgrid-universal/utils@4.3.0(transitive)
- Removed@slickgrid-universal/common@4.2.0(transitive)
- Removed@slickgrid-universal/event-pub-sub@4.2.0(transitive)
- Removed@slickgrid-universal/utils@4.2.0(transitive)