jsl-ui 10.4.2 → 10.4.4
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/docs/OverlayComponent.md +1 -0
- package/lib/components/overlay/OverlayComponent.d.ts +7 -1
- package/lib/components/overlay/OverlayComponent.js +48 -31
- package/lib/components/overlay/overlay.css +2 -5
- package/lib/components/select/SelectComponent.js +4 -4
- package/lib/core/helper.js +11 -6
- package/lib/grid.css +3507 -834
- package/lib/index.css +2 -21
- package/lib/index.css.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/ui/auto.suggest.js +1 -1
- package/lib/ui/date.picker/mode/base-mode.js +1 -1
- package/package.json +1 -1
package/docs/OverlayComponent.md
CHANGED
|
@@ -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
|
|
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
|
-
|
|
19
|
-
this.
|
|
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.
|
|
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.
|
|
36
|
+
onRemove() { var _a; (_a = this.ref) === null || _a === void 0 ? void 0 : _a.destroy(); this.ref = undefined; }
|
|
26
37
|
close() {
|
|
27
|
-
|
|
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
|
-
(
|
|
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 {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
|
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
|
|
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
|
-
((
|
|
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
|
-
(
|
|
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
|
-
(
|
|
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;
|
package/lib/core/helper.js
CHANGED
|
@@ -5,16 +5,21 @@ export class helper {
|
|
|
5
5
|
static newGuid() {
|
|
6
6
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { const r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); });
|
|
7
7
|
}
|
|
8
|
+
// same layout as the C# Saftware.Core.Helper.NewSeqGuid(), so guids from both sides sort sequentially (SQL Server / SqlGuid order):
|
|
9
|
+
// last 12 hex digits = days since 2020-01-01 UTC (4 digits) + UTC milliseconds of the day * 22 (8 digits)
|
|
8
10
|
static newSeqGuid() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const msPerDay = 86400000;
|
|
12
|
+
const sinceBase = new Date().getTime() - Date.UTC(2020, 0, 1);
|
|
13
|
+
let days = (Math.floor(sinceBase / msPerDay) & 0xffff).toString(16);
|
|
14
|
+
while (days.length < 4) {
|
|
15
|
+
days = "0" + days;
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
let timeOfDay = ((sinceBase % msPerDay) * 22).toString(16);
|
|
18
|
+
while (timeOfDay.length < 8) {
|
|
19
|
+
timeOfDay = "0" + timeOfDay;
|
|
15
20
|
}
|
|
16
21
|
return "xxxxxxxx-xxxx-4xxx-yxxx-".replace(/[xy]/g, function (c) { var r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); })
|
|
17
|
-
+
|
|
22
|
+
+ days + timeOfDay;
|
|
18
23
|
}
|
|
19
24
|
static newDomGuid() {
|
|
20
25
|
return "axxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { const r = helper.random() * 16 | 0, v = c == "x" ? r : r & 0x3 | 0x8; return v.toString(16); });
|