@but212/atom-effect-jquery 0.27.0 → 0.29.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
@@ -1,14 +1,7 @@
1
- import { atom } from '@but212/atom-effect';
2
- import { batch } from '@but212/atom-effect';
3
- import { computed } from '@but212/atom-effect';
4
1
  import { ComputedAtom } from '@but212/atom-effect';
5
2
  import { default as default_2 } from 'jquery';
6
- import { effect } from '@but212/atom-effect';
7
3
  import { EffectObject } from '@but212/atom-effect';
8
- import { isAtom } from '@but212/atom-effect';
9
- import { isComputed } from '@but212/atom-effect';
10
4
  import { ReadonlyAtom } from '@but212/atom-effect';
11
- import { untracked } from '@but212/atom-effect';
12
5
  import { WritableAtom } from '@but212/atom-effect';
13
6
 
14
7
  /**
@@ -18,15 +11,6 @@ import { WritableAtom } from '@but212/atom-effect';
18
11
  */
19
12
  declare type AsyncReactiveValue<T> = T | ReadonlyAtom<T | Promise<T>> | Promise<T> | (() => T | Promise<T>);
20
13
 
21
- export { atom }
22
-
23
- /**
24
- * Creates a two-way "lens" for a specific property path on an object-based atom.
25
- */
26
- export declare function atomLens<T extends object, P extends Paths<T>>(atom: WritableAtom<T>, path: P): WritableAtom<PathValue<T, P>>;
27
-
28
- export { batch }
29
-
30
14
  export declare interface BindingOptions<T = unknown> {
31
15
  text?: AsyncReactiveValue<unknown>;
32
16
  html?: AsyncReactiveValue<string>;
@@ -38,7 +22,7 @@ export declare interface BindingOptions<T = unknown> {
38
22
  hide?: AsyncReactiveValue<boolean>;
39
23
  val?: WritableAtom<T> | [atom: WritableAtom<T>, options: ValOptions<T>];
40
24
  checked?: WritableAtom<boolean>;
41
- form?: WritableAtom<T extends object ? T : unknown>;
25
+ form?: WritableAtom<T extends object ? T : unknown> | [atom: WritableAtom<T extends object ? T : unknown>, options: FormOptions<unknown>];
42
26
  on?: Record<string, (e: JQuery.Event) => void>;
43
27
  }
44
28
 
@@ -88,13 +72,6 @@ declare class BindingRegistry {
88
72
 
89
73
  export declare type ComponentFn<P = Record<string, unknown>> = ($el: JQuery, props: P) => EffectResult;
90
74
 
91
- /**
92
- * Composes an existing lens with a sub-path to create a deeper lens.
93
- */
94
- export declare const composeLens: <T extends object, P extends Paths<T>>(lens: WritableAtom<T>, path: P) => WritableAtom<PathValue<T, P>>;
95
-
96
- export { computed }
97
-
98
75
  export { ComputedAtom }
99
76
 
100
77
  export declare type CssBindings = Record<string, CssValue>;
@@ -114,8 +91,6 @@ export declare function disableAutoCleanup(): void;
114
91
  */
115
92
  export declare function disablejQueryOverrides(): void;
116
93
 
117
- export { effect }
118
-
119
94
  export declare type EffectCleanup = () => void;
120
95
 
121
96
  export declare type EffectResult = undefined | EffectCleanup;
@@ -146,9 +121,15 @@ export declare interface FetchOptions<T> {
146
121
  eager?: boolean;
147
122
  }
148
123
 
149
- export { isAtom }
150
-
151
- export { isComputed }
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
+ }
152
133
 
153
134
  /** Checks if a given value is a reactive node (Atom or Computed). */
154
135
  export declare const isReactive: (v: unknown) => v is ReadonlyAtom<unknown>;
@@ -157,11 +138,6 @@ declare type KeysOfType<T, V> = {
157
138
  [K in keyof T]: T[K] extends V ? K : never;
158
139
  }[keyof T];
159
140
 
160
- /**
161
- * Creates a lens factory bound to a specific atom.
162
- */
163
- export declare const lensFor: <T extends object>(atom: WritableAtom<T>) => <P extends Paths<T>>(path: P) => WritableAtom<PathValue<T, P>>;
164
-
165
141
  declare type ListKey = string | number;
166
142
 
167
143
  declare type ListKeyFn<T> = (item: T, index: number) => ListKey;
@@ -180,34 +156,9 @@ export declare interface ListOptions<T> {
180
156
 
181
157
  declare type ListRenderResult = string | Element | DocumentFragment | JQuery;
182
158
 
183
- /** Max recursion depth for dot-paths. */
184
- declare type MaxDepth = 8;
185
-
186
159
  /** Resolves after microtask effects flush. Fast Promise-based scheduling. */
187
160
  export declare const nextTick: () => Promise<void>;
188
161
 
189
- /**
190
- * Generates a union of all possible dot-separated paths for a given type T.
191
- *
192
- * Used for `atomLens` to provide IDE autocomplete and type safety when
193
- * zooming into deeply nested reactive objects.
194
- *
195
- * @example
196
- * type User = { profile: { name: string } };
197
- * type P = Paths<User>; // "profile" | "profile.name"
198
- */
199
- export declare type Paths<T, D extends unknown[] = []> = D['length'] extends MaxDepth ? never : T extends object ? {
200
- [K in keyof T & (string | number)]-?: `${K}` | (T[K] extends object ? `${K}.${Paths<T[K], [...D, 1]>}` : never);
201
- }[keyof T & (string | number)] : never;
202
-
203
- /**
204
- * Resolves the type of a value at a specific dot-path P within type T.
205
- *
206
- * Works in tandem with `Paths<T>` to ensure that lensed atoms have
207
- * the correct inferred type for the member they point to.
208
- */
209
- export declare type PathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ? StringKeyToNumber<K> extends keyof T ? PathValue<T[StringKeyToNumber<K> & keyof T], Rest> : never : StringKeyToNumber<P> extends keyof T ? T[StringKeyToNumber<P> & keyof T] : never;
210
-
211
162
  export declare type PrimitiveValue = string | number | boolean | null | undefined;
212
163
 
213
164
  /**
@@ -254,17 +205,12 @@ export declare interface Router {
254
205
  destroy: () => void;
255
206
  }
256
207
 
257
- /** Helper to convert numeric string to number for array indexing. */
258
- declare type StringKeyToNumber<S extends string> = S extends `${infer N extends number}` ? N : S;
259
-
260
208
  export declare interface TemplateRoute extends RouteLifecycle {
261
209
  template: string;
262
210
  render?: never;
263
211
  onMount?: ($content: JQuery, onUnmount: (cleanupFn: () => void) => void, router: Router) => void;
264
212
  }
265
213
 
266
- export { untracked }
267
-
268
214
  /**
269
215
  * Options for `atomVal`, `atomChecked`, and `atomForm` bindings.
270
216
  */