@pisell/materials 1.0.509 → 1.0.511

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 (28) 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 +4 -4
  7. package/build/lowcode/render/default/view.js +12 -12
  8. package/build/lowcode/view.js +14 -14
  9. package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +4 -2
  10. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -0
  11. package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +5 -3
  12. package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +27 -20
  13. package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
  14. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +1 -1
  15. package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +11 -9
  16. package/es/components/pisellViewGrid/index.js +3 -3
  17. package/es/components/select/index.js +1 -1
  18. package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +3 -1
  19. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -0
  20. package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingProvider.js +4 -3
  21. package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +9 -4
  22. package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
  23. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +1 -1
  24. package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +8 -14
  25. package/lib/components/pisellViewGrid/index.js +2 -2
  26. package/lib/components/select/index.js +1 -1
  27. package/lowcode/data-source-form/meta.ts +12 -0
  28. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className"];
1
+ var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className", "onDataSourceFinish"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -25,6 +25,7 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
25
25
  children = props.children,
26
26
  currentValue = props.currentValue,
27
27
  className = props.className,
28
+ onDataSourceFinish = props.onDataSourceFinish,
28
29
  others = _objectWithoutProperties(props, _excluded);
29
30
  var formRef = useRef(null);
30
31
  var _useDataSource = useDataSource(),
@@ -51,7 +52,8 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
51
52
  renderMode: renderMode,
52
53
  groupInfoPosition: groupInfoPosition,
53
54
  currentValue: currentValue,
54
- size: others.size
55
+ size: others.size,
56
+ onDataSourceFinish: onDataSourceFinish
55
57
  }, /*#__PURE__*/React.createElement(Form, _extends({}, others, {
56
58
  className: classNames('pisell-lowcode-data-source-form', className),
57
59
  ref: formRef,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ModeType } from '../../type';
3
3
  export interface FormSettingContextType {
4
+ onDataSourceFinish?: (values: any, result: any) => void;
4
5
  renderMode?: ModeType;
5
6
  groupInfoPosition?: 'top' | 'side';
6
7
  children?: React.ReactNode;
@@ -10,15 +10,17 @@ var FormSettingProvider = function FormSettingProvider(props) {
10
10
  renderMode = props.renderMode,
11
11
  groupInfoPosition = props.groupInfoPosition,
12
12
  currentValue = props.currentValue,
13
- size = props.size;
13
+ size = props.size,
14
+ onDataSourceFinish = props.onDataSourceFinish;
14
15
  var value = React.useMemo(function () {
15
16
  return {
16
17
  renderMode: renderMode,
17
18
  groupInfoPosition: groupInfoPosition,
18
19
  currentValue: currentValue,
19
- size: size
20
+ size: size,
21
+ onDataSourceFinish: onDataSourceFinish
20
22
  };
21
- }, [renderMode, groupInfoPosition, currentValue, size]);
23
+ }, [renderMode, groupInfoPosition, currentValue, size, onDataSourceFinish]);
22
24
  return /*#__PURE__*/React.createElement(FormSettingContext.Provider, {
23
25
  value: value
24
26
  }, children);
@@ -39,7 +39,8 @@ var SubmitButton = function SubmitButton(props) {
39
39
  contextHolder = _notification$useNoti2[1];
40
40
  var form = Form.useFormInstance();
41
41
  var _useFormSetting = useFormSetting(),
42
- renderMode = _useFormSetting.renderMode;
42
+ renderMode = _useFormSetting.renderMode,
43
+ onDataSourceFinish = _useFormSetting.onDataSourceFinish;
43
44
  var _useCtxActions = useCtxActions(),
44
45
  setVisible = _useCtxActions.setVisible,
45
46
  refreshTableData = _useCtxActions.refreshTableData;
@@ -56,33 +57,33 @@ var SubmitButton = function SubmitButton(props) {
56
57
  setLoading(true);
57
58
  _context.prev = 1;
58
59
  if (!(renderMode === 'edit')) {
59
- _context.next = 7;
60
+ _context.next = 8;
60
61
  break;
61
62
  }
62
63
  _context.next = 5;
63
64
  return update.runAsync(values);
64
65
  case 5:
65
- _context.next = 12;
66
- break;
67
- case 7:
66
+ return _context.abrupt("return", _context.sent);
67
+ case 8:
68
68
  if (!(renderMode === 'add')) {
69
- _context.next = 12;
69
+ _context.next = 14;
70
70
  break;
71
71
  }
72
- _context.next = 10;
72
+ _context.next = 11;
73
73
  return create.runAsync(values);
74
- case 10:
74
+ case 11:
75
75
  res = _context.sent;
76
76
  form === null || form === void 0 ? void 0 : form.resetFields();
77
- case 12:
78
- _context.prev = 12;
77
+ return _context.abrupt("return", res);
78
+ case 14:
79
+ _context.prev = 14;
79
80
  setLoading(false);
80
- return _context.finish(12);
81
- case 15:
81
+ return _context.finish(14);
82
+ case 17:
82
83
  case "end":
83
84
  return _context.stop();
84
85
  }
85
- }, _callee, null, [[1,, 12, 15]]);
86
+ }, _callee, null, [[1,, 14, 17]]);
86
87
  }));
