cradova 3.12.1 → 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.current[name] = element;
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) {
@@ -434,8 +430,8 @@ function invoke(fn, ...args) {
434
430
  return toComp(fn, args);
435
431
  }
436
432
  var useExternalEffect = (effect) => {
437
- return (comp, ...args) => {
438
- return effect.apply(comp, args);
433
+ return (ctx, ...args) => {
434
+ return effect(ctx, ...args);
439
435
  };
440
436
  };
441
437
 
@@ -1091,7 +1087,13 @@ class Router {
1091
1087
  }
1092
1088
 
1093
1089
  class RefInstance {
1094
- current = {};
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 | ((this: Comp) => HTMLElement), element?: (() => HTMLElement) | Comp | ((this: Comp) => HTMLElement)): HTMLElement | undefined;
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
- current: Record<string, T>;
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.
@@ -45,5 +45,5 @@ export declare function invoke(fn: (...args: any[]) => HTMLElement, ...args: any
45
45
  * Gives you access the component instance
46
46
  * @param effect - The function to invoke
47
47
  */
48
- export declare const useExternalEffect: <T>(effect: (this: Comp, ...args: any[]) => T) => (comp: Comp, ...args: any[]) => T;
48
+ export declare const useExternalEffect: <T>(effect: (ctx: Comp, ...args: any[]) => T) => (ctx: Comp, ...args: any[]) => T;
49
49
  export {};
@@ -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 = unknown>() => {
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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.12.1",
3
+ "version": "3.12.3",
4
4
  "description": "Build Powerful ⚡ Web Apps with Ease",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",