@aloudata/aloudata-design 3.0.0-beta.15 → 3.0.0-beta.17

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 (59) hide show
  1. package/dist/Checkbox/index.js +2 -2
  2. package/dist/Checkbox/index.js.map +1 -1
  3. package/dist/Drawer/index.js +49 -44
  4. package/dist/Drawer/index.js.map +1 -1
  5. package/dist/Dropdown/index.js +5 -1
  6. package/dist/Dropdown/index.js.map +1 -1
  7. package/dist/Form/index.js +17 -4
  8. package/dist/Form/index.js.map +1 -1
  9. package/dist/Layout/index.js +1 -1
  10. package/dist/Layout/index.js.map +1 -1
  11. package/dist/LogicTree/index.js +26 -10
  12. package/dist/LogicTree/index.js.map +1 -1
  13. package/dist/Modal/index.js +48 -43
  14. package/dist/Modal/index.js.map +1 -1
  15. package/dist/Popconfirm/index.js +6 -1
  16. package/dist/Popconfirm/index.js.map +1 -1
  17. package/dist/Popover/index.js +3 -2
  18. package/dist/Popover/index.js.map +1 -1
  19. package/dist/Radio/components/Radio/index.js +2 -0
  20. package/dist/Radio/components/Radio/index.js.map +1 -1
  21. package/dist/Select/utils/getWidthStyle.js +4 -1
  22. package/dist/Select/utils/getWidthStyle.js.map +1 -1
  23. package/dist/Switch/index.js +2 -2
  24. package/dist/Switch/index.js.map +1 -1
  25. package/dist/Tabs/index.js +35 -31
  26. package/dist/Tabs/index.js.map +1 -1
  27. package/dist/Tooltip/index.js +5 -3
  28. package/dist/Tooltip/index.js.map +1 -1
  29. package/dist/Tour/index.js +48 -38
  30. package/dist/Tour/index.js.map +1 -1
  31. package/dist/_utils/SimpleOverflow.js +11 -5
  32. package/dist/_utils/SimpleOverflow.js.map +1 -1
  33. package/dist/_utils/floatingLayer.d.ts +15 -0
  34. package/dist/_utils/floatingLayer.js +30 -0
  35. package/dist/_utils/floatingLayer.js.map +1 -0
  36. package/dist/aloudata-design.css +1 -1
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +5 -1
  39. package/dist/theme/createTheme.d.ts +2 -0
  40. package/dist/theme/createTheme.js +46 -0
  41. package/dist/theme/createTheme.js.map +1 -0
  42. package/dist/theme/defaultTheme.d.ts +2 -0
  43. package/dist/theme/defaultTheme.js +19 -0
  44. package/dist/theme/defaultTheme.js.map +1 -0
  45. package/dist/theme/index.d.ts +5 -0
  46. package/dist/theme/index.js +4 -0
  47. package/dist/theme/initAldTheme.d.ts +2 -0
  48. package/dist/theme/initAldTheme.js +26 -0
  49. package/dist/theme/initAldTheme.js.map +1 -0
  50. package/dist/theme/themeToCssVars.d.ts +2 -0
  51. package/dist/theme/themeToCssVars.js +144 -0
  52. package/dist/theme/themeToCssVars.js.map +1 -0
  53. package/dist/theme/tokenMap.d.ts +5 -0
  54. package/dist/theme/tokenMap.js +12 -0
  55. package/dist/theme/tokenMap.js.map +1 -0
  56. package/dist/theme/types.d.ts +20 -0
  57. package/dist/theme/types.js +2 -0
  58. package/dist/theme.d.ts +2 -0
  59. package/package.json +1 -1
