Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,42 +42,41 @@
"url": "https://github.com/gridstack/gridstack.js/issues"
},
"homepage": "http://gridstack.github.io/gridstack.js/",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"@types/jasmine": "^3.5.9",
"@types/jquery": "^3.5.1",
"@types/jqueryui": "^1.12.13",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"connect": "^3.7.0",
"core-js": "^3.6.4",
"coveralls": "^3.0.9",
"doctoc": "^1.4.0",
"eslint": "^6.8.0",
"eslint": "^7.12.1",
"grunt": "^1.0.4",
"grunt-cli": "^1.3.2",
"grunt-contrib-connect": "^2.1.0",
"grunt-contrib-connect": "^3.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-uglify": "^4.0.1",
"grunt-contrib-uglify": "^5.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^22.0.0",
"grunt-eslint": "^23.0.0",
"grunt-protractor-runner": "^5.0.0",
"grunt-protractor-webdriver": "^0.2.5",
"grunt-sass": "3.1.0",
"jasmine-core": "^3.5.0",
"karma": "^4.4.1",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-jasmine": "^3.1.1",
"karma-typescript": "4.1.1",
"node-sass": "^4.13.1",
"puppeteer": "^2.1.1",
"karma-jasmine": "^4.0.1",
"karma-typescript": "5.2.0",
"node-sass": "^5.0.0",
"puppeteer": "^5.4.1",
"serve-static": "^1.14.1",
"ts-loader": "^6.2.1",
"typescript": "3.4.5",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
"ts-loader": "^8.0.7",
"typescript": "4.0.5",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0"
}
}
4 changes: 2 additions & 2 deletions src/gridstack-dd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type DDDropOpt = {

/** drag&drop options currently called from the main code, but others can be passed in grid options */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | {} | any;
export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
export type DDKey = 'minWidth' | 'minHeight' | string;
export type DDValue = number | string;

Expand All @@ -33,7 +33,7 @@ export class GridStackDD {
static registeredPlugins: typeof GridStackDD;

/** call this method to register your plugin instead of the default no-op one */
static registerPlugin(pluginClass: typeof GridStackDD) {
static registerPlugin(pluginClass: typeof GridStackDD): void {
GridStackDD.registeredPlugins = pluginClass;
}

Expand Down
3 changes: 2 additions & 1 deletion src/gridstack-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,11 @@ export class GridStackEngine {
}

/** called to remove all internal values */
public cleanupNode(node: GridStackNode) {
public cleanupNode(node: GridStackNode): GridStackEngine {
for (let prop in node) {
if (prop[0] === '_') delete node[prop];
}
return this;
}

/** @internal legacy method renames */
Expand Down
10 changes: 5 additions & 5 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ export class GridStack {
this._setupRemoveDrop();
this._setupAcceptWidget();
this._updateWindowResizeEvent();
};

}

/**
* add a new widget and returns it.
Expand Down Expand Up @@ -401,7 +400,7 @@ export class GridStack {
* @example
* see http://gridstackjs.com/demo/serialization.html
**/
public load(layout: GridStackWidget[], addAndRemove: boolean | ((w: GridStackWidget, add: boolean) => void) = true) {
public load(layout: GridStackWidget[], addAndRemove: boolean | ((w: GridStackWidget, add: boolean) => void) = true): GridStack {
let items = GridStack.Utils.sort(layout);
let removed: GridStackNode[] = [];
this.batchUpdate();
Expand Down Expand Up @@ -435,6 +434,7 @@ export class GridStack {
});
this.engine.removedNodes = removed;
this.commit();
return this;
}

/**
Expand Down Expand Up @@ -502,7 +502,7 @@ export class GridStack {
this._triggerAddEvent();
this._triggerChangeEvent();
return this;
};
}

/** re-layout grid items to reclaim any empty space */
public compact(): GridStack {
Expand Down Expand Up @@ -1215,7 +1215,7 @@ export class GridStack {
private _setupRemovingTimeout(el: GridItemHTMLElement): GridStack {
let node = el.gridstackNode;
if (!node || node._removeTimeout || !this.opts.removable) return this;
node._removeTimeout = setTimeout(() => {
node._removeTimeout = window.setTimeout(() => {
el.classList.add('grid-stack-item-removing');
node._isAboutToRemove = true;
}, this.opts.removeTimeout);
Expand Down
25 changes: 14 additions & 11 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export interface HeightData {
}

/** checks for obsolete method names */
export function obsolete(self, f, oldName: string, newName: string, rev: string) {
// eslint-disable-next-line
export function obsolete(self, f, oldName: string, newName: string, rev: string): (...args: any[]) => any {
let wrapper = (...args) => {
console.warn('gridstack.js: Function `' + oldName + '` is deprecated in ' + rev + ' and has been replaced ' +
'with `' + newName + '`. It will be **completely** removed in v1.0');
Expand All @@ -25,7 +26,7 @@ export function obsolete(self, f, oldName: string, newName: string, rev: string)
}

/** checks for obsolete grid options (can be used for any fields, but msg is about options) */
export function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string) {
export function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: string, rev: string): void {
if (opts[oldName] !== undefined) {
opts[newName] = opts[oldName];
console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + ' and has been replaced with `' +
Expand All @@ -34,14 +35,14 @@ export function obsoleteOpts(opts: GridStackOptions, oldName: string, newName: s
}

/** checks for obsolete grid options which are gone */
export function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string) {
export function obsoleteOptsDel(opts: GridStackOptions, oldName: string, rev: string, info: string): void {
if (opts[oldName] !== undefined) {
console.warn('gridstack.js: Option `' + oldName + '` is deprecated in ' + rev + info);
}
}

/** checks for obsolete Jquery element attributes */
export function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string) {
export function obsoleteAttr(el: HTMLElement, oldName: string, newName: string, rev: string): void {
let oldAttr = el.getAttribute(oldName);
if (oldAttr !== null) {
el.setAttribute(newName, oldAttr);
Expand Down Expand Up @@ -106,14 +107,14 @@ export class Utils {
}

/** removed the given stylesheet id */
static removeStylesheet(id: string) {
static removeStylesheet(id: string): void {
let el = document.querySelector('STYLE[data-gs-style-id=' + id + ']');
if (!el || !el.parentNode) return;
el.parentNode.removeChild(el);
}

/** inserts a CSS rule */
static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string) {
static addCSSRule(sheet: CSSStyleSheet, selector: string, rules: string): void {
if (typeof sheet.addRule === 'function') {
sheet.addRule(selector, rules);
} else if (typeof sheet.insertRule === 'function') {
Expand All @@ -122,7 +123,7 @@ export class Utils {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
static toBool(v: any): boolean {
static toBool(v: unknown): boolean {
if (typeof v === 'boolean') {
return v;
}
Expand Down Expand Up @@ -154,6 +155,7 @@ export class Utils {
}

/** copies unset fields in target to use the given default sources values */
// eslint-disable-next-line
static defaults(target, ...sources): {} {

sources.forEach(source => {
Expand All @@ -172,8 +174,9 @@ export class Utils {
}

/** makes a shallow copy of the passed json struct */
// eslint-disable-next-line
static clone(target: {}): {} {
return {...target}; // was $.extend({}, target)
return {...target};
}

/** return the closest parent matching the given class */
Expand All @@ -185,7 +188,7 @@ export class Utils {
}

/** @internal */
static throttle(callback: () => void, delay: number) {
static throttle(callback: () => void, delay: number): () => void {
let isWaiting = false;

return (...args) => {
Expand All @@ -197,7 +200,7 @@ export class Utils {
}
}

static removePositioningStyles(el: HTMLElement) {
static removePositioningStyles(el: HTMLElement): void {
let style = el.style;
if (style.position) {
style.removeProperty('position');
Expand Down Expand Up @@ -230,7 +233,7 @@ export class Utils {
}

/** @internal */
static updateScrollPosition(el: HTMLElement, position: {top: number}, distance: number) {
static updateScrollPosition(el: HTMLElement, position: {top: number}, distance: number): void {
// is widget in view?
let rect = el.getBoundingClientRect();
let innerHeightOrClientHeight = (window.innerHeight || document.documentElement.clientHeight);
Expand Down
Loading