@flatbiz/antd 4.5.42 → 4.5.44

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/label-value-render/utils.ts","@flatbiz/antd/src/label-value-render/label-value.tsx"],"sourcesContent":["import { arrayTotal } from '@flatbiz/utils';\nimport { TLabelValueRenderItem } from './types';\n\nexport const getRenderGrid = (dataList: TLabelValueRenderItem[]) => {\n let results: TLabelValueRenderItem[][] = [];\n\n let currentSum = 0;\n let currentArr: TLabelValueRenderItem[] = [];\n for (let i = 0; i < dataList.length; i++) {\n const item = dataList[i];\n const grid = item.grid;\n const temp = {\n ...item,\n grid: grid,\n } as TLabelValueRenderItem;\n if (currentSum + grid <= 24 && grid > 0) {\n currentSum += grid;\n currentArr.push(temp);\n } else {\n results.push(currentArr);\n currentSum = grid;\n currentArr = [temp];\n }\n }\n\n if (currentArr.length > 0) {\n results.push(currentArr);\n }\n if (results.length > 0) {\n results = results.map((item, index) => {\n if (item.length === 1) {\n item[0].grid = 24;\n } else {\n const total = arrayTotal(item, 'grid');\n const lastItem = item[item.length - 1];\n if (total < 24) {\n lastItem.grid = 24 - total + lastItem.grid;\n }\n }\n if (index === results.length - 1) {\n return item.map((temp) => {\n temp.isLast = true;\n return temp;\n });\n }\n return item;\n });\n }\n\n let resultsFt: TLabelValueRenderItem[] = [];\n results.forEach((item) => {\n resultsFt = resultsFt.concat(item);\n });\n return resultsFt;\n};\n","import { classNames } from '@dimjs/utils';\nimport { CSSProperties, ReactElement, useMemo, useState } from 'react';\n\nimport { isNumber, isUndefinedOrNull, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { BoxGrid } from '../box-grid';\nimport { TBoxBreakpoint } from '../box-grid/type';\nimport { fbaHooks } from '../fba-hooks';\nimport { TextOverflow } from '../text-overflow';\nimport { TextSymbolWrapper } from '../text-symbol-wrapper';\nimport { TipsWrapper } from '../tips-wrapper';\nimport './style.less';\nimport { TLabelValueItem, TLabelValueRenderItem } from './types';\nimport { getRenderGrid } from './utils';\n\nexport type LabelValueRenderProps = {\n className?: string;\n style?: CSSProperties;\n /**\n * 定义一行显示几列, 默认值:4\n * ```\n * 1. label+value 一组为一列\n * 2. 当外层宽度尺寸大于 992px(lg) 时,一行显示几列\n * 3. 当外层宽度尺寸小于992px(lg),为xs、sm、md情况下不受column值影响,响应式布局\n * 4. 宽度尺寸定义\n * xs: 宽度 < 576px\n * sm: 宽度 ≥ 576px\n * md: 宽度 ≥ 768px\n * lg: 宽度 ≥ 992px\n * xl: 宽度 ≥ 1200px\n * xxl: 宽度 ≥ 1600px\n * 5. 列数尺寸定义\n * {\n * 1: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },\n * 2: { xs: 24, sm: 12, md: 12, lg: 12, xl: 12, xxl: 12 },\n * 3: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 8 },\n * 4: { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6 },\n * 6: { xs: 24, sm: 12, md: 8, lg: 6, xl: 4, xxl: 4 },\n * };\n * ```\n */\n column?: 1 | 2 | 3 | 4 | 6;\n /**\n * 强制定义一行显示几列,不考虑响应式\n * ```\n * 1. 优先级大于column\n * 2. 建议优先使用column配置\n * ```\n */\n forceColumn?: 1 | 2 | 3 | 4 | 6;\n /** 数据源配置 */\n options: TLabelValueItem[];\n /**\n * 超过宽度将自动省略,默认值:true\n * ```\n * 1. 当 direction = vertical时,强制为true\n * ```\n */\n ellipsis?: boolean;\n /**\n * 是否添加边框\n * @deprecated 已过期,请使用 bordered\n */\n border?: boolean;\n /** 是否添加边框 */\n bordered?: boolean;\n /** label对齐方式 */\n labelAlign?: 'left' | 'right' | 'center';\n /** label 宽度,默认值:100 */\n labelWidth?: number | 'auto';\n width?: number;\n /** label 样式 */\n labelStyle?: CSSProperties;\n /** value 样式 */\n valueStyle?: CSSProperties;\n\n size?: 'default' | 'small';\n /**\n * label&value 方向布局\n * ```\n * 1. auto表示当响应式为xs(小屏幕)时为vertical,其他情况为horizontal\n * ```\n */\n direction?: 'vertical' | 'horizontal' | 'auto';\n /**\n * 网格布局间距,默认值:[10, 0]\n * ```\n * 1. border = true 无效\n * ```\n */\n gutter?: [number, number];\n\n /** 隐藏 value hover效果 */\n hiddenValueHover?: boolean;\n};\n\n/**\n * label+value 列表布局\n * ```\n * 1. 可设置超出隐藏、必填标识、设置隐藏、添加说明标签等功能\n * 2. 可自定义设置占用网格列数\n * 3. 内置响应式布局\n * ```\n */\nexport const LabelValueRender = (props: LabelValueRenderProps) => {\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [breakpoint, setBreakpoint] = useState<TBoxBreakpoint>();\n\n const {\n column,\n forceColumn,\n labelAlign,\n labelWidth,\n options,\n border,\n bordered,\n width,\n size = 'default',\n direction = 'auto',\n gutter,\n hiddenValueHover,\n } = props;\n\n const columnNew = column && [1, 2, 3, 4, 6].includes(column) ? column : 4;\n\n const borderedNew = !isUndefinedOrNull(bordered) ? bordered : border;\n\n const directionNew = useMemo(() => {\n if (direction === 'horizontal' || direction === 'vertical') return direction;\n if (screenType === 'xs' || breakpoint === 'xs') return 'vertical';\n return 'horizontal';\n }, [breakpoint, direction, screenType]);\n\n const ellipsis = useMemo(() => {\n if (directionNew === 'vertical') return true;\n return isUndefinedOrNull(props.ellipsis) ? true : props.ellipsis;\n }, [directionNew, props.ellipsis]);\n\n const labelWidthNew = labelWidth ? (isNumber(labelWidth) ? `${labelWidth}px` : labelWidth) : '100px';\n\n const gridSize = useMemo(() => {\n if (forceColumn) {\n const num = 24 / forceColumn;\n return { xs: num, sm: num, md: num, lg: num, xl: num, xxl: num };\n }\n const columnMap = {\n 1: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },\n 2: { xs: 24, sm: 12, md: 12, lg: 12, xl: 12, xxl: 12 },\n 3: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 8 },\n 4: { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6 },\n 6: { xs: 24, sm: 12, md: 8, lg: 6, xl: 4, xxl: 4 },\n };\n return columnMap[columnNew];\n }, [columnNew, forceColumn]);\n\n const renderList = useMemo(() => {\n if (!breakpoint) return undefined;\n const dataListNew: TLabelValueRenderItem[] = [];\n options.forEach((item) => {\n if (!item.hidden) {\n let grid: number | undefined = undefined;\n if (item.span) {\n const itemSpan = item.span > columnNew ? columnNew : item.span;\n grid = itemSpan * (24 / columnNew);\n if (breakpoint === 'xs') {\n grid = 24;\n } else if (breakpoint === 'sm') {\n grid = grid > 12 ? grid : 12;\n }\n }\n dataListNew.push({\n ...item,\n grid: grid ? grid : gridSize[breakpoint],\n });\n }\n });\n return getRenderGrid(dataListNew.filter(Boolean));\n }, [breakpoint, columnNew, gridSize, options]);\n\n const colon = borderedNew ? '' : ':';\n\n const getFormRowChildren = () => {\n return renderList\n ?.map((item, index) => {\n const ellipsisFt =\n directionNew === 'vertical' ? true : isUndefinedOrNull(item.ellipsis) ? ellipsis : item.ellipsis;\n\n let labelContent: ReactElement | string = `${item.label}${colon}`;\n\n if (item.tips && ellipsisFt) {\n labelContent = (\n <TipsWrapper tipType=\"tooltip\" tooltipProps={{ title: item.tips }}>\n <TextOverflow text={labelContent as unknown as string} hideTip={item.hideTip} />\n </TipsWrapper>\n );\n } else if (item.tips) {\n labelContent = (\n <TipsWrapper tipType=\"tooltip\" tooltipProps={{ title: item.tips }}>\n {labelContent}\n </TipsWrapper>\n );\n } else if (ellipsisFt) {\n labelContent = <TextOverflow text={labelContent as unknown as string} hideTip={item.hideTip} />;\n }\n\n return (\n <BoxGrid.Col\n key={index}\n {...gridSize}\n span={item.grid}\n className={classNames('label-value-tr', {\n 'label-value-last-tr': item.isLast,\n })}\n >\n <span className=\"label-value-label\" style={props.labelStyle}>\n {item.required ? <TextSymbolWrapper text={labelContent} symbolType=\"required\" /> : labelContent}\n </span>\n {ellipsisFt && !item.valueNoWrapper ? (\n <span className=\"label-value-value\" style={props.valueStyle} onClick={item.onClick}>\n <TextOverflow text={item.value as string} onClick={item.onClick} hideTip={item.hideTip} />\n </span>\n ) : (\n <span\n className=\"label-value-value\"\n style={{\n wordBreak: 'break-all',\n ...props.valueStyle,\n }}\n >\n {item.onClick ? <a onClick={item.onClick}>{item.value}</a> : item.value}\n </span>\n )}\n </BoxGrid.Col>\n );\n })\n .filter(Boolean);\n };\n\n const onBoxBreakpointChange = hooks.useCallbackRef((breakpoint: TBoxBreakpoint) => {\n setBreakpoint(breakpoint);\n });\n\n const innerStyle = useMemo(() => {\n /** 小屏幕不控制宽度 */\n if (['xs', 'sm'].includes(screenType) || !width) {\n return {};\n }\n return { width };\n }, [screenType, width]);\n\n const align = (function () {\n if (labelAlign) return labelAlign;\n if (borderedNew) return 'left';\n if (directionNew === 'horizontal') return 'right';\n return 'left';\n })();\n\n return (\n <BoxGrid.Row\n style={\n {\n ...innerStyle,\n ...props.style,\n '--lvr-label-width': directionNew === 'horizontal' ? labelWidthNew : undefined,\n } as TAny\n }\n className={classNames(\n 'label-value-render',\n `lvr-${directionNew}`,\n `lvr-size-${size}`,\n `lvr-label-${align}`,\n { 'lvr-border': borderedNew },\n { 'lvr-hidden-hover': hiddenValueHover },\n props.className,\n )}\n gutter={borderedNew ? [0, 0] : gutter || [10, 0]}\n onBoxBreakpointChange={onBoxBreakpointChange}\n >\n {getFormRowChildren()}\n </BoxGrid.Row>\n );\n};\n"],"names":["getRenderGrid","dataList","results","currentSum","currentArr","i","length","item","grid","temp","_extends","push","map","index","total","arrayTotal","lastItem","isLast","resultsFt","forEach","concat","LabelValueRender","props","screenType","fbaHooks","useResponsivePoint","_useState","useState","breakpoint","setBreakpoint","column","forceColumn","labelAlign","labelWidth","options","border","bordered","width","_props$size","size","_props$direction","direction","gutter","hiddenValueHover","columnNew","includes","borderedNew","isUndefinedOrNull","directionNew","useMemo","ellipsis","labelWidthNew","isNumber","gridSize","num","xs","sm","md","lg","xl","xxl","columnMap","renderList","undefined","dataListNew","hidden","span","itemSpan","filter","Boolean","colon","getFormRowChildren","ellipsisFt","labelContent","label","tips","_jsx","TipsWrapper","tipType","tooltipProps","title","children","TextOverflow","text","hideTip","_jsxs","BoxGrid","Col","className","_classNames","style","labelStyle","required","TextSymbolWrapper","symbolType","valueNoWrapper","valueStyle","onClick","value","wordBreak","onBoxBreakpointChange","_hooks","useCallbackRef","innerStyle","align","Row"],"mappings":";i1BAGO,IAAMA,EAAgB,SAAhBA,EAAiBC,GAC5B,IAAIC,EAAqC,GAEzC,IAAIC,EAAa,EACjB,IAAIC,EAAsC,GAC1C,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAASK,OAAQD,IAAK,CACxC,IAAME,EAAON,EAASI,GACtB,IAAMG,EAAOD,EAAKC,KAClB,IAAMC,EAAIC,EAAA,CAAA,EACLH,EAAI,CACPC,KAAMA,IAER,GAAIL,EAAaK,GAAQ,IAAMA,EAAO,EAAG,CACvCL,GAAcK,EACdJ,EAAWO,KAAKF,EAClB,KAAO,CACLP,EAAQS,KAAKP,GACbD,EAAaK,EACbJ,EAAa,CAACK,EAChB,CACF,CAEA,GAAIL,EAAWE,OAAS,EAAG,CACzBJ,EAAQS,KAAKP,EACf,CACA,GAAIF,EAAQI,OAAS,EAAG,CACtBJ,EAAUA,EAAQU,KAAI,SAACL,EAAMM,GAC3B,GAAIN,EAAKD,SAAW,EAAG,CACrBC,EAAK,GAAGC,KAAO,EACjB,KAAO,CACL,IAAMM,EAAQC,EAAWR,EAAM,QAC/B,IAAMS,EAAWT,EAAKA,EAAKD,OAAS,GACpC,GAAIQ,EAAQ,GAAI,CACdE,EAASR,KAAO,GAAKM,EAAQE,EAASR,IACxC,CACF,CACA,GAAIK,IAAUX,EAAQI,OAAS,EAAG,CAChC,OAAOC,EAAKK,KAAI,SAACH,GACfA,EAAKQ,OAAS,KACd,OAAOR,CACT,GACF,CACA,OAAOF,CACT,GACF,CAEA,IAAIW,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C,UAGZ,IAAM+B,EAAwBC,EAAMC,gBAAe,SAAC1E,GAClDC,EAAcD,EAChB,IAEA,IAAM2E,EAAatD,GAAQ,WAEzB,GAAI,CAAC,KAAM,MAAMJ,SAAStB,KAAgBc,EAAO,CAC/C,MAAO,EACT,CACA,MAAO,CAAEA,MAAAA,EACX,GAAG,CAACd,EAAYc,IAEhB,IAAMmE,EAAS,WACb,GAAIxE,EAAY,OAAOA,EACvB,GAAIc,EAAa,MAAO,OACxB,GAAIE,IAAiB,aAAc,MAAO,QAC1C,MAAO,MACT,CALe,GAOf,OACE4B,EAACU,EAAQmB,IAAG,CACVf,MAAKhF,EAAA,CAAA,EAEE6F,EACAjF,EAAMoE,MAAK,CACd,oBAAqB1C,IAAiB,aAAeG,EAAgBY,YAGzEyB,UAAWC,EACT,qBAAoB,OACbzC,EACKT,YAAAA,EACCiE,aAAAA,EACb,CAAE,aAAc1D,GAChB,CAAE,mBAAoBH,GACtBrB,EAAMkE,WAER9C,OAAQI,EAAc,CAAC,EAAG,GAAKJ,GAAU,CAAC,GAAI,GAC9C0D,sBAAuBA,EAAsBnB,SAE5CV,KAGP"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/label-value-render/utils.ts","@flatbiz/antd/src/label-value-render/label-value.tsx"],"sourcesContent":["import { arrayTotal } from '@flatbiz/utils';\nimport { TLabelValueRenderItem } from './types';\n\nexport const getRenderGrid = (dataList: TLabelValueRenderItem[]) => {\n let results: TLabelValueRenderItem[][] = [];\n\n let currentSum = 0;\n let currentArr: TLabelValueRenderItem[] = [];\n for (let i = 0; i < dataList.length; i++) {\n const item = dataList[i];\n const grid = item.grid;\n const temp = {\n ...item,\n grid: grid,\n } as TLabelValueRenderItem;\n if (currentSum + grid <= 24 && grid > 0) {\n currentSum += grid;\n currentArr.push(temp);\n } else {\n results.push(currentArr);\n currentSum = grid;\n currentArr = [temp];\n }\n }\n\n if (currentArr.length > 0) {\n results.push(currentArr);\n }\n if (results.length > 0) {\n results = results.map((item, index) => {\n if (item.length === 1) {\n item[0].grid = 24;\n } else {\n const total = arrayTotal(item, 'grid');\n const lastItem = item[item.length - 1];\n if (total < 24) {\n lastItem.grid = 24 - total + lastItem.grid;\n }\n }\n if (index === results.length - 1) {\n return item.map((temp) => {\n temp.isLast = true;\n return temp;\n });\n }\n return item;\n });\n }\n\n let resultsFt: TLabelValueRenderItem[] = [];\n results.forEach((item) => {\n resultsFt = resultsFt.concat(item);\n });\n return resultsFt;\n};\n","import { classNames } from '@dimjs/utils';\nimport { CSSProperties, isValidElement, ReactElement, useMemo, useState } from 'react';\n\nimport { isNumber, isUndefinedOrNull, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { BoxGrid } from '../box-grid';\nimport { TBoxBreakpoint } from '../box-grid/type';\nimport { fbaHooks } from '../fba-hooks';\nimport { TextOverflow } from '../text-overflow';\nimport { TextSymbolWrapper } from '../text-symbol-wrapper';\nimport { TipsWrapper } from '../tips-wrapper';\nimport './style.less';\nimport { TLabelValueItem, TLabelValueRenderItem } from './types';\nimport { getRenderGrid } from './utils';\n\nexport type LabelValueRenderProps = {\n className?: string;\n style?: CSSProperties;\n /**\n * 定义一行显示几列, 默认值:4\n * ```\n * 1. label+value 一组为一列\n * 2. 当外层宽度尺寸大于 992px(lg) 时,一行显示几列\n * 3. 当外层宽度尺寸小于992px(lg),为xs、sm、md情况下不受column值影响,响应式布局\n * 4. 宽度尺寸定义\n * xs: 宽度 < 576px\n * sm: 宽度 ≥ 576px\n * md: 宽度 ≥ 768px\n * lg: 宽度 ≥ 992px\n * xl: 宽度 ≥ 1200px\n * xxl: 宽度 ≥ 1600px\n * 5. 列数尺寸定义\n * {\n * 1: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },\n * 2: { xs: 24, sm: 12, md: 12, lg: 12, xl: 12, xxl: 12 },\n * 3: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 8 },\n * 4: { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6 },\n * 6: { xs: 24, sm: 12, md: 8, lg: 6, xl: 4, xxl: 4 },\n * };\n * ```\n */\n column?: 1 | 2 | 3 | 4 | 6;\n /**\n * 强制定义一行显示几列,不考虑响应式\n * ```\n * 1. 优先级大于column\n * 2. 建议优先使用column配置\n * ```\n */\n forceColumn?: 1 | 2 | 3 | 4 | 6;\n /** 数据源配置 */\n options: TLabelValueItem[];\n /**\n * 超过宽度将自动省略,默认值:true\n * ```\n * 1. 当 direction = vertical时,强制为true\n * ```\n */\n ellipsis?: boolean;\n /**\n * 是否添加边框\n * @deprecated 已过期,请使用 bordered\n */\n border?: boolean;\n /** 是否添加边框 */\n bordered?: boolean;\n /** label对齐方式 */\n labelAlign?: 'left' | 'right' | 'center';\n /** label 宽度,默认值:100 */\n labelWidth?: number | 'auto';\n width?: number;\n /** label 样式 */\n labelStyle?: CSSProperties;\n /** value 样式 */\n valueStyle?: CSSProperties;\n\n size?: 'default' | 'small';\n /**\n * label&value 方向布局\n * ```\n * 1. auto表示当响应式为xs(小屏幕)时为vertical,其他情况为horizontal\n * ```\n */\n direction?: 'vertical' | 'horizontal' | 'auto';\n /**\n * 网格布局间距,默认值:[10, 0]\n * ```\n * 1. border = true 无效\n * ```\n */\n gutter?: [number, number];\n\n /** 隐藏 value hover效果 */\n hiddenValueHover?: boolean;\n};\n\n/**\n * label+value 列表布局\n * ```\n * 1. 可设置超出隐藏、必填标识、设置隐藏、添加说明标签等功能\n * 2. 可自定义设置占用网格列数\n * 3. 内置响应式布局\n * ```\n */\nexport const LabelValueRender = (props: LabelValueRenderProps) => {\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [breakpoint, setBreakpoint] = useState<TBoxBreakpoint>();\n\n const {\n column,\n forceColumn,\n labelAlign,\n labelWidth,\n options,\n border,\n bordered,\n width,\n size = 'default',\n direction = 'auto',\n gutter,\n hiddenValueHover,\n } = props;\n\n const columnNew = column && [1, 2, 3, 4, 6].includes(column) ? column : 4;\n\n const borderedNew = !isUndefinedOrNull(bordered) ? bordered : border;\n\n const directionNew = useMemo(() => {\n if (direction === 'horizontal' || direction === 'vertical') return direction;\n if (screenType === 'xs' || breakpoint === 'xs') return 'vertical';\n return 'horizontal';\n }, [breakpoint, direction, screenType]);\n\n const ellipsis = useMemo(() => {\n if (directionNew === 'vertical') return true;\n return isUndefinedOrNull(props.ellipsis) ? true : props.ellipsis;\n }, [directionNew, props.ellipsis]);\n\n const labelWidthNew = labelWidth ? (isNumber(labelWidth) ? `${labelWidth}px` : labelWidth) : '100px';\n\n const gridSize = useMemo(() => {\n if (forceColumn) {\n const num = 24 / forceColumn;\n return { xs: num, sm: num, md: num, lg: num, xl: num, xxl: num };\n }\n const columnMap = {\n 1: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },\n 2: { xs: 24, sm: 12, md: 12, lg: 12, xl: 12, xxl: 12 },\n 3: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 8 },\n 4: { xs: 24, sm: 12, md: 12, lg: 6, xl: 6, xxl: 6 },\n 6: { xs: 24, sm: 12, md: 8, lg: 6, xl: 4, xxl: 4 },\n };\n return columnMap[columnNew];\n }, [columnNew, forceColumn]);\n\n const renderList = useMemo(() => {\n if (!breakpoint) return undefined;\n const dataListNew: TLabelValueRenderItem[] = [];\n options.forEach((item) => {\n if (!item.hidden) {\n let grid: number | undefined = undefined;\n if (item.span) {\n const itemSpan = item.span > columnNew ? columnNew : item.span;\n grid = itemSpan * (24 / columnNew);\n if (breakpoint === 'xs') {\n grid = 24;\n } else if (breakpoint === 'sm') {\n grid = grid > 12 ? grid : 12;\n }\n }\n dataListNew.push({\n ...item,\n grid: grid ? grid : gridSize[breakpoint],\n });\n }\n });\n return getRenderGrid(dataListNew.filter(Boolean));\n }, [breakpoint, columnNew, gridSize, options]);\n\n const showColon = !borderedNew && directionNew !== 'vertical';\n\n const getFormRowChildren = () => {\n return renderList\n ?.map((item, index) => {\n const ellipsisFt =\n directionNew === 'vertical' ? true : isUndefinedOrNull(item.ellipsis) ? ellipsis : item.ellipsis;\n\n let labelContent: ReactElement | string = item.label;\n // let labelContent: ReactElement | string = isValidElement(item.label)\n // ? item.label\n // : `${item.label}${colon}`;\n // if (colon) {\n // labelContent = isValidElement(item.label)\n // ? item.label\n // : `${item.label}${colon}`;\n // }\n\n if (item.tips && ellipsisFt) {\n labelContent = (\n <TipsWrapper tipType=\"tooltip\" tooltipProps={{ title: item.tips }}>\n <TextOverflow text={labelContent as unknown as string} hideTip={item.hideTip} />\n </TipsWrapper>\n );\n } else if (item.tips) {\n labelContent = (\n <TipsWrapper tipType=\"tooltip\" tooltipProps={{ title: item.tips }}>\n {labelContent}\n </TipsWrapper>\n );\n } else if (ellipsisFt) {\n labelContent = <TextOverflow text={labelContent as unknown as string} hideTip={item.hideTip} />;\n }\n\n const innerlabelStyle = showColon ? { display: 'flex', gap: 3 } : {};\n return (\n <BoxGrid.Col\n key={index}\n {...gridSize}\n span={item.grid}\n className={classNames('label-value-tr', {\n 'label-value-last-tr': item.isLast,\n })}\n >\n <div\n className=\"label-value-label\"\n style={{\n ...innerlabelStyle,\n ...props.labelStyle,\n ...item.labelStyle,\n }}\n >\n {item.required ? (\n <div\n style={{\n paddingLeft: 8,\n position: 'relative',\n width: '100%',\n }}\n >\n <TextSymbolWrapper text={labelContent} symbolType=\"required\" />\n </div>\n ) : (\n labelContent\n )}\n {showColon ? <div>:</div> : null}\n </div>\n {!isValidElement(item.value) && ellipsisFt && !item.valueNoWrapper ? (\n <div\n className=\"label-value-value\"\n style={{\n ...props.valueStyle,\n ...item.valueStyle,\n }}\n >\n <TextOverflow text={item.value as string} onClick={item.onClick} hideTip={item.hideTip} />\n </div>\n ) : (\n <div\n className=\"label-value-value\"\n style={{\n wordBreak: 'break-all',\n ...props.valueStyle,\n ...item.valueStyle,\n }}\n >\n {item.onClick ? <a onClick={item.onClick}>{item.value}</a> : item.value}\n </div>\n )}\n </BoxGrid.Col>\n );\n })\n .filter(Boolean);\n };\n\n const onBoxBreakpointChange = hooks.useCallbackRef((breakpoint: TBoxBreakpoint) => {\n setBreakpoint(breakpoint);\n });\n\n const innerStyle = useMemo(() => {\n /** 小屏幕不控制宽度 */\n if (['xs', 'sm'].includes(screenType) || !width) {\n return {};\n }\n return { width };\n }, [screenType, width]);\n\n const align = (function () {\n if (labelAlign) return labelAlign;\n if (borderedNew) return 'left';\n if (directionNew === 'horizontal') return 'right';\n return 'left';\n })();\n\n return (\n <BoxGrid.Row\n style={\n {\n ...innerStyle,\n ...props.style,\n '--lvr-label-width': directionNew === 'horizontal' ? labelWidthNew : undefined,\n } as TAny\n }\n className={classNames(\n 'label-value-render',\n `lvr-${directionNew}`,\n `lvr-size-${size}`,\n `lvr-label-${align}`,\n { 'lvr-border': borderedNew },\n { 'lvr-hidden-hover': hiddenValueHover },\n props.className,\n )}\n gutter={borderedNew ? [0, 0] : gutter || [10, 0]}\n onBoxBreakpointChange={onBoxBreakpointChange}\n >\n {getFormRowChildren()}\n </BoxGrid.Row>\n );\n};\n"],"names":["getRenderGrid","dataList","results","currentSum","currentArr","i","length","item","grid","temp","_extends","push","map","index","total","arrayTotal","lastItem","isLast","resultsFt","forEach","concat","LabelValueRender","props","screenType","fbaHooks","useResponsivePoint","_useState","useState","breakpoint","setBreakpoint","column","forceColumn","labelAlign","labelWidth","options","border","bordered","width","_props$size","size","_props$direction","direction","gutter","hiddenValueHover","columnNew","includes","borderedNew","isUndefinedOrNull","directionNew","useMemo","ellipsis","labelWidthNew","isNumber","gridSize","num","xs","sm","md","lg","xl","xxl","columnMap","renderList","undefined","dataListNew","hidden","span","itemSpan","filter","Boolean","showColon","getFormRowChildren","ellipsisFt","labelContent","label","tips","_jsx","TipsWrapper","tipType","tooltipProps","title","children","TextOverflow","text","hideTip","innerlabelStyle","display","gap","_jsxs","BoxGrid","Col","className","_classNames","style","labelStyle","required","paddingLeft","position","TextSymbolWrapper","symbolType","isValidElement","value","valueNoWrapper","valueStyle","onClick","wordBreak","on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uD,OAAOC,UAGZ,IAAMqC,EAAwBC,EAAMC,gBAAe,SAAChF,GAClDC,EAAcD,EAChB,IAEA,IAAMiF,EAAa5D,GAAQ,WAEzB,GAAI,CAAC,KAAM,MAAMJ,SAAStB,KAAgBc,EAAO,CAC/C,MAAO,EACT,CACA,MAAO,CAAEA,MAAAA,EACX,GAAG,CAACd,EAAYc,IAEhB,IAAMyE,EAAS,WACb,GAAI9E,EAAY,OAAOA,EACvB,GAAIc,EAAa,MAAO,OACxB,GAAIE,IAAiB,aAAc,MAAO,QAC1C,MAAO,MACT,CALe,GAOf,OACE4B,EAACa,EAAQsB,IAAG,CACVlB,MAAKnF,EAAA,CAAA,EAEEmG,EACAvF,EAAMuE,MAAK,CACd,oBAAqB7C,IAAiB,aAAeG,EAAgBY,YAGzE4B,UAAWC,EACT,qBAAoB,OACb5C,EACKT,YAAAA,EACCuE,aAAAA,EACb,CAAE,aAAchE,GAChB,CAAE,mBAAoBH,GACtBrB,EAAMqE,WAERjD,OAAQI,EAAc,CAAC,EAAG,GAAKJ,GAAU,CAAC,GAAI,GAC9CgE,sBAAuBA,EAAsBzB,SAE5CV,KAGP"}
@@ -17,5 +17,5 @@ import './../dropdown-menu-wrapper/index.css';
17
17
  import './../input-search-wrapper/index.css';
18
18
  import './index.css';
19
19
  /*! @flatjs/forge MIT @flatbiz/antd */
20
- import{toArray as e,treeToTiledMap as i,isUndefinedOrNull as n,attachPropertiesToComponent as t}from"@flatbiz/utils";import{_ as o}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as r}from"@wove/react/cjs/hooks";import{useSize as l}from"ahooks";import{Modal as a}from"antd";import{Fragment as d,useRef as s,useState as u,useMemo as c}from"react";import{fbaHooks as m}from"../fba-hooks/index.js";import{isObject as h}from"@dimjs/lang/cjs/is-object";import{FlexLayout as v}from"../flex-layout/index.js";import p from"@ant-design/icons/es/icons/CloseOutlined";import{CssNodeHover as f}from"../css-node-hover/index.js";import{IconWrapper as g}from"../icon-wrapper/index.js";import{TextOverflow as j}from"../text-overflow/index.js";import{jsx as x,jsxs as C}from"react/jsx-runtime";import{TreeWrapper as y}from"../tree-wrapper/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/class-names";import"@dimjs/lang/cjs/is-undefined";import"@dimjs/lang/cjs/is-string";import"@dimjs/model-react";import"@ant-design/icons/es/icons/CaretDownFilled";import"@ant-design/icons/es/icons/MoreOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/utils/cjs/get";import"@dimjs/model";import"../button-operate/index.js";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-promise";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-utils/index.js";import"../dropdown-menu-wrapper/index.js";import"@ant-design/icons/es/icons/ExclamationCircleFilled";import"../dialog-confirm/index.js";import"../dialog-modal/index.js";import"react-dom/client";import"@wove/react/cjs/create-ctx";import"../input-search-wrapper/index.js";import"../request-status/index.js";import"@dimjs/utils/cjs/tree";import"dequal";var b=function e(i){var n=i.chenkedIdList;return x(d,{children:n==null?void 0:n.map((function(e){var n=e.value;var t=e.label||n;return x(f,{style:{paddingLeft:5,paddingRight:0},children:C(v,{fullIndex:1,direction:"horizontal",style:{alignItems:"center",fontSize:14,marginBottom:0,color:"#505050"},children:[x(j,{text:t}),x("div",{style:{position:"relative",zIndex:9,color:"#a1a1a1"},children:x(g,{text:x(p,{}),onClick:i.onDeleteItem.bind(null,n),size:"small",style:{paddingRight:5,margin:"2px"}})})]})},n)}))})};var w=function i(n){var t,l;var a=r.useId(undefined,"tree-select-modal");return x(y,o({initRootExpand:true,showSearch:true,searchPlaceholder:"搜索",checkable:true,checkableType:"2"},n.treeProps,{showIcon:(t=n.treeProps)!=null&&t.icon?true:false,value:(l=n.value)==null?void 0:l.map((function(e){return e.value})),modelKey:a,fieldNames:n.fieldNames,labelInValue:true,serviceConfig:n.serviceConfig,onChange:function i(t){n.onChange==null||n.onChange(e(t))}}))};var N=function e(n){var t,o;var r=n.value||[];var l=((t=n.fieldNames)==null?void 0:t.value)||"value";var a=((o=n.fieldNames)==null?void 0:o.children)||"children";var s=n.textConfig,u=s.selectQuantityPrompt,c=s.placeholder;return C(v,{fullIndex:0,direction:"horizontal",gap:10,style:{height:"100%",overflow:"hidden"},children:[x("div",{style:{backgroundColor:"#f4f4f4",padding:10,borderRadius:5},children:x(w,{treeProps:n.treeProps,value:r,onChange:n.onChange,fieldNames:n.fieldNames,serviceConfig:{onRequest:n.onRequest,onRequestResultAdapter:function e(t){var o=i(t,{value:l,children:a});n.onChangeDataSource==null||n.onChangeDataSource(t,o);return t}}})}),C("div",{style:{width:"40%",overflow:"hidden",height:"100%",display:"flex",flexDirection:"column",flexShrink:0},children:[x("div",{style:{fontSize:15,fontWeight:"500",marginBottom:10},children:r.length>0?x(d,{children:u?u.replace("{total}",""+((r==null?void 0:r.length)||"")):"已选择"+(r==null?void 0:r.length)}):c||"请选择"}),x("div",{style:{overflow:"auto",flex:1},children:x(b,{chenkedIdList:r,fieldNames:n.fieldNames,onDeleteItem:n.onDeleteItem})})]})]})};var R=function e(n){var t,o;var r=n.textConfig,l=r.selectQuantityPrompt,a=r.placeholder;var s=((t=n.fieldNames)==null?void 0:t.value)||"value";var u=((o=n.fieldNames)==null?void 0:o.children)||"children";var c=n.value||[];return C("div",{style:{height:"100%",overflow:"auto"},children:[x("div",{style:{backgroundColor:"#f4f4f4",padding:10,borderRadius:5},children:x(w,{treeProps:n.treeProps,value:c,onChange:n.onChange,fieldNames:n.fieldNames,serviceConfig:{onRequest:n.onRequest,onRequestResultAdapter:function e(t){var o=i(t,{value:s,children:u});n.onChangeDataSource==null||n.onChangeDataSource(t,o);return t}}})}),C("div",{style:{marginTop:20},children:[x("div",{style:{fontSize:15,fontWeight:"500",marginBottom:10},children:c.length>0?x(d,{children:l?l.replace("{total}",""+((c==null?void 0:c.length)||"")):"已选择"+(c==null?void 0:c.length)}):a}),x(b,{chenkedIdList:c,fieldNames:n.fieldNames,onDeleteItem:n.onDeleteItem})]})]})};var k=function i(t){var l,a;var c=t.isMultiple;var v=((l=t.fieldNames)==null?void 0:l.label)||"label";var p=((a=t.fieldNames)==null?void 0:a.value)||"value";var f=s({});var g=m.useResponsivePoint()||"";var j=g==="xs"?"vertical":"horizontal";var C=n(c)?true:c;var y=u(),b=y[0],w=y[1];var k=function e(i){var n=b==null?void 0:b.filter((function(e){return e.value!==i}));w(n);t.onChange==null||t.onChange(n)};m.useEffectCustom((function(){var i=e(t.value).map((function(e){var i;var n=h(e)?e:{label:e,value:e};var t=n.value;return{value:t,label:((i=f.current[t])==null?void 0:i[v])||""}}));w(i)}),[t.value]);var D=o({},t.treeProps,{checkable:C?true:false});var I=function e(i){w(i);t.onChange==null||t.onChange(i)};var P=r.useCallbackRef((function(e,i){f.current=i;var n=b==null?void 0:b.map((function(e){var n=i[e.value];return n?{label:n[v],value:n[p]}:undefined})).filter(Boolean);w(n);t.onDataSourceChange==null||t.onDataSourceChange(e,i)}));return x(d,{children:j==="vertical"?x(R,{value:b,onDeleteItem:k,fieldNames:t.fieldNames,onRequest:t.onRequest,textConfig:t.textConfig,onChange:I,onChangeDataSource:P,treeProps:D}):x(N,{value:b,onDeleteItem:k,fieldNames:t.fieldNames,onRequest:t.onRequest,textConfig:t.textConfig,onChange:I,onChangeDataSource:P,treeProps:D})})};var D=function e(i){var n=i.size,t=n===void 0?"large":n;var h=u(false),v=h[0],p=h[1];var f=l(document.querySelector("html"));var g=m.useResponsivePoint()||"";var j=g==="xs"?"vertical":"horizontal";var y=r.useCallbackRef((function(){p(true)}));var b=i.children.type;var w=u(),N=w[0],R=w[1];var D=s([]);var I=c((function(){if(!(f!=null&&f.height)||!g)return undefined;var e=["xs","sm"].includes(g);var n={};if(t=="large"){n={height:(f==null?void 0:f.height)*.65,width:800}}else if(t=="small"){n={height:(f==null?void 0:f.height)*.45,width:450}}else if(t=="middle"){n={height:(f==null?void 0:f.height)*.55,width:600}}return{height:i.modalBodyHeight||n.height,width:e?"90%":i.modalWidth||n.width}}),[f==null?void 0:f.height,g,t,i.modalBodyHeight,i.modalWidth]);var P=function e(){i.onChange==null||i.onChange(N);p(false)};var S=function e(){p(false);R(D.current)};return C(d,{children:[x(b,o({},i.children.props,{onClick:y})),x(a,{className:i.modalClassName,title:i.textConfig.title||"选择",open:v,onCancel:S,forceRender:i.forceRender,centered:true,width:I==null?void 0:I.width,onOk:P,styles:j==="horizontal"?{body:{height:I==null?void 0:I.height,maxHeight:"calc(100vh - 200px)",padding:"0px 20px 0 20px"},content:{padding:0},header:{padding:"20px 24px 0 20px"},footer:{padding:"0 24px 20px 24px"}}:{body:{height:I==null?void 0:I.height}},children:x(k,o({},i,{onChange:function e(i){R(i)}}))})]})};var I=t(D,{Content:k});export{I as TreeModal};
20
+ import{toArray as e,treeToTiledMap as i,isUndefinedOrNull as n,attachPropertiesToComponent as t}from"@flatbiz/utils";import{_ as o}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as r}from"@wove/react/cjs/hooks";import{useSize as l}from"ahooks";import{Modal as a}from"antd";import{Fragment as d,useRef as s,useState as u,useMemo as c}from"react";import{fbaHooks as m}from"../fba-hooks/index.js";import{isObject as h}from"@dimjs/lang/cjs/is-object";import{FlexLayout as p}from"../flex-layout/index.js";import v from"@ant-design/icons/es/icons/CloseOutlined";import{CssNodeHover as f}from"../css-node-hover/index.js";import{IconWrapper as g}from"../icon-wrapper/index.js";import{TextOverflow as j}from"../text-overflow/index.js";import{jsx as x,jsxs as C}from"react/jsx-runtime";import{TreeWrapper as y}from"../tree-wrapper/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/class-names";import"@dimjs/lang/cjs/is-undefined";import"@dimjs/lang/cjs/is-string";import"@dimjs/model-react";import"@dimjs/utils/cjs/array";import"@ant-design/icons/es/icons/CaretDownFilled";import"@ant-design/icons/es/icons/MoreOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/utils/cjs/get";import"@dimjs/model";import"../button-operate/index.js";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-promise";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-utils/index.js";import"../dropdown-menu-wrapper/index.js";import"@ant-design/icons/es/icons/ExclamationCircleFilled";import"../dialog-confirm/index.js";import"../dialog-modal/index.js";import"react-dom/client";import"@wove/react/cjs/create-ctx";import"../input-search-wrapper/index.js";import"../request-status/index.js";import"@dimjs/utils/cjs/tree";import"dequal";var b=function e(i){var n=i.chenkedIdList;return x(d,{children:n==null?void 0:n.map((function(e){var n=e.value;var t=e.label||n;return x(f,{style:{paddingLeft:5,paddingRight:0},children:C(p,{fullIndex:1,direction:"horizontal",style:{alignItems:"center",fontSize:14,marginBottom:0,color:"#505050"},children:[x(j,{text:t}),x("div",{style:{position:"relative",zIndex:9,color:"#a1a1a1"},children:x(g,{text:x(v,{}),onClick:i.onDeleteItem.bind(null,n),size:"small",style:{paddingRight:5,margin:"2px"}})})]})},n)}))})};var w=function i(n){var t,l;var a=r.useId(undefined,"tree-select-modal");return x(y,o({initRootExpand:true,showSearch:true,searchPlaceholder:"搜索",checkable:true,checkableType:"2"},n.treeProps,{showIcon:(t=n.treeProps)!=null&&t.icon?true:false,value:(l=n.value)==null?void 0:l.map((function(e){return e.value})),modelKey:a,fieldNames:n.fieldNames,labelInValue:true,serviceConfig:n.serviceConfig,onChange:function i(t){n.onChange==null||n.onChange(e(t))}}))};var N=function e(n){var t,o;var r=n.value||[];var l=((t=n.fieldNames)==null?void 0:t.value)||"value";var a=((o=n.fieldNames)==null?void 0:o.children)||"children";var s=n.textConfig,u=s.selectQuantityPrompt,c=s.placeholder;return C(p,{fullIndex:0,direction:"horizontal",gap:10,style:{height:"100%",overflow:"hidden"},children:[x("div",{style:{backgroundColor:"#f4f4f4",padding:10,borderRadius:5},children:x(w,{treeProps:n.treeProps,value:r,onChange:n.onChange,fieldNames:n.fieldNames,serviceConfig:{onRequest:n.onRequest,onRequestResultAdapter:function e(t){var o=i(t,{value:l,children:a});n.onChangeDataSource==null||n.onChangeDataSource(t,o);return t}}})}),C("div",{style:{width:"40%",overflow:"hidden",height:"100%",display:"flex",flexDirection:"column",flexShrink:0},children:[x("div",{style:{fontSize:15,fontWeight:"500",marginBottom:10},children:r.length>0?x(d,{children:u?u.replace("{total}",""+((r==null?void 0:r.length)||"")):"已选择"+(r==null?void 0:r.length)}):c||"请选择"}),x("div",{style:{overflow:"auto",flex:1},children:x(b,{chenkedIdList:r,fieldNames:n.fieldNames,onDeleteItem:n.onDeleteItem})})]})]})};var R=function e(n){var t,o;var r=n.textConfig,l=r.selectQuantityPrompt,a=r.placeholder;var s=((t=n.fieldNames)==null?void 0:t.value)||"value";var u=((o=n.fieldNames)==null?void 0:o.children)||"children";var c=n.value||[];return C("div",{style:{height:"100%",overflow:"auto"},children:[x("div",{style:{backgroundColor:"#f4f4f4",padding:10,borderRadius:5},children:x(w,{treeProps:n.treeProps,value:c,onChange:n.onChange,fieldNames:n.fieldNames,serviceConfig:{onRequest:n.onRequest,onRequestResultAdapter:function e(t){var o=i(t,{value:s,children:u});n.onChangeDataSource==null||n.onChangeDataSource(t,o);return t}}})}),C("div",{style:{marginTop:20},children:[x("div",{style:{fontSize:15,fontWeight:"500",marginBottom:10},children:c.length>0?x(d,{children:l?l.replace("{total}",""+((c==null?void 0:c.length)||"")):"已选择"+(c==null?void 0:c.length)}):a}),x(b,{chenkedIdList:c,fieldNames:n.fieldNames,onDeleteItem:n.onDeleteItem})]})]})};var k=function i(t){var l,a;var c=t.isMultiple;var p=((l=t.fieldNames)==null?void 0:l.label)||"label";var v=((a=t.fieldNames)==null?void 0:a.value)||"value";var f=s({});var g=m.useResponsivePoint()||"";var j=g==="xs"?"vertical":"horizontal";var C=n(c)?true:c;var y=u(),b=y[0],w=y[1];var k=function e(i){var n=b==null?void 0:b.filter((function(e){return e.value!==i}));w(n);t.onChange==null||t.onChange(n)};m.useEffectCustom((function(){var i=e(t.value).map((function(e){var i;var n=h(e)?e:{label:e,value:e};var t=n.value;return{value:t,label:((i=f.current[t])==null?void 0:i[p])||""}}));w(i)}),[t.value]);var D=o({},t.treeProps,{checkable:C?true:false});var I=function e(i){w(i);t.onChange==null||t.onChange(i)};var P=r.useCallbackRef((function(e,i){f.current=i;var n=b==null?void 0:b.map((function(e){var n=i[e.value];return n?{label:n[p],value:n[v]}:undefined})).filter(Boolean);w(n);t.onDataSourceChange==null||t.onDataSourceChange(e,i)}));return x(d,{children:j==="vertical"?x(R,{value:b,onDeleteItem:k,fieldNames:t.fieldNames,onRequest:t.onRequest,textConfig:t.textConfig,onChange:I,onChangeDataSource:P,treeProps:D}):x(N,{value:b,onDeleteItem:k,fieldNames:t.fieldNames,onRequest:t.onRequest,textConfig:t.textConfig,onChange:I,onChangeDataSource:P,treeProps:D})})};var D=function e(i){var n=i.size,t=n===void 0?"large":n;var h=u(false),p=h[0],v=h[1];var f=l(document.querySelector("html"));var g=m.useResponsivePoint()||"";var j=g==="xs"?"vertical":"horizontal";var y=r.useCallbackRef((function(){v(true)}));var b=i.children.type;var w=u(),N=w[0],R=w[1];var D=s([]);var I=c((function(){if(!(f!=null&&f.height)||!g)return undefined;var e=["xs","sm"].includes(g);var n={};if(t=="large"){n={height:(f==null?void 0:f.height)*.65,width:800}}else if(t=="small"){n={height:(f==null?void 0:f.height)*.45,width:450}}else if(t=="middle"){n={height:(f==null?void 0:f.height)*.55,width:600}}return{height:i.modalBodyHeight||n.height,width:e?"90%":i.modalWidth||n.width}}),[f==null?void 0:f.height,g,t,i.modalBodyHeight,i.modalWidth]);var P=function e(){i.onChange==null||i.onChange(N);v(false)};var S=function e(){v(false);R(D.current)};return C(d,{children:[x(b,o({},i.children.props,{onClick:y})),x(a,{className:i.modalClassName,title:i.textConfig.title||"选择",open:p,onCancel:S,forceRender:i.forceRender,centered:true,width:I==null?void 0:I.width,onOk:P,styles:j==="horizontal"?{body:{height:I==null?void 0:I.height,maxHeight:"calc(100vh - 200px)",padding:"0px 20px 0 20px"},content:{padding:0},header:{padding:"20px 24px 0 20px"},footer:{padding:"0 24px 20px 24px"}}:{body:{height:I==null?void 0:I.height}},children:x(k,o({},i,{onChange:function e(i){R(i)}}))})]})};var I=t(D,{Content:k});export{I as TreeModal};
21
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/tree-modal/select-item.tsx","@flatbiz/antd/src/tree-modal/tree.tsx","@flatbiz/antd/src/tree-modal/horizontal.tsx","@flatbiz/antd/src/tree-modal/vertical.tsx","@flatbiz/antd/src/tree-modal/select-modal-content.tsx","@flatbiz/antd/src/tree-modal/select-modal.tsx","@flatbiz/antd/src/tree-modal/index.ts"],"sourcesContent":["import { CloseOutlined } from '@ant-design/icons';\nimport type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { CssNodeHover } from '../css-node-hover';\nimport { FlexLayout } from '../flex-layout';\nimport { IconWrapper } from '../icon-wrapper';\nimport { TextOverflow } from '../text-overflow';\nimport type { TreeModalProps } from './types';\n\nexport const SelectItemList = (props: {\n chenkedIdList: TPlainObject[];\n fieldNames: TreeModalProps['fieldNames'];\n onDeleteItem: (value: TAny) => void;\n}) => {\n const chenkedIdList = props.chenkedIdList;\n return (\n <Fragment>\n {chenkedIdList?.map((item) => {\n const value = item.value;\n const label = item.label || value;\n\n return (\n <CssNodeHover style={{ paddingLeft: 5, paddingRight: 0 }} key={value}>\n <FlexLayout\n fullIndex={1}\n direction=\"horizontal\"\n style={{\n alignItems: 'center',\n fontSize: 14,\n marginBottom: 0,\n color: '#505050',\n }}\n >\n <TextOverflow text={label} />\n <div\n style={{\n position: 'relative',\n zIndex: 9,\n color: '#a1a1a1',\n }}\n >\n <IconWrapper\n text={<CloseOutlined />}\n onClick={props.onDeleteItem.bind(null, value)}\n size=\"small\"\n style={{ paddingRight: 5, margin: '2px' }}\n />\n </div>\n </FlexLayout>\n </CssNodeHover>\n );\n })}\n </Fragment>\n );\n};\n","import type { TAny } from '@flatbiz/utils';\nimport { toArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport type { TreeServiceConfig, TreeWrapperProps } from '../tree-wrapper';\nimport { TreeWrapper } from '../tree-wrapper';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const SelectContent = (props: {\n value?: TAny;\n onChange?: (value?: TreeModelSelectItem[]) => void;\n fieldNames?: TreeWrapperProps['fieldNames'];\n serviceConfig?: TreeServiceConfig;\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const modelKey = hooks.useId(undefined, 'tree-select-modal');\n return (\n <TreeWrapper\n initRootExpand\n showSearch\n searchPlaceholder=\"搜索\"\n checkable={true}\n checkableType=\"2\"\n {...props.treeProps}\n showIcon={props.treeProps?.icon ? true : false}\n value={props.value?.map((item) => item.value)}\n modelKey={modelKey}\n fieldNames={props.fieldNames}\n labelInValue={true}\n serviceConfig={props.serviceConfig}\n onChange={(values) => {\n props.onChange?.(toArray(values));\n }}\n />\n );\n};\n","import type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { treeToTiledMap } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { FlexLayout } from '../flex-layout';\nimport { SelectItemList } from './select-item';\nimport { SelectContent } from './tree';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const HorizontalLayout = (props: {\n onChangeDataSource?: (treeDataList: TPlainObject[], mapData: TPlainObject) => void;\n onDeleteItem: (value: TAny) => void;\n fieldNames?: TreeModalProps['fieldNames'];\n onRequest?: TreeModalProps['onRequest'];\n textConfig: TreeModalProps['textConfig'];\n onChange?: (value?: TreeModelSelectItem[]) => void;\n value?: TreeModelSelectItem[];\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const chenkedIdList = props.value || [];\n\n const valueKey = props.fieldNames?.value || 'value';\n const childrenKey = props.fieldNames?.children || 'children';\n\n const { selectQuantityPrompt, placeholder } = props.textConfig;\n\n return (\n <FlexLayout fullIndex={0} direction=\"horizontal\" gap={10} style={{ height: '100%', overflow: 'hidden' }}>\n <div style={{ backgroundColor: '#f4f4f4', padding: 10, borderRadius: 5 }}>\n <SelectContent\n treeProps={props.treeProps}\n value={chenkedIdList}\n onChange={props.onChange}\n fieldNames={props.fieldNames}\n serviceConfig={{\n onRequest: props.onRequest,\n onRequestResultAdapter: (respData) => {\n const listMap: TPlainObject = treeToTiledMap(respData, {\n value: valueKey,\n children: childrenKey,\n });\n props.onChangeDataSource?.(respData, listMap);\n return respData;\n },\n }}\n />\n </div>\n\n <div\n style={{\n width: '40%',\n overflow: 'hidden',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n flexShrink: 0,\n }}\n >\n <div style={{ fontSize: 15, fontWeight: '500', marginBottom: 10 }}>\n {chenkedIdList.length > 0 ? (\n <Fragment>\n {selectQuantityPrompt\n ? selectQuantityPrompt.replace('{total}', `${chenkedIdList?.length || ''}`)\n : `已选择${chenkedIdList?.length}`}\n </Fragment>\n ) : (\n placeholder || '请选择'\n )}\n </div>\n <div style={{ overflow: 'auto', flex: 1 }}>\n <SelectItemList\n chenkedIdList={chenkedIdList}\n fieldNames={props.fieldNames}\n onDeleteItem={props.onDeleteItem}\n />\n </div>\n </div>\n </FlexLayout>\n );\n};\n","import type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { treeToTiledMap } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { SelectItemList } from './select-item';\nimport { SelectContent } from './tree';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const VerticalLayout = (props: {\n onChangeDataSource?: (treeDataList: TPlainObject[], mapData: TPlainObject) => void;\n onDeleteItem: (value: TAny) => void;\n fieldNames?: TreeModalProps['fieldNames'];\n onRequest?: TreeModalProps['onRequest'];\n textConfig: TreeModalProps['textConfig'];\n onChange?: (value?: TreeModelSelectItem[]) => void;\n value?: TreeModelSelectItem[];\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const { selectQuantityPrompt, placeholder } = props.textConfig;\n const valueKey = props.fieldNames?.value || 'value';\n const childrenKey = props.fieldNames?.children || 'children';\n\n const chenkedIdList = props.value || [];\n\n return (\n <div style={{ height: '100%', overflow: 'auto' }}>\n <div style={{ backgroundColor: '#f4f4f4', padding: 10, borderRadius: 5 }}>\n <SelectContent\n treeProps={props.treeProps}\n value={chenkedIdList}\n onChange={props.onChange}\n fieldNames={props.fieldNames}\n serviceConfig={{\n onRequest: props.onRequest,\n onRequestResultAdapter: (respData) => {\n const listMap: TPlainObject = treeToTiledMap(respData, {\n value: valueKey,\n children: childrenKey,\n });\n props.onChangeDataSource?.(respData, listMap);\n return respData;\n },\n }}\n />\n </div>\n\n <div style={{ marginTop: 20 }}>\n <div style={{ fontSize: 15, fontWeight: '500', marginBottom: 10 }}>\n {chenkedIdList.length > 0 ? (\n <Fragment>\n {selectQuantityPrompt\n ? selectQuantityPrompt.replace('{total}', `${chenkedIdList?.length || ''}`)\n : `已选择${chenkedIdList?.length}`}\n </Fragment>\n ) : (\n placeholder\n )}\n </div>\n <SelectItemList\n chenkedIdList={chenkedIdList}\n fieldNames={props.fieldNames}\n onDeleteItem={props.onDeleteItem}\n />\n </div>\n </div>\n );\n};\n","import { isObject } from '@dimjs/lang';\nimport { isUndefinedOrNull, toArray, type TAny, type TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Fragment, useRef, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { HorizontalLayout } from './horizontal';\nimport type { TreeModalContentProps, TreeModelSelectItem } from './types';\nimport { VerticalLayout } from './vertical';\n\n/**\n * 树节点数据选择,一般用于选择员工等\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModalContent = (props: TreeModalContentProps) => {\n const { isMultiple } = props;\n const labelKey = props.fieldNames?.label || 'label';\n const valueKey = props.fieldNames?.value || 'value';\n const dataSourceMapRef = useRef<TPlainObject>({});\n\n const screenType = fbaHooks.useResponsivePoint() || '';\n\n const direction = screenType === 'xs' ? 'vertical' : 'horizontal';\n const isMultipleFt = isUndefinedOrNull(isMultiple) ? true : isMultiple;\n\n const [values, setValues] = useState<TreeModelSelectItem[]>();\n\n const onDeleteItem = (value) => {\n const targetList = values?.filter((item) => item.value !== value);\n setValues(targetList);\n props.onChange?.(targetList);\n };\n\n fbaHooks.useEffectCustom(() => {\n const values = toArray<TAny>(props.value).map((item) => {\n const target = isObject(item) ? item : { label: item, value: item };\n const value = target.value;\n return {\n value: value,\n label: dataSourceMapRef.current[value]?.[labelKey] || '',\n };\n });\n setValues(values);\n }, [props.value]);\n\n const treePropsFt = {\n ...props.treeProps,\n checkable: isMultipleFt ? true : false,\n };\n\n const onChange = (values?: TreeModelSelectItem[]) => {\n setValues(values);\n props.onChange?.(values);\n };\n\n const onChangeDataSource = hooks.useCallbackRef((treeDataList: TPlainObject[], mapData: TPlainObject) => {\n dataSourceMapRef.current = mapData;\n const result = values\n ?.map((item) => {\n const target = mapData[item.value];\n return target ? { label: target[labelKey], value: target[valueKey] } : undefined;\n })\n .filter(Boolean) as TreeModelSelectItem[];\n setValues(result);\n props.onDataSourceChange?.(treeDataList, mapData);\n });\n\n return (\n <Fragment>\n {direction === 'vertical' ? (\n <VerticalLayout\n value={values}\n onDeleteItem={onDeleteItem}\n fieldNames={props.fieldNames}\n onRequest={props.onRequest}\n textConfig={props.textConfig}\n onChange={onChange}\n onChangeDataSource={onChangeDataSource}\n treeProps={treePropsFt}\n ></VerticalLayout>\n ) : (\n <HorizontalLayout\n value={values}\n onDeleteItem={onDeleteItem}\n fieldNames={props.fieldNames}\n onRequest={props.onRequest}\n textConfig={props.textConfig}\n onChange={onChange}\n onChangeDataSource={onChangeDataSource}\n treeProps={treePropsFt}\n />\n )}\n </Fragment>\n );\n};\n","import type { TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { useSize } from 'ahooks';\nimport { Modal } from 'antd';\nimport { Fragment, useMemo, useRef, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { TreeModalContent } from './select-modal-content';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\n/**\n * 树节点数据选择,一般用于选择员工等\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModal = (props: TreeModalProps) => {\n const { size = 'large' } = props;\n const [isOpen, setIsOpen] = useState(false);\n\n const htmlSize = useSize(document.querySelector('html'));\n const screenType = fbaHooks.useResponsivePoint() || '';\n\n const direction = screenType === 'xs' ? 'vertical' : 'horizontal';\n\n const handleOnClick = hooks.useCallbackRef(() => {\n setIsOpen(true);\n });\n\n const Action = props.children.type;\n\n const [values, setValues] = useState<TreeModelSelectItem[]>();\n const originalValuesRef = useRef<TreeModelSelectItem[]>([]);\n\n const customSize = useMemo(() => {\n if (!htmlSize?.height || !screenType) return undefined;\n const isXsSm = ['xs', 'sm'].includes(screenType);\n let sizeCalculate: TPlainObject = {};\n if (size == 'large') {\n sizeCalculate = {\n height: htmlSize?.height * 0.65,\n width: 800,\n };\n } else if (size == 'small') {\n sizeCalculate = {\n height: htmlSize?.height * 0.45,\n width: 450,\n };\n } else if (size == 'middle') {\n sizeCalculate = {\n height: htmlSize?.height * 0.55,\n width: 600,\n };\n }\n\n return {\n height: props.modalBodyHeight || sizeCalculate.height,\n width: isXsSm ? '90%' : props.modalWidth || sizeCalculate.width,\n };\n }, [htmlSize?.height, screenType, size, props.modalBodyHeight, props.modalWidth]);\n\n const onSubmit = () => {\n props.onChange?.(values);\n setIsOpen(false);\n };\n\n const onCancel = () => {\n setIsOpen(false);\n setValues(originalValuesRef.current);\n };\n\n return (\n <Fragment>\n <Action {...props.children.props} onClick={handleOnClick} />\n <Modal\n className={props.modalClassName}\n title={props.textConfig.title || '选择'}\n open={isOpen}\n onCancel={onCancel}\n forceRender={props.forceRender}\n centered\n width={customSize?.width}\n onOk={onSubmit}\n styles={\n direction === 'horizontal'\n ? {\n body: {\n height: customSize?.height,\n maxHeight: 'calc(100vh - 200px)',\n padding: '0px 20px 0 20px',\n },\n content: {\n padding: 0,\n },\n header: {\n padding: '20px 24px 0 20px',\n },\n footer: {\n padding: '0 24px 20px 24px',\n },\n }\n : {\n body: {\n height: customSize?.height,\n },\n }\n }\n >\n <TreeModalContent\n {...props}\n onChange={(values) => {\n setValues(values);\n }}\n />\n </Modal>\n </Fragment>\n );\n};\n","import { attachPropertiesToComponent } from '@flatbiz/utils';\nimport { TreeModal as TreeModalInner } from './select-modal';\nimport { TreeModalContent } from './select-modal-content';\n\nexport const TreeModal = attachPropertiesToComponent(TreeModalInner, {\n Content: TreeModalContent,\n});\n"],"names":["SelectItemList","props","chenkedIdList","_jsx","Fragment","children","map","item","value","label","CssNodeHover","style","paddingLeft","paddingRight","_jsxs","FlexLayout","fullIndex","direction","alignItems","fontSize","marginBottom","color","TextOverflow","text","position","zIndex","IconWrapper","_CloseOutlined","onClick","onDeleteItem","bind","size","margin","SelectContent","_props$treeProps","_props$value","modelKey","_hooks","useId","undefined","TreeWrapper","_extends","initRootExpand","showSearch","searchPlaceholder","checkable","checkableType","treeProps","showIcon","icon","fieldNames","labelInValue","serviceConfig","onChange","values","toArray","HorizontalLayout","_props$fieldNames","_props$fieldNames2","valueKey","childrenKey","_props$textConfig","textConfig","selectQuantityPrompt","placeholder","gap","height","overflow","backgroundColor","padding","borderRadius","onRequest","onRequestResultAdapter","respData","listMap","treeToTiledMap","onChangeDataSource","width","display","flexDirection","flexShrink","fontWeight","length","replace","flex","VerticalLayout","marginTop","TreeModalContent","isMultiple","labelKey","dataSourceMapRef","useRef","screenType","fbaHooks","useResponsivePoint","isMultipleFt","isUndefinedOrNull","_useState","useState","setValues","targetList","filter","useEffectCustom","_dataSourceMapRef$cur","target","_isObject","current","treePropsFt","useCallbackRef","treeDataList","mapData","result","Boolean","onDataSourceChange","TreeModal","_props$size","isOpen","setIsOpen","htmlSize","useSize","document","querySelector","handleOnClick","Action","type","_useState2","originalValuesRef","customSize","useMemo","isXsSm","includes","sizeCalculate","modalBodyHeight","modalWidth","onSubmit","onCancel","Modal","className","modalClassName","title","open","forceRender","centered","onOk","styles","body","maxHeight","content","header","footer","attachPropertiesToComponent","TreeModalInner","Content"],"mappings":";4oEASO,IAAMA,EAAiB,SAAjBA,EAAkBC,GAK7B,IAAMC,EAAgBD,EAAMC,cAC5B,OACEC,EAACC,EAAQ,CAAAC,SACNH,GAAAA,UAAAA,EAAAA,EAAeI,KAAI,SAACC,GACnB,IAAMC,EAAQD,EAAKC,MACnB,IAAMC,EAAQF,EAAKE,OAASD,EAE5B,OACEL,EAACO,EAAY,CAACC,MAAO,CAAEC,YAAa,EAAGC,aAAc,GAAIR,SACvDS,EAACC,EAAU,CACTC,UAAW,EACXC,UAAU,aACVN,MAAO,CACLO,WAAY,SACZC,SAAU,GACVC,aAAc,EACdC,MAAO,WACPhB,SAAA,CAEFF,EAACm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U,SAAVA,EAAWC,GACT6C,EAAU7C,EACZ,SAKV,MCjHa4D,EAAYoC,EAA4BC,EAAgB,CACnEC,QAASjE"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/tree-modal/select-item.tsx","@flatbiz/antd/src/tree-modal/tree.tsx","@flatbiz/antd/src/tree-modal/horizontal.tsx","@flatbiz/antd/src/tree-modal/vertical.tsx","@flatbiz/antd/src/tree-modal/select-modal-content.tsx","@flatbiz/antd/src/tree-modal/select-modal.tsx","@flatbiz/antd/src/tree-modal/index.ts"],"sourcesContent":["import { CloseOutlined } from '@ant-design/icons';\nimport type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { CssNodeHover } from '../css-node-hover';\nimport { FlexLayout } from '../flex-layout';\nimport { IconWrapper } from '../icon-wrapper';\nimport { TextOverflow } from '../text-overflow';\nimport type { TreeModalProps } from './types';\n\nexport const SelectItemList = (props: {\n chenkedIdList: TPlainObject[];\n fieldNames: TreeModalProps['fieldNames'];\n onDeleteItem: (value: TAny) => void;\n}) => {\n const chenkedIdList = props.chenkedIdList;\n return (\n <Fragment>\n {chenkedIdList?.map((item) => {\n const value = item.value;\n const label = item.label || value;\n\n return (\n <CssNodeHover style={{ paddingLeft: 5, paddingRight: 0 }} key={value}>\n <FlexLayout\n fullIndex={1}\n direction=\"horizontal\"\n style={{\n alignItems: 'center',\n fontSize: 14,\n marginBottom: 0,\n color: '#505050',\n }}\n >\n <TextOverflow text={label} />\n <div\n style={{\n position: 'relative',\n zIndex: 9,\n color: '#a1a1a1',\n }}\n >\n <IconWrapper\n text={<CloseOutlined />}\n onClick={props.onDeleteItem.bind(null, value)}\n size=\"small\"\n style={{ paddingRight: 5, margin: '2px' }}\n />\n </div>\n </FlexLayout>\n </CssNodeHover>\n );\n })}\n </Fragment>\n );\n};\n","import type { TAny } from '@flatbiz/utils';\nimport { toArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport type { TreeServiceConfig, TreeWrapperProps } from '../tree-wrapper';\nimport { TreeWrapper } from '../tree-wrapper';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const SelectContent = (props: {\n value?: TAny;\n onChange?: (value?: TreeModelSelectItem[]) => void;\n fieldNames?: TreeWrapperProps['fieldNames'];\n serviceConfig?: TreeServiceConfig;\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const modelKey = hooks.useId(undefined, 'tree-select-modal');\n return (\n <TreeWrapper\n initRootExpand\n showSearch\n searchPlaceholder=\"搜索\"\n checkable={true}\n checkableType=\"2\"\n {...props.treeProps}\n showIcon={props.treeProps?.icon ? true : false}\n value={props.value?.map((item) => item.value)}\n modelKey={modelKey}\n fieldNames={props.fieldNames}\n labelInValue={true}\n serviceConfig={props.serviceConfig}\n onChange={(values) => {\n props.onChange?.(toArray(values));\n }}\n />\n );\n};\n","import type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { treeToTiledMap } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { FlexLayout } from '../flex-layout';\nimport { SelectItemList } from './select-item';\nimport { SelectContent } from './tree';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const HorizontalLayout = (props: {\n onChangeDataSource?: (treeDataList: TPlainObject[], mapData: TPlainObject) => void;\n onDeleteItem: (value: TAny) => void;\n fieldNames?: TreeModalProps['fieldNames'];\n onRequest?: TreeModalProps['onRequest'];\n textConfig: TreeModalProps['textConfig'];\n onChange?: (value?: TreeModelSelectItem[]) => void;\n value?: TreeModelSelectItem[];\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const chenkedIdList = props.value || [];\n\n const valueKey = props.fieldNames?.value || 'value';\n const childrenKey = props.fieldNames?.children || 'children';\n\n const { selectQuantityPrompt, placeholder } = props.textConfig;\n\n return (\n <FlexLayout fullIndex={0} direction=\"horizontal\" gap={10} style={{ height: '100%', overflow: 'hidden' }}>\n <div style={{ backgroundColor: '#f4f4f4', padding: 10, borderRadius: 5 }}>\n <SelectContent\n treeProps={props.treeProps}\n value={chenkedIdList}\n onChange={props.onChange}\n fieldNames={props.fieldNames}\n serviceConfig={{\n onRequest: props.onRequest,\n onRequestResultAdapter: (respData) => {\n const listMap: TPlainObject = treeToTiledMap(respData, {\n value: valueKey,\n children: childrenKey,\n });\n props.onChangeDataSource?.(respData, listMap);\n return respData;\n },\n }}\n />\n </div>\n\n <div\n style={{\n width: '40%',\n overflow: 'hidden',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n flexShrink: 0,\n }}\n >\n <div style={{ fontSize: 15, fontWeight: '500', marginBottom: 10 }}>\n {chenkedIdList.length > 0 ? (\n <Fragment>\n {selectQuantityPrompt\n ? selectQuantityPrompt.replace('{total}', `${chenkedIdList?.length || ''}`)\n : `已选择${chenkedIdList?.length}`}\n </Fragment>\n ) : (\n placeholder || '请选择'\n )}\n </div>\n <div style={{ overflow: 'auto', flex: 1 }}>\n <SelectItemList\n chenkedIdList={chenkedIdList}\n fieldNames={props.fieldNames}\n onDeleteItem={props.onDeleteItem}\n />\n </div>\n </div>\n </FlexLayout>\n );\n};\n","import type { TAny, TPlainObject } from '@flatbiz/utils';\nimport { treeToTiledMap } from '@flatbiz/utils';\nimport { Fragment } from 'react';\nimport { SelectItemList } from './select-item';\nimport { SelectContent } from './tree';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\nexport const VerticalLayout = (props: {\n onChangeDataSource?: (treeDataList: TPlainObject[], mapData: TPlainObject) => void;\n onDeleteItem: (value: TAny) => void;\n fieldNames?: TreeModalProps['fieldNames'];\n onRequest?: TreeModalProps['onRequest'];\n textConfig: TreeModalProps['textConfig'];\n onChange?: (value?: TreeModelSelectItem[]) => void;\n value?: TreeModelSelectItem[];\n treeProps?: TreeModalProps['treeProps'];\n}) => {\n const { selectQuantityPrompt, placeholder } = props.textConfig;\n const valueKey = props.fieldNames?.value || 'value';\n const childrenKey = props.fieldNames?.children || 'children';\n\n const chenkedIdList = props.value || [];\n\n return (\n <div style={{ height: '100%', overflow: 'auto' }}>\n <div style={{ backgroundColor: '#f4f4f4', padding: 10, borderRadius: 5 }}>\n <SelectContent\n treeProps={props.treeProps}\n value={chenkedIdList}\n onChange={props.onChange}\n fieldNames={props.fieldNames}\n serviceConfig={{\n onRequest: props.onRequest,\n onRequestResultAdapter: (respData) => {\n const listMap: TPlainObject = treeToTiledMap(respData, {\n value: valueKey,\n children: childrenKey,\n });\n props.onChangeDataSource?.(respData, listMap);\n return respData;\n },\n }}\n />\n </div>\n\n <div style={{ marginTop: 20 }}>\n <div style={{ fontSize: 15, fontWeight: '500', marginBottom: 10 }}>\n {chenkedIdList.length > 0 ? (\n <Fragment>\n {selectQuantityPrompt\n ? selectQuantityPrompt.replace('{total}', `${chenkedIdList?.length || ''}`)\n : `已选择${chenkedIdList?.length}`}\n </Fragment>\n ) : (\n placeholder\n )}\n </div>\n <SelectItemList\n chenkedIdList={chenkedIdList}\n fieldNames={props.fieldNames}\n onDeleteItem={props.onDeleteItem}\n />\n </div>\n </div>\n );\n};\n","import { isObject } from '@dimjs/lang';\nimport { isUndefinedOrNull, toArray, type TAny, type TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Fragment, useRef, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { HorizontalLayout } from './horizontal';\nimport type { TreeModalContentProps, TreeModelSelectItem } from './types';\nimport { VerticalLayout } from './vertical';\n\n/**\n * 树节点数据选择,一般用于选择员工等\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModalContent = (props: TreeModalContentProps) => {\n const { isMultiple } = props;\n const labelKey = props.fieldNames?.label || 'label';\n const valueKey = props.fieldNames?.value || 'value';\n const dataSourceMapRef = useRef<TPlainObject>({});\n\n const screenType = fbaHooks.useResponsivePoint() || '';\n\n const direction = screenType === 'xs' ? 'vertical' : 'horizontal';\n const isMultipleFt = isUndefinedOrNull(isMultiple) ? true : isMultiple;\n\n const [values, setValues] = useState<TreeModelSelectItem[]>();\n\n const onDeleteItem = (value) => {\n const targetList = values?.filter((item) => item.value !== value);\n setValues(targetList);\n props.onChange?.(targetList);\n };\n\n fbaHooks.useEffectCustom(() => {\n const values = toArray<TAny>(props.value).map((item) => {\n const target = isObject(item) ? item : { label: item, value: item };\n const value = target.value;\n return {\n value: value,\n label: dataSourceMapRef.current[value]?.[labelKey] || '',\n };\n });\n setValues(values);\n }, [props.value]);\n\n const treePropsFt = {\n ...props.treeProps,\n checkable: isMultipleFt ? true : false,\n };\n\n const onChange = (values?: TreeModelSelectItem[]) => {\n setValues(values);\n props.onChange?.(values);\n };\n\n const onChangeDataSource = hooks.useCallbackRef((treeDataList: TPlainObject[], mapData: TPlainObject) => {\n dataSourceMapRef.current = mapData;\n const result = values\n ?.map((item) => {\n const target = mapData[item.value];\n return target ? { label: target[labelKey], value: target[valueKey] } : undefined;\n })\n .filter(Boolean) as TreeModelSelectItem[];\n setValues(result);\n props.onDataSourceChange?.(treeDataList, mapData);\n });\n\n return (\n <Fragment>\n {direction === 'vertical' ? (\n <VerticalLayout\n value={values}\n onDeleteItem={onDeleteItem}\n fieldNames={props.fieldNames}\n onRequest={props.onRequest}\n textConfig={props.textConfig}\n onChange={onChange}\n onChangeDataSource={onChangeDataSource}\n treeProps={treePropsFt}\n ></VerticalLayout>\n ) : (\n <HorizontalLayout\n value={values}\n onDeleteItem={onDeleteItem}\n fieldNames={props.fieldNames}\n onRequest={props.onRequest}\n textConfig={props.textConfig}\n onChange={onChange}\n onChangeDataSource={onChangeDataSource}\n treeProps={treePropsFt}\n />\n )}\n </Fragment>\n );\n};\n","import type { TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { useSize } from 'ahooks';\nimport { Modal } from 'antd';\nimport { Fragment, useMemo, useRef, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { TreeModalContent } from './select-modal-content';\nimport type { TreeModalProps, TreeModelSelectItem } from './types';\n\n/**\n * 树节点数据选择,一般用于选择员工等\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModal = (props: TreeModalProps) => {\n const { size = 'large' } = props;\n const [isOpen, setIsOpen] = useState(false);\n\n const htmlSize = useSize(document.querySelector('html'));\n const screenType = fbaHooks.useResponsivePoint() || '';\n\n const direction = screenType === 'xs' ? 'vertical' : 'horizontal';\n\n const handleOnClick = hooks.useCallbackRef(() => {\n setIsOpen(true);\n });\n\n const Action = props.children.type;\n\n const [values, setValues] = useState<TreeModelSelectItem[]>();\n const originalValuesRef = useRef<TreeModelSelectItem[]>([]);\n\n const customSize = useMemo(() => {\n if (!htmlSize?.height || !screenType) return undefined;\n const isXsSm = ['xs', 'sm'].includes(screenType);\n let sizeCalculate: TPlainObject = {};\n if (size == 'large') {\n sizeCalculate = {\n height: htmlSize?.height * 0.65,\n width: 800,\n };\n } else if (size == 'small') {\n sizeCalculate = {\n height: htmlSize?.height * 0.45,\n width: 450,\n };\n } else if (size == 'middle') {\n sizeCalculate = {\n height: htmlSize?.height * 0.55,\n width: 600,\n };\n }\n\n return {\n height: props.modalBodyHeight || sizeCalculate.height,\n width: isXsSm ? '90%' : props.modalWidth || sizeCalculate.width,\n };\n }, [htmlSize?.height, screenType, size, props.modalBodyHeight, props.modalWidth]);\n\n const onSubmit = () => {\n props.onChange?.(values);\n setIsOpen(false);\n };\n\n const onCancel = () => {\n setIsOpen(false);\n setValues(originalValuesRef.current);\n };\n\n return (\n <Fragment>\n <Action {...props.children.props} onClick={handleOnClick} />\n <Modal\n className={props.modalClassName}\n title={props.textConfig.title || '选择'}\n open={isOpen}\n onCancel={onCancel}\n forceRender={props.forceRender}\n centered\n width={customSize?.width}\n onOk={onSubmit}\n styles={\n direction === 'horizontal'\n ? {\n body: {\n height: customSize?.height,\n maxHeight: 'calc(100vh - 200px)',\n padding: '0px 20px 0 20px',\n },\n content: {\n padding: 0,\n },\n header: {\n padding: '20px 24px 0 20px',\n },\n footer: {\n padding: '0 24px 20px 24px',\n },\n }\n : {\n body: {\n height: customSize?.height,\n },\n }\n }\n >\n <TreeModalContent\n {...props}\n onChange={(values) => {\n setValues(values);\n }}\n />\n </Modal>\n </Fragment>\n );\n};\n","import { attachPropertiesToComponent } from '@flatbiz/utils';\nimport { TreeModal as TreeModalInner } from './select-modal';\nimport { TreeModalContent } from './select-modal-content';\n\nexport const TreeModal = attachPropertiesToComponent(TreeModalInner, {\n Content: TreeModalContent,\n});\n"],"names":["SelectItemList","props","chenkedIdList","_jsx","Fragment","children","map","item","value","label","CssNodeHover","style","paddingLeft","paddingRight","_jsxs","FlexLayout","fullIndex","direction","alignItems","fontSize","marginBottom","color","TextOverflow","text","position","zIndex","IconWrapper","_CloseOutlined","onClick","onDeleteItem","bind","size","margin","SelectContent","_props$treeProps","_props$value","modelKey","_hooks","useId","undefined","TreeWrapper","_extends","initRootExpand","showSearch","searchPlaceholder","checkable","checkableType","treeProps","showIcon","icon","fieldNames","labelInValue","serviceConfig","onChange","values","toArray","HorizontalLayout","_props$fieldNames","_props$fieldNames2","valueKey","childrenKey","_props$textConfig","textConfig","selectQuantityPrompt","placeholder","gap","height","overflow","backgroundColor","padding","borderRadius","onRequest","onRequestResultAdapter","respData","listMap","treeToTiledMap","onChangeDataSource","width","display","flexDirection","flexShrink","fontWeight","length","replace","flex","VerticalLayout","marginTop","TreeModalContent","isMultiple","labelKey","dataSourceMapRef","useRef","screenType","fbaHooks","useResponsivePoint","isMultipleFt","isUndefinedOrNull","_useState","useState","setValues","targetList","filter","useEffectCustom","_dataSourceMapRef$cur","target","_isObject","current","treePropsFt","useCallbackRef","treeDataList","mapData","result","Boolean","onDataSourceChange","TreeModal","_props$size","isOpen","setIsOpen","htmlSize","useSize","document","querySelector","handleOnClick","Action","type","_useState2","originalValuesRef","customSize","useMemo","isXsSm","includes","sizeCalculate","modalBodyHeight","modalWidth","onSubmit","onCancel","Modal","className","modalClassName","title","open","forceRender","centered","onOk","styles","body","maxHeight","content","header","footer","attachPropertiesToComponent","TreeModalInner","Content"],"mappings":";2qEASO,IAAMA,EAAiB,SAAjBA,EAAkBC,GAK7B,IAAMC,EAAgBD,EAAMC,cAC5B,OACEC,EAACC,EAAQ,CAAAC,SACNH,GAAAA,UAAAA,EAAAA,EAAeI,KAAI,SAACC,GACnB,IAAMC,EAAQD,EAAKC,MACnB,IAAMC,EAAQF,EAAKE,OAASD,EAE5B,OACEL,EAACO,EAAY,CAACC,MAAO,CAAEC,YAAa,EAAGC,aAAc,GAAIR,SACvDS,EAACC,EAAU,CACTC,UAAW,EACXC,UAAU,aACVN,MAAO,CACLO,WAAY,SACZC,SAAU,GACVC,aAAc,EACdC,MAAO,WACPhB,SAAA,CAEFF,EAACmB,EAAY,CAACC,KAAMd,IACpBN,EAAA,MAAA,CACEQ,MAAO,CACLa,SAAU,WACVC,OAAQ,EACRJ,MAAO,WACPhB,SAEFF,EAACuB,EAAW,CACVH,KAAMpB,EAAAwB,MACNC,QAAS3B,EAAM4B,aAAaC,KAAK,KAAMtB,GACvCuB,KAAK,QACLpB,MAAO,CAAEE,aAAc,EAAGmB,OAAQ,eAvBqBxB,OAgCzE,EC/CO,IAAMyB,EAAgB,SAAhBA,EAAiBhC,GAMxB,IAAAiC,EAAAC,EACJ,IAAMC,EAAWC,EAAMC,MAAMC,UAAW,qBACxC,OACEpC,EAACqC,EAAWC,EAAA,CACVC,eAAc,KACdC,WAAU,KACVC,kBAAkB,KAClBC,UAAW,KACXC,cAAc,KACV7C,EAAM8C,UAAS,CACnBC,UAAUd,EAAAjC,EAAM8C,YAANb,MAAAA,EAAiBe,KAAO,KAAO,MACzCzC,OAAK2B,EAAElC,EAAMO,QAAN2B,UAAAA,EAAAA,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AAA,CACPF,EAACwH,EAAMlF,EAAA,CAAA,EAAKxC,EAAMI,SAASJ,MAAK,CAAE2B,QAAS8F,KAC3CvH,EAACqI,EAAK,CACJC,UAAWxI,EAAMyI,eACjBC,MAAO1I,EAAM6D,WAAW6E,OAAS,KACjCC,KAAMxB,EACNmB,SAAUA,EACVM,YAAa5I,EAAM4I,YACnBC,SAAQ,KACRjE,MAAOkD,GAAAA,UAAAA,EAAAA,EAAYlD,MACnBkE,KAAMT,EACNU,OACE/H,IAAc,aACV,CACEgI,KAAM,CACJ/E,OAAQ6D,GAAAA,UAAAA,EAAAA,EAAY7D,OACpBgF,UAAW,sBACX7E,QAAS,mBAEX8E,QAAS,CACP9E,QAAS,GAEX+E,OAAQ,CACN/E,QAAS,oBAEXgF,OAAQ,CACNhF,QAAS,qBAGb,CACE4E,KAAM,CACJ/E,OAAQ6D,GAAAA,UAAAA,EAAAA,EAAY7D,SAG7B7D,SAEDF,EAACoF,EAAgB9C,KACXxC,EAAK,CACToD,SAAU,SAAVA,EAAWC,GACT6C,EAAU7C,EACZ,SAKV,MCjHa4D,EAAYoC,EAA4BC,EAAgB,CACnEC,QAASjE"}
@@ -18,5 +18,5 @@ import './../dropdown-menu-wrapper/index.css';
18
18
  import './../input-search-wrapper/index.css';
19
19
  import './index.css';
20
20
  /*! @flatjs/forge MIT @flatbiz/antd */
21
- import{a as e,_ as i}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as o}from"@wove/react/cjs/hooks";import{isObject as r}from"@dimjs/lang/cjs/is-object";import{isUndefinedOrNull as a,toArray as n}from"@flatbiz/utils";import{Select as t}from"antd";import{useRef as l,useState as s,useEffect as m}from"react";import{TreeModal as p}from"../tree-modal/index.js";import{jsx as d}from"react/jsx-runtime";import"ahooks";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"../flex-layout/index.js";import"@dimjs/utils/cjs/class-names";import"@ant-design/icons/es/icons/CloseOutlined";import"../css-node-hover/index.js";import"../icon-wrapper/index.js";import"@dimjs/lang/cjs/is-undefined";import"../text-overflow/index.js";import"@dimjs/lang/cjs/is-string";import"../tree-wrapper/index.js";import"@dimjs/model-react";import"@ant-design/icons/es/icons/CaretDownFilled";import"@ant-design/icons/es/icons/MoreOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/utils/cjs/get";import"@dimjs/model";import"../button-operate/index.js";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-promise";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-utils/index.js";import"../dropdown-menu-wrapper/index.js";import"@ant-design/icons/es/icons/ExclamationCircleFilled";import"../dialog-confirm/index.js";import"../dialog-modal/index.js";import"react-dom/client";import"@wove/react/cjs/create-ctx";import"../input-search-wrapper/index.js";import"../request-status/index.js";import"@dimjs/utils/cjs/tree";import"dequal";var u=["placeholder","maxTagCount","labelInValue"];var c=function c(j){var v,f;var g=j.placeholder,x=j.maxTagCount,h=j.labelInValue,b=e(j,u);var C=a(g)?"请选择":g;var w=l({});var y=((v=b.fieldNames)==null?void 0:v.label)||"label";var k=((f=b.fieldNames)==null?void 0:f.value)||"value";var F=s(),O=F[0],_=F[1];m((function(){var e;var i=((e=n(j.value))==null?void 0:e.map((function(e){var i;var o=r(e)?e:{label:e,value:e};return{value:o.value,label:((i=w.current[o.value])==null?void 0:i[y])||o.value}})))||[];_(i)}),[y,j.value]);var z=function e(i){var o=n(i).length?i:undefined;if(b.isMultiple==false){j.onChange==null||j.onChange(o==null?void 0:o[0])}else{j.onChange==null||j.onChange(o)}};var D=function e(i){_(i);if(h){z(i);return}z(i==null?void 0:i.map((function(e){return e.value})))};var I=function e(i){_(i);if(h){z(i);return}z(i==null?void 0:i.map((function(e){return e.value})))};var N=o.useCallbackRef((function(e,i){w.current=i;var o=O==null?void 0:O.map((function(e){var o=i[e.value];return o?{label:o[y],value:o[k]}:undefined})).filter(Boolean);_(o)}));return d(p,i({},b,{forceRender:true,onChange:I,onDataSourceChange:N,children:d(t,{labelInValue:true,style:{width:"100%"},placeholder:C,maxTagCount:x,mode:"multiple",open:false,value:O,onChange:D})}))};export{c as TreeModalSelector};
21
+ import{a as e,_ as i}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as o}from"@wove/react/cjs/hooks";import{isObject as r}from"@dimjs/lang/cjs/is-object";import{isUndefinedOrNull as a,toArray as n}from"@flatbiz/utils";import{Select as t,message as l}from"antd";import{useRef as s,useState as m,useEffect as u}from"react";import{TreeModal as d}from"../tree-modal/index.js";import{jsx as p}from"react/jsx-runtime";import"ahooks";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"../flex-layout/index.js";import"@dimjs/utils/cjs/class-names";import"@ant-design/icons/es/icons/CloseOutlined";import"../css-node-hover/index.js";import"../icon-wrapper/index.js";import"@dimjs/lang/cjs/is-undefined";import"../text-overflow/index.js";import"@dimjs/lang/cjs/is-string";import"../tree-wrapper/index.js";import"@dimjs/model-react";import"@dimjs/utils/cjs/array";import"@ant-design/icons/es/icons/CaretDownFilled";import"@ant-design/icons/es/icons/MoreOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/utils/cjs/get";import"@dimjs/model";import"../button-operate/index.js";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-promise";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-utils/index.js";import"../dropdown-menu-wrapper/index.js";import"@ant-design/icons/es/icons/ExclamationCircleFilled";import"../dialog-confirm/index.js";import"../dialog-modal/index.js";import"react-dom/client";import"@wove/react/cjs/create-ctx";import"../input-search-wrapper/index.js";import"../request-status/index.js";import"@dimjs/utils/cjs/tree";import"dequal";var c=["placeholder","maxTagCount","labelInValue","maxCount","overMaxCountMsg"];var j=function j(v){var f,g;var x=v.placeholder,h=v.maxTagCount,C=v.labelInValue,b=v.maxCount,y=v.overMaxCountMsg,w=e(v,c);var k=a(x)?"请选择":x;var M=s({});var F=((f=w.fieldNames)==null?void 0:f.label)||"label";var O=((g=w.fieldNames)==null?void 0:g.value)||"value";var _=m(),z=_[0],D=_[1];u((function(){var e;var i=((e=n(v.value))==null?void 0:e.map((function(e){var i;var o=r(e)?e:{label:e,value:e};return{value:o.value,label:((i=M.current[o.value])==null?void 0:i[F])||o.value}})))||[];D(i)}),[F,v.value]);var I=function e(i){var o=n(i).length?i:undefined;if(w.isMultiple==false){v.onChange==null||v.onChange(o==null?void 0:o[0])}else{if(o&&b!==undefined&&o.length>b){void l.error(y?y:"最多选择"+b+"项");return}v.onChange==null||v.onChange(o)}};var N=function e(i){D(i);if(C){I(i);return}I(i==null?void 0:i.map((function(e){return e.value})))};var T=function e(i){D(i);if(C){I(i);return}I(i==null?void 0:i.map((function(e){return e.value})))};var V=o.useCallbackRef((function(e,i){M.current=i;var o=z==null?void 0:z.map((function(e){var o=i[e.value];return o?{label:o[F],value:o[O]}:undefined})).filter(Boolean);D(o)}));return p(d,i({},w,{forceRender:true,onChange:T,onDataSourceChange:V,children:p(t,{labelInValue:true,style:{width:"100%"},placeholder:k,maxTagCount:h,mode:"multiple",open:false,value:z,onChange:N})}))};export{j as TreeModalSelector};
22
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/tree-modal-selector/selector.tsx"],"sourcesContent":["import { isObject } from '@dimjs/lang';\nimport { isUndefinedOrNull, toArray, type TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Select } from 'antd';\nimport { useEffect, useRef, useState } from 'react';\nimport { TreeModal } from '../tree-modal';\nimport type { TreeModalProps, TreeModelSelectItem } from '../tree-modal/types';\nexport type TreeModalSelectorProps = Omit<TreeModalProps, 'children' | 'forceRender' | 'onChange'> & {\n placeholder?: string;\n /**\n * 1. 可指定数量\n * 2. 可设置 responsive,一行自适应显示\n */\n maxTagCount?: number | 'responsive';\n /** 是否返回label+value模式 */\n labelInValue?: boolean;\n onChange?: (values?: TreeModelSelectItem[] | TreeModelSelectItem) => void;\n};\n\n/**\n * 树弹框选择器\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModalSelector = (props: TreeModalSelectorProps) => {\n const { placeholder, maxTagCount, labelInValue, ...otherProps } = props;\n const placeholderFt = isUndefinedOrNull(placeholder) ? '请选择' : placeholder;\n\n const dataSourceMapRef = useRef<TPlainObject>({});\n\n const labelKey = otherProps.fieldNames?.label || 'label';\n const valueKey = otherProps.fieldNames?.value || 'value';\n\n const [showValues, setShowValues] = useState<TreeModelSelectItem[]>();\n\n useEffect(() => {\n const dataList =\n toArray(props.value)?.map((item) => {\n const objItems = (isObject(item) ? item : { label: item, value: item }) as TreeModelSelectItem;\n return {\n value: objItems.value,\n label: dataSourceMapRef.current[objItems.value]?.[labelKey] || objItems.value,\n } as TreeModelSelectItem;\n }) || [];\n setShowValues(dataList);\n }, [labelKey, props.value]);\n\n const onInnerChange = (value: TreeModelSelectItem[]) => {\n const valueFt = toArray(value).length ? value : undefined;\n if (otherProps.isMultiple == false) {\n props.onChange?.(valueFt?.[0]);\n } else {\n props.onChange?.(valueFt);\n }\n };\n\n const onSelectChange = (value) => {\n setShowValues(value);\n if (labelInValue) {\n onInnerChange(value);\n return;\n }\n\n onInnerChange(value?.map((item) => item.value));\n };\n const treeModalChange = (value) => {\n setShowValues(value);\n if (labelInValue) {\n onInnerChange(value);\n return;\n }\n onInnerChange(value?.map((item) => item.value));\n };\n\n const onDataSourceChange = hooks.useCallbackRef((_treeDataList: TPlainObject[], mapData: TPlainObject) => {\n dataSourceMapRef.current = mapData;\n const result = showValues\n ?.map((item) => {\n const target = mapData[item.value];\n return target ? { label: target[labelKey], value: target[valueKey] } : undefined;\n })\n .filter(Boolean) as TreeModelSelectItem[];\n setShowValues(result);\n });\n\n return (\n <TreeModal\n {...otherProps}\n forceRender={true}\n onChange={treeModalChange}\n onDataSourceChange={onDataSourceChange}\n >\n <Select\n labelInValue\n style={{ width: '100%' }}\n placeholder={placeholderFt}\n maxTagCount={maxTagCount}\n mode=\"multiple\"\n open={false}\n value={showValues}\n onChange={onSelectChange}\n />\n </TreeModal>\n );\n};\n"],"names":["TreeModalSelector","props","_otherProps$fieldName","_otherProps$fieldName2","placeholder","maxTagCount","labelInValue","otherProps","_objectWithoutPropertiesLoose","_excluded","placeholderFt","isUndefinedOrNull","dataSourceMapRef","useRef","labelKey","fieldNames","label","valueKey","value","_useState","useState","showValues","setShowValues","useEffect","_toArray","dataList","toArray","map","item","_dataSourceMapRef$cur","objItems","_isObject","current","onInnerChange","valueFt","length","undefined","isMultiple","onChange","onSelectChange","treeModalChange","onDataSourceChange","_hooks","useCallbackRef","_treeDataList","mapData","result","target","filter","Boolean","_jsx","TreeModal","_extends","forceRender","children","Select","style","width","mode","open"],"mappings":";whEA0BaA,EAAoB,SAApBA,EAAqBC,GAAkC,IAAAC,EAAAC,EAClE,IAAQC,EAA0DH,EAA1DG,YAAaC,EAA6CJ,EAA7CI,YAAaC,EAAgCL,EAAhCK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Ae,EAAcf,GAAAA,UAAAA,EAAAA,EAAOS,KAAI,SAACC,GAAI,OAAKA,EAAKV,KAAK,MAG/C,IAAMuB,EAAqBC,EAAMC,gBAAe,SAACC,EAA+BC,GAC9EjC,EAAiBoB,QAAUa,EAC3B,IAAMC,EAASzB,GAAAA,UAAAA,EAAAA,EACXM,KAAI,SAACC,GACL,IAAMmB,EAASF,EAAQjB,EAAKV,OAC5B,OAAO6B,EAAS,CAAE/B,MAAO+B,EAAOjC,GAAWI,MAAO6B,EAAO9B,IAAcmB,SACzE,IACCY,OAAOC,SACV3B,EAAcwB,EAChB,IAEA,OACEI,EAACC,EAASC,KACJ7C,EAAU,CACd8C,YAAa,KACbf,SAAUE,EACVC,mBAAoBA,EAAmBa,SAEvCJ,EAACK,EAAM,CACLjD,aAAY,KACZkD,MAAO,CAAEC,MAAO,QAChBrD,YAAaM,EACbL,YAAaA,EACbqD,KAAK,WACLC,KAAM,MACNzC,MAAOG,EACPiB,SAAUC,MAIlB"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/tree-modal-selector/selector.tsx"],"sourcesContent":["import { isObject } from '@dimjs/lang';\nimport { isUndefinedOrNull, toArray, type TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { message, Select } from 'antd';\nimport { useEffect, useRef, useState } from 'react';\nimport { TreeModal } from '../tree-modal';\nimport type { TreeModalProps, TreeModelSelectItem } from '../tree-modal/types';\nexport type TreeModalSelectorProps = Omit<TreeModalProps, 'children' | 'forceRender' | 'onChange'> & {\n placeholder?: string;\n /**\n * 1. 可指定数量\n * 2. 可设置 responsive,一行自适应显示\n */\n maxTagCount?: number | 'responsive';\n /** 是否返回label+value模式 */\n labelInValue?: boolean;\n onChange?: (values?: TreeModelSelectItem[] | TreeModelSelectItem) => void;\n\n /** 最大选择数量 */\n maxCount?: number;\n /** 超过最大选择数量提示文本 */\n overMaxCountMsg?: string;\n};\n\n/**\n * 树弹框选择器\n * ```\n * 1. 可通过 treeProps.checkableType 配置多选节点模式(包括返回所有节点、只返回叶子节点、叶子节点&父节点全选只返回父节点),默认只返回叶子节点\n * 2. demo: https://fex.qa.tcshuke.com/docs/admin/main/selector/tree\n * ```\n */\nexport const TreeModalSelector = (props: TreeModalSelectorProps) => {\n const { placeholder, maxTagCount, labelInValue, maxCount, overMaxCountMsg, ...otherProps } = props;\n const placeholderFt = isUndefinedOrNull(placeholder) ? '请选择' : placeholder;\n\n const dataSourceMapRef = useRef<TPlainObject>({});\n\n const labelKey = otherProps.fieldNames?.label || 'label';\n const valueKey = otherProps.fieldNames?.value || 'value';\n\n const [showValues, setShowValues] = useState<TreeModelSelectItem[]>();\n\n useEffect(() => {\n const dataList =\n toArray(props.value)?.map((item) => {\n const objItems = (isObject(item) ? item : { label: item, value: item }) as TreeModelSelectItem;\n return {\n value: objItems.value,\n label: dataSourceMapRef.current[objItems.value]?.[labelKey] || objItems.value,\n } as TreeModelSelectItem;\n }) || [];\n setShowValues(dataList);\n }, [labelKey, props.value]);\n\n const onInnerChange = (value: TreeModelSelectItem[]) => {\n const valueFt = toArray(value).length ? value : undefined;\n if (otherProps.isMultiple == false) {\n props.onChange?.(valueFt?.[0]);\n } else {\n if (valueFt && maxCount !== undefined && valueFt.length > maxCount) {\n void message.error(overMaxCountMsg ? overMaxCountMsg : `最多选择${maxCount}项`);\n return;\n }\n\n props.onChange?.(valueFt);\n }\n };\n\n const onSelectChange = (value) => {\n setShowValues(value);\n if (labelInValue) {\n onInnerChange(value);\n return;\n }\n\n onInnerChange(value?.map((item) => item.value));\n };\n const treeModalChange = (value) => {\n setShowValues(value);\n if (labelInValue) {\n onInnerChange(value);\n return;\n }\n onInnerChange(value?.map((item) => item.value));\n };\n\n const onDataSourceChange = hooks.useCallbackRef((_treeDataList: TPlainObject[], mapData: TPlainObject) => {\n dataSourceMapRef.current = mapData;\n const result = showValues\n ?.map((item) => {\n const target = mapData[item.value];\n return target ? { label: target[labelKey], value: target[valueKey] } : undefined;\n })\n .filter(Boolean) as TreeModelSelectItem[];\n setShowValues(result);\n });\n\n return (\n <TreeModal\n {...otherProps}\n forceRender={true}\n onChange={treeModalChange}\n onDataSourceChange={onDataSourceChange}\n >\n <Select\n labelInValue\n style={{ width: '100%' }}\n placeholder={placeholderFt}\n maxTagCount={maxTagCount}\n mode=\"multiple\"\n open={false}\n value={showValues}\n onChange={onSelectChange}\n />\n </TreeModal>\n );\n};\n"],"names":["TreeModalSelector","props","_otherProps$fieldName","_otherProps$fieldName2","placeholder","maxTagCount","labelInValue","maxCount","overMaxCountMsg","otherProps","_objectWithoutPropertiesLoose","_excluded","placeholderFt","isUndefinedOrNull","dataSourceMapRef","useRef","labelKey","fieldNames","label","valueKey","value","_useState","useState","showValues","setShowValues","useEffect","_toArray","dataList","toArray","map","item","_dataSourceMapRef$cur","objItems","_isObject","current","onInnerChange","valueFt","length","undefined","isMultiple","onChange","message","error","onSelectChange","treeModalChange","onDataSourceChange","_hooks","useCallbackRef","_treeDataList","mapData","result","target","filter","Boolean","_jsx","TreeModal","_extends","forceRender","children","Select","style","width","mode","open"],"mappings":";imEA+BaA,EAAoB,SAApBA,EAAqBC,GAAkC,IAAAC,EAAAC,EAClE,IAAQC,EAAqFH,EAArFG,YAAaC,EAAwEJ,EAAxEI,YAAaC,EAA2DL,EAA3DK,aAAcC,EAA6CN,EAA7CM,SAAUC,EAAmCP,EAAnCO,gBAAoBC,EAAUC,EAAKT,EAAKU,GAClG,IAAMC,EAAgBC,EAAkBT,GAAe,MAAQA,EAE/D,IAAMU,EAAmBC,EAAqB,CAAA,GAE9C,IAAMC,IAAWd,EAAAO,EAAWQ,aAAXf,UAAAA,EAAAA,EAAuBgB,QAAS,QACjD,IAAMC,IAAWhB,EAAAM,EAAWQ,aAAXd,UAAAA,EAAAA,EAAuBiB,QAAS,QAEjD,IAAAC,EAAoCC,IAA7BC,EAAUF,EAAA,GAAEG,EAAaH,EAAA,GAEhCI,GAAU,WAAM,IAAAC,EACd,IAAMC,IACJD,EAAAE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5B,OAAO+B,EAAS,CAAEjC,MAAOiC,EAAOnC,GAAWI,MAAO+B,EAAOhC,IAAcmB,SACzE,IACCc,OAAOC,SACV7B,EAAc0B,EAChB,IAEA,OACEI,EAACC,EAASC,KACJ/C,EAAU,CACdgD,YAAa,KACbjB,SAAUI,EACVC,mBAAoBA,EAAmBa,SAEvCJ,EAACK,EAAM,CACLrD,aAAY,KACZsD,MAAO,CAAEC,MAAO,QAChBzD,YAAaQ,EACbP,YAAaA,EACbyD,KAAK,WACLC,KAAM,MACN3C,MAAOG,EACPiB,SAAUG,MAIlB"}
@@ -3,5 +3,5 @@ import './../fba-hooks/index.css';
3
3
  import './../request-status/index.css';
4
4
  import './index.css';
5
5
  /*! @flatjs/forge MIT @flatbiz/antd */
6
- import e from"@ant-design/icons/es/icons/RedoOutlined";import{classNames as r}from"@dimjs/utils/cjs/class-names";import t from"@ant-design/icons/es/icons/CaretDownFilled";import{extend as l}from"@dimjs/utils/cjs/extend";import{hooks as a}from"@wove/react/cjs/hooks";import{isArray as n}from"@dimjs/lang/cjs/is-array";import{get as i}from"@dimjs/utils/cjs/get";import{isObject as o}from"@dimjs/lang/cjs/is-object";import{a as u,_ as s}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{toArray as c,treeToTiledMap as f,isNotEmptyArray as d,treeToArray as v,isUndefinedOrNull as p}from"@flatbiz/utils";import{TreeSelect as m,Button as h}from"antd";import{dequal as S}from"dequal";import{useState as g,useRef as b,useMemo as C,createElement as y}from"react";import{fbaHooks as q}from"../fba-hooks/index.js";import{RequestStatus as w}from"../request-status/index.js";import{Model as L}from"@dimjs/model-react";import{jsx as T}from"react/jsx-runtime";import"../use-responsive-point-21b8c601.js";var R={treeSelectorList:[],treeSelectorTiledMap:{},queryIsEmpty:false};var j={actions:{setSelectBoxList:function e(r){return function(e){e.treeSelectorList=r.treeSelectorList||[];e.treeSelectorTiledMap=r.treeSelectorTiledMap||{};e.requestStatus="request-success"}},resetSelectBoxList:function e(){return function(e){e.treeSelectorList=[];e.treeSelectorTiledMap={}}},changeRequestStatus:function e(r){return function(e){e.requestStatus=r}}},state:R};var k={};var x=function e(r){if(!k[r]){k[r]=L(j)}return k[r]};var M=function e(r,t){var l=[];var a=t[r];while(a){var n=a.pId;a=t[n];if(a){l.push(n)}}return l};var E=function e(r,t){if(r.length===0)return[];var l=[];r.forEach((function(e){var r=M(e,t);l.push.apply(l,r)}));return Array.from(new Set(l))};var I=["serviceConfig","effectDependencyList","onTreeSelectorListChange","onTreeSelectorRequestError","treeSelectorList","requestMessageConfig","modelKey","value","labelInValue","labelInValueFieldNames","onTreeItemDataAdapter","selectedParentCheckedAllChildrenList","fieldNames","onChange","treeDefaultExpandAll","showAllOption","initRootExpand","treeDefaultExpandedKeys"];var A=function L(R){var j=R.serviceConfig,k=R.effectDependencyList,M=R.onTreeSelectorListChange,A=R.onTreeSelectorRequestError,N=R.treeSelectorList,D=R.requestMessageConfig,P=R.modelKey,O=R.value,B=R.labelInValue,K=R.labelInValueFieldNames,V=R.onTreeItemDataAdapter,F=R.selectedParentCheckedAllChildrenList,H=F===void 0?true:F,W=R.fieldNames,_=R.onChange,z=R.treeDefaultExpandAll,G=R.showAllOption,J=R.initRootExpand,Q=R.treeDefaultExpandedKeys,U=u(R,I);var X=Object.prototype.hasOwnProperty.call(R,"treeSelectorList");var Y=j||{};var Z=k||[];var $=q.useSafeState(false),ee=$[0],re=$[1];var te=g(),le=te[0],ae=te[1];var ne=x(P).useStore(),ie=ne[0],oe=ne[1];var ue="request-progress-"+P;var se=U.treeCheckable||U.multiple;var ce=b(true);var fe=C((function(){if(U.treeCheckStrictly)return true;return B}),[B,U.treeCheckStrictly]);var de=C((function(){return s({label:"label",value:"value",children:"children",disabled:"disabled"},W)}),[W]);var ve=C((function(){return s({label:"label",value:"value"},K)}),[K]);var pe=C((function(){if(G){var e=G===true;return{label:e?"全部":G.label,value:e?"":G.value}}return null}),[G]);var me=g(),he=me[0],Se=me[1];var ge=C((function(){return c(R.value).map((function(e){if(o(e)){return fe?e[ve.value]:e[de.value]}return e}))}),[de.value,fe,ve.value,R.value]);q.useEffectCustom((function(){if(ie.treeSelectorList.length>0){var e=[];if(ce.current){ce.current=false;if(Q){e=Q}else if(z){var r=Object.keys(ie.treeSelectorTiledMap).map((function(e){var r;return(r=ie.treeSelectorTiledMap[e])==null?void 0:r[de.value]}));e=r}else if(J&&ie.treeSelectorList.length===1){e=[ie.treeSelectorList[0][de.value]]}ae(e)}else{if(!he){var t=E(ge,ie.treeSelectorTiledMap);ae(t)}}}}),[O,ie.treeSelectorList]);var be=function e(r){return r===""||p(r)};var Ce=function e(r){var t=r;if(Y.onRequestResultAdapter){t=Y.onRequestResultAdapter(r)}else if(de.list){t=i(r,de.list)}if(t&&!n(t)){console.warn("待渲染数据为非数组结构",t);return[]}return t||[]};var ye=a.useCallbackRef((function(){return new Promise((function(e,r){var t,a,n,i,o;if(!Y.onRequest){return r(new Error("onRequest 调用接口服务不能为空"))}t=Y.requiredParamsKeys||[];a=l({},Y.params);n=t.find((function(e){return be(a[e])}));if(n){void oe.changeRequestStatus("no-dependencies-params");console.warn("TreeSelectorWrapper组件:参数:"+t.join("、")+"不能为空");return e()}var u=function(){try{return e()}catch(e){return r(e)}};var s=function(e){try{re(false);window[ue]=false;void oe.changeRequestStatus("request-error");A==null||A(e);return u()}catch(e){return r(e)}};try{re(true);window[ue]=true;void oe.changeRequestStatus("request-progress");return Promise.resolve(Y.onRequest==null?void 0:Y.onRequest(a)).then((function(e){try{i=e;o=Ce(i);re(false);window[ue]=false;qe(o||[]);return u()}catch(e){return s(e)}}),s)}catch(e){s(e)}}))}));a.useCustomCompareEffect((function(){if(X)return;if(Z.length){qe([]);void ye();return}var e=x(P).getState();if(e.requestStatus==="request-success"){return}if(!window[ue]){void ye();return}}),Z,S);var qe=a.useCallbackRef((function(e){var r;if((e==null?void 0:e.length)===0&&ie.treeSelectorList.length===0){void oe.setSelectBoxList({treeSelectorList:[],treeSelectorTiledMap:{}});M==null||M([]);return}var t=pe?(r={},r[de.label]=pe.label,r[de.value]=pe.value,r):undefined;var l=G?[t].concat(e):e;void oe.setSelectBoxList({treeSelectorList:l,treeSelectorTiledMap:f(l,{value:de.value,children:de.children},"pId")});M==null||M(e)}));q.useEffectCustom((function(){if(X){qe(N||[])}}),[N]);var we=a.useCallbackRef((function(e){ae(e)}));var Le=a.useCallbackRef((function(){void ye()}));var Te=a.useCallbackRef((function(e,r,t){var l=c(e);if(U.treeCheckStrictly){if(H&&t.checked){var a=ie.treeSelectorTiledMap[t==null?void 0:t.triggerValue];if(d(a[de.children])){l=v([a],de.children).map((function(e){return e[de.value]}))}else{l=e==null?void 0:e.map((function(e){return e.value}))}}else{l=e==null?void 0:e.map((function(e){return e.value}))}}if(fe){var n=l.map((function(e){var r;var t=ie.treeSelectorTiledMap[e];return r={},r[ve.label]=t[de.label],r[ve.value]=t[de.value],r}));if(se){_==null||_(n,n,t)}else{_==null||_(n[0],n[0],t)}}else{var i=l.map((function(e){return ie.treeSelectorTiledMap[e]}));if(se){_==null||_(l,i,t)}else{_==null||_(l[0],i[0],t)}}}));var Re=a.useCallbackRef((function(e){if(!e)return null;return e.map((function(e){var r=(V==null?void 0:V(s({},e)))||e;var t=r[de.children];var l=r[de.value];var a=r[de.label];var n=r[de.disabled]?r[de.disabled]:r.disabled;return y(m.TreeNode,s({},r,{disabled:n,value:l,title:a,key:""+l}),t&&t.length>0&&Re(t))}))}));var je=function e(r){Se(r);var t=[];if(!r){Se(undefined);t=ge}else{Object.keys(ie.treeSelectorTiledMap).forEach((function(e){var l=ie.treeSelectorTiledMap[e];var a=l==null?void 0:l[de.label];if(a!=null&&a.includes(r)){t.push(l[de.value])}}))}var l=E(t,ie.treeSelectorTiledMap);ae(l)};var ke=se?ge:ge[0];return T(m,s({searchValue:he,dropdownStyle:{maxHeight:400,overflow:"auto"},showSearch:true,treeLine:{showLeafIcon:false},treeNodeFilterProp:"title",switcherIcon:T(t,{}),popupMatchSelectWidth:false},U,{className:r("v-tree-select-wrapper",U.className),popupClassName:r("v-tree-select-wrapper-dropdown",U.popupClassName),onChange:Te,treeExpandedKeys:le,value:ke,onSearch:je,loading:ee,onTreeExpand:we,style:s({width:"100%"},U.style),suffixIcon:ie.requestStatus==="request-error"?T(e,{spin:ee,onClick:Le}):undefined,notFoundContent:T(w,{status:ie.requestStatus,messageConfig:D,loading:ee,errorButton:T(h,{type:"primary",onClick:Le,children:"重新获取数据"})}),children:Re(ie.treeSelectorList)}))};export{A as TreeSelectorWrapper};
6
+ import e from"@ant-design/icons/es/icons/RedoOutlined";import{classNames as r}from"@dimjs/utils/cjs/class-names";import t from"@ant-design/icons/es/icons/CaretDownFilled";import{extend as n}from"@dimjs/utils/cjs/extend";import{hooks as l}from"@wove/react/cjs/hooks";import{isArray as a}from"@dimjs/lang/cjs/is-array";import{get as i}from"@dimjs/utils/cjs/get";import{isObject as o}from"@dimjs/lang/cjs/is-object";import{a as u,_ as s}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{toArray as c,treeToTiledMap as f,isNotEmptyArray as d,treeToArray as v,isUndefinedOrNull as p}from"@flatbiz/utils";import{usePrevious as m}from"ahooks";import{TreeSelect as h,Button as S}from"antd";import{dequal as g}from"dequal";import{useState as C,useRef as b,useMemo as y,createElement as q}from"react";import{fbaHooks as L}from"../fba-hooks/index.js";import{RequestStatus as w}from"../request-status/index.js";import{Model as R}from"@dimjs/model-react";import{jsx as T}from"react/jsx-runtime";import"../use-responsive-point-21b8c601.js";var j={treeSelectorList:[],treeSelectorTiledMap:{},queryIsEmpty:false};var k={actions:{setSelectBoxList:function e(r){return function(e){e.treeSelectorList=r.treeSelectorList||[];e.treeSelectorTiledMap=r.treeSelectorTiledMap||{};e.requestStatus="request-success"}},resetSelectBoxList:function e(){return function(e){e.treeSelectorList=[];e.treeSelectorTiledMap={}}},changeRequestStatus:function e(r){return function(e){e.requestStatus=r}}},state:j};var x={};var M=function e(r){if(!x[r]){x[r]=R(k)}return x[r]};var E=function e(r,t){var n=[];var l=t[r];while(l){var a=l.pId;l=t[a];if(l){n.push(a)}}return n};var I=function e(r,t){if(r.length===0)return[];var n=[];r.forEach((function(e){var r=E(e,t);n.push.apply(n,r)}));return Array.from(new Set(n))};var N=["serviceConfig","effectDependencyList","onTreeSelectorListChange","onTreeSelectorRequestError","treeSelectorList","requestMessageConfig","modelKey","value","labelInValue","labelInValueFieldNames","onTreeItemDataAdapter","selectedParentCheckedAllChildrenList","fieldNames","onChange","treeDefaultExpandAll","showAllOption","initRootExpand","treeDefaultExpandedKeys","executeOnChangeInRenderFirstValue"];var A=function R(j){var k=j.serviceConfig,x=j.effectDependencyList,E=j.onTreeSelectorListChange,A=j.onTreeSelectorRequestError,O=j.treeSelectorList,D=j.requestMessageConfig,P=j.modelKey,V=j.value,F=j.labelInValue,B=j.labelInValueFieldNames,K=j.onTreeItemDataAdapter,H=j.selectedParentCheckedAllChildrenList,J=H===void 0?true:H,W=j.fieldNames,_=j.onChange,z=j.treeDefaultExpandAll,G=j.showAllOption,Q=j.initRootExpand,U=j.treeDefaultExpandedKeys,X=j.executeOnChangeInRenderFirstValue,Y=u(j,N);var Z=Object.prototype.hasOwnProperty.call(j,"treeSelectorList");var $=k||{};var ee=x||[];var re=L.useSafeState(false),te=re[0],ne=re[1];var le=C(),ae=le[0],ie=le[1];var oe=M(P).useStore(),ue=oe[0],se=oe[1];var ce="request-progress-"+P;var fe=Y.treeCheckable||Y.multiple;var de=b(true);var ve=y((function(){if(Y.treeCheckStrictly)return true;return F}),[F,Y.treeCheckStrictly]);var pe=y((function(){return s({label:"label",value:"value",children:"children",disabled:"disabled"},W)}),[W]);var me=y((function(){return s({label:"label",value:"value"},B)}),[B]);var he=y((function(){if(G){var e=G===true;return{label:e?"全部":G.label,value:e?"":G.value}}return null}),[G]);var Se=C(),ge=Se[0],Ce=Se[1];var be=L.useMemoCustom((function(){return c(V).map((function(e){if(o(e)){return ve?e[me.value]:e[pe.value]}return e}))}),[pe.value,ve,me.value,j.value]);var ye=m(be);L.useEffectCustom((function(){if(ue.treeSelectorList.length>0){if(de.current&&X&&ve){var e=[];var r=[];be.forEach((function(t){var n=ue.treeSelectorTiledMap[t];if(n){var l;r.push(n);e.push((l={},l[me.label]=n[pe.label],l[me.value]=n[pe.value],l))}}));if(fe){j.onChange==null||j.onChange(e?e:undefined,r)}else{j.onChange==null||j.onChange(e?e[0]:undefined,r[0])}}var t=[];if(de.current){de.current=false;if(U){t=U}else if(z){var n=Object.keys(ue.treeSelectorTiledMap).map((function(e){var r;return(r=ue.treeSelectorTiledMap[e])==null?void 0:r[pe.value]}));t=n}else if(Q&&ue.treeSelectorList.length===1){t=[ue.treeSelectorList[0][pe.value]]}ie(t)}}}),[be,ue.treeSelectorList]);L.useEffectCustom((function(){if(!de.current&&be.length>0){if(ue.treeSelectorList.length>0&&JSON.stringify(be)!==JSON.stringify(ye)){if(!ge){var e=I(be,ue.treeSelectorTiledMap);ie(e)}}}}),[be,ue.treeSelectorList]);var qe=function e(r){return r===""||p(r)};var Le=function e(r){var t=r;if($.onRequestResultAdapter){t=$.onRequestResultAdapter(r)}else if(pe.list){t=i(r,pe.list)}if(t&&!a(t)){console.warn("待渲染数据为非数组结构",t);return[]}return t||[]};var we=l.useCallbackRef((function(){return new Promise((function(e,r){var t,l,a,i,o;if(!$.onRequest){return r(new Error("onRequest 调用接口服务不能为空"))}t=$.requiredParamsKeys||[];l=n({},$.params);a=t.find((function(e){return qe(l[e])}));if(a){void se.changeRequestStatus("no-dependencies-params");console.warn("TreeSelectorWrapper组件:参数:"+t.join("、")+"不能为空");return e()}var u=function(){try{return e()}catch(e){return r(e)}};var s=function(e){try{ne(false);window[ce]=false;void se.changeRequestStatus("request-error");A==null||A(e);return u()}catch(e){return r(e)}};try{ne(true);window[ce]=true;void se.changeRequestStatus("request-progress");return Promise.resolve($.onRequest==null?void 0:$.onRequest(l)).then((function(e){try{i=e;o=Le(i);ne(false);window[ce]=false;Re(o||[]);return u()}catch(e){return s(e)}}),s)}catch(e){s(e)}}))}));l.useCustomCompareEffect((function(){if(Z)return;if(ee.length){Re([]);void we();return}var e=M(P).getState();if(e.requestStatus==="request-success"){return}if(!window[ce]){void we();return}}),ee,g);var Re=l.useCallbackRef((function(e){var r;if((e==null?void 0:e.length)===0&&ue.treeSelectorList.length===0){void se.setSelectBoxList({treeSelectorList:[],treeSelectorTiledMap:{}});E==null||E([]);return}var t=he?(r={},r[pe.label]=he.label,r[pe.value]=he.value,r):undefined;var n=G?[t].concat(e):e;void se.setSelectBoxList({treeSelectorList:n,treeSelectorTiledMap:f(n,{value:pe.value,children:pe.children},"pId")});E==null||E(e)}));L.useEffectCustom((function(){if(Z){Re(O||[])}}),[O]);var Te=l.useCallbackRef((function(e){ie(e)}));var je=l.useCallbackRef((function(){void we()}));var ke=l.useCallbackRef((function(e,r,t){var n=c(e);if(Y.treeCheckStrictly){if(J&&t.checked){var l=ue.treeSelectorTiledMap[t==null?void 0:t.triggerValue];if(d(l[pe.children])){n=v([l],pe.children).map((function(e){return e[pe.value]}))}else{n=e==null?void 0:e.map((function(e){return e.value}))}}else{n=e==null?void 0:e.map((function(e){return e.value}))}}if(ve){var a=n.map((function(e){var r;var t=ue.treeSelectorTiledMap[e];return r={},r[me.label]=t[pe.label],r[me.value]=t[pe.value],r}));if(fe){_==null||_(a,a,t)}else{_==null||_(a[0],a[0],t)}}else{var i=n.map((function(e){return ue.treeSelectorTiledMap[e]}));if(fe){_==null||_(n,i,t)}else{_==null||_(n[0],i[0],t)}}}));var xe=l.useCallbackRef((function(e){if(!e)return null;return e.map((function(e){var r=(K==null?void 0:K(s({},e)))||e;var t=r[pe.children];var n=r[pe.value];var l=r[pe.label];var a=r[pe.disabled]?r[pe.disabled]:r.disabled;return q(h.TreeNode,s({},r,{disabled:a,value:n,title:l,key:""+n}),t&&t.length>0&&xe(t))}))}));var Me=function e(r){Ce(r);var t=[];if(!r){Ce(undefined);t=be}else{Object.keys(ue.treeSelectorTiledMap).forEach((function(e){var n=ue.treeSelectorTiledMap[e];var l=n==null?void 0:n[pe.label];if(l!=null&&l.includes(r)){t.push(n[pe.value])}}))}var n=I(t,ue.treeSelectorTiledMap);ie(n)};var Ee=fe?be:be[0];return T(h,s({searchValue:ge,dropdownStyle:{maxHeight:400,overflow:"auto"},showSearch:true,treeLine:{showLeafIcon:false},treeNodeFilterProp:"title",switcherIcon:T(t,{}),popupMatchSelectWidth:false},Y,{className:r("v-tree-select-wrapper",Y.className),popupClassName:r("v-tree-select-wrapper-dropdown",Y.popupClassName),onChange:ke,treeExpandedKeys:ae,value:Ee,onSearch:Me,loading:te,onTreeExpand:Te,style:s({width:"100%"},Y.style),suffixIcon:ue.requestStatus==="request-error"?T(e,{spin:te,onClick:je}):undefined,notFoundContent:T(w,{status:ue.requestStatus,messageConfig:D,loading:te,errorButton:T(S,{type:"primary",onClick:je,children:"重新获取数据"})}),children:xe(ue.treeSelectorList)}))};export{A as TreeSelectorWrapper};
7
7
  //# sourceMappingURL=index.js.map