@greypan/web-ui 2.1.8 → 3.0.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.CN.md +47 -7
- package/README.md +54 -13
- package/dist/assets/menu-portal.js +1 -1
- package/dist/assets/menu-portal.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +121 -0
- package/dist/components/autocomplete/index.js +414 -0
- package/dist/components/autocomplete/index.js.map +1 -0
- package/dist/components/autocomplete/style.js +6 -0
- package/dist/components/autocomplete/style.js.map +1 -0
- package/dist/components/avatar/index.d.ts +0 -1
- package/dist/components/avatar/index.js +9 -9
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/back-top/index.d.ts +0 -1
- package/dist/components/back-top/index.js.map +1 -1
- package/dist/components/badge/index.d.ts +0 -1
- package/dist/components/badge/index.js +5 -5
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/button/index.d.ts +0 -1
- package/dist/components/button/index.js +8 -8
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/style.js +1 -1
- package/dist/components/button/style.js.map +1 -1
- package/dist/components/button-group/index.d.ts +0 -1
- package/dist/components/button-group/index.js.map +1 -1
- package/dist/components/checkbox/index.js +7 -5
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.js +2 -2
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/context-menu/index.js +25 -25
- package/dist/components/context-menu/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/index.js +9 -5
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/drawer/index.js +7 -7
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/dropdown/index.js +31 -30
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/dropdown-divider/index.d.ts +0 -1
- package/dist/components/dropdown-divider/index.js.map +1 -1
- package/dist/components/dropdown-header/index.d.ts +0 -1
- package/dist/components/dropdown-header/index.js.map +1 -1
- package/dist/components/dropdown-item/index.d.ts +0 -1
- package/dist/components/dropdown-item/index.js.map +1 -1
- package/dist/components/dropdown-item/style.js +1 -1
- package/dist/components/dropdown-item/style.js.map +1 -1
- package/dist/components/empty/index.d.ts +0 -1
- package/dist/components/empty/index.js +6 -6
- package/dist/components/empty/index.js.map +1 -1
- package/dist/components/icon/index.d.ts +0 -1
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +36 -35
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +24 -13
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/style.js +1 -1
- package/dist/components/input/style.js.map +1 -1
- package/dist/components/input-number/index.d.ts +2 -0
- package/dist/components/input-number/index.js +25 -12
- package/dist/components/input-number/index.js.map +1 -1
- package/dist/components/input-number/style.js +1 -1
- package/dist/components/input-number/style.js.map +1 -1
- package/dist/components/layout/index.d.ts +0 -1
- package/dist/components/layout/index.js +4 -4
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/option/index.d.ts +0 -11
- package/dist/components/option/index.js.map +1 -1
- package/dist/components/option/style.js +1 -1
- package/dist/components/option/style.js.map +1 -1
- package/dist/components/popover/index.js +12 -12
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio/index.js +8 -5
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/segmented/index.js +2 -2
- package/dist/components/segmented/index.js.map +1 -1
- package/dist/components/segmented-trigger/index.d.ts +1 -0
- package/dist/components/segmented-trigger/index.js +11 -2
- package/dist/components/segmented-trigger/index.js.map +1 -1
- package/dist/components/select/index.d.ts +0 -1
- package/dist/components/select/index.js +19 -30
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/select/style.js +1 -1
- package/dist/components/select/style.js.map +1 -1
- package/dist/components/spinner/index.d.ts +0 -1
- package/dist/components/spinner/index.js.map +1 -1
- package/dist/components/svg-draw-lines/index.d.ts +0 -1
- package/dist/components/svg-draw-lines/index.js.map +1 -1
- package/dist/components/switch/index.js +6 -6
- package/dist/components/textarea/index.js +18 -15
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/style.js +1 -1
- package/dist/components/textarea/style.js.map +1 -1
- package/dist/components/theme/index.d.ts +0 -1
- package/dist/components/theme/index.js.map +1 -1
- package/dist/components/toast/toast.js +13 -13
- package/dist/components/tooltip/index.js +13 -13
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/icons/generated/lucide-external-link.d.ts +6 -0
- package/dist/icons/generated/lucide-external-link.js +10 -0
- package/dist/icons/generated/lucide-external-link.js.map +1 -0
- package/dist/icons/generated/lucide-file-text.d.ts +6 -0
- package/dist/icons/generated/lucide-file-text.js +10 -0
- package/dist/icons/generated/lucide-file-text.js.map +1 -0
- package/dist/icons/generated/lucide-film.d.ts +6 -0
- package/dist/icons/generated/lucide-film.js +10 -0
- package/dist/icons/generated/lucide-film.js.map +1 -0
- package/dist/icons/generated/lucide-folder-open.d.ts +6 -0
- package/dist/icons/generated/lucide-folder-open.js +10 -0
- package/dist/icons/generated/lucide-folder-open.js.map +1 -0
- package/dist/icons/generated/lucide-layout-grid.d.ts +6 -0
- package/dist/icons/generated/lucide-layout-grid.js +10 -0
- package/dist/icons/generated/lucide-layout-grid.js.map +1 -0
- package/dist/icons/generated/lucide-music.d.ts +6 -0
- package/dist/icons/generated/lucide-music.js +10 -0
- package/dist/icons/generated/lucide-music.js.map +1 -0
- package/dist/icons/generated/lucide-package.d.ts +6 -0
- package/dist/icons/generated/lucide-package.js +10 -0
- package/dist/icons/generated/lucide-package.js.map +1 -0
- package/dist/icons/generated/lucide-pencil.d.ts +6 -0
- package/dist/icons/generated/lucide-pencil.js +10 -0
- package/dist/icons/generated/lucide-pencil.js.map +1 -0
- package/dist/icons/generated/lucide-refresh-cw.d.ts +6 -0
- package/dist/icons/generated/lucide-refresh-cw.js +10 -0
- package/dist/icons/generated/lucide-refresh-cw.js.map +1 -0
- package/dist/icons/generated/lucide-tags.d.ts +6 -0
- package/dist/icons/generated/lucide-tags.js +10 -0
- package/dist/icons/generated/lucide-tags.js.map +1 -0
- package/dist/icons/generated/lucide-wrench.d.ts +6 -0
- package/dist/icons/generated/lucide-wrench.js +10 -0
- package/dist/icons/generated/lucide-wrench.js.map +1 -0
- package/dist/icons/index.d.ts +11 -0
- package/dist/icons/index.js +12 -1
- package/dist/shared/menu-portal/menu-portal.js +10 -11
- package/dist/shared/menu-portal/menu-portal.js.map +1 -1
- package/dist/shared/overlay/anchored-panel.js +12 -12
- package/dist/shared/overlay/overlay.js +55 -33
- package/dist/shared/overlay/overlay.js.map +1 -1
- package/dist/shared/overlay/portal.js +25 -13
- package/dist/shared/overlay/portal.js.map +1 -1
- package/dist/shared/scroll-lock/scroll-lock.js +13 -12
- package/dist/shared/scroll-lock/scroll-lock.js.map +1 -1
- package/dist/shared/theme/overlay-root.js +3 -3
- package/dist/types/react.d.ts +15 -41
- package/dist/types/utils.d.ts +38 -4
- package/dist/types/vue.d.ts +17 -49
- package/package.json +6 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/icons/generated/lucide-pencil.ts
|
|
2
|
+
var e = {
|
|
3
|
+
body: "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4\"/>",
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=lucide-pencil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucide-pencil.js","names":[],"sources":["../../../src/icons/generated/lucide-pencil.ts"],"sourcesContent":["import type { IconifyIcon } from '@iconify/types'\n\nexport default {\n body: '<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4\"/>',\n width: 24,\n height: 24\n} satisfies IconifyIcon\n"],"mappings":";AAEA,IAAA,IAAe;CACb,MAAM;CACN,OAAO;CACP,QAAQ;AACV"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/icons/generated/lucide-refresh-cw.ts
|
|
2
|
+
var e = {
|
|
3
|
+
body: "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M3 12a9 9 0 0 1 9-9a9.75 9.75 0 0 1 6.74 2.74L21 8\"/><path d=\"M21 3v5h-5m5 4a9 9 0 0 1-9 9a9.75 9.75 0 0 1-6.74-2.74L3 16\"/><path d=\"M8 16H3v5\"/></g>",
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=lucide-refresh-cw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucide-refresh-cw.js","names":[],"sources":["../../../src/icons/generated/lucide-refresh-cw.ts"],"sourcesContent":["import type { IconifyIcon } from '@iconify/types'\n\nexport default {\n body: '<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M3 12a9 9 0 0 1 9-9a9.75 9.75 0 0 1 6.74 2.74L21 8\"/><path d=\"M21 3v5h-5m5 4a9 9 0 0 1-9 9a9.75 9.75 0 0 1-6.74-2.74L3 16\"/><path d=\"M8 16H3v5\"/></g>',\n width: 24,\n height: 24\n} satisfies IconifyIcon\n"],"mappings":";AAEA,IAAA,IAAe;CACb,MAAM;CACN,OAAO;CACP,QAAQ;AACV"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/icons/generated/lucide-tags.ts
|
|
2
|
+
var e = {
|
|
3
|
+
body: "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1zM2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193\"/><circle cx=\"10.5\" cy=\"6.5\" r=\".5\" fill=\"currentColor\"/></g>",
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=lucide-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucide-tags.js","names":[],"sources":["../../../src/icons/generated/lucide-tags.ts"],"sourcesContent":["import type { IconifyIcon } from '@iconify/types'\n\nexport default {\n body: '<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1zM2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193\"/><circle cx=\"10.5\" cy=\"6.5\" r=\".5\" fill=\"currentColor\"/></g>',\n width: 24,\n height: 24\n} satisfies IconifyIcon\n"],"mappings":";AAEA,IAAA,IAAe;CACb,MAAM;CACN,OAAO;CACP,QAAQ;AACV"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/icons/generated/lucide-wrench.ts
|
|
2
|
+
var e = {
|
|
3
|
+
body: "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z\"/>",
|
|
4
|
+
width: 24,
|
|
5
|
+
height: 24
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=lucide-wrench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lucide-wrench.js","names":[],"sources":["../../../src/icons/generated/lucide-wrench.ts"],"sourcesContent":["import type { IconifyIcon } from '@iconify/types'\n\nexport default {\n body: '<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z\"/>',\n width: 24,\n height: 24\n} satisfies IconifyIcon\n"],"mappings":";AAEA,IAAA,IAAe;CACb,MAAM;CACN,OAAO;CACP,QAAQ;AACV"}
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -38,3 +38,14 @@ export { default as lucideImage } from './generated/lucide-image';
|
|
|
38
38
|
export { default as lucideGlobe } from './generated/lucide-globe';
|
|
39
39
|
export { default as radixIconsPanelLeftMinimized } from './generated/radix-icons-panel-left-minimized';
|
|
40
40
|
export { default as oouiClose } from './generated/ooui-close';
|
|
41
|
+
export { default as lucideExternalLink } from './generated/lucide-external-link';
|
|
42
|
+
export { default as lucideFileText } from './generated/lucide-file-text';
|
|
43
|
+
export { default as lucideFilm } from './generated/lucide-film';
|
|
44
|
+
export { default as lucideFolderOpen } from './generated/lucide-folder-open';
|
|
45
|
+
export { default as lucideLayoutGrid } from './generated/lucide-layout-grid';
|
|
46
|
+
export { default as lucideMusic } from './generated/lucide-music';
|
|
47
|
+
export { default as lucidePackage } from './generated/lucide-package';
|
|
48
|
+
export { default as lucidePencil } from './generated/lucide-pencil';
|
|
49
|
+
export { default as lucideRefreshCw } from './generated/lucide-refresh-cw';
|
|
50
|
+
export { default as lucideTags } from './generated/lucide-tags';
|
|
51
|
+
export { default as lucideWrench } from './generated/lucide-wrench';
|
package/dist/icons/index.js
CHANGED
|
@@ -38,4 +38,15 @@ import I from "./generated/lucide-image.js";
|
|
|
38
38
|
import L from "./generated/lucide-globe.js";
|
|
39
39
|
import R from "./generated/radix-icons-panel-left-minimized.js";
|
|
40
40
|
import z from "./generated/ooui-close.js";
|
|
41
|
-
|
|
41
|
+
import B from "./generated/lucide-external-link.js";
|
|
42
|
+
import V from "./generated/lucide-file-text.js";
|
|
43
|
+
import H from "./generated/lucide-film.js";
|
|
44
|
+
import U from "./generated/lucide-folder-open.js";
|
|
45
|
+
import W from "./generated/lucide-layout-grid.js";
|
|
46
|
+
import G from "./generated/lucide-music.js";
|
|
47
|
+
import K from "./generated/lucide-package.js";
|
|
48
|
+
import q from "./generated/lucide-pencil.js";
|
|
49
|
+
import J from "./generated/lucide-refresh-cw.js";
|
|
50
|
+
import Y from "./generated/lucide-tags.js";
|
|
51
|
+
import X from "./generated/lucide-wrench.js";
|
|
52
|
+
export { k as heroiconsCheck16Solid, j as heroiconsXMark16Solid, w as jamCloseCircleF, r as lucideArrowDownToLine, n as lucideArrowUpToLine, P as lucideBell, T as lucideCheck, s as lucideChevronDown, i as lucideChevronLeft, a as lucideChevronRight, o as lucideChevronUp, O as lucideCircleAlert, h as lucideClipboardPaste, m as lucideCopy, y as lucideDownload, B as lucideExternalLink, f as lucideFile, V as lucideFileText, H as lucideFilm, p as lucideFolder, U as lucideFolderOpen, L as lucideGlobe, N as lucideHeart, I as lucideImage, e as lucideInbox, E as lucideInfo, W as lucideLayoutGrid, t as lucideLoaderCircle, F as lucideMail, l as lucideMinus, G as lucideMusic, K as lucidePackage, q as lucidePencil, c as lucidePlus, _ as lucidePrinter, S as lucideRedo2, J as lucideRefreshCw, C as lucideScissors, u as lucideSearch, v as lucideSettings, M as lucideStar, Y as lucideTags, g as lucideTrash2, D as lucideTriangleAlert, x as lucideUndo2, b as lucideUpload, A as lucideUser, X as lucideWrench, d as lucideX, z as oouiClose, R as radixIconsPanelLeftMinimized };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { findNearestTheme as t, findRootTheme as n } from "../theme/theme-scope.js";
|
|
1
|
+
import { resolveOverlayContainer as e } from "../overlay/portal.js";
|
|
3
2
|
//#region src/shared/menu-portal/menu-portal.ts
|
|
4
|
-
function
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = document.createElement("div");
|
|
5
|
+
r.className = `wui-menu-portal-overlay wui-floating-panel wui-glass ${t}`, r.dataset.wuiPresence = "entering";
|
|
6
|
+
let i = document.createElement("div");
|
|
7
|
+
i.className = "wui-menu-scroll";
|
|
5
8
|
let a = document.createElement("div");
|
|
6
|
-
a.className =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let s = document.createElement("div");
|
|
10
|
-
return s.className = "wui-menu-content", o.append(s), a.append(o), ((i ? t(i) : n())?.getOverlayRoot() ?? e()).appendChild(a), {
|
|
11
|
-
panel: a,
|
|
12
|
-
content: s
|
|
9
|
+
return a.className = "wui-menu-content", i.append(a), r.append(i), e(void 0, n ?? document.body, { preferRootTheme: n === void 0 }).appendChild(r), {
|
|
10
|
+
panel: r,
|
|
11
|
+
content: a
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
//#endregion
|
|
16
|
-
export {
|
|
15
|
+
export { t as createMenuPortalOverlay };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=menu-portal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-portal.js","names":[],"sources":["../../../src/shared/menu-portal/menu-portal.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"menu-portal.js","names":[],"sources":["../../../src/shared/menu-portal/menu-portal.ts"],"sourcesContent":["import { resolveOverlayContainer } from '@/shared/overlay/portal'\n\nexport interface MenuPortalOverlay {\n readonly panel: HTMLElement\n readonly content: HTMLElement\n}\n\n/**\n * 菜单浮层面板:面板直接挂到 overlay 容器(与普通 Overlay Portal 共用容器解析),\n * 样式复用容器内已注入的共享菜单样式(glass/menu-portal/overlay-motion),\n * 因此无需自建 shadow。菜单内容由 dropdown/context-menu 自行构建(menu-tree),\n * 这里只提供 panel 与 content 挂载点。\n */\nexport function createMenuPortalOverlay(className: string, target?: Element): MenuPortalOverlay {\n const panel = document.createElement('div')\n panel.className = `wui-menu-portal-overlay wui-floating-panel wui-glass ${className}`\n panel.dataset.wuiPresence = 'entering'\n const scroll = document.createElement('div')\n scroll.className = 'wui-menu-scroll'\n const content = document.createElement('div')\n content.className = 'wui-menu-content'\n scroll.append(content)\n panel.append(scroll)\n\n const container = resolveOverlayContainer(undefined, target ?? document.body, {\n preferRootTheme: target === undefined\n })\n container.appendChild(panel)\n\n return { panel, content }\n}\n"],"mappings":";;AAaA,SAAgB,EAAwB,GAAmB,GAAqC;CAC9F,IAAM,IAAQ,SAAS,cAAc,KAAK;CAE1C,AADA,EAAM,YAAY,wDAAwD,KAC1E,EAAM,QAAQ,cAAc;CAC5B,IAAM,IAAS,SAAS,cAAc,KAAK;CAC3C,EAAO,YAAY;CACnB,IAAM,IAAU,SAAS,cAAc,KAAK;CAU5C,OATA,EAAQ,YAAY,oBACpB,EAAO,OAAO,CAAO,GACrB,EAAM,OAAO,CAAM,GAKnB,EAH0C,KAAA,GAAW,KAAU,SAAS,MAAM,EAC5E,iBAAiB,MAAW,KAAA,EAC9B,CACA,CAAA,CAAU,YAAY,CAAK,GAEpB;EAAE;EAAO;CAAQ;AAC1B"}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defineOverlay as e } from "./overlay.js";
|
|
2
|
+
import { hideOverlayPresence as t, showOverlayPresence as n } from "./presence.js";
|
|
3
3
|
import { definePlugin as r } from "@greypan/js-kit";
|
|
4
4
|
//#region src/shared/overlay/anchored-panel.ts
|
|
5
5
|
var i = () => r((r) => {
|
|
6
6
|
let i, a, o = () => a?.panel ?? r.getLocalPanel(), s = () => {
|
|
7
7
|
a && (a.restoreContent(), a.remove(), a = void 0, i = void 0);
|
|
8
|
-
}, c = () => r.isPortal() ? (a ??= r.createPortal(), a.panel) : r.getLocalPanel(), l = (
|
|
8
|
+
}, c = () => r.isPortal() ? (a ??= r.createPortal(), a.panel) : r.getLocalPanel(), l = (t, n) => {
|
|
9
9
|
if (i) {
|
|
10
|
-
i.updateAnchor(
|
|
10
|
+
i.updateAnchor(t), i.update(r.getPositioning());
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
i =
|
|
14
|
-
anchor:
|
|
15
|
-
overlay:
|
|
13
|
+
i = e().make({
|
|
14
|
+
anchor: t,
|
|
15
|
+
overlay: n,
|
|
16
16
|
...r.getPositioning()
|
|
17
17
|
});
|
|
18
18
|
}, u = (e = !1) => {
|
|
19
|
-
let
|
|
20
|
-
if (!
|
|
19
|
+
let t = r.getAnchor();
|
|
20
|
+
if (!t) return;
|
|
21
21
|
let a = c();
|
|
22
|
-
a && (l(
|
|
22
|
+
a && (l(t, a), i?.open(), n(a, { isInstant: e }));
|
|
23
23
|
}, d = () => {
|
|
24
24
|
i?.dispose(), i = void 0, s();
|
|
25
25
|
};
|
|
@@ -28,10 +28,10 @@ var i = () => r((r) => {
|
|
|
28
28
|
return o();
|
|
29
29
|
},
|
|
30
30
|
open: u,
|
|
31
|
-
async close(
|
|
31
|
+
async close(e) {
|
|
32
32
|
i?.close();
|
|
33
33
|
let n = o();
|
|
34
|
-
return n && !await
|
|
34
|
+
return n && !await t(n) || e() ? !1 : (s(), !0);
|
|
35
35
|
},
|
|
36
36
|
updatePosition() {
|
|
37
37
|
i?.update(r.getPositioning());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { autoUpdate as e, computePosition as t, flip as n, offset as r, shift as i, size as a } from "../../node_modules/.pnpm/@floating-ui_dom@1.8.0/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
2
2
|
import { definePlugin as o } from "@greypan/js-kit";
|
|
3
3
|
//#region src/shared/overlay/overlay.ts
|
|
4
|
-
var s = {
|
|
4
|
+
var s = 120, c = "--wui-overlay-min-width", l = {
|
|
5
5
|
placement: "bottom-start",
|
|
6
6
|
offset: 4,
|
|
7
7
|
flip: !0,
|
|
@@ -10,55 +10,77 @@ var s = {
|
|
|
10
10
|
minAnchorWidth: !1,
|
|
11
11
|
strategy: "absolute"
|
|
12
12
|
};
|
|
13
|
-
function
|
|
13
|
+
function u(e) {
|
|
14
|
+
if (typeof getComputedStyle != "function") return s;
|
|
15
|
+
let t = Number.parseFloat(getComputedStyle(e).getPropertyValue(c));
|
|
16
|
+
return Number.isFinite(t) ? t : s;
|
|
17
|
+
}
|
|
18
|
+
function d(e) {
|
|
19
|
+
e.style.removeProperty("width"), e.style.removeProperty("min-width");
|
|
20
|
+
}
|
|
21
|
+
function f(e, t, n) {
|
|
22
|
+
if (t.matchWidth) return e.style.removeProperty("min-width"), n.hasManagedStyles = !0, a({ apply({ rects: t }) {
|
|
23
|
+
e.style.width = `${t.reference.width}px`;
|
|
24
|
+
} });
|
|
25
|
+
if (t.minAnchorWidth) {
|
|
26
|
+
let t = u(e);
|
|
27
|
+
return n.hasManagedStyles = !0, a({ apply({ rects: n }) {
|
|
28
|
+
e.style.width = "max-content", e.style.minWidth = `${Math.max(n.reference.width, t)}px`;
|
|
29
|
+
} });
|
|
30
|
+
}
|
|
31
|
+
n.hasManagedStyles &&= (d(e), !1);
|
|
32
|
+
}
|
|
33
|
+
function p(e, t, a) {
|
|
34
|
+
let o = [r(t.offset)];
|
|
35
|
+
t.flip && o.push(n()), t.shift && o.push(i({ padding: 8 }));
|
|
36
|
+
let s = f(e, t, a);
|
|
37
|
+
return s && o.push(s), o;
|
|
38
|
+
}
|
|
39
|
+
function m(e) {
|
|
14
40
|
let [t, n] = e.split("-"), r = n === "start" ? "left" : n === "end" ? "right" : "center", i = n === "start" ? "top" : n === "end" ? "bottom" : "center";
|
|
15
41
|
return t === "top" ? `bottom ${r}` : t === "bottom" ? `top ${r}` : t === "left" ? `right ${i}` : `left ${i}`;
|
|
16
42
|
}
|
|
17
|
-
var
|
|
18
|
-
let
|
|
19
|
-
placement:
|
|
20
|
-
offset:
|
|
21
|
-
flip:
|
|
22
|
-
shift:
|
|
23
|
-
matchWidth:
|
|
24
|
-
minAnchorWidth:
|
|
25
|
-
strategy:
|
|
26
|
-
},
|
|
27
|
-
function
|
|
28
|
-
let o =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} })), f?.(), f = e(p, u, () => {
|
|
34
|
-
t(p, u, {
|
|
35
|
-
placement: l.placement,
|
|
36
|
-
strategy: l.strategy,
|
|
37
|
-
middleware: o
|
|
43
|
+
var h = () => o((n) => {
|
|
44
|
+
let r = {
|
|
45
|
+
placement: n.placement ?? l.placement,
|
|
46
|
+
offset: n.offset ?? l.offset,
|
|
47
|
+
flip: n.flip ?? l.flip,
|
|
48
|
+
shift: n.shift ?? l.shift,
|
|
49
|
+
matchWidth: n.matchWidth ?? l.matchWidth,
|
|
50
|
+
minAnchorWidth: n.minAnchorWidth ?? l.minAnchorWidth,
|
|
51
|
+
strategy: n.strategy ?? l.strategy
|
|
52
|
+
}, i = n.overlay, a = { hasManagedStyles: !1 }, o = !1, s = null, c = n.anchor;
|
|
53
|
+
function u() {
|
|
54
|
+
let n = p(i, r, a), o = () => {
|
|
55
|
+
t(c, i, {
|
|
56
|
+
placement: r.placement,
|
|
57
|
+
strategy: r.strategy,
|
|
58
|
+
middleware: n
|
|
38
59
|
}).then(({ x: e, y: t, placement: n }) => {
|
|
39
|
-
|
|
60
|
+
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.setProperty("--wui-overlay-transform-origin", m(n));
|
|
40
61
|
});
|
|
41
|
-
}
|
|
62
|
+
};
|
|
63
|
+
o(), s?.(), s = e(c, i, o);
|
|
42
64
|
}
|
|
43
65
|
return {
|
|
44
66
|
isOpen() {
|
|
45
|
-
return
|
|
67
|
+
return o;
|
|
46
68
|
},
|
|
47
|
-
options:
|
|
69
|
+
options: r,
|
|
48
70
|
open() {
|
|
49
|
-
|
|
71
|
+
o || (o = !0, i.style.display = "", u());
|
|
50
72
|
},
|
|
51
73
|
close() {
|
|
52
|
-
|
|
74
|
+
o && (o = !1, s?.(), s = null);
|
|
53
75
|
},
|
|
54
76
|
toggle() {
|
|
55
|
-
|
|
77
|
+
o ? this.close() : this.open();
|
|
56
78
|
},
|
|
57
79
|
update(e) {
|
|
58
|
-
Object.assign(
|
|
80
|
+
Object.assign(r, e), o && u();
|
|
59
81
|
},
|
|
60
82
|
updateAnchor(e) {
|
|
61
|
-
|
|
83
|
+
c = e, o && u();
|
|
62
84
|
},
|
|
63
85
|
dispose() {
|
|
64
86
|
this.close();
|
|
@@ -66,6 +88,6 @@ var l = () => o((o) => {
|
|
|
66
88
|
};
|
|
67
89
|
});
|
|
68
90
|
//#endregion
|
|
69
|
-
export {
|
|
91
|
+
export { h as defineOverlay };
|
|
70
92
|
|
|
71
93
|
//# sourceMappingURL=overlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.js","names":[],"sources":["../../../src/shared/overlay/overlay.ts"],"sourcesContent":["import {\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n size,\n type Middleware,\n type Placement,\n type Strategy\n} from '@floating-ui/dom'\nimport { definePlugin } from '@greypan/js-kit'\n\nexport interface OverlayOptions {\n placement?: Placement\n offset?: number\n flip?: boolean\n shift?: boolean\n
|
|
1
|
+
{"version":3,"file":"overlay.js","names":[],"sources":["../../../src/shared/overlay/overlay.ts"],"sourcesContent":["import {\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n size,\n type Middleware,\n type Placement,\n type Strategy\n} from '@floating-ui/dom'\nimport { definePlugin } from '@greypan/js-kit'\n\nexport interface OverlayOptions {\n placement?: Placement\n offset?: number\n flip?: boolean\n shift?: boolean\n /** 面板宽度与锚点宽度保持一致。 */\n matchWidth?: boolean\n /** 面板至少与锚点同宽,同时允许内容将面板撑宽。 */\n minAnchorWidth?: boolean\n strategy?: Strategy\n}\n\n/** 虚拟锚点:无对应 DOM 元素的定位基准(如右键菜单的鼠标坐标)。 */\nexport interface OverlayVirtualAnchor {\n getBoundingClientRect(): DOMRect\n}\n\nexport type OverlayAnchor = HTMLElement | OverlayVirtualAnchor\n\nexport interface OverlayApi {\n isOpen(): boolean\n readonly options: Required<OverlayOptions>\n open(): void\n close(): void\n toggle(): void\n update(options: Partial<OverlayOptions>): void\n updateAnchor(anchor: OverlayAnchor): void\n dispose(): void\n}\n\nconst DEFAULT_OVERLAY_MIN_WIDTH = 120\nconst OVERLAY_MIN_WIDTH_VARIABLE = '--wui-overlay-min-width'\n\nconst DEFAULT_OPTIONS: Required<OverlayOptions> = {\n placement: 'bottom-start',\n offset: 4,\n flip: true,\n shift: true,\n matchWidth: false,\n minAnchorWidth: false,\n strategy: 'absolute'\n}\n\ninterface WidthStyleState {\n hasManagedStyles: boolean\n}\n\nfunction readOverlayMinWidth(overlay: HTMLElement): number {\n if (typeof getComputedStyle !== 'function') return DEFAULT_OVERLAY_MIN_WIDTH\n\n const minWidth = Number.parseFloat(getComputedStyle(overlay).getPropertyValue(OVERLAY_MIN_WIDTH_VARIABLE))\n return Number.isFinite(minWidth) ? minWidth : DEFAULT_OVERLAY_MIN_WIDTH\n}\n\nfunction clearManagedWidthStyles(overlay: HTMLElement) {\n overlay.style.removeProperty('width')\n overlay.style.removeProperty('min-width')\n}\n\nfunction createWidthMiddleware(\n overlay: HTMLElement,\n options: Required<OverlayOptions>,\n widthStyles: WidthStyleState\n): Middleware | undefined {\n if (options.matchWidth) {\n // matchWidth 必须移除之前 minAnchorWidth 写入的 min-width,才能精确跟随 trigger。\n overlay.style.removeProperty('min-width')\n widthStyles.hasManagedStyles = true\n return size({\n apply({ rects }) {\n overlay.style.width = `${rects.reference.width}px`\n }\n })\n }\n\n if (options.minAnchorWidth) {\n const minWidth = readOverlayMinWidth(overlay)\n widthStyles.hasManagedStyles = true\n return size({\n apply({ rects }) {\n // max-content 让内容决定宽度,min-width 再提供 trigger 与 floor 两个下限。\n overlay.style.width = 'max-content'\n overlay.style.minWidth = `${Math.max(rects.reference.width, minWidth)}px`\n }\n })\n }\n\n if (widthStyles.hasManagedStyles) {\n clearManagedWidthStyles(overlay)\n widthStyles.hasManagedStyles = false\n }\n\n return undefined\n}\n\nfunction createPositioningMiddleware(\n overlay: HTMLElement,\n options: Required<OverlayOptions>,\n widthStyles: WidthStyleState\n): Middleware[] {\n const middleware: Middleware[] = [offset(options.offset)]\n if (options.flip) middleware.push(flip())\n if (options.shift) middleware.push(shift({ padding: 8 }))\n\n const widthMiddleware = createWidthMiddleware(overlay, options, widthStyles)\n if (widthMiddleware) middleware.push(widthMiddleware)\n\n return middleware\n}\n\nfunction getTransformOrigin(placement: Placement): string {\n const [side, alignment] = placement.split('-')\n const horizontalOrigin = alignment === 'start' ? 'left' : alignment === 'end' ? 'right' : 'center'\n const verticalOrigin = alignment === 'start' ? 'top' : alignment === 'end' ? 'bottom' : 'center'\n\n if (side === 'top') return `bottom ${horizontalOrigin}`\n if (side === 'bottom') return `top ${horizontalOrigin}`\n if (side === 'left') return `right ${verticalOrigin}`\n return `left ${verticalOrigin}`\n}\n\nexport const defineOverlay = () =>\n definePlugin<OverlayApi, { anchor: OverlayAnchor; overlay: HTMLElement } & OverlayOptions>(ctx => {\n const options: Required<OverlayOptions> = {\n placement: ctx.placement ?? DEFAULT_OPTIONS.placement,\n offset: ctx.offset ?? DEFAULT_OPTIONS.offset,\n flip: ctx.flip ?? DEFAULT_OPTIONS.flip,\n shift: ctx.shift ?? DEFAULT_OPTIONS.shift,\n matchWidth: ctx.matchWidth ?? DEFAULT_OPTIONS.matchWidth,\n minAnchorWidth: ctx.minAnchorWidth ?? DEFAULT_OPTIONS.minAnchorWidth,\n strategy: ctx.strategy ?? DEFAULT_OPTIONS.strategy\n }\n\n const overlay = ctx.overlay\n const widthStyles: WidthStyleState = { hasManagedStyles: false }\n let isOpen = false\n let cleanupAutoUpdate: (() => void) | null = null\n let currentAnchor = ctx.anchor\n\n function updatePosition() {\n const middleware = createPositioningMiddleware(overlay, options, widthStyles)\n\n const applyPosition = () => {\n void computePosition(currentAnchor, overlay, {\n placement: options.placement,\n strategy: options.strategy,\n middleware\n }).then(({ x, y, placement }) => {\n overlay.style.left = `${x}px`\n overlay.style.top = `${y}px`\n overlay.style.setProperty('--wui-overlay-transform-origin', getTransformOrigin(placement))\n })\n }\n\n // 立即定位一次,避免浮层首帧出现在左上角;autoUpdate 负责后续滚动/尺寸变化。\n applyPosition()\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = autoUpdate(currentAnchor, overlay, applyPosition)\n }\n\n return {\n isOpen() {\n return isOpen\n },\n options,\n\n open() {\n if (isOpen) return\n isOpen = true\n overlay.style.display = ''\n updatePosition()\n },\n\n close() {\n if (!isOpen) return\n isOpen = false\n cleanupAutoUpdate?.()\n cleanupAutoUpdate = null\n },\n\n toggle() {\n if (isOpen) this.close()\n else this.open()\n },\n\n update(nextOptions) {\n Object.assign(options, nextOptions)\n if (isOpen) updatePosition()\n },\n\n updateAnchor(newAnchor: OverlayAnchor) {\n currentAnchor = newAnchor\n if (isOpen) updatePosition()\n },\n\n dispose() {\n this.close()\n }\n }\n })\n"],"mappings":"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"}
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { getFallbackOverlayRoot as e } from "../theme/overlay-root.js";
|
|
2
|
-
import { findNearestTheme as t } from "../theme/theme-scope.js";
|
|
2
|
+
import { findNearestTheme as t, findRootTheme as n } from "../theme/theme-scope.js";
|
|
3
|
+
import { definePlugin as r } from "@greypan/js-kit";
|
|
3
4
|
//#region src/shared/overlay/portal.ts
|
|
4
|
-
|
|
5
|
+
var i = () => r((e) => {
|
|
5
6
|
let t = document.createElement("div");
|
|
6
7
|
t.style.display = "contents";
|
|
7
|
-
let n = t.attachShadow({ mode: "open" }),
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
let o = []
|
|
8
|
+
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
9
|
+
r.textContent = e.style;
|
|
10
|
+
let i = document.createElement("div");
|
|
11
|
+
i.className = e.className, i.dataset.wuiPresence = "entering", n.append(r, i), a(e.container, e.target).appendChild(t);
|
|
12
|
+
let o = [], s = (e) => {
|
|
13
|
+
e.forEach((e) => {
|
|
14
|
+
let t = o.indexOf(e);
|
|
15
|
+
t >= 0 && o.splice(t, 1);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
12
18
|
return {
|
|
13
|
-
panel:
|
|
14
|
-
moveContent(e, t =
|
|
19
|
+
panel: i,
|
|
20
|
+
moveContent(e, t = i) {
|
|
15
21
|
o.splice(0, o.length, ...e), t.append(...o);
|
|
16
22
|
},
|
|
23
|
+
appendContent(e, t = i) {
|
|
24
|
+
s(e), o.push(...e), t.append(...e);
|
|
25
|
+
},
|
|
26
|
+
removeContent(e) {
|
|
27
|
+
s(e);
|
|
28
|
+
},
|
|
17
29
|
restoreContent() {
|
|
18
30
|
e.target.append(...o), o.length = 0;
|
|
19
31
|
},
|
|
@@ -21,11 +33,11 @@ function n(e) {
|
|
|
21
33
|
t.remove();
|
|
22
34
|
}
|
|
23
35
|
};
|
|
24
|
-
}
|
|
25
|
-
function r
|
|
26
|
-
return (typeof
|
|
36
|
+
});
|
|
37
|
+
function a(r, i, a = {}) {
|
|
38
|
+
return (typeof r == "function" ? r() : r) || ((a.preferRootTheme ? n() : t(i))?.getOverlayRoot() ?? e());
|
|
27
39
|
}
|
|
28
40
|
//#endregion
|
|
29
|
-
export {
|
|
41
|
+
export { i as defineOverlayPortal, a as resolveOverlayContainer };
|
|
30
42
|
|
|
31
43
|
//# sourceMappingURL=portal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","names":[],"sources":["../../../src/shared/overlay/portal.ts"],"sourcesContent":["import { getFallbackOverlayRoot } from '@/shared/theme/overlay-root'\nimport { findNearestTheme } from '@/shared/theme/theme-scope'\n\nexport type OverlayContainer = HTMLElement | (() => HTMLElement | undefined)\n\
|
|
1
|
+
{"version":3,"file":"portal.js","names":[],"sources":["../../../src/shared/overlay/portal.ts"],"sourcesContent":["import { definePlugin } from '@greypan/js-kit'\n\nimport { getFallbackOverlayRoot } from '@/shared/theme/overlay-root'\nimport { findNearestTheme, findRootTheme } from '@/shared/theme/theme-scope'\n\nexport type OverlayContainer = HTMLElement | (() => HTMLElement | undefined)\n\nexport interface OverlayContainerResolutionOptions {\n /** 无 target 时优先使用文档中的 root theme。 */\n preferRootTheme?: boolean\n}\n\nexport interface OverlayPortalOptions {\n container?: OverlayContainer\n target: Element\n style: string\n className: string\n}\n\nexport interface OverlayPortal {\n readonly panel: HTMLElement\n restoreContent(): void\n moveContent(nodes: Node[], target?: HTMLElement): void\n appendContent(nodes: Node[], target?: HTMLElement): void\n removeContent(nodes: Node[]): void\n remove(): void\n}\n\n/**\n * 构建带 Shadow DOM 样式边界的 Portal 面板,并追踪被迁移的内容节点以便恢复。\n */\nexport const defineOverlayPortal = () =>\n definePlugin<OverlayPortal, OverlayPortalOptions>(ctx => {\n const host = document.createElement('div')\n // :host 规则可能让宿主在 overlay 容器中生成行盒;display: contents 保留面板定位而不参与布局。\n host.style.display = 'contents'\n\n const root = host.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = ctx.style\n const panel = document.createElement('div')\n panel.className = ctx.className\n panel.dataset.wuiPresence = 'entering'\n root.append(style, panel)\n\n resolveOverlayContainer(ctx.container, ctx.target).appendChild(host)\n\n const trackedNodes: Node[] = []\n const untrackNodes = (nodes: Node[]) => {\n nodes.forEach(node => {\n const index = trackedNodes.indexOf(node)\n if (index >= 0) trackedNodes.splice(index, 1)\n })\n }\n\n return {\n panel,\n\n moveContent(nodes, target = panel) {\n trackedNodes.splice(0, trackedNodes.length, ...nodes)\n target.append(...trackedNodes)\n },\n\n appendContent(nodes, target = panel) {\n untrackNodes(nodes)\n trackedNodes.push(...nodes)\n target.append(...nodes)\n },\n\n removeContent(nodes) {\n untrackNodes(nodes)\n },\n\n restoreContent() {\n ctx.target.append(...trackedNodes)\n trackedNodes.length = 0\n },\n\n remove() {\n host.remove()\n }\n }\n })\n\nexport function resolveOverlayContainer(\n container: OverlayContainer | undefined,\n target: Element,\n options: OverlayContainerResolutionOptions = {}\n): HTMLElement {\n const explicit = typeof container === 'function' ? container() : container\n if (explicit) return explicit\n\n // 无 target 的调用(如菜单)优先使用 root theme;有 target 时使用最近的 theme。\n const theme = options.preferRootTheme ? findRootTheme() : findNearestTheme(target)\n return theme?.getOverlayRoot() ?? getFallbackOverlayRoot()\n}\n"],"mappings":";;;;AA+BA,IAAa,UACX,GAAkD,MAAO;CACvD,IAAM,IAAO,SAAS,cAAc,KAAK;CAEzC,EAAK,MAAM,UAAU;CAErB,IAAM,IAAO,EAAK,aAAa,EAAE,MAAM,OAAO,CAAC,GACzC,IAAQ,SAAS,cAAc,OAAO;CAC5C,EAAM,cAAc,EAAI;CACxB,IAAM,IAAQ,SAAS,cAAc,KAAK;CAK1C,AAJA,EAAM,YAAY,EAAI,WACtB,EAAM,QAAQ,cAAc,YAC5B,EAAK,OAAO,GAAO,CAAK,GAExB,EAAwB,EAAI,WAAW,EAAI,MAAM,CAAC,CAAC,YAAY,CAAI;CAEnE,IAAM,IAAuB,CAAC,GACxB,KAAgB,MAAkB;EACtC,EAAM,SAAQ,MAAQ;GACpB,IAAM,IAAQ,EAAa,QAAQ,CAAI;GACvC,AAAI,KAAS,KAAG,EAAa,OAAO,GAAO,CAAC;EAC9C,CAAC;CACH;CAEA,OAAO;EACL;EAEA,YAAY,GAAO,IAAS,GAAO;GAEjC,AADA,EAAa,OAAO,GAAG,EAAa,QAAQ,GAAG,CAAK,GACpD,EAAO,OAAO,GAAG,CAAY;EAC/B;EAEA,cAAc,GAAO,IAAS,GAAO;GAGnC,AAFA,EAAa,CAAK,GAClB,EAAa,KAAK,GAAG,CAAK,GAC1B,EAAO,OAAO,GAAG,CAAK;EACxB;EAEA,cAAc,GAAO;GACnB,EAAa,CAAK;EACpB;EAEA,iBAAiB;GAEf,AADA,EAAI,OAAO,OAAO,GAAG,CAAY,GACjC,EAAa,SAAS;EACxB;EAEA,SAAS;GACP,EAAK,OAAO;EACd;CACF;AACF,CAAC;AAEH,SAAgB,EACd,GACA,GACA,IAA6C,CAAC,GACjC;CAMb,QALiB,OAAO,KAAc,aAAa,EAAU,IAAI,QAInD,EAAQ,kBAAkB,EAAc,IAAI,EAAiB,CAAM,EAAA,EACnE,eAAe,KAAK,EAAuB;AAC3D"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { definePlugin as e } from "@greypan/js-kit";
|
|
1
2
|
//#region src/shared/scroll-lock/scroll-lock.ts
|
|
2
|
-
var
|
|
3
|
-
function r() {
|
|
4
|
-
e === 0 && (n = window.scrollY, t = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.top = `-${n}px`, document.body.style.width = "100%"), e++;
|
|
5
|
-
}
|
|
3
|
+
var t = 0, n = "", r = 0;
|
|
6
4
|
function i() {
|
|
7
|
-
|
|
5
|
+
t === 0 && (r = window.scrollY, n = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden", document.body.style.position = "fixed", document.body.style.top = `-${r}px`, document.body.style.width = "100%"), t++;
|
|
8
6
|
}
|
|
9
7
|
function a() {
|
|
10
|
-
|
|
8
|
+
t = Math.max(0, t - 1), t === 0 && (document.documentElement.style.overflow = n, document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", window.scrollTo(0, r));
|
|
9
|
+
}
|
|
10
|
+
var o = () => e(() => {
|
|
11
|
+
let e = !1, t = (t) => {
|
|
12
|
+
t !== e && (t ? i() : a(), e = t);
|
|
13
|
+
};
|
|
11
14
|
return {
|
|
12
15
|
get isLocked() {
|
|
13
16
|
return e;
|
|
14
17
|
},
|
|
15
|
-
sync
|
|
16
|
-
t !== e && (t ? r() : i(), e = t);
|
|
17
|
-
},
|
|
18
|
+
sync: t,
|
|
18
19
|
release() {
|
|
19
|
-
|
|
20
|
+
t(!1);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
}
|
|
23
|
+
});
|
|
23
24
|
//#endregion
|
|
24
|
-
export {
|
|
25
|
+
export { o as defineScrollLockLease, i as lockScroll, a as unlockScroll };
|
|
25
26
|
|
|
26
27
|
//# sourceMappingURL=scroll-lock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-lock.js","names":[],"sources":["../../../src/shared/scroll-lock/scroll-lock.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"scroll-lock.js","names":[],"sources":["../../../src/shared/scroll-lock/scroll-lock.ts"],"sourcesContent":["import { definePlugin } from '@greypan/js-kit'\n\nlet lockCount = 0\nlet savedOverflow = ''\nlet savedScrollY = 0\n\nexport interface ScrollLockLease {\n readonly isLocked: boolean\n sync(shouldLock: boolean): void\n release(): void\n}\n\n/**\n * 锁定页面滚动。支持嵌套调用(引用计数),仅在最后一个锁释放时恢复。\n */\nexport function lockScroll() {\n if (lockCount === 0) {\n savedScrollY = window.scrollY\n savedOverflow = document.documentElement.style.overflow\n document.documentElement.style.overflow = 'hidden'\n // 固定 body 防止 iOS 弹性滚动\n document.body.style.position = 'fixed'\n document.body.style.top = `-${savedScrollY}px`\n document.body.style.width = '100%'\n }\n lockCount++\n}\n\n/**\n * 解锁页面滚动。与 lockScroll 配对,引用归零时恢复。\n */\nexport function unlockScroll() {\n lockCount = Math.max(0, lockCount - 1)\n if (lockCount === 0) {\n document.documentElement.style.overflow = savedOverflow\n document.body.style.position = ''\n document.body.style.top = ''\n document.body.style.width = ''\n window.scrollTo(0, savedScrollY)\n }\n}\n\n/**\n * 构建组件实例持有的滚动锁租约。每个租约仅释放自身获得的那一次锁,\n * 因此卸载、属性切换和嵌套浮层不会互相影响。\n */\nexport const defineScrollLockLease = () =>\n definePlugin<ScrollLockLease, Record<never, never>>(() => {\n let isLocked = false\n\n const sync = (shouldLock: boolean) => {\n if (shouldLock === isLocked) return\n if (shouldLock) lockScroll()\n else unlockScroll()\n isLocked = shouldLock\n }\n\n return {\n get isLocked() {\n return isLocked\n },\n\n sync,\n\n release() {\n sync(false)\n }\n }\n })\n"],"mappings":";;AAEA,IAAI,IAAY,GACZ,IAAgB,IAChB,IAAe;AAWnB,SAAgB,IAAa;CAU3B,AATI,MAAc,MAChB,IAAe,OAAO,SACtB,IAAgB,SAAS,gBAAgB,MAAM,UAC/C,SAAS,gBAAgB,MAAM,WAAW,UAE1C,SAAS,KAAK,MAAM,WAAW,SAC/B,SAAS,KAAK,MAAM,MAAM,IAAI,EAAa,KAC3C,SAAS,KAAK,MAAM,QAAQ,SAE9B;AACF;AAKA,SAAgB,IAAe;CAE7B,AADA,IAAY,KAAK,IAAI,GAAG,IAAY,CAAC,GACjC,MAAc,MAChB,SAAS,gBAAgB,MAAM,WAAW,GAC1C,SAAS,KAAK,MAAM,WAAW,IAC/B,SAAS,KAAK,MAAM,MAAM,IAC1B,SAAS,KAAK,MAAM,QAAQ,IAC5B,OAAO,SAAS,GAAG,CAAY;AAEnC;AAMA,IAAa,UACX,QAA0D;CACxD,IAAI,IAAW,IAET,KAAQ,MAAwB;EAChC,MAAe,MACf,IAAY,EAAW,IACtB,EAAa,GAClB,IAAW;CACb;CAEA,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EAEA;EAEA,UAAU;GACR,EAAK,EAAK;EACZ;CACF;AACF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import e from "../../assets/glass.js";
|
|
2
|
-
import t from "../../assets/
|
|
3
|
-
import n from "../../assets/
|
|
2
|
+
import t from "../../assets/overlay-motion.js";
|
|
3
|
+
import n from "../../assets/menu-portal.js";
|
|
4
4
|
import r from "../../assets/toast-containers.js";
|
|
5
5
|
//#region src/shared/theme/overlay-root.ts
|
|
6
|
-
var i = "data-wui-overlay-root", a = `${e}\n${r}\n${
|
|
6
|
+
var i = "data-wui-overlay-root", a = `${e}\n${r}\n${n}\n${t}`;
|
|
7
7
|
function o(e) {
|
|
8
8
|
let t = document.createElement("style");
|
|
9
9
|
t.textContent = a, e.prepend(t);
|
package/dist/types/react.d.ts
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'web-ui-drawer': LitReactWrapper<WebUiDrawer>;
|
|
18
|
-
'web-ui-empty': LitReactWrapper<WebUiEmpty>;
|
|
19
|
-
'web-ui-dropdown-divider': LitReactWrapper<WebUiDropdownDivider>;
|
|
20
|
-
'web-ui-dropdown-header': LitReactWrapper<WebUiDropdownHeader>;
|
|
21
|
-
'web-ui-dropdown-item': LitReactWrapper<WebUiDropdownItem>;
|
|
22
|
-
'web-ui-dropdown': LitReactWrapper<WebUiDropdown>;
|
|
23
|
-
'web-ui-icon': LitReactWrapper<WebUiIcon>;
|
|
24
|
-
'web-ui-input': LitReactWrapper<WebUiInput>;
|
|
25
|
-
'web-ui-input-number': LitReactWrapper<WebUiInputNumber>;
|
|
26
|
-
'web-ui-select': LitReactWrapper<WebUiSelect>;
|
|
27
|
-
'web-ui-slider': LitReactWrapper<WebUiSlider>;
|
|
28
|
-
'web-ui-spinner': LitReactWrapper<WebUiSpinner>;
|
|
29
|
-
'web-ui-svg-draw-lines': LitReactWrapper<WebUiSvgDrawLines>;
|
|
30
|
-
'web-ui-option': LitReactWrapper<WebUiOption>;
|
|
31
|
-
'web-ui-popover': LitReactWrapper<WebUiPopover>;
|
|
32
|
-
'web-ui-radio': LitReactWrapper<WebUiRadio>;
|
|
33
|
-
'web-ui-radio-group': LitReactWrapper<WebUiRadioGroup>;
|
|
34
|
-
'web-ui-segmented': LitReactWrapper<WebUiSegmented>;
|
|
35
|
-
'web-ui-segmented-trigger': LitReactWrapper<WebUiSegmentedTrigger>;
|
|
36
|
-
'web-ui-layout': LitReactWrapper<WebUiLayout>;
|
|
37
|
-
'web-ui-switch': LitReactWrapper<WebUiSwitch>;
|
|
38
|
-
'web-ui-textarea': LitReactWrapper<WebUiTextarea>;
|
|
39
|
-
'web-ui-theme': LitReactWrapper<WebUiTheme>;
|
|
40
|
-
'web-ui-toast': LitReactWrapper<WebUiToast>;
|
|
41
|
-
'web-ui-tooltip': LitReactWrapper<WebUiTooltip>;
|
|
42
|
-
}
|
|
2
|
+
import { WebUiElementMap } from '../components';
|
|
3
|
+
import { ExtractProps, OmitLitBase, ReactCustomEventListeners } from './utils';
|
|
4
|
+
/**
|
|
5
|
+
* Lit Web Component 的 React 包装类型。
|
|
6
|
+
*
|
|
7
|
+
* - 标准 DOM 事件(input/change/focus/blur)使用 React 惯用 camelCase handler,
|
|
8
|
+
* `currentTarget` 收窄为组件实例(`target` 遵循 React SyntheticEvent 语义,不承诺)。
|
|
9
|
+
* - kebab-case 自定义事件(open-change/toast-close)生成精确的 `on<event>` 绑定。
|
|
10
|
+
* - 与 `HTMLAttributes<T>` 全量交叉:组件自身属性与通用 HTML 属性(含原生事件)共存,
|
|
11
|
+
* 重叠键类型相容(如 `placeholder`),组件类型在交叉中自然生效;`ref` 保持具体元素类型。
|
|
12
|
+
*/
|
|
13
|
+
export type LitReactWrapper<T extends HTMLElement> = DetailedHTMLProps<ExtractProps<OmitLitBase<T>> & ReactCustomEventListeners<T> & HTMLAttributes<T>, T>;
|
|
14
|
+
export type WebUiComponents = {
|
|
15
|
+
[K in keyof WebUiElementMap]: LitReactWrapper<WebUiElementMap[K]>;
|
|
16
|
+
};
|
|
43
17
|
declare module 'react' {
|
|
44
18
|
namespace JSX {
|
|
45
19
|
interface IntrinsicElements extends WebUiComponents {
|