@hi-ui/schema-fields 4.0.0-experimental.1
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/README.md +11 -0
- package/lib/cjs/base.js +125 -0
- package/lib/cjs/components/image-preview/index.js +63 -0
- package/lib/cjs/components/span/index.js +33 -0
- package/lib/cjs/components/upload-bridge/index.js +227 -0
- package/lib/cjs/components/upload-bridge/utils.js +73 -0
- package/lib/cjs/ctx.js +70 -0
- package/lib/cjs/editable/ctx.js +45 -0
- package/lib/cjs/editable/editable.js +141 -0
- package/lib/cjs/editable/index.js +62 -0
- package/lib/cjs/editable/readonly.js +36 -0
- package/lib/cjs/editable/simple.js +61 -0
- package/lib/cjs/editable/use-readonly.js +200 -0
- package/lib/cjs/extensible/selectable/index.js +114 -0
- package/lib/cjs/extensible/selectable/match-cascader.js +184 -0
- package/lib/cjs/fields/basic/cascader/index.js +98 -0
- package/lib/cjs/fields/basic/check-cascader/index.js +58 -0
- package/lib/cjs/fields/basic/check-select/index.js +89 -0
- package/lib/cjs/fields/basic/check-tree-select/index.js +61 -0
- package/lib/cjs/fields/basic/checkbox/index.js +84 -0
- package/lib/cjs/fields/basic/counter/index.js +40 -0
- package/lib/cjs/fields/basic/radio/index.js +44 -0
- package/lib/cjs/fields/basic/rating/index.js +40 -0
- package/lib/cjs/fields/basic/select/index.js +98 -0
- package/lib/cjs/fields/basic/slider/index.js +40 -0
- package/lib/cjs/fields/basic/switch/index.js +47 -0
- package/lib/cjs/fields/basic/textarea/index.js +40 -0
- package/lib/cjs/fields/basic/time-picker/index.js +45 -0
- package/lib/cjs/fields/basic/time-picker/index.scss.js +18 -0
- package/lib/cjs/fields/basic/tree-select/index.js +61 -0
- package/lib/cjs/fields/basic/upload/custom.js +29 -0
- package/lib/cjs/fields/basic/upload/index.js +48 -0
- package/lib/cjs/fields/enhance/number-range/index.js +39 -0
- package/lib/cjs/fields/semantic/date/index.js +82 -0
- package/lib/cjs/fields/semantic/image/index.js +65 -0
- package/lib/cjs/fields/semantic/image/upload.js +32 -0
- package/lib/cjs/fields/semantic/link/index.js +96 -0
- package/lib/cjs/fields/semantic/number/index.js +106 -0
- package/lib/cjs/fields/semantic/tag/index.js +164 -0
- package/lib/cjs/fields/semantic/tag/index.scss.js +18 -0
- package/lib/cjs/fields/semantic/text/index.js +61 -0
- package/lib/cjs/index.js +145 -0
- package/lib/cjs/utils/batch-dep-update.js +40 -0
- package/lib/cjs/utils/form-binding.js +40 -0
- package/lib/cjs/utils/label.js +34 -0
- package/lib/cjs/utils.js +35 -0
- package/lib/esm/base.js +111 -0
- package/lib/esm/components/image-preview/index.js +49 -0
- package/lib/esm/components/span/index.js +20 -0
- package/lib/esm/components/upload-bridge/index.js +214 -0
- package/lib/esm/components/upload-bridge/utils.js +66 -0
- package/lib/esm/ctx.js +55 -0
- package/lib/esm/editable/ctx.js +32 -0
- package/lib/esm/editable/editable.js +129 -0
- package/lib/esm/editable/index.js +44 -0
- package/lib/esm/editable/readonly.js +24 -0
- package/lib/esm/editable/simple.js +49 -0
- package/lib/esm/editable/use-readonly.js +193 -0
- package/lib/esm/extensible/selectable/index.js +101 -0
- package/lib/esm/extensible/selectable/match-cascader.js +179 -0
- package/lib/esm/fields/basic/cascader/index.js +83 -0
- package/lib/esm/fields/basic/check-cascader/index.js +44 -0
- package/lib/esm/fields/basic/check-select/index.js +75 -0
- package/lib/esm/fields/basic/check-tree-select/index.js +47 -0
- package/lib/esm/fields/basic/checkbox/index.js +70 -0
- package/lib/esm/fields/basic/counter/index.js +26 -0
- package/lib/esm/fields/basic/radio/index.js +30 -0
- package/lib/esm/fields/basic/rating/index.js +26 -0
- package/lib/esm/fields/basic/select/index.js +83 -0
- package/lib/esm/fields/basic/slider/index.js +26 -0
- package/lib/esm/fields/basic/switch/index.js +33 -0
- package/lib/esm/fields/basic/textarea/index.js +26 -0
- package/lib/esm/fields/basic/time-picker/index.js +31 -0
- package/lib/esm/fields/basic/time-picker/index.scss.js +13 -0
- package/lib/esm/fields/basic/tree-select/index.js +47 -0
- package/lib/esm/fields/basic/upload/custom.js +16 -0
- package/lib/esm/fields/basic/upload/index.js +34 -0
- package/lib/esm/fields/enhance/number-range/index.js +26 -0
- package/lib/esm/fields/semantic/date/index.js +67 -0
- package/lib/esm/fields/semantic/image/index.js +51 -0
- package/lib/esm/fields/semantic/image/upload.js +20 -0
- package/lib/esm/fields/semantic/link/index.js +82 -0
- package/lib/esm/fields/semantic/number/index.js +91 -0
- package/lib/esm/fields/semantic/tag/index.js +149 -0
- package/lib/esm/fields/semantic/tag/index.scss.js +13 -0
- package/lib/esm/fields/semantic/text/index.js +47 -0
- package/lib/esm/index.js +85 -0
- package/lib/esm/utils/batch-dep-update.js +35 -0
- package/lib/esm/utils/form-binding.js +34 -0
- package/lib/esm/utils/label.js +21 -0
- package/lib/esm/utils.js +27 -0
- package/lib/types/base.d.ts +44 -0
- package/lib/types/components/async-refill-placeholder/index.d.ts +7 -0
- package/lib/types/components/image-preview/index.d.ts +5 -0
- package/lib/types/components/span/index.d.ts +8 -0
- package/lib/types/components/upload-bridge/index.d.ts +5 -0
- package/lib/types/components/upload-bridge/type.d.ts +26 -0
- package/lib/types/components/upload-bridge/utils.d.ts +11 -0
- package/lib/types/ctx.d.ts +21 -0
- package/lib/types/editable/ctx.d.ts +5 -0
- package/lib/types/editable/editable.d.ts +18 -0
- package/lib/types/editable/index.d.ts +14 -0
- package/lib/types/editable/readonly.d.ts +8 -0
- package/lib/types/editable/simple.d.ts +8 -0
- package/lib/types/editable/type.d.ts +9 -0
- package/lib/types/editable/use-readonly.d.ts +26 -0
- package/lib/types/extensible/selectable/index.d.ts +31 -0
- package/lib/types/extensible/selectable/match-cascader.d.ts +19 -0
- package/lib/types/extensible/selectable/type.d.ts +16 -0
- package/lib/types/fields/basic/cascader/index.d.ts +10 -0
- package/lib/types/fields/basic/check-cascader/index.d.ts +11 -0
- package/lib/types/fields/basic/check-select/index.d.ts +34 -0
- package/lib/types/fields/basic/check-tree-select/index.d.ts +10 -0
- package/lib/types/fields/basic/checkbox/index.d.ts +19 -0
- package/lib/types/fields/basic/counter/index.d.ts +7 -0
- package/lib/types/fields/basic/radio/index.d.ts +7 -0
- package/lib/types/fields/basic/rating/index.d.ts +7 -0
- package/lib/types/fields/basic/select/index.d.ts +12 -0
- package/lib/types/fields/basic/slider/index.d.ts +7 -0
- package/lib/types/fields/basic/switch/index.d.ts +7 -0
- package/lib/types/fields/basic/textarea/index.d.ts +7 -0
- package/lib/types/fields/basic/time-picker/index.d.ts +8 -0
- package/lib/types/fields/basic/tree-select/index.d.ts +11 -0
- package/lib/types/fields/basic/upload/custom.d.ts +3 -0
- package/lib/types/fields/basic/upload/index.d.ts +8 -0
- package/lib/types/fields/enhance/number-range/index.d.ts +7 -0
- package/lib/types/fields/semantic/date/index.d.ts +15 -0
- package/lib/types/fields/semantic/image/index.d.ts +11 -0
- package/lib/types/fields/semantic/image/upload.d.ts +3 -0
- package/lib/types/fields/semantic/link/index.d.ts +31 -0
- package/lib/types/fields/semantic/number/index.d.ts +21 -0
- package/lib/types/fields/semantic/tag/index.d.ts +78 -0
- package/lib/types/fields/semantic/text/index.d.ts +13 -0
- package/lib/types/index.d.ts +108 -0
- package/lib/types/utils/batch-dep-update.d.ts +13 -0
- package/lib/types/utils/form-binding.d.ts +11 -0
- package/lib/types/utils/label.d.ts +11 -0
- package/lib/types/utils.d.ts +15 -0
- package/package.json +98 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import Slider from '@hi-ui/slider';
|
|
13
|
+
import { ProField } from '../../../base.js';
|
|
14
|
+
var ProSlider = /*#__PURE__*/function (_ProField) {
|
|
15
|
+
_inheritsLoose(ProSlider, _ProField);
|
|
16
|
+
function ProSlider() {
|
|
17
|
+
return _ProField.apply(this, arguments) || this;
|
|
18
|
+
}
|
|
19
|
+
var _proto = ProSlider.prototype;
|
|
20
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
21
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
22
|
+
return /*#__PURE__*/React.createElement(Slider, Object.assign({}, fieldProps));
|
|
23
|
+
};
|
|
24
|
+
return ProSlider;
|
|
25
|
+
}(ProField);
|
|
26
|
+
export { ProSlider };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import Switch from '@hi-ui/switch';
|
|
13
|
+
import { InterruptInjector } from '@hi-ui/schema-interrupt-injector';
|
|
14
|
+
import { ProField } from '../../../base.js';
|
|
15
|
+
var ProSwitch = /*#__PURE__*/function (_ProField) {
|
|
16
|
+
_inheritsLoose(ProSwitch, _ProField);
|
|
17
|
+
function ProSwitch() {
|
|
18
|
+
return _ProField.apply(this, arguments) || this;
|
|
19
|
+
}
|
|
20
|
+
var _proto = ProSwitch.prototype;
|
|
21
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
22
|
+
var _a;
|
|
23
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
24
|
+
return /*#__PURE__*/React.createElement(InterruptInjector, {
|
|
25
|
+
config: (_a = ctx.field.control) === null || _a === void 0 ? void 0 : _a.interrupt
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Switch, Object.assign({}, fieldProps, {
|
|
27
|
+
// Switch 组件的 checked 属性,需要手动绑定
|
|
28
|
+
checked: ctx.formBinding.value
|
|
29
|
+
})));
|
|
30
|
+
};
|
|
31
|
+
return ProSwitch;
|
|
32
|
+
}(ProField);
|
|
33
|
+
export { ProSwitch };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import Textarea from '@hi-ui/textarea';
|
|
13
|
+
import { ProField } from '../../../base.js';
|
|
14
|
+
var ProTextArea = /*#__PURE__*/function (_ProField) {
|
|
15
|
+
_inheritsLoose(ProTextArea, _ProField);
|
|
16
|
+
function ProTextArea() {
|
|
17
|
+
return _ProField.apply(this, arguments) || this;
|
|
18
|
+
}
|
|
19
|
+
var _proto = ProTextArea.prototype;
|
|
20
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
21
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
22
|
+
return /*#__PURE__*/React.createElement(Textarea, Object.assign({}, fieldProps));
|
|
23
|
+
};
|
|
24
|
+
return ProTextArea;
|
|
25
|
+
}(ProField);
|
|
26
|
+
export { ProTextArea };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { cx } from '@hi-ui/classname';
|
|
13
|
+
import TimePicker from '@hi-ui/time-picker';
|
|
14
|
+
import { ProField } from '../../../base.js';
|
|
15
|
+
import './index.scss.js';
|
|
16
|
+
var ProTimePicker = /*#__PURE__*/function (_ProField) {
|
|
17
|
+
_inheritsLoose(ProTimePicker, _ProField);
|
|
18
|
+
function ProTimePicker() {
|
|
19
|
+
return _ProField.apply(this, arguments) || this;
|
|
20
|
+
}
|
|
21
|
+
var _proto = ProTimePicker.prototype;
|
|
22
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
23
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
24
|
+
var className = cx('pro-time-picker', fieldProps.className);
|
|
25
|
+
return /*#__PURE__*/React.createElement(TimePicker, Object.assign({}, fieldProps, {
|
|
26
|
+
className: className
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
return ProTimePicker;
|
|
30
|
+
}(ProField);
|
|
31
|
+
export { ProTimePicker };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import __styleInject__ from '@hi-ui/style-inject';
|
|
11
|
+
var css_248z = ".pro-time-picker.hi-v5-time-picker,.pro-time-picker .hi-v5-time-picker__input-wrapper,.pro-time-picker .hi-v5-time-picker__input__wrapper {width: 100%;}.pro-time-picker .hi-v5-time-picker__input-wrapper {-webkit-box-pack: justify;-ms-flex-pack: justify;justify-content: space-between;}.pro-time-picker .hi-v5-time-picker__input {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;}";
|
|
12
|
+
__styleInject__(css_248z);
|
|
13
|
+
export { css_248z as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import TreeSelect from '@hi-ui/tree-select';
|
|
13
|
+
import { AsyncOptsDataInjector } from '@hi-ui/schema-option-injector';
|
|
14
|
+
import { ProSelectableField } from '../../../extensible/selectable/index.js';
|
|
15
|
+
var ProTreeSelect = /*#__PURE__*/function (_ProSelectableField) {
|
|
16
|
+
_inheritsLoose(ProTreeSelect, _ProSelectableField);
|
|
17
|
+
function ProTreeSelect() {
|
|
18
|
+
return _ProSelectableField.apply(this, arguments) || this;
|
|
19
|
+
}
|
|
20
|
+
var _proto = ProTreeSelect.prototype;
|
|
21
|
+
_proto.render = function render(data, ctx) {
|
|
22
|
+
var title = this.getOptionTitle(ctx);
|
|
23
|
+
return _ProSelectableField.prototype.render.call(this, title, ctx);
|
|
24
|
+
};
|
|
25
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
var fieldProps = this.getFieldProps({
|
|
28
|
+
overlay: (_a = ctx.field.extra) === null || _a === void 0 ? void 0 : _a.popperProps
|
|
29
|
+
}, ctx);
|
|
30
|
+
// NOTE 实测 searchMode 不传时,无法开启搜索
|
|
31
|
+
// 考虑到是有接口搜索时,会按照关键字过滤,因此默认采用 filter 模式
|
|
32
|
+
if (fieldProps.request) fieldProps.searchMode = 'filter';
|
|
33
|
+
return /*#__PURE__*/React.createElement(AsyncOptsDataInjector, Object.assign({}, fieldProps, {
|
|
34
|
+
renderCtx: ctx,
|
|
35
|
+
setSelectedRawOption: (_b = ctx.field.payload) === null || _b === void 0 ? void 0 : _b.setSelectedRawOption
|
|
36
|
+
}), /*#__PURE__*/React.createElement(TreeSelect, null));
|
|
37
|
+
};
|
|
38
|
+
_proto.renderEditable = function renderEditable(data, ctx) {
|
|
39
|
+
var dataKey = ctx.dataKey;
|
|
40
|
+
var title = this.getOptionTitle(ctx, dataKey);
|
|
41
|
+
return _ProSelectableField.prototype.renderEditable.call(this, title, ctx, {
|
|
42
|
+
suffix: this.suffixEl
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
return ProTreeSelect;
|
|
46
|
+
}(ProSelectableField);
|
|
47
|
+
export { ProTreeSelect };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import Upload from '@hi-ui/upload';
|
|
12
|
+
import { UploadBridge } from '../../../components/upload-bridge/index.js';
|
|
13
|
+
function CommonUpload(props) {
|
|
14
|
+
return /*#__PURE__*/React.createElement(UploadBridge, Object.assign({}, props), /*#__PURE__*/React.createElement(Upload, null));
|
|
15
|
+
}
|
|
16
|
+
export { CommonUpload };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { cx } from '@hi-ui/classname';
|
|
13
|
+
import { ProField } from '../../../base.js';
|
|
14
|
+
import { CommonUpload } from './custom.js';
|
|
15
|
+
var ProUpload = /*#__PURE__*/function (_ProField) {
|
|
16
|
+
_inheritsLoose(ProUpload, _ProField);
|
|
17
|
+
function ProUpload() {
|
|
18
|
+
return _ProField.apply(this, arguments) || this;
|
|
19
|
+
}
|
|
20
|
+
var _proto = ProUpload.prototype;
|
|
21
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
22
|
+
var fieldProps = this.getFieldProps({
|
|
23
|
+
value: undefined
|
|
24
|
+
}, ctx);
|
|
25
|
+
var className = cx('pro-upload', fieldProps.className);
|
|
26
|
+
return /*#__PURE__*/React.createElement(CommonUpload
|
|
27
|
+
// pro-upload
|
|
28
|
+
, Object.assign({}, fieldProps, {
|
|
29
|
+
className: className
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
return ProUpload;
|
|
33
|
+
}(ProField);
|
|
34
|
+
export { CommonUpload, ProUpload };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { NumberRange } from '@hi-ui/number-range';
|
|
13
|
+
import { ProField } from '../../../base.js';
|
|
14
|
+
var ProNumberRange = /*#__PURE__*/function (_ProField) {
|
|
15
|
+
_inheritsLoose(ProNumberRange, _ProField);
|
|
16
|
+
function ProNumberRange() {
|
|
17
|
+
return _ProField.apply(this, arguments) || this;
|
|
18
|
+
}
|
|
19
|
+
var _proto = ProNumberRange.prototype;
|
|
20
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
21
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
22
|
+
return /*#__PURE__*/React.createElement(NumberRange, Object.assign({}, fieldProps));
|
|
23
|
+
};
|
|
24
|
+
return ProNumberRange;
|
|
25
|
+
}(ProField);
|
|
26
|
+
export { ProNumberRange };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { isNil } from 'lodash-es';
|
|
13
|
+
import dayjs from 'dayjs';
|
|
14
|
+
import EllipsisTooltip from '@hi-ui/ellipsis-tooltip';
|
|
15
|
+
import { DatePicker } from '@hi-ui/date-picker';
|
|
16
|
+
import { CalendarOutlined } from '@hi-ui/icons';
|
|
17
|
+
import { getPrefixStyleVar } from '@hi-ui/classname';
|
|
18
|
+
import { ProField } from '../../../base.js';
|
|
19
|
+
import { ReadonlyWrapper } from '../../../components/span/index.js';
|
|
20
|
+
var defaultFormat = 'YYYY-MM-DD HH:mm:ss';
|
|
21
|
+
var ProDate = /*#__PURE__*/function (_ProField) {
|
|
22
|
+
_inheritsLoose(ProDate, _ProField);
|
|
23
|
+
function ProDate() {
|
|
24
|
+
var _this;
|
|
25
|
+
_this = _ProField.apply(this, arguments) || this;
|
|
26
|
+
_this.dftFieldProps = {
|
|
27
|
+
format: defaultFormat
|
|
28
|
+
};
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
var _proto = ProDate.prototype;
|
|
32
|
+
_proto.render = function render(data, ctx) {
|
|
33
|
+
if (!data) return this.dftDom;
|
|
34
|
+
var date = dayjs(data);
|
|
35
|
+
var fieldProps = this.getFieldProps(this.dftFieldProps, ctx);
|
|
36
|
+
var formatted = this.getFormattedText(date, fieldProps);
|
|
37
|
+
// 无效日期展示 -
|
|
38
|
+
if (formatted === 'Invalid Date') return this.dftDom;
|
|
39
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, null, /*#__PURE__*/React.createElement(EllipsisTooltip, null, formatted));
|
|
40
|
+
};
|
|
41
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
42
|
+
var _a;
|
|
43
|
+
var fieldProps = this.getFieldProps(Object.assign(Object.assign({}, this.dftFieldProps), {
|
|
44
|
+
overlay: (_a = ctx.field.extra) === null || _a === void 0 ? void 0 : _a.popperProps
|
|
45
|
+
}), ctx);
|
|
46
|
+
return /*#__PURE__*/React.createElement(DatePicker, Object.assign({}, fieldProps));
|
|
47
|
+
};
|
|
48
|
+
_proto.getFormattedText = function getFormattedText(date, fieldProps) {
|
|
49
|
+
var formatted = typeof fieldProps.format === 'function' ? fieldProps.format(date) : date.format(fieldProps.format || defaultFormat);
|
|
50
|
+
return formatted;
|
|
51
|
+
};
|
|
52
|
+
_proto.getEditablePlaceholder = function getEditablePlaceholder(data, ctx) {
|
|
53
|
+
if (isNil(data)) return '';
|
|
54
|
+
var fieldProps = this.getFieldProps(this.dftFieldProps, ctx);
|
|
55
|
+
return this.getFormattedText(dayjs(data), fieldProps);
|
|
56
|
+
};
|
|
57
|
+
_proto.renderEditable = function renderEditable(data, ctx) {
|
|
58
|
+
return _ProField.prototype.renderEditable.call(this, data, ctx, {
|
|
59
|
+
suffix: ( /*#__PURE__*/React.createElement(CalendarOutlined, {
|
|
60
|
+
size: 16,
|
|
61
|
+
color: "var(" + getPrefixStyleVar('color-gray-500') + ", #929aa6)"
|
|
62
|
+
}))
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return ProDate;
|
|
66
|
+
}(ProField);
|
|
67
|
+
export { ProDate };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { cx } from '@hi-ui/classname';
|
|
13
|
+
import { ImagePreview } from '../../../components/image-preview/index.js';
|
|
14
|
+
import { ProField } from '../../../base.js';
|
|
15
|
+
import { ReadonlyWrapper } from '../../../components/span/index.js';
|
|
16
|
+
import { ImageUpload } from './upload.js';
|
|
17
|
+
var ProImage = /*#__PURE__*/function (_ProField) {
|
|
18
|
+
_inheritsLoose(ProImage, _ProField);
|
|
19
|
+
function ProImage() {
|
|
20
|
+
return _ProField.apply(this, arguments) || this;
|
|
21
|
+
}
|
|
22
|
+
var _proto = ProImage.prototype;
|
|
23
|
+
_proto.render = function render(data, ctx) {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!data) return this.dftDom;
|
|
26
|
+
if (Array.isArray(data) && data.length === 0) return this.dftDom;
|
|
27
|
+
var dftImages = Array.isArray(data) ? data : [data];
|
|
28
|
+
var fieldProps = this.getFieldProps({}, ctx);
|
|
29
|
+
var images = ((_a = fieldProps.customImages) === null || _a === void 0 ? void 0 : _a.call(fieldProps, dftImages, ctx)) || dftImages;
|
|
30
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, {
|
|
31
|
+
dataSet: {
|
|
32
|
+
fieldType: ctx.field.valueType
|
|
33
|
+
}
|
|
34
|
+
}, /*#__PURE__*/React.createElement(ImagePreview, {
|
|
35
|
+
images: images
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
39
|
+
var fieldProps = this.getFieldProps({
|
|
40
|
+
value: undefined
|
|
41
|
+
}, ctx);
|
|
42
|
+
var className = cx('pro-image-upload', fieldProps.className);
|
|
43
|
+
return /*#__PURE__*/React.createElement(ImageUpload
|
|
44
|
+
// pro-upload
|
|
45
|
+
, Object.assign({}, fieldProps, {
|
|
46
|
+
className: className
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
return ProImage;
|
|
50
|
+
}(ProField);
|
|
51
|
+
export { ImageUpload, ProImage };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { PictureUpload } from '@hi-ui/upload';
|
|
12
|
+
import { mergeProps } from '@hi-ui/schema-utils';
|
|
13
|
+
import { UploadBridge } from '../../../components/upload-bridge/index.js';
|
|
14
|
+
function ImageUpload(props) {
|
|
15
|
+
var finalProps = mergeProps({
|
|
16
|
+
accept: '.png,.jpg,.jpeg,.gif,.webp,.svg'
|
|
17
|
+
}, props);
|
|
18
|
+
return /*#__PURE__*/React.createElement(UploadBridge, Object.assign({}, finalProps), /*#__PURE__*/React.createElement(PictureUpload, null));
|
|
19
|
+
}
|
|
20
|
+
export { ImageUpload };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { Link } from 'react-router-dom';
|
|
13
|
+
import { get } from 'lodash-es';
|
|
14
|
+
import EllipsisTooltip from '@hi-ui/ellipsis-tooltip';
|
|
15
|
+
import { mergeProps } from '@hi-ui/schema-utils';
|
|
16
|
+
import { ProField } from '../../../base.js';
|
|
17
|
+
import { ReadonlyWrapper } from '../../../components/span/index.js';
|
|
18
|
+
var ProLink = /*#__PURE__*/function (_ProField) {
|
|
19
|
+
_inheritsLoose(ProLink, _ProField);
|
|
20
|
+
function ProLink() {
|
|
21
|
+
return _ProField.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
var _proto = ProLink.prototype;
|
|
24
|
+
_proto.render = function render(data, ctx) {
|
|
25
|
+
if (!data) return this.dftDom;
|
|
26
|
+
this.renderCtx = ctx;
|
|
27
|
+
var fieldProps = this.getFieldProps({
|
|
28
|
+
linkField: ''
|
|
29
|
+
}, ctx);
|
|
30
|
+
this.fieldProps = fieldProps;
|
|
31
|
+
var _fieldProps$isHref = fieldProps.isHref,
|
|
32
|
+
isHref = _fieldProps$isHref === void 0 ? true : _fieldProps$isHref;
|
|
33
|
+
if (isHref) return this.renderHref(data);else return this.renderLink(data);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* renderHref
|
|
37
|
+
* @desc 是指固定的链接地址,直接跳转出系统 */;
|
|
38
|
+
_proto.renderHref = function renderHref(href) {
|
|
39
|
+
var to = this.getGoTo(href);
|
|
40
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, null, /*#__PURE__*/React.createElement("a", {
|
|
41
|
+
href: to,
|
|
42
|
+
target: "_blank",
|
|
43
|
+
rel: "noreferrer noopener",
|
|
44
|
+
// TODO color 放这里不是很好,待优化
|
|
45
|
+
style: {
|
|
46
|
+
color: '#237ffa',
|
|
47
|
+
textDecoration: 'underline'
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/React.createElement(EllipsisTooltip, null, href)));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* renderLink
|
|
53
|
+
* @desc 是指链接地址是动态的,需要根据数据进行拼接
|
|
54
|
+
* @desc 通常用于链接到系统其他页面 */;
|
|
55
|
+
_proto.renderLink = function renderLink(data) {
|
|
56
|
+
var _a;
|
|
57
|
+
var rowData = this.renderCtx.rowData;
|
|
58
|
+
var to = this.getGoTo(data);
|
|
59
|
+
var state = mergeProps(rowData, (_a = this.fieldProps) === null || _a === void 0 ? void 0 : _a.extraLinkState);
|
|
60
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, null, /*#__PURE__*/React.createElement(Link, {
|
|
61
|
+
to: to,
|
|
62
|
+
state: state,
|
|
63
|
+
style: {
|
|
64
|
+
color: '#237ffa'
|
|
65
|
+
}
|
|
66
|
+
}, /*#__PURE__*/React.createElement(EllipsisTooltip, null, data)));
|
|
67
|
+
};
|
|
68
|
+
_proto.getGoTo = function getGoTo(data) {
|
|
69
|
+
var rowData = this.renderCtx.rowData;
|
|
70
|
+
var _this$fieldProps = this.fieldProps,
|
|
71
|
+
linkField = _this$fieldProps.linkField,
|
|
72
|
+
customLink = _this$fieldProps.customLink;
|
|
73
|
+
// customLink 优先级最高
|
|
74
|
+
if (customLink) return customLink(data, this.renderCtx);
|
|
75
|
+
// linkField 存在,则使用 linkField 拼接
|
|
76
|
+
if (linkField) return get(rowData, linkField);
|
|
77
|
+
// 最后使用本字段的值
|
|
78
|
+
return data;
|
|
79
|
+
};
|
|
80
|
+
return ProLink;
|
|
81
|
+
}(ProField);
|
|
82
|
+
export { ProLink };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-fields
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-fields#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { isNil } from 'lodash-es';
|
|
13
|
+
import NumberInput from '@hi-ui/number-input';
|
|
14
|
+
import EllipsisTooltip from '@hi-ui/ellipsis-tooltip';
|
|
15
|
+
import { NumberUtil } from '@hi-ui/schema-utils';
|
|
16
|
+
import { ProField } from '../../../base.js';
|
|
17
|
+
import { ReadonlyWrapper } from '../../../components/span/index.js';
|
|
18
|
+
var ProNumber = /*#__PURE__*/function (_ProField) {
|
|
19
|
+
_inheritsLoose(ProNumber, _ProField);
|
|
20
|
+
function ProNumber() {
|
|
21
|
+
return _ProField.apply(this, arguments) || this;
|
|
22
|
+
}
|
|
23
|
+
var _proto = ProNumber.prototype;
|
|
24
|
+
_proto._getFieldProps = function _getFieldProps(ctx) {
|
|
25
|
+
var fieldProps = _ProField.prototype.getFieldProps.call(this, {
|
|
26
|
+
placeholder: this.getDftPlaceholder(ctx)
|
|
27
|
+
}, ctx);
|
|
28
|
+
// 增加精度处理逻辑
|
|
29
|
+
// 如果精度存在,且没有 formatter 方法,则增加精度处理逻辑
|
|
30
|
+
if (!isNil(fieldProps.precision) && isNil(fieldProps.formatter)) {
|
|
31
|
+
fieldProps.formatter = function ProNumberPrecisionFormatter(value) {
|
|
32
|
+
return NumberUtil.round(value, fieldProps.precision);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return fieldProps;
|
|
36
|
+
};
|
|
37
|
+
_proto.render = function render(data, ctx) {
|
|
38
|
+
// 不是数字
|
|
39
|
+
if (typeof data !== 'number') {
|
|
40
|
+
/** 且不存在 */if (!data) return this.dftDom;
|
|
41
|
+
}
|
|
42
|
+
// 或者是NaN
|
|
43
|
+
else if (isNaN(data)) return this.dftDom;
|
|
44
|
+
var num = Number(data);
|
|
45
|
+
if (isNaN(num)) return this.dftDom;
|
|
46
|
+
var formatted = this.toFormatted(num, ctx);
|
|
47
|
+
return /*#__PURE__*/React.createElement(ReadonlyWrapper, null, /*#__PURE__*/React.createElement(EllipsisTooltip, null, formatted));
|
|
48
|
+
};
|
|
49
|
+
_proto.renderFormItem = function renderFormItem(_, ctx) {
|
|
50
|
+
var fieldProps = this._getFieldProps(ctx);
|
|
51
|
+
return /*#__PURE__*/React.createElement(NumberInput, Object.assign({}, fieldProps));
|
|
52
|
+
};
|
|
53
|
+
_proto.getEditablePlaceholder = function getEditablePlaceholder(data) {
|
|
54
|
+
// 记录:返回undefined,会被转换为0,null则不会
|
|
55
|
+
if (isNil(data)) return null;
|
|
56
|
+
if (typeof data === 'number') return isNaN(data) ? null : data;
|
|
57
|
+
var num = Number(data);
|
|
58
|
+
return isNaN(num) ? null : num;
|
|
59
|
+
};
|
|
60
|
+
_proto.renderEditable = function renderEditable(data, ctx) {
|
|
61
|
+
var _a;
|
|
62
|
+
var fieldProps = this._getFieldProps(ctx);
|
|
63
|
+
return /*#__PURE__*/React.createElement(NumberInput, {
|
|
64
|
+
value: this.getEditablePlaceholder(data),
|
|
65
|
+
disabled: (_a = ctx.field.control) === null || _a === void 0 ? void 0 : _a.disabled,
|
|
66
|
+
onDoubleClick: ctx.onActivate,
|
|
67
|
+
onFocus: ctx.onActivate,
|
|
68
|
+
placeholder: fieldProps.placeholder,
|
|
69
|
+
formatter: fieldProps.formatter,
|
|
70
|
+
min: fieldProps.min,
|
|
71
|
+
max: fieldProps.max,
|
|
72
|
+
step: fieldProps.step,
|
|
73
|
+
onChange: ctx.onActivate
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// 可能之后还有更复杂的格式化逻辑
|
|
77
|
+
;
|
|
78
|
+
|
|
79
|
+
_proto.toFormatted = function toFormatted(data, ctx) {
|
|
80
|
+
var fieldProps = this._getFieldProps(ctx);
|
|
81
|
+
// 123456789 => 123,456,789
|
|
82
|
+
// 123.456789 => 123.4567 // precision: 4
|
|
83
|
+
return data.toLocaleString('zh-Hans', {
|
|
84
|
+
// 也是四舍五入进位
|
|
85
|
+
minimumFractionDigits: fieldProps.precision,
|
|
86
|
+
maximumFractionDigits: fieldProps.precision
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return ProNumber;
|
|
90
|
+
}(ProField);
|
|
91
|
+
export { ProNumber };
|