@tiny-codes/react-easy 1.1.3 → 1.2.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/CHANGELOG.md +33 -0
- package/es/components/ConfirmAction/index.d.ts +97 -28
- package/es/components/ConfirmAction/index.js +47 -28
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/ConfirmAction/withConfirmAction.d.ts +48 -0
- package/es/components/ConfirmAction/withConfirmAction.js +131 -0
- package/es/components/ConfirmAction/withConfirmAction.js.map +1 -0
- package/es/components/ContextMenu/index.d.ts +42 -0
- package/es/components/ContextMenu/index.js +188 -0
- package/es/components/ContextMenu/index.js.map +1 -0
- package/es/components/ContextMenu/style/index.d.ts +3 -0
- package/es/components/ContextMenu/style/index.js +25 -0
- package/es/components/ContextMenu/style/index.js.map +1 -0
- package/es/components/DeleteConfirmAction/index.d.ts +1 -1
- package/es/components/DeleteConfirmAction/index.js +9 -3
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
- package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js +20 -0
- package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +1 -0
- package/es/components/EditableText/form.d.ts +12 -6
- package/es/components/EditableText/form.js +106 -56
- package/es/components/EditableText/form.js.map +1 -1
- package/es/components/EditableText/index.d.ts +31 -9
- package/es/components/EditableText/index.js +13 -7
- package/es/components/EditableText/index.js.map +1 -1
- package/es/components/Loading/index.d.ts +2 -2
- package/es/components/Loading/index.js +5 -5
- package/es/components/Loading/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +35 -29
- package/es/components/ModalAction/index.js +16 -9
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.d.ts +5 -1
- package/es/components/index.js +3 -0
- package/es/components/index.js.map +1 -1
- package/lib/components/ConfirmAction/index.d.ts +97 -28
- package/lib/components/ConfirmAction/index.js +57 -32
- package/lib/components/ConfirmAction/index.js.map +2 -2
- package/lib/components/ConfirmAction/withConfirmAction.d.ts +48 -0
- package/lib/components/ConfirmAction/withConfirmAction.js +123 -0
- package/lib/components/ConfirmAction/withConfirmAction.js.map +7 -0
- package/lib/components/ContextMenu/index.d.ts +42 -0
- package/lib/components/ContextMenu/index.js +190 -0
- package/lib/components/ContextMenu/index.js.map +7 -0
- package/lib/components/ContextMenu/style/index.d.ts +3 -0
- package/lib/components/ContextMenu/style/index.js +48 -0
- package/lib/components/ContextMenu/style/index.js.map +7 -0
- package/lib/components/DeleteConfirmAction/index.d.ts +1 -1
- package/lib/components/DeleteConfirmAction/index.js +28 -16
- package/lib/components/DeleteConfirmAction/index.js.map +2 -2
- package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
- package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js +38 -0
- package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +7 -0
- package/lib/components/EditableText/form.d.ts +12 -6
- package/lib/components/EditableText/form.js +69 -39
- package/lib/components/EditableText/form.js.map +2 -2
- package/lib/components/EditableText/index.d.ts +31 -9
- package/lib/components/EditableText/index.js +12 -5
- package/lib/components/EditableText/index.js.map +2 -2
- package/lib/components/Loading/index.d.ts +2 -2
- package/lib/components/Loading/index.js +4 -4
- package/lib/components/Loading/index.js.map +2 -2
- package/lib/components/ModalAction/index.d.ts +35 -29
- package/lib/components/ModalAction/index.js +22 -17
- package/lib/components/ModalAction/index.js.map +2 -2
- package/lib/components/index.d.ts +5 -1
- package/lib/components/index.js +9 -0
- package/lib/components/index.js.map +2 -2
- package/package.json +3 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { CSSProperties } from 'react';
|
|
1
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
2
2
|
import type { ButtonProps, FormItemProps, FormProps, InputProps, SpaceProps } from 'antd';
|
|
3
3
|
import type { TextAreaProps } from 'antd/es/input';
|
|
4
|
-
export interface EditableFormProps<IT extends 'Input' | 'TextArea'> {
|
|
4
|
+
export interface EditableFormProps<V, IT extends 'Input' | 'TextArea' | RenderInputInterface> {
|
|
5
5
|
prefixCls?: string;
|
|
6
6
|
/**
|
|
7
7
|
* - **EN:** The value to edit
|
|
8
8
|
* - **CN:** 编辑的值
|
|
9
9
|
*/
|
|
10
|
-
value:
|
|
10
|
+
value: V | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* - **EN:** Whether the text is required when editing, default is `true`, if `formItemProps.rules`
|
|
13
13
|
* is set, it will override this value
|
|
@@ -37,7 +37,7 @@ export interface EditableFormProps<IT extends 'Input' | 'TextArea'> {
|
|
|
37
37
|
* - **EN:** Input component properties
|
|
38
38
|
* - **CN:** 输入框组件属性
|
|
39
39
|
*/
|
|
40
|
-
inputProps?: IT extends 'TextArea' ? TextAreaProps : InputProps;
|
|
40
|
+
inputProps?: IT extends 'TextArea' ? TextAreaProps : IT extends 'Input' ? InputProps : never;
|
|
41
41
|
/**
|
|
42
42
|
* - **EN:** Whether to display as a block-level element, with width 100%
|
|
43
43
|
* - **CN:** 是否显示为块级元素,宽度100%
|
|
@@ -133,12 +133,18 @@ export interface EditableFormProps<IT extends 'Input' | 'TextArea'> {
|
|
|
133
133
|
* - **EN:** Confirm button click event, supports asynchronous operations
|
|
134
134
|
* - **CN:** 确认按钮点击事件,支持异步操作
|
|
135
135
|
*/
|
|
136
|
-
onOk: (value:
|
|
136
|
+
onOk: (value: V | undefined) => void | Promise<void>;
|
|
137
137
|
/**
|
|
138
138
|
* - **EN:** Cancel button click event, supports asynchronous operations
|
|
139
139
|
* - **CN:** 取消按钮点击事件,支持异步操作
|
|
140
140
|
*/
|
|
141
141
|
onCancel?: () => void | Promise<void>;
|
|
142
142
|
}
|
|
143
|
-
declare const EditableTextForm: <IT extends "Input" | "TextArea">(
|
|
143
|
+
declare const EditableTextForm: <V, IT extends "Input" | RenderInputInterface | "TextArea">(props: EditableFormProps<V, IT>) => import("react/jsx-runtime").JSX.Element;
|
|
144
|
+
export type RenderInputInterface = <V>(props: RenderInputProps<V>) => ReactElement | null;
|
|
145
|
+
export interface RenderInputProps<V> extends Omit<EditableFormProps<V, 'Input'>, 'inputComp' | 'inputProps' | 'onOk' | 'onCancel'> {
|
|
146
|
+
onChange?: (value: V | undefined) => void;
|
|
147
|
+
submit(): Promise<void>;
|
|
148
|
+
cancel(): Promise<void>;
|
|
149
|
+
}
|
|
144
150
|
export default EditableTextForm;
|
|
@@ -38,29 +38,31 @@ var import_classnames = __toESM(require("classnames"));
|
|
|
38
38
|
var import_icons = require("@ant-design/icons");
|
|
39
39
|
var import_useT = __toESM(require("../../hooks/useT"));
|
|
40
40
|
var defaultInputActionGap = 8;
|
|
41
|
-
var EditableTextForm = ({
|
|
42
|
-
prefixCls,
|
|
43
|
-
value,
|
|
44
|
-
required = true,
|
|
45
|
-
classNames,
|
|
46
|
-
styles: styleNames,
|
|
47
|
-
inputComp = "Input",
|
|
48
|
-
block: blockInProps = false,
|
|
49
|
-
formProps,
|
|
50
|
-
formItemProps,
|
|
51
|
-
inputProps,
|
|
52
|
-
actionAlign = "center",
|
|
53
|
-
submitProps,
|
|
54
|
-
cancelProps,
|
|
55
|
-
onOk,
|
|
56
|
-
onCancel
|
|
57
|
-
}) => {
|
|
41
|
+
var EditableTextForm = (props) => {
|
|
58
42
|
var _a, _b;
|
|
43
|
+
const {
|
|
44
|
+
prefixCls,
|
|
45
|
+
value,
|
|
46
|
+
required = true,
|
|
47
|
+
classNames,
|
|
48
|
+
styles: styleNames,
|
|
49
|
+
inputComp = "Input",
|
|
50
|
+
block: blockInProps = false,
|
|
51
|
+
formProps,
|
|
52
|
+
formItemProps,
|
|
53
|
+
inputProps,
|
|
54
|
+
actionAlign = "center",
|
|
55
|
+
submitProps,
|
|
56
|
+
cancelProps,
|
|
57
|
+
onOk,
|
|
58
|
+
onCancel
|
|
59
|
+
} = props;
|
|
59
60
|
const t = (0, import_useT.default)();
|
|
60
61
|
const { getPrefixCls: getAntPrefixCls } = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
|
|
61
62
|
const [form] = import_antd.Form.useForm();
|
|
62
63
|
const wrapperRef = (0, import_react.useRef)(null);
|
|
63
64
|
const inputRef = (0, import_react.useRef)(null);
|
|
65
|
+
const supportAutoScale = inputComp === "Input" || inputComp === "TextArea";
|
|
64
66
|
const detectorRef = (0, import_react.useRef)(null);
|
|
65
67
|
const actionRef = (0, import_react.useRef)(null);
|
|
66
68
|
const [inputWidth, setInputWidth] = (0, import_react.useState)();
|
|
@@ -70,15 +72,15 @@ var EditableTextForm = ({
|
|
|
70
72
|
const inputActionGapRef = (0, import_react.useRef)(0);
|
|
71
73
|
inputActionGapRef.current = pxToNumber(((_a = formItemProps == null ? void 0 : formItemProps.style) == null ? void 0 : _a.marginRight) ?? ((_b = formItemProps == null ? void 0 : formItemProps.style) == null ? void 0 : _b.marginInlineEnd)) || defaultInputActionGap;
|
|
72
74
|
const block = blockInProps || forceBlock;
|
|
73
|
-
const InputComp = inputComp === "TextArea" ? import_antd.Input.TextArea : import_antd.Input;
|
|
74
75
|
(0, import_react.useEffect)(() => {
|
|
75
76
|
form.setFieldsValue({ value });
|
|
76
77
|
}, [form, value]);
|
|
77
78
|
(0, import_react.useEffect)(() => {
|
|
78
79
|
var _a2, _b2;
|
|
79
80
|
let contentWidth = 0;
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const inputElement = (_a2 = inputRef.current) == null ? void 0 : _a2.input;
|
|
82
|
+
if (detectorRef.current && inputElement && supportAutoScale) {
|
|
83
|
+
const inputStyle = getComputedStyle(inputElement);
|
|
82
84
|
contentWidth = detectorRef.current.offsetWidth + pxToNumber(inputStyle.paddingLeft) + pxToNumber(inputStyle.paddingRight) + pxToNumber(inputStyle.borderLeftWidth) + pxToNumber(inputStyle.borderRightWidth);
|
|
83
85
|
setInputWidth(contentWidth);
|
|
84
86
|
}
|
|
@@ -97,7 +99,7 @@ var EditableTextForm = ({
|
|
|
97
99
|
observer.observe(wrapperRef.current);
|
|
98
100
|
}
|
|
99
101
|
return () => observer.disconnect();
|
|
100
|
-
}, []);
|
|
102
|
+
}, [supportAutoScale]);
|
|
101
103
|
const handleCancel = async () => {
|
|
102
104
|
form.resetFields();
|
|
103
105
|
try {
|
|
@@ -108,7 +110,7 @@ var EditableTextForm = ({
|
|
|
108
110
|
};
|
|
109
111
|
const handleEscape = async (e) => {
|
|
110
112
|
var _a2;
|
|
111
|
-
if (e.key === "Escape") {
|
|
113
|
+
if ((inputComp === "Input" || inputComp === "TextArea") && e.key === "Escape") {
|
|
112
114
|
await handleCancel();
|
|
113
115
|
(_a2 = cancelProps == null ? void 0 : cancelProps.onClick) == null ? void 0 : _a2.call(cancelProps, e);
|
|
114
116
|
}
|
|
@@ -124,6 +126,43 @@ var EditableTextForm = ({
|
|
|
124
126
|
setSaving(false);
|
|
125
127
|
}
|
|
126
128
|
};
|
|
129
|
+
const renderInput = () => {
|
|
130
|
+
if (inputComp === "Input" || inputComp === "TextArea") {
|
|
131
|
+
const COMP = inputComp === "Input" ? import_antd.Input : import_antd.Input.TextArea;
|
|
132
|
+
return /* @__PURE__ */ React.createElement(
|
|
133
|
+
COMP,
|
|
134
|
+
{
|
|
135
|
+
ref: inputRef,
|
|
136
|
+
placeholder: t("components.EditableText.placeholder"),
|
|
137
|
+
...inputProps,
|
|
138
|
+
style: {
|
|
139
|
+
width: block ? void 0 : inputWidth,
|
|
140
|
+
// Width is 100% in block mode, no need to set width
|
|
141
|
+
...inputProps && "style" in inputProps ? inputProps == null ? void 0 : inputProps.style : {}
|
|
142
|
+
},
|
|
143
|
+
onPressEnter: () => {
|
|
144
|
+
if (inputComp === "Input") {
|
|
145
|
+
form.submit();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
onKeyUp: handleEscape
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
} else {
|
|
152
|
+
return /* @__PURE__ */ React.createElement(
|
|
153
|
+
CustomInput,
|
|
154
|
+
{
|
|
155
|
+
...props,
|
|
156
|
+
render: inputComp,
|
|
157
|
+
submit: async () => {
|
|
158
|
+
const values = await form.validateFields();
|
|
159
|
+
await handleSubmit(values);
|
|
160
|
+
},
|
|
161
|
+
cancel: handleCancel
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
127
166
|
return /* @__PURE__ */ React.createElement("div", { ref: wrapperRef, className: (0, import_classnames.default)(`${prefixCls}-form`, classNames == null ? void 0 : classNames.wrapper), style: styleNames == null ? void 0 : styleNames.wrapper }, /* @__PURE__ */ React.createElement(
|
|
128
167
|
import_antd.Form,
|
|
129
168
|
{
|
|
@@ -151,23 +190,9 @@ var EditableTextForm = ({
|
|
|
151
190
|
},
|
|
152
191
|
name: "value"
|
|
153
192
|
},
|
|
154
|
-
|
|
155
|
-
InputComp,
|
|
156
|
-
{
|
|
157
|
-
ref: inputRef,
|
|
158
|
-
placeholder: t("components.EditableText.placeholder"),
|
|
159
|
-
...inputProps,
|
|
160
|
-
style: {
|
|
161
|
-
width: block ? void 0 : inputWidth,
|
|
162
|
-
// Width is 100% in block mode, no need to set width
|
|
163
|
-
...inputProps == null ? void 0 : inputProps.style
|
|
164
|
-
},
|
|
165
|
-
onPressEnter: () => form.submit(),
|
|
166
|
-
onKeyUp: handleEscape
|
|
167
|
-
}
|
|
168
|
-
)
|
|
193
|
+
renderInput()
|
|
169
194
|
),
|
|
170
|
-
/* @__PURE__ */ React.createElement(
|
|
195
|
+
supportAutoScale && /* @__PURE__ */ React.createElement(
|
|
171
196
|
"span",
|
|
172
197
|
{
|
|
173
198
|
ref: detectorRef,
|
|
@@ -178,7 +203,7 @@ var EditableTextForm = ({
|
|
|
178
203
|
whiteSpace: "pre"
|
|
179
204
|
}
|
|
180
205
|
},
|
|
181
|
-
value
|
|
206
|
+
value == null ? void 0 : value.toString()
|
|
182
207
|
),
|
|
183
208
|
/* @__PURE__ */ React.createElement(import_antd.Space, { ref: actionRef, className: `${prefixCls}-form-btns`, align: actionAlign, size: 4 }, /* @__PURE__ */ React.createElement(
|
|
184
209
|
import_antd.Button,
|
|
@@ -216,6 +241,11 @@ var EditableTextForm = ({
|
|
|
216
241
|
))
|
|
217
242
|
));
|
|
218
243
|
};
|
|
244
|
+
function CustomInput(props) {
|
|
245
|
+
const { render, value, onChange, ...restProps } = props;
|
|
246
|
+
const useInput = render;
|
|
247
|
+
return useInput({ ...restProps, value, onChange });
|
|
248
|
+
}
|
|
219
249
|
function pxToNumber(px) {
|
|
220
250
|
return px ? parseFloat(px.toString().replace("px", "")) : 0;
|
|
221
251
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/EditableText/form.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { CSSProperties } from 'react';\nimport type React from 'react';\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport type { ButtonProps, FormItemProps, FormProps, InputProps, SpaceProps } from 'antd';\nimport { Button, ConfigProvider, Form, Input, Space } from 'antd';\nimport type { InputRef, TextAreaProps } from 'antd/es/input';\nimport names from 'classnames';\nimport { CheckSquareFilled, CloseSquareFilled } from '@ant-design/icons';\nimport useT from '../../hooks/useT';\n\nconst defaultInputActionGap = 8;\nexport interface EditableFormProps<IT extends 'Input' | 'TextArea'> {\n prefixCls?: string;\n /**\n * - **EN:** The value to edit\n * - **CN:** 编辑的值\n */\n value: string | undefined;\n /**\n * - **EN:** Whether the text is required when editing, default is `true`, if `formItemProps.rules`\n * is set, it will override this value\n * - **CN:** 编辑文本时是否必填,默认值为`true`,如果设置了`formItemProps.rules`,将会覆盖此值\n *\n * @default true\n */\n required?: boolean;\n /**\n * - **EN:** Form properties\n * - **CN:** 表单属性\n */\n formProps?: FormProps;\n /**\n * - **EN:** Form item properties\n * - **CN:** 表单项属性\n */\n formItemProps?: FormItemProps;\n /**\n * - **EN:** Custom component type for rendering the input box\n * - **CN:** 自定义设置渲染输入框的组件类型\n *\n * @default 'Input'\n */\n inputComp?: IT;\n /**\n * - **EN:** Input component properties\n * - **CN:** 输入框组件属性\n */\n inputProps?: IT extends 'TextArea' ? TextAreaProps : InputProps;\n /**\n * - **EN:** Whether to display as a block-level element, with width 100%\n * - **CN:** 是否显示为块级元素,宽度100%\n *\n * @default false\n */\n block?: boolean;\n /**\n * - **EN:** Semantic class names\n * - **CN:** 语义化类名\n */\n classNames?: {\n /**\n * - **EN:** Edit mode parent container class name\n * - **CN:** 编辑模式父容器类名\n */\n wrapper?: string;\n /**\n * - **EN:** Submit button class name\n * - **CN:** 提交按钮类名\n */\n submitButton?: string;\n /**\n * - **EN:** Cancel button class name\n * - **CN:** 取消按钮类名\n */\n cancelButton?: string;\n /**\n * - **EN:** Submit button icon class name\n * - **CN:** 提交按钮图标类名\n */\n submitIcon?: string;\n /**\n * - **EN:** Cancel button icon class name\n * - **CN:** 取消按钮图标类名\n */\n cancelIcon?: string;\n };\n /**\n * - **EN:** Semantic styles\n * - **CN:** 语义化样式\n */\n styles?: {\n /**\n * - **EN:** Edit mode parent container style\n * - **CN:** 编辑模式父容器样式\n */\n wrapper?: CSSProperties;\n /**\n * - **EN:** Submit button style\n * - **CN:** 提交按钮样式\n */\n submitButton?: CSSProperties;\n /**\n * - **EN:** Cancel button style\n * - **CN:** 取消按钮样式\n */\n cancelButton?: CSSProperties;\n /**\n * - **EN:** Submit button icon style\n * - **CN:** 提交按钮图标样式\n */\n submitIcon?: CSSProperties;\n /**\n * - **EN:** Cancel button icon style\n * - **CN:** 取消按钮图标样式\n */\n cancelIcon?: CSSProperties;\n };\n /**\n * **EN:** Submit and cancel action button alignment\n *\n * **CN:** 提交、取消操作按钮的对齐方式\n *\n * - `start` - align to the top | 顶部对齐\n * - `center` - align to the center | 居中对齐\n * - `end` - align to the bottom | 底部对齐\n *\n * @default 'center'\n */\n actionAlign?: SpaceProps['align'];\n /**\n * - **EN:** Submit button properties\n * - **CN:** 提交操作按钮属性\n */\n submitProps?: ButtonProps;\n /**\n * - **EN:** Cancel button properties\n * - **CN:** 取消操作按钮属性\n */\n cancelProps?: ButtonProps;\n /**\n * - **EN:** Confirm button click event, supports asynchronous operations\n * - **CN:** 确认按钮点击事件,支持异步操作\n */\n onOk: (value: string) => void | Promise<void>;\n /**\n * - **EN:** Cancel button click event, supports asynchronous operations\n * - **CN:** 取消按钮点击事件,支持异步操作\n */\n onCancel?: () => void | Promise<void>;\n}\n\nconst EditableTextForm = <IT extends 'Input' | 'TextArea'>({\n prefixCls,\n value,\n required = true,\n classNames,\n styles: styleNames,\n inputComp = 'Input' as IT,\n block: blockInProps = false,\n formProps,\n formItemProps,\n inputProps,\n actionAlign = 'center',\n submitProps,\n cancelProps,\n onOk,\n onCancel,\n}: EditableFormProps<IT>) => {\n const t = useT();\n const { getPrefixCls: getAntPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const [form] = Form.useForm<{ value?: string }>();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<InputRef>(null);\n const detectorRef = useRef<HTMLSpanElement>(null);\n const actionRef = useRef<HTMLDivElement>(null);\n const [inputWidth, setInputWidth] = useState<number>();\n const [visibility, setVisibility] = useState<CSSProperties['visibility']>('hidden');\n const [forceBlock, setForceBlock] = useState(false);\n const [saving, setSaving] = useState(false);\n const inputActionGapRef = useRef<number>(0);\n inputActionGapRef.current =\n pxToNumber(formItemProps?.style?.marginRight ?? formItemProps?.style?.marginInlineEnd) || defaultInputActionGap;\n const block = blockInProps || forceBlock;\n const InputComp = inputComp === 'TextArea' ? Input.TextArea : Input;\n\n // Update form value when `value` prop changes\n useEffect(() => {\n form.setFieldsValue({ value });\n }, [form, value]);\n\n // Detect the width of the text and dynamically adjust the input width\n useEffect(() => {\n let contentWidth = 0;\n if (detectorRef.current && inputRef.current?.input) {\n const inputStyle = getComputedStyle(inputRef.current.input);\n contentWidth =\n detectorRef.current.offsetWidth +\n pxToNumber(inputStyle.paddingLeft) +\n pxToNumber(inputStyle.paddingRight) +\n pxToNumber(inputStyle.borderLeftWidth) +\n pxToNumber(inputStyle.borderRightWidth);\n setInputWidth(contentWidth);\n }\n const actionWidth = actionRef.current?.offsetWidth || 0; // Width of action buttons\n const gap = inputActionGapRef.current; // Gap between input box and action buttons\n setVisibility('visible');\n // Listen to the width of the wrapper container, if the input box width is greater than the wrapper container width,\n const observer = new ResizeObserver(([entity]) => {\n const wrapperWidth = entity.contentRect.width;\n // Width deviation greater than 1px is considered overflow, to avoid misjudgment due to pixel density or scaling\n if (contentWidth + actionWidth + gap - wrapperWidth > 1) {\n setForceBlock(true);\n } else {\n setForceBlock(false);\n }\n });\n if (wrapperRef.current) {\n observer.observe(wrapperRef.current);\n }\n return () => observer.disconnect();\n }, []);\n\n // Cancel editing\n const handleCancel = async () => {\n form.resetFields();\n try {\n await onCancel?.();\n } catch (error) {\n console.error(error);\n }\n };\n // Pressing the Escape key to cancel editing\n const handleEscape: InputProps['onKeyUp'] = async (e) => {\n if (e.key === 'Escape') {\n await handleCancel();\n cancelProps?.onClick?.(e as unknown as React.MouseEvent<HTMLElement>);\n }\n };\n // Submit editing\n const handleSubmit = async (values: { value: string }) => {\n const { value } = values;\n try {\n setSaving(true);\n await onOk?.(value);\n } catch (error) {\n console.error(error);\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <div ref={wrapperRef} className={names(`${prefixCls}-form`, classNames?.wrapper)} style={styleNames?.wrapper}>\n <Form\n component=\"div\" // Do not use form tag to avoid conflicts with external form, which may be nested in other forms\n layout=\"inline\"\n form={form}\n initialValues={{ value }}\n autoComplete=\"off\"\n onFinish={handleSubmit}\n {...formProps}\n style={{\n visibility,\n ...formProps?.style,\n }}\n >\n {/* Input box */}\n <Form.Item\n rules={[{ required, message: t('components.EditableText.requiredMsg') }]}\n {...formItemProps}\n className={names(formItemProps?.className, { [`${getAntPrefixCls('form-item-block')}`]: block })}\n style={{\n marginInlineEnd: defaultInputActionGap,\n ...formItemProps?.style,\n }}\n name=\"value\"\n >\n <InputComp\n ref={inputRef}\n placeholder={t('components.EditableText.placeholder')}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(inputProps as any)}\n style={{\n width: block ? undefined : inputWidth, // Width is 100% in block mode, no need to set width\n ...inputProps?.style,\n }}\n onPressEnter={() => form.submit()}\n onKeyUp={handleEscape}\n />\n </Form.Item>\n {/* Used to calculate the width of the text content */}\n <span\n ref={detectorRef}\n style={{\n position: 'absolute',\n visibility: 'hidden',\n height: 0,\n whiteSpace: 'pre',\n }}\n >\n {value}\n </span>\n\n {/* Action buttons */}\n <Space ref={actionRef} className={`${prefixCls}-form-btns`} align={actionAlign} size={4}>\n <Button\n type=\"text\"\n disabled={saving}\n loading={saving}\n title={t('components.EditableText.save')}\n icon={<CheckSquareFilled className={classNames?.submitIcon} style={styleNames?.submitIcon} />}\n style={styleNames?.submitButton}\n onClick={() => form.submit()}\n {...submitProps}\n className={names(\n `${prefixCls}-form-btn`,\n `${prefixCls}-form-btn-save`,\n classNames?.submitButton,\n submitProps?.className\n )}\n />\n <Button\n type=\"text\"\n style={styleNames?.cancelButton}\n className={names(`${prefixCls}-form-btn`, `${prefixCls}-form-btn-close`, classNames?.cancelButton)}\n title={t('components.EditableText.cancel')}\n icon={<CloseSquareFilled className={classNames?.cancelIcon} style={styleNames?.cancelIcon} />}\n onClick={async (e) => {\n await handleCancel();\n cancelProps?.onClick?.(e);\n }}\n {...cancelProps}\n />\n </Space>\n </Form>\n </div>\n );\n};\n\nfunction pxToNumber(px: string | number | null | undefined) {\n return px ? parseFloat(px.toString().replace('px', '')) : 0;\n}\n\nexport default EditableTextForm;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, ReactElement } from 'react';\nimport { useContext, useEffect, useRef, useState } from 'react';\nimport type { ButtonProps, FormItemProps, FormProps, InputProps, SpaceProps } from 'antd';\nimport { Button, ConfigProvider, Form, Input, Space } from 'antd';\nimport type { InputRef, TextAreaProps } from 'antd/es/input';\nimport names from 'classnames';\nimport { CheckSquareFilled, CloseSquareFilled } from '@ant-design/icons';\nimport useT from '../../hooks/useT';\n\nconst defaultInputActionGap = 8;\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport interface EditableFormProps<V, IT extends 'Input' | 'TextArea' | RenderInputInterface> {\n prefixCls?: string;\n /**\n * - **EN:** The value to edit\n * - **CN:** 编辑的值\n */\n value: V | undefined;\n /**\n * - **EN:** Whether the text is required when editing, default is `true`, if `formItemProps.rules`\n * is set, it will override this value\n * - **CN:** 编辑文本时是否必填,默认值为`true`,如果设置了`formItemProps.rules`,将会覆盖此值\n *\n * @default true\n */\n required?: boolean;\n /**\n * - **EN:** Form properties\n * - **CN:** 表单属性\n */\n formProps?: FormProps;\n /**\n * - **EN:** Form item properties\n * - **CN:** 表单项属性\n */\n formItemProps?: FormItemProps;\n /**\n * - **EN:** Custom component type for rendering the input box\n * - **CN:** 自定义设置渲染输入框的组件类型\n *\n * @default 'Input'\n */\n inputComp?: IT;\n /**\n * - **EN:** Input component properties\n * - **CN:** 输入框组件属性\n */\n inputProps?: IT extends 'TextArea' ? TextAreaProps : IT extends 'Input' ? InputProps : never;\n /**\n * - **EN:** Whether to display as a block-level element, with width 100%\n * - **CN:** 是否显示为块级元素,宽度100%\n *\n * @default false\n */\n block?: boolean;\n /**\n * - **EN:** Semantic class names\n * - **CN:** 语义化类名\n */\n classNames?: {\n /**\n * - **EN:** Edit mode parent container class name\n * - **CN:** 编辑模式父容器类名\n */\n wrapper?: string;\n /**\n * - **EN:** Submit button class name\n * - **CN:** 提交按钮类名\n */\n submitButton?: string;\n /**\n * - **EN:** Cancel button class name\n * - **CN:** 取消按钮类名\n */\n cancelButton?: string;\n /**\n * - **EN:** Submit button icon class name\n * - **CN:** 提交按钮图标类名\n */\n submitIcon?: string;\n /**\n * - **EN:** Cancel button icon class name\n * - **CN:** 取消按钮图标类名\n */\n cancelIcon?: string;\n };\n /**\n * - **EN:** Semantic styles\n * - **CN:** 语义化样式\n */\n styles?: {\n /**\n * - **EN:** Edit mode parent container style\n * - **CN:** 编辑模式父容器样式\n */\n wrapper?: CSSProperties;\n /**\n * - **EN:** Submit button style\n * - **CN:** 提交按钮样式\n */\n submitButton?: CSSProperties;\n /**\n * - **EN:** Cancel button style\n * - **CN:** 取消按钮样式\n */\n cancelButton?: CSSProperties;\n /**\n * - **EN:** Submit button icon style\n * - **CN:** 提交按钮图标样式\n */\n submitIcon?: CSSProperties;\n /**\n * - **EN:** Cancel button icon style\n * - **CN:** 取消按钮图标样式\n */\n cancelIcon?: CSSProperties;\n };\n /**\n * **EN:** Submit and cancel action button alignment\n *\n * **CN:** 提交、取消操作按钮的对齐方式\n *\n * - `start` - align to the top | 顶部对齐\n * - `center` - align to the center | 居中对齐\n * - `end` - align to the bottom | 底部对齐\n *\n * @default 'center'\n */\n actionAlign?: SpaceProps['align'];\n /**\n * - **EN:** Submit button properties\n * - **CN:** 提交操作按钮属性\n */\n submitProps?: ButtonProps;\n /**\n * - **EN:** Cancel button properties\n * - **CN:** 取消操作按钮属性\n */\n cancelProps?: ButtonProps;\n /**\n * - **EN:** Confirm button click event, supports asynchronous operations\n * - **CN:** 确认按钮点击事件,支持异步操作\n */\n onOk: (value: V | undefined) => void | Promise<void>;\n /**\n * - **EN:** Cancel button click event, supports asynchronous operations\n * - **CN:** 取消按钮点击事件,支持异步操作\n */\n onCancel?: () => void | Promise<void>;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nconst EditableTextForm = <V, IT extends 'Input' | 'TextArea' | RenderInputInterface>(\n props: EditableFormProps<V, IT>\n) => {\n const {\n prefixCls,\n value,\n required = true,\n classNames,\n styles: styleNames,\n inputComp = 'Input' as IT,\n block: blockInProps = false,\n formProps,\n formItemProps,\n inputProps,\n actionAlign = 'center',\n submitProps,\n cancelProps,\n onOk,\n onCancel,\n } = props;\n const t = useT();\n const { getPrefixCls: getAntPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const [form] = Form.useForm<{ value: V | undefined }>();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<InputRef>(null);\n const supportAutoScale = inputComp === 'Input' || inputComp === 'TextArea';\n const detectorRef = useRef<HTMLSpanElement>(null);\n const actionRef = useRef<HTMLDivElement>(null);\n const [inputWidth, setInputWidth] = useState<number>();\n const [visibility, setVisibility] = useState<CSSProperties['visibility']>('hidden');\n const [forceBlock, setForceBlock] = useState(false);\n const [saving, setSaving] = useState(false);\n const inputActionGapRef = useRef<number>(0);\n inputActionGapRef.current =\n pxToNumber(formItemProps?.style?.marginRight ?? formItemProps?.style?.marginInlineEnd) || defaultInputActionGap;\n const block = blockInProps || forceBlock;\n\n // Update form value when `value` prop changes\n useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n form.setFieldsValue({ value: value as any });\n }, [form, value]);\n\n // Detect the width of the text and dynamically scale the input width until it reaches the max width of the container.\n // Only built-in Input and TextArea components are supported.\n useEffect(() => {\n let contentWidth = 0;\n const inputElement = inputRef.current?.input;\n if (detectorRef.current && inputElement && supportAutoScale) {\n const inputStyle = getComputedStyle(inputElement);\n contentWidth =\n detectorRef.current.offsetWidth +\n pxToNumber(inputStyle.paddingLeft) +\n pxToNumber(inputStyle.paddingRight) +\n pxToNumber(inputStyle.borderLeftWidth) +\n pxToNumber(inputStyle.borderRightWidth);\n setInputWidth(contentWidth);\n }\n const actionWidth = actionRef.current?.offsetWidth || 0; // Width of action buttons\n const gap = inputActionGapRef.current; // Gap between input box and action buttons\n setVisibility('visible');\n // Listen to the width of the wrapper container, if the input box width is greater than the wrapper container width,\n const observer = new ResizeObserver(([entity]) => {\n const wrapperWidth = entity.contentRect.width;\n // Width deviation greater than 1px is considered overflow, to avoid misjudgment due to pixel density or scaling\n if (contentWidth + actionWidth + gap - wrapperWidth > 1) {\n setForceBlock(true);\n } else {\n setForceBlock(false);\n }\n });\n if (wrapperRef.current) {\n observer.observe(wrapperRef.current);\n }\n return () => observer.disconnect();\n }, [supportAutoScale]);\n\n // Cancel editing\n const handleCancel = async () => {\n form.resetFields();\n try {\n await onCancel?.();\n } catch (error) {\n console.error(error);\n }\n };\n // Pressing the Escape key to cancel editing\n const handleEscape: InputProps['onKeyUp'] = async (e) => {\n if ((inputComp === 'Input' || inputComp === 'TextArea') && e.key === 'Escape') {\n await handleCancel();\n cancelProps?.onClick?.(e as unknown as React.MouseEvent<HTMLElement>);\n }\n };\n // Submit editing\n const handleSubmit = async (values: { value: V | undefined }) => {\n const { value } = values;\n try {\n setSaving(true);\n await onOk?.(value);\n } catch (error) {\n console.error(error);\n } finally {\n setSaving(false);\n }\n };\n\n const renderInput = () => {\n if (inputComp === 'Input' || inputComp === 'TextArea') {\n const COMP = inputComp === 'Input' ? Input : Input.TextArea;\n return (\n <COMP\n ref={inputRef}\n placeholder={t('components.EditableText.placeholder')}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(inputProps as any)}\n style={{\n width: block ? undefined : inputWidth, // Width is 100% in block mode, no need to set width\n ...(inputProps && 'style' in inputProps ? inputProps?.style : {}),\n }}\n onPressEnter={() => {\n if (inputComp === 'Input') {\n form.submit();\n }\n }}\n onKeyUp={handleEscape}\n />\n );\n } else {\n return (\n <CustomInput<V>\n {...props}\n render={inputComp}\n submit={async () => {\n const values = await form.validateFields();\n await handleSubmit(values);\n }}\n cancel={handleCancel}\n />\n );\n }\n };\n\n return (\n <div ref={wrapperRef} className={names(`${prefixCls}-form`, classNames?.wrapper)} style={styleNames?.wrapper}>\n <Form\n component=\"div\" // Do not use form tag to avoid conflicts with external form, which may be nested in other forms\n layout=\"inline\"\n form={form}\n initialValues={{ value }}\n autoComplete=\"off\"\n onFinish={handleSubmit}\n {...formProps}\n style={{\n visibility,\n ...formProps?.style,\n }}\n >\n {/* Input box */}\n <Form.Item\n rules={[{ required, message: t('components.EditableText.requiredMsg') }]}\n {...formItemProps}\n className={names(formItemProps?.className, { [`${getAntPrefixCls('form-item-block')}`]: block })}\n style={{\n marginInlineEnd: defaultInputActionGap,\n ...formItemProps?.style,\n }}\n name=\"value\"\n >\n {renderInput()}\n </Form.Item>\n {/* Used to calculate the width of the text content */}\n {supportAutoScale && (\n <span\n ref={detectorRef}\n style={{\n position: 'absolute',\n visibility: 'hidden',\n height: 0,\n whiteSpace: 'pre',\n }}\n >\n {value?.toString()}\n </span>\n )}\n\n {/* Action buttons */}\n <Space ref={actionRef} className={`${prefixCls}-form-btns`} align={actionAlign} size={4}>\n <Button\n type=\"text\"\n disabled={saving}\n loading={saving}\n title={t('components.EditableText.save')}\n icon={<CheckSquareFilled className={classNames?.submitIcon} style={styleNames?.submitIcon} />}\n style={styleNames?.submitButton}\n onClick={() => form.submit()}\n {...submitProps}\n className={names(\n `${prefixCls}-form-btn`,\n `${prefixCls}-form-btn-save`,\n classNames?.submitButton,\n submitProps?.className\n )}\n />\n <Button\n type=\"text\"\n style={styleNames?.cancelButton}\n className={names(`${prefixCls}-form-btn`, `${prefixCls}-form-btn-close`, classNames?.cancelButton)}\n title={t('components.EditableText.cancel')}\n icon={<CloseSquareFilled className={classNames?.cancelIcon} style={styleNames?.cancelIcon} />}\n onClick={async (e) => {\n await handleCancel();\n cancelProps?.onClick?.(e);\n }}\n {...cancelProps}\n />\n </Space>\n </Form>\n </div>\n );\n};\n\nfunction CustomInput<V>(\n props: RenderInputProps<V> & {\n render: RenderInputInterface;\n }\n): ReactElement | null {\n const { render, value, onChange, ...restProps } = props;\n const useInput = render;\n return useInput({ ...restProps, value, onChange });\n}\n\nfunction pxToNumber(px: string | number | null | undefined) {\n return px ? parseFloat(px.toString().replace('px', '')) : 0;\n}\n\nexport type RenderInputInterface = <V>(props: RenderInputProps<V>) => ReactElement | null;\nexport interface RenderInputProps<V>\n extends Omit<EditableFormProps<V, 'Input'>, 'inputComp' | 'inputProps' | 'onOk' | 'onCancel'> {\n onChange?: (value: V | undefined) => void;\n submit(): Promise<void>;\n cancel(): Promise<void>;\n}\n\nexport default EditableTextForm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A,MAAA,2CAAa,YAAb,gBAAAA,IAAA,kBAAuB;AAAA,QACzB;AAAA,QACC,GAAG;AAAA;AAAA,IACN,CACF;AAAA,EACF,CACF;AAEJ;AAEA,SAAS,YACP,OAGqB;AACrB,QAAM,EAAE,QAAQ,OAAO,UAAU,GAAG,UAAU,IAAI;AAClD,QAAM,WAAW;AACjB,SAAO,SAAS,EAAE,GAAG,WAAW,OAAO,SAAS,CAAC;AACnD;AAEA,SAAS,WAAW,IAAwC;AAC1D,SAAO,KAAK,WAAW,GAAG,SAAS,EAAE,QAAQ,MAAM,EAAE,CAAC,IAAI;AAC5D;AAUA,IAAO,eAAQ;",
|
|
6
6
|
"names": ["useT", "_a", "_b", "value", "names"]
|
|
7
7
|
}
|
|
@@ -5,9 +5,9 @@ import type { LinkProps } from 'antd/es/typography/Link';
|
|
|
5
5
|
import type { ParagraphProps } from 'antd/es/typography/Paragraph';
|
|
6
6
|
import type { TextProps } from 'antd/es/typography/Text';
|
|
7
7
|
import type { TitleProps } from 'antd/es/typography/Title';
|
|
8
|
-
import { type EditableFormProps } from './form';
|
|
9
|
-
declare const getEllipsisConfig: (content:
|
|
10
|
-
export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | 'Link' = 'Text', IT extends 'Input' | 'TextArea' = 'Input'> extends EditableFormProps<IT> {
|
|
8
|
+
import { type EditableFormProps, type RenderInputInterface } from './form';
|
|
9
|
+
declare const getEllipsisConfig: (content: ReactNode | undefined) => EllipsisConfig;
|
|
10
|
+
export interface EditableTextProps<V = string, TT extends 'Text' | 'Paragraph' | 'Title' | 'Link' = 'Text', IT extends 'Input' | 'TextArea' | RenderInputInterface = 'Input'> extends Omit<EditableFormProps<V, IT>, 'block'> {
|
|
11
11
|
prefixCls?: string;
|
|
12
12
|
/**
|
|
13
13
|
* - **EN:** Custom read-only display text, replacing `value` display
|
|
@@ -15,7 +15,7 @@ export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | '
|
|
|
15
15
|
*
|
|
16
16
|
* @default true
|
|
17
17
|
*/
|
|
18
|
-
displayText?:
|
|
18
|
+
displayText?: ReactNode | ((value: V | undefined) => ReactNode);
|
|
19
19
|
/**
|
|
20
20
|
* - **EN:** Another way to customize read-only display text, with higher priority than
|
|
21
21
|
* `displayText`. This method does not support text truncation.
|
|
@@ -36,6 +36,28 @@ export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | '
|
|
|
36
36
|
* @default false
|
|
37
37
|
*/
|
|
38
38
|
editing?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* - **EN:** Whether to display as a block-level element, with width 100%
|
|
41
|
+
* - **CN:** 是否显示为块级元素,宽度100%
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
block?: boolean | {
|
|
46
|
+
/**
|
|
47
|
+
* - **EN:** Whether to display as a block-level element in view mode, with width 100%
|
|
48
|
+
* - **CN:** 只读模式是否显示为块级元素,宽度100%
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
view?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* - **EN:** Whether to display as a block-level element in edit mode, with width 100%
|
|
55
|
+
* - **CN:** 编辑模式是否显示为块级元素,宽度100%
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
editing?: boolean;
|
|
60
|
+
};
|
|
39
61
|
/**
|
|
40
62
|
* - **EN:** Component container class name.
|
|
41
63
|
* - **CN:** 组件容器类名
|
|
@@ -61,12 +83,12 @@ export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | '
|
|
|
61
83
|
* - **CN:** 编辑按钮类名
|
|
62
84
|
*/
|
|
63
85
|
editIcon?: string;
|
|
64
|
-
} & EditableFormProps<IT>['classNames'];
|
|
86
|
+
} & EditableFormProps<V, IT>['classNames'];
|
|
65
87
|
/**
|
|
66
88
|
* - **EN:** After saving with `onOk`, the modified value is passed out through `onChange`
|
|
67
89
|
* - **CN:** 在`onOk`保存后,通过`onChange`把修改后的值传递出去
|
|
68
90
|
*/
|
|
69
|
-
onChange?: (value:
|
|
91
|
+
onChange?: (value: V | undefined) => void;
|
|
70
92
|
/**
|
|
71
93
|
* - **EN:** Event triggered when the editing state changes
|
|
72
94
|
* - **CN:** 编辑状态改变事件
|
|
@@ -87,7 +109,7 @@ export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | '
|
|
|
87
109
|
* - **CN:** 编辑按钮样式
|
|
88
110
|
*/
|
|
89
111
|
editIcon?: CSSProperties;
|
|
90
|
-
} & EditableFormProps<IT>['styles'];
|
|
112
|
+
} & EditableFormProps<V, IT>['styles'];
|
|
91
113
|
/**
|
|
92
114
|
* - **EN:** Custom component type for rendering the text
|
|
93
115
|
* - **CN:** 自定义设置渲染文本组件的组件类型
|
|
@@ -128,8 +150,8 @@ export interface EditableTextProps<TT extends 'Text' | 'Paragraph' | 'Title' | '
|
|
|
128
150
|
* <EditableText value="Editable Text" onOk={(value) => console.log('Saved value:', value)} />;
|
|
129
151
|
*/
|
|
130
152
|
declare const EditableText: {
|
|
131
|
-
<TT extends "Text" | "Paragraph" | "Title" | "Link", IT extends "Input" | "TextArea">(props: EditableTextProps<TT, IT>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
132
|
-
getEllipsisConfig: (content:
|
|
153
|
+
<V, TT extends "Text" | "Paragraph" | "Title" | "Link", IT extends "Input" | RenderInputInterface | "TextArea">(props: EditableTextProps<V, TT, IT>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
154
|
+
getEllipsisConfig: (content: ReactNode | undefined) => EllipsisConfig;
|
|
133
155
|
};
|
|
134
156
|
type EditableTextInterface = typeof EditableText & {
|
|
135
157
|
getEllipsisConfig: typeof getEllipsisConfig;
|
|
@@ -48,7 +48,7 @@ var getEllipsisConfig = (content) => ({
|
|
|
48
48
|
var EditableText = (props) => {
|
|
49
49
|
const {
|
|
50
50
|
prefixCls: prefixClsInProps,
|
|
51
|
-
value: valueInProps
|
|
51
|
+
value: valueInProps,
|
|
52
52
|
displayText: displayTextInProps,
|
|
53
53
|
editable = true,
|
|
54
54
|
editing = false,
|
|
@@ -56,7 +56,7 @@ var EditableText = (props) => {
|
|
|
56
56
|
style = {},
|
|
57
57
|
classNames,
|
|
58
58
|
styles: styleNames,
|
|
59
|
-
block,
|
|
59
|
+
block: blockInProps,
|
|
60
60
|
textComp = "Text",
|
|
61
61
|
textProps,
|
|
62
62
|
editIcon,
|
|
@@ -82,10 +82,17 @@ var EditableText = (props) => {
|
|
|
82
82
|
const [isEditing, setIsEditing] = (0, import_react.useState)(editing);
|
|
83
83
|
const TypographyComponent = import_antd.Typography[textComp];
|
|
84
84
|
const [value, setValue] = (0, import_react.useState)(valueInProps);
|
|
85
|
-
const displayText = displayTextInProps ?? value;
|
|
86
85
|
const inputComp = inputCompInProps ?? (textComp === "Paragraph" ? "TextArea" : "Input");
|
|
86
|
+
const viewBlock = typeof blockInProps === "boolean" ? blockInProps : blockInProps == null ? void 0 : blockInProps.view;
|
|
87
|
+
const editingBlock = typeof blockInProps === "boolean" ? blockInProps : blockInProps == null ? void 0 : blockInProps.editing;
|
|
87
88
|
const editableRef = import_react.default.useRef(editable);
|
|
88
89
|
editableRef.current = editable;
|
|
90
|
+
const displayText = (0, import_react.useMemo)(() => {
|
|
91
|
+
if (typeof displayTextInProps === "function") {
|
|
92
|
+
return displayTextInProps(value);
|
|
93
|
+
}
|
|
94
|
+
return displayTextInProps ?? (value == null ? void 0 : value.toString());
|
|
95
|
+
}, [displayTextInProps, value]);
|
|
89
96
|
(0, import_react.useEffect)(() => {
|
|
90
97
|
setValue(valueInProps);
|
|
91
98
|
}, [valueInProps]);
|
|
@@ -123,7 +130,7 @@ var EditableText = (props) => {
|
|
|
123
130
|
formItemProps,
|
|
124
131
|
inputComp,
|
|
125
132
|
inputProps,
|
|
126
|
-
block,
|
|
133
|
+
block: editingBlock,
|
|
127
134
|
classNames,
|
|
128
135
|
styles: styleNames,
|
|
129
136
|
actionAlign,
|
|
@@ -138,7 +145,7 @@ var EditableText = (props) => {
|
|
|
138
145
|
className: (0, import_classnames.default)(`${prefixCls}-view-mode`, {
|
|
139
146
|
[`${prefixCls}-single-line`]: textComp !== "Paragraph",
|
|
140
147
|
[`${prefixCls}-has-children`]: !!children,
|
|
141
|
-
[`${prefixCls}-view-mode-block`]:
|
|
148
|
+
[`${prefixCls}-view-mode-block`]: viewBlock
|
|
142
149
|
}),
|
|
143
150
|
align: editIconAlign
|
|
144
151
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/EditableText/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { CSSProperties, ReactNode } from 'react';\nimport React, { useContext, useEffect, useState } from 'react';\nimport { ConfigProvider, Flex, Typography } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport names from 'classnames';\nimport { EditOutlined } from '@ant-design/icons';\nimport useT from '../../hooks/useT';\nimport EditableTextForm, { type EditableFormProps } from './form';\nimport useStyle from './style';\n\nconst getEllipsisConfig = (content: string | undefined): EllipsisConfig => ({\n tooltip: {\n title: content,\n overlayStyle: { maxWidth: 500 },\n },\n});\n\nexport interface EditableTextProps<\n TT extends 'Text' | 'Paragraph' | 'Title' | 'Link' = 'Text',\n IT extends 'Input' | 'TextArea' = 'Input',\n> extends EditableFormProps<IT> {\n prefixCls?: string;\n /**\n * - **EN:** Custom read-only display text, replacing `value` display\n * - **CN:** 自定义只读显示文本,替代`value`显示\n *\n * @default true\n */\n displayText?: string;\n /**\n * - **EN:** Another way to customize read-only display text, with higher priority than\n * `displayText`. This method does not support text truncation.\n * - **CN:** 另外一种方式自定义只读显示文本,优先级高于`displayText`,这种方式无文本省略效果\n */\n children?: ReactNode;\n /**\n * - **EN:** Whether to allow editing. If set to `false`, the edit button will not be displayed.\n * - **CN:** 是否允许编辑,如果设置为`false`,则不显示编辑按钮\n *\n * @default true\n */\n editable?: boolean;\n /**\n * - **EN:** Whether to open edit mode.\n * - **CN:** 是否打开编辑模式\n *\n * @default false\n */\n editing?: boolean;\n /**\n * - **EN:** Component container class name.\n * - **CN:** 组件容器类名\n */\n className?: string;\n /**\n * - **EN:** Component container style.\n * - **CN:** 组件容器样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Semantic class names.\n * - **CN:** 语义化类名\n */\n classNames?: {\n /**\n * - **EN:** Read-only text class name\n * - **CN:** 只读文本类名\n */\n text?: string;\n /**\n * - **EN:** Edit button class name\n * - **CN:** 编辑按钮类名\n */\n editIcon?: string;\n } & EditableFormProps<IT>['classNames'];\n /**\n * - **EN:** After saving with `onOk`, the modified value is passed out through `onChange`\n * - **CN:** 在`onOk`保存后,通过`onChange`把修改后的值传递出去\n */\n onChange?: (value: string) => void;\n /**\n * - **EN:** Event triggered when the editing state changes\n * - **CN:** 编辑状态改变事件\n */\n onEditingChange?: (editing: boolean) => void;\n /**\n * - **EN:** Whether to display as a block-level element, with width 100%\n * - **CN:** 语义化样式\n */\n styles?: {\n /**\n * - **EN:** Read-only text class name\n * - **CN:** 只读文本类名\n */\n text?: CSSProperties;\n /**\n * - **EN:** Edit button style\n * - **CN:** 编辑按钮样式\n */\n editIcon?: CSSProperties;\n } & EditableFormProps<IT>['styles'];\n\n /**\n * - **EN:** Custom component type for rendering the text\n * - **CN:** 自定义设置渲染文本组件的组件类型\n *\n * @default 'Text'\n */\n textComp?: TT;\n /**\n * - **EN:** Text component props\n * - **CN:** 文本组件属性\n */\n textProps?: TT extends 'Text'\n ? TextProps\n : TT extends 'Paragraph'\n ? ParagraphProps\n : TT extends 'Title'\n ? TitleProps\n : TT extends 'Link'\n ? LinkProps\n : never;\n /**\n * - **EN:** Custom edit icon\n * - **CN:** 自定义编辑图标\n */\n editIcon?: ReactNode;\n /**\n * **EN:** Edit button vertical alignment\n *\n * **CN:** 编辑按钮垂直对齐方式\n *\n * - `start` - align to the top | 顶部对齐\n * - `center` - align to the center | 居中对齐\n * - `end` - align to the bottom | 底部对齐\n * - `baseline` - align to the text baseline, useful when the text has line height set |\n * 与文本基线对齐,在文本设置了行高时会非常有用\n *\n * @default 'center'\n */\n editIconAlign?: CSSProperties['alignItems'];\n}\n\n/**\n * - **EN:** Editable text component, providing a read-only display and an edit mode.\n * - **CN:** 可编辑文本组件,提供只读显示和编辑模式。\n *\n * @example\n * <EditableText value=\"Editable Text\" onOk={(value) => console.log('Saved value:', value)} />;\n */\nconst EditableText = <TT extends 'Text' | 'Paragraph' | 'Title' | 'Link', IT extends 'Input' | 'TextArea'>(\n props: EditableTextProps<TT, IT>\n) => {\n const {\n prefixCls: prefixClsInProps,\n value: valueInProps = '',\n displayText: displayTextInProps,\n editable = true,\n editing = false,\n className = '',\n style = {},\n classNames,\n styles: styleNames,\n block,\n textComp = 'Text',\n textProps,\n editIcon,\n editIconAlign = 'center',\n children,\n formProps,\n formItemProps,\n inputComp: inputCompInProps,\n inputProps,\n required,\n actionAlign,\n submitProps,\n cancelProps,\n onOk,\n onCancel,\n onChange,\n onEditingChange,\n } = props;\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-editable-text', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const t = useT();\n const [isEditing, setIsEditing] = useState<boolean>(editing);\n const TypographyComponent = Typography[textComp];\n const [value, setValue] = useState(valueInProps);\n const displayText = displayTextInProps ?? value;\n const inputComp = inputCompInProps ?? (textComp === 'Paragraph' ? 'TextArea' : 'Input');\n const editableRef = React.useRef(editable);\n editableRef.current = editable;\n\n // value受控\n useEffect(() => {\n setValue(valueInProps);\n }, [valueInProps]);\n // editing受控\n useEffect(() => {\n if (editableRef.current) {\n setIsEditing(editing);\n }\n }, [editing]);\n\n // 编辑状态改变\n const handleEditingChange = (editing: boolean) => {\n setIsEditing(editing);\n onEditingChange?.(editing);\n };\n // 提交编辑\n const handleOk = async (val: string) => {\n try {\n await onOk?.(val);\n onChange?.(val);\n setValue(val);\n handleEditingChange(false);\n } catch (error) {\n console.error(error);\n }\n };\n // 取消编辑\n const handleCancel = async () => {\n handleEditingChange(false);\n await onCancel?.();\n };\n\n return wrapCSSVar(\n <div className={names(prefixCls, hashId, cssVarCls, className)} style={style}>\n {isEditing ? (\n <div className={`${prefixCls}-edit-mode`}>\n <EditableTextForm\n prefixCls={prefixCls}\n value={value}\n required={required}\n formProps={formProps}\n formItemProps={formItemProps}\n inputComp={inputComp}\n inputProps={inputProps}\n block={block}\n classNames={classNames}\n styles={styleNames}\n actionAlign={actionAlign}\n submitProps={submitProps}\n cancelProps={cancelProps}\n onOk={handleOk}\n onCancel={handleCancel}\n />\n </div>\n ) : (\n <Flex\n className={names(`${prefixCls}-view-mode`, {\n [`${prefixCls}-single-line`]: textComp !== 'Paragraph',\n [`${prefixCls}-has-children`]: !!children,\n [`${prefixCls}-view-mode-block`]: block,\n })}\n align={editIconAlign}\n >\n <div className={`${prefixCls}-text-content`}>\n {children ?? (\n <TypographyComponent\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(textProps as any)}\n className={names(classNames?.text, classNames?.text, textProps?.className)}\n style={{\n marginBottom: textComp === 'Title' ? 0 : undefined, // 去掉标题组件的默认下边距\n ...(textProps?.style ?? styleNames?.text),\n }}\n ellipsis={textProps?.ellipsis ?? getEllipsisConfig(displayText)}\n >\n {displayText}\n </TypographyComponent>\n )}\n </div>\n {/* 编辑按钮 */}\n {editable && (\n <div\n className={names(`${prefixCls}-edit-icon`, classNames?.editIcon)}\n style={styleNames?.editIcon}\n title={t('components.EditableText.edit')}\n onClick={() => handleEditingChange(true)}\n >\n {editIcon ?? <EditOutlined />}\n </div>\n )}\n </Flex>\n )}\n </div>\n );\n};\n\ntype EditableTextInterface = typeof EditableText & {\n getEllipsisConfig: typeof getEllipsisConfig;\n};\n\nEditableText.getEllipsisConfig = getEllipsisConfig;\n\nexport default EditableText as EditableTextInterface;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, ReactNode } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { ConfigProvider, Flex, Typography } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport names from 'classnames';\nimport { EditOutlined } from '@ant-design/icons';\nimport useT from '../../hooks/useT';\nimport EditableTextForm, { type EditableFormProps, type RenderInputInterface } from './form';\nimport useStyle from './style';\n\nconst getEllipsisConfig = (content: ReactNode | undefined): EllipsisConfig => ({\n tooltip: {\n title: content,\n overlayStyle: { maxWidth: 500 },\n },\n});\n\nexport interface EditableTextProps<\n V = string,\n TT extends 'Text' | 'Paragraph' | 'Title' | 'Link' = 'Text',\n IT extends 'Input' | 'TextArea' | RenderInputInterface = 'Input',\n> extends Omit<EditableFormProps<V, IT>, 'block'> {\n prefixCls?: string;\n /**\n * - **EN:** Custom read-only display text, replacing `value` display\n * - **CN:** 自定义只读显示文本,替代`value`显示\n *\n * @default true\n */\n displayText?: ReactNode | ((value: V | undefined) => ReactNode);\n /**\n * - **EN:** Another way to customize read-only display text, with higher priority than\n * `displayText`. This method does not support text truncation.\n * - **CN:** 另外一种方式自定义只读显示文本,优先级高于`displayText`,这种方式无文本省略效果\n */\n children?: ReactNode;\n /**\n * - **EN:** Whether to allow editing. If set to `false`, the edit button will not be displayed.\n * - **CN:** 是否允许编辑,如果设置为`false`,则不显示编辑按钮\n *\n * @default true\n */\n editable?: boolean;\n /**\n * - **EN:** Whether to open edit mode.\n * - **CN:** 是否打开编辑模式\n *\n * @default false\n */\n editing?: boolean;\n /**\n * - **EN:** Whether to display as a block-level element, with width 100%\n * - **CN:** 是否显示为块级元素,宽度100%\n *\n * @default false\n */\n block?:\n | boolean\n | {\n /**\n * - **EN:** Whether to display as a block-level element in view mode, with width 100%\n * - **CN:** 只读模式是否显示为块级元素,宽度100%\n *\n * @default false\n */\n view?: boolean;\n /**\n * - **EN:** Whether to display as a block-level element in edit mode, with width 100%\n * - **CN:** 编辑模式是否显示为块级元素,宽度100%\n *\n * @default false\n */\n editing?: boolean;\n };\n /**\n * - **EN:** Component container class name.\n * - **CN:** 组件容器类名\n */\n className?: string;\n /**\n * - **EN:** Component container style.\n * - **CN:** 组件容器样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Semantic class names.\n * - **CN:** 语义化类名\n */\n classNames?: {\n /**\n * - **EN:** Read-only text class name\n * - **CN:** 只读文本类名\n */\n text?: string;\n /**\n * - **EN:** Edit button class name\n * - **CN:** 编辑按钮类名\n */\n editIcon?: string;\n } & EditableFormProps<V, IT>['classNames'];\n /**\n * - **EN:** After saving with `onOk`, the modified value is passed out through `onChange`\n * - **CN:** 在`onOk`保存后,通过`onChange`把修改后的值传递出去\n */\n onChange?: (value: V | undefined) => void;\n /**\n * - **EN:** Event triggered when the editing state changes\n * - **CN:** 编辑状态改变事件\n */\n onEditingChange?: (editing: boolean) => void;\n /**\n * - **EN:** Whether to display as a block-level element, with width 100%\n * - **CN:** 语义化样式\n */\n styles?: {\n /**\n * - **EN:** Read-only text class name\n * - **CN:** 只读文本类名\n */\n text?: CSSProperties;\n /**\n * - **EN:** Edit button style\n * - **CN:** 编辑按钮样式\n */\n editIcon?: CSSProperties;\n } & EditableFormProps<V, IT>['styles'];\n\n /**\n * - **EN:** Custom component type for rendering the text\n * - **CN:** 自定义设置渲染文本组件的组件类型\n *\n * @default 'Text'\n */\n textComp?: TT;\n /**\n * - **EN:** Text component props\n * - **CN:** 文本组件属性\n */\n textProps?: TT extends 'Text'\n ? TextProps\n : TT extends 'Paragraph'\n ? ParagraphProps\n : TT extends 'Title'\n ? TitleProps\n : TT extends 'Link'\n ? LinkProps\n : never;\n /**\n * - **EN:** Custom edit icon\n * - **CN:** 自定义编辑图标\n */\n editIcon?: ReactNode;\n /**\n * **EN:** Edit button vertical alignment\n *\n * **CN:** 编辑按钮垂直对齐方式\n *\n * - `start` - align to the top | 顶部对齐\n * - `center` - align to the center | 居中对齐\n * - `end` - align to the bottom | 底部对齐\n * - `baseline` - align to the text baseline, useful when the text has line height set |\n * 与文本基线对齐,在文本设置了行高时会非常有用\n *\n * @default 'center'\n */\n editIconAlign?: CSSProperties['alignItems'];\n}\n\n/**\n * - **EN:** Editable text component, providing a read-only display and an edit mode.\n * - **CN:** 可编辑文本组件,提供只读显示和编辑模式。\n *\n * @example\n * <EditableText value=\"Editable Text\" onOk={(value) => console.log('Saved value:', value)} />;\n */\nconst EditableText = <\n V,\n TT extends 'Text' | 'Paragraph' | 'Title' | 'Link',\n IT extends 'Input' | 'TextArea' | RenderInputInterface,\n>(\n props: EditableTextProps<V, TT, IT>\n) => {\n const {\n prefixCls: prefixClsInProps,\n value: valueInProps,\n displayText: displayTextInProps,\n editable = true,\n editing = false,\n className = '',\n style = {},\n classNames,\n styles: styleNames,\n block: blockInProps,\n textComp = 'Text',\n textProps,\n editIcon,\n editIconAlign = 'center',\n children,\n formProps,\n formItemProps,\n inputComp: inputCompInProps,\n inputProps,\n required,\n actionAlign,\n submitProps,\n cancelProps,\n onOk,\n onCancel,\n onChange,\n onEditingChange,\n } = props;\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-editable-text', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const t = useT();\n const [isEditing, setIsEditing] = useState<boolean>(editing);\n const TypographyComponent = Typography[textComp];\n const [value, setValue] = useState(valueInProps);\n const inputComp = inputCompInProps ?? (textComp === 'Paragraph' ? 'TextArea' : 'Input');\n const viewBlock = typeof blockInProps === 'boolean' ? blockInProps : blockInProps?.view;\n const editingBlock = typeof blockInProps === 'boolean' ? blockInProps : blockInProps?.editing;\n const editableRef = React.useRef(editable);\n editableRef.current = editable;\n const displayText = useMemo(() => {\n if (typeof displayTextInProps === 'function') {\n return displayTextInProps(value);\n }\n return displayTextInProps ?? value?.toString();\n }, [displayTextInProps, value]);\n\n // value受控\n useEffect(() => {\n setValue(valueInProps);\n }, [valueInProps]);\n // editing受控\n useEffect(() => {\n if (editableRef.current) {\n setIsEditing(editing);\n }\n }, [editing]);\n\n // 编辑状态改变\n const handleEditingChange = (editing: boolean) => {\n setIsEditing(editing);\n onEditingChange?.(editing);\n };\n // 提交编辑\n const handleOk = async (val: V | undefined) => {\n try {\n await onOk?.(val);\n onChange?.(val);\n setValue(val);\n handleEditingChange(false);\n } catch (error) {\n console.error(error);\n }\n };\n // 取消编辑\n const handleCancel = async () => {\n handleEditingChange(false);\n await onCancel?.();\n };\n\n return wrapCSSVar(\n <div className={names(prefixCls, hashId, cssVarCls, className)} style={style}>\n {isEditing ? (\n <div className={`${prefixCls}-edit-mode`}>\n <EditableTextForm\n prefixCls={prefixCls}\n value={value}\n required={required}\n formProps={formProps}\n formItemProps={formItemProps}\n inputComp={inputComp}\n inputProps={inputProps}\n block={editingBlock}\n classNames={classNames}\n styles={styleNames}\n actionAlign={actionAlign}\n submitProps={submitProps}\n cancelProps={cancelProps}\n onOk={handleOk}\n onCancel={handleCancel}\n />\n </div>\n ) : (\n <Flex\n className={names(`${prefixCls}-view-mode`, {\n [`${prefixCls}-single-line`]: textComp !== 'Paragraph',\n [`${prefixCls}-has-children`]: !!children,\n [`${prefixCls}-view-mode-block`]: viewBlock,\n })}\n align={editIconAlign}\n >\n <div className={`${prefixCls}-text-content`}>\n {children ?? (\n <TypographyComponent\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(textProps as any)}\n className={names(classNames?.text, classNames?.text, textProps?.className)}\n style={{\n marginBottom: textComp === 'Title' ? 0 : undefined, // 去掉标题组件的默认下边距\n ...(textProps?.style ?? styleNames?.text),\n }}\n ellipsis={textProps?.ellipsis ?? getEllipsisConfig(displayText)}\n >\n {displayText}\n </TypographyComponent>\n )}\n </div>\n {/* 编辑按钮 */}\n {editable && (\n <div\n className={names(`${prefixCls}-edit-icon`, classNames?.editIcon)}\n style={styleNames?.editIcon}\n title={t('components.EditableText.edit')}\n onClick={() => handleEditingChange(true)}\n >\n {editIcon ?? <EditOutlined />}\n </div>\n )}\n </Flex>\n )}\n </div>\n );\n};\n\ntype EditableTextInterface = typeof EditableText & {\n getEllipsisConfig: typeof getEllipsisConfig;\n};\n\nEditableText.getEllipsisConfig = getEllipsisConfig;\n\nexport default EditableText as EditableTextInterface;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAgE;AAChE,kBAAiD;AAMjD,wBAAkB;AAClB,mBAA6B;AAC7B,kBAAiB;AACjB,kBAAoF;AACpF,mBAAqB;AAErB,IAAM,oBAAoB,CAAC,aAAoD;AAAA,EAC7E,SAAS;AAAA,IACP,OAAO;AAAA,IACP,cAAc,EAAE,UAAU,IAAI;AAAA,EAChC;AACF;AAgKA,IAAM,eAAe,CAKnB,UACG;AACH,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,OAAO;AAAA,IACP,aAAa;AAAA,IACb,WAAW;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ,CAAC;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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AAO,yCAAY;AAAA,UACnB,OAAO,EAAE,8BAA8B;AAAA,UACvC,SAAS,MAAM,oBAAoB,IAAI;AAAA;AAAA,QAEtC,YAAY,6BAAAF,QAAA,cAAC,+BAAa;AAAA,MAC7B;AAAA,IAEJ,CAEJ;AAAA,EACF;AACF;AAMA,aAAa,oBAAoB;AAEjC,IAAO,uBAAQ;",
|
|
6
6
|
"names": ["useStyle", "useT", "React", "editing", "names", "EditableTextForm"]
|
|
7
7
|
}
|
|
@@ -19,12 +19,12 @@ export type LoadingProps = SpinProps & {
|
|
|
19
19
|
* animation
|
|
20
20
|
* - **CN:** 在独立使用时,设置动画遮罩父容器的样式类名
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
rootClassName?: string;
|
|
23
23
|
/**
|
|
24
24
|
* - **EN:** When used independently, set the style for the mask parent container of the animation
|
|
25
25
|
* - **CN:** 在独立使用时,设置动画遮罩父容器的样式
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
rootStyle?: CSSProperties;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* **EN:** Page loading animation component, providing two usage methods:
|
|
@@ -39,9 +39,9 @@ var import_style = __toESM(require("./style"));
|
|
|
39
39
|
var Loading = (props) => {
|
|
40
40
|
const {
|
|
41
41
|
prefixCls: prefixClsInProps,
|
|
42
|
-
maskClassName,
|
|
43
|
-
maskStyle,
|
|
44
42
|
mode = "flex",
|
|
43
|
+
rootClassName,
|
|
44
|
+
rootStyle,
|
|
45
45
|
children,
|
|
46
46
|
spinning = true,
|
|
47
47
|
className,
|
|
@@ -67,10 +67,10 @@ var Loading = (props) => {
|
|
|
67
67
|
hashId,
|
|
68
68
|
cssVarCls,
|
|
69
69
|
prefixCls,
|
|
70
|
-
|
|
70
|
+
rootClassName,
|
|
71
71
|
mode === "absolute" ? `${prefixCls}-absolute` : `${prefixCls}-flex`
|
|
72
72
|
),
|
|
73
|
-
style:
|
|
73
|
+
style: rootStyle
|
|
74
74
|
},
|
|
75
75
|
/* @__PURE__ */ React.createElement(import_antd.Spin, { className, spinning, ...spinProps })
|
|
76
76
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/Loading/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { type CSSProperties, type FC, useContext } from 'react';\nimport type { SpinProps } from 'antd';\nimport { ConfigProvider, Spin } from 'antd';\nimport classNames from 'classnames';\nimport useStyle from './style';\n\nexport type LoadingProps = SpinProps & {\n /**\n * - **EN:** When used independently, the positioning method of the animation:\n * - **absolute** - Uses absolute positioning, and the animation will automatically center itself\n * within the parent container.\n * - **flex** - Uses flexbox layout, and the animation will automatically fill the parent container\n * and center itself.\n * - **CN:** 独立使用时,动画的定位方式:\n * - **absolute** - 使用绝对定位,动画会自动居中显示在父容器中。\n * - **flex** - 使用弹性布局,动画会自动填充父容器并居中显示。\n *\n * @default `flex`\n */\n mode?: 'absolute' | 'flex';\n /**\n * - **EN:** When used independently, set the class name for the mask parent container of the\n * animation\n * - **CN:** 在独立使用时,设置动画遮罩父容器的样式类名\n */\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwD;AAExD,kBAAqC;AACrC,wBAAuB;AACvB,mBAAqB;AAiErB,IAAM,UAA4B,CAAC,UAAU;AAC3C,QAAM;AAAA,IACJ,WAAW;AAAA,IACX;AAAA,
|
|
4
|
+
"sourcesContent": ["import { type CSSProperties, type FC, useContext } from 'react';\nimport type { SpinProps } from 'antd';\nimport { ConfigProvider, Spin } from 'antd';\nimport classNames from 'classnames';\nimport useStyle from './style';\n\nexport type LoadingProps = SpinProps & {\n /**\n * - **EN:** When used independently, the positioning method of the animation:\n * - **absolute** - Uses absolute positioning, and the animation will automatically center itself\n * within the parent container.\n * - **flex** - Uses flexbox layout, and the animation will automatically fill the parent container\n * and center itself.\n * - **CN:** 独立使用时,动画的定位方式:\n * - **absolute** - 使用绝对定位,动画会自动居中显示在父容器中。\n * - **flex** - 使用弹性布局,动画会自动填充父容器并居中显示。\n *\n * @default `flex`\n */\n mode?: 'absolute' | 'flex';\n /**\n * - **EN:** When used independently, set the class name for the mask parent container of the\n * animation\n * - **CN:** 在独立使用时,设置动画遮罩父容器的样式类名\n */\n rootClassName?: string;\n /**\n * - **EN:** When used independently, set the style for the mask parent container of the animation\n * - **CN:** 在独立使用时,设置动画遮罩父容器的样式\n */\n rootStyle?: CSSProperties;\n};\n\n/**\n * **EN:** Page loading animation component, providing two usage methods:\n *\n * - **Spin** - When the component wraps children, it wraps the `Spin` component around the children\n * to provide animation effects.\n * - **Independent** - Directly render a loading animation that automatically fills the parent\n * container and is centered.\n *\n * **CN:** 页面加载动画组件,提供两种使用方式:\n *\n * - **Spin** - 组件包裹children时,在children外层包裹 `Spin` 组件,提供动画效果。\n * - **独立使用** - 直接渲染一个加载动画,自动撑满父容器,且显示在居中位置。\n *\n * @example\n * 1. Spin surrounding children\n *\n * ```tsx\n * <PageLoading spinning={loading}>\n * <div>This is content</div>\n * </PageLoading>;\n * ```\n *\n * 2. Independent usage (inline layout)\n *\n * ```tsx\n * <PageLoading />;\n * ```\n *\n * 3. Centered display within container (absolute layout)\n *\n * ```tsx\n * <div className=\"container\" style={{ position: 'relative' }}>\n * <PageLoading absolute />\n * </div>;\n * ```\n */\nconst Loading: FC<LoadingProps> = (props) => {\n const {\n prefixCls: prefixClsInProps,\n mode = 'flex',\n rootClassName,\n rootStyle,\n children,\n spinning = true,\n className,\n ...spinProps\n } = props;\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-loading', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n\n return children\n ? // Use spin to wrap children when children is provided,\n // and control the animation display with the spinning prop.\n wrapCSSVar(\n <Spin className={classNames(hashId, cssVarCls, prefixCls, className)} spinning={spinning} {...spinProps}>\n {children}\n </Spin>\n )\n : // Show the loading animation in a wrapper that fills the parent container and centers the animation,\n // and hides the entire component when the animation is off.\n spinning &&\n wrapCSSVar(\n <div\n className={classNames(\n hashId,\n cssVarCls,\n prefixCls,\n rootClassName,\n mode === 'absolute' ? `${prefixCls}-absolute` : `${prefixCls}-flex`\n )}\n style={rootStyle}\n >\n <Spin className={className} spinning={spinning} {...spinProps} />\n </div>\n );\n};\n\nexport default Loading;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwD;AAExD,kBAAqC;AACrC,wBAAuB;AACvB,mBAAqB;AAiErB,IAAM,UAA4B,CAAC,UAAU;AAC3C,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,EAAE,aAAa,QAAI,yBAAW,2BAAe,aAAa;AAChE,QAAM,YAAY,aAAa,gBAAgB,gBAAgB;AAC/D,QAAM,CAAC,YAAY,QAAQ,SAAS,QAAI,aAAAA,SAAS,SAAS;AAE1D,SAAO;AAAA;AAAA;AAAA,IAGH;AAAA,MACE,oCAAC,oBAAK,eAAW,kBAAAC,SAAW,QAAQ,WAAW,WAAW,SAAS,GAAG,UAAqB,GAAG,aAC3F,QACH;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAGA,YACE;AAAA,MACE;AAAA,QAAC;AAAA;AAAA,UACC,eAAW,kBAAAA;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS,aAAa,GAAG,uBAAuB,GAAG;AAAA,UACrD;AAAA,UACA,OAAO;AAAA;AAAA,QAEP,oCAAC,oBAAK,WAAsB,UAAqB,GAAG,WAAW;AAAA,MACjE;AAAA,IACF;AAAA;AACR;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": ["useStyle", "classNames"]
|
|
7
7
|
}
|