@tiny-codes/react-easy 1.1.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/es/components/ConfirmAction/index.d.ts +97 -28
  3. package/es/components/ConfirmAction/index.js +47 -28
  4. package/es/components/ConfirmAction/index.js.map +1 -1
  5. package/es/components/ConfirmAction/withConfirmAction.d.ts +48 -0
  6. package/es/components/ConfirmAction/withConfirmAction.js +131 -0
  7. package/es/components/ConfirmAction/withConfirmAction.js.map +1 -0
  8. package/es/components/ContextMenu/index.d.ts +42 -0
  9. package/es/components/ContextMenu/index.js +188 -0
  10. package/es/components/ContextMenu/index.js.map +1 -0
  11. package/es/components/ContextMenu/style/index.d.ts +3 -0
  12. package/es/components/ContextMenu/style/index.js +25 -0
  13. package/es/components/ContextMenu/style/index.js.map +1 -0
  14. package/es/components/DeleteConfirmAction/index.d.ts +1 -1
  15. package/es/components/DeleteConfirmAction/index.js +9 -3
  16. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  17. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
  18. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js +20 -0
  19. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +1 -0
  20. package/es/components/EditableText/form.d.ts +12 -6
  21. package/es/components/EditableText/form.js +106 -56
  22. package/es/components/EditableText/form.js.map +1 -1
  23. package/es/components/EditableText/index.d.ts +31 -9
  24. package/es/components/EditableText/index.js +13 -7
  25. package/es/components/EditableText/index.js.map +1 -1
  26. package/es/components/Loading/index.d.ts +2 -2
  27. package/es/components/Loading/index.js +5 -5
  28. package/es/components/Loading/index.js.map +1 -1
  29. package/es/components/ModalAction/index.d.ts +35 -29
  30. package/es/components/ModalAction/index.js +16 -9
  31. package/es/components/ModalAction/index.js.map +1 -1
  32. package/es/components/index.d.ts +5 -1
  33. package/es/components/index.js +3 -0
  34. package/es/components/index.js.map +1 -1
  35. package/lib/components/ConfirmAction/index.d.ts +97 -28
  36. package/lib/components/ConfirmAction/index.js +57 -32
  37. package/lib/components/ConfirmAction/index.js.map +2 -2
  38. package/lib/components/ConfirmAction/withConfirmAction.d.ts +48 -0
  39. package/lib/components/ConfirmAction/withConfirmAction.js +123 -0
  40. package/lib/components/ConfirmAction/withConfirmAction.js.map +7 -0
  41. package/lib/components/ContextMenu/index.d.ts +42 -0
  42. package/lib/components/ContextMenu/index.js +190 -0
  43. package/lib/components/ContextMenu/index.js.map +7 -0
  44. package/lib/components/ContextMenu/style/index.d.ts +3 -0
  45. package/lib/components/ContextMenu/style/index.js +48 -0
  46. package/lib/components/ContextMenu/style/index.js.map +7 -0
  47. package/lib/components/DeleteConfirmAction/index.d.ts +1 -1
  48. package/lib/components/DeleteConfirmAction/index.js +28 -16
  49. package/lib/components/DeleteConfirmAction/index.js.map +2 -2
  50. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
  51. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js +38 -0
  52. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +7 -0
  53. package/lib/components/EditableText/form.d.ts +12 -6
  54. package/lib/components/EditableText/form.js +69 -39
  55. package/lib/components/EditableText/form.js.map +2 -2
  56. package/lib/components/EditableText/index.d.ts +31 -9
  57. package/lib/components/EditableText/index.js +12 -5
  58. package/lib/components/EditableText/index.js.map +2 -2
  59. package/lib/components/Loading/index.d.ts +2 -2
  60. package/lib/components/Loading/index.js +4 -4
  61. package/lib/components/Loading/index.js.map +2 -2
  62. package/lib/components/ModalAction/index.d.ts +35 -29
  63. package/lib/components/ModalAction/index.js +22 -17
  64. package/lib/components/ModalAction/index.js.map +2 -2
  65. package/lib/components/index.d.ts +5 -1
  66. package/lib/components/index.js +9 -0
  67. package/lib/components/index.js.map +2 -2
  68. package/package.json +3 -2
