altcha 3.0.4 → 3.0.5

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.
@@ -5365,7 +5365,7 @@
5365
5365
  button.disabled = get(audioState) === AudioState.LOADING || get(audioState) === AudioState.ERROR;
5366
5366
  set_attribute(button, "aria-label", get(audioState) === AudioState.LOADING ? strings().loading : strings().getAudioChallenge);
5367
5367
  });
5368
- delegated("click", button, () => onPlayAudio());
5368
+ event("click", button, () => onPlayAudio(), true);
5369
5369
  append($$anchor2, button);
5370
5370
  };
5371
5371
  if_block(node_1, ($$render) => {
@@ -5420,12 +5420,12 @@
5420
5420
  event("submit", form, onSubmitCapture, true);
5421
5421
  delegated("keydown", input, onInputKeyDown);
5422
5422
  bind_value(input, () => get(code), ($$value) => set(code, $$value));
5423
- delegated("click", button_1, () => onReload()?.());
5424
- delegated("click", button_3, () => onCancel()?.());
5423
+ event("click", button_1, () => onReload()?.(), true);
5424
+ event("click", button_3, () => onCancel()?.(), true);
5425
5425
  append($$anchor, div);
5426
5426
  return pop($$exports);
5427
5427
  }
5428
- delegate(["keydown", "click"]);
5428
+ delegate(["keydown"]);
5429
5429
  create_custom_element(
5430
5430
  Code,
5431
5431
  {
@@ -5448,7 +5448,7 @@
5448
5448
  var root$1 = /* @__PURE__ */ from_html(`<!> <div><!> <!> <div class="altcha-popover-content"><!></div></div>`, 1);
5449
5449
  function Popover($$anchor, $$props) {
5450
5450
  push($$props, true);
5451
- let anchor = prop($$props, "anchor"), children = prop($$props, "children"), display = prop($$props, "display", 7, "standard"), backdrop = prop($$props, "backdrop", 7, false), onClickOutside = prop($$props, "onClickOutside"), onClickOutsideDelay = prop($$props, "onClickOutsideDelay", 7, 600), onClose = prop($$props, "onClose"), placement = prop($$props, "placement", 7, "auto"), variant = prop($$props, "variant", 7, "neutral"), rest = /* @__PURE__ */ rest_props($$props, [
5451
+ let anchor = prop($$props, "anchor"), children = prop($$props, "children"), display = prop($$props, "display", 7, "standard"), backdrop = prop($$props, "backdrop", 7, false), onClickOutside = prop($$props, "onClickOutside"), onClickOutsideDelay = prop($$props, "onClickOutsideDelay", 7, 600), onClose = prop($$props, "onClose"), placement = prop($$props, "placement", 7, "auto"), updateUISignal = prop($$props, "updateUISignal"), variant = prop($$props, "variant", 7, "neutral"), rest = /* @__PURE__ */ rest_props($$props, [
5452
5452
  "$$slots",
5453
5453
  "$$events",
5454
5454
  "$$legacy",
@@ -5461,6 +5461,7 @@
5461
5461
  "onClickOutsideDelay",
5462
5462
  "onClose",
5463
5463
  "placement",
5464
+ "updateUISignal",
5464
5465
  "variant"
5465
5466
  ]);
5466
5467
  let el = /* @__PURE__ */ state(void 0);
@@ -5472,6 +5473,11 @@
5472
5473
  set(top, placement() === "top");
5473
5474
  }
5474
5475
  });
5476
+ user_effect(() => {
5477
+ if (updateUISignal()) {
5478
+ reposition();
5479
+ }
5480
+ });
5475
5481
  onMount(() => {
5476
5482
  const moveToBody = display() === "bottomsheet" || display() === "overlay";
5477
5483
  if (moveToBody) {
@@ -5494,7 +5500,7 @@
5494
5500
  }
5495
5501
  function onWindowClick(ev) {
5496
5502
  const target = ev.target;
5497
- if (!get(el)?.contains(target) && get(mountedAt) && get(mountedAt) + onClickOutsideDelay() < Date.now()) {
5503
+ if (!get(el)?.contains(target) && (!onClickOutsideDelay() || get(mountedAt) + onClickOutsideDelay() < Date.now())) {
5498
5504
  onClickOutside()?.();
5499
5505
  }
5500
5506
  }
@@ -5571,6 +5577,13 @@
5571
5577
  placement($$value);
5572
5578
  flushSync();
5573
5579
  },
5580
+ get updateUISignal() {
5581
+ return updateUISignal();
5582
+ },
5583
+ set updateUISignal($$value) {
5584
+ updateUISignal($$value);
5585
+ flushSync();
5586
+ },
5574
5587
  get variant() {
5575
5588
  return variant();
5576
5589
  },
@@ -5580,7 +5593,7 @@
5580
5593
  }
5581
5594
  };
5582
5595
  var fragment = root$1();
5583
- event("click", $window, onWindowClick);
5596
+ event("click", $window, onWindowClick, true);
5584
5597
  event("resize", $window, onWindowResize);
5585
5598
  event("scroll", $window, onWindowScroll);
5586
5599
  var node = first_child(fragment);
@@ -5617,7 +5630,7 @@
5617
5630
  {
5618
5631
  var consequent_2 = ($$anchor2) => {
5619
5632
  var div_3 = root_3$1();
5620
- delegated("click", div_3, onCloseClick);
5633
+ event("click", div_3, onCloseClick, true);
5621
5634
  append($$anchor2, div_3);
5622
5635
  };
5623
5636
  if_block(node_2, ($$render) => {
@@ -5633,7 +5646,6 @@
5633
5646
  append($$anchor, fragment);
5634
5647
  return pop($$exports);
5635
5648
  }
5636
- delegate(["click"]);
5637
5649
  create_custom_element(
5638
5650
  Popover,
5639
5651
  {
@@ -5645,6 +5657,7 @@
5645
5657
  onClickOutsideDelay: {},
5646
5658
  onClose: {},
5647
5659
  placement: {},
5660
+ updateUISignal: {},
5648
5661
  variant: {}
5649
5662
  },
5650
5663
  [],
@@ -5919,6 +5932,7 @@
5919
5932
  let checked = /* @__PURE__ */ state(false);
5920
5933
  let codeChallenge = /* @__PURE__ */ state(null);
5921
5934
  let currentController = /* @__PURE__ */ state(null);
5935
+ let currentDisplay = /* @__PURE__ */ state(null);
5922
5936
  let currentState = /* @__PURE__ */ state(proxy(State.UNVERIFIED));
5923
5937
  let elAnchorArrow = /* @__PURE__ */ state(void 0);
5924
5938
  let elFloatingAnchor = /* @__PURE__ */ state(void 0);
@@ -5929,6 +5943,7 @@
5929
5943
  let expirationTimeout = /* @__PURE__ */ state(null);
5930
5944
  let payload = /* @__PURE__ */ state(null);
5931
5945
  let plugins = /* @__PURE__ */ state(proxy([]));
5946
+ let updateUISignal = /* @__PURE__ */ state(0);
5932
5947
  let userConfig = /* @__PURE__ */ state(proxy({}));
5933
5948
  let visible = /* @__PURE__ */ state(true);
5934
5949
  const config = /* @__PURE__ */ user_derived(() => ({
@@ -6008,7 +6023,9 @@
6008
6023
  }
6009
6024
  });
6010
6025
  user_effect(() => {
6011
- setDisplay(get(config).display);
6026
+ if (get(currentDisplay) !== get(config).display) {
6027
+ setDisplay(get(config).display);
6028
+ }
6012
6029
  });
6013
6030
  user_effect(() => {
6014
6031
  if (get(checked) && get(currentState) === State.VERIFYING) {
@@ -6059,7 +6076,7 @@
6059
6076
  }
6060
6077
  });
6061
6078
  onMount(() => {
6062
- log("mounted", "3.0.4");
6079
+ log("mounted", "3.0.5");
6063
6080
  if (instance) {
6064
6081
  globalThis.$altcha.instances.add(instance);
6065
6082
  }
@@ -6353,6 +6370,7 @@
6353
6370
  }
6354
6371
  }
6355
6372
  function onWindowPageshow() {
6373
+ setDisplay(get(config).display);
6356
6374
  reset$1();
6357
6375
  }
6358
6376
  function onWindowResize() {
@@ -6473,6 +6491,9 @@
6473
6491
  case "standard":
6474
6492
  show();
6475
6493
  }
6494
+ if (get(currentDisplay) !== value) {
6495
+ set(currentDisplay, value, true);
6496
+ }
6476
6497
  }
6477
6498
  function setChallengeExpiration(expiresAt) {
6478
6499
  if (get(expirationTimeout)) {
@@ -6593,6 +6614,7 @@
6593
6614
  case "floating":
6594
6615
  return repositionFloating();
6595
6616
  }
6617
+ set(updateUISignal, get(updateUISignal) + 1);
6596
6618
  }
6597
6619
  async function verify(options = {}) {
6598
6620
  const {
@@ -6750,7 +6772,7 @@
6750
6772
  if (get(config).overlayContent) $$render(consequent_1);
6751
6773
  });
6752
6774
  }
6753
- delegated("click", div_2, onCloseClick);
6775
+ event("click", div_2, onCloseClick, true);
6754
6776
  append($$anchor2, fragment_1);
6755
6777
  };
6756
6778
  if_block(node_1, ($$render) => {
@@ -6895,6 +6917,9 @@
6895
6917
  get dir() {
6896
6918
  return get(dir);
6897
6919
  },
6920
+ get updateUISignal() {
6921
+ return get(updateUISignal);
6922
+ },
6898
6923
  children: ($$anchor3, $$slotProps) => {
6899
6924
  var fragment_9 = comment();
6900
6925
  var node_10 = first_child(fragment_9);
@@ -6960,6 +6985,9 @@
6960
6985
  get dir() {
6961
6986
  return get(dir);
6962
6987
  },
6988
+ get updateUISignal() {
6989
+ return get(updateUISignal);
6990
+ },
6963
6991
  children: ($$anchor4, $$slotProps) => {
6964
6992
  var fragment_12 = root_19();
6965
6993
  var node_12 = first_child(fragment_12);
@@ -7031,7 +7059,6 @@
7031
7059
  $$cleanup();
7032
7060
  return $$pop;
7033
7061
  }
7034
- delegate(["click"]);
7035
7062
  if (typeof window !== "undefined" && window.customElements) customElements.define("altcha-widget", create_custom_element(
7036
7063
  Widget,
7037
7064
  {