@flatbiz/antd 4.2.45 → 4.2.46

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.
package/esm/index.js CHANGED
@@ -64,6 +64,7 @@ import './selector-wrapper-search/index.css';
64
64
  import './selector-wrapper-simple/index.css';
65
65
  import './sms-count-down/index.css';
66
66
  import './styles/index.css';
67
+ import './switch-confirm-wrapper/index.css';
67
68
  import './switch-wrapper/index.css';
68
69
  import './table-cell-render/index.css';
69
70
  import './tag-list-select/index.css';
@@ -79,5 +80,5 @@ import './tree-selector-wrapper/index.css';
79
80
  import './tree-wrapper/index.css';
80
81
  import './index.css';
81
82
  /*! @flatjs/forge MIT @flatbiz/antd */
82
- export{A as AnchorSteps}from"./anchor-steps-616cd173.js";export{a as ButtonOperate,B as ButtonOperateItemContent}from"./button-operate-37069516.js";export{B as ButtonWrapper}from"./button-wrapper-e833e139.js";export{C as CascaderWrapper}from"./cascader-wrapper-db4a5382.js";export{CheckList}from"./check-list/index.js";export{C as CheckboxWrapper}from"./checkbox-wrapper-018a5c59.js";export{C as ConfigProviderWrapper}from"./config-provider-wrapper-dfe8f592.js";export{createDrawerWrapperModel}from"./create-drawer-wrapper-model/index.js";export{createModalWrapperModel}from"./create-modal-wrapper-model/index.js";export{C as CssNodeHover}from"./css-node-hover-ed7b9860.js";export{D as DataRender}from"./data-render-07c0ab6b.js";export{D as DatePickerWrapper}from"./date-picker-wrapper-ba650858.js";export{D as DateRangePickerWrapper}from"./date-range-picker-wrapper-fb15c592.js";export{D as DateRangePickerWrapperFormItem}from"./date-range-picker-wrapper-form-item-688cf465.js";export{d as dialogAlert}from"./dialog-alert-23b4a533.js";export{d as dialogConfirm}from"./dialog-confirm-2656caad.js";export{d as dialogDrawer}from"./dialog-drawer-a741961f.js";export{d as dialogLoading}from"./dialog-loading-16bd1baa.js";export{d as dialogModal}from"./dialog-modal-7b705b44.js";export{D as DrawerWrapper}from"./drawer-wrapper-9af2f178.js";export{D as DropdownMenuWrapper}from"./dropdown-menu-wrapper-3544d20e.js";export{d as dynamicNode}from"./dynamic-node-c7864af4.js";export{EasyTable}from"./easy-table/index.js";export{E as EditableField}from"./editable-field-7f30db8e.js";export{E as EditableFieldProvider}from"./editable-field-provider-20963c3e.js";export{E as EditableTable}from"./editable-table-2446a059.js";export{E as EditorWrapper}from"./editor-wrapper-ff6e75b7.js";export{fbaHooks}from"./fba-hooks/index.js";export{f as fbaUtils}from"./fba-utils-1e895394.js";export{F as FileImport}from"./file-import-890a1df9.js";export{F as FlexLayout}from"./flex-layout-8d2b668b.js";export{FormGrid}from"./form-grid/index.js";export{FormItemGroup}from"./form-item-group/index.js";export{F as FormItemHidden}from"./form-item-hidden-45541774.js";export{F as FormItemWrapper}from"./form-item-wrapper-dfe2ebd9.js";export{G as Gap}from"./gap-284e1f59.js";export{I as IconWrapper}from"./icon-wrapper-ed5fcacc.js";export{I as InputSearchWrapper}from"./input-search-wrapper-10d4a9b9.js";export{I as InputTextAreaWrapper}from"./input-text-area-wrapper-c958fba0.js";export{I as InputWrapper}from"./input-wrapper-b378eb5a.js";export{L as LabelValueLayout}from"./label-value-layout-beb35b0d.js";export{LocalLoading}from"./local-loading/index.js";export{M as ModalAction}from"./modal-action-5c5ca8a7.js";export{M as ModalWrapper}from"./modal-wrapper-ff8df98b.js";export{P as PageFixedFooter}from"./page-fixed-footer-9ec2b46c.js";export{P as Page404}from"./page404-f087129a.js";export{P as Permission}from"./permission-a1c99455.js";export{preDefinedClassName}from"./pre-defined-class-name/index.js";export{R as RadioGroupWrapper}from"./radio-group-wrapper-b34746d1.js";export{R as RelationTree}from"./relation-tree-7bec12bd.js";export{R as RequestStatus}from"./request-status-03fc60e2.js";export{R as RichTextEditor}from"./rich-text-editor-c8bac6d2.js";export{R as RichTextViewer}from"./rich-text-viewer-3bf4569a.js";export{R as RollLocationCenter}from"./center-a4dfda6f.js";export{R as RollLocationInView}from"./in-view-448ba714.js";export{R as RuleDescribe}from"./rule-describe-b4a8e831.js";export{S as SelectorWrapper}from"./selector-wrapper-dc08cc44.js";export{S as SelectorWrapperSearch}from"./selector-wrapper-search-f799bcf0.js";export{S as SelectorWrapperSimple}from"./selector-wrapper-simple-7b34f7bd.js";export{S as SimpleLayout}from"./simple-layout-1cd0fefc.js";export{S as SmsCountDown}from"./sms-count-down-c2609386.js";export{styles}from"./styles/index.js";export{S as SwitchWrapper}from"./switch-wrapper-f20b9a58.js";export{t as tableCellRender}from"./cell-render-61a5922f.js";export{T as TableScrollbar}from"./table-scrollbar-66c1682c.js";export{T as TableTitleTooltip}from"./title-render-2874a932.js";export{T as TabsWrapper}from"./tabs-wrapper-675dc949.js";export{T as TagGroup}from"./tag-group-4fbcaa14.js";export{T as TagListSelect}from"./tag-list-select-066f682f.js";export{T as TagWrapper}from"./tag-wrapper-6d8b505e.js";export{T as TextOverflowRender}from"./text-overflow-render-2ec38800.js";export{T as TimePickerWrapper}from"./time-picker-wrapper-f1d26d96.js";export{T as TimeRangePickerWrapper}from"./time-range-picker-wrapper-be9850b5.js";export{T as TimeRangePickerWrapperFormItem}from"./time-range-picker-wrapper-form-item-9df6c0f4.js";export{T as TreeSelectorWrapper}from"./tree-selector-wrapper-9cd9da23.js";export{TreeWrapper}from"./tree-wrapper/index.js";export{U as UploadWrapper}from"./upload-wrapper-df8a2277.js";import"@dimjs/utils/cjs/class-names";import"@flatbiz/antd";import"antd";import"react";import"react/jsx-runtime";import"@ant-design/icons/es/icons/MoreOutlined";import"./_rollupPluginBabelHelpers-1f4d8910.js";import"@dimjs/lang/cjs/is-undefined";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@ant-design/icons/es/icons/LoadingOutlined";import"@flatbiz/utils";import"@ant-design/icons/es/icons/RedoOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/model";import"@dimjs/model-react";import"@wove/react/cjs/create-ctx";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"./time-53b3f55f.js";import"@dimjs/lang/cjs/is-array";import"react-dom/client";import"./dom-4d04aa64.js";import"ahooks";import"@ant-design/icons/es/icons/SaveOutlined";import"@ant-design/icons/es/icons/DownOutlined";import"@ant-design/icons/es/icons/UpOutlined";import"react-is";import"@ant-design/icons/es/icons/CloseOutlined";import"@ant-design/icons/es/icons/CheckOutlined";import"@dimjs/lang/cjs/is-number";import"@ant-design/icons/es/icons/EditOutlined";import"./context-25d0b686.js";import"@ant-design/icons/es/icons/PlusOutlined";import"@dimjs/lang/cjs/is-boolean";import"@ant-design/icons/es/icons/DeleteOutlined";import"@wove/react/cjs/editor";import"./use-responsive-point-21b8c601.js";import"@dimjs/lang/cjs/is-deep-equal";import"@tinymce/tinymce-react";import"@ant-design/icons/es/icons/PlusCircleOutlined";import"@ant-design/icons/es/icons/FullscreenOutlined";import"@dimjs/utils/cjs/get";import"@dimjs/utils/cjs/json";import"pubsub-js";import"@dimjs/lang/cjs/is-object";import"@dimjs/lang/cjs/is-empty";import"@ant-design/icons/es/icons/QuestionCircleOutlined";import"dayjs/plugin/isSameOrAfter";import"dayjs/plugin/isSameOrBefore";import"@ant-design/icons/es/icons/CaretDownFilled";import"dequal";import"@dimjs/utils/cjs/tree";import"react-dom";
83
+ export{A as AnchorSteps}from"./anchor-steps-616cd173.js";export{a as ButtonOperate,B as ButtonOperateItemContent}from"./button-operate-37069516.js";export{B as ButtonWrapper}from"./button-wrapper-e833e139.js";export{C as CascaderWrapper}from"./cascader-wrapper-db4a5382.js";export{CheckList}from"./check-list/index.js";export{C as CheckboxWrapper}from"./checkbox-wrapper-018a5c59.js";export{C as ConfigProviderWrapper}from"./config-provider-wrapper-dfe8f592.js";export{createDrawerWrapperModel}from"./create-drawer-wrapper-model/index.js";export{createModalWrapperModel}from"./create-modal-wrapper-model/index.js";export{C as CssNodeHover}from"./css-node-hover-ed7b9860.js";export{D as DataRender}from"./data-render-07c0ab6b.js";export{D as DatePickerWrapper}from"./date-picker-wrapper-ba650858.js";export{D as DateRangePickerWrapper}from"./date-range-picker-wrapper-fb15c592.js";export{D as DateRangePickerWrapperFormItem}from"./date-range-picker-wrapper-form-item-688cf465.js";export{d as dialogAlert}from"./dialog-alert-23b4a533.js";export{d as dialogConfirm}from"./dialog-confirm-2656caad.js";export{d as dialogDrawer}from"./dialog-drawer-a741961f.js";export{d as dialogLoading}from"./dialog-loading-16bd1baa.js";export{d as dialogModal}from"./dialog-modal-7b705b44.js";export{D as DrawerWrapper}from"./drawer-wrapper-9af2f178.js";export{D as DropdownMenuWrapper}from"./dropdown-menu-wrapper-3544d20e.js";export{d as dynamicNode}from"./dynamic-node-c7864af4.js";export{EasyTable}from"./easy-table/index.js";export{E as EditableField}from"./editable-field-7f30db8e.js";export{E as EditableFieldProvider}from"./editable-field-provider-20963c3e.js";export{E as EditableTable}from"./editable-table-2446a059.js";export{E as EditorWrapper}from"./editor-wrapper-ff6e75b7.js";export{fbaHooks}from"./fba-hooks/index.js";export{f as fbaUtils}from"./fba-utils-1e895394.js";export{F as FileImport}from"./file-import-890a1df9.js";export{F as FlexLayout}from"./flex-layout-8d2b668b.js";export{FormGrid}from"./form-grid/index.js";export{FormItemGroup}from"./form-item-group/index.js";export{F as FormItemHidden}from"./form-item-hidden-45541774.js";export{F as FormItemWrapper}from"./form-item-wrapper-dfe2ebd9.js";export{G as Gap}from"./gap-284e1f59.js";export{I as IconWrapper}from"./icon-wrapper-ed5fcacc.js";export{I as InputSearchWrapper}from"./input-search-wrapper-10d4a9b9.js";export{I as InputTextAreaWrapper}from"./input-text-area-wrapper-c958fba0.js";export{I as InputWrapper}from"./input-wrapper-b378eb5a.js";export{L as LabelValueLayout}from"./label-value-layout-beb35b0d.js";export{LocalLoading}from"./local-loading/index.js";export{M as ModalAction}from"./modal-action-5c5ca8a7.js";export{M as ModalWrapper}from"./modal-wrapper-ff8df98b.js";export{P as PageFixedFooter}from"./page-fixed-footer-9ec2b46c.js";export{P as Page404}from"./page404-f087129a.js";export{P as Permission}from"./permission-a1c99455.js";export{preDefinedClassName}from"./pre-defined-class-name/index.js";export{R as RadioGroupWrapper}from"./radio-group-wrapper-b34746d1.js";export{R as RelationTree}from"./relation-tree-7bec12bd.js";export{R as RequestStatus}from"./request-status-03fc60e2.js";export{R as RichTextEditor}from"./rich-text-editor-c8bac6d2.js";export{R as RichTextViewer}from"./rich-text-viewer-3bf4569a.js";export{R as RollLocationCenter}from"./center-a4dfda6f.js";export{R as RollLocationInView}from"./in-view-448ba714.js";export{R as RuleDescribe}from"./rule-describe-b4a8e831.js";export{S as SelectorWrapper}from"./selector-wrapper-dc08cc44.js";export{S as SelectorWrapperSearch}from"./selector-wrapper-search-f799bcf0.js";export{S as SelectorWrapperSimple}from"./selector-wrapper-simple-7b34f7bd.js";export{S as SimpleLayout}from"./simple-layout-1cd0fefc.js";export{S as SmsCountDown}from"./sms-count-down-c2609386.js";export{styles}from"./styles/index.js";export{S as SwitchConfirmWrapper}from"./switch-confirm-wrapper-4857f2a9.js";export{S as SwitchWrapper}from"./switch-wrapper-f20b9a58.js";export{t as tableCellRender}from"./cell-render-61a5922f.js";export{T as TableScrollbar}from"./table-scrollbar-66c1682c.js";export{T as TableTitleTooltip}from"./title-render-2874a932.js";export{T as TabsWrapper}from"./tabs-wrapper-675dc949.js";export{T as TagGroup}from"./tag-group-4fbcaa14.js";export{T as TagListSelect}from"./tag-list-select-066f682f.js";export{T as TagWrapper}from"./tag-wrapper-6d8b505e.js";export{T as TextOverflowRender}from"./text-overflow-render-2ec38800.js";export{T as TimePickerWrapper}from"./time-picker-wrapper-f1d26d96.js";export{T as TimeRangePickerWrapper}from"./time-range-picker-wrapper-be9850b5.js";export{T as TimeRangePickerWrapperFormItem}from"./time-range-picker-wrapper-form-item-9df6c0f4.js";export{T as TreeSelectorWrapper}from"./tree-selector-wrapper-9cd9da23.js";export{TreeWrapper}from"./tree-wrapper/index.js";export{U as UploadWrapper}from"./upload-wrapper-df8a2277.js";import"@dimjs/utils/cjs/class-names";import"@flatbiz/antd";import"antd";import"react";import"react/jsx-runtime";import"@ant-design/icons/es/icons/MoreOutlined";import"./_rollupPluginBabelHelpers-1f4d8910.js";import"@dimjs/lang/cjs/is-undefined";import"@dimjs/lang/cjs/is-plain-object";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@ant-design/icons/es/icons/LoadingOutlined";import"@flatbiz/utils";import"@ant-design/icons/es/icons/RedoOutlined";import"@dimjs/utils/cjs/extend";import"@dimjs/model";import"@dimjs/model-react";import"@wove/react/cjs/create-ctx";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"./time-53b3f55f.js";import"@dimjs/lang/cjs/is-array";import"react-dom/client";import"./dom-4d04aa64.js";import"ahooks";import"@ant-design/icons/es/icons/SaveOutlined";import"@ant-design/icons/es/icons/DownOutlined";import"@ant-design/icons/es/icons/UpOutlined";import"react-is";import"@ant-design/icons/es/icons/CloseOutlined";import"@ant-design/icons/es/icons/CheckOutlined";import"@dimjs/lang/cjs/is-number";import"@ant-design/icons/es/icons/EditOutlined";import"./context-25d0b686.js";import"@ant-design/icons/es/icons/PlusOutlined";import"@dimjs/lang/cjs/is-boolean";import"@ant-design/icons/es/icons/DeleteOutlined";import"@wove/react/cjs/editor";import"./use-responsive-point-21b8c601.js";import"@dimjs/lang/cjs/is-deep-equal";import"@tinymce/tinymce-react";import"@ant-design/icons/es/icons/PlusCircleOutlined";import"@ant-design/icons/es/icons/FullscreenOutlined";import"@dimjs/utils/cjs/get";import"@dimjs/utils/cjs/json";import"pubsub-js";import"@dimjs/lang/cjs/is-object";import"@dimjs/lang/cjs/is-empty";import"@ant-design/icons/es/icons/QuestionCircleOutlined";import"dayjs/plugin/isSameOrAfter";import"dayjs/plugin/isSameOrBefore";import"@ant-design/icons/es/icons/CaretDownFilled";import"dequal";import"@dimjs/utils/cjs/tree";import"react-dom";
83
84
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/local-loading/context.ts","@flatbiz/antd/src/local-loading/local-loading.tsx","@flatbiz/antd/src/local-loading/index.ts"],"sourcesContent":["import { TPlainObject } from '@flatbiz/utils';\nimport { createCtx } from '@wove/react';\n\nexport const [useLocalLoadingCtx, LocalLoadingCtxProvider] = createCtx<{\n onRequest: (params?: TPlainObject) => void;\n}>();\n","import { isDeepEqual } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\nimport { TAny, toArray, TPlainObject } from '@flatbiz/utils';\nimport { Button, Result, Spin } from 'antd';\nimport {\n CSSProperties,\n forwardRef,\n ReactElement,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { dynamicNode } from '../dynamic-node';\nimport { fbaHooks } from '../fba-hooks';\nimport { LocalLoadingCtxProvider } from './context';\nimport './style.less';\n\nexport type LocalLoadingServiceConfig = {\n onRequest: (params?: TAny) => Promise<TPlainObject>;\n params?: TPlainObject;\n /** 标记serviceConfig.params中无效参数,被设置的params key 不传入服务接口入参 */\n invalidParamKey?: string[];\n};\n\nexport interface LocalLoadingProps {\n /** 接口数据配置 */\n serviceConfig: LocalLoadingServiceConfig;\n /** children 为函数,参数【respData】为接口返回数据 */\n children: (respData?: TAny) => ReactElement;\n /**\n * 是否异步,默认:false\n * ```\n * true(异步):onRequest、react dom渲染同步执行\n * false(同步):onRequest有结果了才渲染 react dom\n * ```\n */\n isAsync?: boolean;\n /** 自定义异常渲染处理 */\n errorRender?: (error?: TAny) => ReactElement;\n /** loading高度,默认值:100;isAsync = true 无效 */\n loadingHeight?: number;\n className?: string;\n style?: CSSProperties;\n contentStyle?: CSSProperties;\n}\n\nexport type LocalLoadingRefApi = {\n onRefresh: (params?: TPlainObject) => void;\n};\n\n/**\n * 局部加载,包含接口数据处理逻辑\n * ```\n * 包括\n * 1. loading显示效果\n * 2. error显示效果\n * 3. 获取服务数据\n * 4. 当 serviceConfig.params 值与上一次值不相等时,会主动发起服务调用\n * ```\n * @param props\n * @returns\n */\nexport const LocalLoadingInner = forwardRef<LocalLoadingRefApi, LocalLoadingProps>((props, ref) => {\n const { serviceConfig, isAsync, children, errorRender } = props;\n const [status, setStatus] = useState<'success' | 'error' | 'init'>('init');\n const [respData, setRespData] = useState<TAny>();\n const loadingHeight = props.loadingHeight === undefined ? 100 : props.loadingHeight;\n const rootRef = useRef<HTMLDivElement>(null);\n const loadingKeyRef = useRef<string>();\n const errorRef = useRef<string>();\n\n const prevParams = fbaHooks.usePrevious(serviceConfig.params);\n\n // 用于直接发起接口调用,不能用于比较\n const serviceParams = useMemo(() => {\n if (!serviceConfig.params || toArray(serviceConfig.invalidParamKey).length === 0) {\n return serviceConfig.params;\n }\n const newParams = { ...serviceConfig.params };\n serviceConfig.invalidParamKey?.forEach((key) => {\n newParams[key] = undefined;\n });\n return newParams;\n }, [serviceConfig]);\n\n const openLoading = () => {\n errorRef.current = undefined;\n loadingKeyRef.current = dynamicNode.append({\n content: <Spin spinning={true}></Spin>,\n getContainer: () => {\n return rootRef.current as HTMLElement;\n },\n }).elementId;\n };\n\n const closeLoading = () => {\n dynamicNode.remove(loadingKeyRef.current);\n };\n\n const onInitRequest = async (params?: TPlainObject) => {\n try {\n openLoading();\n const respData = await serviceConfig.onRequest({\n ...serviceParams,\n ...params,\n });\n setStatus('success');\n setRespData(respData);\n } catch (error) {\n console.error(error);\n setStatus('error');\n errorRef.current = error.message;\n } finally {\n closeLoading();\n }\n };\n\n fbaHooks.useEffectCustomAsync(onInitRequest, []);\n\n fbaHooks.useEffectCustom(() => {\n if (prevParams) {\n if (!isDeepEqual(serviceConfig.params, prevParams)) {\n void onInitRequest();\n }\n }\n }, [prevParams, serviceConfig.params]);\n\n useImperativeHandle(ref, () => {\n return { onRefresh: onInitRequest };\n });\n\n if (status === 'error') {\n if (errorRender) {\n return errorRender(respData);\n }\n return (\n <LocalLoadingCtxProvider value={{ onRequest: onInitRequest }}>\n <div className=\"local-loading-error\">\n <div className=\"local-loading-area\" ref={rootRef}></div>\n <Result\n status=\"error\"\n subTitle={errorRef.current || '数据处理异常'}\n extra={[\n <Button\n type=\"primary\"\n ghost\n key=\"console\"\n size=\"small\"\n onClick={() => {\n setStatus('init');\n setTimeout(() => {\n void onInitRequest();\n }, 100);\n }}\n >\n 重新获取\n </Button>,\n ]}\n />\n </div>\n </LocalLoadingCtxProvider>\n );\n }\n\n if (status !== 'success' && !isAsync) {\n return (\n <div\n className=\"fba-local-loading-process\"\n style={{\n height: loadingHeight,\n display: 'flex',\n justifyContent: 'center',\n position: 'relative',\n backgroundColor: '#fff',\n }}\n >\n <div className=\"local-loading-area\" ref={rootRef}></div>\n </div>\n );\n }\n\n return (\n <LocalLoadingCtxProvider value={{ onRequest: onInitRequest }}>\n <div className={classNames('fba-local-loading', props.className)} style={props.style}>\n <div className=\"local-loading-area\" ref={rootRef}></div>\n <div className=\"local-loading-content\" style={props.contentStyle}>\n {children(respData)}\n </div>\n </div>\n </LocalLoadingCtxProvider>\n );\n});\n","import { TPlainObject } from '@flatbiz/utils';\nimport { fbaUtils } from '../fba-utils';\nimport { useLocalLoadingCtx } from './context';\nimport { LocalLoadingInner } from './local-loading';\n\n/**\n * 局部加载,包含接口数据处理逻辑\n * ```\n * 包括\n * 1. loading显示效果\n * 2. error显示效果\n * 3. 获取服务数据\n * 4. 当 serviceConfig.params 值与上一次值不相等时,会主动发起服务调用\n * ```\n */\nexport const LocalLoading = fbaUtils.attachPropertiesToComponent(LocalLoadingInner, {\n useLocalLoading: () => {\n const ctx = useLocalLoadingCtx();\n return {\n onRequest: (params?: TPlainObject) => {\n ctx.onRequest(params);\n },\n };\n },\n});\n"],"names":["_createCtx","_createCtx2","useLocalLoadingCtx","LocalLoadingCtxProvider","LocalLoadingInner","forwardRef","props","ref","serviceConfig","isAsync","children","errorRender","_useState","useState","status","setStatus","_useState2","respData","setRespData","loadingHeight","undefined","rootRef","useRef","loadingKeyRef","errorRef","prevParams","fbaHooks","usePrevious","params","serviceParams","useMemo","_serviceConfig$invali","toArray","invalidParamKey","length","newParams","_extends","forEach","key","openLoading","current","dynamicNode","append","content","_jsx","Spin","spinning","getContainer","elementId","closeLoading","remove","onInitRequest","Promise","$return","$error","$Try_1_Finally","$Try_1_Exit","$Try_1_Value","call","this","$boundEx","bind","_respData","$Try_1_Post","$Try_1_Catch","error","console","message","resolve","onRequest","then","$await_2","useEffectCustomAsync","useEffectCustom","_isDeepEqual","useImperativeHandle","onRefresh","value","_jsxs","className","Result","subTitle","extra","Button","type","ghost","size","onClick","setTimeout","style","height","display","justifyContent","position","backgroundColor","_classNames","contentStyle","LocalLoading","fbaUtils","attachPropertiesToComponent","useLocalLoading","ctx"],"mappings":";owBAGO,IAAAA,EAAsDC,IAA/CC,EAAkBF,EAAA,GAAEG,EAAuBH,EAAA,GC4DlD,IAAMI,EAAoBC,GAAkD,SAACC,EAAOC,GACzF,IAAQC,EAAkDF,EAAlDE,cAAeC,EAAmCH,EAAnCG,QAASC,EAA0BJ,EAA1BI,SAAUC,EAAgBL,EAAhBK,YAC1C,IAAAC,EAA4BC,EAAuC,QAA5DC,EAAMF,EAAA,GAAEG,EAASH,EAAA,GACxB,IAAAI,EAAgCH,IAAzBI,EAAQD,EAAA,GAAEE,EAAWF,EAAA,GAC5B,IAAMG,EAAgBb,EAAMa,gBAAkBC,UAAY,IAAMd,EAAMa,cACtE,IAAME,EAAUC,EAAuB,MACvC,IAAMC,EAAgB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EAAA,MAAA,CAAKC,UAAWgB,EAAW,oBAAqBzF,EAAMyE,WAAYU,MAAOnF,EAAMmF,MAAM/E,UACnFkC,EAAA,MAAA,CAAKmC,UAAU,qBAAqBxE,IAAKc,IACzCuB,EAAA,MAAA,CAAKmC,UAAU,wBAAwBU,MAAOnF,EAAM0F,aAAatF,SAC9DA,EAASO,SAKpB,ICjLO,IAAMgF,EAAeC,EAASC,4BAA4B/F,EAAmB,CAClFgG,gBAAiB,SAAAA,IACf,IAAMC,EAAMnG,IACZ,MAAO,CACLmE,UAAW,SAAAA,EAACzC,GACVyE,EAAIhC,UAAUzC,EAChB,EAEJ"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/local-loading/context.ts","@flatbiz/antd/src/local-loading/local-loading.tsx","@flatbiz/antd/src/local-loading/index.ts"],"sourcesContent":["import { TPlainObject } from '@flatbiz/utils';\nimport { createCtx } from '@wove/react';\n\nexport const [useLocalLoadingCtx, LocalLoadingCtxProvider] = createCtx<{\n onRequest: (params?: TPlainObject) => void;\n}>();\n","import { isDeepEqual } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\nimport { TAny, toArray, TPlainObject } from '@flatbiz/utils';\nimport { Button, Result, Spin } from 'antd';\nimport {\n CSSProperties,\n forwardRef,\n ReactElement,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { dynamicNode } from '../dynamic-node';\nimport { fbaHooks } from '../fba-hooks';\nimport { LocalLoadingCtxProvider } from './context';\nimport './style.less';\n\nexport type LocalLoadingServiceConfig = {\n onRequest: (params?: TAny) => Promise<TPlainObject>;\n params?: TPlainObject;\n /** 标记serviceConfig.params中无效参数,被设置的params key 不传入服务接口入参 */\n invalidParamKey?: string[];\n};\n\nexport interface LocalLoadingProps {\n /** 接口数据配置 */\n serviceConfig: LocalLoadingServiceConfig;\n /** children 为函数,参数【respData】为接口返回数据 */\n children: (respData?: TAny) => ReactElement;\n /**\n * 是否异步,默认:false\n * ```\n * true(异步):onRequest、react dom渲染同步执行\n * false(同步):onRequest有结果了才渲染 react dom\n * ```\n */\n isAsync?: boolean;\n /** 自定义异常渲染处理 */\n errorRender?: (error?: TAny) => ReactElement;\n /** loading高度,默认值:100;isAsync = true 无效 */\n loadingHeight?: number | string;\n className?: string;\n style?: CSSProperties;\n contentStyle?: CSSProperties;\n}\n\nexport type LocalLoadingRefApi = {\n onRefresh: (params?: TPlainObject) => void;\n};\n\n/**\n * 局部加载,包含接口数据处理逻辑\n * ```\n * 包括\n * 1. loading显示效果\n * 2. error显示效果\n * 3. 获取服务数据\n * 4. 当 serviceConfig.params 值与上一次值不相等时,会主动发起服务调用\n * ```\n * @param props\n * @returns\n */\nexport const LocalLoadingInner = forwardRef<LocalLoadingRefApi, LocalLoadingProps>((props, ref) => {\n const { serviceConfig, isAsync, children, errorRender } = props;\n const [status, setStatus] = useState<'success' | 'error' | 'init'>('init');\n const [respData, setRespData] = useState<TAny>();\n const loadingHeight = props.loadingHeight === undefined ? 100 : props.loadingHeight;\n const rootRef = useRef<HTMLDivElement>(null);\n const loadingKeyRef = useRef<string>();\n const errorRef = useRef<string>();\n\n const prevParams = fbaHooks.usePrevious(serviceConfig.params);\n\n // 用于直接发起接口调用,不能用于比较\n const serviceParams = useMemo(() => {\n if (!serviceConfig.params || toArray(serviceConfig.invalidParamKey).length === 0) {\n return serviceConfig.params;\n }\n const newParams = { ...serviceConfig.params };\n serviceConfig.invalidParamKey?.forEach((key) => {\n newParams[key] = undefined;\n });\n return newParams;\n }, [serviceConfig]);\n\n const openLoading = () => {\n errorRef.current = undefined;\n loadingKeyRef.current = dynamicNode.append({\n content: <Spin spinning={true}></Spin>,\n getContainer: () => {\n return rootRef.current as HTMLElement;\n },\n }).elementId;\n };\n\n const closeLoading = () => {\n dynamicNode.remove(loadingKeyRef.current);\n };\n\n const onInitRequest = async (params?: TPlainObject) => {\n try {\n openLoading();\n const respData = await serviceConfig.onRequest({\n ...serviceParams,\n ...params,\n });\n setStatus('success');\n setRespData(respData);\n } catch (error) {\n console.error(error);\n setStatus('error');\n errorRef.current = error.message;\n } finally {\n closeLoading();\n }\n };\n\n fbaHooks.useEffectCustomAsync(onInitRequest, []);\n\n fbaHooks.useEffectCustom(() => {\n if (prevParams) {\n if (!isDeepEqual(serviceConfig.params, prevParams)) {\n void onInitRequest();\n }\n }\n }, [prevParams, serviceConfig.params]);\n\n useImperativeHandle(ref, () => {\n return { onRefresh: onInitRequest };\n });\n\n if (status === 'error') {\n if (errorRender) {\n return errorRender(respData);\n }\n return (\n <LocalLoadingCtxProvider value={{ onRequest: onInitRequest }}>\n <div className=\"local-loading-error\">\n <div className=\"local-loading-area\" ref={rootRef}></div>\n <Result\n status=\"error\"\n subTitle={errorRef.current || '数据处理异常'}\n extra={[\n <Button\n type=\"primary\"\n ghost\n key=\"console\"\n size=\"small\"\n onClick={() => {\n setStatus('init');\n setTimeout(() => {\n void onInitRequest();\n }, 100);\n }}\n >\n 重新获取\n </Button>,\n ]}\n />\n </div>\n </LocalLoadingCtxProvider>\n );\n }\n\n if (status !== 'success' && !isAsync) {\n return (\n <div\n className=\"fba-local-loading-process\"\n style={{\n height: loadingHeight,\n display: 'flex',\n justifyContent: 'center',\n position: 'relative',\n backgroundColor: '#fff',\n }}\n >\n <div className=\"local-loading-area\" ref={rootRef}></div>\n </div>\n );\n }\n\n return (\n <LocalLoadingCtxProvider value={{ onRequest: onInitRequest }}>\n <div className={classNames('fba-local-loading', props.className)} style={props.style}>\n <div className=\"local-loading-area\" ref={rootRef}></div>\n <div className=\"local-loading-content\" style={props.contentStyle}>\n {children(respData)}\n </div>\n </div>\n </LocalLoadingCtxProvider>\n );\n});\n","import { TPlainObject } from '@flatbiz/utils';\nimport { fbaUtils } from '../fba-utils';\nimport { useLocalLoadingCtx } from './context';\nimport { LocalLoadingInner } from './local-loading';\n\n/**\n * 局部加载,包含接口数据处理逻辑\n * ```\n * 包括\n * 1. loading显示效果\n * 2. error显示效果\n * 3. 获取服务数据\n * 4. 当 serviceConfig.params 值与上一次值不相等时,会主动发起服务调用\n * ```\n */\nexport const LocalLoading = fbaUtils.attachPropertiesToComponent(LocalLoadingInner, {\n useLocalLoading: () => {\n const ctx = useLocalLoadingCtx();\n return {\n onRequest: (params?: TPlainObject) => {\n ctx.onRequest(params);\n },\n };\n },\n});\n"],"names":["_createCtx","_createCtx2","useLocalLoadingCtx","LocalLoadingCtxProvider","LocalLoadingInner","forwardRef","props","ref","serviceConfig","isAsync","children","errorRender","_useState","useState","status","setStatus","_useState2","respData","setRespData","loadingHeight","undefined","rootRef","useRef","loadingKeyRef","errorRef","prevParams","fbaHooks","usePrevious","params","serviceParams","useMemo","_serviceConfig$invali","toArray","invalidParamKey","length","newParams","_extends","forEach","key","openLoading","current","dynamicNode","append","content","_jsx","Spin","spinning","getContainer","elementId","closeLoading","remove","onInitRequest","Promise","$return","$error","$Try_1_Finally","$Try_1_Exit","$Try_1_Value","call","this","$boundEx","bind","_respData","$Try_1_Post","$Try_1_Catch","error","console","message","resolve","onRequest","then","$await_2","useEffectCustomAsync","useEffectCustom","_isDeepEqual","useImperativeHandle","onRefresh","value","_jsxs","className","Result","subTitle","extra","Button","type","ghost","size","onClick","setTimeout","style","height","display","justifyContent","position","backgroundColor","_classNames","contentStyle","LocalLoading","fbaUtils","attachPropertiesToComponent","useLocalLoading","ctx"],"mappings":";owBAGO,IAAAA,EAAsDC,IAA/CC,EAAkBF,EAAA,GAAEG,EAAuBH,EAAA,GC4DlD,IAAMI,EAAoBC,GAAkD,SAACC,EAAOC,GACzF,IAAQC,EAAkDF,EAAlDE,cAAeC,EAAmCH,EAAnCG,QAASC,EAA0BJ,EAA1BI,SAAUC,EAAgBL,EAAhBK,YAC1C,IAAAC,EAA4BC,EAAuC,QAA5DC,EAAMF,EAAA,GAAEG,EAASH,EAAA,GACxB,IAAAI,EAAgCH,IAAzBI,EAAQD,EAAA,GAAEE,EAAWF,EAAA,GAC5B,IAAMG,EAAgBb,EAAMa,gBAAkBC,UAAY,IAA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,EAAuB,CAAC0E,MAAO,CAAER,UAAWlB,GAAgBzC,SAC3DoE,EAAA,MAAA,CAAKC,UAAWgB,EAAW,oBAAqBzF,EAAMyE,WAAYU,MAAOnF,EAAMmF,MAAM/E,UACnFkC,EAAA,MAAA,CAAKmC,UAAU,qBAAqBxE,IAAKc,IACzCuB,EAAA,MAAA,CAAKmC,UAAU,wBAAwBU,MAAOnF,EAAM0F,aAAatF,SAC9DA,EAASO,SAKpB,ICjLO,IAAMgF,EAAeC,EAASC,4BAA4B/F,EAAmB,CAClFgG,gBAAiB,SAAAA,IACf,IAAMC,EAAMnG,IACZ,MAAO,CACLmE,UAAW,SAAAA,EAACzC,GACVyE,EAAIhC,UAAUzC,EAChB,EAEJ"}
File without changes
@@ -0,0 +1,5 @@
1
+ /* eslint-disable */
2
+ import './index.css';
3
+ /*! @flatjs/forge MIT @flatbiz/antd */
4
+ export{S as SwitchConfirmWrapper}from"../switch-confirm-wrapper-4857f2a9.js";import"../_rollupPluginBabelHelpers-1f4d8910.js";import"@wove/react/cjs/hooks";import"antd";import"react";import"react/jsx-runtime";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,3 @@
1
+ /*! @flatjs/forge MIT @flatbiz/antd */
2
+ import{_ as e,a as r}from"./_rollupPluginBabelHelpers-1f4d8910.js";import{hooks as n}from"@wove/react/cjs/hooks";import{message as o,Popconfirm as t,Switch as i}from"antd";import{useState as a,useMemo as u}from"react";import{jsx as l}from"react/jsx-runtime";var s=["popConfirmProps","needConfirm","checkedValue","unCheckedValue","onChange","value","serviceConfig","noMessage"];var c=function c(d){var f=d.popConfirmProps,v=d.needConfirm,h=d.checkedValue,m=d.unCheckedValue,p=d.onChange,g=d.value,C=d.serviceConfig,k=d.noMessage,b=e(d,s);var P=f||{},y=P.description,V=P.title,j=P.disabled;var R=a(g===h),q=R[0],w=R[1];var x=a(false),B=x[0],M=x[1];var _=u((function(){return v==="close"&&q||v==="open"&&!q||!v||v==="all"}),[q,v]);var E=n.useCallbackRef((function(){return new Promise((function(e,r){var n,t,i;n=!q?h:m;if(C!=null&&C.onRequest){var a=function(e){return function(n){try{M(false);return e&&e.call(this,n)}catch(e){return r(e)}}.bind(this)}.bind(this);var u=function(){try{return s.call(this)}catch(e){return r(e)}}.bind(this);var l=function(e){try{if(!k){void o.error((e==null?void 0:e.message)||(C==null?void 0:(i=C.message)==null?void 0:i.defaultError)||"状态修改失败!")}return a(u)()}catch(e){return a(r)(e)}};try{M(true);return Promise.resolve(C.onRequest(n)).then((function(e){try{w(!q);p==null?void 0:p(n);if(!k){void o.success((C==null?void 0:(t=C.message)==null?void 0:t.success)||"状态修改成功!")}return a(u)()}catch(e){return l(e)}}),l)}catch(e){l(e)}}else{w(!q);p==null?void 0:p(n);return s.call(this)}function s(){return e()}}))}));if(_){return l(t,{disabled:j,okButtonProps:{loading:B},title:V,description:y,onConfirm:E,children:l(i,r({checked:q},b))})}return l(i,r({checked:q,loading:B},b,{onChange:E}))};export{c as S};
3
+ //# sourceMappingURL=switch-confirm-wrapper-4857f2a9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-confirm-wrapper-4857f2a9.js","sources":["@flatbiz/antd/src/switch-confirm-wrapper/switch-confirm-wrapper.tsx"],"sourcesContent":["import { TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { message, Popconfirm, PopconfirmProps, Switch, SwitchProps } from 'antd';\nimport { useMemo, useState } from 'react';\n\nexport type SwitchConfirmWrapperValue = string | number | boolean;\nexport type SwitchConfirmWrapperProps = Omit<SwitchProps, 'defaultChecked' | 'onChange'> & {\n value?: SwitchConfirmWrapperValue;\n checkedValue: SwitchConfirmWrapperValue;\n unCheckedValue: SwitchConfirmWrapperValue;\n needConfirm?: 'close' | 'open' | 'all' | 'none';\n noMessage?: boolean;\n onChange?: (value: SwitchConfirmWrapperValue) => void;\n popConfirmProps?: Pick<PopconfirmProps, 'disabled' | 'title' | 'description'>;\n serviceConfig?: {\n onRequest: (value: SwitchConfirmWrapperValue) => TAny;\n message?: {\n success?: string;\n defaultError?: string;\n };\n };\n};\n\n/**\n *\n * @description switch 切换时做二次pop提醒, 非可控组件【内部控制】\n * @param props\n * @param value:初始值\n * @param checkedValue:选中状态值\n * @param unCheckedValue:非选中状态值\n * @param needConfirm:二次pop拦截时机 可不传 同 all close:switch 由开启转换成关闭时pop弹出、open:switch 由开启转换成开启时pop弹出all:switch 一直popnone:switch 不弹出\n * @param noMessage:不采用内置message提示\n * @param onChange:switch 有效切换回掉\n * @param popConfirmProps:popConfirm中参数 disabled title description\n * @param serviceConfig onRequest\n * @field onRequest 请求函数\n * @field message message配置 success defaultError\n * @returns RC\n */\nexport const SwitchConfirmWrapper = (props: SwitchConfirmWrapperProps) => {\n const {\n popConfirmProps,\n needConfirm,\n checkedValue,\n unCheckedValue,\n onChange,\n value,\n serviceConfig,\n noMessage,\n ...otherProps\n } = props;\n const { description, title, disabled } = popConfirmProps || {};\n const [isCheked, setIsCheked] = useState(value === checkedValue);\n const [loading, setLoading] = useState<boolean>(false);\n const showConfirm = useMemo(() => {\n return (\n (needConfirm === 'close' && isCheked) ||\n (needConfirm === 'open' && !isCheked) ||\n !needConfirm ||\n needConfirm === 'all'\n );\n }, [isCheked, needConfirm]);\n\n const onHandleChange = hooks.useCallbackRef(async () => {\n const changeValue = !isCheked ? checkedValue : unCheckedValue;\n if (serviceConfig?.onRequest) {\n try {\n setLoading(true);\n await serviceConfig.onRequest(changeValue);\n setIsCheked(!isCheked);\n onChange?.(changeValue);\n if (!noMessage) {\n void message.success(serviceConfig?.message?.success || '状态修改成功!');\n }\n } catch (error) {\n if (!noMessage) {\n void message.error(error?.message || serviceConfig?.message?.defaultError || '状态修改失败!');\n }\n } finally {\n setLoading(false);\n }\n } else {\n setIsCheked(!isCheked);\n onChange?.(changeValue);\n }\n });\n if (showConfirm) {\n return (\n <Popconfirm\n disabled={disabled}\n okButtonProps={{ loading: loading }}\n title={title}\n description={description}\n onConfirm={onHandleChange}\n >\n <Switch checked={isCheked} {...otherProps} />\n </Popconfirm>\n );\n }\n return <Switch checked={isCheked} loading={loading} {...otherProps} onChange={onHandleChange} />;\n};\n"],"names":["SwitchConfirmWrapper","props","popConfirmProps","needConfirm","checkedValue","unCheckedValue","onChange","value","serviceConfig","noMessage","otherProps","_objectWithoutPropertiesLoose","_excluded","_ref","description","title","disabled","_useState","useState","isCheked","setIsCheked","_useState2","loading","setLoading","showConfirm","useMemo","onHandleChange","_hooks","useCallbackRef","Promise","$return","$error","changeValue","_serviceConfig$messag","_serviceConfig$messag2","onRequest","$Try_1_Finally","$Try_1_Exit","$Try_1_Value","call","this","$boundEx","bind","$Try_1_Post","$If_2","$Try_1_Catch","error","message","defaultError","resolve","then","$await_3","success","_jsx","Popconfirm","okButtonProps","onConfirm","children","Switch","_extends","checked"],"mappings":";6XAuCaA,EAAuB,SAAvBA,EAAwBC,GACnC,IACEC,EASED,EATFC,gBACAC,EAQEF,EARFE,YACAC,EAOEH,EAPFG,aACAC,EAMEJ,EANFI,eACAC,EAKEL,EALFK,SACAC,EAIEN,EAJFM,MACAC,EAGEP,EAHFO,cACAC,EAEER,EAFFQ,UACGC,EAAUC,EACXV,EAAKW,GACT,IAAAC,EAAyCX,GAAmB,CAAE,EAAtDY,EAAWD,EAAXC,YAAaC,EAAKF,EAALE,MAAOC,EAAQH,EAARG,SAC5B,IAAAC,EAAgCC,EAASX,IAAUH,GAA5Ce,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GAC5B,IAAAI,EAA8BH,EAAkB,OAAzCI,EAAOD,EAAA,GAAEE,EAAUF,EAAA,GAC1B,IAAMG,EAAcC,GAAQ,WAC1B,OACGtB,IAAgB,SAAWgB,GAC3BhB,IAAgB,SAAWgB,IAC3BhB,GACDA,IAAgB,KAEpB,GAAG,CAACgB,EAAUhB,IAEd,IAAMuB,EAAiBC,EAAMC,gBAAe,WAA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AAAd,GAAA,CAAA,OAEH,GAAIN,EAAa,CACf,OACE6B,EAACC,EAAU,CACTtC,SAAUA,EACVuC,cAAe,CAAEjC,QAASA,GAC1BP,MAAOA,EACPD,YAAaA,EACb0C,UAAW9B,EAAe+B,SAE1BJ,EAACK,EAAMC,EAAA,CAACC,QAASzC,GAAcT,KAGrC,CACA,OAAO2C,EAACK,EAAMC,EAAA,CAACC,QAASzC,EAAUG,QAASA,GAAaZ,EAAU,CAAEJ,SAAUoB,IAChF"}
package/index.d.ts CHANGED
@@ -1515,7 +1515,7 @@ export interface LocalLoadingProps {
1515
1515
  /** 自定义异常渲染处理 */
1516
1516
  errorRender?: (error?: TAny) => ReactElement;
1517
1517
  /** loading高度,默认值:100;isAsync = true 无效 */
1518
- loadingHeight?: number;
1518
+ loadingHeight?: number | string;
1519
1519
  className?: string;
1520
1520
  style?: CSSProperties;
1521
1521
  contentStyle?: CSSProperties;
@@ -1998,6 +1998,40 @@ export interface SmsCountDownProps {
1998
1998
  }
1999
1999
  export declare const SmsCountDown: FC<SmsCountDownProps>;
2000
2000
  export declare const styles: () => void;
2001
+ export type SwitchConfirmWrapperValue = string | number | boolean;
2002
+ export type SwitchConfirmWrapperProps = Omit<SwitchProps, "defaultChecked" | "onChange"> & {
2003
+ value?: SwitchConfirmWrapperValue;
2004
+ checkedValue: SwitchConfirmWrapperValue;
2005
+ unCheckedValue: SwitchConfirmWrapperValue;
2006
+ needConfirm?: "close" | "open" | "all" | "none";
2007
+ noMessage?: boolean;
2008
+ onChange?: (value: SwitchConfirmWrapperValue) => void;
2009
+ popConfirmProps?: Pick<PopconfirmProps, "disabled" | "title" | "description">;
2010
+ serviceConfig?: {
2011
+ onRequest: (value: SwitchConfirmWrapperValue) => TAny;
2012
+ message?: {
2013
+ success?: string;
2014
+ defaultError?: string;
2015
+ };
2016
+ };
2017
+ };
2018
+ /**
2019
+ *
2020
+ * @description switch 切换时做二次pop提醒, 非可控组件【内部控制】
2021
+ * @param props
2022
+ * @param value:初始值
2023
+ * @param checkedValue:选中状态值
2024
+ * @param unCheckedValue:非选中状态值
2025
+ * @param needConfirm:二次pop拦截时机 可不传 同 all close:switch 由开启转换成关闭时pop弹出、open:switch 由开启转换成开启时pop弹出all:switch 一直popnone:switch 不弹出
2026
+ * @param noMessage:不采用内置message提示
2027
+ * @param onChange:switch 有效切换回掉
2028
+ * @param popConfirmProps:popConfirm中参数 disabled title description
2029
+ * @param serviceConfig onRequest
2030
+ * @field onRequest 请求函数
2031
+ * @field message message配置 success defaultError
2032
+ * @returns RC
2033
+ */
2034
+ export declare const SwitchConfirmWrapper: (props: SwitchConfirmWrapperProps) => JSX.Element;
2001
2035
  export type SwitchWrapperValue = string | number | boolean;
2002
2036
  export type SwitchWrapperProps = Omit<SwitchProps, "checked" | "defaultChecked" | "onChange"> & {
2003
2037
  value?: SwitchWrapperValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatbiz/antd",
3
- "version": "4.2.45",
3
+ "version": "4.2.46",
4
4
  "description": "flat-biz ui components",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",