@@ -0,0 +1,123 @@
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/ConfirmAction/withConfirmAction.tsx
20
+ var withConfirmAction_exports = {};
21
+ __export(withConfirmAction_exports, {
22
+ default: () => withConfirmAction,
23
+ withConfirmActionInternal: () => withConfirmActionInternal
24
+ });
25
+ module.exports = __toCommonJS(withConfirmAction_exports);
26
+ var import_react = require("react");
27
+ var import__ = require(".");
28
+ var import_antd = require("antd");
29
+ var import_react_is = require("react-is");
30
+ function withConfirmAction(ActionComponent, defaultProps) {
31
+ return withConfirmActionInternal(
32
+ ActionComponent,
33
+ {
34
+ confirmType: "normal"
35
+ },
36
+ defaultProps
37
+ );
38
+ }
39
+ function withConfirmActionInternal(ActionComponent, renderDefaultProps, defaultProps) {
40
+ const ConfirmActionWithRef = (0, import_react.forwardRef)((0, import__.genRenderer)(renderDefaultProps));
41
+ ConfirmActionWithRef.displayName = "ForwardRef(ConfirmAction)";
42
+ const WrappedActionComponent = (0, import_react.forwardRef)(
43
+ (propsWithDefaults, ref) => {
44
+ const actionRef = (0, import_react.useRef)(null);
45
+ const [customRef, setCustomRef] = (0, import_react.useState)(null);
46
+ const saveFuncRef = (0, import_react.useRef)(void 0);
47
+ const setOnOk = (0, import_react.useCallback)((handler) => {
48
+ saveFuncRef.current = handler;
49
+ }, []);
50
+ (0, import_react.useImperativeHandle)(ref, () => {
51
+ return {
52
+ ...actionRef.current,
53
+ ...customRef
54
+ };
55
+ }, [customRef]);
56
+ const triggerDom = /* @__PURE__ */ React.createElement(
57
+ ConfirmActionWithRef,
58
+ {
59
+ ...propsWithDefaults,
60
+ onOk: saveFuncRef.current,
61
+ ref: actionRef
62
+ }
63
+ );
64
+ return /* @__PURE__ */ React.createElement(
65
+ ActionComponent,
66
+ {
67
+ ...propsWithDefaults,
68
+ ref: (0, import_react_is.isForwardRef)(ActionComponent) ? setCustomRef : void 0,
69
+ setOK: setOnOk,
70
+ triggerDom
71
+ }
72
+ );
73
+ }
74
+ );
75
+ WrappedActionComponent.displayName = "ConfirmAction(ActionComponent)";
76
+ const withDefaults = (0, import__.withDefaultConfirmActionProps)(
77
+ WrappedActionComponent,
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ defaultProps
80
+ );
81
+ return addTriggers(withDefaults);
82
+ }
83
+ function addTriggers(comp) {
84
+ const patchedComp = comp;
85
+ patchedComp.Button = (0, import__.withDefaultConfirmActionProps)(
86
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
87
+ comp,
88
+ {
89
+ triggerComponent: import_antd.Button,
90
+ triggerEvent: "onClick",
91
+ triggerProps: {}
92
+ }
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
+ );
95
+ patchedComp.Switch = (0, import__.withDefaultConfirmActionProps)(
96
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
97
+ comp,
98
+ {
99
+ triggerComponent: import_antd.Switch,
100
+ triggerEvent: "onChange",
101
+ triggerProps: {}
102
+ }
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
+ );
105
+ patchedComp.Link = (0, import__.withDefaultConfirmActionProps)(
106
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
107
+ comp,
108
+ {
109
+ triggerComponent: import_antd.Typography.Link,
110
+ triggerEvent: "onClick",
111
+ triggerProps: {
112
+ style: { whiteSpace: "nowrap" }
113
+ }
114
+ }
115
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
+ );
117
+ return patchedComp;
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ withConfirmActionInternal
122
+ });
123
+ //# sourceMappingURL=withConfirmAction.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ConfirmAction/withConfirmAction.tsx"],
4
+ "sourcesContent": ["import type { ComponentType, PropsWithoutRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';\nimport type { ActionCompConstraint, ConfirmActionProps, ConfirmActionRef } from '.';\nimport { genRenderer, withDefaultConfirmActionProps } from '.';\nimport { Button, type ButtonProps, Switch, type SwitchProps, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\n\n/**\n * - **EN:** Generate a confirm box component with custom trigger and default props\n * - **CN:** 将一个组件包装成一个确认弹框组件,支持自定义触发器和默认属性\n *\n * @param actionComponent Custom trigger component | 自定义触发器组件\n * @param defaultProps Default properties of the confirm box | 确认弹框的默认属性\n */\nexport default function withConfirmAction<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n return withConfirmActionInternal(\n ActionComponent,\n {\n confirmType: 'normal',\n },\n defaultProps\n );\n}\n\nexport function withConfirmActionInternal<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n renderDefaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' },\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n const ConfirmActionWithRef = forwardRef(genRenderer(renderDefaultProps));\n ConfirmActionWithRef.displayName = 'ForwardRef(ConfirmAction)';\n\n const WrappedActionComponent = forwardRef<Ref, ConfirmActionProps<OuterTriggerProp, OuterEvent>>(\n (propsWithDefaults, ref) => {\n const actionRef = useRef<ConfirmActionRef>(null);\n const [customRef, setCustomRef] = useState<Ref | null>(null);\n const saveFuncRef = useRef<(...triggerEventArgs: any[]) => unknown | Promise<unknown>>(undefined);\n\n // Receive the onSave callback method passed by the form component\n const setOnOk: ActionCompConstraint['setOK'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n\n // Merge the default ref and custom ref and output to the parent component\n useImperativeHandle(ref, () => {\n return {\n ...actionRef.current,\n ...customRef,\n } as ConfirmActionRef<Ref>;\n }, [customRef]);\n\n // Render the default trigger DOM element, and pass it to the custom ActionComponent\n const triggerDom = (\n <ConfirmActionWithRef\n {...(propsWithDefaults as ConfirmActionProps<object, never>)}\n onOk={saveFuncRef.current}\n ref={actionRef}\n />\n );\n\n return (\n <ActionComponent\n {...(propsWithDefaults as P)}\n ref={isForwardRef(ActionComponent) ? setCustomRef : undefined}\n setOK={setOnOk}\n triggerDom={triggerDom}\n />\n );\n }\n );\n WrappedActionComponent.displayName = 'ConfirmAction(ActionComponent)';\n\n const withDefaults = withDefaultConfirmActionProps(\n WrappedActionComponent,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps as any\n ) as unknown as ComponentType<\n Omit<ConfirmActionProps<OuterTriggerProp, OuterEvent>, 'triggerComponent'> & RefAttributes<ConfirmActionRef>\n >;\n // return withDefaults;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return addTriggers<P, OuterTriggerProp, OuterEvent, Ref>(withDefaults as any);\n}\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nfunction addTriggers<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(comp: ComponentType<ConfirmActionProps<OuterTriggerProp, OuterEvent> & RefAttributes<ConfirmActionRef<Ref>>>) {\n const patchedComp = comp as unknown as WithGenericTriggers<P, Ref>;\n // Type of button trigger\n patchedComp.Button = withDefaultConfirmActionProps<P, ButtonProps, 'onClick', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultConfirmActionProps<P, SwitchProps, 'onChange', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultConfirmActionProps<P, LinkProps, 'onClick', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\n {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n return patchedComp;\n}\n\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ActionComponentInterface<P extends ActionCompConstraint, Ref extends object> = ComponentType<\n P & RefAttributes<ConfirmActionRef<Ref>>\n>;\n\ntype WithGenericTriggers<P extends ActionCompConstraint, Ref extends object> = (<\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n>(\n props: PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> &\n ConfirmActionProps<TriggerProp, Event> &\n RefAttributes<ConfirmActionRef<Ref>>\n) => ReactNode) &\n TypedTriggers<P, Ref>;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<P extends ActionCompConstraint, Ref extends object> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ConfirmActionWithTrigger<P, ButtonProps, 'onClick', Ref>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ConfirmActionWithTrigger<P, SwitchProps, 'onChange', Ref>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ConfirmActionWithTrigger<P, LinkProps, 'onClick', Ref>;\n}\n\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ConfirmActionWithTrigger<\n P extends ActionCompConstraint,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<\n PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> & ConfirmActionProps<TriggerProp, Event>,\n 'triggerComponent' | 'triggerEvent' | OMIT\n > &\n RefAttributes<ConfirmActionRef<Ref>>\n>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+E;AAE/E,eAA2D;AAC3D,kBAA+E;AAE/E,sBAA6B;AASd,SAAR,k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kB;AAAA,MAClB,cAAc;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAEF;AAEA,cAAY,WAAO;AAAA;AAAA,IAEjB;AAAA,IACA;AAAA,MACE,kBAAkB,uBAAW;AAAA,MAC7B,cAAc;AAAA,MACd,cAAc;AAAA,QACZ,OAAO,EAAE,YAAY,SAAS;AAAA,MAChC;AAAA,IACF;AAAA;AAAA,EAEF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,42 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ import type { ItemProps, MenuProps, SeparatorProps, SubMenuProps } from 'react-contexify';
3
+ import 'react-contexify/dist/ReactContexify.css';
4
+ export interface ContextMenuProps extends MenuProps {
5
+ /**
6
+ * - **EN:** Menu items to be displayed
7
+ * - **CN:** 要显示的菜单项
8
+ */
9
+ items: (ContextMenuItem | ContextMenuSeparator | ContextMenuSubmenu)[] | undefined;
10
+ /**
11
+ * - **EN:** Trigger methods to show the menu, default is `['contextMenu']`
12
+ * - **CN:** 触发显示菜单的方式,默认是 `['contextMenu']`
13
+ */
14
+ trigger?: ('click' | 'doubleClick' | 'hover' | 'contextMenu')[];
15
+ triggerProps?: {
16
+ className?: string;
17
+ style?: CSSProperties;
18
+ };
19
+ prefixCls?: string;
20
+ }
21
+ declare const ContextMenu: import("react").ForwardRefExoticComponent<ContextMenuProps & import("react").RefAttributes<ContextMenuRef>>;
22
+ export interface ContextMenuRef {
23
+ show: (event: React.MouseEvent<HTMLElement>) => void;
24
+ hideAll: () => void;
25
+ }
26
+ export interface ContextMenuItem extends Omit<ItemProps, 'children' | 'keyMatcher'> {
27
+ key: string;
28
+ className?: string;
29
+ icon?: ReactNode;
30
+ label?: ReactNode;
31
+ shortcutKey?: Partial<Pick<KeyboardEvent, 'ctrlKey' | 'altKey' | 'shiftKey' | 'metaKey' | 'key'>> | ItemProps['keyMatcher'];
32
+ children?: ReactNode;
33
+ }
34
+ export interface ContextMenuSeparator extends SeparatorProps {
35
+ type: 'separator';
36
+ }
37
+ export interface ContextMenuSubmenu extends SubMenuProps {
38
+ key: string;
39
+ type: 'submenu';
40
+ items: (ContextMenuItem | ContextMenuSeparator | ContextMenuSubmenu)[];
41
+ }
42
+ export default ContextMenu;
@@ -0,0 +1,190 @@
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/ContextMenu/index.tsx
30
+ var ContextMenu_exports = {};
31
+ __export(ContextMenu_exports, {
32
+ default: () => ContextMenu_default
33
+ });
34
+ module.exports = __toCommonJS(ContextMenu_exports);
35
+ var import_react = require("react");
36
+ var import_antd = require("antd");
37
+ var import_classnames = __toESM(require("classnames"));
38
+ var import_react_contexify = require("react-contexify");
39
+ var import_hooks = require("../../hooks");
40
+ var import_style = __toESM(require("./style"));
41
+ var import_ReactContexify = require("react-contexify/dist/ReactContexify.css");
42
+ var ContextMenu = (0, import_react.forwardRef)((props, ref) => {
43
+ const {
44
+ id,
45
+ items,
46
+ trigger = ["contextMenu"],
47
+ triggerProps,
48
+ prefixCls: prefixClsInProps,
49
+ className,
50
+ children,
51
+ ...rest
52
+ } = props;
53
+ const { getPrefixCls } = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
54
+ const prefixCls = getPrefixCls("context-menu", prefixClsInProps);
55
+ const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
56
+ const { show, hideAll } = (0, import_react_contexify.useContextMenu)({ id });
57
+ const eventNames = (0, import_react.useMemo)(
58
+ () => ({
59
+ click: ["onClick", void 0],
60
+ doubleClick: ["onDoubleClick", void 0],
61
+ hover: ["onPointerEnter", "onPointerLeave"],
62
+ contextMenu: ["onContextMenu", void 0]
63
+ }),
64
+ []
65
+ );
66
+ const handleShow = (0, import_hooks.useRefFunction)(
67
+ (event, options) => {
68
+ show({
69
+ id,
70
+ event,
71
+ props,
72
+ position: options == null ? void 0 : options.position
73
+ });
74
+ }
75
+ );
76
+ const handleHideAll = (0, import_hooks.useRefFunction)(() => {
77
+ hideAll();
78
+ });
79
+ const eventHandlers = (0, import_react.useMemo)(() => {
80
+ const handlers = {};
81
+ if (trigger) {
82
+ trigger.forEach((eventType) => {
83
+ const [handlerName, leaveHandlerName] = eventNames[eventType];
84
+ handlers[handlerName] = (event) => {
85
+ handleShow(event);
86
+ };
87
+ if (leaveHandlerName) {
88
+ handlers[leaveHandlerName] = handleHideAll;
89
+ }
90
+ });
91
+ }
92
+ return handlers;
93
+ }, [eventNames, trigger]);
94
+ (0, import_react.useImperativeHandle)(
95
+ ref,
96
+ () => ({
97
+ show: handleShow,
98
+ hideAll: handleHideAll
99
+ }),
100
+ []
101
+ );
102
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children && wrapCSSVar(
103
+ /* @__PURE__ */ React.createElement(
104
+ "div",
105
+ {
106
+ ...eventHandlers,
107
+ className: (0, import_classnames.default)(hashId, cssVarCls, prefixCls, `${prefixCls}-trigger`, triggerProps == null ? void 0 : triggerProps.className),
108
+ style: triggerProps == null ? void 0 : triggerProps.style
109
+ },
110
+ children
111
+ )
112
+ ), wrapCSSVar(
113
+ /* @__PURE__ */ React.createElement(
114
+ import_react_contexify.Menu,
115
+ {
116
+ id,
117
+ className: (0, import_classnames.default)(
118
+ hashId,
119
+ cssVarCls,
120
+ prefixCls,
121
+ `${prefixCls}-menu`,
122
+ {
123
+ [`${prefixCls}-menu-has-items`]: !!(items == null ? void 0 : items.length)
124
+ },
125
+ className
126
+ ),
127
+ ...rest
128
+ },
129
+ renderItems(items, { theme: props.theme, cmpPrefixCls: prefixCls })
130
+ )
131
+ ));
132
+ });
133
+ ContextMenu.displayName = "ContextMenu";
134
+ function renderItems(items, options) {
135
+ return items == null ? void 0 : items.map((item, index) => {
136
+ const isSeparator = "type" in item && item.type === "separator";
137
+ const isSubmenu = "type" in item && item.type === "submenu";
138
+ const menuItem = item;
139
+ if (isSeparator) {
140
+ return /* @__PURE__ */ React.createElement(import_react_contexify.Separator, { key: `[separator]:${index}` });
141
+ }
142
+ if (isSubmenu) {
143
+ const subMenu = item;
144
+ return /* @__PURE__ */ React.createElement(import_react_contexify.Submenu, { ...subMenu, key: subMenu.key }, renderItems(item.items, options));
145
+ }
146
+ return /* @__PURE__ */ React.createElement(
147
+ import_react_contexify.Item,
148
+ {
149
+ ...menuItem,
150
+ keyMatcher: typeof menuItem.shortcutKey === "object" ? (e) => {
151
+ const shortcutKey = menuItem.shortcutKey;
152
+ if (shortcutKey.ctrlKey && !e.ctrlKey)
153
+ return false;
154
+ if (shortcutKey.altKey && !e.altKey)
155
+ return false;
156
+ if (shortcutKey.shiftKey && !e.shiftKey)
157
+ return false;
158
+ if (shortcutKey.metaKey && !e.metaKey)
159
+ return false;
160
+ if (!shortcutKey.key || shortcutKey.key !== e.key)
161
+ return false;
162
+ return true;
163
+ } : menuItem.shortcutKey,
164
+ key: menuItem.key
165
+ },
166
+ menuItem.children ? menuItem.children : /* @__PURE__ */ React.createElement(React.Fragment, null, menuItem.icon, /* @__PURE__ */ React.createElement("span", null, menuItem.label), typeof menuItem.shortcutKey === "object" && /* @__PURE__ */ React.createElement(import_react_contexify.RightSlot, null, getShortcutText(menuItem.shortcutKey, options)))
167
+ );
168
+ });
169
+ }
170
+ function getShortcutText(event, options) {
171
+ const { theme, cmpPrefixCls } = options;
172
+ const keys = [];
173
+ const Keyboard = (props) => {
174
+ return /* @__PURE__ */ React.createElement(import_antd.ConfigProvider, { theme: { algorithm: theme === "dark" ? import_antd.theme.darkAlgorithm : void 0 } }, /* @__PURE__ */ React.createElement(import_antd.Typography.Text, { keyboard: true, className: `${cmpPrefixCls}-shortcut-key` }, props.children));
175
+ };
176
+ if (event.ctrlKey)
177
+ keys.push(/* @__PURE__ */ React.createElement(Keyboard, null, "^"));
178
+ if (event.altKey)
179
+ keys.push(/* @__PURE__ */ React.createElement(Keyboard, null, "⌥"));
180
+ if (event.shiftKey)
181
+ keys.push(/* @__PURE__ */ React.createElement(Keyboard, null, "⇧"));
182
+ if (event.metaKey)
183
+ keys.push(/* @__PURE__ */ React.createElement(Keyboard, null, "⌘"));
184
+ if (event.key) {
185
+ keys.push(/* @__PURE__ */ React.createElement(Keyboard, null, event.key));
186
+ }
187
+ return keys;
188
+ }
189
+ var ContextMenu_default = ContextMenu;
190
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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, ConfigProvider, 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 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 triggerProps?: {\n className?: string;\n style?: CSSProperties;\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 <ConfigProvider theme={{ algorithm: theme === 'dark' ? AntdTheme.darkAlgorithm : undefined }}>\n <Typography.Text keyboard className={`${cmpPrefixCls}-shortcut-key`}>\n {props.children}\n </Typography.Text>\n </ConfigProvider>\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)[];\n}\n\nexport default ContextMenu;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAqE;AACrE,kBAA+D;AAC/D,wBAAuB;AAEvB,6BAA0E;AAC1E,mBAA+B;AAC/B,mBAAqB;AACrB,4BAAO;AAoBP,IAAM,kBAAc,yBAA6C,CAAC,OAAO,QAAQ;AAC/E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,UAAU,CAAC,aAAa;AAAA,IACxB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,EAAE,aAAa,QAAI,yBAAW,2BAAe,aAAa;AAChE,QAAM,YAAY,aAAa,gBAAgB,gBAAgB;AAC/D,QAAM,CAAC,YAAY,QAAQ,SAAS,QAAI,aAAAA,SAAS,SAAS;AAC1D,QAAM,EAAE,MAAM,QAAQ,QAAI,uCAAe,EAAE,GAAG,CAAC;AAC/C,QAAM,iBAAa;AAAA,IACjB,OAAO;AAAA,MACL,OAAO,CAAC,WAAW,MAAS;AAAA,MAC5B,aAAa,CAAC,iBAAiB,MAAS;AAAA,MACxC,OAAO,CAAC,kBAAkB,gBAAgB;AAAA,MAC1C,aAAa,CAAC,iBAAiB,MAAS;AAAA,IAC1C;AAAA,IACA,CAAC;AAAA,EACH;AAGA,QAAM,iBAAa;AAAA,IACjB,CAAC,OAAsC,YAAsD;AAC3F,WAAK;AAAA,QACH;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,mCAAS;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,oBAAgB,6BAAe,MAAM;AACzC,YAAQ;AAAA,EACV,CAAC;AACD,QAAM,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M;AAAQ,SAAK,KAAK,oCAAC,gBAAS,GAAC,CAAW;AAClD,MAAI,MAAM;AAAU,SAAK,KAAK,oCAAC,gBAAS,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": ["useStyle", "classNames", "AntdTheme"]
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,48 @@
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/ContextMenu/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 } = token;
28
+ return {
29
+ [componentCls]: {
30
+ "&-trigger": {
31
+ width: "fit-content"
32
+ },
33
+ "&-menu": {
34
+ padding: 0,
35
+ "&-has-items": {
36
+ padding: "var(--contexify-menu-padding)"
37
+ },
38
+ [`${componentCls}-shortcut-key`]: {
39
+ kbd: {
40
+ fontFamily: "-apple-system,BlinkMacSystemFont,PingFang SC,Hiragino Sans GB,sans-serif"
41
+ }
42
+ }
43
+ }
44
+ }
45
+ };
46
+ };
47
+ var style_default = (0, import_internal.genStyleHooks)("ContextMenu", genStyle);
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 OverflowTagsToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {\n const { componentCls } = token;\n return {\n [componentCls]: {\n '&-trigger': {\n width: 'fit-content',\n },\n '&-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,WAA6C,CAAC,UAAqB;AACvE,QAAM,EAAE,aAAa,IAAI;AACzB,SAAO;AAAA,IACL,CAAC,YAAY,GAAG;AAAA,MACd,aAAa;AAAA,QACX,OAAO;AAAA,MACT;AAAA,MACA,UAAU;AAAA,QACR,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
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- import { type ConfirmActionWithStatic } from '../ConfirmAction';
1
+ import type { ConfirmActionWithStatic } from '../ConfirmAction';
2
2
  /**
3
3
  * - **EN:** Delete operation confirmation box
4
4
  * - **CN:** 删除操作确认框
@@ -33,22 +33,34 @@ var renderDeleteConfirmAction = (0, import_ConfirmAction.genRenderer)({
33
33
  });
34
34
  var forwarded = (0, import_react.forwardRef)(renderDeleteConfirmAction);
35
35
  var DeleteConfirmAction = forwarded;
36
- DeleteConfirmAction.Button = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
37
- triggerComponent: import_antd.Button,
38
- triggerEvent: "onClick",
39
- triggerProps: {}
40
- });
41
- DeleteConfirmAction.Switch = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
42
- triggerComponent: import_antd.Switch,
43
- triggerEvent: "onChange",
44
- triggerProps: {}
45
- });
46
- DeleteConfirmAction.Link = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
47
- triggerComponent: import_antd.Typography.Link,
48
- triggerEvent: "onClick",
49
- triggerProps: {
50
- style: { whiteSpace: "nowrap" }
36
+ DeleteConfirmAction.Button = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ forwarded,
39
+ {
40
+ triggerComponent: import_antd.Button,
41
+ triggerEvent: "onClick",
42
+ triggerProps: {}
51
43
  }
52
- });
44
+ );
45
+ DeleteConfirmAction.Switch = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ forwarded,
48
+ {
49
+ triggerComponent: import_antd.Switch,
50
+ triggerEvent: "onChange",
51
+ triggerProps: {}
52
+ }
53
+ );
54
+ DeleteConfirmAction.Link = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ forwarded,
57
+ {
58
+ triggerComponent: import_antd.Typography.Link,
59
+ triggerEvent: "onClick",
60
+ triggerProps: {
61
+ style: { whiteSpace: "nowrap" }
62
+ }
63
+ }
64
+ );
53
65
  var DeleteConfirmAction_default = DeleteConfirmAction;
54
66
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/DeleteConfirmAction/index.tsx"],
4
- "sourcesContent": ["import { forwardRef } from 'react';\nimport type { ButtonProps, SwitchProps } from 'antd';\nimport { Button, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { CloseCircleFilled } from '@ant-design/icons';\nimport { type ConfirmActionWithStatic, genRenderer, withDefaultConfirmActionProps } from '../ConfirmAction';\n\nconst renderDeleteConfirmAction = genRenderer({\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n});\nconst forwarded = forwardRef(renderDeleteConfirmAction);\n\n/**\n * - **EN:** Delete operation confirmation box\n * - **CN:** 删除操作确认框\n */\nconst DeleteConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n/**\n * - **EN:** Deletion confirmation box with button type\n * - **CN:** 按钮类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n/**\n * - **EN:** Deletion confirmation box with switch type\n * - **CN:** 开关类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n/**\n * - **EN:** Deletion confirmation box with link type\n * - **CN:** 链接类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Link = withDefaultConfirmActionProps<LinkProps, 'onClick'>(forwarded as any, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n});\n\nexport default DeleteConfirmAction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAE3B,kBAA2C;AAE3C,mBAAkC;AAClC,2BAAyF;AAEzF,IAAM,gCAA4B,kCAAY;AAAA,EAC5C,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM,oCAAC,oCAAkB;AAC3B,CAAC;AACD,IAAM,gBAAY,yBAAW,yBAAyB;AAMtD,IAAM,sBAAsB;AAM5B,oBAAoB,aAAS,oDAAsD,WAAkB;AAAA,EACnG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAMD,oBAAoB,aAAS,oDAAuD,WAAkB;AAAA,EACpG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAMD,oBAAoB,WAAO,oDAAoD,WAAkB;AAAA,EAC/F,kBAAkB,uBAAW;AAAA,EAC7B,cAAc;AAAA,EACd,cAAc;AAAA,IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,8BAAQ;",
4
+ "sourcesContent": ["import { forwardRef } from 'react';\nimport type { ButtonProps, SwitchProps } from 'antd';\nimport { Button, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { CloseCircleFilled } from '@ant-design/icons';\nimport type { ActionCompConstraint, ConfirmActionWithStatic } from '../ConfirmAction';\nimport { genRenderer, withDefaultConfirmActionProps } from '../ConfirmAction';\n\nconst renderDeleteConfirmAction = genRenderer({\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n});\nconst forwarded = forwardRef(renderDeleteConfirmAction);\n\n/**\n * - **EN:** Delete operation confirmation box\n * - **CN:** 删除操作确认框\n */\nconst DeleteConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n/**\n * - **EN:** Deletion confirmation box with button type\n * - **CN:** 按钮类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.Button = withDefaultConfirmActionProps<ActionCompConstraint, ButtonProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n);\n/**\n * - **EN:** Deletion confirmation box with switch type\n * - **CN:** 开关类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.Switch = withDefaultConfirmActionProps<ActionCompConstraint, SwitchProps, 'onChange', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n);\n/**\n * - **EN:** Deletion confirmation box with link type\n * - **CN:** 链接类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.Link = withDefaultConfirmActionProps<ActionCompConstraint, LinkProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n }\n);\n\nexport default DeleteConfirmAction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAE3B,kBAA2C;AAE3C,mBAAkC;AAElC,2BAA2D;AAE3D,IAAM,gCAA4B,kCAAY;AAAA,EAC5C,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM,oCAAC,oCAAkB;AAC3B,CAAC;AACD,IAAM,gBAAY,yBAAW,yBAAyB;AAMtD,IAAM,sBAAsB;AAM5B,oBAAoB,aAAS;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAMA,oBAAoB,aAAS;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAMA,oBAAoB,WAAO;AAAA;AAAA,EAEzB;AAAA,EACA;AAAA,IACE,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA,EACF;AACF;AAEA,IAAO,8BAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import type { ActionCompConstraint, ConfirmActionProps } from '../ConfirmAction';
3
+ import { type ActionComponentInterface } from '../ConfirmAction/withConfirmAction';
4
+ /**
5
+ * - **EN:** Wrap a component into a delete confirmation dialog component, supporting custom triggers
6
+ * and default properties
7
+ * - **CN:** 将一个组件包装成一个删除确认弹框组件,支持自定义触发器和默认属性
8
+ *
9
+ * @param actionComponent Custom trigger component | 自定义触发器组件
10
+ * @param defaultProps Default properties of the deletion confirm box | 删除确认弹框的默认属性
11
+ */
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
+ danger?: boolean | undefined;
14
+ titleColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
15
+ contentColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
16
+ iconColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
17
+ onOk?: ((...args: Parameters<TriggerProp[Event]>) => unknown) | undefined;
18
+ afterOk?: ((data?: any) => void) | undefined;
19
+ } & import("react").RefAttributes<import("../ConfirmAction").ConfirmActionRef<Ref>>) => import("react").ReactNode) & import("../ConfirmAction/withConfirmAction").TypedTriggers<P, Ref>;
@@ -0,0 +1,38 @@
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/DeleteConfirmAction/withDeleteConfirmAction.tsx
20
+ var withDeleteConfirmAction_exports = {};
21
+ __export(withDeleteConfirmAction_exports, {
22
+ default: () => withDeleteConfirmAction
23
+ });
24
+ module.exports = __toCommonJS(withDeleteConfirmAction_exports);
25
+ var import_icons = require("@ant-design/icons");
26
+ var import_withConfirmAction = require("../ConfirmAction/withConfirmAction");
27
+ function withDeleteConfirmAction(ActionComponent, defaultProps) {
28
+ return (0, import_withConfirmAction.withConfirmActionInternal)(
29
+ ActionComponent,
30
+ {
31
+ confirmType: "delete",
32
+ danger: true,
33
+ icon: /* @__PURE__ */ React.createElement(import_icons.CloseCircleFilled, null)
34
+ },
35
+ defaultProps
36
+ );
37
+ }
38
+ //# sourceMappingURL=withDeleteConfirmAction.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/DeleteConfirmAction/withDeleteConfirmAction.tsx"],
4
+ "sourcesContent": ["import { CloseCircleFilled } from '@ant-design/icons';\nimport type { ActionCompConstraint, ConfirmActionProps } from '../ConfirmAction';\nimport { type ActionComponentInterface, withConfirmActionInternal } from '../ConfirmAction/withConfirmAction';\n\n/**\n * - **EN:** Wrap a component into a delete confirmation dialog component, supporting custom triggers\n * and default properties\n * - **CN:** 将一个组件包装成一个删除确认弹框组件,支持自定义触发器和默认属性\n *\n * @param actionComponent Custom trigger component | 自定义触发器组件\n * @param defaultProps Default properties of the deletion confirm box | 删除确认弹框的默认属性\n */\nexport default function withDeleteConfirmAction<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n return withConfirmActionInternal(\n ActionComponent,\n {\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n },\n defaultProps\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAElC,+BAAyE;AAU1D,SAAR,wBAML,iBACA,cAKA;AACA,aAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,oCAAC,oCAAkB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }