@pisell/materials 6.0.11 → 6.0.12
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/build/lowcode/assets-daily.json +11 -15
- package/build/lowcode/assets-dev.json +2 -6
- package/build/lowcode/assets-prod.json +11 -15
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +22 -22
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +22 -22
- package/dist/umd/materials.min.css +1 -0
- package/dist/umd/materials.min.js +1 -0
- package/dist/umd/static/DotsSix.57d66266.svg +1 -0
- package/dist/umd/static/arrow-left.e542294f.svg +1 -0
- package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
- package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
- package/dist/umd/static/help-circle.31c9be40.svg +1 -0
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +94 -3
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +7 -6
- package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +120 -38
- package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
- package/es/components/dataSourceComponents/dataSourceMenu/index.js +19 -0
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +46 -8
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +90 -35
- package/es/components/dataSourceComponents/fields/Input.Mobile/index.js +11 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +0 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +73 -19
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +4 -2
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +161 -52
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +4 -2
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.js +2 -2
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +3 -13
- package/es/components/dataSourceComponents/fields/Input.Subdomain/serve.js +15 -13
- package/es/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
- package/es/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +17 -13
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.js +4 -2
- package/es/components/dataSourceComponents/fields/Upload/WithMode.js +5 -4
- package/es/components/dataSourceComponents/fields/Upload/index.less +1 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.js +5 -5
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
- package/es/components/dataSourceComponents/fields/index.d.ts +9 -5
- package/es/components/dataSourceComponents/fields/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/utils.js +1 -0
- package/es/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
- package/es/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
- package/es/components/dataSourceComponents/provider/actions/ActionsProvider.js +0 -1
- package/es/components/form/index.js +12 -0
- package/es/components/iconfont/index.js +1 -1
- package/es/components/pisellDraggable/components/Action/Action.d.ts +10 -0
- package/es/components/pisellDraggable/components/Action/Action.js +31 -0
- package/es/components/pisellDraggable/components/Action/Action.less +50 -0
- package/es/components/pisellDraggable/components/Action/index.d.ts +2 -0
- package/es/components/pisellDraggable/components/Action/index.js +1 -0
- package/es/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
- package/es/components/pisellDraggable/components/Handle/Handle.js +15 -0
- package/es/components/pisellDraggable/components/Handle/index.d.ts +1 -0
- package/es/components/pisellDraggable/components/Handle/index.js +1 -0
- package/es/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
- package/es/components/pisellDraggable/components/Remove/Remove.js +17 -0
- package/es/components/pisellDraggable/components/Remove/index.d.ts +1 -0
- package/es/components/pisellDraggable/components/Remove/index.js +1 -0
- package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
- package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +51 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +57 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
- package/es/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
- package/es/components/pisellDraggable/components/TreeItem/index.js +2 -0
- package/es/components/pisellDraggable/components/index.d.ts +4 -0
- package/es/components/pisellDraggable/components/index.js +4 -0
- package/es/components/pisellDraggable/index.d.ts +27 -0
- package/es/components/pisellDraggable/index.js +380 -0
- package/es/components/pisellDraggable/types.d.ts +17 -0
- package/es/components/pisellDraggable/types.js +1 -0
- package/es/components/pisellDraggable/utilities.d.ts +17 -0
- package/es/components/pisellDraggable/utilities.js +230 -0
- package/es/components/pisellLayout/content.d.ts +1 -0
- package/es/components/pisellLayout/content.js +19 -2
- package/es/components/pisellMenu/PisellMenu.d.ts +5 -0
- package/es/components/pisellMenu/PisellMenu.js +55 -0
- package/es/components/pisellMenu/PisellMenu.less +53 -0
- package/es/components/pisellMenu/index.d.ts +3 -0
- package/es/components/pisellMenu/index.js +2 -0
- package/es/components/pisellMenu/types.d.ts +30 -0
- package/es/components/pisellMenu/types.js +1 -0
- package/es/components/pisellModal/components/functions/index.less +3 -0
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/versionModal/index.d.ts +15 -0
- package/es/components/versionModal/index.js +192 -0
- package/es/components/versionModal/index.less +3 -0
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -1
- package/es/locales/en-US.d.ts +22 -0
- package/es/locales/en-US.js +24 -1
- package/es/locales/zh-CN.d.ts +21 -0
- package/es/locales/zh-CN.js +24 -2
- package/es/locales/zh-TW.d.ts +20 -0
- package/es/locales/zh-TW.js +23 -2
- package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +77 -4
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +8 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +138 -41
- package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
- package/lib/components/dataSourceComponents/dataSourceMenu/index.js +45 -0
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +14 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +44 -29
- package/lib/components/dataSourceComponents/fields/Input.Mobile/index.js +11 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.d.ts +0 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +34 -17
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.d.ts +4 -2
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +96 -36
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +4 -2
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.d.ts +3 -13
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/serve.js +19 -14
- package/lib/components/dataSourceComponents/fields/Translation/BaseTranslation.js +15 -4
- package/lib/components/dataSourceComponents/fields/Translation/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +5 -3
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.js +2 -2
- package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +4 -4
- package/lib/components/dataSourceComponents/fields/Upload/index.less +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/serve.js +5 -5
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +8 -0
- package/lib/components/dataSourceComponents/fields/index.d.ts +9 -5
- package/lib/components/dataSourceComponents/fields/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/utils.js +1 -0
- package/lib/components/dataSourceComponents/provider/actions/ActionsContext.d.ts +6 -1
- package/lib/components/dataSourceComponents/provider/actions/ActionsProvider.d.ts +4 -1
- package/lib/components/form/index.js +10 -1
- package/lib/components/iconfont/index.js +1 -1
- package/lib/components/pisellDraggable/components/Action/Action.d.ts +10 -0
- package/lib/components/pisellDraggable/components/Action/Action.js +60 -0
- package/lib/components/pisellDraggable/components/Action/Action.less +50 -0
- package/lib/components/pisellDraggable/components/Action/index.d.ts +2 -0
- package/lib/components/pisellDraggable/components/Action/index.js +29 -0
- package/lib/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
- package/lib/components/pisellDraggable/components/Handle/Handle.js +54 -0
- package/lib/components/pisellDraggable/components/Handle/index.d.ts +1 -0
- package/lib/components/pisellDraggable/components/Handle/index.js +29 -0
- package/lib/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
- package/lib/components/pisellDraggable/components/Remove/Remove.js +53 -0
- package/lib/components/pisellDraggable/components/Remove/index.d.ts +1 -0
- package/lib/components/pisellDraggable/components/Remove/index.js +29 -0
- package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
- package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +83 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +93 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
- package/lib/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
- package/lib/components/pisellDraggable/components/TreeItem/index.js +32 -0
- package/lib/components/pisellDraggable/components/index.d.ts +4 -0
- package/lib/components/pisellDraggable/components/index.js +40 -0
- package/lib/components/pisellDraggable/index.d.ts +27 -0
- package/lib/components/pisellDraggable/index.js +271 -0
- package/lib/components/pisellDraggable/types.d.ts +17 -0
- package/lib/components/pisellDraggable/types.js +17 -0
- package/lib/components/pisellDraggable/utilities.d.ts +17 -0
- package/lib/components/pisellDraggable/utilities.js +190 -0
- package/lib/components/pisellLayout/content.d.ts +1 -0
- package/lib/components/pisellLayout/content.js +9 -1
- package/lib/components/pisellMenu/PisellMenu.d.ts +5 -0
- package/lib/components/pisellMenu/PisellMenu.js +91 -0
- package/lib/components/pisellMenu/PisellMenu.less +53 -0
- package/lib/components/pisellMenu/index.d.ts +3 -0
- package/lib/components/pisellMenu/index.js +36 -0
- package/lib/components/pisellMenu/types.d.ts +30 -0
- package/lib/components/pisellMenu/types.js +17 -0
- package/lib/components/pisellModal/components/functions/index.less +3 -0
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/versionModal/index.d.ts +15 -0
- package/lib/components/versionModal/index.js +219 -0
- package/lib/components/versionModal/index.less +3 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +12 -0
- package/lib/locales/en-US.d.ts +22 -0
- package/lib/locales/en-US.js +24 -1
- package/lib/locales/zh-CN.d.ts +21 -0
- package/lib/locales/zh-CN.js +24 -2
- package/lib/locales/zh-TW.d.ts +20 -0
- package/lib/locales/zh-TW.js +23 -2
- package/lowcode/_utils/defaultSchema.ts +23 -2
- package/lowcode/button/meta.ts +4 -20
- package/lowcode/data-source-form/meta.ts +138 -1
- package/lowcode/data-source-form/snippets.ts +54 -0
- package/lowcode/data-source-menu/meta.ts +122 -0
- package/lowcode/data-source-table/meta.ts +32 -27
- package/lowcode/data-source-table/utils.tsx +33 -1
- package/lowcode/data-source-wrapper/meta.ts +6 -2
- package/lowcode/form-group/meta.ts +5 -1
- package/lowcode/form-item-input.mobile/__screenshots__/mobile.png +0 -0
- package/lowcode/form-item-input.mobile/meta.ts +36 -46
- package/lowcode/form-item-input.mobile/snippets.ts +8 -2
- package/lowcode/form-item-input.phone/meta.ts +8 -42
- package/lowcode/form-item-input.phone/snippets.ts +6 -0
- package/lowcode/form-item-input.subdomain/__screenshots__/subdomain.png +0 -0
- package/lowcode/form-item-input.subdomain/meta.ts +20 -6
- package/lowcode/form-item-input.subdomain/snippets.ts +10 -11
- package/lowcode/form.item/meta.ts +48 -0
- package/lowcode/pisell-content/meta.ts +12 -9
- package/lowcode/pisell-draggable/meta.ts +190 -0
- package/lowcode/pisell-layout/meta.ts +9 -9
- package/lowcode/pisell-menu/meta.ts +112 -0
- package/package.json +1 -1
- package/lowcode/form-item-input.mobile/__screenshots__/phone.png +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M8 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.707 4.293a1 1 0 0 1 0 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l5.293 5.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L16.586 13H5a1 1 0 1 1 0-2h11.586l-5.293-5.293a1 1 0 0 1 0-1.414Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 6a1 1 0 0 1 1-1h18a1 1 0 1 1 0 2H3a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H9a1 1 0 0 1-1-1Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11.258-3.976a2 2 0 0 0-2.225 1.308 1 1 0 1 1-1.886-.664 4 4 0 0 1 7.773 1.333c0 1.53-1.135 2.54-1.945 3.081a8.044 8.044 0 0 1-1.686.848l-.035.013-.011.003-.004.002h-.002L11.92 13l.316.949a1 1 0 0 1-.633-1.897l.016-.006.074-.027a6.051 6.051 0 0 0 1.172-.6c.69-.46 1.055-.95 1.055-1.419v-.001a2 2 0 0 0-1.662-1.975ZM11 17a1 1 0 0 1 1-1h.01a1 1 0 1 1 0 2H12a1 1 0 0 1-1-1Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.293 3.293a1 1 0 0 1 1.414 0l4 4a1 1 0 0 1-1.414 1.414L8 6.414V20a1 1 0 1 1-2 0V6.414L3.707 8.707a1 1 0 0 1-1.414-1.414l4-4ZM16 17.586V4a1 1 0 1 1 2 0v13.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 1.414-1.414L16 17.586Z"/></svg>
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["title", "description", "dataSource", "showTitle", "showDescription", "groupInfoPosition", "variables", "renderMode", "children", "currentValue", "className", "onDataSourceFinish", "formatSubmitValues", "formatInitialValues", "customSubmit", "leaveConfirmConfig"];
|
|
2
3
|
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); }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
7
|
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
8
|
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; }
|
|
5
9
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
6
10
|
import classNames from 'classnames';
|
|
11
|
+
import { useMemoizedFn } from 'ahooks';
|
|
12
|
+
import PisellModal from "../../pisellModal";
|
|
13
|
+
import useCtxActions from "../hooks/useCtxActions";
|
|
7
14
|
import useDataSource from "../hooks/useDataSource";
|
|
15
|
+
import useEngineContext from "../../../hooks/useEngineContext";
|
|
8
16
|
import Form from "../../form";
|
|
9
17
|
import FormSettingProvider from "./provider/formSetting/FormSettingProvider";
|
|
10
18
|
import PageHeader from "../../page-header";
|
|
19
|
+
import { transformFormObjToArrayWithUntouched } from "./utils";
|
|
11
20
|
import "./index.less";
|
|
12
|
-
|
|
13
21
|
/**
|
|
14
22
|
* @title: 数据源表单组件
|
|
15
23
|
* @description: 基于数据源动态生成表单,支持编辑、查看、禁用三种模式
|
|
16
24
|
*/
|
|
17
25
|
var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
|
+
var _context$appHelper;
|
|
18
27
|
var title = props.title,
|
|
19
28
|
description = props.description,
|
|
20
29
|
dataSource = props.dataSource,
|
|
@@ -30,7 +39,13 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
30
39
|
formatSubmitValues = props.formatSubmitValues,
|
|
31
40
|
formatInitialValues = props.formatInitialValues,
|
|
32
41
|
customSubmit = props.customSubmit,
|
|
42
|
+
leaveConfirmConfig = props.leaveConfirmConfig,
|
|
33
43
|
others = _objectWithoutProperties(props, _excluded);
|
|
44
|
+
var context = useEngineContext();
|
|
45
|
+
var _useCtxActions = useCtxActions(),
|
|
46
|
+
setBeforeClose = _useCtxActions.setBeforeClose;
|
|
47
|
+
var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
|
|
48
|
+
getApp = _context$appHelper$ut.getApp;
|
|
34
49
|
var formRef = useRef(null);
|
|
35
50
|
var _useDataSource = useDataSource(),
|
|
36
51
|
get = _useDataSource.get;
|
|
@@ -49,10 +64,86 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
49
64
|
get === null || get === void 0 ? void 0 : get.runAsync().then(function (res) {
|
|
50
65
|
var _formRef$current2;
|
|
51
66
|
var formattedValues = formatInitialValues ? formatInitialValues(res) : res;
|
|
52
|
-
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.
|
|
67
|
+
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.setFields(transformFormObjToArrayWithUntouched(formattedValues));
|
|
53
68
|
});
|
|
54
69
|
}
|
|
55
70
|
}, [renderMode, dataSource, formatInitialValues]);
|
|
71
|
+
|
|
72
|
+
// 检查表单是否可以关闭
|
|
73
|
+
var checkFormClose = useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
74
|
+
var _formRef$current3;
|
|
75
|
+
var isFormChanged;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
isFormChanged = (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.isFieldsTouched();
|
|
80
|
+
if (!isFormChanged) {
|
|
81
|
+
_context.next = 3;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
return _context.abrupt("return", new Promise(function (resolve) {
|
|
85
|
+
PisellModal.confirm({
|
|
86
|
+
title: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.title,
|
|
87
|
+
content: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.content,
|
|
88
|
+
okText: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.okText,
|
|
89
|
+
cancelText: leaveConfirmConfig === null || leaveConfirmConfig === void 0 ? void 0 : leaveConfirmConfig.cancelText,
|
|
90
|
+
onOk: function onOk() {
|
|
91
|
+
var _formRef$current4;
|
|
92
|
+
(_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : _formRef$current4.resetFields();
|
|
93
|
+
resolve(true);
|
|
94
|
+
},
|
|
95
|
+
onCancel: function onCancel() {
|
|
96
|
+
resolve(false);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}));
|
|
100
|
+
case 3:
|
|
101
|
+
return _context.abrupt("return", true);
|
|
102
|
+
case 4:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee);
|
|
107
|
+
})));
|
|
108
|
+
useEffect(function () {
|
|
109
|
+
if (leaveConfirmConfig !== null && leaveConfirmConfig !== void 0 && leaveConfirmConfig.enable) {
|
|
110
|
+
setBeforeClose === null || setBeforeClose === void 0 ? void 0 : setBeforeClose(checkFormClose);
|
|
111
|
+
}
|
|
112
|
+
}, [leaveConfirmConfig]);
|
|
113
|
+
useEffect(function () {
|
|
114
|
+
if (leaveConfirmConfig !== null && leaveConfirmConfig !== void 0 && leaveConfirmConfig.enable) {
|
|
115
|
+
var _getApp, _getApp$history;
|
|
116
|
+
var history = getApp === null || getApp === void 0 ? void 0 : (_getApp = getApp()) === null || _getApp === void 0 ? void 0 : (_getApp$history = _getApp.history) === null || _getApp$history === void 0 ? void 0 : _getApp$history.instance;
|
|
117
|
+
var unblock = history === null || history === void 0 ? void 0 : history.block(function (location, action) {
|
|
118
|
+
var _formRef$current5;
|
|
119
|
+
var isFormChanged = (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : _formRef$current5.isFieldsTouched();
|
|
120
|
+
if (isFormChanged) {
|
|
121
|
+
PisellModal.confirm({
|
|
122
|
+
title: leaveConfirmConfig.title,
|
|
123
|
+
content: leaveConfirmConfig.content,
|
|
124
|
+
okText: leaveConfirmConfig.okText,
|
|
125
|
+
cancelText: leaveConfirmConfig.cancelText,
|
|
126
|
+
onOk: function onOk() {
|
|
127
|
+
unblock === null || unblock === void 0 ? void 0 : unblock();
|
|
128
|
+
if (action === 'PUSH') {
|
|
129
|
+
history.push(location);
|
|
130
|
+
} else if (action === 'POP') {
|
|
131
|
+
history.go(-1);
|
|
132
|
+
} else if (action === 'REPLACE') {
|
|
133
|
+
history.replace(location);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
onCancel: function onCancel() {}
|
|
137
|
+
});
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
return function () {
|
|
143
|
+
unblock === null || unblock === void 0 ? void 0 : unblock();
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}, []);
|
|
56
147
|
return /*#__PURE__*/React.createElement(FormSettingProvider, {
|
|
57
148
|
renderMode: renderMode,
|
|
58
149
|
groupInfoPosition: groupInfoPosition,
|
|
@@ -16,7 +16,7 @@ import FormItem from "../formItem";
|
|
|
16
16
|
import useFormSetting from "../provider/hooks/useFormSetting";
|
|
17
17
|
import useCtxActions from "../../hooks/useCtxActions";
|
|
18
18
|
import useDataSource from "../../hooks/useDataSource";
|
|
19
|
-
import { filterSystemFields } from "../utils";
|
|
19
|
+
import { filterSystemFields, transformFormObjToArrayWithUntouched } from "../utils";
|
|
20
20
|
import "./index.less";
|
|
21
21
|
// 表单提交按钮
|
|
22
22
|
var SubmitButton = function SubmitButton(props) {
|
|
@@ -171,19 +171,20 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
171
171
|
afterSubmitFunc();
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
|
|
174
|
+
form.setFields(transformFormObjToArrayWithUntouched(form.getFieldsValue()));
|
|
175
|
+
_context2.next = 21;
|
|
175
176
|
break;
|
|
176
|
-
case
|
|
177
|
-
_context2.prev =
|
|
177
|
+
case 18:
|
|
178
|
+
_context2.prev = 18;
|
|
178
179
|
_context2.t0 = _context2["catch"](0);
|
|
179
180
|
PisellToast({
|
|
180
181
|
content: "".concat(_context2.t0.message)
|
|
181
182
|
});
|
|
182
|
-
case
|
|
183
|
+
case 21:
|
|
183
184
|
case "end":
|
|
184
185
|
return _context2.stop();
|
|
185
186
|
}
|
|
186
|
-
}, _callee2, null, [[0,
|
|
187
|
+
}, _callee2, null, [[0, 18]]);
|
|
187
188
|
}));
|
|
188
189
|
return function handleValideFieldsSubmit(_x3) {
|
|
189
190
|
return _ref2.apply(this, arguments);
|
|
@@ -20,4 +20,12 @@ export interface DataSourceFormProps {
|
|
|
20
20
|
formatSubmitValues?: (values: Record<string, any>) => Record<string, any>;
|
|
21
21
|
formatInitialValues?: (values: Record<string, any>) => Record<string, any>;
|
|
22
22
|
customSubmit?: (values: Record<string, any>) => Promise<any>;
|
|
23
|
+
leaveConfirmConfig?: {
|
|
24
|
+
enable: boolean;
|
|
25
|
+
title: string;
|
|
26
|
+
content: string;
|
|
27
|
+
icon: React.ReactNode;
|
|
28
|
+
okText: string;
|
|
29
|
+
cancelText: string;
|
|
30
|
+
};
|
|
23
31
|
}
|
|
@@ -50,3 +50,4 @@ export declare const getNestedValue: (obj: Record<string, any>, path: string) =>
|
|
|
50
50
|
export declare const renderValueWithMap: (value: any, valueMap?: Record<string, string>, renderMode?: ModeType) => React.JSX.Element | null;
|
|
51
51
|
export declare function toArr(str: string | number | (string | number)[]): (string | number)[];
|
|
52
52
|
export declare const filterSystemFields: (params: Record<string, any>) => Record<string, any>;
|
|
53
|
+
export declare const transformFormObjToArrayWithUntouched: (obj: Record<string, any>) => any[];
|
|
@@ -19,7 +19,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
19
19
|
import React, { useEffect, useMemo } from 'react';
|
|
20
20
|
import { isArr, isNumber, isString } from '@pisell/utils';
|
|
21
21
|
import classNames from 'classnames';
|
|
22
|
-
import { parsePhoneNumberFromString
|
|
22
|
+
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
23
23
|
import { getText } from "../../../locales";
|
|
24
24
|
import Form from "../../form";
|
|
25
25
|
import useDataSource from "../hooks/useDataSource";
|
|
@@ -132,6 +132,8 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
132
132
|
|
|
133
133
|
// 模式优先级:外部传入 mode > 全局模式
|
|
134
134
|
var effectiveMode = propsRenderMode || globalRenderMode;
|
|
135
|
+
// 如果name是字符串,并且包含.,则将name转换为数组 否则提交时会转换为对象
|
|
136
|
+
var name = isString(propsName) && propsName.includes('.') ? [propsName] : propsName;
|
|
135
137
|
var renderComponent = useMemo(function () {
|
|
136
138
|
var _overlayProps$innerPr;
|
|
137
139
|
// 使用renderMode属性,避免和组件mode冲突
|
|
@@ -140,15 +142,13 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
140
142
|
renderMode: effectiveMode
|
|
141
143
|
}, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.innerProps, {
|
|
142
144
|
style: _objectSpread(_objectSpread({}, innerStyle || {}), (overlayProps === null || overlayProps === void 0 ? void 0 : (_overlayProps$innerPr = overlayProps.innerProps) === null || _overlayProps$innerPr === void 0 ? void 0 : _overlayProps$innerPr.style) || {}),
|
|
145
|
+
fieldKey: name,
|
|
143
146
|
isVerification: typeobj === null || typeobj === void 0 ? void 0 : typeobj.enabled,
|
|
144
147
|
size: size
|
|
145
148
|
}));
|
|
146
|
-
}, [effectiveMode, otherProps, propsMode, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.innerProps, typeobj === null || typeobj === void 0 ? void 0 : typeobj.enabled, size, innerStyle]);
|
|
149
|
+
}, [effectiveMode, otherProps, propsMode, overlayProps === null || overlayProps === void 0 ? void 0 : overlayProps.innerProps, typeobj === null || typeobj === void 0 ? void 0 : typeobj.enabled, size, innerStyle, name]);
|
|
147
150
|
var isDesignMode = __designMode === 'design';
|
|
148
151
|
var isHidden = effectiveMode === 'hidden';
|
|
149
|
-
|
|
150
|
-
// 如果name是字符串,并且包含.,则将name转换为数组 否则提交时会转换为对象
|
|
151
|
-
var name = isString(propsName) && propsName.includes('.') ? [propsName] : propsName;
|
|
152
152
|
var concatName = name !== undefined ? [].concat(_toConsumableArray(prefixPath), _toConsumableArray(toArr(name))) : undefined;
|
|
153
153
|
var rules = [];
|
|
154
154
|
if (requiredobj && requiredobj.required) {
|
|
@@ -157,35 +157,107 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
157
157
|
}));
|
|
158
158
|
}
|
|
159
159
|
if (typeobj && typeobj.enabled) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
160
|
+
switch (typeobj.type) {
|
|
161
|
+
case 'email':
|
|
162
|
+
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
163
|
+
message: typeobj.message || getText('pisell-data-source-form-email-message')
|
|
164
|
+
}));
|
|
165
|
+
break;
|
|
166
|
+
case 'pattern':
|
|
167
|
+
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
168
|
+
pattern: new RegExp(typeobj.pattern),
|
|
169
|
+
message: typeobj.message || getText('pisell-data-source-form-pattern-message')
|
|
170
|
+
}));
|
|
171
|
+
break;
|
|
172
|
+
case 'phone':
|
|
173
|
+
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
174
|
+
validator: function validator(_, value) {
|
|
175
|
+
// 如果值为空或者只有空格,直接返回成功,不进行校验
|
|
176
|
+
if (!(value !== null && value !== void 0 && value.trim())) {
|
|
177
|
+
return Promise.resolve();
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
// 清理输入值,移除空格、括号等字符
|
|
181
|
+
var _cleanedNumber = value.replace(/\s|\(|\)/g, '');
|
|
182
|
+
// 使用 parsePhoneNumberFromString 验证 E.164 格式
|
|
183
|
+
var parsedNumber = parsePhoneNumberFromString(_cleanedNumber);
|
|
184
|
+
if (!(parsedNumber !== null && parsedNumber !== void 0 && parsedNumber.isValid())) {
|
|
185
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-phone-message')));
|
|
186
|
+
}
|
|
187
|
+
return Promise.resolve();
|
|
188
|
+
} catch (error) {
|
|
189
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-phone-message')));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
break;
|
|
194
|
+
case 'mobile':
|
|
195
|
+
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
196
|
+
validator: function validator(_, value) {
|
|
197
|
+
// 如果值为空或者只有空格,直接返回成功,不进行校验
|
|
198
|
+
if (!(value !== null && value !== void 0 && value.trim())) {
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
// 清理输入值,移除空格和括号等
|
|
203
|
+
var _cleanedNumber2 = value.replace(/\s|\(|\)/g, '');
|
|
204
|
+
|
|
205
|
+
// 如果超过15位,直接返回错误
|
|
206
|
+
if (_cleanedNumber2.length > 15) {
|
|
207
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-mobile-message')));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 根据号码前缀判断国家
|
|
211
|
+
if (_cleanedNumber2.startsWith('+61')) {
|
|
212
|
+
// 澳大利亚手机号规则:
|
|
213
|
+
// 1. 以04开头必须是10位数字
|
|
214
|
+
// 2. 以4开头必须是9位数字
|
|
215
|
+
var numberWithoutPrefix = _cleanedNumber2.slice(3);
|
|
216
|
+
if (!/^(?:04\d{8}|4\d{8})$/.test(numberWithoutPrefix)) {
|
|
217
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-mobile-message')));
|
|
218
|
+
}
|
|
219
|
+
} else if (_cleanedNumber2.startsWith('+86')) {
|
|
220
|
+
// 中国手机号规则
|
|
221
|
+
var _numberWithoutPrefix = _cleanedNumber2.slice(3);
|
|
222
|
+
if (!/^1[3-9]\d{9}$/.test(_numberWithoutPrefix)) {
|
|
223
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-mobile-message')));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return Promise.resolve();
|
|
227
|
+
} catch (error) {
|
|
228
|
+
// 如果解析出错,只验证长度
|
|
229
|
+
if (cleanedNumber.length > 15) {
|
|
230
|
+
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-mobile-message')));
|
|
231
|
+
}
|
|
232
|
+
return Promise.resolve();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
break;
|
|
237
|
+
case 'subdomain':
|
|
238
|
+
rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
|
|
239
|
+
validator: function validator(_, value) {
|
|
240
|
+
if (!value) return Promise.resolve();
|
|
241
|
+
var subdomain = value.split('.')[0];
|
|
242
|
+
if (!subdomain) {
|
|
243
|
+
return Promise.resolve();
|
|
244
|
+
}
|
|
245
|
+
if (!/^[a-z0-9-]+$/.test(subdomain)) {
|
|
246
|
+
return Promise.reject(new Error(getText('subdomain-error-pattern')));
|
|
247
|
+
}
|
|
248
|
+
if (/^\d+$/.test(subdomain)) {
|
|
249
|
+
return Promise.reject(new Error(getText('subdomain-error-numbers-only')));
|
|
250
|
+
}
|
|
251
|
+
if (subdomain.startsWith('-') || subdomain.endsWith('-')) {
|
|
252
|
+
return Promise.reject(new Error(getText('subdomain-error-hyphen-ends')));
|
|
253
|
+
}
|
|
254
|
+
if (subdomain.includes('--')) {
|
|
255
|
+
return Promise.reject(new Error(getText('subdomain-error-consecutive-hyphens')));
|
|
256
|
+
}
|
|
257
|
+
return Promise.resolve();
|
|
258
|
+
}
|
|
259
|
+
}));
|
|
260
|
+
break;
|
|
189
261
|
}
|
|
190
262
|
}
|
|
191
263
|
if (maxLengthobj && maxLengthobj.enabled) {
|
|
@@ -268,10 +340,8 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
268
340
|
hidden: isHidden && !isDesignMode,
|
|
269
341
|
rules: rules,
|
|
270
342
|
normalize: normalize,
|
|
271
|
-
getValueProps: getValueProps
|
|
272
|
-
|
|
273
|
-
,
|
|
274
|
-
validateTrigger: validateTrigger,
|
|
343
|
+
getValueProps: getValueProps,
|
|
344
|
+
validateTrigger: validateTrigger || ['onChange', 'onBlur'],
|
|
275
345
|
labelCol: labelCol,
|
|
276
346
|
initialValue: otherProps === null || otherProps === void 0 ? void 0 : otherProps.defaultValue,
|
|
277
347
|
className: classNames('pisell-data-source-form-item', {
|
|
@@ -385,4 +455,16 @@ export var filterSystemFields = function filterSystemFields(params) {
|
|
|
385
455
|
}
|
|
386
456
|
return acc;
|
|
387
457
|
}, {});
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
// 表单objvalue转换为数组 并且touched设置为false
|
|
461
|
+
export var transformFormObjToArrayWithUntouched = function transformFormObjToArrayWithUntouched(obj) {
|
|
462
|
+
return Object.keys(obj).reduce(function (acc, key) {
|
|
463
|
+
acc.push({
|
|
464
|
+
name: key,
|
|
465
|
+
value: obj[key],
|
|
466
|
+
touched: false
|
|
467
|
+
});
|
|
468
|
+
return acc;
|
|
469
|
+
}, []);
|
|
388
470
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import BaseMenu from "../../pisellMenu";
|
|
4
|
+
import useVariables from "../hooks/useVariables";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title: 数据源表单组件
|
|
8
|
+
* @description: 基于数据源动态生成表单,支持编辑、查看、禁用三种模式
|
|
9
|
+
*/
|
|
10
|
+
var DataSourceMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
11
|
+
var dataSource = props.dataSource;
|
|
12
|
+
var _useVariables = useVariables(),
|
|
13
|
+
parseVariable = _useVariables.parseVariable;
|
|
14
|
+
return /*#__PURE__*/React.createElement(BaseMenu, _extends({}, props, {
|
|
15
|
+
dataSource: parseVariable === null || parseVariable === void 0 ? void 0 : parseVariable(dataSource),
|
|
16
|
+
ref: ref
|
|
17
|
+
}));
|
|
18
|
+
});
|
|
19
|
+
export default DataSourceMenu;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
2
|
var _excluded = ["columns", "dataSource", "operationContent"];
|
|
2
3
|
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); }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
7
|
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
8
|
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; }
|
|
5
|
-
import React, { useEffect, useRef } from 'react';
|
|
9
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
10
|
import { useUpdateEffect } from 'ahooks';
|
|
7
11
|
import Table from "../../table";
|
|
8
12
|
import useVariables from "../hooks/useVariables";
|
|
@@ -30,6 +34,10 @@ var BaseTable = function BaseTable(props) {
|
|
|
30
34
|
var _useDataSourceKey = useDataSourceKey(),
|
|
31
35
|
dataSourceKey = _useDataSourceKey.dataSourceKey,
|
|
32
36
|
dataSourceKeyRef = _useDataSourceKey.dataSourceKeyRef;
|
|
37
|
+
var beforeClose = useRef();
|
|
38
|
+
var setBeforeClose = useCallback(function (fn) {
|
|
39
|
+
beforeClose.current = fn;
|
|
40
|
+
}, []);
|
|
33
41
|
var _useDrawerState = useDrawerState(operationContent),
|
|
34
42
|
drawerVisible = _useDrawerState.drawerVisible,
|
|
35
43
|
setDrawerVisible = _useDrawerState.setDrawerVisible,
|
|
@@ -73,12 +81,40 @@ var BaseTable = function BaseTable(props) {
|
|
|
73
81
|
}, [dataSource]);
|
|
74
82
|
|
|
75
83
|
// 关闭抽屉
|
|
76
|
-
var handleCloseDrawer = function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
var handleCloseDrawer = /*#__PURE__*/function () {
|
|
85
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
86
|
+
var canClose;
|
|
87
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
+
while (1) switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
if (!beforeClose.current) {
|
|
91
|
+
_context.next = 6;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
_context.next = 3;
|
|
95
|
+
return beforeClose.current();
|
|
96
|
+
case 3:
|
|
97
|
+
canClose = _context.sent;
|
|
98
|
+
if (canClose) {
|
|
99
|
+
_context.next = 6;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
return _context.abrupt("return");
|
|
103
|
+
case 6:
|
|
104
|
+
closeDrawer();
|
|
105
|
+
registerValueVariable === null || registerValueVariable === void 0 ? void 0 : registerValueVariable(componentId, {
|
|
106
|
+
currentRecord: null
|
|
107
|
+
});
|
|
108
|
+
case 8:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context.stop();
|
|
111
|
+
}
|
|
112
|
+
}, _callee);
|
|
113
|
+
}));
|
|
114
|
+
return function handleCloseDrawer() {
|
|
115
|
+
return _ref.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}();
|
|
82
118
|
var transformProps = useTableProps({
|
|
83
119
|
data: data,
|
|
84
120
|
originProps: props,
|
|
@@ -97,7 +133,9 @@ var BaseTable = function BaseTable(props) {
|
|
|
97
133
|
})), /*#__PURE__*/React.createElement(ActionsProvider, {
|
|
98
134
|
visible: drawerVisible,
|
|
99
135
|
setVisible: setDrawerVisible,
|
|
100
|
-
refreshTableData: refreshData
|
|
136
|
+
refreshTableData: refreshData,
|
|
137
|
+
setBeforeClose: setBeforeClose,
|
|
138
|
+
beforeClose: beforeClose.current
|
|
101
139
|
}, /*#__PURE__*/React.createElement(Container, _extends({}, containerProps, {
|
|
102
140
|
// title={DRAWER_TITLES[drawerType]}
|
|
103
141
|
open: drawerVisible,
|
|
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
|
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
19
|
declare const useTableProps: (props: UseTablePropsProps) => {
|
|
20
|
-
title: number | boolean |
|
|
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 |
|
|
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;
|
|
@@ -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" | "
|
|
68
|
+
openContentSize: "small" | "middle" | "large";
|
|
69
69
|
openTitle: string;
|
|
70
70
|
key: string;
|
|
71
71
|
} | undefined;
|
|
@@ -5,7 +5,6 @@ export interface PhoneInputProps extends Omit<InputProps, 'value' | 'onChange'>
|
|
|
5
5
|
renderMode: ModeType;
|
|
6
6
|
value?: string;
|
|
7
7
|
onChange?: (value: string) => void;
|
|
8
|
-
isVerification?: boolean;
|
|
9
8
|
}
|
|
10
9
|
declare const MobileNumberInputWithMode: React.FC<PhoneInputProps & import("../../dataSourceForm/utils").WithModeProps>;
|
|
11
10
|
export default MobileNumberInputWithMode;
|