@cos-design/radar-scan 3.5.3 → 4.0.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/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +60 -0
- package/dist/core/packages/radarScan/src/core.d.ts +1 -0
- package/dist/core/packages/radarScan/src/element.d.ts +1 -0
- package/dist/core/packages/radarScan/src/react.d.ts +3 -0
- package/dist/core/packages/radarScan/src/vue.d.ts +2 -0
- package/dist/core/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/core/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/core/packages/shared/src/index.d.ts +11 -0
- package/dist/core/packages/shared/src/math.d.ts +2 -0
- package/dist/core/packages/shared/src/photo.d.ts +15 -0
- package/dist/core/packages/shared/src/pointer.d.ts +14 -0
- package/dist/core/packages/shared/src/react/index.d.ts +30 -0
- package/dist/core/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/core/packages/shared/src/size.d.ts +8 -0
- package/dist/{packages/shared/src/index.d.ts → core/packages/shared/src/visibility.d.ts} +0 -1
- package/dist/core/src/components/radarScan/core/engine.d.ts +2 -0
- package/dist/core/src/components/radarScan/core/index.d.ts +2 -0
- package/dist/core/src/components/radarScan/core/types.d.ts +10 -0
- package/dist/core/src/components/radarScan/element/index.d.ts +9 -0
- package/dist/core/src/components/radarScan/index.d.ts +3 -0
- package/dist/core/src/components/radarScan/react/index.d.ts +4 -0
- package/dist/{src → core/src}/vite-env.d.ts +6 -0
- package/dist/element/element.css +1 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +87 -0
- package/dist/element/packages/radarScan/src/core.d.ts +1 -0
- package/dist/element/packages/radarScan/src/element.d.ts +1 -0
- package/dist/element/packages/radarScan/src/index.d.ts +3 -0
- package/dist/element/packages/radarScan/src/react.d.ts +3 -0
- package/dist/element/packages/radarScan/src/vue.d.ts +2 -0
- package/dist/element/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/element/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/element/packages/shared/src/index.d.ts +11 -0
- package/dist/element/packages/shared/src/math.d.ts +2 -0
- package/dist/element/packages/shared/src/photo.d.ts +15 -0
- package/dist/element/packages/shared/src/pointer.d.ts +14 -0
- package/dist/element/packages/shared/src/react/index.d.ts +30 -0
- package/dist/element/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/element/packages/shared/src/size.d.ts +8 -0
- package/dist/element/packages/shared/src/visibility.d.ts +2 -0
- package/dist/element/src/components/radarScan/core/engine.d.ts +2 -0
- package/dist/element/src/components/radarScan/core/index.d.ts +2 -0
- package/dist/element/src/components/radarScan/core/types.d.ts +10 -0
- package/dist/element/src/components/radarScan/element/index.d.ts +9 -0
- package/dist/element/src/components/radarScan/index.d.ts +3 -0
- package/dist/element/src/components/radarScan/react/index.d.ts +4 -0
- package/dist/element/src/vite-env.d.ts +45 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +83 -0
- package/dist/react/packages/radarScan/src/core.d.ts +1 -0
- package/dist/react/packages/radarScan/src/element.d.ts +1 -0
- package/dist/react/packages/radarScan/src/index.d.ts +3 -0
- package/dist/react/packages/radarScan/src/react.d.ts +3 -0
- package/dist/react/packages/radarScan/src/vue.d.ts +2 -0
- package/dist/react/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/react/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/react/packages/shared/src/index.d.ts +11 -0
- package/dist/react/packages/shared/src/math.d.ts +2 -0
- package/dist/react/packages/shared/src/photo.d.ts +15 -0
- package/dist/react/packages/shared/src/pointer.d.ts +14 -0
- package/dist/react/packages/shared/src/react/index.d.ts +30 -0
- package/dist/react/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/react/packages/shared/src/size.d.ts +8 -0
- package/dist/react/packages/shared/src/visibility.d.ts +2 -0
- package/dist/react/react.css +1 -0
- package/dist/react/src/components/radarScan/core/engine.d.ts +2 -0
- package/dist/react/src/components/radarScan/core/index.d.ts +2 -0
- package/dist/react/src/components/radarScan/core/types.d.ts +10 -0
- package/dist/react/src/components/radarScan/element/index.d.ts +9 -0
- package/dist/react/src/components/radarScan/index.d.ts +3 -0
- package/dist/react/src/components/radarScan/react/index.d.ts +4 -0
- package/dist/react/src/vite-env.d.ts +45 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +83 -0
- package/dist/vue/packages/radarScan/src/core.d.ts +1 -0
- package/dist/vue/packages/radarScan/src/element.d.ts +1 -0
- package/dist/vue/packages/radarScan/src/index.d.ts +3 -0
- package/dist/vue/packages/radarScan/src/react.d.ts +3 -0
- package/dist/vue/packages/radarScan/src/vue.d.ts +2 -0
- package/dist/vue/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/vue/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/vue/packages/shared/src/index.d.ts +11 -0
- package/dist/vue/packages/shared/src/math.d.ts +2 -0
- package/dist/vue/packages/shared/src/photo.d.ts +15 -0
- package/dist/vue/packages/shared/src/pointer.d.ts +14 -0
- package/dist/vue/packages/shared/src/react/index.d.ts +30 -0
- package/dist/vue/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/vue/packages/shared/src/size.d.ts +8 -0
- package/dist/vue/packages/shared/src/visibility.d.ts +2 -0
- package/dist/vue/src/components/radarScan/core/engine.d.ts +2 -0
- package/dist/vue/src/components/radarScan/core/index.d.ts +2 -0
- package/dist/vue/src/components/radarScan/core/types.d.ts +10 -0
- package/dist/vue/src/components/radarScan/element/index.d.ts +9 -0
- package/dist/vue/src/components/radarScan/index.d.ts +3 -0
- package/dist/vue/src/components/radarScan/react/index.d.ts +4 -0
- package/dist/vue/src/vite-env.d.ts +45 -0
- package/dist/vue/vue.css +1 -0
- package/package.json +43 -11
- package/dist/index.cjs +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -60
- package/dist/src/components/radarScan/index.d.ts +0 -9
- /package/dist/{packages → core/packages}/radarScan/src/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/components/radarScan/core';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { bindVisibilityPause as e } from "@cos-design/shared";
|
|
2
|
+
//#region src/components/radarScan/core/engine.ts
|
|
3
|
+
var t = "cos-radar-scan";
|
|
4
|
+
function n(n, r = {}) {
|
|
5
|
+
let i = {
|
|
6
|
+
size: 300,
|
|
7
|
+
color: "#22d3ee",
|
|
8
|
+
blipCount: 5,
|
|
9
|
+
...r
|
|
10
|
+
}, a = !1, o = i.size ?? 300, s = 0, c = 0, l = typeof document < "u" ? document.hidden : !1, u = null, d = [], f = document.createElement("div");
|
|
11
|
+
f.className = t;
|
|
12
|
+
let p = document.createElement("canvas");
|
|
13
|
+
p.className = `${t}__canvas`, f.appendChild(p), n.appendChild(f);
|
|
14
|
+
let m = () => {
|
|
15
|
+
d.length = 0;
|
|
16
|
+
let e = i.blipCount ?? 5;
|
|
17
|
+
for (let t = 0; t < e; t++) d.push({
|
|
18
|
+
angle: Math.random() * Math.PI * 2,
|
|
19
|
+
dist: Math.random() * .7 + .15,
|
|
20
|
+
alpha: Math.random() * .5 + .5
|
|
21
|
+
});
|
|
22
|
+
}, h = () => {
|
|
23
|
+
o = i.size ?? 300, f.style.width = `${o}px`, f.style.height = `${o}px`, p.style.width = `${o}px`, p.style.height = `${o}px`;
|
|
24
|
+
}, g = () => {
|
|
25
|
+
let e = window.devicePixelRatio || 1;
|
|
26
|
+
p.width = o * e, p.height = o * e;
|
|
27
|
+
let t = p.getContext("2d");
|
|
28
|
+
return t && t.setTransform(e, 0, 0, e, 0, 0), t;
|
|
29
|
+
}, _ = () => {
|
|
30
|
+
if (a || (s = requestAnimationFrame(_), l)) return;
|
|
31
|
+
let e = p.getContext("2d");
|
|
32
|
+
if (!e) return;
|
|
33
|
+
let t = i.color ?? "#22d3ee", n = o / 2, r = o / 2, u = o / 2 - 10;
|
|
34
|
+
c += .03, e.fillStyle = "rgb(15 23 42 / 25%)", e.fillRect(0, 0, o, o);
|
|
35
|
+
for (let i = 1; i <= 4; i++) e.beginPath(), e.arc(n, r, u / 4 * i, 0, Math.PI * 2), e.strokeStyle = `${t}33`, e.lineWidth = 1, e.stroke();
|
|
36
|
+
e.beginPath(), e.moveTo(n, r - u), e.lineTo(n, r + u), e.moveTo(n - u, r), e.lineTo(n + u, r), e.strokeStyle = `${t}44`, e.stroke();
|
|
37
|
+
let f = c, m = e.createConicGradient(f - .5, n, r);
|
|
38
|
+
m.addColorStop(0, "transparent"), m.addColorStop(.15, `${t}66`), m.addColorStop(.3, "transparent"), e.beginPath(), e.moveTo(n, r), e.arc(n, r, u, f - .5, f), e.closePath(), e.fillStyle = m, e.fill(), e.beginPath(), e.moveTo(n, r), e.lineTo(n + Math.cos(f) * u, r + Math.sin(f) * u), e.strokeStyle = t, e.lineWidth = 2, e.stroke();
|
|
39
|
+
for (let i of d) {
|
|
40
|
+
let a = n + Math.cos(i.angle) * u * i.dist, o = r + Math.sin(i.angle) * u * i.dist;
|
|
41
|
+
Math.abs((f - i.angle + Math.PI) % (Math.PI * 2) - Math.PI) < .3 ? i.alpha = Math.min(1, i.alpha + .05) : i.alpha = Math.max(.2, i.alpha - .01), e.beginPath(), e.arc(a, o, 4, 0, Math.PI * 2), e.fillStyle = t, e.globalAlpha = i.alpha, e.fill(), e.globalAlpha = 1;
|
|
42
|
+
}
|
|
43
|
+
e.beginPath(), e.arc(n, r, u, 0, Math.PI * 2), e.strokeStyle = t, e.lineWidth = 2, e.stroke();
|
|
44
|
+
};
|
|
45
|
+
return h(), g(), m(), u = e((e) => {
|
|
46
|
+
l = e;
|
|
47
|
+
}), _(), {
|
|
48
|
+
update(e) {
|
|
49
|
+
i = {
|
|
50
|
+
...i,
|
|
51
|
+
...e
|
|
52
|
+
}, h(), g(), m();
|
|
53
|
+
},
|
|
54
|
+
destroy() {
|
|
55
|
+
a || (a = !0, cancelAnimationFrame(s), u?.(), f.remove());
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { n as createRadarScan };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/radarScan/core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/radarScan/element';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementSize } from './size';
|
|
2
|
+
export interface CanvasBoxSizeInput {
|
|
3
|
+
/** 为 true 时跟随父容器尺寸(需父级有明确高度) */
|
|
4
|
+
fill?: boolean;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
defaultWidth: number;
|
|
8
|
+
defaultHeight: number;
|
|
9
|
+
measured: ElementSize;
|
|
10
|
+
}
|
|
11
|
+
export interface CanvasBoxSize {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
15
|
+
pending: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** 根据 fill / 显式宽高 / 测量结果解析画布逻辑尺寸 */
|
|
18
|
+
export declare const resolveCanvasBoxSize: ({ fill, width, height, defaultWidth, defaultHeight, measured, }: CanvasBoxSizeInput) => CanvasBoxSize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Apply fill / explicit size to the adapter host and make the engine root fill it. */
|
|
2
|
+
export declare function applyCanvasHostBox(container: HTMLElement, root: HTMLElement, opts: {
|
|
3
|
+
fill: boolean;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}): void;
|
|
7
|
+
/**
|
|
8
|
+
* Size the adapter host (React/Vue div or custom element) so percentage widths
|
|
9
|
+
* don't collapse when the host is a shrink-wrapped flex child. Root fills the host
|
|
10
|
+
* unless `rootFillsHost` is false (e.g. PhotoAlbum sizes itself via CSS variables).
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyBlockHostBox(container: HTMLElement, root: HTMLElement, size: {
|
|
13
|
+
width?: number | string;
|
|
14
|
+
height?: number | string;
|
|
15
|
+
rootFillsHost?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
/** Toggle empty-state nodes; author `display:` rules must not override `[hidden]`. */
|
|
18
|
+
export declare function setHidden(el: HTMLElement, hidden: boolean): void;
|
|
19
|
+
/** Stable JSON key for options, ignoring functions (callbacks). */
|
|
20
|
+
export declare function optionsFingerprint(value: unknown): string;
|
|
21
|
+
/** True when non-function fields differ (shallow). */
|
|
22
|
+
export declare function optionsVisualChanged(prev: Record<string, unknown>, next: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { clamp, lerp } 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 { resolveCanvasBoxSize } from './canvas-box';
|
|
10
|
+
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
|
+
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
@@ -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,30 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { ElementSize } from '../size';
|
|
3
|
+
export type { CanvasBoxSize, CanvasBoxSizeInput } from '../canvas-box';
|
|
4
|
+
export { resolveCanvasBoxSize } from '../canvas-box';
|
|
5
|
+
export interface UseElementSizeOptions {
|
|
6
|
+
/** 为 false 时不观察 */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** 观察元素尺寸(clientWidth / clientHeight) */
|
|
10
|
+
export declare const useElementSize: <T extends Element>(ref: RefObject<T | null>, options?: UseElementSizeOptions) => ElementSize;
|
|
11
|
+
export interface UseCanvasBoxOptions {
|
|
12
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
defaultWidth: number;
|
|
17
|
+
defaultHeight: number;
|
|
18
|
+
}
|
|
19
|
+
export interface UseCanvasBoxResult {
|
|
20
|
+
hostRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
/** 挂到宿主容器的样式(fill 时为 100%×100%) */
|
|
24
|
+
hostStyle: CSSProperties;
|
|
25
|
+
fill: boolean;
|
|
26
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
27
|
+
pending: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** 画布/效果宿主尺寸:fill 时跟随父容器,否则用显式宽高或默认值 */
|
|
30
|
+
export declare const useCanvasBox: ({ fill, width: widthProp, height: heightProp, defaultWidth, defaultHeight, }: UseCanvasBoxOptions) => UseCanvasBoxResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RadarScanOptions {
|
|
2
|
+
size?: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
blipCount?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface RadarScanController {
|
|
7
|
+
update(options: Partial<RadarScanOptions>): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
export type RadarScanProps = RadarScanOptions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const TAG = "cos-radar-scan";
|
|
2
|
+
declare class CosRadarScanElement extends HTMLElement {
|
|
3
|
+
private ctrl;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
connectedCallback(): void;
|
|
6
|
+
disconnectedCallback(): void;
|
|
7
|
+
attributeChangedCallback(): void;
|
|
8
|
+
}
|
|
9
|
+
export { CosRadarScanElement, TAG };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue';
|
|
5
|
+
const component: DefineComponent<object, object, unknown>;
|
|
6
|
+
export default component;
|
|
7
|
+
}
|
|
8
|
+
|
|
3
9
|
declare module '*.module.less' {
|
|
4
10
|
const classes: { readonly [key: string]: string };
|
|
5
11
|
export default classes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cos-radarScan-host,cos-radar-scan{justify-content:center;width:100%;display:flex}.cos-radar-scan{background:radial-gradient(circle,#0f172a 0%,#020617 100%);border-radius:50%;margin-inline:auto;position:relative;overflow:hidden;box-shadow:0 0 40px #22d3ee26,inset 0 0 60px #00000080}.cos-radar-scan__canvas{display:block}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/components/radarScan/element';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { bindVisibilityPause as e } from "@cos-design/shared";
|
|
2
|
+
import './element.css';//#region src/components/radarScan/core/engine.ts
|
|
3
|
+
var t = "cos-radar-scan";
|
|
4
|
+
function n(n, r = {}) {
|
|
5
|
+
let i = {
|
|
6
|
+
size: 300,
|
|
7
|
+
color: "#22d3ee",
|
|
8
|
+
blipCount: 5,
|
|
9
|
+
...r
|
|
10
|
+
}, a = !1, o = i.size ?? 300, s = 0, c = 0, l = typeof document < "u" ? document.hidden : !1, u = null, d = [], f = document.createElement("div");
|
|
11
|
+
f.className = t;
|
|
12
|
+
let p = document.createElement("canvas");
|
|
13
|
+
p.className = `${t}__canvas`, f.appendChild(p), n.appendChild(f);
|
|
14
|
+
let m = () => {
|
|
15
|
+
d.length = 0;
|
|
16
|
+
let e = i.blipCount ?? 5;
|
|
17
|
+
for (let t = 0; t < e; t++) d.push({
|
|
18
|
+
angle: Math.random() * Math.PI * 2,
|
|
19
|
+
dist: Math.random() * .7 + .15,
|
|
20
|
+
alpha: Math.random() * .5 + .5
|
|
21
|
+
});
|
|
22
|
+
}, h = () => {
|
|
23
|
+
o = i.size ?? 300, f.style.width = `${o}px`, f.style.height = `${o}px`, p.style.width = `${o}px`, p.style.height = `${o}px`;
|
|
24
|
+
}, g = () => {
|
|
25
|
+
let e = window.devicePixelRatio || 1;
|
|
26
|
+
p.width = o * e, p.height = o * e;
|
|
27
|
+
let t = p.getContext("2d");
|
|
28
|
+
return t && t.setTransform(e, 0, 0, e, 0, 0), t;
|
|
29
|
+
}, _ = () => {
|
|
30
|
+
if (a || (s = requestAnimationFrame(_), l)) return;
|
|
31
|
+
let e = p.getContext("2d");
|
|
32
|
+
if (!e) return;
|
|
33
|
+
let t = i.color ?? "#22d3ee", n = o / 2, r = o / 2, u = o / 2 - 10;
|
|
34
|
+
c += .03, e.fillStyle = "rgb(15 23 42 / 25%)", e.fillRect(0, 0, o, o);
|
|
35
|
+
for (let i = 1; i <= 4; i++) e.beginPath(), e.arc(n, r, u / 4 * i, 0, Math.PI * 2), e.strokeStyle = `${t}33`, e.lineWidth = 1, e.stroke();
|
|
36
|
+
e.beginPath(), e.moveTo(n, r - u), e.lineTo(n, r + u), e.moveTo(n - u, r), e.lineTo(n + u, r), e.strokeStyle = `${t}44`, e.stroke();
|
|
37
|
+
let f = c, m = e.createConicGradient(f - .5, n, r);
|
|
38
|
+
m.addColorStop(0, "transparent"), m.addColorStop(.15, `${t}66`), m.addColorStop(.3, "transparent"), e.beginPath(), e.moveTo(n, r), e.arc(n, r, u, f - .5, f), e.closePath(), e.fillStyle = m, e.fill(), e.beginPath(), e.moveTo(n, r), e.lineTo(n + Math.cos(f) * u, r + Math.sin(f) * u), e.strokeStyle = t, e.lineWidth = 2, e.stroke();
|
|
39
|
+
for (let i of d) {
|
|
40
|
+
let a = n + Math.cos(i.angle) * u * i.dist, o = r + Math.sin(i.angle) * u * i.dist;
|
|
41
|
+
Math.abs((f - i.angle + Math.PI) % (Math.PI * 2) - Math.PI) < .3 ? i.alpha = Math.min(1, i.alpha + .05) : i.alpha = Math.max(.2, i.alpha - .01), e.beginPath(), e.arc(a, o, 4, 0, Math.PI * 2), e.fillStyle = t, e.globalAlpha = i.alpha, e.fill(), e.globalAlpha = 1;
|
|
42
|
+
}
|
|
43
|
+
e.beginPath(), e.arc(n, r, u, 0, Math.PI * 2), e.strokeStyle = t, e.lineWidth = 2, e.stroke();
|
|
44
|
+
};
|
|
45
|
+
return h(), g(), m(), u = e((e) => {
|
|
46
|
+
l = e;
|
|
47
|
+
}), _(), {
|
|
48
|
+
update(e) {
|
|
49
|
+
i = {
|
|
50
|
+
...i,
|
|
51
|
+
...e
|
|
52
|
+
}, h(), g(), m();
|
|
53
|
+
},
|
|
54
|
+
destroy() {
|
|
55
|
+
a || (a = !0, cancelAnimationFrame(s), u?.(), f.remove());
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/radarScan/element/index.ts
|
|
61
|
+
var r = "cos-radar-scan";
|
|
62
|
+
function i(e) {
|
|
63
|
+
let t = {};
|
|
64
|
+
return e.hasAttribute("color") && (t.color = e.getAttribute("color") ?? void 0), e.hasAttribute("size") && (t.size = Number(e.getAttribute("size"))), e.hasAttribute("blip-count") && (t.blipCount = Number(e.getAttribute("blip-count"))), t;
|
|
65
|
+
}
|
|
66
|
+
var a = class extends HTMLElement {
|
|
67
|
+
ctrl = null;
|
|
68
|
+
static get observedAttributes() {
|
|
69
|
+
return [
|
|
70
|
+
"size",
|
|
71
|
+
"color",
|
|
72
|
+
"blip-count"
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
connectedCallback() {
|
|
76
|
+
this.ctrl = n(this, i(this));
|
|
77
|
+
}
|
|
78
|
+
disconnectedCallback() {
|
|
79
|
+
this.ctrl?.destroy(), this.ctrl = null;
|
|
80
|
+
}
|
|
81
|
+
attributeChangedCallback() {
|
|
82
|
+
this.ctrl?.update(i(this));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
typeof customElements < "u" && !customElements.get("cos-radar-scan") && customElements.define(r, a);
|
|
86
|
+
//#endregion
|
|
87
|
+
export { a as CosRadarScanElement, r as TAG };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/radarScan/core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/radarScan/element';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementSize } from './size';
|
|
2
|
+
export interface CanvasBoxSizeInput {
|
|
3
|
+
/** 为 true 时跟随父容器尺寸(需父级有明确高度) */
|
|
4
|
+
fill?: boolean;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
defaultWidth: number;
|
|
8
|
+
defaultHeight: number;
|
|
9
|
+
measured: ElementSize;
|
|
10
|
+
}
|
|
11
|
+
export interface CanvasBoxSize {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
15
|
+
pending: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** 根据 fill / 显式宽高 / 测量结果解析画布逻辑尺寸 */
|
|
18
|
+
export declare const resolveCanvasBoxSize: ({ fill, width, height, defaultWidth, defaultHeight, measured, }: CanvasBoxSizeInput) => CanvasBoxSize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Apply fill / explicit size to the adapter host and make the engine root fill it. */
|
|
2
|
+
export declare function applyCanvasHostBox(container: HTMLElement, root: HTMLElement, opts: {
|
|
3
|
+
fill: boolean;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}): void;
|
|
7
|
+
/**
|
|
8
|
+
* Size the adapter host (React/Vue div or custom element) so percentage widths
|
|
9
|
+
* don't collapse when the host is a shrink-wrapped flex child. Root fills the host
|
|
10
|
+
* unless `rootFillsHost` is false (e.g. PhotoAlbum sizes itself via CSS variables).
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyBlockHostBox(container: HTMLElement, root: HTMLElement, size: {
|
|
13
|
+
width?: number | string;
|
|
14
|
+
height?: number | string;
|
|
15
|
+
rootFillsHost?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
/** Toggle empty-state nodes; author `display:` rules must not override `[hidden]`. */
|
|
18
|
+
export declare function setHidden(el: HTMLElement, hidden: boolean): void;
|
|
19
|
+
/** Stable JSON key for options, ignoring functions (callbacks). */
|
|
20
|
+
export declare function optionsFingerprint(value: unknown): string;
|
|
21
|
+
/** True when non-function fields differ (shallow). */
|
|
22
|
+
export declare function optionsVisualChanged(prev: Record<string, unknown>, next: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { clamp, lerp } 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 { resolveCanvasBoxSize } from './canvas-box';
|
|
10
|
+
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
|
+
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
@@ -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,30 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { ElementSize } from '../size';
|
|
3
|
+
export type { CanvasBoxSize, CanvasBoxSizeInput } from '../canvas-box';
|
|
4
|
+
export { resolveCanvasBoxSize } from '../canvas-box';
|
|
5
|
+
export interface UseElementSizeOptions {
|
|
6
|
+
/** 为 false 时不观察 */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** 观察元素尺寸(clientWidth / clientHeight) */
|
|
10
|
+
export declare const useElementSize: <T extends Element>(ref: RefObject<T | null>, options?: UseElementSizeOptions) => ElementSize;
|
|
11
|
+
export interface UseCanvasBoxOptions {
|
|
12
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
defaultWidth: number;
|
|
17
|
+
defaultHeight: number;
|
|
18
|
+
}
|
|
19
|
+
export interface UseCanvasBoxResult {
|
|
20
|
+
hostRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
/** 挂到宿主容器的样式(fill 时为 100%×100%) */
|
|
24
|
+
hostStyle: CSSProperties;
|
|
25
|
+
fill: boolean;
|
|
26
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
27
|
+
pending: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** 画布/效果宿主尺寸:fill 时跟随父容器,否则用显式宽高或默认值 */
|
|
30
|
+
export declare const useCanvasBox: ({ fill, width: widthProp, height: heightProp, defaultWidth, defaultHeight, }: UseCanvasBoxOptions) => UseCanvasBoxResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface RadarScanOptions {
|
|
2
|
+
size?: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
blipCount?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface RadarScanController {
|
|
7
|
+
update(options: Partial<RadarScanOptions>): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
export type RadarScanProps = RadarScanOptions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const TAG = "cos-radar-scan";
|
|
2
|
+
declare class CosRadarScanElement extends HTMLElement {
|
|
3
|
+
private ctrl;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
connectedCallback(): void;
|
|
6
|
+
disconnectedCallback(): void;
|
|
7
|
+
attributeChangedCallback(): void;
|
|
8
|
+
}
|
|
9
|
+
export { CosRadarScanElement, TAG };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue';
|
|
5
|
+
const component: DefineComponent<object, object, unknown>;
|
|
6
|
+
export default component;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module '*.module.less' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.png' {
|
|
20
|
+
const src: string;
|
|
21
|
+
export default src;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.jpg' {
|
|
25
|
+
const src: string;
|
|
26
|
+
export default src;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.mp4' {
|
|
30
|
+
const src: string;
|
|
31
|
+
export default src;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.mp3' {
|
|
35
|
+
const src: string;
|
|
36
|
+
export default src;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.svg' {
|
|
40
|
+
import type { FC, SVGProps } from 'react';
|
|
41
|
+
|
|
42
|
+
export const ReactComponent: FC<SVGProps<SVGSVGElement>>;
|
|
43
|
+
const src: string;
|
|
44
|
+
export default src;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});require('./react.css');let e=require("react"),t=require("@cos-design/shared"),n=require("react/jsx-runtime");var r=`cos-radar-scan`;function i(e,n={}){let i={size:300,color:`#22d3ee`,blipCount:5,...n},a=!1,o=i.size??300,s=0,c=0,l=typeof document<`u`?document.hidden:!1,u=null,d=[],f=document.createElement(`div`);f.className=r;let p=document.createElement(`canvas`);p.className=`${r}__canvas`,f.appendChild(p),e.appendChild(f);let m=()=>{d.length=0;let e=i.blipCount??5;for(let t=0;t<e;t++)d.push({angle:Math.random()*Math.PI*2,dist:Math.random()*.7+.15,alpha:Math.random()*.5+.5})},h=()=>{o=i.size??300,f.style.width=`${o}px`,f.style.height=`${o}px`,p.style.width=`${o}px`,p.style.height=`${o}px`},g=()=>{let e=window.devicePixelRatio||1;p.width=o*e,p.height=o*e;let t=p.getContext(`2d`);return t&&t.setTransform(e,0,0,e,0,0),t},_=()=>{if(a||(s=requestAnimationFrame(_),l))return;let e=p.getContext(`2d`);if(!e)return;let t=i.color??`#22d3ee`,n=o/2,r=o/2,u=o/2-10;c+=.03,e.fillStyle=`rgb(15 23 42 / 25%)`,e.fillRect(0,0,o,o);for(let i=1;i<=4;i++)e.beginPath(),e.arc(n,r,u/4*i,0,Math.PI*2),e.strokeStyle=`${t}33`,e.lineWidth=1,e.stroke();e.beginPath(),e.moveTo(n,r-u),e.lineTo(n,r+u),e.moveTo(n-u,r),e.lineTo(n+u,r),e.strokeStyle=`${t}44`,e.stroke();let f=c,m=e.createConicGradient(f-.5,n,r);m.addColorStop(0,`transparent`),m.addColorStop(.15,`${t}66`),m.addColorStop(.3,`transparent`),e.beginPath(),e.moveTo(n,r),e.arc(n,r,u,f-.5,f),e.closePath(),e.fillStyle=m,e.fill(),e.beginPath(),e.moveTo(n,r),e.lineTo(n+Math.cos(f)*u,r+Math.sin(f)*u),e.strokeStyle=t,e.lineWidth=2,e.stroke();for(let i of d){let a=n+Math.cos(i.angle)*u*i.dist,o=r+Math.sin(i.angle)*u*i.dist;Math.abs((f-i.angle+Math.PI)%(Math.PI*2)-Math.PI)<.3?i.alpha=Math.min(1,i.alpha+.05):i.alpha=Math.max(.2,i.alpha-.01),e.beginPath(),e.arc(a,o,4,0,Math.PI*2),e.fillStyle=t,e.globalAlpha=i.alpha,e.fill(),e.globalAlpha=1}e.beginPath(),e.arc(n,r,u,0,Math.PI*2),e.strokeStyle=t,e.lineWidth=2,e.stroke()};return h(),g(),m(),u=(0,t.bindVisibilityPause)(e=>{l=e}),_(),{update(e){i={...i,...e},h(),g(),m()},destroy(){a||(a=!0,cancelAnimationFrame(s),u?.(),f.remove())}}}var a=(0,e.forwardRef)((r,a)=>{let o=(0,e.useRef)(null),s=(0,e.useRef)(null),c=(0,e.useRef)(r);c.current=r;let l=(0,e.useMemo)(()=>(0,t.optionsFingerprint)(r),[r]);return(0,e.useImperativeHandle)(a,()=>({})),(0,e.useEffect)(()=>{let e=o.current;if(!e)return;let t=i(e,c.current);return s.current=t,()=>{t.destroy(),s.current=null}},[]),(0,e.useEffect)(()=>{s.current?.update(c.current)},[l]),(0,n.jsx)(`div`,{ref:o,className:`cos-radarScan-host`})});a.displayName=`RadarScan`,exports.RadarScan=a,exports.default=a;
|