@m3e/dialog 1.1.1 → 1.1.3

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.
@@ -22,33 +22,13 @@
22
22
  "attribute": "return-value"
23
23
  },
24
24
  {
25
- "kind": "field",
26
- "name": "#clickHandler",
27
- "privacy": "private",
28
- "readonly": true
29
- },
30
- {
31
- "kind": "field",
32
- "name": "formAssociated",
33
- "static": true,
34
- "readonly": true,
35
- "default": "formAssociated",
36
- "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
37
- "inheritedFrom": {
38
- "name": "AttachInternals",
39
- "module": "../core/src/shared/mixins/AttachInternals.ts"
40
- }
41
- },
42
- {
43
- "kind": "field",
44
- "name": "[_internals]",
45
- "type": {
46
- "text": "ElementInternals | undefined"
47
- },
48
- "privacy": "private",
49
- "inheritedFrom": {
50
- "name": "AttachInternals",
51
- "module": "../core/src/shared/mixins/AttachInternals.ts"
25
+ "kind": "method",
26
+ "name": "_onClick",
27
+ "privacy": "protected",
28
+ "return": {
29
+ "type": {
30
+ "text": "void"
31
+ }
52
32
  }
53
33
  }
54
34
  ],
@@ -63,15 +43,9 @@
63
43
  "fieldName": "returnValue"
64
44
  }
65
45
  ],
66
- "mixins": [
67
- {
68
- "name": "AttachInternals",
69
- "package": "@m3e/core"
70
- }
71
- ],
72
46
  "superclass": {
73
- "name": "LitElement",
74
- "package": "lit"
47
+ "name": "ActionElementBase",
48
+ "package": "@m3e/core"
75
49
  },
76
50
  "tagName": "m3e-dialog-action",
77
51
  "customElement": true
@@ -581,9 +555,13 @@
581
555
  "name": "M3eDialogTriggerElement",
582
556
  "members": [
583
557
  {
584
- "kind": "field",
585
- "name": "#clickHandler",
586
- "privacy": "private"
558
+ "kind": "method",
559
+ "name": "_onClick",
560
+ "return": {
561
+ "type": {
562
+ "text": "void"
563
+ }
564
+ }
587
565
  },
588
566
  {
589
567
  "kind": "field",
@@ -671,45 +649,17 @@
671
649
  "name": "HtmlFor",
672
650
  "module": "../core/src/shared/mixins/HtmlFor.ts"
673
651
  }
674
- },
675
- {
676
- "kind": "field",
677
- "name": "formAssociated",
678
- "static": true,
679
- "readonly": true,
680
- "default": "formAssociated",
681
- "description": "Indicates that this custom element participates in form submission, validation, and form state restoration.",
682
- "inheritedFrom": {
683
- "name": "AttachInternals",
684
- "module": "../core/src/shared/mixins/AttachInternals.ts"
685
- }
686
- },
687
- {
688
- "kind": "field",
689
- "name": "[_internals]",
690
- "type": {
691
- "text": "ElementInternals | undefined"
692
- },
693
- "privacy": "private",
694
- "inheritedFrom": {
695
- "name": "AttachInternals",
696
- "module": "../core/src/shared/mixins/AttachInternals.ts"
697
- }
698
652
  }
699
653
  ],
700
654
  "mixins": [
701
655
  {
702
656
  "name": "HtmlFor",
703
657
  "package": "@m3e/core"
704
- },
705
- {
706
- "name": "AttachInternals",
707
- "package": "@m3e/core"
708
658
  }
709
659
  ],
710
660
  "superclass": {
711
- "name": "LitElement",
712
- "package": "lit"
661
+ "name": "ActionElementBase",
662
+ "package": "@m3e/core"
713
663
  },
714
664
  "tagName": "m3e-dialog-trigger",
715
665
  "customElement": true,
@@ -2410,12 +2360,51 @@
2410
2360
  "description": "Mixin to augment an element with behavior emits a click event on keyboard events.",
2411
2361
  "name": "KeyboardClick",
2412
2362
  "members": [
2363
+ {
2364
+ "kind": "field",
2365
+ "name": "#keyPressed",
2366
+ "privacy": "private",
2367
+ "type": {
2368
+ "text": "boolean"
2369
+ },
2370
+ "default": "false"
2371
+ },
2372
+ {
2373
+ "kind": "field",
2374
+ "name": "#keyDownHandler",
2375
+ "privacy": "private",
2376
+ "readonly": true
2377
+ },
2413
2378
  {
2414
2379
  "kind": "field",
2415
2380
  "name": "#keyUpHandler",
2416
2381
  "privacy": "private",
2417
2382
  "readonly": true
2418
2383
  },
2384
+ {
2385
+ "kind": "field",
2386
+ "name": "#focusOutHandler",
2387
+ "privacy": "private",
2388
+ "readonly": true
2389
+ },
2390
+ {
2391
+ "kind": "method",
2392
+ "name": "#handleKeyDown",
2393
+ "privacy": "private",
2394
+ "return": {
2395
+ "type": {
2396
+ "text": "void"
2397
+ }
2398
+ },
2399
+ "parameters": [
2400
+ {
2401
+ "name": "e",
2402
+ "type": {
2403
+ "text": "KeyboardEvent"
2404
+ }
2405
+ }
2406
+ ]
2407
+ },
2419
2408
  {
2420
2409
  "kind": "method",
2421
2410
  "name": "#handleKeyUp",
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2025 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import { LitElement, html, css, nothing, unsafeCSS } from 'lit';
7
- import { AttachInternals, EventAttribute, prefersReducedMotion, DesignToken, HtmlFor } from '@m3e/core';
6
+ import { ActionElementBase, EventAttribute, focusWhenReady, DesignToken, HtmlFor } from '@m3e/core';
7
+ import { LitElement, html, unsafeCSS, css, nothing } from 'lit';
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -453,14 +453,13 @@ function e$1(e, r) {
453
453
  };
454
454
  }
455
455
 
456
- var _M3eDialogActionElement_clickHandler;
457
456
  /**
458
457
  * An element, nested within a clickable element, used to close a parenting dialog.
459
458
  * @tag m3e-dialog-action
460
459
  *
461
460
  * @attr return-value - The value to return from the dialog.
462
461
  */
463
- let M3eDialogActionElement = class M3eDialogActionElement extends AttachInternals(LitElement) {
462
+ let M3eDialogActionElement = class M3eDialogActionElement extends ActionElementBase {
464
463
  constructor() {
465
464
  super(...arguments);
466
465
  /**
@@ -468,31 +467,12 @@ let M3eDialogActionElement = class M3eDialogActionElement extends AttachInternal
468
467
  * @default ""
469
468
  */
470
469
  this.returnValue = "";
471
- /** @private */
472
- _M3eDialogActionElement_clickHandler.set(this, e => {
473
- if (!e.defaultPrevented) {
474
- this.closest("m3e-dialog")?.hide(this.returnValue);
475
- }
476
- });
477
- }
478
- /** @inheritdoc */
479
- connectedCallback() {
480
- super.connectedCallback();
481
- this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _M3eDialogActionElement_clickHandler, "f"));
482
- }
483
- /** @inheritdoc */
484
- disconnectedCallback() {
485
- super.disconnectedCallback();
486
- this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _M3eDialogActionElement_clickHandler, "f"));
487
470
  }
