@gridui/overlay 1.0.0 → 1.1.1
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/README.md +15 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +3 -3
- package/dist/shared/style.d.ts +12 -0
- package/dist/styles.css +91 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
# @gridui/overlay
|
|
2
2
|
|
|
3
|
-
Core family. Public API: `OverlayOpen`, `RetainedLayer`, `RetainedLayerProps`, `useOverlayState`.
|
|
3
|
+
Core family. Public API: `OverlayOpen`, `RetainedLayer`, `RetainedLayerProps`, `useOverlayState`, `overlaySurfaceStyles`, `overlayBackdropStyles`.
|
|
4
4
|
|
|
5
5
|
Import components from `@gridui/overlay` and load `@gridui/overlay/styles.css` after Theme.
|
|
6
6
|
Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
|
|
7
7
|
|
|
8
8
|
See [component ownership](../../docs/component-ownership.md) and [release history](.changeset/history/).
|
|
9
|
+
|
|
10
|
+
## Surface presentation
|
|
11
|
+
|
|
12
|
+
`overlaySurfaceStyles({ kind })` shares the surface border, colors, motion, and
|
|
13
|
+
reduced-motion behavior. `kind` is `popup` (default), `tooltip`, or `dialog`.
|
|
14
|
+
`overlayBackdropStyles({ pace })` shares backdrop fades at `normal` (default)
|
|
15
|
+
or `deliberate` pace. Load this stylesheet before the consuming family.
|
|
16
|
+
|
|
17
|
+
Each family maps its own positioning origin to `--gridui-overlay-origin`.
|
|
18
|
+
Popup motion follows `data-side`; `data-side="none"` disables surface motion for
|
|
19
|
+
item-aligned Select. Open/closed and Tooltip's instant/delayed open states are
|
|
20
|
+
supported. Families keep dimensions, stacking, positioning, portals, focus,
|
|
21
|
+
and dismissal. Drawer retains its directional panel motion and uses only the
|
|
22
|
+
shared backdrop. Theme continues to own motion tokens and keyframes.
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@
|
|
|
7
7
|
export type { RetainedLayerProps } from "./retained-layer/retained-layer";
|
|
8
8
|
export { OverlayOpen } from "./retained-layer/retained-layer";
|
|
9
9
|
export { RetainedLayer } from "./retained-layer/retained-layer";
|
|
10
|
+
export { overlayBackdropStyles, overlaySurfaceStyles } from "./shared/style";
|
|
10
11
|
export { useOverlayState } from "./shared/use-overlay-state";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,28 @@ var RetainedLayer = (props) => {
|
|
|
14
14
|
);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/shared/style.ts
|
|
18
|
+
import { cva } from "class-variance-authority";
|
|
19
|
+
var overlaySurfaceStyles = cva("gridui-overlay-surface border border-solid border-border bg-background text-foreground", {
|
|
20
|
+
variants: {
|
|
21
|
+
kind: {
|
|
22
|
+
popup: "gridui-overlay-floating rounded-control",
|
|
23
|
+
tooltip: "gridui-overlay-tooltip rounded-control",
|
|
24
|
+
dialog: "gridui-overlay-dialog"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: { kind: "popup" }
|
|
28
|
+
});
|
|
29
|
+
var overlayBackdropStyles = cva("gridui-overlay-backdrop", {
|
|
30
|
+
variants: {
|
|
31
|
+
pace: {
|
|
32
|
+
normal: null,
|
|
33
|
+
deliberate: "gridui-overlay-backdrop-deliberate"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: { pace: "normal" }
|
|
37
|
+
});
|
|
38
|
+
|
|
17
39
|
// src/shared/use-overlay-state.ts
|
|
18
40
|
import { useState } from "react";
|
|
19
41
|
var useOverlayState = (options) => {
|
|
@@ -34,6 +56,8 @@ var useOverlayState = (options) => {
|
|
|
34
56
|
export {
|
|
35
57
|
OverlayOpen,
|
|
36
58
|
RetainedLayer,
|
|
59
|
+
overlayBackdropStyles,
|
|
60
|
+
overlaySurfaceStyles,
|
|
37
61
|
useOverlayState
|
|
38
62
|
};
|
|
39
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/retained-layer/retained-layer.tsx", "../src/shared/use-overlay-state.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Overlay\n * @namespace RetainedLayer\n * @description Retained Layer\n */\n\nimport { Activity, createContext, type FC, type ReactNode, useContext } from \"react\";\n\nexport const OverlayOpen = createContext(false);\n\nexport type RetainedLayerProps = {\n readonly children: ReactNode;\n};\n\nexport const RetainedLayer: FC<RetainedLayerProps> = (props: RetainedLayerProps) => {\n const { children } = props;\n const open = useContext(OverlayOpen);\n return (<Activity\n mode={!open ? \"hidden\" : \"visible\"}\n >\n {children}\n </Activity>);\n};\n", "/**\n * @author WMXPY\n * @package Overlay\n * @namespace Shared\n * @description Use Overlay State\n */\n\nimport { useState } from \"react\";\n\ntype OverlayStateOptions = {\n readonly open?: boolean | undefined;\n readonly defaultOpen?: boolean | undefined;\n readonly onOpenChange?: ((open: boolean) => void) | undefined;\n};\n\nexport const useOverlayState = (options: OverlayStateOptions) => {\n const [\n localOpen,\n setLocalOpen,\n ] = useState(options.defaultOpen ?? false);\n return {\n open: options.open ?? localOpen,\n onOpenChange: (open: boolean): void => {\n if (options.open === undefined) {\n setLocalOpen(open);\n }\n options.onOpenChange?.(open);\n },\n };\n};\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,UAAU,eAAwC,kBAAkB;AAWjE;AATL,IAAM,cAAc,cAAc,KAAK;AAMvC,IAAM,gBAAwC,CAAC,UAA8B;AAChF,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,OAAO,WAAW,WAAW;AACnC,SAAQ;AAAA,IAAC;AAAA;AAAA,MACL,MAAM,CAAC,OAAO,WAAW;AAAA,MAExB;AAAA;AAAA,EACL;AACJ;;;AChBA,SAAS,gBAAgB;AAQlB,IAAM,kBAAkB,CAAC,YAAiC;AAC7D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,QAAQ,eAAe,KAAK;AACzC,SAAO;AAAA,IACH,MAAM,QAAQ,QAAQ;AAAA,IACtB,cAAc,CAAC,SAAwB;AACnC,UAAI,QAAQ,SAAS,QAAW;AAC5B,qBAAa,IAAI;AAAA,MACrB;AACA,cAAQ,eAAe,IAAI;AAAA,IAC/B;AAAA,EACJ;AACJ;",
|
|
3
|
+
"sources": ["../src/retained-layer/retained-layer.tsx", "../src/shared/style.ts", "../src/shared/use-overlay-state.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Overlay\n * @namespace RetainedLayer\n * @description Retained Layer\n */\n\nimport { Activity, createContext, type FC, type ReactNode, useContext } from \"react\";\n\nexport const OverlayOpen = createContext(false);\n\nexport type RetainedLayerProps = {\n readonly children: ReactNode;\n};\n\nexport const RetainedLayer: FC<RetainedLayerProps> = (props: RetainedLayerProps) => {\n const { children } = props;\n const open = useContext(OverlayOpen);\n return (<Activity\n mode={!open ? \"hidden\" : \"visible\"}\n >\n {children}\n </Activity>);\n};\n", "/**\n * @author WMXPY\n * @package Overlay\n * @namespace Shared\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const overlaySurfaceStyles = cva(\"gridui-overlay-surface border border-solid border-border bg-background text-foreground\", {\n variants: {\n kind: {\n popup: \"gridui-overlay-floating rounded-control\",\n tooltip: \"gridui-overlay-tooltip rounded-control\",\n dialog: \"gridui-overlay-dialog\",\n },\n },\n defaultVariants: { kind: \"popup\" },\n});\n\nexport const overlayBackdropStyles = cva(\"gridui-overlay-backdrop\", {\n variants: {\n pace: {\n normal: null,\n deliberate: \"gridui-overlay-backdrop-deliberate\",\n },\n },\n defaultVariants: { pace: \"normal\" },\n});\n", "/**\n * @author WMXPY\n * @package Overlay\n * @namespace Shared\n * @description Use Overlay State\n */\n\nimport { useState } from \"react\";\n\ntype OverlayStateOptions = {\n readonly open?: boolean | undefined;\n readonly defaultOpen?: boolean | undefined;\n readonly onOpenChange?: ((open: boolean) => void) | undefined;\n};\n\nexport const useOverlayState = (options: OverlayStateOptions) => {\n const [\n localOpen,\n setLocalOpen,\n ] = useState(options.defaultOpen ?? false);\n return {\n open: options.open ?? localOpen,\n onOpenChange: (open: boolean): void => {\n if (options.open === undefined) {\n setLocalOpen(open);\n }\n options.onOpenChange?.(open);\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU,eAAwC,kBAAkB;AAWjE;AATL,IAAM,cAAc,cAAc,KAAK;AAMvC,IAAM,gBAAwC,CAAC,UAA8B;AAChF,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,OAAO,WAAW,WAAW;AACnC,SAAQ;AAAA,IAAC;AAAA;AAAA,MACL,MAAM,CAAC,OAAO,WAAW;AAAA,MAExB;AAAA;AAAA,EACL;AACJ;;;AChBA,SAAS,WAAW;AAEb,IAAM,uBAAuB,IAAI,0FAA0F;AAAA,EAC9H,UAAU;AAAA,IACN,MAAM;AAAA,MACF,OAAO;AAAA,MACP,SAAS;AAAA,MACT,QAAQ;AAAA,IACZ;AAAA,EACJ;AAAA,EACA,iBAAiB,EAAE,MAAM,QAAQ;AACrC,CAAC;AAEM,IAAM,wBAAwB,IAAI,2BAA2B;AAAA,EAChE,UAAU;AAAA,IACN,MAAM;AAAA,MACF,QAAQ;AAAA,MACR,YAAY;AAAA,IAChB;AAAA,EACJ;AAAA,EACA,iBAAiB,EAAE,MAAM,SAAS;AACtC,CAAC;;;ACrBD,SAAS,gBAAgB;AAQlB,IAAM,kBAAkB,CAAC,YAAiC;AAC7D,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,QAAQ,eAAe,KAAK;AACzC,SAAO;AAAA,IACH,MAAM,QAAQ,QAAQ;AAAA,IACtB,cAAc,CAAC,SAAwB;AACnC,UAAI,QAAQ,SAAS,QAAW;AAC5B,qBAAa,IAAI;AAAA,MACrB;AACA,cAAQ,eAAe,IAAI;AAAA,IAC/B;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Overlay
|
|
4
|
+
* @namespace Shared
|
|
5
|
+
* @description Style
|
|
6
|
+
*/
|
|
7
|
+
export declare const overlaySurfaceStyles: (props?: ({
|
|
8
|
+
kind?: "popup" | "tooltip" | "dialog" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export declare const overlayBackdropStyles: (props?: ({
|
|
11
|
+
pace?: "normal" | "deliberate" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
package/dist/styles.css
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties;
|
|
2
3
|
@layer theme, base, components, utilities;
|
|
3
4
|
@layer utilities {
|
|
4
5
|
.visible {
|
|
@@ -7,4 +8,94 @@
|
|
|
7
8
|
.hidden {
|
|
8
9
|
display: none;
|
|
9
10
|
}
|
|
11
|
+
.rounded-control {
|
|
12
|
+
border-radius: var(--gridui-control-radius);
|
|
13
|
+
}
|
|
14
|
+
.border {
|
|
15
|
+
border-style: var(--tw-border-style);
|
|
16
|
+
border-width: 1px;
|
|
17
|
+
}
|
|
18
|
+
.border-solid {
|
|
19
|
+
--tw-border-style: solid;
|
|
20
|
+
border-style: solid;
|
|
21
|
+
}
|
|
22
|
+
.border-border {
|
|
23
|
+
border-color: var(--gridui-border);
|
|
24
|
+
}
|
|
25
|
+
.bg-background {
|
|
26
|
+
background-color: var(--gridui-background);
|
|
27
|
+
}
|
|
28
|
+
.text-foreground {
|
|
29
|
+
color: var(--gridui-foreground);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
@layer components {
|
|
33
|
+
.gridui-overlay-surface {
|
|
34
|
+
--gridui-surface-offset-x: 0px;
|
|
35
|
+
--gridui-surface-offset-y: 0px;
|
|
36
|
+
--gridui-overlay-enter-duration: var(--gridui-motion-duration-normal);
|
|
37
|
+
--gridui-overlay-fill-mode: both;
|
|
38
|
+
transform-origin: var(--gridui-overlay-origin, center);
|
|
39
|
+
}
|
|
40
|
+
.gridui-overlay-dialog {
|
|
41
|
+
--gridui-overlay-fill-mode: none;
|
|
42
|
+
transform-origin: center;
|
|
43
|
+
}
|
|
44
|
+
.gridui-overlay-tooltip {
|
|
45
|
+
--gridui-overlay-enter-duration: var(--gridui-motion-duration-quick);
|
|
46
|
+
}
|
|
47
|
+
.gridui-overlay-floating[data-side="bottom"] {
|
|
48
|
+
--gridui-surface-offset-y: calc(-1 * var(--gridui-motion-distance));
|
|
49
|
+
}
|
|
50
|
+
.gridui-overlay-floating[data-side="top"] {
|
|
51
|
+
--gridui-surface-offset-y: var(--gridui-motion-distance);
|
|
52
|
+
}
|
|
53
|
+
.gridui-overlay-floating[data-side="left"] {
|
|
54
|
+
--gridui-surface-offset-x: var(--gridui-motion-distance);
|
|
55
|
+
}
|
|
56
|
+
.gridui-overlay-floating[data-side="right"] {
|
|
57
|
+
--gridui-surface-offset-x: calc(-1 * var(--gridui-motion-distance));
|
|
58
|
+
}
|
|
59
|
+
.gridui-overlay-surface[data-state="closed"] {
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
.gridui-overlay-surface:not([data-side="none"]):is([data-state="open"], [data-state="delayed-open"], [data-state="instant-open"]) {
|
|
63
|
+
animation: gridui-surface-enter var(--gridui-overlay-enter-duration) var(--gridui-motion-ease-out) var(--gridui-overlay-fill-mode);
|
|
64
|
+
}
|
|
65
|
+
.gridui-overlay-surface:not([data-side="none"])[data-state="closed"] {
|
|
66
|
+
animation: gridui-surface-exit var(--gridui-motion-duration-quick) var(--gridui-motion-ease-in) var(--gridui-overlay-fill-mode);
|
|
67
|
+
}
|
|
68
|
+
.gridui-overlay-backdrop {
|
|
69
|
+
--gridui-overlay-enter-duration: var(--gridui-motion-duration-normal);
|
|
70
|
+
--gridui-overlay-exit-duration: var(--gridui-motion-duration-quick);
|
|
71
|
+
--gridui-overlay-fill-mode: none;
|
|
72
|
+
}
|
|
73
|
+
.gridui-overlay-backdrop-deliberate {
|
|
74
|
+
--gridui-overlay-enter-duration: var(--gridui-motion-duration-deliberate);
|
|
75
|
+
--gridui-overlay-exit-duration: var(--gridui-motion-duration-normal);
|
|
76
|
+
--gridui-overlay-fill-mode: both;
|
|
77
|
+
}
|
|
78
|
+
.gridui-overlay-backdrop[data-state="open"] {
|
|
79
|
+
animation: gridui-fade-enter var(--gridui-overlay-enter-duration) var(--gridui-motion-ease-out) var(--gridui-overlay-fill-mode);
|
|
80
|
+
}
|
|
81
|
+
.gridui-overlay-backdrop[data-state="closed"] {
|
|
82
|
+
animation: gridui-fade-exit var(--gridui-overlay-exit-duration) var(--gridui-motion-ease-in) var(--gridui-overlay-fill-mode);
|
|
83
|
+
}
|
|
84
|
+
@media (prefers-reduced-motion: reduce) {
|
|
85
|
+
.gridui-overlay-surface:not([data-side="none"])[data-state], .gridui-overlay-backdrop[data-state] {
|
|
86
|
+
animation: none;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
@property --tw-border-style {
|
|
91
|
+
syntax: "*";
|
|
92
|
+
inherits: false;
|
|
93
|
+
initial-value: solid;
|
|
94
|
+
}
|
|
95
|
+
@layer properties {
|
|
96
|
+
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
97
|
+
*, ::before, ::after, ::backdrop {
|
|
98
|
+
--tw-border-style: solid;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
10
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/overlay",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "GridUI React overlay",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"react-dom": "^19.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@gridui/theme": "^2.1
|
|
29
|
+
"@gridui/theme": "^2.2.1",
|
|
30
|
+
"class-variance-authority": "0.7.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@gridui-internal/configuration": "0.0.0",
|
|
33
|
+
"@gridui-internal/configuration": "0.0.0-internal",
|
|
33
34
|
"@jest/globals": "30.5.2",
|
|
34
35
|
"@types/jest": "30.0.0",
|
|
35
|
-
"@types/node": "26.6.
|
|
36
|
+
"@types/node": "26.6.6",
|
|
36
37
|
"@types/react": "19.3.0",
|
|
37
38
|
"@types/react-dom": "19.3.0",
|
|
38
39
|
"jest": "30.5.2",
|