@verdocs/web-sdk 2.3.26 → 2.3.28
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-portal_2.cjs.entry.js +4 -3
- package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +1 -3
- package/dist/collection/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.js +6 -4
- package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +1 -3
- package/dist/components/verdocs-template-field-properties2.js +6 -5
- package/dist/components/verdocs-template-fields2.js +1 -3
- package/dist/docs.json +1 -1
- package/dist/esm/verdocs-portal_2.entry.js +6 -5
- package/dist/esm/verdocs-template-fields_4.entry.js +1 -3
- package/dist/esm-es5/verdocs-portal_2.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 +2 -0
- package/dist/verdocs-web-sdk/p-05099eec.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-73a2fc6f.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-961ee618.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-ebc1c670.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-f04bf956.system.js +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +1 -1
- package/dist/custom-elements.json +0 -2175
- package/dist/verdocs-web-sdk/p-3ec512a6.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-73abd3fc.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-79de397b.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-7bdbce2d.system.entry.js +0 -1
@@ -286,6 +286,7 @@ const VerdocsTemplateFieldProperties = class {
|
|
286
286
|
this.sdkError = index.createEvent(this, "sdkError", 7);
|
287
287
|
this.templateStore = null;
|
288
288
|
this.fieldStore = null;
|
289
|
+
this.roleStore = null;
|
289
290
|
this.endpoint = VerdocsEndpoint.VerdocsEndpoint.getDefault();
|
290
291
|
this.templateId = '';
|
291
292
|
this.fieldName = '';
|
@@ -323,8 +324,8 @@ const VerdocsTemplateFieldProperties = class {
|
|
323
324
|
return;
|
324
325
|
}
|
325
326
|
this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId);
|
326
|
-
TemplateFieldStore.
|
327
|
-
this.
|
327
|
+
this.fieldStore = await TemplateFieldStore.getTemplateFieldStore(this.templateId);
|
328
|
+
this.roleStore = await TemplateStore.getTemplateRoleStore(this.templateId);
|
328
329
|
// console.log('tfs', this.fieldStore?.state);
|
329
330
|
const field = this.fieldStore.get('fields').find(field => field.name === this.fieldName);
|
330
331
|
// console.log('gf', field);
|
@@ -496,7 +497,7 @@ const VerdocsTemplateFieldProperties = class {
|
|
496
497
|
placeholder: "Optional Label...", onInput: (e) => {
|
497
498
|
this.label = e.target.value;
|
498
499
|
this.dirty = true;
|
499
|
-
} })), index.h("div", { class: "row" }, index.h("div", { class: "input-label" }, "Role:"), index.h("verdocs-select-input", { value: this.roleName, options: (_a = this.
|
500
|
+
} })), index.h("div", { class: "row" }, index.h("div", { class: "input-label" }, "Role:"), index.h("verdocs-select-input", { value: this.roleName, options: (_a = this.roleStore.state) === null || _a === void 0 ? void 0 : _a.roles.map(role => ({ label: role.name, value: role.name })), onInput: (e) => {
|
500
501
|
this.roleName = e.target.value;
|
501
502
|
this.dirty = true;
|
502
503
|
} })), ['textbox', 'textarea'].includes(this.type) && (index.h("div", { class: "row", style: { marginTop: '10px', marginBottom: '10px' } }, index.h("verdocs-text-input", { id: "verdocs-field-value", label: "Value", value: this.value, autocomplete: "off", placeholder: "Pre-defined value...", onInput: (e) => {
|
@@ -380,9 +380,7 @@ const VerdocsTemplateFields = class {
|
|
380
380
|
if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
|
381
381
|
return (index.h(index.Host, null, index.h("verdocs-loader", null)));
|
382
382
|
}
|
383
|
-
const selectableRoles =
|
384
|
-
.filter(role => role !== undefined)
|
385
|
-
.map(role => ({ value: role.name, label: role.name }));
|
383
|
+
const selectableRoles = this.roleStore.get('roles').map(role => ({ value: role.name, label: role.name }));
|
386
384
|
return (index.h(index.Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, index.h("div", { id: "verdocs-template-fields-toolbar" }, index.h("div", { class: "add-for" }, "Add field:"), index.h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (index.h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
|
387
385
|
// We ignore empty-tooltip entries because they're separators
|
388
386
|
if (option.tooltip) {
|
@@ -2,7 +2,8 @@ import uuidv4 from 'uuid-browser';
|
|
2
2
|
import { VerdocsEndpoint } from '@verdocs/js-sdk';
|
3
3
|
import { deleteField, updateField } from '@verdocs/js-sdk/Templates/Fields';
|
4
4
|
import { h, Host } from '@stencil/core';
|
5
|
-
import {
|
5
|
+
import { getTemplateFieldStore, updateStoreField } from '../../../utils/TemplateFieldStore';
|
6
|
+
import { getTemplateRoleStore } from '../../../utils/TemplateRoleStore';
|
6
7
|
import { getTemplateStore } from '../../../utils/TemplateStore';
|
7
8
|
import { SDKError } from '../../../utils/errors';
|
8
9
|
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
@@ -15,6 +16,7 @@ export class VerdocsTemplateFieldProperties {
|
|
15
16
|
constructor() {
|
16
17
|
this.templateStore = null;
|
17
18
|
this.fieldStore = null;
|
19
|
+
this.roleStore = null;
|
18
20
|
this.endpoint = VerdocsEndpoint.getDefault();
|
19
21
|
this.templateId = '';
|
20
22
|
this.fieldName = '';
|
@@ -52,8 +54,8 @@ export class VerdocsTemplateFieldProperties {
|
|
52
54
|
return;
|
53
55
|
}
|
54
56
|
this.templateStore = await getTemplateStore(this.endpoint, this.templateId);
|
55
|
-
|
56
|
-
this.
|
57
|
+
this.fieldStore = await getTemplateFieldStore(this.templateId);
|
58
|
+
this.roleStore = await getTemplateRoleStore(this.templateId);
|
57
59
|
// console.log('tfs', this.fieldStore?.state);
|
58
60
|
const field = this.fieldStore.get('fields').find(field => field.name === this.fieldName);
|
59
61
|
// console.log('gf', field);
|
@@ -225,7 +227,7 @@ export class VerdocsTemplateFieldProperties {
|
|
225
227
|
placeholder: "Optional Label...", onInput: (e) => {
|
226
228
|
this.label = e.target.value;
|
227
229
|
this.dirty = true;
|
228
|
-
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.
|
230
|
+
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.roleStore.state) === null || _a === void 0 ? void 0 : _a.roles.map(role => ({ label: role.name, value: role.name })), onInput: (e) => {
|
229
231
|
this.roleName = e.target.value;
|
230
232
|
this.dirty = true;
|
231
233
|
} })), ['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: (e) => {
|
package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js
CHANGED
@@ -344,9 +344,7 @@ export class VerdocsTemplateFields {
|
|
344
344
|
if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
|
345
345
|
return (h(Host, null, h("verdocs-loader", null)));
|
346
346
|
}
|
347
|
-
const selectableRoles =
|
348
|
-
.filter(role => role !== undefined)
|
349
|
-
.map(role => ({ value: role.name, label: role.name }));
|
347
|
+
const selectableRoles = this.roleStore.get('roles').map(role => ({ value: role.name, label: role.name }));
|
350
348
|
return (h(Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, h("div", { id: "verdocs-template-fields-toolbar" }, h("div", { class: "add-for" }, "Add field:"), h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
|
351
349
|
// We ignore empty-tooltip entries because they're separators
|
352
350
|
if (option.tooltip) {
|
@@ -3,8 +3,8 @@ import { c as commonjsGlobal } from './_commonjsHelpers.js';
|
|
3
3
|
import './Types.js';
|
4
4
|
import { V as VerdocsEndpoint } from './VerdocsEndpoint.js';
|
5
5
|
import { u as updateField, d as deleteField } from './Fields.js';
|
6
|
-
import {
|
7
|
-
import { g as getTemplateStore } from './TemplateStore.js';
|
6
|
+
import { g as getTemplateFieldStore, u as updateStoreField } from './TemplateFieldStore.js';
|
7
|
+
import { g as getTemplateStore, b as getTemplateRoleStore } from './TemplateStore.js';
|
8
8
|
import { S as SDKError } from './errors.js';
|
9
9
|
import { d as defineCustomElement$6 } from './verdocs-button2.js';
|
10
10
|
import { d as defineCustomElement$5 } from './verdocs-checkbox2.js';
|
@@ -217,6 +217,7 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
|
|
217
217
|
this.sdkError = createEvent(this, "sdkError", 7);
|
218
218
|
this.templateStore = null;
|
219
219
|
this.fieldStore = null;
|
220
|
+
this.roleStore = null;
|
220
221
|
this.endpoint = VerdocsEndpoint.getDefault();
|
221
222
|
this.templateId = '';
|
222
223
|
this.fieldName = '';
|
@@ -254,8 +255,8 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
|
|
254
255
|
return;
|
255
256
|
}
|
256
257
|
this.templateStore = await getTemplateStore(this.endpoint, this.templateId);
|
257
|
-
|
258
|
-
this.
|
258
|
+
this.fieldStore = await getTemplateFieldStore(this.templateId);
|
259
|
+
this.roleStore = await getTemplateRoleStore(this.templateId);
|
259
260
|
// console.log('tfs', this.fieldStore?.state);
|
260
261
|
const field = this.fieldStore.get('fields').find(field => field.name === this.fieldName);
|
261
262
|
// console.log('gf', field);
|
@@ -427,7 +428,7 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
|
|
427
428
|
placeholder: "Optional Label...", onInput: (e) => {
|
428
429
|
this.label = e.target.value;
|
429
430
|
this.dirty = true;
|
430
|
-
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.
|
431
|
+
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.roleStore.state) === null || _a === void 0 ? void 0 : _a.roles.map(role => ({ label: role.name, value: role.name })), onInput: (e) => {
|
431
432
|
this.roleName = e.target.value;
|
432
433
|
this.dirty = true;
|
433
434
|
} })), ['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: (e) => {
|
@@ -354,9 +354,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
354
354
|
if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
|
355
355
|
return (h(Host, null, h("verdocs-loader", null)));
|
356
356
|
}
|
357
|
-
const selectableRoles =
|
358
|
-
.filter(role => role !== undefined)
|
359
|
-
.map(role => ({ value: role.name, label: role.name }));
|
357
|
+
const selectableRoles = this.roleStore.get('roles').map(role => ({ value: role.name, label: role.name }));
|
360
358
|
return (h(Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, h("div", { id: "verdocs-template-fields-toolbar" }, h("div", { class: "add-for" }, "Add field:"), h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
|
361
359
|
// We ignore empty-tooltip entries because they're separators
|
362
360
|
if (option.tooltip) {
|
package/dist/docs.json
CHANGED
@@ -3,8 +3,8 @@ import { a as commonjsGlobal } from './_commonjsHelpers-8a9f3b18.js';
|
|
3
3
|
import './Types-5f31149e.js';
|
4
4
|
import { V as VerdocsEndpoint } from './VerdocsEndpoint-56fa3371.js';
|
5
5
|
import { u as updateField, d as deleteField } from './Fields-c82e6df3.js';
|
6
|
-
import {
|
7
|
-
import { g as getTemplateStore } from './TemplateStore-618fb47f.js';
|
6
|
+
import { g as getTemplateFieldStore, u as updateStoreField } from './TemplateFieldStore-0516a7ec.js';
|
7
|
+
import { g as getTemplateStore, b as getTemplateRoleStore } from './TemplateStore-618fb47f.js';
|
8
8
|
import { S as SDKError } from './errors-9b5498c8.js';
|
9
9
|
import './index-4439b0d1.js';
|
10
10
|
|
@@ -282,6 +282,7 @@ const VerdocsTemplateFieldProperties = class {
|
|
282
282
|
this.sdkError = createEvent(this, "sdkError", 7);
|
283
283
|
this.templateStore = null;
|
284
284
|
this.fieldStore = null;
|
285
|
+
this.roleStore = null;
|
285
286
|
this.endpoint = VerdocsEndpoint.getDefault();
|
286
287
|
this.templateId = '';
|
287
288
|
this.fieldName = '';
|
@@ -319,8 +320,8 @@ const VerdocsTemplateFieldProperties = class {
|
|
319
320
|
return;
|
320
321
|
}
|
321
322
|
this.templateStore = await getTemplateStore(this.endpoint, this.templateId);
|
322
|
-
|
323
|
-
this.
|
323
|
+
this.fieldStore = await getTemplateFieldStore(this.templateId);
|
324
|
+
this.roleStore = await getTemplateRoleStore(this.templateId);
|
324
325
|
// console.log('tfs', this.fieldStore?.state);
|
325
326
|
const field = this.fieldStore.get('fields').find(field => field.name === this.fieldName);
|
326
327
|
// console.log('gf', field);
|
@@ -492,7 +493,7 @@ const VerdocsTemplateFieldProperties = class {
|
|
492
493
|
placeholder: "Optional Label...", onInput: (e) => {
|
493
494
|
this.label = e.target.value;
|
494
495
|
this.dirty = true;
|
495
|
-
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.
|
496
|
+
} })), h("div", { class: "row" }, h("div", { class: "input-label" }, "Role:"), h("verdocs-select-input", { value: this.roleName, options: (_a = this.roleStore.state) === null || _a === void 0 ? void 0 : _a.roles.map(role => ({ label: role.name, value: role.name })), onInput: (e) => {
|
496
497
|
this.roleName = e.target.value;
|
497
498
|
this.dirty = true;
|
498
499
|
} })), ['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: (e) => {
|
@@ -376,9 +376,7 @@ const VerdocsTemplateFields = class {
|
|
376
376
|
if (!((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
|
377
377
|
return (h(Host, null, h("verdocs-loader", null)));
|
378
378
|
}
|
379
|
-
const selectableRoles =
|
380
|
-
.filter(role => role !== undefined)
|
381
|
-
.map(role => ({ value: role.name, label: role.name }));
|
379
|
+
const selectableRoles = this.roleStore.get('roles').map(role => ({ value: role.name, label: role.name }));
|
382
380
|
return (h(Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, h("div", { id: "verdocs-template-fields-toolbar" }, h("div", { class: "add-for" }, "Add field:"), h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, onClick: () => {
|
383
381
|
// We ignore empty-tooltip entries because they're separators
|
384
382
|
if (option.tooltip) {
|
@@ -1 +1 @@
|
|
1
|
-
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++){t=arguments[i];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,n){function s(e){try{a(o.next(e))}catch(e){n(e)}}function l(e){try{a(o["throw"](e))}catch(e){n(e)}}function a(e){e.done?i(e.value):r(e.value).then(s,l)}a((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},o,r,n,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(o)throw new TypeError("Generator is already executing.");while(i)try{if(o=1,r&&(n=s[0]&2?r["return"]:s[0]?r["throw"]||((n=r["return"])&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;if(r=0,n)s=[s[0]&2,n.value];switch(s[0]){case 0:case 1:n=s;break;case 4:i.label++;return{value:s[1],done:false};case 5:i.label++;r=s[1];s=[0];continue;case 7:s=i.ops.pop();i.trys.pop();continue;default:if(!(n=i.trys,n=n.length>0&&n[n.length-1])&&(s[0]===6||s[0]===2)){i=0;continue}if(s[0]===3&&(!n||s[1]>n[0]&&s[1]<n[3])){i.label=s[1];break}if(s[0]===6&&i.label<n[1]){i.label=n[1];n=s;break}if(n&&i.label<n[2]){i.label=n[2];i.ops.push(s);break}if(n[2])i.ops.pop();i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e];r=0}finally{o=n=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,i){if(i||arguments.length===2)for(var o=0,r=t.length,n;o<r;o++){if(n||!(o in t)){if(!n)n=Array.prototype.slice.call(t,0,o);n[o]=t[o]}}return e.concat(n||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,a as getElement}from"./index-172625c5.js";import{a as commonjsGlobal}from"./_commonjsHelpers-8a9f3b18.js";import"./Types-5f31149e.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-56fa3371.js";import{u as updateField,d as deleteField}from"./Fields-c82e6df3.js";import{c as createTemplateFieldStore,u as updateStoreField}from"./TemplateFieldStore-0516a7ec.js";import{g as getTemplateStore}from"./TemplateStore-618fb47f.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./index-4439b0d1.js";var verdocsPortalCss="";var Z_INDEX="10001";var VerdocsPortal=function(){function e(e){registerInstance(this,e);this.clickAway=createEvent(this,"clickAway",7);this.moved=false;this.anchor=undefined;this.voffset=0;this.align="left"}e.prototype.handleScroll=function(){this.calculatePosition()};e.prototype.handleResize=function(){this.calculatePosition()};e.prototype.handleClick=function(e){var t;if(!this.element.contains(e.target)){(t=this.clickAway)===null||t===void 0?void 0:t.emit()}};e.prototype.calculateLeft=function(){var e=document.getElementById(this.anchor);if(!e)return 0;var t=e.getBoundingClientRect();if(this.align==="left"){return Math.max(t.left,0)}if(this.align==="right"){return Math.max(t.left+t.width-this.portal.offsetWidth,0)}return Math.max(t.left-this.portal.offsetWidth/2+t.width/2,0)};e.prototype.calculateTop=function(){var e=document.getElementById(this.anchor);if(!e)return 0;var t=e.getBoundingClientRect();return t.bottom+this.voffset};e.prototype.calculatePosition=function(){this.portal.style.top="".concat(this.calculateTop(),"px");this.portal.style.left="".concat(this.calculateLeft(),"px")};e.prototype.componentWillLoad=function(){var e;var t="".concat(this.anchor,"-portal");(e=document.getElementById(t))===null||e===void 0?void 0:e.remove();this.portal=document.createElement("div");this.portal.setAttribute("id",t);this.portal.style.zIndex=Z_INDEX;this.portal.style.position="absolute";document.body.append(this.portal)};e.prototype.componentDidLoad=function(){this.portal.appendChild(this.element);this.calculatePosition()};e.prototype.disconnectedCallback=function(){this.moved?this.portal.remove():this.moved=true};e.prototype.render=function(){var e=this;return h(Host,{ref:function(t){return e.element=t}},h("slot",null))};return e}();VerdocsPortal.style=verdocsPortalCss;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 i=t||0;var o=byteToHex;return o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]}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,i){var o=t&&i||0;var r=t||[];e=e||{};var n=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){n=n+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=n;s+=122192928e5;var d=((s&268435455)*1e4+l)%4294967296;r[o++]=d>>>24&255;r[o++]=d>>>16&255;r[o++]=d>>>8&255;r[o++]=d&255;var p=s/4294967296*1e4&268435455;r[o++]=p>>>8&255;r[o++]=p&255;r[o++]=p>>>24&15|16;r[o++]=p>>>16&255;r[o++]=n>>>8|128;r[o++]=n&255;var c=e.node||_nodeId;for(var u=0;u<6;++u){r[o+u]=c[u]}return t?t:bytesToUuid_1(r)}var v1_1=v1;function v4(e,t,i){var o=t&&i||0;if(typeof e=="string"){t=e=="binary"?new Array(16):null;e=null}e=e||{};var r=e.random||(e.rng||rngBrowser)();r[6]=r[6]&15|64;r[8]=r[8]&63|128;if(t){for(var n=0;n<16;++n){t[o+n]=r[n]}}return t||bytesToUuid_1(r)}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{padding:20px;display:block;border-radius:4px;background:#ffffff;border:1px solid #ccc;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-box-shadow:2px 2px 10px 0px #0000001f;box-shadow:2px 2px 10px 0px #0000001f}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.templateStore=null;this.fieldStore=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.fieldName="";this.helpText="";this.dirty=false;this.loading=true;this.setting=null;this.label="";this.type="textbox";this.name="";this.required=false;this.roleName="";this.group="";this.fieldType="";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,i,o,r,n,s,l,a,d,p;var c=this;return __generator(this,(function(u){switch(u.label){case 0:u.trys.push([0,3,,4]);this.endpoint.loadSession();if(!this.templateId){console.log("[FIELD PROPERTIES] 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("[FIELD PROPERTIES] Unable to start builder session, must be authenticated");return[2]}l=this;return[4,getTemplateStore(this.endpoint,this.templateId)];case 1:l.templateStore=u.sent();createTemplateFieldStore(this.templateStore.state);a=this;return[4,createTemplateFieldStore(this.templateStore.state)];case 2:a.fieldStore=u.sent();d=this.fieldStore.get("fields").find((function(e){return e.name===c.fieldName}));if(!d){console.log('[FIELD PROPERTIES] Unable to find field "'.concat(this.fieldName,'" in fields'))}else{console.log("props",d)}this.type=d.type;this.name=d.name;this.label=d.label;this.group=d.name;this.roleName=d.role_name;this.required=d.required;this.fieldType=d.type;this.placeholder=((e=d.setting)===null||e===void 0?void 0:e.placeholder)||"";this.value=((t=d.setting)===null||t===void 0?void 0:t.result)||"";this.leading=((i=d.setting)===null||i===void 0?void 0:i.leading)||0;this.setting=d.setting||{};this.options=((o=d.setting)===null||o===void 0?void 0:o.options)||[];this.dirty=false;this.loading=false;console.log("Displaying settings for",this.setting);return[3,4];case 3:p=u.sent();console.log("[FIELD PROPERTIES] Error loading template",p);this.loading=false;(r=this.sdkError)===null||r===void 0?void 0:r.emit(new SDKError(p.message,(n=p.response)===null||n===void 0?void 0:n.status,(s=p.response)===null||s===void 0?void 0:s.data));return[3,4];case 4:return[2]}}))}))};e.prototype.handleCancel=function(e){var t=this;var i,o,r,n;e.stopPropagation();var s=this.fieldStore.get("fields").find((function(e){return e.name===t.fieldName}));if(s){this.name=s.name;this.label=s.label;this.roleName=s.role_name;this.required=s.required;this.placeholder=((i=s.setting)===null||i===void 0?void 0:i.placeholder)||"";this.value=((o=s.setting)===null||o===void 0?void 0:o.result)||"";this.leading=((r=s.setting)===null||r===void 0?void 0:r.leading)||0}this.dirty=false;(n=this.close)===null||n===void 0?void 0:n.emit()};e.prototype.handleSave=function(e){var t=this;e.stopPropagation();var i={name:this.name,label:this.label||null,required:this.required,role_name:this.roleName};if(this.type==="checkbox_group"||this.type==="radio_button_group"){i.setting=this.setting;i.setting.options=this.options}else if(this.type==="textarea"||this.type==="textbox"){i.setting=__assign({},this.setting);i.setting.result=(this.value||"").trim()}else if(this.type==="dropdown"){i.setting={x:this.setting.x,y:this.setting.y,options:this.options}}console.log("FP: Will update",this.fieldName,i);updateField(this.endpoint,this.templateId,this.fieldName,i).then((function(e){var o,r;t.dirty=false;var n=__spreadArray([],t.fieldStore.get("fields").map((function(i){if(i.name!==t.fieldName){return i}return __assign(__assign({},i),e)})),true);t.fieldStore.set("fields",n);(o=t.settingsChanged)===null||o===void 0?void 0:o.emit({fieldName:t.fieldName,settings:i,field:e});(r=t.close)===null||r===void 0?void 0:r.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleAddOption=function(e){var t=this;e.stopPropagation();var i={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});i.setting=__assign({},this.setting);delete i.setting.result;i.setting.options=__spreadArray([],this.options,true);updateField(this.endpoint,this.templateId,this.fieldName,i).then((function(e){var o,r;t.dirty=false;updateStoreField(t.fieldStore,t.fieldName,e);t.fieldName=e.name;(o=t.settingsChanged)===null||o===void 0?void 0:o.emit({fieldName:t.fieldName,settings:i,field:e});(r=t.close)===null||r===void 0?void 0:r.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){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(){var e;t.fieldStore.set("fields",t.fieldStore.get("fields").filter((function(e){return e.name!==t.fieldName})));(e=t.delete)===null||e===void 0?void 0:e.emit({templateId:t.templateId,roleName:t.roleName})})).catch((function(e){console.log("[FIELD PROPERTIES] Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t;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||!this.fieldStore.get("fields").some((function(t){return t.name===e.fieldName}))){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("verdocs-text-input",{id:"verdocs-field-label",label:"Optional Label",value:this.label,autocomplete:"off",placeholder:"Optional Label...",onInput:function(t){e.label=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("div",{class:"input-label"},"Role:"),h("verdocs-select-input",{value:this.roleName,options:(t=this.templateStore.state)===null||t===void 0?void 0:t.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,i){return h("div",{class:"row option-row",key:i},h("verdocs-text-input",{id:"verdocs-option-id-".concat(t.id),value:t.id,placeholder:"Unique ID",onInput:function(t){e.options[i].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[i].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{VerdocsPortal as verdocs_portal,VerdocsTemplateFieldProperties as verdocs_template_field_properties};
|
1
|
+
var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++){t=arguments[i];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,i,o){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,n){function s(e){try{a(o.next(e))}catch(e){n(e)}}function l(e){try{a(o["throw"](e))}catch(e){n(e)}}function a(e){e.done?i(e.value):r(e.value).then(s,l)}a((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},o,r,n,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(o)throw new TypeError("Generator is already executing.");while(i)try{if(o=1,r&&(n=s[0]&2?r["return"]:s[0]?r["throw"]||((n=r["return"])&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;if(r=0,n)s=[s[0]&2,n.value];switch(s[0]){case 0:case 1:n=s;break;case 4:i.label++;return{value:s[1],done:false};case 5:i.label++;r=s[1];s=[0];continue;case 7:s=i.ops.pop();i.trys.pop();continue;default:if(!(n=i.trys,n=n.length>0&&n[n.length-1])&&(s[0]===6||s[0]===2)){i=0;continue}if(s[0]===3&&(!n||s[1]>n[0]&&s[1]<n[3])){i.label=s[1];break}if(s[0]===6&&i.label<n[1]){i.label=n[1];n=s;break}if(n&&i.label<n[2]){i.label=n[2];i.ops.push(s);break}if(n[2])i.ops.pop();i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e];r=0}finally{o=n=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,i){if(i||arguments.length===2)for(var o=0,r=t.length,n;o<r;o++){if(n||!(o in t)){if(!n)n=Array.prototype.slice.call(t,0,o);n[o]=t[o]}}return e.concat(n||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,a as getElement}from"./index-172625c5.js";import{a as commonjsGlobal}from"./_commonjsHelpers-8a9f3b18.js";import"./Types-5f31149e.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-56fa3371.js";import{u as updateField,d as deleteField}from"./Fields-c82e6df3.js";import{g as getTemplateFieldStore,u as updateStoreField}from"./TemplateFieldStore-0516a7ec.js";import{g as getTemplateStore,b as getTemplateRoleStore}from"./TemplateStore-618fb47f.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./index-4439b0d1.js";var verdocsPortalCss="";var Z_INDEX="10001";var VerdocsPortal=function(){function e(e){registerInstance(this,e);this.clickAway=createEvent(this,"clickAway",7);this.moved=false;this.anchor=undefined;this.voffset=0;this.align="left"}e.prototype.handleScroll=function(){this.calculatePosition()};e.prototype.handleResize=function(){this.calculatePosition()};e.prototype.handleClick=function(e){var t;if(!this.element.contains(e.target)){(t=this.clickAway)===null||t===void 0?void 0:t.emit()}};e.prototype.calculateLeft=function(){var e=document.getElementById(this.anchor);if(!e)return 0;var t=e.getBoundingClientRect();if(this.align==="left"){return Math.max(t.left,0)}if(this.align==="right"){return Math.max(t.left+t.width-this.portal.offsetWidth,0)}return Math.max(t.left-this.portal.offsetWidth/2+t.width/2,0)};e.prototype.calculateTop=function(){var e=document.getElementById(this.anchor);if(!e)return 0;var t=e.getBoundingClientRect();return t.bottom+this.voffset};e.prototype.calculatePosition=function(){this.portal.style.top="".concat(this.calculateTop(),"px");this.portal.style.left="".concat(this.calculateLeft(),"px")};e.prototype.componentWillLoad=function(){var e;var t="".concat(this.anchor,"-portal");(e=document.getElementById(t))===null||e===void 0?void 0:e.remove();this.portal=document.createElement("div");this.portal.setAttribute("id",t);this.portal.style.zIndex=Z_INDEX;this.portal.style.position="absolute";document.body.append(this.portal)};e.prototype.componentDidLoad=function(){this.portal.appendChild(this.element);this.calculatePosition()};e.prototype.disconnectedCallback=function(){this.moved?this.portal.remove():this.moved=true};e.prototype.render=function(){var e=this;return h(Host,{ref:function(t){return e.element=t}},h("slot",null))};return e}();VerdocsPortal.style=verdocsPortalCss;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 i=t||0;var o=byteToHex;return o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]}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,i){var o=t&&i||0;var r=t||[];e=e||{};var n=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){n=n+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=n;s+=122192928e5;var d=((s&268435455)*1e4+l)%4294967296;r[o++]=d>>>24&255;r[o++]=d>>>16&255;r[o++]=d>>>8&255;r[o++]=d&255;var p=s/4294967296*1e4&268435455;r[o++]=p>>>8&255;r[o++]=p&255;r[o++]=p>>>24&15|16;r[o++]=p>>>16&255;r[o++]=n>>>8|128;r[o++]=n&255;var c=e.node||_nodeId;for(var u=0;u<6;++u){r[o+u]=c[u]}return t?t:bytesToUuid_1(r)}var v1_1=v1;function v4(e,t,i){var o=t&&i||0;if(typeof e=="string"){t=e=="binary"?new Array(16):null;e=null}e=e||{};var r=e.random||(e.rng||rngBrowser)();r[6]=r[6]&15|64;r[8]=r[8]&63|128;if(t){for(var n=0;n<16;++n){t[o+n]=r[n]}}return t||bytesToUuid_1(r)}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{padding:20px;display:block;border-radius:4px;background:#ffffff;border:1px solid #ccc;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;-webkit-box-shadow:2px 2px 10px 0px #0000001f;box-shadow:2px 2px 10px 0px #0000001f}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.templateStore=null;this.fieldStore=null;this.roleStore=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.fieldName="";this.helpText="";this.dirty=false;this.loading=true;this.setting=null;this.label="";this.type="textbox";this.name="";this.required=false;this.roleName="";this.group="";this.fieldType="";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,i,o,r,n,s,l,a,d,p,c;var u=this;return __generator(this,(function(h){switch(h.label){case 0:h.trys.push([0,4,,5]);this.endpoint.loadSession();if(!this.templateId){console.log("[FIELD PROPERTIES] 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("[FIELD PROPERTIES] Unable to start builder session, must be authenticated");return[2]}l=this;return[4,getTemplateStore(this.endpoint,this.templateId)];case 1:l.templateStore=h.sent();a=this;return[4,getTemplateFieldStore(this.templateId)];case 2:a.fieldStore=h.sent();d=this;return[4,getTemplateRoleStore(this.templateId)];case 3:d.roleStore=h.sent();p=this.fieldStore.get("fields").find((function(e){return e.name===u.fieldName}));if(!p){console.log('[FIELD PROPERTIES] Unable to find field "'.concat(this.fieldName,'" in fields'))}else{console.log("props",p)}this.type=p.type;this.name=p.name;this.label=p.label;this.group=p.name;this.roleName=p.role_name;this.required=p.required;this.fieldType=p.type;this.placeholder=((e=p.setting)===null||e===void 0?void 0:e.placeholder)||"";this.value=((t=p.setting)===null||t===void 0?void 0:t.result)||"";this.leading=((i=p.setting)===null||i===void 0?void 0:i.leading)||0;this.setting=p.setting||{};this.options=((o=p.setting)===null||o===void 0?void 0:o.options)||[];this.dirty=false;this.loading=false;console.log("Displaying settings for",this.setting);return[3,5];case 4:c=h.sent();console.log("[FIELD PROPERTIES] Error loading template",c);this.loading=false;(r=this.sdkError)===null||r===void 0?void 0:r.emit(new SDKError(c.message,(n=c.response)===null||n===void 0?void 0:n.status,(s=c.response)===null||s===void 0?void 0:s.data));return[3,5];case 5:return[2]}}))}))};e.prototype.handleCancel=function(e){var t=this;var i,o,r,n;e.stopPropagation();var s=this.fieldStore.get("fields").find((function(e){return e.name===t.fieldName}));if(s){this.name=s.name;this.label=s.label;this.roleName=s.role_name;this.required=s.required;this.placeholder=((i=s.setting)===null||i===void 0?void 0:i.placeholder)||"";this.value=((o=s.setting)===null||o===void 0?void 0:o.result)||"";this.leading=((r=s.setting)===null||r===void 0?void 0:r.leading)||0}this.dirty=false;(n=this.close)===null||n===void 0?void 0:n.emit()};e.prototype.handleSave=function(e){var t=this;e.stopPropagation();var i={name:this.name,label:this.label||null,required:this.required,role_name:this.roleName};if(this.type==="checkbox_group"||this.type==="radio_button_group"){i.setting=this.setting;i.setting.options=this.options}else if(this.type==="textarea"||this.type==="textbox"){i.setting=__assign({},this.setting);i.setting.result=(this.value||"").trim()}else if(this.type==="dropdown"){i.setting={x:this.setting.x,y:this.setting.y,options:this.options}}console.log("FP: Will update",this.fieldName,i);updateField(this.endpoint,this.templateId,this.fieldName,i).then((function(e){var o,r;t.dirty=false;var n=__spreadArray([],t.fieldStore.get("fields").map((function(i){if(i.name!==t.fieldName){return i}return __assign(__assign({},i),e)})),true);t.fieldStore.set("fields",n);(o=t.settingsChanged)===null||o===void 0?void 0:o.emit({fieldName:t.fieldName,settings:i,field:e});(r=t.close)===null||r===void 0?void 0:r.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleAddOption=function(e){var t=this;e.stopPropagation();var i={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});i.setting=__assign({},this.setting);delete i.setting.result;i.setting.options=__spreadArray([],this.options,true);updateField(this.endpoint,this.templateId,this.fieldName,i).then((function(e){var o,r;t.dirty=false;updateStoreField(t.fieldStore,t.fieldName,e);t.fieldName=e.name;(o=t.settingsChanged)===null||o===void 0?void 0:o.emit({fieldName:t.fieldName,settings:i,field:e});(r=t.close)===null||r===void 0?void 0:r.emit()})).catch((function(){console.log("Field update failed",e)}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){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(){var e;t.fieldStore.set("fields",t.fieldStore.get("fields").filter((function(e){return e.name!==t.fieldName})));(e=t.delete)===null||e===void 0?void 0:e.emit({templateId:t.templateId,roleName:t.roleName})})).catch((function(e){console.log("[FIELD PROPERTIES] Deletion error",e)}))}return[2]}))}))};e.prototype.render=function(){var e=this;var t;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||!this.fieldStore.get("fields").some((function(t){return t.name===e.fieldName}))){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("verdocs-text-input",{id:"verdocs-field-label",label:"Optional Label",value:this.label,autocomplete:"off",placeholder:"Optional Label...",onInput:function(t){e.label=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("div",{class:"input-label"},"Role:"),h("verdocs-select-input",{value:this.roleName,options:(t=this.roleStore.state)===null||t===void 0?void 0:t.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,i){return h("div",{class:"row option-row",key:i},h("verdocs-text-input",{id:"verdocs-option-id-".concat(t.id),value:t.id,placeholder:"Unique ID",onInput:function(t){e.options[i].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[i].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{VerdocsPortal as verdocs_portal,VerdocsTemplateFieldProperties as verdocs_template_field_properties};
|