@tiny-codes/react-easy 1.0.11 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +2 -2
  3. package/es/components/ConfirmAction/index.js +16 -12
  4. package/es/components/ConfirmAction/index.js.map +1 -1
  5. package/es/components/FloatDrawer/index.d.ts +1 -1
  6. package/es/components/FloatDrawer/index.js.map +1 -1
  7. package/es/components/OverflowTags/index.d.ts +52 -0
  8. package/es/components/OverflowTags/index.js +91 -0
  9. package/es/components/OverflowTags/index.js.map +1 -0
  10. package/es/components/OverflowTags/style/index.d.ts +3 -0
  11. package/es/components/OverflowTags/style/index.js +18 -0
  12. package/es/components/OverflowTags/style/index.js.map +1 -0
  13. package/es/components/index.d.ts +2 -0
  14. package/es/components/index.js +1 -2
  15. package/es/components/index.js.map +1 -1
  16. package/es/utils/index.d.ts +1 -0
  17. package/es/utils/index.js +1 -0
  18. package/es/utils/index.js.map +1 -1
  19. package/es/utils/math.d.ts +11 -0
  20. package/es/utils/math.js +17 -0
  21. package/es/utils/math.js.map +1 -0
  22. package/lib/components/ConfirmAction/index.js +17 -8
  23. package/lib/components/ConfirmAction/index.js.map +2 -2
  24. package/lib/components/FloatDrawer/index.d.ts +1 -1
  25. package/lib/components/FloatDrawer/index.js.map +2 -2
  26. package/lib/components/OverflowTags/index.d.ts +52 -0
  27. package/lib/components/OverflowTags/index.js +107 -0
  28. package/lib/components/OverflowTags/index.js.map +7 -0
  29. package/lib/components/OverflowTags/style/index.d.ts +3 -0
  30. package/lib/components/OverflowTags/style/index.js +38 -0
  31. package/lib/components/OverflowTags/style/index.js.map +7 -0
  32. package/lib/components/index.d.ts +2 -0
  33. package/lib/components/index.js +3 -0
  34. package/lib/components/index.js.map +2 -2
  35. package/lib/utils/index.d.ts +1 -0
  36. package/lib/utils/index.js +3 -1
  37. package/lib/utils/index.js.map +2 -2
  38. package/lib/utils/math.d.ts +11 -0
  39. package/lib/utils/math.js +35 -0
  40. package/lib/utils/math.js.map +7 -0
  41. package/package.json +4 -3
@@ -0,0 +1,18 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ import { genStyleHooks } from 'antd/es/theme/internal';
6
+ var genStyle = function genStyle(token) {
7
+ var componentCls = token.componentCls;
8
+ return _defineProperty({}, componentCls, {
9
+ display: 'flex',
10
+ flexWrap: 'wrap',
11
+ maxWidth: '100%',
12
+ position: 'relative'
13
+ });
14
+ };
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ export default genStyleHooks('re-overflow-tags', genStyle);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["genStyleHooks","genStyle","token","componentCls","_defineProperty","display","flexWrap","maxWidth","position"],"sources":["../../../../src/components/OverflowTags/style/index.ts"],"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 display: 'flex',\n flexWrap: 'wrap',\n maxWidth: '100%',\n position: 'relative',\n },\n };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default genStyleHooks('re-overflow-tags' as any, genStyle);\n"],"mappings":";;;;AAAA,SAASA,aAAa,QAAQ,wBAAwB;AAOtD,IAAMC,QAA0C,GAAG,SAA7CA,QAA0CA,CAAIC,KAAK,EAAgB;EACvE,IAAQC,YAAY,GAAKD,KAAK,CAAtBC,YAAY;EACpB,OAAAC,eAAA,KACGD,YAAY,EAAG;IACdE,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE,MAAM;IAChBC,QAAQ,EAAE,MAAM;IAChBC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;;AAED;AACA,eAAeR,aAAa,CAAC,kBAAkB,EAASC,QAAQ,CAAC"}
@@ -13,3 +13,5 @@ export { default as FloatDrawer } from './FloatDrawer';
13
13
  export type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';
14
14
  export { withDefaultModalActionProps, withModalAction } from './ModalAction';
15
15
  export { default as ModalAction } from './ModalAction';
16
+ export type { OverflowTagsProps } from './OverflowTags';
17
+ export { default as OverflowTags } from './OverflowTags';
@@ -9,6 +9,5 @@ export { default as DeleteConfirmAction } from "./DeleteConfirmAction";
9
9
  export { default as FloatDrawer } from "./FloatDrawer";
10
10
  export { withDefaultModalActionProps, withModalAction } from "./ModalAction";
11
11
  export { default as ModalAction } from "./ModalAction";
12
-
13
- // export * from '../utils';
12
+ export { default as OverflowTags } from "./OverflowTags";
14
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","BreakLines","ConfigProvider","ReactEasyContext","withDefaultConfirmActionProps","ConfirmAction","DeleteConfirmAction","FloatDrawer","withDefaultModalActionProps","withModalAction","ModalAction"],"sources":["../../src/components/index.tsx"],"sourcesContent":["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\n// export * from '../utils';\n"],"mappings":"AACA,SAASA,OAAO,IAAIC,UAAU;AAG9B,SAASD,OAAO,IAAIE,cAAc;AAElC,SAASF,OAAO,IAAIG,gBAAgB;AAGpC,SAASC,6BAA6B;AACtC,SAASJ,OAAO,IAAIK,aAAa;;AAEjC;AACA,SAASL,OAAO,IAAIM,mBAAmB;AAGvC,SAASN,OAAO,IAAIO,WAAW;AAG/B,SAASC,2BAA2B,EAAEC,eAAe;AACrD,SAAST,OAAO,IAAIU,WAAW;;AAE/B"}
1
+ {"version":3,"names":["default","BreakLines","ConfigProvider","ReactEasyContext","withDefaultConfirmActionProps","ConfirmAction","DeleteConfirmAction","FloatDrawer","withDefaultModalActionProps","withModalAction","ModalAction","OverflowTags"],"sources":["../../src/components/index.tsx"],"sourcesContent":["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\nexport type { OverflowTagsProps } from './OverflowTags';\nexport { default as OverflowTags } from './OverflowTags';\n"],"mappings":"AACA,SAASA,OAAO,IAAIC,UAAU;AAG9B,SAASD,OAAO,IAAIE,cAAc;AAElC,SAASF,OAAO,IAAIG,gBAAgB;AAGpC,SAASC,6BAA6B;AACtC,SAASJ,OAAO,IAAIK,aAAa;;AAEjC;AACA,SAASL,OAAO,IAAIM,mBAAmB;AAGvC,SAASN,OAAO,IAAIO,WAAW;AAG/B,SAASC,2BAA2B,EAAEC,eAAe;AACrD,SAAST,OAAO,IAAIU,WAAW;AAG/B,SAASV,OAAO,IAAIW,YAAY"}
@@ -1 +1,2 @@
1
1
  export * from './color';
