vap1 0.1.1 → 0.1.3

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.
@@ -64,7 +64,7 @@ const BoxContext = (0, react_1.createContext)(null);
64
64
  * */
65
65
  const useBox = () => (0, react_1.useContext)(BoxContext);
66
66
  exports.useBox = useBox;
67
- exports.Box = react_1.default.forwardRef((props, ref) => {
67
+ exports.Box = (0, react_1.forwardRef)((props, ref) => {
68
68
  const app = (0, hooks_1.useApp)();
69
69
  const [state, setState] = (0, hooks_1.useSetState)(null);
70
70
  const _layoutRef = (0, react_1.useRef)(null); // 向下兼容
@@ -125,11 +125,9 @@ exports.Box = react_1.default.forwardRef((props, ref) => {
125
125
  document.body.classList.remove('v-resizing');
126
126
  };
127
127
  (0, react_1.useEffect)(() => { setTimeout(resize, 2); }, [app === null || app === void 0 ? void 0 : app.theme.contentHeight]);
128
+ (0, react_1.useImperativeHandle)(ref, () => ({ resize }), []);
128
129
  (0, react_1.useLayoutEffect)(() => {
129
- if (ref) {
130
- ref.current = { resize };
131
- }
132
- setTimeout(resize, 1);
130
+ setTimeout(resize, 5);
133
131
  }, []);
134
132
  let paginationProps = {};
135
133
  // if (props.pagination && props.mode == 'inner') {
@@ -35,7 +35,7 @@ const utils_1 = require("../../utils");
35
35
  const _register_1 = require("./_register");
36
36
  const Const_1 = require("../_setup/Const");
37
37
  const Icon_1 = require("../_adapt/Icon");
38
- exports.SelectBar = react_1.default.forwardRef((props, ref) => {
38
+ exports.SelectBar = (0, react_1.forwardRef)((props, ref) => {
39
39
  const [keyword, setKeyword] = (0, react_1.useState)(null);
40
40
  const [collapsed, setCollapsed] = (0, hooks_1.useToggle)(false);
41
41
  // const setKeyword = _.debounce(_setKeyword, 100);
@@ -15,6 +15,10 @@ const _SearchBar = props => {
15
15
  if (utils_1.GLOBAL.CONFIG.SEARCHBAR.REVERSE)
16
16
  clazz.push('c-searchbar-reverse');
17
17
  if (!lodash_1.default.isArray(props.fields) || props.fields.length == 0) {
18
+ if (lodash_1.default.has(props, 'keyword'))
19
+ return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
20
+ react_1.default.createElement(ByKeyword_1.SearchBarByKeyword, Object.assign({}, props)),
21
+ react_1.default.createElement("div", { className: 'c-searchbar-actions' }, props.children));
18
22
  if (!lodash_1.default.has(props, 'children'))
19
23
  return react_1.default.createElement(react_1.default.Fragment, null);
20
24
  return react_1.default.createElement("div", { className: utils_1.StringUtil.className(clazz, props.className) },
@@ -27,7 +27,7 @@ exports.ApiTable = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const useApi_1 = require("../../hooks/useApi");
29
29
  const VTable_1 = require("./VTable");
30
- exports.ApiTable = react_1.default.forwardRef((props, ref) => {
30
+ exports.ApiTable = (0, react_1.forwardRef)((props, ref) => {
31
31
  const option = {
32
32
  api: props.api,
33
33
  rowKey: props.rowKey,
@@ -39,10 +39,6 @@ exports.ApiTable = react_1.default.forwardRef((props, ref) => {
39
39
  if (props.pagination && props.pagination.pageSize)
40
40
  option.pageSize = props.pagination.pageSize;
41
41
  const model = (0, useApi_1.useApi)(option);
42
- (0, react_1.useEffect)(() => {
43
- if (ref) {
44
- ref.current = model;
45
- }
46
- }, [ref]);
42
+ (0, react_1.useImperativeHandle)(ref, () => model, []);
47
43
  return react_1.default.createElement(VTable_1.VTable, Object.assign({}, props, { model: model }));
48
44
  });
@@ -36,7 +36,7 @@ const API_TABLE_PROPERTIES = [
36
36
  'api', 'aop', 'tipDisabled', 'tipField',
37
37
  'mode', 'columns', 'showIndex', 'rowKey', 'select', 'selectDisabled', 'actionBar', 'selectBar', 'searchBar', 'default', 'autoLoad'
38
38
  ];
39
- exports.ApiTableModal = react_1.default.forwardRef((props, ref) => {
39
+ exports.ApiTableModal = (0, react_1.forwardRef)((props, ref) => {
40
40
  const modalProps = lodash_1.default.omit(props, API_TABLE_PROPERTIES);
41
41
  const tableProps = lodash_1.default.pick(props, API_TABLE_PROPERTIES);
42
42
  const [tableKey, updateKey] = (0, react_1.useState)(utils_1.StringUtil.genKey());
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
- import type { BaseTableProps } from './index';
2
+ import type { BaseTableProps, TableColumn } from './index';
3
3
  import type { ListModel } from '../../hooks/_list';
4
+ import type { PlainObject, Key } from '../../basetype';
5
+ export type VTableRef = {
6
+ getSelected: () => [Key[], PlainObject[]];
7
+ getParams: () => PlainObject;
8
+ };
4
9
  export declare const getHeightByTagName: (root: HTMLElement, tagName: string) => number;
5
10
  /**
6
11
  * VTable 支持多种模型,内置模型有 API/DATA/STATIC,也支持模型规范的自定义模型
@@ -8,4 +13,18 @@ export declare const getHeightByTagName: (root: HTMLElement, tagName: string) =>
8
13
  export type VTableProps = BaseTableProps & {
9
14
  model: ListModel;
10
15
  };
11
- export declare const VTable: React.FC<VTableProps>;
16
+ export declare const VTable: React.ForwardRefExoticComponent<import("./index").TableDefine & {
17
+ mode?: import("../Box/Box").BoxMode;
18
+ columns: TableColumn[];
19
+ showIndex?: string | false;
20
+ rowKey?: string;
21
+ select?: true | "DEFAULT" | "QUERY";
22
+ selectDisabled?: (record: any) => boolean;
23
+ actionBar?: React.ReactNode | import("./Components/ActionBar").TableActionButton[];
24
+ selectBar?: import("../Box/SelectBar").SelectBarProps;
25
+ searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
26
+ default?: PlainObject;
27
+ autoLoad?: false;
28
+ } & {
29
+ model: ListModel;
30
+ } & React.RefAttributes<VTableRef>>;
@@ -37,6 +37,7 @@ const Util_1 = require("./Util");
37
37
  const HighLight_1 = require("../_common/HighLight");
38
38
  const hooks_1 = require("../../hooks");
39
39
  const Box_1 = require("../Box/Box");
40
+ ;
40
41
  const getHeightByTagName = (root, tagName) => {
41
42
  if (root == null)
42
43
  return 0;
@@ -47,10 +48,10 @@ const getHeightByTagName = (root, tagName) => {
47
48
  return 0;
48
49
  };
49
50
  exports.getHeightByTagName = getHeightByTagName;
50
- const _VTable = react_1.default.forwardRef((props, ref) => {
51
+ const _VTable = (0, react_1.forwardRef)((props, ref) => {
51
52
  const update = (0, hooks_1.useUpdate)();
52
53
  const { state, root, resize } = (0, Box_1.useBox)();
53
- const [scroll, setScroll] = (0, react_1.useState)(undefined);
54
+ // const [scroll, setScroll] = useState<TableProps<PlainObject>['scroll']>(undefined);
54
55
  const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query, total } = props.model;
55
56
  let start = (0, react_1.useRef)(0);
56
57
  const tableProps = {};
@@ -122,7 +123,6 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
122
123
  (0, react_1.useEffect)(() => {
123
124
  if (props.autoLoad === false)
124
125
  return;
125
- console.log(props.model);
126
126
  // @ts-ignore
127
127
  if (props.model.mode == 'api-global' && total > 0)
128
128
  return;
@@ -132,19 +132,16 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
132
132
  query(props.default || {});
133
133
  }, []);
134
134
  // 更新高度 table 需要把 head 排除设置滚动
135
- (0, react_1.useEffect)(() => {
136
- if (props.scroll === null)
137
- return;
138
- if (props.mode == undefined || props.mode == 'common')
139
- return;
140
- let height = state === null || state === void 0 ? void 0 : state.height;
141
- if (!height)
142
- return;
143
- setTimeout(() => {
144
- height -= (0, exports.getHeightByTagName)(root.current, 'thead');
145
- setScroll({ y: Math.ceil(height), x: true });
146
- }, 2);
147
- }, [state === null || state === void 0 ? void 0 : state.height]);
135
+ // useEffect(() => {
136
+ // if (props.scroll === null) return;
137
+ // if (props.mode == undefined || props.mode == 'common') return;
138
+ // let height = state?.height;
139
+ // if (!height) return;
140
+ // setTimeout(() => {
141
+ // height -= getHeightByTagName(root.current, 'thead');
142
+ // setScroll({ y: Math.ceil(height), x: true })
143
+ // }, 2);
144
+ // }, [state?.height])
148
145
  // @ts-ignore
149
146
  const effectKey = props.model.effect;
150
147
  (0, react_1.useEffect)(() => {
@@ -183,7 +180,9 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
183
180
  },
184
181
  };
185
182
  }
186
- return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey, scroll: scroll, tableLayout: "fixed",
183
+ return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey,
184
+ // scroll={scroll}
185
+ // tableLayout="fixed"
187
186
  // showSorterTooltip={false}
188
187
  size: utils_1.GLOBAL.CONFIG.TABLE.SIZE }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) }, dataSource: list, loading: isQuerying, onChange: (x, y, field) => {
189
188
  if (field.column) {
@@ -194,10 +193,19 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
194
193
  }
195
194
  } }));
196
195
  });
197
- const VTable = (props) => {
196
+ exports.VTable = (0, react_1.forwardRef)((props, ref) => {
198
197
  const { isQuerying, pageNo, pageSize, total, totalAcc, param, pageTo, query, cost } = props.model;
199
198
  // 通过 ref 方式交互,后续扩展方法实现定制联页选择
200
199
  const selectedRef = (0, react_1.useRef)({ selected: [[], []], onSelected: () => { }, });
200
+ // 对外提供getSelected方法获取当前选择的数据
201
+ (0, react_1.useImperativeHandle)(ref, () => ({
202
+ getSelected() {
203
+ return selectedRef.current.selected;
204
+ },
205
+ getParams: () => {
206
+ return props.model.param;
207
+ }
208
+ }), []);
201
209
  let boxProps = lodash_1.default.pick(props, ['selectBar', 'style', 'className', 'default', 'mode']);
202
210
  if (props.searchBar) {
203
211
  boxProps.searchBar = Object.assign(Object.assign({}, props.searchBar), { disabled: isQuerying, onSearch: (data) => {
@@ -238,5 +246,4 @@ const VTable = (props) => {
238
246
  }
239
247
  return react_1.default.createElement(Box_1.Box, Object.assign({}, boxProps),
240
248
  react_1.default.createElement(_VTable, Object.assign({}, lodash_1.default.omit(props, ['className', 'style']), { ref: selectedRef })));
241
- };
242
- exports.VTable = VTable;
249
+ });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { TableDefined } from './Components';
3
- import type { ForwardRefExoticComponent, ExoticComponent } from 'react';
3
+ import type { ForwardRefExoticComponent, ExoticComponent, RefAttributes } from 'react';
4
4
  import type { TableProps } from '../_adapt/Table';
5
5
  import type { ColumnProps } from 'antd/es/table/interface';
6
6
  import type { SearchBarProps } from '../SearchBar/index';
@@ -13,7 +13,7 @@ export type TableColumn = BaseItem & ColumnProps<PlainObject>;
13
13
  * 说明:为保持各应用 一致性 与 简单性
14
14
  * 所有VAP组装 Table 排除一些自定义属性
15
15
  */
16
- export type TableDefine = Omit<TableProps<PlainObject>, 'size' | 'columns' | 'dataSource' | 'bordered' | 'tableLayout' | 'rowKey' | 'title' | 'loading' | 'onChange' | 'rowSelection' | 'getPopupContainer' | 'sortDirections' | 'showSorterTooltip' | 'internalHooks' | 'transformColumns' | 'internalRefs'>;
16
+ export type TableDefine = Omit<TableProps<PlainObject>, 'size' | 'columns' | 'dataSource' | 'bordered' | 'rowKey' | 'title' | 'loading' | 'onChange' | 'rowSelection' | 'getPopupContainer' | 'sortDirections' | 'showSorterTooltip' | 'internalHooks' | 'transformColumns' | 'internalRefs'>;
17
17
  export type BaseTableProps = TableDefine & {
18
18
  mode?: BoxMode;
19
19
  /**
@@ -66,10 +66,10 @@ export type BaseTableProps = TableDefine & {
66
66
  autoLoad?: false;
67
67
  };
68
68
  import type { ApiTableProps } from './ApiTable';
69
- export type ApiTable = ForwardRefExoticComponent<ApiTableProps & React.RefAttributes<ApiModel>> & TableDefined;
69
+ export type ApiTable = ForwardRefExoticComponent<ApiTableProps & RefAttributes<ApiModel>> & TableDefined;
70
70
  export declare const ApiTable: ApiTable;
71
- import type { VTableProps } from './VTable';
72
- export type VTable = ExoticComponent<VTableProps> & TableDefined;
71
+ import type { VTableProps, VTableRef } from './VTable';
72
+ export type VTable = ForwardRefExoticComponent<VTableProps & RefAttributes<VTableRef>> & TableDefined;
73
73
  export declare const VTable: VTable;
74
74
  import type { STableProps } from './STable';
75
75
  export type STable = ExoticComponent<STableProps> & TableDefined;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { BaseTreeState } from './BaseTree';
3
- import type { BaseTreeProps, ActionProps, ActionRef } from './index';
3
+ import type { BaseTreeProps, BaseActionTreeProps, ActionTreeRef } from './index';
4
4
  import type { PlainObject, Key } from '../../basetype';
5
5
  import type { ReactNode } from 'react';
6
6
  declare enum INSER_POS {
@@ -10,7 +10,7 @@ declare enum INSER_POS {
10
10
  TOP = 3,
11
11
  BOTTOM = 4
12
12
  }
13
- type ActionTreeProps = BaseTreeProps & ActionProps;
13
+ type ActionTreeProps = BaseTreeProps & BaseActionTreeProps;
14
14
  export type CacheTree = {
15
15
  /**
16
16
  * 清理缓存方法
@@ -22,7 +22,7 @@ export type CacheTree = {
22
22
  getChildren?: Function;
23
23
  };
24
24
  type ActionTreeContext = {
25
- action: ActionProps;
25
+ action: BaseActionTreeProps;
26
26
  showAdd: (pos: INSER_POS, node: PlainObject, position: number[]) => void;
27
27
  showEdit: (node: PlainObject, position: number[]) => void;
28
28
  del: (node: PlainObject, position: number[]) => void;
@@ -45,12 +45,10 @@ export declare const ActionTree: React.ForwardRefExoticComponent<import("../../u
45
45
  defaultExpandAll?: boolean;
46
46
  mustSelect?: boolean;
47
47
  disabled?: boolean;
48
- disabledNode?: (node: PlainObject) => boolean; /**
49
- * 清理缓存方法
50
- */
48
+ disabledNode?: (node: PlainObject) => boolean;
51
49
  onSelect?: (key: Key, node: PlainObject, parentNode: PlainObject, crumb: PlainObject[], pos: number[]) => void;
52
50
  searchValue?: string;
53
- } & ActionProps & CacheTree & React.RefAttributes<ActionRef>>;
51
+ } & BaseActionTreeProps & CacheTree & React.RefAttributes<ActionTreeRef>>;
54
52
  export declare const renderRoot: (props: ActionTreeProps, state: BaseTreeState, context: ActionTreeContext) => ReactNode;
55
53
  export declare const getResponseList: (resp: PlainObject, sortField?: string) => PlainObject[];
56
54
  export {};
@@ -108,21 +108,17 @@ const _Actiontree = (0, react_1.forwardRef)((props, ref) => {
108
108
  if (props.canSort && treeState.sortField)
109
109
  action.canSort = true;
110
110
  }
111
- (0, react_1.useLayoutEffect)(() => {
112
- if (ref != null) {
113
- ref.current = {
114
- updateData, update, del, add: (data, position) => {
115
- let nodePath = position.map(i => `[${i}]`).join('.children');
116
- const { treeData } = treeState;
117
- let node = lodash_1.default.get(treeData, nodePath);
118
- if (node == null) {
119
- antd_1.message.error('No parent found');
120
- }
121
- add(data, { pos: INSER_POS.INNER, node, position });
122
- }
123
- };
111
+ (0, react_1.useImperativeHandle)(ref, () => ({
112
+ updateData, update, del, add: (data, position) => {
113
+ let nodePath = position.map(i => `[${i}]`).join('.children');
114
+ const { treeData } = treeState;
115
+ let node = lodash_1.default.get(treeData, nodePath);
116
+ if (node == null) {
117
+ antd_1.message.error('No parent found');
118
+ }
119
+ add(data, { pos: INSER_POS.INNER, node, position });
124
120
  }
125
- }, [treeState.treeData]);
121
+ }), [treeState.treeData]);
126
122
  (0, react_1.useLayoutEffect)(() => {
127
123
  if (props.formFields) {
128
124
  FIELDS.current = props.formFields;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { BaseTreeProps, ActionProps, ActionRef } from './index';
2
+ import type { BaseTreeProps, BaseActionTreeProps, ActionTreeRef } from './index';
3
3
  import type { Key, PlainObject } from '../../basetype';
4
4
  export type DTreeFetch = {
5
5
  /**
@@ -19,7 +19,7 @@ export type DTreeFetch = {
19
19
  */
20
20
  childApi: string | ((parentId: Key) => Promise<PlainObject[]>);
21
21
  };
22
- export type DTreeProps = BaseTreeProps & ActionProps & DTreeFetch;
22
+ export type DTreeProps = BaseTreeProps & BaseActionTreeProps & DTreeFetch;
23
23
  /**
24
24
  * 动态树
25
25
  * CRUD : 支持
@@ -45,4 +45,4 @@ export declare const DTree: React.MemoExoticComponent<React.ForwardRefExoticComp
45
45
  disabledNode?: (node: PlainObject) => boolean;
46
46
  onSelect?: (key: Key, node: PlainObject, parentNode: PlainObject, crumb: PlainObject[], pos: number[]) => void;
47
47
  searchValue?: string;
48
- } & ActionProps & DTreeFetch & React.RefAttributes<ActionRef>>>;
48
+ } & BaseActionTreeProps & DTreeFetch & React.RefAttributes<ActionTreeRef>>>;
@@ -125,7 +125,6 @@ const _Dtree = (props) => {
125
125
  // 如果根节点只有一个,则自动展开这个根结点
126
126
  treeProps.defaultExpandedKeys = [treeState.treeData[0][treeState.keyField]];
127
127
  }
128
- // loadData?: (node: AntTreeNode) => PromiseLike<void>;
129
128
  const loadData = (evt) => __awaiter(void 0, void 0, void 0, function* () {
130
129
  const { node, position } = evt.props.data;
131
130
  const children = yield props.getChildren(node[treeState.keyField]);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TreeUtil } from '../../utils';
3
- import type { BaseTreeProps, ActionProps, ActionRef } from './index';
3
+ import type { BaseTreeProps, BaseActionTreeProps, ActionTreeRef } from './index';
4
4
  import type { PlainObject } from '../../basetype';
5
5
  type FTreeFetch = {
6
6
  /**
@@ -8,7 +8,7 @@ type FTreeFetch = {
8
8
  */
9
9
  fetchApi?: string;
10
10
  };
11
- export type FTreeProps = BaseTreeProps & ActionProps & FTreeFetch;
11
+ export type FTreeProps = BaseTreeProps & BaseActionTreeProps & FTreeFetch;
12
12
  /**
13
13
  * 动态树
14
14
  * CRUD : 支持
@@ -17,7 +17,9 @@ export type FTreeProps = BaseTreeProps & ActionProps & FTreeFetch;
17
17
  */
18
18
  export declare const FTree: React.MemoExoticComponent<React.ForwardRefExoticComponent<TreeUtil.BaseTreeOpts & {
19
19
  className?: string;
20
- iconField?: string | ((item: any) => React.ReactNode);
20
+ iconField?: string | ((item: any) => React.ReactNode); /**
21
+ * 获取全部节点的API,如果不传,刚用 API 的GET模式代替
22
+ */
21
23
  titleField: string | {
22
24
  zhCN?: string;
23
25
  enUS?: string;
@@ -29,5 +31,5 @@ export declare const FTree: React.MemoExoticComponent<React.ForwardRefExoticComp
29
31
  disabledNode?: (node: PlainObject) => boolean;
30
32
  onSelect?: (key: import("../../basetype").Key, node: PlainObject, parentNode: PlainObject, crumb: PlainObject[], pos: number[]) => void;
31
33
  searchValue?: string;
32
- } & ActionProps & FTreeFetch & React.RefAttributes<ActionRef>>>;
34
+ } & BaseActionTreeProps & FTreeFetch & React.RefAttributes<ActionTreeRef>>>;
33
35
  export {};
@@ -66,7 +66,7 @@ export type BaseTreeProps = BaseTreeOpts & {
66
66
  */
67
67
  searchValue?: string;
68
68
  };
69
- export type ActionProps = {
69
+ export type BaseActionTreeProps = {
70
70
  /**
71
71
  * 对象的 Label
72
72
  */
@@ -131,7 +131,7 @@ export type ActionProps = {
131
131
  * 说明 针对节点进行操作
132
132
  * 说明,节点信息,位置信息,可通过 onSelect 方法的第五个参数可以拿到
133
133
  */
134
- export type ActionRef = {
134
+ export type ActionTreeRef = {
135
135
  updateData: (node: PlainObject, pos: number[]) => void;
136
136
  update: (node: PlainObject, pos: number[]) => Promise<void>;
137
137
  del: (node: PlainObject, pos: number[]) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { UFromProps, UFormFunctions } from './index';
2
+ import type { UFromProps, UFormRef } from './index';
3
3
  import type { FormState } from './FormWrapper';
4
4
  export declare const initValue: (props: UFromProps & {
5
5
  state: FormState;
@@ -14,4 +14,4 @@ export declare const initValue: (props: UFromProps & {
14
14
  * 3. 支持 ref 控制方法
15
15
  * 4. filed 支持更多提示,验证方法
16
16
  */
17
- export declare const UForm: React.ForwardRefExoticComponent<UFromProps & React.RefAttributes<UFormFunctions>>;
17
+ export declare const UForm: React.ForwardRefExoticComponent<UFromProps & React.RefAttributes<UFormRef>>;
@@ -43,13 +43,13 @@ const antd_1 = require("antd");
43
43
  const Row_1 = require("../_adapt/Row");
44
44
  const Col_1 = require("../_adapt/Col");
45
45
  const Popconfirm_1 = require("../_adapt/Popconfirm");
46
+ const Popover_1 = require("../_adapt/Popover");
46
47
  const Button_1 = require("../_adapt/Button");
47
48
  const FormWrapper_1 = require("./FormWrapper");
48
49
  const useUpdate_1 = require("../../hooks/useUpdate");
49
50
  const Icon_1 = require("../_adapt/Icon");
50
51
  const _FormUtils_1 = require("./_FormUtils");
51
52
  const _register_1 = require("./_register");
52
- const Popover_1 = require("../_adapt/Popover");
53
53
  const onChangeEvent = (state, field, form, update, values, extra) => {
54
54
  const { multipleFields, requireFields, disableFields, hiddenFields, optionFields, } = state;
55
55
  if (!lodash_1.default.isArray(field.link) || field.link.length == 0)
@@ -407,24 +407,22 @@ const _UForm = (0, react_1.forwardRef)((props, ref) => {
407
407
  const { form } = props;
408
408
  const [checked, setChecked] = (0, react_1.useState)(false);
409
409
  const initRef = (0, react_1.useRef)(null);
410
+ (0, react_1.useImperativeHandle)(ref, () => ({
411
+ validate: () => __awaiter(void 0, void 0, void 0, function* () {
412
+ return new Promise((r, j) => {
413
+ form.validateFields((err, result) => {
414
+ if (err) {
415
+ console.error(err);
416
+ return;
417
+ }
418
+ r(getValue(state.multipleFields.current, result, initRef));
419
+ });
420
+ });
421
+ }),
422
+ reset: () => form.resetFields(),
423
+ data: () => getValue(state.multipleFields.current, form.getFieldsValue(), initRef),
424
+ }), []);
410
425
  (0, react_1.useLayoutEffect)(() => {
411
- if (ref != null) {
412
- ref.current = {
413
- validate: () => __awaiter(void 0, void 0, void 0, function* () {
414
- return new Promise((r, j) => {
415
- form.validateFields((err, result) => {
416
- if (err) {
417
- console.error(err);
418
- return;
419
- }
420
- r(getValue(state.multipleFields.current, result, initRef));
421
- });
422
- });
423
- }),
424
- reset: () => form.resetFields(),
425
- data: () => getValue(state.multipleFields.current, form.getFieldsValue(), initRef),
426
- };
427
- }
428
426
  const checkMultiple = (field) => {
429
427
  // @ts-ignore
430
428
  if (field == null || field == false)
@@ -449,11 +447,9 @@ const _UForm = (0, react_1.forwardRef)((props, ref) => {
449
447
  if (!checked)
450
448
  return utils_1.Const.NONE;
451
449
  return react_1.default.createElement(antd_1.Form
452
- // defaultValue={initRef.current}
453
450
  // initialValues={props.default}
454
451
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
455
452
  , {
456
- // defaultValue={initRef.current}
457
453
  // initialValues={props.default}
458
454
  // size={props.size || GLOBAL.CONFIG.FORM.SIZE}
459
455
  className: state.isGroup ? 'c-form c-form-group' : 'c-form', style: { width: state.width }, form: form },
@@ -48,9 +48,6 @@ const FormWrapper_1 = require("./FormWrapper");
48
48
  const FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'size'];
49
49
  const UFormModal = (props) => {
50
50
  const ref = (0, react_1.useRef)(null);
51
- const [open, afterClose] = (0, Modal_1.useDestoryModal)(props);
52
- if (!open)
53
- return utils_1.Const.NONE;
54
51
  let modalProps = {
55
52
  onOk: () => __awaiter(void 0, void 0, void 0, function* () {
56
53
  const result = yield ref.current.validate();
@@ -146,7 +143,7 @@ const UFormModal = (props) => {
146
143
  });
147
144
  }
148
145
  }
149
- return react_1.default.createElement(Modal_1.Modal, Object.assign({ maskClosable: utils_1.GLOBAL.CONFIG.FORM.maskClosable, destroyOnClose: true, afterClose: afterClose }, lodash_1.default.omit(props, FORM_FIELDS), { className: utils_1.StringUtil.className(['u-form-modal'], props.className), onCancel: () => props.onCancel() }, modalProps),
146
+ return react_1.default.createElement(Modal_1.Modal, Object.assign({ maskClosable: utils_1.GLOBAL.CONFIG.FORM.maskClosable, destroyOnClose: true }, lodash_1.default.omit(props, FORM_FIELDS), { className: utils_1.StringUtil.className(['u-form-modal'], props.className), onCancel: () => props.onCancel() }, modalProps),
150
147
  react_1.default.createElement(UForm_1.UForm, Object.assign({}, lodash_1.default.pick(props, FORM_FIELDS), { ref: ref })));
151
148
  };
152
149
  exports.UFormModal = UFormModal;
@@ -391,7 +391,7 @@ export type UDescriptionsItemProps = BaseItem & {
391
391
  */
392
392
  children: React.ReactNode;
393
393
  };
394
- export type UFormFunctions = {
394
+ export type UFormRef = {
395
395
  /**
396
396
  * 获取当前表单数据
397
397
  */
@@ -28,10 +28,13 @@ const _Button = props => {
28
28
  icon,
29
29
  " ",
30
30
  react_1.default.createElement("span", null, utils_1.i18n.txt(props.ik)));
31
- return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps),
32
- icon,
33
- " ",
34
- react_1.default.createElement("span", null, props.children));
31
+ if (props.children) {
32
+ return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps),
33
+ icon,
34
+ " ",
35
+ react_1.default.createElement("span", null, props.children));
36
+ }
37
+ return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), icon);
35
38
  }
36
39
  if (props.ik)
37
40
  return react_1.default.createElement(antd_1.Button, Object.assign({}, btnProps), utils_1.i18n.txt(props.ik));
@@ -1,5 +1,5 @@
1
1
  import { Input as AntdInput } from 'antd';
2
- import type { InputProps } from 'antd/es/input';
2
+ import type { InputProps, PasswordProps } from 'antd/es/input';
3
3
  import type { ForwardRefExoticComponent, RefAttributes } from 'react';
4
4
  export interface InputRef {
5
5
  input: HTMLInputElement | null;
@@ -11,7 +11,7 @@ type InputComponent = ForwardRefExoticComponent<InputProps & RefAttributes<Input
11
11
  Group: typeof AntdInput.Group;
12
12
  Search: typeof AntdInput.Search;
13
13
  TextArea: typeof AntdInput.TextArea;
14
- Password: typeof AntdInput.Password;
14
+ Password: ForwardRefExoticComponent<PasswordProps & RefAttributes<InputRef>>;
15
15
  };
16
16
  export declare const Input: InputComponent;
17
17
  export {};
@@ -40,4 +40,14 @@ exports.Input = _Input;
40
40
  exports.Input.Group = antd_1.Input.Group;
41
41
  exports.Input.Search = antd_1.Input.Search;
42
42
  exports.Input.TextArea = antd_1.Input.TextArea;
43
- exports.Input.Password = antd_1.Input.Password;
43
+ exports.Input.Password = (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(antd_1.Input.Password, Object.assign({}, props, { ref: aInput => {
44
+ if (aInput && ref) {
45
+ ref.current = {
46
+ input: aInput.input,
47
+ focus: aInput.focus,
48
+ blur: aInput.blur,
49
+ select: aInput.select,
50
+ };
51
+ }
52
+ } })));
53
+ // ;
@@ -16,8 +16,6 @@ const Row = (props) => {
16
16
  if (props.direction != 'column')
17
17
  return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, { className: clazz.join(' ') }));
18
18
  clazz.push('v-row-direction-column');
19
- return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, {
20
- // wrap={props.wrap || false}
21
- className: clazz.join(' ') }));
19
+ return react_1.default.createElement(antd_1.Row, Object.assign({ type: "flex", gutter: Global_1.CONFIG.GRID.GUTTER }, props, { className: clazz.join(' ') }));
22
20
  };
23
21
  exports.Row = Row;
@@ -1,11 +1,31 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
26
+ const react_1 = __importStar(require("react"));
7
27
  const _register_1 = require("../../Box/_register");
8
28
  const Trees_1 = require("../../Trees");
9
29
  (0, _register_1.registerSelectBar)('stree', (props) => react_1.default.createElement(Trees_1.STree, Object.assign({}, props.config, { onSelect: props.onSelect, searchValue: props.searchValue })));
10
- (0, _register_1.registerSelectBar)('ftree', react_1.default.forwardRef((props, ref) => react_1.default.createElement(Trees_1.FTree, Object.assign({}, props.config, { onSelect: props.onSelect, searchValue: props.searchValue, ref: ref }))));
11
- (0, _register_1.registerSelectBar)('dtree', react_1.default.forwardRef((props, ref) => react_1.default.createElement(Trees_1.DTree, Object.assign({}, props.config, { onSelect: props.onSelect, searchValue: props.searchValue, ref: ref }))));
30
+ (0, _register_1.registerSelectBar)('ftree', (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(Trees_1.FTree, Object.assign({}, props.config, { onSelect: props.onSelect, searchValue: props.searchValue, ref: ref }))));
31
+ (0, _register_1.registerSelectBar)('dtree', (0, react_1.forwardRef)((props, ref) => react_1.default.createElement(Trees_1.DTree, Object.assign({}, props.config, { onSelect: props.onSelect, searchValue: props.searchValue, ref: ref }))));
@@ -13,10 +13,10 @@ const Popover_1 = require("../../../components/_adapt/Popover");
13
13
  const Slider_1 = require("../../../components/_adapt/Slider");
14
14
  const Button_1 = require("../../../components/_adapt/Button");
15
15
  const Select_1 = require("../../../components/_adapt/Select");
16
+ const ColorPicker_1 = require("../../../components/_adapt/ColorPicker");
16
17
  const UForm_1 = require("../../../components/UForm");
17
18
  const Icon_1 = require("../../../components/_adapt/Icon");
18
19
  const hooks_1 = require("../../../hooks");
19
- const ColorPicker_1 = require("../../../components/_adapt/ColorPicker");
20
20
  const markValue = (editor, cmd) => {
21
21
  const marks = slate_1.Editor.marks(editor);
22
22
  if (marks && marks[cmd]) {
package/index.d.ts CHANGED
@@ -132,9 +132,9 @@ export { VTable, ApiTable, ApiTableModal, STable, TopTable, TopTableModal } from
132
132
  export { STree, DTree, FTree } from './components/Trees';
133
133
  export { UploadFile, UploadImage, UploadModal } from './components/Upload';
134
134
  export { SList } from './components/Lists/SList';
135
- export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, UFormFunctions } from './components/UForm';
135
+ export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, UFormRef } from './components/UForm';
136
136
  export type { TableColumn } from './components/Tables/index';
137
- export type { VTableProps } from './components/Tables/VTable';
137
+ export type { VTableProps, VTableRef } from './components/Tables/VTable';
138
138
  export type { ApiTableProps } from './components/Tables/ApiTable';
139
139
  export type { ApiTableModalProps } from './components/Tables/ApiTableModal';
140
140
  export type { STableProps } from './components/Tables/STable';
@@ -143,6 +143,7 @@ export type { TopTableModalProps } from './components/Tables/TopTableModal';
143
143
  export type { UploadModalProps } from './components/Upload/UploadModal';
144
144
  export type { UploadImageProps } from './components/Upload/UploadImage';
145
145
  export type { BaseUploadProps } from './components/Upload';
146
+ export type { ActionTreeRef } from './components/Trees';
146
147
  export type { STreeProps } from './components/Trees/STree';
147
148
  export type { DTreeProps } from './components/Trees/DTree';
148
149
  export type { FTreeProps } from './components/Trees/FTree';
@@ -1,6 +1,7 @@
1
1
  declare global {
2
2
  const PNXGWClient: any;
3
3
  interface Window {
4
+ APP_ROOT: string;
4
5
  ActiveXObject: any;
5
6
  }
6
7
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.1.1","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.1.3","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
package/screen/render.js CHANGED
@@ -7,4 +7,3 @@ const react_dom_1 = require("react-dom");
7
7
  */
8
8
  const render = (children) => (0, react_dom_1.render)(children, document.getElementById('root'));
9
9
  exports.render = render;
10
- // createRoot(document.getElementById('root') as HTMLDivElement).render(children);
@@ -11,6 +11,14 @@ export declare const paramToUri: (param: PlainObject, baseUrl?: string) => strin
11
11
  * 将一个ip4地址转换成数字
12
12
  */
13
13
  export declare const IpToInt: (ip: string) => number;
14
+ /**
15
+ * 兼容二级目录-转化URL
16
+ */
17
+ export declare const resolveURL: ((url: string) => string);
18
+ /**
19
+ * 兼容二级目录-恢复URL
20
+ */
21
+ export declare const clearURL: ((url: string) => string);
14
22
  /**
15
23
  * 判断是否有权限
16
24
  */
package/utils/PageUtil.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getOptions = exports.currentApp = exports.hasRole = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
6
+ exports.getOptions = exports.currentApp = exports.hasRole = exports.clearURL = exports.resolveURL = exports.IpToInt = exports.paramToUri = exports.stopEvent = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const StringUtil_1 = require("./StringUtil");
9
9
  const _Support_1 = require("./_Support");
@@ -46,6 +46,25 @@ const IpToInt = (ip) => {
46
46
  return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;
47
47
  };
48
48
  exports.IpToInt = IpToInt;
49
+ /**
50
+ * 兼容二级目录-转化URL
51
+ */
52
+ exports.resolveURL = (window.APP_ROOT == null || window.APP_ROOT == '') ? (val => val) : (url) => {
53
+ if (!url.startsWith('/'))
54
+ return url;
55
+ if (url.startsWith(window.APP_ROOT))
56
+ return url;
57
+ return window.APP_ROOT + url;
58
+ };
59
+ const len = window.APP_ROOT ? window.APP_ROOT.length : 0;
60
+ /**
61
+ * 兼容二级目录-恢复URL
62
+ */
63
+ exports.clearURL = (len == 0) ? (val => val) : (url) => {
64
+ if (!url.startsWith(window.APP_ROOT))
65
+ return url;
66
+ return url.substring(len);
67
+ };
49
68
  /**
50
69
  * 判断是否有权限
51
70
  */