@kne/form-info 0.1.7 → 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.
@@ -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":"_ZQNNL","form-info":"_GW4Xx","extra-btn":"_eY4qR","list-part":"_SL3dC","list-item":"_PNnMa","is-important":"_Xkp38","list-item-part":"_HiB5Q","table-list-inner":"_Uw-3T","multi-field-item":"_uogqr","react-form__field-label":"_UGjS9","multi-field-add-btn":"_rjVPh","table-list":"_r8-bn","table-list-field":"_Qkutm","table-list-header":"_9WdfD","is-req":"_CsPaL","table-options":"_8smwK","steps":"_IOdkE","steps-form-inner":"_uc1HZ","steps-modal":"_vWPQO","table-list-empty":"_DXskv","extra-container":"_wU-w4"};
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 isFlexBox = !(Number.isInteger(column) && column > 0);
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
  }
@@ -206,12 +213,13 @@ const withLocale = createWithIntlProvider({
206
213
  namespace: 'form-info'
207
214
  });
208
215
 
209
- const _excluded$6 = ["className", "itemClassName", "removeIcon", "removeText", "addText", "addIcon", "important", "title"],
216
+ const _excluded$6 = ["className", "itemClassName", "removeIcon", "removeText", "addText", "addIcon", "important", "title", "bordered"],
210
217
  _excluded2$2 = ["id", "allowRemove", "onRemove", "index", "groupArgs"];
211
218
  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'
