@tiny-codes/react-easy 1.7.6 → 1.7.7
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 +15 -1
- package/es/components/ColumnSetting/index.js +2 -1
- package/es/components/ColumnSetting/index.js.map +1 -1
- package/es/components/ConfigProvider/context.d.ts +36 -0
- package/es/components/ConfigProvider/context.js +1 -0
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.d.ts +5 -3
- package/es/components/ConfigProvider/index.js +13 -8
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfigProvider/style/index.js +1 -1
- package/es/components/ConfigProvider/style/index.js.map +1 -1
- package/es/components/ContextMenu/index.js +3 -2
- package/es/components/ContextMenu/index.js.map +1 -1
- package/es/components/ContextMenu/style/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +3 -3
- package/es/components/EditableText/index.js +3 -2
- package/es/components/EditableText/index.js.map +1 -1
- package/es/components/FloatDrawer/index.js +3 -2
- package/es/components/FloatDrawer/index.js.map +1 -1
- package/es/components/FloatDrawer/style/index.js +1 -1
- package/es/components/FloatDrawer/style/index.js.map +1 -1
- package/es/components/Iconfont/createIconfont.d.ts +28 -0
- package/es/components/Iconfont/createIconfont.js +57 -0
- package/es/components/Iconfont/createIconfont.js.map +1 -0
- package/es/components/Iconfont/index.d.ts +1 -0
- package/es/components/Iconfont/index.js +2 -0
- package/es/components/Iconfont/index.js.map +1 -0
- package/es/components/Loading/index.js +3 -2
- 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/OverflowTags/index.js +3 -2
- 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 +1 -0
- package/es/components/index.js +1 -0
- package/es/components/index.js.map +1 -1
- package/es/hooks/style/useSplitter.d.ts +3 -0
- package/es/hooks/style/useSplitter.js +40 -0
- package/es/hooks/style/useSplitter.js.map +1 -0
- package/es/hooks/useSplitter.d.ts +52 -9
- package/es/hooks/useSplitter.js +69 -39
- package/es/hooks/useSplitter.js.map +1 -1
- package/lib/components/ColumnSetting/index.js +2 -1
- package/lib/components/ColumnSetting/index.js.map +3 -3
- package/lib/components/ConfigProvider/context.d.ts +36 -0
- package/lib/components/ConfigProvider/context.js +1 -0
- package/lib/components/ConfigProvider/context.js.map +2 -2
- package/lib/components/ConfigProvider/index.d.ts +5 -3
- package/lib/components/ConfigProvider/index.js +6 -2
- package/lib/components/ConfigProvider/index.js.map +2 -2
- package/lib/components/ConfigProvider/style/index.js +1 -1
- package/lib/components/ConfigProvider/style/index.js.map +2 -2
- package/lib/components/ContextMenu/index.js +2 -1
- package/lib/components/ContextMenu/index.js.map +3 -3
- package/lib/components/ContextMenu/style/index.js.map +2 -2
- package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +3 -3
- package/lib/components/EditableText/index.js +3 -2
- package/lib/components/EditableText/index.js.map +3 -3
- package/lib/components/FloatDrawer/index.js +3 -2
- package/lib/components/FloatDrawer/index.js.map +3 -3
- package/lib/components/FloatDrawer/style/index.js +1 -1
- package/lib/components/FloatDrawer/style/index.js.map +2 -2
- package/lib/components/Iconfont/createIconfont.d.ts +28 -0
- package/lib/components/Iconfont/createIconfont.js +65 -0
- package/lib/components/Iconfont/createIconfont.js.map +7 -0
- package/lib/components/Iconfont/index.d.ts +1 -0
- package/lib/components/Iconfont/index.js +24 -0
- package/lib/components/Iconfont/index.js.map +7 -0
- package/lib/components/Loading/index.js +3 -2
- package/lib/components/Loading/index.js.map +3 -3
- package/lib/components/Loading/style/index.js +1 -1
- package/lib/components/Loading/style/index.js.map +2 -2
- package/lib/components/OverflowTags/index.js +3 -2
- package/lib/components/OverflowTags/index.js.map +3 -3
- 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 +1 -0
- package/lib/components/index.js +3 -1
- package/lib/components/index.js.map +2 -2
- package/lib/hooks/style/useSplitter.d.ts +3 -0
- package/lib/hooks/style/useSplitter.js +72 -0
- package/lib/hooks/style/useSplitter.js.map +7 -0
- package/lib/hooks/useSplitter.d.ts +52 -9
- package/lib/hooks/useSplitter.js +56 -26
- package/lib/hooks/useSplitter.js.map +3 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ColumnSetting/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useContext, useEffect, useMemo, useState } from 'react';\nimport { Button, Checkbox,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyD;AACzD,
|
|
6
|
-
"names": ["useStyle", "useT", "useLocalStorage", "classNames"]
|
|
4
|
+
"sourcesContent": ["import { useContext, useEffect, useMemo, useState } from 'react';\nimport { Button, Checkbox, Divider, Dropdown, Space, Typography } from 'antd';\nimport type { ButtonProps, DropdownProps } from 'antd';\nimport type { ColumnType } from 'antd/es/table';\nimport classNames from 'classnames';\nimport { ReloadOutlined, SettingOutlined } from '@ant-design/icons';\nimport { useRefFunction, useRefValue } from '../../hooks';\nimport useLocalStorage from '../../hooks/useLocalStorage';\nimport useT from '../../hooks/useT';\nimport ConfigProvider from '../ConfigProvider';\nimport useStyle from './style';\n\nexport interface ColumnSettingProps<T extends ColumnSettingItem = ColumnSettingItem> {\n /**\n * - **EN:** The columns to be displayed in the column setting.\n * - **CN:** 列设置中要显示的列。\n */\n columns: T[];\n /**\n * - **EN:** Callback function triggered when the selected columns change.\n * - **CN:** 选中列变化时触发的回调函数。\n */\n onChange?: (nextColumns: T[]) => void;\n /**\n * - **EN:** Set a local storage key for persisting column settings. If not set, local storage is\n * not enabled.\n * - **CN:** 设置一个本地存储的键值,用于持久化保存列设置。如果未设置,则不启用本地存储。\n */\n storageKey?: string;\n /**\n * - **EN:** Function to render custom column titles.\n * - **CN:** 自定义列标题的渲染函数。\n */\n renderColumnTitle?: (col: ColumnSettingItem, index: number) => React.ReactNode;\n /**\n * - **EN:** Props for the button that triggers the dropdown.\n * - **CN:** 触发下拉菜单的按钮属性。\n */\n triggerProps?: ButtonProps;\n /**\n * - **EN:** Props for the dropdown component.\n * - **CN:** 下拉菜单组件的属性。\n */\n dropdownProps?: DropdownProps;\n /**\n * - **EN:** Props for the dropdown popup container.\n * - **CN:** 下拉菜单弹出层容器的属性。\n */\n popupProps?: React.HTMLAttributes<HTMLDivElement>;\n /**\n * - **EN:** Props for the \"Check All\" button.\n * - **CN:** “全选”按钮的属性。\n */\n checkAllProps?: ButtonProps;\n /**\n * - **EN:** Props for the \"Reset\" button.\n * - **CN:** “重置”按钮的属性。\n */\n resetProps?: ButtonProps;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n}\n\n/**\n * - **EN:** A component for configuring table column visibility.\n * - **CN:** 用于配置表格列可见性的组件。\n */\nfunction ColumnSetting<T extends ColumnSettingItem = ColumnSettingItem>(props: ColumnSettingProps<T>) {\n const {\n columns,\n storageKey,\n triggerProps,\n dropdownProps,\n popupProps,\n prefixCls: prefixClsInProps,\n checkAllProps,\n resetProps,\n onChange,\n renderColumnTitle,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('column-setting', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [open, setOpen] = useState(false);\n const t = useT();\n const [selectedKeysFromStorage, setSelectedKeysFromStorage] = useLocalStorage<string[]>(storageKey, []);\n const [initialKeys, setInitialKeys] = useState<string[]>(selectedKeysFromStorage ?? []);\n const [selectedKeys, setSelectedKeys] = useState<string[]>(initialKeys);\n const storageRef = useRefValue(storageKey);\n const selectedKeysFromStorageRef = useRefValue(selectedKeysFromStorage);\n const hasChange = useMemo(() => {\n return [...selectedKeys].sort().join(',') !== initialKeys.join(',');\n }, [selectedKeys, initialKeys]);\n\n // Compute keys and selectable keys\n const keys = useMemo(() => columns.map((c, i) => String(getColKey(c, i))), [columns]);\n const allSelectableKeys = useMemo(\n () =>\n columns\n .map((c, i) => ({ k: String(getColKey(c, i)), disabled: !!c.disabled }))\n .filter((x) => !x.disabled)\n .map((x) => x.k),\n [columns]\n );\n const isAllChecked = allSelectableKeys.length > 0 && allSelectableKeys.every((k) => selectedKeys.includes(k));\n const isIndeterminate = selectedKeys.length > 0 && !isAllChecked;\n\n // Fire change event when selectedKeysFromStorage changes\n const change = useRefFunction((nextSelected: string[], fireEvent?: boolean) => {\n setSelectedKeys(nextSelected);\n if (storageKey) {\n setSelectedKeysFromStorage(nextSelected);\n }\n if (fireEvent) {\n const next = columns.map((col, i) => {\n const k = String(getColKey(col, i));\n const visible = nextSelected.includes(k);\n return { ...col, hidden: !visible } as T;\n });\n onChange?.(next as T[]);\n }\n });\n\n // Toggle one column change\n const toggleOne = (key: string, checked: boolean) => {\n const next = new Set(selectedKeys);\n if (checked) {\n next.add(key);\n } else {\n // Keep at least one visible column\n if (selectedKeys.length <= 1) return;\n next.delete(key);\n }\n const nextArr = Array.from(next);\n change(nextArr, true);\n };\n\n // Toggle all columns change\n const handleCheckAll = (checked: boolean) => {\n const nextArr = checked\n ? Array.from(new Set([...selectedKeys, ...allSelectableKeys]))\n : selectedKeys.filter((k) => !allSelectableKeys.includes(k)).slice(0, 1);\n const ensured = checked ? nextArr : nextArr.length > 0 ? nextArr : [keys[0]];\n change(ensured, true);\n };\n\n // Reset to initial selected columns\n const handleReset = () => {\n const next = initialKeys.length > 0 ? initialKeys : [keys[0]];\n change(next, true);\n };\n\n const handleOpenChange = (nextOpen: boolean) => {\n setOpen(nextOpen);\n if (nextOpen) {\n setInitialKeys(normalizeToSelectedKeys(columns));\n } else {\n setInitialKeys([]);\n }\n };\n\n // Sync when columns change\n useEffect(() => {\n const next = normalizeToSelectedKeys(columns);\n change(next, false);\n }, [columns]);\n\n // Fire change on mount if storage exists and differs from initial values\n useEffect(() => {\n if (\n storageRef.current &&\n selectedKeysFromStorageRef.current &&\n selectedKeysFromStorageRef.current.join(',') !== initialKeys.join(',')\n ) {\n change(selectedKeysFromStorageRef.current, true);\n }\n }, [initialKeys]);\n\n const dropdownRender = () => (\n <div\n {...popupProps}\n className={classNames(`${prefixCls}-popup`, popupProps?.className)}\n onClick={(e) => {\n e.stopPropagation();\n popupProps?.onClick?.(e);\n }}\n >\n <Typography.Text className={`${prefixCls}-popup-title`}>{t('components.ColumnSetting.title')}</Typography.Text>\n <Space direction=\"vertical\" className={`${prefixCls}-column-list`} size={12}>\n {columns.map((col, idx) => {\n const k = String(getColKey(col, idx));\n const label = col.title ?? col.dataIndex ?? k;\n const checked = selectedKeys.includes(k);\n const disabled = !!col.disabled;\n const disableUncheck = !disabled && checked && selectedKeys.length <= 1; // 禁止取消最后一个\n return (\n <Checkbox\n key={k}\n className={`${prefixCls}-column-item`}\n disabled={disabled || disableUncheck}\n checked={checked}\n onChange={(e) => toggleOne(k, e.target.checked)}\n >\n <span className={`${prefixCls}-column-item-title`}>{renderColumnTitle?.(col, idx) ?? label}</span>\n </Checkbox>\n );\n })}\n </Space>\n <Divider className={`${prefixCls}-divider`} />\n <div className={`${prefixCls}-footer`}>\n <Button\n type=\"text\"\n {...checkAllProps}\n className={classNames(`${prefixCls}-select-all`, checkAllProps?.className)}\n onClick={(e) => {\n handleCheckAll(!isAllChecked);\n checkAllProps?.onClick?.(e);\n }}\n >\n <Checkbox checked={isAllChecked} indeterminate={isIndeterminate}></Checkbox>\n {t('components.ColumnSetting.selectAll')}\n </Button>\n <Button\n type=\"text\"\n icon={<ReloadOutlined />}\n disabled={!hasChange}\n {...resetProps}\n className={classNames(`${prefixCls}-reset`, resetProps?.className)}\n onClick={(e) => {\n handleReset();\n resetProps?.onClick?.(e);\n }}\n >\n {t('components.ColumnSetting.reset')}\n </Button>\n </div>\n </div>\n );\n\n return wrapCSSVar(\n <Dropdown\n open={open}\n onOpenChange={handleOpenChange}\n trigger={['click']}\n dropdownRender={dropdownRender} // To be compatible with lower versions of antd\n popupRender={dropdownRender}\n placement=\"bottomRight\"\n {...dropdownProps}\n rootClassName={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-dropdown`, dropdownProps?.className)}\n >\n <Button\n icon={<SettingOutlined />}\n {...triggerProps}\n className={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-trigger`, triggerProps?.className)}\n />\n </Dropdown>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface ColumnSettingItem<T = any> extends ColumnType<T> {\n /**\n * - **EN:** Disable toggling visibility for this column.\n * - **CN:** 禁止切换此列的可见性。\n */\n disabled?: boolean;\n}\n\nfunction getColKey(col: ColumnType, idx: number): React.Key {\n return col.key ?? (col.dataIndex as string) ?? idx;\n}\n\nfunction normalizeToSelectedKeys(cols: ColumnType[]): string[] {\n return cols\n .map((c, i) => ({ key: String(getColKey(c, i)), hidden: !!c.hidden }))\n .filter((c) => !c.hidden)\n .map((c) => c.key)\n .sort();\n}\n\nexport default ColumnSetting;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyD;AACzD,kBAAuE;AAGvE,wBAAuB;AACvB,mBAAgD;AAChD,mBAA4C;AAC5C,6BAA4B;AAC5B,kBAAiB;AACjB,4BAA2B;AAC3B,mBAAqB;AA4DrB,SAAS,cAA+D,OAA8B;AACpG,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,aAAa,QAAI,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S,wBAAwB,MAA8B;AAC7D,SAAO,KACJ,IAAI,CAAC,GAAG,OAAO,EAAE,KAAK,OAAO,UAAU,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,EACpE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EACvB,IAAI,CAAC,MAAM,EAAE,GAAG,EAChB,KAAK;AACV;AAEA,IAAO,wBAAQ;",
|
|
6
|
+
"names": ["ConfigProvider", "useStyle", "useT", "useLocalStorage", "classNames"]
|
|
7
7
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { Langs } from '../../locales';
|
|
3
|
+
import type { PulseAnimationProps } from '../Animation/Pulse';
|
|
4
|
+
import type { BreakLinesProps } from '../BreakLines';
|
|
5
|
+
import type { ColumnSettingProps } from '../ColumnSetting';
|
|
3
6
|
import type { ConfirmActionProps } from '../ConfirmAction';
|
|
7
|
+
import type { ContextMenuProps } from '../ContextMenu';
|
|
8
|
+
import type { EditableTextProps } from '../EditableText';
|
|
4
9
|
import type { ModalActionProps } from '../ModalAction';
|
|
5
10
|
export interface ReactEasyContextProps {
|
|
11
|
+
getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => string;
|
|
6
12
|
/**
|
|
7
13
|
* - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'
|
|
8
14
|
* - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'
|
|
@@ -20,6 +26,36 @@ export interface ReactEasyContextProps {
|
|
|
20
26
|
* @returns Localized text | 本地化文本
|
|
21
27
|
*/
|
|
22
28
|
localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* - **EN:** Global configuration for `PulseAnimation` component, which can be used to set default
|
|
31
|
+
* animation properties for all `PulseAnimation` components in the application.
|
|
32
|
+
* - **CN:** `PulseAnimation`组件的全局配置,可以用来设置应用中所有`PulseAnimation`组件的默认动画属性。
|
|
33
|
+
*/
|
|
34
|
+
PulseAnimation?: PulseAnimationProps;
|
|
35
|
+
/**
|
|
36
|
+
* - **EN:** Global configuration for `BreakLines` component, which can be used to set default
|
|
37
|
+
* properties for all `BreakLines` components in the application.
|
|
38
|
+
* - **CN:** `BreakLines`组件的全局配置,可以用来设置应用中所有`BreakLines`组件的默认属性。
|
|
39
|
+
*/
|
|
40
|
+
BreakLines?: BreakLinesProps;
|
|
41
|
+
/**
|
|
42
|
+
* - **EN:** Global configuration for `ColumnSetting` component, which can be used to set default
|
|
43
|
+
* properties for all `ColumnSetting` components in the application.
|
|
44
|
+
* - **CN:** `ColumnSetting`组件的全局配置,可以用来设置应用中所有`ColumnSetting`组件的默认属性。
|
|
45
|
+
*/
|
|
46
|
+
ColumnSetting?: ColumnSettingProps;
|
|
47
|
+
/**
|
|
48
|
+
* - **EN:** Global configuration for `ContextMenu` component, which can be used to set default
|
|
49
|
+
* properties for all `ContextMenu` components in the application.
|
|
50
|
+
* - **CN:** `ContextMenu`组件的全局配置,可以用来设置应用中所有`ContextMenu`组件的默认属性。
|
|
51
|
+
*/
|
|
52
|
+
ContextMenu?: ContextMenuProps;
|
|
53
|
+
/**
|
|
54
|
+
* - **EN:** Global configuration for `EditableText` component, which can be used to set default
|
|
55
|
+
* properties for all `EditableText` components in the application.
|
|
56
|
+
* - **CN:** `EditableText`组件的全局配置,可以用来设置应用中所有`EditableText`组件的默认属性。
|
|
57
|
+
*/
|
|
58
|
+
EditableText?: EditableTextProps;
|
|
23
59
|
/**
|
|
24
60
|
* - **EN:** Global configuration for `ConfirmAction` component, which can be used to set default
|
|
25
61
|
* modal title and content for all `ConfirmAction` components in the application.
|
|
@@ -25,6 +25,7 @@ __export(context_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(context_exports);
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var defaultContextValue = {
|
|
28
|
+
getPrefixCls: void 0,
|
|
28
29
|
lang: "en-US"
|
|
29
30
|
};
|
|
30
31
|
var ReactEasyContext = (0, import_react.createContext)(defaultContextValue);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ConfigProvider/context.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext, type ReactNode } from 'react';\nimport type { Langs } from '../../locales';\nimport type { ConfirmActionProps } from '../ConfirmAction';\nimport type { ModalActionProps } from '../ModalAction';\n\nexport interface ReactEasyContextProps {\n /**\n * - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'\n * - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'\n *\n * @default 'en-US'\n */\n lang?: Langs;\n /**\n * - **EN:** Get localized text\n * - **CN:** 获取本地化文本\n *\n * @param key Normal text or key of local resource | 普通文本或本地资源的键值\n * @param args Parameters of the localized text | 本地化文本的参数\n *\n * @returns Localized text | 本地化文本\n */\n localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;\n\n /**\n * - **EN:** Global configuration for `ConfirmAction` component, which can be used to set default\n * modal title and content for all `ConfirmAction` components in the application.\n * - **CN:** `ConfirmAction`组件的全局配置,可以用来设置应用中所有`ConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `ConfirmAction.title` instead */\n defaultConfirmTitle?: ReactNode;\n /** @deprecated Use `ConfirmAction.content` instead */\n defaultConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `DeleteConfirmAction` component, which can be used to set\n * default modal title and content for all `DeleteConfirmAction` components in the application.\n * - **CN:** `DeleteConfirmAction`组件的全局配置,可以用来设置应用中所有`DeleteConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n DeletionConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `DeletionConfirmAction.title` instead */\n defaultDeletionConfirmTitle?: ReactNode;\n /** @deprecated Use `DeletionConfirmAction.content` instead */\n defaultDeletionConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `ModalAction` component, which can be used to set default\n * modal title and content for all `ModalAction` components in the application.\n * - **CN:** `ModalAction`组件的全局配置,可以用来设置应用中所有`ModalAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ModalAction?: Partial<ModalActionProps<any, any, any, any, any>>;\n}\n\nexport const defaultContextValue: ReactEasyContextProps = {\n lang: 'en-US',\n};\n\nconst ReactEasyContext = createContext<ReactEasyContextProps>(defaultContextValue);\n\nexport default ReactEasyContext;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8C;
|
|
4
|
+
"sourcesContent": ["import { createContext, type ReactNode } from 'react';\nimport type { Langs } from '../../locales';\nimport type { PulseAnimationProps } from '../Animation/Pulse';\nimport type { BreakLinesProps } from '../BreakLines';\nimport type { ColumnSettingProps } from '../ColumnSetting';\nimport type { ConfirmActionProps } from '../ConfirmAction';\nimport type { ContextMenuProps } from '../ContextMenu';\nimport type { EditableTextProps } from '../EditableText';\nimport type { ModalActionProps } from '../ModalAction';\n\nexport interface ReactEasyContextProps {\n getPrefixCls: (suffixCls: string, customizePrefixCls?: string) => string;\n /**\n * - **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'\n * - **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'\n *\n * @default 'en-US'\n */\n lang?: Langs;\n /**\n * - **EN:** Get localized text\n * - **CN:** 获取本地化文本\n *\n * @param key Normal text or key of local resource | 普通文本或本地资源的键值\n * @param args Parameters of the localized text | 本地化文本的参数\n *\n * @returns Localized text | 本地化文本\n */\n localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;\n\n /**\n * - **EN:** Global configuration for `PulseAnimation` component, which can be used to set default\n * animation properties for all `PulseAnimation` components in the application.\n * - **CN:** `PulseAnimation`组件的全局配置,可以用来设置应用中所有`PulseAnimation`组件的默认动画属性。\n */\n PulseAnimation?: PulseAnimationProps;\n /**\n * - **EN:** Global configuration for `BreakLines` component, which can be used to set default\n * properties for all `BreakLines` components in the application.\n * - **CN:** `BreakLines`组件的全局配置,可以用来设置应用中所有`BreakLines`组件的默认属性。\n */\n BreakLines?: BreakLinesProps;\n /**\n * - **EN:** Global configuration for `ColumnSetting` component, which can be used to set default\n * properties for all `ColumnSetting` components in the application.\n * - **CN:** `ColumnSetting`组件的全局配置,可以用来设置应用中所有`ColumnSetting`组件的默认属性。\n */\n ColumnSetting?: ColumnSettingProps;\n /**\n * - **EN:** Global configuration for `ContextMenu` component, which can be used to set default\n * properties for all `ContextMenu` components in the application.\n * - **CN:** `ContextMenu`组件的全局配置,可以用来设置应用中所有`ContextMenu`组件的默认属性。\n */\n ContextMenu?: ContextMenuProps;\n /**\n * - **EN:** Global configuration for `EditableText` component, which can be used to set default\n * properties for all `EditableText` components in the application.\n * - **CN:** `EditableText`组件的全局配置,可以用来设置应用中所有`EditableText`组件的默认属性。\n */\n EditableText?: EditableTextProps;\n\n /**\n * - **EN:** Global configuration for `ConfirmAction` component, which can be used to set default\n * modal title and content for all `ConfirmAction` components in the application.\n * - **CN:** `ConfirmAction`组件的全局配置,可以用来设置应用中所有`ConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `ConfirmAction.title` instead */\n defaultConfirmTitle?: ReactNode;\n /** @deprecated Use `ConfirmAction.content` instead */\n defaultConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `DeleteConfirmAction` component, which can be used to set\n * default modal title and content for all `DeleteConfirmAction` components in the application.\n * - **CN:** `DeleteConfirmAction`组件的全局配置,可以用来设置应用中所有`DeleteConfirmAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n DeletionConfirmAction?: ConfirmActionProps<any, never>;\n /** @deprecated Use `DeletionConfirmAction.title` instead */\n defaultDeletionConfirmTitle?: ReactNode;\n /** @deprecated Use `DeletionConfirmAction.content` instead */\n defaultDeletionConfirmContent?: ReactNode;\n\n /**\n * - **EN:** Global configuration for `ModalAction` component, which can be used to set default\n * modal title and content for all `ModalAction` components in the application.\n * - **CN:** `ModalAction`组件的全局配置,可以用来设置应用中所有`ModalAction`组件的默认模态框标题和内容。\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ModalAction?: Partial<ModalActionProps<any, any, any, any, any>>;\n}\n\nexport const defaultContextValue: ReactEasyContextProps = {\n getPrefixCls: undefined!,\n lang: 'en-US',\n};\n\nconst ReactEasyContext = createContext<ReactEasyContextProps>(defaultContextValue);\n\nexport default ReactEasyContext;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8C;AA8FvC,IAAM,sBAA6C;AAAA,EACxD,cAAc;AAAA,EACd,MAAM;AACR;AAEA,IAAM,uBAAmB,4BAAqC,mBAAmB;AAEjF,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties, FC, ReactNode } from 'react';
|
|
2
2
|
import type localesEn from '../../locales/langs/en';
|
|
3
|
-
import { type ReactEasyContextProps } from './context';
|
|
4
|
-
export interface ConfigProviderProps extends ReactEasyContextProps {
|
|
3
|
+
import ReactEasyContext, { type ReactEasyContextProps } from './context';
|
|
4
|
+
export interface ConfigProviderProps extends Omit<ReactEasyContextProps, 'getPrefixCls'> {
|
|
5
5
|
/**
|
|
6
6
|
* - **EN:** Child elements of the ConfigProvider
|
|
7
7
|
* - **CN:** ConfigProvider 的子元素
|
|
@@ -33,5 +33,7 @@ export interface ConfigProviderProps extends ReactEasyContextProps {
|
|
|
33
33
|
* - **EN:** Provide global configuration for AntdHelper
|
|
34
34
|
* - **CN:** 提供AntdHelper的全局配置
|
|
35
35
|
*/
|
|
36
|
-
declare const ConfigProvider: FC<ConfigProviderProps
|
|
36
|
+
declare const ConfigProvider: FC<ConfigProviderProps> & {
|
|
37
|
+
ConfigContext: typeof ReactEasyContext;
|
|
38
|
+
};
|
|
37
39
|
export default ConfigProvider;
|
|
@@ -49,10 +49,13 @@ var ConfigProvider = (props) => {
|
|
|
49
49
|
if (langInProps !== import_locales.default.language) {
|
|
50
50
|
import_locales.default.changeLanguage(langInProps || "en-US");
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
...restProps,
|
|
54
|
+
getPrefixCls: (suffixCls, customizePrefixCls) => getPrefixCls(`easy-${suffixCls}`, customizePrefixCls)
|
|
55
|
+
};
|
|
53
56
|
},
|
|
54
57
|
// eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps
|
|
55
|
-
[langInProps, ...Object.values(restProps)]
|
|
58
|
+
[langInProps, getPrefixCls, ...Object.values(restProps)]
|
|
56
59
|
);
|
|
57
60
|
(0, import_react.useEffect)(() => {
|
|
58
61
|
if (userLocales) {
|
|
@@ -70,5 +73,6 @@ var ConfigProvider = (props) => {
|
|
|
70
73
|
);
|
|
71
74
|
};
|
|
72
75
|
ConfigProvider.displayName = "ReactEasyConfigProvider";
|
|
76
|
+
ConfigProvider.ConfigContext = import_context.default;
|
|
73
77
|
var ConfigProvider_default = ConfigProvider;
|
|
74
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ConfigProvider/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo } from 'react';\nimport { ConfigProvider as ReactConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport locales, { langs, resources } from '../../locales';\nimport type localesEn from '../../locales/langs/en';\nimport ReactEasyContext, { type ReactEasyContextProps } from './context';\nimport useStyle from './style';\n\nexport interface ConfigProviderProps extends ReactEasyContextProps {\n /**\n * - **EN:** Child elements of the ConfigProvider\n * - **CN:** ConfigProvider 的子元素\n */\n children: ReactNode;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Custom class name for the root element\n * - **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom styles for the root element\n * - **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Custom localization resources, if `lang` exists, it will override the localization\n * resources of that language, otherwise, it will add a new language\n * - **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖该语言的本地化资源,否则,会添加一种新的语言\n */\n locales?: Partial<typeof localesEn>;\n}\n\n/**\n * - **EN:** Provide global configuration for AntdHelper\n * - **CN:** 提供AntdHelper的全局配置\n */\nconst ConfigProvider: FC<ConfigProviderProps> = (props) => {\n const { children, locales: userLocales, prefixCls: prefixClsInProps, className, style, ...restProps } = props;\n const { lang: langInProps } = restProps;\n const { getPrefixCls, rootPrefixCls } = useContext(ReactConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('react-easy', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootPrefixCls);\n const contextValue = useMemo(\n () => {\n if (langInProps !== locales.language) {\n locales.changeLanguage(langInProps || 'en-US');\n }\n return restProps;\n },\n // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps\n [langInProps, ...Object.values(restProps)]\n );\n\n useEffect(() => {\n // Dynamically add language pack\n if (userLocales) {\n const lang = langInProps || 'en-US';\n if (lang && langs.includes(lang)) {\n locales.removeResourceBundle(lang, 'translation');\n locales.addResourceBundle(lang, 'translation', { ...resources[lang].translation, ...userLocales });\n } else {\n locales.addResourceBundle(lang, 'translation', { ...resources['en-US'].translation, ...userLocales });\n }\n }\n }, [langInProps, userLocales]);\n\n return wrapCSSVar(\n <ReactEasyContext.Provider value={contextValue}>\n <div className={classNames(hashId, cssVarCls, prefixCls, className)} style={style}>\n {children}\n </div>\n </ReactEasyContext.Provider>\n );\n};\nConfigProvider.displayName = 'ReactEasyConfigProvider';\n\nexport default ConfigProvider;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+C;AAC/C,kBAAsD;AACtD,wBAAuB;AACvB,qBAA0C;AAE1C,qBAA6D;AAC7D,mBAAqB;AAmCrB,IAAM,
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo } from 'react';\nimport { ConfigProvider as ReactConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport locales, { langs, resources } from '../../locales';\nimport type localesEn from '../../locales/langs/en';\nimport ReactEasyContext, { type ReactEasyContextProps } from './context';\nimport useStyle from './style';\n\nexport interface ConfigProviderProps extends Omit<ReactEasyContextProps, 'getPrefixCls'> {\n /**\n * - **EN:** Child elements of the ConfigProvider\n * - **CN:** ConfigProvider 的子元素\n */\n children: ReactNode;\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Custom class name for the root element\n * - **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom styles for the root element\n * - **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Custom localization resources, if `lang` exists, it will override the localization\n * resources of that language, otherwise, it will add a new language\n * - **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖该语言的本地化资源,否则,会添加一种新的语言\n */\n locales?: Partial<typeof localesEn>;\n}\n\n/**\n * - **EN:** Provide global configuration for AntdHelper\n * - **CN:** 提供AntdHelper的全局配置\n */\nconst ConfigProvider: FC<ConfigProviderProps> & { ConfigContext: typeof ReactEasyContext } = (props) => {\n const { children, locales: userLocales, prefixCls: prefixClsInProps, className, style, ...restProps } = props;\n const { lang: langInProps } = restProps;\n const { getPrefixCls, rootPrefixCls } = useContext(ReactConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('react-easy', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls, rootPrefixCls);\n const contextValue = useMemo(\n () => {\n if (langInProps !== locales.language) {\n locales.changeLanguage(langInProps || 'en-US');\n }\n return {\n ...restProps,\n getPrefixCls: (suffixCls: string, customizePrefixCls?: string) =>\n getPrefixCls(`easy-${suffixCls}`, customizePrefixCls),\n };\n },\n // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps\n [langInProps, getPrefixCls, ...Object.values(restProps)]\n );\n\n useEffect(() => {\n // Dynamically add language pack\n if (userLocales) {\n const lang = langInProps || 'en-US';\n if (lang && langs.includes(lang)) {\n locales.removeResourceBundle(lang, 'translation');\n locales.addResourceBundle(lang, 'translation', { ...resources[lang].translation, ...userLocales });\n } else {\n locales.addResourceBundle(lang, 'translation', { ...resources['en-US'].translation, ...userLocales });\n }\n }\n }, [langInProps, userLocales]);\n\n return wrapCSSVar(\n <ReactEasyContext.Provider value={contextValue}>\n <div className={classNames(hashId, cssVarCls, prefixCls, className)} style={style}>\n {children}\n </div>\n </ReactEasyContext.Provider>\n );\n};\nConfigProvider.displayName = 'ReactEasyConfigProvider';\nConfigProvider.ConfigContext = ReactEasyContext;\n\nexport default ConfigProvider;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+C;AAC/C,kBAAsD;AACtD,wBAAuB;AACvB,qBAA0C;AAE1C,qBAA6D;AAC7D,mBAAqB;AAmCrB,IAAM,iBAAuF,CAAC,UAAU;AACtG,QAAM,EAAE,UAAU,SAAS,aAAa,WAAW,kBAAkB,WAAW,OAAO,GAAG,UA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Provider", "useStyle", "locales", "ReactEasyContext", "classNames"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/ConfigProvider/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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,
|
|
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 ConfigProviderToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<ConfigProviderToken> = (token): CSSObject => {\n const { componentCls } = token;\n return {\n [componentCls]: {\n width: '100%',\n height: '100%',\n flex: 'auto',\n minWidth: 0,\n minHeight: 0,\n\n '.easy-full-height-table': {\n height: '100%',\n\n [`& > ${token.antCls}-spin-nested-loading`]: {\n height: '100%',\n\n [`& > div > ${token.antCls}-spin`]: {\n maxHeight: '100%',\n },\n\n [`& > ${token.antCls}-spin-container`]: {\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n\n [`& > ${token.antCls}-table`]: {\n display: 'flex',\n flex: 'auto',\n flexDirection: 'column',\n width: '100%',\n minHeight: 0,\n\n [`& > ${token.antCls}-table-container`]: {\n flex: 'auto',\n minHeight: 0,\n\n [`& > ${token.antCls}-table-content`]: {\n maxHeight: '100%',\n // 把容器再多撑高1px,否则会始终显示纵向滚动条\n paddingBottom: 1,\n // 自动显示纵向滚动条\n // stylelint-disable-next-line declaration-no-important\n overflow: 'auto !important',\n\n '& > table': {\n height: '100%',\n\n [`${token.antCls}-table-thead`]: {\n position: 'sticky',\n top: 0,\n zIndex: 10,\n },\n\n td: {\n // 当嵌套表格时,还原所有full-height样式,防止子表格受影响\n '.easy-full-height-table': {\n height: 'auto',\n },\n },\n },\n },\n },\n },\n [`& > ${token.antCls}-table${token.antCls}-table-empty`]: {\n [`& > ${token.antCls}-table-container`]: {\n [`& > ${token.antCls}-table-content`]: {\n height: '100%',\n },\n },\n },\n\n [`& > ${token.antCls}-table-pagination`]: {\n flex: 'none',\n marginBottom: 0,\n },\n },\n },\n },\n },\n };\n};\n\nexport default genStyleHooks('ConfigProvider' as never, genStyle);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,WAA+C,CAAC,UAAqB;AACzE,QAAM,EAAE,aAAa,IAAI;AACzB,SAAO;AAAA,IACL,CAAC,YAAY,GAAG;AAAA,MACd,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MAEX,2BAA2B;AAAA,QACzB,QAAQ;AAAA,QAER,CAAC,OAAO,MAAM,4BAA4B,GAAG;AAAA,UAC3C,QAAQ;AAAA,UAER,CAAC,aAAa,MAAM,aAAa,GAAG;AAAA,YAClC,WAAW;AAAA,UACb;AAAA,UAEA,CAAC,OAAO,MAAM,uBAAuB,GAAG;AAAA,YACtC,SAAS;AAAA,YACT,eAAe;AAAA,YACf,QAAQ;AAAA,YAER,CAAC,OAAO,MAAM,cAAc,GAAG;AAAA,cAC7B,SAAS;AAAA,cACT,MAAM;AAAA,cACN,eAAe;AAAA,cACf,OAAO;AAAA,cACP,WAAW;AAAA,cAEX,CAAC,OAAO,MAAM,wBAAwB,GAAG;AAAA,gBACvC,MAAM;AAAA,gBACN,WAAW;AAAA,gBAEX,CAAC,OAAO,MAAM,sBAAsB,GAAG;AAAA,kBACrC,WAAW;AAAA;AAAA,kBAEX,eAAe;AAAA;AAAA;AAAA,kBAGf,UAAU;AAAA,kBAEV,aAAa;AAAA,oBACX,QAAQ;AAAA,oBAER,CAAC,GAAG,MAAM,oBAAoB,GAAG;AAAA,sBAC/B,UAAU;AAAA,sBACV,KAAK;AAAA,sBACL,QAAQ;AAAA,oBACV;AAAA,oBAEA,IAAI;AAAA;AAAA,sBAEF,2BAA2B;AAAA,wBACzB,QAAQ;AAAA,sBACV;AAAA,oBACF;AAAA,kBACF;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAAA,YACA,CAAC,OAAO,MAAM,eAAe,MAAM,oBAAoB,GAAG;AAAA,cACxD,CAAC,OAAO,MAAM,wBAAwB,GAAG;AAAA,gBACvC,CAAC,OAAO,MAAM,sBAAsB,GAAG;AAAA,kBACrC,QAAQ;AAAA,gBACV;AAAA,cACF;AAAA,YACF;AAAA,YAEA,CAAC,OAAO,MAAM,yBAAyB,GAAG;AAAA,cACxC,MAAM;AAAA,cACN,cAAc;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,oBAAQ,+BAAc,kBAA2B,QAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ var import_antd = require("antd");
|
|
|
37
37
|
var import_classnames = __toESM(require("classnames"));
|
|
38
38
|
var import_react_contexify = require("react-contexify");
|
|
39
39
|
var import_hooks = require("../../hooks");
|
|
40
|
+
var import_ConfigProvider = __toESM(require("../ConfigProvider"));
|
|
40
41
|
var import_style = __toESM(require("./style"));
|
|
41
42
|
var import_ReactContexify = require("react-contexify/dist/ReactContexify.css");
|
|
42
43
|
var ContextMenu = (0, import_react.forwardRef)((props, ref) => {
|
|
@@ -50,7 +51,7 @@ var ContextMenu = (0, import_react.forwardRef)((props, ref) => {
|
|
|
50
51
|
children,
|
|
51
52
|
...rest
|
|
52
53
|
} = props;
|
|
53
|
-
const { getPrefixCls } = (0, import_react.useContext)(
|
|
54
|
+
const { getPrefixCls } = (0, import_react.useContext)(import_ConfigProvider.default.ConfigContext);
|
|
54
55
|
const prefixCls = getPrefixCls("context-menu", prefixClsInProps);
|
|
55
56
|
const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
|
|
56
57
|
const { show, hideAll } = (0, import_react_contexify.useContextMenu)({ id });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ContextMenu/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { CSSProperties, ReactNode } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useMemo } from 'react';\nimport { theme as AntdTheme,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAqE;AACrE,
|
|
6
|
-
"names": ["useStyle", "classNames", "AntdTheme"]
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, ReactNode } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useMemo } from 'react';\nimport { ConfigProvider as AntConfigProvider, theme as AntdTheme, Typography } from 'antd';\nimport classNames from 'classnames';\nimport type { ItemProps, MenuProps, SeparatorProps, ShowContextMenuParams, SubMenuProps } from 'react-contexify';\nimport { Item, Menu, RightSlot, Separator, Submenu, useContextMenu } from 'react-contexify';\nimport { useRefFunction } from '../../hooks';\nimport ConfigProvider from '../ConfigProvider';\nimport useStyle from './style';\nimport 'react-contexify/dist/ReactContexify.css';\n\nexport interface ContextMenuProps extends MenuProps {\n /**\n * - **EN:** Menu items to be displayed\n * - **CN:** 要显示的菜单项\n */\n items: (ContextMenuItem | ContextMenuSeparator | ContextMenuSubmenu)[] | undefined;\n /**\n * - **EN:** Trigger methods to show the menu, default is `['contextMenu']`\n * - **CN:** 触发显示菜单的方式,默认是 `['contextMenu']`\n */\n trigger?: ('click' | 'doubleClick' | 'hover' | 'contextMenu')[];\n /**\n * - **EN:** Custom properties for the trigger element\n * - **CN:** 触发元素的自定义属性\n */\n triggerProps?: {\n /**\n * - **EN:** Custom class name for the trigger element\n * - **CN:** 触发元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom styles for the trigger element\n * - **CN:** 触发元素的自定义样式\n */\n style?: CSSProperties;\n };\n /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n}\n// 上下文菜单组件\nconst ContextMenu = forwardRef<ContextMenuRef, ContextMenuProps>((props, ref) => {\n const {\n id,\n items,\n trigger = ['contextMenu'],\n triggerProps,\n prefixCls: prefixClsInProps,\n className,\n children,\n ...rest\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('context-menu', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const { show, hideAll } = useContextMenu({ id });\n const eventNames = useMemo<Record<NonNullable<ContextMenuProps['trigger']>[number], [string, string | undefined]>>(\n () => ({\n click: ['onClick', undefined],\n doubleClick: ['onDoubleClick', undefined],\n hover: ['onPointerEnter', 'onPointerLeave'],\n contextMenu: ['onContextMenu', undefined],\n }),\n []\n );\n\n // Show context menu handler\n const handleShow = useRefFunction(\n (event: React.MouseEvent<HTMLElement>, options?: Pick<ShowContextMenuParams, 'position'>) => {\n show({\n id,\n event,\n props,\n position: options?.position,\n });\n }\n );\n // Hide all context menus handler\n const handleHideAll = useRefFunction(() => {\n hideAll();\n });\n const eventHandlers = useMemo(() => {\n const handlers: Record<string, (event: React.MouseEvent<HTMLElement>) => void> = {};\n if (trigger) {\n trigger.forEach((eventType) => {\n const [handlerName, leaveHandlerName] = eventNames[eventType];\n handlers[handlerName] = (event: React.MouseEvent<HTMLElement>) => {\n handleShow(event);\n };\n if (leaveHandlerName) {\n handlers[leaveHandlerName] = handleHideAll;\n }\n });\n }\n return handlers;\n }, [eventNames, trigger]);\n\n // Expose show and hideAll methods to the ref\n useImperativeHandle(\n ref,\n () => ({\n show: handleShow,\n hideAll: handleHideAll,\n }),\n []\n );\n\n return (\n <>\n {children &&\n wrapCSSVar(\n <div\n {...eventHandlers}\n className={classNames(hashId, cssVarCls, prefixCls, `${prefixCls}-trigger`, triggerProps?.className)}\n style={triggerProps?.style}\n >\n {children}\n </div>\n )}\n {wrapCSSVar(\n <Menu\n id={id}\n className={classNames(\n hashId,\n cssVarCls,\n prefixCls,\n `${prefixCls}-menu`,\n {\n [`${prefixCls}-menu-has-items`]: !!items?.length,\n },\n className\n )}\n {...rest}\n >\n {renderItems(items, { theme: props.theme, cmpPrefixCls: prefixCls })}\n </Menu>\n )}\n </>\n );\n});\nContextMenu.displayName = 'ContextMenu';\n\n// Render menu items\nfunction renderItems(\n items: (ContextMenuItem | ContextMenuSeparator | ContextMenuSubmenu)[] | undefined,\n options: Pick<ContextMenuProps, 'theme'> & { cmpPrefixCls: string }\n): ReactNode[] | undefined {\n return items?.map((item, index) => {\n const isSeparator = 'type' in item && item.type === 'separator';\n const isSubmenu = 'type' in item && item.type === 'submenu';\n const menuItem = item as ContextMenuItem;\n\n if (isSeparator) {\n // eslint-disable-next-line react/no-array-index-key\n return <Separator key={`[separator]:${index}`} />;\n }\n\n if (isSubmenu) {\n const subMenu = item as ContextMenuSubmenu;\n return (\n <Submenu {...subMenu} key={subMenu.key}>\n {renderItems(item.items, options)}\n </Submenu>\n );\n }\n\n return (\n <Item\n {...menuItem}\n keyMatcher={\n typeof menuItem.shortcutKey === 'object'\n ? (e) => {\n const shortcutKey = menuItem.shortcutKey as Partial<KeyboardEvent>;\n if (shortcutKey.ctrlKey && !e.ctrlKey) return false;\n if (shortcutKey.altKey && !e.altKey) return false;\n if (shortcutKey.shiftKey && !e.shiftKey) return false;\n if (shortcutKey.metaKey && !e.metaKey) return false;\n if (!shortcutKey.key || shortcutKey.key !== e.key) return false;\n return true;\n }\n : menuItem.shortcutKey\n }\n key={menuItem.key}\n >\n {menuItem.children ? (\n menuItem.children\n ) : (\n <>\n {menuItem.icon}\n <span>{menuItem.label}</span>\n {typeof menuItem.shortcutKey === 'object' && (\n <RightSlot>{getShortcutText(menuItem.shortcutKey, options)}</RightSlot>\n )}\n </>\n )}\n </Item>\n );\n });\n}\n\nfunction getShortcutText(\n event: Partial<Pick<KeyboardEvent, 'ctrlKey' | 'altKey' | 'shiftKey' | 'metaKey' | 'key'>>,\n options: Pick<ContextMenuProps, 'theme'> & { cmpPrefixCls: string }\n): ReactNode[] {\n const { theme, cmpPrefixCls } = options;\n const keys: ReactNode[] = [];\n const Keyboard = (props: { children: ReactNode }) => {\n return (\n <AntConfigProvider theme={{ algorithm: theme === 'dark' ? AntdTheme.darkAlgorithm : undefined }}>\n <Typography.Text keyboard className={`${cmpPrefixCls}-shortcut-key`}>\n {props.children}\n </Typography.Text>\n </AntConfigProvider>\n );\n };\n if (event.ctrlKey) keys.push(<Keyboard>^</Keyboard>);\n if (event.altKey) keys.push(<Keyboard>⌥</Keyboard>);\n if (event.shiftKey) keys.push(<Keyboard>⇧</Keyboard>);\n if (event.metaKey) keys.push(<Keyboard>⌘</Keyboard>);\n if (event.key) {\n keys.push(<Keyboard>{event.key}</Keyboard>);\n }\n return keys;\n}\n\nexport interface ContextMenuRef {\n show: (event: React.MouseEvent<HTMLElement>) => void;\n hideAll: () => void;\n}\n\nexport interface ContextMenuItem extends Omit<ItemProps, 'children' | 'keyMatcher'> {\n key: string;\n className?: string;\n icon?: ReactNode;\n label?: ReactNode;\n shortcutKey?:\n | Partial<Pick<KeyboardEvent, 'ctrlKey' | 'altKey' | 'shiftKey' | 'metaKey' | 'key'>>\n | ItemProps['keyMatcher'];\n children?: ReactNode;\n}\n\nexport interface ContextMenuSeparator extends SeparatorProps {\n type: 'separator';\n}\n\nexport interface ContextMenuSubmenu extends SubMenuProps {\n key: string;\n type: 'submenu';\n items: (ContextMenuItem | ContextMenuSeparator | ContextMenuSubmenu)[];\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AS,GAAC,CAAW;AACpD,MAAI,MAAM;AAAS,SAAK,KAAK,oCAAC,gBAAS,GAAC,CAAW;AACnD,MAAI,MAAM,KAAK;AACb,SAAK,KAAK,oCAAC,gBAAU,MAAM,GAAI,CAAW;AAAA,EAC5C;AACA,SAAO;AACT;AA4BA,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["ConfigProvider", "useStyle", "classNames", "AntConfigProvider", "AntdTheme"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/ContextMenu/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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,
|
|
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 ContextMenuToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<ContextMenuToken> = (token): CSSObject => {\n const { componentCls } = token;\n return {\n [componentCls]: {\n '&-trigger': {\n width: 'fit-content',\n },\n '.contexify&-menu': {\n padding: 0,\n '&-has-items': {\n padding: 'var(--contexify-menu-padding)',\n },\n [`${componentCls}-shortcut-key`]: {\n kbd: {\n fontFamily: '-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,sans-serif',\n },\n },\n },\n },\n };\n};\n\nexport default genStyleHooks('ContextMenu' as never, genStyle);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,WAA4C,CAAC,UAAqB;AACtE,QAAM,EAAE,aAAa,IAAI;AACzB,SAAO;AAAA,IACL,CAAC,YAAY,GAAG;AAAA,MACd,aAAa;AAAA,QACX,OAAO;AAAA,MACT;AAAA,MACA,oBAAoB;AAAA,QAClB,SAAS;AAAA,QACT,eAAe;AAAA,UACb,SAAS;AAAA,QACX;AAAA,QACA,CAAC,GAAG,2BAA2B,GAAG;AAAA,UAChC,KAAK;AAAA,YACH,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,oBAAQ,+BAAc,eAAwB,QAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,9 +11,9 @@ import { type ActionComponentInterface } from '../ConfirmAction/withConfirmActio
|
|
|
11
11
|
*/
|
|
12
12
|
export default function withDeleteConfirmAction<P extends ActionCompConstraint, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(ActionComponent: ActionComponentInterface<P, Ref>, defaultProps?: Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>> | ((actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)): (<TriggerProp extends object, Event extends keyof TriggerProp>(props: import("react").PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> & Omit<import("antd").ModalFuncProps, "onOk"> & import("../ConfirmAction").ConfirmActionTrigger<TriggerProp, Event> & {
|
|
13
13
|
danger?: boolean | undefined;
|
|
14
|
-
titleColor?: import("antd/es/typography/Base").BaseType |
|
|
15
|
-
contentColor?: import("antd/es/typography/Base").BaseType |
|
|
16
|
-
iconColor?: import("antd/es/typography/Base").BaseType |
|
|
14
|
+
titleColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
|
|
15
|
+
contentColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
|
|
16
|
+
iconColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
|
|
17
17
|
onOk?: ((...args: Parameters<TriggerProp[Event]>) => unknown) | undefined;
|
|
18
18
|
afterOk?: ((data?: any) => void) | undefined;
|
|
19
19
|
} & import("react").RefAttributes<import("../ConfirmAction").ConfirmActionRef<Ref>>) => import("react").ReactNode) & import("../ConfirmAction/withConfirmAction").TypedTriggers<P, Ref>;
|
|
@@ -37,6 +37,7 @@ var import_antd = require("antd");
|
|
|
37
37
|
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
|
+
var import_ConfigProvider = __toESM(require("../ConfigProvider"));
|
|
40
41
|
var import_form = __toESM(require("./form"));
|
|
41
42
|
var import_style = __toESM(require("./style"));
|
|
42
43
|
var getEllipsisConfig = (content) => ({
|
|
@@ -75,8 +76,8 @@ var EditableText = (props) => {
|
|
|
75
76
|
onChange,
|
|
76
77
|
onEditingChange
|
|
77
78
|
} = props;
|
|
78
|
-
const { getPrefixCls } = (0, import_react.useContext)(
|
|
79
|
-
const prefixCls = getPrefixCls("
|
|
79
|
+
const { getPrefixCls } = (0, import_react.useContext)(import_ConfigProvider.default.ConfigContext);
|
|
80
|
+
const prefixCls = getPrefixCls("editable-text", prefixClsInProps);
|
|
80
81
|
const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
|
|
81
82
|
const t = (0, import_useT.default)();
|
|
82
83
|
const [isEditing, setIsEditing] = (0, import_react.useState)(editing);
|
|
@@ -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, 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 /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Custom read-only display text, replacing `value` display\n * - **CN:** 自定义只读显示文本,替代`value`显示\n *\n * @default true\n */\n displayText?: boolean | 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 Typography.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,
|
|
6
|
-
"names": ["useStyle", "useT", "React", "editing", "names", "EditableTextForm"]
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, ReactNode } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { 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 ConfigProvider from '../ConfigProvider';\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 /**\n * - **EN:** Custom prefix for the component's CSS class.\n * - **CN:** 组件的自定义 CSS 类前缀。\n */\n prefixCls?: string;\n /**\n * - **EN:** Custom read-only display text, replacing `value` display\n * - **CN:** 自定义只读显示文本,替代`value`显示\n *\n * @default true\n */\n displayText?: boolean | 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 Typography.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('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,kBAAiC;AAMjC,wBAAkB;AAClB,mBAA6B;AAC7B,kBAAiB;AACjB,4BAA2B;AAC3B,kBAAoF;AACpF,mBAAqB;AAErB,IAAM,oBAAoB,CAAC,aAAoD;AAAA,EAC7E,SAAS;AAAA,IACP,OAAO;AAAA,IACP,cAAc,EAAE,UAAU,IAAI;AAAA,EAChC;AACF;AAoKA,IAAM,eAAe,CAKnB,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,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": ["ConfigProvider", "useStyle", "useT", "React", "editing", "names", "EditableTextForm"]
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ var import_antd = require("antd");
|
|
|
37
37
|
var import_classnames = __toESM(require("classnames"));
|
|
38
38
|
var import_icons = require("@ant-design/icons");
|
|
39
39
|
var import_useRefFunction = __toESM(require("../../hooks/useRefFunction"));
|
|
40
|
+
var import_ConfigProvider = __toESM(require("../ConfigProvider"));
|
|
40
41
|
var import_style = __toESM(require("./style"));
|
|
41
42
|
var FloatDrawer = (props) => {
|
|
42
43
|
const {
|
|
@@ -61,8 +62,8 @@ var FloatDrawer = (props) => {
|
|
|
61
62
|
onResize,
|
|
62
63
|
onClick
|
|
63
64
|
} = props;
|
|
64
|
-
const { getPrefixCls } = (0, import_react.useContext)(
|
|
65
|
-
const prefixCls = getPrefixCls("
|
|
65
|
+
const { getPrefixCls } = (0, import_react.useContext)(import_ConfigProvider.default.ConfigContext);
|
|
66
|
+
const prefixCls = getPrefixCls("float-drawer", prefixClsInProps);
|
|
66
67
|
const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
|
|
67
68
|
const [drawerRef, setDrawerRef] = (0, import_react.useState)(null);
|
|
68
69
|
const [size, setSize] = (0, import_react.useState)(
|