@capgo/capacitor-sheets 8.0.2 → 8.0.4

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.
@@ -769,13 +769,15 @@ var SheetController = class {
769
769
  this.root = root;
770
770
  this.options = readOptionsFromElement(root);
771
771
  this.id = this.options.componentId || root.id || createId("cap-sheet");
772
- if (!root.id) root.id = this.id;
773
772
  }
774
773
  /** Connect the controller to the DOM and initialize current state. */
775
774
  connect() {
776
775
  if (this.connected) return;
777
776
  this.connected = true;
778
- this.configure(readOptionsFromElement(this.root));
777
+ const elementOptions = readOptionsFromElement(this.root);
778
+ this.id = elementOptions.componentId || this.root.id || this.id;
779
+ if (!this.root.id) this.root.id = this.id;
780
+ this.configure(elementOptions);
779
781
  const nextPresented = this.options.presented ?? this.options.defaultPresented ?? false;
780
782
  this.activeDetent = this.resolveInitialDetent();
781
783
  this.presented = nextPresented;
@@ -1298,20 +1300,24 @@ var SheetController = class {
1298
1300
  this.clearInert();
1299
1301
  for (const child of Array.from(body.children)) {
1300
1302
  if (!(child instanceof HTMLElement)) continue;
1303
+ this.inertedElements.set(child, { inert: child.inert, ariaHidden: child.getAttribute("aria-hidden") });
1301
1304
  const isAllowed = Array.from(allowed).some((element) => child === element || child.contains(element));
1302
- if (isAllowed) continue;
1303
- this.inertedElements.set(child, child.getAttribute("aria-hidden"));
1305
+ if (isAllowed) {
1306
+ child.inert = false;
1307
+ child.removeAttribute("aria-hidden");
1308
+ continue;
1309
+ }
1304
1310
  child.inert = true;
1305
1311
  child.setAttribute("aria-hidden", "true");
1306
1312
  }
1307
1313
  }
1308
1314
  clearInert() {
1309
- for (const [element, ariaHidden] of this.inertedElements) {
1310
- element.inert = false;
1311
- if (ariaHidden === null) {
1315
+ for (const [element, state] of this.inertedElements) {
1316
+ element.inert = state.inert;
1317
+ if (state.ariaHidden === null) {
1312
1318
  element.removeAttribute("aria-hidden");
1313
1319
  } else {
1314
- element.setAttribute("aria-hidden", ariaHidden);
1320
+ element.setAttribute("aria-hidden", state.ariaHidden);
1315
1321
  }
1316
1322
  }
1317
1323
  this.inertedElements.clear();
@@ -1476,9 +1482,9 @@ var CapSheet = class extends HTMLElement {
1476
1482
  disconnectedCallback() {
1477
1483
  this.controller.disconnect();
1478
1484
  }
1479
- attributeChangedCallback() {
1485
+ attributeChangedCallback(name) {
1480
1486
  if (this.syncingAttribute) return;
1481
- this.controller.configure({});
1487
+ this.controller.configure(readChangedOptionsFromElement(this, name));
1482
1488
  if (this.isConnected) {
1483
1489
  if (this.hasAttribute("presented") && !this.controller.presented) {
1484
1490
  void this.present({ source: "programmatic" });
@@ -1556,6 +1562,38 @@ function isCapSheetElement(element) {
1556
1562
  const candidate = element;
1557
1563
  return typeof candidate.present === "function" && typeof candidate.dismiss === "function";
1558
1564
  }
1565
+ function readChangedOptionsFromElement(element, name) {
1566
+ const options = readOptionsFromElement(element);
1567
+ const keysByAttribute = {
1568
+ "active-detent": ["activeDetent"],
1569
+ "close-on-escape": ["closeOnEscape"],
1570
+ "close-on-outside-click": ["closeOnOutsideClick"],
1571
+ "content-placement": ["contentPlacement", "tracks"],
1572
+ "default-active-detent": ["defaultActiveDetent"],
1573
+ "default-presented": ["defaultPresented"],
1574
+ detents: ["detents"],
1575
+ "focus-trap": ["focusTrap"],
1576
+ "inert-outside": ["inertOutside"],
1577
+ "native-edge-swipe-prevention": ["nativeEdgeSwipePrevention"],
1578
+ "native-focus-scroll-prevention": ["nativeFocusScrollPrevention"],
1579
+ presented: ["presented"],
1580
+ "restore-focus": ["restoreFocus"],
1581
+ "safe-area": ["safeArea"],
1582
+ "sheet-role": ["sheetRole"],
1583
+ stack: ["stack"],
1584
+ swipe: ["swipe"],
1585
+ "swipe-dismissal": ["swipeDismissal"],
1586
+ "swipe-overshoot": ["swipeOvershoot"],
1587
+ "swipe-trap": ["swipeTrap"],
1588
+ "theme-color-dimming": ["themeColorDimming"],
1589
+ tracks: ["tracks"]
1590
+ };
1591
+ const changed = {};
1592
+ for (const key of keysByAttribute[name] || []) {
1593
+ changed[key] = options[key];
1594
+ }
1595
+ return changed;
1596
+ }
1559
1597
  function applySheetOptions(element, options) {
1560
1598
  if (options.contentPlacement) element.setAttribute("content-placement", options.contentPlacement);
1561
1599
  if (options.detents !== void 0) {