@tiny-codes/react-easy 1.1.2 → 1.2.0
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 +24 -0
- package/es/components/BreakLines/index.d.ts +13 -19
- package/es/components/BreakLines/index.js +2 -3
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ConfigProvider/context.d.ts +20 -26
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.d.ts +5 -7
- package/es/components/ConfigProvider/index.js +2 -3
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.d.ts +66 -89
- package/es/components/ConfirmAction/index.js +27 -18
- package/es/components/ConfirmAction/index.js.map +1 -1
- 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 +2 -3
- package/es/components/DeleteConfirmAction/index.js +8 -12
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/EditableText/form.d.ts +150 -0
- package/es/components/EditableText/form.js +359 -0
- package/es/components/EditableText/form.js.map +1 -0
- package/es/components/EditableText/index.d.ts +160 -0
- package/es/components/EditableText/index.js +222 -0
- package/es/components/EditableText/index.js.map +1 -0
- package/es/components/EditableText/style/index.d.ts +3 -0
- package/es/components/EditableText/style/index.js +76 -0
- package/es/components/EditableText/style/index.js.map +1 -0
- package/es/components/FloatDrawer/index.d.ts +89 -86
- package/es/components/FloatDrawer/index.js +43 -20
- package/es/components/FloatDrawer/index.js.map +1 -1
- package/es/components/FloatDrawer/style/index.js +42 -21
- package/es/components/FloatDrawer/style/index.js.map +1 -1
- package/es/components/Loading/index.d.ts +9 -14
- package/es/components/Loading/index.js +7 -6
- package/es/components/Loading/index.js.map +1 -1
- package/es/components/Loading/style/index.js +1 -1
- package/es/components/Loading/style/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +98 -139
- package/es/components/ModalAction/index.js +25 -37
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/OverflowTags/index.d.ts +30 -8
- package/es/components/OverflowTags/index.js +26 -7
- package/es/components/OverflowTags/index.js.map +1 -1
- package/es/components/OverflowTags/style/index.js +1 -1
- package/es/components/OverflowTags/style/index.js.map +1 -1
- package/es/components/index.d.ts +4 -0
- package/es/components/index.js +2 -0
- package/es/components/index.js.map +1 -1
- package/es/hooks/useRefFunction.d.ts +4 -5
- package/es/hooks/useRefFunction.js +6 -7
- package/es/hooks/useRefFunction.js.map +1 -1
- package/es/hooks/useRefValue.d.ts +2 -3
- package/es/hooks/useRefValue.js +2 -3
- package/es/hooks/useRefValue.js.map +1 -1
- package/es/hooks/useT.js +1 -2
- package/es/hooks/useT.js.map +1 -1
- package/es/hooks/useValidator.d.ts +2 -3
- package/es/hooks/useValidator.js +2 -3
- package/es/hooks/useValidator.js.map +1 -1
- package/es/hooks/useValidatorBuilder.d.ts +41 -61
- package/es/hooks/useValidatorBuilder.js +4 -6
- package/es/hooks/useValidatorBuilder.js.map +1 -1
- package/es/hooks/useValidators.d.ts +62 -83
- package/es/hooks/useValidators.js +3 -4
- package/es/hooks/useValidators.js.map +1 -1
- package/es/locales/index.d.ts +15 -0
- package/es/locales/langs/en-US.d.ts +5 -0
- package/es/locales/langs/en-US.js +5 -0
- package/es/locales/langs/en-US.js.map +1 -1
- package/es/locales/langs/zh-CN.d.ts +5 -0
- package/es/locales/langs/zh-CN.js +5 -0
- package/es/locales/langs/zh-CN.js.map +1 -1
- package/lib/components/BreakLines/index.d.ts +13 -19
- package/lib/components/BreakLines/index.js.map +2 -2
- package/lib/components/ConfigProvider/context.d.ts +20 -26
- package/lib/components/ConfigProvider/context.js.map +2 -2
- package/lib/components/ConfigProvider/index.d.ts +5 -7
- package/lib/components/ConfigProvider/index.js.map +2 -2
- package/lib/components/ConfirmAction/index.d.ts +66 -89
- package/lib/components/ConfirmAction/index.js +9 -0
- package/lib/components/ConfirmAction/index.js.map +2 -2
- 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 +2 -3
- package/lib/components/DeleteConfirmAction/index.js.map +2 -2
- package/lib/components/EditableText/form.d.ts +150 -0
- package/lib/components/EditableText/form.js +253 -0
- package/lib/components/EditableText/form.js.map +7 -0
- package/lib/components/EditableText/index.d.ts +160 -0
- package/lib/components/EditableText/index.js +181 -0
- package/lib/components/EditableText/index.js.map +7 -0
- package/lib/components/EditableText/style/index.d.ts +3 -0
- package/lib/components/EditableText/style/index.js +118 -0
- package/lib/components/EditableText/style/index.js.map +7 -0
- package/lib/components/FloatDrawer/index.d.ts +89 -86
- package/lib/components/FloatDrawer/index.js +64 -39
- package/lib/components/FloatDrawer/index.js.map +2 -2
- package/lib/components/FloatDrawer/style/index.js +60 -23
- package/lib/components/FloatDrawer/style/index.js.map +2 -2
- package/lib/components/Loading/index.d.ts +9 -14
- package/lib/components/Loading/index.js +13 -4
- package/lib/components/Loading/index.js.map +2 -2
- package/lib/components/Loading/style/index.js +1 -1
- package/lib/components/Loading/style/index.js.map +2 -2
- package/lib/components/ModalAction/index.d.ts +98 -139
- package/lib/components/ModalAction/index.js.map +2 -2
- package/lib/components/OverflowTags/index.d.ts +30 -8
- package/lib/components/OverflowTags/index.js +7 -5
- package/lib/components/OverflowTags/index.js.map +2 -2
- package/lib/components/OverflowTags/style/index.js +1 -1
- package/lib/components/OverflowTags/style/index.js.map +2 -2
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +6 -0
- package/lib/components/index.js.map +2 -2
- package/lib/hooks/useRefFunction.d.ts +4 -5
- package/lib/hooks/useRefFunction.js.map +2 -2
- package/lib/hooks/useRefValue.d.ts +2 -3
- package/lib/hooks/useRefValue.js.map +2 -2
- package/lib/hooks/useT.js.map +2 -2
- package/lib/hooks/useValidator.d.ts +2 -3
- package/lib/hooks/useValidator.js.map +2 -2
- package/lib/hooks/useValidatorBuilder.d.ts +41 -61
- package/lib/hooks/useValidatorBuilder.js.map +2 -2
- package/lib/hooks/useValidators.d.ts +62 -83
- package/lib/hooks/useValidators.js.map +2 -2
- package/lib/locales/index.d.ts +15 -0
- package/lib/locales/langs/en-US.d.ts +5 -0
- package/lib/locales/langs/en-US.js +5 -0
- package/lib/locales/langs/en-US.js.map +2 -2
- package/lib/locales/langs/zh-CN.d.ts +5 -0
- package/lib/locales/langs/zh-CN.js +5 -0
- package/lib/locales/langs/zh-CN.js.map +2 -2
- package/package.json +3 -2
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { EllipsisConfig } from 'antd/es/typography/Base';
|
|
4
|
+
import type { LinkProps } from 'antd/es/typography/Link';
|
|
5
|
+
import type { ParagraphProps } from 'antd/es/typography/Paragraph';
|
|
6
|
+
import type { TextProps } from 'antd/es/typography/Text';
|
|
7
|
+
import type { TitleProps } from 'antd/es/typography/Title';
|
|
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
|
+
prefixCls?: string;
|
|
12
|
+
/**
|
|
13
|
+
* - **EN:** Custom read-only display text, replacing `value` display
|
|
14
|
+
* - **CN:** 自定义只读显示文本,替代`value`显示
|
|
15
|
+
*
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
displayText?: ReactNode | ((value: V | undefined) => ReactNode);
|
|
19
|
+
/**
|
|
20
|
+
* - **EN:** Another way to customize read-only display text, with higher priority than
|
|
21
|
+
* `displayText`. This method does not support text truncation.
|
|
22
|
+
* - **CN:** 另外一种方式自定义只读显示文本,优先级高于`displayText`,这种方式无文本省略效果
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* - **EN:** Whether to allow editing. If set to `false`, the edit button will not be displayed.
|
|
27
|
+
* - **CN:** 是否允许编辑,如果设置为`false`,则不显示编辑按钮
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
editable?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* - **EN:** Whether to open edit mode.
|
|
34
|
+
* - **CN:** 是否打开编辑模式
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
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
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* - **EN:** Component container class name.
|
|
63
|
+
* - **CN:** 组件容器类名
|
|
64
|
+
*/
|
|
65
|
+
className?: string;
|
|
66
|
+
/**
|
|
67
|
+
* - **EN:** Component container style.
|
|
68
|
+
* - **CN:** 组件容器样式
|
|
69
|
+
*/
|
|
70
|
+
style?: CSSProperties;
|
|
71
|
+
/**
|
|
72
|
+
* - **EN:** Semantic class names.
|
|
73
|
+
* - **CN:** 语义化类名
|
|
74
|
+
*/
|
|
75
|
+
classNames?: {
|
|
76
|
+
/**
|
|
77
|
+
* - **EN:** Read-only text class name
|
|
78
|
+
* - **CN:** 只读文本类名
|
|
79
|
+
*/
|
|
80
|
+
text?: string;
|
|
81
|
+
/**
|
|
82
|
+
* - **EN:** Edit button class name
|
|
83
|
+
* - **CN:** 编辑按钮类名
|
|
84
|
+
*/
|
|
85
|
+
editIcon?: string;
|
|
86
|
+
} & EditableFormProps<V, IT>['classNames'];
|
|
87
|
+
/**
|
|
88
|
+
* - **EN:** After saving with `onOk`, the modified value is passed out through `onChange`
|
|
89
|
+
* - **CN:** 在`onOk`保存后,通过`onChange`把修改后的值传递出去
|
|
90
|
+
*/
|
|
91
|
+
onChange?: (value: V | undefined) => void;
|
|
92
|
+
/**
|
|
93
|
+
* - **EN:** Event triggered when the editing state changes
|
|
94
|
+
* - **CN:** 编辑状态改变事件
|
|
95
|
+
*/
|
|
96
|
+
onEditingChange?: (editing: boolean) => void;
|
|
97
|
+
/**
|
|
98
|
+
* - **EN:** Whether to display as a block-level element, with width 100%
|
|
99
|
+
* - **CN:** 语义化样式
|
|
100
|
+
*/
|
|
101
|
+
styles?: {
|
|
102
|
+
/**
|
|
103
|
+
* - **EN:** Read-only text class name
|
|
104
|
+
* - **CN:** 只读文本类名
|
|
105
|
+
*/
|
|
106
|
+
text?: CSSProperties;
|
|
107
|
+
/**
|
|
108
|
+
* - **EN:** Edit button style
|
|
109
|
+
* - **CN:** 编辑按钮样式
|
|
110
|
+
*/
|
|
111
|
+
editIcon?: CSSProperties;
|
|
112
|
+
} & EditableFormProps<V, IT>['styles'];
|
|
113
|
+
/**
|
|
114
|
+
* - **EN:** Custom component type for rendering the text
|
|
115
|
+
* - **CN:** 自定义设置渲染文本组件的组件类型
|
|
116
|
+
*
|
|
117
|
+
* @default 'Text'
|
|
118
|
+
*/
|
|
119
|
+
textComp?: TT;
|
|
120
|
+
/**
|
|
121
|
+
* - **EN:** Text component props
|
|
122
|
+
* - **CN:** 文本组件属性
|
|
123
|
+
*/
|
|
124
|
+
textProps?: TT extends 'Text' ? TextProps : TT extends 'Paragraph' ? ParagraphProps : TT extends 'Title' ? TitleProps : TT extends 'Link' ? LinkProps : never;
|
|
125
|
+
/**
|
|
126
|
+
* - **EN:** Custom edit icon
|
|
127
|
+
* - **CN:** 自定义编辑图标
|
|
128
|
+
*/
|
|
129
|
+
editIcon?: ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* **EN:** Edit button vertical alignment
|
|
132
|
+
*
|
|
133
|
+
* **CN:** 编辑按钮垂直对齐方式
|
|
134
|
+
*
|
|
135
|
+
* - `start` - align to the top | 顶部对齐
|
|
136
|
+
* - `center` - align to the center | 居中对齐
|
|
137
|
+
* - `end` - align to the bottom | 底部对齐
|
|
138
|
+
* - `baseline` - align to the text baseline, useful when the text has line height set |
|
|
139
|
+
* 与文本基线对齐,在文本设置了行高时会非常有用
|
|
140
|
+
*
|
|
141
|
+
* @default 'center'
|
|
142
|
+
*/
|
|
143
|
+
editIconAlign?: CSSProperties['alignItems'];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* - **EN:** Editable text component, providing a read-only display and an edit mode.
|
|
147
|
+
* - **CN:** 可编辑文本组件,提供只读显示和编辑模式。
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* <EditableText value="Editable Text" onOk={(value) => console.log('Saved value:', value)} />;
|
|
151
|
+
*/
|
|
152
|
+
declare const EditableText: {
|
|
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;
|
|
155
|
+
};
|
|
156
|
+
type EditableTextInterface = typeof EditableText & {
|
|
157
|
+
getEllipsisConfig: typeof getEllipsisConfig;
|
|
158
|
+
};
|
|
159
|
+
declare const _default: EditableTextInterface;
|
|
160
|
+
export default _default;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/EditableText/index.tsx
|
|
30
|
+
var EditableText_exports = {};
|
|
31
|
+
__export(EditableText_exports, {
|
|
32
|
+
default: () => EditableText_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(EditableText_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_antd = require("antd");
|
|
37
|
+
var import_classnames = __toESM(require("classnames"));
|
|
38
|
+
var import_icons = require("@ant-design/icons");
|
|
39
|
+
var import_useT = __toESM(require("../../hooks/useT"));
|
|
40
|
+
var import_form = __toESM(require("./form"));
|
|
41
|
+
var import_style = __toESM(require("./style"));
|
|
42
|
+
var getEllipsisConfig = (content) => ({
|
|
43
|
+
tooltip: {
|
|
44
|
+
title: content,
|
|
45
|
+
overlayStyle: { maxWidth: 500 }
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var EditableText = (props) => {
|
|
49
|
+
const {
|
|
50
|
+
prefixCls: prefixClsInProps,
|
|
51
|
+
value: valueInProps,
|
|
52
|
+
displayText: displayTextInProps,
|
|
53
|
+
editable = true,
|
|
54
|
+
editing = false,
|
|
55
|
+
className = "",
|
|
56
|
+
style = {},
|
|
57
|
+
classNames,
|
|
58
|
+
styles: styleNames,
|
|
59
|
+
block: blockInProps,
|
|
60
|
+
textComp = "Text",
|
|
61
|
+
textProps,
|
|
62
|
+
editIcon,
|
|
63
|
+
editIconAlign = "center",
|
|
64
|
+
children,
|
|
65
|
+
formProps,
|
|
66
|
+
formItemProps,
|
|
67
|
+
inputComp: inputCompInProps,
|
|
68
|
+
inputProps,
|
|
69
|
+
required,
|
|
70
|
+
actionAlign,
|
|
71
|
+
submitProps,
|
|
72
|
+
cancelProps,
|
|
73
|
+
onOk,
|
|
74
|
+
onCancel,
|
|
75
|
+
onChange,
|
|
76
|
+
onEditingChange
|
|
77
|
+
} = props;
|
|
78
|
+
const { getPrefixCls } = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
|
|
79
|
+
const prefixCls = getPrefixCls("easy-editable-text", prefixClsInProps);
|
|
80
|
+
const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
|
|
81
|
+
const t = (0, import_useT.default)();
|
|
82
|
+
const [isEditing, setIsEditing] = (0, import_react.useState)(editing);
|
|
83
|
+
const TypographyComponent = import_antd.Typography[textComp];
|
|
84
|
+
const [value, setValue] = (0, import_react.useState)(valueInProps);
|
|
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;
|
|
88
|
+
const editableRef = import_react.default.useRef(editable);
|
|
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]);
|
|
96
|
+
(0, import_react.useEffect)(() => {
|
|
97
|
+
setValue(valueInProps);
|
|
98
|
+
}, [valueInProps]);
|
|
99
|
+
(0, import_react.useEffect)(() => {
|
|
100
|
+
if (editableRef.current) {
|
|
101
|
+
setIsEditing(editing);
|
|
102
|
+
}
|
|
103
|
+
}, [editing]);
|
|
104
|
+
const handleEditingChange = (editing2) => {
|
|
105
|
+
setIsEditing(editing2);
|
|
106
|
+
onEditingChange == null ? void 0 : onEditingChange(editing2);
|
|
107
|
+
};
|
|
108
|
+
const handleOk = async (val) => {
|
|
109
|
+
try {
|
|
110
|
+
await (onOk == null ? void 0 : onOk(val));
|
|
111
|
+
onChange == null ? void 0 : onChange(val);
|
|
112
|
+
setValue(val);
|
|
113
|
+
handleEditingChange(false);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error(error);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const handleCancel = async () => {
|
|
119
|
+
handleEditingChange(false);
|
|
120
|
+
await (onCancel == null ? void 0 : onCancel());
|
|
121
|
+
};
|
|
122
|
+
return wrapCSSVar(
|
|
123
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(prefixCls, hashId, cssVarCls, className), style }, isEditing ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-edit-mode` }, /* @__PURE__ */ import_react.default.createElement(
|
|
124
|
+
import_form.default,
|
|
125
|
+
{
|
|
126
|
+
prefixCls,
|
|
127
|
+
value,
|
|
128
|
+
required,
|
|
129
|
+
formProps,
|
|
130
|
+
formItemProps,
|
|
131
|
+
inputComp,
|
|
132
|
+
inputProps,
|
|
133
|
+
block: editingBlock,
|
|
134
|
+
classNames,
|
|
135
|
+
styles: styleNames,
|
|
136
|
+
actionAlign,
|
|
137
|
+
submitProps,
|
|
138
|
+
cancelProps,
|
|
139
|
+
onOk: handleOk,
|
|
140
|
+
onCancel: handleCancel
|
|
141
|
+
}
|
|
142
|
+
)) : /* @__PURE__ */ import_react.default.createElement(
|
|
143
|
+
import_antd.Flex,
|
|
144
|
+
{
|
|
145
|
+
className: (0, import_classnames.default)(`${prefixCls}-view-mode`, {
|
|
146
|
+
[`${prefixCls}-single-line`]: textComp !== "Paragraph",
|
|
147
|
+
[`${prefixCls}-has-children`]: !!children,
|
|
148
|
+
[`${prefixCls}-view-mode-block`]: viewBlock
|
|
149
|
+
}),
|
|
150
|
+
align: editIconAlign
|
|
151
|
+
},
|
|
152
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-text-content` }, children ?? /* @__PURE__ */ import_react.default.createElement(
|
|
153
|
+
TypographyComponent,
|
|
154
|
+
{
|
|
155
|
+
...textProps,
|
|
156
|
+
className: (0, import_classnames.default)(classNames == null ? void 0 : classNames.text, classNames == null ? void 0 : classNames.text, textProps == null ? void 0 : textProps.className),
|
|
157
|
+
style: {
|
|
158
|
+
marginBottom: textComp === "Title" ? 0 : void 0,
|
|
159
|
+
// 去掉标题组件的默认下边距
|
|
160
|
+
...(textProps == null ? void 0 : textProps.style) ?? (styleNames == null ? void 0 : styleNames.text)
|
|
161
|
+
},
|
|
162
|
+
ellipsis: (textProps == null ? void 0 : textProps.ellipsis) ?? getEllipsisConfig(displayText)
|
|
163
|
+
},
|
|
164
|
+
displayText
|
|
165
|
+
)),
|
|
166
|
+
editable && /* @__PURE__ */ import_react.default.createElement(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
className: (0, import_classnames.default)(`${prefixCls}-edit-icon`, classNames == null ? void 0 : classNames.editIcon),
|
|
170
|
+
style: styleNames == null ? void 0 : styleNames.editIcon,
|
|
171
|
+
title: t("components.EditableText.edit"),
|
|
172
|
+
onClick: () => handleEditingChange(true)
|
|
173
|
+
},
|
|
174
|
+
editIcon ?? /* @__PURE__ */ import_react.default.createElement(import_icons.EditOutlined, null)
|
|
175
|
+
)
|
|
176
|
+
))
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
EditableText.getEllipsisConfig = getEllipsisConfig;
|
|
180
|
+
var EditableText_default = EditableText;
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/EditableText/index.tsx"],
|
|
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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,EAAE,aAAa,QAAI,yBAAW,2BAAe,aAAa;AAChE,QAAM,YAAY,aAAa,sBAAsB,gBAAgB;AACrE,QAAM,CAAC,YAAY,QAAQ,SAAS,QAAI,aAAAA,SAAS,SAAS;AAC1D,QAAM,QAAI,YAAAC,SAAK;AACf,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAkB,OAAO;AAC3D,QAAM,sBAAsB,uBAAW,QAAQ;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,YAAY;AAC/C,QAAM,YAAY,qBAAqB,aAAa,cAAc,aAAa;AAC/E,QAAM,YAAY,OAAO,i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A;AAAA,IACZ,CACF,IAEA,6BAAAH,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,kBAAAE,SAAM,GAAG,uBAAuB;AAAA,UACzC,CAAC,GAAG,uBAAuB,GAAG,aAAa;AAAA,UAC3C,CAAC,GAAG,wBAAwB,GAAG,CAAC,CAAC;AAAA,UACjC,CAAC,GAAG,2BAA2B,GAAG;AAAA,QACpC,CAAC;AAAA,QACD,OAAO;AAAA;AAAA,MAEP,6BAAAF,QAAA,cAAC,SAAI,WAAW,GAAG,4BAChB,YACC,6BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UAEE,GAAI;AAAA,UACL,eAAW,kBAAAE,SAAM,yCAAY,MAAM,yCAAY,MAAM,uCAAW,SAAS;AAAA,UACzE,OAAO;AAAA,YACL,cAAc,aAAa,UAAU,IAAI;AAAA;AAAA,YACzC,IAAI,uCAAW,WAAS,yCAAY;AAAA,UACtC;AAAA,UACA,WAAU,uCAAW,aAAY,kBAAkB,WAAW;AAAA;AAAA,QAE7D;AAAA,MACH,CAEJ;AAAA,MAEC,YACC,6BAAAF,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,eAAW,kBAAAE,SAAM,GAAG,uBAAuB,yCAAY,QAAQ;AAAA,UAC/D,OAAO,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
|
+
"names": ["useStyle", "useT", "React", "editing", "names", "EditableTextForm"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: (prefixCls: string, rootCls?: string | undefined) => readonly [(node: import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, string, string];
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/components/EditableText/style/index.ts
|
|
20
|
+
var style_exports = {};
|
|
21
|
+
__export(style_exports, {
|
|
22
|
+
default: () => style_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(style_exports);
|
|
25
|
+
var import_internal = require("antd/es/theme/internal");
|
|
26
|
+
var genStyle = (token) => {
|
|
27
|
+
const { componentCls, antCls, iconCls } = token;
|
|
28
|
+
return {
|
|
29
|
+
[componentCls]: {
|
|
30
|
+
width: "100%",
|
|
31
|
+
lineHeight: 1,
|
|
32
|
+
[`${componentCls}-view-mode`]: {
|
|
33
|
+
display: "inline-flex",
|
|
34
|
+
width: "auto",
|
|
35
|
+
maxWidth: "100%",
|
|
36
|
+
columnGap: 8,
|
|
37
|
+
"&-block": {
|
|
38
|
+
display: "flex"
|
|
39
|
+
},
|
|
40
|
+
[`${componentCls}-text-content`]: {
|
|
41
|
+
flex: "auto",
|
|
42
|
+
minWidth: 0
|
|
43
|
+
},
|
|
44
|
+
[`${componentCls}-edit-icon`]: {
|
|
45
|
+
display: "inline-flex",
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
flex: "none",
|
|
48
|
+
color: token.colorTextSecondary,
|
|
49
|
+
fontSize: token.fontSize,
|
|
50
|
+
// lineHeight: token.lineHeight,
|
|
51
|
+
// height: token.fontSize * token.lineHeight, // The height of the button should match the line height of the text, so that when the button is at the bottom, it aligns with the text baseline
|
|
52
|
+
cursor: "pointer",
|
|
53
|
+
"&:hover": {
|
|
54
|
+
color: token.colorPrimary
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// '&.${componentCls}-has-children': {
|
|
58
|
+
// '.edit-icon': {
|
|
59
|
+
// lineHeight: 0,
|
|
60
|
+
// height: 'auto', // When custom children are used, the height of the edit button should adapt automatically, rather than being set according to the Typography line height
|
|
61
|
+
// },
|
|
62
|
+
// },
|
|
63
|
+
},
|
|
64
|
+
[`${componentCls}-edit-mode`]: {
|
|
65
|
+
width: "100%",
|
|
66
|
+
[`${componentCls}-form`]: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
[`${antCls}-form`]: {
|
|
69
|
+
display: "flex",
|
|
70
|
+
flexWrap: "nowrap",
|
|
71
|
+
width: "100%",
|
|
72
|
+
[`${antCls}-form-item`]: {
|
|
73
|
+
[`&${antCls}-form-item-block`]: {
|
|
74
|
+
flex: 1
|
|
75
|
+
},
|
|
76
|
+
[`input${antCls}-input`]: {
|
|
77
|
+
minWidth: 100,
|
|
78
|
+
transition: "all 0.2s, width 0s"
|
|
79
|
+
},
|
|
80
|
+
[`textarea${antCls}-input`]: {
|
|
81
|
+
minWidth: 100,
|
|
82
|
+
transition: "all 0.2s, width 0s"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
[`${componentCls}-form-btns`]: {
|
|
86
|
+
flex: "none",
|
|
87
|
+
lineHeight: 0,
|
|
88
|
+
[`${componentCls}-form-btn`]: {
|
|
89
|
+
width: 20,
|
|
90
|
+
height: 20,
|
|
91
|
+
padding: 0,
|
|
92
|
+
fontSize: 20,
|
|
93
|
+
lineHeight: 1,
|
|
94
|
+
[iconCls]: {
|
|
95
|
+
fontSize: 20
|
|
96
|
+
},
|
|
97
|
+
[`&${componentCls}-form-btn-save:not(:disabled)`]: {
|
|
98
|
+
color: token.colorSuccess,
|
|
99
|
+
"&:hover": {
|
|
100
|
+
color: token.colorSuccessActive
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
[`&${componentCls}-form-btn-close:not(:disabled)`]: {
|
|
104
|
+
color: token.colorError,
|
|
105
|
+
"&:hover": {
|
|
106
|
+
color: token.colorErrorActive
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
var style_default = (0, import_internal.genStyleHooks)("EasyEditableText", genStyle);
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/EditableText/style/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { genStyleHooks } from 'antd/es/theme/internal';\nimport type { AliasToken, GenerateStyle } from 'antd/es/theme/internal';\nimport type { CSSObject } from '@ant-design/cssinjs';\nimport type { FullToken } from '@ant-design/cssinjs-utils';\n\ntype EditableTextToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<EditableTextToken> = (token): CSSObject => {\n const { componentCls, antCls, iconCls } = token;\n return {\n [componentCls]: {\n width: '100%',\n lineHeight: 1,\n\n [`${componentCls}-view-mode`]: {\n display: 'inline-flex',\n width: 'auto',\n maxWidth: '100%',\n columnGap: 8,\n '&-block': {\n display: 'flex',\n },\n\n [`${componentCls}-text-content`]: {\n flex: 'auto',\n minWidth: 0,\n },\n\n [`${componentCls}-edit-icon`]: {\n display: 'inline-flex',\n alignItems: 'center',\n flex: 'none',\n color: token.colorTextSecondary,\n fontSize: token.fontSize,\n // lineHeight: token.lineHeight,\n // height: token.fontSize * token.lineHeight, // The height of the button should match the line height of the text, so that when the button is at the bottom, it aligns with the text baseline\n cursor: 'pointer',\n '&:hover': {\n color: token.colorPrimary,\n },\n },\n // '&.${componentCls}-has-children': {\n // '.edit-icon': {\n // lineHeight: 0,\n // height: 'auto', // When custom children are used, the height of the edit button should adapt automatically, rather than being set according to the Typography line height\n // },\n // },\n },\n\n [`${componentCls}-edit-mode`]: {\n width: '100%',\n\n [`${componentCls}-form`]: {\n display: 'flex',\n [`${antCls}-form`]: {\n display: 'flex',\n flexWrap: 'nowrap',\n width: '100%',\n\n [`${antCls}-form-item`]: {\n [`&${antCls}-form-item-block`]: {\n flex: 1,\n },\n [`input${antCls}-input`]: {\n minWidth: 100,\n transition: 'all 0.2s, width 0s',\n },\n [`textarea${antCls}-input`]: {\n minWidth: 100,\n transition: 'all 0.2s, width 0s',\n },\n },\n [`${componentCls}-form-btns`]: {\n flex: 'none',\n lineHeight: 0,\n\n [`${componentCls}-form-btn`]: {\n width: 20,\n height: 20,\n padding: 0,\n fontSize: 20,\n lineHeight: 1,\n\n [iconCls]: {\n fontSize: 20,\n },\n\n [`&${componentCls}-form-btn-save:not(:disabled)`]: {\n color: token.colorSuccess,\n\n '&:hover': {\n color: token.colorSuccessActive,\n },\n },\n\n [`&${componentCls}-form-btn-close:not(:disabled)`]: {\n color: token.colorError,\n\n '&:hover': {\n color: token.colorErrorActive,\n },\n },\n },\n },\n },\n },\n },\n },\n };\n};\n\nexport default genStyleHooks('EasyEditableText' as never, genStyle);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,WAA6C,CAA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