@slickgrid-universal/composite-editor-component 4.0.3 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"slick-composite-editor.component.d.ts","sourceRoot":"","sources":["../../src/slick-composite-editor.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EACV,MAAM,EACN,oBAAoB,EAEpB,+BAA+B,EAC/B,qBAAqB,EACrB,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,MAAM,EACN,gCAAgC,EAChC,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAKL,iBAAiB,EAElB,MAAM,6BAA6B,CAAC;AAMrC,KAAK,sBAAsB,GAAG,CAC5B,UAAU,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,GAAG,IAAI,EAC/C,SAAS,EAAE;IAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAAE,EAChF,eAAe,CAAC,EAAE,OAAO,KACtB,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9B,KAAK,aAAa,GAAG;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,qBAAa,6BAA8B,YAAW,gBAAgB;IACpE,SAAS,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IACjD,SAAS,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAC5C,SAAS,CAAC,iBAAiB,EAAG,qBAAqB,CAAC;IAC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,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB,EAAE,mBAAmB,EAAE,SAAS;IAS5G,8HAA8H;IAC9H,SAAS,CAAC,6BAA6B,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,gCAAgC;IAqBzF,0DAA0D;IAC1D,SAAS,CAAC,sBAAsB,IAAI,OAAO;IAM3C,gCAAgC;IAChC,SAAS,CAAC,sBAAsB;IAWhC,yFAAyF;IACzF,SAAS,CAAC,iBAAiB;IAyD3B,kGAAkG;IAClG,SAAS,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG;IAY3C,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM;IAM/D,gHAAgH;IAChH,SAAS,CAAC,0BAA0B;IAMpC,sEAAsE;IACtE,SAAS,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,WAAW,GAAG,sBAAsB;IAUnF,uCAAuC;IACvC,SAAS,CAAC,qBAAqB;CAMhC"}
1
+ {"version":3,"file":"slick-composite-editor.component.d.ts","sourceRoot":"","sources":["../../src/slick-composite-editor.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EACV,MAAM,EACN,oBAAoB,EAEpB,+BAA+B,EAC/B,qBAAqB,EACrB,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,MAAM,EACN,gCAAgC,EAChC,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACT,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAKL,iBAAiB,EAElB,MAAM,6BAA6B,CAAC;AAMrC,KAAK,sBAAsB,GAAG,CAC5B,UAAU,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,GAAG,IAAI,EAC/C,SAAS,EAAE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
4
  "description": "Slick Composite Editor Component - Vanilla Implementation of a Composite Editor Modal Window Component",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -25,7 +25,8 @@
25
25
  "access": "public"
26
26
  },
27
27
  "files": [
28
- "/dist"
28
+ "/dist",
29
+ "/src"
29
30
  ],
30
31
  "license": "MIT",
31
32
  "author": "Ghislain B.",
@@ -44,9 +45,9 @@
44
45
  "not dead"
45
46
  ],
46
47
  "dependencies": {
47
- "@slickgrid-universal/binding": "~4.0.2",
48
- "@slickgrid-universal/common": "~4.0.3",
49
- "@slickgrid-universal/utils": "~4.0.2"
48
+ "@slickgrid-universal/binding": "~4.1.0",
49
+ "@slickgrid-universal/common": "~4.2.0",
50
+ "@slickgrid-universal/utils": "~4.2.0"
50
51
  },
51
- "gitHead": "d637300740299f0ded21b0c66c6a21ae953e9789"
52
+ "gitHead": "d97d211a6c2d7d2f3ad65a3d5f19b27584e5ae8c"
52
53
  }
