@verdocs/web-sdk 2.3.5 → 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,44 +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
- console.log('Drop End', { x, y, newX, newY });
233
- const name = event.target.getAttribute('name');
234
- const option = +(event.target.getAttribute('option') || '0');
235
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
236
- if (field) {
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;
257
- }
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;
258
261
  }
259
- break;
260
- }
261
- console.log('[FIELDS] Will update', name, option, field);
262
- const newFieldData = await Fields.updateField(this.endpoint, this.templateId, name, field);
263
- const pageInfo = this.cachedPageInfo[pageNumber];
264
- const roleIndex = utils.getRoleIndex(TemplateStore.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');
262
+ }
263
+ break;
268
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');
269
272
  }
270
273
  generateFieldName(type, pageNumber) {
271
274
  var _a;
@@ -282,6 +285,7 @@ const VerdocsTemplateFields = class {
282
285
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
283
286
  const x = Math.floor(Math.min(viewX / xScale, xMax));
284
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 });
285
289
  return { x, y };
286
290
  }
287
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,44 +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
- console.log('Drop End', { x, y, newX, newY });
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
- switch (field.type) {
201
- case 'attachment':
202
- case 'payment':
203
- case 'initial':
204
- case 'signature':
205
- case 'date':
206
- case 'dropdown':
207
- case 'textarea':
208
- case 'textbox':
209
- case 'timestamp':
210
- field.setting.x = x;
211
- field.setting.y = y;
212
- break;
213
- case 'checkbox_group':
214
- case 'radio_button_group':
215
- {
216
- const opt = field.setting.options[option];
217
- if (opt) {
218
- opt.x = x;
219
- opt.y = y;
220
- }
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;
221
224
  }
222
- break;
223
- }
224
- console.log('[FIELDS] Will update', name, option, field);
225
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
226
- const pageInfo = this.cachedPageInfo[pageNumber];
227
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
228
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
229
- event.target.removeAttribute('posX');
230
- event.target.removeAttribute('posY');
225
+ }
226
+ break;
231
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');
232
235
  }
233
236
  generateFieldName(type, pageNumber) {
234
237
  var _a;
@@ -245,6 +248,7 @@ export class VerdocsTemplateFields {
245
248
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
246
249
  const x = Math.floor(Math.min(viewX / xScale, xMax));
247
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 });
248
252
  return { x, y };
249
253
  }
250
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,44 +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
- console.log('Drop End', { x, y, newX, newY });
207
- const name = event.target.getAttribute('name');
208
- const option = +(event.target.getAttribute('option') || '0');
209
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
210
- if (field) {
211
- switch (field.type) {
212
- case 'attachment':
213
- case 'payment':
214
- case 'initial':
215
- case 'signature':
216
- case 'date':
217
- case 'dropdown':
218
- case 'textarea':
219
- case 'textbox':
220
- case 'timestamp':
221
- field.setting.x = x;
222
- field.setting.y = y;
223
- break;
224
- case 'checkbox_group':
225
- case 'radio_button_group':
226
- {
227
- const opt = field.setting.options[option];
228
- if (opt) {
229
- opt.x = x;
230
- opt.y = y;
231
- }
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;
232
235
  }
233
- break;
234
- }
235
- console.log('[FIELDS] Will update', name, option, field);
236
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
237
- const pageInfo = this.cachedPageInfo[pageNumber];
238
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
239
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
240
- event.target.removeAttribute('posX');
241
- event.target.removeAttribute('posY');
236
+ }
237
+ break;
242
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');
243
246
  }
244
247
  generateFieldName(type, pageNumber) {
245
248
  var _a;
@@ -256,6 +259,7 @@ const VerdocsTemplateFields = /*@__PURE__*/ proxyCustomElement(class extends HTM
256
259
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
257
260
  const x = Math.floor(Math.min(viewX / xScale, xMax));
258
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 });
259
263
  return { x, y };
260
264
  }
261
265
  async handleClickPage(e, pageNumber) {
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-12-16T15:41:25",
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,44 +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
- console.log('Drop End', { x, y, newX, newY });
229
- const name = event.target.getAttribute('name');
230
- const option = +(event.target.getAttribute('option') || '0');
231
- const field = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state.fields.find(field => field.name === name);
232
- if (field) {
233
- switch (field.type) {
234
- case 'attachment':
235
- case 'payment':
236
- case 'initial':
237
- case 'signature':
238
- case 'date':
239
- case 'dropdown':
240
- case 'textarea':
241
- case 'textbox':
242
- case 'timestamp':
243
- field.setting.x = x;
244
- field.setting.y = y;
245
- break;
246
- case 'checkbox_group':
247
- case 'radio_button_group':
248
- {
249
- const opt = field.setting.options[option];
250
- if (opt) {
251
- opt.x = x;
252
- opt.y = y;
253
- }
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;
254
257
  }
255
- break;
256
- }
257
- console.log('[FIELDS] Will update', name, option, field);
258
- const newFieldData = await updateField(this.endpoint, this.templateId, name, field);
259
- const pageInfo = this.cachedPageInfo[pageNumber];
260
- const roleIndex = getRoleIndex(getRoleNames(this.store), field.role_name);
261
- this.handleFieldSettingsChange(pageInfo, field, roleIndex, event.target, newFieldData);
262
- event.target.removeAttribute('posX');
263
- event.target.removeAttribute('posY');
258
+ }
259
+ break;
264
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');
265
268
  }
266
269
  generateFieldName(type, pageNumber) {
267
270
  var _a;
@@ -278,6 +281,7 @@ const VerdocsTemplateFields = class {
278
281
  const { xScale = 1, yScale = 1, renderedHeight = 792 } = this.cachedPageInfo[pageNumber];
279
282
  const x = Math.floor(Math.min(viewX / xScale, xMax));
280
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 });
281
285
  return { x, y };
282
286
  }
283
287
  async handleClickPage(e, pageNumber) {