@neeloong/form 0.22.0 → 0.23.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.22.0
2
+ * @neeloong/form v0.23.0
3
3
  * (c) 2024-2026 Fierflame
4
4
  * @license Apache-2.0
5
5
  */
@@ -778,9 +778,10 @@ declare namespace Enhancement {
778
778
  value: any;
779
779
  };
780
780
  }
781
- type StoreLayout = {
781
+ type StoreLayout<T> = {
782
782
  html?: string | ParentNode | null | undefined;
783
- fields?: StoreLayout.Item[] | null | undefined;
783
+ fields?: StoreLayout.Item<T>[] | null | undefined;
784
+ renderer?: T | undefined;
784
785
  };
785
786
  declare namespace StoreLayout {
786
787
  type Action = "add" | "move" | "trigger" | "remove" | "serial" | "open" | "collapse";
@@ -823,7 +824,7 @@ declare namespace StoreLayout {
823
824
  */
824
825
  label?: string | undefined;
825
826
  };
826
- type Field = {
827
+ type Field<T_1> = {
827
828
  type?: "field" | undefined;
828
829
  colStart?: number | undefined;
829
830
  colSpan?: number | undefined;
@@ -832,10 +833,11 @@ declare namespace StoreLayout {
832
833
  rowSpan?: number | undefined;
833
834
  rowEnd?: number | undefined;
834
835
  cell?: StoreLayout.Grid["cell"];
836
+ renderer?: T_1 | undefined;
835
837
  field: string;
836
838
  html?: string | ParentNode | null | undefined;
837
839
  inlineHtml?: string | ParentNode | null | undefined;
838
- fields?: StoreLayout.Item[] | null | undefined;
840
+ fields?: StoreLayout.Item<T_1>[] | null | undefined;
839
841
  tableFoot?: "add" | "header" | "none" | undefined;
840
842
  columns?: (string | number | StoreLayout.Column | StoreLayout.Action[])[] | undefined;
841
843
  arrayStyle?: "tree" | "table" | undefined;
@@ -872,13 +874,14 @@ declare namespace StoreLayout {
872
874
  description?: string | undefined;
873
875
  html?: string | ParentNode | null | undefined;
874
876
  };
875
- type Item = StoreLayout.Field | StoreLayout.Button | StoreLayout.Html;
877
+ type Item<T_1> = StoreLayout.Field<T_1> | StoreLayout.Button | StoreLayout.Html;
876
878
  type Options = {
877
879
  relate?: ((store: Store, el: Element | Relatedness) => () => void) | undefined;
878
880
  editable?: boolean | undefined;
881
+ signal?: AbortSignal | undefined;
879
882
  call?: ((name: string, event: Event, store: Store<any, any>, options?: StoreLayout.Options | null) => void) | undefined;
880
883
  };
881
- type Renderer = (store: Store<any, any>, options?: StoreLayout.Options | null) => [HTMLElement, () => void] | null;
884
+ type Renderer<T_1> = (store: Store<any, any>, renderer?: T_1, options?: StoreLayout.Options | null) => HTMLElement | null;
882
885
  }
883
886
 
884
887
  declare const ref: unique symbol;
@@ -1292,30 +1295,74 @@ declare function render(store: Store, layouts: Child[], parent: Element, { compo
1292
1295
  /**
1293
1296
  * 创建可赋值计算值
1294
1297
  * @template T
1298
+ * @overload
1295
1299
  * @param {() => T} getter 取值方法
1296
1300
  * @param {(value: T) => void} callback 取值方法
1297
1301
  * @param {boolean} immediate 是否立即执行一次
1302
+ * @param {null} [signal]
1298
1303
  * @returns {() => void}
1299
1304
  */
1300
- declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean): () => void;
1305
+ declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal?: null | undefined): () => void;
1306
+ /**
1307
+ * 创建可赋值计算值
1308
+ * @template T
1309
+ * @overload
1310
+ * @param {() => T} getter 取值方法
1311
+ * @param {(value: T) => void} callback 取值方法
1312
+ * @param {boolean} immediate 是否立即执行一次
1313
+ * @param {AbortSignal?} [signal]
1314
+ * @returns {(() => void) | void}
1315
+ */
1316
+ declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal?: AbortSignal | null | undefined): (() => void) | void;
1317
+ /**
1318
+ * 创建可赋值计算值
1319
+ * @template T
1320
+ * @overload
1321
+ * @param {() => T} getter 取值方法
1322
+ * @param {(value: T) => void} callback 取值方法
1323
+ * @param {boolean} immediate 是否立即执行一次
1324
+ * @param {AbortSignal} signal
1325
+ * @returns {void}
1326
+ */
1327
+ declare function watch<T>(getter: () => T, callback: (value: T) => void, immediate: boolean, signal: AbortSignal): void;
1301
1328
 
1302
1329
  /**
1303
1330
  * 相应式执行
1331
+ * @overload
1304
1332
  * @param {() => void} fn 执行函数
1333
+ * @param {null} [signal]
1305
1334
  * @returns {() => void} 取消函数
1306
1335
  */
1307
- declare function effect(fn: () => void): () => void;
1336
+ declare function effect(fn: () => void, signal?: null | undefined): () => void;
1337
+ /**
1338
+ * 相应式执行
1339
+ * @overload
1340
+ * @param {() => void} fn 执行函数
1341
+ * @param {AbortSignal} signal
1342
+ * @returns {void} 取消函数
1343
+ */
1344
+ declare function effect(fn: () => void, signal: AbortSignal): void;
1345
+ /**
1346
+ * 相应式执行
1347
+ * @overload
1348
+ * @param {() => void} fn 执行函数
1349
+ * @param {AbortSignal?} [signal]
1350
+ * @returns {(() => void) | void} 取消函数
1351
+ */
1352
+ declare function effect(fn: () => void, signal?: AbortSignal | null | undefined): (() => void) | void;
1308
1353
 
1309
1354
  /**
1310
1355
  *
1356
+ * @template T
1311
1357
  * @param {Store} store
1312
- * @param {StoreLayout.Renderer} fieldRenderer
1358
+ * @param {StoreLayout.Renderer<T>} fieldRenderer
1313
1359
  * @param {HTMLElement} root
1314
- * @param {StoreLayout?} [layout]
1360
+ * @param {StoreLayout<T>?} [layout]
1315
1361
  * @param {StoreLayout.Options & {clone?: boolean} | null} [options]
1362
+ * @returns {void}
1316
1363
  */
1317
- declare function renderStore(store: Store, fieldRenderer: StoreLayout.Renderer, root: HTMLElement, layout?: StoreLayout | null, options?: (StoreLayout.Options & {
1364
+ declare function renderStore<T>(store: Store, fieldRenderer: StoreLayout.Renderer<T>, root: HTMLElement, layout?: StoreLayout<T> | null, options?: (StoreLayout.Options & {
1318
1365
  clone?: boolean;
1319
- }) | null): () => void;
1366
+ }) | null): void;
1320
1367
 
1321
1368
  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 };