@pisell/materials 1.0.518 → 1.0.520
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +9 -9
- package/build/lowcode/view.js +10 -10
- package/es/components/dataSourceComponents/dataSourceForm/index.js +4 -2
- package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +10 -3
- package/es/components/dataSourceComponents/dataSourceForm/serve.d.ts +3 -2
- package/es/components/dataSourceComponents/dataSourceForm/serve.js +36 -20
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +3 -2
- package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +12 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.d.ts +4 -1
- package/es/components/dataSourceComponents/fields/Upload/serve.js +10 -31
- package/es/components/dataSourceComponents/hooks/useActions.d.ts +2 -1
- package/es/components/dataSourceComponents/hooks/useActions.js +71 -34
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -1
- package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +49 -3
- package/es/components/profileMenu/index.js +3 -0
- package/lib/components/dataSourceComponents/dataSourceForm/index.js +3 -2
- package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +16 -6
- package/lib/components/dataSourceComponents/dataSourceForm/serve.d.ts +3 -2
- package/lib/components/dataSourceComponents/dataSourceForm/serve.js +9 -5
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +3 -2
- package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +11 -0
- package/lib/components/dataSourceComponents/fields/Upload/serve.d.ts +4 -1
- package/lib/components/dataSourceComponents/fields/Upload/serve.js +20 -12
- package/lib/components/dataSourceComponents/hooks/useActions.d.ts +2 -1
- package/lib/components/dataSourceComponents/hooks/useActions.js +20 -5
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceContext.d.ts +7 -0
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +3 -1
- package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +49 -3
- package/lib/components/profileMenu/index.js +1 -0
- package/lowcode/data-source-form/meta.ts +52 -0
- package/lowcode/data-source-form/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -44,7 +44,8 @@ var import_locales = require("../../../locales");
|
|
|
44
44
|
var useActions = ({
|
|
45
45
|
dataSource: propsDataSource,
|
|
46
46
|
currentValue: propsCurrentValue,
|
|
47
|
-
__designMode
|
|
47
|
+
__designMode,
|
|
48
|
+
extraParams: propsExtraParams
|
|
48
49
|
} = {}) => {
|
|
49
50
|
const { dataSource: ctxDataSource, __designMode: ctxDesignMode } = (0, import_useDataSource.default)();
|
|
50
51
|
const { parseVariable } = (0, import_useVariables.default)();
|
|
@@ -68,6 +69,15 @@ var useActions = ({
|
|
|
68
69
|
const currentRecord = (0, import_react.useMemo)(() => {
|
|
69
70
|
return parseVariable == null ? void 0 : parseVariable(currentValue, {});
|
|
70
71
|
}, [currentValue, parseVariable]);
|
|
72
|
+
const extraParams = (0, import_react.useMemo)(() => {
|
|
73
|
+
return Object.entries(propsExtraParams || {}).reduce((acc, [key, value]) => {
|
|
74
|
+
acc[key] = Object.entries(value || {}).reduce((acc2, [k, v]) => {
|
|
75
|
+
acc2[k] = parseVariable == null ? void 0 : parseVariable(v, {});
|
|
76
|
+
return acc2;
|
|
77
|
+
}, {});
|
|
78
|
+
return acc;
|
|
79
|
+
}, {});
|
|
80
|
+
}, [propsExtraParams, parseVariable]);
|
|
71
81
|
const getParsedActions = (0, import_ahooks.useMemoizedFn)(() => {
|
|
72
82
|
return parseActions(originalActions, { currentRecord });
|
|
73
83
|
});
|
|
@@ -132,7 +142,12 @@ var useActions = ({
|
|
|
132
142
|
const getApi = genCustomApi(actions == null ? void 0 : actions.get);
|
|
133
143
|
return getApi({});
|
|
134
144
|
}
|
|
135
|
-
|
|
145
|
+
const res = await (0, import_serve.getNocobaseData)({
|
|
146
|
+
key: name || "",
|
|
147
|
+
query: extraParams == null ? void 0 : extraParams.get,
|
|
148
|
+
headers: getHeaders()
|
|
149
|
+
});
|
|
150
|
+
return (res == null ? void 0 : res.data) || {};
|
|
136
151
|
} else if (currentValue) {
|
|
137
152
|
return parseVariable == null ? void 0 : parseVariable(currentValue, {});
|
|
138
153
|
}
|
|
@@ -151,7 +166,7 @@ var useActions = ({
|
|
|
151
166
|
const updateApi = genCustomApi(actions == null ? void 0 : actions.update);
|
|
152
167
|
return updateApi(formatCreateUpdateParams(values));
|
|
153
168
|
} else {
|
|
154
|
-
const id = values == null ? void 0 : values.id;
|
|
169
|
+
const id = (extraParams == null ? void 0 : extraParams.filterByTk) || (values == null ? void 0 : values.id);
|
|
155
170
|
if (!id || !name) {
|
|
156
171
|
(0, import_pisellToast.default)({
|
|
157
172
|
content: (0, import_locales.getText)("pisell-action-get-data")
|
|
@@ -160,9 +175,9 @@ var useActions = ({
|
|
|
160
175
|
}
|
|
161
176
|
return (0, import_serve.updateNocobaseData)({
|
|
162
177
|
key: name,
|
|
163
|
-
id,
|
|
164
178
|
data: formatCreateUpdateParams(values),
|
|
165
|
-
headers: getHeaders()
|
|
179
|
+
headers: getHeaders(),
|
|
180
|
+
query: { filterByTk: id, ...extraParams == null ? void 0 : extraParams.update }
|
|
166
181
|
});
|
|
167
182
|
}
|
|
168
183
|
});
|
|
@@ -88,6 +88,13 @@ export declare type DataSourceContextProps = {
|
|
|
88
88
|
list?: boolean;
|
|
89
89
|
get?: boolean;
|
|
90
90
|
};
|
|
91
|
+
extraParams?: {
|
|
92
|
+
list?: Record<string, any>;
|
|
93
|
+
get?: Record<string, any>;
|
|
94
|
+
update?: Record<string, any>;
|
|
95
|
+
create?: Record<string, any>;
|
|
96
|
+
destroy?: Record<string, any>;
|
|
97
|
+
};
|
|
91
98
|
__id?: string;
|
|
92
99
|
__designMode?: string;
|
|
93
100
|
};
|
|
@@ -44,6 +44,7 @@ var DataSourceProvider = (props) => {
|
|
|
44
44
|
children,
|
|
45
45
|
dataSource: propsDataSource,
|
|
46
46
|
currentValue,
|
|
47
|
+
extraParams,
|
|
47
48
|
actions: externalActions,
|
|
48
49
|
overrideData,
|
|
49
50
|
autoRun,
|
|
@@ -55,7 +56,8 @@ var DataSourceProvider = (props) => {
|
|
|
55
56
|
const standardActions = (0, import_useActions.default)({
|
|
56
57
|
dataSource,
|
|
57
58
|
currentValue,
|
|
58
|
-
__designMode
|
|
59
|
+
__designMode,
|
|
60
|
+
extraParams
|
|
59
61
|
});
|
|
60
62
|
const list = (externalActions == null ? void 0 : externalActions.list) || standardActions.list;
|
|
61
63
|
const get = (externalActions == null ? void 0 : externalActions.get) || standardActions.get;
|
|
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(VariablesProvider_exports);
|
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_utils = require("@pisell/utils");
|
|
37
37
|
var import_ahooks = require("ahooks");
|
|
38
|
+
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
|
|
38
39
|
var import_VariablesContext = __toESM(require("./VariablesContext"));
|
|
39
40
|
var import_utils2 = require("../../dataSourceForm/utils");
|
|
40
41
|
var import_utils3 = require("../../../../utils");
|
|
@@ -46,9 +47,54 @@ var defaultCustomizer = (objValue, srcValue) => {
|
|
|
46
47
|
};
|
|
47
48
|
var VARIABLE_PATTERN = /{{([^}]+)}}/g;
|
|
48
49
|
var VariablesProvider = (props) => {
|
|
50
|
+
var _a;
|
|
49
51
|
const { children, variables } = props;
|
|
50
|
-
const
|
|
52
|
+
const context = (0, import_useEngineContext.default)();
|
|
53
|
+
const { getApp } = ((_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
54
|
+
const initialQuery = (0, import_react.useMemo)(() => {
|
|
55
|
+
var _a2, _b, _c;
|
|
56
|
+
const currentLocation = (_c = (_b = (_a2 = getApp == null ? void 0 : getApp()) == null ? void 0 : _a2.history) == null ? void 0 : _b.instance) == null ? void 0 : _c.location;
|
|
57
|
+
if (currentLocation == null ? void 0 : currentLocation.search) {
|
|
58
|
+
const searchParams = new URLSearchParams(currentLocation.search);
|
|
59
|
+
const query = {};
|
|
60
|
+
searchParams.forEach((value2, key) => {
|
|
61
|
+
query[key] = value2;
|
|
62
|
+
});
|
|
63
|
+
return query;
|
|
64
|
+
}
|
|
65
|
+
return {};
|
|
66
|
+
}, []);
|
|
67
|
+
const variablesRef = (0, import_react.useRef)(
|
|
68
|
+
(0, import_utils3.mergeWith)(
|
|
69
|
+
variables,
|
|
70
|
+
{
|
|
71
|
+
global: {
|
|
72
|
+
query: initialQuery
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
defaultCustomizer
|
|
76
|
+
)
|
|
77
|
+
);
|
|
51
78
|
const listenersRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
79
|
+
const setQueryVariable = (0, import_ahooks.useMemoizedFn)((search) => {
|
|
80
|
+
const searchParams = new URLSearchParams(search);
|
|
81
|
+
const query = {};
|
|
82
|
+
searchParams.forEach((value2, key) => {
|
|
83
|
+
query[key] = value2;
|
|
84
|
+
});
|
|
85
|
+
registerVariable({
|
|
86
|
+
global: query
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
(0, import_react.useEffect)(() => {
|
|
90
|
+
var _a2, _b, _c;
|
|
91
|
+
const unlisten = (_c = (_b = (_a2 = getApp == null ? void 0 : getApp()) == null ? void 0 : _a2.history) == null ? void 0 : _b.instance) == null ? void 0 : _c.listen((location) => {
|
|
92
|
+
setQueryVariable(location.search);
|
|
93
|
+
});
|
|
94
|
+
return () => {
|
|
95
|
+
unlisten == null ? void 0 : unlisten();
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
52
98
|
const registerVariable = (0, import_ahooks.useMemoizedFn)((value2) => {
|
|
53
99
|
variablesRef.current = (0, import_utils3.mergeWith)(
|
|
54
100
|
variablesRef.current,
|
|
@@ -82,11 +128,11 @@ var VariablesProvider = (props) => {
|
|
|
82
128
|
);
|
|
83
129
|
const parseVariable = (0, import_ahooks.useMemoizedFn)(
|
|
84
130
|
(str, localVariables = {}) => {
|
|
85
|
-
var
|
|
131
|
+
var _a2;
|
|
86
132
|
if (!(0, import_utils.isString)(str)) {
|
|
87
133
|
return str;
|
|
88
134
|
}
|
|
89
|
-
if (((
|
|
135
|
+
if (((_a2 = str.match(VARIABLE_PATTERN)) == null ? void 0 : _a2[0]) === str) {
|
|
90
136
|
const key = (0, import_utils4.getVariableKey)(str);
|
|
91
137
|
if (!key)
|
|
92
138
|
return str;
|
|
@@ -65,6 +65,7 @@ var ProfileMenu = ({
|
|
|
65
65
|
const renderAvatar = (avatarProps) => /* @__PURE__ */ import_react.default.createElement(
|
|
66
66
|
import_pisellAvatar.default,
|
|
67
67
|
{
|
|
68
|
+
style: { margin: "0 6px" },
|
|
68
69
|
size: "md",
|
|
69
70
|
src: (avatarProps == null ? void 0 : avatarProps.src) || "",
|
|
70
71
|
alt: (avatarProps == null ? void 0 : avatarProps.alt) || "",
|
|
@@ -261,6 +261,58 @@ const dataSourceForm: MetaType = {
|
|
|
261
261
|
},
|
|
262
262
|
},
|
|
263
263
|
},
|
|
264
|
+
{
|
|
265
|
+
type: 'group',
|
|
266
|
+
title: '额外参数',
|
|
267
|
+
display: 'entry',
|
|
268
|
+
items: [
|
|
269
|
+
// {
|
|
270
|
+
// name: 'extraParams.list',
|
|
271
|
+
// title: {
|
|
272
|
+
// type: 'i18n',
|
|
273
|
+
// 'en-US': 'List Params',
|
|
274
|
+
// 'zh-CN': '列表参数',
|
|
275
|
+
// },
|
|
276
|
+
// setter: 'StringSetter'
|
|
277
|
+
// },
|
|
278
|
+
{
|
|
279
|
+
name: 'extraParams.get',
|
|
280
|
+
title: {
|
|
281
|
+
type: 'i18n',
|
|
282
|
+
'en-US': 'Get Params',
|
|
283
|
+
'zh-CN': '获取参数',
|
|
284
|
+
},
|
|
285
|
+
setter: 'JsonSetter'
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: 'extraParams.update',
|
|
289
|
+
title: {
|
|
290
|
+
type: 'i18n',
|
|
291
|
+
'en-US': 'Update Params',
|
|
292
|
+
'zh-CN': '更新参数',
|
|
293
|
+
},
|
|
294
|
+
setter: 'JsonSetter'
|
|
295
|
+
},
|
|
296
|
+
// {
|
|
297
|
+
// name: 'extraParams.create',
|
|
298
|
+
// title: {
|
|
299
|
+
// type: 'i18n',
|
|
300
|
+
// 'en-US': 'Create Params',
|
|
301
|
+
// 'zh-CN': '创建参数',
|
|
302
|
+
// },
|
|
303
|
+
// setter: 'StringSetter'
|
|
304
|
+
// },
|
|
305
|
+
// {
|
|
306
|
+
// name: 'extraParams.destroy',
|
|
307
|
+
// title: {
|
|
308
|
+
// type: 'i18n',
|
|
309
|
+
// 'en-US': 'Destroy Params',
|
|
310
|
+
// 'zh-CN': '删除参数',
|
|
311
|
+
// },
|
|
312
|
+
// setter: 'StringSetter'
|
|
313
|
+
// }
|
|
314
|
+
]
|
|
315
|
+
}
|
|
264
316
|
],
|
|
265
317
|
},
|
|
266
318
|
{
|
|
@@ -227,10 +227,10 @@ export const createFormItemSchema = (
|
|
|
227
227
|
} else {
|
|
228
228
|
props.styleType = 'antd';
|
|
229
229
|
props.showSearch = true;
|
|
230
|
-
props.isShowDropdown = true;
|
|
231
230
|
props.optionFilterProp = 'label';
|
|
232
231
|
if (props.mode === "multiple") {
|
|
233
232
|
props.selectAll = true;
|
|
233
|
+
props.isShowDropdown = true;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
props.optionSourceType = 'default';
|