2
+ export * from './math';
package/es/utils/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./color";
2
+ export * from "./math";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './color';\n"],"mappings":"AAAA"}
1
+ {"version":3,"names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './color';\nexport * from './math';\n"],"mappings":"AAAA;AACA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * **EN**: Generate a random number within a specified range (inclusive on both ends)
3
+ *
4
+ * **CN**: 生成指定范围(两端包含)内的随机数
5
+ *
6
+ * @param min The minimum value (inclusive) | 最小值(包含)
7
+ * @param max The maximum value (inclusive) | 最大值(包含)
8
+ *
9
+ * @returns The generated random number | 生成的随机数
10
+ */
11
+ export declare function random(min: number, max: number): number;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * **EN**: Generate a random number within a specified range (inclusive on both ends)
3
+ *
4
+ * **CN**: 生成指定范围(两端包含)内的随机数
5
+ *
6
+ * @param min The minimum value (inclusive) | 最小值(包含)
7
+ * @param max The maximum value (inclusive) | 最大值(包含)
8
+ *
9
+ * @returns The generated random number | 生成的随机数
10
+ */
11
+ export function random(min, max) {
12
+ var array = new Uint32Array(1);
13
+ globalThis.crypto.getRandomValues(array);
14
+ var randomValue = array[0] / (0xffffffff + 1);
15
+ return Math.floor(randomValue * (max - min + 1)) + min;
16
+ }
17
+ //# sourceMappingURL=math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["random","min","max","array","Uint32Array","globalThis","crypto","getRandomValues","randomValue","Math","floor"],"sources":["../../src/utils/math.ts"],"sourcesContent":["/**\n * **EN**: Generate a random number within a specified range (inclusive on both ends)\n *\n * **CN**: 生成指定范围(两端包含)内的随机数\n *\n * @param min The minimum value (inclusive) | 最小值(包含)\n * @param max The maximum value (inclusive) | 最大值(包含)\n *\n * @returns The generated random number | 生成的随机数\n */\nexport function random(min: number, max: number): number {\n const array = new Uint32Array(1);\n globalThis.crypto.getRandomValues(array);\n const randomValue = array[0] / (0xffffffff + 1);\n return Math.floor(randomValue * (max - min + 1)) + min;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,MAAMA,CAACC,GAAW,EAAEC,GAAW,EAAU;EACvD,IAAMC,KAAK,GAAG,IAAIC,WAAW,CAAC,CAAC,CAAC;EAChCC,UAAU,CAACC,MAAM,CAACC,eAAe,CAACJ,KAAK,CAAC;EACxC,IAAMK,WAAW,GAAGL,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC;EAC/C,OAAOM,IAAI,CAACC,KAAK,CAACF,WAAW,IAAIN,GAAG,GAAGD,GAAG,GAAG,CAAC,CAAC,CAAC,GAAGA,GAAG;AACxD"}
@@ -96,6 +96,7 @@ var genRenderer = (defaultProps) => {
96
96
  icon,
97
97
  iconColor,
98
98
  okButtonProps,
99
+ cancelButtonProps,
99
100
  onOk,
100
101
  afterOk,
101
102
  children,
@@ -120,25 +121,31 @@ var genRenderer = (defaultProps) => {
120
121
  return textContent ? /* @__PURE__ */ React.createElement(import_antd.Typography.Text, { type: color }, textContent) : void 0;
121
122
  };
122
123
  const showConfirm = (0, import_useRefFunction.default)(() => {
124
+ const okProps = {
125
+ ...danger ? { type: "primary", danger: true } : {},
126
+ ...okButtonProps ?? {}
127
+ };
128
+ const cancelProps = {
129
+ ...cancelButtonProps ?? {}
130
+ };
123
131
  const api = modal.confirm({
124
132
  title: coloredText(title, titleColor ?? fallbackColor ?? "warning"),
125
133
  content: coloredText(content, contentColor),
126
134
  icon: coloredText(icon, iconColor ?? fallbackColor ?? "warning"),
127
135
  autoFocusButton: null,
128
- okButtonProps: {
129
- ...danger ? { type: "primary", danger: true } : {},
130
- ...okButtonProps ?? {}
131
- },
136
+ okButtonProps: okProps,
137
+ cancelButtonProps: cancelProps,
132
138
  onOk: async () => {
133
139
  try {
134
140
  api.update({
135
141
  closable: true,
136
142
  okButtonProps: {
137
143
  loading: true,
138
- ...okButtonProps
144
+ ...okProps
139
145
  },
140
146
  cancelButtonProps: {
141
- disabled: true
147
+ disabled: true,
148
+ ...cancelProps
142
149
  }
143
150
  });
144
151
  const result = await (onOk == null ? void 0 : onOk(...triggerEventArgsRef.current ?? []));
@@ -147,10 +154,12 @@ var genRenderer = (defaultProps) => {
147
154
  api.update({
148
155
  closable: false,
149
156
  okButtonProps: {
150
- loading: false
157
+ loading: false,
158
+ ...okProps
151
159
  },
152
160
  cancelButtonProps: {
153
- disabled: false
161
+ disabled: false,
162
+ ...cancelProps
154
163
  }
155
164
  });
156
165
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/ConfirmAction/index.tsx"],
4
- "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ModalFuncProps, 'onOk'> &\n ConfirmActionTrigger<TP, E> & {\n /**\n * **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n *\n * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n *\n * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n *\n * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * **EN:** The color of confirm box title, default is `warning`\n *\n * **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box content\n *\n * **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box title icon, default is the same as `titleColor`\n *\n * **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** Callback when click confirm button\n *\n * **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TP[E] should be casted to function type\n onOk?: (...args: Parameters<TP[E]>) => unknown | Promise<unknown>;\n /**\n * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n *\n * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TP extends object, E extends keyof TP> {\n /**\n * **EN:** Trigger component, trigger to show confirm box\n *\n * **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TP>;\n /**\n * **EN:** Props of trigger component\n *\n * **CN:** 触发器组件的Props属性\n */\n triggerProps?: TP;\n /**\n * **EN:** The event name that triggers the dialog\n *\n * **CN:** 触发弹窗的事件名称\n *\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: E;\n /**\n * **EN:** Custom trigger content\n *\n * **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ConfirmActionRef = ReturnType<typeof confirm> & {\n /**\n * **EN:** Show confirm box\n *\n * **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n};\n\n/**\n * **EN:** Generate a confirm box component\n *\n * **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TP extends object, E extends keyof TP>(\n props: ConfirmActionProps<TP, E>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...restDefaults,\n ...props,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TP,\n };\n const context = useContext(ReactEasyContext);\n const defaultTitle = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent\n );\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as E,\n triggerProps,\n danger,\n title = defaultTitle,\n content = defaultContent,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n okButtonProps: {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n },\n onOk: async () => {\n try {\n api.update({\n closable: true,\n okButtonProps: {\n loading: true,\n ...okButtonProps,\n },\n cancelButtonProps: {\n disabled: true,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: false,\n okButtonProps: {\n loading: false,\n },\n cancelButtonProps: {\n disabled: false,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TP)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * **EN:** Add default properties to the ConfirmAction component\n *\n * **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param WrappedComponent ConfirmAction component | ConfirmAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultConfirmActionProps = <TP extends object, E extends keyof TP>(\n WrappedComponent: ComponentType<PropsWithoutRef<ConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>,\n defaultProps?: Partial<ConfirmActionProps<TP, E>>\n) => {\n const WithDefaultProps = forwardRef<ConfirmActionRef, ConfirmActionProps<TP, E>>((props, ref) => {\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...defaultProps,\n ...props,\n triggerProps: {\n ...defaultProps?.triggerProps,\n ...props.triggerProps,\n } as TP,\n };\n return <WrappedComponent ref={ref} {...mergedProps} />;\n });\n WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardedRef(ConfirmAction)';\n\n/**\n * **EN:** Interface of generic type component\n *\n * **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TP extends object, E extends keyof TP>(\n props: PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * **EN:** Interface of specific type component\n *\n * **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TP extends object, E extends keyof TP> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * **EN:** Props definition of specific type component\n *\n * **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TP extends object, E extends keyof TP> = Omit<\n ConfirmActionProps<TP, E>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * **EN:** Confirm box with button trigger\n *\n * **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * **EN:** Confirm box with switch trigger\n *\n * **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * **EN:** Confirm box with link trigger\n *\n * **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\n/**\n * **EN:** Confirm box component with trigger\n *\n * **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n// Type of link\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.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 ConfirmAction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8E;AAE9E,kBAAuD;AAGvD,sBAAqB;AAGrB,iCAAgC;AAChC,8BAA6B;AAC7B,4BAA2B;AAC3B,qBAA6B;AAmGtB,IAAM,cAAc,CAEzB,iBACG;AACH,QAAM,SAAS,CACb,OACA,QACG;AAtHP;AAuHI,UAAM,EAAE,aAAa,GAAG,aAAa,IAAI;AACzC,UAAM,cAAyC;AAAA,MAC7C,GAAG;AAAA,MACH,GAAG;AAAA,MACH,eAAe;AAAA,QACb,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,mBAAmB;AAAA,QACjB,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;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AAc;AAAA,IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,wBAAQ;",
4
+ "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ModalFuncProps, 'onOk'> &\n ConfirmActionTrigger<TP, E> & {\n /**\n * **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n *\n * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n *\n * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n *\n * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * **EN:** The color of confirm box title, default is `warning`\n *\n * **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box content\n *\n * **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box title icon, default is the same as `titleColor`\n *\n * **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** Callback when click confirm button\n *\n * **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TP[E] should be casted to function type\n onOk?: (...args: Parameters<TP[E]>) => unknown | Promise<unknown>;\n /**\n * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n *\n * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TP extends object, E extends keyof TP> {\n /**\n * **EN:** Trigger component, trigger to show confirm box\n *\n * **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TP>;\n /**\n * **EN:** Props of trigger component\n *\n * **CN:** 触发器组件的Props属性\n */\n triggerProps?: TP;\n /**\n * **EN:** The event name that triggers the dialog\n *\n * **CN:** 触发弹窗的事件名称\n *\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: E;\n /**\n * **EN:** Custom trigger content\n *\n * **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ConfirmActionRef = ReturnType<typeof confirm> & {\n /**\n * **EN:** Show confirm box\n *\n * **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n};\n\n/**\n * **EN:** Generate a confirm box component\n *\n * **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TP extends object, E extends keyof TP>(\n props: ConfirmActionProps<TP, E>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...restDefaults,\n ...props,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TP,\n };\n const context = useContext(ReactEasyContext);\n const defaultTitle = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent\n );\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as E,\n triggerProps,\n danger,\n title = defaultTitle,\n content = defaultContent,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const okProps: ButtonProps = {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n };\n const cancelProps: ButtonProps = {\n ...(cancelButtonProps ?? {}),\n };\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n okButtonProps: okProps,\n cancelButtonProps: cancelProps,\n onOk: async () => {\n try {\n api.update({\n closable: true,\n okButtonProps: {\n loading: true,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: true,\n ...cancelProps,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: false,\n okButtonProps: {\n loading: false,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: false,\n ...cancelProps,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TP)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * **EN:** Add default properties to the ConfirmAction component\n *\n * **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param WrappedComponent ConfirmAction component | ConfirmAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultConfirmActionProps = <TP extends object, E extends keyof TP>(\n WrappedComponent: ComponentType<PropsWithoutRef<ConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>,\n defaultProps?: Partial<ConfirmActionProps<TP, E>>\n) => {\n const WithDefaultProps = forwardRef<ConfirmActionRef, ConfirmActionProps<TP, E>>((props, ref) => {\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...defaultProps,\n ...props,\n triggerProps: {\n ...defaultProps?.triggerProps,\n ...props.triggerProps,\n } as TP,\n };\n return <WrappedComponent ref={ref} {...mergedProps} />;\n });\n WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardedRef(ConfirmAction)';\n\n/**\n * **EN:** Interface of generic type component\n *\n * **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TP extends object, E extends keyof TP>(\n props: PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * **EN:** Interface of specific type component\n *\n * **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TP extends object, E extends keyof TP> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * **EN:** Props definition of specific type component\n *\n * **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TP extends object, E extends keyof TP> = Omit<\n ConfirmActionProps<TP, E>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * **EN:** Confirm box with button trigger\n *\n * **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * **EN:** Confirm box with switch trigger\n *\n * **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * **EN:** Confirm box with link trigger\n *\n * **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\n/**\n * **EN:** Confirm box component with trigger\n *\n * **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n// Type of link\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.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 ConfirmAction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8E;AAE9E,kBAAuD;AAGvD,sBAAqB;AAGrB,iCAAgC;AAChC,8BAA6B;AAC7B,4BAA2B;AAC3B,qBAA6B;AAmGtB,IAAM,cAAc,CAEzB,iBACG;AACH,QAAM,SAAS,CACb,OACA,QACG;AAtHP;AAuHI,UAAM,EAAE,aAAa,GAAG,aAAa,IAAI;AACzC,UAAM,cAAyC;AAAA,MAC7C,GAAG;AAAA,MACH,GAAG;AAAA,MACH,eAAe;AAAA,QACb,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,mBAAmB;AAAA,QACjB,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX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BAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAGD,cAAc,SAAS,8BAAuD,WAAkB;AAAA,EAC9F,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAGD,cAAc,OAAO,8BAAoD,WAAkB;AAAA,EACzF,kBAAkB,uBAAW;AAAA,EAC7B,cAAc;AAAA,EACd,cAAc;AAAA,IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,wBAAQ;",
6
6
  "names": ["ReactEasyContext", "useLocalizedText", "useContextValidator", "useToken", "useRefFunction"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties, FC, ReactNode } from 'react';
2
- import { type CardProps } from 'antd';
2
+ import type { CardProps } from 'antd';
3
3
  export interface FloatDrawerProps {
4
4
  /**
5
5
  * **EN:** Whether the drawer is open
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/FloatDrawer/index.tsx"],
4
- "sourcesContent": ["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { Card, type CardProps, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport { DownOutlined, LeftOutlined, RightOutlined, UpOutlined } from '@ant-design/icons';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport useStyle from './style';\n\nexport interface FloatDrawerProps {\n /**\n * **EN:** Whether the drawer is open\n *\n * **CN:** 抽屉是否打开\n */\n open?: boolean;\n /**\n * **EN:** Position of the drawer\n *\n * **CN:** 抽屉的位置\n *\n * @default 'right'\n */\n position?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the\n * width, otherwise it is the height.\n *\n * **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。\n *\n * @default 300\n */\n defaultSize?: number;\n /**\n * **EN:** Minimum size of the drawer\n *\n * **CN:** 抽屉的最小宽度\n *\n * @default 0\n */\n minSize?: number;\n /**\n * **EN:** Maximum size of the drawer\n *\n * **CN:** 抽屉的最大宽度\n *\n * @default Infinity\n */\n maxSize?: number;\n /**\n * **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be\n * cached.\n *\n * **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。\n */\n cacheKey?: string;\n /**\n * **EN:** Custom class name for the root element\n *\n * **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * **EN:** Custom class names for specific elements\n *\n * **CN:** 特定元素的自定义类名\n */\n classNames?: {\n /**\n * **EN:** Class name for the drawer element\n *\n * **CN:** 抽屉元素的类名\n */\n drawer?: string;\n /**\n * **EN:** Class name for the expand handle\n *\n * **CN:** 展开手柄的类名\n */\n expandHandle?: string;\n /**\n * **EN:** Class name for the resize handle\n *\n * **CN:** 调整大小手柄的类名\n */\n resizeHandle?: string;\n /**\n * **EN:** Class name for the handle icon\n *\n * **CN:** 手柄图标的类名\n */\n handleIcon?: string;\n /**\n * **EN:** Class name for the content area\n *\n * **CN:** 内容区域的类名\n */\n content?: string;\n /**\n * **EN:** Class name for the card element\n *\n * **CN:** 卡片元素的类名\n */\n card?: string;\n };\n /**\n * **EN:** Custom styles for the root element\n *\n * **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * **EN:** Custom styles for specific elements\n *\n * **CN:** 特定元素的自定义样式\n */\n styles?: {\n /**\n * **EN:** Styles for the drawer element\n *\n * **CN:** 抽屉元素的样式\n */\n drawer?: CSSProperties;\n /**\n * **EN:** Styles for the expand handle\n *\n * **CN:** 展开手柄的样式\n */\n expandHandle?: CSSProperties;\n /**\n * **EN:** Styles for the resize handle\n *\n * **CN:** 调整大小手柄的样式\n */\n resizeHandle?: CSSProperties;\n /**\n * **EN:** Styles for the handle icon\n *\n * **CN:** 手柄图标的样式\n */\n handleIcon?: CSSProperties;\n /**\n * **EN:** Styles for the content area\n *\n * **CN:** 内容区域的样式\n */\n content?: CSSProperties;\n /**\n * **EN:** Styles for the card element\n *\n * **CN:** 卡片元素的样式\n */\n card?: CSSProperties;\n };\n /**\n * **EN:** Custom properties for the card element\n *\n * **CN:** 卡片元素的自定义属性\n */\n cardProps?: Omit<CardProps, 'children'>;\n /**\n * **EN:** Content to be rendered inside the drawer\n *\n * **CN:** 抽屉内容\n */\n children?: ReactNode;\n /**\n * **EN:** Callback function when the open state changes\n *\n * **CN:** 打开状态变化时的回调函数\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * **EN:** Callback function when the drawer is resized\n *\n * **CN:** 抽屉调整大小时的回调函数\n */\n onResize?: (size: number) => void;\n}\n\n/**\n * **EN:** FloatDrawer component for creating a draggable, resizable drawer\n *\n * **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉\n */\nconst FloatDrawer: FC<FloatDrawerProps> = (props) => {\n const {\n open,\n position = 'right',\n cardProps,\n children,\n className,\n classNames: classNamesInProps,\n style,\n styles,\n cacheKey,\n defaultSize = 300,\n minSize = 0,\n maxSize = +Infinity,\n onOpenChange,\n onResize,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('re-float-drawer');\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [isOpen, setIsOpen] = useState<boolean>();\n const [size, setSize] = useState(\n cacheKey && localStorage.getItem(cacheKey) ? Number(localStorage.getItem(cacheKey)) || defaultSize : defaultSize\n );\n const sizeMap = useMemo(() => {\n const type = position === 'left' || position === 'right' ? 'width' : 'height';\n return {\n [type]: size,\n };\n }, [position, size]);\n const [isDragging, setIsDragging] = useState(false);\n const dragStartPos = useRef<number>(0);\n const dragStartSize = useRef<number>(size);\n const classString = classNames(\n prefixCls,\n className,\n {\n [`${prefixCls}-open`]: isOpen,\n [`${prefixCls}-closed`]: !isOpen,\n [`${prefixCls}-${position}`]: position,\n },\n hashId,\n cssVarCls\n );\n const closeIcon = useMemo(() => {\n return position === 'left' ? (\n <RightOutlined />\n ) : position === 'top' ? (\n <DownOutlined />\n ) : position === 'bottom' ? (\n <UpOutlined />\n ) : (\n <LeftOutlined />\n );\n }, [position]);\n const openIcon = useMemo(() => {\n return position === 'left' ? (\n <LeftOutlined />\n ) : position === 'top' ? (\n <UpOutlined />\n ) : position === 'bottom' ? (\n <DownOutlined />\n ) : (\n <RightOutlined />\n );\n }, [position]);\n\n // Handle drawer visibility\n const toggleDrawer = () => {\n setIsOpen(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n // Handle resize events\n const handleResizeStart = useRefFunction((e: React.MouseEvent) => {\n setIsDragging(true);\n if (position === 'top' || position === 'bottom') {\n dragStartPos.current = e.clientY;\n } else {\n dragStartPos.current = e.clientX;\n }\n dragStartSize.current = size;\n e.preventDefault();\n });\n const handleResize = useRefFunction((e: MouseEvent) => {\n if (isDragging) {\n let newSize: number;\n if (position === 'left') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientX);\n } else if (position === 'top') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientY);\n } else if (position === 'bottom') {\n newSize = dragStartSize.current - (e.clientY - dragStartPos.current);\n } else {\n newSize = dragStartSize.current - (e.clientX - dragStartPos.current);\n }\n if (newSize >= minSize && newSize <= maxSize) {\n setSize(newSize);\n if (cacheKey) {\n localStorage.setItem(cacheKey, String(newSize));\n }\n onResize?.(newSize);\n }\n }\n });\n const handleResizeEnd = useRefFunction(() => {\n setIsDragging(false);\n });\n\n // Controlled open state\n useEffect(() => {\n setIsOpen(open);\n }, [open]);\n\n // Handle global events\n useEffect(() => {\n if (isDragging) {\n window.addEventListener('mousemove', handleResize);\n window.addEventListener('mouseup', handleResizeEnd);\n } else {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n }\n return () => {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n };\n }, [isDragging]);\n\n return wrapCSSVar(\n <div className={classString} style={style}>\n <div\n className={classNames(`${prefixCls}-drawer`, classNamesInProps?.drawer)}\n style={{ ...sizeMap, ...styles?.drawer }}\n >\n <div\n className={classNames(\n `${prefixCls}-resize-handle`,\n isDragging && `${prefixCls}-resize-handle-dragging`,\n classNamesInProps?.resizeHandle\n )}\n style={styles?.resizeHandle}\n onMouseDown={handleResizeStart}\n />\n <div className={classNames(`${prefixCls}-content`, classNamesInProps?.content)} style={styles?.content}>\n <Card\n bordered={false}\n variant=\"borderless\"\n className={classNames(`${prefixCls}-card`, classNamesInProps?.card)}\n style={styles?.card}\n {...cardProps}\n >\n {children}\n </Card>\n </div>\n <div\n className={classNames(`${prefixCls}-expand-handle`, classNamesInProps?.expandHandle)}\n style={styles?.expandHandle}\n onClick={toggleDrawer}\n >\n <div\n className={classNames(`${prefixCls}-handle-icon`, classNamesInProps?.handleIcon)}\n style={styles?.handleIcon}\n >\n {isOpen ? openIcon : closeIcon}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default FloatDrawer;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAiE;AACjE,kBAAqD;AACrD,wBAAuB;AACvB,mBAAsE;AACtE,4BAA2B;AAC3B,mBAAqB;AAkLrB,IAAM,cAAoC,CAAC,UAAU;AACnD,QAAM;AAAA,IACJ;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,aAAa,QAAI,yBAAW,2BAAe,aAAa;AAChE,QAAM,YAAY,aAAa,iBAAiB;AAChD,QAAM,CAAC,YAAY,QAAQ,SAAS,QAAI,aAAAA,SAAS,SAAS;AAC1D,QAAM,CAAC,QA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AAA,MAAC;AAAA;AAAA,QACC,eAAW,kBAAAD,SAAW,GAAG,oBAAoB,uDAAmB,MAAM;AAAA,QACtE,OAAO,EAAE,GAAG,SAAS,GAAG,iCAAQ,OAAO;AAAA;AAAA,MAEvC;AAAA,QAAC;AAAA;AAAA,UACC,eAAW,kBAAAA;AAAA,YACT,GAAG;AAAA,YACH,cAAc,GAAG;AAAA,YACjB,uDAAmB;AAAA,UACrB;AAAA,UACA,OAAO,iCAAQ;AAAA,UACf,aAAa;AAAA;AAAA,MACf;AAAA,MACA,oCAAC,SAAI,eAAW,kBAAAA,SAAW,GAAG,qBAAqB,uDAAmB,OAAO,GAAG,OAAO,iCAAQ,WAC7F;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,SAAQ;AAAA,UACR,eAAW,kBAAAA,SAAW,GAAG,kBAAkB,uDAAmB,IAAI;AAAA,UAClE,OAAO,iCAAQ;AAAA,UACd,GAAG;AAAA;AAAA,QAEH;AAAA,MACH,CACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,eAAW,kBAAAA,SAAW,GAAG,2BAA2B,uDAAmB,YAAY;AAAA,UACnF,OAAO,iCAAQ;AAAA,UACf,SAAS;AAAA;AAAA,QAET;AAAA,UAAC;AAAA;AAAA,YACC,eAAW,kBAAAA,SAAW,GAAG,yBAAyB,uDAAmB,UAAU;AAAA,YAC/E,OAAO,iCAAQ;AAAA;AAAA,UAEd,SAAS,WAAW;AAAA,QACvB;AAAA,MACF;AAAA,IACF,CACF;AAAA,EACF;AACF;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { CardProps } from 'antd';\nimport { Card, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport { DownOutlined, LeftOutlined, RightOutlined, UpOutlined } from '@ant-design/icons';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport useStyle from './style';\n\nexport interface FloatDrawerProps {\n /**\n * **EN:** Whether the drawer is open\n *\n * **CN:** 抽屉是否打开\n */\n open?: boolean;\n /**\n * **EN:** Position of the drawer\n *\n * **CN:** 抽屉的位置\n *\n * @default 'right'\n */\n position?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the\n * width, otherwise it is the height.\n *\n * **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。\n *\n * @default 300\n */\n defaultSize?: number;\n /**\n * **EN:** Minimum size of the drawer\n *\n * **CN:** 抽屉的最小宽度\n *\n * @default 0\n */\n minSize?: number;\n /**\n * **EN:** Maximum size of the drawer\n *\n * **CN:** 抽屉的最大宽度\n *\n * @default Infinity\n */\n maxSize?: number;\n /**\n * **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be\n * cached.\n *\n * **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。\n */\n cacheKey?: string;\n /**\n * **EN:** Custom class name for the root element\n *\n * **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * **EN:** Custom class names for specific elements\n *\n * **CN:** 特定元素的自定义类名\n */\n classNames?: {\n /**\n * **EN:** Class name for the drawer element\n *\n * **CN:** 抽屉元素的类名\n */\n drawer?: string;\n /**\n * **EN:** Class name for the expand handle\n *\n * **CN:** 展开手柄的类名\n */\n expandHandle?: string;\n /**\n * **EN:** Class name for the resize handle\n *\n * **CN:** 调整大小手柄的类名\n */\n resizeHandle?: string;\n /**\n * **EN:** Class name for the handle icon\n *\n * **CN:** 手柄图标的类名\n */\n handleIcon?: string;\n /**\n * **EN:** Class name for the content area\n *\n * **CN:** 内容区域的类名\n */\n content?: string;\n /**\n * **EN:** Class name for the card element\n *\n * **CN:** 卡片元素的类名\n */\n card?: string;\n };\n /**\n * **EN:** Custom styles for the root element\n *\n * **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * **EN:** Custom styles for specific elements\n *\n * **CN:** 特定元素的自定义样式\n */\n styles?: {\n /**\n * **EN:** Styles for the drawer element\n *\n * **CN:** 抽屉元素的样式\n */\n drawer?: CSSProperties;\n /**\n * **EN:** Styles for the expand handle\n *\n * **CN:** 展开手柄的样式\n */\n expandHandle?: CSSProperties;\n /**\n * **EN:** Styles for the resize handle\n *\n * **CN:** 调整大小手柄的样式\n */\n resizeHandle?: CSSProperties;\n /**\n * **EN:** Styles for the handle icon\n *\n * **CN:** 手柄图标的样式\n */\n handleIcon?: CSSProperties;\n /**\n * **EN:** Styles for the content area\n *\n * **CN:** 内容区域的样式\n */\n content?: CSSProperties;\n /**\n * **EN:** Styles for the card element\n *\n * **CN:** 卡片元素的样式\n */\n card?: CSSProperties;\n };\n /**\n * **EN:** Custom properties for the card element\n *\n * **CN:** 卡片元素的自定义属性\n */\n cardProps?: Omit<CardProps, 'children'>;\n /**\n * **EN:** Content to be rendered inside the drawer\n *\n * **CN:** 抽屉内容\n */\n children?: ReactNode;\n /**\n * **EN:** Callback function when the open state changes\n *\n * **CN:** 打开状态变化时的回调函数\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * **EN:** Callback function when the drawer is resized\n *\n * **CN:** 抽屉调整大小时的回调函数\n */\n onResize?: (size: number) => void;\n}\n\n/**\n * **EN:** FloatDrawer component for creating a draggable, resizable drawer\n *\n * **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉\n */\nconst FloatDrawer: FC<FloatDrawerProps> = (props) => {\n const {\n open,\n position = 'right',\n cardProps,\n children,\n className,\n classNames: classNamesInProps,\n style,\n styles,\n cacheKey,\n defaultSize = 300,\n minSize = 0,\n maxSize = +Infinity,\n onOpenChange,\n onResize,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('re-float-drawer');\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [isOpen, setIsOpen] = useState<boolean>();\n const [size, setSize] = useState(\n cacheKey && localStorage.getItem(cacheKey) ? Number(localStorage.getItem(cacheKey)) || defaultSize : defaultSize\n );\n const sizeMap = useMemo(() => {\n const type = position === 'left' || position === 'right' ? 'width' : 'height';\n return {\n [type]: size,\n };\n }, [position, size]);\n const [isDragging, setIsDragging] = useState(false);\n const dragStartPos = useRef<number>(0);\n const dragStartSize = useRef<number>(size);\n const classString = classNames(\n prefixCls,\n className,\n {\n [`${prefixCls}-open`]: isOpen,\n [`${prefixCls}-closed`]: !isOpen,\n [`${prefixCls}-${position}`]: position,\n },\n hashId,\n cssVarCls\n );\n const closeIcon = useMemo(() => {\n return position === 'left' ? (\n <RightOutlined />\n ) : position === 'top' ? (\n <DownOutlined />\n ) : position === 'bottom' ? (\n <UpOutlined />\n ) : (\n <LeftOutlined />\n );\n }, [position]);\n const openIcon = useMemo(() => {\n return position === 'left' ? (\n <LeftOutlined />\n ) : position === 'top' ? (\n <UpOutlined />\n ) : position === 'bottom' ? (\n <DownOutlined />\n ) : (\n <RightOutlined />\n );\n }, [position]);\n\n // Handle drawer visibility\n const toggleDrawer = () => {\n setIsOpen(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n // Handle resize events\n const handleResizeStart = useRefFunction((e: React.MouseEvent) => {\n setIsDragging(true);\n if (position === 'top' || position === 'bottom') {\n dragStartPos.current = e.clientY;\n } else {\n dragStartPos.current = e.clientX;\n }\n dragStartSize.current = size;\n e.preventDefault();\n });\n const handleResize = useRefFunction((e: MouseEvent) => {\n if (isDragging) {\n let newSize: number;\n if (position === 'left') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientX);\n } else if (position === 'top') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientY);\n } else if (position === 'bottom') {\n newSize = dragStartSize.current - (e.clientY - dragStartPos.current);\n } else {\n newSize = dragStartSize.current - (e.clientX - dragStartPos.current);\n }\n if (newSize >= minSize && newSize <= maxSize) {\n setSize(newSize);\n if (cacheKey) {\n localStorage.setItem(cacheKey, String(newSize));\n }\n onResize?.(newSize);\n }\n }\n });\n const handleResizeEnd = useRefFunction(() => {\n setIsDragging(false);\n });\n\n // Controlled open state\n useEffect(() => {\n setIsOpen(open);\n }, [open]);\n\n // Handle global events\n useEffect(() => {\n if (isDragging) {\n window.addEventListener('mousemove', handleResize);\n window.addEventListener('mouseup', handleResizeEnd);\n } else {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n }\n return () => {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n };\n }, [isDragging]);\n\n return wrapCSSVar(\n <div className={classString} style={style}>\n <div\n className={classNames(`${prefixCls}-drawer`, classNamesInProps?.drawer)}\n style={{ ...sizeMap, ...styles?.drawer }}\n >\n <div\n className={classNames(\n `${prefixCls}-resize-handle`,\n isDragging && `${prefixCls}-resize-handle-dragging`,\n classNamesInProps?.resizeHandle\n )}\n style={styles?.resizeHandle}\n onMouseDown={handleResizeStart}\n />\n <div className={classNames(`${prefixCls}-content`, classNamesInProps?.content)} style={styles?.content}>\n <Card\n bordered={false}\n variant=\"borderless\"\n className={classNames(`${prefixCls}-card`, classNamesInProps?.card)}\n style={styles?.card}\n {...cardProps}\n >\n {children}\n </Card>\n </div>\n <div\n className={classNames(`${prefixCls}-expand-handle`, classNamesInProps?.expandHandle)}\n style={styles?.expandHandle}\n onClick={toggleDrawer}\n >\n <div\n className={classNames(`${prefixCls}-handle-icon`, classNamesInProps?.handleIcon)}\n style={styles?.handleIcon}\n >\n {isOpen ? openIcon : closeIcon}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default FloatDrawer;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAiE;AAEjE,kBAAqC;AACrC,wBAAuB;AACvB,mBAAsE;AACtE,4BAA2B;AAC3B,mBAAqB;AAkLrB,IAAM,cAAoC,CAAC,UAAU;AACnD,QAAM;AAAA,IACJ;AAAA,IACA,WAAW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SAAS,WAAW;AAAA,QACvB;AAAA,MACF;AAAA,IACF,CACF;AAAA,EACF;AACF;AAEA,IAAO,sBAAQ;",
6
6
  "names": ["useStyle", "classNames", "useRefFunction"]
7
7
  }
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { TagProps } from 'antd';
3
+ import type { OverflowProps } from 'rc-overflow';
4
+ export interface OverflowTagsProps<T extends Record<string, unknown> = Record<string, unknown>> extends OverflowProps<T> {
5
+ /**
6
+ * **CN**: 标签集合的数据
7
+ *
8
+ * **EN**: Data collection of tags
9
+ */
10
+ tags: T[] | undefined;
11
+ /**
12
+ * **EN**: Function to get the tag name, default is `tag.name`
13
+ *
14
+ * **CN**: 获取标签名称的函数,默认取`tag.name`
15
+ */
16
+ getTagName?: (tag: T) => ReactNode;
17
+ /**
18
+ * **EN**: Function to get the unique identifier of the tag, default is `tag.id`
19
+ *
20
+ * **CN**: 获取标签唯一标识的函数,默认取`tag.id`
21
+ */
22
+ getTagKey?: (tag: T) => React.Key;
23
+ /**
24
+ * **EN**: Function to render the tag, returns `TagProps`
25
+ *
26
+ * **CN**: 渲染标签的函数,返回`TagProps`
27
+ */
28
+ renderTag?: (tag: T, tags: T[]) => TagProps;
29
+ /**
30
+ * **EN**: Custom properties for the tag component, if `renderTag` is also specified, the latter
31
+ * will override the former
32
+ *
33
+ * **CN**: 自定义标签的组件属性,如果同时指定了`renderTag`,则后者会覆盖前者
34
+ */
35
+ tagProps?: TagProps;
36
+ /**
37
+ * **EN**: When the number of tags exceeds the maximum display count, an ellipsis tag will be
38
+ * shown. This property is used to set the style of the ellipsis tag.
39
+ *
40
+ * **CN**: 当标签数量超过最大显示数量时,会显示省略号的标签,此属性用于设置省略号标签的样式
41
+ */
42
+ ellipsisTagProps?: TagProps;
43
+ /**
44
+ * **EN**: Whether to use random colors, default is `false`. Note that the tag object can also
45
+ * contain a `color` property to specify the color, and the latter takes precedence.
46
+ *
47
+ * **CN**: 是否使用随机颜色,默认`false`。注意,tag对象还可以包含`color`属性来指定颜色,而且后者优先级更高。
48
+ */
49
+ randomColors?: boolean;
50
+ }
51
+ declare const OverflowTags: <T extends Record<string, any>>(props: OverflowTagsProps<T>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
52
+ export default OverflowTags;
@@ -0,0 +1,107 @@
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/OverflowTags/index.tsx
30
+ var OverflowTags_exports = {};
31
+ __export(OverflowTags_exports, {
32
+ default: () => OverflowTags_default
33
+ });
34
+ module.exports = __toCommonJS(OverflowTags_exports);
35
+ var import_react = require("react");
36
+ var import_antd = require("antd");
37
+ var import_internal = require("antd/es/theme/internal");
38
+ var import_classnames = __toESM(require("classnames"));
39
+ var import_rc_overflow = __toESM(require("rc-overflow"));
40
+ var import_math = require("../../utils/math");
41
+ var import_style = __toESM(require("./style"));
42
+ var OverflowTags = (props) => {
43
+ const {
44
+ tags = [],
45
+ randomColors,
46
+ getTagName: getTagNameInProps,
47
+ getTagKey,
48
+ renderTag: renderTagInProps,
49
+ tagProps,
50
+ ellipsisTagProps,
51
+ className,
52
+ ...restProps
53
+ } = props;
54
+ const { token } = import_antd.theme.useToken();
55
+ const { getPrefixCls } = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
56
+ const prefixCls = getPrefixCls("re-float-drawer");
57
+ const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
58
+ const colors = (0, import_react.useMemo)(
59
+ () => import_internal.PresetColors.filter((c) => !["lime", "yellow", "magenta"].includes(c)).map((color) => token[`${color}-3`]),
60
+ [token]
61
+ );
62
+ const getTagName = (0, import_react.useCallback)(
63
+ (tag) => {
64
+ return getTagNameInProps ? getTagNameInProps(tag) : tag.name;
65
+ },
66
+ [getTagNameInProps]
67
+ );
68
+ const renderTag = (item) => {
69
+ const customProps = renderTagInProps == null ? void 0 : renderTagInProps(item, tags);
70
+ return /* @__PURE__ */ React.createElement(
71
+ import_antd.Tag,
72
+ {
73
+ ...tagProps,
74
+ color: randomColors ? colors[(0, import_math.random)(0, colors.length - 1)] : item.color ?? "default",
75
+ ...customProps
76
+ },
77
+ getTagName(item)
78
+ );
79
+ };
80
+ return wrapCSSVar(
81
+ /* @__PURE__ */ React.createElement(
82
+ import_rc_overflow.default,
83
+ {
84
+ className: (0, import_classnames.default)(hashId, cssVarCls, prefixCls, className),
85
+ data: tags,
86
+ maxCount: "responsive",
87
+ renderItem: renderTag,
88
+ renderRest: (omittedItems) => /* @__PURE__ */ React.createElement(
89
+ import_antd.Dropdown,
90
+ {
91
+ menu: {
92
+ items: omittedItems.map((tag) => ({
93
+ type: "item",
94
+ key: getTagKey ? getTagKey(tag) : tag.id ?? getTagName(tag),
95
+ label: getTagName(tag)
96
+ }))
97
+ }
98
+ },
99
+ /* @__PURE__ */ React.createElement(import_antd.Tag, { ...ellipsisTagProps }, "+ ", omittedItems.length, "...")
100
+ ),
101
+ ...restProps
102
+ }
103
+ )
104
+ );
105
+ };
106
+ var OverflowTags_default = OverflowTags;
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/OverflowTags/index.tsx"],
4
+ "sourcesContent": ["import type { ReactNode } from 'react';\nimport { useCallback, useContext, useMemo } from 'react';\nimport type { TagProps } from 'antd';\nimport { ConfigProvider, Dropdown, Tag, theme } from 'antd';\nimport { PresetColors } from 'antd/es/theme/internal';\nimport classNames from 'classnames';\nimport type { OverflowProps } from 'rc-overflow';\nimport Overflow from 'rc-overflow';\nimport { random } from '../../utils/math';\nimport useStyle from './style';\n\nexport interface OverflowTagsProps<T extends Record<string, unknown> = Record<string, unknown>>\n extends OverflowProps<T> {\n /**\n * **CN**: 标签集合的数据\n *\n * **EN**: Data collection of tags\n */\n tags: T[] | undefined;\n /**\n * **EN**: Function to get the tag name, default is `tag.name`\n *\n * **CN**: 获取标签名称的函数,默认取`tag.name`\n */\n getTagName?: (tag: T) => ReactNode;\n /**\n * **EN**: Function to get the unique identifier of the tag, default is `tag.id`\n *\n * **CN**: 获取标签唯一标识的函数,默认取`tag.id`\n */\n getTagKey?: (tag: T) => React.Key;\n /**\n * **EN**: Function to render the tag, returns `TagProps`\n *\n * **CN**: 渲染标签的函数,返回`TagProps`\n */\n renderTag?: (tag: T, tags: T[]) => TagProps;\n /**\n * **EN**: Custom properties for the tag component, if `renderTag` is also specified, the latter\n * will override the former\n *\n * **CN**: 自定义标签的组件属性,如果同时指定了`renderTag`,则后者会覆盖前者\n */\n tagProps?: TagProps;\n /**\n * **EN**: When the number of tags exceeds the maximum display count, an ellipsis tag will be\n * shown. This property is used to set the style of the ellipsis tag.\n *\n * **CN**: 当标签数量超过最大显示数量时,会显示省略号的标签,此属性用于设置省略号标签的样式\n */\n ellipsisTagProps?: TagProps;\n /**\n * **EN**: Whether to use random colors, default is `false`. Note that the tag object can also\n * contain a `color` property to specify the color, and the latter takes precedence.\n *\n * **CN**: 是否使用随机颜色,默认`false`。注意,tag对象还可以包含`color`属性来指定颜色,而且后者优先级更高。\n */\n randomColors?: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst OverflowTags = <T extends Record<string, any>>(props: OverflowTagsProps<T>) => {\n const {\n tags = [],\n randomColors,\n getTagName: getTagNameInProps,\n getTagKey,\n renderTag: renderTagInProps,\n tagProps,\n ellipsisTagProps,\n className,\n ...restProps\n } = props;\n const { token } = theme.useToken();\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('re-float-drawer');\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n\n const colors = useMemo(\n () => PresetColors.filter((c) => !['lime', 'yellow', 'magenta'].includes(c)).map((color) => token[`${color}-3`]),\n [token]\n );\n const getTagName = useCallback(\n (tag: T) => {\n return getTagNameInProps ? getTagNameInProps(tag) : tag.name;\n },\n [getTagNameInProps]\n );\n const renderTag = (item: T) => {\n const customProps = renderTagInProps?.(item, tags);\n return (\n <Tag\n {...tagProps}\n color={randomColors ? colors[random(0, colors.length - 1)] : (item.color ?? 'default')}\n {...customProps}\n >\n {getTagName(item)}\n </Tag>\n );\n };\n\n return wrapCSSVar(\n <Overflow<T>\n className={classNames(hashId, cssVarCls, prefixCls, className)}\n data={tags}\n maxCount=\"responsive\"\n renderItem={renderTag}\n renderRest={(omittedItems) => (\n <Dropdown\n menu={{\n items: omittedItems.map((tag) => ({\n type: 'item',\n key: getTagKey ? getTagKey(tag) : (tag.id ?? getTagName(tag)),\n label: getTagName(tag),\n })),\n }}\n >\n <Tag {...ellipsisTagProps}>+ {omittedItems.length}...</Tag>\n </Dropdown>\n )}\n {...restProps}\n />\n );\n};\n\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C;AAAA,MAAA;AAAA,QACC,eAAW,kBAAAC,SAAW,QAAQ,WAAW,WAAW,SAAS;AAAA,QAC7D,MAAM;AAAA,QACN,UAAS;AAAA,QACT,YAAY;AAAA,QACZ,YAAY,CAAC,iBACX;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,cACJ,OAAO,aAAa,IAAI,CAAC,SAAS;AAAA,gBAChC,MAAM;AAAA,gBACN,KAAK,YAAY,UAAU,GAAG,IAAK,IAAI,MAAM,WAAW,GAAG;AAAA,gBAC3D,OAAO,WAAW,GAAG;AAAA,cACvB,EAAE;AAAA,YACJ;AAAA;AAAA,UAEA,oCAAC,mBAAK,GAAG,oBAAkB,MAAG,aAAa,QAAO,KAAG;AAAA,QACvD;AAAA,QAED,GAAG;AAAA;AAAA,IACN;AAAA,EACF;AACF;AAEA,IAAO,uBAAQ;",
6
+ "names": ["useStyle", "Overflow", "classNames"]
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,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/OverflowTags/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
+ display: "flex",
31
+ flexWrap: "wrap",
32
+ maxWidth: "100%",
33
+ position: "relative"
34
+ }
35
+ };
36
+ };
37
+ var style_default = (0, import_internal.genStyleHooks)("re-overflow-tags", genStyle);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/OverflowTags/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 display: 'flex',\n flexWrap: 'wrap',\n maxWidth: '100%',\n position: 'relative',\n },\n };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default genStyleHooks('re-overflow-tags' as any, 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,SAAS;AAAA,MACT,UAAU;AAAA,MACV,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAGA,IAAO,oBAAQ,+BAAc,oBAA2B,QAAQ;",
6
+ "names": []
7
+ }
@@ -13,3 +13,5 @@ export { default as FloatDrawer } from './FloatDrawer';
13
13
  export type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';
14
14
  export { withDefaultModalActionProps, withModalAction } from './ModalAction';
15
15
  export { default as ModalAction } from './ModalAction';
16
+ export type { OverflowTagsProps } from './OverflowTags';
17
+ export { default as OverflowTags } from './OverflowTags';
@@ -35,6 +35,7 @@ __export(components_exports, {
35
35
  DeleteConfirmAction: () => import_DeleteConfirmAction.default,
36
36
  FloatDrawer: () => import_FloatDrawer.default,
37
37
  ModalAction: () => import_ModalAction2.default,
38
+ OverflowTags: () => import_OverflowTags.default,
38
39
  ReactEasyContext: () => import_context.default,
39
40
  withDefaultConfirmActionProps: () => import_ConfirmAction.withDefaultConfirmActionProps,
40
41
  withDefaultModalActionProps: () => import_ModalAction.withDefaultModalActionProps,
@@ -50,6 +51,7 @@ var import_DeleteConfirmAction = __toESM(require("./DeleteConfirmAction"));
50
51
  var import_FloatDrawer = __toESM(require("./FloatDrawer"));
51
52
  var import_ModalAction = require("./ModalAction");
52
53
  var import_ModalAction2 = __toESM(require("./ModalAction"));
54
+ var import_OverflowTags = __toESM(require("./OverflowTags"));
53
55
  // Annotate the CommonJS export names for ESM import in node:
54
56
  0 && (module.exports = {
55
57
  BreakLines,
@@ -58,6 +60,7 @@ var import_ModalAction2 = __toESM(require("./ModalAction"));
58
60
  DeleteConfirmAction,
59
61
  FloatDrawer,
60
62
  ModalAction,
63
+ OverflowTags,
61
64
  ReactEasyContext,
62
65
  withDefaultConfirmActionProps,
63
66
  withDefaultModalActionProps,