jsl-ui 10.4.2 → 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; } }
@@ -152,7 +152,7 @@ export class SelectComponent {
152
152
  isExpanded() { return this.expanded; }
153
153
  getListId() { return this.listId; }
154
154
  show(searchTxt) {
155
- var _a, _b, _c, _d, _e, _f;
155
+ var _a, _b, _c, _d, _e;
156
156
  if (!this.options.enabled || this.disposed || !this.dom || this.expanded) {
157
157
  return;
158
158
  }
@@ -167,7 +167,7 @@ export class SelectComponent {
167
167
  this.options.onAppend(this.dropdownArea);
168
168
  }
169
169
  else {
170
- ((_c = (_b = this.dom.closest(".jsl-dialog")) !== null && _b !== void 0 ? _b : this.dom.closest("dialog[open]")) !== null && _c !== void 0 ? _c : document.body).appendChild(this.dropdownArea);
170
+ ((_b = this.dom.closest(".jsl-dialog")) !== null && _b !== void 0 ? _b : document.body).appendChild(this.dropdownArea);
171
171
  }
172
172
  this.dropdownLimit = this.dropdownArea.getBoundingClientRect().height;
173
173
  this.dropdownComponent = new SelectDDAreaComponent(this.options, this, {
@@ -193,13 +193,13 @@ export class SelectComponent {
193
193
  if (this.options.onSearch && !searchTxt) {
194
194
  this.requestSearch("", true);
195
195
  }
196
- (_e = (_d = this.options).onOpen) === null || _e === void 0 ? void 0 : _e.call(_d);
196
+ (_d = (_c = this.options).onOpen) === null || _d === void 0 ? void 0 : _d.call(_c);
197
197
  document.addEventListener("mousedown", this.onOutsidePress, true);
198
198
  document.addEventListener("touchstart", this.onOutsidePress, true);
199
199
  document.addEventListener("focusin", this.onDocumentFocus);
200
200
  window.addEventListener("resize", this.positionDropdown);
201
201
  window.addEventListener("scroll", this.onWindowScroll, true);
202
- (_f = this.renderer) === null || _f === void 0 ? void 0 : _f.refresh();
202
+ (_e = this.renderer) === null || _e === void 0 ? void 0 : _e.refresh();
203
203
  this.updateTriggerAria();
204
204
  this.focusFrame = requestAnimationFrame(() => {
205
205
  var _a;