@pisell/materials 1.0.464 → 1.0.466
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/index.js +1 -1
- package/build/lowcode/meta.js +19 -2
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.js +13 -13
- package/build/lowcode/view.js +13 -13
- package/es/components/dataSourceComponents/dataSourceForm/formItem.js +3 -1
- package/es/components/dataSourceComponents/dataSourceForm/index.js +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/hooks/useJsonPrefixPath.d.ts +4 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperContext.d.ts +4 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperContext.js +4 -1
- package/es/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +21 -4
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +15 -10
- package/es/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/utils.d.ts +9 -0
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +49 -2
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +8 -7
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.js +5 -4
- package/es/components/dataSourceComponents/dataSourceTable/index.js +1 -1
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +2 -1
- package/es/components/dataSourceComponents/dataSourceWrapper/index.d.ts +6 -0
- package/es/components/dataSourceComponents/dataSourceWrapper/index.js +6 -0
- package/es/components/dataSourceComponents/fields/Checkbox/index.js +10 -2
- package/es/components/dataSourceComponents/fields/Radio/index.js +10 -2
- package/es/components/dataSourceComponents/fields/Select/index.d.ts +9 -2
- package/es/components/dataSourceComponents/fields/Select/index.js +11 -3
- package/es/components/dataSourceComponents/fields/index.d.ts +8 -1
- package/es/components/dataSourceComponents/hooks/useActions.d.ts +1 -1
- package/es/components/dataSourceComponents/hooks/useActions.js +2 -5
- package/es/components/dataSourceComponents/hooks/useDataSource.d.ts +1 -1
- package/es/components/dataSourceComponents/hooks/useDataSource.js +1 -1
- package/es/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +2 -0
- package/es/components/dataSourceComponents/provider/variables/VariablesContext.js +2 -0
- package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +19 -4
- package/es/components/dataSourceComponents/provider/variables/utils.d.ts +10 -0
- package/es/components/dataSourceComponents/provider/variables/utils.js +19 -0
- package/lib/components/dataSourceComponents/dataSourceForm/formItem.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/index.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/hooks/useJsonPrefixPath.d.ts +4 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperContext.d.ts +4 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperContext.js +4 -1
- package/lib/components/dataSourceComponents/dataSourceForm/provider/jsonWrapper/JsonWrapperProvider.js +6 -2
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +8 -6
- package/lib/components/dataSourceComponents/dataSourceForm/type.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.d.ts +9 -0
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +45 -3
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +7 -6
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDesignMode.js +11 -5
- package/lib/components/dataSourceComponents/dataSourceTable/index.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +2 -1
- package/lib/components/dataSourceComponents/dataSourceWrapper/index.d.ts +6 -0
- package/lib/components/dataSourceComponents/dataSourceWrapper/index.js +40 -0
- package/lib/components/dataSourceComponents/fields/Checkbox/index.js +3 -1
- package/lib/components/dataSourceComponents/fields/Radio/index.js +3 -1
- package/lib/components/dataSourceComponents/fields/Select/index.d.ts +9 -2
- package/lib/components/dataSourceComponents/fields/Select/index.js +4 -2
- package/lib/components/dataSourceComponents/fields/index.d.ts +8 -1
- package/lib/components/dataSourceComponents/hooks/useActions.d.ts +1 -1
- package/lib/components/dataSourceComponents/hooks/useActions.js +1 -4
- package/lib/components/dataSourceComponents/hooks/useDataSource.d.ts +1 -1
- package/lib/components/dataSourceComponents/hooks/useDataSource.js +1 -1
- package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceContext.js +1 -1
- package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceProvider.js +1 -1
- package/lib/components/dataSourceComponents/provider/variables/VariablesContext.d.ts +2 -0
- package/lib/components/dataSourceComponents/provider/variables/VariablesContext.js +4 -0
- package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +24 -3
- package/lib/components/dataSourceComponents/provider/variables/utils.d.ts +10 -0
- package/lib/components/dataSourceComponents/provider/variables/utils.js +48 -0
- package/lowcode/_utils/defaultSchema.ts +674 -6
- package/lowcode/_utils/utils.ts +9 -0
- package/lowcode/data-source-form/meta.ts +10 -3
- package/lowcode/data-source-form/utils.ts +65 -6
- package/lowcode/data-source-table/meta.ts +18 -6
- package/lowcode/data-source-table/utils.tsx +5 -0
- package/lowcode/date-picker.range-picker/meta.ts +20 -0
- package/lowcode/form-group/meta.ts +2 -3
- package/lowcode/form-item-checkbox/snippets.ts +2 -0
- package/lowcode/form-item-checkbox.group/meta.ts +47 -22
- package/lowcode/form-item-color-picker/meta.ts +27 -14
- package/lowcode/form-item-input/meta.ts +23 -2
- package/lowcode/form-item-radio/snippets.ts +6 -3
- package/lowcode/form-item-radio.group/meta.ts +20 -2
- package/lowcode/form-item-select/meta.ts +64 -33
- package/lowcode/form-item-select/snippets.ts +1 -0
- package/package.json +1 -1
- /package/es/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceContext.d.ts +0 -0
- /package/es/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceContext.js +0 -0
- /package/es/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceProvider.d.ts +0 -0
- /package/es/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceProvider.js +0 -0
- /package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceContext.d.ts +0 -0
- /package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceProvider.d.ts +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _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; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
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); }
|
|
5
|
+
// 生成组件的value变量
|
|
6
|
+
export var genComponentValueVariable = function genComponentValueVariable(componentId, value) {
|
|
7
|
+
if (!value || !componentId) return {};
|
|
8
|
+
return _defineProperty({}, componentId, {
|
|
9
|
+
value: value
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// 生成组件的函数变量
|
|
14
|
+
export var genComponentFunctionVariable = function genComponentFunctionVariable(componentId, value) {
|
|
15
|
+
if (!value || !componentId) return {};
|
|
16
|
+
return _defineProperty({}, componentId, {
|
|
17
|
+
functions: value
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -42,7 +42,7 @@ var import_utils2 = require("./utils");
|
|
|
42
42
|
var FormItem = (props) => {
|
|
43
43
|
var _a;
|
|
44
44
|
const { children, name, label: propsLabel, mode: propsMode, ...other } = props;
|
|
45
|
-
const prefixPath = (0, import_useJsonPrefixPath.default)();
|
|
45
|
+
const { path: prefixPath = [] } = (0, import_useJsonPrefixPath.default)();
|
|
46
46
|
const { dataSource } = (0, import_useDataSource.default)();
|
|
47
47
|
const fields = dataSource == null ? void 0 : dataSource.fields;
|
|
48
48
|
const { mode: globalMode } = (0, import_useFormSetting.default)();
|
|
@@ -33,7 +33,7 @@ __export(dataSourceForm_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(dataSourceForm_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
-
var import_DataSourceProvider = __toESM(require("../provider/
|
|
36
|
+
var import_DataSourceProvider = __toESM(require("../provider/dataSource/DataSourceProvider"));
|
|
37
37
|
var import_form = __toESM(require("../../form"));
|
|
38
38
|
var import_BaseForm = __toESM(require("./BaseForm"));
|
|
39
39
|
var import_index = require("./index.less");
|
|
@@ -23,5 +23,8 @@ __export(JsonWrapperContext_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(JsonWrapperContext_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
|
-
var JsonWrapperContext = (0, import_react.createContext)(
|
|
26
|
+
var JsonWrapperContext = (0, import_react.createContext)({
|
|
27
|
+
path: [],
|
|
28
|
+
level: 0
|
|
29
|
+
});
|
|
27
30
|
var JsonWrapperContext_default = JsonWrapperContext;
|
|
@@ -38,11 +38,15 @@ var import_utils = require("../../utils");
|
|
|
38
38
|
var import_JsonWrapperContext = __toESM(require("./JsonWrapperContext"));
|
|
39
39
|
var JsonWrapperProvider = (props) => {
|
|
40
40
|
const { children, prefix, label } = props;
|
|
41
|
-
const prefixPath = (0, import_react.useContext)(import_JsonWrapperContext.default);
|
|
41
|
+
const { path: prefixPath = [], level = 0 } = (0, import_react.useContext)(import_JsonWrapperContext.default) || {};
|
|
42
42
|
const concatPath = (0, import_react.useMemo)(
|
|
43
43
|
() => [...prefixPath, ...(0, import_utils.toArr)(prefix)],
|
|
44
44
|
[prefixPath, prefix]
|
|
45
45
|
);
|
|
46
|
-
|
|
46
|
+
const contextValue = (0, import_react.useMemo)(() => ({
|
|
47
|
+
path: concatPath,
|
|
48
|
+
level: level + 1
|
|
49
|
+
}), [concatPath, level]);
|
|
50
|
+
return /* @__PURE__ */ import_react.default.createElement(import_JsonWrapperContext.default.Provider, { value: contextValue }, /* @__PURE__ */ import_react.default.createElement(import_formItem.default, { label, style: { paddingLeft: `${level * 12}px` } }, /* @__PURE__ */ import_react.default.createElement("div", { style: { paddingLeft: `${level * 12}px` } }, children)));
|
|
47
51
|
};
|
|
48
52
|
var JsonWrapperProvider_default = JsonWrapperProvider;
|
|
@@ -101,11 +101,13 @@ var SubmitButton = (props) => {
|
|
|
101
101
|
const validateFields = () => {
|
|
102
102
|
return form.validateFields();
|
|
103
103
|
};
|
|
104
|
-
const handleValideFieldsSubmit = async () => {
|
|
104
|
+
const handleValideFieldsSubmit = async (values) => {
|
|
105
105
|
try {
|
|
106
106
|
await validateFields();
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const allValues = form.getFieldsValue(true);
|
|
108
|
+
if (allValues.id) {
|
|
109
|
+
values.id = allValues.id;
|
|
110
|
+
}
|
|
109
111
|
await onSubmit(values);
|
|
110
112
|
if (refreshData) {
|
|
111
113
|
refreshTableData == null ? void 0 : refreshTableData();
|
|
@@ -125,7 +127,7 @@ var SubmitButton = (props) => {
|
|
|
125
127
|
}
|
|
126
128
|
};
|
|
127
129
|
const onSubmitClick = async () => {
|
|
128
|
-
await validateFields();
|
|
130
|
+
const values = await validateFields();
|
|
129
131
|
if (confirmConfig == null ? void 0 : confirmConfig.enable) {
|
|
130
132
|
return import_pisellModal.default.confirm({
|
|
131
133
|
title: confirmConfig.title,
|
|
@@ -133,11 +135,11 @@ var SubmitButton = (props) => {
|
|
|
133
135
|
okText: confirmConfig.okText,
|
|
134
136
|
cancelText: confirmConfig.cancelText,
|
|
135
137
|
onOk: () => {
|
|
136
|
-
handleValideFieldsSubmit();
|
|
138
|
+
handleValideFieldsSubmit(values);
|
|
137
139
|
}
|
|
138
140
|
});
|
|
139
141
|
}
|
|
140
|
-
handleValideFieldsSubmit();
|
|
142
|
+
handleValideFieldsSubmit(values);
|
|
141
143
|
};
|
|
142
144
|
if (status === "hidden" || mode === "view") {
|
|
143
145
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DataSourceType } from "../provider/
|
|
2
|
+
import { DataSourceType } from "../provider/dataSource/DataSourceContext";
|
|
3
3
|
export declare type ModeType = 'edit' | 'add' | 'view' | 'disabled' | 'hidden';
|
|
4
4
|
export interface DataSourceFormProps {
|
|
5
5
|
title: string;
|
|
@@ -32,6 +32,15 @@ export declare const formItemNameReverse: (name: string) => string;
|
|
|
32
32
|
* @Date: 2024-11-23 17:14:25
|
|
33
33
|
*/
|
|
34
34
|
export declare const withFormItem: <P extends object>(WrappedComponent: React.ComponentType<P>) => React.FC<P & WithFormItemProps>;
|
|
35
|
+
export declare const withDataSource: <P extends unknown>(WrappedComponent: React.ComponentType<P>) => (props: P & {
|
|
36
|
+
dataSource?: any;
|
|
37
|
+
}) => React.JSX.Element;
|
|
38
|
+
export declare const withOptions: <P extends unknown>(WrappedComponent: React.ComponentType<P>) => (props: P & {
|
|
39
|
+
options?: any;
|
|
40
|
+
optionSourceType?: string | undefined;
|
|
41
|
+
labelField: string;
|
|
42
|
+
valueField: string;
|
|
43
|
+
}) => React.JSX.Element;
|
|
35
44
|
export declare const getNestedValue: (obj: Record<string, any>, path: string) => Record<string, any>;
|
|
36
45
|
export declare const renderValueWithMap: (value: any, valueMap?: Record<string, string>) => React.JSX.Element | null;
|
|
37
46
|
export declare function toArr(str: string | number | (string | number)[]): (string | number)[];
|
|
@@ -34,8 +34,10 @@ __export(utils_exports, {
|
|
|
34
34
|
getNestedValue: () => getNestedValue,
|
|
35
35
|
renderValueWithMap: () => renderValueWithMap,
|
|
36
36
|
toArr: () => toArr,
|
|
37
|
+
withDataSource: () => withDataSource,
|
|
37
38
|
withFormItem: () => withFormItem,
|
|
38
|
-
withMode: () => withMode
|
|
39
|
+
withMode: () => withMode,
|
|
40
|
+
withOptions: () => withOptions
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(utils_exports);
|
|
41
43
|
var import_react = __toESM(require("react"));
|
|
@@ -45,6 +47,7 @@ var import_form = __toESM(require("../../form"));
|
|
|
45
47
|
var import_useDataSource = __toESM(require("../hooks/useDataSource"));
|
|
46
48
|
var import_useFormSetting = __toESM(require("./provider/hooks/useFormSetting"));
|
|
47
49
|
var import_useJsonPrefixPath = __toESM(require("./provider/hooks/useJsonPrefixPath"));
|
|
50
|
+
var import_DataSourceProvider = __toESM(require("../provider/dataSource/DataSourceProvider"));
|
|
48
51
|
var withMode = (FieldComponent, ReadPrettyComponent, transformProps) => {
|
|
49
52
|
return ({ renderMode = "edit", value, onChange, ...props }) => {
|
|
50
53
|
const transformedProps = (transformProps == null ? void 0 : transformProps(
|
|
@@ -101,7 +104,7 @@ var withFormItem = (WrappedComponent) => {
|
|
|
101
104
|
...otherProps
|
|
102
105
|
}) => {
|
|
103
106
|
var _a;
|
|
104
|
-
const prefixPath = (0, import_useJsonPrefixPath.default)();
|
|
107
|
+
const { path: prefixPath = [] } = (0, import_useJsonPrefixPath.default)();
|
|
105
108
|
const { dataSource } = (0, import_useDataSource.default)();
|
|
106
109
|
const { fields } = dataSource || {};
|
|
107
110
|
const { mode: globalMode } = (0, import_useFormSetting.default)();
|
|
@@ -158,6 +161,43 @@ var withFormItem = (WrappedComponent) => {
|
|
|
158
161
|
);
|
|
159
162
|
};
|
|
160
163
|
};
|
|
164
|
+
var withDataSource = (WrappedComponent) => {
|
|
165
|
+
return (props) => {
|
|
166
|
+
const { dataSource } = props;
|
|
167
|
+
return /* @__PURE__ */ import_react.default.createElement(import_DataSourceProvider.default, { dataSource }, /* @__PURE__ */ import_react.default.createElement(WrappedComponent, { ...props }));
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
var withOptions = (WrappedComponent) => {
|
|
171
|
+
return (props) => {
|
|
172
|
+
var _a;
|
|
173
|
+
const {
|
|
174
|
+
options: propsOptions,
|
|
175
|
+
optionSourceType,
|
|
176
|
+
labelField,
|
|
177
|
+
valueField
|
|
178
|
+
} = props;
|
|
179
|
+
const { list } = (0, import_useDataSource.default)();
|
|
180
|
+
(0, import_react.useEffect)(() => {
|
|
181
|
+
if (optionSourceType === "api") {
|
|
182
|
+
list.run({
|
|
183
|
+
page: 1,
|
|
184
|
+
pageSize: 200
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}, []);
|
|
188
|
+
const options = (0, import_react.useMemo)(() => {
|
|
189
|
+
var _a2, _b;
|
|
190
|
+
if (optionSourceType !== "api") {
|
|
191
|
+
return propsOptions;
|
|
192
|
+
}
|
|
193
|
+
return ((_b = (_a2 = list.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.map((item) => ({
|
|
194
|
+
label: item[labelField],
|
|
195
|
+
value: item[valueField]
|
|
196
|
+
}))) || [];
|
|
197
|
+
}, [propsOptions, optionSourceType, (_a = list == null ? void 0 : list.data) == null ? void 0 : _a.data]);
|
|
198
|
+
return /* @__PURE__ */ import_react.default.createElement(import_DataSourceProvider.default, { dataSource: options }, /* @__PURE__ */ import_react.default.createElement(WrappedComponent, { ...props, options }));
|
|
199
|
+
};
|
|
200
|
+
};
|
|
161
201
|
var getNestedValue = (obj, path) => {
|
|
162
202
|
const keys = path.split(".");
|
|
163
203
|
let value = obj;
|
|
@@ -186,6 +226,8 @@ function toArr(str) {
|
|
|
186
226
|
getNestedValue,
|
|
187
227
|
renderValueWithMap,
|
|
188
228
|
toArr,
|
|
229
|
+
withDataSource,
|
|
189
230
|
withFormItem,
|
|
190
|
-
withMode
|
|
231
|
+
withMode,
|
|
232
|
+
withOptions
|
|
191
233
|
});
|
|
@@ -63,9 +63,10 @@ var BaseTable = (props) => {
|
|
|
63
63
|
showAddButton,
|
|
64
64
|
addContent,
|
|
65
65
|
__designMode,
|
|
66
|
+
componentId,
|
|
66
67
|
...others
|
|
67
68
|
} = props;
|
|
68
|
-
const {
|
|
69
|
+
const { registerValueVariable } = (0, import_useVariables.default)();
|
|
69
70
|
const { list, destroy } = (0, import_useDataSource.default)();
|
|
70
71
|
const { data } = list;
|
|
71
72
|
const { dataSourceKey, dataSourceKeyRef } = (0, import_useDataSourceKey.default)();
|
|
@@ -78,7 +79,7 @@ var BaseTable = (props) => {
|
|
|
78
79
|
} = (0, import_useDrawerState.default)();
|
|
79
80
|
const { queryPageConfig, handleValuesChange, refreshData } = (0, import_useTableQuery.default)();
|
|
80
81
|
(0, import_useDesignMode.default)(props, {
|
|
81
|
-
|
|
82
|
+
registerValueVariable,
|
|
82
83
|
openDrawer,
|
|
83
84
|
closeDrawer,
|
|
84
85
|
data: data == null ? void 0 : data.data
|
|
@@ -94,20 +95,20 @@ var BaseTable = (props) => {
|
|
|
94
95
|
}
|
|
95
96
|
}, [queryPageConfig]);
|
|
96
97
|
const handleOpenDrawer = (record, type) => {
|
|
97
|
-
|
|
98
|
-
registerVariable == null ? void 0 : registerVariable({
|
|
98
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
99
99
|
currentRecord: record
|
|
100
100
|
});
|
|
101
|
+
openDrawer(type);
|
|
101
102
|
};
|
|
102
103
|
const handleCloseDrawer = () => {
|
|
103
104
|
closeDrawer();
|
|
104
|
-
|
|
105
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
105
106
|
currentRecord: null
|
|
106
107
|
});
|
|
107
108
|
};
|
|
108
109
|
const handleDelete = async (record) => {
|
|
109
110
|
try {
|
|
110
|
-
|
|
111
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
111
112
|
currentRecord: record
|
|
112
113
|
});
|
|
113
114
|
setTimeout(async () => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const useDesignMode: (props: any, {
|
|
1
|
+
declare const useDesignMode: (props: any, { registerValueVariable, openDrawer, closeDrawer, data }: any) => void;
|
|
2
2
|
export default useDesignMode;
|
|
@@ -23,14 +23,20 @@ __export(useDesignMode_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useDesignMode_exports);
|
|
25
25
|
var import_react = require("react");
|
|
26
|
-
var useDesignMode = (props, {
|
|
27
|
-
const {
|
|
26
|
+
var useDesignMode = (props, { registerValueVariable, openDrawer, closeDrawer, data }) => {
|
|
27
|
+
const {
|
|
28
|
+
__designMode,
|
|
29
|
+
componentId,
|
|
30
|
+
showDetailButton,
|
|
31
|
+
showEditButton,
|
|
32
|
+
showAddButton
|
|
33
|
+
} = props;
|
|
28
34
|
(0, import_react.useEffect)(() => {
|
|
29
35
|
var _a;
|
|
30
36
|
if (__designMode === "design") {
|
|
31
37
|
if (showDetailButton) {
|
|
32
38
|
openDrawer("detail");
|
|
33
|
-
|
|
39
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
34
40
|
currentRecord: ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a[0]) || null
|
|
35
41
|
});
|
|
36
42
|
} else {
|
|
@@ -43,7 +49,7 @@ var useDesignMode = (props, { registerVariable, openDrawer, closeDrawer, data })
|
|
|
43
49
|
if (__designMode === "design") {
|
|
44
50
|
if (showEditButton) {
|
|
45
51
|
openDrawer("edit");
|
|
46
|
-
|
|
52
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
47
53
|
currentRecord: ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a[0]) || null
|
|
48
54
|
});
|
|
49
55
|
} else {
|
|
@@ -55,7 +61,7 @@ var useDesignMode = (props, { registerVariable, openDrawer, closeDrawer, data })
|
|
|
55
61
|
if (__designMode === "design") {
|
|
56
62
|
if (showAddButton) {
|
|
57
63
|
openDrawer("add");
|
|
58
|
-
|
|
64
|
+
registerValueVariable == null ? void 0 : registerValueVariable(componentId, {
|
|
59
65
|
currentRecord: null
|
|
60
66
|
});
|
|
61
67
|
} else {
|
|
@@ -34,7 +34,7 @@ __export(dataSourceTable_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(dataSourceTable_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_BaseTable = __toESM(require("./BaseTable"));
|
|
37
|
-
var import_DataSourceProvider = __toESM(require("../provider/
|
|
37
|
+
var import_DataSourceProvider = __toESM(require("../provider/dataSource/DataSourceProvider"));
|
|
38
38
|
var DataSourceTable = (props) => {
|
|
39
39
|
const { dataSource } = props;
|
|
40
40
|
return /* @__PURE__ */ import_react.default.createElement(import_DataSourceProvider.default, { dataSource }, /* @__PURE__ */ import_react.default.createElement(import_BaseTable.default, { ...props }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ColumnType } from "antd/es/table";
|
|
3
|
-
import { DataSourceType } from "../provider/
|
|
3
|
+
import { DataSourceType } from "../provider/dataSource/DataSourceContext";
|
|
4
4
|
export interface DataSourceTableProps {
|
|
5
5
|
dataSource: DataSourceType;
|
|
6
6
|
columns: ColumnType<any>[];
|
|
@@ -12,4 +12,5 @@ export interface DataSourceTableProps {
|
|
|
12
12
|
editContent?: React.ReactNode;
|
|
13
13
|
addContent?: React.ReactNode;
|
|
14
14
|
__designMode: string;
|
|
15
|
+
componentId: string;
|
|
15
16
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/dataSourceWrapper/index.tsx
|
|
30
|
+
var dataSourceWrapper_exports = {};
|
|
31
|
+
__export(dataSourceWrapper_exports, {
|
|
32
|
+
default: () => dataSourceWrapper_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(dataSourceWrapper_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var DataSourceWrapper = (props) => {
|
|
37
|
+
const { children } = props;
|
|
38
|
+
return /* @__PURE__ */ import_react.default.createElement("div", null, children);
|
|
39
|
+
};
|
|
40
|
+
var dataSourceWrapper_default = DataSourceWrapper;
|
|
@@ -36,5 +36,7 @@ var import_WithMode = __toESM(require("./WithMode"));
|
|
|
36
36
|
var import_utils = require("../../dataSourceForm/utils");
|
|
37
37
|
var Checkbox = (0, import_utils.withFormItem)(import_WithMode.default);
|
|
38
38
|
var CheckboxGroupWithFormItem = (0, import_utils.withFormItem)(import_WithMode.default.Group);
|
|
39
|
-
|
|
39
|
+
var CheckboxGroupWithOptions = (0, import_utils.withOptions)(CheckboxGroupWithFormItem);
|
|
40
|
+
var CheckboxGroupWithDataSource = (0, import_utils.withDataSource)(CheckboxGroupWithOptions);
|
|
41
|
+
Checkbox.Group = CheckboxGroupWithDataSource;
|
|
40
42
|
var Checkbox_default = Checkbox;
|
|
@@ -36,5 +36,7 @@ var import_WithMode = __toESM(require("./WithMode"));
|
|
|
36
36
|
var import_utils = require("../../dataSourceForm/utils");
|
|
37
37
|
var Radio = (0, import_utils.withFormItem)(import_WithMode.default);
|
|
38
38
|
var RadioGroupWithFormItem = (0, import_utils.withFormItem)(import_WithMode.default.Group);
|
|
39
|
-
|
|
39
|
+
var RadioGroupWithOptions = (0, import_utils.withOptions)(RadioGroupWithFormItem);
|
|
40
|
+
var RadioGroupWithDataSource = (0, import_utils.withDataSource)(RadioGroupWithOptions);
|
|
41
|
+
Radio.Group = RadioGroupWithDataSource;
|
|
40
42
|
var Radio_default = Radio;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
|
|
2
|
+
declare const SelectWithDataSource: (props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../../dataSourceForm/utils").WithModeProps & import("../../dataSourceForm/utils").WithFormItemProps & {
|
|
3
|
+
options?: any;
|
|
4
|
+
optionSourceType?: string | undefined;
|
|
5
|
+
labelField: string;
|
|
6
|
+
valueField: string;
|
|
7
|
+
} & {
|
|
8
|
+
dataSource?: any;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export default SelectWithDataSource;
|
|
@@ -34,5 +34,7 @@ __export(Select_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(Select_exports);
|
|
35
35
|
var import_utils = require("../../dataSourceForm/utils");
|
|
36
36
|
var import_WithMode = __toESM(require("./WithMode"));
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var SelectWithFormItem = (0, import_utils.withFormItem)(import_WithMode.default);
|
|
38
|
+
var SelectWithOptions = (0, import_utils.withOptions)(SelectWithFormItem);
|
|
39
|
+
var SelectWithDataSource = (0, import_utils.withDataSource)(SelectWithOptions);
|
|
40
|
+
var Select_default = SelectWithDataSource;
|
|
@@ -12,5 +12,12 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
|
12
12
|
Group: import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
13
13
|
} & {
|
|
14
14
|
Group: import("react").FC<import("./Radio/type").RadioGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
15
|
-
}) |
|
|
15
|
+
}) | ((props: import("antd").SelectProps<any, import("antd/es/select").DefaultOptionType> & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps & {
|
|
16
|
+
options?: any;
|
|
17
|
+
optionSourceType?: string | undefined;
|
|
18
|
+
labelField: string;
|
|
19
|
+
valueField: string;
|
|
20
|
+
} & {
|
|
21
|
+
dataSource?: any;
|
|
22
|
+
}) => import("react").JSX.Element) | import("react").FC<import("antd").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
16
23
|
export { getFieldComponent };
|
|
@@ -110,10 +110,7 @@ var useActions = ({
|
|
|
110
110
|
const getApi = genCustomApi(actions == null ? void 0 : actions.get);
|
|
111
111
|
return getApi({});
|
|
112
112
|
}
|
|
113
|
-
return
|
|
114
|
-
key: name,
|
|
115
|
-
id: "1"
|
|
116
|
-
});
|
|
113
|
+
return {};
|
|
117
114
|
} else if (currentValue) {
|
|
118
115
|
return parseVariable == null ? void 0 : parseVariable(currentValue, {});
|
|
119
116
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 获取当前dataSource
|
|
3
3
|
*/
|
|
4
|
-
declare const useDataSource: () => import("../provider/
|
|
4
|
+
declare const useDataSource: () => import("../provider/dataSource/DataSourceContext").DataSourceContextType;
|
|
5
5
|
export default useDataSource;
|
|
@@ -33,7 +33,7 @@ __export(useDataSource_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(useDataSource_exports);
|
|
35
35
|
var import_react = require("react");
|
|
36
|
-
var import_DataSourceContext = __toESM(require("../provider/
|
|
36
|
+
var import_DataSourceContext = __toESM(require("../provider/dataSource/DataSourceContext"));
|
|
37
37
|
var useDataSource = () => {
|
|
38
38
|
const config = (0, import_react.useContext)(import_DataSourceContext.default);
|
|
39
39
|
return config;
|
package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceContext.js
RENAMED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/components/dataSourceComponents/provider/
|
|
19
|
+
// src/components/dataSourceComponents/provider/dataSource/DataSourceContext.ts
|
|
20
20
|
var DataSourceContext_exports = {};
|
|
21
21
|
__export(DataSourceContext_exports, {
|
|
22
22
|
DataSourceContext: () => DataSourceContext,
|
package/lib/components/dataSourceComponents/provider/{fields → dataSource}/DataSourceProvider.js
RENAMED
|
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/components/dataSourceComponents/provider/
|
|
29
|
+
// src/components/dataSourceComponents/provider/dataSource/DataSourceProvider.tsx
|
|
30
30
|
var DataSourceProvider_exports = {};
|
|
31
31
|
__export(DataSourceProvider_exports, {
|
|
32
32
|
default: () => DataSourceProvider_default
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export interface VariablesContextType {
|
|
3
3
|
variables?: Record<string, any>;
|
|
4
4
|
registerVariable?: (value: Record<string, any>) => void;
|
|
5
|
+
registerValueVariable?: (componentId: string, value: Record<string, any>) => void;
|
|
6
|
+
registerFunctionVariable?: (componentId: string, value: Record<string, any>) => void;
|
|
5
7
|
parseVariable?: (str: string, localVariables: Record<string, any>) => any;
|
|
6
8
|
children?: React.ReactNode;
|
|
7
9
|
}
|
|
@@ -34,10 +34,11 @@ __export(VariablesProvider_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(VariablesProvider_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_utils = require("@pisell/utils");
|
|
37
|
+
var import_ahooks = require("ahooks");
|
|
37
38
|
var import_VariablesContext = __toESM(require("./VariablesContext"));
|
|
38
39
|
var import_utils2 = require("../../dataSourceForm/utils");
|
|
39
40
|
var import_utils3 = require("../../../../utils");
|
|
40
|
-
var
|
|
41
|
+
var import_utils4 = require("./utils");
|
|
41
42
|
var defaultCustomizer = (objValue, srcValue) => {
|
|
42
43
|
if ((0, import_utils.isArr)(srcValue)) {
|
|
43
44
|
return srcValue;
|
|
@@ -63,7 +64,20 @@ var VariablesProvider = (props) => {
|
|
|
63
64
|
value2,
|
|
64
65
|
defaultCustomizer
|
|
65
66
|
);
|
|
67
|
+
console.log("注册变量", value2, "全部变量", variablesRef.current);
|
|
66
68
|
});
|
|
69
|
+
const registerValueVariable = (0, import_ahooks.useMemoizedFn)(
|
|
70
|
+
(componentId, value2) => {
|
|
71
|
+
const variable = (0, import_utils4.genComponentValueVariable)(componentId, value2);
|
|
72
|
+
registerVariable == null ? void 0 : registerVariable(variable);
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
const registerFunctionVariable = (0, import_ahooks.useMemoizedFn)(
|
|
76
|
+
(componentId, value2) => {
|
|
77
|
+
const variable = (0, import_utils4.genComponentFunctionVariable)(componentId, value2);
|
|
78
|
+
registerVariable == null ? void 0 : registerVariable(variable);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
67
81
|
const parseVariable = (0, import_ahooks.useMemoizedFn)(
|
|
68
82
|
(str, localVariables = {}) => {
|
|
69
83
|
var _a;
|
|
@@ -95,9 +109,16 @@ var VariablesProvider = (props) => {
|
|
|
95
109
|
() => ({
|
|
96
110
|
variables: variablesRef.current,
|
|
97
111
|
registerVariable,
|
|
98
|
-
parseVariable
|
|
112
|
+
parseVariable,
|
|
113
|
+
registerValueVariable,
|
|
114
|
+
registerFunctionVariable
|
|
99
115
|
}),
|
|
100
|
-
[
|
|
116
|
+
[
|
|
117
|
+
registerVariable,
|
|
118
|
+
parseVariable,
|
|
119
|
+
registerValueVariable,
|
|
120
|
+
registerFunctionVariable
|
|
121
|
+
]
|
|
101
122
|
);
|
|
102
123
|
return /* @__PURE__ */ import_react.default.createElement(import_VariablesContext.default.Provider, { value }, children);
|
|
103
124
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const genComponentValueVariable: (componentId: string, value: Record<string, any>) => {
|
|
2
|
+
[x: string]: {
|
|
3
|
+
value: Record<string, any>;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
export declare const genComponentFunctionVariable: (componentId: string, value: Record<string, any>) => {
|
|
7
|
+
[x: string]: {
|
|
8
|
+
functions: Record<string, any>;
|
|
9
|
+
};
|
|
10
|
+
};
|