@greypan/web-ui 6.0.0 → 6.2.0
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 +285 -93
- package/README.md +266 -87
- package/dist/assets/glass.js +1 -1
- package/dist/assets/glass.js.map +1 -1
- package/dist/assets/menu-portal.js +1 -1
- package/dist/assets/menu-portal.js.map +1 -1
- package/dist/assets/overlay-motion.js +1 -1
- package/dist/assets/overlay-motion.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +367 -4
- package/dist/components/autocomplete/index.js +87 -80
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/autocomplete/style.js +1 -1
- package/dist/components/autocomplete/style.js.map +1 -1
- package/dist/components/avatar/style.js +1 -1
- package/dist/components/avatar/style.js.map +1 -1
- package/dist/components/back-top/style.js +1 -1
- package/dist/components/back-top/style.js.map +1 -1
- package/dist/components/badge/style.js +1 -1
- package/dist/components/badge/style.js.map +1 -1
- package/dist/components/button/index.js +36 -32
- 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/style.js +1 -1
- package/dist/components/button-group/style.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +366 -5
- package/dist/components/checkbox/index.js +19 -31
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox/style.js +1 -1
- package/dist/components/checkbox/style.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +366 -4
- package/dist/components/checkbox-group/index.js +16 -25
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/collapse/index.d.ts +29 -1
- package/dist/components/collapse/index.js +105 -46
- package/dist/components/collapse/index.js.map +1 -1
- package/dist/components/collapse/style.js +1 -1
- package/dist/components/collapse/style.js.map +1 -1
- package/dist/components/context-menu/index.d.ts +7 -14
- package/dist/components/context-menu/index.js +113 -164
- package/dist/components/context-menu/index.js.map +1 -1
- package/dist/components/dialog/index.js +26 -25
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/style.js +1 -1
- package/dist/components/dialog/style.js.map +1 -1
- package/dist/components/drawer/index.js +71 -64
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/style.js +1 -1
- package/dist/components/drawer/style.js.map +1 -1
- package/dist/components/dropdown/index.d.ts +6 -14
- package/dist/components/dropdown/index.js +100 -156
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/dropdown-header/style.js +1 -1
- package/dist/components/dropdown-header/style.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/style.js +1 -1
- package/dist/components/empty/style.js.map +1 -1
- package/dist/components/image-preview/index.d.ts +58 -0
- package/dist/components/image-preview/index.js +481 -0
- package/dist/components/image-preview/index.js.map +1 -0
- package/dist/components/image-preview/style.js +6 -0
- package/dist/components/image-preview/style.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +20 -19
- package/dist/components/input/index.d.ts +366 -5
- package/dist/components/input/index.js +35 -47
- 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 +366 -5
- package/dist/components/input-number/index.js +31 -44
- 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 +1 -1
- package/dist/components/layout/index.js +5 -3
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/style.js +1 -1
- package/dist/components/layout/style.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.d.ts +1 -0
- package/dist/components/popover/index.js +55 -60
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/popover/style.js +1 -1
- package/dist/components/popover/style.js.map +1 -1
- package/dist/components/radio/index.d.ts +366 -5
- package/dist/components/radio/index.js +21 -31
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/radio/style.js +1 -1
- package/dist/components/radio/style.js.map +1 -1
- package/dist/components/radio-group/index.d.ts +366 -4
- package/dist/components/radio-group/index.js +16 -25
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/segmented/index.d.ts +366 -4
- package/dist/components/segmented/index.js +28 -35
- package/dist/components/segmented/index.js.map +1 -1
- package/dist/components/segmented/style.js +1 -1
- package/dist/components/segmented/style.js.map +1 -1
- package/dist/components/segmented-trigger/index.js +17 -15
- package/dist/components/segmented-trigger/index.js.map +1 -1
- package/dist/components/segmented-trigger/style.js +1 -1
- package/dist/components/segmented-trigger/style.js.map +1 -1
- package/dist/components/select/index.d.ts +368 -5
- package/dist/components/select/index.js +71 -68
- 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/slider/index.d.ts +366 -5
- package/dist/components/slider/index.js +40 -50
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/style.js +1 -1
- package/dist/components/slider/style.js.map +1 -1
- package/dist/components/spinner/style.js +1 -1
- package/dist/components/spinner/style.js.map +1 -1
- package/dist/components/svg-draw-lines/index.js +1 -1
- package/dist/components/svg-draw-lines/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +366 -5
- package/dist/components/switch/index.js +28 -38
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/style.js +1 -1
- package/dist/components/switch/style.js.map +1 -1
- package/dist/components/textarea/index.d.ts +366 -5
- package/dist/components/textarea/index.js +43 -57
- 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.js +1 -1
- package/dist/components/theme/index.js.map +1 -1
- package/dist/components/theme/style.js +1 -1
- package/dist/components/theme/style.js.map +1 -1
- package/dist/components/toast/manager.js +2 -2
- package/dist/components/toast/manager.js.map +1 -1
- package/dist/components/toast/style.js +1 -1
- package/dist/components/toast/style.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +43 -58
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/style.js +1 -1
- package/dist/components/tooltip/style.js.map +1 -1
- package/dist/icons/generated/radix-icons-reset.d.ts +6 -0
- package/dist/icons/generated/radix-icons-reset.js +10 -0
- package/dist/icons/generated/radix-icons-reset.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +2 -1
- package/dist/shared/focus/pointer-focus.js +37 -0
- package/dist/shared/focus/pointer-focus.js.map +1 -0
- package/dist/shared/form-association/index.js +31 -4
- package/dist/shared/form-association/index.js.map +1 -1
- package/dist/shared/gesture/drag-gesture.js +53 -30
- package/dist/shared/gesture/drag-gesture.js.map +1 -1
- package/dist/shared/gesture/pinch-gesture.js +84 -0
- package/dist/shared/gesture/pinch-gesture.js.map +1 -0
- package/dist/shared/group-management/index.js.map +1 -1
- package/dist/shared/menu-behavior/index.js +112 -0
- package/dist/shared/menu-behavior/index.js.map +1 -0
- package/dist/shared/menu-portal/menu-portal.js.map +1 -1
- package/dist/shared/open-state/index.js +12 -0
- package/dist/shared/open-state/index.js.map +1 -0
- package/dist/shared/option-portal/combobox-shell.js +43 -0
- package/dist/shared/option-portal/combobox-shell.js.map +1 -0
- package/dist/shared/option-portal/index.js +22 -21
- package/dist/shared/option-portal/index.js.map +1 -1
- package/dist/shared/overlay/anchored-panel.js +33 -30
- package/dist/shared/overlay/anchored-panel.js.map +1 -1
- package/dist/shared/overlay/composition.js +57 -0
- package/dist/shared/overlay/composition.js.map +1 -0
- package/dist/shared/overlay/lifecycle.js +41 -0
- package/dist/shared/overlay/lifecycle.js.map +1 -0
- package/dist/shared/overlay/native-dialog-presence.js +15 -15
- package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
- package/dist/shared/{theme → overlay}/overlay-root.js +1 -1
- package/dist/shared/overlay/overlay-root.js.map +1 -0
- package/dist/shared/overlay/overlay.js +43 -41
- package/dist/shared/overlay/overlay.js.map +1 -1
- package/dist/shared/overlay/placement-props.js +19 -0
- package/dist/shared/overlay/placement-props.js.map +1 -0
- package/dist/shared/overlay/portal.js +6 -4
- package/dist/shared/overlay/portal.js.map +1 -1
- package/dist/shared/overlay/positioning-generation.js +20 -0
- package/dist/shared/overlay/positioning-generation.js.map +1 -0
- package/dist/shared/{theme/theme-scope.js → overlay/theme-overlay-scope.js} +2 -2
- package/dist/shared/overlay/theme-overlay-scope.js.map +1 -0
- package/package.json +6 -10
- package/dist/shared/theme/overlay-root.js.map +0 -1
- package/dist/shared/theme/theme-scope.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/dropdown-item/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n opacity: 0.4;\n}\n\n.item-inner {\n user-select: none;\n\n display: flex;\n gap: 8px;\n align-items: center;\n\n height: 32px;\n padding: 0 8px;\n border-radius: calc(infinity * 1px);\n\n font-size: var(--wui-font-size, 14px);\n color: inherit;\n white-space: nowrap;\n\n outline: none;\n}\n\n.item-inner:focus-visible {\n color: var(--wui-color-on-accent, #fff);\n background: var(--wui-color-accent, #08f);\n}\n\n:host([active]) .item-inner {\n color: inherit;\n background: var(--wui-color-border, rgb(0 0 0 / 0.1));\n}\n\n@media (hover: hover) and (pointer: fine) {\n :host(:hover) .item-inner {\n color: var(--wui-color-on-accent, #fff);\n background: var(--wui-color-accent, #08f);\n }\n}\n\n.item-label {\n overflow: hidden;\n flex: 1;\n\n min-width: 0;\n\n color: inherit;\n text-overflow: ellipsis;\n}\n\n.item-suffix {\n flex: none;\n opacity: 0.4;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/dropdown-item/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n:host([disabled]) {\n cursor: not-allowed;\n opacity: 0.4;\n}\n\n.item-inner {\n user-select: none;\n\n display: flex;\n gap: 8px;\n align-items: center;\n\n height: 32px;\n padding: 0 8px;\n border-radius: var(--wui-radius-control, calc(infinity * 1px));\n\n font-size: var(--wui-font-size, 14px);\n color: inherit;\n white-space: nowrap;\n\n outline: none;\n}\n\n.item-inner:focus-visible {\n color: var(--wui-color-on-accent, #fff);\n background: var(--wui-color-accent, #08f);\n}\n\n:host([active]) .item-inner {\n color: inherit;\n background: var(--wui-color-border, rgb(0 0 0 / 0.1));\n}\n\n@media (hover: hover) and (pointer: fine) {\n :host(:hover) .item-inner {\n color: var(--wui-color-on-accent, #fff);\n background: var(--wui-color-accent, #08f);\n }\n}\n\n.item-label {\n overflow: hidden;\n flex: 1;\n\n min-width: 0;\n\n color: inherit;\n text-overflow: ellipsis;\n}\n\n.item-suffix {\n flex: none;\n opacity: 0.4;\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/components/empty/style.css?inline
|
|
2
|
-
var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,240px);padding:var(--wui-empty-padding,32px 24px);text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{width:var(--wui-empty-icon-size,56px);height:var(--wui-empty-icon-size,56px);color:var(--wui-color-text-secondary,#6a6a6a);background-color:var(--wui-color-surface-track,#e5e5ea);box-shadow:none;
|
|
2
|
+
var e = "*,:before,:after{box-sizing:border-box}:host{display:block}.empty{width:100%;min-block-size:var(--wui-empty-min-height,240px);padding:var(--wui-empty-padding,32px 24px);text-align:center;flex-direction:column;align-items:center;display:flex}.empty-icon{width:var(--wui-empty-icon-size,56px);height:var(--wui-empty-icon-size,56px);border-radius:var(--wui-internal-empty-icon-radius,16px);color:var(--wui-color-text-secondary,#6a6a6a);background-color:var(--wui-color-surface-track,#e5e5ea);box-shadow:none;flex:none;justify-content:center;align-items:center;display:flex}.empty-title,.empty-description,.empty-action{max-inline-size:var(--wui-empty-content-width,480px)}.empty-title{margin-top:var(--wui-empty-title-margin-top,16px);font-size:var(--wui-empty-title-font-size,16px);color:var(--wui-color-text,#1b1b1b);overflow-wrap:anywhere;font-weight:600;line-height:1.5}.empty-description{font-size:var(--wui-empty-description-font-size,14px);color:var(--wui-color-text-secondary,#6a6a6a);overflow-wrap:anywhere;margin-top:6px;line-height:1.6}.empty-action{margin-top:var(--wui-empty-action-margin-top,20px)}.is-hidden{display:none}:host([size=small]){--wui-empty-min-height:160px;--wui-empty-padding:20px 16px;--wui-empty-icon-size:40px;--wui-empty-title-margin-top:12px;--wui-empty-title-font-size:14px;--wui-empty-description-font-size:13px;--wui-empty-action-margin-top:16px}:host([size=large]){--wui-empty-min-height:320px;--wui-empty-padding:48px 32px;--wui-empty-icon-size:72px;--wui-empty-title-margin-top:20px;--wui-empty-title-font-size:18px;--wui-empty-action-margin-top:24px}";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { e as default };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, 240px);\n padding: var(--wui-empty-padding, 32px 24px);\n\n text-align: center;\n}\n\n.empty-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, 56px);\n height: var(--wui-empty-icon-size, 56px);\n border-radius: 16px;\n\n color: var(--wui-color-text-secondary, #6a6a6a);\n\n background-color: var(--wui-color-surface-track, #e5e5ea);\n box-shadow: none;\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, 16px);\n\n font-size: var(--wui-empty-title-font-size, 16px);\n font-weight: 600;\n line-height: 1.5;\n color: var(--wui-color-text, #1b1b1b);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, 14px);\n line-height: 1.6;\n color: var(--wui-color-text-secondary, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, 20px);\n}\n\n.is-hidden {\n display: none;\n}\n\n:host([size='small']) {\n --wui-empty-min-height: 160px;\n --wui-empty-padding: 20px 16px;\n --wui-empty-icon-size: 40px;\n --wui-empty-title-margin-top: 12px;\n --wui-empty-title-font-size: 14px;\n --wui-empty-description-font-size: 13px;\n --wui-empty-action-margin-top: 16px;\n}\n\n:host([size='large']) {\n --wui-empty-min-height: 320px;\n --wui-empty-padding: 48px 32px;\n --wui-empty-icon-size: 72px;\n --wui-empty-title-margin-top: 20px;\n --wui-empty-title-font-size: 18px;\n --wui-empty-action-margin-top: 24px;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/components/empty/style.css?inline"],"sourcesContent":["*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n}\n\n.empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n\n width: 100%;\n min-block-size: var(--wui-empty-min-height, 240px);\n padding: var(--wui-empty-padding, 32px 24px);\n\n text-align: center;\n}\n\n.empty-icon {\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n width: var(--wui-empty-icon-size, 56px);\n height: var(--wui-empty-icon-size, 56px);\n border-radius: var(--wui-internal-empty-icon-radius, 16px);\n\n color: var(--wui-color-text-secondary, #6a6a6a);\n\n background-color: var(--wui-color-surface-track, #e5e5ea);\n box-shadow: none;\n}\n\n.empty-title,\n.empty-description,\n.empty-action {\n max-inline-size: var(--wui-empty-content-width, 480px);\n}\n\n.empty-title {\n margin-top: var(--wui-empty-title-margin-top, 16px);\n\n font-size: var(--wui-empty-title-font-size, 16px);\n font-weight: 600;\n line-height: 1.5;\n color: var(--wui-color-text, #1b1b1b);\n overflow-wrap: anywhere;\n}\n\n.empty-description {\n margin-top: 6px;\n\n font-size: var(--wui-empty-description-font-size, 14px);\n line-height: 1.6;\n color: var(--wui-color-text-secondary, #6a6a6a);\n overflow-wrap: anywhere;\n}\n\n.empty-action {\n margin-top: var(--wui-empty-action-margin-top, 20px);\n}\n\n.is-hidden {\n display: none;\n}\n\n:host([size='small']) {\n --wui-empty-min-height: 160px;\n --wui-empty-padding: 20px 16px;\n --wui-empty-icon-size: 40px;\n --wui-empty-title-margin-top: 12px;\n --wui-empty-title-font-size: 14px;\n --wui-empty-description-font-size: 13px;\n --wui-empty-action-margin-top: 16px;\n}\n\n:host([size='large']) {\n --wui-empty-min-height: 320px;\n --wui-empty-padding: 48px 32px;\n --wui-empty-icon-size: 72px;\n --wui-empty-title-margin-top: 20px;\n --wui-empty-title-font-size: 18px;\n --wui-empty-action-margin-top: 24px;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface ImagePreviewItem {
|
|
2
|
+
src: string;
|
|
3
|
+
/** 无障碍替代文本;也用于图片加载失败时的回退展示。 */
|
|
4
|
+
alt?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ImagePreviewOptions {
|
|
7
|
+
images: ImagePreviewItem[];
|
|
8
|
+
/** 初始图片索引,越界时钳制到有效区间。默认 0。 */
|
|
9
|
+
index?: number;
|
|
10
|
+
/** 首尾循环切换。默认 true。 */
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
/** 用于解析最近 web-ui-theme 作用域的触发元素。 */
|
|
13
|
+
target?: Element;
|
|
14
|
+
/** 显式挂载容器,优先级高于 target 和主题作用域。 */
|
|
15
|
+
container?: HTMLElement;
|
|
16
|
+
/** 展示上一张 / 下一张按钮;仅在图片多于一张时渲染。默认 false。 */
|
|
17
|
+
nav?: boolean;
|
|
18
|
+
/** 展示缩放工具条。默认 false。 */
|
|
19
|
+
toolbar?: boolean;
|
|
20
|
+
/** 展示关闭按钮。默认 false。 */
|
|
21
|
+
closable?: boolean;
|
|
22
|
+
/** 展示「当前 / 总数」指示器。默认 false。 */
|
|
23
|
+
indicator?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 1x 且图片多于一张时,允许左右滑动切换图片:该手势接管整个拖拽,纵向位移被忽略
|
|
26
|
+
* (不驱平移、不跟手),横向用于切图。放大后拖拽一律平移(纵横都跟)、不再切图。
|
|
27
|
+
* 默认 false。
|
|
28
|
+
*/
|
|
29
|
+
swipe?: boolean;
|
|
30
|
+
/** 打开期间不锁定页面滚动,语义与 `<web-ui-dialog>` 的 `noScrollLock` 一致。默认 false。 */
|
|
31
|
+
noScrollLock?: boolean;
|
|
32
|
+
/** 点击图片以外的空白区域不关闭,语义与 `<web-ui-dialog>` 的 `noBackdropClose` 一致。默认 false。 */
|
|
33
|
+
noBackdropClose?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ImagePreviewHandle {
|
|
36
|
+
/** 当前图片索引;关闭后仍保留最后一次的值。 */
|
|
37
|
+
readonly index: number;
|
|
38
|
+
/** 当前缩放倍率,区间 [1, 4];切换图片时重置为 1。 */
|
|
39
|
+
readonly scale: number;
|
|
40
|
+
readonly images: readonly ImagePreviewItem[];
|
|
41
|
+
/** 退场过渡结束、宿主已从 DOM 移除后兑现。 */
|
|
42
|
+
readonly closed: Promise<void>;
|
|
43
|
+
next(): void;
|
|
44
|
+
prev(): void;
|
|
45
|
+
goTo(index: number): void;
|
|
46
|
+
zoomIn(): void;
|
|
47
|
+
zoomOut(): void;
|
|
48
|
+
resetZoom(): void;
|
|
49
|
+
close(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 打开一个命令式图片预览。
|
|
53
|
+
*
|
|
54
|
+
* 组件挂载到目标 `web-ui-theme` 的 overlay 容器(无主题作用域时回退到全局
|
|
55
|
+
* fallback root),返回的句柄是唯一的控制入口。所有展示类选项默认关闭,
|
|
56
|
+
* 默认只渲染图片本身。
|
|
57
|
+
*/
|
|
58
|
+
export declare function imagePreview(options: ImagePreviewOptions): ImagePreviewHandle;
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/decorate.js";
|
|
2
|
+
import "../icon/index.js";
|
|
3
|
+
import t from "../../icons/generated/lucide-chevron-left.js";
|
|
4
|
+
import n from "../../icons/generated/lucide-chevron-right.js";
|
|
5
|
+
import r from "../../icons/generated/lucide-plus.js";
|
|
6
|
+
import i from "../../icons/generated/lucide-minus.js";
|
|
7
|
+
import a from "../../icons/generated/ooui-close.js";
|
|
8
|
+
import o from "../../icons/generated/radix-icons-reset.js";
|
|
9
|
+
import s from "../../assets/glass.js";
|
|
10
|
+
import { getFallbackOverlayRoot as c } from "../../shared/overlay/overlay-root.js";
|
|
11
|
+
import { findNearestTheme as l, findRootTheme as u } from "../../shared/overlay/theme-overlay-scope.js";
|
|
12
|
+
import { defineScrollLockLease as d } from "../../shared/scroll-lock/scroll-lock.js";
|
|
13
|
+
import "../button/index.js";
|
|
14
|
+
import { defineNativeDialogPresence as f } from "../../shared/overlay/native-dialog-presence.js";
|
|
15
|
+
import { attachDragGesture as p } from "../../shared/gesture/drag-gesture.js";
|
|
16
|
+
import { clamp as m } from "../../shared/gesture/physics.js";
|
|
17
|
+
import { attachPinchGesture as h } from "../../shared/gesture/pinch-gesture.js";
|
|
18
|
+
import g from "./style.js";
|
|
19
|
+
import { LitElement as _, html as v, nothing as y, unsafeCSS as b } from "lit";
|
|
20
|
+
import { customElement as x, property as S, state as C } from "lit/decorators.js";
|
|
21
|
+
import { classMap as w } from "lit/directives/class-map.js";
|
|
22
|
+
import { styleMap as T } from "lit/directives/style-map.js";
|
|
23
|
+
//#region src/components/image-preview/index.ts
|
|
24
|
+
var E = 1, D = 4, O = .5, k = .002, A = 3, j = .15, M = 320, N = 16, P = 160, F = 320, I = class extends _ {
|
|
25
|
+
constructor(...e) {
|
|
26
|
+
super(...e), this.images = [], this.loop = !0, this.nav = !1, this.toolbar = !1, this.closable = !1, this.indicator = !1, this.swipe = !1, this.noScrollLock = !1, this.noBackdropClose = !1, this._open = !1, this._index = 0, this._scale = E, this._offsetX = 0, this._offsetY = 0, this._swipeOffset = 0, this._swipeSettling = !1, this._dragging = !1, this._loadedSources = /* @__PURE__ */ new Set(), this._swipeDir = 0, this._swipeStartTime = 0, this._swipeSettleCommit = !1, this._swipeSettleDir = 1, this._scrollLock = d().make(), this._presence = f().make({
|
|
27
|
+
getDialog: () => this.dialog,
|
|
28
|
+
isConnected: () => this.isConnected,
|
|
29
|
+
isOpen: () => this._open
|
|
30
|
+
}), this._dismissed = !1, this._swipeGesture = !1, this._panOriginX = 0, this._panOriginY = 0, this._dragged = !1, this._blankPointerDown = !1, this._pinchScale = E, this._pinchLocalX = 0, this._pinchLocalY = 0, this._handleImageSettled = (e) => {
|
|
31
|
+
let t = e.currentTarget;
|
|
32
|
+
t && (this._loadedSources.add(t.src), this.requestUpdate());
|
|
33
|
+
}, this._handleCancel = (e) => {
|
|
34
|
+
e.preventDefault(), this.close();
|
|
35
|
+
}, this._handleNativeClose = () => {
|
|
36
|
+
this._notifyDismissed();
|
|
37
|
+
}, this._handleTransitionEnd = (e) => {
|
|
38
|
+
this._presence.handleTransitionEnd(e);
|
|
39
|
+
}, this._handleKeydown = (e) => {
|
|
40
|
+
if (!(!this._open || e.defaultPrevented) && !(e.altKey || e.ctrlKey || e.metaKey)) switch (e.key) {
|
|
41
|
+
case "ArrowLeft":
|
|
42
|
+
e.preventDefault(), this.prev();
|
|
43
|
+
break;
|
|
44
|
+
case "ArrowRight":
|
|
45
|
+
e.preventDefault(), this.next();
|
|
46
|
+
break;
|
|
47
|
+
case "+":
|
|
48
|
+
case "=":
|
|
49
|
+
e.preventDefault(), this.zoomIn();
|
|
50
|
+
break;
|
|
51
|
+
case "-":
|
|
52
|
+
case "_":
|
|
53
|
+
e.preventDefault(), this.zoomOut();
|
|
54
|
+
break;
|
|
55
|
+
case "0": e.preventDefault(), this.resetZoom();
|
|
56
|
+
}
|
|
57
|
+
}, this._handleWheel = (e) => {
|
|
58
|
+
if (!this._open) return;
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
let t = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaY, n = this._stageOrigin();
|
|
61
|
+
this._zoomAt(this._scale * Math.exp(-t * k), e.clientX - n.x, e.clientY - n.y);
|
|
62
|
+
}, this._handleClick = (e) => {
|
|
63
|
+
if (!this._open) return;
|
|
64
|
+
let t = this._blankPointerDown;
|
|
65
|
+
if (this._blankPointerDown = !1, t && e.detail !== 0) {
|
|
66
|
+
if (this._dragged) {
|
|
67
|
+
this._dragged = !1;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.noBackdropClose || this.close();
|
|
71
|
+
}
|
|
72
|
+
}, this._handleDoubleClick = (e) => {
|
|
73
|
+
!this._open || e.target !== this._image || (this._scale > E ? this.resetZoom() : this._setScale(D / 2));
|
|
74
|
+
}, this._handlePinchStart = (e) => {
|
|
75
|
+
if (!this._open) return;
|
|
76
|
+
this._endGesture(), this._dragging = !0, this._dragged = !0;
|
|
77
|
+
let t = this._stageOrigin();
|
|
78
|
+
this._pinchScale = this._scale, this._pinchLocalX = (e.centerX - t.x - this._offsetX) / this._scale, this._pinchLocalY = (e.centerY - t.y - this._offsetY) / this._scale;
|
|
79
|
+
}, this._handlePinchMove = (e) => {
|
|
80
|
+
if (!this._open) return;
|
|
81
|
+
let t = m(this._pinchScale * e.ratio, E, D), n = this._stageOrigin();
|
|
82
|
+
this._applyScale(t, e.centerX - n.x - this._pinchLocalX * t, e.centerY - n.y - this._pinchLocalY * t);
|
|
83
|
+
}, this._handlePinchEnd = () => {
|
|
84
|
+
this._dragging = !1;
|
|
85
|
+
}, this._handlePinchCancel = () => {
|
|
86
|
+
this._dragging = !1;
|
|
87
|
+
}, this._handleSwipeSettleEnd = (e) => {
|
|
88
|
+
!this._swipeSettling || e.propertyName !== "transform" || this._finishSwipeSettle();
|
|
89
|
+
}, this._handlePointerDown = (e) => {
|
|
90
|
+
if (!this._open || (this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0, e.button !== 0 || e.isPrimary === !1)) return;
|
|
91
|
+
this._blankPointerDown = this._isBlank(e.target), this._dragged = !1;
|
|
92
|
+
let t = this._stage;
|
|
93
|
+
!t || e.target !== t && !t.contains(e.target) || (this._swipeGesture = this._scale === E && this.swipe && this.images.length > 1, this._swipeStartTime = e.timeStamp, this._panOriginX = this._offsetX, this._panOriginY = this._offsetY, this._gesture?.destroy(), this._gesture = p(e, {
|
|
94
|
+
axis: "both",
|
|
95
|
+
threshold: A,
|
|
96
|
+
onMove: (e) => {
|
|
97
|
+
this._swipeGesture ? (this._swipeOffset = e.deltaX, e.deltaX !== 0 && (this._swipeDir = e.deltaX < 0 ? 1 : -1)) : this._panTo(e.deltaX, e.deltaY);
|
|
98
|
+
},
|
|
99
|
+
onEnd: (e) => {
|
|
100
|
+
this._dragged = !0, this._dragging = !1, this._swipeGesture && this._settleSwipe(e.deltaX, e.velocityX, e.timeStamp);
|
|
101
|
+
},
|
|
102
|
+
onTap: () => {
|
|
103
|
+
this._dragging = !1;
|
|
104
|
+
},
|
|
105
|
+
onCancel: () => {
|
|
106
|
+
this._dragging = !1, this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0;
|
|
107
|
+
}
|
|
108
|
+
}), this._dragging = !0);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static {
|
|
112
|
+
this.styles = [b(s), b(g)];
|
|
113
|
+
}
|
|
114
|
+
get dialog() {
|
|
115
|
+
return this.shadowRoot?.querySelector("dialog") ?? null;
|
|
116
|
+
}
|
|
117
|
+
get _stage() {
|
|
118
|
+
return this.shadowRoot?.querySelector(".wui-image-preview-stage") ?? null;
|
|
119
|
+
}
|
|
120
|
+
get _image() {
|
|
121
|
+
return this.shadowRoot?.querySelector(".wui-image-preview-slide.is-current .wui-image-preview-image") ?? null;
|
|
122
|
+
}
|
|
123
|
+
get index() {
|
|
124
|
+
return this._index;
|
|
125
|
+
}
|
|
126
|
+
get scale() {
|
|
127
|
+
return this._scale;
|
|
128
|
+
}
|
|
129
|
+
configure(e) {
|
|
130
|
+
this.images = e.images, this.loop = e.loop, this.nav = e.nav, this.toolbar = e.toolbar, this.closable = e.closable, this.indicator = e.indicator, this.swipe = e.swipe, this.noScrollLock = e.noScrollLock, this.noBackdropClose = e.noBackdropClose, this._index = m(e.index, 0, Math.max(0, e.images.length - 1));
|
|
131
|
+
}
|
|
132
|
+
show() {
|
|
133
|
+
this._open ||= (this._dismissed = !1, !0);
|
|
134
|
+
}
|
|
135
|
+
close() {
|
|
136
|
+
this._open &&= (this._endGesture(), !1);
|
|
137
|
+
}
|
|
138
|
+
goTo(e) {
|
|
139
|
+
let t = this.images.length;
|
|
140
|
+
if (t === 0) return;
|
|
141
|
+
let n = this.loop ? (e % t + t) % t : m(e, 0, t - 1);
|
|
142
|
+
n !== this._index && (this._index = n, this.resetZoom());
|
|
143
|
+
}
|
|
144
|
+
next() {
|
|
145
|
+
this.goTo(this._index + 1);
|
|
146
|
+
}
|
|
147
|
+
prev() {
|
|
148
|
+
this.goTo(this._index - 1);
|
|
149
|
+
}
|
|
150
|
+
zoomIn() {
|
|
151
|
+
this._setScale(this._scale + O);
|
|
152
|
+
}
|
|
153
|
+
zoomOut() {
|
|
154
|
+
this._setScale(this._scale - O);
|
|
155
|
+
}
|
|
156
|
+
resetZoom() {
|
|
157
|
+
(this._scale !== E || this._offsetX !== 0 || this._offsetY !== 0) && (this._scale = E, this._offsetX = 0, this._offsetY = 0);
|
|
158
|
+
}
|
|
159
|
+
firstUpdated() {
|
|
160
|
+
let e = this._stage;
|
|
161
|
+
e && (this._pinch = h(e, {
|
|
162
|
+
onStart: this._handlePinchStart,
|
|
163
|
+
onMove: this._handlePinchMove,
|
|
164
|
+
onEnd: this._handlePinchEnd,
|
|
165
|
+
onCancel: this._handlePinchCancel
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
updated(e) {
|
|
169
|
+
super.updated(e), this.isConnected && (e.has("_open") && (this._presence.sync(this._open), !this._open && !this.dialog?.open && queueMicrotask(() => this._notifyDismissed())), (e.has("_open") || e.has("noScrollLock")) && this._syncScrollLock());
|
|
170
|
+
}
|
|
171
|
+
disconnectedCallback() {
|
|
172
|
+
super.disconnectedCallback(), this._endGesture(), this._pinch?.destroy(), this._pinch = void 0, this._presence.dispose(), this._scrollLock.release();
|
|
173
|
+
}
|
|
174
|
+
_syncScrollLock() {
|
|
175
|
+
this._scrollLock.sync(this._open && !this.noScrollLock);
|
|
176
|
+
}
|
|
177
|
+
_notifyDismissed() {
|
|
178
|
+
this._dismissed || this._open || (this._dismissed = !0, this.dispatchEvent(new CustomEvent("preview-dismissed")));
|
|
179
|
+
}
|
|
180
|
+
_zoomAt(e, t, n) {
|
|
181
|
+
let r = m(e, E, D);
|
|
182
|
+
if (r === this._scale) return;
|
|
183
|
+
let i = r / this._scale;
|
|
184
|
+
this._applyScale(r, t - (t - this._offsetX) * i, n - (n - this._offsetY) * i);
|
|
185
|
+
}
|
|
186
|
+
_applyScale(e, t, n) {
|
|
187
|
+
if (this._scale = e, e === E) {
|
|
188
|
+
this._offsetX = 0, this._offsetY = 0;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this._offsetX = t, this._offsetY = n, this._clampOffsets();
|
|
192
|
+
}
|
|
193
|
+
_setScale(e) {
|
|
194
|
+
this._zoomAt(e, 0, 0);
|
|
195
|
+
}
|
|
196
|
+
_stageOrigin() {
|
|
197
|
+
let e = this._stage;
|
|
198
|
+
if (!e) return {
|
|
199
|
+
x: 0,
|
|
200
|
+
y: 0
|
|
201
|
+
};
|
|
202
|
+
let t = e.getBoundingClientRect();
|
|
203
|
+
return {
|
|
204
|
+
x: t.left + t.width / 2,
|
|
205
|
+
y: t.top + t.height / 2
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
_offsetBounds() {
|
|
209
|
+
let e = this._stage, t = this._image;
|
|
210
|
+
if (!e || !t) return {
|
|
211
|
+
x: 0,
|
|
212
|
+
y: 0
|
|
213
|
+
};
|
|
214
|
+
let n = t.offsetWidth, r = t.offsetHeight;
|
|
215
|
+
return !n || !r ? {
|
|
216
|
+
x: 0,
|
|
217
|
+
y: 0
|
|
218
|
+
} : {
|
|
219
|
+
x: Math.abs(n * this._scale - e.clientWidth) / 2,
|
|
220
|
+
y: Math.abs(r * this._scale - e.clientHeight) / 2
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
get _isPanned() {
|
|
224
|
+
return this._offsetX !== 0 || this._offsetY !== 0;
|
|
225
|
+
}
|
|
226
|
+
_clampOffsets() {
|
|
227
|
+
let e = this._offsetBounds();
|
|
228
|
+
this._offsetX = m(this._offsetX, -e.x, e.x), this._offsetY = m(this._offsetY, -e.y, e.y);
|
|
229
|
+
}
|
|
230
|
+
_isBlank(e) {
|
|
231
|
+
return e === this.dialog || e === this._stage;
|
|
232
|
+
}
|
|
233
|
+
_endGesture() {
|
|
234
|
+
this._gesture?.destroy(), this._gesture = void 0, this._dragging = !1, this._cancelSwipeSettle(), this._swipeDir = 0, this._swipeOffset = 0;
|
|
235
|
+
}
|
|
236
|
+
_adjacentIndex(e) {
|
|
237
|
+
let t = this.images.length;
|
|
238
|
+
if (t === 0) return -1;
|
|
239
|
+
if (this.loop) return ((this._index + e) % t + t) % t;
|
|
240
|
+
let n = this._index + e;
|
|
241
|
+
return n >= 0 && n < t ? n : -1;
|
|
242
|
+
}
|
|
243
|
+
_cancelSwipeSettle() {
|
|
244
|
+
this._swipeSettleTimer !== void 0 && (clearTimeout(this._swipeSettleTimer), this._swipeSettleTimer = void 0), this._swipeSettling = !1, this._swipeSettleCommit = !1, this._swipeSettleDir = 1;
|
|
245
|
+
}
|
|
246
|
+
_finishSwipeSettle() {
|
|
247
|
+
if (this._swipeSettleTimer === void 0) return;
|
|
248
|
+
clearTimeout(this._swipeSettleTimer), this._swipeSettleTimer = void 0;
|
|
249
|
+
let e = this._swipeSettleCommit, t = this._swipeSettleDir;
|
|
250
|
+
this._swipeSettling = !1, this._swipeSettleCommit = !1, this._swipeDir = 0, this._swipeOffset = 0, e && this._commitSwipeTo(t);
|
|
251
|
+
}
|
|
252
|
+
_commitSwipeTo(e) {
|
|
253
|
+
let t = this._adjacentIndex(e);
|
|
254
|
+
t < 0 || t === this._index || (this._index = t, this.resetZoom());
|
|
255
|
+
}
|
|
256
|
+
_settleSwipe(e, t, n) {
|
|
257
|
+
let r = this._swipeDir, i = this._stage?.clientWidth ?? 0;
|
|
258
|
+
if (r === 0 || i <= 0) {
|
|
259
|
+
this._swipeOffset = 0;
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
let a = Math.max(1, Math.round(i * j)), o = n - this._swipeStartTime, s = o >= 2 ? e / o * 1e3 : 0, c = (Math.abs(e) >= a || Math.abs(t) >= M || Math.abs(e) >= N && Math.max(Math.abs(t), Math.abs(s)) >= P) && this._adjacentIndex(r) !== -1;
|
|
263
|
+
this._swipeSettling = !0, this._swipeSettleCommit = c, this._swipeSettleDir = r, this._swipeOffset = c ? -r * i : 0, this._swipeSettleTimer = setTimeout(() => this._finishSwipeSettle(), F);
|
|
264
|
+
}
|
|
265
|
+
_panTo(e, t) {
|
|
266
|
+
let n = this._offsetBounds();
|
|
267
|
+
this._offsetX = m(this._panOriginX + e, -n.x, n.x), this._offsetY = m(this._panOriginY + t, -n.y, n.y);
|
|
268
|
+
}
|
|
269
|
+
render() {
|
|
270
|
+
let e = this.images.length, s = this._scale > E, c = e > 0 ? this._adjacentIndex(-1) : -1, l = e > 0 ? this._adjacentIndex(1) : -1, u = `translate3d(${this._swipeOffset}px, 0, 0)`, d = `translate3d(${this._offsetX}px, ${this._offsetY}px, 0) scale(${this._scale})`, f = s ? "translate3d(0, 0, 0) scale(1)" : `translate3d(0, ${this._offsetY}px, 0) scale(1)`;
|
|
271
|
+
return v`
|
|
272
|
+
<dialog
|
|
273
|
+
aria-label="图片预览"
|
|
274
|
+
@cancel=${this._handleCancel}
|
|
275
|
+
@close=${this._handleNativeClose}
|
|
276
|
+
@pointerdown=${this._handlePointerDown}
|
|
277
|
+
@click=${this._handleClick}
|
|
278
|
+
@dblclick=${this._handleDoubleClick}
|
|
279
|
+
@keydown=${this._handleKeydown}
|
|
280
|
+
@wheel=${this._handleWheel}
|
|
281
|
+
@transitionend=${this._handleTransitionEnd}
|
|
282
|
+
>
|
|
283
|
+
<div class="wui-image-preview-backdrop" aria-hidden="true"></div>
|
|
284
|
+
<div class="wui-image-preview-content">
|
|
285
|
+
<div class="wui-image-preview-surface">
|
|
286
|
+
<div
|
|
287
|
+
class=${w({
|
|
288
|
+
"wui-image-preview-stage": !0,
|
|
289
|
+
"is-zoomed": s,
|
|
290
|
+
"is-dragging": this._dragging,
|
|
291
|
+
"is-settling": this._swipeSettling
|
|
292
|
+
})}
|
|
293
|
+
>
|
|
294
|
+
<div
|
|
295
|
+
class="wui-image-preview-track"
|
|
296
|
+
style=${T({ transform: u })}
|
|
297
|
+
@transitionend=${this._handleSwipeSettleEnd}
|
|
298
|
+
>
|
|
299
|
+
${c >= 0 ? v`
|
|
300
|
+
<div class="wui-image-preview-slide is-prev" aria-hidden="true">
|
|
301
|
+
<img
|
|
302
|
+
class=${w({
|
|
303
|
+
"wui-image-preview-image": !0,
|
|
304
|
+
"is-loaded": this._loadedSources.has(this.images[c].src)
|
|
305
|
+
})}
|
|
306
|
+
src=${this.images[c].src}
|
|
307
|
+
alt=${this.images[c].alt ?? ""}
|
|
308
|
+
draggable="false"
|
|
309
|
+
style=${T({ transform: f })}
|
|
310
|
+
@load=${this._handleImageSettled}
|
|
311
|
+
@error=${this._handleImageSettled}
|
|
312
|
+
/>
|
|
313
|
+
</div>
|
|
314
|
+
` : y}
|
|
315
|
+
${e > 0 ? v`
|
|
316
|
+
<div class="wui-image-preview-slide is-current">
|
|
317
|
+
<img
|
|
318
|
+
class=${w({
|
|
319
|
+
"wui-image-preview-image": !0,
|
|
320
|
+
"is-loaded": this._loadedSources.has(this.images[this._index].src)
|
|
321
|
+
})}
|
|
322
|
+
src=${this.images[this._index].src}
|
|
323
|
+
alt=${this.images[this._index].alt ?? ""}
|
|
324
|
+
draggable="false"
|
|
325
|
+
style=${T({ transform: d })}
|
|
326
|
+
@load=${this._handleImageSettled}
|
|
327
|
+
@error=${this._handleImageSettled}
|
|
328
|
+
/>
|
|
329
|
+
</div>
|
|
330
|
+
` : y}
|
|
331
|
+
${l >= 0 ? v`
|
|
332
|
+
<div class="wui-image-preview-slide is-next" aria-hidden="true">
|
|
333
|
+
<img
|
|
334
|
+
class=${w({
|
|
335
|
+
"wui-image-preview-image": !0,
|
|
336
|
+
"is-loaded": this._loadedSources.has(this.images[l].src)
|
|
337
|
+
})}
|
|
338
|
+
src=${this.images[l].src}
|
|
339
|
+
alt=${this.images[l].alt ?? ""}
|
|
340
|
+
draggable="false"
|
|
341
|
+
style=${T({ transform: f })}
|
|
342
|
+
@load=${this._handleImageSettled}
|
|
343
|
+
@error=${this._handleImageSettled}
|
|
344
|
+
/>
|
|
345
|
+
</div>
|
|
346
|
+
` : y}
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
<div class="wui-image-preview-controls">
|
|
351
|
+
${this.indicator ? v`<span class="wui-image-preview-counter wui-glass" aria-live="polite"
|
|
352
|
+
>${this._index + 1} / ${e}</span
|
|
353
|
+
>` : y}
|
|
354
|
+
${this.closable ? v`
|
|
355
|
+
<web-ui-button
|
|
356
|
+
class="wui-image-preview-close"
|
|
357
|
+
variant="glass"
|
|
358
|
+
icon
|
|
359
|
+
size="36"
|
|
360
|
+
aria-label="关闭"
|
|
361
|
+
@click=${this.close}
|
|
362
|
+
>
|
|
363
|
+
<web-ui-icon size="16" .icon=${a}></web-ui-icon>
|
|
364
|
+
</web-ui-button>
|
|
365
|
+
` : y}
|
|
366
|
+
${this.nav && e > 1 ? v`
|
|
367
|
+
<web-ui-button
|
|
368
|
+
class="wui-image-preview-nav wui-image-preview-nav-prev"
|
|
369
|
+
variant="glass"
|
|
370
|
+
icon
|
|
371
|
+
size="44"
|
|
372
|
+
aria-label="上一张"
|
|
373
|
+
?disabled=${!this.loop && this._index === 0}
|
|
374
|
+
@click=${this.prev}
|
|
375
|
+
>
|
|
376
|
+
<web-ui-icon size="20" .icon=${t}></web-ui-icon>
|
|
377
|
+
</web-ui-button>
|
|
378
|
+
<web-ui-button
|
|
379
|
+
class="wui-image-preview-nav wui-image-preview-nav-next"
|
|
380
|
+
variant="glass"
|
|
381
|
+
icon
|
|
382
|
+
size="44"
|
|
383
|
+
aria-label="下一张"
|
|
384
|
+
?disabled=${!this.loop && this._index === e - 1}
|
|
385
|
+
@click=${this.next}
|
|
386
|
+
>
|
|
387
|
+
<web-ui-icon size="20" .icon=${n}></web-ui-icon>
|
|
388
|
+
</web-ui-button>
|
|
389
|
+
` : y}
|
|
390
|
+
${this.toolbar ? v`
|
|
391
|
+
<div class="wui-image-preview-toolbar wui-glass">
|
|
392
|
+
<web-ui-button
|
|
393
|
+
variant="glass"
|
|
394
|
+
icon
|
|
395
|
+
size="30"
|
|
396
|
+
aria-label="缩小"
|
|
397
|
+
?disabled=${this._scale <= E}
|
|
398
|
+
@click=${this.zoomOut}
|
|
399
|
+
>
|
|
400
|
+
<web-ui-icon size="16" .icon=${i}></web-ui-icon>
|
|
401
|
+
</web-ui-button>
|
|
402
|
+
<span class="wui-image-preview-scale">${Math.round(this._scale * 100)}%</span>
|
|
403
|
+
<web-ui-button
|
|
404
|
+
variant="glass"
|
|
405
|
+
icon
|
|
406
|
+
size="30"
|
|
407
|
+
aria-label="放大"
|
|
408
|
+
?disabled=${this._scale >= D}
|
|
409
|
+
@click=${this.zoomIn}
|
|
410
|
+
>
|
|
411
|
+
<web-ui-icon size="16" .icon=${r}></web-ui-icon>
|
|
412
|
+
</web-ui-button>
|
|
413
|
+
<web-ui-button
|
|
414
|
+
variant="glass"
|
|
415
|
+
icon
|
|
416
|
+
size="30"
|
|
417
|
+
aria-label="重置缩放"
|
|
418
|
+
?disabled=${this._scale <= E && !this._isPanned}
|
|
419
|
+
@click=${this.resetZoom}
|
|
420
|
+
>
|
|
421
|
+
<web-ui-icon size="16" .icon=${o}></web-ui-icon>
|
|
422
|
+
</web-ui-button>
|
|
423
|
+
</div>
|
|
424
|
+
` : y}
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
</dialog>
|
|
428
|
+
`;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
e([S({ attribute: !1 })], I.prototype, "images", void 0), e([S({ attribute: !1 })], I.prototype, "loop", void 0), e([S({ attribute: !1 })], I.prototype, "nav", void 0), e([S({ attribute: !1 })], I.prototype, "toolbar", void 0), e([S({ attribute: !1 })], I.prototype, "closable", void 0), e([S({ attribute: !1 })], I.prototype, "indicator", void 0), e([S({ attribute: !1 })], I.prototype, "swipe", void 0), e([S({ attribute: !1 })], I.prototype, "noScrollLock", void 0), e([S({ attribute: !1 })], I.prototype, "noBackdropClose", void 0), e([C()], I.prototype, "_open", void 0), e([C()], I.prototype, "_index", void 0), e([C()], I.prototype, "_scale", void 0), e([C()], I.prototype, "_offsetX", void 0), e([C()], I.prototype, "_offsetY", void 0), e([C()], I.prototype, "_swipeOffset", void 0), e([C()], I.prototype, "_swipeSettling", void 0), e([C()], I.prototype, "_dragging", void 0), I = e([x("web-ui-image-preview")], I);
|
|
432
|
+
function L(e) {
|
|
433
|
+
let t = (e.images ?? []).map((e) => ({
|
|
434
|
+
src: e.src,
|
|
435
|
+
alt: e.alt ?? ""
|
|
436
|
+
}));
|
|
437
|
+
if (t.length === 0) throw Error("[web-ui-image-preview] imagePreview requires at least one image");
|
|
438
|
+
let n = e.target ? l(e.target) : u(), r = e.container ?? n?.getOverlayRoot() ?? c(), i = document.createElement("web-ui-image-preview");
|
|
439
|
+
i.configure({
|
|
440
|
+
images: t,
|
|
441
|
+
index: e.index ?? 0,
|
|
442
|
+
loop: e.loop ?? !0,
|
|
443
|
+
nav: e.nav ?? !1,
|
|
444
|
+
toolbar: e.toolbar ?? !1,
|
|
445
|
+
closable: e.closable ?? !1,
|
|
446
|
+
indicator: e.indicator ?? !1,
|
|
447
|
+
swipe: e.swipe ?? !1,
|
|
448
|
+
noScrollLock: e.noScrollLock ?? !1,
|
|
449
|
+
noBackdropClose: e.noBackdropClose ?? !1
|
|
450
|
+
});
|
|
451
|
+
let a, o = new Promise((e) => {
|
|
452
|
+
a = e;
|
|
453
|
+
});
|
|
454
|
+
return i.addEventListener("preview-dismissed", () => {
|
|
455
|
+
i.remove(), a?.(), a = void 0;
|
|
456
|
+
}, { once: !0 }), r.appendChild(i), i.show(), {
|
|
457
|
+
get index() {
|
|
458
|
+
return i.index;
|
|
459
|
+
},
|
|
460
|
+
get scale() {
|
|
461
|
+
return i.scale;
|
|
462
|
+
},
|
|
463
|
+
get images() {
|
|
464
|
+
return i.images;
|
|
465
|
+
},
|
|
466
|
+
get closed() {
|
|
467
|
+
return o;
|
|
468
|
+
},
|
|
469
|
+
next: () => i.next(),
|
|
470
|
+
prev: () => i.prev(),
|
|
471
|
+
goTo: (e) => i.goTo(e),
|
|
472
|
+
zoomIn: () => i.zoomIn(),
|
|
473
|
+
zoomOut: () => i.zoomOut(),
|
|
474
|
+
resetZoom: () => i.resetZoom(),
|
|
475
|
+
close: () => i.close()
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
export { L as imagePreview };
|
|
480
|
+
|
|
481
|
+
//# sourceMappingURL=index.js.map
|