488
471
  /** @inheritdoc */
489
- render() {
490
- return html`<slot></slot>`;
472
+ _onClick() {
473
+ this.closest("m3e-dialog")?.hide(this.returnValue);
491
474
  }
492
475
  };
493
- _M3eDialogActionElement_clickHandler = new WeakMap();
494
- /** The styles of the element. */
495
- M3eDialogActionElement.styles = css`:host { display: contents; }`;
496
476
  __decorate([n$1({
497
477
  attribute: "return-value"
498
478
  })], M3eDialogActionElement.prototype, "returnValue", void 0);
@@ -938,13 +918,7 @@ let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends Event
938
918
  this._content.scrollTop = 0;
939
919
  const focusable = this.querySelector("[autofocus]");
940
920
  if (focusable) {
941
- if (!prefersReducedMotion()) {
942
- this._base.addEventListener("transitionend", () => focusable.focus(), {
943
- once: true
944
- });
945
- } else {
946
- focusable.focus();
947
- }
921
+ focusWhenReady(focusable);
948
922
  }
949
923
  this.dispatchEvent(new Event("opened"));
950
924
  }
@@ -1065,26 +1039,15 @@ __decorate([n$1({
1065
1039
  })], M3eDialogElement.prototype, "closeLabel", void 0);
1066
1040
  M3eDialogElement = M3eDialogElement_1 = __decorate([t$2("m3e-dialog")], M3eDialogElement);
1067
1041
 
1068
- var _M3eDialogTriggerElement_clickHandler;
1069
1042
  /**
1070
1043
  * An element, nested within a clickable element, used to open a dialog.
1071
1044
  * @tag m3e-dialog-trigger
1072
1045
  */
1073
- let M3eDialogTriggerElement = class M3eDialogTriggerElement extends HtmlFor(AttachInternals(LitElement)) {
1074
- constructor() {
1075
- super(...arguments);
1076
- /** @private */
1077
- _M3eDialogTriggerElement_clickHandler.set(this, e => {
1078
- if (!e.defaultPrevented && this.control instanceof M3eDialogElement) {
1079
- this.control.show();
1080
- }
1081
- });
1082
- }
1046
+ let M3eDialogTriggerElement = class M3eDialogTriggerElement extends HtmlFor(ActionElementBase) {
1083
1047
  /** @inheritdoc */
1084
1048
  connectedCallback() {
1085
1049
  super.connectedCallback();
1086
1050
  if (this.parentElement) {
1087
- this.parentElement.addEventListener("click", __classPrivateFieldGet(this, _M3eDialogTriggerElement_clickHandler, "f"));
1088
1051
  this.parentElement.ariaHasPopup = "dialog";
1089
1052
  }
1090
1053
  }
@@ -1092,18 +1055,16 @@ let M3eDialogTriggerElement = class M3eDialogTriggerElement extends HtmlFor(Atta
1092
1055
  disconnectedCallback() {
1093
1056
  super.disconnectedCallback();
1094
1057
  if (this.parentElement) {
1095
- this.parentElement.removeEventListener("click", __classPrivateFieldGet(this, _M3eDialogTriggerElement_clickHandler, "f"));
1096
1058
  this.parentElement.ariaHasPopup = null;
1097
1059
  }
1098
1060
  }
1099
1061
  /** @inheritdoc */
1100
- render() {
1101
- return html`<slot></slot>`;
1062
+ _onClick() {
1063
+ if (this.control instanceof M3eDialogElement) {
1064
+ this.control.show();
1065
+ }
1102
1066
  }
1103
1067
  };
1104
- _M3eDialogTriggerElement_clickHandler = new WeakMap();
1105
- /** The styles of the element. */
1106
- M3eDialogTriggerElement.styles = css`:host { display: contents; }`;
1107
1068
  M3eDialogTriggerElement = __decorate([t$2("m3e-dialog-trigger")], M3eDialogTriggerElement);
1108
1069
 
1109
1070
  export { M3eDialogActionElement, M3eDialogElement, M3eDialogTriggerElement };