cradova 3.12.2 → 3.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
|
|
|
55
55
|
if (Array.isArray(value)) {
|
|
56
56
|
if (prop === "ref" && value.length === 2 && value[0] instanceof RefInstance && typeof value[1] === "string") {
|
|
57
57
|
const [refInstance, name] = value;
|
|
58
|
-
refInstance.
|
|
58
|
+
refInstance.refs[name] = element;
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
61
|
if (value.length === 2 && value[1] instanceof Signal && typeof value[0] === "string") {
|
|
@@ -227,10 +227,6 @@ function useCallback(callback, deps) {
|
|
|
227
227
|
return useMemo.call(this, () => callback, deps);
|
|
228
228
|
}
|
|
229
229
|
function useRef() {
|
|
230
|
-
const self = this;
|
|
231
|
-
if (typeof self !== "function") {
|
|
232
|
-
throw new Error("Cradova Hook Error: useRef called outside of a Cradova component context.");
|
|
233
|
-
}
|
|
234
230
|
return new RefInstance;
|
|
235
231
|
}
|
|
236
232
|
function useReducer(reducer, initialArg, initializer) {
|
|
@@ -1091,7 +1087,13 @@ class Router {
|
|
|
1091
1087
|
}
|
|
1092
1088
|
|
|
1093
1089
|
class RefInstance {
|
|
1094
|
-
|
|
1090
|
+
$refs = {};
|
|
1091
|
+
current(key) {
|
|
1092
|
+
return this.$refs[key];
|
|
1093
|
+
}
|
|
1094
|
+
get refs() {
|
|
1095
|
+
return this.$refs;
|
|
1096
|
+
}
|
|
1095
1097
|
bind(name) {
|
|
1096
1098
|
return [this, name];
|
|
1097
1099
|
}
|
|
@@ -43,7 +43,7 @@ export declare class Signal<Type = any> {
|
|
|
43
43
|
* @param callback function to call.
|
|
44
44
|
*/
|
|
45
45
|
notify<T extends keyof Type>(eventName: (T | "dataChanged" | "itemUpdated" | T[]) | (() => HTMLElement | void) | Comp | ((ctx: Comp) => HTMLElement), listener?: (() => HTMLElement | void) | Comp | ((this: Comp) => HTMLElement)): void;
|
|
46
|
-
computed<T extends keyof Type>(eventName: (T | "dataChanged" | "itemUpdated") | (() => HTMLElement) | Comp | ((
|
|
46
|
+
computed<T extends keyof Type>(eventName: (T | "dataChanged" | "itemUpdated") | (() => HTMLElement) | Comp | ((ctx: Comp) => HTMLElement), element?: (() => HTMLElement) | Comp | ((ctx: Comp) => HTMLElement)): HTMLElement | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* Cradova Signal
|
|
49
49
|
* ----
|
|
@@ -142,7 +142,9 @@ export declare class Router {
|
|
|
142
142
|
* make reference to dom elements
|
|
143
143
|
*/
|
|
144
144
|
export declare class RefInstance<T = unknown> {
|
|
145
|
-
|
|
145
|
+
private $refs;
|
|
146
|
+
current(key: string): T;
|
|
147
|
+
get refs(): Record<string, T>;
|
|
146
148
|
/**
|
|
147
149
|
* Bind a DOM element to a reference name.
|
|
148
150
|
* @param name - The name to reference the DOM element by.
|
|
@@ -48,9 +48,6 @@ export interface Comp extends Function {
|
|
|
48
48
|
useEffect: (effect: () => (() => void) | void, deps?: unknown[]) => void;
|
|
49
49
|
useMemo: <T>(factory: () => T, deps?: unknown[]) => T;
|
|
50
50
|
useCallback: <T extends (...args: any[]) => any>(callback: T, deps?: unknown[]) => T;
|
|
51
|
-
useRef: <T
|
|
52
|
-
current: Record<string, T>;
|
|
53
|
-
bind: (name: string) => any;
|
|
54
|
-
};
|
|
51
|
+
useRef: <T extends HTMLElement | Node | DocumentFragment>() => RefInstance<T>;
|
|
55
52
|
}
|
|
56
53
|
export {};
|