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