@@ -0,0 +1,261 @@
1
+ import { emptyElement, getOffset, } from '@slickgrid-universal/common';
2
+ import type { Column, CompositeEditorOption, Editor, EditorArguments, EditorValidationResult, ElementPosition, } from '@slickgrid-universal/common';
3
+ import type { HtmlElementPosition } from '@slickgrid-universal/utils';
4
+
5
+ export interface CompositeEditorArguments extends EditorArguments {
6
+ formValues: any;
7
+ }
8
+
9
+ /**
10
+ * A composite SlickGrid editor factory.
11
+ * Generates an editor that is composed of multiple editors for given columns.
12
+ * Individual editors are provided given containers instead of the original cell.
13
+ * Validation will be performed on all editors individually and the results will be aggregated into one
14
+ * validation result.
15
+ *
16
+ *
17
+ * The returned editor will have its prototype set to CompositeEditor, so you can use the "instanceof" check.
18
+ *
19
+ * NOTE: This doesn't work for detached editors since they will be created and positioned relative to the
20
+ * active cell and not the provided container.
21
+ *
22
+ * @class CompositeEditor
23
+ * @constructor
24
+ * @param columns {Array} Column definitions from which editors will be pulled.
25
+ * @param containers {Array} Container HTMLElements in which editors will be placed.
26
+ * @param options {Object} Options hash:
27
+ * validationFailedMsg - A generic failed validation message set on the aggregated validation resuls.
28
+ * validationMsgPrefix - Add an optional prefix to each validation message (only the ones shown in the modal form, not the ones in the "errors")
29
+ * modalType - Defaults to "edit", modal type can 1 of these 3: (create, edit, mass, mass-selection)
30
+ * hide - A function to be called when the grid asks the editor to hide itself.
31
+ * show - A function to be called when the grid asks the editor to show itself.
32
+ * position - A function to be called when the grid asks the editor to reposition itself.
33
+ * destroy - A function to be called when the editor is destroyed.
34
+ */
35
+ export function SlickCompositeEditor(this: any, columns: Column[], containers: Array<HTMLDivElement>, options: CompositeEditorOption) {
36
+ let firstInvalidEditor: Editor | null;
37
+ const defaultOptions = {
38
+ modalType: 'edit', // available type (create, clone, edit, mass)
39
+ validationFailedMsg: 'Some of the fields have failed validation',
40
+ validationMsgPrefix: null,
41
+ show: null,
42
+ hide: null,
43
+ position: null,
44
+ destroy: null,
45
+ formValues: {},
46
+ editors: {}
47
+ } as unknown as CompositeEditorOption;
48
+ options = { ...defaultOptions, ...options };
49
+
50
+ /* no operation (empty) function */
51
+ const noop = () => { };
52
+
53
+ const getContainerBox = (i: number): ElementPosition => {
54
+ const container = containers[i];
55
+ const offset = getOffset(container);
56
+ const width = container?.clientWidth ?? 0;
57
+ const height = container?.clientHeight ?? 0;
58
+
59
+ return {
60
+ top: offset?.top ?? 0,
61
+ left: offset?.left ?? 0,
62
+ bottom: (offset?.top ?? 0) + height,
63
+ right: (offset?.left ?? 0) + width,
64
+ width,
65
+ height,
66
+ visible: true
67
+ };
68
+ };
69
+
70
+ /* Editor prototype that will get instantiated dynamically by looping through each Editors */
71
+ function editor(this: any, args: EditorArguments) {
72
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
73
+ const context: any = this;
74
+ let editors: Array<Editor & { args: EditorArguments }> = [];
75
+
76
+ function init() {
77
+ let newArgs: Partial<CompositeEditorArguments> = {};
78
+ let idx = 0;
79
+ while (idx < columns.length) {
80
+ if (columns[idx].editor) {
81
+ const column = columns[idx];
82
+ newArgs = { ...args };
83
+ newArgs.container = containers[idx];
84
+ newArgs.column = column;
85
+ newArgs.position = getContainerBox(idx);
86
+ newArgs.commitChanges = noop;
87
+ newArgs.cancelChanges = noop;
88
+ newArgs.compositeEditorOptions = options;
89
+ newArgs.formValues = {};
90
+
91
+ const currentEditor = new (column.editor as any)(newArgs) as Editor & { args: EditorArguments };
92
+ options.editors[column.id] = currentEditor; // add every Editor instance refs
93
+ editors.push(currentEditor);
94
+ }
95
+ idx++;
96
+ }
97
+
98
+ // focus on first input
99
+ setTimeout(() => {
100
+ if (Array.isArray(editors) && editors.length > 0 && typeof editors[0].focus === 'function') {
101
+ editors[0].focus();
102
+ }
103
+ }, 0);
104
+ }
105
+
106
+ context.getEditors = () => {
107
+ return editors;
108
+ };
109
+
110
+ context.destroy = () => {
111
+ let tmpEditor = editors.pop();
112
+ while (tmpEditor) {
113
+ tmpEditor?.destroy();
114
+ tmpEditor = editors.pop();
115
+ }
116
+
117
+ let tmpContainer = containers.pop();
118
+ while (tmpContainer) {
119
+ emptyElement(tmpContainer);
120
+ tmpContainer?.remove();
121
+ tmpContainer = containers.pop();
122
+ }
123
+
124
+ options?.destroy?.();
125
+ editors = [];
126
+ containers = null as any;
127
+ };
128
+
129
+ context.focus = () => {
130
+ // if validation has failed, set the focus to the first invalid editor
131
+ (firstInvalidEditor || editors[0]).focus();
132
+ };
133
+
134
+ context.isValueChanged = () => {
135
+ let idx = 0;
136
+ while (idx < editors.length) {
137
+ if (editors[idx].isValueChanged()) {
138
+ return true;
139
+ }
140
+ idx++;
141
+ }
142
+ return false;
143
+ };
144
+
145
+ context.serializeValue = () => {
146
+ const serializedValue = [];
147
+ let idx = 0;
148
+ while (idx < editors.length) {
149
+ serializedValue[idx] = editors[idx].serializeValue();
150
+ idx++;
151
+ }
152
+ return serializedValue;
153
+ };
154
+
155
+ context.applyValue = (item: any, state: any) => {
156
+ let idx = 0;
157
+ while (idx < editors.length) {
158
+ editors[idx].applyValue(item, state?.[idx]);
159
+ idx++;
160
+ }
161
+ };
162
+
163
+ context.loadValue = (item: any) => {
164
+ let idx = 0;
165
+
166
+ while (idx < editors.length) {
167
+ editors[idx].loadValue(item);
168
+ idx++;
169
+ }
170
+ };
171
+
172
+ context.validate = (targetElm: HTMLElement | null) => {
173
+ let validationResults: EditorValidationResult;
174
+ firstInvalidEditor = null;
175
+ const errors = [];
176
+
177
+ let idx = 0;
178
+ while (idx < editors.length) {
179
+ const columnDef = editors[idx].args?.column;
180
+ if (columnDef?.id !== undefined) {
181
+ const compositeModalElm = document.querySelector(`.slick-editor-modal`);
182
+ let validationElm = compositeModalElm?.querySelector(`.item-details-validation.editor-${columnDef.id}`);
183
+ let labelElm = compositeModalElm?.querySelector(`.item-details-label.editor-${columnDef.id}`);
184
+ let editorElm = compositeModalElm?.querySelector(`[data-editorid=${columnDef.id}]`);
185
+ const validationMsgPrefix = options?.validationMsgPrefix ?? '';
186
+
187
+ if (!targetElm || editorElm?.contains(targetElm)) {
188
+ validationResults = editors[idx].validate();
189
+
190
+ if (!validationResults.valid) {
191
+ firstInvalidEditor = editors[idx];
192
+ errors.push({
193
+ index: idx,
194
+ editor: editors[idx],
195
+ container: containers[idx],
196
+ msg: validationResults.msg
197
+ });
198
+
199
+ if (validationElm) {
200
+ validationElm.textContent = `${validationMsgPrefix}${validationResults.msg}`;
201
+ labelElm?.classList.add('invalid');
202
+ editorElm?.classList.add('invalid');
203
+ }
204
+ } else if (validationElm) {
205
+ validationElm.textContent = '';
206
+ editorElm?.classList.remove('invalid');
207
+ labelElm?.classList.remove('invalid');
208
+ }
209
+ }
210
+ validationElm = null;
211
+ labelElm = null;
212
+ editorElm = null;
213
+ }
214
+ idx++;
215
+ }
216
+ targetElm = null;
217
+
218
+ if (errors.length) {
219
+ return {
220
+ valid: false,
221
+ msg: options.validationFailedMsg,
222
+ errors
223
+ };
224
+ }
225
+ return {
226
+ valid: true,
227
+ msg: ''
228
+ };
229
+ };
230
+
231
+ context.hide = () => {
232
+ let idx = 0;
233
+ while (idx < editors.length) {
234
+ editors[idx]?.hide?.();
235
+ idx++;
236
+ }
237
+ options?.hide?.();
238
+ };
239
+
240
+ context.show = () => {
241
+ let idx = 0;
242
+ while (idx < editors.length) {
243
+ editors[idx]?.show?.();
244
+ idx++;
245
+ }
246
+ options?.show?.();
247
+ };
248
+
249
+ context.position = (box: HtmlElementPosition) => {
250
+ options?.position?.(box);
251
+ };
252
+
253
+ // initialize current editor
254
+ init();
255
+ }
256
+
257
+ // so we can do editor instanceof SlickCompositeEditor OR instanceof CompositeEditor
258
+ editor.prototype = this;
259
+
260
+ return editor;
261
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './compositeEditor.factory';
2
+ export * from './slick-composite-editor.component';