@verdocs/web-sdk 1.12.12 → 1.12.14

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.
Files changed (30) hide show
  1. package/dist/cjs/verdocs-button-panel_3.cjs.entry.js +33 -30
  2. package/dist/cjs/verdocs-field-date.cjs.entry.js +2 -2
  3. package/dist/cjs/verdocs-template-create_2.cjs.entry.js +5 -2
  4. package/dist/collection/components/controls/verdocs-button-panel/verdocs-button-panel.js +22 -26
  5. package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.js +2 -2
  6. package/dist/collection/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.js +11 -4
  7. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +5 -2
  8. package/dist/components/verdocs-button-panel2.js +22 -26
  9. package/dist/components/verdocs-field-date.js +2 -2
  10. package/dist/components/verdocs-template-field-properties2.js +11 -4
  11. package/dist/components/verdocs-template-fields2.js +5 -2
  12. package/dist/docs.json +1 -1
  13. package/dist/esm/verdocs-button-panel_3.entry.js +33 -30
  14. package/dist/esm/verdocs-field-date.entry.js +2 -2
  15. package/dist/esm/verdocs-template-create_2.entry.js +5 -2
  16. package/dist/esm-es5/verdocs-button-panel_3.entry.js +1 -1
  17. package/dist/esm-es5/verdocs-field-date.entry.js +1 -1
  18. package/dist/esm-es5/verdocs-template-create_2.entry.js +1 -1
  19. package/dist/verdocs-web-sdk/{p-2c2de2e7.system.entry.js → p-34242d9b.system.entry.js} +1 -1
  20. package/dist/verdocs-web-sdk/{p-329ba73d.entry.js → p-34900911.entry.js} +1 -1
  21. package/dist/verdocs-web-sdk/{p-ec345452.system.entry.js → p-64b9ae85.system.entry.js} +1 -1
  22. package/dist/verdocs-web-sdk/p-7e6d7c07.system.js +1 -1
  23. package/dist/verdocs-web-sdk/p-ad3dad4b.system.entry.js +1 -0
  24. package/dist/verdocs-web-sdk/p-b0922cdf.entry.js +1 -0
  25. package/dist/verdocs-web-sdk/p-e8c200ad.entry.js +1 -0
  26. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/verdocs-web-sdk/p-8a564dcf.system.entry.js +0 -1
  29. package/dist/verdocs-web-sdk/p-972c85b6.entry.js +0 -1
  30. package/dist/verdocs-web-sdk/p-e76245f0.entry.js +0 -1
@@ -43,39 +43,35 @@ const VerdocsButtonPanel = class {
43
43
  }
44
44
  }
45
45
  async showPanel() {
46
- if (!this.showing) {
47
- await this.toggle();
48
- }
46
+ var _a, _b;
47
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.setAttribute('data-show', '');
48
+ (_b = this.popperInstance) === null || _b === void 0 ? void 0 : _b.update().catch(() => { });
49
+ this.showing = true;
50
+ this.hiderEl = document.createElement('div');
51
+ this.hiderEl.style.zIndex = '100';
52
+ this.hiderEl.style.position = 'absolute';
53
+ this.hiderEl.style.top = '0px';
54
+ this.hiderEl.style.left = '0px';
55
+ this.hiderEl.style.right = '0px';
56
+ this.hiderEl.style.bottom = '0px';
57
+ this.hiderEl.onclick = (e) => {
58
+ e.stopPropagation();
59
+ this.toggle();
60
+ };
61
+ document.body.appendChild(this.hiderEl);
49
62
  }
