@slickgrid-universal/composite-editor-component 2.5.0 → 2.6.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/dist/commonjs/compositeEditor.factory.js +237 -237
- package/dist/commonjs/index.js +18 -18
- package/dist/commonjs/slick-composite-editor.component.js +890 -890
- package/dist/esm/compositeEditor.factory.js +233 -233
- package/dist/esm/index.js +2 -2
- package/dist/esm/slick-composite-editor.component.js +886 -886
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/{commonjs → types}/compositeEditor.factory.d.ts +35 -34
- package/dist/types/compositeEditor.factory.d.ts.map +1 -0
- package/dist/{esm → types}/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{esm → types}/slick-composite-editor.component.d.ts +178 -177
- package/dist/types/slick-composite-editor.component.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/commonjs/index.d.ts +0 -2
- package/dist/commonjs/slick-composite-editor.component.d.ts +0 -177
- package/dist/esm/compositeEditor.factory.d.ts +0 -34
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompositeEditor = void 0;
|
|
4
|
-
const common_1 = require("@slickgrid-universal/common");
|
|
5
|
-
/**
|
|
6
|
-
* A composite SlickGrid editor factory.
|
|
7
|
-
* Generates an editor that is composed of multiple editors for given columns.
|
|
8
|
-
* Individual editors are provided given containers instead of the original cell.
|
|
9
|
-
* Validation will be performed on all editors individually and the results will be aggregated into one
|
|
10
|
-
* validation result.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* The returned editor will have its prototype set to CompositeEditor, so you can use the "instanceof" check.
|
|
14
|
-
*
|
|
15
|
-
* NOTE: This doesn't work for detached editors since they will be created and positioned relative to the
|
|
16
|
-
* active cell and not the provided container.
|
|
17
|
-
*
|
|
18
|
-
* @class CompositeEditor
|
|
19
|
-
* @constructor
|
|
20
|
-
* @param columns {Array} Column definitions from which editors will be pulled.
|
|
21
|
-
* @param containers {Array} Container HTMLElements in which editors will be placed.
|
|
22
|
-
* @param options {Object} Options hash:
|
|
23
|
-
* validationFailedMsg - A generic failed validation message set on the aggregated validation resuls.
|
|
24
|
-
* validationMsgPrefix - Add an optional prefix to each validation message (only the ones shown in the modal form, not the ones in the "errors")
|
|
25
|
-
* modalType - Defaults to "edit", modal type can 1 of these 3: (create, edit, mass, mass-selection)
|
|
26
|
-
* hide - A function to be called when the grid asks the editor to hide itself.
|
|
27
|
-
* show - A function to be called when the grid asks the editor to show itself.
|
|
28
|
-
* position - A function to be called when the grid asks the editor to reposition itself.
|
|
29
|
-
* destroy - A function to be called when the editor is destroyed.
|
|
30
|
-
*/
|
|
31
|
-
function CompositeEditor(columns, containers, options) {
|
|
32
|
-
let firstInvalidEditor;
|
|
33
|
-
const defaultOptions = {
|
|
34
|
-
modalType: 'edit',
|
|
35
|
-
validationFailedMsg: 'Some of the fields have failed validation',
|
|
36
|
-
validationMsgPrefix: null,
|
|
37
|
-
show: null,
|
|
38
|
-
hide: null,
|
|
39
|
-
position: null,
|
|
40
|
-
destroy: null,
|
|
41
|
-
formValues: {},
|
|
42
|
-
editors: {}
|
|
43
|
-
};
|
|
44
|
-
options = { ...defaultOptions, ...options };
|
|
45
|
-
/* no operation (empty) function */
|
|
46
|
-
const noop = () => { };
|
|
47
|
-
const getContainerBox = (i) => {
|
|
48
|
-
var _a, _b, _c, _d, _e, _f;
|
|
49
|
-
const container = containers[i];
|
|
50
|
-
const offset = (0, common_1.getHtmlElementOffset)(container);
|
|
51
|
-
const width = (_a = container === null || container === void 0 ? void 0 : container.clientWidth) !== null && _a !== void 0 ? _a : 0;
|
|
52
|
-
const height = (_b = container === null || container === void 0 ? void 0 : container.clientHeight) !== null && _b !== void 0 ? _b : 0;
|
|
53
|
-
return {
|
|
54
|
-
top: (_c = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _c !== void 0 ? _c : 0,
|
|
55
|
-
left: (_d = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _d !== void 0 ? _d : 0,
|
|
56
|
-
bottom: ((_e = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _e !== void 0 ? _e : 0) + height,
|
|
57
|
-
right: ((_f = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _f !== void 0 ? _f : 0) + width,
|
|
58
|
-
width,
|
|
59
|
-
height,
|
|
60
|
-
visible: true
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
/* Editor prototype that will get instantiated dynamically by looping through each Editors */
|
|
64
|
-
function editor(args) {
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
66
|
-
const context = this;
|
|
67
|
-
let editors = [];
|
|
68
|
-
function init() {
|
|
69
|
-
let newArgs = {};
|
|
70
|
-
let idx = 0;
|
|
71
|
-
while (idx < columns.length) {
|
|
72
|
-
if (columns[idx].editor) {
|
|
73
|
-
const column = columns[idx];
|
|
74
|
-
newArgs = { ...args };
|
|
75
|
-
newArgs.container = containers[idx];
|
|
76
|
-
newArgs.column = column;
|
|
77
|
-
newArgs.position = getContainerBox(idx);
|
|
78
|
-
newArgs.commitChanges = noop;
|
|
79
|
-
newArgs.cancelChanges = noop;
|
|
80
|
-
newArgs.compositeEditorOptions = options;
|
|
81
|
-
newArgs.formValues = {};
|
|
82
|
-
const currentEditor = new column.editor(newArgs);
|
|
83
|
-
options.editors[column.id] = currentEditor; // add every Editor instance refs
|
|
84
|
-
editors.push(currentEditor);
|
|
85
|
-
}
|
|
86
|
-
idx++;
|
|
87
|
-
}
|
|
88
|
-
// focus on first input
|
|
89
|
-
setTimeout(() => {
|
|
90
|
-
if (Array.isArray(editors) && editors.length > 0 && typeof editors[0].focus === 'function') {
|
|
91
|
-
editors[0].focus();
|
|
92
|
-
}
|
|
93
|
-
}, 0);
|
|
94
|
-
}
|
|
95
|
-
context.getEditors = () => {
|
|
96
|
-
return editors;
|
|
97
|
-
};
|
|
98
|
-
context.destroy = () => {
|
|
99
|
-
var _a;
|
|
100
|
-
let tmpEditor = editors.pop();
|
|
101
|
-
while (tmpEditor) {
|
|
102
|
-
tmpEditor === null || tmpEditor === void 0 ? void 0 : tmpEditor.destroy();
|
|
103
|
-
tmpEditor = editors.pop();
|
|
104
|
-
}
|
|
105
|
-
let tmpContainer = containers.pop();
|
|
106
|
-
while (tmpContainer) {
|
|
107
|
-
(0, common_1.emptyElement)(tmpContainer);
|
|
108
|
-
tmpContainer === null || tmpContainer === void 0 ? void 0 : tmpContainer.remove();
|
|
109
|
-
tmpContainer = containers.pop();
|
|
110
|
-
}
|
|
111
|
-
(_a = options === null || options === void 0 ? void 0 : options.destroy) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
112
|
-
editors = [];
|
|
113
|
-
containers = null;
|
|
114
|
-
};
|
|
115
|
-
context.focus = () => {
|
|
116
|
-
// if validation has failed, set the focus to the first invalid editor
|
|
117
|
-
(firstInvalidEditor || editors[0]).focus();
|
|
118
|
-
};
|
|
119
|
-
context.isValueChanged = () => {
|
|
120
|
-
let idx = 0;
|
|
121
|
-
while (idx < editors.length) {
|
|
122
|
-
if (editors[idx].isValueChanged()) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
idx++;
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
};
|
|
129
|
-
context.serializeValue = () => {
|
|
130
|
-
const serializedValue = [];
|
|
131
|
-
let idx = 0;
|
|
132
|
-
while (idx < editors.length) {
|
|
133
|
-
serializedValue[idx] = editors[idx].serializeValue();
|
|
134
|
-
idx++;
|
|
135
|
-
}
|
|
136
|
-
return serializedValue;
|
|
137
|
-
};
|
|
138
|
-
context.applyValue = (item, state) => {
|
|
139
|
-
let idx = 0;
|
|
140
|
-
while (idx < editors.length) {
|
|
141
|
-
editors[idx].applyValue(item, state === null || state === void 0 ? void 0 : state[idx]);
|
|
142
|
-
idx++;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
context.loadValue = (item) => {
|
|
146
|
-
let idx = 0;
|
|
147
|
-
while (idx < editors.length) {
|
|
148
|
-
editors[idx].loadValue(item);
|
|
149
|
-
idx++;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
context.validate = (targetElm) => {
|
|
153
|
-
var _a, _b;
|
|
154
|
-
let validationResults;
|
|
155
|
-
firstInvalidEditor = null;
|
|
156
|
-
const errors = [];
|
|
157
|
-
let idx = 0;
|
|
158
|
-
while (idx < editors.length) {
|
|
159
|
-
const columnDef = (_a = editors[idx].args) === null || _a === void 0 ? void 0 : _a.column;
|
|
160
|
-
if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.id) !== undefined) {
|
|
161
|
-
const compositeModalElm = document.querySelector(`.slick-editor-modal`);
|
|
162
|
-
let validationElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`.item-details-validation.editor-${columnDef.id}`);
|
|
163
|
-
let labelElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`.item-details-label.editor-${columnDef.id}`);
|
|
164
|
-
let editorElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`[data-editorid=${columnDef.id}]`);
|
|
165
|
-
const validationMsgPrefix = (_b = options === null || options === void 0 ? void 0 : options.validationMsgPrefix) !== null && _b !== void 0 ? _b : '';
|
|
166
|
-
if (!targetElm || (editorElm === null || editorElm === void 0 ? void 0 : editorElm.contains(targetElm))) {
|
|
167
|
-
validationResults = editors[idx].validate();
|
|
168
|
-
if (!validationResults.valid) {
|
|
169
|
-
firstInvalidEditor = editors[idx];
|
|
170
|
-
errors.push({
|
|
171
|
-
index: idx,
|
|
172
|
-
editor: editors[idx],
|
|
173
|
-
container: containers[idx],
|
|
174
|
-
msg: validationResults.msg
|
|
175
|
-
});
|
|
176
|
-
if (validationElm) {
|
|
177
|
-
validationElm.textContent = `${validationMsgPrefix}${validationResults.msg}`;
|
|
178
|
-
labelElm === null || labelElm === void 0 ? void 0 : labelElm.classList.add('invalid');
|
|
179
|
-
editorElm === null || editorElm === void 0 ? void 0 : editorElm.classList.add('invalid');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else if (validationElm) {
|
|
183
|
-
validationElm.textContent = '';
|
|
184
|
-
editorElm === null || editorElm === void 0 ? void 0 : editorElm.classList.remove('invalid');
|
|
185
|
-
labelElm === null || labelElm === void 0 ? void 0 : labelElm.classList.remove('invalid');
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
validationElm = null;
|
|
189
|
-
labelElm = null;
|
|
190
|
-
editorElm = null;
|
|
191
|
-
}
|
|
192
|
-
idx++;
|
|
193
|
-
}
|
|
194
|
-
targetElm = null;
|
|
195
|
-
if (errors.length) {
|
|
196
|
-
return {
|
|
197
|
-
valid: false,
|
|
198
|
-
msg: options.validationFailedMsg,
|
|
199
|
-
errors
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
valid: true,
|
|
204
|
-
msg: ''
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
context.hide = () => {
|
|
208
|
-
var _a, _b, _c;
|
|
209
|
-
let idx = 0;
|
|
210
|
-
while (idx < editors.length) {
|
|
211
|
-
(_b = (_a = editors[idx]) === null || _a === void 0 ? void 0 : _a.hide) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
212
|
-
idx++;
|
|
213
|
-
}
|
|
214
|
-
(_c = options === null || options === void 0 ? void 0 : options.hide) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
215
|
-
};
|
|
216
|
-
context.show = () => {
|
|
217
|
-
var _a, _b, _c;
|
|
218
|
-
let idx = 0;
|
|
219
|
-
while (idx < editors.length) {
|
|
220
|
-
(_b = (_a = editors[idx]) === null || _a === void 0 ? void 0 : _a.show) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
221
|
-
idx++;
|
|
222
|
-
}
|
|
223
|
-
(_c = options === null || options === void 0 ? void 0 : options.show) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
224
|
-
};
|
|
225
|
-
context.position = (box) => {
|
|
226
|
-
var _a;
|
|
227
|
-
(_a = options === null || options === void 0 ? void 0 : options.position) === null || _a === void 0 ? void 0 : _a.call(options, box);
|
|
228
|
-
};
|
|
229
|
-
// initialize current editor
|
|
230
|
-
init();
|
|
231
|
-
}
|
|
232
|
-
// so we can do editor instanceof Slick.CompositeEditor OR instanceof CompositeEditor
|
|
233
|
-
editor.prototype = this;
|
|
234
|
-
Slick.CompositeEditor = editor;
|
|
235
|
-
return editor;
|
|
236
|
-
}
|
|
237
|
-
exports.CompositeEditor = CompositeEditor;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositeEditor = void 0;
|
|
4
|
+
const common_1 = require("@slickgrid-universal/common");
|
|
5
|
+
/**
|
|
6
|
+
* A composite SlickGrid editor factory.
|
|
7
|
+
* Generates an editor that is composed of multiple editors for given columns.
|
|
8
|
+
* Individual editors are provided given containers instead of the original cell.
|
|
9
|
+
* Validation will be performed on all editors individually and the results will be aggregated into one
|
|
10
|
+
* validation result.
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* The returned editor will have its prototype set to CompositeEditor, so you can use the "instanceof" check.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: This doesn't work for detached editors since they will be created and positioned relative to the
|
|
16
|
+
* active cell and not the provided container.
|
|
17
|
+
*
|
|
18
|
+
* @class CompositeEditor
|
|
19
|
+
* @constructor
|
|
20
|
+
* @param columns {Array} Column definitions from which editors will be pulled.
|
|
21
|
+
* @param containers {Array} Container HTMLElements in which editors will be placed.
|
|
22
|
+
* @param options {Object} Options hash:
|
|
23
|
+
* validationFailedMsg - A generic failed validation message set on the aggregated validation resuls.
|
|
24
|
+
* validationMsgPrefix - Add an optional prefix to each validation message (only the ones shown in the modal form, not the ones in the "errors")
|
|
25
|
+
* modalType - Defaults to "edit", modal type can 1 of these 3: (create, edit, mass, mass-selection)
|
|
26
|
+
* hide - A function to be called when the grid asks the editor to hide itself.
|
|
27
|
+
* show - A function to be called when the grid asks the editor to show itself.
|
|
28
|
+
* position - A function to be called when the grid asks the editor to reposition itself.
|
|
29
|
+
* destroy - A function to be called when the editor is destroyed.
|
|
30
|
+
*/
|
|
31
|
+
function CompositeEditor(columns, containers, options) {
|
|
32
|
+
let firstInvalidEditor;
|
|
33
|
+
const defaultOptions = {
|
|
34
|
+
modalType: 'edit',
|
|
35
|
+
validationFailedMsg: 'Some of the fields have failed validation',
|
|
36
|
+
validationMsgPrefix: null,
|
|
37
|
+
show: null,
|
|
38
|
+
hide: null,
|
|
39
|
+
position: null,
|
|
40
|
+
destroy: null,
|
|
41
|
+
formValues: {},
|
|
42
|
+
editors: {}
|
|
43
|
+
};
|
|
44
|
+
options = { ...defaultOptions, ...options };
|
|
45
|
+
/* no operation (empty) function */
|
|
46
|
+
const noop = () => { };
|
|
47
|
+
const getContainerBox = (i) => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
|
+
const container = containers[i];
|
|
50
|
+
const offset = (0, common_1.getHtmlElementOffset)(container);
|
|
51
|
+
const width = (_a = container === null || container === void 0 ? void 0 : container.clientWidth) !== null && _a !== void 0 ? _a : 0;
|
|
52
|
+
const height = (_b = container === null || container === void 0 ? void 0 : container.clientHeight) !== null && _b !== void 0 ? _b : 0;
|
|
53
|
+
return {
|
|
54
|
+
top: (_c = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _c !== void 0 ? _c : 0,
|
|
55
|
+
left: (_d = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _d !== void 0 ? _d : 0,
|
|
56
|
+
bottom: ((_e = offset === null || offset === void 0 ? void 0 : offset.top) !== null && _e !== void 0 ? _e : 0) + height,
|
|
57
|
+
right: ((_f = offset === null || offset === void 0 ? void 0 : offset.left) !== null && _f !== void 0 ? _f : 0) + width,
|
|
58
|
+
width,
|
|
59
|
+
height,
|
|
60
|
+
visible: true
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/* Editor prototype that will get instantiated dynamically by looping through each Editors */
|
|
64
|
+
function editor(args) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
66
|
+
const context = this;
|
|
67
|
+
let editors = [];
|
|
68
|
+
function init() {
|
|
69
|
+
let newArgs = {};
|
|
70
|
+
let idx = 0;
|
|
71
|
+
while (idx < columns.length) {
|
|
72
|
+
if (columns[idx].editor) {
|
|
73
|
+
const column = columns[idx];
|
|
74
|
+
newArgs = { ...args };
|
|
75
|
+
newArgs.container = containers[idx];
|
|
76
|
+
newArgs.column = column;
|
|
77
|
+
newArgs.position = getContainerBox(idx);
|
|
78
|
+
newArgs.commitChanges = noop;
|
|
79
|
+
newArgs.cancelChanges = noop;
|
|
80
|
+
newArgs.compositeEditorOptions = options;
|
|
81
|
+
newArgs.formValues = {};
|
|
82
|
+
const currentEditor = new column.editor(newArgs);
|
|
83
|
+
options.editors[column.id] = currentEditor; // add every Editor instance refs
|
|
84
|
+
editors.push(currentEditor);
|
|
85
|
+
}
|
|
86
|
+
idx++;
|
|
87
|
+
}
|
|
88
|
+
// focus on first input
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
if (Array.isArray(editors) && editors.length > 0 && typeof editors[0].focus === 'function') {
|
|
91
|
+
editors[0].focus();
|
|
92
|
+
}
|
|
93
|
+
}, 0);
|
|
94
|
+
}
|
|
95
|
+
context.getEditors = () => {
|
|
96
|
+
return editors;
|
|
97
|
+
};
|
|
98
|
+
context.destroy = () => {
|
|
99
|
+
var _a;
|
|
100
|
+
let tmpEditor = editors.pop();
|
|
101
|
+
while (tmpEditor) {
|
|
102
|
+
tmpEditor === null || tmpEditor === void 0 ? void 0 : tmpEditor.destroy();
|
|
103
|
+
tmpEditor = editors.pop();
|
|
104
|
+
}
|
|
105
|
+
let tmpContainer = containers.pop();
|
|
106
|
+
while (tmpContainer) {
|
|
107
|
+
(0, common_1.emptyElement)(tmpContainer);
|
|
108
|
+
tmpContainer === null || tmpContainer === void 0 ? void 0 : tmpContainer.remove();
|
|
109
|
+
tmpContainer = containers.pop();
|
|
110
|
+
}
|
|
111
|
+
(_a = options === null || options === void 0 ? void 0 : options.destroy) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
112
|
+
editors = [];
|
|
113
|
+
containers = null;
|
|
114
|
+
};
|
|
115
|
+
context.focus = () => {
|
|
116
|
+
// if validation has failed, set the focus to the first invalid editor
|
|
117
|
+
(firstInvalidEditor || editors[0]).focus();
|
|
118
|
+
};
|
|
119
|
+
context.isValueChanged = () => {
|
|
120
|
+
let idx = 0;
|
|
121
|
+
while (idx < editors.length) {
|
|
122
|
+
if (editors[idx].isValueChanged()) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
idx++;
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
};
|
|
129
|
+
context.serializeValue = () => {
|
|
130
|
+
const serializedValue = [];
|
|
131
|
+
let idx = 0;
|
|
132
|
+
while (idx < editors.length) {
|
|
133
|
+
serializedValue[idx] = editors[idx].serializeValue();
|
|
134
|
+
idx++;
|
|
135
|
+
}
|
|
136
|
+
return serializedValue;
|
|
137
|
+
};
|
|
138
|
+
context.applyValue = (item, state) => {
|
|
139
|
+
let idx = 0;
|
|
140
|
+
while (idx < editors.length) {
|
|
141
|
+
editors[idx].applyValue(item, state === null || state === void 0 ? void 0 : state[idx]);
|
|
142
|
+
idx++;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
context.loadValue = (item) => {
|
|
146
|
+
let idx = 0;
|
|
147
|
+
while (idx < editors.length) {
|
|
148
|
+
editors[idx].loadValue(item);
|
|
149
|
+
idx++;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
context.validate = (targetElm) => {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
let validationResults;
|
|
155
|
+
firstInvalidEditor = null;
|
|
156
|
+
const errors = [];
|
|
157
|
+
let idx = 0;
|
|
158
|
+
while (idx < editors.length) {
|
|
159
|
+
const columnDef = (_a = editors[idx].args) === null || _a === void 0 ? void 0 : _a.column;
|
|
160
|
+
if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.id) !== undefined) {
|
|
161
|
+
const compositeModalElm = document.querySelector(`.slick-editor-modal`);
|
|
162
|
+
let validationElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`.item-details-validation.editor-${columnDef.id}`);
|
|
163
|
+
let labelElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`.item-details-label.editor-${columnDef.id}`);
|
|
164
|
+
let editorElm = compositeModalElm === null || compositeModalElm === void 0 ? void 0 : compositeModalElm.querySelector(`[data-editorid=${columnDef.id}]`);
|
|
165
|
+
const validationMsgPrefix = (_b = options === null || options === void 0 ? void 0 : options.validationMsgPrefix) !== null && _b !== void 0 ? _b : '';
|
|
166
|
+
if (!targetElm || (editorElm === null || editorElm === void 0 ? void 0 : editorElm.contains(targetElm))) {
|
|
167
|
+
validationResults = editors[idx].validate();
|
|
168
|
+
if (!validationResults.valid) {
|
|
169
|
+
firstInvalidEditor = editors[idx];
|
|
170
|
+
errors.push({
|
|
171
|
+
index: idx,
|
|
172
|
+
editor: editors[idx],
|
|
173
|
+
container: containers[idx],
|
|
174
|
+
msg: validationResults.msg
|
|
175
|
+
});
|
|
176
|
+
if (validationElm) {
|
|
177
|
+
validationElm.textContent = `${validationMsgPrefix}${validationResults.msg}`;
|
|
178
|
+
labelElm === null || labelElm === void 0 ? void 0 : labelElm.classList.add('invalid');
|
|
179
|
+
editorElm === null || editorElm === void 0 ? void 0 : editorElm.classList.add('invalid');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (validationElm) {
|
|
183
|
+
validationElm.textContent = '';
|
|
184
|
+
editorElm === null || editorElm === void 0 ? void 0 : editorElm.classList.remove('invalid');
|
|
185
|
+
labelElm === null || labelElm === void 0 ? void 0 : labelElm.classList.remove('invalid');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
validationElm = null;
|
|
189
|
+
labelElm = null;
|
|
190
|
+
editorElm = null;
|
|
191
|
+
}
|
|
192
|
+
idx++;
|
|
193
|
+
}
|
|
194
|
+
targetElm = null;
|
|
195
|
+
if (errors.length) {
|
|
196
|
+
return {
|
|
197
|
+
valid: false,
|
|
198
|
+
msg: options.validationFailedMsg,
|
|
199
|
+
errors
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
valid: true,
|
|
204
|
+
msg: ''
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
context.hide = () => {
|
|
208
|
+
var _a, _b, _c;
|
|
209
|
+
let idx = 0;
|
|
210
|
+
while (idx < editors.length) {
|
|
211
|
+
(_b = (_a = editors[idx]) === null || _a === void 0 ? void 0 : _a.hide) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
212
|
+
idx++;
|
|
213
|
+
}
|
|
214
|
+
(_c = options === null || options === void 0 ? void 0 : options.hide) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
215
|
+
};
|
|
216
|
+
context.show = () => {
|
|
217
|
+
var _a, _b, _c;
|
|
218
|
+
let idx = 0;
|
|
219
|
+
while (idx < editors.length) {
|
|
220
|
+
(_b = (_a = editors[idx]) === null || _a === void 0 ? void 0 : _a.show) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
221
|
+
idx++;
|
|
222
|
+
}
|
|
223
|
+
(_c = options === null || options === void 0 ? void 0 : options.show) === null || _c === void 0 ? void 0 : _c.call(options);
|
|
224
|
+
};
|
|
225
|
+
context.position = (box) => {
|
|
226
|
+
var _a;
|
|
227
|
+
(_a = options === null || options === void 0 ? void 0 : options.position) === null || _a === void 0 ? void 0 : _a.call(options, box);
|
|
228
|
+
};
|
|
229
|
+
// initialize current editor
|
|
230
|
+
init();
|
|
231
|
+
}
|
|
232
|
+
// so we can do editor instanceof Slick.CompositeEditor OR instanceof CompositeEditor
|
|
233
|
+
editor.prototype = this;
|
|
234
|
+
Slick.CompositeEditor = editor;
|
|
235
|
+
return editor;
|
|
236
|
+
}
|
|
237
|
+
exports.CompositeEditor = CompositeEditor;
|
|
238
238
|
//# sourceMappingURL=compositeEditor.factory.js.map
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./compositeEditor.factory"), exports);
|
|
18
|
-
__exportStar(require("./slick-composite-editor.component"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./compositeEditor.factory"), exports);
|
|
18
|
+
__exportStar(require("./slick-composite-editor.component"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|