@pisell/materials 1.0.631 → 1.0.633

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.
Files changed (27) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +20 -12
  7. package/build/lowcode/render/default/view.js +28 -23
  8. package/build/lowcode/view.js +26 -21
  9. package/es/components/dataSourceComponents/dataSourceForm/utils.js +8 -3
  10. package/es/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +1 -2
  11. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  12. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +1 -0
  13. package/es/components/dataSourceComponents/fields/Select/index.d.ts +0 -1
  14. package/es/components/dataSourceComponents/fields/index.d.ts +0 -2
  15. package/es/components/dataSourceComponents/hooks/useValueMap.js +2 -2
  16. package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
  17. package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -2
  18. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +7 -3
  19. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useColumns.js +5 -4
  20. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
  21. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +1 -0
  22. package/lib/components/dataSourceComponents/fields/Select/index.d.ts +0 -1
  23. package/lib/components/dataSourceComponents/fields/index.d.ts +0 -2
  24. package/lib/components/dataSourceComponents/hooks/useValueMap.js +1 -1
  25. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
  26. package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -1
  27. package/package.json +3 -3
@@ -357,7 +357,12 @@ export var withDataSource = function withDataSource(WrappedComponent) {
357
357
  return function (props) {
358
358
  var dataSource = props.dataSource;
359
359
  return /*#__PURE__*/React.createElement(DataSourceProvider, {
360
- dataSource: dataSource
360
+ dataSource: dataSource,
361
+ requestOptions: {
362
+ list: {
363
+ cacheKey: "".concat(dataSource === null || dataSource === void 0 ? void 0 : dataSource.headerDataSource, "-").concat(dataSource === null || dataSource === void 0 ? void 0 : dataSource.name, "-").concat(dataSource === null || dataSource === void 0 ? void 0 : dataSource.tableName)
364
+ }
365
+ }
361
366
  }, /*#__PURE__*/React.createElement(WrappedComponent, props));
362
367
  };
363
368
  };
@@ -376,7 +381,7 @@ export var withOptions = function withOptions(WrappedComponent) {
376
381
  if (optionSourceType === 'api') {
377
382
  list.run(_objectSpread({
378
383
  page: 1,
379
- pageSize: 200
384
+ pageSize: 500
380
385
  }, extraParams));
381
386
  }
382
387
  }, []);
@@ -436,7 +441,7 @@ export var renderValueWithMap = function renderValueWithMap(value, valueMap, ren
436
441
  style: textStyle
437
442
  }, valueMap === null || valueMap === void 0 ? void 0 : valueMap[item]), index < value.length - 1 && ', ');
438
443
  }));
