@nocobase/client 0.9.2-alpha.3 → 0.9.3-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/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
- package/es/api-client/hooks/useRequest.d.ts +1 -14
- package/es/api-client/hooks/useRequest.js +48 -53
- package/es/block-provider/DetailsBlockProvider.js +13 -1
- package/es/block-provider/FormBlockProvider.js +30 -13
- package/es/block-provider/hooks/index.d.ts +11 -1
- package/es/block-provider/hooks/index.js +527 -301
- package/es/collection-manager/Configuration/CollectionFields.js +1 -2
- package/es/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
- package/es/collection-manager/action-hooks.d.ts +4 -43
- package/es/collection-manager/action-hooks.js +18 -7
- package/es/collection-manager/interfaces/createdBy.js +1 -1
- package/es/collection-manager/interfaces/linkTo.js +5 -40
- package/es/collection-manager/interfaces/m2m.js +6 -39
- package/es/collection-manager/interfaces/m2o.js +6 -39
- package/es/collection-manager/interfaces/o2m.js +6 -69
- package/es/collection-manager/interfaces/o2o.js +31 -122
- package/es/collection-manager/interfaces/types.d.ts +2 -0
- package/es/collection-manager/interfaces/updatedBy.js +1 -1
- package/es/collection-manager/sub-table.d.ts +1 -14
- package/es/collection-manager/templates/tree.js +2 -2
- package/es/filter-provider/FilterProvider.js +3 -1
- package/es/locale/en_US.d.ts +4 -1
- package/es/locale/en_US.js +6 -3
- package/es/locale/ja_JP.d.ts +4 -1
- package/es/locale/ja_JP.js +4 -1
- package/es/locale/pt_BR.d.ts +1 -1
- package/es/locale/pt_BR.js +1 -1
- package/es/locale/zh_CN.d.ts +5 -1
- package/es/locale/zh_CN.js +5 -1
- package/es/schema-component/antd/action/Action.Designer.js +4 -5
- package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
- package/es/schema-component/antd/association-field/AssociationFieldProvider.js +19 -0
- package/es/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
- package/es/schema-component/antd/association-field/AssociationSelect.js +118 -0
- package/es/schema-component/antd/association-field/Editable.d.ts +2 -0
- package/es/schema-component/antd/association-field/Editable.js +88 -0
- package/es/schema-component/antd/association-field/FileManager.d.ts +4 -0
- package/es/schema-component/antd/association-field/FileManager.js +243 -0
- package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -0
- package/es/schema-component/antd/association-field/InternalNester.js +28 -0
- package/es/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
- package/es/schema-component/antd/association-field/InternalPicker.js +267 -0
- package/es/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
- package/es/schema-component/antd/association-field/InternalSubTable.js +28 -0
- package/es/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
- package/es/schema-component/antd/association-field/InternalViewer.js +115 -0
- package/es/schema-component/antd/association-field/Nester.d.ts +1 -0
- package/es/schema-component/antd/association-field/Nester.js +80 -0
- package/es/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
- package/es/schema-component/antd/association-field/ReadPretty.js +38 -0
- package/es/schema-component/antd/association-field/SubTable.d.ts +1 -0
- package/es/schema-component/antd/association-field/SubTable.js +25 -0
- package/es/schema-component/antd/association-field/context.d.ts +7 -0
- package/es/schema-component/antd/association-field/context.js +2 -0
- package/es/schema-component/antd/association-field/hooks.d.ts +8 -0
- package/es/schema-component/antd/association-field/hooks.js +96 -0
- package/es/schema-component/antd/association-field/index.d.ts +1 -0
- package/es/schema-component/antd/association-field/index.js +14 -0
- package/es/schema-component/antd/association-field/schema.d.ts +142 -0
- package/es/schema-component/antd/association-field/schema.js +141 -0
- package/es/schema-component/antd/association-field/util.d.ts +8 -0
- package/es/schema-component/antd/association-field/util.js +84 -0
- package/es/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
- package/es/schema-component/antd/association-select/AssociationSelect.js +11 -2
- package/es/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
- package/es/schema-component/antd/expand-action/Expand.Action.Design.js +112 -0
- package/es/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
- package/es/schema-component/antd/expand-action/Expand.Action.js +40 -0
- package/es/schema-component/antd/expand-action/index.d.ts +1 -0
- package/es/schema-component/antd/expand-action/index.js +5 -0
- package/es/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
- package/es/schema-component/antd/filter/FilterItem.js +1 -1
- package/es/schema-component/antd/filter/useOperators.d.ts +1 -1
- package/es/schema-component/antd/form-item/FormItem.d.ts +2 -1
- package/es/schema-component/antd/form-item/FormItem.js +206 -58
- package/es/schema-component/antd/form-item/SchemaSettingOptions.js +36 -58
- package/es/schema-component/antd/form-v2/utils.js +6 -4
- package/es/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
- package/es/schema-component/antd/gantt/components/other/tooltip.js +1 -1
- package/es/schema-component/antd/index.d.ts +3 -1
- package/es/schema-component/antd/index.js +3 -1
- package/es/schema-component/antd/menu/Menu.js +6 -3
- package/es/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
- package/es/schema-component/antd/record-picker/InputRecordPicker.js +40 -17
- package/es/schema-component/antd/remote-select/RemoteSelect.js +16 -18
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
- package/es/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
- package/es/schema-component/antd/table-v2/Table.Index.js +6 -0
- package/es/schema-component/antd/table-v2/Table.js +9 -5
- package/es/schema-component/antd/table-v2/index.js +3 -1
- package/es/schema-component/antd/table-v2/utils.js +1 -1
- package/es/schema-component/antd/variable/Input.js +15 -16
- package/es/schema-component/antd/variable/TextArea.js +2 -5
- package/es/schema-component/antd/variable/Variable.d.ts +2 -0
- package/es/schema-component/antd/variable/Variable.js +5 -2
- package/es/schema-component/common/dnd-context/index.js +3 -2
- package/es/schema-component/common/sortable-item/SortableItem.js +4 -1
- package/es/schema-component/common/utils/uitls.js +1 -1
- package/es/schema-component/hooks/index.d.ts +1 -0
- package/es/schema-component/hooks/index.js +2 -1
- package/es/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
- package/es/schema-component/hooks/useFieldModeOptions.js +105 -0
- package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -1
- package/es/schema-initializer/components/CreateRecordAction.js +4 -3
- package/es/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
- package/es/schema-initializer/items/ExpandActionInitializer.js +9 -34
- package/es/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
- package/es/schema-initializer/items/SelectActionInitializer.js +65 -0
- package/es/schema-initializer/items/index.d.ts +1 -0
- package/es/schema-initializer/items/index.js +2 -1
- package/es/schema-initializer/utils.js +57 -43
- package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
- package/es/schema-settings/LinkageRules/Variables.d.ts +1 -1
- package/es/schema-settings/LinkageRules/Variables.js +7 -4
- package/es/schema-settings/SchemaSettings.js +3 -3
- package/es/schema-settings/VariableInput/VariableInput.d.ts +3 -2
- package/es/schema-settings/VariableInput/VariableInput.js +3 -1
- package/lib/acl/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
- package/lib/api-client/hooks/useRequest.d.ts +1 -14
- package/lib/api-client/hooks/useRequest.js +48 -53
- package/lib/block-provider/DetailsBlockProvider.js +13 -1
- package/lib/block-provider/FormBlockProvider.js +31 -15
- package/lib/block-provider/hooks/index.d.ts +11 -1
- package/lib/block-provider/hooks/index.js +537 -308
- package/lib/collection-manager/Configuration/CollectionFields.js +1 -2
- package/lib/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
- package/lib/collection-manager/action-hooks.d.ts +4 -43
- package/lib/collection-manager/action-hooks.js +18 -7
- package/lib/collection-manager/interfaces/createdBy.js +1 -1
- package/lib/collection-manager/interfaces/linkTo.js +4 -39
- package/lib/collection-manager/interfaces/m2m.js +5 -38
- package/lib/collection-manager/interfaces/m2o.js +5 -38
- package/lib/collection-manager/interfaces/o2m.js +8 -71
- package/lib/collection-manager/interfaces/o2o.js +36 -127
- package/lib/collection-manager/interfaces/types.d.ts +2 -0
- package/lib/collection-manager/interfaces/updatedBy.js +1 -1
- package/lib/collection-manager/sub-table.d.ts +1 -14
- package/lib/collection-manager/templates/tree.js +2 -2
- package/lib/filter-provider/FilterProvider.js +3 -1
- package/lib/locale/en_US.d.ts +4 -1
- package/lib/locale/en_US.js +6 -3
- package/lib/locale/ja_JP.d.ts +4 -1
- package/lib/locale/ja_JP.js +4 -1
- package/lib/locale/pt_BR.d.ts +1 -1
- package/lib/locale/pt_BR.js +1 -1
- package/lib/locale/zh_CN.d.ts +5 -1
- package/lib/locale/zh_CN.js +5 -1
- package/lib/schema-component/antd/action/Action.Designer.js +4 -5
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +28 -0
- package/lib/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
- package/lib/schema-component/antd/association-field/AssociationSelect.js +129 -0
- package/lib/schema-component/antd/association-field/Editable.d.ts +2 -0
- package/lib/schema-component/antd/association-field/Editable.js +97 -0
- package/lib/schema-component/antd/association-field/FileManager.d.ts +4 -0
- package/lib/schema-component/antd/association-field/FileManager.js +253 -0
- package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -0
- package/lib/schema-component/antd/association-field/InternalNester.js +39 -0
- package/lib/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
- package/lib/schema-component/antd/association-field/InternalPicker.js +277 -0
- package/lib/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
- package/lib/schema-component/antd/association-field/InternalSubTable.js +39 -0
- package/lib/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
- package/lib/schema-component/antd/association-field/InternalViewer.js +126 -0
- package/lib/schema-component/antd/association-field/Nester.d.ts +1 -0
- package/lib/schema-component/antd/association-field/Nester.js +89 -0
- package/lib/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
- package/lib/schema-component/antd/association-field/ReadPretty.js +47 -0
- package/lib/schema-component/antd/association-field/SubTable.d.ts +1 -0
- package/lib/schema-component/antd/association-field/SubTable.js +33 -0
- package/lib/schema-component/antd/association-field/context.d.ts +7 -0
- package/lib/schema-component/antd/association-field/context.js +9 -0
- package/lib/schema-component/antd/association-field/hooks.d.ts +8 -0
- package/lib/schema-component/antd/association-field/hooks.js +107 -0
- package/lib/schema-component/antd/association-field/index.d.ts +1 -0
- package/lib/schema-component/antd/association-field/index.js +21 -0
- package/lib/schema-component/antd/association-field/schema.d.ts +142 -0
- package/lib/schema-component/antd/association-field/schema.js +148 -0
- package/lib/schema-component/antd/association-field/util.d.ts +8 -0
- package/lib/schema-component/antd/association-field/util.js +98 -0
- package/lib/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
- package/lib/schema-component/antd/association-select/AssociationSelect.js +10 -1
- package/lib/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.Design.js +120 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/Expand.Action.js +48 -0
- package/lib/schema-component/antd/expand-action/index.d.ts +1 -0
- package/lib/schema-component/antd/expand-action/index.js +12 -0
- package/lib/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
- package/lib/schema-component/antd/filter/FilterItem.js +1 -1
- package/lib/schema-component/antd/filter/useOperators.d.ts +1 -1
- package/lib/schema-component/antd/form-item/FormItem.d.ts +2 -1
- package/lib/schema-component/antd/form-item/FormItem.js +204 -55
- package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +34 -56
- package/lib/schema-component/antd/form-v2/utils.js +6 -5
- package/lib/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
- package/lib/schema-component/antd/gantt/components/other/tooltip.js +1 -1
- package/lib/schema-component/antd/index.d.ts +3 -1
- package/lib/schema-component/antd/index.js +33 -11
- package/lib/schema-component/antd/menu/Menu.js +6 -3
- package/lib/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
- package/lib/schema-component/antd/record-picker/InputRecordPicker.js +42 -18
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +15 -17
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
- package/lib/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
- package/lib/schema-component/antd/table-v2/Table.Index.js +14 -0
- package/lib/schema-component/antd/table-v2/Table.js +9 -5
- package/lib/schema-component/antd/table-v2/index.js +3 -1
- package/lib/schema-component/antd/table-v2/utils.js +1 -1
- package/lib/schema-component/antd/variable/Input.js +15 -16
- package/lib/schema-component/antd/variable/TextArea.js +2 -5
- package/lib/schema-component/antd/variable/Variable.d.ts +2 -0
- package/lib/schema-component/antd/variable/Variable.js +6 -2
- package/lib/schema-component/common/dnd-context/index.js +3 -2
- package/lib/schema-component/common/sortable-item/SortableItem.js +4 -1
- package/lib/schema-component/common/utils/uitls.js +1 -1
- package/lib/schema-component/hooks/index.d.ts +1 -0
- package/lib/schema-component/hooks/index.js +11 -0
- package/lib/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
- package/lib/schema-component/hooks/useFieldModeOptions.js +112 -0
- package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -1
- package/lib/schema-initializer/components/CreateRecordAction.js +4 -3
- package/lib/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
- package/lib/schema-initializer/items/ExpandActionInitializer.js +11 -37
- package/lib/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
- package/lib/schema-initializer/items/SelectActionInitializer.js +73 -0
- package/lib/schema-initializer/items/index.d.ts +1 -0
- package/lib/schema-initializer/items/index.js +11 -0
- package/lib/schema-initializer/utils.js +56 -42
- package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
- package/lib/schema-settings/LinkageRules/Variables.d.ts +1 -1
- package/lib/schema-settings/LinkageRules/Variables.js +7 -4
- package/lib/schema-settings/SchemaSettings.js +4 -4
- package/lib/schema-settings/VariableInput/VariableInput.d.ts +3 -2
- package/lib/schema-settings/VariableInput/VariableInput.js +3 -1
- package/package.json +5 -6
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
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); }
|
|
7
|
+
import { useFieldSchema } from '@formily/react';
|
|
8
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
9
|
+
import { useCallback, useContext, useMemo } from 'react';
|
|
10
|
+
import { useDesignable } from '../../hooks';
|
|
11
|
+
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
|
12
|
+
import { AssociationFieldContext } from './context';
|
|
13
|
+
import { useRecord } from '../../../record-provider';
|
|
14
|
+
import { isInFilterFormBlock } from '../../../filter-provider';
|
|
15
|
+
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
|
16
|
+
export var useInsertSchema = function useInsertSchema(component) {
|
|
17
|
+
var fieldSchema = useFieldSchema();
|
|
18
|
+
var _useDesignable = useDesignable(),
|
|
19
|
+
insertAfterBegin = _useDesignable.insertAfterBegin;
|
|
20
|
+
var insert = useCallback(function (ss) {
|
|
21
|
+
var schema = fieldSchema.reduceProperties(function (buf, s) {
|
|
22
|
+
if (s['x-component'] === 'AssociationField.' + component) {
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
25
|
+
return buf;
|
|
26
|
+
}, null);
|
|
27
|
+
if (!schema) {
|
|
28
|
+
insertAfterBegin(cloneDeep(ss));
|
|
29
|
+
}
|
|
30
|
+
}, [component]);
|
|
31
|
+
return insert;
|
|
32
|
+
};
|
|
33
|
+
export function useAssociationFieldContext() {
|
|
34
|
+
return useContext(AssociationFieldContext);
|
|
35
|
+
}
|
|
36
|
+
export default function useServiceOptions(props) {
|
|
37
|
+
var _props$action = props.action,
|
|
38
|
+
action = _props$action === void 0 ? 'list' : _props$action,
|
|
39
|
+
service = props.service,
|
|
40
|
+
fieldNames = props.fieldNames;
|
|
41
|
+
var params = (service === null || service === void 0 ? void 0 : service.params) || {};
|
|
42
|
+
var fieldSchema = useFieldSchema();
|
|
43
|
+
var _useCollection = useCollection(),
|
|
44
|
+
getField = _useCollection.getField,
|
|
45
|
+
fields = _useCollection.fields;
|
|
46
|
+
var _useCollectionManager = useCollectionManager(),
|
|
47
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
48
|
+
var record = useRecord();
|
|
49
|
+
var normalizeValues = useCallback(function (obj) {
|
|
50
|
+
if (obj && _typeof(obj) === 'object') {
|
|
51
|
+
return obj[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value];
|
|
52
|
+
}
|
|
53
|
+
return obj;
|
|
54
|
+
}, [fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value]);
|
|
55
|
+
var value = useMemo(function () {
|
|
56
|
+
if (props.value === undefined || props.value === null) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(props.value)) {
|
|
60
|
+
return props.value.map(normalizeValues);
|
|
61
|
+
} else {
|
|
62
|
+
return [normalizeValues(props.value)];
|
|
63
|
+
}
|
|
64
|
+
}, [props.value, normalizeValues]);
|
|
65
|
+
var collectionField = useMemo(function () {
|
|
66
|
+
return getField(fieldSchema.name);
|
|
67
|
+
}, [fieldSchema.name]);
|
|
68
|
+
var sourceValue = record === null || record === void 0 ? void 0 : record[collectionField === null || collectionField === void 0 ? void 0 : collectionField.sourceKey];
|
|
69
|
+
var filter = useMemo(function () {
|
|
70
|
+
var isOToAny = ['oho', 'o2m'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
|
|
71
|
+
return mergeFilter([mergeFilter([isOToAny && !isInFilterFormBlock(fieldSchema) ? _defineProperty({}, collectionField.foreignKey, {
|
|
72
|
+
$is: null
|
|
73
|
+
}) : null, params === null || params === void 0 ? void 0 : params.filter]), isOToAny && sourceValue !== undefined && sourceValue !== null && !isInFilterFormBlock(fieldSchema) ? _defineProperty({}, collectionField.foreignKey, {
|
|
74
|
+
$eq: sourceValue
|
|
75
|
+
}) : null, (params === null || params === void 0 ? void 0 : params.filter) && value ? _defineProperty({}, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value, _defineProperty({}, '$in', value)) : null], '$or');
|
|
76
|
+
}, [params === null || params === void 0 ? void 0 : params.filter, getCollectionFields, collectionField, sourceValue, value, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value]);
|
|
77
|
+
return useMemo(function () {
|
|
78
|
+
return _objectSpread(_objectSpread({
|
|
79
|
+
resource: collectionField === null || collectionField === void 0 ? void 0 : collectionField.target,
|
|
80
|
+
action: action
|
|
81
|
+
}, service), {}, {
|
|
82
|
+
params: _objectSpread(_objectSpread({}, service === null || service === void 0 ? void 0 : service.params), {}, {
|
|
83
|
+
filter: filter
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}, [collectionField === null || collectionField === void 0 ? void 0 : collectionField.target, action, filter, service]);
|
|
87
|
+
}
|
|
88
|
+
export var useFieldNames = function useFieldNames(props) {
|
|
89
|
+
var _fieldSchema$xCompon, _fieldSchema$xCompon$, _fieldSchema$xCompon$2, _fieldSchema$xCompon$3, _fieldSchema$xCompon2;
|
|
90
|
+
var fieldSchema = useFieldSchema();
|
|
91
|
+
var fieldNames = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : (_fieldSchema$xCompon$ = _fieldSchema$xCompon['field']) === null || _fieldSchema$xCompon$ === void 0 ? void 0 : (_fieldSchema$xCompon$2 = _fieldSchema$xCompon$['uiSchema']) === null || _fieldSchema$xCompon$2 === void 0 ? void 0 : (_fieldSchema$xCompon$3 = _fieldSchema$xCompon$2['x-component-props']) === null || _fieldSchema$xCompon$3 === void 0 ? void 0 : _fieldSchema$xCompon$3['fieldNames']) || (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2['fieldNames']) || props.fieldNames;
|
|
92
|
+
return _objectSpread({
|
|
93
|
+
label: 'label',
|
|
94
|
+
value: 'value'
|
|
95
|
+
}, fieldNames);
|
|
96
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AssociationField: any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { connect, mapReadPretty } from '@formily/react';
|
|
2
|
+
import { Action } from '../action';
|
|
3
|
+
import { Editable } from './Editable';
|
|
4
|
+
import { InternalPicker } from './InternalPicker';
|
|
5
|
+
import { Nester } from './Nester';
|
|
6
|
+
import { ReadPretty } from './ReadPretty';
|
|
7
|
+
import { SubTable } from './SubTable';
|
|
8
|
+
export var AssociationField = connect(Editable, mapReadPretty(ReadPretty));
|
|
9
|
+
AssociationField.SubTable = SubTable;
|
|
10
|
+
AssociationField.Nester = Nester;
|
|
11
|
+
AssociationField.AddNewer = Action.Container;
|
|
12
|
+
AssociationField.Selector = Action.Container;
|
|
13
|
+
AssociationField.Viewer = Action.Container;
|
|
14
|
+
AssociationField.InternalSelect = InternalPicker;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
Nester: {
|
|
3
|
+
type: string;
|
|
4
|
+
'x-component': string;
|
|
5
|
+
properties: {
|
|
6
|
+
grid: {
|
|
7
|
+
type: string;
|
|
8
|
+
'x-component': string;
|
|
9
|
+
'x-initializer': string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
AddNewer: {
|
|
14
|
+
type: string;
|
|
15
|
+
'x-component': string;
|
|
16
|
+
'x-action': string;
|
|
17
|
+
title: string;
|
|
18
|
+
'x-component-props': {
|
|
19
|
+
className: string;
|
|
20
|
+
};
|
|
21
|
+
properties: {
|
|
22
|
+
tabs: {
|
|
23
|
+
type: string;
|
|
24
|
+
'x-component': string;
|
|
25
|
+
'x-component-props': {};
|
|
26
|
+
'x-initializer': string;
|
|
27
|
+
properties: {
|
|
28
|
+
tab1: {
|
|
29
|
+
type: string;
|
|
30
|
+
title: string;
|
|
31
|
+
'x-component': string;
|
|
32
|
+
'x-designer': string;
|
|
33
|
+
'x-component-props': {};
|
|
34
|
+
properties: {
|
|
35
|
+
grid: {
|
|
36
|
+
type: string;
|
|
37
|
+
'x-component': string;
|
|
38
|
+
'x-initializer': string;
|
|
39
|
+
properties: {};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
Selector: {
|
|
48
|
+
type: string;
|
|
49
|
+
'x-component': string;
|
|
50
|
+
title: string;
|
|
51
|
+
'x-component-props': {
|
|
52
|
+
className: string;
|
|
53
|
+
};
|
|
54
|
+
properties: {
|
|
55
|
+
grid: {
|
|
56
|
+
type: string;
|
|
57
|
+
'x-component': string;
|
|
58
|
+
'x-initializer': string;
|
|
59
|
+
properties: {};
|
|
60
|
+
};
|
|
61
|
+
footer: {
|
|
62
|
+
'x-component': string;
|
|
63
|
+
'x-component-props': {};
|
|
64
|
+
properties: {
|
|
65
|
+
actions: {
|
|
66
|
+
type: string;
|
|
67
|
+
'x-component': string;
|
|
68
|
+
'x-component-props': {};
|
|
69
|
+
properties: {
|
|
70
|
+
submit: {
|
|
71
|
+
title: string;
|
|
72
|
+
'x-action': string;
|
|
73
|
+
'x-component': string;
|
|
74
|
+
'x-designer': string;
|
|
75
|
+
'x-component-props': {
|
|
76
|
+
type: string;
|
|
77
|
+
htmlType: string;
|
|
78
|
+
useProps: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
Viewer: {
|
|
88
|
+
type: string;
|
|
89
|
+
title: string;
|
|
90
|
+
'x-component': string;
|
|
91
|
+
'x-component-props': {
|
|
92
|
+
className: string;
|
|
93
|
+
};
|
|
94
|
+
properties: {
|
|
95
|
+
tabs: {
|
|
96
|
+
type: string;
|
|
97
|
+
'x-component': string;
|
|
98
|
+
'x-component-props': {};
|
|
99
|
+
'x-initializer': string;
|
|
100
|
+
properties: {
|
|
101
|
+
tab1: {
|
|
102
|
+
type: string;
|
|
103
|
+
title: string;
|
|
104
|
+
'x-component': string;
|
|
105
|
+
'x-designer': string;
|
|
106
|
+
'x-component-props': {};
|
|
107
|
+
properties: {
|
|
108
|
+
grid: {
|
|
109
|
+
type: string;
|
|
110
|
+
'x-component': string;
|
|
111
|
+
'x-initializer': string;
|
|
112
|
+
properties: {};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
SubTable: {
|
|
121
|
+
type: string;
|
|
122
|
+
'x-component': string;
|
|
123
|
+
'x-initializer': string;
|
|
124
|
+
properties: {
|
|
125
|
+
indexCol: {
|
|
126
|
+
type: string;
|
|
127
|
+
'x-component': string;
|
|
128
|
+
'x-component-props': {
|
|
129
|
+
width: number;
|
|
130
|
+
};
|
|
131
|
+
properties: {
|
|
132
|
+
__index__: {
|
|
133
|
+
type: string;
|
|
134
|
+
'x-component': string;
|
|
135
|
+
'x-read-pretty': boolean;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
export default _default;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
Nester: {
|
|
3
|
+
type: 'void',
|
|
4
|
+
'x-component': 'AssociationField.Nester',
|
|
5
|
+
properties: {
|
|
6
|
+
grid: {
|
|
7
|
+
type: 'void',
|
|
8
|
+
'x-component': 'Grid',
|
|
9
|
+
'x-initializer': 'FormItemInitializers'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
AddNewer: {
|
|
14
|
+
type: 'void',
|
|
15
|
+
'x-component': 'AssociationField.AddNewer',
|
|
16
|
+
'x-action': 'create',
|
|
17
|
+
title: '{{ t("Add record") }}',
|
|
18
|
+
'x-component-props': {
|
|
19
|
+
className: 'nb-action-popup'
|
|
20
|
+
},
|
|
21
|
+
properties: {
|
|
22
|
+
tabs: {
|
|
23
|
+
type: 'void',
|
|
24
|
+
'x-component': 'Tabs',
|
|
25
|
+
'x-component-props': {},
|
|
26
|
+
'x-initializer': 'TabPaneInitializersForCreateFormBlock',
|
|
27
|
+
properties: {
|
|
28
|
+
tab1: {
|
|
29
|
+
type: 'void',
|
|
30
|
+
title: '{{t("Add new")}}',
|
|
31
|
+
'x-component': 'Tabs.TabPane',
|
|
32
|
+
'x-designer': 'Tabs.Designer',
|
|
33
|
+
'x-component-props': {},
|
|
34
|
+
properties: {
|
|
35
|
+
grid: {
|
|
36
|
+
type: 'void',
|
|
37
|
+
'x-component': 'Grid',
|
|
38
|
+
'x-initializer': 'CreateFormBlockInitializers',
|
|
39
|
+
properties: {}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
Selector: {
|
|
48
|
+
type: 'void',
|
|
49
|
+
'x-component': 'AssociationField.Selector',
|
|
50
|
+
title: '{{ t("Select record") }}',
|
|
51
|
+
'x-component-props': {
|
|
52
|
+
className: 'nb-record-picker-selector'
|
|
53
|
+
},
|
|
54
|
+
properties: {
|
|
55
|
+
grid: {
|
|
56
|
+
type: 'void',
|
|
57
|
+
'x-component': 'Grid',
|
|
58
|
+
'x-initializer': 'TableSelectorInitializers',
|
|
59
|
+
properties: {}
|
|
60
|
+
},
|
|
61
|
+
footer: {
|
|
62
|
+
'x-component': 'Action.Container.Footer',
|
|
63
|
+
'x-component-props': {},
|
|
64
|
+
properties: {
|
|
65
|
+
actions: {
|
|
66
|
+
type: 'void',
|
|
67
|
+
'x-component': 'ActionBar',
|
|
68
|
+
'x-component-props': {},
|
|
69
|
+
properties: {
|
|
70
|
+
submit: {
|
|
71
|
+
title: '{{ t("Submit") }}',
|
|
72
|
+
'x-action': 'submit',
|
|
73
|
+
'x-component': 'Action',
|
|
74
|
+
'x-designer': 'Action.Designer',
|
|
75
|
+
'x-component-props': {
|
|
76
|
+
type: 'primary',
|
|
77
|
+
htmlType: 'submit',
|
|
78
|
+
useProps: '{{ usePickActionProps }}'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
Viewer: {
|
|
88
|
+
type: 'void',
|
|
89
|
+
title: '{{ t("View record") }}',
|
|
90
|
+
'x-component': 'AssociationField.Viewer',
|
|
91
|
+
'x-component-props': {
|
|
92
|
+
className: 'nb-action-popup'
|
|
93
|
+
},
|
|
94
|
+
properties: {
|
|
95
|
+
tabs: {
|
|
96
|
+
type: 'void',
|
|
97
|
+
'x-component': 'Tabs',
|
|
98
|
+
'x-component-props': {},
|
|
99
|
+
'x-initializer': 'TabPaneInitializers',
|
|
100
|
+
properties: {
|
|
101
|
+
tab1: {
|
|
102
|
+
type: 'void',
|
|
103
|
+
title: '{{t("Details")}}',
|
|
104
|
+
'x-component': 'Tabs.TabPane',
|
|
105
|
+
'x-designer': 'Tabs.Designer',
|
|
106
|
+
'x-component-props': {},
|
|
107
|
+
properties: {
|
|
108
|
+
grid: {
|
|
109
|
+
type: 'void',
|
|
110
|
+
'x-component': 'Grid',
|
|
111
|
+
'x-initializer': 'RecordBlockInitializers',
|
|
112
|
+
properties: {}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
SubTable: {
|
|
121
|
+
type: 'void',
|
|
122
|
+
'x-component': 'AssociationField.SubTable',
|
|
123
|
+
'x-initializer': 'TableColumnInitializers',
|
|
124
|
+
properties: {
|
|
125
|
+
indexCol: {
|
|
126
|
+
type: 'void',
|
|
127
|
+
'x-component': 'TableV2.Column',
|
|
128
|
+
'x-component-props': {
|
|
129
|
+
width: 80
|
|
130
|
+
},
|
|
131
|
+
properties: {
|
|
132
|
+
__index__: {
|
|
133
|
+
type: 'void',
|
|
134
|
+
'x-component': 'TableV2.Index',
|
|
135
|
+
'x-read-pretty': true
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ISchema } from '@formily/react';
|
|
2
|
+
import { CollectionFieldOptions } from '../../../collection-manager';
|
|
3
|
+
export declare const useLabelUiSchema: (collectionField: CollectionFieldOptions, label: string) => ISchema;
|
|
4
|
+
export declare const getDatePickerLabels: (props: any) => string;
|
|
5
|
+
export declare const getLabelFormatValue: (labelUiSchema: ISchema, value: any, isTag?: boolean) => any;
|
|
6
|
+
export declare function flatData(data: any): any[];
|
|
7
|
+
export declare function isShowFilePicker(labelUiSchema: any): boolean;
|
|
8
|
+
export declare const toValue: (value: any, placeholder: any) => any;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
import { isArr } from '@formily/shared';
|
|
14
|
+
import { getDefaultFormat, str2moment } from '@nocobase/utils/client';
|
|
15
|
+
import { Tag } from 'antd';
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { useCollectionManager } from '../../../collection-manager';
|
|
18
|
+
export var useLabelUiSchema = function useLabelUiSchema(collectionField, label) {
|
|
19
|
+
var _useCollectionManager = useCollectionManager(),
|
|
20
|
+
getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
|
|
21
|
+
if (!collectionField) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var labelField = getCollectionJoinField("".concat(collectionField.target, ".").concat(label));
|
|
25
|
+
return labelField === null || labelField === void 0 ? void 0 : labelField.uiSchema;
|
|
26
|
+
};
|
|
27
|
+
export var getDatePickerLabels = function getDatePickerLabels(props) {
|
|
28
|
+
var format = getDefaultFormat(props);
|
|
29
|
+
var m = str2moment(props.value, props);
|
|
30
|
+
var labels = m && m.isValid() ? m.format(format) : props.value;
|
|
31
|
+
return isArr(labels) ? labels.join('~') : labels;
|
|
32
|
+
};
|
|
33
|
+
var toArr = function toArr(v) {
|
|
34
|
+
if (!v) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
return Array.isArray(v) ? v : [v];
|
|
38
|
+
};
|
|
39
|
+
export var getLabelFormatValue = function getLabelFormatValue(labelUiSchema, value) {
|
|
40
|
+
var isTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
41
|
+
var options = labelUiSchema === null || labelUiSchema === void 0 ? void 0 : labelUiSchema.enum;
|
|
42
|
+
if (Array.isArray(options) && value) {
|
|
43
|
+
var values = toArr(value).map(function (val) {
|
|
44
|
+
var opt = options.find(function (option) {
|
|
45
|
+
return option.value === val;
|
|
46
|
+
});
|
|
47
|
+
if (isTag) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
49
|
+
color: opt === null || opt === void 0 ? void 0 : opt.color
|
|
50
|
+
}, opt === null || opt === void 0 ? void 0 : opt.label);
|
|
51
|
+
}
|
|
52
|
+
return opt === null || opt === void 0 ? void 0 : opt.label;
|
|
53
|
+
});
|
|
54
|
+
return isTag ? values : values.join(', ');
|
|
55
|
+
}
|
|
56
|
+
switch (labelUiSchema === null || labelUiSchema === void 0 ? void 0 : labelUiSchema['x-component']) {
|
|
57
|
+
case 'DatePicker':
|
|
58
|
+
return getDatePickerLabels(_objectSpread(_objectSpread({}, labelUiSchema === null || labelUiSchema === void 0 ? void 0 : labelUiSchema['x-component-props']), {}, {
|
|
59
|
+
value: value
|
|
60
|
+
}));
|
|
61
|
+
default:
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export function flatData(data) {
|
|
66
|
+
var newArr = [];
|
|
67
|
+
for (var i = 0; i < data.length; i++) {
|
|
68
|
+
var children = data[i]['children'];
|
|
69
|
+
if (Array.isArray(children)) {
|
|
70
|
+
newArr.push.apply(newArr, _toConsumableArray(flatData(children)));
|
|
71
|
+
}
|
|
72
|
+
newArr.push(_objectSpread({}, data[i]));
|
|
73
|
+
}
|
|
74
|
+
return newArr;
|
|
75
|
+
}
|
|
76
|
+
export function isShowFilePicker(labelUiSchema) {
|
|
77
|
+
return (labelUiSchema === null || labelUiSchema === void 0 ? void 0 : labelUiSchema['x-component']) === 'Preview';
|
|
78
|
+
}
|
|
79
|
+
export var toValue = function toValue(value, placeholder) {
|
|
80
|
+
if (value === null || value === undefined) {
|
|
81
|
+
return placeholder;
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
};
|
package/es/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js
CHANGED
|
@@ -63,10 +63,10 @@ export var AssociationFilterFilterBlockInitializer = function AssociationFilterF
|
|
|
63
63
|
title: t('Association fields'),
|
|
64
64
|
children: children
|
|
65
65
|
};
|
|
66
|
-
//
|
|
66
|
+
// 选项字段
|
|
67
67
|
var optionalFieldGroup = {
|
|
68
68
|
type: 'itemGroup',
|
|
69
|
-
title: t('
|
|
69
|
+
title: t('Choices fields'),
|
|
70
70
|
children: optionalChildren
|
|
71
71
|
};
|
|
72
72
|
var dividerItem = {
|
|
@@ -12,7 +12,7 @@ import { ArrayCollapse, ArrayItems, FormLayout } from '@formily/antd';
|
|
|
12
12
|
import { connect, mapProps, mapReadPretty, useField, useFieldSchema } from '@formily/react';
|
|
13
13
|
import { uid } from '@formily/shared';
|
|
14
14
|
import _ from 'lodash';
|
|
15
|
-
import React, { useCallback, useMemo } from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { useFilterByTk, useFormBlockContext } from '../../../block-provider';
|
|
18
18
|
import { useCollection, useCollectionFilterOptions, useCollectionManager, useSortFields } from '../../../collection-manager';
|
|
@@ -104,6 +104,13 @@ AssociationSelect.Designer = function Designer() {
|
|
|
104
104
|
var defaultSort = ((_field$componentProps = field.componentProps) === null || _field$componentProps === void 0 ? void 0 : (_field$componentProps2 = _field$componentProps.service) === null || _field$componentProps2 === void 0 ? void 0 : (_field$componentProps3 = _field$componentProps2.params) === null || _field$componentProps3 === void 0 ? void 0 : _field$componentProps3.sort) || [];
|
|
105
105
|
var defaultFilter = ((_field$componentProps4 = field.componentProps) === null || _field$componentProps4 === void 0 ? void 0 : (_field$componentProps5 = _field$componentProps4.service) === null || _field$componentProps5 === void 0 ? void 0 : (_field$componentProps6 = _field$componentProps5.params) === null || _field$componentProps6 === void 0 ? void 0 : _field$componentProps6.filter) || {};
|
|
106
106
|
var dataSource = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
|
|
107
|
+
// TODO: 这里 fieldSchema['x-read-pretty'] 的值为 true,但是 field.readPretty 的值却为 false,不知道什么原因
|
|
108
|
+
useEffect(function () {
|
|
109
|
+
// 没有这一步判断会出现禁用状态失效的情况
|
|
110
|
+
if (field.readPretty !== fieldSchema['x-read-pretty']) {
|
|
111
|
+
field.readPretty = !!fieldSchema['x-read-pretty'];
|
|
112
|
+
}
|
|
113
|
+
}, [fieldSchema['x-read-pretty']]);
|
|
107
114
|
var sort = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.map(function (item) {
|
|
108
115
|
return item.startsWith('-') ? {
|
|
109
116
|
field: item.substring(1),
|
|
@@ -389,7 +396,9 @@ AssociationSelect.Designer = function Designer() {
|
|
|
389
396
|
}),
|
|
390
397
|
name: 'default',
|
|
391
398
|
title: t('Default value'),
|
|
392
|
-
default: fieldSchema.default || collectionField.defaultValue
|
|
399
|
+
default: fieldSchema.default || collectionField.defaultValue,
|
|
400
|
+
'x-read-pretty': false,
|
|
401
|
+
'x-disabled': false
|
|
393
402
|
})
|
|
394
403
|
}
|
|
395
404
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ExpandActionDesign: (props: any) => JSX.Element;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { GeneralSchemaDesigner, SchemaSettings } from '../../../schema-settings';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { useFieldSchema, useField } from '@formily/react';
|
|
11
|
+
import { useDesignable } from '../..';
|
|
12
|
+
export var ExpandActionDesign = function ExpandActionDesign(props) {
|
|
13
|
+
var _fieldSchema$xCompon, _fieldSchema$xCompon2;
|
|
14
|
+
var _useTranslation = useTranslation(),
|
|
15
|
+
t = _useTranslation.t;
|
|
16
|
+
var fieldSchema = useFieldSchema();
|
|
17
|
+
var field = useField();
|
|
18
|
+
var _useDesignable = useDesignable(),
|
|
19
|
+
dn = _useDesignable.dn;
|
|
20
|
+
var _ref = fieldSchema['x-component-props'] || {},
|
|
21
|
+
titleExpand = _ref.titleExpand,
|
|
22
|
+
titleCollapse = _ref.titleCollapse,
|
|
23
|
+
iconExpand = _ref.iconExpand,
|
|
24
|
+
iconCollapse = _ref.iconCollapse;
|
|
25
|
+
return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, _objectSpread(_objectSpread({}, props), {}, {
|
|
26
|
+
disableInitializer: true
|
|
27
|
+
}), /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
|
|
28
|
+
title: t('Edit button'),
|
|
29
|
+
schema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
title: t('Edit button'),
|
|
32
|
+
properties: {
|
|
33
|
+
titleExpand: {
|
|
34
|
+
'x-decorator': 'FormItem',
|
|
35
|
+
'x-component': 'Input',
|
|
36
|
+
title: "".concat(t('Button title'), " - ").concat(t('Expand all')),
|
|
37
|
+
default: titleExpand
|
|
38
|
+
},
|
|
39
|
+
titleCollapse: {
|
|
40
|
+
'x-decorator': 'FormItem',
|
|
41
|
+
'x-component': 'Input',
|
|
42
|
+
title: "".concat(t('Button title'), " - ").concat(t('Collapse all')),
|
|
43
|
+
default: titleCollapse
|
|
44
|
+
},
|
|
45
|
+
iconExpand: {
|
|
46
|
+
'x-decorator': 'FormItem',
|
|
47
|
+
'x-component': 'IconPicker',
|
|
48
|
+
title: "".concat(t('Button icon'), " - ").concat(t('Expand all')),
|
|
49
|
+
default: iconExpand
|
|
50
|
+
},
|
|
51
|
+
iconCollapse: {
|
|
52
|
+
'x-decorator': 'FormItem',
|
|
53
|
+
'x-component': 'IconPicker',
|
|
54
|
+
title: "".concat(t('Button icon'), " - ").concat(t('Collapse all')),
|
|
55
|
+
default: iconCollapse
|
|
56
|
+
},
|
|
57
|
+
type: {
|
|
58
|
+
'x-decorator': 'FormItem',
|
|
59
|
+
'x-component': 'Radio.Group',
|
|
60
|
+
title: t('Button background color'),
|
|
61
|
+
default: (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.danger) ? 'danger' : (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.type) === 'primary' ? 'primary' : 'default',
|
|
62
|
+
enum: [{
|
|
63
|
+
value: 'default',
|
|
64
|
+
label: '{{t("Default")}}'
|
|
65
|
+
}, {
|
|
66
|
+
value: 'primary',
|
|
67
|
+
label: '{{t("Highlight")}}'
|
|
68
|
+
}, {
|
|
69
|
+
value: 'danger',
|
|
70
|
+
label: '{{t("Danger red")}}'
|
|
71
|
+
}]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
onSubmit: function onSubmit(_ref2) {
|
|
76
|
+
var titleExpand = _ref2.titleExpand,
|
|
77
|
+
titleCollapse = _ref2.titleCollapse,
|
|
78
|
+
iconExpand = _ref2.iconExpand,
|
|
79
|
+
iconCollapse = _ref2.iconCollapse,
|
|
80
|
+
type = _ref2.type;
|
|
81
|
+
fieldSchema.title = t('Expand/Collapse');
|
|
82
|
+
field.title = t('Expand/Collapse');
|
|
83
|
+
field.componentProps.icon = iconExpand;
|
|
84
|
+
field.componentProps.danger = type === 'danger';
|
|
85
|
+
field.componentProps.type = type;
|
|
86
|
+
fieldSchema['x-component-props'] = _objectSpread(_objectSpread({}, fieldSchema['x-component-props'] || {}), {}, {
|
|
87
|
+
titleExpand: titleExpand,
|
|
88
|
+
titleCollapse: titleCollapse,
|
|
89
|
+
iconExpand: iconExpand,
|
|
90
|
+
iconCollapse: iconCollapse,
|
|
91
|
+
type: type,
|
|
92
|
+
danger: type === 'danger'
|
|
93
|
+
});
|
|
94
|
+
dn.emit('patch', {
|
|
95
|
+
schema: {
|
|
96
|
+
'x-uid': fieldSchema['x-uid'],
|
|
97
|
+
'x-component-props': fieldSchema['x-component-props'],
|
|
98
|
+
title: fieldSchema.title
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
dn.refresh();
|
|
102
|
+
}
|
|
103
|
+
}), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
|
|
104
|
+
removeParentsIfNoChildren: true,
|
|
105
|
+
breakRemoveOn: function breakRemoveOn(s) {
|
|
106
|
+
return s['x-component'] === 'Space' || s['x-component'].endsWith('ActionBar');
|
|
107
|
+
},
|
|
108
|
+
confirm: {
|
|
109
|
+
title: t('Delete action')
|
|
110
|
+
}
|
|
111
|
+
}));
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ExpandAction: (props: any) => JSX.Element;
|