@revolist/revogrid 4.8.1 → 4.8.2
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/dist/cjs/base.plugin-75fc9e81.js.map +1 -1
- package/dist/cjs/{column.service-b3b5a4ee.js → column.service-43f8c476.js} +2 -2
- package/dist/cjs/{column.service-b3b5a4ee.js.map → column.service-43f8c476.js.map} +1 -1
- package/dist/cjs/{filter.button-147884a8.js → filter.button-35f508a0.js} +3 -3
- package/dist/cjs/filter.button-35f508a0.js.map +1 -0
- package/dist/cjs/{header-cell-renderer-96a37624.js → header-cell-renderer-a3b43bca.js} +2 -2
- package/dist/cjs/{header-cell-renderer-96a37624.js.map → header-cell-renderer-a3b43bca.js.map} +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/{key.utils-be4d0b46.js → key.utils-4a384064.js} +17 -12
- package/dist/cjs/key.utils-4a384064.js.map +1 -0
- package/dist/cjs/revo-grid.cjs.entry.js +14 -9
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-attribution_6.cjs.entry.js +41 -12
- package/dist/cjs/revogr-attribution_6.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +5 -3
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +10 -9
- package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +13 -8
- package/dist/cjs/revogr-filter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/{selection.helpers-032d7192.js → selection.helpers-26d856ba.js} +67 -20
- package/dist/cjs/selection.helpers-26d856ba.js.map +1 -0
- package/dist/collection/components/clipboard/revogr-clipboard.js +1 -0
- package/dist/collection/components/clipboard/revogr-clipboard.js.map +1 -1
- package/dist/collection/components/data/revogr-data.js +1 -1
- package/dist/collection/components/data/revogr-data.js.map +1 -1
- package/dist/collection/components/editors/text-editor.js +4 -3
- package/dist/collection/components/editors/text-editor.js.map +1 -1
- package/dist/collection/components/header/header-renderer.js +2 -2
- package/dist/collection/components/header/header-renderer.js.map +1 -1
- package/dist/collection/components/overlay/keyboard.service.js +15 -5
- package/dist/collection/components/overlay/keyboard.service.js.map +1 -1
- package/dist/collection/components/overlay/revogr-overlay-selection.js +44 -5
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js +3 -3
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/plugins/base.plugin.js.map +1 -1
- package/dist/collection/plugins/column.auto-size.plugin.js.map +1 -1
- package/dist/collection/plugins/column.stretch.plugin.js.map +1 -1
- package/dist/collection/plugins/filter/filter.button.js +2 -2
- package/dist/collection/plugins/filter/filter.button.js.map +1 -1
- package/dist/collection/plugins/filter/filter.plugin.js +7 -2
- package/dist/collection/plugins/filter/filter.plugin.js.map +1 -1
- package/dist/collection/plugins/filter/filter.pop.js +13 -8
- package/dist/collection/plugins/filter/filter.pop.js.map +1 -1
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js.map +1 -1
- package/dist/collection/plugins/moveColumn/column.drag.plugin.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.sign.js +2 -1
- package/dist/collection/plugins/sorting/sorting.sign.js.map +1 -1
- package/dist/collection/services/selection.store.connector.js +62 -19
- package/dist/collection/services/selection.store.connector.js.map +1 -1
- package/dist/collection/store/selection/selection.store.js +4 -0
- package/dist/collection/store/selection/selection.store.js.map +1 -1
- package/dist/collection/types/interfaces.js.map +1 -1
- package/dist/collection/types/plugin.js.map +1 -1
- package/dist/collection/types/plugin.types.js.map +1 -1
- package/dist/collection/types/selection.js.map +1 -1
- package/dist/collection/utils/key.codes.js +6 -2
- package/dist/collection/utils/key.codes.js.map +1 -1
- package/dist/collection/utils/key.utils.js +25 -13
- package/dist/collection/utils/key.utils.js.map +1 -1
- package/dist/esm/base.plugin-e6e2bac2.js.map +1 -1
- package/dist/esm/{column.service-ffe99cfc.js → column.service-6aab6fac.js} +2 -2
- package/dist/esm/{column.service-ffe99cfc.js.map → column.service-6aab6fac.js.map} +1 -1
- package/dist/esm/{filter.button-f132c10a.js → filter.button-f9883a78.js} +3 -3
- package/dist/esm/filter.button-f9883a78.js.map +1 -0
- package/dist/esm/{header-cell-renderer-cac333a3.js → header-cell-renderer-b8663a21.js} +2 -2
- package/dist/esm/{header-cell-renderer-cac333a3.js.map → header-cell-renderer-b8663a21.js.map} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/{key.utils-9120fde7.js → key.utils-c4a27968.js} +17 -12
- package/dist/esm/key.utils-c4a27968.js.map +1 -0
- package/dist/esm/revo-grid.entry.js +14 -9
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revogr-attribution_6.entry.js +41 -12
- package/dist/esm/revogr-attribution_6.entry.js.map +1 -1
- package/dist/esm/revogr-clipboard_3.entry.js +5 -3
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/revogr-data_4.entry.js +10 -9
- package/dist/esm/revogr-data_4.entry.js.map +1 -1
- package/dist/esm/revogr-filter-panel.entry.js +13 -8
- package/dist/esm/revogr-filter-panel.entry.js.map +1 -1
- package/dist/esm/{selection.helpers-0f3ed629.js → selection.helpers-dbf69cc1.js} +67 -20
- package/dist/esm/selection.helpers-dbf69cc1.js.map +1 -0
- package/dist/revo-grid/base.plugin-e6e2bac2.js.map +1 -1
- package/dist/revo-grid/{column.service-ffe99cfc.js → column.service-6aab6fac.js} +2 -2
- package/dist/revo-grid/{filter.button-f132c10a.js → filter.button-f9883a78.js} +2 -2
- package/dist/revo-grid/filter.button-f9883a78.js.map +1 -0
- package/dist/revo-grid/{header-cell-renderer-cac333a3.js → header-cell-renderer-b8663a21.js} +2 -2
- package/dist/revo-grid/index.esm.js +1 -1
- package/dist/revo-grid/{key.utils-9120fde7.js → key.utils-c4a27968.js} +2 -2
- package/dist/revo-grid/key.utils-c4a27968.js.map +1 -0
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_6.entry.js +1 -1
- package/dist/revo-grid/revogr-attribution_6.entry.js.map +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js.map +1 -1
- package/dist/revo-grid/selection.helpers-dbf69cc1.js +5 -0
- package/dist/revo-grid/selection.helpers-dbf69cc1.js.map +1 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +1 -1
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +9 -1
- package/dist/types/components.d.ts +5 -0
- package/dist/types/plugins/base.plugin.d.ts +8 -8
- package/dist/types/plugins/column.auto-size.plugin.d.ts +26 -16
- package/dist/types/plugins/column.stretch.plugin.d.ts +1 -1
- package/dist/types/plugins/filter/filter.button.d.ts +1 -1
- package/dist/types/plugins/filter/filter.plugin.d.ts +24 -16
- package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +2 -2
- package/dist/types/plugins/moveColumn/column.drag.plugin.d.ts +3 -3
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +8 -8
- package/dist/types/services/selection.store.connector.d.ts +20 -0
- package/dist/types/store/selection/selection.store.d.ts +1 -0
- package/dist/types/types/interfaces.d.ts +2 -2
- package/dist/types/types/plugin.d.ts +23 -0
- package/dist/types/types/plugin.types.d.ts +20 -0
- package/dist/types/types/selection.d.ts +24 -0
- package/dist/types/utils/key.codes.d.ts +5 -2
- package/dist/types/utils/key.utils.d.ts +2 -1
- package/hydrate/index.js +153 -59
- package/hydrate/index.mjs +153 -59
- package/package.json +1 -1
- package/standalone/column.service.js +66 -19
- package/standalone/column.service.js.map +1 -1
- package/standalone/filter.button.js +2 -2
- package/standalone/filter.button.js.map +1 -1
- package/standalone/revo-grid.js +10 -5
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-clipboard2.js +1 -0
- package/standalone/revogr-clipboard2.js.map +1 -1
- package/standalone/revogr-data2.js +1 -1
- package/standalone/revogr-data2.js.map +1 -1
- package/standalone/revogr-edit2.js +19 -13
- package/standalone/revogr-edit2.js.map +1 -1
- package/standalone/revogr-filter-panel.js +12 -7
- package/standalone/revogr-filter-panel.js.map +1 -1
- package/standalone/revogr-header2.js +5 -4
- package/standalone/revogr-header2.js.map +1 -1
- package/standalone/revogr-overlay-selection2.js +39 -10
- package/standalone/revogr-overlay-selection2.js.map +1 -1
- package/dist/cjs/filter.button-147884a8.js.map +0 -1
- package/dist/cjs/key.utils-be4d0b46.js.map +0 -1
- package/dist/cjs/selection.helpers-032d7192.js.map +0 -1
- package/dist/esm/filter.button-f132c10a.js.map +0 -1
- package/dist/esm/key.utils-9120fde7.js.map +0 -1
- package/dist/esm/selection.helpers-0f3ed629.js.map +0 -1
- package/dist/revo-grid/filter.button-f132c10a.js.map +0 -1
- package/dist/revo-grid/key.utils-9120fde7.js.map +0 -1
- package/dist/revo-grid/selection.helpers-0f3ed629.js +0 -5
- package/dist/revo-grid/selection.helpers-0f3ed629.js.map +0 -1
- /package/dist/revo-grid/{column.service-ffe99cfc.js.map → column.service-6aab6fac.js.map} +0 -0
- /package/dist/revo-grid/{header-cell-renderer-cac333a3.js.map → header-cell-renderer-b8663a21.js.map} +0 -0
|
@@ -155,42 +155,91 @@ export default class SelectionStoreConnector {
|
|
|
155
155
|
this.focusByCell(storePos, editCell, editCell);
|
|
156
156
|
this.setEdit('');
|
|
157
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Sets the next focus cell before the current one.
|
|
160
|
+
*
|
|
161
|
+
* @param focus - The cell to set as the next focus.
|
|
162
|
+
*/
|
|
163
|
+
beforeNextFocusCell(focus) {
|
|
164
|
+
var _a;
|
|
165
|
+
// If there is no focused store, return early.
|
|
166
|
+
if (!this.focusedStore) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
// Get the next store based on the current focus and the last cell.
|
|
170
|
+
const next = this.getNextStore(focus, this.focusedStore.position, this.focusedStore.entity.store.get('lastCell'));
|
|
171
|
+
// Set the next focus cell in the store.
|
|
172
|
+
(_a = next.store) === null || _a === void 0 ? void 0 : _a.setNextFocus(Object.assign(Object.assign({}, focus), next.item));
|
|
173
|
+
}
|
|
158
174
|
focusByCell(storePos, start, end) {
|
|
159
175
|
const store = this.stores[storePos.y][storePos.x];
|
|
160
176
|
this.focus(store, { focus: start, end });
|
|
161
177
|
}
|
|
162
178
|
focus(store, { focus, end }) {
|
|
179
|
+
const currentStorePointer = this.getCurrentStorePointer(store);
|
|
180
|
+
if (!currentStorePointer) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
// check for the focus in nearby store/viewport
|
|
184
|
+
const lastCell = store.store.get('lastCell');
|
|
185
|
+
const next = this.getNextStore(focus, currentStorePointer, lastCell);
|
|
186
|
+
// if next store present - update
|
|
187
|
+
if (next === null || next === void 0 ? void 0 : next.store) {
|
|
188
|
+
const item = Object.assign(Object.assign({}, focus), next.item);
|
|
189
|
+
this.focus(next.store, { focus: item, end: item });
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
focus = cropCellToMax(focus, lastCell);
|
|
193
|
+
end = cropCellToMax(end, lastCell);
|
|
194
|
+
store.setFocus(focus, end);
|
|
195
|
+
return focus;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Retrieves the current store pointer based on the active store.
|
|
199
|
+
* Clears focus from all stores except the active one.
|
|
200
|
+
*/
|
|
201
|
+
getCurrentStorePointer(store) {
|
|
163
202
|
let currentStorePointer;
|
|
164
|
-
//
|
|
203
|
+
// Iterate through all stores
|
|
165
204
|
for (let y in this.stores) {
|
|
166
205
|
for (let x in this.stores[y]) {
|
|
167
206
|
const s = this.stores[y][x];
|
|
168
|
-
//
|
|
207
|
+
// Clear focus from stores other than the active one
|
|
169
208
|
if (s !== store) {
|
|
170
209
|
s.clearFocus();
|
|
171
210
|
}
|
|
172
211
|
else {
|
|
173
|
-
|
|
212
|
+
// Update the current store pointer with the active store coordinates
|
|
213
|
+
currentStorePointer = {
|
|
214
|
+
x: parseInt(x, 10),
|
|
215
|
+
y: parseInt(y, 10)
|
|
216
|
+
};
|
|
174
217
|
}
|
|
175
218
|
}
|
|
176
219
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
220
|
+
return currentStorePointer;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Retrieves the next store based on the focus cell and current store pointer.
|
|
224
|
+
* If the next store exists, returns an object with the next store and the item in the new store.
|
|
225
|
+
* If the next store does not exist, returns null.
|
|
226
|
+
*/
|
|
227
|
+
getNextStore(focus, currentStorePointer, lastCell) {
|
|
182
228
|
// item in new store
|
|
183
229
|
const nextItem = nextCell(focus, lastCell);
|
|
184
|
-
let nextStore;
|
|
230
|
+
let nextStore = null;
|
|
185
231
|
if (nextItem) {
|
|
186
232
|
for (let i in nextItem) {
|
|
187
233
|
let type = i;
|
|
188
234
|
let stores;
|
|
189
235
|
switch (type) {
|
|
190
236
|
case 'x':
|
|
237
|
+
// Get the X stores for the current Y coordinate of the current store pointer
|
|
191
238
|
stores = this.getXStores(currentStorePointer.y);
|
|
192
239
|
break;
|
|
193
240
|
case 'y':
|
|
241
|
+
// Get the Y stores for the current X coordinate of the current store pointer
|
|
242
|
+
stores = this.getYStores(currentStorePointer.x);
|
|
194
243
|
stores = this.getYStores(currentStorePointer.x);
|
|
195
244
|
break;
|
|
196
245
|
}
|
|
@@ -206,16 +255,10 @@ export default class SelectionStoreConnector {
|
|
|
206
255
|
}
|
|
207
256
|
}
|
|
208
257
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
focus = cropCellToMax(focus, lastCell);
|
|
216
|
-
end = cropCellToMax(end, lastCell);
|
|
217
|
-
store.setFocus(focus, end);
|
|
218
|
-
return focus;
|
|
258
|
+
return {
|
|
259
|
+
store: nextStore,
|
|
260
|
+
item: nextItem,
|
|
261
|
+
};
|
|
219
262
|
}
|
|
220
263
|
clearAll() {
|
|
221
264
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.store.connector.js","sourceRoot":"","sources":["../../src/services/selection.store.connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAYhF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC;AAE9B,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAA5C;QACE,kFAAkF;QAC1E,UAAK,GAAG,KAAK,CAAC;QACb,WAAM,GAAqD,EAAE,CAAC;QAE9D,iBAAY,GAAqB,EAAE,CAAC;QACpC,cAAS,GAAoC,EAAE,CAAC;QAEzD;;WAEG;QACM,iBAAY,GAAgD,EAAE,CAAC;QAC/D,kBAAa,GAAiC,EAAE,CAAC;QACjD,kBAAa,GAAiC,EAAE,CAAC;QAiCzC,aAAQ,GAAc,EAAE,CAAC;IA+N5C,CAAC;IA9PC,IAAI,YAAY;;QACd,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,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,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,MAAM,MAAM,GAAoC,EAAE,CAAC;QACnD,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { cropCellToMax, isHiddenStore, nextCell, SelectionStore } from '@store';\nimport type { MultiDimensionType, DimensionCols, DimensionRows, Cell, EditCellStore, RangeArea } from '@type';\n\ntype StoreByDimension = Record<number, SelectionStore>;\ntype FocusedStore = {\n entity: SelectionStore;\n cell: Cell;\n position: Cell;\n};\n\ntype StoresMapping<T> = { [xOrY: number]: Partial<T> };\n\nexport const EMPTY_INDEX = -1;\n\nexport default class SelectionStoreConnector {\n // dirty flag required to cleanup whole store in case visibility of panels changed\n private dirty = false;\n readonly stores: { [y: number]: { [x: number]: SelectionStore } } = {};\n\n readonly columnStores: StoreByDimension = {};\n readonly rowStores: { [y: number]: SelectionStore } = {};\n\n /**\n * Helpers for data conversion\n */\n readonly storesByType: Partial<Record<MultiDimensionType, number>> = {};\n readonly storesXToType: StoresMapping<DimensionCols> = {};\n readonly storesYToType: StoresMapping<DimensionRows> = {};\n\n get focusedStore(): FocusedStore | null {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const focused = this.stores[y][x]?.store.get('focus');\n if (focused) {\n return {\n entity: this.stores[y][x],\n cell: focused,\n position: {\n x: parseInt(x, 10),\n y: parseInt(y, 10),\n },\n };\n }\n }\n }\n return null;\n }\n\n get edit(): EditCellStore | undefined {\n return this.focusedStore?.entity.store.get('edit');\n }\n\n get focused(): Cell | undefined {\n return this.focusedStore?.entity.store.get('focus');\n }\n\n get selectedRange(): RangeArea | undefined {\n return this.focusedStore?.entity.store.get('range');\n }\n\n private readonly sections: Element[] = [];\n\n registerSection(e?: Element) {\n if (!e) {\n this.sections.length = 0;\n // some elements removed, rebuild stores\n this.dirty = true;\n return;\n }\n if (this.sections.indexOf(e) === -1) {\n this.sections.push(e);\n }\n }\n\n // check if require to cleanup all stores\n beforeUpdate() {\n if (this.dirty) {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x].dispose();\n }\n }\n this.dirty = false;\n }\n }\n\n registerColumn(x: number, type: DimensionCols): SelectionStore {\n\n // if hidden just create store but no operations needed\n if (isHiddenStore(x)) {\n return new SelectionStore();\n }\n if (this.columnStores[x]) {\n return this.columnStores[x];\n }\n this.columnStores[x] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = x;\n this.storesXToType[x] = type;\n return this.columnStores[x];\n }\n\n registerRow(y: number, type: DimensionRows): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (this.rowStores[y]) {\n return this.rowStores[y];\n }\n this.rowStores[y] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = y;\n this.storesYToType[y] = type;\n return this.rowStores[y];\n }\n\n /**\n * Cross store proxy, based on multiple dimensions\n */\n register({ x, y }: Cell): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(x) || isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (!this.stores[y]) {\n this.stores[y] = {};\n }\n if (this.stores[y][x]) {\n // Store already registered. Do not register twice\n return this.stores[y][x];\n }\n this.stores[y][x] = new SelectionStore();\n // proxy update, column store trigger only range area\n this.stores[y][x]?.onChange('range', c => {\n this.columnStores[x].setRangeArea(c);\n this.rowStores[y].setRangeArea(c);\n });\n // clean up on remove\n this.stores[y][x]?.store.on('dispose', () => this.destroy(x, y));\n return this.stores[y][x];\n }\n\n private destroy(x: number, y: number) {\n this.columnStores[x]?.dispose();\n this.rowStores[y]?.dispose();\n\n delete this.rowStores[y];\n delete this.columnStores[x];\n // clear x cross link\n if (this.storesXToType[x]) {\n const type = this.storesXToType[x];\n delete this.storesXToType[x];\n delete this.storesByType[type];\n }\n // clear y cross link\n if (this.storesYToType[y]) {\n const type = this.storesYToType[y];\n delete this.storesYToType[y];\n delete this.storesByType[type];\n }\n if (this.stores[y]) {\n delete this.stores[y][x];\n }\n // clear empty rows\n if (!Object.keys(this.stores[y] || {}).length) {\n delete this.stores[y];\n }\n }\n\n setEditByCell<T extends Cell>(storePos: T, editCell: T) {\n this.focusByCell(storePos, editCell, editCell);\n this.setEdit('');\n }\n\n focusByCell<T extends Cell>(storePos: T, start: T, end: T) {\n const store = this.stores[storePos.y][storePos.x];\n this.focus(store, { focus: start, end });\n }\n\n focus(store: SelectionStore, { focus, end }: { focus: Cell; end: Cell }) {\n let currentStorePointer: Cell;\n // clear all stores focus leave only active one\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const s = this.stores[y][x];\n // clear other stores, only one area can be selected\n if (s !== store) {\n s.clearFocus();\n } else {\n currentStorePointer = { x: parseInt(x, 10), y: parseInt(y, 10) };\n }\n }\n }\n if (!currentStorePointer) {\n return null;\n }\n\n // check is focus in next store\n const lastCell = store.store.get('lastCell');\n // item in new store\n const nextItem: Partial<Cell> | null = nextCell(focus, lastCell);\n\n let nextStore;\n if (nextItem) {\n for (let i in nextItem) {\n let type: keyof Cell = i as keyof Cell;\n let stores;\n switch (type) {\n case 'x':\n stores = this.getXStores(currentStorePointer.y);\n break;\n case 'y':\n stores = this.getYStores(currentStorePointer.x);\n break;\n }\n if (nextItem[type] >= 0) {\n nextStore = stores[++currentStorePointer[type]];\n } else {\n nextStore = stores[--currentStorePointer[type]];\n const nextLastCell = nextStore?.store.get('lastCell');\n if (nextLastCell) {\n nextItem[type] = nextLastCell[type] + nextItem[type];\n }\n }\n }\n }\n // if next store present - update\n if (nextStore) {\n let item = { ...focus, ...nextItem };\n this.focus(nextStore, { focus: item, end: item });\n return null;\n }\n\n focus = cropCellToMax(focus, lastCell);\n end = cropCellToMax(end, lastCell);\n\n store.setFocus(focus, end);\n return focus;\n }\n\n clearAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x]?.clearFocus();\n }\n }\n }\n\n setEdit(val: string | boolean) {\n if (!this.focusedStore) {\n return;\n }\n this.focusedStore.entity.setEdit(val);\n }\n\n /**\n * Select all cells across all stores\n */\n selectAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const store = this.stores[y][x];\n if (!store) {\n continue;\n }\n const lastCell = store.store.get('lastCell');\n store.setRange({ x: 0, y: 0 }, { x: lastCell.x - 1, y: lastCell.y - 1 });\n }\n }\n }\n\n private getXStores(y: number) {\n return this.stores[y];\n }\n\n private getYStores(x: number) {\n const stores: { [p: number]: SelectionStore } = {};\n for (let i in this.stores) {\n stores[i] = this.stores[i][x];\n }\n return stores;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"selection.store.connector.js","sourceRoot":"","sources":["../../src/services/selection.store.connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAmBhF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC;AAE9B,MAAM,CAAC,OAAO,OAAO,uBAAuB;IAA5C;QACE,kFAAkF;QAC1E,UAAK,GAAG,KAAK,CAAC;QACb,WAAM,GAAqD,EAAE,CAAC;QAE9D,iBAAY,GAAqB,EAAE,CAAC;QACpC,cAAS,GAAoC,EAAE,CAAC;QAEzD;;WAEG;QACM,iBAAY,GAAgD,EAAE,CAAC;QAC/D,kBAAa,GA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,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,SAAS;gBACX,CAAC;gBACD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAC7C,KAAK,CAAC,QAAQ,CACZ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EACd,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CACzC,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,MAAM,MAAM,GAAoC,EAAE,CAAC;QACnD,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { cropCellToMax, isHiddenStore, nextCell, SelectionStore } from '@store';\nimport type {\n MultiDimensionType,\n DimensionCols,\n DimensionRows,\n Cell,\n EditCellStore,\n RangeArea,\n} from '@type';\n\ntype StoreByDimension = Record<number, SelectionStore>;\ntype FocusedStore = {\n entity: SelectionStore;\n cell: Cell;\n position: Cell;\n};\n\ntype StoresMapping<T> = { [xOrY: number]: Partial<T> };\n\nexport const EMPTY_INDEX = -1;\n\nexport default class SelectionStoreConnector {\n // dirty flag required to cleanup whole store in case visibility of panels changed\n private dirty = false;\n readonly stores: { [y: number]: { [x: number]: SelectionStore } } = {};\n\n readonly columnStores: StoreByDimension = {};\n readonly rowStores: { [y: number]: SelectionStore } = {};\n\n /**\n * Helpers for data conversion\n */\n readonly storesByType: Partial<Record<MultiDimensionType, number>> = {};\n readonly storesXToType: StoresMapping<DimensionCols> = {};\n readonly storesYToType: StoresMapping<DimensionRows> = {};\n\n get focusedStore(): FocusedStore | null {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const focused = this.stores[y][x]?.store.get('focus');\n if (focused) {\n return {\n entity: this.stores[y][x],\n cell: focused,\n position: {\n x: parseInt(x, 10),\n y: parseInt(y, 10),\n },\n };\n }\n }\n }\n return null;\n }\n\n get edit(): EditCellStore | undefined {\n return this.focusedStore?.entity.store.get('edit');\n }\n\n get focused(): Cell | undefined {\n return this.focusedStore?.entity.store.get('focus');\n }\n\n get selectedRange(): RangeArea | undefined {\n return this.focusedStore?.entity.store.get('range');\n }\n\n private readonly sections: Element[] = [];\n\n registerSection(e?: Element) {\n if (!e) {\n this.sections.length = 0;\n // some elements removed, rebuild stores\n this.dirty = true;\n return;\n }\n if (this.sections.indexOf(e) === -1) {\n this.sections.push(e);\n }\n }\n\n // check if require to cleanup all stores\n beforeUpdate() {\n if (this.dirty) {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x].dispose();\n }\n }\n this.dirty = false;\n }\n }\n\n registerColumn(x: number, type: DimensionCols): SelectionStore {\n // if hidden just create store but no operations needed\n if (isHiddenStore(x)) {\n return new SelectionStore();\n }\n if (this.columnStores[x]) {\n return this.columnStores[x];\n }\n this.columnStores[x] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = x;\n this.storesXToType[x] = type;\n return this.columnStores[x];\n }\n\n registerRow(y: number, type: DimensionRows): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (this.rowStores[y]) {\n return this.rowStores[y];\n }\n this.rowStores[y] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = y;\n this.storesYToType[y] = type;\n return this.rowStores[y];\n }\n\n /**\n * Cross store proxy, based on multiple dimensions\n */\n register({ x, y }: Cell): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(x) || isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (!this.stores[y]) {\n this.stores[y] = {};\n }\n if (this.stores[y][x]) {\n // Store already registered. Do not register twice\n return this.stores[y][x];\n }\n this.stores[y][x] = new SelectionStore();\n // proxy update, column store trigger only range area\n this.stores[y][x]?.onChange('range', c => {\n this.columnStores[x].setRangeArea(c);\n this.rowStores[y].setRangeArea(c);\n });\n // clean up on remove\n this.stores[y][x]?.store.on('dispose', () => this.destroy(x, y));\n return this.stores[y][x];\n }\n\n private destroy(x: number, y: number) {\n this.columnStores[x]?.dispose();\n this.rowStores[y]?.dispose();\n\n delete this.rowStores[y];\n delete this.columnStores[x];\n // clear x cross link\n if (this.storesXToType[x]) {\n const type = this.storesXToType[x];\n delete this.storesXToType[x];\n delete this.storesByType[type];\n }\n // clear y cross link\n if (this.storesYToType[y]) {\n const type = this.storesYToType[y];\n delete this.storesYToType[y];\n delete this.storesByType[type];\n }\n if (this.stores[y]) {\n delete this.stores[y][x];\n }\n // clear empty rows\n if (!Object.keys(this.stores[y] || {}).length) {\n delete this.stores[y];\n }\n }\n\n setEditByCell<T extends Cell>(storePos: T, editCell: T) {\n this.focusByCell(storePos, editCell, editCell);\n this.setEdit('');\n }\n\n /**\n * Sets the next focus cell before the current one.\n * \n * @param focus - The cell to set as the next focus.\n */\n beforeNextFocusCell(focus: Cell) {\n // If there is no focused store, return early.\n if (!this.focusedStore) {\n return;\n }\n\n // Get the next store based on the current focus and the last cell.\n const next = this.getNextStore(focus, this.focusedStore.position, this.focusedStore.entity.store.get('lastCell') );\n\n // Set the next focus cell in the store.\n next.store?.setNextFocus({ ...focus, ...next.item });\n }\n\n focusByCell<T extends Cell>(storePos: T, start: T, end: T) {\n const store = this.stores[storePos.y][storePos.x];\n this.focus(store, { focus: start, end });\n }\n\n focus(store: SelectionStore, { focus, end }: { focus: Cell; end: Cell }) {\n const currentStorePointer = this.getCurrentStorePointer(store);\n if (!currentStorePointer) {\n return null;\n }\n\n // check for the focus in nearby store/viewport\n const lastCell = store.store.get('lastCell');\n const next = this.getNextStore(focus, currentStorePointer, lastCell);\n\n // if next store present - update\n if (next?.store) {\n const item = { ...focus, ...next.item };\n this.focus(next.store, { focus: item, end: item });\n return null;\n }\n\n focus = cropCellToMax(focus, lastCell);\n end = cropCellToMax(end, lastCell);\n\n store.setFocus(focus, end);\n return focus;\n }\n\n /**\n * Retrieves the current store pointer based on the active store.\n * Clears focus from all stores except the active one.\n */\n getCurrentStorePointer(store: SelectionStore): Cell {\n let currentStorePointer: Cell;\n\n // Iterate through all stores\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const s = this.stores[y][x];\n\n // Clear focus from stores other than the active one\n if (s !== store) {\n s.clearFocus();\n } else {\n // Update the current store pointer with the active store coordinates\n currentStorePointer = { \n x: parseInt(x, 10), \n y: parseInt(y, 10) \n };\n }\n }\n }\n\n return currentStorePointer;\n }\n\n /**\n * Retrieves the next store based on the focus cell and current store pointer.\n * If the next store exists, returns an object with the next store and the item in the new store.\n * If the next store does not exist, returns null.\n */\n getNextStore(\n focus: Cell,\n currentStorePointer: Cell,\n lastCell: Cell,\n ) {\n // item in new store\n const nextItem: Partial<Cell> | null = nextCell(focus, lastCell);\n\n let nextStore: SelectionStore | null = null;\n if (nextItem) {\n for (let i in nextItem) {\n let type: keyof Cell = i as keyof Cell;\n let stores;\n switch (type) {\n case 'x':\n // Get the X stores for the current Y coordinate of the current store pointer\n stores = this.getXStores(currentStorePointer.y);\n break;\n case 'y':\n // Get the Y stores for the current X coordinate of the current store pointer\n stores = this.getYStores(currentStorePointer.x);\n stores = this.getYStores(currentStorePointer.x);\n break;\n }\n if (nextItem[type] >= 0) {\n nextStore = stores[++currentStorePointer[type]];\n } else {\n nextStore = stores[--currentStorePointer[type]];\n const nextLastCell = nextStore?.store.get('lastCell');\n if (nextLastCell) {\n nextItem[type] = nextLastCell[type] + nextItem[type];\n }\n }\n }\n }\n return {\n store: nextStore,\n item: nextItem,\n };\n }\n\n clearAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x]?.clearFocus();\n }\n }\n }\n\n setEdit(val: string | boolean) {\n if (!this.focusedStore) {\n return;\n }\n this.focusedStore.entity.setEdit(val);\n }\n\n /**\n * Select all cells across all stores\n */\n selectAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const store = this.stores[y][x];\n if (!store) {\n continue;\n }\n const lastCell = store.store.get('lastCell');\n store.setRange(\n { x: 0, y: 0 },\n { x: lastCell.x - 1, y: lastCell.y - 1 },\n );\n }\n }\n }\n\n private getXStores(y: number) {\n return this.stores[y];\n }\n\n private getYStores(x: number) {\n const stores: { [p: number]: SelectionStore } = {};\n for (let i in this.stores) {\n stores[i] = this.stores[i][x];\n }\n return stores;\n }\n}\n"]}
|
|
@@ -15,6 +15,7 @@ function defaultState() {
|
|
|
15
15
|
focus: null,
|
|
16
16
|
edit: null,
|
|
17
17
|
lastCell: null,
|
|
18
|
+
nextFocus: null,
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
export class SelectionStore {
|
|
@@ -46,6 +47,9 @@ export class SelectionStore {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
setNextFocus(focus) {
|
|
51
|
+
setStore(this.store, { nextFocus: focus });
|
|
52
|
+
}
|
|
49
53
|
setTempArea(range) {
|
|
50
54
|
setStore(this.store, { tempRange: range === null || range === void 0 ? void 0 : range.area, tempRangeType: range === null || range === void 0 ? void 0 : range.type, edit: null });
|
|
51
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.store.js","sourceRoot":"","sources":["../../../src/store/selection/selection.store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,SAAS,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QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,QAAc;QACxB,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,GAAqB;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,KAAK,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;aACtC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["/**\n * Selection store\n */\n\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { getRange } from '@store';\nimport { SelectionStoreState, Cell, TempRange, RangeArea } from '@type';\nimport { createStore } from '@stencil/store';\n\nfunction defaultState(): SelectionStoreState {\n return {\n range: null,\n tempRange: null,\n tempRangeType: null,\n focus: null,\n edit: null,\n lastCell: null,\n nextFocus: null,\n };\n}\n\nexport class SelectionStore {\n readonly store: Observable<SelectionStoreState>;\n private unsubscribe: { (): void }[] = [];\n constructor() {\n this.store = createStore(defaultState());\n this.store.on('set', (key, newVal) => {\n if (key === 'tempRange' && !newVal) {\n this.store.set('tempRangeType', null);\n }\n });\n }\n\n onChange<Key extends keyof SelectionStoreState>(propName: Key, cb: (newValue: SelectionStoreState[Key]) => void) {\n this.unsubscribe.push(this.store.onChange(propName, cb));\n }\n\n clearFocus() {\n setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });\n }\n\n setFocus(focus: Cell, end?: Cell) {\n if (!end) {\n setStore(this.store, { focus });\n } else {\n setStore(this.store, {\n focus,\n range: getRange(focus, end),\n edit: null,\n tempRange: null,\n });\n }\n }\n\n setNextFocus(focus: Cell) {\n setStore(this.store, { nextFocus: focus });\n }\n\n setTempArea(range: TempRange | null) {\n setStore(this.store, { tempRange: range?.area, tempRangeType: range?.type, edit: null });\n }\n\n clearTemp() {\n setStore(this.store, { tempRange: null });\n }\n\n /** Can be applied from selection change or from simple keyboard change clicks */\n setRangeArea(range: RangeArea) {\n setStore(this.store, { range, edit: null, tempRange: null });\n }\n setRange(start: Cell, end: Cell) {\n this.setRangeArea(getRange(start, end));\n }\n\n setLastCell(lastCell: Cell) {\n setStore(this.store, { lastCell });\n }\n\n setEdit(val: string | boolean) {\n const focus = this.store.get('focus');\n if (focus && typeof val === 'string') {\n setStore(this.store, {\n edit: { x: focus.x, y: focus.y, val },\n });\n return;\n }\n setStore(this.store, { edit: null });\n }\n\n dispose() {\n this.unsubscribe.forEach(f => f());\n this.store.dispose();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AA0PC,CAAC","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in @editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n * \n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: DataFormat;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config @filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check @cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in @columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n};\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat = any;\n\nexport type CellProp = string | number | object | boolean | undefined;\n\n/**\n * Additional properties applied to the cell.\n * Contains style object where key is CSS property and value is CSS property value.\n * Contains class object where key is CSS class and value is boolean flag indicating if class should be applied.\n * Contains additional properties for custom cell rendering.\n */\nexport type CellProps = {\n // CSS styles applied to the cell\n style?: {\n [key: string]: string | undefined;\n };\n // CSS classes applied to the cell\n class?:\n | {\n // CSS class name\n [key: string]: boolean;\n }\n | string;\n // Additional properties for custom cell rendering\n [attr: string]: CellProp;\n};\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: ColumnDataSchemaModel,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType = {\n [T in ColumnProp]: DataFormat;\n};\n\nexport type DataLookup = {\n [rowIndex: number]: DataType;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: Record<any, any>;\n\n /**\n * Object containing size for each visible item.\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n dataItem: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n /**\n * Represents the next cell to focus.\n */\n next?: Partial<Cell>;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AA0PC,CAAC","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in @editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n * \n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: DataFormat;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config @filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check @cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in @columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n};\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat = any;\n\nexport type CellProp = string | number | object | boolean | undefined;\n\n/**\n * Additional properties applied to the cell.\n * Contains style object where key is CSS property and value is CSS property value.\n * Contains class object where key is CSS class and value is boolean flag indicating if class should be applied.\n * Contains additional properties for custom cell rendering.\n */\nexport type CellProps = {\n // CSS styles applied to the cell\n style?: {\n [key: string]: string | undefined;\n };\n // CSS classes applied to the cell\n class?:\n | {\n // CSS class name\n [key: string]: boolean;\n }\n | string;\n // Additional properties for custom cell rendering\n [attr: string]: CellProp;\n};\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: ColumnDataSchemaModel,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType = {\n [T in ColumnProp]: DataFormat;\n};\n\nexport type DataLookup = {\n [rowIndex: number]: DataType;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: Record<any, any>;\n\n /**\n * Object containing size for each visible item.\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n model: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n /**\n * Changes for the next cell to focus. @example { y: -1 }\n */\n next?: Partial<Cell>;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interface for plugin components\n */\nexport interface PluginBaseComponent {\n /**\n * Cleans up plugin's resources\n */\n destroy(): void;\n}\n\n\n/**\n * Interface for plugin constructors\n *\n * @param revogrid - The RevoGrid component instance\n * @param ...[] - Additional parameters for the plugin constructor\n *\n * @returns The created plugin component instance\n */\nexport interface PluginConstructor {\n new (revogrid: HTMLRevoGridElement, ...[]: Iterable<any>): PluginBaseComponent;\n}\n\n/**\n * Interface for plugin constructors that expect a providers object\n *\n * @param revogrid - The RevoGrid component instance\n * @param providers - The providers object to inject into the plugin's template\n * @param ...[] - Additional parameters for the plugin constructor\n *\n * @returns The created plugin component instance\n */\nexport interface PluginExternalConstructor {\n new (revogrid: HTMLRevoGridElement, providers: Record<string, any>, ...[]: Iterable<any>): PluginBaseComponent;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.types.js","sourceRoot":"","sources":["../../src/types/plugin.types.ts"],"names":[],"mappings":"","sourcesContent":["import ColumnDataProvider from '../services/column.data.provider';\nimport { DataProvider } from '../services/data.provider';\nimport DimensionProvider from '../services/dimension.provider';\nimport SelectionStoreConnector from '../services/selection.store.connector';\nimport ViewportProvider from '../services/viewport.provider';\nexport type PluginProviders = {\n data: DataProvider;\n dimension: DimensionProvider;\n selection: SelectionStoreConnector;\n column: ColumnDataProvider;\n viewport: ViewportProvider;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.types.js","sourceRoot":"","sources":["../../src/types/plugin.types.ts"],"names":[],"mappings":"","sourcesContent":["import ColumnDataProvider from '../services/column.data.provider';\nimport { DataProvider } from '../services/data.provider';\nimport DimensionProvider from '../services/dimension.provider';\nimport SelectionStoreConnector from '../services/selection.store.connector';\nimport ViewportProvider from '../services/viewport.provider';\n\n/**\n * Services that are provided by the various plugins for use by the grid. Each plugin\n * is responsible for providing a specific service, and the `PluginProviders` type collects all the services provided\n * by the plugins.\n */\nexport type PluginProviders = {\n /**\n * The data service provides access to the grid data.\n */\n data: DataProvider;\n /**\n * The dimension service provides access to the grid's dimensions and settings.\n */\n dimension: DimensionProvider;\n /**\n * The selection service provides access to the grid's selection state.\n */\n selection: SelectionStoreConnector;\n /**\n * The column service provides access to the grid's column data.\n */\n column: ColumnDataProvider;\n /**\n * The viewport service provides access to the grid's viewport state.\n */\n viewport: ViewportProvider;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/types/selection.ts"],"names":[],"mappings":"","sourcesContent":["import { VNode } from '@stencil/core';\nimport { DimensionRows, DimensionCols } from './dimension';\nimport {\n ColumnProp,\n DataType,\n DataLookup,\n HyperFunc,\n ColumnDataSchemaModel,\n} from './interfaces';\n\nexport type RowIndex = number;\nexport type ColIndex = number;\nexport type SelectionStoreState = {\n range: RangeArea | null;\n tempRange: RangeArea | null;\n tempRangeType: string | null;\n focus: Cell | null;\n edit: EditCellStore | null;\n lastCell: Cell | null;\n};\nexport type RangeArea = {\n x: ColIndex;\n y: RowIndex;\n x1: ColIndex;\n y1: RowIndex;\n};\nexport type TempRange = {\n type: string;\n area: RangeArea;\n};\nexport type OldNewRangeMapping = {\n [rowIndex: number]: {\n [T in ColumnProp]: {\n rowIndex: number;\n colIndex: number;\n colProp: ColumnProp;\n };\n };\n};\nexport type ChangedRange = {\n type: DimensionRows;\n colType: DimensionCols;\n newRange: RangeArea;\n oldRange: RangeArea;\n mapping: OldNewRangeMapping;\n newData: {\n [key: number]: DataType;\n };\n};\n\n/**\n * Cell coordinates\n */\nexport interface Cell {\n x: ColIndex;\n y: RowIndex;\n}\nexport type FocusedCells = {\n focus: Cell;\n end: Cell;\n};\nexport type RangeAreaCss = {\n left: string;\n top: string;\n width: string;\n height: string;\n};\n\nexport type SaveData = string;\nexport type SaveDataDetails = {\n rgRow: RowIndex;\n rgCol: ColIndex;\n type: DimensionRows;\n prop: ColumnProp;\n val: any;\n preventFocus?: boolean;\n};\n\nexport type BeforeEdit = BeforeSaveDataDetails;\n\nexport type BeforeSaveDataDetails = {\n prop: ColumnProp;\n model: DataType;\n val?: SaveData;\n rowIndex: number;\n colIndex: number;\n colType: DimensionCols;\n type: DimensionRows;\n};\nexport type BeforeRangeSaveDataDetails = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n type: DimensionRows;\n};\n\nexport type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;\n\n/**\n * Edit cell info for store\n */\nexport interface EditCellStore extends Cell {\n val?: SaveData;\n}\n/**\n * Edit cell info for editor\n */\nexport type EditCell = EditCellStore & BeforeSaveDataDetails;\n\n/**\n * Available editors in grid\n */\nexport type Editors = {\n [name: string]: EditorCtr;\n};\n\n/**\n * Editor component\n */\nexport type EditorCtr = EditorCtrCallable | EditorCtrConstructible;\n\n\n/**\n * Editor component callable function\n */\nexport type EditorCtrCallable = {\n (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n/**\n * Editor component constructible class\n */\nexport interface EditorCtrConstructible {\n new (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n\n/**\n * Editor interface\n */\nexport interface EditorBase {\n element?: Element | null;\n editCell?: EditCell;\n /**\n * Autosave usage when you want to return value for models.\n */\n getValue?(): any;\n /**\n * For Editor plugin internal usage.\n * Prevents Editor save. Manual save usage required.\n */\n beforeAutoSave?(val?: any): boolean;\n beforeUpdate?(): void;\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n beforeDisconnect?(): void;\n componentDidRender?(): void;\n disconnectedCallback?(): void;\n render(\n createElement?: HyperFunc<VNode>,\n additionalData?: any,\n ): VNode | VNode[] | string | void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/types/selection.ts"],"names":[],"mappings":"","sourcesContent":["import { VNode } from '@stencil/core';\nimport { DimensionRows, DimensionCols } from './dimension';\nimport {\n ColumnProp,\n DataType,\n DataLookup,\n HyperFunc,\n ColumnDataSchemaModel,\n} from './interfaces';\n\nexport type RowIndex = number;\nexport type ColIndex = number;\n\n/**\n * Represents the state of the selection store.\n * It contains information about the selection range, temporary range,\n * focused cell, editing cell, last focused cell, and next cell to focus.\n */\nexport type SelectionStoreState = {\n range: RangeArea | null;\n /**\n * Temporary range selection area\n */\n tempRange: RangeArea | null;\n /**\n * Type of the temporary range selection\n */\n tempRangeType: string | null;\n /**\n * Focused cell coordinate\n */\n focus: Cell | null;\n /**\n * Editing cell store\n */\n edit: EditCellStore | null;\n /**\n * Last cell which was focused\n */\n lastCell: Cell | null;\n /**\n * Next cell to focus\n */\n nextFocus: Cell | null;\n};\nexport type RangeArea = {\n x: ColIndex;\n y: RowIndex;\n x1: ColIndex;\n y1: RowIndex;\n};\nexport type TempRange = {\n type: string;\n area: RangeArea;\n};\nexport type OldNewRangeMapping = {\n [rowIndex: number]: {\n [T in ColumnProp]: {\n rowIndex: number;\n colIndex: number;\n colProp: ColumnProp;\n };\n };\n};\nexport type ChangedRange = {\n type: DimensionRows;\n colType: DimensionCols;\n newRange: RangeArea;\n oldRange: RangeArea;\n mapping: OldNewRangeMapping;\n newData: {\n [key: number]: DataType;\n };\n};\n\n/**\n * Cell coordinates\n */\nexport interface Cell {\n x: ColIndex;\n y: RowIndex;\n}\nexport type FocusedCells = {\n focus: Cell;\n end: Cell;\n};\nexport type RangeAreaCss = {\n left: string;\n top: string;\n width: string;\n height: string;\n};\n\nexport type SaveData = string;\nexport type SaveDataDetails = {\n rgRow: RowIndex;\n rgCol: ColIndex;\n type: DimensionRows;\n prop: ColumnProp;\n val: any;\n preventFocus?: boolean;\n};\n\nexport type BeforeEdit = BeforeSaveDataDetails;\n\nexport type BeforeSaveDataDetails = {\n prop: ColumnProp;\n model: DataType;\n val?: SaveData;\n rowIndex: number;\n colIndex: number;\n colType: DimensionCols;\n type: DimensionRows;\n};\nexport type BeforeRangeSaveDataDetails = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n type: DimensionRows;\n};\n\nexport type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;\n\n/**\n * Edit cell info for store\n */\nexport interface EditCellStore extends Cell {\n val?: SaveData;\n}\n/**\n * Edit cell info for editor\n */\nexport type EditCell = EditCellStore & BeforeSaveDataDetails;\n\n/**\n * Available editors in grid\n */\nexport type Editors = {\n [name: string]: EditorCtr;\n};\n\n/**\n * Editor component\n */\nexport type EditorCtr = EditorCtrCallable | EditorCtrConstructible;\n\n\n/**\n * Editor component callable function\n */\nexport type EditorCtrCallable = {\n (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n/**\n * Editor component constructible class\n */\nexport interface EditorCtrConstructible {\n new (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n\n/**\n * Editor interface\n */\nexport interface EditorBase {\n element?: Element | null;\n editCell?: EditCell;\n /**\n * Autosave usage when you want to return value for models.\n */\n getValue?(): any;\n /**\n * For Editor plugin internal usage.\n * Prevents Editor save. Manual save usage required.\n */\n beforeAutoSave?(val?: any): boolean;\n beforeUpdate?(): void;\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n beforeDisconnect?(): void;\n componentDidRender?(): void;\n disconnectedCallback?(): void;\n render(\n createElement?: HyperFunc<VNode>,\n additionalData?: any,\n ): VNode | VNode[] | string | void;\n}\n"]}
|
|
@@ -53,7 +53,7 @@ var codes;
|
|
|
53
53
|
codes[codes["V"] = 86] = "V";
|
|
54
54
|
codes[codes["X"] = 88] = "X";
|
|
55
55
|
})(codes || (codes = {}));
|
|
56
|
-
var codesLetter;
|
|
56
|
+
export var codesLetter;
|
|
57
57
|
(function (codesLetter) {
|
|
58
58
|
codesLetter["ENTER"] = "Enter";
|
|
59
59
|
codesLetter["ENTER_NUM"] = "NumpadEnter";
|
|
@@ -71,6 +71,10 @@ var codesLetter;
|
|
|
71
71
|
codesLetter["ARROW_DOWN"] = "ArrowDown";
|
|
72
72
|
codesLetter["SHIFT"] = "Shift";
|
|
73
73
|
})(codesLetter || (codesLetter = {}));
|
|
74
|
+
export var keyValues;
|
|
75
|
+
(function (keyValues) {
|
|
76
|
+
keyValues["ENTER"] = "Enter";
|
|
77
|
+
keyValues["TAB"] = "Tab";
|
|
78
|
+
})(keyValues || (keyValues = {}));
|
|
74
79
|
export default codes;
|
|
75
|
-
export { codesLetter };
|
|
76
80
|
//# sourceMappingURL=key.codes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.codes.js","sourceRoot":"","sources":["../../src/utils/key.codes.ts"],"names":[],"mappings":"AAAA,IAAK,KAkDJ;AAlDD,WAAK,KAAK;IACR,6CAAc,CAAA;IACd,+CAAe,CAAA;IACf,iDAAgB,CAAA;IAChB,2CAAa,CAAA;IACb,qCAAW,CAAA;IACX,sCAAW,CAAA;IACX,sCAAW,CAAA;IACX,gCAAQ,CAAA;IACR,oCAAU,CAAA;IACV,sCAAW,CAAA;IACX,wCAAY,CAAA;IACZ,kDAAiB,CAAA;IACjB,oDAAkB,CAAA;IAClB,yDAAqB,CAAA;IACrB,gCAAQ,CAAA;IACR,kCAAS,CAAA;IACT,4CAAc,CAAA;IACd,wCAAY,CAAA;IACZ,uCAAY,CAAA;IACZ,oCAAU,CAAA;IACV,oCAAU,CAAA;IACV,4CAAc,CAAA;IACd,+BAAO,CAAA;IACP,gDAAgB,CAAA;IAChB,8CAAe,CAAA;IACf,0CAAa,CAAA;IACb,8CAAe,CAAA;IACf,+BAAQ,CAAA;IACR,+BAAQ,CAAA;IACR,+BAAQ,CAAA;I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;IACT,iCAAS,CAAA;IACT,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;IACN,4BAAM,CAAA;AACR,CAAC,EAlDI,KAAK,KAAL,KAAK,QAkDT;AAED,MAAM,CAAN,IAAY,WAgBX;AAhBD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,yBAAU,CAAA;IACV,yBAAU,CAAA;IACV,yBAAU,CAAA;IACV,yBAAU,CAAA;IACV,gCAAiB,CAAA;IACjB,0BAAW,CAAA;IACX,sCAAuB,CAAA;IACvB,gCAAiB,CAAA;IACjB,yCAA0B,CAAA;IAC1B,uCAAwB,CAAA;IACxB,mCAAoB,CAAA;IACpB,uCAAwB,CAAA;IACxB,8BAAe,CAAA;AACjB,CAAC,EAhBW,WAAW,KAAX,WAAW,QAgBtB;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,wBAAW,CAAA;AACb,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,eAAe,KAAK,CAAC","sourcesContent":["enum codes {\n MOUSE_LEFT = 1,\n MOUSE_RIGHT = 3,\n MOUSE_MIDDLE = 2,\n BACKSPACE = 8,\n COMMA = 188,\n INSERT = 45,\n DELETE = 46,\n END = 35,\n ENTER = 13,\n ESCAPE = 27,\n CONTROL = 17,\n COMMAND_LEFT = 91,\n COMMAND_RIGHT = 93,\n COMMAND_FIREFOX = 224,\n ALT = 18,\n HOME = 36,\n PAGE_DOWN = 34,\n PAGE_UP = 33,\n PERIOD = 190,\n SPACE = 32,\n SHIFT = 16,\n CAPS_LOCK = 20,\n TAB = 9,\n ARROW_RIGHT = 39,\n ARROW_LEFT = 37,\n ARROW_UP = 38,\n ARROW_DOWN = 40,\n F1 = 112,\n F2 = 113,\n F3 = 114,\n F4 = 115,\n F5 = 116,\n F6 = 117,\n F7 = 118,\n F8 = 119,\n F9 = 120,\n F10 = 121,\n F11 = 122,\n F12 = 123,\n A = 65,\n C = 67,\n D = 68,\n F = 70,\n L = 76,\n O = 79,\n P = 80,\n S = 83,\n V = 86,\n X = 88,\n}\n\nexport enum codesLetter {\n ENTER = 'Enter',\n ENTER_NUM = 'NumpadEnter',\n A = 'KeyA',\n C = 'KeyC',\n X = 'KeyX',\n V = 'KeyV',\n ESCAPE = 'Escape',\n TAB = 'Tab',\n BACKSPACE = 'Backspace',\n DELETE = 'Delete',\n ARROW_RIGHT = 'ArrowRight',\n ARROW_LEFT = 'ArrowLeft',\n ARROW_UP = 'ArrowUp',\n ARROW_DOWN = 'ArrowDown',\n SHIFT = 'Shift',\n}\n\nexport enum keyValues {\n ENTER = 'Enter', // Enter + NumpadEnter\n TAB = 'Tab',\n}\n\nexport default codes;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import KeyCodesEnum, { codesLetter } from "./key.codes";
|
|
4
|
+
import KeyCodesEnum, { codesLetter, keyValues } from "./key.codes";
|
|
5
5
|
import OsPlatform from "./platform";
|
|
6
6
|
import includes from "lodash/includes";
|
|
7
7
|
export function isLetterKey(code) {
|
|
@@ -49,12 +49,21 @@ export function isMetaKey(code) {
|
|
|
49
49
|
// navigator.platform
|
|
50
50
|
export function isCtrlKey(code, platform) {
|
|
51
51
|
if (platform.includes(OsPlatform.mac)) {
|
|
52
|
-
return includes([
|
|
52
|
+
return includes([
|
|
53
|
+
KeyCodesEnum.COMMAND_LEFT,
|
|
54
|
+
KeyCodesEnum.COMMAND_RIGHT,
|
|
55
|
+
KeyCodesEnum.COMMAND_FIREFOX,
|
|
56
|
+
], code);
|
|
53
57
|
}
|
|
54
58
|
return KeyCodesEnum.CONTROL === code;
|
|
55
59
|
}
|
|
56
60
|
export function isCtrlMetaKey(code) {
|
|
57
|
-
return includes([
|
|
61
|
+
return includes([
|
|
62
|
+
KeyCodesEnum.CONTROL,
|
|
63
|
+
KeyCodesEnum.COMMAND_LEFT,
|
|
64
|
+
KeyCodesEnum.COMMAND_RIGHT,
|
|
65
|
+
KeyCodesEnum.COMMAND_FIREFOX,
|
|
66
|
+
], code);
|
|
58
67
|
}
|
|
59
68
|
export function isClear(code) {
|
|
60
69
|
return codesLetter.BACKSPACE === code || codesLetter.DELETE === code;
|
|
@@ -62,23 +71,26 @@ export function isClear(code) {
|
|
|
62
71
|
export function isTab(code) {
|
|
63
72
|
return codesLetter.TAB === code;
|
|
64
73
|
}
|
|
65
|
-
export function
|
|
66
|
-
return
|
|
74
|
+
export function isTabKeyValue(key) {
|
|
75
|
+
return keyValues.TAB === key;
|
|
76
|
+
}
|
|
77
|
+
export function isEnterKeyValue(key) {
|
|
78
|
+
return keyValues.ENTER === key;
|
|
67
79
|
}
|
|
68
80
|
export function isCut(event) {
|
|
69
|
-
return (event.ctrlKey && event.code === 'KeyX') || // Ctrl + X on Windows
|
|
70
|
-
(event.metaKey && event.code === 'KeyX'); // Cmd + X on Mac
|
|
81
|
+
return ((event.ctrlKey && event.code === 'KeyX') || // Ctrl + X on Windows
|
|
82
|
+
(event.metaKey && event.code === 'KeyX')); // Cmd + X on Mac
|
|
71
83
|
}
|
|
72
84
|
export function isCopy(event) {
|
|
73
|
-
return (event.ctrlKey && event.code === 'KeyC') || // Ctrl + C on Windows
|
|
74
|
-
(event.metaKey && event.code === 'KeyC'); // Cmd + C on Mac
|
|
85
|
+
return ((event.ctrlKey && event.code === 'KeyC') || // Ctrl + C on Windows
|
|
86
|
+
(event.metaKey && event.code === 'KeyC')); // Cmd + C on Mac
|
|
75
87
|
}
|
|
76
88
|
export function isPaste(event) {
|
|
77
|
-
return (event.ctrlKey && event.code === 'KeyV') || // Ctrl + V on Windows
|
|
78
|
-
(event.metaKey && event.code === 'KeyV'); // Cmd + V on Mac
|
|
89
|
+
return ((event.ctrlKey && event.code === 'KeyV') || // Ctrl + V on Windows
|
|
90
|
+
(event.metaKey && event.code === 'KeyV')); // Cmd + V on Mac
|
|
79
91
|
}
|
|
80
92
|
export function isAll(event) {
|
|
81
|
-
return (event.ctrlKey && event.code === 'KeyA') || // Ctrl + A on Windows
|
|
82
|
-
(event.metaKey && event.code === 'KeyA'); // Cmd + A on Mac
|
|
93
|
+
return ((event.ctrlKey && event.code === 'KeyA') || // Ctrl + A on Windows
|
|
94
|
+
(event.metaKey && event.code === 'KeyA')); // Cmd + A on Mac
|
|
83
95
|
}
|
|
84
96
|
//# sourceMappingURL=key.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.utils.js","sourceRoot":"","sources":["../../src/utils/key.utils.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"key.utils.js","sourceRoot":"","sources":["../../src/utils/key.utils.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,CACL,IAAI,KAAK,EAAE,IAAI,QAAQ;QACvB,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;QAC1B,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC;QAC3B,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC;QAC5B,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC;QAC5B,IAAI,IAAI,GAAG;QACX,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,CAC3B,CAAC,CAAC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I,KAAK,MAAM,CAAC,CACzC,CAAC,CAAC,iBAAiB;AACtB,CAAC;AACD,MAAM,UAAU,KAAK,CAAC,KAAoB;IACxC,OAAO,CACL,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,sBAAsB;QAClE,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CACzC,CAAC,CAAC,iBAAiB;AACtB,CAAC","sourcesContent":["import KeyCodesEnum, { codesLetter, keyValues } from './key.codes';\nimport OsPlatform from './platform';\nimport includes from 'lodash/includes';\n\nexport function isLetterKey(code: number): boolean {\n return (\n code === 32 || // space\n (code >= 48 && code <= 57) ||\n (code >= 96 && code <= 111) ||\n (code >= 186 && code <= 192) ||\n (code >= 219 && code <= 222) ||\n code >= 226 ||\n (code >= 65 && code <= 90)\n ); // a-z\n}\n\nexport function isMetaKey(code: number): boolean {\n const keys: KeyCodesEnum[] = [\n KeyCodesEnum.ARROW_DOWN,\n KeyCodesEnum.ARROW_UP,\n KeyCodesEnum.ARROW_LEFT,\n KeyCodesEnum.ARROW_RIGHT,\n KeyCodesEnum.HOME,\n KeyCodesEnum.END,\n KeyCodesEnum.DELETE,\n KeyCodesEnum.BACKSPACE,\n KeyCodesEnum.F1,\n KeyCodesEnum.F2,\n KeyCodesEnum.F3,\n KeyCodesEnum.F4,\n KeyCodesEnum.F5,\n KeyCodesEnum.F6,\n KeyCodesEnum.F7,\n KeyCodesEnum.F8,\n KeyCodesEnum.F9,\n KeyCodesEnum.F10,\n KeyCodesEnum.F11,\n KeyCodesEnum.F12,\n KeyCodesEnum.TAB,\n KeyCodesEnum.PAGE_DOWN,\n KeyCodesEnum.PAGE_UP,\n KeyCodesEnum.ENTER,\n KeyCodesEnum.ESCAPE,\n KeyCodesEnum.SHIFT,\n KeyCodesEnum.CAPS_LOCK,\n KeyCodesEnum.ALT,\n ];\n\n return keys.indexOf(code) !== -1;\n}\n\n// navigator.platform\nexport function isCtrlKey(code: number, platform: string): boolean {\n if (platform.includes(OsPlatform.mac)) {\n return includes(\n [\n KeyCodesEnum.COMMAND_LEFT,\n KeyCodesEnum.COMMAND_RIGHT,\n KeyCodesEnum.COMMAND_FIREFOX,\n ],\n code,\n );\n }\n\n return KeyCodesEnum.CONTROL === code;\n}\n\nexport function isCtrlMetaKey(code: KeyCodesEnum): boolean {\n return includes(\n [\n KeyCodesEnum.CONTROL,\n KeyCodesEnum.COMMAND_LEFT,\n KeyCodesEnum.COMMAND_RIGHT,\n KeyCodesEnum.COMMAND_FIREFOX,\n ],\n code,\n );\n}\n\nexport function isClear(code: string): boolean {\n return codesLetter.BACKSPACE === code || codesLetter.DELETE === code;\n}\n\nexport function isTab(code: string): boolean {\n return codesLetter.TAB === code;\n}\nexport function isTabKeyValue(key: string): boolean {\n return keyValues.TAB === key;\n}\n\nexport function isEnterKeyValue(key: string): boolean {\n return keyValues.ENTER === key;\n}\n\nexport function isCut(event: KeyboardEvent): boolean {\n return (\n (event.ctrlKey && event.code === 'KeyX') || // Ctrl + X on Windows\n (event.metaKey && event.code === 'KeyX')\n ); // Cmd + X on Mac\n}\nexport function isCopy(event: KeyboardEvent): boolean {\n return (\n (event.ctrlKey && event.code === 'KeyC') || // Ctrl + C on Windows\n (event.metaKey && event.code === 'KeyC')\n ); // Cmd + C on Mac\n}\nexport function isPaste(event: KeyboardEvent): boolean {\n return (\n (event.ctrlKey && event.code === 'KeyV') || // Ctrl + V on Windows\n (event.metaKey && event.code === 'KeyV')\n ); // Cmd + V on Mac\n}\nexport function isAll(event: KeyboardEvent): boolean {\n return (\n (event.ctrlKey && event.code === 'KeyA') || // Ctrl + A on Windows\n (event.metaKey && event.code === 'KeyA')\n ); // Cmd + A on Mac\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"base.plugin-e6e2bac2.js","mappings":";;;;;;;AAAA;;;;AAuBA,MAAM,aAAa,GAAG,CACpB,KAAqB;IAErB,IAA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/dimension/dimension.store.ts","src/store/index.ts","src/plugins/base.plugin.ts"],"sourcesContent":["/**\n * Storing pre-calculated\n * Dimension information and sizes\n */\nimport reduce from 'lodash/reduce';\nimport { createStore } from '@stencil/store';\n\nimport { setStore, Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport each from 'lodash/each';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nconst trimmedPlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n let trimmedSize: DimensionSettingsState['sizes'] = {};\n\n const setTrimmed = (\n sizes: DimensionSettingsState['sizes'],\n trimmed: DimensionSettingsState['trimmed'],\n ) => {\n const newSize = { ...sizes };\n trimmedSize = {};\n each(trimmed, (v, index) => {\n if (v && newSize[index]) {\n trimmedSize[index] = newSize[index];\n delete newSize[index];\n }\n });\n store.setDimensionSize(newSize);\n };\n return {\n set(key, val) {\n switch (key) {\n case 'trimmed':\n const trim = val as DimensionSettingsState['trimmed'];\n const sizes = store.store.get('sizes');\n // recover trimmed, apply new trim\n setTrimmed({ ...sizes, ...trimmedSize }, trim);\n break;\n }\n },\n };\n};\n\nconst realSizePlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n return {\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n let realSize = 0;\n const count = store.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n store.store.get('sizes')[i] || store.store.get('originItemSize');\n }\n store.setStore({ realSize });\n }\n },\n };\n};\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // plugin support\n trimmed: {},\n\n // size operations, this provider stores only changed sizes, not all of them\n // same as indexes but for sizes and positions\n // item index to size\n sizes: {},\n // order in indexes[] to coordinate\n positionIndexToItem: {},\n // initial element to coordinate ^\n indexToItem: {},\n positionIndexes: [],\n };\n}\n\nfunction initialState(): DimensionSettingsState {\n return {\n ...initialBase(),\n // size which all items can take\n realSize: 0,\n\n // initial item size if it wasn't changed\n originItemSize: 0,\n };\n}\n\nexport class DimensionStore {\n readonly store: Observable<DimensionSettingsState>;\n constructor() {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(realSizePlugin(this));\n }\n\n getCurrentState(): DimensionSettingsState {\n const state = initialState();\n const keys = Object.keys(state);\n return reduce(\n keys,\n (r: DimensionSettingsState, k: Item) => {\n const data = this.store.get(k);\n r[k] = data as never;\n return r;\n },\n state,\n );\n }\n\n dispose() {\n setStore(this.store, initialState());\n }\n\n setStore<T extends Record<string, any>>(data: Partial<T>) {\n setStore(this.store, data);\n }\n\n drop() {\n setStore(this.store, initialBase());\n }\n\n /**\n * Set custom dimension sizes and overwrite old\n * Generates new indexes based on sizes\n * @param sizes - sizes to set\n */\n setDimensionSize(sizes: ViewSettingSizeProp) {\n const dimensionData = calculateDimensionData(\n this.store.get('originItemSize'),\n sizes,\n );\n setStore(this.store, dimensionData);\n }\n}\n","import type { DimensionCols, DimensionRows } from '@type';\n\nexport * from './dataSource';\nexport * from './dimension';\nexport * from './selection';\nexport * from './vp';\n\nexport const rowTypes: DimensionRows[] = ['rowPinStart', 'rgRow', 'rowPinEnd'];\nexport const columnTypes: DimensionCols[] = [\n 'colPinStart',\n 'rgCol',\n 'colPinEnd',\n];\n\nexport function isRowType(type: DimensionRows | any): type is DimensionRows {\n return rowTypes.indexOf(type) > -1;\n}\n","import { PluginProviders, PluginBaseComponent } from '..';\n\ntype WatchConfig = { immediate: boolean };\n\n/**\n * Base layer for plugins\n * Provide minimal starting core for plugins to work\n * Extend this class to create plugin\n */\nexport class BasePlugin implements PluginBaseComponent {\n protected readonly subscriptions: Record<string, (...args: any[]) => void> = {};\n constructor(protected revogrid: HTMLRevoGridElement, protected providers: PluginProviders) {}\n /**\n *\n * @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')\n * @param callback - callback function for event\n */\n protected addEventListener(\n eventName: string,\n callback: (e: CustomEvent) => void,\n ) {\n this.revogrid.addEventListener(eventName, callback);\n this.subscriptions[eventName] = callback;\n }\n\n /**\n * Subscribe to property change in revo-grid component\n * You can return false in callback to prevent default value set\n *\n * @param prop - property name\n * @param callback - callback function\n * @param immediate - trigger callback immediately with current value\n */\n protected watch<T extends any>(\n prop: string,\n callback: (arg: T) => boolean | void,\n { immediate }: Partial<WatchConfig> = { immediate: false },\n ) {\n const nativeValueDesc =\n Object.getOwnPropertyDescriptor(this.revogrid, prop) ||\n Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);\n\n // Overwrite property descriptor for this instance\n Object.defineProperty(this.revogrid, prop, {\n set(val: T) {\n const keepDefault = callback(val);\n if (keepDefault === false) {\n return;\n }\n // Continue with native behavior\n return nativeValueDesc?.set?.call(this, val);\n },\n get() {\n // Continue with native behavior\n return nativeValueDesc?.get?.call(this);\n },\n });\n if (immediate) {\n callback(nativeValueDesc?.value);\n }\n }\n\n /**\n * Remove event listener\n * @param eventName\n */\n protected removeEventListener(eventName: string) {\n this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);\n delete this.subscriptions[eventName];\n }\n\n /**\n * Emit event from revo-grid component\n * Event can be cancelled by calling event.preventDefault() in callback\n */\n protected emit(eventName: string, detail?: any) {\n const event = new CustomEvent(eventName, { detail, cancelable: true });\n this.revogrid.dispatchEvent(event);\n return event;\n }\n\n /**\n * Clear all subscriptions\n */\n protected clearSubscriptions() {\n for (let type in this.subscriptions) {\n this.removeEventListener(type);\n }\n }\n\n /**\n * Destroy plugin and clear all subscriptions\n */\n destroy() {\n this.clearSubscriptions();\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"base.plugin-e6e2bac2.js","mappings":";;;;;;;AAAA;;;;AAuBA,MAAM,aAAa,GAAG,CACpB,KAAqB;IAErB,IAAI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ension/dimension.store.ts","src/store/index.ts","src/plugins/base.plugin.ts"],"sourcesContent":["/**\n * Storing pre-calculated\n * Dimension information and sizes\n */\nimport reduce from 'lodash/reduce';\nimport { createStore } from '@stencil/store';\n\nimport { setStore, Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport each from 'lodash/each';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nconst trimmedPlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n let trimmedSize: DimensionSettingsState['sizes'] = {};\n\n const setTrimmed = (\n sizes: DimensionSettingsState['sizes'],\n trimmed: DimensionSettingsState['trimmed'],\n ) => {\n const newSize = { ...sizes };\n trimmedSize = {};\n each(trimmed, (v, index) => {\n if (v && newSize[index]) {\n trimmedSize[index] = newSize[index];\n delete newSize[index];\n }\n });\n store.setDimensionSize(newSize);\n };\n return {\n set(key, val) {\n switch (key) {\n case 'trimmed':\n const trim = val as DimensionSettingsState['trimmed'];\n const sizes = store.store.get('sizes');\n // recover trimmed, apply new trim\n setTrimmed({ ...sizes, ...trimmedSize }, trim);\n break;\n }\n },\n };\n};\n\nconst realSizePlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n return {\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n let realSize = 0;\n const count = store.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n store.store.get('sizes')[i] || store.store.get('originItemSize');\n }\n store.setStore({ realSize });\n }\n },\n };\n};\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // plugin support\n trimmed: {},\n\n // size operations, this provider stores only changed sizes, not all of them\n // same as indexes but for sizes and positions\n // item index to size\n sizes: {},\n // order in indexes[] to coordinate\n positionIndexToItem: {},\n // initial element to coordinate ^\n indexToItem: {},\n positionIndexes: [],\n };\n}\n\nfunction initialState(): DimensionSettingsState {\n return {\n ...initialBase(),\n // size which all items can take\n realSize: 0,\n\n // initial item size if it wasn't changed\n originItemSize: 0,\n };\n}\n\nexport class DimensionStore {\n readonly store: Observable<DimensionSettingsState>;\n constructor() {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(realSizePlugin(this));\n }\n\n getCurrentState(): DimensionSettingsState {\n const state = initialState();\n const keys = Object.keys(state);\n return reduce(\n keys,\n (r: DimensionSettingsState, k: Item) => {\n const data = this.store.get(k);\n r[k] = data as never;\n return r;\n },\n state,\n );\n }\n\n dispose() {\n setStore(this.store, initialState());\n }\n\n setStore<T extends Record<string, any>>(data: Partial<T>) {\n setStore(this.store, data);\n }\n\n drop() {\n setStore(this.store, initialBase());\n }\n\n /**\n * Set custom dimension sizes and overwrite old\n * Generates new indexes based on sizes\n * @param sizes - sizes to set\n */\n setDimensionSize(sizes: ViewSettingSizeProp) {\n const dimensionData = calculateDimensionData(\n this.store.get('originItemSize'),\n sizes,\n );\n setStore(this.store, dimensionData);\n }\n}\n","import type { DimensionCols, DimensionRows } from '@type';\n\nexport * from './dataSource';\nexport * from './dimension';\nexport * from './selection';\nexport * from './vp';\n\nexport const rowTypes: DimensionRows[] = ['rowPinStart', 'rgRow', 'rowPinEnd'];\nexport const columnTypes: DimensionCols[] = [\n 'colPinStart',\n 'rgCol',\n 'colPinEnd',\n];\n\nexport function isRowType(type: DimensionRows | any): type is DimensionRows {\n return rowTypes.indexOf(type) > -1;\n}\n","import { PluginProviders, PluginBaseComponent } from '..';\n\ntype WatchConfig = { immediate: boolean };\n\n/**\n * Base layer for plugins\n * Provide minimal starting core for plugins to work\n * Extend this class to create plugin\n */\nexport class BasePlugin implements PluginBaseComponent {\n readonly subscriptions: Record<string, (...args: any[]) => void> = {};\n constructor(public revogrid: HTMLRevoGridElement, public providers: PluginProviders) {}\n /**\n *\n * @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')\n * @param callback - callback function for event\n */\n addEventListener(\n eventName: string,\n callback: (e: CustomEvent) => void,\n ) {\n this.revogrid.addEventListener(eventName, callback);\n this.subscriptions[eventName] = callback;\n }\n\n /**\n * Subscribe to property change in revo-grid component\n * You can return false in callback to prevent default value set\n *\n * @param prop - property name\n * @param callback - callback function\n * @param immediate - trigger callback immediately with current value\n */\n watch<T extends any>(\n prop: string,\n callback: (arg: T) => boolean | void,\n { immediate }: Partial<WatchConfig> = { immediate: false },\n ) {\n const nativeValueDesc =\n Object.getOwnPropertyDescriptor(this.revogrid, prop) ||\n Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);\n\n // Overwrite property descriptor for this instance\n Object.defineProperty(this.revogrid, prop, {\n set(val: T) {\n const keepDefault = callback(val);\n if (keepDefault === false) {\n return;\n }\n // Continue with native behavior\n return nativeValueDesc?.set?.call(this, val);\n },\n get() {\n // Continue with native behavior\n return nativeValueDesc?.get?.call(this);\n },\n });\n if (immediate) {\n callback(nativeValueDesc?.value);\n }\n }\n\n /**\n * Remove event listener\n * @param eventName\n */\n removeEventListener(eventName: string) {\n this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);\n delete this.subscriptions[eventName];\n }\n\n /**\n * Emit event from revo-grid component\n * Event can be cancelled by calling event.preventDefault() in callback\n */\n emit(eventName: string, detail?: any) {\n const event = new CustomEvent(eventName, { detail, cancelable: true });\n this.revogrid.dispatchEvent(event);\n return event;\n }\n\n /**\n * Clear all subscriptions\n */\n clearSubscriptions() {\n for (let type in this.subscriptions) {\n this.removeEventListener(type);\n }\n }\n\n /**\n * Destroy plugin and clear all subscriptions\n */\n destroy() {\n this.clearSubscriptions();\n }\n}\n"],"version":3}
|