@cos-design/ripple-water 4.0.0 → 4.1.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/packages/shared/src/element-options.d.ts +19 -0
- package/dist/core/packages/shared/src/index.d.ts +2 -0
- package/dist/element/index.js +55 -63
- package/dist/element/packages/shared/src/element-options.d.ts +19 -0
- package/dist/element/packages/shared/src/index.d.ts +2 -0
- package/dist/react/packages/shared/src/element-options.d.ts +19 -0
- package/dist/react/packages/shared/src/index.d.ts +2 -0
- package/dist/vue/index.js +38 -43
- package/dist/vue/packages/shared/src/element-options.d.ts +19 -0
- package/dist/vue/packages/shared/src/index.d.ts +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Component attribute → Core options parsing (v4 Element adapters).
|
|
3
|
+
* Keeps behavior consistent across 91 components.
|
|
4
|
+
*/
|
|
5
|
+
export type BooleanAttrMode =
|
|
6
|
+
/** `options.key = el.hasAttribute(attr)` — always written */
|
|
7
|
+
'presence'
|
|
8
|
+
/** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
|
|
9
|
+
| 'optional-true'
|
|
10
|
+
/** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
|
|
11
|
+
| 'optional-undefined';
|
|
12
|
+
export declare const camelToKebabAttr: (name: string) => string;
|
|
13
|
+
export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
14
|
+
export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
15
|
+
export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
|
|
16
|
+
export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
|
|
17
|
+
/** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
|
|
18
|
+
export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
|
|
19
|
+
export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
|
|
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
|
|
|
9
9
|
export { resolveCanvasBoxSize } from './canvas-box';
|
|
10
10
|
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
11
|
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
12
|
+
export type { BooleanAttrMode } from './element-options';
|
|
13
|
+
export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
|
package/dist/element/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { applyCanvasHostBox as e, bindPrefersReducedMotion as t, bindVisibilityPause as n, clamp as r, observeElementSize as i, prefersReducedMotion as a,
|
|
1
|
+
import { applyCanvasHostBox as e, bindPrefersReducedMotion as t, bindVisibilityPause as n, clamp as r, observeElementSize as i, prefersReducedMotion as a, readBooleanAttr as o, readNumberAttr as s, readStringAttr as c, resolveCanvasBoxSize as l } from "@cos-design/shared";
|
|
2
2
|
import './element.css';//#region src/components/rippleWater/core/engine.ts
|
|
3
|
-
var
|
|
3
|
+
var u = "cos-ripple-water", d = 800, f = 500, p = 192, m = "\nattribute vec2 a_pos;\nvarying vec2 v_uv;\nvoid main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}\n", h = "\nprecision highp float;\nuniform float u_time;\nuniform vec2 u_res;\nuniform vec3 u_tint;\nuniform vec3 u_from;\nuniform vec3 u_to;\nuniform sampler2D u_height;\nuniform vec2 u_sim;\nuniform float u_waveAmp;\nuniform float u_waveSpeed;\nuniform float u_shimmer;\nuniform float u_reflection;\nvarying vec2 v_uv;\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n}\nfloat ambientH(vec2 p, float t) {\n float h = 0.0;\n h += sin(p.x * 3.2 + t * 1.3) * cos(p.y * 2.4 - t * 0.9) * 0.45;\n h += sin(p.x * 6.8 - t * 1.7 + p.y * 1.1) * 0.22;\n h += sin(p.x * 12.0 + p.y * 9.0 + t * 2.4) * 0.08;\n h += sin(p.x * 1.4 + p.y * 1.8 + t * 0.55) * 0.35;\n return h;\n}\nfloat sampleHeight(vec2 uv) {\n float rip = texture2D(u_height, uv).r * 2.0 - 1.0;\n vec2 p = uv * vec2(u_res.x / u_res.y, 1.0) * 2.8;\n float amb = ambientH(p, u_time * u_waveSpeed) * 0.035 * u_waveAmp;\n return rip * 0.55 + amb;\n}\nvec3 calcNormal(vec2 uv) {\n vec2 e = vec2(1.5 / u_sim.x, 1.5 / u_sim.y);\n float hL = sampleHeight(uv - vec2(e.x, 0.0));\n float hR = sampleHeight(uv + vec2(e.x, 0.0));\n float hD = sampleHeight(uv - vec2(0.0, e.y));\n float hU = sampleHeight(uv + vec2(0.0, e.y));\n return normalize(vec3((hL - hR) * 14.0, (hD - hU) * 14.0, 1.0));\n}\nvoid main() {\n vec2 uv = v_uv;\n vec3 n = calcNormal(uv);\n float h = sampleHeight(uv);\n vec3 V = normalize(vec3(0.0, 0.25, 1.0));\n vec3 L = normalize(vec3(0.45, 0.75, 0.55));\n float ndotl = max(dot(n, L), 0.0);\n float fresnel = pow(1.0 - max(dot(n, V), 0.0), 3.2);\n float g = clamp((uv.x + (1.0 - uv.y)) * 0.5, 0.0, 1.0);\n vec3 water = mix(u_from, u_to, g);\n water = mix(water, u_from, clamp(h * 1.8 + ndotl * 0.12, 0.0, 0.28));\n water *= 0.92 + n.y * 0.1;\n vec3 sky = mix(u_from * 1.15, vec3(0.85, 0.92, 1.0), 0.45);\n vec3 reflectCol = mix(sky, vec3(0.9, 0.95, 1.0), pow(max(n.y, 0.0), 2.0));\n water = mix(water, reflectCol, fresnel * u_reflection);\n vec3 H = normalize(L + V);\n float spec = pow(max(dot(n, H), 0.0), 180.0);\n float glitter = pow(max(dot(n, H), 0.0), 48.0);\n float sparkThresh = step(0.992, glitter) * glitter;\n vec3 sparkle = u_tint * (spec * 1.8 + sparkThresh * 2.5) * u_shimmer + vec3(1.0) * sparkThresh * 0.8 * u_shimmer;\n float softSpec = pow(max(dot(n, H), 0.0), 16.0) * 0.22 * u_shimmer;\n water += u_tint * softSpec + sparkle;\n float crest = smoothstep(0.02, 0.12, abs(h)) * fresnel;\n water += mix(u_tint, vec3(1.0), 0.4) * crest * 0.35;\n float vig = smoothstep(1.15, 0.35, length((uv - 0.5) * vec2(1.1, 1.0)));\n water *= 0.88 + 0.12 * vig;\n water += (hash(uv * u_res + u_time) - 0.5) * 0.015;\n gl_FragColor = vec4(water, 1.0);\n}\n", g = (e) => {
|
|
4
4
|
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = Number.parseInt(n, 16);
|
|
5
5
|
return Number.isNaN(r) ? [
|
|
6
6
|
.22,
|
|
@@ -11,17 +11,17 @@ var s = "cos-ripple-water", c = 800, l = 500, u = 192, d = "\nattribute vec2 a_p
|
|
|
11
11
|
(r >> 8 & 255) / 255,
|
|
12
12
|
(r & 255) / 255
|
|
13
13
|
];
|
|
14
|
-
},
|
|
14
|
+
}, _ = (e, t, n) => {
|
|
15
15
|
let r = e.createShader(t);
|
|
16
16
|
return r ? (e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (e.deleteShader(r), null)) : null;
|
|
17
|
-
},
|
|
18
|
-
let r =
|
|
17
|
+
}, v = (e, t, n) => {
|
|
18
|
+
let r = _(e, e.VERTEX_SHADER, t), i = _(e, e.FRAGMENT_SHADER, n);
|
|
19
19
|
if (!r || !i) return null;
|
|
20
20
|
let a = e.createProgram();
|
|
21
21
|
return a ? (e.attachShader(a, r), e.attachShader(a, i), e.linkProgram(a), e.deleteShader(r), e.deleteShader(i), e.getProgramParameter(a, e.LINK_STATUS) ? a : (e.deleteProgram(a), null)) : null;
|
|
22
22
|
};
|
|
23
|
-
function
|
|
24
|
-
let
|
|
23
|
+
function y(o, s = {}) {
|
|
24
|
+
let c = {
|
|
25
25
|
fill: !1,
|
|
26
26
|
fromColor: "#52ade3",
|
|
27
27
|
toColor: "#013565",
|
|
@@ -37,29 +37,29 @@ function g(m, g = {}) {
|
|
|
37
37
|
interactive: !0,
|
|
38
38
|
showHint: !0,
|
|
39
39
|
hint: "点击水面产生涟漪",
|
|
40
|
-
...
|
|
41
|
-
},
|
|
42
|
-
O.className =
|
|
40
|
+
...s
|
|
41
|
+
}, _ = !1, y = c.width ?? d, b = c.height ?? f, x = typeof document < "u" ? document.hidden : !1, S = a(), C = null, w = null, T = null, E = null, D = null, O = document.createElement("div");
|
|
42
|
+
O.className = u;
|
|
43
43
|
let k = document.createElement("canvas");
|
|
44
|
-
k.className = `${
|
|
44
|
+
k.className = `${u}__canvas`, k.setAttribute("role", "img");
|
|
45
45
|
let A = document.createElement("span");
|
|
46
|
-
A.className = `${
|
|
46
|
+
A.className = `${u}__hint`, A.setAttribute("aria-hidden", "true"), O.append(k, A), o.appendChild(O);
|
|
47
47
|
let j = () => {
|
|
48
|
-
let e =
|
|
49
|
-
A.textContent = t, A.hidden = !e, k.style.cursor =
|
|
48
|
+
let e = c.showHint ?? !0, t = c.hint ?? "点击水面产生涟漪";
|
|
49
|
+
A.textContent = t, A.hidden = !e, k.style.cursor = c.interactive ?? !0 ? "pointer" : "default", k.setAttribute("aria-label", t || "涟漪水面");
|
|
50
50
|
}, M = () => {
|
|
51
|
-
e(
|
|
52
|
-
fill: !!
|
|
51
|
+
e(o, O, {
|
|
52
|
+
fill: !!c.fill,
|
|
53
53
|
width: y,
|
|
54
54
|
height: b
|
|
55
55
|
}), k.style.width = `${y}px`, k.style.height = `${b}px`, j();
|
|
56
56
|
}, N = (e) => {
|
|
57
|
-
if (!(
|
|
57
|
+
if (!(c.interactive ?? !0) || e.pointerType === "mouse" && e.button !== 0) return;
|
|
58
58
|
let t = k.getBoundingClientRect();
|
|
59
59
|
D = {
|
|
60
60
|
x: (e.clientX - t.left) / t.width,
|
|
61
61
|
y: 1 - (e.clientY - t.top) / t.height,
|
|
62
|
-
strength:
|
|
62
|
+
strength: c.rippleStrength ?? 1
|
|
63
63
|
};
|
|
64
64
|
}, P = {
|
|
65
65
|
w: 0,
|
|
@@ -80,7 +80,7 @@ function g(m, g = {}) {
|
|
|
80
80
|
premultipliedAlpha: !1
|
|
81
81
|
});
|
|
82
82
|
if (!t) return;
|
|
83
|
-
let n =
|
|
83
|
+
let n = v(t, m, h);
|
|
84
84
|
if (!n) return;
|
|
85
85
|
let i = t.createBuffer();
|
|
86
86
|
t.bindBuffer(t.ARRAY_BUFFER, i), t.bufferData(t.ARRAY_BUFFER, new Float32Array([
|
|
@@ -93,29 +93,29 @@ function g(m, g = {}) {
|
|
|
93
93
|
1,
|
|
94
94
|
1
|
|
95
95
|
]), t.STATIC_DRAW);
|
|
96
|
-
let a = t.getAttribLocation(n, "a_pos"), o = t.getUniformLocation(n, "u_time"), s = t.getUniformLocation(n, "u_res"),
|
|
96
|
+
let a = t.getAttribLocation(n, "a_pos"), o = t.getUniformLocation(n, "u_time"), s = t.getUniformLocation(n, "u_res"), l = t.getUniformLocation(n, "u_tint"), u = t.getUniformLocation(n, "u_from"), d = t.getUniformLocation(n, "u_to"), f = t.getUniformLocation(n, "u_height"), C = t.getUniformLocation(n, "u_sim"), w = t.getUniformLocation(n, "u_waveAmp"), T = t.getUniformLocation(n, "u_waveSpeed"), O = t.getUniformLocation(n, "u_shimmer"), A = t.getUniformLocation(n, "u_reflection"), j = p * p, M = new Float32Array(j), N = new Float32Array(j), F = new Float32Array(j), I = t.createTexture();
|
|
97
97
|
t.bindTexture(t.TEXTURE_2D, I), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE);
|
|
98
98
|
let L = new Uint8Array(j * 4), R = () => {
|
|
99
99
|
for (let e = 0; e < j; e++) {
|
|
100
100
|
let t = Math.max(0, Math.min(255, Math.floor((N[e] * .5 + .5) * 255))), n = e * 4;
|
|
101
101
|
L[n] = t, L[n + 1] = t, L[n + 2] = t, L[n + 3] = 255;
|
|
102
102
|
}
|
|
103
|
-
t.bindTexture(t.TEXTURE_2D, I), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA,
|
|
103
|
+
t.bindTexture(t.TEXTURE_2D, I), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, p, p, 0, t.RGBA, t.UNSIGNED_BYTE, L);
|
|
104
104
|
}, z = (e, t, n, i) => {
|
|
105
|
-
let a = e * (
|
|
105
|
+
let a = e * (p - 1), o = t * (p - 1), s = r(i, 2, 12);
|
|
106
106
|
for (let e = -s - 1; e <= s + 1; e++) for (let t = -s - 1; t <= s + 1; t++) {
|
|
107
107
|
let r = Math.round(a + t), i = Math.round(o + e);
|
|
108
|
-
if (r <= 0 || r >=
|
|
109
|
-
let c = Math.sqrt(t * t + e * e), l = Math.exp(-c * c * .55) * -.35,
|
|
110
|
-
N[i *
|
|
108
|
+
if (r <= 0 || r >= p - 1 || i <= 0 || i >= p - 1) continue;
|
|
109
|
+
let c = Math.sqrt(t * t + e * e), l = Math.exp(-c * c * .55) * -.35, u = Math.exp(-((c - s * .55) ** 2) * .9);
|
|
110
|
+
N[i * p + r] += n * (l + u * 1.1);
|
|
111
111
|
}
|
|
112
112
|
}, B = (e, t) => {
|
|
113
113
|
let n = r(e, .9, .999), i = r(t, .3, .7);
|
|
114
114
|
for (let e = 0; e < 2; e++) {
|
|
115
|
-
for (let e = 1; e <
|
|
116
|
-
let t = e *
|
|
117
|
-
for (let e = 1; e <
|
|
118
|
-
let r = t + e, a = N[r - 1] + N[r + 1] + N[r -
|
|
115
|
+
for (let e = 1; e < p - 1; e++) {
|
|
116
|
+
let t = e * p;
|
|
117
|
+
for (let e = 1; e < p - 1; e++) {
|
|
118
|
+
let r = t + e, a = N[r - 1] + N[r + 1] + N[r - p] + N[r + p];
|
|
119
119
|
F[r] = (a * i - M[r]) * n, F[r] > 1.5 ? F[r] = 1.5 : F[r] < -1.5 && (F[r] = -1.5);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -123,8 +123,8 @@ function g(m, g = {}) {
|
|
|
123
123
|
M = N, N = F, F = e, F.fill(0);
|
|
124
124
|
}
|
|
125
125
|
}, V = (e) => {
|
|
126
|
-
let
|
|
127
|
-
t.viewport(0, 0, k.width, k.height), t.useProgram(n), t.bindBuffer(t.ARRAY_BUFFER, i), t.enableVertexAttribArray(a), t.vertexAttribPointer(a, 2, t.FLOAT, !1, 0, 0), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, I), t.uniform1i(
|
|
126
|
+
let m = g(c.fromColor ?? "#52ade3"), h = g(c.toColor ?? "#013565"), _ = g(c.color ?? "#a8d8f5");
|
|
127
|
+
t.viewport(0, 0, k.width, k.height), t.useProgram(n), t.bindBuffer(t.ARRAY_BUFFER, i), t.enableVertexAttribArray(a), t.vertexAttribPointer(a, 2, t.FLOAT, !1, 0, 0), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, I), t.uniform1i(f, 0), t.uniform1f(o, e), t.uniform2f(s, k.width, k.height), t.uniform3f(l, _[0], _[1], _[2]), t.uniform3f(u, m[0], m[1], m[2]), t.uniform3f(d, h[0], h[1], h[2]), t.uniform2f(C, p, p), t.uniform1f(w, r(c.waveAmplitude ?? 1, 0, 2)), t.uniform1f(T, r(c.waveSpeed ?? 1, 0, 3)), t.uniform1f(O, r(c.shimmer ?? 1, 0, 2)), t.uniform1f(A, r(c.reflection ?? .38, 0, 1)), t.drawArrays(t.TRIANGLE_STRIP, 0, 4);
|
|
128
128
|
};
|
|
129
129
|
if (R(), S) {
|
|
130
130
|
V(0), E = () => {
|
|
@@ -133,29 +133,29 @@ function g(m, g = {}) {
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
let H = performance.now(), U = 0, W = (e) => {
|
|
136
|
-
if (!
|
|
136
|
+
if (!_ && (U = requestAnimationFrame(W), !(x || S))) {
|
|
137
137
|
if (D) {
|
|
138
|
-
let e = D, t = r(e.strength, 0, 3), n =
|
|
138
|
+
let e = D, t = r(e.strength, 0, 3), n = c.rippleRadius ?? 6;
|
|
139
139
|
z(e.x, e.y, t, n), z(e.x + .004, e.y - .003, t * .35, n), D = null;
|
|
140
140
|
}
|
|
141
|
-
B(
|
|
141
|
+
B(c.damping ?? .985, c.spread ?? .5), R(), V((e - H) / 1e3);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
U = requestAnimationFrame(W), E = () => {
|
|
145
145
|
cancelAnimationFrame(U), t.deleteTexture(I), t.deleteBuffer(i), t.deleteProgram(n);
|
|
146
146
|
};
|
|
147
147
|
}, I = () => {
|
|
148
|
-
if (C?.(), C = null, !(
|
|
149
|
-
y =
|
|
148
|
+
if (C?.(), C = null, !(c.fill ?? !1)) {
|
|
149
|
+
y = c.width ?? d, b = c.height ?? f, M(), F();
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
|
-
C = i(
|
|
153
|
-
let t =
|
|
152
|
+
C = i(o, (e) => {
|
|
153
|
+
let t = l({
|
|
154
154
|
fill: !0,
|
|
155
|
-
width:
|
|
156
|
-
height:
|
|
157
|
-
defaultWidth:
|
|
158
|
-
defaultHeight:
|
|
155
|
+
width: c.width,
|
|
156
|
+
height: c.height,
|
|
157
|
+
defaultWidth: d,
|
|
158
|
+
defaultHeight: f,
|
|
159
159
|
measured: e
|
|
160
160
|
});
|
|
161
161
|
y = t.width, b = t.height, M(), F();
|
|
@@ -167,33 +167,25 @@ function g(m, g = {}) {
|
|
|
167
167
|
S = e;
|
|
168
168
|
}), I(), {
|
|
169
169
|
update(e) {
|
|
170
|
-
let t =
|
|
171
|
-
|
|
172
|
-
...
|
|
170
|
+
let t = c.fill, n = c.width, r = c.height;
|
|
171
|
+
c = {
|
|
172
|
+
...c,
|
|
173
173
|
...e
|
|
174
|
-
}, j(), (
|
|
174
|
+
}, j(), (c.fill !== t || c.width !== n || c.height !== r) && I();
|
|
175
175
|
},
|
|
176
176
|
destroy() {
|
|
177
|
-
|
|
177
|
+
_ || (_ = !0, E?.(), w?.(), T?.(), C?.(), k.removeEventListener("pointerdown", N), O.remove());
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/components/rippleWater/element/index.ts
|
|
183
|
-
var
|
|
184
|
-
function
|
|
183
|
+
var b = "cos-ripple-water";
|
|
184
|
+
function x(e) {
|
|
185
185
|
let t = {};
|
|
186
|
-
|
|
187
|
-
let n = e.getAttribute("interactive");
|
|
188
|
-
t.interactive = n !== "false" && n !== "0";
|
|
189
|
-
}
|
|
190
|
-
if (e.hasAttribute("show-hint")) {
|
|
191
|
-
let n = e.getAttribute("show-hint");
|
|
192
|
-
t.showHint = n !== "false" && n !== "0";
|
|
193
|
-
}
|
|
194
|
-
return t;
|
|
186
|
+
return c(t, e, "fromColor", "from-color"), c(t, e, "toColor", "to-color"), c(t, e, "color", "color"), c(t, e, "hint", "hint"), s(t, e, "width", "width"), s(t, e, "height", "height"), s(t, e, "waveAmplitude", "wave-amplitude"), s(t, e, "waveSpeed", "wave-speed"), s(t, e, "shimmer", "shimmer"), s(t, e, "reflection", "reflection"), s(t, e, "rippleStrength", "ripple-strength"), s(t, e, "rippleRadius", "ripple-radius"), s(t, e, "damping", "damping"), s(t, e, "spread", "spread"), o(t, e, "fill", "fill", "presence"), o(t, e, "interactive", "interactive", "optional-true"), o(t, e, "showHint", "show-hint", "optional-true"), t;
|
|
195
187
|
}
|
|
196
|
-
var
|
|
188
|
+
var S = class extends HTMLElement {
|
|
197
189
|
ctrl = null;
|
|
198
190
|
static get observedAttributes() {
|
|
199
191
|
return [
|
|
@@ -217,15 +209,15 @@ var y = class extends HTMLElement {
|
|
|
217
209
|
];
|
|
218
210
|
}
|
|
219
211
|
connectedCallback() {
|
|
220
|
-
this.ctrl =
|
|
212
|
+
this.ctrl = y(this, x(this));
|
|
221
213
|
}
|
|
222
214
|
disconnectedCallback() {
|
|
223
215
|
this.ctrl?.destroy(), this.ctrl = null;
|
|
224
216
|
}
|
|
225
217
|
attributeChangedCallback() {
|
|
226
|
-
this.ctrl?.update(
|
|
218
|
+
this.ctrl?.update(x(this));
|
|
227
219
|
}
|
|
228
220
|
};
|
|
229
|
-
typeof customElements < "u" && !customElements.get("cos-ripple-water") && customElements.define(
|
|
221
|
+
typeof customElements < "u" && !customElements.get("cos-ripple-water") && customElements.define(b, S);
|
|
230
222
|
//#endregion
|
|
231
|
-
export {
|
|
223
|
+
export { S as CosRippleWaterElement, b as TAG };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Component attribute → Core options parsing (v4 Element adapters).
|
|
3
|
+
* Keeps behavior consistent across 91 components.
|
|
4
|
+
*/
|
|
5
|
+
export type BooleanAttrMode =
|
|
6
|
+
/** `options.key = el.hasAttribute(attr)` — always written */
|
|
7
|
+
'presence'
|
|
8
|
+
/** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
|
|
9
|
+
| 'optional-true'
|
|
10
|
+
/** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
|
|
11
|
+
| 'optional-undefined';
|
|
12
|
+
export declare const camelToKebabAttr: (name: string) => string;
|
|
13
|
+
export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
14
|
+
export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
15
|
+
export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
|
|
16
|
+
export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
|
|
17
|
+
/** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
|
|
18
|
+
export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
|
|
19
|
+
export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
|
|
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
|
|
|
9
9
|
export { resolveCanvasBoxSize } from './canvas-box';
|
|
10
10
|
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
11
|
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
12
|
+
export type { BooleanAttrMode } from './element-options';
|
|
13
|
+
export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Component attribute → Core options parsing (v4 Element adapters).
|
|
3
|
+
* Keeps behavior consistent across 91 components.
|
|
4
|
+
*/
|
|
5
|
+
export type BooleanAttrMode =
|
|
6
|
+
/** `options.key = el.hasAttribute(attr)` — always written */
|
|
7
|
+
'presence'
|
|
8
|
+
/** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
|
|
9
|
+
| 'optional-true'
|
|
10
|
+
/** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
|
|
11
|
+
| 'optional-undefined';
|
|
12
|
+
export declare const camelToKebabAttr: (name: string) => string;
|
|
13
|
+
export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
14
|
+
export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
15
|
+
export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
|
|
16
|
+
export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
|
|
17
|
+
/** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
|
|
18
|
+
export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
|
|
19
|
+
export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
|
|
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
|
|
|
9
9
|
export { resolveCanvasBoxSize } from './canvas-box';
|
|
10
10
|
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
11
|
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
12
|
+
export type { BooleanAttrMode } from './element-options';
|
|
13
|
+
export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
|
package/dist/vue/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElementBlock as e, defineComponent as t, onMounted as n, onUnmounted as r, openBlock as i, ref as a, watch as o } from "vue";
|
|
2
|
-
import { applyCanvasHostBox as s, bindPrefersReducedMotion as c, bindVisibilityPause as l, clamp as u, observeElementSize as d,
|
|
2
|
+
import { applyCanvasHostBox as s, bindPrefersReducedMotion as c, bindVisibilityPause as l, clamp as u, observeElementSize as d, prefersReducedMotion as f, resolveCanvasBoxSize as p } from "@cos-design/shared";
|
|
3
3
|
import './vue.css';//#region src/components/rippleWater/core/engine.ts
|
|
4
|
-
var
|
|
4
|
+
var m = "cos-ripple-water", h = 800, g = 500, _ = 192, v = "\nattribute vec2 a_pos;\nvarying vec2 v_uv;\nvoid main() {\n v_uv = a_pos * 0.5 + 0.5;\n gl_Position = vec4(a_pos, 0.0, 1.0);\n}\n", y = "\nprecision highp float;\nuniform float u_time;\nuniform vec2 u_res;\nuniform vec3 u_tint;\nuniform vec3 u_from;\nuniform vec3 u_to;\nuniform sampler2D u_height;\nuniform vec2 u_sim;\nuniform float u_waveAmp;\nuniform float u_waveSpeed;\nuniform float u_shimmer;\nuniform float u_reflection;\nvarying vec2 v_uv;\nfloat hash(vec2 p) {\n return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);\n}\nfloat ambientH(vec2 p, float t) {\n float h = 0.0;\n h += sin(p.x * 3.2 + t * 1.3) * cos(p.y * 2.4 - t * 0.9) * 0.45;\n h += sin(p.x * 6.8 - t * 1.7 + p.y * 1.1) * 0.22;\n h += sin(p.x * 12.0 + p.y * 9.0 + t * 2.4) * 0.08;\n h += sin(p.x * 1.4 + p.y * 1.8 + t * 0.55) * 0.35;\n return h;\n}\nfloat sampleHeight(vec2 uv) {\n float rip = texture2D(u_height, uv).r * 2.0 - 1.0;\n vec2 p = uv * vec2(u_res.x / u_res.y, 1.0) * 2.8;\n float amb = ambientH(p, u_time * u_waveSpeed) * 0.035 * u_waveAmp;\n return rip * 0.55 + amb;\n}\nvec3 calcNormal(vec2 uv) {\n vec2 e = vec2(1.5 / u_sim.x, 1.5 / u_sim.y);\n float hL = sampleHeight(uv - vec2(e.x, 0.0));\n float hR = sampleHeight(uv + vec2(e.x, 0.0));\n float hD = sampleHeight(uv - vec2(0.0, e.y));\n float hU = sampleHeight(uv + vec2(0.0, e.y));\n return normalize(vec3((hL - hR) * 14.0, (hD - hU) * 14.0, 1.0));\n}\nvoid main() {\n vec2 uv = v_uv;\n vec3 n = calcNormal(uv);\n float h = sampleHeight(uv);\n vec3 V = normalize(vec3(0.0, 0.25, 1.0));\n vec3 L = normalize(vec3(0.45, 0.75, 0.55));\n float ndotl = max(dot(n, L), 0.0);\n float fresnel = pow(1.0 - max(dot(n, V), 0.0), 3.2);\n float g = clamp((uv.x + (1.0 - uv.y)) * 0.5, 0.0, 1.0);\n vec3 water = mix(u_from, u_to, g);\n water = mix(water, u_from, clamp(h * 1.8 + ndotl * 0.12, 0.0, 0.28));\n water *= 0.92 + n.y * 0.1;\n vec3 sky = mix(u_from * 1.15, vec3(0.85, 0.92, 1.0), 0.45);\n vec3 reflectCol = mix(sky, vec3(0.9, 0.95, 1.0), pow(max(n.y, 0.0), 2.0));\n water = mix(water, reflectCol, fresnel * u_reflection);\n vec3 H = normalize(L + V);\n float spec = pow(max(dot(n, H), 0.0), 180.0);\n float glitter = pow(max(dot(n, H), 0.0), 48.0);\n float sparkThresh = step(0.992, glitter) * glitter;\n vec3 sparkle = u_tint * (spec * 1.8 + sparkThresh * 2.5) * u_shimmer + vec3(1.0) * sparkThresh * 0.8 * u_shimmer;\n float softSpec = pow(max(dot(n, H), 0.0), 16.0) * 0.22 * u_shimmer;\n water += u_tint * softSpec + sparkle;\n float crest = smoothstep(0.02, 0.12, abs(h)) * fresnel;\n water += mix(u_tint, vec3(1.0), 0.4) * crest * 0.35;\n float vig = smoothstep(1.15, 0.35, length((uv - 0.5) * vec2(1.1, 1.0)));\n water *= 0.88 + 0.12 * vig;\n water += (hash(uv * u_res + u_time) - 0.5) * 0.015;\n gl_FragColor = vec4(water, 1.0);\n}\n", b = (e) => {
|
|
5
5
|
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = Number.parseInt(n, 16);
|
|
6
6
|
return Number.isNaN(r) ? [
|
|
7
7
|
.22,
|
|
@@ -12,16 +12,16 @@ var h = "cos-ripple-water", g = 800, _ = 500, v = 192, y = "\nattribute vec2 a_p
|
|
|
12
12
|
(r >> 8 & 255) / 255,
|
|
13
13
|
(r & 255) / 255
|
|
14
14
|
];
|
|
15
|
-
},
|
|
15
|
+
}, x = (e, t, n) => {
|
|
16
16
|
let r = e.createShader(t);
|
|
17
17
|
return r ? (e.shaderSource(r, n), e.compileShader(r), e.getShaderParameter(r, e.COMPILE_STATUS) ? r : (e.deleteShader(r), null)) : null;
|
|
18
|
-
},
|
|
19
|
-
let r =
|
|
18
|
+
}, S = (e, t, n) => {
|
|
19
|
+
let r = x(e, e.VERTEX_SHADER, t), i = x(e, e.FRAGMENT_SHADER, n);
|
|
20
20
|
if (!r || !i) return null;
|
|
21
21
|
let a = e.createProgram();
|
|
22
22
|
return a ? (e.attachShader(a, r), e.attachShader(a, i), e.linkProgram(a), e.deleteShader(r), e.deleteShader(i), e.getProgramParameter(a, e.LINK_STATUS) ? a : (e.deleteProgram(a), null)) : null;
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function C(e, t = {}) {
|
|
25
25
|
let n = {
|
|
26
26
|
fill: !1,
|
|
27
27
|
fromColor: "#52ade3",
|
|
@@ -39,12 +39,12 @@ function w(e, t = {}) {
|
|
|
39
39
|
showHint: !0,
|
|
40
40
|
hint: "点击水面产生涟漪",
|
|
41
41
|
...t
|
|
42
|
-
}, r = !1, i = n.width ??
|
|
43
|
-
O.className =
|
|
42
|
+
}, r = !1, i = n.width ?? h, a = n.height ?? g, o = typeof document < "u" ? document.hidden : !1, x = f(), C = null, w = null, T = null, E = null, D = null, O = document.createElement("div");
|
|
43
|
+
O.className = m;
|
|
44
44
|
let k = document.createElement("canvas");
|
|
45
|
-
k.className = `${
|
|
45
|
+
k.className = `${m}__canvas`, k.setAttribute("role", "img");
|
|
46
46
|
let A = document.createElement("span");
|
|
47
|
-
A.className = `${
|
|
47
|
+
A.className = `${m}__hint`, A.setAttribute("aria-hidden", "true"), O.append(k, A), e.appendChild(O);
|
|
48
48
|
let j = () => {
|
|
49
49
|
let e = n.showHint ?? !0, t = n.hint ?? "点击水面产生涟漪";
|
|
50
50
|
A.textContent = t, A.hidden = !e, k.style.cursor = n.interactive ?? !0 ? "pointer" : "default", k.setAttribute("aria-label", t || "涟漪水面");
|
|
@@ -81,7 +81,7 @@ function w(e, t = {}) {
|
|
|
81
81
|
premultipliedAlpha: !1
|
|
82
82
|
});
|
|
83
83
|
if (!t) return;
|
|
84
|
-
let s =
|
|
84
|
+
let s = S(t, v, y);
|
|
85
85
|
if (!s) return;
|
|
86
86
|
let c = t.createBuffer();
|
|
87
87
|
t.bindBuffer(t.ARRAY_BUFFER, c), t.bufferData(t.ARRAY_BUFFER, new Float32Array([
|
|
@@ -94,29 +94,29 @@ function w(e, t = {}) {
|
|
|
94
94
|
1,
|
|
95
95
|
1
|
|
96
96
|
]), t.STATIC_DRAW);
|
|
97
|
-
let l = t.getAttribLocation(s, "a_pos"), d = t.getUniformLocation(s, "u_time"),
|
|
97
|
+
let l = t.getAttribLocation(s, "a_pos"), d = t.getUniformLocation(s, "u_time"), f = t.getUniformLocation(s, "u_res"), p = t.getUniformLocation(s, "u_tint"), m = t.getUniformLocation(s, "u_from"), h = t.getUniformLocation(s, "u_to"), g = t.getUniformLocation(s, "u_height"), C = t.getUniformLocation(s, "u_sim"), w = t.getUniformLocation(s, "u_waveAmp"), T = t.getUniformLocation(s, "u_waveSpeed"), O = t.getUniformLocation(s, "u_shimmer"), A = t.getUniformLocation(s, "u_reflection"), j = _ * _, M = new Float32Array(j), N = new Float32Array(j), F = new Float32Array(j), I = t.createTexture();
|
|
98
98
|
t.bindTexture(t.TEXTURE_2D, I), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE);
|
|
99
99
|
let L = new Uint8Array(j * 4), R = () => {
|
|
100
100
|
for (let e = 0; e < j; e++) {
|
|
101
101
|
let t = Math.max(0, Math.min(255, Math.floor((N[e] * .5 + .5) * 255))), n = e * 4;
|
|
102
102
|
L[n] = t, L[n + 1] = t, L[n + 2] = t, L[n + 3] = 255;
|
|
103
103
|
}
|
|
104
|
-
t.bindTexture(t.TEXTURE_2D, I), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA,
|
|
104
|
+
t.bindTexture(t.TEXTURE_2D, I), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, _, _, 0, t.RGBA, t.UNSIGNED_BYTE, L);
|
|
105
105
|
}, z = (e, t, n, r) => {
|
|
106
|
-
let i = e * (
|
|
106
|
+
let i = e * (_ - 1), a = t * (_ - 1), o = u(r, 2, 12);
|
|
107
107
|
for (let e = -o - 1; e <= o + 1; e++) for (let t = -o - 1; t <= o + 1; t++) {
|
|
108
108
|
let r = Math.round(i + t), s = Math.round(a + e);
|
|
109
|
-
if (r <= 0 || r >=
|
|
109
|
+
if (r <= 0 || r >= _ - 1 || s <= 0 || s >= _ - 1) continue;
|
|
110
110
|
let c = Math.sqrt(t * t + e * e), l = Math.exp(-c * c * .55) * -.35, u = Math.exp(-((c - o * .55) ** 2) * .9);
|
|
111
|
-
N[s *
|
|
111
|
+
N[s * _ + r] += n * (l + u * 1.1);
|
|
112
112
|
}
|
|
113
113
|
}, B = (e, t) => {
|
|
114
114
|
let n = u(e, .9, .999), r = u(t, .3, .7);
|
|
115
115
|
for (let e = 0; e < 2; e++) {
|
|
116
|
-
for (let e = 1; e <
|
|
117
|
-
let t = e *
|
|
118
|
-
for (let e = 1; e <
|
|
119
|
-
let i = t + e, a = N[i - 1] + N[i + 1] + N[i -
|
|
116
|
+
for (let e = 1; e < _ - 1; e++) {
|
|
117
|
+
let t = e * _;
|
|
118
|
+
for (let e = 1; e < _ - 1; e++) {
|
|
119
|
+
let i = t + e, a = N[i - 1] + N[i + 1] + N[i - _] + N[i + _];
|
|
120
120
|
F[i] = (a * r - M[i]) * n, F[i] > 1.5 ? F[i] = 1.5 : F[i] < -1.5 && (F[i] = -1.5);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -124,17 +124,17 @@ function w(e, t = {}) {
|
|
|
124
124
|
M = N, N = F, F = e, F.fill(0);
|
|
125
125
|
}
|
|
126
126
|
}, V = (e) => {
|
|
127
|
-
let r =
|
|
128
|
-
t.viewport(0, 0, k.width, k.height), t.useProgram(s), t.bindBuffer(t.ARRAY_BUFFER, c), t.enableVertexAttribArray(l), t.vertexAttribPointer(l, 2, t.FLOAT, !1, 0, 0), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, I), t.uniform1i(
|
|
127
|
+
let r = b(n.fromColor ?? "#52ade3"), i = b(n.toColor ?? "#013565"), a = b(n.color ?? "#a8d8f5");
|
|
128
|
+
t.viewport(0, 0, k.width, k.height), t.useProgram(s), t.bindBuffer(t.ARRAY_BUFFER, c), t.enableVertexAttribArray(l), t.vertexAttribPointer(l, 2, t.FLOAT, !1, 0, 0), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, I), t.uniform1i(g, 0), t.uniform1f(d, e), t.uniform2f(f, k.width, k.height), t.uniform3f(p, a[0], a[1], a[2]), t.uniform3f(m, r[0], r[1], r[2]), t.uniform3f(h, i[0], i[1], i[2]), t.uniform2f(C, _, _), t.uniform1f(w, u(n.waveAmplitude ?? 1, 0, 2)), t.uniform1f(T, u(n.waveSpeed ?? 1, 0, 3)), t.uniform1f(O, u(n.shimmer ?? 1, 0, 2)), t.uniform1f(A, u(n.reflection ?? .38, 0, 1)), t.drawArrays(t.TRIANGLE_STRIP, 0, 4);
|
|
129
129
|
};
|
|
130
|
-
if (R(),
|
|
130
|
+
if (R(), x) {
|
|
131
131
|
V(0), E = () => {
|
|
132
132
|
t.deleteTexture(I), t.deleteBuffer(c), t.deleteProgram(s);
|
|
133
133
|
};
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
let H = performance.now(), U = 0, W = (e) => {
|
|
137
|
-
if (!r && (U = requestAnimationFrame(W), !(o ||
|
|
137
|
+
if (!r && (U = requestAnimationFrame(W), !(o || x))) {
|
|
138
138
|
if (D) {
|
|
139
139
|
let e = D, t = u(e.strength, 0, 3), r = n.rippleRadius ?? 6;
|
|
140
140
|
z(e.x, e.y, t, r), z(e.x + .004, e.y - .003, t * .35, r), D = null;
|
|
@@ -146,17 +146,17 @@ function w(e, t = {}) {
|
|
|
146
146
|
cancelAnimationFrame(U), t.deleteTexture(I), t.deleteBuffer(c), t.deleteProgram(s);
|
|
147
147
|
};
|
|
148
148
|
}, I = () => {
|
|
149
|
-
if (
|
|
150
|
-
i = n.width ??
|
|
149
|
+
if (C?.(), C = null, !(n.fill ?? !1)) {
|
|
150
|
+
i = n.width ?? h, a = n.height ?? g, M(), F();
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
let t =
|
|
153
|
+
C = d(e, (e) => {
|
|
154
|
+
let t = p({
|
|
155
155
|
fill: !0,
|
|
156
156
|
width: n.width,
|
|
157
157
|
height: n.height,
|
|
158
|
-
defaultWidth:
|
|
159
|
-
defaultHeight:
|
|
158
|
+
defaultWidth: h,
|
|
159
|
+
defaultHeight: g,
|
|
160
160
|
measured: e
|
|
161
161
|
});
|
|
162
162
|
i = t.width, a = t.height, M(), F();
|
|
@@ -165,7 +165,7 @@ function w(e, t = {}) {
|
|
|
165
165
|
return k.addEventListener("pointerdown", N), w = l((e) => {
|
|
166
166
|
o = e;
|
|
167
167
|
}), T = c((e) => {
|
|
168
|
-
|
|
168
|
+
x = e;
|
|
169
169
|
}), I(), {
|
|
170
170
|
update(e) {
|
|
171
171
|
let t = n.fill, r = n.width, i = n.height;
|
|
@@ -175,13 +175,13 @@ function w(e, t = {}) {
|
|
|
175
175
|
}, j(), (n.fill !== t || n.width !== r || n.height !== i) && I();
|
|
176
176
|
},
|
|
177
177
|
destroy() {
|
|
178
|
-
r || (r = !0, E?.(), w?.(), T?.(),
|
|
178
|
+
r || (r = !0, E?.(), w?.(), T?.(), C?.(), k.removeEventListener("pointerdown", N), O.remove());
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
//#endregion
|
|
183
183
|
//#region src/components/rippleWater/vue/RippleWater.vue
|
|
184
|
-
var
|
|
184
|
+
var w = /* @__PURE__ */ t({
|
|
185
185
|
__name: "RippleWater",
|
|
186
186
|
props: {
|
|
187
187
|
width: {},
|
|
@@ -209,22 +209,17 @@ var T = /* @__PURE__ */ t({
|
|
|
209
209
|
hint: {}
|
|
210
210
|
},
|
|
211
211
|
setup(t, { expose: s, emit: c }) {
|
|
212
|
-
let l = t, u = a(), d = null,
|
|
212
|
+
let l = t, u = a(), d = null, f = () => ({ ...l });
|
|
213
213
|
return n(() => {
|
|
214
|
-
u.value && (d =
|
|
215
|
-
}), o(() =>
|
|
214
|
+
u.value && (d = C(u.value, f()));
|
|
215
|
+
}), o(() => ({ ...l }), () => d?.update(f()), { deep: !0 }), r(() => {
|
|
216
216
|
d?.destroy(), d = null;
|
|
217
217
|
}), s({}), (t, n) => (i(), e("div", {
|
|
218
218
|
ref_key: "hostRef",
|
|
219
219
|
ref: u,
|
|
220
|
-
class: "cos-rippleWater-host"
|
|
221
|
-
style: {
|
|
222
|
-
display: "block",
|
|
223
|
-
width: "100%",
|
|
224
|
-
height: "100%"
|
|
225
|
-
}
|
|
220
|
+
class: "cos-rippleWater-host"
|
|
226
221
|
}, null, 512));
|
|
227
222
|
}
|
|
228
223
|
});
|
|
229
224
|
//#endregion
|
|
230
|
-
export {
|
|
225
|
+
export { w as RippleWater };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Component attribute → Core options parsing (v4 Element adapters).
|
|
3
|
+
* Keeps behavior consistent across 91 components.
|
|
4
|
+
*/
|
|
5
|
+
export type BooleanAttrMode =
|
|
6
|
+
/** `options.key = el.hasAttribute(attr)` — always written */
|
|
7
|
+
'presence'
|
|
8
|
+
/** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
|
|
9
|
+
| 'optional-true'
|
|
10
|
+
/** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
|
|
11
|
+
| 'optional-undefined';
|
|
12
|
+
export declare const camelToKebabAttr: (name: string) => string;
|
|
13
|
+
export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
14
|
+
export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
|
|
15
|
+
export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
|
|
16
|
+
export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
|
|
17
|
+
/** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
|
|
18
|
+
export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
|
|
19
|
+
export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
|
|
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
|
|
|
9
9
|
export { resolveCanvasBoxSize } from './canvas-box';
|
|
10
10
|
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
11
|
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
12
|
+
export type { BooleanAttrMode } from './element-options';
|
|
13
|
+
export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cos-design/ripple-water",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "RippleWater component from cos-design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/react/index.cjs",
|
|
@@ -84,6 +84,6 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@cos-design/shared": "4.
|
|
87
|
+
"@cos-design/shared": "4.1.0"
|
|
88
88
|
}
|
|
89
|
-
}
|
|
89
|
+
}
|