@kne/form-info 0.1.9 → 0.1.10
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 +27 -18
- package/dist/index.css +228 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +145 -42
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +136 -35
- package/dist/index.modern.js.map +1 -1
- package/dist/package-manifest.json +5 -0
- package/package.json +3 -1
package/dist/index.modern.js
CHANGED
|
@@ -2,14 +2,17 @@ import '@kne/info-page/dist/index.css';
|
|
|
2
2
|
import '@kne/react-form-antd/dist/index.css';
|
|
3
3
|
import { FormAntd, CancelButton, SubmitButton } from '@kne/react-form-antd';
|
|
4
4
|
export * from '@kne/react-form-antd';
|
|
5
|
-
import { forwardRef, isValidElement, useRef, createElement, createContext, useContext } from 'react';
|
|
5
|
+
import { useMemo, forwardRef, isValidElement, useRef, createElement, createContext, useContext } from 'react';
|
|
6
6
|
import InfoPage from '@kne/info-page';
|
|
7
7
|
import { useFlexBox } from '@kne/flex-box';
|
|
8
|
-
import { FormInfo as FormInfo$1, SubList, MultiField as MultiField$1, TableList as TableList$1 } from '@kne/react-form-plus';
|
|
8
|
+
import { FormInfo as FormInfo$1, SubList, MultiField as MultiField$1, TableList as TableList$1, FieldList } from '@kne/react-form-plus';
|
|
9
|
+
import { useIsMobile } from '@kne/responsive-utils';
|
|
9
10
|
import { Col, Row, Empty, Button, Divider, Modal, Flex, Steps } from 'antd';
|
|
10
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
12
|
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons';
|
|
12
13
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
14
|
+
import TableView, { isRenderMobileActive, resolveRenderMobile } from '@kne/table-view';
|
|
15
|
+
import '@kne/table-view/dist/index.css';
|
|
13
16
|
import useControlValue from '@kne/use-control-value';
|
|
14
17
|
|
|
15
18
|
function _extends() {
|
|
@@ -113,7 +116,7 @@ var classnames = createCommonjsModule(function (module) {
|
|
|
113
116
|
}());
|
|
114
117
|
});
|
|
115
118
|
|
|
116
|
-
var style = {"form-outer":"kne-form-info_ZQNNL","form-info":"kne-form-info_GW4Xx","extra-btn":"kne-form-info_eY4qR","list-part":"kne-form-info_SL3dC","list-item":"kne-form-info_PNnMa","
|
|
119
|
+
var style = {"kne-responsive-boundary":"kne-form-info_gh14z","kne-responsive-scroll":"kne-form-info_Kfn6L","form-outer":"kne-form-info_ZQNNL","form-info":"kne-form-info_GW4Xx","extra-btn":"kne-form-info_eY4qR","list-part":"kne-form-info_SL3dC","list-item":"kne-form-info_PNnMa","list-item-part":"kne-form-info_HiB5Q","is-important":"kne-form-info_Xkp38","table-list-inner":"kne-form-info_Uw-3T","multi-field-item":"kne-form-info_uogqr","react-form__field-label":"kne-form-info_UGjS9","multi-field-add-btn":"kne-form-info_rjVPh","table-list-view":"kne-form-info_ZD9zd","table-list":"kne-form-info_r8-bn","is-mobile":"kne-form-info_LtgJz","table-list-mobile-list":"kne-form-info_5uGUh","table-list-mobile-card":"kne-form-info_H8TZT","table-list-mobile-card-body":"kne-form-info_3Mhy7","table-list-mobile-field":"kne-form-info_-e-f1","table-list-mobile-actions":"kne-form-info_FVPV7","table-list-field":"kne-form-info_Qkutm","table-list-header":"kne-form-info_9WdfD","is-req":"kne-form-info_CsPaL","table-options":"kne-form-info_8smwK","steps":"kne-form-info_IOdkE","steps-vertical":"kne-form-info_03aHQ","steps-form-inner":"kne-form-info_uc1HZ","steps-modal":"kne-form-info_vWPQO","table-list-empty":"kne-form-info_DXskv","extra-container":"kne-form-info_wU-w4"};
|
|
117
120
|
|
|
118
121
|
const _excluded$7 = ["className", "column", "list", "gap"];
|
|
119
122
|
const FormInfo = props => {
|
|
@@ -128,7 +131,8 @@ const FormInfo = props => {
|
|
|
128
131
|
gap
|
|
129
132
|
} = _Object$assign,
|
|
130
133
|
others = _objectWithoutPropertiesLoose(_Object$assign, _excluded$7);
|
|
131
|
-
const
|
|
134
|
+
const isMobile = useIsMobile();
|
|
135
|
+
const isFlexBox = !isMobile && !(Number.isInteger(column) && column > 0);
|
|
132
136
|
const {
|
|
133
137
|
ref: flexBoxRef,
|
|
134
138
|
column: flexBoxColumn
|
|
@@ -163,6 +167,9 @@ const FormInfo = props => {
|
|
|
163
167
|
});
|
|
164
168
|
};
|
|
165
169
|
const renderColumn = () => {
|
|
170
|
+
if (isMobile) {
|
|
171
|
+
return renderInner(1);
|
|
172
|
+
}
|
|
166
173
|
if (!isFlexBox) {
|
|
167
174
|
return renderInner(column);
|
|
168
175
|
}
|
|
@@ -212,6 +219,7 @@ const List = withLocale(p => {
|
|
|
212
219
|
const {
|
|
213
220
|
formatMessage
|
|
214
221
|
} = useIntl();
|
|
222
|
+
const isMobile = useIsMobile();
|
|
215
223
|
const _Object$assign = Object.assign({}, {
|
|
216
224
|
addText: formatMessage({
|
|
217
225
|
id: 'addText'
|
|
@@ -237,8 +245,8 @@ const List = withLocale(p => {
|
|
|
237
245
|
bordered
|
|
238
246
|
} = _Object$assign,
|
|
239
247
|
others = _objectWithoutPropertiesLoose(_Object$assign, _excluded$6);
|
|
248
|
+
const showBorder = isMobile ? false : bordered;
|
|
240
249
|
return /*#__PURE__*/jsx(SubList, _extends({}, others, {
|
|
241
|
-
className: classnames(className, style['list-part']),
|
|
242
250
|
listRender: _ref => {
|
|
243
251
|
let {
|
|
244
252
|
id,
|
|
@@ -251,7 +259,7 @@ const List = withLocale(p => {
|
|
|
251
259
|
[style['is-important']]: important
|
|
252
260
|
}),
|
|
253
261
|
children: [/*#__PURE__*/jsx(FormInfo, _extends({}, props, {
|
|
254
|
-
bordered:
|
|
262
|
+
bordered: showBorder,
|
|
255
263
|
className: style['list-item-part'],
|
|
256
264
|
gap: 16,
|
|
257
265
|
extra: allowRemove && /*#__PURE__*/jsx(Button, {
|
|
@@ -270,9 +278,9 @@ const List = withLocale(p => {
|
|
|
270
278
|
onAdd
|
|
271
279
|
}) => {
|
|
272
280
|
return /*#__PURE__*/jsx(InfoPage.Part, {
|
|
273
|
-
className: itemClassName,
|
|
281
|
+
className: classnames(className, itemClassName, style['list-part']),
|
|
274
282
|
title: title,
|
|
275
|
-
bordered:
|
|
283
|
+
bordered: showBorder,
|
|
276
284
|
extra: /*#__PURE__*/jsx("div", {
|
|
277
285
|
className: style['extra-container'],
|
|
278
286
|
children: allowAdd && /*#__PURE__*/jsx(Button, {
|
|
@@ -348,7 +356,26 @@ const MultiField = withLocale(p => {
|
|
|
348
356
|
}));
|
|
349
357
|
});
|
|
350
358
|
|
|
351
|
-
const _excluded$4 = ["className", "addIcon", "addText", "removeIcon", "removeText", "title", "bordered"];
|
|
359
|
+
const _excluded$4 = ["className", "addIcon", "addText", "removeIcon", "removeText", "title", "bordered", "renderMobile", "list"];
|
|
360
|
+
const buildColumns = (list, {
|
|
361
|
+
removeText
|
|
362
|
+
}) => {
|
|
363
|
+
const fieldList = Array.isArray(list) ? list : [];
|
|
364
|
+
return [...fieldList.filter(item => {
|
|
365
|
+
var _item$props, _item$props2;
|
|
366
|
+
return (item == null || (_item$props = item.props) == null ? void 0 : _item$props.display) !== false && !(item != null && (_item$props2 = item.props) != null && _item$props2.hidden);
|
|
367
|
+
}).map(item => ({
|
|
368
|
+
name: item.props.name,
|
|
369
|
+
title: item.props.label,
|
|
370
|
+
render: value => value
|
|
371
|
+
})), {
|
|
372
|
+
name: '__options__',
|
|
373
|
+
type: 'options',
|
|
374
|
+
title: removeText || '',
|
|
375
|
+
width: 100,
|
|
376
|
+
render: value => value
|
|
377
|
+
}];
|
|
378
|
+
};
|
|
352
379
|
const TableList = withLocale(p => {
|
|
353
380
|
const {
|
|
354
381
|
formatMessage
|
|
@@ -374,10 +401,37 @@ const TableList = withLocale(p => {
|
|
|
374
401
|
removeIcon,
|
|
375
402
|
removeText,
|
|
376
403
|
title,
|
|
377
|
-
bordered
|
|
404
|
+
bordered,
|
|
405
|
+
renderMobile = true,
|
|
406
|
+
list
|
|
378
407
|
} = _Object$assign,
|
|
379
408
|
others = _objectWithoutPropertiesLoose(_Object$assign, _excluded$4);
|
|
380
|
-
|
|
409
|
+
const isMobile = useIsMobile();
|
|
410
|
+
const useMobileRender = isRenderMobileActive(renderMobile, isMobile);
|
|
411
|
+
const resolvedRenderMobile = useMemo(() => resolveRenderMobile(renderMobile), [renderMobile]);
|
|
412
|
+
const columns = useMemo(() => buildColumns(list, {
|
|
413
|
+
removeText
|
|
414
|
+
}), [list, removeText]);
|
|
415
|
+
const renderPart = (children, {
|
|
416
|
+
onAdd,
|
|
417
|
+
allowAdd
|
|
418
|
+
}, extraClassName) => /*#__PURE__*/jsx(InfoPage.Part, {
|
|
419
|
+
title: title,
|
|
420
|
+
className: classnames(className, style['table-list'], extraClassName),
|
|
421
|
+
bordered: bordered,
|
|
422
|
+
extra: /*#__PURE__*/jsx("div", {
|
|
423
|
+
className: style['extra-container'],
|
|
424
|
+
children: allowAdd && /*#__PURE__*/jsx(Button, {
|
|
425
|
+
className: style['extra-btn'],
|
|
426
|
+
icon: addIcon,
|
|
427
|
+
onClick: onAdd,
|
|
428
|
+
children: addText
|
|
429
|
+
})
|
|
430
|
+
}),
|
|
431
|
+
children: children
|
|
432
|
+
});
|
|
433
|
+
const renderDesktop = () => /*#__PURE__*/jsx(TableList$1, _extends({}, others, {
|
|
434
|
+
list: list,
|
|
381
435
|
headerRender: (children, {
|
|
382
436
|
width
|
|
383
437
|
}) => {
|
|
@@ -435,30 +489,68 @@ const TableList = withLocale(p => {
|
|
|
435
489
|
})]
|
|
436
490
|
}, id);
|
|
437
491
|
},
|
|
438
|
-
children: (children, {
|
|
439
|
-
|
|
440
|
-
|
|
492
|
+
children: (children, controls) => renderPart(/*#__PURE__*/jsx("div", {
|
|
493
|
+
className: style['table-list-inner'],
|
|
494
|
+
children: children
|
|
495
|
+
}), controls)
|
|
496
|
+
}));
|
|
497
|
+
const renderMobileList = () => /*#__PURE__*/jsx(SubList, _extends({}, others, {
|
|
498
|
+
list: list,
|
|
499
|
+
listRender: ({
|
|
500
|
+
id,
|
|
501
|
+
list: rowList,
|
|
502
|
+
groupArgs,
|
|
503
|
+
onRemove,
|
|
504
|
+
allowRemove
|
|
441
505
|
}) => {
|
|
442
|
-
return /*#__PURE__*/
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
506
|
+
return /*#__PURE__*/jsxs("div", {
|
|
507
|
+
className: classnames(style['table-list-mobile-card'], 'info-page-table-mobile-card'),
|
|
508
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
509
|
+
className: style['table-list-mobile-card-body'],
|
|
510
|
+
children: /*#__PURE__*/jsx(FieldList, {
|
|
511
|
+
list: rowList,
|
|
512
|
+
groupArgs: groupArgs,
|
|
513
|
+
itemRender: (children, targetProps) => {
|
|
514
|
+
if (targetProps.hidden) {
|
|
515
|
+
return /*#__PURE__*/jsx("div", {
|
|
516
|
+
style: {
|
|
517
|
+
display: 'none'
|
|
518
|
+
},
|
|
519
|
+
children: children
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return /*#__PURE__*/jsx("div", {
|
|
523
|
+
className: style['table-list-mobile-field'],
|
|
524
|
+
children: children
|
|
525
|
+
});
|
|
526
|
+
}
|
|
453
527
|
})
|
|
454
|
-
}),
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
528
|
+
}), /*#__PURE__*/jsx("div", {
|
|
529
|
+
className: style['table-list-mobile-actions'],
|
|
530
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
531
|
+
type: "link",
|
|
532
|
+
onClick: onRemove,
|
|
533
|
+
danger: true,
|
|
534
|
+
disabled: !allowRemove,
|
|
535
|
+
icon: removeIcon,
|
|
536
|
+
children: removeText
|
|
537
|
+
})
|
|
538
|
+
})]
|
|
539
|
+
}, id);
|
|
540
|
+
},
|
|
541
|
+
children: (children, controls) => renderPart(/*#__PURE__*/jsx("div", {
|
|
542
|
+
className: classnames(style['table-list-mobile-list'], 'info-page-table-mobile-card-list'),
|
|
543
|
+
children: children
|
|
544
|
+
}), controls, style['is-mobile'])
|
|
461
545
|
}));
|
|
546
|
+
return /*#__PURE__*/jsx(TableView, {
|
|
547
|
+
columns: columns,
|
|
548
|
+
dataSource: [],
|
|
549
|
+
empty: null,
|
|
550
|
+
className: style['table-list-view'],
|
|
551
|
+
renderMobile: useMobileRender ? typeof resolvedRenderMobile === 'function' ? resolvedRenderMobile : () => renderMobileList() : false,
|
|
552
|
+
render: () => renderDesktop()
|
|
553
|
+
});
|
|
462
554
|
});
|
|
463
555
|
|
|
464
556
|
const _excluded$3 = ["className", "children"];
|
|
@@ -3890,6 +3982,7 @@ const FormSteps = p => {
|
|
|
3890
3982
|
children
|
|
3891
3983
|
} = _Object$assign,
|
|
3892
3984
|
stepProps = _objectWithoutPropertiesLoose(_Object$assign, _excluded$1);
|
|
3985
|
+
const isMobile = useIsMobile();
|
|
3893
3986
|
const [currentStep, onStepChange] = useControlValue(stepProps, {
|
|
3894
3987
|
value: 'current',
|
|
3895
3988
|
defaultValue: 'defaultCurrent'
|
|
@@ -3915,12 +4008,20 @@ const FormSteps = p => {
|
|
|
3915
4008
|
}
|
|
3916
4009
|
return currentItem;
|
|
3917
4010
|
});
|
|
4011
|
+
|
|
4012
|
+
// 移动端强制垂直布局,不允许水平 Steps
|
|
4013
|
+
const stepsDirection = isMobile ? 'vertical' : stepProps.direction || stepProps.orientation;
|
|
4014
|
+
const isVerticalSteps = stepsDirection === 'vertical';
|
|
3918
4015
|
const inner = /*#__PURE__*/jsxs(Flex, {
|
|
3919
4016
|
className: className,
|
|
3920
|
-
vertical:
|
|
4017
|
+
vertical: !isVerticalSteps || isMobile,
|
|
3921
4018
|
gap: 24,
|
|
3922
|
-
children: [/*#__PURE__*/jsx(Steps, _extends({}, omit_1(stepProps, ['current', 'defaultCurrent', 'onChange']), {
|
|
3923
|
-
|
|
4019
|
+
children: [/*#__PURE__*/jsx(Steps, _extends({}, omit_1(stepProps, ['current', 'defaultCurrent', 'onChange', 'direction', 'orientation']), {
|
|
4020
|
+
direction: stepsDirection,
|
|
4021
|
+
orientation: stepsDirection,
|
|
4022
|
+
className: classnames(stepsClassName, style['steps'], {
|
|
4023
|
+
[style['steps-vertical']]: isVerticalSteps
|
|
4024
|
+
}),
|
|
3924
4025
|
items: stepItems,
|
|
3925
4026
|
current: currentStep
|
|
3926
4027
|
})), /*#__PURE__*/jsx("div", {
|