@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 1.54 kB
Source Map (JSON)
{"version":3,"file":"context.mjs","names":[],"sources":["../../../src/base-ui/Tree/context.ts"],"sourcesContent":["import { createContext, type MouseEvent, type ReactNode, use } from 'react';\n\nimport type { ControlSize } from '../controlSize';\nimport type { TreeClassNames, TreeDataNode, TreeProps, TreeStyles } from './type';\n\nexport interface TreeContextValue {\n activeKey: string | null;\n blockNode: boolean;\n checkable: boolean;\n checked: Set<string>;\n classNames: TreeClassNames;\n disabled: boolean;\n expanded: Set<string>;\n halfChecked: Set<string>;\n indent: number;\n onRightClick: (event: MouseEvent<HTMLDivElement>, node: TreeDataNode) => void;\n selected: Set<string>;\n setActiveKey: (key: string) => void;\n showIcon: boolean;\n showLine: boolean;\n size: ControlSize;\n styles: TreeStyles;\n switcherIcon?: TreeProps['switcherIcon'];\n titleRender?: (node: TreeDataNode) => ReactNode;\n toggleCheck: (node: TreeDataNode) => void;\n toggleExpand: (node: TreeDataNode) => void;\n toggleSelect: (node: TreeDataNode, event?: { metaKey?: boolean; ctrlKey?: boolean; shiftKey?: boolean }) => void;\n}\n\nexport const TreeContext = createContext<TreeContextValue | null>(null);\n\nexport const useTreeContext = () => {\n const ctx = use(TreeContext);\n if (!ctx) throw new Error('Tree components must be rendered inside <Tree>');\n return ctx;\n};\n"],"mappings":";;AA6BA,MAAa,cAAc,cAAuC,IAAI;AAEtE,MAAa,uBAAuB;CAClC,MAAM,MAAM,IAAI,WAAW;CAC3B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,gDAAgD;CAC1E,OAAO;AACT"}