@hi-ui/schema-fields 4.0.0-experimental.7 → 4.0.0-experimental.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.
- package/CHANGELOG.md +28 -0
- package/lib/base.d.ts +44 -0
- package/lib/bundle.d.ts +76 -0
- package/lib/bundle.js +66 -0
- package/lib/components/async-refill-placeholder/index.d.ts +7 -0
- package/lib/components/image-preview/index.d.ts +5 -0
- package/lib/components/image-preview/index.js +49 -0
- package/lib/components/span/index.d.ts +8 -0
- package/lib/components/upload-bridge/index.d.ts +5 -0
- package/lib/components/upload-bridge/index.js +214 -0
- package/lib/components/upload-bridge/type.d.ts +26 -0
- package/lib/components/upload-bridge/utils.d.ts +11 -0
- package/lib/components/upload-bridge/utils.js +66 -0
- package/lib/ctx.d.ts +26 -0
- package/lib/editable/ctx.d.ts +5 -0
- package/lib/editable/editable.d.ts +18 -0
- package/lib/editable/index.d.ts +14 -0
- package/lib/editable/readonly.d.ts +8 -0
- package/lib/editable/simple.d.ts +8 -0
- package/lib/editable/type.d.ts +9 -0
- package/lib/editable/use-readonly.d.ts +26 -0
- package/lib/extensible/selectable/index.d.ts +31 -0
- package/lib/extensible/selectable/index.js +101 -0
- package/lib/extensible/selectable/match-cascader.d.ts +19 -0
- package/lib/extensible/selectable/match-cascader.js +179 -0
- package/lib/extensible/selectable/type.d.ts +16 -0
- package/lib/fields/basic/cascader/index.d.ts +10 -0
- package/lib/fields/basic/cascader/index.js +83 -0
- package/lib/fields/basic/check-cascader/index.d.ts +11 -0
- package/lib/fields/basic/check-cascader/index.js +44 -0
- package/lib/fields/basic/check-select/index.d.ts +34 -0
- package/lib/fields/basic/check-select/index.js +75 -0
- package/lib/fields/basic/check-tree-select/index.d.ts +10 -0
- package/lib/fields/basic/check-tree-select/index.js +47 -0
- package/lib/fields/basic/checkbox/index.d.ts +19 -0
- package/lib/fields/basic/checkbox/index.js +70 -0
- package/lib/fields/basic/counter/index.d.ts +7 -0
- package/lib/fields/basic/counter/index.js +26 -0
- package/lib/fields/basic/radio/index.d.ts +7 -0
- package/lib/fields/basic/radio/index.js +30 -0
- package/lib/fields/basic/rating/index.d.ts +7 -0
- package/lib/fields/basic/rating/index.js +26 -0
- package/lib/fields/basic/select/index.d.ts +12 -0
- package/lib/fields/basic/select/index.js +83 -0
- package/lib/fields/basic/slider/index.d.ts +7 -0
- package/lib/fields/basic/slider/index.js +26 -0
- package/lib/fields/basic/switch/index.d.ts +7 -0
- package/lib/fields/basic/switch/index.js +33 -0
- package/lib/fields/basic/textarea/index.d.ts +7 -0
- package/lib/fields/basic/textarea/index.js +26 -0
- package/lib/fields/basic/time-picker/index.d.ts +8 -0
- package/lib/fields/basic/time-picker/index.js +31 -0
- package/lib/fields/basic/time-picker/index.scss.js +13 -0
- package/lib/fields/basic/tree-select/index.d.ts +11 -0
- package/lib/fields/basic/tree-select/index.js +47 -0
- package/lib/fields/basic/upload/custom.d.ts +3 -0
- package/lib/fields/basic/upload/custom.js +16 -0
- package/lib/fields/basic/upload/index.d.ts +8 -0
- package/lib/fields/basic/upload/index.js +34 -0
- package/lib/fields/enhance/number-range/index.d.ts +7 -0
- package/lib/fields/enhance/number-range/index.js +26 -0
- package/lib/fields/semantic/date/index.d.ts +15 -0
- package/lib/fields/semantic/date/index.js +67 -0
- package/lib/fields/semantic/image/index.d.ts +11 -0
- package/lib/fields/semantic/image/index.js +51 -0
- package/lib/fields/semantic/image/upload.d.ts +3 -0
- package/lib/fields/semantic/image/upload.js +20 -0
- package/lib/fields/semantic/link/index.d.ts +31 -0
- package/lib/fields/semantic/link/index.js +82 -0
- package/lib/fields/semantic/number/index.d.ts +21 -0
- package/lib/fields/semantic/number/index.js +91 -0
- package/lib/fields/semantic/tag/index.d.ts +25 -0
- package/lib/fields/semantic/tag/index.js +100 -0
- package/lib/fields/semantic/tag/index.scss.js +13 -0
- package/lib/fields/semantic/tag/preset.d.ts +54 -0
- package/lib/fields/semantic/text/index.d.ts +13 -0
- package/lib/index.d.ts +30 -0
- package/lib/utils/batch-dep-update.d.ts +13 -0
- package/lib/utils/form-binding.d.ts +11 -0
- package/lib/utils/label.d.ts +11 -0
- package/lib/utils.d.ts +15 -0
- package/package.json +17 -17
|
@@ -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,8 @@
|
|
|
1
|
+
import { ProField } from '../../../base';
|
|
2
|
+
import type { ProFieldRenderFormItemCtx } from '../../../base';
|
|
3
|
+
import { CommonUpload, type CommonUploadProps } from './custom';
|
|
4
|
+
export { CommonUpload, CommonUploadProps };
|
|
5
|
+
export type ProUploadProps = CommonUploadProps & {};
|
|
6
|
+
export declare class ProUpload extends ProField {
|
|
7
|
+
renderFormItem(_: null, ctx: ProFieldRenderFormItemCtx<ProUploadProps>): JSX.Element;
|
|
8
|
+
}
|
|
@@ -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,7 @@
|
|
|
1
|
+
import type { NumberRangeProps } from '@hi-ui/number-range';
|
|
2
|
+
import { ProField } from '../../../base';
|
|
3
|
+
import type { ProFieldRenderFormItemCtx } from '../../../base';
|
|
4
|
+
export type ProNumberRangeProps = NumberRangeProps & {};
|
|
5
|
+
export declare class ProNumberRange extends ProField {
|
|
6
|
+
renderFormItem(_: null, ctx: ProFieldRenderFormItemCtx<ProNumberRangeProps>): JSX.Element;
|
|
7
|
+
}
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { type DatePickerProps } from '@hi-ui/date-picker';
|
|
3
|
+
import { ProField } from '../../../base';
|
|
4
|
+
import type { ProFieldRenderFormItemCtx, ProFieldRenderCtx, ProFieldRenderEditableCtx } from '../../../base';
|
|
5
|
+
export type ProDateProps = Omit<DatePickerProps, 'format'> & {
|
|
6
|
+
format?: string | ((date: Dayjs) => string);
|
|
7
|
+
};
|
|
8
|
+
export declare class ProDate extends ProField {
|
|
9
|
+
dftFieldProps: ProDateProps;
|
|
10
|
+
render(data: string, ctx: ProFieldRenderCtx<ProDateProps>): JSX.Element;
|
|
11
|
+
renderFormItem(_: null, ctx: ProFieldRenderFormItemCtx<ProDateProps>): JSX.Element;
|
|
12
|
+
protected getFormattedText(date: Dayjs, fieldProps: ProDateProps): string;
|
|
13
|
+
protected getEditablePlaceholder(data: string | number | Date, ctx: ProFieldRenderEditableCtx<ProDateProps>): string;
|
|
14
|
+
renderEditable(data: string, ctx: ProFieldRenderEditableCtx<ProDateProps>): JSX.Element;
|
|
15
|
+
}
|
|
@@ -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,11 @@
|
|
|
1
|
+
import { ProField } from '../../../base';
|
|
2
|
+
import type { ProFieldRenderCtx, ProFieldRenderFormItemCtx } from '../../../base';
|
|
3
|
+
import { ImageUpload, type ImageUploadProps } from './upload';
|
|
4
|
+
export type ProImageProps = UnknownObject & {
|
|
5
|
+
customImages?: (data: string[], ctx: ProFieldRenderCtx<ProImageProps>) => string[];
|
|
6
|
+
};
|
|
7
|
+
export { ImageUpload, ImageUploadProps };
|
|
8
|
+
export declare class ProImage extends ProField {
|
|
9
|
+
render(data: unknown, ctx: ProFieldRenderCtx<ProImageProps>): JSX.Element;
|
|
10
|
+
renderFormItem(_: null, ctx: ProFieldRenderFormItemCtx<ImageUploadProps>): JSX.Element;
|
|
11
|
+
}
|
|
@@ -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,31 @@
|
|
|
1
|
+
import { ProField } from '../../../base';
|
|
2
|
+
import type { ProFieldRenderCtx } from '../../../base';
|
|
3
|
+
export type ProLinkProps = UnknownObject & {
|
|
4
|
+
/** 是否使用href跳转,默认使用Link组件跳转 */
|
|
5
|
+
isHref?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* 链接字段,优先级低于 customLink
|
|
8
|
+
* @desc 支持路径字符串,例如 user.avatar
|
|
9
|
+
*/
|
|
10
|
+
linkField?: string;
|
|
11
|
+
/** 自定义链接地址,优先级高于 linkField */
|
|
12
|
+
customLink?: (data: string, ctx: CustomLinkCtx) => string;
|
|
13
|
+
/** 额外传递给Link组件的state,模型会自动将rowData注入 */
|
|
14
|
+
extraLinkState?: AnyObject;
|
|
15
|
+
};
|
|
16
|
+
export type CustomLinkCtx = ProFieldRenderCtx<ProLinkProps>;
|
|
17
|
+
export declare class ProLink extends ProField {
|
|
18
|
+
renderCtx: ProFieldRenderCtx<ProLinkProps>;
|
|
19
|
+
fieldProps: ProLinkProps;
|
|
20
|
+
render(data: string, ctx: ProFieldRenderCtx<ProLinkProps>): JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* renderHref
|
|
23
|
+
* @desc 是指固定的链接地址,直接跳转出系统 */
|
|
24
|
+
renderHref(href: string): JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* renderLink
|
|
27
|
+
* @desc 是指链接地址是动态的,需要根据数据进行拼接
|
|
28
|
+
* @desc 通常用于链接到系统其他页面 */
|
|
29
|
+
renderLink(data: unknown): JSX.Element;
|
|
30
|
+
getGoTo(data: unknown): any;
|
|
31
|
+
}
|
|
@@ -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,21 @@
|
|
|
1
|
+
import { type NumberInputProps } from '@hi-ui/number-input';
|
|
2
|
+
import { ProField } from '../../../base';
|
|
3
|
+
import type { ProFieldRenderCtx, ProFieldRenderEditableCtx, ProFieldRenderFormItemCtx } from '../../../base';
|
|
4
|
+
import type { NormalFieldCtxType } from '../../../utils';
|
|
5
|
+
export type ProNumberProps = NumberInputProps & {
|
|
6
|
+
/**
|
|
7
|
+
* 指定数字变化的精度
|
|
8
|
+
* @desc 可编辑模式时,指定数字变化的精度
|
|
9
|
+
* @desc 内部使用 HiUI 的 formatter 方法实现四舍五入精度处理
|
|
10
|
+
* @desc 如需更复杂的格式化逻辑精度处理,请结合 NumberUtil 自行实现 formatter 方法
|
|
11
|
+
*/
|
|
12
|
+
precision?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare class ProNumber extends ProField {
|
|
15
|
+
protected _getFieldProps(ctx: NormalFieldCtxType<ProNumberProps>): ProNumberProps;
|
|
16
|
+
render(data: unknown, ctx: ProFieldRenderCtx<ProNumberProps>): JSX.Element;
|
|
17
|
+
renderFormItem(_: null, ctx: ProFieldRenderFormItemCtx<ProNumberProps>): JSX.Element;
|
|
18
|
+
protected getEditablePlaceholder(data: unknown): number | null;
|
|
19
|
+
renderEditable(data: unknown, ctx: ProFieldRenderEditableCtx<ProNumberProps>): JSX.Element;
|
|
20
|
+
toFormatted(data: number, ctx: NormalFieldCtxType<ProNumberProps>): string;
|
|
21
|
+
}
|
|
@@ -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 };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TagProps } from '@hi-ui/tag';
|
|
3
|
+
import { ProField, type ProFieldRenderCtx } from '../../../base';
|
|
4
|
+
import type { ColorPreset, BuiltinColorEnum, SCMColorEnumPreset } from './preset';
|
|
5
|
+
import './index.scss';
|
|
6
|
+
export type ProTagProps = TagProps & {
|
|
7
|
+
/** 是否显示边框 */
|
|
8
|
+
bordered?: boolean;
|
|
9
|
+
colorPreset: Record<string, LiteralUnion<BuiltinColorEnum | SCMColorEnumPreset> | ColorPreset>;
|
|
10
|
+
/** 文本映射
|
|
11
|
+
* - 例如:字段值为0/1,想要显示为 否/是
|
|
12
|
+
* - 可以配置为:textMap: { 0: '否', 1: '是' } 或 textMap: new Map([[0, '否'], [1, '是']])
|
|
13
|
+
* - Map 中 key 的类型可以是任意类型
|
|
14
|
+
* - Map 中 value 的类型需要是有效的 React 子元素类型,例如:string、number、React.ReactNode 等
|
|
15
|
+
*/
|
|
16
|
+
textMap?: Record<string, string | number | React.ReactNode> | Map<unknown, string | number | React.ReactNode>;
|
|
17
|
+
};
|
|
18
|
+
export declare class ProTag extends ProField {
|
|
19
|
+
render(data: string | string[], ctx: ProFieldRenderCtx<ProTagProps>): JSX.Element;
|
|
20
|
+
renderTag(dataArray: string[], ctx: ProFieldRenderCtx<ProTagProps>): JSX.Element;
|
|
21
|
+
getTagProps(props: ProTagProps): Omit<ProTagProps, "bordered" | "colorPreset">;
|
|
22
|
+
getType(preset: ValueOf<ProTagProps['colorPreset']>): "default" | "yellow" | "purple" | "skyblue" | "primary" | "success" | "warning" | "danger" | "ultramarine" | "rosered" | undefined;
|
|
23
|
+
getColor(preset: ValueOf<ProTagProps['colorPreset']>): ColorPreset | undefined;
|
|
24
|
+
getText(data: string, textMap: ProTagProps['textMap']): {};
|
|
25
|
+
}
|