gridstack 10.1.1 → 10.2.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/README.md +1 -1
- package/angular/package.json +1 -1
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +12 -10
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +14 -12
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +14 -12
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +1 -1
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +4 -4
- package/dist/dd-draggable.js +40 -3
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +4 -3
- package/dist/dd-resizable-handle.js +12 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +1 -1
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +1 -1
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +1 -1
- package/dist/es5/dd-base-impl.js +1 -1
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +4 -4
- package/dist/es5/dd-draggable.js +53 -5
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +1 -1
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +1 -1
- package/dist/es5/dd-element.js +1 -1
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +1 -1
- package/dist/es5/dd-gridstack.js +1 -1
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +1 -1
- package/dist/es5/dd-manager.js +1 -1
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +4 -3
- package/dist/es5/dd-resizable-handle.js +13 -1
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +1 -1
- package/dist/es5/dd-resizable.js +1 -1
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +1 -1
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +3 -3
- package/dist/es5/gridstack-engine.js +17 -14
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +11 -4
- package/dist/es5/gridstack.js +100 -46
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +8 -8
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +5 -4
- package/dist/es5/utils.js +19 -18
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +3 -3
- package/dist/gridstack-engine.js +15 -13
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +11 -4
- package/dist/gridstack.js +96 -45
- package/dist/gridstack.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +5 -4
- package/dist/utils.js +18 -18
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +17 -0
- package/doc/README.md +10 -4
- package/package.json +1 -1
- package/angular/projects/demo/.browserslistrc +0 -16
- package/angular/projects/demo/src/app/app.component.css +0 -11
- package/angular/projects/demo/src/app/app.component.html +0 -110
- package/angular/projects/demo/src/app/app.component.spec.ts +0 -25
- package/angular/projects/demo/src/app/app.component.ts +0 -221
- package/angular/projects/demo/src/app/app.module.ts +0 -39
- package/angular/projects/demo/src/app/dummy.component.ts +0 -35
- package/angular/projects/demo/src/app/ngFor.ts +0 -131
- package/angular/projects/demo/src/app/ngFor_cmd.ts +0 -106
- package/angular/projects/demo/src/app/simple.ts +0 -46
- package/angular/projects/demo/src/assets/.gitkeep +0 -0
- package/angular/projects/demo/src/environments/environment.ts +0 -16
- package/angular/projects/demo/src/favicon.ico +0 -0
- package/angular/projects/demo/src/index.html +0 -13
- package/angular/projects/demo/src/main.ts +0 -12
- package/angular/projects/demo/src/polyfills.ts +0 -53
- package/angular/projects/demo/src/styles.css +0 -41
- package/angular/projects/demo/src/test.ts +0 -26
- package/angular/projects/demo/tsconfig.app.json +0 -15
- package/angular/projects/demo/tsconfig.spec.json +0 -18
- package/angular/projects/lib/src/lib/base-widget.ts +0 -28
- package/angular/projects/lib/src/lib/gridstack-item.component.ts +0 -78
- package/angular/projects/lib/src/lib/gridstack.component.ts +0 -287
- package/angular/projects/lib/src/lib/gridstack.module.ts +0 -32
- package/angular/projects/lib/src/public-api.ts +0 -8
- package/angular/projects/lib/src/test.ts +0 -27
- package/dist/angular/src/base-widget.ts +0 -28
- package/dist/angular/src/gridstack-item.component.ts +0 -78
- package/dist/angular/src/gridstack.component.ts +0 -287
- package/dist/angular/src/gridstack.module.ts +0 -32
- package/dist/src/gridstack-extra.scss +0 -25
- package/dist/src/gridstack.scss +0 -157
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack.component.ts 10.1.1
|
|
3
|
-
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { NgModule } from "@angular/core";
|
|
7
|
-
import { CommonModule } from '@angular/common';
|
|
8
|
-
|
|
9
|
-
import { GridStack } from "gridstack";
|
|
10
|
-
import { GridstackComponent, gsCreateNgComponents, gsSaveAdditionalNgInfo } from "./gridstack.component";
|
|
11
|
-
import { GridstackItemComponent } from "./gridstack-item.component";
|
|
12
|
-
|
|
13
|
-
@NgModule({
|
|
14
|
-
imports: [
|
|
15
|
-
CommonModule,
|
|
16
|
-
],
|
|
17
|
-
declarations: [
|
|
18
|
-
GridstackComponent,
|
|
19
|
-
GridstackItemComponent,
|
|
20
|
-
],
|
|
21
|
-
exports: [
|
|
22
|
-
GridstackComponent,
|
|
23
|
-
GridstackItemComponent,
|
|
24
|
-
],
|
|
25
|
-
})
|
|
26
|
-
export class GridstackModule {
|
|
27
|
-
constructor() {
|
|
28
|
-
// set globally our method to create the right widget type
|
|
29
|
-
GridStack.addRemoveCB = gsCreateNgComponents;
|
|
30
|
-
GridStack.saveCB = gsSaveAdditionalNgInfo;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
-
|
|
3
|
-
import 'zone.js';
|
|
4
|
-
import 'zone.js/testing';
|
|
5
|
-
import { getTestBed } from '@angular/core/testing';
|
|
6
|
-
import {
|
|
7
|
-
BrowserDynamicTestingModule,
|
|
8
|
-
platformBrowserDynamicTesting
|
|
9
|
-
} from '@angular/platform-browser-dynamic/testing';
|
|
10
|
-
|
|
11
|
-
declare const require: {
|
|
12
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
13
|
-
<T>(id: string): T;
|
|
14
|
-
keys(): string[];
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// First, initialize the Angular testing environment.
|
|
19
|
-
getTestBed().initTestEnvironment(
|
|
20
|
-
BrowserDynamicTestingModule,
|
|
21
|
-
platformBrowserDynamicTesting(),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
// Then we find all the tests.
|
|
25
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
26
|
-
// And load the modules.
|
|
27
|
-
context.keys().forEach(context);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack-item.component.ts 10.1.1
|
|
3
|
-
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Base interface that all widgets need to implement in order for GridstackItemComponent to correctly save/load/delete/..
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Injectable } from '@angular/core';
|
|
11
|
-
import { NgCompInputs, NgGridStackWidget } from './gridstack.component';
|
|
12
|
-
|
|
13
|
-
@Injectable()
|
|
14
|
-
export abstract class BaseWidget {
|
|
15
|
-
/**
|
|
16
|
-
* REDEFINE to return an object representing the data needed to re-create yourself, other than `selector` already handled.
|
|
17
|
-
* This should map directly to the @Input() fields of this objects on create, so a simple apply can be used on read
|
|
18
|
-
*/
|
|
19
|
-
public serialize(): NgCompInputs | undefined { return; }
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* REDEFINE this if your widget needs to read from saved data and transform it to create itself - you do this for
|
|
23
|
-
* things that are not mapped directly into @Input() fields for example.
|
|
24
|
-
*/
|
|
25
|
-
public deserialize(w: NgGridStackWidget) {
|
|
26
|
-
if (w.input) Object.assign(this, w.input);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack-item.component.ts 10.1.1
|
|
3
|
-
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { Component, ElementRef, Input, ViewChild, ViewContainerRef, OnDestroy, ComponentRef } from '@angular/core';
|
|
7
|
-
import { GridItemHTMLElement, GridStackNode } from 'gridstack';
|
|
8
|
-
import { BaseWidget } from './base-widget';
|
|
9
|
-
|
|
10
|
-
/** store element to Ng Class pointer back */
|
|
11
|
-
export interface GridItemCompHTMLElement extends GridItemHTMLElement {
|
|
12
|
-
_gridItemComp?: GridstackItemComponent;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* HTML Component Wrapper for gridstack items, in combination with GridstackComponent for parent grid
|
|
17
|
-
*/
|
|
18
|
-
@Component({
|
|
19
|
-
selector: 'gridstack-item',
|
|
20
|
-
template: `
|
|
21
|
-
<div class="grid-stack-item-content">
|
|
22
|
-
<!-- where dynamic items go based on component types, or sub-grids, etc...) -->
|
|
23
|
-
<ng-template #container></ng-template>
|
|
24
|
-
<!-- any static (defined in dom) content goes here -->
|
|
25
|
-
<ng-content></ng-content>
|
|
26
|
-
<!-- fallback HTML content from GridStackWidget content field if used instead -->
|
|
27
|
-
{{options.content}}
|
|
28
|
-
</div>`,
|
|
29
|
-
styles: [`
|
|
30
|
-
:host { display: block; }
|
|
31
|
-
`],
|
|
32
|
-
// changeDetection: ChangeDetectionStrategy.OnPush, // IFF you want to optimize and control when ChangeDetection needs to happen...
|
|
33
|
-
})
|
|
34
|
-
export class GridstackItemComponent implements OnDestroy {
|
|
35
|
-
|
|
36
|
-
/** container to append items dynamically */
|
|
37
|
-
@ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
|
|
38
|
-
|
|
39
|
-
/** ComponentRef of ourself - used by dynamic object to correctly get removed */
|
|
40
|
-
public ref: ComponentRef<GridstackItemComponent> | undefined;
|
|
41
|
-
|
|
42
|
-
/** child component so we can save/restore additional data to be saved along */
|
|
43
|
-
public childWidget: BaseWidget | undefined;
|
|
44
|
-
|
|
45
|
-
/** list of options for creating/updating this item */
|
|
46
|
-
@Input() public set options(val: GridStackNode) {
|
|
47
|
-
if (this.el.gridstackNode?.grid) {
|
|
48
|
-
// already built, do an update...
|
|
49
|
-
this.el.gridstackNode.grid.update(this.el, val);
|
|
50
|
-
} else {
|
|
51
|
-
// store our custom element in options so we can update it and not re-create a generic div!
|
|
52
|
-
this._options = {...val, el: this.el};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/** return the latest grid options (from GS once built, otherwise initial values) */
|
|
56
|
-
public get options(): GridStackNode {
|
|
57
|
-
return this.el.gridstackNode || this._options || {el: this.el};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private _options?: GridStackNode;
|
|
61
|
-
|
|
62
|
-
/** return the native element that contains grid specific fields as well */
|
|
63
|
-
public get el(): GridItemCompHTMLElement { return this.elementRef.nativeElement; }
|
|
64
|
-
|
|
65
|
-
/** clears the initial options now that we've built */
|
|
66
|
-
public clearOptions() {
|
|
67
|
-
delete this._options;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
constructor(private readonly elementRef: ElementRef<GridItemHTMLElement>) {
|
|
71
|
-
this.el._gridItemComp = this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public ngOnDestroy(): void {
|
|
75
|
-
delete this.ref;
|
|
76
|
-
delete this.el._gridItemComp;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack.component.ts 10.1.1
|
|
3
|
-
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { AfterContentInit, Component, ContentChildren, ElementRef, EventEmitter, Input,
|
|
7
|
-
OnDestroy, OnInit, Output, QueryList, Type, ViewChild, ViewContainerRef, reflectComponentType, ComponentRef } from '@angular/core';
|
|
8
|
-
import { Subject } from 'rxjs';
|
|
9
|
-
import { takeUntil } from 'rxjs/operators';
|
|
10
|
-
import { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode, GridStackOptions, GridStackWidget } from 'gridstack';
|
|
11
|
-
|
|
12
|
-
import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
|
|
13
|
-
import { BaseWidget } from './base-widget';
|
|
14
|
-
|
|
15
|
-
/** events handlers emitters signature for different events */
|
|
16
|
-
export type eventCB = {event: Event};
|
|
17
|
-
export type elementCB = {event: Event, el: GridItemHTMLElement};
|
|
18
|
-
export type nodesCB = {event: Event, nodes: GridStackNode[]};
|
|
19
|
-
export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: GridStackNode};
|
|
20
|
-
|
|
21
|
-
export type NgCompInputs = {[key: string]: any};
|
|
22
|
-
|
|
23
|
-
/** extends to store Ng Component selector, instead/inAddition to content */
|
|
24
|
-
export interface NgGridStackWidget extends GridStackWidget {
|
|
25
|
-
selector?: string; // component type to create as content
|
|
26
|
-
input?: NgCompInputs; // serialized data for the component input fields
|
|
27
|
-
}
|
|
28
|
-
export interface NgGridStackNode extends GridStackNode {
|
|
29
|
-
selector?: string; // component type to create as content
|
|
30
|
-
}
|
|
31
|
-
export interface NgGridStackOptions extends GridStackOptions {
|
|
32
|
-
children?: NgGridStackWidget[];
|
|
33
|
-
subGridOpts?: NgGridStackOptions;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** store element to Ng Class pointer back */
|
|
37
|
-
export interface GridCompHTMLElement extends GridHTMLElement {
|
|
38
|
-
_gridComp?: GridstackComponent;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** selector string to runtime Type mapping */
|
|
42
|
-
export type SelectorToType = {[key: string]: Type<Object>};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* HTML Component Wrapper for gridstack, in combination with GridstackItemComponent for the items
|
|
46
|
-
*/
|
|
47
|
-
@Component({
|
|
48
|
-
selector: 'gridstack',
|
|
49
|
-
template: `
|
|
50
|
-
<!-- content to show when when grid is empty, like instructions on how to add widgets -->
|
|
51
|
-
<ng-content select="[empty-content]" *ngIf="isEmpty"></ng-content>
|
|
52
|
-
<!-- where dynamic items go -->
|
|
53
|
-
<ng-template #container></ng-template>
|
|
54
|
-
<!-- where template items go -->
|
|
55
|
-
<ng-content></ng-content>
|
|
56
|
-
`,
|
|
57
|
-
styles: [`
|
|
58
|
-
:host { display: block; }
|
|
59
|
-
`],
|
|
60
|
-
// changeDetection: ChangeDetectionStrategy.OnPush, // IFF you want to optimize and control when ChangeDetection needs to happen...
|
|
61
|
-
})
|
|
62
|
-
export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
63
|
-
|
|
64
|
-
/** track list of TEMPLATE grid items so we can sync between DOM and GS internals */
|
|
65
|
-
@ContentChildren(GridstackItemComponent) public gridstackItems?: QueryList<GridstackItemComponent>;
|
|
66
|
-
/** container to append items dynamically */
|
|
67
|
-
@ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
|
|
68
|
-
|
|
69
|
-
/** initial options for creation of the grid */
|
|
70
|
-
@Input() public set options(val: GridStackOptions) { this._options = val; }
|
|
71
|
-
/** return the current running options */
|
|
72
|
-
public get options(): GridStackOptions { return this._grid?.opts || this._options || {}; }
|
|
73
|
-
|
|
74
|
-
/** true while ng-content with 'no-item-content' should be shown when last item is removed from a grid */
|
|
75
|
-
@Input() public isEmpty?: boolean;
|
|
76
|
-
|
|
77
|
-
/** individual list of GridStackEvent callbacks handlers as output
|
|
78
|
-
* otherwise use this.grid.on('name1 name2 name3', callback) to handle multiple at once
|
|
79
|
-
* see https://github.com/gridstack/gridstack.js/blob/master/demo/events.js#L4
|
|
80
|
-
*
|
|
81
|
-
* Note: camel casing and 'CB' added at the end to prevent @angular-eslint/no-output-native
|
|
82
|
-
* eg: 'change' would trigger the raw CustomEvent so use different name.
|
|
83
|
-
*/
|
|
84
|
-
@Output() public addedCB = new EventEmitter<nodesCB>();
|
|
85
|
-
@Output() public changeCB = new EventEmitter<nodesCB>();
|
|
86
|
-
@Output() public disableCB = new EventEmitter<eventCB>();
|
|
87
|
-
@Output() public dragCB = new EventEmitter<elementCB>();
|
|
88
|
-
@Output() public dragStartCB = new EventEmitter<elementCB>();
|
|
89
|
-
@Output() public dragStopCB = new EventEmitter<elementCB>();
|
|
90
|
-
@Output() public droppedCB = new EventEmitter<droppedCB>();
|
|
91
|
-
@Output() public enableCB = new EventEmitter<eventCB>();
|
|
92
|
-
@Output() public removedCB = new EventEmitter<nodesCB>();
|
|
93
|
-
@Output() public resizeCB = new EventEmitter<elementCB>();
|
|
94
|
-
@Output() public resizeStartCB = new EventEmitter<elementCB>();
|
|
95
|
-
@Output() public resizeStopCB = new EventEmitter<elementCB>();
|
|
96
|
-
|
|
97
|
-
/** return the native element that contains grid specific fields as well */
|
|
98
|
-
public get el(): GridCompHTMLElement { return this.elementRef.nativeElement; }
|
|
99
|
-
|
|
100
|
-
/** return the GridStack class */
|
|
101
|
-
public get grid(): GridStack | undefined { return this._grid; }
|
|
102
|
-
|
|
103
|
-
/** ComponentRef of ourself - used by dynamic object to correctly get removed */
|
|
104
|
-
public ref: ComponentRef<GridstackComponent> | undefined;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* stores the selector -> Type mapping, so we can create items dynamically from a string.
|
|
108
|
-
* Unfortunately Ng doesn't provide public access to that mapping.
|
|
109
|
-
*/
|
|
110
|
-
public static selectorToType: SelectorToType = {};
|
|
111
|
-
/** add a list of ng Component to be mapped to selector */
|
|
112
|
-
public static addComponentToSelectorType(typeList: Array<Type<Object>>) {
|
|
113
|
-
typeList.forEach(type => GridstackComponent.selectorToType[ GridstackComponent.getSelector(type) ] = type);
|
|
114
|
-
}
|
|
115
|
-
/** return the ng Component selector */
|
|
116
|
-
public static getSelector(type: Type<Object>): string {
|
|
117
|
-
return reflectComponentType(type)!.selector;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private _options?: GridStackOptions;
|
|
121
|
-
private _grid?: GridStack;
|
|
122
|
-
private loaded?: boolean;
|
|
123
|
-
private ngUnsubscribe: Subject<void> = new Subject();
|
|
124
|
-
|
|
125
|
-
constructor(
|
|
126
|
-
// private readonly zone: NgZone,
|
|
127
|
-
// private readonly cd: ChangeDetectorRef,
|
|
128
|
-
private readonly elementRef: ElementRef<GridCompHTMLElement>,
|
|
129
|
-
) {
|
|
130
|
-
this.el._gridComp = this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public ngOnInit(): void {
|
|
134
|
-
// init ourself before any template children are created since we track them below anyway - no need to double create+update widgets
|
|
135
|
-
this.loaded = !!this.options?.children?.length;
|
|
136
|
-
this._grid = GridStack.init(this._options, this.el);
|
|
137
|
-
delete this._options; // GS has it now
|
|
138
|
-
|
|
139
|
-
this.checkEmpty();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** wait until after all DOM is ready to init gridstack children (after angular ngFor and sub-components run first) */
|
|
143
|
-
public ngAfterContentInit(): void {
|
|
144
|
-
// track whenever the children list changes and update the layout...
|
|
145
|
-
this.gridstackItems?.changes
|
|
146
|
-
.pipe(takeUntil(this.ngUnsubscribe))
|
|
147
|
-
.subscribe(() => this.updateAll());
|
|
148
|
-
// ...and do this once at least unless we loaded children already
|
|
149
|
-
if (!this.loaded) this.updateAll();
|
|
150
|
-
this.hookEvents(this.grid);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public ngOnDestroy(): void {
|
|
154
|
-
delete this.ref;
|
|
155
|
-
this.ngUnsubscribe.next();
|
|
156
|
-
this.ngUnsubscribe.complete();
|
|
157
|
-
this.grid?.destroy();
|
|
158
|
-
delete this._grid;
|
|
159
|
-
delete this.el._gridComp;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* called when the TEMPLATE list of items changes - get a list of nodes and
|
|
164
|
-
* update the layout accordingly (which will take care of adding/removing items changed by Angular)
|
|
165
|
-
*/
|
|
166
|
-
public updateAll() {
|
|
167
|
-
if (!this.grid) return;
|
|
168
|
-
const layout: GridStackWidget[] = [];
|
|
169
|
-
this.gridstackItems?.forEach(item => {
|
|
170
|
-
layout.push(item.options);
|
|
171
|
-
item.clearOptions();
|
|
172
|
-
});
|
|
173
|
-
this.grid.load(layout); // efficient that does diffs only
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/** check if the grid is empty, if so show alternative content */
|
|
177
|
-
public checkEmpty() {
|
|
178
|
-
if (!this.grid) return;
|
|
179
|
-
const isEmpty = !this.grid.engine.nodes.length;
|
|
180
|
-
if (isEmpty === this.isEmpty) return;
|
|
181
|
-
this.isEmpty = isEmpty;
|
|
182
|
-
// this.cd.detectChanges();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** get all known events as easy to use Outputs for convenience */
|
|
186
|
-
private hookEvents(grid?: GridStack) {
|
|
187
|
-
if (!grid) return;
|
|
188
|
-
grid
|
|
189
|
-
.on('added', (event: Event, nodes: GridStackNode[]) => { this.checkEmpty(); this.addedCB.emit({event, nodes}); })
|
|
190
|
-
.on('change', (event: Event, nodes: GridStackNode[]) => this.changeCB.emit({event, nodes}))
|
|
191
|
-
.on('disable', (event: Event) => this.disableCB.emit({event}))
|
|
192
|
-
.on('drag', (event: Event, el: GridItemHTMLElement) => this.dragCB.emit({event, el}))
|
|
193
|
-
.on('dragstart', (event: Event, el: GridItemHTMLElement) => this.dragStartCB.emit({event, el}))
|
|
194
|
-
.on('dragstop', (event: Event, el: GridItemHTMLElement) => this.dragStopCB.emit({event, el}))
|
|
195
|
-
.on('dropped', (event: Event, previousNode: GridStackNode, newNode: GridStackNode) => this.droppedCB.emit({event, previousNode, newNode}))
|
|
196
|
-
.on('enable', (event: Event) => this.enableCB.emit({event}))
|
|
197
|
-
.on('removed', (event: Event, nodes: GridStackNode[]) => { this.checkEmpty(); this.removedCB.emit({event, nodes}); })
|
|
198
|
-
.on('resize', (event: Event, el: GridItemHTMLElement) => this.resizeCB.emit({event, el}))
|
|
199
|
-
.on('resizestart', (event: Event, el: GridItemHTMLElement) => this.resizeStartCB.emit({event, el}))
|
|
200
|
-
.on('resizestop', (event: Event, el: GridItemHTMLElement) => this.resizeStopCB.emit({event, el}))
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* can be used when a new item needs to be created, which we do as a Angular component, or deleted (skip)
|
|
206
|
-
**/
|
|
207
|
-
export function gsCreateNgComponents(host: GridCompHTMLElement | HTMLElement, w: NgGridStackWidget | GridStackNode, add: boolean, isGrid: boolean): HTMLElement | undefined {
|
|
208
|
-
if (add) {
|
|
209
|
-
//
|
|
210
|
-
// create the component dynamically - see https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
|
|
211
|
-
//
|
|
212
|
-
if (!host) return;
|
|
213
|
-
if (isGrid) {
|
|
214
|
-
const container = (host.parentElement as GridItemCompHTMLElement)?._gridItemComp?.container;
|
|
215
|
-
// TODO: figure out how to create ng component inside regular Div. need to access app injectors...
|
|
216
|
-
// if (!container) {
|
|
217
|
-
// const hostElement: Element = host;
|
|
218
|
-
// const environmentInjector: EnvironmentInjector;
|
|
219
|
-
// grid = createComponent(GridstackComponent, {environmentInjector, hostElement})?.instance;
|
|
220
|
-
// }
|
|
221
|
-
const gridRef = container?.createComponent(GridstackComponent);
|
|
222
|
-
const grid = gridRef?.instance;
|
|
223
|
-
if (!grid) return;
|
|
224
|
-
grid.ref = gridRef;
|
|
225
|
-
grid.options = w as GridStackOptions;
|
|
226
|
-
return grid.el;
|
|
227
|
-
} else {
|
|
228
|
-
const gridComp = (host as GridCompHTMLElement)._gridComp;
|
|
229
|
-
const gridItemRef = gridComp?.container?.createComponent(GridstackItemComponent);
|
|
230
|
-
const gridItem = gridItemRef?.instance;
|
|
231
|
-
if (!gridItem) return;
|
|
232
|
-
gridItem.ref = gridItemRef
|
|
233
|
-
|
|
234
|
-
// IFF we're not a subGrid, define what type of component to create as child, OR you can do it GridstackItemComponent template, but this is more generic
|
|
235
|
-
const selector = (w as NgGridStackWidget).selector;
|
|
236
|
-
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
|
|
237
|
-
if (!w.subGridOpts && type) {
|
|
238
|
-
const childWidget = gridItem.container?.createComponent(type)?.instance as BaseWidget;
|
|
239
|
-
if (typeof childWidget?.serialize === 'function' && typeof childWidget?.deserialize === 'function') {
|
|
240
|
-
// proper BaseWidget subclass, save it and load additional data
|
|
241
|
-
gridItem.childWidget = childWidget;
|
|
242
|
-
childWidget.deserialize(w);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return gridItem.el;
|
|
247
|
-
}
|
|
248
|
-
} else {
|
|
249
|
-
//
|
|
250
|
-
// REMOVE - have to call ComponentRef:destroy() for dynamic objects to correctly remove themselves
|
|
251
|
-
// Note: this will destroy all children dynamic components as well: gridItem -> childWidget
|
|
252
|
-
//
|
|
253
|
-
const n = w as GridStackNode;
|
|
254
|
-
if (isGrid) {
|
|
255
|
-
const grid = (n.el as GridCompHTMLElement)?._gridComp;
|
|
256
|
-
if (grid?.ref) grid.ref.destroy();
|
|
257
|
-
else grid?.ngOnDestroy();
|
|
258
|
-
} else {
|
|
259
|
-
const gridItem = (n.el as GridItemCompHTMLElement)?._gridItemComp;
|
|
260
|
-
if (gridItem?.ref) gridItem.ref.destroy();
|
|
261
|
-
else gridItem?.ngOnDestroy();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* called for each item in the grid - check if additional information needs to be saved.
|
|
269
|
-
* Note: since this is options minus gridstack private members using Utils.removeInternalForSave(),
|
|
270
|
-
* this typically doesn't need to do anything. However your custom Component @Input() are now supported
|
|
271
|
-
* using BaseWidget.serialize()
|
|
272
|
-
*/
|
|
273
|
-
export function gsSaveAdditionalNgInfo(n: NgGridStackNode, w: NgGridStackWidget) {
|
|
274
|
-
const gridItem = (n.el as GridItemCompHTMLElement)?._gridItemComp;
|
|
275
|
-
if (gridItem) {
|
|
276
|
-
const input = gridItem.childWidget?.serialize();
|
|
277
|
-
if (input) {
|
|
278
|
-
w.input = input;
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
// else check if Grid
|
|
283
|
-
const grid = (n.el as GridCompHTMLElement)?._gridComp;
|
|
284
|
-
if (grid) {
|
|
285
|
-
//.... save any custom data
|
|
286
|
-
}
|
|
287
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack.component.ts 10.1.1
|
|
3
|
-
* Copyright (c) 2022 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { NgModule } from "@angular/core";
|
|
7
|
-
import { CommonModule } from '@angular/common';
|
|
8
|
-
|
|
9
|
-
import { GridStack } from "gridstack";
|
|
10
|
-
import { GridstackComponent, gsCreateNgComponents, gsSaveAdditionalNgInfo } from "./gridstack.component";
|
|
11
|
-
import { GridstackItemComponent } from "./gridstack-item.component";
|
|
12
|
-
|
|
13
|
-
@NgModule({
|
|
14
|
-
imports: [
|
|
15
|
-
CommonModule,
|
|
16
|
-
],
|
|
17
|
-
declarations: [
|
|
18
|
-
GridstackComponent,
|
|
19
|
-
GridstackItemComponent,
|
|
20
|
-
],
|
|
21
|
-
exports: [
|
|
22
|
-
GridstackComponent,
|
|
23
|
-
GridstackItemComponent,
|
|
24
|
-
],
|
|
25
|
-
})
|
|
26
|
-
export class GridstackModule {
|
|
27
|
-
constructor() {
|
|
28
|
-
// set globally our method to create the right widget type
|
|
29
|
-
GridStack.addRemoveCB = gsCreateNgComponents;
|
|
30
|
-
GridStack.saveCB = gsSaveAdditionalNgInfo;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* default to generate [2-11] columns as 1 (oneColumnMode) and 12 (default) are in the main css
|
|
3
|
-
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
$start: 2 !default;
|
|
6
|
-
$end: 11 !default;
|
|
7
|
-
|
|
8
|
-
@function fixed($float) {
|
|
9
|
-
@return calc(round($float * 1000) / 1000); // total 4-5 digits being %
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@mixin grid-stack-items($columns) {
|
|
13
|
-
.gs-#{$columns} > .grid-stack-item {
|
|
14
|
-
width: fixed(calc(100% / $columns));
|
|
15
|
-
|
|
16
|
-
@for $i from 1 through $columns - 1 {
|
|
17
|
-
&[gs-x='#{$i}'] { left: fixed(calc(100% / $columns) * $i); }
|
|
18
|
-
&[gs-w='#{$i+1}'] { width: fixed(calc(100% / $columns) * ($i+1)); }
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@for $j from $start through $end {
|
|
24
|
-
@include grid-stack-items($j)
|
|
25
|
-
}
|
package/dist/src/gridstack.scss
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* gridstack SASS styles 10.1.1
|
|
3
|
-
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
$columns: 12 !default;
|
|
7
|
-
$animation_speed: .3s !default;
|
|
8
|
-
|
|
9
|
-
@function fixed($float) {
|
|
10
|
-
@return calc(round($float * 1000) / 1000); // total 4-5 digits being %
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@mixin vendor($property, $value...){
|
|
14
|
-
// -webkit-#{$property}: $value;
|
|
15
|
-
// -moz-#{$property}: $value;
|
|
16
|
-
// -ms-#{$property}: $value;
|
|
17
|
-
// -o-#{$property}: $value;
|
|
18
|
-
#{$property}: $value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.grid-stack {
|
|
22
|
-
position: relative;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.grid-stack-rtl {
|
|
26
|
-
direction: ltr;
|
|
27
|
-
> .grid-stack-item {
|
|
28
|
-
direction: rtl;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.grid-stack-placeholder > .placeholder-content {
|
|
33
|
-
background-color: rgba(0,0,0,0.1);
|
|
34
|
-
margin: 0;
|
|
35
|
-
position: absolute;
|
|
36
|
-
width: auto;
|
|
37
|
-
z-index: 0 !important;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// make those more unique as to not conflict with side panel items
|
|
41
|
-
.grid-stack > .grid-stack-item {
|
|
42
|
-
position: absolute;
|
|
43
|
-
padding: 0;
|
|
44
|
-
|
|
45
|
-
> .grid-stack-item-content {
|
|
46
|
-
margin: 0;
|
|
47
|
-
position: absolute;
|
|
48
|
-
width: auto;
|
|
49
|
-
overflow-x: hidden;
|
|
50
|
-
overflow-y: auto;
|
|
51
|
-
}
|
|
52
|
-
&.size-to-content:not(.size-to-content-max) > .grid-stack-item-content {
|
|
53
|
-
overflow-y: hidden;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.grid-stack-item {
|
|
58
|
-
> .ui-resizable-handle {
|
|
59
|
-
position: absolute;
|
|
60
|
-
font-size: 0.1px;
|
|
61
|
-
display: block;
|
|
62
|
-
-ms-touch-action: none;
|
|
63
|
-
touch-action: none;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&.ui-resizable-disabled > .ui-resizable-handle,
|
|
67
|
-
&.ui-resizable-autohide > .ui-resizable-handle { display: none; }
|
|
68
|
-
|
|
69
|
-
> .ui-resizable-ne,
|
|
70
|
-
> .ui-resizable-nw,
|
|
71
|
-
> .ui-resizable-se,
|
|
72
|
-
> .ui-resizable-sw {
|
|
73
|
-
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="%23666" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 20 20"><path d="m10 3 2 2H8l2-2v14l-2-2h4l-2 2"/></svg>');
|
|
74
|
-
background-repeat: no-repeat;
|
|
75
|
-
background-position: center;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
> .ui-resizable-ne {
|
|
79
|
-
@include vendor(transform, translate(0, 10px) rotate(45deg));
|
|
80
|
-
}
|
|
81
|
-
> .ui-resizable-sw {
|
|
82
|
-
@include vendor(transform, rotate(45deg));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
> .ui-resizable-nw {
|
|
86
|
-
@include vendor(transform, translate(0, 10px) rotate(-45deg));
|
|
87
|
-
}
|
|
88
|
-
> .ui-resizable-se {
|
|
89
|
-
@include vendor(transform, rotate(-45deg));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
> .ui-resizable-nw { cursor: nw-resize; width: 20px; height: 20px; top: 0; }
|
|
93
|
-
> .ui-resizable-n { cursor: n-resize; height: 10px; top: 0; left: 25px; right: 25px; }
|
|
94
|
-
> .ui-resizable-ne { cursor: ne-resize; width: 20px; height: 20px; top: 0; }
|
|
95
|
-
> .ui-resizable-e { cursor: e-resize; width: 10px; top: 15px; bottom: 15px; }
|
|
96
|
-
> .ui-resizable-se { cursor: se-resize; width: 20px; height: 20px;}
|
|
97
|
-
> .ui-resizable-s { cursor: s-resize; height: 10px; left: 25px; bottom: 0; right: 25px; }
|
|
98
|
-
> .ui-resizable-sw { cursor: sw-resize; width: 20px; height: 20px;}
|
|
99
|
-
> .ui-resizable-w { cursor: w-resize; width: 10px; top: 15px; bottom: 15px; }
|
|
100
|
-
|
|
101
|
-
&.ui-draggable-dragging {
|
|
102
|
-
&> .ui-resizable-handle {
|
|
103
|
-
display: none !important;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&.ui-draggable-dragging {
|
|
108
|
-
will-change: left, top;
|
|
109
|
-
cursor: move;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&.ui-resizable-resizing {
|
|
113
|
-
will-change: width, height;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// not .grid-stack-item specific to also affect dragIn regions
|
|
118
|
-
.ui-draggable-dragging,
|
|
119
|
-
.ui-resizable-resizing {
|
|
120
|
-
z-index: 10000; // bootstrap modal has a z-index of 1050
|
|
121
|
-
|
|
122
|
-
> .grid-stack-item-content {
|
|
123
|
-
box-shadow: 1px 4px 6px rgba(0, 0, 0, 0.2);
|
|
124
|
-
opacity: 0.8;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.grid-stack-animate,
|
|
129
|
-
.grid-stack-animate .grid-stack-item {
|
|
130
|
-
@include vendor(transition, left $animation_speed, top $animation_speed, height $animation_speed, width $animation_speed);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.grid-stack-animate .grid-stack-item.ui-draggable-dragging,
|
|
134
|
-
.grid-stack-animate .grid-stack-item.ui-resizable-resizing,
|
|
135
|
-
.grid-stack-animate .grid-stack-item.grid-stack-placeholder{
|
|
136
|
-
@include vendor(transition, left 0s, top 0s, height 0s, width 0s);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// make those more unique as to not conflict with side panel items, but apply to all column layouts (so not in loop below)
|
|
140
|
-
.grid-stack > .grid-stack-item[gs-y="0"] {
|
|
141
|
-
top: 0px;
|
|
142
|
-
}
|
|
143
|
-
.grid-stack > .grid-stack-item[gs-x="0"] {
|
|
144
|
-
left: 0%;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.gs-#{$columns} > .grid-stack-item {
|
|
148
|
-
width: fixed(calc(100% / $columns));
|
|
149
|
-
@for $i from 1 through ($columns - 1) {
|
|
150
|
-
&[gs-x='#{$i}'] { left: fixed(calc(100% / $columns) * $i); }
|
|
151
|
-
&[gs-w='#{$i + 1}'] { width: fixed(calc(100% / $columns) * ($i + 1)); }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.gs-1 > .grid-stack-item {
|
|
156
|
-
width: 100%;
|
|
157
|
-
}
|