vap1 0.1.8 → 0.1.9

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.
@@ -76,8 +76,7 @@ exports.Box = (0, react_1.forwardRef)((props, ref) => {
76
76
  if (props.nobg)
77
77
  className.push('c-box-nobg');
78
78
  const style = Object.assign({}, props.style);
79
- if (props.mode)
80
- className.push('c-box-' + props.mode);
79
+ className.push(props.mode ? ('c-box-' + props.mode) : 'c-box-common');
81
80
  if (props.mode == 'inner') {
82
81
  if (rootRef.current == null) {
83
82
  // style.height = 0;
@@ -5,4 +5,4 @@
5
5
  | text ||
6
6
  *
7
7
  */
8
- export declare const _FieldType: readonly ["text", "number", "select", "multi-select", "radio", "radio-button", "checkbox", "switch", "date", "daterange", "daterange-single", "datetime", "datetimerange", "datetimerange-single", "month", "monthrange", "autocomplete"];
8
+ export declare const _FieldType: readonly ["text", "number", "select", "multi-select", "radio", "radio-button", "checkbox", "switch", "date", "daterange", "daterange-single", "datetime", "datetimerange", "datetimerange-single", "month", "monthrange", "stree-select", "dtree-select", "ftree-select", "multi-stree-select", "multi-dtree-select", "multi-ftree-select", "autocomplete"];
@@ -25,6 +25,12 @@ exports._FieldType = [
25
25
  'datetimerange-single',
26
26
  'month',
27
27
  'monthrange',
28
+ 'stree-select',
29
+ 'dtree-select',
30
+ 'ftree-select',
31
+ 'multi-stree-select',
32
+ 'multi-dtree-select',
33
+ 'multi-ftree-select',
28
34
  'autocomplete',
29
35
  ];
30
36
  // * text 文本输入(默认)
@@ -27,7 +27,6 @@ exports.renderRoot = exports.getNodeParam = exports.BaseTreeSelect = exports.use
27
27
  const lodash_1 = __importStar(require("lodash"));
28
28
  const react_1 = __importStar(require("react"));
29
29
  const antd_1 = require("antd");
30
- // import { HighLight, Icon } from '';
31
30
  const HighLight_1 = require("../_common/HighLight");
32
31
  ;
33
32
  const Icon_1 = require("../_adapt/Icon");
@@ -1,191 +1,151 @@
1
1
  "use strict";
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;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // registerSearchField('treeselect', (props: TableSelectFieldProps) => {
4
- // const { field, onChange, width, data } = props;
5
- // if (!_.has(field.config, 'treeData')) {
6
- // console.error('field type : dictselect must have a treeData field')
7
- // return <TEXT {...props} style={width ? { width } : {}} />
8
- // }
9
- // let param: any = {
10
- // allowClear: true,
11
- // placeholder: _.has(field.config, 'placeholder') ? field.config.placeholder : null || field.placeholder || `请选择${field.label}`,
12
- // };
13
- // if (field.allowClear === false) {
14
- // param.allowClear = false;
15
- // }
16
- // if (_.has(data, field.field)) {
17
- // param.value = data[field.field] || undefined;
18
- // }
19
- // if (_.has(props, 'width')) {
20
- // param.style = { width: props.width }
21
- // }
22
- // return <TreeSelect
23
- // treeDefaultExpandAll
24
- // {...field.config}
25
- // {...param}
26
- // dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
27
- // onChange={value => onChange(value)}
28
- // />
29
- // });
30
- // 动态树
31
- // type TreeNodeData = {
32
- // children?: TreeNodeData[];
33
- // [props: string]: any
34
- // }
35
- // export type BaseTreeOpts = {
36
- // /**
37
- // * 树取值的字段,默认为 `id`
38
- // */
39
- // keyField?: string,
40
- // /**
41
- // * 树显示名称的字段 ,默认为 `name`
42
- // */
43
- // titleField?: string,
44
- // /**
45
- // * 排序字段,默认为空,传入后,以此字段做为排序依据
46
- // */
47
- // sortField?: string;
48
- // /**
49
- // * 根节点 Code 标识
50
- // */
51
- // rootCode?: string;
52
- // /**
53
- // * 根节点API 与rootCode 二选一
54
- // */
55
- // rootApi?: string;
56
- // /**
57
- // * 是否存在子节点,如果有些属性,则根据此值不必多点一次加号
58
- // */
59
- // checkField?: string;
60
- // /**
61
- // * 展开子节点:
62
- // *
63
- // * 方式一:传一个 api 接口地址,必须返回 VData<Array<Object>> 格式
64
- // *
65
- // * 方式二:传一个方法 ,接收一个父节点参数,必须返回 Promise<TreeNodeData[]> (不要返回 children, 仅返回一级)
66
- // */
67
- // childApi?: string | ((parentId: string) => Promise<TreeNodeData[]>);
68
- // }
69
- // class DynamicTreeSelect extends React.PureComponent<TableSelectFieldProps> {
70
- // fields: BaseTreeOpts = {
71
- // keyField: 'id',
72
- // titleField: 'title',
73
- // }
74
- // state = {
75
- // treeData: [],
76
- // }
77
- // async getChildren(parentCode) {
78
- // if (typeof this.props.field.config.childApi == 'string') {
79
- // const resp = await Ajax.GET(`${this.props.field.config.childApi}${parentCode}`);
80
- // if (resp.code == '0') {
81
- // return resp.data;
82
- // }
83
- // return []
84
- // }
85
- // let children = await this.props.field.config.childApi(parentCode);
86
- // return children;
87
- // }
88
- // async componentDidMount() {
89
- // const { field } = this.props;
90
- // if (!_.has(field, 'config.childApi')) {
91
- // return;
92
- // }
93
- // const config: BaseTreeOpts = field.config;
94
- // if (config.keyField) {
95
- // this.fields.keyField = config.keyField;
96
- // }
97
- // if (config.titleField) {
98
- // this.fields.titleField = config.titleField;
99
- // }
100
- // if (config.sortField) {
101
- // this.fields.sortField = config.sortField;
102
- // }
103
- // if (config.checkField) {
104
- // this.fields.checkField = config.checkField;
105
- // }
106
- // let treeData = [];
107
- // if (config.rootCode) {
108
- // treeData = await this.getChildren(config.rootCode);
109
- // } else if (config.rootApi) {
110
- // const resp = await Ajax.GET(config.rootApi);
111
- // if (resp.code == '0') {
112
- // if (_.isArray(resp.data)) {
113
- // treeData = resp.data;
114
- // } else {
115
- // treeData = [resp.data];
116
- // }
117
- // }
118
- // }
119
- // this.setState({ treeData });
120
- // };
121
- // setChidren(treeData: any[], key: string, children: any[]) {
122
- // for (let node of treeData) {
123
- // if (node[this.fields.keyField] == key) {
124
- // node.children = children;
125
- // return true;
126
- // } else if (_.isArray(node.children) && node.children.length) {
127
- // return this.setChidren(node.children, key, children);
128
- // }
129
- // }
130
- // return false;
131
- // }
132
- // async onLoadData(node) {
133
- // const children = await this.getChildren(node.props.eventKey);
134
- // if (children.length == 0) {
135
- // return;
136
- // }
137
- // const treeData = _.concat([], this.state.treeData);
138
- // this.setChidren(treeData, node.props.eventKey, children)
139
- // this.setState({ treeData })
140
- // };
141
- // renderNode(data: any) {
142
- // let isLeaf = false;
143
- // if (_.has(data, 'children') && _.isArray(data.children)) {
144
- // if (data.children.length) {
145
- // isLeaf = false;
146
- // } else {
147
- // isLeaf = true;
148
- // }
149
- // } else if (this.fields.checkField) {
150
- // if (!data[this.fields.checkField]) {
151
- // isLeaf = true;
152
- // }
153
- // }
154
- // if (isLeaf) {
155
- // return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]} isLeaf> </TreeSelect.TreeNode>
156
- // }
157
- // if (_.isArray(data.children) && data.children.length) {
158
- // return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]}>
159
- // {data.children.map(item => this.renderNode(item))}
160
- // </TreeSelect.TreeNode>
161
- // }
162
- // return <TreeSelect.TreeNode value={data[this.fields.keyField]} key={data[this.fields.keyField]} title={data[this.fields.titleField]}> </TreeSelect.TreeNode>
163
- // }
164
- // render() {
165
- // const { field, onChange, data } = this.props;
166
- // const { treeData } = this.state;
167
- // let param: any = {
168
- // allowClear: true,
169
- // placeholder: _.has(field.config, 'placeholder') ? field.config.placeholder : null || field.placeholder || `请选择 ${field.label}`,
170
- // }
171
- // if (field.allowClear === false) {
172
- // param.allowClear = false;
173
- // }
174
- // if (_.has(data, field.field)) {
175
- // param.value = data[field.field];
176
- // }
177
- // if (_.has(this.props, 'width')) {
178
- // param.style = { width: this.props.width }
179
- // }
180
- // return <TreeSelect
181
- // {...param}
182
- // onChange={(value, label, extra) => {
183
- // onChange(value)
184
- // }}
185
- // loadData={(node) => this.onLoadData(node)}
186
- // >
187
- // {treeData.map(item => this.renderNode(item))}
188
- // </TreeSelect>
189
- // }
190
- // }
191
- // registerSearchField('dynamic-tree-select', DynamicTreeSelect);
29
+ const react_1 = __importStar(require("react"));
30
+ const lodash_1 = __importDefault(require("lodash"));
31
+ const _register_1 = require("../../SearchBar/_register");
32
+ const STreeSelect_1 = require("../../TreeSelect/STreeSelect");
33
+ const DTreeSelect_1 = require("../../TreeSelect/DTreeSelect");
34
+ const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
35
+ const SearchFieldInput_1 = require("./SearchFieldInput");
36
+ const toArr = (value) => (0, react_1.useMemo)(() => {
37
+ if (value == undefined)
38
+ return [];
39
+ if (lodash_1.default.isArray(value))
40
+ return value;
41
+ if (lodash_1.default.isString(value))
42
+ return value.split(',');
43
+ return [];
44
+ }, [value]);
45
+ (0, _register_1.registerSearchField)('stree-select', (props) => {
46
+ const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
47
+ if (!lodash_1.default.has(config, 'titleField')) {
48
+ console.error('field type : STree select must have a config with titleField');
49
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
50
+ }
51
+ let treeData = lodash_1.default.has(config, 'treeData') ? config.treeData : options;
52
+ let params = {
53
+ titleField: config.titleFField,
54
+ disabled: disabled,
55
+ treeData,
56
+ multiple: false,
57
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
58
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
59
+ style: { width },
60
+ };
61
+ return react_1.default.createElement(STreeSelect_1.STreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
62
+ });
63
+ (0, _register_1.registerSearchField)('dtree-select', (props) => {
64
+ const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
65
+ if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'childApi')) {
66
+ console.error('field type : DTree select must have a config with titleField and childApi');
67
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
68
+ }
69
+ let params = {
70
+ titleField: config.titleFField,
71
+ childApi: config.childApi,
72
+ disabled: disabled,
73
+ multiple: false,
74
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
75
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
76
+ style: { width },
77
+ };
78
+ return react_1.default.createElement(DTreeSelect_1.DTreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
79
+ });
80
+ (0, _register_1.registerSearchField)('ftree-select', (props) => {
81
+ const { field: { field, config, placeholder, allowClear }, disabled, onChange, data, width } = props;
82
+ if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'fetchApi')) {
83
+ console.error('field type : FTree select must have a config with titleField and fetchApi');
84
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
85
+ }
86
+ let params = {
87
+ titleField: config.titleFField,
88
+ fetchApi: config.fetchApi,
89
+ disabled: disabled,
90
+ multiple: false,
91
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
92
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
93
+ style: { width },
94
+ };
95
+ return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, config, { multiple: false, value: (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined, onChange: onChange }));
96
+ });
97
+ (0, _register_1.registerSearchField)('multi-stree-select', (props) => {
98
+ const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
99
+ if (!lodash_1.default.has(config, 'titleField')) {
100
+ console.error('field type : tree-select must have a config with title field');
101
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
102
+ }
103
+ let treeData = lodash_1.default.has(config, 'treeData') ? config.treeData : options;
104
+ let params = {
105
+ titleField: config.titleFField,
106
+ disabled: disabled,
107
+ treeData,
108
+ multiple: true,
109
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
110
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
111
+ style: { width },
112
+ };
113
+ const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
114
+ return react_1.default.createElement(STreeSelect_1.STreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
115
+ });
116
+ (0, _register_1.registerSearchField)('multi-dtree-select', (props) => {
117
+ const { field: { field, config, placeholder, allowClear, options }, disabled, onChange, data, width } = props;
118
+ if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'childApi')) {
119
+ console.error('field type : DTree select must have a config with titleField and childApi');
120
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
121
+ }
122
+ let params = {
123
+ titleField: config.titleFField,
124
+ childApi: config.childApi,
125
+ disabled: disabled,
126
+ multiple: false,
127
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
128
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
129
+ style: { width },
130
+ };
131
+ const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
132
+ return react_1.default.createElement(DTreeSelect_1.DTreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
133
+ });
134
+ (0, _register_1.registerSearchField)('multi-ftree-select', (props) => {
135
+ const { field: { field, config, placeholder, allowClear }, disabled, onChange, data, width } = props;
136
+ if (!lodash_1.default.has(config, 'titleField') || !lodash_1.default.has(config, 'fetchApi')) {
137
+ console.error('field type : FTree select must have a config with titleField and fetchApi');
138
+ return react_1.default.createElement(SearchFieldInput_1.TEXT, Object.assign({}, props));
139
+ }
140
+ let params = {
141
+ titleField: config.titleFField,
142
+ fetchApi: config.fetchApi,
143
+ disabled: disabled,
144
+ multiple: false,
145
+ allowClear: typeof allowClear == 'boolean' ? allowClear : true,
146
+ placeholder: lodash_1.default.has(config, 'placeholder') ? config.placeholder : placeholder,
147
+ style: { width },
148
+ };
149
+ const value = (lodash_1.default.has(data, field) && data[field] !== null) ? data[field] : undefined;
150
+ return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, config, { multiple: true, value: toArr(value), onChange: (ids) => onChange(ids.join(',')) }));
151
+ });
@@ -33,6 +33,15 @@ const _input_1 = require("../../UForm/_input");
33
33
  const STreeSelect_1 = require("../../TreeSelect/STreeSelect");