87
88
  return function onSubmit(_x2) {
88
89
  return _ref.apply(this, arguments);
@@ -116,7 +117,7 @@ var SubmitButton = function SubmitButton(props) {
116
117
  // 验证表单并提交
117
118
  var handleValideFieldsSubmit = /*#__PURE__*/function () {
118
119
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values) {
119
- var allValues, afterSubmitFunc;
120
+ var allValues, result, afterSubmitFunc;
120
121
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
121
122
  while (1) switch (_context2.prev = _context2.next) {
122
123
  case 0:
@@ -137,6 +138,11 @@ var SubmitButton = function SubmitButton(props) {
137
138
  _context2.next = 8;
138
139
  return onSubmit(values);
139
140
  case 8:
141
+ result = _context2.sent;
142
+ // 数据源提交成功
143
+ if (onDataSourceFinish) {
144
+ onDataSourceFinish(values, result);
145
+ }
140
146
  if (refreshData) {
141
147
  refreshTableData === null || refreshTableData === void 0 ? void 0 : refreshTableData();
142
148
  }
@@ -151,19 +157,19 @@ var SubmitButton = function SubmitButton(props) {
151
157
  afterSubmitFunc();
152
158
  }
153
159
  }
154
- _context2.next = 16;
160
+ _context2.next = 18;
155
161
  break;
156
- case 13:
157
- _context2.prev = 13;
162
+ case 15:
163
+ _context2.prev = 15;
158
164
  _context2.t0 = _context2["catch"](0);
159
165
  PisellToast({
160
166
  content: "".concat(_context2.t0.message)
161
167
  });
162
- case 16:
168
+ case 18:
163
169
  case "end":
164
170
  return _context2.stop();
165
171
  }
166
- }, _callee2, null, [[0, 13]]);
172
+ }, _callee2, null, [[0, 15]]);
167
173
  }));
168
174
  return function handleValideFieldsSubmit(_x3) {
169
175
  return _ref2.apply(this, arguments);
@@ -216,7 +222,8 @@ var SubmitButton = function SubmitButton(props) {
216
222
  size: "large",
217
223
  loading: loading,
218
224
  onClick: onSubmitClick,
219
- disabled: isDisabled
225
+ disabled: isDisabled,
226
+ htmlType: "submit"
220
227
  }, childrenString), contextHolder));
221
228
  };
222
229
  export default SubmitButton;
@@ -14,5 +14,6 @@ export interface DataSourceFormProps {
14
14
  children: React.ReactNode;
15
15
  className?: string;
16
16
  size?: 'small' | 'middle' | 'large';
17
+ onDataSourceFinish?: (values: any, result: any) => void;
17
18
  __designMode?: string;
18
19
  }
@@ -65,7 +65,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
65
65
  useCustomAction: boolean;
