@kne/form-creator 0.1.16 → 0.1.17
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 +124 -2
- package/dist/index.css +14 -13
- package/dist/index.css.map +1 -1
- package/dist/index.js +113 -148
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +21 -5
- package/dist/index.modern.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1367,14 +1367,10 @@ const mapOptionItem = item => {
|
|
|
1367
1367
|
* 搭建器选项是 { label, value, children };SelectCascader 默认 valueKey='id'、示例用 id/name。
|
|
1368
1368
|
* 补齐两边的 key,避免 mapping 全部落到 undefined 导致下拉空白。
|
|
1369
1369
|
*/
|
|
1370
|
-
const alignOptionKeys =
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
let {
|
|
1375
|
-
valueKey = 'value',
|
|
1376
|
-
labelKey = 'label'
|
|
1377
|
-
} = _temp === void 0 ? {} : _temp;
|
|
1370
|
+
const alignOptionKeys = (options = [], {
|
|
1371
|
+
valueKey = 'value',
|
|
1372
|
+
labelKey = 'label'
|
|
1373
|
+
} = {}) => {
|
|
1378
1374
|
if (!Array.isArray(options)) {
|
|
1379
1375
|
return options;
|
|
1380
1376
|
}
|
|
@@ -1413,16 +1409,12 @@ const alignOptionKeys = function (options, _temp) {
|
|
|
1413
1409
|
* SelectTree 按扁平 parentId 组树,会覆盖节点上已有的 children。
|
|
1414
1410
|
* 搭建器存的是嵌套 children,交给 SelectTree 前先拍平。
|
|
1415
1411
|
*/
|
|
1416
|
-
const flattenTreeOptions =
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
parentKey = 'parentId',
|
|
1423
|
-
childrenKey = 'children',
|
|
1424
|
-
parentId
|
|
1425
|
-
} = _temp2 === void 0 ? {} : _temp2;
|
|
1412
|
+
const flattenTreeOptions = (options = [], {
|
|
1413
|
+
valueKey = 'value',
|
|
1414
|
+
parentKey = 'parentId',
|
|
1415
|
+
childrenKey = 'children',
|
|
1416
|
+
parentId
|
|
1417
|
+
} = {}) => {
|
|
1426
1418
|
const result = [];
|
|
1427
1419
|
(Array.isArray(options) ? options : []).forEach(item => {
|
|
1428
1420
|
if (!item || typeof item !== 'object') {
|
|
@@ -1448,16 +1440,11 @@ const flattenTreeOptions = function (options, _temp2) {
|
|
|
1448
1440
|
});
|
|
1449
1441
|
return result;
|
|
1450
1442
|
};
|
|
1451
|
-
const createApiFromOptions =
|
|
1452
|
-
|
|
1453
|
-
options
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
loader: () => ({
|
|
1457
|
-
pageData: options.map(mapOptionItem)
|
|
1458
|
-
})
|
|
1459
|
-
};
|
|
1460
|
-
};
|
|
1443
|
+
const createApiFromOptions = (options = []) => ({
|
|
1444
|
+
loader: () => ({
|
|
1445
|
+
pageData: options.map(mapOptionItem)
|
|
1446
|
+
})
|
|
1447
|
+
});
|
|
1461
1448
|
|
|
1462
1449
|
const {
|
|
1463
1450
|
useOnChange: useOnChange$1
|
|
@@ -2430,15 +2417,14 @@ const TYPE_TAG_COLORS = {
|
|
|
2430
2417
|
Checkbox: 'green',
|
|
2431
2418
|
DatePicker: 'lime'
|
|
2432
2419
|
};
|
|
2433
|
-
const FieldRow =
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
} = _ref;
|
|
2420
|
+
const FieldRow = ({
|
|
2421
|
+
field,
|
|
2422
|
+
index,
|
|
2423
|
+
total,
|
|
2424
|
+
onEdit,
|
|
2425
|
+
onDelete,
|
|
2426
|
+
onMove
|
|
2427
|
+
}) => {
|
|
2442
2428
|
const {
|
|
2443
2429
|
formatMessage
|
|
2444
2430
|
} = reactIntl.useIntl();
|
|
@@ -3636,24 +3622,18 @@ const RulePresetEditor = () => {
|
|
|
3636
3622
|
id: 'ruleLenMin'
|
|
3637
3623
|
}),
|
|
3638
3624
|
min: 0,
|
|
3639
|
-
display:
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
} = _ref;
|
|
3643
|
-
return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
|
|
3644
|
-
}
|
|
3625
|
+
display: ({
|
|
3626
|
+
openApi
|
|
3627
|
+
}) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
|
|
3645
3628
|
}, "lenMin"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.InputNumber, {
|
|
3646
3629
|
name: "lenMax",
|
|
3647
3630
|
label: formatMessage({
|
|
3648
3631
|
id: 'ruleLenMax'
|
|
3649
3632
|
}),
|
|
3650
3633
|
min: 0,
|
|
3651
|
-
display:
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
} = _ref2;
|
|
3655
|
-
return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
|
|
3656
|
-
}
|
|
3634
|
+
display: ({
|
|
3635
|
+
openApi
|
|
3636
|
+
}) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
|
|
3657
3637
|
}, "lenMax"), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3658
3638
|
block: true,
|
|
3659
3639
|
children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
|
|
@@ -3694,30 +3674,19 @@ const createEmptyTableRow = columns => {
|
|
|
3694
3674
|
});
|
|
3695
3675
|
return row;
|
|
3696
3676
|
};
|
|
3697
|
-
const ensureOptionKeys =
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
_key: item._key || createOptionKey(),
|
|
3704
|
-
children: Array.isArray(item.children) ? ensureOptionKeys(item.children) : undefined
|
|
3705
|
-
}));
|
|
3706
|
-
};
|
|
3707
|
-
const hasMissingOptionKey = function (list) {
|
|
3708
|
-
if (list === void 0) {
|
|
3709
|
-
list = [];
|
|
3710
|
-
}
|
|
3711
|
-
return list.some(item => !item?._key || Array.isArray(item.children) && hasMissingOptionKey(item.children));
|
|
3712
|
-
};
|
|
3677
|
+
const ensureOptionKeys = (list = []) => list.map(item => ({
|
|
3678
|
+
...item,
|
|
3679
|
+
_key: item._key || createOptionKey(),
|
|
3680
|
+
children: Array.isArray(item.children) ? ensureOptionKeys(item.children) : undefined
|
|
3681
|
+
}));
|
|
3682
|
+
const hasMissingOptionKey = (list = []) => list.some(item => !item?._key || Array.isArray(item.children) && hasMissingOptionKey(item.children));
|
|
3713
3683
|
|
|
3714
3684
|
/** 扁平选项(非树) */
|
|
3715
|
-
const FlatOptionRows =
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
} = _ref;
|
|
3685
|
+
const FlatOptionRows = ({
|
|
3686
|
+
list,
|
|
3687
|
+
onChange,
|
|
3688
|
+
allowDescription
|
|
3689
|
+
}) => {
|
|
3721
3690
|
const {
|
|
3722
3691
|
formatMessage
|
|
3723
3692
|
} = reactIntl.useIntl();
|
|
@@ -3783,16 +3752,15 @@ const FlatOptionRows = _ref => {
|
|
|
3783
3752
|
};
|
|
3784
3753
|
|
|
3785
3754
|
/** 树形 / 级联选项 */
|
|
3786
|
-
const TreeOptionNode =
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
} = _ref2;
|
|
3755
|
+
const TreeOptionNode = ({
|
|
3756
|
+
item,
|
|
3757
|
+
index,
|
|
3758
|
+
siblings,
|
|
3759
|
+
onChangeSiblings,
|
|
3760
|
+
allowDescription,
|
|
3761
|
+
depth,
|
|
3762
|
+
maxDepth = 4
|
|
3763
|
+
}) => {
|
|
3796
3764
|
const {
|
|
3797
3765
|
formatMessage
|
|
3798
3766
|
} = reactIntl.useIntl();
|
|
@@ -3889,12 +3857,11 @@ const TreeOptionNode = _ref2 => {
|
|
|
3889
3857
|
}) : null]
|
|
3890
3858
|
});
|
|
3891
3859
|
};
|
|
3892
|
-
const TreeOptionsEditor =
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
} = _ref3;
|
|
3860
|
+
const TreeOptionsEditor = ({
|
|
3861
|
+
value = [],
|
|
3862
|
+
onChange,
|
|
3863
|
+
allowDescription
|
|
3864
|
+
}) => {
|
|
3898
3865
|
const {
|
|
3899
3866
|
formatMessage
|
|
3900
3867
|
} = reactIntl.useIntl();
|
|
@@ -3933,11 +3900,10 @@ const TreeOptionsEditor = _ref3 => {
|
|
|
3933
3900
|
})]
|
|
3934
3901
|
});
|
|
3935
3902
|
};
|
|
3936
|
-
const ColumnsEditor =
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
} = _ref4;
|
|
3903
|
+
const ColumnsEditor = ({
|
|
3904
|
+
value = [],
|
|
3905
|
+
onChange
|
|
3906
|
+
}) => {
|
|
3941
3907
|
const {
|
|
3942
3908
|
formatMessage
|
|
3943
3909
|
} = reactIntl.useIntl();
|
|
@@ -4032,12 +3998,11 @@ const ColumnsEditor = _ref4 => {
|
|
|
4032
3998
|
}, "columns-editor")]
|
|
4033
3999
|
});
|
|
4034
4000
|
};
|
|
4035
|
-
const TableRowsEditor =
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
} = _ref5;
|
|
4001
|
+
const TableRowsEditor = ({
|
|
4002
|
+
columns = [],
|
|
4003
|
+
value = [],
|
|
4004
|
+
onChange
|
|
4005
|
+
}) => {
|
|
4041
4006
|
const {
|
|
4042
4007
|
formatMessage
|
|
4043
4008
|
} = reactIntl.useIntl();
|
|
@@ -4162,16 +4127,15 @@ const TableRowsEditor = _ref5 => {
|
|
|
4162
4127
|
}, "table-rows-editor")]
|
|
4163
4128
|
});
|
|
4164
4129
|
};
|
|
4165
|
-
const OptionsEditor =
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
} = _ref6;
|
|
4130
|
+
const OptionsEditor = ({
|
|
4131
|
+
value = [],
|
|
4132
|
+
onChange,
|
|
4133
|
+
allowDescription = false,
|
|
4134
|
+
allowChildren = false,
|
|
4135
|
+
hasColumns = false,
|
|
4136
|
+
columns = [],
|
|
4137
|
+
onColumnsChange
|
|
4138
|
+
}) => {
|
|
4175
4139
|
const {
|
|
4176
4140
|
formatMessage
|
|
4177
4141
|
} = reactIntl.useIntl();
|
|
@@ -4238,10 +4202,9 @@ const OptionsEditor = _ref6 => {
|
|
|
4238
4202
|
};
|
|
4239
4203
|
var OptionsEditor$1 = OptionsEditor;
|
|
4240
4204
|
|
|
4241
|
-
const SuperSelectPropsEditor =
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
} = _ref;
|
|
4205
|
+
const SuperSelectPropsEditor = ({
|
|
4206
|
+
definition
|
|
4207
|
+
}) => {
|
|
4245
4208
|
const {
|
|
4246
4209
|
formatMessage
|
|
4247
4210
|
} = reactIntl.useIntl();
|
|
@@ -4279,12 +4242,9 @@ const SuperSelectPropsEditor = _ref => {
|
|
|
4279
4242
|
})
|
|
4280
4243
|
}, "allowClear"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
|
|
4281
4244
|
name: "allowSelectedAll",
|
|
4282
|
-
display:
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
} = _ref2;
|
|
4286
|
-
return !openApi?.data?.single;
|
|
4287
|
-
},
|
|
4245
|
+
display: ({
|
|
4246
|
+
openApi
|
|
4247
|
+
}) => !openApi?.data?.single,
|
|
4288
4248
|
children: formatMessage({
|
|
4289
4249
|
id: 'superSelectAllowSelectedAll'
|
|
4290
4250
|
})
|
|
@@ -4306,12 +4266,9 @@ const SuperSelectPropsEditor = _ref => {
|
|
|
4306
4266
|
placeholder: formatMessage({
|
|
4307
4267
|
id: 'superSelectMaxLengthPlaceholder'
|
|
4308
4268
|
}),
|
|
4309
|
-
display:
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
} = _ref3;
|
|
4313
|
-
return !openApi?.data?.single;
|
|
4314
|
-
}
|
|
4269
|
+
display: ({
|
|
4270
|
+
openApi
|
|
4271
|
+
}) => !openApi?.data?.single
|
|
4315
4272
|
}, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
|
|
4316
4273
|
name: "placeholder",
|
|
4317
4274
|
label: formatMessage({
|
|
@@ -4544,12 +4501,9 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4544
4501
|
}]
|
|
4545
4502
|
}, "format"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
|
|
4546
4503
|
name: "showTime",
|
|
4547
|
-
display:
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
} = _ref;
|
|
4551
|
-
return (openApi?.data?.picker || 'date') === 'date';
|
|
4552
|
-
},
|
|
4504
|
+
display: ({
|
|
4505
|
+
openApi
|
|
4506
|
+
}) => (openApi?.data?.picker || 'date') === 'date',
|
|
4553
4507
|
children: formatMessage({
|
|
4554
4508
|
id: 'propShowTime'
|
|
4555
4509
|
})
|
|
@@ -4576,11 +4530,10 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4576
4530
|
return [];
|
|
4577
4531
|
}
|
|
4578
4532
|
};
|
|
4579
|
-
const FieldPropsEditor =
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
} = _ref2;
|
|
4533
|
+
const FieldPropsEditor = ({
|
|
4534
|
+
type,
|
|
4535
|
+
definition: definitionProp
|
|
4536
|
+
}) => {
|
|
4584
4537
|
const {
|
|
4585
4538
|
formatMessage
|
|
4586
4539
|
} = reactIntl.useIntl();
|
|
@@ -5172,14 +5125,14 @@ const buildMultipleHint = (formatMessage, minLength, maxLength) => {
|
|
|
5172
5125
|
* choice:同一条选项 UI;mode=single 只挂载一支;mode=multiple 平铺所有选中支。
|
|
5173
5126
|
* 外层用 InfoPage.Part 的 title 展示标题。
|
|
5174
5127
|
*/
|
|
5175
|
-
const ChoiceBlock =
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5128
|
+
const ChoiceBlock = ({
|
|
5129
|
+
block,
|
|
5130
|
+
preview = false,
|
|
5131
|
+
isMobile = false,
|
|
5132
|
+
isPartRoot = false,
|
|
5133
|
+
formatMessage,
|
|
5134
|
+
renderOptionContent
|
|
5135
|
+
}) => {
|
|
5183
5136
|
const mode = block.mode === 'multiple' ? 'multiple' : 'single';
|
|
5184
5137
|
const selectorName = resolveSelectorName(block);
|
|
5185
5138
|
const options = react.useMemo(() => block.options || [], [block.options]);
|
|
@@ -5325,7 +5278,7 @@ const ChoiceBlock = _ref => {
|
|
|
5325
5278
|
title,
|
|
5326
5279
|
subtitle: modeHint,
|
|
5327
5280
|
bordered,
|
|
5328
|
-
className: style['choice-block'],
|
|
5281
|
+
className: [style['choice-block'], isPartRoot ? InfoPage__default["default"].partRootClassName : null].filter(Boolean).join(' '),
|
|
5329
5282
|
'data-choice-mode': mode
|
|
5330
5283
|
}, /*#__PURE__*/react.createElement('div', {
|
|
5331
5284
|
className: style['choice-selector']
|
|
@@ -5349,6 +5302,11 @@ const buildLabelTips = tips => {
|
|
|
5349
5302
|
className: style['field-label-tips-icon']
|
|
5350
5303
|
}));
|
|
5351
5304
|
};
|
|
5305
|
+
const resolvePartRootClassName = function (depth) {
|
|
5306
|
+
// 顶层模块一律重设一级标题,嵌入外层 FormInfo Part 时不降为二级胶囊
|
|
5307
|
+
const names = [depth === 0 ? InfoPage__default["default"].partRootClassName : null, ...[].slice.call(arguments, 1)].filter(Boolean);
|
|
5308
|
+
return names.length ? names.join(' ') : undefined;
|
|
5309
|
+
};
|
|
5352
5310
|
const renderFieldElements = function (fields, preview, _temp) {
|
|
5353
5311
|
if (fields === void 0) {
|
|
5354
5312
|
fields = [];
|
|
@@ -5473,7 +5431,8 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5473
5431
|
gap: block.gap,
|
|
5474
5432
|
bordered,
|
|
5475
5433
|
list: [...fields, ...nested],
|
|
5476
|
-
...(listItemPartProps || {})
|
|
5434
|
+
...(listItemPartProps || {}),
|
|
5435
|
+
className: resolvePartRootClassName(depth)
|
|
5477
5436
|
}), asListItem);
|
|
5478
5437
|
}
|
|
5479
5438
|
case 'object':
|
|
@@ -5490,7 +5449,8 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5490
5449
|
gap: block.gap,
|
|
5491
5450
|
bordered,
|
|
5492
5451
|
list: [...fields, ...nested],
|
|
5493
|
-
...(listItemPartProps || {})
|
|
5452
|
+
...(listItemPartProps || {}),
|
|
5453
|
+
className: resolvePartRootClassName(depth)
|
|
5494
5454
|
}), asListItem);
|
|
5495
5455
|
}
|
|
5496
5456
|
case 'list':
|
|
@@ -5503,6 +5463,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5503
5463
|
title: block.title || undefined,
|
|
5504
5464
|
important: block.important || undefined,
|
|
5505
5465
|
bordered,
|
|
5466
|
+
className: resolvePartRootClassName(depth),
|
|
5506
5467
|
maxLength: block.maxLength,
|
|
5507
5468
|
minLength: block.minLength,
|
|
5508
5469
|
...(block.addText ? {
|
|
@@ -5528,7 +5489,8 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5528
5489
|
addText: block.addText
|
|
5529
5490
|
} : {}),
|
|
5530
5491
|
list: fields,
|
|
5531
|
-
...(listItemPartProps || {})
|
|
5492
|
+
...(listItemPartProps || {}),
|
|
5493
|
+
className: resolvePartRootClassName(depth)
|
|
5532
5494
|
}), asListItem);
|
|
5533
5495
|
}
|
|
5534
5496
|
case 'multiField':
|
|
@@ -5555,6 +5517,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5555
5517
|
title: block.title || undefined,
|
|
5556
5518
|
subtitle: block.subtitle || undefined,
|
|
5557
5519
|
bordered,
|
|
5520
|
+
className: resolvePartRootClassName(depth),
|
|
5558
5521
|
prevIcon: /*#__PURE__*/react.createElement(icons.ArrowLeftOutlined),
|
|
5559
5522
|
nextIcon: /*#__PURE__*/react.createElement(icons.ArrowRightOutlined),
|
|
5560
5523
|
items: (block.items || []).map(step => {
|
|
@@ -5595,6 +5558,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5595
5558
|
block,
|
|
5596
5559
|
preview,
|
|
5597
5560
|
isMobile,
|
|
5561
|
+
isPartRoot: depth === 0,
|
|
5598
5562
|
formatMessage,
|
|
5599
5563
|
renderOptionContent: option => {
|
|
5600
5564
|
const nodes = [];
|
|
@@ -7236,7 +7200,8 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7236
7200
|
key: block.id,
|
|
7237
7201
|
title: block.title || block.label || undefined,
|
|
7238
7202
|
subtitle: block.subtitle || undefined,
|
|
7239
|
-
bordered
|
|
7203
|
+
bordered,
|
|
7204
|
+
className: depth === 0 ? InfoPage__default["default"].partRootClassName : undefined
|
|
7240
7205
|
};
|
|
7241
7206
|
switch (block.kind) {
|
|
7242
7207
|
case 'formInfo':
|