vap1 0.6.5 → 0.6.7

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.
Files changed (41) hide show
  1. package/components/Box/Box.d.ts +14 -2
  2. package/components/Box/Box.js +4 -4
  3. package/components/Lists/VList.js +2 -2
  4. package/components/Lists/components/SearchTool.d.ts +1 -1
  5. package/components/Lists/components/SearchTool.js +2 -2
  6. package/components/Lists/index.d.ts +2 -1
  7. package/components/SearchTool/SearchBand/hooks.js +1 -1
  8. package/components/SearchTool/SearchBand/type.d.ts +2 -2
  9. package/components/SearchTool/SearchBar/ActionButtons.d.ts +2 -2
  10. package/components/SearchTool/SearchBar/ByField.js +3 -3
  11. package/components/SearchTool/SearchBar/type.d.ts +8 -2
  12. package/components/Tables/ApiTable.d.ts +1 -1
  13. package/components/Tables/ApiTable.js +1 -1
  14. package/components/Tables/ApiTableModal.d.ts +1 -1
  15. package/components/Tables/ApiTableModal.js +1 -1
  16. package/components/Tables/Components/useTableContext.d.ts +1 -1
  17. package/components/Tables/Components/useTableContext.js +1 -4
  18. package/components/Tables/VTable.d.ts +1 -1
  19. package/components/Tables/VTable.js +7 -3
  20. package/components/Tables/index.d.ts +1 -1
  21. package/components/UForm/UForm.js +3 -3
  22. package/components/UForm/UFormModal.js +1 -1
  23. package/components/UForm/UInfoModal.js +1 -1
  24. package/components/UForm/_FormUtils.d.ts +1 -1
  25. package/components/UForm/_input.js +1 -1
  26. package/components/UForm/_register.d.ts +1 -1
  27. package/components/UForm/index.d.ts +9 -3
  28. package/components/_common/AutoComplete.d.ts +1 -1
  29. package/components/_common/AutoComplete.js +1 -1
  30. package/hooks/index.d.ts +1 -0
  31. package/hooks/index.js +3 -1
  32. package/hooks/usePreference.d.ts +9 -0
  33. package/hooks/usePreference.js +101 -0
  34. package/package.json +1 -1
  35. package/uform/panel/Propreties/Component/LinkAsyncFunction.js +1 -1
  36. package/uform/panel/Propreties/Component/ValidateAsyncFunction.js +1 -1
  37. package/uform/utils/Convert.js +1 -1
  38. package/utils/CustomApp.d.ts +14 -5
  39. package/utils/Renders/FileRender.d.ts +1 -1
  40. package/utils/Renders/FileRender.js +1 -1
  41. package/utils/py.js +1 -1
@@ -107,9 +107,15 @@ export type BoxProps = SearchTool & {
107
107
  */
108
108
  overflowAuto?: true;
109
109
  /**
110
- * 默认查询参数
110
+ * @deprecated
111
+ * 说明:在一些极端场景下编译,可能会有Bug,
112
+ * 统一使用 defaultParam 替代,后续版本会移除
111
113
  */
112
114
  default?: PlainObject;
115
+ /**
116
+ * 默认查询条件
117
+ */
118
+ defaultParam?: PlainObject;
113
119
  /**
114
120
  * 在部分皮肤下有效,强制不显示背景
115
121
  */
@@ -145,9 +151,15 @@ export declare const Box: React.ForwardRefExoticComponent<SearchTool & {
145
151
  */
146
152
  overflowAuto?: true;
147
153
  /**
148
- * 默认查询参数
154
+ * @deprecated
155
+ * 说明:在一些极端场景下编译,可能会有Bug,
156
+ * 统一使用 defaultParam 替代,后续版本会移除
149
157
  */
150
158
  default?: PlainObject;
159
+ /**
160
+ * 默认查询条件
161
+ */
162
+ defaultParam?: PlainObject;
151
163
  /**
152
164
  * 在部分皮肤下有效,强制不显示背景
153
165
  */
@@ -149,7 +149,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
149
149
  }
150
150
  }, [state === null || state === void 0 ? void 0 : state.height]);
