@expressivecss/expressive 0.1.0 → 0.2.0

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.
@@ -1842,6 +1842,74 @@ var Range = class _Range extends Component {
1842
1842
  }
1843
1843
  };
1844
1844
 
1845
+ // src/ts/behaviors/dialogs.ts
1846
+ var _Dialogs = class _Dialogs {
1847
+ static Init() {
1848
+ Utils.onDocumentReady(() => {
1849
+ document.addEventListener("pointerdown", _Dialogs._onPointerDown, { passive: true });
1850
+ document.addEventListener("pointerup", _Dialogs._onPointerUp, { passive: true });
1851
+ document.addEventListener("pointercancel", _Dialogs._onPointerCancel, { passive: true });
1852
+ });
1853
+ }
1854
+ static _onPointerDown(event) {
1855
+ if (!_Dialogs._isPrimaryPress(event)) {
1856
+ _Dialogs._down = null;
1857
+ return;
1858
+ }
1859
+ const dialog = _Dialogs._backdropDialog(event);
1860
+ if (!dialog || !_Dialogs._lightDismissible(dialog) || !_Dialogs._outside(event, dialog)) {
1861
+ _Dialogs._down = null;
1862
+ return;
1863
+ }
1864
+ _Dialogs._down = { dialog, pointerId: event.pointerId };
1865
+ }
1866
+ static _onPointerUp(event) {
1867
+ const started = _Dialogs._down;
1868
+ _Dialogs._down = null;
1869
+ if (!started || started.pointerId !== event.pointerId) return;
1870
+ if (!event.isPrimary) return;
1871
+ if (!started.dialog.isConnected || !started.dialog.open) return;
1872
+ if (!_Dialogs._lightDismissible(started.dialog)) return;
1873
+ if (_Dialogs._backdropDialog(event) !== started.dialog) return;
1874
+ if (_Dialogs._outside(event, started.dialog)) {
1875
+ started.dialog.close();
1876
+ }
1877
+ }
1878
+ static _onPointerCancel() {
1879
+ _Dialogs._down = null;
1880
+ }
1881
+ /** Backdrop hits retarget to the dialog itself, never a child. */
1882
+ static _backdropDialog(event) {
1883
+ const target = event.target;
1884
+ if (!(target instanceof HTMLDialogElement) || !target.open) return null;
1885
+ return target;
1886
+ }
1887
+ static _outside(event, dialog) {
1888
+ const rect = dialog.getBoundingClientRect();
1889
+ return event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom;
1890
+ }
1891
+ static _isPrimaryPress(event) {
1892
+ if (!event.isPrimary) return false;
1893
+ return event.pointerType !== "mouse" || event.button === 0;
1894
+ }
1895
+ static _lightDismissible(dialog) {
1896
+ const value = _Dialogs._closedBy(dialog);
1897
+ if (value === "none" || value === "closerequest") return false;
1898
+ if (value === "any" && "closedBy" in HTMLDialogElement.prototype) return false;
1899
+ return true;
1900
+ }
1901
+ // Read the attribute only. The IDL default for an unset closedby is
1902
+ // "closerequest" (Escape, no light dismiss) — treating that as an
1903
+ // author opt-out made every dialog undismissable from the scrim.
1904
+ static _closedBy(dialog) {
1905
+ const attr = dialog.getAttribute("closedby");
1906
+ if (attr === "any" || attr === "closerequest" || attr === "none") return attr;
1907
+ return null;
1908
+ }
1909
+ };
1910
+ _Dialogs._down = null;
1911
+ var Dialogs = _Dialogs;
1912
+
1845
1913
  // src/ts/behaviors/forms.ts
1846
1914
  var Forms = class _Forms {
1847
1915
  /**
@@ -7386,7 +7454,7 @@ function AutoInit(context = document.body, options) {
7386
7454
  }
7387
7455
 
7388
7456
  // src/ts/index.ts
7389
- var version = "0.1.0";
7457
+ var version = "0.2.0";
7390
7458
  if (typeof document !== "undefined") {
7391
7459
  document.addEventListener("keydown", Utils.docHandleKeydown, true);
7392
7460
  document.addEventListener("keyup", Utils.docHandleKeyup, true);
@@ -7398,6 +7466,7 @@ Chips.Init();
7398
7466
  Waves.Init();
7399
7467
  Range.Init();
7400
7468
  Cards.Init();
7469
+ Dialogs.Init();
7401
7470
  export {
7402
7471
  AutoInit,
7403
7472
  Autocomplete,
@@ -7407,6 +7476,7 @@ export {
7407
7476
  Chips,
7408
7477
  Collapsible,
7409
7478
  Datepicker,
7479
+ Dialogs,
7410
7480
  Dropdown,
7411
7481
  FloatingActionButton,
7412
7482
  FormSelect,