@verdocs/web-sdk 1.16.2 → 1.16.4
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/verdocs-button-panel_3.cjs.entry.js +15 -15
- package/dist/cjs/verdocs-field-textbox.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +3 -2
- package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.js +1 -1
- package/dist/collection/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.js +21 -17
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +3 -2
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.stories.js +1 -1
- package/dist/components/verdocs-field-textbox.js +1 -1
- package/dist/components/verdocs-template-field-properties2.js +15 -15
- package/dist/components/verdocs-template-fields2.js +3 -2
- package/dist/docs.json +2 -2
- package/dist/esm/verdocs-button-panel_3.entry.js +15 -15
- package/dist/esm/verdocs-field-textbox.entry.js +1 -1
- package/dist/esm/verdocs-template-fields_4.entry.js +3 -2
- package/dist/esm-es5/verdocs-button-panel_3.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-fields_4.entry.js +1 -1
- package/dist/types/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.d.ts +3 -2
- package/dist/types/components.d.ts +1 -1
- package/dist/verdocs-web-sdk/p-0a4be7e5.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-a9ecf297.entry.js → p-4ab54e29.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-698c0f03.system.entry.js → p-4ed347fe.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-647cdb84.system.js +1 -1
- package/dist/verdocs-web-sdk/p-cdf71be7.entry.js +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/verdocs-web-sdk/p-1a859044.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-e202ce0e.system.entry.js +0 -1
@@ -403,13 +403,12 @@ const VerdocsTemplateFieldProperties = class {
|
|
403
403
|
options: this.options,
|
404
404
|
};
|
405
405
|
}
|
406
|
-
console.log('will', newProperties);
|
407
406
|
Fields.updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
408
|
-
.then(
|
407
|
+
.then(field => {
|
409
408
|
var _a, _b;
|
410
409
|
this.dirty = false;
|
411
|
-
this.updateField();
|
412
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
410
|
+
this.updateField(field);
|
411
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
413
412
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
414
413
|
})
|
415
414
|
.catch(() => {
|
@@ -443,29 +442,30 @@ const VerdocsTemplateFieldProperties = class {
|
|
443
442
|
delete newProperties.setting.result;
|
444
443
|
newProperties.setting.options = [...this.options];
|
445
444
|
Fields.updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
446
|
-
.then(
|
445
|
+
.then(field => {
|
447
446
|
var _a, _b;
|
448
447
|
this.dirty = false;
|
449
|
-
this.updateField();
|
450
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
448
|
+
this.updateField(field);
|
449
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
451
450
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
452
451
|
})
|
453
452
|
.catch(() => {
|
454
453
|
console.log('Field update failed', e);
|
455
454
|
});
|
456
455
|
}
|
457
|
-
updateField() {
|
456
|
+
updateField(newField) {
|
458
457
|
const newFields = [...this.store.state.fields];
|
459
458
|
newFields.forEach(field => {
|
460
459
|
if (field.name === this.fieldName) {
|
461
|
-
field
|
462
|
-
field.
|
463
|
-
field.
|
464
|
-
field.
|
460
|
+
Object.assign(field, newField);
|
461
|
+
// field.name = this.name;
|
462
|
+
// field.role_name = this.roleName;
|
463
|
+
// field.required = this.required;
|
464
|
+
// field.label = this.placeholder;
|
465
465
|
// field.setting.result = this.defaultValue;
|
466
|
-
if (field.setting.options) {
|
467
|
-
|
468
|
-
}
|
466
|
+
// if (field.setting.options) {
|
467
|
+
// field.setting.options = this.options;
|
468
|
+
// }
|
469
469
|
}
|
470
470
|
});
|
471
471
|
this.store.state.fields = newFields;
|
@@ -104,7 +104,7 @@ const VerdocsFieldTextbox = class {
|
|
104
104
|
const backgroundColor = this.field['rgba'] || Colors.getRGBA(this.roleindex);
|
105
105
|
const value = (settings === null || settings === void 0 ? void 0 : settings.result) || '';
|
106
106
|
const width = settings.width || 150;
|
107
|
-
// TODO: This is an
|
107
|
+
// TODO: This is an outdated technique from the old system. We should compute it.
|
108
108
|
const maxlength = width / 5;
|
109
109
|
if (this.done) {
|
110
110
|
return index.h(index.Host, { class: { done: this.done } }, value);
|
@@ -143,8 +143,9 @@ const VerdocsTemplateFields = class {
|
|
143
143
|
el.addEventListener('settingsChanged', e => {
|
144
144
|
var _a, _b, _c, _d;
|
145
145
|
console.log('[FIELDS] settingsChanged', e.detail);
|
146
|
-
Object.assign(field
|
146
|
+
Object.assign(field, e.detail.field);
|
147
147
|
this.selectedRoleName = field.role_name;
|
148
|
+
el.field = e.detail.field;
|
148
149
|
el.setAttribute('roleindex', utils.getRoleIndex(TemplateStore.getRoleNames(this.store), field.role_name));
|
149
150
|
el.field = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.fields.find(f => f.name === field.name);
|
150
151
|
this.rerender++;
|
@@ -159,7 +160,7 @@ const VerdocsTemplateFields = class {
|
|
159
160
|
});
|
160
161
|
el.addEventListener('deleted', () => {
|
161
162
|
var _a, _b;
|
162
|
-
console.log('
|
163
|
+
console.log('[FIELDS] Deleted', this, field);
|
163
164
|
el.remove();
|
164
165
|
this.rerender++;
|
165
166
|
(_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state, event: 'updated-field' });
|
@@ -90,7 +90,7 @@ export class VerdocsFieldTextbox {
|
|
90
90
|
const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
|
91
91
|
const value = (settings === null || settings === void 0 ? void 0 : settings.result) || '';
|
92
92
|
const width = settings.width || 150;
|
93
|
-
// TODO: This is an
|
93
|
+
// TODO: This is an outdated technique from the old system. We should compute it.
|
94
94
|
const maxlength = width / 5;
|
95
95
|
if (this.done) {
|
96
96
|
return h(Host, { class: { done: this.done } }, value);
|
@@ -113,13 +113,12 @@ export class VerdocsTemplateFieldProperties {
|
|
113
113
|
options: this.options,
|
114
114
|
};
|
115
115
|
}
|
116
|
-
console.log('will', newProperties);
|
117
116
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
118
|
-
.then(
|
117
|
+
.then(field => {
|
119
118
|
var _a, _b;
|
120
119
|
this.dirty = false;
|
121
|
-
this.updateField();
|
122
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
120
|
+
this.updateField(field);
|
121
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
123
122
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
124
123
|
})
|
125
124
|
.catch(() => {
|
@@ -153,29 +152,30 @@ export class VerdocsTemplateFieldProperties {
|
|
153
152
|
delete newProperties.setting.result;
|
154
153
|
newProperties.setting.options = [...this.options];
|
155
154
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
156
|
-
.then(
|
155
|
+
.then(field => {
|
157
156
|
var _a, _b;
|
158
157
|
this.dirty = false;
|
159
|
-
this.updateField();
|
160
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
158
|
+
this.updateField(field);
|
159
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
161
160
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
162
161
|
})
|
163
162
|
.catch(() => {
|
164
163
|
console.log('Field update failed', e);
|
165
164
|
});
|
166
165
|
}
|
167
|
-
updateField() {
|
166
|
+
updateField(newField) {
|
168
167
|
const newFields = [...this.store.state.fields];
|
169
168
|
newFields.forEach(field => {
|
170
169
|
if (field.name === this.fieldName) {
|
171
|
-
field
|
172
|
-
field.
|
173
|
-
field.
|
174
|
-
field.
|
170
|
+
Object.assign(field, newField);
|
171
|
+
// field.name = this.name;
|
172
|
+
// field.role_name = this.roleName;
|
173
|
+
// field.required = this.required;
|
174
|
+
// field.label = this.placeholder;
|
175
175
|
// field.setting.result = this.defaultValue;
|
176
|
-
if (field.setting.options) {
|
177
|
-
|
178
|
-
}
|
176
|
+
// if (field.setting.options) {
|
177
|
+
// field.setting.options = this.options;
|
178
|
+
// }
|
179
179
|
}
|
180
180
|
});
|
181
181
|
this.store.state.fields = newFields;
|
@@ -403,12 +403,16 @@ export class VerdocsTemplateFieldProperties {
|
|
403
403
|
"text": "Event fired when the field's settings are changed."
|
404
404
|
},
|
405
405
|
"complexType": {
|
406
|
-
"original": "{fieldName: string; settings: ITemplateFieldSetting}",
|
407
|
-
"resolved": "{ fieldName: string; settings: ITemplateFieldSetting; }",
|
406
|
+
"original": "{fieldName: string; settings: ITemplateFieldSetting; field: ITemplateField}",
|
407
|
+
"resolved": "{ fieldName: string; settings: ITemplateFieldSetting; field: ITemplateField; }",
|
408
408
|
"references": {
|
409
409
|
"ITemplateFieldSetting": {
|
410
410
|
"location": "import",
|
411
411
|
"path": "@verdocs/js-sdk/Templates/Types"
|
412
|
+
},
|
413
|
+
"ITemplateField": {
|
414
|
+
"location": "import",
|
415
|
+
"path": "@verdocs/js-sdk/Templates/Types"
|
412
416
|
}
|
413
417
|
}
|
414
418
|
}
|
package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js
CHANGED
@@ -104,8 +104,9 @@ export class VerdocsTemplateFields {
|
|
104
104
|
el.addEventListener('settingsChanged', e => {
|
105
105
|
var _a, _b, _c, _d;
|
106
106
|
console.log('[FIELDS] settingsChanged', e.detail);
|
107
|
-
Object.assign(field
|
107
|
+
Object.assign(field, e.detail.field);
|
108
108
|
this.selectedRoleName = field.role_name;
|
109
|
+
el.field = e.detail.field;
|
109
110
|
el.setAttribute('roleindex', getRoleIndex(getRoleNames(this.store), field.role_name));
|
110
111
|
el.field = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.fields.find(f => f.name === field.name);
|
111
112
|
this.rerender++;
|
@@ -120,7 +121,7 @@ export class VerdocsTemplateFields {
|
|
120
121
|
});
|
121
122
|
el.addEventListener('deleted', () => {
|
122
123
|
var _a, _b;
|
123
|
-
console.log('
|
124
|
+
console.log('[FIELDS] Deleted', this, field);
|
124
125
|
el.remove();
|
125
126
|
this.rerender++;
|
126
127
|
(_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state, event: 'updated-field' });
|
@@ -103,7 +103,7 @@ const VerdocsFieldTextbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
103
103
|
const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
|
104
104
|
const value = (settings === null || settings === void 0 ? void 0 : settings.result) || '';
|
105
105
|
const width = settings.width || 150;
|
106
|
-
// TODO: This is an
|
106
|
+
// TODO: This is an outdated technique from the old system. We should compute it.
|
107
107
|
const maxlength = width / 5;
|
108
108
|
if (this.done) {
|
109
109
|
return h(Host, { class: { done: this.done } }, value);
|
@@ -315,13 +315,12 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
|
|
315
315
|
options: this.options,
|
316
316
|
};
|
317
317
|
}
|
318
|
-
console.log('will', newProperties);
|
319
318
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
320
|
-
.then(
|
319
|
+
.then(field => {
|
321
320
|
var _a, _b;
|
322
321
|
this.dirty = false;
|
323
|
-
this.updateField();
|
324
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
322
|
+
this.updateField(field);
|
323
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
325
324
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
326
325
|
})
|
327
326
|
.catch(() => {
|
@@ -355,29 +354,30 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
|
|
355
354
|
delete newProperties.setting.result;
|
356
355
|
newProperties.setting.options = [...this.options];
|
357
356
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
358
|
-
.then(
|
357
|
+
.then(field => {
|
359
358
|
var _a, _b;
|
360
359
|
this.dirty = false;
|
361
|
-
this.updateField();
|
362
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
360
|
+
this.updateField(field);
|
361
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
363
362
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
364
363
|
})
|
365
364
|
.catch(() => {
|
366
365
|
console.log('Field update failed', e);
|
367
366
|
});
|
368
367
|
}
|
369
|
-
updateField() {
|
368
|
+
updateField(newField) {
|
370
369
|
const newFields = [...this.store.state.fields];
|
371
370
|
newFields.forEach(field => {
|
372
371
|
if (field.name === this.fieldName) {
|
373
|
-
field
|
374
|
-
field.
|
375
|
-
field.
|
376
|
-
field.
|
372
|
+
Object.assign(field, newField);
|
373
|
+
// field.name = this.name;
|
374
|
+
// field.role_name = this.roleName;
|
375
|
+
// field.required = this.required;
|
376
|
+
// field.label = this.placeholder;
|
377
377
|
// field.setting.result = this.defaultValue;
|
378
|
-
if (field.setting.options) {
|
379
|
-
|
380
|
-
}
|
378
|
+
// if (field.setting.options) {
|
379
|
+
// field.setting.options = this.options;
|
380
|
+
// }
|
381
381
|
}
|
382
382
|
});
|
383
383
|
this.store.state.fields = newFields;
|
@@ -115,8 +115,9 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
115
115
|
el.addEventListener('settingsChanged', e => {
|
116
116
|
var _a, _b, _c, _d;
|
117
117
|
console.log('[FIELDS] settingsChanged', e.detail);
|
118
|
-
Object.assign(field
|
118
|
+
Object.assign(field, e.detail.field);
|
119
119
|
this.selectedRoleName = field.role_name;
|
120
|
+
el.field = e.detail.field;
|
120
121
|
el.setAttribute('roleindex', getRoleIndex(getRoleNames(this.store), field.role_name));
|
121
122
|
el.field = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.fields.find(f => f.name === field.name);
|
122
123
|
this.rerender++;
|
@@ -131,7 +132,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
131
132
|
});
|
132
133
|
el.addEventListener('deleted', () => {
|
133
134
|
var _a, _b;
|
134
|
-
console.log('
|
135
|
+
console.log('[FIELDS] Deleted', this, field);
|
135
136
|
el.remove();
|
136
137
|
this.rerender++;
|
137
138
|
(_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state, event: 'updated-field' });
|
package/dist/docs.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "2023-07-
|
2
|
+
"timestamp": "2023-07-10T17:03:58",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
5
|
"version": "2.20.0",
|
@@ -7353,7 +7353,7 @@
|
|
7353
7353
|
},
|
7354
7354
|
{
|
7355
7355
|
"event": "settingsChanged",
|
7356
|
-
"detail": "{ fieldName: string; settings: ITemplateFieldSetting; }",
|
7356
|
+
"detail": "{ fieldName: string; settings: ITemplateFieldSetting; field: ITemplateField; }",
|
7357
7357
|
"bubbles": true,
|
7358
7358
|
"cancelable": true,
|
7359
7359
|
"composed": true,
|
@@ -399,13 +399,12 @@ const VerdocsTemplateFieldProperties = class {
|
|
399
399
|
options: this.options,
|
400
400
|
};
|
401
401
|
}
|
402
|
-
console.log('will', newProperties);
|
403
402
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
404
|
-
.then(
|
403
|
+
.then(field => {
|
405
404
|
var _a, _b;
|
406
405
|
this.dirty = false;
|
407
|
-
this.updateField();
|
408
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
406
|
+
this.updateField(field);
|
407
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
409
408
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
410
409
|
})
|
411
410
|
.catch(() => {
|
@@ -439,29 +438,30 @@ const VerdocsTemplateFieldProperties = class {
|
|
439
438
|
delete newProperties.setting.result;
|
440
439
|
newProperties.setting.options = [...this.options];
|
441
440
|
updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
|
442
|
-
.then(
|
441
|
+
.then(field => {
|
443
442
|
var _a, _b;
|
444
443
|
this.dirty = false;
|
445
|
-
this.updateField();
|
446
|
-
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties });
|
444
|
+
this.updateField(field);
|
445
|
+
(_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName, settings: newProperties, field });
|
447
446
|
(_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
|
448
447
|
})
|
449
448
|
.catch(() => {
|
450
449
|
console.log('Field update failed', e);
|
451
450
|
});
|
452
451
|
}
|
453
|
-
updateField() {
|
452
|
+
updateField(newField) {
|
454
453
|
const newFields = [...this.store.state.fields];
|
455
454
|
newFields.forEach(field => {
|
456
455
|
if (field.name === this.fieldName) {
|
457
|
-
field
|
458
|
-
field.
|
459
|
-
field.
|
460
|
-
field.
|
456
|
+
Object.assign(field, newField);
|
457
|
+
// field.name = this.name;
|
458
|
+
// field.role_name = this.roleName;
|
459
|
+
// field.required = this.required;
|
460
|
+
// field.label = this.placeholder;
|
461
461
|
// field.setting.result = this.defaultValue;
|
462
|
-
if (field.setting.options) {
|
463
|
-
|
464
|
-
}
|
462
|
+
// if (field.setting.options) {
|
463
|
+
// field.setting.options = this.options;
|
464
|
+
// }
|
465
465
|
}
|
466
466
|
});
|
467
467
|
this.store.state.fields = newFields;
|
@@ -100,7 +100,7 @@ const VerdocsFieldTextbox = class {
|
|
100
100
|
const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
|
101
101
|
const value = (settings === null || settings === void 0 ? void 0 : settings.result) || '';
|
102
102
|
const width = settings.width || 150;
|
103
|
-
// TODO: This is an
|
103
|
+
// TODO: This is an outdated technique from the old system. We should compute it.
|
104
104
|
const maxlength = width / 5;
|
105
105
|
if (this.done) {
|
106
106
|
return h(Host, { class: { done: this.done } }, value);
|
@@ -139,8 +139,9 @@ const VerdocsTemplateFields = class {
|
|
139
139
|
el.addEventListener('settingsChanged', e => {
|
140
140
|
var _a, _b, _c, _d;
|
141
141
|
console.log('[FIELDS] settingsChanged', e.detail);
|
142
|
-
Object.assign(field
|
142
|
+
Object.assign(field, e.detail.field);
|
143
143
|
this.selectedRoleName = field.role_name;
|
144
|
+
el.field = e.detail.field;
|
144
145
|
el.setAttribute('roleindex', getRoleIndex(getRoleNames(this.store), field.role_name));
|
145
146
|
el.field = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.fields.find(f => f.name === field.name);
|
146
147
|
this.rerender++;
|
@@ -155,7 +156,7 @@ const VerdocsTemplateFields = class {
|
|
155
156
|
});
|
156
157
|
el.addEventListener('deleted', () => {
|
157
158
|
var _a, _b;
|
158
|
-
console.log('
|
159
|
+
console.log('[FIELDS] Deleted', this, field);
|
159
160
|
el.remove();
|
160
161
|
this.rerender++;
|
161
162
|
(_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.store) === null || _b === void 0 ? void 0 : _b.state, event: 'updated-field' });
|
@@ -1 +1 @@
|
|
1
|
-
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++){t=arguments[o];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,o,i){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i["throw"](e))}catch(e){r(e)}}function a(e){e.done?o(e.value):n(e.value).then(s,l)}a((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(t){return a([e,t])}}function a(s){if(i)throw new TypeError("Generator is already executing.");while(o)try{if(i=1,n&&(r=s[0]&2?n["return"]:s[0]?n["throw"]||((r=n["return"])&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;if(n=0,r)s=[s[0]&2,r.value];switch(s[0]){case 0:case 1:r=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;n=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(r=o.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(s[0]===6&&o.label<r[1]){o.label=r[1];r=s;break}if(r&&o.label<r[2]){o.label=r[2];o.ops.push(s);break}if(r[2])o.ops.pop();o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e];n=0}finally{i=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var i=0,n=t.length,r;i<n;i++){if(r||!(i in t)){if(!r)r=Array.prototype.slice.call(t,0,i);r[i]=t[i]}}return e.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,h,H as Host,c as createEvent,a as getElement}from"./index-151c0874.js";import{c as createPopper}from"./popper-bfa25c7f.js";import{a as commonjsGlobal}from"./_commonjsHelpers-5ec8f9b7.js";import"./Types-5f31149e.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-f65843b9.js";import{u as updateField,d as deleteField}from"./Fields-c82e6df3.js";import{g as getTemplateStore}from"./TemplateStore-bc248c04.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./index-38d7bc0b.js";import"./Templates-1893bda7.js";var verdocsButtonPanelCss='verdocs-button-panel{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:inline-block}verdocs-button-panel .icon{display:inline-block;cursor:pointer;opacity:0.6}verdocs-button-panel .icon svg{fill:#707ae5}verdocs-button-panel .icon:hover{opacity:1}.verdocs-button-panel-content{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-box-shadow:0 0 10px 1px #999999;box-shadow:0 0 10px 1px #999999;display:none;background:#ffffff;color:#33364b;width:320px;font-weight:bold;padding:15px;font-size:14px;position:relative;border-radius:4px;z-index:10000}.verdocs-button-panel-content .arrow,.verdocs-button-panel-content .arrow::before{position:absolute;width:8px;height:8px;background:inherit}.verdocs-button-panel-content .arrow{visibility:hidden;top:-4px}.verdocs-button-panel-content .arrow::before{visibility:visible;content:"";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.verdocs-button-panel-content[data-show]{display:block}.verdocs-button-panel-content[data-popper-placement^=top]>.arrow{bottom:-4px}.verdocs-button-panel-content[data-popper-placement^=bottom]>.arrow{top:-4px}.verdocs-button-panel-content[data-popper-placement^=left]>.arrow{right:-4px}.verdocs-button-panel-content[data-popper-placement^=right]>.arrow{left:-4px}.verdocs-button-panel-content h6{font-size:16px;font-weight:bold;margin:0 0 16px 0;color:#092c4c;border-bottom:1px solid #cccccc}';var VerdocsButtonPanel=function(){function e(e){registerInstance(this,e);this.showing=false;this.icon=""}e.prototype.componentDidRender=function(){document.body.appendChild(this.panelEl);if(this.popperInstance){this.popperInstance.destroy()}this.popperInstance=createPopper(this.iconEl,this.panelEl,{})};e.prototype.disconnectedCallback=function(){if(this.popperInstance){this.popperInstance.destroy();this.popperInstance=null}if(this.panelEl){this.panelEl.remove()}};e.prototype.showPanel=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;var o=this;return __generator(this,(function(i){(e=this.panelEl)===null||e===void 0?void 0:e.setAttribute("data-show","");(t=this.popperInstance)===null||t===void 0?void 0:t.update().catch((function(){}));this.showing=true;this.hiderEl=document.createElement("div");this.hiderEl.id="verdocs-button-panel-hider";this.hiderEl.style.zIndex="100";this.hiderEl.style.position="absolute";this.hiderEl.style.top="0px";this.hiderEl.style.left="0px";this.hiderEl.style.right="0px";this.hiderEl.style.bottom="0px";this.hiderEl.onclick=function(e){e.stopPropagation();o.toggle()};document.body.appendChild(this.hiderEl);return[2]}))}))};e.prototype.hidePanel=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){Array.from(document.getElementsByClassName("verdocs-button-panel-content")).forEach((function(e){e.removeAttribute("data-show")}));(e=document.getElementById("verdocs-button-panel-hider"))===null||e===void 0?void 0:e.remove();this.showing=false;return[2]}))}))};e.prototype.toggle=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(!this.showing)return[3,2];return[4,this.hidePanel()];case 1:e.sent();return[3,4];case 2:return[4,this.showPanel()];case 3:e.sent();e.label=4;case 4:return[2]}}))}))};e.prototype.render=function(){var e=this;return h(Host,null,h("div",{class:"icon",innerHTML:this.icon,onClick:function(t){t.stopPropagation();return e.toggle()},ref:function(t){return e.iconEl=t}}),h("div",{role:"tooltip",class:"verdocs-button-panel-content","data-popper-placement":"bottom",ref:function(t){return e.panelEl=t}},h("div",{"data-popper-arrow":"true",class:"arrow"}),h("slot",null)))};return e}();VerdocsButtonPanel.style=verdocsButtonPanelCss;var verdocsSelectInputCss='verdocs-select-input{font-family:"Inter", "Barlow", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 0 10px 0;display:block}verdocs-select-input .input-element{-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;border:1px solid #cccccc;border-radius:4px;background:#ffffff;color:#092c4c;width:100%;font-size:16px;height:28px;padding:2px 8px}verdocs-select-input .input-element::-webkit-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-moz-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element:-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0}';var VerdocsSelectInput=function(){function e(e){registerInstance(this,e);this.value="";this.label="";this.options=undefined;this.disabled=false}e.prototype.render=function(){var e=this;return h(Host,{class:"input-field"},h("label",null,this.label?h("div",{class:"input-label"},this.label+":"):h("div",null),h("select",{class:"input-element",disabled:this.disabled},this.options.map((function(t){return h("option",{value:t.value,selected:t.value===e.value},t.label)})))))};return e}();VerdocsSelectInput.style=verdocsSelectInputCss;var rng;var crypto=typeof commonjsGlobal!=="undefined"&&(commonjsGlobal.crypto||commonjsGlobal.msCrypto);if(crypto&&crypto.getRandomValues){var rnds8=new Uint8Array(16);rng=function e(){crypto.getRandomValues(rnds8);return rnds8}}if(!rng){var rnds=new Array(16);rng=function(){for(var e=0,t;e<16;e++){if((e&3)===0)t=Math.random()*4294967296;rnds[e]=t>>>((e&3)<<3)&255}return rnds}}var rngBrowser=rng;var byteToHex=[];for(var i=0;i<256;++i){byteToHex[i]=(i+256).toString(16).substr(1)}function bytesToUuid(e,t){var o=t||0;var i=byteToHex;return i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]}var bytesToUuid_1=bytesToUuid;var _seedBytes=rngBrowser();var _nodeId=[_seedBytes[0]|1,_seedBytes[1],_seedBytes[2],_seedBytes[3],_seedBytes[4],_seedBytes[5]];var _clockseq=(_seedBytes[6]<<8|_seedBytes[7])&16383;var _lastMSecs=0,_lastNSecs=0;function v1(e,t,o){var i=t&&o||0;var n=t||[];e=e||{};var r=e.clockseq!==undefined?e.clockseq:_clockseq;var s=e.msecs!==undefined?e.msecs:(new Date).getTime();var l=e.nsecs!==undefined?e.nsecs:_lastNSecs+1;var a=s-_lastMSecs+(l-_lastNSecs)/1e4;if(a<0&&e.clockseq===undefined){r=r+1&16383}if((a<0||s>_lastMSecs)&&e.nsecs===undefined){l=0}if(l>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}_lastMSecs=s;_lastNSecs=l;_clockseq=r;s+=122192928e5;var d=((s&268435455)*1e4+l)%4294967296;n[i++]=d>>>24&255;n[i++]=d>>>16&255;n[i++]=d>>>8&255;n[i++]=d&255;var p=s/4294967296*1e4&268435455;n[i++]=p>>>8&255;n[i++]=p&255;n[i++]=p>>>24&15|16;n[i++]=p>>>16&255;n[i++]=r>>>8|128;n[i++]=r&255;var c=e.node||_nodeId;for(var u=0;u<6;++u){n[i+u]=c[u]}return t?t:bytesToUuid_1(n)}var v1_1=v1;function v4(e,t,o){var i=t&&o||0;if(typeof e=="string"){t=e=="binary"?new Array(16):null;e=null}e=e||{};var n=e.random||(e.rng||rngBrowser)();n[6]=n[6]&15|64;n[8]=n[8]&63|128;if(t){for(var r=0;r<16;++r){t[i+r]=n[r]}}return t||bytesToUuid_1(n)}var v4_1=v4;var uuid=v4_1;uuid.v1=v1_1;uuid.v4=v4_1;var uuidBrowser=uuid;var verdocsTemplateFieldPropertiesCss='verdocs-template-field-properties{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-field-properties .buttons{display:-ms-flexbox;display:flex;margin-top:30px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-field-properties .buttons verdocs-button{margin-left:16px}verdocs-template-field-properties form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;margin:0 0 10px 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties form .row .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0;-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-field-properties verdocs-select-input{-ms-flex:1;flex:1;margin:0}verdocs-template-field-properties verdocs-text-input{margin:0;-ms-flex:1;flex:1}verdocs-template-field-properties verdocs-text-input label{margin:0;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties verdocs-text-input .input-label{-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-field-properties verdocs-text-input input{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-field-properties .checkbox-wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-field-properties .delete-button{height:34px;display:-ms-flexbox;display:flex;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-field-properties .delete-button:active{background:#f3f3f3}verdocs-template-field-properties .delete-button svg{width:24px;height:24px}verdocs-template-field-properties h6{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:16px;font-weight:bold;margin:0 0 8px 0;-ms-flex-direction:row;flex-direction:row;color:#092c4c}verdocs-template-field-properties h6 .help-icon{opacity:0.5}verdocs-template-field-properties h6 .help-icon:hover{opacity:1;cursor:pointer}verdocs-template-field-properties .row-header{gap:15px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties .row-header h6{margin-bottom:0}verdocs-template-field-properties .row-header verdocs-help-icon{-webkit-transform:scale(0.85);transform:scale(0.85)}verdocs-template-field-properties .row-header verdocs-help-icon svg{margin-bottom:-5px}verdocs-template-field-properties .row-header .add-button{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-field-properties .row-header .add-button:hover{opacity:1}verdocs-template-field-properties .row-header .add-button svg{width:32px;height:32px}verdocs-template-field-properties .option-row{margin:15px 0}verdocs-template-field-properties .option-row .remove-button{height:28px;display:-ms-flexbox;display:flex;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-field-properties .option-row .remove-button:active{background:#f3f3f3}verdocs-template-field-properties .option-row .remove-button:hover svg{stroke:#a50021}verdocs-template-field-properties .option-row .remove-button svg{width:20px;height:20px;stroke:#333333}verdocs-template-field-properties .options{background:#f3f3f3;padding:0 0 10px 0}verdocs-template-field-properties .options .row-header,verdocs-template-field-properties .options .option-row{padding:0 10px}verdocs-template-field-properties .options .add-option-button{border-radius:5px;border:1px solid #cccccc;background:#46497d;color:#ffffff;padding:3px 8px}verdocs-template-field-properties .options .option-row .input-element{font-size:14px}verdocs-template-field-properties .options verdocs-help-icon{opacity:1;-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-field-properties .options verdocs-help-icon svg{fill:#ffffff}';var capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};var TrashIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#a50021"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>';var HelpIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M11.925 18q.55 0 .938-.387.387-.388.387-.938 0-.55-.387-.925-.388-.375-.938-.375-.55 0-.925.375t-.375.925q0 .55.375.938.375.387.925.387Zm-.95-3.85h1.95q0-.8.2-1.287.2-.488 1.025-1.288.65-.625 1.025-1.213.375-.587.375-1.437 0-1.425-1.025-2.175Q13.5 6 12.1 6q-1.425 0-2.35.775t-1.275 1.85l1.775.7q.125-.45.55-.975.425-.525 1.275-.525.725 0 1.1.412.375.413.375.888 0 .475-.287.9-.288.425-.713.775-1.075.95-1.325 1.475-.25.525-.25 1.875ZM12 22.2q-2.125 0-3.988-.8-1.862-.8-3.237-2.175Q3.4 17.85 2.6 15.988 1.8 14.125 1.8 12t.8-3.988q.8-1.862 2.175-3.237Q6.15 3.4 8.012 2.6 9.875 1.8 12 1.8t3.988.8q1.862.8 3.237 2.175Q20.6 6.15 21.4 8.012q.8 1.863.8 3.988t-.8 3.988q-.8 1.862-2.175 3.237Q17.85 20.6 15.988 21.4q-1.863.8-3.988.8Zm0-2.275q3.325 0 5.625-2.3t2.3-5.625q0-3.325-2.3-5.625T12 4.075q-3.325 0-5.625 2.3T4.075 12q0 3.325 2.3 5.625t5.625 2.3ZM12 12Z"/></svg>';var VerdocsTemplateFieldProperties=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.delete=createEvent(this,"delete",7);this.settingsChanged=createEvent(this,"settingsChanged",7);this.sdkError=createEvent(this,"sdkError",7);this.store=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.fieldName="";this.helpText="";this.dirty=false;this.loading=true;this.type="signature";this.setting=null;this.name="";this.roleName="";this.group="";this.fieldType="";this.required=false;this.options=[];this.placeholder="";this.value="";this.leading=0;this.showingHelp=false}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,i,n,r,s,l,a,d,p,c;var u=this;return __generator(this,(function(h){switch(h.label){case 0:h.trys.push([0,2,,3]);this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.fieldName){console.error("[FIELD PROPERTIES] Missing required field name");return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}d=this;return[4,getTemplateStore(this.endpoint,this.templateId,false)];case 1:d.store=h.sent();p=(t=(e=this.store)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.fields.find((function(e){return e.name===u.fieldName}));if(!p){console.log('[FIELD PROPERTIES] Unable to find field "'.concat(this.fieldName,'" in template'))}this.type=p.type;this.name=p.name;this.group=p.name;this.roleName=p.role_name;this.required=p.required;this.fieldType=p.type;this.placeholder=((o=p.setting)===null||o===void 0?void 0:o.placeholder)||"";this.value=((i=p.setting)===null||i===void 0?void 0:i.result)||"";this.leading=((n=p.setting)===null||n===void 0?void 0:n.leading)||0;this.setting=p.setting||{};this.options=((r=p.setting)===null||r===void 0?void 0:r.options)||[];this.dirty=false;this.loading=false;return[3,3];case 2:c=h.sent();console.log("[FIELD PROPERTIES] Error loading template",c);this.loading=false;(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(c.message,(l=c.response)===null||l===void 0?void 0:l.status,(a=c.response)===null||a===void 0?void 0:a.data));return[3,3];case 3:return[2]}}))}))};e.prototype.handleCancel=function(e){var t=this;var o,i,n,r,s,l;e.stopPropagation();var a=(i=(o=this.store)===null||o===void 0?void 0:o.state)===null||i===void 0?void 0:i.fields.find((function(e){return e.name===t.fieldName}));if(a){this.name=a.name;this.roleName=a.role_name;this.required=a.required;this.placeholder=((n=a.setting)===null||n===void 0?void 0:n.placeholder)||"";this.value=((r=a.setting)===null||r===void 0?void 0:r.result)||"";this.leading=((s=a.setting)===null||s===void 0?void 0:s.leading)||0}this.dirty=false;(l=this.close)===null||l===void 0?void 0:l.emit()};e.prototype.handleSave=function(e){var t=this;e.stopPropagation();var o={name:this.name,required:this.required,role_name:this.roleName};if(this.type==="checkbox_group"||this.type==="radio_button_group"){o.setting=this.setting;o.setting.options=this.options}else if(this.type==="textarea"||this.type==="textbox"){o.setting=__assign({},this.setting);o.setting.result=(this.value||"").trim()}else if(this.type==="dropdown"){o.setting={x:this.setting.x,y:this.setting.y,options:this.options}}console.log("will",o);updateField(this.endpoint,this.templateId,this.fieldName,o).then((function(){var e,i;t.dirty=false;t.updateField();(e=t.settingsChanged)===null||e===void 0?void 0:e.emit({fieldName:t.fieldName,settings:o});(i=t.close)===null||i===void 0?void 0:i.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleAddOption=function(e){var t=this;e.stopPropagation();var o={name:this.name,required:this.required,role_name:this.roleName};this.options.push(this.type==="radio_button_group"?{id:uuidBrowser(),value:"Option ".concat(this.options.length+1),selected:false,x:this.options.length>0?this.options[this.options.length-1].x:20,y:this.options.length>0?this.options[this.options.length-1].y-25:20}:{id:uuidBrowser(),value:"Option ".concat(this.options.length+1),checked:false,x:this.options.length>0?this.options[this.options.length-1].x:20,y:this.options.length>0?this.options[this.options.length-1].y-25:20});o.setting=__assign({},this.setting);delete o.setting.result;o.setting.options=__spreadArray([],this.options,true);updateField(this.endpoint,this.templateId,this.fieldName,o).then((function(){var e,i;t.dirty=false;t.updateField();(e=t.settingsChanged)===null||e===void 0?void 0:e.emit({fieldName:t.fieldName,settings:o});(i=t.close)===null||i===void 0?void 0:i.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.updateField=function(){var e=this;var t=__spreadArray([],this.store.state.fields,true);t.forEach((function(t){if(t.name===e.fieldName){t.name=e.name;t.role_name=e.roleName;t.required=e.required;t.label=e.placeholder;if(t.setting.options){t.setting.options=e.options}}}));this.store.state.fields=t};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(o){e.stopPropagation();if(window.confirm("Are you sure you wish to remove this field? This action cannot be undone.")){deleteField(this.endpoint,this.templateId,this.fieldName).then((function(e){var o,i,n,r,s;console.log("Field deleted",e);t.store.state.fields=__spreadArray([],(i=(o=t.store)===null||o===void 0?void 0:o.state)===null||i===void 0?void 0:i.fields.filter((function(e){return e.name!==t.fieldName})),true);(r=(n=t.store)===null||n===void 0?void 0:n.state)===null||r===void 0?void 0:r.roles.forEach((function(e){e.fields=__spreadArray([],e.fields.filter((function(e){return e.name!==t.fieldName})),true)}));(s=t.delete)===null||s===void 0?void 0:s.emit({templateId:t.templateId,roleName:t.roleName})})).catch((function(e){console.log("Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t,o,i,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(!this.endpoint.session||!((o=(t=this.store)===null||t===void 0?void 0:t.state)===null||o===void 0?void 0:o.isLoaded)){return h(Host,{class:"empty"})}if(this.helpText&&this.showingHelp){return h(Host,null,h("h6",null,capitalize(this.fieldType)," Settings ",h("div",{style:{flex:"1"}}),h("div",{class:"help-icon",innerHTML:HelpIcon,onClick:function(){return e.showingHelp=false}})),h("p",{class:"instructions",innerHTML:this.helpText}))}return h(Host,null,h("h6",null,capitalize(this.fieldType.replace(/_/g," "))," Settings ",h("div",{style:{flex:"1"}}),this.helpText&&h("div",{class:"help-icon",innerHTML:HelpIcon,onClick:function(){return e.showingHelp=true}})),h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Field Name",value:this.name,autocomplete:"off",placeholder:"Field Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("div",{class:"input-label"},"Role:"),h("verdocs-select-input",{value:this.roleName,options:(n=(i=this.store)===null||i===void 0?void 0:i.state)===null||n===void 0?void 0:n.roles.map((function(e){return{label:e.name,value:e.name}})),onInput:function(t){e.roleName=t.target.value;e.dirty=true}})),["textbox","textarea"].includes(this.type)&&h("div",{class:"row",style:{marginTop:"10px",marginBottom:"10px"}},h("verdocs-text-input",{id:"verdocs-field-value",label:"Value",value:this.value,autocomplete:"off",placeholder:"Pre-defined value...",onInput:function(t){e.value=t.target.value;e.dirty=true}})),["textbox","textarea"].includes(this.type)&&h("div",{class:"row",style:{marginTop:"10px",marginBottom:"10px"}},h("verdocs-text-input",{id:"verdocs-field-placeholder",label:"Placeholder",value:this.placeholder,autocomplete:"off",placeholder:"Placeholder...",onInput:function(t){e.placeholder=t.target.value;e.dirty=true}})),h("div",{class:"row",style:{marginTop:"15px",marginBottom:"15px"}},h("label",{htmlFor:"verdocs-is-required",class:"input-label"},"Required"),h("verdocs-checkbox",{id:"verdocs-is-required",name:"is-required",checked:this.required,value:"on",onInput:function(t){e.required=t.target.checked;e.dirty=true}})),["checkbox_group","radio_button_group"].includes(this.type)&&h("verdocs-button",{size:"small",onClick:function(t){return e.handleAddOption(t)},label:"Add Option"}),["dropdown"].includes(this.type)&&h("div",{class:"options"},h("div",{class:"row",style:{marginTop:"15px",marginBottom:"15px",textAlign:"center",fontWeight:"700",fontSize:"14px",justifyContent:"center",backgroundColor:"#333333",padding:"5px 8px",color:"#ffffff"}},"Options"),h("div",{class:"row-header"},h("h6",null,"ID"),h("h6",null,"Label"),h("div",{style:{width:"34px"}})),this.options.map((function(t,o){return h("div",{class:"row option-row",key:o},h("verdocs-text-input",{id:"verdocs-option-id-".concat(t.id),value:t.id,placeholder:"Unique ID",onInput:function(t){e.options[o].id=t.target.value;e.dirty=true}}),h("verdocs-text-input",{id:"verdocs-option-value-".concat(t.id),value:t.value,placeholder:"Display value",onInput:function(t){e.options[o].value=t.target.value;e.dirty=true}}),h("button",{innerHTML:TrashIcon,class:"remove-button",onClick:function(){e.options=e.options.filter((function(e){return e.id!==t.id}));e.dirty=true}}))})),h("div",{class:"row-header"},h("button",{class:"add-option-button",onClick:function(){e.options=__spreadArray(__spreadArray([],e.options,true),[{id:"option-".concat(e.options.length+1),value:"Option ".concat(e.options.length+1)}],false);e.dirty=true}},"Add Option"))),h("div",{class:"buttons"},h("button",{class:"delete-button",disabled:this.dirty,onClick:function(t){return e.handleDelete(t)},innerHTML:TrashIcon}),h("div",{style:{flex:"1"}}),h("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:function(t){return e.handleSave(t)}}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateFieldProperties.style=verdocsTemplateFieldPropertiesCss;export{VerdocsButtonPanel as verdocs_button_panel,VerdocsSelectInput as verdocs_select_input,VerdocsTemplateFieldProperties as verdocs_template_field_properties};
|
1
|
+
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++){t=arguments[o];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,o,i){function n(e){return e instanceof o?e:new o((function(t){t(e)}))}return new(o||(o=Promise))((function(o,r){function s(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i["throw"](e))}catch(e){r(e)}}function a(e){e.done?o(e.value):n(e.value).then(s,l)}a((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var o={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(t){return a([e,t])}}function a(s){if(i)throw new TypeError("Generator is already executing.");while(o)try{if(i=1,n&&(r=s[0]&2?n["return"]:s[0]?n["throw"]||((r=n["return"])&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;if(n=0,r)s=[s[0]&2,r.value];switch(s[0]){case 0:case 1:r=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;n=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(r=o.trys,r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(s[0]===6&&o.label<r[1]){o.label=r[1];r=s;break}if(r&&o.label<r[2]){o.label=r[2];o.ops.push(s);break}if(r[2])o.ops.pop();o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e];n=0}finally{i=r=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,o){if(o||arguments.length===2)for(var i=0,n=t.length,r;i<n;i++){if(r||!(i in t)){if(!r)r=Array.prototype.slice.call(t,0,i);r[i]=t[i]}}return e.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,h,H as Host,c as createEvent,a as getElement}from"./index-151c0874.js";import{c as createPopper}from"./popper-bfa25c7f.js";import{a as commonjsGlobal}from"./_commonjsHelpers-5ec8f9b7.js";import"./Types-5f31149e.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-f65843b9.js";import{u as updateField,d as deleteField}from"./Fields-c82e6df3.js";import{g as getTemplateStore}from"./TemplateStore-bc248c04.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./index-38d7bc0b.js";import"./Templates-1893bda7.js";var verdocsButtonPanelCss='verdocs-button-panel{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;display:inline-block}verdocs-button-panel .icon{display:inline-block;cursor:pointer;opacity:0.6}verdocs-button-panel .icon svg{fill:#707ae5}verdocs-button-panel .icon:hover{opacity:1}.verdocs-button-panel-content{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-box-shadow:0 0 10px 1px #999999;box-shadow:0 0 10px 1px #999999;display:none;background:#ffffff;color:#33364b;width:320px;font-weight:bold;padding:15px;font-size:14px;position:relative;border-radius:4px;z-index:10000}.verdocs-button-panel-content .arrow,.verdocs-button-panel-content .arrow::before{position:absolute;width:8px;height:8px;background:inherit}.verdocs-button-panel-content .arrow{visibility:hidden;top:-4px}.verdocs-button-panel-content .arrow::before{visibility:visible;content:"";-webkit-transform:rotate(45deg);transform:rotate(45deg)}.verdocs-button-panel-content[data-show]{display:block}.verdocs-button-panel-content[data-popper-placement^=top]>.arrow{bottom:-4px}.verdocs-button-panel-content[data-popper-placement^=bottom]>.arrow{top:-4px}.verdocs-button-panel-content[data-popper-placement^=left]>.arrow{right:-4px}.verdocs-button-panel-content[data-popper-placement^=right]>.arrow{left:-4px}.verdocs-button-panel-content h6{font-size:16px;font-weight:bold;margin:0 0 16px 0;color:#092c4c;border-bottom:1px solid #cccccc}';var VerdocsButtonPanel=function(){function e(e){registerInstance(this,e);this.showing=false;this.icon=""}e.prototype.componentDidRender=function(){document.body.appendChild(this.panelEl);if(this.popperInstance){this.popperInstance.destroy()}this.popperInstance=createPopper(this.iconEl,this.panelEl,{})};e.prototype.disconnectedCallback=function(){if(this.popperInstance){this.popperInstance.destroy();this.popperInstance=null}if(this.panelEl){this.panelEl.remove()}};e.prototype.showPanel=function(){return __awaiter(this,void 0,void 0,(function(){var e,t;var o=this;return __generator(this,(function(i){(e=this.panelEl)===null||e===void 0?void 0:e.setAttribute("data-show","");(t=this.popperInstance)===null||t===void 0?void 0:t.update().catch((function(){}));this.showing=true;this.hiderEl=document.createElement("div");this.hiderEl.id="verdocs-button-panel-hider";this.hiderEl.style.zIndex="100";this.hiderEl.style.position="absolute";this.hiderEl.style.top="0px";this.hiderEl.style.left="0px";this.hiderEl.style.right="0px";this.hiderEl.style.bottom="0px";this.hiderEl.onclick=function(e){e.stopPropagation();o.toggle()};document.body.appendChild(this.hiderEl);return[2]}))}))};e.prototype.hidePanel=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){Array.from(document.getElementsByClassName("verdocs-button-panel-content")).forEach((function(e){e.removeAttribute("data-show")}));(e=document.getElementById("verdocs-button-panel-hider"))===null||e===void 0?void 0:e.remove();this.showing=false;return[2]}))}))};e.prototype.toggle=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:if(!this.showing)return[3,2];return[4,this.hidePanel()];case 1:e.sent();return[3,4];case 2:return[4,this.showPanel()];case 3:e.sent();e.label=4;case 4:return[2]}}))}))};e.prototype.render=function(){var e=this;return h(Host,null,h("div",{class:"icon",innerHTML:this.icon,onClick:function(t){t.stopPropagation();return e.toggle()},ref:function(t){return e.iconEl=t}}),h("div",{role:"tooltip",class:"verdocs-button-panel-content","data-popper-placement":"bottom",ref:function(t){return e.panelEl=t}},h("div",{"data-popper-arrow":"true",class:"arrow"}),h("slot",null)))};return e}();VerdocsButtonPanel.style=verdocsButtonPanelCss;var verdocsSelectInputCss='verdocs-select-input{font-family:"Inter", "Barlow", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 0 10px 0;display:block}verdocs-select-input .input-element{-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;border:1px solid #cccccc;border-radius:4px;background:#ffffff;color:#092c4c;width:100%;font-size:16px;height:28px;padding:2px 8px}verdocs-select-input .input-element::-webkit-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-moz-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element:-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0}';var VerdocsSelectInput=function(){function e(e){registerInstance(this,e);this.value="";this.label="";this.options=undefined;this.disabled=false}e.prototype.render=function(){var e=this;return h(Host,{class:"input-field"},h("label",null,this.label?h("div",{class:"input-label"},this.label+":"):h("div",null),h("select",{class:"input-element",disabled:this.disabled},this.options.map((function(t){return h("option",{value:t.value,selected:t.value===e.value},t.label)})))))};return e}();VerdocsSelectInput.style=verdocsSelectInputCss;var rng;var crypto=typeof commonjsGlobal!=="undefined"&&(commonjsGlobal.crypto||commonjsGlobal.msCrypto);if(crypto&&crypto.getRandomValues){var rnds8=new Uint8Array(16);rng=function e(){crypto.getRandomValues(rnds8);return rnds8}}if(!rng){var rnds=new Array(16);rng=function(){for(var e=0,t;e<16;e++){if((e&3)===0)t=Math.random()*4294967296;rnds[e]=t>>>((e&3)<<3)&255}return rnds}}var rngBrowser=rng;var byteToHex=[];for(var i=0;i<256;++i){byteToHex[i]=(i+256).toString(16).substr(1)}function bytesToUuid(e,t){var o=t||0;var i=byteToHex;return i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+"-"+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]+i[e[o++]]}var bytesToUuid_1=bytesToUuid;var _seedBytes=rngBrowser();var _nodeId=[_seedBytes[0]|1,_seedBytes[1],_seedBytes[2],_seedBytes[3],_seedBytes[4],_seedBytes[5]];var _clockseq=(_seedBytes[6]<<8|_seedBytes[7])&16383;var _lastMSecs=0,_lastNSecs=0;function v1(e,t,o){var i=t&&o||0;var n=t||[];e=e||{};var r=e.clockseq!==undefined?e.clockseq:_clockseq;var s=e.msecs!==undefined?e.msecs:(new Date).getTime();var l=e.nsecs!==undefined?e.nsecs:_lastNSecs+1;var a=s-_lastMSecs+(l-_lastNSecs)/1e4;if(a<0&&e.clockseq===undefined){r=r+1&16383}if((a<0||s>_lastMSecs)&&e.nsecs===undefined){l=0}if(l>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}_lastMSecs=s;_lastNSecs=l;_clockseq=r;s+=122192928e5;var d=((s&268435455)*1e4+l)%4294967296;n[i++]=d>>>24&255;n[i++]=d>>>16&255;n[i++]=d>>>8&255;n[i++]=d&255;var p=s/4294967296*1e4&268435455;n[i++]=p>>>8&255;n[i++]=p&255;n[i++]=p>>>24&15|16;n[i++]=p>>>16&255;n[i++]=r>>>8|128;n[i++]=r&255;var c=e.node||_nodeId;for(var u=0;u<6;++u){n[i+u]=c[u]}return t?t:bytesToUuid_1(n)}var v1_1=v1;function v4(e,t,o){var i=t&&o||0;if(typeof e=="string"){t=e=="binary"?new Array(16):null;e=null}e=e||{};var n=e.random||(e.rng||rngBrowser)();n[6]=n[6]&15|64;n[8]=n[8]&63|128;if(t){for(var r=0;r<16;++r){t[i+r]=n[r]}}return t||bytesToUuid_1(n)}var v4_1=v4;var uuid=v4_1;uuid.v1=v1_1;uuid.v4=v4_1;var uuidBrowser=uuid;var verdocsTemplateFieldPropertiesCss='verdocs-template-field-properties{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-field-properties .buttons{display:-ms-flexbox;display:flex;margin-top:30px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-field-properties .buttons verdocs-button{margin-left:16px}verdocs-template-field-properties form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;margin:0 0 10px 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties form .row .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0;-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-field-properties verdocs-select-input{-ms-flex:1;flex:1;margin:0}verdocs-template-field-properties verdocs-text-input{margin:0;-ms-flex:1;flex:1}verdocs-template-field-properties verdocs-text-input label{margin:0;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties verdocs-text-input .input-label{-ms-flex:0 0 100px;flex:0 0 100px}verdocs-template-field-properties verdocs-text-input input{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-field-properties .checkbox-wrapper{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex}verdocs-template-field-properties .delete-button{height:34px;display:-ms-flexbox;display:flex;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-field-properties .delete-button:active{background:#f3f3f3}verdocs-template-field-properties .delete-button svg{width:24px;height:24px}verdocs-template-field-properties h6{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:16px;font-weight:bold;margin:0 0 8px 0;-ms-flex-direction:row;flex-direction:row;color:#092c4c}verdocs-template-field-properties h6 .help-icon{opacity:0.5}verdocs-template-field-properties h6 .help-icon:hover{opacity:1;cursor:pointer}verdocs-template-field-properties .row-header{gap:15px;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row}verdocs-template-field-properties .row-header h6{margin-bottom:0}verdocs-template-field-properties .row-header verdocs-help-icon{-webkit-transform:scale(0.85);transform:scale(0.85)}verdocs-template-field-properties .row-header verdocs-help-icon svg{margin-bottom:-5px}verdocs-template-field-properties .row-header .add-button{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-field-properties .row-header .add-button:hover{opacity:1}verdocs-template-field-properties .row-header .add-button svg{width:32px;height:32px}verdocs-template-field-properties .option-row{margin:15px 0}verdocs-template-field-properties .option-row .remove-button{height:28px;display:-ms-flexbox;display:flex;cursor:pointer;background:none;border-radius:4px;-ms-flex-align:center;align-items:center;border:1px solid #999;-ms-flex-pack:center;justify-content:center}verdocs-template-field-properties .option-row .remove-button:active{background:#f3f3f3}verdocs-template-field-properties .option-row .remove-button:hover svg{stroke:#a50021}verdocs-template-field-properties .option-row .remove-button svg{width:20px;height:20px;stroke:#333333}verdocs-template-field-properties .options{background:#f3f3f3;padding:0 0 10px 0}verdocs-template-field-properties .options .row-header,verdocs-template-field-properties .options .option-row{padding:0 10px}verdocs-template-field-properties .options .add-option-button{border-radius:5px;border:1px solid #cccccc;background:#46497d;color:#ffffff;padding:3px 8px}verdocs-template-field-properties .options .option-row .input-element{font-size:14px}verdocs-template-field-properties .options verdocs-help-icon{opacity:1;-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-field-properties .options verdocs-help-icon svg{fill:#ffffff}';var capitalize=function(e){return e.charAt(0).toUpperCase()+e.slice(1)};var TrashIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#a50021"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>';var HelpIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M11.925 18q.55 0 .938-.387.387-.388.387-.938 0-.55-.387-.925-.388-.375-.938-.375-.55 0-.925.375t-.375.925q0 .55.375.938.375.387.925.387Zm-.95-3.85h1.95q0-.8.2-1.287.2-.488 1.025-1.288.65-.625 1.025-1.213.375-.587.375-1.437 0-1.425-1.025-2.175Q13.5 6 12.1 6q-1.425 0-2.35.775t-1.275 1.85l1.775.7q.125-.45.55-.975.425-.525 1.275-.525.725 0 1.1.412.375.413.375.888 0 .475-.287.9-.288.425-.713.775-1.075.95-1.325 1.475-.25.525-.25 1.875ZM12 22.2q-2.125 0-3.988-.8-1.862-.8-3.237-2.175Q3.4 17.85 2.6 15.988 1.8 14.125 1.8 12t.8-3.988q.8-1.862 2.175-3.237Q6.15 3.4 8.012 2.6 9.875 1.8 12 1.8t3.988.8q1.862.8 3.237 2.175Q20.6 6.15 21.4 8.012q.8 1.863.8 3.988t-.8 3.988q-.8 1.862-2.175 3.237Q17.85 20.6 15.988 21.4q-1.863.8-3.988.8Zm0-2.275q3.325 0 5.625-2.3t2.3-5.625q0-3.325-2.3-5.625T12 4.075q-3.325 0-5.625 2.3T4.075 12q0 3.325 2.3 5.625t5.625 2.3ZM12 12Z"/></svg>';var VerdocsTemplateFieldProperties=function(){function e(e){registerInstance(this,e);this.close=createEvent(this,"close",7);this.delete=createEvent(this,"delete",7);this.settingsChanged=createEvent(this,"settingsChanged",7);this.sdkError=createEvent(this,"sdkError",7);this.store=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.fieldName="";this.helpText="";this.dirty=false;this.loading=true;this.type="signature";this.setting=null;this.name="";this.roleName="";this.group="";this.fieldType="";this.required=false;this.options=[];this.placeholder="";this.value="";this.leading=0;this.showingHelp=false}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,o,i,n,r,s,l,a,d,p,c;var u=this;return __generator(this,(function(h){switch(h.label){case 0:h.trys.push([0,2,,3]);this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.fieldName){console.error("[FIELD PROPERTIES] Missing required field name");return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}d=this;return[4,getTemplateStore(this.endpoint,this.templateId,false)];case 1:d.store=h.sent();p=(t=(e=this.store)===null||e===void 0?void 0:e.state)===null||t===void 0?void 0:t.fields.find((function(e){return e.name===u.fieldName}));if(!p){console.log('[FIELD PROPERTIES] Unable to find field "'.concat(this.fieldName,'" in template'))}this.type=p.type;this.name=p.name;this.group=p.name;this.roleName=p.role_name;this.required=p.required;this.fieldType=p.type;this.placeholder=((o=p.setting)===null||o===void 0?void 0:o.placeholder)||"";this.value=((i=p.setting)===null||i===void 0?void 0:i.result)||"";this.leading=((n=p.setting)===null||n===void 0?void 0:n.leading)||0;this.setting=p.setting||{};this.options=((r=p.setting)===null||r===void 0?void 0:r.options)||[];this.dirty=false;this.loading=false;return[3,3];case 2:c=h.sent();console.log("[FIELD PROPERTIES] Error loading template",c);this.loading=false;(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(c.message,(l=c.response)===null||l===void 0?void 0:l.status,(a=c.response)===null||a===void 0?void 0:a.data));return[3,3];case 3:return[2]}}))}))};e.prototype.handleCancel=function(e){var t=this;var o,i,n,r,s,l;e.stopPropagation();var a=(i=(o=this.store)===null||o===void 0?void 0:o.state)===null||i===void 0?void 0:i.fields.find((function(e){return e.name===t.fieldName}));if(a){this.name=a.name;this.roleName=a.role_name;this.required=a.required;this.placeholder=((n=a.setting)===null||n===void 0?void 0:n.placeholder)||"";this.value=((r=a.setting)===null||r===void 0?void 0:r.result)||"";this.leading=((s=a.setting)===null||s===void 0?void 0:s.leading)||0}this.dirty=false;(l=this.close)===null||l===void 0?void 0:l.emit()};e.prototype.handleSave=function(e){var t=this;e.stopPropagation();var o={name:this.name,required:this.required,role_name:this.roleName};if(this.type==="checkbox_group"||this.type==="radio_button_group"){o.setting=this.setting;o.setting.options=this.options}else if(this.type==="textarea"||this.type==="textbox"){o.setting=__assign({},this.setting);o.setting.result=(this.value||"").trim()}else if(this.type==="dropdown"){o.setting={x:this.setting.x,y:this.setting.y,options:this.options}}updateField(this.endpoint,this.templateId,this.fieldName,o).then((function(e){var i,n;t.dirty=false;t.updateField(e);(i=t.settingsChanged)===null||i===void 0?void 0:i.emit({fieldName:t.fieldName,settings:o,field:e});(n=t.close)===null||n===void 0?void 0:n.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleAddOption=function(e){var t=this;e.stopPropagation();var o={name:this.name,required:this.required,role_name:this.roleName};this.options.push(this.type==="radio_button_group"?{id:uuidBrowser(),value:"Option ".concat(this.options.length+1),selected:false,x:this.options.length>0?this.options[this.options.length-1].x:20,y:this.options.length>0?this.options[this.options.length-1].y-25:20}:{id:uuidBrowser(),value:"Option ".concat(this.options.length+1),checked:false,x:this.options.length>0?this.options[this.options.length-1].x:20,y:this.options.length>0?this.options[this.options.length-1].y-25:20});o.setting=__assign({},this.setting);delete o.setting.result;o.setting.options=__spreadArray([],this.options,true);updateField(this.endpoint,this.templateId,this.fieldName,o).then((function(e){var i,n;t.dirty=false;t.updateField(e);(i=t.settingsChanged)===null||i===void 0?void 0:i.emit({fieldName:t.fieldName,settings:o,field:e});(n=t.close)===null||n===void 0?void 0:n.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.updateField=function(e){var t=this;var o=__spreadArray([],this.store.state.fields,true);o.forEach((function(o){if(o.name===t.fieldName){Object.assign(o,e)}}));this.store.state.fields=o};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(o){e.stopPropagation();if(window.confirm("Are you sure you wish to remove this field? This action cannot be undone.")){deleteField(this.endpoint,this.templateId,this.fieldName).then((function(e){var o,i,n,r,s;console.log("Field deleted",e);t.store.state.fields=__spreadArray([],(i=(o=t.store)===null||o===void 0?void 0:o.state)===null||i===void 0?void 0:i.fields.filter((function(e){return e.name!==t.fieldName})),true);(r=(n=t.store)===null||n===void 0?void 0:n.state)===null||r===void 0?void 0:r.roles.forEach((function(e){e.fields=__spreadArray([],e.fields.filter((function(e){return e.name!==t.fieldName})),true)}));(s=t.delete)===null||s===void 0?void 0:s.emit({templateId:t.templateId,roleName:t.roleName})})).catch((function(e){console.log("Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t,o,i,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(!this.endpoint.session||!((o=(t=this.store)===null||t===void 0?void 0:t.state)===null||o===void 0?void 0:o.isLoaded)){return h(Host,{class:"empty"})}if(this.helpText&&this.showingHelp){return h(Host,null,h("h6",null,capitalize(this.fieldType)," Settings ",h("div",{style:{flex:"1"}}),h("div",{class:"help-icon",innerHTML:HelpIcon,onClick:function(){return e.showingHelp=false}})),h("p",{class:"instructions",innerHTML:this.helpText}))}return h(Host,null,h("h6",null,capitalize(this.fieldType.replace(/_/g," "))," Settings ",h("div",{style:{flex:"1"}}),this.helpText&&h("div",{class:"help-icon",innerHTML:HelpIcon,onClick:function(){return e.showingHelp=true}})),h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Field Name",value:this.name,autocomplete:"off",placeholder:"Field Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("div",{class:"input-label"},"Role:"),h("verdocs-select-input",{value:this.roleName,options:(n=(i=this.store)===null||i===void 0?void 0:i.state)===null||n===void 0?void 0:n.roles.map((function(e){return{label:e.name,value:e.name}})),onInput:function(t){e.roleName=t.target.value;e.dirty=true}})),["textbox","textarea"].includes(this.type)&&h("div",{class:"row",style:{marginTop:"10px",marginBottom:"10px"}},h("verdocs-text-input",{id:"verdocs-field-value",label:"Value",value:this.value,autocomplete:"off",placeholder:"Pre-defined value...",onInput:function(t){e.value=t.target.value;e.dirty=true}})),["textbox","textarea"].includes(this.type)&&h("div",{class:"row",style:{marginTop:"10px",marginBottom:"10px"}},h("verdocs-text-input",{id:"verdocs-field-placeholder",label:"Placeholder",value:this.placeholder,autocomplete:"off",placeholder:"Placeholder...",onInput:function(t){e.placeholder=t.target.value;e.dirty=true}})),h("div",{class:"row",style:{marginTop:"15px",marginBottom:"15px"}},h("label",{htmlFor:"verdocs-is-required",class:"input-label"},"Required"),h("verdocs-checkbox",{id:"verdocs-is-required",name:"is-required",checked:this.required,value:"on",onInput:function(t){e.required=t.target.checked;e.dirty=true}})),["checkbox_group","radio_button_group"].includes(this.type)&&h("verdocs-button",{size:"small",onClick:function(t){return e.handleAddOption(t)},label:"Add Option"}),["dropdown"].includes(this.type)&&h("div",{class:"options"},h("div",{class:"row",style:{marginTop:"15px",marginBottom:"15px",textAlign:"center",fontWeight:"700",fontSize:"14px",justifyContent:"center",backgroundColor:"#333333",padding:"5px 8px",color:"#ffffff"}},"Options"),h("div",{class:"row-header"},h("h6",null,"ID"),h("h6",null,"Label"),h("div",{style:{width:"34px"}})),this.options.map((function(t,o){return h("div",{class:"row option-row",key:o},h("verdocs-text-input",{id:"verdocs-option-id-".concat(t.id),value:t.id,placeholder:"Unique ID",onInput:function(t){e.options[o].id=t.target.value;e.dirty=true}}),h("verdocs-text-input",{id:"verdocs-option-value-".concat(t.id),value:t.value,placeholder:"Display value",onInput:function(t){e.options[o].value=t.target.value;e.dirty=true}}),h("button",{innerHTML:TrashIcon,class:"remove-button",onClick:function(){e.options=e.options.filter((function(e){return e.id!==t.id}));e.dirty=true}}))})),h("div",{class:"row-header"},h("button",{class:"add-option-button",onClick:function(){e.options=__spreadArray(__spreadArray([],e.options,true),[{id:"option-".concat(e.options.length+1),value:"Option ".concat(e.options.length+1)}],false);e.dirty=true}},"Add Option"))),h("div",{class:"buttons"},h("button",{class:"delete-button",disabled:this.dirty,onClick:function(t){return e.handleDelete(t)},innerHTML:TrashIcon}),h("div",{style:{flex:"1"}}),h("verdocs-button",{size:"small",variant:"outline",label:"Cancel",disabled:!this.dirty,onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{size:"small",label:"Save",disabled:!this.dirty,onClick:function(t){return e.handleSave(t)}}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateFieldProperties.style=verdocsTemplateFieldPropertiesCss;export{VerdocsButtonPanel as verdocs_button_panel,VerdocsSelectInput as verdocs_select_input,VerdocsTemplateFieldProperties as verdocs_template_field_properties};
|