@hkyhy/marsun-components-core 0.1.68 → 0.1.69
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/components/FlexBox/FlexBox.d.ts +7 -0
- package/dist/components/FlexBox/FlexBox.js +43 -0
- package/dist/components/FlexBox/FlexBox.js.map +1 -0
- package/dist/components/FlexBox/FlexBoxFetch.d.ts +3 -0
- package/dist/components/FlexBox/FlexBoxFetch.js +92 -0
- package/dist/components/FlexBox/FlexBoxFetch.js.map +1 -0
- package/dist/components/FlexBox/FlexBoxView.d.ts +18 -0
- package/dist/components/FlexBox/FlexBoxView.js +42 -0
- package/dist/components/FlexBox/FlexBoxView.js.map +1 -0
- package/dist/components/FlexBox/defaultColumns.d.ts +7 -0
- package/dist/components/FlexBox/defaultColumns.js +26 -0
- package/dist/components/FlexBox/defaultColumns.js.map +1 -0
- package/dist/components/FlexBox/index.d.ts +79 -0
- package/dist/components/FlexBox/useFlexBox.d.ts +5 -0
- package/dist/components/FlexBox/useFlexBox.js +19 -0
- package/dist/components/FlexBox/useFlexBox.js.map +1 -0
- package/dist/components/Form/FormDataSync.d.ts +3 -0
- package/dist/components/Form/FormDataSync.js +29 -15
- package/dist/components/Form/FormDataSync.js.map +1 -1
- package/dist/components/Form/InputRange.d.ts +19 -0
- package/dist/components/Form/InputRange.js +84 -0
- package/dist/components/Form/InputRange.js.map +1 -0
- package/dist/components/Form/InputRange.module.scss.js +9 -0
- package/dist/components/Form/InputRange.module.scss.js.map +1 -0
- package/dist/components/Form/index.d.ts +4 -0
- package/dist/components/Form/inputRangeRules.d.ts +15 -0
- package/dist/components/Form/inputRangeRules.js +23 -0
- package/dist/components/Form/inputRangeRules.js.map +1 -0
- package/dist/components/Form/kneFormInfo.js +7 -7
- package/dist/components/FormInfo/ErrorTip.d.ts +7 -0
- package/dist/components/FormInfo/ErrorTip.js +89 -0
- package/dist/components/FormInfo/ErrorTip.js.map +1 -0
- package/dist/components/FormInfo/Form.d.ts +7 -0
- package/dist/components/FormInfo/Form.js +23 -0
- package/dist/components/FormInfo/Form.js.map +1 -0
- package/dist/components/FormInfo/FormApiButton.d.ts +7 -0
- package/dist/components/FormInfo/FormApiButton.js +28 -0
- package/dist/components/FormInfo/FormApiButton.js.map +1 -0
- package/dist/components/FormInfo/FormDrawer.d.ts +9 -0
- package/dist/components/FormInfo/FormDrawer.js +42 -0
- package/dist/components/FormInfo/FormDrawer.js.map +1 -0
- package/dist/components/FormInfo/FormInfo.d.ts +4 -0
- package/dist/components/FormInfo/FormInfo.js +61 -0
- package/dist/components/FormInfo/FormInfo.js.map +1 -0
- package/dist/components/FormInfo/FormItem.d.ts +4 -0
- package/dist/components/FormInfo/FormItem.js +10 -0
- package/dist/components/FormInfo/FormItem.js.map +1 -0
- package/dist/components/FormInfo/FormModal.d.ts +11 -0
- package/dist/components/FormInfo/FormModal.js +43 -0
- package/dist/components/FormInfo/FormModal.js.map +1 -0
- package/dist/components/FormInfo/FormSteps.d.ts +9 -0
- package/dist/components/FormInfo/FormSteps.js +96 -0
- package/dist/components/FormInfo/FormSteps.js.map +1 -0
- package/dist/components/FormInfo/FormStepsModal.d.ts +14 -0
- package/dist/components/FormInfo/FormStepsModal.js +96 -0
- package/dist/components/FormInfo/FormStepsModal.js.map +1 -0
- package/dist/components/FormInfo/List.d.ts +6 -0
- package/dist/components/FormInfo/List.js +180 -0
- package/dist/components/FormInfo/List.js.map +1 -0
- package/dist/components/FormInfo/MultiField.d.ts +6 -0
- package/dist/components/FormInfo/MultiField.js +76 -0
- package/dist/components/FormInfo/MultiField.js.map +1 -0
- package/dist/components/FormInfo/Steps.d.ts +26 -0
- package/dist/components/FormInfo/Steps.js +178 -0
- package/dist/components/FormInfo/Steps.js.map +1 -0
- package/dist/components/FormInfo/TableList.d.ts +6 -0
- package/dist/components/FormInfo/TableList.js +216 -0
- package/dist/components/FormInfo/TableList.js.map +1 -0
- package/dist/components/FormInfo/buildFormOverlayProps.d.ts +27 -0
- package/dist/components/FormInfo/buildFormOverlayProps.js +55 -0
- package/dist/components/FormInfo/buildFormOverlayProps.js.map +1 -0
- package/dist/components/FormInfo/fields.d.ts +33 -0
- package/dist/components/FormInfo/fields.js +30 -0
- package/dist/components/FormInfo/fields.js.map +1 -0
- package/dist/components/FormInfo/index.d.ts +21 -0
- package/dist/components/FormInfo/locale/zh-CN.d.ts +16 -0
- package/dist/components/FormInfo/locale/zh-CN.js +17 -0
- package/dist/components/FormInfo/locale/zh-CN.js.map +1 -0
- package/dist/components/FormInfo/nestBlock.d.ts +15 -0
- package/dist/components/FormInfo/nestBlock.js +19 -0
- package/dist/components/FormInfo/nestBlock.js.map +1 -0
- package/dist/components/FormInfo/style.module.scss.js +57 -0
- package/dist/components/FormInfo/style.module.scss.js.map +1 -0
- package/dist/components/FormInfo/types.d.ts +213 -0
- package/dist/components/FormInfo/withLocale.d.ts +14 -0
- package/dist/components/FormInfo/withLocale.js +25 -0
- package/dist/components/FormInfo/withLocale.js.map +1 -0
- package/dist/components/InfoPage/CentralContent/boxComputed.d.ts +2 -0
- package/dist/components/InfoPage/CentralContent/boxComputed.js +15 -0
- package/dist/components/InfoPage/CentralContent/boxComputed.js.map +1 -0
- package/dist/components/InfoPage/CentralContent/index.d.ts +3 -0
- package/dist/components/InfoPage/CentralContent/index.js +102 -0
- package/dist/components/InfoPage/CentralContent/index.js.map +1 -0
- package/dist/components/InfoPage/CentralContent/style.module.scss.js +15 -0
- package/dist/components/InfoPage/CentralContent/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/Content/index.d.ts +16 -0
- package/dist/components/InfoPage/Content/index.js +72 -0
- package/dist/components/InfoPage/Content/index.js.map +1 -0
- package/dist/components/InfoPage/Content/style.module.scss.js +14 -0
- package/dist/components/InfoPage/Content/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/Descriptions/index.d.ts +9 -0
- package/dist/components/InfoPage/Descriptions/index.js +48 -0
- package/dist/components/InfoPage/Descriptions/index.js.map +1 -0
- package/dist/components/InfoPage/Descriptions/style.module.scss.js +11 -0
- package/dist/components/InfoPage/Descriptions/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/Flow/index.d.ts +9 -0
- package/dist/components/InfoPage/Flow/index.js +165 -0
- package/dist/components/InfoPage/Flow/index.js.map +1 -0
- package/dist/components/InfoPage/Flow/style.module.scss.js +19 -0
- package/dist/components/InfoPage/Flow/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/InfoPage/Collapse.d.ts +10 -0
- package/dist/components/InfoPage/InfoPage/Collapse.js +11 -0
- package/dist/components/InfoPage/InfoPage/Collapse.js.map +1 -0
- package/dist/components/InfoPage/InfoPage/index.d.ts +21 -0
- package/dist/components/InfoPage/InfoPage/index.js +35 -0
- package/dist/components/InfoPage/InfoPage/index.js.map +1 -0
- package/dist/components/InfoPage/InfoPage/style.module.scss.js +15 -0
- package/dist/components/InfoPage/InfoPage/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/Report/List.d.ts +6 -0
- package/dist/components/InfoPage/Report/List.js +26 -0
- package/dist/components/InfoPage/Report/List.js.map +1 -0
- package/dist/components/InfoPage/Report/Part.d.ts +6 -0
- package/dist/components/InfoPage/Report/Part.js +42 -0
- package/dist/components/InfoPage/Report/Part.js.map +1 -0
- package/dist/components/InfoPage/Report/PrintPageBreak.d.ts +3 -0
- package/dist/components/InfoPage/Report/PrintPageBreak.js +8 -0
- package/dist/components/InfoPage/Report/PrintPageBreak.js.map +1 -0
- package/dist/components/InfoPage/Report/Result.d.ts +6 -0
- package/dist/components/InfoPage/Report/Result.js +26 -0
- package/dist/components/InfoPage/Report/Result.js.map +1 -0
- package/dist/components/InfoPage/Report/Table.d.ts +6 -0
- package/dist/components/InfoPage/Report/Table.js +125 -0
- package/dist/components/InfoPage/Report/Table.js.map +1 -0
- package/dist/components/InfoPage/Report/index.d.ts +26 -0
- package/dist/components/InfoPage/Report/index.js +61 -0
- package/dist/components/InfoPage/Report/index.js.map +1 -0
- package/dist/components/InfoPage/Report/style.module.scss.js +47 -0
- package/dist/components/InfoPage/Report/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/Score/index.d.ts +8 -0
- package/dist/components/InfoPage/Score/index.js +50 -0
- package/dist/components/InfoPage/Score/index.js.map +1 -0
- package/dist/components/InfoPage/Score/style.module.scss.js +10 -0
- package/dist/components/InfoPage/Score/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/SplitLine/index.d.ts +17 -0
- package/dist/components/InfoPage/SplitLine/index.js +67 -0
- package/dist/components/InfoPage/SplitLine/index.js.map +1 -0
- package/dist/components/InfoPage/SplitLine/style.module.scss.js +8 -0
- package/dist/components/InfoPage/SplitLine/style.module.scss.js.map +1 -0
- package/dist/components/InfoPage/computeColumnsValue.d.ts +28 -0
- package/dist/components/InfoPage/computeColumnsValue.js +60 -0
- package/dist/components/InfoPage/computeColumnsValue.js.map +1 -0
- package/dist/components/InfoPage/formatView.d.ts +23 -0
- package/dist/components/InfoPage/formatView.js +119 -0
- package/dist/components/InfoPage/formatView.js.map +1 -0
- package/dist/components/InfoPage/index.d.ts +262 -0
- package/dist/components/ReactModal/ColumnsLayout.d.ts +7 -0
- package/dist/components/ReactModal/ColumnsLayout.js +20 -0
- package/dist/components/ReactModal/ColumnsLayout.js.map +1 -0
- package/dist/components/ReactModal/Drawer.d.ts +73 -0
- package/dist/components/ReactModal/Drawer.js +292 -0
- package/dist/components/ReactModal/Drawer.js.map +1 -0
- package/dist/components/ReactModal/Footer.d.ts +12 -0
- package/dist/components/ReactModal/Footer.js +53 -0
- package/dist/components/ReactModal/Footer.js.map +1 -0
- package/dist/components/ReactModal/Modal.d.ts +14 -0
- package/dist/components/ReactModal/Modal.js +366 -0
- package/dist/components/ReactModal/Modal.js.map +1 -0
- package/dist/components/ReactModal/ScrollRegion.d.ts +7 -0
- package/dist/components/ReactModal/ScrollRegion.js +22 -0
- package/dist/components/ReactModal/ScrollRegion.js.map +1 -0
- package/dist/components/ReactModal/SimpleBar.d.ts +2 -0
- package/dist/components/ReactModal/SimpleBar.js +7 -0
- package/dist/components/ReactModal/SimpleBar.js.map +1 -0
- package/dist/components/ReactModal/TabsLayout.d.ts +6 -0
- package/dist/components/ReactModal/TabsLayout.js +16 -0
- package/dist/components/ReactModal/TabsLayout.js.map +1 -0
- package/dist/components/ReactModal/confirmModal.module.scss.js +30 -0
- package/dist/components/ReactModal/confirmModal.module.scss.js.map +1 -0
- package/dist/components/ReactModal/createDrawerRender.d.ts +2 -0
- package/dist/components/ReactModal/createDrawerRender.js +7 -0
- package/dist/components/ReactModal/createDrawerRender.js.map +1 -0
- package/dist/components/ReactModal/createModalRender.d.ts +2 -0
- package/dist/components/ReactModal/createModalRender.js +7 -0
- package/dist/components/ReactModal/createModalRender.js.map +1 -0
- package/dist/components/ReactModal/drawer.module.scss.js +36 -0
- package/dist/components/ReactModal/drawer.module.scss.js.map +1 -0
- package/dist/components/ReactModal/index.d.ts +57 -0
- package/dist/components/ReactModal/intlStub.d.ts +15 -0
- package/dist/components/ReactModal/intlStub.js +21 -0
- package/dist/components/ReactModal/intlStub.js.map +1 -0
- package/dist/components/ReactModal/layouts.module.scss.js +12 -0
- package/dist/components/ReactModal/layouts.module.scss.js.map +1 -0
- package/dist/components/ReactModal/locale/en-US.d.ts +5 -0
- package/dist/components/ReactModal/locale/zh-CN.d.ts +5 -0
- package/dist/components/ReactModal/locale/zh-CN.js +8 -0
- package/dist/components/ReactModal/locale/zh-CN.js.map +1 -0
- package/dist/components/ReactModal/lockParentScroll.d.ts +3 -0
- package/dist/components/ReactModal/modalClassNames.d.ts +5 -0
- package/dist/components/ReactModal/modalClassNames.js +8 -0
- package/dist/components/ReactModal/modalClassNames.js.map +1 -0
- package/dist/components/ReactModal/style.module.scss.js +38 -0
- package/dist/components/ReactModal/style.module.scss.js.map +1 -0
- package/dist/components/ReactModal/useConfirmModal.d.ts +4 -0
- package/dist/components/ReactModal/useConfirmModal.js +161 -0
- package/dist/components/ReactModal/useConfirmModal.js.map +1 -0
- package/dist/components/ReactModal/useDrawer.d.ts +5 -0
- package/dist/components/ReactModal/useDrawer.js +123 -0
- package/dist/components/ReactModal/useDrawer.js.map +1 -0
- package/dist/components/ReactModal/usePatchElement.d.ts +2 -0
- package/dist/components/ReactModal/usePatchElement.js +11 -0
- package/dist/components/ReactModal/usePatchElement.js.map +1 -0
- package/dist/components/ReactModal/withLocale.d.ts +5 -0
- package/dist/components/ReactModal/withLocale.js +6 -0
- package/dist/components/ReactModal/withLocale.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/form-info.d.ts +17 -0
- package/dist/form-info.js +68 -0
- package/dist/form-info.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +700 -632
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/utils/date.d.ts +4 -1
- package/dist/utils/date.js +35 -27
- package/dist/utils/date.js.map +1 -1
- package/package.json +16 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type KneRuleResult = {
|
|
2
|
+
result: boolean;
|
|
3
|
+
errMsg: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Form `rules` 注册名:两端均有值时要求右端 ≥ 左端。
|
|
7
|
+
* 用法:`formProps.rules={{ ...inputRangeRules }}` + 字段 `rule="RANGE_ASC"`(可与 REQ 组合)。
|
|
8
|
+
*/
|
|
9
|
+
export declare const RANGE_ASC_RULE_NAME = "RANGE_ASC";
|
|
10
|
+
/** 校验 InputRange 值:空 / 单侧可过;双侧时 max >= min */
|
|
11
|
+
export declare function validateRangeAsc(value: unknown): KneRuleResult;
|
|
12
|
+
/** 供 Form / FormModal `rules` 直接展开 */
|
|
13
|
+
export declare const inputRangeRules: {
|
|
14
|
+
readonly RANGE_ASC: typeof validateRangeAsc;
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const i = "RANGE_ASC";
|
|
2
|
+
function l(r) {
|
|
3
|
+
if (r == null || r === "")
|
|
4
|
+
return { result: !0, errMsg: "" };
|
|
5
|
+
if (!Array.isArray(r) || r.length < 2)
|
|
6
|
+
return { result: !1, errMsg: "%s须为区间 [下限, 上限]" };
|
|
7
|
+
const s = r, e = s[0], t = s[1];
|
|
8
|
+
if (e == null && t == null)
|
|
9
|
+
return { result: !0, errMsg: "" };
|
|
10
|
+
if (e == null || t == null)
|
|
11
|
+
return { result: !0, errMsg: "" };
|
|
12
|
+
const n = typeof e == "number" ? e : Number(e), u = typeof t == "number" ? t : Number(t);
|
|
13
|
+
return !Number.isFinite(n) || !Number.isFinite(u) ? { result: !1, errMsg: "%s须为数字" } : u < n ? { result: !1, errMsg: "%s上限不可小于下限" } : { result: !0, errMsg: "" };
|
|
14
|
+
}
|
|
15
|
+
const f = {
|
|
16
|
+
[i]: l
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
i as RANGE_ASC_RULE_NAME,
|
|
20
|
+
f as inputRangeRules,
|
|
21
|
+
l as validateRangeAsc
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=inputRangeRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputRangeRules.js","sources":["../../../src/components/Form/inputRangeRules.ts"],"sourcesContent":["import type { InputRangeValue } from './InputRange';\n\nexport type KneRuleResult = { result: boolean; errMsg: string };\n\n/**\n * Form `rules` 注册名:两端均有值时要求右端 ≥ 左端。\n * 用法:`formProps.rules={{ ...inputRangeRules }}` + 字段 `rule=\"RANGE_ASC\"`(可与 REQ 组合)。\n */\nexport const RANGE_ASC_RULE_NAME = 'RANGE_ASC';\n\n/** 校验 InputRange 值:空 / 单侧可过;双侧时 max >= min */\nexport function validateRangeAsc(value: unknown): KneRuleResult {\n if (value == null || value === '') {\n return { result: true, errMsg: '' };\n }\n if (!Array.isArray(value) || value.length < 2) {\n return { result: false, errMsg: '%s须为区间 [下限, 上限]' };\n }\n const pair = value as NonNullable<InputRangeValue>;\n const rawMin = pair[0];\n const rawMax = pair[1];\n if (rawMin == null && rawMax == null) {\n return { result: true, errMsg: '' };\n }\n if (rawMin == null || rawMax == null) {\n return { result: true, errMsg: '' };\n }\n const min = typeof rawMin === 'number' ? rawMin : Number(rawMin);\n const max = typeof rawMax === 'number' ? rawMax : Number(rawMax);\n if (!Number.isFinite(min) || !Number.isFinite(max)) {\n return { result: false, errMsg: '%s须为数字' };\n }\n if (max < min) {\n return { result: false, errMsg: '%s上限不可小于下限' };\n }\n return { result: true, errMsg: '' };\n}\n\n/** 供 Form / FormModal `rules` 直接展开 */\nexport const inputRangeRules = {\n [RANGE_ASC_RULE_NAME]: validateRangeAsc,\n} as const;\n"],"names":["RANGE_ASC_RULE_NAME","validateRangeAsc","value","pair","rawMin","rawMax","min","max","inputRangeRules"],"mappings":"AAQO,MAAMA,IAAsB;AAG5B,SAASC,EAAiBC,GAA+B;AAC9D,MAAIA,KAAS,QAAQA,MAAU;AAC7B,WAAO,EAAE,QAAQ,IAAM,QAAQ,GAAA;AAEjC,MAAI,CAAC,MAAM,QAAQA,CAAK,KAAKA,EAAM,SAAS;AAC1C,WAAO,EAAE,QAAQ,IAAO,QAAQ,kBAAA;AAElC,QAAMC,IAAOD,GACPE,IAASD,EAAK,CAAC,GACfE,IAASF,EAAK,CAAC;AACrB,MAAIC,KAAU,QAAQC,KAAU;AAC9B,WAAO,EAAE,QAAQ,IAAM,QAAQ,GAAA;AAEjC,MAAID,KAAU,QAAQC,KAAU;AAC9B,WAAO,EAAE,QAAQ,IAAM,QAAQ,GAAA;AAEjC,QAAMC,IAAM,OAAOF,KAAW,WAAWA,IAAS,OAAOA,CAAM,GACzDG,IAAM,OAAOF,KAAW,WAAWA,IAAS,OAAOA,CAAM;AAC/D,SAAI,CAAC,OAAO,SAASC,CAAG,KAAK,CAAC,OAAO,SAASC,CAAG,IACxC,EAAE,QAAQ,IAAO,QAAQ,SAAA,IAE9BA,IAAMD,IACD,EAAE,QAAQ,IAAO,QAAQ,aAAA,IAE3B,EAAE,QAAQ,IAAM,QAAQ,GAAA;AACjC;AAGO,MAAME,IAAkB;AAAA,EAC7B,CAACR,CAAmB,GAAGC;AACzB;"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/* empty css */
|
|
2
2
|
import s, { Form as e, FormModal as n, FormSteps as a, FormStepsModal as r, List as c, MultiField as i, TableList as m } from "@kne/form-info";
|
|
3
|
-
import { CancelButton as u, ResetButton as l, SubmitButton as p, Input as S,
|
|
3
|
+
import { CancelButton as u, ResetButton as l, SubmitButton as p, Input as S, InputNumber as d, RadioGroup as F, Select as $, Switch as b, TextArea as T, TreeSelect as B } from "@kne/react-form-antd";
|
|
4
4
|
import { withNormalizedLabelTips as t } from "./normalizeLabelTips.js";
|
|
5
5
|
import { normalizeLabelTips as H } from "./normalizeLabelTips.js";
|
|
6
6
|
const R = s, x = e, h = n, N = a, A = r, C = c, G = m, z = i, o = S, I = t(o), P = Object.assign(I, {
|
|
7
7
|
Password: t(o.Password)
|
|
8
8
|
}), g = t(
|
|
9
|
-
|
|
9
|
+
T
|
|
10
10
|
), j = t(
|
|
11
|
-
F
|
|
12
|
-
), y = t(
|
|
13
11
|
$
|
|
12
|
+
), y = t(
|
|
13
|
+
B
|
|
14
14
|
), K = t(
|
|
15
|
-
|
|
15
|
+
d
|
|
16
16
|
), O = t(
|
|
17
|
-
|
|
17
|
+
b
|
|
18
18
|
), W = t(
|
|
19
|
-
|
|
19
|
+
F
|
|
20
20
|
), k = p, q = l, v = u;
|
|
21
21
|
export {
|
|
22
22
|
v as CancelButton,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ErrorTipProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 校验失败悬停提示;外点关闭用 ahooks useClickAway。
|
|
4
|
+
* Adapted from kne-union/components-core FormInfo/ErrorTip.
|
|
5
|
+
*/
|
|
6
|
+
declare const ErrorTip: ({ name, groupName, overlayClassName, errorRender, groupIndex, children, }: ErrorTipProps) => import("react").JSX.Element;
|
|
7
|
+
export default ErrorTip;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext as M } from "@kne/react-form-antd";
|
|
3
|
+
import { useClickAway as S } from "ahooks";
|
|
4
|
+
import { Popover as w } from "antd";
|
|
5
|
+
import x from "classnames";
|
|
6
|
+
import { useState as v, useRef as b, useLayoutEffect as L, useEffect as F } from "react";
|
|
7
|
+
import I from "./style.module.scss.js";
|
|
8
|
+
const N = (t, f) => typeof t != "string" ? String(t ?? "") : t.replace(/%s/g, String(f ?? "")), j = ({
|
|
9
|
+
name: t,
|
|
10
|
+
groupName: f,
|
|
11
|
+
groupIndex: a
|
|
12
|
+
}) => {
|
|
13
|
+
const y = M() || {}, { emitter: c, formState: g } = y, m = b({ name: t, groupName: f, groupIndex: a });
|
|
14
|
+
m.current = { name: t, groupName: f, groupIndex: a };
|
|
15
|
+
const E = b(g);
|
|
16
|
+
E.current = g;
|
|
17
|
+
const [p, R] = v(null);
|
|
18
|
+
return F(() => {
|
|
19
|
+
if (!(c != null && c.addListener)) return;
|
|
20
|
+
const u = c.addListener("form-field-validate-complete", (o) => {
|
|
21
|
+
var i;
|
|
22
|
+
const { id: d, validate: r } = o || {}, n = d ? (i = E.current) == null ? void 0 : i[d] : void 0;
|
|
23
|
+
if (!n) return;
|
|
24
|
+
const e = m.current;
|
|
25
|
+
if (n.name === e.name && (!e.groupName || n.groupName === e.groupName && n.groupIndex === e.groupIndex)) {
|
|
26
|
+
const s = (r == null ? void 0 : r.status) === 2 || (r == null ? void 0 : r.status) === "FAIL" || (r == null ? void 0 : r.status) === "ERROR";
|
|
27
|
+
R(
|
|
28
|
+
s ? Object.assign({}, r, {
|
|
29
|
+
label: n.label,
|
|
30
|
+
errMsg: N(r == null ? void 0 : r.msg, n.label)
|
|
31
|
+
}) : null
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
var o;
|
|
37
|
+
(o = u == null ? void 0 : u.remove) == null || o.call(u);
|
|
38
|
+
};
|
|
39
|
+
}, [c]), p;
|
|
40
|
+
}, P = ({
|
|
41
|
+
name: t,
|
|
42
|
+
groupName: f,
|
|
43
|
+
overlayClassName: a,
|
|
44
|
+
errorRender: y = () => null,
|
|
45
|
+
groupIndex: c,
|
|
46
|
+
children: g
|
|
47
|
+
}) => {
|
|
48
|
+
const m = j({ name: t, groupName: f, groupIndex: c }), [E, p] = v(!1), R = !!(m && E), u = R && y(Object.assign({}, m, { closeHover: () => p(!1) })), o = b(null), d = b(null), [r, n] = v(0);
|
|
49
|
+
return S(
|
|
50
|
+
() => p(!1),
|
|
51
|
+
[() => o.current, () => d.current]
|
|
52
|
+
), L(() => {
|
|
53
|
+
const e = o.current;
|
|
54
|
+
if (!e) return;
|
|
55
|
+
const i = () => {
|
|
56
|
+
const C = e.querySelector(".react-form__field-component");
|
|
57
|
+
C && n(C.clientWidth);
|
|
58
|
+
};
|
|
59
|
+
i();
|
|
60
|
+
const s = typeof ResizeObserver < "u" ? new ResizeObserver(i) : null;
|
|
61
|
+
s == null || s.observe(e);
|
|
62
|
+
const l = typeof MutationObserver < "u" ? new MutationObserver(i) : null;
|
|
63
|
+
return l == null || l.observe(e, { subtree: !0, childList: !0 }), () => {
|
|
64
|
+
l == null || l.disconnect(), s == null || s.disconnect();
|
|
65
|
+
};
|
|
66
|
+
}, []), /* @__PURE__ */ h(
|
|
67
|
+
w,
|
|
68
|
+
{
|
|
69
|
+
open: R,
|
|
70
|
+
content: /* @__PURE__ */ h(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
ref: d,
|
|
74
|
+
style: r ? { width: r } : void 0,
|
|
75
|
+
className: x("marsun-form-info-error-tip", I["marsun-form-info-error-tip"]),
|
|
76
|
+
children: u
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
overlayClassName: a,
|
|
80
|
+
placement: "bottom",
|
|
81
|
+
arrow: !1,
|
|
82
|
+
children: /* @__PURE__ */ h("div", { ref: o, onMouseEnter: () => p(!0), children: g })
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
P as default
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=ErrorTip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorTip.js","sources":["../../../src/components/FormInfo/ErrorTip.tsx"],"sourcesContent":["// @ts-nocheck\nimport { useFormContext } from '@kne/react-form-antd';\nimport { useClickAway } from 'ahooks';\nimport { Popover } from 'antd';\nimport classnames from 'classnames';\nimport { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport type { ErrorTipProps } from './types';\nimport style from './style.module.scss';\n\ntype FieldState = {\n name?: string;\n groupName?: string;\n groupIndex?: number;\n label?: ReactNode;\n id?: string;\n};\n\nconst compileErrMsg = (msg: unknown, label: unknown) => {\n if (typeof msg !== 'string') return String(msg ?? '');\n return msg.replace(/%s/g, String(label ?? ''));\n};\n\nconst useErrorMsg = ({\n name,\n groupName,\n groupIndex,\n}: {\n name: string;\n groupName?: string;\n groupIndex?: number;\n}) => {\n const ctx = (useFormContext() || {}) as {\n emitter?: { addListener: (ev: string, fn: (p: unknown) => void) => { remove?: () => void } };\n formState?: Record<string, FieldState>;\n };\n const { emitter, formState } = ctx;\n const targetFieldInfo = useRef({ name, groupName, groupIndex });\n targetFieldInfo.current = { name, groupName, groupIndex };\n const formStateRef = useRef(formState);\n formStateRef.current = formState;\n const [currentError, setCurrentError] = useState<Record<string, unknown> | null>(null);\n\n useEffect(() => {\n if (!emitter?.addListener) return undefined;\n const target = emitter.addListener('form-field-validate-complete', (payload: unknown) => {\n const { id, validate } = (payload || {}) as {\n id?: string;\n validate?: { status?: number | string; msg?: string };\n };\n const field = id ? formStateRef.current?.[id] : undefined;\n if (!field) return;\n const currentField = targetFieldInfo.current;\n if (\n field.name === currentField.name &&\n (!currentField.groupName ||\n (field.groupName === currentField.groupName &&\n field.groupIndex === currentField.groupIndex))\n ) {\n const failed =\n validate?.status === 2 || validate?.status === 'FAIL' || validate?.status === 'ERROR';\n setCurrentError(\n failed\n ? Object.assign({}, validate, {\n label: field.label,\n errMsg: compileErrMsg(validate?.msg, field.label),\n })\n : null,\n );\n }\n });\n return () => {\n target?.remove?.();\n };\n }, [emitter]);\n\n return currentError;\n};\n\n/**\n * 校验失败悬停提示;外点关闭用 ahooks useClickAway。\n * Adapted from kne-union/components-core FormInfo/ErrorTip.\n */\nconst ErrorTip = ({\n name,\n groupName,\n overlayClassName,\n errorRender = () => null,\n groupIndex,\n children,\n}: ErrorTipProps) => {\n const currentError = useErrorMsg({ name, groupName, groupIndex });\n const [isHover, setIsHover] = useState(false);\n const open = !!(currentError && isHover);\n const errorContent =\n open && errorRender(Object.assign({}, currentError, { closeHover: () => setIsHover(false) }));\n\n const popoverChildrenRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n\n useClickAway(\n () => setIsHover(false),\n [() => popoverChildrenRef.current, () => popoverContentRef.current],\n );\n\n useLayoutEffect(() => {\n const root = popoverChildrenRef.current;\n if (!root) return undefined;\n const callback = () => {\n const target = root.querySelector('.react-form__field-component');\n if (target) setWidth((target as HTMLElement).clientWidth);\n };\n callback();\n const resizeObserver =\n typeof ResizeObserver !== 'undefined' ? new ResizeObserver(callback) : null;\n resizeObserver?.observe(root);\n const mutationObserver =\n typeof MutationObserver !== 'undefined' ? new MutationObserver(callback) : null;\n mutationObserver?.observe(root, { subtree: true, childList: true });\n return () => {\n mutationObserver?.disconnect();\n resizeObserver?.disconnect();\n };\n }, []);\n\n return (\n <Popover\n open={open}\n content={\n <div\n ref={popoverContentRef}\n style={width ? { width } : undefined}\n className={classnames('marsun-form-info-error-tip', style['marsun-form-info-error-tip'])}\n >\n {errorContent}\n </div>\n }\n overlayClassName={overlayClassName}\n placement=\"bottom\"\n arrow={false}\n >\n <div ref={popoverChildrenRef} onMouseEnter={() => setIsHover(true)}>\n {children}\n </div>\n </Popover>\n );\n};\n\nexport default ErrorTip;\n"],"names":["compileErrMsg","msg","label","useErrorMsg","name","groupName","groupIndex","ctx","useFormContext","emitter","formState","targetFieldInfo","useRef","formStateRef","currentError","setCurrentError","useState","useEffect","target","payload","id","validate","field","_a","currentField","failed","ErrorTip","overlayClassName","errorRender","children","isHover","setIsHover","open","errorContent","popoverChildrenRef","popoverContentRef","width","setWidth","useClickAway","useLayoutEffect","root","callback","resizeObserver","mutationObserver","jsx","Popover","classnames","style"],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 新栈 Form:FormAntd + type=inner;外层 InfoPage.Part(扁平少 border)。
|
|
4
|
+
* Ported/adapted from kne-union/form-info Form.js(计划要求 Part 而非整页 InfoPage)。
|
|
5
|
+
*/
|
|
6
|
+
declare const Form: import('react').ForwardRefExoticComponent<Omit<FormProps, "ref"> & import('react').RefAttributes<unknown>>;
|
|
7
|
+
export default Form;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { FormAntd as a } from "@kne/react-form-antd";
|
|
3
|
+
import f from "classnames";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import i from "./style.module.scss.js";
|
|
6
|
+
import l from "../InfoPage/InfoPage/index.js";
|
|
7
|
+
const p = n((o, m) => {
|
|
8
|
+
const { className: e, children: s, ...t } = Object.assign({ type: "inner" }, o);
|
|
9
|
+
return /* @__PURE__ */ r(
|
|
10
|
+
a,
|
|
11
|
+
{
|
|
12
|
+
...t,
|
|
13
|
+
ref: m,
|
|
14
|
+
className: f("marsun-form-info-outer", i["marsun-form-info-outer"], e),
|
|
15
|
+
children: /* @__PURE__ */ r(l.Part, { bordered: !1, children: s })
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
p.displayName = "Form";
|
|
20
|
+
export {
|
|
21
|
+
p as default
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=Form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../../src/components/FormInfo/Form.tsx"],"sourcesContent":["// @ts-nocheck\nimport { FormAntd as ReactForm } from '@kne/react-form-antd';\nimport classnames from 'classnames';\nimport { forwardRef } from 'react';\nimport InfoPage from '@/components/InfoPage';\nimport type { FormProps } from './types';\nimport style from './style.module.scss';\n\n/**\n * 新栈 Form:FormAntd + type=inner;外层 InfoPage.Part(扁平少 border)。\n * Ported/adapted from kne-union/form-info Form.js(计划要求 Part 而非整页 InfoPage)。\n */\nconst Form = forwardRef<unknown, FormProps>((props, ref) => {\n const { className, children, ...others } = Object.assign({ type: 'inner' }, props);\n return (\n <ReactForm\n {...others}\n ref={ref}\n className={classnames('marsun-form-info-outer', style['marsun-form-info-outer'], className)}\n >\n <InfoPage.Part bordered={false}>{children}</InfoPage.Part>\n </ReactForm>\n );\n});\n\nForm.displayName = 'Form';\n\nexport default Form;\n"],"names":["Form","forwardRef","props","ref","className","children","others","jsx","ReactForm","classnames","style","InfoPage"],"mappings":";;;;;;AAYA,MAAMA,IAAOC,EAA+B,CAACC,GAAOC,MAAQ;AAC1D,QAAM,EAAE,WAAAC,GAAW,UAAAC,GAAU,GAAGC,EAAA,IAAW,OAAO,OAAO,EAAE,MAAM,QAAA,GAAWJ,CAAK;AACjF,SACE,gBAAAK;AAAA,IAACC;AAAAA,IAAA;AAAA,MACE,GAAGF;AAAA,MACJ,KAAAH;AAAA,MACA,WAAWM,EAAW,0BAA0BC,EAAM,wBAAwB,GAAGN,CAAS;AAAA,MAE1F,4BAACO,EAAS,MAAT,EAAc,UAAU,IAAQ,UAAAN,EAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AAGhD,CAAC;AAEDL,EAAK,cAAc;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormApiButtonProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* antd Button + loading;onClick(formContext, e)。
|
|
4
|
+
* 不绑上游 LoadingButton。
|
|
5
|
+
*/
|
|
6
|
+
declare const FormApiButton: ({ onClick, ...props }: FormApiButtonProps) => import("react").JSX.Element;
|
|
7
|
+
export default FormApiButton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext as m } from "@kne/react-form-antd";
|
|
3
|
+
import { Button as s } from "antd";
|
|
4
|
+
import { useState as f } from "react";
|
|
5
|
+
const g = ({ onClick: t, ...o }) => {
|
|
6
|
+
const n = m() || {}, [a, r] = f(!1);
|
|
7
|
+
return /* @__PURE__ */ i(
|
|
8
|
+
s,
|
|
9
|
+
{
|
|
10
|
+
...o,
|
|
11
|
+
loading: o.loading ?? a,
|
|
12
|
+
onClick: async (e) => {
|
|
13
|
+
if (t) {
|
|
14
|
+
r(!0);
|
|
15
|
+
try {
|
|
16
|
+
await t(n, e);
|
|
17
|
+
} finally {
|
|
18
|
+
r(!1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
g as default
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=FormApiButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormApiButton.js","sources":["../../../src/components/FormInfo/FormApiButton.tsx"],"sourcesContent":["// @ts-nocheck\nimport { useFormContext } from '@kne/react-form-antd';\nimport { Button } from 'antd';\nimport { useState } from 'react';\nimport type { FormApiButtonProps } from './types';\n\n/**\n * antd Button + loading;onClick(formContext, e)。\n * 不绑上游 LoadingButton。\n */\nconst FormApiButton = ({ onClick, ...props }: FormApiButtonProps) => {\n const context = (useFormContext() || {}) as Record<string, unknown>;\n const [loading, setLoading] = useState(false);\n\n return (\n <Button\n {...props}\n loading={props.loading ?? loading}\n onClick={async (e) => {\n if (!onClick) return;\n setLoading(true);\n try {\n await onClick(context, e);\n } finally {\n setLoading(false);\n }\n }}\n />\n );\n};\n\nexport default FormApiButton;\n"],"names":["FormApiButton","onClick","props","context","useFormContext","loading","setLoading","useState","jsx","Button"],"mappings":";;;;AAUA,MAAMA,IAAgB,CAAC,EAAE,SAAAC,GAAS,GAAGC,QAAgC;AACnE,QAAMC,IAAWC,EAAA,KAAoB,CAAA,GAC/B,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAE5C,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACE,GAAGP;AAAA,MACJ,SAASA,EAAM,WAAWG;AAAA,MAC1B,SAAS,OAAO,MAAM;AACpB,YAAKJ,GACL;AAAA,UAAAK,EAAW,EAAI;AACf,cAAI;AACF,kBAAML,EAAQE,GAAS,CAAC;AAAA,UAC1B,UAAA;AACE,YAAAG,EAAW,EAAK;AAAA,UAClB;AAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormDrawerProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 受控 FormDrawer:挂本仓 ReactDrawer;placement 默认 right;destroyOnHidden。
|
|
4
|
+
*/
|
|
5
|
+
declare const FormDrawer: (props: FormDrawerProps) => import("react").JSX.Element;
|
|
6
|
+
export default FormDrawer;
|
|
7
|
+
export declare const useFormDrawer: () => (props?: FormDrawerProps) => {
|
|
8
|
+
close: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import l from "classnames";
|
|
3
|
+
import { buildFormOverlayProps as u } from "./buildFormOverlayProps.js";
|
|
4
|
+
import f from "./style.module.scss.js";
|
|
5
|
+
import i from "../ReactModal/Drawer.js";
|
|
6
|
+
import { useDrawer as d } from "../ReactModal/useDrawer.js";
|
|
7
|
+
const m = (t, r) => {
|
|
8
|
+
const { placement: o = "right", className: e, ...s } = t;
|
|
9
|
+
return {
|
|
10
|
+
...u({ ...s, className: e }, r),
|
|
11
|
+
placement: o,
|
|
12
|
+
className: l(f["marsun-form-info-drawer"], "marsun-form-info-drawer", e)
|
|
13
|
+
};
|
|
14
|
+
}, N = (t) => {
|
|
15
|
+
const { open: r, onCancel: o, onClose: e, ...s } = t, n = o ?? e, a = m(
|
|
16
|
+
{ ...s, onClose: n, onCancel: n },
|
|
17
|
+
{ close: n }
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ c(i, { ...a, open: !!r, destroyOnHidden: !0 });
|
|
20
|
+
}, P = () => {
|
|
21
|
+
const t = d();
|
|
22
|
+
return (r = {}) => {
|
|
23
|
+
const o = {}, e = () => {
|
|
24
|
+
var n;
|
|
25
|
+
return (n = o.close) == null ? void 0 : n.call(o);
|
|
26
|
+
}, s = t(
|
|
27
|
+
m(
|
|
28
|
+
{
|
|
29
|
+
...r,
|
|
30
|
+
onClose: r.onClose || r.onCancel || e
|
|
31
|
+
},
|
|
32
|
+
{ close: e }
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
return o.close = s.close, s;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
N as default,
|
|
40
|
+
P as useFormDrawer
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=FormDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDrawer.js","sources":["../../../src/components/FormInfo/FormDrawer.tsx"],"sourcesContent":["// @ts-nocheck\nimport classnames from 'classnames';\nimport { ReactDrawer, useDrawer } from '@/components/ReactModal';\nimport { buildFormOverlayProps } from './buildFormOverlayProps';\nimport type { FormDrawerProps } from './types';\nimport style from './style.module.scss';\n\nconst buildFormDrawerProps = (props: FormDrawerProps, options?: { close?: () => void }) => {\n const { placement = 'right', className, ...rest } = props;\n return {\n ...buildFormOverlayProps({ ...rest, className }, options),\n placement,\n className: classnames(style['marsun-form-info-drawer'], 'marsun-form-info-drawer', className),\n };\n};\n\n/**\n * 受控 FormDrawer:挂本仓 ReactDrawer;placement 默认 right;destroyOnHidden。\n */\nconst FormDrawer = (props: FormDrawerProps) => {\n const { open, onCancel, onClose, ...rest } = props;\n const close = onCancel ?? onClose;\n const overlayProps = buildFormDrawerProps(\n { ...rest, onClose: close, onCancel: close },\n { close },\n );\n return <ReactDrawer {...overlayProps} open={!!open} destroyOnHidden />;\n};\n\nexport default FormDrawer;\n\nexport const useFormDrawer = () => {\n const drawer = useDrawer();\n return (props: FormDrawerProps = {}) => {\n const api: { close?: () => void } = {};\n const close = () => api.close?.();\n const opened = drawer(\n buildFormDrawerProps(\n {\n ...props,\n onClose: props.onClose || props.onCancel || close,\n },\n { close },\n ),\n );\n api.close = opened.close;\n return opened;\n };\n};\n"],"names":["buildFormDrawerProps","props","options","placement","className","rest","buildFormOverlayProps","classnames","style","FormDrawer","open","onCancel","onClose","close","overlayProps","jsx","ReactDrawer","useFormDrawer","drawer","useDrawer","api","_a","opened"],"mappings":";;;;;;AAOA,MAAMA,IAAuB,CAACC,GAAwBC,MAAqC;AACzF,QAAM,EAAE,WAAAC,IAAY,SAAS,WAAAC,GAAW,GAAGC,MAASJ;AACpD,SAAO;AAAA,IACL,GAAGK,EAAsB,EAAE,GAAGD,GAAM,WAAAD,EAAA,GAAaF,CAAO;AAAA,IACxD,WAAAC;AAAA,IACA,WAAWI,EAAWC,EAAM,yBAAyB,GAAG,2BAA2BJ,CAAS;AAAA,EAAA;AAEhG,GAKMK,IAAa,CAACR,MAA2B;AAC7C,QAAM,EAAE,MAAAS,GAAM,UAAAC,GAAU,SAAAC,GAAS,GAAGP,MAASJ,GACvCY,IAAQF,KAAYC,GACpBE,IAAed;AAAA,IACnB,EAAE,GAAGK,GAAM,SAASQ,GAAO,UAAUA,EAAA;AAAA,IACrC,EAAE,OAAAA,EAAA;AAAA,EAAM;AAEV,SAAO,gBAAAE,EAACC,KAAa,GAAGF,GAAc,MAAM,CAAC,CAACJ,GAAM,iBAAe,IAAC;AACtE,GAIaO,IAAgB,MAAM;AACjC,QAAMC,IAASC,EAAA;AACf,SAAO,CAAClB,IAAyB,OAAO;AACtC,UAAMmB,IAA8B,CAAA,GAC9BP,IAAQ;;AAAM,cAAAQ,IAAAD,EAAI,UAAJ,gBAAAC,EAAA,KAAAD;AAAA,OACdE,IAASJ;AAAA,MACblB;AAAA,QACE;AAAA,UACE,GAAGC;AAAA,UACH,SAASA,EAAM,WAAWA,EAAM,YAAYY;AAAA,QAAA;AAAA,QAE9C,EAAE,OAAAA,EAAA;AAAA,MAAM;AAAA,IACV;AAEF,WAAAO,EAAI,QAAQE,EAAO,OACZA;AAAA,EACT;AACF;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs as T, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { FormInfo as v } from "@kne/react-form-plus";
|
|
3
|
+
import { useIsMobile as w } from "@kne/responsive-utils";
|
|
4
|
+
import { Row as A, Col as P } from "antd";
|
|
5
|
+
import c from "classnames";
|
|
6
|
+
import _, { useMemo as $ } from "react";
|
|
7
|
+
import { markNestBlock as z, isNestBlockType as x, NEST_DEPTH_BEYOND as E } from "./nestBlock.js";
|
|
8
|
+
import f from "./style.module.scss.js";
|
|
9
|
+
import G from "../FlexBox/useFlexBox.js";
|
|
10
|
+
import H from "../InfoPage/InfoPage/index.js";
|
|
11
|
+
const L = (s) => (Array.isArray(s) ? s : []).map((o) => {
|
|
12
|
+
var r;
|
|
13
|
+
return !o || typeof o != "object" || !("type" in o) || !x(o.type) || ((r = o.props) == null ? void 0 : r.block) === !0 ? o : _.cloneElement(o, { block: !0 });
|
|
14
|
+
}), O = (s) => {
|
|
15
|
+
const { className: o, column: r = 2, list: l = [], gap: B, bordered: k, nestDepth: a, ...I } = s, u = w(), F = typeof a == "number" && a >= 1 ? !1 : k, D = $(() => L(l), [l]), p = !u && !(Number.isInteger(r) && r > 0), { ref: g, column: i } = G(
|
|
16
|
+
p ? r : {}
|
|
17
|
+
), h = B ?? 24, m = (R, j) => /* @__PURE__ */ t(
|
|
18
|
+
v,
|
|
19
|
+
{
|
|
20
|
+
list: D,
|
|
21
|
+
column: R,
|
|
22
|
+
className: c({
|
|
23
|
+
[f["marsun-form-info-column-not-layout"]]: !!j
|
|
24
|
+
}),
|
|
25
|
+
itemRender: (n, d) => {
|
|
26
|
+
var N;
|
|
27
|
+
if (d.hidden)
|
|
28
|
+
return /* @__PURE__ */ t("div", { style: { display: "none" }, children: n });
|
|
29
|
+
const e = n, y = x(e == null ? void 0 : e.type), b = (N = e == null ? void 0 : e.props) == null ? void 0 : N.nestDepth, M = y && typeof b == "number" && b >= E;
|
|
30
|
+
return /* @__PURE__ */ t(
|
|
31
|
+
P,
|
|
32
|
+
{
|
|
33
|
+
span: d.span,
|
|
34
|
+
className: c({
|
|
35
|
+
[f["marsun-form-info-nest-block-col"]]: y,
|
|
36
|
+
[f["marsun-form-info-nest-block-col-beyond"]]: M
|
|
37
|
+
}),
|
|
38
|
+
children: n
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
children: (n) => /* @__PURE__ */ t(A, { gutter: [h, 0], children: n })
|
|
43
|
+
}
|
|
44
|
+
), C = () => u ? m(1) : p ? i ? m(i.col) : m(2, !0) : m(r);
|
|
45
|
+
return /* @__PURE__ */ T(
|
|
46
|
+
H.Part,
|
|
47
|
+
{
|
|
48
|
+
...I,
|
|
49
|
+
bordered: F,
|
|
50
|
+
className: c("marsun-form-info", f["marsun-form-info"], o),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ t("div", { ref: g }),
|
|
53
|
+
C()
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}, Z = z(O);
|
|
58
|
+
export {
|
|
59
|
+
Z as default
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=FormInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInfo.js","sources":["../../../src/components/FormInfo/FormInfo.tsx"],"sourcesContent":["// @ts-nocheck\nimport { FormInfo as FormInfoBase } from '@kne/react-form-plus';\nimport { useIsMobile } from '@kne/responsive-utils';\nimport { Col, Row } from 'antd';\nimport classnames from 'classnames';\nimport React, { useMemo, type ReactElement, type ReactNode } from 'react';\nimport InfoPage from '@/components/InfoPage';\nimport { useFlexBox } from '@/components/FlexBox';\nimport { isNestBlockType, markNestBlock, NEST_DEPTH_BEYOND } from './nestBlock';\nimport type { FormInfoProps } from './types';\nimport style from './style.module.scss';\n\n/** 仅保证嵌套块整行;nestDepth 由 List 在 listRender 里写入,这里不覆盖 */\nconst ensureNestBlocksFullWidth = (list: ReactNode[]) =>\n (Array.isArray(list) ? list : []).map((item) => {\n if (\n !item ||\n typeof item !== 'object' ||\n !('type' in item) ||\n !isNestBlockType((item as ReactElement).type) ||\n (item as ReactElement).props?.block === true\n ) {\n return item;\n }\n return React.cloneElement(item as ReactElement, { block: true });\n });\n\n/**\n * FormInfo 布局:固定 column 走 Row/Col;column 为断点配置时走本仓 useFlexBox。\n * Ported/adapted from kne-union/form-info FormInfo.js\n */\nconst FormInfo = (props: FormInfoProps) => {\n const { className, column = 2, list = [], gap, bordered, nestDepth, ...others } = props;\n const isMobile = useIsMobile();\n // 第二级起嵌套块不走 info-page bordered;样式由 SCSS 色条/子项 plain 负责\n const partBordered = typeof nestDepth === 'number' && nestDepth >= 1 ? false : bordered;\n const normalizedList = useMemo(() => ensureNestBlocksFullWidth(list), [list]);\n const isFlexBox = !isMobile && !(Number.isInteger(column) && (column as number) > 0);\n const { ref: flexBoxRef, column: flexBoxColumn } = useFlexBox(\n isFlexBox ? (column as object) : {},\n );\n const rowGap = gap ?? 24;\n\n const renderInner = (col: number, notLayout?: boolean) => (\n <FormInfoBase\n list={normalizedList as never[]}\n column={col}\n className={classnames({\n [style['marsun-form-info-column-not-layout']]: !!notLayout,\n })}\n itemRender={(children: ReactNode, itemProps: { hidden?: boolean; span?: number }) => {\n if (itemProps.hidden) {\n return <div style={{ display: 'none' }}>{children}</div>;\n }\n const childEl = children as ReactElement | null;\n const nestCol = isNestBlockType(childEl?.type);\n const childNestDepth = childEl?.props?.nestDepth as number | undefined;\n const nestBeyond =\n nestCol && typeof childNestDepth === 'number' && childNestDepth >= NEST_DEPTH_BEYOND;\n return (\n <Col\n span={itemProps.span}\n className={classnames({\n [style['marsun-form-info-nest-block-col']]: nestCol,\n [style['marsun-form-info-nest-block-col-beyond']]: nestBeyond,\n })}\n >\n {children}\n </Col>\n );\n }}\n >\n {(children: ReactNode) => <Row gutter={[rowGap, 0]}>{children}</Row>}\n </FormInfoBase>\n );\n\n const renderColumn = () => {\n if (isMobile) {\n return renderInner(1);\n }\n if (!isFlexBox) {\n return renderInner(column as number);\n }\n if (flexBoxColumn) {\n return renderInner(flexBoxColumn.col);\n }\n return renderInner(2, true);\n };\n\n return (\n <InfoPage.Part\n {...others}\n bordered={partBordered}\n className={classnames('marsun-form-info', style['marsun-form-info'], className)}\n >\n <div ref={flexBoxRef} />\n {renderColumn()}\n </InfoPage.Part>\n );\n};\n\nexport default markNestBlock(FormInfo);\n"],"names":["ensureNestBlocksFullWidth","list","item","isNestBlockType","_a","React","FormInfo","props","className","column","gap","bordered","nestDepth","others","isMobile","useIsMobile","partBordered","normalizedList","useMemo","isFlexBox","flexBoxRef","flexBoxColumn","useFlexBox","rowGap","renderInner","col","notLayout","jsx","FormInfoBase","classnames","style","children","itemProps","childEl","nestCol","childNestDepth","nestBeyond","NEST_DEPTH_BEYOND","Col","Row","renderColumn","jsxs","InfoPage","FormInfo$1","markNestBlock"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAA4B,CAACC,OAChC,MAAM,QAAQA,CAAI,IAAIA,IAAO,CAAA,GAAI,IAAI,CAACC,MAAS;;AAC9C,SACE,CAACA,KACD,OAAOA,KAAS,YAChB,EAAE,UAAUA,MACZ,CAACC,EAAiBD,EAAsB,IAAI,OAC3CE,IAAAF,EAAsB,UAAtB,gBAAAE,EAA6B,WAAU,KAEjCF,IAEFG,EAAM,aAAaH,GAAsB,EAAE,OAAO,IAAM;AACjE,CAAC,GAMGI,IAAW,CAACC,MAAyB;AACzC,QAAM,EAAE,WAAAC,GAAW,QAAAC,IAAS,GAAG,MAAAR,IAAO,CAAA,GAAI,KAAAS,GAAK,UAAAC,GAAU,WAAAC,GAAW,GAAGC,EAAA,IAAWN,GAC5EO,IAAWC,EAAA,GAEXC,IAAe,OAAOJ,KAAc,YAAYA,KAAa,IAAI,KAAQD,GACzEM,IAAiBC,EAAQ,MAAMlB,EAA0BC,CAAI,GAAG,CAACA,CAAI,CAAC,GACtEkB,IAAY,CAACL,KAAY,EAAE,OAAO,UAAUL,CAAM,KAAMA,IAAoB,IAC5E,EAAE,KAAKW,GAAY,QAAQC,MAAkBC;AAAA,IACjDH,IAAaV,IAAoB,CAAA;AAAA,EAAC,GAE9Bc,IAASb,KAAO,IAEhBc,IAAc,CAACC,GAAaC,MAChC,gBAAAC;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,MAAMX;AAAA,MACN,QAAQQ;AAAA,MACR,WAAWI,EAAW;AAAA,QACpB,CAACC,EAAM,oCAAoC,CAAC,GAAG,CAAC,CAACJ;AAAA,MAAA,CAClD;AAAA,MACD,YAAY,CAACK,GAAqBC,MAAmD;;AACnF,YAAIA,EAAU;AACZ,mCAAQ,OAAA,EAAI,OAAO,EAAE,SAAS,OAAA,GAAW,UAAAD,GAAS;AAEpD,cAAME,IAAUF,GACVG,IAAU/B,EAAgB8B,KAAA,gBAAAA,EAAS,IAAI,GACvCE,KAAiB/B,IAAA6B,KAAA,gBAAAA,EAAS,UAAT,gBAAA7B,EAAgB,WACjCgC,IACJF,KAAW,OAAOC,KAAmB,YAAYA,KAAkBE;AACrE,eACE,gBAAAV;AAAA,UAACW;AAAA,UAAA;AAAA,YACC,MAAMN,EAAU;AAAA,YAChB,WAAWH,EAAW;AAAA,cACpB,CAACC,EAAM,iCAAiC,CAAC,GAAGI;AAAA,cAC5C,CAACJ,EAAM,wCAAwC,CAAC,GAAGM;AAAA,YAAA,CACpD;AAAA,YAEA,UAAAL;AAAA,UAAA;AAAA,QAAA;AAAA,MAGP;AAAA,MAEC,UAAA,CAACA,MAAwB,gBAAAJ,EAACY,GAAA,EAAI,QAAQ,CAAChB,GAAQ,CAAC,GAAI,UAAAQ,EAAA,CAAS;AAAA,IAAA;AAAA,EAAA,GAI5DS,IAAe,MACf1B,IACKU,EAAY,CAAC,IAEjBL,IAGDE,IACKG,EAAYH,EAAc,GAAG,IAE/BG,EAAY,GAAG,EAAI,IALjBA,EAAYf,CAAgB;AAQvC,SACE,gBAAAgC;AAAA,IAACC,EAAS;AAAA,IAAT;AAAA,MACE,GAAG7B;AAAA,MACJ,UAAUG;AAAA,MACV,WAAWa,EAAW,oBAAoBC,EAAM,kBAAkB,GAAGtB,CAAS;AAAA,MAE9E,UAAA;AAAA,QAAA,gBAAAmB,EAAC,OAAA,EAAI,KAAKP,EAAA,CAAY;AAAA,QACrBoB,EAAA;AAAA,MAAa;AAAA,IAAA;AAAA,EAAA;AAGpB,GAEAG,IAAeC,EAActC,CAAQ;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as m, Fragment as n } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext as s } from "@kne/react-form-antd";
|
|
3
|
+
const p = ({ children: o }) => {
|
|
4
|
+
const r = s() || {}, { openApi: t = {}, formData: e } = r, a = typeof t.getFormData == "function" ? t.getFormData() : e;
|
|
5
|
+
return /* @__PURE__ */ m(n, { children: o({ ...t, formData: a }) });
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
p as default
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=FormItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormItem.js","sources":["../../../src/components/FormInfo/FormItem.tsx"],"sourcesContent":["// @ts-nocheck\nimport { useFormContext } from '@kne/react-form-antd';\nimport type { FormItemProps } from './types';\n\n/** children({...openApi, formData});formData 优先 openApi.getFormData() */\nconst FormItem = ({ children }: FormItemProps) => {\n const ctx = (useFormContext() || {}) as {\n openApi?: Record<string, unknown> & { getFormData?: () => Record<string, unknown> };\n formData?: Record<string, unknown>;\n };\n const { openApi = {}, formData } = ctx;\n const resolvedFormData =\n typeof openApi.getFormData === 'function' ? openApi.getFormData() : formData;\n return <>{children({ ...openApi, formData: resolvedFormData })}</>;\n};\n\nexport default FormItem;\n"],"names":["FormItem","children","ctx","useFormContext","openApi","formData","resolvedFormData","jsx","Fragment"],"mappings":";;AAKA,MAAMA,IAAW,CAAC,EAAE,UAAAC,QAA8B;AAChD,QAAMC,IAAOC,EAAA,KAAoB,CAAA,GAI3B,EAAE,SAAAC,IAAU,IAAI,UAAAC,MAAaH,GAC7BI,IACJ,OAAOF,EAAQ,eAAgB,aAAaA,EAAQ,gBAAgBC;AACtE,SAAO,gBAAAE,EAAAC,GAAA,EAAG,YAAS,EAAE,GAAGJ,GAAS,UAAUE,EAAA,CAAkB,GAAE;AACjE;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormModalProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 受控 FormModal:默认挂本仓 ReactModal;可传 renderModal(createModalRender/createDrawerRender)切换宿主。
|
|
4
|
+
* destroyOnHidden。
|
|
5
|
+
*/
|
|
6
|
+
declare const FormModal: (props: FormModalProps) => string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
7
|
+
export default FormModal;
|
|
8
|
+
/** 命令式打开:内部挂 useModal */
|
|
9
|
+
export declare const useFormModal: () => (props?: FormModalProps) => {
|
|
10
|
+
close: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import f from "classnames";
|
|
3
|
+
import { buildFormOverlayProps as c } from "./buildFormOverlayProps.js";
|
|
4
|
+
import u from "./style.module.scss.js";
|
|
5
|
+
import i, { useModal as p } from "../ReactModal/Modal.js";
|
|
6
|
+
const P = (l) => {
|
|
7
|
+
const { open: e, onCancel: o, onClose: n, renderModal: s, ...r } = l, t = o ?? n, m = c(
|
|
8
|
+
{ ...r, onClose: t, onCancel: t },
|
|
9
|
+
{ close: t }
|
|
10
|
+
), a = {
|
|
11
|
+
...m,
|
|
12
|
+
open: !!e,
|
|
13
|
+
className: f(
|
|
14
|
+
u["marsun-form-info-modal"],
|
|
15
|
+
"marsun-form-info-modal",
|
|
16
|
+
m.className
|
|
17
|
+
),
|
|
18
|
+
destroyOnHidden: !0
|
|
19
|
+
};
|
|
20
|
+
return typeof s == "function" ? s(a) : /* @__PURE__ */ d(i, { ...a });
|
|
21
|
+
}, v = () => {
|
|
22
|
+
const l = p();
|
|
23
|
+
return (e = {}) => {
|
|
24
|
+
const o = {}, n = () => {
|
|
25
|
+
var r;
|
|
26
|
+
return (r = o.close) == null ? void 0 : r.call(o);
|
|
27
|
+
}, s = l(
|
|
28
|
+
c(
|
|
29
|
+
{
|
|
30
|
+
...e,
|
|
31
|
+
onClose: e.onClose || e.onCancel || n
|
|
32
|
+
},
|
|
33
|
+
{ close: n }
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
return o.close = s.close, s;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
P as default,
|
|
41
|
+
v as useFormModal
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=FormModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormModal.js","sources":["../../../src/components/FormInfo/FormModal.tsx"],"sourcesContent":["// @ts-nocheck\nimport classnames from 'classnames';\nimport { ReactModal, useModal } from '@/components/ReactModal';\nimport { buildFormOverlayProps } from './buildFormOverlayProps';\nimport type { FormModalProps } from './types';\nimport style from './style.module.scss';\n\n/**\n * 受控 FormModal:默认挂本仓 ReactModal;可传 renderModal(createModalRender/createDrawerRender)切换宿主。\n * destroyOnHidden。\n */\nconst FormModal = (props: FormModalProps) => {\n const { open, onCancel, onClose, renderModal, ...rest } = props;\n const close = onCancel ?? onClose;\n const overlayProps = buildFormOverlayProps(\n { ...rest, onClose: close, onCancel: close },\n { close },\n );\n const hostProps = {\n ...overlayProps,\n open: !!open,\n className: classnames(\n style['marsun-form-info-modal'],\n 'marsun-form-info-modal',\n overlayProps.className,\n ),\n destroyOnHidden: true as const,\n };\n if (typeof renderModal === 'function') {\n return renderModal(hostProps);\n }\n return <ReactModal {...hostProps} />;\n};\n\nexport default FormModal;\n\n/** 命令式打开:内部挂 useModal */\nexport const useFormModal = () => {\n const modal = useModal();\n return (props: FormModalProps = {}) => {\n const api: { close?: () => void } = {};\n const close = () => api.close?.();\n const opened = modal(\n buildFormOverlayProps(\n {\n ...props,\n onClose: props.onClose || props.onCancel || close,\n },\n { close },\n ),\n );\n api.close = opened.close;\n return opened;\n };\n};\n"],"names":["FormModal","props","open","onCancel","onClose","renderModal","rest","close","overlayProps","buildFormOverlayProps","hostProps","classnames","style","jsx","ReactModal","useFormModal","modal","useModal","api","_a","opened"],"mappings":";;;;;AAWA,MAAMA,IAAY,CAACC,MAA0B;AAC3C,QAAM,EAAE,MAAAC,GAAM,UAAAC,GAAU,SAAAC,GAAS,aAAAC,GAAa,GAAGC,MAASL,GACpDM,IAAQJ,KAAYC,GACpBI,IAAeC;AAAA,IACnB,EAAE,GAAGH,GAAM,SAASC,GAAO,UAAUA,EAAA;AAAA,IACrC,EAAE,OAAAA,EAAA;AAAA,EAAM,GAEJG,IAAY;AAAA,IAChB,GAAGF;AAAA,IACH,MAAM,CAAC,CAACN;AAAA,IACR,WAAWS;AAAAA,MACTC,EAAM,wBAAwB;AAAA,MAC9B;AAAA,MACAJ,EAAa;AAAA,IAAA;AAAA,IAEf,iBAAiB;AAAA,EAAA;AAEnB,SAAI,OAAOH,KAAgB,aAClBA,EAAYK,CAAS,IAEvB,gBAAAG,EAACC,GAAA,EAAY,GAAGJ,EAAA,CAAW;AACpC,GAKaK,IAAe,MAAM;AAChC,QAAMC,IAAQC,EAAA;AACd,SAAO,CAAChB,IAAwB,OAAO;AACrC,UAAMiB,IAA8B,CAAA,GAC9BX,IAAQ;;AAAM,cAAAY,IAAAD,EAAI,UAAJ,gBAAAC,EAAA,KAAAD;AAAA,OACdE,IAASJ;AAAA,MACbP;AAAA,QACE;AAAA,UACE,GAAGR;AAAA,UACH,SAASA,EAAM,WAAWA,EAAM,YAAYM;AAAA,QAAA;AAAA,QAE9C,EAAE,OAAAA,EAAA;AAAA,MAAM;AAAA,IACV;AAEF,WAAAW,EAAI,QAAQE,EAAO,OACZA;AAAA,EACT;AACF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormStepsProps } from './types';
|
|
2
|
+
declare const FormSteps: {
|
|
3
|
+
(p: FormStepsProps): import("react").JSX.Element;
|
|
4
|
+
Embed: {
|
|
5
|
+
(props: import('./types').StepsProps): import("react").JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default FormSteps;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsxs as I, jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as V, createElement as w } from "react";
|
|
3
|
+
import { useIsMobile as M } from "@kne/responsive-utils";
|
|
4
|
+
import { useControllableValue as R } from "ahooks";
|
|
5
|
+
import { Flex as k, Steps as L } from "antd";
|
|
6
|
+
import q from "classnames";
|
|
7
|
+
import D from "lodash/omit";
|
|
8
|
+
import z from "./Form.js";
|
|
9
|
+
import A from "./Steps.js";
|
|
10
|
+
import p from "./style.module.scss.js";
|
|
11
|
+
const B = (F) => {
|
|
12
|
+
var j, N, P, v, y;
|
|
13
|
+
const { className: O, stepsClassName: E, autoStep: f, onComplete: m, children: l, ...o } = Object.assign(
|
|
14
|
+
{
|
|
15
|
+
autoStep: !0,
|
|
16
|
+
defaultCurrent: 0,
|
|
17
|
+
items: [],
|
|
18
|
+
onComplete: () => {
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
F
|
|
22
|
+
), d = M(), [e, i] = R(o, {
|
|
23
|
+
valuePropName: "current",
|
|
24
|
+
defaultValuePropName: "defaultCurrent"
|
|
25
|
+
}), t = V([]), a = o.items || [], c = e === a.length - 1, h = Object.assign({}, (j = a[e]) == null ? void 0 : j.formProps, {
|
|
26
|
+
data: Object.assign(
|
|
27
|
+
{},
|
|
28
|
+
(P = (N = a[e]) == null ? void 0 : N.formProps) == null ? void 0 : P.data,
|
|
29
|
+
(v = t.current[e]) == null ? void 0 : v.formData
|
|
30
|
+
)
|
|
31
|
+
}), S = a.map((r) => {
|
|
32
|
+
const s = D(r, ["formProps"]);
|
|
33
|
+
return typeof s.children == "function" ? Object.assign({}, s, {
|
|
34
|
+
children: s.children({
|
|
35
|
+
isLastStep: c,
|
|
36
|
+
currentStep: e,
|
|
37
|
+
onStepChange: i,
|
|
38
|
+
getStepCache: () => t.current
|
|
39
|
+
})
|
|
40
|
+
}) : s;
|
|
41
|
+
}), b = d ? "vertical" : o.direction || o.orientation, g = b === "vertical", C = /* @__PURE__ */ I(k, { className: O, vertical: !g || d, gap: 24, children: [
|
|
42
|
+
/* @__PURE__ */ x(
|
|
43
|
+
L,
|
|
44
|
+
{
|
|
45
|
+
...D(o, ["current", "defaultCurrent", "onChange", "direction", "orientation"]),
|
|
46
|
+
direction: b,
|
|
47
|
+
className: q(
|
|
48
|
+
"marsun-form-info-steps",
|
|
49
|
+
E,
|
|
50
|
+
p["marsun-form-info-steps"],
|
|
51
|
+
{
|
|
52
|
+
[p["marsun-form-info-steps-vertical"]]: g
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
items: S.map((r) => ({ title: r.title })),
|
|
56
|
+
current: e
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ x("div", { className: p["marsun-form-info-steps-form-inner"], children: (y = S[e]) == null ? void 0 : y.children })
|
|
60
|
+
] });
|
|
61
|
+
return /* @__PURE__ */ w(
|
|
62
|
+
z,
|
|
63
|
+
{
|
|
64
|
+
...Object.assign({}, h, {
|
|
65
|
+
onSubmit: async (r, ...s) => {
|
|
66
|
+
t.current[e] || (t.current[e] = {}), t.current[e].formData = r;
|
|
67
|
+
const u = h.onSubmit, n = await (u == null ? void 0 : u(
|
|
68
|
+
r,
|
|
69
|
+
{
|
|
70
|
+
currentStep: e,
|
|
71
|
+
onStepChange: i,
|
|
72
|
+
stepCache: t.current,
|
|
73
|
+
getStepCache: () => t.current,
|
|
74
|
+
isLastStep: c
|
|
75
|
+
},
|
|
76
|
+
...s
|
|
77
|
+
));
|
|
78
|
+
return t.current[e].submitData = n, f && n !== !1 && !c ? (i(e + 1), n) : (f && n !== !1 && await (m == null ? void 0 : m(t.current)), n);
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
key: e
|
|
82
|
+
},
|
|
83
|
+
typeof l == "function" ? l({
|
|
84
|
+
children: C,
|
|
85
|
+
isLastStep: c,
|
|
86
|
+
currentStep: e,
|
|
87
|
+
onStepChange: i,
|
|
88
|
+
getStepCache: () => t.current
|
|
89
|
+
}) : C
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
B.Embed = A;
|
|
93
|
+
export {
|
|
94
|
+
B as default
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=FormSteps.js.map
|