@neeloong/form 0.24.0 → 0.25.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 +3 -3
- package/index.full.js +79 -97
- package/index.full.min.js +3 -3
- package/index.full.min.mjs +2 -2
- package/index.min.mjs +2 -2
- package/index.mjs +79 -97
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.25.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -653,10 +653,10 @@ declare class Store<T = any, M = any> {
|
|
|
653
653
|
/**
|
|
654
654
|
* 异步校验
|
|
655
655
|
* @overload
|
|
656
|
-
* @param {true} [
|
|
656
|
+
* @param {true} [self]
|
|
657
657
|
* @returns {Promise<string[] | null>}
|
|
658
658
|
*/
|
|
659
|
-
validate(
|
|
659
|
+
validate(self?: true | undefined): Promise<string[] | null>;
|
|
660
660
|
/**
|
|
661
661
|
* 异步校验
|
|
662
662
|
* @overload
|
package/index.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @neeloong/form v0.
|
|
2
|
+
* @neeloong/form v0.25.0
|
|
3
3
|
* (c) 2024-2026 Fierflame
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
@@ -1482,7 +1482,7 @@
|
|
|
1482
1482
|
/**
|
|
1483
1483
|
* 异步校验
|
|
1484
1484
|
* @overload
|
|
1485
|
-
* @param {true} [
|
|
1485
|
+
* @param {true} [self]
|
|
1486
1486
|
* @returns {Promise<string[] | null>}
|
|
1487
1487
|
*/
|
|
1488
1488
|
/**
|
|
@@ -1505,6 +1505,7 @@
|
|
|
1505
1505
|
});
|
|
1506
1506
|
}
|
|
1507
1507
|
const selfPath = Array.isArray(path) ? path : [];
|
|
1508
|
+
if (this.#hidden.get()) { return Promise.resolve([]); }
|
|
1508
1509
|
const list = [this.validate(true).then(errors => {
|
|
1509
1510
|
if (!errors?.length) { return []; }
|
|
1510
1511
|
return [{ path: [...selfPath], store: /** @type {Store} */(this), errors }];
|
|
@@ -5626,6 +5627,7 @@
|
|
|
5626
5627
|
const body = root.appendChild(document.createElement('tr'));
|
|
5627
5628
|
const main = body.appendChild(document.createElement('td'));
|
|
5628
5629
|
main.colSpan = columns.length;
|
|
5630
|
+
main.appendChild(form);
|
|
5629
5631
|
body.hidden = true;
|
|
5630
5632
|
trigger = () => {
|
|
5631
5633
|
if (body.hidden) {
|
|
@@ -5718,6 +5720,64 @@
|
|
|
5718
5720
|
return root;
|
|
5719
5721
|
}
|
|
5720
5722
|
|
|
5723
|
+
/** @import { ArrayStore } from '../Store/index.mjs' */
|
|
5724
|
+
/** @import { StoreLayout } from '../StoreLayout.types.mjs' */
|
|
5725
|
+
|
|
5726
|
+
/**
|
|
5727
|
+
*
|
|
5728
|
+
* @template T
|
|
5729
|
+
* @param {ArrayStore} store
|
|
5730
|
+
* @param {StoreLayout.Field<T>} layout
|
|
5731
|
+
* @param {StoreLayout.Action[]} actionOptions
|
|
5732
|
+
* @param {(fields: { field: string; width: any; label: any; }[]) => StoreLayout.Column<T>[]} createDefault
|
|
5733
|
+
* @returns {StoreLayout.Column<T>[]}
|
|
5734
|
+
*/
|
|
5735
|
+
function getColumns(store, layout, actionOptions, createDefault) {
|
|
5736
|
+
const fieldList = Object.entries(store.type || {})
|
|
5737
|
+
.filter(([k, v]) => typeof v?.type !== 'object')
|
|
5738
|
+
.map(([field, { width, label }]) => ({ field, width, label }));
|
|
5739
|
+
const headerColumns = layout.columns;
|
|
5740
|
+
if (Array.isArray(headerColumns)) {
|
|
5741
|
+
const map = new Map(fieldList.map(v => [v.field, v]));
|
|
5742
|
+
/** @type {(StoreLayout.Column<T> | null)[]} */
|
|
5743
|
+
const allColumns = headerColumns.map(v => {
|
|
5744
|
+
if (!v) { return null; }
|
|
5745
|
+
if (typeof v === 'number') { return { placeholder: v }; }
|
|
5746
|
+
if (typeof v === 'string') { return map.get(v) || null; }
|
|
5747
|
+
if (typeof v !== 'object') { return null; }
|
|
5748
|
+
if (Array.isArray(v)) {
|
|
5749
|
+
/** @type {Set<StoreLayout.Action>} */
|
|
5750
|
+
const options = new Set(actionOptions);
|
|
5751
|
+
const actions = v.filter(v => options.delete(v));
|
|
5752
|
+
if (!actions) { return null; }
|
|
5753
|
+
return { actions };
|
|
5754
|
+
}
|
|
5755
|
+
const { action, actions, field, placeholder, pattern, width, label } = v;
|
|
5756
|
+
if (field) {
|
|
5757
|
+
const define = map.get(field);
|
|
5758
|
+
if (define) {
|
|
5759
|
+
return { field, placeholder, width, label: label || define.label };
|
|
5760
|
+
}
|
|
5761
|
+
}
|
|
5762
|
+
const options = new Set(actionOptions);
|
|
5763
|
+
const allActions = [action, actions].flat().filter(v => v && options.delete(v));
|
|
5764
|
+
if (allActions.length) {
|
|
5765
|
+
return { actions: /** @type {StoreLayout.Action[]} */(allActions), width, label };
|
|
5766
|
+
}
|
|
5767
|
+
if (pattern) {
|
|
5768
|
+
return { pattern, placeholder, width, label };
|
|
5769
|
+
}
|
|
5770
|
+
if (placeholder || width) {
|
|
5771
|
+
return { placeholder, width, label };
|
|
5772
|
+
}
|
|
5773
|
+
return null;
|
|
5774
|
+
});
|
|
5775
|
+
const columns = /** @type {StoreLayout.Column<T>[]} */(allColumns.filter(Boolean));
|
|
5776
|
+
if (columns.length) { return columns; }
|
|
5777
|
+
}
|
|
5778
|
+
return createDefault(fieldList);
|
|
5779
|
+
}
|
|
5780
|
+
|
|
5721
5781
|
/** @import { Store, ArrayStore } from '../Store/index.mjs' */
|
|
5722
5782
|
/** @import { StoreLayout } from '../StoreLayout.types.mjs' */
|
|
5723
5783
|
|
|
@@ -5748,6 +5808,7 @@
|
|
|
5748
5808
|
watch(() => !addable.get(), disabled => { button.disabled = disabled; }, true, signal);
|
|
5749
5809
|
}
|
|
5750
5810
|
}
|
|
5811
|
+
|
|
5751
5812
|
/**
|
|
5752
5813
|
*
|
|
5753
5814
|
* @template T
|
|
@@ -5759,54 +5820,15 @@
|
|
|
5759
5820
|
*/
|
|
5760
5821
|
function Table(store, fieldRenderer, layout, options) {
|
|
5761
5822
|
if (options?.signal?.aborted) { return null; }
|
|
5762
|
-
const
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
let columns = [];
|
|
5768
|
-
if (Array.isArray(headerColumns)) {
|
|
5769
|
-
const map = new Map(fieldList.map(v => [v.field, v]));
|
|
5770
|
-
|
|
5771
|
-
/** @type {(StoreLayout.Column<T> | null)[]} */
|
|
5772
|
-
const allColumns = headerColumns.map(v => {
|
|
5773
|
-
if (!v) { return null; }
|
|
5774
|
-
if (typeof v === 'number') { return { placeholder: v }; }
|
|
5775
|
-
if (typeof v === 'string') { return map.get(v) || null; }
|
|
5776
|
-
if (typeof v !== 'object') { return null; }
|
|
5777
|
-
if (Array.isArray(v)) {
|
|
5778
|
-
/** @type {Set<StoreLayout.Action>} */
|
|
5779
|
-
const options = new Set(['add', 'move', 'trigger', 'remove', 'serial', 'open', 'collapse']);
|
|
5780
|
-
const actions = v.filter(v => options.delete(v));
|
|
5781
|
-
if (!actions) { return null; }
|
|
5782
|
-
return { actions };
|
|
5783
|
-
}
|
|
5784
|
-
const { action, actions, field, placeholder, pattern, width, label } = v;
|
|
5785
|
-
if (field) {
|
|
5786
|
-
const define = map.get(field);
|
|
5787
|
-
if (define) {
|
|
5788
|
-
return { field, placeholder, width, label: label || define.label };
|
|
5789
|
-
}
|
|
5790
|
-
}
|
|
5791
|
-
const options = new Set(['add', 'move', 'trigger', 'remove', 'serial']);
|
|
5792
|
-
const allActions = [action, actions].flat().filter(v => v && options.delete(v));
|
|
5793
|
-
if (allActions.length) {
|
|
5794
|
-
return { actions: /** @type {StoreLayout.Action[]} */(allActions), width, label };
|
|
5795
|
-
}
|
|
5796
|
-
// if (pattern) {
|
|
5797
|
-
// return { pattern, placeholder, width, label };
|
|
5798
|
-
// }
|
|
5799
|
-
return null;
|
|
5800
|
-
});
|
|
5801
|
-
columns = /** @type {StoreLayout.Column<T>[]} */(allColumns.filter(Boolean));
|
|
5802
|
-
|
|
5803
|
-
}
|
|
5804
|
-
if (!columns.length) {
|
|
5805
|
-
columns = [
|
|
5823
|
+
const columns = getColumns(
|
|
5824
|
+
store,
|
|
5825
|
+
layout,
|
|
5826
|
+
['add', 'move', 'trigger', 'remove', 'serial'],
|
|
5827
|
+
fields => [
|
|
5806
5828
|
{ actions: ['add', 'trigger', 'move', 'remove', 'serial'] },
|
|
5807
|
-
...
|
|
5808
|
-
]
|
|
5809
|
-
|
|
5829
|
+
...fields.slice(0, 3),
|
|
5830
|
+
],
|
|
5831
|
+
);
|
|
5810
5832
|
|
|
5811
5833
|
const table = document.createElement('table');
|
|
5812
5834
|
table.classList.add('NeeloongForm-table');
|
|
@@ -6383,56 +6405,16 @@
|
|
|
6383
6405
|
*/
|
|
6384
6406
|
function Tree(store, fieldRenderer, layout, options) {
|
|
6385
6407
|
if (options?.signal?.aborted) { return null; }
|
|
6386
|
-
const
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
let columns = [];
|
|
6392
|
-
if (Array.isArray(headerColumns)) {
|
|
6393
|
-
const map = new Map(fieldList.map(v => [v.field, v]));
|
|
6394
|
-
/** @type {(StoreLayout.Column<T> | null)[]} */
|
|
6395
|
-
const allColumns = headerColumns.map(v => {
|
|
6396
|
-
if (!v) { return null; }
|
|
6397
|
-
if (typeof v === 'number') { return { placeholder: v }; }
|
|
6398
|
-
if (typeof v === 'string') { return map.get(v) || null; }
|
|
6399
|
-
if (typeof v !== 'object') { return null; }
|
|
6400
|
-
if (Array.isArray(v)) {
|
|
6401
|
-
/** @type {Set<StoreLayout.Action>} */
|
|
6402
|
-
const options = new Set(['add', 'move', 'trigger', 'remove', 'serial', 'open', 'collapse']);
|
|
6403
|
-
const actions = v.filter(v => options.delete(v));
|
|
6404
|
-
if (!actions) { return null; }
|
|
6405
|
-
return { actions };
|
|
6406
|
-
}
|
|
6407
|
-
const { action, actions, field, placeholder, pattern, width, label } = v;
|
|
6408
|
-
if (field) {
|
|
6409
|
-
const define = map.get(field);
|
|
6410
|
-
if (define) {
|
|
6411
|
-
return { field, placeholder, width, label: label || define.label };
|
|
6412
|
-
}
|
|
6413
|
-
}
|
|
6414
|
-
const options = new Set(['add', 'move', 'trigger', 'remove', 'serial', 'open', 'collapse']);
|
|
6415
|
-
const allActions = [action, actions].flat().filter(v => v && options.delete(v));
|
|
6416
|
-
if (allActions.length) {
|
|
6417
|
-
return { actions: /** @type {StoreLayout.Action[]} */(allActions), width, label };
|
|
6418
|
-
}
|
|
6419
|
-
if (pattern) {
|
|
6420
|
-
return { pattern, placeholder, width, label };
|
|
6421
|
-
}
|
|
6422
|
-
if (placeholder || width) {
|
|
6423
|
-
return { placeholder, width, label };
|
|
6424
|
-
}
|
|
6425
|
-
return null;
|
|
6426
|
-
});
|
|
6427
|
-
columns = /** @type {StoreLayout.Column<T>[]} */(allColumns.filter(Boolean));
|
|
6428
|
-
}
|
|
6429
|
-
if (!columns.length) {
|
|
6430
|
-
columns = [
|
|
6408
|
+
const columns = getColumns(
|
|
6409
|
+
store,
|
|
6410
|
+
layout,
|
|
6411
|
+
['add', 'move', 'trigger', 'remove', 'serial', 'open', 'collapse'],
|
|
6412
|
+
fields => [
|
|
6431
6413
|
{ actions: ['collapse', 'move'] },
|
|
6432
|
-
|
|
6414
|
+
fields[0],
|
|
6433
6415
|
{ actions: ['add', 'remove'] },
|
|
6434
|
-
]
|
|
6435
|
-
|
|
6416
|
+
]
|
|
6417
|
+
);
|
|
6436
6418
|
|
|
6437
6419
|
|
|
6438
6420
|
const root = document.createElement('div');
|