@y14e/path-bar 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -10,16 +10,16 @@ npm i @y14e/path-bar
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import PathBar from '@y14e/path-bar@1.0.0';
13
+ import PathBar from '@y14e/path-bar@1.0.2';
14
14
  // with middleware
15
- import PathBar, { flip, offset, shift } from '@y14e/path-bar@1.0.0';
15
+ import PathBar, { flip, offset, shift } from '@y14e/path-bar@1.0.2';
16
16
 
17
17
  // CDNs
18
- import PathBar from 'https://esm.sh/@y14e/path-bar@1.0.0';
18
+ import PathBar from 'https://esm.sh/@y14e/path-bar@1.0.2';
19
19
  // or
20
- import PathBar from 'https://cdn.jsdelivr.net/npm/@y14e/path-bar@1.0.0/+esm';
20
+ import PathBar from 'https://cdn.jsdelivr.net/npm/@y14e/path-bar@1.0.2/+esm';
21
21
  // or
22
- import PathBar from 'https://esm.unpkg.com/@y14e/path-bar@1.0.0';
22
+ import PathBar from 'https://esm.unpkg.com/@y14e/path-bar@1.0.2';
23
23
  ```
24
24
 
25
25
  ## Usage
package/dist/index.cjs CHANGED
@@ -2414,7 +2414,13 @@ function createRovingTabIndex(container, options = {}) {
2414
2414
  console.warn("Invalid wrap option. Fallback: false.");
2415
2415
  wrap = false;
2416
2416
  }
2417
- const settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
2417
+ const settings = {
2418
+ navigationOnly,
2419
+ noMemory,
2420
+ noStart,
2421
+ typeahead,
2422
+ wrap
2423
+ };
2418
2424
  direction && Object.assign(settings, { direction });
2419
2425
  selector && Object.assign(settings, { selector });
2420
2426
  const roving = new RovingTabIndex(container, settings);
@@ -2502,7 +2508,6 @@ var RovingTabIndex = class {
2502
2508
  return;
2503
2509
  }
2504
2510
  event.preventDefault();
2505
- event.stopPropagation();
2506
2511
  const currentIndex = current.indexOf(active);
2507
2512
  let rawIndex;
2508
2513
  let newIndex = currentIndex;
@@ -2663,7 +2668,6 @@ var Menu = class _Menu {
2663
2668
  #cleanupRovingTabIndex = null;
2664
2669
  #timers = [];
2665
2670
  #animation = null;
2666
- #animationId = 0;
2667
2671
  #buttons = [];
2668
2672
  #submenus = [];
2669
2673
  #submenuTimer;
@@ -3080,14 +3084,14 @@ var Menu = class _Menu {
3080
3084
  const opacity = getComputedStyle(this.#listElement).getPropertyValue(
3081
3085
  "opacity"
3082
3086
  );
3083
- const animationId = ++this.#animationId;
3084
3087
  this.#animation?.cancel();
3085
- this.#animation = this.#listElement.animate(
3088
+ const animation = this.#listElement.animate(
3086
3089
  { opacity: isOpen ? [opacity, "1"] : [opacity, "0"] },
3087
3090
  { duration: this.#settings.animation.duration, easing: "ease" }
3088
3091
  );
3092
+ this.#animation = animation;
3089
3093
  const cleanupAnimation = () => {
3090
- if (animationId === this.#animationId) {
3094
+ if (this.#animation === animation) {
3091
3095
  this.#animation = null;
3092
3096
  }
3093
3097
  };
@@ -3099,7 +3103,7 @@ var Menu = class _Menu {
3099
3103
  this.#animation.addEventListener(
3100
3104
  "finish",
3101
3105
  () => {
3102
- if (animationId !== this.#animationId) {
3106
+ if (this.#animation !== animation) {
3103
3107
  return;
3104
3108
  }
3105
3109
  cleanupAnimation();
@@ -3634,7 +3638,13 @@ function createRovingTabIndex2(container, options = {}) {
3634
3638
  console.warn("Invalid wrap option. Fallback: false.");
3635
3639
  wrap = false;
3636
3640
  }
3637
- const settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
3641
+ const settings = {
3642
+ navigationOnly,
3643
+ noMemory,
3644
+ noStart,
3645
+ typeahead,
3646
+ wrap
3647
+ };
3638
3648
  direction && Object.assign(settings, { direction });
3639
3649
  selector && Object.assign(settings, { selector });
3640
3650
  const roving = new RovingTabIndex2(container, settings);
@@ -3722,7 +3732,6 @@ var RovingTabIndex2 = class {
3722
3732
  return;
3723
3733
  }
3724
3734
  event.preventDefault();
3725
- event.stopPropagation();
3726
3735
  const currentIndex = current.indexOf(active);
3727
3736
  let rawIndex;
3728
3737
  let newIndex = currentIndex;
@@ -4180,6 +4189,7 @@ var PathBar = class _PathBar {
4180
4189
  #rootElement;
4181
4190
  #defaults = {
4182
4191
  animation: { duration: 300 },
4192
+ delay: 200,
4183
4193
  popover: {
4184
4194
  arrow: true,
4185
4195
  middleware: [flip2(), offset2(), shift2()],
@@ -4234,11 +4244,11 @@ var PathBar = class _PathBar {
4234
4244
  console.warn("Missing item elements");
4235
4245
  return;
4236
4246
  }
4237
- this.#linkElements = [
4238
- ...this.#listElement.querySelectorAll(
4239
- `${selector.list} > * > a`
4240
- )
4241
- ];
4247
+ this.#linkElements = [];
4248
+ this.#itemElements.forEach((item) => {
4249
+ const link = item.querySelector("a");
4250
+ link && this.#linkElements.push(link);
4251
+ });
4242
4252
  if (!this.#linkElements.length) {
4243
4253
  console.warn("Missing <a> elements");
4244
4254
  return;
@@ -4276,18 +4286,26 @@ var PathBar = class _PathBar {
4276
4286
  });
4277
4287
  this.#linkElements.forEach((link) => {
4278
4288
  link.addEventListener("keydown", this.#onKeyDown, { signal });
4279
- const menuRoot = link.nextElementSibling;
4280
- if (!(menuRoot instanceof HTMLElement)) {
4289
+ const root = link.closest(this.#settings.selector.item);
4290
+ if (!(root instanceof HTMLElement)) {
4281
4291
  return;
4282
4292
  }
4283
- const { animation, popover, selector } = this.#settings;
4284
- const menuInstance = new Menu(
4285
- menuRoot,
4286
- { animation, popover: { menu: popover }, selector: selector.menu },
4293
+ const { animation, delay, popover, selector } = this.#settings;
4294
+ if (!root.querySelector(selector.menu.trigger)) {
4295
+ return;
4296
+ }
4297
+ const menu = new Menu(
4298
+ root,
4299
+ {
4300
+ animation,
4301
+ delay,
4302
+ popover: { menu: popover },
4303
+ selector: selector.menu
4304
+ },
4287
4305
  { externalTrigger: link, isMenubar: true }
4288
4306
  );
4289
- this.#bindings.set(link, createBinding(link, menuInstance));
4290
- this.#menus.push(menuInstance);
4307
+ this.#bindings.set(link, createBinding(link, menu));
4308
+ this.#menus.push(menu);
4291
4309
  });
4292
4310
  this.#cleanupRovingTabIndex = createRovingTabIndex2(this.#listElement, {
4293
4311
  direction: "horizontal",
@@ -4384,7 +4402,7 @@ function createBinding(link, menu) {
4384
4402
  * Breadcrumb-style path bar implementation in TypeScript.
4385
4403
  * Supports keyboard navigation, integrated menus, and seamless menu traversal.
4386
4404
  *
4387
- * @version 1.0.0
4405
+ * @version 1.0.2
4388
4406
  * @author Yusuke Kamiyamane
4389
4407
  * @license MIT
4390
4408
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4398,7 +4416,7 @@ function createBinding(link, menu) {
4398
4416
  * WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
4399
4417
  * Supports checkbox item, radio item, and infinitely nested menus.
4400
4418
  *
4401
- * @version 1.7.1
4419
+ * @version 1.7.3
4402
4420
  * @author Yusuke Kamiyamane
4403
4421
  * @license MIT
4404
4422
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4473,7 +4491,7 @@ function createBinding(link, menu) {
4473
4491
  * Lightweight roving tabindex utility with fully focus management.
4474
4492
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
4475
4493
  *
4476
- * @version 2.2.0
4494
+ * @version 3.0.0
4477
4495
  * @author Yusuke Kamiyamane
4478
4496
  * @license MIT
4479
4497
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4513,7 +4531,7 @@ function createBinding(link, menu) {
4513
4531
  * Lightweight roving tabindex utility with fully focus management.
4514
4532
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
4515
4533
  *
4516
- * @version 2.2.0
4534
+ * @version 3.0.0
4517
4535
  * @author Yusuke Kamiyamane
4518
4536
  * @license MIT
4519
4537
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ export { flip, offset, shift } from '@y14e/menu';
6
6
  * Breadcrumb-style path bar implementation in TypeScript.
7
7
  * Supports keyboard navigation, integrated menus, and seamless menu traversal.
8
8
  *
9
- * @version 1.0.0
9
+ * @version 1.0.2
10
10
  * @author Yusuke Kamiyamane
11
11
  * @license MIT
12
12
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -17,6 +17,7 @@ interface PathBarOptions {
17
17
  readonly animation?: {
18
18
  readonly duration?: number;
19
19
  };
20
+ readonly delay?: number;
20
21
  readonly popover?: PathBarPopoverOptions;
21
22
  readonly selector?: {
22
23
  readonly item?: string;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { flip, offset, shift } from '@y14e/menu';
6
6
  * Breadcrumb-style path bar implementation in TypeScript.
7
7
  * Supports keyboard navigation, integrated menus, and seamless menu traversal.
8
8
  *
9
- * @version 1.0.0
9
+ * @version 1.0.2
10
10
  * @author Yusuke Kamiyamane
11
11
  * @license MIT
12
12
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -17,6 +17,7 @@ interface PathBarOptions {
17
17
  readonly animation?: {
18
18
  readonly duration?: number;
19
19
  };
20
+ readonly delay?: number;
20
21
  readonly popover?: PathBarPopoverOptions;
21
22
  readonly selector?: {
22
23
  readonly item?: string;
package/dist/index.js CHANGED
@@ -2410,7 +2410,13 @@ function createRovingTabIndex(container, options = {}) {
2410
2410
  console.warn("Invalid wrap option. Fallback: false.");
2411
2411
  wrap = false;
2412
2412
  }
2413
- const settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
2413
+ const settings = {
2414
+ navigationOnly,
2415
+ noMemory,
2416
+ noStart,
2417
+ typeahead,
2418
+ wrap
2419
+ };
2414
2420
  direction && Object.assign(settings, { direction });
2415
2421
  selector && Object.assign(settings, { selector });
2416
2422
  const roving = new RovingTabIndex(container, settings);
@@ -2498,7 +2504,6 @@ var RovingTabIndex = class {
2498
2504
  return;
2499
2505
  }
2500
2506
  event.preventDefault();
2501
- event.stopPropagation();
2502
2507
  const currentIndex = current.indexOf(active);
2503
2508
  let rawIndex;
2504
2509
  let newIndex = currentIndex;
@@ -2659,7 +2664,6 @@ var Menu = class _Menu {
2659
2664
  #cleanupRovingTabIndex = null;
2660
2665
  #timers = [];
2661
2666
  #animation = null;
2662
- #animationId = 0;
2663
2667
  #buttons = [];
2664
2668
  #submenus = [];
2665
2669
  #submenuTimer;
@@ -3076,14 +3080,14 @@ var Menu = class _Menu {
3076
3080
  const opacity = getComputedStyle(this.#listElement).getPropertyValue(
3077
3081
  "opacity"
3078
3082
  );
3079
- const animationId = ++this.#animationId;
3080
3083
  this.#animation?.cancel();
3081
- this.#animation = this.#listElement.animate(
3084
+ const animation = this.#listElement.animate(
3082
3085
  { opacity: isOpen ? [opacity, "1"] : [opacity, "0"] },
3083
3086
  { duration: this.#settings.animation.duration, easing: "ease" }
3084
3087
  );
3088
+ this.#animation = animation;
3085
3089
  const cleanupAnimation = () => {
3086
- if (animationId === this.#animationId) {
3090
+ if (this.#animation === animation) {
3087
3091
  this.#animation = null;
3088
3092
  }
3089
3093
  };
@@ -3095,7 +3099,7 @@ var Menu = class _Menu {
3095
3099
  this.#animation.addEventListener(
3096
3100
  "finish",
3097
3101
  () => {
3098
- if (animationId !== this.#animationId) {
3102
+ if (this.#animation !== animation) {
3099
3103
  return;
3100
3104
  }
3101
3105
  cleanupAnimation();
@@ -3630,7 +3634,13 @@ function createRovingTabIndex2(container, options = {}) {
3630
3634
  console.warn("Invalid wrap option. Fallback: false.");
3631
3635
  wrap = false;
3632
3636
  }
3633
- const settings = { navigationOnly, noMemory, noStart, typeahead, wrap };
3637
+ const settings = {
3638
+ navigationOnly,
3639
+ noMemory,
3640
+ noStart,
3641
+ typeahead,
3642
+ wrap
3643
+ };
3634
3644
  direction && Object.assign(settings, { direction });
3635
3645
  selector && Object.assign(settings, { selector });
3636
3646
  const roving = new RovingTabIndex2(container, settings);
@@ -3718,7 +3728,6 @@ var RovingTabIndex2 = class {
3718
3728
  return;
3719
3729
  }
3720
3730
  event.preventDefault();
3721
- event.stopPropagation();
3722
3731
  const currentIndex = current.indexOf(active);
3723
3732
  let rawIndex;
3724
3733
  let newIndex = currentIndex;
@@ -4176,6 +4185,7 @@ var PathBar = class _PathBar {
4176
4185
  #rootElement;
4177
4186
  #defaults = {
4178
4187
  animation: { duration: 300 },
4188
+ delay: 200,
4179
4189
  popover: {
4180
4190
  arrow: true,
4181
4191
  middleware: [flip2(), offset2(), shift2()],
@@ -4230,11 +4240,11 @@ var PathBar = class _PathBar {
4230
4240
  console.warn("Missing item elements");
4231
4241
  return;
4232
4242
  }
4233
- this.#linkElements = [
4234
- ...this.#listElement.querySelectorAll(
4235
- `${selector.list} > * > a`
4236
- )
4237
- ];
4243
+ this.#linkElements = [];
4244
+ this.#itemElements.forEach((item) => {
4245
+ const link = item.querySelector("a");
4246
+ link && this.#linkElements.push(link);
4247
+ });
4238
4248
  if (!this.#linkElements.length) {
4239
4249
  console.warn("Missing <a> elements");
4240
4250
  return;
@@ -4272,18 +4282,26 @@ var PathBar = class _PathBar {
4272
4282
  });
4273
4283
  this.#linkElements.forEach((link) => {
4274
4284
  link.addEventListener("keydown", this.#onKeyDown, { signal });
4275
- const menuRoot = link.nextElementSibling;
4276
- if (!(menuRoot instanceof HTMLElement)) {
4285
+ const root = link.closest(this.#settings.selector.item);
4286
+ if (!(root instanceof HTMLElement)) {
4277
4287
  return;
4278
4288
  }
4279
- const { animation, popover, selector } = this.#settings;
4280
- const menuInstance = new Menu(
4281
- menuRoot,
4282
- { animation, popover: { menu: popover }, selector: selector.menu },
4289
+ const { animation, delay, popover, selector } = this.#settings;
4290
+ if (!root.querySelector(selector.menu.trigger)) {
4291
+ return;
4292
+ }
4293
+ const menu = new Menu(
4294
+ root,
4295
+ {
4296
+ animation,
4297
+ delay,
4298
+ popover: { menu: popover },
4299
+ selector: selector.menu
4300
+ },
4283
4301
  { externalTrigger: link, isMenubar: true }
4284
4302
  );
4285
- this.#bindings.set(link, createBinding(link, menuInstance));
4286
- this.#menus.push(menuInstance);
4303
+ this.#bindings.set(link, createBinding(link, menu));
4304
+ this.#menus.push(menu);
4287
4305
  });
4288
4306
  this.#cleanupRovingTabIndex = createRovingTabIndex2(this.#listElement, {
4289
4307
  direction: "horizontal",
@@ -4380,7 +4398,7 @@ function createBinding(link, menu) {
4380
4398
  * Breadcrumb-style path bar implementation in TypeScript.
4381
4399
  * Supports keyboard navigation, integrated menus, and seamless menu traversal.
4382
4400
  *
4383
- * @version 1.0.0
4401
+ * @version 1.0.2
4384
4402
  * @author Yusuke Kamiyamane
4385
4403
  * @license MIT
4386
4404
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4394,7 +4412,7 @@ function createBinding(link, menu) {
4394
4412
  * WAI-ARIA compliant menu (menu button) pattern implementation in TypeScript.
4395
4413
  * Supports checkbox item, radio item, and infinitely nested menus.
4396
4414
  *
4397
- * @version 1.7.1
4415
+ * @version 1.7.3
4398
4416
  * @author Yusuke Kamiyamane
4399
4417
  * @license MIT
4400
4418
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4469,7 +4487,7 @@ function createBinding(link, menu) {
4469
4487
  * Lightweight roving tabindex utility with fully focus management.
4470
4488
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
4471
4489
  *
4472
- * @version 2.2.0
4490
+ * @version 3.0.0
4473
4491
  * @author Yusuke Kamiyamane
4474
4492
  * @license MIT
4475
4493
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -4509,7 +4527,7 @@ function createBinding(link, menu) {
4509
4527
  * Lightweight roving tabindex utility with fully focus management.
4510
4528
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
4511
4529
  *
4512
- * @version 2.2.0
4530
+ * @version 3.0.0
4513
4531
  * @author Yusuke Kamiyamane
4514
4532
  * @license MIT
4515
4533
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/path-bar",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,8 +44,8 @@
44
44
  "devDependencies": {
45
45
  "@floating-ui/dom": "^1.7.6",
46
46
  "@y14e/attributes-utils": "^1.1.1",
47
- "@y14e/menu": "^1.7.1",
48
- "@y14e/roving-tabindex": "^2.2.0",
47
+ "@y14e/menu": "^1.7.3",
48
+ "@y14e/roving-tabindex": "^3.0.0",
49
49
  "bun-types": "latest",
50
50
  "power-focusable": "^4.3.2",
51
51
  "tsup": "^8.0.0",