@cos-design/weather-background 3.5.4 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +272 -262
- package/dist/packages/shared/src/index.d.ts +10 -3
- package/dist/packages/shared/src/math.d.ts +1 -0
- package/dist/packages/shared/src/photo.d.ts +15 -0
- package/dist/packages/shared/src/pointer.d.ts +14 -0
- package/dist/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/packages/shared/src/size.d.ts +8 -0
- package/dist/packages/shared/src/use-element-size.d.ts +45 -0
- package/dist/packages/shared/src/visibility.d.ts +2 -0
- package/dist/src/components/weatherBackground/types.d.ts +6 -0
- package/package.json +2 -2
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { clamp } from './math';
|
|
2
|
+
export { bindVisibilityPause } from './visibility';
|
|
3
|
+
export { prefersReducedMotion, bindPrefersReducedMotion } from './reduced-motion';
|
|
4
|
+
export { observeElementSize } from './size';
|
|
5
|
+
export type { ElementSize } from './size';
|
|
6
|
+
export { getRelativePointerPosition } from './pointer';
|
|
7
|
+
export type { PointerPosition } from './pointer';
|
|
8
|
+
export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from './photo';
|
|
9
|
+
export { useElementSize, resolveCanvasBoxSize, useCanvasBox } from './use-element-size';
|
|
10
|
+
export type { UseElementSizeOptions, CanvasBoxSizeInput, CanvasBoxSize, UseCanvasBoxOptions, UseCanvasBoxResult } from './use-element-size';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 图片预览组件通用照片项 */
|
|
2
|
+
export interface PhotoItem {
|
|
3
|
+
/** 图片地址 */
|
|
4
|
+
src: string;
|
|
5
|
+
/** 图片替代文本 */
|
|
6
|
+
alt?: string;
|
|
7
|
+
/** 照片标题 */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** 照片说明 */
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 线性浏览:当前索引变化(相册 / 胶卷 / 晾绳等) */
|
|
13
|
+
export type PhotoIndexChangeHandler<T = PhotoItem> = (index: number, photo: T) => void;
|
|
14
|
+
/** 环形浏览:正对镜头的面变化(走马灯 / 旋转木马等) */
|
|
15
|
+
export type PhotoFaceChangeHandler<T = PhotoItem> = (index: number, photo?: T) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PointerPosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
type PointLike = {
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
};
|
|
9
|
+
/** 相对元素左上角的指针坐标(兼容 mouse / touch / pointer) */
|
|
10
|
+
export declare const getRelativePointerPosition: (element: Element, event: PointLike | {
|
|
11
|
+
touches?: ArrayLike<PointLike>;
|
|
12
|
+
changedTouches?: ArrayLike<PointLike>;
|
|
13
|
+
}) => PointerPosition | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { ElementSize } from './size';
|
|
3
|
+
export interface UseElementSizeOptions {
|
|
4
|
+
/** 为 false 时不观察 */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** 观察元素尺寸(clientWidth / clientHeight) */
|
|
8
|
+
export declare const useElementSize: <T extends Element>(ref: RefObject<T | null>, options?: UseElementSizeOptions) => ElementSize;
|
|
9
|
+
export interface CanvasBoxSizeInput {
|
|
10
|
+
/** 为 true 时跟随父容器尺寸(需父级有明确高度) */
|
|
11
|
+
fill?: boolean;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
defaultWidth: number;
|
|
15
|
+
defaultHeight: number;
|
|
16
|
+
measured: ElementSize;
|
|
17
|
+
}
|
|
18
|
+
export interface CanvasBoxSize {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
22
|
+
pending: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** 根据 fill / 显式宽高 / 测量结果解析画布逻辑尺寸 */
|
|
25
|
+
export declare const resolveCanvasBoxSize: ({ fill, width, height, defaultWidth, defaultHeight, measured }: CanvasBoxSizeInput) => CanvasBoxSize;
|
|
26
|
+
export interface UseCanvasBoxOptions {
|
|
27
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
28
|
+
fill?: boolean;
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
defaultWidth: number;
|
|
32
|
+
defaultHeight: number;
|
|
33
|
+
}
|
|
34
|
+
export interface UseCanvasBoxResult {
|
|
35
|
+
hostRef: RefObject<HTMLDivElement | null>;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
/** 挂到宿主容器的样式(fill 时为 100%×100%) */
|
|
39
|
+
hostStyle: CSSProperties;
|
|
40
|
+
fill: boolean;
|
|
41
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
42
|
+
pending: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** 画布/效果宿主尺寸:fill 时跟随父容器,否则用显式宽高或默认值 */
|
|
45
|
+
export declare const useCanvasBox: ({ fill, width: widthProp, height: heightProp, defaultWidth, defaultHeight }: UseCanvasBoxOptions) => UseCanvasBoxResult;
|
|
@@ -22,6 +22,8 @@ export type WeatherType = 'sunny' | 'partlyCloudy' | 'overcast'
|
|
|
22
22
|
export interface WeatherBackgroundProps {
|
|
23
23
|
width?: number;
|
|
24
24
|
height?: number;
|
|
25
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
26
|
+
fill?: boolean;
|
|
25
27
|
/** 天气类型:sunny / partlyCloudy / overcast / rain 雨天 / thunderstorm / fog / snow 雪天 / sleet / hail / smog;雨量用 rainLevel,雪量用 snowLevel,风效用 windLevel */
|
|
26
28
|
weather?: WeatherType;
|
|
27
29
|
/**
|
|
@@ -51,6 +53,10 @@ export interface WeatherBackgroundProps {
|
|
|
51
53
|
onLiveWeather?: (weather: WeatherType) => void;
|
|
52
54
|
/** 外部受控 loading:在当前画面上叠加加载遮罩(live 模式定位/请求期间会自动显示,无需传入) */
|
|
53
55
|
loading?: boolean;
|
|
56
|
+
/** 画布无障碍标签;不传时使用默认中文描述 */
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
/** 加载状态文案 */
|
|
59
|
+
loadingText?: string;
|
|
54
60
|
}
|
|
55
61
|
export interface WeatherConfig {
|
|
56
62
|
sky: [string, string];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cos-design/weather-background",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.6",
|
|
4
4
|
"description": "WeatherBackground component from cos-design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"registry": "https://registry.npmjs.org"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@cos-design/shared": "3.5.
|
|
55
|
+
"@cos-design/shared": "3.5.6"
|
|
56
56
|
}
|
|
57
57
|
}
|