igniteui-webcomponents 5.2.0 → 5.3.0-alpha.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/components/carousel/carousel-indicator.js +1 -1
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.js +1 -1
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.js +1 -1
- package/components/carousel/carousel.js.map +1 -1
- package/components/common/context.d.ts +22 -0
- package/components/common/context.js +6 -0
- package/components/common/context.js.map +1 -0
- package/components/common/util.d.ts +1 -0
- package/components/common/util.js +8 -0
- package/components/common/util.js.map +1 -1
- package/components/icon/icon-references.js +46 -0
- package/components/icon/icon-references.js.map +1 -1
- package/components/icon/internal-icons-lib.js +47 -0
- package/components/icon/internal-icons-lib.js.map +1 -1
- package/components/tile-manager/controllers/fullscreen.d.ts +15 -0
- package/components/tile-manager/controllers/fullscreen.js +43 -0
- package/components/tile-manager/controllers/fullscreen.js.map +1 -0
- package/components/tile-manager/controllers/tile-dnd.d.ts +24 -0
- package/components/tile-manager/controllers/tile-dnd.js +46 -0
- package/components/tile-manager/controllers/tile-dnd.js.map +1 -0
- package/components/tile-manager/position.d.ts +20 -0
- package/components/tile-manager/position.js +61 -0
- package/components/tile-manager/position.js.map +1 -0
- package/components/tile-manager/resize-controller.d.ts +52 -0
- package/components/tile-manager/resize-controller.js +157 -0
- package/components/tile-manager/resize-controller.js.map +1 -0
- package/components/tile-manager/resize-element.d.ts +41 -0
- package/components/tile-manager/resize-element.js +107 -0
- package/components/tile-manager/resize-element.js.map +1 -0
- package/components/tile-manager/serializer.d.ts +24 -0
- package/components/tile-manager/serializer.js +52 -0
- package/components/tile-manager/serializer.js.map +1 -0
- package/components/tile-manager/themes/container.d.ts +2 -0
- package/components/tile-manager/themes/container.js +47 -0
- package/components/tile-manager/themes/container.js.map +1 -0
- package/components/tile-manager/themes/dark/tile-manager.bootstrap.css.d.ts +1 -0
- package/components/tile-manager/themes/dark/tile-manager.bootstrap.css.js +3 -0
- package/components/tile-manager/themes/dark/tile-manager.bootstrap.css.js.map +1 -0
- package/components/tile-manager/themes/dark/tile-manager.fluent.css.d.ts +1 -0
- package/components/tile-manager/themes/dark/tile-manager.fluent.css.js +3 -0
- package/components/tile-manager/themes/dark/tile-manager.fluent.css.js.map +1 -0
- package/components/tile-manager/themes/dark/tile-manager.indigo.css.d.ts +1 -0
- package/components/tile-manager/themes/dark/tile-manager.indigo.css.js +3 -0
- package/components/tile-manager/themes/dark/tile-manager.indigo.css.js.map +1 -0
- package/components/tile-manager/themes/dark/tile-manager.material.css.d.ts +1 -0
- package/components/tile-manager/themes/dark/tile-manager.material.css.js +3 -0
- package/components/tile-manager/themes/dark/tile-manager.material.css.js.map +1 -0
- package/components/tile-manager/themes/dark/tile-manager.shared.css.d.ts +1 -0
- package/components/tile-manager/themes/dark/tile-manager.shared.css.js +3 -0
- package/components/tile-manager/themes/dark/tile-manager.shared.css.js.map +1 -0
- package/components/tile-manager/themes/header.d.ts +2 -0
- package/components/tile-manager/themes/header.js +28 -0
- package/components/tile-manager/themes/header.js.map +1 -0
- package/components/tile-manager/themes/light/tile-manager.bootstrap.css.d.ts +1 -0
- package/components/tile-manager/themes/light/tile-manager.bootstrap.css.js +3 -0
- package/components/tile-manager/themes/light/tile-manager.bootstrap.css.js.map +1 -0
- package/components/tile-manager/themes/light/tile-manager.fluent.css.d.ts +1 -0
- package/components/tile-manager/themes/light/tile-manager.fluent.css.js +3 -0
- package/components/tile-manager/themes/light/tile-manager.fluent.css.js.map +1 -0
- package/components/tile-manager/themes/light/tile-manager.indigo.css.d.ts +1 -0
- package/components/tile-manager/themes/light/tile-manager.indigo.css.js +3 -0
- package/components/tile-manager/themes/light/tile-manager.indigo.css.js.map +1 -0
- package/components/tile-manager/themes/light/tile-manager.material.css.d.ts +1 -0
- package/components/tile-manager/themes/light/tile-manager.material.css.js +3 -0
- package/components/tile-manager/themes/light/tile-manager.material.css.js.map +1 -0
- package/components/tile-manager/themes/light/tile-manager.shared.css.d.ts +1 -0
- package/components/tile-manager/themes/light/tile-manager.shared.css.js +3 -0
- package/components/tile-manager/themes/light/tile-manager.shared.css.js.map +1 -0
- package/components/tile-manager/themes/resize.base.css.d.ts +1 -0
- package/components/tile-manager/themes/resize.base.css.js +3 -0
- package/components/tile-manager/themes/resize.base.css.js.map +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.bootstrap.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.bootstrap.css.js +3 -0
- package/components/tile-manager/themes/shared/header/tile-header.bootstrap.css.js.map +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.common.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.common.css.js +3 -0
- package/components/tile-manager/themes/shared/header/tile-header.common.css.js.map +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.fluent.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.fluent.css.js +3 -0
- package/components/tile-manager/themes/shared/header/tile-header.fluent.css.js.map +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.indigo.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/header/tile-header.indigo.css.js +3 -0
- package/components/tile-manager/themes/shared/header/tile-header.indigo.css.js.map +1 -0
- package/components/tile-manager/themes/shared/resize.common.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/resize.common.css.js +3 -0
- package/components/tile-manager/themes/shared/resize.common.css.js.map +1 -0
- package/components/tile-manager/themes/shared/tile/tile.common.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/tile/tile.common.css.js +3 -0
- package/components/tile-manager/themes/shared/tile/tile.common.css.js.map +1 -0
- package/components/tile-manager/themes/shared/tile/tile.indigo.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/tile/tile.indigo.css.js +3 -0
- package/components/tile-manager/themes/shared/tile/tile.indigo.css.js.map +1 -0
- package/components/tile-manager/themes/shared/tile-manager.common.css.d.ts +1 -0
- package/components/tile-manager/themes/shared/tile-manager.common.css.js +3 -0
- package/components/tile-manager/themes/shared/tile-manager.common.css.js.map +1 -0
- package/components/tile-manager/themes/tile-header.base.css.d.ts +1 -0
- package/components/tile-manager/themes/tile-header.base.css.js +3 -0
- package/components/tile-manager/themes/tile-header.base.css.js.map +1 -0
- package/components/tile-manager/themes/tile-manager.base.css.d.ts +1 -0
- package/components/tile-manager/themes/tile-manager.base.css.js +3 -0
- package/components/tile-manager/themes/tile-manager.base.css.js.map +1 -0
- package/components/tile-manager/themes/tile.base.css.d.ts +1 -0
- package/components/tile-manager/themes/tile.base.css.js +3 -0
- package/components/tile-manager/themes/tile.base.css.js.map +1 -0
- package/components/tile-manager/themes/tile.d.ts +2 -0
- package/components/tile-manager/themes/tile.js +14 -0
- package/components/tile-manager/themes/tile.js.map +1 -0
- package/components/tile-manager/tile-header.d.ts +34 -0
- package/components/tile-manager/tile-header.js +106 -0
- package/components/tile-manager/tile-header.js.map +1 -0
- package/components/tile-manager/tile-manager.d.ts +83 -0
- package/components/tile-manager/tile-manager.js +188 -0
- package/components/tile-manager/tile-manager.js.map +1 -0
- package/components/tile-manager/tile-util.d.ts +6 -0
- package/components/tile-manager/tile-util.js +70 -0
- package/components/tile-manager/tile-util.js.map +1 -0
- package/components/tile-manager/tile.d.ts +128 -0
- package/components/tile-manager/tile.js +467 -0
- package/components/tile-manager/tile.js.map +1 -0
- package/custom-elements.json +5623 -3417
- package/igniteui-webcomponents.css-data.json +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/web-types.json +2 -2
- package/components/carousel/context.d.ts +0 -4
- package/components/carousel/context.js +0 -3
- package/components/carousel/context.js.map +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var IgcTileManagerComponent_1;
|
|
8
|
+
import { ContextProvider } from '@lit/context';
|
|
9
|
+
import { LitElement, html } from 'lit';
|
|
10
|
+
import { property } from 'lit/decorators.js';
|
|
11
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
|
+
import { themes } from '../../theming/theming-decorator.js';
|
|
13
|
+
import { tileManagerContext } from '../common/context.js';
|
|
14
|
+
import { createMutationController, } from '../common/controllers/mutation-observer.js';
|
|
15
|
+
import { registerComponent } from '../common/definitions/register.js';
|
|
16
|
+
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
|
|
17
|
+
import { asNumber, findElementFromEventPath, partNameMap, } from '../common/util.js';
|
|
18
|
+
import { createTilesState, isSameTile, swapTiles } from './position.js';
|
|
19
|
+
import { createSerializer } from './serializer.js';
|
|
20
|
+
import { all } from './themes/container.js';
|
|
21
|
+
import { styles as shared } from './themes/shared/tile-manager.common.css.js';
|
|
22
|
+
import { styles } from './themes/tile-manager.base.css.js';
|
|
23
|
+
import IgcTileComponent from './tile.js';
|
|
24
|
+
let IgcTileManagerComponent = IgcTileManagerComponent_1 = class IgcTileManagerComponent extends EventEmitterMixin(LitElement) {
|
|
25
|
+
static register() {
|
|
26
|
+
registerComponent(IgcTileManagerComponent_1, IgcTileComponent);
|
|
27
|
+
}
|
|
28
|
+
_setManagerContext() {
|
|
29
|
+
this._context.setValue({
|
|
30
|
+
instance: this,
|
|
31
|
+
draggedItem: this._draggedItem,
|
|
32
|
+
lastSwapTile: this._lastSwapTile,
|
|
33
|
+
}, true);
|
|
34
|
+
}
|
|
35
|
+
_observerCallback({ changes: { added, removed }, }) {
|
|
36
|
+
const ownAdded = added.filter(({ target }) => target.closest(this.tagName) === this);
|
|
37
|
+
const ownRemoved = removed.filter(({ target }) => target.closest(this.tagName) === this);
|
|
38
|
+
for (const remove of ownRemoved) {
|
|
39
|
+
this._tilesState.remove(remove.node);
|
|
40
|
+
}
|
|
41
|
+
for (const added of ownAdded) {
|
|
42
|
+
this._tilesState.add(added.node);
|
|
43
|
+
}
|
|
44
|
+
this._tilesState.assignTiles();
|
|
45
|
+
}
|
|
46
|
+
set columnCount(value) {
|
|
47
|
+
this._columnCount = Math.max(0, asNumber(value));
|
|
48
|
+
Object.assign(this._internalStyles, {
|
|
49
|
+
'--ig-column-count': this._columnCount || undefined,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
get columnCount() {
|
|
53
|
+
return this._columnCount;
|
|
54
|
+
}
|
|
55
|
+
set minColumnWidth(value) {
|
|
56
|
+
this._minColWidth = value ?? undefined;
|
|
57
|
+
Object.assign(this._internalStyles, {
|
|
58
|
+
'--ig-min-col-width': this._minColWidth,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
get minColumnWidth() {
|
|
62
|
+
return this._minColWidth;
|
|
63
|
+
}
|
|
64
|
+
set minRowHeight(value) {
|
|
65
|
+
this._minRowHeight = value ?? undefined;
|
|
66
|
+
Object.assign(this._internalStyles, {
|
|
67
|
+
'--ig-min-row-height': this._minRowHeight,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
get minRowHeight() {
|
|
71
|
+
return this._minRowHeight;
|
|
72
|
+
}
|
|
73
|
+
set gap(value) {
|
|
74
|
+
this._gap = value ?? undefined;
|
|
75
|
+
Object.assign(this._internalStyles, {
|
|
76
|
+
'--ig-gap': this._gap,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
get gap() {
|
|
80
|
+
return this._gap;
|
|
81
|
+
}
|
|
82
|
+
get tiles() {
|
|
83
|
+
return this._tilesState.tiles;
|
|
84
|
+
}
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
this._internalStyles = {};
|
|
88
|
+
this._columnCount = 0;
|
|
89
|
+
this._draggedItem = null;
|
|
90
|
+
this._lastSwapTile = null;
|
|
91
|
+
this._serializer = createSerializer(this);
|
|
92
|
+
this._tilesState = createTilesState(this);
|
|
93
|
+
this._context = new ContextProvider(this, {
|
|
94
|
+
context: tileManagerContext,
|
|
95
|
+
initialValue: {
|
|
96
|
+
instance: this,
|
|
97
|
+
draggedItem: this._draggedItem,
|
|
98
|
+
lastSwapTile: this._lastSwapTile,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
this.dragMode = 'slide';
|
|
102
|
+
createMutationController(this, {
|
|
103
|
+
callback: this._observerCallback,
|
|
104
|
+
filter: [IgcTileComponent.tagName],
|
|
105
|
+
config: {
|
|
106
|
+
childList: true,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
firstUpdated() {
|
|
111
|
+
this._tilesState.assignPositions();
|
|
112
|
+
this._tilesState.assignTiles();
|
|
113
|
+
}
|
|
114
|
+
handleTileDragStart({ detail }) {
|
|
115
|
+
this.emitEvent('igcTileDragStarted', { detail });
|
|
116
|
+
this._draggedItem = detail;
|
|
117
|
+
this._setManagerContext();
|
|
118
|
+
}
|
|
119
|
+
handleTileDragEnd() {
|
|
120
|
+
if (this._draggedItem) {
|
|
121
|
+
this._draggedItem = null;
|
|
122
|
+
this._setManagerContext();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
handleDragOver(event) {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
}
|
|
128
|
+
handleDrop(event) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
const draggedItem = this._draggedItem;
|
|
131
|
+
const target = findElementFromEventPath(IgcTileComponent.tagName, event);
|
|
132
|
+
if (!isSameTile(draggedItem, target) &&
|
|
133
|
+
this.dragMode === 'swap' &&
|
|
134
|
+
!target?.disableDrag) {
|
|
135
|
+
swapTiles(draggedItem, target);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
saveLayout() {
|
|
139
|
+
return this._serializer.saveAsJSON();
|
|
140
|
+
}
|
|
141
|
+
loadLayout(data) {
|
|
142
|
+
this._serializer.loadFromJSON(data);
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
const parts = partNameMap({
|
|
146
|
+
base: true,
|
|
147
|
+
'maximized-tile': this.tiles.some((tile) => tile.maximized),
|
|
148
|
+
});
|
|
149
|
+
return html `
|
|
150
|
+
<div
|
|
151
|
+
style=${styleMap(this._internalStyles)}
|
|
152
|
+
part=${parts}
|
|
153
|
+
@tileDragStart=${this.handleTileDragStart}
|
|
154
|
+
@tileDragEnd=${this.handleTileDragEnd}
|
|
155
|
+
@dragover=${this.handleDragOver}
|
|
156
|
+
@drop=${this.handleDrop}
|
|
157
|
+
>
|
|
158
|
+
<slot></slot>
|
|
159
|
+
</div>
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
IgcTileManagerComponent.tagName = 'igc-tile-manager';
|
|
164
|
+
IgcTileManagerComponent.styles = [styles, shared];
|
|
165
|
+
IgcTileManagerComponent.shadowRootOptions = {
|
|
166
|
+
mode: 'open',
|
|
167
|
+
slotAssignment: 'manual',
|
|
168
|
+
};
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ attribute: 'drag-mode' })
|
|
171
|
+
], IgcTileManagerComponent.prototype, "dragMode", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
property({ type: Number, attribute: 'column-count' })
|
|
174
|
+
], IgcTileManagerComponent.prototype, "columnCount", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
property({ attribute: 'min-column-width' })
|
|
177
|
+
], IgcTileManagerComponent.prototype, "minColumnWidth", null);
|
|
178
|
+
__decorate([
|
|
179
|
+
property({ attribute: 'min-row-height' })
|
|
180
|
+
], IgcTileManagerComponent.prototype, "minRowHeight", null);
|
|
181
|
+
__decorate([
|
|
182
|
+
property()
|
|
183
|
+
], IgcTileManagerComponent.prototype, "gap", null);
|
|
184
|
+
IgcTileManagerComponent = IgcTileManagerComponent_1 = __decorate([
|
|
185
|
+
themes(all)
|
|
186
|
+
], IgcTileManagerComponent);
|
|
187
|
+
export default IgcTileManagerComponent;
|
|
188
|
+
//# sourceMappingURL=tile-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-manager.js","sourceRoot":"","sources":["../../../src/components/tile-manager/tile-manager.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAkB,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAEL,wBAAwB,GACzB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EACL,QAAQ,EACR,wBAAwB,EACxB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;0DAMrD;AAWD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;6DAM3C;AAWD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;2DAMzC;AAUD;IADC,QAAQ,EAAE;kDAMV;AAzIkB,uBAAuB;IAD3C,MAAM,CAAC,GAAG,CAAC;GACS,uBAAuB,CAsO3C;eAtOoB,uBAAuB","sourcesContent":["import { ContextProvider } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { type StyleInfo, styleMap } from 'lit/directives/style-map.js';\nimport { themes } from '../../theming/theming-decorator.js';\nimport { tileManagerContext } from '../common/context.js';\nimport {\n type MutationControllerParams,\n createMutationController,\n} from '../common/controllers/mutation-observer.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport type { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport {\n asNumber,\n findElementFromEventPath,\n partNameMap,\n} from '../common/util.js';\nimport { createTilesState, isSameTile, swapTiles } from './position.js';\nimport { createSerializer } from './serializer.js';\nimport { all } from './themes/container.js';\nimport { styles as shared } from './themes/shared/tile-manager.common.css.js';\nimport { styles } from './themes/tile-manager.base.css.js';\nimport IgcTileComponent from './tile.js';\n\n// REVIEW: WIP\nexport interface IgcTileManagerComponentEventMap {\n igcTileDragStarted: CustomEvent<IgcTileComponent>;\n}\n\n/**\n * The tile manager component enables the dynamic arrangement, resizing, and interaction of tiles.\n *\n * @element igc-tile-manager\n *\n * @fires igcTileDragStarted - Fired when an owning tile begins a drag operation.\n */\n@themes(all)\nexport default class IgcTileManagerComponent extends EventEmitterMixin<\n IgcTileManagerComponentEventMap,\n Constructor<LitElement>\n>(LitElement) {\n public static readonly tagName = 'igc-tile-manager';\n public static styles = [styles, shared];\n\n protected static shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n slotAssignment: 'manual',\n };\n\n /* blazorSuppress */\n public static register() {\n registerComponent(IgcTileManagerComponent, IgcTileComponent);\n }\n\n private _internalStyles: StyleInfo = {};\n\n private _columnCount = 0;\n private _gap?: string;\n private _minColWidth?: string;\n private _minRowHeight?: string;\n private _draggedItem: IgcTileComponent | null = null;\n private _lastSwapTile: IgcTileComponent | null = null;\n\n private _serializer = createSerializer(this);\n private _tilesState = createTilesState(this);\n\n private _context = new ContextProvider(this, {\n context: tileManagerContext,\n initialValue: {\n instance: this,\n draggedItem: this._draggedItem,\n lastSwapTile: this._lastSwapTile,\n },\n });\n\n private _setManagerContext() {\n this._context.setValue(\n {\n instance: this,\n draggedItem: this._draggedItem,\n lastSwapTile: this._lastSwapTile,\n },\n true\n );\n }\n\n private _observerCallback({\n changes: { added, removed },\n }: MutationControllerParams<IgcTileComponent>) {\n const ownAdded = added.filter(\n ({ target }) => target.closest(this.tagName) === this\n );\n const ownRemoved = removed.filter(\n ({ target }) => target.closest(this.tagName) === this\n );\n\n for (const remove of ownRemoved) {\n this._tilesState.remove(remove.node);\n }\n\n for (const added of ownAdded) {\n this._tilesState.add(added.node);\n }\n\n this._tilesState.assignTiles();\n }\n\n /**\n * Determines whether the tiles slide or swap on drop.\n * @attr drag-mode\n */\n @property({ attribute: 'drag-mode' })\n public dragMode: 'slide' | 'swap' = 'slide';\n\n /**\n * Sets the number of columns for the tile manager.\n * Setting value <= than zero will trigger a responsive layout.\n *\n * @attr column-count\n * @default 0\n */\n @property({ type: Number, attribute: 'column-count' })\n public set columnCount(value: number) {\n this._columnCount = Math.max(0, asNumber(value));\n Object.assign(this._internalStyles, {\n '--ig-column-count': this._columnCount || undefined,\n });\n }\n\n public get columnCount(): number {\n return this._columnCount;\n }\n\n /**\n * Sets the minimum width for a column unit in the tile manager.\n * @attr min-column-width\n */\n @property({ attribute: 'min-column-width' })\n public set minColumnWidth(value: string | undefined) {\n this._minColWidth = value ?? undefined;\n Object.assign(this._internalStyles, {\n '--ig-min-col-width': this._minColWidth,\n });\n }\n\n public get minColumnWidth(): string | undefined {\n return this._minColWidth;\n }\n\n /**\n * Sets the minimum height for a row unit in the tile manager.\n * @attr min-row-height\n */\n @property({ attribute: 'min-row-height' })\n public set minRowHeight(value: string | undefined) {\n this._minRowHeight = value ?? undefined;\n Object.assign(this._internalStyles, {\n '--ig-min-row-height': this._minRowHeight,\n });\n }\n\n public get minRowHeight(): string | undefined {\n return this._minRowHeight;\n }\n\n /**\n * Sets the gap size of the the tile manager.\n */\n @property()\n public set gap(value: string | undefined) {\n this._gap = value ?? undefined;\n Object.assign(this._internalStyles, {\n '--ig-gap': this._gap,\n });\n }\n\n public get gap(): string | undefined {\n return this._gap;\n }\n\n /**\n * Gets the tiles sorted by their position in the layout.\n * @attr\n */\n public get tiles() {\n return this._tilesState.tiles;\n }\n\n constructor() {\n super();\n\n createMutationController(this, {\n callback: this._observerCallback,\n filter: [IgcTileComponent.tagName],\n config: {\n childList: true,\n },\n });\n }\n\n protected override firstUpdated() {\n this._tilesState.assignPositions();\n this._tilesState.assignTiles();\n }\n\n private handleTileDragStart({ detail }: CustomEvent<IgcTileComponent>) {\n this.emitEvent('igcTileDragStarted', { detail });\n this._draggedItem = detail;\n this._setManagerContext();\n }\n\n private handleTileDragEnd() {\n if (this._draggedItem) {\n this._draggedItem = null;\n this._setManagerContext();\n }\n }\n\n private handleDragOver(event: DragEvent) {\n event.preventDefault(); // Allow dropping\n }\n\n private handleDrop(event: DragEvent) {\n event.preventDefault();\n\n const draggedItem = this._draggedItem;\n const target = findElementFromEventPath<IgcTileComponent>(\n IgcTileComponent.tagName,\n event\n );\n\n if (\n !isSameTile(draggedItem, target) &&\n this.dragMode === 'swap' &&\n !target?.disableDrag\n ) {\n swapTiles(draggedItem!, target!);\n }\n }\n\n public saveLayout(): string {\n return this._serializer.saveAsJSON();\n }\n\n public loadLayout(data: string): void {\n this._serializer.loadFromJSON(data);\n }\n\n protected override render() {\n const parts = partNameMap({\n base: true,\n 'maximized-tile': this.tiles.some((tile) => tile.maximized),\n });\n\n return html`\n <div\n style=${styleMap(this._internalStyles)}\n part=${parts}\n @tileDragStart=${this.handleTileDragStart}\n @tileDragEnd=${this.handleTileDragEnd}\n @dragover=${this.handleDragOver}\n @drop=${this.handleDrop}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-tile-manager': IgcTileManagerComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class ResizeUtil {
|
|
2
|
+
static calculateSnappedHeight(deltaY: number, startingY: number, rowHeights: number[], rowGap: number, initialTop: number, initialHeight: number): number;
|
|
3
|
+
static calculateSnappedWidth(deltaX: number, initialWidth: number, gap: number, gridColumnWidth: number): number;
|
|
4
|
+
static calculate(initialTop: number, rowHeights: number[], rowGap: number): any;
|
|
5
|
+
private static accumulateHeight;
|
|
6
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export class ResizeUtil {
|
|
2
|
+
static calculateSnappedHeight(deltaY, startingY, rowHeights, rowGap, initialTop, initialHeight) {
|
|
3
|
+
const snappedHeight = startingY + deltaY;
|
|
4
|
+
const rowsAbove = ResizeUtil.calculate(initialTop, rowHeights, rowGap).targetIndex || 0;
|
|
5
|
+
const res = ResizeUtil.calculate(snappedHeight, rowHeights, rowGap);
|
|
6
|
+
const accumulatedHeight = res.accumulatedHeight;
|
|
7
|
+
const startRowIndex = res.targetIndex;
|
|
8
|
+
const aboveRowsHeight = ResizeUtil.accumulateHeight(rowsAbove, rowHeights, rowGap);
|
|
9
|
+
let result = initialHeight;
|
|
10
|
+
let previousRowsHeight = ResizeUtil.accumulateHeight(startRowIndex, rowHeights, rowGap);
|
|
11
|
+
if (deltaY > 0) {
|
|
12
|
+
const rowHeight = rowHeights[startRowIndex];
|
|
13
|
+
const halfwayThreshold = previousRowsHeight + rowGap + rowHeight / 2;
|
|
14
|
+
if (snappedHeight >= halfwayThreshold) {
|
|
15
|
+
result = accumulatedHeight - aboveRowsHeight;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
result = initialHeight + deltaY;
|
|
19
|
+
}
|
|
20
|
+
result = result <= 0 ? rowHeights[startRowIndex - 1] : result;
|
|
21
|
+
}
|
|
22
|
+
else if (deltaY < 0) {
|
|
23
|
+
previousRowsHeight =
|
|
24
|
+
previousRowsHeight === 0 ? rowHeights[0] : previousRowsHeight;
|
|
25
|
+
const currentRowHeight = rowHeights[startRowIndex];
|
|
26
|
+
const halfwayThreshold = accumulatedHeight - currentRowHeight / 2 - rowGap;
|
|
27
|
+
if (startRowIndex !== 0 && startRowIndex >= startRowIndex - 1) {
|
|
28
|
+
if (snappedHeight <= halfwayThreshold) {
|
|
29
|
+
result =
|
|
30
|
+
accumulatedHeight - currentRowHeight - rowGap - aboveRowsHeight;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
result = rowHeights
|
|
34
|
+
.slice(rowsAbove, startRowIndex)
|
|
35
|
+
.reduce((sum, height) => sum + height, 0);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
result = snappedHeight - aboveRowsHeight;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
static calculateSnappedWidth(deltaX, initialWidth, gap, gridColumnWidth) {
|
|
45
|
+
const newSize = initialWidth + deltaX;
|
|
46
|
+
const totalSpan = Math.round(newSize / (gridColumnWidth + gap));
|
|
47
|
+
const snappedWidth = totalSpan * gridColumnWidth + (totalSpan - 1) * gap;
|
|
48
|
+
return snappedWidth < gridColumnWidth ? gridColumnWidth : snappedWidth;
|
|
49
|
+
}
|
|
50
|
+
static calculate(initialTop, rowHeights, rowGap) {
|
|
51
|
+
let targetIndex = 0;
|
|
52
|
+
let accumulatedHeight = 0;
|
|
53
|
+
for (let i = 0; i < rowHeights.length; i++) {
|
|
54
|
+
accumulatedHeight += rowHeights[i] + (i > 0 ? rowGap : 0);
|
|
55
|
+
if (initialTop <= accumulatedHeight) {
|
|
56
|
+
targetIndex = i;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { targetIndex, accumulatedHeight };
|
|
61
|
+
}
|
|
62
|
+
static accumulateHeight(rowIndex, rowHeights, rowGap) {
|
|
63
|
+
let accumulatedHeight = 0;
|
|
64
|
+
for (let i = 0; i < rowIndex; i++) {
|
|
65
|
+
accumulatedHeight += rowHeights[i] + rowGap;
|
|
66
|
+
}
|
|
67
|
+
return accumulatedHeight;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=tile-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-util.js","sourceRoot":"","sources":["../../../src/components/tile-manager/tile-util.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IACd,MAAM,CAAC,sBAAsB,CAClC,MAAc,EACd,SAAiB,EACjB,UAAoB,EACpB,MAAc,EACd,UAAkB,EAClB,aAAqB;QAErB,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;QACzC,MAAM,SAAS,GACb,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC;QACxE,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,MAAM,CAAE,CAAC;QACrE,MAAM,iBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;QAChD,MAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC;QACtC,MAAM,eAAe,GAAG,UAAU,CAAC,gBAAgB,CACjD,SAAS,EACT,UAAU,EACV,MAAM,CACP,CAAC;QAEF,IAAI,MAAM,GAAG,aAAa,CAAC;QAC3B,IAAI,kBAAkB,GAAG,UAAU,CAAC,gBAAgB,CAClD,aAAa,EACb,UAAU,EACV,MAAM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CAAC,EAAE,EAAE,CAAC;YAClC,iBAAiB,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;QAC9C,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF","sourcesContent":["export class ResizeUtil {\n public static calculateSnappedHeight(\n deltaY: number,\n startingY: number,\n rowHeights: number[],\n rowGap: number,\n initialTop: number,\n initialHeight: number\n ): number {\n const snappedHeight = startingY + deltaY;\n const rowsAbove =\n ResizeUtil.calculate(initialTop, rowHeights, rowGap).targetIndex || 0;\n const res = ResizeUtil.calculate(snappedHeight, rowHeights, rowGap)!;\n const accumulatedHeight = res.accumulatedHeight;\n const startRowIndex = res.targetIndex;\n const aboveRowsHeight = ResizeUtil.accumulateHeight(\n rowsAbove,\n rowHeights,\n rowGap\n );\n\n let result = initialHeight;\n let previousRowsHeight = ResizeUtil.accumulateHeight(\n startRowIndex,\n rowHeights,\n rowGap\n );\n\n if (deltaY > 0) {\n const rowHeight = rowHeights[startRowIndex];\n const halfwayThreshold = previousRowsHeight + rowGap + rowHeight / 2;\n\n if (snappedHeight >= halfwayThreshold) {\n result = accumulatedHeight - aboveRowsHeight;\n } else {\n result = initialHeight + deltaY;\n }\n\n result = result <= 0 ? rowHeights[startRowIndex - 1] : result;\n } else if (deltaY < 0) {\n previousRowsHeight =\n previousRowsHeight === 0 ? rowHeights[0] : previousRowsHeight;\n const currentRowHeight = rowHeights[startRowIndex];\n const halfwayThreshold =\n accumulatedHeight - currentRowHeight / 2 - rowGap;\n\n if (startRowIndex !== 0 && startRowIndex >= startRowIndex - 1) {\n if (snappedHeight <= halfwayThreshold) {\n result =\n accumulatedHeight - currentRowHeight - rowGap - aboveRowsHeight;\n } else {\n result = rowHeights\n .slice(rowsAbove, startRowIndex)\n .reduce((sum, height) => sum + height, 0);\n }\n } else {\n result = snappedHeight - aboveRowsHeight;\n }\n }\n\n return result;\n }\n\n public static calculateSnappedWidth(\n deltaX: number,\n initialWidth: number,\n gap: number,\n gridColumnWidth: number\n ): number {\n const newSize = initialWidth + deltaX;\n const totalSpan = Math.round(newSize / (gridColumnWidth + gap));\n const snappedWidth = totalSpan * gridColumnWidth + (totalSpan - 1) * gap;\n\n return snappedWidth < gridColumnWidth ? gridColumnWidth : snappedWidth;\n }\n\n public static calculate(\n initialTop: number,\n rowHeights: number[],\n rowGap: number\n ): any {\n let targetIndex = 0;\n let accumulatedHeight = 0;\n\n for (let i = 0; i < rowHeights.length; i++) {\n accumulatedHeight += rowHeights[i] + (i > 0 ? rowGap : 0);\n if (initialTop <= accumulatedHeight) {\n targetIndex = i;\n break;\n }\n }\n\n return { targetIndex, accumulatedHeight };\n }\n\n private static accumulateHeight(\n rowIndex: number,\n rowHeights: number[],\n rowGap: number\n ): number {\n let accumulatedHeight = 0;\n for (let i = 0; i < rowIndex; i++) {\n accumulatedHeight += rowHeights[i] + rowGap;\n }\n\n return accumulatedHeight;\n }\n}\n"]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { Constructor } from '../common/mixins/constructor.js';
|
|
3
|
+
type IgcTileChangeState = {
|
|
4
|
+
tile: IgcTileComponent;
|
|
5
|
+
state: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface IgcTileComponentEventMap {
|
|
8
|
+
igcTileFullscreen: CustomEvent<IgcTileChangeState>;
|
|
9
|
+
igcTileMaximize: CustomEvent<IgcTileChangeState>;
|
|
10
|
+
tileDragStart: CustomEvent<IgcTileComponent>;
|
|
11
|
+
tileDragEnd: CustomEvent<IgcTileComponent>;
|
|
12
|
+
igcResizeStart: CustomEvent<IgcTileComponent>;
|
|
13
|
+
igcResizeMove: CustomEvent<IgcTileComponent>;
|
|
14
|
+
igcResizeEnd: CustomEvent<IgcTileComponent>;
|
|
15
|
+
}
|
|
16
|
+
declare const IgcTileComponent_base: Constructor<import("../common/mixins/event-emitter.js").EventEmitterInterface<IgcTileComponentEventMap>> & Constructor<LitElement>;
|
|
17
|
+
/**
|
|
18
|
+
* The tile component is used within the `igc-tile-manager` as a container
|
|
19
|
+
* for displaying various types of information.
|
|
20
|
+
*
|
|
21
|
+
* @element igc-tile
|
|
22
|
+
*
|
|
23
|
+
* @fires igcTileFullscreen - Fired when tile fullscreen state changes.
|
|
24
|
+
* @fires igcTileMaximize - Fired when tile maximize state changes.
|
|
25
|
+
* @fires igcResizeStart - Fired when tile begins resizing.
|
|
26
|
+
* @fires igcResizeMove - Fired when tile is being resized.
|
|
27
|
+
* @fires igcResizeEnd - Fired when tile finishes resizing.
|
|
28
|
+
*/
|
|
29
|
+
export default class IgcTileComponent extends IgcTileComponent_base {
|
|
30
|
+
static readonly tagName = "igc-tile";
|
|
31
|
+
static styles: import("lit").CSSResult[];
|
|
32
|
+
static register(): void;
|
|
33
|
+
private static readonly increment;
|
|
34
|
+
private _dragController;
|
|
35
|
+
private _fullscreenController;
|
|
36
|
+
private _colSpan;
|
|
37
|
+
private _rowSpan;
|
|
38
|
+
private _colStart;
|
|
39
|
+
private _rowStart;
|
|
40
|
+
private _position;
|
|
41
|
+
private _disableDrag;
|
|
42
|
+
private _maximized;
|
|
43
|
+
private _initialPointerX;
|
|
44
|
+
private _initialPointerY;
|
|
45
|
+
private _dragCounter;
|
|
46
|
+
private _dragGhost;
|
|
47
|
+
private _dragImage;
|
|
48
|
+
private _cachedStyles;
|
|
49
|
+
private _managerContext?;
|
|
50
|
+
private _context;
|
|
51
|
+
private _setTileContext;
|
|
52
|
+
private get _draggedItem();
|
|
53
|
+
private get _isSlideMode();
|
|
54
|
+
_ghost: HTMLElement;
|
|
55
|
+
_tileContent: HTMLElement;
|
|
56
|
+
private _isDragging;
|
|
57
|
+
private _hasDragOver;
|
|
58
|
+
private _isResizing;
|
|
59
|
+
/**
|
|
60
|
+
* The unique identifier of the tile.
|
|
61
|
+
* @attr
|
|
62
|
+
*/
|
|
63
|
+
tileId: string | null;
|
|
64
|
+
set colSpan(value: number);
|
|
65
|
+
get colSpan(): number;
|
|
66
|
+
set rowSpan(value: number);
|
|
67
|
+
get rowSpan(): number;
|
|
68
|
+
set colStart(value: number);
|
|
69
|
+
get colStart(): number | null;
|
|
70
|
+
set rowStart(value: number);
|
|
71
|
+
get rowStart(): number | null;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates whether the tile occupies the whole screen.
|
|
74
|
+
* @attr fullscreen
|
|
75
|
+
*/
|
|
76
|
+
set fullscreen(value: boolean);
|
|
77
|
+
get fullscreen(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Indicates whether the tile occupies all available space within the layout.
|
|
80
|
+
* @attr maximized
|
|
81
|
+
*/
|
|
82
|
+
set maximized(value: boolean);
|
|
83
|
+
get maximized(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Indicates whether the tile can be dragged.
|
|
86
|
+
* @attr disable-drag
|
|
87
|
+
*/
|
|
88
|
+
set disableDrag(value: boolean);
|
|
89
|
+
get disableDrag(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Indicates whether the tile can be resized.
|
|
92
|
+
* @attr disable-resize
|
|
93
|
+
*/
|
|
94
|
+
disableResize: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Gets/sets the tile's visual position in the layout.
|
|
97
|
+
* Corresponds to the CSS order property.
|
|
98
|
+
* @attr
|
|
99
|
+
*/
|
|
100
|
+
set position(value: number);
|
|
101
|
+
get position(): number;
|
|
102
|
+
protected get gridColumnWidth(): number;
|
|
103
|
+
constructor();
|
|
104
|
+
connectedCallback(): void;
|
|
105
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
106
|
+
private emitFullScreenEvent;
|
|
107
|
+
private assignDragImage;
|
|
108
|
+
private handleDragStart;
|
|
109
|
+
private handleDragEnter;
|
|
110
|
+
private handleDragOver;
|
|
111
|
+
private handleDragLeave;
|
|
112
|
+
private handleDragEnd;
|
|
113
|
+
private hasPointerLeftLastSwapTile;
|
|
114
|
+
private cacheStyles;
|
|
115
|
+
private _handleResizeStart;
|
|
116
|
+
private _handleResize;
|
|
117
|
+
private _handleResizeEnd;
|
|
118
|
+
private _calculateRowSpan;
|
|
119
|
+
protected ghostFactory: () => HTMLDivElement;
|
|
120
|
+
protected renderContent(): import("lit-html").TemplateResult<1>;
|
|
121
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
122
|
+
}
|
|
123
|
+
declare global {
|
|
124
|
+
interface HTMLElementTagNameMap {
|
|
125
|
+
'igc-tile': IgcTileComponent;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export {};
|