@wpmoo/ui 2.1.0 → 2.1.1

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/js/sheet.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI sheet.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI sheet.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI sidebar.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI sidebar.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -45,6 +45,14 @@ __name(ownerPortalRoot, "ownerPortalRoot");
45
45
 
46
46
  // src/js/components/sidebar.js
47
47
  var instances = /* @__PURE__ */ new WeakMap();
48
+ var FLYOUT_FOCUSABLE_SELECTOR = "a[href], button, input, select, textarea, [tabindex]";
49
+ function flyoutFocusables(flyout) {
50
+ const view = flyout.ownerDocument.defaultView;
51
+ return [...flyout.querySelectorAll(FLYOUT_FOCUSABLE_SELECTOR)].filter(
52
+ (element) => !element.matches(":disabled") && element.tabIndex >= 0 && !element.closest("[hidden], [inert]") && element.getClientRects().length > 0 && view.getComputedStyle(element).visibility === "visible"
53
+ );
54
+ }
55
+ __name(flyoutFocusables, "flyoutFocusables");
48
56
  var _Sidebar = class _Sidebar {
49
57
  static getInstance(element) {
50
58
  return element?.nodeType === 1 ? instances.get(element) || null : null;
@@ -472,8 +480,38 @@ var _Sidebar = class _Sidebar {
472
480
  this._closeFlyouts();
473
481
  } else {
474
482
  this._openFlyout(item);
483
+ if (event.detail === 0) {
484
+ if (this._flyout) {
485
+ flyoutFocusables(this._flyout)[0]?.focus();
486
+ }
487
+ }
475
488
  }
476
489
  }
490
+ // The flyout lives in a portal, away from its trigger, so Escape and Tab
491
+ // out of it return to the trigger instead of wandering. Tab between its
492
+ // items stays native; a key a flyout control already handled is left alone.
493
+ _handleFlyoutKeydown(event) {
494
+ const owner = this._flyoutOwner;
495
+ if (event.defaultPrevented || !this._flyout || !owner || !(event.key === "Escape" || event.key === "Tab")) {
496
+ return false;
497
+ }
498
+ const inFlyout = this._flyout.contains(event.target);
499
+ if (!inFlyout && !(event.key === "Escape" && owner.contains(event.target))) {
500
+ return false;
501
+ }
502
+ if (event.key === "Tab") {
503
+ const items = flyoutFocusables(this._flyout);
504
+ const edge = event.shiftKey ? items[0] : items[items.length - 1];
505
+ if (edge && event.target !== edge) {
506
+ return false;
507
+ }
508
+ }
509
+ event.preventDefault();
510
+ const trigger = owner.querySelector(":scope > .sidebar-menu-sub-trigger");
511
+ this._closeFlyouts();
512
+ trigger?.focus();
513
+ return true;
514
+ }
477
515
  _handleOutsideFlyoutClick(event) {
478
516
  if (!this._flyout) {
479
517
  return;
@@ -485,6 +523,9 @@ var _Sidebar = class _Sidebar {
485
523
  }
486
524
  }
487
525
  _handleShortcut(event) {
526
+ if (this._handleFlyoutKeydown(event)) {
527
+ return;
528
+ }
488
529
  const target = event.target;
489
530
  const isEditable = target instanceof this._window.Element && (target.matches("input, textarea, select") || target.isContentEditable);
490
531
  if (event.defaultPrevented || event.isComposing || isEditable || !this._config.keyboard || !(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== "b" || !this._isDesktop()) {
package/dist/js/slider.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI slider.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI slider.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
package/dist/js/state.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI state.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI state.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI table-of-contents.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI table-of-contents.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
package/dist/js/toc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI toc.js v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI toc.js v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  */
@@ -3,22 +3,22 @@
3
3
  {
4
4
  "export": "./moo.css",
5
5
  "path": "dist/assets/css/moo.css",
6
- "sha256": "b59eab8eb8321379f5995c831b17de2984cb90711dbe4fb4cf6ddc879962cb59"
6
+ "sha256": "2c98f8a15fdd14b6749831dbe78edfeb8998f5cfc017733164efacf93b16db11"
7
7
  },
8
8
  {
9
9
  "export": "./moo-ui.css",
10
10
  "path": "dist/assets/css/moo-ui.css",
11
- "sha256": "2a898c1c05759626168d736cd999a9abc26ebc675e47187e70b5e0d84d91b85e"
11
+ "sha256": "afca34860a8a9cb3bc3ebf4b5d22d687b26d7cadac0dace6224e44da28f24874"
12
12
  },
13
13
  {
14
14
  "export": "./state.js",
15
15
  "path": "dist/js/state.js",
16
- "sha256": "d02e78a71a624a0c8d36f33efc4b5a4fa0d2ac49b329e53994c20ff60c386713"
16
+ "sha256": "adb29ff6ee521414f8975d7b4240f7aeb39dc7c6a59349fc6c95591b5b1f109d"
17
17
  }
18
18
  ],
19
19
  "package": {
20
20
  "name": "@wpmoo/ui",
21
- "version": "2.1.0"
21
+ "version": "2.1.1"
22
22
  },
23
23
  "schemaVersion": 1
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpmoo/ui",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Bootstrap markup. shadcn feel. A frontend-framework-free component system for server-rendered apps.",
5
5
  "license": "MIT",
6
6
  "author": "WPMoo (https://wpmoo.org)",
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Moo UI v2.1.0 (https://wpmoo.org/)
2
+ * Moo UI v2.1.1 (https://wpmoo.org/)
3
3
  * Copyright 2026 WPMoo Authors
4
4
  * Licensed under MIT (https://github.com/wpmoo-org/ui/blob/main/LICENSE)
5
5
  *