151
151
  var resize = (0, react_1.useCallback)(function () {
152
- if (mode == 'common' || app == null) {
152
+ if (mode == 'common') {
153
153
  if (state === null)
154
154
  setState({});
155
155
  return;
@@ -207,7 +207,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
207
207
  // const isFix = _.isBoolean(props.searchBand.fixMode) ? props.searchBand.fixMode : CONFIG.SEARCHBAND.FIX_MODE;
208
208
  // return <SearchBand
209
209
  // {...props.searchBand}
210
- // default={props.default}
210
+ // defaultParam={props.defaultParam || props.default}
211
211
  // className={HEIGHT_OMIT}
212
212
  // extraAction={null}
213
213
  // onSearch={(data) => {
@@ -217,7 +217,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
217
217
  // >{action}</SearchBand>
218
218
  // }
219
219
  if (hasBar) {
220
- return react_1.default.createElement(SearchBar_1.SearchBar, __assign({}, props.searchBar, { default: props.default, className: HEIGHT_OMIT, onExpand: function (isExpand) {
220
+ return react_1.default.createElement(SearchBar_1.SearchBar, __assign({}, props.searchBar, { defaultParam: props.defaultParam || props.default, className: HEIGHT_OMIT, onExpand: function (isExpand) {
221
221
  resize();
222
222
  if (lodash_1.default.isFunction(props.searchBar.onExpand)) {
223
223
  props.searchBar.onExpand(isExpand);
@@ -225,7 +225,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
225
225
  } }), action);
226
226
  }
227
227
  if (action) {
228
- return react_1.default.createElement(SearchBar_1.SearchBar, { onSearch: LOOP, default: props.default, className: HEIGHT_OMIT, onExpand: LOOP }, action);
228
+ return react_1.default.createElement(SearchBar_1.SearchBar, { onSearch: LOOP, defaultParam: props.defaultParam || props.default, className: HEIGHT_OMIT, onExpand: LOOP }, action);
229
229
  }
230
230
  return utils_1.Const.NONE;
231
231
  }, [props.actionBar, props.searchBar,
@@ -60,7 +60,7 @@ var VList = function (props) {
60
60
  var model = props.model;
61
61
  var app = (0, useApp_1.useApp)();
62
62
  var _a = (0, LayoutSwitcher_1.useListLayout)(props), layout = _a.layout, layouts = _a.layouts, setLayout = _a.setLayout;
63
- (0, react_1.useLayoutEffect)(function () { model.query(props.default || {}); }, []);
63
+ (0, react_1.useLayoutEffect)(function () { model.query(props.defaultParam || {}); }, []);
64
64
  var extraAction = (0, react_1.useMemo)(function () {
65
65
  if (layouts.length <= 1)
66
66
  return null;
@@ -85,7 +85,7 @@ var VList = function (props) {
85
85
  return classNames.join(' ');
86
86
  }, [props.className]);
87
87
  return react_1.default.createElement("div", { style: style, className: clazz },
88
- react_1.default.createElement(SearchTool_1.SearchTool, __assign({}, props, { onSearch: function (data) { return model.query(data, true); }, default: props.default, extraAction: extraAction, children: lodash_1.default.isEmpty(props.actionBar) ? undefined : (lodash_1.default.isArray(props.actionBar) ? react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: props.actionBar }) : props.actionBar) })),
88
+ react_1.default.createElement(SearchTool_1.SearchTool, __assign({}, props, { onSearch: function (data) { return model.query(data, true); }, defaultParam: props.defaultParam, extraAction: extraAction, children: lodash_1.default.isEmpty(props.actionBar) ? undefined : (lodash_1.default.isArray(props.actionBar) ? react_1.default.createElement(ActionButtons_1.ActionButtons, { buttons: props.actionBar }) : props.actionBar) })),
89
89
  react_1.default.createElement(BaseList_1.BaseList, __assign({}, props, { layout: layout, style: null, className: null, dataSource: model.list, loading: model.isQuerying })),
90
90
  props.pagination !== false && react_1.default.createElement(Upagination_1.UPagination, __assign({}, (0, Upagination_1.defaultPaginationProps)(props.pagination), { disabled: model.isQuerying, total: model.total, totalAcc: model.totalAcc, onChange: model.pageTo })));
91
91
  };
@@ -8,6 +8,6 @@ export type SearchToolProps = XOR<{
8
8
  }>;
9
9
  export declare const SearchTool: FC<PropsWithChildren<SearchToolProps & {
10
10
  onSearch: (data: PlainObject) => void;
11
- default?: any;
11
+ defaultParam?: any;
12
12
  extraAction?: ReactNode;
13
13
  }>>;
@@ -26,9 +26,9 @@ var SearchTool = function (props) {
26
26
  return react_1.default.createElement(SearchTool_1.SearchBar, { onSearch: function () { }, children: props.children });
27
27
  }
28
28
  if (props.searchBand)
29
- return react_1.default.createElement(SearchTool_1.SearchBand, __assign({}, props.searchBand, { default: props.default, onSearch: props.onSearch, children: props.children, extraAction: props.extraAction }));
29
+ return react_1.default.createElement(SearchTool_1.SearchBand, __assign({}, props.searchBand, { defaultParam: props.defaultParam, onSearch: props.onSearch, children: props.children, extraAction: props.extraAction }));
30
30
  if (props.searchBar)
31
- return react_1.default.createElement(SearchTool_1.SearchBar, __assign({}, props.searchBar, { default: props.default, onSearch: props.onSearch, children: props.children }));
31
+ return react_1.default.createElement(SearchTool_1.SearchBar, __assign({}, props.searchBar, { defaultParam: props.defaultParam, onSearch: props.onSearch, children: props.children }));
32
32
  return Const_1.NONE;
33
33
  };
34
34
  exports.SearchTool = SearchTool;
@@ -123,7 +123,8 @@ export type ListRenderDefine = {
123
123
  export type ListLayoutType = keyof ListRenderDefine;
124
124
  type CommonListProps = Pick<ListProps<PlainObject>, 'rowKey' | 'className' | 'style'> & ListRenderDefine & {
125
125
  defaultLayout?: ListLayoutType;
126
+ onLayoutChange?: (layout: ListLayoutType) => void;
126
127
  };
127
128
  export type BaseListProps = CommonListProps & Pick<ListProps<PlainObject>, 'dataSource' | 'loading'>;
128
- export type VListProps = CommonListProps & SearchToolProps & Pick<VTableProps, 'default' | 'model' | 'mode' | 'pagination' | 'actionBar'>;
129
+ export type VListProps = CommonListProps & SearchToolProps & Pick<VTableProps, 'defaultParam' | 'model' | 'mode' | 'pagination' | 'actionBar'>;
129
130
  export {};
@@ -129,7 +129,7 @@ var useTableColumns = function (props, labelWidth, data, fixMode) {
129
129
  }, [data]);
130
130
  };
131
131
  var useSearchBand = function (props, fixMode) {
132
- var _a = __read((0, react_1.useState)(props.default || {}), 2), state = _a[0], setState = _a[1];
132
+ var _a = __read((0, react_1.useState)(props.defaultParam || {}), 2), state = _a[0], setState = _a[1];
133
133
  var isFristMount = (0, hooks_1.useFirstMountState)();
134
134
  var labelWidth = (0, react_1.useMemo)(function () {
135
135
  if (lodash_1.default.isNumber(props.labelWidth))
@@ -44,8 +44,8 @@ export type SearchBandProps = {
44
44
  onSearch: (param: PlainObject) => void;
45
45
  /**
46
46
  * 默认参数
47
- */
48
- default?: PlainObject;
47
+ */
48
+ defaultParam?: PlainObject;
49
49
  /**
50
50
  * 如果为true, 则不会以Tag显示
51
51
  */
@@ -42,9 +42,9 @@ export type ActButton = {
42
42
  /**
43
43
  * 说明 : 最多支持2级子菜单,不能递归
44
44
  */
45
- children?: ActButton[];
45
+ children?: Array<ActButton>;
46
46
  };
47
47
  export declare const ActionButtons: FC<{
48
- buttons: (ActButton | null | false)[];
48
+ buttons: Array<ActButton | null | false>;
49
49
  size?: ButtonSize;
50
50
  }>;
@@ -75,15 +75,15 @@ var SearchField_1 = require("./SearchField");
75
75
  var _register_1 = require("./_register");
76
76
  exports.InnerSearchBarByField = (0, react_1.forwardRef)(function (props, ref) {
77
77
  var isAwaysExpand = utils_1.GLOBAL.CONFIG.SEARCHBAR.AWAYS_EXPAND || props.__innerExpand;
78
- var _a = __read((0, react_1.useState)(props.default || {}), 2), data = _a[0], setData = _a[1];
78
+ var _a = __read((0, react_1.useState)(props.defaultParam || props.default || {}), 2), data = _a[0], setData = _a[1];
79
79
  var _b = __read((0, react_1.useState)(isAwaysExpand), 2), isExpand = _b[0], _setIsExpand = _b[1];
80
80
  var clear = (0, react_1.useCallback)(function () { return setData(function (prev) {
81
81
  var data = {};
82
82
  lodash_1.default.keys(prev).map(function (item) {
83
83
  data[item] = null;
84
84
  });
85
- if (props.default) {
86
- return lodash_1.default.extend({}, data, props.default);
85
+ if (props.defaultParam || props.default) {
86
+ return lodash_1.default.extend({}, data, props.defaultParam || props.default);
87
87
  }
88
88
  return data;
89
89
  }); }, []);
@@ -48,9 +48,15 @@ export type SearchBarByFieldProps = {
48
48
  */
49
49
  onExpand?: (isShowMore: boolean) => void;
50
50
  /**
51
- * 默认参数
51
+ * @deprecated
52
+ * 说明:在一些极端场景下编译,可能会有Bug,
53
+ * 统一使用 defaultParam 替代,后续版本会移除
52
54
  */
53
- default?: any;
55
+ default?: PlainObject;
56
+ /**
57
+ * 默认参数
58
+ */
59
+ defaultParam?: PlainObject;
54
60
  /**
55
61
  * 用于单独使用时,不需要按钮的情况
56
62
  */
@@ -3,7 +3,7 @@ import type { BaseTableProps } from './index';
3
3
  import type { ApiModel } from '../../hooks/_list';
4
4
  import type { ApiOption } from '../../hooks/useApiBase';
5
5
  export type ApiTableProps = BaseTableProps & Pick<ApiOption, 'api' | 'aop' | 'tipDisabled' | 'tipField'>;
6
- export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar"> & {
6
+ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
7
7
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
8
8
  } & {
9
9
  columns: import("./index").TableCol[];
@@ -52,7 +52,7 @@ exports.ApiTable = (0, react_1.forwardRef)(function (props, ref) {
52
52
  var option = {
53
53
  api: props.api,
54
54
  rowKey: props.rowKey,
55
- param: props.default,
55
+ param: props.defaultParam || props.default || {},
56
56
  aop: props.aop,
57
57
  tipDisabled: props.tipDisabled,
58
58
  tipField: props.tipField,
@@ -3,7 +3,7 @@ import type { ModalProps } from '../_adapt/Modal';
3
3
  import type { ApiTableProps } from './ApiTable';
4
4
  import type { ApiModel } from '../../hooks/_list';
5
5
  export type ApiTableModalProps = ApiTableProps & ModalProps;
6
- export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar"> & {
6
+ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").TableDefine & Pick<import("../..").BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
7
7
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
8
8
  } & {
9
9
  columns: import(".").TableCol[];
@@ -71,7 +71,7 @@ var ApiTable_1 = require("./ApiTable");
71
71
  var utils_1 = require("../../utils");
72
72
  var API_TABLE_PROPERTIES = [
73
73
  'api', 'aop', 'tipDisabled', 'tipField',
74
- 'mode', 'columns', 'showIndex', 'rowKey', 'select', 'selectDisabled', 'actionBar', 'selectBar', 'searchBar', 'default', 'autoLoad'
74
+ 'mode', 'columns', 'showIndex', 'rowKey', 'select', 'selectDisabled', 'actionBar', 'selectBar', 'searchBar', 'default', 'defaultParam', 'autoLoad'
75
75
  ];
76
76
  exports.ApiTableModal = (0, react_1.forwardRef)(function (props, ref) {
77
77
  var modalProps = lodash_1.default.omit(props, API_TABLE_PROPERTIES);
@@ -11,6 +11,6 @@ type TableAction = {
11
11
  initObjects: (List: Array<any>) => void;
12
12
  reflushPage: (List: Array<any>) => void;
13
13
  };
14
- export declare const TableContextWrapper: FC<PropsWithChildren<Pick<VTableProps, 'default' | 'defaultSelectedKeys' | 'rowKey'>>>;
14
+ export declare const TableContextWrapper: FC<PropsWithChildren<Pick<VTableProps, 'defaultParam' | 'defaultSelectedKeys' | 'rowKey'>>>;
15
15
  export declare const useTableContext: () => TableContext & TableAction;
16
16
  export {};
@@ -73,14 +73,11 @@ var TableContextWrapper = function (props) {
73
73
  var DEFAULT = {
74
74
  selectedRowKeys: [],
75
75
  selectedObjects: [],
76
- param: {},
76
+ param: props.defaultParam || {},
77
77
  };
78
78
  if (lodash_1.default.isArray(props.defaultSelectedKeys)) {
79
79
  DEFAULT.selectedRowKeys = props.defaultSelectedKeys;
80
80
  }
81
- if (props.default) {
82
- DEFAULT.param = __assign({}, props.default);
83
- }
84
81
  return DEFAULT;
85
82
  }), 2), state = _a[0], setState = _a[1];
86
83
  var setSelection = (0, react_1.useCallback)(function (selectedRowKeys, selectedObjects) {
@@ -27,7 +27,7 @@ export type VTableProps = BaseTableProps & {
27
27
  */
28
28
  onSelectedChange?: (selectedRowKeys: Key[], selectedRows?: any[]) => void;
29
29
  };
30
- export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<BoxProps, "default" | "mode" | "selectBar"> & {
30
+ export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & Pick<BoxProps, "default" | "mode" | "selectBar" | "defaultParam"> & {
31
31
  searchBar?: Omit<import("../SearchTool").SearchBarProps, "onChange" | "onSearch">;
32
32
  } & {
33
33
  columns: import("./index").TableCol[];
@@ -128,7 +128,7 @@ var _VTable = (0, react_1.forwardRef)(function (props) {
128
128
  return;
129
129
  if (lodash_1.default.isFunction((_b = props.selectBar) === null || _b === void 0 ? void 0 : _b.onSelect)) {
130
130
  var param = (_a = props.selectBar).onSelect.apply(_a, __spreadArray([], __read(state.selected), false));
131
- query(__assign(__assign({}, props.default), param));
131
+ query(__assign(__assign({}, (props.defaultParam || props.default)), param));
132
132
  }
133
133
  }, [state.selected]);
134
134
  // 更新页数
@@ -162,7 +162,7 @@ var _VTable = (0, react_1.forwardRef)(function (props) {
162
162
  return;
163
163
  if (lodash_1.default.has(props.selectBar, 'config.mustSelect') && props.selectBar.config.mustSelect == true)
164
164
  return;
165
- query(props.default || {});
165
+ query(props.defaultParam || props.default || {});
166
166
  }, []);
167
167
  // 更新高度 table 需要把 head 排除设置滚动
168
168
  // useEffect(() => {
@@ -316,7 +316,11 @@ var VTableRoot = (0, react_1.forwardRef)(function (props, ref) {
316
316
  });
317
317
  exports.VTable = (0, react_1.forwardRef)(function (props, ref) {
318
318
  var _a;
319
- var initValue = (0, react_1.useMemo)(function () { return lodash_1.default.pick(props, ['defaultSelectedKeys', 'default']); }, []);
319
+ var initValue = (0, react_1.useMemo)(function () {
320
+ var initProps = lodash_1.default.pick(props, ['defaultSelectedKeys', 'rowKey']);
321
+ initProps.defaultParam = props.defaultParam || props.default || {};
322
+ return initProps;
323
+ }, []);
320
324
  return react_1.default.createElement(useTableContext_1.TableContextWrapper, __assign({}, initValue, { rowKey: ((_a = props.model) === null || _a === void 0 ? void 0 : _a.rowKey) || props.rowKey || 'id' }),
321
325
  react_1.default.createElement(VTableRoot, __assign({}, props, { ref: ref })));
322
326
  });
@@ -22,7 +22,7 @@ type SearchToolProps = {
22
22
  * 所有VAP组装 Table 排除一些自定义属性
23
23
  */
24
24
  export type TableDefine = Omit<TableProps<PlainObject>, 'size' | 'columns' | 'dataSource' | 'bordered' | 'rowKey' | 'title' | 'loading' | 'onChange' | 'rowSelection' | 'getPopupContainer' | 'sortDirections' | 'showSorterTooltip' | 'internalHooks' | 'transformColumns' | 'internalRefs'>;
25
- export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' | 'default'> & SearchToolProps & {
25
+ export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' | 'defaultParam' | 'default'> & SearchToolProps & {
26
26
  /**
27
27
  * 列
28
28
  */
@@ -413,7 +413,7 @@ var getValue = function (multipleFields, values, initRef) {
413
413
  };
414
414
  var initValue = function (props) {
415
415
  var e_1, _a;
416
- var values = __assign(__assign({}, props.default), props.data);
416
+ var values = __assign(__assign({}, (props.defaultValue || props.default)), props.data);
417
417
  var _loop_1 = function (key) {
418
418
  var fields = key.split(',').map(lodash_1.default.trim);
419
419
  if (fields.length == 1) {
@@ -564,10 +564,10 @@ var _UForm = (0, react_1.forwardRef)(function (props, ref) {
564
564
  if (state.isGroup)
565
565
  clazz.push('c-form-group');
566
566
  return react_1.default.createElement(antd_1.Form
567
- // initialValues={props.default}
567
+ // initialValues={props.defaultValue || props.default}
568
568
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
569
569
  , {
570
- // initialValues={props.default}
570
+ // initialValues={props.defaultValue || props.default}
571
571
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
572
572
  className: clazz.join(' '), style: { width: state.width }, form: form },
573
573
  props.tip && react_1.default.createElement("div", { className: 'c-form-tip' }, props.tip),
@@ -93,7 +93,7 @@ var UForm_1 = require("./UForm");
93
93
  var utils_1 = require("../../utils");
94
94
  var _i18n_1 = require("../_i18n");
95
95
  var FormWrapper_1 = require("./FormWrapper");
96
- var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'size', 'width'];
96
+ var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'defaultValue', 'data', 'mode', 'size', 'width'];
97
97
  var UFormModal = function (props) {
98
98
  var ref = (0, react_1.useRef)(null);
99
99
  var modalProps = {
@@ -22,7 +22,7 @@ var utils_1 = require("../../utils");
22
22
  var UInfo_1 = require("./UInfo");
23
23
  var _i18n_1 = require("../_i18n");
24
24
  var FormWrapper_1 = require("./FormWrapper");
25
- var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'hideBorder', 'theme'];
25
+ var FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'defaultValue', 'data', 'mode', 'hideBorder', 'theme'];
26
26
  var UInfoModal = function (props) {
27
27
  var param = lodash_1.default.omit(props, FORM_FIELDS);
28
28
  if (!lodash_1.default.has(props, 'title') && lodash_1.default.has(props, 'autoTitle')) {
@@ -1,5 +1,5 @@
1
1
  import type { UFormField } from './index';
2
2
  import type { BaseOption } from '../../basetype';
3
3
  import type { ValidationRule } from 'antd/es/form/Form';
4
- export declare const requireStatus: (field: UFormField, required: Map<string, boolean>, disabled: Set<string>, hiden: Set<string>) => [boolean, ValidationRule[]];
4
+ export declare const requireStatus: (field: UFormField, required: Map<string, boolean>, disabled: Set<string>, hiden: Set<string>) => [boolean, Array<ValidationRule>];
5
5
  export declare const getOptions: (items: BaseOption[], field: UFormField, data: any) => BaseOption[];
@@ -159,7 +159,7 @@ var builderApiTableSerletor = function (options, nameIdx) { return function (pro
159
159
  };
160
160
  return react_1.default.createElement(react_1.Fragment, null,
161
161
  values[0] != undefined ? react_1.default.createElement(Button_1.Button, __assign({}, params, { icon: 'select', onClick: function () { return setOpen(true); } }), getTip(values)) : react_1.default.createElement(Button_1.Button, __assign({}, params, { icon: 'select', onClick: function () { return setOpen(true); } }), (0, exports.getPlaceholder)(field, true)),
162
- react_1.default.createElement(Tables_1.ApiTableModal, __assign({ title: options.title, searchBar: options.searchBar, width: options.width || 720 }, field.config, { api: options.api, default: defaultParam, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
162
+ react_1.default.createElement(Tables_1.ApiTableModal, __assign({ title: options.title, searchBar: options.searchBar, width: options.width || 720 }, field.config, { api: options.api, defaultParam: defaultParam, columns: __spreadArray(__spreadArray([], __read(options.columns), false), [
163
163
  Tables_1.ApiTable.COL_OPERACTION({ render: function (data) { return react_1.default.createElement(Tables_1.ApiTable.ACTION, { title: "\u9009\u62E9", icon: "select", onClick: function () { return onSelect(data); } }); } })
164
164
  ], false), open: open, onCancel: function () { return setOpen(false); } })));
165
165
  }; };
@@ -69,7 +69,7 @@ export type FormFieldOptions = {
69
69
  * 校验规则
70
70
  * 支持传Rule, Rule数组,及一个方法,接收一个数组
71
71
  */
72
- rules?: ValidationRule | ValidationRule[] | ((field: UFormField) => ValidationRule | ValidationRule[]);
72
+ rules?: ValidationRule | Array<ValidationRule> | ((field: UFormField) => ValidationRule | Array<ValidationRule>);
73
73
  };
74
74
  export type FormField = FormFieldOptions & {
75
75
  component: FormFieldComponent;
@@ -172,12 +172,12 @@ export type UFormField = BaseItem & {
172
172
  /**
173
173
  * rules 用法: https://github.com/yiminghe/async-validator
174
174
  */
175
- rules?: ValidationRule[];
175
+ rules?: Array<ValidationRule>;
176
176
  /**
177
177
  * 字段联动,目前只支持 `text` `select` 类型,受影响的字段只能是具有 `options` 属性的类型
178
178
  *
179
179
  */
180
- link?: Link[];
180
+ link?: Array<Link>;
181
181
  /**
182
182
  * (试验中,暂不要使用)
183
183
  * 在复杂类型中使用时,可使用dataType定义类型
@@ -266,9 +266,15 @@ export type UFromProps = {
266
266
  */
267
267
  tip?: ReactNode;
268
268
  /**
269
- * 默认
269
+ * @deprecated
270
+ * 说明:在一些极端场景下编译,可能会有Bug,
271
+ * 统一使用 defaultValue 替代,后续版本会移除
270
272
  */
271
273
  default?: PlainObject;
274
+ /**
275
+ * 默认值
276
+ */
277
+ defaultValue?: PlainObject;
272
278
  /**
273
279
  * 数据
274
280
  */
@@ -23,7 +23,7 @@ export interface IAutoCompleteProps extends Omit<AutoCompleteProps, 'onChange'>
23
23
  /**
24
24
  * 接口默认参数
25
25
  */
26
- default?: any;
26
+ defaultParam?: any;
27
27
  onChange?: (value: any, option: any) => void;
28
28
  }
29
29
  /**
@@ -141,7 +141,7 @@ var IAutoComplete = function (props) {
141
141
  setOptions(cacheRef.current.get(text));
142
142
  return [2 /*return*/];
143
143
  }
144
- param = lodash_1.default.merge({ start_: 0, count_: 15 }, props.default);
144
+ param = lodash_1.default.merge({ start_: 0, count_: 15 }, props.defaultParam);
145
145
  if (text) {
146
146
  param[paramField] = text;
147
147
  }
package/hooks/index.d.ts CHANGED
@@ -13,4 +13,5 @@ export { useOpenState } from './useOpenState';
13
13
  export { useFirstMountState } from './useFirstMountState';
14
14
  export { useToggle } from './useToggle';
15
15
  export { useUpdate } from './useUpdate';
16
+ export { usePreference } from './usePreference';
16
17
  export { useSyncExternalStore } from './useSyncExternalStore';
package/hooks/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSyncExternalStore = exports.useUpdate = exports.useToggle = exports.useFirstMountState = exports.useOpenState = exports.useAjaxAction = exports.useAjaxQuery = exports.useEffectFunction = exports.useModals = exports.useGlobal = exports.useDoLoad = exports.useSetState = exports.useArray = exports.useApiGlobal = exports.useApi = exports.useApp = void 0;
3
+ exports.useSyncExternalStore = exports.usePreference = exports.useUpdate = exports.useToggle = exports.useFirstMountState = exports.useOpenState = exports.useAjaxAction = exports.useAjaxQuery = exports.useEffectFunction = exports.useModals = exports.useGlobal = exports.useDoLoad = exports.useSetState = exports.useArray = exports.useApiGlobal = exports.useApi = exports.useApp = void 0;
4
4
  // export type { GlobalApp } from './useApp';
5
5
  var useApp_1 = require("./useApp");
6
6
  Object.defineProperty(exports, "useApp", { enumerable: true, get: function () { return useApp_1.useApp; } });
@@ -46,6 +46,8 @@ Object.defineProperty(exports, "useToggle", { enumerable: true, get: function ()
46
46
  var useUpdate_1 = require("./useUpdate");
47
47
  Object.defineProperty(exports, "useUpdate", { enumerable: true, get: function () { return useUpdate_1.useUpdate; } });
48
48
  // export { useUpdateEffect } from './useUpdateEffect';
49
+ var usePreference_1 = require("./usePreference");
50
+ Object.defineProperty(exports, "usePreference", { enumerable: true, get: function () { return usePreference_1.usePreference; } });
49
51
  var useSyncExternalStore_1 = require("./useSyncExternalStore");
50
52
  Object.defineProperty(exports, "useSyncExternalStore", { enumerable: true, get: function () { return useSyncExternalStore_1.useSyncExternalStore; } });
51
53
  // 说明: 主要从以下两个库中提取常用hooks 集成至VAP
@@ -0,0 +1,9 @@
1
+ type UsePreferenceConfig = {
2
+ module: string;
3
+ key: string;
4
+ defaultValue?: string;
5
+ allowValue?: Array<string>;
6
+ };
7
+ type UsePreferenceResult = [boolean, string, (val: string) => void];
8
+ export declare const usePreference: (config: UsePreferenceConfig) => UsePreferenceResult;
9
+ export {};
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __importDefault = (this && this.__importDefault) || function (mod) {
55
+ return (mod && mod.__esModule) ? mod : { "default": mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.usePreference = void 0;
59
+ var lodash_1 = __importDefault(require("lodash"));
60
+ var react_1 = require("react");
61
+ var useApp_1 = require("./useApp");
62
+ var usePreference = function (config) {
63
+ var _a = (0, useApp_1.useApp)().user, getConfig = _a.getConfig, setConfig = _a.setConfig;
64
+ var _b = __read((0, react_1.useState)(null), 2), value = _b[0], setValue = _b[1];
65
+ var allowValue = (0, react_1.useCallback)(function (value) {
66
+ if (lodash_1.default.isArray(config.allowValue) && config.allowValue.length > 0) {
67
+ return lodash_1.default.includes(config.allowValue, value);
68
+ }
69
+ return true;
70
+ }, []);
71
+ var set = (0, react_1.useCallback)(function (value) { return __awaiter(void 0, void 0, void 0, function () {
72
+ var isOk;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ if (!allowValue(value))
77
+ return [2 /*return*/];
78
+ return [4 /*yield*/, setConfig(config.module, config.key, value)];
79
+ case 1:
80
+ isOk = _a.sent();
81
+ if (isOk) {
82
+ setValue(value);
83
+ }
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); }, []);
88
+ (0, react_1.useEffect)(function () {
89
+ getConfig(config.module, config.key).then(function (result) {
90
+ var value = result || config.defaultValue || '';
91
+ if (allowValue(value)) {
92
+ setValue(value);
93
+ }
94
+ else {
95
+ setValue(config.defaultValue || '');
96
+ }
97
+ });
98
+ }, []);
99
+ return [value === null, value === null ? config.defaultValue : value, set];
100
+ };
101
+ exports.usePreference = usePreference;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.6.5","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.6.7","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -102,7 +102,7 @@ var LinkAsyncFunction = function (props) {
102
102
  react_1.default.createElement("b", null, "dayjs")),
103
103
  react_1.default.createElement("li", { style: { listStyle: 'none' } },
104
104
  "\u65B9\u6CD5\u8FD4\u56DE\u6253\u5370 \uFF1A",
105
- react_1.default.createElement("b", null, "print"))) }), title: props.isEdit ? '编辑联动方法' : '添加联动方法', default: { method: 'GET', url: '/api/${value}' }, fields: [
105
+ react_1.default.createElement("b", null, "print"))) }), title: props.isEdit ? '编辑联动方法' : '添加联动方法', defaultValue: { method: 'GET', url: '/api/${value}' }, fields: [
106
106
  { field: 'field', title: '被联动字段', required: true, options: targetOptions, type: 'select' },
107
107
  {
108
108
  field: 'url,method', title: '请求',
@@ -64,7 +64,7 @@ var ValidateAsyncFunction = function (props) { return react_1.default.createElem
64
64
  "\u652F\u6301 lodash \u53D8\u91CF\u540D \uFF1A",
65
65
  react_1.default.createElement("b", null, "_")),
66
66
  react_1.default.createElement("li", { style: { listStyle: 'none' } },
67
- react_1.default.createElement(index_1.Alert, { type: "error", message: "\u8BF4\u660E2\uFF1A\u5F02\u6B65\u9A8C\u8BC1\u4EC5\u652F\u6301 VAP2, \u6682\u4E0D\u652F\u6301 VAP1" }))) }), title: props.isEdit ? '编辑校验方法' : '添加校验方法', default: { method: 'GET', url: '/api/${value}' }, fields: [
67
+ react_1.default.createElement(index_1.Alert, { type: "error", message: "\u8BF4\u660E2\uFF1A\u5F02\u6B65\u9A8C\u8BC1\u4EC5\u652F\u6301 VAP2, \u6682\u4E0D\u652F\u6301 VAP1" }))) }), title: props.isEdit ? '编辑校验方法' : '添加校验方法', defaultValue: { method: 'GET', url: '/api/${value}' }, fields: [
68
68
  {
69
69
  field: 'url,method', title: '请求',
70
70
  type: 'input-with-select',
@@ -311,7 +311,7 @@ var schemaToForm = function (schema) {
311
311
  if (schema.size)
312
312
  uformProps.size = schema.size;
313
313
  if (lodash_1.default.keys(defaultValue).length > 0)
314
- uformProps.default = defaultValue;
314
+ uformProps.defaultValue = defaultValue;
315
315
  return uformProps;
316
316
  };
317
317
  exports.schemaToForm = schemaToForm;
@@ -39,10 +39,10 @@ export type Menu = {
39
39
  *
40
40
  * 1 :菜单组
41
41
  * 2 : 链接
42
- * 3 : 权限码
43
- * 4 : 小组件
42
+ * 3 : 权限码 - 无效
43
+ * 4 : 小组件 -无效
44
44
  */
45
- type: 1 | 2 | 3 | 4;
45
+ type: 1 | 2;
46
46
  /**
47
47
  * 图标
48
48
  */
@@ -72,12 +72,21 @@ export type Menu = {
72
72
  * type = 1 时存在
73
73
  * 其它 type 也可存在,但只能放置权限码
74
74
  */
75
- children?: Menu[];
75
+ children?: Array<Menu>;
76
76
  };
77
77
  type CustomAppMenu = {
78
+ /**
79
+ * none: (默认)无菜单模式
80
+ * 一般情况下,注册一个 '/' 路由即可
81
+ * list: 自定义菜单模式
82
+ * 使用 list 模式时,必须指定 list , 为已经整理好结构的 Menu 结构
83
+ * parent: 向上找一个菜单
84
+ * 使用 parent 模式时,必须指定 parent
85
+ * 使用资源里面的菜单
86
+ */
78
87
  mode?: 'none' | 'list' | 'parent';
79
88
  parent?: string;
80
- list?: Menu[];
89
+ list?: Array<Menu>;
81
90
  };
82
91
  export type CustomAppTheme = {
83
92
  /**
@@ -5,7 +5,7 @@ type ImgRenderOptions = {
5
5
  style?: CSSProperties;
6
6
  width?: number;
7
7
  height?: number;
8
- default?: string;
8
+ defaultValue?: string;
9
9
  };
10
10
  export declare const ImgRender: (option?: ImgRenderOptions) => (link: string) => React.JSX.Element;
11
11
  export declare const imgRender: (link: string) => React.JSX.Element;
@@ -98,7 +98,7 @@ var ImgRender = function (option) {
98
98
  style.height = 80;
99
99
  style.width = 80;
100
100
  }
101
- var defaultValue = (option === null || option === void 0 ? void 0 : option.default) || null;
101
+ var defaultValue = (option === null || option === void 0 ? void 0 : option.defaultValue) || null;
102
102
  if (lodash_1.default.has(option, 'style')) {
103
103
  style = __assign(__assign({}, style), option.style);
104
104
  }
package/utils/py.js CHANGED
@@ -89,7 +89,7 @@ var matchKeywordByIndex = function (key, index) {
89
89
  /**
90
90
  * 4. 如果原文本已经遍历完成 ,不管关键字有没有完成 ,都直接中段
91
91
  */
92
- if (textCursor >= (textLen - 1))
92
+ if (textCursor >= textLen)
93
93
  break;
94
94
  keywordCursor++;
95
95
  }