34
34
  const DTreeSelect_1 = require("../../TreeSelect/DTreeSelect");
35
35
  const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
36
+ const toArr = (value) => (0, react_1.useMemo)(() => {
37
+ if (value == undefined)
38
+ return [];
39
+ if (lodash_1.default.isArray(value))
40
+ return value;
41
+ if (lodash_1.default.isString(value))
42
+ return value.split(',');
43
+ return [];
44
+ }, [value]);
36
45
  (0, _register_1.registerFormField)('stree-select', (props) => {
37
46
  const { field, disabled, value, onChange } = props;
38
47
  let params = { placeholder: (0, _input_1.getPlaceholder)(field, true), disabled, allowClear: true };
@@ -54,15 +63,6 @@ const FTreeSelect_1 = require("../../TreeSelect/FTreeSelect");
54
63
  params.allowClear = false;
55
64
  return react_1.default.createElement(FTreeSelect_1.FTreeSelect, Object.assign({}, params, field.config, { multiple: false, value: value === null ? undefined : value, onChange: onChange }));
56
65
  });
57
- const toArr = (value) => (0, react_1.useMemo)(() => {
58
- if (value == undefined)
59
- return [];
60
- if (lodash_1.default.isArray(value))
61
- return value;
62
- if (lodash_1.default.isString(value))
63
- return value.split(',');
64
- return [];
65
- }, [value]);
66
66
  const treeChange = (onChange, dataType) => (0, react_1.useCallback)((value) => {
67
67
  if (dataType == 'array') {
68
68
  onChange(value);
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.1.8","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.9","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}