@neeloong/form 0.14.0 → 0.16.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @neeloong/form v0.14.0
2
+ * @neeloong/form v0.16.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 index_d_Options 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 };
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,7 @@ 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;
925
928
  set loading(loading: boolean);
926
929
  get loading(): boolean;
927
930
  /** 存储对象自身 */
@@ -1055,17 +1058,17 @@ declare class Store<T = any, M = any> {
1055
1058
  /**
1056
1059
  * 异步校验
1057
1060
  * @overload
1058
- * @param {null} [path]
1061
+ * @param {true} [path]
1059
1062
  * @returns {Promise<string[] | null>}
1060
1063
  */
1061
- validate(path?: null | undefined): Promise<string[] | null>;
1064
+ validate(path?: true | undefined): Promise<string[] | null>;
1062
1065
  /**
1063
1066
  * 异步校验
1064
1067
  * @overload
1065
- * @param {(string | number)[]} path 到当前层级的路径
1068
+ * @param {(string | number)[] | false | null} [path] 到当前层级的路径
1066
1069
  * @returns {Promise<{ path: (string | number)[]; store: Store; errors: string[]}[]>}
1067
1070
  */
1068
- validate(path: (string | number)[]): Promise<{
1071
+ validate(path?: false | (string | number)[] | null | undefined): Promise<{
1069
1072
  path: (string | number)[];
1070
1073
  store: Store;
1071
1074
  errors: string[];
@@ -1171,6 +1174,32 @@ declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
1171
1174
  #private;
1172
1175
  }
1173
1176
 
1177
+ type GridFormItemTemplate = {
1178
+ field: string;
1179
+ subFields?: GridFormTemplate | null | undefined;
1180
+ span: number;
1181
+ headers?: string[] | undefined;
1182
+ colStart?: number | undefined;
1183
+ colSpan?: number | undefined;
1184
+ colEnd?: number | undefined;
1185
+ rowStart?: number | undefined;
1186
+ rowSpan?: number | undefined;
1187
+ rowEnd?: number | undefined;
1188
+ };
1189
+ type GridFormTemplate = GridFormItemTemplate[];
1190
+ type Options = object;
1191
+ type FieldRenderer = (store: Store<any, any>, component: any, Options: Options) => [HTMLElement, () => void];
1192
+
1193
+ /**
1194
+ *
1195
+ * @param {Store} store
1196
+ * @param {HTMLElement} root
1197
+ * @param {FieldRenderer} fieldRenderer
1198
+ * @param {boolean} editable
1199
+ * @param {GridFormTemplate?} [template]
1200
+ */
1201
+ declare function _default(store: Store, root: HTMLElement, fieldRenderer: FieldRenderer, editable: boolean, template?: GridFormTemplate | null): () => void;
1202
+
1174
1203
  /**
1175
1204
  * @param {Store} store 存储实例
1176
1205
  * @param {Layout.Child[]} layouts 布局信息
@@ -1211,4 +1240,14 @@ declare function watch<T>(getter: () => T, callback: (value: T) => void, immedia
1211
1240
  */
1212
1241
  declare function effect(fn: () => void): () => void;
1213
1242
 
1214
- export { ArrayStore, type AsyncValidator, Component, Enhancement, index_d as Layout, ObjectStore, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, render, watch };
1243
+ /**
1244
+ *
1245
+ * @param {(store: Store<any, any>, component: any) => [HTMLElement, () => void]?} renderField
1246
+ * @param {Store} store
1247
+ * @param {HTMLElement} root
1248
+ * @param {string | ParentNode} [html]
1249
+ * @param {boolean} [clone]
1250
+ */
1251
+ declare function renderHtml(renderField: (store: Store<any, any>, component: any) => [HTMLElement, () => void] | null, store: Store, root: HTMLElement, html?: string | ParentNode, clone?: boolean): () => void;
1252
+
1253
+ 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 };