@kne/form-creator 0.1.2 → 0.1.4
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/README.md +128 -99
- package/dist/index.js +170 -141
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +95 -31
- package/dist/index.modern.js.map +1 -1
- package/package.json +6 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import '@kne/form-info/dist/index.css';
|
|
2
|
+
import '@kne/info-page/dist/index.css';
|
|
1
3
|
import { useState, useMemo, useEffect, createElement, Fragment } from 'react';
|
|
2
4
|
import { Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, Input as Input$1, InputNumber as InputNumber$1, Card, Tooltip } from 'antd';
|
|
3
5
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
4
6
|
import { useIsMobile, RESPONSIVE_BOUNDARY_CLASS } from '@kne/responsive-utils';
|
|
5
7
|
import { ArrowUpOutlined, ArrowDownOutlined, EditOutlined, DeleteOutlined, PlusOutlined, SettingOutlined, FormOutlined, UnorderedListOutlined, TableOutlined, AppstoreOutlined, OrderedListOutlined, ApartmentOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
6
|
-
import { hooks, Input, TextArea, InputNumber, Select, RadioGroup, CheckboxGroup, Switch, Checkbox, DatePicker, useFormContext, Slider, SubmitButton, ResetButton, CancelButton } from '@kne/react-form-antd';
|
|
8
|
+
import { hooks, Input, TextArea, InputNumber, Select, RadioGroup, CheckboxGroup, Switch, Checkbox, DatePicker, useFormContext, Slider, SubmitButton, ResetButton, CancelButton, RULES, preset as preset$1 } from '@kne/react-form-antd';
|
|
7
9
|
import SelectList, { SelectTableList, SelectTree, SelectCascader } from '@kne/super-select';
|
|
8
10
|
import { SelectFunction, SelectIndustry, SelectAddress } from '@kne/super-select-plus';
|
|
9
11
|
import '@kne/super-select/dist/index.css';
|
|
10
12
|
import '@kne/super-select-plus/dist/index.css';
|
|
11
13
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
14
|
import FormInfo, { FormModal, Form, Steps, MultiField, TableList, List } from '@kne/form-info';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
|
|
15
17
|
|
|
16
18
|
function _extends() {
|
|
17
19
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -195,6 +197,7 @@ const locale$1 = {
|
|
|
195
197
|
formSubtitlePlaceholder: '表单副标题(可选)',
|
|
196
198
|
formColumnPlaceholder: '每行显示列数'
|
|
197
199
|
};
|
|
200
|
+
var zhCN = locale$1;
|
|
198
201
|
|
|
199
202
|
const locale = {
|
|
200
203
|
addField: 'Add Field',
|
|
@@ -359,15 +362,17 @@ const locale = {
|
|
|
359
362
|
formSubtitlePlaceholder: 'Form subtitle (optional)',
|
|
360
363
|
formColumnPlaceholder: 'Columns per row'
|
|
361
364
|
};
|
|
365
|
+
var enUS = locale;
|
|
362
366
|
|
|
363
367
|
const withLocale = createWithIntlProvider({
|
|
364
368
|
defaultLocale: 'zh-CN',
|
|
365
369
|
messages: {
|
|
366
|
-
'zh-CN':
|
|
367
|
-
'en-US':
|
|
370
|
+
'zh-CN': zhCN,
|
|
371
|
+
'en-US': enUS
|
|
368
372
|
},
|
|
369
373
|
namespace: 'form-creator'
|
|
370
374
|
});
|
|
375
|
+
var withLocale$1 = withLocale;
|
|
371
376
|
|
|
372
377
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
373
378
|
|
|
@@ -685,7 +690,7 @@ const formValuesToStep = (values, existingStep = {}) => {
|
|
|
685
690
|
});
|
|
686
691
|
};
|
|
687
692
|
|
|
688
|
-
const _excluded$
|
|
693
|
+
const _excluded$4 = ["children"];
|
|
689
694
|
const mapOptionItem = item => {
|
|
690
695
|
if (!item || typeof item !== 'object') {
|
|
691
696
|
return item;
|
|
@@ -693,7 +698,7 @@ const mapOptionItem = item => {
|
|
|
693
698
|
const {
|
|
694
699
|
children
|
|
695
700
|
} = item,
|
|
696
|
-
rest = _objectWithoutPropertiesLoose(item, _excluded$
|
|
701
|
+
rest = _objectWithoutPropertiesLoose(item, _excluded$4);
|
|
697
702
|
const next = _extends({}, rest);
|
|
698
703
|
if (Array.isArray(children) && children.length) {
|
|
699
704
|
next.children = children.map(mapOptionItem);
|
|
@@ -706,7 +711,7 @@ const createApiFromOptions = (options = []) => ({
|
|
|
706
711
|
})
|
|
707
712
|
});
|
|
708
713
|
|
|
709
|
-
const _excluded$
|
|
714
|
+
const _excluded$3 = ["options", "api", "placeholder"];
|
|
710
715
|
const {
|
|
711
716
|
useOnChange: useOnChange$1
|
|
712
717
|
} = hooks;
|
|
@@ -721,7 +726,7 @@ const createField = (Component, {
|
|
|
721
726
|
api,
|
|
722
727
|
placeholder
|
|
723
728
|
} = props,
|
|
724
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded$
|
|
729
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
725
730
|
const useOptionsDirectly = _preferOptions || hasNestedOptions(options);
|
|
726
731
|
const mergedApi = api || (!useOptionsDirectly && Array.isArray(options) && options.length ? createApiFromOptions(options) : undefined);
|
|
727
732
|
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : `${_placeholderPrefix}${props.label || ''}`;
|
|
@@ -1478,8 +1483,6 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
1478
1483
|
};
|
|
1479
1484
|
};
|
|
1480
1485
|
|
|
1481
|
-
var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
|
|
1482
|
-
|
|
1483
1486
|
const {
|
|
1484
1487
|
Text: Text$4
|
|
1485
1488
|
} = Typography;
|
|
@@ -1591,8 +1594,9 @@ const FieldRow = ({
|
|
|
1591
1594
|
})]
|
|
1592
1595
|
});
|
|
1593
1596
|
};
|
|
1597
|
+
var FieldRow$1 = FieldRow;
|
|
1594
1598
|
|
|
1595
|
-
const _excluded$
|
|
1599
|
+
const _excluded$2 = ["title", "danger"];
|
|
1596
1600
|
const {
|
|
1597
1601
|
Text: Text$3
|
|
1598
1602
|
} = Typography;
|
|
@@ -1607,7 +1611,7 @@ const IconBtn = _ref => {
|
|
|
1607
1611
|
title,
|
|
1608
1612
|
danger
|
|
1609
1613
|
} = _ref,
|
|
1610
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1614
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1611
1615
|
return /*#__PURE__*/jsx(Button, _extends({
|
|
1612
1616
|
type: "text",
|
|
1613
1617
|
size: "small",
|
|
@@ -1664,7 +1668,7 @@ const BlockListPanel = ({
|
|
|
1664
1668
|
}
|
|
1665
1669
|
return /*#__PURE__*/jsx("div", {
|
|
1666
1670
|
className: style['field-list'],
|
|
1667
|
-
children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow, {
|
|
1671
|
+
children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow$1, {
|
|
1668
1672
|
field: field,
|
|
1669
1673
|
index: fieldIndex,
|
|
1670
1674
|
total: fields.length,
|
|
@@ -1955,6 +1959,7 @@ const BlockListPanel = ({
|
|
|
1955
1959
|
})]
|
|
1956
1960
|
});
|
|
1957
1961
|
};
|
|
1962
|
+
var BlockListPanel$1 = BlockListPanel;
|
|
1958
1963
|
|
|
1959
1964
|
const BlockConfigFields = ({
|
|
1960
1965
|
kind
|
|
@@ -2161,6 +2166,7 @@ const BlockEditorModal = ({
|
|
|
2161
2166
|
})
|
|
2162
2167
|
}), open ? block != null && block.id ? `edit-${block.id}` : `add-${(block == null ? void 0 : block.kind) || 'formInfo'}-${formData.name || 'new'}` : 'closed');
|
|
2163
2168
|
};
|
|
2169
|
+
var BlockEditorModal$1 = BlockEditorModal;
|
|
2164
2170
|
|
|
2165
2171
|
const StepEditorModal = ({
|
|
2166
2172
|
open,
|
|
@@ -2220,6 +2226,7 @@ const StepEditorModal = ({
|
|
|
2220
2226
|
})
|
|
2221
2227
|
}), open ? step != null && step.id ? `edit-${step.id}` : `add-step-${formData.title || 'new'}` : 'closed');
|
|
2222
2228
|
};
|
|
2229
|
+
var StepEditorModal$1 = StepEditorModal;
|
|
2223
2230
|
|
|
2224
2231
|
const {
|
|
2225
2232
|
Text: Text$2
|
|
@@ -2290,6 +2297,7 @@ const RulePresetEditor = () => {
|
|
|
2290
2297
|
list: list
|
|
2291
2298
|
});
|
|
2292
2299
|
};
|
|
2300
|
+
var RulePresetEditor$1 = RulePresetEditor;
|
|
2293
2301
|
|
|
2294
2302
|
const {
|
|
2295
2303
|
Text: Text$1
|
|
@@ -2826,6 +2834,7 @@ const OptionsEditor = ({
|
|
|
2826
2834
|
}, "options-editor")]
|
|
2827
2835
|
});
|
|
2828
2836
|
};
|
|
2837
|
+
var OptionsEditor$1 = OptionsEditor;
|
|
2829
2838
|
|
|
2830
2839
|
const SuperSelectPropsEditor = ({
|
|
2831
2840
|
definition
|
|
@@ -2927,6 +2936,7 @@ const SuperSelectPropsEditor = ({
|
|
|
2927
2936
|
list: list
|
|
2928
2937
|
});
|
|
2929
2938
|
};
|
|
2939
|
+
var SuperSelectPropsEditor$1 = SuperSelectPropsEditor;
|
|
2930
2940
|
|
|
2931
2941
|
const BUILTIN_PROP_TYPES = ['Input', 'TextArea', 'InputNumber', 'Select', 'DatePicker', 'Switch'];
|
|
2932
2942
|
const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(item => item == null ? void 0 : item.name).map(item => {
|
|
@@ -3200,8 +3210,9 @@ const hasFieldPropsEditor = (type, definition) => {
|
|
|
3200
3210
|
}
|
|
3201
3211
|
return BUILTIN_PROP_TYPES.includes(type);
|
|
3202
3212
|
};
|
|
3213
|
+
var FieldPropsEditor$1 = FieldPropsEditor;
|
|
3203
3214
|
|
|
3204
|
-
const _excluded = ["columns"];
|
|
3215
|
+
const _excluded$1 = ["columns"];
|
|
3205
3216
|
const {
|
|
3206
3217
|
Text
|
|
3207
3218
|
} = Typography;
|
|
@@ -3217,7 +3228,7 @@ const getDefaultSelectProps = () => ({
|
|
|
3217
3228
|
columns: [createEmptyColumn()]
|
|
3218
3229
|
});
|
|
3219
3230
|
const omitColumns = (_ref = {}) => {
|
|
3220
|
-
let rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
3231
|
+
let rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
3221
3232
|
return rest;
|
|
3222
3233
|
};
|
|
3223
3234
|
const FieldConfigFields = ({
|
|
@@ -3331,17 +3342,17 @@ const FieldConfigFields = ({
|
|
|
3331
3342
|
}),
|
|
3332
3343
|
column: 1,
|
|
3333
3344
|
list: list
|
|
3334
|
-
}), definition != null && definition.isSuperSelect ? /*#__PURE__*/jsx(SuperSelectPropsEditor, {
|
|
3345
|
+
}), definition != null && definition.isSuperSelect ? /*#__PURE__*/jsx(SuperSelectPropsEditor$1, {
|
|
3335
3346
|
definition: definition
|
|
3336
|
-
}) : hasFieldPropsEditor(fieldType, definition) ? /*#__PURE__*/jsx(FieldPropsEditor, {
|
|
3347
|
+
}) : hasFieldPropsEditor(fieldType, definition) ? /*#__PURE__*/jsx(FieldPropsEditor$1, {
|
|
3337
3348
|
type: fieldType,
|
|
3338
3349
|
definition: definition
|
|
3339
|
-
}) : null, /*#__PURE__*/jsx(RulePresetEditor, {}), definition != null && definition.hasBuiltinData ? /*#__PURE__*/jsx(Text, {
|
|
3350
|
+
}) : null, /*#__PURE__*/jsx(RulePresetEditor$1, {}), definition != null && definition.hasBuiltinData ? /*#__PURE__*/jsx(Text, {
|
|
3340
3351
|
type: "secondary",
|
|
3341
3352
|
children: formatMessage({
|
|
3342
3353
|
id: 'builtinDataHint'
|
|
3343
3354
|
})
|
|
3344
|
-
}) : definition != null && definition.hasOptions ? /*#__PURE__*/jsx(OptionsEditor, {
|
|
3355
|
+
}) : definition != null && definition.hasOptions ? /*#__PURE__*/jsx(OptionsEditor$1, {
|
|
3345
3356
|
value: options,
|
|
3346
3357
|
onChange: onOptionsChange,
|
|
3347
3358
|
allowDescription: definition.optionsAllowDescription,
|
|
@@ -3464,6 +3475,7 @@ const FieldEditorModal = ({
|
|
|
3464
3475
|
})
|
|
3465
3476
|
}), modalKey);
|
|
3466
3477
|
};
|
|
3478
|
+
var FieldEditorModal$1 = FieldEditorModal;
|
|
3467
3479
|
|
|
3468
3480
|
const FormActionsEditor = ({
|
|
3469
3481
|
open,
|
|
@@ -3632,6 +3644,7 @@ const FormActionsEditor = ({
|
|
|
3632
3644
|
})
|
|
3633
3645
|
}), open ? 'form-actions-open' : 'form-actions-closed');
|
|
3634
3646
|
};
|
|
3647
|
+
var FormActionsEditor$1 = FormActionsEditor;
|
|
3635
3648
|
|
|
3636
3649
|
const buildLabelTips = tips => {
|
|
3637
3650
|
if (tips == null || !String(tips).trim()) {
|
|
@@ -3805,6 +3818,7 @@ const renderSchemaContent = (schema, {
|
|
|
3805
3818
|
className: style['schema-body']
|
|
3806
3819
|
}, ...contentChildren, children), actionNode || null);
|
|
3807
3820
|
};
|
|
3821
|
+
var renderSchemaContent$1 = renderSchemaContent;
|
|
3808
3822
|
|
|
3809
3823
|
const resolveActionNode = ({
|
|
3810
3824
|
schema,
|
|
@@ -3865,7 +3879,7 @@ const resolveActionNode = ({
|
|
|
3865
3879
|
type: 'primary'
|
|
3866
3880
|
}, resolvedSubmitButtonProps), resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/createElement(ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/createElement(CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
|
|
3867
3881
|
};
|
|
3868
|
-
const SchemaRendererInner = withLocale(props => {
|
|
3882
|
+
const SchemaRendererInner = withLocale$1(props => {
|
|
3869
3883
|
const {
|
|
3870
3884
|
schema,
|
|
3871
3885
|
preview = false,
|
|
@@ -3919,7 +3933,7 @@ const SchemaRendererInner = withLocale(props => {
|
|
|
3919
3933
|
actionNode
|
|
3920
3934
|
});
|
|
3921
3935
|
});
|
|
3922
|
-
const SchemaRenderer = withLocale(props => {
|
|
3936
|
+
const SchemaRenderer = withLocale$1(props => {
|
|
3923
3937
|
const {
|
|
3924
3938
|
schema,
|
|
3925
3939
|
formProps = {},
|
|
@@ -3965,7 +3979,7 @@ const SchemaRenderer = withLocale(props => {
|
|
|
3965
3979
|
actionsAlign,
|
|
3966
3980
|
actionsGap
|
|
3967
3981
|
});
|
|
3968
|
-
return renderSchemaContent(normalized, {
|
|
3982
|
+
return renderSchemaContent$1(normalized, {
|
|
3969
3983
|
preview,
|
|
3970
3984
|
formProps,
|
|
3971
3985
|
className,
|
|
@@ -3975,8 +3989,9 @@ const SchemaRenderer = withLocale(props => {
|
|
|
3975
3989
|
actionNode
|
|
3976
3990
|
});
|
|
3977
3991
|
});
|
|
3992
|
+
var SchemaRenderer$1 = SchemaRenderer;
|
|
3978
3993
|
|
|
3979
|
-
const FormCreator = withLocale(({
|
|
3994
|
+
const FormCreator = withLocale$1(({
|
|
3980
3995
|
value,
|
|
3981
3996
|
defaultValue,
|
|
3982
3997
|
onChange,
|
|
@@ -4149,7 +4164,7 @@ const FormCreator = withLocale(({
|
|
|
4149
4164
|
className: [style['form-creator'], RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
|
|
4150
4165
|
children: [/*#__PURE__*/jsx("div", {
|
|
4151
4166
|
className: style['editor-pane'],
|
|
4152
|
-
children: /*#__PURE__*/jsx(BlockListPanel, {
|
|
4167
|
+
children: /*#__PURE__*/jsx(BlockListPanel$1, {
|
|
4153
4168
|
blocks: schema.blocks,
|
|
4154
4169
|
onAddBlock: handleAddBlock,
|
|
4155
4170
|
onEditBlock: handleEditBlock,
|
|
@@ -4169,7 +4184,7 @@ const FormCreator = withLocale(({
|
|
|
4169
4184
|
className: style['preview-pane'],
|
|
4170
4185
|
children: /*#__PURE__*/jsx("div", {
|
|
4171
4186
|
className: style['preview-body'],
|
|
4172
|
-
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer, {
|
|
4187
|
+
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer$1, {
|
|
4173
4188
|
schema: schema,
|
|
4174
4189
|
preview: true,
|
|
4175
4190
|
formProps: formProps
|
|
@@ -4180,7 +4195,7 @@ const FormCreator = withLocale(({
|
|
|
4180
4195
|
})
|
|
4181
4196
|
})
|
|
4182
4197
|
})
|
|
4183
|
-
}) : null, /*#__PURE__*/jsx(BlockEditorModal, {
|
|
4198
|
+
}) : null, /*#__PURE__*/jsx(BlockEditorModal$1, {
|
|
4184
4199
|
open: blockEditorOpen,
|
|
4185
4200
|
block: editingBlock,
|
|
4186
4201
|
renderModal: renderModal,
|
|
@@ -4189,7 +4204,7 @@ const FormCreator = withLocale(({
|
|
|
4189
4204
|
setEditingBlock(null);
|
|
4190
4205
|
},
|
|
4191
4206
|
onSave: handleSaveBlock
|
|
4192
|
-
}), /*#__PURE__*/jsx(StepEditorModal, {
|
|
4207
|
+
}), /*#__PURE__*/jsx(StepEditorModal$1, {
|
|
4193
4208
|
open: stepEditorOpen,
|
|
4194
4209
|
step: stepContext == null ? void 0 : stepContext.step,
|
|
4195
4210
|
renderModal: renderModal,
|
|
@@ -4198,7 +4213,7 @@ const FormCreator = withLocale(({
|
|
|
4198
4213
|
setStepContext(null);
|
|
4199
4214
|
},
|
|
4200
4215
|
onSave: handleSaveStep
|
|
4201
|
-
}), /*#__PURE__*/jsx(FieldEditorModal, {
|
|
4216
|
+
}), /*#__PURE__*/jsx(FieldEditorModal$1, {
|
|
4202
4217
|
open: fieldEditorOpen,
|
|
4203
4218
|
field: editingField,
|
|
4204
4219
|
fieldList: currentFieldScope,
|
|
@@ -4209,7 +4224,7 @@ const FormCreator = withLocale(({
|
|
|
4209
4224
|
setEditingField(null);
|
|
4210
4225
|
},
|
|
4211
4226
|
onSave: handleSaveField
|
|
4212
|
-
}), /*#__PURE__*/jsx(FormActionsEditor, {
|
|
4227
|
+
}), /*#__PURE__*/jsx(FormActionsEditor$1, {
|
|
4213
4228
|
open: formActionsOpen,
|
|
4214
4229
|
value: schema.actions,
|
|
4215
4230
|
renderModal: renderModal,
|
|
@@ -4223,6 +4238,55 @@ const FormCreator = withLocale(({
|
|
|
4223
4238
|
})]
|
|
4224
4239
|
});
|
|
4225
4240
|
});
|
|
4241
|
+
var FormCreator$1 = FormCreator;
|
|
4242
|
+
|
|
4243
|
+
const _excluded = ["label", "validator"];
|
|
4244
|
+
|
|
4245
|
+
/**
|
|
4246
|
+
* 统一注册扩展规则与填写项:运行时校验 + 编辑器规则面板 + 字段类型 registry。
|
|
4247
|
+
* 应用入口调用一次即可,FormCreator / SchemaRenderer 共用。
|
|
4248
|
+
*/
|
|
4249
|
+
const preset = ({
|
|
4250
|
+
rules: _rules = {},
|
|
4251
|
+
fields: _fields = {}
|
|
4252
|
+
} = {}) => {
|
|
4253
|
+
const runtimeRules = _extends({}, RULES);
|
|
4254
|
+
Object.entries(_rules).forEach(([value, def]) => {
|
|
4255
|
+
if (def == null) {
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
if (typeof def === 'function') {
|
|
4259
|
+
registerRulePreset({
|
|
4260
|
+
value,
|
|
4261
|
+
label: value
|
|
4262
|
+
});
|
|
4263
|
+
runtimeRules[value] = def;
|
|
4264
|
+
return;
|
|
4265
|
+
}
|
|
4266
|
+
const {
|
|
4267
|
+
label,
|
|
4268
|
+
validator
|
|
4269
|
+
} = def,
|
|
4270
|
+
ruleBody = _objectWithoutPropertiesLoose(def, _excluded);
|
|
4271
|
+
if (label) {
|
|
4272
|
+
registerRulePreset({
|
|
4273
|
+
value,
|
|
4274
|
+
label
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
if (typeof validator === 'function') {
|
|
4278
|
+
runtimeRules[value] = validator;
|
|
4279
|
+
} else if (Object.keys(ruleBody).length) {
|
|
4280
|
+
runtimeRules[value] = ruleBody;
|
|
4281
|
+
}
|
|
4282
|
+
});
|
|
4283
|
+
preset$1({
|
|
4284
|
+
rules: runtimeRules
|
|
4285
|
+
});
|
|
4286
|
+
Object.entries(_fields).forEach(([type, definition]) => {
|
|
4287
|
+
registerField(type, definition);
|
|
4288
|
+
});
|
|
4289
|
+
};
|
|
4226
4290
|
|
|
4227
|
-
export { FormCreator, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectSchemaFields, createBlock, createField$1 as createField, createFieldId, createStep, FormCreator as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, formValuesToBlock, formValuesToField, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, registerField, registerRulePreset, updateBlocks };
|
|
4291
|
+
export { FormCreator$1 as FormCreator, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectSchemaFields, createBlock, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, formValuesToBlock, formValuesToField, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, registerRulePreset, updateBlocks };
|
|
4228
4292
|
//# sourceMappingURL=index.modern.js.map
|