439
- } else if (isString(value)) {
444
+ } else if (isString(value) || isNumber(value)) {
440
445
  return /*#__PURE__*/React.createElement("span", {
441
446
  className: "pisell-form-read-pretty-text"
442
447
  }, /*#__PURE__*/React.createElement("span", {
@@ -12,8 +12,7 @@ var genFieldProps = function genFieldProps(field, fieldProps) {
12
12
  renderMode: 'tableView',
13
13
  noStyle: true
14
14
  };
15
- if (!field) return props;
16
- if (['Select', 'Radio.Group', 'Checkbox.Group'].includes(field.uiSchema['x-component']) && field.uiSchema.enum.length > 0) {
15
+ if (field && ['Select', 'Radio.Group', 'Checkbox.Group'].includes(field.uiSchema['x-component']) && field.uiSchema.enum.length > 0) {
17
16
  if (['Radio.Group', 'Checkbox.Group'].includes(field.uiSchema['x-component'])) {
18
17
  props.direction = 'horizontal';
19
18
  }
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
17
17
  * @returns
18
18
  */
19
19
  declare const useTableProps: (props: UseTablePropsProps) => {
20
- title: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
20
+ title: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
21
21
  pagination: {
22
22
  total: number;
23
23
  current: number;
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
26
26
  showSizeChanger: boolean;
27
27
  };
28
28
  columns: import("./useColumns").Column[];
29
- subTitle: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
29
+ subTitle: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
30
30
  buttons: any[] | null;
31
31
  filter: React.JSX.Element | null;
32
32
  onRow: (record: any) => any;
@@ -47,7 +47,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
47
47
  width: number;
48
48
  align: "center" | "left" | "right";
49
49
  fixed: false | "left" | "right";
50
- type: "button" | "link";
50
+ type: "link" | "button";
51
51
  items: OperationItem[];
52
52
  } | undefined;
53
53
  operationContent?: {
@@ -220,6 +220,7 @@ var useTableProps = function useTableProps(props) {
220
220
  buttonProps = button.buttonProps,
221
221
  beforeOpen = button.beforeOpen;
222
222
  return _objectSpread(_objectSpread(_objectSpread({}, button), buttonProps), {}, {
223
+ title: button.label,
223
224
  onClick: function onClick() {
224
225
  if (actionType === 'add') {
225
226
  var result = true;
@@ -4,7 +4,6 @@ declare const SelectWithDataSource: (props: import("antd").SelectProps<any, impo
4
4
  optionSourceType?: "default" | "custom" | "api" | undefined;
5
5
  labelField: string;
6
6
  valueField: string;
7
- extraParams?: Record<string, any> | undefined;
8
7
  } & {
9
8
  dataSource?: any;
10
9
  }) => React.JSX.Element;
@@ -38,7 +38,6 @@ declare const formFieldMap: {
38
38
  optionSourceType?: "default" | "custom" | "api" | undefined;
39
39
  labelField: string;
40
40
  valueField: string;
41
- extraParams?: Record<string, any> | undefined;
42
41
  } & {
43
42
  dataSource?: any;
44
43
  }) => import("react").JSX.Element;
@@ -95,7 +94,6 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
95
94
  optionSourceType?: "default" | "custom" | "api" | undefined;
96
95
  labelField: string;
97
96
  valueField: string;
98
- extraParams?: Record<string, any> | undefined;
99
97
  } & {
100
98
  dataSource?: any;
101
99
  }) => import("react").JSX.Element) | import("react").FC<import("./TimePicker/type").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./IconSelect/type").IconSelectProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import { isString } from '@pisell/utils';
2
+ import { isNumber, isString } from '@pisell/utils';
3
3
 
4
4
  /**
5
5
  * 将 options 转换为 valueMap
@@ -12,7 +12,7 @@ var useValueMap = function useValueMap(options) {
12
12
  return (options === null || options === void 0 ? void 0 : options.reduce(function (acc, item) {
13
13
  var itemValue = item.value;
14
14
  var itemLabel = item.label;
15
- if (isString(itemValue) && isString(itemLabel)) {
15
+ if ((isString(itemValue) || isNumber(itemValue)) && isString(itemLabel)) {
16
16
  acc[itemValue] = itemLabel;
17
17
  }
18
18
  return acc;
@@ -80,6 +80,13 @@ export declare type DataSourceContextProps = {
80
80
  create?: () => Promise<any>;
81
81
  destroy?: () => Promise<any>;
82
82
  };
83
+ requestOptions?: {
84
+ list?: any;
85
+ get?: any;
86
+ update?: any;
87
+ create?: any;
88
+ destroy?: any;
89
+ };
83
90
  overrideData?: {
84
91
  list?: any;
85
92
  get?: any;
@@ -24,6 +24,7 @@ var DataSourceProvider = function DataSourceProvider(props) {
24
24
  externalActions = props.actions,
25
25
  overrideData = props.overrideData,
26
26
  autoRun = props.autoRun,
27
+ requestOptions = props.requestOptions,
27
28
  __designMode = props.__designMode;
28
29
  useSetRequest();
29
30
  var _useVariables = useVariables(),
@@ -44,9 +45,9 @@ var DataSourceProvider = function DataSourceProvider(props) {
44
45
  var update = (externalActions === null || externalActions === void 0 ? void 0 : externalActions.update) || standardActions.update;
45
46
  var create = (externalActions === null || externalActions === void 0 ? void 0 : externalActions.create) || standardActions.create;
46
47
  var destroy = (externalActions === null || externalActions === void 0 ? void 0 : externalActions.destroy) || standardActions.destroy;
47
- var listResult = useRequest(list, {
48
+ var listResult = useRequest(list, _objectSpread({
48
49
  manual: isBoolean(autoRun === null || autoRun === void 0 ? void 0 : autoRun.list) ? !(autoRun !== null && autoRun !== void 0 && autoRun.list) : true
49
- });
50
+ }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.list));
50
51
  var getResult = useRequest(get, {
51
52
  manual: isBoolean(autoRun === null || autoRun === void 0 ? void 0 : autoRun.get) ? !(autoRun !== null && autoRun !== void 0 && autoRun.get) : true
52
53
  });
@@ -403,7 +403,11 @@ var withFormItem = (WrappedComponent, overlayProps) => {
403
403
  var withDataSource = (WrappedComponent) => {
404
404
  return (props) => {
405
405
  const { dataSource } = props;
406
- return /* @__PURE__ */ import_react.default.createElement(import_DataSourceProvider.default, { dataSource }, /* @__PURE__ */ import_react.default.createElement(WrappedComponent, { ...props }));
406
+ return /* @__PURE__ */ import_react.default.createElement(import_DataSourceProvider.default, { dataSource, requestOptions: {
407
+ list: {
408
+ cacheKey: `${dataSource == null ? void 0 : dataSource.headerDataSource}-${dataSource == null ? void 0 : dataSource.name}-${dataSource == null ? void 0 : dataSource.tableName}`
409
+ }
410
+ } }, /* @__PURE__ */ import_react.default.createElement(WrappedComponent, { ...props }));
407
411
  };
408
412
  };
409
413
  var withOptions = (WrappedComponent) => {
@@ -422,7 +426,7 @@ var withOptions = (WrappedComponent) => {
422
426
  if (optionSourceType === "api") {
423
427
  list.run({
424
428
  page: 1,
425
- pageSize: 200,
429
+ pageSize: 500,
426
430
  ...extraParams
427
431
  });
428
432
  }
@@ -462,7 +466,7 @@ var renderValueWithMap = (value, valueMap, renderMode) => {
462
466
  },
463
467
  valueMap == null ? void 0 : valueMap[item]
464
468
  ), index < value.length - 1 && ", ")));
465
- } else if ((0, import_utils.isString)(value)) {
469
+ } else if ((0, import_utils.isString)(value) || (0, import_utils.isNumber)(value)) {
466
470
  return /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-form-read-pretty-text" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-form-read-pretty-value", style: textStyle }, (valueMap == null ? void 0 : valueMap[value]) || value));
