@pointcloud/pcloud-components 0.1.17 → 0.1.18
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 +314 -312
- package/dist/esm/DForm/DItem/itemType.d.ts +4 -2
- package/dist/esm/DForm/DItem/itemsRender.d.ts +1 -1
- package/dist/esm/DForm/DItem/itemsRender.js +1 -1
- package/dist/esm/DForm/index.d.ts +2 -2
- package/dist/esm/DForm/index.js +29 -15
- package/dist/esm/LabelValue/index.d.ts +3 -2
- package/dist/esm/LabelValue/interface.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import { InputProps, InputNumberProps, AutoCompleteProps, CascaderProps, SelectProps, TreeSelectProps, DatePickerProps, TimePickerProps, MentionProps, CheckboxProps, RadioProps, RateProps, SliderSingleProps, SwitchProps, TransferProps, UploadProps, ButtonProps, DividerProps, FormItemProps, RadioGroupProps } from 'antd';
|
|
2
|
+
import { InputProps, InputNumberProps, AutoCompleteProps, CascaderProps, SelectProps, TreeSelectProps, DatePickerProps, TimePickerProps, MentionProps, CheckboxProps, RadioProps, RateProps, SliderSingleProps, SwitchProps, TransferProps, UploadProps, ButtonProps, DividerProps, FormItemProps, RadioGroupProps, ColProps } from 'antd';
|
|
3
3
|
import { PasswordProps, TextAreaProps } from 'antd/lib/input';
|
|
4
4
|
import { RangePickerProps } from 'antd/lib/date-picker';
|
|
5
5
|
import { CheckboxGroupProps } from 'antd/lib/checkbox';
|
|
@@ -14,7 +14,9 @@ export declare type DItemBaseProps = {
|
|
|
14
14
|
/** name标签文本,同antd Form.Item的name */
|
|
15
15
|
name?: string;
|
|
16
16
|
/** Form.Item 的其他属性 */
|
|
17
|
-
formItemProps?: FormItemProps
|
|
17
|
+
formItemProps?: FormItemProps & {
|
|
18
|
+
grid?: Omit<ColProps, 'prefixCls'>;
|
|
19
|
+
};
|
|
18
20
|
};
|
|
19
21
|
/** 自定义渲染的DItem */
|
|
20
22
|
declare type CustomItemProps = DItemBaseProps & HTMLAttributes<HTMLElement> & {
|
|
@@ -33,7 +33,7 @@ declare const renderMap: {
|
|
|
33
33
|
rate: (props: RateProps, formItemProps: FormItemProps) => JSX.Element;
|
|
34
34
|
slider: (props: SliderSingleProps, formItemProps: FormItemProps) => JSX.Element;
|
|
35
35
|
switch: (props: SwitchProps, formItemProps: FormItemProps) => JSX.Element;
|
|
36
|
-
transfer: (props: TransferProps<any>, formItemProps: FormItemProps, render: TransferProps<any>['render']) => JSX.Element;
|
|
36
|
+
transfer: (props: TransferProps<any>, formItemProps: FormItemProps, label: DItemBaseProps['label'], render: TransferProps<any>['render']) => JSX.Element;
|
|
37
37
|
upload: (props: UploadProps, formItemProps: FormItemProps, label: DItemBaseProps['label'], render: () => void, children: UploadProps['children']) => JSX.Element;
|
|
38
38
|
dUpload: (props: DUploadProps, formItemProps: FormItemProps, render: (props: any) => ReactNode, children: DUploadProps['children']) => JSX.Element;
|
|
39
39
|
button: (props: ButtonProps, formItemProps: FormItemProps, label: DItemBaseProps['label']) => JSX.Element;
|
|
@@ -165,7 +165,7 @@ var renderMap = {
|
|
|
165
165
|
children: /*#__PURE__*/_jsx(Switch, _objectSpread({}, props))
|
|
166
166
|
}));
|
|
167
167
|
},
|
|
168
|
-
transfer: function transfer(props, formItemProps, render) {
|
|
168
|
+
transfer: function transfer(props, formItemProps, label, render) {
|
|
169
169
|
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemProps), {}, {
|
|
170
170
|
children: /*#__PURE__*/_jsx(Transfer, _objectSpread({
|
|
171
171
|
render: render
|
|
@@ -9,8 +9,8 @@ declare type InternalFormProps = {
|
|
|
9
9
|
defaultItemProps?: DItemProps;
|
|
10
10
|
/** children 方式添加表单项,如果同时设置了 items,则 children 在 items 下面 */
|
|
11
11
|
children?: ReactNode;
|
|
12
|
-
/** 布局方式 新增了行内垂直布局方式inlineVertical */
|
|
13
|
-
layout?: 'inline' | 'horizontal' | 'vertical' | 'inlineVertical';
|
|
12
|
+
/** 布局方式 新增了行内垂直布局方式inlineVertical 和 grid栅格布局 */
|
|
13
|
+
layout?: 'inline' | 'horizontal' | 'vertical' | 'inlineVertical' | 'grid';
|
|
14
14
|
};
|
|
15
15
|
declare type DFormProps = Omit<FormProps, 'children' | 'layout'> & InternalFormProps;
|
|
16
16
|
declare type DFormRefProps = {
|
package/dist/esm/DForm/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var _excluded = ["className", "defaultItemProps", "items", "children", "layout",
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import React, { forwardRef, useContext, useState, useEffect, useImperativeHandle } from 'react';
|
|
14
|
-
import { Form } from 'antd';
|
|
14
|
+
import { Form, Row, Col } from 'antd';
|
|
15
15
|
import { ConfigContext } from "../ConfigProvider";
|
|
16
16
|
import helper from "./helper";
|
|
17
17
|
import DItem from "./DItem";
|
|
@@ -19,13 +19,26 @@ import "./index.less";
|
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line no-unused-vars
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
function getChildren(items, children, _defaultItemProps) {
|
|
22
|
+
function getChildren(items, children, _defaultItemProps, layout) {
|
|
23
23
|
var list = [];
|
|
24
24
|
if (items instanceof Array && items.length > 0) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (layout === 'grid') {
|
|
26
|
+
list.push( /*#__PURE__*/_jsx(Row, {
|
|
27
|
+
children: items.map(function (item, index) {
|
|
28
|
+
var _item$formItemProps;
|
|
29
|
+
var _item = helper.merge(_defaultItemProps, item);
|
|
30
|
+
var _gridProps = (_item === null || _item === void 0 ? void 0 : (_item$formItemProps = _item.formItemProps) === null || _item$formItemProps === void 0 ? void 0 : _item$formItemProps.grid) || {};
|
|
31
|
+
return /*#__PURE__*/_jsx(Col, _objectSpread(_objectSpread({}, _gridProps), {}, {
|
|
32
|
+
children: /*#__PURE__*/_jsx(DItem, _objectSpread({}, _item))
|
|
33
|
+
}), (item === null || item === void 0 ? void 0 : item.name) || index);
|
|
34
|
+
})
|
|
35
|
+
}));
|
|
36
|
+
} else {
|
|
37
|
+
list = items.map(function (item, index) {
|
|
38
|
+
var _item = helper.merge(_defaultItemProps, item);
|
|
39
|
+
return /*#__PURE__*/_jsx(DItem, _objectSpread({}, _item), (item === null || item === void 0 ? void 0 : item.name) || index);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
29
42
|
}
|
|
30
43
|
if (children) {
|
|
31
44
|
var childrenList = children instanceof Array ? children : [children];
|
|
@@ -44,34 +57,35 @@ function InternalForm(props, ref) {
|
|
|
44
57
|
defaultItemProps = props.defaultItemProps,
|
|
45
58
|
items = props.items,
|
|
46
59
|
children = props.children,
|
|
47
|
-
layout = props.layout,
|
|
60
|
+
_props$layout = props.layout,
|
|
61
|
+
layout = _props$layout === void 0 ? 'vertical' : _props$layout,
|
|
48
62
|
_props$autoComplete = props.autoComplete,
|
|
49
63
|
autoComplete = _props$autoComplete === void 0 ? 'off' : _props$autoComplete,
|
|
50
64
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
51
65
|
var _useContext = useContext(ConfigContext),
|
|
52
66
|
getPrefixCls = _useContext.getPrefixCls;
|
|
53
|
-
var _className = "".concat(getPrefixCls('form'), " ").concat(className, " ").concat(
|
|
54
|
-
var _layout =
|
|
55
|
-
var _useState = useState(getChildren(items, children, defaultItemProps)),
|
|
67
|
+
var _className = "".concat(getPrefixCls('form'), " ").concat(className, " ").concat(['inlineVertical', 'grid'].includes(layout) ? 'inlineVertical' : '');
|
|
68
|
+
var _layout = ['inlineVertical', 'grid'].includes(layout) ? 'inline' : layout;
|
|
69
|
+
var _useState = useState(getChildren(items, children, defaultItemProps, layout)),
|
|
56
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
57
71
|
itemChildren = _useState2[0],
|
|
58
72
|
setItemChildren = _useState2[1];
|
|
59
73
|
useEffect(function () {
|
|
60
|
-
setItemChildren(getChildren(items, children, defaultItemProps));
|
|
61
|
-
}, [items, children, defaultItemProps]);
|
|
74
|
+
setItemChildren(getChildren(items, children, defaultItemProps, layout));
|
|
75
|
+
}, [items, children, defaultItemProps, layout]);
|
|
62
76
|
useImperativeHandle(ref, function () {
|
|
63
77
|
return {
|
|
64
78
|
setItems: function setItems(value) {
|
|
65
79
|
if (value instanceof Array) {
|
|
66
|
-
setItemChildren(getChildren(value, null, defaultItemProps));
|
|
80
|
+
setItemChildren(getChildren(value, null, defaultItemProps, layout));
|
|
67
81
|
} else if (typeof value === 'function') {
|
|
68
82
|
var result = value(items || []);
|
|
69
83
|
if ('then' in result) {
|
|
70
84
|
result.then(function (list) {
|
|
71
|
-
setItemChildren(getChildren(list, null, defaultItemProps));
|
|
85
|
+
setItemChildren(getChildren(list, null, defaultItemProps, layout));
|
|
72
86
|
});
|
|
73
87
|
} else {
|
|
74
|
-
setItemChildren(getChildren(result, null, defaultItemProps));
|
|
88
|
+
setItemChildren(getChildren(result, null, defaultItemProps, layout));
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { LabelValueProps } from './interface';
|
|
2
|
+
import { LabelValueProps as ILabelValueProps } from './interface';
|
|
3
3
|
import './styles/index.less';
|
|
4
|
-
declare
|
|
4
|
+
export declare type LabelValueProps = ILabelValueProps;
|
|
5
|
+
declare function LabelValue({ label, value, emptyValue, className, noWrap, noColon }: ILabelValueProps): JSX.Element;
|
|
5
6
|
declare namespace LabelValue {
|
|
6
7
|
var defaultProps: {
|
|
7
8
|
className: string;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as LabelValue } from './LabelValue';
|
|
2
|
+
export type { LabelValueProps } from './LabelValue';
|
|
2
3
|
export { default as AdvancedFilter } from './AdvancedFilter';
|
|
3
4
|
export { default as AuthComponent } from './AuthComponent';
|
|
4
5
|
export type { FProps } from './AdvancedFilter/interface';
|