@nocobase/client 0.12.0-alpha.2 → 0.12.0-alpha.4
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/api-client/hooks/useRequest.js +16 -1
- package/es/block-provider/BlockProvider.js +2 -2
- package/es/block-provider/hooks/index.js +16 -18
- package/es/collection-manager/Configuration/AddCollectionAction.js +2 -2
- package/es/collection-manager/Configuration/AddFieldAction.js +2 -1
- package/es/collection-manager/Configuration/EditFieldAction.js +2 -1
- package/es/collection-manager/action-hooks.js +3 -1
- package/es/global-theme/AntdAppProvider.js +5 -1
- package/es/locale/en_US.d.ts +4 -0
- package/es/locale/en_US.js +4 -0
- package/es/locale/ja_JP.d.ts +1 -0
- package/es/locale/ja_JP.js +1 -0
- package/es/locale/zh_CN.d.ts +6 -0
- package/es/locale/zh_CN.js +7 -1
- package/es/pm/Card.js +6 -1
- package/es/schema-component/antd/action/Action.Designer.js +243 -54
- package/es/schema-component/antd/action/Action.Drawer.js +2 -2
- package/es/schema-component/antd/action/Action.Modal.js +1 -1
- package/es/schema-component/antd/action/Action.js +15 -19
- package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
- package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +67 -36
- package/es/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
- package/es/schema-component/antd/association-field/Editable.js +2 -1
- package/es/schema-component/antd/association-field/FileManager.js +4 -3
- package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -1
- package/es/schema-component/antd/association-field/InternalNester.js +6 -4
- package/es/schema-component/antd/association-field/InternalPicker.js +2 -1
- package/es/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
- package/es/schema-component/antd/association-field/InternalPopoverNester.js +95 -0
- package/es/schema-component/antd/association-field/InternalSubTable.js +2 -5
- package/es/schema-component/antd/association-field/InternalViewer.js +1 -1
- package/es/schema-component/antd/association-field/hooks.js +77 -5
- package/es/schema-component/antd/association-field/util.d.ts +4 -0
- package/es/schema-component/antd/association-field/util.js +32 -1
- package/es/schema-component/antd/color-picker/ReadPretty.js +1 -1
- package/es/schema-component/antd/form-item/FormItem.js +36 -112
- package/es/schema-component/antd/form-v2/Templates.js +12 -5
- package/es/schema-component/antd/grid-card/GridCard.Item.js +4 -4
- package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
- package/es/schema-component/antd/list/List.Item.js +3 -3
- package/es/schema-component/antd/markdown/Markdown.Void.js +6 -1
- package/es/schema-component/antd/markdown/Markdown.js +6 -1
- package/es/schema-component/antd/markdown/style.js +2 -4
- package/es/schema-component/antd/quick-edit/QuickEdit.js +5 -3
- package/es/schema-component/antd/remote-select/RemoteSelect.js +11 -79
- package/es/schema-component/antd/rich-text/RichText.js +7 -2
- package/es/schema-component/antd/table-v2/Table.Column.Designer.js +45 -35
- package/es/schema-component/antd/table-v2/Table.js +12 -10
- package/es/schema-component/antd/table-v2/utils.d.ts +5 -0
- package/es/schema-component/antd/table-v2/utils.js +14 -1
- package/es/schema-component/antd/variable/Input.js +2 -1
- package/es/schema-component/antd/variable/TextArea.js +1 -1
- package/es/schema-component/common/utils/uitls.js +19 -2
- package/es/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
- package/es/schema-component/hooks/useFieldModeOptions.js +23 -9
- package/es/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
- package/es/schema-initializer/buttons/FormActionInitializers.js +39 -11
- package/es/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
- package/es/schema-initializer/items/CreateActionInitializer.js +2 -1
- package/es/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
- package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
- package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +74 -0
- package/es/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
- package/es/schema-initializer/items/RecordAssociationListBlockInitializer.js +74 -0
- package/es/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
- package/es/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
- package/es/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
- package/es/schema-initializer/items/index.d.ts +2 -0
- package/es/schema-initializer/items/index.js +2 -0
- package/es/schema-initializer/utils.js +6 -4
- package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
- package/es/schema-settings/DataTemplates/utils.js +1 -1
- package/es/schema-settings/LinkageRules/components/LinkageHeader.js +2 -2
- package/es/schema-settings/SchemaSettings.js +132 -19
- package/es/schema-settings/VariableInput/VariableInput.js +6 -3
- package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
- package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.js +22 -5
- package/es/schema-templates/SchemaTemplateManagerProvider.js +6 -1
- package/lib/api-client/hooks/useRequest.js +16 -1
- package/lib/block-provider/BlockProvider.js +2 -2
- package/lib/block-provider/hooks/index.js +21 -23
- package/lib/collection-manager/Configuration/AddCollectionAction.js +2 -2
- package/lib/collection-manager/Configuration/AddFieldAction.js +2 -1
- package/lib/collection-manager/Configuration/EditFieldAction.js +2 -1
- package/lib/collection-manager/action-hooks.js +3 -1
- package/lib/global-theme/AntdAppProvider.js +5 -1
- package/lib/locale/en_US.d.ts +4 -0
- package/lib/locale/en_US.js +4 -0
- package/lib/locale/ja_JP.d.ts +1 -0
- package/lib/locale/ja_JP.js +1 -0
- package/lib/locale/zh_CN.d.ts +6 -0
- package/lib/locale/zh_CN.js +7 -1
- package/lib/pm/Card.js +6 -1
- package/lib/schema-component/antd/action/Action.Designer.js +242 -53
- package/lib/schema-component/antd/action/Action.Drawer.js +2 -2
- package/lib/schema-component/antd/action/Action.Modal.js +1 -1
- package/lib/schema-component/antd/action/Action.js +15 -19
- package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
- package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +66 -35
- package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
- package/lib/schema-component/antd/association-field/Editable.js +2 -1
- package/lib/schema-component/antd/association-field/FileManager.js +4 -3
- package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -1
- package/lib/schema-component/antd/association-field/InternalNester.js +5 -3
- package/lib/schema-component/antd/association-field/InternalPicker.js +2 -1
- package/lib/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
- package/lib/schema-component/antd/association-field/InternalPopoverNester.js +104 -0
- package/lib/schema-component/antd/association-field/InternalSubTable.js +1 -4
- package/lib/schema-component/antd/association-field/InternalViewer.js +1 -1
- package/lib/schema-component/antd/association-field/hooks.js +76 -4
- package/lib/schema-component/antd/association-field/util.d.ts +4 -0
- package/lib/schema-component/antd/association-field/util.js +37 -2
- package/lib/schema-component/antd/color-picker/ReadPretty.js +1 -1
- package/lib/schema-component/antd/form-item/FormItem.js +34 -110
- package/lib/schema-component/antd/form-v2/Templates.js +12 -5
- package/lib/schema-component/antd/grid-card/GridCard.Item.js +3 -3
- package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
- package/lib/schema-component/antd/list/List.Item.js +2 -2
- package/lib/schema-component/antd/markdown/Markdown.Void.js +6 -1
- package/lib/schema-component/antd/markdown/Markdown.js +6 -1
- package/lib/schema-component/antd/markdown/style.js +2 -4
- package/lib/schema-component/antd/quick-edit/QuickEdit.js +5 -3
- package/lib/schema-component/antd/remote-select/RemoteSelect.js +11 -79
- package/lib/schema-component/antd/rich-text/RichText.js +6 -1
- package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +44 -34
- package/lib/schema-component/antd/table-v2/Table.js +11 -9
- package/lib/schema-component/antd/table-v2/utils.d.ts +5 -0
- package/lib/schema-component/antd/table-v2/utils.js +16 -2
- package/lib/schema-component/antd/variable/Input.js +2 -1
- package/lib/schema-component/antd/variable/TextArea.js +1 -1
- package/lib/schema-component/common/utils/uitls.js +19 -2
- package/lib/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
- package/lib/schema-component/hooks/useFieldModeOptions.js +23 -9
- package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
- package/lib/schema-initializer/buttons/FormActionInitializers.js +39 -11
- package/lib/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
- package/lib/schema-initializer/items/CreateActionInitializer.js +2 -1
- package/lib/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
- package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
- package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +82 -0
- package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
- package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.js +82 -0
- package/lib/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
- package/lib/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
- package/lib/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
- package/lib/schema-initializer/items/index.d.ts +2 -0
- package/lib/schema-initializer/items/index.js +22 -0
- package/lib/schema-initializer/utils.js +6 -4
- package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
- package/lib/schema-settings/DataTemplates/utils.js +1 -1
- package/lib/schema-settings/LinkageRules/components/LinkageHeader.js +1 -1
- package/lib/schema-settings/SchemaSettings.js +131 -18
- package/lib/schema-settings/VariableInput/VariableInput.js +5 -2
- package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
- package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.js +24 -6
- package/lib/schema-templates/SchemaTemplateManagerProvider.js +6 -1
- package/package.json +5 -5
- package/es/schema-component/antd/remote-select/utils.d.ts +0 -4
- package/es/schema-component/antd/remote-select/utils.js +0 -31
- package/lib/schema-component/antd/remote-select/utils.d.ts +0 -4
- package/lib/schema-component/antd/remote-select/utils.js +0 -41
|
@@ -1,18 +1,23 @@
|
|
|
1
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
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 _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); }
|
|
3
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; }
|
|
4
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
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); }
|
|
6
|
-
|
|
7
|
-
import
|
|
7
|
+
import { useField, useFieldSchema, useForm } from '@formily/react';
|
|
8
|
+
import flat from 'flat';
|
|
9
|
+
import { isString } from 'lodash';
|
|
8
10
|
import cloneDeep from 'lodash/cloneDeep';
|
|
9
11
|
import { useCallback, useContext, useMemo } from 'react';
|
|
12
|
+
import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
|
|
10
13
|
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
|
11
14
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
|
12
15
|
import { isInFilterFormBlock } from '../../../filter-provider';
|
|
13
16
|
import { useRecord } from '../../../record-provider';
|
|
17
|
+
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
|
14
18
|
import { useDesignable } from '../../hooks';
|
|
15
19
|
import { AssociationFieldContext } from './context';
|
|
20
|
+
import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './util';
|
|
16
21
|
export var useInsertSchema = function useInsertSchema(component) {
|
|
17
22
|
var fieldSchema = useFieldSchema();
|
|
18
23
|
var _useDesignable = useDesignable(),
|
|
@@ -34,18 +39,85 @@ export function useAssociationFieldContext() {
|
|
|
34
39
|
return useContext(AssociationFieldContext);
|
|
35
40
|
}
|
|
36
41
|
export default function useServiceOptions(props) {
|
|
42
|
+
var _ctx$props, _field$componentProps4, _field$componentProps5, _field$componentProps6, _service$params2;
|
|
37
43
|
var _props$action = props.action,
|
|
38
44
|
action = _props$action === void 0 ? 'list' : _props$action,
|
|
39
45
|
service = props.service,
|
|
40
46
|
fieldNames = props.fieldNames;
|
|
41
47
|
var params = (service === null || service === void 0 ? void 0 : service.params) || {};
|
|
42
48
|
var fieldSchema = useFieldSchema();
|
|
49
|
+
var field = useField();
|
|
50
|
+
var form = useForm();
|
|
51
|
+
var ctx = useBlockRequestContext();
|
|
43
52
|
var _useCollection = useCollection(),
|
|
44
53
|
getField = _useCollection.getField;
|
|
45
54
|
var _useCollectionManager = useCollectionManager(),
|
|
46
55
|
getCollectionFields = _useCollectionManager.getCollectionFields,
|
|
47
56
|
getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
|
|
48
57
|
var record = useRecord();
|
|
58
|
+
var parseFilter = useCallback(function (rules) {
|
|
59
|
+
if (!rules) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
if (typeof rules === 'string') {
|
|
63
|
+
return rules;
|
|
64
|
+
}
|
|
65
|
+
var type = Object.keys(rules)[0] || '$and';
|
|
66
|
+
var conditions = rules[type];
|
|
67
|
+
var results = [];
|
|
68
|
+
conditions === null || conditions === void 0 ? void 0 : conditions.forEach(function (c) {
|
|
69
|
+
var _jsonlogic$value, _jsonlogic$value$matc;
|
|
70
|
+
var jsonlogic = getInnermostKeyAndValue(c);
|
|
71
|
+
var regex = /{{(.*?)}}/;
|
|
72
|
+
var matches = (_jsonlogic$value = jsonlogic.value) === null || _jsonlogic$value === void 0 ? void 0 : (_jsonlogic$value$matc = _jsonlogic$value.match) === null || _jsonlogic$value$matc === void 0 ? void 0 : _jsonlogic$value$matc.call(_jsonlogic$value, regex);
|
|
73
|
+
if (!matches || !matches[1].includes('$form') && !matches[1].includes('$iteration')) {
|
|
74
|
+
results.push(c);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
var associationfield = extractFilterfield(matches[1]);
|
|
78
|
+
var filterCollectionField = getCollectionJoinField("".concat(ctx.props.collection, ".").concat(associationfield));
|
|
79
|
+
if (['o2m', 'm2m'].includes(filterCollectionField === null || filterCollectionField === void 0 ? void 0 : filterCollectionField.interface)) {
|
|
80
|
+
// 对多子表单
|
|
81
|
+
var pattern = generatePattern(matches === null || matches === void 0 ? void 0 : matches[1], associationfield);
|
|
82
|
+
var parseValue = extractValuesByPattern(flat(form.values), pattern);
|
|
83
|
+
var filters = parseValue.map(function (v) {
|
|
84
|
+
return JSON.parse(JSON.stringify(c).replace(jsonlogic.value, v));
|
|
85
|
+
});
|
|
86
|
+
results.push({
|
|
87
|
+
$or: filters
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
var variablesCtx = {
|
|
91
|
+
$form: form.values,
|
|
92
|
+
$iteration: form.values
|
|
93
|
+
};
|
|
94
|
+
var str = matches === null || matches === void 0 ? void 0 : matches[1];
|
|
95
|
+
if (str.includes('$iteration')) {
|
|
96
|
+
var path = field.path.segments.concat([]);
|
|
97
|
+
path.pop();
|
|
98
|
+
str = str.replace('$iteration.', "$iteration.".concat(path.join('.'), "."));
|
|
99
|
+
}
|
|
100
|
+
var _parseValue = parseVariables(str, variablesCtx);
|
|
101
|
+
if (Array.isArray(_parseValue)) {
|
|
102
|
+
var _filters = _parseValue.map(function (v) {
|
|
103
|
+
return JSON.parse(JSON.stringify(c).replace(jsonlogic.value, v));
|
|
104
|
+
});
|
|
105
|
+
results.push({
|
|
106
|
+
$or: _filters
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
var filterObj = JSON.parse(JSON.stringify(c).replace(jsonlogic.value, str.endsWith('id') ? _parseValue !== null && _parseValue !== void 0 ? _parseValue : 0 : _parseValue));
|
|
110
|
+
results.push(filterObj);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return _defineProperty({}, type, results);
|
|
115
|
+
}, [(_ctx$props = ctx.props) === null || _ctx$props === void 0 ? void 0 : _ctx$props.collection, field.path.segments, form.values, getCollectionJoinField]);
|
|
116
|
+
var fieldServiceFilter = useMemo(function () {
|
|
117
|
+
var _fieldSchema$xCompon, _fieldSchema$xCompon$, _fieldSchema$xCompon$2, _field$componentProps, _field$componentProps2, _field$componentProps3, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _service$params;
|
|
118
|
+
var filterFromSchema = isString(fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : (_fieldSchema$xCompon$ = _fieldSchema$xCompon.service) === null || _fieldSchema$xCompon$ === void 0 ? void 0 : (_fieldSchema$xCompon$2 = _fieldSchema$xCompon$.params) === null || _fieldSchema$xCompon$2 === void 0 ? void 0 : _fieldSchema$xCompon$2.filter) ? (_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.filter : fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : (_fieldSchema$xCompon3 = _fieldSchema$xCompon2.service) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.params) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.filter;
|
|
119
|
+
return mergeFilter([parseFilter(filterFromSchema) || (service === null || service === void 0 ? void 0 : (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params.filter)]);
|
|
120
|
+
}, [(_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, fieldSchema, parseFilter, service === null || service === void 0 ? void 0 : (_service$params2 = service.params) === null || _service$params2 === void 0 ? void 0 : _service$params2.filter]);
|
|
49
121
|
var normalizeValues = useCallback(function (obj) {
|
|
50
122
|
if (obj && _typeof(obj) === 'object') {
|
|
51
123
|
return obj[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value];
|
|
@@ -70,7 +142,7 @@ export default function useServiceOptions(props) {
|
|
|
70
142
|
var isOToAny = ['oho', 'o2m'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
|
|
71
143
|
return mergeFilter([mergeFilter([isOToAny && !isInFilterFormBlock(fieldSchema) && collectionField !== null && collectionField !== void 0 && collectionField.foreignKey ? _defineProperty({}, collectionField.foreignKey, {
|
|
72
144
|
$is: null
|
|
73
|
-
}) : null,
|
|
145
|
+
}) : null, fieldServiceFilter]), isOToAny && sourceValue !== undefined && sourceValue !== null && !isInFilterFormBlock(fieldSchema) && collectionField !== null && collectionField !== void 0 && collectionField.foreignKey ? _defineProperty({}, collectionField.foreignKey, {
|
|
74
146
|
$eq: sourceValue
|
|
75
147
|
}) : null, params !== null && params !== void 0 && params.filter && value ? _defineProperty({}, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value, _defineProperty({}, '$in', value)) : null], '$or');
|
|
76
148
|
}, [params === null || params === void 0 ? void 0 : params.filter, getCollectionFields, collectionField, sourceValue, value, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value]);
|
|
@@ -86,9 +158,9 @@ export default function useServiceOptions(props) {
|
|
|
86
158
|
}, [collectionField === null || collectionField === void 0 ? void 0 : collectionField.target, action, filter, service]);
|
|
87
159
|
}
|
|
88
160
|
export var useFieldNames = function useFieldNames(props) {
|
|
89
|
-
var _fieldSchema$
|
|
161
|
+
var _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _fieldSchema$xCompon8, _fieldSchema$xCompon9;
|
|
90
162
|
var fieldSchema = useFieldSchema();
|
|
91
|
-
var fieldNames = ((_fieldSchema$
|
|
163
|
+
var fieldNames = ((_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : (_fieldSchema$xCompon6 = _fieldSchema$xCompon5['field']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : (_fieldSchema$xCompon7 = _fieldSchema$xCompon6['uiSchema']) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : (_fieldSchema$xCompon8 = _fieldSchema$xCompon7['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : _fieldSchema$xCompon8['fieldNames']) || (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon9 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon9 === void 0 ? void 0 : _fieldSchema$xCompon9['fieldNames']) || props.fieldNames;
|
|
92
164
|
return _objectSpread({
|
|
93
165
|
label: 'label',
|
|
94
166
|
value: 'value'
|
|
@@ -6,3 +6,7 @@ export declare const getTabFormatValue: (labelUiSchema: ISchema, value: any, tag
|
|
|
6
6
|
export declare function flatData(data: any): any[];
|
|
7
7
|
export declare function isShowFilePicker(labelUiSchema: any): boolean;
|
|
8
8
|
export declare const toValue: (value: any, placeholder: any) => any;
|
|
9
|
+
export declare const parseVariables: (str: string, ctx: any) => any;
|
|
10
|
+
export declare function extractFilterfield(str: any): any;
|
|
11
|
+
export declare function extractValuesByPattern(obj: any, pattern: any): any[];
|
|
12
|
+
export declare function generatePattern(str: any, fieldName: any): any;
|
|
@@ -13,6 +13,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
13
13
|
import { isArr } from '@formily/shared';
|
|
14
14
|
import { getDefaultFormat, str2moment } from '@nocobase/utils/client';
|
|
15
15
|
import { Tag } from 'antd';
|
|
16
|
+
import { get, isFunction } from 'lodash';
|
|
16
17
|
import React from 'react';
|
|
17
18
|
import { useCollectionManager } from '../../../collection-manager';
|
|
18
19
|
export var useLabelUiSchema = function useLabelUiSchema(collectionName, label) {
|
|
@@ -107,4 +108,34 @@ export var toValue = function toValue(value, placeholder) {
|
|
|
107
108
|
return placeholder;
|
|
108
109
|
}
|
|
109
110
|
return value;
|
|
110
|
-
};
|
|
111
|
+
};
|
|
112
|
+
export var parseVariables = function parseVariables(str, ctx) {
|
|
113
|
+
if (str) {
|
|
114
|
+
var result = get(ctx, str);
|
|
115
|
+
return isFunction(result) ? result() : result;
|
|
116
|
+
} else {
|
|
117
|
+
return str;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export function extractFilterfield(str) {
|
|
121
|
+
var match = str.match(/^\$form\.([^.[\]]+)/);
|
|
122
|
+
if (match) {
|
|
123
|
+
return match[1];
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
export function extractValuesByPattern(obj, pattern) {
|
|
128
|
+
var regexPattern = new RegExp(pattern.replace(/\*/g, '\\d+'));
|
|
129
|
+
var result = [];
|
|
130
|
+
for (var key in obj) {
|
|
131
|
+
if (regexPattern.test(key)) {
|
|
132
|
+
var value = obj[key];
|
|
133
|
+
result.push(value);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
export function generatePattern(str, fieldName) {
|
|
139
|
+
var result = str.replace("$form.".concat(fieldName, "."), "".concat(fieldName, ".*."));
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
@@ -14,7 +14,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
|
14
14
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
15
|
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; }
|
|
16
16
|
import { css, cx } from '@emotion/css';
|
|
17
|
-
import { ArrayCollapse,
|
|
17
|
+
import { ArrayCollapse, FormLayout, FormItem as Item } from '@formily/antd-v5';
|
|
18
18
|
import { observer, useField, useFieldSchema } from '@formily/react';
|
|
19
19
|
import { Select } from 'antd';
|
|
20
20
|
import dayjs from 'dayjs';
|
|
@@ -24,7 +24,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
24
24
|
import { ACLCollectionFieldProvider } from '../../../acl/ACLProvider';
|
|
25
25
|
import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
|
|
26
26
|
import { useFormBlockContext } from '../../../block-provider/FormBlockProvider';
|
|
27
|
-
import { useCollection, useCollectionFilterOptions, useCollectionManager
|
|
27
|
+
import { useCollection, useCollectionFilterOptions, useCollectionManager } from '../../../collection-manager';
|
|
28
28
|
import { isTitleField } from '../../../collection-manager/Configuration/CollectionFields';
|
|
29
29
|
import { GeneralSchemaItems } from '../../../schema-items/GeneralSchemaItems';
|
|
30
30
|
import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled, isShowDefaultValue } from '../../../schema-settings';
|
|
@@ -58,6 +58,23 @@ export var findColumnFieldSchema = function findColumnFieldSchema(fieldSchema, g
|
|
|
58
58
|
getAssociationAppends(fieldSchema);
|
|
59
59
|
return _toConsumableArray(childsSchema);
|
|
60
60
|
};
|
|
61
|
+
function transformData(inputData) {
|
|
62
|
+
var transformedData = [];
|
|
63
|
+
var keys = Object.keys(inputData) || [];
|
|
64
|
+
var values = Object.values(inputData) || [];
|
|
65
|
+
var _loop = function _loop(i) {
|
|
66
|
+
var newObj = {};
|
|
67
|
+
keys.forEach(function (key, index) {
|
|
68
|
+
newObj[key] = values[index][i];
|
|
69
|
+
});
|
|
70
|
+
transformedData.push(newObj);
|
|
71
|
+
};
|
|
72
|
+
for (var i = 0; i < ((_values$ = values[0]) === null || _values$ === void 0 ? void 0 : _values$.length); i++) {
|
|
73
|
+
var _values$;
|
|
74
|
+
_loop(i);
|
|
75
|
+
}
|
|
76
|
+
return transformedData;
|
|
77
|
+
}
|
|
61
78
|
export var FormItem = observer(function (props) {
|
|
62
79
|
var _schema$xDecoratorP, _schema$xDecoratorP2;
|
|
63
80
|
useEnsureOperatorsValid();
|
|
@@ -89,24 +106,26 @@ export var FormItem = observer(function (props) {
|
|
|
89
106
|
});
|
|
90
107
|
iniValues = iniValues.concat(data);
|
|
91
108
|
});
|
|
92
|
-
|
|
109
|
+
var data = _.uniqBy(iniValues, 'id');
|
|
110
|
+
(_field$setInitialValu2 = field.setInitialValue) === null || _field$setInitialValu2 === void 0 ? void 0 : _field$setInitialValu2.call(field, data.length > 0 ? data : [{}]);
|
|
93
111
|
} else if ((collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'o2m' && ['SubTable', 'Nester'].includes(schema === null || schema === void 0 ? void 0 : (_schema$xComponentP = schema['x-component-props']) === null || _schema$xComponentP === void 0 ? void 0 : _schema$xComponentP['mode']) // 间接对多
|
|
94
112
|
) {
|
|
95
113
|
var childrenFieldWithDefault = findColumnFieldSchema(schema, getCollectionJoinField);
|
|
96
114
|
// 子表格/子表单中找出所有belongsTo字段的上下文默认值
|
|
97
115
|
if (childrenFieldWithDefault.length > 0) {
|
|
98
116
|
var _field$setInitialValu3;
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
var tableData = parseVariables('{{$context}}', variablesCtx);
|
|
118
|
+
var _contextData = {};
|
|
119
|
+
// 将数据拍平
|
|
120
|
+
childrenFieldWithDefault === null || childrenFieldWithDefault === void 0 ? void 0 : childrenFieldWithDefault.forEach(function (s) {
|
|
121
|
+
var child = JSON.parse(s);
|
|
122
|
+
tableData === null || tableData === void 0 ? void 0 : tableData.map(function (v) {
|
|
123
|
+
_contextData[child.name] = _.uniqBy((_contextData[child.name] || []).concat(parseVariables(child.default, {
|
|
105
124
|
$context: v
|
|
106
|
-
});
|
|
125
|
+
})), 'id');
|
|
107
126
|
});
|
|
108
|
-
return obj;
|
|
109
127
|
});
|
|
128
|
+
var initValues = transformData(_contextData);
|
|
110
129
|
(_field$setInitialValu3 = field.setInitialValue) === null || _field$setInitialValu3 === void 0 ? void 0 : _field$setInitialValu3.call(field, initValues);
|
|
111
130
|
}
|
|
112
131
|
}
|
|
@@ -128,7 +147,7 @@ export var FormItem = observer(function (props) {
|
|
|
128
147
|
displayName: 'FormItem'
|
|
129
148
|
});
|
|
130
149
|
FormItem.Designer = function Designer() {
|
|
131
|
-
var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _collectionField$targ, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _field$componentProps,
|
|
150
|
+
var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _collectionField$targ, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _field$componentProps, _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _fieldSchema$xCompon8, _fieldSchema$xCompon9, _fieldSchema$xCompon10, _fieldSchema$xCompon11, _field$componentProps2, _fieldSchema$xCompon12, _fieldSchema$xCompon13, _fieldSchema$xCompon14, _field$componentProps3, _field$componentProps4, _field$componentProps5;
|
|
132
151
|
var targetField;
|
|
133
152
|
var _useCollectionManager2 = useCollectionManager(),
|
|
134
153
|
getCollectionFields = _useCollectionManager2.getCollectionFields,
|
|
@@ -189,19 +208,8 @@ FormItem.Designer = function Designer() {
|
|
|
189
208
|
}
|
|
190
209
|
var dataSource = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
|
|
191
210
|
var defaultFilter = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : (_fieldSchema$xCompon3 = _fieldSchema$xCompon2.service) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.params) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.filter) || {};
|
|
192
|
-
var
|
|
193
|
-
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) || [];
|
|
194
|
-
var fieldMode = (field === null || field === void 0 ? void 0 : (_field$componentProps4 = field.componentProps) === null || _field$componentProps4 === void 0 ? void 0 : _field$componentProps4['mode']) || (isFileField ? 'FileManager' : 'Select');
|
|
211
|
+
var fieldMode = (field === null || field === void 0 ? void 0 : (_field$componentProps = field.componentProps) === null || _field$componentProps === void 0 ? void 0 : _field$componentProps['mode']) || (isFileField ? 'FileManager' : 'Select');
|
|
195
212
|
var isSelectFieldMode = isAssociationField && fieldMode === 'Select';
|
|
196
|
-
var sort = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.map(function (item) {
|
|
197
|
-
return item !== null && item !== void 0 && item.startsWith('-') ? {
|
|
198
|
-
field: item.substring(1),
|
|
199
|
-
direction: 'desc'
|
|
200
|
-
} : {
|
|
201
|
-
field: item,
|
|
202
|
-
direction: 'asc'
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
213
|
var isSubFormMode = ((_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : _fieldSchema$xCompon5.mode) === 'Nester';
|
|
206
214
|
var isPickerMode = ((_fieldSchema$xCompon6 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6.mode) === 'Picker';
|
|
207
215
|
var showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
|
|
@@ -405,91 +413,7 @@ FormItem.Designer = function Designer() {
|
|
|
405
413
|
schema: (_schema4 = {}, _defineProperty(_schema4, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema4, 'x-component-props', field.componentProps), _schema4)
|
|
406
414
|
});
|
|
407
415
|
}
|
|
408
|
-
}), isSelectFieldMode && !field.readPretty && /*#__PURE__*/React.createElement(SchemaSettings.
|
|
409
|
-
title: t('Set default sorting rules'),
|
|
410
|
-
components: {
|
|
411
|
-
ArrayItems: ArrayItems
|
|
412
|
-
},
|
|
413
|
-
schema: {
|
|
414
|
-
type: 'object',
|
|
415
|
-
title: t('Set default sorting rules'),
|
|
416
|
-
properties: {
|
|
417
|
-
sort: {
|
|
418
|
-
type: 'array',
|
|
419
|
-
default: sort,
|
|
420
|
-
'x-component': 'ArrayItems',
|
|
421
|
-
'x-decorator': 'FormItem',
|
|
422
|
-
items: {
|
|
423
|
-
type: 'object',
|
|
424
|
-
properties: {
|
|
425
|
-
space: {
|
|
426
|
-
type: 'void',
|
|
427
|
-
'x-component': 'Space',
|
|
428
|
-
properties: {
|
|
429
|
-
sort: {
|
|
430
|
-
type: 'void',
|
|
431
|
-
'x-decorator': 'FormItem',
|
|
432
|
-
'x-component': 'ArrayItems.SortHandle'
|
|
433
|
-
},
|
|
434
|
-
field: {
|
|
435
|
-
type: 'string',
|
|
436
|
-
enum: sortFields,
|
|
437
|
-
required: true,
|
|
438
|
-
'x-decorator': 'FormItem',
|
|
439
|
-
'x-component': 'Select',
|
|
440
|
-
'x-component-props': {
|
|
441
|
-
style: {
|
|
442
|
-
width: 260
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
direction: {
|
|
447
|
-
type: 'string',
|
|
448
|
-
'x-decorator': 'FormItem',
|
|
449
|
-
'x-component': 'Radio.Group',
|
|
450
|
-
'x-component-props': {
|
|
451
|
-
optionType: 'button'
|
|
452
|
-
},
|
|
453
|
-
enum: [{
|
|
454
|
-
label: t('ASC'),
|
|
455
|
-
value: 'asc'
|
|
456
|
-
}, {
|
|
457
|
-
label: t('DESC'),
|
|
458
|
-
value: 'desc'
|
|
459
|
-
}]
|
|
460
|
-
},
|
|
461
|
-
remove: {
|
|
462
|
-
type: 'void',
|
|
463
|
-
'x-decorator': 'FormItem',
|
|
464
|
-
'x-component': 'ArrayItems.Remove'
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
properties: {
|
|
471
|
-
add: {
|
|
472
|
-
type: 'void',
|
|
473
|
-
title: t('Add sort field'),
|
|
474
|
-
'x-component': 'ArrayItems.Addition'
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
},
|
|
480
|
-
onSubmit: function onSubmit(_ref2) {
|
|
481
|
-
var _schema5;
|
|
482
|
-
var sort = _ref2.sort;
|
|
483
|
-
var sortArr = sort.map(function (item) {
|
|
484
|
-
return item.direction === 'desc' ? "-".concat(item.field) : item.field;
|
|
485
|
-
});
|
|
486
|
-
_.set(field.componentProps, 'service.params.sort', sortArr);
|
|
487
|
-
fieldSchema['x-component-props'] = field.componentProps;
|
|
488
|
-
dn.emit('patch', {
|
|
489
|
-
schema: (_schema5 = {}, _defineProperty(_schema5, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema5, 'x-component-props', field.componentProps), _schema5)
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
}), showFieldMode && /*#__PURE__*/React.createElement(SchemaSettings.SelectItem, {
|
|
416
|
+
}), isSelectFieldMode && !field.readPretty && /*#__PURE__*/React.createElement(SchemaSettings.SortingRule, null), showFieldMode && /*#__PURE__*/React.createElement(SchemaSettings.SelectItem, {
|
|
493
417
|
key: "field-mode",
|
|
494
418
|
title: t('Field component'),
|
|
495
419
|
options: fieldModeOptions,
|
|
@@ -588,7 +512,7 @@ FormItem.Designer = function Designer() {
|
|
|
588
512
|
label: t('Pop-up'),
|
|
589
513
|
value: 'modalAdd'
|
|
590
514
|
}],
|
|
591
|
-
value: ((_field$
|
|
515
|
+
value: ((_field$componentProps2 = field.componentProps) === null || _field$componentProps2 === void 0 ? void 0 : _field$componentProps2.addMode) || 'none',
|
|
592
516
|
onChange: function onChange(mode) {
|
|
593
517
|
if (mode === 'modalAdd') {
|
|
594
518
|
var hasAddNew = fieldSchema.reduceProperties(function (buf, schema) {
|
|
@@ -728,7 +652,7 @@ FormItem.Designer = function Designer() {
|
|
|
728
652
|
key: "title-field",
|
|
729
653
|
title: t('Title field'),
|
|
730
654
|
options: options,
|
|
731
|
-
value: field === null || field === void 0 ? void 0 : (_field$
|
|
655
|
+
value: field === null || field === void 0 ? void 0 : (_field$componentProps3 = field.componentProps) === null || _field$componentProps3 === void 0 ? void 0 : (_field$componentProps4 = _field$componentProps3.fieldNames) === null || _field$componentProps4 === void 0 ? void 0 : _field$componentProps4.label,
|
|
732
656
|
onChange: function onChange(label) {
|
|
733
657
|
var _collectionField$uiSc3, _collectionField$uiSc4;
|
|
734
658
|
var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
|
|
@@ -750,7 +674,7 @@ FormItem.Designer = function Designer() {
|
|
|
750
674
|
key: "title-field",
|
|
751
675
|
title: t('Tag color field'),
|
|
752
676
|
options: colorFieldOptions,
|
|
753
|
-
value: field === null || field === void 0 ? void 0 : (_field$
|
|
677
|
+
value: field === null || field === void 0 ? void 0 : (_field$componentProps5 = field.componentProps) === null || _field$componentProps5 === void 0 ? void 0 : _field$componentProps5.tagColorField,
|
|
754
678
|
onChange: function onChange(tagColorField) {
|
|
755
679
|
var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
|
|
756
680
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
|
@@ -113,6 +113,13 @@ export var Templates = function Templates(_ref) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}, []);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
if (!(templateOptions !== null && templateOptions !== void 0 && templateOptions.some(function (v) {
|
|
118
|
+
return v.key === targetTemplate;
|
|
119
|
+
}))) {
|
|
120
|
+
handleTemplateChange('none');
|
|
121
|
+
}
|
|
122
|
+
}, [templateOptions]);
|
|
116
123
|
var wrapperStyle = useMemo(function () {
|
|
117
124
|
return _objectSpread({
|
|
118
125
|
display: 'flex',
|
|
@@ -130,7 +137,7 @@ export var Templates = function Templates(_ref) {
|
|
|
130
137
|
};
|
|
131
138
|
}, [token.fontSize, token.marginXS]);
|
|
132
139
|
var handleTemplateChange = useCallback( /*#__PURE__*/function () {
|
|
133
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value
|
|
140
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
|
|
134
141
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
135
142
|
while (1) switch (_context.prev = _context.next) {
|
|
136
143
|
case 0:
|
|
@@ -143,7 +150,7 @@ export var Templates = function Templates(_ref) {
|
|
|
143
150
|
}
|
|
144
151
|
}, _callee);
|
|
145
152
|
}));
|
|
146
|
-
return function (_x2
|
|
153
|
+
return function (_x2) {
|
|
147
154
|
return _ref2.apply(this, arguments);
|
|
148
155
|
};
|
|
149
156
|
}(), []);
|
|
@@ -178,7 +185,7 @@ export var Templates = function Templates(_ref) {
|
|
|
178
185
|
}
|
|
179
186
|
}, _callee2);
|
|
180
187
|
}));
|
|
181
|
-
return function (
|
|
188
|
+
return function (_x3, _x4) {
|
|
182
189
|
return _ref3.apply(this, arguments);
|
|
183
190
|
};
|
|
184
191
|
}(), []);
|
|
@@ -203,7 +210,7 @@ export var Templates = function Templates(_ref) {
|
|
|
203
210
|
},
|
|
204
211
|
value: targetTemplate,
|
|
205
212
|
onChange: handleTemplateChange
|
|
206
|
-
}), targetTemplate !== 'none' && /*#__PURE__*/React.createElement(RemoteSelect, {
|
|
213
|
+
}), targetTemplate !== 'none' && template && /*#__PURE__*/React.createElement(RemoteSelect, {
|
|
207
214
|
style: {
|
|
208
215
|
width: 220
|
|
209
216
|
},
|
|
@@ -233,7 +240,7 @@ function findDataTemplates(fieldSchema) {
|
|
|
233
240
|
}
|
|
234
241
|
return {};
|
|
235
242
|
}
|
|
236
|
-
export function fetchTemplateData(_x6, _x7
|
|
243
|
+
export function fetchTemplateData(_x5, _x6, _x7) {
|
|
237
244
|
return _fetchTemplateData.apply(this, arguments);
|
|
238
245
|
}
|
|
239
246
|
function _fetchTemplateData() {
|
|
@@ -4,15 +4,15 @@ import { css } from '@emotion/css';
|
|
|
4
4
|
import { useField } from '@formily/react';
|
|
5
5
|
import { Card } from 'antd';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { RecordProvider } from '../../../record-provider';
|
|
8
8
|
var itemCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n height: 100%;\n flex-direction: column;\n justify-content: space-between;\n gap: 8px;\n"])));
|
|
9
9
|
export var GridCardItem = function GridCardItem(props) {
|
|
10
10
|
var field = useField();
|
|
11
11
|
return /*#__PURE__*/React.createElement(Card, {
|
|
12
|
-
className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 100%;\n > .ant-card-body {\n padding: 24px 24px 0px;\n height: 100%;\n }\n .nb-action-bar
|
|
12
|
+
className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 100%;\n > .ant-card-body {\n padding: 24px 24px 0px;\n height: 100%;\n }\n .nb-action-bar {\n padding: 5px 0;\n }\n "])))
|
|
13
13
|
}, /*#__PURE__*/React.createElement("div", {
|
|
14
14
|
className: itemCss
|
|
15
|
-
}, /*#__PURE__*/React.createElement(
|
|
16
|
-
|
|
15
|
+
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
16
|
+
record: field.value
|
|
17
17
|
}, props.children)));
|
|
18
18
|
};
|
|
@@ -60,7 +60,8 @@ export var EllipsisWithTooltip = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
60
60
|
content: /*#__PURE__*/React.createElement("div", {
|
|
61
61
|
style: {
|
|
62
62
|
width: 300,
|
|
63
|
-
|
|
63
|
+
overflow: 'auto',
|
|
64
|
+
maxHeight: 400
|
|
64
65
|
}
|
|
65
66
|
}, popoverContent || props.children)
|
|
66
67
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useField } from '@formily/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { RecordProvider } from '../../../record-provider';
|
|
4
4
|
export var ListItem = function ListItem(props) {
|
|
5
5
|
var field = useField();
|
|
6
6
|
return /*#__PURE__*/React.createElement("div", {
|
|
7
7
|
className: 'itemCss'
|
|
8
|
-
}, /*#__PURE__*/React.createElement(
|
|
9
|
-
|
|
8
|
+
}, /*#__PURE__*/React.createElement(RecordProvider, {
|
|
9
|
+
record: field.value
|
|
10
10
|
}, props.children));
|
|
11
11
|
};
|
|
@@ -18,6 +18,7 @@ import { Input as AntdInput, Button, Space, Spin } from 'antd';
|
|
|
18
18
|
import cls from 'classnames';
|
|
19
19
|
import React, { useState } from 'react';
|
|
20
20
|
import { useTranslation } from 'react-i18next';
|
|
21
|
+
import { useGlobalTheme } from '../../../global-theme';
|
|
21
22
|
import { useDesignable } from '../../hooks/useDesignable';
|
|
22
23
|
import { MarkdownVoidDesigner } from './Markdown.Void.Designer';
|
|
23
24
|
import { useStyles } from './style';
|
|
@@ -63,7 +64,11 @@ var MarkdownEditor = function MarkdownEditor(props) {
|
|
|
63
64
|
}, t('Save'))));
|
|
64
65
|
};
|
|
65
66
|
export var MarkdownVoid = observer(function (props) {
|
|
66
|
-
var
|
|
67
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
68
|
+
isDarkTheme = _useGlobalTheme.isDarkTheme;
|
|
69
|
+
var _useStyles = useStyles({
|
|
70
|
+
isDarkTheme: isDarkTheme
|
|
71
|
+
}),
|
|
67
72
|
componentCls = _useStyles.componentCls,
|
|
68
73
|
hashId = _useStyles.hashId;
|
|
69
74
|
var content = props.content,
|
|
@@ -8,6 +8,7 @@ import { LoadingOutlined } from '@ant-design/icons';
|
|
|
8
8
|
import { connect, mapProps, mapReadPretty } from '@formily/react';
|
|
9
9
|
import { Input as AntdInput, Spin } from 'antd';
|
|
10
10
|
import React from 'react';
|
|
11
|
+
import { useGlobalTheme } from '../../../global-theme';
|
|
11
12
|
import { ReadPretty as InputReadPretty } from '../input';
|
|
12
13
|
import { MarkdownVoid } from './Markdown.Void';
|
|
13
14
|
import { useStyles } from './style';
|
|
@@ -25,7 +26,11 @@ export var Markdown = connect(AntdInput.TextArea, mapProps(function (props, fiel
|
|
|
25
26
|
return /*#__PURE__*/React.createElement(MarkdownReadPretty, _objectSpread({}, props));
|
|
26
27
|
}));
|
|
27
28
|
export var MarkdownReadPretty = function MarkdownReadPretty(props) {
|
|
28
|
-
var
|
|
29
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
30
|
+
isDarkTheme = _useGlobalTheme.isDarkTheme;
|
|
31
|
+
var _useStyles = useStyles({
|
|
32
|
+
isDarkTheme: isDarkTheme
|
|
33
|
+
}),
|
|
29
34
|
wrapSSR = _useStyles.wrapSSR,
|
|
30
35
|
hashId = _useStyles.hashId,
|
|
31
36
|
className = _useStyles.componentCls;
|
|
@@ -5,12 +5,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
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
7
|
import { TinyColor } from '@ctrl/tinycolor';
|
|
8
|
-
import { useGlobalTheme } from '../../../global-theme';
|
|
9
8
|
import { genStyleHook } from './../__builtins__';
|
|
10
|
-
export var useStyles = genStyleHook('nb-markdown', function (token) {
|
|
9
|
+
export var useStyles = genStyleHook('nb-markdown', function (token, _ref) {
|
|
10
|
+
var isDarkTheme = _ref.isDarkTheme;
|
|
11
11
|
var componentCls = token.componentCls;
|
|
12
|
-
var _useGlobalTheme = useGlobalTheme(),
|
|
13
|
-
isDarkTheme = _useGlobalTheme.isDarkTheme;
|
|
14
12
|
var colorFillAlterSolid = new TinyColor(token.colorFillAlter).onBackground(token.colorBgContainer).toHexShortString();
|
|
15
13
|
var defaultStyle = {
|
|
16
14
|
// default style of markdown
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
|
-
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); }
|
|
3
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
3
|
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; }
|
|
5
4
|
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; }
|
|
6
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
7
|
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); }
|
|
8
|
+
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); }
|
|
9
9
|
import { css } from '@emotion/css';
|
|
10
10
|
import { FormItem } from '@formily/antd-v5';
|
|
11
11
|
import { createForm } from '@formily/core';
|
|
@@ -14,20 +14,22 @@ import { Popover } from 'antd';
|
|
|
14
14
|
import React, { useMemo, useRef } from 'react';
|
|
15
15
|
import { useCollectionManager } from '../../../collection-manager';
|
|
16
16
|
export var Editable = observer(function (props) {
|
|
17
|
+
var _field$value;
|
|
17
18
|
var field = useField();
|
|
18
19
|
var containerRef = useRef(null);
|
|
19
20
|
var fieldSchema = useFieldSchema();
|
|
21
|
+
var value = _typeof(field.value) === 'object' ? (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.default : field.value;
|
|
20
22
|
var schema = {
|
|
21
23
|
name: fieldSchema.name,
|
|
22
24
|
'x-collection-field': fieldSchema['x-collection-field'],
|
|
23
25
|
'x-component': 'CollectionField',
|
|
24
26
|
'x-read-pretty': true,
|
|
25
|
-
default:
|
|
27
|
+
default: value,
|
|
26
28
|
'x-component-props': fieldSchema['x-component-props']
|
|
27
29
|
};
|
|
28
30
|
var form = useMemo(function () {
|
|
29
31
|
return createForm({
|
|
30
|
-
values: _defineProperty({}, fieldSchema.name,
|
|
32
|
+
values: _defineProperty({}, fieldSchema.name, value)
|
|
31
33
|
});
|
|
32
34
|
}, [field.value, fieldSchema['x-component-props']]);
|
|
33
35
|
var getContainer = function getContainer() {
|