vap1 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Box/SelectBar.d.ts +2 -2
- package/components/Lists/SList.d.ts +4 -2
- package/components/Lists/SList.js +16 -13
- package/components/Tables/STable.js +5 -1
- package/components/UForm/FormWrapper.js +16 -16
- package/components/UForm/index.d.ts +1 -1
- package/components/_setup/SearchField/SearchFieldSelect.js +0 -20
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/utils/PageUtil.js +3 -1
- package/utils/StringUtil.d.ts +1 -0
- package/utils/StringUtil.js +7 -1
|
@@ -4,7 +4,7 @@ import type { Key, BaseItem, PlainObject } from '../../basetype';
|
|
|
4
4
|
import type { STreeProps } from '../Trees/STree';
|
|
5
5
|
import type { DTreeProps } from '../Trees/DTree';
|
|
6
6
|
import type { FTreeProps } from '../Trees/FTree';
|
|
7
|
-
import type {
|
|
7
|
+
import type { SListProps } from '../Lists/SList';
|
|
8
8
|
type SelectBarAction = BaseItem & {
|
|
9
9
|
/**
|
|
10
10
|
* action 图标
|
|
@@ -74,7 +74,7 @@ type ExtendSelectProps = {
|
|
|
74
74
|
config: Omit<FTreeProps, 'searchValue' | 'onSelect'>;
|
|
75
75
|
} | {
|
|
76
76
|
type: 'slist';
|
|
77
|
-
config: Omit<
|
|
77
|
+
config: Omit<SListProps, 'searchValue' | 'onSelect'>;
|
|
78
78
|
} | {
|
|
79
79
|
type: 'custom';
|
|
80
80
|
config?: any;
|
|
@@ -3,7 +3,9 @@ import type { PlainObject, Key } from '../../basetype';
|
|
|
3
3
|
import type { ReactNode } from 'react';
|
|
4
4
|
import type { IconProps } from '../_adapt/Icon';
|
|
5
5
|
type ItemRenderFunction = (record: PlainObject, searchValue?: string) => ReactNode;
|
|
6
|
-
export type
|
|
6
|
+
export type SListProps = {
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
className?: string;
|
|
7
9
|
/**
|
|
8
10
|
* key 字段,默认为ID
|
|
9
11
|
*/
|
|
@@ -54,5 +56,5 @@ export type SListPorps = {
|
|
|
54
56
|
*/
|
|
55
57
|
mustSelect?: true | ((list: PlainObject[]) => PlainObject);
|
|
56
58
|
};
|
|
57
|
-
export declare const SList: React.FC<
|
|
59
|
+
export declare const SList: React.FC<SListProps>;
|
|
58
60
|
export {};
|
|
@@ -134,23 +134,26 @@ exports.SList = (0, react_1.memo)((props) => {
|
|
|
134
134
|
setSelected(item[keyField]);
|
|
135
135
|
onSelect(item[keyField], item);
|
|
136
136
|
}, [list]);
|
|
137
|
-
const listProps = {
|
|
138
|
-
|
|
139
|
-
size: "small",
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
listProps.
|
|
137
|
+
const listProps = (0, react_1.useMemo)(() => {
|
|
138
|
+
const clazz = ['c-selectbar-list'];
|
|
139
|
+
let listProps = { size: "small", style: props.style };
|
|
140
|
+
if (lodash_1.default.isFunction(props.onSelect))
|
|
141
|
+
clazz.push('c-selectbar-list-canselect');
|
|
142
|
+
if (props.className)
|
|
143
|
+
clazz.push(props.className);
|
|
144
|
+
listProps.className = clazz.join(' ');
|
|
145
|
+
return listProps;
|
|
146
|
+
}, [props.className]);
|
|
147
|
+
const renderItem = item => {
|
|
148
|
+
if (!lodash_1.default.isFunction(props.onSelect))
|
|
149
|
+
return react_1.default.createElement(antd_1.List.Item, null, render(item, searchValue));
|
|
150
|
+
return react_1.default.createElement(antd_1.List.Item, { className: item[keyField] == selected ? 'c-selectbar-list-selected' : '', onClick: evt => {
|
|
145
151
|
utils_1.PageUtil.stopEvent(evt);
|
|
146
152
|
setSelected(item[keyField]);
|
|
147
153
|
onSelect(item[keyField], item);
|
|
148
154
|
} }, render(item, searchValue));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
listProps.renderItem = (item) => react_1.default.createElement(antd_1.List.Item, null, render(item, searchValue));
|
|
152
|
-
}
|
|
153
|
-
return react_1.default.createElement(antd_1.List, Object.assign({}, listProps));
|
|
155
|
+
};
|
|
156
|
+
return react_1.default.createElement(antd_1.List, Object.assign({}, listProps, { dataSource: list, renderItem: renderItem }));
|
|
154
157
|
}, (prev, next) => {
|
|
155
158
|
if (prev.searchValue != next.searchValue)
|
|
156
159
|
return false;
|
|
@@ -46,7 +46,11 @@ const STable = (props) => {
|
|
|
46
46
|
arrOption.pageSize = 0;
|
|
47
47
|
}
|
|
48
48
|
const model = (0, useArray_1.useArray)(arrOption);
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
49
|
+
(0, react_1.useEffect)(() => {
|
|
50
|
+
if (lodash_1.default.isArray(props.list)) {
|
|
51
|
+
model.setList(props.list);
|
|
52
|
+
}
|
|
53
|
+
}, [props.list]);
|
|
50
54
|
return react_1.default.createElement(VTable_1.VTable, Object.assign({}, props, { pagination: arrOption.pageSize == 0 ? false : { hideOnSinglePage: true }, model: model }));
|
|
51
55
|
};
|
|
52
56
|
exports.STable = STable;
|
|
@@ -79,10 +79,10 @@ const getFormLayout = (props, root) => {
|
|
|
79
79
|
width = totalWidth;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
let isInfo = false, isEdit = false,
|
|
82
|
+
let isInfo = false, isEdit = false, isAdd = false;
|
|
83
83
|
switch (props.mode) {
|
|
84
84
|
case 'ADD':
|
|
85
|
-
|
|
85
|
+
isAdd = true;
|
|
86
86
|
break;
|
|
87
87
|
case 'EDIT':
|
|
88
88
|
isEdit = true;
|
|
@@ -99,14 +99,14 @@ const getFormLayout = (props, root) => {
|
|
|
99
99
|
isEdit = true;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
isAdd = true;
|
|
103
103
|
// if (props.data != null || _.keys(props.data).length == 0) {
|
|
104
104
|
// isInfo = true;
|
|
105
105
|
// break;
|
|
106
106
|
// }
|
|
107
107
|
// isInfo = true;
|
|
108
108
|
}
|
|
109
|
-
return [isGroup, cols, width, colMax, isInfo, isEdit,
|
|
109
|
+
return [isGroup, cols, width, colMax, isInfo, isEdit, isAdd];
|
|
110
110
|
};
|
|
111
111
|
const getMaxTitleWidth = (field) => {
|
|
112
112
|
if (field.type && (0, _register_1.getUFormInput)(field.type).breakTitle)
|
|
@@ -128,7 +128,7 @@ const getMaxTitleWidth = (field) => {
|
|
|
128
128
|
return Math.ceil(sum);
|
|
129
129
|
};
|
|
130
130
|
// 遍历字段,计算表单属性
|
|
131
|
-
const _LOOP = (fs, maxLabel, isInfo, isEdit,
|
|
131
|
+
const _LOOP = (fs, maxLabel, isInfo, isEdit, isAdd, hiddFields, disableFields) => {
|
|
132
132
|
fs.map(field => {
|
|
133
133
|
// @ts-ignore // 兼容 && 写法
|
|
134
134
|
if (field == null || field === false)
|
|
@@ -144,22 +144,22 @@ const _LOOP = (fs, maxLabel, isInfo, isEdit, isCreate, hiddFields, disableFields
|
|
|
144
144
|
else if (field.show) {
|
|
145
145
|
switch (field.show) {
|
|
146
146
|
case 'A':
|
|
147
|
-
show =
|
|
148
|
-
break;
|
|
149
|
-
case 'AE':
|
|
150
|
-
show = !isInfo;
|
|
147
|
+
show = isAdd;
|
|
151
148
|
break;
|
|
152
149
|
case 'I':
|
|
153
150
|
show = isInfo;
|
|
154
151
|
break;
|
|
155
|
-
case '
|
|
156
|
-
show =
|
|
152
|
+
case 'E':
|
|
153
|
+
show = isEdit;
|
|
154
|
+
break;
|
|
155
|
+
case 'AE':
|
|
156
|
+
show = isAdd || isEdit;
|
|
157
157
|
break;
|
|
158
158
|
case 'IE':
|
|
159
159
|
show = isInfo || isEdit;
|
|
160
160
|
break;
|
|
161
|
-
case '
|
|
162
|
-
show =
|
|
161
|
+
case 'IA':
|
|
162
|
+
show = isAdd || isEdit;
|
|
163
163
|
break;
|
|
164
164
|
case 'IAE':
|
|
165
165
|
show = true;
|
|
@@ -222,14 +222,14 @@ const FormWrapper = (props) => {
|
|
|
222
222
|
const { fields } = props;
|
|
223
223
|
if (fields == null || fields.length == 0)
|
|
224
224
|
throw new Error('Must Have Fields');
|
|
225
|
-
const [isGroup, cols, width, colMax, isInfo, isEdit,
|
|
225
|
+
const [isGroup, cols, width, colMax, isInfo, isEdit, isAdd] = getFormLayout(props, formContainer.current);
|
|
226
226
|
let colSpan = 24 / cols;
|
|
227
227
|
// const MAX_LABEL_SPAN = COLMAX[cols];
|
|
228
228
|
if (isGroup) {
|
|
229
|
-
fields.map(group => _LOOP(group.fields, maxLabelRef, isInfo, isEdit,
|
|
229
|
+
fields.map(group => _LOOP(group.fields, maxLabelRef, isInfo, isEdit, isAdd, HiddenFieldRef.current, DisableFieldRef.current));
|
|
230
230
|
}
|
|
231
231
|
else {
|
|
232
|
-
_LOOP(fields, maxLabelRef, isInfo, isEdit,
|
|
232
|
+
_LOOP(fields, maxLabelRef, isInfo, isEdit, isAdd, HiddenFieldRef.current, DisableFieldRef.current);
|
|
233
233
|
}
|
|
234
234
|
let fieldWidth = width / cols;
|
|
235
235
|
var percent = (maxLabelRef.current * FONT_SIZE + 20) / fieldWidth;
|
|
@@ -85,7 +85,7 @@ export type Link = {
|
|
|
85
85
|
* 1. 传 **data** = Update ,
|
|
86
86
|
* 2. 不传= Add
|
|
87
87
|
*/
|
|
88
|
-
export type APPEAR_MODE = 'I' | 'A' | 'E' | 'IE' | '
|
|
88
|
+
export type APPEAR_MODE = 'I' | 'A' | 'E' | 'IE' | 'IA' | 'AE' | 'IAE' | false | true;
|
|
89
89
|
/**
|
|
90
90
|
* 表单的字段定义
|
|
91
91
|
*/
|
|
@@ -70,26 +70,6 @@ const SearchFieldInput_1 = require("./SearchFieldInput");
|
|
|
70
70
|
let options = utils_1.PageUtil.getOptions(props.field.options);
|
|
71
71
|
return react_1.default.createElement(antd_1.Checkbox.Group, Object.assign({}, config, { className: "i-checkbox", disabled: disabled, onChange: val => onChange(val.join(',')), value: (lodash_1.default.has(data, field) && data[field]) ? data[field].split(',') : [] }), options.map(option => react_1.default.createElement(antd_1.Checkbox, { value: option.value + '' }, option.label)));
|
|
72
72
|
}, { outside: true });
|
|
73
|
-
// registerSearchField('checkbox-button', (props: SearchFieldProps) => {
|
|
74
|
-
// const { field: { field, config, placeholder, allowClear, }, disabled, onChange, data, width } = props;
|
|
75
|
-
// if (!_.isArray(props.field.options)) {
|
|
76
|
-
// console.error('field type : select must have a options field')
|
|
77
|
-
// return <TEXT {...props} />
|
|
78
|
-
// }
|
|
79
|
-
// let options = PageUtil.getOptions(props.field.options);
|
|
80
|
-
// return <Checkbox.Group
|
|
81
|
-
// {...config}
|
|
82
|
-
// style={{ width }}
|
|
83
|
-
// optionType="button"
|
|
84
|
-
// buttonStyle="solid"
|
|
85
|
-
// disabled={disabled}
|
|
86
|
-
// onChange={val => onChange(val.join(','))}
|
|
87
|
-
// value={(_.has(data, field) && data[field].split(',')) ? data[field] : undefined}
|
|
88
|
-
// options={options}
|
|
89
|
-
// >
|
|
90
|
-
// {/* {options.map(option => <Checkbox value={option.value + ''}>{option.label}</Checkbox>)} */}
|
|
91
|
-
// </Checkbox.Group>
|
|
92
|
-
// });
|
|
93
73
|
(0, _register_1.registerSearchField)('switch', (props) => {
|
|
94
74
|
const { field: { field, config, placeholder, allowClear, }, disabled, onChange, data, width } = props;
|
|
95
75
|
if (!lodash_1.default.isArray(props.field.options) || (props.field.options.length <= 1)) {
|
package/index.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export { UForm, UFormModal, UInfo, UInfoModal, UModal, UDescriptions } from './c
|
|
|
134
134
|
export { VTable, ApiTable, ApiTableModal, STable, TopTable, TopTableModal } from './components/Tables';
|
|
135
135
|
export { STree, DTree, FTree } from './components/Trees';
|
|
136
136
|
export { UploadFile, UploadImage, UploadModal } from './components/Upload';
|
|
137
|
-
export { SList } from './components/Lists/SList';
|
|
137
|
+
export { SList, type SListProps } from './components/Lists/SList';
|
|
138
138
|
export type { UFromProps, UModalProps, UFormField, UFormFieldGroup, LinkResult, UDescriptionsProps, UFormRef, Link, LinkValue } from './components/UForm';
|
|
139
139
|
export type { TableColumn } from './components/Tables/index';
|
|
140
140
|
export type { VTableProps, VTableRef } from './components/Tables/VTable';
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"vap1","version":"0.2.
|
|
1
|
+
{"name":"vap1","version":"0.2.2","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
|
package/utils/PageUtil.js
CHANGED
|
@@ -68,7 +68,9 @@ exports.clearURL = (len == 0) ? (val => val) : (url) => {
|
|
|
68
68
|
/**
|
|
69
69
|
* 判断是否有权限
|
|
70
70
|
*/
|
|
71
|
-
const hasRole = (roleCode) =>
|
|
71
|
+
const hasRole = (roleCode) => {
|
|
72
|
+
return Global_1.CONFIG.PROMISSION.ROLE.has(roleCode) || Global_1.CONFIG.PROMISSION.ROLE.has((0, StringUtil_1.trimLower)(roleCode));
|
|
73
|
+
};
|
|
72
74
|
exports.hasRole = hasRole;
|
|
73
75
|
// export const hasRole = (roleCode: string): boolean => true; // 测试中,总返回有权限
|
|
74
76
|
const GLOBAL_APPS = new Map();
|
package/utils/StringUtil.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export declare const searchText: (sentence: string, keyword: string) => MatchPat
|
|
|
91
91
|
* 拼 className
|
|
92
92
|
*/
|
|
93
93
|
export declare const className: (base: string[], classNameProps?: string) => string;
|
|
94
|
+
export declare const replaceAll: (text: string, keyword: string | RegExp, replaceText: string) => string;
|
|
94
95
|
/**
|
|
95
96
|
* 试图转px的值
|
|
96
97
|
* 300px -> 300
|
package/utils/StringUtil.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.getFileType = exports.getFloat = exports.getInteger = exports.getBoolean = exports.getString = exports.copy = exports.px = exports.className = exports.searchText = exports.trimLower = exports.isBoolean = exports.isBTCAddress = exports.uuid = exports.genKey = exports.isId = exports.isId15 = exports.isId18 = exports.REG_ID_15 = exports.REG_ID_18 = exports.isIP = exports.isIP6 = exports.isIP4 = exports.isPhone = exports.isMAC = exports.isURL = exports.isEmail = exports.isTelePhone = exports.isMobilePhone = exports.REG_PORT = exports.REG_URL = exports.REG_IPV6 = exports.REG_IPV4 = exports.REG_TELEPHONE = exports.REG_PHONE = exports.REG_EMAIL = void 0;
|
|
6
|
+
exports.getFileType = exports.getFloat = exports.getInteger = exports.getBoolean = exports.getString = exports.copy = exports.px = exports.replaceAll = exports.className = exports.searchText = exports.trimLower = exports.isBoolean = exports.isBTCAddress = exports.uuid = exports.genKey = exports.isId = exports.isId15 = exports.isId18 = exports.REG_ID_15 = exports.REG_ID_18 = exports.isIP = exports.isIP6 = exports.isIP4 = exports.isPhone = exports.isMAC = exports.isURL = exports.isEmail = exports.isTelePhone = exports.isMobilePhone = exports.REG_PORT = exports.REG_URL = exports.REG_IPV6 = exports.REG_IPV4 = exports.REG_TELEPHONE = exports.REG_PHONE = exports.REG_EMAIL = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const _Support_1 = require("./_Support");
|
|
9
9
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
@@ -205,6 +205,12 @@ const className = (base, classNameProps) => {
|
|
|
205
205
|
return base.join(' ');
|
|
206
206
|
};
|
|
207
207
|
exports.className = className;
|
|
208
|
+
const replaceAll = (text, keyword, replaceText) => {
|
|
209
|
+
let reg = lodash_1.default.isRegExp(keyword) ? new RegExp(keyword, 'g') : new RegExp(keyword, "g");
|
|
210
|
+
return lodash_1.default.replace(text, reg, replaceText);
|
|
211
|
+
;
|
|
212
|
+
};
|
|
213
|
+
exports.replaceAll = replaceAll;
|
|
208
214
|
/**
|
|
209
215
|
* 试图转px的值
|
|
210
216
|
* 300px -> 300
|