add-to-calendar-button 2.2.1 → 2.2.2

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.
@@ -7,15 +7,15 @@ const tzlibActions = require('timezones-ical-library');
7
7
  * Add to Calendar Button
8
8
  * ++++++++++++++++++++++
9
9
  *
10
- * Version: 2.2.1
10
+ * Version: 2.2.2
11
11
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
12
12
  * Project: https://github.com/add2cal/add-to-calendar-button
13
13
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
14
14
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
15
15
  *
16
16
  */
17
- const atcbVersion = '2.2.1';
18
- const atcbCssTemplate = {
17
+ const atcbVersion = '2.2.2';
18
+ const atcbCssTemplate = {
19
19
  if (typeof window === 'undefined') {
20
20
  return false;
21
21
  } else {
@@ -173,7 +173,8 @@ const atcbWcBooleanParams = [
173
173
  'disabled',
174
174
  'hidden',
175
175
  ];
176
- const atcbWcObjectParams = ['dates', 'customLabels', 'ty', 'rsvp'];
176
+ const atcbWcObjectParams = ['customLabels', 'ty', 'rsvp'];
177
+ const atcbWcObjectArrayParams = ['dates'];
177
178
  const atcbWcArrayParams = ['images', 'options'];
178
179
  const atcbIcon = {
179
180
  trigger:
@@ -590,17 +591,16 @@ function atcb_decorate_data_button_status_handling(data) {
590
591
  }
591
592
 
592
593
 
593
- function atcb_check_required(data, throwError = true) {
594
+ function atcb_check_required(data) {
595
+ if (data.validationError) {
596
+ data.validationError = null;
597
+ }
594
598
  if (data.options == null || data.options.length < 1) {
595
- if (throwError) {
596
- throw new Error('Add to Calendar Button generation failed: no valid options set');
597
- }
599
+ data.validationError = 'Add to Calendar Button generation failed: no valid options set';
598
600
  return false;
599
601
  }
600
602
  if (data.name == null || data.name == '') {
601
- if (throwError) {
602
- throw new Error('Add to Calendar Button generation failed: required name information missing');
603
- }
603
+ data.validationError = 'Add to Calendar Button generation failed: required name information missing';
604
604
  return false;
605
605
  }
606
606
  if (data.dates != null && data.dates.length > 0) {
@@ -612,9 +612,7 @@ function atcb_check_required(data, throwError = true) {
612
612
  (!requiredMultiFieldFlex.includes(`${field}`) && (data.dates[`${i}`][`${field}`] == null || data.dates[`${i}`][`${field}`] == '')) ||
613
613
  (requiredMultiFieldFlex.includes(`${field}`) && (data.dates[`${i}`][`${field}`] == null || data.dates[`${i}`][`${field}`] == '') && (data[`${field}`] == null || data[`${field}`] == ''))
614
614
  ) {
615
- if (throwError) {
616
- throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
617
- }
615
+ data.validationError = 'Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']';
618
616
  return false;
619
617
  }
620
618
  }
@@ -624,9 +622,7 @@ function atcb_check_required(data, throwError = true) {
624
622
  const requiredSingleField = ['startDate'];
625
623
  return requiredSingleField.every(function (field) {
626
624
  if (data[`${field}`] == null || data[`${field}`] == '') {
627
- if (throwError) {
628
- throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
629
- }
625
+ data.validationError = 'Add to Calendar Button generation failed: required setting missing [' + field + ']';
630
626
  return false;
631
627
  }
632
628
  return true;
@@ -2468,8 +2464,12 @@ function atcb_rewrite_html_elements(content, clear = false) {
2468
2464
  } else {
2469
2465
  content = content.replace(/\[(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)\]/gi, '<$1$2>');
2470
2466
  content = content.replace(/\{(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)\}/gi, '<$1$2>');
2471
- content = content.replace(/\[url\]([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\[\/url\]/gi, function (match, p1) { return atcb_parse_url_code(p1); });
2472
- content = content.replace(/\{url\}([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\{\/url\}/gi, function (match, p1) { return atcb_parse_url_code(p1); });
2467
+ content = content.replace(/\[url\]([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\[\/url\]/gi, function (match, p1) {
2468
+ return atcb_parse_url_code(p1);
2469
+ });
2470
+ content = content.replace(/\{url\}([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\{\/url\}/gi, function (match, p1) {
2471
+ return atcb_parse_url_code(p1);
2472
+ });
2473
2473
  }
2474
2474
  return content;
2475
2475
  }
@@ -3102,9 +3102,8 @@ const i18nStrings = {
3102
3102
  };
3103
3103
  const availableLanguages = Object.keys(i18nStrings);
3104
3104
  function atcb_translate_hook(identifier, data) {
3105
- const searchKey = identifier.replace(/\s+/g, '').toLowerCase();
3106
- if (data.customLabels != null && data.customLabels[`${searchKey}`] != null && data.customLabels[`${searchKey}`] != '') {
3107
- return atcb_rewrite_html_elements(data.customLabels[`${searchKey}`]);
3105
+ if (data.customLabels != null && data.customLabels[`${identifier}`] != null && data.customLabels[`${identifier}`] != '') {
3106
+ return atcb_rewrite_html_elements(data.customLabels[`${identifier}`]);
3108
3107
  } else {
3109
3108
  return atcb_translate(identifier, data.language);
3110
3109
  }
@@ -3147,9 +3146,8 @@ if (isBrowser()) {
3147
3146
  } catch (e) {
3148
3147
  if (this.debug) {
3149
3148
  atcb_render_debug_msg(this.shadowRoot, e);
3150
- console.error(e);
3151
- return;
3152
3149
  }
3150
+ return;
3153
3151
  }
3154
3152
  this.data.proKey = '';
3155
3153
  }
@@ -3179,9 +3177,8 @@ if (isBrowser()) {
3179
3177
  } catch (e) {
3180
3178
  if (this.debug) {
3181
3179
  atcb_render_debug_msg(this.shadowRoot, e);
3182
- console.error(e);
3183
- return;
3184
3180
  }
3181
+ return;
3185
3182
  }
3186
3183
  }
3187
3184
  disconnectedCallback() {
@@ -3222,9 +3219,8 @@ if (isBrowser()) {
3222
3219
  } catch (e) {
3223
3220
  if (this.debug) {
3224
3221
  atcb_render_debug_msg(this.shadowRoot, e);
3225
- console.error(e);
3226
- return;
3227
3222
  }
3223
+ return;
3228
3224
  }
3229
3225
  this.data.identifier = this.identifier;
3230
3226
  try {
@@ -3232,9 +3228,8 @@ if (isBrowser()) {
3232
3228
  } catch (e) {
3233
3229
  if (this.debug) {
3234
3230
  atcb_render_debug_msg(this.shadowRoot, e);
3235
- console.error(e);
3236
- return;
3237
3231
  }
3232
+ return;
3238
3233
  }
3239
3234
  }
3240
3235
  }
@@ -3258,6 +3253,14 @@ function atcb_read_attributes(el) {
3258
3253
  }
3259
3254
  } else if (atcbWcObjectParams.includes(attr)) {
3260
3255
  val = JSON.parse(inputVal);
3256
+ } else if (atcbWcObjectArrayParams.includes(attr)) {
3257
+ const cleanedInput = (function () {
3258
+ if (inputVal.substring(0, 1) != '[') {
3259
+ return '[' + inputVal + ']';
3260
+ }
3261
+ return inputVal;
3262
+ })();
3263
+ val = JSON.parse(cleanedInput);
3261
3264
  } else if (atcbWcArrayParams.includes(attr)) {
3262
3265
  const cleanedInput = (function () {
3263
3266
  let newVal = inputVal;
@@ -3288,7 +3291,7 @@ function atcb_read_attributes(el) {
3288
3291
  data['identifier'] = atcb_secure_content(identifierAttr.replace(/(\r\n|\n|\r)/g, ''), false);
3289
3292
  }
3290
3293
  }
3291
- if (!atcb_check_required(data, false)) {
3294
+ if (!atcb_check_required(data)) {
3292
3295
  const slotInput = el.innerHTML;
3293
3296
  const atcbJsonInput = (function () {
3294
3297
  if (slotInput != '') {
@@ -3301,6 +3304,7 @@ function atcb_read_attributes(el) {
3301
3304
  return '';
3302
3305
  })();
3303
3306
  if (atcbJsonInput.length == 0) {
3307
+ console.error(data.validationError);
3304
3308
  throw new Error('Add to Calendar Button generation failed: no data provided or missing required fields - see console logs for details');
3305
3309
  }
3306
3310
  data = atcbJsonInput;
@@ -3308,26 +3312,24 @@ function atcb_read_attributes(el) {
3308
3312
  return data;
3309
3313
  }
3310
3314
  function atcb_build_button(host, data, debug = false) {
3311
- if (atcb_check_required(data)) {
3312
- data = atcb_decorate_data(data);
3313
- if (atcb_validate(data)) {
3314
- const rootObj = host.querySelector('.atcb-initialized');
3315
- atcb_set_light_mode(host, data);
3316
- rootObj.setAttribute('lang', data.language);
3317
- atcb_load_css(host, rootObj, data.buttonStyle, data.inline, data.buttonsList, data.customCss);
3318
- atcb_setup_state_management(data);
3319
- atcb_set_global_event_listener(host, data);
3320
- atcb_init_log(data.proKey, debug);
3321
- atcb_generate_button(host, rootObj, data, debug);
3322
- if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
3323
- atcb_generate_rich_data(data, host.host);
3324
- data.schemaEl = host.host.previousSibling;
3325
- }
3326
- atcb_log_event('initialization', data.identifier, data.identifier);
3327
- } else if (debug) {
3328
- console.error(data.validationError);
3329
- atcb_render_debug_msg(host, data.validationError);
3330
- }
3315
+ data = atcb_decorate_data(data);
3316
+ if (atcb_validate(data)) {
3317
+ const rootObj = host.querySelector('.atcb-initialized');
3318
+ atcb_set_light_mode(host, data);
3319
+ rootObj.setAttribute('lang', data.language);
3320
+ atcb_load_css(host, rootObj, data.buttonStyle, data.inline, data.buttonsList, data.customCss);
3321
+ atcb_setup_state_management(data);
3322
+ atcb_set_global_event_listener(host, data);
3323
+ atcb_init_log(data.proKey, debug);
3324
+ atcb_generate_button(host, rootObj, data, debug);
3325
+ if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
3326
+ atcb_generate_rich_data(data, host.host);
3327
+ data.schemaEl = host.host.previousSibling;
3328
+ }
3329
+ atcb_log_event('initialization', data.identifier, data.identifier);
3330
+ } else if (debug) {
3331
+ console.error(data.validationError);
3332
+ throw new Error(data.validationError);
3331
3333
  }
3332
3334
  }
3333
3335
  function atcb_cleanup(host, data) {
@@ -3453,7 +3455,8 @@ function atcb_action(data, triggerElement, keyboardTrigger = false) {
3453
3455
  }
3454
3456
  data.debug = data.debug === 'true';
3455
3457
  if (!atcb_check_required(data)) {
3456
- throw new Error('Add to Calendar Button generation failed: required data missing; see console logs');
3458
+ console.error(data.validationError);
3459
+ return;
3457
3460
  }
3458
3461
  data = atcb_decorate_data(data);
3459
3462
  let root = document.body;
@@ -3478,7 +3481,8 @@ function atcb_action(data, triggerElement, keyboardTrigger = false) {
3478
3481
  data.listStyle = 'modal';
3479
3482
  }
3480
3483
  if (!atcb_validate(data)) {
3481
- throw new Error('Add to Calendar Button generation (' + data.identifier + ') failed: invalid data; see console logs');
3484
+ console.error(data.validationError);
3485
+ return;
3482
3486
  }
3483
3487
  const oneOption = (function () {
3484
3488
  if (data.options.length === 1) {
@@ -6,15 +6,15 @@ import { tzlib_get_ical_block, tzlib_get_offset, tzlib_get_timezones } from 'tim
6
6
  * Add to Calendar Button
7
7
  * ++++++++++++++++++++++
8
8
  *
9
- * Version: 2.2.1
9
+ * Version: 2.2.2
10
10
  * Creator: Jens Kuerschner (https://jenskuerschner.de)
11
11
  * Project: https://github.com/add2cal/add-to-calendar-button
12
12
  * License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
13
13
  * Note: DO NOT REMOVE THE COPYRIGHT NOTICE ABOVE!
14
14
  *
15
15
  */
16
- const atcbVersion = '2.2.1';
17
- const atcbCssTemplate = {
16
+ const atcbVersion = '2.2.2';
17
+ const atcbCssTemplate = {
18
18
  if (typeof window === 'undefined') {
19
19
  return false;
20
20
  } else {
@@ -172,7 +172,8 @@ const atcbWcBooleanParams = [
172
172
  'disabled',
173
173
  'hidden',
174
174
  ];
175
- const atcbWcObjectParams = ['dates', 'customLabels', 'ty', 'rsvp'];
175
+ const atcbWcObjectParams = ['customLabels', 'ty', 'rsvp'];
176
+ const atcbWcObjectArrayParams = ['dates'];
176
177
  const atcbWcArrayParams = ['images', 'options'];
177
178
  const atcbIcon = {
178
179
  trigger:
@@ -589,17 +590,16 @@ function atcb_decorate_data_button_status_handling(data) {
589
590
  }
590
591
 
591
592
 
592
- function atcb_check_required(data, throwError = true) {
593
+ function atcb_check_required(data) {
594
+ if (data.validationError) {
595
+ data.validationError = null;
596
+ }
593
597
  if (data.options == null || data.options.length < 1) {
594
- if (throwError) {
595
- throw new Error('Add to Calendar Button generation failed: no valid options set');
596
- }
598
+ data.validationError = 'Add to Calendar Button generation failed: no valid options set';
597
599
  return false;
598
600
  }
599
601
  if (data.name == null || data.name == '') {
600
- if (throwError) {
601
- throw new Error('Add to Calendar Button generation failed: required name information missing');
602
- }
602
+ data.validationError = 'Add to Calendar Button generation failed: required name information missing';
603
603
  return false;
604
604
  }
605
605
  if (data.dates != null && data.dates.length > 0) {
@@ -611,9 +611,7 @@ function atcb_check_required(data, throwError = true) {
611
611
  (!requiredMultiFieldFlex.includes(`${field}`) && (data.dates[`${i}`][`${field}`] == null || data.dates[`${i}`][`${field}`] == '')) ||
612
612
  (requiredMultiFieldFlex.includes(`${field}`) && (data.dates[`${i}`][`${field}`] == null || data.dates[`${i}`][`${field}`] == '') && (data[`${field}`] == null || data[`${field}`] == ''))
613
613
  ) {
614
- if (throwError) {
615
- throw new Error('Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']');
616
- }
614
+ data.validationError = 'Add to Calendar Button generation failed: required setting missing [dates array object #' + (i + 1) + '/' + data.dates.length + '] => [' + field + ']';
617
615
  return false;
618
616
  }
619
617
  }
@@ -623,9 +621,7 @@ function atcb_check_required(data, throwError = true) {
623
621
  const requiredSingleField = ['startDate'];
624
622
  return requiredSingleField.every(function (field) {
625
623
  if (data[`${field}`] == null || data[`${field}`] == '') {
626
- if (throwError) {
627
- throw new Error('Add to Calendar Button generation failed: required setting missing [' + field + ']');
628
- }
624
+ data.validationError = 'Add to Calendar Button generation failed: required setting missing [' + field + ']';
629
625
  return false;
630
626
  }
631
627
  return true;
@@ -2467,8 +2463,12 @@ function atcb_rewrite_html_elements(content, clear = false) {
2467
2463
  } else {
2468
2464
  content = content.replace(/\[(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)\]/gi, '<$1$2>');
2469
2465
  content = content.replace(/\{(\/|)(br|hr|p|b|strong|u|i|em|li|ul|ol|h\d)\}/gi, '<$1$2>');
2470
- content = content.replace(/\[url\]([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\[\/url\]/gi, function (match, p1) { return atcb_parse_url_code(p1); });
2471
- content = content.replace(/\{url\}([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\{\/url\}/gi, function (match, p1) { return atcb_parse_url_code(p1); });
2466
+ content = content.replace(/\[url\]([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\[\/url\]/gi, function (match, p1) {
2467
+ return atcb_parse_url_code(p1);
2468
+ });
2469
+ content = content.replace(/\{url\}([\w&$+.,:;=~!*'?@^%#|\s\-()/]*)\{\/url\}/gi, function (match, p1) {
2470
+ return atcb_parse_url_code(p1);
2471
+ });
2472
2472
  }
2473
2473
  return content;
2474
2474
  }
@@ -3101,9 +3101,8 @@ const i18nStrings = {
3101
3101
  };
3102
3102
  const availableLanguages = Object.keys(i18nStrings);
3103
3103
  function atcb_translate_hook(identifier, data) {
3104
- const searchKey = identifier.replace(/\s+/g, '').toLowerCase();
3105
- if (data.customLabels != null && data.customLabels[`${searchKey}`] != null && data.customLabels[`${searchKey}`] != '') {
3106
- return atcb_rewrite_html_elements(data.customLabels[`${searchKey}`]);
3104
+ if (data.customLabels != null && data.customLabels[`${identifier}`] != null && data.customLabels[`${identifier}`] != '') {
3105
+ return atcb_rewrite_html_elements(data.customLabels[`${identifier}`]);
3107
3106
  } else {
3108
3107
  return atcb_translate(identifier, data.language);
3109
3108
  }
@@ -3146,9 +3145,8 @@ if (isBrowser()) {
3146
3145
  } catch (e) {
3147
3146
  if (this.debug) {
3148
3147
  atcb_render_debug_msg(this.shadowRoot, e);
3149
- console.error(e);
3150
- return;
3151
3148
  }
3149
+ return;
3152
3150
  }
3153
3151
  this.data.proKey = '';
3154
3152
  }
@@ -3178,9 +3176,8 @@ if (isBrowser()) {
3178
3176
  } catch (e) {
3179
3177
  if (this.debug) {
3180
3178
  atcb_render_debug_msg(this.shadowRoot, e);
3181
- console.error(e);
3182
- return;
3183
3179
  }
3180
+ return;
3184
3181
  }
3185
3182
  }
3186
3183
  disconnectedCallback() {
@@ -3221,9 +3218,8 @@ if (isBrowser()) {
3221
3218
  } catch (e) {
3222
3219
  if (this.debug) {
3223
3220
  atcb_render_debug_msg(this.shadowRoot, e);
3224
- console.error(e);
3225
- return;
3226
3221
  }
3222
+ return;
3227
3223
  }
3228
3224
  this.data.identifier = this.identifier;
3229
3225
  try {
@@ -3231,9 +3227,8 @@ if (isBrowser()) {
3231
3227
  } catch (e) {
3232
3228
  if (this.debug) {
3233
3229
  atcb_render_debug_msg(this.shadowRoot, e);
3234
- console.error(e);
3235
- return;
3236
3230
  }
3231
+ return;
3237
3232
  }
3238
3233
  }
3239
3234
  }
@@ -3257,6 +3252,14 @@ function atcb_read_attributes(el) {
3257
3252
  }
3258
3253
  } else if (atcbWcObjectParams.includes(attr)) {
3259
3254
  val = JSON.parse(inputVal);
3255
+ } else if (atcbWcObjectArrayParams.includes(attr)) {
3256
+ const cleanedInput = (function () {
3257
+ if (inputVal.substring(0, 1) != '[') {
3258
+ return '[' + inputVal + ']';
3259
+ }
3260
+ return inputVal;
3261
+ })();
3262
+ val = JSON.parse(cleanedInput);
3260
3263
  } else if (atcbWcArrayParams.includes(attr)) {
3261
3264
  const cleanedInput = (function () {
3262
3265
  let newVal = inputVal;
@@ -3287,7 +3290,7 @@ function atcb_read_attributes(el) {
3287
3290
  data['identifier'] = atcb_secure_content(identifierAttr.replace(/(\r\n|\n|\r)/g, ''), false);
3288
3291
  }
3289
3292
  }
3290
- if (!atcb_check_required(data, false)) {
3293
+ if (!atcb_check_required(data)) {
3291
3294
  const slotInput = el.innerHTML;
3292
3295
  const atcbJsonInput = (function () {
3293
3296
  if (slotInput != '') {
@@ -3300,6 +3303,7 @@ function atcb_read_attributes(el) {
3300
3303
  return '';
3301
3304
  })();
3302
3305
  if (atcbJsonInput.length == 0) {
3306
+ console.error(data.validationError);
3303
3307
  throw new Error('Add to Calendar Button generation failed: no data provided or missing required fields - see console logs for details');
3304
3308
  }
3305
3309
  data = atcbJsonInput;
@@ -3307,26 +3311,24 @@ function atcb_read_attributes(el) {
3307
3311
  return data;
3308
3312
  }
3309
3313
  function atcb_build_button(host, data, debug = false) {
3310
- if (atcb_check_required(data)) {
3311
- data = atcb_decorate_data(data);
3312
- if (atcb_validate(data)) {
3313
- const rootObj = host.querySelector('.atcb-initialized');
3314
- atcb_set_light_mode(host, data);
3315
- rootObj.setAttribute('lang', data.language);
3316
- atcb_load_css(host, rootObj, data.buttonStyle, data.inline, data.buttonsList, data.customCss);
3317
- atcb_setup_state_management(data);
3318
- atcb_set_global_event_listener(host, data);
3319
- atcb_init_log(data.proKey, debug);
3320
- atcb_generate_button(host, rootObj, data, debug);
3321
- if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
3322
- atcb_generate_rich_data(data, host.host);
3323
- data.schemaEl = host.host.previousSibling;
3324
- }
3325
- atcb_log_event('initialization', data.identifier, data.identifier);
3326
- } else if (debug) {
3327
- console.error(data.validationError);
3328
- atcb_render_debug_msg(host, data.validationError);
3329
- }
3314
+ data = atcb_decorate_data(data);
3315
+ if (atcb_validate(data)) {
3316
+ const rootObj = host.querySelector('.atcb-initialized');
3317
+ atcb_set_light_mode(host, data);
3318
+ rootObj.setAttribute('lang', data.language);
3319
+ atcb_load_css(host, rootObj, data.buttonStyle, data.inline, data.buttonsList, data.customCss);
3320
+ atcb_setup_state_management(data);
3321
+ atcb_set_global_event_listener(host, data);
3322
+ atcb_init_log(data.proKey, debug);
3323
+ atcb_generate_button(host, rootObj, data, debug);
3324
+ if (!data.hideRichData && data.name && data.dates[0].location && data.dates[0].startDate) {
3325
+ atcb_generate_rich_data(data, host.host);
3326
+ data.schemaEl = host.host.previousSibling;
3327
+ }
3328
+ atcb_log_event('initialization', data.identifier, data.identifier);
3329
+ } else if (debug) {
3330
+ console.error(data.validationError);
3331
+ throw new Error(data.validationError);
3330
3332
  }
3331
3333
  }
3332
3334
  function atcb_cleanup(host, data) {
@@ -3452,7 +3454,8 @@ function atcb_action(data, triggerElement, keyboardTrigger = false) {
3452
3454
  }
3453
3455
  data.debug = data.debug === 'true';
3454
3456
  if (!atcb_check_required(data)) {
3455
- throw new Error('Add to Calendar Button generation failed: required data missing; see console logs');
3457
+ console.error(data.validationError);
3458
+ return;
3456
3459
  }
3457
3460
  data = atcb_decorate_data(data);
3458
3461
  let root = document.body;
@@ -3477,7 +3480,8 @@ function atcb_action(data, triggerElement, keyboardTrigger = false) {
3477
3480
  data.listStyle = 'modal';
3478
3481
  }
3479
3482
  if (!atcb_validate(data)) {
3480
- throw new Error('Add to Calendar Button generation (' + data.identifier + ') failed: invalid data; see console logs');
3483
+ console.error(data.validationError);
3484
+ return;
3481
3485
  }
3482
3486
  const oneOption = (function () {
3483
3487
  if (data.options.length === 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-to-calendar-button",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "engines": {
5
5
  "node": ">=16.18.1",
6
6
  "npm": ">=8.19.2"