@arim-aisdc/public-components 0.0.53 → 0.0.55

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.
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
17
17
  value: any;
18
18
  field: string;
19
19
  label?: string;
20
- text: string | Element | JSX.Element;
20
+ text: string | JSX.Element | Element;
21
21
  units?: string;
22
22
  width?: string;
23
23
  labelWidth?: string;
@@ -1,7 +0,0 @@
1
- import { FC } from 'react';
2
- export interface MicroComponentProps {
3
- name: string;
4
- componentName: string;
5
- params?: any;
6
- }
7
- export declare const MicroComponent: FC<MicroComponentProps>;
@@ -1,14 +1,20 @@
1
- import { MicroAppWithMemoHistory } from 'umi';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export var MicroComponent = function MicroComponent(_ref) {
4
- var name = _ref.name,
5
- componentName = _ref.componentName,
6
- params = _ref.params;
7
- return /*#__PURE__*/_jsx(MicroAppWithMemoHistory, {
8
- url: "/".concat(name),
9
- name: name,
10
- type: "component",
11
- componentName: componentName,
12
- params: params
13
- });
14
- };
1
+ // import { FC } from 'react';
2
+ // import { MicroAppWithMemoHistory } from 'umi';
3
+
4
+ // export interface MicroComponentProps {
5
+ // name: string;
6
+ // componentName: string;
7
+ // params?: any;
8
+ // }
9
+
10
+ // export const MicroComponent: FC<MicroComponentProps> = ({ name, componentName, params }) => {
11
+ // return (
12
+ // <MicroAppWithMemoHistory
13
+ // url={`/${name}`}
14
+ // name={name}
15
+ // type="component"
16
+ // componentName={componentName}
17
+ // params={params}
18
+ // />
19
+ // );
20
+ // };
@@ -0,0 +1,3 @@
1
+ import { ISchemaFormProps } from './type';
2
+ declare const SchemaForm: <T>({ formConfig, onFinish, layoutType, onReset, onCancel, formRef, submitText, resetText, cancelText, showButtonConfig, trigger, title, onOpenChange, requestMethod, labelLayoutType, labelCol, wrapperCol, }: ISchemaFormProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default SchemaForm;
@@ -0,0 +1,98 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import "antd/es/button/style";
3
+ import _Button from "antd/es/button";
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ import { BetaSchemaForm } from '@ant-design/pro-components';
10
+ import { FormActionEnum } from "./type";
11
+ import { transformFormSchema } from "./utils";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var SchemaForm = function SchemaForm(_ref) {
14
+ var formConfig = _ref.formConfig,
15
+ onFinish = _ref.onFinish,
16
+ _ref$layoutType = _ref.layoutType,
17
+ layoutType = _ref$layoutType === void 0 ? 'Form' : _ref$layoutType,
18
+ onReset = _ref.onReset,
19
+ onCancel = _ref.onCancel,
20
+ formRef = _ref.formRef,
21
+ _ref$submitText = _ref.submitText,
22
+ submitText = _ref$submitText === void 0 ? '确认' : _ref$submitText,
23
+ _ref$resetText = _ref.resetText,
24
+ resetText = _ref$resetText === void 0 ? '重置' : _ref$resetText,
25
+ _ref$cancelText = _ref.cancelText,
26
+ cancelText = _ref$cancelText === void 0 ? '取消' : _ref$cancelText,
27
+ _ref$showButtonConfig = _ref.showButtonConfig,
28
+ showButtonConfig = _ref$showButtonConfig === void 0 ? [FormActionEnum.submit, FormActionEnum.reset] : _ref$showButtonConfig,
29
+ trigger = _ref.trigger,
30
+ _ref$title = _ref.title,
31
+ title = _ref$title === void 0 ? '' : _ref$title,
32
+ onOpenChange = _ref.onOpenChange,
33
+ requestMethod = _ref.requestMethod,
34
+ _ref$labelLayoutType = _ref.labelLayoutType,
35
+ labelLayoutType = _ref$labelLayoutType === void 0 ? 'horizontal' : _ref$labelLayoutType,
36
+ _ref$labelCol = _ref.labelCol,
37
+ labelCol = _ref$labelCol === void 0 ? {
38
+ span: 6
39
+ } : _ref$labelCol,
40
+ _ref$wrapperCol = _ref.wrapperCol,
41
+ wrapperCol = _ref$wrapperCol === void 0 ? {
42
+ span: 18
43
+ } : _ref$wrapperCol;
44
+ var innerFormConfig = transformFormSchema(formConfig, requestMethod);
45
+ console.log('formConfig :>> ', innerFormConfig);
46
+ return /*#__PURE__*/_jsx(BetaSchemaForm, _objectSpread(_objectSpread(_objectSpread({
47
+ title: title,
48
+ trigger: trigger,
49
+ formRef: formRef,
50
+ shouldUpdate: false,
51
+ columns: innerFormConfig,
52
+ layoutType: layoutType,
53
+ layout: labelLayoutType,
54
+ labelCol: labelCol,
55
+ wrapperCol: wrapperCol,
56
+ labelAlign: "left",
57
+ scrollToFirstError: true,
58
+ onFinish: onFinish
59
+ }, layoutType === 'ModalForm' ? {
60
+ modalProps: {
61
+ destroyOnClose: true
62
+ }
63
+ } : {}), layoutType === 'DrawerForm' ? {
64
+ drawerProps: {
65
+ destroyOnClose: true
66
+ }
67
+ } : {}), {}, {
68
+ onReset: onReset,
69
+ submitter: {
70
+ // 配置按钮文本
71
+ searchConfig: {
72
+ resetText: resetText,
73
+ submitText: submitText
74
+ },
75
+ // 自定义整个区域
76
+ render: function render(props, doms) {
77
+ // console.log(props, doms);
78
+ var res = [];
79
+ if (showButtonConfig.includes(FormActionEnum.cancel)) {
80
+ res.push( /*#__PURE__*/_jsx(_Button, {
81
+ onClick: onCancel,
82
+ children: cancelText
83
+ }, "cancel"));
84
+ }
85
+ if (showButtonConfig.includes(FormActionEnum.reset)) {
86
+ res.push(doms[0]);
87
+ }
88
+ if (showButtonConfig.includes(FormActionEnum.submit)) {
89
+ res.push(doms[1]);
90
+ }
91
+ return res;
92
+ }
93
+ }
94
+ }, ['DrawerForm', 'ModalForm'].includes(layoutType) ? {
95
+ onOpenChange: onOpenChange
96
+ } : {}));
97
+ };
98
+ export default SchemaForm;
@@ -0,0 +1,4 @@
1
+ import SchemaForm from './SchemaForm';
2
+ export { DataSourceTypeEnum, FormActionEnum, ProFieldValueTypeEnum } from './type';
3
+ export type { ILayoutType, ISchemaFormProps } from './type';
4
+ export default SchemaForm;
@@ -0,0 +1,3 @@
1
+ import SchemaForm from "./SchemaForm";
2
+ export { DataSourceTypeEnum, FormActionEnum, ProFieldValueTypeEnum } from "./type";
3
+ export default SchemaForm;
@@ -0,0 +1,124 @@
1
+ /// <reference types="react" />
2
+ import { FormLayout } from 'antd/lib/form/Form';
3
+ export interface FieldDefinitionDto {
4
+ id: string;
5
+ creationTime: string;
6
+ creatorId?: string;
7
+ lastModificationTime?: string;
8
+ lastModifierId?: string;
9
+ formDefinitionId: string;
10
+ name?: string;
11
+ title?: string;
12
+ shortCode?: string;
13
+ valueType?: string;
14
+ category?: string;
15
+ defaultValue?: any;
16
+ required: boolean;
17
+ maxValue?: number;
18
+ minValue?: number;
19
+ dataSource?: string;
20
+ dataSourceType?: string;
21
+ controlType?: ProFieldValueTypeEnum;
22
+ multiple?: boolean;
23
+ remark?: string;
24
+ icon?: string;
25
+ suffix?: string;
26
+ prefix?: string;
27
+ rank: number;
28
+ hideExpression?: string;
29
+ tooltip?: string;
30
+ }
31
+ export declare enum DataSourceTypeEnum {
32
+ TEXT_VALUE = "textValue",
33
+ URL = "url",
34
+ DICT = "dict"
35
+ }
36
+ export declare enum ProFieldValueTypeEnum {
37
+ /** 文本输入框 */
38
+ text = "text",
39
+ /** 密码输入框 */
40
+ password = "password",
41
+ /** 多行文本 */
42
+ textarea = "textarea",
43
+ /** 日期选择器 */
44
+ date = "date",
45
+ /** 周选择器 */
46
+ dateWeek = "dateWeek",
47
+ /** 月选择器 */
48
+ dateMonth = "dateMonth",
49
+ /** 季度选择器 */
50
+ dateQuarter = "dateQuarter",
51
+ /** 年选择器 */
52
+ dateYear = "dateYear",
53
+ /** 日期时间选择器 */
54
+ dateTime = "dateTime",
55
+ /** 相对时间 */
56
+ /** 日期范围选择器 */
57
+ dateRange = "dateRange",
58
+ /** 日期时间范围选择器 */
59
+ dateTimeRange = "dateTimeRange",
60
+ /** 周范围选择器 */
61
+ dateWeekRange = "dateWeekRange",
62
+ /** 月范围选择器 */
63
+ dateMonthRange = "dateMonthRange",
64
+ /** 季范围选择器 */
65
+ dateQuarterRange = "dateQuarterRange",
66
+ /** 年范围选择器 */
67
+ dateYearRange = "dateYearRange",
68
+ /** 时间选择器 */
69
+ time = "time",
70
+ /** 时间范围选择器 */
71
+ timeRange = "timeRange",
72
+ /** 下拉选择器 */
73
+ select = "select",
74
+ /** 复选框 */
75
+ checkbox = "checkbox",
76
+ /** 评分 */
77
+ rate = "rate",
78
+ /** 滑动条 */
79
+ slider = "slider",
80
+ /** 单选框 */
81
+ radio = "radio",
82
+ /** 单选框按钮 */
83
+ radioButton = "radioButton",
84
+ /** 进度条 */
85
+ /** 数字输入框 */
86
+ digit = "digit",
87
+ /** 数字范围输入框 */
88
+ digitRange = "digitRange",
89
+ /** 开关 */
90
+ switch = "switch",
91
+ /** 级联选择 */
92
+ /** 树形选择 */
93
+ /** 颜色选择器 */
94
+ color = "color"
95
+ }
96
+ export declare enum FormActionEnum {
97
+ submit = "submit",
98
+ reset = "reset",
99
+ cancel = "cancel"
100
+ }
101
+ export type ILayoutType = 'Form' | 'DrawerForm' | 'ModalForm' | 'QueryFilter' | 'LightFilter';
102
+ export type ISchemaFormProps<T = FieldDefinitionDto> = {
103
+ formConfig: (FieldDefinitionDto & T)[];
104
+ onFinish?: (values: any) => Promise<boolean | void>;
105
+ onReset?: (e: any) => void;
106
+ onCancel?: (e: any) => void;
107
+ layoutType?: ILayoutType;
108
+ labelLayoutType?: FormLayout;
109
+ formRef?: any;
110
+ submitText?: string;
111
+ resetText?: string;
112
+ cancelText?: string;
113
+ showButtonConfig?: FormActionEnum[];
114
+ trigger?: JSX.Element;
115
+ title?: string;
116
+ onOpenChange?: (visible: boolean) => void;
117
+ requestMethod?: () => Promise<any>;
118
+ labelCol?: {
119
+ span: number;
120
+ };
121
+ wrapperCol?: {
122
+ span: number;
123
+ };
124
+ };
@@ -0,0 +1,49 @@
1
+ // 数据源类型
2
+ export var DataSourceTypeEnum = /*#__PURE__*/function (DataSourceTypeEnum) {
3
+ DataSourceTypeEnum["TEXT_VALUE"] = "textValue";
4
+ DataSourceTypeEnum["URL"] = "url";
5
+ DataSourceTypeEnum["DICT"] = "dict";
6
+ return DataSourceTypeEnum;
7
+ }({});
8
+
9
+ // 表单项组件类型
10
+ export var ProFieldValueTypeEnum = /*#__PURE__*/function (ProFieldValueTypeEnum) {
11
+ ProFieldValueTypeEnum["text"] = "text";
12
+ ProFieldValueTypeEnum["password"] = "password";
13
+ ProFieldValueTypeEnum["textarea"] = "textarea";
14
+ ProFieldValueTypeEnum["date"] = "date";
15
+ ProFieldValueTypeEnum["dateWeek"] = "dateWeek";
16
+ ProFieldValueTypeEnum["dateMonth"] = "dateMonth";
17
+ ProFieldValueTypeEnum["dateQuarter"] = "dateQuarter";
18
+ ProFieldValueTypeEnum["dateYear"] = "dateYear";
19
+ ProFieldValueTypeEnum["dateTime"] = "dateTime";
20
+ ProFieldValueTypeEnum["dateRange"] = "dateRange";
21
+ ProFieldValueTypeEnum["dateTimeRange"] = "dateTimeRange";
22
+ ProFieldValueTypeEnum["dateWeekRange"] = "dateWeekRange";
23
+ ProFieldValueTypeEnum["dateMonthRange"] = "dateMonthRange";
24
+ ProFieldValueTypeEnum["dateQuarterRange"] = "dateQuarterRange";
25
+ ProFieldValueTypeEnum["dateYearRange"] = "dateYearRange";
26
+ ProFieldValueTypeEnum["time"] = "time";
27
+ ProFieldValueTypeEnum["timeRange"] = "timeRange";
28
+ ProFieldValueTypeEnum["select"] = "select";
29
+ ProFieldValueTypeEnum["checkbox"] = "checkbox";
30
+ ProFieldValueTypeEnum["rate"] = "rate";
31
+ ProFieldValueTypeEnum["slider"] = "slider";
32
+ ProFieldValueTypeEnum["radio"] = "radio";
33
+ ProFieldValueTypeEnum["radioButton"] = "radioButton";
34
+ ProFieldValueTypeEnum["digit"] = "digit";
35
+ ProFieldValueTypeEnum["digitRange"] = "digitRange";
36
+ ProFieldValueTypeEnum["switch"] = "switch";
37
+ ProFieldValueTypeEnum["color"] = "color";
38
+ return ProFieldValueTypeEnum;
39
+ }({});
40
+ /** 分割线 */
41
+ // divider = 'divider',
42
+
43
+ // 表单动作类型枚举
44
+ export var FormActionEnum = /*#__PURE__*/function (FormActionEnum) {
45
+ FormActionEnum["submit"] = "submit";
46
+ FormActionEnum["reset"] = "reset";
47
+ FormActionEnum["cancel"] = "cancel";
48
+ return FormActionEnum;
49
+ }({});
@@ -0,0 +1,4 @@
1
+ import { ProFormColumnsType } from '@ant-design/pro-components';
2
+ import { FieldDefinitionDto } from './type';
3
+ export declare const getVariablesFromExpression: (expression: string) => any[];
4
+ export declare const transformFormSchema: <T = FieldDefinitionDto>(originFormSchema: (FieldDefinitionDto & T)[], requestMethod: () => Promise<any>) => ProFormColumnsType[];
@@ -0,0 +1,206 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
3
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
4
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ 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); } }
18
+ 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); }); }; }
19
+ import { getValueByPath } from "../../utils";
20
+ import request from "../../utils/request";
21
+ import jsep from 'jsep';
22
+ import moment from 'moment';
23
+ import { DataSourceTypeEnum, ProFieldValueTypeEnum } from "./type";
24
+ // 从表达式中获取有哪些变量
25
+ export var getVariablesFromExpression = function getVariablesFromExpression(expression) {
26
+ var parsed = {};
27
+ try {
28
+ parsed = jsep(expression);
29
+ } catch (error) {}
30
+ // console.log('parsed :>> ', parsed);
31
+
32
+ function extractVariables(node) {
33
+ var variables = [];
34
+ if (node.type === 'BinaryExpression') {
35
+ variables = variables.concat(extractVariables(node.left));
36
+ variables = variables.concat(extractVariables(node.right));
37
+ } else if (node.type === 'Identifier') {
38
+ variables.push(node.name);
39
+ }
40
+ return variables;
41
+ }
42
+ var variables = Array.from(new Set(extractVariables(parsed)));
43
+ return variables;
44
+ };
45
+
46
+ // 可以展示前缀、后缀的组件
47
+ var showAddonCom = [ProFieldValueTypeEnum.text, ProFieldValueTypeEnum.digit, ProFieldValueTypeEnum.digitRange];
48
+
49
+ // 格式化默认值
50
+ var formatDefaultValue = function formatDefaultValue(originFormItemSchema) {
51
+ var defaultValue = originFormItemSchema.defaultValue,
52
+ controlType = originFormItemSchema.controlType,
53
+ multiple = originFormItemSchema.multiple;
54
+ if (defaultValue) {
55
+ if ([ProFieldValueTypeEnum.digit, ProFieldValueTypeEnum.rate, ProFieldValueTypeEnum.slider].includes(controlType)) {
56
+ return Number(defaultValue);
57
+ } else if (controlType === ProFieldValueTypeEnum.digitRange || controlType === ProFieldValueTypeEnum.select && multiple || controlType === ProFieldValueTypeEnum.checkbox) {
58
+ // '[1,2]',字符串数组格式的值
59
+ return typeof defaultValue === 'string' ? JSON.parse(defaultValue) : defaultValue;
60
+ } else if (controlType === ProFieldValueTypeEnum.switch) {
61
+ return typeof defaultValue === 'boolean' ? defaultValue : defaultValue === 'true';
62
+ } else if ([ProFieldValueTypeEnum.date, ProFieldValueTypeEnum.time, ProFieldValueTypeEnum.dateTime, ProFieldValueTypeEnum.dateWeek, ProFieldValueTypeEnum.dateMonth, ProFieldValueTypeEnum.dateQuarter, ProFieldValueTypeEnum.dateYear].includes(controlType)) {
63
+ return moment(defaultValue);
64
+ } else if ([ProFieldValueTypeEnum.dateRange, ProFieldValueTypeEnum.timeRange, ProFieldValueTypeEnum.dateTimeRange, ProFieldValueTypeEnum.dateWeekRange, ProFieldValueTypeEnum.dateMonthRange, ProFieldValueTypeEnum.dateQuarterRange, ProFieldValueTypeEnum.dateYearRange].includes(controlType)) {
65
+ var array = typeof defaultValue === 'string' ? JSON.parse(defaultValue) : defaultValue;
66
+ return [array[0] ? moment(array[0]) : moment(), array[1] ? moment(array[1]) : moment()];
67
+ }
68
+ return defaultValue;
69
+ }
70
+ };
71
+ var transformFormItemSchema = function transformFormItemSchema(originFormItemSchema, requestMethod) {
72
+ var formItemSchema = {
73
+ key: originFormItemSchema.id,
74
+ dataIndex: originFormItemSchema.name,
75
+ title: originFormItemSchema.title,
76
+ order: 0 - originFormItemSchema.rank,
77
+ valueType: originFormItemSchema.controlType in ProFieldValueTypeEnum ? originFormItemSchema.controlType : 'text',
78
+ initialValue: formatDefaultValue(originFormItemSchema),
79
+ tooltip: originFormItemSchema.tooltip,
80
+ fieldProps: {
81
+ // placeholder: `请输入${originFormItemSchema.title}`,
82
+ addonBefore: showAddonCom.includes(originFormItemSchema.controlType) ? originFormItemSchema.prefix : undefined,
83
+ addonAfter: showAddonCom.includes(originFormItemSchema.controlType) ? originFormItemSchema.suffix : undefined,
84
+ mode: originFormItemSchema.controlType === ProFieldValueTypeEnum.select && !!originFormItemSchema.multiple ? 'multiple' : undefined,
85
+ showSearch: originFormItemSchema.controlType === ProFieldValueTypeEnum.select ? true : undefined
86
+ },
87
+ formItemProps: {
88
+ rules: [{
89
+ required: originFormItemSchema.required,
90
+ message: originFormItemSchema.required ? '此项为必填项' : ''
91
+ }],
92
+ colon: true
93
+ }
94
+ };
95
+
96
+ // select/radio/checkbox 可配置数据源 + 远程搜索
97
+ if ([ProFieldValueTypeEnum.select, ProFieldValueTypeEnum.radio, ProFieldValueTypeEnum.checkbox, ProFieldValueTypeEnum.radioButton].includes(originFormItemSchema.controlType)) {
98
+ var dataSourceType = originFormItemSchema.dataSourceType,
99
+ dataSource = originFormItemSchema.dataSource;
100
+ if (dataSourceType === DataSourceTypeEnum.TEXT_VALUE) {
101
+ var data = dataSource ? JSON.parse(dataSource) : [];
102
+ var valueEnum = {};
103
+ data.forEach(function (item) {
104
+ var text = item.text,
105
+ value = item.value;
106
+ valueEnum[value] = text;
107
+ });
108
+ formItemSchema.valueEnum = valueEnum;
109
+ } else if (dataSourceType === DataSourceTypeEnum.URL) {
110
+ var _ref = dataSource ? JSON.parse(dataSource) : {},
111
+ _ref$url = _ref.url,
112
+ url = _ref$url === void 0 ? '' : _ref$url,
113
+ _ref$method = _ref.method,
114
+ method = _ref$method === void 0 ? 'get' : _ref$method,
115
+ _ref$params = _ref.params,
116
+ params = _ref$params === void 0 ? {} : _ref$params,
117
+ _ref$dynamicParams = _ref.dynamicParams,
118
+ dynamicParams = _ref$dynamicParams === void 0 ? [] : _ref$dynamicParams,
119
+ _ref$path = _ref.path,
120
+ path = _ref$path === void 0 ? '' : _ref$path,
121
+ _ref$textField = _ref.textField,
122
+ textField = _ref$textField === void 0 ? '' : _ref$textField,
123
+ _ref$valueField = _ref.valueField,
124
+ valueField = _ref$valueField === void 0 ? '' : _ref$valueField;
125
+ formItemSchema.request = /*#__PURE__*/function () {
126
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchParams) {
127
+ var resRequest, data, optionData, options;
128
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
129
+ while (1) switch (_context.prev = _context.next) {
130
+ case 0:
131
+ // console.log('searchParams :>> ', searchParams);
132
+ resRequest = requestMethod !== null && requestMethod !== void 0 ? requestMethod : request;
133
+ _context.next = 3;
134
+ return resRequest(url, {
135
+ method: method,
136
+ data: _objectSpread(_objectSpread(_objectSpread({}, params), searchParams), {}, {
137
+ key: searchParams.keyWords
138
+ })
139
+ });
140
+ case 3:
141
+ data = _context.sent;
142
+ // console.log('data :>> ', data);
143
+ optionData = getValueByPath(data, path);
144
+ options = optionData.map(function (item) {
145
+ if (typeof item === 'string' || typeof item === 'number') {
146
+ return {
147
+ label: item,
148
+ value: item
149
+ };
150
+ }
151
+ return {
152
+ label: textField ? item[textField] : item,
153
+ value: valueField ? item[valueField] : item
154
+ };
155
+ }); // console.log('options :>> ', options);
156
+ return _context.abrupt("return", options);
157
+ case 7:
158
+ case "end":
159
+ return _context.stop();
160
+ }
161
+ }, _callee);
162
+ }));
163
+ return function (_x) {
164
+ return _ref2.apply(this, arguments);
165
+ };
166
+ }();
167
+ formItemSchema.debounceTime = 300;
168
+ if (Array.isArray(dynamicParams) && dynamicParams.length) {
169
+ formItemSchema.dependencies = dynamicParams;
170
+ }
171
+ }
172
+ }
173
+
174
+ // 联动
175
+ if (originFormItemSchema.hideExpression) {
176
+ var dependencies = getVariablesFromExpression(originFormItemSchema.hideExpression);
177
+ return {
178
+ valueType: 'dependency',
179
+ name: dependencies,
180
+ columns: function columns(formValue) {
181
+ var func = _construct(Function, _toConsumableArray(Object.keys(formValue)).concat(["return ".concat(originFormItemSchema.hideExpression)]));
182
+ var result = true;
183
+ try {
184
+ result = func.apply(void 0, _toConsumableArray(Object.values(formValue)));
185
+ } catch (error) {
186
+ result = true;
187
+ }
188
+ return result ? [] : [_objectSpread({}, formItemSchema)];
189
+ },
190
+ order: formItemSchema.order
191
+ };
192
+ }
193
+
194
+ // console.log('formItemSchema :>> ', originFormItemSchema.controlType, formItemSchema);
195
+ return formItemSchema;
196
+ };
197
+
198
+ // 转化schema
199
+ export var transformFormSchema = function transformFormSchema(originFormSchema, requestMethod) {
200
+ var formSchema = [];
201
+ originFormSchema.forEach(function (originFormItemSchema) {
202
+ var formItemConfig = transformFormItemSchema(originFormItemSchema, requestMethod);
203
+ formSchema.push(formItemConfig);
204
+ });
205
+ return formSchema;
206
+ };
@@ -3,13 +3,13 @@ import { BuiltInFilterFn, Column } from '@tanstack/react-table';
3
3
  import customFilterFns from './customFilterFns';
