@nocobase/plugin-snapshot-field 0.9.1-alpha.2 → 0.9.2-alpha.2
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/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.js +2 -13
- package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.js +21 -54
- package/lib/client/SnapshotBlock/SnapshotBlockProvider.js +9 -43
- package/lib/client/SnapshotHistoryCollectionProvider.js +16 -33
- package/lib/client/SnapshotRecordPicker.js +6 -29
- package/lib/client/components/AppendsTreeSelect.js +12 -57
- package/lib/client/components/SnapshotOwnerCollectionFieldsSelect.js +4 -23
- package/lib/client/index.js +5 -29
- package/lib/client/interface.js +8 -37
- package/lib/client/locale/index.js +2 -11
- package/lib/client/locale/pt-BR.d.ts +12 -0
- package/lib/client/locale/pt-BR.js +18 -0
- package/lib/index.js +0 -2
- package/lib/server/collections/collectionsHistory.js +1 -1
- package/lib/server/collections/fieldsHistory.js +9 -7
- package/lib/server/fields/snapshot-field.js +2 -25
- package/lib/server/index.js +0 -2
- package/lib/server/plugin.js +4 -57
- package/package.json +4 -4
- package/src/client/index.tsx +5 -9
- package/src/client/locale/pt-BR.ts +12 -0
- package/src/server/collections/collectionsHistory.ts +1 -1
- package/src/server/collections/fieldsHistory.ts +7 -7
|
@@ -4,37 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SnapshotBlockInitializers = void 0;
|
|
7
|
-
|
|
8
7
|
function _react() {
|
|
9
8
|
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
9
|
_react = function _react() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _client() {
|
|
19
15
|
const data = require("@nocobase/client");
|
|
20
|
-
|
|
21
16
|
_client = function _client() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var _locale = require("../../locale");
|
|
29
|
-
|
|
30
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
23
|
const SnapshotBlockInitializers = props => {
|
|
33
24
|
const _useSnapshotTranslati = (0, _locale.useSnapshotTranslation)(),
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
t = _useSnapshotTranslati.t;
|
|
36
26
|
const insertPosition = props.insertPosition,
|
|
37
|
-
|
|
27
|
+
component = props.component;
|
|
38
28
|
return _react().default.createElement(_client().SchemaInitializer.Button, {
|
|
39
29
|
wrap: _client().gridRowColWrap,
|
|
40
30
|
insertPosition: insertPosition,
|
|
@@ -63,5 +53,4 @@ const SnapshotBlockInitializers = props => {
|
|
|
63
53
|
}]
|
|
64
54
|
});
|
|
65
55
|
};
|
|
66
|
-
|
|
67
56
|
exports.SnapshotBlockInitializers = SnapshotBlockInitializers;
|
package/lib/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.js
CHANGED
|
@@ -4,77 +4,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createSnapshotBlockSchema = exports.SnapshotBlockInitializersDetailItem = void 0;
|
|
7
|
-
|
|
8
7
|
function _react() {
|
|
9
8
|
const data = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
9
|
_react = function _react() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _icons() {
|
|
19
15
|
const data = require("@ant-design/icons");
|
|
20
|
-
|
|
21
16
|
_icons = function _icons() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _client() {
|
|
29
22
|
const data = require("@nocobase/client");
|
|
30
|
-
|
|
31
23
|
_client = function _client() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _shared() {
|
|
39
29
|
const data = require("@formily/shared");
|
|
40
|
-
|
|
41
30
|
_shared = function _shared() {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
const _excluded = ["formItemInitializers", "actionInitializers", "collection", "association", "resource", "template"],
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
_excluded2 = ["onCreateBlockSchema", "componentType", "createBlockSchema", "insert", "icon", "targetCollection"];
|
|
51
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
52
|
-
|
|
53
38
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
54
|
-
|
|
55
39
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
56
|
-
|
|
57
40
|
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; }
|
|
58
|
-
|
|
59
41
|
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; }
|
|
60
|
-
|
|
61
|
-
function
|
|
62
|
-
|
|
42
|
+
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; }
|
|
43
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
44
|
+
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); }
|
|
63
45
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
64
|
-
|
|
65
46
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
66
|
-
|
|
67
47
|
const createSnapshotBlockSchema = options => {
|
|
68
48
|
const _options$formItemInit = options.formItemInitializers,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
formItemInitializers = _options$formItemInit === void 0 ? 'ReadPrettyFormItemInitializers' : _options$formItemInit,
|
|
50
|
+
_options$actionInitia = options.actionInitializers,
|
|
51
|
+
actionInitializers = _options$actionInitia === void 0 ? 'ReadPrettyFormActionInitializers' : _options$actionInitia,
|
|
52
|
+
collection = options.collection,
|
|
53
|
+
association = options.association,
|
|
54
|
+
resource = options.resource,
|
|
55
|
+
template = options.template,
|
|
56
|
+
others = _objectWithoutProperties(options, _excluded);
|
|
78
57
|
const resourceName = resource || association || collection;
|
|
79
58
|
const schema = {
|
|
80
59
|
type: 'void',
|
|
@@ -112,28 +91,22 @@ const createSnapshotBlockSchema = options => {
|
|
|
112
91
|
console.log(JSON.stringify(schema, null, 2));
|
|
113
92
|
return schema;
|
|
114
93
|
};
|
|
115
|
-
|
|
116
94
|
exports.createSnapshotBlockSchema = createSnapshotBlockSchema;
|
|
117
|
-
|
|
118
95
|
const SnapshotBlockInitializersDetailItem = props => {
|
|
119
96
|
const onCreateBlockSchema = props.onCreateBlockSchema,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
componentType = props.componentType,
|
|
98
|
+
createBlockSchema = props.createBlockSchema,
|
|
99
|
+
insert = props.insert,
|
|
100
|
+
_props$icon = props.icon,
|
|
101
|
+
icon = _props$icon === void 0 ? true : _props$icon,
|
|
102
|
+
targetCollection = props.targetCollection,
|
|
103
|
+
others = _objectWithoutProperties(props, _excluded2);
|
|
128
104
|
const _useSchemaTemplateMan = (0, _client().useSchemaTemplateManager)(),
|
|
129
|
-
|
|
130
|
-
|
|
105
|
+
getTemplateSchemaByMode = _useSchemaTemplateMan.getTemplateSchemaByMode;
|
|
131
106
|
const collection = targetCollection || (0, _client().useCollection)();
|
|
132
107
|
const association = (0, _client().useBlockAssociationContext)();
|
|
133
|
-
|
|
134
108
|
const _useBlockRequestConte = (0, _client().useBlockRequestContext)(),
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
block = _useBlockRequestConte.block;
|
|
137
110
|
const actionInitializers = block !== 'TableField' ? props.actionInitializers || 'ReadPrettyFormActionInitializers' : null;
|
|
138
111
|
return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({
|
|
139
112
|
icon: icon && _react().default.createElement(_icons().FormOutlined, null)
|
|
@@ -145,7 +118,6 @@ const SnapshotBlockInitializersDetailItem = props => {
|
|
|
145
118
|
}) {
|
|
146
119
|
if (item.template) {
|
|
147
120
|
const s = yield getTemplateSchemaByMode(item);
|
|
148
|
-
|
|
149
121
|
if (item.template.componentName === 'ReadPrettyFormItem') {
|
|
150
122
|
const blockSchema = createSnapshotBlockSchema({
|
|
151
123
|
actionInitializers,
|
|
@@ -156,11 +128,9 @@ const SnapshotBlockInitializersDetailItem = props => {
|
|
|
156
128
|
useParams: '{{ useParamsFromRecord }}',
|
|
157
129
|
template: s
|
|
158
130
|
});
|
|
159
|
-
|
|
160
131
|
if (item.mode === 'reference') {
|
|
161
132
|
blockSchema['x-template-key'] = item.template.key;
|
|
162
133
|
}
|
|
163
|
-
|
|
164
134
|
insert(blockSchema);
|
|
165
135
|
} else {
|
|
166
136
|
insert(s);
|
|
@@ -176,15 +146,12 @@ const SnapshotBlockInitializersDetailItem = props => {
|
|
|
176
146
|
}));
|
|
177
147
|
}
|
|
178
148
|
});
|
|
179
|
-
|
|
180
149
|
function onClick(_x) {
|
|
181
150
|
return _onClick.apply(this, arguments);
|
|
182
151
|
}
|
|
183
|
-
|
|
184
152
|
return onClick;
|
|
185
153
|
}(),
|
|
186
154
|
items: (0, _client().useRecordCollectionDataSourceItems)('ReadPrettyFormItem')
|
|
187
155
|
}));
|
|
188
156
|
};
|
|
189
|
-
|
|
190
157
|
exports.SnapshotBlockInitializersDetailItem = SnapshotBlockInitializersDetailItem;
|
|
@@ -4,87 +4,63 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SnapshotBlockProvider = void 0;
|
|
7
|
-
|
|
8
7
|
function _react() {
|
|
9
8
|
const data = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
9
|
_react = function _react() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _core() {
|
|
19
15
|
const data = require("@formily/core");
|
|
20
|
-
|
|
21
16
|
_core = function _core() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _react2() {
|
|
29
22
|
const data = require("@formily/react");
|
|
30
|
-
|
|
31
23
|
_react2 = function _react2() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
function _client() {
|
|
39
29
|
const data = require("@nocobase/client");
|
|
40
|
-
|
|
41
30
|
_client = function _client() {
|
|
42
31
|
return data;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
return data;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
function _antd() {
|
|
49
36
|
const data = require("antd");
|
|
50
|
-
|
|
51
37
|
_antd = function _antd() {
|
|
52
38
|
return data;
|
|
53
39
|
};
|
|
54
|
-
|
|
55
40
|
return data;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
|
-
|
|
60
43
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
|
-
|
|
62
44
|
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; }
|
|
63
|
-
|
|
64
45
|
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; }
|
|
65
|
-
|
|
66
|
-
function
|
|
67
|
-
|
|
46
|
+
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; }
|
|
47
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
48
|
+
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); }
|
|
68
49
|
const InternalFormBlockProvider = props => {
|
|
69
50
|
var _service$data;
|
|
70
|
-
|
|
71
51
|
const action = props.action,
|
|
72
|
-
|
|
52
|
+
readPretty = props.readPretty;
|
|
73
53
|
const field = (0, _react2().useField)();
|
|
74
54
|
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
75
55
|
readPretty
|
|
76
56
|
}), []);
|
|
77
|
-
|
|
78
57
|
const _useBlockRequestConte = (0, _client().useBlockRequestContext)(),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
resource = _useBlockRequestConte.resource,
|
|
59
|
+
service = _useBlockRequestConte.service;
|
|
82
60
|
const formBlockRef = (0, _react().useRef)();
|
|
83
|
-
|
|
84
61
|
if (service.loading) {
|
|
85
62
|
return _react().default.createElement(_antd().Spin, null);
|
|
86
63
|
}
|
|
87
|
-
|
|
88
64
|
return _react().default.createElement(_client().FormBlockContext.Provider, {
|
|
89
65
|
value: {
|
|
90
66
|
action,
|
|
@@ -103,7 +79,6 @@ const InternalFormBlockProvider = props => {
|
|
|
103
79
|
ref: formBlockRef
|
|
104
80
|
}, props.children));
|
|
105
81
|
};
|
|
106
|
-
|
|
107
82
|
const BlockRequestProvider = props => {
|
|
108
83
|
const field = (0, _react2().useField)();
|
|
109
84
|
const resource = (0, _client().useBlockResource)();
|
|
@@ -113,9 +88,7 @@ const BlockRequestProvider = props => {
|
|
|
113
88
|
data: (0, _client().useRecord)()
|
|
114
89
|
}
|
|
115
90
|
};
|
|
116
|
-
|
|
117
91
|
const __parent = (0, _react().useContext)(_client().BlockRequestContext);
|
|
118
|
-
|
|
119
92
|
return _react().default.createElement(_client().BlockRequestContext.Provider, {
|
|
120
93
|
value: {
|
|
121
94
|
block: props.block,
|
|
@@ -127,10 +100,9 @@ const BlockRequestProvider = props => {
|
|
|
127
100
|
}
|
|
128
101
|
}, props.children);
|
|
129
102
|
};
|
|
130
|
-
|
|
131
103
|
const BlockProvider = props => {
|
|
132
104
|
const collection = props.collection,
|
|
133
|
-
|
|
105
|
+
association = props.association;
|
|
134
106
|
const resource = (0, _client().useResource)(props);
|
|
135
107
|
return _react().default.createElement(_client().MaybeCollectionProvider, {
|
|
136
108
|
collection: collection
|
|
@@ -140,21 +112,15 @@ const BlockProvider = props => {
|
|
|
140
112
|
value: resource
|
|
141
113
|
}, _react().default.createElement(BlockRequestProvider, _objectSpread({}, props), props.children))));
|
|
142
114
|
};
|
|
143
|
-
|
|
144
115
|
const SnapshotBlockProvider = props => {
|
|
145
116
|
const record = (0, _client().useRecord)();
|
|
146
117
|
const __tableName = record.__tableName;
|
|
147
|
-
|
|
148
118
|
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
149
|
-
|
|
150
|
-
|
|
119
|
+
getInheritCollections = _useCollectionManager.getInheritCollections;
|
|
151
120
|
const inheritCollections = getInheritCollections(__tableName);
|
|
152
|
-
|
|
153
121
|
const _useDesignable = (0, _client().useDesignable)(),
|
|
154
|
-
|
|
155
|
-
|
|
122
|
+
designable = _useDesignable.designable;
|
|
156
123
|
const flag = !designable && __tableName && !inheritCollections.includes(props.collection) && __tableName !== props.collection;
|
|
157
124
|
return !flag && _react().default.createElement(BlockProvider, _objectSpread({}, props), _react().default.createElement(InternalFormBlockProvider, _objectSpread({}, props)));
|
|
158
125
|
};
|
|
159
|
-
|
|
160
126
|
exports.SnapshotBlockProvider = SnapshotBlockProvider;
|
|
@@ -4,63 +4,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SnapshotHistoryCollectionProvider = void 0;
|
|
7
|
-
|
|
8
7
|
function _client() {
|
|
9
8
|
const data = require("@nocobase/client");
|
|
10
|
-
|
|
11
9
|
_client = function _client() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _react() {
|
|
19
15
|
const data = _interopRequireWildcard(require("react"));
|
|
20
|
-
|
|
21
16
|
_react = function _react() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
const _excluded = ["collections"];
|
|
29
|
-
|
|
30
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
24
|
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; }
|
|
35
|
-
|
|
36
25
|
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; }
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
26
|
+
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; }
|
|
27
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
28
|
+
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); }
|
|
40
29
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
41
|
-
|
|
42
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
|
-
|
|
44
31
|
const SnapshotHistoryCollectionProvider = props => {
|
|
45
32
|
var _useHistoryCollection, _snapshotTargetCollec, _snapshotTargetCollec2;
|
|
46
|
-
|
|
47
33
|
const collectionName = props.collectionName;
|
|
48
|
-
|
|
49
34
|
const _useContext = (0, _react().useContext)(_client().CollectionManagerContext),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
allCollections = _useContext.collections,
|
|
36
|
+
rest = _objectWithoutProperties(_useContext, _excluded);
|
|
37
|
+
// 目标表
|
|
38
|
+
const snapshotTargetCollection = (_useHistoryCollection = (0, _client().useHistoryCollectionsByNames)([collectionName])) === null || _useHistoryCollection === void 0 ? void 0 : _useHistoryCollection[0];
|
|
39
|
+
// 目标如果是继承表则获取继承表
|
|
40
|
+
const inheritCollections = (0, _client().useHistoryCollectionsByNames)((_snapshotTargetCollec = snapshotTargetCollection === null || snapshotTargetCollection === void 0 ? void 0 : snapshotTargetCollection.inherits) !== null && _snapshotTargetCollec !== void 0 ? _snapshotTargetCollec : []);
|
|
41
|
+
// 目标表内关联字段的表
|
|
42
|
+
const associationFieldTargetCollections = (0, _client().useHistoryCollectionsByNames)((_snapshotTargetCollec2 = snapshotTargetCollection === null || snapshotTargetCollection === void 0 ? void 0 : snapshotTargetCollection.fields.filter(i => i.interface !== 'snapshot').map(i => i.target)) !== null && _snapshotTargetCollec2 !== void 0 ? _snapshotTargetCollec2 : []);
|
|
43
|
+
// 替换表的集合
|
|
44
|
+
const finallyHistoryCollecionts = [snapshotTargetCollection, ...associationFieldTargetCollections, ...inheritCollections].filter(i => i);
|
|
45
|
+
// 过滤出不需要替换的表
|
|
46
|
+
const filterdAllCollection = allCollections.filter(c => !finallyHistoryCollecionts.map(i => i.name).includes(c.name));
|
|
47
|
+
// 最终替换后的表
|
|
64
48
|
const overridedCollections = [...filterdAllCollection, ...finallyHistoryCollecionts];
|
|
65
49
|
return _react().default.createElement(_client().CollectionManagerContext.Provider, {
|
|
66
50
|
value: _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -68,5 +52,4 @@ const SnapshotHistoryCollectionProvider = props => {
|
|
|
68
52
|
})
|
|
69
53
|
}, props.children);
|
|
70
54
|
};
|
|
71
|
-
|
|
72
55
|
exports.SnapshotHistoryCollectionProvider = SnapshotHistoryCollectionProvider;
|
|
@@ -4,80 +4,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SnapshotRecordPicker = void 0;
|
|
7
|
-
|
|
8
7
|
function _react() {
|
|
9
8
|
const data = require("@formily/react");
|
|
10
|
-
|
|
11
9
|
_react = function _react() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _client() {
|
|
19
15
|
const data = require("@nocobase/client");
|
|
20
|
-
|
|
21
16
|
_client = function _client() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function _react2() {
|
|
29
22
|
const data = _interopRequireDefault(require("react"));
|
|
30
|
-
|
|
31
23
|
_react2 = function _react2() {
|
|
32
24
|
return data;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
return data;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
var _SnapshotHistoryCollectionProvider = require("./SnapshotHistoryCollectionProvider");
|
|
39
|
-
|
|
40
29
|
const _excluded = ["value", "onChange"];
|
|
41
|
-
|
|
42
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
-
|
|
44
31
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
45
|
-
|
|
46
32
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
|
-
|
|
48
33
|
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; }
|
|
49
|
-
|
|
50
34
|
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; }
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
35
|
+
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; }
|
|
36
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
37
|
+
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); }
|
|
54
38
|
const ReadPrettyRecordPickerWrapper = props => {
|
|
55
39
|
const fieldSchema = (0, _react().useFieldSchema)();
|
|
56
|
-
|
|
57
40
|
const _useCollection = (0, _client().useCollection)(),
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
getField = _useCollection.getField;
|
|
60
42
|
const collectionField = getField(fieldSchema.name);
|
|
61
43
|
return _react2().default.createElement(_SnapshotHistoryCollectionProvider.SnapshotHistoryCollectionProvider, {
|
|
62
44
|
collectionName: collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection
|
|
63
45
|
}, _react2().default.createElement(_client().ReadPrettyRecordPicker, _objectSpread({}, props)));
|
|
64
46
|
};
|
|
65
|
-
|
|
66
47
|
const SnapshotRecordPickerInner = (0, _react().connect)(ReadPrettyRecordPickerWrapper, (0, _react().mapReadPretty)(ReadPrettyRecordPickerWrapper));
|
|
67
|
-
|
|
68
48
|
const SnapshotRecordPicker = props => {
|
|
69
49
|
const value = props.value,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
_onChange = props.onChange,
|
|
51
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
73
52
|
const newProps = _objectSpread(_objectSpread({}, restProps), {}, {
|
|
74
53
|
value: value === null || value === void 0 ? void 0 : value.data,
|
|
75
54
|
onChange: value => _onChange({
|
|
76
55
|
data: value
|
|
77
56
|
})
|
|
78
57
|
});
|
|
79
|
-
|
|
80
58
|
return _react2().default.createElement(SnapshotRecordPickerInner, _objectSpread({}, newProps));
|
|
81
59
|
};
|
|
82
|
-
|
|
83
60
|
exports.SnapshotRecordPicker = SnapshotRecordPicker;
|