66
66
  actionType: string;
67
67
  openMode: "modal" | "drawer";
68
- openContentSize: "small" | "large" | "middle";
68
+ openContentSize: "small" | "middle" | "large";
69
69
  openTitle: string;
70
70
  key: string;
71
71
  } | undefined;
@@ -109,15 +109,17 @@ var PhoneInput = function PhoneInput(_ref) {
109
109
  },
110
110
  onBlur: handleBlur,
111
111
  popupMatchSelectWidth: false,
112
- optionLabelProp: "label",
113
- showSearch: true
114
- }, countries.map(function (country) {
115
- return /*#__PURE__*/React.createElement(Option, {
116
- key: country.code,
117
- value: country.code,
118
- label: country.prefix
119
- }, translationOriginal(country.name), " (", country.prefix, ")");
120
- })), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
112
+ optionLabelProp: "inputValue",
113
+ optionFilterProp: "label",
114
+ showSearch: true,
115
+ options: countries.map(function (country) {
116
+ return {
117
+ value: country.code,
118
+ label: "".concat(translationOriginal(country.name), " (").concat(country.prefix, ")"),
119
+ inputValue: country.prefix
120
+ };
121
+ })
122
+ }), /*#__PURE__*/React.createElement(Input, _extends({}, props, {
121
123
  status: status,
122
124
  type: "tel",
123
125
  value: phoneNumber,
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import React from 'react';
8
- import { Loading } from '@alifd/next';
8
+ import Loading from "../pisellLoading";
9
9
  import classNames from 'classnames';
10
10
  import "./index.less";
11
11
  var PisellViewGrid = function PisellViewGrid(_ref) {
@@ -58,8 +58,8 @@ var PisellViewGrid = function PisellViewGrid(_ref) {
58
58
  });
59
59
  };
60
60
  return /*#__PURE__*/React.createElement(Loading, {
61
- visible: loading,
62
- fullScreen: false,
61
+ loading: loading,
62
+ fullscreen: false,
63
63
  style: {
64
64
  width: '100%'
65
65
  }
@@ -41,7 +41,7 @@ var SelectBase = /*#__PURE__*/forwardRef(function (props, ref) {
41
41
  setSearchValue = _useState2[1];
42
42
  var filteredOptions = useMemo(function () {
43
43
  if (!searchValue) return options;
44
- return options.filter(function (option) {
44
+ return (options || []).filter(function (option) {
45
45
  var _option$optionFilterP;
46
46
  var optionValue = ((_option$optionFilterP = option[optionFilterProp]) === null || _option$optionFilterP === void 0 ? void 0 : _option$optionFilterP.toString().toLowerCase()) || '';
47
47
  return optionValue.includes(searchValue.toLowerCase());
@@ -52,6 +52,7 @@ var BaseForm = (0, import_react.forwardRef)(
52
52
  children,
53
53
  currentValue,
54
54
  className,
55
+ onDataSourceFinish,
55
56
  ...others
56
57
  } = props;
57
58
  const formRef = (0, import_react.useRef)(null);
@@ -78,7 +79,8 @@ var BaseForm = (0, import_react.forwardRef)(
78
79
  renderMode,
79
80
  groupInfoPosition,
80
81
  currentValue,
81
- size: others.size
82
+ size: others.size,
83
+ onDataSourceFinish
82
84
  },
83
85
  /* @__PURE__ */ import_react.default.createElement(
84
86
  import_form.default,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { ModeType } from '../../type';
3
3
  export interface FormSettingContextType {
4
+ onDataSourceFinish?: (values: any, result: any) => void;
4
5
  renderMode?: ModeType;
5
6
  groupInfoPosition?: 'top' | 'side';
6
7
  children?: React.ReactNode;
@@ -35,15 +35,16 @@ module.exports = __toCommonJS(FormSettingProvider_exports);
35
35
  var import_react = __toESM(require("react"));
36
36
  var import_FormSettingContext = __toESM(require("./FormSettingContext"));
37
37
  var FormSettingProvider = (props) => {
38
- const { children, renderMode, groupInfoPosition, currentValue, size } = props;
38
+ const { children, renderMode, groupInfoPosition, currentValue, size, onDataSourceFinish } = props;
39
39
  const value = import_react.default.useMemo(() => {
40
40
  return {
41
41
  renderMode,
42
42
  groupInfoPosition,
43
43
  currentValue,
44
- size
44
+ size,
45
+ onDataSourceFinish
45
46
  };
46
- }, [renderMode, groupInfoPosition, currentValue, size]);
47
+ }, [renderMode, groupInfoPosition, currentValue, size, onDataSourceFinish]);
47
48
  return /* @__PURE__ */ import_react.default.createElement(
48
49
  import_FormSettingContext.default.Provider,
49
50
  {
@@ -57,7 +57,7 @@ var SubmitButton = (props) => {
57
57
  const [loading, setLoading] = (0, import_react.useState)(false);
58
58
  const [api, contextHolder] = import_antd.notification.useNotification();
59
59
  const form = import_antd.Form.useFormInstance();
60
- const { renderMode } = (0, import_useFormSetting.default)();
60
+ const { renderMode, onDataSourceFinish } = (0, import_useFormSetting.default)();
61
61
  const { setVisible, refreshTableData } = (0, import_useCtxActions.default)();
62
62
  const { create, update } = (0, import_useDataSource.default)();
63
63
  const isDisabled = status === "disabled";
@@ -65,10 +65,11 @@ var SubmitButton = (props) => {
65
65
  setLoading(true);
66
66
  try {
67
67
  if (renderMode === "edit") {
68
- await update.runAsync(values);
68
+ return await update.runAsync(values);
69
69
  } else if (renderMode === "add") {
70
70
  const res = await create.runAsync(values);
71
71
  form == null ? void 0 : form.resetFields();
72
+ return res;
72
73
  }
73
74
  } finally {
74
75
  setLoading(false);
@@ -110,7 +111,10 @@ var SubmitButton = (props) => {
110
111
  content: toastConfig.title
111
112
  });
112
113
  }
113
- await onSubmit(values);
114
+ const result = await onSubmit(values);
115
+ if (onDataSourceFinish) {
116
+ onDataSourceFinish(values, result);
117
+ }
114
118
  if (refreshData) {
115
119
  refreshTableData == null ? void 0 : refreshTableData();
116
120
  }
@@ -156,7 +160,8 @@ var SubmitButton = (props) => {
156
160
  size: "large",
157
161
  loading,
158
162
  onClick: onSubmitClick,
159
- disabled: isDisabled
163
+ disabled: isDisabled,
164
+ htmlType: "submit"
160
165
  },
161
166
  childrenString
162
167
  ), contextHolder));
@@ -14,5 +14,6 @@ export interface DataSourceFormProps {
14
14
  children: React.ReactNode;
15
15
  className?: string;
16
16
  size?: 'small' | 'middle' | 'large';
17
+ onDataSourceFinish?: (values: any, result: any) => void;
17
18
  __designMode?: string;
18
19
  }
@@ -65,7 +65,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
65
65
  useCustomAction: boolean;
66
66
  actionType: string;
67
67
  openMode: "modal" | "drawer";
68
- openContentSize: "small" | "large" | "middle";
68
+ openContentSize: "small" | "middle" | "large";
69
69
  openTitle: string;
70
70
  key: string;
71
71
  } | undefined;
@@ -111,21 +111,15 @@ var PhoneInput = ({ value: propsValue, onChange, isVerification, ...props }) =>
111
111
  style: { width: "90px" },
112
112
  onBlur: handleBlur,
113
113
  popupMatchSelectWidth: false,
114
- optionLabelProp: "label",
115
- showSearch: true
116
- },
117
- countries.map((country) => /* @__PURE__ */ import_react.default.createElement(
118
- Option,
119
- {
120
- key: country.code,
114
+ optionLabelProp: "inputValue",
115
+ optionFilterProp: "label",
116
+ showSearch: true,
117
+ options: countries.map((country) => ({
121
118
  value: country.code,
122
- label: country.prefix
123
- },
124
- translationOriginal(country.name),
125
- " (",
126
- country.prefix,
127
- ")"
128
- ))
119
+ label: `${translationOriginal(country.name)} (${country.prefix})`,
120
+ inputValue: country.prefix
121
+ }))
122
+ }
129
123
  ), /* @__PURE__ */ import_react.default.createElement(
130
124
  import_antd.Input,
131
125
  {
@@ -33,7 +33,7 @@ __export(pisellViewGrid_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(pisellViewGrid_exports);
35
35
  var import_react = __toESM(require("react"));
36
- var import_next = require("@alifd/next");
36
+ var import_pisellLoading = __toESM(require("../pisellLoading"));
37
37
  var import_classnames = __toESM(require("classnames"));
38
38
  var import_index = require("./index.less");
39
39
  var PisellViewGrid = ({
@@ -87,7 +87,7 @@ var PisellViewGrid = ({
87
87
  (dataSource == null ? void 0 : dataSource.length) ? renderItem == null ? void 0 : renderItem(item, index) : index
88
88
  ));
89
89
  };
90
- return /* @__PURE__ */ import_react.default.createElement(import_next.Loading, { visible: loading, fullScreen: false, style: { width: "100%" } }, /* @__PURE__ */ import_react.default.createElement("div", { className: classes, style }, /* @__PURE__ */ import_react.default.createElement(
90
+ return /* @__PURE__ */ import_react.default.createElement(import_pisellLoading.default, { loading, fullscreen: false, style: { width: "100%" } }, /* @__PURE__ */ import_react.default.createElement("div", { className: classes, style }, /* @__PURE__ */ import_react.default.createElement(
91
91
  "div",
92
92
  {
93
93
  className: "pisell-view-grid-content",
@@ -63,7 +63,7 @@ var SelectBase = (0, import_react.forwardRef)((props, ref) => {
63
63
  const filteredOptions = (0, import_react.useMemo)(() => {
64
64
  if (!searchValue)
65
65
  return options;
66
- return options.filter(
66
+ return (options || []).filter(
67
67
  (option) => {
68
68
  var _a;
69
69
  const optionValue = ((_a = option[optionFilterProp]) == null ? void 0 : _a.toString().toLowerCase()) || "";
@@ -704,6 +704,13 @@ const dataSourceForm: MetaType = {
704
704
  tip: '字段值更新时触发回调事件',
705
705
  },
706
706
  },
707
+ {
708
+ name: 'onDataSourceFinish',
709
+ title: {
710
+ label: '数据源提交成功',
711
+ tip: '数据源提交成功',
712
+ },
713
+ },
707
714
  ],
708
715
  component: { isContainer: true },
709
716
  supports: {
@@ -729,6 +736,11 @@ const dataSourceForm: MetaType = {
729
736
  template:
730
737
  "onValuesChange(changedValues,allValues,${extParams}){\n// 字段值更新时触发回调事件\nconsole.log('onValuesChange',changedValues,allValues);}",
731
738
  },
739
+ {
740
+ name: 'onDataSourceFinish',
741
+ template:
742
+ "onDataSourceFinish(values,result,${extParams}){\n// 数据源提交成功\nconsole.log('onDataSourceFinish',values,result);}",
743
+ },
732
744
  ],
733
745
  },
734
746
  advanced: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.509",
3
+ "version": "1.0.511",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -68,9 +68,9 @@
68
68
  "styled-components": "^6.0.0-rc.3",
69
69
  "libphonenumber-js": "^1.11.17",
70
70
  "swiper": "^8.4.7",
71
- "@pisell/icon": "0.0.10",
72
71
  "@pisell/utils": "1.0.43",
73
- "@pisell/date-picker": "1.0.114"
72
+ "@pisell/date-picker": "1.0.114",
73
+ "@pisell/icon": "0.0.10"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": "^18.0.0",