@@ -48,7 +48,7 @@ function Sider({ className, style, children, width = 200, collapsed: controlledC
48
48
  };
49
49
  const showTrigger = collapsible && trigger !== null;
50
50
  return /* @__PURE__ */ jsxs("aside", {
51
- className: cn("ald-layout-sider tw-relative tw-flex tw-flex-none tw-flex-col tw-transition-all", theme === "dark" && "tw-bg-[#001529] tw-text-white", className),
51
+ className: cn("ald-layout-sider tw-relative tw-flex tw-flex-none tw-flex-col tw-transition-all", theme === "dark" && "tw-bg-[var(--background-inverted)] tw-text-[var(--content-inverted-primary)]", className),
52
52
  style: {
53
53
  width: isCollapsed ? collapsedWidth : width,
54
54
  ...style
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Layout/index.tsx"],"sourcesContent":["import React from 'react';\nimport { cn } from '../lib/utils';\n\nexport interface LayoutProps {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n hasSider?: boolean;\n}\n\nexport interface SiderProps {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n width?: number | string;\n collapsed?: boolean;\n collapsedWidth?: number | string;\n collapsible?: boolean;\n trigger?: React.ReactNode;\n onCollapse?: (collapsed: boolean) => void;\n breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';\n onBreakpoint?: (broken: boolean) => void;\n theme?: 'light' | 'dark';\n}\n\ninterface LayoutComponent extends React.FC<LayoutProps> {\n Header: React.FC<LayoutProps>;\n Footer: React.FC<LayoutProps>;\n Content: React.FC<LayoutProps>;\n Sider: React.FC<SiderProps>;\n}\n\nconst Layout: LayoutComponent = ({ className, style, children, hasSider }) => (\n <section\n className={cn(\n 'ald-layout tw-flex tw-flex-auto',\n hasSider ? 'tw-flex-row' : 'tw-flex-col',\n className,\n )}\n style={style}\n >\n {children}\n </section>\n);\n\nLayout.Header = ({ className, style, children }) => (\n <header\n className={cn('ald-layout-header tw-flex-none', className)}\n style={style}\n >\n {children}\n </header>\n);\n\nLayout.Footer = ({ className, style, children }) => (\n <footer\n className={cn('ald-layout-footer tw-flex-none', className)}\n style={style}\n >\n {children}\n </footer>\n);\n\nLayout.Content = ({ className, style, children }) => (\n <main\n className={cn('ald-layout-content tw-flex-auto', className)}\n style={style}\n >\n {children}\n </main>\n);\n\nconst breakpointWidths: Record<string, number> = {\n xs: 480,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600,\n};\n\nfunction Sider({\n className,\n style,\n children,\n width = 200,\n collapsed: controlledCollapsed,\n collapsedWidth = 80,\n collapsible = false,\n trigger,\n onCollapse,\n breakpoint,\n onBreakpoint,\n theme,\n}: SiderProps) {\n const [internalCollapsed, setInternalCollapsed] = React.useState(false);\n\n React.useEffect(() => {\n if (!breakpoint) return;\n const mq = window.matchMedia(\n `(max-width: ${breakpointWidths[breakpoint]}px)`,\n );\n const handler = (e: MediaQueryListEvent) => onBreakpoint?.(e.matches);\n mq.addEventListener('change', handler);\n onBreakpoint?.(mq.matches);\n return () => mq.removeEventListener('change', handler);\n }, [breakpoint, onBreakpoint]);\n const isCollapsed =\n controlledCollapsed !== undefined ? controlledCollapsed : internalCollapsed;\n\n const handleToggle = () => {\n const next = !isCollapsed;\n if (controlledCollapsed === undefined) {\n setInternalCollapsed(next);\n }\n onCollapse?.(next);\n };\n\n const showTrigger = collapsible && trigger !== null;\n\n return (\n <aside\n className={cn(\n 'ald-layout-sider tw-relative tw-flex tw-flex-none tw-flex-col tw-transition-all',\n theme === 'dark' && 'tw-bg-[#001529] tw-text-white',\n className,\n )}\n style={{\n width: isCollapsed ? collapsedWidth : width,\n ...style,\n }}\n >\n <div className=\"tw-flex-1 tw-overflow-hidden\">{children}</div>\n {showTrigger && (\n <div\n className=\"ald-layout-sider-trigger tw-flex tw-h-12 tw-cursor-pointer tw-items-center tw-justify-center tw-border-t tw-border-solid tw-border-[var(--border-default)] tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)] hover:tw-text-[var(--content-primary)]\"\n onClick={handleToggle}\n >\n {trigger !== undefined ? (\n trigger\n ) : (\n <span\n className=\"tw-inline-block tw-text-xs tw-transition-transform\"\n style={{\n transform: isCollapsed ? 'rotate(0deg)' : 'rotate(180deg)',\n }}\n >\n {'\\u25C0'}\n </span>\n )}\n </div>\n )}\n </aside>\n );\n}\n\nLayout.Sider = Sider;\n\nexport default Layout;\n"],"mappings":";;;;AAgCA,IAAM,UAA2B,EAAE,WAAW,OAAO,UAAU,eAC7D,oBAAC,WAAD;CACE,WAAW,GACT,mCACA,WAAW,gBAAgB,eAC3B,UACD;CACM;CAEN;CACO,CAAA;AAGZ,OAAO,UAAU,EAAE,WAAW,OAAO,eACnC,oBAAC,UAAD;CACE,WAAW,GAAG,kCAAkC,UAAU;CACnD;CAEN;CACM,CAAA;AAGX,OAAO,UAAU,EAAE,WAAW,OAAO,eACnC,oBAAC,UAAD;CACE,WAAW,GAAG,kCAAkC,UAAU;CACnD;CAEN;CACM,CAAA;AAGX,OAAO,WAAW,EAAE,WAAW,OAA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["import React from 'react';\nimport { cn } from '../lib/utils';\n\nexport interface LayoutProps {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n hasSider?: boolean;\n}\n\nexport interface SiderProps {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n width?: number | string;\n collapsed?: boolean;\n collapsedWidth?: number | string;\n collapsible?: boolean;\n trigger?: React.ReactNode;\n onCollapse?: (collapsed: boolean) => void;\n breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';\n onBreakpoint?: (broken: boolean) => void;\n theme?: 'light' | 'dark';\n}\n\ninterface LayoutComponent extends React.FC<LayoutProps> {\n Header: React.FC<LayoutProps>;\n Footer: React.FC<LayoutProps>;\n Content: React.FC<LayoutProps>;\n Sider: React.FC<SiderProps>;\n}\n\nconst Layout: LayoutComponent = ({ className, style, children, hasSider }) => (\n <section\n className={cn(\n 'ald-layout tw-flex tw-flex-auto',\n hasSider ? 'tw-flex-row' : 'tw-flex-col',\n className,\n )}\n style={style}\n >\n {children}\n </section>\n);\n\nLayout.Header = ({ className, style, children }) => (\n <header\n className={cn('ald-layout-header tw-flex-none', className)}\n style={style}\n >\n {children}\n </header>\n);\n\nLayout.Footer = ({ className, style, children }) => (\n <footer\n className={cn('ald-layout-footer tw-flex-none', className)}\n style={style}\n >\n {children}\n </footer>\n);\n\nLayout.Content = ({ className, style, children }) => (\n <main\n className={cn('ald-layout-content tw-flex-auto', className)}\n style={style}\n >\n {children}\n </main>\n);\n\nconst breakpointWidths: Record<string, number> = {\n xs: 480,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600,\n};\n\nfunction Sider({\n className,\n style,\n children,\n width = 200,\n collapsed: controlledCollapsed,\n collapsedWidth = 80,\n collapsible = false,\n trigger,\n onCollapse,\n breakpoint,\n onBreakpoint,\n theme,\n}: SiderProps) {\n const [internalCollapsed, setInternalCollapsed] = React.useState(false);\n\n React.useEffect(() => {\n if (!breakpoint) return;\n const mq = window.matchMedia(\n `(max-width: ${breakpointWidths[breakpoint]}px)`,\n );\n const handler = (e: MediaQueryListEvent) => onBreakpoint?.(e.matches);\n mq.addEventListener('change', handler);\n onBreakpoint?.(mq.matches);\n return () => mq.removeEventListener('change', handler);\n }, [breakpoint, onBreakpoint]);\n const isCollapsed =\n controlledCollapsed !== undefined ? controlledCollapsed : internalCollapsed;\n\n const handleToggle = () => {\n const next = !isCollapsed;\n if (controlledCollapsed === undefined) {\n setInternalCollapsed(next);\n }\n onCollapse?.(next);\n };\n\n const showTrigger = collapsible && trigger !== null;\n\n return (\n <aside\n className={cn(\n 'ald-layout-sider tw-relative tw-flex tw-flex-none tw-flex-col tw-transition-all',\n theme === 'dark' &&\n 'tw-bg-[var(--background-inverted)] tw-text-[var(--content-inverted-primary)]',\n className,\n )}\n style={{\n width: isCollapsed ? collapsedWidth : width,\n ...style,\n }}\n >\n <div className=\"tw-flex-1 tw-overflow-hidden\">{children}</div>\n {showTrigger && (\n <div\n className=\"ald-layout-sider-trigger tw-flex tw-h-12 tw-cursor-pointer tw-items-center tw-justify-center tw-border-t tw-border-solid tw-border-[var(--border-default)] tw-bg-[var(--background-neutral-subtle)] tw-text-[var(--content-secondary)] hover:tw-text-[var(--content-primary)]\"\n onClick={handleToggle}\n >\n {trigger !== undefined ? (\n trigger\n ) : (\n <span\n className=\"tw-inline-block tw-text-xs tw-transition-transform\"\n style={{\n transform: isCollapsed ? 'rotate(0deg)' : 'rotate(180deg)',\n }}\n >\n {'\\u25C0'}\n </span>\n )}\n </div>\n )}\n </aside>\n );\n}\n\nLayout.Sider = Sider;\n\nexport default Layout;\n"],"mappings":";;;;AAgCA,IAAM,UAA2B,EAAE,WAAW,OAAO,UAAU,eAC7D,oBAAC,WAAD;CACE,WAAW,GACT,mCACA,WAAW,gBAAgB,eAC3B,UACD;CACM;CAEN;CACO,CAAA;AAGZ,OAAO,UAAU,EAAE,WAAW,OAAO,eACnC,oBAAC,UAAD;CACE,WAAW,GAAG,kCAAkC,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WAAU;IACV,OAAO,EACL,WAAW,cAAc,iBAAiB,kBAC3C;cAEA;IACI,CAAA;GAEL,CAAA,CAEF;;;AAIZ,OAAO,QAAQ"}
@@ -6,10 +6,10 @@ import LogicItem from "./components/LogicItem/index.js";
6
6
  import { addLogicNode, addRecordNode, changeRecordData, changeRelation, findNodeById, findParentNodeById, isDescendant, removeNode } from "./helper.js";
7
7
  import "./DisplayLogicTree.js";
8
8
  import { useCallback, useState } from "react";
9
- import { jsx } from "react/jsx-runtime";
9
+ import { Fragment, jsx } from "react/jsx-runtime";
10
10
  import _ from "lodash";
11
11
  import { useControllableValue } from "ahooks";
12
- import { DndProvider } from "react-dnd";
12
+ import { DndProvider, useDragDropManager } from "react-dnd";
13
13
  import { HTML5Backend } from "react-dnd-html5-backend";
14
14
  //#region src/LogicTree/index.tsx
15
15
  var EPutPosition = /* @__PURE__ */ function(EPutPosition) {
@@ -17,8 +17,29 @@ var EPutPosition = /* @__PURE__ */ function(EPutPosition) {
17
17
  EPutPosition["BOTTOM"] = "BOTTOM";
18
18
  return EPutPosition;
19
19
  }({});
20
+ function useHasDndContext() {
21
+ try {
22
+ return !!useDragDropManager();
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+ function LogicTreeDndProvider({ children }) {
28
+ const hasDndContext = useHasDndContext();
29
+ const [rootElement, setRootElement] = useState(null);
30
+ if (hasDndContext) return /* @__PURE__ */ jsx(Fragment, { children });
31
+ return /* @__PURE__ */ jsx("div", {
32
+ ref: setRootElement,
33
+ style: { display: "contents" },
34
+ children: rootElement ? /* @__PURE__ */ jsx(DndProvider, {
35
+ backend: HTML5Backend,
36
+ options: { rootElement },
37
+ children
38
+ }) : null
39
+ });
40
+ }
20
41
  function LogicTree(props) {
21
- const { newInitializationData, onChange: propsOnChange, renderCondition, rootNodeAllowedEmpty, className, needDndProvider = false, hideBottomBtn } = props;
42
+ const { newInitializationData, onChange: propsOnChange, renderCondition, rootNodeAllowedEmpty, className, hideBottomBtn } = props;
22
43
  const initialNode = {
23
44
  id: getUniqId(),
24
45
  type: ENodeType.LOGIC,
@@ -73,7 +94,7 @@ function LogicTree(props) {
73
94
  }
74
95
  }, [innerValue, changeInnerValue]);
75
96
  if (!innerValue) return null;
76
- const content = /* @__PURE__ */ jsx("div", {
97
+ return /* @__PURE__ */ jsx(LogicTreeDndProvider, { children: /* @__PURE__ */ jsx("div", {
77
98
  className: cn("ald-logic-tree-wrap", className),
78
99
  children: /* @__PURE__ */ jsx(LogicItem, {
79
100
  value: innerValue,
@@ -89,12 +110,7 @@ function LogicTree(props) {
89
110
  isRoot: true,
90
111
  hideBottomBtn
91
112
  })
92
- });
93
- if (!needDndProvider) return content;
94
- return /* @__PURE__ */ jsx(DndProvider, {
95
- backend: HTML5Backend,
96
- children: content
97
- });
113
+ }) });
98
114
  }
99
115
  //#endregion
100
116
  export { EPutPosition, LogicTree as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/LogicTree/index.tsx"],"sourcesContent":["import { useControllableValue } from 'ahooks';\nimport { cn } from '../lib/utils';\nimport './logic-tree.css';\nimport _ from 'lodash';\nimport React, { useCallback, useState } from 'react';\nimport { DndProvider } from 'react-dnd';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\nimport { getUniqId } from '../_utils/getUniqId';\nimport LogicItem from './components/LogicItem';\nimport {\n addLogicNode,\n addRecordNode,\n changeRecordData,\n changeRelation,\n findNodeById,\n findParentNodeById,\n isDescendant,\n removeNode,\n} from './helper';\nimport { ELogicType, ENodeType, type TNode } from './type';\n\nexport { default as DisplayLogicTree } from './DisplayLogicTree';\nexport * from './type';\n\nexport enum EPutPosition {\n TOP = 'TOP',\n BOTTOM = 'BOTTOM',\n}\n\nexport type TRenderCondition<T> = (\n data: T,\n { changeData }: { changeData: (data: T) => void },\n nodeId: string,\n) => React.ReactNode;\n\ninterface IProps<T> {\n newInitializationData: T;\n onChange: (value: TNode<T>) => void;\n value?: TNode<T>;\n renderCondition: TRenderCondition<T>;\n rootNodeAllowedEmpty?: boolean;\n className?: string;\n needDndProvider?: boolean;\n hideBottomBtn?: {\n addRelation?: boolean;\n };\n}\n\nexport default function LogicTree<T>(props: IProps<T>) {\n const {\n newInitializationData,\n onChange: propsOnChange,\n renderCondition,\n rootNodeAllowedEmpty,\n className,\n needDndProvider = false,\n hideBottomBtn,\n } = props;\n const initialNode: TNode<T> = {\n id: getUniqId(),\n type: ENodeType.LOGIC,\n logicType: ELogicType.AND,\n nodes: [\n {\n id: getUniqId(),\n type: ENodeType.RECORD,\n data: newInitializationData,\n },\n ],\n };\n\n const [innerValue, setInnerValue] = useControllableValue<TNode<T>>(\n props.value ? { value: props.value } : {},\n {\n defaultValue: initialNode,\n },\n );\n const [hoverItemId, setHoverItemId] = useState<string>('');\n\n const changeInnerValue = useCallback(\n (newValue: TNode<T>) => {\n setInnerValue(newValue);\n propsOnChange(newValue);\n },\n [propsOnChange, setInnerValue],\n );\n\n const onAddCondition = (id: string) => {\n const newRootNode = addRecordNode(id, innerValue, newInitializationData);\n changeInnerValue(newRootNode);\n };\n\n const onAddRelation = (id: string) => {\n const newRootNode = addLogicNode(id, innerValue, newInitializationData);\n changeInnerValue(newRootNode);\n };\n\n const onChangeRelation = (id: string, logicType: ELogicType) => {\n const newRootNode = changeRelation(id, logicType, innerValue);\n changeInnerValue(newRootNode);\n };\n\n const onRemove = (id: string) => {\n const newRootNode = removeNode(\n id,\n innerValue,\n initialNode,\n rootNodeAllowedEmpty,\n );\n changeInnerValue(newRootNode);\n };\n\n const onChangeRecordData = (id: string, data: T) => {\n const newRootNode = changeRecordData(id, data, innerValue);\n changeInnerValue(newRootNode);\n };\n\n const moveNode = useCallback(\n (dragId: string, hoverId: string, dropPosition: EPutPosition) => {\n const newRootNode = _.cloneDeep(innerValue);\n const dragNode = findNodeById(dragId, newRootNode);\n const hoverNode = findNodeById(hoverId, newRootNode);\n\n if (dragNode && hoverNode) {\n if (isDescendant(hoverId, dragNode)) {\n return;\n }\n\n const dragParent = findParentNodeById(dragId, newRootNode);\n const hoverParent = findParentNodeById(hoverId, newRootNode);\n\n if (dragParent && hoverParent) {\n // 从原位置移除节点\n dragParent.nodes = dragParent.nodes.filter(\n (node) => node.id !== dragId,\n );\n\n // 如果拖拽父节点为空,处理删除逻辑\n if (dragParent.nodes.length === 0) {\n const grandParent = findParentNodeById(dragParent.id, newRootNode);\n if (grandParent) {\n grandParent.nodes = grandParent.nodes.filter(\n (node) => node.id !== dragParent.id,\n );\n } else {\n dragParent.nodes = [];\n }\n }\n\n // 插入到新位置\n const hoverIndex = hoverParent.nodes.findIndex(\n (node) => node.id === hoverId,\n );\n const newIndex =\n dropPosition === EPutPosition.TOP ? hoverIndex : hoverIndex + 1;\n hoverParent.nodes.splice(newIndex, 0, dragNode);\n\n // 更新状态\n changeInnerValue(newRootNode);\n }\n }\n },\n [innerValue, changeInnerValue],\n );\n\n if (!innerValue) {\n return null;\n }\n\n const content = (\n <div className={cn('ald-logic-tree-wrap', className)}>\n <LogicItem\n value={innerValue}\n addCondition={onAddCondition}\n addRelation={onAddRelation}\n remove={onRemove}\n changeRecordData={onChangeRecordData}\n renderCondition={renderCondition}\n changeRelation={onChangeRelation}\n onDragEnd={moveNode}\n hoverId={hoverItemId}\n setHoverId={setHoverItemId}\n isRoot={true} // 将最顶层的LogicItem标记为根节点\n hideBottomBtn={hideBottomBtn}\n />\n </div>\n );\n\n if (!needDndProvider) {\n return content;\n }\n\n return <DndProvider backend={HTML5Backend}>{content}</DndProvider>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAY,eAAL,yBAAA,cAAA;AACL,cAAA,SAAA;AACA,cAAA,YAAA;;KACD;AAqBD,SAAwB,UAAa,OAAkB;CACrD,MAAM,EACJ,uBACA,UAAU,eACV,iBACA,sBACA,WACA,kBAAkB,OAClB,kBACE;CACJ,MAAM,cAAwB;EAC5B,IAAI,WAAW;EACf,MAAM,UAAU;EAChB,WAAW,WAAW;EACtB,OAAO,CACL;GACE,IAAI,WAA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WAAW,GAClC;SAED,YAAW,QAAQ,EAAE;;IAKzB,MAAM,aAAa,YAAY,MAAM,WAClC,SAAS,KAAK,OAAO,QACvB;IACD,MAAM,WACJ,iBAAiB,aAAa,MAAM,aAAa,aAAa;AAChE,gBAAY,MAAM,OAAO,UAAU,GAAG,SAAS;AAG/C,qBAAiB,YAAY;;;IAInC,CAAC,YAAY,iBAAiB,CAC/B;AAED,KAAI,CAAC,WACH,QAAO;CAGT,MAAM,UACJ,oBAAC,OAAD;EAAK,WAAW,GAAG,uBAAuB,UAAU;YAClD,oBAAC,WAAD;GACE,OAAO;GACP,cAAc;GACd,aAAa;GACb,QAAQ;GACR,kBAAkB;GACD;GACjB,gBAAgB;GAChB,WAAW;GACX,SAAS;GACT,YAAY;GACZ,QAAQ;GACO;GACf,CAAA;EACE,CAAA;AAGR,KAAI,CAAC,gBACH,QAAO;AAGT,QAAO,oBAAC,aAAD;EAAa,SAAS;YAAe;EAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/LogicTree/index.tsx"],"sourcesContent":["import { useControllableValue } from 'ahooks';\nimport { cn } from '../lib/utils';\nimport './logic-tree.css';\nimport _ from 'lodash';\nimport React, { useCallback, useState } from 'react';\nimport { DndProvider, useDragDropManager } from 'react-dnd';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\nimport { getUniqId } from '../_utils/getUniqId';\nimport LogicItem from './components/LogicItem';\nimport {\n addLogicNode,\n addRecordNode,\n changeRecordData,\n changeRelation,\n findNodeById,\n findParentNodeById,\n isDescendant,\n removeNode,\n} from './helper';\nimport { ELogicType, ENodeType, type TNode } from './type';\n\nexport { default as DisplayLogicTree } from './DisplayLogicTree';\nexport * from './type';\n\nexport enum EPutPosition {\n TOP = 'TOP',\n BOTTOM = 'BOTTOM',\n}\n\nexport type TRenderCondition<T> = (\n data: T,\n { changeData }: { changeData: (data: T) => void },\n nodeId: string,\n) => React.ReactNode;\n\ninterface IProps<T> {\n newInitializationData: T;\n onChange: (value: TNode<T>) => void;\n value?: TNode<T>;\n renderCondition: TRenderCondition<T>;\n rootNodeAllowedEmpty?: boolean;\n className?: string;\n needDndProvider?: boolean;\n hideBottomBtn?: {\n addRelation?: boolean;\n };\n}\n\nfunction useHasDndContext() {\n try {\n return !!useDragDropManager();\n } catch {\n return false;\n }\n}\n\nfunction LogicTreeDndProvider({ children }: { children: React.ReactNode }) {\n const hasDndContext = useHasDndContext();\n const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null);\n\n if (hasDndContext) {\n return <>{children}</>;\n }\n\n return (\n <div ref={setRootElement} style={{ display: 'contents' }}>\n {rootElement ? (\n <DndProvider backend={HTML5Backend} options={{ rootElement }}>\n {children}\n </DndProvider>\n ) : null}\n </div>\n );\n}\n\nexport default function LogicTree<T>(props: IProps<T>) {\n const {\n newInitializationData,\n onChange: propsOnChange,\n renderCondition,\n rootNodeAllowedEmpty,\n className,\n hideBottomBtn,\n } = props;\n const initialNode: TNode<T> = {\n id: getUniqId(),\n type: ENodeType.LOGIC,\n logicType: ELogicType.AND,\n nodes: [\n {\n id: getUniqId(),\n type: ENodeType.RECORD,\n data: newInitializationData,\n },\n ],\n };\n\n const [innerValue, setInnerValue] = useControllableValue<TNode<T>>(\n props.value ? { value: props.value } : {},\n {\n defaultValue: initialNode,\n },\n );\n const [hoverItemId, setHoverItemId] = useState<string>('');\n\n const changeInnerValue = useCallback(\n (newValue: TNode<T>) => {\n setInnerValue(newValue);\n propsOnChange(newValue);\n },\n [propsOnChange, setInnerValue],\n );\n\n const onAddCondition = (id: string) => {\n const newRootNode = addRecordNode(id, innerValue, newInitializationData);\n changeInnerValue(newRootNode);\n };\n\n const onAddRelation = (id: string) => {\n const newRootNode = addLogicNode(id, innerValue, newInitializationData);\n changeInnerValue(newRootNode);\n };\n\n const onChangeRelation = (id: string, logicType: ELogicType) => {\n const newRootNode = changeRelation(id, logicType, innerValue);\n changeInnerValue(newRootNode);\n };\n\n const onRemove = (id: string) => {\n const newRootNode = removeNode(\n id,\n innerValue,\n initialNode,\n rootNodeAllowedEmpty,\n );\n changeInnerValue(newRootNode);\n };\n\n const onChangeRecordData = (id: string, data: T) => {\n const newRootNode = changeRecordData(id, data, innerValue);\n changeInnerValue(newRootNode);\n };\n\n const moveNode = useCallback(\n (dragId: string, hoverId: string, dropPosition: EPutPosition) => {\n const newRootNode = _.cloneDeep(innerValue);\n const dragNode = findNodeById(dragId, newRootNode);\n const hoverNode = findNodeById(hoverId, newRootNode);\n\n if (dragNode && hoverNode) {\n if (isDescendant(hoverId, dragNode)) {\n return;\n }\n\n const dragParent = findParentNodeById(dragId, newRootNode);\n const hoverParent = findParentNodeById(hoverId, newRootNode);\n\n if (dragParent && hoverParent) {\n // 从原位置移除节点\n dragParent.nodes = dragParent.nodes.filter(\n (node) => node.id !== dragId,\n );\n\n // 如果拖拽父节点为空,处理删除逻辑\n if (dragParent.nodes.length === 0) {\n const grandParent = findParentNodeById(dragParent.id, newRootNode);\n if (grandParent) {\n grandParent.nodes = grandParent.nodes.filter(\n (node) => node.id !== dragParent.id,\n );\n } else {\n dragParent.nodes = [];\n }\n }\n\n // 插入到新位置\n const hoverIndex = hoverParent.nodes.findIndex(\n (node) => node.id === hoverId,\n );\n const newIndex =\n dropPosition === EPutPosition.TOP ? hoverIndex : hoverIndex + 1;\n hoverParent.nodes.splice(newIndex, 0, dragNode);\n\n // 更新状态\n changeInnerValue(newRootNode);\n }\n }\n },\n [innerValue, changeInnerValue],\n );\n\n if (!innerValue) {\n return null;\n }\n\n const content = (\n <div className={cn('ald-logic-tree-wrap', className)}>\n <LogicItem\n value={innerValue}\n addCondition={onAddCondition}\n addRelation={onAddRelation}\n remove={onRemove}\n changeRecordData={onChangeRecordData}\n renderCondition={renderCondition}\n changeRelation={onChangeRelation}\n onDragEnd={moveNode}\n hoverId={hoverItemId}\n setHoverId={setHoverItemId}\n isRoot={true} // 将最顶层的LogicItem标记为根节点\n hideBottomBtn={hideBottomBtn}\n />\n </div>\n );\n\n return <LogicTre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,QAAQ;GACO;GACf,CAAA;EACE,CAAA,EAGqD,CAAA"}
@@ -4,6 +4,7 @@ import Memo$1 from "../Icon/components/CheckCircleLightLine.js";
4
4
  import Memo$2 from "../Icon/components/CloseLLine.js";
5
5
  import Memo$3 from "../Icon/components/InformationCircleLightLine.js";
6
6
  import Button_default from "../Button/index.js";
7
+ import { FloatingLayerProvider, useFloatingLayer } from "../_utils/floatingLayer.js";
7
8
  import { LocaleContext, getTranslator } from "../locale/default.js";
8
9
  import IconButton from "../IconButton/index.js";
9
10
  import ScrollArea_default from "../ScrollArea/index.js";
@@ -112,6 +113,7 @@ function OriginModal(props) {
112
113
  loading: confirmLoading,
113
114
  ...okButtonProps
114
115
  };
116
+ const { maskZIndex, contentZIndex, nextLevel } = useFloatingLayer(zIndex);
115
117
  const renderFooter = () => {
116
118
  if (footer === null) return null;
117
119
  if (footer) return /* @__PURE__ */ jsx("div", {
@@ -140,16 +142,16 @@ function OriginModal(props) {
140
142
  modal: false,
141
143
  children: /* @__PURE__ */ jsxs(DialogPrimitive.Portal, { children: [/* @__PURE__ */ jsx("div", {
142
144
  className: "ald-modal-mask tw-animate-in tw-fade-in-0 tw-fixed tw-inset-0 tw-bg-black/45",
143
- style: { zIndex },
145
+ style: { zIndex: maskZIndex },
144
146
  onPointerDown: () => {
145
147
  if (maskClosable) onCancel?.({});
146
148
  }
147
149
  }), /* @__PURE__ */ jsx("div", {
148
150
  ref: contentRef,
149
151
  className: cn("ald-modal-wrap ant-modal-wrap tw-pointer-events-none tw-fixed tw-inset-0 tw-flex tw-items-center tw-justify-center", wrapClassName),
150
- style: { zIndex: zIndex + 1 },
152
+ style: { zIndex: contentZIndex },
151
153
  children: /* @__PURE__ */ jsx(DialogPrimitive.Content, {
152
- className: cn("ald-modal ant-modal tw-pointer-events-auto tw-flex tw-flex-col tw-overflow-hidden tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-shadow-[var(--elevation-bottom-bottom-lg)]", fullscreen ? "ald-modal-fullscreen tw-fixed tw-inset-0 tw-size-full tw-rounded-none" : "tw-rounded-r-75", paddingLess && "ald-modal-padding-less", virtualScrollBar && "ald-modal-virtual-scroll-bar", hideHeaderBottomBorder && "ald-modal-hide-header-bottom-border", responsiveBounds && "ald-modal-responsive-bounds", className),
154
+ className: cn("ald-modal ant-modal tw-pointer-events-auto tw-box-border tw-flex tw-flex-col tw-overflow-hidden tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-shadow-[var(--elevation-bottom-bottom-lg)] tw-outline-none", fullscreen ? "ald-modal-fullscreen tw-fixed tw-inset-0 tw-size-full tw-rounded-none" : "tw-rounded-r-75", !fullscreen && "tw-border tw-border-solid tw-border-[var(--border-default)]", paddingLess && "ald-modal-padding-less", virtualScrollBar && "ald-modal-virtual-scroll-bar", hideHeaderBottomBorder && "ald-modal-hide-header-bottom-border", responsiveBounds && "ald-modal-responsive-bounds", className),
153
155
  style: {
154
156
  ...fullscreen ? {} : {
155
157
  width: responsiveBounds ? responsiveBoundsStyle.width : width || DEFAULT_WIDTH,
@@ -168,48 +170,51 @@ function OriginModal(props) {
168
170
  onInteractOutside: (e) => {
169
171
  if (!maskClosable) e.preventDefault();
170
172
  },
171
- children: /* @__PURE__ */ jsxs("div", {
173
+ children: /* @__PURE__ */ jsx("div", {
172
174
  className: "ant-modal-content tw-flex tw-h-full tw-flex-col",
173
- children: [
174
- !fullscreen && /* @__PURE__ */ jsxs("div", {
175
- className: cn("ald-modal-header ant-modal-header tw-flex tw-items-start tw-justify-between tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-4", !hideHeaderBottomBorder && "tw-border-b tw-border-solid tw-border-[var(--global-cool-grey-100)]"),
176
- children: [/* @__PURE__ */ jsx(DialogPrimitive.Title, {
177
- asChild: true,
178
- children: /* @__PURE__ */ jsx("div", {
179
- className: "tw-flex-1",
180
- children: ModalTitle({
181
- icon,
182
- title,
183
- subTitle
184
- }, _modalType)
185
- })
186
- }), closable && /* @__PURE__ */ jsx(DialogPrimitive.Close, {
187
- asChild: true,
188
- children: /* @__PURE__ */ jsx("span", {
189
- className: "ant-modal-close",
190
- onClick: onCancel,
191
- children: closeIcon || /* @__PURE__ */ jsx(IconButton, {
192
- icon: /* @__PURE__ */ jsx(Memo$2, { size: 20 }),
193
- size: "middle"
175
+ children: /* @__PURE__ */ jsxs(FloatingLayerProvider, {
176
+ value: nextLevel,
177
+ children: [
178
+ !fullscreen && /* @__PURE__ */ jsxs("div", {
179
+ className: cn("ald-modal-header ant-modal-header tw-flex tw-items-start tw-justify-between tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-4", !hideHeaderBottomBorder && "tw-border-b tw-border-solid tw-border-[var(--global-cool-grey-100)]"),
180
+ children: [/* @__PURE__ */ jsx(DialogPrimitive.Title, {
181
+ asChild: true,
182
+ children: /* @__PURE__ */ jsx("div", {
183
+ className: "tw-flex-1",
184
+ children: ModalTitle({
185
+ icon,
186
+ title,
187
+ subTitle
188
+ }, _modalType)
194
189
  })
195
- })
196
- })]
197
- }),
198
- fullscreen && /* @__PURE__ */ jsx(DialogPrimitive.Title, {
199
- className: "tw-sr-only",
200
- children: title
201
- }),
202
- /* @__PURE__ */ jsx("div", {
203
- className: cn("ald-modal-body ant-modal-body tw-flex-1 tw-text-sm tw-leading-5", fullscreen ? "tw-h-full tw-overflow-hidden tw-p-0" : "tw-min-h-[130px] tw-overflow-auto", !fullscreen && !responsiveBounds && "tw-max-h-[68vh]", !fullscreen && !paddingLess && "tw-p-6"),
204
- style: bodyStyle,
205
- children: virtualScrollBar ? /* @__PURE__ */ jsx(ScrollArea_default, {
206
- className: "ald-modal-body-wrap",
207
- innerClassName: "ald-modal-body-wrap-inner",
208
- children
209
- }) : children
210
- }),
211
- !fullscreen && renderFooter()
212
- ]
190
+ }), closable && /* @__PURE__ */ jsx(DialogPrimitive.Close, {
191
+ asChild: true,
192
+ children: /* @__PURE__ */ jsx("span", {
193
+ className: "ant-modal-close",
194
+ onClick: onCancel,
195
+ children: closeIcon || /* @__PURE__ */ jsx(IconButton, {
196
+ icon: /* @__PURE__ */ jsx(Memo$2, { size: 20 }),
197
+ size: "middle"
198
+ })
199
+ })
200
+ })]
201
+ }),
202
+ fullscreen && /* @__PURE__ */ jsx(DialogPrimitive.Title, {
203
+ className: "tw-sr-only",
204
+ children: title
205
+ }),
206
+ /* @__PURE__ */ jsx("div", {
207
+ className: cn("ald-modal-body ant-modal-body tw-flex-1 tw-text-sm tw-leading-5", fullscreen ? "tw-h-full tw-overflow-hidden tw-p-0" : "tw-min-h-[130px]", !fullscreen && (virtualScrollBar ? "tw-overflow-hidden tw-p-0" : "tw-overflow-auto"), !fullscreen && !responsiveBounds && !virtualScrollBar && "tw-max-h-[68vh]", !fullscreen && !paddingLess && !virtualScrollBar && "tw-p-6"),
208
+ style: bodyStyle,
209
+ children: virtualScrollBar ? /* @__PURE__ */ jsx(ScrollArea_default, {
210
+ className: "ald-modal-body-wrap !tw-h-auto",
211
+ innerClassName: cn("ald-modal-body-wrap-inner tw-max-h-[68vh]", paddingLess ? "tw-p-0" : "tw-px-[23px] tw-py-0"),
212
+ children
213
+ }) : children
214
+ }),
215
+ !fullscreen && renderFooter()
216
+ ]
217
+ })
213
218
  })
214
219
  })
215
220
  })] })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Modal/index.tsx"],"sourcesContent":["import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { hideOthers } from 'aria-hidden';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Button, { ButtonType, IButtonProps } from '../Button';\nimport {\n AttentionTriangleLightLine,\n CheckCircleLightLine,\n CloseLLine,\n InformationCircleLightLine,\n} from '../Icon';\nimport IconButton from '../IconButton';\nimport ScrollArea from '../ScrollArea';\nimport { LocaleContext, getTranslator } from '../locale/default';\nimport { cn } from '../lib/utils';\n\nexport const destroyFns: Array<() => void> = [];\n\nexport interface ModalProps {\n open?: boolean;\n onOk?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n afterClose?: () => void;\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n icon?: React.ReactElement;\n width?: number | string;\n footer?: React.ReactNode | null;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n confirmLoading?: boolean;\n maskClosable?: boolean;\n closable?: boolean;\n closeIcon?: React.ReactNode;\n centered?: boolean;\n destroyOnClose?: boolean;\n className?: string;\n /** Applied to the outer wrap layer (matches antd wrapClassName behavior) */\n wrapClassName?: string;\n style?: React.CSSProperties;\n bodyStyle?: React.CSSProperties;\n zIndex?: number;\n children?: React.ReactNode;\n paddingLess?: boolean;\n virtualScrollBar?: boolean;\n hideHeaderBottomBorder?: boolean;\n responsiveBounds?: boolean;\n fullscreen?: boolean;\n keyboard?: boolean;\n afterOpenChange?: (open: boolean) => void;\n getContainer?: (() => HTMLElement) | false;\n /** @internal used by static methods to pass modal type for icon styling */\n _modalType?: string;\n}\n\nexport interface ModalFuncProps {\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n content?: React.ReactNode;\n icon?: React.ReactElement;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n onOk?: (...args: any[]) => any;\n onCancel?: (...args: any[]) => any;\n width?: number | string;\n className?: string;\n /** @deprecated Use `className` instead. Preserved for antd v4 compat. */\n wrapClassName?: string;\n closable?: boolean;\n type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';\n centered?: boolean;\n maskClosable?: boolean;\n}\n\nconst DEFAULT_WIDTH = 552;\n\nconst ModalTitle = (\n { icon, title, subTitle }: Pick<ModalProps, 'icon' | 'title' | 'subTitle'>,\n type?: string,\n) => (\n <div className=\"ald-modal-title-container tw-flex tw-items-center tw-gap-4\">\n {icon && (\n <div\n className={cn(\n 'ald-modal-icon-container tw-grid tw-size-10 tw-shrink-0 tw-place-items-center tw-rounded-[var(--global-grid-250)]',\n type === 'info' &&\n 'ald-modal-cion-info-container tw-bg-[var(--action-primary-subtle-hover)]',\n type === 'success' &&\n 'ald-modal-cion-success-container tw-bg-[var(--background-positive-muted)]',\n type === 'warning' &&\n 'ald-modal-cion-warning-container tw-bg-[var(--background-warning-muted)]',\n type === 'warn' &&\n 'ald-modal-cion-warning-container tw-bg-[var(--background-warning-muted)]',\n type === 'error' &&\n 'ald-modal-cion-error-container tw-bg-[var(--background-negative-muted)]',\n type === 'confirm' &&\n 'ald-modal-cion-confirm-container tw-bg-[var(--action-primary-subtle-hover)]',\n )}\n >\n {icon}\n </div>\n )}\n <div className=\"ald-modal-text-container\">\n {title && (\n <div\n className={cn(\n 'ald-modal-text-title tw-text-lg tw-font-semibold tw-leading-7 tw-text-[var(--alias-colors-text-strong)]',\n !subTitle && 'ald-modal-text-title-only tw-text-xl',\n )}\n >\n {title}\n </div>\n )}\n {subTitle && (\n <div className=\"ald-modal-text-sub-title tw-mt-1 tw-text-xs tw-leading-4 tw-text-[var(--alias-colors-text-subtle)]\">\n {subTitle}\n </div>\n )}\n </div>\n </div>\n);\n\nfunction getIcon(\n type: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm',\n) {\n if (type === 'success')\n return (\n <CheckCircleLightLine\n fill=\"var(--content-inverted-primary)\"\n color=\"var(--background-positive-strong)\"\n size={24}\n />\n );\n if (type === 'error')\n return (\n <AttentionTriangleLightLine\n color=\"var(--background-negative-strong)\"\n fill=\"var(--content-inverted-primary)\"\n size={24}\n />\n );\n if (type === 'warning' || type === 'warn')\n return (\n <AttentionTriangleLightLine\n color=\"var(--background-warning-strong)\"\n size={24}\n />\n );\n return (\n <InformationCircleLightLine\n size={24}\n color=\"var(--interaction-default-normal)\"\n />\n );\n}\n\nfunction OriginModal(props: ModalProps) {\n const { locale } = useContext(LocaleContext);\n const t = getTranslator(locale);\n const {\n className,\n children,\n okType = 'primary',\n width,\n closeIcon,\n subTitle,\n okButtonProps = {},\n cancelButtonProps = {},\n okText = t.Modal.sure,\n cancelText = t.Modal.cancel,\n icon,\n title,\n paddingLess,\n responsiveBounds,\n hideHeaderBottomBorder,\n virtualScrollBar,\n style,\n maskClosable = false,\n fullscreen,\n open = false,\n onOk,\n onCancel,\n footer,\n confirmLoading,\n closable = true,\n zIndex = 1000,\n bodyStyle,\n keyboard = true,\n afterOpenChange,\n wrapClassName,\n _modalType,\n } = props;\n\n const prevOpenRef = useRef(open);\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (prevOpenRef.current !== open) {\n prevOpenRef.current = open;\n afterOpenChange?.(open);\n }\n }, [open, afterOpenChange]);\n\n // ---- modal={false} 补偿:锁定背景滚动 ----\n useEffect(() => {\n if (!open) return;\n const prev = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n return () => {\n document.body.style.overflow = prev;\n };\n }, [open]);\n\n // ---- modal={false} 补偿:aria-hidden(屏幕阅读器只感知弹窗) ----\n useEffect(() => {\n if (!open || !contentRef.current) return;\n return hideOthers(contentRef.current);\n }, [open]);\n\n // ---- modal={false} 补偿:Tab 焦点循环 ----\n useEffect(() => {\n if (!open || !contentRef.current) return;\n const container = contentRef.current;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab') return;\n const focusable = container.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])',\n );\n if (focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey) {\n if (\n document.activeElement === first ||\n !container.contains(document.activeElement)\n ) {\n e.preventDefault();\n last.focus();\n }\n } else {\n if (\n document.activeElement === last ||\n !container.contains(document.activeElement)\n ) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [open]);\n\n const responsiveBoundsStyle = useMemo(() => {\n if (!responsiveBounds) return {};\n return {\n width: 'calc(100% - 160px)',\n maxWidth: '1680px',\n minWidth: '1280px',\n height: 'calc(100% - 48px)',\n maxHeight: '900px',\n minHeight: '640px',\n };\n }, [responsiveBounds]);\n\n const mergedOkProps = { loading: confirmLoading, ...okButtonProps };\n\n const renderFooter = () => {\n if (footer === null) return null;\n if (footer)\n return (\n // antd 兼容:antd .ant-modal-footer 使用 text-align:right 让 inline 按钮右对齐,\n // 即使消费方传入 width:100% 的子容器,内部 inline 元素仍能右对齐。\n // 此处同时使用 tw-flex tw-justify-end(flexbox 对齐)和 tw-text-right(继承式对齐)保持兼容。\n <div className=\"ald-modal-footer ant-modal-footer tw-flex tw-items-center tw-justify-end tw-gap-2 tw-border-t tw-border-solid tw-border-[var(--global-cool-grey-100)] tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-3 tw-text-right\">\n {footer}\n </div>\n );\n return (\n <div className=\"ald-modal-footer ant-modal-footer tw-flex tw-justify-end tw-gap-2 tw-border-t tw-border-solid tw-border-[var(--border-default)] tw-px-6 tw-py-4\">\n <Button\n type=\"secondary\"\n size=\"middle\"\n {...cancelButtonProps}\n onClick={onCancel}\n >\n {cancelText}\n </Button>\n <Button type={okType} size=\"middle\" {...mergedOkProps} onClick={onOk}>\n {okText}\n </Button>\n </div>\n );\n };\n\n return (\n <DialogPrimitive.Root open={open} modal={false}>\n <DialogPrimitive.Portal>\n {/* modal={false} 时 DialogPrimitive.Overlay 不渲染,用普通 div 替代 */}\n <div\n className=\"ald-modal-mask tw-animate-in tw-fade-in-0 tw-fixed tw-inset-0 tw-bg-black/45\"\n style={{ zIndex }}\n onPointerDown={() => {\n if (maskClosable) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n }\n }}\n />\n {/* Centering wrapper — replaces transform centering so consumer CSS (top/left overrides) works */}\n <div\n ref={contentRef}\n className={cn(\n // antd 兼容:保留 ant-modal-wrap class,消费方 CSS 通过 wrapClassName + :global(.ant-modal) 控制弹窗宽高\n 'ald-modal-wrap ant-modal-wrap tw-pointer-events-none tw-fixed tw-inset-0 tw-flex tw-items-center tw-justify-center',\n wrapClassName,\n )}\n style={{ zIndex: zIndex + 1 }}\n >\n <DialogPrimitive.Content\n className={cn(\n // antd 兼容:保留 ant-modal class,消费方 CSS 通过 .ant-modal 选择器控制弹窗宽高等样式\n 'ald-modal ant-modal tw-pointer-events-auto tw-flex tw-flex-col tw-overflow-hidden tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-shadow-[var(--elevation-bottom-bottom-lg)]',\n fullscreen\n ? 'ald-modal-fullscreen tw-fixed tw-inset-0 tw-size-full tw-rounded-none'\n : 'tw-rounded-r-75',\n paddingLess && 'ald-modal-padding-less',\n virtualScrollBar && 'ald-modal-virtual-scroll-bar',\n hideHeaderBottomBorder && 'ald-modal-hide-header-bottom-border',\n responsiveBounds && 'ald-modal-responsive-bounds',\n className,\n )}\n style={{\n ...(fullscreen\n ? {}\n : {\n width: responsiveBounds\n ? responsiveBoundsStyle.width\n : width || DEFAULT_WIDTH,\n ...responsiveBoundsStyle,\n }),\n ...style,\n }}\n onEscapeKeyDown={(e) => {\n if (keyboard) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n } else {\n e.preventDefault();\n }\n }}\n onPointerDownOutside={(e) => {\n if (maskClosable) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n } else {\n e.preventDefault();\n }\n }}\n onInteractOutside={(e) => {\n if (!maskClosable) {\n e.preventDefault();\n }\n }}\n >\n {/* ant-modal-content compat wrapper — matches antd DOM nesting for consumer CSS */}\n <div className=\"ant-modal-content tw-flex tw-h-full tw-flex-col\">\n {!fullscreen && (\n <div\n className={cn(\n 'ald-modal-header ant-modal-header tw-flex tw-items-start tw-justify-between tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-4',\n !hideHeaderBottomBorder &&\n 'tw-border-b tw-border-solid tw-border-[var(--global-cool-grey-100)]',\n )}\n >\n <DialogPrimitive.Title asChild>\n <div className=\"tw-flex-1\">\n {ModalTitle({ icon, title, subTitle }, _modalType)}\n </div>\n </DialogPrimitive.Title>\n {closable && (\n <DialogPrimitive.Close asChild>\n <span className=\"ant-modal-close\" onClick={onCancel}>\n {closeIcon || (\n <IconButton\n icon={<CloseLLine size={20} />}\n size=\"middle\"\n />\n )}\n </span>\n </DialogPrimitive.Close>\n )}\n </div>\n )}\n {/* Hidden title for accessibility when fullscreen hides the header */}\n {fullscreen && (\n <DialogPrimitive.Title className=\"tw-sr-only\">\n {title}\n </DialogPrimitive.Title>\n )}\n <div\n className={cn(\n 'ald-modal-body ant-modal-body tw-flex-1 tw-text-sm tw-leading-5',\n fullscreen\n ? 'tw-h-full tw-overflow-hidden tw-p-0'\n : 'tw-min-h-[130px] tw-overflow-auto',\n !fullscreen && !responsiveBounds && 'tw-max-h-[68vh]',\n !fullscreen && !paddingLess && 'tw-p-6',\n )}\n style={bodyStyle}\n >\n {virtualScrollBar ? (\n <ScrollArea\n className=\"ald-modal-body-wrap\"\n innerClassName=\"ald-modal-body-wrap-inner\"\n >\n {children}\n </ScrollArea>\n ) : (\n children\n )}\n </div>\n {!fullscreen && renderFooter()}\n </div>\n </DialogPrimitive.Content>\n </div>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n}\n\n// Static method helper\nfunction createStaticModal(\n type: ModalFuncProps['type'],\n props: ModalFuncProps,\n) {\n const container = document.createElement('div');\n document.body.appendChild(container);\n const root = createRoot(container);\n\n let currentProps = { ...props };\n\n const destroy = () => {\n root.unmount();\n container.remove();\n const idx = destroyFns.indexOf(destroy);\n if (idx >= 0) destroyFns.splice(idx, 1);\n };\n\n const update = (newProps: Partial<ModalFuncProps>) => {\n currentProps = { ...currentProps, ...newProps };\n render(currentProps);\n };\n\n const isConfirm = type === 'confirm';\n\n const render = (p: ModalFuncProps) => {\n const handleOk = () => {\n p.onOk?.();\n destroy();\n };\n const handleCancel = () => {\n p.onCancel?.();\n destroy();\n };\n\n root.render(\n <OriginModal\n open={true}\n title={p.title}\n subTitle={p.subTitle}\n icon={p.icon || getIcon(type || 'info')}\n onOk={handleOk}\n onCancel={handleCancel}\n okText={p.okText}\n cancelText={p.cancelText}\n okButtonProps={p.okButtonProps}\n cancelButtonProps={p.cancelButtonProps}\n okType={p.okType || (isConfirm ? 'dangerous' : 'primary')}\n width={p.width || DEFAULT_WIDTH}\n className={cn('ald-modal', p.className)}\n closable={p.closable}\n maskClosable={p.maskClosable}\n _modalType={type}\n footer={\n isConfirm ? undefined : (\n <Button\n type=\"primary\"\n size=\"middle\"\n {...(p.okButtonProps || {})}\n onClick={handleOk}\n >\n {p.okText || 'OK'}\n </Button>\n )\n }\n >\n {p.content}\n </OriginModal>,\n );\n };\n\n destroyFns.push(destroy);\n render(currentProps);\n\n return { destroy, update };\n}\n\n// Attach static methods\ntype ModalFunc = (props: ModalFuncProps) => {\n destroy: () => void;\n update: (props: Partial<ModalFuncProps>) => void;\n};\n\n// ---------- useModal hook ----------\n\ninterface ModalInstance {\n id: number;\n type: ModalFuncProps['type'];\n props: ModalFuncProps;\n open: boolean;\n}\n\nexport interface ModalApiInstance {\n destroy: () => void;\n update: (newProps: Partial<ModalFuncProps>) => void;\n}\n\nexport interface ModalStaticFunctions {\n info: (props: ModalFuncProps) => ModalApiInstance;\n success: (props: ModalFuncProps) => ModalApiInstance;\n error: (props: ModalFuncProps) => ModalApiInstance;\n warning: (props: ModalFuncProps) => ModalApiInstance;\n confirm: (props: ModalFuncProps) => ModalApiInstance;\n}\n\nfunction useModal(): [ModalStaticFunctions, React.ReactElement] {\n const [modals, setModals] = useState<ModalInstance[]>([]);\n const idCounter = useRef(0);\n\n const removeModal = useCallback((id: number) => {\n setModals((prev) =>\n prev.map((m) => (m.id === id ? { ...m, open: false } : m)),\n );\n // Remove from DOM after animation\n setTimeout(() => {\n setModals((prev) => prev.filter((m) => m.id !== id));\n }, 300);\n }, []);\n\n const updateModal = useCallback(\n (id: number, newProps: Partial<ModalFuncProps>) => {\n setModals((prev) =>\n prev.map((m) =>\n m.id === id ? { ...m, props: { ...m.props, ...newProps } } : m,\n ),\n );\n },\n [],\n );\n\n const openModal = useCallback(\n (type: ModalFuncProps['type'], props: ModalFuncProps): ModalApiInstance => {\n const id = ++idCounter.current;\n const instance: ModalInstance = { id, type, props, open: true };\n setModals((prev) => [...prev, instance]);\n\n return {\n destroy: () => removeModal(id),\n update: (newProps: Partial<ModalFuncProps>) =>\n updateModal(id, newProps),\n };\n },\n [removeModal, updateModal],\n );\n\n const api = useMemo<ModalStaticFunctions>(\n () => ({\n info: (props) => openModal('info', props),\n success: (props) => openModal('success', props),\n error: (props) => openModal('error', props),\n warning: (props) => openModal('warning', props),\n confirm: (props) =>\n openModal('confirm', { ...props, type: props.type || 'confirm' }),\n }),\n [openModal],\n );\n\n const contextHolder = (\n <>\n {modals.map((m) => {\n const isConfirmType = m.type === 'confirm';\n const handleOk = () => {\n m.props.onOk?.();\n removeModal(m.id);\n };\n const handleCancel = () => {\n m.props.onCancel?.();\n removeModal(m.id);\n };\n return (\n <OriginModal\n key={m.id}\n open={m.open}\n title={m.props.title}\n subTitle={m.props.subTitle}\n icon={m.props.icon || getIcon(m.type || 'info')}\n onOk={handleOk}\n onCancel={handleCancel}\n okText={m.props.okText}\n cancelText={m.props.cancelText}\n okButtonProps={m.props.okButtonProps}\n cancelButtonProps={m.props.cancelButtonProps}\n okType={m.props.okType || (isConfirmType ? 'dangerous' : 'primary')}\n width={m.props.width || DEFAULT_WIDTH}\n className={cn('ald-modal', m.props.className)}\n closable={m.props.closable}\n maskClosable={m.props.maskClosable}\n _modalType={m.type}\n footer={\n isConfirmType ? undefined : (\n <Button\n type=\"primary\"\n size=\"middle\"\n {...(m.props.okButtonProps || {})}\n onClick={handleOk}\n >\n {m.props.okText || 'OK'}\n </Button>\n )\n }\n >\n {m.props.content}\n </OriginModal>\n );\n })}\n </>\n );\n\n return [api, contextHolder];\n}\n\n// ---------- end useModal ----------\n\nconst Modal = OriginModal as typeof OriginModal & {\n info: ModalFunc;\n success: ModalFunc;\n error: ModalFunc;\n warning: ModalFunc;\n confirm: ModalFunc;\n destroyAll: () => void;\n useModal: typeof useModal;\n config: (config: any) => void;\n};\n\nModal.info = (props) => createStaticModal('info', props);\nModal.success = (props) => createStaticModal('success', props);\nModal.error = (props) => createStaticModal('error', props);\nModal.warning = (props) => createStaticModal('warning', props);\nModal.confirm = (props) =>\n createStaticModal('confirm', { ...props, type: props.type || 'confirm' });\n\nModal.destroyAll = () => {\n while (destroyFns.length) {\n const close = destroyFns.pop();\n if (close) close();\n }\n};\n\nModal.useModal = useModal;\nModal.config = () => {};\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,IAAa,aAAgC,EAAE;AAgE/C,IAAM,gBAAgB;AAEtB,IAAM,cACJ,EAAE,MAAM,OAAO,YACf,SAEA,qBAAC,OAAD;CAAK,WAAU;WAAf,CACG,QACC,oBAAC,OAAD;EACE,WAAW,GACT,qHACA,SAAS,UACP,4EACF,SAAS,aACP,6EACF,SAAS,aACP,4EACF,SAAS,UACP,4EACF,SAAS,WACP,2EACF,SAAS,aACP,8EACH;YAEA;EACG,CAAA,EAER,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,SACC,oBAAC,OAAD;GACE,WAAW,GACT,2GACA,CAAC,YAAY,uCACd;aAEA;GACG,CAAA,EAEP,YACC,oBAAC,OAAD;GAAK,WAAU;aACZ;GACG,CAAA,CAEJ;IACF;;AAGR,SAAS,QACP,MACA;AACA,KAAI,SAAS,UACX,QACE,oBAAC,QAAD;EACE,MAAK;EACL,OAAM;EACN,MAAM;EACN,CAAA;AAEN,KAAI,SAAS,QACX,QACE,oBAAC,MAAD;EACE,OAAM;EACN,MAAK;EACL,MAAM;EACN,CA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],"sourcesContent":["import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { hideOthers } from 'aria-hidden';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Button, { ButtonType, IButtonProps } from '../Button';\nimport {\n AttentionTriangleLightLine,\n CheckCircleLightLine,\n CloseLLine,\n InformationCircleLightLine,\n} from '../Icon';\nimport IconButton from '../IconButton';\nimport ScrollArea from '../ScrollArea';\nimport {\n FloatingLayerProvider,\n useFloatingLayer,\n} from '../_utils/floatingLayer';\nimport { LocaleContext, getTranslator } from '../locale/default';\nimport { cn } from '../lib/utils';\n\nexport const destroyFns: Array<() => void> = [];\n\nexport interface ModalProps {\n open?: boolean;\n onOk?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n onCancel?: (e: React.MouseEvent<HTMLButtonElement>) => void;\n afterClose?: () => void;\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n icon?: React.ReactElement;\n width?: number | string;\n footer?: React.ReactNode | null;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n confirmLoading?: boolean;\n maskClosable?: boolean;\n closable?: boolean;\n closeIcon?: React.ReactNode;\n centered?: boolean;\n destroyOnClose?: boolean;\n className?: string;\n /** Applied to the outer wrap layer (matches antd wrapClassName behavior) */\n wrapClassName?: string;\n style?: React.CSSProperties;\n bodyStyle?: React.CSSProperties;\n zIndex?: number;\n children?: React.ReactNode;\n paddingLess?: boolean;\n virtualScrollBar?: boolean;\n hideHeaderBottomBorder?: boolean;\n responsiveBounds?: boolean;\n fullscreen?: boolean;\n keyboard?: boolean;\n afterOpenChange?: (open: boolean) => void;\n getContainer?: (() => HTMLElement) | false;\n /** @internal used by static methods to pass modal type for icon styling */\n _modalType?: string;\n}\n\nexport interface ModalFuncProps {\n title?: React.ReactNode;\n subTitle?: React.ReactNode;\n content?: React.ReactNode;\n icon?: React.ReactElement;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n onOk?: (...args: any[]) => any;\n onCancel?: (...args: any[]) => any;\n width?: number | string;\n className?: string;\n /** @deprecated Use `className` instead. Preserved for antd v4 compat. */\n wrapClassName?: string;\n closable?: boolean;\n type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';\n centered?: boolean;\n maskClosable?: boolean;\n}\n\nconst DEFAULT_WIDTH = 552;\n\nconst ModalTitle = (\n { icon, title, subTitle }: Pick<ModalProps, 'icon' | 'title' | 'subTitle'>,\n type?: string,\n) => (\n <div className=\"ald-modal-title-container tw-flex tw-items-center tw-gap-4\">\n {icon && (\n <div\n className={cn(\n 'ald-modal-icon-container tw-grid tw-size-10 tw-shrink-0 tw-place-items-center tw-rounded-[var(--global-grid-250)]',\n type === 'info' &&\n 'ald-modal-cion-info-container tw-bg-[var(--action-primary-subtle-hover)]',\n type === 'success' &&\n 'ald-modal-cion-success-container tw-bg-[var(--background-positive-muted)]',\n type === 'warning' &&\n 'ald-modal-cion-warning-container tw-bg-[var(--background-warning-muted)]',\n type === 'warn' &&\n 'ald-modal-cion-warning-container tw-bg-[var(--background-warning-muted)]',\n type === 'error' &&\n 'ald-modal-cion-error-container tw-bg-[var(--background-negative-muted)]',\n type === 'confirm' &&\n 'ald-modal-cion-confirm-container tw-bg-[var(--action-primary-subtle-hover)]',\n )}\n >\n {icon}\n </div>\n )}\n <div className=\"ald-modal-text-container\">\n {title && (\n <div\n className={cn(\n 'ald-modal-text-title tw-text-lg tw-font-semibold tw-leading-7 tw-text-[var(--alias-colors-text-strong)]',\n !subTitle && 'ald-modal-text-title-only tw-text-xl',\n )}\n >\n {title}\n </div>\n )}\n {subTitle && (\n <div className=\"ald-modal-text-sub-title tw-mt-1 tw-text-xs tw-leading-4 tw-text-[var(--alias-colors-text-subtle)]\">\n {subTitle}\n </div>\n )}\n </div>\n </div>\n);\n\nfunction getIcon(\n type: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm',\n) {\n if (type === 'success')\n return (\n <CheckCircleLightLine\n fill=\"var(--content-inverted-primary)\"\n color=\"var(--background-positive-strong)\"\n size={24}\n />\n );\n if (type === 'error')\n return (\n <AttentionTriangleLightLine\n color=\"var(--background-negative-strong)\"\n fill=\"var(--content-inverted-primary)\"\n size={24}\n />\n );\n if (type === 'warning' || type === 'warn')\n return (\n <AttentionTriangleLightLine\n color=\"var(--background-warning-strong)\"\n size={24}\n />\n );\n return (\n <InformationCircleLightLine\n size={24}\n color=\"var(--interaction-default-normal)\"\n />\n );\n}\n\nfunction OriginModal(props: ModalProps) {\n const { locale } = useContext(LocaleContext);\n const t = getTranslator(locale);\n const {\n className,\n children,\n okType = 'primary',\n width,\n closeIcon,\n subTitle,\n okButtonProps = {},\n cancelButtonProps = {},\n okText = t.Modal.sure,\n cancelText = t.Modal.cancel,\n icon,\n title,\n paddingLess,\n responsiveBounds,\n hideHeaderBottomBorder,\n virtualScrollBar,\n style,\n maskClosable = false,\n fullscreen,\n open = false,\n onOk,\n onCancel,\n footer,\n confirmLoading,\n closable = true,\n zIndex = 1000,\n bodyStyle,\n keyboard = true,\n afterOpenChange,\n wrapClassName,\n _modalType,\n } = props;\n\n const prevOpenRef = useRef(open);\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (prevOpenRef.current !== open) {\n prevOpenRef.current = open;\n afterOpenChange?.(open);\n }\n }, [open, afterOpenChange]);\n\n // ---- modal={false} 补偿:锁定背景滚动 ----\n useEffect(() => {\n if (!open) return;\n const prev = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n return () => {\n document.body.style.overflow = prev;\n };\n }, [open]);\n\n // ---- modal={false} 补偿:aria-hidden(屏幕阅读器只感知弹窗) ----\n useEffect(() => {\n if (!open || !contentRef.current) return;\n return hideOthers(contentRef.current);\n }, [open]);\n\n // ---- modal={false} 补偿:Tab 焦点循环 ----\n useEffect(() => {\n if (!open || !contentRef.current) return;\n const container = contentRef.current;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key !== 'Tab') return;\n const focusable = container.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])',\n );\n if (focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n\n if (e.shiftKey) {\n if (\n document.activeElement === first ||\n !container.contains(document.activeElement)\n ) {\n e.preventDefault();\n last.focus();\n }\n } else {\n if (\n document.activeElement === last ||\n !container.contains(document.activeElement)\n ) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [open]);\n\n const responsiveBoundsStyle = useMemo(() => {\n if (!responsiveBounds) return {};\n return {\n width: 'calc(100% - 160px)',\n maxWidth: '1680px',\n minWidth: '1280px',\n height: 'calc(100% - 48px)',\n maxHeight: '900px',\n minHeight: '640px',\n };\n }, [responsiveBounds]);\n\n const mergedOkProps = { loading: confirmLoading, ...okButtonProps };\n const { maskZIndex, contentZIndex, nextLevel } = useFloatingLayer(zIndex);\n\n const renderFooter = () => {\n if (footer === null) return null;\n if (footer)\n return (\n // antd 兼容:antd .ant-modal-footer 使用 text-align:right 让 inline 按钮右对齐,\n // 即使消费方传入 width:100% 的子容器,内部 inline 元素仍能右对齐。\n // 此处同时使用 tw-flex tw-justify-end(flexbox 对齐)和 tw-text-right(继承式对齐)保持兼容。\n <div className=\"ald-modal-footer ant-modal-footer tw-flex tw-items-center tw-justify-end tw-gap-2 tw-border-t tw-border-solid tw-border-[var(--global-cool-grey-100)] tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-3 tw-text-right\">\n {footer}\n </div>\n );\n return (\n <div className=\"ald-modal-footer ant-modal-footer tw-flex tw-justify-end tw-gap-2 tw-border-t tw-border-solid tw-border-[var(--border-default)] tw-px-6 tw-py-4\">\n <Button\n type=\"secondary\"\n size=\"middle\"\n {...cancelButtonProps}\n onClick={onCancel}\n >\n {cancelText}\n </Button>\n <Button type={okType} size=\"middle\" {...mergedOkProps} onClick={onOk}>\n {okText}\n </Button>\n </div>\n );\n };\n\n return (\n <DialogPrimitive.Root open={open} modal={false}>\n <DialogPrimitive.Portal>\n {/* modal={false} 时 DialogPrimitive.Overlay 不渲染,用普通 div 替代 */}\n <div\n className=\"ald-modal-mask tw-animate-in tw-fade-in-0 tw-fixed tw-inset-0 tw-bg-black/45\"\n style={{ zIndex: maskZIndex }}\n onPointerDown={() => {\n if (maskClosable) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n }\n }}\n />\n {/* Centering wrapper — replaces transform centering so consumer CSS (top/left overrides) works */}\n <div\n ref={contentRef}\n className={cn(\n // antd 兼容:保留 ant-modal-wrap class,消费方 CSS 通过 wrapClassName + :global(.ant-modal) 控制弹窗宽高\n 'ald-modal-wrap ant-modal-wrap tw-pointer-events-none tw-fixed tw-inset-0 tw-flex tw-items-center tw-justify-center',\n wrapClassName,\n )}\n style={{ zIndex: contentZIndex }}\n >\n <DialogPrimitive.Content\n className={cn(\n // antd 兼容:保留 ant-modal class,消费方 CSS 通过 .ant-modal 选择器控制弹窗宽高等样式\n // tw-outline-none:Radix 打开时会聚焦 Content,不抑制 outline 会渲染出蓝色焦点框\n 'ald-modal ant-modal tw-pointer-events-auto tw-box-border tw-flex tw-flex-col tw-overflow-hidden tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-shadow-[var(--elevation-bottom-bottom-lg)] tw-outline-none',\n fullscreen\n ? 'ald-modal-fullscreen tw-fixed tw-inset-0 tw-size-full tw-rounded-none'\n : 'tw-rounded-r-75',\n !fullscreen &&\n 'tw-border tw-border-solid tw-border-[var(--border-default)]',\n paddingLess && 'ald-modal-padding-less',\n virtualScrollBar && 'ald-modal-virtual-scroll-bar',\n hideHeaderBottomBorder && 'ald-modal-hide-header-bottom-border',\n responsiveBounds && 'ald-modal-responsive-bounds',\n className,\n )}\n style={{\n ...(fullscreen\n ? {}\n : {\n width: responsiveBounds\n ? responsiveBoundsStyle.width\n : width || DEFAULT_WIDTH,\n ...responsiveBoundsStyle,\n }),\n ...style,\n }}\n onEscapeKeyDown={(e) => {\n if (keyboard) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n } else {\n e.preventDefault();\n }\n }}\n onPointerDownOutside={(e) => {\n if (maskClosable) {\n onCancel?.({} as React.MouseEvent<HTMLButtonElement>);\n } else {\n e.preventDefault();\n }\n }}\n onInteractOutside={(e) => {\n if (!maskClosable) {\n e.preventDefault();\n }\n }}\n >\n {/* ant-modal-content compat wrapper — matches antd DOM nesting for consumer CSS */}\n <div className=\"ant-modal-content tw-flex tw-h-full tw-flex-col\">\n <FloatingLayerProvider value={nextLevel}>\n {!fullscreen && (\n <div\n className={cn(\n 'ald-modal-header ant-modal-header tw-flex tw-items-start tw-justify-between tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-px-6 tw-py-4',\n !hideHeaderBottomBorder &&\n 'tw-border-b tw-border-solid tw-border-[var(--global-cool-grey-100)]',\n )}\n >\n <DialogPrimitive.Title asChild>\n <div className=\"tw-flex-1\">\n {ModalTitle({ icon, title, subTitle }, _modalType)}\n </div>\n </DialogPrimitive.Title>\n {closable && (\n <DialogPrimitive.Close asChild>\n <span className=\"ant-modal-close\" onClick={onCancel}>\n {closeIcon || (\n <IconButton\n icon={<CloseLLine size={20} />}\n size=\"middle\"\n />\n )}\n </span>\n </DialogPrimitive.Close>\n )}\n </div>\n )}\n {/* Hidden title for accessibility when fullscreen hides the header */}\n {fullscreen && (\n <DialogPrimitive.Title className=\"tw-sr-only\">\n {title}\n </DialogPrimitive.Title>\n )}\n <div\n className={cn(\n 'ald-modal-body ant-modal-body tw-flex-1 tw-text-sm tw-leading-5',\n fullscreen\n ? 'tw-h-full tw-overflow-hidden tw-p-0'\n : 'tw-min-h-[130px]',\n !fullscreen &&\n (virtualScrollBar\n ? 'tw-overflow-hidden tw-p-0'\n : 'tw-overflow-auto'),\n !fullscreen &&\n !responsiveBounds &&\n !virtualScrollBar &&\n 'tw-max-h-[68vh]',\n !fullscreen &&\n !paddingLess &&\n !virtualScrollBar &&\n 'tw-p-6',\n )}\n style={bodyStyle}\n >\n {virtualScrollBar ? (\n <ScrollArea\n className=\"ald-modal-body-wrap !tw-h-auto\"\n innerClassName={cn(\n 'ald-modal-body-wrap-inner tw-max-h-[68vh]',\n paddingLess ? 'tw-p-0' : 'tw-px-[23px] tw-py-0',\n )}\n >\n {children}\n </ScrollArea>\n ) : (\n children\n )}\n </div>\n {!fullscreen && renderFooter()}\n </FloatingLayerProvider>\n </div>\n </DialogPrimitive.Content>\n </div>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n}\n\n// Static method helper\nfunction createStaticModal(\n type: ModalFuncProps['type'],\n props: ModalFuncProps,\n) {\n const container = document.createElement('div');\n document.body.appendChild(container);\n const root = createRoot(container);\n\n let currentProps = { ...props };\n\n const destroy = () => {\n root.unmount();\n container.remove();\n const idx = destroyFns.indexOf(destroy);\n if (idx >= 0) destroyFns.splice(idx, 1);\n };\n\n const update = (newProps: Partial<ModalFuncProps>) => {\n currentProps = { ...currentProps, ...newProps };\n render(currentProps);\n };\n\n const isConfirm = type === 'confirm';\n\n const render = (p: ModalFuncProps) => {\n const handleOk = () => {\n p.onOk?.();\n destroy();\n };\n const handleCancel = () => {\n p.onCancel?.();\n destroy();\n };\n\n root.render(\n <OriginModal\n open={true}\n title={p.title}\n subTitle={p.subTitle}\n icon={p.icon || getIcon(type || 'info')}\n onOk={handleOk}\n onCancel={handleCancel}\n okText={p.okText}\n cancelText={p.cancelText}\n okButtonProps={p.okButtonProps}\n cancelButtonProps={p.cancelButtonProps}\n okType={p.okType || (isConfirm ? 'dangerous' : 'primary')}\n width={p.width || DEFAULT_WIDTH}\n className={cn('ald-modal', p.className)}\n closable={p.closable}\n maskClosable={p.maskClosable}\n _modalType={type}\n footer={\n isConfirm ? undefined : (\n <Button\n type=\"primary\"\n size=\"middle\"\n {...(p.okButtonProps || {})}\n onClick={handleOk}\n >\n {p.okText || 'OK'}\n </Button>\n )\n }\n >\n {p.content}\n </OriginModal>,\n );\n };\n\n destroyFns.push(destroy);\n render(currentProps);\n\n return { destroy, update };\n}\n\n// Attach static methods\ntype ModalFunc = (props: ModalFuncProps) => {\n destroy: () => void;\n update: (props: Partial<ModalFuncProps>) => void;\n};\n\n// ---------- useModal hook ----------\n\ninterface ModalInstance {\n id: number;\n type: ModalFuncProps['type'];\n props: ModalFuncProps;\n open: boolean;\n}\n\nexport interface ModalApiInstance {\n destroy: () => void;\n update: (newProps: Partial<ModalFuncProps>) => void;\n}\n\nexport interface ModalStaticFunctions {\n info: (props: ModalFuncProps) => ModalApiInstance;\n success: (props: ModalFuncProps) => ModalApiInstance;\n error: (props: ModalFuncProps) => ModalApiInstance;\n warning: (props: ModalFuncProps) => ModalApiInstance;\n confirm: (props: ModalFuncProps) => ModalApiInstance;\n}\n\nfunction useModal(): [ModalStaticFunctions, React.ReactElement] {\n const [modals, setModals] = useState<ModalInstance[]>([]);\n const idCounter = useRef(0);\n\n const removeModal = useCallback((id: number) => {\n setModals((prev) =>\n prev.map((m) => (m.id === id ? { ...m, open: false } : m)),\n );\n // Remove from DOM after animation\n setTimeout(() => {\n setModals((prev) => prev.filter((m) => m.id !== id));\n }, 300);\n }, []);\n\n const updateModal = useCallback(\n (id: number, newProps: Partial<ModalFuncProps>) => {\n setModals((prev) =>\n prev.map((m) =>\n m.id === id ? { ...m, props: { ...m.props, ...newProps } } : m,\n ),\n );\n },\n [],\n );\n\n const openModal = useCallback(\n (type: ModalFuncProps['type'], props: ModalFuncProps): ModalApiInstance => {\n const id = ++idCounter.current;\n const instance: ModalInstance = { id, type, props, open: true };\n setModals((prev) => [...prev, instance]);\n\n return {\n destroy: () => removeModal(id),\n update: (newProps: Partial<ModalFuncProps>) =>\n updateModal(id, newProps),\n };\n },\n [removeModal, updateModal],\n );\n\n const api = useMemo<ModalStaticFunctions>(\n () => ({\n info: (props) => openModal('info', props),\n success: (props) => openModal('success', props),\n error: (props) => openModal('error', props),\n warning: (props) => openModal('warning', props),\n confirm: (props) =>\n openModal('confirm', { ...props, type: props.type || 'confirm' }),\n }),\n [openModal],\n );\n\n const contextHolder = (\n <>\n {modals.map((m) => {\n const isConfirmType = m.type === 'confirm';\n const handleOk = () => {\n m.props.onOk?.();\n removeModal(m.id);\n };\n const handleCancel = () => {\n m.props.onCancel?.();\n removeModal(m.id);\n };\n return (\n <OriginModal\n key={m.id}\n open={m.open}\n title={m.props.title}\n subTitle={m.props.subTitle}\n icon={m.props.icon || getIcon(m.type || 'info')}\n onOk={handleOk}\n onCancel={handleCancel}\n okText={m.props.okText}\n cancelText={m.props.cancelText}\n okButtonProps={m.props.okButtonProps}\n cancelButtonProps={m.props.cancelButtonProps}\n okType={m.props.okType || (isConfirmType ? 'dangerous' : 'primary')}\n width={m.props.width || DEFAULT_WIDTH}\n className={cn('ald-modal', m.props.className)}\n closable={m.props.closable}\n maskClosable={m.props.maskClosable}\n _modalType={m.type}\n footer={\n isConfirmType ? undefined : (\n <Button\n type=\"primary\"\n size=\"middle\"\n {...(m.props.okButtonProps || {})}\n onClick={handleOk}\n >\n {m.props.okText || 'OK'}\n </Button>\n )\n }\n >\n {m.props.content}\n </OriginModal>\n );\n })}\n </>\n );\n\n return [api, contextHolder];\n}\n\n// ---------- end useModal ----------\n\nconst Modal = OriginModal as typeof OriginModal & {\n info: ModalFunc;\n success: ModalFunc;\n error: ModalFunc;\n warning: ModalFunc;\n confirm: ModalFunc;\n destroyAll: () => void;\n useModal: typeof useModal;\n config: (config: any) => void;\n};\n\nModal.info = (props) => createStaticModal('info', props);\nModal.success = (props) => createStaticModal('success', props);\nModal.error = (props) => createStaticModal('error', props);\nModal.warning = (props) => createStaticModal('warning', props);\nModal.confirm = (props) =>\n createStaticModal('confirm', { ...props, type: props.type || 'confirm' });\n\nModal.destroyAll = () => {\n while (destroyFns.length) {\n const close = destroyFns.pop();\n if (close) close();\n }\n};\n\nModal.useModal = useModal;\nModal.config = () => {};\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAa,aAAgC,EAAE;AAgE/C,IAAM,gBAAgB;AAEtB,IAAM,cACJ,EAAE,MAAM,OAAO,YACf,SAEA,qBAAC,OAAD;CAAK,WAAU;WAAf,CACG,QACC,oBAAC,OAAD;EACE,WAAW,GACT,qHACA,SAAS,UACP,4EACF,SAAS,aACP,6EACF,SAAS,aACP,4EACF,SAAS,UACP,4EACF,SAAS,WACP,2EACF,SAAS,aACP,8EACH;YAEA;EACG,CAAA,EAER,qBAAC,OAAD;EAAK,WAAU;YAAf,CACG,SACC,oBAAC,OAAD;GACE,WAAW,GACT,2GACA,CAAC,YAAY,uCACd;aAEA;GACG,CAAA,EAEP,YACC,oBAAC,OAAD;GAAK,WAAU;aACZ;GACG,CAAA,CAEJ;IACF;;AAGR,SAAS,QACP,MACA;AACA,KAAI,SAAS,UACX,QACE,oBAAC,QAAD;EACE,MAAK;EACL,OAAM;EACN,MAAM;EACN,CAAA;AAEN,KAAI,SAAS,QACX,QACE,oBAAC,MAAD;EACE,OAAM;EACN,MAAK;EACL,MAAM;EACN,CAAA;AAEN,KAAI,SAAS,aAAa,SAAS,OACjC,QACE,oBAAC,MAAD;EACE,OAAM;EACN,MAAM;EACN,CAAA;AAEN,QACE,oBAAC,QAAD;EACE,MAAM;EACN,OAAM;EACN,CAAA;;AAIN,SAAS,YAAY,OAAmB;CACtC,MAAM,EAAE,WAAW,WAAW,cAAc;CAC5C,MAAM,IAAI,cAAc,OAAO;CAC/B,MAAM,EACJ,WACA,UACA,SAAS,WACT,OACA,WACA,UACA,gBAAgB,EAAE,EAClB,oBAAoB,EAAE,EACtB,SAAS,EAAE,MAAM,MACjB,aAAa,EAAE,MAAM,QACrB,MACA,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QAAQ,EAAE,QAAQ,OAAO;GAC/C,MAAM;GACN,UAAU;GACV,QAAQ,EAAE,MAAM;GAChB,YAAY,EAAE,MAAM;GACpB,eAAe,EAAE,MAAM;GACvB,mBAAmB,EAAE,MAAM;GAC3B,QAAQ,EAAE,MAAM,WAAW,gBAAgB,cAAc;GACzD,OAAO,EAAE,MAAM,SAAS;GACxB,WAAW,GAAG,aAAa,EAAE,MAAM,UAAU;GAC7C,UAAU,EAAE,MAAM;GAClB,cAAc,EAAE,MAAM;GACtB,YAAY,EAAE;GACd,QACE,gBAAgB,SACd,oBAAC,gBAAD;IACE,MAAK;IACL,MAAK;IACL,GAAK,EAAE,MAAM,iBAAiB,EAAE;IAChC,SAAS;cAER,EAAE,MAAM,UAAU;IACZ,CAAA;aAIZ,EAAE,MAAM;GACG,EA/BP,EAAE,GA+BK;GAEhB,EACD,CAAA,CAGsB;;AAK7B,IAAM,QAAQ;AAWd,MAAM,QAAQ,UAAU,kBAAkB,QAAQ,MAAM;AACxD,MAAM,WAAW,UAAU,kBAAkB,WAAW,MAAM;AAC9D,MAAM,SAAS,UAAU,kBAAkB,SAAS,MAAM;AAC1D,MAAM,WAAW,UAAU,kBAAkB,WAAW,MAAM;AAC9D,MAAM,WAAW,UACf,kBAAkB,WAAW;CAAE,GAAG;CAAO,MAAM,MAAM,QAAQ;CAAW,CAAC;AAE3E,MAAM,mBAAmB;AACvB,QAAO,WAAW,QAAQ;EACxB,MAAM,QAAQ,WAAW,KAAK;AAC9B,MAAI,MAAO,QAAO;;;AAItB,MAAM,WAAW;AACjB,MAAM,eAAe"}
@@ -1,6 +1,7 @@
1
1
  import { cn } from "../lib/utils.js";
2
2
  import Memo from "../Icon/components/AttentionTriangleFill.js";
3
3
  import Button_default from "../Button/index.js";
4
+ import { useFloatingPopupZIndex } from "../_utils/floatingLayer.js";
4
5
  import React, { useState } from "react";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import * as PopoverPrimitive from "@radix-ui/react-popover";
@@ -52,6 +53,7 @@ function Popconfirm(props) {
52
53
  };
53
54
  const side = sideMap[placement] || "top";
54
55
  const align = alignMap[placement] || "center";
56
+ const popupZIndex = useFloatingPopupZIndex();
55
57
  return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, {
56
58
  open: isOpen,
57
59
  onOpenChange: handleOpenChange,
@@ -63,7 +65,10 @@ function Popconfirm(props) {
63
65
  align,
64
66
  sideOffset: 4,
65
67
  className: cn("ald-pop-confirm tw-z-50 tw-w-[240px] tw-rounded-[6px] tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--background-default)] tw-p-3 tw-outline-none", rootClassName),
66
- style: { boxShadow: "var(--elevation-bottom-bottom-md)" },
68
+ style: {
69
+ zIndex: popupZIndex,
70
+ boxShadow: "var(--elevation-bottom-bottom-md)"
71
+ },
67
72
  children: /* @__PURE__ */ jsxs("div", {
68
73
  className: "tw-flex tw-gap-2",
69
74
  children: [icon && /* @__PURE__ */ jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Popconfirm/index.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { useState } from 'react';\nimport Button, { ButtonType, IButtonProps } from '../Button';\nimport { AttentionTriangleFill } from '../Icon';\nimport { cn } from '../lib/utils';\n\nexport interface PopconfirmProps {\n title?: React.ReactNode;\n onConfirm?: (e?: React.MouseEvent) => void;\n onCancel?: (e?: React.MouseEvent) => void;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n icon?: React.ReactNode;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n placement?:\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n rootClassName?: string;\n className?: string;\n children?: React.ReactNode;\n disabled?: boolean;\n}\n\nconst sideMap: Record<string, PopoverPrimitive.PopoverContentProps['side']> = {\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n topLeft: 'top',\n topRight: 'top',\n bottomLeft: 'bottom',\n bottomRight: 'bottom',\n leftTop: 'left',\n leftBottom: 'left',\n rightTop: 'right',\n rightBottom: 'right',\n};\n\nconst alignMap: Record<string, PopoverPrimitive.PopoverContentProps['align']> =\n {\n topLeft: 'start',\n topRight: 'end',\n bottomLeft: 'start',\n bottomRight: 'end',\n leftTop: 'start',\n leftBottom: 'end',\n rightTop: 'start',\n rightBottom: 'end',\n };\n\nfunction Popconfirm(props: PopconfirmProps) {\n const {\n title,\n onConfirm,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps = {},\n cancelButtonProps = {},\n okType = 'dangerous',\n icon = (\n <AttentionTriangleFill\n size={16}\n color=\"var(--action-destructive-normal)\"\n fill=\"var(--action-inverted-normal)\"\n />\n ),\n open: controlledOpen,\n onOpenChange,\n placement = 'top',\n rootClassName,\n children,\n disabled,\n } = props;\n\n const [innerOpen, setInnerOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const isOpen = isControlled ? controlledOpen : innerOpen;\n\n const handleOpenChange = (val: boolean) => {\n if (!isControlled) setInnerOpen(val);\n onOpenChange?.(val);\n };\n\n const handleConfirm = (e?: React.MouseEvent) => {\n onConfirm?.(e);\n handleOpenChange(false);\n };\n\n const handleCancel = (e?: React.MouseEvent) => {\n onCancel?.(e);\n handleOpenChange(false);\n };\n\n const side = sideMap[placement] || 'top';\n const align = alignMap[placement] || 'center';\n\n return (\n <PopoverPrimitive.Root open={isOpen} onOpenChange={handleOpenChange}>\n <PopoverPrimitive.Trigger asChild>\n {disabled ? (\n <span>{children}</span>\n ) : React.isValidElement(children) ? (\n children\n ) : (\n <span>{children}</span>\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side={side}\n align={align}\n sideOffset={4}\n className={cn(\n 'ald-pop-confirm tw-z-50 tw-w-[240px] tw-rounded-[6px] tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--background-default)] tw-p-3 tw-outline-none',\n rootClassName,\n )}\n style={{ boxShadow: 'var(--elevation-bottom-bottom-md)' }}\n >\n <div className=\"tw-flex tw-gap-2\">\n {icon && <span className=\"tw-mt-0.5 tw-shrink-0\">{icon}</span>}\n <div className=\"tw-flex-1\">\n <div className=\"tw-mb-2 tw-break-all tw-text-xs tw-leading-4 tw-text-[var(--alias-colors-text-default)]\">\n {title}\n </div>\n <div className=\"tw-flex tw-justify-end tw-gap-2\">\n <Button\n type=\"secondary\"\n size=\"small\"\n {...cancelButtonProps}\n onClick={handleCancel}\n >\n {cancelText}\n </Button>\n <Button\n type={okType}\n size=\"small\"\n {...okButtonProps}\n onClick={handleConfirm}\n >\n {okText}\n </Button>\n </div>\n </div>\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nexport default Popconfirm;\n"],"mappings":";;;;;;;AAqCA,IAAM,UAAwE;CAC5E,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAED,IAAM,WACJ;CACE,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAEH,SAAS,WAAW,OAAwB;CAC1C,MAAM,EACJ,OACA,WACA,UACA,SAAS,MACT,aAAa,UACb,gBAAgB,EAAE,EAClB,oBAAoB,EAAE,EACtB,SAAS,aACT,OACE,oBAAC,MAAD;EACE,MAAM;EACN,OAAM;EACN,MAAK;EACL,CAAA,EAEJ,MAAM,gBACN,cACA,YAAY,OACZ,eACA,UACA,aACE;CAEJ,MAAM,CAAC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sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { useState } from 'react';\nimport Button, { ButtonType, IButtonProps } from '../Button';\nimport { AttentionTriangleFill } from '../Icon';\nimport { useFloatingPopupZIndex } from '../_utils/floatingLayer';\nimport { cn } from '../lib/utils';\n\nexport interface PopconfirmProps {\n title?: React.ReactNode;\n onConfirm?: (e?: React.MouseEvent) => void;\n onCancel?: (e?: React.MouseEvent) => void;\n okText?: React.ReactNode;\n cancelText?: React.ReactNode;\n okButtonProps?: IButtonProps;\n cancelButtonProps?: IButtonProps;\n okType?: ButtonType;\n icon?: React.ReactNode;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n placement?:\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n rootClassName?: string;\n className?: string;\n children?: React.ReactNode;\n disabled?: boolean;\n}\n\nconst sideMap: Record<string, PopoverPrimitive.PopoverContentProps['side']> = {\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n topLeft: 'top',\n topRight: 'top',\n bottomLeft: 'bottom',\n bottomRight: 'bottom',\n leftTop: 'left',\n leftBottom: 'left',\n rightTop: 'right',\n rightBottom: 'right',\n};\n\nconst alignMap: Record<string, PopoverPrimitive.PopoverContentProps['align']> =\n {\n topLeft: 'start',\n topRight: 'end',\n bottomLeft: 'start',\n bottomRight: 'end',\n leftTop: 'start',\n leftBottom: 'end',\n rightTop: 'start',\n rightBottom: 'end',\n };\n\nfunction Popconfirm(props: PopconfirmProps) {\n const {\n title,\n onConfirm,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps = {},\n cancelButtonProps = {},\n okType = 'dangerous',\n icon = (\n <AttentionTriangleFill\n size={16}\n color=\"var(--action-destructive-normal)\"\n fill=\"var(--action-inverted-normal)\"\n />\n ),\n open: controlledOpen,\n onOpenChange,\n placement = 'top',\n rootClassName,\n children,\n disabled,\n } = props;\n\n const [innerOpen, setInnerOpen] = useState(false);\n const isControlled = controlledOpen !== undefined;\n const isOpen = isControlled ? controlledOpen : innerOpen;\n\n const handleOpenChange = (val: boolean) => {\n if (!isControlled) setInnerOpen(val);\n onOpenChange?.(val);\n };\n\n const handleConfirm = (e?: React.MouseEvent) => {\n onConfirm?.(e);\n handleOpenChange(false);\n };\n\n const handleCancel = (e?: React.MouseEvent) => {\n onCancel?.(e);\n handleOpenChange(false);\n };\n\n const side = sideMap[placement] || 'top';\n const align = alignMap[placement] || 'center';\n const popupZIndex = useFloatingPopupZIndex();\n\n return (\n <PopoverPrimitive.Root open={isOpen} onOpenChange={handleOpenChange}>\n <PopoverPrimitive.Trigger asChild>\n {disabled ? (\n <span>{children}</span>\n ) : React.isValidElement(children) ? (\n children\n ) : (\n <span>{children}</span>\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n side={side}\n align={align}\n sideOffset={4}\n className={cn(\n 'ald-pop-confirm tw-z-50 tw-w-[240px] tw-rounded-[6px] tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--background-default)] tw-p-3 tw-outline-none',\n rootClassName,\n )}\n style={{\n zIndex: popupZIndex,\n boxShadow: 'var(--elevation-bottom-bottom-md)',\n }}\n >\n <div className=\"tw-flex tw-gap-2\">\n {icon && <span className=\"tw-mt-0.5 tw-shrink-0\">{icon}</span>}\n <div className=\"tw-flex-1\">\n <div className=\"tw-mb-2 tw-break-all tw-text-xs tw-leading-4 tw-text-[var(--alias-colors-text-default)]\">\n {title}\n </div>\n <div className=\"tw-flex tw-justify-end tw-gap-2\">\n <Button\n type=\"secondary\"\n size=\"small\"\n {...cancelButtonProps}\n onClick={handleCancel}\n >\n {cancelText}\n </Button>\n <Button\n type={okType}\n size=\"small\"\n {...okButtonProps}\n onClick={handleConfirm}\n >\n {okText}\n </Button>\n </div>\n </div>\n </div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nexport default Popconfirm;\n"],"mappings":";;;;;;;;AAsCA,IAAM,UAAwE;CAC5E,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAED,IAAM,WACJ;CACE,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAEH,SAAS,WAAW,OAAwB;CAC1C,MAAM,EACJ,OACA,WACA,UACA,SAAS,MACT,aAAa,UACb,gBAAgB,EAAE,EAClB,oBAAoB,EAAE,EACtB,SAAS,aACT,OACE,oBAAC,MAAD;EACE,MAAM;EACN,OAAM;EACN,MAAK;EACL,CAAA,EAEJ,MAAM,gBACN,cACA,YAAY,OACZ,eACA,UACA,aACE;CAEJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,eAAe,mBAAmB;CACxC,MAAM,SAAS,eAAe,iBAAiB;CAE/C,MAAM,oBAAoB,QAAiB;AACzC,MAAI,CAAC,aAAc,cAAa,IAAI;AACpC,iBAAe,IAAI;;CAGrB,MAAM,iBAAiB,MAAyB;AAC9C,cAAY,EAAE;AACd,mBAAiB,MAAM;;CAGzB,MAAM,gBAAgB,MAAyB;AAC7C,aAAW,EAAE;AACb,mBAAiB,MAAM;;CAGzB,MAAM,OAAO,QAAQ,cAAc;CACnC,MAAM,QAAQ,SAAS,cAAc;CACrC,MAAM,cAAc,wBAAwB;AAE5C,QACE,qBAAC,iBAAiB,MAAlB;EAAuB,MAAM;EAAQ,cAAc;YAAnD,CACE,oBAAC,iBAAiB,SAAlB;GAA0B,SAAA;aACvB,WACC,oBAAC,QAAD,EAAO,UAAgB,CAAA,GACrB,MAAM,eAAe,SAAS,GAChC,WAEA,oBAAC,QAAD,EAAO,UAAgB,CAAA;GAEA,CAAA,EAC3B,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,iBAAiB,SAAlB;GACQ;GACC;GACP,YAAY;GACZ,WAAW,GACT,oLACA,cACD;GACD,OAAO;IACL,QAAQ;IACR,WAAW;IACZ;aAED,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,QAAQ,oBAAC,QAAD;KAAM,WAAU;eAAyB;KAAY,CAAA,EAC9D,qBAAC,OAAD;KAAK,WAAU;eAAf,CACE,oBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA,EACN,qBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,oBAAC,gBAAD;OACE,MAAK;OACL,MAAK;OACL,GAAI;OACJ,SAAS;iBAER;OACM,CAAA,EACT,oBAAC,gBAAD;OACE,MAAM;OACN,MAAK;OACL,GAAI;OACJ,SAAS;iBAER;OACM,CAAA,CACL;QACF;OACF;;GACmB,CAAA,EACH,CAAA,CACJ"}
@@ -1,9 +1,9 @@
1
1
  import { cn } from "../lib/utils.js";
2
+ import { useFloatingPopupZIndex } from "../_utils/floatingLayer.js";
2
3
  import React from "react";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  import * as PopoverPrimitive from "@radix-ui/react-popover";
5
6
  //#region src/Popover/index.tsx
6
- var DEFAULT_POPOVER_Z_INDEX = 1100;
7
7
  var placementMap = {
8
8
  top: "top",
9
9
  bottom: "bottom",
@@ -47,6 +47,7 @@ function Popover(props) {
47
47
  };
48
48
  const side = placementMap[placement] || "top";
49
49
  const align = alignMap[placement] || "center";
50
+ const popupZIndex = useFloatingPopupZIndex(zIndex);
50
51
  const triggerChild = React.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
51
52
  if (triggers.size === 0 && !isControlled) return /* @__PURE__ */ jsx(Fragment, { children });
52
53
  return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, {
@@ -69,7 +70,7 @@ function Popover(props) {
69
70
  className: cn("ald-popover ant-popover-inner tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-p-3 tw-outline-none", "tw-animate-in tw-fade-in-0 tw-zoom-in-95", overlayClassName),
70
71
  style: {
71
72
  boxShadow: "var(--elevation-bottom-bottom-sm)",
72
- zIndex: zIndex ?? DEFAULT_POPOVER_Z_INDEX,
73
+ zIndex: popupZIndex,
73
74
  ...overlayStyle
74
75
  },
75
76
  onMouseEnter: isHoverTrigger ? () => handleOpenChange(true) : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Popover/index.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React from 'react';\nimport { cn } from '../lib/utils';\n\ntype TriggerType = 'hover' | 'click' | 'focus';\n\nconst DEFAULT_POPOVER_Z_INDEX = 1100;\n\nexport interface PopoverProps {\n content?: React.ReactNode;\n title?: React.ReactNode;\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger?: TriggerType | TriggerType[];\n rootClassName?: string;\n placement?:\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n overlayClassName?: string;\n overlayStyle?: React.CSSProperties;\n arrow?: boolean;\n mouseEnterDelay?: number;\n mouseLeaveDelay?: number;\n className?: string;\n style?: React.CSSProperties;\n getPopupContainer?: () => HTMLElement;\n zIndex?: number;\n}\n\nconst placementMap: Record<\n string,\n PopoverPrimitive.PopoverContentProps['side']\n> = {\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n topLeft: 'top',\n topRight: 'top',\n bottomLeft: 'bottom',\n bottomRight: 'bottom',\n leftTop: 'left',\n leftBottom: 'left',\n rightTop: 'right',\n rightBottom: 'right',\n};\n\nconst alignMap: Record<string, PopoverPrimitive.PopoverContentProps['align']> =\n {\n topLeft: 'start',\n topRight: 'end',\n bottomLeft: 'start',\n bottomRight: 'end',\n leftTop: 'start',\n leftBottom: 'end',\n rightTop: 'start',\n rightBottom: 'end',\n };\n\nfunction normalizeTrigger(trigger: PopoverProps['trigger']): Set<TriggerType> {\n if (Array.isArray(trigger)) return new Set(trigger);\n if (trigger) return new Set([trigger]);\n return new Set<TriggerType>(['hover']);\n}\n\nfunction Popover(props: PopoverProps) {\n const {\n content,\n title,\n children,\n open,\n defaultOpen,\n onOpenChange,\n trigger = 'hover',\n placement = 'top',\n overlayClassName,\n overlayStyle,\n arrow = false,\n getPopupContainer,\n zIndex,\n } = props;\n\n const containerRef = React.useRef<HTMLElement | undefined>(\n getPopupContainer?.(),\n );\n\n const [hoverOpen, setHoverOpen] = React.useState(false);\n const triggers = normalizeTrigger(trigger);\n\n const isControlled = open !== undefined;\n const isHoverTrigger = triggers.has('hover');\n const isOpen = isControlled\n ? open\n : isHoverTrigger\n ? hoverOpen\n : triggers.size === 0\n ? false\n : undefined;\n\n const handleOpenChange = (val: boolean) => {\n if (!isControlled && isHoverTrigger) {\n setHoverOpen(val);\n }\n onOpenChange?.(val);\n };\n\n const side = placementMap[placement] || 'top';\n const align = alignMap[placement] || 'center';\n\n const triggerChild = React.isValidElement(children) ? (\n children\n ) : (\n <span>{children}</span>\n );\n\n if (triggers.size === 0 && !isControlled) {\n return <>{children}</>;\n }\n\n return (\n <PopoverPrimitive.Root\n open={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n >\n <PopoverPrimitive.Trigger asChild>\n {isHoverTrigger ? (\n <span\n onMouseEnter={() => handleOpenChange(true)}\n onMouseLeave={() => handleOpenChange(false)}\n >\n {triggerChild}\n </span>\n ) : (\n triggerChild\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal container={containerRef.current}>\n <PopoverPrimitive.Content\n side={side}\n align={align}\n sideOffset={4}\n // antd 兼容:保留 ant-popover-inner class,消费方 CSS 可能通过该选择器自定义内边距、背景等样式\n className={cn(\n 'ald-popover ant-popover-inner tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-p-3 tw-outline-none',\n 'tw-animate-in tw-fade-in-0 tw-zoom-in-95',\n overlayClassName,\n )}\n style={{\n boxShadow: 'var(--elevation-bottom-bottom-sm)',\n zIndex: zIndex ?? DEFAULT_POPOVER_Z_INDEX,\n ...overlayStyle,\n }}\n onMouseEnter={\n isHoverTrigger ? () => handleOpenChange(true) : undefined\n }\n onMouseLeave={\n isHoverTrigger ? () => handleOpenChange(false) : undefined\n }\n >\n {title && (\n <div className=\"ald-popover-title tw-mb-2 tw-text-sm tw-font-medium tw-text-[var(--content-primary)]\">\n {title}\n </div>\n )}\n {content && (\n // antd 兼容:保留 ant-popover-inner-content class,消费方 CSS 可能通过该选择器自定义样式\n <div className=\"ald-popover-inner-content ant-popover-inner-content\">\n {content}\n </div>\n )}\n {arrow && (\n <PopoverPrimitive.Arrow\n style={{ fill: 'var(--alias-colors-bg-skeleton-subtler, #fff)' }}\n />\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nexport default Popover;\n"],"mappings":";;;;;AAMA,IAAM,0BAA0B;AAmChC,IAAM,eAGF;CACF,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAED,IAAM,WACJ;CACE,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAEH,SAAS,iBAAiB,SAAoD;AAC5E,KAAI,MAAM,QAAQ,QAAQ,CAAE,QAAO,IAAI,IAAI,QAAQ;AACnD,KAAI,QAAS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AuB,iBAAiB,KAAK,GAAG;IAElD,cACE,uBAAuB,iBAAiB,MAAM,GAAG;cAnBrD;KAsBG,SACC,oBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA;KAEP,WAEC,oBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA;KAEP,SACC,oBAAC,iBAAiB,OAAlB,EACE,OAAO,EAAE,MAAM,iDAAiD,EAChE,CAAA;KAEqB;;GACH,CAAA,CACJ"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/Popover/index.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React from 'react';\nimport { useFloatingPopupZIndex } from '../_utils/floatingLayer';\nimport { cn } from '../lib/utils';\n\ntype TriggerType = 'hover' | 'click' | 'focus';\n\nexport interface PopoverProps {\n content?: React.ReactNode;\n title?: React.ReactNode;\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger?: TriggerType | TriggerType[];\n rootClassName?: string;\n placement?:\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'topLeft'\n | 'topRight'\n | 'bottomLeft'\n | 'bottomRight'\n | 'leftTop'\n | 'leftBottom'\n | 'rightTop'\n | 'rightBottom';\n overlayClassName?: string;\n overlayStyle?: React.CSSProperties;\n arrow?: boolean;\n mouseEnterDelay?: number;\n mouseLeaveDelay?: number;\n className?: string;\n style?: React.CSSProperties;\n getPopupContainer?: () => HTMLElement;\n zIndex?: number;\n}\n\nconst placementMap: Record<\n string,\n PopoverPrimitive.PopoverContentProps['side']\n> = {\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n topLeft: 'top',\n topRight: 'top',\n bottomLeft: 'bottom',\n bottomRight: 'bottom',\n leftTop: 'left',\n leftBottom: 'left',\n rightTop: 'right',\n rightBottom: 'right',\n};\n\nconst alignMap: Record<string, PopoverPrimitive.PopoverContentProps['align']> =\n {\n topLeft: 'start',\n topRight: 'end',\n bottomLeft: 'start',\n bottomRight: 'end',\n leftTop: 'start',\n leftBottom: 'end',\n rightTop: 'start',\n rightBottom: 'end',\n };\n\nfunction normalizeTrigger(trigger: PopoverProps['trigger']): Set<TriggerType> {\n if (Array.isArray(trigger)) return new Set(trigger);\n if (trigger) return new Set([trigger]);\n return new Set<TriggerType>(['hover']);\n}\n\nfunction Popover(props: PopoverProps) {\n const {\n content,\n title,\n children,\n open,\n defaultOpen,\n onOpenChange,\n trigger = 'hover',\n placement = 'top',\n overlayClassName,\n overlayStyle,\n arrow = false,\n getPopupContainer,\n zIndex,\n } = props;\n\n const containerRef = React.useRef<HTMLElement | undefined>(\n getPopupContainer?.(),\n );\n\n const [hoverOpen, setHoverOpen] = React.useState(false);\n const triggers = normalizeTrigger(trigger);\n\n const isControlled = open !== undefined;\n const isHoverTrigger = triggers.has('hover');\n const isOpen = isControlled\n ? open\n : isHoverTrigger\n ? hoverOpen\n : triggers.size === 0\n ? false\n : undefined;\n\n const handleOpenChange = (val: boolean) => {\n if (!isControlled && isHoverTrigger) {\n setHoverOpen(val);\n }\n onOpenChange?.(val);\n };\n\n const side = placementMap[placement] || 'top';\n const align = alignMap[placement] || 'center';\n const popupZIndex = useFloatingPopupZIndex(zIndex);\n\n const triggerChild = React.isValidElement(children) ? (\n children\n ) : (\n <span>{children}</span>\n );\n\n if (triggers.size === 0 && !isControlled) {\n return <>{children}</>;\n }\n\n return (\n <PopoverPrimitive.Root\n open={isOpen}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n >\n <PopoverPrimitive.Trigger asChild>\n {isHoverTrigger ? (\n <span\n onMouseEnter={() => handleOpenChange(true)}\n onMouseLeave={() => handleOpenChange(false)}\n >\n {triggerChild}\n </span>\n ) : (\n triggerChild\n )}\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Portal container={containerRef.current}>\n <PopoverPrimitive.Content\n side={side}\n align={align}\n sideOffset={4}\n // antd 兼容:保留 ant-popover-inner class,消费方 CSS 可能通过该选择器自定义内边距、背景等样式\n className={cn(\n 'ald-popover ant-popover-inner tw-rounded-r-75 tw-border tw-border-solid tw-border-[var(--border-default-alpha)] tw-bg-[var(--alias-colors-bg-skeleton-subtler)] tw-p-3 tw-outline-none',\n 'tw-animate-in tw-fade-in-0 tw-zoom-in-95',\n overlayClassName,\n )}\n style={{\n boxShadow: 'var(--elevation-bottom-bottom-sm)',\n zIndex: popupZIndex,\n ...overlayStyle,\n }}\n onMouseEnter={\n isHoverTrigger ? () => handleOpenChange(true) : undefined\n }\n onMouseLeave={\n isHoverTrigger ? () => handleOpenChange(false) : undefined\n }\n >\n {title && (\n <div className=\"ald-popover-title tw-mb-2 tw-text-sm tw-font-medium tw-text-[var(--content-primary)]\">\n {title}\n </div>\n )}\n {content && (\n // antd 兼容:保留 ant-popover-inner-content class,消费方 CSS 可能通过该选择器自定义样式\n <div className=\"ald-popover-inner-content ant-popover-inner-content\">\n {content}\n </div>\n )}\n {arrow && (\n <PopoverPrimitive.Arrow\n style={{ fill: 'var(--alias-colors-bg-skeleton-subtler, #fff)' }}\n />\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n\nexport default Popover;\n"],"mappings":";;;;;;AAwCA,IAAM,eAGF;CACF,KAAK;CACL,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAED,IAAM,WACJ;CACE,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;CACb,SAAS;CACT,YAAY;CACZ,UAAU;CACV,aAAa;CACd;AAEH,SAAS,iBAAiB,SAAoD;AAC5E,KAAI,MAAM,QAAQ,QAAQ,CAAE,QAAO,IAAI,IAAI,QAAQ;AACnD,KAAI,QAAS,QAAO,IAAI,IAAI,CAAC,QAAQ,CAAC;AACtC,QAAO,IAAI,IAAiB,CAAC,QAAQ,CAAC;;A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AAG;cAnBrD;KAsBG,SACC,oBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA;KAEP,WAEC,oBAAC,OAAD;MAAK,WAAU;gBACZ;MACG,CAAA;KAEP,SACC,oBAAC,iBAAiB,OAAlB,EACE,OAAO,EAAE,MAAM,iDAAiD,EAChE,CAAA;KAEqB;;GACH,CAAA,CACJ"}
@@ -52,8 +52,10 @@ function Radio(props) {
52
52
  id,
53
53
  type: "radio",
54
54
  className: "ald-radio-input",
55
+ checked: !!checked,
55
56
  disabled: radioProps.disabled,
56
57
  value: props.value,
58
+ onChange: (e) => props.onChange?.(e),
57
59
  onClick: (e) => {
58
60
  props.onClick?.(e);
59
61
  if (inGroup && groupContext?.onChange) groupContext.onChange(props.value);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Radio/components/Radio/index.tsx"],"sourcesContent":["import { cn } from '../../../lib/utils';\nimport _ from 'lodash';\nimport React, { useContext, useRef, useState } from 'react';\n\nimport { getUUID } from '../../../_utils/hooks/useId';\nimport { IRadioProps } from '../../interface/radio';\nimport { RadioGroupContext } from '../Group';\n\nexport default function Radio(props: IRadioProps) {\n const groupContext = useContext(RadioGroupContext);\n const labelRef = useRef<HTMLLabelElement>(null);\n const [id] = useState(() => getUUID().toString());\n\n const radioProps = { ...props };\n const inGroup = !_.isEmpty(groupContext);\n\n if (inGroup) {\n radioProps.disabled = groupContext.disabled || props.disabled;\n }\n\n // checked 直接从 groupContext 或 props 派生,不使用 useState + useEffect,\n // 避免双重渲染导致切换时视觉抖动。\n const checked = inGroup\n ? !radioProps.disabled && groupContext.value === props.value\n : !('checked' in props)\n ? props.defaultChecked\n : radioProps.checked;\n\n // 设置input外层盒子的class\n const aldRadioClass = cn('ald-radio', {\n 'ald-radio-checked': checked,\n 'ald-radio-disabled': radioProps.disabled,\n });\n\n // 根据属性设置最外层的class\n const getWrapperClass = () => {\n let otherClass = '';\n if (groupContext.type === 'button') {\n if (groupContext.radioGroupStyle === 'filled') {\n otherClass = 'ald-radio-button-wrapper-filled';\n } else if (groupContext.radioGroupStyle === 'border') {\n otherClass = 'ald-radio-button-wrapper-border';\n } else if (groupContext.radioGroupStyle === 'filter') {\n otherClass = 'ald-radio-button-wrapper-filter';\n } else {\n otherClass = 'ald-radio-button-wrapper-border-primary';\n }\n } else if (groupContext.type === 'iconButton') {\n if (groupContext.radioGroupStyle === 'filled') {\n otherClass = 'ald-radio-icon-button-wrapper-filled';\n } else if (groupContext.radioGroupStyle === 'border') {\n otherClass = 'ald-radio-icon-button-wrapper-border';\n } else if (groupContext.radioGroupStyle === 'filter') {\n otherClass = 'ald-radio-icon-button-wrapper-filter';\n } else {\n otherClass = 'ald-radio-icon-button-wrapper-border-primary';\n }\n } else {\n // 当type未设置或者是radio时\n otherClass = 'ald-radio-wrapper';\n if (props.indeterminate) {\n otherClass = otherClass + ' ald-radio-wrapper-indeterminate';\n }\n }\n return cn('ald-radio-label', otherClass, props.className, {\n 'ald-radio-wrapper-checked': checked,\n 'ald-radio-wrapper-disabled': radioProps.disabled,\n });\n };\n\n // button / iconButton 模式下,radio 圆圈需要完全隐藏\n const isButtonMode =\n groupContext.type === 'button' || groupContext.type === 'iconButton';\n const radioHideStyle: React.CSSProperties | undefined = isButtonMode\n ? { width: 0, height: 0, overflow: 'hidden' }\n : undefined;\n\n return (\n <label className={getWrapperClass()} htmlFor={id} ref={labelRef}>\n <span className={aldRadioClass} style={radioHideStyle}>\n <input\n id={id}\n type=\"radio\"\n className=\"ald-radio-input\"\n disabled={radioProps.disabled}\n value={props.value}\n onClick={(e) => {\n props.onClick?.(e);\n\n if (inGroup && groupContext?.onChange) {\n // input事件的value会被toString,所以此处进行一个覆盖\n groupContext.onChange(props.value);\n }\n }}\n />\n <span className=\"ald-radio-inner\" />\n </span>\n {props.children && (\n <span className=\"ald-radio-desc\">{props.children}</span>\n )}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAQA,SAAwB,MAAM,OAAoB;CAChD,MAAM,eA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,EAAE;AAElB,SAAI,WAAW,cAAc,SAE3B,cAAa,SAAS,MAAM,MAAM;;IAGtC,CAAA,EACF,oBAAC,QAAD,EAAM,WAAU,mBAAoB,CAAA,CAC/B;MACN,MAAM,YACL,oBAAC,QAAD;GAAM,WAAU;aAAkB,MAAM;GAAgB,CAAA,CAEpD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/Radio/components/Radio/index.tsx"],"sourcesContent":["import { cn } from '../../../lib/utils';\nimport _ from 'lodash';\nimport React, { useContext, useRef, useState } from 'react';\n\nimport { getUUID } from '../../../_utils/hooks/useId';\nimport { IRadioProps } from '../../interface/radio';\nimport { RadioGroupContext } from '../Group';\n\nexport default function Radio(props: IRadioProps) {\n const groupContext = useContext(RadioGroupContext);\n const labelRef = useRef<HTMLLabelElement>(null);\n const [id] = useState(() => getUUID().toString());\n\n const radioProps = { ...props };\n const inGroup = !_.isEmpty(groupContext);\n\n if (inGroup) {\n radioProps.disabled = groupContext.disabled || props.disabled;\n }\n\n // checked 直接从 groupContext 或 props 派生,不使用 useState + useEffect,\n // 避免双重渲染导致切换时视觉抖动。\n const checked = inGroup\n ? !radioProps.disabled && groupContext.value === props.value\n : !('checked' in props)\n ? props.defaultChecked\n : radioProps.checked;\n\n // 设置input外层盒子的class\n const aldRadioClass = cn('ald-radio', {\n 'ald-radio-checked': checked,\n 'ald-radio-disabled': radioProps.disabled,\n });\n\n // 根据属性设置最外层的class\n const getWrapperClass = () => {\n let otherClass = '';\n if (groupContext.type === 'button') {\n if (groupContext.radioGroupStyle === 'filled') {\n otherClass = 'ald-radio-button-wrapper-filled';\n } else if (groupContext.radioGroupStyle === 'border') {\n otherClass = 'ald-radio-button-wrapper-border';\n } else if (groupContext.radioGroupStyle === 'filter') {\n otherClass = 'ald-radio-button-wrapper-filter';\n } else {\n otherClass = 'ald-radio-button-wrapper-border-primary';\n }\n } else if (groupContext.type === 'iconButton') {\n if (groupContext.radioGroupStyle === 'filled') {\n otherClass = 'ald-radio-icon-button-wrapper-filled';\n } else if (groupContext.radioGroupStyle === 'border') {\n otherClass = 'ald-radio-icon-button-wrapper-border';\n } else if (groupContext.radioGroupStyle === 'filter') {\n otherClass = 'ald-radio-icon-button-wrapper-filter';\n } else {\n otherClass = 'ald-radio-icon-button-wrapper-border-primary';\n }\n } else {\n // 当type未设置或者是radio时\n otherClass = 'ald-radio-wrapper';\n if (props.indeterminate) {\n otherClass = otherClass + ' ald-radio-wrapper-indeterminate';\n }\n }\n return cn('ald-radio-label', otherClass, props.className, {\n 'ald-radio-wrapper-checked': checked,\n 'ald-radio-wrapper-disabled': radioProps.disabled,\n });\n };\n\n // button / iconButton 模式下,radio 圆圈需要完全隐藏\n const isButtonMode =\n groupContext.type === 'button' || groupContext.type === 'iconButton';\n const radioHideStyle: React.CSSProperties | undefined = isButtonMode\n ? { width: 0, height: 0, overflow: 'hidden' }\n : undefined;\n\n return (\n <label className={getWrapperClass()} htmlFor={id} ref={labelRef}>\n <span className={aldRadioClass} style={radioHideStyle}>\n <input\n id={id}\n type=\"radio\"\n className=\"ald-radio-input\"\n // 同步派生的 checked 到原生 input,对齐 v2/antd 行为(仅有 class 不更新 input.checked)\n checked={!!checked}\n disabled={radioProps.disabled}\n value={props.value}\n onChange={(e) => props.onChange?.(e)}\n onClick={(e) => {\n props.onClick?.(e);\n\n if (inGroup && groupContext?.onChange) {\n // input事件的value会被toString,所以此处进行一个覆盖\n groupContext.onChange(props.value);\n }\n }}\n />\n <span className=\"ald-radio-inner\" />\n </span>\n {props.children && (\n <span className=\"ald-radio-desc\">{props.children}</span>\n )}\n </label>\n );\n}\n"],"mappings":";;;;;;;AAQA,SAAwB,MAAM,OAAoB;CAChD,MAAM,eAAe,WAAW,kBAAkB;CAClD,MAAM,WAAW,OAAyB,KAAK;CAC/C,MAAM,CAAC,MAAM,eAAe,SAAS,CAAC,UAAU,CAAC;CAEjD,MAAM,aAAa,EAAE,GAAG,OAAO;CAC/B,MAAM,UAAU,CAAC,EAAE,QAAQ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