@neeloong/form 0.16.0 → 0.18.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.16.0
2
+ * @neeloong/form v0.18.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$1): Child[];
16
+ declare function parse(source: string, { createCalc, createInit, createEvent, simpleTag, enableHTML, }?: Options): Child[];
17
17
 
18
18
  /**
19
19
  * 增强信息
@@ -39,7 +39,7 @@ type Enhancement$1 = {
39
39
  /**
40
40
  * 解析选项
41
41
  */
42
- type Options$1 = {
42
+ type Options = {
43
43
  /**
44
44
  * 启用 `!html` 指令
45
45
  */
@@ -349,12 +349,13 @@ 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;
352
353
  type index_d_Select = Select;
353
354
  type index_d_Template = Template;
354
355
  type index_d_Variable<T = unknown> = Variable<T>;
355
356
  declare const index_d_parse: typeof parse;
356
357
  declare namespace index_d {
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 };
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 };
358
359
  }
359
360
 
360
361
  type VerifyError = any;
@@ -777,6 +778,65 @@ declare namespace Enhancement {
777
778
  value: any;
778
779
  };
779
780
  }
781
+ type StoreLayout = {
782
+ html?: string | ParentNode | null | undefined;
783
+ fields?: StoreLayout.Item[] | null | undefined;
784
+ };
785
+ declare namespace StoreLayout {
786
+ type Action = "add" | "move" | "trigger" | "remove" | "serial";
787
+ type Field = {
788
+ type?: "field" | undefined;
789
+ colStart?: number | undefined;
790
+ colSpan?: number | undefined;
791
+ colEnd?: number | undefined;
792
+ rowStart?: number | undefined;
793
+ rowSpan?: number | undefined;
794
+ rowEnd?: number | undefined;
795
+ cell?: "" | "block" | "inline" | "collapse" | "base" | undefined;
796
+ field: string;
797
+ html?: string | ParentNode | null | undefined;
798
+ inlineHtml?: string | ParentNode | null | undefined;
799
+ fields?: StoreLayout.Item[] | null | undefined;
800
+ tableFoot?: "add" | "header" | "none" | undefined;
801
+ columns?: (string | StoreLayout.Action[])[] | undefined;
802
+ };
803
+ type Button = {
804
+ type: "button";
805
+ colStart?: number | undefined;
806
+ colSpan?: number | undefined;
807
+ colEnd?: number | undefined;
808
+ rowStart?: number | undefined;
809
+ rowSpan?: number | undefined;
810
+ rowEnd?: number | undefined;
811
+ cell?: "" | "block" | "inline" | "collapse" | "base" | undefined;
812
+ required?: boolean | undefined;
813
+ label?: string | undefined;
814
+ description?: string | undefined;
815
+ text?: string | undefined;
816
+ click?: string | ((event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
817
+ };
818
+ type Html = {
819
+ type: "html";
820
+ colStart?: number | undefined;
821
+ colSpan?: number | undefined;
822
+ colEnd?: number | undefined;
823
+ rowStart?: number | undefined;
824
+ rowSpan?: number | undefined;
825
+ rowEnd?: number | undefined;
826
+ cell?: "" | "content" | "block" | "inline" | "collapse" | undefined;
827
+ required?: boolean | undefined;
828
+ label?: string | undefined;
829
+ description?: string | undefined;
830
+ html?: string | ParentNode | null | undefined;
831
+ };
832
+ type Item = StoreLayout.Field | StoreLayout.Button | StoreLayout.Html;
833
+ type Options = {
834
+ relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
835
+ editable?: boolean | undefined;
836
+ call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
837
+ };
838
+ type Renderer = (store: Store<any, any>, component: any, options?: StoreLayout.Options | null) => [HTMLElement, () => void] | null;
839
+ }
780
840
 
781
841
  declare const ref: unique symbol;
782
842
  type Ref = {
@@ -1174,32 +1234,6 @@ declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
1174
1234
  #private;
1175
1235
  }
1176
1236
 
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
-
1203
1237
  /**
1204
1238
  * @param {Store} store 存储实例
1205
1239
  * @param {Layout.Child[]} layouts 布局信息
@@ -1242,12 +1276,14 @@ declare function effect(fn: () => void): () => void;
1242
1276
 
1243
1277
  /**
1244
1278
  *
1245
- * @param {(store: Store<any, any>, component: any) => [HTMLElement, () => void]?} renderField
1246
1279
  * @param {Store} store
1280
+ * @param {StoreLayout.Renderer} fieldRenderer
1247
1281
  * @param {HTMLElement} root
1248
- * @param {string | ParentNode} [html]
1249
- * @param {boolean} [clone]
1282
+ * @param {StoreLayout?} [layout]
1283
+ * @param {StoreLayout.Options & {clone?: boolean} | null} [options]
1250
1284
  */
1251
- declare function renderHtml(renderField: (store: Store<any, any>, component: any) => [HTMLElement, () => void] | null, store: Store, root: HTMLElement, html?: string | ParentNode, clone?: boolean): () => void;
1285
+ declare function renderStore(store: Store, fieldRenderer: StoreLayout.Renderer, root: HTMLElement, layout?: StoreLayout | null, options?: (StoreLayout.Options & {
1286
+ clone?: boolean;
1287
+ }) | null): () => void;
1252
1288
 
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 };
1289
+ export { ArrayStore, type AsyncValidator, Component, Enhancement, index_d as Layout, ObjectStore, type Ref, type Relatedness, Schema, Store, StoreLayout, type Validator, type VerifyError, effect, render, renderStore, watch };