@sia.soul/sia-react-ui 0.1.164 → 0.1.165
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/dist/index.cjs +14 -26
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +14 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -28391,7 +28391,11 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28391
28391
|
const adapter = config?.adapter;
|
|
28392
28392
|
async function load(edit) {
|
|
28393
28393
|
const current = latest.current;
|
|
28394
|
-
if (!current.config)
|
|
28394
|
+
if (!current.config) {
|
|
28395
|
+
const next = snapshot ?? { fields: [], defaultCollapsed: current.defaultCollapsed ?? false };
|
|
28396
|
+
setDraft({ ...next, fields: reconcileQueryFields(current.fields.map((field) => field.key), next.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key)) });
|
|
28397
|
+
return;
|
|
28398
|
+
}
|
|
28395
28399
|
const request = ++token.current;
|
|
28396
28400
|
setLoading(true);
|
|
28397
28401
|
setError("");
|
|
@@ -28429,7 +28433,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28429
28433
|
}, [adapter, moduleName, businessKey]);
|
|
28430
28434
|
async function save() {
|
|
28431
28435
|
const current = latest.current;
|
|
28432
|
-
if (
|
|
28436
|
+
if (loading || loadFailed || disabled || saveLock.current) return false;
|
|
28433
28437
|
saveLock.current = true;
|
|
28434
28438
|
setSaving(true);
|
|
28435
28439
|
setError("");
|
|
@@ -28437,7 +28441,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28437
28441
|
const active = reconcileQueryFields(current.fields.map((field) => field.key), draft.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key));
|
|
28438
28442
|
const next = { ...draft, fields: mergeQueryFields(snapshot?.fields ?? [], active) };
|
|
28439
28443
|
try {
|
|
28440
|
-
await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
28444
|
+
if (current.config) await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
28441
28445
|
if (request !== token.current) return false;
|
|
28442
28446
|
setSnapshot(next);
|
|
28443
28447
|
current.applyCollapsed(next.defaultCollapsed);
|
|
@@ -28446,7 +28450,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28446
28450
|
} catch (reason) {
|
|
28447
28451
|
if (request !== token.current) return false;
|
|
28448
28452
|
setError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u67E5\u8BE2\u8BBE\u7F6E\u5931\u8D25");
|
|
28449
|
-
current.config
|
|
28453
|
+
current.config?.onError?.(reason, "save");
|
|
28450
28454
|
return false;
|
|
28451
28455
|
} finally {
|
|
28452
28456
|
if (request === token.current) {
|
|
@@ -28469,7 +28473,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28469
28473
|
const items = new Map(visibleDraft.map((item) => [item.key, item]));
|
|
28470
28474
|
setDraft((current) => ({ ...current, fields: keys.map((key, order) => ({ ...items.get(key), order })) }));
|
|
28471
28475
|
});
|
|
28472
|
-
const control =
|
|
28476
|
+
const control = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
28473
28477
|
Button,
|
|
28474
28478
|
{
|
|
28475
28479
|
type: "button",
|
|
@@ -28484,8 +28488,8 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28484
28488
|
void load(true);
|
|
28485
28489
|
}
|
|
28486
28490
|
}
|
|
28487
|
-
)
|
|
28488
|
-
const panel =
|
|
28491
|
+
);
|
|
28492
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_jsx_runtime103.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
28489
28493
|
Modal2,
|
|
28490
28494
|
{
|
|
28491
28495
|
title: "\u67E5\u8BE2\u8BBE\u7F6E",
|
|
@@ -28528,7 +28532,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28528
28532
|
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", disabled: locked, onClick: () => setDraft({ fields: reconcileQueryFields(fields.map((field) => field.key)), defaultCollapsed: defaultCollapsed ?? false }), children: "\u6062\u590D\u9ED8\u8BA4" })
|
|
28529
28533
|
] })
|
|
28530
28534
|
}
|
|
28531
|
-
) })
|
|
28535
|
+
) });
|
|
28532
28536
|
return { snapshot, control, panel };
|
|
28533
28537
|
}
|
|
28534
28538
|
|
|
@@ -28537,7 +28541,7 @@ var import_jsx_runtime104 = require("react/jsx-runtime");
|
|
|
28537
28541
|
function QueryForm({
|
|
28538
28542
|
fields,
|
|
28539
28543
|
settings,
|
|
28540
|
-
showSettings,
|
|
28544
|
+
showSettings = true,
|
|
28541
28545
|
children,
|
|
28542
28546
|
form: providedForm,
|
|
28543
28547
|
onSearch,
|
|
@@ -28614,7 +28618,6 @@ function QueryForm({
|
|
|
28614
28618
|
const actionsRef = (0, import_react111.useRef)(null);
|
|
28615
28619
|
const toggleRef = (0, import_react111.useRef)(null);
|
|
28616
28620
|
const [fittingCount, setFittingCount] = (0, import_react111.useState)(limit);
|
|
28617
|
-
const [settingsRows, setSettingsRows] = (0, import_react111.useState)(0);
|
|
28618
28621
|
(0, import_react111.useLayoutEffect)(() => {
|
|
28619
28622
|
const row = rowRef.current;
|
|
28620
28623
|
const actions = actionsRef.current;
|
|
@@ -28622,21 +28625,6 @@ function QueryForm({
|
|
|
28622
28625
|
function measure() {
|
|
28623
28626
|
if (!row || !actions || row.dataset.queryMotion === "true") return;
|
|
28624
28627
|
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
28625
|
-
const sourceFields = Array.from(row.querySelectorAll(":scope > .sia-query-form__field"));
|
|
28626
|
-
const sourceHidden = sourceFields.map((field) => field.hidden);
|
|
28627
|
-
const sourceCollapsed = row.classList.contains("is-collapsed");
|
|
28628
|
-
row.classList.remove("is-collapsed");
|
|
28629
|
-
sourceFields.forEach((field) => {
|
|
28630
|
-
field.hidden = false;
|
|
28631
|
-
});
|
|
28632
|
-
if (row.clientWidth > 0) setSettingsRows(countQueryFieldRows(sourceFields.map((field) => {
|
|
28633
|
-
const rect = field.getBoundingClientRect();
|
|
28634
|
-
return rect.top + rect.height / 2;
|
|
28635
|
-
})));
|
|
28636
|
-
sourceFields.forEach((field, index) => {
|
|
28637
|
-
field.hidden = sourceHidden[index];
|
|
28638
|
-
});
|
|
28639
|
-
row.classList.toggle("is-collapsed", sourceCollapsed);
|
|
28640
28628
|
const allFields = Array.from(
|
|
28641
28629
|
row.querySelectorAll(":scope > .sia-query-form__field:not([data-settings-hidden])")
|
|
28642
28630
|
);
|
|
@@ -28865,7 +28853,7 @@ function QueryForm({
|
|
|
28865
28853
|
children: saveText
|
|
28866
28854
|
}
|
|
28867
28855
|
) : null,
|
|
28868
|
-
showSettings
|
|
28856
|
+
showSettings ? cloudSettings.control : null
|
|
28869
28857
|
] }),
|
|
28870
28858
|
collapsible && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { ref: toggleRef, hidden: !needsCollapse, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
28871
28859
|
Button,
|
package/dist/index.d.cts
CHANGED
|
@@ -3508,12 +3508,12 @@ interface QueryFormSearchInfo {
|
|
|
3508
3508
|
interface QueryFormProps<T extends FormValues = FormValues> extends Omit<FormProps, "onFinish" | "children" | "onError"> {
|
|
3509
3509
|
/** 查询字段配置,每项包含稳定 key、可选宽度以及 Form.Item 属性;提供后优先于 children。 */
|
|
3510
3510
|
fields?: readonly QueryFormField[];
|
|
3511
|
-
/** 云设置入口,在查询操作按钮组末尾显示竖向三点图标;复用表格 adapter 和 scope,读写共用快照的 queryForm
|
|
3511
|
+
/** 云设置入口,在查询操作按钮组末尾显示竖向三点图标;复用表格 adapter 和 scope,读写共用快照的 queryForm 属性。未提供时使用仅在当前组件挂载期间保留的本地设置;入口显隐由 showSettings 控制。隐藏字段保留挂载和值;children 模式需提供稳定 React key。 */
|
|
3512
3512
|
settings?: QueryFormSettingsConfig;
|
|
3513
3513
|
/**
|
|
3514
|
-
*
|
|
3515
|
-
*
|
|
3516
|
-
* @defaultValue
|
|
3514
|
+
* 是否显示查询设置入口。默认始终显示,不受字段数量、行数、展开收起或是否配置云存储影响;显式 false 隐藏。
|
|
3515
|
+
* 未提供 settings 时可调整当前组件的字段显隐、顺序和默认收起状态,卸载后恢复默认;提供 settings 后沿用该适配器和业务作用域持久化。
|
|
3516
|
+
* @defaultValue true
|
|
3517
3517
|
*/
|
|
3518
3518
|
showSettings?: boolean;
|
|
3519
3519
|
/** 也可直接放入 Form.Item 或 Space.Compact,每个直接子项视为一个查询字段。横向 Space.Compact 仅包含左侧 Select 和右侧 Input 时,默认按 40% / 60% 分配宽度;Form.Item noStyle 包裹时同样适用。 */
|
package/dist/index.d.ts
CHANGED
|
@@ -3508,12 +3508,12 @@ interface QueryFormSearchInfo {
|
|
|
3508
3508
|
interface QueryFormProps<T extends FormValues = FormValues> extends Omit<FormProps, "onFinish" | "children" | "onError"> {
|
|
3509
3509
|
/** 查询字段配置,每项包含稳定 key、可选宽度以及 Form.Item 属性;提供后优先于 children。 */
|
|
3510
3510
|
fields?: readonly QueryFormField[];
|
|
3511
|
-
/** 云设置入口,在查询操作按钮组末尾显示竖向三点图标;复用表格 adapter 和 scope,读写共用快照的 queryForm
|
|
3511
|
+
/** 云设置入口,在查询操作按钮组末尾显示竖向三点图标;复用表格 adapter 和 scope,读写共用快照的 queryForm 属性。未提供时使用仅在当前组件挂载期间保留的本地设置;入口显隐由 showSettings 控制。隐藏字段保留挂载和值;children 模式需提供稳定 React key。 */
|
|
3512
3512
|
settings?: QueryFormSettingsConfig;
|
|
3513
3513
|
/**
|
|
3514
|
-
*
|
|
3515
|
-
*
|
|
3516
|
-
* @defaultValue
|
|
3514
|
+
* 是否显示查询设置入口。默认始终显示,不受字段数量、行数、展开收起或是否配置云存储影响;显式 false 隐藏。
|
|
3515
|
+
* 未提供 settings 时可调整当前组件的字段显隐、顺序和默认收起状态,卸载后恢复默认;提供 settings 后沿用该适配器和业务作用域持久化。
|
|
3516
|
+
* @defaultValue true
|
|
3517
3517
|
*/
|
|
3518
3518
|
showSettings?: boolean;
|
|
3519
3519
|
/** 也可直接放入 Form.Item 或 Space.Compact,每个直接子项视为一个查询字段。横向 Space.Compact 仅包含左侧 Select 和右侧 Input 时,默认按 40% / 60% 分配宽度;Form.Item noStyle 包裹时同样适用。 */
|
package/dist/index.js
CHANGED
|
@@ -11436,7 +11436,11 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11436
11436
|
const adapter = config?.adapter;
|
|
11437
11437
|
async function load(edit) {
|
|
11438
11438
|
const current = latest.current;
|
|
11439
|
-
if (!current.config)
|
|
11439
|
+
if (!current.config) {
|
|
11440
|
+
const next = snapshot ?? { fields: [], defaultCollapsed: current.defaultCollapsed ?? false };
|
|
11441
|
+
setDraft({ ...next, fields: reconcileQueryFields(current.fields.map((field) => field.key), next.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key)) });
|
|
11442
|
+
return;
|
|
11443
|
+
}
|
|
11440
11444
|
const request = ++token.current;
|
|
11441
11445
|
setLoading(true);
|
|
11442
11446
|
setError("");
|
|
@@ -11474,7 +11478,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11474
11478
|
}, [adapter, moduleName, businessKey]);
|
|
11475
11479
|
async function save() {
|
|
11476
11480
|
const current = latest.current;
|
|
11477
|
-
if (
|
|
11481
|
+
if (loading || loadFailed || disabled || saveLock.current) return false;
|
|
11478
11482
|
saveLock.current = true;
|
|
11479
11483
|
setSaving(true);
|
|
11480
11484
|
setError("");
|
|
@@ -11482,7 +11486,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11482
11486
|
const active = reconcileQueryFields(current.fields.map((field) => field.key), draft.fields, current.fields.filter((field) => field.hideDisabled).map((field) => field.key));
|
|
11483
11487
|
const next = { ...draft, fields: mergeQueryFields(snapshot?.fields ?? [], active) };
|
|
11484
11488
|
try {
|
|
11485
|
-
await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
11489
|
+
if (current.config) await saveSettingsPatch(current.config.adapter, current.config.scope, { queryForm: next });
|
|
11486
11490
|
if (request !== token.current) return false;
|
|
11487
11491
|
setSnapshot(next);
|
|
11488
11492
|
current.applyCollapsed(next.defaultCollapsed);
|
|
@@ -11491,7 +11495,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11491
11495
|
} catch (reason) {
|
|
11492
11496
|
if (request !== token.current) return false;
|
|
11493
11497
|
setError(reason instanceof Error ? reason.message : "\u4FDD\u5B58\u67E5\u8BE2\u8BBE\u7F6E\u5931\u8D25");
|
|
11494
|
-
current.config
|
|
11498
|
+
current.config?.onError?.(reason, "save");
|
|
11495
11499
|
return false;
|
|
11496
11500
|
} finally {
|
|
11497
11501
|
if (request === token.current) {
|
|
@@ -11514,7 +11518,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11514
11518
|
const items = new Map(visibleDraft.map((item) => [item.key, item]));
|
|
11515
11519
|
setDraft((current) => ({ ...current, fields: keys.map((key, order) => ({ ...items.get(key), order })) }));
|
|
11516
11520
|
});
|
|
11517
|
-
const control =
|
|
11521
|
+
const control = /* @__PURE__ */ jsx33(
|
|
11518
11522
|
Button,
|
|
11519
11523
|
{
|
|
11520
11524
|
type: "button",
|
|
@@ -11529,8 +11533,8 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11529
11533
|
void load(true);
|
|
11530
11534
|
}
|
|
11531
11535
|
}
|
|
11532
|
-
)
|
|
11533
|
-
const panel =
|
|
11536
|
+
);
|
|
11537
|
+
const panel = /* @__PURE__ */ jsx33(Fragment11, { children: /* @__PURE__ */ jsx33(
|
|
11534
11538
|
Modal,
|
|
11535
11539
|
{
|
|
11536
11540
|
title: "\u67E5\u8BE2\u8BBE\u7F6E",
|
|
@@ -11573,7 +11577,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
11573
11577
|
/* @__PURE__ */ jsx33(Button, { type: "button", disabled: locked, onClick: () => setDraft({ fields: reconcileQueryFields(fields.map((field) => field.key)), defaultCollapsed: defaultCollapsed ?? false }), children: "\u6062\u590D\u9ED8\u8BA4" })
|
|
11574
11578
|
] })
|
|
11575
11579
|
}
|
|
11576
|
-
) })
|
|
11580
|
+
) });
|
|
11577
11581
|
return { snapshot, control, panel };
|
|
11578
11582
|
}
|
|
11579
11583
|
|
|
@@ -11582,7 +11586,7 @@ import { jsx as jsx34, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
|
11582
11586
|
function QueryForm({
|
|
11583
11587
|
fields,
|
|
11584
11588
|
settings,
|
|
11585
|
-
showSettings,
|
|
11589
|
+
showSettings = true,
|
|
11586
11590
|
children,
|
|
11587
11591
|
form: providedForm,
|
|
11588
11592
|
onSearch,
|
|
@@ -11659,7 +11663,6 @@ function QueryForm({
|
|
|
11659
11663
|
const actionsRef = useRef29(null);
|
|
11660
11664
|
const toggleRef = useRef29(null);
|
|
11661
11665
|
const [fittingCount, setFittingCount] = useState28(limit);
|
|
11662
|
-
const [settingsRows, setSettingsRows] = useState28(0);
|
|
11663
11666
|
useLayoutEffect9(() => {
|
|
11664
11667
|
const row = rowRef.current;
|
|
11665
11668
|
const actions = actionsRef.current;
|
|
@@ -11667,21 +11670,6 @@ function QueryForm({
|
|
|
11667
11670
|
function measure() {
|
|
11668
11671
|
if (!row || !actions || row.dataset.queryMotion === "true") return;
|
|
11669
11672
|
const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
|
|
11670
|
-
const sourceFields = Array.from(row.querySelectorAll(":scope > .sia-query-form__field"));
|
|
11671
|
-
const sourceHidden = sourceFields.map((field) => field.hidden);
|
|
11672
|
-
const sourceCollapsed = row.classList.contains("is-collapsed");
|
|
11673
|
-
row.classList.remove("is-collapsed");
|
|
11674
|
-
sourceFields.forEach((field) => {
|
|
11675
|
-
field.hidden = false;
|
|
11676
|
-
});
|
|
11677
|
-
if (row.clientWidth > 0) setSettingsRows(countQueryFieldRows(sourceFields.map((field) => {
|
|
11678
|
-
const rect = field.getBoundingClientRect();
|
|
11679
|
-
return rect.top + rect.height / 2;
|
|
11680
|
-
})));
|
|
11681
|
-
sourceFields.forEach((field, index) => {
|
|
11682
|
-
field.hidden = sourceHidden[index];
|
|
11683
|
-
});
|
|
11684
|
-
row.classList.toggle("is-collapsed", sourceCollapsed);
|
|
11685
11673
|
const allFields = Array.from(
|
|
11686
11674
|
row.querySelectorAll(":scope > .sia-query-form__field:not([data-settings-hidden])")
|
|
11687
11675
|
);
|
|
@@ -11910,7 +11898,7 @@ function QueryForm({
|
|
|
11910
11898
|
children: saveText
|
|
11911
11899
|
}
|
|
11912
11900
|
) : null,
|
|
11913
|
-
showSettings
|
|
11901
|
+
showSettings ? cloudSettings.control : null
|
|
11914
11902
|
] }),
|
|
11915
11903
|
collapsible && entries.length > 0 ? /* @__PURE__ */ jsx34("span", { ref: toggleRef, hidden: !needsCollapse, children: /* @__PURE__ */ jsx34(
|
|
11916
11904
|
Button,
|