4
4
  export declare const defaultDateFormat = "YYYY-MM-DD";
5
5
  export declare enum FilterType {
6
- Date = "date",
7
- SingleDate = "singleDate",
8
- Integer = "integer",
9
- SingleInteger = "singleInteger",
10
- SingleSelect = "singleSelect",
11
- MultiSelect = "multiSelect",
12
- AutoComplete = "autoComplete",
6
+ Date = "date",// 日期范围筛选
7
+ SingleDate = "singleDate",// 单日期筛选
8
+ Integer = "integer",// 数字范围筛选
9
+ SingleInteger = "singleInteger",// 数字筛选
10
+ SingleSelect = "singleSelect",// 单选
11
+ MultiSelect = "multiSelect",// 多选
12
+ AutoComplete = "autoComplete",// 自动补全
13
13
  Input = "input"
14
14
  }
15
15
  export type FilterFnType = keyof typeof customFilterFns | BuiltInFilterFn | undefined;
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export { default as SplitPane } from './components/SplitPane';
23
23
  export * from './components/TableMax';
24
24
  export { default as TableMax } from './components/TableMax';
25
25
  export * from './components/ConfigProvider';
26
+ export { default as SchemaForm } from './components/SchemaForm';
26
27
  export * from './hooks/useEventBus';
