@verdocs/web-sdk 2.3.4 → 2.3.6

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.
@@ -219,6 +219,13 @@ const VerdocsTemplateFields = class {
219
219
  }
220
220
  async handleMoveEnd(event) {
221
221
  var _a;
222
+ const name = event.target.getAttribute('name');
223
+ const option = +(event.target.getAttribute('option') || '0');
224
+ const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
225
+ if (!field) {
226
+ console.log('[FIELDS] Unable to find field', name);
227
+ return;
228
+ }
222
229
  const pageNumber = event.target.getAttribute('pageNumber');
223
230
  const { naturalWidth = 612, naturalHeight = 792, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
224
231
  const clientRect = event.target.getBoundingClientRect();
@@ -228,43 +235,40 @@ const VerdocsTemplateFields = class {
228
235
  // "up" from the bottom (negative displacement).
229
236
  const newX = Math.max(clientRect.left - parentRect.left, 0);
230
237
  const newY = Math.max(renderedHeight - (parentRect.bottom - clientRect.bottom), 0);
231
- const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - event.rect.width, naturalHeight - event.rect.height);
232
- const name = event.target.getAttribute('name');
233
- const option = +(event.target.getAttribute('option') || '0');
234
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
235
- if (field) {
236
- switch (field.type) {
237
- case 'attachment':
238
- case 'payment':
239
- case 'initial':
240
- case 'signature':
241
- case 'date':
242
- case 'dropdown':
243
- case 'textarea':
244
- case 'textbox':
245
- case 'timestamp':
246
- field.setting.x = x;
247
- field.setting.y = y;
248
- break;
249
- case 'checkbox_group':
250
- case 'radio_button_group':
251
- {
252
- const opt = field.setting.options[option];
253
- if (opt) {
254
- opt.x = x;
255
- opt.y = y;
256
- }
238
+ // console.log('Computing coordinates', {naturalWidth, width: event.rect.width, naturalHeight, height: event.rect.height, newX, newY});
239
+ const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - field.setting.width, naturalHeight - field.setting.height);
240
+ // console.log('Drop End', {x, y, newX, newY});
241
+ switch (field.type) {
242
+ case 'attachment':
243
+ case 'payment':
244
+ case 'initial':
245
+ case 'signature':
246
+ case 'date':
247
+ case 'dropdown':
248
+ case 'textarea':
249
+ case 'textbox':
250
+ case 'timestamp':
251
+ field.setting.x = x;
252
+ field.setting.y = y;
253
+ break;
254
+ case 'checkbox_group':
255
+ case 'radio_button_group':
256
+ {
257
+ const opt = field.setting.options[option];
258
+ if (opt) {
259
+ opt.x = x;
260
+ opt.y = y;
257
261
  }
258
- break;
259
- }
260
- console.log('[FIELDS] Will update', name, option, field);
261
- const newFieldData = await Fields.updateField(this.endpoint, this.templateId, name, field);
262
- const pageInfo = this.cachedPageInfo[pageNumber];
263
- const roleIndex = utils.getRoleIndex(TemplateStore.getRoleNames(this.store), field.role_name);
264
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
265
- event.target.removeAttribute('posX');
266
- event.target.removeAttribute('posY');
262
+ }
263
+ break;
267
264
  }
265
+ console.log('[FIELDS] Will update', name, option, field);
266
+ const newFieldData = await Fields.updateField(this.endpoint, this.templateId, name, field);
267
+ const pageInfo = this.cachedPageInfo[pageNumber];
268
+ const roleIndex = utils.getRoleIndex(TemplateStore.getRoleNames(this.store), field.role_name);
269
+ this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
270
+ event.target.removeAttribute('posX');
271
+ event.target.removeAttribute('posY');
268
272
  }
269
273
  generateFieldName(type, pageNumber) {
270
274
  var _a;
@@ -281,6 +285,7 @@ const VerdocsTemplateFields = class {
281
285
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
282
286
  const x = Math.floor(Math.min(viewX / xScale, xMax));
283
287
  const y = Math.floor(Math.min(Math.max(renderedHeight - viewY, 0) / yScale, yMax));
288
+ console.log('Computed coordinates', { x, y, viewX, viewY, xMax, yMax });
284
289
  return { x, y };
285
290
  }
286
291
  async handleClickPage(e, pageNumber) {
@@ -182,6 +182,13 @@ export class VerdocsTemplateFields {
182
182
  }
183
183
  async handleMoveEnd(event) {
184
184
  var _a;
185
+ const name = event.target.getAttribute('name');
186
+ const option = +(event.target.getAttribute('option') || '0');
187
+ const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
188
+ if (!field) {
189
+ console.log('[FIELDS] Unable to find field', name);
190
+ return;
191
+ }
185
192
  const pageNumber = event.target.getAttribute('pageNumber');
186
193
  const { naturalWidth = 612, naturalHeight = 792, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
187
194
  const clientRect = event.target.getBoundingClientRect();
@@ -191,43 +198,40 @@ export class VerdocsTemplateFields {
191
198
  // "up" from the bottom (negative displacement).
192
199
  const newX = Math.max(clientRect.left - parentRect.left, 0);
193
200
  const newY = Math.max(renderedHeight - (parentRect.bottom - clientRect.bottom), 0);
194
- const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - event.rect.width, naturalHeight - event.rect.height);
195
- const name = event.target.getAttribute('name');
196
- const option = +(event.target.getAttribute('option') || '0');
197
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
198
- if (field) {
199
- switch (field.type) {
200
- case 'attachment':
201
- case 'payment':
202
- case 'initial':
203
- case 'signature':
204
- case 'date':
205
- case 'dropdown':
206
- case 'textarea':
207
- case 'textbox':
208
- case 'timestamp':
209
- field.setting.x = x;
210
- field.setting.y = y;
211
- break;
212
- case 'checkbox_group':
213
- case 'radio_button_group':
214
- {
215
- const opt = field.setting.options[option];
216
- if (opt) {
217
- opt.x = x;
218
- opt.y = y;
219
- }
201
+ // console.log('Computing coordinates', {naturalWidth, width: event.rect.width, naturalHeight, height: event.rect.height, newX, newY});
202
+ const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - field.setting.width, naturalHeight - field.setting.height);
203
+ // console.log('Drop End', {x, y, newX, newY});
204
+ switch (field.type) {
205
+ case 'attachment':
206
+ case 'payment':
207
+ case 'initial':
208
+ case 'signature':
209
+ case 'date':
210
+ case 'dropdown':
211
+ case 'textarea':
212
+ case 'textbox':
213
+ case 'timestamp':
214
+ field.setting.x = x;
215
+ field.setting.y = y;
216
+ break;
217
+ case 'checkbox_group':
218
+ case 'radio_button_group':
219
+ {
220
+ const opt = field.setting.options[option];
221
+ if (opt) {
222
+ opt.x = x;
223
+ opt.y = y;
220
224
  }
221
- break;
222
- }
223
- console.log('[FIELDS] Will update', name, option, field);
224
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
225
- const pageInfo = this.cachedPageInfo[pageNumber];
226
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
227
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
228
- event.target.removeAttribute('posX');
229
- event.target.removeAttribute('posY');
225
+ }
226
+ break;
230
227
  }
228
+ console.log('[FIELDS] Will update', name, option, field);
229
+ const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
230
+ const pageInfo = this.cachedPageInfo[pageNumber];
231
+ const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
232
+ this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
233
+ event.target.removeAttribute('posX');
234
+ event.target.removeAttribute('posY');
231
235
  }
232
236
  generateFieldName(type, pageNumber) {
233
237
  var _a;
@@ -244,6 +248,7 @@ export class VerdocsTemplateFields {
244
248
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
245
249
  const x = Math.floor(Math.min(viewX / xScale, xMax));
246
250
  const y = Math.floor(Math.min(Math.max(renderedHeight - viewY, 0) / yScale, yMax));
251
+ console.log('Computed coordinates', { x, y, viewX, viewY, xMax, yMax });
247
252
  return { x, y };
248
253
  }
249
254
  async handleClickPage(e, pageNumber) {
@@ -193,6 +193,13 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
193
193
  }
194
194
  async handleMoveEnd(event) {
195
195
  var _a;
196
+ const name = event.target.getAttribute('name');
197
+ const option = +(event.target.getAttribute('option') || '0');
198
+ const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
199
+ if (!field) {
200
+ console.log('[FIELDS] Unable to find field', name);
201
+ return;
202
+ }
196
203
  const pageNumber = event.target.getAttribute('pageNumber');
197
204
  const { naturalWidth = 612, naturalHeight = 792, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
198
205
  const clientRect = event.target.getBoundingClientRect();
@@ -202,43 +209,40 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
202
209
  // "up" from the bottom (negative displacement).
203
210
  const newX = Math.max(clientRect.left - parentRect.left, 0);
204
211
  const newY = Math.max(renderedHeight - (parentRect.bottom - clientRect.bottom), 0);
205
- const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - event.rect.width, naturalHeight - event.rect.height);
206
- const name = event.target.getAttribute('name');
207
- const option = +(event.target.getAttribute('option') || '0');
208
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
209
- if (field) {
210
- switch (field.type) {
211
- case 'attachment':
212
- case 'payment':
213
- case 'initial':
214
- case 'signature':
215
- case 'date':
216
- case 'dropdown':
217
- case 'textarea':
218
- case 'textbox':
219
- case 'timestamp':
220
- field.setting.x = x;
221
- field.setting.y = y;
222
- break;
223
- case 'checkbox_group':
224
- case 'radio_button_group':
225
- {
226
- const opt = field.setting.options[option];
227
- if (opt) {
228
- opt.x = x;
229
- opt.y = y;
230
- }
212
+ // console.log('Computing coordinates', {naturalWidth, width: event.rect.width, naturalHeight, height: event.rect.height, newX, newY});
213
+ const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - field.setting.width, naturalHeight - field.setting.height);
214
+ // console.log('Drop End', {x, y, newX, newY});
215
+ switch (field.type) {
216
+ case 'attachment':
217
+ case 'payment':
218
+ case 'initial':
219
+ case 'signature':
220
+ case 'date':
221
+ case 'dropdown':
222
+ case 'textarea':
223
+ case 'textbox':
224
+ case 'timestamp':
225
+ field.setting.x = x;
226
+ field.setting.y = y;
227
+ break;
228
+ case 'checkbox_group':
229
+ case 'radio_button_group':
230
+ {
231
+ const opt = field.setting.options[option];
232
+ if (opt) {
233
+ opt.x = x;
234
+ opt.y = y;
231
235
  }
232
- break;
233
- }
234
- console.log('[FIELDS] Will update', name, option, field);
235
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
236
- const pageInfo = this.cachedPageInfo[pageNumber];
237
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
238
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
239
- event.target.removeAttribute('posX');
240
- event.target.removeAttribute('posY');
236
+ }
237
+ break;
241
238
  }
239
+ console.log('[FIELDS] Will update', name, option, field);
240
+ const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
241
+ const pageInfo = this.cachedPageInfo[pageNumber];
242
+ const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
243
+ this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
244
+ event.target.removeAttribute('posX');
245
+ event.target.removeAttribute('posY');
242
246
  }
243
247
  generateFieldName(type, pageNumber) {
244
248
  var _a;
@@ -255,6 +259,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
255
259
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
256
260
  const x = Math.floor(Math.min(viewX / xScale, xMax));
257
261
  const y = Math.floor(Math.min(Math.max(renderedHeight - viewY, 0) / yScale, yMax));
262
+ console.log('Computed coordinates', { x, y, viewX, viewY, xMax, yMax });
258
263
  return { x, y };
259
264
  }
260
265
  async handleClickPage(e, pageNumber) {
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-12-14T19:18:11",
2
+ "timestamp": "2023-12-17T22:44:32",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "2.20.0",
@@ -215,6 +215,13 @@ const VerdocsTemplateFields = class {
215
215
  }
216
216
  async handleMoveEnd(event) {
217
217
  var _a;
218
+ const name = event.target.getAttribute('name');
219
+ const option = +(event.target.getAttribute('option') || '0');
220
+ const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
221
+ if (!field) {
222
+ console.log('[FIELDS] Unable to find field', name);
223
+ return;
224
+ }
218
225
  const pageNumber = event.target.getAttribute('pageNumber');
219
226
  const { naturalWidth = 612, naturalHeight = 792, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
220
227
  const clientRect = event.target.getBoundingClientRect();
@@ -224,43 +231,40 @@ const VerdocsTemplateFields = class {
224
231
  // "up" from the bottom (negative displacement).
225
232
  const newX = Math.max(clientRect.left - parentRect.left, 0);
226
233
  const newY = Math.max(renderedHeight - (parentRect.bottom - clientRect.bottom), 0);
227
- const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - event.rect.width, naturalHeight - event.rect.height);
228
- const name = event.target.getAttribute('name');
229
- const option = +(event.target.getAttribute('option') || '0');
230
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
231
- if (field) {
232
- switch (field.type) {
233
- case 'attachment':
234
- case 'payment':
235
- case 'initial':
236
- case 'signature':
237
- case 'date':
238
- case 'dropdown':
239
- case 'textarea':
240
- case 'textbox':
241
- case 'timestamp':
242
- field.setting.x = x;
243
- field.setting.y = y;
244
- break;
245
- case 'checkbox_group':
246
- case 'radio_button_group':
247
- {
248
- const opt = field.setting.options[option];
249
- if (opt) {
250
- opt.x = x;
251
- opt.y = y;
252
- }
234
+ // console.log('Computing coordinates', {naturalWidth, width: event.rect.width, naturalHeight, height: event.rect.height, newX, newY});
235
+ const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - field.setting.width, naturalHeight - field.setting.height);
236
+ // console.log('Drop End', {x, y, newX, newY});
237
+ switch (field.type) {
238
+ case 'attachment':
239
+ case 'payment':
240
+ case 'initial':
241
+ case 'signature':
242
+ case 'date':
243
+ case 'dropdown':
244
+ case 'textarea':
245
+ case 'textbox':
246
+ case 'timestamp':
247
+ field.setting.x = x;
248
+ field.setting.y = y;
249
+ break;
250
+ case 'checkbox_group':
251
+ case 'radio_button_group':
252
+ {
253
+ const opt = field.setting.options[option];
254
+ if (opt) {
255
+ opt.x = x;
256
+ opt.y = y;
253
257
  }
254
- break;
255
- }
256
- console.log('[FIELDS] Will update', name, option, field);
257
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
258
- const pageInfo = this.cachedPageInfo[pageNumber];
259
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
260
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
261
- event.target.removeAttribute('posX');
262
- event.target.removeAttribute('posY');
258
+ }
259
+ break;
263
260
  }
261
+ console.log('[FIELDS] Will update', name, option, field);
262
+ const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
263
+ const pageInfo = this.cachedPageInfo[pageNumber];
264
+ const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
265
+ this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
266
+ event.target.removeAttribute('posX');
267
+ event.target.removeAttribute('posY');
264
268
  }
265
269
  generateFieldName(type, pageNumber) {
266
270
  var _a;
@@ -277,6 +281,7 @@ const VerdocsTemplateFields = class {
277
281
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
278
282
  const x = Math.floor(Math.min(viewX / xScale, xMax));
279
283
  const y = Math.floor(Math.min(Math.max(renderedHeight - viewY, 0) / yScale, yMax));
284
+ console.log('Computed coordinates', { x, y, viewX, viewY, xMax, yMax });
280
285
  return { x, y };
281
286
  }
282
287
  async handleClickPage(e, pageNumber) {