@@ -233,11 +241,12 @@ const List = withLocale(p => {
233
241
  addText,
234
242
  addIcon,
235
243
  important,
236
- title
244
+ title,
245
+ bordered
237
246
  } = _Object$assign,
238
247
  others = _objectWithoutPropertiesLoose(_Object$assign, _excluded$6);
248
+ const showBorder = isMobile ? false : bordered;
239
249
  return /*#__PURE__*/jsx(SubList, _extends({}, others, {
240
- className: classnames(className, style['list-part']),
241
250
  listRender: _ref => {
242
251
  let {
243
252
  id,
@@ -250,6 +259,7 @@ const List = withLocale(p => {
250
259
  [style['is-important']]: important
251
260
  }),
252
261
  children: [/*#__PURE__*/jsx(FormInfo, _extends({}, props, {
262
+ bordered: showBorder,
253
263
  className: style['list-item-part'],
254
264
  gap: 16,
255
265
  extra: allowRemove && /*#__PURE__*/jsx(Button, {
@@ -268,8 +278,9 @@ const List = withLocale(p => {
268
278
  onAdd
269
279
  }) => {
270
280
  return /*#__PURE__*/jsx(InfoPage.Part, {
271
- className: itemClassName,
281
+ className: classnames(className, itemClassName, style['list-part']),
272
282
  title: title,
283
+ bordered: showBorder,
273
284
  extra: /*#__PURE__*/jsx("div", {
274
285
  className: style['extra-container'],
275
286
  children: allowAdd && /*#__PURE__*/jsx(Button, {
@@ -345,7 +356,26 @@ const MultiField = withLocale(p => {
345
356
  }));
346
357
  });
347
358
 
348
- const _excluded$4 = ["className", "addIcon", "addText", "removeIcon", "removeText", "title"];
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
+ };
349
379
  const TableList = withLocale(p => {
350
380
  const {
351
381
  formatMessage
@@ -370,10 +400,38 @@ const TableList = withLocale(p => {
370
400
  addText,
371
401
  removeIcon,
372
402
  removeText,
373
- title
403
+ title,
404
+ bordered,
405
+ renderMobile = true,
406
+ list
374
407
  } = _Object$assign,
375
408
  others = _objectWithoutPropertiesLoose(_Object$assign, _excluded$4);
376
- return /*#__PURE__*/jsx(TableList$1, _extends({}, others, {
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,
377
435
  headerRender: (children, {
378
436
  width
379
437
  }) => {
@@ -431,29 +489,68 @@ const TableList = withLocale(p => {
431
489
  })]
432
490
  }, id);
433
491
  },
434
- children: (children, {
435
- onAdd,
436
- allowAdd
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
437
505
  }) => {
438
- return /*#__PURE__*/jsx(InfoPage.Part, {
439
- title: title,
440
- className: classnames(className, style['table-list']),
441
- extra: /*#__PURE__*/jsx("div", {
442
- className: style['extra-container'],
443
- children: allowAdd && /*#__PURE__*/jsx(Button, {
444
- className: style['extra-btn'],
445
- icon: addIcon,
446
- onClick: onAdd,
447
- children: addText
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
+ }
448
527
  })
449
- }),
450
- children: /*#__PURE__*/jsx("div", {
451
- className: style['table-list-inner'],
452
- children: children
453
- })
454
- });
455
- }
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'])
456
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
+ });
457
554
  });
458
555
 
459
556
  const _excluded$3 = ["className", "children"];
@@ -3332,7 +3429,9 @@ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
3332
3429
  function baseUnset(object, path) {
3333
3430
  path = _castPath(path, object);
3334
3431
 
3335
- // Prevent prototype pollution, see: https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg
3432
+ // Prevent prototype pollution:
3433
+ // https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg
3434
+ // https://github.com/lodash/lodash/security/advisories/GHSA-f23m-r3pf-42rh
3336
3435
  var index = -1,
3337
3436
  length = path.length;
3338
3437
 
@@ -3340,32 +3439,17 @@ function baseUnset(object, path) {
3340
3439
  return true;
3341
3440
  }
3342
3441
 
3343
- var isRootPrimitive = object == null || (typeof object !== 'object' && typeof object !== 'function');
3344
-
3345
3442
  while (++index < length) {
3346
- var key = path[index];
3347
-
3348
- // skip non-string keys (e.g., Symbols, numbers)
3349
- if (typeof key !== 'string') {
3350
- continue;
3351
- }
3443
+ var key = _toKey(path[index]);
3352
3444
 
3353
3445
  // Always block "__proto__" anywhere in the path if it's not expected
3354
3446
  if (key === '__proto__' && !hasOwnProperty$1.call(object, '__proto__')) {
3355
3447
  return false;
3356
3448
  }
3357
3449
 
3358
- // Block "constructor.prototype" chains
3359
- if (key === 'constructor' &&
3360
- (index + 1) < length &&
3361
- typeof path[index + 1] === 'string' &&
3362
- path[index + 1] === 'prototype') {
3363
-
3364
- // Allow ONLY when the path starts at a primitive root, e.g., _.unset(0, 'constructor.prototype.a')
3365
- if (isRootPrimitive && index === 0) {
3366
- continue;
3367
- }
3368
-
3450
+ // Block constructor/prototype as non-terminal traversal keys to prevent
3451
+ // escaping the object graph into built-in constructors and prototypes.
3452
+ if ((key === 'constructor' || key === 'prototype') && index < length - 1) {
3369
3453
  return false;
3370
3454
  }
3371
3455
  }
@@ -3898,6 +3982,7 @@ const FormSteps = p => {
3898
3982
  children
3899
3983
  } = _Object$assign,
3900
3984
  stepProps = _objectWithoutPropertiesLoose(_Object$assign, _excluded$1);
3985
+ const isMobile = useIsMobile();
3901
3986
  const [currentStep, onStepChange] = useControlValue(stepProps, {
3902
3987
  value: 'current',
3903
3988
  defaultValue: 'defaultCurrent'
@@ -3923,12 +4008,20 @@ const FormSteps = p => {
3923
4008
  }
3924
4009
  return currentItem;
3925
4010
  });
4011
+
4012
+ // 移动端强制垂直布局,不允许水平 Steps
4013
+ const stepsDirection = isMobile ? 'vertical' : stepProps.direction || stepProps.orientation;
4014
+ const isVerticalSteps = stepsDirection === 'vertical';
3926
4015
  const inner = /*#__PURE__*/jsxs(Flex, {
3927
4016
  className: className,
3928
- vertical: stepProps.direction !== 'vertical' || stepProps.orientation !== 'vertical',
4017
+ vertical: !isVerticalSteps || isMobile,
3929
4018
  gap: 24,
3930
- children: [/*#__PURE__*/jsx(Steps, _extends({}, omit_1(stepProps, ['current', 'defaultCurrent', 'onChange']), {
3931
- className: classnames(stepsClassName, style['steps']),
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
+ }),
3932
4025
  items: stepItems,
3933
4026
  current: currentStep
3934
4027
  })), /*#__PURE__*/jsx("div", {