@neeloong/form 0.6.2 → 0.7.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/index.d.mts +29 -32
- package/index.js +205 -131
- package/index.min.js +7 -7
- package/index.min.mjs +8 -8
- package/index.mjs +205 -131
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.7.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -216,6 +216,13 @@ declare namespace Schema {
|
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
declare const ref: unique symbol;
|
|
220
|
+
type Ref = {
|
|
221
|
+
[ref]: Store;
|
|
222
|
+
[k: string]: Ref | undefined;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** @import { Ref } from './ref.mjs' */
|
|
219
226
|
/** @import { Schema } from '../types.mjs' */
|
|
220
227
|
/**
|
|
221
228
|
* @template [T=any]
|
|
@@ -228,10 +235,17 @@ declare class Store<T = any> {
|
|
|
228
235
|
*/
|
|
229
236
|
static create(schema: Schema, options?: {
|
|
230
237
|
new?: boolean | undefined;
|
|
231
|
-
}):
|
|
238
|
+
}): Store<any>;
|
|
239
|
+
/**
|
|
240
|
+
* @param {string} type
|
|
241
|
+
* @param {{new(...p: ConstructorParameters<typeof Store>): Store}} Class
|
|
242
|
+
*/
|
|
243
|
+
static setStore(type: string, Class: {
|
|
244
|
+
new (...p: ConstructorParameters<typeof Store>): Store;
|
|
245
|
+
}): void;
|
|
232
246
|
/**
|
|
233
247
|
* @param {Schema.Field} schema
|
|
234
|
-
* @param {object} options
|
|
248
|
+
* @param {object} [options]
|
|
235
249
|
* @param {*} [options.parent]
|
|
236
250
|
* @param {*} [options.state]
|
|
237
251
|
* @param {number | string | null} [options.index]
|
|
@@ -252,13 +266,16 @@ declare class Store<T = any> {
|
|
|
252
266
|
* @param {number} [options.step] 日期、时间、数字的步长
|
|
253
267
|
* @param {(Schema.Value.Group | Schema.Value | string | number)[]} [options.values] 可选值
|
|
254
268
|
*
|
|
269
|
+
* @param {Ref?} [options.ref]
|
|
270
|
+
*
|
|
255
271
|
* @param {((value: any) => any)?} [options.setValue]
|
|
256
272
|
* @param {((value: any) => any)?} [options.setState]
|
|
257
273
|
* @param {((value: any, state: any) => [value: any, state: any])?} [options.convert]
|
|
258
|
-
*
|
|
259
|
-
* @param {((value: T?, index: any) => void)?} [options.
|
|
274
|
+
*
|
|
275
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
276
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdateState]
|
|
260
277
|
*/
|
|
261
|
-
constructor(schema: Schema.Field, { null: isNull, state, setValue, setState, convert, onUpdate, onUpdateState, index, length, new: isNew, parent: parentNode, hidden, clearable, required, disabled, readonly, label, description, placeholder, min, max, step, values }
|
|
278
|
+
constructor(schema: Schema.Field, { null: isNull, state, ref, setValue, setState, convert, onUpdate, onUpdateState, index, length, new: isNew, parent: parentNode, hidden, clearable, required, disabled, readonly, label, description, placeholder, min, max, step, values }?: {
|
|
262
279
|
parent?: any;
|
|
263
280
|
state?: any;
|
|
264
281
|
index?: string | number | null | undefined;
|
|
@@ -277,11 +294,12 @@ declare class Store<T = any> {
|
|
|
277
294
|
max?: number | undefined;
|
|
278
295
|
step?: number | undefined;
|
|
279
296
|
values?: (string | number | Schema.Value | Schema.Value.Group)[] | undefined;
|
|
297
|
+
ref?: Ref | null | undefined;
|
|
280
298
|
setValue?: ((value: any) => any) | null | undefined;
|
|
281
299
|
setState?: ((value: any) => any) | null | undefined;
|
|
282
300
|
convert?: ((value: any, state: any) => [value: any, state: any]) | null | undefined;
|
|
283
|
-
onUpdate?: ((value: T | null, index: any) => void) | null | undefined;
|
|
284
|
-
onUpdateState?: ((value: T | null, index: any) => void) | null | undefined;
|
|
301
|
+
onUpdate?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
302
|
+
onUpdateState?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
285
303
|
});
|
|
286
304
|
/**
|
|
287
305
|
*
|
|
@@ -300,6 +318,7 @@ declare class Store<T = any> {
|
|
|
300
318
|
listen<K extends keyof Schema.Events>(event: K, listener: (this: this, p: Schema.Events[K], store: this) => void | boolean | null): () => void;
|
|
301
319
|
get null(): boolean;
|
|
302
320
|
get kind(): string;
|
|
321
|
+
get ref(): Ref;
|
|
303
322
|
schema: Schema.Field;
|
|
304
323
|
get store(): this;
|
|
305
324
|
get parent(): Store<any> | null;
|
|
@@ -372,37 +391,15 @@ declare class Store<T = any> {
|
|
|
372
391
|
*/
|
|
373
392
|
child(key: string | number): Store | null;
|
|
374
393
|
get changed(): boolean;
|
|
375
|
-
get saved(): boolean;
|
|
376
394
|
set value(v: T | null);
|
|
377
395
|
get value(): T | null;
|
|
378
396
|
set state(v: any);
|
|
379
397
|
get state(): any;
|
|
380
|
-
|
|
381
|
-
destroy(): void;
|
|
398
|
+
reset(value?: T | null): void;
|
|
382
399
|
/** @returns {IterableIterator<[key: string | number, value: Store]>} */
|
|
383
400
|
[Symbol.iterator](): IterableIterator<[key: string | number, value: Store]>;
|
|
384
401
|
#private;
|
|
385
402
|
}
|
|
386
|
-
declare class ObjectStore extends Store<any> {
|
|
387
|
-
/**
|
|
388
|
-
* @param {Schema.Object & Schema.Attr} schema
|
|
389
|
-
* @param {object} [options]
|
|
390
|
-
* @param {Store?} [options.parent]
|
|
391
|
-
* @param {string | number} [options.index]
|
|
392
|
-
* @param {boolean} [options.new]
|
|
393
|
-
* @param {(value: any, index: any) => void} [options.onUpdate]
|
|
394
|
-
* @param {(value: any, index: any) => void} [options.onUpdateState]
|
|
395
|
-
*/
|
|
396
|
-
constructor(schema: Schema.Object & Schema.Attr, { parent, index, new: isNew, onUpdate, onUpdateState }?: {
|
|
397
|
-
parent?: Store<any> | null | undefined;
|
|
398
|
-
index?: string | number | undefined;
|
|
399
|
-
new?: boolean | undefined;
|
|
400
|
-
onUpdate?: ((value: any, index: any) => void) | undefined;
|
|
401
|
-
onUpdateState?: ((value: any, index: any) => void) | undefined;
|
|
402
|
-
});
|
|
403
|
-
[Symbol.iterator](): Generator<[string, Store<any>], void, unknown>;
|
|
404
|
-
#private;
|
|
405
|
-
}
|
|
406
403
|
|
|
407
404
|
/**
|
|
408
405
|
* @overload
|
|
@@ -446,4 +443,4 @@ declare function watch<T>(getter: () => T, callback: (value: T) => void, immedia
|
|
|
446
443
|
*/
|
|
447
444
|
declare function effect(fn: () => void): () => void;
|
|
448
445
|
|
|
449
|
-
export { Component, index_d as Layout, Schema, Store, type VerifyError, effect, _default as render, watch };
|
|
446
|
+
export { Component, index_d as Layout, type Ref, Schema, Store, type VerifyError, effect, _default as render, watch };
|