@verdocs/web-sdk 2.3.5 → 2.3.7

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