27
28
  export { default as useEventBus } from './hooks/useEventBus';
28
29
  export { default as usePageCacheState } from './hooks/usePageCacheState';
29
- export * from './components/MicroComponent';
package/dist/index.js CHANGED
@@ -24,9 +24,9 @@ export { default as SplitPane } from "./components/SplitPane";
24
24
  export * from "./components/TableMax";
25
25
  export { default as TableMax } from "./components/TableMax";
26
26
  export * from "./components/ConfigProvider";
27
+ export { default as SchemaForm } from "./components/SchemaForm";
27
28
 
28
29
  // hooks
29
30
  export * from "./hooks/useEventBus";
30
31
  export { default as useEventBus } from "./hooks/useEventBus";
31
- export { default as usePageCacheState } from "./hooks/usePageCacheState";
32
- export * from "./components/MicroComponent";
32
+ export { default as usePageCacheState } from "./hooks/usePageCacheState";
@@ -1,3 +1,4 @@
1
1
  export declare function getTextWidth(text: string, fontSize: number): any;
2
2
  export declare function to<T, U = Error>(promise: Promise<T>): Promise<[U | null, T | null]>;
3
3
  export declare const judgeHasPermission: (arr1: string[], arr2: string[]) => boolean;
4
+ export declare function getValueByPath(obj: any, path: any): any;
@@ -20,4 +20,14 @@ export var judgeHasPermission = function judgeHasPermission(arr1, arr2) {
20
20
  });