467
471
  }
468
472
  return null;
@@ -39,9 +39,7 @@ var genFieldProps = (field, fieldProps) => {
39
39
  renderMode: "tableView",
40
40
  noStyle: true
41
41
  };
42
- if (!field)
43
- return props;
44
- if (["Select", "Radio.Group", "Checkbox.Group"].includes(
42
+ if (field && ["Select", "Radio.Group", "Checkbox.Group"].includes(
45
43
  field.uiSchema["x-component"]
46
44
  ) && field.uiSchema.enum.length > 0) {
47
45
  if (["Radio.Group", "Checkbox.Group"].includes(field.uiSchema["x-component"])) {
@@ -76,7 +74,10 @@ var useColumns = ({
76
74
  const field = fieldMap[column == null ? void 0 : column.dataIndex];
77
75
  const title = (column == null ? void 0 : column.title) || (field == null ? void 0 : field.title);
78
76
  const FieldComponent = (0, import_fields.getFieldComponent)(column == null ? void 0 : column.fieldComponent) || "div";
79
- const fieldProps = genFieldProps(field, (_a = column.other) == null ? void 0 : _a.fieldProps);
77
+ const fieldProps = genFieldProps(
78
+ field,
79
+ (_a = column.other) == null ? void 0 : _a.fieldProps
80
+ );
80
81
  return {
81
82
  ...column,
82
83
  title,
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
17
17
  * @returns
18
18
  */
19
19
  declare const useTableProps: (props: UseTablePropsProps) => {
20
- title: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
20
+ title: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
21
21
  pagination: {
22
22
  total: number;
23
23
  current: number;
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
26
26
  showSizeChanger: boolean;
27
27
  };
28
28
  columns: import("./useColumns").Column[];
29
- subTitle: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
29
+ subTitle: number | boolean | React.JSX.Element | Iterable<React.ReactNode> | (() => React.ReactNode) | null | undefined;
30
30
  buttons: any[] | null;
31
31
  filter: React.JSX.Element | null;
32
32
  onRow: (record: any) => any;
@@ -47,7 +47,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
47
47
  width: number;
48
48
  align: "center" | "left" | "right";
49
49
  fixed: false | "left" | "right";
50
- type: "button" | "link";
50
+ type: "link" | "button";
51
51
  items: OperationItem[];
52
52
  } | undefined;
53
53
  operationContent?: {
@@ -207,6 +207,7 @@ var useTableProps = (props) => {
207
207
  return {
208
208
  ...button,
209
209
  ...buttonProps,
210
+ title: button.label,
210
211
  onClick: () => {
211
212
  if (actionType === "add") {
212
213
  let result = true;
@@ -4,7 +4,6 @@ declare const SelectWithDataSource: (props: import("antd").SelectProps<any, impo
4
4
  optionSourceType?: "default" | "custom" | "api" | undefined;
5
5
  labelField: string;
6
6
  valueField: string;
7
- extraParams?: Record<string, any> | undefined;
8
7
  } & {
9
8
  dataSource?: any;
10
9
  }) => React.JSX.Element;
@@ -38,7 +38,6 @@ declare const formFieldMap: {
38
38
  optionSourceType?: "default" | "custom" | "api" | undefined;
39
39
  labelField: string;
40
40
  valueField: string;
41
- extraParams?: Record<string, any> | undefined;
42
41
  } & {
43
42
  dataSource?: any;
44
43
  }) => import("react").JSX.Element;
@@ -95,7 +94,6 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
95
94
  optionSourceType?: "default" | "custom" | "api" | undefined;
96
95
  labelField: string;
97
96
  valueField: string;
98
- extraParams?: Record<string, any> | undefined;
99
97
  } & {
100
98
  dataSource?: any;
101
99
  }) => import("react").JSX.Element) | import("react").FC<import("./TimePicker/type").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./IconSelect/type").IconSelectProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
@@ -29,7 +29,7 @@ var useValueMap = (options) => {
29
29
  return (options == null ? void 0 : options.reduce((acc, item) => {
30
30
  const itemValue = item.value;
31
31
  const itemLabel = item.label;
32
- if ((0, import_utils.isString)(itemValue) && (0, import_utils.isString)(itemLabel)) {
32
+ if (((0, import_utils.isString)(itemValue) || (0, import_utils.isNumber)(itemValue)) && (0, import_utils.isString)(itemLabel)) {
33
33
  acc[itemValue] = itemLabel;
34
34
  }
35
35
  return acc;
@@ -80,6 +80,13 @@ export declare type DataSourceContextProps = {
80
80
  create?: () => Promise<any>;
81
81
  destroy?: () => Promise<any>;
82
82
  };
83
+ requestOptions?: {
84
+ list?: any;
85
+ get?: any;
86
+ update?: any;
87
+ create?: any;
88
+ destroy?: any;
89
+ };
83
90
  overrideData?: {
84
91
  list?: any;
85
92
  get?: any;
@@ -48,6 +48,7 @@ var DataSourceProvider = (props) => {
48
48
  actions: externalActions,
49
49
  overrideData,
50
50
  autoRun,
51
+ requestOptions,
51
52
  __designMode
52
53
  } = props;
53
54
  (0, import_useSetRequest.default)();
@@ -65,7 +66,8 @@ var DataSourceProvider = (props) => {
65
66
  const create = (externalActions == null ? void 0 : externalActions.create) || standardActions.create;
66
67
  const destroy = (externalActions == null ? void 0 : externalActions.destroy) || standardActions.destroy;
67
68
  const listResult = (0, import_ahooks.useRequest)(list, {
68
- manual: (0, import_utils.isBoolean)(autoRun == null ? void 0 : autoRun.list) ? !(autoRun == null ? void 0 : autoRun.list) : true
69
+ manual: (0, import_utils.isBoolean)(autoRun == null ? void 0 : autoRun.list) ? !(autoRun == null ? void 0 : autoRun.list) : true,
70
+ ...requestOptions == null ? void 0 : requestOptions.list
69
71
  });
70
72
  const getResult = (0, import_ahooks.useRequest)(get, {
71
73
  manual: (0, import_utils.isBoolean)(autoRun == null ? void 0 : autoRun.get) ? !(autoRun == null ? void 0 : autoRun.get) : true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.631",
3
+ "version": "1.0.633",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -70,9 +70,9 @@
70
70
  "swiper": "^8.4.7",
71
71
  "react-barcode": "^1.5.3",
72
72
  "vod-js-sdk-v6": "^1.4.11",
73
+ "@pisell/utils": "1.0.43",
73
74
  "@pisell/date-picker": "1.0.115",
74
- "@pisell/icon": "0.0.10",
75
- "@pisell/utils": "1.0.43"
75
+ "@pisell/icon": "0.0.10"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "react": "^18.0.0",