@but212/atom-effect-jquery 0.28.0 → 0.30.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/index.d.ts CHANGED
@@ -12,7 +12,7 @@ import { WritableAtom } from '@but212/atom-effect';
12
12
  declare type AsyncReactiveValue<T> = T | ReadonlyAtom<T | Promise<T>> | Promise<T> | (() => T | Promise<T>);
13
13
 
14
14
  export declare interface BindingOptions<T = unknown> {
15
- text?: AsyncReactiveValue<unknown>;
15
+ text?: AsyncReactiveValue<unknown> | [source: AsyncReactiveValue<unknown>, formatter: (v: unknown) => string];
16
16
  html?: AsyncReactiveValue<string>;
17
17
  class?: Record<string, AsyncReactiveValue<boolean>>;
18
18
  css?: CssBindings;
@@ -22,7 +22,10 @@ export declare interface BindingOptions<T = unknown> {
22
22
  hide?: AsyncReactiveValue<boolean>;
23
23
  val?: WritableAtom<T> | [atom: WritableAtom<T>, options: ValOptions<T>];
24
24
  checked?: WritableAtom<boolean>;
25
- form?: WritableAtom<T extends object ? T : unknown>;
25
+ form?: WritableAtom<T extends object ? T : unknown> | [
26
+ atom: WritableAtom<T extends object ? T : unknown>,
27
+ options: FormOptions<T extends object ? T : unknown>
28
+ ];
26
29
  on?: Record<string, (e: JQuery.Event) => void>;
27
30
  }
28
31
 
@@ -65,9 +68,9 @@ declare class BindingRegistry {
65
68
  */
66
69
  setComponentCleanup(el: Element, fn: (() => void) | undefined): void;
67
70
  hasBind(el: Element): boolean;
68
- cleanup(el: Element | Node): void;
71
+ cleanup(el: Node): void;
69
72
  cleanupDescendants(el: Element | DocumentFragment | ShadowRoot): void;
70
- cleanupTree(el: Element | Node): void;
73
+ cleanupTree(el: Node): void;
71
74
  }
72
75
 
73
76
  export declare type ComponentFn<P = Record<string, unknown>> = ($el: JQuery, props: P) => EffectResult;
@@ -99,13 +102,10 @@ export declare type EffectResult = undefined | EffectCleanup;
99
102
  * Starts observing `root` for removed elements and automatically disposes
100
103
  * their reactive bindings when they leave the DOM.
101
104
  *
105
+ * Supports Element, ShadowRoot, and DocumentFragment roots.
102
106
  * Multiple roots can be observed concurrently (e.g. for Micro-Frontends).
103
- * The `root` parameter is required (no default) to make the caller explicit
104
- * about which subtree is being observed.
105
- *
106
- * Idempotent: calling more than once with the same root has no effect.
107
107
  */
108
- export declare function enableAutoCleanup(root: Element): void;
108
+ export declare function enableAutoCleanup(root: Element | ShadowRoot | DocumentFragment): void;
109
109
 
110
110
  export declare function enablejQueryOverrides(): void;
111
111
 
@@ -121,6 +121,16 @@ export declare interface FetchOptions<T> {
121
121
  eager?: boolean;
122
122
  }
123
123
 
124
+ /**
125
+ * Options for `atomForm` binding.
126
+ */
127
+ declare interface FormOptions<T> extends ValOptions<T> {
128
+ /** Custom function to transform field value based on path before atomic sync. */
129
+ transform?: (path: string, value: unknown) => unknown;
130
+ /** Callback triggered when a field value changes. */
131
+ onChange?: (path: string, value: unknown) => void;
132
+ }
133
+
124
134
  /** Checks if a given value is a reactive node (Atom or Computed). */
125
135
  export declare const isReactive: (v: unknown) => v is ReadonlyAtom<unknown>;
126
136