50
63
  async hidePanel() {
51
- console.log('Hiding panel', this.showing);
52
- if (this.showing) {
53
- await this.toggle();
54
- }
64
+ var _a, _b;
65
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
66
+ (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
67
+ this.showing = false;
55
68
  }
56
69
  async toggle() {
57
- var _a, _b, _c, _d;
58
70
  if (this.showing) {
59
- (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
60
- (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
61
- this.showing = false;
71
+ await this.hidePanel();
62
72
  }
63
73
  else {
64
- (_c = this.panelEl) === null || _c === void 0 ? void 0 : _c.setAttribute('data-show', '');
65
- (_d = this.popperInstance) === null || _d === void 0 ? void 0 : _d.update().catch(() => { });
66
- this.showing = true;
67
- this.hiderEl = document.createElement('div');
68
- this.hiderEl.style.zIndex = '100';
69
- this.hiderEl.style.position = 'absolute';
70
- this.hiderEl.style.top = '0px';
71
- this.hiderEl.style.left = '0px';
72
- this.hiderEl.style.right = '0px';
73
- this.hiderEl.style.bottom = '0px';
74
- this.hiderEl.onclick = (e) => {
75
- e.stopPropagation();
76
- this.toggle();
77
- };
78
- document.body.appendChild(this.hiderEl);
74
+ await this.showPanel();
79
75
  }
80
76
  }
81
77
  render() {
@@ -188,22 +184,29 @@ const VerdocsTemplateFieldProperties = class {
188
184
  role_name: this.roleName,
189
185
  // TODO: Default value in setting?
190
186
  };
191
- console.log('np', this.required, newProperties);
192
- if (this.type === 'dropdown' || this.type === 'checkbox_group' || this.type === 'radio_button_group') {
187
+ if (this.type === 'checkbox_group' || this.type === 'radio_button_group') {
193
188
  newProperties.setting = this.setting;
194
189
  newProperties.setting.options = this.options;
195
190
  }
191
+ else if (this.type === 'dropdown') {
192
+ newProperties.setting = {
193
+ x: this.setting.x,
194
+ y: this.setting.y,
195
+ options: this.options,
196
+ };
197
+ }
196
198
  Fields.updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
197
199
  .then(() => {
198
200
  var _a, _b;
199
201
  this.dirty = false;
200
- templateStore.state.fields.forEach(field => {
202
+ const field = templateStore.state.fields.find(field => field.name === this.fieldName);
203
+ if (field) {
201
204
  field.name = this.name;
202
205
  field.role_name = this.roleName;
203
206
  field.required = this.required;
204
207
  field.label = this.placeholder;
205
208
  field.setting.result = this.defaultValue;
206
- });
209
+ }
207
210
  (_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName });
208
211
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
209
212
  })
@@ -2615,7 +2615,7 @@ const VerdocsFieldDate = class {
2615
2615
  }
2616
2616
  // NOTE: We don't use a "date" field here because browsers vary widely in their formatting of it.
2617
2617
  render() {
2618
- var _a, _b;
2618
+ var _a, _b, _c;
2619
2619
  const settings = utils.getFieldSettings(this.field);
2620
2620
  const disabled = (_b = (_a = this.disabled) !== null && _a !== void 0 ? _a : settings.disabled) !== null && _b !== void 0 ? _b : false;
2621
2621
  const backgroundColor = this.field['rgba'] || Colors.getRGBA(this.roleindex);
@@ -2623,7 +2623,7 @@ const VerdocsFieldDate = class {
2623
2623
  const formatted = (settings === null || settings === void 0 ? void 0 : settings.result) ? index$1.format(new Date(settings === null || settings === void 0 ? void 0 : settings.result), 'PP') : '';
2624
2624
  return index.h(index.Host, { class: { done: this.done } }, formatted);
2625
2625
  }
2626
- return (index.h(index.Host, { class: { required: settings.required, disabled }, style: { backgroundColor } }, index.h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (index.h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, index.h("verdocs-template-field-properties", { templateId: templateStore.state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2626
+ return (index.h(index.Host, { class: { required: (_c = this.field) === null || _c === void 0 ? void 0 : _c.required, disabled }, style: { backgroundColor } }, index.h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (index.h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, index.h("verdocs-template-field-properties", { templateId: templateStore.state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2627
2627
  var _a;
2628
2628
  (_a = this.deleted) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.field.name });
2629
2629
  return this.hideSettingsPanel();
@@ -200,7 +200,9 @@ const VerdocsTemplateFields = class {
200
200
  el.addEventListener('input', e => this.handleFieldChange(field, e));
201
201
  el.addEventListener('settingsChanged', () => {
202
202
  var _a;
203
- console.log('settings changed', this, field);
203
+ console.log('Settings', templateStore.state.fields);
204
+ this.selectedRoleName = field.role_name;
205
+ console.log('settings changed', this.selectedRoleName, field);
204
206
  el.setAttribute('roleindex', utils.getRoleIndex(templateStore.state.roleNames, field.role_name));
205
207
  this.rerender++;
206
208
  el.setAttribute('rerender', this.rerender);
@@ -331,9 +333,10 @@ const VerdocsTemplateFields = class {
331
333
  let fieldName;
332
334
  do {
333
335
  fieldName = `${type}P${pageNumber}-${i}`;
336
+ console.log('testing field', fieldName);
334
337
  i++;
335
338
  } while (templateStore.state.fields.some(field => field.name === fieldName));
336
- console.log('Field name', fieldName);
339
+ console.log('Will use field name', fieldName, templateStore.state.fields);
337
340
  return fieldName;
338
341
  }
339
342
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
@@ -37,39 +37,35 @@ export class VerdocsButtonPanel {
37
37
  }
38
38
  }
39
39
  async showPanel() {
40
- if (!this.showing) {
41
- await this.toggle();
42
- }
40
+ var _a, _b;
41
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.setAttribute('data-show', '');
42
+ (_b = this.popperInstance) === null || _b === void 0 ? void 0 : _b.update().catch(() => { });
43
+ this.showing = true;
44
+ this.hiderEl = document.createElement('div');
45
+ this.hiderEl.style.zIndex = '100';
46
+ this.hiderEl.style.position = 'absolute';
47
+ this.hiderEl.style.top = '0px';
48
+ this.hiderEl.style.left = '0px';
49
+ this.hiderEl.style.right = '0px';
50
+ this.hiderEl.style.bottom = '0px';
51
+ this.hiderEl.onclick = (e) => {
52
+ e.stopPropagation();
53
+ this.toggle();
54
+ };
55
+ document.body.appendChild(this.hiderEl);
43
56
  }
44
57
  async hidePanel() {
45
- console.log('Hiding panel', this.showing);
46
- if (this.showing) {
47
- await this.toggle();
48
- }
58
+ var _a, _b;
59
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
60
+ (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
61
+ this.showing = false;
49
62
  }
50
63
  async toggle() {
51
- var _a, _b, _c, _d;
52
64
  if (this.showing) {
53
- (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
54
- (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
55
- this.showing = false;
65
+ await this.hidePanel();
56
66
  }
57
67
  else {
58
- (_c = this.panelEl) === null || _c === void 0 ? void 0 : _c.setAttribute('data-show', '');
59
- (_d = this.popperInstance) === null || _d === void 0 ? void 0 : _d.update().catch(() => { });
60
- this.showing = true;
61
- this.hiderEl = document.createElement('div');
62
- this.hiderEl.style.zIndex = '100';
63
- this.hiderEl.style.position = 'absolute';
64
- this.hiderEl.style.top = '0px';
65
- this.hiderEl.style.left = '0px';
66
- this.hiderEl.style.right = '0px';
67
- this.hiderEl.style.bottom = '0px';
68
- this.hiderEl.onclick = (e) => {
69
- e.stopPropagation();
70
- this.toggle();
71
- };
72
- document.body.appendChild(this.hiderEl);
68
+ await this.showPanel();
73
69
  }
74
70
  }
75
71
  render() {
@@ -54,7 +54,7 @@ export class VerdocsFieldDate {
54
54
  }
55
55
  // NOTE: We don't use a "date" field here because browsers vary widely in their formatting of it.
56
56
  render() {
57
- var _a, _b;
57
+ var _a, _b, _c;
58
58
  const settings = getFieldSettings(this.field);
59
59
  const disabled = (_b = (_a = this.disabled) !== null && _a !== void 0 ? _a : settings.disabled) !== null && _b !== void 0 ? _b : false;
60
60
  const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
@@ -62,7 +62,7 @@ export class VerdocsFieldDate {
62
62
  const formatted = (settings === null || settings === void 0 ? void 0 : settings.result) ? format(new Date(settings === null || settings === void 0 ? void 0 : settings.result), 'PP') : '';
63
63
  return h(Host, { class: { done: this.done } }, formatted);
64
64
  }
65
- return (h(Host, { class: { required: settings.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: TemplateStore.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
65
+ return (h(Host, { class: { required: (_c = this.field) === null || _c === void 0 ? void 0 : _c.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: TemplateStore.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
66
66
  var _a;
67
67
  (_a = this.deleted) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.field.name });
68
68
  return this.hideSettingsPanel();
@@ -86,22 +86,29 @@ export class VerdocsTemplateFieldProperties {
86
86
  role_name: this.roleName,
87
87
  // TODO: Default value in setting?
88
88
  };
89
- console.log('np', this.required, newProperties);
90
- if (this.type === 'dropdown' || this.type === 'checkbox_group' || this.type === 'radio_button_group') {
89
+ if (this.type === 'checkbox_group' || this.type === 'radio_button_group') {
91
90
  newProperties.setting = this.setting;
92
91
  newProperties.setting.options = this.options;
93
92
  }
93
+ else if (this.type === 'dropdown') {
94
+ newProperties.setting = {
95
+ x: this.setting.x,
96
+ y: this.setting.y,
97
+ options: this.options,
98
+ };
99
+ }
94
100
  updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
95
101
  .then(() => {
96
102
  var _a, _b;
97
103
  this.dirty = false;
98
- TemplateStore.fields.forEach(field => {
104
+ const field = TemplateStore.fields.find(field => field.name === this.fieldName);
105
+ if (field) {
99
106
  field.name = this.name;
100
107
  field.role_name = this.roleName;
101
108
  field.required = this.required;
102
109
  field.label = this.placeholder;
103
110
  field.setting.result = this.defaultValue;
104
- });
111
+ }
105
112
  (_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName });
106
113
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
107
114
  })
@@ -99,7 +99,9 @@ export class VerdocsTemplateFields {
99
99
  el.addEventListener('input', e => this.handleFieldChange(field, e));
100
100
  el.addEventListener('settingsChanged', () => {
101
101
  var _a;
102
- console.log('settings changed', this, field);
102
+ console.log('Settings', TemplateStore.fields);
103
+ this.selectedRoleName = field.role_name;
104
+ console.log('settings changed', this.selectedRoleName, field);
103
105
  el.setAttribute('roleindex', getRoleIndex(TemplateStore.roleNames, field.role_name));
104
106
  this.rerender++;
105
107
  el.setAttribute('rerender', this.rerender);
@@ -230,9 +232,10 @@ export class VerdocsTemplateFields {
230
232
  let fieldName;
231
233
  do {
232
234
  fieldName = `${type}P${pageNumber}-${i}`;
235
+ console.log('testing field', fieldName);
233
236
  i++;
234
237
  } while (TemplateStore.fields.some(field => field.name === fieldName));
235
- console.log('Field name', fieldName);
238
+ console.log('Will use field name', fieldName, TemplateStore.fields);
236
239
  return fieldName;
237
240
  }
238
241
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
@@ -31,39 +31,35 @@ const VerdocsButtonPanel = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
31
31
  }
32
32
  }
33
33
  async showPanel() {
34
- if (!this.showing) {
35
- await this.toggle();
36
- }
34
+ var _a, _b;
35
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.setAttribute('data-show', '');
36
+ (_b = this.popperInstance) === null || _b === void 0 ? void 0 : _b.update().catch(() => { });
37
+ this.showing = true;
38
+ this.hiderEl = document.createElement('div');
39
+ this.hiderEl.style.zIndex = '100';
40
+ this.hiderEl.style.position = 'absolute';
41
+ this.hiderEl.style.top = '0px';
42
+ this.hiderEl.style.left = '0px';
43
+ this.hiderEl.style.right = '0px';
44
+ this.hiderEl.style.bottom = '0px';
45
+ this.hiderEl.onclick = (e) => {
46
+ e.stopPropagation();
47
+ this.toggle();
48
+ };
49
+ document.body.appendChild(this.hiderEl);
37
50
  }
38
51
  async hidePanel() {
39
- console.log('Hiding panel', this.showing);
40
- if (this.showing) {
41
- await this.toggle();
42
- }
52
+ var _a, _b;
53
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
54
+ (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
55
+ this.showing = false;
43
56
  }
44
57
  async toggle() {
45
- var _a, _b, _c, _d;
46
58
  if (this.showing) {
47
- (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
48
- (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
49
- this.showing = false;
59
+ await this.hidePanel();
50
60
  }
51
61
  else {
52
- (_c = this.panelEl) === null || _c === void 0 ? void 0 : _c.setAttribute('data-show', '');
53
- (_d = this.popperInstance) === null || _d === void 0 ? void 0 : _d.update().catch(() => { });
54
- this.showing = true;
55
- this.hiderEl = document.createElement('div');
56
- this.hiderEl.style.zIndex = '100';
57
- this.hiderEl.style.position = 'absolute';
58
- this.hiderEl.style.top = '0px';
59
- this.hiderEl.style.left = '0px';
60
- this.hiderEl.style.right = '0px';
61
- this.hiderEl.style.bottom = '0px';
62
- this.hiderEl.onclick = (e) => {
63
- e.stopPropagation();
64
- this.toggle();
65
- };
66
- document.body.appendChild(this.hiderEl);
62
+ await this.showPanel();
67
63
  }
68
64
  }
69
65
  render() {
@@ -2615,7 +2615,7 @@ const VerdocsFieldDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
2615
2615
  }
2616
2616
  // NOTE: We don't use a "date" field here because browsers vary widely in their formatting of it.
2617
2617
  render() {
2618
- var _a, _b;
2618
+ var _a, _b, _c;
2619
2619
  const settings = getFieldSettings(this.field);
2620
2620
  const disabled = (_b = (_a = this.disabled) !== null && _a !== void 0 ? _a : settings.disabled) !== null && _b !== void 0 ? _b : false;
2621
2621
  const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
@@ -2623,7 +2623,7 @@ const VerdocsFieldDate$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
2623
2623
  const formatted = (settings === null || settings === void 0 ? void 0 : settings.result) ? format(new Date(settings === null || settings === void 0 ? void 0 : settings.result), 'PP') : '';
2624
2624
  return h(Host, { class: { done: this.done } }, formatted);
2625
2625
  }
2626
- return (h(Host, { class: { required: settings.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2626
+ return (h(Host, { class: { required: (_c = this.field) === null || _c === void 0 ? void 0 : _c.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2627
2627
  var _a;
2628
2628
  (_a = this.deleted) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.field.name });
2629
2629
  return this.hideSettingsPanel();
@@ -97,22 +97,29 @@ const VerdocsTemplateFieldProperties = /*@__PURE__*/ proxyCustomElement(class ex
97
97
  role_name: this.roleName,
98
98
  // TODO: Default value in setting?
99
99
  };
100
- console.log('np', this.required, newProperties);
101
- if (this.type === 'dropdown' || this.type === 'checkbox_group' || this.type === 'radio_button_group') {
100
+ if (this.type === 'checkbox_group' || this.type === 'radio_button_group') {
102
101
  newProperties.setting = this.setting;
103
102
  newProperties.setting.options = this.options;
104
103
  }
104
+ else if (this.type === 'dropdown') {
105
+ newProperties.setting = {
106
+ x: this.setting.x,
107
+ y: this.setting.y,
108
+ options: this.options,
109
+ };
110
+ }
105
111
  updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
106
112
  .then(() => {
107
113
  var _a, _b;
108
114
  this.dirty = false;
109
- state.fields.forEach(field => {
115
+ const field = state.fields.find(field => field.name === this.fieldName);
116
+ if (field) {
110
117
  field.name = this.name;
111
118
  field.role_name = this.roleName;
112
119
  field.required = this.required;
113
120
  field.label = this.placeholder;
114
121
  field.setting.result = this.defaultValue;
115
- });
122
+ }
116
123
  (_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName });
117
124
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
118
125
  })
@@ -106,7 +106,9 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
106
106
  el.addEventListener('input', e => this.handleFieldChange(field, e));
107
107
  el.addEventListener('settingsChanged', () => {
108
108
  var _a;
109
- console.log('settings changed', this, field);
109
+ console.log('Settings', state.fields);
110
+ this.selectedRoleName = field.role_name;
111
+ console.log('settings changed', this.selectedRoleName, field);
110
112
  el.setAttribute('roleindex', getRoleIndex(state.roleNames, field.role_name));
111
113
  this.rerender++;
112
114
  el.setAttribute('rerender', this.rerender);
@@ -237,9 +239,10 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
237
239
  let fieldName;
238
240
  do {
239
241
  fieldName = `${type}P${pageNumber}-${i}`;
242
+ console.log('testing field', fieldName);
240
243
  i++;
241
244
  } while (state.fields.some(field => field.name === fieldName));
242
- console.log('Field name', fieldName);
245
+ console.log('Will use field name', fieldName, state.fields);
243
246
  return fieldName;
244
247
  }
245
248
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-03-10T17:35:54",
2
+ "timestamp": "2023-03-13T15:41:37",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "2.20.0",
@@ -39,39 +39,35 @@ const VerdocsButtonPanel = class {
39
39
  }
40
40
  }
41
41
  async showPanel() {
42
- if (!this.showing) {
43
- await this.toggle();
44
- }
42
+ var _a, _b;
43
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.setAttribute('data-show', '');
44
+ (_b = this.popperInstance) === null || _b === void 0 ? void 0 : _b.update().catch(() => { });
45
+ this.showing = true;
46
+ this.hiderEl = document.createElement('div');
47
+ this.hiderEl.style.zIndex = '100';
48
+ this.hiderEl.style.position = 'absolute';
49
+ this.hiderEl.style.top = '0px';
50
+ this.hiderEl.style.left = '0px';
51
+ this.hiderEl.style.right = '0px';
52
+ this.hiderEl.style.bottom = '0px';
53
+ this.hiderEl.onclick = (e) => {
54
+ e.stopPropagation();
55
+ this.toggle();
56
+ };
57
+ document.body.appendChild(this.hiderEl);
45
58
  }
46
59
  async hidePanel() {
47
- console.log('Hiding panel', this.showing);
48
- if (this.showing) {
49
- await this.toggle();
50
- }
60
+ var _a, _b;
61
+ (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
62
+ (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
63
+ this.showing = false;
51
64
  }
52
65
  async toggle() {
53
- var _a, _b, _c, _d;
54
66
  if (this.showing) {
55
- (_a = this.panelEl) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-show');
56
- (_b = this.hiderEl) === null || _b === void 0 ? void 0 : _b.remove();
57
- this.showing = false;
67
+ await this.hidePanel();
58
68
  }
59
69
  else {
60
- (_c = this.panelEl) === null || _c === void 0 ? void 0 : _c.setAttribute('data-show', '');
61
- (_d = this.popperInstance) === null || _d === void 0 ? void 0 : _d.update().catch(() => { });
62
- this.showing = true;
63
- this.hiderEl = document.createElement('div');
64
- this.hiderEl.style.zIndex = '100';
65
- this.hiderEl.style.position = 'absolute';
66
- this.hiderEl.style.top = '0px';
67
- this.hiderEl.style.left = '0px';
68
- this.hiderEl.style.right = '0px';
69
- this.hiderEl.style.bottom = '0px';
70
- this.hiderEl.onclick = (e) => {
71
- e.stopPropagation();
72
- this.toggle();
73
- };
74
- document.body.appendChild(this.hiderEl);
70
+ await this.showPanel();
75
71
  }
76
72
  }
77
73
  render() {
@@ -184,22 +180,29 @@ const VerdocsTemplateFieldProperties = class {
184
180
  role_name: this.roleName,
185
181
  // TODO: Default value in setting?
186
182
  };
187
- console.log('np', this.required, newProperties);
188
- if (this.type === 'dropdown' || this.type === 'checkbox_group' || this.type === 'radio_button_group') {
183
+ if (this.type === 'checkbox_group' || this.type === 'radio_button_group') {
189
184
  newProperties.setting = this.setting;
190
185
  newProperties.setting.options = this.options;
191
186
  }
187
+ else if (this.type === 'dropdown') {
188
+ newProperties.setting = {
189
+ x: this.setting.x,
190
+ y: this.setting.y,
191
+ options: this.options,
192
+ };
193
+ }
192
194
  updateField(this.endpoint, this.templateId, this.fieldName, newProperties)
193
195
  .then(() => {
194
196
  var _a, _b;
195
197
  this.dirty = false;
196
- state.fields.forEach(field => {
198
+ const field = state.fields.find(field => field.name === this.fieldName);
199
+ if (field) {
197
200
  field.name = this.name;
198
201
  field.role_name = this.roleName;
199
202
  field.required = this.required;
200
203
  field.label = this.placeholder;
201
204
  field.setting.result = this.defaultValue;
202
- });
205
+ }
203
206
  (_a = this.settingsChanged) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.fieldName });
204
207
  (_b = this.close) === null || _b === void 0 ? void 0 : _b.emit();
205
208
  })
@@ -2611,7 +2611,7 @@ const VerdocsFieldDate = class {
2611
2611
  }
2612
2612
  // NOTE: We don't use a "date" field here because browsers vary widely in their formatting of it.
2613
2613
  render() {
2614
- var _a, _b;
2614
+ var _a, _b, _c;
2615
2615
  const settings = getFieldSettings(this.field);
2616
2616
  const disabled = (_b = (_a = this.disabled) !== null && _a !== void 0 ? _a : settings.disabled) !== null && _b !== void 0 ? _b : false;
2617
2617
  const backgroundColor = this.field['rgba'] || getRGBA(this.roleindex);
@@ -2619,7 +2619,7 @@ const VerdocsFieldDate = class {
2619
2619
  const formatted = (settings === null || settings === void 0 ? void 0 : settings.result) ? format(new Date(settings === null || settings === void 0 ? void 0 : settings.result), 'PP') : '';
2620
2620
  return h(Host, { class: { done: this.done } }, formatted);
2621
2621
  }
2622
- return (h(Host, { class: { required: settings.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2622
+ return (h(Host, { class: { required: (_c = this.field) === null || _c === void 0 ? void 0 : _c.required, disabled }, style: { backgroundColor } }, h("input", { type: "text", value: "", id: this.containerId, disabled: disabled, placeholder: settings.placeholder, ref: el => (this.el = el) }), this.editable && (h("verdocs-button-panel", { icon: settingsIcon, id: `verdocs-settings-panel-${this.field.name}` }, h("verdocs-template-field-properties", { templateId: state.templateId, fieldName: this.field.name, onClose: () => this.hideSettingsPanel(), onDelete: () => {
2623
2623
  var _a;
2624
2624
  (_a = this.deleted) === null || _a === void 0 ? void 0 : _a.emit({ fieldName: this.field.name });
2625
2625
  return this.hideSettingsPanel();
@@ -196,7 +196,9 @@ const VerdocsTemplateFields = class {
196
196
  el.addEventListener('input', e => this.handleFieldChange(field, e));
197
197
  el.addEventListener('settingsChanged', () => {
198
198
  var _a;
199
- console.log('settings changed', this, field);
199
+ console.log('Settings', state.fields);
200
+ this.selectedRoleName = field.role_name;
201
+ console.log('settings changed', this.selectedRoleName, field);
200
202
  el.setAttribute('roleindex', getRoleIndex(state.roleNames, field.role_name));
201
203
  this.rerender++;
202
204
  el.setAttribute('rerender', this.rerender);
@@ -327,9 +329,10 @@ const VerdocsTemplateFields = class {
327
329
  let fieldName;
328
330
  do {
329
331
  fieldName = `${type}P${pageNumber}-${i}`;
332
+ console.log('testing field', fieldName);
330
333
  i++;
331
334
  } while (state.fields.some(field => field.name === fieldName));
332
- console.log('Field name', fieldName);
335
+ console.log('Will use field name', fieldName, state.fields);
333
336
  return fieldName;
334
337
  }
335
338
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.