@ng-atomic/common 18.10.0 → 18.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/directives/molecules/column/column.molecule.d.ts +66 -0
- package/directives/molecules/column/index.d.ts +1 -0
- package/directives/resize-column/index.d.ts +1 -0
- package/directives/resize-column/resize-column.directive.d.ts +21 -0
- package/directives/resize-column/resize-handle.component.d.ts +5 -0
- package/esm2022/directives/molecules/column/column.molecule.mjs +112 -0
- package/esm2022/directives/molecules/column/index.mjs +2 -0
- package/esm2022/directives/molecules/column/ng-atomic-common-directives-molecules-column.mjs +5 -0
- package/esm2022/directives/resize-column/index.mjs +2 -0
- package/esm2022/directives/resize-column/ng-atomic-common-directives-resize-column.mjs +5 -0
- package/esm2022/directives/resize-column/resize-column.directive.mjs +62 -0
- package/esm2022/directives/resize-column/resize-handle.component.mjs +13 -0
- package/esm2022/models/index.mjs +1 -1
- package/esm2022/pipes/actions/actions.pipe.mjs +1 -1
- package/esm2022/pipes/columns/columns.pipe.mjs +3 -2
- package/esm2022/pipes/data-accessor/data-accessor.pipe.mjs +16 -3
- package/esm2022/pipes/domain/domain.pipe.mjs +22 -26
- package/esm2022/pipes/error/error.pipe.mjs +1 -2
- package/esm2022/pipes/expression/expression.pipe.mjs +18 -0
- package/esm2022/pipes/expression/index.mjs +2 -0
- package/esm2022/pipes/expression/ng-atomic-common-pipes-expression.mjs +5 -0
- package/esm2022/pipes/smart-field/smart-field.pipe.mjs +15 -4
- package/esm2022/pipes/style/index.mjs +2 -0
- package/esm2022/pipes/style/ng-atomic-common-pipes-style.mjs +5 -0
- package/esm2022/pipes/style/style.pipe.mjs +41 -0
- package/esm2022/services/form/columns/columns.service.mjs +28 -21
- package/esm2022/services/form/json-schema/json-schema.service.mjs +77 -58
- package/esm2022/services/form/pagination/pagination.service.mjs +4 -4
- package/esm2022/services/language/index.mjs +2 -0
- package/esm2022/services/language/language.service.mjs +39 -0
- package/esm2022/services/language/ng-atomic-common-services-language.mjs +5 -0
- package/esm2022/services/loading/loading.service.mjs +2 -2
- package/esm2022/services/query-resolver/query-resolver.service.mjs +4 -5
- package/esm2022/services/snack-bar/snack-bar.service.mjs +29 -11
- package/esm2022/services/spreadsheet/directives/grid-cell.directive.mjs +124 -0
- package/esm2022/services/spreadsheet/directives/index.mjs +2 -0
- package/esm2022/services/spreadsheet/features/clipboard.service.mjs +71 -0
- package/esm2022/services/spreadsheet/features/data.service.mjs +63 -0
- package/esm2022/services/spreadsheet/features/editor.service.mjs +65 -0
- package/esm2022/services/spreadsheet/features/grid.service.mjs +54 -0
- package/esm2022/services/spreadsheet/features/index.mjs +8 -0
- package/esm2022/services/spreadsheet/features/navigation.service.mjs +71 -0
- package/esm2022/services/spreadsheet/features/protection.service.mjs +25 -0
- package/esm2022/services/spreadsheet/features/selection.service.mjs +129 -0
- package/esm2022/services/spreadsheet/index.mjs +5 -0
- package/esm2022/services/spreadsheet/models/cell.model.mjs +2 -0
- package/esm2022/services/spreadsheet/models/index.mjs +2 -0
- package/esm2022/services/spreadsheet/ng-atomic-common-services-spreadsheet.mjs +5 -0
- package/esm2022/services/spreadsheet/spreadsheet.service.mjs +183 -0
- package/esm2022/services/ui/ui.helpers.mjs +15 -8
- package/esm2022/stores/query/query.store.mjs +2 -2
- package/esm2022/utils/expression/expression.transformer.mjs +38 -0
- package/esm2022/utils/expression/index.mjs +2 -0
- package/esm2022/utils/get/get.mjs +2 -2
- package/esm2022/utils/index.mjs +2 -2
- package/esm2022/utils/inject/inject.mjs +1 -1
- package/fesm2022/ng-atomic-common-directives-fallback-src.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-directives-ios-safari-scroll-buggyfill.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-directives-molecules-column.mjs +119 -0
- package/fesm2022/ng-atomic-common-directives-molecules-column.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-directives-resize-column.mjs +79 -0
- package/fesm2022/ng-atomic-common-directives-resize-column.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-interceptors-authorization.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-interceptors-throttle.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-interceptors-token.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-interceptors.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-actions.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-auto-columns.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-columns.mjs +2 -1
- package/fesm2022/ng-atomic-common-pipes-columns.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-data-accessor.mjs +15 -2
- package/fesm2022/ng-atomic-common-pipes-data-accessor.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-domain.mjs +22 -26
- package/fesm2022/ng-atomic-common-pipes-domain.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-error.mjs +0 -1
- package/fesm2022/ng-atomic-common-pipes-error.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-expression.mjs +25 -0
- package/fesm2022/ng-atomic-common-pipes-expression.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-pipes-grouped-by.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-index-length.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-index.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-keys.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-map.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-page.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-pagination.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-query.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-resolve-columns.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-secret.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-select-id.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-signal.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-smart-field.mjs +15 -4
- package/fesm2022/ng-atomic-common-pipes-smart-field.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-sort-by.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-sort.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-pipes-style.mjs +48 -0
- package/fesm2022/ng-atomic-common-pipes-style.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-pipes-yen.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-app.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-auth.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-breakpoint.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-chips-manager.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-csv.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-fab.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form-_index.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form-columns.mjs +27 -20
- package/fesm2022/ng-atomic-common-services-form-columns.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form-json-schema.mjs +76 -57
- package/fesm2022/ng-atomic-common-services-form-json-schema.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form-pagination.mjs +3 -3
- package/fesm2022/ng-atomic-common-services-form-pagination.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form-sort.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-form.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-initializer.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-language.mjs +46 -0
- package/fesm2022/ng-atomic-common-services-language.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-services-loading.mjs +1 -1
- package/fesm2022/ng-atomic-common-services-loading.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-navigation-history.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-query-resolver.mjs +3 -3
- package/fesm2022/ng-atomic-common-services-query-resolver.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-root-property.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-router.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-secret.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-sheets-actions.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-sheets.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-side-app.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-side-nav-mode.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-snack-bar.mjs +29 -11
- package/fesm2022/ng-atomic-common-services-snack-bar.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-services-spreadsheet.mjs +758 -0
- package/fesm2022/ng-atomic-common-services-spreadsheet.mjs.map +1 -0
- package/fesm2022/ng-atomic-common-services-ui.mjs +14 -7
- package/fesm2022/ng-atomic-common-services-ui.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-entities.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-entity.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-pagination.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-query.mjs +1 -1
- package/fesm2022/ng-atomic-common-stores-query.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-selection.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-stores-sort.mjs.map +1 -1
- package/fesm2022/ng-atomic-common-utils.mjs +34 -15
- package/fesm2022/ng-atomic-common-utils.mjs.map +1 -1
- package/fesm2022/ng-atomic-common.mjs.map +1 -1
- package/models/index.d.ts +2 -1
- package/package.json +73 -44
- package/pipes/actions/actions.pipe.d.ts +2 -1
- package/pipes/columns/columns.pipe.d.ts +1 -0
- package/pipes/data-accessor/data-accessor.pipe.d.ts +4 -2
- package/pipes/domain/domain.pipe.d.ts +7 -6
- package/pipes/expression/expression.pipe.d.ts +9 -0
- package/pipes/expression/index.d.ts +1 -0
- package/pipes/smart-field/smart-field.pipe.d.ts +2 -2
- package/pipes/style/index.d.ts +1 -0
- package/pipes/style/style.pipe.d.ts +18 -0
- package/services/form/_index/index.service.d.ts +4 -4
- package/services/form/columns/columns.service.d.ts +5 -2
- package/services/form/json-schema/json-schema.service.d.ts +9 -1
- package/services/form/pagination/pagination.service.d.ts +5 -5
- package/services/language/index.d.ts +1 -0
- package/services/language/language.service.d.ts +12 -0
- package/services/query-resolver/query-resolver.service.d.ts +2 -2
- package/services/snack-bar/snack-bar.service.d.ts +5 -3
- package/services/spreadsheet/directives/grid-cell.directive.d.ts +41 -0
- package/services/spreadsheet/directives/index.d.ts +1 -0
- package/services/spreadsheet/features/clipboard.service.d.ts +15 -0
- package/services/spreadsheet/features/data.service.d.ts +16 -0
- package/services/spreadsheet/features/editor.service.d.ts +22 -0
- package/services/spreadsheet/features/grid.service.d.ts +17 -0
- package/services/spreadsheet/features/index.d.ts +7 -0
- package/services/spreadsheet/features/navigation.service.d.ts +17 -0
- package/services/spreadsheet/features/protection.service.d.ts +24 -0
- package/services/spreadsheet/features/selection.service.d.ts +40 -0
- package/services/spreadsheet/index.d.ts +4 -0
- package/services/spreadsheet/models/cell.model.d.ts +17 -0
- package/services/spreadsheet/models/index.d.ts +1 -0
- package/services/spreadsheet/spreadsheet.service.d.ts +29 -0
- package/utils/expression/expression.transformer.d.ts +12 -0
- package/utils/expression/index.d.ts +1 -0
- package/utils/index.d.ts +1 -1
- package/utils/inject/inject.d.ts +2 -2
- package/esm2022/pipes/smart-exp/index.mjs +0 -3
- package/esm2022/pipes/smart-exp/ng-atomic-common-pipes-smart-exp.mjs +0 -5
- package/esm2022/pipes/smart-exp/smart-exp.module.mjs +0 -16
- package/esm2022/pipes/smart-exp/smart-exp.pipe.mjs +0 -27
- package/esm2022/utils/smart-exp-transformer/index.mjs +0 -2
- package/esm2022/utils/smart-exp-transformer/smart-exp-transformer.mjs +0 -18
- package/fesm2022/ng-atomic-common-pipes-smart-exp.mjs +0 -47
- package/fesm2022/ng-atomic-common-pipes-smart-exp.mjs.map +0 -1
- package/pipes/smart-exp/index.d.ts +0 -2
- package/pipes/smart-exp/smart-exp.module.d.ts +0 -7
- package/pipes/smart-exp/smart-exp.pipe.d.ts +0 -11
- package/utils/smart-exp-transformer/index.d.ts +0 -1
- package/utils/smart-exp-transformer/smart-exp-transformer.d.ts +0 -6
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, computed, Injectable, inject, effect, InjectionToken, ElementRef, input, Directive } from '@angular/core';
|
|
3
|
+
import { isEqual } from 'lodash-es';
|
|
4
|
+
import { Clipboard } from '@angular/cdk/clipboard';
|
|
5
|
+
import papaparse from 'papaparse';
|
|
6
|
+
import { SnackBarService } from '@ng-atomic/common/services/snack-bar';
|
|
7
|
+
import { LanguageService } from '@ng-atomic/common/services/language';
|
|
8
|
+
import { injectDataAccessor } from '@ng-atomic/common/pipes/data-accessor';
|
|
9
|
+
import { EXPRESSION_TRANSFORMER } from '@ng-atomic/common/utils';
|
|
10
|
+
|
|
11
|
+
class GridService {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.data = signal([[]]);
|
|
14
|
+
this.columns = computed(() => Array.from({ length: this.data()[0].length }, (_, i) => String.fromCharCode(65 + i)));
|
|
15
|
+
this.contextMap = new Map();
|
|
16
|
+
}
|
|
17
|
+
updateCell(row, col, value) {
|
|
18
|
+
this.data.update(data => {
|
|
19
|
+
data[row][col] = {
|
|
20
|
+
dataValue: value,
|
|
21
|
+
expressionValue: value,
|
|
22
|
+
};
|
|
23
|
+
return [...data];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
getValue(position) {
|
|
27
|
+
return this.getCell(position)?.dataValue ?? null;
|
|
28
|
+
}
|
|
29
|
+
getExpressionValue(position) {
|
|
30
|
+
return this.getCell(position)?.expressionValue ?? null;
|
|
31
|
+
}
|
|
32
|
+
getCell(position) {
|
|
33
|
+
return this.data()[position.row]?.[position.col] ?? null;
|
|
34
|
+
}
|
|
35
|
+
updateAllCells(predicate, updates) {
|
|
36
|
+
this.data.update(data => {
|
|
37
|
+
for (let i = 0; i < data.length; i++) {
|
|
38
|
+
for (let j = 0; j < data[0].length; j++) {
|
|
39
|
+
if (predicate(data[i][j])) {
|
|
40
|
+
data[i][j] = { ...data[i][j], ...updates };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return [...data];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
setContext(context) {
|
|
48
|
+
this.contextMap.set(this.buildKey(context.position), context);
|
|
49
|
+
}
|
|
50
|
+
getContext(position) {
|
|
51
|
+
return this.contextMap.get(this.buildKey(position)) ?? null;
|
|
52
|
+
}
|
|
53
|
+
buildKey(position) {
|
|
54
|
+
return `(${position.row}, ${position.col})`;
|
|
55
|
+
}
|
|
56
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: GridService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
57
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: GridService }); }
|
|
58
|
+
}
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: GridService, decorators: [{
|
|
60
|
+
type: Injectable
|
|
61
|
+
}] });
|
|
62
|
+
|
|
63
|
+
class NavigationService {
|
|
64
|
+
constructor(gridService) {
|
|
65
|
+
this.gridService = gridService;
|
|
66
|
+
}
|
|
67
|
+
moveToNextCell({ row, col }) {
|
|
68
|
+
const columns = this.gridService.columns();
|
|
69
|
+
if (col < columns.length - 1) {
|
|
70
|
+
return { row, col: col + 1 };
|
|
71
|
+
}
|
|
72
|
+
else if (row < this.gridService.data().length - 1) {
|
|
73
|
+
return { row: row + 1, col: 0 };
|
|
74
|
+
}
|
|
75
|
+
return { row, col };
|
|
76
|
+
}
|
|
77
|
+
moveToPreviousCell({ row, col }) {
|
|
78
|
+
const columns = this.gridService.columns();
|
|
79
|
+
if (col > 0) {
|
|
80
|
+
return { row, col: col - 1 };
|
|
81
|
+
}
|
|
82
|
+
else if (row > 0) {
|
|
83
|
+
return { row: row - 1, col: columns.length - 1 };
|
|
84
|
+
}
|
|
85
|
+
return { row, col };
|
|
86
|
+
}
|
|
87
|
+
moveToNextRow({ row, col }) {
|
|
88
|
+
if (row < this.gridService.data().length - 1) {
|
|
89
|
+
return { row: row + 1, col };
|
|
90
|
+
}
|
|
91
|
+
return { row, col };
|
|
92
|
+
}
|
|
93
|
+
moveToPreviousRow({ row, col }) {
|
|
94
|
+
if (row > 0) {
|
|
95
|
+
return { row: row - 1, col };
|
|
96
|
+
}
|
|
97
|
+
return { row, col };
|
|
98
|
+
}
|
|
99
|
+
moveRight({ row, col }) {
|
|
100
|
+
if (col < this.gridService.columns().length - 1) {
|
|
101
|
+
return { row, col: col + 1 };
|
|
102
|
+
}
|
|
103
|
+
return { row, col };
|
|
104
|
+
}
|
|
105
|
+
moveLeft({ row, col }) {
|
|
106
|
+
if (col > 0) {
|
|
107
|
+
return { row, col: col - 1 };
|
|
108
|
+
}
|
|
109
|
+
return { row, col };
|
|
110
|
+
}
|
|
111
|
+
moveUp({ row, col }) {
|
|
112
|
+
if (row > 0) {
|
|
113
|
+
return { row: row - 1, col };
|
|
114
|
+
}
|
|
115
|
+
return { row, col };
|
|
116
|
+
}
|
|
117
|
+
moveDown({ row, col }) {
|
|
118
|
+
if (row < this.gridService.data().length - 1) {
|
|
119
|
+
return { row: row + 1, col };
|
|
120
|
+
}
|
|
121
|
+
return { row, col };
|
|
122
|
+
}
|
|
123
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: NavigationService, deps: [{ token: GridService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
124
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: NavigationService }); }
|
|
125
|
+
}
|
|
126
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: NavigationService, decorators: [{
|
|
127
|
+
type: Injectable
|
|
128
|
+
}], ctorParameters: () => [{ type: GridService }] });
|
|
129
|
+
|
|
130
|
+
class SelectionService {
|
|
131
|
+
constructor() {
|
|
132
|
+
this.selection = signal({ start: { row: 1, col: 0 }, end: null });
|
|
133
|
+
this.selectionStart = computed(() => this.selection().start, { equal: isEqual });
|
|
134
|
+
this.isMouseDown = signal(false);
|
|
135
|
+
this.grid = inject(GridService);
|
|
136
|
+
this.cellElMap = new Map();
|
|
137
|
+
effect(() => {
|
|
138
|
+
const position = this.selectionStart();
|
|
139
|
+
if (position)
|
|
140
|
+
this.focus(position);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
isSelected(position) {
|
|
144
|
+
// selectionの範囲に含まれているかどうかを返す
|
|
145
|
+
const selection = this.selection();
|
|
146
|
+
if (!selection)
|
|
147
|
+
return false;
|
|
148
|
+
const { start, end } = selection;
|
|
149
|
+
const minRow = Math.min(start.row, end?.row ?? start.row);
|
|
150
|
+
const maxRow = Math.max(start.row, end?.row ?? start.row);
|
|
151
|
+
const minCol = Math.min(start.col, end?.col ?? start.col);
|
|
152
|
+
const maxCol = Math.max(start.col, end?.col ?? start.col);
|
|
153
|
+
const { row, col } = position;
|
|
154
|
+
return row >= minRow && row <= maxRow && col >= minCol && col <= maxCol;
|
|
155
|
+
}
|
|
156
|
+
isCursorPosition(position) {
|
|
157
|
+
return isEqual(this.selection().start, position);
|
|
158
|
+
}
|
|
159
|
+
handleMouseDown(position, event) {
|
|
160
|
+
this.isMouseDown.set(true);
|
|
161
|
+
if (!event?.shiftKey) {
|
|
162
|
+
this.startSelection(position);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
handleMouseUp() {
|
|
166
|
+
this.isMouseDown.set(false);
|
|
167
|
+
}
|
|
168
|
+
handleMouseEnter(position) {
|
|
169
|
+
if (this.isMouseDown()) {
|
|
170
|
+
this.updateSelection(position);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
handleClick(position, event) {
|
|
174
|
+
if (!this.isMouseDown()) {
|
|
175
|
+
if (event?.shiftKey) {
|
|
176
|
+
this.updateSelectionEnd(position);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.startSelection(position);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
clearSelection() {
|
|
184
|
+
this.selection.update((selection) => ({ ...selection, start: selection.start, end: null }));
|
|
185
|
+
}
|
|
186
|
+
setStartPosition(position) {
|
|
187
|
+
this.selection.update((selection) => ({ ...selection, start: position, end: null }));
|
|
188
|
+
}
|
|
189
|
+
getSelection() {
|
|
190
|
+
return this.selection();
|
|
191
|
+
}
|
|
192
|
+
getSelectionEndOrStart() {
|
|
193
|
+
return this.selection()?.end || this.selection()?.start;
|
|
194
|
+
}
|
|
195
|
+
findSelectedCell() {
|
|
196
|
+
const data = this.grid.data();
|
|
197
|
+
for (let i = 0; i < data.length; i++) {
|
|
198
|
+
for (let j = 0; j < data[i].length; j++) {
|
|
199
|
+
if (this.isSelected({ row: i, col: j })) {
|
|
200
|
+
return { row: i, col: j };
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
updateSelectionEnd(position) {
|
|
207
|
+
this.selection.update((selection) => ({ ...selection, end: position }));
|
|
208
|
+
}
|
|
209
|
+
startSelection(position) {
|
|
210
|
+
this.selection.set({ start: position, end: null });
|
|
211
|
+
}
|
|
212
|
+
updateSelection(position) {
|
|
213
|
+
if (this.selection()) {
|
|
214
|
+
this.selection.update((selection) => ({ ...selection, end: position }));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
clearSelectedRange(selection) {
|
|
218
|
+
const minRow = Math.min(selection.start.row, selection.end.row);
|
|
219
|
+
const maxRow = Math.max(selection.start.row, selection.end.row);
|
|
220
|
+
const minCol = Math.min(selection.start.col, selection.end.col);
|
|
221
|
+
const maxCol = Math.max(selection.start.col, selection.end.col);
|
|
222
|
+
for (let i = minRow; i <= maxRow; i++) {
|
|
223
|
+
for (let j = minCol; j <= maxCol; j++) {
|
|
224
|
+
this.grid.updateCell(i, j, {
|
|
225
|
+
dataValue: '',
|
|
226
|
+
expressionValue: ''
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
setCell(position, el) {
|
|
232
|
+
this.cellElMap.set(`${this.buildKey(position)}`, el);
|
|
233
|
+
}
|
|
234
|
+
getCell(position) {
|
|
235
|
+
return this.cellElMap.get(this.buildKey(position)) ?? null;
|
|
236
|
+
}
|
|
237
|
+
focus(position) {
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
const el = this.getCell(position);
|
|
240
|
+
if (el && el !== document.activeElement) {
|
|
241
|
+
el.focus();
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
buildKey(position) {
|
|
246
|
+
return `(${position.row}, ${position.col})`;
|
|
247
|
+
}
|
|
248
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SelectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
249
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SelectionService }); }
|
|
250
|
+
}
|
|
251
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SelectionService, decorators: [{
|
|
252
|
+
type: Injectable
|
|
253
|
+
}], ctorParameters: () => [] });
|
|
254
|
+
|
|
255
|
+
class ClipboardService {
|
|
256
|
+
constructor(gridService, selectionService) {
|
|
257
|
+
this.gridService = gridService;
|
|
258
|
+
this.selectionService = selectionService;
|
|
259
|
+
this.clipboard = inject(Clipboard);
|
|
260
|
+
this.snackBar = inject(SnackBarService);
|
|
261
|
+
}
|
|
262
|
+
async copy() {
|
|
263
|
+
const selection = this.selectionService.getSelection();
|
|
264
|
+
if (!selection)
|
|
265
|
+
return;
|
|
266
|
+
const { start, end } = selection;
|
|
267
|
+
if (!end) {
|
|
268
|
+
this.copyText(this.gridService.data()[start.row][start.col].dataValue);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const minRow = Math.min(start.row, end.row);
|
|
272
|
+
const maxRow = Math.max(start.row, end.row);
|
|
273
|
+
const minCol = Math.min(start.col, end.col);
|
|
274
|
+
const maxCol = Math.max(start.col, end.col);
|
|
275
|
+
const data = this.gridService.data();
|
|
276
|
+
const clipboardData = [];
|
|
277
|
+
for (let i = minRow; i <= maxRow; i++) {
|
|
278
|
+
const row = [];
|
|
279
|
+
for (let j = minCol; j <= maxCol; j++) {
|
|
280
|
+
row.push(data[i][j].dataValue);
|
|
281
|
+
}
|
|
282
|
+
clipboardData.push(row);
|
|
283
|
+
}
|
|
284
|
+
const tsv = papaparse.unparse(clipboardData, { delimiter: '\t', newline: '\n', header: false });
|
|
285
|
+
this.clipboard.copy(tsv);
|
|
286
|
+
}
|
|
287
|
+
copyText(text) {
|
|
288
|
+
this.clipboard.copy(text);
|
|
289
|
+
this.snackBar.open('クリップボードにコピーしました。');
|
|
290
|
+
}
|
|
291
|
+
async paste(targetRow, targetCol) {
|
|
292
|
+
try {
|
|
293
|
+
const clipboardText = await navigator.clipboard.readText();
|
|
294
|
+
const rows = clipboardText.split('\n');
|
|
295
|
+
const data = this.gridService.data();
|
|
296
|
+
const rowCount = Math.min(rows.length, data.length - targetRow);
|
|
297
|
+
for (let i = 0; i < rowCount; i++) {
|
|
298
|
+
const cells = rows[i].split('\t');
|
|
299
|
+
const colCount = Math.min(cells.length, this.gridService.columns().length - targetCol);
|
|
300
|
+
for (let j = 0; j < colCount; j++) {
|
|
301
|
+
this.gridService.updateCell(targetRow + i, targetCol + j, cells[j]);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
console.log('Data pasted from clipboard as TSV');
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
console.error('Failed to read data from clipboard', err);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ClipboardService, deps: [{ token: GridService }, { token: SelectionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
311
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ClipboardService }); }
|
|
312
|
+
}
|
|
313
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ClipboardService, decorators: [{
|
|
314
|
+
type: Injectable
|
|
315
|
+
}], ctorParameters: () => [{ type: GridService }, { type: SelectionService }] });
|
|
316
|
+
|
|
317
|
+
const COLUMN_PROTECTOR = new InjectionToken('COLUMN_PROTECTOR', {
|
|
318
|
+
providedIn: 'root',
|
|
319
|
+
factory: () => [],
|
|
320
|
+
});
|
|
321
|
+
function provideCellProtector(useFactory) {
|
|
322
|
+
return { provide: COLUMN_PROTECTOR, useFactory, multi: true };
|
|
323
|
+
}
|
|
324
|
+
class ProtectionService {
|
|
325
|
+
constructor() {
|
|
326
|
+
this.protectors = inject(COLUMN_PROTECTOR, { optional: true });
|
|
327
|
+
}
|
|
328
|
+
isEditable(value, context) {
|
|
329
|
+
if (!this.protectors)
|
|
330
|
+
return true;
|
|
331
|
+
return this.protectors.every((protector) => protector(value, context));
|
|
332
|
+
}
|
|
333
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ProtectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
334
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ProtectionService }); }
|
|
335
|
+
}
|
|
336
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: ProtectionService, decorators: [{
|
|
337
|
+
type: Injectable
|
|
338
|
+
}] });
|
|
339
|
+
|
|
340
|
+
class EditorService {
|
|
341
|
+
constructor() {
|
|
342
|
+
this.grid = inject(GridService);
|
|
343
|
+
this.selection = inject(SelectionService);
|
|
344
|
+
this.protection = inject(ProtectionService);
|
|
345
|
+
this.editinngCell = signal(null);
|
|
346
|
+
this.inputMap = new Map();
|
|
347
|
+
}
|
|
348
|
+
isEditing(position) {
|
|
349
|
+
return this.editinngCell()?.row === position.row && this.editinngCell()?.col === position.col;
|
|
350
|
+
}
|
|
351
|
+
startEditing(position) {
|
|
352
|
+
const context = this.grid.getContext(position);
|
|
353
|
+
console.debug('context:', context);
|
|
354
|
+
if (!this.protection.isEditable(null, context)) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
this.selection.clearSelection();
|
|
358
|
+
this.editinngCell.set(position);
|
|
359
|
+
this.focus(position);
|
|
360
|
+
}
|
|
361
|
+
stopEditing() {
|
|
362
|
+
this.editinngCell.set(null);
|
|
363
|
+
}
|
|
364
|
+
focus(position) {
|
|
365
|
+
setTimeout(() => {
|
|
366
|
+
const input = this.getInput(position);
|
|
367
|
+
if (input && input !== document.activeElement) {
|
|
368
|
+
input.focus();
|
|
369
|
+
input.select();
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
getEditingCell() {
|
|
374
|
+
const data = this.grid.data();
|
|
375
|
+
for (let i = 0; i < data.length; i++) {
|
|
376
|
+
for (let j = 0; j < data[i].length; j++) {
|
|
377
|
+
if (this.isEditing({ row: i, col: j })) {
|
|
378
|
+
return { row: i, col: j };
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
setInput(input, position) {
|
|
385
|
+
this.inputMap.set(`${this.buildKey(position)}`, input);
|
|
386
|
+
}
|
|
387
|
+
getInput(position) {
|
|
388
|
+
return this.inputMap.get(this.buildKey(position)) ?? null;
|
|
389
|
+
}
|
|
390
|
+
buildKey(position) {
|
|
391
|
+
return `(${position.row}, ${position.col})`;
|
|
392
|
+
}
|
|
393
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: EditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
394
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: EditorService }); }
|
|
395
|
+
}
|
|
396
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: EditorService, decorators: [{
|
|
397
|
+
type: Injectable
|
|
398
|
+
}] });
|
|
399
|
+
|
|
400
|
+
class SpreadSheetDataService {
|
|
401
|
+
constructor() {
|
|
402
|
+
this.cache = new Map();
|
|
403
|
+
this.language = inject(LanguageService);
|
|
404
|
+
this.dataAccessor = injectDataAccessor();
|
|
405
|
+
this.expression = inject(EXPRESSION_TRANSFORMER);
|
|
406
|
+
}
|
|
407
|
+
buildGridData(items, displayedColumns) {
|
|
408
|
+
return [
|
|
409
|
+
this.buildGridHeaderRow(displayedColumns),
|
|
410
|
+
...items.map((item) => this.buildGridRow(item, displayedColumns))
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
buildGridHeaderRow(columns) {
|
|
414
|
+
const key = this.buildKey({ columns });
|
|
415
|
+
const cached = this.cache.get(key);
|
|
416
|
+
if (cached)
|
|
417
|
+
return cached;
|
|
418
|
+
const row = columns.map((column) => ({
|
|
419
|
+
dataValue: this.language.transform(column),
|
|
420
|
+
expressionValue: this.language.transform(column),
|
|
421
|
+
isHeader: true
|
|
422
|
+
}));
|
|
423
|
+
this.cache.set(key, row);
|
|
424
|
+
return row;
|
|
425
|
+
}
|
|
426
|
+
buildGridRow(item, displayedColumns) {
|
|
427
|
+
const key = this.buildKey({ item, displayedColumns });
|
|
428
|
+
const cached = this.cache.get(key);
|
|
429
|
+
if (cached)
|
|
430
|
+
return cached;
|
|
431
|
+
const row = displayedColumns.map((column) => this.buildGridCell(item, column));
|
|
432
|
+
this.cache.set(key, row);
|
|
433
|
+
return row;
|
|
434
|
+
}
|
|
435
|
+
buildGridCell(item, column) {
|
|
436
|
+
const key = this.buildKey({ item, column });
|
|
437
|
+
const cached = this.cache.get(key);
|
|
438
|
+
if (cached)
|
|
439
|
+
return cached;
|
|
440
|
+
const cell = {
|
|
441
|
+
dataValue: this.dataAccessor(item, column),
|
|
442
|
+
expressionValue: this.expression(this.dataAccessor(item, column), { item, name: column }),
|
|
443
|
+
};
|
|
444
|
+
this.cache.set(key, cell);
|
|
445
|
+
return cell;
|
|
446
|
+
}
|
|
447
|
+
buildKey(obj) {
|
|
448
|
+
// return CryptoJS.MD5(JSON.stringify(obj)).toString(CryptoJS.enc.Base64).slice(0, 10);
|
|
449
|
+
return JSON.stringify(obj);
|
|
450
|
+
}
|
|
451
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
452
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetDataService }); }
|
|
453
|
+
}
|
|
454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetDataService, decorators: [{
|
|
455
|
+
type: Injectable
|
|
456
|
+
}] });
|
|
457
|
+
|
|
458
|
+
class SpreadSheetService {
|
|
459
|
+
constructor() {
|
|
460
|
+
this.config = { paste: false };
|
|
461
|
+
this.grid = inject(GridService);
|
|
462
|
+
this.data = inject(SpreadSheetDataService);
|
|
463
|
+
this.navigation = inject(NavigationService);
|
|
464
|
+
this.selection = inject(SelectionService);
|
|
465
|
+
this.clipboard = inject(ClipboardService);
|
|
466
|
+
this.editor = inject(EditorService);
|
|
467
|
+
this.protection = inject(ProtectionService);
|
|
468
|
+
}
|
|
469
|
+
handleKeyDown(event) {
|
|
470
|
+
if (this.editor.editinngCell()) {
|
|
471
|
+
this.handleKeyDownOnEditing(event);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
this.handleKeyDownOnSelecting(event);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
handleKeyDownOnEditing(event) {
|
|
478
|
+
const cell = this.editor.editinngCell();
|
|
479
|
+
if (event.key === 'Tab') {
|
|
480
|
+
event.preventDefault();
|
|
481
|
+
if (event.shiftKey) {
|
|
482
|
+
this.move(cell, 'left', 'select');
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
this.move(cell, 'right', 'select');
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else if (event.key === 'Enter') {
|
|
489
|
+
event.preventDefault();
|
|
490
|
+
if (event.shiftKey) {
|
|
491
|
+
this.move(cell, 'top', 'select');
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
this.move(cell, 'bottom', 'select');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
handleKeyDownOnSelecting(event) {
|
|
499
|
+
if (event.key === 'Tab') {
|
|
500
|
+
const selectedCell = this.selection.findSelectedCell();
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
event.stopPropagation();
|
|
503
|
+
if (event.shiftKey) {
|
|
504
|
+
this.move(selectedCell, 'left', 'select');
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
this.move(selectedCell, 'right', 'select');
|
|
508
|
+
}
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
else if (event.key === 'Enter') {
|
|
512
|
+
const selectedCell = this.selection.findSelectedCell();
|
|
513
|
+
if (selectedCell) {
|
|
514
|
+
this.editor.startEditing(selectedCell);
|
|
515
|
+
event.preventDefault();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else if (event.ctrlKey || event.metaKey) {
|
|
519
|
+
if (event.key === 'c') {
|
|
520
|
+
this.clipboard.copy();
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
}
|
|
523
|
+
else if (event.key === 'v') {
|
|
524
|
+
if (!this.config.paste)
|
|
525
|
+
return;
|
|
526
|
+
const target = this.selection.findSelectedCell();
|
|
527
|
+
if (target) {
|
|
528
|
+
this.clipboard.paste(target.row, target.col);
|
|
529
|
+
}
|
|
530
|
+
event.preventDefault();
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
535
|
+
const selection = this.selection.getSelection();
|
|
536
|
+
if (selection) {
|
|
537
|
+
this.selection.clearSelectedRange(selection);
|
|
538
|
+
event.preventDefault();
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
const selectedCell = this.selection.findSelectedCell();
|
|
544
|
+
let newPosition;
|
|
545
|
+
if (event.shiftKey) {
|
|
546
|
+
const selectionEnd = this.selection.getSelectionEndOrStart();
|
|
547
|
+
switch (event.key) {
|
|
548
|
+
case 'ArrowRight':
|
|
549
|
+
newPosition = this.navigation.moveRight(selectionEnd);
|
|
550
|
+
break;
|
|
551
|
+
case 'ArrowLeft':
|
|
552
|
+
newPosition = this.navigation.moveLeft(selectionEnd);
|
|
553
|
+
break;
|
|
554
|
+
case 'ArrowUp':
|
|
555
|
+
newPosition = this.navigation.moveUp(selectionEnd);
|
|
556
|
+
break;
|
|
557
|
+
case 'ArrowDown':
|
|
558
|
+
newPosition = this.navigation.moveDown(selectionEnd);
|
|
559
|
+
break;
|
|
560
|
+
default:
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (newPosition) {
|
|
564
|
+
event.preventDefault();
|
|
565
|
+
this.selection.updateSelectionEnd(newPosition);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
switch (event.key) {
|
|
570
|
+
case 'ArrowRight':
|
|
571
|
+
newPosition = this.navigation.moveRight(selectedCell);
|
|
572
|
+
break;
|
|
573
|
+
case 'ArrowLeft':
|
|
574
|
+
newPosition = this.navigation.moveLeft(selectedCell);
|
|
575
|
+
break;
|
|
576
|
+
case 'ArrowUp':
|
|
577
|
+
newPosition = this.navigation.moveUp(selectedCell);
|
|
578
|
+
break;
|
|
579
|
+
case 'ArrowDown':
|
|
580
|
+
newPosition = this.navigation.moveDown(selectedCell);
|
|
581
|
+
break;
|
|
582
|
+
default:
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
if (newPosition) {
|
|
586
|
+
event.preventDefault();
|
|
587
|
+
this.selection.clearSelection();
|
|
588
|
+
this.selection.handleClick(newPosition);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
move(_position, dest, mode) {
|
|
594
|
+
this.editor.stopEditing();
|
|
595
|
+
let position;
|
|
596
|
+
if (dest === 'top') {
|
|
597
|
+
position = this.navigation.moveToPreviousRow(_position);
|
|
598
|
+
}
|
|
599
|
+
else if (dest === 'bottom') {
|
|
600
|
+
position = this.navigation.moveToNextRow(_position);
|
|
601
|
+
}
|
|
602
|
+
else if (dest === 'left') {
|
|
603
|
+
position = this.navigation.moveToPreviousCell(_position);
|
|
604
|
+
}
|
|
605
|
+
else if (dest === 'right') {
|
|
606
|
+
position = this.navigation.moveToNextCell(_position);
|
|
607
|
+
}
|
|
608
|
+
this.selection.setStartPosition(position);
|
|
609
|
+
if (mode === 'edit') {
|
|
610
|
+
this.editor.startEditing(position);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
614
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetService }); }
|
|
615
|
+
}
|
|
616
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetService, decorators: [{
|
|
617
|
+
type: Injectable
|
|
618
|
+
}] });
|
|
619
|
+
function provideSpreadSheetService() {
|
|
620
|
+
return [
|
|
621
|
+
ClipboardService,
|
|
622
|
+
SpreadSheetDataService,
|
|
623
|
+
EditorService,
|
|
624
|
+
SpreadSheetService,
|
|
625
|
+
GridService,
|
|
626
|
+
NavigationService,
|
|
627
|
+
SelectionService,
|
|
628
|
+
ProtectionService
|
|
629
|
+
];
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
class SpreadSheetCell {
|
|
633
|
+
constructor() {
|
|
634
|
+
this.ss = inject(SpreadSheetService);
|
|
635
|
+
this.el = inject(ElementRef);
|
|
636
|
+
this.position = input({ row: 0, col: 0 }, { alias: 'ssCell' });
|
|
637
|
+
this.editable = input(false, { alias: 'ssCellEditable' });
|
|
638
|
+
this.context = input(null, { alias: 'ssCellContext' });
|
|
639
|
+
this.isSelected = computed(() => this.ss.selection.isSelected(this.position()));
|
|
640
|
+
this.isEditing = computed(() => this.ss.editor.isEditing(this.position()));
|
|
641
|
+
this.frameEl = signal(null);
|
|
642
|
+
effect(() => {
|
|
643
|
+
if (!this.context())
|
|
644
|
+
return;
|
|
645
|
+
this.ss.grid.setContext(this.context());
|
|
646
|
+
});
|
|
647
|
+
effect(() => {
|
|
648
|
+
const isCursor = this.ss.selection.isCursorPosition(this.position());
|
|
649
|
+
let frame = this.frameEl();
|
|
650
|
+
if (isCursor) {
|
|
651
|
+
if (!frame) {
|
|
652
|
+
frame = this.buildOutlineFrame();
|
|
653
|
+
this.el.nativeElement.appendChild(frame);
|
|
654
|
+
this.frameEl.set(frame);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
frame?.remove();
|
|
659
|
+
this.frameEl.set(null);
|
|
660
|
+
}
|
|
661
|
+
}, { allowSignalWrites: true });
|
|
662
|
+
}
|
|
663
|
+
onDbClick() {
|
|
664
|
+
if (!this.editable())
|
|
665
|
+
return;
|
|
666
|
+
this.ss.editor.startEditing(this.position());
|
|
667
|
+
}
|
|
668
|
+
ngAfterViewInit() {
|
|
669
|
+
this.ss.selection.setCell(this.position(), this.el.nativeElement);
|
|
670
|
+
if (this.isSelected() && !this.isEditing()) {
|
|
671
|
+
this.ss.selection.focus(this.position());
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
buildOutlineFrame() {
|
|
675
|
+
const frame = document.createElement('div');
|
|
676
|
+
frame.classList.add('selection-frame');
|
|
677
|
+
frame.style.position = 'absolute';
|
|
678
|
+
frame.style.top = '0';
|
|
679
|
+
frame.style.left = '0';
|
|
680
|
+
frame.style.width = '100%';
|
|
681
|
+
frame.style.height = '100%';
|
|
682
|
+
frame.style.border = '2px solid #2196f3';
|
|
683
|
+
frame.style.borderRadius = '4px';
|
|
684
|
+
frame.style.pointerEvents = 'none';
|
|
685
|
+
frame.style.boxSizing = 'border-box';
|
|
686
|
+
return frame;
|
|
687
|
+
}
|
|
688
|
+
createLabelElement(options) {
|
|
689
|
+
const el = document.createElement('span');
|
|
690
|
+
el.textContent = options.label;
|
|
691
|
+
el.style.backgroundColor = `${options.color}`;
|
|
692
|
+
el.style.color = '#fff';
|
|
693
|
+
el.style.padding = '2px 4px';
|
|
694
|
+
el.style.position = 'absolute';
|
|
695
|
+
el.style.fontSize = '10px';
|
|
696
|
+
el.style.top = '0';
|
|
697
|
+
el.style.left = '0';
|
|
698
|
+
el.style.zIndex = '9999';
|
|
699
|
+
el.style.lineHeight = '1.5em';
|
|
700
|
+
el.style.whiteSpace = 'nowrap';
|
|
701
|
+
this.el.nativeElement.appendChild(el);
|
|
702
|
+
}
|
|
703
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetCell, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
704
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.2", type: SpreadSheetCell, isStandalone: true, selector: "[ssCell]", inputs: { position: { classPropertyName: "position", publicName: "ssCell", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "ssCellEditable", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ssCellContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mousedown": "ss.selection.handleMouseDown(position(), $event)", "mouseup": "ss.selection.handleMouseUp()", "mouseenter": "ss.selection.handleMouseEnter(position())", "click": "ss.selection.handleClick(position(), $event)", "dblclick": "onDbClick()" }, properties: { "class.selected": "ss.selection.isSelected(position())", "class.editing": "ss.editor.isEditing(position())" } }, ngImport: i0 }); }
|
|
705
|
+
}
|
|
706
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetCell, decorators: [{
|
|
707
|
+
type: Directive,
|
|
708
|
+
args: [{
|
|
709
|
+
standalone: true,
|
|
710
|
+
selector: '[ssCell]',
|
|
711
|
+
host: {
|
|
712
|
+
'[class.selected]': 'ss.selection.isSelected(position())',
|
|
713
|
+
'[class.editing]': 'ss.editor.isEditing(position())',
|
|
714
|
+
'(mousedown)': 'ss.selection.handleMouseDown(position(), $event)',
|
|
715
|
+
'(mouseup)': 'ss.selection.handleMouseUp()',
|
|
716
|
+
'(mouseenter)': 'ss.selection.handleMouseEnter(position())',
|
|
717
|
+
'(click)': 'ss.selection.handleClick(position(), $event)',
|
|
718
|
+
'(dblclick)': 'onDbClick()',
|
|
719
|
+
}
|
|
720
|
+
}]
|
|
721
|
+
}], ctorParameters: () => [] });
|
|
722
|
+
class SpreadSheetCellInput {
|
|
723
|
+
constructor() {
|
|
724
|
+
this.ss = inject(SpreadSheetService);
|
|
725
|
+
this.position = input({ row: 0, col: 0 }, { alias: 'ssCellInput' });
|
|
726
|
+
this.el = inject(ElementRef);
|
|
727
|
+
this.isSelected = computed(() => this.ss.selection.isSelected(this.position()));
|
|
728
|
+
this.isEditing = computed(() => this.ss.editor.isEditing(this.position()));
|
|
729
|
+
}
|
|
730
|
+
ngAfterViewInit() {
|
|
731
|
+
this.ss.editor.setInput(this.el.nativeElement, this.position());
|
|
732
|
+
if (this.isSelected() && this.isEditing()) {
|
|
733
|
+
this.ss.editor.focus(this.position());
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
stopEditing() {
|
|
737
|
+
this.ss.editor.stopEditing();
|
|
738
|
+
}
|
|
739
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetCellInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
740
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.1.2", type: SpreadSheetCellInput, isStandalone: true, selector: "[ssCellInput]", inputs: { position: { classPropertyName: "position", publicName: "ssCellInput", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "blur": "stopEditing()" } }, ngImport: i0 }); }
|
|
741
|
+
}
|
|
742
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: SpreadSheetCellInput, decorators: [{
|
|
743
|
+
type: Directive,
|
|
744
|
+
args: [{
|
|
745
|
+
standalone: true,
|
|
746
|
+
selector: '[ssCellInput]',
|
|
747
|
+
host: {
|
|
748
|
+
'(blur)': 'stopEditing()',
|
|
749
|
+
}
|
|
750
|
+
}]
|
|
751
|
+
}] });
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Generated bundle index. Do not edit.
|
|
755
|
+
*/
|
|
756
|
+
|
|
757
|
+
export { COLUMN_PROTECTOR, ClipboardService, EditorService, GridService, NavigationService, ProtectionService, SelectionService, SpreadSheetCell, SpreadSheetCellInput, SpreadSheetDataService, SpreadSheetService, provideCellProtector, provideSpreadSheetService };
|
|
758
|
+
//# sourceMappingURL=ng-atomic-common-services-spreadsheet.mjs.map
|