@yuntijs/ui 1.0.0-beta.31 → 1.0.0-beta.33
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/es/CollapseGroup/index.d.ts +4 -0
- package/es/CollapseGroup/index.js +23 -0
- package/es/CollapseGroup/style.d.ts +3 -0
- package/es/CollapseGroup/style.js +11 -0
- package/es/ConfigProvider/index.d.ts +1 -0
- package/es/Divider/index.js +6 -4
- package/es/DragPanel/index.d.ts +10 -0
- package/es/DragPanel/index.js +96 -0
- package/es/DragPanel/style.d.ts +7 -0
- package/es/DragPanel/style.js +15 -0
- package/es/Form/collapse-list/index.d.ts +38 -0
- package/es/Form/collapse-list/index.js +205 -0
- package/es/Form/collapse-list/style.d.ts +5 -0
- package/es/Form/collapse-list/style.js +13 -0
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +5 -0
- package/es/Mentions/constants.d.ts +6 -0
- package/es/Mentions/constants.js +28 -0
- package/es/Mentions/hooks.d.ts +20 -0
- package/es/Mentions/hooks.js +133 -0
- package/es/Mentions/index.d.ts +19 -0
- package/es/Mentions/index.js +120 -0
- package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
- package/es/Mentions/plugins/custom-text/node.js +72 -0
- package/es/Mentions/plugins/mention-node/component.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/component.js +72 -0
- package/es/Mentions/plugins/mention-node/index.d.ts +11 -0
- package/es/Mentions/plugins/mention-node/index.js +39 -0
- package/es/Mentions/plugins/mention-node/node.d.ts +26 -0
- package/es/Mentions/plugins/mention-node/node.js +110 -0
- package/es/Mentions/plugins/mention-node/replacement.d.ts +7 -0
- package/es/Mentions/plugins/mention-node/replacement.js +43 -0
- package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/style.js +49 -0
- package/es/Mentions/plugins/mention-node/utils.d.ts +5 -0
- package/es/Mentions/plugins/mention-node/utils.js +6 -0
- package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.js +38 -0
- package/es/Mentions/plugins/mention-picker/index.d.ts +36 -0
- package/es/Mentions/plugins/mention-picker/index.js +87 -0
- package/es/Mentions/plugins/mention-picker/menu-item.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/menu-item.js +70 -0
- package/es/Mentions/plugins/mention-picker/menu.d.ts +9 -0
- package/es/Mentions/plugins/mention-picker/menu.js +30 -0
- package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/style.js +19 -0
- package/es/Mentions/plugins/mention-picker/utils.d.ts +22 -0
- package/es/Mentions/plugins/mention-picker/utils.js +39 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +7 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.js +36 -0
- package/es/Mentions/style.d.ts +11 -0
- package/es/Mentions/style.js +20 -0
- package/es/Mentions/types.d.ts +17 -0
- package/es/Mentions/types.js +1 -0
- package/es/Mentions/utils.d.ts +9 -0
- package/es/Mentions/utils.js +95 -0
- package/es/Table/collapse/index.d.ts +8 -0
- package/es/Table/collapse/index.js +39 -0
- package/es/Table/collapse/style.d.ts +3 -0
- package/es/Table/collapse/style.js +11 -0
- package/es/Table/index.d.ts +3 -0
- package/es/Table/index.js +7 -5
- package/es/index.d.ts +6 -2
- package/es/index.js +6 -2
- package/package.json +10 -4
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FormGroupProps } from '@lobehub/ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type CollapseGroupProps = Omit<FormGroupProps, 'items' | 'activeKey' | 'defaultActiveKey' | 'accordion' | 'expandIconPosition'>;
|
|
4
|
+
export declare const CollapseGroup: React.FC<CollapseGroupProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["className", "variant"];
|
|
4
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { Form as LobeForm } from '@lobehub/ui';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useStyles } from "./style";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
var FormGroup = LobeForm.Group;
|
|
11
|
+
export var CollapseGroup = function CollapseGroup(_ref) {
|
|
12
|
+
var className = _ref.className,
|
|
13
|
+
variant = _ref.variant,
|
|
14
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
15
|
+
var _useStyles = useStyles(),
|
|
16
|
+
styles = _useStyles.styles,
|
|
17
|
+
cx = _useStyles.cx;
|
|
18
|
+
return /*#__PURE__*/_jsx(FormGroup, _objectSpread({
|
|
19
|
+
className: cx(styles.root, className),
|
|
20
|
+
collapsible: variant === 'pure' ? 'icon' : 'header',
|
|
21
|
+
variant: variant
|
|
22
|
+
}, otherProps));
|
|
23
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
prefixCls = _ref.prefixCls;
|
|
8
|
+
return {
|
|
9
|
+
root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin-bottom: ", "px;\n .", "-collapse {\n &-header {\n padding: 0 !important;\n &-text {\n padding: ", "px ", "px ", "px 0;\n & > * {\n font-size: ", "px;\n /* font-weight: unset; */\n }\n }\n }\n &-expand-icon {\n padding: ", "px 0 ", "px ", "px;\n }\n &-extra {\n padding-right: ", "px;\n }\n &-content {\n padding: ", "px 0;\n background-color: ", ";\n }\n }\n "])), token.margin, prefixCls, token.paddingSM, token.paddingSM, token.paddingSM, token.fontSize, token.padding, token.padding, token.paddingSM, token.paddingSM, token.paddingXS, token.colorBgContainer)
|
|
10
|
+
};
|
|
11
|
+
});
|
|
@@ -5,6 +5,7 @@ export interface Config {
|
|
|
5
5
|
customCdnFn?: CdnFn;
|
|
6
6
|
imgAs?: ElementType;
|
|
7
7
|
proxy?: CDN | 'custom';
|
|
8
|
+
prefixCls: string;
|
|
8
9
|
}
|
|
9
10
|
export declare const ConfigContext: import("react").Context<Config | null>;
|
|
10
11
|
export declare const ConfigProvider: import("react").NamedExoticComponent<{
|
package/es/Divider/index.js
CHANGED
|
@@ -12,10 +12,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
export var Divider = function Divider(props) {
|
|
15
|
-
var mode = props.mode,
|
|
15
|
+
var _props$mode = props.mode,
|
|
16
|
+
mode = _props$mode === void 0 ? 'line' : _props$mode,
|
|
16
17
|
content = props.content,
|
|
17
18
|
defaultOpen = props.defaultOpen,
|
|
18
|
-
iconPlacement = props.iconPlacement,
|
|
19
|
+
_props$iconPlacement = props.iconPlacement,
|
|
20
|
+
iconPlacement = _props$iconPlacement === void 0 ? 'left' : _props$iconPlacement,
|
|
19
21
|
openIcon = props.openIcon,
|
|
20
22
|
closeIcon = props.closeIcon,
|
|
21
23
|
type = props.type,
|
|
@@ -49,7 +51,7 @@ export var Divider = function Divider(props) {
|
|
|
49
51
|
children: /*#__PURE__*/_jsxs(Space, {
|
|
50
52
|
size: 6,
|
|
51
53
|
children: [iconPlacement !== 'right' && iconDom, /*#__PURE__*/_jsx("span", {
|
|
52
|
-
children:
|
|
54
|
+
children: content
|
|
53
55
|
}), iconPlacement === 'right' && iconDom]
|
|
54
56
|
})
|
|
55
57
|
})
|
|
@@ -57,7 +59,7 @@ export var Divider = function Divider(props) {
|
|
|
57
59
|
style: {
|
|
58
60
|
display: open ? 'block' : 'none'
|
|
59
61
|
},
|
|
60
|
-
children:
|
|
62
|
+
children: props.children
|
|
61
63
|
})]
|
|
62
64
|
});
|
|
63
65
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrawerProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ControlPosition } from 'react-draggable';
|
|
4
|
+
export interface DragPanelProps extends DrawerProps {
|
|
5
|
+
/** 面板默认位置 */
|
|
6
|
+
defaultPosition?: ControlPosition;
|
|
7
|
+
/** 面板位置改变的回调函数 */
|
|
8
|
+
onPositionChange?: (position: ControlPosition) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const DragPanel: React.FC<DragPanelProps>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["title", "classNames", "defaultPosition", "onPositionChange"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { DragOutlined } from '@ant-design/icons';
|
|
8
|
+
import { Button, Drawer, Flex } from 'antd';
|
|
9
|
+
import React, { memo, useRef, useState } from 'react';
|
|
10
|
+
// @Todo: use react-rnd instead, support resizing
|
|
11
|
+
import Draggable from 'react-draggable';
|
|
12
|
+
import { useStyles } from "./style";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
export var DragPanel = /*#__PURE__*/memo(function (_ref) {
|
|
16
|
+
var title = _ref.title,
|
|
17
|
+
_ref$classNames = _ref.classNames,
|
|
18
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
19
|
+
defaultPosition = _ref.defaultPosition,
|
|
20
|
+
onPositionChange = _ref.onPositionChange,
|
|
21
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var _useStyles = useStyles(),
|
|
23
|
+
styles = _useStyles.styles,
|
|
24
|
+
cx = _useStyles.cx;
|
|
25
|
+
var _useState = useState({
|
|
26
|
+
left: 0,
|
|
27
|
+
top: 0,
|
|
28
|
+
bottom: 0,
|
|
29
|
+
right: 0
|
|
30
|
+
}),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
bounds = _useState2[0],
|
|
33
|
+
setBounds = _useState2[1];
|
|
34
|
+
var draggleRef = useRef(null);
|
|
35
|
+
var _onStart = function onStart(_event, uiData) {
|
|
36
|
+
var _draggleRef$current;
|
|
37
|
+
var _window$document$docu = window.document.documentElement,
|
|
38
|
+
clientWidth = _window$document$docu.clientWidth,
|
|
39
|
+
clientHeight = _window$document$docu.clientHeight;
|
|
40
|
+
var targetRect = (_draggleRef$current = draggleRef.current) === null || _draggleRef$current === void 0 ? void 0 : _draggleRef$current.getBoundingClientRect();
|
|
41
|
+
if (!targetRect) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setBounds({
|
|
45
|
+
left: -targetRect.left + uiData.x,
|
|
46
|
+
right: clientWidth - (targetRect.right - uiData.x),
|
|
47
|
+
top: -targetRect.top + uiData.y,
|
|
48
|
+
bottom: clientHeight - (targetRect.bottom - uiData.y)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return /*#__PURE__*/_jsx(Drawer, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
52
|
+
classNames: _objectSpread(_objectSpread({}, classNames), {}, {
|
|
53
|
+
wrapper: cx(styles.wrapper, classNames.wrapper),
|
|
54
|
+
content: cx(styles.content, classNames.content)
|
|
55
|
+
}),
|
|
56
|
+
destroyOnClose: true,
|
|
57
|
+
drawerRender: function drawerRender(drawer) {
|
|
58
|
+
return /*#__PURE__*/_jsx(Draggable, {
|
|
59
|
+
bounds: bounds,
|
|
60
|
+
defaultPosition: defaultPosition,
|
|
61
|
+
handle: ".".concat(styles.dragHandle),
|
|
62
|
+
nodeRef: draggleRef,
|
|
63
|
+
onStart: function onStart(event, uiData) {
|
|
64
|
+
return _onStart(event, uiData);
|
|
65
|
+
},
|
|
66
|
+
onStop: function onStop(_e, data) {
|
|
67
|
+
onPositionChange === null || onPositionChange === void 0 || onPositionChange({
|
|
68
|
+
x: data.x,
|
|
69
|
+
y: data.y
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
73
|
+
className: styles.dragWrapper,
|
|
74
|
+
ref: draggleRef,
|
|
75
|
+
children: drawer
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
mask: false,
|
|
80
|
+
rootClassName: styles.root,
|
|
81
|
+
title: /*#__PURE__*/_jsxs(Flex, {
|
|
82
|
+
align: "center",
|
|
83
|
+
className: styles.dragHandle,
|
|
84
|
+
children: [/*#__PURE__*/_jsx(Flex, {
|
|
85
|
+
flex: 2,
|
|
86
|
+
children: title
|
|
87
|
+
}), /*#__PURE__*/_jsx(Flex, {
|
|
88
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
89
|
+
className: styles.dragHandle,
|
|
90
|
+
icon: /*#__PURE__*/_jsx(DragOutlined, {}),
|
|
91
|
+
type: "text"
|
|
92
|
+
})
|
|
93
|
+
})]
|
|
94
|
+
})
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
2
|
+
root: import("antd-style").SerializedStyles;
|
|
3
|
+
wrapper: import("antd-style").SerializedStyles;
|
|
4
|
+
content: import("antd-style").SerializedStyles;
|
|
5
|
+
dragWrapper: import("antd-style").SerializedStyles;
|
|
6
|
+
dragHandle: import("antd-style").SerializedStyles;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
prefixCls = _ref.prefixCls;
|
|
8
|
+
return {
|
|
9
|
+
root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n "]))),
|
|
10
|
+
wrapper: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 640px !important;\n margin: ", "px;\n box-shadow: none !important;\n "])), token.marginLG),
|
|
11
|
+
content: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: hidden;\n border-radius: ", "px;\n box-shadow: ", ";\n "])), token.borderRadiusLG, token.boxShadowSecondary),
|
|
12
|
+
dragWrapper: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n "]))),
|
|
13
|
+
dragHandle: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n cursor: move;\n "])))
|
|
14
|
+
};
|
|
15
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FormItemProps, FormListFieldData, TableColumnProps } from 'antd';
|
|
2
|
+
import { FormListProps as AntFormListProps } from 'antd/es/form';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { CollapseGroupProps } from '../../CollapseGroup';
|
|
5
|
+
export interface FormCollapseListColumnItem extends Omit<FormItemProps, 'dependencies' | 'rules' | 'tooltip' | 'labelAlign' | 'labelCol' | 'colon' | 'children'> {
|
|
6
|
+
render?: (field: FormListFieldData, index: number) => React.ReactElement;
|
|
7
|
+
rules?: FormItemProps['rules'] | ((field: FormListFieldData, index: number) => FormItemProps['rules']);
|
|
8
|
+
dependencies?: FormItemProps['dependencies'] | ((field: FormListFieldData, index: number) => FormItemProps['dependencies']);
|
|
9
|
+
}
|
|
10
|
+
export interface FormListOperationAddParams {
|
|
11
|
+
defaultValue?: any;
|
|
12
|
+
insertIndex?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface FormCollapseListColumn extends FormCollapseListColumnItem, Pick<TableColumnProps<any>, 'align' | 'ellipsis' | 'fixed' | 'responsive' | 'shouldCellUpdate' | 'width'> {
|
|
15
|
+
}
|
|
16
|
+
export interface FormCollapseListProps extends Omit<AntFormListProps, 'name' | 'children'>, Pick<CollapseGroupProps, 'className' | 'icon' | 'title' | 'variant' | 'defaultActive' | 'style'> {
|
|
17
|
+
/** 字段名 */
|
|
18
|
+
name?: FormItemProps['name'];
|
|
19
|
+
/** 表单列为空时展示的空内容 */
|
|
20
|
+
empty?: React.ReactNode;
|
|
21
|
+
/** 表单列配置 */
|
|
22
|
+
columns?: FormCollapseListColumn[];
|
|
23
|
+
/** 新增表单项的参数 */
|
|
24
|
+
addParams?: FormListOperationAddParams | (() => FormListOperationAddParams);
|
|
25
|
+
/** 是否禁用 */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** 只读模式 */
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
/** 默认添加一个 field */
|
|
30
|
+
addOneFieldDefault?: boolean;
|
|
31
|
+
/** 当只有一个 field 时禁用移除 */
|
|
32
|
+
disableRemoveWhenOneField?: boolean;
|
|
33
|
+
/** 限制最大 fields 数量 */
|
|
34
|
+
maxFileds?: number;
|
|
35
|
+
/** 删除时调用,返回 false 时取消删除 */
|
|
36
|
+
onRemove?: (values: any) => boolean | void | Promise<boolean | void>;
|
|
37
|
+
}
|
|
38
|
+
export declare const FormCollapseList: React.FC<FormCollapseListProps>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["icon", "title", "variant", "defaultActive", "empty", "columns", "disabled", "readOnly", "addOneFieldDefault", "disableRemoveWhenOneField", "maxFileds", "name", "addParams", "className", "onRemove", "style"],
|
|
6
|
+
_excluded2 = ["label", "name", "render", "dependencies", "rules", "align", "ellipsis", "fixed", "responsive", "shouldCellUpdate", "width"],
|
|
7
|
+
_excluded3 = ["key", "name"];
|
|
8
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
12
|
+
import { Icon } from '@lobehub/ui';
|
|
13
|
+
import { Button, Flex, Form, Table, Tooltip } from 'antd';
|
|
14
|
+
import { Trash2 } from 'lucide-react';
|
|
15
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
16
|
+
import { CollapseGroup } from "../../CollapseGroup";
|
|
17
|
+
import { useStyles } from "./style";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
export var FormCollapseList = function FormCollapseList(_ref) {
|
|
20
|
+
var icon = _ref.icon,
|
|
21
|
+
title = _ref.title,
|
|
22
|
+
variant = _ref.variant,
|
|
23
|
+
defaultActive = _ref.defaultActive,
|
|
24
|
+
_ref$empty = _ref.empty,
|
|
25
|
+
empty = _ref$empty === void 0 ? '点击右上角 + 添加 ' : _ref$empty,
|
|
26
|
+
_ref$columns = _ref.columns,
|
|
27
|
+
columns = _ref$columns === void 0 ? [] : _ref$columns,
|
|
28
|
+
disabled = _ref.disabled,
|
|
29
|
+
readOnly = _ref.readOnly,
|
|
30
|
+
addOneFieldDefault = _ref.addOneFieldDefault,
|
|
31
|
+
disableRemoveWhenOneField = _ref.disableRemoveWhenOneField,
|
|
32
|
+
maxFileds = _ref.maxFileds,
|
|
33
|
+
name = _ref.name,
|
|
34
|
+
addParams = _ref.addParams,
|
|
35
|
+
className = _ref.className,
|
|
36
|
+
onRemove = _ref.onRemove,
|
|
37
|
+
style = _ref.style,
|
|
38
|
+
formListProps = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _useStyles = useStyles(),
|
|
40
|
+
styles = _useStyles.styles;
|
|
41
|
+
var listAdd = useRef();
|
|
42
|
+
var form = Form.useFormInstance();
|
|
43
|
+
var fieldsWatch = Form.useWatch(name, form);
|
|
44
|
+
var getAddParams = useCallback(function () {
|
|
45
|
+
if (!addParams) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
var params = typeof addParams === 'function' ? addParams() : addParams;
|
|
49
|
+
return [params.defaultValue, params.insertIndex];
|
|
50
|
+
}, [addParams]);
|
|
51
|
+
var handleOnRemove = useCallback(function (fieldName) {
|
|
52
|
+
var values = form.getFieldValue([name, fieldName]);
|
|
53
|
+
return onRemove === null || onRemove === void 0 ? void 0 : onRemove(values);
|
|
54
|
+
}, [form, name, onRemove]);
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
var _form$getFieldValue;
|
|
57
|
+
if (addOneFieldDefault && (!(form !== null && form !== void 0 && form.getFieldValue(name)) || (form === null || form === void 0 || (_form$getFieldValue = form.getFieldValue(name)) === null || _form$getFieldValue === void 0 ? void 0 : _form$getFieldValue.length) === 0)) {
|
|
58
|
+
var _listAdd$current;
|
|
59
|
+
(_listAdd$current = listAdd.current) === null || _listAdd$current === void 0 || _listAdd$current.call.apply(_listAdd$current, [listAdd].concat(_toConsumableArray(getAddParams())));
|
|
60
|
+
}
|
|
61
|
+
}, [addOneFieldDefault, getAddParams, form, name]);
|
|
62
|
+
return /*#__PURE__*/_jsx(CollapseGroup, {
|
|
63
|
+
extra: name && !readOnly && /*#__PURE__*/_jsx(Tooltip, {
|
|
64
|
+
title: maxFileds && "\u6700\u591A\u6DFB\u52A0 ".concat(maxFileds, " \u9879"),
|
|
65
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
66
|
+
disabled: disabled || !!(maxFileds && (fieldsWatch === null || fieldsWatch === void 0 ? void 0 : fieldsWatch.length) === maxFileds),
|
|
67
|
+
icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
|
|
68
|
+
onClick: function onClick(e) {
|
|
69
|
+
var _listAdd$current2;
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
(_listAdd$current2 = listAdd.current) === null || _listAdd$current2 === void 0 || _listAdd$current2.call.apply(_listAdd$current2, [listAdd].concat(_toConsumableArray(getAddParams())));
|
|
72
|
+
},
|
|
73
|
+
size: "small",
|
|
74
|
+
type: "text"
|
|
75
|
+
})
|
|
76
|
+
}),
|
|
77
|
+
className: className,
|
|
78
|
+
icon: icon,
|
|
79
|
+
title: title,
|
|
80
|
+
variant: variant,
|
|
81
|
+
defaultActive: defaultActive,
|
|
82
|
+
style: style,
|
|
83
|
+
children: name ? /*#__PURE__*/_jsx(Form.List, _objectSpread(_objectSpread({
|
|
84
|
+
name: name
|
|
85
|
+
}, formListProps), {}, {
|
|
86
|
+
children: function children(fields, _ref2) {
|
|
87
|
+
var add = _ref2.add,
|
|
88
|
+
remove = _ref2.remove;
|
|
89
|
+
listAdd.current = add;
|
|
90
|
+
|
|
91
|
+
// @Todo: support sort
|
|
92
|
+
return /*#__PURE__*/_jsx(Table, {
|
|
93
|
+
className: styles.list,
|
|
94
|
+
columns: [].concat(_toConsumableArray(columns.map(function (_ref3) {
|
|
95
|
+
var label = _ref3.label,
|
|
96
|
+
itemName = _ref3.name,
|
|
97
|
+
fieldRender = _ref3.render,
|
|
98
|
+
dependencies = _ref3.dependencies,
|
|
99
|
+
rules = _ref3.rules,
|
|
100
|
+
align = _ref3.align,
|
|
101
|
+
ellipsis = _ref3.ellipsis,
|
|
102
|
+
fixed = _ref3.fixed,
|
|
103
|
+
responsive = _ref3.responsive,
|
|
104
|
+
shouldCellUpdate = _ref3.shouldCellUpdate,
|
|
105
|
+
width = _ref3.width,
|
|
106
|
+
itemProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
107
|
+
return {
|
|
108
|
+
title: label,
|
|
109
|
+
dataIndex: itemName,
|
|
110
|
+
align: align,
|
|
111
|
+
ellipsis: ellipsis,
|
|
112
|
+
fixed: fixed,
|
|
113
|
+
responsive: responsive,
|
|
114
|
+
shouldCellUpdate: shouldCellUpdate,
|
|
115
|
+
width: width,
|
|
116
|
+
render: function render(_text, _record, index) {
|
|
117
|
+
var _fields$index = fields[index],
|
|
118
|
+
key = _fields$index.key,
|
|
119
|
+
name = _fields$index.name,
|
|
120
|
+
restField = _objectWithoutProperties(_fields$index, _excluded3);
|
|
121
|
+
var children = fieldRender === null || fieldRender === void 0 ? void 0 : fieldRender(fields[index], index);
|
|
122
|
+
if (!children && !itemProps.noStyle) {
|
|
123
|
+
return /*#__PURE__*/_jsx(Flex, {
|
|
124
|
+
align: "center",
|
|
125
|
+
className: styles.noFormItem,
|
|
126
|
+
children: "\u65E0\u9700\u8BBE\u7F6E"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (!itemName) {
|
|
130
|
+
return /*#__PURE__*/_jsx(Flex, {
|
|
131
|
+
align: "center",
|
|
132
|
+
className: styles.noFormItem,
|
|
133
|
+
children: children
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
var chidrenProps = {
|
|
137
|
+
readOnly: readOnly,
|
|
138
|
+
disabled: disabled
|
|
139
|
+
};
|
|
140
|
+
if (readOnly === true) {
|
|
141
|
+
chidrenProps.showCount = false;
|
|
142
|
+
chidrenProps.variant = 'borderless';
|
|
143
|
+
chidrenProps.placeholder = '-';
|
|
144
|
+
}
|
|
145
|
+
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread(_objectSpread({}, restField), {}, {
|
|
146
|
+
dependencies: typeof dependencies === 'function' ? dependencies(fields[index], index) : dependencies,
|
|
147
|
+
name: [name, itemName],
|
|
148
|
+
rules: typeof rules === 'function' ? rules(fields[index], index) : rules
|
|
149
|
+
}, itemProps), {}, {
|
|
150
|
+
children: children && /*#__PURE__*/React.cloneElement(children, chidrenProps)
|
|
151
|
+
}), key);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
})), [{
|
|
155
|
+
title: '',
|
|
156
|
+
dataIndex: 'del',
|
|
157
|
+
render: function render(_text, _record, index) {
|
|
158
|
+
if (readOnly) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
var fieldName = fields[index].name;
|
|
162
|
+
return /*#__PURE__*/_jsx(Form.Item, {
|
|
163
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
164
|
+
disabled: disabled || disableRemoveWhenOneField && fields.length === 1,
|
|
165
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
166
|
+
icon: Trash2
|
|
167
|
+
}),
|
|
168
|
+
onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
169
|
+
var isRemove;
|
|
170
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
171
|
+
while (1) switch (_context.prev = _context.next) {
|
|
172
|
+
case 0:
|
|
173
|
+
_context.next = 2;
|
|
174
|
+
return handleOnRemove(fieldName);
|
|
175
|
+
case 2:
|
|
176
|
+
isRemove = _context.sent;
|
|
177
|
+
if (isRemove !== false) {
|
|
178
|
+
remove(fieldName);
|
|
179
|
+
}
|
|
180
|
+
case 4:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context.stop();
|
|
183
|
+
}
|
|
184
|
+
}, _callee);
|
|
185
|
+
})),
|
|
186
|
+
type: "text"
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}]),
|
|
191
|
+
dataSource: fields,
|
|
192
|
+
locale: {
|
|
193
|
+
emptyText: empty
|
|
194
|
+
},
|
|
195
|
+
pagination: false,
|
|
196
|
+
rowHoverable: false,
|
|
197
|
+
size: "small"
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
})) : /*#__PURE__*/_jsx("div", {
|
|
201
|
+
className: styles.empty,
|
|
202
|
+
children: empty
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token,
|
|
7
|
+
prefixCls = _ref.prefixCls;
|
|
8
|
+
return {
|
|
9
|
+
empty: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: ", "px ", "px;\n color: ", ";\n "])), token.paddingXS, token.paddingSM, token.colorTextTertiary),
|
|
10
|
+
list: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", "-table {\n &-thead {\n & > tr > th {\n font-weight: normal;\n color: ", ";\n background-color: unset;\n &::before {\n display: none;\n }\n }\n }\n &-tbody {\n & > tr:last-child {\n & > td {\n border-bottom-color: transparent;\n }\n }\n }\n &-cell {\n vertical-align: top;\n }\n }\n .", "-form {\n &-item {\n margin-bottom: 0;\n }\n }\n "])), prefixCls, token.colorTextTertiary, prefixCls),
|
|
11
|
+
noFormItem: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n height: ", "px;\n color: ", ";\n "])), token.controlHeight, token.colorTextTertiary)
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Form as AntForm } from 'antd';
|
|
2
|
+
import { FormCollapseList } from './collapse-list';
|
|
3
|
+
export * from './collapse-list';
|
|
4
|
+
export type { FormInstance, FormItemProps, FormListFieldData, FormListOperation, FormProps, FormRule, } from 'antd';
|
|
5
|
+
export type FormType = typeof AntForm & {
|
|
6
|
+
CollapseList: typeof FormCollapseList;
|
|
7
|
+
};
|
|
8
|
+
export declare const Form: FormType;
|
package/es/Form/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_PUNCTUATION = "\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%'\"~=<>_:;";
|
|
2
|
+
export declare const PRE_TRIGGER_CHARS = "\\(";
|
|
3
|
+
export declare const TRIGGERS: (triggers: string[]) => string;
|
|
4
|
+
export declare const VALID_CHARS: (triggers: string[], punctuation: string) => string;
|
|
5
|
+
export declare const VALID_JOINS: (punctuation: string) => string;
|
|
6
|
+
export declare const LENGTH_LIMIT = 75;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var DEFAULT_PUNCTUATION = '\\.,\\*\\?\\$\\|#{}\\(\\)\\^\\[\\]\\\\/!%\'"~=<>_:;';
|
|
2
|
+
|
|
3
|
+
// Makes it possible to use brackets before the trigger: (@mention)
|
|
4
|
+
export var PRE_TRIGGER_CHARS = '\\(';
|
|
5
|
+
|
|
6
|
+
// Strings that can trigger the mention menu.
|
|
7
|
+
export var TRIGGERS = function TRIGGERS(triggers) {
|
|
8
|
+
return '(?:' + triggers.join('|') + ')';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
12
|
+
export var VALID_CHARS = function VALID_CHARS(triggers, punctuation) {
|
|
13
|
+
var lookahead = triggers.length === 0 ? '' : '(?!' + triggers.join('|') + ')';
|
|
14
|
+
return lookahead + '[^\\s' + punctuation + ']';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Non-standard series of chars. Each series must be preceded and followed by
|
|
18
|
+
// a valid char.
|
|
19
|
+
export var VALID_JOINS = function VALID_JOINS(punctuation) {
|
|
20
|
+
return '(?:' + '\\.[ |$]|' +
|
|
21
|
+
// E.g. "r. " in "Mr. Smith"
|
|
22
|
+
'\\s|' +
|
|
23
|
+
// E.g. " " in "Josh Duck"
|
|
24
|
+
'[' + punctuation + ']|' +
|
|
25
|
+
// E.g. "-' in "Salier-Hellendag"
|
|
26
|
+
')';
|
|
27
|
+
};
|
|
28
|
+
export var LENGTH_LIMIT = 75;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MenuTextMatch } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
2
|
+
import type { LexicalCommand } from 'lexical';
|
|
3
|
+
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
|
4
|
+
export type UseSelectOrDeleteHanlder = (nodeKey: string, command: LexicalCommand<undefined>) => [RefObject<HTMLDivElement>, boolean];
|
|
5
|
+
export declare const useSelectOrDelete: UseSelectOrDeleteHanlder;
|
|
6
|
+
export type UseTriggerHandler = () => [
|
|
7
|
+
RefObject<HTMLDivElement>,
|
|
8
|
+
boolean,
|
|
9
|
+
Dispatch<SetStateAction<boolean>>
|
|
10
|
+
];
|
|
11
|
+
export declare const useTrigger: UseTriggerHandler;
|
|
12
|
+
export declare function checkForMentions(text: string, triggers: string[], preTriggerChars: string, punctuation: string, allowSpaces: boolean): MenuTextMatch | null;
|
|
13
|
+
export declare const useCheckForMentionMatch: (triggers: string[], { punctuation, preTriggerChars, allowSpaces, }: {
|
|
14
|
+
punctuation: string;
|
|
15
|
+
preTriggerChars: string;
|
|
16
|
+
allowSpaces: boolean;
|
|
17
|
+
}) => {
|
|
18
|
+
trigger: string | null;
|
|
19
|
+
checkForMentionMatch: (text: string) => MenuTextMatch | null;
|
|
20
|
+
};
|