@neeloong/form 0.17.0 → 0.19.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.17.0
2
+ * @neeloong/form v0.19.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,66 @@ 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
+ disabled?: ((store: Store<any, any>, options?: StoreLayout.Options | null) => boolean) | undefined;
816
+ text?: string | ((store: Store<any, any>, options?: StoreLayout.Options | null) => string) | undefined;
817
+ click?: string | ((event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
818
+ };
819
+ type Html = {
820
+ type: "html";
821
+ colStart?: number | undefined;
822
+ colSpan?: number | undefined;
823
+ colEnd?: number | undefined;
824
+ rowStart?: number | undefined;
825
+ rowSpan?: number | undefined;
826
+ rowEnd?: number | undefined;
827
+ cell?: "" | "content" | "block" | "inline" | "collapse" | undefined;
828
+ required?: boolean | undefined;
829
+ label?: string | undefined;
830
+ description?: string | undefined;
831
+ html?: string | ParentNode | null | undefined;
832
+ };
833
+ type Item = StoreLayout.Field | StoreLayout.Button | StoreLayout.Html;
834
+ type Options = {
835
+ relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
836
+ editable?: boolean | undefined;
837
+ call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
838
+ };
839
+ type Renderer = (store: Store<any, any>, component: any, options?: StoreLayout.Options | null) => [HTMLElement, () => void] | null;
840
+ }
780
841
 
781
842
  declare const ref: unique symbol;
782
843
  type Ref = {
@@ -1174,35 +1235,6 @@ declare class ArrayStore<T = any, M = any> extends Store<(T | null)[], M> {
1174
1235
  #private;
1175
1236
  }
1176
1237
 
1177
- type GridFormItemTemplateTableAction = "add" | "move" | "trigger" | "remove" | "serial";
1178
- type GridFieldLayout = {
1179
- field: string;
1180
- fields?: GridFieldLayout[] | null | undefined;
1181
- tableFoot?: "add" | "header" | "none" | undefined;
1182
- columns?: (string | GridFormItemTemplateTableAction[])[] | undefined;
1183
- colStart?: number | undefined;
1184
- colSpan?: number | undefined;
1185
- colEnd?: number | undefined;
1186
- rowStart?: number | undefined;
1187
- rowSpan?: number | undefined;
1188
- rowEnd?: number | undefined;
1189
- };
1190
- type GridLayout = {
1191
- fields?: GridFieldLayout[] | null | undefined;
1192
- };
1193
- type Options = object;
1194
- type FieldRenderer = (store: Store<any, any>, component: any, Options: Options) => [HTMLElement, () => void];
1195
-
1196
- /**
1197
- *
1198
- * @param {Store} store
1199
- * @param {HTMLElement} root
1200
- * @param {FieldRenderer} fieldRenderer
1201
- * @param {boolean} editable
1202
- * @param {GridLayout?} [layout]
1203
- */
1204
- declare function _default(store: Store, root: HTMLElement, fieldRenderer: FieldRenderer, editable: boolean, layout?: GridLayout | null): () => void;
1205
-
1206
1238
  /**
1207
1239
  * @param {Store} store 存储实例
1208
1240
  * @param {Layout.Child[]} layouts 布局信息
@@ -1245,12 +1277,14 @@ declare function effect(fn: () => void): () => void;
1245
1277
 
1246
1278
  /**
1247
1279
  *
1248
- * @param {(store: Store<any, any>, component: any) => [HTMLElement, () => void]?} renderField
1249
1280
  * @param {Store} store
1281
+ * @param {StoreLayout.Renderer} fieldRenderer
1250
1282
  * @param {HTMLElement} root
1251
- * @param {string | ParentNode} [html]
1252
- * @param {boolean} [clone]
1283
+ * @param {StoreLayout?} [layout]
1284
+ * @param {StoreLayout.Options & {clone?: boolean} | null} [options]
1253
1285
  */
1254
- declare function renderHtml(renderField: (store: Store<any, any>, component: any) => [HTMLElement, () => void] | null, store: Store, root: HTMLElement, html?: string | ParentNode, clone?: boolean): () => void;
1286
+ declare function renderStore(store: Store, fieldRenderer: StoreLayout.Renderer, root: HTMLElement, layout?: StoreLayout | null, options?: (StoreLayout.Options & {
1287
+ clone?: boolean;
1288
+ }) | null): () => void;
1255
1289
 
1256
- export { ArrayStore, type AsyncValidator, Component, Enhancement, type FieldRenderer, type GridFieldLayout, type GridFormItemTemplateTableAction, type GridLayout, index_d as Layout, ObjectStore, type Options, type Ref, type Relatedness, Schema, Store, type Validator, type VerifyError, effect, render, _default as renderGrid, renderHtml, watch };
1290
+ 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 };