@neeloong/form 0.13.0 → 0.15.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/README.md +1 -0
- package/index.d.mts +142 -11
- package/index.js +660 -20
- package/index.min.js +8 -8
- package/index.min.mjs +8 -8
- package/index.mjs +655 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -311,6 +311,7 @@ render(store, layouts, app);
|
|
|
311
311
|
- `$creatable` 只读 值是否可创建(`$new` 为 `true` 时,字段只读)
|
|
312
312
|
- `$immutable` 只读 值是否不可改变(`$new` 为 `false` 时,字段只读)
|
|
313
313
|
- `$new` 只读 是否新建项
|
|
314
|
+
- `$loading` 只读 加载状态
|
|
314
315
|
- `$readonly` 只读 是否只读
|
|
315
316
|
- `$hidden` 只读 是否可隐藏
|
|
316
317
|
- `$clearable` 只读 是否可清除
|
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.15.0
|
|
3
3
|
* (c) 2024-2025 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -13,7 +13,7 @@ export { Signal } from 'signal-polyfill';
|
|
|
13
13
|
* @param {Layout.Options} [options] 解析选项
|
|
14
14
|
* @returns {Layout.Child[]}
|
|
15
15
|
*/
|
|
16
|
-
declare function parse(source: string, { createCalc, createInit, createEvent, simpleTag, enableHTML, }?: Options): Child[];
|
|
16
|
+
declare function parse(source: string, { createCalc, createInit, createEvent, simpleTag, enableHTML, }?: Options$1): Child[];
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* 增强信息
|
|
@@ -39,7 +39,7 @@ type Enhancement$1 = {
|
|
|
39
39
|
/**
|
|
40
40
|
* 解析选项
|
|
41
41
|
*/
|
|
42
|
-
type Options = {
|
|
42
|
+
type Options$1 = {
|
|
43
43
|
/**
|
|
44
44
|
* 启用 `!html` 指令
|
|
45
45
|
*/
|
|
@@ -349,13 +349,12 @@ type index_d_Enum = Enum;
|
|
|
349
349
|
type index_d_EventListener = EventListener;
|
|
350
350
|
type index_d_Fragment = Fragment;
|
|
351
351
|
declare const index_d_Node: typeof Node;
|
|
352
|
-
type index_d_Options = Options;
|
|
353
352
|
type index_d_Select = Select;
|
|
354
353
|
type index_d_Template = Template;
|
|
355
354
|
type index_d_Variable<T = unknown> = Variable<T>;
|
|
356
355
|
declare const index_d_parse: typeof parse;
|
|
357
356
|
declare namespace index_d {
|
|
358
|
-
export { type index_d_Calc as Calc, type index_d_CallTemplate as CallTemplate, type index_d_Child as Child, type index_d_Content as Content, type index_d_Divergent as Divergent, type index_d_DivergentChildren as DivergentChildren, type Enhancement$1 as Enhancement, type index_d_Enum as Enum, type index_d_EventListener as EventListener, type index_d_Fragment as Fragment, index_d_Node as Node, type
|
|
357
|
+
export { type index_d_Calc as Calc, type index_d_CallTemplate as CallTemplate, type index_d_Child as Child, type index_d_Content as Content, type index_d_Divergent as Divergent, type index_d_DivergentChildren as DivergentChildren, type Enhancement$1 as Enhancement, type index_d_Enum as Enum, type index_d_EventListener as EventListener, type index_d_Fragment as Fragment, index_d_Node as Node, type Options$1 as Options, type index_d_Select as Select, type index_d_Template as Template, type index_d_Variable as Variable, index_d_parse as parse };
|
|
359
358
|
}
|
|
360
359
|
|
|
361
360
|
type VerifyError = any;
|
|
@@ -586,6 +585,7 @@ declare namespace Schema {
|
|
|
586
585
|
* 元信息
|
|
587
586
|
*/
|
|
588
587
|
meta?: M_1 | undefined;
|
|
588
|
+
default?: ((store: Store) => any) | any;
|
|
589
589
|
/**
|
|
590
590
|
* 自定义组件
|
|
591
591
|
*/
|
|
@@ -814,6 +814,7 @@ declare class Store<T = any, M = any> {
|
|
|
814
814
|
* @param {Schema.Field<M>} schema 字段的 Schema 定义
|
|
815
815
|
* @param {object} [options] 可选配置
|
|
816
816
|
* @param {Store?} [options.parent]
|
|
817
|
+
* @param {((store: Store) => any) | any} [options.default]
|
|
817
818
|
* @param {*} [options.state]
|
|
818
819
|
* @param {number | string | null} [options.index]
|
|
819
820
|
* @param {number | Signal.State<number> | Signal.Computed<number>} [options.size]
|
|
@@ -848,8 +849,9 @@ declare class Store<T = any, M = any> {
|
|
|
848
849
|
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
849
850
|
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdateState]
|
|
850
851
|
*/
|
|
851
|
-
constructor(schema: Schema.Field<M>, { null: isNull, state, ref, setValue, setState, convert, onUpdate, onUpdateState, validator, validators, index, size, new: isNew, parent: parentNode, hidden, clearable, required, disabled, readonly, removable, label, description, placeholder, min, max, step, minLength, maxLength, pattern, values }?: {
|
|
852
|
+
constructor(schema: Schema.Field<M>, { null: isNull, state, ref, default: defaultValue, setValue, setState, convert, onUpdate, onUpdateState, validator, validators, index, size, new: isNew, parent: parentNode, hidden, clearable, required, disabled, readonly, removable, label, description, placeholder, min, max, step, minLength, maxLength, pattern, values }?: {
|
|
852
853
|
parent?: Store<any, any> | null | undefined;
|
|
854
|
+
default?: ((store: Store) => any) | any;
|
|
853
855
|
state?: any;
|
|
854
856
|
index?: string | number | null | undefined;
|
|
855
857
|
size?: number | Signal.State<number> | Signal.Computed<number> | undefined;
|
|
@@ -922,6 +924,9 @@ declare class Store<T = any, M = any> {
|
|
|
922
924
|
get kind(): string;
|
|
923
925
|
get ref(): Ref;
|
|
924
926
|
schema: Schema.Field<M>;
|
|
927
|
+
createDefault(): any;
|
|
928
|
+
set loading(loading: boolean);
|
|
929
|
+
get loading(): boolean;
|
|
925
930
|
/** 存储对象自身 */
|
|
926
931
|
get store(): this;
|
|
927
932
|
/** 父级存储对象 */
|
|
@@ -1053,17 +1058,17 @@ declare class Store<T = any, M = any> {
|
|
|
1053
1058
|
/**
|
|
1054
1059
|
* 异步校验
|
|
1055
1060
|
* @overload
|
|
1056
|
-
* @param {
|
|
1061
|
+
* @param {true} [path]
|
|
1057
1062
|
* @returns {Promise<string[] | null>}
|
|
1058
1063
|
*/
|
|
1059
|
-
validate(path?:
|
|
1064
|
+
validate(path?: true | undefined): Promise<string[] | null>;
|
|
1060
1065
|
/**
|
|
1061
1066
|
* 异步校验
|
|
1062
1067
|
* @overload
|
|
1063
|
-
* @param {(string | number)[]} path 到当前层级的路径
|
|
1068
|
+
* @param {(string | number)[] | false | null} [path] 到当前层级的路径
|
|
1064
1069
|
* @returns {Promise<{ path: (string | number)[]; store: Store; errors: string[]}[]>}
|
|
1065
1070
|
*/
|
|
1066
|
-
validate(path
|
|
1071
|
+
validate(path?: false | (string | number)[] | null | undefined): Promise<{
|
|
1067
1072
|
path: (string | number)[];
|
|
1068
1073
|
store: Store;
|
|
1069
1074
|
errors: string[];
|
|
@@ -1073,6 +1078,122 @@ declare class Store<T = any, M = any> {
|
|
|
1073
1078
|
#private;
|
|
1074
1079
|
}
|
|
1075
1080
|
|
|
1081
|
+
/** @import { Schema } from '../types.mjs' */
|
|
1082
|
+
/**
|
|
1083
|
+
* @template {Record<string, any>} [T=Record<string, any>]
|
|
1084
|
+
* @template [M=any]
|
|
1085
|
+
* @extends {Store<T, M>}
|
|
1086
|
+
*/
|
|
1087
|
+
declare class ObjectStore<T extends Record<string, any> = Record<string, any>, M = any> extends Store<T, M> {
|
|
1088
|
+
/**
|
|
1089
|
+
* @param {Schema.Object<M> & Schema.Attr<M>} schema
|
|
1090
|
+
* @param {object} [options]
|
|
1091
|
+
* @param {Store?} [options.parent]
|
|
1092
|
+
* @param {number | string | null} [options.index]
|
|
1093
|
+
* @param {boolean} [options.new]
|
|
1094
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdate]
|
|
1095
|
+
* @param {((value: T?, index: any, store: Store) => void)?} [options.onUpdateState]
|
|
1096
|
+
*/
|
|
1097
|
+
constructor(schema: Schema.Object<M> & Schema.Attr<M>, { parent, index, new: isNew, onUpdate, onUpdateState }?: {
|
|
1098
|
+
parent?: Store<any, any> | null | undefined;
|
|
1099
|
+
index?: string | number | null | undefined;
|
|
1100
|
+
new?: boolean | undefined;
|
|
1101
|
+
onUpdate?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
1102
|
+
onUpdateState?: ((value: T | null, index: any, store: Store) => void) | null | undefined;
|
|
1103
|
+
});
|
|
1104
|
+
[Symbol.iterator](): Generator<[string, Store<any, any>], void, unknown>;
|
|
1105
|
+
#private;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/** @import { Schema } from '../types.mjs' */
|
|
1109
|
+
/**
|
|
1110
|
+
* @template [T=any]
|
|
1111
|
+
* @template [M=any]
|
|
1112
|
+
* @extends {Store<(T | null)[], M>}
|
|
1113
|
+
*/
|
|
1114
|
+
declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
|
|
1115
|
+
/**
|
|
1116
|
+
* @param {Schema.Field<M>} schema
|
|
1117
|
+
* @param {object} [options]
|
|
1118
|
+
* @param {Store?} [options.parent]
|
|
1119
|
+
* @param {string | number | null} [options.index]
|
|
1120
|
+
* @param {boolean} [options.new]
|
|
1121
|
+
* @param {boolean} [options.addable]
|
|
1122
|
+
* @param {(value: any, index: any, store: Store) => void} [options.onUpdate]
|
|
1123
|
+
* @param {(value: any, index: any, store: Store) => void} [options.onUpdateState]
|
|
1124
|
+
*/
|
|
1125
|
+
constructor(schema: Schema.Field<M>, { parent, onUpdate, onUpdateState, index, new: isNew, addable }?: {
|
|
1126
|
+
parent?: Store<any, any> | null | undefined;
|
|
1127
|
+
index?: string | number | null | undefined;
|
|
1128
|
+
new?: boolean | undefined;
|
|
1129
|
+
addable?: boolean | undefined;
|
|
1130
|
+
onUpdate?: ((value: any, index: any, store: Store) => void) | undefined;
|
|
1131
|
+
onUpdateState?: ((value: any, index: any, store: Store) => void) | undefined;
|
|
1132
|
+
});
|
|
1133
|
+
get children(): Store<any, any>[];
|
|
1134
|
+
set selfAddable(v: boolean | null);
|
|
1135
|
+
get selfAddable(): boolean | null;
|
|
1136
|
+
set addable(v: boolean);
|
|
1137
|
+
/** 是否禁用字段 */
|
|
1138
|
+
get addable(): boolean;
|
|
1139
|
+
/**
|
|
1140
|
+
*
|
|
1141
|
+
* @param {number} index
|
|
1142
|
+
* @param {T?} [value]
|
|
1143
|
+
* @param {boolean} [isNew]
|
|
1144
|
+
* @returns
|
|
1145
|
+
*/
|
|
1146
|
+
insert(index: number, value?: T | null, isNew?: boolean): boolean;
|
|
1147
|
+
/**
|
|
1148
|
+
*
|
|
1149
|
+
* @param {T?} [value]
|
|
1150
|
+
* @returns
|
|
1151
|
+
*/
|
|
1152
|
+
add(value?: T | null): boolean;
|
|
1153
|
+
/**
|
|
1154
|
+
*
|
|
1155
|
+
* @param {number} index
|
|
1156
|
+
* @returns
|
|
1157
|
+
*/
|
|
1158
|
+
remove(index: number): T | null | undefined;
|
|
1159
|
+
/**
|
|
1160
|
+
*
|
|
1161
|
+
* @param {number} from
|
|
1162
|
+
* @param {number} to
|
|
1163
|
+
* @returns
|
|
1164
|
+
*/
|
|
1165
|
+
move(from: number, to: number): boolean;
|
|
1166
|
+
/**
|
|
1167
|
+
*
|
|
1168
|
+
* @param {number} a
|
|
1169
|
+
* @param {number} b
|
|
1170
|
+
* @returns
|
|
1171
|
+
*/
|
|
1172
|
+
exchange(a: number, b: number): boolean;
|
|
1173
|
+
[Symbol.iterator](): Generator<[number, Store<any, any>], undefined, unknown>;
|
|
1174
|
+
#private;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
type GridFormItemTemplate = {
|
|
1178
|
+
field: string;
|
|
1179
|
+
subFields?: GridFormTemplate | null | undefined;
|
|
1180
|
+
span: number;
|
|
1181
|
+
headers?: string[] | undefined;
|
|
1182
|
+
};
|
|
1183
|
+
type GridFormTemplate = GridFormItemTemplate[];
|
|
1184
|
+
type Options = object;
|
|
1185
|
+
type FieldRenderer = (store: Store<any, any>, component: any, Options: Options) => [HTMLElement, () => void];
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
*
|
|
1189
|
+
* @param {Store} store
|
|
1190
|
+
* @param {HTMLElement} root
|
|
1191
|
+
* @param {FieldRenderer} fieldRenderer
|
|
1192
|
+
* @param {boolean} editable
|
|
1193
|
+
* @param {GridFormTemplate?} [template]
|
|
1194
|
+
*/
|
|
1195
|
+
declare function _default(store: Store, root: HTMLElement, fieldRenderer: FieldRenderer, editable: boolean, template?: GridFormTemplate | null): () => void;
|
|
1196
|
+
|
|
1076
1197
|
/**
|
|
1077
1198
|
* @param {Store} store 存储实例
|
|
1078
1199
|
* @param {Layout.Child[]} layouts 布局信息
|
|
@@ -1113,4 +1234,14 @@ declare function watch<T>(getter: () => T, callback: (value: T) => void, immedia
|
|
|
1113
1234
|
*/
|
|
1114
1235
|
declare function effect(fn: () => void): () => void;
|
|
1115
1236
|
|
|
1116
|
-
|
|
1237
|
+
/**
|
|
1238
|
+
*
|
|
1239
|
+
* @param {(store: Store<any, any>, component: any) => [HTMLElement, () => void]?} renderField
|
|
1240
|
+
* @param {Store} store
|
|
1241
|
+
* @param {HTMLElement} root
|
|
1242
|
+
* @param {string | ParentNode} [html]
|
|
1243
|
+
* @param {boolean} [clone]
|
|
1244
|
+
*/
|
|
1245
|
+
declare function renderHtml(renderField: (store: Store<any, any>, component: any) => [HTMLElement, () => void] | null, store: Store, root: HTMLElement, html?: string | ParentNode, clone?: boolean): () => void;
|
|
1246
|
+
|
|
1247
|
+
export { ArrayStore, type AsyncValidator, Component, Enhancement, type FieldRenderer, type GridFormItemTemplate, type GridFormTemplate, index_d as Layout, ObjectStore, type Options, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, render, _default as renderGrid, renderHtml, watch };
|