@esportsplus/reactivity 0.29.11 → 0.29.13
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/build/types.d.ts +2 -2
- package/package.json +2 -2
- package/src/types.ts +2 -2
- package/test/range.ts +45 -0
package/build/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface Computed<T> {
|
|
|
5
5
|
cleanup: VoidFunction | VoidFunction[] | null;
|
|
6
6
|
deps: Link | null;
|
|
7
7
|
depsTail: Link | null;
|
|
8
|
-
fn: (onCleanup
|
|
8
|
+
fn: (onCleanup: (fn: VoidFunction) => typeof fn) => T;
|
|
9
9
|
height: number;
|
|
10
10
|
nextHeap: Computed<unknown> | undefined;
|
|
11
11
|
prevHeap: Computed<unknown>;
|
|
@@ -29,7 +29,7 @@ type Reactive<T> = T extends (...args: unknown[]) => Promise<infer R> ? (R | und
|
|
|
29
29
|
} : T extends (...args: any[]) => infer R ? R & {
|
|
30
30
|
readonly [READONLY]: true;
|
|
31
31
|
} : T extends (infer U)[] ? U[] & Pick<ReactiveArray<U>, 'clear' | 'dispose' | 'on' | 'once'> : T extends Record<PropertyKey, unknown> ? {
|
|
32
|
-
[K in keyof T]: Reactive<T[K]
|
|
32
|
+
[K in keyof T]: T[K] extends (infer U)[] ? Reactive<U[]> : T[K];
|
|
33
33
|
} & {
|
|
34
34
|
dispose: VoidFunction;
|
|
35
35
|
} : T;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"@esportsplus/utilities": "^0.27.2"
|
|
5
5
|
},
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@esportsplus/typescript": "^0.27.
|
|
7
|
+
"@esportsplus/typescript": "^0.27.3",
|
|
8
8
|
"@types/node": "^25.0.3",
|
|
9
9
|
"vite": "^7.3.1"
|
|
10
10
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"types": "build/index.d.ts",
|
|
38
|
-
"version": "0.29.
|
|
38
|
+
"version": "0.29.13",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsc",
|
|
41
41
|
"build:test": "pnpm build && vite build --config test/vite.config.ts",
|
package/src/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ interface Computed<T> {
|
|
|
7
7
|
cleanup: VoidFunction | VoidFunction[] | null;
|
|
8
8
|
deps: Link | null;
|
|
9
9
|
depsTail: Link | null;
|
|
10
|
-
fn: (onCleanup
|
|
10
|
+
fn: (onCleanup: (fn: VoidFunction) => typeof fn) => T;
|
|
11
11
|
height: number;
|
|
12
12
|
nextHeap: Computed<unknown> | undefined;
|
|
13
13
|
prevHeap: Computed<unknown>;
|
|
@@ -43,7 +43,7 @@ type Reactive<T> = T extends (...args: unknown[]) => Promise<infer R>
|
|
|
43
43
|
: T extends (infer U)[]
|
|
44
44
|
? U[] & Pick<ReactiveArray<U>, 'clear' | 'dispose' | 'on' | 'once'>
|
|
45
45
|
: T extends Record<PropertyKey, unknown>
|
|
46
|
-
? { [K in keyof T]: Reactive<T[K]
|
|
46
|
+
? { [K in keyof T]: T[K] extends (infer U)[] ? Reactive<U[]> : T[K]; } & { dispose: VoidFunction }
|
|
47
47
|
: T;
|
|
48
48
|
|
|
49
49
|
type Signal<T> = {
|
package/test/range.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { reactive, root } from '@esportsplus/reactivity';
|
|
2
|
+
// import { html, type Attributes } from '@esportsplus/template';
|
|
3
|
+
// import form from '~/components/form';
|
|
4
|
+
import './scss/index.scss';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default function(
|
|
8
|
+
this: { attributes?: Record<PropertyKey, unknown> } | any,
|
|
9
|
+
attributes: Record<PropertyKey, unknown> & { max: number, min: number, state?: { active: boolean, error: string, value: number } }
|
|
10
|
+
) {
|
|
11
|
+
let { max, min } = attributes,
|
|
12
|
+
state = attributes.state || reactive({
|
|
13
|
+
active: false,
|
|
14
|
+
error: '',
|
|
15
|
+
value: 0
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (attributes?.value) {
|
|
19
|
+
state.value = Number( attributes.value );
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
return html`
|
|
24
|
+
<input
|
|
25
|
+
class='range --border-state --border-black'
|
|
26
|
+
style='${() => `--thumb-position: ${((state.value - min) / (max - min)) * 100}%`}'
|
|
27
|
+
type='range'
|
|
28
|
+
${this?.attributes}
|
|
29
|
+
${attributes}
|
|
30
|
+
${{
|
|
31
|
+
class: () => state.active && '--active',
|
|
32
|
+
onfocusin: () => {
|
|
33
|
+
state.active = true;
|
|
34
|
+
},
|
|
35
|
+
onfocusout: () => {
|
|
36
|
+
state.active = false;
|
|
37
|
+
},
|
|
38
|
+
oninput: (e: any) => {
|
|
39
|
+
state.value = Number((e.target as HTMLInputElement).value);
|
|
40
|
+
},
|
|
41
|
+
value: root(() => (attributes?.value as number) || state.value || 0)
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
`;
|
|
45
|
+
};
|