@cos-design/solar-system 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 +16 -16
- 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 +23 -23
- 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 { bindVisibilityPause as e } from "@cos-design/shared";
|
|
1
|
+
import { bindVisibilityPause as e, readBooleanAttr as t, readNumberAttr as n } from "@cos-design/shared";
|
|
2
2
|
import './element.css';//#region src/components/solarSystem/core/engine.ts
|
|
3
|
-
var
|
|
3
|
+
var r = "cos-solar-system", i = [
|
|
4
4
|
{
|
|
5
5
|
name: "Mercury",
|
|
6
6
|
radius: 0,
|
|
@@ -59,14 +59,14 @@ var t = "cos-solar-system", n = [
|
|
|
59
59
|
parent: 2
|
|
60
60
|
}
|
|
61
61
|
];
|
|
62
|
-
function
|
|
62
|
+
function a(t, n = {}) {
|
|
63
63
|
let a = {
|
|
64
64
|
width: 400,
|
|
65
65
|
height: 400,
|
|
66
66
|
speed: 1,
|
|
67
67
|
showOrbits: !0,
|
|
68
|
-
...
|
|
69
|
-
}, o = !1, s = 0, c = typeof document < "u" ? document.hidden : !1, l = null, u =
|
|
68
|
+
...n
|
|
69
|
+
}, o = !1, s = 0, c = typeof document < "u" ? document.hidden : !1, l = null, u = i.map((e) => ({
|
|
70
70
|
...e,
|
|
71
71
|
angle: Math.random() * Math.PI * 2
|
|
72
72
|
})), d = Array.from({ length: 80 }, () => ({
|
|
@@ -74,9 +74,9 @@ function r(r, i = {}) {
|
|
|
74
74
|
y: Math.random(),
|
|
75
75
|
alpha: Math.random() * .6
|
|
76
76
|
})), f = document.createElement("div");
|
|
77
|
-
f.className =
|
|
77
|
+
f.className = r;
|
|
78
78
|
let p = document.createElement("canvas");
|
|
79
|
-
p.className = `${
|
|
79
|
+
p.className = `${r}__canvas`, f.appendChild(p), t.appendChild(f);
|
|
80
80
|
let m = () => {
|
|
81
81
|
let e = a.width ?? 400, t = a.height ?? 400;
|
|
82
82
|
f.style.width = `${e}px`, f.style.height = `${t}px`, p.style.width = `${e}px`, p.style.height = `${t}px`;
|
|
@@ -124,12 +124,12 @@ function r(r, i = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/components/solarSystem/element/index.ts
|
|
127
|
-
var
|
|
128
|
-
function
|
|
129
|
-
let
|
|
130
|
-
return e
|
|
127
|
+
var o = "cos-solar-system";
|
|
128
|
+
function s(e) {
|
|
129
|
+
let r = {};
|
|
130
|
+
return n(r, e, "width", "width"), n(r, e, "height", "height"), n(r, e, "speed", "speed"), t(r, e, "showOrbits", "show-orbits", "presence"), r;
|
|
131
131
|
}
|
|
132
|
-
var
|
|
132
|
+
var c = class extends HTMLElement {
|
|
133
133
|
ctrl = null;
|
|
134
134
|
static get observedAttributes() {
|
|
135
135
|
return [
|
|
@@ -140,15 +140,15 @@ var o = class extends HTMLElement {
|
|
|
140
140
|
];
|
|
141
141
|
}
|
|
142
142
|
connectedCallback() {
|
|
143
|
-
this.ctrl =
|
|
143
|
+
this.ctrl = a(this, s(this));
|
|
144
144
|
}
|
|
145
145
|
disconnectedCallback() {
|
|
146
146
|
this.ctrl?.destroy(), this.ctrl = null;
|
|
147
147
|
}
|
|
148
148
|
attributeChangedCallback() {
|
|
149
|
-
this.ctrl?.update(
|
|
149
|
+
this.ctrl?.update(s(this));
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
typeof customElements < "u" && !customElements.get("cos-solar-system") && customElements.define(
|
|
152
|
+
typeof customElements < "u" && !customElements.get("cos-solar-system") && customElements.define(o, c);
|
|
153
153
|
//#endregion
|
|
154
|
-
export {
|
|
154
|
+
export { c as CosSolarSystemElement, o 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 { bindVisibilityPause as s
|
|
2
|
+
import { bindVisibilityPause as s } from "@cos-design/shared";
|
|
3
3
|
import './vue.css';//#region src/components/solarSystem/core/engine.ts
|
|
4
|
-
var
|
|
4
|
+
var c = "cos-solar-system", l = [
|
|
5
5
|
{
|
|
6
6
|
name: "Mercury",
|
|
7
7
|
radius: 0,
|
|
@@ -60,14 +60,14 @@ var l = "cos-solar-system", u = [
|
|
|
60
60
|
parent: 2
|
|
61
61
|
}
|
|
62
62
|
];
|
|
63
|
-
function
|
|
63
|
+
function u(e, t = {}) {
|
|
64
64
|
let n = {
|
|
65
65
|
width: 400,
|
|
66
66
|
height: 400,
|
|
67
67
|
speed: 1,
|
|
68
68
|
showOrbits: !0,
|
|
69
69
|
...t
|
|
70
|
-
}, r = !1, i = 0, a = typeof document < "u" ? document.hidden : !1, o = null,
|
|
70
|
+
}, r = !1, i = 0, a = typeof document < "u" ? document.hidden : !1, o = null, u = l.map((e) => ({
|
|
71
71
|
...e,
|
|
72
72
|
angle: Math.random() * Math.PI * 2
|
|
73
73
|
})), d = Array.from({ length: 80 }, () => ({
|
|
@@ -75,9 +75,9 @@ function d(e, t = {}) {
|
|
|
75
75
|
y: Math.random(),
|
|
76
76
|
alpha: Math.random() * .6
|
|
77
77
|
})), f = document.createElement("div");
|
|
78
|
-
f.className =
|
|
78
|
+
f.className = c;
|
|
79
79
|
let p = document.createElement("canvas");
|
|
80
|
-
p.className = `${
|
|
80
|
+
p.className = `${c}__canvas`, f.appendChild(p), e.appendChild(f);
|
|
81
81
|
let m = () => {
|
|
82
82
|
let e = n.width ?? 400, t = n.height ?? 400;
|
|
83
83
|
f.style.width = `${e}px`, f.style.height = `${t}px`, p.style.width = `${e}px`, p.style.height = `${t}px`;
|
|
@@ -89,21 +89,21 @@ function d(e, t = {}) {
|
|
|
89
89
|
if (r || (i = requestAnimationFrame(h), a)) return;
|
|
90
90
|
let e = p.getContext("2d");
|
|
91
91
|
if (!e) return;
|
|
92
|
-
let t = n.width ?? 400, o = n.height ?? 400, s = n.speed ?? 1,
|
|
92
|
+
let t = n.width ?? 400, o = n.height ?? 400, s = n.speed ?? 1, c = n.showOrbits ?? !0, l = t / 2, f = o / 2, m = Math.min(t, o) / 380, g = [];
|
|
93
93
|
e.fillStyle = "#0f172a", e.fillRect(0, 0, t, o), d.forEach((n) => {
|
|
94
94
|
e.fillStyle = `rgba(255,255,255,${n.alpha})`, e.fillRect(n.x * t, n.y * o, 1, 1);
|
|
95
|
-
}), e.beginPath(), e.arc(
|
|
96
|
-
let _ = e.createRadialGradient(
|
|
97
|
-
_.addColorStop(0, "#fef08a"), _.addColorStop(.5, "#fbbf24"), _.addColorStop(1, "#f97316"), e.fillStyle = _, e.shadowColor = "#fbbf24", e.shadowBlur = 24, e.fill(), e.shadowBlur = 0,
|
|
95
|
+
}), e.beginPath(), e.arc(l, f, 18 * m, 0, Math.PI * 2);
|
|
96
|
+
let _ = e.createRadialGradient(l, f, 0, l, f, 18 * m);
|
|
97
|
+
_.addColorStop(0, "#fef08a"), _.addColorStop(.5, "#fbbf24"), _.addColorStop(1, "#f97316"), e.fillStyle = _, e.shadowColor = "#fbbf24", e.shadowBlur = 24, e.fill(), e.shadowBlur = 0, u.forEach((t, n) => {
|
|
98
98
|
t.angle += t.speed * .008 * s / Math.sqrt(t.orbit);
|
|
99
|
-
let r =
|
|
99
|
+
let r = l, i = f;
|
|
100
100
|
t.parent !== void 0 && g[t.parent] && (r = g[t.parent].x, i = g[t.parent].y);
|
|
101
|
-
let a = t.orbit * m, o = r + Math.cos(t.angle) * a,
|
|
101
|
+
let a = t.orbit * m, o = r + Math.cos(t.angle) * a, u = i + Math.sin(t.angle) * a;
|
|
102
102
|
if (g[n] = {
|
|
103
103
|
x: o,
|
|
104
|
-
y:
|
|
105
|
-
},
|
|
106
|
-
let n = e.createRadialGradient(o - 2,
|
|
104
|
+
y: u
|
|
105
|
+
}, c && t.parent === void 0 && (e.beginPath(), e.arc(r, i, a, 0, Math.PI * 2), e.strokeStyle = "rgba(148, 163, 184, 0.15)", e.lineWidth = 1, e.stroke()), t.name === "Saturn" && (e.beginPath(), e.ellipse(o, u, t.size * m * 1.8, t.size * m * .5, t.angle * .3, 0, Math.PI * 2), e.strokeStyle = "rgba(252, 211, 77, 0.5)", e.lineWidth = 1.5, e.stroke()), e.beginPath(), e.arc(o, u, t.size * m, 0, Math.PI * 2), e.fillStyle = t.color, t.name === "Earth") {
|
|
106
|
+
let n = e.createRadialGradient(o - 2, u - 2, 0, o, u, t.size * m);
|
|
107
107
|
n.addColorStop(0, "#4ade80"), n.addColorStop(.6, t.color), n.addColorStop(1, "#1d4ed8"), e.fillStyle = n;
|
|
108
108
|
}
|
|
109
109
|
e.fill();
|
|
@@ -125,7 +125,7 @@ function d(e, t = {}) {
|
|
|
125
125
|
}
|
|
126
126
|
//#endregion
|
|
127
127
|
//#region src/components/solarSystem/vue/SolarSystem.vue
|
|
128
|
-
var
|
|
128
|
+
var d = /* @__PURE__ */ t({
|
|
129
129
|
__name: "SolarSystem",
|
|
130
130
|
props: {
|
|
131
131
|
width: {},
|
|
@@ -133,18 +133,18 @@ var f = /* @__PURE__ */ t({
|
|
|
133
133
|
speed: {},
|
|
134
134
|
showOrbits: { type: Boolean }
|
|
135
135
|
},
|
|
136
|
-
setup(t, { expose: s, emit:
|
|
137
|
-
let
|
|
136
|
+
setup(t, { expose: s, emit: c }) {
|
|
137
|
+
let l = t, d = a(), f = null, p = () => ({ ...l });
|
|
138
138
|
return n(() => {
|
|
139
|
-
|
|
140
|
-
}), o(() =>
|
|
141
|
-
|
|
139
|
+
d.value && (f = u(d.value, p()));
|
|
140
|
+
}), o(() => ({ ...l }), () => f?.update(p()), { deep: !0 }), r(() => {
|
|
141
|
+
f?.destroy(), f = null;
|
|
142
142
|
}), s({}), (t, n) => (i(), e("div", {
|
|
143
143
|
ref_key: "hostRef",
|
|
144
|
-
ref:
|
|
144
|
+
ref: d,
|
|
145
145
|
class: "cos-solarSystem-host"
|
|
146
146
|
}, null, 512));
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
//#endregion
|
|
150
|
-
export {
|
|
150
|
+
export { d as SolarSystem };
|
|
@@ -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/solar-system",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "SolarSystem 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
|
+
}
|