jsl-ui 10.4.1 → 10.4.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.
@@ -9,4 +9,5 @@ const panel = OverlayComponent.show({
9
9
  ```
10
10
 
11
11
  - `show()` owns mounting and cleanup; `panel.close()` closes it. The overlay is modal and defaults to a left-side panel.
12
+ - It is built on the same fixed-position, z-index based technique as `DialogComponent` (not a native `<dialog>`/top layer), so dropdowns and date pickers appended to `document.body` render above it and stacking with dialogs works.
12
13
  - Escape and backdrop clicks close by default. Return `false` from `onClose` to veto closing.
@@ -15,11 +15,16 @@ export interface IOverlayComponentOptions {
15
15
  ariaLabel?: string;
16
16
  closeButtonLabel?: string;
17
17
  }
18
+ /**
19
+ * Side/top panel. Uses the same technique as DialogComponent: a fixed-position div with a z-index
20
+ * (managed by JSLDialog) instead of a native <dialog>/showModal(), so it does not enter the browser's
21
+ * top layer and popups that are appended to document.body (date picker, select, ...) render above it.
22
+ */
18
23
  export declare class OverlayComponent implements IJSLComponent {
19
24
  State: {
20
25
  closed: boolean;
21
26
  };
22
- private dom;
27
+ private ref;
23
28
  private renderer;
24
29
  private disposeHost?;
25
30
  private options;
@@ -29,5 +34,6 @@ export declare class OverlayComponent implements IJSLComponent {
29
34
  onCreate(node: IJSLVNode): void;
30
35
  onRemove(): void;
31
36
  close(): void;
37
+ private handleClose;
32
38
  render(): IJSLVNode;
33
39
  }
@@ -1,5 +1,11 @@
1
1
  import "./overlay.css";
2
2
  import { JSLRender } from "jsl-render";
3
+ import { Dialog } from "../../ui/dialog";
4
+ /**
5
+ * Side/top panel. Uses the same technique as DialogComponent: a fixed-position div with a z-index
6
+ * (managed by JSLDialog) instead of a native <dialog>/showModal(), so it does not enter the browser's
7
+ * top layer and popups that are appended to document.body (date picker, select, ...) render above it.
8
+ */
3
9
  export class OverlayComponent {
4
10
  static show(options) {
5
11
  const container = document.createElement("div");
@@ -15,52 +21,63 @@ export class OverlayComponent {
15
21
  }
16
22
  onInit(renderer) { this.renderer = renderer; }
17
23
  onCreate(node) {
18
- var _a, _b;
19
- this.dom = node.dom;
24
+ // Initialize first so close() can safely use the reference from onOpen.
25
+ this.ref = Dialog(node.dom, {
26
+ autoOpen: false, modal: true,
27
+ closeOnEscape: this.options.closeOnEscape,
28
+ closeOnOverlayClick: this.options.closeOnOverlayClick,
29
+ onOpen: this.options.onOpen,
30
+ onClose: () => this.handleClose()
31
+ });
20
32
  if (!this.State.closed) {
21
- this.dom.showModal();
22
- (_b = (_a = this.options).onOpen) === null || _b === void 0 ? void 0 : _b.call(_a);
33
+ this.ref.open();
23
34
  }
24
35
  }
25
- onRemove() { var _a; (_a = this.dom) === null || _a === void 0 ? void 0 : _a.close(); this.dom = undefined; }
36
+ onRemove() { var _a; (_a = this.ref) === null || _a === void 0 ? void 0 : _a.destroy(); this.ref = undefined; }
26
37
  close() {
27
- var _a, _b, _c, _d;
28
- if (this.State.closed || ((_b = (_a = this.options).onClose) === null || _b === void 0 ? void 0 : _b.call(_a)) === false) {
38
+ if (this.State.closed) {
29
39
  return;
30
40
  }
41
+ if (this.ref) {
42
+ this.ref.close();
43
+ }
44
+ else {
45
+ this.handleClose();
46
+ }
47
+ }
48
+ handleClose() {
49
+ var _a, _b, _c;
50
+ if (this.State.closed || ((_b = (_a = this.options).onClose) === null || _b === void 0 ? void 0 : _b.call(_a)) === false) {
51
+ return false;
52
+ }
31
53
  this.State.closed = true;
32
- (_c = this.dom) === null || _c === void 0 ? void 0 : _c.close();
33
54
  if (this.disposeHost) {
34
55
  this.disposeHost();
35
56
  }
36
57
  else {
37
- (_d = this.renderer) === null || _d === void 0 ? void 0 : _d.refresh();
58
+ (_c = this.renderer) === null || _c === void 0 ? void 0 : _c.refresh();
38
59
  }
39
60
  }
40
61
  render() {
41
62
  var _a, _b, _c, _d, _e;
42
- return { tag: "dialog", attr: { class: "jsl-overlay-overlay", hidden: this.State.closed ? "hidden" : undefined,
43
- "aria-label": (_a = this.options.ariaLabel) !== null && _a !== void 0 ? _a : "Panel",
44
- keydown: (e) => { if (e.key === "Escape") {
45
- e.preventDefault();
46
- e.stopPropagation();
47
- if (this.options.closeOnEscape) {
48
- this.close();
49
- }
50
- } return false; },
51
- cancel: (e) => { e.preventDefault(); if (this.options.closeOnEscape) {
52
- this.close();
53
- } return false; },
54
- click: (e) => { if (e.target === e.currentTarget && this.options.closeOnOverlayClick) {
55
- const r = this.dom.getBoundingClientRect();
56
- if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) {
57
- this.close();
58
- }
59
- } return false; }
60
- }, children: [{ tag: "div", attr: { class: "overl-body overl-body-" + this.options.direction + (this.options.animate ? " overl-animate" : "") + " " + ((_b = this.options.class) !== null && _b !== void 0 ? _b : ""),
61
- style: "--jsl-overlay-size:" + ((_c = this.options.size) !== null && _c !== void 0 ? _c : "28rem") + ";" + ((_d = this.options.style) !== null && _d !== void 0 ? _d : "") }, children: [
62
- { tag: "div", attr: { class: "overl-header" }, children: this.options.showCloseButton ? [{ tag: "button", content: "×", attr: { type: "button", class: "overl-close-btn", "aria-label": (_e = this.options.closeButtonLabel) !== null && _e !== void 0 ? _e : "Close panel", click: () => { this.close(); return false; } } }] : [] },
63
+ return {
64
+ tag: "div", attr: { class: "jsl-overlay-overlay" }, children: [{
65
+ tag: "div", attr: {
66
+ class: "overl-body overl-body-" + this.options.direction + (this.options.animate ? " overl-animate" : "") + " " + ((_a = this.options.class) !== null && _a !== void 0 ? _a : ""),
67
+ role: "dialog", "aria-label": (_b = this.options.ariaLabel) !== null && _b !== void 0 ? _b : "Panel",
68
+ style: "--jsl-overlay-size:" + ((_c = this.options.size) !== null && _c !== void 0 ? _c : "28rem") + ";" + ((_d = this.options.style) !== null && _d !== void 0 ? _d : "")
69
+ }, children: [
70
+ {
71
+ tag: "div", attr: { class: "overl-header" }, children: this.options.showCloseButton ? [{
72
+ tag: "button", content: "×", attr: {
73
+ type: "button", class: "overl-close-btn", "aria-label": (_e = this.options.closeButtonLabel) !== null && _e !== void 0 ? _e : "Close panel",
74
+ click: () => { this.close(); return false; }
75
+ }
76
+ }] : []
77
+ },
63
78
  { tag: "div", attr: { class: "overl-content" }, children: [typeof this.options.content === "string" ? { tag: "div", content: this.options.content } : this.options.content] }
64
- ] }] };
79
+ ]
80
+ }]
81
+ };
65
82
  }
66
83
  }
@@ -1,8 +1,5 @@
1
1
  @import "../../ui/theme.css";
2
- .jsl-overlay-overlay { position: fixed; inset: 0; margin: 0; padding: 0; border: 0; background: transparent; color: var(--jsl-color-text); max-width: 100vw; max-height: 100dvh; overflow: visible; width: fit-content; height: fit-content; font: inherit; }
3
- .jsl-overlay-overlay:has(.overl-body-top) { width: 100%; }
4
- .jsl-overlay-overlay::backdrop { background: var(--jsl-color-overlay); }
5
- .jsl-overlay-overlay[hidden] { display: none; }
2
+ .jsl-overlay-overlay { position: fixed; inset: 0; z-index: var(--jsl-dialog-z-index, 2001); background: var(--jsl-dialog-backdrop, var(--jsl-color-overlay)); color: var(--jsl-color-text); font: inherit; }
6
3
  .overl-body { box-sizing: border-box; display: flex; flex-direction: column; overflow: auto; background: var(--jsl-color-surface); box-shadow: var(--jsl-shadow-dialog); }
7
4
  .overl-body-left { width: var(--jsl-overlay-size); max-width: 100vw; height: 100dvh; border-radius: 0 .75rem .75rem 0; }
8
5
  .overl-body-top { height: var(--jsl-overlay-size); max-height: 100dvh; width: 100vw; border-radius: 0 0 .75rem .75rem; }
@@ -15,4 +12,4 @@
15
12
  .overl-body-top.overl-animate { animation: jsl-panel-top .18s ease-out; }
16
13
  @keyframes jsl-panel-left { from { transform: translateX(-100%); } }
17
14
  @keyframes jsl-panel-top { from { transform: translateY(-100%); } }
18
- @media (prefers-reduced-motion: reduce) { .overl-animate { animation: none !important; } }
15
+ @media (prefers-reduced-motion: reduce) { .overl-animate { animation: none !important; } }
package/lib/index.css CHANGED
@@ -3820,31 +3820,12 @@ textarea.jsl-input {
3820
3820
  }
3821
3821
 
3822
3822
  .jsl-overlay-overlay {
3823
+ z-index: var(--jsl-dialog-z-index, 2001);
3824
+ background: var(--jsl-dialog-backdrop, var(--jsl-color-overlay));
3823
3825
  color: var(--jsl-color-text);
3824
- width: fit-content;
3825
- max-width: 100vw;
3826
- height: fit-content;
3827
- max-height: 100dvh;
3828
3826
  font: inherit;
3829
- background: none;
3830
- border: 0;
3831
- margin: 0;
3832
- padding: 0;
3833
3827
  position: fixed;
3834
3828
  inset: 0;
3835
- overflow: visible;
3836
- }
3837
-
3838
- .jsl-overlay-overlay:has(.overl-body-top) {
3839
- width: 100%;
3840
- }
3841
-
3842
- .jsl-overlay-overlay::backdrop {
3843
- background: var(--jsl-color-overlay);
3844
- }
3845
-
3846
- .jsl-overlay-overlay[hidden] {
3847
- display: none;
3848
3829
  }
3849
3830
 
3850
3831
  .overl-body {