@nocobase/client 0.9.0-alpha.2 → 0.9.1-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/es/acl/ACLProvider.js +4 -7
- package/es/api-client/APIClient.js +6 -0
- package/es/block-provider/BlockProvider.js +9 -6
- package/es/block-provider/FormBlockProvider.js +3 -1
- package/es/block-provider/KanbanBlockProvider.js +1 -1
- package/es/block-provider/SharedFilterProvider.js +9 -1
- package/es/block-provider/TableBlockProvider.js +1 -1
- package/es/block-provider/TableSelectorProvider.js +2 -2
- package/es/block-provider/hooks/index.js +22 -7
- package/es/collection-manager/CollectionManagerProvider.d.ts +1 -0
- package/es/collection-manager/CollectionManagerProvider.js +71 -9
- package/es/collection-manager/CollectionManagerShortcut.js +36 -23
- package/es/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
- package/es/collection-manager/Configuration/AddCategoryAction.js +117 -0
- package/es/collection-manager/Configuration/AddCollectionAction.js +8 -3
- package/es/collection-manager/Configuration/AddFieldAction.js +1 -0
- package/es/collection-manager/Configuration/ConfigurationTable.js +33 -4
- package/es/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
- package/es/collection-manager/Configuration/ConfigurationTabs.js +381 -0
- package/es/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
- package/es/collection-manager/Configuration/EditCategoryAction.js +150 -0
- package/es/collection-manager/Configuration/EditCollectionAction.js +6 -2
- package/es/collection-manager/Configuration/OverridingCollectionField.js +17 -8
- package/es/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
- package/es/collection-manager/Configuration/components/CollectionCategory.js +13 -0
- package/es/collection-manager/Configuration/index.d.ts +3 -0
- package/es/collection-manager/Configuration/index.js +3 -0
- package/es/collection-manager/Configuration/schemas/collections.d.ts +3 -0
- package/es/collection-manager/Configuration/schemas/collections.js +309 -176
- package/es/collection-manager/Configuration/templates.d.ts +1 -0
- package/es/collection-manager/Configuration/templates.js +1 -1
- package/es/collection-manager/action-hooks.js +3 -1
- package/es/collection-manager/context.d.ts +4 -0
- package/es/collection-manager/context.js +5 -1
- package/es/collection-manager/hooks/useCollectionManager.d.ts +7 -0
- package/es/collection-manager/hooks/useCollectionManager.js +51 -6
- package/es/collection-manager/interfaces/m2m.js +2 -2
- package/es/collection-manager/interfaces/properties/index.d.ts +0 -56
- package/es/collection-manager/interfaces/properties/index.js +1 -2
- package/es/collection-manager/templates/calendar.js +1 -1
- package/es/collection-manager/templates/general.js +1 -1
- package/es/collection-manager/templates/properties/index.d.ts +12 -1
- package/es/collection-manager/templates/properties/index.js +11 -0
- package/es/i18n/i18n.js +3 -1
- package/es/locale/en_US.d.ts +23 -0
- package/es/locale/en_US.js +23 -0
- package/es/locale/ja_JP.d.ts +23 -0
- package/es/locale/ja_JP.js +24 -1
- package/es/locale/ru_RU.d.ts +1 -0
- package/es/locale/ru_RU.js +1 -0
- package/es/locale/zh_CN.d.ts +43 -4
- package/es/locale/zh_CN.js +44 -5
- package/es/route-switch/antd/admin-layout/index.js +13 -33
- package/es/schema-component/antd/action/Action.Designer.js +22 -15
- package/es/schema-component/antd/action/Action.js +25 -3
- package/es/schema-component/antd/action/utils.d.ts +1 -0
- package/es/schema-component/antd/action/utils.js +49 -0
- package/es/schema-component/antd/association-filter/AssociationFilter.js +4 -4
- package/es/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
- package/es/schema-component/antd/association-select/useServiceOptions.js +47 -6
- package/es/schema-component/antd/calendar/Calendar.Designer.js +17 -36
- package/es/schema-component/antd/checkbox/Checkbox.js +9 -8
- package/es/schema-component/antd/date-picker/util.d.ts +1 -1
- package/es/schema-component/antd/date-picker/util.js +1 -1
- package/es/schema-component/antd/filter/DynamicComponent.js +3 -1
- package/es/schema-component/antd/filter/Filter.js +2 -1
- package/es/schema-component/antd/filter/FilterGroup.js +7 -4
- package/es/schema-component/antd/filter/FilterItem.js +3 -2
- package/es/schema-component/antd/filter/context.d.ts +1 -0
- package/es/schema-component/antd/filter/useValues.js +14 -11
- package/es/schema-component/antd/form/Form.js +11 -5
- package/es/schema-component/antd/form-item/FormItem.js +17 -8
- package/es/schema-component/antd/form-v2/Form.Designer.js +2 -0
- package/es/schema-component/antd/form-v2/Form.js +90 -7
- package/es/schema-component/antd/form-v2/utils.d.ts +5 -0
- package/es/schema-component/antd/form-v2/utils.js +161 -0
- package/es/schema-component/antd/grid/Grid.js +10 -5
- package/es/schema-component/antd/icon-picker/IconPicker.js +1 -0
- package/es/schema-component/antd/index.d.ts +1 -0
- package/es/schema-component/antd/index.js +1 -0
- package/es/schema-component/antd/input/Input.d.ts +2 -1
- package/es/schema-component/antd/input/Json.d.ts +5 -3
- package/es/schema-component/antd/input/Json.js +3 -2
- package/es/schema-component/antd/input-number/InputNumber.js +3 -1
- package/es/schema-component/antd/page/FixedBlock.js +3 -1
- package/es/schema-component/antd/page/Page.js +11 -5
- package/es/schema-component/antd/page/PageTabDesigner.js +3 -3
- package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
- package/es/schema-component/antd/record-picker/RecordPicker.js +1 -2
- package/es/schema-component/antd/record-picker/util.js +7 -0
- package/es/schema-component/antd/remote-select/RemoteSelect.js +76 -36
- package/es/schema-component/antd/rich-text/RichText.js +4 -2
- package/es/schema-component/antd/select/Select.js +14 -4
- package/es/schema-component/antd/table/Table.Array.js +10 -3
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
- package/es/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
- package/es/schema-component/antd/tabs/Tabs.Designer.js +1 -0
- package/es/schema-component/antd/time-picker/TimePicker.js +1 -1
- package/es/schema-component/antd/variable/Input.d.ts +2 -0
- package/es/schema-component/antd/variable/Input.js +244 -0
- package/es/schema-component/antd/variable/JSONInput.d.ts +2 -0
- package/es/schema-component/antd/variable/JSONInput.js +82 -0
- package/es/schema-component/antd/variable/TextArea.d.ts +2 -0
- package/es/schema-component/antd/variable/TextArea.js +322 -0
- package/es/schema-component/antd/variable/Variable.d.ts +8 -0
- package/es/schema-component/antd/variable/Variable.js +11 -0
- package/es/schema-component/antd/variable/index.d.ts +1 -0
- package/es/schema-component/antd/variable/index.js +1 -0
- package/es/schema-component/common/sortable-item/SortableItem.js +36 -6
- package/es/schema-component/common/utils/logic.js +523 -0
- package/es/schema-component/common/utils/uitls.d.ts +1 -0
- package/es/schema-component/common/utils/uitls.js +89 -0
- package/es/schema-initializer/SchemaInitializer.js +0 -1
- package/es/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
- package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -3
- package/es/schema-initializer/index.d.ts +2 -1
- package/es/schema-initializer/index.js +2 -1
- package/es/schema-initializer/items/CalendarBlockInitializer.js +24 -41
- package/es/schema-initializer/utils.js +22 -7
- package/es/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
- package/es/schema-settings/LinkageRules/DynamicComponent.js +113 -0
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +15 -0
- package/es/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
- package/es/schema-settings/LinkageRules/LinkageRuleAction.js +162 -0
- package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
- package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.js +71 -0
- package/es/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
- package/es/schema-settings/LinkageRules/ValueDynamicComponent.js +82 -0
- package/es/schema-settings/LinkageRules/Variables.d.ts +7 -0
- package/es/schema-settings/LinkageRules/Variables.js +115 -0
- package/es/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
- package/es/schema-settings/LinkageRules/action-hooks.js +115 -0
- package/es/schema-settings/LinkageRules/context.d.ts +13 -0
- package/es/schema-settings/LinkageRules/context.js +4 -0
- package/es/schema-settings/LinkageRules/index.d.ts +2 -0
- package/es/schema-settings/LinkageRules/index.js +132 -0
- package/es/schema-settings/LinkageRules/type.d.ts +13 -0
- package/es/schema-settings/LinkageRules/type.js +15 -0
- package/es/schema-settings/LinkageRules/useValues.d.ts +1 -0
- package/es/schema-settings/LinkageRules/useValues.js +84 -0
- package/es/schema-settings/SchemaSettings.d.ts +4 -1
- package/es/schema-settings/SchemaSettings.js +153 -26
- package/es/schema-templates/BlockTemplate.js +9 -1
- package/es/system-settings/SystemSettingsShortcut.js +1 -1
- package/lib/acl/ACLProvider.js +4 -7
- package/lib/api-client/APIClient.js +6 -0
- package/lib/block-provider/BlockProvider.js +9 -6
- package/lib/block-provider/FormBlockProvider.js +3 -1
- package/lib/block-provider/KanbanBlockProvider.js +1 -1
- package/lib/block-provider/SharedFilterProvider.js +9 -3
- package/lib/block-provider/TableBlockProvider.js +1 -1
- package/lib/block-provider/TableSelectorProvider.js +2 -2
- package/lib/block-provider/hooks/index.js +23 -7
- package/lib/collection-manager/CollectionManagerProvider.d.ts +1 -0
- package/lib/collection-manager/CollectionManagerProvider.js +81 -16
- package/lib/collection-manager/CollectionManagerShortcut.js +36 -23
- package/lib/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
- package/lib/collection-manager/Configuration/AddCategoryAction.js +145 -0
- package/lib/collection-manager/Configuration/AddCollectionAction.js +8 -3
- package/lib/collection-manager/Configuration/AddFieldAction.js +1 -0
- package/lib/collection-manager/Configuration/ConfigurationTable.js +34 -4
- package/lib/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
- package/lib/collection-manager/Configuration/ConfigurationTabs.js +407 -0
- package/lib/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
- package/lib/collection-manager/Configuration/EditCategoryAction.js +178 -0
- package/lib/collection-manager/Configuration/EditCollectionAction.js +6 -2
- package/lib/collection-manager/Configuration/OverridingCollectionField.js +17 -8
- package/lib/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
- package/lib/collection-manager/Configuration/components/CollectionCategory.js +27 -0
- package/lib/collection-manager/Configuration/index.d.ts +3 -0
- package/lib/collection-manager/Configuration/index.js +39 -0
- package/lib/collection-manager/Configuration/schemas/collections.d.ts +3 -0
- package/lib/collection-manager/Configuration/schemas/collections.js +316 -178
- package/lib/collection-manager/Configuration/templates.d.ts +1 -0
- package/lib/collection-manager/Configuration/templates.js +2 -0
- package/lib/collection-manager/action-hooks.js +3 -1
- package/lib/collection-manager/context.d.ts +4 -0
- package/lib/collection-manager/context.js +7 -2
- package/lib/collection-manager/hooks/useCollectionManager.d.ts +7 -0
- package/lib/collection-manager/hooks/useCollectionManager.js +52 -6
- package/lib/collection-manager/interfaces/m2m.js +2 -2
- package/lib/collection-manager/interfaces/properties/index.d.ts +0 -56
- package/lib/collection-manager/interfaces/properties/index.js +1 -2
- package/lib/collection-manager/templates/calendar.js +1 -1
- package/lib/collection-manager/templates/general.js +1 -1
- package/lib/collection-manager/templates/properties/index.d.ts +12 -1
- package/lib/collection-manager/templates/properties/index.js +11 -0
- package/lib/i18n/i18n.js +3 -1
- package/lib/locale/en_US.d.ts +23 -0
- package/lib/locale/en_US.js +23 -0
- package/lib/locale/ja_JP.d.ts +23 -0
- package/lib/locale/ja_JP.js +24 -1
- package/lib/locale/ru_RU.d.ts +1 -0
- package/lib/locale/ru_RU.js +1 -0
- package/lib/locale/zh_CN.d.ts +43 -4
- package/lib/locale/zh_CN.js +44 -5
- package/lib/route-switch/antd/admin-layout/index.js +13 -33
- package/lib/schema-component/antd/action/Action.Designer.js +24 -14
- package/lib/schema-component/antd/action/Action.js +27 -2
- package/lib/schema-component/antd/action/utils.d.ts +1 -0
- package/lib/schema-component/antd/action/utils.js +58 -2
- package/lib/schema-component/antd/association-filter/AssociationFilter.js +3 -3
- package/lib/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
- package/lib/schema-component/antd/association-select/useServiceOptions.js +47 -4
- package/lib/schema-component/antd/calendar/Calendar.Designer.js +15 -33
- package/lib/schema-component/antd/checkbox/Checkbox.js +8 -7
- package/lib/schema-component/antd/date-picker/util.d.ts +1 -1
- package/lib/schema-component/antd/date-picker/util.js +1 -1
- package/lib/schema-component/antd/filter/DynamicComponent.js +3 -1
- package/lib/schema-component/antd/filter/Filter.js +2 -1
- package/lib/schema-component/antd/filter/FilterGroup.js +7 -4
- package/lib/schema-component/antd/filter/FilterItem.js +3 -2
- package/lib/schema-component/antd/filter/context.d.ts +1 -0
- package/lib/schema-component/antd/filter/useValues.js +15 -11
- package/lib/schema-component/antd/form/Form.js +9 -3
- package/lib/schema-component/antd/form-item/FormItem.js +21 -7
- package/lib/schema-component/antd/form-v2/Form.Designer.js +2 -0
- package/lib/schema-component/antd/form-v2/Form.js +89 -5
- package/lib/schema-component/antd/form-v2/utils.d.ts +5 -0
- package/lib/schema-component/antd/form-v2/utils.js +181 -0
- package/lib/schema-component/antd/grid/Grid.js +10 -5
- package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -0
- package/lib/schema-component/antd/index.d.ts +1 -0
- package/lib/schema-component/antd/index.js +13 -0
- package/lib/schema-component/antd/input/Input.d.ts +2 -1
- package/lib/schema-component/antd/input/Json.d.ts +5 -3
- package/lib/schema-component/antd/input/Json.js +6 -3
- package/lib/schema-component/antd/input-number/InputNumber.js +2 -0
- package/lib/schema-component/antd/page/FixedBlock.js +3 -1
- package/lib/schema-component/antd/page/Page.js +14 -5
- package/lib/schema-component/antd/page/PageTabDesigner.js +1 -1
- package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
- package/lib/schema-component/antd/record-picker/RecordPicker.js +1 -2
- package/lib/schema-component/antd/record-picker/util.js +7 -0
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +76 -37
- package/lib/schema-component/antd/rich-text/RichText.js +4 -2
- package/lib/schema-component/antd/select/Select.js +14 -4
- package/lib/schema-component/antd/table/Table.Array.js +8 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
- package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
- package/lib/schema-component/antd/tabs/Tabs.Designer.js +1 -0
- package/lib/schema-component/antd/time-picker/TimePicker.js +1 -1
- package/lib/schema-component/antd/variable/Input.d.ts +2 -0
- package/lib/schema-component/antd/variable/Input.js +262 -0
- package/lib/schema-component/antd/variable/JSONInput.d.ts +2 -0
- package/lib/schema-component/antd/variable/JSONInput.js +100 -0
- package/lib/schema-component/antd/variable/TextArea.d.ts +2 -0
- package/lib/schema-component/antd/variable/TextArea.js +341 -0
- package/lib/schema-component/antd/variable/Variable.d.ts +8 -0
- package/lib/schema-component/antd/variable/Variable.js +25 -0
- package/lib/schema-component/antd/variable/index.d.ts +1 -0
- package/lib/schema-component/antd/variable/index.js +18 -0
- package/lib/schema-component/common/sortable-item/SortableItem.js +36 -6
- package/lib/schema-component/common/utils/logic.js +525 -0
- package/lib/schema-component/common/utils/uitls.d.ts +1 -0
- package/lib/schema-component/common/utils/uitls.js +103 -0
- package/lib/schema-initializer/SchemaInitializer.js +0 -1
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
- package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +3 -1
- package/lib/schema-initializer/index.d.ts +2 -1
- package/lib/schema-initializer/index.js +51 -2
- package/lib/schema-initializer/items/CalendarBlockInitializer.js +16 -33
- package/lib/schema-initializer/utils.js +22 -6
- package/lib/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/DynamicComponent.js +139 -0
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +27 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleAction.js +190 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
- package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.js +90 -0
- package/lib/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/ValueDynamicComponent.js +104 -0
- package/lib/schema-settings/LinkageRules/Variables.d.ts +7 -0
- package/lib/schema-settings/LinkageRules/Variables.js +124 -0
- package/lib/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/action-hooks.js +127 -0
- package/lib/schema-settings/LinkageRules/context.d.ts +13 -0
- package/lib/schema-settings/LinkageRules/context.js +15 -0
- package/lib/schema-settings/LinkageRules/index.d.ts +2 -0
- package/lib/schema-settings/LinkageRules/index.js +149 -0
- package/lib/schema-settings/LinkageRules/type.d.ts +13 -0
- package/lib/schema-settings/LinkageRules/type.js +22 -0
- package/lib/schema-settings/LinkageRules/useValues.d.ts +1 -0
- package/lib/schema-settings/LinkageRules/useValues.js +95 -0
- package/lib/schema-settings/SchemaSettings.d.ts +4 -1
- package/lib/schema-settings/SchemaSettings.js +176 -48
- package/lib/schema-templates/BlockTemplate.js +9 -1
- package/lib/system-settings/SystemSettingsShortcut.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Input = Input;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _react2 = require("@formily/react");
|
|
11
|
+
|
|
12
|
+
var _antd = require("antd");
|
|
13
|
+
|
|
14
|
+
var _icons = require("@ant-design/icons");
|
|
15
|
+
|
|
16
|
+
var _css = require("@emotion/css");
|
|
17
|
+
|
|
18
|
+
var _reactI18next = require("react-i18next");
|
|
19
|
+
|
|
20
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
21
|
+
|
|
22
|
+
var _ = require("../..");
|
|
23
|
+
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
29
|
+
|
|
30
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
31
|
+
|
|
32
|
+
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."); }
|
|
33
|
+
|
|
34
|
+
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); }
|
|
35
|
+
|
|
36
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
37
|
+
|
|
38
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
43
|
+
|
|
44
|
+
var JT_VALUE_RE = /^\s*{{\s*([^{}]+)\s*}}\s*$/;
|
|
45
|
+
|
|
46
|
+
function parseValue(value) {
|
|
47
|
+
if (value == null) {
|
|
48
|
+
return 'null';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var type = _typeof(value);
|
|
52
|
+
|
|
53
|
+
if (type === 'string') {
|
|
54
|
+
var matched = value.match(JT_VALUE_RE);
|
|
55
|
+
|
|
56
|
+
if (matched) {
|
|
57
|
+
return matched[1].split('.');
|
|
58
|
+
} // const ts = Date.parse(value);
|
|
59
|
+
// if (value.match(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d{0,3})Z$/) && !Number.isNaN(Date.parse(value))) {
|
|
60
|
+
// return {
|
|
61
|
+
// type: 'date',
|
|
62
|
+
// };
|
|
63
|
+
// }
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return type === 'object' && value instanceof Date ? 'date' : type;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var ConstantTypes = {
|
|
71
|
+
string: {
|
|
72
|
+
label: "{{t(\"String\")}}",
|
|
73
|
+
value: 'string',
|
|
74
|
+
component: function component(_ref) {
|
|
75
|
+
var _onChange = _ref.onChange,
|
|
76
|
+
value = _ref.value;
|
|
77
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
78
|
+
value: value,
|
|
79
|
+
onChange: function onChange(ev) {
|
|
80
|
+
return _onChange(ev.target.value);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
default: ''
|
|
85
|
+
},
|
|
86
|
+
number: {
|
|
87
|
+
label: '{{t("Number")}}',
|
|
88
|
+
value: 'number',
|
|
89
|
+
component: function component(_ref2) {
|
|
90
|
+
var onChange = _ref2.onChange,
|
|
91
|
+
value = _ref2.value;
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_antd.InputNumber, {
|
|
93
|
+
value: value,
|
|
94
|
+
onChange: onChange
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
default: 0
|
|
98
|
+
},
|
|
99
|
+
boolean: {
|
|
100
|
+
label: "{{t(\"Boolean\")}}",
|
|
101
|
+
value: 'boolean',
|
|
102
|
+
component: function component(_ref3) {
|
|
103
|
+
var onChange = _ref3.onChange,
|
|
104
|
+
value = _ref3.value;
|
|
105
|
+
|
|
106
|
+
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
107
|
+
t = _useTranslation.t;
|
|
108
|
+
|
|
109
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Select, {
|
|
110
|
+
value: value,
|
|
111
|
+
onChange: onChange,
|
|
112
|
+
placeholder: t('Select'),
|
|
113
|
+
options: [{
|
|
114
|
+
value: true,
|
|
115
|
+
label: t('True')
|
|
116
|
+
}, {
|
|
117
|
+
value: false,
|
|
118
|
+
label: t('False')
|
|
119
|
+
}]
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
default: false
|
|
123
|
+
},
|
|
124
|
+
date: {
|
|
125
|
+
label: '{{t("Date")}}',
|
|
126
|
+
value: 'date',
|
|
127
|
+
component: function component(_ref4) {
|
|
128
|
+
var _onChange2 = _ref4.onChange,
|
|
129
|
+
value = _ref4.value;
|
|
130
|
+
return /*#__PURE__*/_react.default.createElement(_antd.DatePicker, {
|
|
131
|
+
value: (0, _moment.default)(value),
|
|
132
|
+
onChange: function onChange(d) {
|
|
133
|
+
return d ? _onChange2(d.toDate()) : null;
|
|
134
|
+
},
|
|
135
|
+
allowClear: false,
|
|
136
|
+
showTime: true
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
default: function () {
|
|
140
|
+
var now = new Date();
|
|
141
|
+
return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);
|
|
142
|
+
}()
|
|
143
|
+
},
|
|
144
|
+
null: {
|
|
145
|
+
label: "{{t(\"Null\")}}",
|
|
146
|
+
value: 'null',
|
|
147
|
+
component: function component() {
|
|
148
|
+
var _useTranslation2 = (0, _reactI18next.useTranslation)(),
|
|
149
|
+
t = _useTranslation2.t;
|
|
150
|
+
|
|
151
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
152
|
+
readOnly: true,
|
|
153
|
+
placeholder: t('Null'),
|
|
154
|
+
className: "null-value"
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
default: null
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
function Input(props) {
|
|
162
|
+
var _ConstantTypes$type;
|
|
163
|
+
|
|
164
|
+
var _props$value = props.value,
|
|
165
|
+
value = _props$value === void 0 ? '' : _props$value,
|
|
166
|
+
scope = props.scope,
|
|
167
|
+
onChange = props.onChange,
|
|
168
|
+
children = props.children,
|
|
169
|
+
button = props.button;
|
|
170
|
+
var parsed = parseValue(value);
|
|
171
|
+
var isConstant = typeof parsed === 'string';
|
|
172
|
+
var type = isConstant ? parsed : '';
|
|
173
|
+
var variable = isConstant ? null : parsed;
|
|
174
|
+
var ConstantComponent = (_ConstantTypes$type = ConstantTypes[type]) === null || _ConstantTypes$type === void 0 ? void 0 : _ConstantTypes$type.component;
|
|
175
|
+
var constantOptions = Object.values(ConstantTypes);
|
|
176
|
+
var compile = (0, _.useCompile)();
|
|
177
|
+
|
|
178
|
+
var _useTranslation3 = (0, _reactI18next.useTranslation)(),
|
|
179
|
+
t = _useTranslation3.t;
|
|
180
|
+
|
|
181
|
+
var options = compile([{
|
|
182
|
+
value: '',
|
|
183
|
+
label: t('Constant'),
|
|
184
|
+
children: children ? null : constantOptions
|
|
185
|
+
}].concat(_toConsumableArray(typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [])));
|
|
186
|
+
var form = (0, _react2.useForm)();
|
|
187
|
+
|
|
188
|
+
function onSwitch(next) {
|
|
189
|
+
if (next[0] === '') {
|
|
190
|
+
if (next[1]) {
|
|
191
|
+
if (next[1] !== type) {
|
|
192
|
+
var _ConstantTypes$next$, _ConstantTypes$next$2;
|
|
193
|
+
|
|
194
|
+
onChange((_ConstantTypes$next$ = (_ConstantTypes$next$2 = ConstantTypes[next[1]]) === null || _ConstantTypes$next$2 === void 0 ? void 0 : _ConstantTypes$next$2.default) !== null && _ConstantTypes$next$ !== void 0 ? _ConstantTypes$next$ : null);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
if (variable) {
|
|
198
|
+
onChange(null);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
onChange("{{".concat(next.join('.'), "}}"));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var variableText = variable === null || variable === void 0 ? void 0 : variable.reduce(function (opts, key, i) {
|
|
209
|
+
var _ref5;
|
|
210
|
+
|
|
211
|
+
var option = (_ref5 = i ? opts[i - 1].children : options) === null || _ref5 === void 0 ? void 0 : _ref5.find(function (item) {
|
|
212
|
+
return item.value === key;
|
|
213
|
+
});
|
|
214
|
+
return option ? opts.concat(option) : opts;
|
|
215
|
+
}, []).map(function (item) {
|
|
216
|
+
return item.label;
|
|
217
|
+
}).join(' / ');
|
|
218
|
+
var disabled = props.disabled || form.disabled;
|
|
219
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Input.Group, {
|
|
220
|
+
compact: true,
|
|
221
|
+
className: (0, _css.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: auto;\n display: flex !important;\n .ant-input-disabled {\n .ant-tag {\n color: #bfbfbf;\n border-color: #d9d9d9;\n }\n }\n .ant-input.null-value {\n width: 4em;\n min-width: 4em;\n }\n "])))
|
|
222
|
+
}, variable ? /*#__PURE__*/_react.default.createElement("div", {
|
|
223
|
+
className: (0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n line-height: 0;\n\n &:hover {\n .ant-select-clear {\n opacity: 0.8;\n }\n }\n\n .ant-input {\n overflow: auto;\n white-space: nowrap;\n ", "\n\n .ant-tag {\n display: inline;\n line-height: 19px;\n margin: 0;\n padding: 2px 7px;\n border-radius: 10px;\n }\n }\n "])), disabled ? '' : 'padding-right: 28px;')
|
|
224
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
225
|
+
onInput: function onInput(e) {
|
|
226
|
+
return e.preventDefault();
|
|
227
|
+
},
|
|
228
|
+
onKeyDown: function onKeyDown(e) {
|
|
229
|
+
if (e.key !== 'Backspace') {
|
|
230
|
+
e.preventDefault();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
onChange(null);
|
|
235
|
+
},
|
|
236
|
+
className: (0, _css.cx)('ant-input', {
|
|
237
|
+
'ant-input-disabled': disabled
|
|
238
|
+
}),
|
|
239
|
+
contentEditable: !disabled,
|
|
240
|
+
suppressContentEditableWarning: true
|
|
241
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Tag, {
|
|
242
|
+
contentEditable: false,
|
|
243
|
+
color: "blue"
|
|
244
|
+
}, variableText)), !disabled ? /*#__PURE__*/_react.default.createElement("span", {
|
|
245
|
+
className: (0, _css.cx)('ant-select-clear', (0, _css.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n user-select: 'none';\n "])))),
|
|
246
|
+
unselectable: "on",
|
|
247
|
+
"aria-hidden": true,
|
|
248
|
+
onClick: function onClick() {
|
|
249
|
+
return onChange(null);
|
|
250
|
+
}
|
|
251
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloseCircleFilled, null)) : null) : children !== null && children !== void 0 ? children : /*#__PURE__*/_react.default.createElement(ConstantComponent, {
|
|
252
|
+
value: value,
|
|
253
|
+
onChange: onChange
|
|
254
|
+
}), options.length > 1 ? /*#__PURE__*/_react.default.createElement(_antd.Cascader, {
|
|
255
|
+
value: variable !== null && variable !== void 0 ? variable : [''].concat(_toConsumableArray(children ? [] : [type])),
|
|
256
|
+
options: options,
|
|
257
|
+
onChange: onSwitch
|
|
258
|
+
}, button !== null && button !== void 0 ? button : /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
259
|
+
type: variable ? 'primary' : 'default',
|
|
260
|
+
className: (0, _css.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: 'New York', 'Times New Roman', Times, serif;\n "])))
|
|
261
|
+
}, "x")) : null);
|
|
262
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.JSONInput = JSONInput;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _antd = require("antd");
|
|
13
|
+
|
|
14
|
+
var _css = require("@emotion/css");
|
|
15
|
+
|
|
16
|
+
var _input = require("../input");
|
|
17
|
+
|
|
18
|
+
var _reactI18next = require("react-i18next");
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
|
|
32
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
33
|
+
|
|
34
|
+
// NOTE: https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js/46012210#46012210
|
|
35
|
+
function setNativeInputValue(input, value) {
|
|
36
|
+
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value').set;
|
|
37
|
+
nativeInputValueSetter.call(input, value);
|
|
38
|
+
input.dispatchEvent(new Event('input', {
|
|
39
|
+
bubbles: true
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function JSONInput(props) {
|
|
44
|
+
var inputRef = (0, _react.useRef)(null);
|
|
45
|
+
var value = props.value,
|
|
46
|
+
_props$space = props.space,
|
|
47
|
+
space = _props$space === void 0 ? 2 : _props$space,
|
|
48
|
+
scope = props.scope;
|
|
49
|
+
|
|
50
|
+
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
51
|
+
t = _useTranslation.t;
|
|
52
|
+
|
|
53
|
+
var options = typeof scope === 'function' ? scope() : scope !== null && scope !== void 0 ? scope : [];
|
|
54
|
+
|
|
55
|
+
function onFormat() {
|
|
56
|
+
if (!inputRef.current) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!value) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var textArea = inputRef.current.resizableTextArea.textArea;
|
|
65
|
+
var nextValue = JSON.stringify(value, null, space);
|
|
66
|
+
setNativeInputValue(textArea, nextValue);
|
|
67
|
+
textArea.setSelectionRange(nextValue.length, nextValue.length);
|
|
68
|
+
textArea.focus();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onInsert(selected) {
|
|
72
|
+
if (!inputRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var variable = "{{".concat(selected.join('.'), "}}");
|
|
77
|
+
var textArea = inputRef.current.resizableTextArea.textArea;
|
|
78
|
+
var nextValue = textArea.value.slice(0, textArea.selectionStart) + variable + textArea.value.slice(textArea.selectionEnd);
|
|
79
|
+
var nextPos = [textArea.selectionStart, textArea.selectionStart + variable.length];
|
|
80
|
+
setNativeInputValue(textArea, nextValue);
|
|
81
|
+
textArea.setSelectionRange.apply(textArea, nextPos);
|
|
82
|
+
textArea.focus();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
86
|
+
className: (0, _css.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n .ant-input{\n width: 100%;\n }\n "])))
|
|
87
|
+
}, /*#__PURE__*/_react.default.createElement(_input.Input.JSON, _objectSpread(_objectSpread({}, props), {}, {
|
|
88
|
+
ref: inputRef
|
|
89
|
+
})), /*#__PURE__*/_react.default.createElement(_antd.Button.Group, {
|
|
90
|
+
className: (0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n right: 0;\n top: 0;\n .ant-btn-sm{\n font-size: 85%;\n }\n "])))
|
|
91
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
92
|
+
onClick: onFormat
|
|
93
|
+
}, t('Prettify')), /*#__PURE__*/_react.default.createElement(_antd.Cascader, {
|
|
94
|
+
value: [],
|
|
95
|
+
options: options,
|
|
96
|
+
onChange: onInsert
|
|
97
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
98
|
+
className: (0, _css.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n font-style: italic;\n font-family: \"New York\", \"Times New Roman\", Times, serif;\n "])))
|
|
99
|
+
}, "x"))));
|
|
100
|
+
}
|