form-render-v3 3.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +126 -0
- package/es/derivative/SearchForm/ActionView.d.ts +3 -0
- package/es/derivative/SearchForm/ActionView.js +72 -0
- package/es/derivative/SearchForm/index.css +31 -0
- package/es/derivative/SearchForm/index.d.ts +5 -0
- package/es/derivative/SearchForm/index.js +294 -0
- package/es/derivative/SlimRender/index.d.ts +3 -0
- package/es/derivative/SlimRender/index.js +6 -0
- package/es/form-core/connectForm.d.ts +3 -0
- package/es/form-core/connectForm.js +12 -0
- package/es/form-core/index.css +19 -0
- package/es/form-core/index.d.ts +5 -0
- package/es/form-core/index.js +305 -0
- package/es/index.d.ts +10 -0
- package/es/index.js +10 -0
- package/es/locales/en_US.d.ts +28 -0
- package/es/locales/en_US.js +27 -0
- package/es/locales/index.d.ts +57 -0
- package/es/locales/index.js +6 -0
- package/es/locales/zh_CN.d.ts +28 -0
- package/es/locales/zh_CN.js +27 -0
- package/es/models/bindValues.d.ts +2 -0
- package/es/models/bindValues.js +172 -0
- package/es/models/context.d.ts +3 -0
- package/es/models/context.js +3 -0
- package/es/models/expression.d.ts +7 -0
- package/es/models/expression.js +135 -0
- package/es/models/fieldShouldUpdate.d.ts +2 -0
- package/es/models/fieldShouldUpdate.js +70 -0
- package/es/models/filterValuesHidden.d.ts +5 -0
- package/es/models/filterValuesHidden.js +61 -0
- package/es/models/filterValuesUndefined.d.ts +2 -0
- package/es/models/filterValuesUndefined.js +47 -0
- package/es/models/flattenSchema.d.ts +3 -0
- package/es/models/flattenSchema.js +91 -0
- package/es/models/formCoreUtils.d.ts +8 -0
- package/es/models/formCoreUtils.js +190 -0
- package/es/models/formDataSkeleton.d.ts +1 -0
- package/es/models/formDataSkeleton.js +31 -0
- package/es/models/layout.d.ts +4 -0
- package/es/models/layout.js +88 -0
- package/es/models/mapping.d.ts +89 -0
- package/es/models/mapping.js +119 -0
- package/es/models/sortProperties.d.ts +2 -0
- package/es/models/sortProperties.js +41 -0
- package/es/models/store.d.ts +10 -0
- package/es/models/store.js +22 -0
- package/es/models/transformProps.d.ts +34 -0
- package/es/models/transformProps.js +80 -0
- package/es/models/useForm.d.ts +3 -0
- package/es/models/useForm.js +322 -0
- package/es/models/validateMessage.d.ts +93 -0
- package/es/models/validateMessage.js +95 -0
- package/es/models/validates.d.ts +3 -0
- package/es/models/validates.js +201 -0
- package/es/render-core/FieldItem/field.d.ts +3 -0
- package/es/render-core/FieldItem/field.js +81 -0
- package/es/render-core/FieldItem/index.d.ts +3 -0
- package/es/render-core/FieldItem/index.js +54 -0
- package/es/render-core/FieldItem/main.d.ts +3 -0
- package/es/render-core/FieldItem/main.js +228 -0
- package/es/render-core/FieldItem/module.d.ts +18 -0
- package/es/render-core/FieldItem/module.js +337 -0
- package/es/render-core/FieldList/field.d.ts +3 -0
- package/es/render-core/FieldList/field.js +300 -0
- package/es/render-core/FieldList/index.d.ts +3 -0
- package/es/render-core/FieldList/index.js +44 -0
- package/es/render-core/FieldList/main.d.ts +3 -0
- package/es/render-core/FieldList/main.js +99 -0
- package/es/render-core/FieldList/modules.d.ts +7 -0
- package/es/render-core/FieldList/modules.js +108 -0
- package/es/render-core/index.css +29 -0
- package/es/render-core/index.d.ts +9 -0
- package/es/render-core/index.js +85 -0
- package/es/type.d.ts +405 -0
- package/es/type.js +1 -0
- package/es/utils/index.d.ts +75 -0
- package/es/utils/index.js +120 -0
- package/es/widgets/ErrorSchema/index.d.ts +3 -0
- package/es/widgets/ErrorSchema/index.js +14 -0
- package/es/widgets/boxCollapse/index.css +53 -0
- package/es/widgets/boxCollapse/index.d.ts +18 -0
- package/es/widgets/boxCollapse/index.js +70 -0
- package/es/widgets/boxLineTitle/index.css +18 -0
- package/es/widgets/boxLineTitle/index.d.ts +8 -0
- package/es/widgets/boxLineTitle/index.js +23 -0
- package/es/widgets/boxSubInline/index.css +11 -0
- package/es/widgets/boxSubInline/index.d.ts +4 -0
- package/es/widgets/boxSubInline/index.js +56 -0
- package/es/widgets/boxcard/index.css +17 -0
- package/es/widgets/boxcard/index.d.ts +8 -0
- package/es/widgets/boxcard/index.js +20 -0
- package/es/widgets/components/DatePicker/index.d.ts +3 -0
- package/es/widgets/components/DatePicker/index.js +15 -0
- package/es/widgets/components/FButton/index.d.ts +3 -0
- package/es/widgets/components/FButton/index.js +24 -0
- package/es/widgets/components/HeaderTitle/index.css +0 -0
- package/es/widgets/components/HeaderTitle/index.d.ts +4 -0
- package/es/widgets/components/HeaderTitle/index.js +14 -0
- package/es/widgets/components/PanelView/index.css +6 -0
- package/es/widgets/components/PanelView/index.d.ts +4 -0
- package/es/widgets/components/PanelView/index.js +13 -0
- package/es/widgets/components/TimePicker/index.d.ts +2 -0
- package/es/widgets/components/TimePicker/index.js +18 -0
- package/es/widgets/fields/checkbox/index.d.ts +3 -0
- package/es/widgets/fields/checkbox/index.js +15 -0
- package/es/widgets/fields/checkboxes/index.d.ts +3 -0
- package/es/widgets/fields/checkboxes/index.js +31 -0
- package/es/widgets/fields/date/index.d.ts +3 -0
- package/es/widgets/fields/date/index.js +45 -0
- package/es/widgets/fields/dateRange/index.d.ts +7 -0
- package/es/widgets/fields/dateRange/index.js +64 -0
- package/es/widgets/fields/html/index.d.ts +2 -0
- package/es/widgets/fields/html/index.js +53 -0
- package/es/widgets/fields/imageInput/index.css +7 -0
- package/es/widgets/fields/imageInput/index.d.ts +4 -0
- package/es/widgets/fields/imageInput/index.js +38 -0
- package/es/widgets/fields/input/index.d.ts +2 -0
- package/es/widgets/fields/input/index.js +4 -0
- package/es/widgets/fields/number/index.d.ts +2 -0
- package/es/widgets/fields/number/index.js +4 -0
- package/es/widgets/fields/percentSlider/index.d.ts +17 -0
- package/es/widgets/fields/percentSlider/index.js +82 -0
- package/es/widgets/fields/radio/index.d.ts +3 -0
- package/es/widgets/fields/radio/index.js +31 -0
- package/es/widgets/fields/rate/index.d.ts +2 -0
- package/es/widgets/fields/rate/index.js +4 -0
- package/es/widgets/fields/select/index.d.ts +2 -0
- package/es/widgets/fields/select/index.js +4 -0
- package/es/widgets/fields/slider/index.css +5 -0
- package/es/widgets/fields/slider/index.d.ts +7 -0
- package/es/widgets/fields/slider/index.js +58 -0
- package/es/widgets/fields/switch/index.d.ts +2 -0
- package/es/widgets/fields/switch/index.js +4 -0
- package/es/widgets/fields/textArea/index.d.ts +3 -0
- package/es/widgets/fields/textArea/index.js +14 -0
- package/es/widgets/fields/time/index.d.ts +3 -0
- package/es/widgets/fields/time/index.js +29 -0
- package/es/widgets/fields/timeRange/index.d.ts +9 -0
- package/es/widgets/fields/timeRange/index.js +48 -0
- package/es/widgets/fields/treeSelect/index.d.ts +2 -0
- package/es/widgets/fields/treeSelect/index.js +4 -0
- package/es/widgets/fields/upload/index.css +28 -0
- package/es/widgets/fields/upload/index.d.ts +13 -0
- package/es/widgets/fields/upload/index.js +57 -0
- package/es/widgets/fields/urlInput/index.d.ts +3 -0
- package/es/widgets/fields/urlInput/index.js +63 -0
- package/es/widgets/index.d.ts +33 -0
- package/es/widgets/index.js +33 -0
- package/es/widgets/listCard/index.css +20 -0
- package/es/widgets/listCard/index.d.ts +4 -0
- package/es/widgets/listCard/index.js +141 -0
- package/es/widgets/listDrawer/drawerForm.d.ts +3 -0
- package/es/widgets/listDrawer/drawerForm.js +40 -0
- package/es/widgets/listDrawer/index.css +16 -0
- package/es/widgets/listDrawer/index.d.ts +12 -0
- package/es/widgets/listDrawer/index.js +288 -0
- package/es/widgets/listSimple/index.css +27 -0
- package/es/widgets/listSimple/index.d.ts +4 -0
- package/es/widgets/listSimple/index.js +124 -0
- package/es/widgets/listTab/index.css +0 -0
- package/es/widgets/listTab/index.d.ts +13 -0
- package/es/widgets/listTab/index.js +113 -0
- package/es/widgets/listTable/index.css +28 -0
- package/es/widgets/listTable/index.d.ts +14 -0
- package/es/widgets/listTable/index.js +227 -0
- package/es/widgets/listTable/tableCell.d.ts +3 -0
- package/es/widgets/listTable/tableCell.js +62 -0
- package/es/widgets/listVirtual/index.css +28 -0
- package/es/widgets/listVirtual/index.d.ts +14 -0
- package/es/widgets/listVirtual/index.js +213 -0
- package/es/widgets/listVirtual/virtualCell.d.ts +3 -0
- package/es/widgets/listVirtual/virtualCell.js +61 -0
- package/es/widgets/utils/hooks.d.ts +2 -0
- package/es/widgets/utils/hooks.js +14 -0
- package/es/widgets/utils/index.d.ts +4 -0
- package/es/widgets/utils/index.js +80 -0
- package/es/widgets/utils/withFieldWrap.d.ts +3 -0
- package/es/widgets/utils/withFieldWrap.js +17 -0
- package/es/widgets/voidTitle/index.css +7 -0
- package/es/widgets/voidTitle/index.d.ts +6 -0
- package/es/widgets/voidTitle/index.js +13 -0
- package/es/withProvider.d.ts +3 -0
- package/es/withProvider.js +70 -0
- package/lib/derivative/SearchForm/ActionView.d.ts +3 -0
- package/lib/derivative/SearchForm/ActionView.js +81 -0
- package/lib/derivative/SearchForm/index.css +31 -0
- package/lib/derivative/SearchForm/index.d.ts +5 -0
- package/lib/derivative/SearchForm/index.js +302 -0
- package/lib/derivative/SlimRender/index.d.ts +3 -0
- package/lib/derivative/SlimRender/index.js +13 -0
- package/lib/form-core/connectForm.d.ts +3 -0
- package/lib/form-core/connectForm.js +21 -0
- package/lib/form-core/index.css +19 -0
- package/lib/form-core/index.d.ts +5 -0
- package/lib/form-core/index.js +313 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +66 -0
- package/lib/locales/en_US.d.ts +28 -0
- package/lib/locales/en_US.js +33 -0
- package/lib/locales/index.d.ts +57 -0
- package/lib/locales/index.js +13 -0
- package/lib/locales/zh_CN.d.ts +28 -0
- package/lib/locales/zh_CN.js +33 -0
- package/lib/models/bindValues.d.ts +2 -0
- package/lib/models/bindValues.js +178 -0
- package/lib/models/context.d.ts +3 -0
- package/lib/models/context.js +9 -0
- package/lib/models/expression.d.ts +7 -0
- package/lib/models/expression.js +141 -0
- package/lib/models/fieldShouldUpdate.d.ts +2 -0
- package/lib/models/fieldShouldUpdate.js +76 -0
- package/lib/models/filterValuesHidden.d.ts +5 -0
- package/lib/models/filterValuesHidden.js +67 -0
- package/lib/models/filterValuesUndefined.d.ts +2 -0
- package/lib/models/filterValuesUndefined.js +53 -0
- package/lib/models/flattenSchema.d.ts +3 -0
- package/lib/models/flattenSchema.js +100 -0
- package/lib/models/formCoreUtils.d.ts +8 -0
- package/lib/models/formCoreUtils.js +199 -0
- package/lib/models/formDataSkeleton.d.ts +1 -0
- package/lib/models/formDataSkeleton.js +36 -0
- package/lib/models/layout.d.ts +4 -0
- package/lib/models/layout.js +94 -0
- package/lib/models/mapping.d.ts +89 -0
- package/lib/models/mapping.js +127 -0
- package/lib/models/sortProperties.d.ts +2 -0
- package/lib/models/sortProperties.js +47 -0
- package/lib/models/store.d.ts +10 -0
- package/lib/models/store.js +28 -0
- package/lib/models/transformProps.d.ts +34 -0
- package/lib/models/transformProps.js +86 -0
- package/lib/models/useForm.d.ts +3 -0
- package/lib/models/useForm.js +329 -0
- package/lib/models/validateMessage.d.ts +93 -0
- package/lib/models/validateMessage.js +101 -0
- package/lib/models/validates.d.ts +3 -0
- package/lib/models/validates.js +208 -0
- package/lib/render-core/FieldItem/field.d.ts +3 -0
- package/lib/render-core/FieldItem/field.js +90 -0
- package/lib/render-core/FieldItem/index.d.ts +3 -0
- package/lib/render-core/FieldItem/index.js +63 -0
- package/lib/render-core/FieldItem/main.d.ts +3 -0
- package/lib/render-core/FieldItem/main.js +236 -0
- package/lib/render-core/FieldItem/module.d.ts +18 -0
- package/lib/render-core/FieldItem/module.js +343 -0
- package/lib/render-core/FieldList/field.d.ts +3 -0
- package/lib/render-core/FieldList/field.js +309 -0
- package/lib/render-core/FieldList/index.d.ts +3 -0
- package/lib/render-core/FieldList/index.js +53 -0
- package/lib/render-core/FieldList/main.d.ts +3 -0
- package/lib/render-core/FieldList/main.js +108 -0
- package/lib/render-core/FieldList/modules.d.ts +7 -0
- package/lib/render-core/FieldList/modules.js +115 -0
- package/lib/render-core/index.css +29 -0
- package/lib/render-core/index.d.ts +9 -0
- package/lib/render-core/index.js +92 -0
- package/lib/type.d.ts +405 -0
- package/lib/type.js +7 -0
- package/lib/utils/index.d.ts +75 -0
- package/lib/utils/index.js +142 -0
- package/lib/widgets/ErrorSchema/index.d.ts +3 -0
- package/lib/widgets/ErrorSchema/index.js +23 -0
- package/lib/widgets/boxCollapse/index.css +53 -0
- package/lib/widgets/boxCollapse/index.d.ts +18 -0
- package/lib/widgets/boxCollapse/index.js +79 -0
- package/lib/widgets/boxLineTitle/index.css +18 -0
- package/lib/widgets/boxLineTitle/index.d.ts +8 -0
- package/lib/widgets/boxLineTitle/index.js +30 -0
- package/lib/widgets/boxSubInline/index.css +11 -0
- package/lib/widgets/boxSubInline/index.d.ts +4 -0
- package/lib/widgets/boxSubInline/index.js +63 -0
- package/lib/widgets/boxcard/index.css +17 -0
- package/lib/widgets/boxcard/index.d.ts +8 -0
- package/lib/widgets/boxcard/index.js +27 -0
- package/lib/widgets/components/DatePicker/index.d.ts +3 -0
- package/lib/widgets/components/DatePicker/index.js +22 -0
- package/lib/widgets/components/FButton/index.d.ts +3 -0
- package/lib/widgets/components/FButton/index.js +31 -0
- package/lib/widgets/components/HeaderTitle/index.css +0 -0
- package/lib/widgets/components/HeaderTitle/index.d.ts +4 -0
- package/lib/widgets/components/HeaderTitle/index.js +21 -0
- package/lib/widgets/components/PanelView/index.css +6 -0
- package/lib/widgets/components/PanelView/index.d.ts +4 -0
- package/lib/widgets/components/PanelView/index.js +20 -0
- package/lib/widgets/components/TimePicker/index.d.ts +2 -0
- package/lib/widgets/components/TimePicker/index.js +27 -0
- package/lib/widgets/fields/checkbox/index.d.ts +3 -0
- package/lib/widgets/fields/checkbox/index.js +22 -0
- package/lib/widgets/fields/checkboxes/index.d.ts +3 -0
- package/lib/widgets/fields/checkboxes/index.js +38 -0
- package/lib/widgets/fields/date/index.d.ts +3 -0
- package/lib/widgets/fields/date/index.js +54 -0
- package/lib/widgets/fields/dateRange/index.d.ts +7 -0
- package/lib/widgets/fields/dateRange/index.js +74 -0
- package/lib/widgets/fields/html/index.d.ts +2 -0
- package/lib/widgets/fields/html/index.js +60 -0
- package/lib/widgets/fields/imageInput/index.css +7 -0
- package/lib/widgets/fields/imageInput/index.d.ts +4 -0
- package/lib/widgets/fields/imageInput/index.js +47 -0
- package/lib/widgets/fields/input/index.d.ts +2 -0
- package/lib/widgets/fields/input/index.js +11 -0
- package/lib/widgets/fields/number/index.d.ts +2 -0
- package/lib/widgets/fields/number/index.js +11 -0
- package/lib/widgets/fields/percentSlider/index.d.ts +17 -0
- package/lib/widgets/fields/percentSlider/index.js +91 -0
- package/lib/widgets/fields/radio/index.d.ts +3 -0
- package/lib/widgets/fields/radio/index.js +38 -0
- package/lib/widgets/fields/rate/index.d.ts +2 -0
- package/lib/widgets/fields/rate/index.js +11 -0
- package/lib/widgets/fields/select/index.d.ts +2 -0
- package/lib/widgets/fields/select/index.js +11 -0
- package/lib/widgets/fields/slider/index.css +5 -0
- package/lib/widgets/fields/slider/index.d.ts +7 -0
- package/lib/widgets/fields/slider/index.js +66 -0
- package/lib/widgets/fields/switch/index.d.ts +2 -0
- package/lib/widgets/fields/switch/index.js +11 -0
- package/lib/widgets/fields/textArea/index.d.ts +3 -0
- package/lib/widgets/fields/textArea/index.js +21 -0
- package/lib/widgets/fields/time/index.d.ts +3 -0
- package/lib/widgets/fields/time/index.js +36 -0
- package/lib/widgets/fields/timeRange/index.d.ts +9 -0
- package/lib/widgets/fields/timeRange/index.js +54 -0
- package/lib/widgets/fields/treeSelect/index.d.ts +2 -0
- package/lib/widgets/fields/treeSelect/index.js +11 -0
- package/lib/widgets/fields/upload/index.css +28 -0
- package/lib/widgets/fields/upload/index.d.ts +13 -0
- package/lib/widgets/fields/upload/index.js +66 -0
- package/lib/widgets/fields/urlInput/index.d.ts +3 -0
- package/lib/widgets/fields/urlInput/index.js +72 -0
- package/lib/widgets/index.d.ts +33 -0
- package/lib/widgets/index.js +236 -0
- package/lib/widgets/listCard/index.css +20 -0
- package/lib/widgets/listCard/index.d.ts +4 -0
- package/lib/widgets/listCard/index.js +148 -0
- package/lib/widgets/listDrawer/drawerForm.d.ts +3 -0
- package/lib/widgets/listDrawer/drawerForm.js +49 -0
- package/lib/widgets/listDrawer/index.css +16 -0
- package/lib/widgets/listDrawer/index.d.ts +12 -0
- package/lib/widgets/listDrawer/index.js +296 -0
- package/lib/widgets/listSimple/index.css +27 -0
- package/lib/widgets/listSimple/index.d.ts +4 -0
- package/lib/widgets/listSimple/index.js +131 -0
- package/lib/widgets/listTab/index.css +0 -0
- package/lib/widgets/listTab/index.d.ts +13 -0
- package/lib/widgets/listTab/index.js +122 -0
- package/lib/widgets/listTable/index.css +28 -0
- package/lib/widgets/listTable/index.d.ts +14 -0
- package/lib/widgets/listTable/index.js +234 -0
- package/lib/widgets/listTable/tableCell.d.ts +3 -0
- package/lib/widgets/listTable/tableCell.js +71 -0
- package/lib/widgets/listVirtual/index.css +28 -0
- package/lib/widgets/listVirtual/index.d.ts +14 -0
- package/lib/widgets/listVirtual/index.js +220 -0
- package/lib/widgets/listVirtual/virtualCell.d.ts +3 -0
- package/lib/widgets/listVirtual/virtualCell.js +70 -0
- package/lib/widgets/utils/hooks.d.ts +2 -0
- package/lib/widgets/utils/hooks.js +21 -0
- package/lib/widgets/utils/index.d.ts +4 -0
- package/lib/widgets/utils/index.js +89 -0
- package/lib/widgets/utils/withFieldWrap.d.ts +3 -0
- package/lib/widgets/utils/withFieldWrap.js +24 -0
- package/lib/widgets/voidTitle/index.css +7 -0
- package/lib/widgets/voidTitle/index.d.ts +6 -0
- package/lib/widgets/voidTitle/index.js +20 -0
- package/lib/withProvider.d.ts +3 -0
- package/lib/withProvider.js +79 -0
- package/package.json +64 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.parseValuesToBind = exports.parseBindToValues = void 0;
|
|
8
|
+
var _lodashEs = require("lodash-es");
|
|
9
|
+
var _index = require("../utils/index");
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
13
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
14
|
+
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."); }
|
|
15
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
16
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
17
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
19
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
20
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
21
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
|
+
var isMultiBind = function isMultiBind(array) {
|
|
23
|
+
return (0, _index.isArray)(array) && array.every(function (item) {
|
|
24
|
+
return typeof item === 'string';
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
// Need to consider list nested controls
|
|
28
|
+
var transformPath = function transformPath(path) {
|
|
29
|
+
var result = [];
|
|
30
|
+
var _recursion = function recursion(str) {
|
|
31
|
+
var index = str.indexOf('[]');
|
|
32
|
+
if (index === -1) {
|
|
33
|
+
result.push(str);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
result.push(str.substring(0, index));
|
|
37
|
+
_recursion(str.substring(index + 3));
|
|
38
|
+
};
|
|
39
|
+
_recursion(path);
|
|
40
|
+
if (result.length === 1) {
|
|
41
|
+
return result[0];
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
var transformValueToBind = function transformValueToBind(data, path, bind) {
|
|
46
|
+
if (bind === false) {
|
|
47
|
+
(0, _lodashEs.unset)(data, path);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (typeof bind === 'string') {
|
|
51
|
+
var value = (0, _lodashEs.get)(data, path);
|
|
52
|
+
var preValue = (0, _lodashEs.get)(data, bind);
|
|
53
|
+
if ((0, _index.isObject)(preValue)) {
|
|
54
|
+
value = Object.assign(Object.assign({}, preValue), value);
|
|
55
|
+
}
|
|
56
|
+
(0, _lodashEs.set)(data, bind, value);
|
|
57
|
+
(0, _lodashEs.unset)(data, path);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// The array is converted to multiple fields.
|
|
61
|
+
if (isMultiBind(bind)) {
|
|
62
|
+
var _value = (0, _lodashEs.get)(data, path);
|
|
63
|
+
(0, _lodashEs.unset)(data, path);
|
|
64
|
+
if (Array.isArray(_value)) {
|
|
65
|
+
_value.forEach(function (item, index) {
|
|
66
|
+
var bindPath = bind[index];
|
|
67
|
+
bindPath && (0, _lodashEs.set)(data, bindPath, item);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var transformBindToValue = function transformBindToValue(data, path, bind) {
|
|
73
|
+
if (typeof bind === 'string') {
|
|
74
|
+
var value = (0, _lodashEs.get)(data, bind);
|
|
75
|
+
var preValue = (0, _lodashEs.get)(data, path);
|
|
76
|
+
if ((0, _index.isObject)(preValue)) {
|
|
77
|
+
value = Object.assign(Object.assign({}, preValue), value);
|
|
78
|
+
}
|
|
79
|
+
(0, _lodashEs.set)(data, path, value);
|
|
80
|
+
(0, _lodashEs.unset)(data, bind);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// The array is converted to multiple fields.
|
|
84
|
+
if (isMultiBind(bind)) {
|
|
85
|
+
var _value2 = [];
|
|
86
|
+
bind.forEach(function (key) {
|
|
87
|
+
var bindValue = (0, _lodashEs.get)(data, key);
|
|
88
|
+
// if (bindValue != undefined) {
|
|
89
|
+
// value.push(bindValue);
|
|
90
|
+
// }
|
|
91
|
+
_value2.push(bindValue);
|
|
92
|
+
(0, _lodashEs.unset)(data, key);
|
|
93
|
+
});
|
|
94
|
+
if (_value2.length > 0) {
|
|
95
|
+
(0, _lodashEs.set)(data, path, _value2);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var parseValuesToBind = exports.parseValuesToBind = function parseValuesToBind(values, flatten) {
|
|
100
|
+
// No bind field exists, no processing
|
|
101
|
+
if (!JSON.stringify(flatten).includes('bind')) {
|
|
102
|
+
return values;
|
|
103
|
+
}
|
|
104
|
+
var data = (0, _index._cloneDeep)(values);
|
|
105
|
+
var _dealFieldList = function dealFieldList(obj, _ref, bind) {
|
|
106
|
+
var _ref2 = _toArray(_ref),
|
|
107
|
+
path = _ref2[0],
|
|
108
|
+
rest = _arrayLikeToArray(_ref2).slice(1);
|
|
109
|
+
if (rest.length === 1) {
|
|
110
|
+
var list = (0, _lodashEs.get)(obj, path, []) || [];
|
|
111
|
+
list.forEach(function (item, index) {
|
|
112
|
+
var value = (0, _lodashEs.get)(item, rest[0]);
|
|
113
|
+
if (bind === 'root') {
|
|
114
|
+
list[index] = value;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
transformValueToBind(item, rest[0], bind);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if ((0, _index.isArray)(obj)) {
|
|
121
|
+
obj.forEach(function (item) {
|
|
122
|
+
return _dealFieldList(item, [path].concat(_toConsumableArray(rest)), bind);
|
|
123
|
+
});
|
|
124
|
+
} else if ((0, _index.isObject)(obj)) {
|
|
125
|
+
var value = (0, _lodashEs.get)(obj, path);
|
|
126
|
+
_dealFieldList(value, rest, bind);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
Object.keys(flatten).forEach(function (key) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
var bind = (_b = (_a = flatten[key]) === null || _a === void 0 ? void 0 : _a.schema) === null || _b === void 0 ? void 0 : _b.bind;
|
|
132
|
+
if (bind === undefined) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var path = transformPath(key);
|
|
136
|
+
(0, _index.isArray)(path) ? _dealFieldList(data, path, bind) : transformValueToBind(data, path, bind);
|
|
137
|
+
});
|
|
138
|
+
return data;
|
|
139
|
+
};
|
|
140
|
+
var parseBindToValues = exports.parseBindToValues = function parseBindToValues(values, flatten) {
|
|
141
|
+
if (!JSON.stringify(flatten).includes('bind')) {
|
|
142
|
+
return values;
|
|
143
|
+
}
|
|
144
|
+
var data = (0, _index._cloneDeep)(values);
|
|
145
|
+
var _dealFieldList2 = function dealFieldList(obj, _ref3, bind) {
|
|
146
|
+
var _ref4 = _toArray(_ref3),
|
|
147
|
+
path = _ref4[0],
|
|
148
|
+
rest = _arrayLikeToArray(_ref4).slice(1);
|
|
149
|
+
if (rest.length === 1) {
|
|
150
|
+
var list = (0, _index.safeGet)(obj, path, []);
|
|
151
|
+
list.forEach(function (item, index) {
|
|
152
|
+
if (bind === 'root') {
|
|
153
|
+
list[index] = _defineProperty({}, rest[0], item);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
transformBindToValue(item, rest[0], bind);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if ((0, _index.isArray)(obj)) {
|
|
160
|
+
obj.forEach(function (item) {
|
|
161
|
+
return _dealFieldList2(item, [path].concat(_toConsumableArray(rest)), bind);
|
|
162
|
+
});
|
|
163
|
+
} else if ((0, _index.isObject)(obj)) {
|
|
164
|
+
var value = (0, _lodashEs.get)(obj, path);
|
|
165
|
+
_dealFieldList2(value, rest, bind);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
Object.keys(flatten).forEach(function (key) {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
var bind = (_b = (_a = flatten[key]) === null || _a === void 0 ? void 0 : _a.schema) === null || _b === void 0 ? void 0 : _b.bind;
|
|
171
|
+
if (bind === undefined) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
var path = transformPath(key);
|
|
175
|
+
(0, _index.isArray)(path) ? _dealFieldList2(data, path, bind) : transformBindToValue(data, path, bind);
|
|
176
|
+
});
|
|
177
|
+
return data;
|
|
178
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FRContext = exports.ConfigContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var FRContext = exports.FRContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
9
|
+
var ConfigContext = exports.ConfigContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const isExpression: (str: string) => boolean;
|
|
2
|
+
export declare const isHasExpression: (schema: any) => boolean;
|
|
3
|
+
export declare const parseExpression: (func: any, formData: {}, parentPath: string | [
|
|
4
|
+
]) => any;
|
|
5
|
+
export declare function getRealDataPath(path: any): string;
|
|
6
|
+
export declare function getValueByPath(formData: any, path: any): any;
|
|
7
|
+
export declare const parseAllExpression: (_schema: any, _formData: any, dataPath: string, formSchema?: any) => any;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRealDataPath = getRealDataPath;
|
|
7
|
+
exports.getValueByPath = getValueByPath;
|
|
8
|
+
exports.parseExpression = exports.parseAllExpression = exports.isHasExpression = exports.isExpression = void 0;
|
|
9
|
+
var _lodashEs = require("lodash-es");
|
|
10
|
+
var _index = require("../utils/index");
|
|
11
|
+
var _formDataSkeleton = require("./formDataSkeleton");
|
|
12
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
13
|
+
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."); }
|
|
14
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
15
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
16
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
17
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
|
+
var isExpression = exports.isExpression = function isExpression(str) {
|
|
19
|
+
if (typeof str !== 'string') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
var pattern = /^{\s*{([^]+)}\s*}$/;
|
|
23
|
+
var reg1 = /^{\s*{function\(.+}\s*}$/;
|
|
24
|
+
return str.match(pattern) && !str.match(reg1);
|
|
25
|
+
};
|
|
26
|
+
var _isHasExpression = exports.isHasExpression = function isHasExpression(schema) {
|
|
27
|
+
var result = Object.keys(schema).some(function (key) {
|
|
28
|
+
var item = schema[key];
|
|
29
|
+
// 子协议不做递归确认
|
|
30
|
+
if (key === 'properties') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var _recursionArray = function recursionArray(list) {
|
|
34
|
+
var result = list.some(function (ite) {
|
|
35
|
+
if ((0, _index.isArray)(ite)) {
|
|
36
|
+
return _recursionArray(ite);
|
|
37
|
+
}
|
|
38
|
+
if ((0, _index.isObject)(ite)) {
|
|
39
|
+
return _isHasExpression(ite);
|
|
40
|
+
}
|
|
41
|
+
return isExpression(ite);
|
|
42
|
+
});
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
if ((0, _index.isArray)(item)) {
|
|
46
|
+
return _recursionArray(item);
|
|
47
|
+
}
|
|
48
|
+
if ((0, _index.isObject)(item)) {
|
|
49
|
+
return _isHasExpression(item);
|
|
50
|
+
}
|
|
51
|
+
return isExpression(item);
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
var parseFunc = function parseFunc(funcBody) {
|
|
56
|
+
var funcBodyTemp = funcBody.replace(/(\.|\?\.)/g, '?.'); // 将. 和 ?. 统一替换为?.
|
|
57
|
+
var funcBodyStr = funcBodyTemp.replace(/(\d+)\?\.(\d+)/g, '$1.$2'); // 排除数字中的?.
|
|
58
|
+
var result = _toConsumableArray(funcBodyStr).reduce(function (acc, char, index) {
|
|
59
|
+
if (char === '[') {
|
|
60
|
+
if (index > 0 && funcBodyStr[index - 1] !== '\n') {
|
|
61
|
+
// 排除开头[]
|
|
62
|
+
return "".concat(acc, "?.").concat(char);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return "".concat(acc).concat(char);
|
|
66
|
+
}, '');
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
var parseExpression = exports.parseExpression = function parseExpression(func) {
|
|
70
|
+
var formData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
71
|
+
var parentPath = arguments.length > 2 ? arguments[2] : undefined;
|
|
72
|
+
var parentData = (0, _lodashEs.get)(formData, parentPath) || {};
|
|
73
|
+
if (typeof func === 'string') {
|
|
74
|
+
var funcBody = func.replace(/^{\s*{/g, '').replace(/}\s*}$/g, '').trim();
|
|
75
|
+
var isHandleData = (funcBody === null || funcBody === void 0 ? void 0 : funcBody.startsWith('formData')) || (funcBody === null || funcBody === void 0 ? void 0 : funcBody.startsWith('rootValue'));
|
|
76
|
+
var funcBodyStr = isHandleData ? parseFunc(funcBody) : funcBody;
|
|
77
|
+
var funcStr = "\n return ".concat(funcBodyStr.replace(/formData/g, JSON.stringify(formData)).replace(/rootValue/g, JSON.stringify(parentData)), "\n ");
|
|
78
|
+
try {
|
|
79
|
+
var result = Function(funcStr)();
|
|
80
|
+
return result;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.log(error, funcStr, parentPath);
|
|
83
|
+
return null; // 如果计算有错误,return null 最合适
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return func;
|
|
87
|
+
};
|
|
88
|
+
function getRealDataPath(path) {
|
|
89
|
+
if (typeof path !== 'string') {
|
|
90
|
+
throw Error("id ".concat(path, " is not a string!!! Something wrong here"));
|
|
91
|
+
}
|
|
92
|
+
if (path.match(/[$]void_[^.]+$/)) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return path.replace(/[$]void_[^.]+./g, '');
|
|
96
|
+
}
|
|
97
|
+
function getValueByPath(formData, path) {
|
|
98
|
+
if (path === '#' || !path) {
|
|
99
|
+
return formData || {};
|
|
100
|
+
} else if (typeof path === 'string') {
|
|
101
|
+
var realPath = getRealDataPath(path);
|
|
102
|
+
return realPath && (0, _lodashEs.get)(formData, realPath);
|
|
103
|
+
} else {
|
|
104
|
+
console.error('path has to be a string');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var _parseAllExpression = exports.parseAllExpression = function parseAllExpression(_schema, _formData, dataPath, formSchema) {
|
|
108
|
+
var schema = (0, _index._cloneDeep)(_schema);
|
|
109
|
+
var formData = _formData;
|
|
110
|
+
if (formSchema) {
|
|
111
|
+
formData = (0, _formDataSkeleton.createDataSkeleton)(formSchema, formData);
|
|
112
|
+
}
|
|
113
|
+
var _recursionArray2 = function recursionArray(list) {
|
|
114
|
+
var result = list.map(function (item) {
|
|
115
|
+
if ((0, _index.isArray)(item)) {
|
|
116
|
+
return _recursionArray2(item);
|
|
117
|
+
}
|
|
118
|
+
if ((0, _index.isObject)(item)) {
|
|
119
|
+
return _parseAllExpression(item, formData, dataPath);
|
|
120
|
+
}
|
|
121
|
+
if (isExpression(item)) {
|
|
122
|
+
return parseExpression(item, formData, dataPath);
|
|
123
|
+
}
|
|
124
|
+
return item;
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
};
|
|
128
|
+
Object.keys(schema).forEach(function (key) {
|
|
129
|
+
var _a;
|
|
130
|
+
var value = schema[key];
|
|
131
|
+
if ((0, _index.isArray)(value)) {
|
|
132
|
+
schema[key] = _recursionArray2(value);
|
|
133
|
+
}
|
|
134
|
+
if ((0, _index.isObject)(value) && ((_a = value.mustacheParse) !== null && _a !== void 0 ? _a : true)) {
|
|
135
|
+
schema[key] = _parseAllExpression(value, formData, dataPath);
|
|
136
|
+
} else if (isExpression(value)) {
|
|
137
|
+
schema[key] = parseExpression(value, formData, dataPath);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return schema;
|
|
141
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _expression = require("./expression");
|
|
8
|
+
// 提取 formData. 开头的字符串
|
|
9
|
+
var extractFormDataStrings = function extractFormDataStrings(list) {
|
|
10
|
+
var result = [];
|
|
11
|
+
list.forEach(function (str) {
|
|
12
|
+
// TODO: 为啥要拆开来获取?
|
|
13
|
+
// const regex = /formData.\w+(.\w+)*(\(.*\))?/g; // 匹配formData.后面跟着字母、数字、下划线间隔的组合
|
|
14
|
+
// const regex = /formData(\.\w+|\[\w+\])(\.\w+|\[\w+\])*/g; // 1.同时匹配两种格式
|
|
15
|
+
var regex = /formData(\.\w+|\[(['"])?\w+\2?\])*(\.\w+)?/g; // 1.支持formData.xx 格式 以及formData[]格式 []中变量名只能包含字母、数字、下划线(_)
|
|
16
|
+
var matches = str.match(regex);
|
|
17
|
+
if (matches) {
|
|
18
|
+
result = result.concat(matches);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
// 提取 rootValue. 开头的字符串
|
|
24
|
+
var extractRootValueStrings = function extractRootValueStrings(list) {
|
|
25
|
+
var result = [];
|
|
26
|
+
list.forEach(function (str) {
|
|
27
|
+
// const regex = /rootValue.\w+(.\w+)*(\(.*\))?/g; // 匹配formData.后面跟着字母、数字、下划线间隔的组合
|
|
28
|
+
// const regex = /rootValue(\.\w+|\[\w+\])(\.\w+|\[\w+\])*/g; // 1.同时匹配两种格式
|
|
29
|
+
var regex = /rootValue(\.\w+|\[(['"])?\w+\2?\])*(\.\w+)?/g; // 1.支持rootValue.xx 格式 以及rootValue[]格式 []中变量名只能包含字母、数字、下划线(_)
|
|
30
|
+
var matches = str.match(regex);
|
|
31
|
+
if (matches) {
|
|
32
|
+
result = result.concat(matches);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
// 提取 {{ }} 里面的内容
|
|
38
|
+
var findStrList = function findStrList(str, type) {
|
|
39
|
+
var regex = /{{(.*?)}}/g;
|
|
40
|
+
var matches = [];
|
|
41
|
+
var match;
|
|
42
|
+
while ((match = regex.exec(str)) !== null) {
|
|
43
|
+
matches.push(match[1]);
|
|
44
|
+
}
|
|
45
|
+
;
|
|
46
|
+
if (type === 'formData') {
|
|
47
|
+
return extractFormDataStrings(matches);
|
|
48
|
+
}
|
|
49
|
+
if (type === 'rootValue') {
|
|
50
|
+
return extractRootValueStrings(matches);
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
var getListEveryResult = function getListEveryResult(list, preValue, nextValue, dataPath) {
|
|
55
|
+
return list.every(function (item) {
|
|
56
|
+
var pre = (0, _expression.parseExpression)(item, preValue, dataPath);
|
|
57
|
+
var curr = (0, _expression.parseExpression)(item, nextValue, dataPath);
|
|
58
|
+
return pre === curr;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var _default = exports.default = function _default(str, dataPath, dependencies, shouldUpdateOpen) {
|
|
62
|
+
return function (preValue, nextValue) {
|
|
63
|
+
// dependencies 先不处理
|
|
64
|
+
if (dependencies) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
var formDataList = findStrList(str, 'formData');
|
|
68
|
+
var rootValueList = findStrList(str, 'rootValue');
|
|
69
|
+
var formDataRes = getListEveryResult(formDataList, preValue, nextValue, dataPath);
|
|
70
|
+
var rootValueRes = getListEveryResult(rootValueList, preValue, nextValue, dataPath);
|
|
71
|
+
if (formDataRes && rootValueRes) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var transformHidden = function transformHidden(str) {
|
|
9
|
+
var formData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10
|
+
var parentData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11
|
+
if (typeof str !== 'string') {
|
|
12
|
+
return !!str;
|
|
13
|
+
}
|
|
14
|
+
var funcBody = str.replace(/^{\s*{/g, '').replace(/}\s*}$/g, '').trim();
|
|
15
|
+
var funcStr = "\n return ".concat(funcBody.replace(/formData/g, JSON.stringify(formData)).replace(/rootValue/g, JSON.stringify(parentData)), "\n ");
|
|
16
|
+
try {
|
|
17
|
+
var result = Function(funcStr)();
|
|
18
|
+
return result;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 过滤 field.schema.hidden = true,的值
|
|
25
|
+
*/
|
|
26
|
+
var _default = exports.default = function _default(_values, flattenSchema) {
|
|
27
|
+
var recursiveArray = function recursiveArray(list, _path) {
|
|
28
|
+
return list.map(function (item) {
|
|
29
|
+
if ((0, _utils.isObject)(item)) {
|
|
30
|
+
return _recursiveObj(item, _path, item);
|
|
31
|
+
}
|
|
32
|
+
return item;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var _recursiveObj = function recursiveObj(obj, prePath, parentData) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) {
|
|
38
|
+
var key = _Object$keys[_i];
|
|
39
|
+
var item = obj[key];
|
|
40
|
+
var path = prePath ? "".concat(prePath, ".").concat(key) : key;
|
|
41
|
+
var schema = (_a = flattenSchema[path]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
42
|
+
if ((0, _utils.isArray)(item) && !schema) {
|
|
43
|
+
path = prePath ? "".concat(prePath, ".").concat(key, "[]") : "".concat(key, "[]");
|
|
44
|
+
schema = (_b = flattenSchema[path]) === null || _b === void 0 ? void 0 : _b.schema;
|
|
45
|
+
}
|
|
46
|
+
// 剔除隐藏数据
|
|
47
|
+
if (schema === null || schema === void 0 ? void 0 : schema.hidden) {
|
|
48
|
+
var hidden = transformHidden(schema.hidden, _values, parentData);
|
|
49
|
+
if (hidden) {
|
|
50
|
+
obj[key] = undefined;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if ((0, _utils.isObject)(item)) {
|
|
55
|
+
obj[key] = _recursiveObj(item, path, parentData);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if ((0, _utils.isArray)(item) && (schema === null || schema === void 0 ? void 0 : schema.items)) {
|
|
59
|
+
obj[key] = recursiveArray(item, path) || [];
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
obj[key] = item;
|
|
63
|
+
}
|
|
64
|
+
return obj;
|
|
65
|
+
};
|
|
66
|
+
return _recursiveObj(_values) || {};
|
|
67
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _lodashEs = require("lodash-es");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _default = exports.default = function _default(values, notFilter) {
|
|
10
|
+
var _recursiveArray = function recursiveArray(list) {
|
|
11
|
+
var result = list.map(function (item) {
|
|
12
|
+
if ((0, _utils.isObject)(item)) {
|
|
13
|
+
return _recursiveObj(item, false);
|
|
14
|
+
}
|
|
15
|
+
if ((0, _utils.isArray)(item)) {
|
|
16
|
+
return _recursiveArray(item);
|
|
17
|
+
}
|
|
18
|
+
return item;
|
|
19
|
+
});
|
|
20
|
+
if (Object.keys(result).length === 0) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var _recursiveObj = function recursiveObj(_obj) {
|
|
26
|
+
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
27
|
+
if (_obj._isAMomentObject) {
|
|
28
|
+
return _obj;
|
|
29
|
+
}
|
|
30
|
+
var obj = (0, _lodashEs.omitBy)(_obj, _lodashEs.isUndefined);
|
|
31
|
+
Object.keys(obj).forEach(function (key) {
|
|
32
|
+
var item = obj[key];
|
|
33
|
+
if ((0, _utils.isObject)(item)) {
|
|
34
|
+
obj[key] = _recursiveObj(item);
|
|
35
|
+
}
|
|
36
|
+
if ((0, _utils.isArray)(item)) {
|
|
37
|
+
var data = _recursiveArray(item);
|
|
38
|
+
obj[key] = data;
|
|
39
|
+
if (!notFilter && data) {
|
|
40
|
+
obj[key] = data.filter(function (item) {
|
|
41
|
+
return item !== undefined;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
obj = (0, _lodashEs.omitBy)(obj, _lodashEs.isUndefined);
|
|
47
|
+
if (Object.keys(obj).length === 0 && filter) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
};
|
|
52
|
+
return _recursiveObj(values) || {};
|
|
53
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flattenSchema = flattenSchema;
|
|
7
|
+
exports.getKeyFromPath = void 0;
|
|
8
|
+
exports.getSchemaFromFlatten = getSchemaFromFlatten;
|
|
9
|
+
var _index = require("../utils/index");
|
|
10
|
+
var _sortProperties = _interopRequireDefault(require("./sortProperties"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
13
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
15
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
+
var getKeyFromPath = exports.getKeyFromPath = function getKeyFromPath() {
|
|
19
|
+
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#';
|
|
20
|
+
try {
|
|
21
|
+
var arr = path.split('.');
|
|
22
|
+
var last = arr.slice(-1)[0];
|
|
23
|
+
var result = last.replace('[]', '');
|
|
24
|
+
return result;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error, 'getKeyFromPath');
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function getSchemaFromFlatten(flatten) {
|
|
31
|
+
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#';
|
|
32
|
+
var schema = {};
|
|
33
|
+
var item = (0, _index._cloneDeep)(flatten[path]);
|
|
34
|
+
if (!item) {
|
|
35
|
+
return schema;
|
|
36
|
+
}
|
|
37
|
+
schema = item.schema;
|
|
38
|
+
// schema.$id && delete schema.$id;
|
|
39
|
+
if (item.children.length > 0) {
|
|
40
|
+
item.children.forEach(function (child) {
|
|
41
|
+
if (!flatten[child]) return;
|
|
42
|
+
var key = getKeyFromPath(child);
|
|
43
|
+
if ((0, _index.isObjType)(schema)) {
|
|
44
|
+
schema.properties[key] = getSchemaFromFlatten(flatten, child);
|
|
45
|
+
}
|
|
46
|
+
if ((0, _index.isListType)(schema)) {
|
|
47
|
+
schema.items.properties[key] = getSchemaFromFlatten(flatten, child);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return schema;
|
|
52
|
+
}
|
|
53
|
+
// TODO: more tests to make sure weird & wrong schema won't crush
|
|
54
|
+
function flattenSchema() {
|
|
55
|
+
var _schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
56
|
+
var name = arguments.length > 1 ? arguments[1] : undefined;
|
|
57
|
+
var parent = arguments.length > 2 ? arguments[2] : undefined;
|
|
58
|
+
var _result = arguments.length > 3 ? arguments[3] : undefined;
|
|
59
|
+
// 排序
|
|
60
|
+
// _schema = orderBy(_schema, item => item.order, ['asc']);
|
|
61
|
+
var result = _result || {};
|
|
62
|
+
var schema = (0, _index._cloneDeep)(_schema) || {};
|
|
63
|
+
var _name = name || '#';
|
|
64
|
+
if (!schema.$id) {
|
|
65
|
+
schema.$id = _name; // path as $id, for easy access to path in schema
|
|
66
|
+
}
|
|
67
|
+
var children = [];
|
|
68
|
+
if ((0, _index.isObjType)(schema)) {
|
|
69
|
+
(0, _sortProperties.default)(Object.entries(schema.properties)).forEach(function (_ref) {
|
|
70
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
71
|
+
key = _ref2[0],
|
|
72
|
+
value = _ref2[1];
|
|
73
|
+
var _key = (0, _index.isListType)(value) ? key + '[]' : key;
|
|
74
|
+
var uniqueName = _name === '#' ? _key : _name + '.' + _key;
|
|
75
|
+
children.push(uniqueName);
|
|
76
|
+
flattenSchema(value, uniqueName, _name, result);
|
|
77
|
+
});
|
|
78
|
+
schema.properties = {};
|
|
79
|
+
}
|
|
80
|
+
if ((0, _index.isListType)(schema)) {
|
|
81
|
+
(0, _sortProperties.default)(Object.entries(schema.items.properties)).forEach(function (_ref3) {
|
|
82
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
83
|
+
key = _ref4[0],
|
|
84
|
+
value = _ref4[1];
|
|
85
|
+
var _key = (0, _index.isListType)(value) ? key + '[]' : key;
|
|
86
|
+
var uniqueName = _name === '#' ? _key : _name + '.' + _key;
|
|
87
|
+
children.push(uniqueName);
|
|
88
|
+
flattenSchema(value, uniqueName, _name, result);
|
|
89
|
+
});
|
|
90
|
+
schema.items.properties = {};
|
|
91
|
+
}
|
|
92
|
+
if (schema.type) {
|
|
93
|
+
result[_name] = {
|
|
94
|
+
parent: parent,
|
|
95
|
+
schema: schema,
|
|
96
|
+
children: children
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const valuesWatch: (changedValues: any, allValues: any, watch: any) => void;
|
|
2
|
+
export declare const transformFieldsData: (_fieldsError: any, getFieldName: any) => any;
|
|
3
|
+
export declare const immediateWatch: (watch: any, values: any) => void;
|
|
4
|
+
export declare const getSchemaFullPath: (path: string, schema: any) => string;
|
|
5
|
+
export declare function yymmdd(timeStamp: any): string;
|
|
6
|
+
export declare function msToTime(duration: any): string;
|
|
7
|
+
export declare const getSessionItem: (key: string) => number;
|
|
8
|
+
export declare const setSessionItem: (key: string, data: any) => void;
|