@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.
@@ -742,13 +742,15 @@ var SheetController = class {
742
742
  this.root = root;
743
743
  this.options = readOptionsFromElement(root);
744
744
  this.id = this.options.componentId || root.id || createId("cap-sheet");
745
- if (!root.id) root.id = this.id;
746
745
  }
747
746
  /** Connect the controller to the DOM and initialize current state. */
748
747
  connect() {
749
748
  if (this.connected) return;
750
749
  this.connected = true;
751
- this.configure(readOptionsFromElement(this.root));
750
+ const elementOptions = readOptionsFromElement(this.root);
751
+ this.id = elementOptions.componentId || this.root.id || this.id;
752
+ if (!this.root.id) this.root.id = this.id;
753
+ this.configure(elementOptions);
752
754
  const nextPresented = this.options.presented ?? this.options.defaultPresented ?? false;
753
755
  this.activeDetent = this.resolveInitialDetent();
754
756
  this.presented = nextPresented;
@@ -1271,20 +1273,24 @@ var SheetController = class {
1271
1273
  this.clearInert();
1272
1274
  for (const child of Array.from(body.children)) {
1273
1275
  if (!(child instanceof HTMLElement)) continue;
1276
+ this.inertedElements.set(child, { inert: child.inert, ariaHidden: child.getAttribute("aria-hidden") });
1274
1277
  const isAllowed = Array.from(allowed).some((element) => child === element || child.contains(element));
1275
- if (isAllowed) continue;
1276
- this.inertedElements.set(child, child.getAttribute("aria-hidden"));
1278
+ if (isAllowed) {
1279
+ child.inert = false;
1280
+ child.removeAttribute("aria-hidden");
1281
+ continue;
1282
+ }
1277
1283
  child.inert = true;
1278
1284
  child.setAttribute("aria-hidden", "true");
1279
1285
  }
1280
1286
  }
1281
1287
  clearInert() {
1282
- for (const [element, ariaHidden] of this.inertedElements) {
1283
- element.inert = false;
1284
- if (ariaHidden === null) {
1288
+ for (const [element, state] of this.inertedElements) {
1289
+ element.inert = state.inert;
1290
+ if (state.ariaHidden === null) {
1285
1291
  element.removeAttribute("aria-hidden");
1286
1292
  } else {
1287
- element.setAttribute("aria-hidden", ariaHidden);
1293
+ element.setAttribute("aria-hidden", state.ariaHidden);
1288
1294
  }
1289
1295
  }
1290
1296
  this.inertedElements.clear();
@@ -1449,9 +1455,9 @@ var CapSheet = class extends HTMLElement {
1449
1455
  disconnectedCallback() {
1450
1456
  this.controller.disconnect();
1451
1457
  }
1452
- attributeChangedCallback() {
1458
+ attributeChangedCallback(name) {
1453
1459
  if (this.syncingAttribute) return;
1454
- this.controller.configure({});
1460
+ this.controller.configure(readChangedOptionsFromElement(this, name));
1455
1461
  if (this.isConnected) {
1456
1462
  if (this.hasAttribute("presented") && !this.controller.presented) {
1457
1463
  void this.present({ source: "programmatic" });
@@ -1529,6 +1535,38 @@ function isCapSheetElement(element) {
1529
1535
  const candidate = element;
1530
1536
  return typeof candidate.present === "function" && typeof candidate.dismiss === "function";
1531
1537
  }
1538
+ function readChangedOptionsFromElement(element, name) {
1539
+ const options = readOptionsFromElement(element);
1540
+ const keysByAttribute = {
1541
+ "active-detent": ["activeDetent"],
1542
+ "close-on-escape": ["closeOnEscape"],
1543
+ "close-on-outside-click": ["closeOnOutsideClick"],
1544
+ "content-placement": ["contentPlacement", "tracks"],
1545
+ "default-active-detent": ["defaultActiveDetent"],
1546
+ "default-presented": ["defaultPresented"],
1547
+ detents: ["detents"],
1548
+ "focus-trap": ["focusTrap"],
1549
+ "inert-outside": ["inertOutside"],
1550
+ "native-edge-swipe-prevention": ["nativeEdgeSwipePrevention"],
1551
+ "native-focus-scroll-prevention": ["nativeFocusScrollPrevention"],
1552
+ presented: ["presented"],
1553
+ "restore-focus": ["restoreFocus"],
1554
+ "safe-area": ["safeArea"],
1555
+ "sheet-role": ["sheetRole"],
1556
+ stack: ["stack"],
1557
+ swipe: ["swipe"],
1558
+ "swipe-dismissal": ["swipeDismissal"],
1559
+ "swipe-overshoot": ["swipeOvershoot"],
1560
+ "swipe-trap": ["swipeTrap"],
1561
+ "theme-color-dimming": ["themeColorDimming"],
1562
+ tracks: ["tracks"]
1563
+ };
1564
+ const changed = {};
1565
+ for (const key of keysByAttribute[name] || []) {
1566
+ changed[key] = options[key];
1567
+ }
1568
+ return changed;
1569
+ }
1532
1570
  function applySheetOptions(element, options) {
1533
1571
  if (options.contentPlacement) element.setAttribute("content-placement", options.contentPlacement);
1534
1572
  if (options.detents !== void 0) {