21
21
  if (tempArr.length === len) return true;
22
22
  return false;
23
- };
23
+ };
24
+ export function getValueByPath(obj, path) {
25
+ if (!path) {
26
+ return obj;
27
+ }
28
+ var pathArray = path.split('.');
29
+ var data = pathArray.reduce(function (acc, key) {
30
+ return acc && acc[key] ? acc[key] : undefined;
31
+ }, obj);
32
+ return data || [];
33
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @en-US https://github.com/umijs/umi-request/blob/master/README_zh-CN.md
3
+ * @zh-CN 配置request请求时的默认参数
4
+ */
5
+ declare const request: import("umi-request").RequestMethod<false>;
6
+ export default request;
@@ -0,0 +1,75 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import "antd/es/message/style";
3
+ import _message from "antd/es/message";
4
+ import "antd/es/modal/style";
5
+ import _Modal from "antd/es/modal";
6
+ /** Request 网络请求工具 更详细的 api 文档: https://github.com/umijs/umi-request */
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
11
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ import { extend } from 'umi-request';
13
+ var codeMessage = {
14
+ 200: '服务器成功返回请求的数据。',
15
+ 201: '新建或修改数据成功。',
16
+ 202: '一个请求已经进入后台排队(异步任务)。',
17
+ 204: '删除数据成功。',
18
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
19
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
20
+ 403: '用户得到授权,但是访问是被禁止的。',
21
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
22
+ 406: '请求的格式不可得。',
23
+ 410: '请求的资源被永久删除,且不会再得到的。',
24
+ 422: '当创建一个对象时,发生一个验证错误。',
25
+ 500: '服务器发生错误,请检查服务器。',
26
+ 502: '网关错误。',
27
+ 503: '服务不可用,服务器暂时过载或维护。',
28
+ 504: '网关超时。'
29
+ };
30
+
31
+ /**
32
+ * @zh-CN 异常处理程序
33
+ * @en-US Exception handler
34
+ */
35
+ var errorHandler = function errorHandler(error) {
36
+ var response = error.response,
37
+ data = error.data;
38
+ _Modal.destroyAll();
39
+ _message.destroy();
40
+ if (response && response.status) {
41
+ var _data$error;
42
+ var errorText = (data === null || data === void 0 || (_data$error = data.error) === null || _data$error === void 0 ? void 0 : _data$error.message) || (data === null || data === void 0 ? void 0 : data.error_description) || response.statusText || codeMessage[response.status];
43
+ console.log(errorText);
44
+ }
45
+ };
46
+ var authHeaderInterceptor = function authHeaderInterceptor(url, options) {
47
+ var token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjhEMzJDQUE3MzUwRkI5NEJCRjcxOTU3MDAxMUM0Q0E0M0NGMkYwOTQiLCJ4NXQiOiJqVExLcHpVUHVVdV9jWlZ3QVJ4TXBEenk4SlEiLCJ0eXAiOiJhdCtqd3QifQ.eyJzdWIiOiI2NjY2MTAzYS0wZDBiLTQ0OTYtYmNkYy0wM2EwYjdmZGQ1M2QiLCJ1bmlxdWVfbmFtZSI6ImFkbWluIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4iLCJyb2xlIjoiYWRtaW4iLCJlbWFpbCI6ImFkbWluQGFicC5pbyIsImVtYWlsX3ZlcmlmaWVkIjoiRmFsc2UiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOiJGYWxzZSIsIm9pX3Byc3QiOiJPZHNfV2ViIiwiY2xpZW50X2lkIjoiT2RzX1dlYiIsIm9pX3Rrbl9pZCI6IjBmMmExMTNhLTRmNjMtMjRiNS1iZGUwLWRhM2M2MDI1NzcwOCIsImF1ZCI6WyJJZGVudGl0eSIsIk9kcyJdLCJzY29wZSI6InByb2ZpbGUgT2RzIElkZW50aXR5IiwianRpIjoiODA5MTQyODgtZDQzNy00YWFkLWFhYWQtZWU1ODMzOTMwNTc3IiwiaXNzIjoiaHR0cDovLzE5Mi4xNjguMTUxLjE5MDozMDAwMC8iLCJleHAiOjE3NDEzMzM3MDYsImlhdCI6MTcwOTc5NzcwNn0.RFZW3I5QRgHx3sRPmkcOic_9CHgr9YufHXFWNtuRhz-3ngLBdXO0IO6EyniRVfeV2eUokayb1mVbViHwWfmiLDujtD39XVVtSbfq6uIaBtaYnGm2Mw9iFNCILJCQ6_vrI2QD4NefQpkCraXVaOAYmydA_s2-2jcOJfCC9QD1QwA0p43Xa6BV2QR6dXa5DkxexOhykj3DuVlq7Di4bIM-nzfJm3r31B0v4_Ju1jSH64OZWbKzWa4zXPiJRuh0rGQvmTAkn3NvI8Jf68lxEcRJiDv9bxPbAOjaAkL4bZkhoCDcAh7n9kQRKQ_cQf0e-fWDE87la9C5VbPEbmqZpMXNTw';
48
+ var authHeader = {
49
+ Authorization: "Bearer ".concat(token)
50
+ };
51
+ // const authHeader = { Authorization: `Bearer ${getAccessToken()}` };
52
+
53
+ return {
54
+ url: url,
55
+ options: _objectSpread(_objectSpread({}, options), {}, {
56
+ // prefix,
57
+ interceptors: true,
58
+ headers: authHeader
59
+ })
60
+ };
61
+ };
62
+
63
+ /**
64
+ * @en-US https://github.com/umijs/umi-request/blob/master/README_zh-CN.md
65
+ * @zh-CN 配置request请求时的默认参数
66
+ */
67
+
68
+ var request = extend({
69
+ // prefix: BaseUrl,
70
+ timeoutMessage: '接口请求超时',
71
+ timeout: 21000,
72
+ errorHandler: errorHandler
73
+ });
74
+ request.interceptors.request.use(authHeaderInterceptor);
75
+ export default request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -47,15 +47,16 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^4.7.0",
50
+ "@ant-design/pro-components": "2.6.51",
50
51
  "@tanstack/match-sorter-utils": "^8.8.4",
51
52
  "@tanstack/react-table": "^8.9.1",
52
53
  "ahooks": "^3.7.8",
53
- "antd": "^4.22.3",
54
+ "antd": "^4.24.15",
54
55
  "css-vars-ponyfill": "^2.4.8",
55
56
  "fs": "^0.0.1-security",
56
57
  "immer": "^10.0.3",
58
+ "jsep": "^1.3.8",
57
59
  "lodash": "^4.17.21",
58
- "moment": ">=2.29.4",
59
60
  "path": "^0.12.7",
60
61
  "react-dnd": "^16.0.1",
61
62
  "react-dnd-html5-backend": "^16.0.1",
@@ -78,6 +79,7 @@
78
79
  "less-loader": "^11.1.0",
79
80
  "less-vars-to-js": "^1.3.0",
80
81
  "lint-staged": "^13.0.3",
82
+ "mockjs": "^1.1.0",
81
83
  "prettier": "^2.7.1",
82
84
  "prettier-plugin-organize-imports": "^3.0.0",
83
85
  "prettier-plugin-packagejson": "^2.2.18",
@@ -87,8 +89,7 @@
87
89
  "moment": ">=2.29.4",
88
90
  "react": ">=17.0.1",
89
91
  "react-dom": ">=17.0.1",
90
- "umi": "^4.1.2",
91
- "@umijs/plugins": "^4.1.5"
92
+ "umi-request": "^1.4.0"
92
93
  },
93
94
  "publishConfig": {
94
95
  "access": "public"
@@ -96,4 +97,4 @@
96
97
  "authors": [
97
98
  "na.xu2278@foxmail.com"
98
99
  ]
99
- }
100
+ }