@stacksjs/components 0.2.527 → 0.2.529
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/dist/utils/overlays.d.ts +5 -0
- package/package.json +3 -3
- package/src/ui/dialog/README.md +6 -0
- package/src/utils/overlays.ts +13 -1
package/dist/utils/overlays.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare function openOverlays(): string[];
|
|
|
26
26
|
* onDestroy(() => closeOverlay('workout-panel'))
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
+
* An overlay the app lifts into `<body>` itself (a bottom sheet) passes that
|
|
30
|
+
* element as `root`: the rest of the page goes inert behind it, and stays
|
|
31
|
+
* inert while a dialog opened from its content is on top.
|
|
32
|
+
*
|
|
29
33
|
* Every call is a no-op where there is no runtime (server rendering, tests
|
|
30
34
|
* without a DOM), so shared code can call them unguarded.
|
|
31
35
|
*
|
|
@@ -36,6 +40,7 @@ export declare function openOverlays(): string[];
|
|
|
36
40
|
export declare interface OverlayOptions {
|
|
37
41
|
panel: Element | string | null | (() => Element | null)
|
|
38
42
|
root?: Element | null
|
|
43
|
+
zIndex?: number
|
|
39
44
|
onEscape?: (() => void) | null
|
|
40
45
|
initialFocus?: HTMLElement | null | (() => HTMLElement | null)
|
|
41
46
|
opener?: Element | null
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.529",
|
|
5
5
|
"description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@iconify-json/f7": "^1.2.2",
|
|
79
79
|
"@stacksjs/ts-css": "^0.3.11",
|
|
80
|
-
"@stacksjs/stx": "0.2.
|
|
81
|
-
"bun-plugin-stx": "0.2.
|
|
80
|
+
"@stacksjs/stx": "0.2.529",
|
|
81
|
+
"bun-plugin-stx": "0.2.529",
|
|
82
82
|
"ts-syntax-highlighter": "^0.2.17",
|
|
83
83
|
"ts-video-player": "^0.1.9"
|
|
84
84
|
},
|
package/src/ui/dialog/README.md
CHANGED
|
@@ -55,6 +55,12 @@ function openModal() {
|
|
|
55
55
|
|
|
56
56
|
An open dialog goes on the page's overlay stack (`window.stx.overlays`), shared with `Drawer`, `CommandPalette`, `stxConfirm`/`stxAlert`, the library's menus and popovers, and the app's own overlays (`openOverlay` / `closeOverlay` from `@stacksjs/components`). The topmost layer answers Escape and owns Tab, so one Escape closes a menu inside a dialog, or the inner of two dialogs, and nothing else. The page stays locked from the first open to the last close, and focus returns to whatever opened each one.
|
|
57
57
|
|
|
58
|
+
An overlay the app lifts into `<body>` itself, such as a bottom sheet, passes that element as `root` (import the functions from `@stacksjs/components/overlays` in a `<script client>`). The rest of the page goes inert behind it, and stays inert while a dialog opened from its content is on top. Give it `zIndex` as well and the stack sets the root's z-index to that base plus its place in the stack, so a sheet opened over another draws above it wherever the two sit in the document:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
openOverlay('my-sheet', { panel: () => panelEl, root: sheetEl, zIndex: 70, onEscape: close })
|
|
62
|
+
```
|
|
63
|
+
|
|
58
64
|
### DialogBackdrop
|
|
59
65
|
| Prop | Type | Default | Description |
|
|
60
66
|
|------|------|---------|-------------|
|
package/src/utils/overlays.ts
CHANGED
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
* onDestroy(() => closeOverlay('workout-panel'))
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
+
* An overlay the app lifts into `<body>` itself (a bottom sheet) passes that
|
|
22
|
+
* element as `root`: the rest of the page goes inert behind it, and stays
|
|
23
|
+
* inert while a dialog opened from its content is on top.
|
|
24
|
+
*
|
|
21
25
|
* Every call is a no-op where there is no runtime (server rendering, tests
|
|
22
26
|
* without a DOM), so shared code can call them unguarded.
|
|
23
27
|
*
|
|
@@ -29,8 +33,16 @@
|
|
|
29
33
|
export interface OverlayOptions {
|
|
30
34
|
/** Where focus is kept while this overlay is on top: an element, a selector, or a function returning one. A selector or function is looked up each time, since the panel may not be rendered yet when the overlay opens. */
|
|
31
35
|
panel: Element | string | null | (() => Element | null)
|
|
32
|
-
/** The overlay's outermost element, when it is not the panel. An overlay that is a direct child of `<body>` makes the rest of the page inert while it is on top. */
|
|
36
|
+
/** The overlay's outermost element, when it is not the panel. An overlay that is a direct child of `<body>` makes the rest of the page inert while it, or an overlay opened inside it, is on top. */
|
|
33
37
|
root?: Element | null
|
|
38
|
+
/**
|
|
39
|
+
* A base z-index for `root`. While the overlay is open its z-index is this
|
|
40
|
+
* plus its place in the stack, so an overlay opened later draws over one
|
|
41
|
+
* opened before it wherever the two sit in the document. Kept after it
|
|
42
|
+
* closes, so a closing transition stays above what it was over. Leave it
|
|
43
|
+
* out to keep the stylesheet's.
|
|
44
|
+
*/
|
|
45
|
+
zIndex?: number
|
|
34
46
|
/** Escape while this overlay is on top. Leave it out for one that must be answered rather than dismissed. */
|
|
35
47
|
onEscape?: (() => void) | null
|
|
36
48
|
/** Where focus goes first. Defaults to `[autofocus]`, then the first focusable element, then the panel. */
|